@webiny/api-prerendering-service-so-ddb 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d

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 (43) hide show
  1. package/definitions/queueJob.d.ts +4 -3
  2. package/definitions/queueJob.js +8 -12
  3. package/definitions/queueJob.js.map +1 -1
  4. package/definitions/render.d.ts +4 -3
  5. package/definitions/render.js +8 -12
  6. package/definitions/render.js.map +1 -1
  7. package/definitions/renderLegacy.d.ts +4 -3
  8. package/definitions/renderLegacy.js +8 -12
  9. package/definitions/renderLegacy.js.map +1 -1
  10. package/definitions/settings.d.ts +4 -3
  11. package/definitions/settings.js +8 -12
  12. package/definitions/settings.js.map +1 -1
  13. package/definitions/table.d.ts +5 -5
  14. package/definitions/table.js +7 -6
  15. package/definitions/table.js.map +1 -1
  16. package/definitions/tagPathLink.d.ts +51 -4
  17. package/definitions/tagPathLink.js +8 -12
  18. package/definitions/tagPathLink.js.map +1 -1
  19. package/definitions/tagPathLinkLegacy.d.ts +57 -4
  20. package/definitions/tagPathLinkLegacy.js +8 -12
  21. package/definitions/tagPathLinkLegacy.js.map +1 -1
  22. package/definitions/tenantEntity.d.ts +8 -0
  23. package/definitions/tenantEntity.js +39 -0
  24. package/definitions/tenantEntity.js.map +1 -0
  25. package/index.d.ts +1 -1
  26. package/index.js +24 -30
  27. package/index.js.map +1 -1
  28. package/operations/queueJob.d.ts +2 -2
  29. package/operations/queueJob.js +21 -35
  30. package/operations/queueJob.js.map +1 -1
  31. package/operations/render.d.ts +4 -5
  32. package/operations/render.js +67 -112
  33. package/operations/render.js.map +1 -1
  34. package/operations/settings.d.ts +2 -2
  35. package/operations/settings.js +12 -19
  36. package/operations/settings.js.map +1 -1
  37. package/operations/tenant.d.ts +6 -0
  38. package/operations/tenant.js +29 -0
  39. package/operations/tenant.js.map +1 -0
  40. package/package.json +16 -31
  41. package/types.d.ts +12 -12
  42. package/types.js +6 -5
  43. package/types.js.map +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_toolbox","require","createTenantEntity","entityName","table","Entity","name","attributes","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","id","exports"],"sources":["tenantEntity.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n}\n\nexport const createTenantEntity = ({ entityName, table }: Params): Entity<any> => {\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n }\n }\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,UAAU;EAAEC;AAAc,CAAC,KAAkB;EAC9E,OAAO,IAAIC,eAAM,CAAC;IACdD,KAAK;IACLE,IAAI,EAAEH,UAAU;IAChBI,UAAU,EAAE;MACRC,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDG,EAAE,EAAE;QACAH,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACI,OAAA,CAAAf,kBAAA,GAAAA,kBAAA","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { PrerenderingServiceFactory } from "./types";
1
+ import type { PrerenderingServiceFactory } from "./types";
2
2
  export declare const createPrerenderingServiceStorageOperations: PrerenderingServiceFactory;
package/index.js CHANGED
@@ -1,59 +1,42 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createPrerenderingServiceStorageOperations = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
8
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
9
  var _types = require("./types");
15
-
16
10
  var _table = require("./definitions/table");
17
-
18
11
  var _render = require("./definitions/render");
19
-
20
12
  var _settings = require("./definitions/settings");
21
-
22
13
  var _queueJob = require("./definitions/queueJob");
23
-
24
14
  var _render2 = require("./operations/render");
25
-
15
+ var _tenant = require("./operations/tenant");
26
16
  var _settings2 = require("./operations/settings");
27
-
28
17
  var _queueJob2 = require("./operations/queueJob");
29
-
30
18
  var _tagPathLink = require("./definitions/tagPathLink");
31
-
19
+ var _tenantEntity = require("./definitions/tenantEntity");
32
20
  const reservedFields = ["PK", "SK", "index", "data", "TYPE", "__type", "GSI1_PK", "GSI1_SK"];
