@webiny/db-dynamodb 0.0.0-unstable.c2780f51fe → 0.0.0-unstable.c7dec08bb0
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 +1 -1
- package/index.d.ts +1 -1
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/package.json +17 -17
- package/plugins/filters/fuzzy.js +5 -1
- package/plugins/filters/fuzzy.js.map +1 -1
- package/utils/batchRead.d.ts +4 -5
- package/utils/batchRead.js.map +1 -1
- package/utils/batchWrite.d.ts +4 -5
- package/utils/batchWrite.js.map +1 -1
- 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/index.d.ts +12 -0
- package/utils/index.js +137 -0
- package/utils/index.js.map +1 -0
- package/utils/createStandardEntity.d.ts +0 -2
- package/utils/createStandardEntity.js +0 -34
- package/utils/createStandardEntity.js.map +0 -1
package/BatchProcess.d.ts
CHANGED
|
@@ -42,6 +42,6 @@ declare class BatchProcess {
|
|
|
42
42
|
addBatchDelete(args: AddBatchOperationArgs): AddBatchOperationResponse;
|
|
43
43
|
addBatchGet(args: AddBatchOperationArgs): AddBatchOperationResponse;
|
|
44
44
|
allOperationsAdded(): boolean;
|
|
45
|
-
startExecution(): import("aws-sdk/lib/request").Request<DocumentClient.
|
|
45
|
+
startExecution(): import("aws-sdk/lib/request").Request<DocumentClient.BatchGetItemOutput, import("aws-sdk/lib/error").AWSError> | import("aws-sdk/lib/request").Request<DocumentClient.BatchWriteItemOutput, import("aws-sdk/lib/error").AWSError>;
|
|
46
46
|
}
|
|
47
47
|
export default BatchProcess;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -21,15 +21,15 @@ Object.defineProperty(exports, "DynamoDbDriver", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
var _DynamoDbDriver = _interopRequireDefault(require("./DynamoDbDriver"));
|
|
24
|
-
var
|
|
25
|
-
Object.keys(
|
|
24
|
+
var _utils = require("./utils");
|
|
25
|
+
Object.keys(_utils).forEach(function (key) {
|
|
26
26
|
if (key === "default" || key === "__esModule") return;
|
|
27
27
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
-
if (key in exports && exports[key] ===
|
|
28
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
29
29
|
Object.defineProperty(exports, key, {
|
|
30
30
|
enumerable: true,
|
|
31
31
|
get: function () {
|
|
32
|
-
return
|
|
32
|
+
return _utils[key];
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
});
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import { default as DynamoDbDriver } from \"./DynamoDbDriver\";\nexport * from \"./utils
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import { default as DynamoDbDriver } from \"./DynamoDbDriver\";\nexport * from \"./utils\";\nexport { DbItem } from \"./types\";\n\nexport { DynamoDbDriver };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/db-dynamodb",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.c7dec08bb0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"author": "Webiny Ltd",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/api": "0.0.0-unstable.
|
|
14
|
-
"@webiny/db": "0.0.0-unstable.
|
|
15
|
-
"@webiny/error": "0.0.0-unstable.
|
|
16
|
-
"@webiny/handler-db": "0.0.0-unstable.
|
|
17
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
13
|
+
"@webiny/api": "0.0.0-unstable.c7dec08bb0",
|
|
14
|
+
"@webiny/db": "0.0.0-unstable.c7dec08bb0",
|
|
15
|
+
"@webiny/error": "0.0.0-unstable.c7dec08bb0",
|
|
16
|
+
"@webiny/handler-db": "0.0.0-unstable.c7dec08bb0",
|
|
17
|
+
"@webiny/plugins": "0.0.0-unstable.c7dec08bb0",
|
|
18
18
|
"date-fns": "2.29.3",
|
|
19
19
|
"dot-prop": "6.0.1",
|
|
20
20
|
"fuse.js": "6.6.2",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"lodash": "4.17.21"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "
|
|
26
|
-
"@babel/core": "
|
|
27
|
-
"@types/is-number": "
|
|
28
|
-
"@webiny/cli": "
|
|
29
|
-
"@webiny/project-utils": "
|
|
30
|
-
"dynamodb-toolbox": "
|
|
31
|
-
"jest": "
|
|
32
|
-
"jest-dynalite": "
|
|
33
|
-
"rimraf": "
|
|
34
|
-
"ttypescript": "
|
|
25
|
+
"@babel/cli": "7.20.7",
|
|
26
|
+
"@babel/core": "7.20.12",
|
|
27
|
+
"@types/is-number": "7.0.3",
|
|
28
|
+
"@webiny/cli": "0.0.0-unstable.c7dec08bb0",
|
|
29
|
+
"@webiny/project-utils": "0.0.0-unstable.c7dec08bb0",
|
|
30
|
+
"dynamodb-toolbox": "0.3.5",
|
|
31
|
+
"jest": "29.5.0",
|
|
32
|
+
"jest-dynalite": "3.6.1",
|
|
33
|
+
"rimraf": "3.0.2",
|
|
34
|
+
"ttypescript": "1.5.15",
|
|
35
35
|
"typescript": "4.7.4"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"build": "yarn webiny run build",
|
|
43
43
|
"watch": "yarn webiny run watch"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c7dec08bb095467cca6a61381bd399d66b7bb147"
|
|
46
46
|
}
|
package/plugins/filters/fuzzy.js
CHANGED
|
@@ -16,7 +16,11 @@ const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
16
16
|
if (typeof value !== "string") {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
const f = new _fuse.default([value], {
|
|
19
|
+
const f = new _fuse.default([value], {
|
|
20
|
+
includeScore: true,
|
|
21
|
+
minMatchCharLength: 3,
|
|
22
|
+
threshold: 0.6
|
|
23
|
+
});
|
|
20
24
|
const result = f.search(compareValue);
|
|
21
25
|
return result.length > 0;
|
|
22
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","f","Fuse","result","search","length","name"],"sources":["fuzzy.ts"],"sourcesContent":["import Fuse from \"fuse.js\";\nimport {\n ValueFilterPluginParamsMatchesParams,\n ValueFilterPlugin\n} from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"fuzzy\",\n matches: ({\n value,\n compareValue\n }: ValueFilterPluginParamsMatchesParams<string | null, string>) => {\n if (typeof value !== \"string\") {\n return false;\n }\n const f = new Fuse([value], {});\n const result = f.search(compareValue);\n\n return result.length > 0;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.fuzzy\";\n\nexport default plugin;\n"],"mappings":";;;;;;;AAAA;AACA;AAKA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,OAAO;EAClBC,OAAO,EAAE,CAAC;IACNC,KAAK;IACLC;EACyD,CAAC,KAAK;IAC/D,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;MAC3B,OAAO,KAAK;IAChB;IACA,MAAME,CAAC,GAAG,IAAIC,aAAI,CAAC,CAACH,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","f","Fuse","includeScore","minMatchCharLength","threshold","result","search","length","name"],"sources":["fuzzy.ts"],"sourcesContent":["import Fuse from \"fuse.js\";\nimport {\n ValueFilterPluginParamsMatchesParams,\n ValueFilterPlugin\n} from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"fuzzy\",\n matches: ({\n value,\n compareValue\n }: ValueFilterPluginParamsMatchesParams<string | null, string>) => {\n if (typeof value !== \"string\") {\n return false;\n }\n const f = new Fuse([value], {\n includeScore: true,\n minMatchCharLength: 3,\n threshold: 0.6\n });\n const result = f.search(compareValue);\n\n return result.length > 0;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.fuzzy\";\n\nexport default plugin;\n"],"mappings":";;;;;;;AAAA;AACA;AAKA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,OAAO;EAClBC,OAAO,EAAE,CAAC;IACNC,KAAK;IACLC;EACyD,CAAC,KAAK;IAC/D,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;MAC3B,OAAO,KAAK;IAChB;IACA,MAAME,CAAC,GAAG,IAAIC,aAAI,CAAC,CAACH,KAAK,CAAC,EAAE;MACxBI,YAAY,EAAE,IAAI;MAClBC,kBAAkB,EAAE,CAAC;MACrBC,SAAS,EAAE;IACf,CAAC,CAAC;IACF,MAAMC,MAAM,GAAGL,CAAC,CAACM,MAAM,CAACP,YAAY,CAAC;IAErC,OAAOM,MAAM,CAACE,MAAM,GAAG,CAAC;EAC5B;AACJ,CAAC,CAAC;AAEFb,MAAM,CAACc,IAAI,GAAG,6BAA6B;AAAC,eAE7Bd,MAAM;AAAA"}
|
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.map
CHANGED
|
@@ -1 +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\
|
|
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.map
CHANGED
|
@@ -1 +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\
|
|
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"}
|
|
@@ -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/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./batchRead";
|
|
2
|
+
export * from "./batchWrite";
|
|
3
|
+
export * from "./cleanup";
|
|
4
|
+
export * from "./createEntity";
|
|
5
|
+
export * from "./cursor";
|
|
6
|
+
export * from "./filter";
|
|
7
|
+
export * from "./get";
|
|
8
|
+
export * from "./listResponse";
|
|
9
|
+
export * from "./query";
|
|
10
|
+
export * from "./sort";
|
|
11
|
+
export * from "./createTable";
|
|
12
|
+
export * from "./table";
|
package/utils/index.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _batchRead = require("./batchRead");
|
|
7
|
+
Object.keys(_batchRead).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _batchRead[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _batchRead[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _batchWrite = require("./batchWrite");
|
|
18
|
+
Object.keys(_batchWrite).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _batchWrite[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _batchWrite[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _cleanup = require("./cleanup");
|
|
29
|
+
Object.keys(_cleanup).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _cleanup[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _cleanup[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _createEntity = require("./createEntity");
|
|
40
|
+
Object.keys(_createEntity).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _createEntity[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _createEntity[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _cursor = require("./cursor");
|
|
51
|
+
Object.keys(_cursor).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _cursor[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _cursor[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _filter = require("./filter");
|
|
62
|
+
Object.keys(_filter).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _filter[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _filter[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _get = require("./get");
|
|
73
|
+
Object.keys(_get).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _get[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _get[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _listResponse = require("./listResponse");
|
|
84
|
+
Object.keys(_listResponse).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _listResponse[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _listResponse[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _query = require("./query");
|
|
95
|
+
Object.keys(_query).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _query[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _query[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _sort = require("./sort");
|
|
106
|
+
Object.keys(_sort).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _sort[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _sort[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
var _createTable = require("./createTable");
|
|
117
|
+
Object.keys(_createTable).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _createTable[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _createTable[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
var _table = require("./table");
|
|
128
|
+
Object.keys(_table).forEach(function (key) {
|
|
129
|
+
if (key === "default" || key === "__esModule") return;
|
|
130
|
+
if (key in exports && exports[key] === _table[key]) return;
|
|
131
|
+
Object.defineProperty(exports, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return _table[key];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./batchRead\";\nexport * from \"./batchWrite\";\nexport * from \"./cleanup\";\nexport * from \"./createEntity\";\nexport * from \"./cursor\";\nexport * from \"./filter\";\nexport * from \"./get\";\nexport * from \"./listResponse\";\nexport * from \"./query\";\nexport * from \"./sort\";\nexport * from \"./createTable\";\nexport * from \"./table\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createStandardEntity = void 0;
|
|
7
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
8
|
-
const createStandardEntity = (table, name) => {
|
|
9
|
-
return new _dynamodbToolbox.Entity({
|
|
10
|
-
name,
|
|
11
|
-
table,
|
|
12
|
-
attributes: {
|
|
13
|
-
PK: {
|
|
14
|
-
partitionKey: true
|
|
15
|
-
},
|
|
16
|
-
SK: {
|
|
17
|
-
sortKey: true
|
|
18
|
-
},
|
|
19
|
-
GSI1_PK: {
|
|
20
|
-
type: "string"
|
|
21
|
-
},
|
|
22
|
-
GSI1_SK: {
|
|
23
|
-
type: "string"
|
|
24
|
-
},
|
|
25
|
-
TYPE: {
|
|
26
|
-
type: "string"
|
|
27
|
-
},
|
|
28
|
-
data: {
|
|
29
|
-
type: "map"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
exports.createStandardEntity = createStandardEntity;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createStandardEntity","table","name","Entity","attributes","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","data"],"sources":["createStandardEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\n\nexport const createStandardEntity = (table: Table, name: string): Entity<any> => {\n return new Entity({\n name,\n 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"],"mappings":";;;;;;AAAA;AAEO,MAAMA,oBAAoB,GAAG,CAACC,KAAY,EAAEC,IAAY,KAAkB;EAC7E,OAAO,IAAIC,uBAAM,CAAC;IACdD,IAAI;IACJD,KAAK;IACLG,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"}
|