@webiny/api-headless-cms-ddb-es 5.41.4 → 5.42.0-beta.0

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 (31) hide show
  1. package/configurations.js.map +1 -1
  2. package/dynamoDb/storage/longText.js.map +1 -1
  3. package/dynamoDb/storage/richText.js.map +1 -1
  4. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  5. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  6. package/elasticsearch/search/refSearch.js.map +1 -1
  7. package/helpers/entryIndexHelpers.js.map +1 -1
  8. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  9. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  10. package/operations/entry/dataLoader/index.js.map +1 -1
  11. package/operations/entry/dataLoaders.js.map +1 -1
  12. package/operations/entry/elasticsearch/fields.js.map +1 -1
  13. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  14. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  15. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
  16. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
  17. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
  18. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  19. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  20. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  21. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -1
  22. package/operations/entry/elasticsearch/sort.js.map +1 -1
  23. package/operations/entry/index.js.map +1 -1
  24. package/operations/entry/keys.js.map +1 -1
  25. package/operations/entry/recordType.js.map +1 -1
  26. package/operations/entry/transformations/index.js.map +1 -1
  27. package/operations/group/index.js.map +1 -1
  28. package/operations/model/index.js.map +1 -1
  29. package/operations/system/index.js.map +1 -1
  30. package/package.json +26 -31
  31. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_transformEntryKeys","require","_transformEntryToIndex","_plugins","_modifyEntryValues","_apiElasticsearch","_recordType","_error","_interopRequireDefault","createTransformer","params","plugins","model","entry","baseEntry","storageEntry","baseStorageEntry","transformedToIndex","initialTransformedEntryToIndex","undefined","transformedEntryKeys","transformedEntryToIndex","modifiedEntryValues","elasticsearchLatestEntry","elasticsearchPublishedEntry","modifierPlugins","byType","CmsEntryElasticsearchValuesModifier","type","filter","pl","canModify","modelId","modifyEntryValues","WebinyError","modifiedEntry","modifyEntryValuesCallable","modifiedStorageEntry","transformEntryKeys","transformToIndex","length","result","transformEntryToIndex","getElasticsearchLatestEntryData","compress","latest","TYPE","createLatestRecordType","__type","getElasticsearchPublishedEntryData","published","createPublishedRecordType","exports"],"sources":["index.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsEntry,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { transformEntryKeys } from \"./transformEntryKeys\";\nimport { CmsIndexEntry } from \"~/types\";\nimport { transformEntryToIndex } from \"~/operations/entry/transformations/transformEntryToIndex\";\nimport { CmsEntryElasticsearchValuesModifier } from \"~/plugins\";\nimport { modifyEntryValues as modifyEntryValuesCallable } from \"~/operations/entry/transformations/modifyEntryValues\";\nimport { compress } from \"@webiny/api-elasticsearch\";\nimport { createLatestRecordType, createPublishedRecordType } from \"~/operations/entry/recordType\";\nimport WebinyError from \"@webiny/error\";\n\ninterface BaseTransformerParams {\n plugins: PluginsContainer;\n model: StorageOperationsCmsModel;\n}\n\ninterface EntryTransformerParams extends BaseTransformerParams {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n transformedToIndex?: never;\n}\n\ninterface TransformedEntryTransformerParams extends BaseTransformerParams {\n entry?: never;\n storageEntry?: never;\n transformedToIndex: CmsIndexEntry;\n}\n\ninterface TransformedKeysEntry {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\ninterface ModifiedEntryValues {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\ninterface TransformerResult {\n transformEntryKeys: () => TransformedKeysEntry;\n transformToIndex: () => CmsIndexEntry;\n getElasticsearchLatestEntryData: () => Promise<Record<string, any>>;\n getElasticsearchPublishedEntryData: () => Promise<Record<string, any>>;\n}\n\nexport const createTransformer = (\n params: EntryTransformerParams | TransformedEntryTransformerParams\n): TransformerResult => {\n const {\n plugins,\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry,\n transformedToIndex: initialTransformedEntryToIndex = undefined\n } = params;\n\n let transformedEntryKeys: TransformedKeysEntry | undefined = undefined;\n let transformedEntryToIndex: CmsIndexEntry | undefined = initialTransformedEntryToIndex;\n let modifiedEntryValues: ModifiedEntryValues | undefined = undefined;\n let elasticsearchLatestEntry: any = undefined;\n let elasticsearchPublishedEntry: any = undefined;\n\n const modifierPlugins = plugins\n .byType<CmsEntryElasticsearchValuesModifier>(CmsEntryElasticsearchValuesModifier.type)\n .filter(pl => pl.canModify(model.modelId));\n\n const modifyEntryValues = () => {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (modifiedEntryValues) {\n return modifiedEntryValues;\n }\n const modifiedEntry = modifyEntryValuesCallable({\n plugins: modifierPlugins,\n model,\n entry: baseEntry\n });\n const modifiedStorageEntry = modifyEntryValuesCallable({\n plugins: modifierPlugins,\n model,\n entry: baseStorageEntry\n });\n\n return (modifiedEntryValues = transformEntryKeys({\n model,\n entry: modifiedEntry,\n storageEntry: modifiedStorageEntry\n }));\n };\n\n return {\n transformEntryKeys: function () {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (transformedEntryKeys) {\n return transformedEntryKeys;\n }\n return (transformedEntryKeys = transformEntryKeys({\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry\n }));\n },\n transformToIndex: function () {\n if (transformedEntryToIndex) {\n return transformedEntryToIndex;\n }\n let entry: CmsEntry;\n let storageEntry: CmsStorageEntry;\n /**\n * In case there are value modifier plugins, we need to\n * - run modifiers\n * - transform keys\n */\n if (modifierPlugins.length > 0) {\n const result = modifyEntryValues();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n // In case there are no modifier plugins, just transform the keys - or used already transformed.\n else {\n const result = this.transformEntryKeys();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n return (transformedEntryToIndex = transformEntryToIndex({\n plugins,\n model,\n entry,\n storageEntry\n }));\n },\n getElasticsearchLatestEntryData: async function () {\n if (elasticsearchLatestEntry) {\n return elasticsearchLatestEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchLatestEntry = await compress(plugins, {\n ...entry,\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n }));\n },\n getElasticsearchPublishedEntryData: async function () {\n if (elasticsearchPublishedEntry) {\n return elasticsearchPublishedEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchPublishedEntry = await compress(plugins, {\n ...entry,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n }));\n }\n };\n};\n"],"mappings":";;;;;;;AAMA,IAAAA,mBAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAC,sBAAA,CAAAP,OAAA;AAoCO,MAAMQ,iBAAiB,GAC1BC,MAAkE,I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AI;QACZC,IAAI,EAAE,IAAAC,kCAAsB,EAAC,CAAC;QAC9BC,MAAM,EAAE,IAAAD,kCAAsB,EAAC;MACnC,CAAC,CAAC;IACN,CAAC;IACDE,kCAAkC,EAAE,eAAAA,CAAA,EAAkB;MAClD,IAAIzB,2BAA2B,EAAE;QAC7B,OAAOA,2BAA2B;MACtC;MACA,MAAMX,KAAK,GAAG,IAAI,CAAC0B,gBAAgB,CAAC,CAAC;MAErC,OAAQf,2BAA2B,GAAG,MAAM,IAAAoB,0BAAQ,EAACjC,OAAO,EAAE;QAC1D,GAAGE,KAAK;QACRqC,SAAS,EAAE,IAAI;QACfJ,IAAI,EAAE,IAAAK,qCAAyB,EAAC,CAAC;QACjCH,MAAM,EAAE,IAAAG,qCAAyB,EAAC;MACtC,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAA3C,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_transformEntryKeys","require","_transformEntryToIndex","_plugins","_modifyEntryValues","_apiElasticsearch","_recordType","_error","_interopRequireDefault","createTransformer","params","plugins","model","entry","baseEntry","storageEntry","baseStorageEntry","transformedToIndex","initialTransformedEntryToIndex","undefined","transformedEntryKeys","transformedEntryToIndex","modifiedEntryValues","elasticsearchLatestEntry","elasticsearchPublishedEntry","modifierPlugins","byType","CmsEntryElasticsearchValuesModifier","type","filter","pl","canModify","modelId","modifyEntryValues","WebinyError","modifiedEntry","modifyEntryValuesCallable","modifiedStorageEntry","transformEntryKeys","transformToIndex","length","result","transformEntryToIndex","getElasticsearchLatestEntryData","compress","latest","TYPE","createLatestRecordType","__type","getElasticsearchPublishedEntryData","published","createPublishedRecordType","exports"],"sources":["index.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsEntry,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { transformEntryKeys } from \"./transformEntryKeys\";\nimport { CmsIndexEntry } from \"~/types\";\nimport { transformEntryToIndex } from \"~/operations/entry/transformations/transformEntryToIndex\";\nimport { CmsEntryElasticsearchValuesModifier } from \"~/plugins\";\nimport { modifyEntryValues as modifyEntryValuesCallable } from \"~/operations/entry/transformations/modifyEntryValues\";\nimport { compress } from \"@webiny/api-elasticsearch\";\nimport { createLatestRecordType, createPublishedRecordType } from \"~/operations/entry/recordType\";\nimport WebinyError from \"@webiny/error\";\n\ninterface BaseTransformerParams {\n plugins: PluginsContainer;\n model: StorageOperationsCmsModel;\n}\n\ninterface EntryTransformerParams extends BaseTransformerParams {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n transformedToIndex?: never;\n}\n\ninterface TransformedEntryTransformerParams extends BaseTransformerParams {\n entry?: never;\n storageEntry?: never;\n transformedToIndex: CmsIndexEntry;\n}\n\ninterface TransformedKeysEntry {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\ninterface ModifiedEntryValues {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\ninterface TransformerResult {\n transformEntryKeys: () => TransformedKeysEntry;\n transformToIndex: () => CmsIndexEntry;\n getElasticsearchLatestEntryData: () => Promise<Record<string, any>>;\n getElasticsearchPublishedEntryData: () => Promise<Record<string, any>>;\n}\n\nexport const createTransformer = (\n params: EntryTransformerParams | TransformedEntryTransformerParams\n): TransformerResult => {\n const {\n plugins,\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry,\n transformedToIndex: initialTransformedEntryToIndex = undefined\n } = params;\n\n let transformedEntryKeys: TransformedKeysEntry | undefined = undefined;\n let transformedEntryToIndex: CmsIndexEntry | undefined = initialTransformedEntryToIndex;\n let modifiedEntryValues: ModifiedEntryValues | undefined = undefined;\n let elasticsearchLatestEntry: any = undefined;\n let elasticsearchPublishedEntry: any = undefined;\n\n const modifierPlugins = plugins\n .byType<CmsEntryElasticsearchValuesModifier>(CmsEntryElasticsearchValuesModifier.type)\n .filter(pl => pl.canModify(model.modelId));\n\n const modifyEntryValues = () => {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (modifiedEntryValues) {\n return modifiedEntryValues;\n }\n const modifiedEntry = modifyEntryValuesCallable({\n plugins: modifierPlugins,\n model,\n entry: baseEntry\n });\n const modifiedStorageEntry = modifyEntryValuesCallable({\n plugins: modifierPlugins,\n model,\n entry: baseStorageEntry\n });\n\n return (modifiedEntryValues = transformEntryKeys({\n model,\n entry: modifiedEntry,\n storageEntry: modifiedStorageEntry\n }));\n };\n\n return {\n transformEntryKeys: function () {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (transformedEntryKeys) {\n return transformedEntryKeys;\n }\n return (transformedEntryKeys = transformEntryKeys({\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry\n }));\n },\n transformToIndex: function () {\n if (transformedEntryToIndex) {\n return transformedEntryToIndex;\n }\n let entry: CmsEntry;\n let storageEntry: CmsStorageEntry;\n /**\n * In case there are value modifier plugins, we need to\n * - run modifiers\n * - transform keys\n */\n if (modifierPlugins.length > 0) {\n const result = modifyEntryValues();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n // In case there are no modifier plugins, just transform the keys - or used already transformed.\n else {\n const result = this.transformEntryKeys();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n return (transformedEntryToIndex = transformEntryToIndex({\n plugins,\n model,\n entry,\n storageEntry\n }));\n },\n getElasticsearchLatestEntryData: async function () {\n if (elasticsearchLatestEntry) {\n return elasticsearchLatestEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchLatestEntry = await compress(plugins, {\n ...entry,\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n }));\n },\n getElasticsearchPublishedEntryData: async function () {\n if (elasticsearchPublishedEntry) {\n return elasticsearchPublishedEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchPublishedEntry = await compress(plugins, {\n ...entry,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n }));\n }\n };\n};\n"],"mappings":";;;;;;;AAMA,IAAAA,mBAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAC,sBAAA,CAAAP,OAAA;AAoCO,MAAMQ,iBAAiB,GAC1BC,MAAkE,IAC9C;EACpB,MAAM;IACFC,OAAO;IACPC,KAAK;IACLC,KAAK,EAAEC,SAAS;IAChBC,YAAY,EAAEC,gBAAgB;IAC9BC,kBAAkB,EAAEC,8BAA8B,GAAGC;EACzD,CAAC,GAAGT,MAAM;EAEV,IAAIU,oBAAsD,GAAGD,SAAS;EACtE,IAAIE,uBAAkD,GAAGH,8BAA8B;EACvF,IAAII,mBAAoD,GAAGH,SAAS;EACpE,IAAII,wBAA6B,GAAGJ,SAAS;EAC7C,IAAIK,2BAAgC,GAAGL,SAAS;EAEhD,MAAMM,eAAe,GAAGd,OAAO,CAC1Be,MAAM,CAAsCC,4CAAmC,CAACC,IAAI,CAAC,CACrFC,MAAM,CAACC,EAAE,IAAIA,EAAE,CAACC,SAAS,CAACnB,KAAK,CAACoB,OAAO,CAAC,CAAC;EAE9C,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;IAC5B,IAAIf,8BAA8B,IAAI,CAACJ,SAAS,EAAE;MAC9C,MAAM,IAAIoB,cAAW,CACjB,gFAAgF,EAChF,oBAAoB,EACpB;QACIrB,KAAK,EAAEK;MACX,CACJ,CAAC;IACL;IACA,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AG,IAAI,CAACH,kBAAkB,CAAC,CAAC;QACxCzB,KAAK,GAAG4B,MAAM,CAAC5B,KAAK;QACpBE,YAAY,GAAG0B,MAAM,CAAC1B,YAAY;MACtC;MACA,OAAQM,uBAAuB,GAAG,IAAAqB,4CAAqB,EAAC;QACpD/B,OAAO;QACPC,KAAK;QACLC,KAAK;QACLE;MACJ,CAAC,CAAC;IACN,CAAC;IACD4B,+BAA+B,EAAE,eAAAA,CAAA,EAAkB;MAC/C,IAAIpB,wBAAwB,EAAE;QAC1B,OAAOA,wBAAwB;MACnC;MACA,MAAMV,KAAK,GAAG,IAAI,CAAC0B,gBAAgB,CAAC,CAAC;MAErC,OAAQhB,wBAAwB,GAAG,MAAM,IAAAqB,0BAAQ,EAACjC,OAAO,EAAE;QACvD,GAAGE,KAAK;QACRgC,MAAM,EAAE,IAAI;QACZC,IAAI,EAAE,IAAAC,kCAAsB,EAAC,CAAC;QAC9BC,MAAM,EAAE,IAAAD,kCAAsB,EAAC;MACnC,CAAC,CAAC;IACN,CAAC;IACDE,kCAAkC,EAAE,eAAAA,CAAA,EAAkB;MAClD,IAAIzB,2BAA2B,EAAE;QAC7B,OAAOA,2BAA2B;MACtC;MACA,MAAMX,KAAK,GAAG,IAAI,CAAC0B,gBAAgB,CAAC,CAAC;MAErC,OAAQf,2BAA2B,GAAG,MAAM,IAAAoB,0BAAQ,EAACjC,OAAO,EAAE;QAC1D,GAAGE,KAAK;QACRqC,SAAS,EAAE,IAAI;QACfJ,IAAI,EAAE,IAAAK,qCAAyB,EAAC,CAAC;QACjCH,MAAM,EAAE,IAAAG,qCAAyB,EAAC;MACtC,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAA3C,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_get","_query","_filter","_ValueFilterPlugin","_sort","_dbDynamodb","createPartitionKey","params","tenant","locale","createSortKeys","id","createKeys","PK","SK","createType","createGroupsStorageOperations","entity","plugins","filteringPlugins","byType","ValueFilterPlugin","type","length","WebinyError","create","group","keys","put","item","TYPE","ex","message","code","error","update","deleteGroup","deleteItem","get","getClean","list","sort","where","initialWhere","queryAllParams","partitionKey","options","gte","records","queryAll","filteredItems","cleanupItems","filterItems","items","fields","sortItems","delete","exports"],"sources":["index.ts"],"sourcesContent":["import {\n CmsGroup,\n CmsGroupStorageOperations,\n CmsGroupStorageOperationsCreateParams,\n CmsGroupStorageOperationsDeleteParams,\n CmsGroupStorageOperationsGetParams,\n CmsGroupStorageOperationsListParams,\n CmsGroupStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { deleteItem, put, cleanupItems } from \"@webiny/db-dynamodb\";\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\nconst createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CMG`;\n};\n\ninterface SortKeyParams {\n id: string;\n}\nconst createSortKeys = (params: SortKeyParams): string => {\n const { id } = params;\n return id;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKeys(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.group\";\n};\n\nexport interface CreateGroupsStorageOperationsParams {\n entity: Entity<any>;\n plugins: PluginsContainer;\n}\nexport const createGroupsStorageOperations = (\n params: CreateGroupsStorageOperationsParams\n): CmsGroupStorageOperations => {\n const { entity, plugins } = params;\n\n const filteringPlugins = plugins.byType<ValueFilterPlugin>(ValueFilterPlugin.type);\n if (filteringPlugins.length === 0) {\n throw new WebinyError(\n \"DynamoDB filtering plugins not loaded.\",\n \"MISSING_DYNAMODB_FILTERING_PLUGINS\"\n );\n }\n\n const create = async (params: CmsGroupStorageOperationsCreateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await put({\n entity,\n item: {\n ...group,\n TYPE: createType(),\n ...keys\n }\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const update = async (params: CmsGroupStorageOperationsUpdateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await put({\n entity,\n item: {\n ...group,\n TYPE: createType(),\n ...keys\n }\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const deleteGroup = async (params: CmsGroupStorageOperationsDeleteParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await deleteItem({\n entity,\n keys\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const get = async (params: CmsGroupStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n return await getClean<CmsGroup>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n };\n const list = async (params: CmsGroupStorageOperationsListParams) => {\n const { sort, where: initialWhere } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(initialWhere),\n options: {\n gte: \" \"\n }\n };\n\n let records: CmsGroup[] = [];\n try {\n records = await queryAll(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n sort,\n where: initialWhere\n }\n );\n }\n\n const where: Partial<CmsGroupStorageOperationsListParams[\"where\"]> = {\n ...initialWhere\n };\n delete where[\"tenant\"];\n delete where[\"locale\"];\n\n const filteredItems = cleanupItems(\n entity,\n filterItems({\n items: records,\n where,\n fields: [],\n plugins\n })\n );\n\n if (!sort || sort.length === 0 || filteredItems.length === 0) {\n return filteredItems;\n }\n return sortItems({\n items: filteredItems,\n sort,\n fields: []\n });\n };\n\n return {\n create,\n update,\n delete: deleteGroup,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;AAUA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAMA,MAAMO,kBAAkB,GAAIC,MAA0B,IAAa;EAC/D,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAQ,KAAIC,MAAO,MAAKC,MAAO,UAAS;AAC5C,CAAC;AAKD,MAAMC,cAAc,GAAIH,MAAqB,IAAa;EACtD,MAAM;IAAEI;EAAG,CAAC,GAAGJ,MAAM;EACrB,OAAOI,EAAE;AACb,CAAC;AAMD,MAAMC,UAAU,GAAIL,MAA0C,IAAW;EACrE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEJ,cAAc,CAACH,MAAM;EAC7B,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAGA,CAAA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RequireDefault","require","_get","_query","_filter","_ValueFilterPlugin","_sort","_dbDynamodb","createPartitionKey","params","tenant","locale","createSortKeys","id","createKeys","PK","SK","createType","createGroupsStorageOperations","entity","plugins","filteringPlugins","byType","ValueFilterPlugin","type","length","WebinyError","create","group","keys","put","item","TYPE","ex","message","code","error","update","deleteGroup","deleteItem","get","getClean","list","sort","where","initialWhere","queryAllParams","partitionKey","options","gte","records","queryAll","filteredItems","cleanupItems","filterItems","items","fields","sortItems","delete","exports"],"sources":["index.ts"],"sourcesContent":["import {\n CmsGroup,\n CmsGroupStorageOperations,\n CmsGroupStorageOperationsCreateParams,\n CmsGroupStorageOperationsDeleteParams,\n CmsGroupStorageOperationsGetParams,\n CmsGroupStorageOperationsListParams,\n CmsGroupStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { deleteItem, put, cleanupItems } from \"@webiny/db-dynamodb\";\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\nconst createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CMG`;\n};\n\ninterface SortKeyParams {\n id: string;\n}\nconst createSortKeys = (params: SortKeyParams): string => {\n const { id } = params;\n return id;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKeys(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.group\";\n};\n\nexport interface CreateGroupsStorageOperationsParams {\n entity: Entity<any>;\n plugins: PluginsContainer;\n}\nexport const createGroupsStorageOperations = (\n params: CreateGroupsStorageOperationsParams\n): CmsGroupStorageOperations => {\n const { entity, plugins } = params;\n\n const filteringPlugins = plugins.byType<ValueFilterPlugin>(ValueFilterPlugin.type);\n if (filteringPlugins.length === 0) {\n throw new WebinyError(\n \"DynamoDB filtering plugins not loaded.\",\n \"MISSING_DYNAMODB_FILTERING_PLUGINS\"\n );\n }\n\n const create = async (params: CmsGroupStorageOperationsCreateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await put({\n entity,\n item: {\n ...group,\n TYPE: createType(),\n ...keys\n }\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const update = async (params: CmsGroupStorageOperationsUpdateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await put({\n entity,\n item: {\n ...group,\n TYPE: createType(),\n ...keys\n }\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const deleteGroup = async (params: CmsGroupStorageOperationsDeleteParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await deleteItem({\n entity,\n keys\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const get = async (params: CmsGroupStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n return await getClean<CmsGroup>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n };\n const list = async (params: CmsGroupStorageOperationsListParams) => {\n const { sort, where: initialWhere } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(initialWhere),\n options: {\n gte: \" \"\n }\n };\n\n let records: CmsGroup[] = [];\n try {\n records = await queryAll(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n sort,\n where: initialWhere\n }\n );\n }\n\n const where: Partial<CmsGroupStorageOperationsListParams[\"where\"]> = {\n ...initialWhere\n };\n delete where[\"tenant\"];\n delete where[\"locale\"];\n\n const filteredItems = cleanupItems(\n entity,\n filterItems({\n items: records,\n where,\n fields: [],\n plugins\n })\n );\n\n if (!sort || sort.length === 0 || filteredItems.length === 0) {\n return filteredItems;\n }\n return sortItems({\n items: filteredItems,\n sort,\n fields: []\n });\n };\n\n return {\n create,\n update,\n delete: deleteGroup,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;AAUA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAMA,MAAMO,kBAAkB,GAAIC,MAA0B,IAAa;EAC/D,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAO,KAAKC,MAAM,MAAMC,MAAM,UAAU;AAC5C,CAAC;AAKD,MAAMC,cAAc,GAAIH,MAAqB,IAAa;EACtD,MAAM;IAAEI;EAAG,CAAC,GAAGJ,MAAM;EACrB,OAAOI,EAAE;AACb,CAAC;AAMD,MAAMC,UAAU,GAAIL,MAA0C,IAAW;EACrE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9B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AACL,CAAC;AAACiB,OAAA,CAAAzC,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_configurations","_cleanup","_query","_dbDynamodb","createPartitionKey","params","tenant","locale","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","es","keys","error","put","item","cleanupItem","TYPE","ex","indices","delete","ignore_unavailable","WebinyError","dynamodbError","elasticsearchError","update","message","code","deleteModel","deleteItem","get","getClean","list","where","queryAllParams","partitionKey","options","gte","queryAllClean","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { configurations } from \"~/configurations\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAllClean, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { deleteItem, getClean, put } from \"@webiny/db-dynamodb\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: Entity<any>;\n elasticsearch: Client;\n}\n\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await deleteItem({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n return await getClean<CmsModel>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n };\n try {\n return await queryAllClean<CmsModel>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAOA,MAAMK,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAQ,KAAIC,MAAO,MAAKC,MAAO,SAAQ;AAC3C,CAAC;AAMD,MAAMC,aAAa,GAAIH,MAAqB,IAAa;EACrD,OAAOA,MAAM,CAACI,OAAO;AACzB,CAAC;AAOD,MAAMC,UAAU,GAAIL,MAA2C,IAAW;EACtE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEJ,aAAa,CAACH,MAAM;EAC5B,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAGA,CAAA,KAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAOM,MAAMC,6BAA6B,GACtCT,MAA2C,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MiB,IAAI,GAAGZ,UAAU,CAACL,MAAM,CAAC;IAE/B,IAAI;MACA,OAAO,MAAM,IAAAoC,oBAAQ,EAAW;QAC5B1B,MAAM;QACNO;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOM,EAAE,EAAE;MACT,MAAM,IAAII,cAAW,CACjBJ,EAAE,CAACQ,OAAO,IAAI,sBAAsB,EACpCR,EAAE,CAACS,IAAI,IAAI,iBAAiB,EAC5B;QACId,KAAK,EAAEK,EAAE;QACTN;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMoB,IAAI,GAAG,MAAOrC,MAA2C,IAAK;IAChE,MAAM;MAAEsC;IAAM,CAAC,GAAGtC,MAAM;IACxB,MAAMuC,cAA8B,GAAG;MACnC7B,MAAM;MACN8B,YAAY,EAAEzC,kBAAkB,CAACuC,KAAK,CAAC;MACvCG,OAAO,EAAE;QACLC,GAAG,EAAE;MACT;IACJ,CAAC;IACD,IAAI;MACA,OAAO,MAAM,IAAAC,oBAAa,EAAWJ,cAAc,CAAC;IACxD,CAAC,CAAC,OAAOhB,EAAE,EAAE;MACT,MAAM,IAAII,cAAW,CACjBJ,EAAE,CAACQ,OAAO,IAAI,wBAAwB,EACtCR,EAAE,CAACS,IAAI,IAAI,kBAAkB,EAC7B;QACId,KAAK,EAAEK,EAAE;QACTiB,YAAY,EAAED,cAAc,CAACC;MACjC,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACH5B,MAAM;IACNkB,MAAM;IACNL,MAAM,EAAEQ,WAAW;IACnBE,GAAG;IACHE;EACJ,CAAC;AACL,CAAC;AAACO,OAAA,CAAAnC,6BAAA,GAAAA,6BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_configurations","_cleanup","_query","_dbDynamodb","createPartitionKey","params","tenant","locale","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","es","keys","error","put","item","cleanupItem","TYPE","ex","indices","delete","ignore_unavailable","WebinyError","dynamodbError","elasticsearchError","update","message","code","deleteModel","deleteItem","get","getClean","list","where","queryAllParams","partitionKey","options","gte","queryAllClean","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { configurations } from \"~/configurations\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAllClean, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { deleteItem, getClean, put } from \"@webiny/db-dynamodb\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: Entity<any>;\n elasticsearch: Client;\n}\n\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await deleteItem({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n return await getClean<CmsModel>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n };\n try {\n return await queryAllClean<CmsModel>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAOA,MAAMK,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAO,KAAKC,MAAM,MAAMC,MAAM,SAAS;AAC3C,CAAC;AAMD,MAAMC,aAAa,GAAIH,MAAqB,IAAa;EACrD,OAAOA,MAAM,CAACI,OAAO;AACzB,CAAC;AAOD,MAAMC,UAAU,GAAIL,MAA2C,IAAW;EACtE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEJ,aAAa,CAACH,MAAM;EAC5B,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAGA,CAAA,KAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAOM,MAAMC,6BAA6B,GACtCT,MAA2C,IACf;EAC5B,MAAM;IAAEU,MAAM;IAAEC;EAAc,CAAC,GAAGX,MAAM;EAExC,MAAMY,MAAM,GAAG,MAAOZ,MAA6C,IAAK;IACpE,MAAM;MAAEa;IAAM,CAAC,GAAGb,MAAM;IAExB,MAAM;MAAEc;IAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;MAChCH;IACJ,CAAC,CAAC;IAEF,MAAMI,IAAI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IAAI,iBAAiB,EAC5B;QACId,KAAK,EAAEK,EAAE;QACTN;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMoB,IAAI,GAAG,MAAOrC,MAA2C,IAAK;IAChE,MAAM;MAAEsC;IAAM,CAAC,GAAGtC,MAAM;IACxB,MAAMuC,cAA8B,GAAG;MACnC7B,MAAM;MACN8B,YAAY,EAAEzC,kBAAkB,CAACuC,KAAK,CAAC;MACvCG,OAAO,EAAE;QACLC,GAAG,EAAE;MACT;IACJ,CAAC;IACD,IAAI;MACA,OAAO,MAAM,IAAAC,oBAAa,EAAWJ,cAAc,CAAC;IACxD,CAAC,CAAC,OAAOhB,EAAE,EAAE;MACT,MAAM,IAAII,cAAW,CACjBJ,EAAE,CAACQ,OAAO,IAAI,wBAAwB,EACtCR,EAAE,CAACS,IAAI,IAAI,kBAAkB,EAC7B;QACId,KAAK,EAAEK,EAAE;QACTiB,YAAY,EAAED,cAAc,CAACC;MACjC,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACH5B,MAAM;IACNkB,MAAM;IACNL,MAAM,EAAEQ,WAAW;IACnBE,GAAG;IACHE;EACJ,CAAC;AACL,CAAC;AAACO,OAAA,CAAAnC,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_get","_dbDynamodb","createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","item","ex","WebinyError","message","code","error","update","get","getClean","exports"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n return await getClean<CmsSystem>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":";;;;;;;AAQA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,MAAMG,kBAAkB,GAA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MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,0BAA0B,EACxCF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACTJ,MAAM;QACNC;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMS,GAAG,GAAG,MAAOhB,MAA2C,IAAK;IAC/D,MAAMO,IAAI,GAAGR,UAAU,CAACC,MAAM,CAAC;IAE/B,IAAI;MACA,OAAO,MAAM,IAAAiB,aAAQ,EAAY;QAC7Bb,MAAM;QACNG;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,uBAAuB,EACrCF,EAAE,CAACG,IAAI,IAAI,kBAAkB,EAC7B;QACIC,KAAK,EAAEJ,EAAE;QACTH;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHF,MAAM;IACNU,MAAM;IACNC;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAAf,6BAAA,GAAAA,6BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_get","_dbDynamodb","createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","item","ex","WebinyError","message","code","error","update","get","getClean","exports"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n return await getClean<CmsSystem>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":";;;;;;;AAQA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,MAAMG,kBAAkB,GAAGA,CAAC;EAAEC;AAA2B,CAAC,KAAa;EACnE,OAAO,KAAKA,MAAM,CAACC,WAAW,CAAC,CAAC,SAAS;A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qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACTJ,MAAM;QACNC;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMS,GAAG,GAAG,MAAOhB,MAA2C,IAAK;IAC/D,MAAMO,IAAI,GAAGR,UAAU,CAACC,MAAM,CAAC;IAE/B,IAAI;MACA,OAAO,MAAM,IAAAiB,aAAQ,EAAY;QAC7Bb,MAAM;QACNG;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,uBAAuB,EACrCF,EAAE,CAACG,IAAI,IAAI,kBAAkB,EAC7B;QACIC,KAAK,EAAEJ,EAAE;QACTH;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHF,MAAM;IACNU,MAAM;IACNC;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAAf,6BAAA,GAAAA,6BAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb-es",
3
- "version": "5.41.4",
3
+ "version": "5.42.0-beta.0",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-headless-cms",
@@ -26,43 +26,38 @@
26
26
  ],
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@babel/runtime": "7.24.1",
30
- "@webiny/api": "5.41.4",
31
- "@webiny/api-elasticsearch": "5.41.4",
32
- "@webiny/api-elasticsearch-tasks": "5.41.4",
33
- "@webiny/api-headless-cms": "5.41.4",
34
- "@webiny/aws-sdk": "5.41.4",
35
- "@webiny/db-dynamodb": "5.41.4",
36
- "@webiny/error": "5.41.4",
37
- "@webiny/handler-db": "5.41.4",
38
- "@webiny/plugins": "5.41.4",
39
- "@webiny/utils": "5.41.4",
40
- "dataloader": "2.2.1",
29
+ "@webiny/api": "5.42.0-beta.0",
30
+ "@webiny/api-elasticsearch": "5.42.0-beta.0",
31
+ "@webiny/api-elasticsearch-tasks": "5.42.0-beta.0",
32
+ "@webiny/api-headless-cms": "5.42.0-beta.0",
33
+ "@webiny/aws-sdk": "5.42.0-beta.0",
34
+ "@webiny/db-dynamodb": "5.42.0-beta.0",
35
+ "@webiny/error": "5.42.0-beta.0",
36
+ "@webiny/handler-db": "5.42.0-beta.0",
37
+ "@webiny/plugins": "5.42.0-beta.0",
38
+ "@webiny/utils": "5.42.0-beta.0",
39
+ "dataloader": "2.2.3",
41
40
  "jsonpack": "1.1.5",
