electrodb 1.12.1 → 2.0.0
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/.travis.yml +1 -1
- package/README.md +686 -648
- package/index.d.ts +180 -179
- package/package.json +1 -1
- package/src/clauses.js +15 -32
- package/src/entity.js +176 -89
- package/src/errors.js +6 -0
- package/src/filters.js +2 -2
- package/src/service.js +30 -111
- package/src/types.js +15 -2
- package/src/util.js +24 -0
- package/src/where.js +2 -2
- package/notes +0 -45
- package/output +0 -106
- package/taskdata.json +0 -1
- package/typez.ts +0 -1736
package/typez.ts
DELETED
|
@@ -1,1736 +0,0 @@
|
|
|
1
|
-
import {Entity, Service} from "./index";
|
|
2
|
-
|
|
3
|
-
export type DocumentClientMethod = (parameters: any) => {promise: () => Promise<any>};
|
|
4
|
-
|
|
5
|
-
export type DocumentClient = {
|
|
6
|
-
get: DocumentClientMethod;
|
|
7
|
-
put: DocumentClientMethod;
|
|
8
|
-
delete: DocumentClientMethod;
|
|
9
|
-
update: DocumentClientMethod;
|
|
10
|
-
batchWrite: DocumentClientMethod;
|
|
11
|
-
batchGet: DocumentClientMethod;
|
|
12
|
-
scan: DocumentClientMethod;
|
|
13
|
-
transactGet: DocumentClientMethod;
|
|
14
|
-
transactWrite: DocumentClientMethod;
|
|
15
|
-
} | {
|
|
16
|
-
send: (command: any) => Promise<any>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type AllCollectionNames<E extends {[name: string]: Entity<any, any, any, any>}> = {
|
|
20
|
-
[Name in keyof E]:
|
|
21
|
-
E[Name] extends Entity<infer A, infer F, infer C, infer S>
|
|
22
|
-
? {
|
|
23
|
-
[Collection in keyof EntityCollections<A,F,C,S>]: Collection
|
|
24
|
-
}[keyof EntityCollections<A,F,C,S>]
|
|
25
|
-
: never
|
|
26
|
-
}[keyof E];
|
|
27
|
-
|
|
28
|
-
export type AllEntityAttributeNames<E extends {[name: string]: Entity<any, any, any, any>}> = {
|
|
29
|
-
[Name in keyof E]: {
|
|
30
|
-
[A in keyof E[Name]["schema"]["attributes"]]: A
|
|
31
|
-
}[keyof E[Name]["schema"]["attributes"]]
|
|
32
|
-
}[keyof E];
|
|
33
|
-
|
|
34
|
-
export type AllEntityAttributes<E extends {[name: string]: Entity<any, any, any, any>}> = {
|
|
35
|
-
[Attr in AllEntityAttributeNames<E>]: {
|
|
36
|
-
[Name in keyof E]: Attr extends keyof E[Name]["schema"]["attributes"]
|
|
37
|
-
? ItemAttribute<E[Name]["schema"]["attributes"][Attr]>
|
|
38
|
-
: never
|
|
39
|
-
}[keyof E];
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type CollectionAssociations<E extends {[name: string]: Entity<any, any, any, any>}> = {
|
|
43
|
-
[Collection in AllCollectionNames<E>]: {
|
|
44
|
-
[Name in keyof E]: E[Name] extends Entity<infer A, infer F, infer C, infer S>
|
|
45
|
-
? Collection extends keyof EntityCollections<A,F,C,S>
|
|
46
|
-
? Name
|
|
47
|
-
: never
|
|
48
|
-
: never
|
|
49
|
-
}[keyof E];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type CollectionAttributes<E extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<E>> = {
|
|
53
|
-
[Collection in keyof Collections]: {
|
|
54
|
-
[EntityName in keyof E]: E[EntityName] extends Entity<infer A, infer F, infer C, infer S>
|
|
55
|
-
? EntityName extends Collections[Collection]
|
|
56
|
-
? keyof S["attributes"]
|
|
57
|
-
: never
|
|
58
|
-
: never
|
|
59
|
-
}[keyof E]
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface CollectionWhereOperations {
|
|
63
|
-
eq: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
64
|
-
ne: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
65
|
-
gt: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
66
|
-
lt: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
67
|
-
gte: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
68
|
-
lte: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
69
|
-
between: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T, value2: T) => string;
|
|
70
|
-
begins: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
71
|
-
exists: <T, A extends WhereAttributeSymbol<T>>(attr: A) => string;
|
|
72
|
-
notExists: <T, A extends WhereAttributeSymbol<T>>(attr: A) => string;
|
|
73
|
-
contains: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
74
|
-
notContains: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
75
|
-
value: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
76
|
-
name: <T, A extends WhereAttributeSymbol<T>>(attr: A) => string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export type CollectionWhereCallback<E extends {[name: string]: Entity<any, any, any, any>}, I extends Partial<AllEntityAttributes<E>>> =
|
|
80
|
-
<W extends {[A in keyof I]: WhereAttributeSymbol<I[A]>}>(attributes: W, operations: CollectionWhereOperations) => string;
|
|
81
|
-
|
|
82
|
-
export type CollectionWhereClause<E extends {[name: string]: Entity<any, any, any, any>}, A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Partial<AllEntityAttributes<E>>, T> = (where: CollectionWhereCallback<E, I>) => T;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
export interface ServiceWhereRecordsActionOptions<E extends {[name: string]: Entity<any, any, any, any>}, A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Partial<AllEntityAttributes<E>>, Items, IndexCompositeAttributes> {
|
|
86
|
-
go: ServiceQueryRecordsGo<Items>;
|
|
87
|
-
params: ParamRecord;
|
|
88
|
-
page: PageRecord<Items,IndexCompositeAttributes>;
|
|
89
|
-
where: CollectionWhereClause<E,A,F,C,S,I, ServiceWhereRecordsActionOptions<E,A,F,C,S,I,Items,IndexCompositeAttributes>>;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export type CollectionIndexKeys<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
|
|
93
|
-
[Collection in keyof Collections]: {
|
|
94
|
-
[EntityResultName in Collections[Collection]]:
|
|
95
|
-
EntityResultName extends keyof Entities
|
|
96
|
-
? Entities[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
97
|
-
? keyof TableIndexCompositeAttributes<A, F, C, S>
|
|
98
|
-
: never
|
|
99
|
-
: never
|
|
100
|
-
}[Collections[Collection]]
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export type CollectionPageKeys<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
|
|
104
|
-
[Collection in keyof Collections]: {
|
|
105
|
-
[EntityResultName in Collections[Collection]]:
|
|
106
|
-
EntityResultName extends keyof Entities
|
|
107
|
-
? Entities[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
108
|
-
? keyof Parameters<Entities[EntityResultName]["query"][
|
|
109
|
-
Collection extends keyof EntityCollections<A,F,C,S>
|
|
110
|
-
? EntityCollections<A,F,C,S>[Collection]
|
|
111
|
-
: never
|
|
112
|
-
]>[0]
|
|
113
|
-
: never
|
|
114
|
-
: never
|
|
115
|
-
}[Collections[Collection]]
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export type CollectionIndexAttributes<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
|
|
119
|
-
[Collection in keyof CollectionIndexKeys<Entities, Collections>]: {
|
|
120
|
-
[key in CollectionIndexKeys<Entities, Collections>[Collection]]:
|
|
121
|
-
key extends keyof AllEntityAttributes<Entities>
|
|
122
|
-
? AllEntityAttributes<Entities>[key]
|
|
123
|
-
: never
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export type CollectionPageAttributes<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
|
|
128
|
-
[Collection in keyof CollectionPageKeys<Entities, Collections>]: {
|
|
129
|
-
[key in CollectionPageKeys<Entities, Collections>[Collection]]:
|
|
130
|
-
key extends keyof AllEntityAttributes<Entities>
|
|
131
|
-
? AllEntityAttributes<Entities>[key]
|
|
132
|
-
: never
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export type OptionalPropertyNames<T> =
|
|
137
|
-
{ [K in keyof T]: undefined extends T[K] ? K : never }[keyof T];
|
|
138
|
-
|
|
139
|
-
// Common properties from L and R with undefined in R[K] replaced by type in L[K]
|
|
140
|
-
export type SpreadProperties<L, R, K extends keyof L & keyof R> =
|
|
141
|
-
{ [P in K]: L[P] | Exclude<R[P], undefined> };
|
|
142
|
-
|
|
143
|
-
export type Id<T> = {[K in keyof T]: T[K]} // see note at bottom*
|
|
144
|
-
|
|
145
|
-
// Type of { ...L, ...R }
|
|
146
|
-
export type Spread<L, R> = Id<
|
|
147
|
-
// Properties in L that don't exist in R
|
|
148
|
-
& Pick<L, Exclude<keyof L, keyof R>>
|
|
149
|
-
// Properties in R with types that exclude undefined
|
|
150
|
-
& Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>>
|
|
151
|
-
// Properties in R, with types that include undefined, that don't exist in L
|
|
152
|
-
& Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>>
|
|
153
|
-
// Properties in R, with types that include undefined, that exist in L
|
|
154
|
-
& SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>
|
|
155
|
-
>;
|
|
156
|
-
|
|
157
|
-
export type RequiredProperties<T> = Pick<T, {[K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T]>
|
|
158
|
-
|
|
159
|
-
export type CollectionQueries<E extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<E>> = {
|
|
160
|
-
[Collection in keyof Collections]: {
|
|
161
|
-
[EntityName in keyof E]:
|
|
162
|
-
EntityName extends Collections[Collection]
|
|
163
|
-
? (params:
|
|
164
|
-
RequiredProperties<
|
|
165
|
-
Parameters<
|
|
166
|
-
E[EntityName]["query"][
|
|
167
|
-
E[EntityName] extends Entity<infer A, infer F, infer C, infer S>
|
|
168
|
-
? Collection extends keyof EntityCollections<A,F,C,S>
|
|
169
|
-
? EntityCollections<A,F,C,S>[Collection]
|
|
170
|
-
: never
|
|
171
|
-
: never
|
|
172
|
-
]
|
|
173
|
-
>[0]
|
|
174
|
-
>) => {
|
|
175
|
-
go: ServiceQueryRecordsGo<{
|
|
176
|
-
[EntityResultName in Collections[Collection]]:
|
|
177
|
-
EntityResultName extends keyof E
|
|
178
|
-
? E[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
179
|
-
? ResponseItem<A,F,C,S>[]
|
|
180
|
-
: never
|
|
181
|
-
: never
|
|
182
|
-
}>;
|
|
183
|
-
params: ParamRecord;
|
|
184
|
-
page: {
|
|
185
|
-
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
186
|
-
? Pick<AllEntityAttributes<E>, Extract<AllEntityAttributeNames<E>, CollectionAttributes<E,Collections>[Collection]>> extends Partial<AllEntityAttributes<E>>
|
|
187
|
-
?
|
|
188
|
-
PageRecord<
|
|
189
|
-
{
|
|
190
|
-
[EntityResultName in Collections[Collection]]:
|
|
191
|
-
EntityResultName extends keyof E
|
|
192
|
-
? E[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
193
|
-
? ResponseItem<A,F,C,S>[]
|
|
194
|
-
: never
|
|
195
|
-
: never
|
|
196
|
-
},
|
|
197
|
-
Partial<
|
|
198
|
-
Spread<
|
|
199
|
-
Collection extends keyof CollectionPageAttributes<E, Collections>
|
|
200
|
-
? CollectionPageAttributes<E, Collections>[Collection]
|
|
201
|
-
: {},
|
|
202
|
-
Collection extends keyof CollectionIndexAttributes<E, Collections>
|
|
203
|
-
? CollectionIndexAttributes<E, Collections>[Collection]
|
|
204
|
-
: {}
|
|
205
|
-
>
|
|
206
|
-
>
|
|
207
|
-
>
|
|
208
|
-
: never
|
|
209
|
-
: never
|
|
210
|
-
}[Collections[Collection]];
|
|
211
|
-
where: {
|
|
212
|
-
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
213
|
-
? E[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
214
|
-
? Pick<AllEntityAttributes<E>, Extract<AllEntityAttributeNames<E>, CollectionAttributes<E,Collections>[Collection]>> extends Partial<AllEntityAttributes<E>>
|
|
215
|
-
? CollectionWhereClause<E,A,F,C,S,
|
|
216
|
-
Pick<AllEntityAttributes<E>, Extract<AllEntityAttributeNames<E>, CollectionAttributes<E,Collections>[Collection]>>,
|
|
217
|
-
ServiceWhereRecordsActionOptions<E,A,F,C,S,
|
|
218
|
-
Pick<AllEntityAttributes<E>, Extract<AllEntityAttributeNames<E>, CollectionAttributes<E,Collections>[Collection]>>,
|
|
219
|
-
{
|
|
220
|
-
[EntityResultName in Collections[Collection]]:
|
|
221
|
-
EntityResultName extends keyof E
|
|
222
|
-
? E[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
223
|
-
? ResponseItem<A,F,C,S>[]
|
|
224
|
-
: never
|
|
225
|
-
: never
|
|
226
|
-
},
|
|
227
|
-
Partial<
|
|
228
|
-
Spread<
|
|
229
|
-
Collection extends keyof CollectionPageAttributes<E, Collections>
|
|
230
|
-
? CollectionPageAttributes<E, Collections>[Collection]
|
|
231
|
-
: {},
|
|
232
|
-
Collection extends keyof CollectionIndexAttributes<E, Collections>
|
|
233
|
-
? CollectionIndexAttributes<E, Collections>[Collection]
|
|
234
|
-
: {}
|
|
235
|
-
>
|
|
236
|
-
>
|
|
237
|
-
>>
|
|
238
|
-
: never
|
|
239
|
-
: never
|
|
240
|
-
: never
|
|
241
|
-
}[Collections[Collection]];
|
|
242
|
-
}
|
|
243
|
-
: never
|
|
244
|
-
}[keyof E];
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export type ElectroDBMethodTypes = "put" | "get" | "query" | "scan" | "update" | "delete" | "remove" | "patch" | "create" | "batchGet" | "batchWrite";
|
|
248
|
-
|
|
249
|
-
export interface ElectroQueryEvent<P extends any = any> {
|
|
250
|
-
type: 'query';
|
|
251
|
-
method: ElectroDBMethodTypes;
|
|
252
|
-
config: any;
|
|
253
|
-
params: P;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export interface ElectroResultsEvent<R extends any = any> {
|
|
257
|
-
type: 'results';
|
|
258
|
-
method: ElectroDBMethodTypes;
|
|
259
|
-
config: any;
|
|
260
|
-
results: R;
|
|
261
|
-
success: boolean;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export type ElectroEvent =
|
|
265
|
-
ElectroQueryEvent
|
|
266
|
-
| ElectroResultsEvent;
|
|
267
|
-
|
|
268
|
-
export type ElectroEventType = Pick<ElectroEvent, 'type'>;
|
|
269
|
-
|
|
270
|
-
export type ElectroEventListener = (event: ElectroEvent) => void;
|
|
271
|
-
|
|
272
|
-
// todo: coming soon, more events!
|
|
273
|
-
// | {
|
|
274
|
-
// name: "error";
|
|
275
|
-
// type: "configuration_error" | "invalid_query" | "dynamodb_client";
|
|
276
|
-
// message: string;
|
|
277
|
-
// details: ElectroError;
|
|
278
|
-
// } | {
|
|
279
|
-
// name: "error";
|
|
280
|
-
// type: "user_defined";
|
|
281
|
-
// message: string;
|
|
282
|
-
// details: ElectroValidationError;
|
|
283
|
-
// } | {
|
|
284
|
-
// name: "warn";
|
|
285
|
-
// type: "deprecation_warning" | "optimization_suggestion";
|
|
286
|
-
// message: string;
|
|
287
|
-
// details: any;
|
|
288
|
-
// } | {
|
|
289
|
-
// name: "info";
|
|
290
|
-
// type: "client_updated" | "table_overwritten";
|
|
291
|
-
// message: string;
|
|
292
|
-
// details: any;
|
|
293
|
-
// };
|
|
294
|
-
|
|
295
|
-
export type EntityItem<E extends Entity<any, any, any, any>> =
|
|
296
|
-
E extends Entity<infer A, infer F, infer C, infer S>
|
|
297
|
-
? ResponseItem<A, F, C, S>
|
|
298
|
-
: never;
|
|
299
|
-
|
|
300
|
-
export type CreateEntityItem<E extends Entity<any, any, any, any>> =
|
|
301
|
-
E extends Entity<infer A, infer F, infer C, infer S>
|
|
302
|
-
? PutItem<A, F, C, S>
|
|
303
|
-
: never;
|
|
304
|
-
|
|
305
|
-
export type UpdateEntityItem<E extends Entity<any, any, any, any>> =
|
|
306
|
-
E extends Entity<infer A, infer F, infer C, infer S>
|
|
307
|
-
? Partial<ResponseItem<A,F,C,S>>
|
|
308
|
-
: never;
|
|
309
|
-
|
|
310
|
-
export type UpdateAddEntityItem<E extends Entity<any, any, any, any>> =
|
|
311
|
-
E extends Entity<infer A, infer F, infer C, infer S>
|
|
312
|
-
? AddItem<A, F, C, S>
|
|
313
|
-
: never;
|
|
314
|
-
|
|
315
|
-
export type UpdateSubtractEntityItem<E extends Entity<any, any, any, any>> =
|
|
316
|
-
E extends Entity<infer A, infer F, infer C, infer S>
|
|
317
|
-
? SubtractItem<A, F, C, S>
|
|
318
|
-
: never;
|
|
319
|
-
|
|
320
|
-
export type UpdateAppendEntityItem<E extends Entity<any, any, any, any>> =
|
|
321
|
-
E extends Entity<infer A, infer F, infer C, infer S>
|
|
322
|
-
? AppendItem<A, F, C, S>
|
|
323
|
-
: never;
|
|
324
|
-
|
|
325
|
-
export type UpdateRemoveEntityItem<E extends Entity<any, any, any, any>> =
|
|
326
|
-
E extends Entity<infer A, infer F, infer C, infer S>
|
|
327
|
-
? RemoveItem<A, F, C, S>
|
|
328
|
-
: never;
|
|
329
|
-
|
|
330
|
-
export type UpdateDeleteEntityItem<E extends Entity<any, any, any, any>> =
|
|
331
|
-
E extends Entity<infer A, infer F, infer C, infer S>
|
|
332
|
-
? DeleteItem<A, F, C, S>
|
|
333
|
-
: never;
|
|
334
|
-
|
|
335
|
-
export type EntityRecord<E extends Entity<any, any, any, any>> =
|
|
336
|
-
E extends Entity<infer A, infer F, infer C, infer S>
|
|
337
|
-
? Item<A,F,C,S,S["attributes"]>
|
|
338
|
-
: never;
|
|
339
|
-
|
|
340
|
-
export type CollectionItem<SERVICE extends Service<any>, COLLECTION extends keyof SERVICE["collections"]> =
|
|
341
|
-
SERVICE extends Service<infer E>
|
|
342
|
-
? Pick<{
|
|
343
|
-
[EntityName in keyof E]: E[EntityName] extends Entity<infer A, infer F, infer C, infer S>
|
|
344
|
-
? COLLECTION extends keyof CollectionAssociations<E>
|
|
345
|
-
? EntityName extends CollectionAssociations<E>[COLLECTION]
|
|
346
|
-
? ResponseItem<A,F,C,S>[]
|
|
347
|
-
: never
|
|
348
|
-
: never
|
|
349
|
-
: never
|
|
350
|
-
}, COLLECTION extends keyof CollectionAssociations<E>
|
|
351
|
-
? CollectionAssociations<E>[COLLECTION]
|
|
352
|
-
: never>
|
|
353
|
-
: never
|
|
354
|
-
|
|
355
|
-
export interface QueryBranches<A extends string,
|
|
356
|
-
F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem, IndexCompositeAttributes> {
|
|
357
|
-
go: GoQueryTerminal<A,F,C,S,ResponseItem>;
|
|
358
|
-
params: ParamTerminal<A,F,C,S,ResponseItem>;
|
|
359
|
-
page: PageQueryTerminal<A,F,C,S,ResponseItem,IndexCompositeAttributes>;
|
|
360
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,QueryBranches<A,F,C,S,ResponseItem,IndexCompositeAttributes>>
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
export interface RecordsActionOptions<A extends string,
|
|
364
|
-
F extends string, C extends string, S extends Schema<A,F,C>, Items, IndexCompositeAttributes> {
|
|
365
|
-
go: QueryRecordsGo<Items>;
|
|
366
|
-
params: ParamRecord;
|
|
367
|
-
page: PageRecord<Items,IndexCompositeAttributes>;
|
|
368
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,RecordsActionOptions<A,F,C,S,Items,IndexCompositeAttributes>>;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export interface SingleRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
372
|
-
go: GoGetTerminal<A,F,C,S, ResponseType>;
|
|
373
|
-
params: ParamTerminal<A,F,C,S,ResponseType>;
|
|
374
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,SingleRecordOperationOptions<A,F,C,S,ResponseType>>;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
export interface BatchGetRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
378
|
-
go: GoBatchGetTerminal<A,F,C,S,ResponseType>
|
|
379
|
-
params: ParamTerminal<A,F,C,S,ResponseType>;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
export interface PutRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
383
|
-
go: PutRecordGo<ResponseType, PutQueryOptions>;
|
|
384
|
-
params: ParamRecord<PutQueryOptions>;
|
|
385
|
-
where: WhereClause<A, F, C, S, Item<A, F, C, S, S["attributes"]>, PutRecordOperationOptions<A, F, C, S, ResponseType>>;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
export interface DeleteRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
389
|
-
go: DeleteRecordOperationGo<ResponseType, DeleteQueryOptions>;
|
|
390
|
-
params: ParamRecord<DeleteQueryOptions>;
|
|
391
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,DeleteRecordOperationOptions<A,F,C,S,ResponseType>>;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
export interface BatchWriteOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
395
|
-
go: BatchWriteGo<ResponseType>;
|
|
396
|
-
params: ParamRecord<BulkOptions>;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
export interface SetRecordActionOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr,IndexCompositeAttributes,TableItem> {
|
|
400
|
-
go: UpdateRecordGo<Partial<TableItem>, UpdateQueryOptions>;
|
|
401
|
-
params: ParamRecord<UpdateQueryParams>;
|
|
402
|
-
set: SetRecord<A,F,C,S, SetItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
403
|
-
remove: SetRecord<A,F,C,S, Array<keyof SetItem<A,F,C,S>>,IndexCompositeAttributes,TableItem>;
|
|
404
|
-
add: SetRecord<A,F,C,S, AddItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
405
|
-
subtract: SetRecord<A,F,C,S, SubtractItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
406
|
-
append: SetRecord<A,F,C,S, AppendItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
407
|
-
delete: SetRecord<A,F,C,S, DeleteItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
408
|
-
data: DataUpdateMethodRecord<A,F,C,S, Item<A,F,C,S,S["attributes"]>,IndexCompositeAttributes,TableItem>;
|
|
409
|
-
where: WhereClause<A,F,C,S, Item<A,F,C,S,S["attributes"]>,SetRecordActionOptions<A,F,C,S,SetAttr,IndexCompositeAttributes,TableItem>>;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
export type SetRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr, IndexCompositeAttributes, TableItem> = (properties: SetAttr) =>
|
|
413
|
-
SetRecordActionOptions<A,F,C,S, SetAttr, IndexCompositeAttributes, TableItem>;
|
|
414
|
-
|
|
415
|
-
export type RemoveRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, RemoveAttr, IndexCompositeAttributes, TableItem> = (properties: RemoveAttr) =>
|
|
416
|
-
SetRecordActionOptions<A,F,C,S, RemoveAttr, IndexCompositeAttributes, TableItem>;
|
|
417
|
-
|
|
418
|
-
export type DataUpdateMethodRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr, IndexCompositeAttributes, TableItem> =
|
|
419
|
-
DataUpdateMethod<A,F,C,S, UpdateData<A,F,C,S>, SetRecordActionOptions<A,F,C,S, SetAttr, IndexCompositeAttributes, TableItem>>
|
|
420
|
-
|
|
421
|
-
interface QueryOperations<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, CompositeAttributes, ResponseItem, IndexCompositeAttributes> {
|
|
422
|
-
between: (skCompositeAttributesStart: CompositeAttributes, skCompositeAttributesEnd: CompositeAttributes) => QueryBranches<A,F,C,S, ResponseItem, IndexCompositeAttributes>;
|
|
423
|
-
gt: (skCompositeAttributes: CompositeAttributes) => QueryBranches<A,F,C,S, ResponseItem,IndexCompositeAttributes>;
|
|
424
|
-
gte: (skCompositeAttributes: CompositeAttributes) => QueryBranches<A,F,C,S, ResponseItem,IndexCompositeAttributes>;
|
|
425
|
-
lt: (skCompositeAttributes: CompositeAttributes) => QueryBranches<A,F,C,S, ResponseItem,IndexCompositeAttributes>;
|
|
426
|
-
lte: (skCompositeAttributes: CompositeAttributes) => QueryBranches<A,F,C,S, ResponseItem,IndexCompositeAttributes>;
|
|
427
|
-
begins: (skCompositeAttributes: CompositeAttributes) => QueryBranches<A,F,C,S, ResponseItem,IndexCompositeAttributes>;
|
|
428
|
-
go: GoQueryTerminal<A,F,C,S,ResponseItem>;
|
|
429
|
-
params: ParamTerminal<A,F,C,S,ResponseItem>;
|
|
430
|
-
page: PageQueryTerminal<A,F,C,S,ResponseItem,IndexCompositeAttributes>;
|
|
431
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,QueryBranches<A,F,C,S,ResponseItem,IndexCompositeAttributes>>
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
export type Queries<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
435
|
-
[I in keyof S["indexes"]]: <CompositeAttributes extends IndexCompositeAttributes<A,F,C,S,I>>(composite: CompositeAttributes) =>
|
|
436
|
-
IndexSKAttributes<A,F,C,S,I> extends infer SK
|
|
437
|
-
// If there is no SK, dont show query operations (when an empty array is provided)
|
|
438
|
-
? [keyof SK] extends [never]
|
|
439
|
-
? QueryBranches<A,F,C,S, ResponseItem<A,F,C,S>, AllTableIndexCompositeAttributes<A,F,C,S> & Required<CompositeAttributes>>
|
|
440
|
-
// If there is no SK, dont show query operations (When no PK is specified)
|
|
441
|
-
: S["indexes"][I] extends IndexWithSortKey
|
|
442
|
-
? QueryOperations<
|
|
443
|
-
A,F,C,S,
|
|
444
|
-
// Omit the composite attributes already provided
|
|
445
|
-
Omit<Partial<IndexSKAttributes<A,F,C,S,I>>, keyof CompositeAttributes>,
|
|
446
|
-
ResponseItem<A,F,C,S>,
|
|
447
|
-
AllTableIndexCompositeAttributes<A,F,C,S> & Required<CompositeAttributes> & SK
|
|
448
|
-
>
|
|
449
|
-
: QueryBranches<A,F,C,S, ResponseItem<A,F,C,S>, AllTableIndexCompositeAttributes<A,F,C,S> & Required<CompositeAttributes> & SK>
|
|
450
|
-
: never
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
export type ParseSingleInput = {
|
|
454
|
-
Item?: {[key: string]: any}
|
|
455
|
-
} | {
|
|
456
|
-
Attributes?: {[key: string]: any}
|
|
457
|
-
} | null;
|
|
458
|
-
|
|
459
|
-
export type ParseMultiInput = {
|
|
460
|
-
Items?: {[key: string]: any}[]
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
export type ReturnValues = "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
464
|
-
|
|
465
|
-
export interface QueryOptions {
|
|
466
|
-
raw?: boolean;
|
|
467
|
-
table?: string;
|
|
468
|
-
limit?: number;
|
|
469
|
-
params?: object;
|
|
470
|
-
includeKeys?: boolean;
|
|
471
|
-
originalErr?: boolean;
|
|
472
|
-
ignoreOwnership?: boolean;
|
|
473
|
-
pages?: number;
|
|
474
|
-
listeners?: Array<ElectroEventListener>;
|
|
475
|
-
logger?: ElectroEventListener;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// subset of QueryOptions
|
|
479
|
-
export interface ParseOptions<Attributes> {
|
|
480
|
-
attributes?: ReadonlyArray<Attributes>;
|
|
481
|
-
ignoreOwnership?: boolean;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
export interface UpdateQueryOptions extends QueryOptions {
|
|
485
|
-
response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
export interface UpdateQueryParams {
|
|
489
|
-
response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
490
|
-
table?: string;
|
|
491
|
-
params?: object;
|
|
492
|
-
originalErr?: boolean;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
export interface DeleteQueryOptions extends QueryOptions {
|
|
496
|
-
response?: "default" | "none" | 'all_old';
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
export interface PutQueryOptions extends QueryOptions {
|
|
500
|
-
response?: "default" | "none" | 'all_old';
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
export interface ParamOptions {
|
|
504
|
-
params?: object;
|
|
505
|
-
table?: string;
|
|
506
|
-
limit?: number;
|
|
507
|
-
response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
export interface PaginationOptions extends QueryOptions {
|
|
511
|
-
pager?: "raw" | "item" | "named";
|
|
512
|
-
limit?: number;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
export interface BulkOptions extends QueryOptions {
|
|
516
|
-
unprocessed?: "raw" | "item";
|
|
517
|
-
concurrency?: number;
|
|
518
|
-
preserveBatchOrder?: boolean;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
export type OptionalDefaultEntityIdentifiers = {
|
|
522
|
-
__edb_e__?: string;
|
|
523
|
-
__edb_v__?: string;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
interface GoBatchGetTerminalOptions<Attributes> {
|
|
527
|
-
raw?: boolean;
|
|
528
|
-
table?: string;
|
|
529
|
-
limit?: number;
|
|
530
|
-
params?: object;
|
|
531
|
-
includeKeys?: boolean;
|
|
532
|
-
originalErr?: boolean;
|
|
533
|
-
ignoreOwnership?: boolean;
|
|
534
|
-
pages?: number;
|
|
535
|
-
attributes?: ReadonlyArray<Attributes>;
|
|
536
|
-
unprocessed?: "raw" | "item";
|
|
537
|
-
concurrency?: number;
|
|
538
|
-
preserveBatchOrder?: boolean;
|
|
539
|
-
listeners?: Array<ElectroEventListener>;
|
|
540
|
-
logger?: ElectroEventListener;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
interface GoQueryTerminalOptions<Attributes> {
|
|
544
|
-
raw?: boolean;
|
|
545
|
-
table?: string;
|
|
546
|
-
limit?: number;
|
|
547
|
-
params?: object;
|
|
548
|
-
includeKeys?: boolean;
|
|
549
|
-
originalErr?: boolean;
|
|
550
|
-
ignoreOwnership?: boolean;
|
|
551
|
-
pages?: number;
|
|
552
|
-
attributes?: ReadonlyArray<Attributes>;
|
|
553
|
-
listeners?: Array<ElectroEventListener>;
|
|
554
|
-
logger?: ElectroEventListener;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
interface PageQueryTerminalOptions<Attributes> extends GoQueryTerminalOptions<Attributes> {
|
|
558
|
-
pager?: "raw" | "item" | "named";
|
|
559
|
-
raw?: boolean;
|
|
560
|
-
table?: string;
|
|
561
|
-
limit?: number;
|
|
562
|
-
includeKeys?: boolean;
|
|
563
|
-
originalErr?: boolean;
|
|
564
|
-
ignoreOwnership?: boolean;
|
|
565
|
-
attributes?: ReadonlyArray<Attributes>;
|
|
566
|
-
listeners?: Array<ElectroEventListener>;
|
|
567
|
-
logger?: ElectroEventListener;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
export interface ParamTerminalOptions<Attributes> {
|
|
571
|
-
table?: string;
|
|
572
|
-
limit?: number;
|
|
573
|
-
params?: object;
|
|
574
|
-
originalErr?: boolean;
|
|
575
|
-
attributes?: ReadonlyArray<Attributes>;
|
|
576
|
-
response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
type GoBatchGetTerminal<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem> = <Options extends GoBatchGetTerminalOptions<keyof ResponseItem>>(options?: Options) =>
|
|
580
|
-
Options extends GoBatchGetTerminalOptions<infer Attr>
|
|
581
|
-
? 'preserveBatchOrder' extends keyof Options
|
|
582
|
-
? Options['preserveBatchOrder'] extends true
|
|
583
|
-
? Promise<{
|
|
584
|
-
data: Array<Resolve<{
|
|
585
|
-
[
|
|
586
|
-
Name in keyof ResponseItem as Name extends Attr
|
|
587
|
-
? Name
|
|
588
|
-
: never
|
|
589
|
-
]: ResponseItem[Name]
|
|
590
|
-
} | null>>,
|
|
591
|
-
unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>>
|
|
592
|
-
}>
|
|
593
|
-
: Promise<{
|
|
594
|
-
data: Array<Resolve<{
|
|
595
|
-
[
|
|
596
|
-
Name in keyof ResponseItem as Name extends Attr
|
|
597
|
-
? Name
|
|
598
|
-
: never
|
|
599
|
-
]: ResponseItem[Name]
|
|
600
|
-
}>>,
|
|
601
|
-
unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>>
|
|
602
|
-
}>
|
|
603
|
-
: Promise<{
|
|
604
|
-
data: Array<Resolve<{
|
|
605
|
-
[
|
|
606
|
-
Name in keyof ResponseItem as Name extends Attr
|
|
607
|
-
? Name
|
|
608
|
-
: never
|
|
609
|
-
]: ResponseItem[Name]
|
|
610
|
-
}>>,
|
|
611
|
-
unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>>
|
|
612
|
-
}>
|
|
613
|
-
: 'preserveBatchOrder' extends keyof Options
|
|
614
|
-
? Options['preserveBatchOrder'] extends true
|
|
615
|
-
? { data: Array<Resolve<ResponseItem | null>>, unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>> }
|
|
616
|
-
: { data: Array<Resolve<ResponseItem>>, unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>> }
|
|
617
|
-
: { data: Array<Resolve<ResponseItem>>, unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>> }
|
|
618
|
-
|
|
619
|
-
type GoGetTerminal<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem> = <Options extends GoQueryTerminalOptions<keyof ResponseItem>>(options?: Options) =>
|
|
620
|
-
Options extends GoQueryTerminalOptions<infer Attr>
|
|
621
|
-
? Promise<{
|
|
622
|
-
data: {
|
|
623
|
-
[Name in keyof ResponseItem as Name extends Attr
|
|
624
|
-
? Name
|
|
625
|
-
: never]: ResponseItem[Name]
|
|
626
|
-
}
|
|
627
|
-
} | null>
|
|
628
|
-
: Promise<{ data: ResponseItem | null }>
|
|
629
|
-
|
|
630
|
-
export type GoQueryTerminal<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, Item> = <Options extends GoQueryTerminalOptions<keyof Item>>(options?: Options) =>
|
|
631
|
-
Options extends GoQueryTerminalOptions<infer Attr>
|
|
632
|
-
? Promise<Array<{
|
|
633
|
-
[
|
|
634
|
-
Name in keyof Item as Name extends Attr
|
|
635
|
-
? Name
|
|
636
|
-
: never
|
|
637
|
-
]: Item[Name]
|
|
638
|
-
}>>
|
|
639
|
-
: Promise<Array<Item>>
|
|
640
|
-
|
|
641
|
-
export type EntityParseMultipleItems<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem> =
|
|
642
|
-
<Options extends ParseOptions<keyof ResponseItem>>(item: ParseMultiInput, options?: Options) =>
|
|
643
|
-
Options extends ParseOptions<infer Attr>
|
|
644
|
-
? Array<{
|
|
645
|
-
[
|
|
646
|
-
Name in keyof ResponseItem as Name extends Attr
|
|
647
|
-
? Name
|
|
648
|
-
: never
|
|
649
|
-
]: ResponseItem[Name]
|
|
650
|
-
}>
|
|
651
|
-
: Array<ResponseItem>
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
export type PageQueryTerminal<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, Item, CompositeAttributes> = <Options extends PageQueryTerminalOptions<keyof Item>>(page?: (CompositeAttributes & OptionalDefaultEntityIdentifiers) | null, options?: Options) =>
|
|
655
|
-
Options extends GoQueryTerminalOptions<infer Attr>
|
|
656
|
-
? Promise<[
|
|
657
|
-
(CompositeAttributes & OptionalDefaultEntityIdentifiers) | null,
|
|
658
|
-
Array<{
|
|
659
|
-
[
|
|
660
|
-
Name in keyof Item as Name extends Attr
|
|
661
|
-
? Name
|
|
662
|
-
: never
|
|
663
|
-
]: Item[Name]
|
|
664
|
-
}>
|
|
665
|
-
]>
|
|
666
|
-
: Promise<[
|
|
667
|
-
(CompositeAttributes & OptionalDefaultEntityIdentifiers) | null,
|
|
668
|
-
Array<ResponseType>
|
|
669
|
-
]>;
|
|
670
|
-
|
|
671
|
-
export type ParamTerminal<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem> = <P extends any = any, Options extends ParamTerminalOptions<keyof ResponseItem> = ParamTerminalOptions<keyof ResponseItem>>(options?: Options) => P;
|
|
672
|
-
|
|
673
|
-
export type ServiceQueryRecordsGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{ data: T, cursor?: string }>;
|
|
674
|
-
|
|
675
|
-
export type QueryRecordsGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{ data: T, cursor?: string }>;
|
|
676
|
-
|
|
677
|
-
export type UpdateRecordGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{ data: T }>;
|
|
678
|
-
|
|
679
|
-
export type PutRecordGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{ data: T }>;
|
|
680
|
-
|
|
681
|
-
export type DeleteRecordOperationGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{unprocessed: T}>;
|
|
682
|
-
|
|
683
|
-
export type BatchWriteGo<ResponseType> = <O extends BulkOptions>(options?: O) =>
|
|
684
|
-
Promise<{ unprocessed: ResponseType }>
|
|
685
|
-
|
|
686
|
-
export type PageRecord<ResponseType, CompositeAttributes> = (page?: (CompositeAttributes & OptionalDefaultEntityIdentifiers) | null, options?: PaginationOptions) => Promise<[
|
|
687
|
-
(CompositeAttributes & OptionalDefaultEntityIdentifiers) | null,
|
|
688
|
-
ResponseType
|
|
689
|
-
]>;
|
|
690
|
-
|
|
691
|
-
export type ParamRecord<Options = ParamOptions> = <P>(options?: Options) => P;
|
|
692
|
-
|
|
693
|
-
export interface ElectroError extends Error {
|
|
694
|
-
readonly name: 'ElectroError';
|
|
695
|
-
readonly code: number;
|
|
696
|
-
readonly date: number;
|
|
697
|
-
readonly isElectroError: boolean;
|
|
698
|
-
ref: {
|
|
699
|
-
readonly code: number;
|
|
700
|
-
readonly section: string;
|
|
701
|
-
readonly name: string;
|
|
702
|
-
readonly sym: unique symbol;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
export interface ElectroValidationErrorFieldReference<T extends Error = Error> {
|
|
707
|
-
/**
|
|
708
|
-
* The json path to the attribute that had a validation error
|
|
709
|
-
*/
|
|
710
|
-
readonly field: string;
|
|
711
|
-
|
|
712
|
-
/**
|
|
713
|
-
* A description of the validation error for that attribute
|
|
714
|
-
*/
|
|
715
|
-
readonly reason: string;
|
|
716
|
-
|
|
717
|
-
/**
|
|
718
|
-
* Index of the value passed (present only in List attribute validation errors)
|
|
719
|
-
*/
|
|
720
|
-
readonly index: number | undefined;
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* The error thrown from the attribute's validate callback (if applicable)
|
|
724
|
-
*/
|
|
725
|
-
readonly cause: T | undefined;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
export interface ElectroValidationError<T extends Error = Error> extends ElectroError {
|
|
729
|
-
readonly fields: ReadonlyArray<ElectroValidationErrorFieldReference<T>>;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
export interface ReadOnlyAttribute {
|
|
733
|
-
readonly readOnly: true;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
export interface RequiredAttribute {
|
|
737
|
-
required: true;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
export interface HiddenAttribute {
|
|
741
|
-
readonly hidden: true;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
export interface DefaultedAttribute {
|
|
745
|
-
readonly default: any;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
export interface SecondaryIndex {
|
|
749
|
-
readonly index: string;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
export interface NestedBooleanAttribute {
|
|
753
|
-
readonly type: "boolean";
|
|
754
|
-
readonly required?: boolean;
|
|
755
|
-
readonly hidden?: boolean;
|
|
756
|
-
readonly readOnly?: boolean;
|
|
757
|
-
readonly get?: (val: boolean, item: any) => boolean | undefined | void;
|
|
758
|
-
readonly set?: (val?: boolean, item?: any) => boolean | undefined | void;
|
|
759
|
-
readonly default?: boolean | (() => boolean);
|
|
760
|
-
readonly validate?: ((val: boolean) => boolean) | ((val: boolean) => void) | ((val: boolean) => string | void);
|
|
761
|
-
readonly field?: string;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
export interface BooleanAttribute {
|
|
765
|
-
readonly type: "boolean";
|
|
766
|
-
readonly required?: boolean;
|
|
767
|
-
readonly hidden?: boolean;
|
|
768
|
-
readonly readOnly?: boolean;
|
|
769
|
-
readonly get?: (val: boolean, item: any) => boolean | undefined | void;
|
|
770
|
-
readonly set?: (val?: boolean, item?: any) => boolean | undefined | void;
|
|
771
|
-
readonly default?: boolean | (() => boolean);
|
|
772
|
-
readonly validate?: ((val: boolean) => boolean) | ((val: boolean) => void) | ((val: boolean) => string | void);
|
|
773
|
-
readonly field?: string;
|
|
774
|
-
readonly label?: string;
|
|
775
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
export interface NestedNumberAttribute {
|
|
779
|
-
readonly type: "number";
|
|
780
|
-
readonly required?: boolean;
|
|
781
|
-
readonly hidden?: boolean;
|
|
782
|
-
readonly readOnly?: boolean;
|
|
783
|
-
readonly get?: (val: number, item: any) => number | undefined | void;
|
|
784
|
-
readonly set?: (val?: number, item?: any) => number | undefined | void;
|
|
785
|
-
readonly default?: number | (() => number);
|
|
786
|
-
readonly validate?: ((val: number) => boolean) | ((val: number) => void) | ((val: number) => string | void);
|
|
787
|
-
readonly field?: string;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
export interface NumberAttribute {
|
|
791
|
-
readonly type: "number";
|
|
792
|
-
readonly required?: boolean;
|
|
793
|
-
readonly hidden?: boolean;
|
|
794
|
-
readonly readOnly?: boolean;
|
|
795
|
-
readonly get?: (val: number, item: any) => number | undefined | void;
|
|
796
|
-
readonly set?: (val?: number, item?: any) => number | undefined | void;
|
|
797
|
-
readonly default?: number | (() => number);
|
|
798
|
-
readonly validate?: ((val: number) => boolean) | ((val: number) => void) | ((val: number) => string | void);
|
|
799
|
-
readonly field?: string;
|
|
800
|
-
readonly label?: string;
|
|
801
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
export interface NestedStringAttribute {
|
|
805
|
-
readonly type: "string";
|
|
806
|
-
readonly required?: boolean;
|
|
807
|
-
readonly hidden?: boolean;
|
|
808
|
-
readonly readOnly?: boolean;
|
|
809
|
-
readonly get?: (val: string, item: any) => string | undefined | void;
|
|
810
|
-
readonly set?: (val?: string, item?: any) => string | undefined | void;
|
|
811
|
-
readonly default?: string | (() => string);
|
|
812
|
-
readonly validate?: ((val: string) => boolean) | ((val: string) => void) | ((val: string) => string | void) | RegExp;
|
|
813
|
-
readonly field?: string;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
export interface StringAttribute {
|
|
817
|
-
readonly type: "string";
|
|
818
|
-
readonly required?: boolean;
|
|
819
|
-
readonly hidden?: boolean;
|
|
820
|
-
readonly readOnly?: boolean;
|
|
821
|
-
readonly get?: (val: string, item: any) => string | undefined | void;
|
|
822
|
-
readonly set?: (val?: string, item?: any) => string | undefined | void;
|
|
823
|
-
readonly default?: string | (() => string);
|
|
824
|
-
readonly validate?: ((val: string) => boolean) | ((val: string) => void) | ((val: string) => string | void) | RegExp;
|
|
825
|
-
readonly field?: string;
|
|
826
|
-
readonly label?: string;
|
|
827
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
export interface NestedEnumAttribute {
|
|
831
|
-
readonly type: ReadonlyArray<string>;
|
|
832
|
-
readonly required?: boolean;
|
|
833
|
-
readonly hidden?: boolean;
|
|
834
|
-
readonly readOnly?: boolean;
|
|
835
|
-
readonly get?: (val: any, item: any) => any | undefined | void;
|
|
836
|
-
readonly set?: (val?: any, item?: any) => any | undefined | void;
|
|
837
|
-
readonly default?: string | (() => string);
|
|
838
|
-
readonly validate?: ((val: any) => boolean) | ((val: any) => void) | ((val: any) => string | void);
|
|
839
|
-
readonly field?: string;
|
|
840
|
-
readonly label?: string;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
export interface EnumAttribute {
|
|
845
|
-
readonly type: ReadonlyArray<string>;
|
|
846
|
-
readonly required?: boolean;
|
|
847
|
-
readonly hidden?: boolean;
|
|
848
|
-
readonly readOnly?: boolean;
|
|
849
|
-
readonly get?: (val: any, item: any) => any | undefined | void;
|
|
850
|
-
readonly set?: (val?: any, item?: any) => any | undefined | void;
|
|
851
|
-
readonly default?: string | (() => string);
|
|
852
|
-
readonly validate?: ((val: any) => boolean) | ((val: any) => void) | ((val: any) => string | void);
|
|
853
|
-
readonly field?: string;
|
|
854
|
-
readonly label?: string;
|
|
855
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
export interface NestedAnyAttribute {
|
|
859
|
-
readonly type: "any";
|
|
860
|
-
readonly required?: boolean;
|
|
861
|
-
readonly hidden?: boolean;
|
|
862
|
-
readonly readOnly?: boolean;
|
|
863
|
-
readonly get?: (val: any, item: any) => any | undefined | void;
|
|
864
|
-
readonly set?: (val?: any, item?: any) => any | undefined | void;
|
|
865
|
-
readonly default?: any | (() => any);
|
|
866
|
-
readonly validate?: ((val: any) => boolean) | ((val: any) => void) | ((val: any) => string | void);
|
|
867
|
-
readonly field?: string;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
export interface AnyAttribute {
|
|
871
|
-
readonly type: "any";
|
|
872
|
-
readonly required?: boolean;
|
|
873
|
-
readonly hidden?: boolean;
|
|
874
|
-
readonly readOnly?: boolean;
|
|
875
|
-
readonly get?: (val: any, item: any) => any | undefined | void;
|
|
876
|
-
readonly set?: (val?: any, item?: any) => any | undefined | void;
|
|
877
|
-
readonly default?: any | (() => any);
|
|
878
|
-
readonly validate?: ((val: any) => boolean) | ((val: any) => void) | ((val: any) => string | void);
|
|
879
|
-
readonly field?: string;
|
|
880
|
-
readonly label?: string;
|
|
881
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
export interface NestedMapAttribute {
|
|
885
|
-
readonly type: "map";
|
|
886
|
-
readonly properties: {
|
|
887
|
-
readonly [name: string]: NestedAttributes;
|
|
888
|
-
};
|
|
889
|
-
readonly required?: boolean;
|
|
890
|
-
readonly hidden?: boolean;
|
|
891
|
-
readonly readOnly?: boolean;
|
|
892
|
-
readonly get?: (val: Record<string, any>, item: any) => Record<string, any> | undefined | void;
|
|
893
|
-
readonly set?: (val?: Record<string, any>, item?: any) => Record<string, any> | undefined | void;
|
|
894
|
-
readonly default?: Record<string, any> | (() => Record<string, any>);
|
|
895
|
-
readonly validate?: ((val: Record<string, any>) => boolean) | ((val: Record<string, any>) => void) | ((val: Record<string, any>) => string | void);
|
|
896
|
-
readonly field?: string;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
export interface MapAttribute {
|
|
900
|
-
readonly type: "map";
|
|
901
|
-
readonly properties: {
|
|
902
|
-
readonly [name: string]: NestedAttributes;
|
|
903
|
-
};
|
|
904
|
-
readonly required?: boolean;
|
|
905
|
-
readonly hidden?: boolean;
|
|
906
|
-
readonly readOnly?: boolean;
|
|
907
|
-
readonly get?: (val: Record<string, any>, item: any) => Record<string, any> | undefined | void;
|
|
908
|
-
readonly set?: (val?: Record<string, any>, item?: any) => Record<string, any> | undefined | void;
|
|
909
|
-
readonly default?: Record<string, any> | (() => Record<string, any>);
|
|
910
|
-
readonly validate?: ((val: Record<string, any>) => boolean) | ((val: Record<string, any>) => void) | ((val: Record<string, any>) => string | void);
|
|
911
|
-
readonly field?: string;
|
|
912
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
export interface NestedStringListAttribute {
|
|
916
|
-
readonly type: "list";
|
|
917
|
-
readonly items: {
|
|
918
|
-
readonly type: "string";
|
|
919
|
-
readonly required?: boolean;
|
|
920
|
-
readonly hidden?: boolean;
|
|
921
|
-
readonly readOnly?: boolean;
|
|
922
|
-
readonly get?: (val: string, item: any) => string | undefined | void;
|
|
923
|
-
readonly set?: (val?: string, item?: any) => string | undefined | void;
|
|
924
|
-
readonly default?: string | (() => string);
|
|
925
|
-
readonly validate?: ((val: string) => boolean) | ((val: string) => void) | ((val: string) => string | void) | RegExp;
|
|
926
|
-
readonly field?: string;
|
|
927
|
-
};
|
|
928
|
-
readonly required?: boolean;
|
|
929
|
-
readonly hidden?: boolean;
|
|
930
|
-
readonly readOnly?: boolean;
|
|
931
|
-
readonly get?: (val: Array<string>, item: any) => Array<string> | undefined | void;
|
|
932
|
-
readonly set?: (val?: Array<string>, item?: any) => Array<string> | undefined | void;
|
|
933
|
-
readonly default?: Array<string> | (() => Array<string>);
|
|
934
|
-
readonly validate?: ((val: Array<string>) => boolean) | ((val: Array<string>) => void) | ((val: Array<string>) => string | void);
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
export interface StringListAttribute {
|
|
938
|
-
readonly type: "list";
|
|
939
|
-
readonly items: {
|
|
940
|
-
readonly type: "string";
|
|
941
|
-
readonly required?: boolean;
|
|
942
|
-
readonly hidden?: boolean;
|
|
943
|
-
readonly readOnly?: boolean;
|
|
944
|
-
readonly get?: (val: string, item: any) => string | undefined | void;
|
|
945
|
-
readonly set?: (val?: string, item?: any) => string | undefined | void;
|
|
946
|
-
readonly default?: string | (() => string);
|
|
947
|
-
readonly validate?: ((val: string) => boolean) | ((val: string) => void) | ((val: string) => string | void) | RegExp;
|
|
948
|
-
readonly field?: string;
|
|
949
|
-
}
|
|
950
|
-
readonly required?: boolean;
|
|
951
|
-
readonly hidden?: boolean;
|
|
952
|
-
readonly readOnly?: boolean;
|
|
953
|
-
readonly get?: (val: Array<string>, item: any) => Array<string> | undefined | void;
|
|
954
|
-
readonly set?: (val?: Array<string>, item?: any) => Array<string> | undefined | void;
|
|
955
|
-
readonly default?: Array<string> | (() => Array<string>);
|
|
956
|
-
readonly validate?: ((val: Array<string>) => boolean) | ((val: Array<string>) => void) | ((val: Array<string>) => string | void);
|
|
957
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
export interface NestedNumberListAttribute {
|
|
961
|
-
readonly type: "list";
|
|
962
|
-
readonly items: NestedNumberAttribute;
|
|
963
|
-
readonly required?: boolean;
|
|
964
|
-
readonly hidden?: boolean;
|
|
965
|
-
readonly readOnly?: boolean;
|
|
966
|
-
readonly get?: (val: Array<number>, item: any) => Array<number> | undefined | void;
|
|
967
|
-
readonly set?: (val?: Array<number>, item?: any) => Array<number> | undefined | void;
|
|
968
|
-
readonly default?: Array<number> | (() => Array<number>);
|
|
969
|
-
readonly validate?: ((val: Array<number>) => boolean) | ((val: Array<number>) => void) | ((val: Array<number>) => string | void);
|
|
970
|
-
readonly field?: string;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
export interface NumberListAttribute {
|
|
974
|
-
readonly type: "list";
|
|
975
|
-
readonly items: NestedNumberAttribute;
|
|
976
|
-
readonly required?: boolean;
|
|
977
|
-
readonly hidden?: boolean;
|
|
978
|
-
readonly readOnly?: boolean;
|
|
979
|
-
readonly get?: (val: Array<number>, item: any) => Array<number> | undefined | void;
|
|
980
|
-
readonly set?: (val?: Array<number>, item?: any) => Array<number> | undefined | void;
|
|
981
|
-
readonly default?: Array<number> | (() => Array<number>);
|
|
982
|
-
readonly validate?: ((val: Array<number>) => boolean) | ((val: Array<number>) => void) | ((val: Array<number>) => string | void);
|
|
983
|
-
readonly field?: string;
|
|
984
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
export interface NestedMapListAttribute {
|
|
988
|
-
readonly type: "list";
|
|
989
|
-
readonly items: NestedMapAttribute;
|
|
990
|
-
readonly required?: boolean;
|
|
991
|
-
readonly hidden?: boolean;
|
|
992
|
-
readonly readOnly?: boolean;
|
|
993
|
-
readonly get?: (val: Record<string, any>[], item: any) => Record<string, any>[] | undefined | void;
|
|
994
|
-
readonly set?: (val?: Record<string, any>[], item?: any) => Record<string, any>[] | undefined | void;
|
|
995
|
-
readonly default?: Record<string, any>[] | (() => Record<string, any>[]);
|
|
996
|
-
readonly validate?: ((val: Record<string, any>[]) => boolean) | ((val: Record<string, any>[]) => void) | ((val: Record<string, any>[]) => string | void);
|
|
997
|
-
readonly field?: string;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
export interface MapListAttribute {
|
|
1001
|
-
readonly type: "list";
|
|
1002
|
-
readonly items: NestedMapAttribute;
|
|
1003
|
-
readonly required?: boolean;
|
|
1004
|
-
readonly hidden?: boolean;
|
|
1005
|
-
readonly readOnly?: boolean;
|
|
1006
|
-
readonly get?: (val: Record<string, any>[], item: any) => Record<string, any>[] | undefined | void;
|
|
1007
|
-
readonly set?: (val?: Record<string, any>[], item?: any) => Record<string, any>[] | undefined | void;
|
|
1008
|
-
readonly default?: Record<string, any>[] | (() => Record<string, any>[]);
|
|
1009
|
-
readonly validate?: ((val: Record<string, any>[]) => boolean) | ((val: Record<string, any>[]) => void) | ((val: Record<string, any>[]) => string | void);
|
|
1010
|
-
readonly field?: string;
|
|
1011
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
export interface NestedStringSetAttribute {
|
|
1015
|
-
readonly type: "set";
|
|
1016
|
-
readonly items: "string";
|
|
1017
|
-
readonly required?: boolean;
|
|
1018
|
-
readonly hidden?: boolean;
|
|
1019
|
-
readonly readOnly?: boolean;
|
|
1020
|
-
readonly get?: (val: Array<string>, item: any) => Array<string> | undefined | void;
|
|
1021
|
-
readonly set?: (val?: Array<string>, item?: any) => Array<string> | undefined | void;
|
|
1022
|
-
readonly default?: Array<string> | (() => Array<string>);
|
|
1023
|
-
readonly validate?: ((val: Array<string>) => boolean) | ((val: Array<string>) => void) | ((val: Array<string>) => string | void) | RegExp;
|
|
1024
|
-
readonly field?: string;
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
export interface StringSetAttribute {
|
|
1028
|
-
readonly type: "set";
|
|
1029
|
-
readonly items: "string";
|
|
1030
|
-
readonly required?: boolean;
|
|
1031
|
-
readonly hidden?: boolean;
|
|
1032
|
-
readonly readOnly?: boolean;
|
|
1033
|
-
readonly get?: (val: Array<string>, item: any) => Array<string> | undefined | void;
|
|
1034
|
-
readonly set?: (val?: Array<string>, item?: any) => Array<string> | undefined | void;
|
|
1035
|
-
readonly default?: Array<string> | (() => Array<string>);
|
|
1036
|
-
readonly validate?: ((val: Array<string>) => boolean) | ((val: Array<string>) => void) | ((val: Array<string>) => string | void) | RegExp;
|
|
1037
|
-
readonly field?: string;
|
|
1038
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
export interface NestedNumberSetAttribute {
|
|
1042
|
-
readonly type: "set";
|
|
1043
|
-
readonly items: "number";
|
|
1044
|
-
readonly required?: boolean;
|
|
1045
|
-
readonly hidden?: boolean;
|
|
1046
|
-
readonly readOnly?: boolean;
|
|
1047
|
-
readonly get?: (val: Array<number>, item: any) => Array<number> | undefined | void;
|
|
1048
|
-
readonly set?: (val?: Array<number>, item?: any) => Array<number> | undefined | void;
|
|
1049
|
-
readonly default?: Array<number> | (() => Array<number>);
|
|
1050
|
-
readonly validate?: ((val: Array<number>) => boolean) | ((val: Array<number>) => void) | ((val: Array<number>) => string | void);
|
|
1051
|
-
readonly field?: string;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
export interface NumberSetAttribute {
|
|
1055
|
-
readonly type: "set";
|
|
1056
|
-
readonly items: "number";
|
|
1057
|
-
readonly required?: boolean;
|
|
1058
|
-
readonly hidden?: boolean;
|
|
1059
|
-
readonly readOnly?: boolean;
|
|
1060
|
-
readonly get?: (val: Array<number>, item: any) => Array<number> | undefined | void;
|
|
1061
|
-
readonly set?: (val?: Array<number>, item?: any) => Array<number> | undefined | void;
|
|
1062
|
-
readonly default?: Array<number> | (() => Array<number>);
|
|
1063
|
-
readonly validate?: ((val: Array<number>) => boolean) | ((val: Array<number>) => void) | ((val: Array<number>) => string | void);
|
|
1064
|
-
readonly field?: string;
|
|
1065
|
-
readonly watch?: ReadonlyArray<string> | "*";
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
export type Attribute =
|
|
1069
|
-
BooleanAttribute
|
|
1070
|
-
| NumberAttribute
|
|
1071
|
-
| StringAttribute
|
|
1072
|
-
| EnumAttribute
|
|
1073
|
-
| AnyAttribute
|
|
1074
|
-
| MapAttribute
|
|
1075
|
-
| StringSetAttribute
|
|
1076
|
-
| NumberSetAttribute
|
|
1077
|
-
| StringListAttribute
|
|
1078
|
-
| NumberListAttribute
|
|
1079
|
-
| MapListAttribute;
|
|
1080
|
-
|
|
1081
|
-
export type NestedAttributes =
|
|
1082
|
-
NestedBooleanAttribute
|
|
1083
|
-
| NestedNumberAttribute
|
|
1084
|
-
| NestedStringAttribute
|
|
1085
|
-
| NestedAnyAttribute
|
|
1086
|
-
| NestedMapAttribute
|
|
1087
|
-
| NestedStringListAttribute
|
|
1088
|
-
| NestedNumberListAttribute
|
|
1089
|
-
| NestedMapListAttribute
|
|
1090
|
-
| NestedStringSetAttribute
|
|
1091
|
-
| NestedNumberSetAttribute
|
|
1092
|
-
| NestedEnumAttribute;
|
|
1093
|
-
|
|
1094
|
-
export interface IndexWithSortKey {
|
|
1095
|
-
readonly sk: {
|
|
1096
|
-
readonly field: string;
|
|
1097
|
-
readonly composite: ReadonlyArray<string>;
|
|
1098
|
-
readonly template?: string;
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
export type AccessPatternCollection<C extends string> = C | ReadonlyArray<C>;
|
|
1103
|
-
|
|
1104
|
-
export interface Schema<A extends string, F extends string, C extends string> {
|
|
1105
|
-
readonly model: {
|
|
1106
|
-
readonly entity: string;
|
|
1107
|
-
readonly service: string;
|
|
1108
|
-
readonly version: string;
|
|
1109
|
-
}
|
|
1110
|
-
readonly attributes: {
|
|
1111
|
-
readonly [a in A]: Attribute
|
|
1112
|
-
};
|
|
1113
|
-
readonly indexes: {
|
|
1114
|
-
[accessPattern: string]: {
|
|
1115
|
-
readonly index?: string;
|
|
1116
|
-
readonly collection?: AccessPatternCollection<C>;
|
|
1117
|
-
readonly pk: {
|
|
1118
|
-
readonly casing?: "upper" | "lower" | "none" | "default";
|
|
1119
|
-
readonly field: string;
|
|
1120
|
-
readonly composite: ReadonlyArray<F>;
|
|
1121
|
-
readonly template?: string;
|
|
1122
|
-
}
|
|
1123
|
-
readonly sk?: {
|
|
1124
|
-
readonly casing?: "upper" | "lower" | "none" | "default";
|
|
1125
|
-
readonly field: string;
|
|
1126
|
-
readonly composite: ReadonlyArray<F>;
|
|
1127
|
-
readonly template?: string;
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
export type Attributes<A extends string> = Record<A, Attribute>
|
|
1134
|
-
|
|
1135
|
-
export type IndexCollections<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
1136
|
-
[i in keyof S["indexes"]]: S["indexes"][i]["collection"] extends
|
|
1137
|
-
AccessPatternCollection<infer Name>
|
|
1138
|
-
? Name
|
|
1139
|
-
: never
|
|
1140
|
-
}[keyof S["indexes"]];
|
|
1141
|
-
|
|
1142
|
-
export type EntityCollections<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
1143
|
-
[N in IndexCollections<A,F,C,S>]: {
|
|
1144
|
-
[i in keyof S["indexes"]]: S["indexes"][i]["collection"] extends AccessPatternCollection<infer Name>
|
|
1145
|
-
? Name extends N
|
|
1146
|
-
? i
|
|
1147
|
-
: never
|
|
1148
|
-
: never
|
|
1149
|
-
}[keyof S["indexes"]];
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
declare const SkipSymbol: unique symbol;
|
|
1153
|
-
type SkipValue = typeof SkipSymbol;
|
|
1154
|
-
|
|
1155
|
-
type PartialDefinedKeys<T> = {
|
|
1156
|
-
[P in keyof T as
|
|
1157
|
-
[undefined] extends [T[P]]
|
|
1158
|
-
? never
|
|
1159
|
-
: SkipValue extends T[P]
|
|
1160
|
-
? never
|
|
1161
|
-
: P
|
|
1162
|
-
]?: T[P] | undefined;
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
export type ItemAttribute<A extends Attribute> =
|
|
1166
|
-
A["type"] extends infer R
|
|
1167
|
-
? R extends "string" ? string
|
|
1168
|
-
: R extends "number" ? number
|
|
1169
|
-
: R extends "boolean" ? boolean
|
|
1170
|
-
: R extends ReadonlyArray<infer E> ? E
|
|
1171
|
-
: R extends "map"
|
|
1172
|
-
? "properties" extends keyof A
|
|
1173
|
-
? {
|
|
1174
|
-
[P in keyof A["properties"]]:
|
|
1175
|
-
A["properties"][P] extends infer M
|
|
1176
|
-
? M extends Attribute
|
|
1177
|
-
? ItemAttribute<M>
|
|
1178
|
-
: never
|
|
1179
|
-
: never
|
|
1180
|
-
}
|
|
1181
|
-
: never
|
|
1182
|
-
: R extends "list"
|
|
1183
|
-
? "items" extends keyof A
|
|
1184
|
-
? A["items"] extends infer I
|
|
1185
|
-
? I extends Attribute
|
|
1186
|
-
? Array<ItemAttribute<I>>
|
|
1187
|
-
: never
|
|
1188
|
-
: never
|
|
1189
|
-
: never
|
|
1190
|
-
: R extends "set"
|
|
1191
|
-
? "items" extends keyof A
|
|
1192
|
-
? A["items"] extends infer I
|
|
1193
|
-
? I extends "string" ? string[]
|
|
1194
|
-
: I extends "number" ? number[]
|
|
1195
|
-
: never
|
|
1196
|
-
: never
|
|
1197
|
-
: never
|
|
1198
|
-
: R extends "any" ? any
|
|
1199
|
-
: never
|
|
1200
|
-
: never
|
|
1201
|
-
|
|
1202
|
-
export type ReturnedAttribute<A extends Attribute> =
|
|
1203
|
-
A["type"] extends infer R
|
|
1204
|
-
? R extends "string" ? string
|
|
1205
|
-
: R extends "number" ? number
|
|
1206
|
-
: R extends "boolean" ? boolean
|
|
1207
|
-
: R extends ReadonlyArray<infer E> ? E
|
|
1208
|
-
: R extends "map"
|
|
1209
|
-
? "properties" extends keyof A
|
|
1210
|
-
?
|
|
1211
|
-
{
|
|
1212
|
-
[
|
|
1213
|
-
P in keyof A["properties"] as A["properties"][P] extends RequiredAttribute
|
|
1214
|
-
? P
|
|
1215
|
-
: never
|
|
1216
|
-
]: A["properties"][P] extends infer M
|
|
1217
|
-
? M extends Attribute
|
|
1218
|
-
? ReturnedAttribute<M>
|
|
1219
|
-
: never
|
|
1220
|
-
: never
|
|
1221
|
-
} & {
|
|
1222
|
-
[
|
|
1223
|
-
P in keyof A["properties"] as A["properties"][P] extends HiddenAttribute | RequiredAttribute
|
|
1224
|
-
? never
|
|
1225
|
-
: P
|
|
1226
|
-
]?: A["properties"][P] extends infer M
|
|
1227
|
-
? M extends Attribute
|
|
1228
|
-
? ReturnedAttribute<M> | undefined
|
|
1229
|
-
: never
|
|
1230
|
-
: never
|
|
1231
|
-
}
|
|
1232
|
-
: never
|
|
1233
|
-
: R extends "list"
|
|
1234
|
-
? "items" extends keyof A
|
|
1235
|
-
? A["items"] extends infer I
|
|
1236
|
-
? I extends Attribute
|
|
1237
|
-
? ReturnedAttribute<I>[]
|
|
1238
|
-
: never
|
|
1239
|
-
: never
|
|
1240
|
-
: never
|
|
1241
|
-
: R extends "set"
|
|
1242
|
-
? "items" extends keyof A
|
|
1243
|
-
? A["items"] extends infer I
|
|
1244
|
-
? I extends "string" ? string[]
|
|
1245
|
-
: I extends "number" ? number[]
|
|
1246
|
-
: never
|
|
1247
|
-
: never
|
|
1248
|
-
: never
|
|
1249
|
-
: R extends "any" ? any
|
|
1250
|
-
: never
|
|
1251
|
-
: never
|
|
1252
|
-
|
|
1253
|
-
export type CreatedAttribute<A extends Attribute> =
|
|
1254
|
-
A["type"] extends infer R
|
|
1255
|
-
? R extends "string" ? string
|
|
1256
|
-
: R extends "number" ? number
|
|
1257
|
-
: R extends "boolean" ? boolean
|
|
1258
|
-
: R extends ReadonlyArray<infer E> ? E
|
|
1259
|
-
: R extends "map"
|
|
1260
|
-
? "properties" extends keyof A
|
|
1261
|
-
? {
|
|
1262
|
-
[
|
|
1263
|
-
P in keyof A["properties"] as A["properties"][P] extends RequiredAttribute
|
|
1264
|
-
? A["properties"][P] extends DefaultedAttribute
|
|
1265
|
-
? never
|
|
1266
|
-
: P
|
|
1267
|
-
: never
|
|
1268
|
-
]: A["properties"][P] extends infer M
|
|
1269
|
-
? M extends Attribute
|
|
1270
|
-
? CreatedAttribute<M>
|
|
1271
|
-
: never
|
|
1272
|
-
: never
|
|
1273
|
-
} & {
|
|
1274
|
-
[P in keyof A["properties"] as A["properties"][P] extends HiddenAttribute
|
|
1275
|
-
? never
|
|
1276
|
-
: P
|
|
1277
|
-
]?: A["properties"][P] extends infer M
|
|
1278
|
-
? M extends Attribute
|
|
1279
|
-
? CreatedAttribute<M> | undefined
|
|
1280
|
-
: never
|
|
1281
|
-
: never
|
|
1282
|
-
}
|
|
1283
|
-
: never
|
|
1284
|
-
: R extends "list"
|
|
1285
|
-
? "items" extends keyof A
|
|
1286
|
-
? A["items"] extends infer I
|
|
1287
|
-
? I extends Attribute
|
|
1288
|
-
? CreatedAttribute<I>[]
|
|
1289
|
-
: never
|
|
1290
|
-
: never
|
|
1291
|
-
: never
|
|
1292
|
-
: R extends "set"
|
|
1293
|
-
? "items" extends keyof A
|
|
1294
|
-
? A["items"] extends infer I
|
|
1295
|
-
? I extends "string" ? string[]
|
|
1296
|
-
: I extends "number" ? number[]
|
|
1297
|
-
: never
|
|
1298
|
-
: never
|
|
1299
|
-
: never
|
|
1300
|
-
: R extends "any" ? any
|
|
1301
|
-
: never
|
|
1302
|
-
: never
|
|
1303
|
-
|
|
1304
|
-
export type ReturnedItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>,Attr extends S["attributes"]> = {
|
|
1305
|
-
[a in keyof Attr]: ReturnedAttribute<Attr[a]>
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
export type CreatedItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>,Attr extends S["attributes"]> = {
|
|
1309
|
-
[a in keyof Attr]: CreatedAttribute<Attr[a]>
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
export type EditableItemAttribute<A extends Attribute> =
|
|
1313
|
-
A extends ReadOnlyAttribute
|
|
1314
|
-
? never
|
|
1315
|
-
: A["type"] extends infer R
|
|
1316
|
-
? R extends "string" ? string
|
|
1317
|
-
: R extends "number" ? number
|
|
1318
|
-
: R extends "boolean" ? boolean
|
|
1319
|
-
: R extends ReadonlyArray<infer E> ? E
|
|
1320
|
-
: R extends "map"
|
|
1321
|
-
? "properties" extends keyof A
|
|
1322
|
-
? {
|
|
1323
|
-
[
|
|
1324
|
-
P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute
|
|
1325
|
-
? never
|
|
1326
|
-
: P
|
|
1327
|
-
]:
|
|
1328
|
-
A["properties"][P] extends infer M
|
|
1329
|
-
? M extends Attribute
|
|
1330
|
-
? EditableItemAttribute<M>
|
|
1331
|
-
: never
|
|
1332
|
-
: never
|
|
1333
|
-
}
|
|
1334
|
-
: never
|
|
1335
|
-
: R extends "list"
|
|
1336
|
-
? "items" extends keyof A
|
|
1337
|
-
? A["items"] extends infer I
|
|
1338
|
-
? I extends Attribute
|
|
1339
|
-
? Array<EditableItemAttribute<I>>
|
|
1340
|
-
: never
|
|
1341
|
-
: never
|
|
1342
|
-
: never
|
|
1343
|
-
: R extends "set"
|
|
1344
|
-
? "items" extends keyof A
|
|
1345
|
-
? A["items"] extends infer I
|
|
1346
|
-
? I extends "string" ? string[]
|
|
1347
|
-
: I extends "number" ? number[]
|
|
1348
|
-
: never
|
|
1349
|
-
: never
|
|
1350
|
-
: never
|
|
1351
|
-
: R extends "any" ? any
|
|
1352
|
-
: never
|
|
1353
|
-
: never
|
|
1354
|
-
|
|
1355
|
-
export type UpdatableItemAttribute<A extends Attribute> =
|
|
1356
|
-
A extends ReadOnlyAttribute
|
|
1357
|
-
? never
|
|
1358
|
-
: A["type"] extends infer R
|
|
1359
|
-
? R extends "string" ? string
|
|
1360
|
-
: R extends "number" ? number
|
|
1361
|
-
: R extends "boolean" ? boolean
|
|
1362
|
-
: R extends ReadonlyArray<infer E> ? E
|
|
1363
|
-
: R extends "map"
|
|
1364
|
-
? "properties" extends keyof A
|
|
1365
|
-
? {
|
|
1366
|
-
[
|
|
1367
|
-
P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute
|
|
1368
|
-
? never
|
|
1369
|
-
: A["properties"][P] extends RequiredAttribute
|
|
1370
|
-
? P
|
|
1371
|
-
: never
|
|
1372
|
-
]:
|
|
1373
|
-
A["properties"][P] extends infer M
|
|
1374
|
-
? M extends Attribute
|
|
1375
|
-
? UpdatableItemAttribute<M>
|
|
1376
|
-
: never
|
|
1377
|
-
: never
|
|
1378
|
-
} & {
|
|
1379
|
-
[
|
|
1380
|
-
P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute
|
|
1381
|
-
? never
|
|
1382
|
-
: A["properties"][P] extends RequiredAttribute
|
|
1383
|
-
? never
|
|
1384
|
-
: P
|
|
1385
|
-
]?:
|
|
1386
|
-
A["properties"][P] extends infer M
|
|
1387
|
-
? M extends Attribute
|
|
1388
|
-
? UpdatableItemAttribute<M>
|
|
1389
|
-
: never
|
|
1390
|
-
: never
|
|
1391
|
-
}
|
|
1392
|
-
: never
|
|
1393
|
-
: R extends "list"
|
|
1394
|
-
? "items" extends keyof A
|
|
1395
|
-
? A["items"] extends infer I
|
|
1396
|
-
? I extends Attribute
|
|
1397
|
-
? Array<UpdatableItemAttribute<I>>
|
|
1398
|
-
: never
|
|
1399
|
-
: never
|
|
1400
|
-
: never
|
|
1401
|
-
: R extends "set"
|
|
1402
|
-
? "items" extends keyof A
|
|
1403
|
-
? A["items"] extends infer I
|
|
1404
|
-
? I extends "string" ? string[]
|
|
1405
|
-
: I extends "number" ? number[]
|
|
1406
|
-
: never
|
|
1407
|
-
: never
|
|
1408
|
-
: never
|
|
1409
|
-
: R extends "any" ? any
|
|
1410
|
-
: never
|
|
1411
|
-
: never
|
|
1412
|
-
|
|
1413
|
-
export type RemovableItemAttribute<A extends Attribute> =
|
|
1414
|
-
A extends ReadOnlyAttribute | RequiredAttribute
|
|
1415
|
-
? never
|
|
1416
|
-
: A["type"] extends infer R
|
|
1417
|
-
? R extends "string" ? string
|
|
1418
|
-
: R extends "number" ? number
|
|
1419
|
-
: R extends "boolean" ? boolean
|
|
1420
|
-
: R extends ReadonlyArray<infer E> ? E
|
|
1421
|
-
: R extends "map"
|
|
1422
|
-
? "properties" extends keyof A
|
|
1423
|
-
? {
|
|
1424
|
-
[
|
|
1425
|
-
P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute | RequiredAttribute
|
|
1426
|
-
? never
|
|
1427
|
-
: P
|
|
1428
|
-
]?:
|
|
1429
|
-
A["properties"][P] extends infer M
|
|
1430
|
-
? M extends Attribute
|
|
1431
|
-
? UpdatableItemAttribute<M>
|
|
1432
|
-
: never
|
|
1433
|
-
: never
|
|
1434
|
-
}
|
|
1435
|
-
: never
|
|
1436
|
-
: R extends "list"
|
|
1437
|
-
? "items" extends keyof A
|
|
1438
|
-
? A["items"] extends infer I
|
|
1439
|
-
? I extends Attribute
|
|
1440
|
-
? Array<UpdatableItemAttribute<I>>
|
|
1441
|
-
: never
|
|
1442
|
-
: never
|
|
1443
|
-
: never
|
|
1444
|
-
: R extends "set"
|
|
1445
|
-
? "items" extends keyof A
|
|
1446
|
-
? A["items"] extends infer I
|
|
1447
|
-
? I extends "string" ? string[]
|
|
1448
|
-
: I extends "number" ? number[]
|
|
1449
|
-
: never
|
|
1450
|
-
: never
|
|
1451
|
-
: never
|
|
1452
|
-
: R extends "any" ? any
|
|
1453
|
-
: never
|
|
1454
|
-
: never
|
|
1455
|
-
|
|
1456
|
-
export type Item<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, Attr extends Attributes<A>> = {
|
|
1457
|
-
[a in keyof Attr]: ItemAttribute<Attr[a]>
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
export type ItemTypeDescription<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
1461
|
-
[a in keyof S["attributes"]]: S["attributes"][a]["type"] extends infer R
|
|
1462
|
-
? R
|
|
1463
|
-
: never
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
export type RequiredAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = ExtractKeysOfValueType<{
|
|
1467
|
-
[a in keyof S["attributes"]]: S["attributes"][a] extends RequiredAttribute
|
|
1468
|
-
? true
|
|
1469
|
-
: false
|
|
1470
|
-
}, true>
|
|
1471
|
-
|
|
1472
|
-
export type HiddenAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = ExtractKeysOfValueType<{
|
|
1473
|
-
[a in keyof S["attributes"]]: S["attributes"][a] extends HiddenAttribute
|
|
1474
|
-
? true
|
|
1475
|
-
: false
|
|
1476
|
-
}, true>
|
|
1477
|
-
|
|
1478
|
-
export type ReadOnlyAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = ExtractKeysOfValueType<{
|
|
1479
|
-
[a in keyof S["attributes"]]: S["attributes"][a] extends ReadOnlyAttribute
|
|
1480
|
-
? true
|
|
1481
|
-
: false
|
|
1482
|
-
}, true>
|
|
1483
|
-
|
|
1484
|
-
type ExtractKeysOfValueType<T, K> = {
|
|
1485
|
-
[I in keyof T]: T[I] extends K ? I : never
|
|
1486
|
-
}[keyof T];
|
|
1487
|
-
|
|
1488
|
-
export type TableIndexes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
1489
|
-
[i in keyof S["indexes"]]: S["indexes"][i] extends SecondaryIndex
|
|
1490
|
-
? "secondary"
|
|
1491
|
-
: "table"
|
|
1492
|
-
};
|
|
1493
|
-
|
|
1494
|
-
export type TableIndexName<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = ExtractKeysOfValueType<TableIndexes<A,F,C,S>, "table">;
|
|
1495
|
-
|
|
1496
|
-
export type PKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
1497
|
-
[i in keyof S["indexes"]]: S["indexes"][i]["pk"]["composite"] extends ReadonlyArray<infer Composite>
|
|
1498
|
-
? Composite
|
|
1499
|
-
: never
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
export type SKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
1503
|
-
[i in keyof S["indexes"]]: S["indexes"][i] extends IndexWithSortKey
|
|
1504
|
-
? S["indexes"][i]["sk"]["composite"] extends ReadonlyArray<infer Composite>
|
|
1505
|
-
? Composite
|
|
1506
|
-
: never
|
|
1507
|
-
: never;
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
export type TableIndexPKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = Pick<PKCompositeAttributes<A,F,C,S>, TableIndexName<A,F,C,S>>;
|
|
1511
|
-
|
|
1512
|
-
export type TableIndexSKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = Pick<SKCompositeAttributes<A,F,C,S>, TableIndexName<A,F,C,S>>;
|
|
1513
|
-
|
|
1514
|
-
export type IndexPKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> = Pick<PKCompositeAttributes<A,F,C,S>,I>;
|
|
1515
|
-
|
|
1516
|
-
export type IndexSKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> = Pick<SKCompositeAttributes<A,F,C,S>,I>;
|
|
1517
|
-
|
|
1518
|
-
export type TableIndexPKAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1519
|
-
TableIndexName<A,F,C,S> extends keyof TableIndexPKCompositeAttributes<A,F,C,S>
|
|
1520
|
-
? TableIndexPKCompositeAttributes<A,F,C,S>[TableIndexName<A,F,C,S>] extends keyof Item<A,F,C,S,S["attributes"]>
|
|
1521
|
-
? Pick<Item<A,F,C,S,S["attributes"]>, TableIndexPKCompositeAttributes<A,F,C,S>[TableIndexName<A,F,C,S>]>
|
|
1522
|
-
: never
|
|
1523
|
-
: never
|
|
1524
|
-
|
|
1525
|
-
export type TableIndexSKAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = TableIndexSKCompositeAttributes<A,F,C,S>[TableIndexName<A,F,C,S>] extends keyof S["attributes"]
|
|
1526
|
-
? Pick<Item<A,F,C,S,S["attributes"]>, TableIndexSKCompositeAttributes<A,F,C,S>[TableIndexName<A,F,C,S>]>
|
|
1527
|
-
: Item<A,F,C,S,S["attributes"]>;
|
|
1528
|
-
|
|
1529
|
-
export type IndexPKAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> =
|
|
1530
|
-
I extends keyof IndexPKCompositeAttributes<A,F,C,S,I>
|
|
1531
|
-
? IndexPKCompositeAttributes<A,F,C,S,I>[I] extends keyof Item<A,F,C,S,S["attributes"]>
|
|
1532
|
-
? Pick<Item<A,F,C,S,S["attributes"]>, IndexPKCompositeAttributes<A,F,C,S,I>[I]>
|
|
1533
|
-
: never
|
|
1534
|
-
: never;
|
|
1535
|
-
|
|
1536
|
-
export type IndexSKAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> = IndexSKCompositeAttributes<A,F,C,S,I>[I] extends keyof S["attributes"]
|
|
1537
|
-
? Pick<Item<A,F,C,S,S["attributes"]>, IndexSKCompositeAttributes<A,F,C,S,I>[I]>
|
|
1538
|
-
: Item<A,F,C,S,S["attributes"]>;
|
|
1539
|
-
|
|
1540
|
-
export type TableIndexCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = TableIndexPKAttributes<A,F,C,S> & Partial<TableIndexSKAttributes<A,F,C,S>>;
|
|
1541
|
-
|
|
1542
|
-
export type AllTableIndexCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = TableIndexPKAttributes<A,F,C,S> & TableIndexSKAttributes<A,F,C,S>;
|
|
1543
|
-
|
|
1544
|
-
export type IndexCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> = IndexPKAttributes<A,F,C,S,I> & Partial<IndexSKAttributes<A,F,C,S,I>>;
|
|
1545
|
-
|
|
1546
|
-
export type TableItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1547
|
-
AllTableIndexCompositeAttributes<A,F,C,S> &
|
|
1548
|
-
Pick<ReturnedItem<A,F,C,S,S["attributes"]>, RequiredAttributes<A,F,C,S>> &
|
|
1549
|
-
Partial<Omit<ReturnedItem<A,F,C,S,S["attributes"]>, RequiredAttributes<A,F,C,S>>>
|
|
1550
|
-
|
|
1551
|
-
export type ResponseItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1552
|
-
Omit<TableItem<A,F,C,S>, HiddenAttributes<A,F,C,S>>
|
|
1553
|
-
|
|
1554
|
-
export type RequiredPutItems<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
1555
|
-
[Attribute in keyof S["attributes"]]:
|
|
1556
|
-
"default" extends keyof S["attributes"][Attribute]
|
|
1557
|
-
? false
|
|
1558
|
-
: "required" extends keyof S["attributes"][Attribute]
|
|
1559
|
-
? true extends S["attributes"][Attribute]["required"]
|
|
1560
|
-
? true
|
|
1561
|
-
: Attribute extends keyof TableIndexCompositeAttributes<A,F,C,S>
|
|
1562
|
-
? true
|
|
1563
|
-
: false
|
|
1564
|
-
: Attribute extends keyof TableIndexCompositeAttributes<A,F,C,S>
|
|
1565
|
-
? true
|
|
1566
|
-
: false
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
export type PutItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1570
|
-
Pick<CreatedItem<A,F,C,S,S["attributes"]>, ExtractKeysOfValueType<RequiredPutItems<A,F,C,S>,true>>
|
|
1571
|
-
& Partial<CreatedItem<A,F,C,S,S["attributes"]>>
|
|
1572
|
-
|
|
1573
|
-
export type UpdateData<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1574
|
-
Omit<{
|
|
1575
|
-
[Attr in keyof S["attributes"]]: EditableItemAttribute<S["attributes"][Attr]>
|
|
1576
|
-
}, keyof AllTableIndexCompositeAttributes<A,F,C,S> | ReadOnlyAttributes<A,F,C,S>>
|
|
1577
|
-
|
|
1578
|
-
export type SetItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1579
|
-
// UpdatableItemAttribute
|
|
1580
|
-
Omit<{
|
|
1581
|
-
[Attr in keyof S["attributes"]]?: UpdatableItemAttribute<S["attributes"][Attr]>
|
|
1582
|
-
}, keyof AllTableIndexCompositeAttributes<A,F,C,S> | ReadOnlyAttributes<A,F,C,S>>
|
|
1583
|
-
|
|
1584
|
-
// type RemoveItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1585
|
-
// Array<keyof SetItem<A,F,C,S>>
|
|
1586
|
-
export type RemoveItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1587
|
-
Array< keyof Omit<{
|
|
1588
|
-
[Attr in keyof S["attributes"]]?: RemovableItemAttribute<S["attributes"][Attr]>
|
|
1589
|
-
}, keyof AllTableIndexCompositeAttributes<A,F,C,S> | ReadOnlyAttributes<A,F,C,S> | RequiredAttributes<A,F,C,S>>>
|
|
1590
|
-
|
|
1591
|
-
export type AppendItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1592
|
-
{
|
|
1593
|
-
[
|
|
1594
|
-
P in keyof ItemTypeDescription<A,F,C,S> as ItemTypeDescription<A,F,C,S>[P] extends 'list' | 'any'
|
|
1595
|
-
? P
|
|
1596
|
-
: never
|
|
1597
|
-
]?: P extends keyof SetItem<A,F,C,S>
|
|
1598
|
-
? SetItem<A,F,C,S>[P] | undefined
|
|
1599
|
-
: never
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
export type AddItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1603
|
-
{
|
|
1604
|
-
[
|
|
1605
|
-
P in keyof ItemTypeDescription<A,F,C,S> as ItemTypeDescription<A,F,C,S>[P] extends "number" | "any" | "set"
|
|
1606
|
-
? P
|
|
1607
|
-
: never
|
|
1608
|
-
]?: P extends keyof SetItem<A,F,C,S>
|
|
1609
|
-
? SetItem<A,F,C,S>[P] | undefined
|
|
1610
|
-
: never
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
export type SubtractItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1614
|
-
{
|
|
1615
|
-
[
|
|
1616
|
-
P in keyof ItemTypeDescription<A,F,C,S> as ItemTypeDescription<A,F,C,S>[P] extends "number" | "any"
|
|
1617
|
-
? P
|
|
1618
|
-
: never
|
|
1619
|
-
]?: P extends keyof SetItem<A,F,C,S>
|
|
1620
|
-
? SetItem<A,F,C,S>[P] | undefined
|
|
1621
|
-
: never
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
export type DeleteItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1625
|
-
{
|
|
1626
|
-
[
|
|
1627
|
-
P in keyof ItemTypeDescription<A,F,C,S> as ItemTypeDescription<A,F,C,S>[P] extends "any" | "set"
|
|
1628
|
-
? P
|
|
1629
|
-
: never
|
|
1630
|
-
]?: P extends keyof SetItem<A,F,C,S>
|
|
1631
|
-
? SetItem<A,F,C,S>[P] | undefined
|
|
1632
|
-
: never
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
export declare const WhereSymbol: unique symbol;
|
|
1636
|
-
export declare const UpdateDataSymbol: unique symbol;
|
|
1637
|
-
|
|
1638
|
-
export type WhereAttributeSymbol<T extends any> =
|
|
1639
|
-
{ [WhereSymbol]: void }
|
|
1640
|
-
& T extends string ? T
|
|
1641
|
-
: T extends number ? T
|
|
1642
|
-
: T extends boolean ? T
|
|
1643
|
-
: T extends {[key: string]: any}
|
|
1644
|
-
? {[key in keyof T]: WhereAttributeSymbol<T[key]>}
|
|
1645
|
-
: T extends ReadonlyArray<infer A>
|
|
1646
|
-
? ReadonlyArray<WhereAttributeSymbol<A>>
|
|
1647
|
-
: T extends Array<infer I>
|
|
1648
|
-
? Array<WhereAttributeSymbol<I>>
|
|
1649
|
-
: T
|
|
1650
|
-
|
|
1651
|
-
export type WhereAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Item<A,F,C,S,S["attributes"]>> = {
|
|
1652
|
-
[Attr in keyof I]: WhereAttributeSymbol<I[Attr]>
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
export type DataUpdateAttributeSymbol<T extends any> =
|
|
1656
|
-
{ [UpdateDataSymbol]: void }
|
|
1657
|
-
& T extends string ? T
|
|
1658
|
-
: T extends number ? T
|
|
1659
|
-
: T extends boolean ? T
|
|
1660
|
-
: T extends {[key: string]: any}
|
|
1661
|
-
? {[key in keyof T]: DataUpdateAttributeSymbol<T[key]>}
|
|
1662
|
-
: T extends ReadonlyArray<infer A>
|
|
1663
|
-
? ReadonlyArray<DataUpdateAttributeSymbol<A>>
|
|
1664
|
-
: T extends Array<infer I>
|
|
1665
|
-
? Array<DataUpdateAttributeSymbol<I>>
|
|
1666
|
-
: [T] extends [never]
|
|
1667
|
-
? never
|
|
1668
|
-
: T
|
|
1669
|
-
|
|
1670
|
-
export type DataUpdateAttributeValues<A extends DataUpdateAttributeSymbol<any>> =
|
|
1671
|
-
A extends DataUpdateAttributeSymbol<infer T>
|
|
1672
|
-
? T extends string ? T
|
|
1673
|
-
: T extends number ? T
|
|
1674
|
-
: T extends boolean ? T
|
|
1675
|
-
: T extends {[key: string]: any}
|
|
1676
|
-
? {[key in keyof T]?: DataUpdateAttributeValues<T[key]>}
|
|
1677
|
-
: T extends ReadonlyArray<infer A> ? ReadonlyArray<DataUpdateAttributeValues<A>>
|
|
1678
|
-
: T extends Array<infer I> ? Array<DataUpdateAttributeValues<I>>
|
|
1679
|
-
: [T] extends [never]
|
|
1680
|
-
? never
|
|
1681
|
-
: T
|
|
1682
|
-
: never
|
|
1683
|
-
|
|
1684
|
-
export type DataUpdateAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends UpdateData<A,F,C,S>> = {
|
|
1685
|
-
[Attr in keyof I]: DataUpdateAttributeSymbol<I[Attr]>
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
export interface WhereOperations<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Item<A,F,C,S,S["attributes"]>> {
|
|
1689
|
-
eq: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
1690
|
-
ne: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
1691
|
-
gt: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
1692
|
-
lt: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
1693
|
-
gte: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
1694
|
-
lte: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
1695
|
-
between: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T, value2: T) => string;
|
|
1696
|
-
begins: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
1697
|
-
exists: <A extends WhereAttributeSymbol<any>>(attr: A) => string;
|
|
1698
|
-
notExists: <A extends WhereAttributeSymbol<any>>(attr: A) => string;
|
|
1699
|
-
contains: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
1700
|
-
notContains: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
|
|
1701
|
-
value: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: A extends WhereAttributeSymbol<infer V> ? V : never) => A extends WhereAttributeSymbol<infer V> ? V : never;
|
|
1702
|
-
name: <A extends WhereAttributeSymbol<any>>(attr: A) => string;
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
export interface DataUpdateOperations<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends UpdateData<A,F,C,S>> {
|
|
1706
|
-
set: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: DataUpdateAttributeValues<A>) => any;
|
|
1707
|
-
remove: <T, A extends DataUpdateAttributeSymbol<T>>(attr: [T] extends [never] ? never : A) => any;
|
|
1708
|
-
append: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: DataUpdateAttributeValues<A> extends Array<any> ? DataUpdateAttributeValues<A> : never) => any;
|
|
1709
|
-
add: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: A extends DataUpdateAttributeSymbol<infer V> ? V extends number | Array<any> ? V : [V] extends [any] ? V : never : never ) => any;
|
|
1710
|
-
subtract: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: A extends DataUpdateAttributeSymbol<infer V> ? V extends number ? V : [V] extends [any] ? V : never : never ) => any;
|
|
1711
|
-
delete: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: A extends DataUpdateAttributeSymbol<infer V> ? V extends Array<any> ? V : [V] extends [any] ? V : never : never ) => any;
|
|
1712
|
-
del: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: A extends DataUpdateAttributeSymbol<infer V> ? V extends Array<any> ? V : never : never ) => any;
|
|
1713
|
-
value: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: DataUpdateAttributeValues<A>) => Required<DataUpdateAttributeValues<A>>;
|
|
1714
|
-
name: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A) => any;
|
|
1715
|
-
ifNotExists: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: DataUpdateAttributeValues<A>) => any;
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
export type WhereCallback<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Item<A,F,C,S,S["attributes"]>> =
|
|
1719
|
-
<W extends WhereAttributes<A,F,C,S,I>>(attributes: W, operations: WhereOperations<A,F,C,S,I>) => string;
|
|
1720
|
-
|
|
1721
|
-
export type DataUpdateCallback<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends UpdateData<A,F,C,S>> =
|
|
1722
|
-
<W extends DataUpdateAttributes<A,F,C,S,I>>(attributes: W, operations: DataUpdateOperations<A,F,C,S,I>) => any;
|
|
1723
|
-
|
|
1724
|
-
export type WhereClause<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Item<A,F,C,S,S["attributes"]>, T> = (where: WhereCallback<A,F,C,S,I>) => T;
|
|
1725
|
-
|
|
1726
|
-
export type DataUpdateMethod<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends UpdateData<A,F,C,S>, T> = (update: DataUpdateCallback<A,F,C,S,I>) => T;
|
|
1727
|
-
|
|
1728
|
-
type Resolve<T> = T extends Function | string | number | boolean
|
|
1729
|
-
? T : {[Key in keyof T]: Resolve<T[Key]>}
|
|
1730
|
-
|
|
1731
|
-
export type EntityConfiguration = {
|
|
1732
|
-
table?: string;
|
|
1733
|
-
client?: DocumentClient;
|
|
1734
|
-
listeners?: Array<ElectroEventListener>;
|
|
1735
|
-
logger?: ElectroEventListener;
|
|
1736
|
-
};
|