@webiny/db-dynamodb 6.3.0-beta.4 → 6.4.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/DynamoDbDriver.js +204 -209
  2. package/DynamoDbDriver.js.map +1 -1
  3. package/exports/api/db.js +0 -2
  4. package/feature/FilterUtil/FilterUtil.js +18 -20
  5. package/feature/FilterUtil/FilterUtil.js.map +1 -1
  6. package/feature/FilterUtil/abstractions/FilterUtil.js +2 -1
  7. package/feature/FilterUtil/abstractions/FilterUtil.js.map +1 -1
  8. package/feature/FilterUtil/createFilters.js +82 -120
  9. package/feature/FilterUtil/createFilters.js.map +1 -1
  10. package/feature/FilterUtil/extractWhereArgs.js +15 -19
  11. package/feature/FilterUtil/extractWhereArgs.js.map +1 -1
  12. package/feature/FilterUtil/feature.js +6 -5
  13. package/feature/FilterUtil/feature.js.map +1 -1
  14. package/feature/FilterUtil/index.js +0 -2
  15. package/feature/ValueFilter/ValueFilterRegistry.js +21 -17
  16. package/feature/ValueFilter/ValueFilterRegistry.js.map +1 -1
  17. package/feature/ValueFilter/abstractions/ValueFilter.js +2 -1
  18. package/feature/ValueFilter/abstractions/ValueFilter.js.map +1 -1
  19. package/feature/ValueFilter/abstractions/ValueFilterRegistry.js +2 -1
  20. package/feature/ValueFilter/abstractions/ValueFilterRegistry.js.map +1 -1
  21. package/feature/ValueFilter/feature.js +17 -16
  22. package/feature/ValueFilter/feature.js.map +1 -1
  23. package/feature/ValueFilter/filters/AndInFilter.js +19 -23
  24. package/feature/ValueFilter/filters/AndInFilter.js.map +1 -1
  25. package/feature/ValueFilter/filters/BetweenFilter.js +23 -25
  26. package/feature/ValueFilter/filters/BetweenFilter.js.map +1 -1
  27. package/feature/ValueFilter/filters/ContainsFilter.js +34 -53
  28. package/feature/ValueFilter/filters/ContainsFilter.js.map +1 -1
  29. package/feature/ValueFilter/filters/EqFilter.js +17 -27
  30. package/feature/ValueFilter/filters/EqFilter.js.map +1 -1
  31. package/feature/ValueFilter/filters/FuzzyFilter.js +30 -30
  32. package/feature/ValueFilter/filters/FuzzyFilter.js.map +1 -1
  33. package/feature/ValueFilter/filters/GtFilter.js +16 -16
  34. package/feature/ValueFilter/filters/GtFilter.js.map +1 -1
  35. package/feature/ValueFilter/filters/GteFilter.js +16 -16
  36. package/feature/ValueFilter/filters/GteFilter.js.map +1 -1
  37. package/feature/ValueFilter/filters/InFilter.js +19 -23
  38. package/feature/ValueFilter/filters/InFilter.js.map +1 -1
  39. package/feature/ValueFilter/filters/LtFilter.js +16 -16
  40. package/feature/ValueFilter/filters/LtFilter.js.map +1 -1
  41. package/feature/ValueFilter/filters/LteFilter.js +16 -16
  42. package/feature/ValueFilter/filters/LteFilter.js.map +1 -1
  43. package/feature/ValueFilter/filters/StartsWithFilter.js +20 -36
  44. package/feature/ValueFilter/filters/StartsWithFilter.js.map +1 -1
  45. package/feature/ValueFilter/index.js +0 -2
  46. package/index.js +7 -9
  47. package/index.js.map +1 -1
  48. package/package.json +13 -13
  49. package/plugins/definitions/DateTimeTransformPlugin.js +18 -30
  50. package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -1
  51. package/plugins/definitions/FieldPlugin.js +34 -37
  52. package/plugins/definitions/FieldPlugin.js.map +1 -1
  53. package/plugins/definitions/TimeTransformPlugin.js +25 -37
  54. package/plugins/definitions/TimeTransformPlugin.js.map +1 -1
  55. package/plugins/definitions/ValueTransformPlugin.js +18 -17
  56. package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
  57. package/plugins/definitions/assignFields.js +14 -18
  58. package/plugins/definitions/assignFields.js.map +1 -1
  59. package/plugins/index.js +0 -2
  60. package/store/entity.js +6 -9
  61. package/store/entity.js.map +1 -1
  62. package/store/keys.js +6 -13
  63. package/store/keys.js.map +1 -1
  64. package/store/types.js +0 -3
  65. package/toolbox.js +0 -5
  66. package/types.js +0 -3
  67. package/utils/batch/batchRead.js +37 -56
  68. package/utils/batch/batchRead.js.map +1 -1
  69. package/utils/batch/batchWrite.js +33 -51
  70. package/utils/batch/batchWrite.js.map +1 -1
  71. package/utils/batch/index.js +0 -2
  72. package/utils/batch/types.js +0 -3
  73. package/utils/cleanup.js +35 -25
  74. package/utils/cleanup.js.map +1 -1
  75. package/utils/count.js +8 -14
  76. package/utils/count.js.map +1 -1
  77. package/utils/createEntity.d.ts +1 -1
  78. package/utils/createEntity.js +75 -78
  79. package/utils/createEntity.js.map +1 -1
  80. package/utils/createTable.js +25 -35
  81. package/utils/createTable.js.map +1 -1
  82. package/utils/cursor.js +7 -10
  83. package/utils/cursor.js.map +1 -1
  84. package/utils/delete.js +6 -8
  85. package/utils/delete.js.map +1 -1
  86. package/utils/entity/Entity.js +85 -90
  87. package/utils/entity/Entity.js.map +1 -1
  88. package/utils/entity/EntityReadBatch.js +23 -31
  89. package/utils/entity/EntityReadBatch.js.map +1 -1
  90. package/utils/entity/EntityReadBatchBuilder.js +12 -15
  91. package/utils/entity/EntityReadBatchBuilder.js.map +1 -1
  92. package/utils/entity/EntityWriteBatch.js +34 -41
  93. package/utils/entity/EntityWriteBatch.js.map +1 -1
  94. package/utils/entity/EntityWriteBatchBuilder.js +15 -16
  95. package/utils/entity/EntityWriteBatchBuilder.js.map +1 -1
  96. package/utils/entity/getEntity.js +8 -9
  97. package/utils/entity/getEntity.js.map +1 -1
  98. package/utils/entity/index.js +0 -2
  99. package/utils/entity/types.js +0 -4
  100. package/utils/get.js +12 -26
  101. package/utils/get.js.map +1 -1
  102. package/utils/index.js +1 -3
  103. package/utils/put.js +7 -9
  104. package/utils/put.js.map +1 -1
  105. package/utils/query.js +77 -129
  106. package/utils/query.js.map +1 -1
  107. package/utils/scan.js +47 -73
  108. package/utils/scan.js.map +1 -1
  109. package/utils/sort.js +37 -61
  110. package/utils/sort.js.map +1 -1
  111. package/utils/table/Table.js +22 -21
  112. package/utils/table/Table.js.map +1 -1
  113. package/utils/table/TableReadBatch.js +37 -45
  114. package/utils/table/TableReadBatch.js.map +1 -1
  115. package/utils/table/TableWriteBatch.js +47 -56
  116. package/utils/table/TableWriteBatch.js.map +1 -1
  117. package/utils/table/index.js +0 -2
  118. package/utils/table/types.js +0 -3
  119. package/exports/api/db.js.map +0 -1
  120. package/feature/FilterUtil/index.js.map +0 -1
  121. package/feature/ValueFilter/index.js.map +0 -1
  122. package/plugins/index.js.map +0 -1
  123. package/store/types.js.map +0 -1
  124. package/toolbox.js.map +0 -1
  125. package/types.js.map +0 -1
  126. package/utils/batch/index.js.map +0 -1
  127. package/utils/batch/types.js.map +0 -1
  128. package/utils/entity/index.js.map +0 -1
  129. package/utils/entity/types.js.map +0 -1
  130. package/utils/index.js.map +0 -1
  131. package/utils/table/index.js.map +0 -1
  132. package/utils/table/types.js.map +0 -1
