@openstax/ts-utils 1.25.1-pre1 → 1.25.1-pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/services/documentStore/versioned/file-system.d.ts +3 -1
- package/dist/cjs/services/documentStore/versioned/file-system.js +3 -3
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/documentStore/versioned/file-system.d.ts +3 -1
- package/dist/esm/services/documentStore/versioned/file-system.js +3 -3
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,9 @@ interface Initializer<C> {
|
|
|
8
8
|
}
|
|
9
9
|
export declare const fileSystemVersionedDocumentStore: <C extends string = "fileSystem">(initializer: Initializer<C>) => <T extends VersionedTDocument<T>>() => (configProvider: { [key in C]: {
|
|
10
10
|
tableName: import("../../../config").ConfigValueProvider<string>;
|
|
11
|
-
}; }) => <K extends keyof T, A extends ((...a: any[]) => Promise<VersionedDocumentAuthor>) | undefined>(_: {}, hashKey: K,
|
|
11
|
+
}; }) => <K extends keyof T, A extends ((...a: any[]) => Promise<VersionedDocumentAuthor>) | undefined>(_: {}, hashKey: K, options?: {
|
|
12
|
+
getAuthor?: A | undefined;
|
|
13
|
+
} | undefined) => {
|
|
12
14
|
loadAllDocumentsTheBadWay: () => Promise<T[]>;
|
|
13
15
|
getVersions: (id: T[K], startVersion?: number | undefined) => Promise<{
|
|
14
16
|
items: T[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fileSystemUnversionedDocumentStore } from '../unversioned/file-system';
|
|
2
2
|
const PAGE_LIMIT = 5;
|
|
3
|
-
export const fileSystemVersionedDocumentStore = (initializer) => () => (configProvider) => (_, hashKey,
|
|
3
|
+
export const fileSystemVersionedDocumentStore = (initializer) => () => (configProvider) => (_, hashKey, options) => {
|
|
4
4
|
const unversionedDocuments = fileSystemUnversionedDocumentStore(initializer)()(configProvider)({}, 'id');
|
|
5
5
|
return {
|
|
6
6
|
loadAllDocumentsTheBadWay: () => {
|
|
@@ -31,7 +31,7 @@ export const fileSystemVersionedDocumentStore = (initializer) => () => (configPr
|
|
|
31
31
|
},
|
|
32
32
|
prepareItem: async (item, ...authorArgs) => {
|
|
33
33
|
// this getAuthor type is terrible
|
|
34
|
-
const author = getAuthor ? await getAuthor(...authorArgs) : authorArgs[0];
|
|
34
|
+
const author = (options === null || options === void 0 ? void 0 : options.getAuthor) ? await options.getAuthor(...authorArgs) : authorArgs[0];
|
|
35
35
|
const timestamp = new Date().getTime();
|
|
36
36
|
return {
|
|
37
37
|
document: { ...item, timestamp, author },
|
|
@@ -47,7 +47,7 @@ export const fileSystemVersionedDocumentStore = (initializer) => () => (configPr
|
|
|
47
47
|
},
|
|
48
48
|
putItem: async (item, ...authorArgs) => {
|
|
49
49
|
var _a;
|
|
50
|
-
const author = getAuthor ? await getAuthor(...authorArgs) : authorArgs[0];
|
|
50
|
+
const author = (options === null || options === void 0 ? void 0 : options.getAuthor) ? await options.getAuthor(...authorArgs) : authorArgs[0];
|
|
51
51
|
const document = { ...item, timestamp: new Date().getTime(), author };
|
|
52
52
|
const container = (_a = await unversionedDocuments.getItem(document[hashKey])) !== null && _a !== void 0 ? _a : { id: document[hashKey], items: [] };
|
|
53
53
|
const updated = { ...container, items: [...container.items, document] };
|