@webiny/db-dynamodb 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
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/DynamoDbDriver.d.ts +18 -32
- package/DynamoDbDriver.js +215 -261
- package/DynamoDbDriver.js.map +1 -1
- package/README.md +6 -62
- package/exports/api/db.d.ts +2 -0
- package/exports/api/db.js +2 -0
- package/feature/FilterUtil/FilterUtil.d.ts +11 -0
- package/feature/FilterUtil/FilterUtil.js +26 -0
- package/feature/FilterUtil/FilterUtil.js.map +1 -0
- package/feature/FilterUtil/abstractions/FilterUtil.d.ts +17 -0
- package/feature/FilterUtil/abstractions/FilterUtil.js +5 -0
- package/feature/FilterUtil/abstractions/FilterUtil.js.map +1 -0
- package/feature/FilterUtil/createFilters.d.ts +22 -0
- package/feature/FilterUtil/createFilters.js +92 -0
- package/feature/FilterUtil/createFilters.js.map +1 -0
- package/feature/FilterUtil/extractWhereArgs.d.ts +7 -0
- package/feature/FilterUtil/extractWhereArgs.js +20 -0
- package/feature/FilterUtil/extractWhereArgs.js.map +1 -0
- package/feature/FilterUtil/feature.d.ts +4 -0
- package/feature/FilterUtil/feature.js +11 -0
- package/feature/FilterUtil/feature.js.map +1 -0
- package/feature/FilterUtil/index.d.ts +2 -0
- package/feature/FilterUtil/index.js +2 -0
- package/feature/ValueFilter/ValueFilterRegistry.d.ts +12 -0
- package/feature/ValueFilter/ValueFilterRegistry.js +27 -0
- package/feature/ValueFilter/ValueFilterRegistry.js.map +1 -0
- package/feature/ValueFilter/abstractions/ValueFilter.d.ts +22 -0
- package/feature/ValueFilter/abstractions/ValueFilter.js +5 -0
- package/feature/ValueFilter/abstractions/ValueFilter.js.map +1 -0
- package/feature/ValueFilter/abstractions/ValueFilterRegistry.d.ts +10 -0
- package/feature/ValueFilter/abstractions/ValueFilterRegistry.js +5 -0
- package/feature/ValueFilter/abstractions/ValueFilterRegistry.js.map +1 -0
- package/feature/ValueFilter/feature.d.ts +4 -0
- package/feature/ValueFilter/feature.js +33 -0
- package/feature/ValueFilter/feature.js.map +1 -0
- package/feature/ValueFilter/filters/AndInFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/AndInFilter.js +28 -0
- package/feature/ValueFilter/filters/AndInFilter.js.map +1 -0
- package/feature/ValueFilter/filters/BetweenFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/BetweenFilter.js +31 -0
- package/feature/ValueFilter/filters/BetweenFilter.js.map +1 -0
- package/feature/ValueFilter/filters/ContainsFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/ContainsFilter.js +42 -0
- package/feature/ValueFilter/filters/ContainsFilter.js.map +1 -0
- package/feature/ValueFilter/filters/EqFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/EqFilter.js +24 -0
- package/feature/ValueFilter/filters/EqFilter.js.map +1 -0
- package/feature/ValueFilter/filters/FuzzyFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/FuzzyFilter.js +37 -0
- package/feature/ValueFilter/filters/FuzzyFilter.js.map +1 -0
- package/feature/ValueFilter/filters/GtFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/GtFilter.js +22 -0
- package/feature/ValueFilter/filters/GtFilter.js.map +1 -0
- package/feature/ValueFilter/filters/GteFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/GteFilter.js +22 -0
- package/feature/ValueFilter/filters/GteFilter.js.map +1 -0
- package/feature/ValueFilter/filters/InFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/InFilter.js +28 -0
- package/feature/ValueFilter/filters/InFilter.js.map +1 -0
- package/feature/ValueFilter/filters/LtFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/LtFilter.js +22 -0
- package/feature/ValueFilter/filters/LtFilter.js.map +1 -0
- package/feature/ValueFilter/filters/LteFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/LteFilter.js +22 -0
- package/feature/ValueFilter/filters/LteFilter.js.map +1 -0
- package/feature/ValueFilter/filters/StartsWithFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/StartsWithFilter.js +29 -0
- package/feature/ValueFilter/filters/StartsWithFilter.js.map +1 -0
- package/feature/ValueFilter/index.d.ts +3 -0
- package/feature/ValueFilter/index.js +3 -0
- package/index.d.ts +5 -1
- package/index.js +12 -14
- package/index.js.map +1 -1
- package/package.json +32 -30
- package/plugins/definitions/DateTimeTransformPlugin.d.ts +2 -1
- package/plugins/definitions/DateTimeTransformPlugin.js +21 -50
- package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/FieldPlugin.d.ts +2 -2
- package/plugins/definitions/FieldPlugin.js +36 -68
- package/plugins/definitions/FieldPlugin.js.map +1 -1
- package/plugins/definitions/TimeTransformPlugin.d.ts +2 -1
- package/plugins/definitions/TimeTransformPlugin.js +29 -56
- package/plugins/definitions/TimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/ValueTransformPlugin.d.ts +2 -7
- package/plugins/definitions/ValueTransformPlugin.js +20 -46
- package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
- package/plugins/definitions/assignFields.js +15 -34
- package/plugins/definitions/assignFields.js.map +1 -1
- package/plugins/index.d.ts +5 -2
- package/plugins/index.js +5 -19
- package/store/entity.d.ts +6 -0
- package/store/entity.js +8 -0
- package/store/entity.js.map +1 -0
- package/store/keys.d.ts +6 -0
- package/store/keys.js +9 -0
- package/store/keys.js.map +1 -0
- package/store/types.d.ts +6 -0
- package/store/types.js +0 -0
- package/toolbox.d.ts +60 -0
- package/toolbox.js +1 -0
- package/types.d.ts +10 -23
- package/types.js +0 -5
- package/utils/batch/batchRead.d.ts +15 -0
- package/utils/batch/batchRead.js +45 -0
- package/utils/batch/batchRead.js.map +1 -0
- package/utils/batch/batchWrite.d.ts +13 -0
- package/utils/batch/batchWrite.js +39 -0
- package/utils/batch/batchWrite.js.map +1 -0
- package/utils/batch/index.d.ts +3 -0
- package/utils/batch/index.js +3 -0
- package/utils/batch/types.d.ts +30 -0
- package/utils/batch/types.js +0 -0
- package/utils/cleanup.d.ts +3 -3
- package/utils/cleanup.js +36 -41
- package/utils/cleanup.js.map +1 -1
- package/utils/count.d.ts +2 -0
- package/utils/count.js +11 -0
- package/utils/count.js.map +1 -0
- package/utils/createEntity.d.ts +36 -0
- package/utils/createEntity.js +82 -0
- package/utils/createEntity.js.map +1 -0
- package/utils/createTable.d.ts +11 -0
- package/utils/createTable.js +29 -0
- package/utils/createTable.js.map +1 -0
- package/utils/cursor.js +8 -23
- package/utils/cursor.js.map +1 -1
- package/utils/delete.d.ts +10 -0
- package/utils/delete.js +9 -0
- package/utils/delete.js.map +1 -0
- package/utils/entity/Entity.d.ts +28 -0
- package/utils/entity/Entity.js +95 -0
- package/utils/entity/Entity.js.map +1 -0
- package/utils/entity/EntityReadBatch.d.ts +18 -0
- package/utils/entity/EntityReadBatch.js +31 -0
- package/utils/entity/EntityReadBatch.js.map +1 -0
- package/utils/entity/EntityReadBatchBuilder.d.ts +10 -0
- package/utils/entity/EntityReadBatchBuilder.js +18 -0
- package/utils/entity/EntityReadBatchBuilder.js.map +1 -0
- package/utils/entity/EntityWriteBatch.d.ts +23 -0
- package/utils/entity/EntityWriteBatch.js +44 -0
- package/utils/entity/EntityWriteBatch.js.map +1 -0
- package/utils/entity/EntityWriteBatchBuilder.d.ts +11 -0
- package/utils/entity/EntityWriteBatchBuilder.js +19 -0
- package/utils/entity/EntityWriteBatchBuilder.js.map +1 -0
- package/utils/entity/getEntity.d.ts +4 -0
- package/utils/entity/getEntity.js +11 -0
- package/utils/entity/getEntity.js.map +1 -0
- package/utils/entity/index.d.ts +7 -0
- package/utils/entity/index.js +7 -0
- package/utils/entity/types.d.ts +75 -0
- package/utils/entity/types.js +0 -0
- package/utils/get.d.ts +8 -6
- package/utils/get.js +15 -28
- package/utils/get.js.map +1 -1
- package/utils/index.d.ts +13 -0
- package/utils/index.js +13 -0
- package/utils/put.d.ts +12 -0
- package/utils/put.js +10 -0
- package/utils/put.js.map +1 -0
- package/utils/query.d.ts +20 -14
- package/utils/query.js +84 -108
- package/utils/query.js.map +1 -1
- package/utils/scan.d.ts +38 -0
- package/utils/scan.js +56 -0
- package/utils/scan.js.map +1 -0
- package/utils/sort.d.ts +1 -1
- package/utils/sort.js +38 -84
- package/utils/sort.js.map +1 -1
- package/utils/table/Table.d.ts +10 -0
- package/utils/table/Table.js +28 -0
- package/utils/table/Table.js.map +1 -0
- package/utils/table/TableReadBatch.d.ts +19 -0
- package/utils/table/TableReadBatch.js +46 -0
- package/utils/table/TableReadBatch.js.map +1 -0
- package/utils/table/TableWriteBatch.d.ts +21 -0
- package/utils/table/TableWriteBatch.js +52 -0
- package/utils/table/TableWriteBatch.js.map +1 -0
- package/utils/table/index.d.ts +4 -0
- package/utils/table/index.js +4 -0
- package/utils/table/types.d.ts +39 -0
- package/utils/table/types.js +0 -0
- package/BatchProcess.d.ts +0 -47
- package/BatchProcess.js +0 -198
- package/BatchProcess.js.map +0 -1
- package/QueryGenerator.d.ts +0 -21
- package/QueryGenerator.js +0 -78
- package/QueryGenerator.js.map +0 -1
- package/operators/comparison/beginsWith.d.ts +0 -3
- package/operators/comparison/beginsWith.js +0 -24
- package/operators/comparison/beginsWith.js.map +0 -1
- package/operators/comparison/between.d.ts +0 -3
- package/operators/comparison/between.js +0 -30
- package/operators/comparison/between.js.map +0 -1
- package/operators/comparison/eq.d.ts +0 -3
- package/operators/comparison/eq.js +0 -34
- package/operators/comparison/eq.js.map +0 -1
- package/operators/comparison/gt.d.ts +0 -3
- package/operators/comparison/gt.js +0 -24
- package/operators/comparison/gt.js.map +0 -1
- package/operators/comparison/gte.d.ts +0 -3
- package/operators/comparison/gte.js +0 -24
- package/operators/comparison/gte.js.map +0 -1
- package/operators/comparison/lt.d.ts +0 -3
- package/operators/comparison/lt.js +0 -24
- package/operators/comparison/lt.js.map +0 -1
- package/operators/comparison/lte.d.ts +0 -3
- package/operators/comparison/lte.js +0 -24
- package/operators/comparison/lte.js.map +0 -1
- package/operators/index.d.ts +0 -12
- package/operators/index.js +0 -39
- package/operators/index.js.map +0 -1
- package/operators/logical/and.d.ts +0 -3
- package/operators/logical/and.js +0 -63
- package/operators/logical/and.js.map +0 -1
- package/operators/logical/or.d.ts +0 -3
- package/operators/logical/or.js +0 -63
- package/operators/logical/or.js.map +0 -1
- package/plugins/definitions/AttributePlugin.d.ts +0 -20
- package/plugins/definitions/AttributePlugin.js +0 -61
- package/plugins/definitions/AttributePlugin.js.map +0 -1
- package/plugins/definitions/FieldPathPlugin.d.ts +0 -22
- package/plugins/definitions/FieldPathPlugin.js +0 -46
- package/plugins/definitions/FieldPathPlugin.js.map +0 -1
- package/plugins/definitions/NumberTransformPlugin.d.ts +0 -4
- package/plugins/definitions/NumberTransformPlugin.js +0 -45
- package/plugins/definitions/NumberTransformPlugin.js.map +0 -1
- package/plugins/definitions/ValueFilterPlugin.d.ts +0 -20
- package/plugins/definitions/ValueFilterPlugin.js +0 -49
- package/plugins/definitions/ValueFilterPlugin.js.map +0 -1
- package/plugins/filters/andIn.d.ts +0 -3
- package/plugins/filters/andIn.js +0 -35
- package/plugins/filters/andIn.js.map +0 -1
- package/plugins/filters/between.d.ts +0 -3
- package/plugins/filters/between.js +0 -36
- package/plugins/filters/between.js.map +0 -1
- package/plugins/filters/contains.d.ts +0 -3
- package/plugins/filters/contains.js +0 -32
- package/plugins/filters/contains.js.map +0 -1
- package/plugins/filters/eq.d.ts +0 -3
- package/plugins/filters/eq.js +0 -33
- package/plugins/filters/eq.js.map +0 -1
- package/plugins/filters/fuzzy.d.ts +0 -3
- package/plugins/filters/fuzzy.js +0 -30
- package/plugins/filters/fuzzy.js.map +0 -1
- package/plugins/filters/gt.d.ts +0 -3
- package/plugins/filters/gt.js +0 -20
- package/plugins/filters/gt.js.map +0 -1
- package/plugins/filters/gte.d.ts +0 -3
- package/plugins/filters/gte.js +0 -20
- package/plugins/filters/gte.js.map +0 -1
- package/plugins/filters/in.d.ts +0 -3
- package/plugins/filters/in.js +0 -35
- package/plugins/filters/in.js.map +0 -1
- package/plugins/filters/index.d.ts +0 -2
- package/plugins/filters/index.js +0 -34
- package/plugins/filters/index.js.map +0 -1
- package/plugins/filters/lt.d.ts +0 -3
- package/plugins/filters/lt.js +0 -20
- package/plugins/filters/lt.js.map +0 -1
- package/plugins/filters/lte.d.ts +0 -3
- package/plugins/filters/lte.js +0 -20
- package/plugins/filters/lte.js.map +0 -1
- package/plugins/filters/startsWith.d.ts +0 -3
- package/plugins/filters/startsWith.js +0 -33
- package/plugins/filters/startsWith.js.map +0 -1
- package/plugins/index.js.map +0 -1
- package/statements/createKeyConditionExpressionArgs.d.ts +0 -15
- package/statements/createKeyConditionExpressionArgs.js +0 -52
- package/statements/createKeyConditionExpressionArgs.js.map +0 -1
- package/statements/processStatement.d.ts +0 -3
- package/statements/processStatement.js +0 -42
- package/statements/processStatement.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/attributes.d.ts +0 -10
- package/utils/attributes.js +0 -31
- package/utils/attributes.js.map +0 -1
- package/utils/batchRead.d.ts +0 -15
- package/utils/batchRead.js +0 -89
- package/utils/batchRead.js.map +0 -1
- package/utils/batchWrite.d.ts +0 -17
- package/utils/batchWrite.js +0 -30
- package/utils/batchWrite.js.map +0 -1
- package/utils/filter.d.ts +0 -12
- package/utils/filter.js +0 -213
- package/utils/filter.js.map +0 -1
- package/utils/listResponse.d.ts +0 -13
- package/utils/listResponse.js +0 -33
- package/utils/listResponse.js.map +0 -1
- package/utils/table.d.ts +0 -7
- package/utils/table.js +0 -27
- package/utils/table.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Entity } from "../toolbox.js";
|
|
2
|
+
export interface IDeleteItemKeys {
|
|
3
|
+
PK: string;
|
|
4
|
+
SK: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IDeleteItemParams {
|
|
7
|
+
entity: Entity;
|
|
8
|
+
keys: IDeleteItemKeys;
|
|
9
|
+
}
|
|
10
|
+
export declare const deleteItem: (params: IDeleteItemParams) => Promise<import("@aws-sdk/lib-dynamodb").DeleteCommandOutput>;
|
package/utils/delete.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/delete.js","sources":["../../src/utils/delete.ts"],"sourcesContent":["import type { Entity } from \"~/toolbox.js\";\nexport interface IDeleteItemKeys {\n PK: string;\n SK: string;\n}\nexport interface IDeleteItemParams {\n entity: Entity;\n keys: IDeleteItemKeys;\n}\n\nexport const deleteItem = async (params: IDeleteItemParams) => {\n const { entity, keys } = params;\n\n return await entity.delete(keys, {\n execute: true\n });\n};\n"],"names":["deleteItem","params","entity","keys"],"mappings":"AAUO,MAAMA,aAAa,OAAOC;IAC7B,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGF;IAEzB,OAAO,MAAMC,OAAO,MAAM,CAACC,MAAM;QAC7B,SAAS;IACb;AACJ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AttributeDefinitions, EntityConstructor as BaseEntityConstructor, Readonly, TableDef } from "../../toolbox.js";
|
|
2
|
+
import { Entity as BaseEntity } from "../../toolbox.js";
|
|
3
|
+
import type { ITableWriteBatch } from "../table/types.js";
|
|
4
|
+
import type { IEntity, IEntityCreateEntityReaderParams, IEntityCreateEntityWriterParams, IEntityDeleteResult, IEntityGetCleanResult, IEntityGetResult, IEntityPutResult, IEntityQueryAllCleanResult, IEntityQueryAllParams, IEntityQueryAllResult, IEntityQueryOneCleanResult, IEntityQueryOneParams, IEntityQueryOneResult, IEntityQueryPerPageParams, IEntityReadBatch, IEntityWriteBatch } from "./types.js";
|
|
5
|
+
import type { IPutParamsItem } from "../put.js";
|
|
6
|
+
import type { GetRecordParamsKeys } from "../get.js";
|
|
7
|
+
import type { IDeleteItemKeys } from "../delete.js";
|
|
8
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
9
|
+
export type EntityConstructor<T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>> = BaseEntityConstructor<T>;
|
|
10
|
+
export declare class Entity<T extends GenericRecord = GenericRecord> implements IEntity<T> {
|
|
11
|
+
readonly entity: BaseEntity;
|
|
12
|
+
get name(): string;
|
|
13
|
+
get table(): TableDef;
|
|
14
|
+
constructor(params: EntityConstructor);
|
|
15
|
+
createEntityReader(params?: IEntityCreateEntityReaderParams): IEntityReadBatch<T>;
|
|
16
|
+
createEntityWriter(params?: IEntityCreateEntityWriterParams): IEntityWriteBatch<T>;
|
|
17
|
+
createTableWriter(): ITableWriteBatch;
|
|
18
|
+
put<T extends GenericRecord = GenericRecord>(item: IPutParamsItem<T>): IEntityPutResult;
|
|
19
|
+
get<T>(keys: GetRecordParamsKeys): IEntityGetResult<T>;
|
|
20
|
+
getClean<T>(keys: GetRecordParamsKeys): IEntityGetCleanResult<T>;
|
|
21
|
+
delete(keys: IDeleteItemKeys): IEntityDeleteResult;
|
|
22
|
+
queryOne<T>(params: IEntityQueryOneParams): IEntityQueryOneResult<T>;
|
|
23
|
+
queryOneClean<T>(params: IEntityQueryOneParams): IEntityQueryOneCleanResult<T>;
|
|
24
|
+
queryAll<T>(params: IEntityQueryAllParams): IEntityQueryAllResult<T>;
|
|
25
|
+
queryAllClean<T>(params: IEntityQueryAllParams): IEntityQueryAllCleanResult<T>;
|
|
26
|
+
queryPerPage<T>(params: IEntityQueryPerPageParams): Promise<import("../query.js").IQueryPageResponse<T>>;
|
|
27
|
+
}
|
|
28
|
+
export declare const createEntity: <T extends GenericRecord = GenericRecord>(params: EntityConstructor) => IEntity<T>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Entity } from "../../toolbox.js";
|
|
2
|
+
import { put } from "../put.js";
|
|
3
|
+
import { get, getClean } from "../get.js";
|
|
4
|
+
import { deleteItem } from "../delete.js";
|
|
5
|
+
import { createEntityReadBatch } from "./EntityReadBatch.js";
|
|
6
|
+
import { createEntityWriteBatch } from "./EntityWriteBatch.js";
|
|
7
|
+
import { createTableWriteBatch } from "../table/TableWriteBatch.js";
|
|
8
|
+
import { queryAll, queryAllClean, queryOne, queryOneClean, queryPerPage } from "../query.js";
|
|
9
|
+
class Entity_Entity {
|
|
10
|
+
get name() {
|
|
11
|
+
return this.entity.name;
|
|
12
|
+
}
|
|
13
|
+
get table() {
|
|
14
|
+
return this.entity.table;
|
|
15
|
+
}
|
|
16
|
+
constructor(params){
|
|
17
|
+
this.entity = new Entity(params);
|
|
18
|
+
}
|
|
19
|
+
createEntityReader(params) {
|
|
20
|
+
return createEntityReadBatch({
|
|
21
|
+
entity: this.entity,
|
|
22
|
+
read: params?.read
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
createEntityWriter(params) {
|
|
26
|
+
return createEntityWriteBatch({
|
|
27
|
+
entity: this.entity,
|
|
28
|
+
put: params?.put,
|
|
29
|
+
delete: params?.delete
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
createTableWriter() {
|
|
33
|
+
return createTableWriteBatch({
|
|
34
|
+
table: this.entity.table
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async put(item) {
|
|
38
|
+
return put({
|
|
39
|
+
entity: this.entity,
|
|
40
|
+
item
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async get(keys) {
|
|
44
|
+
return get({
|
|
45
|
+
entity: this.entity,
|
|
46
|
+
keys
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async getClean(keys) {
|
|
50
|
+
return getClean({
|
|
51
|
+
entity: this.entity,
|
|
52
|
+
keys
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async delete(keys) {
|
|
56
|
+
return deleteItem({
|
|
57
|
+
entity: this.entity,
|
|
58
|
+
keys
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async queryOne(params) {
|
|
62
|
+
return queryOne({
|
|
63
|
+
...params,
|
|
64
|
+
entity: this.entity
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async queryOneClean(params) {
|
|
68
|
+
return queryOneClean({
|
|
69
|
+
...params,
|
|
70
|
+
entity: this.entity
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async queryAll(params) {
|
|
74
|
+
return queryAll({
|
|
75
|
+
...params,
|
|
76
|
+
entity: this.entity
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async queryAllClean(params) {
|
|
80
|
+
return queryAllClean({
|
|
81
|
+
...params,
|
|
82
|
+
entity: this.entity
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async queryPerPage(params) {
|
|
86
|
+
return queryPerPage({
|
|
87
|
+
...params,
|
|
88
|
+
entity: this.entity
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const createEntity = (params)=>new Entity_Entity(params);
|
|
93
|
+
export { Entity_Entity as Entity, createEntity };
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=Entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/entity/Entity.js","sources":["../../../src/utils/entity/Entity.ts"],"sourcesContent":["import type {\n AttributeDefinitions,\n EntityConstructor as BaseEntityConstructor,\n Readonly,\n TableDef\n} from \"~/toolbox.js\";\nimport { Entity as BaseEntity } from \"~/toolbox.js\";\nimport type { ITableWriteBatch } from \"../table/types.js\";\nimport type {\n IEntity,\n IEntityCreateEntityReaderParams,\n IEntityCreateEntityWriterParams,\n IEntityDeleteResult,\n IEntityGetCleanResult,\n IEntityGetResult,\n IEntityPutResult,\n IEntityQueryAllCleanResult,\n IEntityQueryAllParams,\n IEntityQueryAllResult,\n IEntityQueryOneCleanResult,\n IEntityQueryOneParams,\n IEntityQueryOneResult,\n IEntityQueryPerPageParams,\n IEntityReadBatch,\n IEntityWriteBatch\n} from \"./types.js\";\nimport type { IPutParamsItem } from \"../put.js\";\nimport { put } from \"../put.js\";\nimport type { GetRecordParamsKeys } from \"../get.js\";\nimport { get, getClean } from \"../get.js\";\nimport type { IDeleteItemKeys } from \"../delete.js\";\nimport { deleteItem } from \"../delete.js\";\nimport { createEntityReadBatch } from \"./EntityReadBatch.js\";\nimport { createEntityWriteBatch } from \"./EntityWriteBatch.js\";\nimport { createTableWriteBatch } from \"~/utils/table/TableWriteBatch.js\";\nimport { queryAll, queryAllClean, queryOne, queryOneClean, queryPerPage } from \"../query.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport type EntityConstructor<\n T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>\n> = BaseEntityConstructor<T>;\n\nexport class Entity<T extends GenericRecord = GenericRecord> implements IEntity<T> {\n public readonly entity: BaseEntity;\n\n public get name(): string {\n return this.entity.name;\n }\n\n public get table(): TableDef {\n /**\n * Not possible to be undefined.\n */\n return this.entity.table!;\n }\n\n public constructor(params: EntityConstructor) {\n // @ts-expect-error\n this.entity = new BaseEntity(params);\n }\n\n public createEntityReader(params?: IEntityCreateEntityReaderParams): IEntityReadBatch<T> {\n return createEntityReadBatch({\n entity: this.entity,\n read: params?.read\n });\n }\n\n public createEntityWriter(params?: IEntityCreateEntityWriterParams): IEntityWriteBatch<T> {\n return createEntityWriteBatch({\n entity: this.entity,\n put: params?.put,\n delete: params?.delete\n });\n }\n\n public createTableWriter(): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.entity.table as TableDef\n });\n }\n\n public async put<T extends GenericRecord = GenericRecord>(\n item: IPutParamsItem<T>\n ): IEntityPutResult {\n return put({\n entity: this.entity,\n item\n });\n }\n\n public async get<T>(keys: GetRecordParamsKeys): IEntityGetResult<T> {\n return get<T>({\n entity: this.entity,\n keys\n });\n }\n\n public async getClean<T>(keys: GetRecordParamsKeys): IEntityGetCleanResult<T> {\n return getClean<T>({\n entity: this.entity,\n keys\n });\n }\n\n public async delete(keys: IDeleteItemKeys): IEntityDeleteResult {\n return deleteItem({\n entity: this.entity,\n keys\n });\n }\n\n public async queryOne<T>(params: IEntityQueryOneParams): IEntityQueryOneResult<T> {\n return queryOne<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryOneClean<T>(params: IEntityQueryOneParams): IEntityQueryOneCleanResult<T> {\n return queryOneClean<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryAll<T>(params: IEntityQueryAllParams): IEntityQueryAllResult<T> {\n return queryAll<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryAllClean<T>(params: IEntityQueryAllParams): IEntityQueryAllCleanResult<T> {\n return queryAllClean<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryPerPage<T>(params: IEntityQueryPerPageParams) {\n return queryPerPage<T>({\n ...params,\n entity: this.entity\n });\n }\n}\n\nexport const createEntity = <T extends GenericRecord = GenericRecord>(\n params: EntityConstructor\n): IEntity<T> => {\n return new Entity<T>(params);\n};\n"],"names":["Entity","params","BaseEntity","createEntityReadBatch","createEntityWriteBatch","createTableWriteBatch","item","put","keys","get","getClean","deleteItem","queryOne","queryOneClean","queryAll","queryAllClean","queryPerPage","createEntity"],"mappings":";;;;;;;;AA0CO,MAAMA;IAGT,IAAW,OAAe;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IAC3B;IAEA,IAAW,QAAkB;QAIzB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK;IAC5B;IAEA,YAAmBC,MAAyB,CAAE;QAE1C,IAAI,CAAC,MAAM,GAAG,IAAIC,OAAWD;IACjC;IAEO,mBAAmBA,MAAwC,EAAuB;QACrF,OAAOE,sBAAsB;YACzB,QAAQ,IAAI,CAAC,MAAM;YACnB,MAAMF,QAAQ;QAClB;IACJ;IAEO,mBAAmBA,MAAwC,EAAwB;QACtF,OAAOG,uBAAuB;YAC1B,QAAQ,IAAI,CAAC,MAAM;YACnB,KAAKH,QAAQ;YACb,QAAQA,QAAQ;QACpB;IACJ;IAEO,oBAAsC;QACzC,OAAOI,sBAAsB;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK;QAC5B;IACJ;IAEA,MAAa,IACTC,IAAuB,EACP;QAChB,OAAOC,IAAI;YACP,QAAQ,IAAI,CAAC,MAAM;YACnBD;QACJ;IACJ;IAEA,MAAa,IAAOE,IAAyB,EAAuB;QAChE,OAAOC,IAAO;YACV,QAAQ,IAAI,CAAC,MAAM;YACnBD;QACJ;IACJ;IAEA,MAAa,SAAYA,IAAyB,EAA4B;QAC1E,OAAOE,SAAY;YACf,QAAQ,IAAI,CAAC,MAAM;YACnBF;QACJ;IACJ;IAEA,MAAa,OAAOA,IAAqB,EAAuB;QAC5D,OAAOG,WAAW;YACd,QAAQ,IAAI,CAAC,MAAM;YACnBH;QACJ;IACJ;IAEA,MAAa,SAAYP,MAA6B,EAA4B;QAC9E,OAAOW,SAAY;YACf,GAAGX,MAAM;YACT,QAAQ,IAAI,CAAC,MAAM;QACvB;IACJ;IAEA,MAAa,cAAiBA,MAA6B,EAAiC;QACxF,OAAOY,cAAiB;YACpB,GAAGZ,MAAM;YACT,QAAQ,IAAI,CAAC,MAAM;QACvB;IACJ;IAEA,MAAa,SAAYA,MAA6B,EAA4B;QAC9E,OAAOa,SAAY;YACf,GAAGb,MAAM;YACT,QAAQ,IAAI,CAAC,MAAM;QACvB;IACJ;IAEA,MAAa,cAAiBA,MAA6B,EAAiC;QACxF,OAAOc,cAAiB;YACpB,GAAGd,MAAM;YACT,QAAQ,IAAI,CAAC,MAAM;QACvB;IACJ;IAEA,MAAa,aAAgBA,MAAiC,EAAE;QAC5D,OAAOe,aAAgB;YACnB,GAAGf,MAAM;YACT,QAAQ,IAAI,CAAC,MAAM;QACvB;IACJ;AACJ;AAEO,MAAMgB,eAAe,CACxBhB,SAEO,IAAID,cAAUC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IReadBatchItem } from "../../utils/batch/types.js";
|
|
2
|
+
import type { IEntityReadBatch, IEntityReadBatchBuilderGetResponse, IEntityReadBatchKey } from "./types.js";
|
|
3
|
+
import type { EntityOption } from "./getEntity.js";
|
|
4
|
+
export interface IEntityReadBatchParams {
|
|
5
|
+
entity: EntityOption;
|
|
6
|
+
read?: IReadBatchItem[];
|
|
7
|
+
}
|
|
8
|
+
export declare class EntityReadBatch<T> implements IEntityReadBatch<T> {
|
|
9
|
+
private readonly entity;
|
|
10
|
+
private readonly builder;
|
|
11
|
+
private readonly _items;
|
|
12
|
+
get total(): number;
|
|
13
|
+
get items(): IEntityReadBatchBuilderGetResponse[];
|
|
14
|
+
constructor(params: IEntityReadBatchParams);
|
|
15
|
+
get(input: IEntityReadBatchKey | IEntityReadBatchKey[]): void;
|
|
16
|
+
execute(): Promise<T[]>;
|
|
17
|
+
}
|
|
18
|
+
export declare const createEntityReadBatch: <T>(params: IEntityReadBatchParams) => IEntityReadBatch<T>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { batchReadAll } from "../batch/batchRead.js";
|
|
2
|
+
import { createEntityReadBatchBuilder } from "./EntityReadBatchBuilder.js";
|
|
3
|
+
import { getEntity } from "./getEntity.js";
|
|
4
|
+
class EntityReadBatch {
|
|
5
|
+
get total() {
|
|
6
|
+
return this._items.length;
|
|
7
|
+
}
|
|
8
|
+
get items() {
|
|
9
|
+
return Array.from(this._items);
|
|
10
|
+
}
|
|
11
|
+
constructor(params){
|
|
12
|
+
this._items = [];
|
|
13
|
+
this.entity = getEntity(params.entity);
|
|
14
|
+
this.builder = createEntityReadBatchBuilder(this.entity);
|
|
15
|
+
for (const item of params.read || [])this.get(item);
|
|
16
|
+
}
|
|
17
|
+
get(input) {
|
|
18
|
+
if (Array.isArray(input)) return void this._items.push(...input.map((item)=>this.builder.get(item)));
|
|
19
|
+
this._items.push(this.builder.get(input));
|
|
20
|
+
}
|
|
21
|
+
async execute() {
|
|
22
|
+
return await batchReadAll({
|
|
23
|
+
table: this.entity.table,
|
|
24
|
+
items: this._items
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const createEntityReadBatch = (params)=>new EntityReadBatch(params);
|
|
29
|
+
export { EntityReadBatch, createEntityReadBatch };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=EntityReadBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/entity/EntityReadBatch.js","sources":["../../../src/utils/entity/EntityReadBatch.ts"],"sourcesContent":["import type { IReadBatchItem } from \"~/utils/batch/types.js\";\nimport type {\n IEntityReadBatch,\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse,\n IEntityReadBatchKey\n} from \"./types.js\";\nimport type { Entity as ToolboxEntity, TableDef } from \"~/toolbox.js\";\nimport { batchReadAll } from \"~/utils/batch/batchRead.js\";\nimport { createEntityReadBatchBuilder } from \"./EntityReadBatchBuilder.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport interface IEntityReadBatchParams {\n entity: EntityOption;\n read?: IReadBatchItem[];\n}\n\nexport class EntityReadBatch<T> implements IEntityReadBatch<T> {\n private readonly entity: ToolboxEntity;\n private readonly builder: IEntityReadBatchBuilder;\n private readonly _items: IEntityReadBatchBuilderGetResponse[] = [];\n\n public get total(): number {\n return this._items.length;\n }\n\n public get items(): IEntityReadBatchBuilderGetResponse[] {\n return Array.from(this._items);\n }\n\n public constructor(params: IEntityReadBatchParams) {\n this.entity = getEntity(params.entity);\n this.builder = createEntityReadBatchBuilder(this.entity);\n for (const item of params.read || []) {\n this.get(item);\n }\n }\n\n public get(input: IEntityReadBatchKey | IEntityReadBatchKey[]): void {\n if (Array.isArray(input)) {\n this._items.push(\n ...input.map(item => {\n return this.builder.get(item);\n })\n );\n return;\n }\n this._items.push(this.builder.get(input));\n }\n\n public async execute() {\n return await batchReadAll<T>({\n table: this.entity.table as TableDef,\n items: this._items\n });\n }\n}\n\nexport const createEntityReadBatch = <T>(params: IEntityReadBatchParams): IEntityReadBatch<T> => {\n return new EntityReadBatch<T>(params);\n};\n"],"names":["EntityReadBatch","Array","params","getEntity","createEntityReadBatchBuilder","item","input","batchReadAll","createEntityReadBatch"],"mappings":";;;AAkBO,MAAMA;IAKT,IAAW,QAAgB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM;IAC7B;IAEA,IAAW,QAA8C;QACrD,OAAOC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;IACjC;IAEA,YAAmBC,MAA8B,CAAE;aAVlC,MAAM,GAAyC,EAAE;QAW9D,IAAI,CAAC,MAAM,GAAGC,UAAUD,OAAO,MAAM;QACrC,IAAI,CAAC,OAAO,GAAGE,6BAA6B,IAAI,CAAC,MAAM;QACvD,KAAK,MAAMC,QAAQH,OAAO,IAAI,IAAI,EAAE,CAChC,IAAI,CAAC,GAAG,CAACG;IAEjB;IAEO,IAAIC,KAAkD,EAAQ;QACjE,IAAIL,MAAM,OAAO,CAACK,QAAQ,YACtB,IAAI,CAAC,MAAM,CAAC,IAAI,IACTA,MAAM,GAAG,CAACD,CAAAA,OACF,IAAI,CAAC,OAAO,CAAC,GAAG,CAACA;QAKpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAACC;IACtC;IAEA,MAAa,UAAU;QACnB,OAAO,MAAMC,aAAgB;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK;YACxB,OAAO,IAAI,CAAC,MAAM;QACtB;IACJ;AACJ;AAEO,MAAMC,wBAAwB,CAAIN,SAC9B,IAAIF,gBAAmBE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Entity as ToolboxEntity } from "../../toolbox.js";
|
|
2
|
+
import type { IEntityReadBatchBuilder, IEntityReadBatchBuilderGetResponse, IEntityReadBatchKey } from "./types.js";
|
|
3
|
+
import type { Entity } from "./Entity.js";
|
|
4
|
+
import type { EntityOption } from "./getEntity.js";
|
|
5
|
+
export declare class EntityReadBatchBuilder implements IEntityReadBatchBuilder {
|
|
6
|
+
private readonly entity;
|
|
7
|
+
constructor(entity: EntityOption);
|
|
8
|
+
get(item: IEntityReadBatchKey): IEntityReadBatchBuilderGetResponse;
|
|
9
|
+
}
|
|
10
|
+
export declare const createEntityReadBatchBuilder: (entity: ToolboxEntity | Entity) => IEntityReadBatchBuilder;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { getEntity } from "./getEntity.js";
|
|
3
|
+
class EntityReadBatchBuilder {
|
|
4
|
+
constructor(entity){
|
|
5
|
+
this.entity = getEntity(entity);
|
|
6
|
+
}
|
|
7
|
+
get(item) {
|
|
8
|
+
const result = this.entity.getBatch(item);
|
|
9
|
+
if (result.Table) {
|
|
10
|
+
if (!result.Key) throw new WebinyError(`No key provided for entity ${this.entity.name}.`);
|
|
11
|
+
} else throw new WebinyError(`No table provided for entity ${this.entity.name}.`);
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const createEntityReadBatchBuilder = (entity)=>new EntityReadBatchBuilder(entity);
|
|
16
|
+
export { EntityReadBatchBuilder, createEntityReadBatchBuilder };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=EntityReadBatchBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/entity/EntityReadBatchBuilder.js","sources":["../../../src/utils/entity/EntityReadBatchBuilder.ts"],"sourcesContent":["import type { Entity as ToolboxEntity } from \"~/toolbox.js\";\nimport type {\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse,\n IEntityReadBatchKey\n} from \"./types.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { Entity } from \"./Entity.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport class EntityReadBatchBuilder implements IEntityReadBatchBuilder {\n private readonly entity: ToolboxEntity;\n\n public constructor(entity: EntityOption) {\n this.entity = getEntity(entity);\n }\n\n public get(item: IEntityReadBatchKey): IEntityReadBatchBuilderGetResponse {\n const result = this.entity.getBatch(item);\n if (!result.Table) {\n throw new WebinyError(`No table provided for entity ${this.entity.name}.`);\n } else if (!result.Key) {\n throw new WebinyError(`No key provided for entity ${this.entity.name}.`);\n }\n return result as unknown as IEntityReadBatchBuilderGetResponse;\n }\n}\n\nexport const createEntityReadBatchBuilder = (\n entity: ToolboxEntity | Entity\n): IEntityReadBatchBuilder => {\n return new EntityReadBatchBuilder(entity);\n};\n"],"names":["EntityReadBatchBuilder","entity","getEntity","item","result","WebinyError","createEntityReadBatchBuilder"],"mappings":";;AAWO,MAAMA;IAGT,YAAmBC,MAAoB,CAAE;QACrC,IAAI,CAAC,MAAM,GAAGC,UAAUD;IAC5B;IAEO,IAAIE,IAAyB,EAAsC;QACtE,MAAMC,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACD;QACpC,IAAKC,OAAO,KAAK,EAEV;YAAA,IAAI,CAACA,OAAO,GAAG,EAClB,MAAM,IAAIC,YAAY,CAAC,2BAA2B,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3E,OAHI,MAAM,IAAIA,YAAY,CAAC,6BAA6B,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAI7E,OAAOD;IACX;AACJ;AAEO,MAAME,+BAA+B,CACxCL,SAEO,IAAID,uBAAuBC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BatchWriteItem, BatchWriteResult, IDeleteBatchItem, IPutBatchItem } from "../../utils/batch/types.js";
|
|
2
|
+
import type { IEntityWriteBatch } from "./types.js";
|
|
3
|
+
import type { ITableWriteBatch } from "../../utils/table/types.js";
|
|
4
|
+
import type { EntityOption } from "./getEntity.js";
|
|
5
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
6
|
+
export interface IEntityWriteBatchParams<T = GenericRecord> {
|
|
7
|
+
entity: EntityOption;
|
|
8
|
+
put?: IPutBatchItem<T>[];
|
|
9
|
+
delete?: IDeleteBatchItem[];
|
|
10
|
+
}
|
|
11
|
+
export declare class EntityWriteBatch<T> implements IEntityWriteBatch<T> {
|
|
12
|
+
private readonly entity;
|
|
13
|
+
private readonly _items;
|
|
14
|
+
private readonly builder;
|
|
15
|
+
get total(): number;
|
|
16
|
+
get items(): BatchWriteItem[];
|
|
17
|
+
constructor(params: IEntityWriteBatchParams);
|
|
18
|
+
put(item: IPutBatchItem<T>): void;
|
|
19
|
+
delete(item: IDeleteBatchItem): void;
|
|
20
|
+
combine(items: BatchWriteItem[]): ITableWriteBatch;
|
|
21
|
+
execute(): Promise<BatchWriteResult>;
|
|
22
|
+
}
|
|
23
|
+
export declare const createEntityWriteBatch: (params: IEntityWriteBatchParams) => IEntityWriteBatch;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { batchWriteAll } from "../batch/batchWrite.js";
|
|
2
|
+
import { createTableWriteBatch } from "../table/TableWriteBatch.js";
|
|
3
|
+
import { createEntityWriteBatchBuilder } from "./EntityWriteBatchBuilder.js";
|
|
4
|
+
import { getEntity } from "./getEntity.js";
|
|
5
|
+
class EntityWriteBatch {
|
|
6
|
+
get total() {
|
|
7
|
+
return this._items.length;
|
|
8
|
+
}
|
|
9
|
+
get items() {
|
|
10
|
+
return Array.from(this._items);
|
|
11
|
+
}
|
|
12
|
+
constructor(params){
|
|
13
|
+
this._items = [];
|
|
14
|
+
this.entity = getEntity(params.entity);
|
|
15
|
+
this.builder = createEntityWriteBatchBuilder(this.entity);
|
|
16
|
+
for (const item of params.put || [])this.put(item);
|
|
17
|
+
for (const item of params.delete || [])this.delete(item);
|
|
18
|
+
}
|
|
19
|
+
put(item) {
|
|
20
|
+
this._items.push(this.builder.put(item));
|
|
21
|
+
}
|
|
22
|
+
delete(item) {
|
|
23
|
+
this._items.push(this.builder.delete(item));
|
|
24
|
+
}
|
|
25
|
+
combine(items) {
|
|
26
|
+
return createTableWriteBatch({
|
|
27
|
+
table: this.entity.table,
|
|
28
|
+
items: this._items.concat(items)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async execute() {
|
|
32
|
+
if (0 === this._items.length) return [];
|
|
33
|
+
const items = Array.from(this._items);
|
|
34
|
+
this._items.length = 0;
|
|
35
|
+
return await batchWriteAll({
|
|
36
|
+
items,
|
|
37
|
+
table: this.entity.table
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const createEntityWriteBatch = (params)=>new EntityWriteBatch(params);
|
|
42
|
+
export { EntityWriteBatch, createEntityWriteBatch };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=EntityWriteBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/entity/EntityWriteBatch.js","sources":["../../../src/utils/entity/EntityWriteBatch.ts"],"sourcesContent":["import type { Entity as ToolboxEntity, TableDef } from \"~/toolbox.js\";\nimport { batchWriteAll } from \"~/utils/batch/batchWrite.js\";\nimport type {\n BatchWriteItem,\n BatchWriteResult,\n IDeleteBatchItem,\n IPutBatchItem\n} from \"~/utils/batch/types.js\";\nimport type { IEntityWriteBatch, IEntityWriteBatchBuilder } from \"./types.js\";\nimport type { ITableWriteBatch } from \"~/utils/table/types.js\";\nimport { createTableWriteBatch } from \"~/utils/table/TableWriteBatch.js\";\nimport { createEntityWriteBatchBuilder } from \"./EntityWriteBatchBuilder.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface IEntityWriteBatchParams<T = GenericRecord> {\n entity: EntityOption;\n put?: IPutBatchItem<T>[];\n delete?: IDeleteBatchItem[];\n}\n\nexport class EntityWriteBatch<T> implements IEntityWriteBatch<T> {\n private readonly entity: ToolboxEntity;\n private readonly _items: BatchWriteItem[] = [];\n private readonly builder: IEntityWriteBatchBuilder;\n\n public get total(): number {\n return this._items.length;\n }\n\n public get items(): BatchWriteItem[] {\n return Array.from(this._items);\n }\n\n public constructor(params: IEntityWriteBatchParams) {\n this.entity = getEntity(params.entity);\n this.builder = createEntityWriteBatchBuilder(this.entity);\n for (const item of params.put || []) {\n this.put(item);\n }\n for (const item of params.delete || []) {\n this.delete(item);\n }\n }\n\n public put(item: IPutBatchItem<T>): void {\n this._items.push(this.builder.put(item));\n }\n\n public delete(item: IDeleteBatchItem): void {\n this._items.push(this.builder.delete(item));\n }\n\n public combine(items: BatchWriteItem[]): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.entity!.table as TableDef,\n items: this._items.concat(items)\n });\n }\n\n public async execute(): Promise<BatchWriteResult> {\n if (this._items.length === 0) {\n return [];\n }\n const items = Array.from(this._items);\n this._items.length = 0;\n return await batchWriteAll({\n items,\n table: this.entity.table\n });\n }\n}\n\nexport const createEntityWriteBatch = (params: IEntityWriteBatchParams): IEntityWriteBatch => {\n return new EntityWriteBatch(params);\n};\n"],"names":["EntityWriteBatch","Array","params","getEntity","createEntityWriteBatchBuilder","item","items","createTableWriteBatch","batchWriteAll","createEntityWriteBatch"],"mappings":";;;;AAsBO,MAAMA;IAKT,IAAW,QAAgB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM;IAC7B;IAEA,IAAW,QAA0B;QACjC,OAAOC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;IACjC;IAEA,YAAmBC,MAA+B,CAAE;aAXnC,MAAM,GAAqB,EAAE;QAY1C,IAAI,CAAC,MAAM,GAAGC,UAAUD,OAAO,MAAM;QACrC,IAAI,CAAC,OAAO,GAAGE,8BAA8B,IAAI,CAAC,MAAM;QACxD,KAAK,MAAMC,QAAQH,OAAO,GAAG,IAAI,EAAE,CAC/B,IAAI,CAAC,GAAG,CAACG;QAEb,KAAK,MAAMA,QAAQH,OAAO,MAAM,IAAI,EAAE,CAClC,IAAI,CAAC,MAAM,CAACG;IAEpB;IAEO,IAAIA,IAAsB,EAAQ;QACrC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAACA;IACtC;IAEO,OAAOA,IAAsB,EAAQ;QACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAACA;IACzC;IAEO,QAAQC,KAAuB,EAAoB;QACtD,OAAOC,sBAAsB;YACzB,OAAO,IAAI,CAAC,MAAM,CAAE,KAAK;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAACD;QAC9B;IACJ;IAEA,MAAa,UAAqC;QAC9C,IAAI,AAAuB,MAAvB,IAAI,CAAC,MAAM,CAAC,MAAM,EAClB,OAAO,EAAE;QAEb,MAAMA,QAAQL,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;QACpC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG;QACrB,OAAO,MAAMO,cAAc;YACvBF;YACA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK;QAC5B;IACJ;AACJ;AAEO,MAAMG,yBAAyB,CAACP,SAC5B,IAAIF,iBAAiBE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Entity } from "../../toolbox.js";
|
|
2
|
+
import type { BatchWriteItem, IDeleteBatchItem, IPutBatchItem } from "../../utils/batch/types.js";
|
|
3
|
+
import type { IEntityWriteBatchBuilder } from "./types.js";
|
|
4
|
+
import type { EntityOption } from "./getEntity.js";
|
|
5
|
+
export declare class EntityWriteBatchBuilder implements IEntityWriteBatchBuilder {
|
|
6
|
+
private readonly entity;
|
|
7
|
+
constructor(entity: EntityOption);
|
|
8
|
+
put<T extends Record<string, any>>(item: IPutBatchItem<T>): BatchWriteItem;
|
|
9
|
+
delete(item: IDeleteBatchItem): BatchWriteItem;
|
|
10
|
+
}
|
|
11
|
+
export declare const createEntityWriteBatchBuilder: (entity: Entity) => IEntityWriteBatchBuilder;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getEntity } from "./getEntity.js";
|
|
2
|
+
class EntityWriteBatchBuilder {
|
|
3
|
+
constructor(entity){
|
|
4
|
+
this.entity = getEntity(entity);
|
|
5
|
+
}
|
|
6
|
+
put(item) {
|
|
7
|
+
return this.entity.putBatch(item, {
|
|
8
|
+
execute: true,
|
|
9
|
+
strictSchemaCheck: false
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
delete(item) {
|
|
13
|
+
return this.entity.deleteBatch(item);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const createEntityWriteBatchBuilder = (entity)=>new EntityWriteBatchBuilder(entity);
|
|
17
|
+
export { EntityWriteBatchBuilder, createEntityWriteBatchBuilder };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=EntityWriteBatchBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/entity/EntityWriteBatchBuilder.js","sources":["../../../src/utils/entity/EntityWriteBatchBuilder.ts"],"sourcesContent":["import type { Entity } from \"~/toolbox.js\";\nimport type { BatchWriteItem, IDeleteBatchItem, IPutBatchItem } from \"~/utils/batch/types.js\";\nimport type { IEntityWriteBatchBuilder } from \"./types.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport class EntityWriteBatchBuilder implements IEntityWriteBatchBuilder {\n private readonly entity: Entity;\n\n public constructor(entity: EntityOption) {\n this.entity = getEntity(entity);\n }\n\n public put<T extends Record<string, any>>(item: IPutBatchItem<T>): BatchWriteItem {\n return this.entity.putBatch(item, {\n execute: true,\n strictSchemaCheck: false\n });\n }\n\n public delete(item: IDeleteBatchItem): BatchWriteItem {\n return this.entity.deleteBatch(item);\n }\n}\n\nexport const createEntityWriteBatchBuilder = (entity: Entity): IEntityWriteBatchBuilder => {\n return new EntityWriteBatchBuilder(entity);\n};\n"],"names":["EntityWriteBatchBuilder","entity","getEntity","item","createEntityWriteBatchBuilder"],"mappings":";AAMO,MAAMA;IAGT,YAAmBC,MAAoB,CAAE;QACrC,IAAI,CAAC,MAAM,GAAGC,UAAUD;IAC5B;IAEO,IAAmCE,IAAsB,EAAkB;QAC9E,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACA,MAAM;YAC9B,SAAS;YACT,mBAAmB;QACvB;IACJ;IAEO,OAAOA,IAAsB,EAAkB;QAClD,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAACA;IACnC;AACJ;AAEO,MAAMC,gCAAgC,CAACH,SACnC,IAAID,wBAAwBC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Entity } from "../../toolbox.js";
|
|
2
|
+
const getEntity = (entity)=>{
|
|
3
|
+
const result = entity instanceof Entity ? entity : entity.entity;
|
|
4
|
+
if (result.name) {
|
|
5
|
+
if (!result.table) throw new Error(`No table provided for entity ${result.name}.`);
|
|
6
|
+
} else throw new Error("No name provided for entity.");
|
|
7
|
+
return result;
|
|
8
|
+
};
|
|
9
|
+
export { getEntity };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=getEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/entity/getEntity.js","sources":["../../../src/utils/entity/getEntity.ts"],"sourcesContent":["import { Entity as ToolboxEntity } from \"~/toolbox.js\";\nimport type { Entity } from \"./Entity.js\";\n\nexport type EntityOption = ToolboxEntity | Entity;\n\nexport const getEntity = (entity: EntityOption): ToolboxEntity => {\n const result = entity instanceof ToolboxEntity ? entity : entity.entity;\n if (!result.name) {\n throw new Error(`No name provided for entity.`);\n } else if (!result.table) {\n throw new Error(`No table provided for entity ${result.name}.`);\n }\n return result;\n};\n"],"names":["getEntity","entity","result","ToolboxEntity","Error"],"mappings":";AAKO,MAAMA,YAAY,CAACC;IACtB,MAAMC,SAASD,kBAAkBE,SAAgBF,SAASA,OAAO,MAAM;IACvE,IAAKC,OAAO,IAAI,EAET;QAAA,IAAI,CAACA,OAAO,KAAK,EACpB,MAAM,IAAIE,MAAM,CAAC,6BAA6B,EAAEF,OAAO,IAAI,CAAC,CAAC,CAAC;IAClE,OAHI,MAAM,IAAIE,MAAM;IAIpB,OAAOF;AACX"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./Entity.js";
|
|
2
|
+
export * from "./EntityReadBatch.js";
|
|
3
|
+
export * from "./EntityReadBatchBuilder.js";
|
|
4
|
+
export * from "./EntityWriteBatch.js";
|
|
5
|
+
export * from "./EntityWriteBatchBuilder.js";
|
|
6
|
+
export * from "./getEntity.js";
|
|
7
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./Entity.js";
|
|
2
|
+
export * from "./EntityReadBatch.js";
|
|
3
|
+
export * from "./EntityReadBatchBuilder.js";
|
|
4
|
+
export * from "./EntityWriteBatch.js";
|
|
5
|
+
export * from "./EntityWriteBatchBuilder.js";
|
|
6
|
+
export * from "./getEntity.js";
|
|
7
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Entity as BaseEntity } from "dynamodb-toolbox";
|
|
2
|
+
import type { BatchWriteItem, BatchWriteResult, IDeleteBatchItem, IPutBatchItem } from "../../utils/batch/types.js";
|
|
3
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
4
|
+
import type { TableDef } from "../../toolbox.js";
|
|
5
|
+
import type { ITableWriteBatch } from "../../utils/table/types.js";
|
|
6
|
+
import type { IPutParamsItem, put } from "../../utils/put.js";
|
|
7
|
+
import { queryAll, queryAllClean, type QueryAllParams, queryOne, queryOneClean, type QueryOneParams } from "../../utils/query.js";
|
|
8
|
+
import type { get, getClean, GetRecordParamsKeys } from "../../utils/get.js";
|
|
9
|
+
import type { deleteItem, IDeleteItemKeys } from "../../utils/delete.js";
|
|
10
|
+
import type { batchReadAll, BatchReadItem } from "../../utils/batch/batchRead.js";
|
|
11
|
+
import type { IEntityWriteBatchParams } from "./EntityWriteBatch.js";
|
|
12
|
+
import type { IEntityReadBatchParams } from "./EntityReadBatch.js";
|
|
13
|
+
import { queryPerPage } from "../../utils/index.js";
|
|
14
|
+
export type IEntityQueryOneParams = Omit<QueryOneParams, "entity">;
|
|
15
|
+
export type IEntityQueryAllParams = Omit<QueryAllParams, "entity">;
|
|
16
|
+
export type IEntityQueryPerPageParams = Omit<QueryAllParams, "entity">;
|
|
17
|
+
export interface IEntityCreateEntityWriterParams<T = GenericRecord> extends Omit<IEntityWriteBatchParams<T>, "entity"> {
|
|
18
|
+
}
|
|
19
|
+
export interface IEntityCreateEntityReaderParams extends Omit<IEntityReadBatchParams, "entity"> {
|
|
20
|
+
}
|
|
21
|
+
export type IEntityPutResult = ReturnType<typeof put>;
|
|
22
|
+
export type IEntityGetResult<T> = ReturnType<typeof get<T>>;
|
|
23
|
+
export type IEntityGetCleanResult<T> = ReturnType<typeof getClean<T>>;
|
|
24
|
+
export type IEntityDeleteResult = ReturnType<typeof deleteItem>;
|
|
25
|
+
export type IEntityQueryOneResult<T> = ReturnType<typeof queryOne<T>>;
|
|
26
|
+
export type IEntityQueryOneCleanResult<T> = ReturnType<typeof queryOneClean<T>>;
|
|
27
|
+
export type IEntityQueryAllResult<T> = ReturnType<typeof queryAll<T>>;
|
|
28
|
+
export type IEntityQueryAllCleanResult<T> = ReturnType<typeof queryAllClean<T>>;
|
|
29
|
+
export type IEntityQueryPerPageResult<T> = ReturnType<typeof queryPerPage<T>>;
|
|
30
|
+
export interface IEntity<T extends GenericRecord = GenericRecord> {
|
|
31
|
+
readonly entity: BaseEntity;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly table: TableDef;
|
|
34
|
+
createEntityReader(params?: IEntityCreateEntityReaderParams): IEntityReadBatch<T>;
|
|
35
|
+
createEntityWriter(params?: IEntityCreateEntityWriterParams<T>): IEntityWriteBatch<T>;
|
|
36
|
+
createTableWriter(): ITableWriteBatch;
|
|
37
|
+
put(item: IPutParamsItem<T>): IEntityPutResult;
|
|
38
|
+
get<R extends T = T>(keys: GetRecordParamsKeys): IEntityGetResult<R>;
|
|
39
|
+
getClean<R extends T = T>(keys: GetRecordParamsKeys): IEntityGetCleanResult<R>;
|
|
40
|
+
delete(keys: IDeleteItemKeys): IEntityDeleteResult;
|
|
41
|
+
queryOne<R extends T = T>(params: IEntityQueryOneParams): IEntityQueryOneResult<R>;
|
|
42
|
+
queryOneClean<R extends T = T>(params: IEntityQueryOneParams): IEntityQueryOneCleanResult<R>;
|
|
43
|
+
queryAll<R extends T = T>(params: IEntityQueryAllParams): IEntityQueryAllResult<R>;
|
|
44
|
+
queryAllClean<R extends T = T>(params: IEntityQueryAllParams): IEntityQueryAllCleanResult<R>;
|
|
45
|
+
queryPerPage<R extends T = T>(params: IEntityQueryPerPageParams): IEntityQueryPerPageResult<R>;
|
|
46
|
+
}
|
|
47
|
+
export interface IEntityWriteBatchBuilder {
|
|
48
|
+
put<T extends Record<string, any>>(item: IPutBatchItem<T>): BatchWriteItem;
|
|
49
|
+
delete(item: IDeleteBatchItem): BatchWriteItem;
|
|
50
|
+
}
|
|
51
|
+
export interface IEntityWriteBatch<T = GenericRecord> {
|
|
52
|
+
readonly total: number;
|
|
53
|
+
readonly items: BatchWriteItem[];
|
|
54
|
+
put(item: IPutBatchItem<T>): void;
|
|
55
|
+
delete(item: IDeleteBatchItem): void;
|
|
56
|
+
execute(): Promise<BatchWriteResult>;
|
|
57
|
+
combine(items: BatchWriteItem[]): ITableWriteBatch;
|
|
58
|
+
}
|
|
59
|
+
export interface IEntityReadBatchKey {
|
|
60
|
+
PK: string;
|
|
61
|
+
SK: string;
|
|
62
|
+
}
|
|
63
|
+
export interface IEntityReadBatch<T = GenericRecord> {
|
|
64
|
+
readonly total: number;
|
|
65
|
+
readonly items: BatchReadItem[];
|
|
66
|
+
get(input: IEntityReadBatchKey | IEntityReadBatchKey[]): void;
|
|
67
|
+
execute(): ReturnType<typeof batchReadAll<T>>;
|
|
68
|
+
}
|
|
69
|
+
export interface IEntityReadBatchBuilderGetResponse {
|
|
70
|
+
Table: TableDef;
|
|
71
|
+
Key: IEntityReadBatchKey;
|
|
72
|
+
}
|
|
73
|
+
export interface IEntityReadBatchBuilder {
|
|
74
|
+
get(item: IEntityReadBatchKey): IEntityReadBatchBuilderGetResponse;
|
|
75
|
+
}
|
|
File without changes
|
package/utils/get.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Entity } from "
|
|
1
|
+
import type { Entity } from "../toolbox.js";
|
|
2
|
+
export interface GetRecordParamsKeys {
|
|
3
|
+
PK: string;
|
|
4
|
+
SK: string;
|
|
5
|
+
}
|
|
2
6
|
export interface GetRecordParams {
|
|
3
|
-
entity: Entity
|
|
4
|
-
keys:
|
|
5
|
-
PK: string;
|
|
6
|
-
SK: string;
|
|
7
|
-
};
|
|
7
|
+
entity: Entity;
|
|
8
|
+
keys: GetRecordParamsKeys;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* Gets a single record from the DynamoDB table.
|
|
@@ -15,3 +16,4 @@ export interface GetRecordParams {
|
|
|
15
16
|
* @throws
|
|
16
17
|
*/
|
|
17
18
|
export declare const get: <T>(params: GetRecordParams) => Promise<T | null>;
|
|
19
|
+
export declare const getClean: <T>(params: GetRecordParams) => Promise<T | null>;
|
package/utils/get.js
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @throws
|
|
15
|
-
*/
|
|
16
|
-
const get = async params => {
|
|
17
|
-
const {
|
|
18
|
-
entity,
|
|
19
|
-
keys
|
|
20
|
-
} = params;
|
|
21
|
-
const result = await entity.get(keys);
|
|
22
|
-
|
|
23
|
-
if (!result || !result.Item) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return result.Item;
|
|
1
|
+
import { cleanupItem } from "./cleanup.js";
|
|
2
|
+
const get = async (params)=>{
|
|
3
|
+
const { entity, keys } = params;
|
|
4
|
+
const result = await entity.get(keys, {
|
|
5
|
+
execute: true
|
|
6
|
+
});
|
|
7
|
+
if (!result?.Item) return null;
|
|
8
|
+
return result.Item;
|
|
9
|
+
};
|
|
10
|
+
const getClean = async (params)=>{
|
|
11
|
+
const result = await get(params);
|
|
12
|
+
if (!result) return null;
|
|
13
|
+
return cleanupItem(params.entity, result);
|
|
28
14
|
};
|
|
15
|
+
export { get, getClean };
|
|
29
16
|
|
|
30
|
-
|
|
17
|
+
//# sourceMappingURL=get.js.map
|
package/utils/get.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/get.js","sources":["../../src/utils/get.ts"],"sourcesContent":["import type { Entity } from \"~/toolbox.js\";\nimport { cleanupItem } from \"~/utils/cleanup.js\";\n\nexport interface GetRecordParamsKeys {\n PK: string;\n SK: string;\n}\n\nexport interface GetRecordParams {\n entity: Entity;\n keys: GetRecordParamsKeys;\n}\n\n/**\n * Gets a single record from the DynamoDB table.\n * Returns either record or null.\n *\n * Be aware to wrap in try/catch to avoid the error killing your app.\n *\n * @throws\n */\nexport const get = async <T>(params: GetRecordParams): Promise<T | null> => {\n const { entity, keys } = params;\n\n const result = await entity.get(keys, {\n execute: true\n });\n\n if (!result?.Item) {\n return null;\n }\n return result.Item as T;\n};\n\nexport const getClean = async <T>(params: GetRecordParams): Promise<T | null> => {\n const result = await get<T>(params);\n if (!result) {\n return null;\n }\n return cleanupItem<T>(params.entity, result);\n};\n"],"names":["get","params","entity","keys","result","getClean","cleanupItem"],"mappings":";AAqBO,MAAMA,MAAM,OAAUC;IACzB,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGF;IAEzB,MAAMG,SAAS,MAAMF,OAAO,GAAG,CAACC,MAAM;QAClC,SAAS;IACb;IAEA,IAAI,CAACC,QAAQ,MACT,OAAO;IAEX,OAAOA,OAAO,IAAI;AACtB;AAEO,MAAMC,WAAW,OAAUJ;IAC9B,MAAMG,SAAS,MAAMJ,IAAOC;IAC5B,IAAI,CAACG,QACD,OAAO;IAEX,OAAOE,YAAeL,OAAO,MAAM,EAAEG;AACzC"}
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./cleanup.js";
|
|
2
|
+
export * from "./createEntity.js";
|
|
3
|
+
export * from "./createTable.js";
|
|
4
|
+
export { decodeCursor, encodeCursor } from "./cursor.js";
|
|
5
|
+
export * from "./get.js";
|
|
6
|
+
export * from "./delete.js";
|
|
7
|
+
export * from "./put.js";
|
|
8
|
+
export * from "./query.js";
|
|
9
|
+
export * from "./scan.js";
|
|
10
|
+
export * from "./sort.js";
|
|
11
|
+
export * from "./batch/index.js";
|
|
12
|
+
export * from "./entity/index.js";
|
|
13
|
+
export * from "./table/index.js";
|
package/utils/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./cleanup.js";
|
|
2
|
+
export * from "./createEntity.js";
|
|
3
|
+
export * from "./createTable.js";
|
|
4
|
+
export * from "./get.js";
|
|
5
|
+
export * from "./delete.js";
|
|
6
|
+
export * from "./put.js";
|
|
7
|
+
export * from "./query.js";
|
|
8
|
+
export * from "./scan.js";
|
|
9
|
+
export * from "./sort.js";
|
|
10
|
+
export * from "./batch/index.js";
|
|
11
|
+
export * from "./entity/index.js";
|
|
12
|
+
export * from "./table/index.js";
|
|
13
|
+
export { decodeCursor, encodeCursor } from "./cursor.js";
|
package/utils/put.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Entity } from "../toolbox.js";
|
|
2
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
3
|
+
export type IPutParamsItem<T extends GenericRecord = GenericRecord> = {
|
|
4
|
+
PK: string;
|
|
5
|
+
SK: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
} & T;
|
|
8
|
+
export interface IPutParams<T extends GenericRecord = GenericRecord> {
|
|
9
|
+
entity: Entity;
|
|
10
|
+
item: IPutParamsItem<T>;
|
|
11
|
+
}
|
|
12
|
+
export declare const put: <T extends GenericRecord = GenericRecord>(params: IPutParams<T>) => Promise<import("@aws-sdk/lib-dynamodb").PutCommandOutput>;
|