@webiny/api-headless-cms-ddb-es 5.25.0-beta.6 → 5.25.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/configurations.d.ts +2 -2
  2. package/configurations.js +18 -7
  3. package/configurations.js.map +1 -1
  4. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  5. package/elasticsearch/createElasticsearchIndex.js +60 -0
  6. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  7. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  8. package/elasticsearch/deleteElasticsearchIndex.js +43 -0
  9. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  10. package/elasticsearch/indexing/dateTimeIndexing.js +1 -1
  11. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
  12. package/elasticsearch/indices/base.d.ts +2 -0
  13. package/elasticsearch/indices/base.js +23 -0
  14. package/elasticsearch/indices/base.js.map +1 -0
  15. package/elasticsearch/indices/index.d.ts +1 -0
  16. package/elasticsearch/indices/index.js +16 -0
  17. package/elasticsearch/indices/index.js.map +1 -0
  18. package/elasticsearch/indices/japanese.d.ts +2 -0
  19. package/elasticsearch/indices/japanese.js +24 -0
  20. package/elasticsearch/indices/japanese.js.map +1 -0
  21. package/helpers/createElasticsearchQueryBody.js +83 -28
  22. package/helpers/createElasticsearchQueryBody.js.map +1 -1
  23. package/index.js +49 -14
  24. package/index.js.map +1 -1
  25. package/operations/entry/index.js +37 -47
  26. package/operations/entry/index.js.map +1 -1
  27. package/operations/group/index.js +1 -3
  28. package/operations/group/index.js.map +1 -1
  29. package/operations/model/index.js +18 -36
  30. package/operations/model/index.js.map +1 -1
  31. package/operations/settings/index.js +1 -3
  32. package/operations/settings/index.js.map +1 -1
  33. package/operations/system/index.js +1 -3
  34. package/operations/system/index.js.map +1 -1
  35. package/package.json +15 -17
  36. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  37. package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
  38. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  39. package/types.d.ts +2 -2
  40. package/types.js.map +1 -1
  41. package/upgrades/index.d.ts +1 -1
  42. package/upgrades/index.js +1 -7
  43. package/upgrades/index.js.map +1 -1
  44. package/helpers/operatorPluginsList.d.ts +0 -6
  45. package/helpers/operatorPluginsList.js +0 -30
  46. package/helpers/operatorPluginsList.js.map +0 -1
  47. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  48. package/operations/system/createElasticsearchTemplate.js +0 -62
  49. package/operations/system/createElasticsearchTemplate.js.map +0 -1
  50. package/upgrades/utils.d.ts +0 -4
  51. package/upgrades/utils.js +0 -20
  52. package/upgrades/utils.js.map +0 -1
  53. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -9
  54. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -20
  55. package/upgrades/v5.0.0/cleanDatabaseRecord.js.map +0 -1
  56. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  57. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  58. package/upgrades/v5.0.0/createOldVersionIndiceName.js.map +0 -1
  59. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -7
  60. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  61. package/upgrades/v5.0.0/entryValueFixer.js.map +0 -1
  62. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -9
  63. package/upgrades/v5.0.0/fieldFinder.js +0 -46
  64. package/upgrades/v5.0.0/fieldFinder.js.map +0 -1
  65. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  66. package/upgrades/v5.0.0/helpers.js +0 -57
  67. package/upgrades/v5.0.0/helpers.js.map +0 -1
  68. package/upgrades/v5.0.0/index.d.ts +0 -4
  69. package/upgrades/v5.0.0/index.js +0 -232
  70. package/upgrades/v5.0.0/index.js.map +0 -1
  71. package/upgrades/v5.8.0/index.d.ts +0 -7
  72. package/upgrades/v5.8.0/index.js +0 -426
  73. package/upgrades/v5.8.0/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","original","get","record"],"mappings":";;;;;;;;;;;AAQA;;AACA;;AACA;;;;;;AAMA,MAAMA,eAAe,GAAIC,QAAD,IAA0C;AAC9D,yCACOA,QADP;AAEIC,IAAAA,sBAAsB,EAAED,QAAQ,CAACC,sBAAT,CAAgCC,WAAhC;AAF5B;AAIH,CALD;;AAOA,MAAMC,iBAAiB,GAAIH,QAAD,IAAkD;AACxE,MAAI,CAACA,QAAL,EAAe;AACX,WAAO,IAAP;AACH;;AACD,MAAIC,sBAAJ;;AACA,MAAI;AACAA,IAAAA,sBAAsB,GAAG,IAAIG,IAAJ,CAASJ,QAAQ,CAACC,sBAAlB,CAAzB;AACH,GAFD,CAEE,MAAM;AACJA,IAAAA,sBAAsB,GAAG,IAAIG,IAAJ,EAAzB;AACH;;AACD,yCACOJ,QADP;AAEIC,IAAAA;AAFJ;AAIH,CAdD;;AAqBA,MAAMI,kBAAkB,GAAG,CAAC;AAAEC,EAAAA,MAAF;AAAUC,EAAAA;AAAV,CAAD,KAAoD;AAC3E,SAAQ,KAAID,MAAO,MAAKC,MAAO,eAA/B;AACH,CAFD;;AAIA,MAAMC,aAAa,GAAG,MAAc;AAChC,SAAO,UAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;AACrD,SAAO;AACHC,IAAAA,EAAE,EAAEN,kBAAkB,CAACK,MAAD,CADnB;AAEHE,IAAAA,EAAE,EAAEJ,aAAa;AAFd,GAAP;AAIH,CALD;;AAWO,MAAMK,+BAA+B,GACxCH,MAD2C,IAEZ;AAC/B,QAAM;AAAEI,IAAAA;A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B,MAAP,IAAyD;AACjE,UAAMM,IAAI,GAAGP,UAAU,CAACC,MAAD,CAAvB;;AACA,QAAI;AACA,YAAMiB,MAAM,GAAG,MAAM,cAAyB;AAC1Cb,QAAAA,MAD0C;AAE1CE,QAAAA;AAF0C,OAAzB,CAArB;;AAIA,UAAI,CAACW,MAAL,EAAa;AACT,eAAO,IAAP;AACH;;AACD,YAAM3B,QAAQ,GAAG,0BAAYc,MAAZ,EAAoBa,MAApB,CAAjB;AACA,aAAOxB,iBAAiB,CAACH,QAAD,CAAxB;AACH,KAVD,CAUE,OAAOmB,EAAP,EAAW;AACT,YAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,yBADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,oBAFT,EAGF;AACIC,QAAAA,KAAK,EAAEJ,EADX;AAEIH,QAAAA;AAFJ,OAHE,CAAN;AAQH;AACJ,GAtBD;;AAwBA,SAAO;AACHD,IAAAA,MADG;AAEHW,IAAAA,GAFG;AAGHF,IAAAA;AAHG,GAAP;AAKH,CAxFM","sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\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 interface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings, original } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n original,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record"],"mappings":";;;;;;;;;;;AAQA;;AACA;;AACA;;;;;;AAMA,MAAMA,eAAe,GAAIC,QAAD,IAA0C;AAC9D,yCACOA,QADP;AAEIC,IAAAA,sBAAsB,EAAED,QAAQ,CAACC,sBAAT,CAAgCC,WAAhC;AAF5B;AAIH,CALD;;AAOA,MAAMC,iBAAiB,GAAIH,QAAD,IAAkD;AACxE,MAAI,CAACA,QAAL,EAAe;AACX,WAAO,IAAP;AACH;;AACD,MAAIC,sBAAJ;;AACA,MAAI;AACAA,IAAAA,sBAAsB,GAAG,IAAIG,IAAJ,CAASJ,QAAQ,CAACC,sBAAlB,CAAzB;AACH,GAFD,CAEE,MAAM;AACJA,IAAAA,sBAAsB,GAAG,IAAIG,IAAJ,EAAzB;AACH;;AACD,yCACOJ,QADP;AAEIC,IAAAA;AAFJ;AAIH,CAdD;;AAqBA,MAAMI,kBAAkB,GAAG,CAAC;AAAEC,EAAAA,MAAF;AAAUC,EAAAA;AAAV,CAAD,KAAoD;AAC3E,SAAQ,KAAID,MAAO,MAAKC,MAAO,eAA/B;AACH,CAFD;;AAIA,MAAMC,aAAa,GAAG,MAAc;AAChC,SAAO,UAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;AACrD,SAAO;AACHC,IAAAA,EAAE,EAAEN,kBAAkB,CAACK,MAAD,CADnB;AAEHE,IAAAA,EAAE,EAAEJ,aAAa;AAFd,GAAP;AAIH,CALD;;AAWO,MAAMK,+BAA+B,GACxCH,MAD2C,IAEZ;AAC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AMM,IAAI,GAAGP,UAAU,CAACC,MAAD,CAAvB;;AACA,QAAI;AACA,YAAMgB,MAAM,GAAG,MAAM,cAAyB;AAC1CZ,QAAAA,MAD0C;AAE1CE,QAAAA;AAF0C,OAAzB,CAArB;;AAIA,UAAI,CAACU,MAAL,EAAa;AACT,eAAO,IAAP;AACH;;AACD,YAAM1B,QAAQ,GAAG,0BAAYc,MAAZ,EAAoBY,MAApB,CAAjB;AACA,aAAOvB,iBAAiB,CAACH,QAAD,CAAxB;AACH,KAVD,CAUE,OAAOmB,EAAP,EAAW;AACT,YAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,yBADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,oBAFT,EAGF;AACIC,QAAAA,KAAK,EAAEJ,EADX;AAEIH,QAAAA;AAFJ,OAHE,CAAN;AAQH;AACJ,GAtBD;;AAwBA,SAAO;AACHD,IAAAA,MADG;AAEHU,IAAAA,GAFG;AAGHD,IAAAA;AAHG,GAAP;AAKH,CAvFM","sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\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 interface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"]}
