@workglow/storage 0.0.85 → 0.0.86

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.
Files changed (108) hide show
  1. package/README.md +185 -53
  2. package/dist/browser.js +451 -188
  3. package/dist/browser.js.map +21 -18
  4. package/dist/bun.js +1069 -356
  5. package/dist/bun.js.map +29 -24
  6. package/dist/common-server.d.ts +17 -15
  7. package/dist/common-server.d.ts.map +1 -1
  8. package/dist/common.d.ts +13 -10
  9. package/dist/common.d.ts.map +1 -1
  10. package/dist/kv/{FsFolderJsonKvRepository.d.ts → FsFolderJsonKvStorage.d.ts} +8 -8
  11. package/dist/kv/FsFolderJsonKvStorage.d.ts.map +1 -0
  12. package/dist/kv/{FsFolderKvRepository.d.ts → FsFolderKvStorage.d.ts} +7 -7
  13. package/dist/kv/FsFolderKvStorage.d.ts.map +1 -0
  14. package/dist/kv/{IKvRepository.d.ts → IKvStorage.d.ts} +3 -3
  15. package/dist/kv/IKvStorage.d.ts.map +1 -0
  16. package/dist/kv/{InMemoryKvRepository.d.ts → InMemoryKvStorage.d.ts} +8 -8
  17. package/dist/kv/InMemoryKvStorage.d.ts.map +1 -0
  18. package/dist/kv/{IndexedDbKvRepository.d.ts → IndexedDbKvStorage.d.ts} +8 -8
  19. package/dist/kv/IndexedDbKvStorage.d.ts.map +1 -0
  20. package/dist/kv/{KvRepository.d.ts → KvStorage.d.ts} +7 -7
  21. package/dist/kv/KvStorage.d.ts.map +1 -0
  22. package/dist/kv/{KvViaTabularRepository.d.ts → KvViaTabularStorage.d.ts} +7 -7
  23. package/dist/kv/KvViaTabularStorage.d.ts.map +1 -0
  24. package/dist/kv/{PostgresKvRepository.d.ts → PostgresKvStorage.d.ts} +8 -8
  25. package/dist/kv/PostgresKvStorage.d.ts.map +1 -0
  26. package/dist/kv/{SqliteKvRepository.d.ts → SqliteKvStorage.d.ts} +8 -8
  27. package/dist/kv/SqliteKvStorage.d.ts.map +1 -0
  28. package/dist/kv/{SupabaseKvRepository.d.ts → SupabaseKvStorage.d.ts} +9 -9
  29. package/dist/kv/SupabaseKvStorage.d.ts.map +1 -0
  30. package/dist/node.js +1069 -356
  31. package/dist/node.js.map +29 -24
  32. package/dist/queue-limiter/IRateLimiterStorage.d.ts.map +1 -0
  33. package/dist/queue-limiter/InMemoryRateLimiterStorage.d.ts.map +1 -0
  34. package/dist/queue-limiter/IndexedDbRateLimiterStorage.d.ts.map +1 -0
  35. package/dist/queue-limiter/PostgresRateLimiterStorage.d.ts.map +1 -0
  36. package/dist/queue-limiter/SqliteRateLimiterStorage.d.ts.map +1 -0
  37. package/dist/queue-limiter/SupabaseRateLimiterStorage.d.ts.map +1 -0
  38. package/dist/tabular/{BaseSqlTabularRepository.d.ts → BaseSqlTabularStorage.d.ts} +8 -7
  39. package/dist/tabular/BaseSqlTabularStorage.d.ts.map +1 -0
  40. package/dist/tabular/{TabularRepository.d.ts → BaseTabularStorage.d.ts} +52 -10
  41. package/dist/tabular/BaseTabularStorage.d.ts.map +1 -0
  42. package/dist/tabular/{CachedTabularRepository.d.ts → CachedTabularStorage.d.ts} +15 -14
  43. package/dist/tabular/CachedTabularStorage.d.ts.map +1 -0
  44. package/dist/tabular/{FsFolderTabularRepository.d.ts → FsFolderTabularStorage.d.ts} +22 -12
  45. package/dist/tabular/FsFolderTabularStorage.d.ts.map +1 -0
  46. package/dist/tabular/{ITabularRepository.d.ts → ITabularStorage.d.ts} +29 -6
  47. package/dist/tabular/ITabularStorage.d.ts.map +1 -0
  48. package/dist/tabular/{InMemoryTabularRepository.d.ts → InMemoryTabularStorage.d.ts} +24 -14
  49. package/dist/tabular/InMemoryTabularStorage.d.ts.map +1 -0
  50. package/dist/tabular/{IndexedDbTabularRepository.d.ts → IndexedDbTabularStorage.d.ts} +20 -11
  51. package/dist/tabular/IndexedDbTabularStorage.d.ts.map +1 -0
  52. package/dist/tabular/{PostgresTabularRepository.d.ts → PostgresTabularStorage.d.ts} +37 -15
  53. package/dist/tabular/PostgresTabularStorage.d.ts.map +1 -0
  54. package/dist/tabular/{SharedInMemoryTabularRepository.d.ts → SharedInMemoryTabularStorage.d.ts} +14 -13
  55. package/dist/tabular/SharedInMemoryTabularStorage.d.ts.map +1 -0
  56. package/dist/tabular/{SqliteTabularRepository.d.ts → SqliteTabularStorage.d.ts} +25 -11
  57. package/dist/tabular/SqliteTabularStorage.d.ts.map +1 -0
  58. package/dist/tabular/{SupabaseTabularRepository.d.ts → SupabaseTabularStorage.d.ts} +17 -15
  59. package/dist/tabular/SupabaseTabularStorage.d.ts.map +1 -0
  60. package/dist/tabular/TabularStorageRegistry.d.ts +29 -0
  61. package/dist/tabular/TabularStorageRegistry.d.ts.map +1 -0
  62. package/dist/util/IndexedDbTable.d.ts +1 -1
  63. package/dist/util/IndexedDbTable.d.ts.map +1 -1
  64. package/dist/vector/IVectorStorage.d.ts +83 -0
  65. package/dist/vector/IVectorStorage.d.ts.map +1 -0
  66. package/dist/vector/InMemoryVectorStorage.d.ts +41 -0
  67. package/dist/vector/InMemoryVectorStorage.d.ts.map +1 -0
  68. package/dist/vector/PostgresVectorStorage.d.ts +57 -0
  69. package/dist/vector/PostgresVectorStorage.d.ts.map +1 -0
  70. package/dist/vector/SqliteVectorStorage.d.ts +45 -0
  71. package/dist/vector/SqliteVectorStorage.d.ts.map +1 -0
  72. package/package.json +5 -5
  73. package/src/kv/README.md +3 -3
  74. package/src/tabular/README.md +186 -23
  75. package/src/vector/README.md +393 -0
  76. package/dist/kv/FsFolderJsonKvRepository.d.ts.map +0 -1
  77. package/dist/kv/FsFolderKvRepository.d.ts.map +0 -1
  78. package/dist/kv/IKvRepository.d.ts.map +0 -1
  79. package/dist/kv/InMemoryKvRepository.d.ts.map +0 -1
  80. package/dist/kv/IndexedDbKvRepository.d.ts.map +0 -1
  81. package/dist/kv/KvRepository.d.ts.map +0 -1
  82. package/dist/kv/KvViaTabularRepository.d.ts.map +0 -1
  83. package/dist/kv/PostgresKvRepository.d.ts.map +0 -1
  84. package/dist/kv/SqliteKvRepository.d.ts.map +0 -1
  85. package/dist/kv/SupabaseKvRepository.d.ts.map +0 -1
  86. package/dist/limiter/IRateLimiterStorage.d.ts.map +0 -1
  87. package/dist/limiter/InMemoryRateLimiterStorage.d.ts.map +0 -1
  88. package/dist/limiter/IndexedDbRateLimiterStorage.d.ts.map +0 -1
  89. package/dist/limiter/PostgresRateLimiterStorage.d.ts.map +0 -1
  90. package/dist/limiter/SqliteRateLimiterStorage.d.ts.map +0 -1
  91. package/dist/limiter/SupabaseRateLimiterStorage.d.ts.map +0 -1
  92. package/dist/tabular/BaseSqlTabularRepository.d.ts.map +0 -1
  93. package/dist/tabular/CachedTabularRepository.d.ts.map +0 -1
  94. package/dist/tabular/FsFolderTabularRepository.d.ts.map +0 -1
  95. package/dist/tabular/ITabularRepository.d.ts.map +0 -1
  96. package/dist/tabular/InMemoryTabularRepository.d.ts.map +0 -1
  97. package/dist/tabular/IndexedDbTabularRepository.d.ts.map +0 -1
  98. package/dist/tabular/PostgresTabularRepository.d.ts.map +0 -1
  99. package/dist/tabular/SharedInMemoryTabularRepository.d.ts.map +0 -1
  100. package/dist/tabular/SqliteTabularRepository.d.ts.map +0 -1
  101. package/dist/tabular/SupabaseTabularRepository.d.ts.map +0 -1
  102. package/dist/tabular/TabularRepository.d.ts.map +0 -1
  103. /package/dist/{limiter → queue-limiter}/IRateLimiterStorage.d.ts +0 -0
  104. /package/dist/{limiter → queue-limiter}/InMemoryRateLimiterStorage.d.ts +0 -0
  105. /package/dist/{limiter → queue-limiter}/IndexedDbRateLimiterStorage.d.ts +0 -0
  106. /package/dist/{limiter → queue-limiter}/PostgresRateLimiterStorage.d.ts +0 -0
  107. /package/dist/{limiter → queue-limiter}/SqliteRateLimiterStorage.d.ts +0 -0
  108. /package/dist/{limiter → queue-limiter}/SupabaseRateLimiterStorage.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRateLimiterStorage.d.ts","sourceRoot":"","sources":["../../src/queue-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;IACH,OAAO,CAAC,kBAAkB;IAQ1B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAQhB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAmD9B,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWjD,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAe9E,0BAA0B,CACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAiBjB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAmBpE,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB/E,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAcrD"}
