Skip to content

Commit

Permalink
refactor: update StoreFileStat type to make extension property optional
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Aug 31, 2024
1 parent de15678 commit e75a186
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/engine/demo/collection.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ async function quickstart() {
alwatrStore.defineStoreFile({
...postsCollectionId,
type: StoreFileType.Collection,
extension: StoreFileExtension.Json,
});

// Get a collection reference.
Expand Down
4 changes: 2 additions & 2 deletions packages/reference/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {flatString} from '@alwatr/flat-string';
import {type StoreFileId, type StoreFileStat} from '@alwatr/store-types';
import {StoreFileExtension, type StoreFileId, type StoreFileStat} from '@alwatr/store-types';

/**
* Convert StoreFileId to a string ID.
Expand All @@ -26,6 +26,6 @@ export function getStorePath(storeStat: StoreFileStat): string {
if (storeStat.ownerId !== undefined) {
path += '/' + storeStat.ownerId.slice(0, 3) + '/' + storeStat.ownerId;
}
path += `/${storeStat.name}.${storeStat.type}.${storeStat.extension}`;
path += `/${storeStat.name}.${storeStat.type}.${storeStat.extension ?? StoreFileExtension.Json}`;
return flatString(path);
}
2 changes: 1 addition & 1 deletion packages/types/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export type StoreFileStat = StoreFileId & {
*
* @see {@link StoreFileExtension}
*/
readonly extension: StoreFileExtension;
readonly extension?: StoreFileExtension;

/**
* The save debounce timeout in milliseconds for minimal disk I/O usage.
Expand Down

0 comments on commit e75a186

Please sign in to comment.