@@ -60,8 +60,7 @@ const createSystemStorageOperations = params => {
60
60
 
61
61
  const update = async params => {
62
62
  const {
63
- system,
64
- original
63
+ system
65
64
  } = params;
66
65
  const keys = createKeys(system);
67
66
 
@@ -72,7 +71,6 @@ const createSystemStorageOperations = params => {
72
71
  throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
73
72
  error: ex,
74
73
  system,
75
- original,
76
74
  keys
77
75
  });
78
76
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","original","get"],"mappings":";;;;;;;;;;;AAQA;;AACA;;AACA;;;;;;AASA,MAAMA,kBAAkB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAA4C;AACnE,SAAQ,KAAIA,MAAM,CAACC,WAAP,EAAqB,SAAjC;AACH,CAFD;;AAGA,MAAMC,aAAa,GAAG,MAAc;AAChC,SAAO,KAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;AACrD,SAAO;AACHC,IAAAA,EAAE,EAAEN,kBAAkB,CAACK,MAAD,CADnB;AAEHE,IAAAA,EAAE,EAAEJ,aAAa;AAFd,GAAP;AAIH,CALD;;AAOO,MAAMK,6BAA6B,GACtCH,MADyC,IAEZ;AAC7B,QAAM;AAAEI,IAAAA;AAAF,MAAaJ,MAAnB;;AAEA,QAAMK,MAAM,GAAG,OAAO;AAAEC,IAAAA;AAAF,GAAP,KAA8D;AACzE,UAAMC,IAAI,GAAGR,UAAU,CAACO,MAAD,CAAvB;;AACA,QAAI;AACA,YAAMF,MAAM,CAACI,GAAP,iCACCF,MADD,GAECC,IAFD,EAAN;AAIA,aAAOD,MAAP;AACH,KAND,CAME,O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ACJ,GAnBD;;AAqBA,SAAO;AACHF,IAAAA,MADG;AAEHS,IAAAA,MAFG;AAGHE,IAAAA;AAHG,GAAP;AAKH,CA7EM","sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\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 entity.put({\n ...system,\n ...keys\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, original } = params;\n\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 system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n original,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\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"]}
1
+ {"version":3,"sources":["index.ts"],"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","get"],"mappings":";;;;;;;;;;;AAQA;;AACA;;AACA;;;;;;AASA,MAAMA,kBAAkB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAA4C;AACnE,SAAQ,KAAIA,MAAM,CAACC,WAAP,EAAqB,SAAjC;AACH,CAFD;;AAGA,MAAMC,aAAa,GAAG,MAAc;AAChC,SAAO,KAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;AACrD,SAAO;AACHC,IAAAA,EAAE,EAAEN,kBAAkB,CAACK,MAAD,CADnB;AAEHE,IAAAA,EAAE,EAAEJ,aAAa;AAFd,GAAP;AAIH,CALD;;AAOO,MAAMK,6BAA6B,GACtCH,MADyC,IAEZ;AAC7B,QAAM;AAAEI,IAAAA;AAAF,MAAaJ,MAAnB;;AAEA,QAAMK,MAAM,GAAG,OAAO;AAAEC,IAAAA;AAAF,GAAP,KAA8D;AACzE,UAAMC,IAAI,GAAGR,UAAU,CAACO,MAAD,CAAvB;;AACA,QAAI;AACA,YAAMF,MAAM,CAACI,GAAP,iCACCF,MADD,GAECC,IAFD,EAAN;AAIA,aAAOD,MAAP;AACH,KAND,CAME,OAAOG,EAAP,EAAW;AACT,YAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,0BADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,qBAFT,EAGF;AACIC,QAAAA,KAAK,EAAEJ,EADX;AAEIH,QAAAA,MAFJ;AAGIC,QAAAA;AAHJ,OAHE,CAAN;AASH;AACJ,GAnBD;;AAqBA,QAAMO,MAAM,GAAG,MAAOd,MAAP,IAA0D;AACrE,UAAM;AAAEM,MAAAA;AAAF,QAAaN,MAAnB;AAEA,UAAMO,IAAI,GAAGR,UAAU,CAACO,MAAD,CAAvB;;AAEA,QAAI;AACA,YAAMF,MAAM,CAACI,GAAP,iCACCF,MADD,GAECC,IAFD,EAAN;AAIA,aAAOD,MAAP;AACH,KAND,CAME,OAAOG,EAAP,EAAW;AACT,YAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,0BADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,qBAFT,EAGF;AACIC,QAAAA,KAAK,EAAEJ,EADX;AAEIH,QAAAA,MAFJ;AAGIC,QAAAA;AAHJ,OAHE,CAAN;AASH;AACJ,GAtBD;;AAwBA,QAAMQ,GAAG,GAAG,MAAOf,MAAP,IAAuD;AAC/D,UAAMO,IAAI,GAAGR,UAAU,CAACC,MAAD,CAAvB;;AAEA,QAAI;AACA,YAAMM,MAAM,GAAG,MAAM,cAAqB;AACtCF,QAAAA,MADsC;AAEtCG,QAAAA;AAFsC,OAArB,CAArB;AAIA,aAAO,0BAAYH,MAAZ,EAAoBE,MAApB,CAAP;AACH,KAND,CAME,OAAOG,EAAP,EAAW;AACT,YAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,uBADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,kBAFT,EAGF;AACIC,QAAAA,KAAK,EAAEJ,EADX;AAEIF,QAAAA;AAFJ,OAHE,CAAN;AAQH;AACJ,GAnBD;;AAqBA,SAAO;AACHF,IAAAA,MADG;AAEHS,IAAAA,MAFG;AAGHC,IAAAA;AAHG,GAAP;AAKH,CA5EM","sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\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 entity.put({\n ...system,\n ...keys\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 entity.put({\n ...system,\n ...keys\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 const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb-es",
3
- "version": "5.25.0-beta.6",
3
+ "version": "5.25.1-beta.1",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-headless-cms",
@@ -22,16 +22,16 @@
22
22
  ],
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@babel/runtime": "7.17.7",
26
- "@webiny/api-headless-cms": "5.25.0-beta.6",
27
- "@webiny/api-upgrade": "5.25.0-beta.6",
28
- "@webiny/db-dynamodb": "5.25.0-beta.6",
29
- "@webiny/error": "5.25.0-beta.6",
30
- "@webiny/handler": "5.25.0-beta.6",
31
- "@webiny/handler-aws": "5.25.0-beta.6",
32
- "@webiny/handler-db": "5.25.0-beta.6",
33
- "@webiny/plugins": "5.25.0-beta.6",
34
- "@webiny/utils": "5.25.0-beta.6",
25
+ "@babel/runtime": "7.16.7",
26
+ "@webiny/api-elasticsearch": "5.25.1-beta.1",
27
+ "@webiny/api-headless-cms": "5.25.1-beta.1",
28
+ "@webiny/db-dynamodb": "5.25.1-beta.1",
29
+ "@webiny/error": "5.25.1-beta.1",
30
+ "@webiny/handler": "5.25.1-beta.1",
31
+ "@webiny/handler-aws": "5.25.1-beta.1",
32
+ "@webiny/handler-db": "5.25.1-beta.1",
33
+ "@webiny/plugins": "5.25.1-beta.1",
34
+ "@webiny/utils": "5.25.1-beta.1",
35
35
  "dataloader": "2.0.0",
36
36
  "dynamodb-toolbox": "0.3.5",
37
37
  "jsonpack": "1.1.5",
@@ -43,12 +43,10 @@
43
43
  "@babel/preset-env": "^7.16.4",
44
44
  "@babel/preset-flow": "^7.16.0",
45
45
  "@elastic/elasticsearch": "7.12.0",
46
- "@shelf/jest-elasticsearch": "^1.0.0",
47
46
  "@types/jsonpack": "^1.1.0",
48
- "@webiny/api-dynamodb-to-elasticsearch": "^5.25.0-beta.6",
49
- "@webiny/api-elasticsearch": "^5.25.0-beta.6",
50
- "@webiny/cli": "^5.25.0-beta.6",
51
- "@webiny/project-utils": "^5.25.0-beta.6",
47
+ "@webiny/api-dynamodb-to-elasticsearch": "^5.25.1-beta.1",
48
+ "@webiny/cli": "^5.25.1-beta.1",
49
+ "@webiny/project-utils": "^5.25.1-beta.1",
52
50
  "jest": "^26.6.3",
53
51
  "jest-dynalite": "^3.2.0",
54
52
  "jest-environment-node": "^26.6.2",
@@ -67,5 +65,5 @@
67
65
  "build": "yarn webiny run build",
68
66
  "watch": "yarn webiny run watch"
69
67
  },
