@webiny/db-dynamodb 6.0.0-alpha.5 → 6.0.0-rc.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/DynamoDbDriver.d.ts +4 -8
- package/DynamoDbDriver.js +71 -102
- package/DynamoDbDriver.js.map +1 -1
- package/README.md +6 -142
- package/index.d.ts +4 -3
- package/index.js +4 -28
- package/index.js.map +1 -1
- package/package.json +18 -20
- package/plugins/definitions/AttributePlugin.d.ts +1 -1
- package/plugins/definitions/AttributePlugin.js +4 -12
- package/plugins/definitions/AttributePlugin.js.map +1 -1
- package/plugins/definitions/DateTimeTransformPlugin.d.ts +2 -2
- package/plugins/definitions/DateTimeTransformPlugin.js +6 -14
- package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/FieldPathPlugin.js +6 -14
- package/plugins/definitions/FieldPathPlugin.js.map +1 -1
- package/plugins/definitions/FieldPlugin.d.ts +1 -1
- package/plugins/definitions/FieldPlugin.js +2 -9
- package/plugins/definitions/FieldPlugin.js.map +1 -1
- package/plugins/definitions/TimeTransformPlugin.d.ts +2 -2
- package/plugins/definitions/TimeTransformPlugin.js +7 -15
- package/plugins/definitions/TimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/ValueFilterPlugin.js +5 -13
- package/plugins/definitions/ValueFilterPlugin.js.map +1 -1
- package/plugins/definitions/ValueTransformPlugin.js +6 -14
- package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
- package/plugins/definitions/assignFields.js +4 -12
- package/plugins/definitions/assignFields.js.map +1 -1
- package/plugins/filters/andIn.d.ts +1 -1
- package/plugins/filters/andIn.js +5 -12
- package/plugins/filters/andIn.js.map +1 -1
- package/plugins/filters/between.d.ts +1 -1
- package/plugins/filters/between.js +5 -12
- package/plugins/filters/between.js.map +1 -1
- package/plugins/filters/contains.d.ts +1 -1
- package/plugins/filters/contains.js +3 -9
- package/plugins/filters/contains.js.map +1 -1
- package/plugins/filters/eq.d.ts +1 -1
- package/plugins/filters/eq.js +3 -9
- package/plugins/filters/eq.js.map +1 -1
- package/plugins/filters/fuzzy.d.ts +1 -1
- package/plugins/filters/fuzzy.js +5 -12
- package/plugins/filters/fuzzy.js.map +1 -1
- package/plugins/filters/gt.d.ts +1 -1
- package/plugins/filters/gt.js +3 -9
- package/plugins/filters/gt.js.map +1 -1
- package/plugins/filters/gte.d.ts +1 -1
- package/plugins/filters/gte.js +3 -9
- package/plugins/filters/gte.js.map +1 -1
- package/plugins/filters/in.d.ts +1 -1
- package/plugins/filters/in.js +5 -12
- package/plugins/filters/in.js.map +1 -1
- package/plugins/filters/index.d.ts +1 -1
- package/plugins/filters/index.js +12 -20
- package/plugins/filters/index.js.map +1 -1
- package/plugins/filters/lt.d.ts +1 -1
- package/plugins/filters/lt.js +3 -9
- package/plugins/filters/lt.js.map +1 -1
- package/plugins/filters/lte.d.ts +1 -1
- package/plugins/filters/lte.js +3 -9
- package/plugins/filters/lte.js.map +1 -1
- package/plugins/filters/startsWith.d.ts +1 -1
- package/plugins/filters/startsWith.js +3 -9
- package/plugins/filters/startsWith.js.map +1 -1
- package/plugins/index.d.ts +9 -1
- package/plugins/index.js +11 -11
- package/plugins/index.js.map +1 -1
- package/store/entity.d.ts +4 -76
- package/store/entity.js +5 -35
- package/store/entity.js.map +1 -1
- package/store/keys.d.ts +1 -1
- package/store/keys.js +7 -13
- package/store/keys.js.map +1 -1
- package/store/types.d.ts +3 -4
- package/store/types.js +1 -5
- package/store/types.js.map +1 -1
- package/toolbox.d.ts +7 -2
- package/toolbox.js +2 -17
- package/toolbox.js.map +1 -1
- package/types.js +1 -5
- package/utils/attributes.d.ts +2 -2
- package/utils/attributes.js +4 -12
- package/utils/attributes.js.map +1 -1
- package/utils/batch/batchRead.d.ts +2 -2
- package/utils/batch/batchRead.js +5 -13
- package/utils/batch/batchRead.js.map +1 -1
- package/utils/batch/batchWrite.d.ts +2 -2
- package/utils/batch/batchWrite.js +3 -11
- package/utils/batch/batchWrite.js.map +1 -1
- package/utils/batch/index.d.ts +3 -3
- package/utils/batch/index.js +3 -38
- package/utils/batch/index.js.map +1 -1
- package/utils/batch/types.d.ts +7 -2
- package/utils/batch/types.js +1 -5
- package/utils/batch/types.js.map +1 -1
- package/utils/cleanup.d.ts +1 -1
- package/utils/cleanup.js +3 -10
- package/utils/cleanup.js.map +1 -1
- package/utils/count.d.ts +1 -1
- package/utils/count.js +1 -8
- package/utils/count.js.map +1 -1
- package/utils/createEntity.d.ts +36 -54
- package/utils/createEntity.js +75 -51
- package/utils/createEntity.js.map +1 -1
- package/utils/createTable.d.ts +10 -7
- package/utils/createTable.js +25 -15
- package/utils/createTable.js.map +1 -1
- package/utils/cursor.js +2 -10
- package/utils/cursor.js.map +1 -1
- package/utils/delete.d.ts +1 -1
- package/utils/delete.js +1 -8
- package/utils/delete.js.map +1 -1
- package/utils/entity/Entity.d.ts +23 -21
- package/utils/entity/Entity.js +56 -34
- package/utils/entity/Entity.js.map +1 -1
- package/utils/entity/EntityReadBatch.d.ts +9 -8
- package/utils/entity/EntityReadBatch.js +14 -16
- package/utils/entity/EntityReadBatch.js.map +1 -1
- package/utils/entity/EntityReadBatchBuilder.d.ts +4 -4
- package/utils/entity/EntityReadBatchBuilder.js +7 -15
- package/utils/entity/EntityReadBatchBuilder.js.map +1 -1
- package/utils/entity/EntityWriteBatch.d.ts +9 -8
- package/utils/entity/EntityWriteBatch.js +10 -18
- package/utils/entity/EntityWriteBatch.js.map +1 -1
- package/utils/entity/EntityWriteBatchBuilder.d.ts +4 -4
- package/utils/entity/EntityWriteBatchBuilder.js +4 -12
- package/utils/entity/EntityWriteBatchBuilder.js.map +1 -1
- package/utils/entity/getEntity.d.ts +2 -2
- package/utils/entity/getEntity.js +3 -10
- package/utils/entity/getEntity.js.map +1 -1
- package/utils/entity/index.d.ts +7 -7
- package/utils/entity/index.js +7 -82
- package/utils/entity/index.js.map +1 -1
- package/utils/entity/types.d.ts +46 -22
- package/utils/entity/types.js +2 -5
- package/utils/entity/types.js.map +1 -1
- package/utils/filter.d.ts +1 -1
- package/utils/filter.js +7 -14
- package/utils/filter.js.map +1 -1
- package/utils/get.d.ts +1 -1
- package/utils/get.js +4 -12
- package/utils/get.js.map +1 -1
- package/utils/index.d.ts +17 -17
- package/utils/index.js +17 -192
- package/utils/index.js.map +1 -1
- package/utils/listResponse.js +4 -10
- package/utils/listResponse.js.map +1 -1
- package/utils/put.d.ts +2 -2
- package/utils/put.js +1 -8
- package/utils/put.js.map +1 -1
- package/utils/query.d.ts +5 -12
- package/utils/query.js +13 -27
- package/utils/query.js.map +1 -1
- package/utils/scan.d.ts +2 -2
- package/utils/scan.js +5 -13
- package/utils/scan.js.map +1 -1
- package/utils/sort.d.ts +1 -1
- package/utils/sort.js +7 -14
- package/utils/sort.js.map +1 -1
- package/utils/table/Table.d.ts +4 -5
- package/utils/table/Table.js +9 -20
- package/utils/table/Table.js.map +1 -1
- package/utils/table/TableReadBatch.d.ts +4 -4
- package/utils/table/TableReadBatch.js +8 -16
- package/utils/table/TableReadBatch.js.map +1 -1
- package/utils/table/TableWriteBatch.d.ts +3 -3
- package/utils/table/TableWriteBatch.js +6 -14
- package/utils/table/TableWriteBatch.js.map +1 -1
- package/utils/table/index.d.ts +4 -4
- package/utils/table/index.js +4 -49
- package/utils/table/index.js.map +1 -1
- package/utils/table/types.d.ts +8 -8
- package/utils/table/types.js +1 -5
- package/utils/table/types.js.map +1 -1
- package/utils/update.d.ts +1 -1
- package/utils/update.js +1 -8
- package/utils/update.js.map +1 -1
package/utils/createEntity.d.ts
CHANGED
|
@@ -1,54 +1,36 @@
|
|
|
1
|
-
import type { AttributeDefinitions
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
type: "string";
|
|
38
|
-
};
|
|
39
|
-
GSI1_SK: {
|
|
40
|
-
type: "string";
|
|
41
|
-
};
|
|
42
|
-
TYPE: {
|
|
43
|
-
type: "string";
|
|
44
|
-
};
|
|
45
|
-
}, import("dynamodb-toolbox/dist/cjs/classes/Entity").ParsedAttributes<import("ts-toolbelt/out/Any/Key").Key>, any, {
|
|
46
|
-
[x: string]: any;
|
|
47
|
-
[x: number]: any;
|
|
48
|
-
[x: symbol]: any;
|
|
49
|
-
}, {
|
|
50
|
-
[x: string]: any;
|
|
51
|
-
[x: number]: any;
|
|
52
|
-
[x: symbol]: any;
|
|
53
|
-
}>;
|
|
54
|
-
export {};
|
|
1
|
+
import type { AttributeDefinitions } from "../toolbox.js";
|
|
2
|
+
import { type EntityConstructor } from "../utils/entity/index.js";
|
|
3
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
4
|
+
export type IGlobalEntityAttributes<T = undefined> = {
|
|
5
|
+
PK: string;
|
|
6
|
+
SK: string;
|
|
7
|
+
TYPE: string;
|
|
8
|
+
GSI1_PK?: string;
|
|
9
|
+
GSI1_SK?: string;
|
|
10
|
+
GSI2_PK?: string;
|
|
11
|
+
GSI2_SK?: string;
|
|
12
|
+
expiresAt?: string | null;
|
|
13
|
+
} & (T extends undefined ? {
|
|
14
|
+
data?: undefined;
|
|
15
|
+
} : {
|
|
16
|
+
data: T;
|
|
17
|
+
});
|
|
18
|
+
export declare const globalEntityAttributes: AttributeDefinitions;
|
|
19
|
+
export declare const createGlobalEntity: <T extends GenericRecord = GenericRecord>(params: Omit<EntityConstructor, "attributes"> & Partial<Pick<EntityConstructor, "attributes">>) => import("~/utils/entity/index.js").IEntity<IGlobalEntityAttributes<T>>;
|
|
20
|
+
export type IStandardEntityAttributes<T = undefined> = {
|
|
21
|
+
PK: string;
|
|
22
|
+
SK: string;
|
|
23
|
+
GSI_TENANT: string;
|
|
24
|
+
TYPE: string;
|
|
25
|
+
GSI1_PK?: string;
|
|
26
|
+
GSI1_SK?: string;
|
|
27
|
+
GSI2_PK?: string;
|
|
28
|
+
GSI2_SK?: string;
|
|
29
|
+
expiresAt?: number | null;
|
|
30
|
+
} & (T extends undefined ? {
|
|
31
|
+
data?: undefined;
|
|
32
|
+
} : {
|
|
33
|
+
data: T;
|
|
34
|
+
});
|
|
35
|
+
export declare const standardEntityAttributes: AttributeDefinitions;
|
|
36
|
+
export declare const createStandardEntity: <T extends GenericRecord = GenericRecord>(params: Omit<EntityConstructor, "attributes"> & Partial<Pick<EntityConstructor, "attributes">>) => import("~/utils/entity/index.js").IEntity<IStandardEntityAttributes<T>>;
|
package/utils/createEntity.js
CHANGED
|
@@ -1,61 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { createEntity } from "./entity/index.js";
|
|
2
|
+
export const globalEntityAttributes = {
|
|
3
|
+
PK: {
|
|
4
|
+
partitionKey: true
|
|
5
|
+
},
|
|
6
|
+
SK: {
|
|
7
|
+
sortKey: true
|
|
8
|
+
},
|
|
9
|
+
GSI1_PK: {
|
|
10
|
+
type: "string"
|
|
11
|
+
},
|
|
12
|
+
GSI1_SK: {
|
|
13
|
+
type: "string"
|
|
14
|
+
},
|
|
15
|
+
GSI2_PK: {
|
|
16
|
+
type: "string"
|
|
17
|
+
},
|
|
18
|
+
GSI2_SK: {
|
|
19
|
+
type: "string"
|
|
20
|
+
},
|
|
21
|
+
TYPE: {
|
|
22
|
+
type: "string",
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
data: {
|
|
26
|
+
type: "map"
|
|
27
|
+
},
|
|
28
|
+
expiresAt: {
|
|
29
|
+
type: "number"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const createGlobalEntity = params => {
|
|
33
|
+
return createEntity({
|
|
34
|
+
...params,
|
|
12
35
|
attributes: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
SK: {
|
|
17
|
-
sortKey: true
|
|
18
|
-
},
|
|
19
|
-
GSI1_PK: {
|
|
20
|
-
type: "string"
|
|
21
|
-
},
|
|
22
|
-
GSI1_SK: {
|
|
23
|
-
type: "string"
|
|
24
|
-
},
|
|
25
|
-
TYPE: {
|
|
26
|
-
type: "string"
|
|
27
|
-
},
|
|
28
|
-
data: {
|
|
29
|
-
type: "map"
|
|
30
|
-
}
|
|
36
|
+
...globalEntityAttributes,
|
|
37
|
+
...params.attributes
|
|
31
38
|
}
|
|
32
39
|
});
|
|
33
40
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
export const standardEntityAttributes = {
|
|
42
|
+
PK: {
|
|
43
|
+
partitionKey: true
|
|
44
|
+
},
|
|
45
|
+
SK: {
|
|
46
|
+
sortKey: true
|
|
47
|
+
},
|
|
48
|
+
GSI_TENANT: {
|
|
49
|
+
type: "string",
|
|
50
|
+
required: true
|
|
51
|
+
},
|
|
52
|
+
GSI1_PK: {
|
|
53
|
+
type: "string"
|
|
54
|
+
},
|
|
55
|
+
GSI1_SK: {
|
|
56
|
+
type: "string"
|
|
57
|
+
},
|
|
58
|
+
GSI2_PK: {
|
|
59
|
+
type: "string"
|
|
60
|
+
},
|
|
61
|
+
GSI2_SK: {
|
|
62
|
+
type: "string"
|
|
63
|
+
},
|
|
64
|
+
TYPE: {
|
|
65
|
+
type: "string",
|
|
66
|
+
required: true
|
|
67
|
+
},
|
|
68
|
+
data: {
|
|
69
|
+
type: "map"
|
|
70
|
+
},
|
|
71
|
+
expiresAt: {
|
|
72
|
+
type: "number"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export const createStandardEntity = params => {
|
|
76
|
+
return createEntity({
|
|
77
|
+
...params,
|
|
39
78
|
attributes: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
SK: {
|
|
44
|
-
sortKey: true
|
|
45
|
-
},
|
|
46
|
-
GSI1_PK: {
|
|
47
|
-
type: "string"
|
|
48
|
-
},
|
|
49
|
-
GSI1_SK: {
|
|
50
|
-
type: "string"
|
|
51
|
-
},
|
|
52
|
-
TYPE: {
|
|
53
|
-
type: "string"
|
|
54
|
-
},
|
|
55
|
-
...(params.attributes || {})
|
|
79
|
+
...standardEntityAttributes,
|
|
80
|
+
...params.attributes
|
|
56
81
|
}
|
|
57
82
|
});
|
|
58
83
|
};
|
|
59
|
-
exports.createLegacyEntity = createLegacyEntity;
|
|
60
84
|
|
|
61
85
|
//# sourceMappingURL=createEntity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createEntity","globalEntityAttributes","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","GSI2_PK","GSI2_SK","TYPE","required","data","expiresAt","createGlobalEntity","params","attributes","standardEntityAttributes","GSI_TENANT","createStandardEntity"],"sources":["createEntity.ts"],"sourcesContent":["import type { AttributeDefinitions } from \"~/toolbox.js\";\nimport { createEntity, type EntityConstructor } from \"~/utils/entity/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport type IGlobalEntityAttributes<T = undefined> = {\n PK: string;\n SK: string;\n TYPE: string;\n GSI1_PK?: string;\n GSI1_SK?: string;\n GSI2_PK?: string;\n GSI2_SK?: string;\n expiresAt?: string | null;\n} & (T extends undefined ? { data?: undefined } : { data: T });\n\nexport const globalEntityAttributes: AttributeDefinitions = {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n GSI2_PK: {\n type: \"string\"\n },\n GSI2_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\",\n required: true\n },\n data: {\n type: \"map\"\n },\n expiresAt: {\n type: \"number\"\n }\n};\n\nexport const createGlobalEntity = <T extends GenericRecord = GenericRecord>(\n params: Omit<EntityConstructor, \"attributes\"> & Partial<Pick<EntityConstructor, \"attributes\">>\n) => {\n return createEntity<IGlobalEntityAttributes<T>>({\n ...params,\n attributes: {\n ...globalEntityAttributes,\n ...params.attributes\n }\n });\n};\n\nexport type IStandardEntityAttributes<T = undefined> = {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n TYPE: string;\n GSI1_PK?: string;\n GSI1_SK?: string;\n GSI2_PK?: string;\n GSI2_SK?: string;\n expiresAt?: number | null;\n} & (T extends undefined ? { data?: undefined } : { data: T });\n\nexport const standardEntityAttributes: AttributeDefinitions = {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI_TENANT: {\n type: \"string\",\n required: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n GSI2_PK: {\n type: \"string\"\n },\n GSI2_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\",\n required: true\n },\n data: {\n type: \"map\"\n },\n expiresAt: {\n type: \"number\"\n }\n};\n\nexport const createStandardEntity = <T extends GenericRecord = GenericRecord>(\n params: Omit<EntityConstructor, \"attributes\"> & Partial<Pick<EntityConstructor, \"attributes\">>\n) => {\n return createEntity<IStandardEntityAttributes<T>>({\n ...params,\n attributes: {\n ...standardEntityAttributes,\n ...params.attributes\n }\n });\n};\n"],"mappings":"AACA,SAASA,YAAY;AAcrB,OAAO,MAAMC,sBAA4C,GAAG;EACxDC,EAAE,EAAE;IACAC,YAAY,EAAE;EAClB,CAAC;EACDC,EAAE,EAAE;IACAC,OAAO,EAAE;EACb,CAAC;EACDC,OAAO,EAAE;IACLC,IAAI,EAAE;EACV,CAAC;EACDC,OAAO,EAAE;IACLD,IAAI,EAAE;EACV,CAAC;EACDE,OAAO,EAAE;IACLF,IAAI,EAAE;EACV,CAAC;EACDG,OAAO,EAAE;IACLH,IAAI,EAAE;EACV,CAAC;EACDI,IAAI,EAAE;IACFJ,IAAI,EAAE,QAAQ;IACdK,QAAQ,EAAE;EACd,CAAC;EACDC,IAAI,EAAE;IACFN,IAAI,EAAE;EACV,CAAC;EACDO,SAAS,EAAE;IACPP,IAAI,EAAE;EACV;AACJ,CAAC;AAED,OAAO,MAAMQ,kBAAkB,GAC3BC,MAA8F,IAC7F;EACD,OAAOhB,YAAY,CAA6B;IAC5C,GAAGgB,MAAM;IACTC,UAAU,EAAE;MACR,GAAGhB,sBAAsB;MACzB,GAAGe,MAAM,CAACC;IACd;EACJ,CAAC,CAAC;AACN,CAAC;AAcD,OAAO,MAAMC,wBAA8C,GAAG;EAC1DhB,EAAE,EAAE;IACAC,YAAY,EAAE;EAClB,CAAC;EACDC,EAAE,EAAE;IACAC,OAAO,EAAE;EACb,CAAC;EACDc,UAAU,EAAE;IACRZ,IAAI,EAAE,QAAQ;IACdK,QAAQ,EAAE;EACd,CAAC;EACDN,OAAO,EAAE;IACLC,IAAI,EAAE;EACV,CAAC;EACDC,OAAO,EAAE;IACLD,IAAI,EAAE;EACV,CAAC;EACDE,OAAO,EAAE;IACLF,IAAI,EAAE;EACV,CAAC;EACDG,OAAO,EAAE;IACLH,IAAI,EAAE;EACV,CAAC;EACDI,IAAI,EAAE;IACFJ,IAAI,EAAE,QAAQ;IACdK,QAAQ,EAAE;EACd,CAAC;EACDC,IAAI,EAAE;IACFN,IAAI,EAAE;EACV,CAAC;EACDO,SAAS,EAAE;IACPP,IAAI,EAAE;EACV;AACJ,CAAC;AAED,OAAO,MAAMa,oBAAoB,GAC7BJ,MAA8F,IAC7F;EACD,OAAOhB,YAAY,CAA+B;IAC9C,GAAGgB,MAAM;IACTC,UAAU,EAAE;MACR,GAAGC,wBAAwB;MAC3B,GAAGF,MAAM,CAACC;IACd;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/utils/createTable.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { ITable } from "../utils/table/index.js";
|
|
2
|
+
import type { TableConstructor } from "../toolbox.js";
|
|
3
|
+
export interface ICreateTableParamsIndexDefinition {
|
|
4
|
+
partitionKey: string;
|
|
5
|
+
sortKey?: string;
|
|
6
6
|
}
|
|
7
|
-
export type
|
|
8
|
-
|
|
7
|
+
export type ICreateTableParams = Partial<Omit<TableConstructor<string, string, string>, "DocumentClient">> & {
|
|
8
|
+
name: string;
|
|
9
|
+
documentClient: Pick<TableConstructor<string, string, string>, "DocumentClient">["DocumentClient"];
|
|
10
|
+
};
|
|
11
|
+
export declare const createTable: (params: ICreateTableParams) => ITable<string, "PK", "SK">;
|
package/utils/createTable.js
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { Table } from "./table/index.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
// export interface ICreateTableParams {
|
|
4
|
+
// name?: string;
|
|
5
|
+
// documentClient: DynamoDBDocument;
|
|
6
|
+
// indexes?: GenericRecord<string, ICreateTableParamsIndexDefinition>;
|
|
7
|
+
// }
|
|
8
|
+
|
|
9
|
+
export const createTable = params => {
|
|
10
|
+
const {
|
|
11
|
+
documentClient,
|
|
12
|
+
indexes = {},
|
|
13
|
+
...rest
|
|
14
|
+
} = params;
|
|
15
|
+
return new Table({
|
|
14
16
|
partitionKey: "PK",
|
|
15
17
|
sortKey: "SK",
|
|
16
18
|
DocumentClient: documentClient,
|
|
17
19
|
indexes: {
|
|
20
|
+
GSI_TENANT: {
|
|
21
|
+
partitionKey: "GSI_TENANT"
|
|
22
|
+
},
|
|
18
23
|
GSI1: {
|
|
19
24
|
partitionKey: "GSI1_PK",
|
|
20
25
|
sortKey: "GSI1_SK"
|
|
21
|
-
}
|
|
26
|
+
},
|
|
27
|
+
GSI2: {
|
|
28
|
+
partitionKey: "GSI2_PK",
|
|
29
|
+
sortKey: "GSI2_SK"
|
|
30
|
+
},
|
|
31
|
+
...indexes
|
|
22
32
|
},
|
|
23
33
|
autoExecute: true,
|
|
24
|
-
autoParse: true
|
|
34
|
+
autoParse: true,
|
|
35
|
+
...rest
|
|
25
36
|
});
|
|
26
37
|
};
|
|
27
|
-
exports.createTable = createTable;
|
|
28
38
|
|
|
29
39
|
//# sourceMappingURL=createTable.js.map
|
package/utils/createTable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Table","createTable","params","documentClient","indexes","rest","partitionKey","sortKey","DocumentClient","GSI_TENANT","GSI1","GSI2","autoExecute","autoParse"],"sources":["createTable.ts"],"sourcesContent":["import type { ITable } from \"~/utils/table/index.js\";\nimport { Table } from \"~/utils/table/index.js\";\nimport type { TableConstructor } from \"~/toolbox.js\";\n\nexport interface ICreateTableParamsIndexDefinition {\n partitionKey: string;\n sortKey?: string;\n}\n\n// export interface ICreateTableParams {\n// name?: string;\n// documentClient: DynamoDBDocument;\n// indexes?: GenericRecord<string, ICreateTableParamsIndexDefinition>;\n// }\n\nexport type ICreateTableParams = Partial<\n Omit<TableConstructor<string, string, string>, \"DocumentClient\">\n> & {\n name: string;\n documentClient: Pick<\n TableConstructor<string, string, string>,\n \"DocumentClient\"\n >[\"DocumentClient\"];\n};\n\nexport const createTable = (params: ICreateTableParams): ITable<string, \"PK\", \"SK\"> => {\n const { documentClient, indexes = {}, ...rest } = params;\n return new Table({\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI_TENANT: {\n partitionKey: \"GSI_TENANT\"\n },\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n },\n GSI2: {\n partitionKey: \"GSI2_PK\",\n sortKey: \"GSI2_SK\"\n },\n ...indexes\n },\n autoExecute: true,\n autoParse: true,\n ...rest\n });\n};\n"],"mappings":"AACA,SAASA,KAAK;;AAQd;AACA;AACA;AACA;AACA;;AAYA,OAAO,MAAMC,WAAW,GAAIC,MAA0B,IAAiC;EACnF,MAAM;IAAEC,cAAc;IAAEC,OAAO,GAAG,CAAC,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGH,MAAM;EACxD,OAAO,IAAIF,KAAK,CAAC;IACbM,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAEL,cAAc;IAC9BC,OAAO,EAAE;MACLK,UAAU,EAAE;QACRH,YAAY,EAAE;MAClB,CAAC;MACDI,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb,CAAC;MACDI,IAAI,EAAE;QACFL,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb,CAAC;MACD,GAAGH;IACP,CAAC;IACDQ,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE,IAAI;IACf,GAAGR;EACP,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/utils/cursor.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.encodeCursor = exports.decodeCursor = void 0;
|
|
7
|
-
const encodeCursor = cursor => {
|
|
1
|
+
export const encodeCursor = cursor => {
|
|
8
2
|
if (!cursor) {
|
|
9
3
|
return null;
|
|
10
4
|
}
|
|
11
5
|
return Buffer.from(JSON.stringify(cursor)).toString("base64");
|
|
12
6
|
};
|
|
13
|
-
|
|
14
|
-
const decodeCursor = cursor => {
|
|
7
|
+
export const decodeCursor = cursor => {
|
|
15
8
|
if (!cursor) {
|
|
16
9
|
return null;
|
|
17
10
|
}
|
|
18
11
|
return JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
|
|
19
12
|
};
|
|
20
|
-
exports.decodeCursor = decodeCursor;
|
|
21
13
|
|
|
22
14
|
//# sourceMappingURL=cursor.js.map
|
package/utils/cursor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["encodeCursor","cursor","Buffer","from","JSON","stringify","toString","
|
|
1
|
+
{"version":3,"names":["encodeCursor","cursor","Buffer","from","JSON","stringify","toString","decodeCursor","parse"],"sources":["cursor.ts"],"sourcesContent":["export const encodeCursor = (cursor?: any): string | null => {\n if (!cursor) {\n return null;\n }\n\n return Buffer.from(JSON.stringify(cursor)).toString(\"base64\");\n};\n\nexport const decodeCursor = (cursor?: string | null): string | null => {\n if (!cursor) {\n return null;\n }\n\n return JSON.parse(Buffer.from(cursor, \"base64\").toString(\"ascii\"));\n};\n"],"mappings":"AAAA,OAAO,MAAMA,YAAY,GAAIC,MAAY,IAAoB;EACzD,IAAI,CAACA,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,OAAOC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACJ,MAAM,CAAC,CAAC,CAACK,QAAQ,CAAC,QAAQ,CAAC;AACjE,CAAC;AAED,OAAO,MAAMC,YAAY,GAAIN,MAAsB,IAAoB;EACnE,IAAI,CAACA,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,OAAOG,IAAI,CAACI,KAAK,CAACN,MAAM,CAACC,IAAI,CAACF,MAAM,EAAE,QAAQ,CAAC,CAACK,QAAQ,CAAC,OAAO,CAAC,CAAC;AACtE,CAAC","ignoreList":[]}
|
package/utils/delete.d.ts
CHANGED
package/utils/delete.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.deleteItem = void 0;
|
|
7
|
-
const deleteItem = async params => {
|
|
1
|
+
export const deleteItem = async params => {
|
|
8
2
|
const {
|
|
9
3
|
entity,
|
|
10
4
|
keys
|
|
@@ -13,6 +7,5 @@ const deleteItem = async params => {
|
|
|
13
7
|
execute: true
|
|
14
8
|
});
|
|
15
9
|
};
|
|
16
|
-
exports.deleteItem = deleteItem;
|
|
17
10
|
|
|
18
11
|
//# sourceMappingURL=delete.js.map
|
package/utils/delete.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["deleteItem","params","entity","keys","delete","execute"
|
|
1
|
+
{"version":3,"names":["deleteItem","params","entity","keys","delete","execute"],"sources":["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"],"mappings":"AAUA,OAAO,MAAMA,UAAU,GAAG,MAAOC,MAAyB,IAAK;EAC3D,MAAM;IAAEC,MAAM;IAAEC;EAAK,CAAC,GAAGF,MAAM;EAE/B,OAAO,MAAMC,MAAM,CAACE,MAAM,CAACD,IAAI,EAAE;IAC7BE,OAAO,EAAE;EACb,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/utils/entity/Entity.d.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import type { AttributeDefinitions, EntityConstructor as BaseEntityConstructor, Readonly, TableDef } from "../../toolbox";
|
|
2
|
-
import { Entity as BaseEntity } from "../../toolbox";
|
|
3
|
-
import type { ITableWriteBatch } from "../table/types";
|
|
4
|
-
import type { IEntity, IEntityQueryAllParams, IEntityQueryOneParams, IEntityReadBatch, IEntityWriteBatch } from "./types";
|
|
5
|
-
import type { IPutParamsItem } from "../put";
|
|
6
|
-
import {
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
9
|
-
import type { IDeleteItemKeys } from "../delete";
|
|
10
|
-
import { deleteItem } from "../delete";
|
|
11
|
-
import type { GenericRecord } from "@webiny/api/types";
|
|
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";
|
|
12
9
|
export type EntityConstructor<T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>> = BaseEntityConstructor<TableDef, string, true, true, true, "created", "modified", "entity", false, T>;
|
|
13
|
-
export declare class Entity implements IEntity {
|
|
10
|
+
export declare class Entity<T extends GenericRecord = GenericRecord> implements IEntity<T> {
|
|
14
11
|
readonly entity: BaseEntity;
|
|
12
|
+
get name(): string;
|
|
13
|
+
get table(): TableDef;
|
|
15
14
|
constructor(params: EntityConstructor);
|
|
16
|
-
createEntityReader(): IEntityReadBatch
|
|
17
|
-
createEntityWriter(): IEntityWriteBatch
|
|
15
|
+
createEntityReader(params?: IEntityCreateEntityReaderParams): IEntityReadBatch<T>;
|
|
16
|
+
createEntityWriter(params?: IEntityCreateEntityWriterParams): IEntityWriteBatch<T>;
|
|
18
17
|
createTableWriter(): ITableWriteBatch;
|
|
19
|
-
put<T extends GenericRecord = GenericRecord>(item: IPutParamsItem<T>):
|
|
20
|
-
get<T>(keys: GetRecordParamsKeys):
|
|
21
|
-
getClean<T>(keys: GetRecordParamsKeys):
|
|
22
|
-
delete(keys: IDeleteItemKeys):
|
|
23
|
-
queryOne<T>(params: IEntityQueryOneParams):
|
|
24
|
-
|
|
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>>;
|
|
25
27
|
}
|
|
26
|
-
export declare const createEntity: (params: EntityConstructor) => IEntity
|
|
28
|
+
export declare const createEntity: <T extends GenericRecord = GenericRecord>(params: EntityConstructor) => IEntity<T>;
|
package/utils/entity/Entity.js
CHANGED
|
@@ -1,77 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { Entity as BaseEntity } 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
|
+
export class Entity {
|
|
10
|
+
get name() {
|
|
11
|
+
return this.entity.name;
|
|
12
|
+
}
|
|
13
|
+
get table() {
|
|
14
|
+
/**
|
|
15
|
+
* Not possible to be undefined.
|
|
16
|
+
*/
|
|
17
|
+
return this.entity.table;
|
|
18
|
+
}
|
|
16
19
|
constructor(params) {
|
|
17
|
-
this.entity = new
|
|
20
|
+
this.entity = new BaseEntity(params);
|
|
18
21
|
}
|
|
19
|
-
createEntityReader() {
|
|
20
|
-
return
|
|
21
|
-
entity: this.entity
|
|
22
|
+
createEntityReader(params) {
|
|
23
|
+
return createEntityReadBatch({
|
|
24
|
+
entity: this.entity,
|
|
25
|
+
read: params?.read
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
|
-
createEntityWriter() {
|
|
25
|
-
return
|
|
26
|
-
entity: this.entity
|
|
28
|
+
createEntityWriter(params) {
|
|
29
|
+
return createEntityWriteBatch({
|
|
30
|
+
entity: this.entity,
|
|
31
|
+
put: params?.put,
|
|
32
|
+
delete: params?.delete
|
|
27
33
|
});
|
|
28
34
|
}
|
|
29
35
|
createTableWriter() {
|
|
30
|
-
return
|
|
36
|
+
return createTableWriteBatch({
|
|
31
37
|
table: this.entity.table
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
40
|
async put(item) {
|
|
35
|
-
return
|
|
41
|
+
return put({
|
|
36
42
|
entity: this.entity,
|
|
37
43
|
item
|
|
38
44
|
});
|
|
39
45
|
}
|
|
40
46
|
async get(keys) {
|
|
41
|
-
return
|
|
47
|
+
return get({
|
|
42
48
|
entity: this.entity,
|
|
43
49
|
keys
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
async getClean(keys) {
|
|
47
|
-
return
|
|
53
|
+
return getClean({
|
|
48
54
|
entity: this.entity,
|
|
49
55
|
keys
|
|
50
56
|
});
|
|
51
57
|
}
|
|
52
58
|
async delete(keys) {
|
|
53
|
-
return
|
|
59
|
+
return deleteItem({
|
|
54
60
|
entity: this.entity,
|
|
55
61
|
keys
|
|
56
62
|
});
|
|
57
63
|
}
|
|
58
|
-
queryOne(params) {
|
|
59
|
-
return (
|
|
64
|
+
async queryOne(params) {
|
|
65
|
+
return queryOne({
|
|
66
|
+
...params,
|
|
67
|
+
entity: this.entity
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async queryOneClean(params) {
|
|
71
|
+
return queryOneClean({
|
|
72
|
+
...params,
|
|
73
|
+
entity: this.entity
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async queryAll(params) {
|
|
77
|
+
return queryAll({
|
|
78
|
+
...params,
|
|
79
|
+
entity: this.entity
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async queryAllClean(params) {
|
|
83
|
+
return queryAllClean({
|
|
60
84
|
...params,
|
|
61
85
|
entity: this.entity
|
|
62
86
|
});
|
|
63
87
|
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
88
|
+
async queryPerPage(params) {
|
|
89
|
+
return queryPerPage({
|
|
66
90
|
...params,
|
|
67
91
|
entity: this.entity
|
|
68
92
|
});
|
|
69
93
|
}
|
|
70
94
|
}
|
|
71
|
-
|
|
72
|
-
const createEntity = params => {
|
|
95
|
+
export const createEntity = params => {
|
|
73
96
|
return new Entity(params);
|
|
74
97
|
};
|
|
75
|
-
exports.createEntity = createEntity;
|
|
76
98
|
|
|
77
99
|
//# sourceMappingURL=Entity.js.map
|