@webiny/db-dynamodb 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9

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 (215) hide show
  1. package/DynamoDbDriver.js +204 -209
  2. package/DynamoDbDriver.js.map +1 -1
  3. package/exports/api/db.d.ts +2 -0
  4. package/exports/api/db.js +2 -0
  5. package/feature/FilterUtil/FilterUtil.d.ts +11 -0
  6. package/feature/FilterUtil/FilterUtil.js +26 -0
  7. package/feature/FilterUtil/FilterUtil.js.map +1 -0
  8. package/feature/FilterUtil/abstractions/FilterUtil.d.ts +17 -0
  9. package/feature/FilterUtil/abstractions/FilterUtil.js +5 -0
  10. package/feature/FilterUtil/abstractions/FilterUtil.js.map +1 -0
  11. package/feature/FilterUtil/createFilters.d.ts +22 -0
  12. package/feature/FilterUtil/createFilters.js +92 -0
  13. package/feature/FilterUtil/createFilters.js.map +1 -0
  14. package/feature/FilterUtil/extractWhereArgs.d.ts +7 -0
  15. package/feature/FilterUtil/extractWhereArgs.js +20 -0
  16. package/feature/FilterUtil/extractWhereArgs.js.map +1 -0
  17. package/feature/FilterUtil/feature.d.ts +4 -0
  18. package/feature/FilterUtil/feature.js +11 -0
  19. package/feature/FilterUtil/feature.js.map +1 -0
  20. package/feature/FilterUtil/index.d.ts +2 -0
  21. package/feature/FilterUtil/index.js +2 -0
  22. package/feature/ValueFilter/ValueFilterRegistry.d.ts +12 -0
  23. package/feature/ValueFilter/ValueFilterRegistry.js +27 -0
  24. package/feature/ValueFilter/ValueFilterRegistry.js.map +1 -0
  25. package/feature/ValueFilter/abstractions/ValueFilter.d.ts +22 -0
  26. package/feature/ValueFilter/abstractions/ValueFilter.js +5 -0
  27. package/feature/ValueFilter/abstractions/ValueFilter.js.map +1 -0
  28. package/feature/ValueFilter/abstractions/ValueFilterRegistry.d.ts +10 -0
  29. package/feature/ValueFilter/abstractions/ValueFilterRegistry.js +5 -0
  30. package/feature/ValueFilter/abstractions/ValueFilterRegistry.js.map +1 -0
  31. package/feature/ValueFilter/feature.d.ts +4 -0
  32. package/feature/ValueFilter/feature.js +33 -0
  33. package/feature/ValueFilter/feature.js.map +1 -0
  34. package/feature/ValueFilter/filters/AndInFilter.d.ts +11 -0
  35. package/feature/ValueFilter/filters/AndInFilter.js +28 -0
  36. package/feature/ValueFilter/filters/AndInFilter.js.map +1 -0
  37. package/feature/ValueFilter/filters/BetweenFilter.d.ts +11 -0
  38. package/feature/ValueFilter/filters/BetweenFilter.js +31 -0
  39. package/feature/ValueFilter/filters/BetweenFilter.js.map +1 -0
  40. package/feature/ValueFilter/filters/ContainsFilter.d.ts +11 -0
  41. package/feature/ValueFilter/filters/ContainsFilter.js +42 -0
  42. package/feature/ValueFilter/filters/ContainsFilter.js.map +1 -0
  43. package/feature/ValueFilter/filters/EqFilter.d.ts +11 -0
  44. package/feature/ValueFilter/filters/EqFilter.js +24 -0
  45. package/feature/ValueFilter/filters/EqFilter.js.map +1 -0
  46. package/feature/ValueFilter/filters/FuzzyFilter.d.ts +11 -0
  47. package/feature/ValueFilter/filters/FuzzyFilter.js +37 -0
  48. package/feature/ValueFilter/filters/FuzzyFilter.js.map +1 -0
  49. package/feature/ValueFilter/filters/GtFilter.d.ts +11 -0
  50. package/feature/ValueFilter/filters/GtFilter.js +22 -0
  51. package/feature/ValueFilter/filters/GtFilter.js.map +1 -0
  52. package/feature/ValueFilter/filters/GteFilter.d.ts +11 -0
  53. package/feature/ValueFilter/filters/GteFilter.js +22 -0
  54. package/feature/ValueFilter/filters/GteFilter.js.map +1 -0
  55. package/feature/ValueFilter/filters/InFilter.d.ts +11 -0
  56. package/feature/ValueFilter/filters/InFilter.js +28 -0
  57. package/feature/ValueFilter/filters/InFilter.js.map +1 -0
  58. package/feature/ValueFilter/filters/LtFilter.d.ts +11 -0
  59. package/feature/ValueFilter/filters/LtFilter.js +22 -0
  60. package/feature/ValueFilter/filters/LtFilter.js.map +1 -0
  61. package/feature/ValueFilter/filters/LteFilter.d.ts +11 -0
  62. package/feature/ValueFilter/filters/LteFilter.js +22 -0
  63. package/feature/ValueFilter/filters/LteFilter.js.map +1 -0
  64. package/feature/ValueFilter/filters/StartsWithFilter.d.ts +11 -0
  65. package/feature/ValueFilter/filters/StartsWithFilter.js +29 -0
  66. package/feature/ValueFilter/filters/StartsWithFilter.js.map +1 -0
  67. package/feature/ValueFilter/index.d.ts +3 -0
  68. package/feature/ValueFilter/index.js +3 -0
  69. package/index.d.ts +1 -0
  70. package/index.js +9 -2
  71. package/index.js.map +1 -1
  72. package/package.json +28 -20
  73. package/plugins/definitions/DateTimeTransformPlugin.js +18 -27
  74. package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -1
  75. package/plugins/definitions/FieldPlugin.js +34 -37
  76. package/plugins/definitions/FieldPlugin.js.map +1 -1
  77. package/plugins/definitions/TimeTransformPlugin.js +25 -37
  78. package/plugins/definitions/TimeTransformPlugin.js.map +1 -1
  79. package/plugins/definitions/ValueTransformPlugin.d.ts +1 -6
  80. package/plugins/definitions/ValueTransformPlugin.js +17 -22
  81. package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
  82. package/plugins/definitions/assignFields.js +14 -18
  83. package/plugins/definitions/assignFields.js.map +1 -1
  84. package/plugins/index.d.ts +0 -5
  85. package/plugins/index.js +0 -12
  86. package/store/entity.js +6 -9
  87. package/store/entity.js.map +1 -1
  88. package/store/keys.js +6 -13
  89. package/store/keys.js.map +1 -1
  90. package/store/types.js +0 -3
  91. package/toolbox.d.ts +53 -1
  92. package/toolbox.js +0 -4
  93. package/types.js +0 -3
  94. package/utils/batch/batchRead.js +37 -56
  95. package/utils/batch/batchRead.js.map +1 -1
  96. package/utils/batch/batchWrite.js +33 -51
  97. package/utils/batch/batchWrite.js.map +1 -1
  98. package/utils/batch/index.js +0 -2
  99. package/utils/batch/types.js +0 -3
  100. package/utils/cleanup.js +35 -25
  101. package/utils/cleanup.js.map +1 -1
  102. package/utils/count.js +8 -13
  103. package/utils/count.js.map +1 -1
  104. package/utils/createEntity.d.ts +1 -1
  105. package/utils/createEntity.js +75 -78
  106. package/utils/createEntity.js.map +1 -1
  107. package/utils/createTable.js +25 -35
  108. package/utils/createTable.js.map +1 -1
  109. package/utils/cursor.js +7 -10
  110. package/utils/cursor.js.map +1 -1
  111. package/utils/delete.js +6 -8
  112. package/utils/delete.js.map +1 -1
  113. package/utils/entity/Entity.d.ts +1 -1
  114. package/utils/entity/Entity.js +85 -89
  115. package/utils/entity/Entity.js.map +1 -1
  116. package/utils/entity/EntityReadBatch.js +23 -31
  117. package/utils/entity/EntityReadBatch.js.map +1 -1
  118. package/utils/entity/EntityReadBatchBuilder.js +12 -15
  119. package/utils/entity/EntityReadBatchBuilder.js.map +1 -1
  120. package/utils/entity/EntityWriteBatch.js +34 -41
  121. package/utils/entity/EntityWriteBatch.js.map +1 -1
  122. package/utils/entity/EntityWriteBatchBuilder.js +15 -16
  123. package/utils/entity/EntityWriteBatchBuilder.js.map +1 -1
  124. package/utils/entity/getEntity.js +8 -9
  125. package/utils/entity/getEntity.js.map +1 -1
  126. package/utils/entity/index.js +0 -2
  127. package/utils/entity/types.js +0 -4
  128. package/utils/get.js +12 -26
  129. package/utils/get.js.map +1 -1
  130. package/utils/index.d.ts +1 -5
  131. package/utils/index.js +1 -7
  132. package/utils/put.js +7 -9
  133. package/utils/put.js.map +1 -1
  134. package/utils/query.js +77 -128
  135. package/utils/query.js.map +1 -1
  136. package/utils/scan.js +47 -73
  137. package/utils/scan.js.map +1 -1
  138. package/utils/sort.js +37 -61
  139. package/utils/sort.js.map +1 -1
  140. package/utils/table/Table.js +22 -21
  141. package/utils/table/Table.js.map +1 -1
  142. package/utils/table/TableReadBatch.js +37 -45
  143. package/utils/table/TableReadBatch.js.map +1 -1
  144. package/utils/table/TableWriteBatch.js +47 -56
  145. package/utils/table/TableWriteBatch.js.map +1 -1
  146. package/utils/table/index.js +0 -2
  147. package/utils/table/types.js +0 -3
  148. package/plugins/definitions/AttributePlugin.d.ts +0 -18
  149. package/plugins/definitions/AttributePlugin.js +0 -38
  150. package/plugins/definitions/AttributePlugin.js.map +0 -1
  151. package/plugins/definitions/FieldPathPlugin.d.ts +0 -22
  152. package/plugins/definitions/FieldPathPlugin.js +0 -26
  153. package/plugins/definitions/FieldPathPlugin.js.map +0 -1
  154. package/plugins/definitions/ValueFilterPlugin.d.ts +0 -22
  155. package/plugins/definitions/ValueFilterPlugin.js +0 -35
  156. package/plugins/definitions/ValueFilterPlugin.js.map +0 -1
  157. package/plugins/filters/andIn.d.ts +0 -3
  158. package/plugins/filters/andIn.js +0 -24
  159. package/plugins/filters/andIn.js.map +0 -1
  160. package/plugins/filters/between.d.ts +0 -3
  161. package/plugins/filters/between.js +0 -25
  162. package/plugins/filters/between.js.map +0 -1
  163. package/plugins/filters/contains.d.ts +0 -3
  164. package/plugins/filters/contains.js +0 -53
  165. package/plugins/filters/contains.js.map +0 -1
  166. package/plugins/filters/eq.d.ts +0 -3
  167. package/plugins/filters/eq.js +0 -26
  168. package/plugins/filters/eq.js.map +0 -1
  169. package/plugins/filters/fuzzy.d.ts +0 -3
  170. package/plugins/filters/fuzzy.js +0 -29
  171. package/plugins/filters/fuzzy.js.map +0 -1
  172. package/plugins/filters/gt.d.ts +0 -3
  173. package/plugins/filters/gt.js +0 -14
  174. package/plugins/filters/gt.js.map +0 -1
  175. package/plugins/filters/gte.d.ts +0 -3
  176. package/plugins/filters/gte.js +0 -14
  177. package/plugins/filters/gte.js.map +0 -1
  178. package/plugins/filters/in.d.ts +0 -3
  179. package/plugins/filters/in.js +0 -24
  180. package/plugins/filters/in.js.map +0 -1
  181. package/plugins/filters/index.d.ts +0 -2
  182. package/plugins/filters/index.js +0 -14
  183. package/plugins/filters/index.js.map +0 -1
  184. package/plugins/filters/lt.d.ts +0 -3
  185. package/plugins/filters/lt.js +0 -14
  186. package/plugins/filters/lt.js.map +0 -1
  187. package/plugins/filters/lte.d.ts +0 -3
  188. package/plugins/filters/lte.js +0 -14
  189. package/plugins/filters/lte.js.map +0 -1
  190. package/plugins/filters/startsWith.d.ts +0 -3
  191. package/plugins/filters/startsWith.js +0 -34
  192. package/plugins/filters/startsWith.js.map +0 -1
  193. package/plugins/index.js.map +0 -1
  194. package/store/types.js.map +0 -1
  195. package/toolbox.js.map +0 -1
  196. package/types.js.map +0 -1
  197. package/utils/attributes.d.ts +0 -10
  198. package/utils/attributes.js +0 -19
  199. package/utils/attributes.js.map +0 -1
  200. package/utils/batch/index.js.map +0 -1
  201. package/utils/batch/types.js.map +0 -1
  202. package/utils/entity/index.js.map +0 -1
  203. package/utils/entity/types.js.map +0 -1
  204. package/utils/filter.d.ts +0 -12
  205. package/utils/filter.js +0 -174
  206. package/utils/filter.js.map +0 -1
  207. package/utils/index.js.map +0 -1
  208. package/utils/listResponse.d.ts +0 -13
  209. package/utils/listResponse.js +0 -25
  210. package/utils/listResponse.js.map +0 -1
  211. package/utils/table/index.js.map +0 -1
  212. package/utils/table/types.js.map +0 -1
  213. package/utils/update.d.ts +0 -12
  214. package/utils/update.js +0 -12
  215. package/utils/update.js.map +0 -1
