@webiny/api-form-builder-so-ddb 0.0.0-unstable.de38392959 → 0.0.0-unstable.e0bfc55d5a

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.
@@ -1,5 +1,6 @@
1
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
- import { Attributes } from "../types";
1
+ import type { Table } from "@webiny/db-dynamodb/toolbox";
2
+ import { Entity } from "@webiny/db-dynamodb/toolbox";
3
+ import type { Attributes } from "../types";
3
4
  interface Params {
4
5
  table: Table<string, string, string>;
5
6
  entityName: string;
@@ -1 +1 @@
1
- {"version":3,"names":["_toolbox","require","createFormEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","id","formId","tenant","locale","createdBy","ownedBy","savedOn","createdOn","slug","version","locked","published","publishedOn","status","fields","steps","stats","settings","triggers","webinyVersion","exports"],"sources":["form.ts"],"sourcesContent":["import { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createFormEntity = (params: Params): Entity<any> => {\n const { table, entityName, attributes } = params;\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 formId: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n ownedBy: {\n type: \"map\"\n },\n savedOn: {\n type: \"string\"\n },\n createdOn: {\n type: \"string\"\n },\n name: {\n type: \"string\"\n },\n slug: {\n type: \"string\"\n },\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n published: {\n type: \"boolean\"\n },\n publishedOn: {\n type: \"string\"\n },\n status: {\n type: \"string\"\n },\n fields: {\n type: \"list\"\n },\n steps: {\n type: \"list\"\n },\n stats: {\n type: \"map\"\n },\n settings: {\n type: \"map\"\n },\n triggers: {\n type: \"map\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,gBAAgB,GAAIC,MAAc,IAAkB;EAC7D,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdH,KAAK;IACLI,IAAI,EAAEH,UAAU;IAChBC,UAAU,EAAE;MACRG,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,CAAC;MACDI,MAAM,EAAE;QACJJ,IAAI,EAAE;MACV,CAAC;MACDK,MAAM,EAAE;QACJL,IAAI,EAAE;MACV,CAAC;MACDM,MAAM,EAAE;QACJN,IAAI,EAAE;MACV,CAAC;MACDO,SAAS,EAAE;QACPP,IAAI,EAAE;MACV,CAAC;MACDQ,OAAO,EAAE;QACLR,IAAI,EAAE;MACV,CAAC;MACDS,OAAO,EAAE;QACLT,IAAI,EAAE;MACV,CAAC;MACDU,SAAS,EAAE;QACPV,IAAI,EAAE;MACV,CAAC;MACDN,IAAI,EAAE;QACFM,IAAI,EAAE;MACV,CAAC;MACDW,IAAI,EAAE;QACFX,IAAI,EAAE;MACV,CAAC;MACDY,OAAO,EAAE;QACLZ,IAAI,EAAE;MACV,CAAC;MACDa,MAAM,EAAE;QACJb,IAAI,EAAE;MACV,CAAC;MACDc,SAAS,EAAE;QACPd,IAAI,EAAE;MACV,CAAC;MACDe,WAAW,EAAE;QACTf,IAAI,EAAE;MACV,CAAC;MACDgB,MAAM,EAAE;QACJhB,IAAI,EAAE;MACV,CAAC;MACDiB,MAAM,EAAE;QACJjB,IAAI,EAAE;MACV,CAAC;MACDkB,KAAK,EAAE;QACHlB,IAAI,EAAE;MACV,CAAC;MACDmB,KAAK,EAAE;QACHnB,IAAI,EAAE;MACV,CAAC;MACDoB,QAAQ,EAAE;QACNpB,IAAI,EAAE;MACV,CAAC;MACDqB,QAAQ,EAAE;QACNrB,IAAI,EAAE;MACV,CAAC;MACDsB,aAAa,EAAE;QACXtB,IAAI,EAAE;MACV,CAAC;MACD,IAAIR,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC+B,OAAA,CAAAnC,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_toolbox","require","createFormEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","id","formId","tenant","locale","createdBy","ownedBy","savedOn","createdOn","slug","version","locked","published","publishedOn","status","fields","steps","stats","settings","triggers","webinyVersion","exports"],"sources":["form.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createFormEntity = (params: Params): Entity<any> => {\n const { table, entityName, attributes } = params;\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 formId: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n ownedBy: {\n type: \"map\"\n },\n savedOn: {\n type: \"string\"\n },\n createdOn: {\n type: \"string\"\n },\n name: {\n type: \"string\"\n },\n slug: {\n type: \"string\"\n },\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n published: {\n type: \"boolean\"\n },\n publishedOn: {\n type: \"string\"\n },\n status: {\n type: \"string\"\n },\n fields: {\n type: \"list\"\n },\n steps: {\n type: \"list\"\n },\n stats: {\n type: \"map\"\n },\n settings: {\n type: \"map\"\n },\n triggers: {\n type: \"map\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,gBAAgB,GAAIC,MAAc,IAAkB;EAC7D,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdH,KAAK;IACLI,IAAI,EAAEH,UAAU;IAChBC,UAAU,EAAE;MACRG,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,CAAC;MACDI,MAAM,EAAE;QACJJ,IAAI,EAAE;MACV,CAAC;MACDK,MAAM,EAAE;QACJL,IAAI,EAAE;MACV,CAAC;MACDM,MAAM,EAAE;QACJN,IAAI,EAAE;MACV,CAAC;MACDO,SAAS,EAAE;QACPP,IAAI,EAAE;MACV,CAAC;MACDQ,OAAO,EAAE;QACLR,IAAI,EAAE;MACV,CAAC;MACDS,OAAO,EAAE;QACLT,IAAI,EAAE;MACV,CAAC;MACDU,SAAS,EAAE;QACPV,IAAI,EAAE;MACV,CAAC;MACDN,IAAI,EAAE;QACFM,IAAI,EAAE;MACV,CAAC;MACDW,IAAI,EAAE;QACFX,IAAI,EAAE;MACV,CAAC;MACDY,OAAO,EAAE;QACLZ,IAAI,EAAE;MACV,CAAC;MACDa,MAAM,EAAE;QACJb,IAAI,EAAE;MACV,CAAC;MACDc,SAAS,EAAE;QACPd,IAAI,EAAE;MACV,CAAC;MACDe,WAAW,EAAE;QACTf,IAAI,EAAE;MACV,CAAC;MACDgB,MAAM,EAAE;QACJhB,IAAI,EAAE;MACV,CAAC;MACDiB,MAAM,EAAE;QACJjB,IAAI,EAAE;MACV,CAAC;MACDkB,KAAK,EAAE;QACHlB,IAAI,EAAE;MACV,CAAC;MACDmB,KAAK,EAAE;QACHnB,IAAI,EAAE;MACV,CAAC;MACDoB,QAAQ,EAAE;QACNpB,IAAI,EAAE;MACV,CAAC;MACDqB,QAAQ,EAAE;QACNrB,IAAI,EAAE;MACV,CAAC;MACDsB,aAAa,EAAE;QACXtB,IAAI,EAAE;MACV,CAAC;MACD,IAAIR,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC+B,OAAA,CAAAnC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,5 +1,6 @@
1
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
- import { Attributes } from "../types";
1
+ import type { Table } from "@webiny/db-dynamodb/toolbox";
2
+ import { Entity } from "@webiny/db-dynamodb/toolbox";
3
+ import type { Attributes } from "../types";
3
4
  interface Params {
4
5
  table: Table<string, string, string>;
5
6
  entityName: string;
@@ -1 +1 @@
1
- {"version":3,"names":["_toolbox","require","createSettingsEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","reCaptcha","domain","tenant","locale","exports"],"sources":["settings.ts"],"sourcesContent":["import { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSettingsEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n reCaptcha: {\n type: \"map\"\n },\n domain: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,oBAAoB,GAAIC,MAAc,IAAkB;EACjE,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFC,IAAI,EAAE;MACV,CAAC;MACDC,SAAS,EAAE;QACPD,IAAI,EAAE;MACV,CAAC;MACDE,MAAM,EAAE;QACJF,IAAI,EAAE;MACV,CAAC;MACDG,MAAM,EAAE;QACJH,IAAI,EAAE;MACV,CAAC;MACDI,MAAM,EAAE;QACJJ,IAAI,EAAE;MACV,CAAC;MACD,IAAIT,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACc,OAAA,CAAAjB,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"names":["_toolbox","require","createSettingsEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","reCaptcha","domain","tenant","locale","exports"],"sources":["settings.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSettingsEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n reCaptcha: {\n type: \"map\"\n },\n domain: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,oBAAoB,GAAIC,MAAc,IAAkB;EACjE,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFC,IAAI,EAAE;MACV,CAAC;MACDC,SAAS,EAAE;QACPD,IAAI,EAAE;MACV,CAAC;MACDE,MAAM,EAAE;QACJF,IAAI,EAAE;MACV,CAAC;MACDG,MAAM,EAAE;QACJH,IAAI,EAAE;MACV,CAAC;MACDI,MAAM,EAAE;QACJJ,IAAI,EAAE;MACV,CAAC;MACD,IAAIT,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACc,OAAA,CAAAjB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -1,5 +1,6 @@
1
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
- import { Attributes } from "../types";
1
+ import type { Table } from "@webiny/db-dynamodb/toolbox";
2
+ import { Entity } from "@webiny/db-dynamodb/toolbox";
3
+ import type { Attributes } from "../types";
3
4
  interface Params {
4
5
  table: Table<string, string, string>;
5
6
  entityName: string;
@@ -1 +1 @@
1
- {"version":3,"names":["_toolbox","require","createSubmissionEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","id","type","TYPE","data","meta","form","logs","createdOn","savedOn","ownedBy","tenant","locale","webinyVersion","exports"],"sources":["submission.ts"],"sourcesContent":["import { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSubmissionEntity = (params: Params): Entity<any> => {\n const { table, entityName, attributes } = params;\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n id: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n meta: {\n type: \"map\"\n },\n form: {\n type: \"map\"\n },\n logs: {\n type: \"list\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n ownedBy: {\n type: \"map\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,sBAAsB,GAAIC,MAAc,IAAkB;EACnE,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdH,KAAK;IACLI,IAAI,EAAEH,UAAU;IAChBC,UAAU,EAAE;MACRG,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,EAAE,EAAE;QACAC,IAAI,EAAE;MACV,CAAC;MACDC,IAAI,EAAE;QACFD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDG,IAAI,EAAE;QACFH,IAAI,EAAE;MACV,CAAC;MACDI,IAAI,EAAE;QACFJ,IAAI,EAAE;MACV,CAAC;MACDK,IAAI,EAAE;QACFL,IAAI,EAAE;MACV,CAAC;MACDM,SAAS,EAAE;QACPN,IAAI,EAAE;MACV,CAAC;MACDO,OAAO,EAAE;QACLP,IAAI,EAAE;MACV,CAAC;MACDQ,OAAO,EAAE;QACLR,IAAI,EAAE;MACV,CAAC;MACDS,MAAM,EAAE;QACJT,IAAI,EAAE;MACV,CAAC;MACDU,MAAM,EAAE;QACJV,IAAI,EAAE;MACV,CAAC;MACDW,aAAa,EAAE;QACXX,IAAI,EAAE;MACV,CAAC;MACD,IAAIR,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACoB,OAAA,CAAAxB,sBAAA,GAAAA,sBAAA"}
1
+ {"version":3,"names":["_toolbox","require","createSubmissionEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","id","type","TYPE","data","meta","form","logs","createdOn","savedOn","ownedBy","tenant","locale","webinyVersion","exports"],"sources":["submission.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSubmissionEntity = (params: Params): Entity<any> => {\n const { table, entityName, attributes } = params;\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n id: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n meta: {\n type: \"map\"\n },\n form: {\n type: \"map\"\n },\n logs: {\n type: \"list\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n ownedBy: {\n type: \"map\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,sBAAsB,GAAIC,MAAc,IAAkB;EACnE,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdH,KAAK;IACLI,IAAI,EAAEH,UAAU;IAChBC,UAAU,EAAE;MACRG,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,EAAE,EAAE;QACAC,IAAI,EAAE;MACV,CAAC;MACDC,IAAI,EAAE;QACFD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDG,IAAI,EAAE;QACFH,IAAI,EAAE;MACV,CAAC;MACDI,IAAI,EAAE;QACFJ,IAAI,EAAE;MACV,CAAC;MACDK,IAAI,EAAE;QACFL,IAAI,EAAE;MACV,CAAC;MACDM,SAAS,EAAE;QACPN,IAAI,EAAE;MACV,CAAC;MACDO,OAAO,EAAE;QACLP,IAAI,EAAE;MACV,CAAC;MACDQ,OAAO,EAAE;QACLR,IAAI,EAAE;MACV,CAAC;MACDS,MAAM,EAAE;QACJT,IAAI,EAAE;MACV,CAAC;MACDU,MAAM,EAAE;QACJV,IAAI,EAAE;MACV,CAAC;MACDW,aAAa,EAAE;QACXX,IAAI,EAAE;MACV,CAAC;MACD,IAAIR,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACoB,OAAA,CAAAxB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -1,5 +1,6 @@
1
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
- import { Attributes } from "../types";
1
+ import type { Table } from "@webiny/db-dynamodb/toolbox";
2
+ import { Entity } from "@webiny/db-dynamodb/toolbox";
3
+ import type { Attributes } from "../types";
3
4
  interface Params {
4
5
  table: Table<string, string, string>;
5
6
  entityName: string;
@@ -1 +1 @@
1
- {"version":3,"names":["_toolbox","require","createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","tenant","exports"],"sources":["system.ts"],"sourcesContent":["import { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSystemEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,kBAAkB,GAAIC,MAAc,IAAkB;EAC/D,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,MAAM,EAAE;QACJD,IAAI,EAAE;MACV,CAAC;MACD,IAAIT,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACW,OAAA,CAAAd,kBAAA,GAAAA,kBAAA"}
1
+ {"version":3,"names":["_toolbox","require","createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","tenant","exports"],"sources":["system.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSystemEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,kBAAkB,GAAIC,MAAc,IAAkB;EAC/D,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,MAAM,EAAE;QACJD,IAAI,EAAE;MACV,CAAC;MACD,IAAIT,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACW,OAAA,CAAAd,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import { DynamoDBClient } from "@webiny/aws-sdk/client-dynamodb";
1
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
2
2
  import { Table } from "@webiny/db-dynamodb/toolbox";
3
3
  interface Params {
4
4
  tableName?: string;
5
- documentClient: DynamoDBClient;
5
+ documentClient: DynamoDBDocument;
6
6
  }
7
7
  export declare const createTable: (params: Params) => Table<string, string, string>;
8
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"names":["_toolbox","require","createTable","params","tableName","documentClient","Table","name","process","env","DB_TABLE","partitionKey","sortKey","DocumentClient","indexes","GSI1","autoExecute","autoParse","exports"],"sources":["table.ts"],"sourcesContent":["import { DynamoDBClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Table } from \"@webiny/db-dynamodb/toolbox\";\n\ninterface Params {\n tableName?: string;\n documentClient: DynamoDBClient;\n}\n\nexport const createTable = (params: Params): Table<string, string, string> => {\n const { tableName, documentClient } = params;\n\n return new Table({\n name: tableName || (process.env.DB_TABLE as string),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n }\n },\n autoExecute: true,\n autoParse: true\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,WAAW,GAAIC,MAAc,IAAoC;EAC1E,MAAM;IAAEC,SAAS;IAAEC;EAAe,CAAC,GAAGF,MAAM;EAE5C,OAAO,IAAIG,cAAK,CAAC;IACbC,IAAI,EAAEH,SAAS,IAAKI,OAAO,CAACC,GAAG,CAACC,QAAmB;IACnDC,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAER,cAAc;IAC9BS,OAAO,EAAE;MACLC,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb;IACJ,CAAC;IACDI,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAhB,WAAA,GAAAA,WAAA"}
1
+ {"version":3,"names":["_toolbox","require","createTable","params","tableName","documentClient","Table","name","process","env","DB_TABLE","partitionKey","sortKey","DocumentClient","indexes","GSI1","autoExecute","autoParse","exports"],"sources":["table.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Table } from \"@webiny/db-dynamodb/toolbox\";\n\ninterface Params {\n tableName?: string;\n documentClient: DynamoDBDocument;\n}\n\nexport const createTable = (params: Params): Table<string, string, string> => {\n const { tableName, documentClient } = params;\n\n return new Table({\n name: tableName || (process.env.DB_TABLE as string),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n }\n },\n autoExecute: true,\n autoParse: true\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,WAAW,GAAIC,MAAc,IAAoC;EAC1E,MAAM;IAAEC,SAAS;IAAEC;EAAe,CAAC,GAAGF,MAAM;EAE5C,OAAO,IAAIG,cAAK,CAAC;IACbC,IAAI,EAAEH,SAAS,IAAKI,OAAO,CAACC,GAAG,CAACC,QAAmB;IACnDC,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAER,cAAc;IAC9BS,OAAO,EAAE;MACLC,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb;IACJ,CAAC;IACDI,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAhB,WAAA,GAAAA,WAAA","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { FormBuilderStorageOperationsFactory } from "./types";
1
+ import type { FormBuilderStorageOperationsFactory } from "./types";
2
2
  export * from "./plugins";
3
3
  export declare const createFormBuilderStorageOperations: FormBuilderStorageOperationsFactory;
package/index.js CHANGED
@@ -35,6 +35,7 @@ Object.keys(_plugins2).forEach(function (key) {
35
35
  }
36
36
  });
37
37
  });
38
+ var _api = require("@webiny/api");
38
39
  const reservedFields = ["PK", "SK", "index", "data", "TYPE", "__type", "GSI1_PK", "GSI1_SK"];
39
40
  const isReserved = name => {
40
41
  if (reservedFields.includes(name) === false) {
@@ -104,7 +105,7 @@ const createFormBuilderStorageOperations = params => {
104
105
  };
105
106
  return {
106
107
  beforeInit: async context => {
107
- const types = [_plugins2.FormDynamoDbFieldPlugin.type, _plugins2.FormSubmissionDynamoDbFieldPlugin.type];
108
+ const types = [_plugins2.FormDynamoDbFieldPlugin.type, _plugins2.FormSubmissionDynamoDbFieldPlugin.type, _api.CompressorPlugin.type];
108
109
  for (const type of types) {
109
110
  plugins.mergeByType(context.plugins, type);
110
111
  }
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_filters","_interopRequireDefault","require","_fields","_fields2","_error","_types","_table","_form","_submission","_system","_settings","_system2","_submission2","_settings2","_form2","_plugins","_plugins2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","reservedFields","isReserved","name","includes","WebinyError","createFormBuilderStorageOperations","params","attributes","table","tableName","documentClient","plugins","userPlugins","values","attrs","PluginsContainer","formSubmissionFields","formFields","dynamoDbValueFilters","createTable","entities","form","createFormEntity","entityName","ENTITIES","FORM","submission","createSubmissionEntity","SUBMISSION","system","createSystemEntity","SYSTEM","settings","createSettingsEntity","SETTINGS","beforeInit","context","types","FormDynamoDbFieldPlugin","type","FormSubmissionDynamoDbFieldPlugin","mergeByType","getTable","getEntities","createSystemStorageOperations","entity","createSettingsStorageOperations","createFormStorageOperations","createSubmissionStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport formSubmissionFields from \"~/operations/submission/fields\";\nimport formFields from \"~/operations/form/fields\";\nimport WebinyError from \"@webiny/error\";\nimport { FormBuilderStorageOperationsFactory, ENTITIES } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createFormEntity } from \"~/definitions/form\";\nimport { createSubmissionEntity } from \"~/definitions/submission\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createSystemStorageOperations } from \"~/operations/system\";\nimport { createSubmissionStorageOperations } from \"~/operations/submission\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createFormStorageOperations } from \"~/operations/form\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { FormDynamoDbFieldPlugin, FormSubmissionDynamoDbFieldPlugin } from \"~/plugins\";\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 * from \"./plugins\";\n\nexport const createFormBuilderStorageOperations: FormBuilderStorageOperationsFactory = params => {\n const { attributes, table: tableName, documentClient, plugins: userPlugins } = params;\n\n if (attributes) {\n Object.values(attributes).forEach(attrs => {\n Object.keys(attrs).forEach(isReserved);\n });\n }\n\n const plugins = new PluginsContainer([\n /**\n * User defined plugins.\n */\n userPlugins || [],\n /**\n * Form submission DynamoDB fields.\n */\n formSubmissionFields(),\n /**\n * Form DynamoDB fields.\n */\n formFields(),\n\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters()\n ]);\n\n const table = createTable({\n tableName,\n documentClient\n });\n\n const entities = {\n /**\n * Regular entities.\n */\n form: createFormEntity({\n entityName: ENTITIES.FORM,\n table,\n attributes: attributes ? attributes[ENTITIES.FORM] : {}\n }),\n submission: createSubmissionEntity({\n entityName: ENTITIES.SUBMISSION,\n table,\n attributes: attributes ? attributes[ENTITIES.SUBMISSION] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n })\n };\n\n return {\n beforeInit: async context => {\n const types: string[] = [\n FormDynamoDbFieldPlugin.type,\n FormSubmissionDynamoDbFieldPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n },\n getTable: () => table,\n getEntities: () => entities,\n ...createSystemStorageOperations({\n table,\n entity: entities.system\n }),\n ...createSettingsStorageOperations({\n table,\n entity: entities.settings\n }),\n ...createFormStorageOperations({\n table,\n entity: entities.form,\n plugins\n }),\n ...createSubmissionStorageOperations({\n table,\n entity: entities.submission,\n plugins\n })\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,YAAA,GAAAX,OAAA;AACA,IAAAY,UAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,QAAA,GAAAd,OAAA;AACA,IAAAe,SAAA,GAAAf,OAAA;AAaAgB,MAAA,CAAAC,IAAA,CAAAF,SAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,SAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAA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AK;MACLqC,MAAM,EAAEzB,QAAQ,CAACY;IACrB,CAAC,CAAC;IACF,GAAG,IAAAe,kCAA2B,EAAC;MAC3BvC,KAAK;MACLqC,MAAM,EAAEzB,QAAQ,CAACC,IAAI;MACrBV;IACJ,CAAC,CAAC;IACF,GAAG,IAAAqC,8CAAiC,EAAC;MACjCxC,KAAK;MACLqC,MAAM,EAAEzB,QAAQ,CAACM,UAAU;MAC3Bf;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAACf,OAAA,CAAAS,kCAAA,GAAAA,kCAAA"}
1
+ {"version":3,"names":["_filters","_interopRequireDefault","require","_fields","_fields2","_error","_types","_table","_form","_submission","_system","_settings","_system2","_submission2","_settings2","_form2","_plugins","_plugins2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_api","reservedFields","isReserved","name","includes","WebinyError","createFormBuilderStorageOperations","params","attributes","table","tableName","documentClient","plugins","userPlugins","values","attrs","PluginsContainer","formSubmissionFields","formFields","dynamoDbValueFilters","createTable","entities","form","createFormEntity","entityName","ENTITIES","FORM","submission","createSubmissionEntity","SUBMISSION","system","createSystemEntity","SYSTEM","settings","createSettingsEntity","SETTINGS","beforeInit","context","types","FormDynamoDbFieldPlugin","type","FormSubmissionDynamoDbFieldPlugin","CompressorPlugin","mergeByType","getTable","getEntities","createSystemStorageOperations","entity","createSettingsStorageOperations","createFormStorageOperations","createSubmissionStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport formSubmissionFields from \"~/operations/submission/fields\";\nimport formFields from \"~/operations/form/fields\";\nimport WebinyError from \"@webiny/error\";\nimport type { FormBuilderStorageOperationsFactory } from \"~/types\";\nimport { ENTITIES } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createFormEntity } from \"~/definitions/form\";\nimport { createSubmissionEntity } from \"~/definitions/submission\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createSystemStorageOperations } from \"~/operations/system\";\nimport { createSubmissionStorageOperations } from \"~/operations/submission\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createFormStorageOperations } from \"~/operations/form\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { FormDynamoDbFieldPlugin, FormSubmissionDynamoDbFieldPlugin } from \"~/plugins\";\nimport { CompressorPlugin } from \"@webiny/api\";\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 * from \"./plugins\";\n\nexport const createFormBuilderStorageOperations: FormBuilderStorageOperationsFactory = params => {\n const { attributes, table: tableName, documentClient, plugins: userPlugins } = params;\n\n if (attributes) {\n Object.values(attributes).forEach(attrs => {\n Object.keys(attrs).forEach(isReserved);\n });\n }\n\n const plugins = new PluginsContainer([\n /**\n * User defined plugins.\n */\n userPlugins || [],\n /**\n * Form submission DynamoDB fields.\n */\n formSubmissionFields(),\n /**\n * Form DynamoDB fields.\n */\n formFields(),\n\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters()\n ]);\n\n const table = createTable({\n tableName,\n documentClient\n });\n\n const entities = {\n /**\n * Regular entities.\n */\n form: createFormEntity({\n entityName: ENTITIES.FORM,\n table,\n attributes: attributes ? attributes[ENTITIES.FORM] : {}\n }),\n submission: createSubmissionEntity({\n entityName: ENTITIES.SUBMISSION,\n table,\n attributes: attributes ? attributes[ENTITIES.SUBMISSION] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n })\n };\n\n return {\n beforeInit: async context => {\n const types: string[] = [\n FormDynamoDbFieldPlugin.type,\n FormSubmissionDynamoDbFieldPlugin.type,\n CompressorPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n },\n getTable: () => table,\n getEntities: () => entities,\n ...createSystemStorageOperations({\n table,\n entity: entities.system\n }),\n ...createSettingsStorageOperations({\n table,\n entity: entities.settings\n }),\n ...createFormStorageOperations({\n table,\n entity: entities.form,\n plugins\n }),\n ...createSubmissionStorageOperations({\n table,\n entity: entities.submission,\n plugins\n })\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,YAAA,GAAAX,OAAA;AACA,IAAAY,UAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,QAAA,GAAAd,OAAA;AACA,IAAAe,SAAA,GAAAf,OAAA;AAcAgB,MAAA,CAAAC,IAAA,CAAAF,SAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,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AA,KAAMxB,QAAQ;IAC3B,GAAG,IAAAyB,sCAA6B,EAAC;MAC7BrC,KAAK;MACLsC,MAAM,EAAE1B,QAAQ,CAACS;IACrB,CAAC,CAAC;IACF,GAAG,IAAAkB,0CAA+B,EAAC;MAC/BvC,KAAK;MACLsC,MAAM,EAAE1B,QAAQ,CAACY;IACrB,CAAC,CAAC;IACF,GAAG,IAAAgB,kCAA2B,EAAC;MAC3BxC,KAAK;MACLsC,MAAM,EAAE1B,QAAQ,CAACC,IAAI;MACrBV;IACJ,CAAC,CAAC;IACF,GAAG,IAAAsC,8CAAiC,EAAC;MACjCzC,KAAK;MACLsC,MAAM,EAAE1B,QAAQ,CAACM,UAAU;MAC3Bf;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAAChB,OAAA,CAAAU,kCAAA,GAAAA,kCAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_FormDynamoDbFieldPlugin","require","_default","FormDynamoDbFieldPlugin","field","type","path","exports","default"],"sources":["fields.ts"],"sourcesContent":["import { FormDynamoDbFieldPlugin } from \"~/plugins/FormDynamoDbFieldPlugin\";\n\nexport default () => [\n new FormDynamoDbFieldPlugin({\n field: \"publishedOn\",\n type: \"date\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"createdOn\",\n type: \"date\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"savedOn\",\n type: \"date\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"name\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"slug\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"locale\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"tenant\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"published\",\n type: \"boolean\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"status\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"version\",\n type: \"number\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"ownedBy\",\n path: \"ownedBy.id\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"createdBy\",\n path: \"createdBy.id\"\n })\n];\n"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAA4E,IAAAC,QAAA,GAE7DA,CAAA,KAAM,CACjB,IAAIC,gDAAuB,CAAC;EACxBC,KAAK,EAAE,aAAa;EACpBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE,SAAS;EAChBE,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIH,gDAAuB,CAAC;EACxBC,KAAK,EAAE,WAAW;EAClBE,IAAI,EAAE;AACV,CAAC,CAAC,CACL;AAAAC,OAAA,CAAAC,OAAA,GAAAN,QAAA"}
1
+ {"version":3,"names":["_FormDynamoDbFieldPlugin","require","_default","FormDynamoDbFieldPlugin","field","type","path","exports","default"],"sources":["fields.ts"],"sourcesContent":["import { FormDynamoDbFieldPlugin } from \"~/plugins/FormDynamoDbFieldPlugin\";\n\nexport default () => [\n new FormDynamoDbFieldPlugin({\n field: \"publishedOn\",\n type: \"date\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"createdOn\",\n type: \"date\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"savedOn\",\n type: \"date\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"name\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"slug\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"locale\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"tenant\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"published\",\n type: \"boolean\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"status\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"version\",\n type: \"number\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"ownedBy\",\n path: \"ownedBy.id\"\n }),\n new FormDynamoDbFieldPlugin({\n field: \"createdBy\",\n path: \"createdBy.id\"\n })\n];\n"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAA4E,IAAAC,QAAA,GAE7DA,CAAA,KAAM,CACjB,IAAIC,gDAAuB,CAAC;EACxBC,KAAK,EAAE,aAAa;EACpBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC,EACF,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE,SAAS;EAChBE,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIH,gDAAuB,CAAC;EACxBC,KAAK,EAAE,WAAW;EAClBE,IAAI,EAAE;AACV,CAAC,CAAC,CACL;AAAAC,OAAA,CAAAC,OAAA,GAAAN,QAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- import { FormBuilderFormStorageOperations } from "../../types";
1
+ import type { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
+ import type { PluginsContainer } from "@webiny/plugins";
3
+ import type { FormBuilderFormStorageOperations } from "../../types";
4
4
  export interface CreateFormStorageOperationsParams {
5
5
  entity: Entity<any>;
6
6
  table: Table<string, string, string>;
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.createFormStorageOperations = void 0;
8
8
  var _error = _interopRequireDefault(require("@webiny/error"));
9
9
  var _query = require("@webiny/db-dynamodb/utils/query");
10
- var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
10
+ var _dbDynamodb = require("@webiny/db-dynamodb");
11
11
  var _filter = require("@webiny/db-dynamodb/utils/filter");
12
12
  var _sort = require("@webiny/db-dynamodb/utils/sort");
13
13
  var _utils = require("@webiny/utils");
@@ -17,7 +17,6 @@ var _get = require("@webiny/db-dynamodb/utils/get");
17
17
  const createFormStorageOperations = params => {
18
18
  const {
19
19
  entity,
20
- table,
21
20
  plugins
22
21
  } = params;
23
22
  const formDynamoDbFields = plugins.byType(_FormDynamoDbFieldPlugin.FormDynamoDbFieldPlugin.type);
@@ -107,21 +106,21 @@ const createFormStorageOperations = params => {
107
106
  const revisionKeys = createRevisionKeys(form);
108
107
  const latestKeys = createLatestKeys(form);
109
108
  const gsiKeys = createGSIKeys(form);
110
- const items = [entity.putBatch({
111
- ...form,
112
- ...revisionKeys,
113
- ...gsiKeys,
114
- TYPE: createFormType()
115
- }), entity.putBatch({
116
- ...form,
117
- ...latestKeys,
118
- TYPE: createFormLatestType()
119
- })];
109
+ const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
110
+ entity,
111
+ put: [{
112
+ ...form,
113
+ ...revisionKeys,
114
+ ...gsiKeys,
115
+ TYPE: createFormType()
116
+ }, {
117
+ ...form,
118
+ ...latestKeys,
119
+ TYPE: createFormLatestType()
120
+ }]
121
+ });
120
122
  try {
121
- await (0, _batchWrite.batchWriteAll)({
122
- table,
123
- items
124
- });
123
+ await entityBatch.execute();
125
124
  } catch (ex) {
126
125
  throw new _error.default(ex.message || "Could not insert form data into table.", ex.code || "CREATE_FORM_ERROR", {
127
126
  revisionKeys,
@@ -140,21 +139,21 @@ const createFormStorageOperations = params => {
140
139
  const revisionKeys = createRevisionKeys(form);
141
140
  const latestKeys = createLatestKeys(form);
142
141
  const gsiKeys = createGSIKeys(form);
143
- const items = [entity.putBatch({
144
- ...form,
145
- ...revisionKeys,
146
- ...gsiKeys,
147
- TYPE: createFormType()
148
- }), entity.putBatch({
149
- ...form,
150
- ...latestKeys,
151
- TYPE: createFormLatestType()
152
- })];
142
+ const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
143
+ entity,
144
+ put: [{
145
+ ...form,
146
+ ...revisionKeys,
147
+ ...gsiKeys,
148
+ TYPE: createFormType()
149
+ }, {
150
+ ...form,
151
+ ...latestKeys,
152
+ TYPE: createFormLatestType()
153
+ }]
154
+ });
153
155
  try {
154
- await (0, _batchWrite.batchWriteAll)({
155
- table,
156
- items
157
- });
156
+ await entityBatch.execute();
158
157
  } catch (ex) {
159
158
  throw new _error.default(ex.message || "Could not create form data in the table, from existing form.", ex.code || "CREATE_FORM_FROM_ERROR", {
160
159
  revisionKeys,
@@ -188,24 +187,24 @@ const createFormStorageOperations = params => {
188
187
  }
189
188
  });
190
189
  const isLatestForm = latestForm ? latestForm.id === form.id : false;
191
- const items = [entity.putBatch({
192
- ...form,
193
- ...revisionKeys,
194
- ...gsiKeys,
195
- TYPE: createFormType()
196
- })];
190
+ const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
191
+ entity,
192
+ put: [{
193
+ ...form,
194
+ ...revisionKeys,
195
+ ...gsiKeys,
196
+ TYPE: createFormType()
197
+ }]
198
+ });
197
199
  if (isLatestForm) {
198
- items.push(entity.putBatch({
200
+ entityBatch.put({
199
201
  ...form,
200
202
  ...latestKeys,
201
203
  TYPE: createFormLatestType()
202
- }));
204
+ });
203
205
  }
204
206
  try {
205
- await (0, _batchWrite.batchWriteAll)({
206
- table,
207
- items
208
- });
207
+ await entityBatch.execute();
209
208
  } catch (ex) {
210
209
  throw new _error.default(ex.message || "Could not update form data in the table.", ex.code || "UPDATE_FORM_ERROR", {
211
210
  revisionKeys,
@@ -409,25 +408,25 @@ const createFormStorageOperations = params => {
409
408
  options: queryAllParams.options
410
409
  });
411
410
  }
412
- let hasLatestPublishedRecord = false;
413
- const deleteItems = items.map(item => {
414
- if (!hasLatestPublishedRecord && item.published) {
415
- hasLatestPublishedRecord = true;
411
+ let latestPublishedKeys;
412
+ const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
413
+ entity,
414
+ delete: [createLatestKeys(form)]
415
+ });
416
+ for (const item of items) {
417
+ if (!latestPublishedKeys && item.published) {
418
+ latestPublishedKeys = createLatestPublishedKeys(item);
416
419
  }
417
- return entity.deleteBatch({
420
+ entityBatch.delete({
418
421
  PK: item.PK,
419
422
  SK: item.SK
420
423
  });
421
- });
422
- if (hasLatestPublishedRecord) {
423
- deleteItems.push(entity.deleteBatch(createLatestPublishedKeys(items[0])));
424
424
  }
425
- deleteItems.push(entity.deleteBatch(createLatestKeys(items[0])));
425
+ if (latestPublishedKeys) {
426
+ entityBatch.delete(latestPublishedKeys);
427
+ }
426
428
  try {
427
- await (0, _batchWrite.batchWriteAll)({
428
- table,
429
- items: deleteItems
430
- });
429
+ await entityBatch.execute();
431
430
  } catch (ex) {
432
431
  throw new _error.default(ex.message || "Could not delete form and it's submissions.", ex.code || "DELETE_FORM_AND_SUBMISSIONS_ERROR");
433
432
  }
@@ -451,7 +450,10 @@ const createFormStorageOperations = params => {
451
450
  const latestPublishedForm = revisions.find(rev => rev.published === true);
452
451
  const isLatest = latestForm ? latestForm.id === form.id : false;
453
452
  const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;
454
- const items = [entity.deleteBatch(revisionKeys)];
453
+ const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
454
+ entity,
455
+ delete: [revisionKeys]
456
+ });
455
457
  if (isLatest || isLatestPublished) {
456
458
  /**
457
459
  * Sort out the latest published record.
@@ -461,38 +463,35 @@ const createFormStorageOperations = params => {
461
463
  return new Date(b.publishedOn).getTime() - new Date(a.publishedOn).getTime();
462
464
  }).shift();
463
465
  if (previouslyPublishedForm) {
464
- items.push(entity.putBatch({
466
+ entityBatch.put({
465
467
  ...previouslyPublishedForm,
466
468
  ...createLatestPublishedKeys(previouslyPublishedForm),
467
469
  GSI1_PK: null,
468
470
  GSI1_SK: null,
469
471
  TYPE: createFormLatestPublishedType()
470
- }));
472
+ });
471
473
  } else {
472
- items.push(entity.deleteBatch(createLatestPublishedKeys(form)));
474
+ entityBatch.delete(createLatestPublishedKeys(form));
473
475
  }
474
476
  }
475
477
  /**
476
478
  * Sort out the latest record.
477
479
  */
478
480
  if (isLatest) {
479
- items.push(entity.putBatch({
481
+ entityBatch.put({
480
482
  ...previous,
481
483
  ...latestKeys,
482
484
  GSI1_PK: null,
483
485
  GSI1_SK: null,
484
486
  TYPE: createFormLatestType()
485
- }));
487
+ });
486
488
  }
487
489
  }
488
490
  /**
489
491
  * Now save the batch data.
490
492
  */
491
493
  try {
492
- await (0, _batchWrite.batchWriteAll)({
493
- table,
494
- items
495
- });
494
+ await entityBatch.execute();
496
495
  return form;
497
496
  } catch (ex) {
498
497
  throw new _error.default(ex.message || "Could not delete form revision from table.", ex.code || "DELETE_FORM_REVISION_ERROR", {
@@ -540,31 +539,32 @@ const createFormStorageOperations = params => {
540
539
  /**
541
540
  * Update revision and latest published records
542
541
  */
543
- const items = [entity.putBatch({
544
- ...form,
545
- ...revisionKeys,
546
- ...gsiKeys,
547
- TYPE: createFormType()
548
- }), entity.putBatch({
549
- ...form,
550
- ...latestPublishedKeys,
551
- TYPE: createFormLatestPublishedType()
552
- })];
542
+ const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
543
+ entity,
544
+ put: [{
545
+ ...form,
546
+ ...revisionKeys,
547
+ ...gsiKeys,
548
+ TYPE: createFormType()
549
+ }, {
550
+ ...form,
551
+ ...latestPublishedKeys,
552
+ TYPE: createFormLatestPublishedType()
553
+ }]
554
+ });
555
+
553
556
  /**
554
557
  * Update the latest form as well
555
558
  */
556
559
  if (isLatestForm) {
557
- items.push(entity.putBatch({
560
+ entityBatch.put({
558
561
  ...form,
559
562
  ...latestKeys,
560
563
  TYPE: createFormLatestType()
561
- }));
564
+ });
562
565
  }
563
566
  try {
564
- await (0, _batchWrite.batchWriteAll)({
565
- table,
566
- items
567
- });
567
+ await entityBatch.execute();
568
568
  } catch (ex) {
569
569
  throw new _error.default(ex.message || "Could not publish form.", ex.code || "PUBLISH_FORM_ERROR", {
570
570
  form,
@@ -616,14 +616,17 @@ const createFormStorageOperations = params => {
616
616
  });
617
617
  const isLatest = latestForm ? latestForm.id === form.id : false;
618
618
  const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;
619
- const items = [entity.putBatch({
620
- ...form,
621
- ...revisionKeys,
622
- ...gsiKeys,
623
- TYPE: createFormType()
624
- })];
619
+ const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
620
+ entity,
621
+ put: [{
622
+ ...form,
623
+ ...revisionKeys,
624
+ ...gsiKeys,
625
+ TYPE: createFormType()
626
+ }]
627
+ });
625
628
  if (isLatest) {
626
- entity.putBatch({
629
+ entityBatch.put({
627
630
  ...form,
628
631
  ...latestKeys,
629
632
  TYPE: createFormLatestType()
@@ -646,20 +649,17 @@ const createFormStorageOperations = params => {
646
649
  });
647
650
  const previouslyPublishedRevision = revisions.shift();
648
651
  if (previouslyPublishedRevision) {
649
- items.push(entity.putBatch({
652
+ entityBatch.put({
650
653
  ...previouslyPublishedRevision,
651
654
  ...latestPublishedKeys,
652
655
  TYPE: createFormLatestPublishedType()
653
- }));
656
+ });
654
657
  } else {
655
- items.push(entity.deleteBatch(latestPublishedKeys));
658
+ entityBatch.delete(latestPublishedKeys);
656
659
  }
657
660
  }
658
661
  try {
659
- await (0, _batchWrite.batchWriteAll)({
660
- table,
661
- items
662
- });
662
+ await entityBatch.execute();
663
663
  return form;
664
664
  } catch (ex) {
665
665
  throw new _error.default(ex.message || "Could not unpublish form.", ex.code || "UNPUBLISH_FORM_ERROR", {
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_query","_batchWrite","_filter","_sort","_utils","_FormDynamoDbFieldPlugin","_cursor","_get","createFormStorageOperations","params","entity","table","plugins","formDynamoDbFields","byType","FormDynamoDbFieldPlugin","type","createFormPartitionKey","tenant","locale","createFormLatestPartitionKey","createFormLatestPublishedPartitionKey","createFormGSIPartitionKey","id","targetId","parseIdentifier","createRevisionSortKey","createFormLatestSortKey","formId","value","createLatestPublishedSortKey","createGSISortKey","version","createFormType","createFormLatestType","createFormLatestPublishedType","createRevisionKeys","form","PK","SK","createLatestKeys","createLatestPublishedKeys","createGSIKeys","GSI1_PK","GSI1_SK","createForm","revisionKeys","latestKeys","gsiKeys","items","putBatch","TYPE","batchWriteAll","ex","WebinyError","message","code","createFormFrom","original","latest","updateForm","latestForm","getForm","where","isLatestForm","push","published","partitionKey","sortKey","createIdentifier","keys","getClean","listForms","sort","limit","initialWhere","after","queryAllParams","options","gte","results","queryAll","totalCount","length","filteredItems","filterItems","fields","sortedItems","sortItems","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slice","cursor","encodeCursor","meta","listFormRevisions","index","deleteForm","beginsWith","hasLatestPublishedRecord","deleteItems","map","item","deleteBatch","deleteFormRevision","revisions","previous","latestPublishedForm","find","rev","isLatest","isLatestPublished","previouslyPublishedForm","filter","f","publishedOn","a","b","Date","getTime","shift","publishForm","latestPublishedKeys","unpublishForm","version_not","publishedOn_not","previouslyPublishedRevision","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n FbForm,\n FormBuilderStorageOperationsCreateFormFromParams,\n FormBuilderStorageOperationsCreateFormParams,\n FormBuilderStorageOperationsDeleteFormParams,\n FormBuilderStorageOperationsDeleteFormRevisionParams,\n FormBuilderStorageOperationsGetFormParams,\n FormBuilderStorageOperationsListFormRevisionsParams,\n FormBuilderStorageOperationsListFormRevisionsParamsWhere,\n FormBuilderStorageOperationsListFormsParams,\n FormBuilderStorageOperationsListFormsResponse,\n FormBuilderStorageOperationsPublishFormParams,\n FormBuilderStorageOperationsUnpublishFormParams,\n FormBuilderStorageOperationsUpdateFormParams\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n FormBuilderFormCreateGSIPartitionKeyParams,\n FormBuilderFormCreatePartitionKeyParams,\n FormBuilderFormStorageOperations\n} from \"~/types\";\nimport { FormDynamoDbFieldPlugin } from \"~/plugins/FormDynamoDbFieldPlugin\";\nimport { decodeCursor, encodeCursor } from \"@webiny/db-dynamodb/utils/cursor\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\n\ntype DbRecord<T = any> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\n\ninterface FormLatestSortKeyParams {\n id?: string;\n formId?: string;\n}\n\ninterface GsiKeys {\n GSI1_PK: string;\n GSI1_SK: string;\n}\n\nexport interface CreateFormStorageOperationsParams {\n entity: Entity<any>;\n table: Table<string, string, string>;\n plugins: PluginsContainer;\n}\n\nexport const createFormStorageOperations = (\n params: CreateFormStorageOperationsParams\n): FormBuilderFormStorageOperations => {\n const { entity, table, plugins } = params;\n\n const formDynamoDbFields = plugins.byType<FormDynamoDbFieldPlugin>(\n FormDynamoDbFieldPlugin.type\n );\n\n const createFormPartitionKey = (params: FormBuilderFormCreatePartitionKeyParams): string => {\n const { tenant, locale } = params;\n\n return `T#${tenant}#L#${locale}#FB#F`;\n };\n\n const createFormLatestPartitionKey = (\n params: FormBuilderFormCreatePartitionKeyParams\n ): string => {\n return `${createFormPartitionKey(params)}#L`;\n };\n\n const createFormLatestPublishedPartitionKey = (\n params: FormBuilderFormCreatePartitionKeyParams\n ): string => {\n return `${createFormPartitionKey(params)}#LP`;\n };\n\n const createFormGSIPartitionKey = (\n params: FormBuilderFormCreateGSIPartitionKeyParams\n ): string => {\n const { tenant, locale, id: targetId } = params;\n const { id } = parseIdentifier(targetId);\n\n return `T#${tenant}#L#${locale}#FB#F#${id}`;\n };\n\n const createRevisionSortKey = ({ id }: { id: string }): string => {\n return `${id}`;\n };\n\n const createFormLatestSortKey = ({ id, formId }: FormLatestSortKeyParams): string => {\n const value = parseIdentifier(id || formId);\n return value.id;\n };\n\n const createLatestPublishedSortKey = ({ id, formId }: FormLatestSortKeyParams): string => {\n const value = parseIdentifier(id || formId);\n return value.id;\n };\n\n const createGSISortKey = (version: number) => {\n return `${version}`;\n };\n\n const createFormType = (): string => {\n return \"fb.form\";\n };\n\n const createFormLatestType = (): string => {\n return \"fb.form.latest\";\n };\n\n const createFormLatestPublishedType = (): string => {\n return \"fb.form.latestPublished\";\n };\n\n const createRevisionKeys = (form: FbForm): Keys => {\n return {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form)\n };\n };\n\n const createLatestKeys = (form: FbForm): Keys => {\n return {\n PK: createFormLatestPartitionKey(form),\n SK: createFormLatestSortKey(form)\n };\n };\n\n const createLatestPublishedKeys = (form: FbForm): Keys => {\n return {\n PK: createFormLatestPublishedPartitionKey(form),\n SK: createLatestPublishedSortKey(form)\n };\n };\n\n const createGSIKeys = (form: FbForm): GsiKeys => {\n return {\n GSI1_PK: createFormGSIPartitionKey(form),\n GSI1_SK: createGSISortKey(form.version)\n };\n };\n\n const createForm = async (\n params: FormBuilderStorageOperationsCreateFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n }),\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n ];\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert form data into table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n form\n }\n );\n }\n return form;\n };\n\n const createFormFrom = async (\n params: FormBuilderStorageOperationsCreateFormFromParams\n ): Promise<FbForm> => {\n const { form, original, latest } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n }),\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n ];\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form data in the table, from existing form.\",\n ex.code || \"CREATE_FORM_FROM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latest\n }\n );\n }\n\n return form;\n };\n\n const updateForm = async (\n params: FormBuilderStorageOperationsUpdateFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const { formId, tenant, locale } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n const isLatestForm = latestForm ? latestForm.id === form.id : false;\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n })\n ];\n if (isLatestForm) {\n items.push(\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n );\n }\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form data in the table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latestForm\n }\n );\n }\n\n return form;\n };\n\n const getForm = async (\n params: FormBuilderStorageOperationsGetFormParams\n ): Promise<FbForm | null> => {\n const { where } = params;\n const { id, formId, latest, published, version } = where;\n if (latest && published) {\n throw new WebinyError(\"Cannot have both latest and published params.\");\n }\n let partitionKey: string;\n let sortKey: string;\n if (latest) {\n partitionKey = createFormLatestPartitionKey(where);\n sortKey = createFormLatestSortKey(where);\n } else if (published && !version) {\n /**\n * Because of the specifics how DynamoDB works, we must not load the published record if version is sent.\n */\n partitionKey = createFormLatestPublishedPartitionKey(where);\n sortKey = createLatestPublishedSortKey(where);\n } else if (id || version) {\n partitionKey = createFormPartitionKey(where);\n sortKey = createRevisionSortKey({\n id:\n id ||\n createIdentifier({\n id: formId as string,\n version: version as number\n })\n });\n } else {\n throw new WebinyError(\n \"Missing parameter to create a sort key.\",\n \"MISSING_WHERE_PARAMETER\",\n {\n where\n }\n );\n }\n\n const keys = {\n PK: partitionKey,\n SK: sortKey\n };\n\n try {\n return await getClean<FbForm>({ entity, keys });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get form by keys.\",\n ex.code || \"GET_FORM_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const listForms = async (\n params: FormBuilderStorageOperationsListFormsParams\n ): Promise<FormBuilderStorageOperationsListFormsResponse> => {\n const { sort, limit, where: initialWhere, after } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormLatestPartitionKey(initialWhere),\n options: {\n gte: \" \"\n }\n };\n\n let results;\n try {\n results = await queryAll<FbForm>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list forms.\",\n ex.code || \"LIST_FORMS_ERROR\",\n {\n where: initialWhere,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n const totalCount = results.length;\n\n const where: Partial<FormBuilderStorageOperationsListFormsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.tenant;\n delete where.locale;\n\n const filteredItems = filterItems({\n plugins,\n items: results,\n where,\n fields: formDynamoDbFields\n });\n\n const sortedItems = sortItems({\n items: filteredItems,\n sort,\n fields: formDynamoDbFields\n });\n\n const start = parseInt(decodeCursor(after) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const items = sortedItems.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = items.length > 0 ? encodeCursor(start + limit) : null;\n\n const meta = {\n hasMoreItems,\n totalCount,\n cursor\n };\n\n return {\n items,\n meta\n };\n };\n\n const listFormRevisions = async (\n params: FormBuilderStorageOperationsListFormRevisionsParams\n ): Promise<FbForm[]> => {\n const { where: initialWhere, sort } = params;\n const { id, formId, tenant, locale } = initialWhere;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormGSIPartitionKey({\n tenant,\n locale,\n id: formId || id\n }),\n options: {\n index: \"GSI1\",\n gte: \" \"\n }\n };\n\n let items: FbForm[] = [];\n try {\n items = await queryAll<FbForm>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query forms by given params.\",\n ex.code || \"QUERY_FORMS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n const where: Partial<FormBuilderStorageOperationsListFormRevisionsParamsWhere> = {\n ...initialWhere\n };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.id;\n delete where.formId;\n delete where.tenant;\n delete where.locale;\n\n const filteredItems = filterItems({\n plugins,\n items,\n where,\n fields: formDynamoDbFields\n });\n return sortItems({\n items: filteredItems,\n sort,\n fields: formDynamoDbFields\n });\n };\n\n const deleteForm = async (\n params: FormBuilderStorageOperationsDeleteFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n let items: any[];\n /**\n * This will find all form records.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormPartitionKey(form),\n options: {\n beginsWith: form.formId || undefined\n }\n };\n try {\n items = await queryAll<DbRecord>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query forms and submissions by given params.\",\n ex.code || \"QUERY_FORM_AND_SUBMISSIONS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n\n let hasLatestPublishedRecord = false;\n\n const deleteItems = items.map(item => {\n if (!hasLatestPublishedRecord && item.published) {\n hasLatestPublishedRecord = true;\n }\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n if (hasLatestPublishedRecord) {\n deleteItems.push(entity.deleteBatch(createLatestPublishedKeys(items[0])));\n }\n\n deleteItems.push(entity.deleteBatch(createLatestKeys(items[0])));\n\n try {\n await batchWriteAll({\n table,\n items: deleteItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form and it's submissions.\",\n ex.code || \"DELETE_FORM_AND_SUBMISSIONS_ERROR\"\n );\n }\n return form;\n };\n /**\n * We need to:\n * - delete current revision\n * - get previously published revision and update the record if it exists or delete if it does not\n * - update latest record if current one is the latest\n */\n const deleteFormRevision = async (\n params: FormBuilderStorageOperationsDeleteFormRevisionParams\n ): Promise<FbForm> => {\n const { form, revisions, previous } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n\n const latestForm = revisions[0];\n const latestPublishedForm = revisions.find(rev => rev.published === true);\n\n const isLatest = latestForm ? latestForm.id === form.id : false;\n const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;\n\n const items = [entity.deleteBatch(revisionKeys)];\n\n if (isLatest || isLatestPublished) {\n /**\n * Sort out the latest published record.\n */\n if (isLatestPublished) {\n const previouslyPublishedForm = revisions\n .filter(f => !!f.publishedOn && f.version !== form.version)\n .sort((a, b) => {\n return (\n new Date(b.publishedOn as string).getTime() -\n new Date(a.publishedOn as string).getTime()\n );\n })\n .shift();\n if (previouslyPublishedForm) {\n items.push(\n entity.putBatch({\n ...previouslyPublishedForm,\n ...createLatestPublishedKeys(previouslyPublishedForm),\n GSI1_PK: null,\n GSI1_SK: null,\n TYPE: createFormLatestPublishedType()\n })\n );\n } else {\n items.push(entity.deleteBatch(createLatestPublishedKeys(form)));\n }\n }\n /**\n * Sort out the latest record.\n */\n if (isLatest) {\n items.push(\n entity.putBatch({\n ...previous,\n ...latestKeys,\n GSI1_PK: null,\n GSI1_SK: null,\n TYPE: createFormLatestType()\n })\n );\n }\n }\n /**\n * Now save the batch data.\n */\n try {\n await batchWriteAll({\n table,\n items\n });\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form revision from table.\",\n ex.code || \"DELETE_FORM_REVISION_ERROR\",\n {\n form,\n latestForm,\n revisionKeys,\n latestKeys\n }\n );\n }\n };\n\n /**\n * We need to save form in:\n * - regular form record\n * - latest published form record\n * - latest form record - if form is latest one\n * - elasticsearch latest form record\n */\n const publishForm = async (\n params: FormBuilderStorageOperationsPublishFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = createRevisionKeys(form);\n\n const latestKeys = createLatestKeys(form);\n\n const latestPublishedKeys = createLatestPublishedKeys(form);\n\n const gsiKeys = {\n GSI1_PK: createFormGSIPartitionKey(form),\n GSI1_SK: createGSISortKey(form.version)\n };\n\n const { locale, tenant, formId } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n\n const isLatestForm = latestForm ? latestForm.id === form.id : false;\n /**\n * Update revision and latest published records\n */\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n }),\n entity.putBatch({\n ...form,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n })\n ];\n /**\n * Update the latest form as well\n */\n if (isLatestForm) {\n items.push(\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not publish form.\",\n ex.code || \"PUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n return form;\n };\n\n /**\n * We need to:\n * - update form revision record\n * - if latest published (LP) is current form, find the previously published record and update LP if there is some previously published, delete otherwise\n * - if is latest update the Elasticsearch record\n */\n const unpublishForm = async (\n params: FormBuilderStorageOperationsUnpublishFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const latestPublishedKeys = createLatestPublishedKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const { formId, tenant, locale } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n\n const latestPublishedForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n published: true\n }\n });\n\n const isLatest = latestForm ? latestForm.id === form.id : false;\n const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n })\n ];\n\n if (isLatest) {\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n });\n }\n /**\n * In case previously published revision exists, replace current one with that one.\n * And if it does not, delete the record.\n */\n if (isLatestPublished) {\n const revisions = await listFormRevisions({\n where: {\n formId,\n tenant,\n locale,\n version_not: form.version,\n publishedOn_not: null\n },\n sort: [\"savedOn_DESC\"]\n });\n\n const previouslyPublishedRevision = revisions.shift();\n if (previouslyPublishedRevision) {\n items.push(\n entity.putBatch({\n ...previouslyPublishedRevision,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n })\n );\n } else {\n items.push(entity.deleteBatch(latestPublishedKeys));\n }\n }\n\n try {\n await batchWriteAll({\n table,\n items\n });\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not unpublish form.\",\n ex.code || \"UNPUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n };\n\n return {\n createForm,\n createFormFrom,\n updateForm,\n listForms,\n listFormRevisions,\n getForm,\n deleteForm,\n deleteFormRevision,\n publishForm,\n unpublishForm,\n createFormPartitionKey\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAiBA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA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F,EAAE,CAACG,IAAI,IAAI,sBAAsB,EACjC;QACInB,IAAI;QACJqB,QAAQ;QACRG,UAAU;QACVf,YAAY;QACZC,UAAU;QACV+E;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHjF,UAAU;IACVY,cAAc;IACdG,UAAU;IACVY,SAAS;IACT2B,iBAAiB;IACjBrC,OAAO;IACPuC,UAAU;IACVO,kBAAkB;IAClBiB,WAAW;IACXE,aAAa;IACb9G;EACJ,CAAC;AACL,CAAC;AAACkH,OAAA,CAAA3H,2BAAA,GAAAA,2BAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_query","_dbDynamodb","_filter","_sort","_utils","_FormDynamoDbFieldPlugin","_cursor","_get","createFormStorageOperations","params","entity","plugins","formDynamoDbFields","byType","FormDynamoDbFieldPlugin","type","createFormPartitionKey","tenant","locale","createFormLatestPartitionKey","createFormLatestPublishedPartitionKey","createFormGSIPartitionKey","id","targetId","parseIdentifier","createRevisionSortKey","createFormLatestSortKey","formId","value","createLatestPublishedSortKey","createGSISortKey","version","createFormType","createFormLatestType","createFormLatestPublishedType","createRevisionKeys","form","PK","SK","createLatestKeys","createLatestPublishedKeys","createGSIKeys","GSI1_PK","GSI1_SK","createForm","revisionKeys","latestKeys","gsiKeys","entityBatch","createEntityWriteBatch","put","TYPE","execute","ex","WebinyError","message","code","createFormFrom","original","latest","updateForm","latestForm","getForm","where","isLatestForm","published","partitionKey","sortKey","createIdentifier","keys","getClean","listForms","sort","limit","initialWhere","after","queryAllParams","options","gte","results","queryAll","totalCount","length","filteredItems","filterItems","items","fields","sortedItems","sortItems","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slice","cursor","encodeCursor","meta","listFormRevisions","index","deleteForm","beginsWith","latestPublishedKeys","delete","item","deleteFormRevision","revisions","previous","latestPublishedForm","find","rev","isLatest","isLatestPublished","previouslyPublishedForm","filter","f","publishedOn","a","b","Date","getTime","shift","publishForm","unpublishForm","version_not","publishedOn_not","previouslyPublishedRevision","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n FbForm,\n FormBuilderStorageOperationsCreateFormFromParams,\n FormBuilderStorageOperationsCreateFormParams,\n FormBuilderStorageOperationsDeleteFormParams,\n FormBuilderStorageOperationsDeleteFormRevisionParams,\n FormBuilderStorageOperationsGetFormParams,\n FormBuilderStorageOperationsListFormRevisionsParams,\n FormBuilderStorageOperationsListFormRevisionsParamsWhere,\n FormBuilderStorageOperationsListFormsParams,\n FormBuilderStorageOperationsListFormsResponse,\n FormBuilderStorageOperationsPublishFormParams,\n FormBuilderStorageOperationsUnpublishFormParams,\n FormBuilderStorageOperationsUpdateFormParams\n} from \"@webiny/api-form-builder/types\";\nimport type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { createEntityWriteBatch } from \"@webiny/db-dynamodb\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n FormBuilderFormCreateGSIPartitionKeyParams,\n FormBuilderFormCreatePartitionKeyParams,\n FormBuilderFormStorageOperations\n} from \"~/types\";\nimport { FormDynamoDbFieldPlugin } from \"~/plugins/FormDynamoDbFieldPlugin\";\nimport { decodeCursor, encodeCursor } from \"@webiny/db-dynamodb/utils/cursor\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\n\ntype DbRecord<T = any> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\n\ninterface FormLatestSortKeyParams {\n id?: string;\n formId?: string;\n}\n\ninterface GsiKeys {\n GSI1_PK: string;\n GSI1_SK: string;\n}\n\nexport interface CreateFormStorageOperationsParams {\n entity: Entity<any>;\n table: Table<string, string, string>;\n plugins: PluginsContainer;\n}\n\nexport const createFormStorageOperations = (\n params: CreateFormStorageOperationsParams\n): FormBuilderFormStorageOperations => {\n const { entity, plugins } = params;\n\n const formDynamoDbFields = plugins.byType<FormDynamoDbFieldPlugin>(\n FormDynamoDbFieldPlugin.type\n );\n\n const createFormPartitionKey = (params: FormBuilderFormCreatePartitionKeyParams): string => {\n const { tenant, locale } = params;\n\n return `T#${tenant}#L#${locale}#FB#F`;\n };\n\n const createFormLatestPartitionKey = (\n params: FormBuilderFormCreatePartitionKeyParams\n ): string => {\n return `${createFormPartitionKey(params)}#L`;\n };\n\n const createFormLatestPublishedPartitionKey = (\n params: FormBuilderFormCreatePartitionKeyParams\n ): string => {\n return `${createFormPartitionKey(params)}#LP`;\n };\n\n const createFormGSIPartitionKey = (\n params: FormBuilderFormCreateGSIPartitionKeyParams\n ): string => {\n const { tenant, locale, id: targetId } = params;\n const { id } = parseIdentifier(targetId);\n\n return `T#${tenant}#L#${locale}#FB#F#${id}`;\n };\n\n const createRevisionSortKey = ({ id }: { id: string }): string => {\n return `${id}`;\n };\n\n const createFormLatestSortKey = ({ id, formId }: FormLatestSortKeyParams): string => {\n const value = parseIdentifier(id || formId);\n return value.id;\n };\n\n const createLatestPublishedSortKey = ({ id, formId }: FormLatestSortKeyParams): string => {\n const value = parseIdentifier(id || formId);\n return value.id;\n };\n\n const createGSISortKey = (version: number) => {\n return `${version}`;\n };\n\n const createFormType = (): string => {\n return \"fb.form\";\n };\n\n const createFormLatestType = (): string => {\n return \"fb.form.latest\";\n };\n\n const createFormLatestPublishedType = (): string => {\n return \"fb.form.latestPublished\";\n };\n\n const createRevisionKeys = (form: Pick<FbForm, \"id\" | \"tenant\" | \"locale\">): Keys => {\n return {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form)\n };\n };\n\n const createLatestKeys = (form: Pick<FbForm, \"tenant\" | \"locale\" | \"id\" | \"formId\">): Keys => {\n return {\n PK: createFormLatestPartitionKey(form),\n SK: createFormLatestSortKey(form)\n };\n };\n\n const createLatestPublishedKeys = (\n form: Pick<FbForm, \"tenant\" | \"locale\" | \"id\" | \"formId\">\n ): Keys => {\n return {\n PK: createFormLatestPublishedPartitionKey(form),\n SK: createLatestPublishedSortKey(form)\n };\n };\n\n const createGSIKeys = (form: Pick<FbForm, \"version\" | \"tenant\" | \"locale\">): GsiKeys => {\n return {\n GSI1_PK: createFormGSIPartitionKey(form),\n GSI1_SK: createGSISortKey(form.version)\n };\n };\n\n const createForm = async (\n params: FormBuilderStorageOperationsCreateFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n },\n {\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n }\n ]\n });\n\n try {\n await entityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert form data into table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n form\n }\n );\n }\n return form;\n };\n\n const createFormFrom = async (\n params: FormBuilderStorageOperationsCreateFormFromParams\n ): Promise<FbForm> => {\n const { form, original, latest } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n },\n {\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n }\n ]\n });\n\n try {\n await entityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form data in the table, from existing form.\",\n ex.code || \"CREATE_FORM_FROM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latest\n }\n );\n }\n\n return form;\n };\n\n const updateForm = async (\n params: FormBuilderStorageOperationsUpdateFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const { formId, tenant, locale } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n const isLatestForm = latestForm ? latestForm.id === form.id : false;\n\n const entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n }\n ]\n });\n\n if (isLatestForm) {\n entityBatch.put({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n });\n }\n try {\n await entityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form data in the table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latestForm\n }\n );\n }\n\n return form;\n };\n\n const getForm = async (\n params: FormBuilderStorageOperationsGetFormParams\n ): Promise<FbForm | null> => {\n const { where } = params;\n const { id, formId, latest, published, version } = where;\n if (latest && published) {\n throw new WebinyError(\"Cannot have both latest and published params.\");\n }\n let partitionKey: string;\n let sortKey: string;\n if (latest) {\n partitionKey = createFormLatestPartitionKey(where);\n sortKey = createFormLatestSortKey(where);\n } else if (published && !version) {\n /**\n * Because of the specifics how DynamoDB works, we must not load the published record if version is sent.\n */\n partitionKey = createFormLatestPublishedPartitionKey(where);\n sortKey = createLatestPublishedSortKey(where);\n } else if (id || version) {\n partitionKey = createFormPartitionKey(where);\n sortKey = createRevisionSortKey({\n id:\n id ||\n createIdentifier({\n id: formId as string,\n version: version as number\n })\n });\n } else {\n throw new WebinyError(\n \"Missing parameter to create a sort key.\",\n \"MISSING_WHERE_PARAMETER\",\n {\n where\n }\n );\n }\n\n const keys = {\n PK: partitionKey,\n SK: sortKey\n };\n\n try {\n return await getClean<FbForm>({ entity, keys });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get form by keys.\",\n ex.code || \"GET_FORM_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const listForms = async (\n params: FormBuilderStorageOperationsListFormsParams\n ): Promise<FormBuilderStorageOperationsListFormsResponse> => {\n const { sort, limit, where: initialWhere, after } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormLatestPartitionKey(initialWhere),\n options: {\n gte: \" \"\n }\n };\n\n let results;\n try {\n results = await queryAll<FbForm>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list forms.\",\n ex.code || \"LIST_FORMS_ERROR\",\n {\n where: initialWhere,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n const totalCount = results.length;\n\n const where: Partial<FormBuilderStorageOperationsListFormsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.tenant;\n delete where.locale;\n\n const filteredItems = filterItems({\n plugins,\n items: results,\n where,\n fields: formDynamoDbFields\n });\n\n const sortedItems = sortItems({\n items: filteredItems,\n sort,\n fields: formDynamoDbFields\n });\n\n const start = parseInt(decodeCursor(after) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const items = sortedItems.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = items.length > 0 ? encodeCursor(start + limit) : null;\n\n const meta = {\n hasMoreItems,\n totalCount,\n cursor\n };\n\n return {\n items,\n meta\n };\n };\n\n const listFormRevisions = async (\n params: FormBuilderStorageOperationsListFormRevisionsParams\n ): Promise<FbForm[]> => {\n const { where: initialWhere, sort } = params;\n const { id, formId, tenant, locale } = initialWhere;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormGSIPartitionKey({\n tenant,\n locale,\n id: formId || id\n }),\n options: {\n index: \"GSI1\",\n gte: \" \"\n }\n };\n\n let items: FbForm[] = [];\n try {\n items = await queryAll<FbForm>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query forms by given params.\",\n ex.code || \"QUERY_FORMS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n const where: Partial<FormBuilderStorageOperationsListFormRevisionsParamsWhere> = {\n ...initialWhere\n };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.id;\n delete where.formId;\n delete where.tenant;\n delete where.locale;\n\n const filteredItems = filterItems({\n plugins,\n items,\n where,\n fields: formDynamoDbFields\n });\n return sortItems({\n items: filteredItems,\n sort,\n fields: formDynamoDbFields\n });\n };\n\n const deleteForm = async (\n params: FormBuilderStorageOperationsDeleteFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n let items: any[];\n /**\n * This will find all form records.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormPartitionKey(form),\n options: {\n beginsWith: form.formId || undefined\n }\n };\n try {\n items = await queryAll<DbRecord>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query forms and submissions by given params.\",\n ex.code || \"QUERY_FORM_AND_SUBMISSIONS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n let latestPublishedKeys: Keys | undefined;\n const entityBatch = createEntityWriteBatch({\n entity,\n delete: [createLatestKeys(form)]\n });\n\n for (const item of items) {\n if (!latestPublishedKeys && item.published) {\n latestPublishedKeys = createLatestPublishedKeys(item);\n }\n entityBatch.delete({\n PK: item.PK,\n SK: item.SK\n });\n }\n\n if (latestPublishedKeys) {\n entityBatch.delete(latestPublishedKeys);\n }\n\n try {\n await entityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form and it's submissions.\",\n ex.code || \"DELETE_FORM_AND_SUBMISSIONS_ERROR\"\n );\n }\n return form;\n };\n /**\n * We need to:\n * - delete current revision\n * - get previously published revision and update the record if it exists or delete if it does not\n * - update latest record if current one is the latest\n */\n const deleteFormRevision = async (\n params: FormBuilderStorageOperationsDeleteFormRevisionParams\n ): Promise<FbForm> => {\n const { form, revisions, previous } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n\n const latestForm = revisions[0];\n const latestPublishedForm = revisions.find(rev => rev.published === true);\n\n const isLatest = latestForm ? latestForm.id === form.id : false;\n const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;\n\n const entityBatch = createEntityWriteBatch({\n entity,\n delete: [revisionKeys]\n });\n\n if (isLatest || isLatestPublished) {\n /**\n * Sort out the latest published record.\n */\n if (isLatestPublished) {\n const previouslyPublishedForm = revisions\n .filter(f => !!f.publishedOn && f.version !== form.version)\n .sort((a, b) => {\n return (\n new Date(b.publishedOn as string).getTime() -\n new Date(a.publishedOn as string).getTime()\n );\n })\n .shift();\n if (previouslyPublishedForm) {\n entityBatch.put({\n ...previouslyPublishedForm,\n ...createLatestPublishedKeys(previouslyPublishedForm),\n GSI1_PK: null,\n GSI1_SK: null,\n TYPE: createFormLatestPublishedType()\n });\n } else {\n entityBatch.delete(createLatestPublishedKeys(form));\n }\n }\n /**\n * Sort out the latest record.\n */\n if (isLatest) {\n entityBatch.put({\n ...previous,\n ...latestKeys,\n GSI1_PK: null,\n GSI1_SK: null,\n TYPE: createFormLatestType()\n });\n }\n }\n /**\n * Now save the batch data.\n */\n try {\n await entityBatch.execute();\n\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form revision from table.\",\n ex.code || \"DELETE_FORM_REVISION_ERROR\",\n {\n form,\n latestForm,\n revisionKeys,\n latestKeys\n }\n );\n }\n };\n\n /**\n * We need to save form in:\n * - regular form record\n * - latest published form record\n * - latest form record - if form is latest one\n * - elasticsearch latest form record\n */\n const publishForm = async (\n params: FormBuilderStorageOperationsPublishFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = createRevisionKeys(form);\n\n const latestKeys = createLatestKeys(form);\n\n const latestPublishedKeys = createLatestPublishedKeys(form);\n\n const gsiKeys = {\n GSI1_PK: createFormGSIPartitionKey(form),\n GSI1_SK: createGSISortKey(form.version)\n };\n\n const { locale, tenant, formId } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n\n const isLatestForm = latestForm ? latestForm.id === form.id : false;\n /**\n * Update revision and latest published records\n */\n const entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n },\n {\n ...form,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n }\n ]\n });\n\n /**\n * Update the latest form as well\n */\n if (isLatestForm) {\n entityBatch.put({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n });\n }\n\n try {\n await entityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not publish form.\",\n ex.code || \"PUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n return form;\n };\n\n /**\n * We need to:\n * - update form revision record\n * - if latest published (LP) is current form, find the previously published record and update LP if there is some previously published, delete otherwise\n * - if is latest update the Elasticsearch record\n */\n const unpublishForm = async (\n params: FormBuilderStorageOperationsUnpublishFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const latestPublishedKeys = createLatestPublishedKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const { formId, tenant, locale } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n\n const latestPublishedForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n published: true\n }\n });\n\n const isLatest = latestForm ? latestForm.id === form.id : false;\n const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;\n\n const entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n }\n ]\n });\n\n if (isLatest) {\n entityBatch.put({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n });\n }\n /**\n * In case previously published revision exists, replace current one with that one.\n * And if it does not, delete the record.\n */\n if (isLatestPublished) {\n const revisions = await listFormRevisions({\n where: {\n formId,\n tenant,\n locale,\n version_not: form.version,\n publishedOn_not: null\n },\n sort: [\"savedOn_DESC\"]\n });\n\n const previouslyPublishedRevision = revisions.shift();\n if (previouslyPublishedRevision) {\n entityBatch.put({\n ...previouslyPublishedRevision,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n });\n } else {\n entityBatch.delete(latestPublishedKeys);\n }\n }\n\n try {\n await entityBatch.execute();\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not unpublish form.\",\n ex.code || \"UNPUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n };\n\n return {\n createForm,\n createFormFrom,\n updateForm,\n listForms,\n listFormRevisions,\n getForm,\n deleteForm,\n deleteFormRevision,\n publishForm,\n unpublishForm,\n createFormPartitionKey\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAkBA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAOA,IAAAM,wBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,IAAA,GAAAR,OAAA;AA6BO,MAAMS,2BAA2B,GACpCC,MAAyC,IACN;EACnC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAElC,MAAMG,kBAAkB,GAAGD,OAAO,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zB,CAAC,CAAC;MAEF,MAAMuD,2BAA2B,GAAGpB,SAAS,CAACe,KAAK,CAAC,CAAC;MACrD,IAAIK,2BAA2B,EAAE;QAC7B/E,WAAW,CAACE,GAAG,CAAC;UACZ,GAAG6E,2BAA2B;UAC9B,GAAGxB,mBAAmB;UACtBpD,IAAI,EAAEjB,6BAA6B,CAAC;QACxC,CAAC,CAAC;MACN,CAAC,MAAM;QACHc,WAAW,CAACwD,MAAM,CAACD,mBAAmB,CAAC;MAC3C;IACJ;IAEA,IAAI;MACA,MAAMvD,WAAW,CAACI,OAAO,CAAC,CAAC;MAC3B,OAAOhB,IAAI;IACf,CAAC,CAAC,OAAOiB,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,2BAA2B,EACzCF,EAAE,CAACG,IAAI,IAAI,sBAAsB,EACjC;QACIpB,IAAI;QACJsB,QAAQ;QACRG,UAAU;QACVhB,YAAY;QACZC,UAAU;QACVyD;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACH3D,UAAU;IACVa,cAAc;IACdG,UAAU;IACVW,SAAS;IACT4B,iBAAiB;IACjBrC,OAAO;IACPuC,UAAU;IACVK,kBAAkB;IAClBiB,WAAW;IACXC,aAAa;IACb5G;EACJ,CAAC;AACL,CAAC;AAACgH,OAAA,CAAAxH,2BAAA,GAAAA,2BAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
- import { FormBuilderSettingsStorageOperations } from "../../types";
1
+ import type { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
+ import type { FormBuilderSettingsStorageOperations } from "../../types";
3
3
  export interface CreateSettingsStorageOperationsParams {
4
4
  entity: Entity<any>;
5
5
  table: Table<string, string, string>;
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_get","_dbDynamodb","createSettingsStorageOperations","params","entity","createSettingsPartitionKey","tenant","locale","createSettingsSortKey","createKeys","PK","SK","createSettings","settings","keys","put","item","ex","WebinyError","message","code","getSettings","getClean","updateSettings","original","deleteSettings","deleteItem","exports"],"sources":["index.ts"],"sourcesContent":["import {\n FormBuilderStorageOperationsCreateSettingsParams,\n FormBuilderStorageOperationsDeleteSettingsParams,\n FormBuilderStorageOperationsGetSettingsParams,\n FormBuilderStorageOperationsUpdateSettingsParams,\n Settings\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport {\n FormBuilderSettingsStorageOperations,\n FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { deleteItem, put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n table: Table<string, string, string>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): FormBuilderSettingsStorageOperations => {\n const { entity } = params;\n\n const createSettingsPartitionKey = ({\n tenant,\n locale\n }: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#FB#SETTINGS`;\n };\n\n const createSettingsSortKey = (): string => {\n return \"default\";\n };\n\n const createKeys = (params: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams) => {\n return {\n PK: createSettingsPartitionKey(params),\n SK: createSettingsSortKey()\n };\n };\n\n const createSettings = async (\n params: FormBuilderStorageOperationsCreateSettingsParams\n ): Promise<Settings> => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n try {\n await put({\n entity,\n item: {\n ...settings,\n ...keys\n }\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create the settings record by given keys.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n keys,\n settings\n }\n );\n }\n };\n\n const getSettings = async (\n params: FormBuilderStorageOperationsGetSettingsParams\n ): Promise<Settings | null> => {\n const keys = createKeys(params);\n\n try {\n return await getClean<Settings>({ entity, keys });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get the settings record by given keys.\",\n ex.code || \"LOAD_SETTINGS_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const updateSettings = async (\n params: FormBuilderStorageOperationsUpdateSettingsParams\n ): Promise<Settings> => {\n const { settings, original } = params;\n const keys = createKeys(settings);\n\n try {\n await put({\n entity,\n item: {\n ...settings,\n ...keys\n }\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update the settings record by given keys.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n keys,\n original,\n settings\n }\n );\n }\n };\n\n const deleteSettings = async (\n params: FormBuilderStorageOperationsDeleteSettingsParams\n ): Promise<void> => {\n const { settings } = params;\n const keys = createKeys(settings);\n try {\n await deleteItem({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the settings record by given keys.\",\n ex.code || \"DELETE_SETTINGS_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n return {\n createSettings,\n getSettings,\n updateSettings,\n deleteSettings,\n createSettingsPartitionKey,\n createSettingsSortKey\n };\n};\n"],"mappings":";;;;;;;AAYA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAOO,MAAMG,+BAA+B,GACxCC,MAA6C,IACN;EACvC,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EAEzB,MAAME,0BAA0B,GAAGA,CAAC;IAChCC,MAAM;IACNC;EAC0D,CAAC,KAAa;IACxE,OAAQ,KAAID,MAAO,MAAKC,MAAO,cAAa;EAChD,CAAC;EAED,MAAMC,qBAAqB,GAAGA,CAAA,KAAc;IACxC,OAAO,SAAS;EACpB,CAAC;EAED,MAAMC,UAAU,GAAIN,MAAoE,IAAK;IACzF,OAAO;MACHO,EAAE,EAAEL,0B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AC;MACF,OAAOD,QAAQ;IACnB,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,qDAAqD,EACnEF,EAAE,CAACG,IAAI,IAAI,uBAAuB,EAClC;QACIN,IAAI;QACJU,QAAQ;QACRX;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMY,cAAc,GAAG,MACnBtB,MAAwD,IACxC;IAChB,MAAM;MAAEU;IAAS,CAAC,GAAGV,MAAM;IAC3B,MAAMW,IAAI,GAAGL,UAAU,CAACI,QAAQ,CAAC;IACjC,IAAI;MACA,MAAM,IAAAa,sBAAU,EAAC;QACbtB,MAAM;QACNU;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,qDAAqD,EACnEF,EAAE,CAACG,IAAI,IAAI,uBAAuB,EAClC;QACIN;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHF,cAAc;IACdS,WAAW;IACXE,cAAc;IACdE,cAAc;IACdpB,0BAA0B;IAC1BG;EACJ,CAAC;AACL,CAAC;AAACmB,OAAA,CAAAzB,+BAAA,GAAAA,+BAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_get","_dbDynamodb","createSettingsStorageOperations","params","entity","createSettingsPartitionKey","tenant","locale","createSettingsSortKey","createKeys","PK","SK","createSettings","settings","keys","put","item","ex","WebinyError","message","code","getSettings","getClean","updateSettings","original","deleteSettings","deleteItem","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n FormBuilderStorageOperationsCreateSettingsParams,\n FormBuilderStorageOperationsDeleteSettingsParams,\n FormBuilderStorageOperationsGetSettingsParams,\n FormBuilderStorageOperationsUpdateSettingsParams,\n Settings\n} from \"@webiny/api-form-builder/types\";\nimport type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type {\n FormBuilderSettingsStorageOperations,\n FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { deleteItem, put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n table: Table<string, string, string>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): FormBuilderSettingsStorageOperations => {\n const { entity } = params;\n\n const createSettingsPartitionKey = ({\n tenant,\n locale\n }: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#FB#SETTINGS`;\n };\n\n const createSettingsSortKey = (): string => {\n return \"default\";\n };\n\n const createKeys = (params: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams) => {\n return {\n PK: createSettingsPartitionKey(params),\n SK: createSettingsSortKey()\n };\n };\n\n const createSettings = async (\n params: FormBuilderStorageOperationsCreateSettingsParams\n ): Promise<Settings> => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n try {\n await put({\n entity,\n item: {\n ...settings,\n ...keys\n }\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create the settings record by given keys.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n keys,\n settings\n }\n );\n }\n };\n\n const getSettings = async (\n params: FormBuilderStorageOperationsGetSettingsParams\n ): Promise<Settings | null> => {\n const keys = createKeys(params);\n\n try {\n return await getClean<Settings>({ entity, keys });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get the settings record by given keys.\",\n ex.code || \"LOAD_SETTINGS_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const updateSettings = async (\n params: FormBuilderStorageOperationsUpdateSettingsParams\n ): Promise<Settings> => {\n const { settings, original } = params;\n const keys = createKeys(settings);\n\n try {\n await put({\n entity,\n item: {\n ...settings,\n ...keys\n }\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update the settings record by given keys.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n keys,\n original,\n settings\n }\n );\n }\n };\n\n const deleteSettings = async (\n params: FormBuilderStorageOperationsDeleteSettingsParams\n ): Promise<void> => {\n const { settings } = params;\n const keys = createKeys(settings);\n try {\n await deleteItem({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the settings record by given keys.\",\n ex.code || \"DELETE_SETTINGS_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n return {\n createSettings,\n getSettings,\n updateSettings,\n deleteSettings,\n createSettingsPartitionKey,\n createSettingsSortKey\n };\n};\n"],"mappings":";;;;;;;AAYA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAOO,MAAMG,+BAA+B,GACxCC,MAA6C,IACN;EACvC,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EAEzB,MAAME,0BAA0B,GAAGA,CAAC;IAChCC,MAAM;IACNC;EAC0D,CAAC,KAAa;IACxE,OAAO,KAAKD,MAAM,MAAMC,MAAM,cAAc;EAChD,CAAC;EAED,MAAMC,qBAAqB,GAAGA,CAAA,KAAc;IACxC,OAAO,SAAS;EACpB,CAAC;EAED,MAAMC,UAAU,GAAIN,MAAoE,IAAK;IACzF,OAAO;MACHO,EAAE,EAAEL,0BAA0B,CAACF,MAAM,CAAC;MACtCQ,EAAE,EAAEH,qBAAqB,CAAC;IAC9B,CAAC;EACL,CAAC;EAED,MAAMI,cAAc,GAAG,MACnBT,MAAwD,IACpC;IACpB,MAAM;MAAEU;IAAS,CAAC,GAAGV,MAAM;IAC3B,MAAMW,IAAI,GAAGL,UAAU,CAACI,QAAQ,CAAC;IAEjC,IAAI;MACA,MAAM,IAAAE,eAAG,EAAC;QACNX,MAAM;QACNY,IAAI,EAAE;UACF,GAAGH,QAAQ;UACX,GAAGC;QACP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AAMW,IAAI,GAAGL,UAAU,CAACI,QAAQ,CAAC;IACjC,IAAI;MACA,MAAM,IAAAa,sBAAU,EAAC;QACbtB,MAAM;QACNU;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,qDAAqD,EACnEF,EAAE,CAACG,IAAI,IAAI,uBAAuB,EAClC;QACIN;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHF,cAAc;IACdS,WAAW;IACXE,cAAc;IACdE,cAAc;IACdpB,0BAA0B;IAC1BG;EACJ,CAAC;AACL,CAAC;AAACmB,OAAA,CAAAzB,+BAAA,GAAAA,+BAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_FormSubmissionDynamoDbFieldPlugin","require","_default","FormSubmissionDynamoDbFieldPlugin","field","type","exports","default"],"sources":["fields.ts"],"sourcesContent":["import { FormSubmissionDynamoDbFieldPlugin } from \"~/plugins/FormSubmissionDynamoDbFieldPlugin\";\n\nexport default () => [\n new FormSubmissionDynamoDbFieldPlugin({\n field: \"createdOn\",\n type: \"date\"\n }),\n new FormSubmissionDynamoDbFieldPlugin({\n field: \"savedOn\",\n type: \"date\"\n })\n];\n"],"mappings":";;;;;;AAAA,IAAAA,kCAAA,GAAAC,OAAA;AAAgG,IAAAC,QAAA,GAEjFA,CAAA,KAAM,CACjB,IAAIC,oEAAiC,CAAC;EAClCC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,oEAAiC,CAAC;EAClCC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC,CACL;AAAAC,OAAA,CAAAC,OAAA,GAAAL,QAAA"}
1
+ {"version":3,"names":["_FormSubmissionDynamoDbFieldPlugin","require","_default","FormSubmissionDynamoDbFieldPlugin","field","type","exports","default"],"sources":["fields.ts"],"sourcesContent":["import { FormSubmissionDynamoDbFieldPlugin } from \"~/plugins/FormSubmissionDynamoDbFieldPlugin\";\n\nexport default () => [\n new FormSubmissionDynamoDbFieldPlugin({\n field: \"createdOn\",\n type: \"date\"\n }),\n new FormSubmissionDynamoDbFieldPlugin({\n field: \"savedOn\",\n type: \"date\"\n })\n];\n"],"mappings":";;;;;;AAAA,IAAAA,kCAAA,GAAAC,OAAA;AAAgG,IAAAC,QAAA,GAEjFA,CAAA,KAAM,CACjB,IAAIC,oEAAiC,CAAC;EAClCC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC,CAAC,EACF,IAAIF,oEAAiC,CAAC;EAClCC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC,CACL;AAAAC,OAAA,CAAAC,OAAA,GAAAL,QAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- import { FormBuilderSubmissionStorageOperations } from "../../types";
1
+ import type { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
+ import type { PluginsContainer } from "@webiny/plugins";
3
+ import type { FormBuilderSubmissionStorageOperations } from "../../types";
4
4
  export interface CreateSubmissionStorageOperationsParams {
5
5
  entity: Entity<any>;
6
6
  table: Table<string, string, string>;
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_utils","_query","_cursor","_sort","_filter","_FormSubmissionDynamoDbFieldPlugin","_get","_dbDynamodb","createSubmissionStorageOperations","params","entity","plugins","createSubmissionPartitionKey","tenant","locale","formId","id","parseIdentifier","createSubmissionSortKey","createSubmissionType","createSubmission","submission","form","keys","PK","SK","put","item","TYPE","ex","WebinyError","message","code","updateSubmission","original","deleteSubmission","deleteItem","listSubmissions","where","initialWhere","sort","limit","after","queryAllParams","partitionKey","options","gte","reverse","results","queryAll","fields","byType","FormSubmissionDynamoDbFieldPlugin","type","filteredSubmissions","filterItems","items","sortedSubmissions","sortItems","totalCount","length","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slice","cursor","encodeCursor","meta","getSubmission","getClean","exports"],"sources":["index.ts"],"sourcesContent":["import {\n FbSubmission,\n FormBuilderStorageOperationsCreateSubmissionParams,\n FormBuilderStorageOperationsDeleteSubmissionParams,\n FormBuilderStorageOperationsGetSubmissionParams,\n FormBuilderStorageOperationsListSubmissionsParams,\n FormBuilderStorageOperationsListSubmissionsResponse,\n FormBuilderStorageOperationsUpdateSubmissionParams\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n FormBuilderSubmissionStorageOperations,\n FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { decodeCursor, encodeCursor } from \"@webiny/db-dynamodb/utils/cursor\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { FormSubmissionDynamoDbFieldPlugin } from \"~/plugins/FormSubmissionDynamoDbFieldPlugin\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { deleteItem, put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSubmissionStorageOperationsParams {\n entity: Entity<any>;\n table: Table<string, string, string>;\n plugins: PluginsContainer;\n}\n\nexport const createSubmissionStorageOperations = (\n params: CreateSubmissionStorageOperationsParams\n): FormBuilderSubmissionStorageOperations => {\n const { entity, plugins } = params;\n\n const createSubmissionPartitionKey = (\n params: FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n ) => {\n const { tenant, locale, formId } = params;\n\n const { id } = parseIdentifier(formId);\n\n return `T#${tenant}#L#${locale}#FB#FS#${id}`;\n };\n const createSubmissionSortKey = (id: string) => {\n return id;\n };\n\n const createSubmissionType = () => {\n return \"fb.formSubmission\";\n };\n\n const createSubmission = async (\n params: FormBuilderStorageOperationsCreateSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form } = params;\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await put({\n entity,\n item: {\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\n }\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form submission in the DynamoDB.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n\n const updateSubmission = async (\n params: FormBuilderStorageOperationsUpdateSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form, original } = params;\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await put({\n entity,\n item: {\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\n }\n });\n return submission;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form submission in the DynamoDB.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n original,\n form,\n keys\n }\n );\n }\n };\n\n const deleteSubmission = async (\n params: FormBuilderStorageOperationsDeleteSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form } = params;\n\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await deleteItem({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form submission from DynamoDB.\",\n ex.code || \"DELETE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n\n const listSubmissions = async (\n params: FormBuilderStorageOperationsListSubmissionsParams\n ): Promise<FormBuilderStorageOperationsListSubmissionsResponse> => {\n const { where: initialWhere, sort, limit = 100000, after } = params;\n\n const { tenant, locale, formId } = initialWhere;\n\n const where: Partial<FormBuilderStorageOperationsListSubmissionsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.tenant;\n delete where.locale;\n delete where.formId;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createSubmissionPartitionKey({\n tenant,\n locale,\n formId\n }),\n options: {\n gte: \" \",\n reverse: true\n }\n };\n\n let results;\n try {\n results = await queryAll<FbSubmission>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list form submissions.\",\n ex.code || \"LIST_SUBMISSIONS_ERROR\",\n {\n where: initialWhere,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n\n const fields = plugins.byType<FormSubmissionDynamoDbFieldPlugin>(\n FormSubmissionDynamoDbFieldPlugin.type\n );\n\n const filteredSubmissions = filterItems({\n plugins,\n items: results,\n where,\n fields\n });\n\n const sortedSubmissions = sortItems({\n items: filteredSubmissions,\n sort,\n fields\n });\n\n const totalCount = sortedSubmissions.length;\n const start = parseInt(decodeCursor(after) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const items = sortedSubmissions.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = items.length > 0 ? encodeCursor(start + limit) : null;\n\n const meta = {\n hasMoreItems,\n totalCount,\n cursor\n };\n\n return {\n items,\n meta\n };\n };\n\n const getSubmission = async (\n params: FormBuilderStorageOperationsGetSubmissionParams\n ): Promise<FbSubmission | null> => {\n const { where } = params;\n\n const keys = {\n PK: createSubmissionPartitionKey(where),\n SK: createSubmissionSortKey(where.id)\n };\n\n try {\n return await getClean<FbSubmission>({ entity, keys });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not oad submission.\",\n ex.code || \"GET_SUBMISSION_ERROR\",\n {\n where,\n keys\n }\n );\n }\n };\n\n return {\n createSubmission,\n deleteSubmission,\n updateSubmission,\n list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M,IAAAwD,aAAQ,EAAe;QAAE9D,MAAM;QAAEa;MAAK,CAAC,CAAC;IACzD,CAAC,CAAC,OAAOM,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,2BAA2B,EACzCF,EAAE,CAACG,IAAI,IAAI,sBAAsB,EACjC;QACIM,KAAK;QACLf;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHH,gBAAgB;IAChBe,gBAAgB;IAChBF,gBAAgB;IAChBI,eAAe;IACfkC,aAAa;IACb3D,4BAA4B;IAC5BM;EACJ,CAAC;AACL,CAAC;AAACuD,OAAA,CAAAjE,iCAAA,GAAAA,iCAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_utils","_query","_cursor","_sort","_filter","_FormSubmissionDynamoDbFieldPlugin","_get","_dbDynamodb","createSubmissionStorageOperations","params","entity","plugins","createSubmissionPartitionKey","tenant","locale","formId","id","parseIdentifier","createSubmissionSortKey","createSubmissionType","createSubmission","submission","form","keys","PK","SK","put","item","TYPE","ex","WebinyError","message","code","updateSubmission","original","deleteSubmission","deleteItem","listSubmissions","where","initialWhere","sort","limit","after","queryAllParams","partitionKey","options","gte","reverse","results","queryAll","fields","byType","FormSubmissionDynamoDbFieldPlugin","type","filteredSubmissions","filterItems","items","sortedSubmissions","sortItems","totalCount","length","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slice","cursor","encodeCursor","meta","getSubmission","getClean","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n FbSubmission,\n FormBuilderStorageOperationsCreateSubmissionParams,\n FormBuilderStorageOperationsDeleteSubmissionParams,\n FormBuilderStorageOperationsGetSubmissionParams,\n FormBuilderStorageOperationsListSubmissionsParams,\n FormBuilderStorageOperationsListSubmissionsResponse,\n FormBuilderStorageOperationsUpdateSubmissionParams\n} from \"@webiny/api-form-builder/types\";\nimport type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n FormBuilderSubmissionStorageOperations,\n FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { decodeCursor, encodeCursor } from \"@webiny/db-dynamodb/utils/cursor\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { FormSubmissionDynamoDbFieldPlugin } from \"~/plugins/FormSubmissionDynamoDbFieldPlugin\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { deleteItem, put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSubmissionStorageOperationsParams {\n entity: Entity<any>;\n table: Table<string, string, string>;\n plugins: PluginsContainer;\n}\n\nexport const createSubmissionStorageOperations = (\n params: CreateSubmissionStorageOperationsParams\n): FormBuilderSubmissionStorageOperations => {\n const { entity, plugins } = params;\n\n const createSubmissionPartitionKey = (\n params: FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n ) => {\n const { tenant, locale, formId } = params;\n\n const { id } = parseIdentifier(formId);\n\n return `T#${tenant}#L#${locale}#FB#FS#${id}`;\n };\n const createSubmissionSortKey = (id: string) => {\n return id;\n };\n\n const createSubmissionType = () => {\n return \"fb.formSubmission\";\n };\n\n const createSubmission = async (\n params: FormBuilderStorageOperationsCreateSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form } = params;\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await put({\n entity,\n item: {\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\n }\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form submission in the DynamoDB.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n\n const updateSubmission = async (\n params: FormBuilderStorageOperationsUpdateSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form, original } = params;\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await put({\n entity,\n item: {\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\n }\n });\n return submission;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form submission in the DynamoDB.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n original,\n form,\n keys\n }\n );\n }\n };\n\n const deleteSubmission = async (\n params: FormBuilderStorageOperationsDeleteSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form } = params;\n\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await deleteItem({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form submission from DynamoDB.\",\n ex.code || \"DELETE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n\n const listSubmissions = async (\n params: FormBuilderStorageOperationsListSubmissionsParams\n ): Promise<FormBuilderStorageOperationsListSubmissionsResponse> => {\n const { where: initialWhere, sort, limit = 100000, after } = params;\n\n const { tenant, locale, formId } = initialWhere;\n\n const where: Partial<FormBuilderStorageOperationsListSubmissionsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.tenant;\n delete where.locale;\n delete where.formId;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createSubmissionPartitionKey({\n tenant,\n locale,\n formId\n }),\n options: {\n gte: \" \",\n reverse: true\n }\n };\n\n let results;\n try {\n results = await queryAll<FbSubmission>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list form submissions.\",\n ex.code || \"LIST_SUBMISSIONS_ERROR\",\n {\n where: initialWhere,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n\n const fields = plugins.byType<FormSubmissionDynamoDbFieldPlugin>(\n FormSubmissionDynamoDbFieldPlugin.type\n );\n\n const filteredSubmissions = filterItems({\n plugins,\n items: results,\n where,\n fields\n });\n\n const sortedSubmissions = sortItems({\n items: filteredSubmissions,\n sort,\n fields\n });\n\n const totalCount = sortedSubmissions.length;\n const start = parseInt(decodeCursor(after) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const items = sortedSubmissions.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = items.length > 0 ? encodeCursor(start + limit) : null;\n\n const meta = {\n hasMoreItems,\n totalCount,\n cursor\n };\n\n return {\n items,\n meta\n };\n };\n\n const getSubmission = async (\n params: FormBuilderStorageOperationsGetSubmissionParams\n ): Promise<FbSubmission | null> => {\n const { where } = params;\n\n const keys = {\n PK: createSubmissionPartitionKey(where),\n SK: createSubmissionSortKey(where.id)\n };\n\n try {\n return await getClean<FbSubmission>({ entity, keys });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not oad submission.\",\n ex.code || \"GET_SUBMISSION_ERROR\",\n {\n where,\n keys\n }\n );\n }\n };\n\n return {\n createSubmission,\n deleteSubmission,\n updateSubmission,\n listSubmissions,\n getSubmission,\n createSubmissionPartitionKey,\n createSubmissionSortKey\n };\n};\n"],"mappings":";;;;;;;AAUA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,kCAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,WA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;IAC5BM;EACJ,CAAC;AACL,CAAC;AAACuD,OAAA,CAAAjE,iCAAA,GAAAA,iCAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
- import { FormBuilderSystemStorageOperations } from "../../types";
1
+ import type { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
+ import type { FormBuilderSystemStorageOperations } from "../../types";
3
3
  export interface CreateSystemStorageOperationsParams {
4
4
  entity: Entity<any>;
5
5
  table: Table<string, string, string>;
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_get","_dbDynamodb","createSystemStorageOperations","params","entity","createSystemPartitionKey","tenant","createSystemSortKey","createKeys","PK","SK","createSystem","system","keys","put","item","ex","WebinyError","message","code","getSystem","getClean","updateSystem","original","exports"],"sources":["index.ts"],"sourcesContent":["import {\n FormBuilderStorageOperationsCreateSystemParams,\n FormBuilderStorageOperationsGetSystemParams,\n FormBuilderStorageOperationsUpdateSystemParams,\n System\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { FormBuilderSystemCreateKeysParams, FormBuilderSystemStorageOperations } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n table: Table<string, string, string>;\n}\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): FormBuilderSystemStorageOperations => {\n const { entity } = params;\n\n const createSystemPartitionKey = ({ tenant }: FormBuilderSystemCreateKeysParams): string => {\n return `T#${tenant}#SYSTEM`;\n };\n\n const createSystemSortKey = (): string => {\n return \"FB\";\n };\n\n const createKeys = (params: FormBuilderSystemCreateKeysParams) => {\n return {\n PK: createSystemPartitionKey(params),\n SK: createSystemSortKey()\n };\n };\n\n const createSystem = async (\n params: FormBuilderStorageOperationsCreateSystemParams\n ): Promise<System> => {\n const { system } = params;\n const keys = createKeys(system);\n\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create the system record by given keys.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n keys,\n system\n }\n );\n }\n };\n\n const getSystem = async (\n params: FormBuilderStorageOperationsGetSystemParams\n ): Promise<System | null> => {\n const keys = createKeys(params);\n\n try {\n return await getClean<System>({ entity, keys });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get the system record by given keys.\",\n ex.code || \"LOAD_SYSTEM_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const updateSystem = async (\n params: FormBuilderStorageOperationsUpdateSystemParams\n ): Promise<System> => {\n const { system, original } = params;\n const keys = createKeys(system);\n\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update the system record by given keys.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n keys,\n original,\n system\n }\n );\n }\n };\n\n return {\n createSystem,\n getSystem,\n updateSystem,\n createSystemPartitionKey,\n createSystemSortKey\n };\n};\n"],"mappings":";;;;;;;AAQA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAOO,MAAMG,6BAA6B,GACtCC,MAA2C,IACN;EACrC,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EAEzB,MAAME,wBAAwB,GAAGA,CAAC;IAAEC;EAA0C,CAAC,KAAa;IACxF,OAAQ,KAAIA,MAAO,SAAQ;EAC/B,CAAC;EAED,MAAMC,mBAAmB,GAAGA,CAAA,KAAc;IACtC,OAAO,IAAI;EACf,CAAC;EAED,MAAMC,UAAU,GAAIL,MAAyC,IAAK;IAC9D,OAAO;MACHM,EAAE,EAAEJ,wBAAwB,C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M;IACjB,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,mDAAmD,EACjEF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIN,IAAI;QACJU,QAAQ;QACRX;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHD,YAAY;IACZS,SAAS;IACTE,YAAY;IACZjB,wBAAwB;IACxBE;EACJ,CAAC;AACL,CAAC;AAACiB,OAAA,CAAAtB,6BAAA,GAAAA,6BAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_get","_dbDynamodb","createSystemStorageOperations","params","entity","createSystemPartitionKey","tenant","createSystemSortKey","createKeys","PK","SK","createSystem","system","keys","put","item","ex","WebinyError","message","code","getSystem","getClean","updateSystem","original","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n FormBuilderStorageOperationsCreateSystemParams,\n FormBuilderStorageOperationsGetSystemParams,\n FormBuilderStorageOperationsUpdateSystemParams,\n System\n} from \"@webiny/api-form-builder/types\";\nimport type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type {\n FormBuilderSystemCreateKeysParams,\n FormBuilderSystemStorageOperations\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n table: Table<string, string, string>;\n}\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): FormBuilderSystemStorageOperations => {\n const { entity } = params;\n\n const createSystemPartitionKey = ({ tenant }: FormBuilderSystemCreateKeysParams): string => {\n return `T#${tenant}#SYSTEM`;\n };\n\n const createSystemSortKey = (): string => {\n return \"FB\";\n };\n\n const createKeys = (params: FormBuilderSystemCreateKeysParams) => {\n return {\n PK: createSystemPartitionKey(params),\n SK: createSystemSortKey()\n };\n };\n\n const createSystem = async (\n params: FormBuilderStorageOperationsCreateSystemParams\n ): Promise<System> => {\n const { system } = params;\n const keys = createKeys(system);\n\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create the system record by given keys.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n keys,\n system\n }\n );\n }\n };\n\n const getSystem = async (\n params: FormBuilderStorageOperationsGetSystemParams\n ): Promise<System | null> => {\n const keys = createKeys(params);\n\n try {\n return await getClean<System>({ entity, keys });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get the system record by given keys.\",\n ex.code || \"LOAD_SYSTEM_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const updateSystem = async (\n params: FormBuilderStorageOperationsUpdateSystemParams\n ): Promise<System> => {\n const { system, original } = params;\n const keys = createKeys(system);\n\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update the system record by given keys.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n keys,\n original,\n system\n }\n );\n }\n };\n\n return {\n createSystem,\n getSystem,\n updateSystem,\n createSystemPartitionKey,\n createSystemSortKey\n };\n};\n"],"mappings":";;;;;;;AAWA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAOO,MAAMG,6BAA6B,GACtCC,MAA2C,IACN;EACrC,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EAEzB,MAAME,wBAAwB,GAAGA,CAAC;IAAEC;EAA0C,CAAC,KAAa;IACxF,OAAO,KAAKA,MAAM,SAAS;EAC/B,CAAC;EAED,MAAMC,mBAAmB,GAAGA,CAAA,KAAc;IACtC,OAAO,IAAI;EACf,CAAC;EAED,MAAMC,UAAU,GAAIL,MAAyC,IAAK;IAC9D,OAAO;MACHM,EAAE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AC;MACF,OAAOD,MAAM;IACjB,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,mDAAmD,EACjEF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIN,IAAI;QACJU,QAAQ;QACRX;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHD,YAAY;IACZS,SAAS;IACTE,YAAY;IACZjB,wBAAwB;IACxBE;EACJ,CAAC;AACL,CAAC;AAACiB,OAAA,CAAAtB,6BAAA,GAAAA,6BAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-form-builder-so-ddb",
3
- "version": "0.0.0-unstable.de38392959",
3
+ "version": "0.0.0-unstable.e0bfc55d5a",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-form-builder",
@@ -21,36 +21,30 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@babel/runtime": "7.22.6",
25
- "@webiny/api-form-builder": "0.0.0-unstable.de38392959",
26
- "@webiny/aws-sdk": "0.0.0-unstable.de38392959",
27
- "@webiny/db-dynamodb": "0.0.0-unstable.de38392959",
28
- "@webiny/error": "0.0.0-unstable.de38392959",
29
- "@webiny/plugins": "0.0.0-unstable.de38392959",
30
- "@webiny/utils": "0.0.0-unstable.de38392959"
24
+ "@webiny/api": "0.0.0-unstable.e0bfc55d5a",
25
+ "@webiny/api-form-builder": "0.0.0-unstable.e0bfc55d5a",
26
+ "@webiny/aws-sdk": "0.0.0-unstable.e0bfc55d5a",
27
+ "@webiny/db-dynamodb": "0.0.0-unstable.e0bfc55d5a",
28
+ "@webiny/error": "0.0.0-unstable.e0bfc55d5a",
29
+ "@webiny/plugins": "0.0.0-unstable.e0bfc55d5a",
30
+ "@webiny/utils": "0.0.0-unstable.e0bfc55d5a"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/cli": "7.22.6",
34
- "@babel/core": "7.22.8",
35
- "@babel/preset-env": "7.22.7",
36
- "@babel/preset-typescript": "7.22.5",
37
- "@webiny/cli": "0.0.0-unstable.de38392959",
38
- "@webiny/handler-db": "0.0.0-unstable.de38392959",
39
- "@webiny/project-utils": "0.0.0-unstable.de38392959",
33
+ "@webiny/handler-db": "0.0.0-unstable.e0bfc55d5a",
34
+ "@webiny/project-utils": "0.0.0-unstable.e0bfc55d5a",
40
35
  "csvtojson": "2.0.10",
41
- "jest": "29.5.0",
36
+ "jest": "29.7.0",
42
37
  "jest-dynalite": "3.6.1",
43
- "rimraf": "3.0.2",
44
- "ttypescript": "1.5.15",
45
- "typescript": "4.7.4"
38
+ "rimraf": "6.0.1",
39
+ "typescript": "5.3.3"
46
40
  },
47
41
  "publishConfig": {
48
42
  "access": "public",
49
43
  "directory": "dist"
50
44
  },
51
45
  "scripts": {
52
- "build": "yarn webiny run build",
53
- "watch": "yarn webiny run watch"
46
+ "build": "node ../cli/bin.js run build",
47
+ "watch": "node ../cli/bin.js run watch"
54
48
  },
55
- "gitHead": "de38392959f2692d1feb08945a3588cd80e4924c"
49
+ "gitHead": "e0bfc55d5a4d6a42b32e6558d9fb2eb6753e331b"
56
50
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_FieldPlugin","require","FormDynamoDbFieldPlugin","FieldPlugin","type","exports"],"sources":["FormDynamoDbFieldPlugin.ts"],"sourcesContent":["import { FieldPlugin } from \"@webiny/db-dynamodb/plugins/definitions/FieldPlugin\";\n\nexport class FormDynamoDbFieldPlugin extends FieldPlugin {\n public static override readonly type: string = \"formBuilder.dynamodb.field.form\";\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,uBAAuB,SAASC,wBAAW,CAAC;EACrD,OAAgCC,IAAI,GAAW,iCAAiC;AACpF;AAACC,OAAA,CAAAH,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_FieldPlugin","require","FormDynamoDbFieldPlugin","FieldPlugin","type","exports"],"sources":["FormDynamoDbFieldPlugin.ts"],"sourcesContent":["import { FieldPlugin } from \"@webiny/db-dynamodb/plugins/definitions/FieldPlugin\";\n\nexport class FormDynamoDbFieldPlugin extends FieldPlugin {\n public static override readonly type: string = \"formBuilder.dynamodb.field.form\";\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,uBAAuB,SAASC,wBAAW,CAAC;EACrD,OAAgCC,IAAI,GAAW,iCAAiC;AACpF;AAACC,OAAA,CAAAH,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_FieldPlugin","require","FormSubmissionDynamoDbFieldPlugin","FieldPlugin","type","exports"],"sources":["FormSubmissionDynamoDbFieldPlugin.ts"],"sourcesContent":["import { FieldPlugin } from \"@webiny/db-dynamodb/plugins/definitions/FieldPlugin\";\n\nexport class FormSubmissionDynamoDbFieldPlugin extends FieldPlugin {\n public static override readonly type: string = \"formBuilder.dynamodb.field.formSubmission\";\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,iCAAiC,SAASC,wBAAW,CAAC;EAC/D,OAAgCC,IAAI,GAAW,2CAA2C;AAC9F;AAACC,OAAA,CAAAH,iCAAA,GAAAA,iCAAA"}
1
+ {"version":3,"names":["_FieldPlugin","require","FormSubmissionDynamoDbFieldPlugin","FieldPlugin","type","exports"],"sources":["FormSubmissionDynamoDbFieldPlugin.ts"],"sourcesContent":["import { FieldPlugin } from \"@webiny/db-dynamodb/plugins/definitions/FieldPlugin\";\n\nexport class FormSubmissionDynamoDbFieldPlugin extends FieldPlugin {\n public static override readonly type: string = \"formBuilder.dynamodb.field.formSubmission\";\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,iCAAiC,SAASC,wBAAW,CAAC;EAC/D,OAAgCC,IAAI,GAAW,2CAA2C;AAC9F;AAACC,OAAA,CAAAH,iCAAA,GAAAA,iCAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_FormDynamoDbFieldPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_FormSubmissionDynamoDbFieldPlugin"],"sources":["index.ts"],"sourcesContent":["export * from \"./FormDynamoDbFieldPlugin\";\nexport * from \"./FormSubmissionDynamoDbFieldPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,wBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,wBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,wBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,kCAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,kCAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,kCAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,kCAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_FormDynamoDbFieldPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_FormSubmissionDynamoDbFieldPlugin"],"sources":["index.ts"],"sourcesContent":["export * from \"./FormDynamoDbFieldPlugin\";\nexport * from \"./FormSubmissionDynamoDbFieldPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,wBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,wBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,wBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,kCAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,kCAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,kCAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,kCAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { FormBuilderStorageOperations as BaseFormBuilderStorageOperations, FormBuilderSystemStorageOperations as BaseFormBuilderSystemStorageOperations, FormBuilderSubmissionStorageOperations as BaseFormBuilderSubmissionStorageOperations, FormBuilderSettingsStorageOperations as BaseFormBuilderSettingsStorageOperations, FormBuilderFormStorageOperations as BaseFormBuilderFormStorageOperations } from "@webiny/api-form-builder/types";
2
- import { DynamoDBClient } from "@webiny/aws-sdk/client-dynamodb";
3
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
4
- import { AttributeDefinition } from "@webiny/db-dynamodb/toolbox";
5
- import { Plugin } from "@webiny/plugins";
6
- export declare type Attributes = Record<string, AttributeDefinition>;
1
+ import type { FormBuilderStorageOperations as BaseFormBuilderStorageOperations, FormBuilderSystemStorageOperations as BaseFormBuilderSystemStorageOperations, FormBuilderSubmissionStorageOperations as BaseFormBuilderSubmissionStorageOperations, FormBuilderSettingsStorageOperations as BaseFormBuilderSettingsStorageOperations, FormBuilderFormStorageOperations as BaseFormBuilderFormStorageOperations } from "@webiny/api-form-builder/types";
2
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
3
+ import type { Entity, Table } from "@webiny/db-dynamodb/toolbox";
4
+ import type { AttributeDefinition } from "@webiny/db-dynamodb/toolbox";
5
+ import type { Plugin } from "@webiny/plugins";
6
+ export type Attributes = Record<string, AttributeDefinition>;
7
7
  export declare enum ENTITIES {
8
8
  FORM = "FormBuilderForm",
9
9
  SUBMISSION = "FormBuilderSubmission",
@@ -11,7 +11,7 @@ export declare enum ENTITIES {
11
11
  SETTINGS = "FormBuilderSettings"
12
12
  }
13
13
  export interface FormBuilderStorageOperationsFactoryParams {
14
- documentClient: DynamoDBClient;
14
+ documentClient: DynamoDBDocument;
15
15
  table?: string;
16
16
  attributes?: Record<ENTITIES, Attributes>;
17
17
  plugins?: Plugin;
@@ -53,7 +53,7 @@ export interface FormBuilderSettingsStorageOperations extends BaseFormBuilderSet
53
53
  createSettingsPartitionKey: (params: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams) => string;
54
54
  createSettingsSortKey: () => string;
55
55
  }
56
- export declare type Entities = "form" | "submission" | "system" | "settings";
56
+ export type Entities = "form" | "submission" | "system" | "settings";
57
57
  export interface FormBuilderStorageOperations extends BaseFormBuilderStorageOperations, FormBuilderSettingsStorageOperations, FormBuilderSubmissionStorageOperations, FormBuilderFormStorageOperations, FormBuilderSystemStorageOperations {
58
58
  getTable(): Table<string, string, string>;
59
59
  getEntities(): Record<Entities, Entity<any>>;
package/types.js CHANGED
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ENTITIES = void 0;
7
- let ENTITIES = /*#__PURE__*/function (ENTITIES) {
7
+ let ENTITIES = exports.ENTITIES = /*#__PURE__*/function (ENTITIES) {
8
8
  ENTITIES["FORM"] = "FormBuilderForm";
9
9
  ENTITIES["SUBMISSION"] = "FormBuilderSubmission";
10
10
  ENTITIES["SYSTEM"] = "FormBuilderSystem";
11
11
  ENTITIES["SETTINGS"] = "FormBuilderSettings";
12
12
  return ENTITIES;
13
13
  }({});
14
- exports.ENTITIES = ENTITIES;
15
14
 
16
15
  //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ENTITIES","exports"],"sources":["types.ts"],"sourcesContent":["import {\n FormBuilderStorageOperations as BaseFormBuilderStorageOperations,\n FormBuilderSystemStorageOperations as BaseFormBuilderSystemStorageOperations,\n FormBuilderSubmissionStorageOperations as BaseFormBuilderSubmissionStorageOperations,\n FormBuilderSettingsStorageOperations as BaseFormBuilderSettingsStorageOperations,\n FormBuilderFormStorageOperations as BaseFormBuilderFormStorageOperations\n} from \"@webiny/api-form-builder/types\";\nimport { DynamoDBClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { AttributeDefinition } from \"@webiny/db-dynamodb/toolbox\";\nimport { Plugin } from \"@webiny/plugins\";\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n FORM = \"FormBuilderForm\",\n SUBMISSION = \"FormBuilderSubmission\",\n SYSTEM = \"FormBuilderSystem\",\n SETTINGS = \"FormBuilderSettings\"\n}\n\nexport interface FormBuilderStorageOperationsFactoryParams {\n documentClient: DynamoDBClient;\n table?: string;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: Plugin;\n}\n\nexport interface FormBuilderSystemCreateKeysParams {\n tenant: string;\n}\n\nexport interface FormBuilderSystemStorageOperations extends BaseFormBuilderSystemStorageOperations {\n createSystemPartitionKey: (params: FormBuilderSystemCreateKeysParams) => string;\n createSystemSortKey: () => string;\n}\n\nexport interface FormBuilderFormCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderFormCreateGSIPartitionKeyParams {\n id?: string;\n formId?: string;\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderFormStorageOperations extends BaseFormBuilderFormStorageOperations {\n createFormPartitionKey: (params: FormBuilderFormCreatePartitionKeyParams) => string;\n}\n\nexport interface FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n formId: string;\n}\n\nexport interface FormBuilderSubmissionStorageOperations\n extends BaseFormBuilderSubmissionStorageOperations {\n createSubmissionPartitionKey: (\n params: FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSubmissionSortKey: (id: string) => string;\n}\n\nexport interface FormBuilderSettingsStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderSettingsStorageOperations\n extends BaseFormBuilderSettingsStorageOperations {\n createSettingsPartitionKey: (\n params: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSettingsSortKey: () => string;\n}\n\nexport type Entities = \"form\" | \"submission\" | \"system\" | \"settings\";\n\nexport interface FormBuilderStorageOperations\n extends BaseFormBuilderStorageOperations,\n FormBuilderSettingsStorageOperations,\n FormBuilderSubmissionStorageOperations,\n FormBuilderFormStorageOperations,\n FormBuilderSystemStorageOperations {\n getTable(): Table<string, string, string>;\n getEntities(): Record<Entities, Entity<any>>;\n}\n\nexport interface FormBuilderStorageOperationsFactory {\n (params: FormBuilderStorageOperationsFactoryParams): FormBuilderStorageOperations;\n}\n"],"mappings":";;;;;;IAcYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAAAC,OAAA,CAAAD,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"names":["ENTITIES","exports"],"sources":["types.ts"],"sourcesContent":["import type {\n FormBuilderStorageOperations as BaseFormBuilderStorageOperations,\n FormBuilderSystemStorageOperations as BaseFormBuilderSystemStorageOperations,\n FormBuilderSubmissionStorageOperations as BaseFormBuilderSubmissionStorageOperations,\n FormBuilderSettingsStorageOperations as BaseFormBuilderSettingsStorageOperations,\n FormBuilderFormStorageOperations as BaseFormBuilderFormStorageOperations\n} from \"@webiny/api-form-builder/types\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type { AttributeDefinition } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Plugin } from \"@webiny/plugins\";\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n FORM = \"FormBuilderForm\",\n SUBMISSION = \"FormBuilderSubmission\",\n SYSTEM = \"FormBuilderSystem\",\n SETTINGS = \"FormBuilderSettings\"\n}\n\nexport interface FormBuilderStorageOperationsFactoryParams {\n documentClient: DynamoDBDocument;\n table?: string;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: Plugin;\n}\n\nexport interface FormBuilderSystemCreateKeysParams {\n tenant: string;\n}\n\nexport interface FormBuilderSystemStorageOperations extends BaseFormBuilderSystemStorageOperations {\n createSystemPartitionKey: (params: FormBuilderSystemCreateKeysParams) => string;\n createSystemSortKey: () => string;\n}\n\nexport interface FormBuilderFormCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderFormCreateGSIPartitionKeyParams {\n id?: string;\n formId?: string;\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderFormStorageOperations extends BaseFormBuilderFormStorageOperations {\n createFormPartitionKey: (params: FormBuilderFormCreatePartitionKeyParams) => string;\n}\n\nexport interface FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n formId: string;\n}\n\nexport interface FormBuilderSubmissionStorageOperations\n extends BaseFormBuilderSubmissionStorageOperations {\n createSubmissionPartitionKey: (\n params: FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSubmissionSortKey: (id: string) => string;\n}\n\nexport interface FormBuilderSettingsStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderSettingsStorageOperations\n extends BaseFormBuilderSettingsStorageOperations {\n createSettingsPartitionKey: (\n params: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSettingsSortKey: () => string;\n}\n\nexport type Entities = \"form\" | \"submission\" | \"system\" | \"settings\";\n\nexport interface FormBuilderStorageOperations\n extends BaseFormBuilderStorageOperations,\n FormBuilderSettingsStorageOperations,\n FormBuilderSubmissionStorageOperations,\n FormBuilderFormStorageOperations,\n FormBuilderSystemStorageOperations {\n getTable(): Table<string, string, string>;\n getEntities(): Record<Entities, Entity<any>>;\n}\n\nexport interface FormBuilderStorageOperationsFactory {\n (params: FormBuilderStorageOperationsFactoryParams): FormBuilderStorageOperations;\n}\n"],"mappings":";;;;;;IAcYA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}