@strapi/i18n 5.56.0 → 5.57.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 (88) hide show
  1. package/dist/admin/contentManagerHooks/editView.js +0 -1
  2. package/dist/admin/contentManagerHooks/editView.js.map +1 -1
  3. package/dist/admin/contentManagerHooks/editView.mjs +0 -1
  4. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
  5. package/dist/server/bootstrap.js +2 -2
  6. package/dist/server/bootstrap.js.map +1 -1
  7. package/dist/server/bootstrap.mjs +1 -1
  8. package/dist/server/bootstrap.mjs.map +1 -1
  9. package/dist/server/controllers/content-types.js +11 -11
  10. package/dist/server/controllers/content-types.js.map +1 -1
  11. package/dist/server/controllers/content-types.mjs +11 -11
  12. package/dist/server/controllers/content-types.mjs.map +1 -1
  13. package/dist/server/controllers/locales.js +2 -2
  14. package/dist/server/controllers/locales.js.map +1 -1
  15. package/dist/server/controllers/locales.mjs +2 -2
  16. package/dist/server/controllers/locales.mjs.map +1 -1
  17. package/dist/server/controllers/validate-locale-creation.js +1 -2
  18. package/dist/server/controllers/validate-locale-creation.js.map +1 -1
  19. package/dist/server/controllers/validate-locale-creation.mjs +1 -2
  20. package/dist/server/controllers/validate-locale-creation.mjs.map +1 -1
  21. package/dist/server/graphql.js +4 -4
  22. package/dist/server/graphql.js.map +1 -1
  23. package/dist/server/graphql.mjs +2 -2
  24. package/dist/server/graphql.mjs.map +1 -1
  25. package/dist/server/index.js.map +1 -1
  26. package/dist/server/index.mjs.map +1 -1
  27. package/dist/server/localization.js +36 -0
  28. package/dist/server/localization.js.map +1 -0
  29. package/dist/server/localization.mjs +34 -0
  30. package/dist/server/localization.mjs.map +1 -0
  31. package/dist/server/register.js +2 -0
  32. package/dist/server/register.js.map +1 -1
  33. package/dist/server/register.mjs +2 -0
  34. package/dist/server/register.mjs.map +1 -1
  35. package/dist/server/services/content-types.js +12 -12
  36. package/dist/server/services/content-types.js.map +1 -1
  37. package/dist/server/services/content-types.mjs +11 -11
  38. package/dist/server/services/content-types.mjs.map +1 -1
  39. package/dist/server/services/fill-from-locale.js +5 -6
  40. package/dist/server/services/fill-from-locale.js.map +1 -1
  41. package/dist/server/services/fill-from-locale.mjs +5 -6
  42. package/dist/server/services/fill-from-locale.mjs.map +1 -1
  43. package/dist/server/services/locales.js +1 -2
  44. package/dist/server/services/locales.js.map +1 -1
  45. package/dist/server/services/locales.mjs +1 -2
  46. package/dist/server/services/locales.mjs.map +1 -1
  47. package/dist/server/services/localizations.js +4 -4
  48. package/dist/server/services/localizations.js.map +1 -1
  49. package/dist/server/services/localizations.mjs +1 -1
  50. package/dist/server/services/localizations.mjs.map +1 -1
  51. package/dist/server/services/metrics.js +1 -2
  52. package/dist/server/services/metrics.js.map +1 -1
  53. package/dist/server/services/metrics.mjs +1 -2
  54. package/dist/server/services/metrics.mjs.map +1 -1
  55. package/dist/server/services/permissions/actions.js +5 -5
  56. package/dist/server/services/permissions/actions.js.map +1 -1
  57. package/dist/server/services/permissions/actions.mjs +5 -5
  58. package/dist/server/services/permissions/actions.mjs.map +1 -1
  59. package/dist/server/services/permissions/sections-builder.js +2 -2
  60. package/dist/server/services/permissions/sections-builder.js.map +1 -1
  61. package/dist/server/services/permissions/sections-builder.mjs +1 -1
  62. package/dist/server/services/permissions/sections-builder.mjs.map +1 -1
  63. package/dist/server/services/sanitize/index.js +2 -2
  64. package/dist/server/services/sanitize/index.js.map +1 -1
  65. package/dist/server/services/sanitize/index.mjs +1 -1
  66. package/dist/server/services/sanitize/index.mjs.map +1 -1
  67. package/dist/server/src/controllers/content-types.d.ts.map +1 -1
  68. package/dist/server/src/controllers/validate-locale-creation.d.ts.map +1 -1
  69. package/dist/server/src/index.d.ts +1 -2
  70. package/dist/server/src/index.d.ts.map +1 -1
  71. package/dist/server/src/localization.d.ts +4 -0
  72. package/dist/server/src/localization.d.ts.map +1 -0
  73. package/dist/server/src/register.d.ts.map +1 -1
  74. package/dist/server/src/services/fill-from-locale.d.ts.map +1 -1
  75. package/dist/server/src/services/index.d.ts.map +1 -1
  76. package/dist/server/src/services/locales.d.ts.map +1 -1
  77. package/dist/server/src/services/metrics.d.ts.map +1 -1
  78. package/dist/server/src/validation/content-types.d.ts.map +1 -1
  79. package/dist/server/src/validation/locales.d.ts.map +1 -1
  80. package/dist/server/validation/content-types.js +1 -2
  81. package/dist/server/validation/content-types.js.map +1 -1
  82. package/dist/server/validation/content-types.mjs +1 -2
  83. package/dist/server/validation/content-types.mjs.map +1 -1
  84. package/dist/server/validation/locales.js +1 -2
  85. package/dist/server/validation/locales.js.map +1 -1
  86. package/dist/server/validation/locales.mjs +1 -2
  87. package/dist/server/validation/locales.mjs.map +1 -1
  88. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"validate-locale-creation.js","sources":["../../../server/src/controllers/validate-locale-creation.ts"],"sourcesContent":["import { get } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\nimport { getService } from '../utils';\n\nconst { ApplicationError } = errors;\n\n// TODO: v5 if implemented in the CM => delete this middleware\nconst validateLocaleCreation: Core.MiddlewareHandler = async (ctx, next) => {\n const { model } = ctx.params;\n const { query } = ctx.request;\n\n // Prevent empty body\n if (!ctx.request.body) {\n ctx.request.body = {};\n }\n\n const body = ctx.request.body as any;\n\n const { getValidLocale, isLocalizedContentType } = getService('content-types');\n\n const modelDef = strapi.getModel(model) as Struct.ContentTypeSchema;\n\n if (!isLocalizedContentType(modelDef)) {\n return next();\n }\n\n // Prevent empty string locale\n const locale = get('locale', query) || get('locale', body) || undefined;\n\n // cleanup to avoid creating duplicates in single types\n ctx.request.query = {};\n\n let entityLocale;\n try {\n entityLocale = await getValidLocale(locale);\n } catch {\n throw new ApplicationError(\"This locale doesn't exist\");\n }\n\n body.locale = entityLocale;\n\n if (modelDef.kind === 'singleType') {\n const entity = await strapi.entityService.findMany(modelDef.uid, {\n locale: entityLocale,\n } as any); // TODO: add this type to entityService\n\n ctx.request.query.locale = body.locale;\n\n // updating\n if (entity) {\n return next();\n }\n }\n\n return next();\n};\n\nexport default validateLocaleCreation;\n"],"names":["ApplicationError","errors","validateLocaleCreation","ctx","next","model","params","query","request","body","getValidLocale","isLocalizedContentType","getService","modelDef","strapi","getModel","locale","get","undefined","entityLocale","kind","entity","entityService","findMany","uid"],"mappings":";;;;;;AAKA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B;AACA,MAAMC,sBAAAA,GAAiD,OAAOC,GAAAA,EAAKC,IAAAA,GAAAA;AACjE,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGF,IAAIG,MAAM;AAC5B,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGJ,IAAIK,OAAO;;AAG7B,IAAA,IAAI,CAACL,GAAAA,CAAIK,OAAO,CAACC,IAAI,EAAE;AACrBN,QAAAA,GAAAA,CAAIK,OAAO,CAACC,IAAI,GAAG,EAAC;AACtB,IAAA;AAEA,IAAA,MAAMA,IAAAA,GAAON,GAAAA,CAAIK,OAAO,CAACC,IAAI;AAE7B,IAAA,MAAM,EAAEC,cAAc,EAAEC,sBAAsB,EAAE,GAAGC,gBAAAA,CAAW,eAAA,CAAA;IAE9D,MAAMC,QAAAA,GAAWC,MAAAA,CAAOC,QAAQ,CAACV,KAAAA,CAAAA;IAEjC,IAAI,CAACM,uBAAuBE,QAAAA,CAAAA,EAAW;QACrC,OAAOT,IAAAA,EAAAA;AACT,IAAA;;AAGA,IAAA,MAAMY,SAASC,MAAAA,CAAI,QAAA,EAAUV,KAAAA,CAAAA,IAAUU,MAAAA,CAAI,UAAUR,IAAAA,CAAAA,IAASS,SAAAA;;AAG9Df,IAAAA,GAAAA,CAAIK,OAAO,CAACD,KAAK,GAAG,EAAC;IAErB,IAAIY,YAAAA;IACJ,IAAI;AACFA,QAAAA,YAAAA,GAAe,MAAMT,cAAAA,CAAeM,MAAAA,CAAAA;AACtC,IAAA,CAAA,CAAE,OAAM;AACN,QAAA,MAAM,IAAIhB,gBAAAA,CAAiB,2BAAA,CAAA;AAC7B,IAAA;AAEAS,IAAAA,IAAAA,CAAKO,MAAM,GAAGG,YAAAA;IAEd,IAAIN,QAAAA,CAASO,IAAI,KAAK,YAAA,EAAc;QAClC,MAAMC,MAAAA,GAAS,MAAMP,MAAAA,CAAOQ,aAAa,CAACC,QAAQ,CAACV,QAAAA,CAASW,GAAG,EAAE;YAC/DR,MAAAA,EAAQG;AACV,SAAA,CAAA,CAAA;AAEAhB,QAAAA,GAAAA,CAAIK,OAAO,CAACD,KAAK,CAACS,MAAM,GAAGP,KAAKO,MAAM;;AAGtC,QAAA,IAAIK,MAAAA,EAAQ;YACV,OAAOjB,IAAAA,EAAAA;AACT,QAAA;AACF,IAAA;IAEA,OAAOA,IAAAA,EAAAA;AACT;;;;"}
1
+ {"version":3,"file":"validate-locale-creation.js","sources":["../../../server/src/controllers/validate-locale-creation.ts"],"sourcesContent":["import { errors } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\nimport { getService } from '../utils';\n\nconst { ApplicationError } = errors;\n\n// TODO: v5 if implemented in the CM => delete this middleware\nconst validateLocaleCreation: Core.MiddlewareHandler = async (ctx, next) => {\n const { model } = ctx.params;\n const { query } = ctx.request;\n\n // Prevent empty body\n if (!ctx.request.body) {\n ctx.request.body = {};\n }\n\n const body = ctx.request.body as any;\n\n const { getValidLocale, isLocalizedContentType } = getService('content-types');\n\n const modelDef = strapi.getModel(model) as Struct.ContentTypeSchema;\n\n if (!isLocalizedContentType(modelDef)) {\n return next();\n }\n\n // Prevent empty string locale\n const locale = query?.locale || body?.locale || undefined;\n\n // cleanup to avoid creating duplicates in single types\n ctx.request.query = {};\n\n let entityLocale;\n try {\n entityLocale = await getValidLocale(locale);\n } catch {\n throw new ApplicationError(\"This locale doesn't exist\");\n }\n\n body.locale = entityLocale;\n\n if (modelDef.kind === 'singleType') {\n const entity = await strapi.entityService.findMany(modelDef.uid, {\n locale: entityLocale,\n } as any); // TODO: add this type to entityService\n\n ctx.request.query.locale = body.locale;\n\n // updating\n if (entity) {\n return next();\n }\n }\n\n return next();\n};\n\nexport default validateLocaleCreation;\n"],"names":["ApplicationError","errors","validateLocaleCreation","ctx","next","model","params","query","request","body","getValidLocale","isLocalizedContentType","getService","modelDef","strapi","getModel","locale","undefined","entityLocale","kind","entity","entityService","findMany","uid"],"mappings":";;;;;AAIA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B;AACA,MAAMC,sBAAAA,GAAiD,OAAOC,GAAAA,EAAKC,IAAAA,GAAAA;AACjE,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGF,IAAIG,MAAM;AAC5B,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGJ,IAAIK,OAAO;;AAG7B,IAAA,IAAI,CAACL,GAAAA,CAAIK,OAAO,CAACC,IAAI,EAAE;AACrBN,QAAAA,GAAAA,CAAIK,OAAO,CAACC,IAAI,GAAG,EAAC;AACtB,IAAA;AAEA,IAAA,MAAMA,IAAAA,GAAON,GAAAA,CAAIK,OAAO,CAACC,IAAI;AAE7B,IAAA,MAAM,EAAEC,cAAc,EAAEC,sBAAsB,EAAE,GAAGC,gBAAAA,CAAW,eAAA,CAAA;IAE9D,MAAMC,QAAAA,GAAWC,MAAAA,CAAOC,QAAQ,CAACV,KAAAA,CAAAA;IAEjC,IAAI,CAACM,uBAAuBE,QAAAA,CAAAA,EAAW;QACrC,OAAOT,IAAAA,EAAAA;AACT,IAAA;;AAGA,IAAA,MAAMY,MAAAA,GAAST,KAAAA,EAAOS,MAAAA,IAAUP,IAAAA,EAAMO,MAAAA,IAAUC,SAAAA;;AAGhDd,IAAAA,GAAAA,CAAIK,OAAO,CAACD,KAAK,GAAG,EAAC;IAErB,IAAIW,YAAAA;IACJ,IAAI;AACFA,QAAAA,YAAAA,GAAe,MAAMR,cAAAA,CAAeM,MAAAA,CAAAA;AACtC,IAAA,CAAA,CAAE,OAAM;AACN,QAAA,MAAM,IAAIhB,gBAAAA,CAAiB,2BAAA,CAAA;AAC7B,IAAA;AAEAS,IAAAA,IAAAA,CAAKO,MAAM,GAAGE,YAAAA;IAEd,IAAIL,QAAAA,CAASM,IAAI,KAAK,YAAA,EAAc;QAClC,MAAMC,MAAAA,GAAS,MAAMN,MAAAA,CAAOO,aAAa,CAACC,QAAQ,CAACT,QAAAA,CAASU,GAAG,EAAE;YAC/DP,MAAAA,EAAQE;AACV,SAAA,CAAA,CAAA;AAEAf,QAAAA,GAAAA,CAAIK,OAAO,CAACD,KAAK,CAACS,MAAM,GAAGP,KAAKO,MAAM;;AAGtC,QAAA,IAAII,MAAAA,EAAQ;YACV,OAAOhB,IAAAA,EAAAA;AACT,QAAA;AACF,IAAA;IAEA,OAAOA,IAAAA,EAAAA;AACT;;;;"}
@@ -1,4 +1,3 @@
1
- import { get } from 'lodash/fp';
2
1
  import { errors } from '@strapi/utils';