33
-
34
21
  const isReserved = name => {
35
22
  if (reservedFields.includes(name) === false) {
36
23
  return;
37
24
  }
38
-
39
25
  throw new _error.default(`Attribute name "${name}" is not allowed.`, "ATTRIBUTE_NOT_ALLOWED", {
40
26
  name
41
27
  });
42
28
  };
43
-
44
29
  const createPrerenderingServiceStorageOperations = params => {
45
30
  const {
46
31
  attributes,
47
32
  table,
48
33
  documentClient
49
34
  } = params;
50
-
51
35
  if (attributes) {
52
36
  Object.values(attributes).forEach(attrs => {
53
37
  Object.keys(attrs).forEach(isReserved);
54
38
  });
55
39
  }
56
-
57
40
  const tableInstance = (0, _table.createTable)({
58
41
  table,
59
42
  documentClient
@@ -78,19 +61,30 @@ const createPrerenderingServiceStorageOperations = params => {
78
61
  entityName: _types.ENTITIES.TAG_PATH_LINK,
79
62
  table: tableInstance,
80
63
  attributes: attributes ? attributes[_types.ENTITIES.TAG_PATH_LINK] : {}
64
+ }),
65
+ tenant: (0, _tenantEntity.createTenantEntity)({
66
+ entityName: _types.ENTITIES.TENANT,
67
+ table: tableInstance
81
68
  })
82
69
  };
83
- return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
70
+ return {
84
71
  getTable: () => tableInstance,
85
- getEntities: () => entities
86
- }, (0, _render2.createRenderStorageOperations)({
87
- entity: entities.render,
88
- tagPathLinkEntity: entities.tagPathLink
89
- })), (0, _queueJob2.createQueueJobStorageOperations)({
90
- entity: entities.queueJob
91
- })), (0, _settings2.createSettingsStorageOperations)({
92
- entity: entities.settings
93
- }));
72
+ getEntities: () => entities,
73
+ ...(0, _render2.createRenderStorageOperations)({
74
+ entity: entities.render,
75
+ tagPathLinkEntity: entities.tagPathLink
76
+ }),
77
+ ...(0, _queueJob2.createQueueJobStorageOperations)({
78
+ entity: entities.queueJob
79
+ }),
80
+ ...(0, _settings2.createSettingsStorageOperations)({
81
+ entity: entities.settings
82
+ }),
83
+ ...(0, _tenant.createTenantStorageOperations)({
84
+ entity: entities.tenant
85
+ })
86
+ };
94
87
  };
88
+ exports.createPrerenderingServiceStorageOperations = createPrerenderingServiceStorageOperations;
95
89
 