@@ -3,9 +3,9 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { DataPortSchemaObject, FromSchema, JsonSchema } from "@workglow/util";
7
- import { ValueOptionType } from "./ITabularRepository";
8
- import { TabularRepository } from "./TabularRepository";
6
+ import { DataPortSchemaObject, FromSchema, JsonSchema, TypedArraySchemaOptions } from "@workglow/util";
7
+ import { BaseTabularStorage, ClientProvidedKeysOption } from "./BaseTabularStorage";
8
+ import { AutoGeneratedKeys, InsertEntity, SimplifyPrimaryKey, ValueOptionType } from "./ITabularStorage";
9
9
  /**
10
10
  * Base class for SQL-based tabular repositories that implements common functionality
11
11
  * for both SQLite and PostgreSQL database implementations.
@@ -13,17 +13,18 @@ import { TabularRepository } from "./TabularRepository";
13
13
  * @template Schema - The schema definition for the entity using JSON Schema
14
14
  * @template PrimaryKeyNames - Array of property names that form the primary key
15
15
  */
16
- export declare abstract class BaseSqlTabularRepository<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema>, PrimaryKey = Pick<Entity, PrimaryKeyNames[number] & keyof Entity>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>> extends TabularRepository<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value> {
16
+ export declare abstract class BaseSqlTabularStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema, TypedArraySchemaOptions>, PrimaryKey = SimplifyPrimaryKey<Entity, PrimaryKeyNames>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>, InsertType extends InsertEntity<Entity, AutoGeneratedKeys<Schema>> = InsertEntity<Entity, AutoGeneratedKeys<Schema>>> extends BaseTabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value, InsertType> {
17
17
  protected readonly table: string;
18
18
  /**
19
- * Creates a new instance of BaseSqlTabularRepository
19
+ * Creates a new instance of BaseSqlTabularStorage
20
20
  * @param table - The name of the database table to use for storage
21
21
  * @param schema - Schema defining the structure of the entity
22
22
  * @param primaryKeyNames - Array of property names that form the primary key
23
23
  * @param indexes - Array of columns or column arrays to make searchable. Each string or single column creates a single-column index,
24
24
  * while each array creates a compound index with columns in the specified order.
25
+ * @param clientProvidedKeys - How to handle client-provided values for auto-generated keys
25
26
  */
26
- constructor(table: string | undefined, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[]);
27
+ constructor(table: string | undefined, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[], clientProvidedKeys?: ClientProvidedKeysOption);
27
28
  /**
28
29
  * Maps JavaScript/TypeScript types to their corresponding SQL type
29
30
  * Must be implemented by derived classes for specific SQL dialects
@@ -91,4 +92,4 @@ export declare abstract class BaseSqlTabularRepository<Schema extends DataPortSc
91
92
  */
92
93
  protected validateTableAndSchema(): void;
93
94
  }
94
- //# sourceMappingURL=BaseSqlTabularRepository.d.ts.map
95
+ //# sourceMappingURL=BaseSqlTabularStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseSqlTabularStorage.d.ts","sourceRoot":"","sources":["../../src/tabular/BaseSqlTabularStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAI3B;;;;;;GAMG;AACH,8BAAsB,qBAAqB,CACzC,MAAM,SAAS,oBAAoB,EACnC,eAAe,SAAS,aAAa,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,EAEjE,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,uBAAuB,CAAC,EACpD,UAAU,GAAG,kBAAkB,CAAC,MAAM,EAAE,eAAe,CAAC,EACxD,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,EAC5D,UAAU,SAAS,YAAY,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAC/E,MAAM,EACN,iBAAiB,CAAC,MAAM,CAAC,CAC1B,CACD,SAAQ,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC;IAWxF,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAVlC;;;;;;;;OAQG;gBAEkB,KAAK,EAAE,MAAM,YAAkB,EAClD,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,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5
5
  */
6
- import { DataPortSchemaObject, EventEmitter, FromSchema } from "@workglow/util";
7
- import { DeleteSearchCriteria, ITabularRepository, TabularChangePayload, TabularEventListener, TabularEventListeners, TabularEventName, TabularEventParameters, TabularSubscribeOptions, ValueOptionType } from "./ITabularRepository";
8
- export declare const TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<ITabularRepository<any, any, any, any, any>>;
6
+ import { DataPortSchemaObject, EventEmitter, FromSchema, TypedArraySchemaOptions } from "@workglow/util";
7
+ import { AnyTabularStorage, AutoGeneratedKeys, DeleteSearchCriteria, InsertEntity, ITabularStorage, SimplifyPrimaryKey, TabularChangePayload, TabularEventListener, TabularEventListeners, TabularEventName, TabularEventParameters, TabularSubscribeOptions, ValueOptionType } from "./ITabularStorage";
8
+ export declare const TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<AnyTabularStorage>;
9
+ /**
10
+ * Options for controlling how client-provided values for auto-generated keys are handled
11
+ */
12
+ export type ClientProvidedKeysOption = "never" | "if-missing" | "always";
13
+ /**
14
+ * Generation strategy for auto-generated keys
15
+ */
16
+ export type KeyGenerationStrategy = "autoincrement" | "uuid";
9
17
  /**
10
18
  * Abstract base class for tabular storage repositories.
11
19
  * Provides functionality for storing and retrieving data with typed
@@ -15,7 +23,7 @@ export declare const TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<I
15
23
  * @template Schema - The schema definition for the entity using JSON Schema
16
24
  * @template PrimaryKeyNames - Array of property names that form the primary key
17
25
  */
18
- export declare abstract class TabularRepository<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema>, PrimaryKey = Pick<Entity, PrimaryKeyNames[number] & keyof Entity>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>> implements ITabularRepository<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value> {
26
+ export declare abstract class BaseTabularStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema, TypedArraySchemaOptions>, PrimaryKey = SimplifyPrimaryKey<Entity, PrimaryKeyNames>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>, InsertType = InsertEntity<Entity, AutoGeneratedKeys<Schema>>> implements ITabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey, InsertType> {
19
27
  protected schema: Schema;
20
28
  protected primaryKeyNames: PrimaryKeyNames;
21
29
  /** Event emitter for repository events */
@@ -23,14 +31,21 @@ export declare abstract class TabularRepository<Schema extends DataPortSchemaObj
23
31
  protected indexes: Array<keyof Entity>[];
24
32
  protected primaryKeySchema: DataPortSchemaObject;
25
33
  protected valueSchema: DataPortSchemaObject;
26
- /**
27
- * Creates a new TabularRepository instance
34
+ /** Name of the auto-generated key column (only first primary key column can be auto-generated) */
35
+ protected autoGeneratedKeyName: keyof Entity | null;
36
+ /** Strategy for generating the auto-generated key */
37
+ protected autoGeneratedKeyStrategy: KeyGenerationStrategy | null;
38
+ /** How to handle client-provided values for auto-generated keys */
39
+ protected clientProvidedKeys: ClientProvidedKeysOption;
40
+ /**
41
+ * Creates a new BaseTabularStorage instance
28
42
  * @param schema - Schema defining the structure of the entity
29
43
  * @param primaryKeyNames - Array of property names that form the primary key
30
44
  * @param indexes - Array of columns or column arrays to make searchable. Each string or single column creates a single-column index,
31
45
  * while each array creates a compound index with columns in the specified order.
46
+ * @param clientProvidedKeys - How to handle client-provided values for auto-generated keys
32
47
  */
33
- constructor(schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[]);
48
+ constructor(schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[], clientProvidedKeys?: ClientProvidedKeysOption);
34
49
  protected filterCompoundKeys(primaryKey: Array<keyof Entity>, potentialKeys: Array<keyof Entity>[]): Array<keyof Entity>[];
35
50
  /**
36
51
  * Adds an event listener for a specific event
@@ -65,8 +80,8 @@ export declare abstract class TabularRepository<Schema extends DataPortSchemaObj
65
80
  /**
66
81
  * Core abstract methods that must be implemented by concrete repositories
67
82
  */
68
- abstract put(value: Entity): Promise<Entity>;
69
- abstract putBulk(values: Entity[]): Promise<Entity[]>;
83
+ abstract put(value: InsertType): Promise<Entity>;
84
+ abstract putBulk(values: InsertType[]): Promise<Entity[]>;
70
85
  abstract get(key: PrimaryKey): Promise<Entity | undefined>;
71
86
  abstract delete(key: PrimaryKey | Entity): Promise<void>;
72
87
  abstract getAll(): Promise<Entity[] | undefined>;
@@ -129,6 +144,33 @@ export declare abstract class TabularRepository<Schema extends DataPortSchemaObj
129
144
  * @returns Array of column names representing the best matching index, or undefined if no suitable index is found
130
145
  */
131
146
  findBestMatchingIndex(unorderedSearchKey: Array<keyof Entity>): Array<keyof Entity> | undefined;
147
+ /**
148
+ * Checks if this storage has an auto-generated key configured
149
+ * @returns true if an auto-generated key is configured
150
+ */
151
+ protected hasAutoGeneratedKey(): boolean;
152
+ /**
153
+ * Checks if a given column name is the auto-generated key
154
+ * @param name - Column name to check
155
+ * @returns true if the column is the auto-generated key
156
+ */
157
+ protected isAutoGeneratedKey(name: string): boolean;
158
+ /**
159
+ * Determines the generation strategy for an auto-generated key based on its type
160
+ * @param columnName - Name of the column
161
+ * @param typeDef - JSON Schema type definition for the column
162
+ * @returns The generation strategy to use
163
+ */
164
+ protected determineGenerationStrategy(columnName: string, typeDef: any): KeyGenerationStrategy;
165
+ /**
166
+ * Generates a key value for client-side key generation
167
+ * Override in storage classes that generate keys client-side (InMemory, IndexedDB for UUIDs)
168
+ * SQL-based storages typically generate keys server-side
169
+ * @param columnName - Name of the column to generate a key for
170
+ * @param strategy - The generation strategy to use
171
+ * @returns The generated key value
172
+ */
173
+ protected generateKeyValue(columnName: string, strategy: KeyGenerationStrategy): Promise<string | number> | string | number;
132
174
  /**
133
175
  * Sets up the database/storage for the repository.
134
176
  * Must be called before using any other methods (except for in-memory implementations).
@@ -142,4 +184,4 @@ export declare abstract class TabularRepository<Schema extends DataPortSchemaObj
142
184
  [Symbol.asyncDispose](): Promise<void>;
143
185
  [Symbol.dispose](): void;
144
186
  }
145
- //# sourceMappingURL=TabularRepository.d.ts.map
187
+ //# sourceMappingURL=BaseTabularStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseTabularStorage.d.ts","sourceRoot":"","sources":["../../src/tabular/BaseTabularStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,oBAAoB,EACpB,YAAY,EACZ,UAAU,EAEV,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,kBAAkB,0DAE9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG,MAAM,CAAC;AAE7D;;;;;;;;GAQG;AACH,8BAAsB,kBAAkB,CACtC,MAAM,SAAS,oBAAoB,EACnC,eAAe,SAAS,aAAa,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,EAEjE,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,uBAAuB,CAAC,EACpD,UAAU,GAAG,kBAAkB,CAAC,MAAM,EAAE,eAAe,CAAC,EACxD,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,EAC5D,UAAU,GAAG,YAAY,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAC5D,YAAW,eAAe,CAAC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T,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB"}
@@ -3,33 +3,34 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { DataPortSchemaObject, FromSchema } from "@workglow/util";
7
- import { DeleteSearchCriteria, ITabularRepository, TabularSubscribeOptions } from "./ITabularRepository";
8
- import { TabularRepository } from "./TabularRepository";
9
- export declare const CACHED_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<ITabularRepository<any, any, any, any, any>>;
6
+ import { DataPortSchemaObject, FromSchema, TypedArraySchemaOptions } from "@workglow/util";
7
+ import { BaseTabularStorage, ClientProvidedKeysOption } from "./BaseTabularStorage";
8
+ import { AnyTabularStorage, AutoGeneratedKeys, DeleteSearchCriteria, InsertEntity, ITabularStorage, SimplifyPrimaryKey, TabularSubscribeOptions } from "./ITabularStorage";
9
+ export declare const CACHED_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<AnyTabularStorage>;
10
10
  /**
11
11
  * A tabular repository wrapper that adds caching layer to a durable repository.
12
- * Uses InMemoryTabularRepository or SharedInMemoryTabularRepository as a cache
12
+ * Uses InMemoryTabularStorage or SharedInMemoryTabularStorage as a cache
13
13
  * for faster access to frequently used data.
14
14
  *
15
15
  * @template Schema - The schema definition for the entity using JSON Schema
16
16
  * @template PrimaryKeyNames - Array of property names that form the primary key
17
17
  */
18
- export declare class CachedTabularRepository<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema>, PrimaryKey = Pick<Entity, PrimaryKeyNames[number] & keyof Entity>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>> extends TabularRepository<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value> {
19
- readonly cache: ITabularRepository<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value>;
18
+ export declare class CachedTabularStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema, TypedArraySchemaOptions>, PrimaryKey = SimplifyPrimaryKey<Entity, PrimaryKeyNames>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>, InsertType extends InsertEntity<Entity, AutoGeneratedKeys<Schema>> = InsertEntity<Entity, AutoGeneratedKeys<Schema>>> extends BaseTabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value, InsertType> {
19
+ readonly cache: ITabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey>;
20
20
  private durable;
21
21
  private cacheInitialized;
22
22
  /**
23
- * Creates a new CachedTabularRepository instance
23
+ * Creates a new CachedTabularStorage instance
24
24
  * @param durable - The durable repository to use as the source of truth
25
- * @param cache - Optional cache repository (InMemoryTabularRepository or SharedInMemoryTabularRepository).
26
- * If not provided, a new InMemoryTabularRepository will be created.
25
+ * @param cache - Optional cache repository (InMemoryTabularStorage or SharedInMemoryTabularStorage).
26
+ * If not provided, a new InMemoryTabularStorage will be created.
27
27
  * @param schema - Schema defining the structure of the entity
28
28
  * @param primaryKeyNames - Array of property names that form the primary key
29
29
  * @param indexes - Array of columns or column arrays to make searchable. Each string or single column creates a single-column index,
30
30
  * while each array creates a compound index with columns in the specified order.
31
+ * @param clientProvidedKeys - How to handle client-provided values for auto-generated keys
31
32
  */
32
- constructor(durable: ITabularRepository<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value>, cache?: ITabularRepository<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value>, schema?: Schema, primaryKeyNames?: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[]);
33
+ constructor(durable: ITabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey>, cache?: ITabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey>, schema?: Schema, primaryKeyNames?: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[], clientProvidedKeys?: ClientProvidedKeysOption);
33
34
  /**
34
35
  * Sets up event forwarding from cache and durable repositories
35
36
  */
@@ -44,14 +45,14 @@ export declare class CachedTabularRepository<Schema extends DataPortSchemaObject
44
45
  * @returns The stored entity
45
46
  * @emits 'put' event with the stored entity when successful
46
47
  */
47
- put(value: Entity): Promise<Entity>;
48
+ put(value: InsertType): Promise<Entity>;
48
49
  /**
49
50
  * Stores multiple key-value pairs in both cache and durable repository
50
51
  * @param values - Array of combined objects to store
51
52
  * @returns Array of stored entities
52
53
  * @emits 'put' event for each value stored
53
54
  */
54
- putBulk(values: Entity[]): Promise<Entity[]>;
55
+ putBulk(values: InsertType[]): Promise<Entity[]>;
55
56
  /**
56
57
  * Retrieves a value by its key, checking cache first, then durable repository
57
58
  * @param key - The primary key object to look up
@@ -117,4 +118,4 @@ export declare class CachedTabularRepository<Schema extends DataPortSchemaObject
117
118
  */
118
119
  destroy(): void;
119
120
  }
120
- //# sourceMappingURL=CachedTabularRepository.d.ts.map
121
+ //# sourceMappingURL=CachedTabularStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CachedTabularStorage.d.ts","sourceRoot":"","sources":["../../src/tabular/CachedTabularStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,oBAAoB,EACpB,UAAU,EACV,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEpF,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,yBAAyB,0DAErC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,oBAAoB,CAC/B,MAAM,SAAS,oBAAoB,EACnC,eAAe,SAAS,aAAa,CA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,OAAO,CAAC,MAAM,EAAE,CAAC;IAYtD;;;;;OAKG;IACG,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAiBvD;;;;;OAKG;IACG,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC;IAiBjE;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUvD;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAUhC;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC;IAiB7C;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAO7B;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUzE;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtC;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnC;;;;;;;;OAQG;IACH,kBAAkB,CAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,EAC/B,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,IAAI;IAmBb;;OAEG;IACH,OAAO,IAAI,IAAI;CAIhB"}
@@ -3,10 +3,10 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { DataPortSchemaObject, FromSchema } from "@workglow/util";
7
- import { DeleteSearchCriteria, ITabularRepository, TabularChangePayload, TabularSubscribeOptions } from "./ITabularRepository";
8
- import { TabularRepository } from "./TabularRepository";
9
- export declare const FS_FOLDER_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<ITabularRepository<any, any, any, any, any>>;
6
+ import { DataPortSchemaObject, FromSchema, TypedArraySchemaOptions } from "@workglow/util";
7
+ import { BaseTabularStorage, ClientProvidedKeysOption, KeyGenerationStrategy } from "./BaseTabularStorage";
8
+ import { AnyTabularStorage, AutoGeneratedKeys, DeleteSearchCriteria, InsertEntity, SimplifyPrimaryKey, TabularChangePayload, TabularSubscribeOptions } from "./ITabularStorage";
9
+ export declare const FS_FOLDER_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<AnyTabularStorage>;
10
10
  /**
11
11
  * A tabular repository implementation that uses the filesystem for storage.
12
12
  * Each row is stored as a separate JSON file in the specified directory.
@@ -14,37 +14,47 @@ export declare const FS_FOLDER_TABULAR_REPOSITORY: import("@workglow/util").Serv
14
14
  * @template Schema - The schema definition for the entity
15
15
  * @template PrimaryKeyNames - Array of property names that form the primary key
16
16
  */
17
- export declare class FsFolderTabularRepository<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema>, PrimaryKey = Pick<Entity, PrimaryKeyNames[number] & keyof Entity>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>> extends TabularRepository<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value> {
17
+ export declare class FsFolderTabularStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema, TypedArraySchemaOptions>, PrimaryKey = SimplifyPrimaryKey<Entity, PrimaryKeyNames>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>, InsertType = InsertEntity<Entity, AutoGeneratedKeys<Schema>>> extends BaseTabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value, InsertType> {
18
18
  private folderPath;
19
+ /** Counter for auto-incrementing integer keys */
20
+ private autoIncrementCounter;
19
21
  /** Shared polling subscription manager */
20
22
  private pollingManager;
21
23
  /**
22
- * Creates a new FsFolderTabularRepository instance.
24
+ * Creates a new FsFolderTabularStorage instance.
23
25
  *
24
26
  * @param folderPath - The directory path where the JSON files will be stored
25
27
  * @param schema - Schema defining the structure of the entity
26
28
  * @param primaryKeyNames - Array of property names that form the primary key
27
29
  * @param indexes - Note: indexes are not supported in this implementation.
30
+ * @param clientProvidedKeys - How to handle client-provided values for auto-generated keys
28
31
  */
29
- constructor(folderPath: string, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[]);
32
+ constructor(folderPath: string, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[], clientProvidedKeys?: ClientProvidedKeysOption);
30
33
  /**
31
34
  * Sets up the directory for the repository (creates directory)
32
35
  */
33
36
  setupDirectory(): Promise<void>;
37
+ /**
38
+ * Generates a key value for auto-generated keys
39
+ * @param columnName - Name of the column to generate a key for
40
+ * @param strategy - The generation strategy to use
41
+ * @returns The generated key value
42
+ */
43
+ protected generateKeyValue(columnName: string, strategy: KeyGenerationStrategy): string | number;
34
44
  /**
35
45
  * Stores a row in the repository
36
- * @param entity - The entity to store
46
+ * @param entity - The entity to store (may be missing auto-generated keys)
37
47
  * @returns The stored entity
38
48
  * @emits 'put' event when successful
39
49
  */
40
- put(entity: Entity): Promise<Entity>;
50
+ put(entity: InsertType): Promise<Entity>;
41
51
  /**
42
52
  * Stores multiple rows in the repository in a bulk operation
43
- * @param entities - Array of entities to store
53
+ * @param entities - Array of entities to store (may be missing auto-generated keys)
44
54
  * @returns Array of stored entities
45
55
  * @emits 'put' event for each entity stored
46
56
  */
47
- putBulk(entities: Entity[]): Promise<Entity[]>;
57
+ putBulk(entities: InsertType[]): Promise<Entity[]>;
48
58
  /**
49
59
  * Retrieves a value by its key
50
60
  * @param key - The primary key object to look up
@@ -110,4 +120,4 @@ export declare class FsFolderTabularRepository<Schema extends DataPortSchemaObje
110
120
  */
111
121
  destroy(): void;
112
122
  }
113
- //# sourceMappingURL=FsFolderTabularRepository.d.ts.map
123
+ //# sourceMappingURL=FsFolderTabularStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsFolderTabularStorage.d.ts","sourceRoot":"","sources":["../../src/tabular/FsFolderTabularStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,oBAAoB,EACpB,UAAU,EAGV,uBAAuB,EAExB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,4BAA4B,0DAExC,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,sBAAsB,CACjC,MAAM,SAAS,oBAAoB,EACnC,eAAe,SAAS,aAAa,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,EAEjE,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,uBAAuB,CAAC,EACpD,UAAU,GAAG,kBAAkB,CAAC,MAAM,EAAE,eAAe,CAAC,EACxD,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,EAC5D,UAAU,GAAG,YAAY,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAC5D,SAAQ,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC;IAC1F,OAAO,CAAC,UAAU,CAAS;IAC3B,iDAAiD;IACjD,OAAO,CAAC,oBAAoB,CAAK;IACjC,0CAA0C;IAC1C,OAAO,CAAC,cAAc,CAIN;IAEhB;;;;;;;;OAQG;gBAED,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,eAAe,E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AAoB,CAAC,MAAM,CAAC,KAAK,IAAI,EACxD,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,IAAI;IAQb;;OAEG;IACH,OAAO,IAAI,IAAI;CAOhB"}
@@ -3,7 +3,7 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { DataPortSchemaObject, EventParameters, FromSchema } from "@workglow/util";
6
+ import { DataPortSchemaObject, EventParameters, FromSchema, TypedArraySchemaOptions } from "@workglow/util";
7
7
  export type ValueOptionType = string | number | bigint | boolean | null | Uint8Array;
8
8
  /**
9
9
  * Type definitions for tabular repository events
@@ -37,7 +37,9 @@ export interface TabularSubscribeOptions {
37
37
  /** Polling interval in milliseconds (used by implementations that rely on polling) */
38
38
  readonly pollingIntervalMs?: number;
39
39
  }
40
- export type uuid4 = string;
40
+ export type uuid4 = string & {
41
+ readonly __brand: "uuid4";
42
+ };
41
43
  export type JSONValue = string | number | boolean | null | JSONValue[] | {
42
44
  [key: string]: JSONValue;
43
45
  };
@@ -73,6 +75,26 @@ export type DeleteSearchCriteria<Entity> = {
73
75
  * Type guard to check if a value is a SearchCondition
74
76
  */
75
77
  export declare function isSearchCondition<T>(value: unknown): value is SearchCondition<T>;
78
+ /**
79
+ * Helper type to compute PrimaryKey while deferring Entity resolution.
80
+ * Uses a conditional type to avoid forcing full Entity resolution at class definition time.
81
+ *
82
+ */
83
+ export type SimplifyPrimaryKey<Entity, KeyName extends ReadonlyArray<keyof any>> = Entity extends any ? Pick<Entity, Extract<KeyName[number], keyof Entity>> : never;
84
+ /**
85
+ * Extracts property names marked as auto-generated from the schema.
86
+ * Properties with `x-auto-generated: true` are considered auto-generated.
87
+ */
88
+ export type AutoGeneratedKeys<Schema extends DataPortSchemaObject> = {
89
+ [K in keyof Schema["properties"]]: Schema["properties"][K] extends {
90
+ "x-auto-generated": true;
91
+ } ? K : never;
92
+ }[keyof Schema["properties"]];
93
+ /**
94
+ * Entity type for insertion - auto-generated keys are optional.
95
+ * This allows clients to omit auto-generated keys when inserting entities.
96
+ */
97
+ export type InsertEntity<Entity, AutoGenKeys> = Omit<Entity, AutoGenKeys & keyof Entity> & Partial<Pick<Entity, AutoGenKeys & keyof Entity>>;
76
98
  /**
77
99
  * Interface defining the contract for tabular storage repositories.
78
100
  * Provides a flexible interface for storing and retrieving data with typed
@@ -81,9 +103,9 @@ export declare function isSearchCondition<T>(value: unknown): value is SearchCon
81
103
  * @typeParam Schema - The schema definition for the entity using JSON Schema
82
104
  * @typeParam PrimaryKeyNames - Array of property names that form the primary key
83
105
  */
84
- export interface ITabularRepository<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema>, PrimaryKey = Pick<Entity, PrimaryKeyNames[number] & keyof Entity>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>> {
85
- put(value: Entity): Promise<Entity>;
86
- putBulk(values: Entity[]): Promise<Entity[]>;
106
+ export interface ITabularStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema, TypedArraySchemaOptions>, PrimaryKey = SimplifyPrimaryKey<Entity, PrimaryKeyNames>, InsertType = InsertEntity<Entity, AutoGeneratedKeys<Schema>>> {
107
+ put(value: InsertType): Promise<Entity>;
108
+ putBulk(values: InsertType[]): Promise<Entity[]>;
87
109
  get(key: PrimaryKey): Promise<Entity | undefined>;
88
110
  delete(key: PrimaryKey | Entity): Promise<void>;
89
111
  getAll(): Promise<Entity[] | undefined>;
@@ -128,4 +150,5 @@ export interface ITabularRepository<Schema extends DataPortSchemaObject, Primary
128
150
  [Symbol.dispose](): void;
129
151
  [Symbol.asyncDispose](): Promise<void>;
130
152
  }
131
- //# sourceMappingURL=ITabularRepository.d.ts.map
153
+ export type AnyTabularStorage = ITabularStorage<any, any, any, any, any>;
154
+ //# sourceMappingURL=ITabularStorage.d.ts.map
@@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,kBAAkB,CAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAAK,IAAI,EACxD,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,IAAI,CAAC;IAEd;;;;OAIG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAG/B,OAAO,IAAI,IAAI,CAAC;IAChB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IACzB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC"}
@@ -3,10 +3,10 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { DataPortSchemaObject, FromSchema } from "@workglow/util";
7
- import { DeleteSearchCriteria, ITabularRepository, TabularChangePayload, TabularSubscribeOptions } from "./ITabularRepository";
8
- import { TabularRepository } from "./TabularRepository";
9
- export declare const MEMORY_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<ITabularRepository<any, any, any, any, any>>;
6
+ import { DataPortSchemaObject, FromSchema, TypedArraySchemaOptions } from "@workglow/util";
7
+ import { BaseTabularStorage, ClientProvidedKeysOption, KeyGenerationStrategy } from "./BaseTabularStorage";
8
+ import { AnyTabularStorage, AutoGeneratedKeys, DeleteSearchCriteria, InsertEntity, SimplifyPrimaryKey, TabularChangePayload, TabularSubscribeOptions } from "./ITabularStorage";
9
+ export declare const MEMORY_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<AnyTabularStorage>;
10
10
  /**
11
11
  * A generic in-memory key-value repository implementation.
12
12
  * Provides a simple, non-persistent storage solution suitable for testing and caching scenarios.
@@ -14,35 +14,45 @@ export declare const MEMORY_TABULAR_REPOSITORY: import("@workglow/util").Service
14
14
  * @template Schema - The schema definition for the entity using JSON Schema
15
15
  * @template PrimaryKeyNames - Array of property names that form the primary key
16
16
  */
17
- export declare class InMemoryTabularRepository<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema>, PrimaryKey = Pick<Entity, PrimaryKeyNames[number] & keyof Entity>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>> extends TabularRepository<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value> {
17
+ export declare class InMemoryTabularStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema, TypedArraySchemaOptions>, PrimaryKey = SimplifyPrimaryKey<Entity, PrimaryKeyNames>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>, InsertType extends InsertEntity<Entity, AutoGeneratedKeys<Schema>> = InsertEntity<Entity, AutoGeneratedKeys<Schema>>> extends BaseTabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value, InsertType> {
18
18
  /** Internal storage using a Map with fingerprint strings as keys */
19
19
  values: Map<string, Entity>;
20
+ /** Counter for auto-incrementing integer keys */
21
+ private autoIncrementCounter;
20
22
  /**
21
- * Creates a new InMemoryTabularRepository instance
23
+ * Creates a new InMemoryTabularStorage instance
22
24
  * @param schema - Schema defining the structure of the entity
23
25
  * @param primaryKeyNames - Array of property names that form the primary key
24
26
  * @param indexes - Array of columns or column arrays to make searchable. Each string or single column creates a single-column index,
25
27
  * while each array creates a compound index with columns in the specified order.
28
+ * @param clientProvidedKeys - How to handle client-provided values for auto-generated keys
26
29
  */
27
- constructor(schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[]);
30
+ constructor(schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[], clientProvidedKeys?: ClientProvidedKeysOption);
28
31
  /**
29
32
  * Sets up the database for the repository (no-op for in-memory)
30
33
  */
31
34
  setupDatabase(): Promise<void>;
35
+ /**
36
+ * Generates a key value for auto-generated keys
37
+ * @param columnName - Name of the column to generate a key for
38
+ * @param strategy - The generation strategy to use
39
+ * @returns The generated key value
40
+ */
41
+ protected generateKeyValue(columnName: string, strategy: KeyGenerationStrategy): string | number;
32
42
  /**
33
43
  * Stores a key-value pair in the repository
34
- * @param value - The combined object to store
35
- * @returns The stored entity
44
+ * @param value - The combined object to store (may be missing auto-generated keys)
45
+ * @returns The stored entity with all keys filled in
36
46
  * @emits 'put' event with the stored entity when successful
37
47
  */
38
- put(value: Entity): Promise<Entity>;
48
+ put(value: InsertType): Promise<Entity>;
39
49
  /**
40
50
  * Stores multiple key-value pairs in the repository in a bulk operation
41
- * @param values - Array of combined objects to store
42
- * @returns Array of stored entities
51
+ * @param values - Array of combined objects to store (may be missing auto-generated keys)
52
+ * @returns Array of stored entities with all keys filled in
43
53
  * @emits 'put' event for each value stored
44
54
  */
45
- putBulk(values: Entity[]): Promise<Entity[]>;
55
+ putBulk(values: InsertType[]): Promise<Entity[]>;
46
56
  /**
47
57
  * Retrieves a value by its key
48
58
  * @param key - The primary key object to look up
@@ -99,4 +109,4 @@ export declare class InMemoryTabularRepository<Schema extends DataPortSchemaObje
99
109
  */
100
110
  destroy(): void;
101
111
  }
102
- //# sourceMappingURL=InMemoryTabularRepository.d.ts.map
112
+ //# sourceMappingURL=InMemoryTabularStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InMemoryTabularStorage.d.ts","sourceRoot":"","sources":["../../src/tabular/InMemoryTabularStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,oBAAoB,EACpB,UAAU,EAEV,uBAAuB,EAExB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EACL,iBAAiB,EACj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OAAO,CAAC,MAAM,CAAC;IAuC7C;;;;;OAKG;IACG,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAItD;;;;;OAKG;IACG,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAOvD;;;;;OAKG;IACG,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC;IAiCjE;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOvD;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAKhC;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC;IAK7C;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAuDzE;;;;;;;OAOG;IACH,kBAAkB,CAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAAK,IAAI,EACxD,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,IAAI;IAyBb;;OAEG;IACH,OAAO,IAAI,IAAI;CAGhB"}
@@ -3,18 +3,18 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { DataPortSchemaObject, FromSchema } from "@workglow/util";
6
+ import { DataPortSchemaObject, FromSchema, TypedArraySchemaOptions } from "@workglow/util";
7
7
  import { MigrationOptions } from "../util/IndexedDbTable";
8
- import { DeleteSearchCriteria, ITabularRepository, TabularChangePayload, TabularSubscribeOptions } from "./ITabularRepository";
9
- import { TabularRepository } from "./TabularRepository";
10
- export declare const IDB_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<ITabularRepository<any, any, any, any, any>>;
8
+ import { BaseTabularStorage, ClientProvidedKeysOption, KeyGenerationStrategy } from "./BaseTabularStorage";
9
+ import { AnyTabularStorage, AutoGeneratedKeys, DeleteSearchCriteria, InsertEntity, SimplifyPrimaryKey, TabularChangePayload, TabularSubscribeOptions } from "./ITabularStorage";
10
+ export declare const IDB_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<AnyTabularStorage>;
11
11
  /**
12
12
  * A tabular repository implementation using IndexedDB for browser-based storage.
13
13
  *
14
14
  * @template Schema - The schema definition for the entity
15
15
  * @template PrimaryKeyNames - Array of property names that form the primary key
16
16
  */
17
- export declare class IndexedDbTabularRepository<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema>, PrimaryKey = Pick<Entity, PrimaryKeyNames[number] & keyof Entity>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>> extends TabularRepository<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value> {
17
+ export declare class IndexedDbTabularStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema, TypedArraySchemaOptions>, PrimaryKey = SimplifyPrimaryKey<Entity, PrimaryKeyNames>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>, InsertType extends InsertEntity<Entity, AutoGeneratedKeys<Schema>> = InsertEntity<Entity, AutoGeneratedKeys<Schema>>> extends BaseTabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value, InsertType> {
18
18
  table: string;
19
19
  /** Promise that resolves to the IndexedDB database instance */
20
20
  private db;
@@ -34,11 +34,12 @@ export declare class IndexedDbTabularRepository<Schema extends DataPortSchemaObj
34
34
  * @param indexes - Array of columns or column arrays to make searchable. Each string or single column creates a single-column index,
35
35
  * while each array creates a compound index with columns in the specified order.
36
36
  * @param migrationOptions - Options for handling database schema migrations
37
+ * @param clientProvidedKeys - How to handle client-provided values for auto-generated keys
37
38
  */
38
39
  constructor(table: string | undefined, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof Entity | readonly (keyof Entity)[])[], migrationOptions?: MigrationOptions & {
39
40
  readonly useBroadcastChannel?: boolean;
40
41
  readonly backupPollingIntervalMs?: number;
41
- });
42
+ }, clientProvidedKeys?: ClientProvidedKeysOption);
42
43
  /**
43
44
  * Internal method to get the database, setting it up if needed.
44
45
  * This ensures lazy initialization of the database.
@@ -53,20 +54,28 @@ export declare class IndexedDbTabularRepository<Schema extends DataPortSchemaObj
53
54
  * Internal method to perform the actual database setup
54
55
  */
55
56
  private performSetup;
57
+ /**
58
+ * Generates a key value for UUID keys
59
+ * Integer autoincrement keys are handled by IndexedDB's autoIncrement
60
+ * @param columnName - Name of the column to generate a key for
61
+ * @param strategy - The generation strategy to use
62
+ * @returns The generated key value
63
+ */
64
+ protected generateKeyValue(columnName: string, strategy: KeyGenerationStrategy): string | number;
56
65
  /**
57
66
  * Stores a row in the repository.
58
- * @param record - The entity to store.
67
+ * @param record - The entity to store (may be missing auto-generated keys).
59
68
  * @returns The stored entity
60
69
  * @emits put - Emitted when the value is successfully stored
61
70
  */
62
- put(record: Entity): Promise<Entity>;
71
+ put(record: InsertType): Promise<Entity>;
63
72
  /**
64
73
  * Stores multiple rows in the repository in a bulk operation.
65
- * @param records - Array of entities to store.
74
+ * @param records - Array of entities to store (may be missing auto-generated keys).
66
75
  * @returns Array of stored entities
67
76
  * @emits put - Emitted for each record successfully stored
68
77
  */
69
- putBulk(records: Entity[]): Promise<Entity[]>;
78
+ putBulk(records: InsertType[]): Promise<Entity[]>;
70
79
  protected getPrimaryKeyAsOrderedArray(key: PrimaryKey): (string | number | boolean | Uint8Array<ArrayBufferLike> | null)[];
71
80
  private getIndexedKey;
72
81
  /**
@@ -136,4 +145,4 @@ export declare class IndexedDbTabularRepository<Schema extends DataPortSchemaObj
136
145
  */
137
146
  destroy(): void;
138
147
  }
139
- //# sourceMappingURL=IndexedDbTabularRepository.d.ts.map
148
+ //# sourceMappingURL=IndexedDbTabularStorage.d.ts.map