electrodb 1.8.3 → 1.10.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/README.md +23 -19
- package/index.d.ts +3 -1551
- package/package.json +7 -7
- package/src/entity.d.ts +94 -0
- package/src/entity.js +91 -34
- package/src/entity.test-d.ts +110 -0
- package/src/errors.js +6 -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 +67 -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 +36 -3
- package/CHANGELOG.md +0 -181
|
@@ -0,0 +1,1016 @@
|
|
|
1
|
+
export interface ElectroError extends Error {
|
|
2
|
+
readonly name: 'ElectroError';
|
|
3
|
+
readonly code: number;
|
|
4
|
+
readonly date: number;
|
|
5
|
+
readonly isElectroError: boolean;
|
|
6
|
+
ref: {
|
|
7
|
+
readonly code: number;
|
|
8
|
+
readonly section: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly sym: unique symbol;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ElectroValidationErrorFieldReference<T extends Error = Error> {
|
|
15
|
+
/**
|
|
16
|
+
* The json path to the attribute that had a validation error
|
|
17
|
+
*/
|
|
18
|
+
readonly field: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A description of the validation error for that attribute
|
|
22
|
+
*/
|
|
23
|
+
readonly reason: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Index of the value passed (present only in List attribute validation errors)
|
|
27
|
+
*/
|
|
28
|
+
readonly index: number | undefined;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The error thrown from the attribute's validate callback (if applicable)
|
|
32
|
+
*/
|
|
33
|
+
readonly cause: T | undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ElectroValidationError<T extends Error = Error> extends ElectroError {
|
|
37
|
+
readonly fields: ReadonlyArray<ElectroValidationErrorFieldReference<T>>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ReadOnlyAttribute {
|
|
41
|
+
readonly readOnly: true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface RequiredAttribute {
|
|
45
|
+
required: true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface HiddenAttribute {
|
|
49
|
+
readonly hidden: true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface DefaultedAttribute {
|
|
53
|
+
readonly default: any;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface SecondaryIndex {
|
|
57
|
+
readonly index: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface NestedBooleanAttribute {
|
|
61
|
+
readonly type: "boolean";
|
|
62
|
+
readonly required?: boolean;
|
|
63
|
+
readonly hidden?: boolean;
|
|
64
|
+
readonly readOnly?: boolean;
|
|
65
|
+
readonly get?: (val: boolean, item: any) => boolean | undefined | void;
|
|
66
|
+
readonly set?: (val?: boolean, item?: any) => boolean | undefined | void;
|
|
67
|
+
readonly default?: boolean | (() => boolean);
|
|
68
|
+
readonly validate?: ((val: boolean) => boolean) | ((val: boolean) => void) | ((val: boolean) => string | void);
|
|
69
|
+
readonly field?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface BooleanAttribute {
|
|
73
|
+
readonly type: "boolean";
|
|
74
|
+
readonly required?: boolean;
|
|
75
|
+
readonly hidden?: boolean;
|
|
76
|
+
readonly readOnly?: boolean;
|
|
77
|
+
readonly get?: (val: boolean, item: any) => boolean | undefined | void;
|
|
78
|
+
readonly set?: (val?: boolean, item?: any) => boolean | undefined | void;
|
|
79
|
+
readonly default?: boolean | (() => boolean);
|
|
80
|
+
readonly validate?: ((val: boolean) => boolean) | ((val: boolean) => void) | ((val: boolean) => string | void);
|
|
81
|
+
readonly field?: string;
|
|
82
|
+
readonly label?: string;
|
|
83
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface NestedNumberAttribute {
|
|
87
|
+
readonly type: "number";
|
|
88
|
+
readonly required?: boolean;
|
|
89
|
+
readonly hidden?: boolean;
|
|
90
|
+
readonly readOnly?: boolean;
|
|
91
|
+
readonly get?: (val: number, item: any) => number | undefined | void;
|
|
92
|
+
readonly set?: (val?: number, item?: any) => number | undefined | void;
|
|
93
|
+
readonly default?: number | (() => number);
|
|
94
|
+
readonly validate?: ((val: number) => boolean) | ((val: number) => void) | ((val: number) => string | void);
|
|
95
|
+
readonly field?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface NumberAttribute {
|
|
99
|
+
readonly type: "number";
|
|
100
|
+
readonly required?: boolean;
|
|
101
|
+
readonly hidden?: boolean;
|
|
102
|
+
readonly readOnly?: boolean;
|
|
103
|
+
readonly get?: (val: number, item: any) => number | undefined | void;
|
|
104
|
+
readonly set?: (val?: number, item?: any) => number | undefined | void;
|
|
105
|
+
readonly default?: number | (() => number);
|
|
106
|
+
readonly validate?: ((val: number) => boolean) | ((val: number) => void) | ((val: number) => string | void);
|
|
107
|
+
readonly field?: string;
|
|
108
|
+
readonly label?: string;
|
|
109
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface NestedStringAttribute {
|
|
113
|
+
readonly type: "string";
|
|
114
|
+
readonly required?: boolean;
|
|
115
|
+
readonly hidden?: boolean;
|
|
116
|
+
readonly readOnly?: boolean;
|
|
117
|
+
readonly get?: (val: string, item: any) => string | undefined | void;
|
|
118
|
+
readonly set?: (val?: string, item?: any) => string | undefined | void;
|
|
119
|
+
readonly default?: string | (() => string);
|
|
120
|
+
readonly validate?: ((val: string) => boolean) | ((val: string) => void) | ((val: string) => string | void) | RegExp;
|
|
121
|
+
readonly field?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface StringAttribute {
|
|
125
|
+
readonly type: "string";
|
|
126
|
+
readonly required?: boolean;
|
|
127
|
+
readonly hidden?: boolean;
|
|
128
|
+
readonly readOnly?: boolean;
|
|
129
|
+
readonly get?: (val: string, item: any) => string | undefined | void;
|
|
130
|
+
readonly set?: (val?: string, item?: any) => string | undefined | void;
|
|
131
|
+
readonly default?: string | (() => string);
|
|
132
|
+
readonly validate?: ((val: string) => boolean) | ((val: string) => void) | ((val: string) => string | void) | RegExp;
|
|
133
|
+
readonly field?: string;
|
|
134
|
+
readonly label?: string;
|
|
135
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface NestedEnumAttribute {
|
|
139
|
+
readonly type: ReadonlyArray<string>;
|
|
140
|
+
readonly required?: boolean;
|
|
141
|
+
readonly hidden?: boolean;
|
|
142
|
+
readonly readOnly?: boolean;
|
|
143
|
+
readonly get?: (val: any, item: any) => any | undefined | void;
|
|
144
|
+
readonly set?: (val?: any, item?: any) => any | undefined | void;
|
|
145
|
+
readonly default?: string | (() => string);
|
|
146
|
+
readonly validate?: ((val: any) => boolean) | ((val: any) => void) | ((val: any) => string | void);
|
|
147
|
+
readonly field?: string;
|
|
148
|
+
readonly label?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
export interface EnumAttribute {
|
|
153
|
+
readonly type: ReadonlyArray<string>;
|
|
154
|
+
readonly required?: boolean;
|
|
155
|
+
readonly hidden?: boolean;
|
|
156
|
+
readonly readOnly?: boolean;
|
|
157
|
+
readonly get?: (val: any, item: any) => any | undefined | void;
|
|
158
|
+
readonly set?: (val?: any, item?: any) => any | undefined | void;
|
|
159
|
+
readonly default?: string | (() => string);
|
|
160
|
+
readonly validate?: ((val: any) => boolean) | ((val: any) => void) | ((val: any) => string | void);
|
|
161
|
+
readonly field?: string;
|
|
162
|
+
readonly label?: string;
|
|
163
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface NestedAnyAttribute {
|
|
167
|
+
readonly type: "any";
|
|
168
|
+
readonly required?: boolean;
|
|
169
|
+
readonly hidden?: boolean;
|
|
170
|
+
readonly readOnly?: boolean;
|
|
171
|
+
readonly get?: (val: any, item: any) => any | undefined | void;
|
|
172
|
+
readonly set?: (val?: any, item?: any) => any | undefined | void;
|
|
173
|
+
readonly default?: any | (() => any);
|
|
174
|
+
readonly validate?: ((val: any) => boolean) | ((val: any) => void) | ((val: any) => string | void);
|
|
175
|
+
readonly field?: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface AnyAttribute {
|
|
179
|
+
readonly type: "any";
|
|
180
|
+
readonly required?: boolean;
|
|
181
|
+
readonly hidden?: boolean;
|
|
182
|
+
readonly readOnly?: boolean;
|
|
183
|
+
readonly get?: (val: any, item: any) => any | undefined | void;
|
|
184
|
+
readonly set?: (val?: any, item?: any) => any | undefined | void;
|
|
185
|
+
readonly default?: any | (() => any);
|
|
186
|
+
readonly validate?: ((val: any) => boolean) | ((val: any) => void) | ((val: any) => string | void);
|
|
187
|
+
readonly field?: string;
|
|
188
|
+
readonly label?: string;
|
|
189
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface NestedMapAttribute {
|
|
193
|
+
readonly type: "map";
|
|
194
|
+
readonly properties: {
|
|
195
|
+
readonly [name: string]: NestedAttributes;
|
|
196
|
+
};
|
|
197
|
+
readonly required?: boolean;
|
|
198
|
+
readonly hidden?: boolean;
|
|
199
|
+
readonly readOnly?: boolean;
|
|
200
|
+
readonly get?: (val: Record<string, any>, item: any) => Record<string, any> | undefined | void;
|
|
201
|
+
readonly set?: (val?: Record<string, any>, item?: any) => Record<string, any> | undefined | void;
|
|
202
|
+
readonly default?: Record<string, any> | (() => Record<string, any>);
|
|
203
|
+
readonly validate?: ((val: Record<string, any>) => boolean) | ((val: Record<string, any>) => void) | ((val: Record<string, any>) => string | void);
|
|
204
|
+
readonly field?: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface MapAttribute {
|
|
208
|
+
readonly type: "map";
|
|
209
|
+
readonly properties: {
|
|
210
|
+
readonly [name: string]: NestedAttributes;
|
|
211
|
+
};
|
|
212
|
+
readonly required?: boolean;
|
|
213
|
+
readonly hidden?: boolean;
|
|
214
|
+
readonly readOnly?: boolean;
|
|
215
|
+
readonly get?: (val: Record<string, any>, item: any) => Record<string, any> | undefined | void;
|
|
216
|
+
readonly set?: (val?: Record<string, any>, item?: any) => Record<string, any> | undefined | void;
|
|
217
|
+
readonly default?: Record<string, any> | (() => Record<string, any>);
|
|
218
|
+
readonly validate?: ((val: Record<string, any>) => boolean) | ((val: Record<string, any>) => void) | ((val: Record<string, any>) => string | void);
|
|
219
|
+
readonly field?: string;
|
|
220
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface NestedStringListAttribute {
|
|
224
|
+
readonly type: "list";
|
|
225
|
+
readonly items: {
|
|
226
|
+
readonly type: "string";
|
|
227
|
+
readonly required?: boolean;
|
|
228
|
+
readonly hidden?: boolean;
|
|
229
|
+
readonly readOnly?: boolean;
|
|
230
|
+
readonly get?: (val: string, item: any) => string | undefined | void;
|
|
231
|
+
readonly set?: (val?: string, item?: any) => string | undefined | void;
|
|
232
|
+
readonly default?: string | (() => string);
|
|
233
|
+
readonly validate?: ((val: string) => boolean) | ((val: string) => void) | ((val: string) => string | void) | RegExp;
|
|
234
|
+
readonly field?: string;
|
|
235
|
+
};
|
|
236
|
+
readonly required?: boolean;
|
|
237
|
+
readonly hidden?: boolean;
|
|
238
|
+
readonly readOnly?: boolean;
|
|
239
|
+
readonly get?: (val: Array<string>, item: any) => Array<string> | undefined | void;
|
|
240
|
+
readonly set?: (val?: Array<string>, item?: any) => Array<string> | undefined | void;
|
|
241
|
+
readonly default?: Array<string> | (() => Array<string>);
|
|
242
|
+
readonly validate?: ((val: Array<string>) => boolean) | ((val: Array<string>) => void) | ((val: Array<string>) => string | void);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface StringListAttribute {
|
|
246
|
+
readonly type: "list";
|
|
247
|
+
readonly items: {
|
|
248
|
+
readonly type: "string";
|
|
249
|
+
readonly required?: boolean;
|
|
250
|
+
readonly hidden?: boolean;
|
|
251
|
+
readonly readOnly?: boolean;
|
|
252
|
+
readonly get?: (val: string, item: any) => string | undefined | void;
|
|
253
|
+
readonly set?: (val?: string, item?: any) => string | undefined | void;
|
|
254
|
+
readonly default?: string | (() => string);
|
|
255
|
+
readonly validate?: ((val: string) => boolean) | ((val: string) => void) | ((val: string) => string | void) | RegExp;
|
|
256
|
+
readonly field?: string;
|
|
257
|
+
}
|
|
258
|
+
readonly required?: boolean;
|
|
259
|
+
readonly hidden?: boolean;
|
|
260
|
+
readonly readOnly?: boolean;
|
|
261
|
+
readonly get?: (val: Array<string>, item: any) => Array<string> | undefined | void;
|
|
262
|
+
readonly set?: (val?: Array<string>, item?: any) => Array<string> | undefined | void;
|
|
263
|
+
readonly default?: Array<string> | (() => Array<string>);
|
|
264
|
+
readonly validate?: ((val: Array<string>) => boolean) | ((val: Array<string>) => void) | ((val: Array<string>) => string | void);
|
|
265
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface NestedNumberListAttribute {
|
|
269
|
+
readonly type: "list";
|
|
270
|
+
readonly items: NestedNumberAttribute;
|
|
271
|
+
readonly required?: boolean;
|
|
272
|
+
readonly hidden?: boolean;
|
|
273
|
+
readonly readOnly?: boolean;
|
|
274
|
+
readonly get?: (val: Array<number>, item: any) => Array<number> | undefined | void;
|
|
275
|
+
readonly set?: (val?: Array<number>, item?: any) => Array<number> | undefined | void;
|
|
276
|
+
readonly default?: Array<number> | (() => Array<number>);
|
|
277
|
+
readonly validate?: ((val: Array<number>) => boolean) | ((val: Array<number>) => void) | ((val: Array<number>) => string | void);
|
|
278
|
+
readonly field?: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface NumberListAttribute {
|
|
282
|
+
readonly type: "list";
|
|
283
|
+
readonly items: NestedNumberAttribute;
|
|
284
|
+
readonly required?: boolean;
|
|
285
|
+
readonly hidden?: boolean;
|
|
286
|
+
readonly readOnly?: boolean;
|
|
287
|
+
readonly get?: (val: Array<number>, item: any) => Array<number> | undefined | void;
|
|
288
|
+
readonly set?: (val?: Array<number>, item?: any) => Array<number> | undefined | void;
|
|
289
|
+
readonly default?: Array<number> | (() => Array<number>);
|
|
290
|
+
readonly validate?: ((val: Array<number>) => boolean) | ((val: Array<number>) => void) | ((val: Array<number>) => string | void);
|
|
291
|
+
readonly field?: string;
|
|
292
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface NestedMapListAttribute {
|
|
296
|
+
readonly type: "list";
|
|
297
|
+
readonly items: NestedMapAttribute;
|
|
298
|
+
readonly required?: boolean;
|
|
299
|
+
readonly hidden?: boolean;
|
|
300
|
+
readonly readOnly?: boolean;
|
|
301
|
+
readonly get?: (val: Record<string, any>[], item: any) => Record<string, any>[] | undefined | void;
|
|
302
|
+
readonly set?: (val?: Record<string, any>[], item?: any) => Record<string, any>[] | undefined | void;
|
|
303
|
+
readonly default?: Record<string, any>[] | (() => Record<string, any>[]);
|
|
304
|
+
readonly validate?: ((val: Record<string, any>[]) => boolean) | ((val: Record<string, any>[]) => void) | ((val: Record<string, any>[]) => string | void);
|
|
305
|
+
readonly field?: string;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export interface MapListAttribute {
|
|
309
|
+
readonly type: "list";
|
|
310
|
+
readonly items: NestedMapAttribute;
|
|
311
|
+
readonly required?: boolean;
|
|
312
|
+
readonly hidden?: boolean;
|
|
313
|
+
readonly readOnly?: boolean;
|
|
314
|
+
readonly get?: (val: Record<string, any>[], item: any) => Record<string, any>[] | undefined | void;
|
|
315
|
+
readonly set?: (val?: Record<string, any>[], item?: any) => Record<string, any>[] | undefined | void;
|
|
316
|
+
readonly default?: Record<string, any>[] | (() => Record<string, any>[]);
|
|
317
|
+
readonly validate?: ((val: Record<string, any>[]) => boolean) | ((val: Record<string, any>[]) => void) | ((val: Record<string, any>[]) => string | void);
|
|
318
|
+
readonly field?: string;
|
|
319
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export interface NestedStringSetAttribute {
|
|
323
|
+
readonly type: "set";
|
|
324
|
+
readonly items: "string";
|
|
325
|
+
readonly required?: boolean;
|
|
326
|
+
readonly hidden?: boolean;
|
|
327
|
+
readonly readOnly?: boolean;
|
|
328
|
+
readonly get?: (val: Array<string>, item: any) => Array<string> | undefined | void;
|
|
329
|
+
readonly set?: (val?: Array<string>, item?: any) => Array<string> | undefined | void;
|
|
330
|
+
readonly default?: Array<string> | (() => Array<string>);
|
|
331
|
+
readonly validate?: ((val: Array<string>) => boolean) | ((val: Array<string>) => void) | ((val: Array<string>) => string | void) | RegExp;
|
|
332
|
+
readonly field?: string;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface StringSetAttribute {
|
|
336
|
+
readonly type: "set";
|
|
337
|
+
readonly items: "string";
|
|
338
|
+
readonly required?: boolean;
|
|
339
|
+
readonly hidden?: boolean;
|
|
340
|
+
readonly readOnly?: boolean;
|
|
341
|
+
readonly get?: (val: Array<string>, item: any) => Array<string> | undefined | void;
|
|
342
|
+
readonly set?: (val?: Array<string>, item?: any) => Array<string> | undefined | void;
|
|
343
|
+
readonly default?: Array<string> | (() => Array<string>);
|
|
344
|
+
readonly validate?: ((val: Array<string>) => boolean) | ((val: Array<string>) => void) | ((val: Array<string>) => string | void) | RegExp;
|
|
345
|
+
readonly field?: string;
|
|
346
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export interface NestedNumberSetAttribute {
|
|
350
|
+
readonly type: "set";
|
|
351
|
+
readonly items: "number";
|
|
352
|
+
readonly required?: boolean;
|
|
353
|
+
readonly hidden?: boolean;
|
|
354
|
+
readonly readOnly?: boolean;
|
|
355
|
+
readonly get?: (val: Array<number>, item: any) => Array<number> | undefined | void;
|
|
356
|
+
readonly set?: (val?: Array<number>, item?: any) => Array<number> | undefined | void;
|
|
357
|
+
readonly default?: Array<number> | (() => Array<number>);
|
|
358
|
+
readonly validate?: ((val: Array<number>) => boolean) | ((val: Array<number>) => void) | ((val: Array<number>) => string | void);
|
|
359
|
+
readonly field?: string;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export interface NumberSetAttribute {
|
|
363
|
+
readonly type: "set";
|
|
364
|
+
readonly items: "number";
|
|
365
|
+
readonly required?: boolean;
|
|
366
|
+
readonly hidden?: boolean;
|
|
367
|
+
readonly readOnly?: boolean;
|
|
368
|
+
readonly get?: (val: Array<number>, item: any) => Array<number> | undefined | void;
|
|
369
|
+
readonly set?: (val?: Array<number>, item?: any) => Array<number> | undefined | void;
|
|
370
|
+
readonly default?: Array<number> | (() => Array<number>);
|
|
371
|
+
readonly validate?: ((val: Array<number>) => boolean) | ((val: Array<number>) => void) | ((val: Array<number>) => string | void);
|
|
372
|
+
readonly field?: string;
|
|
373
|
+
readonly watch?: ReadonlyArray<string> | "*";
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
type Attribute =
|
|
377
|
+
BooleanAttribute
|
|
378
|
+
| NumberAttribute
|
|
379
|
+
| StringAttribute
|
|
380
|
+
| EnumAttribute
|
|
381
|
+
| AnyAttribute
|
|
382
|
+
| MapAttribute
|
|
383
|
+
| StringSetAttribute
|
|
384
|
+
| NumberSetAttribute
|
|
385
|
+
| StringListAttribute
|
|
386
|
+
| NumberListAttribute
|
|
387
|
+
| MapListAttribute;
|
|
388
|
+
|
|
389
|
+
type NestedAttributes =
|
|
390
|
+
NestedBooleanAttribute
|
|
391
|
+
| NestedNumberAttribute
|
|
392
|
+
| NestedStringAttribute
|
|
393
|
+
| NestedAnyAttribute
|
|
394
|
+
| NestedMapAttribute
|
|
395
|
+
| NestedStringListAttribute
|
|
396
|
+
| NestedNumberListAttribute
|
|
397
|
+
| NestedMapListAttribute
|
|
398
|
+
| NestedStringSetAttribute
|
|
399
|
+
| NestedNumberSetAttribute
|
|
400
|
+
| NestedEnumAttribute;
|
|
401
|
+
|
|
402
|
+
export interface IndexWithSortKey {
|
|
403
|
+
readonly sk: {
|
|
404
|
+
readonly field: string;
|
|
405
|
+
readonly composite: ReadonlyArray<string>;
|
|
406
|
+
readonly template?: string;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
type AccessPatternCollection<C extends string> = C | ReadonlyArray<C>;
|
|
411
|
+
|
|
412
|
+
export interface Schema<A extends string, F extends string, C extends string> {
|
|
413
|
+
readonly model: {
|
|
414
|
+
readonly entity: string;
|
|
415
|
+
readonly service: string;
|
|
416
|
+
readonly version: string;
|
|
417
|
+
}
|
|
418
|
+
readonly attributes: {
|
|
419
|
+
readonly [a in A]: Attribute
|
|
420
|
+
};
|
|
421
|
+
readonly indexes: {
|
|
422
|
+
[accessPattern: string]: {
|
|
423
|
+
readonly index?: string;
|
|
424
|
+
readonly collection?: AccessPatternCollection<C>;
|
|
425
|
+
readonly pk: {
|
|
426
|
+
readonly casing?: "upper" | "lower" | "none" | "default";
|
|
427
|
+
readonly field: string;
|
|
428
|
+
readonly composite: ReadonlyArray<F>;
|
|
429
|
+
readonly template?: string;
|
|
430
|
+
}
|
|
431
|
+
readonly sk?: {
|
|
432
|
+
readonly casing?: "upper" | "lower" | "none" | "default";
|
|
433
|
+
readonly field: string;
|
|
434
|
+
readonly composite: ReadonlyArray<F>;
|
|
435
|
+
readonly template?: string;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
type Attributes<A extends string> = Record<A, Attribute>
|
|
442
|
+
|
|
443
|
+
export type IndexCollections<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
444
|
+
[i in keyof S["indexes"]]: S["indexes"][i]["collection"] extends
|
|
445
|
+
AccessPatternCollection<infer Name>
|
|
446
|
+
? Name
|
|
447
|
+
: never
|
|
448
|
+
}[keyof S["indexes"]];
|
|
449
|
+
|
|
450
|
+
export type EntityCollections<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
451
|
+
[N in IndexCollections<A,F,C,S>]: {
|
|
452
|
+
[i in keyof S["indexes"]]: S["indexes"][i]["collection"] extends AccessPatternCollection<infer Name>
|
|
453
|
+
? Name extends N
|
|
454
|
+
? i
|
|
455
|
+
: never
|
|
456
|
+
: never
|
|
457
|
+
}[keyof S["indexes"]];
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// type UndefinedKeys<T> = {
|
|
461
|
+
// [P in keyof T]: undefined extends T[P] ? P: never
|
|
462
|
+
// }[keyof T]
|
|
463
|
+
|
|
464
|
+
declare const SkipSymbol: unique symbol;
|
|
465
|
+
type SkipValue = typeof SkipSymbol;
|
|
466
|
+
|
|
467
|
+
type DefinedKeys<T> = {
|
|
468
|
+
[P in keyof T as
|
|
469
|
+
[undefined] extends [T[P]]
|
|
470
|
+
? never
|
|
471
|
+
: SkipValue extends T[P]
|
|
472
|
+
? never
|
|
473
|
+
: P
|
|
474
|
+
]: T[P]
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
type PartialDefinedKeys<T> = {
|
|
478
|
+
[P in keyof T as
|
|
479
|
+
[undefined] extends [T[P]]
|
|
480
|
+
? never
|
|
481
|
+
: SkipValue extends T[P]
|
|
482
|
+
? never
|
|
483
|
+
: P
|
|
484
|
+
]?: T[P] | undefined;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
type SkipKeys<T> = {
|
|
488
|
+
[P in keyof T as SkipValue extends T[P] ? never : P]: T[P]
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// type TrimmedAttributes<A extends Attributes<any>> =
|
|
492
|
+
// Partial<Pick<A, UndefinedKeys<A>>> & Omit<A, UndefinedKeys<A>>
|
|
493
|
+
|
|
494
|
+
export type ItemAttribute<A extends Attribute> =
|
|
495
|
+
A["type"] extends infer R
|
|
496
|
+
? R extends "string" ? string
|
|
497
|
+
: R extends "number" ? number
|
|
498
|
+
: R extends "boolean" ? boolean
|
|
499
|
+
: R extends ReadonlyArray<infer E> ? E
|
|
500
|
+
: R extends "map"
|
|
501
|
+
? "properties" extends keyof A
|
|
502
|
+
? {
|
|
503
|
+
[P in keyof A["properties"]]:
|
|
504
|
+
A["properties"][P] extends infer M
|
|
505
|
+
? M extends Attribute
|
|
506
|
+
? ItemAttribute<M>
|
|
507
|
+
: never
|
|
508
|
+
: never
|
|
509
|
+
}
|
|
510
|
+
: never
|
|
511
|
+
: R extends "list"
|
|
512
|
+
? "items" extends keyof A
|
|
513
|
+
? A["items"] extends infer I
|
|
514
|
+
? I extends Attribute
|
|
515
|
+
? Array<ItemAttribute<I>>
|
|
516
|
+
: never
|
|
517
|
+
: never
|
|
518
|
+
: never
|
|
519
|
+
: R extends "set"
|
|
520
|
+
? "items" extends keyof A
|
|
521
|
+
? A["items"] extends infer I
|
|
522
|
+
? I extends "string" ? string[]
|
|
523
|
+
: I extends "number" ? number[]
|
|
524
|
+
: never
|
|
525
|
+
: never
|
|
526
|
+
: never
|
|
527
|
+
: R extends "any" ? any
|
|
528
|
+
: never
|
|
529
|
+
: never
|
|
530
|
+
|
|
531
|
+
type FormattedPutMapAttributes<A extends MapAttribute> = {
|
|
532
|
+
[P in keyof A["properties"]]: A["properties"][P] extends infer M
|
|
533
|
+
? M extends HiddenAttribute
|
|
534
|
+
? false
|
|
535
|
+
: M extends DefaultedAttribute
|
|
536
|
+
? false
|
|
537
|
+
: M extends RequiredAttribute
|
|
538
|
+
? true
|
|
539
|
+
: false
|
|
540
|
+
: false
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
type ReturnedAttribute<A extends Attribute> =
|
|
544
|
+
A["type"] extends infer R
|
|
545
|
+
? R extends "string" ? string
|
|
546
|
+
: R extends "number" ? number
|
|
547
|
+
: R extends "boolean" ? boolean
|
|
548
|
+
: R extends ReadonlyArray<infer E> ? E
|
|
549
|
+
: R extends "map"
|
|
550
|
+
? "properties" extends keyof A
|
|
551
|
+
?
|
|
552
|
+
{
|
|
553
|
+
[
|
|
554
|
+
P in keyof A["properties"] as A["properties"][P] extends RequiredAttribute
|
|
555
|
+
? P
|
|
556
|
+
: never
|
|
557
|
+
]: A["properties"][P] extends infer M
|
|
558
|
+
? M extends Attribute
|
|
559
|
+
? ReturnedAttribute<M>
|
|
560
|
+
: never
|
|
561
|
+
: never
|
|
562
|
+
} & {
|
|
563
|
+
[
|
|
564
|
+
P in keyof A["properties"] as A["properties"][P] extends HiddenAttribute | RequiredAttribute
|
|
565
|
+
? never
|
|
566
|
+
: P
|
|
567
|
+
]?: A["properties"][P] extends infer M
|
|
568
|
+
? M extends Attribute
|
|
569
|
+
? ReturnedAttribute<M> | undefined
|
|
570
|
+
: never
|
|
571
|
+
: never
|
|
572
|
+
}
|
|
573
|
+
// SkipKeys<{
|
|
574
|
+
// [P in keyof A["properties"]]: A["properties"][P] extends infer M
|
|
575
|
+
// ? M extends Attribute
|
|
576
|
+
// ? M extends HiddenAttribute
|
|
577
|
+
// ? SkipValue
|
|
578
|
+
// : M extends RequiredAttribute
|
|
579
|
+
// ? ReturnedAttribute<M>
|
|
580
|
+
// : SkipValue
|
|
581
|
+
// : never
|
|
582
|
+
// : never
|
|
583
|
+
// }> & SkipKeys<{
|
|
584
|
+
// [P in keyof A["properties"]]?: A["properties"][P] extends infer M
|
|
585
|
+
// ? M extends Attribute
|
|
586
|
+
// ? M extends HiddenAttribute
|
|
587
|
+
// ? SkipValue
|
|
588
|
+
// : M extends RequiredAttribute
|
|
589
|
+
// ? SkipValue
|
|
590
|
+
// : ReturnedAttribute<M> | undefined
|
|
591
|
+
// : never
|
|
592
|
+
// : never
|
|
593
|
+
// }>
|
|
594
|
+
: never
|
|
595
|
+
: R extends "list"
|
|
596
|
+
? "items" extends keyof A
|
|
597
|
+
? A["items"] extends infer I
|
|
598
|
+
? I extends Attribute
|
|
599
|
+
? ReturnedAttribute<I>[]
|
|
600
|
+
: never
|
|
601
|
+
: never
|
|
602
|
+
: never
|
|
603
|
+
: R extends "set"
|
|
604
|
+
? "items" extends keyof A
|
|
605
|
+
? A["items"] extends infer I
|
|
606
|
+
? I extends "string" ? string[]
|
|
607
|
+
: I extends "number" ? number[]
|
|
608
|
+
: never
|
|
609
|
+
: never
|
|
610
|
+
: never
|
|
611
|
+
: R extends "any" ? any
|
|
612
|
+
: never
|
|
613
|
+
: never
|
|
614
|
+
|
|
615
|
+
type CreatedAttribute<A extends Attribute> =
|
|
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
|
+
? {
|
|
624
|
+
[
|
|
625
|
+
P in keyof A["properties"] as A["properties"][P] extends RequiredAttribute
|
|
626
|
+
? A["properties"][P] extends DefaultedAttribute
|
|
627
|
+
? never
|
|
628
|
+
: P
|
|
629
|
+
: never
|
|
630
|
+
]: A["properties"][P] extends infer M
|
|
631
|
+
? M extends Attribute
|
|
632
|
+
? CreatedAttribute<M>
|
|
633
|
+
: never
|
|
634
|
+
: never
|
|
635
|
+
} & {
|
|
636
|
+
[P in keyof A["properties"] as A["properties"][P] extends HiddenAttribute
|
|
637
|
+
? never
|
|
638
|
+
: P
|
|
639
|
+
]?: A["properties"][P] extends infer M
|
|
640
|
+
? M extends Attribute
|
|
641
|
+
? CreatedAttribute<M> | undefined
|
|
642
|
+
: never
|
|
643
|
+
: never
|
|
644
|
+
}
|
|
645
|
+
// ? SkipKeys<{
|
|
646
|
+
// [P in keyof A["properties"]]: A["properties"][P] extends infer M
|
|
647
|
+
// ? M extends Attribute
|
|
648
|
+
// ? M extends HiddenAttribute
|
|
649
|
+
// ? SkipValue
|
|
650
|
+
// : M extends DefaultedAttribute
|
|
651
|
+
// ? SkipValue
|
|
652
|
+
// : M extends RequiredAttribute
|
|
653
|
+
// ? CreatedAttribute<M>
|
|
654
|
+
// : SkipValue
|
|
655
|
+
// : never
|
|
656
|
+
// : never
|
|
657
|
+
// }> & SkipKeys<{
|
|
658
|
+
// [P in keyof A["properties"]]?: A["properties"][P] extends infer M
|
|
659
|
+
// ? M extends Attribute
|
|
660
|
+
// ? M extends HiddenAttribute
|
|
661
|
+
// ? SkipValue
|
|
662
|
+
// : CreatedAttribute<M> | undefined
|
|
663
|
+
// : never
|
|
664
|
+
// : never
|
|
665
|
+
// }>
|
|
666
|
+
: never
|
|
667
|
+
: R extends "list"
|
|
668
|
+
? "items" extends keyof A
|
|
669
|
+
? A["items"] extends infer I
|
|
670
|
+
? I extends Attribute
|
|
671
|
+
? CreatedAttribute<I>[]
|
|
672
|
+
: never
|
|
673
|
+
: never
|
|
674
|
+
: never
|
|
675
|
+
: R extends "set"
|
|
676
|
+
? "items" extends keyof A
|
|
677
|
+
? A["items"] extends infer I
|
|
678
|
+
? I extends "string" ? string[]
|
|
679
|
+
: I extends "number" ? number[]
|
|
680
|
+
: never
|
|
681
|
+
: never
|
|
682
|
+
: never
|
|
683
|
+
: R extends "any" ? any
|
|
684
|
+
: never
|
|
685
|
+
: never
|
|
686
|
+
|
|
687
|
+
export type ReturnedItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>,Attr extends S["attributes"]> = {
|
|
688
|
+
[a in keyof Attr]: ReturnedAttribute<Attr[a]>
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export type CreatedItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>,Attr extends S["attributes"]> = {
|
|
692
|
+
[a in keyof Attr]: CreatedAttribute<Attr[a]>
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
type EditableItemAttribute<A extends Attribute> =
|
|
696
|
+
A extends ReadOnlyAttribute
|
|
697
|
+
? never
|
|
698
|
+
: A["type"] extends infer R
|
|
699
|
+
? R extends "string" ? string
|
|
700
|
+
: R extends "number" ? number
|
|
701
|
+
: R extends "boolean" ? boolean
|
|
702
|
+
: R extends ReadonlyArray<infer E> ? E
|
|
703
|
+
: R extends "map"
|
|
704
|
+
? "properties" extends keyof A
|
|
705
|
+
? {
|
|
706
|
+
[
|
|
707
|
+
P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute
|
|
708
|
+
? never
|
|
709
|
+
: P
|
|
710
|
+
]:
|
|
711
|
+
A["properties"][P] extends infer M
|
|
712
|
+
? M extends Attribute
|
|
713
|
+
? EditableItemAttribute<M>
|
|
714
|
+
: never
|
|
715
|
+
: never
|
|
716
|
+
}
|
|
717
|
+
: never
|
|
718
|
+
: R extends "list"
|
|
719
|
+
? "items" extends keyof A
|
|
720
|
+
? A["items"] extends infer I
|
|
721
|
+
? I extends Attribute
|
|
722
|
+
? Array<EditableItemAttribute<I>>
|
|
723
|
+
: never
|
|
724
|
+
: never
|
|
725
|
+
: never
|
|
726
|
+
: R extends "set"
|
|
727
|
+
? "items" extends keyof A
|
|
728
|
+
? A["items"] extends infer I
|
|
729
|
+
? I extends "string" ? string[]
|
|
730
|
+
: I extends "number" ? number[]
|
|
731
|
+
: never
|
|
732
|
+
: never
|
|
733
|
+
: never
|
|
734
|
+
: R extends "any" ? any
|
|
735
|
+
: never
|
|
736
|
+
: never
|
|
737
|
+
|
|
738
|
+
type UpdatableItemAttribute<A extends Attribute> =
|
|
739
|
+
A extends ReadOnlyAttribute
|
|
740
|
+
? never
|
|
741
|
+
: A["type"] extends infer R
|
|
742
|
+
? R extends "string" ? string
|
|
743
|
+
: R extends "number" ? number
|
|
744
|
+
: R extends "boolean" ? boolean
|
|
745
|
+
: R extends ReadonlyArray<infer E> ? E
|
|
746
|
+
: R extends "map"
|
|
747
|
+
? "properties" extends keyof A
|
|
748
|
+
? {
|
|
749
|
+
[
|
|
750
|
+
P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute
|
|
751
|
+
? never
|
|
752
|
+
: A["properties"][P] extends RequiredAttribute
|
|
753
|
+
? P
|
|
754
|
+
: never
|
|
755
|
+
]:
|
|
756
|
+
A["properties"][P] extends infer M
|
|
757
|
+
? M extends Attribute
|
|
758
|
+
? UpdatableItemAttribute<M>
|
|
759
|
+
: never
|
|
760
|
+
: never
|
|
761
|
+
} & {
|
|
762
|
+
[
|
|
763
|
+
P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute
|
|
764
|
+
? never
|
|
765
|
+
: A["properties"][P] extends RequiredAttribute
|
|
766
|
+
? never
|
|
767
|
+
: P
|
|
768
|
+
]?:
|
|
769
|
+
A["properties"][P] extends infer M
|
|
770
|
+
? M extends Attribute
|
|
771
|
+
? UpdatableItemAttribute<M>
|
|
772
|
+
: never
|
|
773
|
+
: never
|
|
774
|
+
}
|
|
775
|
+
: never
|
|
776
|
+
: R extends "list"
|
|
777
|
+
? "items" extends keyof A
|
|
778
|
+
? A["items"] extends infer I
|
|
779
|
+
? I extends Attribute
|
|
780
|
+
? Array<UpdatableItemAttribute<I>>
|
|
781
|
+
: never
|
|
782
|
+
: never
|
|
783
|
+
: never
|
|
784
|
+
: R extends "set"
|
|
785
|
+
? "items" extends keyof A
|
|
786
|
+
? A["items"] extends infer I
|
|
787
|
+
? I extends "string" ? string[]
|
|
788
|
+
: I extends "number" ? number[]
|
|
789
|
+
: never
|
|
790
|
+
: never
|
|
791
|
+
: never
|
|
792
|
+
: R extends "any" ? any
|
|
793
|
+
: never
|
|
794
|
+
: never
|
|
795
|
+
|
|
796
|
+
type RemovableItemAttribute<A extends Attribute> =
|
|
797
|
+
A extends ReadOnlyAttribute | RequiredAttribute
|
|
798
|
+
? never
|
|
799
|
+
: A["type"] extends infer R
|
|
800
|
+
? R extends "string" ? string
|
|
801
|
+
: R extends "number" ? number
|
|
802
|
+
: R extends "boolean" ? boolean
|
|
803
|
+
: R extends ReadonlyArray<infer E> ? E
|
|
804
|
+
: R extends "map"
|
|
805
|
+
? "properties" extends keyof A
|
|
806
|
+
? {
|
|
807
|
+
[
|
|
808
|
+
P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute | RequiredAttribute
|
|
809
|
+
? never
|
|
810
|
+
: P
|
|
811
|
+
]?:
|
|
812
|
+
A["properties"][P] extends infer M
|
|
813
|
+
? M extends Attribute
|
|
814
|
+
? UpdatableItemAttribute<M>
|
|
815
|
+
: never
|
|
816
|
+
: never
|
|
817
|
+
}
|
|
818
|
+
: never
|
|
819
|
+
: R extends "list"
|
|
820
|
+
? "items" extends keyof A
|
|
821
|
+
? A["items"] extends infer I
|
|
822
|
+
? I extends Attribute
|
|
823
|
+
? Array<UpdatableItemAttribute<I>>
|
|
824
|
+
: never
|
|
825
|
+
: never
|
|
826
|
+
: never
|
|
827
|
+
: R extends "set"
|
|
828
|
+
? "items" extends keyof A
|
|
829
|
+
? A["items"] extends infer I
|
|
830
|
+
? I extends "string" ? string[]
|
|
831
|
+
: I extends "number" ? number[]
|
|
832
|
+
: never
|
|
833
|
+
: never
|
|
834
|
+
: never
|
|
835
|
+
: R extends "any" ? any
|
|
836
|
+
: never
|
|
837
|
+
: never
|
|
838
|
+
|
|
839
|
+
export type Item<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, Attr extends Attributes<A>> = {
|
|
840
|
+
[a in keyof Attr]: ItemAttribute<Attr[a]>
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
export type ItemTypeDescription<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
844
|
+
[a in keyof S["attributes"]]: S["attributes"][a]["type"] extends infer R
|
|
845
|
+
? R
|
|
846
|
+
: never
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
export type RequiredAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = ExtractKeysOfValueType<{
|
|
850
|
+
[a in keyof S["attributes"]]: S["attributes"][a] extends RequiredAttribute
|
|
851
|
+
? true
|
|
852
|
+
: false
|
|
853
|
+
}, true>
|
|
854
|
+
|
|
855
|
+
export type HiddenAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = ExtractKeysOfValueType<{
|
|
856
|
+
[a in keyof S["attributes"]]: S["attributes"][a] extends HiddenAttribute
|
|
857
|
+
? true
|
|
858
|
+
: false
|
|
859
|
+
}, true>
|
|
860
|
+
|
|
861
|
+
export type ReadOnlyAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = ExtractKeysOfValueType<{
|
|
862
|
+
[a in keyof S["attributes"]]: S["attributes"][a] extends ReadOnlyAttribute
|
|
863
|
+
? true
|
|
864
|
+
: false
|
|
865
|
+
}, true>
|
|
866
|
+
|
|
867
|
+
type ExtractKeysOfValueType<T, K> = {
|
|
868
|
+
[I in keyof T]: T[I] extends K ? I : never
|
|
869
|
+
}[keyof T];
|
|
870
|
+
|
|
871
|
+
export type TableIndexes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
872
|
+
[i in keyof S["indexes"]]: S["indexes"][i] extends SecondaryIndex
|
|
873
|
+
? "secondary"
|
|
874
|
+
: "table"
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
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">;
|
|
878
|
+
|
|
879
|
+
export type PKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
880
|
+
[i in keyof S["indexes"]]: S["indexes"][i]["pk"]["composite"] extends ReadonlyArray<infer Composite>
|
|
881
|
+
? Composite
|
|
882
|
+
: never
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export type SKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
886
|
+
[i in keyof S["indexes"]]: S["indexes"][i] extends IndexWithSortKey
|
|
887
|
+
? S["indexes"][i]["sk"]["composite"] extends ReadonlyArray<infer Composite>
|
|
888
|
+
? Composite
|
|
889
|
+
: never
|
|
890
|
+
: never;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
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>>;
|
|
894
|
+
|
|
895
|
+
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>>;
|
|
896
|
+
|
|
897
|
+
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>;
|
|
898
|
+
|
|
899
|
+
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>;
|
|
900
|
+
|
|
901
|
+
export type TableIndexPKAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
902
|
+
TableIndexName<A,F,C,S> extends keyof TableIndexPKCompositeAttributes<A,F,C,S>
|
|
903
|
+
? TableIndexPKCompositeAttributes<A,F,C,S>[TableIndexName<A,F,C,S>] extends keyof Item<A,F,C,S,S["attributes"]>
|
|
904
|
+
? Pick<Item<A,F,C,S,S["attributes"]>, TableIndexPKCompositeAttributes<A,F,C,S>[TableIndexName<A,F,C,S>]>
|
|
905
|
+
: never
|
|
906
|
+
: never
|
|
907
|
+
|
|
908
|
+
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"]
|
|
909
|
+
? Pick<Item<A,F,C,S,S["attributes"]>, TableIndexSKCompositeAttributes<A,F,C,S>[TableIndexName<A,F,C,S>]>
|
|
910
|
+
: Item<A,F,C,S,S["attributes"]>;
|
|
911
|
+
|
|
912
|
+
export type IndexPKAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> =
|
|
913
|
+
I extends keyof IndexPKCompositeAttributes<A,F,C,S,I>
|
|
914
|
+
? IndexPKCompositeAttributes<A,F,C,S,I>[I] extends keyof Item<A,F,C,S,S["attributes"]>
|
|
915
|
+
? Pick<Item<A,F,C,S,S["attributes"]>, IndexPKCompositeAttributes<A,F,C,S,I>[I]>
|
|
916
|
+
: never
|
|
917
|
+
: never;
|
|
918
|
+
|
|
919
|
+
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"]
|
|
920
|
+
? Pick<Item<A,F,C,S,S["attributes"]>, IndexSKCompositeAttributes<A,F,C,S,I>[I]>
|
|
921
|
+
: Item<A,F,C,S,S["attributes"]>;
|
|
922
|
+
|
|
923
|
+
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>>;
|
|
924
|
+
|
|
925
|
+
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>;
|
|
926
|
+
|
|
927
|
+
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>>;
|
|
928
|
+
|
|
929
|
+
export type TableItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
930
|
+
AllTableIndexCompositeAttributes<A,F,C,S> &
|
|
931
|
+
Pick<ReturnedItem<A,F,C,S,S["attributes"]>, RequiredAttributes<A,F,C,S>> &
|
|
932
|
+
Partial<Omit<ReturnedItem<A,F,C,S,S["attributes"]>, RequiredAttributes<A,F,C,S>>>
|
|
933
|
+
|
|
934
|
+
export type ResponseItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
935
|
+
Omit<TableItem<A,F,C,S>, HiddenAttributes<A,F,C,S>>
|
|
936
|
+
|
|
937
|
+
export type RequiredPutItems<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
938
|
+
[Attribute in keyof S["attributes"]]:
|
|
939
|
+
"default" extends keyof S["attributes"][Attribute]
|
|
940
|
+
? false
|
|
941
|
+
: "required" extends keyof S["attributes"][Attribute]
|
|
942
|
+
? true extends S["attributes"][Attribute]["required"]
|
|
943
|
+
? true
|
|
944
|
+
: Attribute extends keyof TableIndexCompositeAttributes<A,F,C,S>
|
|
945
|
+
? true
|
|
946
|
+
: false
|
|
947
|
+
: Attribute extends keyof TableIndexCompositeAttributes<A,F,C,S>
|
|
948
|
+
? true
|
|
949
|
+
: false
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
export type PutItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
953
|
+
Pick<CreatedItem<A,F,C,S,S["attributes"]>, ExtractKeysOfValueType<RequiredPutItems<A,F,C,S>,true>>
|
|
954
|
+
& Partial<CreatedItem<A,F,C,S,S["attributes"]>>
|
|
955
|
+
|
|
956
|
+
export type UpdateData<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
957
|
+
Omit<{
|
|
958
|
+
[Attr in keyof S["attributes"]]: EditableItemAttribute<S["attributes"][Attr]>
|
|
959
|
+
}, keyof AllTableIndexCompositeAttributes<A,F,C,S> | ReadOnlyAttributes<A,F,C,S>>
|
|
960
|
+
|
|
961
|
+
export type SetItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
962
|
+
// UpdatableItemAttribute
|
|
963
|
+
Omit<{
|
|
964
|
+
[Attr in keyof S["attributes"]]?: UpdatableItemAttribute<S["attributes"][Attr]>
|
|
965
|
+
}, keyof AllTableIndexCompositeAttributes<A,F,C,S> | ReadOnlyAttributes<A,F,C,S>>
|
|
966
|
+
|
|
967
|
+
// type RemoveItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
968
|
+
// Array<keyof SetItem<A,F,C,S>>
|
|
969
|
+
export type RemoveItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
970
|
+
Array< keyof Omit<{
|
|
971
|
+
[Attr in keyof S["attributes"]]?: RemovableItemAttribute<S["attributes"][Attr]>
|
|
972
|
+
}, keyof AllTableIndexCompositeAttributes<A,F,C,S> | ReadOnlyAttributes<A,F,C,S> | RequiredAttributes<A,F,C,S>>>
|
|
973
|
+
|
|
974
|
+
export type AppendItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
975
|
+
{
|
|
976
|
+
[
|
|
977
|
+
P in keyof ItemTypeDescription<A,F,C,S> as ItemTypeDescription<A,F,C,S>[P] extends 'list' | 'any'
|
|
978
|
+
? P
|
|
979
|
+
: never
|
|
980
|
+
]?: P extends keyof SetItem<A,F,C,S>
|
|
981
|
+
? SetItem<A,F,C,S>[P] | undefined
|
|
982
|
+
: never
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
export type AddItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
986
|
+
{
|
|
987
|
+
[
|
|
988
|
+
P in keyof ItemTypeDescription<A,F,C,S> as ItemTypeDescription<A,F,C,S>[P] extends "number" | "any" | "set"
|
|
989
|
+
? P
|
|
990
|
+
: never
|
|
991
|
+
]?: P extends keyof SetItem<A,F,C,S>
|
|
992
|
+
? SetItem<A,F,C,S>[P] | undefined
|
|
993
|
+
: never
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
export type SubtractItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
997
|
+
{
|
|
998
|
+
[
|
|
999
|
+
P in keyof ItemTypeDescription<A,F,C,S> as ItemTypeDescription<A,F,C,S>[P] extends "number" | "any"
|
|
1000
|
+
? P
|
|
1001
|
+
: never
|
|
1002
|
+
]?: P extends keyof SetItem<A,F,C,S>
|
|
1003
|
+
? SetItem<A,F,C,S>[P] | undefined
|
|
1004
|
+
: never
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
export type DeleteItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
|
|
1008
|
+
{
|
|
1009
|
+
[
|
|
1010
|
+
P in keyof ItemTypeDescription<A,F,C,S> as ItemTypeDescription<A,F,C,S>[P] extends "any" | "set"
|
|
1011
|
+
? P
|
|
1012
|
+
: never
|
|
1013
|
+
]?: P extends keyof SetItem<A,F,C,S>
|
|
1014
|
+
? SetItem<A,F,C,S>[P] | undefined
|
|
1015
|
+
: never
|
|
1016
|
+
}
|