@webiny/api-form-builder-so-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.1e66d121db
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/configurations.d.ts +7 -5
- package/configurations.js +31 -9
- package/configurations.js.map +1 -0
- package/definitions/elasticsearch.d.ts +2 -1
- package/definitions/elasticsearch.js +3 -7
- package/definitions/elasticsearch.js.map +1 -0
- package/definitions/form.d.ts +2 -1
- package/definitions/form.js +3 -7
- package/definitions/form.js.map +1 -0
- package/definitions/settings.d.ts +2 -1
- package/definitions/settings.js +3 -7
- package/definitions/settings.js.map +1 -0
- package/definitions/submission.d.ts +2 -1
- package/definitions/submission.js +3 -7
- package/definitions/submission.js.map +1 -0
- package/definitions/system.d.ts +2 -1
- package/definitions/system.js +3 -7
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +3 -2
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +2 -1
- package/definitions/tableElasticsearch.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +10 -0
- package/elasticsearch/createElasticsearchIndex.js +63 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +19 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +16 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +20 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/index.js +35 -32
- package/index.js.map +1 -0
- package/operations/form/elasticsearchBody.js +8 -17
- package/operations/form/elasticsearchBody.js.map +1 -0
- package/operations/form/elasticsearchFields.js.map +1 -0
- package/operations/form/fields.js.map +1 -0
- package/operations/form/index.d.ts +2 -2
- package/operations/form/index.js +49 -48
- package/operations/form/index.js.map +1 -0
- package/operations/settings/index.d.ts +2 -2
- package/operations/settings/index.js +4 -8
- package/operations/settings/index.js.map +1 -0
- package/operations/submission/elasticsearchBody.js +10 -12
- package/operations/submission/elasticsearchBody.js.map +1 -0
- package/operations/submission/elasticsearchFields.js.map +1 -0
- package/operations/submission/index.d.ts +2 -2
- package/operations/submission/index.js +19 -22
- package/operations/submission/index.js.map +1 -0
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js +4 -8
- package/operations/system/index.js.map +1 -0
- package/package.json +23 -27
- package/plugins/FormDynamoDbFieldPlugin.js +1 -1
- package/plugins/FormDynamoDbFieldPlugin.js.map +1 -0
- package/plugins/FormElasticsearchBodyModifierPlugin.js +1 -1
- package/plugins/FormElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/FormElasticsearchFieldPlugin.js +1 -1
- package/plugins/FormElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/FormElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/FormElasticsearchIndexPlugin.js +17 -0
- package/plugins/FormElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/FormElasticsearchQueryModifierPlugin.js +1 -1
- package/plugins/FormElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/FormElasticsearchSortModifierPlugin.js +1 -1
- package/plugins/FormElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.js +1 -1
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchFieldPlugin.js +1 -1
- package/plugins/SubmissionElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.js +1 -1
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchSortModifierPlugin.js +1 -1
- package/plugins/SubmissionElasticsearchSortModifierPlugin.js.map +1 -0
- package/types.d.ts +2 -2
- package/types.js.map +1 -0
- package/operations/system/createElasticsearchIndex.d.ts +0 -6
- package/operations/system/createElasticsearchIndex.js +0 -70
- package/upgrades/5.16.0/index.d.ts +0 -8
- package/upgrades/5.16.0/index.js +0 -141
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getESDataForLatestRevision","form","__type","createFormElasticType","id","createdOn","savedOn","name","slug","published","publishedOn","version","locked","status","createdBy","ownedBy","tenant","locale","webinyVersion","formId","createFormStorageOperations","params","entity","esEntity","table","plugins","elasticsearch","formDynamoDbFields","fields","createFormPartitionKey","targetId","parseIdentifier","createRevisionSortKey","value","Number","zeroPad","createLatestSortKey","createLatestPublishedSortKey","createFormType","createFormLatestType","createFormLatestPublishedType","createForm","revisionKeys","PK","SK","latestKeys","items","putBatch","TYPE","batchWriteAll","ex","WebinyError","message","code","index","configurations","es","put","data","createFormFrom","original","latest","updateForm","latestForm","getForm","where","isLatestForm","push","sortKey","keys","result","get","Item","cleanupItem","listForms","sort","limit","after","body","createElasticsearchBody","decodeCursor","esConfig","query","response","search","hits","total","map","item","_source","hasMoreItems","length","pop","meta","totalCount","cursor","encodeCursor","listFormRevisions","initialWhere","queryAllParams","partitionKey","options","beginsWith","queryAll","undefined","filteredItems","filterItems","sortItems","deleteForm","gte","deleteItems","deleteBatch","delete","deleteFormRevision","revisions","previous","latestPublishedForm","find","rev","isLatest","isLatestPublished","esDataItem","previouslyPublishedForm","filter","f","a","b","Date","getTime","shift","publishForm","latestPublishedKeys","esData","unpublishForm","version_not","publishedOn_not","previouslyPublishedRevision"],"sources":["index.ts"],"sourcesContent":["import {\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 { Client } from \"@elastic/elasticsearch\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { configurations } from \"~/configurations\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport fields from \"./fields\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { parseIdentifier, zeroPad } from \"@webiny/utils\";\nimport { createElasticsearchBody, createFormElasticType } from \"./elasticsearchBody\";\nimport { decodeCursor, encodeCursor } from \"@webiny/api-elasticsearch/cursors\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { FormBuilderFormCreateKeyParams, FormBuilderFormStorageOperations } from \"~/types\";\nimport { ElasticsearchSearchResponse } from \"@webiny/api-elasticsearch/types\";\n\nexport type DbRecord<T = any> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\nexport interface CreateFormStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n table: Table;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\n\ntype FbFormElastic = Omit<FbForm, \"triggers\" | \"fields\" | \"settings\" | \"layout\" | \"stats\"> & {\n __type: string;\n};\n\nconst getESDataForLatestRevision = (form: FbForm): FbFormElastic => ({\n __type: createFormElasticType(),\n id: form.id,\n createdOn: form.createdOn,\n savedOn: form.savedOn,\n name: form.name,\n slug: form.slug,\n published: form.published,\n publishedOn: form.publishedOn,\n version: form.version,\n locked: form.locked,\n status: form.status,\n createdBy: form.createdBy,\n ownedBy: form.ownedBy,\n tenant: form.tenant,\n locale: form.locale,\n webinyVersion: form.webinyVersion,\n formId: form.formId\n});\n\nexport const createFormStorageOperations = (\n params: CreateFormStorageOperationsParams\n): FormBuilderFormStorageOperations => {\n const { entity, esEntity, table, plugins, elasticsearch } = params;\n\n const formDynamoDbFields = fields();\n\n const createFormPartitionKey = (params: FormBuilderFormCreateKeyParams): string => {\n const { tenant, locale, id: targetId } = params;\n\n const { id } = parseIdentifier(targetId);\n\n return `T#${tenant}#L#${locale}#FB#F#${id}`;\n };\n\n const createRevisionSortKey = (value: string | number | undefined): string => {\n const version =\n typeof value === \"number\" ? Number(value) : (parseIdentifier(value).version as number);\n return `REV#${zeroPad(version)}`;\n };\n\n const createLatestSortKey = (): string => {\n return \"L\";\n };\n\n const createLatestPublishedSortKey = (): string => {\n return \"LP\";\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 createForm = async (\n params: FormBuilderStorageOperationsCreateFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.id)\n };\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...form,\n TYPE: createFormType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...form,\n TYPE: createFormLatestType(),\n ...latestKeys\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 regular table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n form\n }\n );\n }\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: getESDataForLatestRevision(form),\n TYPE: createFormType(),\n ...latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert form data into Elasticsearch table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\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 = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.version)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\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 ||\n \"Could not create form data in the regular 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 try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: getESDataForLatestRevision(form),\n TYPE: createFormLatestType(),\n ...latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not create form in the Elasticsearch table, from existing form.\",\n ex.code || \"CREATE_FORM_FROM_ERROR\",\n {\n latestKeys,\n form,\n latest,\n original\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 = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.id)\n };\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\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 TYPE: createFormType(),\n ...revisionKeys\n })\n ];\n if (isLatestForm) {\n items.push(\n entity.putBatch({\n ...form,\n TYPE: createFormLatestType(),\n ...latestKeys\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 regular table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latestForm\n }\n );\n }\n /**\n * No need to go further if its not latest form.\n */\n if (!isLatestForm) {\n return form;\n }\n\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: getESDataForLatestRevision(form),\n TYPE: createFormLatestType(),\n ...latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form data in the Elasticsearch table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n latestKeys,\n form,\n latestForm,\n original\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, tenant, locale } = where;\n if (latest && published) {\n throw new WebinyError(\"Cannot have both latest and published params.\");\n }\n let sortKey: string;\n if (latest) {\n sortKey = createLatestSortKey();\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 sortKey = createLatestPublishedSortKey();\n } else if (id || version) {\n sortKey = createRevisionSortKey(version || id);\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: createFormPartitionKey({\n tenant,\n locale,\n id: (formId || id) as string\n }),\n SK: sortKey\n };\n\n try {\n const result = await entity.get(keys);\n if (!result || !result.Item) {\n return null;\n }\n return cleanupItem(entity, result.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, after } = params;\n\n const body = createElasticsearchBody({\n plugins,\n sort,\n limit: limit + 1,\n where,\n after: decodeCursor(after) as any\n });\n\n const esConfig = configurations.es({\n tenant: where.tenant,\n locale: where.locale\n });\n\n const query = {\n ...esConfig,\n body\n };\n\n let response: ElasticsearchSearchResponse<FbForm>;\n try {\n response = await elasticsearch.search(query);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list forms.\",\n ex.code || \"LIST_FORMS_ERROR\",\n {\n where,\n query\n }\n );\n }\n\n const { hits, total } = response.body.hits;\n const items = hits.map(item => item._source);\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n\n const meta = {\n hasMoreItems,\n totalCount: total.value,\n cursor: items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null\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 const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormPartitionKey({\n tenant,\n locale,\n id: (id || formId) as string\n }),\n options: {\n beginsWith: \"REV#\"\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 id: undefined,\n formId: undefined\n };\n const filteredItems = filterItems({\n plugins,\n items,\n where,\n fields: formDynamoDbFields\n });\n if (!sort || sort.length === 0) {\n return filteredItems;\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 and submission records.\n */\n const queryAllParams = {\n entity,\n partitionKey: createFormPartitionKey(form),\n options: {\n gte: \" \"\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 const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\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\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n try {\n await esEntity.delete(latestKeys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete latest form record from Elasticsearch.\",\n ex.code || \"DELETE_FORM_ERROR\",\n {\n latestKeys\n }\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 = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.id)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\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 let esDataItem = undefined;\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 PK: createFormPartitionKey(previouslyPublishedForm),\n SK: createLatestPublishedSortKey(),\n TYPE: createFormLatestPublishedType()\n })\n );\n } else {\n items.push(\n entity.deleteBatch({\n PK: createFormPartitionKey(form),\n SK: createLatestPublishedSortKey()\n })\n );\n }\n }\n /**\n * Sort out the latest record.\n */\n if (isLatest && previous) {\n items.push(\n entity.putBatch({\n ...previous,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n );\n\n const { index } = configurations.es({\n tenant: previous.tenant,\n locale: previous.locale\n });\n\n esDataItem = {\n index,\n ...latestKeys,\n data: getESDataForLatestRevision(previous)\n };\n }\n }\n /**\n * Now save the batch data.\n */\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form revision from regular table.\",\n ex.code || \"DELETE_FORM_REVISION_ERROR\",\n {\n form,\n latestForm,\n revisionKeys,\n latestKeys\n }\n );\n }\n /**\n * And then the Elasticsearch data, if any.\n */\n if (!esDataItem) {\n return form;\n }\n try {\n await esEntity.put(esDataItem);\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form from to the Elasticsearch 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 = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.version)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const latestPublishedKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestPublishedSortKey()\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 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 if (!isLatestForm) {\n return form;\n }\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n const esData = getESDataForLatestRevision(form);\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n TYPE: createFormLatestType(),\n data: esData\n });\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not publish form to the Elasticsearch.\",\n ex.code || \"PUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\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 = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.version)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const latestPublishedKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestPublishedSortKey()\n };\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 TYPE: createFormType()\n })\n ];\n let esData: any = undefined;\n if (isLatest) {\n esData = getESDataForLatestRevision(form);\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 } 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 * No need to go further in case of non-existing Elasticsearch data.\n */\n if (!esData) {\n return form;\n }\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n TYPE: createFormLatestType(),\n data: esData\n });\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not unpublish form from the Elasticsearch.\",\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":";;;;;;;;;;;AAiBA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAuBA,MAAMA,0BAA0B,GAAIC,IAAD,KAAkC;EACjEC,MAAM,EAAE,IAAAC,wCAAA,GADyD;EAEjEC,EAAE,EAAEH,IAAI,CAACG,EAFwD;EAGjEC,SAAS,EAAEJ,IAAI,CAACI,SAHiD;EAIjEC,OAAO,EAAEL,IAAI,CAACK,OAJmD;EAKjEC,IAAI,EAAEN,IAAI,CAACM,IALsD;EAMjEC,IAAI,EAAEP,IAAI,CAACO,IANsD;EAOjEC,SAAS,EAAER,IAAI,CAACQ,SAPiD;EAQjEC,WAAW,EAAET,IAAI,CAACS,WAR+C;EASjEC,OAAO,EAAEV,IAAI,CAACU,OATmD;EAUjEC,MAAM,EAAEX,IAAI,CAACW,MAVoD;EAWjEC,MAAM,EAAEZ,IAAI,CAACY,MAXoD;EAYjEC,SAAS,EAAEb,IAAI,CAACa,SAZiD;EAajEC,OAAO,EAAEd,IAAI,CAACc,OAbmD;EAcjEC,MAAM,EAAEf,IAAI,CAACe,MAdoD;EAejEC,MAAM,EAAEhB,IAAI,CAACgB,MAfoD;EAgBjEC,aAAa,EAAEjB,IAAI,CAACiB,aAhB6C;EAiBjEC,MAAM,EAAElB,IAAI,CAACkB;AAjBoD,CAAlC,CAAnC;;AAoBO,MAAMC,2BAA2B,GACpCC,MADuC,IAE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CAAP;AAaH,CA/4BM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Entity, Table } from "dynamodb-toolbox";
|
|
2
2
|
import { FormBuilderSettingsStorageOperations } from "../../types";
|
|
3
|
-
export interface
|
|
3
|
+
export interface CreateSettingsStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
table: Table;
|
|
6
6
|
}
|
|
7
|
-
export declare const createSettingsStorageOperations: (params:
|
|
7
|
+
export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => FormBuilderSettingsStorageOperations;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createSettingsStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
14
14
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
15
15
|
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
-
|
|
20
16
|
const createSettingsStorageOperations = params => {
|
|
21
17
|
const {
|
|
22
18
|
entity
|
|
@@ -47,7 +43,7 @@ const createSettingsStorageOperations = params => {
|
|
|
47
43
|
const keys = createKeys(settings);
|
|
48
44
|
|
|
49
45
|
try {
|
|
50
|
-
await entity.put(
|
|
46
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), keys));
|
|
51
47
|
return settings;
|
|
52
48
|
} catch (ex) {
|
|
53
49
|
throw new _error.default(ex.message || "Could not create the settings record by given keys.", ex.code || "CREATE_SETTINGS_ERROR", {
|
|
@@ -83,7 +79,7 @@ const createSettingsStorageOperations = params => {
|
|
|
83
79
|
const keys = createKeys(settings);
|
|
84
80
|
|
|
85
81
|
try {
|
|
86
|
-
await entity.put(
|
|
82
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), keys));
|
|
87
83
|
return settings;
|
|
88
84
|
} catch (ex) {
|
|
89
85
|
throw new _error.default(ex.message || "Could not update the settings record by given keys.", ex.code || "UPDATE_SETTINGS_ERROR", {
|
|
@@ -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","result","get","Item","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\";\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 result = await entity.get(keys);\n if (!result || !result.Item) {\n return null;\n }\n return cleanupItem(entity, result.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;;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;IACzF,OAAO;MACHO,EAAE,EAAEL,0BAA0B,CAACF,MAAD,CAD3B;MAEHQ,EAAE,EAAEH,qBAAqB;IAFtB,CAAP;EAIH,CALD;;EAOA,MAAMI,cAAc,GAAG,MACnBT,MADmB,IAEC;IACpB,MAAM;MAAEU;IAAF,IAAeV,MAArB;IACA,MAAMW,IAAI,GAAGL,UAAU,CAACI,QAAD,CAAvB;;IAEA,IAAI;MACA,MAAMT,MAAM,CAACW,GAAP,6DACCF,QADD,GAECC,IAFD,EAAN;MAIA,OAAOD,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;QAEID;MAFJ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Z,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;IAGHK,cAHG;IAIHE,cAJG;IAKHtB,0BALG;IAMHG;EANG,CAAP;AAQH,CAxHM"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createSubmissionElasticType = exports.createElasticsearchBody = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _cursors = require("@webiny/api-elasticsearch/cursors");
|
|
13
13
|
|
|
@@ -27,10 +27,6 @@ var _SubmissionElasticsearchQueryModifierPlugin = require("../../plugins/Submiss
|
|
|
27
27
|
|
|
28
28
|
var _where = require("@webiny/api-elasticsearch/where");
|
|
29
29
|
|
|
30
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
-
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
33
|
-
|
|
34
30
|
const createInitialQueryValue = () => {
|
|
35
31
|
return {
|
|
36
32
|
must: [
|
|
@@ -66,11 +62,14 @@ const createElasticsearchQuery = params => {
|
|
|
66
62
|
*/
|
|
67
63
|
|
|
68
64
|
const operatorPlugins = plugins.byType(_ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
|
|
65
|
+
if (plugin.isLocaleSupported(initialWhere.locale) === false) {
|
|
66
|
+
return acc;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
69
|
acc[plugin.getOperator()] = plugin;
|
|
70
70
|
return acc;
|
|
71
71
|
}, {});
|
|
72
|
-
|
|
73
|
-
const where = _objectSpread({}, initialWhere);
|
|
72
|
+
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
74
73
|
/**
|
|
75
74
|
* !!! IMPORTANT !!! There are few specific cases where we hardcode the query conditions.
|
|
76
75
|
*
|
|
@@ -78,10 +77,9 @@ const createElasticsearchQuery = params => {
|
|
|
78
77
|
* No need for the tenant filtering otherwise as each index is for single tenant.
|
|
79
78
|
*/
|
|
80
79
|
|
|
81
|
-
|
|
82
80
|
const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
|
|
83
81
|
|
|
84
|
-
if (sharedIndex) {
|
|
82
|
+
if (sharedIndex && where.tenant) {
|
|
85
83
|
query.must.push({
|
|
86
84
|
term: {
|
|
87
85
|
"tenant.keyword": where.tenant
|
|
@@ -141,7 +139,7 @@ const createElasticsearchBody = params => {
|
|
|
141
139
|
return acc;
|
|
142
140
|
}, {});
|
|
143
141
|
const limit = (0, _limit.createLimit)(initialLimit, 100);
|
|
144
|
-
const query = createElasticsearchQuery(
|
|
142
|
+
const query = createElasticsearchQuery((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
145
143
|
fieldPlugins
|
|
146
144
|
}));
|
|
147
145
|
const sort = (0, _sort.createSort)({
|
|
@@ -169,7 +167,7 @@ const createElasticsearchBody = params => {
|
|
|
169
167
|
query: {
|
|
170
168
|
constant_score: {
|
|
171
169
|
filter: {
|
|
172
|
-
bool:
|
|
170
|
+
bool: (0, _objectSpread2.default)({}, query)
|
|
173
171
|
}
|
|
174
172
|
}
|
|
175
173
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createInitialQueryValue","must","term","must_not","should","filter","createSubmissionElasticType","createElasticsearchQuery","params","plugins","where","initialWhere","fieldPlugins","query","operatorPlugins","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","acc","plugin","isLocaleSupported","locale","getOperator","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","tenant","push","formId","applyWhere","fields","operators","createElasticsearchBody","limit","initialLimit","sort","initialSort","after","SubmissionElasticsearchFieldPlugin","field","createLimit","createSort","queryModifiers","SubmissionElasticsearchQueryModifierPlugin","modifyQuery","sortModifiers","SubmissionElasticsearchSortModifierPlugin","modifySort","body","constant_score","bool","size","search_after","decodeCursor","bodyModifiers","SubmissionElasticsearchBodyModifierPlugin","modifyBody"],"sources":["elasticsearchBody.ts"],"sourcesContent":["import { SearchBody as esSearchBody } from \"elastic-ts\";\nimport { decodeCursor } from \"@webiny/api-elasticsearch/cursors\";\nimport { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { createSort } from \"@webiny/api-elasticsearch/sort\";\nimport { createLimit } from \"@webiny/api-elasticsearch/limit\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { SubmissionElasticsearchFieldPlugin } from \"~/plugins/SubmissionElasticsearchFieldPlugin\";\nimport { SubmissionElasticsearchSortModifierPlugin } from \"~/plugins/SubmissionElasticsearchSortModifierPlugin\";\nimport { SubmissionElasticsearchBodyModifierPlugin } from \"~/plugins/SubmissionElasticsearchBodyModifierPlugin\";\nimport { FormBuilderStorageOperationsListSubmissionsParams } from \"@webiny/api-form-builder/types\";\nimport { SubmissionElasticsearchQueryModifierPlugin } from \"~/plugins/SubmissionElasticsearchQueryModifierPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { applyWhere } from \"@webiny/api-elasticsearch/where\";\n\nconst createInitialQueryValue = (): ElasticsearchBoolQueryConfig => {\n return {\n must: [\n /**\n * We add the __type filtering in the initial query because it must be applied.\n */\n {\n term: {\n \"__type.keyword\": \"fb.submission\"\n }\n }\n ],\n must_not: [],\n should: [],\n filter: []\n };\n};\n\nexport const createSubmissionElasticType = (): string => {\n return \"fb.submission\";\n};\n\ninterface CreateElasticsearchQueryParams extends CreateElasticsearchBodyParams {\n fieldPlugins: Record<string, SubmissionElasticsearchFieldPlugin>;\n}\n\nconst createElasticsearchQuery = (params: CreateElasticsearchQueryParams) => {\n const { plugins, where: initialWhere, fieldPlugins } = params;\n const query = createInitialQueryValue();\n /**\n * Be aware that, if having more registered operator plugins of same type, the last one will be used.\n */\n const operatorPlugins = plugins\n .byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n )\n .reduce((acc, plugin) => {\n if (plugin.isLocaleSupported(initialWhere.locale) === false) {\n return acc;\n }\n acc[plugin.getOperator()] = plugin;\n return acc;\n }, {} as Record<string, ElasticsearchQueryBuilderOperatorPlugin>);\n\n const where: Partial<FormBuilderStorageOperationsListSubmissionsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * !!! IMPORTANT !!! There are few specific cases where we hardcode the query conditions.\n *\n * When ES index is shared between tenants, we need to filter records by tenant ID.\n * No need for the tenant filtering otherwise as each index is for single tenant.\n */\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex && where.tenant) {\n query.must.push({\n term: {\n \"tenant.keyword\": where.tenant\n }\n });\n }\n /**\n * Remove tenant so it is not applied again later.\n * Possibly tenant is not defined, but just in case, remove it.\n */\n delete where.tenant;\n /**\n * Add the locale to filtering.\n */\n query.must.push({\n term: {\n \"locale.keyword\": where.locale as string\n }\n });\n delete where.locale;\n /**\n * And add the parent (form) to the filtering, if it exists.\n */\n query.must.push({\n term: {\n \"form.parent.keyword\": where.formId as string\n }\n });\n delete where.formId;\n /**\n * We apply other conditions as they are passed via the where value.\n */\n applyWhere({\n query,\n where,\n fields: fieldPlugins,\n operators: operatorPlugins\n });\n\n return query;\n};\n\ninterface CreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n where: FormBuilderStorageOperationsListSubmissionsParams[\"where\"];\n limit: number;\n after?: string;\n sort: string[];\n}\n\nexport const createElasticsearchBody = (params: CreateElasticsearchBodyParams): esSearchBody => {\n const { plugins, where, limit: initialLimit, sort: initialSort, after } = params;\n\n const fieldPlugins = plugins\n .byType<SubmissionElasticsearchFieldPlugin>(SubmissionElasticsearchFieldPlugin.type)\n .reduce((acc, plugin) => {\n acc[plugin.field] = plugin;\n return acc;\n }, {} as Record<string, SubmissionElasticsearchFieldPlugin>);\n\n const limit = createLimit(initialLimit, 100);\n\n const query = createElasticsearchQuery({\n ...params,\n fieldPlugins\n });\n\n const sort = createSort({\n sort: initialSort,\n fieldPlugins\n });\n\n const queryModifiers = plugins.byType<SubmissionElasticsearchQueryModifierPlugin>(\n SubmissionElasticsearchQueryModifierPlugin.type\n );\n\n for (const plugin of queryModifiers) {\n plugin.modifyQuery({\n query,\n where\n });\n }\n\n const sortModifiers = plugins.byType<SubmissionElasticsearchSortModifierPlugin>(\n SubmissionElasticsearchSortModifierPlugin.type\n );\n\n for (const plugin of sortModifiers) {\n plugin.modifySort({\n sort\n });\n }\n\n const body = {\n query: {\n constant_score: {\n filter: {\n bool: {\n ...query\n }\n }\n }\n },\n size: limit + 1,\n /**\n * Casting as any is required due to search_after is accepting an array of values.\n * Which is correct in some cases. In our case, it is not.\n * https://www.elastic.co/guide/en/elasticsearch/reference/7.13/paginate-search-results.html\n */\n search_after: decodeCursor(after) as any,\n sort\n };\n\n const bodyModifiers = plugins.byType<SubmissionElasticsearchBodyModifierPlugin>(\n SubmissionElasticsearchBodyModifierPlugin.type\n );\n\n for (const plugin of bodyModifiers) {\n plugin.modifyBody({\n body\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AAEA,MAAMA,uBAAuB,GAAG,MAAoC;EAChE,OAAO;IACHC,IAAI,EAAE;IACF;AACZ;AACA;IACY;MACIC,IAAI,EAAE;QACF,kBAAkB;MADhB;IADV,CAJE,CADH;IAWHC,QAAQ,EAAE,EAXP;IAYHC,MAAM,EAAE,EAZL;IAaHC,MAAM,EAAE;EAbL,CAAP;AAeH,CAhBD;;AAkBO,MAAMC,2BAA2B,GAAG,MAAc;EACrD,OAAO,eAAP;AACH,CAFM;;;;AAQP,MAAMC,wBAAwB,GAAIC,MAAD,IAA4C;EACzE,MAAM;IAAEC,OAAF;IAAWC,KAAK,EAAEC,YAAlB;IAAgCC;EAAhC,IAAiDJ,MAAvD;EACA,MAAMK,KAAK,GAAGb,uBAAuB,EAArC;EACA;AACJ;AACA;;EACI,MAAMc,eAAe,GAAGL,OAAO,CAC1BM,MADmB,CAEhBC,gFAAA,CAAwCC,IAFxB,EAInBC,MAJmB,CAIZ,CAACC,GAAD,EAAMC,MAAN,KAAiB;IACrB,IAAIA,MAAM,CAACC,iBAAP,CAAyBV,YAAY,CAACW,MAAtC,MAAkD,KAAtD,EAA6D;MACzD,OAAOH,GAAP;IACH;;IACDA,GAAG,CAACC,MAAM,CAACG,WAAP,EAAD,CAAH,GAA4BH,MAA5B;IACA,OAAOD,GAAP;EACH,CAVmB,EAUjB,EAViB,CAAxB;EAYA,MAAMT,KAA0E,mCACzEC,YADyE,CAAhF;EAGA;AACJ;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","unmappedType","ALL"],"sources":["elasticsearchFields.ts"],"sourcesContent":["import { SubmissionElasticsearchFieldPlugin } from \"~/plugins/SubmissionElasticsearchFieldPlugin\";\n\nexport default () => [\n new SubmissionElasticsearchFieldPlugin({\n field: \"parent\",\n path: \"form.parent\"\n }),\n new SubmissionElasticsearchFieldPlugin({\n field: \"ownedBy\",\n path: \"ownedBy.id\"\n }),\n new SubmissionElasticsearchFieldPlugin({\n field: \"createdOn\",\n unmappedType: \"date\"\n }),\n new SubmissionElasticsearchFieldPlugin({\n field: \"savedOn\",\n unmappedType: \"date\"\n }),\n /**\n * Always add the ALL fields plugin because of the keyword/path build.\n */\n new SubmissionElasticsearchFieldPlugin({\n field: SubmissionElasticsearchFieldPlugin.ALL\n })\n];\n"],"mappings":";;;;;;;AAAA;;eAEe,MAAM,CACjB,IAAIA,sEAAJ,CAAuC;EACnCC,KAAK,EAAE,QAD4B;EAEnCC,IAAI,EAAE;AAF6B,CAAvC,CADiB,EAKjB,IAAIF,sEAAJ,CAAuC;EACnCC,KAAK,EAAE,SAD4B;EAEnCC,IAAI,EAAE;AAF6B,CAAvC,CALiB,EASjB,IAAIF,sEAAJ,CAAuC;EACnCC,KAAK,EAAE,WAD4B;EAEnCE,YAAY,EAAE;AAFqB,CAAvC,CATiB,EAajB,IAAIH,sEAAJ,CAAuC;EACnCC,KAAK,EAAE,SAD4B;EAEnCE,YAAY,EAAE;AAFqB,CAAvC,CAbiB;AAiBjB;AACJ;AACA;AACI,IAAIH,sEAAJ,CAAuC;EACnCC,KAAK,EAAED,sEAAA,CAAmCI;AADP,CAAvC,CApBiB,C"}
|
|
@@ -2,11 +2,11 @@ import { Entity, Table } from "dynamodb-toolbox";
|
|
|
2
2
|
import { Client } from "@elastic/elasticsearch";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
import { FormBuilderSubmissionStorageOperations } from "../../types";
|
|
5
|
-
export interface
|
|
5
|
+
export interface CreateSubmissionStorageOperationsParams {
|
|
6
6
|
entity: Entity<any>;
|
|
7
7
|
esEntity: Entity<any>;
|
|
8
8
|
table: Table;
|
|
9
9
|
elasticsearch: Client;
|
|
10
10
|
plugins: PluginsContainer;
|
|
11
11
|
}
|
|
12
|
-
export declare const createSubmissionStorageOperations: (params:
|
|
12
|
+
export declare const createSubmissionStorageOperations: (params: CreateSubmissionStorageOperationsParams) => FormBuilderSubmissionStorageOperations;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createSubmissionStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ var _limit = require("@webiny/api-elasticsearch/limit");
|
|
|
19
19
|
|
|
20
20
|
var _elasticsearchBody = require("./elasticsearchBody");
|
|
21
21
|
|
|
22
|
-
var _configurations =
|
|
22
|
+
var _configurations = require("../../configurations");
|
|
23
23
|
|
|
24
24
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
25
25
|
|
|
@@ -27,10 +27,6 @@ var _utils = require("@webiny/utils");
|
|
|
27
27
|
|
|
28
28
|
var _cursors = require("@webiny/api-elasticsearch/cursors");
|
|
29
29
|
|
|
30
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
-
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
33
|
-
|
|
34
30
|
const createSubmissionStorageOperations = params => {
|
|
35
31
|
const {
|
|
36
32
|
entity,
|
|
@@ -71,7 +67,7 @@ const createSubmissionStorageOperations = params => {
|
|
|
71
67
|
};
|
|
72
68
|
|
|
73
69
|
try {
|
|
74
|
-
await entity.put(
|
|
70
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, submission), keys), {}, {
|
|
75
71
|
TYPE: createSubmissionType()
|
|
76
72
|
}));
|
|
77
73
|
} catch (ex) {
|
|
@@ -85,13 +81,14 @@ const createSubmissionStorageOperations = params => {
|
|
|
85
81
|
try {
|
|
86
82
|
const {
|
|
87
83
|
index
|
|
88
|
-
} = _configurations.
|
|
89
|
-
tenant: form.tenant
|
|
84
|
+
} = _configurations.configurations.es({
|
|
85
|
+
tenant: form.tenant,
|
|
86
|
+
locale: form.locale
|
|
90
87
|
});
|
|
91
88
|
|
|
92
|
-
await esEntity.put(
|
|
89
|
+
await esEntity.put((0, _objectSpread2.default)({
|
|
93
90
|
index,
|
|
94
|
-
data:
|
|
91
|
+
data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, submission), {}, {
|
|
95
92
|
__type: (0, _elasticsearchBody.createSubmissionElasticType)()
|
|
96
93
|
}),
|
|
97
94
|
TYPE: createSubmissionType()
|
|
@@ -123,7 +120,7 @@ const createSubmissionStorageOperations = params => {
|
|
|
123
120
|
};
|
|
124
121
|
|
|
125
122
|
try {
|
|
126
|
-
await entity.put(
|
|
123
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, submission), keys), {}, {
|
|
127
124
|
TYPE: createSubmissionType()
|
|
128
125
|
}));
|
|
129
126
|
return submission;
|
|
@@ -182,9 +179,9 @@ const createSubmissionStorageOperations = params => {
|
|
|
182
179
|
where,
|
|
183
180
|
sort
|
|
184
181
|
} = params;
|
|
185
|
-
const items = where.id_in.map(id => {
|
|
182
|
+
const items = (where.id_in || []).map(id => {
|
|
186
183
|
return entity.getBatch({
|
|
187
|
-
PK: createSubmissionPartitionKey(
|
|
184
|
+
PK: createSubmissionPartitionKey((0, _objectSpread2.default)({}, where)),
|
|
188
185
|
SK: createSubmissionSortKey(id)
|
|
189
186
|
});
|
|
190
187
|
});
|
|
@@ -224,7 +221,7 @@ const createSubmissionStorageOperations = params => {
|
|
|
224
221
|
const listSubmissions = async params => {
|
|
225
222
|
const {
|
|
226
223
|
where,
|
|
227
|
-
sort,
|
|
224
|
+
sort = [],
|
|
228
225
|
limit: initialLimit,
|
|
229
226
|
after
|
|
230
227
|
} = params;
|
|
@@ -250,14 +247,14 @@ const createSubmissionStorageOperations = params => {
|
|
|
250
247
|
after: (0, _cursors.decodeCursor)(after)
|
|
251
248
|
});
|
|
252
249
|
|
|
253
|
-
const esConfig = _configurations.
|
|
254
|
-
tenant: where.tenant
|
|
250
|
+
const esConfig = _configurations.configurations.es({
|
|
251
|
+
tenant: where.tenant,
|
|
252
|
+
locale: where.locale
|
|
255
253
|
});
|
|
256
254
|
|
|
257
|
-
const query =
|
|
255
|
+
const query = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, esConfig), {}, {
|
|
258
256
|
body
|
|
259
257
|
});
|
|
260
|
-
|
|
261
258
|
let response;
|
|
262
259
|
|
|
263
260
|
try {
|
|
@@ -291,7 +288,7 @@ const createSubmissionStorageOperations = params => {
|
|
|
291
288
|
const meta = {
|
|
292
289
|
hasMoreItems,
|
|
293
290
|
totalCount: total.value,
|
|
294
|
-
cursor: items.length > 0 ? (0, _cursors.encodeCursor)(hits[items.length - 1].sort) : null
|
|
291
|
+
cursor: items.length > 0 ? (0, _cursors.encodeCursor)(hits[items.length - 1].sort) || null : null
|
|
295
292
|
};
|
|
296
293
|
return {
|
|
297
294
|
items,
|
|
@@ -304,7 +301,7 @@ const createSubmissionStorageOperations = params => {
|
|
|
304
301
|
where
|
|
305
302
|
} = params;
|
|
306
303
|
const keys = {
|
|
307
|
-
PK: createSubmissionPartitionKey(
|
|
304
|
+
PK: createSubmissionPartitionKey((0, _objectSpread2.default)((0, _objectSpread2.default)({}, where), {}, {
|
|
308
305
|
formId: where.formId
|
|
309
306
|
})),
|
|
310
307
|
SK: createSubmissionSortKey(where.id)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSubmissionStorageOperations","params","entity","esEntity","table","elasticsearch","plugins","createSubmissionPartitionKey","tenant","locale","formId","id","parseIdentifier","createSubmissionSortKey","createSubmissionType","createSubmission","submission","form","keys","PK","SK","put","TYPE","ex","WebinyError","message","code","index","configurations","es","data","__type","createSubmissionElasticType","updateSubmission","original","deleteSubmission","delete","listSubmissionsByIds","where","sort","items","id_in","map","getBatch","results","batchReadAll","submissions","filter","Boolean","cleanupItem","sortItems","fields","listSubmissions","limit","initialLimit","after","meta","hasMoreItems","cursor","totalCount","length","createLimit","body","createElasticsearchBody","decodeCursor","esConfig","query","response","search","hits","total","item","_source","pop","value","encodeCursor","getSubmission","result","get","Item"],"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 { Client } from \"@elastic/elasticsearch\";\nimport WebinyError from \"@webiny/error\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { createLimit } from \"@webiny/api-elasticsearch/limit\";\nimport {\n createElasticsearchBody,\n createSubmissionElasticType\n} from \"~/operations/submission/elasticsearchBody\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n FormBuilderSubmissionStorageOperations,\n FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport { configurations } from \"~/configurations\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { decodeCursor, encodeCursor } from \"@webiny/api-elasticsearch/cursors\";\nimport { ElasticsearchSearchResponse } from \"@webiny/api-elasticsearch/types\";\n\nexport interface CreateSubmissionStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n table: Table;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\n\nexport const createSubmissionStorageOperations = (\n params: CreateSubmissionStorageOperationsParams\n): FormBuilderSubmissionStorageOperations => {\n const { entity, esEntity, table, elasticsearch, 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#F#${id}`;\n };\n const createSubmissionSortKey = (id: string) => {\n return `FS#${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 try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: {\n ...submission,\n __type: createSubmissionElasticType()\n },\n TYPE: createSubmissionType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form submission in the Elasticsearch.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n /**\n * We do not save the data in the Elasticsearch because there is no need for that.\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 try {\n await esEntity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form submission from Elasticsearch.\",\n ex.code || \"DELETE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n\n /**\n *\n * We are using this method because it is faster to fetch the exact data from the DynamoDB than Elasticsearch.\n *\n * @internal\n */\n const listSubmissionsByIds = async (\n params: FormBuilderStorageOperationsListSubmissionsParams\n ): Promise<FbSubmission[]> => {\n const { where, sort } = params;\n const items = (where.id_in || []).map(id => {\n return entity.getBatch({\n PK: createSubmissionPartitionKey({\n ...where\n }),\n SK: createSubmissionSortKey(id)\n });\n });\n\n let results: FbSubmission[] = [];\n\n try {\n results = await batchReadAll<FbSubmission>({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch read form submissions.\",\n ex.code || \"BATCH_READ_SUBMISSIONS_ERROR\",\n {\n where,\n sort\n }\n );\n }\n /**\n * We need to remove empty results because it is a possibility that batch read returned null for non-existing record.\n */\n const submissions = results.filter(Boolean).map(submission => {\n return cleanupItem(entity, submission);\n }) as FbSubmission[];\n if (!sort) {\n return submissions;\n }\n return sortItems<FbSubmission>({\n items: submissions,\n sort,\n fields: []\n });\n };\n\n const listSubmissions = async (\n params: FormBuilderStorageOperationsListSubmissionsParams\n ): Promise<FormBuilderStorageOperationsListSubmissionsResponse> => {\n const { where, sort = [], limit: initialLimit, after } = params;\n\n if (where.id_in) {\n const items = await listSubmissionsByIds(params);\n\n return {\n items,\n meta: {\n hasMoreItems: false,\n cursor: null,\n totalCount: items.length\n }\n };\n }\n\n const limit = createLimit(initialLimit);\n\n const body = createElasticsearchBody({\n plugins,\n sort,\n limit: limit + 1,\n where,\n after: decodeCursor(after) as any\n });\n\n const esConfig = configurations.es({\n tenant: where.tenant,\n locale: where.locale\n });\n\n const query = {\n ...esConfig,\n body\n };\n\n let response: ElasticsearchSearchResponse<FbSubmission>;\n try {\n response = await elasticsearch.search(query);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list form submissions.\",\n ex.code || \"LIST_SUBMISSIONS_ERROR\",\n {\n where,\n query\n }\n );\n }\n\n const { hits, total } = response.body.hits;\n const items = hits.map(item => item._source);\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const meta = {\n hasMoreItems,\n totalCount: total.value,\n cursor: items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null\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({\n ...where,\n formId: where.formId as string\n }),\n SK: createSubmissionSortKey(where.id)\n };\n\n try {\n const result = await entity.get(keys);\n\n if (!result || !result.Item) {\n return null;\n }\n\n return cleanupItem(entity, result.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":";;;;;;;;;;;AAWA;;AACA;;AACA;;AACA;;AACA;;AASA;;AACA;;AACA;;AACA;;AAWO,MAAMA,iCAAiC,GAC1CC,MAD6C,IAEJ;EACzC,MAAM;IAAEC,MAAF;IAAUC,QAAV;IAAoBC,KAApB;IAA2BC,aAA3B;IAA0CC;EAA1C,IAAsDL,MAA5D;;EAEA,MAAMM,4BAA4B,GAC9BN,MADiC,IAEhC;IACD,MAAM;MAAEO,MAAF;MAAUC,MAAV;MAAkBC;IAAlB,IAA6BT,MAAnC;IAEA,MAAM;MAAEU;IAAF,IAAS,IAAAC,sBAAA,EAAgBF,MAAhB,CAAf;IAEA,OAAQ,KAAIF,MAAO,MAAKC,MAAO,SAAQE,EAAG,EAA1C;EACH,CARD;;EASA,MAAME,uBAAuB,GAAIF,EAAD,IAAgB;IAC5C,OAAQ,MAA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CARD,CAQE,OAAOxD,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,2BADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,sBAFT,EAGF;QACIY,KADJ;QAEIpB;MAFJ,CAHE,CAAN;IAQH;EACJ,CA/BD;;EAiCA,OAAO;IACHH,gBADG;IAEHoB,gBAFG;IAGHF,gBAHG;IAIHmB,eAJG;IAKHwB,aALG;IAMHrE,4BANG;IAOHM;EAPG,CAAP;AASH,CAnUM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Entity, Table } from "dynamodb-toolbox";
|
|
2
2
|
import { FormBuilderSystemStorageOperations } from "../../types";
|
|
3
|
-
export interface
|
|
3
|
+
export interface CreateSystemStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
table: Table;
|
|
6
6
|
}
|
|
7
|
-
export declare const createSystemStorageOperations: (params:
|
|
7
|
+
export declare const createSystemStorageOperations: (params: CreateSystemStorageOperationsParams) => FormBuilderSystemStorageOperations;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createSystemStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
13
13
|
|
|
14
14
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
15
|
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
-
|
|
20
16
|
const createSystemStorageOperations = params => {
|
|
21
17
|
const {
|
|
22
18
|
entity
|
|
@@ -46,7 +42,7 @@ const createSystemStorageOperations = params => {
|
|
|
46
42
|
const keys = createKeys(system);
|
|
47
43
|
|
|
48
44
|
try {
|
|
49
|
-
await entity.put(
|
|
45
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
50
46
|
return system;
|
|
51
47
|
} catch (ex) {
|
|
52
48
|
throw new _error.default(ex.message || "Could not create the system record by given keys.", ex.code || "CREATE_SYSTEM_ERROR", {
|
|
@@ -82,7 +78,7 @@ const createSystemStorageOperations = params => {
|
|
|
82
78
|
const keys = createKeys(system);
|
|
83
79
|
|
|
84
80
|
try {
|
|
85
|
-
await entity.put(
|
|
81
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
86
82
|
return system;
|
|
87
83
|
} catch (ex) {
|
|
88
84
|
throw new _error.default(ex.message || "Could not update the system record by given keys.", ex.code || "UPDATE_SYSTEM_ERROR", {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSystemStorageOperations","params","entity","createSystemPartitionKey","tenant","createSystemSortKey","createKeys","PK","SK","createSystem","system","keys","put","ex","WebinyError","message","code","getSystem","result","get","Item","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\";\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 result = await entity.get(keys);\n if (!result || !result.Item) {\n return null;\n }\n return cleanupItem(entity, result.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;;AAOO,MAAMA,6BAA6B,GACtCC,MADyC,IAEJ;EACrC,MAAM;IAAEC;EAAF,IAAaD,MAAnB;;EAEA,MAAME,wBAAwB,GAAG,CAAC;IAAEC;EAAF,CAAD,KAA2D;IACxF,OAAQ,KAAIA,MAAO,SAAnB;EACH,CAFD;;EAIA,MAAMC,mBAAmB,GAAG,MAAc;IACtC,OAAO,IAAP;EACH,CAFD;;EAIA,MAAMC,UAAU,GAAIL,MAAD,IAA+C;IAC9D,OAAO;MACHM,EAAE,EAAEJ,wBAAwB,CAACF,MAAD,CADzB;MAEHO,EAAE,EAAEH,mBAAmB;IAFpB,CAAP;EAIH,CALD;;EAOA,MAAMI,YAAY,GAAG,MACjBR,MADiB,IAEC;IAClB,MAAM;MAAES;IAAF,IAAaT,MAAnB;IACA,MAAMU,IAAI,GAAGL,UAAU,CAACI,MAAD,CAAvB;;IAEA,IAAI;MACA,MAAMR,MAAM,CAACU,GAAP,6DACCF,MADD,GAECC,IAFD,EAAN;MAIA,OAAOD,MAAP;IACH,CAND,CAME,OAAOG,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,mDADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,qBAFT,EAGF;QACIL,IADJ;QAEID;MAFJ,CAHE,CAAN;IAQH;EACJ,CAtBD;;EAwBA,MAAMO,SAAS,GAAG,MACdhB,MADc,IAEW;IACzB,MAAMU,IAAI,GAAGL,UAAU,CAACL,MAAD,CAAvB;;IAEA,IAA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