@webiny/api-form-builder-so-ddb 0.0.0-ee-vpcs.549378cf03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/definitions/form.d.ts +9 -0
  4. package/definitions/form.js +106 -0
  5. package/definitions/form.js.map +1 -0
  6. package/definitions/settings.d.ts +9 -0
  7. package/definitions/settings.js +49 -0
  8. package/definitions/settings.js.map +1 -0
  9. package/definitions/submission.d.ts +9 -0
  10. package/definitions/submission.js +70 -0
  11. package/definitions/submission.js.map +1 -0
  12. package/definitions/system.d.ts +9 -0
  13. package/definitions/system.js +40 -0
  14. package/definitions/system.js.map +1 -0
  15. package/definitions/table.d.ts +8 -0
  16. package/definitions/table.js +29 -0
  17. package/definitions/table.js.map +1 -0
  18. package/index.d.ts +2 -0
  19. package/index.js +135 -0
  20. package/index.js.map +1 -0
  21. package/operations/form/fields.d.ts +3 -0
  22. package/operations/form/fields.js +43 -0
  23. package/operations/form/fields.js.map +1 -0
  24. package/operations/form/index.d.ts +9 -0
  25. package/operations/form/index.js +738 -0
  26. package/operations/form/index.js.map +1 -0
  27. package/operations/settings/index.d.ts +7 -0
  28. package/operations/settings/index.js +118 -0
  29. package/operations/settings/index.js.map +1 -0
  30. package/operations/submission/fields.d.ts +3 -0
  31. package/operations/submission/fields.js +18 -0
  32. package/operations/submission/fields.js.map +1 -0
  33. package/operations/submission/index.d.ts +9 -0
  34. package/operations/submission/index.js +241 -0
  35. package/operations/submission/index.js.map +1 -0
  36. package/operations/system/index.d.ts +7 -0
  37. package/operations/system/index.js +101 -0
  38. package/operations/system/index.js.map +1 -0
  39. package/package.json +56 -0
  40. package/plugins/FormDynamoDbFieldPlugin.d.ts +4 -0
  41. package/plugins/FormDynamoDbFieldPlugin.js +17 -0
  42. package/plugins/FormDynamoDbFieldPlugin.js.map +1 -0
  43. package/plugins/FormSubmissionDynamoDbFieldPlugin.d.ts +4 -0
  44. package/plugins/FormSubmissionDynamoDbFieldPlugin.js +17 -0
  45. package/plugins/FormSubmissionDynamoDbFieldPlugin.js.map +1 -0
  46. package/types.d.ts +65 -0
  47. package/types.js +15 -0
  48. package/types.js.map +1 -0