3
2
  import { getService } from '../utils/index.mjs';
4
3
 
@@ -18,7 +17,7 @@ const validateLocaleCreation = async (ctx, next)=>{
18
17
  return next();
19
18
  }
20
19
  // Prevent empty string locale
21
- const locale = get('locale', query) || get('locale', body) || undefined;
20
+ const locale = query?.locale || body?.locale || undefined;
22
21
  // cleanup to avoid creating duplicates in single types
23
22
  ctx.request.query = {};
24
23
  let entityLocale;
@@ -1 +1 @@
1
- {"version":3,"file":"validate-locale-creation.mjs","sources":["../../../server/src/controllers/validate-locale-creation.ts"],"sourcesContent":["import { get } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\nimport { getService } from '../utils';\n\nconst { ApplicationError } = errors;\n\n// TODO: v5 if implemented in the CM => delete this middleware\nconst validateLocaleCreation: Core.MiddlewareHandler = async (ctx, next) => {\n const { model } = ctx.params;\n const { query } = ctx.request;\n\n // Prevent empty body\n if (!ctx.request.body) {\n ctx.request.body = {};\n }\n\n const body = ctx.request.body as any;\n\n const { getValidLocale, isLocalizedContentType } = getService('content-types');\n\n const modelDef = strapi.getModel(model) as Struct.ContentTypeSchema;\n\n if (!isLocalizedContentType(modelDef)) {\n return next();\n }\n\n // Prevent empty string locale\n const locale = get('locale', query) || get('locale', body) || undefined;\n\n // cleanup to avoid creating duplicates in single types\n ctx.request.query = {};\n\n let entityLocale;\n try {\n entityLocale = await getValidLocale(locale);\n } catch {\n throw new ApplicationError(\"This locale doesn't exist\");\n }\n\n body.locale = entityLocale;\n\n if (modelDef.kind === 'singleType') {\n const entity = await strapi.entityService.findMany(modelDef.uid, {\n locale: entityLocale,\n } as any); // TODO: add this type to entityService\n\n ctx.request.query.locale = body.locale;\n\n // updating\n if (entity) {\n return next();\n }\n }\n\n return next();\n};\n\nexport default validateLocaleCreation;\n"],"names":["ApplicationError","errors","validateLocaleCreation","ctx","next","model","params","query","request","body","getValidLocale","isLocalizedContentType","getService","modelDef","strapi","getModel","locale","get","undefined","entityLocale","kind","entity","entityService","findMany","uid"],"mappings":";;;;AAKA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B;AACA,MAAMC,sBAAAA,GAAiD,OAAOC,GAAAA,EAAKC,IAAAA,GAAAA;AACjE,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGF,IAAIG,MAAM;AAC5B,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGJ,IAAIK,OAAO;;AAG7B,IAAA,IAAI,CAACL,GAAAA,CAAIK,OAAO,CAACC,IAAI,EAAE;AACrBN,QAAAA,GAAAA,CAAIK,OAAO,CAACC,IAAI,GAAG,EAAC;AACtB,IAAA;AAEA,IAAA,MAAMA,IAAAA,GAAON,GAAAA,CAAIK,OAAO,CAACC,IAAI;AAE7B,IAAA,MAAM,EAAEC,cAAc,EAAEC,sBAAsB,EAAE,GAAGC,UAAAA,CAAW,eAAA,CAAA;IAE9D,MAAMC,QAAAA,GAAWC,MAAAA,CAAOC,QAAQ,CAACV,KAAAA,CAAAA;IAEjC,IAAI,CAACM,uBAAuBE,QAAAA,CAAAA,EAAW;QACrC,OAAOT,IAAAA,EAAAA;AACT,IAAA;;AAGA,IAAA,MAAMY,SAASC,GAAAA,CAAI,QAAA,EAAUV,KAAAA,CAAAA,IAAUU,GAAAA,CAAI,UAAUR,IAAAA,CAAAA,IAASS,SAAAA;;AAG9Df,IAAAA,GAAAA,CAAIK,OAAO,CAACD,KAAK,GAAG,EAAC;IAErB,IAAIY,YAAAA;IACJ,IAAI;AACFA,QAAAA,YAAAA,GAAe,MAAMT,cAAAA,CAAeM,MAAAA,CAAAA;AACtC,IAAA,CAAA,CAAE,OAAM;AACN,QAAA,MAAM,IAAIhB,gBAAAA,CAAiB,2BAAA,CAAA;AAC7B,IAAA;AAEAS,IAAAA,IAAAA,CAAKO,MAAM,GAAGG,YAAAA;IAEd,IAAIN,QAAAA,CAASO,IAAI,KAAK,YAAA,EAAc;QAClC,MAAMC,MAAAA,GAAS,MAAMP,MAAAA,CAAOQ,aAAa,CAACC,QAAQ,CAACV,QAAAA,CAASW,GAAG,EAAE;YAC/DR,MAAAA,EAAQG;AACV,SAAA,CAAA,CAAA;AAEAhB,QAAAA,GAAAA,CAAIK,OAAO,CAACD,KAAK,CAACS,MAAM,GAAGP,KAAKO,MAAM;;AAGtC,QAAA,IAAIK,MAAAA,EAAQ;YACV,OAAOjB,IAAAA,EAAAA;AACT,QAAA;AACF,IAAA;IAEA,OAAOA,IAAAA,EAAAA;AACT;;;;"}
1
+ {"version":3,"file":"validate-locale-creation.mjs","sources":["../../../server/src/controllers/validate-locale-creation.ts"],"sourcesContent":["import { errors } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\nimport { getService } from '../utils';\n\nconst { ApplicationError } = errors;\n\n// TODO: v5 if implemented in the CM => delete this middleware\nconst validateLocaleCreation: Core.MiddlewareHandler = async (ctx, next) => {\n const { model } = ctx.params;\n const { query } = ctx.request;\n\n // Prevent empty body\n if (!ctx.request.body) {\n ctx.request.body = {};\n }\n\n const body = ctx.request.body as any;\n\n const { getValidLocale, isLocalizedContentType } = getService('content-types');\n\n const modelDef = strapi.getModel(model) as Struct.ContentTypeSchema;\n\n if (!isLocalizedContentType(modelDef)) {\n return next();\n }\n\n // Prevent empty string locale\n const locale = query?.locale || body?.locale || undefined;\n\n // cleanup to avoid creating duplicates in single types\n ctx.request.query = {};\n\n let entityLocale;\n try {\n entityLocale = await getValidLocale(locale);\n } catch {\n throw new ApplicationError(\"This locale doesn't exist\");\n }\n\n body.locale = entityLocale;\n\n if (modelDef.kind === 'singleType') {\n const entity = await strapi.entityService.findMany(modelDef.uid, {\n locale: entityLocale,\n } as any); // TODO: add this type to entityService\n\n ctx.request.query.locale = body.locale;\n\n // updating\n if (entity) {\n return next();\n }\n }\n\n return next();\n};\n\nexport default validateLocaleCreation;\n"],"names":["ApplicationError","errors","validateLocaleCreation","ctx","next","model","params","query","request","body","getValidLocale","isLocalizedContentType","getService","modelDef","strapi","getModel","locale","undefined","entityLocale","kind","entity","entityService","findMany","uid"],"mappings":";;;AAIA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B;AACA,MAAMC,sBAAAA,GAAiD,OAAOC,GAAAA,EAAKC,IAAAA,GAAAA;AACjE,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGF,IAAIG,MAAM;AAC5B,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGJ,IAAIK,OAAO;;AAG7B,IAAA,IAAI,CAACL,GAAAA,CAAIK,OAAO,CAACC,IAAI,EAAE;AACrBN,QAAAA,GAAAA,CAAIK,OAAO,CAACC,IAAI,GAAG,EAAC;AACtB,IAAA;AAEA,IAAA,MAAMA,IAAAA,GAAON,GAAAA,CAAIK,OAAO,CAACC,IAAI;AAE7B,IAAA,MAAM,EAAEC,cAAc,EAAEC,sBAAsB,EAAE,GAAGC,UAAAA,CAAW,eAAA,CAAA;IAE9D,MAAMC,QAAAA,GAAWC,MAAAA,CAAOC,QAAQ,CAACV,KAAAA,CAAAA;IAEjC,IAAI,CAACM,uBAAuBE,QAAAA,CAAAA,EAAW;QACrC,OAAOT,IAAAA,EAAAA;AACT,IAAA;;AAGA,IAAA,MAAMY,MAAAA,GAAST,KAAAA,EAAOS,MAAAA,IAAUP,IAAAA,EAAMO,MAAAA,IAAUC,SAAAA;;AAGhDd,IAAAA,GAAAA,CAAIK,OAAO,CAACD,KAAK,GAAG,EAAC;IAErB,IAAIW,YAAAA;IACJ,IAAI;AACFA,QAAAA,YAAAA,GAAe,MAAMR,cAAAA,CAAeM,MAAAA,CAAAA;AACtC,IAAA,CAAA,CAAE,OAAM;AACN,QAAA,MAAM,IAAIhB,gBAAAA,CAAiB,2BAAA,CAAA;AAC7B,IAAA;AAEAS,IAAAA,IAAAA,CAAKO,MAAM,GAAGE,YAAAA;IAEd,IAAIL,QAAAA,CAASM,IAAI,KAAK,YAAA,EAAc;QAClC,MAAMC,MAAAA,GAAS,MAAMN,MAAAA,CAAOO,aAAa,CAACC,QAAQ,CAACT,QAAAA,CAASU,GAAG,EAAE;YAC/DP,MAAAA,EAAQE;AACV,SAAA,CAAA,CAAA;AAEAf,QAAAA,GAAAA,CAAIK,OAAO,CAACD,KAAK,CAACS,MAAM,GAAGP,KAAKO,MAAM;;AAGtC,QAAA,IAAII,MAAAA,EAAQ;YACV,OAAOhB,IAAAA,EAAAA;AACT,QAAA;AACF,IAAA;IAEA,OAAOA,IAAAA,EAAAA;AACT;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('lodash/fp');
3
+ var _ = require('lodash');
4
4
  var utils = require('@strapi/utils');
5
5
 
6
6
  const { ValidationError } = utils.errors;
@@ -60,13 +60,13 @@ const getLocaleScalar = ({ nexus })=>{
60
60
  return nexus.scalarType({
61
61
  name: LOCALE_SCALAR_TYPENAME,
62
62
  description: 'A string used to identify an i18n locale',
63
- serialize: fp.identity,
64
- parseValue: fp.identity,
63
+ serialize: _.identity,
64
+ parseValue: _.identity,
65
65
  parseLiteral (ast) {
66
66
  if (ast.kind !== 'StringValue') {
67
67
  throw new ValidationError('Locale cannot represent non string type');
68
68
  }
69
- const isValidLocale = ast.value === '*' || locales.find(fp.propEq('code', ast.value));
69
+ const isValidLocale = ast.value === '*' || locales.find(_.matchesProperty('code', ast.value));
70
70
  if (!isValidLocale) {
71
71
  throw new ValidationError('Unknown locale supplied');
72
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.js","sources":["../../server/src/graphql.ts"],"sourcesContent":["import { propEq, identity } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nconst { ValidationError } = errors;\n\nconst LOCALE_SCALAR_TYPENAME = 'I18NLocaleCode';\nconst LOCALE_ARG_PLUGIN_NAME = 'I18NLocaleArg';\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => ({\n register() {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const { isLocalizedContentType } = getI18NService('content-types');\n\n const extensionService = getGraphQLService('extension');\n\n extensionService.shadowCRUD('plugin::i18n.locale').disableMutations();\n\n // Disable unwanted fields for localized content types\n Object.entries(strapi.contentTypes).forEach(([uid, ct]) => {\n if (isLocalizedContentType(ct)) {\n // Disable locale field in localized inputs\n extensionService.shadowCRUD(uid).field('locale').disableInput();\n\n // Disable localizations field in localized inputs\n extensionService.shadowCRUD(uid).field('localizations').disableInput();\n }\n });\n\n extensionService.use(({ nexus, typeRegistry }: any) => {\n const i18nLocaleArgPlugin = getI18nLocaleArgPlugin({ nexus, typeRegistry });\n const i18nLocaleScalar = getLocaleScalar({ nexus });\n return {\n plugins: [i18nLocaleArgPlugin],\n types: [i18nLocaleScalar],\n\n resolversConfig: {\n // Modify the default scope associated to find and findOne locale queries to match the actual action name\n 'Query.i18NLocale': { auth: { scope: 'plugin::i18n.locales.listLocales' } },\n 'Query.i18NLocales': { auth: { scope: 'plugin::i18n.locales.listLocales' } },\n },\n };\n });\n },\n});\n\nconst getLocaleScalar = ({ nexus }: any) => {\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const locales = getI18NService('iso-locales').getIsoLocales();\n\n return nexus.scalarType({\n name: LOCALE_SCALAR_TYPENAME,\n\n description: 'A string used to identify an i18n locale',\n\n serialize: identity,\n parseValue: identity,\n\n parseLiteral(ast: any) {\n if (ast.kind !== 'StringValue') {\n throw new ValidationError('Locale cannot represent non string type');\n }\n\n const isValidLocale = ast.value === '*' || locales.find(propEq('code', ast.value));\n\n if (!isValidLocale) {\n throw new ValidationError('Unknown locale supplied');\n }\n\n return ast.value;\n },\n });\n};\n\nconst getI18nLocaleArgPlugin = ({ nexus, typeRegistry }: any) => {\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const { isLocalizedContentType } = getI18NService('content-types');\n\n return nexus.plugin({\n name: LOCALE_ARG_PLUGIN_NAME,\n\n onAddOutputField(config: any) {\n // Add the locale arg to the queries on localized CTs\n\n const { parentType } = config;\n\n // Only target queries or mutations\n if (parentType !== 'Query' && parentType !== 'Mutation') {\n return;\n }\n\n let contentType;\n\n if (config?.extensions?.strapi?.contentType) {\n contentType = config.extensions.strapi.contentType;\n } else {\n const registryType = typeRegistry.get(config.type);\n\n if (!registryType) {\n return;\n }\n\n contentType = registryType.config.contentType;\n }\n\n // Ignore non-localized content types\n if (!isLocalizedContentType(contentType)) {\n return;\n }\n\n if (!config.args) {\n config.args = {};\n }\n\n config.args.locale = nexus.arg({\n type: LOCALE_SCALAR_TYPENAME,\n description: 'The locale to use for the query',\n });\n },\n });\n};\n"],"names":["ValidationError","errors","LOCALE_SCALAR_TYPENAME","LOCALE_ARG_PLUGIN_NAME","strapi","register","service","getGraphQLService","plugin","getI18NService","isLocalizedContentType","extensionService","shadowCRUD","disableMutations","Object","entries","contentTypes","forEach","uid","ct","field","disableInput","use","nexus","typeRegistry","i18nLocaleArgPlugin","getI18nLocaleArgPlugin","i18nLocaleScalar","getLocaleScalar","plugins","types","resolversConfig","auth","scope","locales","getIsoLocales","scalarType","name","description","serialize","identity","parseValue","parseLiteral","ast","kind","isValidLocale","value","find","propEq","onAddOutputField","config","parentType","contentType","extensions","registryType","get","type","args","locale","arg"],"mappings":";;;;;AAIA,MAAM,EAAEA,eAAe,EAAE,GAAGC,YAAAA;AAE5B,MAAMC,sBAAAA,GAAyB,gBAAA;AAC/B,MAAMC,sBAAAA,GAAyB,eAAA;AAE/B,sBAAe,CAAA,CAAC,EAAEC,QAAAA,OAAM,EAA2B,IAAM;AACvDC,QAAAA,QAAAA,CAAAA,GAAAA;AACE,YAAA,MAAM,EAAEC,OAAAA,EAASC,iBAAiB,EAAE,GAAGH,OAAAA,CAAOI,MAAM,CAAC,SAAA,CAAA;AACrD,YAAA,MAAM,EAAEF,OAAAA,EAASG,cAAc,EAAE,GAAGL,OAAAA,CAAOI,MAAM,CAAC,MAAA,CAAA;AAElD,YAAA,MAAM,EAAEE,sBAAsB,EAAE,GAAGD,cAAAA,CAAe,eAAA,CAAA;AAElD,YAAA,MAAME,mBAAmBJ,iBAAAA,CAAkB,WAAA,CAAA;YAE3CI,gBAAAA,CAAiBC,UAAU,CAAC,qBAAA,CAAA,CAAuBC,gBAAgB,EAAA;;YAGnEC,MAAAA,CAAOC,OAAO,CAACX,OAAAA,CAAOY,YAAY,CAAA,CAAEC,OAAO,CAAC,CAAC,CAACC,GAAAA,EAAKC,EAAAA,CAAG,GAAA;AACpD,gBAAA,IAAIT,uBAAuBS,EAAAA,CAAAA,EAAK;;AAE9BR,oBAAAA,gBAAAA,CAAiBC,UAAU,CAACM,GAAAA,CAAAA,CAAKE,KAAK,CAAC,UAAUC,YAAY,EAAA;;AAG7DV,oBAAAA,gBAAAA,CAAiBC,UAAU,CAACM,GAAAA,CAAAA,CAAKE,KAAK,CAAC,iBAAiBC,YAAY,EAAA;AACtE,gBAAA;AACF,YAAA,CAAA,CAAA;AAEAV,YAAAA,gBAAAA,CAAiBW,GAAG,CAAC,CAAC,EAAEC,KAAK,EAAEC,YAAY,EAAO,GAAA;AAChD,gBAAA,MAAMC,sBAAsBC,sBAAAA,CAAu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,GAAG,EAAC;AACjB,YAAA;AAEAP,YAAAA,MAAAA,CAAOO,IAAI,CAACC,MAAM,GAAGnC,KAAAA,CAAMoC,GAAG,CAAC;gBAC7BH,IAAAA,EAAMtD,sBAAAA;gBACNoC,WAAAA,EAAa;AACf,aAAA,CAAA;AACF,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"graphql.js","sources":["../../server/src/graphql.ts"],"sourcesContent":["import { matchesProperty, identity } from 'lodash';\nimport { errors } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nconst { ValidationError } = errors;\n\nconst LOCALE_SCALAR_TYPENAME = 'I18NLocaleCode';\nconst LOCALE_ARG_PLUGIN_NAME = 'I18NLocaleArg';\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => ({\n register() {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const { isLocalizedContentType } = getI18NService('content-types');\n\n const extensionService = getGraphQLService('extension');\n\n extensionService.shadowCRUD('plugin::i18n.locale').disableMutations();\n\n // Disable unwanted fields for localized content types\n Object.entries(strapi.contentTypes).forEach(([uid, ct]) => {\n if (isLocalizedContentType(ct)) {\n // Disable locale field in localized inputs\n extensionService.shadowCRUD(uid).field('locale').disableInput();\n\n // Disable localizations field in localized inputs\n extensionService.shadowCRUD(uid).field('localizations').disableInput();\n }\n });\n\n extensionService.use(({ nexus, typeRegistry }: any) => {\n const i18nLocaleArgPlugin = getI18nLocaleArgPlugin({ nexus, typeRegistry });\n const i18nLocaleScalar = getLocaleScalar({ nexus });\n return {\n plugins: [i18nLocaleArgPlugin],\n types: [i18nLocaleScalar],\n\n resolversConfig: {\n // Modify the default scope associated to find and findOne locale queries to match the actual action name\n 'Query.i18NLocale': { auth: { scope: 'plugin::i18n.locales.listLocales' } },\n 'Query.i18NLocales': { auth: { scope: 'plugin::i18n.locales.listLocales' } },\n },\n };\n });\n },\n});\n\nconst getLocaleScalar = ({ nexus }: any) => {\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const locales = getI18NService('iso-locales').getIsoLocales();\n\n return nexus.scalarType({\n name: LOCALE_SCALAR_TYPENAME,\n\n description: 'A string used to identify an i18n locale',\n\n serialize: identity,\n parseValue: identity,\n\n parseLiteral(ast: any) {\n if (ast.kind !== 'StringValue') {\n throw new ValidationError('Locale cannot represent non string type');\n }\n\n const isValidLocale = ast.value === '*' || locales.find(matchesProperty('code', ast.value));\n\n if (!isValidLocale) {\n throw new ValidationError('Unknown locale supplied');\n }\n\n return ast.value;\n },\n });\n};\n\nconst getI18nLocaleArgPlugin = ({ nexus, typeRegistry }: any) => {\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const { isLocalizedContentType } = getI18NService('content-types');\n\n return nexus.plugin({\n name: LOCALE_ARG_PLUGIN_NAME,\n\n onAddOutputField(config: any) {\n // Add the locale arg to the queries on localized CTs\n\n const { parentType } = config;\n\n // Only target queries or mutations\n if (parentType !== 'Query' && parentType !== 'Mutation') {\n return;\n }\n\n let contentType;\n\n if (config?.extensions?.strapi?.contentType) {\n contentType = config.extensions.strapi.contentType;\n } else {\n const registryType = typeRegistry.get(config.type);\n\n if (!registryType) {\n return;\n }\n\n contentType = registryType.config.contentType;\n }\n\n // Ignore non-localized content types\n if (!isLocalizedContentType(contentType)) {\n return;\n }\n\n if (!config.args) {\n config.args = {};\n }\n\n config.args.locale = nexus.arg({\n type: LOCALE_SCALAR_TYPENAME,\n description: 'The locale to use for the query',\n });\n },\n });\n};\n"],"names":["ValidationError","errors","LOCALE_SCALAR_TYPENAME","LOCALE_ARG_PLUGIN_NAME","strapi","register","service","getGraphQLService","plugin","getI18NService","isLocalizedContentType","extensionService","shadowCRUD","disableMutations","Object","entries","contentTypes","forEach","uid","ct","field","disableInput","use","nexus","typeRegistry","i18nLocaleArgPlugin","getI18nLocaleArgPlugin","i18nLocaleScalar","getLocaleScalar","plugins","types","resolversConfig","auth","scope","locales","getIsoLocales","scalarType","name","description","serialize","identity","parseValue","parseLiteral","ast","kind","isValidLocale","value","find","matchesProperty","onAddOutputField","config","parentType","contentType","extensions","registryType","get","type","args","locale","arg"],"mappings":";;;;;AAIA,MAAM,EAAEA,eAAe,EAAE,GAAGC,YAAAA;AAE5B,MAAMC,sBAAAA,GAAyB,gBAAA;AAC/B,MAAMC,sBAAAA,GAAyB,eAAA;AAE/B,sBAAe,CAAA,CAAC,EAAEC,QAAAA,OAAM,EAA2B,IAAM;AACvDC,QAAAA,QAAAA,CAAAA,GAAAA;AACE,YAAA,MAAM,EAAEC,OAAAA,EAASC,iBAAiB,EAAE,GAAGH,OAAAA,CAAOI,MAAM,CAAC,SAAA,CAAA;AACrD,YAAA,MAAM,EAAEF,OAAAA,EAASG,cAAc,EAAE,GAAGL,OAAAA,CAAOI,MAAM,CAAC,MAAA,CAAA;AAElD,YAAA,MAAM,EAAEE,sBAAsB,EAAE,GAAGD,cAAAA,CAAe,eAAA,CAAA;AAElD,YAAA,MAAME,mBAAmBJ,iBAAAA,CAAkB,WAAA,CAAA;YAE3CI,gBAAAA,CAAiBC,UAAU,CAAC,qBAAA,CAAA,CAAuBC,gBAAgB,EAAA;;YAGnEC,MAAAA,CAAOC,OAAO,CAACX,OAAAA,CAAOY,YAAY,CAAA,CAAEC,OAAO,CAAC,CAAC,CAACC,GAAAA,EAAKC,EAAAA,CAAG,GAAA;AACpD,gBAAA,IAAIT,uBAAuBS,EAAAA,CAAAA,EAAK;;AAE9BR,oBAAAA,gBAAAA,CAAiBC,UAAU,CAACM,GAAAA,CAAAA,CAAKE,KAAK,CAAC,UAAUC,YAAY,EAAA;;AAG7DV,oBAAAA,gBAAAA,CAAiBC,UAAU,CAACM,GAAAA,CAAAA,CAAKE,KAAK,CAAC,iBAAiBC,YAAY,EAAA;AACtE,gBAAA;AACF,YAAA,CAAA,CAAA;AAEAV,YAAAA,gBAAAA,CAAiBW,GAAG,CAAC,CAAC,EAAEC,KAAK,EAAEC,YAAY,EAAO,GAAA;AAChD,gBAAA,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AAE;gBAChBP,MAAAA,CAAOO,IAAI,GAAG,EAAC;AACjB,YAAA;AAEAP,YAAAA,MAAAA,CAAOO,IAAI,CAACC,MAAM,GAAGnC,KAAAA,CAAMoC,GAAG,CAAC;gBAC7BH,IAAAA,EAAMtD,sBAAAA;gBACNoC,WAAAA,EAAa;AACf,aAAA,CAAA;AACF,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -1,4 +1,4 @@
1
- import { identity, propEq } from 'lodash/fp';
1
+ import { identity, matchesProperty } from 'lodash';
2
2
  import { errors } from '@strapi/utils';
3
3
 
4
4
  const { ValidationError } = errors;
@@ -64,7 +64,7 @@ const getLocaleScalar = ({ nexus })=>{
64
64
  if (ast.kind !== 'StringValue') {
65
65
  throw new ValidationError('Locale cannot represent non string type');
66
66
  }
67
- const isValidLocale = ast.value === '*' || locales.find(propEq('code', ast.value));
67
+ const isValidLocale = ast.value === '*' || locales.find(matchesProperty('code', ast.value));
68
68
  if (!isValidLocale) {
69
69
  throw new ValidationError('Unknown locale supplied');
70
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.mjs","sources":["../../server/src/graphql.ts"],"sourcesContent":["import { propEq, identity } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nconst { ValidationError } = errors;\n\nconst LOCALE_SCALAR_TYPENAME = 'I18NLocaleCode';\nconst LOCALE_ARG_PLUGIN_NAME = 'I18NLocaleArg';\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => ({\n register() {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const { isLocalizedContentType } = getI18NService('content-types');\n\n const extensionService = getGraphQLService('extension');\n\n extensionService.shadowCRUD('plugin::i18n.locale').disableMutations();\n\n // Disable unwanted fields for localized content types\n Object.entries(strapi.contentTypes).forEach(([uid, ct]) => {\n if (isLocalizedContentType(ct)) {\n // Disable locale field in localized inputs\n extensionService.shadowCRUD(uid).field('locale').disableInput();\n\n // Disable localizations field in localized inputs\n extensionService.shadowCRUD(uid).field('localizations').disableInput();\n }\n });\n\n extensionService.use(({ nexus, typeRegistry }: any) => {\n const i18nLocaleArgPlugin = getI18nLocaleArgPlugin({ nexus, typeRegistry });\n const i18nLocaleScalar = getLocaleScalar({ nexus });\n return {\n plugins: [i18nLocaleArgPlugin],\n types: [i18nLocaleScalar],\n\n resolversConfig: {\n // Modify the default scope associated to find and findOne locale queries to match the actual action name\n 'Query.i18NLocale': { auth: { scope: 'plugin::i18n.locales.listLocales' } },\n 'Query.i18NLocales': { auth: { scope: 'plugin::i18n.locales.listLocales' } },\n },\n };\n });\n },\n});\n\nconst getLocaleScalar = ({ nexus }: any) => {\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const locales = getI18NService('iso-locales').getIsoLocales();\n\n return nexus.scalarType({\n name: LOCALE_SCALAR_TYPENAME,\n\n description: 'A string used to identify an i18n locale',\n\n serialize: identity,\n parseValue: identity,\n\n parseLiteral(ast: any) {\n if (ast.kind !== 'StringValue') {\n throw new ValidationError('Locale cannot represent non string type');\n }\n\n const isValidLocale = ast.value === '*' || locales.find(propEq('code', ast.value));\n\n if (!isValidLocale) {\n throw new ValidationError('Unknown locale supplied');\n }\n\n return ast.value;\n },\n });\n};\n\nconst getI18nLocaleArgPlugin = ({ nexus, typeRegistry }: any) => {\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const { isLocalizedContentType } = getI18NService('content-types');\n\n return nexus.plugin({\n name: LOCALE_ARG_PLUGIN_NAME,\n\n onAddOutputField(config: any) {\n // Add the locale arg to the queries on localized CTs\n\n const { parentType } = config;\n\n // Only target queries or mutations\n if (parentType !== 'Query' && parentType !== 'Mutation') {\n return;\n }\n\n let contentType;\n\n if (config?.extensions?.strapi?.contentType) {\n contentType = config.extensions.strapi.contentType;\n } else {\n const registryType = typeRegistry.get(config.type);\n\n if (!registryType) {\n return;\n }\n\n contentType = registryType.config.contentType;\n }\n\n // Ignore non-localized content types\n if (!isLocalizedContentType(contentType)) {\n return;\n }\n\n if (!config.args) {\n config.args = {};\n }\n\n config.args.locale = nexus.arg({\n type: LOCALE_SCALAR_TYPENAME,\n description: 'The locale to use for the query',\n });\n },\n });\n};\n"],"names":["ValidationError","errors","LOCALE_SCALAR_TYPENAME","LOCALE_ARG_PLUGIN_NAME","strapi","register","service","getGraphQLService","plugin","getI18NService","isLocalizedContentType","extensionService","shadowCRUD","disableMutations","Object","entries","contentTypes","forEach","uid","ct","field","disableInput","use","nexus","typeRegistry","i18nLocaleArgPlugin","getI18nLocaleArgPlugin","i18nLocaleScalar","getLocaleScalar","plugins","types","resolversConfig","auth","scope","locales","getIsoLocales","scalarType","name","description","serialize","identity","parseValue","parseLiteral","ast","kind","isValidLocale","value","find","propEq","onAddOutputField","config","parentType","contentType","extensions","registryType","get","type","args","locale","arg"],"mappings":";;;AAIA,MAAM,EAAEA,eAAe,EAAE,GAAGC,MAAAA;AAE5B,MAAMC,sBAAAA,GAAyB,gBAAA;AAC/B,MAAMC,sBAAAA,GAAyB,eAAA;AAE/B,sBAAe,CAAA,CAAC,EAAEC,QAAAA,OAAM,EAA2B,IAAM;AACvDC,QAAAA,QAAAA,CAAAA,GAAAA;AACE,YAAA,MAAM,EAAEC,OAAAA,EAASC,iBAAiB,EAAE,GAAGH,OAAAA,CAAOI,MAAM,CAAC,SAAA,CAAA;AACrD,YAAA,MAAM,EAAEF,OAAAA,EAASG,cAAc,EAAE,GAAGL,OAAAA,CAAOI,MAAM,CAAC,MAAA,CAAA;AAElD,YAAA,MAAM,EAAEE,sBAAsB,EAAE,GAAGD,cAAAA,CAAe,eAAA,CAAA;AAElD,YAAA,MAAME,mBAAmBJ,iBAAAA,CAAkB,WAAA,CAAA;YAE3CI,gBAAAA,CAAiBC,UAAU,CAAC,qBAAA,CAAA,CAAuBC,gBAAgB,EAAA;;YAGnEC,MAAAA,CAAOC,OAAO,CAACX,OAAAA,CAAOY,YAAY,CAAA,CAAEC,OAAO,CAAC,C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Aa;AAC3CA,gBAAAA,WAAAA,GAAcF,MAAAA,CAAOG,UAAU,CAACjD,MAAM,CAACgD,WAAW;YACpD,CAAA,MAAO;AACL,gBAAA,MAAME,YAAAA,GAAe9B,YAAAA,CAAa+B,GAAG,CAACL,OAAOM,IAAI,CAAA;AAEjD,gBAAA,IAAI,CAACF,YAAAA,EAAc;AACjB,oBAAA;AACF,gBAAA;gBAEAF,WAAAA,GAAcE,YAAAA,CAAaJ,MAAM,CAACE,WAAW;AAC/C,YAAA;;YAGA,IAAI,CAAC1C,uBAAuB0C,WAAAA,CAAAA,EAAc;AACxC,gBAAA;AACF,YAAA;YAEA,IAAI,CAACF,MAAAA,CAAOO,IAAI,EAAE;gBAChBP,MAAAA,CAAOO,IAAI,GAAG,EAAC;AACjB,YAAA;AAEAP,YAAAA,MAAAA,CAAOO,IAAI,CAACC,MAAM,GAAGnC,KAAAA,CAAMoC,GAAG,CAAC;gBAC7BH,IAAAA,EAAMtD,sBAAAA;gBACNoC,WAAAA,EAAa;AACf,aAAA,CAAA;AACF,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"graphql.mjs","sources":["../../server/src/graphql.ts"],"sourcesContent":["import { matchesProperty, identity } from 'lodash';\nimport { errors } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nconst { ValidationError } = errors;\n\nconst LOCALE_SCALAR_TYPENAME = 'I18NLocaleCode';\nconst LOCALE_ARG_PLUGIN_NAME = 'I18NLocaleArg';\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => ({\n register() {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const { isLocalizedContentType } = getI18NService('content-types');\n\n const extensionService = getGraphQLService('extension');\n\n extensionService.shadowCRUD('plugin::i18n.locale').disableMutations();\n\n // Disable unwanted fields for localized content types\n Object.entries(strapi.contentTypes).forEach(([uid, ct]) => {\n if (isLocalizedContentType(ct)) {\n // Disable locale field in localized inputs\n extensionService.shadowCRUD(uid).field('locale').disableInput();\n\n // Disable localizations field in localized inputs\n extensionService.shadowCRUD(uid).field('localizations').disableInput();\n }\n });\n\n extensionService.use(({ nexus, typeRegistry }: any) => {\n const i18nLocaleArgPlugin = getI18nLocaleArgPlugin({ nexus, typeRegistry });\n const i18nLocaleScalar = getLocaleScalar({ nexus });\n return {\n plugins: [i18nLocaleArgPlugin],\n types: [i18nLocaleScalar],\n\n resolversConfig: {\n // Modify the default scope associated to find and findOne locale queries to match the actual action name\n 'Query.i18NLocale': { auth: { scope: 'plugin::i18n.locales.listLocales' } },\n 'Query.i18NLocales': { auth: { scope: 'plugin::i18n.locales.listLocales' } },\n },\n };\n });\n },\n});\n\nconst getLocaleScalar = ({ nexus }: any) => {\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const locales = getI18NService('iso-locales').getIsoLocales();\n\n return nexus.scalarType({\n name: LOCALE_SCALAR_TYPENAME,\n\n description: 'A string used to identify an i18n locale',\n\n serialize: identity,\n parseValue: identity,\n\n parseLiteral(ast: any) {\n if (ast.kind !== 'StringValue') {\n throw new ValidationError('Locale cannot represent non string type');\n }\n\n const isValidLocale = ast.value === '*' || locales.find(matchesProperty('code', ast.value));\n\n if (!isValidLocale) {\n throw new ValidationError('Unknown locale supplied');\n }\n\n return ast.value;\n },\n });\n};\n\nconst getI18nLocaleArgPlugin = ({ nexus, typeRegistry }: any) => {\n const { service: getI18NService } = strapi.plugin('i18n');\n\n const { isLocalizedContentType } = getI18NService('content-types');\n\n return nexus.plugin({\n name: LOCALE_ARG_PLUGIN_NAME,\n\n onAddOutputField(config: any) {\n // Add the locale arg to the queries on localized CTs\n\n const { parentType } = config;\n\n // Only target queries or mutations\n if (parentType !== 'Query' && parentType !== 'Mutation') {\n return;\n }\n\n let contentType;\n\n if (config?.extensions?.strapi?.contentType) {\n contentType = config.extensions.strapi.contentType;\n } else {\n const registryType = typeRegistry.get(config.type);\n\n if (!registryType) {\n return;\n }\n\n contentType = registryType.config.contentType;\n }\n\n // Ignore non-localized content types\n if (!isLocalizedContentType(contentType)) {\n return;\n }\n\n if (!config.args) {\n config.args = {};\n }\n\n config.args.locale = nexus.arg({\n type: LOCALE_SCALAR_TYPENAME,\n description: 'The locale to use for the query',\n });\n },\n });\n};\n"],"names":["ValidationError","errors","LOCALE_SCALAR_TYPENAME","LOCALE_ARG_PLUGIN_NAME","strapi","register","service","getGraphQLService","plugin","getI18NService","isLocalizedContentType","extensionService","shadowCRUD","disableMutations","Object","entries","contentTypes","forEach","uid","ct","field","disableInput","use","nexus","typeRegistry","i18nLocaleArgPlugin","getI18nLocaleArgPlugin","i18nLocaleScalar","getLocaleScalar","plugins","types","resolversConfig","auth","scope","locales","getIsoLocales","scalarType","name","description","serialize","identity","parseValue","parseLiteral","ast","kind","isValidLocale","value","find","matchesProperty","onAddOutputField","config","parentType","contentType","extensions","registryType","get","type","args","locale","arg"],"mappings":";;;AAIA,MAAM,EAAEA,eAAe,EAAE,GAAGC,MAAAA;AAE5B,MAAMC,sBAAAA,GAAyB,gBAAA;AAC/B,MAAMC,sBAAAA,GAAyB,eAAA;AAE/B,sBAAe,CAAA,CAAC,EAAEC,QAAAA,OAAM,EAA2B,IAAM;AACvDC,QAAAA,QAAAA,CAAAA,GAAAA;AACE,YAAA,MAAM,EAAEC,OAAAA,EAASC,iBAAiB,EAAE,GAAGH,OAAAA,CAAOI,MAAM,CAAC,SAAA,CAAA;AACrD,YAAA,MAAM,EAAEF,OAAAA,EAASG,cAAc,EAAE,GAAGL,OAAAA,CAAOI,MAAM,CAAC,MAAA,CAAA;AAElD,YAAA,MAAM,EAAEE,sBAAsB,EAAE,GAAGD,cAAAA,CAAe,eAAA,CAAA;AAElD,YAAA,MAAME,mBAAmBJ,iBAAAA,CAAkB,WAAA,CAAA;YAE3CI,gBAAAA,CAAiBC,UAAU,CAAC,qBAAA,CAAA,CAAuBC,gBAAgB,EAAA;;YAGnEC,MAAAA,CAAOC,OAAO,CAACX,OAAAA,CAAOY,YA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AYjD,MAAAA,EAAQgD,WAAAA,EAAa;AAC3CA,gBAAAA,WAAAA,GAAcF,MAAAA,CAAOG,UAAU,CAACjD,MAAM,CAACgD,WAAW;YACpD,CAAA,MAAO;AACL,gBAAA,MAAME,YAAAA,GAAe9B,YAAAA,CAAa+B,GAAG,CAACL,OAAOM,IAAI,CAAA;AAEjD,gBAAA,IAAI,CAACF,YAAAA,EAAc;AACjB,oBAAA;AACF,gBAAA;gBAEAF,WAAAA,GAAcE,YAAAA,CAAaJ,MAAM,CAACE,WAAW;AAC/C,YAAA;;YAGA,IAAI,CAAC1C,uBAAuB0C,WAAAA,CAAAA,EAAc;AACxC,gBAAA;AACF,YAAA;YAEA,IAAI,CAACF,MAAAA,CAAOO,IAAI,EAAE;gBAChBP,MAAAA,CAAOO,IAAI,GAAG,EAAC;AACjB,YAAA;AAEAP,YAAAA,MAAAA,CAAOO,IAAI,CAACC,MAAM,GAAGnC,KAAAA,CAAMoC,GAAG,CAAC;gBAC7BH,IAAAA,EAAMtD,sBAAAA;gBACNoC,WAAAA,EAAa;AACf,aAAA,CAAA;AACF,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import bootstrap from './bootstrap';\nimport register from './register';\nimport contentTypes from './content-types';\nimport services from './services';\nimport routes from './routes';\nimport controllers from './controllers';\n\nexport type {\n AiTranslationsProvider,\n AiTranslationsService,\n GenerateTranslationsParams,\n GenerateTranslationsResult,\n} from './services/ai-translations';\n\nexport default () => ({\n register,\n bootstrap,\n routes,\n controllers,\n contentTypes,\n services,\n});\n"],"names":["register","bootstrap","routes","controllers","contentTypes","services"],"mappings":";;;;;;;;;AAcA,YAAe,CAAA,KAAO;AACpBA,QAAAA,QAAAA;AACAC,QAAAA,SAAAA;AACAC,gBAAAA,OAAAA;AACAC,qBAAAA,OAAAA;AACAC,sBAAAA,OAAAA;AACAC,kBAAAA;AACF,KAAA,CAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import bootstrap from './bootstrap';\nimport register from './register';\nimport contentTypes from './content-types';\nimport services from './services';\nimport routes from './routes';\nimport controllers from './controllers';\n\nexport default () => ({\n register,\n bootstrap,\n routes,\n controllers,\n contentTypes,\n services,\n});\n"],"names":["register","bootstrap","routes","controllers","contentTypes","services"],"mappings":";;;;;;;;;AAOA,YAAe,CAAA,KAAO;AACpBA,QAAAA,QAAAA;AACAC,QAAAA,SAAAA;AACAC,gBAAAA,OAAAA;AACAC,qBAAAA,OAAAA;AACAC,sBAAAA,OAAAA;AACAC,kBAAAA;AACF,KAAA,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../server/src/index.ts"],"sourcesContent":["import bootstrap from './bootstrap';\nimport register from './register';\nimport contentTypes from './content-types';\nimport services from './services';\nimport routes from './routes';\nimport controllers from './controllers';\n\nexport type {\n AiTranslationsProvider,\n AiTranslationsService,\n GenerateTranslationsParams,\n GenerateTranslationsResult,\n} from './services/ai-translations';\n\nexport default () => ({\n register,\n bootstrap,\n routes,\n controllers,\n contentTypes,\n services,\n});\n"],"names":["register","bootstrap","routes","controllers","contentTypes","services"],"mappings":";;;;;;;AAcA,YAAe,CAAA,KAAO;AACpBA,QAAAA,QAAAA;AACAC,QAAAA,SAAAA;AACAC,QAAAA,MAAAA;AACAC,QAAAA,WAAAA;AACAC,QAAAA,YAAAA;AACAC,QAAAA;AACF,KAAA,CAAC;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../server/src/index.ts"],"sourcesContent":["import bootstrap from './bootstrap';\nimport register from './register';\nimport contentTypes from './content-types';\nimport services from './services';\nimport routes from './routes';\nimport controllers from './controllers';\n\nexport default () => ({\n register,\n bootstrap,\n routes,\n controllers,\n contentTypes,\n services,\n});\n"],"names":["register","bootstrap","routes","controllers","contentTypes","services"],"mappings":";;;;;;;AAOA,YAAe,CAAA,KAAO;AACpBA,QAAAA,QAAAA;AACAC,QAAAA,SAAAA;AACAC,QAAAA,MAAAA;AACAC,QAAAA,WAAAA;AACAC,QAAAA,YAAAA;AACAC,QAAAA;AACF,KAAA,CAAC;;;;"}
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ /** Adapts i18n services to core's capability without resolving them before registration finishes. */ const createLocalizationProvider = (strapi)=>{
4
+ const getContentTypesService = ()=>strapi.plugin('i18n').service('content-types');
5
+ const getLocalesService = ()=>strapi.plugin('i18n').service('locales');
6
+ return {
7
+ isLocalizedContentType (model) {
8
+ return getContentTypesService().isLocalizedContentType(model);
9
+ },
10
+ async getDefaultLocale () {
11
+ // The core store is untyped: only a code string is a default locale
12
+ const value = await getLocalesService().getDefaultLocale();
13
+ return typeof value === 'string' ? value : null;
14
+ },
15
+ async getLocales () {
16
+ const locales = await getLocalesService().find();
17
+ // Stored names are optional, but core consumers need a display name for every locale.
18
+ return (locales ?? []).map(({ code, name })=>({
19
+ code,
20
+ name: name ?? code
21
+ }));
22
+ },
23
+ getNestedPopulateOfNonLocalizedAttributes (modelUID) {
24
+ return getContentTypesService().getNestedPopulateOfNonLocalizedAttributes(modelUID);
25
+ },
26
+ getNonLocalizedAttributes (model) {
27
+ return getContentTypesService().getNonLocalizedAttributes(model);
28
+ },
29
+ fillNonLocalizedAttributes (entry, relatedEntry, options) {
30
+ getContentTypesService().fillNonLocalizedAttributes(entry, relatedEntry, options);
31
+ }
32
+ };
33
+ };
34
+
35
+ exports.createLocalizationProvider = createLocalizationProvider;
36
+ //# sourceMappingURL=localization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization.js","sources":["../../server/src/localization.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport type { ContentTypesService } from './services/content-types';\nimport type { LocaleService } from './services/locales';\n\n/** Adapts i18n services to core's capability without resolving them before registration finishes. */\nexport const createLocalizationProvider = (strapi: Core.Strapi): Modules.Localization.Provider => {\n const getContentTypesService = () =>\n strapi.plugin('i18n').service<ReturnType<ContentTypesService>>('content-types');\n const getLocalesService = () =>\n strapi.plugin('i18n').service<ReturnType<LocaleService>>('locales');\n\n return {\n isLocalizedContentType(model) {\n return getContentTypesService().isLocalizedContentType(model);\n },\n async getDefaultLocale() {\n // The core store is untyped: only a code string is a default locale\n const value: unknown = await getLocalesService().getDefaultLocale();\n return typeof value === 'string' ? value : null;\n },\n async getLocales() {\n const locales: Array<{ code: string; name: string | null }> | null | undefined =\n await getLocalesService().find();\n\n // Stored names are optional, but core consumers need a display name for every locale.\n return (locales ?? []).map(({ code, name }) => ({ code, name: name ?? code }));\n },\n getNestedPopulateOfNonLocalizedAttributes(modelUID) {\n return getContentTypesService().getNestedPopulateOfNonLocalizedAttributes(modelUID);\n },\n getNonLocalizedAttributes(model) {\n return getContentTypesService().getNonLocalizedAttributes(model);\n },\n fillNonLocalizedAttributes(entry, relatedEntry, options) {\n getContentTypesService().fillNonLocalizedAttributes(entry, relatedEntry, options);\n },\n };\n};\n"],"names":["createLocalizationProvider","strapi","getContentTypesService","plugin","service","getLocalesService","isLocalizedContentType","model","getDefaultLocale","value","getLocales","locales","find","map","code","name","getNestedPopulateOfNonLocalizedAttributes","modelUID","getNonLocalizedAttributes","fillNonLocalizedAttributes","entry","relatedEntry","options"],"mappings":";;AAIA,sGACO,MAAMA,0BAAAA,GAA6B,CAACC,MAAAA,GAAAA;AACzC,IAAA,MAAMC,yBAAyB,IAC7BD,MAAAA,CAAOE,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAAkC,eAAA,CAAA;AACjE,IAAA,MAAMC,oBAAoB,IACxBJ,MAAAA,CAAOE,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAA4B,SAAA,CAAA;IAE3D,OAAO;AACLE,QAAAA,sBAAAA,CAAAA,CAAuBC,KAAK,EAAA;YAC1B,OAAOL,sBAAAA,EAAAA,CAAyBI,sBAAsB,CAACC,KAAAA,CAAAA;AACzD,QAAA,CAAA;QACA,MAAMC,gBAAAA,CAAAA,GAAAA;;YAEJ,MAAMC,KAAAA,GAAiB,MAAMJ,iBAAAA,EAAAA,CAAoBG,gBAAgB,EAAA;YACjE,OAAO,OAAOC,KAAAA,KAAU,QAAA,GAAWA,KAAAA,GAAQ,IAAA;AAC7C,QAAA,CAAA;QACA,MAAMC,UAAAA,CAAAA,GAAAA;YACJ,MAAMC,OAAAA,GACJ,MAAMN,iBAAAA,EAAAA,CAAoBO,IAAI,EAAA;;AAGhC,YAAA,OAAO,CAACD,OAAAA,IAAW,EAAE,EAAEE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEC,IAAI,EAAE,IAAM;AAAED,oBAAAA,IAAAA;AAAMC,oBAAAA,IAAAA,EAAMA,IAAAA,IAAQD;iBAAK,CAAA,CAAA;AAC7E,QAAA,CAAA;AACAE,QAAAA,yCAAAA,CAAAA,CAA0CC,QAAQ,EAAA;YAChD,OAAOf,sBAAAA,EAAAA,CAAyBc,yCAAyC,CAACC,QAAAA,CAAAA;AAC5E,QAAA,CAAA;AACAC,QAAAA,yBAAAA,CAAAA,CAA0BX,KAAK,EAAA;YAC7B,OAAOL,sBAAAA,EAAAA,CAAyBgB,yBAAyB,CAACX,KAAAA,CAAAA;AAC5D,QAAA,CAAA;AACAY,QAAAA,0BAAAA,CAAAA,CAA2BC,KAAK,EAAEC,YAAY,EAAEC,OAAO,EAAA;YACrDpB,sBAAAA,EAAAA,CAAyBiB,0BAA0B,CAACC,KAAAA,EAAOC,YAAAA,EAAcC,OAAAA,CAAAA;AAC3E,QAAA;AACF,KAAA;AACF;;;;"}
@@ -0,0 +1,34 @@
1
+ /** Adapts i18n services to core's capability without resolving them before registration finishes. */ const createLocalizationProvider = (strapi)=>{
2
+ const getContentTypesService = ()=>strapi.plugin('i18n').service('content-types');
3
+ const getLocalesService = ()=>strapi.plugin('i18n').service('locales');
4
+ return {
5
+ isLocalizedContentType (model) {
6
+ return getContentTypesService().isLocalizedContentType(model);
7
+ },
8
+ async getDefaultLocale () {
9
+ // The core store is untyped: only a code string is a default locale
10
+ const value = await getLocalesService().getDefaultLocale();
11
+ return typeof value === 'string' ? value : null;
12
+ },
13
+ async getLocales () {
14
+ const locales = await getLocalesService().find();
15
+ // Stored names are optional, but core consumers need a display name for every locale.
16
+ return (locales ?? []).map(({ code, name })=>({
17
+ code,
18
+ name: name ?? code
19
+ }));
20
+ },
21
+ getNestedPopulateOfNonLocalizedAttributes (modelUID) {
22
+ return getContentTypesService().getNestedPopulateOfNonLocalizedAttributes(modelUID);
23
+ },
24
+ getNonLocalizedAttributes (model) {
25
+ return getContentTypesService().getNonLocalizedAttributes(model);
26
+ },
27
+ fillNonLocalizedAttributes (entry, relatedEntry, options) {
28
+ getContentTypesService().fillNonLocalizedAttributes(entry, relatedEntry, options);
29
+ }
30
+ };
31
+ };
32
+
33
+ export { createLocalizationProvider };
34
+ //# sourceMappingURL=localization.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization.mjs","sources":["../../server/src/localization.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport type { ContentTypesService } from './services/content-types';\nimport type { LocaleService } from './services/locales';\n\n/** Adapts i18n services to core's capability without resolving them before registration finishes. */\nexport const createLocalizationProvider = (strapi: Core.Strapi): Modules.Localization.Provider => {\n const getContentTypesService = () =>\n strapi.plugin('i18n').service<ReturnType<ContentTypesService>>('content-types');\n const getLocalesService = () =>\n strapi.plugin('i18n').service<ReturnType<LocaleService>>('locales');\n\n return {\n isLocalizedContentType(model) {\n return getContentTypesService().isLocalizedContentType(model);\n },\n async getDefaultLocale() {\n // The core store is untyped: only a code string is a default locale\n const value: unknown = await getLocalesService().getDefaultLocale();\n return typeof value === 'string' ? value : null;\n },\n async getLocales() {\n const locales: Array<{ code: string; name: string | null }> | null | undefined =\n await getLocalesService().find();\n\n // Stored names are optional, but core consumers need a display name for every locale.\n return (locales ?? []).map(({ code, name }) => ({ code, name: name ?? code }));\n },\n getNestedPopulateOfNonLocalizedAttributes(modelUID) {\n return getContentTypesService().getNestedPopulateOfNonLocalizedAttributes(modelUID);\n },\n getNonLocalizedAttributes(model) {\n return getContentTypesService().getNonLocalizedAttributes(model);\n },\n fillNonLocalizedAttributes(entry, relatedEntry, options) {\n getContentTypesService().fillNonLocalizedAttributes(entry, relatedEntry, options);\n },\n };\n};\n"],"names":["createLocalizationProvider","strapi","getContentTypesService","plugin","service","getLocalesService","isLocalizedContentType","model","getDefaultLocale","value","getLocales","locales","find","map","code","name","getNestedPopulateOfNonLocalizedAttributes","modelUID","getNonLocalizedAttributes","fillNonLocalizedAttributes","entry","relatedEntry","options"],"mappings":"AAIA,sGACO,MAAMA,0BAAAA,GAA6B,CAACC,MAAAA,GAAAA;AACzC,IAAA,MAAMC,yBAAyB,IAC7BD,MAAAA,CAAOE,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAAkC,eAAA,CAAA;AACjE,IAAA,MAAMC,oBAAoB,IACxBJ,MAAAA,CAAOE,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAA4B,SAAA,CAAA;IAE3D,OAAO;AACLE,QAAAA,sBAAAA,CAAAA,CAAuBC,KAAK,EAAA;YAC1B,OAAOL,sBAAAA,EAAAA,CAAyBI,sBAAsB,CAACC,KAAAA,CAAAA;AACzD,QAAA,CAAA;QACA,MAAMC,gBAAAA,CAAAA,GAAAA;;YAEJ,MAAMC,KAAAA,GAAiB,MAAMJ,iBAAAA,EAAAA,CAAoBG,gBAAgB,EAAA;YACjE,OAAO,OAAOC,KAAAA,KAAU,QAAA,GAAWA,KAAAA,GAAQ,IAAA;AAC7C,QAAA,CAAA;QACA,MAAMC,UAAAA,CAAAA,GAAAA;YACJ,MAAMC,OAAAA,GACJ,MAAMN,iBAAAA,EAAAA,CAAoBO,IAAI,EAAA;;AAGhC,YAAA,OAAO,CAACD,OAAAA,IAAW,EAAE,EAAEE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEC,IAAI,EAAE,IAAM;AAAED,oBAAAA,IAAAA;AAAMC,oBAAAA,IAAAA,EAAMA,IAAAA,IAAQD;iBAAK,CAAA,CAAA;AAC7E,QAAA,CAAA;AACAE,QAAAA,yCAAAA,CAAAA,CAA0CC,QAAQ,EAAA;YAChD,OAAOf,sBAAAA,EAAAA,CAAyBc,yCAAyC,CAACC,QAAAA,CAAAA;AAC5E,QAAA,CAAA;AACAC,QAAAA,yBAAAA,CAAAA,CAA0BX,KAAK,EAAA;YAC7B,OAAOL,sBAAAA,EAAAA,CAAyBgB,yBAAyB,CAACX,KAAAA,CAAAA;AAC5D,QAAA,CAAA;AACAY,QAAAA,0BAAAA,CAAAA,CAA2BC,KAAK,EAAEC,YAAY,EAAEC,OAAO,EAAA;YACrDpB,sBAAAA,EAAAA,CAAyBiB,0BAA0B,CAACC,KAAAA,EAAOC,YAAAA,EAAcC,OAAAA,CAAAA;AAC3E,QAAA;AACF,KAAA;AACF;;;;"}
@@ -5,12 +5,14 @@ var validateLocaleCreation = require('./controllers/validate-locale-creation.js'
5
5
  var graphql = require('./graphql.js');
6
6
  var index = require('./utils/index.js');
7
7
  var aiLocalizationJob = require('./models/ai-localization-job.js');
8
+ var localization = require('./localization.js');
8
9
 
9
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
11
 
11
12
  var ___default = /*#__PURE__*/_interopDefault(_);
12
13
 
13
14
  var register = (async ({ strapi })=>{
15
+ strapi.localization.register(localization.createLocalizationProvider(strapi));
14
16
  strapi.get('models').add(aiLocalizationJob.aiLocalizationJob);
15
17
  extendContentTypes(strapi);
16
18
  addContentManagerLocaleMiddleware(strapi);
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core } from '@strapi/types';\n\nimport validateLocaleCreation from './controllers/validate-locale-creation';\nimport graphqlProvider from './graphql';\nimport { getService } from './utils';\nimport { aiLocalizationJob } from './models/ai-localization-job';\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.get('models').add(aiLocalizationJob);\n\n extendContentTypes(strapi);\n addContentManagerLocaleMiddleware(strapi);\n\n strapi\n .hook('strapi::content-types.afterSync')\n .register(({ oldContentTypes, contentTypes }: any) =>\n getService('permissions').actions.repairPermissionsForNewlyLocalizedTypes({\n oldContentTypes,\n contentTypes,\n })\n );\n};\n\n// TODO: v5 if implemented in the CM => delete this middleware\n/**\n * Adds middleware on CM creation routes to use i18n locale passed in a specific param\n * @param {Strapi} strapi\n */\nconst addContentManagerLocaleMiddleware = (strapi: Core.Strapi) => {\n strapi.server.router.use('/content-manager/collection-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n\n strapi.server.router.use('/content-manager/single-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n};\n\n/**\n * Adds locale and localization fields to all content types\n * Even if content type is not localized, it will have these fields\n * @param {Strapi} strapi\n */\nconst extendContentTypes = (strapi: Core.Strapi) => {\n const { isLocalizedContentType } = getService('content-types');\n\n Object.values(strapi.contentTypes).forEach((contentType) => {\n const { attributes } = contentType;\n\n const isLocalized = isLocalizedContentType(contentType);\n\n _.set(attributes, 'locale', {\n writable: true,\n private: !isLocalized,\n configurable: false,\n visible: false,\n type: 'string',\n });\n\n _.set(attributes, 'localizations', {\n type: 'relation',\n relation: 'oneToMany',\n target: contentType.uid,\n writable: false,\n private: !isLocalized,\n configurable: false,\n visible: false,\n unstable_virtual: true,\n joinColumn: {\n name: 'document_id',\n referencedColumn: 'document_id',\n referencedTable: strapi.db.metadata.identifiers.getTableName(contentType.collectionName!),\n // ensure the population will not include the results we already loaded\n on({ results }: { results: any[] }) {\n return {\n id: {\n $notIn: results.map((r) => r.id),\n },\n };\n },\n },\n });\n });\n\n if (strapi.plugin('graphql')) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n graphqlProvider({ strapi }).register();\n }\n};\n"],"names":["strapi","get","add","aiLocalizationJob","extendContentTypes","addContentManagerLocaleMiddleware","hook","register","oldContentTypes","contentTypes","getService","actions","repairPermissionsForNewlyLocalizedTypes","server","router","use","ctx","next","method","validateLocaleCreation","isLocalizedContentType","Object","values","forEach","contentType","attributes","isLocalized","_","set","writable","private","configurable","visible","type","relation","target","uid","unstable_virtual","joinColumn","name","referencedColumn","referencedTable","db","metadata","identifiers","getTableName","collectionName","on","results","id","$notIn","map","r","plugin","graphqlProvider"],"mappings":";;;;;;;;;;;;AAQA,eAAe,CAAA,OAAO,EAAEA,MAAM,EAA2B,GAAA;AACvDA,IAAAA,MAAAA,CAAOC,GAAG,CAAC,QAAA,CAAA,CAAUC,GAAG,CAACC,mCAAAA,CAAAA;IAEzBC,kBAAAA,CAAmBJ,MAAAA,CAAAA;IACnBK,iCAAAA,CAAkCL,MAAAA,CAAAA;AAElCA,IAAAA,MAAAA,CACGM,IAAI,CAAC,iCAAA,CAAA,CACLC,QAAQ,CAAC,CAAC,EAAEC,eAAe,EAAEC,YAAY,EAAO,GAC/CC,gBAAAA,CAAW,eAAeC,OAAO,CAACC,uCAAuC,CAAC;AACxEJ,YAAAA,eAAAA;AACAC,YAAAA;AACF,SAAA,CAAA,CAAA;AAEN,CAAA;AAEA;AACA;;;IAIA,MAAMJ,oCAAoC,CAACL,MAAAA,GAAAA;IACzCA,MAAAA,CAAOa,MAAM,CAACC,MAAM,CAACC,GAAG,CAAC,0CAAA,EAA4C,CAACC,GAAAA,EAAKC,IAAAA,GAAAA;AACzE,QAAA,IAAID,IAAIE,MAAM,KAAK,UAAUF,GAAAA,CAAIE,MAAM,KAAK,KAAA,EAAO;AACjD,YAAA,OAAOC,uBAAuBH,GAAAA,EAAKC,IAAAA,CAAAA;AACrC,QAAA;QAEA,OAAOA,IAAAA,EAAAA;AACT,IAAA,CAAA,CAAA;IAEAjB,MAAAA,CAAOa,MAAM,CAACC,MAAM,CAACC,GAAG,CAAC,sCAAA,EAAwC,C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AACC,QAAQ,CAACC,WAAW,CAACC,YAAY,CAACrB,WAAAA,CAAYsB,cAAc,CAAA;;gBAEvFC,EAAAA,CAAAA,CAAG,EAAEC,OAAO,EAAsB,EAAA;oBAChC,OAAO;wBACLC,EAAAA,EAAI;AACFC,4BAAAA,MAAAA,EAAQF,QAAQG,GAAG,CAAC,CAACC,CAAAA,GAAMA,EAAEH,EAAE;AACjC;AACF,qBAAA;AACF,gBAAA;AACF;AACF,SAAA,CAAA;AACF,IAAA,CAAA,CAAA;IAEA,IAAIjD,MAAAA,CAAOqD,MAAM,CAAC,SAAA,CAAA,EAAY;;QAE5BC,OAAAA,CAAgB;AAAEtD,YAAAA;AAAO,SAAA,CAAA,CAAGO,QAAQ,EAAA;AACtC,IAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core } from '@strapi/types';\n\nimport validateLocaleCreation from './controllers/validate-locale-creation';\nimport graphqlProvider from './graphql';\nimport { getService } from './utils';\nimport { aiLocalizationJob } from './models/ai-localization-job';\nimport { createLocalizationProvider } from './localization';\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.localization.register(createLocalizationProvider(strapi));\n strapi.get('models').add(aiLocalizationJob);\n\n extendContentTypes(strapi);\n addContentManagerLocaleMiddleware(strapi);\n\n strapi\n .hook('strapi::content-types.afterSync')\n .register(({ oldContentTypes, contentTypes }: any) =>\n getService('permissions').actions.repairPermissionsForNewlyLocalizedTypes({\n oldContentTypes,\n contentTypes,\n })\n );\n};\n\n// TODO: v5 if implemented in the CM => delete this middleware\n/**\n * Adds middleware on CM creation routes to use i18n locale passed in a specific param\n * @param {Strapi} strapi\n */\nconst addContentManagerLocaleMiddleware = (strapi: Core.Strapi) => {\n strapi.server.router.use('/content-manager/collection-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n\n strapi.server.router.use('/content-manager/single-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n};\n\n/**\n * Adds locale and localization fields to all content types\n * Even if content type is not localized, it will have these fields\n * @param {Strapi} strapi\n */\nconst extendContentTypes = (strapi: Core.Strapi) => {\n const { isLocalizedContentType } = getService('content-types');\n\n Object.values(strapi.contentTypes).forEach((contentType) => {\n const { attributes } = contentType;\n\n const isLocalized = isLocalizedContentType(contentType);\n\n _.set(attributes, 'locale', {\n writable: true,\n private: !isLocalized,\n configurable: false,\n visible: false,\n type: 'string',\n });\n\n _.set(attributes, 'localizations', {\n type: 'relation',\n relation: 'oneToMany',\n target: contentType.uid,\n writable: false,\n private: !isLocalized,\n configurable: false,\n visible: false,\n unstable_virtual: true,\n joinColumn: {\n name: 'document_id',\n referencedColumn: 'document_id',\n referencedTable: strapi.db.metadata.identifiers.getTableName(contentType.collectionName!),\n // ensure the population will not include the results we already loaded\n on({ results }: { results: any[] }) {\n return {\n id: {\n $notIn: results.map((r) => r.id),\n },\n };\n },\n },\n });\n });\n\n if (strapi.plugin('graphql')) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n graphqlProvider({ strapi }).register();\n }\n};\n"],"names":["strapi","localization","register","createLocalizationProvider","get","add","aiLocalizationJob","extendContentTypes","addContentManagerLocaleMiddleware","hook","oldContentTypes","contentTypes","getService","actions","repairPermissionsForNewlyLocalizedTypes","server","router","use","ctx","next","method","validateLocaleCreation","isLocalizedContentType","Object","values","forEach","contentType","attributes","isLocalized","_","set","writable","private","configurable","visible","type","relation","target","uid","unstable_virtual","joinColumn","name","referencedColumn","referencedTable","db","metadata","identifiers","getTableName","collectionName","on","results","id","$notIn","map","r","plugin","graphqlProvider"],"mappings":";;;;;;;;;;;;;AASA,eAAe,CAAA,OAAO,EAAEA,MAAM,EAA2B,GAAA;AACvDA,IAAAA,MAAAA,CAAOC,YAAY,CAACC,QAAQ,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AAOuD,MAAM,CAAC,SAAA,CAAA,EAAY;;QAE5BC,OAAAA,CAAgB;AAAExD,YAAAA;AAAO,SAAA,CAAA,CAAGE,QAAQ,EAAA;AACtC,IAAA;AACF,CAAA;;;;"}
@@ -3,8 +3,10 @@ import validateLocaleCreation from './controllers/validate-locale-creation.mjs';
3
3
  import graphqlProvider from './graphql.mjs';
4
4
  import { getService } from './utils/index.mjs';
5
5
  import { aiLocalizationJob } from './models/ai-localization-job.mjs';
6
+ import { createLocalizationProvider } from './localization.mjs';
6
7
 
7
8
  var register = (async ({ strapi })=>{
9
+ strapi.localization.register(createLocalizationProvider(strapi));
8
10
  strapi.get('models').add(aiLocalizationJob);
9
11
  extendContentTypes(strapi);
10
12
  addContentManagerLocaleMiddleware(strapi);
@@ -1 +1 @@
1
- {"version":3,"file":"register.mjs","sources":["../../server/src/register.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core } from '@strapi/types';\n\nimport validateLocaleCreation from './controllers/validate-locale-creation';\nimport graphqlProvider from './graphql';\nimport { getService } from './utils';\nimport { aiLocalizationJob } from './models/ai-localization-job';\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.get('models').add(aiLocalizationJob);\n\n extendContentTypes(strapi);\n addContentManagerLocaleMiddleware(strapi);\n\n strapi\n .hook('strapi::content-types.afterSync')\n .register(({ oldContentTypes, contentTypes }: any) =>\n getService('permissions').actions.repairPermissionsForNewlyLocalizedTypes({\n oldContentTypes,\n contentTypes,\n })\n );\n};\n\n// TODO: v5 if implemented in the CM => delete this middleware\n/**\n * Adds middleware on CM creation routes to use i18n locale passed in a specific param\n * @param {Strapi} strapi\n */\nconst addContentManagerLocaleMiddleware = (strapi: Core.Strapi) => {\n strapi.server.router.use('/content-manager/collection-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n\n strapi.server.router.use('/content-manager/single-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n};\n\n/**\n * Adds locale and localization fields to all content types\n * Even if content type is not localized, it will have these fields\n * @param {Strapi} strapi\n */\nconst extendContentTypes = (strapi: Core.Strapi) => {\n const { isLocalizedContentType } = getService('content-types');\n\n Object.values(strapi.contentTypes).forEach((contentType) => {\n const { attributes } = contentType;\n\n const isLocalized = isLocalizedContentType(contentType);\n\n _.set(attributes, 'locale', {\n writable: true,\n private: !isLocalized,\n configurable: false,\n visible: false,\n type: 'string',\n });\n\n _.set(attributes, 'localizations', {\n type: 'relation',\n relation: 'oneToMany',\n target: contentType.uid,\n writable: false,\n private: !isLocalized,\n configurable: false,\n visible: false,\n unstable_virtual: true,\n joinColumn: {\n name: 'document_id',\n referencedColumn: 'document_id',\n referencedTable: strapi.db.metadata.identifiers.getTableName(contentType.collectionName!),\n // ensure the population will not include the results we already loaded\n on({ results }: { results: any[] }) {\n return {\n id: {\n $notIn: results.map((r) => r.id),\n },\n };\n },\n },\n });\n });\n\n if (strapi.plugin('graphql')) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n graphqlProvider({ strapi }).register();\n }\n};\n"],"names":["strapi","get","add","aiLocalizationJob","extendContentTypes","addContentManagerLocaleMiddleware","hook","register","oldContentTypes","contentTypes","getService","actions","repairPermissionsForNewlyLocalizedTypes","server","router","use","ctx","next","method","validateLocaleCreation","isLocalizedContentType","Object","values","forEach","contentType","attributes","isLocalized","_","set","writable","private","configurable","visible","type","relation","target","uid","unstable_virtual","joinColumn","name","referencedColumn","referencedTable","db","metadata","identifiers","getTableName","collectionName","on","results","id","$notIn","map","r","plugin","graphqlProvider"],"mappings":";;;;;;AAQA,eAAe,CAAA,OAAO,EAAEA,MAAM,EAA2B,GAAA;AACvDA,IAAAA,MAAAA,CAAOC,GAAG,CAAC,QAAA,CAAA,CAAUC,GAAG,CAACC,iBAAAA,CAAAA;IAEzBC,kBAAAA,CAAmBJ,MAAA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s","sources":["../../server/src/register.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core } from '@strapi/types';\n\nimport validateLocaleCreation from './controllers/validate-locale-creation';\nimport graphqlProvider from './graphql';\nimport { getService } from './utils';\nimport { aiLocalizationJob } from './models/ai-localization-job';\nimport { createLocalizationProvider } from './localization';\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.localization.register(createLocalizationProvider(strapi));\n strapi.get('models').add(aiLocalizationJob);\n\n extendContentTypes(strapi);\n addContentManagerLocaleMiddleware(strapi);\n\n strapi\n .hook('strapi::content-types.afterSync')\n .register(({ oldContentTypes, contentTypes }: any) =>\n getService('permissions').actions.repairPermissionsForNewlyLocalizedTypes({\n oldContentTypes,\n contentTypes,\n })\n );\n};\n\n// TODO: v5 if implemented in the CM => delete this middleware\n/**\n * Adds middleware on CM creation routes to use i18n locale passed in a specific param\n * @param {Strapi} strapi\n */\nconst addContentManagerLocaleMiddleware = (strapi: Core.Strapi) => {\n strapi.server.router.use('/content-manager/collection-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n\n strapi.server.router.use('/content-manager/single-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n};\n\n/**\n * Adds locale and localization fields to all content types\n * Even if content type is not localized, it will have these fields\n * @param {Strapi} strapi\n */\nconst extendContentTypes = (strapi: Core.Strapi) => {\n const { isLocalizedContentType } = getService('content-types');\n\n Object.values(strapi.contentTypes).forEach((contentType) => {\n const { attributes } = contentType;\n\n const isLocalized = isLocalizedContentType(contentType);\n\n _.set(attributes, 'locale', {\n writable: true,\n private: !isLocalized,\n configurable: false,\n visible: false,\n type: 'string',\n });\n\n _.set(attributes, 'localizations', {\n type: 'relation',\n relation: 'oneToMany',\n target: contentType.uid,\n writable: false,\n private: !isLocalized,\n configurable: false,\n visible: false,\n unstable_virtual: true,\n joinColumn: {\n name: 'document_id',\n referencedColumn: 'document_id',\n referencedTable: strapi.db.metadata.identifiers.getTableName(contentType.collectionName!),\n // ensure the population will not include the results we already loaded\n on({ results }: { results: any[] }) {\n return {\n id: {\n $notIn: results.map((r) => r.id),\n },\n };\n },\n },\n });\n });\n\n if (strapi.plugin('graphql')) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n graphqlProvider({ strapi }).register();\n }\n};\n"],"names":["strapi","localization","register","createLocalizationProvider","get","add","aiLocalizationJob","extendContentTypes","addContentManagerLocaleMiddleware","hook","oldContentTypes","contentTypes","getService","actions","repairPermissionsForNewlyLocalizedTypes","server","router","use","ctx","next","method","validateLocaleCreation","isLocalizedContentType","Object","values","forEach","contentType","attributes","isLocalized","_","set","writable","private","configurable","visible","type","relation","target","uid","unstable_virtual","joinColumn","name","referencedColumn","referencedTable","db","metadata","identifiers","getTableName","collectionName","on","results","id","$notIn","map","r","plugin","graphqlProvider"],"mappings":";;;;;;;AASA,eAAe,CAAA,OAAO,EAAEA,MAAM,EAA2B,GAAA;AACvDA,IAAAA,MAAAA,CAAOC,YAAY,CAACC,QAAQ,CAACC,0BAAAA,CAA2BH,MAAAA,CAAAA,CAAAA;AACxDA,IAAAA,MAAAA,CAAOI,GAAG,CAAC,QAAA,CAAA,CAAUC,GAAG,CAACC,iBAAAA,CAAAA;IAEzBC,kBAAAA,CAAmBP,MAAAA,CAAAA;IACnBQ,iCAAAA,CAAkCR,MAAAA,CAAAA;AAElCA,IAAAA,MAAAA,CACGS,IAAI,CAAC,iCAAA,CAAA,CACLP,QAAQ,CAAC,CAAC,EAAEQ,eAAe,EAAEC,YAAY,EAAO,GAC/CC,UAAAA,CAAW,eAAeC,OAAO,CAACC,uCAAuC,CAAC;AACxEJ,YAAAA,eAAAA;AACAC,YAAAA;AACF,SAAA,CAAA,CAAA;AAEN,CAAA;AAEA;AACA;;;IAIA,MAAMH,oCAAoC,CAACR,MAAAA,GAAAA;IACzCA,M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A,EAAiB;YACjCQ,IAAAA,EAAM,UAAA;YACNC,QAAAA,EAAU,WAAA;AACVC,YAAAA,MAAAA,EAAQX,YAAYY,GAAG;YACvBP,QAAAA,EAAU,KAAA;AACVC,YAAAA,OAAAA,EAAS,CAACJ,WAAAA;YACVK,YAAAA,EAAc,KAAA;YACdC,OAAAA,EAAS,KAAA;YACTK,gBAAAA,EAAkB,IAAA;YAClBC,UAAAA,EAAY;gBACVC,IAAAA,EAAM,aAAA;gBACNC,gBAAAA,EAAkB,aAAA;gBAClBC,eAAAA,EAAiB3C,MAAAA,CAAO4C,EAAE,CAACC,QAAQ,CAACC,WAAW,CAACC,YAAY,CAACrB,WAAAA,CAAYsB,cAAc,CAAA;;gBAEvFC,EAAAA,CAAAA,CAAG,EAAEC,OAAO,EAAsB,EAAA;oBAChC,OAAO;wBACLC,EAAAA,EAAI;AACFC,4BAAAA,MAAAA,EAAQF,QAAQG,GAAG,CAAC,CAACC,CAAAA,GAAMA,EAAEH,EAAE;AACjC;AACF,qBAAA;AACF,gBAAA;AACF;AACF,SAAA,CAAA;AACF,IAAA,CAAA,CAAA;IAEA,IAAInD,MAAAA,CAAOuD,MAAM,CAAC,SAAA,CAAA,EAAY;;QAE5BC,eAAAA,CAAgB;AAAExD,YAAAA;AAAO,SAAA,CAAA,CAAGE,QAAQ,EAAA;AACtC,IAAA;AACF,CAAA;;;;"}
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('lodash/fp');
3
+ var _ = require('lodash');
4
4
  var utils = require('@strapi/utils');
5
5
  var index = require('../utils/index.js');
6
6
 
7
7
  const { isRelationalAttribute, getVisibleAttributes, isTypedAttribute, getScalarAttributes, getRelationalAttributes } = utils.contentTypes;
8
8
  const { ApplicationError } = utils.errors;
9
9
  const hasLocalizedOption = (modelOrAttribute)=>{
10
- return fp.prop('pluginOptions.i18n.localized', modelOrAttribute) === true;
10
+ return _.get(modelOrAttribute, 'pluginOptions.i18n.localized') === true;
11
11
  };
12
12
  const getValidLocale = async (locale)=>{
13
13
  const localesService = index.getService('locales');
14
- if (fp.isNil(locale)) {
14
+ if (locale == null) {
15
15
  return localesService.getDefaultLocale();
16
16
  }
17
17
  const foundLocale = await localesService.findByCode(locale);
@@ -42,28 +42,28 @@ const getValidLocale = async (locale)=>{
42
42
  return getVisibleAttributes(model).filter((attrName)=>!isLocalizedAttribute(model.attributes[attrName]));
43
43
  };
44
44
  const removeId = (value)=>{
45
- if (typeof value === 'object' && fp.has('id', value)) {
45
+ if (typeof value === 'object' && _.has(value, 'id')) {
46
46
  delete value.id;
47
47
  }
48
48
  };
49
- const removeIds = (model)=>(entry)=>removeIdsMut(model, fp.cloneDeep(entry));
49
+ const removeIds = (model)=>(entry)=>removeIdsMut(model, _.cloneDeep(entry));
50
50
  const removeIdsMut = (model, entry)=>{
51
- if (fp.isNil(entry)) {
51
+ if (entry == null) {
52
52
  return entry;
53
53
  }
54
54
  removeId(entry);
55
55
  for (const [attrName, attr] of Object.entries(model.attributes)){
56
56
  const value = entry[attrName];
57
- if (attr.type === 'dynamiczone' && fp.isArray(value)) {
57
+ if (attr.type === 'dynamiczone' && Array.isArray(value)) {
58
58
  value.forEach((compo)=>{
59
- if (fp.has('__component', compo)) {
59
+ if (_.has(compo, '__component')) {
60
60
  const model = strapi.components[compo.__component];
61
61
  removeIdsMut(model, compo);
62
62
  }
63
63
  });
64
64
  } else if (attr.type === 'component') {
65
65
  const model = strapi.components[attr.component];
66
- if (fp.isArray(value)) {
66
+ if (Array.isArray(value)) {
67
67
  value.forEach((compo)=>removeIdsMut(model, compo));
68
68
  } else {
69
69
  removeIdsMut(model, value);
@@ -79,7 +79,7 @@ const removeIdsMut = (model, entry)=>{
79
79
  * @returns {object}
80
80
  */ const copyNonLocalizedAttributes = (model, entry)=>{
81
81
  const nonLocalizedAttributes = getNonLocalizedAttributes(model);
82
- return fp.pipe(fp.pick(nonLocalizedAttributes), removeIds(model))(entry);
82
+ return removeIds(model)(_.pick(entry, nonLocalizedAttributes));
83
83
  };
84
84
  /**
85
85
  * Returns the list of attribute names that are localized
@@ -95,13 +95,13 @@ const removeIdsMut = (model, entry)=>{
95
95
  * @param {Object} options
96
96
  * @param {Object} options.model corresponding model
97
97
  */ const fillNonLocalizedAttributes = (entry, relatedEntry, { model })=>{
98
- if (fp.isNil(relatedEntry)) {
98
+ if (relatedEntry == null) {
99
99
  return;
100
100
  }
101
101
  const modelDef = strapi.getModel(model);
102
102
  const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);
103
103
  for (const [field, value] of Object.entries(relatedEntryCopy)){
104
- if (fp.isNil(entry[field])) {
104
+ if (entry[field] == null) {
105
105
  entry[field] = value;
106
106
  }
107
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.js","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import { pick, pipe, has, prop, isNil, cloneDeep, isArray } from 'lodash/fp';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport type { Struct } from '@strapi/types';\nimport { getService } from '../utils';\n\nconst {\n isRelationalAttribute,\n getVisibleAttributes,\n isTypedAttribute,\n getScalarAttributes,\n getRelationalAttributes,\n} = contentTypeUtils;\nconst { ApplicationError } = errors;\n\nconst hasLocalizedOption = (modelOrAttribute: any) => {\n return prop('pluginOptions.i18n.localized', modelOrAttribute) === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (isNil(locale)) {\n return localesService.getDefaultLocale();\n }\n\n const foundLocale = await localesService.findByCode(locale);\n if (!foundLocale) {\n throw new ApplicationError('Locale not found');\n }\n\n return locale;\n};\n\n/**\n * Returns whether an attribute is localized or not\n * @param {*} attribute\n * @returns\n */\nconst isLocalizedAttribute = (attribute: any) => {\n return (\n hasLocalizedOption(attribute) ||\n isRelationalAttribute(attribute) ||\n isTypedAttribute(attribute, 'uid')\n );\n};\n\n/**\n * Returns whether a model is localized or not\n * @param {*} model\n * @returns\n */\nconst isLocalizedContentType = (model: any) => {\n return hasLocalizedOption(model);\n};\n\n/**\n * Returns the list of attribute names that are not localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getNonLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter(\n (attrName) => !isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\nconst removeId = (value: any) => {\n if (typeof value === 'object' && has('id', value)) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: Struct.ComponentSchema | Struct.ContentTypeSchema) => (entry: any) =>\n removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (\n model: Struct.ComponentSchema | Struct.ContentTypeSchema,\n entry: any\n): Record<string, any> => {\n if (isNil(entry)) {\n return entry as unknown as Record<string, any>;\n }\n\n removeId(entry);\n\n for (const [attrName, attr] of Object.entries(model.attributes)) {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && isArray(value)) {\n value.forEach((compo) => {\n if (has('__component', compo)) {\n const model = strapi.components[compo.__component];\n removeIdsMut(model, compo);\n }\n });\n } else if (attr.type === 'component') {\n const model = strapi.components[attr.component];\n if (isArray(value)) {\n value.forEach((compo) => removeIdsMut(model, compo));\n } else {\n removeIdsMut(model, value);\n }\n }\n }\n\n return entry;\n};\n\n/**\n * Returns a copy of an entry picking only its non localized attributes\n * @param {object} model\n * @param {object} entry\n * @returns {object}\n */\nconst copyNonLocalizedAttributes = (\n model: Struct.ComponentSchema | Struct.ContentTypeSchema,\n entry: any\n) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return pipe(pick(nonLocalizedAttributes), removeIds(model))(entry);\n};\n\n/**\n * Returns the list of attribute names that are localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter((attrName) =>\n isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\n/**\n * Fill non localized fields of an entry if there are nil\n * @param {Object} entry entry to fill\n * @param {Object} relatedEntry values used to fill\n * @param {Object} options\n * @param {Object} options.model corresponding model\n */\nconst fillNonLocalizedAttributes = (entry: any, relatedEntry: any, { model }: any) => {\n if (isNil(relatedEntry)) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n for (const [field, value] of Object.entries(relatedEntryCopy)) {\n if (isNil(entry[field])) {\n entry[field] = value;\n }\n }\n};\n\n/**\n * build the populate param to\n * @param {String} modelUID uid of the model, could be of a content-type or a component\n */\nconst getNestedPopulateOfNonLocalizedAttributes = (modelUID: any): string[] => {\n const schema = strapi.getModel(modelUID);\n const scalarAttributes = getScalarAttributes(schema);\n const nonLocalizedAttributes = getNonLocalizedAttributes(schema);\n\n const allAttributes = [...scalarAttributes, ...nonLocalizedAttributes];\n if (schema.modelType === 'component') {\n // When called recursively on a non localized component we\n // need to explicitly populate that components relations\n allAttributes.push(...getRelationalAttributes(schema));\n }\n\n const currentAttributesToPopulate = allAttributes.filter((value, index, self) => {\n return self.indexOf(value) === index && self.lastIndexOf(value) === index;\n });\n\n const attributesToPopulate = [...currentAttributesToPopulate];\n for (const attrName of currentAttributesToPopulate) {\n const attr = schema.attributes[attrName];\n if (attr.type === 'component') {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n } else if (attr.type === 'dynamiczone') {\n attr.components.forEach((componentName) => {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n });\n }\n }\n\n return attributesToPopulate;\n};\n\nconst contentTypes = () => ({\n isLocalizedContentType,\n getValidLocale,\n getLocalizedAttributes,\n getNonLocalizedAttributes,\n copyNonLocalizedAttributes,\n fillNonLocalizedAttributes,\n getNestedPopulateOfNonLocalizedAttributes,\n});\n\ntype ContentTypesService = typeof contentTypes;\n\nexport default contentTypes;\nexport { ContentTypesService };\n"],"names":["isRelationalAttribute","getVisibleAttributes","isTypedAttribute","getScalarAttributes","getRelationalAttributes","contentTypeUtils","ApplicationError","errors","hasLocalizedOption","modelOrAttribute","prop","getValidLocale","locale","localesService","getService","isNil","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","attr","Object","entries","type","isArray","forEach","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","pipe","pick","getLocalizedAttributes","fillNonLocalizedAttributes","relatedEntry","modelDef","getModel","relatedEntryCopy","field","getNestedPopulateOfNonLocalizedAttributes","modelUID","schema","scalarAttributes","allAttributes","modelType","push","currentAttributesToPopulate","index","self","indexOf","lastIndexOf","attributesToPopulate","nestedPopulate","map","nestedAttr","componentName","contentTypes"],"mappings":";;;;;;AAKA,MAAM,EACJA,qBAAqB,EACrBC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,uBAAuB,EACxB,GAAGC,kBAAAA;AACJ,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,MAAMC,qBAAqB,CAACC,gBAAAA,GAAAA;IAC1B,OAAOC,OAAAA,CAAK,gCAAgCD,gBAAAA,CAAAA,KAAsB,IAAA;AACpE,CAAA;AAEA,MAAME,iBAAiB,OAAOC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,iBAAiBC,gBAAAA,CAAW,SAAA,CAAA;AAElC,IAAA,IAAIC,SAAMH,MAAAA,CAAAA,EAAS;AACjB,QAAA,OAAOC,eAAeG,gBAAgB,EAAA;AACxC,IAAA;AAEA,IAAA,MAAMC,WAAAA,GAAc,MAAMJ,cAAAA,CAAeK,UAAU,CAACN,MAAAA,CAAAA;AACpD,IAAA,IAAI,CAACK,WAAAA,EAAa;AAChB,QAAA,MAAM,IAAIX,gBAAAA,CAAiB,kBAAA,CAAA;AAC7B,IAAA;IAEA,OAAOM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A;AACA3B,QAAAA,yBAAAA;AACAuB,QAAAA,0BAAAA;AACAK,QAAAA,0BAAAA;AACAM,QAAAA;KACF;;;;"}
1
+ {"version":3,"file":"content-types.js","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import { get, has, cloneDeep, pick } from 'lodash';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport type { Struct } from '@strapi/types';\nimport { getService } from '../utils';\n\nconst {\n isRelationalAttribute,\n getVisibleAttributes,\n isTypedAttribute,\n getScalarAttributes,\n getRelationalAttributes,\n} = contentTypeUtils;\nconst { ApplicationError } = errors;\n\nconst hasLocalizedOption = (modelOrAttribute: any) => {\n return get(modelOrAttribute, 'pluginOptions.i18n.localized') === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (locale == null) {\n return localesService.getDefaultLocale();\n }\n\n const foundLocale = await localesService.findByCode(locale);\n if (!foundLocale) {\n throw new ApplicationError('Locale not found');\n }\n\n return locale;\n};\n\n/**\n * Returns whether an attribute is localized or not\n * @param {*} attribute\n * @returns\n */\nconst isLocalizedAttribute = (attribute: any) => {\n return (\n hasLocalizedOption(attribute) ||\n isRelationalAttribute(attribute) ||\n isTypedAttribute(attribute, 'uid')\n );\n};\n\n/**\n * Returns whether a model is localized or not\n * @param {*} model\n * @returns\n */\nconst isLocalizedContentType = (model: any) => {\n return hasLocalizedOption(model);\n};\n\n/**\n * Returns the list of attribute names that are not localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getNonLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter(\n (attrName) => !isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\nconst removeId = (value: any) => {\n if (typeof value === 'object' && has(value, 'id')) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: Struct.ComponentSchema | Struct.ContentTypeSchema) => (entry: any) =>\n removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (\n model: Struct.ComponentSchema | Struct.ContentTypeSchema,\n entry: any\n): Record<string, any> => {\n if (entry == null) {\n return entry as unknown as Record<string, any>;\n }\n\n removeId(entry);\n\n for (const [attrName, attr] of Object.entries(model.attributes)) {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && Array.isArray(value)) {\n value.forEach((compo) => {\n if (has(compo, '__component')) {\n const model = strapi.components[compo.__component];\n removeIdsMut(model, compo);\n }\n });\n } else if (attr.type === 'component') {\n const model = strapi.components[attr.component];\n if (Array.isArray(value)) {\n value.forEach((compo) => removeIdsMut(model, compo));\n } else {\n removeIdsMut(model, value);\n }\n }\n }\n\n return entry;\n};\n\n/**\n * Returns a copy of an entry picking only its non localized attributes\n * @param {object} model\n * @param {object} entry\n * @returns {object}\n */\nconst copyNonLocalizedAttributes = (\n model: Struct.ComponentSchema | Struct.ContentTypeSchema,\n entry: any\n) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return removeIds(model)(pick(entry, nonLocalizedAttributes));\n};\n\n/**\n * Returns the list of attribute names that are localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter((attrName) =>\n isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\n/**\n * Fill non localized fields of an entry if there are nil\n * @param {Object} entry entry to fill\n * @param {Object} relatedEntry values used to fill\n * @param {Object} options\n * @param {Object} options.model corresponding model\n */\nconst fillNonLocalizedAttributes = (entry: any, relatedEntry: any, { model }: any) => {\n if (relatedEntry == null) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n for (const [field, value] of Object.entries(relatedEntryCopy)) {\n if (entry[field] == null) {\n entry[field] = value;\n }\n }\n};\n\n/**\n * build the populate param to\n * @param {String} modelUID uid of the model, could be of a content-type or a component\n */\nconst getNestedPopulateOfNonLocalizedAttributes = (modelUID: any): string[] => {\n const schema = strapi.getModel(modelUID);\n const scalarAttributes = getScalarAttributes(schema);\n const nonLocalizedAttributes = getNonLocalizedAttributes(schema);\n\n const allAttributes = [...scalarAttributes, ...nonLocalizedAttributes];\n if (schema.modelType === 'component') {\n // When called recursively on a non localized component we\n // need to explicitly populate that components relations\n allAttributes.push(...getRelationalAttributes(schema));\n }\n\n const currentAttributesToPopulate = allAttributes.filter((value, index, self) => {\n return self.indexOf(value) === index && self.lastIndexOf(value) === index;\n });\n\n const attributesToPopulate = [...currentAttributesToPopulate];\n for (const attrName of currentAttributesToPopulate) {\n const attr = schema.attributes[attrName];\n if (attr.type === 'component') {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n } else if (attr.type === 'dynamiczone') {\n attr.components.forEach((componentName) => {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n });\n }\n }\n\n return attributesToPopulate;\n};\n\nconst contentTypes = () => ({\n isLocalizedContentType,\n getValidLocale,\n getLocalizedAttributes,\n getNonLocalizedAttributes,\n copyNonLocalizedAttributes,\n fillNonLocalizedAttributes,\n getNestedPopulateOfNonLocalizedAttributes,\n});\n\ntype ContentTypesService = typeof contentTypes;\n\nexport default contentTypes;\nexport { ContentTypesService };\n"],"names":["isRelationalAttribute","getVisibleAttributes","isTypedAttribute","getScalarAttributes","getRelationalAttributes","contentTypeUtils","ApplicationError","errors","hasLocalizedOption","modelOrAttribute","get","getValidLocale","locale","localesService","getService","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","attr","Object","entries","type","Array","isArray","forEach","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","pick","getLocalizedAttributes","fillNonLocalizedAttributes","relatedEntry","modelDef","getModel","relatedEntryCopy","field","getNestedPopulateOfNonLocalizedAttributes","modelUID","schema","scalarAttributes","allAttributes","modelType","push","currentAttributesToPopulate","index","self","indexOf","lastIndexOf","attributesToPopulate","nestedPopulate","map","nestedAttr","componentName","contentTypes"],"mappings":";;;;;;AAKA,MAAM,EACJA,qBAAqB,EACrBC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,uBAAuB,EACxB,GAAGC,kBAAAA;AACJ,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,MAAMC,qBAAqB,CAACC,gBAAAA,GAAAA;IAC1B,OAAOC,KAAAA,CAAID,kBAAkB,8BAAA,CAAA,KAAoC,IAAA;AACnE,CAAA;AAEA,MAAME,iBAAiB,OAAOC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,iBAAiBC,gBAAAA,CAAW,SAAA,CAAA;AAElC,IAAA,IAAIF,UAAU,IAAA,EAAM;AAClB,QAAA,OAAOC,eAAeE,gBAAgB,EAAA;AACxC,IAAA;AAEA,IAAA,MAAMC,WAAAA,GAAc,MAAMH,cAAAA,CAAeI,UAAU,CAACL,MAAAA,CAAAA;AACpD,IAAA,IAAI,CAACI,WAAAA,EAAa;AAChB,QAAA,MAAM,IAAIV,gBAAAA,CAAiB,kBAAA,CAAA;AAC7B,IAAA;IAEA,OAAOM,MAAAA;AACT,CAAA;AAEA;;;;IAKA,MAAMM,uBAAuB,CAACC,SAAAA,GAAAA;AAC5B,IAAA,OACEX,kBAAAA,CAAmBW,SAAAA,CAAAA,IACnBnB,qBAAAA,CAAsBmB,SAAAA,CAAAA,IACtBjB,iBAAiBiB,SAAAA,EAAW,KAAA,CAAA;AAEhC,CAAA;AAEA;;;;IAKA,MAAMC,yBAAyB,CAACC,KAAAA,GAAAA;AAC9B,IAAA,OAAOb,kBAAAA,CAAmBa,KAAAA,CAAAA;AAC5B,CAAA;AAEA;;;;IAKA,MAAMC,4BAA4B,CAACD,KAAAA,GAAAA;IACjC,OAAOpB,oBAA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