@webda/models 0.0.0-stage → 4.0.0-beta.4
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/LICENSE +166 -0
- package/README.md +146 -2
- package/lib/index.d.ts +11 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/mock.d.ts +72 -0
- package/lib/mock.d.ts.map +1 -0
- package/lib/mock.js +83 -0
- package/lib/mock.js.map +1 -0
- package/lib/model.model.d.ts +286 -0
- package/lib/model.model.d.ts.map +1 -0
- package/lib/model.model.js +336 -0
- package/lib/model.model.js.map +1 -0
- package/lib/relations.d.ts +705 -0
- package/lib/relations.d.ts.map +1 -0
- package/lib/relations.js +938 -0
- package/lib/relations.js.map +1 -0
- package/lib/repositories/abstract.d.ts +138 -0
- package/lib/repositories/abstract.d.ts.map +1 -0
- package/lib/repositories/abstract.js +280 -0
- package/lib/repositories/abstract.js.map +1 -0
- package/lib/repositories/conformance.d.ts +40 -0
- package/lib/repositories/conformance.d.ts.map +1 -0
- package/lib/repositories/conformance.js +38 -0
- package/lib/repositories/conformance.js.map +1 -0
- package/lib/repositories/event.d.ts +101 -0
- package/lib/repositories/event.d.ts.map +1 -0
- package/lib/repositories/event.js +228 -0
- package/lib/repositories/event.js.map +1 -0
- package/lib/repositories/hooks.d.ts +88 -0
- package/lib/repositories/hooks.d.ts.map +1 -0
- package/lib/repositories/hooks.js +105 -0
- package/lib/repositories/hooks.js.map +1 -0
- package/lib/repositories/memory.d.ts +262 -0
- package/lib/repositories/memory.d.ts.map +1 -0
- package/lib/repositories/memory.js +574 -0
- package/lib/repositories/memory.js.map +1 -0
- package/lib/repositories/repository.d.ts +238 -0
- package/lib/repositories/repository.d.ts.map +1 -0
- package/lib/repositories/repository.js +19 -0
- package/lib/repositories/repository.js.map +1 -0
- package/lib/storable.d.ts +210 -0
- package/lib/storable.d.ts.map +1 -0
- package/lib/storable.js +76 -0
- package/lib/storable.js.map +1 -0
- package/lib/types.d.ts +230 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +12 -0
- package/lib/types.js.map +1 -0
- package/package.json +60 -3
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { ArrayElement } from "@webda/tsc-esm";
|
|
2
|
+
import type { QueryParameters, WebdaQLString } from "@webda/ql";
|
|
3
|
+
import type { PrimaryKey, PrimaryKeyType, SettablePrimaryKey, WEBDA_EVENTS, ModelClass, PrimaryKeyAttributes } from "../storable.js";
|
|
4
|
+
import type { Helpers, JSONed, NumericPropertyPaths, PropertyPaths, PropertyPathType } from "../types.js";
|
|
5
|
+
import type { ModelRefWithCreate } from "../relations.js";
|
|
6
|
+
/** Symbol key for test utilities on a repository (e.g. `clear()`). */
|
|
7
|
+
export declare const WEBDA_TEST: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* Core repository interface - every repository must implement this
|
|
10
|
+
*
|
|
11
|
+
* Contains only the essential CRUD operations that work across
|
|
12
|
+
* all storage backends (SQL, NoSQL, in-memory, etc.)
|
|
13
|
+
*/
|
|
14
|
+
export interface CoreRepository<T extends ModelClass = ModelClass> {
|
|
15
|
+
/**
|
|
16
|
+
* Get the root model class for this repository
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
getRootModel(): T;
|
|
20
|
+
/**
|
|
21
|
+
* In REST API, composite keys are represented as a string with the format "key1#key2#key3"
|
|
22
|
+
* We need a way to convert this string to the object
|
|
23
|
+
*
|
|
24
|
+
* @param uid serialized primary key
|
|
25
|
+
* @param forceObject if true, the result will be an object with the primary key fields
|
|
26
|
+
*/
|
|
27
|
+
fromUID(uid: string, forceObject?: boolean): ModelRefWithCreate<InstanceType<T>>;
|
|
28
|
+
/**
|
|
29
|
+
* Parse the UID into the primary key
|
|
30
|
+
* @param uid
|
|
31
|
+
* @param forceObject
|
|
32
|
+
*/
|
|
33
|
+
parseUID(uid: string, forceObject?: boolean): PrimaryKeyType<InstanceType<T>> | PrimaryKey<InstanceType<T>>;
|
|
34
|
+
/**
|
|
35
|
+
* Extract the primary key from the object
|
|
36
|
+
* @param object to extract the primary key from
|
|
37
|
+
* @param forceObject if true, the result will be an object with the primary key fields
|
|
38
|
+
*/
|
|
39
|
+
getPrimaryKey<K>(object: any, forceObject?: boolean): K extends false ? PrimaryKeyType<InstanceType<T>> : PrimaryKey<InstanceType<T>>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the UID of the object
|
|
42
|
+
* @param object to extract the primary key from
|
|
43
|
+
*/
|
|
44
|
+
getUID(object: any): string;
|
|
45
|
+
/**
|
|
46
|
+
* Remove the primary key from the object
|
|
47
|
+
* @param object
|
|
48
|
+
*/
|
|
49
|
+
excludePrimaryKey(object: any): any;
|
|
50
|
+
/**
|
|
51
|
+
* Refers to the object in the store
|
|
52
|
+
* @param pk primary key
|
|
53
|
+
*/
|
|
54
|
+
ref(pk: SettablePrimaryKey<InstanceType<T>>): ModelRefWithCreate<InstanceType<T>>;
|
|
55
|
+
/**
|
|
56
|
+
* Get data from the store
|
|
57
|
+
* @param primaryKey
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
get(primaryKey: PrimaryKeyType<InstanceType<T>>): Promise<Helpers<InstanceType<T>>>;
|
|
61
|
+
/**
|
|
62
|
+
* Create data in the store
|
|
63
|
+
* @param data
|
|
64
|
+
* @param save if false, create in-memory object without saving
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
create(data: Helpers<InstanceType<T>>, save?: boolean): Promise<InstanceType<T>>;
|
|
68
|
+
/**
|
|
69
|
+
* Delete data from the store
|
|
70
|
+
* @param uid - Primary key or UID string
|
|
71
|
+
* @param conditionField - Field to check for condition (optional)
|
|
72
|
+
* @param condition - Value to check for condition (optional)
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
delete<K extends PropertyPaths<InstanceType<T>>>(uid: PrimaryKeyType<InstanceType<T>> | string, conditionField?: K | null, condition?: PropertyPathType<InstanceType<T>, K> | JSONed<PropertyPathType<InstanceType<T>, K>>): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Verify if the object exists
|
|
78
|
+
* @param uid
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
exists(uid: PrimaryKeyType<InstanceType<T>> | string): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Query the store
|
|
84
|
+
* @param query - the WebdaQL query, optionally with `?` or `:name` placeholders
|
|
85
|
+
* @param params - values for the placeholders: an array for `?`, an object for `:name`
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
query(query: WebdaQLString<InstanceType<T>>, params?: QueryParameters): Promise<{
|
|
89
|
+
results: InstanceType<T>[];
|
|
90
|
+
continuationToken?: string;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* Iterate over the store
|
|
94
|
+
* @param query - the WebdaQL query, optionally with `?` or `:name` placeholders
|
|
95
|
+
* @param params - values for the placeholders: an array for `?`, an object for `:name`
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
iterate(query: WebdaQLString<InstanceType<T>>, params?: QueryParameters): AsyncGenerator<InstanceType<T>>;
|
|
99
|
+
/**
|
|
100
|
+
* Event listeners
|
|
101
|
+
*/
|
|
102
|
+
on<K extends keyof InstanceType<T>[typeof WEBDA_EVENTS]>(event: K, listener: (data: InstanceType<T>[typeof WEBDA_EVENTS][K]) => void): void;
|
|
103
|
+
once<K extends keyof InstanceType<T>[typeof WEBDA_EVENTS]>(event: K, listener: (data: InstanceType<T>[typeof WEBDA_EVENTS][K]) => void): void;
|
|
104
|
+
off<K extends keyof InstanceType<T>[typeof WEBDA_EVENTS]>(event: K, listener: (data: InstanceType<T>[typeof WEBDA_EVENTS][K]) => void): void;
|
|
105
|
+
emit<K extends keyof InstanceType<T>[typeof WEBDA_EVENTS]>(event: K, payload: InstanceType<T>[typeof WEBDA_EVENTS][K]): Promise<void>;
|
|
106
|
+
[WEBDA_TEST]?: {
|
|
107
|
+
clear(): Promise<void>;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Update operations with optimistic locking support
|
|
112
|
+
*
|
|
113
|
+
* Most repositories should implement this to support updates
|
|
114
|
+
*/
|
|
115
|
+
export interface Updatable<T extends ModelClass = ModelClass> {
|
|
116
|
+
/**
|
|
117
|
+
* Replace entire object (full update)
|
|
118
|
+
* @param data - Complete object data including primary key
|
|
119
|
+
* @param conditionField - Field to check for optimistic locking (null = no check)
|
|
120
|
+
* @param condition - Expected value for condition field
|
|
121
|
+
*/
|
|
122
|
+
update<K extends PropertyPaths<InstanceType<T>>>(data: Helpers<InstanceType<T>>, conditionField?: K | null, condition?: PropertyPathType<InstanceType<T>, K>): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Partially update object (only specified fields)
|
|
125
|
+
* @param uid - Primary key of object to update
|
|
126
|
+
* @param data - Partial object data (only fields to update)
|
|
127
|
+
* @param conditionField - Field to check for optimistic locking (null = no check)
|
|
128
|
+
* @param condition - Expected value for condition field
|
|
129
|
+
*/
|
|
130
|
+
patch<K extends PropertyPaths<InstanceType<T>>>(uid: PrimaryKeyType<InstanceType<T>> | string, data: Partial<Omit<InstanceType<T>, PrimaryKeyAttributes<InstanceType<T>>>>, conditionField?: K | null, condition?: PropertyPathType<InstanceType<T>, K> | JSONed<PropertyPathType<InstanceType<T>, K>>): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Create or update object (insert if not exists, update if exists)
|
|
133
|
+
*/
|
|
134
|
+
upsert(data: Helpers<InstanceType<T>>): Promise<InstanceType<T>>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Atomic operations for NoSQL databases
|
|
138
|
+
*
|
|
139
|
+
* Only implement this for storage backends that support atomic updates
|
|
140
|
+
* (DynamoDB, MongoDB, Redis, etc.)
|
|
141
|
+
*
|
|
142
|
+
* SQL databases should NOT implement this - use transactions instead
|
|
143
|
+
*/
|
|
144
|
+
export interface AtomicOperations<T extends ModelClass = ModelClass> {
|
|
145
|
+
/**
|
|
146
|
+
* Atomically increment numeric field(s)
|
|
147
|
+
* @param primaryKeyOrUid - Primary key of object to update
|
|
148
|
+
* @param info - Fields to increment with optional values (default: 1)
|
|
149
|
+
* @param conditionField - Field to check for condition
|
|
150
|
+
* @param condition - Expected value for condition field
|
|
151
|
+
*/
|
|
152
|
+
incrementAttributes<K extends PropertyPaths<InstanceType<T>>, L extends NumericPropertyPaths<InstanceType<T>>>(primaryKeyOrUid: PrimaryKeyType<InstanceType<T>> | string, info: ({
|
|
153
|
+
property: L;
|
|
154
|
+
value?: number;
|
|
155
|
+
} | L)[] | Record<L, number>, conditionField?: K | null, condition?: PropertyPathType<InstanceType<T>, K> | JSONed<PropertyPathType<InstanceType<T>, K>>): Promise<void | Record<string, number>>;
|
|
156
|
+
/**
|
|
157
|
+
* Atomically increment a single numeric field
|
|
158
|
+
* @param primaryKeyOrUid - Primary key of object to update
|
|
159
|
+
* @param info - Field to increment with optional value (default: 1)
|
|
160
|
+
* @param conditionField - Field to check for condition
|
|
161
|
+
* @param condition - Expected value for condition field
|
|
162
|
+
*/
|
|
163
|
+
incrementAttribute<K extends PropertyPaths<InstanceType<T>>, L extends NumericPropertyPaths<InstanceType<T>>>(primaryKeyOrUid: PrimaryKeyType<InstanceType<T>> | string, info: {
|
|
164
|
+
property: L;
|
|
165
|
+
value?: number;
|
|
166
|
+
} | L, conditionField?: K | null, condition?: PropertyPathType<InstanceType<T>, K> | JSONed<PropertyPathType<InstanceType<T>, K>>): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Atomically set a single attribute value
|
|
169
|
+
* @param primaryKeyOrUid - Primary key of object to update
|
|
170
|
+
* @param attribute - Attribute name to set
|
|
171
|
+
* @param value - New value for attribute
|
|
172
|
+
* @param conditionField - Field to check for condition
|
|
173
|
+
* @param condition - Expected value for condition field
|
|
174
|
+
*/
|
|
175
|
+
setAttribute<K extends PropertyPaths<InstanceType<T>>, L extends PropertyPaths<InstanceType<T>>>(primaryKeyOrUid: PrimaryKeyType<InstanceType<T>> | string, attribute: K, value: PropertyPathType<InstanceType<T>, K>, conditionField?: L | null, condition?: PropertyPathType<InstanceType<T>, L> | JSONed<PropertyPathType<InstanceType<T>, L>>): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Atomically remove an attribute
|
|
178
|
+
* @param primaryKeyOrUid - Primary key of object to update
|
|
179
|
+
* @param attribute - Attribute name to remove
|
|
180
|
+
* @param conditionField - Field to check for condition
|
|
181
|
+
* @param condition - Expected value for condition field
|
|
182
|
+
*/
|
|
183
|
+
removeAttribute<L extends PropertyPaths<InstanceType<T>>, K extends PropertyPaths<InstanceType<T>>>(primaryKeyOrUid: PrimaryKeyType<InstanceType<T>> | string, attribute: K, conditionField?: L | null, condition?: PropertyPathType<InstanceType<T>, L> | JSONed<PropertyPathType<InstanceType<T>, L>>): Promise<void>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Collection operations for nested arrays
|
|
187
|
+
*
|
|
188
|
+
* Only implement this for storage backends that support atomic array operations
|
|
189
|
+
* (DynamoDB, MongoDB, etc.)
|
|
190
|
+
*/
|
|
191
|
+
export interface CollectionOperations<T extends ModelClass = ModelClass> {
|
|
192
|
+
/**
|
|
193
|
+
* Add or update item in a collection (array field)
|
|
194
|
+
* @param primaryKeyOrUid - Primary key of object containing the collection
|
|
195
|
+
* @param collection - Name of the array field
|
|
196
|
+
* @param item - Item to add/update
|
|
197
|
+
* @param index - Position to insert (undefined = append to end)
|
|
198
|
+
* @param itemWriteConditionField - Field to check for condition on item
|
|
199
|
+
* @param itemWriteCondition - Expected value for condition field on item
|
|
200
|
+
*/
|
|
201
|
+
upsertItemToCollection<K extends Extract<PropertyPaths<InstanceType<T>, any[]>, keyof InstanceType<T>>, L extends keyof ArrayElement<InstanceType<T>[K]>>(primaryKeyOrUid: PrimaryKeyType<InstanceType<T>> | string, collection: K, item: ArrayElement<InstanceType<T>[K]> | JSONed<ArrayElement<InstanceType<T>[K]>>, index?: number, itemWriteConditionField?: ArrayElement<InstanceType<T>[K]> extends object ? L : never, itemWriteCondition?: ArrayElement<InstanceType<T>[K]> extends object ? ArrayElement<InstanceType<T>[K]>[L] : ArrayElement<InstanceType<T>[K]> | null): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* Remove item from a collection by index
|
|
204
|
+
* @param primaryKeyOrUid - Primary key of object containing the collection
|
|
205
|
+
* @param collection - Name of the array field
|
|
206
|
+
* @param index - Position of item to remove
|
|
207
|
+
* @param itemWriteConditionField - Field to check for condition on item
|
|
208
|
+
* @param itemWriteCondition - Expected value for condition field on item
|
|
209
|
+
*/
|
|
210
|
+
deleteItemFromCollection<K extends Extract<PropertyPaths<InstanceType<T>, any[]>, keyof InstanceType<T>>, L extends keyof ArrayElement<InstanceType<T>[K]>>(primaryKeyOrUid: PrimaryKeyType<InstanceType<T>> | string, collection: K, index: number, itemWriteConditionField?: L, itemWriteCondition?: ArrayElement<InstanceType<T>[K]>[L]): Promise<void>;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Type guard to check if repository supports atomic operations
|
|
214
|
+
* @param repo - the repository to check
|
|
215
|
+
* @returns true if atomic operations are supported
|
|
216
|
+
*/
|
|
217
|
+
export declare function supportsAtomicOperations<T extends ModelClass>(repo: CoreRepository<T>): repo is CoreRepository<T> & AtomicOperations<T>;
|
|
218
|
+
/**
|
|
219
|
+
* Type guard to check if repository supports collection operations
|
|
220
|
+
* @param repo - the repository to check
|
|
221
|
+
* @returns true if collection operations are supported
|
|
222
|
+
*/
|
|
223
|
+
export declare function supportsCollectionOperations<T extends ModelClass>(repo: CoreRepository<T>): repo is CoreRepository<T> & CollectionOperations<T>;
|
|
224
|
+
/**
|
|
225
|
+
* Full-featured repository combining all capabilities (backward compatible)
|
|
226
|
+
*
|
|
227
|
+
* This is the main interface that most code will interact with.
|
|
228
|
+
* It extends all specialized interfaces for backward compatibility.
|
|
229
|
+
*
|
|
230
|
+
* Note: All methods are inherited from:
|
|
231
|
+
* - CoreRepository: Basic CRUD, query, and key management
|
|
232
|
+
* - Updatable: Update, patch, and upsert operations
|
|
233
|
+
* - AtomicOperations: Atomic increment, setAttribute, removeAttribute
|
|
234
|
+
* - CollectionOperations: Array/collection manipulation
|
|
235
|
+
*/
|
|
236
|
+
export interface Repository<T extends ModelClass = ModelClass> extends CoreRepository<T>, Updatable<T>, AtomicOperations<T>, CollectionOperations<T> {
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../src/repositories/repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,gBAAgB,EAAc,MAAM,aAAa,CAAC;AACtH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,sEAAsE;AACtE,eAAO,MAAM,UAAU,eAAuB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAC/D;;;OAGG;IACH,YAAY,IAAI,CAAC,CAAC;IAElB;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjF;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MA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
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Symbol key for test utilities on a repository (e.g. `clear()`). */
|
|
2
|
+
export const WEBDA_TEST = Symbol("webda_test");
|
|
3
|
+
/**
|
|
4
|
+
* Type guard to check if repository supports atomic operations
|
|
5
|
+
* @param repo - the repository to check
|
|
6
|
+
* @returns true if atomic operations are supported
|
|
7
|
+
*/
|
|
8
|
+
export function supportsAtomicOperations(repo) {
|
|
9
|
+
return typeof repo.incrementAttribute === "function";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Type guard to check if repository supports collection operations
|
|
13
|
+
* @param repo - the repository to check
|
|
14
|
+
* @returns true if collection operations are supported
|
|
15
|
+
*/
|
|
16
|
+
export function supportsCollectionOperations(repo) {
|
|
17
|
+
return typeof repo.upsertItemToCollection === "function";
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../src/repositories/repository.ts"],"names":[],"mappings":"AAaA,sEAAsE;AACtE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAyS/C;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAuB;IAEvB,OAAO,OAAQ,IAAY,CAAC,kBAAkB,KAAK,UAAU,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,IAAuB;IAEvB,OAAO,OAAQ,IAAY,CAAC,sBAAsB,KAAK,UAAU,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { FilterAttributes, IsUnion, ReadonlyKeys } from "@webda/tsc-esm";
|
|
2
|
+
import type { QueryParameters } from "@webda/ql";
|
|
3
|
+
import { WEBDA_DIRTY } from "@webda/utils";
|
|
4
|
+
import type { ModelRefWithCreate, ModelRelated } from "./relations.js";
|
|
5
|
+
import type { JSONed, Settable } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Define the model primary key
|
|
8
|
+
*/
|
|
9
|
+
export declare const WEBDA_PRIMARY_KEY: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* REST API and other system may require a string representation of the primary key
|
|
12
|
+
* We concatenate the primary key fields with the separator '_'
|
|
13
|
+
*
|
|
14
|
+
* If one of these fields can contain a _ you can pick a different separator
|
|
15
|
+
*/
|
|
16
|
+
export declare const WEBDA_PRIMARY_KEY_SEPARATOR: unique symbol;
|
|
17
|
+
/**
|
|
18
|
+
* Define the model plural key
|
|
19
|
+
* We might go back to a JSDoc @WebdaPlural annotation later
|
|
20
|
+
* @default <modelName>s
|
|
21
|
+
*/
|
|
22
|
+
export declare const WEBDA_PLURAL: unique symbol;
|
|
23
|
+
/**
|
|
24
|
+
* Define the model events key
|
|
25
|
+
*/
|
|
26
|
+
export declare const WEBDA_EVENTS: unique symbol;
|
|
27
|
+
/**
|
|
28
|
+
* Symbol for internal storage of model properties that require custom getters/setters (e.g. for handling multiple input types like Date).
|
|
29
|
+
*/
|
|
30
|
+
export declare const WEBDA_STORAGE: unique symbol;
|
|
31
|
+
/**
|
|
32
|
+
* Raw storage key carried (non-enumerable) by a primary key parsed from a legacy UID
|
|
33
|
+
*
|
|
34
|
+
* A model class may declare `static parseLegacyUID(uid: string): Record<string, any> | undefined` to accept
|
|
35
|
+
* storage keys written under an older key layout (e.g. v3 `"<uid>_<provider>"` idents now keyed
|
|
36
|
+
* `"<providerUid>:<provider>"`). Repositories consult it only when a key does not split into the
|
|
37
|
+
* composite primary key; the parsed key then serializes back to the raw legacy key, so `get`, `exists`
|
|
38
|
+
* and `delete` address the legacy record on every store.
|
|
39
|
+
*/
|
|
40
|
+
export declare const WEBDA_LEGACY_UID: unique symbol;
|
|
41
|
+
/**
|
|
42
|
+
* Define the events for the model
|
|
43
|
+
*/
|
|
44
|
+
export type Eventable = {
|
|
45
|
+
[WEBDA_EVENTS]?: any;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A Storable object is an object that can be stored in a database or anywhere else
|
|
49
|
+
* and can be retrieved later
|
|
50
|
+
*
|
|
51
|
+
* It has a primary key, a toJSON method and an Events object
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
export interface Storable<T = any, PrimaryKeyProperties extends keyof T = any> extends Eventable {
|
|
55
|
+
/**
|
|
56
|
+
* Define the primary key for your model
|
|
57
|
+
*/
|
|
58
|
+
[WEBDA_PRIMARY_KEY]: readonly PrimaryKeyProperties[];
|
|
59
|
+
/**
|
|
60
|
+
* Define the separator to use when concatenating primary key fields (for UUID generation)
|
|
61
|
+
*/
|
|
62
|
+
[WEBDA_PRIMARY_KEY_SEPARATOR]?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Define the plural for your model
|
|
65
|
+
*/
|
|
66
|
+
[WEBDA_PLURAL]?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Properties that are dirty and need to be saved
|
|
69
|
+
*/
|
|
70
|
+
[WEBDA_DIRTY]?: Set<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Return the primary key
|
|
73
|
+
*/
|
|
74
|
+
getPrimaryKey(): IsUnion<PrimaryKeyProperties> extends true ? Pick<T, PrimaryKeyProperties> : T[PrimaryKeyProperties];
|
|
75
|
+
/**
|
|
76
|
+
* Return the string version of the primary key
|
|
77
|
+
*/
|
|
78
|
+
getUUID(): string;
|
|
79
|
+
/**
|
|
80
|
+
* Load the serialized version of itself
|
|
81
|
+
*/
|
|
82
|
+
load(params: any): this;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A concrete storable is a storable that has a constructor that can be used to create a new instance
|
|
86
|
+
*/
|
|
87
|
+
export type ConcreteStorable<T = any, K extends keyof T = any> = Storable<T, K> & (new (arg: any) => any);
|
|
88
|
+
/**
|
|
89
|
+
* Constructor interface for Model classes.
|
|
90
|
+
*
|
|
91
|
+
* Provides static methods for CRUD operations, querying, and serialization.
|
|
92
|
+
*/
|
|
93
|
+
export interface ModelClass<S extends Storable = Storable> {
|
|
94
|
+
new (arg: any): S;
|
|
95
|
+
prototype: S;
|
|
96
|
+
ref<T extends ModelClass>(this: T, key: SettablePrimaryKey<InstanceType<T>>): ModelRefWithCreate<InstanceType<T>>;
|
|
97
|
+
iterate<T extends ModelClass>(this: T, query: string, params?: QueryParameters): AsyncGenerator<InstanceType<T>, any, any>;
|
|
98
|
+
create<T extends ModelClass>(this: T, data: ConstructorParameters<T>[0], save?: boolean): Promise<InstanceType<T>>;
|
|
99
|
+
query<T extends ModelClass>(this: T, query: string, params?: QueryParameters): Promise<{
|
|
100
|
+
results: InstanceType<T>[];
|
|
101
|
+
continuationToken?: string;
|
|
102
|
+
}>;
|
|
103
|
+
registerSerializer(overwrite?: boolean, identifier?: string): void;
|
|
104
|
+
getDeserializers<T extends ModelClass>(): Partial<Record<keyof InstanceType<T>, (value: any) => any>> | undefined;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Check if the object is a Model class
|
|
108
|
+
* @param object - the value to check
|
|
109
|
+
* @returns true if it is a ModelClass
|
|
110
|
+
*/
|
|
111
|
+
export declare function isModelClass(object: any): object is ModelClass;
|
|
112
|
+
/**
|
|
113
|
+
* All storable need to have a constructor that take an object as argument
|
|
114
|
+
*/
|
|
115
|
+
export type StorableConstructor<T extends new (arg: any) => any = any> = new (arg: ConstructorParameters<T>[0]) => T;
|
|
116
|
+
/** Extract the first parameter type of a `set` method, if present. */
|
|
117
|
+
type FirstSetArg<X> = X extends {
|
|
118
|
+
set: (...args: infer A) => any;
|
|
119
|
+
} ? A[0] : never;
|
|
120
|
+
/** Resolve the accepted value type for an attribute: uses `set` arg if available, otherwise `JSONed<X> | X`. */
|
|
121
|
+
type AttributeValue<X> = X extends {
|
|
122
|
+
set: Function;
|
|
123
|
+
} ? FirstSetArg<X> : JSONed<X> | X;
|
|
124
|
+
/** Keys where the `set` method's first arg is optional or includes undefined. */
|
|
125
|
+
type OptionalArgKeys<T extends Storable> = {
|
|
126
|
+
[P in StorableAttributes<T>]-?: T[P] extends {
|
|
127
|
+
set: any;
|
|
128
|
+
} ? (undefined extends FirstSetArg<T[P]> ? P : never) : never;
|
|
129
|
+
}[StorableAttributes<T>];
|
|
130
|
+
/** Keys whose `set` arg is required (complement of OptionalArgKeys). */
|
|
131
|
+
type RequiredArgKeys<T extends Storable> = Exclude<StorableAttributes<T>, OptionalArgKeys<T>>;
|
|
132
|
+
/**
|
|
133
|
+
* Build the argument type for creating/updating a Storable.
|
|
134
|
+
*
|
|
135
|
+
* Properties with a required `set` arg are required; those with an optional `set` arg are optional.
|
|
136
|
+
*/
|
|
137
|
+
export type AttributesArgument<T extends Storable> = {
|
|
138
|
+
[P in Extract<RequiredArgKeys<T>, string | number>]: AttributeValue<T[P]>;
|
|
139
|
+
} & {
|
|
140
|
+
[P in Extract<OptionalArgKeys<T>, string | number>]?: AttributeValue<T[P]>;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Resolve the primary key type: if T is a union of keys, returns `Pick<K, T>`;
|
|
144
|
+
* if T is a single key, returns `K[T]` directly.
|
|
145
|
+
*/
|
|
146
|
+
export type PK<K, T extends keyof K> = IsUnion<T> extends true ? Pick<K, T> : K[T];
|
|
147
|
+
/**
|
|
148
|
+
* Get the primary key type of the object
|
|
149
|
+
*
|
|
150
|
+
* The main difference with the PrimaryKey<T> type is that if the primary key is a not union type, it will
|
|
151
|
+
* be returned as a single type, otherwise it will be returned as a Pick type
|
|
152
|
+
*
|
|
153
|
+
* The PrimaryKey<T> will always return a Pick type
|
|
154
|
+
*/
|
|
155
|
+
export type PrimaryKeyType<T extends Storable<any, any>> = PK<T, T[typeof WEBDA_PRIMARY_KEY][number]> & {
|
|
156
|
+
toString(): string;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* A widened version of PrimaryKeyType that accepts setter-compatible values.
|
|
160
|
+
*
|
|
161
|
+
* For composite keys (objects), applies Settable to widen properties that have
|
|
162
|
+
* a `set()` method (e.g. ModelLink accepts string).
|
|
163
|
+
* For single keys (string/number), returns the type as-is.
|
|
164
|
+
*/
|
|
165
|
+
export type SettablePrimaryKey<T extends Storable<any, any>> = PrimaryKeyType<T> extends object ? Settable<PrimaryKeyType<T>> | PrimaryKeyType<T> : PrimaryKeyType<T>;
|
|
166
|
+
/**
|
|
167
|
+
* Get the primary key of the object
|
|
168
|
+
*
|
|
169
|
+
* The main difference with the PrimaryKeyType<T> type is that it will always return a Pick type
|
|
170
|
+
*
|
|
171
|
+
* The PrimaryKeyType<T> will return a Pick type only if the primary key is a union type
|
|
172
|
+
*/
|
|
173
|
+
export type PrimaryKey<T extends Storable<any, any>> = Pick<T, T[typeof WEBDA_PRIMARY_KEY][number]> & {
|
|
174
|
+
toString(): string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Get the primary key attributes of the object
|
|
178
|
+
*/
|
|
179
|
+
export type PrimaryKeyAttributes<T extends Storable<any, any>> = keyof PrimaryKey<T>;
|
|
180
|
+
/**
|
|
181
|
+
* Compare two primary keys for equality
|
|
182
|
+
* @param a - the first primary key or storable
|
|
183
|
+
* @param b - the second primary key or storable
|
|
184
|
+
* @returns true if the keys are equal
|
|
185
|
+
*/
|
|
186
|
+
export declare function PrimaryKeyEquals(a: PrimaryKeyType<any> | Storable, b: PrimaryKeyType<any> | Storable): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Check if the object is a Storable object
|
|
189
|
+
* @param object - the value to check
|
|
190
|
+
* @returns true if it is a Storable
|
|
191
|
+
*/
|
|
192
|
+
export declare function isStorable<T = any>(object: any): object is Storable<T>;
|
|
193
|
+
/** Remove symbol-keyed properties from a type. */
|
|
194
|
+
type ExcludeSymbols<T> = {
|
|
195
|
+
[P in keyof T as P extends symbol ? never : P]: T[P];
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Get the model attributes without the internal properties
|
|
199
|
+
*
|
|
200
|
+
* Used for the create method
|
|
201
|
+
*/
|
|
202
|
+
export type StorableAttributes<T extends Storable, U = any> = FilterAttributes<Omit<ExcludeSymbols<T>, FilterAttributes<T, Function> | FilterAttributes<T, ModelRelated<any, any, any>> | ReadonlyKeys<T> | Extract<keyof T, symbol>>, U>;
|
|
203
|
+
/**
|
|
204
|
+
* Get the model attributes without the primary key properties
|
|
205
|
+
*
|
|
206
|
+
* Used for the update method
|
|
207
|
+
*/
|
|
208
|
+
export type UpdatableAttributes<T extends Storable, U = any> = Exclude<StorableAttributes<T, U>, PrimaryKeyAttributes<T> | ReadonlyKeys<T>>;
|
|
209
|
+
export {};
|
|
210
|
+
//# sourceMappingURL=storable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storable.d.ts","sourceRoot":"","sources":["../src/storable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,MAA8B,CAAC;AACtE;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAAO,MAAwC,CAAC;AAC1F;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,MAAoC,CAAC;AACvE;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,MAAoC,CAAC;AACvE;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,OAAO,MAAqC,CAAC;AACzE;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAO,MAA6B,CAAC;AAEpE;;GAEG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G,QAAQ,GAAG,OAAO,CAgB9G;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,CAEtE;AAID,kDAAkD;AAClD,KAAK,cAAc,CAAC,CAAC,IAAI;KACtB,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrD,CAAC;AACF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,GAAG,GAAG,IAAI,gBAAgB,CAC5E,IAAI,CACF,cAAc,CAAC,CAAC,CAAC,EACf,gBAAgB,CAAC,CAAC,EAAE,QAAQ,CAAC,GAC7B,gBAAgB,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GAChD,YAAY,CAAC,CAAC,CAAC,GACf,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAC3B,EACD,CAAC,CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,GAAG,GAAG,IAAI,OAAO,CACpE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EACxB,oBAAoB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAC1C,CAAC"}
|
package/lib/storable.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { WEBDA_DIRTY } from "@webda/utils";
|
|
2
|
+
/**
|
|
3
|
+
* Define the model primary key
|
|
4
|
+
*/
|
|
5
|
+
export const WEBDA_PRIMARY_KEY = Symbol("Primary key");
|
|
6
|
+
/**
|
|
7
|
+
* REST API and other system may require a string representation of the primary key
|
|
8
|
+
* We concatenate the primary key fields with the separator '_'
|
|
9
|
+
*
|
|
10
|
+
* If one of these fields can contain a _ you can pick a different separator
|
|
11
|
+
*/
|
|
12
|
+
export const WEBDA_PRIMARY_KEY_SEPARATOR = Symbol("Primary key separator");
|
|
13
|
+
/**
|
|
14
|
+
* Define the model plural key
|
|
15
|
+
* We might go back to a JSDoc @WebdaPlural annotation later
|
|
16
|
+
* @default <modelName>s
|
|
17
|
+
*/
|
|
18
|
+
export const WEBDA_PLURAL = Symbol("Plural definition");
|
|
19
|
+
/**
|
|
20
|
+
* Define the model events key
|
|
21
|
+
*/
|
|
22
|
+
export const WEBDA_EVENTS = Symbol("Events definition");
|
|
23
|
+
/**
|
|
24
|
+
* Symbol for internal storage of model properties that require custom getters/setters (e.g. for handling multiple input types like Date).
|
|
25
|
+
*/
|
|
26
|
+
export const WEBDA_STORAGE = Symbol("Storage definition");
|
|
27
|
+
/**
|
|
28
|
+
* Raw storage key carried (non-enumerable) by a primary key parsed from a legacy UID
|
|
29
|
+
*
|
|
30
|
+
* A model class may declare `static parseLegacyUID(uid: string): Record<string, any> | undefined` to accept
|
|
31
|
+
* storage keys written under an older key layout (e.g. v3 `"<uid>_<provider>"` idents now keyed
|
|
32
|
+
* `"<providerUid>:<provider>"`). Repositories consult it only when a key does not split into the
|
|
33
|
+
* composite primary key; the parsed key then serializes back to the raw legacy key, so `get`, `exists`
|
|
34
|
+
* and `delete` address the legacy record on every store.
|
|
35
|
+
*/
|
|
36
|
+
export const WEBDA_LEGACY_UID = Symbol("Legacy UID");
|
|
37
|
+
/**
|
|
38
|
+
* Check if the object is a Model class
|
|
39
|
+
* @param object - the value to check
|
|
40
|
+
* @returns true if it is a ModelClass
|
|
41
|
+
*/
|
|
42
|
+
export function isModelClass(object) {
|
|
43
|
+
return (typeof object === "function" &&
|
|
44
|
+
typeof object.prototype?.getPrimaryKey === "function" &&
|
|
45
|
+
typeof object.getDeserializers === "function");
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Compare two primary keys for equality
|
|
49
|
+
* @param a - the first primary key or storable
|
|
50
|
+
* @param b - the second primary key or storable
|
|
51
|
+
* @returns true if the keys are equal
|
|
52
|
+
*/
|
|
53
|
+
export function PrimaryKeyEquals(a, b) {
|
|
54
|
+
if (isStorable(a)) {
|
|
55
|
+
a = a.getPrimaryKey();
|
|
56
|
+
}
|
|
57
|
+
if (isStorable(b)) {
|
|
58
|
+
b = b.getPrimaryKey();
|
|
59
|
+
}
|
|
60
|
+
if (a instanceof Object && b instanceof Object) {
|
|
61
|
+
return (a.constructor === b.constructor &&
|
|
62
|
+
Object.keys(a)
|
|
63
|
+
.filter(k => typeof a[k] !== "function")
|
|
64
|
+
.every(key => a[key] === b[key]));
|
|
65
|
+
}
|
|
66
|
+
return a === b;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Check if the object is a Storable object
|
|
70
|
+
* @param object - the value to check
|
|
71
|
+
* @returns true if it is a Storable
|
|
72
|
+
*/
|
|
73
|
+
export function isStorable(object) {
|
|
74
|
+
return typeof object.getPrimaryKey === "function" && Array.isArray(object[WEBDA_PRIMARY_KEY]);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=storable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storable.js","sourceRoot":"","sources":["../src/storable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI3C;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkB,MAAM,CAAC,aAAa,CAAC,CAAC;AACtE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAkB,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAC1F;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACvE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACvE;;GAEG;AACH,MAAM,CAAC,MAAM,aAA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