@webiny/db-dynamodb 0.0.0-unstable.6f45466a1d → 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.js +204 -209
- package/DynamoDbDriver.js.map +1 -1
- 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 +1 -0
- package/index.js +9 -2
- package/index.js.map +1 -1
- package/package.json +28 -20
- package/plugins/definitions/DateTimeTransformPlugin.js +18 -27
- package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/FieldPlugin.js +34 -37
- package/plugins/definitions/FieldPlugin.js.map +1 -1
- package/plugins/definitions/TimeTransformPlugin.js +25 -37
- package/plugins/definitions/TimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/ValueTransformPlugin.d.ts +1 -6
- package/plugins/definitions/ValueTransformPlugin.js +17 -22
- package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
- package/plugins/definitions/assignFields.js +14 -18
- package/plugins/definitions/assignFields.js.map +1 -1
- package/plugins/index.d.ts +0 -5
- package/plugins/index.js +0 -12
- package/store/entity.js +6 -9
- package/store/entity.js.map +1 -1
- package/store/keys.js +6 -13
- package/store/keys.js.map +1 -1
- package/store/types.js +0 -3
- package/toolbox.d.ts +53 -1
- package/toolbox.js +0 -4
- package/types.js +0 -3
- package/utils/batch/batchRead.js +37 -56
- package/utils/batch/batchRead.js.map +1 -1
- package/utils/batch/batchWrite.js +33 -51
- package/utils/batch/batchWrite.js.map +1 -1
- package/utils/batch/index.js +0 -2
- package/utils/batch/types.js +0 -3
- package/utils/cleanup.js +35 -25
- package/utils/cleanup.js.map +1 -1
- package/utils/count.js +8 -13
- package/utils/count.js.map +1 -1
- package/utils/createEntity.d.ts +1 -1
- package/utils/createEntity.js +75 -78
- package/utils/createEntity.js.map +1 -1
- package/utils/createTable.js +25 -35
- package/utils/createTable.js.map +1 -1
- package/utils/cursor.js +7 -10
- package/utils/cursor.js.map +1 -1
- package/utils/delete.js +6 -8
- package/utils/delete.js.map +1 -1
- package/utils/entity/Entity.d.ts +1 -1
- package/utils/entity/Entity.js +85 -89
- package/utils/entity/Entity.js.map +1 -1
- package/utils/entity/EntityReadBatch.js +23 -31
- package/utils/entity/EntityReadBatch.js.map +1 -1
- package/utils/entity/EntityReadBatchBuilder.js +12 -15
- package/utils/entity/EntityReadBatchBuilder.js.map +1 -1
- package/utils/entity/EntityWriteBatch.js +34 -41
- package/utils/entity/EntityWriteBatch.js.map +1 -1
- package/utils/entity/EntityWriteBatchBuilder.js +15 -16
- package/utils/entity/EntityWriteBatchBuilder.js.map +1 -1
- package/utils/entity/getEntity.js +8 -9
- package/utils/entity/getEntity.js.map +1 -1
- package/utils/entity/index.js +0 -2
- package/utils/entity/types.js +0 -4
- package/utils/get.js +12 -26
- package/utils/get.js.map +1 -1
- package/utils/index.d.ts +1 -5
- package/utils/index.js +1 -7
- package/utils/put.js +7 -9
- package/utils/put.js.map +1 -1
- package/utils/query.js +77 -128
- package/utils/query.js.map +1 -1
- package/utils/scan.js +47 -73
- package/utils/scan.js.map +1 -1
- package/utils/sort.js +37 -61
- package/utils/sort.js.map +1 -1
- package/utils/table/Table.js +22 -21
- package/utils/table/Table.js.map +1 -1
- package/utils/table/TableReadBatch.js +37 -45
- package/utils/table/TableReadBatch.js.map +1 -1
- package/utils/table/TableWriteBatch.js +47 -56
- package/utils/table/TableWriteBatch.js.map +1 -1
- package/utils/table/index.js +0 -2
- package/utils/table/types.js +0 -3
- package/plugins/definitions/AttributePlugin.d.ts +0 -18
- package/plugins/definitions/AttributePlugin.js +0 -38
- package/plugins/definitions/AttributePlugin.js.map +0 -1
- package/plugins/definitions/FieldPathPlugin.d.ts +0 -22
- package/plugins/definitions/FieldPathPlugin.js +0 -26
- package/plugins/definitions/FieldPathPlugin.js.map +0 -1
- package/plugins/definitions/ValueFilterPlugin.d.ts +0 -22
- package/plugins/definitions/ValueFilterPlugin.js +0 -35
- package/plugins/definitions/ValueFilterPlugin.js.map +0 -1
- package/plugins/filters/andIn.d.ts +0 -3
- package/plugins/filters/andIn.js +0 -24
- package/plugins/filters/andIn.js.map +0 -1
- package/plugins/filters/between.d.ts +0 -3
- package/plugins/filters/between.js +0 -25
- package/plugins/filters/between.js.map +0 -1
- package/plugins/filters/contains.d.ts +0 -3
- package/plugins/filters/contains.js +0 -53
- package/plugins/filters/contains.js.map +0 -1
- package/plugins/filters/eq.d.ts +0 -3
- package/plugins/filters/eq.js +0 -26
- package/plugins/filters/eq.js.map +0 -1
- package/plugins/filters/fuzzy.d.ts +0 -3
- package/plugins/filters/fuzzy.js +0 -29
- package/plugins/filters/fuzzy.js.map +0 -1
- package/plugins/filters/gt.d.ts +0 -3
- package/plugins/filters/gt.js +0 -14
- package/plugins/filters/gt.js.map +0 -1
- package/plugins/filters/gte.d.ts +0 -3
- package/plugins/filters/gte.js +0 -14
- package/plugins/filters/gte.js.map +0 -1
- package/plugins/filters/in.d.ts +0 -3
- package/plugins/filters/in.js +0 -24
- package/plugins/filters/in.js.map +0 -1
- package/plugins/filters/index.d.ts +0 -2
- package/plugins/filters/index.js +0 -14
- package/plugins/filters/index.js.map +0 -1
- package/plugins/filters/lt.d.ts +0 -3
- package/plugins/filters/lt.js +0 -14
- package/plugins/filters/lt.js.map +0 -1
- package/plugins/filters/lte.d.ts +0 -3
- package/plugins/filters/lte.js +0 -14
- package/plugins/filters/lte.js.map +0 -1
- package/plugins/filters/startsWith.d.ts +0 -3
- package/plugins/filters/startsWith.js +0 -34
- package/plugins/filters/startsWith.js.map +0 -1
- package/plugins/index.js.map +0 -1
- package/store/types.js.map +0 -1
- package/toolbox.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/attributes.d.ts +0 -10
- package/utils/attributes.js +0 -19
- package/utils/attributes.js.map +0 -1
- package/utils/batch/index.js.map +0 -1
- package/utils/batch/types.js.map +0 -1
- package/utils/entity/index.js.map +0 -1
- package/utils/entity/types.js.map +0 -1
- package/utils/filter.d.ts +0 -12
- package/utils/filter.js +0 -174
- package/utils/filter.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/listResponse.d.ts +0 -13
- package/utils/listResponse.js +0 -25
- package/utils/listResponse.js.map +0 -1
- package/utils/table/index.js.map +0 -1
- package/utils/table/types.js.map +0 -1
- package/utils/update.d.ts +0 -12
- package/utils/update.js +0 -12
- package/utils/update.js.map +0 -1
package/utils/cleanup.js
CHANGED
|
@@ -1,30 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
const attributesToRemove = [
|
|
2
|
+
"PK",
|
|
3
|
+
"SK",
|
|
4
|
+
"created",
|
|
5
|
+
"_ct",
|
|
6
|
+
"modified",
|
|
7
|
+
"_mt",
|
|
8
|
+
"entity",
|
|
9
|
+
"_et",
|
|
10
|
+
"GSI1_PK",
|
|
11
|
+
"GSI1_SK",
|
|
12
|
+
"GSI2_PK",
|
|
13
|
+
"GSI2_SK",
|
|
14
|
+
"GSI3_PK",
|
|
15
|
+
"GSI3_SK",
|
|
16
|
+
"GSI4_PK",
|
|
17
|
+
"GSI4_SK",
|
|
18
|
+
"GSI5_PK",
|
|
19
|
+
"GSI5_SK",
|
|
20
|
+
"GSI_TENANT",
|
|
21
|
+
"TYPE"
|
|
22
|
+
];
|
|
23
|
+
function cleanupItem(entity, item, removeAttributes = []) {
|
|
24
|
+
if (!item) return null;
|
|
25
|
+
const newItem = {
|
|
26
|
+
...item
|
|
27
|
+
};
|
|
28
|
+
const targets = attributesToRemove.concat(removeAttributes);
|
|
29
|
+
const attributes = entity.schema.attributes;
|
|
30
|
+
for(const key in item)if (false !== item.hasOwnProperty(key)) {
|
|
31
|
+
if (!attributes[key] || false !== targets.includes(key)) delete newItem[key];
|
|
18
32
|
}
|
|
19
|
-
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
delete newItem[key];
|
|
23
|
-
}
|
|
24
|
-
return newItem;
|
|
33
|
+
return newItem;
|
|
25
34
|
}
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
function cleanupItems(entity, items, removeAttributes = []) {
|
|
36
|
+
return items.map((item)=>cleanupItem(entity, item, removeAttributes));
|
|
28
37
|
}
|
|
38
|
+
export { cleanupItem, cleanupItems };
|
|
29
39
|
|
|
30
40
|
//# sourceMappingURL=cleanup.js.map
|
package/utils/cleanup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/cleanup.js","sources":["../../src/utils/cleanup.ts"],"sourcesContent":["import type { Entity } from \"~/toolbox.js\";\n\n/**\n * The attributes defined by us or the dynamodb-toolbox library.\n * Add more attributes if necessary.\n */\nconst attributesToRemove = [\n \"PK\",\n \"SK\",\n \"created\",\n \"_ct\",\n \"modified\",\n \"_mt\",\n \"entity\",\n \"_et\",\n \"GSI1_PK\",\n \"GSI1_SK\",\n \"GSI2_PK\",\n \"GSI2_SK\",\n \"GSI3_PK\",\n \"GSI3_SK\",\n \"GSI4_PK\",\n \"GSI4_SK\",\n \"GSI5_PK\",\n \"GSI5_SK\",\n \"GSI_TENANT\",\n \"TYPE\"\n];\n\nexport function cleanupItem<T>(\n entity: Entity<any>,\n item?: T | null,\n removeAttributes: string[] = []\n): T | null {\n if (!item) {\n return null;\n }\n const newItem = {\n ...item\n };\n const targets = attributesToRemove.concat(removeAttributes);\n const attributes = entity.schema.attributes;\n for (const key in item) {\n if (item.hasOwnProperty(key) === false) {\n continue;\n }\n if (attributes[key] && targets.includes(key) === false) {\n continue;\n }\n delete newItem[key];\n }\n return newItem;\n}\n\nexport function cleanupItems<T>(\n entity: Entity<any>,\n items: T[],\n removeAttributes: string[] = []\n): T[] {\n return items.map(item => cleanupItem<T>(entity, item, removeAttributes) as T);\n}\n"],"names":["attributesToRemove","cleanupItem","entity","item","removeAttributes","newItem","targets","attributes","key","cleanupItems","items"],"mappings":"AAMA,MAAMA,qBAAqB;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,SAASC,YACZC,MAAmB,EACnBC,IAAe,EACfC,mBAA6B,EAAE;IAE/B,IAAI,CAACD,MACD,OAAO;IAEX,MAAME,UAAU;QACZ,GAAGF,IAAI;IACX;IACA,MAAMG,UAAUN,mBAAmB,MAAM,CAACI;IAC1C,MAAMG,aAAaL,OAAO,MAAM,CAAC,UAAU;IAC3C,IAAK,MAAMM,OAAOL,KACd,IAAIA,AAA6B,UAA7BA,KAAK,cAAc,CAACK,MAGxB;QAAA,IAAID,CAAAA,UAAU,CAACC,IAAI,IAAIF,AAA0B,UAA1BA,QAAQ,QAAQ,CAACE,MAGxC,OAAOH,OAAO,CAACG,IAAI;IADnB;IAGJ,OAAOH;AACX;AAEO,SAASI,aACZP,MAAmB,EACnBQ,KAAU,EACVN,mBAA6B,EAAE;IAE/B,OAAOM,MAAM,GAAG,CAACP,CAAAA,OAAQF,YAAeC,QAAQC,MAAMC;AAC1D"}
|
package/utils/count.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
entity,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Count
|
|
9
|
-
} = await entity.query(partitionKey, {
|
|
10
|
-
...options,
|
|
11
|
-
select: "count"
|
|
12
|
-
});
|
|
13
|
-
return Count || 0;
|
|
1
|
+
const count = async (params)=>{
|
|
2
|
+
const { entity, partitionKey, options = {} } = params;
|
|
3
|
+
const { Count } = await entity.query(partitionKey, {
|
|
4
|
+
...options,
|
|
5
|
+
select: "count"
|
|
6
|
+
});
|
|
7
|
+
return Count || 0;
|
|
14
8
|
};
|
|
9
|
+
export { count };
|
|
15
10
|
|
|
16
11
|
//# sourceMappingURL=count.js.map
|
package/utils/count.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/count.js","sources":["../../src/utils/count.ts"],"sourcesContent":["import type { QueryAllParams } from \"~/utils/query.js\";\n\nexport const count = async (params: QueryAllParams): Promise<number> => {\n const { entity, partitionKey, options = {} } = params;\n // @ts-expect-error\n const { Count } = await entity.query(partitionKey, { ...options, select: \"count\" });\n return Count || 0;\n};\n"],"names":["count","params","entity","partitionKey","options","Count"],"mappings":"AAEO,MAAMA,QAAQ,OAAOC;IACxB,MAAM,EAAEC,MAAM,EAAEC,YAAY,EAAEC,UAAU,CAAC,CAAC,EAAE,GAAGH;IAE/C,MAAM,EAAEI,KAAK,EAAE,GAAG,MAAMH,OAAO,KAAK,CAACC,cAAc;QAAE,GAAGC,OAAO;QAAE,QAAQ;IAAQ;IACjF,OAAOC,SAAS;AACpB"}
|
package/utils/createEntity.d.ts
CHANGED
package/utils/createEntity.js
CHANGED
|
@@ -1,85 +1,82 @@
|
|
|
1
1
|
import { createEntity } from "./entity/index.js";
|
|
2
|
-
|
|
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
|
-
export const createGlobalEntity = params => {
|
|
33
|
-
return createEntity({
|
|
34
|
-
...params,
|
|
35
|
-
attributes: {
|
|
36
|
-
...globalEntityAttributes,
|
|
37
|
-
...params.attributes
|
|
2
|
+
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"
|
|
38
30
|
}
|
|
39
|
-
});
|
|
40
|
-
};
|
|
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
31
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
32
|
+
const createGlobalEntity = (params)=>createEntity({
|
|
33
|
+
...params,
|
|
34
|
+
attributes: {
|
|
35
|
+
...globalEntityAttributes,
|
|
36
|
+
...params.attributes
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const standardEntityAttributes = {
|
|
40
|
+
PK: {
|
|
41
|
+
partitionKey: true
|
|
42
|
+
},
|
|
43
|
+
SK: {
|
|
44
|
+
sortKey: true
|
|
45
|
+
},
|
|
46
|
+
GSI_TENANT: {
|
|
47
|
+
type: "string",
|
|
48
|
+
required: true
|
|
49
|
+
},
|
|
50
|
+
GSI1_PK: {
|
|
51
|
+
type: "string"
|
|
52
|
+
},
|
|
53
|
+
GSI1_SK: {
|
|
54
|
+
type: "string"
|
|
55
|
+
},
|
|
56
|
+
GSI2_PK: {
|
|
57
|
+
type: "string"
|
|
58
|
+
},
|
|
59
|
+
GSI2_SK: {
|
|
60
|
+
type: "string"
|
|
61
|
+
},
|
|
62
|
+
TYPE: {
|
|
63
|
+
type: "string",
|
|
64
|
+
required: true
|
|
65
|
+
},
|
|
66
|
+
data: {
|
|
67
|
+
type: "map"
|
|
68
|
+
},
|
|
69
|
+
expiresAt: {
|
|
70
|
+
type: "number"
|
|
81
71
|
}
|
|
82
|
-
});
|
|
83
72
|
};
|
|
73
|
+
const createStandardEntity = (params)=>createEntity({
|
|
74
|
+
...params,
|
|
75
|
+
attributes: {
|
|
76
|
+
...standardEntityAttributes,
|
|
77
|
+
...params.attributes
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
export { createGlobalEntity, createStandardEntity, globalEntityAttributes, standardEntityAttributes };
|
|
84
81
|
|
|
85
82
|
//# sourceMappingURL=createEntity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/createEntity.js","sources":["../../src/utils/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?: number | 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"],"names":["globalEntityAttributes","createGlobalEntity","params","createEntity","standardEntityAttributes","createStandardEntity"],"mappings":";AAeO,MAAMA,yBAA+C;IACxD,IAAI;QACA,cAAc;IAClB;IACA,IAAI;QACA,SAAS;IACb;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,MAAM;QACF,MAAM;QACN,UAAU;IACd;IACA,MAAM;QACF,MAAM;IACV;IACA,WAAW;QACP,MAAM;IACV;AACJ;AAEO,MAAMC,qBAAqB,CAC9BC,SAEOC,aAAyC;QAC5C,GAAGD,MAAM;QACT,YAAY;YACR,GAAGF,sBAAsB;YACzB,GAAGE,OAAO,UAAU;QACxB;IACJ;AAeG,MAAME,2BAAiD;IAC1D,IAAI;QACA,cAAc;IAClB;IACA,IAAI;QACA,SAAS;IACb;IACA,YAAY;QACR,MAAM;QACN,UAAU;IACd;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,MAAM;QACF,MAAM;QACN,UAAU;IACd;IACA,MAAM;QACF,MAAM;IACV;IACA,WAAW;QACP,MAAM;IACV;AACJ;AAEO,MAAMC,uBAAuB,CAChCH,SAEOC,aAA2C;QAC9C,GAAGD,MAAM;QACT,YAAY;YACR,GAAGE,wBAAwB;YAC3B,GAAGF,OAAO,UAAU;QACxB;IACJ"}
|
package/utils/createTable.js
CHANGED
|
@@ -1,39 +1,29 @@
|
|
|
1
1
|
import { Table } from "./table/index.js";
|
|
2
|
-
|
|
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
|
-
GSI2: {
|
|
28
|
-
partitionKey: "GSI2_PK",
|
|
29
|
-
sortKey: "GSI2_SK"
|
|
30
|
-
},
|
|
31
|
-
...indexes
|
|
32
|
-
},
|
|
33
|
-
autoExecute: true,
|
|
34
|
-
autoParse: true,
|
|
35
|
-
...rest
|
|
36
|
-
});
|
|
2
|
+
const createTable = (params)=>{
|
|
3
|
+
const { documentClient, indexes = {}, ...rest } = params;
|
|
4
|
+
return new Table({
|
|
5
|
+
partitionKey: "PK",
|
|
6
|
+
sortKey: "SK",
|
|
7
|
+
DocumentClient: documentClient,
|
|
8
|
+
indexes: {
|
|
9
|
+
GSI_TENANT: {
|
|
10
|
+
partitionKey: "GSI_TENANT"
|
|
11
|
+
},
|
|
12
|
+
GSI1: {
|
|
13
|
+
partitionKey: "GSI1_PK",
|
|
14
|
+
sortKey: "GSI1_SK"
|
|
15
|
+
},
|
|
16
|
+
GSI2: {
|
|
17
|
+
partitionKey: "GSI2_PK",
|
|
18
|
+
sortKey: "GSI2_SK"
|
|
19
|
+
},
|
|
20
|
+
...indexes
|
|
21
|
+
},
|
|
22
|
+
autoExecute: true,
|
|
23
|
+
autoParse: true,
|
|
24
|
+
...rest
|
|
25
|
+
});
|
|
37
26
|
};
|
|
27
|
+
export { createTable };
|
|
38
28
|
|
|
39
29
|
//# sourceMappingURL=createTable.js.map
|
package/utils/createTable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/createTable.js","sources":["../../src/utils/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"],"names":["createTable","params","documentClient","indexes","rest","Table"],"mappings":";AAyBO,MAAMA,cAAc,CAACC;IACxB,MAAM,EAAEC,cAAc,EAAEC,UAAU,CAAC,CAAC,EAAE,GAAGC,MAAM,GAAGH;IAClD,OAAO,IAAII,MAAM;QACb,cAAc;QACd,SAAS;QACT,gBAAgBH;QAChB,SAAS;YACL,YAAY;gBACR,cAAc;YAClB;YACA,MAAM;gBACF,cAAc;gBACd,SAAS;YACb;YACA,MAAM;gBACF,cAAc;gBACd,SAAS;YACb;YACA,GAAGC,OAAO;QACd;QACA,aAAa;QACb,WAAW;QACX,GAAGC,IAAI;IACX;AACJ"}
|
package/utils/cursor.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return
|
|
4
|
-
}
|
|
5
|
-
return Buffer.from(JSON.stringify(cursor)).toString("base64");
|
|
1
|
+
const encodeCursor = (cursor)=>{
|
|
2
|
+
if (!cursor) return null;
|
|
3
|
+
return Buffer.from(JSON.stringify(cursor)).toString("base64");
|
|
6
4
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
return JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
|
|
5
|
+
const decodeCursor = (cursor)=>{
|
|
6
|
+
if (!cursor) return null;
|
|
7
|
+
return JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
|
|
12
8
|
};
|
|
9
|
+
export { decodeCursor, encodeCursor };
|
|
13
10
|
|
|
14
11
|
//# sourceMappingURL=cursor.js.map
|
package/utils/cursor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/cursor.js","sources":["../../src/utils/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"],"names":["encodeCursor","cursor","Buffer","JSON","decodeCursor"],"mappings":"AAAO,MAAMA,eAAe,CAACC;IACzB,IAAI,CAACA,QACD,OAAO;IAGX,OAAOC,OAAO,IAAI,CAACC,KAAK,SAAS,CAACF,SAAS,QAAQ,CAAC;AACxD;AAEO,MAAMG,eAAe,CAACH;IACzB,IAAI,CAACA,QACD,OAAO;IAGX,OAAOE,KAAK,KAAK,CAACD,OAAO,IAAI,CAACD,QAAQ,UAAU,QAAQ,CAAC;AAC7D"}
|
package/utils/delete.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
entity,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return await entity.delete(keys, {
|
|
7
|
-
execute: true
|
|
8
|
-
});
|
|
1
|
+
const deleteItem = async (params)=>{
|
|
2
|
+
const { entity, keys } = params;
|
|
3
|
+
return await entity.delete(keys, {
|
|
4
|
+
execute: true
|
|
5
|
+
});
|
|
9
6
|
};
|
|
7
|
+
export { deleteItem };
|
|
10
8
|
|
|
11
9
|
//# sourceMappingURL=delete.js.map
|
package/utils/delete.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/utils/entity/Entity.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { IPutParamsItem } from "../put.js";
|
|
|
6
6
|
import type { GetRecordParamsKeys } from "../get.js";
|
|
7
7
|
import type { IDeleteItemKeys } from "../delete.js";
|
|
8
8
|
import type { GenericRecord } from "@webiny/api/types.js";
|
|
9
|
-
export type EntityConstructor<T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>> = BaseEntityConstructor<
|
|
9
|
+
export type EntityConstructor<T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>> = BaseEntityConstructor<T>;
|
|
10
10
|
export declare class Entity<T extends GenericRecord = GenericRecord> implements IEntity<T> {
|
|
11
11
|
readonly entity: BaseEntity;
|
|
12
12
|
get name(): string;
|