42
41
  "lodash": "4.17.21"
43
42
  },
44
43
  "devDependencies": {
45
- "@babel/cli": "7.24.1",
46
- "@babel/core": "7.24.3",
47
- "@babel/preset-env": "7.24.3",
48
44
  "@elastic/elasticsearch": "7.12.0",
49
- "@types/jsonpack": "1.1.2",
50
- "@webiny/api-dynamodb-to-elasticsearch": "5.41.4",
51
- "@webiny/api-i18n": "5.41.4",
52
- "@webiny/api-security": "5.41.4",
53
- "@webiny/api-tenancy": "5.41.4",
54
- "@webiny/api-wcp": "5.41.4",
55
- "@webiny/cli": "5.41.4",
56
- "@webiny/handler": "5.41.4",
57
- "@webiny/handler-aws": "5.41.4",
58
- "@webiny/handler-graphql": "5.41.4",
59
- "@webiny/project-utils": "5.41.4",
60
- "@webiny/tasks": "5.41.4",
45
+ "@types/jsonpack": "1.1.6",
46
+ "@webiny/api-dynamodb-to-elasticsearch": "5.42.0-beta.0",
47
+ "@webiny/api-i18n": "5.42.0-beta.0",
48
+ "@webiny/api-security": "5.42.0-beta.0",
49
+ "@webiny/api-tenancy": "5.42.0-beta.0",
50
+ "@webiny/api-wcp": "5.42.0-beta.0",
51
+ "@webiny/cli": "5.42.0-beta.0",
52
+ "@webiny/handler": "5.42.0-beta.0",
53
+ "@webiny/handler-aws": "5.42.0-beta.0",
54
+ "@webiny/handler-graphql": "5.42.0-beta.0",
55
+ "@webiny/project-utils": "5.42.0-beta.0",
56
+ "@webiny/tasks": "5.42.0-beta.0",
61
57
  "jest": "29.7.0",
62
58
  "jest-dynalite": "3.6.1",
63
59
  "prettier": "2.8.8",
64
- "rimraf": "5.0.5",
65
- "sinon": "9.2.4",
60
+ "rimraf": "6.0.1",
66
61
  "ttypescript": "1.5.15",
67
62
  "typescript": "4.9.5"
68
63
  },