70
- "gitHead": "a208508363613ea3cb7540d18bb9b2f2250a8466"
68
+ "gitHead": "aeeff2c4da36d72638831e85f3fa1f815e9abb3e"
71
69
  }
@@ -0,0 +1,4 @@
1
+ import { ElasticsearchIndexPlugin } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchIndexPlugin";
2
+ export declare class CmsEntryElasticsearchIndexPlugin extends ElasticsearchIndexPlugin {
3
+ static readonly type: string;
4
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CmsEntryElasticsearchIndexPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchIndexPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchIndexPlugin");
13
+
14
+ class CmsEntryElasticsearchIndexPlugin extends _ElasticsearchIndexPlugin.ElasticsearchIndexPlugin {}
15
+
16
+ exports.CmsEntryElasticsearchIndexPlugin = CmsEntryElasticsearchIndexPlugin;
17
+ (0, _defineProperty2.default)(CmsEntryElasticsearchIndexPlugin, "type", "cms.entry.elasticsearch.index");
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["CmsEntryElasticsearchIndexPlugin.ts"],"names":["CmsEntryElasticsearchIndexPlugin","ElasticsearchIndexPlugin"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,gCAAN,SAA+CC,kDAA/C,CAAwE;;;8BAAlED,gC,UACsC,+B","sourcesContent":["import { ElasticsearchIndexPlugin } from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchIndexPlugin\";\n\nexport class CmsEntryElasticsearchIndexPlugin extends ElasticsearchIndexPlugin {\n public static override readonly type: string = \"cms.entry.elasticsearch.index\";\n}\n"]}
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from "@webiny/plugins/types";
1
+ import { Plugin, PluginCollection } from "@webiny/plugins/types";
2
2
  import { CmsEntry, CmsModel, CmsModelField, CmsModelFieldToGraphQLPlugin, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
3
3
  import { DynamoDBTypes, TableConstructor } from "dynamodb-toolbox/dist/classes/Table";
4
4
  import { DocumentClient } from "aws-sdk/clients/dynamodb";
@@ -149,7 +149,7 @@ export interface StorageOperationsFactoryParams {
149
149
  esTable?: TableModifier;
150
150
  modelFieldToGraphQLPlugins: CmsModelFieldToGraphQLPlugin[];
151
151
  attributes?: Record<ENTITIES, Attributes>;
152
- plugins?: Plugin[] | Plugin[][];
152
+ plugins?: PluginCollection;
153
153
  }
154
154
  export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
155
155
  getTable: () => Table;
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["types.ts"],"names":["ENTITIES"],"mappings":";;;;;;;AAkBA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IAsDYA,Q;;;WAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;GAAAA,Q,wBAAAA,Q","sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport {\n CmsEntry,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * A definition of the entry that is being prepared for the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsIndexEntry extends CmsEntry {\n /**\n * Values that are not going to be indexed.\n */\n rawValues: Record<string, any>;\n /**\n * A first part of the ID, without the revision.\n * For example, we can search for all the revisions of the given entry.\n */\n primaryId: string;\n /**\n * Dev can add what ever keys they want and need. Just need to be careful not to break the entry.\n */\n [key: string]: any;\n}\n\n/**\n * Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\ninterface CmsModelFieldToElasticsearchToParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n /**\n * Raw value on the entry - before prepare for storage.\n */\n rawValue: any;\n /**\n * Value prepared for storage received from base api-headless-cms package.\n */\n value: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * Arguments for the method that is transforming content entry from Elasticsearch into the original one.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\ninterface CmsModelFieldToElasticsearchFromParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n rawValue: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\ninterface ToIndexValue {\n /**\n * Use this key to store value for indexing.\n */\n value?: any;\n /**\n * Use this key to tell ES that this value should not be indexed.\n */\n rawValue?: any;\n}\n\n/**\n * A plugin defining transformation of entry for Elasticsearch.\n *\n * @category Plugin\n * @category ContentModelField\n * @category CmsEntry\n * @category Elasticsearch\n */\nexport interface CmsModelFieldToElasticsearchPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-elastic-search\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: string;\n /**\n * If you need to define a type when building an Elasticsearch query.\n * Check [dateTimeIndexing](https://github.com/webiny/webiny-js/blob/3074165701b8b45e5fc6ac2444caace7d04ada66/packages/api-headless-cms/src/content/plugins/es/indexing/dateTimeIndexing.ts) plugin for usage example.\n *\n * ```ts\n * unmappedType: \"date\"\n * ```\n */\n unmappedType?: (field: CmsModelField) => string;\n /**\n * This is meant to do some transformation of the entry, preferably only to fieldType it was defined for. Nothing is stopping you to do anything you want to other fields, but try to separate field transformations.\n * It returns `Partial<CmsContentIndexEntryType>`. Always return a top-level property of the entry since it is merged via spread operator.\n *\n * ```ts\n * toIndex({ value }) {\n * return {\n * value: value, // This will be stored and indexed\n * rawValue: JSON.stringify(value) // This will be stored but excluded from indexing\n * };\n * }\n * ```\n */\n toIndex?: (params: CmsModelFieldToElasticsearchToParams) => ToIndexValue;\n /**\n * This is meant to revert a transformation done in the `toIndex` method.\n * You have access to \"value\" or a \"rawValue\", depending on what you returned from `toIndex`.\n *\n * ```ts\n * fromIndex({ value, rawValue }) {\n * return JSON.parse(rawValue);\n * }\n * ```\n */\n fromIndex?: (params: CmsModelFieldToElasticsearchFromParams) => any;\n}\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n SETTINGS = \"CmsSettings\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\",\n ENTRIES_ES = \"CmsEntriesElasticsearch\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor): TableConstructor;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DocumentClient;\n elasticsearch: Client;\n table?: TableModifier;\n esTable?: TableModifier;\n modelFieldToGraphQLPlugins: CmsModelFieldToGraphQLPlugin[];\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: Plugin[] | Plugin[][];\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => Table;\n getEsTable: () => Table;\n getEntities: () => Record<\n \"system\" | \"settings\" | \"groups\" | \"models\" | \"entries\" | \"entriesEs\",\n Entity<any>\n >;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n"]}
1
+ {"version":3,"sources":["types.ts"],"names":["ENTITIES"],"mappings":";;;;;;;AAkBA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IAsDYA,Q;;;WAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;GAAAA,Q,wBAAAA,Q","sourcesContent":["import { Plugin, PluginCollection } from \"@webiny/plugins/types\";\nimport {\n CmsEntry,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * A definition of the entry that is being prepared for the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsIndexEntry extends CmsEntry {\n /**\n * Values that are not going to be indexed.\n */\n rawValues: Record<string, any>;\n /**\n * A first part of the ID, without the revision.\n * For example, we can search for all the revisions of the given entry.\n */\n primaryId: string;\n /**\n * Dev can add what ever keys they want and need. Just need to be careful not to break the entry.\n */\n [key: string]: any;\n}\n\n/**\n * Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\ninterface CmsModelFieldToElasticsearchToParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n /**\n * Raw value on the entry - before prepare for storage.\n */\n rawValue: any;\n /**\n * Value prepared for storage received from base api-headless-cms package.\n */\n value: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * Arguments for the method that is transforming content entry from Elasticsearch into the original one.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\ninterface CmsModelFieldToElasticsearchFromParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n rawValue: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\ninterface ToIndexValue {\n /**\n * Use this key to store value for indexing.\n */\n value?: any;\n /**\n * Use this key to tell ES that this value should not be indexed.\n */\n rawValue?: any;\n}\n\n/**\n * A plugin defining transformation of entry for Elasticsearch.\n *\n * @category Plugin\n * @category ContentModelField\n * @category CmsEntry\n * @category Elasticsearch\n */\nexport interface CmsModelFieldToElasticsearchPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-elastic-search\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: string;\n /**\n * If you need to define a type when building an Elasticsearch query.\n * Check [dateTimeIndexing](https://github.com/webiny/webiny-js/blob/3074165701b8b45e5fc6ac2444caace7d04ada66/packages/api-headless-cms/src/content/plugins/es/indexing/dateTimeIndexing.ts) plugin for usage example.\n *\n * ```ts\n * unmappedType: \"date\"\n * ```\n */\n unmappedType?: (field: CmsModelField) => string;\n /**\n * This is meant to do some transformation of the entry, preferably only to fieldType it was defined for. Nothing is stopping you to do anything you want to other fields, but try to separate field transformations.\n * It returns `Partial<CmsContentIndexEntryType>`. Always return a top-level property of the entry since it is merged via spread operator.\n *\n * ```ts\n * toIndex({ value }) {\n * return {\n * value: value, // This will be stored and indexed\n * rawValue: JSON.stringify(value) // This will be stored but excluded from indexing\n * };\n * }\n * ```\n */\n toIndex?: (params: CmsModelFieldToElasticsearchToParams) => ToIndexValue;\n /**\n * This is meant to revert a transformation done in the `toIndex` method.\n * You have access to \"value\" or a \"rawValue\", depending on what you returned from `toIndex`.\n *\n * ```ts\n * fromIndex({ value, rawValue }) {\n * return JSON.parse(rawValue);\n * }\n * ```\n */\n fromIndex?: (params: CmsModelFieldToElasticsearchFromParams) => any;\n}\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n SETTINGS = \"CmsSettings\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\",\n ENTRIES_ES = \"CmsEntriesElasticsearch\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor): TableConstructor;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DocumentClient;\n elasticsearch: Client;\n table?: TableModifier;\n esTable?: TableModifier;\n modelFieldToGraphQLPlugins: CmsModelFieldToGraphQLPlugin[];\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: PluginCollection;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => Table;\n getEsTable: () => Table;\n getEntities: () => Record<\n \"system\" | \"settings\" | \"groups\" | \"models\" | \"entries\" | \"entriesEs\",\n Entity<any>\n >;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n"]}
@@ -1,2 +1,2 @@
1
- declare const _default: () => import("@webiny/api-upgrade").UpgradePlugin<import("@webiny/api-headless-cms/types").CmsContext>[];
1
+ declare const _default: () => never[];
2
2
  export default _default;
