electrodb 1.12.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +1 -1
- package/README.md +712 -668
- package/index.d.ts +192 -179
- package/package.json +1 -1
- package/src/clauses.js +15 -32
- package/src/entity.js +184 -92
- package/src/errors.js +6 -0
- package/src/filters.js +2 -2
- package/src/operations.js +1 -1
- package/src/schema.js +68 -12
- package/src/service.js +48 -117
- package/src/types.js +15 -2
- package/src/util.js +63 -0
- package/src/validations.js +12 -0
- package/src/where.js +2 -2
- package/notes +0 -45
- package/output +0 -106
- package/taskdata.json +0 -1
- package/typez.ts +0 -1736
package/index.d.ts
CHANGED
|
@@ -81,11 +81,10 @@ export type CollectionWhereCallback<E extends {[name: string]: Entity<any, any,
|
|
|
81
81
|
export type CollectionWhereClause<E extends {[name: string]: Entity<any, any, any, any>}, A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Partial<AllEntityAttributes<E>>, T> = (where: CollectionWhereCallback<E, I>) => T;
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
export interface
|
|
85
|
-
go:
|
|
84
|
+
export interface ServiceWhereRecordsActionOptions<E extends {[name: string]: Entity<any, any, any, any>}, A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Partial<AllEntityAttributes<E>>, Items, IndexCompositeAttributes> {
|
|
85
|
+
go: ServiceQueryRecordsGo<Items>;
|
|
86
86
|
params: ParamRecord;
|
|
87
|
-
|
|
88
|
-
where: CollectionWhereClause<E,A,F,C,S,I, WhereRecordsActionOptions<E,A,F,C,S,I,Items,IndexCompositeAttributes>>;
|
|
87
|
+
where: CollectionWhereClause<E,A,F,C,S,I, ServiceWhereRecordsActionOptions<E,A,F,C,S,I,Items,IndexCompositeAttributes>>;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
export type CollectionIndexKeys<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
|
|
@@ -171,7 +170,7 @@ export type CollectionQueries<E extends {[name: string]: Entity<any, any, any, a
|
|
|
171
170
|
]
|
|
172
171
|
>[0]
|
|
173
172
|
>) => {
|
|
174
|
-
go:
|
|
173
|
+
go: ServiceQueryRecordsGo<{
|
|
175
174
|
[EntityResultName in Collections[Collection]]:
|
|
176
175
|
EntityResultName extends keyof E
|
|
177
176
|
? E[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
@@ -180,40 +179,13 @@ export type CollectionQueries<E extends {[name: string]: Entity<any, any, any, a
|
|
|
180
179
|
: never
|
|
181
180
|
}>;
|
|
182
181
|
params: ParamRecord;
|
|
183
|
-
page: {
|
|
184
|
-
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
185
|
-
? Pick<AllEntityAttributes<E>, Extract<AllEntityAttributeNames<E>, CollectionAttributes<E,Collections>[Collection]>> extends Partial<AllEntityAttributes<E>>
|
|
186
|
-
?
|
|
187
|
-
PageRecord<
|
|
188
|
-
{
|
|
189
|
-
[EntityResultName in Collections[Collection]]:
|
|
190
|
-
EntityResultName extends keyof E
|
|
191
|
-
? E[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
192
|
-
? ResponseItem<A,F,C,S>[]
|
|
193
|
-
: never
|
|
194
|
-
: never
|
|
195
|
-
},
|
|
196
|
-
Partial<
|
|
197
|
-
Spread<
|
|
198
|
-
Collection extends keyof CollectionPageAttributes<E, Collections>
|
|
199
|
-
? CollectionPageAttributes<E, Collections>[Collection]
|
|
200
|
-
: {},
|
|
201
|
-
Collection extends keyof CollectionIndexAttributes<E, Collections>
|
|
202
|
-
? CollectionIndexAttributes<E, Collections>[Collection]
|
|
203
|
-
: {}
|
|
204
|
-
>
|
|
205
|
-
>
|
|
206
|
-
>
|
|
207
|
-
: never
|
|
208
|
-
: never
|
|
209
|
-
}[Collections[Collection]];
|
|
210
182
|
where: {
|
|
211
183
|
[EntityResultName in Collections[Collection]]: EntityResultName extends keyof E
|
|
212
184
|
? E[EntityResultName] extends Entity<infer A, infer F, infer C, infer S>
|
|
213
185
|
? Pick<AllEntityAttributes<E>, Extract<AllEntityAttributeNames<E>, CollectionAttributes<E,Collections>[Collection]>> extends Partial<AllEntityAttributes<E>>
|
|
214
186
|
? CollectionWhereClause<E,A,F,C,S,
|
|
215
187
|
Pick<AllEntityAttributes<E>, Extract<AllEntityAttributeNames<E>, CollectionAttributes<E,Collections>[Collection]>>,
|
|
216
|
-
|
|
188
|
+
ServiceWhereRecordsActionOptions<E,A,F,C,S,
|
|
217
189
|
Pick<AllEntityAttributes<E>, Extract<AllEntityAttributeNames<E>, CollectionAttributes<E,Collections>[Collection]>>,
|
|
218
190
|
{
|
|
219
191
|
[EntityResultName in Collections[Collection]]:
|
|
@@ -260,9 +232,7 @@ export interface ElectroResultsEvent<R extends any = any> {
|
|
|
260
232
|
success: boolean;
|
|
261
233
|
}
|
|
262
234
|
|
|
263
|
-
export type ElectroEvent =
|
|
264
|
-
ElectroQueryEvent
|
|
265
|
-
| ElectroResultsEvent;
|
|
235
|
+
export type ElectroEvent = ElectroQueryEvent | ElectroResultsEvent;
|
|
266
236
|
|
|
267
237
|
export type ElectroEventType = Pick<ElectroEvent, 'type'>;
|
|
268
238
|
|
|
@@ -301,6 +271,16 @@ export type CreateEntityItem<E extends Entity<any, any, any, any>> =
|
|
|
301
271
|
? PutItem<A, F, C, S>
|
|
302
272
|
: never;
|
|
303
273
|
|
|
274
|
+
export type BatchWriteEntityItem<E extends Entity<any, any, any, any>> =
|
|
275
|
+
E extends Entity<infer A, infer F, infer C, infer S>
|
|
276
|
+
? PutItem<A, F, C, S>[]
|
|
277
|
+
: never;
|
|
278
|
+
|
|
279
|
+
export type BatchGetEntityItem<E extends Entity<any, any, any, any>> =
|
|
280
|
+
E extends Entity<infer A, infer F, infer C, infer S>
|
|
281
|
+
? ResponseItem<A, F, C, S>[]
|
|
282
|
+
: never;
|
|
283
|
+
|
|
304
284
|
export type UpdateEntityItem<E extends Entity<any, any, any, any>> =
|
|
305
285
|
E extends Entity<infer A, infer F, infer C, infer S>
|
|
306
286
|
? Partial<ResponseItem<A,F,C,S>>
|
|
@@ -351,19 +331,61 @@ export type CollectionItem<SERVICE extends Service<any>, COLLECTION extends keyo
|
|
|
351
331
|
: never>
|
|
352
332
|
: never
|
|
353
333
|
|
|
334
|
+
export type QueryResponse<E extends Entity<any, any, any, any>> = {
|
|
335
|
+
data: EntityItem<E>[];
|
|
336
|
+
cursor: string | null;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export type CreateEntityResponse<E extends Entity<any, any, any, any>> = {
|
|
340
|
+
data: CreateEntityItem<E>;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export type BatchWriteResponse<E extends Entity<any, any, any, any>> =
|
|
344
|
+
E extends Entity<infer A, infer F, infer C, infer S> ? {
|
|
345
|
+
unprocessed: AllTableIndexCompositeAttributes<A,F,C,S>[];
|
|
346
|
+
} : never
|
|
347
|
+
|
|
348
|
+
export type BatchGetResponse<E extends Entity<any, any, any, any>> =
|
|
349
|
+
E extends Entity<infer A, infer F, infer C, infer S> ? {
|
|
350
|
+
data: EntityItem<E>[];
|
|
351
|
+
unprocessed: AllTableIndexCompositeAttributes<A,F,C,S>[];
|
|
352
|
+
} : never;
|
|
353
|
+
|
|
354
|
+
export type UpdateEntityResponse<E extends Entity<any, any, any, any>> = {
|
|
355
|
+
data: UpdateEntityItem<E>;
|
|
356
|
+
}
|
|
357
|
+
export type UpdateAddEntityResponse<E extends Entity<any, any, any, any>> = {
|
|
358
|
+
data: UpdateAddEntityItem<E>;
|
|
359
|
+
}
|
|
360
|
+
export type UpdateSubtractEntityResponse<E extends Entity<any, any, any, any>> = {
|
|
361
|
+
data: UpdateSubtractEntityItem<E>;
|
|
362
|
+
}
|
|
363
|
+
export type UpdateAppendEntityResponse<E extends Entity<any, any, any, any>> = {
|
|
364
|
+
data: UpdateAppendEntityItem<E>;
|
|
365
|
+
}
|
|
366
|
+
export type UpdateRemoveEntityResponse<E extends Entity<any, any, any, any>> = {
|
|
367
|
+
data: UpdateRemoveEntityItem<E>;
|
|
368
|
+
}
|
|
369
|
+
export type UpdateDeleteEntityResponse<E extends Entity<any, any, any, any>> = {
|
|
370
|
+
data: UpdateDeleteEntityItem<E>;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export type CollectionResponse<SERVICE extends Service<any>, COLLECTION extends keyof SERVICE["collections"]> = {
|
|
374
|
+
data: CollectionItem<SERVICE, COLLECTION>;
|
|
375
|
+
cursor: string | null;
|
|
376
|
+
}
|
|
377
|
+
|
|
354
378
|
export interface QueryBranches<A extends string,
|
|
355
379
|
F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem, IndexCompositeAttributes> {
|
|
356
380
|
go: GoQueryTerminal<A,F,C,S,ResponseItem>;
|
|
357
381
|
params: ParamTerminal<A,F,C,S,ResponseItem>;
|
|
358
|
-
page: PageQueryTerminal<A,F,C,S,ResponseItem,IndexCompositeAttributes>;
|
|
359
382
|
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,QueryBranches<A,F,C,S,ResponseItem,IndexCompositeAttributes>>
|
|
360
383
|
}
|
|
361
384
|
|
|
362
385
|
export interface RecordsActionOptions<A extends string,
|
|
363
386
|
F extends string, C extends string, S extends Schema<A,F,C>, Items, IndexCompositeAttributes> {
|
|
364
|
-
go:
|
|
387
|
+
go: QueryRecordsGo<Items>;
|
|
365
388
|
params: ParamRecord;
|
|
366
|
-
page: PageRecord<Items,IndexCompositeAttributes>;
|
|
367
389
|
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,RecordsActionOptions<A,F,C,S,Items,IndexCompositeAttributes>>;
|
|
368
390
|
}
|
|
369
391
|
|
|
@@ -379,30 +401,24 @@ export interface BatchGetRecordOperationOptions<A extends string, F extends stri
|
|
|
379
401
|
}
|
|
380
402
|
|
|
381
403
|
export interface PutRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
382
|
-
go:
|
|
404
|
+
go: PutRecordGo<ResponseType, PutQueryOptions>;
|
|
383
405
|
params: ParamRecord<PutQueryOptions>;
|
|
384
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,PutRecordOperationOptions<A,F,C,S,ResponseType>>;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export interface UpdateRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
388
|
-
go: GoRecord<ResponseType, UpdateQueryOptions>;
|
|
389
|
-
params: ParamRecord<UpdateQueryParams>;
|
|
390
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,PutRecordOperationOptions<A,F,C,S,ResponseType>>;
|
|
406
|
+
where: WhereClause<A, F, C, S, Item<A, F, C, S, S["attributes"]>, PutRecordOperationOptions<A, F, C, S, ResponseType>>;
|
|
391
407
|
}
|
|
392
408
|
|
|
393
409
|
export interface DeleteRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
394
|
-
go:
|
|
410
|
+
go: DeleteRecordOperationGo<ResponseType, DeleteQueryOptions>;
|
|
395
411
|
params: ParamRecord<DeleteQueryOptions>;
|
|
396
412
|
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,DeleteRecordOperationOptions<A,F,C,S,ResponseType>>;
|
|
397
413
|
}
|
|
398
414
|
|
|
399
|
-
export interface
|
|
400
|
-
go:
|
|
415
|
+
export interface BatchWriteOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
416
|
+
go: BatchWriteGo<ResponseType>;
|
|
401
417
|
params: ParamRecord<BulkOptions>;
|
|
402
418
|
}
|
|
403
419
|
|
|
404
420
|
export interface SetRecordActionOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr,IndexCompositeAttributes,TableItem> {
|
|
405
|
-
go:
|
|
421
|
+
go: UpdateRecordGo<Partial<TableItem>, UpdateQueryOptions>;
|
|
406
422
|
params: ParamRecord<UpdateQueryParams>;
|
|
407
423
|
set: SetRecord<A,F,C,S, SetItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
408
424
|
remove: SetRecord<A,F,C,S, Array<keyof SetItem<A,F,C,S>>,IndexCompositeAttributes,TableItem>;
|
|
@@ -414,8 +430,11 @@ export interface SetRecordActionOptions<A extends string, F extends string, C ex
|
|
|
414
430
|
where: WhereClause<A,F,C,S, Item<A,F,C,S,S["attributes"]>,SetRecordActionOptions<A,F,C,S,SetAttr,IndexCompositeAttributes,TableItem>>;
|
|
415
431
|
}
|
|
416
432
|
|
|
417
|
-
export type SetRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr, IndexCompositeAttributes, TableItem> = (properties: SetAttr) =>
|
|
418
|
-
|
|
433
|
+
export type SetRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr, IndexCompositeAttributes, TableItem> = (properties: SetAttr) =>
|
|
434
|
+
SetRecordActionOptions<A,F,C,S, SetAttr, IndexCompositeAttributes, TableItem>;
|
|
435
|
+
|
|
436
|
+
export type RemoveRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, RemoveAttr, IndexCompositeAttributes, TableItem> = (properties: RemoveAttr) =>
|
|
437
|
+
SetRecordActionOptions<A,F,C,S, RemoveAttr, IndexCompositeAttributes, TableItem>;
|
|
419
438
|
|
|
420
439
|
export type DataUpdateMethodRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr, IndexCompositeAttributes, TableItem> =
|
|
421
440
|
DataUpdateMethod<A,F,C,S, UpdateData<A,F,C,S>, SetRecordActionOptions<A,F,C,S, SetAttr, IndexCompositeAttributes, TableItem>>
|
|
@@ -429,7 +448,6 @@ interface QueryOperations<A extends string, F extends string, C extends string,
|
|
|
429
448
|
begins: (skCompositeAttributes: CompositeAttributes) => QueryBranches<A,F,C,S, ResponseItem,IndexCompositeAttributes>;
|
|
430
449
|
go: GoQueryTerminal<A,F,C,S,ResponseItem>;
|
|
431
450
|
params: ParamTerminal<A,F,C,S,ResponseItem>;
|
|
432
|
-
page: PageQueryTerminal<A,F,C,S,ResponseItem,IndexCompositeAttributes>;
|
|
433
451
|
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,QueryBranches<A,F,C,S,ResponseItem,IndexCompositeAttributes>>
|
|
434
452
|
}
|
|
435
453
|
|
|
@@ -465,16 +483,22 @@ export type ParseMultiInput = {
|
|
|
465
483
|
export type ReturnValues = "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
466
484
|
|
|
467
485
|
export interface QueryOptions {
|
|
468
|
-
|
|
486
|
+
cursor?: string | null;
|
|
487
|
+
params?: object;
|
|
469
488
|
table?: string;
|
|
470
489
|
limit?: number;
|
|
471
|
-
params?: object;
|
|
472
|
-
includeKeys?: boolean;
|
|
473
490
|
originalErr?: boolean;
|
|
474
491
|
ignoreOwnership?: boolean;
|
|
475
|
-
pages?: number;
|
|
492
|
+
pages?: number | 'all';
|
|
476
493
|
listeners?: Array<ElectroEventListener>;
|
|
477
494
|
logger?: ElectroEventListener;
|
|
495
|
+
data?: 'raw' | 'includeKeys' | 'attributes';
|
|
496
|
+
|
|
497
|
+
/** @depricated use 'data=raw' instead */
|
|
498
|
+
raw?: boolean;
|
|
499
|
+
/** @depricated use 'data=includeKeys' instead */
|
|
500
|
+
includeKeys?: boolean;
|
|
501
|
+
order?: 'asc' | 'desc';
|
|
478
502
|
}
|
|
479
503
|
|
|
480
504
|
// subset of QueryOptions
|
|
@@ -503,15 +527,12 @@ export interface PutQueryOptions extends QueryOptions {
|
|
|
503
527
|
}
|
|
504
528
|
|
|
505
529
|
export interface ParamOptions {
|
|
530
|
+
cursor?: string | null;
|
|
506
531
|
params?: object;
|
|
507
532
|
table?: string;
|
|
508
533
|
limit?: number;
|
|
509
534
|
response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
export interface PaginationOptions extends QueryOptions {
|
|
513
|
-
pager?: "raw" | "item" | "named";
|
|
514
|
-
limit?: number;
|
|
535
|
+
order?: 'asc' | 'desc';
|
|
515
536
|
}
|
|
516
537
|
|
|
517
538
|
export interface BulkOptions extends QueryOptions {
|
|
@@ -526,11 +547,15 @@ export type OptionalDefaultEntityIdentifiers = {
|
|
|
526
547
|
}
|
|
527
548
|
|
|
528
549
|
interface GoBatchGetTerminalOptions<Attributes> {
|
|
550
|
+
data?: 'raw' | 'includeKeys' | 'attributes';
|
|
551
|
+
/** @depricated use 'data=raw' instead */
|
|
529
552
|
raw?: boolean;
|
|
553
|
+
/** @depricated use 'data=raw' instead */
|
|
554
|
+
includeKeys?: boolean;
|
|
555
|
+
|
|
530
556
|
table?: string;
|
|
531
557
|
limit?: number;
|
|
532
558
|
params?: object;
|
|
533
|
-
includeKeys?: boolean;
|
|
534
559
|
originalErr?: boolean;
|
|
535
560
|
ignoreOwnership?: boolean;
|
|
536
561
|
pages?: number;
|
|
@@ -543,30 +568,22 @@ interface GoBatchGetTerminalOptions<Attributes> {
|
|
|
543
568
|
}
|
|
544
569
|
|
|
545
570
|
interface GoQueryTerminalOptions<Attributes> {
|
|
571
|
+
cursor?: string | null,
|
|
572
|
+
data?: 'raw' | 'includeKeys' | 'attributes';
|
|
573
|
+
/** @depricated use 'data=raw' instead */
|
|
546
574
|
raw?: boolean;
|
|
547
|
-
|
|
548
|
-
limit?: number;
|
|
549
|
-
params?: object;
|
|
575
|
+
/** @depricated use 'data=raw' instead */
|
|
550
576
|
includeKeys?: boolean;
|
|
551
|
-
originalErr?: boolean;
|
|
552
|
-
ignoreOwnership?: boolean;
|
|
553
|
-
pages?: number;
|
|
554
|
-
attributes?: ReadonlyArray<Attributes>;
|
|
555
|
-
listeners?: Array<ElectroEventListener>;
|
|
556
|
-
logger?: ElectroEventListener;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
interface PageQueryTerminalOptions<Attributes> extends GoQueryTerminalOptions<Attributes> {
|
|
560
|
-
pager?: "raw" | "item" | "named";
|
|
561
|
-
raw?: boolean;
|
|
562
577
|
table?: string;
|
|
563
578
|
limit?: number;
|
|
564
|
-
|
|
579
|
+
params?: object;
|
|
565
580
|
originalErr?: boolean;
|
|
566
581
|
ignoreOwnership?: boolean;
|
|
582
|
+
pages?: number | 'all';
|
|
567
583
|
attributes?: ReadonlyArray<Attributes>;
|
|
568
584
|
listeners?: Array<ElectroEventListener>;
|
|
569
585
|
logger?: ElectroEventListener;
|
|
586
|
+
order?: 'asc' | 'desc';
|
|
570
587
|
}
|
|
571
588
|
|
|
572
589
|
export interface ParamTerminalOptions<Attributes> {
|
|
@@ -576,126 +593,108 @@ export interface ParamTerminalOptions<Attributes> {
|
|
|
576
593
|
originalErr?: boolean;
|
|
577
594
|
attributes?: ReadonlyArray<Attributes>;
|
|
578
595
|
response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
596
|
+
order?: 'asc' | 'desc';
|
|
579
597
|
}
|
|
580
598
|
|
|
581
599
|
type GoBatchGetTerminal<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem> = <Options extends GoBatchGetTerminalOptions<keyof ResponseItem>>(options?: Options) =>
|
|
582
600
|
Options extends GoBatchGetTerminalOptions<infer Attr>
|
|
583
601
|
? 'preserveBatchOrder' extends keyof Options
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
Name in keyof ResponseItem as Name extends Attr
|
|
598
|
-
? Name
|
|
599
|
-
: never
|
|
600
|
-
]: ResponseItem[Name]
|
|
601
|
-
}>>, Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>>
|
|
602
|
-
]>
|
|
603
|
-
: Promise<[
|
|
604
|
-
Array<Resolve<{
|
|
602
|
+
? Options['preserveBatchOrder'] extends true
|
|
603
|
+
? Promise<{
|
|
604
|
+
data: Array<Resolve<{
|
|
605
|
+
[
|
|
606
|
+
Name in keyof ResponseItem as Name extends Attr
|
|
607
|
+
? Name
|
|
608
|
+
: never
|
|
609
|
+
]: ResponseItem[Name]
|
|
610
|
+
} | null>>,
|
|
611
|
+
unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>>
|
|
612
|
+
}>
|
|
613
|
+
: Promise<{
|
|
614
|
+
data: Array<Resolve<{
|
|
605
615
|
[
|
|
606
616
|
Name in keyof ResponseItem as Name extends Attr
|
|
607
617
|
? Name
|
|
608
618
|
: never
|
|
609
619
|
]: ResponseItem[Name]
|
|
610
|
-
}>>,
|
|
611
|
-
|
|
620
|
+
}>>,
|
|
621
|
+
unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>>
|
|
622
|
+
}>
|
|
623
|
+
: Promise<{
|
|
624
|
+
data: Array<Resolve<{
|
|
625
|
+
[
|
|
626
|
+
Name in keyof ResponseItem as Name extends Attr
|
|
627
|
+
? Name
|
|
628
|
+
: never
|
|
629
|
+
]: ResponseItem[Name]
|
|
630
|
+
}>>,
|
|
631
|
+
unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>>
|
|
632
|
+
}>
|
|
612
633
|
: 'preserveBatchOrder' extends keyof Options
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
634
|
+
? Options['preserveBatchOrder'] extends true
|
|
635
|
+
? { data: Array<Resolve<ResponseItem | null>>, unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>> }
|
|
636
|
+
: { data: Array<Resolve<ResponseItem>>, unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>> }
|
|
637
|
+
: { data: Array<Resolve<ResponseItem>>, unprocessed: Array<Resolve<AllTableIndexCompositeAttributes<A,F,C,S>>> }
|
|
617
638
|
|
|
618
639
|
type GoGetTerminal<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem> = <Options extends GoQueryTerminalOptions<keyof ResponseItem>>(options?: Options) =>
|
|
619
640
|
Options extends GoQueryTerminalOptions<infer Attr>
|
|
620
641
|
? Promise<{
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
: Promise<ResponseItem | null>
|
|
642
|
+
data: {
|
|
643
|
+
[Name in keyof ResponseItem as Name extends Attr
|
|
644
|
+
? Name
|
|
645
|
+
: never]: ResponseItem[Name]
|
|
646
|
+
} | null
|
|
647
|
+
}>
|
|
648
|
+
: Promise<{ data: ResponseItem | null }>
|
|
628
649
|
|
|
629
650
|
export type GoQueryTerminal<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, Item> = <Options extends GoQueryTerminalOptions<keyof Item>>(options?: Options) =>
|
|
630
651
|
Options extends GoQueryTerminalOptions<infer Attr>
|
|
631
|
-
? Promise<
|
|
632
|
-
|
|
633
|
-
Name in keyof Item as Name extends Attr
|
|
634
|
-
? Name
|
|
635
|
-
: never
|
|
636
|
-
]: Item[Name]
|
|
637
|
-
}>>
|
|
638
|
-
: Promise<Array<Item>>
|
|
639
|
-
|
|
640
|
-
export type EntityParseSingleItem<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem> =
|
|
641
|
-
<Options extends ParseOptions<keyof ResponseItem>>(item: ParseSingleInput, options?: Options) =>
|
|
642
|
-
Options extends ParseOptions<infer Attr>
|
|
643
|
-
? {
|
|
652
|
+
? Promise<{
|
|
653
|
+
data: Array<{
|
|
644
654
|
[
|
|
645
|
-
Name in keyof
|
|
655
|
+
Name in keyof Item as Name extends Attr
|
|
646
656
|
? Name
|
|
647
657
|
: never
|
|
648
|
-
]:
|
|
649
|
-
}
|
|
650
|
-
:
|
|
658
|
+
]: Item[Name]
|
|
659
|
+
}>,
|
|
660
|
+
cursor: string | null
|
|
661
|
+
}>
|
|
662
|
+
: Promise<{ data: Array<Item>, cursor: string | null }>
|
|
651
663
|
|
|
652
664
|
export type EntityParseMultipleItems<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem> =
|
|
653
665
|
<Options extends ParseOptions<keyof ResponseItem>>(item: ParseMultiInput, options?: Options) =>
|
|
654
666
|
Options extends ParseOptions<infer Attr>
|
|
655
|
-
?
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
667
|
+
? {
|
|
668
|
+
data: Array<{
|
|
669
|
+
[
|
|
670
|
+
Name in keyof ResponseItem as Name extends Attr
|
|
671
|
+
? Name
|
|
672
|
+
: never
|
|
673
|
+
]: ResponseItem[Name]
|
|
674
|
+
}>,
|
|
675
|
+
cursor?: string | null
|
|
676
|
+
}
|
|
677
|
+
: { data: Array<ResponseItem>, cursor?: string | null }
|
|
663
678
|
|
|
679
|
+
export type ParamTerminal<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseItem> = <P extends any = any, Options extends ParamTerminalOptions<keyof ResponseItem> = ParamTerminalOptions<keyof ResponseItem>>(options?: Options) => P;
|
|
664
680
|
|
|
665
|
-
export type
|
|
666
|
-
Options extends GoQueryTerminalOptions<infer Attr>
|
|
667
|
-
? Promise<[
|
|
668
|
-
(CompositeAttributes & OptionalDefaultEntityIdentifiers) | null,
|
|
669
|
-
Array<{
|
|
670
|
-
[
|
|
671
|
-
Name in keyof Item as Name extends Attr
|
|
672
|
-
? Name
|
|
673
|
-
: never
|
|
674
|
-
]: Item[Name]
|
|
675
|
-
}>
|
|
676
|
-
]>
|
|
677
|
-
: Promise<[
|
|
678
|
-
(CompositeAttributes & OptionalDefaultEntityIdentifiers) | null,
|
|
679
|
-
Array<ResponseType>
|
|
680
|
-
]>;
|
|
681
|
+
export type ServiceQueryRecordsGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{ data: T, cursor: string | null }>;
|
|
681
682
|
|
|
682
|
-
export type
|
|
683
|
+
export type QueryRecordsGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{ data: T, cursor: string | null }>;
|
|
683
684
|
|
|
684
|
-
export type
|
|
685
|
+
export type UpdateRecordGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{ data: T }>;
|
|
685
686
|
|
|
686
|
-
export type
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
? Options['preserveBatchOrder'] extends true
|
|
690
|
-
? Promise<AlternateResponseType>
|
|
691
|
-
: Promise<ResponseType>
|
|
692
|
-
: Promise<ResponseType>
|
|
693
|
-
: never
|
|
687
|
+
export type PutRecordGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{ data: T }>;
|
|
688
|
+
|
|
689
|
+
export type DeleteRecordOperationGo<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<{ data: T }>;
|
|
694
690
|
|
|
695
|
-
export type
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
691
|
+
export type BatchWriteGo<ResponseType> = <O extends BulkOptions>(options?: O) =>
|
|
692
|
+
Promise<{ unprocessed: ResponseType }>
|
|
693
|
+
|
|
694
|
+
// export type PageRecord<ResponseType, CompositeAttributes> = (page?: (CompositeAttributes & OptionalDefaultEntityIdentifiers) | null, options?: PaginationOptions) => Promise<[
|
|
695
|
+
// (CompositeAttributes & OptionalDefaultEntityIdentifiers) | null,
|
|
696
|
+
// ResponseType
|
|
697
|
+
// ]>;
|
|
699
698
|
|
|
700
699
|
export type ParamRecord<Options = ParamOptions> = <P>(options?: Options) => P;
|
|
701
700
|
|
|
@@ -782,6 +781,10 @@ export interface BooleanAttribute {
|
|
|
782
781
|
readonly field?: string;
|
|
783
782
|
readonly label?: string;
|
|
784
783
|
readonly watch?: ReadonlyArray<string> | "*";
|
|
784
|
+
readonly padding?: {
|
|
785
|
+
length: number;
|
|
786
|
+
char: string;
|
|
787
|
+
}
|
|
785
788
|
}
|
|
786
789
|
|
|
787
790
|
export interface NestedNumberAttribute {
|
|
@@ -808,6 +811,10 @@ export interface NumberAttribute {
|
|
|
808
811
|
readonly field?: string;
|
|
809
812
|
readonly label?: string;
|
|
810
813
|
readonly watch?: ReadonlyArray<string> | "*";
|
|
814
|
+
readonly padding?: {
|
|
815
|
+
length: number;
|
|
816
|
+
char: string;
|
|
817
|
+
}
|
|
811
818
|
}
|
|
812
819
|
|
|
813
820
|
export interface NestedStringAttribute {
|
|
@@ -834,6 +841,10 @@ export interface StringAttribute {
|
|
|
834
841
|
readonly field?: string;
|
|
835
842
|
readonly label?: string;
|
|
836
843
|
readonly watch?: ReadonlyArray<string> | "*";
|
|
844
|
+
readonly padding?: {
|
|
845
|
+
length: number;
|
|
846
|
+
char: string;
|
|
847
|
+
}
|
|
837
848
|
}
|
|
838
849
|
|
|
839
850
|
export interface NestedEnumAttribute {
|
|
@@ -1854,13 +1865,15 @@ export class Entity<A extends string, F extends string, C extends string, S exte
|
|
|
1854
1865
|
|
|
1855
1866
|
get(key: AllTableIndexCompositeAttributes<A,F,C,S>): SingleRecordOperationOptions<A,F,C,S, ResponseItem<A,F,C,S>>;
|
|
1856
1867
|
get(key: AllTableIndexCompositeAttributes<A,F,C,S>[]): BatchGetRecordOperationOptions<A,F,C,S, ResponseItem<A,F,C,S>>;
|
|
1868
|
+
|
|
1857
1869
|
delete(key: AllTableIndexCompositeAttributes<A,F,C,S>): DeleteRecordOperationOptions<A,F,C,S, ResponseItem<A,F,C,S>>;
|
|
1858
|
-
delete(key: AllTableIndexCompositeAttributes<A,F,C,S>[]):
|
|
1870
|
+
delete(key: AllTableIndexCompositeAttributes<A,F,C,S>[]): BatchWriteOperationOptions<A,F,C,S, AllTableIndexCompositeAttributes<A,F,C,S>[]>;
|
|
1871
|
+
remove(key: AllTableIndexCompositeAttributes<A,F,C,S>): DeleteRecordOperationOptions<A,F,C,S, ResponseItem<A,F,C,S>>
|
|
1859
1872
|
|
|
1860
1873
|
put(record: PutItem<A,F,C,S>): PutRecordOperationOptions<A,F,C,S, ResponseItem<A,F,C,S>>;
|
|
1861
|
-
put(record: PutItem<A,F,C,S>[]):
|
|
1874
|
+
put(record: PutItem<A,F,C,S>[]): BatchWriteOperationOptions<A,F,C,S, AllTableIndexCompositeAttributes<A,F,C,S>[]>;
|
|
1875
|
+
create(record: PutItem<A,F,C,S>): PutRecordOperationOptions<A,F,C,S, ResponseItem<A,F,C,S>>
|
|
1862
1876
|
|
|
1863
|
-
remove(key: AllTableIndexCompositeAttributes<A,F,C,S>): DeleteRecordOperationOptions<A,F,C,S, ResponseItem<A,F,C,S>>
|
|
1864
1877
|
update(key: AllTableIndexCompositeAttributes<A,F,C,S>): {
|
|
1865
1878
|
set: SetRecord<A,F,C,S, SetItem<A,F,C,S>, TableIndexCompositeAttributes<A,F,C,S>, ResponseItem<A,F,C,S>>;
|
|
1866
1879
|
remove: RemoveRecord<A,F,C,S, RemoveItem<A,F,C,S>, TableIndexCompositeAttributes<A,F,C,S>, ResponseItem<A,F,C,S>>;
|
|
@@ -1870,7 +1883,6 @@ export class Entity<A extends string, F extends string, C extends string, S exte
|
|
|
1870
1883
|
delete: SetRecord<A,F,C,S, DeleteItem<A,F,C,S>, TableIndexCompositeAttributes<A,F,C,S>, ResponseItem<A,F,C,S>>;
|
|
1871
1884
|
data: DataUpdateMethodRecord<A,F,C,S, Item<A,F,C,S,S["attributes"]>, TableIndexCompositeAttributes<A,F,C,S>, ResponseItem<A,F,C,S>>;
|
|
1872
1885
|
};
|
|
1873
|
-
|
|
1874
1886
|
patch(key: AllTableIndexCompositeAttributes<A,F,C,S>): {
|
|
1875
1887
|
set: SetRecord<A,F,C,S, SetItem<A,F,C,S>, TableIndexCompositeAttributes<A,F,C,S>, ResponseItem<A,F,C,S>>;
|
|
1876
1888
|
remove: RemoveRecord<A,F,C,S, RemoveItem<A,F,C,S>, TableIndexCompositeAttributes<A,F,C,S>, ResponseItem<A,F,C,S>>;
|
|
@@ -1881,7 +1893,6 @@ export class Entity<A extends string, F extends string, C extends string, S exte
|
|
|
1881
1893
|
data: DataUpdateMethodRecord<A,F,C,S, Item<A,F,C,S,S["attributes"]>, TableIndexCompositeAttributes<A,F,C,S>, ResponseItem<A,F,C,S>>;
|
|
1882
1894
|
};
|
|
1883
1895
|
|
|
1884
|
-
create(record: PutItem<A,F,C,S>): PutRecordOperationOptions<A,F,C,S, ResponseItem<A,F,C,S>>
|
|
1885
1896
|
|
|
1886
1897
|
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>>;
|
|
1887
1898
|
|
|
@@ -1893,23 +1904,25 @@ export class Entity<A extends string, F extends string, C extends string, S exte
|
|
|
1893
1904
|
parse<Options extends ParseOptions<keyof ResponseItem<A,F,C,S>>>(item: ParseSingleInput, options?: Options):
|
|
1894
1905
|
Options extends ParseOptions<infer Attr>
|
|
1895
1906
|
? {
|
|
1907
|
+
data: {
|
|
1896
1908
|
[
|
|
1897
1909
|
Name in keyof ResponseItem<A,F,C,S> as Name extends Attr
|
|
1898
1910
|
? Name
|
|
1899
1911
|
: never
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1912
|
+
]: ResponseItem<A,F,C,S>[Name]
|
|
1913
|
+
} | null
|
|
1914
|
+
}
|
|
1915
|
+
: { data: ResponseItem<A,F,C,S> | null }
|
|
1903
1916
|
parse<Options extends ParseOptions<keyof ResponseItem<A,F,C,S>>>(item: ParseMultiInput, options?: Options):
|
|
1904
1917
|
Options extends ParseOptions<infer Attr>
|
|
1905
|
-
? Array<{
|
|
1918
|
+
? { data: Array<{
|
|
1906
1919
|
[
|
|
1907
1920
|
Name in keyof ResponseItem<A,F,C,S> as Name extends Attr
|
|
1908
1921
|
? Name
|
|
1909
1922
|
: never
|
|
1910
1923
|
]: ResponseItem<A,F,C,S>[Name]
|
|
1911
|
-
}
|
|
1912
|
-
: Array<ResponseItem<A,F,C,S
|
|
1924
|
+
}>, cursor: string | null }
|
|
1925
|
+
: { data: Array<ResponseItem<A,F,C,S>>, cursor: string | null }
|
|
1913
1926
|
setIdentifier(type: "entity" | "version", value: string): void;
|
|
1914
1927
|
client: any;
|
|
1915
1928
|
}
|