96
- exports.createPrerenderingServiceStorageOperations = createPrerenderingServiceStorageOperations;
90
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["reservedFields","isReserved","name","includes","WebinyError","createPrerenderingServiceStorageOperations","params","attributes","table","documentClient","Object","values","forEach","attrs","keys","tableInstance","createTable","entities","render","createRenderEntity","entityName","ENTITIES","RENDER","settings","createSettingsEntity","SETTINGS","queueJob","createQueueJobEntity","QUEUE_JOB","tagPathLink","createTagPathLinkEntity","TAG_PATH_LINK","getTable","getEntities","createRenderStorageOperations","entity","tagPathLinkEntity","createQueueJobStorageOperations","createSettingsStorageOperations"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ENTITIES, PrerenderingServiceFactory, PrerenderingServiceFactoryParams } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createRenderEntity } from \"~/definitions/render\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createQueueJobEntity } from \"~/definitions/queueJob\";\nimport { createRenderStorageOperations } from \"~/operations/render\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createQueueJobStorageOperations } from \"~/operations/queueJob\";\nimport { createTagPathLinkEntity } from \"~/definitions/tagPathLink\";\n\nconst reservedFields = [\"PK\", \"SK\", \"index\", \"data\", \"TYPE\", \"__type\", \"GSI1_PK\", \"GSI1_SK\"];\n\nconst isReserved = (name: string): void => {\n if (reservedFields.includes(name) === false) {\n return;\n }\n throw new WebinyError(`Attribute name \"${name}\" is not allowed.`, \"ATTRIBUTE_NOT_ALLOWED\", {\n name\n });\n};\n\nexport const createPrerenderingServiceStorageOperations: PrerenderingServiceFactory = (\n params: PrerenderingServiceFactoryParams\n) => {\n const { attributes, table, documentClient } = params;\n\n if (attributes) {\n Object.values(attributes).forEach(attrs => {\n Object.keys(attrs).forEach(isReserved);\n });\n }\n\n const tableInstance = createTable({ table, documentClient });\n\n const entities = {\n render: createRenderEntity({\n entityName: ENTITIES.RENDER,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.RENDER] : {}\n }),\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n queueJob: createQueueJobEntity({\n entityName: ENTITIES.QUEUE_JOB,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.QUEUE_JOB] : {}\n }),\n tagPathLink: createTagPathLinkEntity({\n entityName: ENTITIES.TAG_PATH_LINK,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.TAG_PATH_LINK] : {}\n })\n };\n\n return {\n getTable: () => tableInstance,\n getEntities: () => entities,\n ...createRenderStorageOperations({\n entity: entities.render,\n tagPathLinkEntity: entities.tagPathLink\n }),\n ...createQueueJobStorageOperations({\n entity: entities.queueJob\n }),\n ...createSettingsStorageOperations({\n entity: entities.settings\n })\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,cAAc,GAAG,CAAC,IAAD,EAAO,IAAP,EAAa,OAAb,EAAsB,MAAtB,EAA8B,MAA9B,EAAsC,QAAtC,EAAgD,SAAhD,EAA2D,SAA3D,CAAvB;;AAEA,MAAMC,UAAU,GAAIC,IAAD,IAAwB;EACvC,IAAIF,cAAc,CAACG,QAAf,CAAwBD,IAAxB,MAAkC,KAAtC,EAA6C;IACzC;EACH;;EACD,MAAM,IAAIE,cAAJ,CAAiB,mBAAkBF,IAAK,mBAAxC,EAA4D,uBAA5D,EAAqF;IACvFA;EADuF,CAArF,CAAN;AAGH,CAPD;;AASO,MAAMG,0CAAsE,GAC/EC,MADkF,IAEjF;EACD,MAAM;IAAEC,UAAF;IAAcC,KAAd;IAAqBC;EAArB,IAAwCH,MAA9C;;EAEA,IAAIC,UAAJ,EAAgB;IACZG,MAAM,CAACC,MAAP,CAAcJ,UAAd,EAA0BK,OAA1B,CAAkCC,KAAK,IAAI;MACvCH,MAAM,CAACI,IAAP,CAAYD,KAAZ,EAAmBD,OAAnB,CAA2BX,UAA3B;IACH,CAFD;EAGH;;EAED,MAAMc,aAAa,GAAG,IAAAC,kBAAA,EAAY;IAAER,KAAF;IAASC;EAAT,CAAZ,CAAtB;EAEA,MAAMQ,QAAQ,GAAG;IACbC,MAAM,EAAE,IAAAC,0BAAA,EAAmB;MACvBC,UAAU,EAAEC,eAAA,CAASC,MADE;MAEvBd,KAAK,EAAEO,aAFgB;MAGvBR,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACc,eAAA,CAASC,MAAV,CAAb,GAAiC;IAHhC,CAAnB,CADK;IAMbC,QAAQ,EAAE,IAAAC,8BAAA,EAAqB;MAC3BJ,UAAU,EAAEC,eAAA,CAASI,QADM;MAE3BjB,KAAK,EAAEO,aAFoB;MAG3BR,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACc,eAAA,CAASI,QAAV,CAAb,GAAmC;IAH9B,CAArB,CANG;IAWbC,QAAQ,EAAE,IAAAC,8BAAA,EAAqB;MAC3BP,UAAU,EAAEC,eAAA,CAASO,SADM;MAE3BpB,KAAK,EAAEO,aAFoB;MAG3BR,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACc,eAAA,CAASO,SAAV,CAAb,GAAoC;IAH/B,CAArB,CAXG;IAgBbC,WAAW,EAAE,IAAAC,oCAAA,EAAwB;MACjCV,UAAU,EAAEC,eAAA,CAASU,aADY;MAEjCvB,KAAK,EAAEO,aAF0B;MAGjCR,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACc,eAAA,CAASU,aAAV,CAAb,GAAwC;IAH7B,CAAxB;EAhBA,CAAjB;EAuBA;IACIC,QAAQ,EAAE,MAAMjB,aADpB;IAEIkB,WAAW,EAAE,MAAMhB;EAFvB,GAGO,IAAAiB,sCAAA,EAA8B;IAC7BC,MAAM,EAAElB,QAAQ,CAACC,MADY;IAE7BkB,iBAAiB,EAAEnB,QAAQ,CAACY;EAFC,CAA9B,CAHP,GAOO,IAAAQ,0CAAA,EAAgC;IAC/BF,MAAM,EAAElB,QAAQ,CAACS;EADc,CAAhC,CAPP,GAUO,IAAAY,0CAAA,EAAgC;IAC/BH,MAAM,EAAElB,QAAQ,CAACM;EADc,CAAhC,CAVP;AAcH,CAlDM"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_types","_table","_render","_settings","_queueJob","_render2","_tenant","_settings2","_queueJob2","_tagPathLink","_tenantEntity","reservedFields","isReserved","name","includes","WebinyError","createPrerenderingServiceStorageOperations","params","attributes","table","documentClient","Object","values","forEach","attrs","keys","tableInstance","createTable","entities","render","createRenderEntity","entityName","ENTITIES","RENDER","settings","createSettingsEntity","SETTINGS","queueJob","createQueueJobEntity","QUEUE_JOB","tagPathLink","createTagPathLinkEntity","TAG_PATH_LINK","tenant","createTenantEntity","TENANT","getTable","getEntities","createRenderStorageOperations","entity","tagPathLinkEntity","createQueueJobStorageOperations","createSettingsStorageOperations","createTenantStorageOperations","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { PrerenderingServiceFactory, PrerenderingServiceFactoryParams } from \"~/types\";\nimport { ENTITIES } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createRenderEntity } from \"~/definitions/render\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createQueueJobEntity } from \"~/definitions/queueJob\";\nimport { createRenderStorageOperations } from \"~/operations/render\";\nimport { createTenantStorageOperations } from \"~/operations/tenant\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createQueueJobStorageOperations } from \"~/operations/queueJob\";\nimport { createTagPathLinkEntity } from \"~/definitions/tagPathLink\";\nimport { createTenantEntity } from \"~/definitions/tenantEntity\";\n\nconst reservedFields = [\"PK\", \"SK\", \"index\", \"data\", \"TYPE\", \"__type\", \"GSI1_PK\", \"GSI1_SK\"];\n\nconst isReserved = (name: string): void => {\n if (reservedFields.includes(name) === false) {\n return;\n }\n throw new WebinyError(`Attribute name \"${name}\" is not allowed.`, \"ATTRIBUTE_NOT_ALLOWED\", {\n name\n });\n};\n\nexport const createPrerenderingServiceStorageOperations: PrerenderingServiceFactory = (\n params: PrerenderingServiceFactoryParams\n) => {\n const { attributes, table, documentClient } = params;\n\n if (attributes) {\n Object.values(attributes).forEach(attrs => {\n Object.keys(attrs).forEach(isReserved);\n });\n }\n\n const tableInstance = createTable({ table, documentClient });\n\n const entities = {\n render: createRenderEntity({\n entityName: ENTITIES.RENDER,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.RENDER] : {}\n }),\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n queueJob: createQueueJobEntity({\n entityName: ENTITIES.QUEUE_JOB,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.QUEUE_JOB] : {}\n }),\n tagPathLink: createTagPathLinkEntity({\n entityName: ENTITIES.TAG_PATH_LINK,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.TAG_PATH_LINK] : {}\n }),\n tenant: createTenantEntity({\n entityName: ENTITIES.TENANT,\n table: tableInstance\n })\n };\n\n return {\n getTable: () => tableInstance,\n getEntities: () => entities,\n ...createRenderStorageOperations({\n entity: entities.render,\n tagPathLinkEntity: entities.tagPathLink\n }),\n ...createQueueJobStorageOperations({\n entity: entities.queueJob\n }),\n ...createSettingsStorageOperations({\n entity: entities.settings\n }),\n ...createTenantStorageOperations({\n entity: entities.tenant\n })\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AAEA,MAAMY,cAAc,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;AAE5F,MAAMC,UAAU,GAAIC,IAAY,IAAW;EACvC,IAAIF,cAAc,CAACG,QAAQ,CAACD,IAAI,CAAC,KAAK,KAAK,EAAE;IACzC;EACJ;EACA,MAAM,IAAIE,cAAW,CAAC,m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AK,EAAEO,aAAa;MACpBR,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACc,eAAQ,CAACU,aAAa,CAAC,GAAG,CAAC;IACnE,CAAC,CAAC;IACFC,MAAM,EAAE,IAAAC,gCAAkB,EAAC;MACvBb,UAAU,EAAEC,eAAQ,CAACa,MAAM;MAC3B1B,KAAK,EAAEO;IACX,CAAC;EACL,CAAC;EAED,OAAO;IACHoB,QAAQ,EAAEA,CAAA,KAAMpB,aAAa;IAC7BqB,WAAW,EAAEA,CAAA,KAAMnB,QAAQ;IAC3B,GAAG,IAAAoB,sCAA6B,EAAC;MAC7BC,MAAM,EAAErB,QAAQ,CAACC,MAAM;MACvBqB,iBAAiB,EAAEtB,QAAQ,CAACY;IAChC,CAAC,CAAC;IACF,GAAG,IAAAW,0CAA+B,EAAC;MAC/BF,MAAM,EAAErB,QAAQ,CAACS;IACrB,CAAC,CAAC;IACF,GAAG,IAAAe,0CAA+B,EAAC;MAC/BH,MAAM,EAAErB,QAAQ,CAACM;IACrB,CAAC,CAAC;IACF,GAAG,IAAAmB,qCAA6B,EAAC;MAC7BJ,MAAM,EAAErB,QAAQ,CAACe;IACrB,CAAC;EACL,CAAC;AACL,CAAC;AAACW,OAAA,CAAAtC,0CAAA,GAAAA,0CAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { PrerenderingServiceQueueJobStorageOperations } from "@webiny/api-prerendering-service/types";
2
- import { Entity } from "dynamodb-toolbox";
1
+ import type { PrerenderingServiceQueueJobStorageOperations } from "@webiny/api-prerendering-service/types";
2
+ import type { Entity } from "@webiny/db-dynamodb/toolbox";
3
3
  export interface CreateQueueJobStorageOperationsParams {
4
4
  entity: Entity<any>;
5
5
  }
