@webiny/db-dynamodb 5.41.4-beta.3 → 5.41.4-beta.5
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/README.md +81 -1
- package/index.d.ts +1 -1
- package/index.js +1 -9
- package/index.js.map +1 -1
- package/package.json +10 -11
- package/toolbox.d.ts +1 -1
- package/toolbox.js.map +1 -1
- package/utils/{batchRead.d.ts → batch/batchRead.d.ts} +1 -1
- package/utils/batch/batchWrite.d.ts +13 -0
- package/utils/batch/batchWrite.js.map +1 -0
- package/utils/batch/index.d.ts +3 -0
- package/utils/batch/index.js +40 -0
- package/utils/batch/index.js.map +1 -0
- package/utils/batch/types.d.ts +25 -0
- package/utils/batch/types.js +7 -0
- package/utils/batch/types.js.map +1 -0
- package/utils/delete.d.ts +7 -7
- package/utils/delete.js.map +1 -1
- package/utils/entity/Entity.d.ts +25 -0
- package/utils/entity/Entity.js +77 -0
- package/utils/entity/Entity.js.map +1 -0
- package/utils/entity/EntityReadBatch.d.ts +17 -0
- package/utils/entity/EntityReadBatch.js +41 -0
- package/utils/entity/EntityReadBatch.js.map +1 -0
- package/utils/entity/EntityReadBatchBuilder.d.ts +10 -0
- package/utils/entity/EntityReadBatchBuilder.js +29 -0
- package/utils/entity/EntityReadBatchBuilder.js.map +1 -0
- package/utils/entity/EntityWriteBatch.d.ts +22 -0
- package/utils/entity/EntityWriteBatch.js +59 -0
- package/utils/entity/EntityWriteBatch.js.map +1 -0
- package/utils/entity/EntityWriteBatchBuilder.d.ts +11 -0
- package/utils/entity/EntityWriteBatchBuilder.js +28 -0
- package/utils/entity/EntityWriteBatchBuilder.js.map +1 -0
- package/utils/entity/getEntity.d.ts +4 -0
- package/utils/entity/getEntity.js +19 -0
- package/utils/entity/getEntity.js.map +1 -0
- package/utils/entity/index.d.ts +7 -0
- package/utils/entity/index.js +84 -0
- package/utils/entity/index.js.map +1 -0
- package/utils/entity/types.d.ts +51 -0
- package/utils/entity/types.js +7 -0
- package/utils/entity/types.js.map +1 -0
- package/utils/get.d.ts +5 -4
- package/utils/get.js.map +1 -1
- package/utils/index.d.ts +3 -3
- package/utils/index.js +30 -30
- package/utils/index.js.map +1 -1
- package/utils/put.d.ts +8 -8
- package/utils/put.js +2 -1
- package/utils/put.js.map +1 -1
- package/utils/scan.d.ts +4 -4
- package/utils/scan.js.map +1 -1
- package/utils/table/Table.d.ts +10 -0
- package/utils/table/Table.js +34 -0
- package/utils/table/Table.js.map +1 -0
- package/utils/table/TableReadBatch.d.ts +19 -0
- package/utils/table/TableReadBatch.js +62 -0
- package/utils/table/TableReadBatch.js.map +1 -0
- package/utils/table/TableWriteBatch.d.ts +21 -0
- package/utils/table/TableWriteBatch.js +69 -0
- package/utils/table/TableWriteBatch.js.map +1 -0
- package/utils/table/index.d.ts +4 -0
- package/utils/table/index.js +51 -0
- package/utils/table/index.js.map +1 -0
- package/utils/table/types.d.ts +39 -0
- package/utils/table/types.js +7 -0
- package/utils/table/types.js.map +1 -0
- package/utils/update.d.ts +1 -0
- package/utils/update.js +2 -1
- package/utils/update.js.map +1 -1
- package/utils/batchWrite.d.ts +0 -29
- package/utils/batchWrite.js.map +0 -1
- package/utils/table.d.ts +0 -7
- package/utils/table.js +0 -24
- package/utils/table.js.map +0 -1
- /package/utils/{batchRead.js → batch/batchRead.js} +0 -0
- /package/utils/{batchRead.js.map → batch/batchRead.js.map} +0 -0
- /package/utils/{batchWrite.js → batch/batchWrite.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_toolbox","require","_TableWriteBatch","_TableReadBatch","_scan","Table","constructor","params","table","BaseTable","createWriter","createTableWriteBatch","createReader","createTableReadBatch","scan","exports"],"sources":["Table.ts"],"sourcesContent":["import type { TableConstructor } from \"~/toolbox\";\nimport { Table as BaseTable } from \"~/toolbox\";\nimport type {\n ITable,\n ITableReadBatch,\n ITableScanParams,\n ITableScanResponse,\n ITableWriteBatch\n} from \"./types\";\nimport { createTableWriteBatch } from \"./TableWriteBatch\";\nimport { createTableReadBatch } from \"./TableReadBatch\";\nimport { scan } from \"../scan\";\n\nexport class Table<\n Name extends string = string,\n PartitionKey extends string = string,\n SortKey extends string = string\n> implements ITable\n{\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"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAQA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEO,MAAMI,KAAK,CAKlB;EAGWC,WAAWA,CAACC,MAAqD,EAAE;IACtE,IAAI,CAACC,KAAK,GAAG,IAAIC,cAAS,CAACF,MAAM,CAAC;EACtC;EAEOG,YAAYA,CAAA,EAAqB;IACpC,OAAO,IAAAC,sCAAqB,EAAC;MACzBH,KAAK,EAAE,IAAI,CAACA;IAChB,CAAC,CAAC;EACN;EAEOI,YAAYA,CAAA,EAAoB;IACnC,OAAO,IAAAC,oCAAoB,EAAC;MACxBL,KAAK,EAAE,IAAI,CAACA;IAChB,CAAC,CAAC;EACN;EAEA,MAAaM,IAAIA,CAAIP,MAAwB,EAAkC;IAC3E,OAAO,IAAAO,UAAI,EAAI;MACX,GAAGP,MAAM;MACTC,KAAK,EAAE,IAAI,CAACA;IAChB,CAAC,CAAC;EACN;AACJ;AAACO,OAAA,CAAAV,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Entity, TableDef } from "../../toolbox";
|
|
2
|
+
import type { IEntityReadBatchBuilderGetResponse } from "../entity/types";
|
|
3
|
+
import type { GenericRecord } from "@webiny/api/types";
|
|
4
|
+
import type { ITableReadBatch, ITableReadBatchKey } from "./types";
|
|
5
|
+
export interface ITableReadBatchParams {
|
|
6
|
+
table: TableDef;
|
|
7
|
+
}
|
|
8
|
+
export declare class TableReadBatch implements ITableReadBatch {
|
|
9
|
+
private readonly table;
|
|
10
|
+
private readonly _items;
|
|
11
|
+
private readonly builders;
|
|
12
|
+
constructor(params: ITableReadBatchParams);
|
|
13
|
+
get total(): number;
|
|
14
|
+
get items(): IEntityReadBatchBuilderGetResponse[];
|
|
15
|
+
get(entity: Entity, input: ITableReadBatchKey): void;
|
|
16
|
+
execute<T = GenericRecord>(): Promise<T[]>;
|
|
17
|
+
private getBuilder;
|
|
18
|
+
}
|
|
19
|
+
export declare const createTableReadBatch: (params: ITableReadBatchParams) => ITableReadBatch;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTableReadBatch = exports.TableReadBatch = void 0;
|
|
7
|
+
var _batchRead = require("../batch/batchRead");
|
|
8
|
+
var _EntityReadBatchBuilder = require("../entity/EntityReadBatchBuilder");
|
|
9
|
+
var _error = require("@webiny/error");
|
|
10
|
+
class TableReadBatch {
|
|
11
|
+
_items = [];
|
|
12
|
+
builders = new Map();
|
|
13
|
+
constructor(params) {
|
|
14
|
+
this.table = params.table;
|
|
15
|
+
}
|
|
16
|
+
get total() {
|
|
17
|
+
return this._items.length;
|
|
18
|
+
}
|
|
19
|
+
get items() {
|
|
20
|
+
return Array.from(this._items);
|
|
21
|
+
}
|
|
22
|
+
get(entity, input) {
|
|
23
|
+
const builder = this.getBuilder(entity);
|
|
24
|
+
const items = Array.isArray(input) ? input : [input];
|
|
25
|
+
for (const item of items) {
|
|
26
|
+
/**
|
|
27
|
+
* We cannot read from two tables at the same time, so check for that.
|
|
28
|
+
*/
|
|
29
|
+
if (this.table.name !== entity.table.name) {
|
|
30
|
+
throw new _error.WebinyError(`Cannot read from two different tables at the same time.`);
|
|
31
|
+
}
|
|
32
|
+
this._items.push(builder.get(item));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async execute() {
|
|
36
|
+
if (this._items.length === 0) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
const items = Array.from(this._items);
|
|
40
|
+
this._items.length = 0;
|
|
41
|
+
return await (0, _batchRead.batchReadAll)({
|
|
42
|
+
items,
|
|
43
|
+
table: this.table
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getBuilder(entity) {
|
|
47
|
+
const builder = this.builders.get(entity.name);
|
|
48
|
+
if (builder) {
|
|
49
|
+
return builder;
|
|
50
|
+
}
|
|
51
|
+
const newBuilder = (0, _EntityReadBatchBuilder.createEntityReadBatchBuilder)(entity);
|
|
52
|
+
this.builders.set(entity.name, newBuilder);
|
|
53
|
+
return newBuilder;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TableReadBatch = TableReadBatch;
|
|
57
|
+
const createTableReadBatch = params => {
|
|
58
|
+
return new TableReadBatch(params);
|
|
59
|
+
};
|
|
60
|
+
exports.createTableReadBatch = createTableReadBatch;
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=TableReadBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_batchRead","require","_EntityReadBatchBuilder","_error","TableReadBatch","_items","builders","Map","constructor","params","table","total","length","items","Array","from","get","entity","input","builder","getBuilder","isArray","item","name","WebinyError","push","execute","batchReadAll","newBuilder","createEntityReadBatchBuilder","set","exports","createTableReadBatch"],"sources":["TableReadBatch.ts"],"sourcesContent":["import type { Entity, TableDef } from \"~/toolbox\";\nimport type {\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse\n} from \"~/utils/entity/types\";\nimport { batchReadAll } from \"~/utils/batch/batchRead\";\nimport { createEntityReadBatchBuilder } from \"~/utils/entity/EntityReadBatchBuilder\";\nimport type { GenericRecord } from \"@webiny/api/types\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { ITableReadBatch, ITableReadBatchKey } from \"./types\";\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"],"mappings":";;;;;;AAKA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAOO,MAAMG,cAAc,CAA4B;EAGlCC,MAAM,GAAyC,EAAE;EACjDC,QAAQ,GAAyC,IAAIC,GAAG,CAAC,CAAC;EAEpEC,WAAWA,CAACC,MAA6B,EAAE;IAC9C,IAAI,CAACC,KAAK,GAAGD,MAAM,CAACC,KAAK;EAC7B;EAEA,IAAWC,KAAKA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACN,MAAM,CAACO,MAAM;EAC7B;EAEA,IAAWC,KAAKA,CAAA,EAAyC;IACrD,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACV,MAAM,CAAC;EAClC;EAEOW,GAAGA,CAACC,MAAc,EAAEC,KAAyB,EAAQ;IACxD,MAAMC,OAAO,GAAG,IAAI,CAACC,UAAU,CAACH,MAAM,CAAC;IAEvC,MAAMJ,KAAK,GAAGC,KAAK,CAACO,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAG,CAACA,KAAK,CAAC;IACpD,KAAK,MAAMI,IAAI,IAAIT,KAAK,EAAE;MACtB;AACZ;AACA;MACY,IAAI,IAAI,CAACH,KAAK,CAACa,IAAI,KAAKN,MAAM,CAACP,KAAK,CAAEa,IAAI,EAAE;QACxC,MAAM,IAAIC,kBAAW,CAAE,yDAAwD,CAAC;MACpF;MAEA,IAAI,CAACnB,MAAM,CAACoB,IAAI,CAACN,OAAO,CAACH,GAAG,CAACM,IAAI,CAAC,CAAC;IACvC;EACJ;EAEA,MAAaI,OAAOA,CAAA,EAAoC;IACpD,IAAI,IAAI,CAACrB,MAAM,CAACO,MAAM,KAAK,CAAC,EAAE;MAC1B,OAAO,EAAE;IACb;IACA,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACV,MAAM,CAAC;IACrC,IAAI,CAACA,MAAM,CAACO,MAAM,GAAG,CAAC;IACtB,OAAO,MAAM,IAAAe,uBAAY,EAAI;MACzBd,KAAK;MACLH,KAAK,EAAE,IAAI,CAACA;IAChB,CAAC,CAAC;EACN;EAEQU,UAAUA,CAACH,MAAc,EAA2B;IACxD,MAAME,OAAO,GAAG,IAAI,CAACb,QAAQ,CAACU,GAAG,CAACC,MAAM,CAACM,IAAI,CAAC;IAC9C,IAAIJ,OAAO,EAAE;MACT,OAAOA,OAAO;IAClB;IACA,MAAMS,UAAU,GAAG,IAAAC,oDAA4B,EAACZ,MAAM,CAAC;IACvD,IAAI,CAACX,QAAQ,CAACwB,GAAG,CAACb,MAAM,CAACM,IAAI,EAAEK,UAAU,CAAC;IAC1C,OAAOA,UAAU;EACrB;AACJ;AAACG,OAAA,CAAA3B,cAAA,GAAAA,cAAA;AAEM,MAAM4B,oBAAoB,GAAIvB,MAA6B,IAAsB;EACpF,OAAO,IAAIL,cAAc,CAACK,MAAM,CAAC;AACrC,CAAC;AAACsB,OAAA,CAAAC,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Entity, TableDef } from "../../toolbox";
|
|
2
|
+
import type { BatchWriteItem, BatchWriteResult, IDeleteBatchItem, IPutBatchItem } from "../batch/types";
|
|
3
|
+
import type { ITableWriteBatch } from "./types";
|
|
4
|
+
export interface ITableWriteBatchParams {
|
|
5
|
+
table: TableDef;
|
|
6
|
+
items?: BatchWriteItem[];
|
|
7
|
+
}
|
|
8
|
+
export declare class TableWriteBatch implements ITableWriteBatch {
|
|
9
|
+
private readonly table;
|
|
10
|
+
private readonly _items;
|
|
11
|
+
private readonly builders;
|
|
12
|
+
get total(): number;
|
|
13
|
+
get items(): BatchWriteItem[];
|
|
14
|
+
constructor(params: ITableWriteBatchParams);
|
|
15
|
+
put(entity: Entity, item: IPutBatchItem): void;
|
|
16
|
+
delete(entity: Entity, item: IDeleteBatchItem): void;
|
|
17
|
+
combine(items: BatchWriteItem[]): ITableWriteBatch;
|
|
18
|
+
execute(): Promise<BatchWriteResult>;
|
|
19
|
+
private getBuilder;
|
|
20
|
+
}
|
|
21
|
+
export declare const createTableWriteBatch: (params: ITableWriteBatchParams) => ITableWriteBatch;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTableWriteBatch = exports.TableWriteBatch = void 0;
|
|
7
|
+
var _batchWrite = require("../batch/batchWrite");
|
|
8
|
+
var _EntityWriteBatchBuilder = require("../entity/EntityWriteBatchBuilder");
|
|
9
|
+
class TableWriteBatch {
|
|
10
|
+
_items = [];
|
|
11
|
+
builders = new Map();
|
|
12
|
+
get total() {
|
|
13
|
+
return this._items.length;
|
|
14
|
+
}
|
|
15
|
+
get items() {
|
|
16
|
+
return Array.from(this._items);
|
|
17
|
+
}
|
|
18
|
+
constructor(params) {
|
|
19
|
+
this.table = params.table;
|
|
20
|
+
if (!params.items?.length) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this._items.push(...params.items);
|
|
24
|
+
}
|
|
25
|
+
put(entity, item) {
|
|
26
|
+
const builder = this.getBuilder(entity);
|
|
27
|
+
this._items.push(builder.put(item));
|
|
28
|
+
}
|
|
29
|
+
delete(entity, item) {
|
|
30
|
+
const builder = this.getBuilder(entity);
|
|
31
|
+
this._items.push(builder.delete(item));
|
|
32
|
+
}
|
|
33
|
+
combine(items) {
|
|
34
|
+
return createTableWriteBatch({
|
|
35
|
+
table: this.table,
|
|
36
|
+
items: this._items.concat(items)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async execute() {
|
|
40
|
+
if (this._items.length === 0) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const items = Array.from(this._items);
|
|
44
|
+
this._items.length = 0;
|
|
45
|
+
return await (0, _batchWrite.batchWriteAll)({
|
|
46
|
+
items,
|
|
47
|
+
table: this.table
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getBuilder(entity) {
|
|
51
|
+
if (!entity.name) {
|
|
52
|
+
throw new Error("Entity must have a name.");
|
|
53
|
+
}
|
|
54
|
+
const builder = this.builders.get(entity.name);
|
|
55
|
+
if (builder) {
|
|
56
|
+
return builder;
|
|
57
|
+
}
|
|
58
|
+
const newBuilder = (0, _EntityWriteBatchBuilder.createEntityWriteBatchBuilder)(entity);
|
|
59
|
+
this.builders.set(entity.name, newBuilder);
|
|
60
|
+
return newBuilder;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.TableWriteBatch = TableWriteBatch;
|
|
64
|
+
const createTableWriteBatch = params => {
|
|
65
|
+
return new TableWriteBatch(params);
|
|
66
|
+
};
|
|
67
|
+
exports.createTableWriteBatch = createTableWriteBatch;
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=TableWriteBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_batchWrite","require","_EntityWriteBatchBuilder","TableWriteBatch","_items","builders","Map","total","length","items","Array","from","constructor","params","table","push","put","entity","item","builder","getBuilder","delete","combine","createTableWriteBatch","concat","execute","batchWriteAll","name","Error","get","newBuilder","createEntityWriteBatchBuilder","set","exports"],"sources":["TableWriteBatch.ts"],"sourcesContent":["import type { Entity, TableDef } from \"~/toolbox\";\nimport type {\n BatchWriteItem,\n BatchWriteResult,\n IDeleteBatchItem,\n IPutBatchItem\n} from \"~/utils/batch/types\";\nimport type { IEntityWriteBatchBuilder } from \"~/utils/entity/types\";\nimport { batchWriteAll } from \"~/utils/batch/batchWrite\";\nimport { createEntityWriteBatchBuilder } from \"~/utils/entity/EntityWriteBatchBuilder\";\nimport type { ITableWriteBatch } from \"./types\";\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"],"mappings":";;;;;;AAQA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAQO,MAAME,eAAe,CAA6B;EAEpCC,MAAM,GAAqB,EAAE;EAC7BC,QAAQ,GAA0C,IAAIC,GAAG,CAAC,CAAC;EAE5E,IAAWC,KAAKA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACH,MAAM,CAACI,MAAM;EAC7B;EAEA,IAAWC,KAAKA,CAAA,EAAqB;IACjC,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACP,MAAM,CAAC;EAClC;EAEOQ,WAAWA,CAACC,MAA8B,EAAE;IAC/C,IAAI,CAACC,KAAK,GAAGD,MAAM,CAACC,KAAK;IACzB,IAAI,CAACD,MAAM,CAACJ,KAAK,EAAED,MAAM,EAAE;MACvB;IACJ;IACA,IAAI,CAACJ,MAAM,CAACW,IAAI,CAAC,GAAGF,MAAM,CAACJ,KAAK,CAAC;EACrC;EAEOO,GAAGA,CAACC,MAAc,EAAEC,IAAmB,EAAQ;IAClD,MAAMC,OAAO,GAAG,IAAI,CAACC,UAAU,CAACH,MAAM,CAAC;IACvC,IAAI,CAACb,MAAM,CAACW,IAAI,CAACI,OAAO,CAACH,GAAG,CAACE,IAAI,CAAC,CAAC;EACvC;EAEOG,MAAMA,CAACJ,MAAc,EAAEC,IAAsB,EAAQ;IACxD,MAAMC,OAAO,GAAG,IAAI,CAACC,UAAU,CAACH,MAAM,CAAC;IACvC,IAAI,CAACb,MAAM,CAACW,IAAI,CAACI,OAAO,CAACE,MAAM,CAACH,IAAI,CAAC,CAAC;EAC1C;EAEOI,OAAOA,CAACb,KAAuB,EAAoB;IACtD,OAAOc,qBAAqB,CAAC;MACzBT,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBL,KAAK,EAAE,IAAI,CAACL,MAAM,CAACoB,MAAM,CAACf,KAAK;IACnC,CAAC,CAAC;EACN;EAEA,MAAagB,OAAOA,CAAA,EAA8B;IAC9C,IAAI,IAAI,CAACrB,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;MAC1B,OAAO,EAAE;IACb;IACA,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACP,MAAM,CAAC;IACrC,IAAI,CAACA,MAAM,CAACI,MAAM,GAAG,CAAC;IACtB,OAAO,MAAM,IAAAkB,yBAAa,EAAC;MACvBjB,KAAK;MACLK,KAAK,EAAE,IAAI,CAACA;IAChB,CAAC,CAAC;EACN;EAEQM,UAAUA,CAACH,MAAc,EAA4B;IACzD,IAAI,CAACA,MAAM,CAACU,IAAI,EAAE;MACd,MAAM,IAAIC,KAAK,CAAC,0BAA0B,CAAC;IAC/C;IACA,MAAMT,OAAO,GAAG,IAAI,CAACd,QAAQ,CAACwB,GAAG,CAACZ,MAAM,CAACU,IAAI,CAAC;IAC9C,IAAIR,OAAO,EAAE;MACT,OAAOA,OAAO;IAClB;IACA,MAAMW,UAAU,GAAG,IAAAC,sDAA6B,EAACd,MAAM,CAAC;IACxD,IAAI,CAACZ,QAAQ,CAAC2B,GAAG,CAACf,MAAM,CAACU,IAAI,EAAEG,UAAU,CAAC;IAC1C,OAAOA,UAAU;EACrB;AACJ;AAACG,OAAA,CAAA9B,eAAA,GAAAA,eAAA;AAEM,MAAMoB,qBAAqB,GAAIV,MAA8B,IAAuB;EACvF,OAAO,IAAIV,eAAe,CAACU,MAAM,CAAC;AACtC,CAAC;AAACoB,OAAA,CAAAV,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Table = require("./Table");
|
|
7
|
+
Object.keys(_Table).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Table[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _Table[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _TableReadBatch = require("./TableReadBatch");
|
|
18
|
+
Object.keys(_TableReadBatch).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _TableReadBatch[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _TableReadBatch[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _TableWriteBatch = require("./TableWriteBatch");
|
|
29
|
+
Object.keys(_TableWriteBatch).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _TableWriteBatch[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _TableWriteBatch[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _types = require("./types");
|
|
40
|
+
Object.keys(_types).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _types[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Table","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_TableReadBatch","_TableWriteBatch","_types"],"sources":["index.ts"],"sourcesContent":["export * from \"./Table\";\nexport * from \"./TableReadBatch\";\nexport * from \"./TableWriteBatch\";\nexport * from \"./types\";\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,eAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,eAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,eAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,eAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,gBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,gBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,gBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,gBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,MAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,MAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,MAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,MAAA,CAAAP,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { TableDef } from "dynamodb-toolbox/dist/cjs/classes/Table/types";
|
|
2
|
+
import type { BatchWriteItem, BatchWriteResult, IDeleteBatchItem, IPutBatchItem } from "../batch/types";
|
|
3
|
+
import type { BaseScanParams, ScanResponse } from "../scan";
|
|
4
|
+
import type { Entity } from "../../toolbox";
|
|
5
|
+
import type { GenericRecord } from "@webiny/api/types";
|
|
6
|
+
export type ITableScanParams = BaseScanParams;
|
|
7
|
+
export type ITableScanResponse<T> = ScanResponse<T>;
|
|
8
|
+
export interface ITable {
|
|
9
|
+
table: TableDef;
|
|
10
|
+
createWriter(): ITableWriteBatch;
|
|
11
|
+
createReader(): ITableReadBatch;
|
|
12
|
+
scan<T>(params: ITableScanParams): Promise<ITableScanResponse<T>>;
|
|
13
|
+
}
|
|
14
|
+
export interface ITableWriteBatch {
|
|
15
|
+
readonly total: number;
|
|
16
|
+
readonly items: BatchWriteItem[];
|
|
17
|
+
put(entity: Entity, item: IPutBatchItem): void;
|
|
18
|
+
delete(entity: Entity, item: IDeleteBatchItem): void;
|
|
19
|
+
execute(): Promise<BatchWriteResult>;
|
|
20
|
+
combine(items: BatchWriteItem[]): ITableWriteBatch;
|
|
21
|
+
}
|
|
22
|
+
export interface ITableReadBatchKey {
|
|
23
|
+
PK: string;
|
|
24
|
+
SK: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ITableReadBatchBuilderGetResponse {
|
|
27
|
+
Table: TableDef;
|
|
28
|
+
Key: ITableReadBatchKey;
|
|
29
|
+
}
|
|
30
|
+
export interface ITableReadBatchKey {
|
|
31
|
+
PK: string;
|
|
32
|
+
SK: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ITableReadBatch {
|
|
35
|
+
readonly total: number;
|
|
36
|
+
readonly items: ITableReadBatchBuilderGetResponse[];
|
|
37
|
+
get(entity: Entity, input: ITableReadBatchKey | ITableReadBatchKey[]): void;
|
|
38
|
+
execute<T = GenericRecord>(): Promise<T[]>;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { TableDef } from \"dynamodb-toolbox/dist/cjs/classes/Table/types\";\nimport type {\n BatchWriteItem,\n BatchWriteResult,\n IDeleteBatchItem,\n IPutBatchItem\n} from \"~/utils/batch/types\";\nimport type { BaseScanParams, ScanResponse } from \"../scan\";\nimport type { Entity } from \"~/toolbox\";\nimport type { GenericRecord } from \"@webiny/api/types\";\n\nexport type ITableScanParams = BaseScanParams;\n\nexport type ITableScanResponse<T> = ScanResponse<T>;\n\nexport interface ITable {\n table: TableDef;\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 table: TableDef;\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: TableDef;\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":[]}
|
package/utils/update.d.ts
CHANGED
package/utils/update.js
CHANGED
package/utils/update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["update","params","entity","item","execute","exports"],"sources":["update.ts"],"sourcesContent":["import { Entity } from \"~/toolbox\";\n\ninterface Params {\n entity: Entity;\n item: {\n PK: string;\n SK: string;\n [key: string]: any;\n };\n}\n\nexport const update = async (params: Params) => {\n const { entity, item } = params;\n\n return await entity.update(item, {\n execute: true\n });\n};\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["update","params","entity","item","execute","strictSchemaCheck","exports"],"sources":["update.ts"],"sourcesContent":["import { Entity } from \"~/toolbox\";\n\ninterface Params {\n entity: Entity;\n item: {\n PK: string;\n SK: string;\n TYPE?: string;\n [key: string]: any;\n };\n}\n\nexport const update = async (params: Params) => {\n const { entity, item } = params;\n\n return await entity.update(item, {\n execute: true,\n strictSchemaCheck: false\n });\n};\n"],"mappings":";;;;;;AAYO,MAAMA,MAAM,GAAG,MAAOC,MAAc,IAAK;EAC5C,MAAM;IAAEC,MAAM;IAAEC;EAAK,CAAC,GAAGF,MAAM;EAE/B,OAAO,MAAMC,MAAM,CAACF,MAAM,CAACG,IAAI,EAAE;IAC7BC,OAAO,EAAE,IAAI;IACbC,iBAAiB,EAAE;EACvB,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAN,MAAA,GAAAA,MAAA","ignoreList":[]}
|
package/utils/batchWrite.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { TableDef } from "../toolbox";
|
|
2
|
-
import { WriteRequest } from "@webiny/aws-sdk/client-dynamodb";
|
|
3
|
-
export interface BatchWriteItem {
|
|
4
|
-
[key: string]: WriteRequest;
|
|
5
|
-
}
|
|
6
|
-
export interface BatchWriteParams {
|
|
7
|
-
table?: TableDef;
|
|
8
|
-
items: BatchWriteItem[];
|
|
9
|
-
}
|
|
10
|
-
export interface BatchWriteResponse {
|
|
11
|
-
next?: () => Promise<BatchWriteResponse>;
|
|
12
|
-
$metadata: {
|
|
13
|
-
httpStatusCode: number;
|
|
14
|
-
requestId: string;
|
|
15
|
-
attempts: number;
|
|
16
|
-
totalRetryDelay: number;
|
|
17
|
-
};
|
|
18
|
-
UnprocessedItems?: {
|
|
19
|
-
[table: string]: WriteRequest[];
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export type BatchWriteResult = BatchWriteResponse[];
|
|
23
|
-
/**
|
|
24
|
-
* Method is meant for batch writing to a single table.
|
|
25
|
-
* It expects already prepared items for writing.
|
|
26
|
-
* It can either delete or put items
|
|
27
|
-
* The method does not check items before actually sending them into the underlying library.
|
|
28
|
-
*/
|
|
29
|
-
export declare const batchWriteAll: (params: BatchWriteParams, maxChunk?: number) => Promise<BatchWriteResult>;
|
package/utils/batchWrite.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_chunk","_interopRequireDefault","require","hasUnprocessedItems","result","next","items","UnprocessedItems","keys","Object","some","key","value","Array","isArray","val","PutRequest","DeleteRequest","retry","input","results","batchWriteAll","params","maxChunk","collection","table","console","log","length","chunkedItems","lodashChunk","batchWrite","execute","push","exports"],"sources":["batchWrite.ts"],"sourcesContent":["import lodashChunk from \"lodash/chunk\";\nimport { TableDef } from \"~/toolbox\";\nimport { WriteRequest } from \"@webiny/aws-sdk/client-dynamodb\";\n\nexport interface BatchWriteItem {\n [key: string]: WriteRequest;\n}\n\nexport interface BatchWriteParams {\n table?: TableDef;\n items: BatchWriteItem[];\n}\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\nconst hasUnprocessedItems = (result: BatchWriteResponse): boolean => {\n if (typeof result.next !== \"function\") {\n return false;\n }\n const items = result.UnprocessedItems;\n if (!items || typeof items !== \"object\") {\n return false;\n }\n const keys = Object.keys(items);\n return keys.some(key => {\n const value = items[key];\n if (!Array.isArray(value)) {\n return false;\n }\n return value.some(val => {\n return val.PutRequest || val.DeleteRequest;\n });\n });\n};\n\nconst retry = async (input: BatchWriteResponse, results: BatchWriteResult): Promise<void> => {\n if (!hasUnprocessedItems(input)) {\n return;\n }\n const result = await input.next!();\n await retry(result, results);\n};\n/**\n * Method is meant for batch writing to a single table.\n * It expects already prepared items for writing.\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 (\n params: BatchWriteParams,\n maxChunk = 25\n): Promise<BatchWriteResult> => {\n const { items: collection, table } = params;\n if (!table) {\n console.log(\"No table provided.\");\n return [];\n } else if (collection.length === 0) {\n return [];\n }\n\n const chunkedItems: BatchWriteItem[][] = lodashChunk(collection, maxChunk);\n const results: BatchWriteResult = [];\n for (const items of chunkedItems) {\n const result = (await table.batchWrite(items, {\n execute: true\n })) as BatchWriteResponse;\n results.push(result);\n await retry(result, results);\n }\n return results;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AA4BA,MAAMC,mBAAmB,GAAIC,MAA0B,IAAc;EACjE,IAAI,OAAOA,MAAM,CAACC,IAAI,KAAK,UAAU,EAAE;IACnC,OAAO,KAAK;EAChB;EACA,MAAMC,KAAK,GAAGF,MAAM,CAACG,gBAAgB;EACrC,IAAI,CAACD,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACrC,OAAO,KAAK;EAChB;EACA,MAAME,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACF,KAAK,CAAC;EAC/B,OAAOE,IAAI,CAACE,IAAI,CAACC,GAAG,IAAI;IACpB,MAAMC,KAAK,GAAGN,KAAK,CAACK,GAAG,CAAC;IACxB,IAAI,CAACE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACvB,OAAO,KAAK;IAChB;IACA,OAAOA,KAAK,CAACF,IAAI,CAACK,GAAG,IAAI;MACrB,OAAOA,GAAG,CAACC,UAAU,IAAID,GAAG,CAACE,aAAa;IAC9C,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAED,MAAMC,KAAK,GAAG,MAAAA,CAAOC,KAAyB,EAAEC,OAAyB,KAAoB;EACzF,IAAI,CAACjB,mBAAmB,CAACgB,KAAK,CAAC,EAAE;IAC7B;EACJ;EACA,MAAMf,MAAM,GAAG,MAAMe,KAAK,CAACd,IAAI,CAAE,CAAC;EAClC,MAAMa,KAAK,CAACd,MAAM,EAAEgB,OAAO,CAAC;AAChC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,aAAa,GAAG,MAAAA,CACzBC,MAAwB,EACxBC,QAAQ,GAAG,EAAE,KACe;EAC5B,MAAM;IAAEjB,KAAK,EAAEkB,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAC3C,IAAI,CAACG,KAAK,EAAE;IACRC,OAAO,CAACC,GAAG,CAAC,oBAAoB,CAAC;IACjC,OAAO,EAAE;EACb,CAAC,MAAM,IAAIH,UAAU,CAACI,MAAM,KAAK,CAAC,EAAE;IAChC,OAAO,EAAE;EACb;EAEA,MAAMC,YAAgC,GAAG,IAAAC,cAAW,EAACN,UAAU,EAAED,QAAQ,CAAC;EAC1E,MAAMH,OAAyB,GAAG,EAAE;EACpC,KAAK,MAAMd,KAAK,IAAIuB,YAAY,EAAE;IAC9B,MAAMzB,MAAM,GAAI,MAAMqB,KAAK,CAACM,UAAU,CAACzB,KAAK,EAAE;MAC1C0B,OAAO,EAAE;IACb,CAAC,CAAwB;IACzBZ,OAAO,CAACa,IAAI,CAAC7B,MAAM,CAAC;IACpB,MAAMc,KAAK,CAACd,MAAM,EAAEgB,OAAO,CAAC;EAChC;EACA,OAAOA,OAAO;AAClB,CAAC;AAACc,OAAA,CAAAb,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/utils/table.d.ts
DELETED
package/utils/table.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getTable = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
/**
|
|
10
|
-
* Will be removed in favor of passing the table name directly to the storage operations.
|
|
11
|
-
*
|
|
12
|
-
* @deprecated
|
|
13
|
-
*/
|
|
14
|
-
const getTable = context => {
|
|
15
|
-
if (!context.db) {
|
|
16
|
-
throw new _error.default("Missing db on context.", "DB_ERROR");
|
|
17
|
-
} else if (!context.db.table) {
|
|
18
|
-
throw new _error.default("Missing table on context.db.", "TABLE_ERROR");
|
|
19
|
-
}
|
|
20
|
-
return context.db.table;
|
|
21
|
-
};
|
|
22
|
-
exports.getTable = getTable;
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=table.js.map
|
package/utils/table.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","getTable","context","db","WebinyError","table","exports"],"sources":["table.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { DbContext } from \"@webiny/handler-db/types\";\n\n/**\n * Will be removed in favor of passing the table name directly to the storage operations.\n *\n * @deprecated\n */\nexport const getTable = <T extends DbContext>(context: T): string => {\n if (!context.db) {\n throw new WebinyError(\"Missing db on context.\", \"DB_ERROR\");\n } else if (!context.db.table) {\n throw new WebinyError(\"Missing table on context.db.\", \"TABLE_ERROR\");\n }\n return context.db.table;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACO,MAAMC,QAAQ,GAAyBC,OAAU,IAAa;EACjE,IAAI,CAACA,OAAO,CAACC,EAAE,EAAE;IACb,MAAM,IAAIC,cAAW,CAAC,wBAAwB,EAAE,UAAU,CAAC;EAC/D,CAAC,MAAM,IAAI,CAACF,OAAO,CAACC,EAAE,CAACE,KAAK,EAAE;IAC1B,MAAM,IAAID,cAAW,CAAC,8BAA8B,EAAE,aAAa,CAAC;EACxE;EACA,OAAOF,OAAO,CAACC,EAAE,CAACE,KAAK;AAC3B,CAAC;AAACC,OAAA,CAAAL,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|