@@ -74,5 +69,5 @@
74
69
  "build": "yarn webiny run build",
75
70
  "watch": "yarn webiny run watch"
76
71
  },
77
- "gitHead": "94922b33af59db5afe75127bb07443ce7f1448c4"
72
+ "gitHead": "ebf90f62ed3f28114ffdb012b7e5f80988af53d3"
78
73
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_Plugin","require","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","Plugin","type","fieldType","config","constructor","params","name","transform","createPath","path","exports","createCmsEntryElasticsearchQueryBuilderValueSearchPlugin"],"sources":["CmsEntryElasticsearchQueryBuilderValueSearchPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams<T = any> {\n field: CmsModelField;\n key: string;\n value: T;\n}\n\nexport interface CreatePathCallable<T = any> {\n (params: CreatePathCallableParams<T>): string;\n}\n\nexport interface TransformCallableParams<T = any> {\n field: CmsModelField;\n value: T;\n}\nexport interface TransformCallable<T = any> {\n (params: TransformCallableParams<T>): string;\n}\n\nexport interface CmsEntryElasticsearchQueryBuilderValueSearchPluginParams {\n fieldType: string;\n path?: string | CreatePathCallable;\n transform: TransformCallable;\n}\nexport class CmsEntryElasticsearchQueryBuilderValueSearchPlugin extends Plugin {\n public static override readonly type: string = \"cms-elastic-search-query-builder-value-search\";\n\n private readonly config: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams) {\n super();\n\n this.config = params;\n /**\n * There is a type on the constructor, TS just doesn't see it.\n */\n // @ts-expect-error\n this.name = `${this.constructor.type}-${this.config.fieldType}`;\n }\n\n public transform(params: TransformCallableParams): any {\n return this.config.transform(params);\n }\n\n public createPath(params: CreatePathCallableParams): string | null {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n return null;\n }\n}\n\nexport const createCmsEntryElasticsearchQueryBuilderValueSearchPlugin = (\n params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams\n) => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin(params);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AA0BO,MAAMC,kDAAkD,SAASC,cAAM,CAAC;EAC3E,OAAgCC,IAAI,GAAW,+CAA+C;EAI9F,IAAWC,SAASA,CAAA,EAAW;IAC3B,OAAO,IAAI,CAACC,MAAM,CAACD,SAAS;EAChC;EAEOE,WAAWA,CAACC,MAAgE,EAAE;IACjF,KAAK,CAAC,CAAC;IAEP,IAAI,CAACF,MAAM,GAAGE,MAAM;IACpB;AACR;AACA;IACQ;IACA,IAAI,CAACC,IAAI,GAAI,GAAE,IAAI,CAACF,WAAW,CAACH,IAAK,IAAG,IAAI,CAACE,MAAM,CAACD,SAAU,EAAC;EACnE;EAEOK,SAASA,CAACF,MAA+B,EAAO;IACnD,OAAO,IAAI,CAACF,MAAM,CAACI,SAAS,CAACF,MAAM,CAAC;EACxC;EAEOG,UAAUA,CAACH,MAAgC,EAAiB;IAC/D,IAAI,OAAO,IAAI,CAACF,MAAM,CAACM,IAAI,KAAK,UAAU,EAAE;MACxC,OAAO,IAAI,CAACN,MAAM,CAACM,IAAI,CAACJ,MAAM,CAAC;IACnC,CAAC,MAAM,IAAI,OAAO,IAAI,CAACF,MAAM,CAACM,IAAI,KAAK,QAAQ,EAAE;MAC7C,OAAO,IAAI,CAACN,MAAM,CAACM,IAAI;IAC3B;IACA,OAAO,IAAI;EACf;AACJ;AAACC,OAAA,CAAAX,kDAAA,GAAAA,kDAAA;AAEM,MAAMY,wDAAwD,GACjEN,MAAgE,IAC/D;EACD,OAAO,IAAIN,kDAAkD,CAACM,MAAM,CAAC;AACzE,CAAC;AAACK,OAAA,CAAAC,wDAAA,GAAAA,wDAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Plugin","require","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","Plugin","type","fieldType","config","constructor","params","name","transform","createPath","path","exports","createCmsEntryElasticsearchQueryBuilderValueSearchPlugin"],"sources":["CmsEntryElasticsearchQueryBuilderValueSearchPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams<T = any> {\n field: CmsModelField;\n key: string;\n value: T;\n}\n\nexport interface CreatePathCallable<T = any> {\n (params: CreatePathCallableParams<T>): string;\n}\n\nexport interface TransformCallableParams<T = any> {\n field: CmsModelField;\n value: T;\n}\nexport interface TransformCallable<T = any> {\n (params: TransformCallableParams<T>): string;\n}\n\nexport interface CmsEntryElasticsearchQueryBuilderValueSearchPluginParams {\n fieldType: string;\n path?: string | CreatePathCallable;\n transform: TransformCallable;\n}\nexport class CmsEntryElasticsearchQueryBuilderValueSearchPlugin extends Plugin {\n public static override readonly type: string = \"cms-elastic-search-query-builder-value-search\";\n\n private readonly config: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams) {\n super();\n\n this.config = params;\n /**\n * There is a type on the constructor, TS just doesn't see it.\n */\n // @ts-expect-error\n this.name = `${this.constructor.type}-${this.config.fieldType}`;\n }\n\n public transform(params: TransformCallableParams): any {\n return this.config.transform(params);\n }\n\n public createPath(params: CreatePathCallableParams): string | null {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n return null;\n }\n}\n\nexport const createCmsEntryElasticsearchQueryBuilderValueSearchPlugin = (\n params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams\n) => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin(params);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AA0BO,MAAMC,kDAAkD,SAASC,cAAM,CAAC;EAC3E,OAAgCC,IAAI,GAAW,+CAA+C;EAI9F,IAAWC,SAASA,CAAA,EAAW;IAC3B,OAAO,IAAI,CAACC,MAAM,CAACD,SAAS;EAChC;EAEOE,WAAWA,CAACC,MAAgE,EAAE;IACjF,KAAK,CAAC,CAAC;IAEP,IAAI,CAACF,MAAM,GAAGE,MAAM;IACpB;AACR;AACA;IACQ;IACA,IAAI,CAACC,IAAI,GAAG,GAAG,IAAI,CAACF,WAAW,CAACH,IAAI,IAAI,IAAI,CAACE,MAAM,CAACD,SAAS,EAAE;EACnE;EAEOK,SAASA,CAACF,MAA+B,EAAO;IACnD,OAAO,IAAI,CAACF,MAAM,CAACI,SAAS,CAACF,MAAM,CAAC;EACxC;EAEOG,UAAUA,CAACH,MAAgC,EAAiB;IAC/D,IAAI,OAAO,IAAI,CAACF,MAAM,CAACM,IAAI,KAAK,UAAU,EAAE;MACxC,OAAO,IAAI,CAACN,MAAM,CAACM,IAAI,CAACJ,MAAM,CAAC;IACnC,CAAC,MAAM,IAAI,OAAO,IAAI,CAACF,MAAM,CAACM,IAAI,KAAK,QAAQ,EAAE;MAC7C,OAAO,IAAI,CAACN,MAAM,CAACM,IAAI;IAC3B;IACA,OAAO,IAAI;EACf;AACJ;AAACC,OAAA,CAAAX,kDAAA,GAAAA,kDAAA;AAEM,MAAMY,wDAAwD,GACjEN,MAAgE,IAC/D;EACD,OAAO,IAAIN,kDAAkD,CAACM,MAAM,CAAC;AACzE,CAAC;AAACK,OAAA,CAAAC,wDAAA,GAAAA,wDAAA","ignoreList":[]}