@webiny/db-dynamodb 6.3.0-beta.4 → 6.4.0-beta.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.js +204 -209
- package/DynamoDbDriver.js.map +1 -1
- package/exports/api/db.js +0 -2
- package/feature/FilterUtil/FilterUtil.js +18 -20
- package/feature/FilterUtil/FilterUtil.js.map +1 -1
- package/feature/FilterUtil/abstractions/FilterUtil.js +2 -1
- package/feature/FilterUtil/abstractions/FilterUtil.js.map +1 -1
- package/feature/FilterUtil/createFilters.js +82 -120
- package/feature/FilterUtil/createFilters.js.map +1 -1
- package/feature/FilterUtil/extractWhereArgs.js +15 -19
- package/feature/FilterUtil/extractWhereArgs.js.map +1 -1
- package/feature/FilterUtil/feature.js +6 -5
- package/feature/FilterUtil/feature.js.map +1 -1
- package/feature/FilterUtil/index.js +0 -2
- package/feature/ValueFilter/ValueFilterRegistry.js +21 -17
- package/feature/ValueFilter/ValueFilterRegistry.js.map +1 -1
- package/feature/ValueFilter/abstractions/ValueFilter.js +2 -1
- package/feature/ValueFilter/abstractions/ValueFilter.js.map +1 -1
- package/feature/ValueFilter/abstractions/ValueFilterRegistry.js +2 -1
- package/feature/ValueFilter/abstractions/ValueFilterRegistry.js.map +1 -1
- package/feature/ValueFilter/feature.js +17 -16
- package/feature/ValueFilter/feature.js.map +1 -1
- package/feature/ValueFilter/filters/AndInFilter.js +19 -23
- package/feature/ValueFilter/filters/AndInFilter.js.map +1 -1
- package/feature/ValueFilter/filters/BetweenFilter.js +23 -25
- package/feature/ValueFilter/filters/BetweenFilter.js.map +1 -1
- package/feature/ValueFilter/filters/ContainsFilter.js +34 -53
- package/feature/ValueFilter/filters/ContainsFilter.js.map +1 -1
- package/feature/ValueFilter/filters/EqFilter.js +17 -27
- package/feature/ValueFilter/filters/EqFilter.js.map +1 -1
- package/feature/ValueFilter/filters/FuzzyFilter.js +30 -30
- package/feature/ValueFilter/filters/FuzzyFilter.js.map +1 -1
- package/feature/ValueFilter/filters/GtFilter.js +16 -16
- package/feature/ValueFilter/filters/GtFilter.js.map +1 -1
- package/feature/ValueFilter/filters/GteFilter.js +16 -16
- package/feature/ValueFilter/filters/GteFilter.js.map +1 -1
- package/feature/ValueFilter/filters/InFilter.js +19 -23
- package/feature/ValueFilter/filters/InFilter.js.map +1 -1
- package/feature/ValueFilter/filters/LtFilter.js +16 -16
- package/feature/ValueFilter/filters/LtFilter.js.map +1 -1
- package/feature/ValueFilter/filters/LteFilter.js +16 -16
- package/feature/ValueFilter/filters/LteFilter.js.map +1 -1
- package/feature/ValueFilter/filters/StartsWithFilter.js +20 -36
- package/feature/ValueFilter/filters/StartsWithFilter.js.map +1 -1
- package/feature/ValueFilter/index.js +0 -2
- package/index.js +7 -9
- package/index.js.map +1 -1
- package/package.json +13 -13
- package/plugins/definitions/DateTimeTransformPlugin.js +18 -30
- 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.js +18 -17
- 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.js +0 -2
- 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.js +0 -5
- 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 -14
- 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.js +85 -90
- 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.js +1 -3
- package/utils/put.js +7 -9
- package/utils/put.js.map +1 -1
- package/utils/query.js +77 -129
- 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/exports/api/db.js.map +0 -1
- package/feature/FilterUtil/index.js.map +0 -1
- package/feature/ValueFilter/index.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/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/index.js.map +0 -1
- package/utils/table/index.js.map +0 -1
- package/utils/table/types.js.map +0 -1
package/utils/scan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/scan.js","sources":["../../src/utils/scan.ts"],"sourcesContent":["import type { ScanInput, ScanOutput } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { Entity, ScanOptions, TableDef } from \"~/toolbox.js\";\nimport type { ExecuteWithRetryOptions } from \"@webiny/utils\";\nimport { executeWithRetry } from \"@webiny/utils\";\n\nexport type { ScanOptions, ScanInput, ScanOutput };\n\nexport interface BaseScanParams {\n options?: ScanOptions;\n params?: Partial<ScanInput>;\n}\n\nexport interface ScanWithTable extends BaseScanParams {\n table: TableDef;\n entity?: never;\n}\n\nexport interface ScanWithEntity extends BaseScanParams {\n entity: Entity;\n table?: never;\n}\n\nexport type ScanParams = ScanWithTable | ScanWithEntity;\n\nexport interface ScanResponse<T = any> {\n items: T[];\n count?: number;\n scannedCount?: number;\n lastEvaluatedKey?: ScanOutput[\"LastEvaluatedKey\"];\n next?: () => Promise<ScanResponse<T>>;\n requestId: string;\n error: any;\n}\n\ninterface DdbScanResult<T> {\n Items?: T[];\n Count?: number;\n ScannedCount?: number;\n LastEvaluatedKey?: ScanOutput[\"LastEvaluatedKey\"];\n next?: () => Promise<DdbScanResult<T>>;\n error?: any;\n $response?: {\n requestId: string;\n };\n}\n\ntype NextCb<T> = () => Promise<ScanResponse<T>>;\n\nconst createNext = <T>(result: DdbScanResult<T>): NextCb<T> | undefined => {\n if (!result?.LastEvaluatedKey || !result.next) {\n return undefined;\n }\n return async () => {\n const response = await result!.next!();\n return convertResult(response);\n };\n};\n\nconst convertResult = <T>(result: DdbScanResult<T>): ScanResponse<T> => {\n return {\n items: result.Items || [],\n count: result.Count,\n scannedCount: result.ScannedCount,\n lastEvaluatedKey: result.LastEvaluatedKey || undefined,\n next: createNext<T>(result),\n error: result.error,\n requestId: result.$response?.requestId || \"\"\n };\n};\n\nexport type ScanDbItem<T> = T & {\n PK: string;\n SK: string;\n GSI1_PK: string;\n GSI1_SK: string;\n TYPE: string;\n};\n\nexport const scan = async <T>(params: ScanParams): Promise<ScanResponse<T>> => {\n const { options } = params;\n\n const table = params.table ? params.table : params.entity.table;\n if (!table) {\n throw new Error(`Missing table for scan: ${JSON.stringify(options)}`);\n }\n\n const result = await table.scan(\n {\n ...options,\n execute: true\n },\n params.params\n );\n\n return convertResult(result) as ScanResponse<T>;\n};\n\ninterface ScanWithCallbackOptions {\n retry?: true | ExecuteWithRetryOptions;\n}\n\nexport const scanWithCallback = async <T>(\n params: ScanParams,\n callback: (result: ScanResponse<ScanDbItem<T>>) => Promise<void | boolean>,\n options?: ScanWithCallbackOptions\n): Promise<void> => {\n // For backwards compatibility, we still allow for executing the scan without retries.\n const usingRetry = Boolean(options?.retry);\n const retryOptions = options?.retry === true ? {} : options?.retry;\n\n const executeScan = () => scan<ScanDbItem<T>>(params);\n const getInitialResult = () => {\n if (usingRetry) {\n return executeWithRetry(executeScan, retryOptions);\n }\n return executeScan();\n };\n\n let result = await getInitialResult();\n\n if (!result.items?.length && !result.lastEvaluatedKey) {\n return;\n }\n\n // If the result of the callback was `false`, that means the\n // user's intention was to stop further table scanning.\n const callbackResult = await callback(result);\n const mustBreak = callbackResult === false;\n if (mustBreak) {\n return;\n }\n\n while (result.next) {\n const executeNext = () => result.next!();\n const getNextResult = () => {\n if (usingRetry) {\n return executeWithRetry(executeNext, retryOptions);\n }\n return executeNext();\n };\n\n result = await getNextResult();\n\n // If the result of the callback was `false`, that means the\n // user's intention was to stop further table scanning.\n const callbackResult = await callback(result);\n const mustBreak = callbackResult === false;\n if (mustBreak) {\n break;\n }\n\n if (!result.next) {\n return;\n }\n }\n};\n"],"names":["createNext","result","response","convertResult","undefined","scan","params","options","table","Error","JSON","scanWithCallback","callback","usingRetry","Boolean","retryOptions","executeScan","getInitialResult","executeWithRetry","callbackResult","mustBreak","executeNext","getNextResult"],"mappings":";AAgDA,MAAMA,aAAa,CAAIC;IACnB,IAAI,CAACA,QAAQ,oBAAoB,CAACA,OAAO,IAAI,EACzC;IAEJ,OAAO;QACH,MAAMC,WAAW,MAAMD,OAAQ,IAAI;QACnC,OAAOE,cAAcD;IACzB;AACJ;AAEA,MAAMC,gBAAgB,CAAIF,SACf;QACH,OAAOA,OAAO,KAAK,IAAI,EAAE;QACzB,OAAOA,OAAO,KAAK;QACnB,cAAcA,OAAO,YAAY;QACjC,kBAAkBA,OAAO,gBAAgB,IAAIG;QAC7C,MAAMJ,WAAcC;QACpB,OAAOA,OAAO,KAAK;QACnB,WAAWA,OAAO,SAAS,EAAE,aAAa;IAC9C;AAWG,MAAMI,OAAO,OAAUC;IAC1B,MAAM,EAAEC,OAAO,EAAE,GAAGD;IAEpB,MAAME,QAAQF,OAAO,KAAK,GAAGA,OAAO,KAAK,GAAGA,OAAO,MAAM,CAAC,KAAK;IAC/D,IAAI,CAACE,OACD,MAAM,IAAIC,MAAM,CAAC,wBAAwB,EAAEC,KAAK,SAAS,CAACH,UAAU;IAGxE,MAAMN,SAAS,MAAMO,MAAM,IAAI,CAC3B;QACI,GAAGD,OAAO;QACV,SAAS;IACb,GACAD,OAAO,MAAM;IAGjB,OAAOH,cAAcF;AACzB;AAMO,MAAMU,mBAAmB,OAC5BL,QACAM,UACAL;IAGA,MAAMM,aAAaC,QAAQP,SAAS;IACpC,MAAMQ,eAAeR,SAAS,UAAU,OAAO,CAAC,IAAIA,SAAS;IAE7D,MAAMS,cAAc,IAAMX,KAAoBC;IAC9C,MAAMW,mBAAmB;QACrB,IAAIJ,YACA,OAAOK,iBAAiBF,aAAaD;QAEzC,OAAOC;IACX;IAEA,IAAIf,SAAS,MAAMgB;IAEnB,IAAI,CAAChB,OAAO,KAAK,EAAE,UAAU,CAACA,OAAO,gBAAgB,EACjD;IAKJ,MAAMkB,iBAAiB,MAAMP,SAASX;IACtC,MAAMmB,YAAYD,AAAmB,UAAnBA;IAClB,IAAIC,WACA;IAGJ,MAAOnB,OAAO,IAAI,CAAE;QAChB,MAAMoB,cAAc,IAAMpB,OAAO,IAAI;QACrC,MAAMqB,gBAAgB;YAClB,IAAIT,YACA,OAAOK,iBAAiBG,aAAaN;YAEzC,OAAOM;QACX;QAEApB,SAAS,MAAMqB;QAIf,MAAMH,iBAAiB,MAAMP,SAASX;QACtC,MAAMmB,YAAYD,AAAmB,UAAnBA;QAClB,IAAIC,WACA;QAGJ,IAAI,CAACnB,OAAO,IAAI,EACZ;IAER;AACJ"}
|
package/utils/sort.js
CHANGED
|
@@ -1,69 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
const extractSort = (sortBy, fields)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
sortBy
|
|
1
|
+
import orderBy from "lodash/orderBy.js";
|
|
2
|
+
import error from "@webiny/error";
|
|
3
|
+
const extractSort = (sortBy, fields)=>{
|
|
4
|
+
const result = sortBy.split("_");
|
|
5
|
+
if (2 !== result.length) throw new error("Problem in determining the sorting for the entry items.", "SORT_ERROR", {
|
|
6
|
+
sortBy
|
|
8
7
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
order,
|
|
15
|
-
fields
|
|
8
|
+
const [field, order] = result;
|
|
9
|
+
if (!field) throw new error("Sorting field does not exist.", "SORTING_FIELD_ERROR", {
|
|
10
|
+
field,
|
|
11
|
+
order,
|
|
12
|
+
fields
|
|
16
13
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fields,
|
|
23
|
-
field
|
|
14
|
+
const fieldPlugin = fields.find((f)=>f.getField() === field);
|
|
15
|
+
const isSortable = fieldPlugin ? fieldPlugin.isSortable() : true;
|
|
16
|
+
if (false === isSortable) throw new error(`Cannot sort by given field: "${field}".`, "UNSUPPORTED_SORT_ERROR", {
|
|
17
|
+
fields,
|
|
18
|
+
field
|
|
24
19
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
20
|
+
return {
|
|
21
|
+
field,
|
|
22
|
+
reverse: "DESC" === order.toUpperCase()
|
|
23
|
+
};
|
|
30
24
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
items
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
orders: []
|
|
46
|
-
};
|
|
47
|
-
for (const sort of initialSort) {
|
|
48
|
-
/**
|
|
49
|
-
* Possibly empty array item was passed.
|
|
50
|
-
*/
|
|
51
|
-
if (!sort) {
|
|
52
|
-
continue;
|
|
25
|
+
function sortItems(params) {
|
|
26
|
+
const { items, sort: initialSort = [], fields = [] } = params;
|
|
27
|
+
if (items.length <= 1 || false === Array.isArray(initialSort) || 0 === initialSort.length) return items;
|
|
28
|
+
const info = {
|
|
29
|
+
sorters: [],
|
|
30
|
+
orders: []
|
|
31
|
+
};
|
|
32
|
+
for (const sort of initialSort){
|
|
33
|
+
if (!sort) continue;
|
|
34
|
+
const { field, reverse } = extractSort(sort, fields);
|
|
35
|
+
const fieldPlugin = fields.find((f)=>f.getField() === field);
|
|
36
|
+
const path = fieldPlugin ? fieldPlugin.getPath() : field;
|
|
37
|
+
info.sorters.push(path);
|
|
38
|
+
info.orders.push(true === reverse ? "desc" : "asc");
|
|
53
39
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
reverse
|
|
57
|
-
} = extractSort(sort, fields);
|
|
58
|
-
const fieldPlugin = fields.find(f => f.getField() === field);
|
|
59
|
-
const path = fieldPlugin ? fieldPlugin.getPath() : field;
|
|
60
|
-
info.sorters.push(path);
|
|
61
|
-
info.orders.push(reverse === true ? "desc" : "asc");
|
|
62
|
-
}
|
|
63
|
-
if (info.sorters.length === 0) {
|
|
64
|
-
return items;
|
|
65
|
-
}
|
|
66
|
-
return lodashOrderBy(items, info.sorters, info.orders);
|
|
40
|
+
if (0 === info.sorters.length) return items;
|
|
41
|
+
return orderBy(items, info.sorters, info.orders);
|
|
67
42
|
}
|
|
43
|
+
export { sortItems };
|
|
68
44
|
|
|
69
45
|
//# sourceMappingURL=sort.js.map
|
package/utils/sort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/sort.js","sources":["../../src/utils/sort.ts"],"sourcesContent":["import lodashOrderBy from \"lodash/orderBy.js\";\nimport WebinyError from \"@webiny/error\";\nimport type { FieldPlugin } from \"~/plugins/definitions/FieldPlugin.js\";\n\ninterface Info {\n sorters: string[];\n orders: (boolean | \"asc\" | \"desc\")[];\n}\n\ninterface Response {\n reverse: boolean;\n field: string;\n}\n\nconst extractSort = (sortBy: string, fields: FieldPlugin[]): Response => {\n const result = sortBy.split(\"_\");\n if (result.length !== 2) {\n throw new WebinyError(\n \"Problem in determining the sorting for the entry items.\",\n \"SORT_ERROR\",\n {\n sortBy\n }\n );\n }\n const [field, order] = result;\n\n if (!field) {\n throw new WebinyError(\"Sorting field does not exist.\", \"SORTING_FIELD_ERROR\", {\n field,\n order,\n fields\n });\n }\n const fieldPlugin = fields.find(f => f.getField() === field);\n const isSortable = fieldPlugin ? fieldPlugin.isSortable() : true;\n if (isSortable === false) {\n throw new WebinyError(`Cannot sort by given field: \"${field}\".`, \"UNSUPPORTED_SORT_ERROR\", {\n fields,\n field\n });\n }\n\n return {\n field,\n reverse: order.toUpperCase() === \"DESC\"\n };\n};\n\ninterface Params<T> {\n /**\n * The items we are sorting.\n */\n items: T[];\n /**\n * Sort options. For example: [\"id_ASC\"]\n */\n sort?: string[];\n /**\n * Fields we can sort by.\n */\n fields?: FieldPlugin[];\n}\n\nexport function sortItems<T = any>(params: Params<T>): T[] {\n const { items, sort: initialSort = [], fields = [] } = params;\n /**\n * Skip sorting if nothing was passed to sort by or nothing to sort.\n */\n if (items.length <= 1 || Array.isArray(initialSort) === false || initialSort.length === 0) {\n return items;\n }\n\n const info: Info = {\n sorters: [],\n orders: []\n };\n\n for (const sort of initialSort) {\n /**\n * Possibly empty array item was passed.\n */\n if (!sort) {\n continue;\n }\n const { field, reverse } = extractSort(sort, fields);\n const fieldPlugin = fields.find(f => f.getField() === field);\n const path = fieldPlugin ? fieldPlugin.getPath() : field;\n\n info.sorters.push(path);\n info.orders.push(reverse === true ? \"desc\" : \"asc\");\n }\n\n if (info.sorters.length === 0) {\n return items;\n }\n\n return lodashOrderBy(items, info.sorters, info.orders);\n}\n"],"names":["extractSort","sortBy","fields","result","WebinyError","field","order","fieldPlugin","f","isSortable","sortItems","params","items","initialSort","Array","info","sort","reverse","path","lodashOrderBy"],"mappings":";;AAcA,MAAMA,cAAc,CAACC,QAAgBC;IACjC,MAAMC,SAASF,OAAO,KAAK,CAAC;IAC5B,IAAIE,AAAkB,MAAlBA,OAAO,MAAM,EACb,MAAM,IAAIC,MACN,2DACA,cACA;QACIH;IACJ;IAGR,MAAM,CAACI,OAAOC,MAAM,GAAGH;IAEvB,IAAI,CAACE,OACD,MAAM,IAAID,MAAY,iCAAiC,uBAAuB;QAC1EC;QACAC;QACAJ;IACJ;IAEJ,MAAMK,cAAcL,OAAO,IAAI,CAACM,CAAAA,IAAKA,EAAE,QAAQ,OAAOH;IACtD,MAAMI,aAAaF,cAAcA,YAAY,UAAU,KAAK;IAC5D,IAAIE,AAAe,UAAfA,YACA,MAAM,IAAIL,MAAY,CAAC,6BAA6B,EAAEC,MAAM,EAAE,CAAC,EAAE,0BAA0B;QACvFH;QACAG;IACJ;IAGJ,OAAO;QACHA;QACA,SAASC,AAAwB,WAAxBA,MAAM,WAAW;IAC9B;AACJ;AAiBO,SAASI,UAAmBC,MAAiB;IAChD,MAAM,EAAEC,KAAK,EAAE,MAAMC,cAAc,EAAE,EAAEX,SAAS,EAAE,EAAE,GAAGS;IAIvD,IAAIC,MAAM,MAAM,IAAI,KAAKE,AAA+B,UAA/BA,MAAM,OAAO,CAACD,gBAA0BA,AAAuB,MAAvBA,YAAY,MAAM,EAC/E,OAAOD;IAGX,MAAMG,OAAa;QACf,SAAS,EAAE;QACX,QAAQ,EAAE;IACd;IAEA,KAAK,MAAMC,QAAQH,YAAa;QAI5B,IAAI,CAACG,MACD;QAEJ,MAAM,EAAEX,KAAK,EAAEY,OAAO,EAAE,GAAGjB,YAAYgB,MAAMd;QAC7C,MAAMK,cAAcL,OAAO,IAAI,CAACM,CAAAA,IAAKA,EAAE,QAAQ,OAAOH;QACtD,MAAMa,OAAOX,cAAcA,YAAY,OAAO,KAAKF;QAEnDU,KAAK,OAAO,CAAC,IAAI,CAACG;QAClBH,KAAK,MAAM,CAAC,IAAI,CAACE,AAAY,SAAZA,UAAmB,SAAS;IACjD;IAEA,IAAIF,AAAwB,MAAxBA,KAAK,OAAO,CAAC,MAAM,EACnB,OAAOH;IAGX,OAAOO,QAAcP,OAAOG,KAAK,OAAO,EAAEA,KAAK,MAAM;AACzD"}
|
package/utils/table/Table.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { Table
|
|
1
|
+
import { Table } from "../../toolbox.js";
|
|
2
2
|
import { createTableWriteBatch } from "./TableWriteBatch.js";
|
|
3
3
|
import { createTableReadBatch } from "./TableReadBatch.js";
|
|
4
4
|
import { scan } from "../scan.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
class Table_Table {
|
|
6
|
+
constructor(params){
|
|
7
|
+
this.table = new Table(params);
|
|
8
|
+
}
|
|
9
|
+
createWriter() {
|
|
10
|
+
return createTableWriteBatch({
|
|
11
|
+
table: this.table
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
createReader() {
|
|
15
|
+
return createTableReadBatch({
|
|
16
|
+
table: this.table
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async scan(params) {
|
|
20
|
+
return scan({
|
|
21
|
+
...params,
|
|
22
|
+
table: this.table
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
25
|
}
|
|
26
|
+
export { Table_Table as Table };
|
|
26
27
|
|
|
27
28
|
//# sourceMappingURL=Table.js.map
|
package/utils/table/Table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/table/Table.js","sources":["../../../src/utils/table/Table.ts"],"sourcesContent":["import type { TableConstructor } from \"~/toolbox.js\";\nimport { Table as BaseTable } from \"~/toolbox.js\";\nimport type {\n ITable,\n ITableReadBatch,\n ITableScanParams,\n ITableScanResponse,\n ITableWriteBatch\n} from \"./types.js\";\nimport { createTableWriteBatch } from \"./TableWriteBatch.js\";\nimport { createTableReadBatch } from \"./TableReadBatch.js\";\nimport { scan } from \"../scan.js\";\n\nexport class Table<\n Name extends string = string,\n PartitionKey extends string = string,\n SortKey extends string = string\n> implements ITable<Name, PartitionKey, SortKey> {\n public readonly table: BaseTable<Name, PartitionKey, SortKey>;\n\n public constructor(params: TableConstructor<Name, PartitionKey, SortKey>) {\n this.table = new BaseTable(params);\n }\n\n public createWriter(): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.table\n });\n }\n\n public createReader(): ITableReadBatch {\n return createTableReadBatch({\n table: this.table\n });\n }\n\n public async scan<T>(params: ITableScanParams): Promise<ITableScanResponse<T>> {\n return scan<T>({\n ...params,\n table: this.table\n });\n }\n}\n"],"names":["Table","params","BaseTable","createTableWriteBatch","createTableReadBatch","scan"],"mappings":";;;;AAaO,MAAMA;IAOT,YAAmBC,MAAqD,CAAE;QACtE,IAAI,CAAC,KAAK,GAAG,IAAIC,MAAUD;IAC/B;IAEO,eAAiC;QACpC,OAAOE,sBAAsB;YACzB,OAAO,IAAI,CAAC,KAAK;QACrB;IACJ;IAEO,eAAgC;QACnC,OAAOC,qBAAqB;YACxB,OAAO,IAAI,CAAC,KAAK;QACrB;IACJ;IAEA,MAAa,KAAQH,MAAwB,EAAkC;QAC3E,OAAOI,KAAQ;YACX,GAAGJ,MAAM;YACT,OAAO,IAAI,CAAC,KAAK;QACrB;IACJ;AACJ"}
|
|
@@ -1,54 +1,46 @@
|
|
|
1
1
|
import { batchReadAll } from "../batch/batchRead.js";
|
|
2
2
|
import { createEntityReadBatchBuilder } from "../entity/EntityReadBatchBuilder.js";
|
|
3
3
|
import { WebinyError } from "@webiny/error";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
get total() {
|
|
11
|
-
return this._items.length;
|
|
12
|
-
}
|
|
13
|
-
get items() {
|
|
14
|
-
return Array.from(this._items);
|
|
15
|
-
}
|
|
16
|
-
get(entity, input) {
|
|
17
|
-
const builder = this.getBuilder(entity);
|
|
18
|
-
const items = Array.isArray(input) ? input : [input];
|
|
19
|
-
for (const item of items) {
|
|
20
|
-
/**
|
|
21
|
-
* We cannot read from two tables at the same time, so check for that.
|
|
22
|
-
*/
|
|
23
|
-
if (this.table.name !== entity.table.name) {
|
|
24
|
-
throw new WebinyError(`Cannot read from two different tables at the same time.`);
|
|
25
|
-
}
|
|
26
|
-
this._items.push(builder.get(item));
|
|
4
|
+
class TableReadBatch {
|
|
5
|
+
constructor(params){
|
|
6
|
+
this._items = [];
|
|
7
|
+
this.builders = new Map();
|
|
8
|
+
this.table = params.table;
|
|
27
9
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (this._items.length === 0) {
|
|
31
|
-
return [];
|
|
10
|
+
get total() {
|
|
11
|
+
return this._items.length;
|
|
32
12
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
get items() {
|
|
14
|
+
return Array.from(this._items);
|
|
15
|
+
}
|
|
16
|
+
get(entity, input) {
|
|
17
|
+
const builder = this.getBuilder(entity);
|
|
18
|
+
const items = Array.isArray(input) ? input : [
|
|
19
|
+
input
|
|
20
|
+
];
|
|
21
|
+
for (const item of items){
|
|
22
|
+
if (this.table.name !== entity.table.name) throw new WebinyError("Cannot read from two different tables at the same time.");
|
|
23
|
+
this._items.push(builder.get(item));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async execute() {
|
|
27
|
+
if (0 === this._items.length) return [];
|
|
28
|
+
const items = Array.from(this._items);
|
|
29
|
+
this._items.length = 0;
|
|
30
|
+
return await batchReadAll({
|
|
31
|
+
items,
|
|
32
|
+
table: this.table
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
getBuilder(entity) {
|
|
36
|
+
const builder = this.builders.get(entity.name);
|
|
37
|
+
if (builder) return builder;
|
|
38
|
+
const newBuilder = createEntityReadBatchBuilder(entity);
|
|
39
|
+
this.builders.set(entity.name, newBuilder);
|
|
40
|
+
return newBuilder;
|
|
44
41
|
}
|
|
45
|
-
const newBuilder = createEntityReadBatchBuilder(entity);
|
|
46
|
-
this.builders.set(entity.name, newBuilder);
|
|
47
|
-
return newBuilder;
|
|
48
|
-
}
|
|
49
42
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
43
|
+
const createTableReadBatch = (params)=>new TableReadBatch(params);
|
|
44
|
+
export { TableReadBatch, createTableReadBatch };
|
|
53
45
|
|
|
54
46
|
//# sourceMappingURL=TableReadBatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/table/TableReadBatch.js","sources":["../../../src/utils/table/TableReadBatch.ts"],"sourcesContent":["import type { Entity, TableDef } from \"~/toolbox.js\";\nimport type {\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse\n} from \"~/utils/entity/types.js\";\nimport { batchReadAll } from \"~/utils/batch/batchRead.js\";\nimport { createEntityReadBatchBuilder } from \"~/utils/entity/EntityReadBatchBuilder.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { ITableReadBatch, ITableReadBatchKey } from \"./types.js\";\n\nexport interface ITableReadBatchParams {\n table: TableDef;\n}\n\nexport class TableReadBatch implements ITableReadBatch {\n private readonly table: TableDef;\n\n private readonly _items: IEntityReadBatchBuilderGetResponse[] = [];\n private readonly builders: Map<string, IEntityReadBatchBuilder> = new Map();\n\n public constructor(params: ITableReadBatchParams) {\n this.table = params.table;\n }\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 get(entity: Entity, input: ITableReadBatchKey): void {\n const builder = this.getBuilder(entity);\n\n const items = Array.isArray(input) ? input : [input];\n for (const item of items) {\n /**\n * We cannot read from two tables at the same time, so check for that.\n */\n if (this.table.name !== entity.table!.name) {\n throw new WebinyError(`Cannot read from two different tables at the same time.`);\n }\n\n this._items.push(builder.get(item));\n }\n }\n\n public async execute<T = GenericRecord>(): Promise<T[]> {\n if (this._items.length === 0) {\n return [];\n }\n const items = Array.from(this._items);\n this._items.length = 0;\n return await batchReadAll<T>({\n items,\n table: this.table\n });\n }\n\n private getBuilder(entity: Entity): IEntityReadBatchBuilder {\n const builder = this.builders.get(entity.name);\n if (builder) {\n return builder;\n }\n const newBuilder = createEntityReadBatchBuilder(entity);\n this.builders.set(entity.name, newBuilder);\n return newBuilder;\n }\n}\n\nexport const createTableReadBatch = (params: ITableReadBatchParams): ITableReadBatch => {\n return new TableReadBatch(params);\n};\n"],"names":["TableReadBatch","params","Map","Array","entity","input","builder","items","item","WebinyError","batchReadAll","newBuilder","createEntityReadBatchBuilder","createTableReadBatch"],"mappings":";;;AAeO,MAAMA;IAMT,YAAmBC,MAA6B,CAAE;aAHjC,MAAM,GAAyC,EAAE;aACjD,QAAQ,GAAyC,IAAIC;QAGlE,IAAI,CAAC,KAAK,GAAGD,OAAO,KAAK;IAC7B;IAEA,IAAW,QAAgB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM;IAC7B;IAEA,IAAW,QAA8C;QACrD,OAAOE,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;IACjC;IAEO,IAAIC,MAAc,EAAEC,KAAyB,EAAQ;QACxD,MAAMC,UAAU,IAAI,CAAC,UAAU,CAACF;QAEhC,MAAMG,QAAQJ,MAAM,OAAO,CAACE,SAASA,QAAQ;YAACA;SAAM;QACpD,KAAK,MAAMG,QAAQD,MAAO;YAItB,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAKH,OAAO,KAAK,CAAE,IAAI,EACtC,MAAM,IAAIK,YAAY;YAG1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAACH,QAAQ,GAAG,CAACE;QACjC;IACJ;IAEA,MAAa,UAA2C;QACpD,IAAI,AAAuB,MAAvB,IAAI,CAAC,MAAM,CAAC,MAAM,EAClB,OAAO,EAAE;QAEb,MAAMD,QAAQJ,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;QACpC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG;QACrB,OAAO,MAAMO,aAAgB;YACzBH;YACA,OAAO,IAAI,CAAC,KAAK;QACrB;IACJ;IAEQ,WAAWH,MAAc,EAA2B;QACxD,MAAME,UAAU,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACF,OAAO,IAAI;QAC7C,IAAIE,SACA,OAAOA;QAEX,MAAMK,aAAaC,6BAA6BR;QAChD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACA,OAAO,IAAI,EAAEO;QAC/B,OAAOA;IACX;AACJ;AAEO,MAAME,uBAAuB,CAACZ,SAC1B,IAAID,eAAeC"}
|
|
@@ -1,61 +1,52 @@
|
|
|
1
1
|
import { batchWriteAll } from "../batch/batchWrite.js";
|
|
2
2
|
import { createEntityWriteBatchBuilder } from "../entity/EntityWriteBatchBuilder.js";
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
const builder = this.builders.get(entity.name);
|
|
49
|
-
if (builder) {
|
|
50
|
-
return builder;
|
|
51
|
-
}
|
|
52
|
-
const newBuilder = createEntityWriteBatchBuilder(entity);
|
|
53
|
-
this.builders.set(entity.name, newBuilder);
|
|
54
|
-
return newBuilder;
|
|
55
|
-
}
|
|
3
|
+
class TableWriteBatch {
|
|
4
|
+
get total() {
|
|
5
|
+
return this._items.length;
|
|
6
|
+
}
|
|
7
|
+
get items() {
|
|
8
|
+
return Array.from(this._items);
|
|
9
|
+
}
|
|
10
|
+
constructor(params){
|
|
11
|
+
this._items = [];
|
|
12
|
+
this.builders = new Map();
|
|
13
|
+
this.table = params.table;
|
|
14
|
+
if (!params.items?.length) return;
|
|
15
|
+
this._items.push(...params.items);
|
|
16
|
+
}
|
|
17
|
+
put(entity, item) {
|
|
18
|
+
const builder = this.getBuilder(entity);
|
|
19
|
+
this._items.push(builder.put(item));
|
|
20
|
+
}
|
|
21
|
+
delete(entity, item) {
|
|
22
|
+
const builder = this.getBuilder(entity);
|
|
23
|
+
this._items.push(builder.delete(item));
|
|
24
|
+
}
|
|
25
|
+
combine(items) {
|
|
26
|
+
return createTableWriteBatch({
|
|
27
|
+
table: this.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.table
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
getBuilder(entity) {
|
|
41
|
+
if (!entity.name) throw new Error("Entity must have a name.");
|
|
42
|
+
const builder = this.builders.get(entity.name);
|
|
43
|
+
if (builder) return builder;
|
|
44
|
+
const newBuilder = createEntityWriteBatchBuilder(entity);
|
|
45
|
+
this.builders.set(entity.name, newBuilder);
|
|
46
|
+
return newBuilder;
|
|
47
|
+
}
|
|
56
48
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
49
|
+
const createTableWriteBatch = (params)=>new TableWriteBatch(params);
|
|
50
|
+
export { TableWriteBatch, createTableWriteBatch };
|
|
60
51
|
|
|
61
52
|
//# sourceMappingURL=TableWriteBatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/table/TableWriteBatch.js","sources":["../../../src/utils/table/TableWriteBatch.ts"],"sourcesContent":["import type { Entity, TableDef } from \"~/toolbox.js\";\nimport type {\n BatchWriteItem,\n BatchWriteResult,\n IDeleteBatchItem,\n IPutBatchItem\n} from \"~/utils/batch/types.js\";\nimport type { IEntityWriteBatchBuilder } from \"~/utils/entity/types.js\";\nimport { batchWriteAll } from \"~/utils/batch/batchWrite.js\";\nimport { createEntityWriteBatchBuilder } from \"~/utils/entity/EntityWriteBatchBuilder.js\";\nimport type { ITableWriteBatch } from \"./types.js\";\n\nexport interface ITableWriteBatchParams {\n table: TableDef;\n items?: BatchWriteItem[];\n}\n\nexport class TableWriteBatch implements ITableWriteBatch {\n private readonly table: TableDef;\n private readonly _items: BatchWriteItem[] = [];\n private readonly builders: Map<string, IEntityWriteBatchBuilder> = new Map();\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: ITableWriteBatchParams) {\n this.table = params.table;\n if (!params.items?.length) {\n return;\n }\n this._items.push(...params.items);\n }\n\n public put(entity: Entity, item: IPutBatchItem): void {\n const builder = this.getBuilder(entity);\n this._items.push(builder.put(item));\n }\n\n public delete(entity: Entity, item: IDeleteBatchItem): void {\n const builder = this.getBuilder(entity);\n this._items.push(builder.delete(item));\n }\n\n public combine(items: BatchWriteItem[]): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.table,\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.table\n });\n }\n\n private getBuilder(entity: Entity): IEntityWriteBatchBuilder {\n if (!entity.name) {\n throw new Error(\"Entity must have a name.\");\n }\n const builder = this.builders.get(entity.name);\n if (builder) {\n return builder;\n }\n const newBuilder = createEntityWriteBatchBuilder(entity);\n this.builders.set(entity.name, newBuilder);\n return newBuilder;\n }\n}\n\nexport const createTableWriteBatch = (params: ITableWriteBatchParams): ITableWriteBatch => {\n return new TableWriteBatch(params);\n};\n"],"names":["TableWriteBatch","Array","params","Map","entity","item","builder","items","createTableWriteBatch","batchWriteAll","Error","newBuilder","createEntityWriteBatchBuilder"],"mappings":";;AAiBO,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,MAA8B,CAAE;aAXlC,MAAM,GAAqB,EAAE;aAC7B,QAAQ,GAA0C,IAAIC;QAWnE,IAAI,CAAC,KAAK,GAAGD,OAAO,KAAK;QACzB,IAAI,CAACA,OAAO,KAAK,EAAE,QACf;QAEJ,IAAI,CAAC,MAAM,CAAC,IAAI,IAAIA,OAAO,KAAK;IACpC;IAEO,IAAIE,MAAc,EAAEC,IAAmB,EAAQ;QAClD,MAAMC,UAAU,IAAI,CAAC,UAAU,CAACF;QAChC,IAAI,CAAC,MAAM,CAAC,IAAI,CAACE,QAAQ,GAAG,CAACD;IACjC;IAEO,OAAOD,MAAc,EAAEC,IAAsB,EAAQ;QACxD,MAAMC,UAAU,IAAI,CAAC,UAAU,CAACF;QAChC,IAAI,CAAC,MAAM,CAAC,IAAI,CAACE,QAAQ,MAAM,CAACD;IACpC;IAEO,QAAQE,KAAuB,EAAoB;QACtD,OAAOC,sBAAsB;YACzB,OAAO,IAAI,CAAC,KAAK;YACjB,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,QAAQN,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;QACpC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG;QACrB,OAAO,MAAMQ,cAAc;YACvBF;YACA,OAAO,IAAI,CAAC,KAAK;QACrB;IACJ;IAEQ,WAAWH,MAAc,EAA4B;QACzD,IAAI,CAACA,OAAO,IAAI,EACZ,MAAM,IAAIM,MAAM;QAEpB,MAAMJ,UAAU,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACF,OAAO,IAAI;QAC7C,IAAIE,SACA,OAAOA;QAEX,MAAMK,aAAaC,8BAA8BR;QACjD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACA,OAAO,IAAI,EAAEO;QAC/B,OAAOA;IACX;AACJ;AAEO,MAAMH,wBAAwB,CAACN,SAC3B,IAAIF,gBAAgBE"}
|
package/utils/table/index.js
CHANGED
package/utils/table/types.js
CHANGED
package/exports/api/db.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilter","ValueFilterRegistry","FilterUtil"],"sources":["db.ts"],"sourcesContent":["export { ValueFilter, ValueFilterRegistry } from \"~/feature/ValueFilter/index.js\";\nexport { FilterUtil } from \"~/feature/FilterUtil/index.js\";\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,mBAAmB;AACzC,SAASC,UAAU","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["FilterUtil","FilterUtilFeature"],"sources":["index.ts"],"sourcesContent":["export { FilterUtil } from \"./abstractions/FilterUtil.js\";\nexport { FilterUtilFeature } from \"./feature.js\";\n"],"mappings":"AAAA,SAASA,UAAU;AACnB,SAASC,iBAAiB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilter","ValueFilterRegistry","ValueFilterFeature"],"sources":["index.ts"],"sourcesContent":["export { ValueFilter } from \"./abstractions/ValueFilter.js\";\nexport { ValueFilterRegistry } from \"./abstractions/ValueFilterRegistry.js\";\nexport { ValueFilterFeature } from \"./feature.js\";\n"],"mappings":"AAAA,SAASA,WAAW;AACpB,SAASC,mBAAmB;AAC5B,SAASC,kBAAkB","ignoreList":[]}
|
package/plugins/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./definitions/assignFields.js\";\nexport * from \"./definitions/DateTimeTransformPlugin.js\";\nexport * from \"./definitions/FieldPlugin.js\";\nexport * from \"./definitions/TimeTransformPlugin.js\";\nexport * from \"./definitions/ValueTransformPlugin.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/store/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntity, IGlobalEntityAttributes } from \"~/utils/index.js\";\n\nexport interface IStoreEntityValue {\n key: string;\n value: string;\n}\n\nexport type IStoreEntity = IEntity<IGlobalEntityAttributes<IStoreEntityValue>>;\n"],"mappings":"","ignoreList":[]}
|
package/toolbox.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Entity","Table"],"sources":["toolbox.ts"],"sourcesContent":["export { Entity, Table } from \"dynamodb-toolbox\";\n\nimport { Entity, Table } from \"dynamodb-toolbox\";\n\nexport type ScanOptions = NonNullable<Parameters<Entity[\"scan\"]>[0]>;\nexport type DynamoDBTypes =\n | \"string\"\n | \"boolean\"\n | \"number\"\n | \"bigint\"\n | \"list\"\n | \"map\"\n | \"binary\"\n | \"set\";\n\ntype Key = string | number | symbol;\n\nexport type TableDef = Table<string, Key, Key | null>;\nexport type TableConstructor<\n A extends string,\n B extends Key,\n C extends Key\n> = ConstructorParameters<typeof Table<A, B, C>>[0];\n\n// Types previously imported from dynamodb-toolbox internals.\n// Declared locally to avoid deep path imports blocked by moduleResolution: bundler.\nexport type Readonly<T> = T extends ((...args: any[]) => any) | undefined\n ? T\n : T extends object\n ? { readonly [P in keyof T]: Readonly<T[P]> }\n : T;\n\nexport type AttributeDefinition =\n | DynamoDBTypes\n | Partial<{\n type: DynamoDBTypes;\n coerce: boolean;\n default: unknown;\n dependsOn: string | string[];\n required: boolean | \"always\";\n hidden: boolean;\n prefix: string;\n suffix: string;\n delimiter: string;\n map: string;\n alias: string;\n onlyMap: boolean;\n partitionKey: boolean;\n sortKey: boolean;\n [key: string]: unknown;\n }>\n | [string, number]\n | [string, number, string]\n | [string, number, Record<string, unknown>];\n\nexport type AttributeDefinitions = Record<PropertyKey, AttributeDefinition>;\n\nexport interface EntityConstructor<\n T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>\n> {\n name: string;\n attributes: T;\n table?: TableDef;\n timestamps?: boolean;\n createdAlias?: string;\n modifiedAlias?: string;\n typeAlias?: string;\n typeHidden?: boolean;\n autoExecute?: boolean;\n autoParse?: boolean;\n}\n\nexport interface EntityQueryOptions {\n index?: string;\n limit?: number;\n reverse?: boolean;\n consistent?: boolean;\n capacity?: \"indexes\" | \"total\" | \"none\";\n select?: \"all_attributes\" | \"all_projected_attributes\" | \"count\" | \"specific_attributes\";\n eq?: string | number;\n lt?: string | number;\n lte?: string | number;\n gt?: string | number;\n gte?: string | number;\n between?: [string, string] | [number, number] | [bigint, bigint];\n beginsWith?: string;\n startKey?: Record<string, unknown>;\n filters?: Record<string, unknown>;\n attributes?: string[];\n execute?: boolean;\n parse?: boolean;\n}\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,KAAK,QAAQ,kBAAkB;;AAwBhD;AACA","ignoreList":[]}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/**\n * We use this definition to search for a value in any given field that was passed.\n * It works as an \"OR\" condition.\n */\nexport interface DynamoDbContainsFilter {\n fields: string[];\n value: string;\n}\n\nexport interface ProcessStatementArgsParam {\n expression: string;\n attributeNames: Record<string, any>;\n attributeValues: Record<string, any>;\n}\nexport interface ProcessStatementQueryParam {\n [key: string]: any;\n}\nexport interface ProcessStatementParams {\n args: ProcessStatementArgsParam;\n query: ProcessStatementQueryParam;\n}\n\nexport interface ProcessStatementCallable {\n (params: ProcessStatementParams): void;\n}\n\nexport interface Query {\n [key: string]: string;\n}\nexport interface QueryKeyField {\n name: string;\n}\nexport interface QueryKey {\n fields: QueryKeyField[];\n primary?: boolean;\n unique?: boolean;\n name: string;\n}\nexport type QueryKeys = QueryKey[];\n\nexport type QuerySort = Record<string, -1 | 1>;\n\nexport type DbItem<TData extends Record<string, any> = Record<string, any>> = {\n PK: string;\n SK: string;\n GSI1_PK: string;\n GSI1_SK: string;\n TYPE: string;\n data: TData;\n};\n"],"mappings":"","ignoreList":[]}
|
package/utils/batch/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./batchRead.js\";\nexport * from \"./batchWrite.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
|
package/utils/batch/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { WriteRequest } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface BatchWriteResponse {\n next?: () => Promise<BatchWriteResponse>;\n $metadata: {\n httpStatusCode: number;\n requestId: string;\n attempts: number;\n totalRetryDelay: number;\n };\n UnprocessedItems?: {\n [table: string]: WriteRequest[];\n };\n}\n\nexport type BatchWriteResult = BatchWriteResponse[];\n\nexport interface IDeleteBatchItem {\n PK: string;\n SK: string;\n}\n\nexport type IPutBatchItem<T = GenericRecord> = {\n PK: string;\n SK: string;\n} & T;\n\nexport interface BatchWriteItem {\n [key: string]: WriteRequest;\n}\n\nexport interface IReadBatchItem {\n PK: string;\n SK: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Entity.js\";\nexport * from \"./EntityReadBatch.js\";\nexport * from \"./EntityReadBatchBuilder.js\";\nexport * from \"./EntityWriteBatch.js\";\nexport * from \"./EntityWriteBatchBuilder.js\";\nexport * from \"./getEntity.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["queryAll","queryAllClean","queryOne","queryOneClean","queryPerPage"],"sources":["types.ts"],"sourcesContent":["import type { Entity as BaseEntity } from \"dynamodb-toolbox\";\nimport type {\n BatchWriteItem,\n BatchWriteResult,\n IDeleteBatchItem,\n IPutBatchItem\n} from \"~/utils/batch/types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { TableDef } from \"~/toolbox.js\";\nimport type { ITableWriteBatch } from \"~/utils/table/types.js\";\nimport type { IPutParamsItem, put } from \"~/utils/put.js\";\nimport {\n queryAll,\n queryAllClean,\n type QueryAllParams,\n queryOne,\n queryOneClean,\n type QueryOneParams\n} from \"~/utils/query.js\";\nimport type { get, getClean, GetRecordParamsKeys } from \"~/utils/get.js\";\nimport type { deleteItem, IDeleteItemKeys } from \"~/utils/delete.js\";\nimport type { batchReadAll, BatchReadItem } from \"~/utils/batch/batchRead.js\";\nimport type { IEntityWriteBatchParams } from \"./EntityWriteBatch.js\";\nimport type { IEntityReadBatchParams } from \"./EntityReadBatch.js\";\nimport { queryPerPage } from \"~/utils/index.js\";\n\nexport type IEntityQueryOneParams = Omit<QueryOneParams, \"entity\">;\n\nexport type IEntityQueryAllParams = Omit<QueryAllParams, \"entity\">;\nexport type IEntityQueryPerPageParams = Omit<QueryAllParams, \"entity\">;\n\nexport interface IEntityCreateEntityWriterParams<T = GenericRecord> extends Omit<\n IEntityWriteBatchParams<T>,\n \"entity\"\n> {}\nexport interface IEntityCreateEntityReaderParams extends Omit<IEntityReadBatchParams, \"entity\"> {}\n\nexport type IEntityPutResult = ReturnType<typeof put>;\nexport type IEntityGetResult<T> = ReturnType<typeof get<T>>;\nexport type IEntityGetCleanResult<T> = ReturnType<typeof getClean<T>>;\nexport type IEntityDeleteResult = ReturnType<typeof deleteItem>;\nexport type IEntityQueryOneResult<T> = ReturnType<typeof queryOne<T>>;\nexport type IEntityQueryOneCleanResult<T> = ReturnType<typeof queryOneClean<T>>;\nexport type IEntityQueryAllResult<T> = ReturnType<typeof queryAll<T>>;\nexport type IEntityQueryAllCleanResult<T> = ReturnType<typeof queryAllClean<T>>;\nexport type IEntityQueryPerPageResult<T> = ReturnType<typeof queryPerPage<T>>;\n\nexport interface IEntity<T extends GenericRecord = GenericRecord> {\n readonly entity: BaseEntity;\n readonly name: string;\n readonly table: TableDef;\n createEntityReader(params?: IEntityCreateEntityReaderParams): IEntityReadBatch<T>;\n createEntityWriter(params?: IEntityCreateEntityWriterParams<T>): IEntityWriteBatch<T>;\n createTableWriter(): ITableWriteBatch;\n put(item: IPutParamsItem<T>): IEntityPutResult;\n get<R extends T = T>(keys: GetRecordParamsKeys): IEntityGetResult<R>;\n getClean<R extends T = T>(keys: GetRecordParamsKeys): IEntityGetCleanResult<R>;\n delete(keys: IDeleteItemKeys): IEntityDeleteResult;\n queryOne<R extends T = T>(params: IEntityQueryOneParams): IEntityQueryOneResult<R>;\n queryOneClean<R extends T = T>(params: IEntityQueryOneParams): IEntityQueryOneCleanResult<R>;\n queryAll<R extends T = T>(params: IEntityQueryAllParams): IEntityQueryAllResult<R>;\n queryAllClean<R extends T = T>(params: IEntityQueryAllParams): IEntityQueryAllCleanResult<R>;\n queryPerPage<R extends T = T>(params: IEntityQueryPerPageParams): IEntityQueryPerPageResult<R>;\n}\n\nexport interface IEntityWriteBatchBuilder {\n // readonly entity: Entity;\n put<T extends Record<string, any>>(item: IPutBatchItem<T>): BatchWriteItem;\n delete(item: IDeleteBatchItem): BatchWriteItem;\n}\n\nexport interface IEntityWriteBatch<T = GenericRecord> {\n readonly total: number;\n readonly items: BatchWriteItem[];\n\n put(item: IPutBatchItem<T>): void;\n delete(item: IDeleteBatchItem): void;\n execute(): Promise<BatchWriteResult>;\n combine(items: BatchWriteItem[]): ITableWriteBatch;\n}\n\nexport interface IEntityReadBatchKey {\n PK: string;\n SK: string;\n}\n\nexport interface IEntityReadBatch<T = GenericRecord> {\n readonly total: number;\n readonly items: BatchReadItem[];\n get(input: IEntityReadBatchKey | IEntityReadBatchKey[]): void;\n execute(): ReturnType<typeof batchReadAll<T>>;\n}\n\nexport interface IEntityReadBatchBuilderGetResponse {\n Table: TableDef;\n Key: IEntityReadBatchKey;\n}\n\nexport interface IEntityReadBatchBuilder {\n get(item: IEntityReadBatchKey): IEntityReadBatchBuilderGetResponse;\n}\n"],"mappings":"AAWA,SACIA,QAAQ,EACRC,aAAa,EAEbC,QAAQ,EACRC,aAAa;AAQjB,SAASC,YAAY","ignoreList":[]}
|
package/utils/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["decodeCursor","encodeCursor"],"sources":["index.ts"],"sourcesContent":["export * from \"./cleanup.js\";\nexport * from \"./createEntity.js\";\nexport * from \"./createTable.js\";\nexport { decodeCursor, encodeCursor } from \"./cursor.js\";\nexport * from \"./get.js\";\nexport * from \"./delete.js\";\nexport * from \"./put.js\";\nexport * from \"./query.js\";\nexport * from \"./scan.js\";\nexport * from \"./sort.js\";\nexport * from \"./batch/index.js\";\nexport * from \"./entity/index.js\";\nexport * from \"./table/index.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,YAAY;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/utils/table/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Table.js\";\nexport * from \"./TableReadBatch.js\";\nexport * from \"./TableWriteBatch.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA","ignoreList":[]}
|
package/utils/table/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n BatchWriteItem,\n BatchWriteResult,\n IDeleteBatchItem,\n IPutBatchItem\n} from \"~/utils/batch/types.js\";\nimport type { BaseScanParams, ScanResponse } from \"../scan.js\";\nimport type { Entity } from \"~/toolbox.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { Table } from \"~/toolbox.js\";\n\nexport type ITableScanParams = BaseScanParams;\n\nexport type ITableScanResponse<T> = ScanResponse<T>;\n\nexport interface ITable<\n Name extends string = string,\n PK extends string = string,\n SK extends string = string\n> {\n table: Table<Name, PK, SK>;\n createWriter(): ITableWriteBatch;\n createReader(): ITableReadBatch;\n scan<T>(params: ITableScanParams): Promise<ITableScanResponse<T>>;\n}\n\nexport interface ITableWriteBatch {\n readonly total: number;\n readonly items: BatchWriteItem[];\n put(entity: Entity, item: IPutBatchItem): void;\n delete(entity: Entity, item: IDeleteBatchItem): void;\n execute(): Promise<BatchWriteResult>;\n combine(items: BatchWriteItem[]): ITableWriteBatch;\n}\n\nexport interface ITableReadBatchKey {\n PK: string;\n SK: string;\n}\n\nexport interface ITableReadBatchBuilderGetResponse {\n Table: Table<string, string, string>;\n Key: ITableReadBatchKey;\n}\n\nexport interface ITableReadBatchKey {\n PK: string;\n SK: string;\n}\n\nexport interface ITableReadBatch {\n readonly total: number;\n readonly items: ITableReadBatchBuilderGetResponse[];\n get(entity: Entity, input: ITableReadBatchKey | ITableReadBatchKey[]): void;\n execute<T = GenericRecord>(): Promise<T[]>;\n}\n"],"mappings":"","ignoreList":[]}
|