@@ -1,39 +1,29 @@
1
1
  import { Table } from "./table/index.js";
2
-
3
- // export interface ICreateTableParams {
4
- // name?: string;
5
- // documentClient: DynamoDBDocument;
6
- // indexes?: GenericRecord<string, ICreateTableParamsIndexDefinition>;
7
- // }
8
-
9
- export const createTable = params => {
10
- const {
11
- documentClient,
12
- indexes = {},
13
- ...rest
14
- } = params;
15
- return new Table({
16
- partitionKey: "PK",
17
- sortKey: "SK",
18
- DocumentClient: documentClient,
19
- indexes: {
20
- GSI_TENANT: {
21
- partitionKey: "GSI_TENANT"
22
- },
23
- GSI1: {
24
- partitionKey: "GSI1_PK",
25
- sortKey: "GSI1_SK"
26
- },
27
- GSI2: {
28
- partitionKey: "GSI2_PK",
29
- sortKey: "GSI2_SK"
30
- },
31
- ...indexes
32
- },
33
- autoExecute: true,
34
- autoParse: true,
35
- ...rest
36
- });
2
+ const createTable = (params)=>{
3
+ const { documentClient, indexes = {}, ...rest } = params;
4
+ return new Table({
5
+ partitionKey: "PK",
6
+ sortKey: "SK",
7
+ DocumentClient: documentClient,
8
+ indexes: {
9
+ GSI_TENANT: {
10
+ partitionKey: "GSI_TENANT"
11
+ },
12
+ GSI1: {
13
+ partitionKey: "GSI1_PK",
14
+ sortKey: "GSI1_SK"
15
+ },
16
+ GSI2: {
17
+ partitionKey: "GSI2_PK",
18
+ sortKey: "GSI2_SK"
19
+ },
20
+ ...indexes
21
+ },
22
+ autoExecute: true,
23
+ autoParse: true,
24
+ ...rest
25
+ });
37
26
  };
27
+ export { createTable };
38
28
 
39
29
  //# sourceMappingURL=createTable.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Table","createTable","params","documentClient","indexes","rest","partitionKey","sortKey","DocumentClient","GSI_TENANT","GSI1","GSI2","autoExecute","autoParse"],"sources":["createTable.ts"],"sourcesContent":["import type { ITable } from \"~/utils/table/index.js\";\nimport { Table } from \"~/utils/table/index.js\";\nimport type { TableConstructor } from \"~/toolbox.js\";\n\nexport interface ICreateTableParamsIndexDefinition {\n partitionKey: string;\n sortKey?: string;\n}\n\n// export interface ICreateTableParams {\n// name?: string;\n// documentClient: DynamoDBDocument;\n// indexes?: GenericRecord<string, ICreateTableParamsIndexDefinition>;\n// }\n\nexport type ICreateTableParams = Partial<\n Omit<TableConstructor<string, string, string>, \"DocumentClient\">\n> & {\n name: string;\n documentClient: Pick<\n TableConstructor<string, string, string>,\n \"DocumentClient\"\n >[\"DocumentClient\"];\n};\n\nexport const createTable = (params: ICreateTableParams): ITable<string, \"PK\", \"SK\"> => {\n const { documentClient, indexes = {}, ...rest } = params;\n return new Table({\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI_TENANT: {\n partitionKey: \"GSI_TENANT\"\n },\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n },\n GSI2: {\n partitionKey: \"GSI2_PK\",\n sortKey: \"GSI2_SK\"\n },\n ...indexes\n },\n autoExecute: true,\n autoParse: true,\n ...rest\n });\n};\n"],"mappings":"AACA,SAASA,KAAK;;AAQd;AACA;AACA;AACA;AACA;;AAYA,OAAO,MAAMC,WAAW,GAAIC,MAA0B,IAAiC;EACnF,MAAM;IAAEC,cAAc;IAAEC,OAAO,GAAG,CAAC,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGH,MAAM;EACxD,OAAO,IAAIF,KAAK,CAAC;IACbM,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAEL,cAAc;IAC9BC,OAAO,EAAE;MACLK,UAAU,EAAE;QACRH,YAAY,EAAE;MAClB,CAAC;MACDI,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb,CAAC;MACDI,IAAI,EAAE;QACFL,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb,CAAC;MACD,GAAGH;IACP,CAAC;IACDQ,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE,IAAI;IACf,GAAGR;EACP,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/createTable.js","sources":["../../src/utils/createTable.ts"],"sourcesContent":["import type { ITable } from \"~/utils/table/index.js\";\nimport { Table } from \"~/utils/table/index.js\";\nimport type { TableConstructor } from \"~/toolbox.js\";\n\nexport interface ICreateTableParamsIndexDefinition {\n partitionKey: string;\n sortKey?: string;\n}\n\n// export interface ICreateTableParams {\n// name?: string;\n// documentClient: DynamoDBDocument;\n// indexes?: GenericRecord<string, ICreateTableParamsIndexDefinition>;\n// }\n\nexport type ICreateTableParams = Partial<\n Omit<TableConstructor<string, string, string>, \"DocumentClient\">\n> & {\n name: string;\n documentClient: Pick<\n TableConstructor<string, string, string>,\n \"DocumentClient\"\n >[\"DocumentClient\"];\n};\n\nexport const createTable = (params: ICreateTableParams): ITable<string, \"PK\", \"SK\"> => {\n const { documentClient, indexes = {}, ...rest } = params;\n return new Table({\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI_TENANT: {\n partitionKey: \"GSI_TENANT\"\n },\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n },\n GSI2: {\n partitionKey: \"GSI2_PK\",\n sortKey: \"GSI2_SK\"\n },\n ...indexes\n },\n autoExecute: true,\n autoParse: true,\n ...rest\n });\n};\n"],"names":["createTable","params","documentClient","indexes","rest","Table"],"mappings":";AAyBO,MAAMA,cAAc,CAACC;IACxB,MAAM,EAAEC,cAAc,EAAEC,UAAU,CAAC,CAAC,EAAE,GAAGC,MAAM,GAAGH;IAClD,OAAO,IAAII,MAAM;QACb,cAAc;QACd,SAAS;QACT,gBAAgBH;QAChB,SAAS;YACL,YAAY;gBACR,cAAc;YAClB;YACA,MAAM;gBACF,cAAc;gBACd,SAAS;YACb;YACA,MAAM;gBACF,cAAc;gBACd,SAAS;YACb;YACA,GAAGC,OAAO;QACd;QACA,aAAa;QACb,WAAW;QACX,GAAGC,IAAI;IACX;AACJ"}
package/utils/cursor.js CHANGED
@@ -1,14 +1,11 @@
1
- export const encodeCursor = cursor => {
2
- if (!cursor) {
3
- return null;
4
- }
5
- return Buffer.from(JSON.stringify(cursor)).toString("base64");
1
+ const encodeCursor = (cursor)=>{
2
+ if (!cursor) return null;
3
+ return Buffer.from(JSON.stringify(cursor)).toString("base64");
6
4
  };
7
- export const decodeCursor = cursor => {
8
- if (!cursor) {
9
- return null;
10
- }
11
- return JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
5
+ const decodeCursor = (cursor)=>{
6
+ if (!cursor) return null;
7
+ return JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
12
8
  };
9
+ export { decodeCursor, encodeCursor };
13
10
 
14
11
  //# sourceMappingURL=cursor.js.map
@@ -1 +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":"AAAA,OAAO,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;AAED,OAAO,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","ignoreList":[]}
1
+ {"version":3,"file":"utils/cursor.js","sources":["../../src/utils/cursor.ts"],"sourcesContent":["export const encodeCursor = (cursor?: any): string | null => {\n if (!cursor) {\n return null;\n }\n\n return Buffer.from(JSON.stringify(cursor)).toString(\"base64\");\n};\n\nexport const decodeCursor = (cursor?: string | null): string | null => {\n if (!cursor) {\n return null;\n }\n\n return JSON.parse(Buffer.from(cursor, \"base64\").toString(\"ascii\"));\n};\n"],"names":["encodeCursor","cursor","Buffer","JSON","decodeCursor"],"mappings":"AAAO,MAAMA,eAAe,CAACC;IACzB,IAAI,CAACA,QACD,OAAO;IAGX,OAAOC,OAAO,IAAI,CAACC,KAAK,SAAS,CAACF,SAAS,QAAQ,CAAC;AACxD;AAEO,MAAMG,eAAe,CAACH;IACzB,IAAI,CAACA,QACD,OAAO;IAGX,OAAOE,KAAK,KAAK,CAACD,OAAO,IAAI,CAACD,QAAQ,UAAU,QAAQ,CAAC;AAC7D"}
package/utils/delete.js CHANGED
@@ -1,11 +1,9 @@
1
- export const deleteItem = async params => {
2
- const {
3
- entity,
4
- keys
5
- } = params;
6
- return await entity.delete(keys, {
7
- execute: true
8
- });
1
+ const deleteItem = async (params)=>{
2
+ const { entity, keys } = params;
3
+ return await entity.delete(keys, {
4
+ execute: true
5
+ });
9
6
  };
7
+ export { deleteItem };
10
8
 
11
9
  //# sourceMappingURL=delete.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["deleteItem","params","entity","keys","delete","execute"],"sources":["delete.ts"],"sourcesContent":["import type { Entity } from \"~/toolbox.js\";\nexport interface IDeleteItemKeys {\n PK: string;\n SK: string;\n}\nexport interface IDeleteItemParams {\n entity: Entity;\n keys: IDeleteItemKeys;\n}\n\nexport const deleteItem = async (params: IDeleteItemParams) => {\n const { entity, keys } = params;\n\n return await entity.delete(keys, {\n execute: true\n });\n};\n"],"mappings":"AAUA,OAAO,MAAMA,UAAU,GAAG,MAAOC,MAAyB,IAAK;EAC3D,MAAM;IAAEC,MAAM;IAAEC;EAAK,CAAC,GAAGF,MAAM;EAE/B,OAAO,MAAMC,MAAM,CAACE,MAAM,CAACD,IAAI,EAAE;IAC7BE,OAAO,EAAE;EACb,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/delete.js","sources":["../../src/utils/delete.ts"],"sourcesContent":["import type { Entity } from \"~/toolbox.js\";\nexport interface IDeleteItemKeys {\n PK: string;\n SK: string;\n}\nexport interface IDeleteItemParams {\n entity: Entity;\n keys: IDeleteItemKeys;\n}\n\nexport const deleteItem = async (params: IDeleteItemParams) => {\n const { entity, keys } = params;\n\n return await entity.delete(keys, {\n execute: true\n });\n};\n"],"names":["deleteItem","params","entity","keys"],"mappings":"AAUO,MAAMA,aAAa,OAAOC;IAC7B,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGF;IAEzB,OAAO,MAAMC,OAAO,MAAM,CAACC,MAAM;QAC7B,SAAS;IACb;AACJ"}
@@ -1,4 +1,4 @@
1
- import { Entity as BaseEntity } from "../../toolbox.js";
1
+ import { Entity } from "../../toolbox.js";
2
2
  import { put } from "../put.js";
3
3
  import { get, getClean } from "../get.js";
4
4
  import { deleteItem } from "../delete.js";
@@ -6,95 +6,90 @@ import { createEntityReadBatch } from "./EntityReadBatch.js";
6
6
  import { createEntityWriteBatch } from "./EntityWriteBatch.js";
7
7
  import { createTableWriteBatch } from "../table/TableWriteBatch.js";
8
8
  import { queryAll, queryAllClean, queryOne, queryOneClean, queryPerPage } from "../query.js";
9
- export class Entity {
10
- get name() {
11
- return this.entity.name;
12
- }
13
- get table() {
14
- /**
15
- * Not possible to be undefined.
16
- */
17
- return this.entity.table;
18
- }
19
- constructor(params) {
20
- // @ts-expect-error
21
- this.entity = new BaseEntity(params);
22
- }
23
- createEntityReader(params) {
24
- return createEntityReadBatch({
25
- entity: this.entity,
26
- read: params?.read
27
- });
28
- }
29
- createEntityWriter(params) {
30
- return createEntityWriteBatch({
31
- entity: this.entity,
32
- put: params?.put,
33
- delete: params?.delete
34
- });
35
- }
36
- createTableWriter() {
37
- return createTableWriteBatch({
38
- table: this.entity.table
39
- });
40
- }
41
- async put(item) {
42
- return put({
43
- entity: this.entity,
44
- item
45
- });
46
- }
47
- async get(keys) {
48
- return get({
49
- entity: this.entity,
50
- keys
51
- });
52
- }
53
- async getClean(keys) {
54
- return getClean({
55
- entity: this.entity,
56
- keys
57
- });
58
- }
59
- async delete(keys) {
60
- return deleteItem({
61
- entity: this.entity,
62
- keys
63
- });
64
- }
65
- async queryOne(params) {
66
- return queryOne({
67
- ...params,
68
- entity: this.entity
69
- });
70
- }
71
- async queryOneClean(params) {
72
- return queryOneClean({
73
- ...params,
74
- entity: this.entity
75
- });
76
- }
77
- async queryAll(params) {
78
- return queryAll({
79
- ...params,
80
- entity: this.entity
81
- });
82
- }
83
- async queryAllClean(params) {
84
- return queryAllClean({
85
- ...params,
86
- entity: this.entity
87
- });
88
- }
89
- async queryPerPage(params) {
90
- return queryPerPage({
91
- ...params,
92
- entity: this.entity
93
- });
94
- }
9
+ class Entity_Entity {
10
+ get name() {
11
+ return this.entity.name;
12
+ }
13
+ get table() {
14
+ return this.entity.table;
15
+ }
16
+ constructor(params){
17
+ this.entity = new Entity(params);
18
+ }
19
+ createEntityReader(params) {
20
+ return createEntityReadBatch({
21
+ entity: this.entity,
22
+ read: params?.read
23
+ });
24
+ }
25
+ createEntityWriter(params) {
26
+ return createEntityWriteBatch({
27
+ entity: this.entity,
28
+ put: params?.put,
29
+ delete: params?.delete
30
+ });
31
+ }
32
+ createTableWriter() {
33
+ return createTableWriteBatch({
34
+ table: this.entity.table
35
+ });
36
+ }
37
+ async put(item) {
38
+ return put({
39
+ entity: this.entity,
40
+ item
41
+ });
42
+ }
43
+ async get(keys) {
44
+ return get({
45
+ entity: this.entity,
46
+ keys
47
+ });
48
+ }
49
+ async getClean(keys) {
50
+ return getClean({
51
+ entity: this.entity,
52
+ keys
53
+ });
54
+ }
55
+ async delete(keys) {
56
+ return deleteItem({
57
+ entity: this.entity,
58
+ keys
59
+ });
60
+ }
61
+ async queryOne(params) {
62
+ return queryOne({
63
+ ...params,
64
+ entity: this.entity
65
+ });
66
+ }
67
+ async queryOneClean(params) {
68
+ return queryOneClean({
69
+ ...params,
70
+ entity: this.entity
71
+ });
72
+ }
73
+ async queryAll(params) {
74
+ return queryAll({
75
+ ...params,
76
+ entity: this.entity
77
+ });
78
+ }
79
+ async queryAllClean(params) {
80
+ return queryAllClean({
81
+ ...params,
82
+ entity: this.entity
83
+ });
84
+ }
85
+ async queryPerPage(params) {
86
+ return queryPerPage({
87
+ ...params,
88
+ entity: this.entity
89
+ });
90
+ }
95
91
  }
96
- export const createEntity = params => {
97
- return new Entity(params);
98
- };
92
+ const createEntity = (params)=>new Entity_Entity(params);
93
+ export { Entity_Entity as Entity, createEntity };
99
94
 
100
95
  //# sourceMappingURL=Entity.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Entity","BaseEntity","put","get","getClean","deleteItem","createEntityReadBatch","createEntityWriteBatch","createTableWriteBatch","queryAll","queryAllClean","queryOne","queryOneClean","queryPerPage","name","entity","table","constructor","params","createEntityReader","read","createEntityWriter","delete","createTableWriter","item","keys","createEntity"],"sources":["Entity.ts"],"sourcesContent":["import type {\n AttributeDefinitions,\n EntityConstructor as BaseEntityConstructor,\n Readonly,\n TableDef\n} from \"~/toolbox.js\";\nimport { Entity as BaseEntity } from \"~/toolbox.js\";\nimport type { ITableWriteBatch } from \"../table/types.js\";\nimport type {\n IEntity,\n IEntityCreateEntityReaderParams,\n IEntityCreateEntityWriterParams,\n IEntityDeleteResult,\n IEntityGetCleanResult,\n IEntityGetResult,\n IEntityPutResult,\n IEntityQueryAllCleanResult,\n IEntityQueryAllParams,\n IEntityQueryAllResult,\n IEntityQueryOneCleanResult,\n IEntityQueryOneParams,\n IEntityQueryOneResult,\n IEntityQueryPerPageParams,\n IEntityReadBatch,\n IEntityWriteBatch\n} from \"./types.js\";\nimport type { IPutParamsItem } from \"../put.js\";\nimport { put } from \"../put.js\";\nimport type { GetRecordParamsKeys } from \"../get.js\";\nimport { get, getClean } from \"../get.js\";\nimport type { IDeleteItemKeys } from \"../delete.js\";\nimport { deleteItem } from \"../delete.js\";\nimport { createEntityReadBatch } from \"./EntityReadBatch.js\";\nimport { createEntityWriteBatch } from \"./EntityWriteBatch.js\";\nimport { createTableWriteBatch } from \"~/utils/table/TableWriteBatch.js\";\nimport { queryAll, queryAllClean, queryOne, queryOneClean, queryPerPage } from \"../query.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport type EntityConstructor<\n T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>\n> = BaseEntityConstructor<T>;\n\nexport class Entity<T extends GenericRecord = GenericRecord> implements IEntity<T> {\n public readonly entity: BaseEntity;\n\n public get name(): string {\n return this.entity.name;\n }\n\n public get table(): TableDef {\n /**\n * Not possible to be undefined.\n */\n return this.entity.table!;\n }\n\n public constructor(params: EntityConstructor) {\n // @ts-expect-error\n this.entity = new BaseEntity(params);\n }\n\n public createEntityReader(params?: IEntityCreateEntityReaderParams): IEntityReadBatch<T> {\n return createEntityReadBatch({\n entity: this.entity,\n read: params?.read\n });\n }\n\n public createEntityWriter(params?: IEntityCreateEntityWriterParams): IEntityWriteBatch<T> {\n return createEntityWriteBatch({\n entity: this.entity,\n put: params?.put,\n delete: params?.delete\n });\n }\n\n public createTableWriter(): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.entity.table as TableDef\n });\n }\n\n public async put<T extends GenericRecord = GenericRecord>(\n item: IPutParamsItem<T>\n ): IEntityPutResult {\n return put({\n entity: this.entity,\n item\n });\n }\n\n public async get<T>(keys: GetRecordParamsKeys): IEntityGetResult<T> {\n return get<T>({\n entity: this.entity,\n keys\n });\n }\n\n public async getClean<T>(keys: GetRecordParamsKeys): IEntityGetCleanResult<T> {\n return getClean<T>({\n entity: this.entity,\n keys\n });\n }\n\n public async delete(keys: IDeleteItemKeys): IEntityDeleteResult {\n return deleteItem({\n entity: this.entity,\n keys\n });\n }\n\n public async queryOne<T>(params: IEntityQueryOneParams): IEntityQueryOneResult<T> {\n return queryOne<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryOneClean<T>(params: IEntityQueryOneParams): IEntityQueryOneCleanResult<T> {\n return queryOneClean<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryAll<T>(params: IEntityQueryAllParams): IEntityQueryAllResult<T> {\n return queryAll<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryAllClean<T>(params: IEntityQueryAllParams): IEntityQueryAllCleanResult<T> {\n return queryAllClean<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryPerPage<T>(params: IEntityQueryPerPageParams) {\n return queryPerPage<T>({\n ...params,\n entity: this.entity\n });\n }\n}\n\nexport const createEntity = <T extends GenericRecord = GenericRecord>(\n params: EntityConstructor\n): IEntity<T> => {\n return new Entity<T>(params);\n};\n"],"mappings":"AAMA,SAASA,MAAM,IAAIC,UAAU;AAqB7B,SAASC,GAAG;AAEZ,SAASC,GAAG,EAAEC,QAAQ;AAEtB,SAASC,UAAU;AACnB,SAASC,qBAAqB;AAC9B,SAASC,sBAAsB;AAC/B,SAASC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AI;MACfW,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBU;IACJ,CAAC,CAAC;EACN;EAEA,MAAaH,MAAMA,CAACG,IAAqB,EAAuB;IAC5D,OAAOpB,UAAU,CAAC;MACdU,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBU;IACJ,CAAC,CAAC;EACN;EAEA,MAAad,QAAQA,CAAIO,MAA6B,EAA4B;IAC9E,OAAOP,QAAQ,CAAI;MACf,GAAGO,MAAM;MACTH,MAAM,EAAE,IAAI,CAACA;IACjB,CAAC,CAAC;EACN;EAEA,MAAaH,aAAaA,CAAIM,MAA6B,EAAiC;IACxF,OAAON,aAAa,CAAI;MACpB,GAAGM,MAAM;MACTH,MAAM,EAAE,IAAI,CAACA;IACjB,CAAC,CAAC;EACN;EAEA,MAAaN,QAAQA,CAAIS,MAA6B,EAA4B;IAC9E,OAAOT,QAAQ,CAAI;MACf,GAAGS,MAAM;MACTH,MAAM,EAAE,IAAI,CAACA;IACjB,CAAC,CAAC;EACN;EAEA,MAAaL,aAAaA,CAAIQ,MAA6B,EAAiC;IACxF,OAAOR,aAAa,CAAI;MACpB,GAAGQ,MAAM;MACTH,MAAM,EAAE,IAAI,CAACA;IACjB,CAAC,CAAC;EACN;EAEA,MAAaF,YAAYA,CAAIK,MAAiC,EAAE;IAC5D,OAAOL,YAAY,CAAI;MACnB,GAAGK,MAAM;MACTH,MAAM,EAAE,IAAI,CAACA;IACjB,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMW,YAAY,GACrBR,MAAyB,IACZ;EACb,OAAO,IAAIlB,MAAM,CAAIkB,MAAM,CAAC;AAChC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/entity/Entity.js","sources":["../../../src/utils/entity/Entity.ts"],"sourcesContent":["import type {\n AttributeDefinitions,\n EntityConstructor as BaseEntityConstructor,\n Readonly,\n TableDef\n} from \"~/toolbox.js\";\nimport { Entity as BaseEntity } from \"~/toolbox.js\";\nimport type { ITableWriteBatch } from \"../table/types.js\";\nimport type {\n IEntity,\n IEntityCreateEntityReaderParams,\n IEntityCreateEntityWriterParams,\n IEntityDeleteResult,\n IEntityGetCleanResult,\n IEntityGetResult,\n IEntityPutResult,\n IEntityQueryAllCleanResult,\n IEntityQueryAllParams,\n IEntityQueryAllResult,\n IEntityQueryOneCleanResult,\n IEntityQueryOneParams,\n IEntityQueryOneResult,\n IEntityQueryPerPageParams,\n IEntityReadBatch,\n IEntityWriteBatch\n} from \"./types.js\";\nimport type { IPutParamsItem } from \"../put.js\";\nimport { put } from \"../put.js\";\nimport type { GetRecordParamsKeys } from \"../get.js\";\nimport { get, getClean } from \"../get.js\";\nimport type { IDeleteItemKeys } from \"../delete.js\";\nimport { deleteItem } from \"../delete.js\";\nimport { createEntityReadBatch } from \"./EntityReadBatch.js\";\nimport { createEntityWriteBatch } from \"./EntityWriteBatch.js\";\nimport { createTableWriteBatch } from \"~/utils/table/TableWriteBatch.js\";\nimport { queryAll, queryAllClean, queryOne, queryOneClean, queryPerPage } from \"../query.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport type EntityConstructor<\n T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>\n> = BaseEntityConstructor<T>;\n\nexport class Entity<T extends GenericRecord = GenericRecord> implements IEntity<T> {\n public readonly entity: BaseEntity;\n\n public get name(): string {\n return this.entity.name;\n }\n\n public get table(): TableDef {\n /**\n * Not possible to be undefined.\n */\n return this.entity.table!;\n }\n\n public constructor(params: EntityConstructor) {\n // @ts-expect-error\n this.entity = new BaseEntity(params);\n }\n\n public createEntityReader(params?: IEntityCreateEntityReaderParams): IEntityReadBatch<T> {\n return createEntityReadBatch({\n entity: this.entity,\n read: params?.read\n });\n }\n\n public createEntityWriter(params?: IEntityCreateEntityWriterParams): IEntityWriteBatch<T> {\n return createEntityWriteBatch({\n entity: this.entity,\n put: params?.put,\n delete: params?.delete\n });\n }\n\n public createTableWriter(): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.entity.table as TableDef\n });\n }\n\n public async put<T extends GenericRecord = GenericRecord>(\n item: IPutParamsItem<T>\n ): IEntityPutResult {\n return put({\n entity: this.entity,\n item\n });\n }\n\n public async get<T>(keys: GetRecordParamsKeys): IEntityGetResult<T> {\n return get<T>({\n entity: this.entity,\n keys\n });\n }\n\n public async getClean<T>(keys: GetRecordParamsKeys): IEntityGetCleanResult<T> {\n return getClean<T>({\n entity: this.entity,\n keys\n });\n }\n\n public async delete(keys: IDeleteItemKeys): IEntityDeleteResult {\n return deleteItem({\n entity: this.entity,\n keys\n });\n }\n\n public async queryOne<T>(params: IEntityQueryOneParams): IEntityQueryOneResult<T> {\n return queryOne<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryOneClean<T>(params: IEntityQueryOneParams): IEntityQueryOneCleanResult<T> {\n return queryOneClean<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryAll<T>(params: IEntityQueryAllParams): IEntityQueryAllResult<T> {\n return queryAll<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryAllClean<T>(params: IEntityQueryAllParams): IEntityQueryAllCleanResult<T> {\n return queryAllClean<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryPerPage<T>(params: IEntityQueryPerPageParams) {\n return queryPerPage<T>({\n ...params,\n entity: this.entity\n });\n }\n}\n\nexport const createEntity = <T extends GenericRecord = GenericRecord>(\n params: EntityConstructor\n): IEntity<T> => {\n return new Entity<T>(params);\n};\n"],"names":["Entity","params","BaseEntity","createEntityReadBatch","createEntityWriteBatch","createTableWriteBatch","item","put","keys","get","getClean","deleteItem","queryOne","queryOneClean","queryAll","queryAllClean","queryPerPage","createEntity"],"mappings":";;;;;;;;AA0CO,MAAMA;IAGT,IAAW,OAAe;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IAC3B;IAEA,IAAW,QAAkB;QAIzB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK;IAC5B;IAEA,YAAmBC,MAAyB,CAAE;QAE1C,IA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CAAC,MAAM;QACvB;IACJ;IAEA,MAAa,aAAgBA,MAAiC,EAAE;QAC5D,OAAOe,aAAgB;YACnB,GAAGf,MAAM;YACT,QAAQ,IAAI,CAAC,MAAM;QACvB;IACJ;AACJ;AAEO,MAAMgB,eAAe,CACxBhB,SAEO,IAAID,cAAUC"}
@@ -1,39 +1,31 @@
1
1
  import { batchReadAll } from "../batch/batchRead.js";
2
2
  import { createEntityReadBatchBuilder } from "./EntityReadBatchBuilder.js";
3
3
  import { getEntity } from "./getEntity.js";
4
- export class EntityReadBatch {
5
- _items = [];
6
- get total() {
7
- return this._items.length;
8
- }
9
- get items() {
10
- return Array.from(this._items);
11
- }
12
- constructor(params) {
13
- this.entity = getEntity(params.entity);
14
- this.builder = createEntityReadBatchBuilder(this.entity);
15
- for (const item of params.read || []) {
16
- this.get(item);
4
+ class EntityReadBatch {
5
+ get total() {
6
+ return this._items.length;
17
7
  }
18
- }
19
- get(input) {
20
- if (Array.isArray(input)) {
21
- this._items.push(...input.map(item => {
22
- return this.builder.get(item);
23
- }));
24
- return;
8
+ get items() {
9
+ return Array.from(this._items);
10
+ }
11
+ constructor(params){
12
+ this._items = [];
13
+ this.entity = getEntity(params.entity);
14
+ this.builder = createEntityReadBatchBuilder(this.entity);
15
+ for (const item of params.read || [])this.get(item);
16
+ }
17
+ get(input) {
18
+ if (Array.isArray(input)) return void this._items.push(...input.map((item)=>this.builder.get(item)));
19
+ this._items.push(this.builder.get(input));
20
+ }
21
+ async execute() {
22
+ return await batchReadAll({
23
+ table: this.entity.table,
24
+ items: this._items
25
+ });
25
26
  }
26
- this._items.push(this.builder.get(input));
27
- }
28
- async execute() {
29
- return await batchReadAll({
30
- table: this.entity.table,
31
- items: this._items
32
- });
33
- }
34
27
  }
35
- export const createEntityReadBatch = params => {
36
- return new EntityReadBatch(params);
37
- };
28
+ const createEntityReadBatch = (params)=>new EntityReadBatch(params);
29
+ export { EntityReadBatch, createEntityReadBatch };
38
30
 
39
31
  //# sourceMappingURL=EntityReadBatch.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["batchReadAll","createEntityReadBatchBuilder","getEntity","EntityReadBatch","_items","total","length","items","Array","from","constructor","params","entity","builder","item","read","get","input","isArray","push","map","execute","table","createEntityReadBatch"],"sources":["EntityReadBatch.ts"],"sourcesContent":["import type { IReadBatchItem } from \"~/utils/batch/types.js\";\nimport type {\n IEntityReadBatch,\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse,\n IEntityReadBatchKey\n} from \"./types.js\";\nimport type { Entity as ToolboxEntity, TableDef } from \"~/toolbox.js\";\nimport { batchReadAll } from \"~/utils/batch/batchRead.js\";\nimport { createEntityReadBatchBuilder } from \"./EntityReadBatchBuilder.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport interface IEntityReadBatchParams {\n entity: EntityOption;\n read?: IReadBatchItem[];\n}\n\nexport class EntityReadBatch<T> implements IEntityReadBatch<T> {\n private readonly entity: ToolboxEntity;\n private readonly builder: IEntityReadBatchBuilder;\n private readonly _items: IEntityReadBatchBuilderGetResponse[] = [];\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 constructor(params: IEntityReadBatchParams) {\n this.entity = getEntity(params.entity);\n this.builder = createEntityReadBatchBuilder(this.entity);\n for (const item of params.read || []) {\n this.get(item);\n }\n }\n\n public get(input: IEntityReadBatchKey | IEntityReadBatchKey[]): void {\n if (Array.isArray(input)) {\n this._items.push(\n ...input.map(item => {\n return this.builder.get(item);\n })\n );\n return;\n }\n this._items.push(this.builder.get(input));\n }\n\n public async execute() {\n return await batchReadAll<T>({\n table: this.entity.table as TableDef,\n items: this._items\n });\n }\n}\n\nexport const createEntityReadBatch = <T>(params: IEntityReadBatchParams): IEntityReadBatch<T> => {\n return new EntityReadBatch<T>(params);\n};\n"],"mappings":"AAQA,SAASA,YAAY;AACrB,SAASC,4BAA4B;AA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"version":3,"file":"utils/entity/EntityReadBatch.js","sources":["../../../src/utils/entity/EntityReadBatch.ts"],"sourcesContent":["import type { IReadBatchItem } from \"~/utils/batch/types.js\";\nimport type {\n IEntityReadBatch,\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse,\n IEntityReadBatchKey\n} from \"./types.js\";\nimport type { Entity as ToolboxEntity, TableDef } from \"~/toolbox.js\";\nimport { batchReadAll } from \"~/utils/batch/batchRead.js\";\nimport { createEntityReadBatchBuilder } from \"./EntityReadBatchBuilder.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport interface IEntityReadBatchParams {\n entity: EntityOption;\n read?: IReadBatchItem[];\n}\n\nexport class EntityReadBatch<T> implements IEntityReadBatch<T> {\n private readonly entity: ToolboxEntity;\n private readonly builder: IEntityReadBatchBuilder;\n private readonly _items: IEntityReadBatchBuilderGetResponse[] = [];\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 constructor(params: IEntityReadBatchParams) {\n this.entity = getEntity(params.entity);\n this.builder = createEntityReadBatchBuilder(this.entity);\n for (const item of params.read || []) {\n this.get(item);\n }\n }\n\n public get(input: IEntityReadBatchKey | IEntityReadBatchKey[]): void {\n if (Array.isArray(input)) {\n this._items.push(\n ...input.map(item => {\n return this.builder.get(item);\n })\n );\n return;\n }\n this._items.push(this.builder.get(input));\n }\n\n public async execute() {\n return await batchReadAll<T>({\n table: this.entity.table as TableDef,\n items: this._items\n });\n }\n}\n\nexport const createEntityReadBatch = <T>(params: IEntityReadBatchParams): IEntityReadBatch<T> => {\n return new EntityReadBatch<T>(params);\n};\n"],"names":["EntityReadBatch","Array","params","getEntity","createEntityReadBatchBuilder","item","input","batchReadAll","createEntityReadBatch"],"mappings":";;;AAkBO,MAAMA;IAKT,IAAW,QAAgB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM;IAC7B;IAEA,IAAW,QAA8C;QACrD,OAAOC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;IACjC;IAEA,YAAmBC,MAA8B,CAAE;aAVlC,MAAM,GAAyC,EAAE;QAW9D,IAAI,CAAC,MAAM,GAAGC,UAAUD,OAAO,MAAM;QACrC,IAAI,CAAC,OAAO,GAAGE,6BAA6B,IAAI,CAAC,MAAM;QACvD,KAAK,MAAMC,QAAQH,OAAO,IAAI,IAAI,EAAE,CAChC,IAAI,CAAC,GAAG,CAACG;IAEjB;IAEO,IAAIC,KAAkD,EAAQ;QACjE,IAAIL,MAAM,OAAO,CAACK,QAAQ,YACtB,IAAI,CAAC,MAAM,CAAC,IAAI,IACTA,MAAM,GAAG,CAACD,CAAAA,OACF,IAAI,CAAC,OAAO,CAAC,GAAG,CAACA;QAKpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAACC;IACtC;IAEA,MAAa,UAAU;QACnB,OAAO,MAAMC,aAAgB;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK;YACxB,OAAO,IAAI,CAAC,MAAM;QACtB;IACJ;AACJ;AAEO,MAAMC,wBAAwB,CAAIN,SAC9B,IAAIF,gBAAmBE"}
@@ -1,21 +1,18 @@
1
1
  import { WebinyError } from "@webiny/error";
2
2
  import { getEntity } from "./getEntity.js";
3
- export class EntityReadBatchBuilder {
4
- constructor(entity) {
5
- this.entity = getEntity(entity);
6
- }
7
- get(item) {
8
- const result = this.entity.getBatch(item);
9
- if (!result.Table) {
10
- throw new WebinyError(`No table provided for entity ${this.entity.name}.`);
11
- } else if (!result.Key) {
12
- throw new WebinyError(`No key provided for entity ${this.entity.name}.`);
3
+ class EntityReadBatchBuilder {
4
+ constructor(entity){
5
+ this.entity = getEntity(entity);
6
+ }
7
+ get(item) {
8
+ const result = this.entity.getBatch(item);
9
+ if (result.Table) {
10
+ if (!result.Key) throw new WebinyError(`No key provided for entity ${this.entity.name}.`);
11
+ } else throw new WebinyError(`No table provided for entity ${this.entity.name}.`);
12
+ return result;
13
13
  }
14
- return result;
15
- }
16
14
  }
17
- export const createEntityReadBatchBuilder = entity => {
18
- return new EntityReadBatchBuilder(entity);
19
- };
15
+ const createEntityReadBatchBuilder = (entity)=>new EntityReadBatchBuilder(entity);
16
+ export { EntityReadBatchBuilder, createEntityReadBatchBuilder };
20
17
 
21
18
  //# sourceMappingURL=EntityReadBatchBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","getEntity","EntityReadBatchBuilder","constructor","entity","get","item","result","getBatch","Table","name","Key","createEntityReadBatchBuilder"],"sources":["EntityReadBatchBuilder.ts"],"sourcesContent":["import type { Entity as ToolboxEntity } from \"~/toolbox.js\";\nimport type {\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse,\n IEntityReadBatchKey\n} from \"./types.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { Entity } from \"./Entity.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport class EntityReadBatchBuilder implements IEntityReadBatchBuilder {\n private readonly entity: ToolboxEntity;\n\n public constructor(entity: EntityOption) {\n this.entity = getEntity(entity);\n }\n\n public get(item: IEntityReadBatchKey): IEntityReadBatchBuilderGetResponse {\n const result = this.entity.getBatch(item);\n if (!result.Table) {\n throw new WebinyError(`No table provided for entity ${this.entity.name}.`);\n } else if (!result.Key) {\n throw new WebinyError(`No key provided for entity ${this.entity.name}.`);\n }\n return result as unknown as IEntityReadBatchBuilderGetResponse;\n }\n}\n\nexport const createEntityReadBatchBuilder = (\n entity: ToolboxEntity | Entity\n): IEntityReadBatchBuilder => {\n return new EntityReadBatchBuilder(entity);\n};\n"],"mappings":"AAMA,SAASA,WAAW,QAAQ,eAAe;AAG3C,SAASC,SAAS;AAElB,OAAO,MAAMC,sBAAsB,CAAoC;EAG5DC,WAAWA,CAACC,MAAoB,EAAE;IACrC,IAAI,CAACA,MAAM,GAAGH,SAAS,CAACG,MAAM,CAAC;EACnC;EAEOC,GAAGA,CAACC,IAAyB,EAAsC;IACtE,MAAMC,MAAM,GAAG,IAAI,CAACH,MAAM,CAACI,QAAQ,CAACF,IAAI,CAAC;IACzC,IAAI,CAACC,MAAM,CAACE,KAAK,EAAE;MACf,MAAM,IAAIT,WAAW,CAAC,gCAAgC,IAAI,CAACI,MAAM,CAACM,IAAI,GAAG,CAAC;IAC9E,CAAC,MAAM,IAAI,CAACH,MAAM,CAACI,GAAG,EAAE;MACpB,MAAM,IAAIX,WAAW,CAAC,8BAA8B,IAAI,CAACI,MAAM,CAACM,IAAI,GAAG,CAAC;IAC5E;IACA,OAAOH,MAAM;EACjB;AACJ;AAEA,OAAO,MAAMK,4BAA4B,GACrCR,MAA8B,IACJ;EAC1B,OAAO,IAAIF,sBAAsB,CAACE,MAAM,CAAC;AAC7C,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/entity/EntityReadBatchBuilder.js","sources":["../../../src/utils/entity/EntityReadBatchBuilder.ts"],"sourcesContent":["import type { Entity as ToolboxEntity } from \"~/toolbox.js\";\nimport type {\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse,\n IEntityReadBatchKey\n} from \"./types.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { Entity } from \"./Entity.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport class EntityReadBatchBuilder implements IEntityReadBatchBuilder {\n private readonly entity: ToolboxEntity;\n\n public constructor(entity: EntityOption) {\n this.entity = getEntity(entity);\n }\n\n public get(item: IEntityReadBatchKey): IEntityReadBatchBuilderGetResponse {\n const result = this.entity.getBatch(item);\n if (!result.Table) {\n throw new WebinyError(`No table provided for entity ${this.entity.name}.`);\n } else if (!result.Key) {\n throw new WebinyError(`No key provided for entity ${this.entity.name}.`);\n }\n return result as unknown as IEntityReadBatchBuilderGetResponse;\n }\n}\n\nexport const createEntityReadBatchBuilder = (\n entity: ToolboxEntity | Entity\n): IEntityReadBatchBuilder => {\n return new EntityReadBatchBuilder(entity);\n};\n"],"names":["EntityReadBatchBuilder","entity","getEntity","item","result","WebinyError","createEntityReadBatchBuilder"],"mappings":";;AAWO,MAAMA;IAGT,YAAmBC,MAAoB,CAAE;QACrC,IAAI,CAAC,MAAM,GAAGC,UAAUD;IAC5B;IAEO,IAAIE,IAAyB,EAAsC;QACtE,MAAMC,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACD;QACpC,IAAKC,OAAO,KAAK,EAEV;YAAA,IAAI,CAACA,OAAO,GAAG,EAClB,MAAM,IAAIC,YAAY,CAAC,2BAA2B,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3E,OAHI,MAAM,IAAIA,YAAY,CAAC,6BAA6B,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAI7E,OAAOD;IACX;AACJ;AAEO,MAAME,+BAA+B,CACxCL,SAEO,IAAID,uBAAuBC"}
@@ -2,50 +2,43 @@ import { batchWriteAll } from "../batch/batchWrite.js";
2
2
  import { createTableWriteBatch } from "../table/TableWriteBatch.js";
3
3
  import { createEntityWriteBatchBuilder } from "./EntityWriteBatchBuilder.js";
4
4
  import { getEntity } from "./getEntity.js";
5
- export class EntityWriteBatch {
6
- _items = [];
7
- get total() {
8
- return this._items.length;
9
- }
10
- get items() {
11
- return Array.from(this._items);
12
- }
13
- constructor(params) {
14
- this.entity = getEntity(params.entity);
15
- this.builder = createEntityWriteBatchBuilder(this.entity);
16
- for (const item of params.put || []) {
17
- this.put(item);
5
+ class EntityWriteBatch {
6
+ get total() {
7
+ return this._items.length;
18
8
  }
19
- for (const item of params.delete || []) {
20
- this.delete(item);
9
+ get items() {
10
+ return Array.from(this._items);
21
11
  }
22
- }
23
- put(item) {
24
- this._items.push(this.builder.put(item));
25
- }
26
- delete(item) {
27
- this._items.push(this.builder.delete(item));
28
- }
29
- combine(items) {
30
- return createTableWriteBatch({
31
- table: this.entity.table,
32
- items: this._items.concat(items)
33
- });
34
- }
35
- async execute() {
36
- if (this._items.length === 0) {
37
- return [];
12
+ constructor(params){
13
+ this._items = [];
14
+ this.entity = getEntity(params.entity);
15
+ this.builder = createEntityWriteBatchBuilder(this.entity);
16
+ for (const item of params.put || [])this.put(item);
17
+ for (const item of params.delete || [])this.delete(item);
18
+ }
19
+ put(item) {
20
+ this._items.push(this.builder.put(item));
21
+ }
22
+ delete(item) {
23
+ this._items.push(this.builder.delete(item));
24
+ }
25
+ combine(items) {
26
+ return createTableWriteBatch({
27
+ table: this.entity.table,
28
+ items: this._items.concat(items)
29
+ });
30
+ }
31
+ async execute() {
32
+ if (0 === this._items.length) return [];
33
+ const items = Array.from(this._items);
34
+ this._items.length = 0;
35
+ return await batchWriteAll({
36
+ items,
37
+ table: this.entity.table
38
+ });
38
39
  }
39
- const items = Array.from(this._items);
40
- this._items.length = 0;
41
- return await batchWriteAll({
42
- items,
43
- table: this.entity.table
44
- });
45
- }
46
40
  }
47
- export const createEntityWriteBatch = params => {
48
- return new EntityWriteBatch(params);
49
- };
41
+ const createEntityWriteBatch = (params)=>new EntityWriteBatch(params);
42
+ export { EntityWriteBatch, createEntityWriteBatch };
50
43
 
51
44
  //# sourceMappingURL=EntityWriteBatch.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["batchWriteAll","createTableWriteBatch","createEntityWriteBatchBuilder","getEntity","EntityWriteBatch","_items","total","length","items","Array","from","constructor","params","entity","builder","item","put","delete","push","combine","table","concat","execute","createEntityWriteBatch"],"sources":["EntityWriteBatch.ts"],"sourcesContent":["import type { Entity as ToolboxEntity, TableDef } from \"~/toolbox.js\";\nimport { batchWriteAll } from \"~/utils/batch/batchWrite.js\";\nimport type {\n BatchWriteItem,\n BatchWriteResult,\n IDeleteBatchItem,\n IPutBatchItem\n} from \"~/utils/batch/types.js\";\nimport type { IEntityWriteBatch, IEntityWriteBatchBuilder } from \"./types.js\";\nimport type { ITableWriteBatch } from \"~/utils/table/types.js\";\nimport { createTableWriteBatch } from \"~/utils/table/TableWriteBatch.js\";\nimport { createEntityWriteBatchBuilder } from \"./EntityWriteBatchBuilder.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface IEntityWriteBatchParams<T = GenericRecord> {\n entity: EntityOption;\n put?: IPutBatchItem<T>[];\n delete?: IDeleteBatchItem[];\n}\n\nexport class EntityWriteBatch<T> implements IEntityWriteBatch<T> {\n private readonly entity: ToolboxEntity;\n private readonly _items: BatchWriteItem[] = [];\n private readonly builder: IEntityWriteBatchBuilder;\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: IEntityWriteBatchParams) {\n this.entity = getEntity(params.entity);\n this.builder = createEntityWriteBatchBuilder(this.entity);\n for (const item of params.put || []) {\n this.put(item);\n }\n for (const item of params.delete || []) {\n this.delete(item);\n }\n }\n\n public put(item: IPutBatchItem<T>): void {\n this._items.push(this.builder.put(item));\n }\n\n public delete(item: IDeleteBatchItem): void {\n this._items.push(this.builder.delete(item));\n }\n\n public combine(items: BatchWriteItem[]): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.entity!.table as TableDef,\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.entity.table\n });\n }\n}\n\nexport const createEntityWriteBatch = (params: IEntityWriteBatchParams): IEntityWriteBatch => {\n return new EntityWriteBatch(params);\n};\n"],"mappings":"AACA,SAASA,aAAa;AAStB,SAASC,qBAAqB;AAC9B,SAASC,6BAA6B;AAEtC,SAASC,SAAS;AASlB,OAAO,MAAMC,gBAAgB,CAAoC;EAE5CC,MAAM,GAAqB,EAAE;EAG9C,IAAWC,KAAKA,CAAA,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,CAAC;IACrC,IAAI,CAACA,MAAM,CAACE,MAAM,GAAG,CAAC;IACtB,OAAO,MAAMP,aAAa,CAAC;MACvBQ,KAAK;MACLY,KAAK,EAAE,IAAI,CAACP,MAAM,CAACO;IACvB,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMG,sBAAsB,GAAIX,MAA+B,IAAwB;EAC1F,OAAO,IAAIR,gBAAgB,CAACQ,MAAM,CAAC;AACvC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/entity/EntityWriteBatch.js","sources":["../../../src/utils/entity/EntityWriteBatch.ts"],"sourcesContent":["import type { Entity as ToolboxEntity, TableDef } from \"~/toolbox.js\";\nimport { batchWriteAll } from \"~/utils/batch/batchWrite.js\";\nimport type {\n BatchWriteItem,\n BatchWriteResult,\n IDeleteBatchItem,\n IPutBatchItem\n} from \"~/utils/batch/types.js\";\nimport type { IEntityWriteBatch, IEntityWriteBatchBuilder } from \"./types.js\";\nimport type { ITableWriteBatch } from \"~/utils/table/types.js\";\nimport { createTableWriteBatch } from \"~/utils/table/TableWriteBatch.js\";\nimport { createEntityWriteBatchBuilder } from \"./EntityWriteBatchBuilder.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface IEntityWriteBatchParams<T = GenericRecord> {\n entity: EntityOption;\n put?: IPutBatchItem<T>[];\n delete?: IDeleteBatchItem[];\n}\n\nexport class EntityWriteBatch<T> implements IEntityWriteBatch<T> {\n private readonly entity: ToolboxEntity;\n private readonly _items: BatchWriteItem[] = [];\n private readonly builder: IEntityWriteBatchBuilder;\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: IEntityWriteBatchParams) {\n this.entity = getEntity(params.entity);\n this.builder = createEntityWriteBatchBuilder(this.entity);\n for (const item of params.put || []) {\n this.put(item);\n }\n for (const item of params.delete || []) {\n this.delete(item);\n }\n }\n\n public put(item: IPutBatchItem<T>): void {\n this._items.push(this.builder.put(item));\n }\n\n public delete(item: IDeleteBatchItem): void {\n this._items.push(this.builder.delete(item));\n }\n\n public combine(items: BatchWriteItem[]): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.entity!.table as TableDef,\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.entity.table\n });\n }\n}\n\nexport const createEntityWriteBatch = (params: IEntityWriteBatchParams): IEntityWriteBatch => {\n return new EntityWriteBatch(params);\n};\n"],"names":["EntityWriteBatch","Array","params","getEntity","createEntityWriteBatchBuilder","item","items","createTableWriteBatch","batchWriteAll","createEntityWriteBatch"],"mappings":";;;;AAsBO,MAAMA;IAKT,IAAW,QAAgB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM;IAC7B;IAEA,IAAW,QAA0B;QACjC,OAAOC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;IACjC;IAEA,YAAmBC,MAA+B,CAAE;aAXnC,MAAM,GAAqB,EAAE;QAY1C,IAAI,CAAC,MAAM,GAAGC,UAAUD,OAAO,MAAM;QACrC,IAAI,CAAC,OAAO,GAAGE,8BAA8B,IAAI,CAAC,MAAM;QACxD,KAAK,MAAMC,QAAQH,OAAO,GAAG,IAAI,EAAE,CAC/B,IAAI,CAAC,GAAG,CAACG;QAEb,KAAK,MAAMA,QAAQH,OAAO,MAAM,IAAI,EAAE,CAClC,IAAI,CAAC,MAAM,CAACG;IAEpB;IAEO,IAAIA,IAAsB,EAAQ;QACrC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAACA;IACtC;IAEO,OAAOA,IAAsB,EAAQ;QACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC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