@webiny/db-dynamodb 0.0.0-mt-2 → 0.0.0-unstable.085ff6572f
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/BatchProcess.d.ts +27 -11
- package/BatchProcess.js +10 -42
- package/BatchProcess.js.map +1 -0
- package/DynamoDbDriver.d.ts +19 -11
- package/DynamoDbDriver.js +11 -44
- package/DynamoDbDriver.js.map +1 -0
- package/QueryGenerator.d.ts +15 -13
- package/QueryGenerator.js +16 -31
- package/QueryGenerator.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +25 -4
- package/index.js.map +1 -0
- package/operators/comparison/beginsWith.js.map +1 -0
- package/operators/comparison/between.js.map +1 -0
- package/operators/comparison/eq.js +0 -2
- package/operators/comparison/eq.js.map +1 -0
- package/operators/comparison/gt.js.map +1 -0
- package/operators/comparison/gte.js.map +1 -0
- package/operators/comparison/lt.js.map +1 -0
- package/operators/comparison/lte.js.map +1 -0
- package/operators/index.js +1 -12
- package/operators/index.js.map +1 -0
- package/operators/logical/and.js +0 -5
- package/operators/logical/and.js.map +1 -0
- package/operators/logical/or.js +0 -5
- package/operators/logical/or.js.map +1 -0
- package/package.json +20 -19
- package/plugins/definitions/AttributePlugin.d.ts +3 -3
- package/plugins/definitions/AttributePlugin.js +1 -14
- package/plugins/definitions/AttributePlugin.js.map +1 -0
- package/plugins/definitions/DateTimeTransformPlugin.d.ts +2 -2
- package/plugins/definitions/DateTimeTransformPlugin.js +6 -20
- package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -0
- package/plugins/definitions/FieldPathPlugin.d.ts +3 -3
- package/plugins/definitions/FieldPathPlugin.js +3 -17
- package/plugins/definitions/FieldPathPlugin.js.map +1 -0
- package/plugins/definitions/FieldPlugin.d.ts +3 -3
- package/plugins/definitions/FieldPlugin.js +1 -17
- package/plugins/definitions/FieldPlugin.js.map +1 -0
- package/plugins/definitions/NumberTransformPlugin.d.ts +2 -2
- package/plugins/definitions/NumberTransformPlugin.js +3 -18
- package/plugins/definitions/NumberTransformPlugin.js.map +1 -0
- package/plugins/definitions/TimeTransformPlugin.d.ts +2 -2
- package/plugins/definitions/TimeTransformPlugin.js +3 -21
- package/plugins/definitions/TimeTransformPlugin.js.map +1 -0
- package/plugins/definitions/ValueFilterPlugin.d.ts +10 -10
- package/plugins/definitions/ValueFilterPlugin.js +1 -13
- package/plugins/definitions/ValueFilterPlugin.js.map +1 -0
- package/plugins/definitions/ValueTransformPlugin.d.ts +8 -8
- package/plugins/definitions/ValueTransformPlugin.js +3 -18
- package/plugins/definitions/ValueTransformPlugin.js.map +1 -0
- package/plugins/definitions/assignFields.js +1 -10
- package/plugins/definitions/assignFields.js.map +1 -0
- package/plugins/filters/andIn.d.ts +2 -2
- package/plugins/filters/andIn.js +4 -9
- package/plugins/filters/andIn.js.map +1 -0
- package/plugins/filters/between.d.ts +2 -2
- package/plugins/filters/between.js +4 -9
- package/plugins/filters/between.js.map +1 -0
- package/plugins/filters/contains.d.ts +2 -2
- package/plugins/filters/contains.js +3 -6
- package/plugins/filters/contains.js.map +1 -0
- package/plugins/filters/eq.d.ts +2 -2
- package/plugins/filters/eq.js +15 -4
- package/plugins/filters/eq.js.map +1 -0
- package/plugins/filters/fuzzy.d.ts +2 -2
- package/plugins/filters/fuzzy.js +9 -9
- package/plugins/filters/fuzzy.js.map +1 -0
- package/plugins/filters/gt.d.ts +2 -2
- package/plugins/filters/gt.js +3 -4
- package/plugins/filters/gt.js.map +1 -0
- package/plugins/filters/gte.d.ts +2 -2
- package/plugins/filters/gte.js +3 -4
- package/plugins/filters/gte.js.map +1 -0
- package/plugins/filters/in.d.ts +2 -2
- package/plugins/filters/in.js +4 -9
- package/plugins/filters/in.js.map +1 -0
- package/plugins/filters/index.js +3 -15
- package/plugins/filters/index.js.map +1 -0
- package/plugins/filters/lt.d.ts +2 -2
- package/plugins/filters/lt.js +3 -4
- package/plugins/filters/lt.js.map +1 -0
- package/plugins/filters/lte.d.ts +2 -2
- package/plugins/filters/lte.js +3 -4
- package/plugins/filters/lte.js.map +1 -0
- package/plugins/filters/startsWith.d.ts +3 -0
- package/plugins/filters/startsWith.js +29 -0
- package/plugins/filters/startsWith.js.map +1 -0
- package/plugins/index.js +1 -5
- package/plugins/index.js.map +1 -0
- package/statements/createKeyConditionExpressionArgs.d.ts +12 -9
- package/statements/createKeyConditionExpressionArgs.js +5 -8
- package/statements/createKeyConditionExpressionArgs.js.map +1 -0
- package/statements/processStatement.d.ts +3 -4
- package/statements/processStatement.js +7 -11
- package/statements/processStatement.js.map +1 -0
- package/types.d.ts +45 -8
- package/types.js.map +1 -0
- package/utils/attributes.d.ts +2 -2
- package/utils/attributes.js +3 -14
- package/utils/attributes.js.map +1 -0
- package/utils/batchRead.d.ts +4 -5
- package/utils/batchRead.js +43 -34
- package/utils/batchRead.js.map +1 -0
- package/utils/batchWrite.d.ts +4 -5
- package/utils/batchWrite.js +1 -7
- package/utils/batchWrite.js.map +1 -0
- package/utils/cleanup.d.ts +2 -2
- package/utils/cleanup.js +9 -27
- package/utils/cleanup.js.map +1 -0
- package/utils/createEntity.d.ts +14 -0
- package/utils/createEntity.js +60 -0
- package/utils/createEntity.js.map +1 -0
- package/utils/createTable.d.ts +7 -0
- package/utils/createTable.js +25 -0
- package/utils/createTable.js.map +1 -0
- package/utils/cursor.d.ts +2 -2
- package/utils/cursor.js +0 -6
- package/utils/cursor.js.map +1 -0
- package/utils/filter.d.ts +2 -2
- package/utils/filter.js +7 -43
- package/utils/filter.js.map +1 -0
- package/utils/get.d.ts +2 -2
- package/utils/get.js +0 -4
- package/utils/get.js.map +1 -0
- package/utils/index.d.ts +12 -0
- package/utils/index.js +137 -0
- package/utils/index.js.map +1 -0
- package/utils/listResponse.d.ts +1 -1
- package/utils/listResponse.js +7 -8
- package/utils/listResponse.js.map +1 -0
- package/utils/query.d.ts +8 -4
- package/utils/query.js +28 -36
- package/utils/query.js.map +1 -0
- package/utils/sort.d.ts +2 -2
- package/utils/sort.js +4 -23
- package/utils/sort.js.map +1 -0
- package/utils/table.js +1 -6
- package/utils/table.js.map +1 -0
- package/utils/documentClient.d.ts +0 -8
- package/utils/documentClient.js +0 -33
package/utils/attributes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "@webiny/api/types";
|
|
2
2
|
import { DefinitionParams } from "../plugins/definitions/AttributePlugin";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
/**
|
|
@@ -6,5 +6,5 @@ import { PluginsContainer } from "@webiny/plugins";
|
|
|
6
6
|
*
|
|
7
7
|
* @deprecated
|
|
8
8
|
*/
|
|
9
|
-
export declare const getExtraAttributes: (context:
|
|
9
|
+
export declare const getExtraAttributes: (context: Context, entity: string) => Record<string, DefinitionParams>;
|
|
10
10
|
export declare const getExtraAttributesFromPlugins: (plugins: PluginsContainer, entity: string) => Record<string, DefinitionParams>;
|
package/utils/attributes.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.getExtraAttributesFromPlugins = exports.getExtraAttributes = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
9
|
var _AttributePlugin = require("../plugins/definitions/AttributePlugin");
|
|
13
|
-
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
-
|
|
18
10
|
/**
|
|
19
11
|
* Will be removed in favor of directly assigning attributes to a certain entity when creating the storage operations.
|
|
20
12
|
*
|
|
@@ -23,13 +15,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
23
15
|
const getExtraAttributes = (context, entity) => {
|
|
24
16
|
return getExtraAttributesFromPlugins(context.plugins, entity);
|
|
25
17
|
};
|
|
26
|
-
|
|
27
18
|
exports.getExtraAttributes = getExtraAttributes;
|
|
28
|
-
|
|
29
19
|
const getExtraAttributesFromPlugins = (plugins, entity) => {
|
|
30
20
|
return plugins.byType(_AttributePlugin.AttributePlugin.type).filter(plugin => plugin.entity === entity).reduce((attributes, plugin) => {
|
|
31
|
-
return
|
|
21
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, attributes), plugin.getDefinition());
|
|
32
22
|
}, {});
|
|
33
23
|
};
|
|
34
|
-
|
|
35
24
|
exports.getExtraAttributesFromPlugins = getExtraAttributesFromPlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getExtraAttributes","context","entity","getExtraAttributesFromPlugins","plugins","byType","AttributePlugin","type","filter","plugin","reduce","attributes","getDefinition"],"sources":["attributes.ts"],"sourcesContent":["import { Context } from \"@webiny/api/types\";\nimport { AttributePlugin, DefinitionParams } from \"~/plugins/definitions/AttributePlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * Will be removed in favor of directly assigning attributes to a certain entity when creating the storage operations.\n *\n * @deprecated\n */\nexport const getExtraAttributes = (\n context: Context,\n entity: string\n): Record<string, DefinitionParams> => {\n return getExtraAttributesFromPlugins(context.plugins, entity);\n};\n\nexport const getExtraAttributesFromPlugins = (\n plugins: PluginsContainer,\n entity: string\n): Record<string, DefinitionParams> => {\n return plugins\n .byType<AttributePlugin>(AttributePlugin.type)\n .filter(plugin => plugin.entity === entity)\n .reduce((attributes, plugin) => {\n return {\n ...attributes,\n ...plugin.getDefinition()\n };\n }, {});\n};\n"],"mappings":";;;;;;;;AACA;AAGA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAG,CAC9BC,OAAgB,EAChBC,MAAc,KACqB;EACnC,OAAOC,6BAA6B,CAACF,OAAO,CAACG,OAAO,EAAEF,MAAM,CAAC;AACjE,CAAC;AAAC;AAEK,MAAMC,6BAA6B,GAAG,CACzCC,OAAyB,EACzBF,MAAc,KACqB;EACnC,OAAOE,OAAO,CACTC,MAAM,CAAkBC,gCAAe,CAACC,IAAI,CAAC,CAC7CC,MAAM,CAACC,MAAM,IAAIA,MAAM,CAACP,MAAM,KAAKA,MAAM,CAAC,CAC1CQ,MAAM,CAAC,CAACC,UAAU,EAAEF,MAAM,KAAK;IAC5B,mEACOE,UAAU,GACVF,MAAM,CAACG,aAAa,EAAE;EAEjC,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC;AAAC"}
|
package/utils/batchRead.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Table } from "dynamodb-toolbox";
|
|
2
|
-
interface
|
|
2
|
+
export interface BatchReadItem {
|
|
3
3
|
Table: Table;
|
|
4
4
|
Key: any;
|
|
5
5
|
}
|
|
6
|
-
interface
|
|
6
|
+
export interface BatchReadParams {
|
|
7
7
|
table: Table;
|
|
8
|
-
items:
|
|
8
|
+
items: BatchReadItem[];
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* This helper function is meant to be used to batch read from one table.
|
|
12
12
|
* It will fetch all results, as there is a next() method call built in.
|
|
13
13
|
*/
|
|
14
|
-
export declare const batchReadAll: <T = any>(params:
|
|
15
|
-
export {};
|
|
14
|
+
export declare const batchReadAll: <T = any>(params: BatchReadParams, maxChunk?: number) => Promise<T[]>;
|
package/utils/batchRead.js
CHANGED
|
@@ -1,58 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.batchReadAll = void 0;
|
|
7
|
-
|
|
8
|
+
var _chunk = _interopRequireDefault(require("lodash/chunk"));
|
|
9
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
const MAX_BATCH_ITEMS = 100;
|
|
8
11
|
const flatten = responses => {
|
|
9
12
|
const entries = [];
|
|
10
13
|
const values = Object.values(responses);
|
|
11
|
-
|
|
12
14
|
for (const items of values) {
|
|
13
15
|
entries.push(...items);
|
|
14
16
|
}
|
|
15
|
-
|
|
16
17
|
return entries;
|
|
17
18
|
};
|
|
19
|
+
const batchReadAllChunk = async params => {
|
|
20
|
+
const {
|
|
21
|
+
table,
|
|
22
|
+
items
|
|
23
|
+
} = params;
|
|
24
|
+
const records = [];
|
|
25
|
+
const result = await table.batchGet(items);
|
|
26
|
+
if (!result || !result.Responses) {
|
|
27
|
+
return records;
|
|
28
|
+
}
|
|
29
|
+
records.push(...flatten(result.Responses));
|
|
30
|
+
if (!result.next || typeof result.next !== "function") {
|
|
31
|
+
return records;
|
|
32
|
+
}
|
|
33
|
+
let previous = result;
|
|
34
|
+
while (typeof previous.next === "function") {
|
|
35
|
+
const nextResult = await previous.next();
|
|
36
|
+
if (!nextResult) {
|
|
37
|
+
return records;
|
|
38
|
+
}
|
|
39
|
+
records.push(...flatten(nextResult.Responses));
|
|
40
|
+
previous = nextResult;
|
|
41
|
+
}
|
|
42
|
+
return records;
|
|
43
|
+
};
|
|
18
44
|
/**
|
|
19
45
|
* This helper function is meant to be used to batch read from one table.
|
|
20
46
|
* It will fetch all results, as there is a next() method call built in.
|
|
21
47
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const batchReadAll = async params => {
|
|
48
|
+
const batchReadAll = async (params, maxChunk = MAX_BATCH_ITEMS) => {
|
|
25
49
|
if (params.items.length === 0) {
|
|
26
50
|
return [];
|
|
51
|
+
} else if (maxChunk > MAX_BATCH_ITEMS) {
|
|
52
|
+
throw new _error.default(`Cannot set to load more than ${MAX_BATCH_ITEMS} items from the DynamoDB at once.`, "DYNAMODB_MAX_BATCH_GET_LIMIT_ERROR", {
|
|
53
|
+
maxChunk
|
|
54
|
+
});
|
|
27
55
|
}
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (typeof result.next === "function") {
|
|
37
|
-
let previous = result;
|
|
38
|
-
let nextResult;
|
|
39
|
-
|
|
40
|
-
while (nextResult = await previous.next()) {
|
|
41
|
-
if (!nextResult) {
|
|
42
|
-
return items;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
items.push(...flatten(nextResult.Responses));
|
|
46
|
-
|
|
47
|
-
if (!nextResult || typeof nextResult.next !== "function") {
|
|
48
|
-
return items;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
previous = nextResult;
|
|
52
|
-
}
|
|
56
|
+
const records = [];
|
|
57
|
+
const chunkItemsList = (0, _chunk.default)(params.items, maxChunk);
|
|
58
|
+
for (const chunkItems of chunkItemsList) {
|
|
59
|
+
const results = await batchReadAllChunk({
|
|
60
|
+
table: params.table,
|
|
61
|
+
items: chunkItems
|
|
62
|
+
});
|
|
63
|
+
records.push(...results);
|
|
53
64
|
}
|
|
54
|
-
|
|
55
|
-
return items;
|
|
65
|
+
return records;
|
|
56
66
|
};
|
|
57
|
-
|
|
58
67
|
exports.batchReadAll = batchReadAll;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MAX_BATCH_ITEMS","flatten","responses","entries","values","Object","items","push","batchReadAllChunk","params","table","records","result","batchGet","Responses","next","previous","nextResult","batchReadAll","maxChunk","length","WebinyError","chunkItemsList","lodashChunk","chunkItems","results"],"sources":["batchRead.ts"],"sourcesContent":["import { Table } from \"dynamodb-toolbox\";\nimport lodashChunk from \"lodash/chunk\";\nimport WebinyError from \"@webiny/error\";\n\nexport interface BatchReadItem {\n Table: Table;\n Key: any;\n}\nexport interface BatchReadParams {\n table: Table;\n items: BatchReadItem[];\n}\n\nconst MAX_BATCH_ITEMS = 100;\n\nconst flatten = (responses: Record<string, any[]>): any[] => {\n const entries = [];\n const values = Object.values(responses);\n for (const items of values) {\n entries.push(...items);\n }\n return entries;\n};\n\ninterface BatchReadAllChunkParams {\n table: Table;\n items: BatchReadItem[];\n}\nconst batchReadAllChunk = async <T = any>(params: BatchReadAllChunkParams): Promise<T[]> => {\n const { table, items } = params;\n const records: T[] = [];\n\n const result = await table.batchGet(items);\n if (!result || !result.Responses) {\n return records;\n }\n records.push(...flatten(result.Responses));\n if (!result.next || typeof result.next !== \"function\") {\n return records;\n }\n let previous = result;\n while (typeof previous.next === \"function\") {\n const nextResult = await previous.next();\n if (!nextResult) {\n return records;\n }\n records.push(...flatten(nextResult.Responses));\n previous = nextResult;\n }\n return records;\n};\n/**\n * This helper function is meant to be used to batch read from one table.\n * It will fetch all results, as there is a next() method call built in.\n */\nexport const batchReadAll = async <T = any>(\n params: BatchReadParams,\n maxChunk = MAX_BATCH_ITEMS\n): Promise<T[]> => {\n if (params.items.length === 0) {\n return [];\n } else if (maxChunk > MAX_BATCH_ITEMS) {\n throw new WebinyError(\n `Cannot set to load more than ${MAX_BATCH_ITEMS} items from the DynamoDB at once.`,\n \"DYNAMODB_MAX_BATCH_GET_LIMIT_ERROR\",\n {\n maxChunk\n }\n );\n }\n\n const records: T[] = [];\n\n const chunkItemsList: BatchReadItem[][] = lodashChunk(params.items, maxChunk);\n\n for (const chunkItems of chunkItemsList) {\n const results = await batchReadAllChunk<T>({\n table: params.table,\n items: chunkItems\n });\n\n records.push(...results);\n }\n\n return records;\n};\n"],"mappings":";;;;;;;AACA;AACA;AAWA,MAAMA,eAAe,GAAG,GAAG;AAE3B,MAAMC,OAAO,GAAIC,SAAgC,IAAY;EACzD,MAAMC,OAAO,GAAG,EAAE;EAClB,MAAMC,MAAM,GAAGC,MAAM,CAACD,MAAM,CAACF,SAAS,CAAC;EACvC,KAAK,MAAMI,KAAK,IAAIF,MAAM,EAAE;IACxBD,OAAO,CAACI,IAAI,CAAC,GAAGD,KAAK,CAAC;EAC1B;EACA,OAAOH,OAAO;AAClB,CAAC;AAMD,MAAMK,iBAAiB,GAAG,MAAgBC,MAA+B,IAAmB;EACxF,MAAM;IAAEC,KAAK;IAAEJ;EAAM,CAAC,GAAGG,MAAM;EAC/B,MAAME,OAAY,GAAG,EAAE;EAEvB,MAAMC,MAAM,GAAG,MAAMF,KAAK,CAACG,QAAQ,CAACP,KAAK,CAAC;EAC1C,IAAI,CAACM,MAAM,IAAI,CAACA,MAAM,CAACE,SAAS,EAAE;IAC9B,OAAOH,OAAO;EAClB;EACAA,OAAO,CAACJ,IAAI,CAAC,GAAGN,OAAO,CAACW,MAAM,CAACE,SAAS,CAAC,CAAC;EAC1C,IAAI,CAACF,MAAM,CAACG,IAAI,IAAI,OAAOH,MAAM,CAACG,IAAI,KAAK,UAAU,EAAE;IACnD,OAAOJ,OAAO;EAClB;EACA,IAAIK,QAAQ,GAAGJ,MAAM;EACrB,OAAO,OAAOI,QAAQ,CAACD,IAAI,KAAK,UAAU,EAAE;IACxC,MAAME,UAAU,GAAG,MAAMD,QAAQ,CAACD,IAAI,EAAE;IACxC,IAAI,CAACE,UAAU,EAAE;MACb,OAAON,OAAO;IAClB;IACAA,OAAO,CAACJ,IAAI,CAAC,GAAGN,OAAO,CAACgB,UAAU,CAACH,SAAS,CAAC,CAAC;IAC9CE,QAAQ,GAAGC,UAAU;EACzB;EACA,OAAON,OAAO;AAClB,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMO,YAAY,GAAG,OACxBT,MAAuB,EACvBU,QAAQ,GAAGnB,eAAe,KACX;EACf,IAAIS,MAAM,CAACH,KAAK,CAACc,MAAM,KAAK,CAAC,EAAE;IAC3B,OAAO,EAAE;EACb,CAAC,MAAM,IAAID,QAAQ,GAAGnB,eAAe,EAAE;IACnC,MAAM,IAAIqB,cAAW,CAChB,gCAA+BrB,eAAgB,mCAAkC,EAClF,oCAAoC,EACpC;MACImB;IACJ,CAAC,CACJ;EACL;EAEA,MAAMR,OAAY,GAAG,EAAE;EAEvB,MAAMW,cAAiC,GAAG,IAAAC,cAAW,EAACd,MAAM,CAACH,KAAK,EAAEa,QAAQ,CAAC;EAE7E,KAAK,MAAMK,UAAU,IAAIF,cAAc,EAAE;IACrC,MAAMG,OAAO,GAAG,MAAMjB,iBAAiB,CAAI;MACvCE,KAAK,EAAED,MAAM,CAACC,KAAK;MACnBJ,KAAK,EAAEkB;IACX,CAAC,CAAC;IAEFb,OAAO,CAACJ,IAAI,CAAC,GAAGkB,OAAO,CAAC;EAC5B;EAEA,OAAOd,OAAO;AAClB,CAAC;AAAC"}
|
package/utils/batchWrite.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Table } from "dynamodb-toolbox";
|
|
2
2
|
import { DocumentClient } from "aws-sdk/clients/dynamodb";
|
|
3
|
-
interface
|
|
3
|
+
export interface BatchWriteItem {
|
|
4
4
|
[key: string]: DocumentClient.WriteRequest;
|
|
5
5
|
}
|
|
6
|
-
interface
|
|
6
|
+
export interface BatchWriteParams {
|
|
7
7
|
table: Table;
|
|
8
|
-
items:
|
|
8
|
+
items: BatchWriteItem[];
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Method is meant for batch writing to a single table.
|
|
@@ -13,5 +13,4 @@ interface Params {
|
|
|
13
13
|
* It can either delete or put items
|
|
14
14
|
* The method does not check items before actually sending them into the underlying library.
|
|
15
15
|
*/
|
|
16
|
-
export declare const batchWriteAll: (params:
|
|
17
|
-
export {};
|
|
16
|
+
export declare const batchWriteAll: (params: BatchWriteParams, maxChunk?: number) => Promise<void>;
|
package/utils/batchWrite.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.batchWriteAll = void 0;
|
|
9
|
-
|
|
10
8
|
var _chunk = _interopRequireDefault(require("lodash/chunk"));
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Method is meant for batch writing to a single table.
|
|
14
11
|
* It expects already prepared items for the write.
|
|
@@ -19,12 +16,9 @@ const batchWriteAll = async (params, maxChunk = 25) => {
|
|
|
19
16
|
if (params.items.length === 0) {
|
|
20
17
|
return;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
const chunkedItems = (0, _chunk.default)(params.items, maxChunk);
|
|
24
|
-
|
|
25
20
|
for (const items of chunkedItems) {
|
|
26
21
|
await params.table.batchWrite(items);
|
|
27
22
|
}
|
|
28
23
|
};
|
|
29
|
-
|
|
30
24
|
exports.batchWriteAll = batchWriteAll;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["batchWriteAll","params","maxChunk","items","length","chunkedItems","lodashChunk","table","batchWrite"],"sources":["batchWrite.ts"],"sourcesContent":["import { Table } from \"dynamodb-toolbox\";\nimport lodashChunk from \"lodash/chunk\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\n\nexport interface BatchWriteItem {\n [key: string]: DocumentClient.WriteRequest;\n}\n\nexport interface BatchWriteParams {\n table: Table;\n items: BatchWriteItem[];\n}\n\n/**\n * Method is meant for batch writing to a single table.\n * It expects already prepared items for the write.\n * It can either delete or put items\n * The method does not check items before actually sending them into the underlying library.\n */\nexport const batchWriteAll = async (params: BatchWriteParams, maxChunk = 25): Promise<void> => {\n if (params.items.length === 0) {\n return;\n }\n const chunkedItems: BatchWriteItem[][] = lodashChunk(params.items, maxChunk);\n for (const items of chunkedItems) {\n await params.table.batchWrite(items);\n }\n};\n"],"mappings":";;;;;;;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAG,OAAOC,MAAwB,EAAEC,QAAQ,GAAG,EAAE,KAAoB;EAC3F,IAAID,MAAM,CAACE,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;IAC3B;EACJ;EACA,MAAMC,YAAgC,GAAG,IAAAC,cAAW,EAACL,MAAM,CAACE,KAAK,EAAED,QAAQ,CAAC;EAC5E,KAAK,MAAMC,KAAK,IAAIE,YAAY,EAAE;IAC9B,MAAMJ,MAAM,CAACM,KAAK,CAACC,UAAU,CAACL,KAAK,CAAC;EACxC;AACJ,CAAC;AAAC"}
|
package/utils/cleanup.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Entity } from "dynamodb-toolbox";
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
2
|
+
export declare function cleanupItem<T>(entity: Entity<any>, item?: (T & Record<string, any>) | null, removeAttributes?: string[]): T | null;
|
|
3
|
+
export declare function cleanupItems<T>(entity: Entity<any>, items: (T & Record<string, any>)[], removeAttributes?: string[]): T[];
|
package/utils/cleanup.js
CHANGED
|
@@ -1,53 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
15
|
-
|
|
7
|
+
exports.cleanupItem = cleanupItem;
|
|
8
|
+
exports.cleanupItems = cleanupItems;
|
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
16
10
|
/**
|
|
17
11
|
* The attributes defined by us or the dynamodb-toolbox library.
|
|
18
12
|
* Add more attributes if necessary.
|
|
19
13
|
*/
|
|
20
14
|
const attributesToRemove = ["PK", "SK", "created", "_ct", "modified", "_mt", "entity", "_et", "GSI1_PK", "GSI1_SK", "TYPE"];
|
|
21
|
-
|
|
22
|
-
const cleanupItem = (entity, item, removeAttributes = []) => {
|
|
15
|
+
function cleanupItem(entity, item, removeAttributes = []) {
|
|
23
16
|
if (!item) {
|
|
24
17
|
return null;
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
const newItem = _objectSpread({}, item);
|
|
28
|
-
|
|
19
|
+
const newItem = (0, _objectSpread2.default)({}, item);
|
|
29
20
|
const targets = attributesToRemove.concat(removeAttributes);
|
|
30
21
|
const attributes = entity.schema.attributes;
|
|
31
|
-
|
|
32
22
|
for (const key in item) {
|
|
33
23
|
if (item.hasOwnProperty(key) === false) {
|
|
34
24
|
continue;
|
|
35
25
|
}
|
|
36
|
-
|
|
37
26
|
if (attributes[key] && targets.includes(key) === false) {
|
|
38
27
|
continue;
|
|
39
28
|
}
|
|
40
|
-
|
|
41
29
|
delete newItem[key];
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
return newItem;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
exports.cleanupItem = cleanupItem;
|
|
48
|
-
|
|
49
|
-
const cleanupItems = (entity, items, removeAttributes = []) => {
|
|
32
|
+
}
|
|
33
|
+
function cleanupItems(entity, items, removeAttributes = []) {
|
|
50
34
|
return items.map(item => cleanupItem(entity, item, removeAttributes));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
exports.cleanupItems = cleanupItems;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["attributesToRemove","cleanupItem","entity","item","removeAttributes","newItem","targets","concat","attributes","schema","key","hasOwnProperty","includes","cleanupItems","items","map"],"sources":["cleanup.ts"],"sourcesContent":["import { Entity } from \"dynamodb-toolbox\";\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 \"TYPE\"\n];\n\nexport function cleanupItem<T>(\n entity: Entity<any>,\n item?: (T & Record<string, any>) | 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 & Record<string, any>)[],\n removeAttributes: string[] = []\n): T[] {\n return items.map(item => cleanupItem<T>(entity, item, removeAttributes) as T);\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;AACA;AACA,MAAMA,kBAAkB,GAAG,CACvB,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,KAAK,EACL,UAAU,EACV,KAAK,EACL,QAAQ,EACR,KAAK,EACL,SAAS,EACT,SAAS,EACT,MAAM,CACT;AAEM,SAASC,WAAW,CACvBC,MAAmB,EACnBC,IAAuC,EACvCC,gBAA0B,GAAG,EAAE,EACvB;EACR,IAAI,CAACD,IAAI,EAAE;IACP,OAAO,IAAI;EACf;EACA,MAAME,OAAO,mCACNF,IAAI,CACV;EACD,MAAMG,OAAO,GAAGN,kBAAkB,CAACO,MAAM,CAACH,gBAAgB,CAAC;EAC3D,MAAMI,UAAU,GAAGN,MAAM,CAACO,MAAM,CAACD,UAAU;EAC3C,KAAK,MAAME,GAAG,IAAIP,IAAI,EAAE;IACpB,IAAIA,IAAI,CAACQ,cAAc,CAACD,GAAG,CAAC,KAAK,KAAK,EAAE;MACpC;IACJ;IACA,IAAIF,UAAU,CAACE,GAAG,CAAC,IAAIJ,OAAO,CAACM,QAAQ,CAACF,GAAG,CAAC,KAAK,KAAK,EAAE;MACpD;IACJ;IACA,OAAOL,OAAO,CAACK,GAAG,CAAC;EACvB;EACA,OAAOL,OAAO;AAClB;AAEO,SAASQ,YAAY,CACxBX,MAAmB,EACnBY,KAAkC,EAClCV,gBAA0B,GAAG,EAAE,EAC5B;EACH,OAAOU,KAAK,CAACC,GAAG,CAACZ,IAAI,IAAIF,WAAW,CAAIC,MAAM,EAAEC,IAAI,EAAEC,gBAAgB,CAAM,CAAC;AACjF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Entity, Table } from "dynamodb-toolbox";
|
|
2
|
+
import { EntityAttributes } from "dynamodb-toolbox/dist/classes/Entity";
|
|
3
|
+
interface CreateStandardEntityParams {
|
|
4
|
+
table: Table;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const createStandardEntity: (params: CreateStandardEntityParams) => Entity<any>;
|
|
8
|
+
interface CreateLegacyEntityParams {
|
|
9
|
+
table: Table;
|
|
10
|
+
name: string;
|
|
11
|
+
attributes?: EntityAttributes;
|
|
12
|
+
}
|
|
13
|
+
export declare const createLegacyEntity: (params: CreateLegacyEntityParams) => Entity<{}>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createStandardEntity = exports.createLegacyEntity = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
10
|
+
const createStandardEntity = params => {
|
|
11
|
+
return new _dynamodbToolbox.Entity({
|
|
12
|
+
name: params.name,
|
|
13
|
+
table: params.table,
|
|
14
|
+
attributes: {
|
|
15
|
+
PK: {
|
|
16
|
+
partitionKey: true
|
|
17
|
+
},
|
|
18
|
+
SK: {
|
|
19
|
+
sortKey: true
|
|
20
|
+
},
|
|
21
|
+
GSI1_PK: {
|
|
22
|
+
type: "string"
|
|
23
|
+
},
|
|
24
|
+
GSI1_SK: {
|
|
25
|
+
type: "string"
|
|
26
|
+
},
|
|
27
|
+
TYPE: {
|
|
28
|
+
type: "string"
|
|
29
|
+
},
|
|
30
|
+
data: {
|
|
31
|
+
type: "map"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.createStandardEntity = createStandardEntity;
|
|
37
|
+
const createLegacyEntity = params => {
|
|
38
|
+
return new _dynamodbToolbox.Entity({
|
|
39
|
+
table: params.table,
|
|
40
|
+
name: params.name,
|
|
41
|
+
attributes: (0, _objectSpread2.default)({
|
|
42
|
+
PK: {
|
|
43
|
+
partitionKey: true
|
|
44
|
+
},
|
|
45
|
+
SK: {
|
|
46
|
+
sortKey: true
|
|
47
|
+
},
|
|
48
|
+
GSI1_PK: {
|
|
49
|
+
type: "string"
|
|
50
|
+
},
|
|
51
|
+
GSI1_SK: {
|
|
52
|
+
type: "string"
|
|
53
|
+
},
|
|
54
|
+
TYPE: {
|
|
55
|
+
type: "string"
|
|
56
|
+
}
|
|
57
|
+
}, params.attributes || {})
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.createLegacyEntity = createLegacyEntity;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createStandardEntity","params","Entity","name","table","attributes","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","data","createLegacyEntity"],"sources":["createEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { EntityAttributes } from \"dynamodb-toolbox/dist/classes/Entity\";\n\ninterface CreateStandardEntityParams {\n table: Table;\n name: string;\n}\n\nexport const createStandardEntity = (params: CreateStandardEntityParams): Entity<any> => {\n return new Entity({\n name: params.name,\n table: params.table,\n attributes: {\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 TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n }\n }\n });\n};\n\ninterface CreateLegacyEntityParams {\n table: Table;\n name: string;\n attributes?: EntityAttributes;\n}\n\nexport const createLegacyEntity = (params: CreateLegacyEntityParams) => {\n return new Entity({\n table: params.table,\n name: params.name,\n attributes: {\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 TYPE: {\n type: \"string\"\n },\n ...(params.attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAQO,MAAMA,oBAAoB,GAAIC,MAAkC,IAAkB;EACrF,OAAO,IAAIC,uBAAM,CAAC;IACdC,IAAI,EAAEF,MAAM,CAACE,IAAI;IACjBC,KAAK,EAAEH,MAAM,CAACG,KAAK;IACnBC,UAAU,EAAE;MACRC,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDG,IAAI,EAAE;QACFH,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC;AAQK,MAAMI,kBAAkB,GAAId,MAAgC,IAAK;EACpE,OAAO,IAAIC,uBAAM,CAAC;IACdE,KAAK,EAAEH,MAAM,CAACG,KAAK;IACnBD,IAAI,EAAEF,MAAM,CAACE,IAAI;IACjBE,UAAU;MACNC,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV;IAAC,GACGV,MAAM,CAACI,UAAU,IAAI,CAAC,CAAC;EAEnC,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DocumentClient } from "aws-sdk/clients/dynamodb";
|
|
2
|
+
import { Table } from "dynamodb-toolbox";
|
|
3
|
+
export interface CreateTableParams {
|
|
4
|
+
name?: string;
|
|
5
|
+
documentClient: DocumentClient;
|
|
6
|
+
}
|
|
7
|
+
export declare const createTable: ({ name, documentClient }: CreateTableParams) => Table;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTable = void 0;
|
|
7
|
+
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
8
|
+
const createTable = ({
|
|
9
|
+
name,
|
|
10
|
+
documentClient
|
|
11
|
+
}) => {
|
|
12
|
+
return new _dynamodbToolbox.Table({
|
|
13
|
+
name: name || String(process.env.DB_TABLE),
|
|
14
|
+
partitionKey: "PK",
|
|
15
|
+
sortKey: "SK",
|
|
16
|
+
DocumentClient: documentClient,
|
|
17
|
+
indexes: {
|
|
18
|
+
GSI1: {
|
|
19
|
+
partitionKey: "GSI1_PK",
|
|
20
|
+
sortKey: "GSI1_SK"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.createTable = createTable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createTable","name","documentClient","Table","String","process","env","DB_TABLE","partitionKey","sortKey","DocumentClient","indexes","GSI1"],"sources":["createTable.ts"],"sourcesContent":["import { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Table } from \"dynamodb-toolbox\";\n\nexport interface CreateTableParams {\n name?: string;\n documentClient: DocumentClient;\n}\n\nexport const createTable = ({ name, documentClient }: CreateTableParams) => {\n return new Table({\n name: name || String(process.env.DB_TABLE),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n }\n }\n });\n};\n"],"mappings":";;;;;;AACA;AAOO,MAAMA,WAAW,GAAG,CAAC;EAAEC,IAAI;EAAEC;AAAkC,CAAC,KAAK;EACxE,OAAO,IAAIC,sBAAK,CAAC;IACbF,IAAI,EAAEA,IAAI,IAAIG,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,QAAQ,CAAC;IAC1CC,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAER,cAAc;IAC9BS,OAAO,EAAE;MACLC,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/utils/cursor.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const encodeCursor: (cursor?: any) => string;
|
|
2
|
-
export declare const decodeCursor: (cursor?: string) =>
|
|
1
|
+
export declare const encodeCursor: (cursor?: any) => string | null;
|
|
2
|
+
export declare const decodeCursor: (cursor?: string | null) => string | null;
|
package/utils/cursor.js
CHANGED
|
@@ -4,23 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.encodeCursor = exports.decodeCursor = void 0;
|
|
7
|
-
|
|
8
7
|
const encodeCursor = cursor => {
|
|
9
8
|
if (!cursor) {
|
|
10
9
|
return null;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return Buffer.from(JSON.stringify(cursor)).toString("base64");
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
exports.encodeCursor = encodeCursor;
|
|
17
|
-
|
|
18
14
|
const decodeCursor = cursor => {
|
|
19
15
|
if (!cursor) {
|
|
20
16
|
return null;
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
return JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
|
|
24
19
|
};
|
|
25
|
-
|
|
26
20
|
exports.decodeCursor = decodeCursor;
|
|
@@ -0,0 +1 @@
|
|
|
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":";;;;;;AAAO,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;AAAC;AAEK,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;AAAC"}
|
package/utils/filter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginsContainer } from "@webiny/plugins";
|
|
2
2
|
import { FieldPlugin } from "../plugins/definitions/FieldPlugin";
|
|
3
|
-
export interface Params<T
|
|
3
|
+
export interface Params<T = any> {
|
|
4
4
|
plugins: PluginsContainer;
|
|
5
5
|
items: T[];
|
|
6
6
|
where: Record<string, any>;
|
|
@@ -9,4 +9,4 @@ export interface Params<T extends any = any> {
|
|
|
9
9
|
*/
|
|
10
10
|
fields: FieldPlugin[];
|
|
11
11
|
}
|
|
12
|
-
export declare
|
|
12
|
+
export declare function filterItems<T = any>(params: Params<T>): T[];
|