@@ -1,39 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createQueueJobStorageOperations = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
8
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
- var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
15
-
9
+ var _dbDynamodb = require("@webiny/db-dynamodb");
16
10
  var _query = require("@webiny/db-dynamodb/utils/query");
17
-
18
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
19
-
20
11
  const createQueueJobStorageOperations = params => {
21
12
  const {
22
13
  entity
23
14
  } = params;
24
-
25
15
  const createQueueJobPartitionKey = () => {
26
16
  return "PS#Q#JOB";
27
17
  };
28
-
29
18
  const createQueueJobSortKey = id => {
30
19
  return id;
31
20
  };
32
-
33
21
  const createQueueJobType = () => {
34
22
  return "ps.queue.job";
35
23
  };
36
-
37
24
  const createQueueJob = async params => {
38
25
  const {
39
26
  queueJob
@@ -42,11 +29,15 @@ const createQueueJobStorageOperations = params => {
42
29
  PK: createQueueJobPartitionKey(),
43
30
  SK: createQueueJobSortKey(queueJob.id)
44
31
  };
45
-
46
32
  try {
47
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, queueJob), keys), {}, {
48
- TYPE: createQueueJobType()
49
- }));
33
+ await (0, _dbDynamodb.put)({
34
+ entity,
35
+ item: {
36
+ ...queueJob,
37
+ ...keys,
38
+ TYPE: createQueueJobType()
39
+ }
40
+ });
50
41
  return queueJob;