package/upgrades/index.js CHANGED
@@ -1,16 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
7
 
10
- var _index = _interopRequireDefault(require("./v5.0.0/index"));
11
-
12
- var _index2 = _interopRequireDefault(require("./v5.8.0/index"));
13
-
14
- var _default = () => [(0, _index.default)(), (0, _index2.default)()];
8
+ var _default = () => [];
15
9
 
16
10
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;AACA;;eAEe,MAAM,CAAC,qBAAD,EAAe,sBAAf,C","sourcesContent":["import upgrade500 from \"./v5.0.0/index\";\nimport upgrade580 from \"./v5.8.0/index\";\n\nexport default () => [upgrade500(), upgrade580()];\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;eAAe,MAAM,E","sourcesContent":["export default () => [];\n"]}
@@ -1,6 +0,0 @@
1
- import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- export interface OperatorPlugins {
4
- [operator: string]: ElasticsearchQueryBuilderOperatorPlugin;
5
- }
6
- export declare const operatorPluginsList: (plugins: PluginsContainer) => OperatorPlugins;
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.operatorPluginsList = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- var _ElasticsearchQueryBuilderOperatorPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin");
13
-
14
- const operatorPluginsList = plugins => {
15
- return plugins.byType(_ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((plugins, plugin) => {
16
- const operator = plugin.getOperator();
17
-
18
- if (plugins[operator]) {
19
- throw new _error.default("There is a ElasticsearchQueryBuilderOperatorPlugin defined for the operator.", "PLUGIN_ALREADY_EXISTS", {
20
- operator: operator,
21
- name: plugin.name || "unknown"
22
- });
23
- }
24
-
25
- plugins[operator] = plugin;
26
- return plugins;
27
- }, {});
28
- };
29
-
30
- exports.operatorPluginsList = operatorPluginsList;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["operatorPluginsList.ts"],"names":["operatorPluginsList","plugins","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","plugin","operator","getOperator","WebinyError","name"],"mappings":";;;;;;;;;AAAA;;AACA;;AAOO,MAAMA,mBAAmB,GAAIC,OAAD,IAAgD;AAC/E,SAAOA,OAAO,CACTC,MADE,CAECC,iFAAwCC,IAFzC,EAIFC,MAJE,CAIK,CAACJ,OAAD,EAAUK,MAAV,KAAqB;AACzB,UAAMC,QAAQ,GAAGD,MAAM,CAACE,WAAP,EAAjB;;AACA,QAAIP,OAAO,CAACM,QAAD,CAAX,EAAuB;AACnB,YAAM,IAAIE,cAAJ,CACF,8EADE,EAEF,uBAFE,EAGF;AACIF,QAAAA,QAAQ,EAAEA,QADd;AAEIG,QAAAA,IAAI,EAAEJ,MAAM,CAACI,IAAP,IAAe;AAFzB,OAHE,CAAN;AAQH;;AACDT,IAAAA,OAAO,CAACM,QAAD,CAAP,GAAoBD,MAApB;AAEA,WAAOL,OAAP;AACH,GAnBE,EAmBA,EAnBA,CAAP;AAoBH,CArBM","sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface OperatorPlugins {\n [operator: string]: ElasticsearchQueryBuilderOperatorPlugin;\n}\n\nexport const operatorPluginsList = (plugins: PluginsContainer): OperatorPlugins => {\n return plugins\n .byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n )\n .reduce((plugins, plugin) => {\n const operator = plugin.getOperator();\n if (plugins[operator]) {\n throw new WebinyError(\n \"There is a ElasticsearchQueryBuilderOperatorPlugin defined for the operator.\",\n \"PLUGIN_ALREADY_EXISTS\",\n {\n operator: operator,\n name: plugin.name || \"unknown\"\n }\n );\n }\n plugins[operator] = plugin;\n\n return plugins;\n }, {} as OperatorPlugins);\n};\n"]}
@@ -1,5 +0,0 @@
1
- import { Client } from "@elastic/elasticsearch";
2
- export interface CreateElasticsearchTemplateParams {
3
- elasticsearch: Client;
4
- }
5
- export declare const createElasticsearchTemplate: (params: CreateElasticsearchTemplateParams) => Promise<void>;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createElasticsearchTemplate = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- const createElasticsearchTemplate = async params => {
13
- const {
14
- elasticsearch
15
- } = params;
16
- const options = {
17
- name: "headless-cms-entries-index",
18
- body: {
19
- index_patterns: ["*headless-cms*"],
20
- settings: {
21
- analysis: {
22
- analyzer: {
23
- lowercase_analyzer: {
24
- type: "custom",
25
- filter: ["lowercase", "trim"],
26
- tokenizer: "keyword"
27
- }
28
- }
29
- }
30
- },
31
- mappings: {
32
- properties: {
33
- property: {
34
- type: "text",
35
- fields: {
36
- keyword: {
37
- type: "keyword",
38
- ignore_above: 256
39
- }
40
- },
41
- analyzer: "lowercase_analyzer"
42
- },
43
- rawValues: {
44
- type: "object",
45
- enabled: false
46
- }
47
- }
48
- }
49
- }
50
- };
51
-
52
- try {
53
- await elasticsearch.indices.putTemplate(options);
54
- } catch (ex) {
55
- throw new _error.default(ex.message || "Could not create Elasticsearch index template for the Headless CMS.", ex.code || "CMS_ELASTICSEARCH_TEMPLATE_ERROR", {
56
- error: ex,
57
- options
58
- });
59
- }
60
- };
61
-
62
- exports.createElasticsearchTemplate = createElasticsearchTemplate;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["createElasticsearchTemplate.ts"],"names":["createElasticsearchTemplate","params","elasticsearch","options","name","body","index_patterns","settings","analysis","analyzer","lowercase_analyzer","type","filter","tokenizer","mappings","properties","property","fields","keyword","ignore_above","rawValues","enabled","indices","putTemplate","ex","WebinyError","message","code","error"],"mappings":";;;;;;;;;AAAA;;AAQO,MAAMA,2BAA2B,GAAG,MAAOC,MAAP,IAAqD;AAC5F,QAAM;AAAEC,IAAAA;AAAF,MAAoBD,MAA1B;AAEA,QAAME,OAA2B,GAAG;AAChCC,IAAAA,IAAI,EAAE,4BAD0B;AAEhCC,IAAAA,IAAI,EAAE;AACFC,MAAAA,cAAc,EAAE,CAAC,gBAAD,CADd;AAEFC,MAAAA,QAAQ,EAAE;AACNC,QAAAA,QAAQ,EAAE;AACNC,UAAAA,QAAQ,EAAE;AACNC,YAAAA,kBAAkB,EAAE;AAChBC,cAAAA,IAAI,EAAE,QADU;AAEhBC,cAAAA,MAAM,EAAE,CAAC,WAAD,EAAc,MAAd,CAFQ;AAGhBC,cAAAA,SAAS,EAAE;AAHK;AADd;AADJ;AADJ,OAFR;AAaFC,MAAAA,QAAQ,EAAE;AACNC,QAAAA,UAAU,EAAE;AACRC,UAAAA,QAAQ,EAAE;AACNL,YAAAA,IAAI,EAAE,MADA;AAENM,YAAAA,MAAM,EAAE;AACJC,cAAAA,OAAO,EAAE;AACLP,gBAAAA,IAAI,EAAE,SADD;AAELQ,gBAAAA,YAAY,EAAE;AAFT;AADL,aAFF;AAQNV,YAAAA,QAAQ,EAAE;AARJ,WADF;AAWRW,UAAAA,SAAS,EAAE;AACPT,YAAAA,IAAI,EAAE,QADC;AAEPU,YAAAA,OAAO,EAAE;AAFF;AAXH;AADN;AAbR;AAF0B,GAApC;;AAoCA,MAAI;AACA,UAAMnB,aAAa,CAACoB,OAAd,CAAsBC,WAAtB,CAAkCpB,OAAlC,CAAN;AACH,GAFD,CAEE,OAAOqB,EAAP,EAAW;AACT,UAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,qEADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,kCAFT,EAGF;AACIC,MAAAA,KAAK,EAAEJ,EADX;AAEIrB,MAAAA;AAFJ,KAHE,CAAN;AAQH;AACJ,CAnDM","sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { IndicesPutTemplate } from \"@elastic/elasticsearch/api/requestParams\";\n\nexport interface CreateElasticsearchTemplateParams {\n elasticsearch: Client;\n}\n\nexport const createElasticsearchTemplate = async (params: CreateElasticsearchTemplateParams) => {\n const { elasticsearch } = params;\n\n const options: IndicesPutTemplate = {\n name: \"headless-cms-entries-index\",\n body: {\n index_patterns: [\"*headless-cms*\"],\n settings: {\n analysis: {\n analyzer: {\n lowercase_analyzer: {\n type: \"custom\",\n filter: [\"lowercase\", \"trim\"],\n tokenizer: \"keyword\"\n }\n }\n }\n },\n mappings: {\n properties: {\n property: {\n type: \"text\",\n fields: {\n keyword: {\n type: \"keyword\",\n ignore_above: 256\n }\n },\n analyzer: \"lowercase_analyzer\"\n },\n rawValues: {\n type: \"object\",\n enabled: false\n }\n }\n }\n }\n };\n\n try {\n await elasticsearch.indices.putTemplate(options);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create Elasticsearch index template for the Headless CMS.\",\n ex.code || \"CMS_ELASTICSEARCH_TEMPLATE_ERROR\",\n {\n error: ex,\n options\n }\n );\n }\n};\n"]}
@@ -1,4 +0,0 @@
1
- /**
2
- * File not used anymore.
3
- */
4
- export declare const paginateBatch: (items: any, perPage: any, execute: any) => Promise<void>;
package/upgrades/utils.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.paginateBatch = void 0;
7
-
8
- /**
9
- * File not used anymore.
10
- */
11
- // @ts-nocheck
12
- const paginateBatch = async (items, perPage, execute) => {
13
- const pages = Math.ceil(items.length / perPage);
14
-
15
- for (let i = 0; i < pages; i++) {
16
- await execute(items.slice(i * perPage, i * perPage + perPage));
17
- }
18
- };
19
-
20
- exports.paginateBatch = paginateBatch;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["utils.ts"],"names":["paginateBatch","items","perPage","execute","pages","Math","ceil","length","i","slice"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAG,OAAOC,KAAP,EAAcC,OAAd,EAAuBC,OAAvB,KAAmC;AAC5D,QAAMC,KAAK,GAAGC,IAAI,CAACC,IAAL,CAAUL,KAAK,CAACM,MAAN,GAAeL,OAAzB,CAAd;;AAEA,OAAK,IAAIM,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGJ,KAApB,EAA2BI,CAAC,EAA5B,EAAgC;AAC5B,UAAML,OAAO,CAACF,KAAK,CAACQ,KAAN,CAAYD,CAAC,GAAGN,OAAhB,EAAyBM,CAAC,GAAGN,OAAJ,GAAcA,OAAvC,CAAD,CAAb;AACH;AACJ,CANM","sourcesContent":["/**\n * File not used anymore.\n */\n// @ts-nocheck\nexport const paginateBatch = async (items, perPage, execute) => {\n const pages = Math.ceil(items.length / perPage);\n\n for (let i = 0; i < pages; i++) {\n await execute(items.slice(i * perPage, i * perPage + perPage));\n }\n};\n"]}
@@ -1,9 +0,0 @@
1
- /**
2
- * File not used anymore.
3
- */
4
- import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
5
- export declare const cleanDatabaseRecord: <T extends CmsModel | CmsEntry>(record: T & {
6
- PK?: string | undefined;
7
- SK?: string | undefined;
8
- TYPE?: string | undefined;
9
- }) => T;
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.cleanDatabaseRecord = void 0;
9
-
10
- var _omit = _interopRequireDefault(require("lodash/omit"));
11
-
12
- /**
13
- * File not used anymore.
14
- */
15
- // @ts-nocheck
16
- const cleanDatabaseRecord = record => {
17
- return (0, _omit.default)(record, ["PK", "SK", "TYPE"]);
18
- };
19
-
20
- exports.cleanDatabaseRecord = cleanDatabaseRecord;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["cleanDatabaseRecord.ts"],"names":["cleanDatabaseRecord","record"],"mappings":";;;;;;;;;AAKA;;AALA;AACA;AACA;AACA;AAIO,MAAMA,mBAAmB,GAC5BC,MAD+B,IAE3B;AACJ,SAAO,mBAAWA,MAAX,EAAmB,CAAC,IAAD,EAAO,IAAP,EAAa,MAAb,CAAnB,CAAP;AACH,CAJM","sourcesContent":["/**\n * File not used anymore.\n */\n// @ts-nocheck\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport lodashOmit from \"lodash/omit\";\n\nexport const cleanDatabaseRecord = <T extends CmsModel | CmsEntry>(\n record: T & { PK?: string; SK?: string; TYPE?: string }\n): T => {\n return lodashOmit(record, [\"PK\", \"SK\", \"TYPE\"]) as T;\n};\n"]}
@@ -1,2 +0,0 @@
1
- import { CmsContext } from "@webiny/api-headless-cms/types";
2
- export declare const createOldVersionIndiceName: (context: CmsContext) => string;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createOldVersionIndiceName = void 0;
7
-
8
- const createOldVersionIndiceName = context => {
9
- return `${context.tenancy.getCurrentTenant().id}-headless-cms`;
10
- };
11
-
12
- exports.createOldVersionIndiceName = createOldVersionIndiceName;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["createOldVersionIndiceName.ts"],"names":["createOldVersionIndiceName","context","tenancy","getCurrentTenant","id"],"mappings":";;;;;;;AAEO,MAAMA,0BAA0B,GAAIC,OAAD,IAAiC;AACvE,SAAQ,GAAEA,OAAO,CAACC,OAAR,CAAgBC,gBAAhB,GAAmCC,EAAG,eAAhD;AACH,CAFM","sourcesContent":["import { CmsContext } from \"@webiny/api-headless-cms/types\";\n\nexport const createOldVersionIndiceName = (context: CmsContext): string => {\n return `${context.tenancy.getCurrentTenant().id}-headless-cms`;\n};\n"]}
@@ -1,7 +0,0 @@
1
- /**
2
- * File not used anymore.
3
- */
4
- import { ModelFieldFinder } from "./fieldFinder";
5
- import { CmsIndexEntry } from "../../types";
6
- import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
7
- export declare const entryValueFixer: (_: CmsModel, finder: ModelFieldFinder, target: CmsIndexEntry) => CmsEntry;
@@ -1,124 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.entryValueFixer = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _cleanDatabaseRecord = require("./cleanDatabaseRecord");
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
- const convertTimeToNumber = time => {
19
- if (!time) {
20
- return null;
21
- }
22
-
23
- const [hours, minutes, seconds = 0] = time.split(":").map(Number);
24
- return hours * 60 * 60 + minutes * 60 + seconds;
25
- };
26
-
27
- const fixRawValues = (target, finder) => {
28
- const entry = _objectSpread({}, target);
29
-
30
- for (const fieldId in entry.rawValues) {
31
- // if field is ref field then continue, otherwise break
32
- const field = finder.findById(target.modelId, fieldId);
33
-
34
- if (field.type !== "ref") {
35
- continue;
36
- }
37
-
38
- const existingValue = entry.values[fieldId];
39
- const rawValue = entry.rawValues[fieldId]; // always remove from rawValue
40
-
41
- delete entry.rawValues[fieldId]; // if there is something in values - do not switch it
42
-
43
- if (typeof existingValue !== "undefined" || rawValue === undefined || rawValue === null) {
44
- continue;
45
- }
46
-
47
- entry.values[fieldId] = rawValue;
48
- }
49
-
50
- return entry;
51
- };
52
-
53
- const fixTime = (field, time) => {
54
- if (isNaN(time) === false) {
55
- return parseInt(time);
56
- } // lets not reinvent the wheel
57
-
58
-
59
- try {
60
- return convertTimeToNumber(time);
61
- } catch (err) {
62
- console.log(`fixTime on field "${field.fieldId}" failed`, err);
63
- return null;
64
- }
65
- };
66
-
67
- const fixDateTime = (field, dateTime) => {
68
- switch (field.settings.type) {
69
- case "time":
70
- return fixTime(field, dateTime);
71
-
72
- case "date":
73
- return new Date(dateTime).toISOString();
74
-
75
- case "dateTimeWithoutTimezone":
76
- return new Date(dateTime).toISOString();
77
-
78
- default:
79
- return dateTime;
80
- }
81
- };
82
-
83
- const fixNumber = (_, value) => {
84
- if (value === undefined || value === null) {
85
- return null;
86
- }
87
-
88
- return parseFloat(value);
89
- };
90
-
91
- const fieldFixMethods = {
92
- datetime: fixDateTime,
93
- number: fixNumber
94
- };
95
-
96
- const fixFieldValues = (target, finder) => {
97
- const entry = _objectSpread({}, target);
98
-
99
- for (const fieldId in target.values) {
100
- const field = finder.findById(target.modelId, fieldId);
101
-
102
- if (!field) {
103
- continue;
104
- }
105
-
106
- const fixMethod = fieldFixMethods[field.type];
107
-
108
- if (!fixMethod) {
109
- continue;
110
- } else if (target.values[fieldId] === null || target.values[fieldId] === undefined) {
111
- continue;
112
- }
113
-
114
- target.values[fieldId] = fixMethod(field, target.values[fieldId]);
115
- }
116
-
117
- return entry;
118
- };
119
-
120
- const entryValueFixer = (_, finder, target) => {
121
- return (0, _cleanDatabaseRecord.cleanDatabaseRecord)(fixFieldValues(fixRawValues(target, finder), finder));
122
- };
123
-
124
- exports.entryValueFixer = entryValueFixer;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["entryValueFixer.ts"],"names":["convertTimeToNumber","time","hours","minutes","seconds","split","map","Number","fixRawValues","target","finder","entry","fieldId","rawValues","field","findById","modelId","type","existingValue","values","rawValue","undefined","fixTime","isNaN","parseInt","err","console","log","fixDateTime","dateTime","settings","Date","toISOString","fixNumber","_","value","parseFloat","fieldFixMethods","datetime","number","fixFieldValues","fixMethod","entryValueFixer"],"mappings":";;;;;;;;;;;AAKA;;;;;;AAIA,MAAMA,mBAAmB,GAAIC,IAAD,IAAkC;AAC1D,MAAI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ACA,QAAI,CAACwB,SAAL,EAAgB;AACZ;AACH,KAFD,MAEO,IAAIhC,MAAM,CAACU,MAAP,CAAcP,OAAd,MAA2B,IAA3B,IAAmCH,MAAM,CAACU,MAAP,CAAcP,OAAd,MAA2BS,SAAlE,EAA6E;AAChF;AACH;;AACDZ,IAAAA,MAAM,CAACU,MAAP,CAAcP,OAAd,IAAyB6B,SAAS,CAAC3B,KAAD,EAAQL,MAAM,CAACU,MAAP,CAAcP,OAAd,CAAR,CAAlC;AACH;;AAED,SAAOD,KAAP;AACH,CArBD;;AAuBO,MAAM+B,eAAe,GAAG,CAC3BR,CAD2B,EAE3BxB,MAF2B,EAG3BD,MAH2B,KAIhB;AACX,SAAO,8CAAoB+B,cAAc,CAAChC,YAAY,CAACC,MAAD,EAASC,MAAT,CAAb,EAA+BA,MAA/B,CAAlC,CAAP;AACH,CANM","sourcesContent":["/**\n * File not used anymore.\n */\n// @ts-nocheck\nimport { ModelFieldFinder } from \"./fieldFinder\";\nimport { cleanDatabaseRecord } from \"./cleanDatabaseRecord\";\nimport { CmsIndexEntry } from \"../../types\";\nimport { CmsEntry, CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst fixRawValues = (target: CmsIndexEntry, finder: ModelFieldFinder): CmsIndexEntry => {\n const entry = {\n ...target\n };\n for (const fieldId in entry.rawValues) {\n // if field is ref field then continue, otherwise break\n const field = finder.findById(target.modelId, fieldId);\n if (field.type !== \"ref\") {\n continue;\n }\n const existingValue = entry.values[fieldId];\n const rawValue = entry.rawValues[fieldId];\n // always remove from rawValue\n delete entry.rawValues[fieldId];\n // if there is something in values - do not switch it\n if (typeof existingValue !== \"undefined\" || rawValue === undefined || rawValue === null) {\n continue;\n }\n entry.values[fieldId] = rawValue;\n }\n return entry;\n};\n\nconst fixTime = (field, time: any): number | null => {\n if (isNaN(time as number) === false) {\n return parseInt(time);\n }\n // lets not reinvent the wheel\n try {\n return convertTimeToNumber(time);\n } catch (err) {\n console.log(`fixTime on field \"${field.fieldId}\" failed`, err);\n return null;\n }\n};\n\nconst fixDateTime = (field: CmsModelField, dateTime: any): any => {\n switch (field.settings.type) {\n case \"time\":\n return fixTime(field, dateTime);\n case \"date\":\n return new Date(dateTime).toISOString();\n case \"dateTimeWithoutTimezone\":\n return new Date(dateTime).toISOString();\n default:\n return dateTime;\n }\n};\n\nconst fixNumber = (_: CmsModelField, value: any) => {\n if (value === undefined || value === null) {\n return null;\n }\n return parseFloat(value);\n};\n\nconst fieldFixMethods = {\n datetime: fixDateTime,\n number: fixNumber\n};\n\nconst fixFieldValues = (target: CmsIndexEntry, finder: ModelFieldFinder): CmsIndexEntry => {\n const entry = {\n ...target\n };\n\n for (const fieldId in target.values) {\n const field = finder.findById(target.modelId, fieldId);\n if (!field) {\n continue;\n }\n\n const fixMethod = fieldFixMethods[field.type];\n if (!fixMethod) {\n continue;\n } else if (target.values[fieldId] === null || target.values[fieldId] === undefined) {\n continue;\n }\n target.values[fieldId] = fixMethod(field, target.values[fieldId]);\n }\n\n return entry;\n};\n\nexport const entryValueFixer = (\n _: CmsModel,\n finder: ModelFieldFinder,\n target: CmsIndexEntry\n): CmsEntry => {\n return cleanDatabaseRecord(fixFieldValues(fixRawValues(target, finder), finder));\n};\n"]}
@@ -1,9 +0,0 @@
1
- /**
2
- * File not used anymore.
3
- */
4
- import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
5
- export interface ModelFieldFinder {
6
- findById: (model: CmsModel | string, fieldId: string) => CmsModelField;
7
- findByType: (model: CmsModel | string, type: string) => CmsModelField[];
8
- }
9
- export declare const createFieldFinder: (models: CmsModel[]) => ModelFieldFinder;