@webiny/api-form-builder-so-ddb 5.36.2 → 5.37.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/definitions/form.js.map +1 -1
- package/definitions/settings.js.map +1 -1
- package/definitions/submission.js.map +1 -1
- package/definitions/system.js.map +1 -1
- package/definitions/table.js.map +1 -1
- package/index.js.map +1 -1
- package/operations/form/fields.js.map +1 -1
- package/operations/form/index.js.map +1 -1
- package/operations/settings/index.js +1 -1
- package/operations/settings/index.js.map +1 -1
- package/operations/submission/fields.js.map +1 -1
- package/operations/submission/index.js.map +1 -1
- package/operations/system/index.js.map +1 -1
- package/package.json +17 -17
- package/plugins/FormDynamoDbFieldPlugin.js.map +1 -1
- package/plugins/FormSubmissionDynamoDbFieldPlugin.js.map +1 -1
- package/plugins/index.js.map +1 -1
- package/types.js +4 -4
- package/types.js.map +1 -1
package/definitions/form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["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","layout","stats","settings","triggers","webinyVersion"],"sources":["form.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\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 layout: {\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;AASO,
|
|
1
|
+
{"version":3,"names":["_dynamodbToolbox","require","createFormEntity","params","table","entityName","attributes","Entity","name","_objectSpread2","default","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","layout","stats","settings","triggers","webinyVersion","exports"],"sources":["form.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\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 layout: {\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,gBAAA,GAAAC,OAAA;AASO,MAAMC,gBAAgB,GAAIC,MAAc,IAAkB;EAC7D,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdH,KAAK;IACLI,IAAI,EAAEH,UAAU;IAChBC,UAAU,MAAAG,cAAA,CAAAC,OAAA;MACNC,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;MACDR,IAAI,EAAE;QACFQ,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,MAAM,EAAE;QACJlB,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;IAAC,GACGV,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAACiC,OAAA,CAAArC,gBAAA,GAAAA,gBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSettingsEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","reCaptcha","domain","tenant","locale"],"sources":["settings.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\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;AASO,
|
|
1
|
+
{"version":3,"names":["_dynamodbToolbox","require","createSettingsEntity","params","entityName","attributes","table","Entity","name","_objectSpread2","default","PK","partitionKey","SK","sortKey","TYPE","type","reCaptcha","domain","tenant","locale","exports"],"sources":["settings.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\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,gBAAA,GAAAC,OAAA;AASO,MAAMC,oBAAoB,GAAIC,MAAc,IAAkB;EACjE,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,MAAAI,cAAA,CAAAC,OAAA;MACNC,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;IAAC,GACGX,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAACgB,OAAA,CAAAnB,oBAAA,GAAAA,oBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSubmissionEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","id","type","TYPE","data","meta","form","logs","createdOn","savedOn","ownedBy","tenant","locale","webinyVersion"],"sources":["submission.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\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;AASO,
|
|
1
|
+
{"version":3,"names":["_dynamodbToolbox","require","createSubmissionEntity","params","table","entityName","attributes","Entity","name","_objectSpread2","default","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 \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\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,gBAAA,GAAAC,OAAA;AASO,MAAMC,sBAAsB,GAAIC,MAAc,IAAkB;EACnE,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdH,KAAK;IACLI,IAAI,EAAEH,UAAU;IAChBC,UAAU,MAAAG,cAAA,CAAAC,OAAA;MACNC,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;IAAC,GACGV,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAACsB,OAAA,CAAA1B,sBAAA,GAAAA,sBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","tenant"],"sources":["system.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\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;AASO,
|
|
1
|
+
{"version":3,"names":["_dynamodbToolbox","require","createSystemEntity","params","entityName","attributes","table","Entity","name","_objectSpread2","default","PK","partitionKey","SK","sortKey","version","type","tenant","exports"],"sources":["system.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\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,gBAAA,GAAAC,OAAA;AASO,MAAMC,kBAAkB,GAAIC,MAAc,IAAkB;EAC/D,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,MAAAI,cAAA,CAAAC,OAAA;MACNC,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;IAAC,GACGX,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAACa,OAAA,CAAAhB,kBAAA,GAAAA,kBAAA"}
|
package/definitions/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createTable","params","tableName","documentClient","Table","name","process","env","DB_TABLE","partitionKey","sortKey","DocumentClient","indexes","GSI1"],"sources":["table.ts"],"sourcesContent":["import { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Table } from \"dynamodb-toolbox\";\n\ninterface Params {\n tableName?: string;\n documentClient: DocumentClient;\n}\n\nexport const createTable = (params: Params): Table => {\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 });\n};\n"],"mappings":";;;;;;AACA;AAOO,
|
|
1
|
+
{"version":3,"names":["_dynamodbToolbox","require","createTable","params","tableName","documentClient","Table","name","process","env","DB_TABLE","partitionKey","sortKey","DocumentClient","indexes","GSI1","exports"],"sources":["table.ts"],"sourcesContent":["import { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Table } from \"dynamodb-toolbox\";\n\ninterface Params {\n tableName?: string;\n documentClient: DocumentClient;\n}\n\nexport const createTable = (params: Params): Table => {\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 });\n};\n"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AAOO,MAAMC,WAAW,GAAIC,MAAc,IAAY;EAClD,MAAM;IAAEC,SAAS;IAAEC;EAAe,CAAC,GAAGF,MAAM;EAE5C,OAAO,IAAIG,sBAAK,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;EACJ,CAAC,CAAC;AACN,CAAC;AAACI,OAAA,CAAAd,WAAA,GAAAA,WAAA"}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["reservedFields","isReserved","name","includes","WebinyError","createFormBuilderStorageOperations","params","attributes","table","tableName","documentClient","plugins","userPlugins","
|
|
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","_objectSpread2","default","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,C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ACC,IAAI,EAC5BC,2CAAiC,CAACD,IAAI,CACzC;MACD,KAAK,MAAMA,IAAI,IAAIF,KAAK,EAAE;QACtB5B,OAAO,CAACgC,WAAW,CAACL,OAAO,CAAC3B,OAAO,EAAE8B,IAAI,CAAC;MAC9C;IACJ,CAAC;IACDG,QAAQ,EAAEA,CAAA,KAAMpC,KAAK;IACrBqC,WAAW,EAAEA,CAAA,KAAMzB;EAAQ,GACxB,IAAA0B,sCAA6B,EAAC;IAC7BtC,KAAK;IACLuC,MAAM,EAAE3B,QAAQ,CAACS;EACrB,CAAC,CAAC,GACC,IAAAmB,0CAA+B,EAAC;IAC/BxC,KAAK;IACLuC,MAAM,EAAE3B,QAAQ,CAACY;EACrB,CAAC,CAAC,GACC,IAAAiB,kCAA2B,EAAC;IAC3BzC,KAAK;IACLuC,MAAM,EAAE3B,QAAQ,CAACC,IAAI;IACrBV;EACJ,CAAC,CAAC,GACC,IAAAuC,8CAAiC,EAAC;IACjC1C,KAAK;IACLuC,MAAM,EAAE3B,QAAQ,CAACM,UAAU;IAC3Bf;EACJ,CAAC,CAAC;AAEV,CAAC;AAACf,OAAA,CAAAS,kCAAA,GAAAA,kCAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormDynamoDbFieldPlugin","field","type","path"],"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;AAA4E,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["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","item","get","cleanupItem","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","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"],"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 \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\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 { get } 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;\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 const item = await get<FbForm>({ entity, keys });\n return cleanupItem(entity, item);\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\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;AAiBA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;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AE5F,IAAI,CAACL,OAAO;UACzBkG,eAAe,EAAE;QACrB,CAAC;QACDvD,IAAI,EAAE,CAAC,cAAc;MACzB,CAAC,CAAC;MAEF,MAAMwD,2BAA2B,GAAGrB,SAAS,CAACe,KAAK,EAAE;MACrD,IAAIM,2BAA2B,EAAE;QAC7BlF,KAAK,CAACgB,IAAI,CACNvD,MAAM,CAACwC,QAAQ,yFACRiF,2BAA2B,GAC3BJ,mBAAmB;UACtB5E,IAAI,EAAEhB,6BAA6B;QAAE,GACvC,CACL;MACL,CAAC,MAAM;QACHc,KAAK,CAACgB,IAAI,CAACvD,MAAM,CAACkG,WAAW,CAACmB,mBAAmB,CAAC,CAAC;MACvD;IACJ;IAEA,IAAI;MACA,MAAM,IAAA3E,yBAAa,EAAC;QAChBzC,KAAK;QACLsC;MACJ,CAAC,CAAC;MACF,OAAOZ,IAAI;IACf,CAAC,CAAC,OAAOgB,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,2BAA2B,EACzCF,EAAE,CAACG,IAAI,IAAI,sBAAsB,EACjC;QACInB,IAAI;QACJqB,QAAQ;QACRG,UAAU;QACVf,YAAY;QACZC,UAAU;QACVgF;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,OAAO;IACHlF,UAAU;IACVY,cAAc;IACdG,UAAU;IACVc,SAAS;IACT2B,iBAAiB;IACjBvC,OAAO;IACPyC,UAAU;IACVM,kBAAkB;IAClBiB,WAAW;IACXE,aAAa;IACb/G;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_query","_cleanup","_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","_objectSpread2","default","TYPE","batchWriteAll","ex","WebinyError","message","code","createFormFrom","original","latest","updateForm","latestForm","getForm","where","isLatestForm","push","published","partitionKey","sortKey","createIdentifier","keys","item","get","cleanupItem","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","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 \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\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 { get } 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;\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 const item = await get<FbForm>({ entity, keys });\n return cleanupItem(entity, item);\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\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,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAOA,IAAAO,wBAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,IAAA,GAAAT,OAAA;AA6BO,MAAMU,2BAA2B,GACpCC,MAAyC,IACN;EACnC,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAEzC,MAAMI,kBAAkB,GAAGD,OAAO,CAACE,MAAM,CACrCC,gDAAuB,CAACC,IAC5B,CAAC;EAED,MAAMC,sBAAsB,GAAIR,MAA+C,IAAa;IACxF,MAAM;MAAES,MAAM;MAAEC;IAAO,CAAC,GAAGV,MAAM;IAEjC,OAAQ,KAAIS,MAAO,MAAKC,MAAO,OAAM;EACzC,CAAC;EAED,MAAMC,4BAA4B,GAC9BX,MAA+C,IACtC;IACT,OAAQ,GAAEQ,sBAAsB,CAACR,MAAM,CAAE,IAAG;EAChD,CAAC;EAED,MAAMY,qCAAqC,GACvCZ,MAA+C,IACtC;IACT,OAAQ,GAAEQ,sBAAsB,CAACR,MAAM,CAAE,KAAI;EACjD,CAAC;EAED,MAAMa,yBAAyB,GAC3Bb,MAAkD,IACzC;IACT,MAAM;MAAES,MAAM;MAAEC,MAAM;MAAEI,EAAE,EAAEC;IAAS,CAAC,GAAGf,MAAM;IAC/C,MAAM;MAAEc;IAAG,CAAC,GAAG,IAAAE,sBAAe,EAACD,QAAQ,CAAC;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C;QAChB3C,KAAK;QACLsC;MACJ,CAAC,CAAC;MACF,OAAOZ,IAAI;IACf,CAAC,CAAC,OAAOkB,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,2BAA2B,EACzCF,EAAE,CAACG,IAAI,IAAI,sBAAsB,EACjC;QACIrB,IAAI;QACJuB,QAAQ;QACRG,UAAU;QACVjB,YAAY;QACZC,UAAU;QACVkF;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHpF,UAAU;IACVc,cAAc;IACdG,UAAU;IACVc,SAAS;IACT2B,iBAAiB;IACjBvC,OAAO;IACPyC,UAAU;IACVM,kBAAkB;IAClBiB,WAAW;IACXE,aAAa;IACbjH;EACJ,CAAC;AACL,CAAC;AAACqH,OAAA,CAAA9H,2BAAA,GAAAA,2BAAA"}
|
|
@@ -80,7 +80,7 @@ const createSettingsStorageOperations = params => {
|
|
|
80
80
|
} = params;
|
|
81
81
|
const keys = createKeys(settings);
|
|
82
82
|
try {
|
|
83
|
-
await entity.delete();
|
|
83
|
+
await entity.delete(keys);
|
|
84
84
|
} catch (ex) {
|
|
85
85
|
throw new _error.default(ex.message || "Could not delete the settings record by given keys.", ex.code || "DELETE_SETTINGS_ERROR", {
|
|
86
86
|
keys
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSettingsStorageOperations","params","entity","createSettingsPartitionKey","tenant","locale","createSettingsSortKey","createKeys","PK","SK","createSettings","settings","keys","put","ex","WebinyError","message","code","getSettings","item","get","cleanupItem","updateSettings","original","deleteSettings","delete"],"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 \"dynamodb-toolbox\";\nimport {\n FormBuilderSettingsStorageOperations,\n FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { get } from \"@webiny/db-dynamodb/utils/get\";\n\nexport interface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n table: Table;\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 entity.put({\n ...settings,\n ...keys\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 const item = await get<Settings>({ entity, keys });\n return cleanupItem(entity, item);\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 entity.put({\n ...settings,\n ...keys\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 entity.delete();\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;AACA;AACA;AAOO,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_cleanup","_get","createSettingsStorageOperations","params","entity","createSettingsPartitionKey","tenant","locale","createSettingsSortKey","createKeys","PK","SK","createSettings","settings","keys","put","_objectSpread2","default","ex","WebinyError","message","code","getSettings","item","get","cleanupItem","updateSettings","original","deleteSettings","delete","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 \"dynamodb-toolbox\";\nimport {\n FormBuilderSettingsStorageOperations,\n FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { get } from \"@webiny/db-dynamodb/utils/get\";\n\nexport interface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n table: Table;\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 entity.put({\n ...settings,\n ...keys\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 const item = await get<Settings>({ entity, keys });\n return cleanupItem(entity, item);\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 entity.put({\n ...settings,\n ...keys\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 entity.delete(keys);\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 createSettingsPartition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AO;IACHF,cAAc;IACdU,WAAW;IACXI,cAAc;IACdE,cAAc;IACdvB,0BAA0B;IAC1BG;EACJ,CAAC;AACL,CAAC;AAACsB,OAAA,CAAA5B,+BAAA,GAAAA,+BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormSubmissionDynamoDbFieldPlugin","field","type"],"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;AAAgG,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSubmissionStorageOperations","params","entity","plugins","createSubmissionPartitionKey","tenant","locale","formId","id","parseIdentifier","createSubmissionSortKey","createSubmissionType","createSubmission","submission","form","keys","PK","SK","put","TYPE","ex","WebinyError","message","code","updateSubmission","original","deleteSubmission","delete","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","item","get","cleanupItem"],"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 \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n FormBuilderSubmissionStorageOperations,\n FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\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 { get } from \"@webiny/db-dynamodb/utils/get\";\n\nexport interface CreateSubmissionStorageOperationsParams {\n entity: Entity<any>;\n table: Table;\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 entity.put({\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\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 entity.put({\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\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 entity.delete(keys);\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 const item = await get<FbSubmission>({ entity, keys });\n return cleanupItem(entity, item);\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;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQO,MAAMA,iCAAiC,GAC1CC,MAA+C,IACN;EACzC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAElC,MAAMG,4BAA4B,GAC9BH,MAAsE,IACrE;IACD,MAAM;MAAEI,MAAM;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGN,MAAM;IAEzC,MAAM;MAAEO;IAAG,CAAC,GAAG,IAAAC,sBAAe,EAACF,MAAM,CAAC;IAEtC,OAAQ,KAAIF,MAAO,MAAKC,MAAO,UAASE,EAAG,EAAC;EAChD,CAAC;EACD,MAAME,uBAAuB,GAAIF,EAAU,IAAK;IAC5C,OAAOA,EAAE;EACb,CAAC;EAED,MAAMG,oBAAoB,GAAG,MAAM;IAC/B,OAAO,mBAAmB;EAC9B,CAAC;EAED,MAAMC,gBAAgB,GAAG,MACrBX,MAA0D,IAClC;IACxB,MAAM;MAAEY,UAAU;MAAEC;IAAK,CAAC,GAAGb,MAAM;IACnC,MAAMc,IAAI,GAAG;MACTC,EAAE,EAAEZ,4BAA4B,CAACU,IAAI,CAAC;MACtCG,EAAE,EAAEP,uBAAuB,CAACG,UAAU,CAACL,EAAE;IAC7C,CAAC;IAED,IAAI;MACA,MAAMN,MAAM,CAACgB,GAAG,yFACTL,UAAU,GACVE,IAAI;QACPI,IAAI,EAAER,oBAAoB;MAAE,GAC9B;IACN,CAAC,CAAC,OAAOS,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,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AI,2BAA2B,EACzCF,EAAE,CAACG,IAAI,IAAI,sBAAsB,EACjC;QACIM,KAAK;QACLd;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,OAAO;IACHH,gBAAgB;IAChBc,gBAAgB;IAChBF,gBAAgB;IAChBI,eAAe;IACfkC,aAAa;IACb1D,4BAA4B;IAC5BM;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_cleanup","_utils","_query","_cursor","_sort","_filter","_FormSubmissionDynamoDbFieldPlugin","_get","createSubmissionStorageOperations","params","entity","plugins","createSubmissionPartitionKey","tenant","locale","formId","id","parseIdentifier","createSubmissionSortKey","createSubmissionType","createSubmission","submission","form","keys","PK","SK","put","_objectSpread2","default","TYPE","ex","WebinyError","message","code","updateSubmission","original","deleteSubmission","delete","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","item","get","cleanupItem","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 \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n FormBuilderSubmissionStorageOperations,\n FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\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 { get } from \"@webiny/db-dynamodb/utils/get\";\n\nexport interface CreateSubmissionStorageOperationsParams {\n entity: Entity<any>;\n table: Table;\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 entity.put({\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\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 entity.put({\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\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 entity.delete(keys);\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 const item = await get<FbSubmission>({ entity, keys });\n return cleanupItem(entity, item);\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,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,kCAAA,GAAAP,OAAA;AACA,IAAAQ,IAAA,GAAAR,OAAA;AAQO,MAAMS,iCAAiC,GAC1CC,MAA+C,IACN;EACzC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAElC,MAAMG,4BAA4B,GAC9BH,MAAsE,IACrE;IACD,MAAM;MAAEI,MAAM;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGN,MAAM;IAEzC,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
|
|
1
|
-
{"version":3,"names":["createSystemStorageOperations","params","entity","createSystemPartitionKey","tenant","createSystemSortKey","createKeys","PK","SK","createSystem","system","keys","put","ex","WebinyError","message","code","getSystem","item","get","cleanupItem","updateSystem","original"],"sources":["index.ts"],"sourcesContent":["import {\n FormBuilderStorageOperationsCreateSystemParams,\n FormBuilderStorageOperationsGetSystemParams,\n FormBuilderStorageOperationsUpdateSystemParams,\n System\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport { FormBuilderSystemCreateKeysParams, FormBuilderSystemStorageOperations } from \"~/types\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport WebinyError from \"@webiny/error\";\nimport { get } from \"@webiny/db-dynamodb/utils/get\";\n\nexport interface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n table: Table;\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 entity.put({\n ...system,\n ...keys\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 const item = await get<System>({ entity, keys });\n return cleanupItem(entity, item);\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 entity.put({\n ...system,\n ...keys\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;AACA;AACA;AAOO,
|
|
1
|
+
{"version":3,"names":["_cleanup","require","_error","_interopRequireDefault","_get","createSystemStorageOperations","params","entity","createSystemPartitionKey","tenant","createSystemSortKey","createKeys","PK","SK","createSystem","system","keys","put","_objectSpread2","default","ex","WebinyError","message","code","getSystem","item","get","cleanupItem","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 \"dynamodb-toolbox\";\nimport { FormBuilderSystemCreateKeysParams, FormBuilderSystemStorageOperations } from \"~/types\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport WebinyError from \"@webiny/error\";\nimport { get } from \"@webiny/db-dynamodb/utils/get\";\n\nexport interface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n table: Table;\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 entity.put({\n ...system,\n ...keys\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 const item = await get<System>({ entity, keys });\n return cleanupItem(entity, item);\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 entity.put({\n ...system,\n ...keys\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,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAOO,MAAMI,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,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I,GAAGL,UAAU,CAACI,MAAM,CAAC;IAE/B,IAAI;MACA,MAAMR,MAAM,CAACU,GAAG,KAAAC,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACTJ,MAAM,GACNC,IAAI,CACV,CAAC;MACF,OAAOD,MAAM;IACjB,CAAC,CAAC,OAAOK,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,mDAAmD,EACjEF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIP,IAAI;QACJa,QAAQ;QACRd;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHD,YAAY;IACZU,SAAS;IACTI,YAAY;IACZpB,wBAAwB;IACxBE;EACJ,CAAC;AACL,CAAC;AAACoB,OAAA,CAAAzB,6BAAA,GAAAA,6BAAA"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-form-builder-so-ddb",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.37.0-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-form-builder",
|
|
7
7
|
"storage-operations",
|
|
8
8
|
"dynamodb",
|
|
9
|
+
"ddb",
|
|
9
10
|
"fb:ddb"
|
|
10
11
|
],
|
|
11
12
|
"repository": {
|
|
@@ -20,26 +21,25 @@
|
|
|
20
21
|
],
|
|
21
22
|
"license": "MIT",
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@babel/runtime": "7.
|
|
24
|
-
"@webiny/api-form-builder": "5.
|
|
25
|
-
"@webiny/db-dynamodb": "5.
|
|
26
|
-
"@webiny/error": "5.
|
|
27
|
-
"@webiny/plugins": "5.
|
|
28
|
-
"@webiny/utils": "5.
|
|
24
|
+
"@babel/runtime": "7.22.6",
|
|
25
|
+
"@webiny/api-form-builder": "5.37.0-beta.1",
|
|
26
|
+
"@webiny/db-dynamodb": "5.37.0-beta.1",
|
|
27
|
+
"@webiny/error": "5.37.0-beta.1",
|
|
28
|
+
"@webiny/plugins": "5.37.0-beta.1",
|
|
29
|
+
"@webiny/utils": "5.37.0-beta.1",
|
|
29
30
|
"dynamodb-toolbox": "0.3.5"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@babel/cli": "7.
|
|
33
|
-
"@babel/core": "7.
|
|
34
|
-
"@babel/preset-env": "7.
|
|
35
|
-
"@babel/preset-typescript": "7.
|
|
36
|
-
"@webiny/cli": "5.
|
|
37
|
-
"@webiny/handler-db": "5.
|
|
38
|
-
"@webiny/project-utils": "5.
|
|
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": "5.37.0-beta.1",
|
|
38
|
+
"@webiny/handler-db": "5.37.0-beta.1",
|
|
39
|
+
"@webiny/project-utils": "5.37.0-beta.1",
|
|
39
40
|
"csvtojson": "2.0.10",
|
|
40
|
-
"jest": "
|
|
41
|
+
"jest": "29.5.0",
|
|
41
42
|
"jest-dynalite": "3.6.1",
|
|
42
|
-
"jest-environment-node": "27.5.1",
|
|
43
43
|
"rimraf": "3.0.2",
|
|
44
44
|
"ttypescript": "1.5.15",
|
|
45
45
|
"typescript": "4.7.4"
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"build": "yarn webiny run build",
|
|
53
53
|
"watch": "yarn webiny run watch"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "176c29425477d1daaca1b7da79bacc79a1d35f6e"
|
|
56
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormDynamoDbFieldPlugin","FieldPlugin"],"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;AAEO,
|
|
1
|
+
{"version":3,"names":["_FieldPlugin","require","FormDynamoDbFieldPlugin","FieldPlugin","exports","_defineProperty2","default"],"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;AAExDC,OAAA,CAAAF,uBAAA,GAAAA,uBAAA;AAAA,IAAAG,gBAAA,CAAAC,OAAA,EAFYJ,uBAAuB,UACe,iCAAiC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormSubmissionDynamoDbFieldPlugin","FieldPlugin"],"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;AAEO,
|
|
1
|
+
{"version":3,"names":["_FieldPlugin","require","FormSubmissionDynamoDbFieldPlugin","FieldPlugin","exports","_defineProperty2","default"],"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;AAElEC,OAAA,CAAAF,iCAAA,GAAAA,iCAAA;AAAA,IAAAG,gBAAA,CAAAC,OAAA,EAFYJ,iCAAiC,UACK,2CAA2C"}
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./FormDynamoDbFieldPlugin\";\nexport * from \"./FormSubmissionDynamoDbFieldPlugin\";\n"],"mappings":";;;;;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"}
|
package/types.js
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ENTITIES = void 0;
|
|
7
|
-
let ENTITIES
|
|
8
|
-
exports.ENTITIES = ENTITIES;
|
|
9
|
-
(function (ENTITIES) {
|
|
7
|
+
let ENTITIES = /*#__PURE__*/function (ENTITIES) {
|
|
10
8
|
ENTITIES["FORM"] = "FormBuilderForm";
|
|
11
9
|
ENTITIES["SUBMISSION"] = "FormBuilderSubmission";
|
|
12
10
|
ENTITIES["SYSTEM"] = "FormBuilderSystem";
|
|
13
11
|
ENTITIES["SETTINGS"] = "FormBuilderSettings";
|
|
14
|
-
|
|
12
|
+
return ENTITIES;
|
|
13
|
+
}({});
|
|
14
|
+
exports.ENTITIES = ENTITIES;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ENTITIES"],"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 { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Table, Entity } from \"dynamodb-toolbox\";\nimport { DynamoDBTypes } from \"dynamodb-toolbox/dist/classes/Table\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { Plugin } from \"@webiny/plugins\";\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\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: DocumentClient;\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;\n getEntities(): Record<Entities, Entity<any>>;\n}\n\nexport interface FormBuilderStorageOperationsFactory {\n (params: FormBuilderStorageOperationsFactoryParams): FormBuilderStorageOperations;\n}\n"],"mappings":";;;;;;IAoBYA,QAAQ
|
|
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 { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Table, Entity } from \"dynamodb-toolbox\";\nimport { DynamoDBTypes } from \"dynamodb-toolbox/dist/classes/Table\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { Plugin } from \"@webiny/plugins\";\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\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: DocumentClient;\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;\n getEntities(): Record<Entities, Entity<any>>;\n}\n\nexport interface FormBuilderStorageOperationsFactory {\n (params: FormBuilderStorageOperationsFactoryParams): FormBuilderStorageOperations;\n}\n"],"mappings":";;;;;;IAoBYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAAAC,OAAA,CAAAD,QAAA,GAAAA,QAAA"}
|