package/utils/cleanup.js CHANGED
@@ -1,30 +1,40 @@
1
- /**
2
- * The attributes defined by us or the dynamodb-toolbox library.
3
- * Add more attributes if necessary.
4
- */
5
- const attributesToRemove = ["PK", "SK", "created", "_ct", "modified", "_mt", "entity", "_et", "GSI1_PK", "GSI1_SK", "GSI2_PK", "GSI2_SK", "GSI3_PK", "GSI3_SK", "GSI4_PK", "GSI4_SK", "GSI5_PK", "GSI5_SK", "GSI_TENANT", "TYPE"];
6
- export function cleanupItem(entity, item, removeAttributes = []) {
7
- if (!item) {
8
- return null;
9
- }
10
- const newItem = {
11
- ...item
12
- };
13
- const targets = attributesToRemove.concat(removeAttributes);
14
- const attributes = entity.schema.attributes;
15
- for (const key in item) {
16
- if (item.hasOwnProperty(key) === false) {
17
- continue;
1
+ const attributesToRemove = [
2
+ "PK",
3
+ "SK",
4
+ "created",
5
+ "_ct",
6
+ "modified",
7
+ "_mt",
8
+ "entity",
9
+ "_et",
10
+ "GSI1_PK",
11
+ "GSI1_SK",
12
+ "GSI2_PK",
13
+ "GSI2_SK",
14
+ "GSI3_PK",
15
+ "GSI3_SK",
16
+ "GSI4_PK",
17
+ "GSI4_SK",
18
+ "GSI5_PK",
19
+ "GSI5_SK",
20
+ "GSI_TENANT",
21
+ "TYPE"
22
+ ];
23
+ function cleanupItem(entity, item, removeAttributes = []) {
24
+ if (!item) return null;
25
+ const newItem = {
26
+ ...item
27
+ };
28
+ const targets = attributesToRemove.concat(removeAttributes);
29
+ const attributes = entity.schema.attributes;
30
+ for(const key in item)if (false !== item.hasOwnProperty(key)) {
31
+ if (!attributes[key] || false !== targets.includes(key)) delete newItem[key];
18
32
  }
19
- if (attributes[key] && targets.includes(key) === false) {
20
- continue;
21
- }
22
- delete newItem[key];
23
- }
24
- return newItem;
33
+ return newItem;
25
34
  }
26
- export function cleanupItems(entity, items, removeAttributes = []) {
27
- return items.map(item => cleanupItem(entity, item, removeAttributes));
35
+ function cleanupItems(entity, items, removeAttributes = []) {
36
+ return items.map((item)=>cleanupItem(entity, item, removeAttributes));
28
37
  }
38
+ export { cleanupItem, cleanupItems };
29
39
 
30
40
  //# sourceMappingURL=cleanup.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["attributesToRemove","cleanupItem","entity","item","removeAttributes","newItem","targets","concat","attributes","schema","key","hasOwnProperty","includes","cleanupItems","items","map"],"sources":["cleanup.ts"],"sourcesContent":["import type { Entity } from \"~/toolbox.js\";\n\n/**\n * The attributes defined by us or the dynamodb-toolbox library.\n * Add more attributes if necessary.\n */\nconst attributesToRemove = [\n \"PK\",\n \"SK\",\n \"created\",\n \"_ct\",\n \"modified\",\n \"_mt\",\n \"entity\",\n \"_et\",\n \"GSI1_PK\",\n \"GSI1_SK\",\n \"GSI2_PK\",\n \"GSI2_SK\",\n \"GSI3_PK\",\n \"GSI3_SK\",\n \"GSI4_PK\",\n \"GSI4_SK\",\n \"GSI5_PK\",\n \"GSI5_SK\",\n \"GSI_TENANT\",\n \"TYPE\"\n];\n\nexport function cleanupItem<T>(\n entity: Entity<any>,\n item?: T | null,\n removeAttributes: string[] = []\n): T | null {\n if (!item) {\n return null;\n }\n const newItem = {\n ...item\n };\n const targets = attributesToRemove.concat(removeAttributes);\n const attributes = entity.schema.attributes;\n for (const key in item) {\n if (item.hasOwnProperty(key) === false) {\n continue;\n }\n if (attributes[key] && targets.includes(key) === false) {\n continue;\n }\n delete newItem[key];\n }\n return newItem;\n}\n\nexport function cleanupItems<T>(\n entity: Entity<any>,\n items: T[],\n removeAttributes: string[] = []\n): T[] {\n return items.map(item => cleanupItem<T>(entity, item, removeAttributes) as T);\n}\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA,MAAMA,kBAAkB,GAAG,CACvB,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,KAAK,EACL,UAAU,EACV,KAAK,EACL,QAAQ,EACR,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,YAAY,EACZ,MAAM,CACT;AAED,OAAO,SAASC,WAAWA,CACvBC,MAAmB,EACnBC,IAAe,EACfC,gBAA0B,GAAG,EAAE,EACvB;EACR,IAAI,CAACD,IAAI,EAAE;IACP,OAAO,IAAI;EACf;EACA,MAAME,OAAO,GAAG;IACZ,GAAGF;EACP,CAAC;EACD,MAAMG,OAAO,GAAGN,kBAAkB,CAACO,MAAM,CAACH,gBAAgB,CAAC;EAC3D,MAAMI,UAAU,GAAGN,MAAM,CAACO,MAAM,CAACD,UAAU;EAC3C,KAAK,MAAME,GAAG,IAAIP,IAAI,EAAE;IACpB,IAAIA,IAAI,CAACQ,cAAc,CAACD,GAAG,CAAC,KAAK,KAAK,EAAE;MACpC;IACJ;IACA,IAAIF,UAAU,CAACE,GAAG,CAAC,IAAIJ,OAAO,CAACM,QAAQ,CAACF,GAAG,CAAC,KAAK,KAAK,EAAE;MACpD;IACJ;IACA,OAAOL,OAAO,CAACK,GAAG,CAAC;EACvB;EACA,OAAOL,OAAO;AAClB;AAEA,OAAO,SAASQ,YAAYA,CACxBX,MAAmB,EACnBY,KAAU,EACVV,gBAA0B,GAAG,EAAE,EAC5B;EACH,OAAOU,KAAK,CAACC,GAAG,CAACZ,IAAI,IAAIF,WAAW,CAAIC,MAAM,EAAEC,IAAI,EAAEC,gBAAgB,CAAM,CAAC;AACjF","ignoreList":[]}
1
+ {"version":3,"file":"utils/cleanup.js","sources":["../../src/utils/cleanup.ts"],"sourcesContent":["import type { Entity } from \"~/toolbox.js\";\n\n/**\n * The attributes defined by us or the dynamodb-toolbox library.\n * Add more attributes if necessary.\n */\nconst attributesToRemove = [\n \"PK\",\n \"SK\",\n \"created\",\n \"_ct\",\n \"modified\",\n \"_mt\",\n \"entity\",\n \"_et\",\n \"GSI1_PK\",\n \"GSI1_SK\",\n \"GSI2_PK\",\n \"GSI2_SK\",\n \"GSI3_PK\",\n \"GSI3_SK\",\n \"GSI4_PK\",\n \"GSI4_SK\",\n \"GSI5_PK\",\n \"GSI5_SK\",\n \"GSI_TENANT\",\n \"TYPE\"\n];\n\nexport function cleanupItem<T>(\n entity: Entity<any>,\n item?: T | null,\n removeAttributes: string[] = []\n): T | null {\n if (!item) {\n return null;\n }\n const newItem = {\n ...item\n };\n const targets = attributesToRemove.concat(removeAttributes);\n const attributes = entity.schema.attributes;\n for (const key in item) {\n if (item.hasOwnProperty(key) === false) {\n continue;\n }\n if (attributes[key] && targets.includes(key) === false) {\n continue;\n }\n delete newItem[key];\n }\n return newItem;\n}\n\nexport function cleanupItems<T>(\n entity: Entity<any>,\n items: T[],\n removeAttributes: string[] = []\n): T[] {\n return items.map(item => cleanupItem<T>(entity, item, removeAttributes) as T);\n}\n"],"names":["attributesToRemove","cleanupItem","entity","item","removeAttributes","newItem","targets","attributes","key","cleanupItems","items"],"mappings":"AAMA,MAAMA,qBAAqB;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,SAASC,YACZC,MAAmB,EACnBC,IAAe,EACfC,mBAA6B,EAAE;IAE/B,IAAI,CAACD,MACD,OAAO;IAEX,MAAME,UAAU;QACZ,GAAGF,IAAI;IACX;IACA,MAAMG,UAAUN,mBAAmB,MAAM,CAACI;IAC1C,MAAMG,aAAaL,OAAO,MAAM,CAAC,UAAU;IAC3C,IAAK,MAAMM,OAAOL,KACd,IAAIA,AAA6B,UAA7BA,KAAK,cAAc,CAACK,MAGxB;QAAA,IAAID,CAAAA,UAAU,CAACC,IAAI,IAAIF,AAA0B,UAA1BA,QAAQ,QAAQ,CAACE,MAGxC,OAAOH,OAAO,CAACG,IAAI;IADnB;IAGJ,OAAOH;AACX;AAEO,SAASI,aACZP,MAAmB,EACnBQ,KAAU,EACVN,mBAA6B,EAAE;IAE/B,OAAOM,MAAM,GAAG,CAACP,CAAAA,OAAQF,YAAeC,QAAQC,MAAMC;AAC1D"}
package/utils/count.js CHANGED
@@ -1,16 +1,11 @@
1
- export const count = async params => {
2
- const {
3
- entity,
4
- partitionKey,
5
- options = {}
6
- } = params;
7
- const {
8
- Count
9
- } = await entity.query(partitionKey, {
10
- ...options,
11
- select: "count"
12
- });
13
- return Count || 0;
1
+ const count = async (params)=>{
2
+ const { entity, partitionKey, options = {} } = params;
3
+ const { Count } = await entity.query(partitionKey, {
4
+ ...options,
5
+ select: "count"
6
+ });
7
+ return Count || 0;
14
8
  };
9
+ export { count };
15
10
 
16
11
  //# sourceMappingURL=count.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["count","params","entity","partitionKey","options","Count","query","select"],"sources":["count.ts"],"sourcesContent":["import type { QueryAllParams } from \"~/utils/query.js\";\n\nexport const count = async (params: QueryAllParams): Promise<number> => {\n const { entity, partitionKey, options = {} } = params;\n const { Count } = await entity.query(partitionKey, { ...options, select: \"count\" });\n return Count || 0;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,KAAK,GAAG,MAAOC,MAAsB,IAAsB;EACpE,MAAM;IAAEC,MAAM;IAAEC,YAAY;IAAEC,OAAO,GAAG,CAAC;EAAE,CAAC,GAAGH,MAAM;EACrD,MAAM;IAAEI;EAAM,CAAC,GAAG,MAAMH,MAAM,CAACI,KAAK,CAACH,YAAY,EAAE;IAAE,GAAGC,OAAO;IAAEG,MAAM,EAAE;EAAQ,CAAC,CAAC;EACnF,OAAOF,KAAK,IAAI,CAAC;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/count.js","sources":["../../src/utils/count.ts"],"sourcesContent":["import type { QueryAllParams } from \"~/utils/query.js\";\n\nexport const count = async (params: QueryAllParams): Promise<number> => {\n const { entity, partitionKey, options = {} } = params;\n // @ts-expect-error\n const { Count } = await entity.query(partitionKey, { ...options, select: \"count\" });\n return Count || 0;\n};\n"],"names":["count","params","entity","partitionKey","options","Count"],"mappings":"AAEO,MAAMA,QAAQ,OAAOC;IACxB,MAAM,EAAEC,MAAM,EAAEC,YAAY,EAAEC,UAAU,CAAC,CAAC,EAAE,GAAGH;IAE/C,MAAM,EAAEI,KAAK,EAAE,GAAG,MAAMH,OAAO,KAAK,CAACC,cAAc;QAAE,GAAGC,OAAO;QAAE,QAAQ;IAAQ;IACjF,OAAOC,SAAS;AACpB"}
@@ -9,7 +9,7 @@ export type IGlobalEntityAttributes<T = undefined> = {
9
9
  GSI1_SK?: string;
10
10
  GSI2_PK?: string;
11
11
  GSI2_SK?: string;
12
- expiresAt?: string | null;
12
+ expiresAt?: number | null;
13
13
  } & (T extends undefined ? {
14
14
  data?: undefined;
15
15
  } : {
@@ -1,85 +1,82 @@
1
1
  import { createEntity } from "./entity/index.js";
2
- export const globalEntityAttributes = {
3
- PK: {
4
- partitionKey: true
5
- },
6
- SK: {
7
- sortKey: true
8
- },
9
- GSI1_PK: {
10
- type: "string"
11
- },
12
- GSI1_SK: {
13
- type: "string"
14
- },
15
- GSI2_PK: {
16
- type: "string"
17
- },
18
- GSI2_SK: {
19
- type: "string"
20
- },
21
- TYPE: {
22
- type: "string",
23
- required: true
24
- },
25
- data: {
26
- type: "map"
27
- },
28
- expiresAt: {
29
- type: "number"
30
- }
31
- };
32
- export const createGlobalEntity = params => {
33
- return createEntity({
34
- ...params,
35
- attributes: {
36
- ...globalEntityAttributes,
37
- ...params.attributes
2
+ const globalEntityAttributes = {
3
+ PK: {
4
+ partitionKey: true
5
+ },
6
+ SK: {
7
+ sortKey: true
8
+ },
9
+ GSI1_PK: {
10
+ type: "string"
11
+ },
12
+ GSI1_SK: {
13
+ type: "string"
14
+ },
15
+ GSI2_PK: {
16
+ type: "string"
17
+ },
18
+ GSI2_SK: {
19
+ type: "string"
20
+ },
21
+ TYPE: {
22
+ type: "string",
23
+ required: true
24
+ },
25
+ data: {
26
+ type: "map"
27
+ },
28
+ expiresAt: {
29
+ type: "number"
38
30
  }
39
- });
40
- };
41
- export const standardEntityAttributes = {
42
- PK: {
43
- partitionKey: true
44
- },
45
- SK: {
46
- sortKey: true
47
- },
48
- GSI_TENANT: {
49
- type: "string",
50
- required: true
51
- },
52
- GSI1_PK: {
53
- type: "string"
54
- },
55
- GSI1_SK: {
56
- type: "string"
57
- },
58
- GSI2_PK: {
59
- type: "string"
60
- },
61
- GSI2_SK: {
62
- type: "string"
63
- },
64
- TYPE: {
65
- type: "string",
66
- required: true
67
- },
68
- data: {
69
- type: "map"
70
- },
71
- expiresAt: {
72
- type: "number"
73
- }
74
31
  };
75
- export const createStandardEntity = params => {
76
- return createEntity({
77
- ...params,
78
- attributes: {
79
- ...standardEntityAttributes,
80
- ...params.attributes
32
+ const createGlobalEntity = (params)=>createEntity({
33
+ ...params,
34
+ attributes: {
35
+ ...globalEntityAttributes,
36
+ ...params.attributes
37
+ }
38
+ });
39
+ const standardEntityAttributes = {
40
+ PK: {
41
+ partitionKey: true
42
+ },
43
+ SK: {
44
+ sortKey: true
45
+ },
46
+ GSI_TENANT: {
47
+ type: "string",
48
+ required: true
49
+ },
50
+ GSI1_PK: {
51
+ type: "string"
52
+ },
53
+ GSI1_SK: {
54
+ type: "string"
55
+ },
56
+ GSI2_PK: {
57
+ type: "string"
58
+ },
59
+ GSI2_SK: {
60
+ type: "string"
61
+ },
62
+ TYPE: {
63
+ type: "string",
64
+ required: true
65
+ },
66
+ data: {
67
+ type: "map"
68
+ },
69
+ expiresAt: {
70
+ type: "number"
81
71
  }
82
- });
83
72
  };
73
+ const createStandardEntity = (params)=>createEntity({
74
+ ...params,
75
+ attributes: {
76
+ ...standardEntityAttributes,
77
+ ...params.attributes
78
+ }
79
+ });
80
+ export { createGlobalEntity, createStandardEntity, globalEntityAttributes, standardEntityAttributes };
84
81
 
85
82
  //# sourceMappingURL=createEntity.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createEntity","globalEntityAttributes","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","GSI2_PK","GSI2_SK","TYPE","required","data","expiresAt","createGlobalEntity","params","attributes","standardEntityAttributes","GSI_TENANT","createStandardEntity"],"sources":["createEntity.ts"],"sourcesContent":["import type { AttributeDefinitions } from \"~/toolbox.js\";\nimport { createEntity, type EntityConstructor } from \"~/utils/entity/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport type IGlobalEntityAttributes<T = undefined> = {\n PK: string;\n SK: string;\n TYPE: string;\n GSI1_PK?: string;\n GSI1_SK?: string;\n GSI2_PK?: string;\n GSI2_SK?: string;\n expiresAt?: string | null;\n} & (T extends undefined ? { data?: undefined } : { data: T });\n\nexport const globalEntityAttributes: AttributeDefinitions = {\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 GSI2_PK: {\n type: \"string\"\n },\n GSI2_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\",\n required: true\n },\n data: {\n type: \"map\"\n },\n expiresAt: {\n type: \"number\"\n }\n};\n\nexport const createGlobalEntity = <T extends GenericRecord = GenericRecord>(\n params: Omit<EntityConstructor, \"attributes\"> & Partial<Pick<EntityConstructor, \"attributes\">>\n) => {\n return createEntity<IGlobalEntityAttributes<T>>({\n ...params,\n attributes: {\n ...globalEntityAttributes,\n ...params.attributes\n }\n });\n};\n\nexport type IStandardEntityAttributes<T = undefined> = {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n TYPE: string;\n GSI1_PK?: string;\n GSI1_SK?: string;\n GSI2_PK?: string;\n GSI2_SK?: string;\n expiresAt?: number | null;\n} & (T extends undefined ? { data?: undefined } : { data: T });\n\nexport const standardEntityAttributes: AttributeDefinitions = {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI_TENANT: {\n type: \"string\",\n required: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n GSI2_PK: {\n type: \"string\"\n },\n GSI2_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\",\n required: true\n },\n data: {\n type: \"map\"\n },\n expiresAt: {\n type: \"number\"\n }\n};\n\nexport const createStandardEntity = <T extends GenericRecord = GenericRecord>(\n params: Omit<EntityConstructor, \"attributes\"> & Partial<Pick<EntityConstructor, \"attributes\">>\n) => {\n return createEntity<IStandardEntityAttributes<T>>({\n ...params,\n attributes: {\n ...standardEntityAttributes,\n ...params.attributes\n }\n });\n};\n"],"mappings":"AACA,SAASA,YAAY;AAcrB,OAAO,MAAMC,sBAA4C,GAAG;EACxDC,EAAE,EAAE;IACAC,YAAY,EAAE;EAClB,CAAC;EACDC,EAAE,EAAE;IACAC,OAAO,EAAE;EACb,CAAC;EACDC,OAAO,EAAE;IACLC,IAAI,EAAE;EACV,CAAC;EACDC,OAAO,EAAE;IACLD,IAAI,EAAE;EACV,CAAC;EACDE,OAAO,EAAE;IACLF,IAAI,EAAE;EACV,CAAC;EACDG,OAAO,EAAE;IACLH,IAAI,EAAE;EACV,CAAC;EACDI,IAAI,EAAE;IACFJ,IAAI,EAAE,QAAQ;IACdK,QAAQ,EAAE;EACd,CAAC;EACDC,IAAI,EAAE;IACFN,IAAI,EAAE;EACV,CAAC;EACDO,SAAS,EAAE;IACPP,IAAI,EAAE;EACV;AACJ,CAAC;AAED,OAAO,MAAMQ,kBAAkB,GAC3BC,MAA8F,IAC7F;EACD,OAAOhB,YAAY,CAA6B;IAC5C,GAAGgB,MAAM;IACTC,UAAU,EAAE;MACR,GAAGhB,sBAAsB;MACzB,GAAGe,MAAM,CAACC;IACd;EACJ,CAAC,CAAC;AACN,CAAC;AAcD,OAAO,MAAMC,wBAA8C,GAAG;EAC1DhB,EAAE,EAAE;IACAC,YAAY,EAAE;EAClB,CAAC;EACDC,EAAE,EAAE;IACAC,OAAO,EAAE;EACb,CAAC;EACDc,UAAU,EAAE;IACRZ,IAAI,EAAE,QAAQ;IACdK,QAAQ,EAAE;EACd,CAAC;EACDN,OAAO,EAAE;IACLC,IAAI,EAAE;EACV,CAAC;EACDC,OAAO,EAAE;IACLD,IAAI,EAAE;EACV,CAAC;EACDE,OAAO,EAAE;IACLF,IAAI,EAAE;EACV,CAAC;EACDG,OAAO,EAAE;IACLH,IAAI,EAAE;EACV,CAAC;EACDI,IAAI,EAAE;IACFJ,IAAI,EAAE,QAAQ;IACdK,QAAQ,EAAE;EACd,CAAC;EACDC,IAAI,EAAE;IACFN,IAAI,EAAE;EACV,CAAC;EACDO,SAAS,EAAE;IACPP,IAAI,EAAE;EACV;AACJ,CAAC;AAED,OAAO,MAAMa,oBAAoB,GAC7BJ,MAA8F,IAC7F;EACD,OAAOhB,YAAY,CAA+B;IAC9C,GAAGgB,MAAM;IACTC,UAAU,EAAE;MACR,GAAGC,wBAAwB;MAC3B,GAAGF,MAAM,CAACC;IACd;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/createEntity.js","sources":["../../src/utils/createEntity.ts"],"sourcesContent":["import type { AttributeDefinitions } from \"~/toolbox.js\";\nimport { createEntity, type EntityConstructor } from \"~/utils/entity/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport type IGlobalEntityAttributes<T = undefined> = {\n PK: string;\n SK: string;\n TYPE: string;\n GSI1_PK?: string;\n GSI1_SK?: string;\n GSI2_PK?: string;\n GSI2_SK?: string;\n expiresAt?: number | null;\n} & (T extends undefined ? { data?: undefined } : { data: T });\n\nexport const globalEntityAttributes: AttributeDefinitions = {\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 GSI2_PK: {\n type: \"string\"\n },\n GSI2_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\",\n required: true\n },\n data: {\n type: \"map\"\n },\n expiresAt: {\n type: \"number\"\n }\n};\n\nexport const createGlobalEntity = <T extends GenericRecord = GenericRecord>(\n params: Omit<EntityConstructor, \"attributes\"> & Partial<Pick<EntityConstructor, \"attributes\">>\n) => {\n return createEntity<IGlobalEntityAttributes<T>>({\n ...params,\n attributes: {\n ...globalEntityAttributes,\n ...params.attributes\n }\n });\n};\n\nexport type IStandardEntityAttributes<T = undefined> = {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n TYPE: string;\n GSI1_PK?: string;\n GSI1_SK?: string;\n GSI2_PK?: string;\n GSI2_SK?: string;\n expiresAt?: number | null;\n} & (T extends undefined ? { data?: undefined } : { data: T });\n\nexport const standardEntityAttributes: AttributeDefinitions = {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI_TENANT: {\n type: \"string\",\n required: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n GSI2_PK: {\n type: \"string\"\n },\n GSI2_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\",\n required: true\n },\n data: {\n type: \"map\"\n },\n expiresAt: {\n type: \"number\"\n }\n};\n\nexport const createStandardEntity = <T extends GenericRecord = GenericRecord>(\n params: Omit<EntityConstructor, \"attributes\"> & Partial<Pick<EntityConstructor, \"attributes\">>\n) => {\n return createEntity<IStandardEntityAttributes<T>>({\n ...params,\n attributes: {\n ...standardEntityAttributes,\n ...params.attributes\n }\n });\n};\n"],"names":["globalEntityAttributes","createGlobalEntity","params","createEntity","standardEntityAttributes","createStandardEntity"],"mappings":";AAeO,MAAMA,yBAA+C;IACxD,IAAI;QACA,cAAc;IAClB;IACA,IAAI;QACA,SAAS;IACb;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,MAAM;QACF,MAAM;QACN,UAAU;IACd;IACA,MAAM;QACF,MAAM;IACV;IACA,WAAW;QACP,MAAM;IACV;AACJ;AAEO,MAAMC,qBAAqB,CAC9BC,SAEOC,aAAyC;QAC5C,GAAGD,MAAM;QACT,YAAY;YACR,GAAGF,sBAAsB;YACzB,GAAGE,OAAO,UAAU;QACxB;IACJ;AAeG,MAAME,2BAAiD;IAC1D,IAAI;QACA,cAAc;IAClB;IACA,IAAI;QACA,SAAS;IACb;IACA,YAAY;QACR,MAAM;QACN,UAAU;IACd;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,SAAS;QACL,MAAM;IACV;IACA,MAAM;QACF,MAAM;QACN,UAAU;IACd;IACA,MAAM;QACF,MAAM;IACV;IACA,WAAW;QACP,MAAM;IACV;AACJ;AAEO,MAAMC,uBAAuB,CAChCH,SAEOC,aAA2C;QAC9C,GAAGD,MAAM;QACT,YAAY;YACR,GAAGE,wBAAwB;YAC3B,GAAGF,OAAO,UAAU;QACxB;IACJ"}
@@ -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"}
@@ -6,7 +6,7 @@ import type { IPutParamsItem } from "../put.js";
6
6
  import type { GetRecordParamsKeys } from "../get.js";
7
7
  import type { IDeleteItemKeys } from "../delete.js";
8
8
  import type { GenericRecord } from "@webiny/api/types.js";
9
- export type EntityConstructor<T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>> = BaseEntityConstructor<TableDef, string, true, true, true, "created", "modified", "entity", false, T>;
9
+ export type EntityConstructor<T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>> = BaseEntityConstructor<T>;
10
10
  export declare class Entity<T extends GenericRecord = GenericRecord> implements IEntity<T> {
11
11
  readonly entity: BaseEntity;
12
12
  get name(): string;