51
42
  } catch (ex) {
52
43
  throw new _error.default(ex.message || "Could not create render record.", ex.code || "CREATE_RENDER_ERROR", {
@@ -55,7 +46,6 @@ const createQueueJobStorageOperations = params => {
55
46
  });
56
47
  }
57
48
  };
58
-
59
49
  const listQueueJobs = async () => {
60
50
  const queryAllParams = {
61
51
  entity,
@@ -64,10 +54,8 @@ const createQueueJobStorageOperations = params => {
64
54
  gte: " "
65
55
  }
66
56
  };
67
-
68
57
  try {
69
- const results = await (0, _query.queryAll)(queryAllParams);
70
- return (0, _cleanup.cleanupItems)(entity, results);
58
+ return await (0, _query.queryAllClean)(queryAllParams);
71
59
  } catch (ex) {
72
60
  throw new _error.default(ex.message || "Could not list queue jobs records.", ex.code || "LIST_QUEUE_JOBS_ERROR", {
73
61
  partitionKey: queryAllParams.partitionKey,
@@ -75,23 +63,21 @@ const createQueueJobStorageOperations = params => {
75
63
  });
76
64
  }
77
65
  };
78
-
79
66
  const deleteQueueJobs = async params => {
80
67
  const {
81
68
  queueJobs
82
69
  } = params;
83
- const items = queueJobs.map(job => {
84
- return entity.deleteBatch({
85
- PK: createQueueJobPartitionKey(),
86
- SK: createQueueJobSortKey(job.id)
87
- });
70
+ const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
71
+ entity,
72
+ delete: queueJobs.map(job => {
73
+ return {
74
+ PK: createQueueJobPartitionKey(),
75
+ SK: createQueueJobSortKey(job.id)
76
+ };
77
+ })
88
78
  });
89
-
90
79
  try {
91
- await (0, _batchWrite.batchWriteAll)({
92
- table: entity.table,
93
- items
94
- });
80
+ await entityBatch.execute();
95
81
  return queueJobs;
96
82
  } catch (ex) {
97
83
  throw new _error.default(ex.message || "Could not delete queue jobs records.", ex.code || "DELETE_QUEUE_JOBS_ERROR", {
@@ -99,12 +85,12 @@ const createQueueJobStorageOperations = params => {
99
85
  });
100
86
  }
101
87
  };
102
-
103
88
  return {
104
89
  createQueueJob,
105
90
  deleteQueueJobs,
106
91
  listQueueJobs
107
92
  };
108
93
  };
94
+ exports.createQueueJobStorageOperations = createQueueJobStorageOperations;
109
95
 
110
- exports.createQueueJobStorageOperations = createQueueJobStorageOperations;
96
+ //# sourceMappingURL=queueJob.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createQueueJobStorageOperations","params","entity","createQueueJobPartitionKey","createQueueJobSortKey","id","createQueueJobType","createQueueJob","queueJob","keys","PK","SK","put","TYPE","ex","WebinyError","message","code","listQueueJobs","queryAllParams","partitionKey","options","gte","results","queryAll","cleanupItems","deleteQueueJobs","queueJobs","items","map","job","deleteBatch","batchWriteAll","table"],"sources":["queueJob.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n PrerenderingServiceQueueJobStorageOperations,\n PrerenderingServiceStorageOperationsCreateQueueJobParams,\n PrerenderingServiceStorageOperationsDeleteQueueJobsParams,\n QueueJob\n} from \"@webiny/api-prerendering-service/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\n\nexport interface CreateQueueJobStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createQueueJobStorageOperations = (\n params: CreateQueueJobStorageOperationsParams\n): PrerenderingServiceQueueJobStorageOperations => {\n const { entity } = params;\n\n const createQueueJobPartitionKey = (): string => {\n return \"PS#Q#JOB\";\n };\n const createQueueJobSortKey = (id: string): string => {\n return id;\n };\n\n const createQueueJobType = () => {\n return \"ps.queue.job\";\n };\n\n const createQueueJob = async (\n params: PrerenderingServiceStorageOperationsCreateQueueJobParams\n ): Promise<QueueJob> => {\n const { queueJob } = params;\n const keys = {\n PK: createQueueJobPartitionKey(),\n SK: createQueueJobSortKey(queueJob.id)\n };\n\n try {\n await entity.put({\n ...queueJob,\n ...keys,\n TYPE: createQueueJobType()\n });\n return queueJob;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create render record.\",\n ex.code || \"CREATE_RENDER_ERROR\",\n {\n keys,\n queueJob\n }\n );\n }\n };\n\n const listQueueJobs = async () => {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createQueueJobPartitionKey(),\n options: {\n gte: \" \"\n }\n };\n\n try {\n const results = await queryAll<QueueJob>(queryAllParams);\n\n return cleanupItems(entity, results);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list queue jobs records.\",\n ex.code || \"LIST_QUEUE_JOBS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n };\n\n const deleteQueueJobs = async (\n params: PrerenderingServiceStorageOperationsDeleteQueueJobsParams\n ) => {\n const { queueJobs } = params;\n\n const items = queueJobs.map(job => {\n return entity.deleteBatch({\n PK: createQueueJobPartitionKey(),\n SK: createQueueJobSortKey(job.id)\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n return queueJobs;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete queue jobs records.\",\n ex.code || \"DELETE_QUEUE_JOBS_ERROR\",\n {\n queueJobs\n }\n );\n }\n };\n\n return {\n createQueueJob,\n deleteQueueJobs,\n listQueueJobs\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AAMO,MAAMA,+BAA+B,GACxCC,MAD2C,IAEI;EAC/C,MAAM;IAAEC;EAAF,IAAaD,MAAnB;;EAEA,MAAME,0BAA0B,GAAG,MAAc;IAC7C,OAAO,UAAP;EACH,CAFD;;EAGA,MAAMC,qBAAqB,GAAIC,EAAD,IAAwB;IAClD,OAAOA,EAAP;EACH,CAFD;;EAIA,MAAMC,kBAAkB,GAAG,MAAM;IAC7B,OAAO,cAAP;EACH,CAFD;;EAIA,MAAMC,cAAc,GAAG,MACnBN,MADmB,IAEC;IACpB,MAAM;MAAEO;IAAF,IAAeP,MAArB;IACA,MAAMQ,IAAI,GAAG;MACTC,EAAE,EAAEP,0BAA0B,EADrB;MAETQ,EAAE,EAAEP,qBAAqB,CAACI,QAAQ,CAACH,EAAV;IAFhB,CAAb;;IAKA,IAAI;MACA,MAAMH,MAAM,CAACU,GAAP,yFACCJ,QADD,GAECC,IAFD;QAGFI,IAAI,EAAEP,kBAAkB;MAHtB,GAAN;MAKA,OAAOE,QAAP;IACH,CAPD,CAOE,OAAOM,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,iCADZ,EAEFF,EAAE,CAACG,IA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W,yBAFT,EAGF;QACIU;MADJ,CAHE,CAAN;IAOH;EACJ,CA3BD;;EA6BA,OAAO;IACHpB,cADG;IAEHmB,eAFG;IAGHR;EAHG,CAAP;AAKH,CAvGM"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_dbDynamodb","_query","createQueueJobStorageOperations","params","entity","createQueueJobPartitionKey","createQueueJobSortKey","id","createQueueJobType","createQueueJob","queueJob","keys","PK","SK","put","item","TYPE","ex","WebinyError","message","code","listQueueJobs","queryAllParams","partitionKey","options","gte","queryAllClean","deleteQueueJobs","queueJobs","entityBatch","createEntityWriteBatch","delete","map","job","execute","exports"],"sources":["queueJob.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n PrerenderingServiceQueueJobStorageOperations,\n PrerenderingServiceStorageOperationsCreateQueueJobParams,\n PrerenderingServiceStorageOperationsDeleteQueueJobsParams,\n QueueJob\n} from \"@webiny/api-prerendering-service/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { createEntityWriteBatch, put } from \"@webiny/db-dynamodb\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAllClean } from \"@webiny/db-dynamodb/utils/query\";\n\nexport interface CreateQueueJobStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createQueueJobStorageOperations = (\n params: CreateQueueJobStorageOperationsParams\n): PrerenderingServiceQueueJobStorageOperations => {\n const { entity } = params;\n\n const createQueueJobPartitionKey = (): string => {\n return \"PS#Q#JOB\";\n };\n const createQueueJobSortKey = (id: string): string => {\n return id;\n };\n\n const createQueueJobType = () => {\n return \"ps.queue.job\";\n };\n\n const createQueueJob = async (\n params: PrerenderingServiceStorageOperationsCreateQueueJobParams\n ): Promise<QueueJob> => {\n const { queueJob } = params;\n const keys = {\n PK: createQueueJobPartitionKey(),\n SK: createQueueJobSortKey(queueJob.id)\n };\n\n try {\n await put({\n entity,\n item: {\n ...queueJob,\n ...keys,\n TYPE: createQueueJobType()\n }\n });\n return queueJob;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create render record.\",\n ex.code || \"CREATE_RENDER_ERROR\",\n {\n keys,\n queueJob\n }\n );\n }\n };\n\n const listQueueJobs = async () => {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createQueueJobPartitionKey(),\n options: {\n gte: \" \"\n }\n };\n\n try {\n return await queryAllClean<QueueJob>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list queue jobs records.\",\n ex.code || \"LIST_QUEUE_JOBS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n };\n\n const deleteQueueJobs = async (\n params: PrerenderingServiceStorageOperationsDeleteQueueJobsParams\n ) => {\n const { queueJobs } = params;\n\n const entityBatch = createEntityWriteBatch({\n entity,\n delete: queueJobs.map(job => {\n return {\n PK: createQueueJobPartitionKey(),\n SK: createQueueJobSortKey(job.id)\n };\n })\n });\n\n try {\n await entityBatch.execute();\n return queueJobs;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete queue jobs records.\",\n ex.code || \"DELETE_QUEUE_JOBS_ERROR\",\n {\n queueJobs\n }\n );\n }\n };\n\n return {\n createQueueJob,\n deleteQueueJobs,\n listQueueJobs\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAQA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAMO,MAAMG,+BAA+B,GACxCC,MAA6C,IACE;EAC/C,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EAEzB,MAAME,0BAA0B,GAAGA,CAAA,KAAc;IAC7C,OAAO,UAAU;EACrB,CAAC;EACD,MAAMC,qBAAqB,GAAIC,EAAU,IAAa;IAClD,OAAOA,EAAE;EACb,CAAC;EAED,MAAMC,kBAAkB,GAAGA,CAAA,KAAM;IAC7B,OAAO,cAAc;EACzB,CAAC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C,kCAAsB,EAAC;MACvC1B,MAAM;MACN2B,MAAM,EAAEH,SAAS,CAACI,GAAG,CAACC,GAAG,IAAI;QACzB,OAAO;UACHrB,EAAE,EAAEP,0BAA0B,CAAC,CAAC;UAChCQ,EAAE,EAAEP,qBAAqB,CAAC2B,GAAG,CAAC1B,EAAE;QACpC,CAAC;MACL,CAAC;IACL,CAAC,CAAC;IAEF,IAAI;MACA,MAAMsB,WAAW,CAACK,OAAO,CAAC,CAAC;MAC3B,OAAON,SAAS;IACpB,CAAC,CAAC,OAAOX,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,sCAAsC,EACpDF,EAAE,CAACG,IAAI,IAAI,yBAAyB,EACpC;QACIQ;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHnB,cAAc;IACdkB,eAAe;IACfN;EACJ,CAAC;AACL,CAAC;AAACc,OAAA,CAAAjC,+BAAA,GAAAA,+BAAA","ignoreList":[]}
@@ -1,9 +1,8 @@
1
- import { PrerenderingServiceRenderStorageOperations } from "@webiny/api-prerendering-service/types";
2
- import { Entity } from "dynamodb-toolbox";
3
- import { Tag } from "@webiny/api-prerendering-service/types";
1
+ import type { PrerenderingServiceRenderStorageOperations, Tag } from "@webiny/api-prerendering-service/types";
2
+ import type { Entity } from "@webiny/db-dynamodb/toolbox";
4
3
  export interface CreateRenderStorageOperationsParams {
5
- entity: Entity<any>;
6
- tagPathLinkEntity: Entity<any>;
4
+ entity: Entity;
5
+ tagPathLinkEntity: Entity;
7
6
  }
8
7
  export interface CreateTagPathLinkPartitionKeyParams {
9
8
  tenant: string;