@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.
@@ -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, getAuthor: A) => {
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[];
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fileSystemVersionedDocumentStore = void 0;
4
4
  const file_system_1 = require("../unversioned/file-system");
5
5
  const PAGE_LIMIT = 5;
6
- const fileSystemVersionedDocumentStore = (initializer) => () => (configProvider) => (_, hashKey, getAuthor) => {
6
+ const fileSystemVersionedDocumentStore = (initializer) => () => (configProvider) => (_, hashKey, options) => {
7
7
  const unversionedDocuments = (0, file_system_1.fileSystemUnversionedDocumentStore)(initializer)()(configProvider)({}, 'id');
8
8
  return {
9
9
  loadAllDocumentsTheBadWay: () => {
@@ -34,7 +34,7 @@ const fileSystemVersionedDocumentStore = (initializer) => () => (configProvider)
34
34
  },
35
35
  prepareItem: async (item, ...authorArgs) => {
36
36
  // this getAuthor type is terrible
37
- const author = getAuthor ? await getAuthor(...authorArgs) : authorArgs[0];
37
+ const author = (options === null || options === void 0 ? void 0 : options.getAuthor) ? await options.getAuthor(...authorArgs) : authorArgs[0];
38
38
  const timestamp = new Date().getTime();
39
39
  return {
40
40
  document: { ...item, timestamp, author },
@@ -50,7 +50,7 @@ const fileSystemVersionedDocumentStore = (initializer) => () => (configProvider)
50
50
  },
51
51
  putItem: async (item, ...authorArgs) => {
52
52
  var _a;
53
- const author = getAuthor ? await getAuthor(...authorArgs) : authorArgs[0];
53
+ const author = (options === null || options === void 0 ? void 0 : options.getAuthor) ? await options.getAuthor(...authorArgs) : authorArgs[0];
54
54
  const document = { ...item, timestamp: new Date().getTime(), author };
55
55
  const container = (_a = await unversionedDocuments.getItem(document[hashKey])) !== null && _a !== void 0 ? _a : { id: document[hashKey], items: [] };
56
56
  const updated = { ...container, items: [...container.items, document] };