@@ -0,0 +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;;AA6BO,MAAMA,2BAA2B,GACpCC,MADuC,IAEJ;EACnC,MAAM;IAAEC,MAAF;IAAUC,KAAV;IAAiBC;EAAjB,IAA6BH,MAAnC;EAEA,MAAMI,kBAAkB,GAAGD,OAAO,CAACE,MAAR,CACvBC,gDAAA,CAAwBC,IADD,CAA3B;;EAIA,MAAMC,sBAAsB,GAAIR,MAAD,IAA6D;IACxF,MAAM;MAAES,MAAF;MAAUC;IAAV,IAAqBV,MAA3B;IAEA,OAAQ,KAAIS,MAAO,MAAKC,MAAO,OAA/B;EACH,CAJD;;EAMA,MAAMC,4BAA4B,GAC9BX,MADiC,IAExB;IACT,OAAQ,GAAEQ,sBAAsB,CAACR,MAAD,CAAS,IAAzC;EACH,CAJD;;EAMA,MAAMY,qCAAqC,GACvCZ,MAD0C,IAEjC;IACT,OAAQ,GAAEQ,sBAAsB,CAACR,MAAD,CAAS,KAAzC;EACH,CAJD;;EAMA,MAAMa,yBAAyB,GAC3Bb,MAD8B,IAErB;IACT,MAAM;MAAES,MAAF;MAAUC,MAAV;MAAkBI,EAAE,EAAEC;IAAtB,IAAmCf,MAAzC;IACA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AN;MAIA,OAAOZ,IAAP;IACH,CAND,CAME,OAAOgB,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,2BADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,sBAFT,EAGF;QACInB,IADJ;QAEIqB,QAFJ;QAGIG,UAHJ;QAIIf,YAJJ;QAKIC,UALJ;QAMIgF;MANJ,CAHE,CAAN;IAYH;EACJ,CAnGD;;EAqGA,OAAO;IACHlF,UADG;IAEHY,cAFG;IAGHG,UAHG;IAIHc,SAJG;IAKH2B,iBALG;IAMHvC,OANG;IAOHyC,UAPG;IAQHM,kBARG;IASHiB,WATG;IAUHE,aAVG;IAWH/G;EAXG,CAAP;AAaH,CA3wBM"}
@@ -0,0 +1,7 @@
1
+ import { Entity, Table } from "dynamodb-toolbox";
2
+ import { FormBuilderSettingsStorageOperations } from "../../types";
3
+ export interface CreateSettingsStorageOperationsParams {
4
+ entity: Entity<any>;
5
+ table: Table;
6
+ }
7
+ export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => FormBuilderSettingsStorageOperations;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createSettingsStorageOperations = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
15
+
16
+ var _get = require("@webiny/db-dynamodb/utils/get");
17
+
18
+ const createSettingsStorageOperations = params => {
19
+ const {
20
+ entity
21
+ } = params;
22
+
23
+ const createSettingsPartitionKey = ({
24
+ tenant,
25
+ locale
26
+ }) => {
27
+ return `T#${tenant}#L#${locale}#FB#SETTINGS`;
28
+ };
29
+
30
+ const createSettingsSortKey = () => {
31
+ return "default";
32
+ };
33
+
34
+ const createKeys = params => {
35
+ return {
36
+ PK: createSettingsPartitionKey(params),
37
+ SK: createSettingsSortKey()
38
+ };
39
+ };
40
+
41
+ const createSettings = async params => {
42
+ const {
43
+ settings
44
+ } = params;
45
+ const keys = createKeys(settings);
46
+
47
+ try {
48
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), keys));
49
+ return settings;
50
+ } catch (ex) {
51
+ throw new _error.default(ex.message || "Could not create the settings record by given keys.", ex.code || "CREATE_SETTINGS_ERROR", {
52
+ keys,
53
+ settings
54
+ });
55
+ }
56
+ };
57
+
58
+ const getSettings = async params => {
59
+ const keys = createKeys(params);
60
+
61
+ try {
62
+ const item = await (0, _get.get)({
63
+ entity,
64
+ keys
65
+ });
66
+ return (0, _cleanup.cleanupItem)(entity, item);
67
+ } catch (ex) {
68
+ throw new _error.default(ex.message || "Could not get the settings record by given keys.", ex.code || "LOAD_SETTINGS_ERROR", {
69
+ keys
70
+ });
71
+ }
72
+ };
73
+
74
+ const updateSettings = async params => {
75
+ const {
76
+ settings,
77
+ original
78
+ } = params;
79
+ const keys = createKeys(settings);
80
+
81
+ try {
82
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), keys));
83
+ return settings;
84
+ } catch (ex) {
85
+ throw new _error.default(ex.message || "Could not update the settings record by given keys.", ex.code || "UPDATE_SETTINGS_ERROR", {
86
+ keys,
87
+ original,
88
+ settings
89
+ });
90
+ }
91
+ };
92
+
93
+ const deleteSettings = async params => {
94
+ const {
95
+ settings
96
+ } = params;
97
+ const keys = createKeys(settings);
98
+
99
+ try {
100
+ await entity.delete();
101
+ } catch (ex) {
102
+ throw new _error.default(ex.message || "Could not delete the settings record by given keys.", ex.code || "DELETE_SETTINGS_ERROR", {
103
+ keys
104
+ });
105
+ }
106
+ };
107
+
108
+ return {
109
+ createSettings,
110
+ getSettings,
111
+ updateSettings,
112
+ deleteSettings,
113
+ createSettingsPartitionKey,
114
+ createSettingsSortKey
115
+ };
116
+ };
117
+
118
+ exports.createSettingsStorageOperations = createSettingsStorageOperations;
@@ -0,0 +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,MAAMA,+BAA+B,GACxCC,MAD2C,IAEJ;EACvC,MAAM;IAAEC;EAAF,IAAaD,MAAnB;;EAEA,MAAME,0BAA0B,GAAG,CAAC;IAChCC,MADgC;IAEhCC;EAFgC,CAAD,KAGyC;IACxE,OAAQ,KAAID,MAAO,MAAKC,MAAO,cAA/B;EACH,CALD;;EAOA,MAAMC,qBAAqB,GAAG,MAAc;IACxC,OAAO,SAAP;EACH,CAFD;;EAIA,MAAMC,UAAU,GAAIN,MAAD,IAA0E;I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QAAP;IACH,CAND,CAME,OAAOG,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,qDADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,uBAFT,EAGF;QACIL,IADJ;QAEIW,QAFJ;QAGIZ;MAHJ,CAHE,CAAN;IASH;EACJ,CAvBD;;EAyBA,MAAMa,cAAc,GAAG,MACnBvB,MADmB,IAEH;IAChB,MAAM;MAAEU;IAAF,IAAeV,MAArB;IACA,MAAMW,IAAI,GAAGL,UAAU,CAACI,QAAD,CAAvB;;IACA,IAAI;MACA,MAAMT,MAAM,CAACuB,MAAP,EAAN;IACH,CAFD,CAEE,OAAOX,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,qDADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,uBAFT,EAGF;QACIL;MADJ,CAHE,CAAN;IAOH;EACJ,CAhBD;;EAkBA,OAAO;IACHF,cADG;IAEHQ,WAFG;IAGHI,cAHG;IAIHE,cAJG;IAKHrB,0BALG;IAMHG;EANG,CAAP;AAQH,CArHM"}
@@ -0,0 +1,3 @@
1
+ import { FormSubmissionDynamoDbFieldPlugin } from "../../plugins/FormSubmissionDynamoDbFieldPlugin";
2
+ declare const _default: () => FormSubmissionDynamoDbFieldPlugin[];
3
+ export default _default;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _FormSubmissionDynamoDbFieldPlugin = require("../../plugins/FormSubmissionDynamoDbFieldPlugin");
9
+
10
+ var _default = () => [new _FormSubmissionDynamoDbFieldPlugin.FormSubmissionDynamoDbFieldPlugin({
11
+ field: "createdOn",
12
+ type: "date"
13
+ }), new _FormSubmissionDynamoDbFieldPlugin.FormSubmissionDynamoDbFieldPlugin({
14
+ field: "savedOn",
15
+ type: "date"
16
+ })];
17
+
18
+ exports.default = _default;
@@ -0,0 +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;;eAEe,MAAM,CACjB,IAAIA,oEAAJ,CAAsC;EAClCC,KAAK,EAAE,WAD2B;EAElCC,IAAI,EAAE;AAF4B,CAAtC,CADiB,EAKjB,IAAIF,oEAAJ,CAAsC;EAClCC,KAAK,EAAE,SAD2B;EAElCC,IAAI,EAAE;AAF4B,CAAtC,CALiB,C"}
@@ -0,0 +1,9 @@
1
+ import { Entity, Table } from "dynamodb-toolbox";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { FormBuilderSubmissionStorageOperations } from "../../types";
4
+ export interface CreateSubmissionStorageOperationsParams {
5
+ entity: Entity<any>;
6
+ table: Table;
7
+ plugins: PluginsContainer;
8
+ }
9
+ export declare const createSubmissionStorageOperations: (params: CreateSubmissionStorageOperationsParams) => FormBuilderSubmissionStorageOperations;
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createSubmissionStorageOperations = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
15
+
16
+ var _utils = require("@webiny/utils");
17
+
18
+ var _query = require("@webiny/db-dynamodb/utils/query");
19
+
20
+ var _cursor = require("@webiny/db-dynamodb/utils/cursor");
21
+
22
+ var _sort = require("@webiny/db-dynamodb/utils/sort");
23
+
24
+ var _filter = require("@webiny/db-dynamodb/utils/filter");
25
+
26
+ var _FormSubmissionDynamoDbFieldPlugin = require("../../plugins/FormSubmissionDynamoDbFieldPlugin");
27
+
28
+ var _get = require("@webiny/db-dynamodb/utils/get");
29
+
30
+ const createSubmissionStorageOperations = params => {
31
+ const {
32
+ entity,
33
+ plugins
34
+ } = params;
35
+
36
+ const createSubmissionPartitionKey = params => {
37
+ const {
38
+ tenant,
39
+ locale,
40
+ formId
41
+ } = params;
42
+ const {
43
+ id
44
+ } = (0, _utils.parseIdentifier)(formId);
45
+ return `T#${tenant}#L#${locale}#FB#FS#${id}`;
46
+ };
47
+
48
+ const createSubmissionSortKey = id => {
49
+ return id;
50
+ };
51
+
52
+ const createSubmissionType = () => {
53
+ return "fb.formSubmission";
54
+ };
55
+
56
+ const createSubmission = async params => {
57
+ const {
58
+ submission,
59
+ form
60
+ } = params;
61
+ const keys = {
62
+ PK: createSubmissionPartitionKey(form),
63
+ SK: createSubmissionSortKey(submission.id)
64
+ };
65
+
66
+ try {
67
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, submission), keys), {}, {
68
+ TYPE: createSubmissionType()
69
+ }));
70
+ } catch (ex) {
71
+ throw new _error.default(ex.message || "Could not create form submission in the DynamoDB.", ex.code || "UPDATE_FORM_SUBMISSION_ERROR", {
72
+ submission,
73
+ form,
74
+ keys
75
+ });
76
+ }
77
+
78
+ return submission;
79
+ };
80
+
81
+ const updateSubmission = async params => {
82
+ const {
83
+ submission,
84
+ form,
85
+ original
86
+ } = params;
87
+ const keys = {
88
+ PK: createSubmissionPartitionKey(form),
89
+ SK: createSubmissionSortKey(submission.id)
90
+ };
91
+
92
+ try {
93
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, submission), keys), {}, {
94
+ TYPE: createSubmissionType()
95
+ }));
96
+ return submission;
97
+ } catch (ex) {
98
+ throw new _error.default(ex.message || "Could not update form submission in the DynamoDB.", ex.code || "UPDATE_FORM_SUBMISSION_ERROR", {
99
+ submission,
100
+ original,
101
+ form,
102
+ keys
103
+ });
104
+ }
105
+ };
106
+
107
+ const deleteSubmission = async params => {
108
+ const {
109
+ submission,
110
+ form
111
+ } = params;
112
+ const keys = {
113
+ PK: createSubmissionPartitionKey(form),
114
+ SK: createSubmissionSortKey(submission.id)
115
+ };
116
+
117
+ try {
118
+ await entity.delete(keys);
119
+ } catch (ex) {
120
+ throw new _error.default(ex.message || "Could not delete form submission from DynamoDB.", ex.code || "DELETE_FORM_SUBMISSION_ERROR", {
121
+ submission,
122
+ form,
123
+ keys
124
+ });
125
+ }
126
+
127
+ return submission;
128
+ };
129
+
130
+ const listSubmissions = async params => {
131
+ const {
132
+ where: initialWhere,
133
+ sort,
134
+ limit = 100000,
135
+ after
136
+ } = params;
137
+ const {
138
+ tenant,
139
+ locale,
140
+ formId
141
+ } = initialWhere;
142
+ const where = (0, _objectSpread2.default)({}, initialWhere);
143
+ /**
144
+ * We need to remove conditions so we do not filter by them again.
145
+ */
146
+
147
+ delete where.tenant;
148
+ delete where.locale;
149
+ delete where.formId;
150
+ const queryAllParams = {
151
+ entity,
152
+ partitionKey: createSubmissionPartitionKey({
153
+ tenant,
154
+ locale,
155
+ formId
156
+ }),
157
+ options: {
158
+ gte: " ",
159
+ reverse: true
160
+ }
161
+ };
162
+ let results;
163
+
164
+ try {
165
+ results = await (0, _query.queryAll)(queryAllParams);
166
+ } catch (ex) {
167
+ throw new _error.default(ex.message || "Could list form submissions.", ex.code || "LIST_SUBMISSIONS_ERROR", {
168
+ where: initialWhere,
169
+ partitionKey: queryAllParams.partitionKey
170
+ });
171
+ }
172
+
173
+ const fields = plugins.byType(_FormSubmissionDynamoDbFieldPlugin.FormSubmissionDynamoDbFieldPlugin.type);
174
+ const filteredSubmissions = (0, _filter.filterItems)({
175
+ plugins,
176
+ items: results,
177
+ where,
178
+ fields
179
+ });
180
+ const sortedSubmissions = (0, _sort.sortItems)({
181
+ items: filteredSubmissions,
182
+ sort,
183
+ fields
184
+ });
185
+ const totalCount = sortedSubmissions.length;
186
+ const start = parseInt((0, _cursor.decodeCursor)(after) || "0") || 0;
187
+ const hasMoreItems = totalCount > start + limit;
188
+ const end = limit > totalCount + start + limit ? undefined : start + limit;
189
+ const items = sortedSubmissions.slice(start, end);
190
+ /**
191
+ * Although we do not need a cursor here, we will use it as such to keep it standardized.
192
+ * Number is simply encoded.
193
+ */
194
+
195
+ const cursor = items.length > 0 ? (0, _cursor.encodeCursor)(start + limit) : null;
196
+ const meta = {
197
+ hasMoreItems,
198
+ totalCount,
199
+ cursor
200
+ };
201
+ return {
202
+ items,
203
+ meta
204
+ };
205
+ };
206
+
207
+ const getSubmission = async params => {
208
+ const {
209
+ where
210
+ } = params;
211
+ const keys = {
212
+ PK: createSubmissionPartitionKey(where),
213
+ SK: createSubmissionSortKey(where.id)
214
+ };
215
+
216
+ try {
217
+ const item = await (0, _get.get)({
218
+ entity,
219
+ keys
220
+ });
221
+ return (0, _cleanup.cleanupItem)(entity, item);
222
+ } catch (ex) {
223
+ throw new _error.default(ex.message || "Could not oad submission.", ex.code || "GET_SUBMISSION_ERROR", {
224
+ where,
225
+ keys
226
+ });
227
+ }
228
+ };
229
+
230
+ return {
231
+ createSubmission,
232
+ deleteSubmission,
233
+ updateSubmission,
234
+ listSubmissions,
235
+ getSubmission,
236
+ createSubmissionPartitionKey,
237
+ createSubmissionSortKey
238
+ };
239
+ };
240
+
241
+ exports.createSubmissionStorageOperations = createSubmissionStorageOperations;
@@ -0,0 +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,MAD6C,IAEJ;EACzC,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAsBF,MAA5B;;EAEA,MAAMG,4BAA4B,GAC9BH,MADiC,IAEhC;IACD,MAAM;MAAEI,MAAF;MAAUC,MAAV;MAAkBC;IAAlB,IAA6BN,MAAnC;IAEA,MAAM;MAAEO;IAAF,IAAS,IAAAC,sBAAA,EAAgBF,MAAhB,CAAf;IAEA,OAAQ,KAAIF,MAAO,MAAKC,MAAO,UAASE,EAAG,EAA3C;EACH,CARD;;EASA,MAAME,uBAAuB,GAAIF,EAAD,IAAgB;IAC5C,OAAOA,EAAP;EACH,CAFD;;EAIA,MAAMG,oBAAoB,GAAG,MAAM;IAC/B,OAAO,mBAAP;EACH,CAFD;;EAIA,MAAMC,gBAAgB,GAAG,MACrBX,MADqB,IAEG;IACxB,MAAM;MAAEY,UAAF;MAAcC;IAAd,IAAuBb,MAA7B;IACA,MAAMc,IAAI,GAAG;MACTC,EAAE,EAAEZ,4BAA4B,CAACU,IAAD,CADvB;MAETG,EAAE,EAAEP,uBAAuB,CAACG,UAAU,CAACL,EAAZ;IAFlB,CAAb;;IAKA,IAAI;MACA,MAAMN,MAAM,CAACgB,GAAP,yFACCL,UADD,GAECE,IAFD;QAGFI,IAAI,EAAER,oBAAoB;MAHxB,GAAN;IAKH,CAND,CAME,OAAOS,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,mDADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,8BAFT,EAGF;QACIV,UADJ;QAEIC,IAFJ;QAGIC;MAHJ,CAHE,CAA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GF;QACIM,KADJ;QAEId;MAFJ,CAHE,CAAN;IAQH;EACJ,CAvBD;;EAyBA,OAAO;IACHH,gBADG;IAEHc,gBAFG;IAGHF,gBAHG;IAIHI,eAJG;IAKHkC,aALG;IAMH1D,4BANG;IAOHM;EAPG,CAAP;AASH,CAnOM"}
@@ -0,0 +1,7 @@
1
+ import { Entity, Table } from "dynamodb-toolbox";
2
+ import { FormBuilderSystemStorageOperations } from "../../types";
3
+ export interface CreateSystemStorageOperationsParams {
4
+ entity: Entity<any>;
5
+ table: Table;
6
+ }
7
+ export declare const createSystemStorageOperations: (params: CreateSystemStorageOperationsParams) => FormBuilderSystemStorageOperations;