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