@strapi/core 5.0.0-rc.2 → 5.0.0-rc.4

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 (127) hide show
  1. package/dist/Strapi.js +2 -2
  2. package/dist/Strapi.js.map +1 -1
  3. package/dist/configuration/get-dirs.js +2 -2
  4. package/dist/configuration/get-dirs.js.map +1 -1
  5. package/dist/configuration/index.js +2 -2
  6. package/dist/configuration/index.js.map +1 -1
  7. package/dist/core-api/controller/collection-type.js +3 -3
  8. package/dist/core-api/controller/collection-type.js.map +1 -1
  9. package/dist/core-api/controller/index.js +2 -2
  10. package/dist/core-api/controller/index.js.map +1 -1
  11. package/dist/core-api/controller/single-type.js +2 -2
  12. package/dist/core-api/controller/single-type.js.map +1 -1
  13. package/dist/core-api/controller/transform.js +8 -8
  14. package/dist/core-api/controller/transform.js.map +1 -1
  15. package/dist/core-api/service/pagination.js +8 -8
  16. package/dist/core-api/service/pagination.js.map +1 -1
  17. package/dist/domain/content-type/index.js +4 -4
  18. package/dist/domain/content-type/index.js.map +1 -1
  19. package/dist/ee/index.js +3 -3
  20. package/dist/ee/index.js.map +1 -1
  21. package/dist/factories.js +4 -4
  22. package/dist/factories.js.map +1 -1
  23. package/dist/loaders/apis.js +2 -2
  24. package/dist/loaders/apis.js.map +1 -1
  25. package/dist/loaders/plugins/get-enabled-plugins.js +8 -8
  26. package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
  27. package/dist/loaders/plugins/get-user-plugins-config.js +2 -2
  28. package/dist/loaders/plugins/get-user-plugins-config.js.map +1 -1
  29. package/dist/loaders/plugins/index.js +6 -6
  30. package/dist/loaders/plugins/index.js.map +1 -1
  31. package/dist/middlewares/body.js +2 -2
  32. package/dist/middlewares/body.js.map +1 -1
  33. package/dist/middlewares/public.js +2 -2
  34. package/dist/middlewares/public.js.map +1 -1
  35. package/dist/middlewares/responses.js +2 -2
  36. package/dist/middlewares/responses.js.map +1 -1
  37. package/dist/middlewares/security.js +3 -3
  38. package/dist/middlewares/security.js.map +1 -1
  39. package/dist/middlewares/session.js +2 -2
  40. package/dist/middlewares/session.js.map +1 -1
  41. package/dist/registries/apis.js +2 -2
  42. package/dist/registries/apis.js.map +1 -1
  43. package/dist/registries/components.js +2 -2
  44. package/dist/registries/components.js.map +1 -1
  45. package/dist/registries/content-types.js +3 -3
  46. package/dist/registries/content-types.js.map +1 -1
  47. package/dist/registries/controllers.js +3 -3
  48. package/dist/registries/controllers.js.map +1 -1
  49. package/dist/registries/custom-fields.js +4 -4
  50. package/dist/registries/custom-fields.js.map +1 -1
  51. package/dist/registries/hooks.js +2 -2
  52. package/dist/registries/hooks.js.map +1 -1
  53. package/dist/registries/middlewares.js +3 -3
  54. package/dist/registries/middlewares.js.map +1 -1
  55. package/dist/registries/modules.js +3 -3
  56. package/dist/registries/modules.js.map +1 -1
  57. package/dist/registries/plugins.js +2 -2
  58. package/dist/registries/plugins.js.map +1 -1
  59. package/dist/registries/policies.js +4 -4
  60. package/dist/registries/policies.js.map +1 -1
  61. package/dist/registries/services.js +3 -3
  62. package/dist/registries/services.js.map +1 -1
  63. package/dist/services/auth/index.js +3 -3
  64. package/dist/services/auth/index.js.map +1 -1
  65. package/dist/services/core-store.js +3 -3
  66. package/dist/services/core-store.js.map +1 -1
  67. package/dist/services/cron.js +3 -3
  68. package/dist/services/cron.js.map +1 -1
  69. package/dist/services/document-service/attributes/index.js +2 -2
  70. package/dist/services/document-service/attributes/index.js.map +1 -1
  71. package/dist/services/document-service/attributes/transforms.js +3 -3
  72. package/dist/services/document-service/attributes/transforms.js.map +1 -1
  73. package/dist/services/document-service/components.js +15 -15
  74. package/dist/services/document-service/components.js.map +1 -1
  75. package/dist/services/document-service/draft-and-publish.js +16 -16
  76. package/dist/services/document-service/draft-and-publish.js.map +1 -1
  77. package/dist/services/document-service/entries.js +5 -5
  78. package/dist/services/document-service/entries.js.map +1 -1
  79. package/dist/services/document-service/internationalization.js +9 -9
  80. package/dist/services/document-service/internationalization.js.map +1 -1
  81. package/dist/services/document-service/params.js +2 -2
  82. package/dist/services/document-service/params.js.map +1 -1
  83. package/dist/services/document-service/repository.js +9 -9
  84. package/dist/services/document-service/repository.js.map +1 -1
  85. package/dist/services/document-service/transform/id-transform.js +2 -2
  86. package/dist/services/document-service/transform/id-transform.js.map +1 -1
  87. package/dist/services/document-service/transform/query.js +3 -3
  88. package/dist/services/document-service/transform/query.js.map +1 -1
  89. package/dist/services/document-service/transform/relations/extract/data-ids.js +2 -2
  90. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  91. package/dist/services/document-service/transform/relations/transform/data-ids.js +2 -2
  92. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  93. package/dist/services/document-service/transform/relations/utils/dp.js +2 -2
  94. package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -1
  95. package/dist/services/document-service/transform/relations/utils/map-relation.js +6 -6
  96. package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
  97. package/dist/services/entity-validator/index.js +19 -19
  98. package/dist/services/entity-validator/index.js.map +1 -1
  99. package/dist/services/server/compose-endpoint.js +7 -7
  100. package/dist/services/server/compose-endpoint.js.map +1 -1
  101. package/dist/services/server/koa.js +3 -3
  102. package/dist/services/server/koa.js.map +1 -1
  103. package/dist/services/server/middleware.js +3 -3
  104. package/dist/services/server/middleware.js.map +1 -1
  105. package/dist/services/server/routing.js +2 -2
  106. package/dist/services/server/routing.js.map +1 -1
  107. package/dist/services/utils/dynamic-zones.js +5 -5
  108. package/dist/services/utils/dynamic-zones.js.map +1 -1
  109. package/dist/utils/cron.js +3 -3
  110. package/dist/utils/cron.js.map +1 -1
  111. package/dist/utils/filepath-to-prop-path.d.ts +1 -1
  112. package/dist/utils/filepath-to-prop-path.d.ts.map +1 -1
  113. package/dist/utils/filepath-to-prop-path.js +27 -6
  114. package/dist/utils/filepath-to-prop-path.js.map +1 -1
  115. package/dist/utils/filepath-to-prop-path.mjs +25 -5
  116. package/dist/utils/filepath-to-prop-path.mjs.map +1 -1
  117. package/dist/utils/is-initialized.js +3 -3
  118. package/dist/utils/is-initialized.js.map +1 -1
  119. package/dist/utils/startup-logger.js +4 -4
  120. package/dist/utils/startup-logger.js.map +1 -1
  121. package/dist/utils/startup-logger.mjs +3 -3
  122. package/dist/utils/startup-logger.mjs.map +1 -1
  123. package/dist/utils/transform-content-types-to-models.js +4 -4
  124. package/dist/utils/transform-content-types-to-models.js.map +1 -1
  125. package/dist/utils/transform-content-types-to-models.mjs +3 -3
  126. package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
  127. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n const components: Record<UID.Component, Struct.ComponentSchema> = {};\n\n return {\n /**\n * Returns this list of registered components uids\n */\n keys(): UID.Component[] {\n return Object.keys(components) as UID.Component[];\n },\n\n /**\n * Returns the instance of a component. Instantiate the component if not already done\n */\n get(uid: UID.Component) {\n return components[uid];\n },\n\n /**\n * Returns a map with all the components in a namespace\n */\n getAll() {\n return components;\n },\n\n /**\n * Registers a component\n */\n set(uid: UID.Component, component: Struct.ComponentSchema) {\n if (has(uid, components)) {\n throw new Error(`Component ${uid} has already been registered.`);\n }\n\n components[uid] = component;\n\n return this;\n },\n\n /**\n * Registers a map of components for a specific namespace\n */\n add(newComponents: Record<UID.Component, Struct.ComponentSchema>) {\n for (const uid of Object.keys(newComponents) as UID.Component[]) {\n this.set(uid, newComponents[uid]);\n }\n },\n };\n};\n\nexport default componentsRegistry;\n"],"names":["has"],"mappings":";;AAGA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,aAA4D,CAAA;AAE3D,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAwB;AACf,aAAA,OAAO,KAAK,UAAU;AAAA,IAC/B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB;AACtB,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA;AAAA;AAAA;AAAA,IAKA,SAAS;AACA,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB,WAAmC;AACrD,UAAAA,EAAA,IAAI,KAAK,UAAU,GAAG;AACxB,cAAM,IAAI,MAAM,aAAa,GAAG,+BAA+B;AAAA,MACjE;AAEA,iBAAW,GAAG,IAAI;AAEX,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,eAA8D;AAChE,iBAAW,OAAO,OAAO,KAAK,aAAa,GAAsB;AAC/D,aAAK,IAAI,KAAK,cAAc,GAAG,CAAC;AAAA,MAClC;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"components.js","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n const components: Record<UID.Component, Struct.ComponentSchema> = {};\n\n return {\n /**\n * Returns this list of registered components uids\n */\n keys(): UID.Component[] {\n return Object.keys(components) as UID.Component[];\n },\n\n /**\n * Returns the instance of a component. Instantiate the component if not already done\n */\n get(uid: UID.Component) {\n return components[uid];\n },\n\n /**\n * Returns a map with all the components in a namespace\n */\n getAll() {\n return components;\n },\n\n /**\n * Registers a component\n */\n set(uid: UID.Component, component: Struct.ComponentSchema) {\n if (has(uid, components)) {\n throw new Error(`Component ${uid} has already been registered.`);\n }\n\n components[uid] = component;\n\n return this;\n },\n\n /**\n * Registers a map of components for a specific namespace\n */\n add(newComponents: Record<UID.Component, Struct.ComponentSchema>) {\n for (const uid of Object.keys(newComponents) as UID.Component[]) {\n this.set(uid, newComponents[uid]);\n }\n },\n };\n};\n\nexport default componentsRegistry;\n"],"names":["has"],"mappings":";;AAGA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,aAA4D,CAAA;AAE3D,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAwB;AACf,aAAA,OAAO,KAAK,UAAU;AAAA,IAC/B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB;AACtB,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA;AAAA;AAAA;AAAA,IAKA,SAAS;AACA,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB,WAAmC;AACrD,UAAAA,GAAA,IAAI,KAAK,UAAU,GAAG;AACxB,cAAM,IAAI,MAAM,aAAa,GAAG,+BAA+B;AAAA,MACjE;AAEA,iBAAW,GAAG,IAAI;AAEX,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,eAA8D;AAChE,iBAAW,OAAO,OAAO,KAAK,aAAa,GAAsB;AAC/D,aAAK,IAAI,KAAK,cAAc,GAAG,CAAC;AAAA,MAClC;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const index = require("../domain/content-type/index.js");
4
4
  const namespace = require("./namespace.js");
5
5
  const validateKeySameToSingularName = (contentTypes) => {
@@ -31,7 +31,7 @@ const contentTypesRegistry = () => {
31
31
  * Returns a map with all the contentTypes in a namespace
32
32
  */
33
33
  getAll(namespace$1) {
34
- return _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(contentTypes);
34
+ return fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(contentTypes);
35
35
  },
36
36
  /**
37
37
  * Registers a contentType
@@ -47,7 +47,7 @@ const contentTypesRegistry = () => {
47
47
  validateKeySameToSingularName(newContentTypes);
48
48
  for (const rawCtName of Object.keys(newContentTypes)) {
49
49
  const uid = namespace.addNamespace(rawCtName, namespace$1);
50
- if (_.has(uid, contentTypes)) {
50
+ if (fp.has(uid, contentTypes)) {
51
51
  throw new Error(`Content-type ${uid} has already been registered.`);
52
52
  }
53
53
  contentTypes[uid] = index.createContentType(uid, newContentTypes[rawCtName]);
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.js","sources":["../../src/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { UID, Struct } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Struct.ContentTypeSchema) => Struct.ContentTypeSchema;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Struct.ContentTypeSchema> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: UID.ContentType, contentType: Struct.ContentTypeSchema) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n extendFn(currentContentType);\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":["namespace","pickBy","_","hasNamespace","addNamespace","has","createContentType"],"mappings":";;;;AAQA,MAAM,gCAAgC,CAAC,iBAAoC;AACzE,aAAW,UAAU,OAAO,KAAK,YAAY,GAAG;AACxC,UAAA,cAAc,aAAa,MAAM;AAEvC,QAAI,WAAW,YAAY,OAAO,KAAK,cAAc;AACnD,YAAM,IAAI;AAAA,QACR,6EAA6E,MAAM,QAAQ,YAAY,OAAO,KAAK,YAAY;AAAA,MAAA;AAAA,IAEnI;AAAA,EACF;AACF;AAEA,MAAM,uBAAuB,MAAM;AACjC,QAAM,eAAyD,CAAA;AAExD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,YAAY;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB;AACxB,aAAO,aAAa,GAAG;AAAA,IACzB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,EAAA,OAAO,CAACC,IAAG,QAAQC,UAAAA,aAAa,KAAKH,WAAS,CAAC,EAAE,YAAY;AAAA,IACtE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB,aAAuC;AAC/D,mBAAa,GAAG,IAAI;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,iBAAoC;AACzD,oCAA8B,eAAe;AAE7C,iBAAW,aAAa,OAAO,KAAK,eAAe,GAAG;AAC9C,cAAA,MAAMI,UAAAA,aAAa,WAAWJ,WAAS;AAEzC,YAAAK,EAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,gBAAgB,GAAG,+BAA+B;AAAA,QACpE;AAEA,qBAAa,GAAG,IAAIC,MAAA,kBAAkB,KAAK,gBAAgB,SAAS,CAAC;AAAA,MACvE;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,OAAwB,UAA+B;AACtD,YAAA,qBAAqB,KAAK,IAAI,KAAK;AAEzC,UAAI,CAAC,oBAAoB;AACvB,cAAM,IAAI,MAAM,gBAAgB,KAAK,gBAAgB;AAAA,MACvD;AAEA,eAAS,kBAAkB;AAEpB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"content-types.js","sources":["../../src/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { UID, Struct } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Struct.ContentTypeSchema) => Struct.ContentTypeSchema;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Struct.ContentTypeSchema> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: UID.ContentType, contentType: Struct.ContentTypeSchema) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n extendFn(currentContentType);\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has","createContentType"],"mappings":";;;;AAQA,MAAM,gCAAgC,CAAC,iBAAoC;AACzE,aAAW,UAAU,OAAO,KAAK,YAAY,GAAG;AACxC,UAAA,cAAc,aAAa,MAAM;AAEvC,QAAI,WAAW,YAAY,OAAO,KAAK,cAAc;AACnD,YAAM,IAAI;AAAA,QACR,6EAA6E,MAAM,QAAQ,YAAY,OAAO,KAAK,YAAY;AAAA,MAAA;AAAA,IAEnI;AAAA,EACF;AACF;AAEA,MAAM,uBAAuB,MAAM;AACjC,QAAM,eAAyD,CAAA;AAExD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,YAAY;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB;AACxB,aAAO,aAAa,GAAG;AAAA,IACzB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,GAAA,OAAO,CAAC,GAAG,QAAQC,UAAAA,aAAa,KAAKF,WAAS,CAAC,EAAE,YAAY;AAAA,IACtE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB,aAAuC;AAC/D,mBAAa,GAAG,IAAI;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,iBAAoC;AACzD,oCAA8B,eAAe;AAE7C,iBAAW,aAAa,OAAO,KAAK,eAAe,GAAG;AAC9C,cAAA,MAAMG,UAAAA,aAAa,WAAWH,WAAS;AAEzC,YAAAI,GAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,gBAAgB,GAAG,+BAA+B;AAAA,QACpE;AAEA,qBAAa,GAAG,IAAIC,MAAA,kBAAkB,KAAK,gBAAgB,SAAS,CAAC;AAAA,MACvE;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,OAAwB,UAA+B;AACtD,YAAA,qBAAqB,KAAK,IAAI,KAAK;AAEzC,UAAI,CAAC,oBAAoB;AACvB,cAAM,IAAI,MAAM,gBAAgB,KAAK,gBAAgB;AAAA,MACvD;AAEA,eAAS,kBAAkB;AAEpB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const namespace = require("./namespace.js");
4
4
  const controllersRegistry = (strapi) => {
5
5
  const controllers = {};
@@ -28,7 +28,7 @@ const controllersRegistry = (strapi) => {
28
28
  * Returns a map with all the controller in a namespace
29
29
  */
30
30
  getAll(namespace$1) {
31
- const filteredControllers = _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(controllers);
31
+ const filteredControllers = fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(controllers);
32
32
  const map = {};
33
33
  for (const uid of Object.keys(filteredControllers)) {
34
34
  Object.defineProperty(map, uid, {
@@ -55,7 +55,7 @@ const controllersRegistry = (strapi) => {
55
55
  for (const controllerName of Object.keys(newControllers)) {
56
56
  const controller = newControllers[controllerName];
57
57
  const uid = namespace.addNamespace(controllerName, namespace$1);
58
- if (_.has(uid, controllers)) {
58
+ if (fp.has(uid, controllers)) {
59
59
  throw new Error(`Controller ${uid} has already been registered.`);
60
60
  }
61
61
  controllers[uid] = controller;
@@ -1 +1 @@
1
- {"version":3,"file":"controllers.js","sources":["../../src/registries/controllers.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nexport type ControllerFactory =\n | ((params: { strapi: Core.Strapi }) => Core.Controller)\n | Core.Controller;\nexport type ControllerFactoryMap = Record<UID.Controller, ControllerFactory>;\nexport type ControllerMap = Record<UID.Controller, Core.Controller>;\nexport type ControllerExtendFn = (service: Core.Controller) => Core.Controller;\n\nconst controllersRegistry = (strapi: Core.Strapi) => {\n const controllers: ControllerFactoryMap = {};\n const instances: ControllerMap = {};\n\n return {\n /**\n * Returns this list of registered controllers uids\n */\n keys() {\n return Object.keys(controllers);\n },\n\n /**\n * Returns the instance of a controller. Instantiate the controller if not already done\n */\n get(uid: UID.Controller) {\n if (instances[uid]) {\n return instances[uid];\n }\n\n const controller = controllers[uid];\n\n if (controller) {\n instances[uid] = typeof controller === 'function' ? controller({ strapi }) : controller;\n return instances[uid];\n }\n },\n\n /**\n * Returns a map with all the controller in a namespace\n */\n getAll(namespace: string) {\n const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);\n\n const map = {};\n for (const uid of Object.keys(filteredControllers) as UID.Controller[]) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a controller\n */\n set(uid: UID.Controller, value: ControllerFactory) {\n controllers[uid] = value;\n delete instances[uid];\n return this;\n },\n\n /**\n * Registers a map of controllers for a specific namespace\n */\n add(namespace: string, newControllers: ControllerFactoryMap) {\n for (const controllerName of Object.keys(newControllers) as UID.Controller[]) {\n const controller = newControllers[controllerName];\n const uid = addNamespace(controllerName, namespace) as UID.Controller;\n\n if (has(uid, controllers)) {\n throw new Error(`Controller ${uid} has already been registered.`);\n }\n\n controllers[uid] = controller;\n }\n\n return this;\n },\n\n /**\n * Wraps a controller to extend it\n */\n extend(controllerUID: UID.Controller, extendFn: ControllerExtendFn) {\n const currentController = this.get(controllerUID);\n\n if (!currentController) {\n throw new Error(`Controller ${controllerUID} doesn't exist`);\n }\n\n const newController = extendFn(currentController);\n instances[controllerUID] = newController;\n\n return this;\n },\n };\n};\n\nexport default controllersRegistry;\n"],"names":["namespace","pickBy","_","hasNamespace","addNamespace","has"],"mappings":";;;AAWM,MAAA,sBAAsB,CAAC,WAAwB;AACnD,QAAM,cAAoC,CAAA;AAC1C,QAAM,YAA2B,CAAA;AAE1B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB;AACnB,UAAA,UAAU,GAAG,GAAG;AAClB,eAAO,UAAU,GAAG;AAAA,MACtB;AAEM,YAAA,aAAa,YAAY,GAAG;AAElC,UAAI,YAAY;AACJ,kBAAA,GAAG,IAAI,OAAO,eAAe,aAAa,WAAW,EAAE,QAAQ,IAAI;AAC7E,eAAO,UAAU,GAAG;AAAA,MACtB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AAClB,YAAA,sBAAsBC,EAAAA,OAAO,CAACC,IAAG,QAAQC,uBAAa,KAAKH,WAAS,CAAC,EAAE,WAAW;AAExF,YAAM,MAAM,CAAA;AACZ,iBAAW,OAAO,OAAO,KAAK,mBAAmB,GAAuB;AAC/D,eAAA,eAAe,KAAK,KAAK;AAAA,UAC9B,YAAY;AAAA,UACZ,KAAK,MAAM;AACF,mBAAA,KAAK,IAAI,GAAG;AAAA,UACrB;AAAA,QAAA,CACD;AAAA,MACH;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB,OAA0B;AACjD,kBAAY,GAAG,IAAI;AACnB,aAAO,UAAU,GAAG;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,gBAAsC;AAC3D,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAuB;AACtE,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMI,UAAAA,aAAa,gBAAgBJ,WAAS;AAE9C,YAAAK,EAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AAEA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,eAA+B,UAA8B;AAC5D,YAAA,oBAAoB,KAAK,IAAI,aAAa;AAEhD,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,aAAa,gBAAgB;AAAA,MAC7D;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,gBAAU,aAAa,IAAI;AAEpB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"controllers.js","sources":["../../src/registries/controllers.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nexport type ControllerFactory =\n | ((params: { strapi: Core.Strapi }) => Core.Controller)\n | Core.Controller;\nexport type ControllerFactoryMap = Record<UID.Controller, ControllerFactory>;\nexport type ControllerMap = Record<UID.Controller, Core.Controller>;\nexport type ControllerExtendFn = (service: Core.Controller) => Core.Controller;\n\nconst controllersRegistry = (strapi: Core.Strapi) => {\n const controllers: ControllerFactoryMap = {};\n const instances: ControllerMap = {};\n\n return {\n /**\n * Returns this list of registered controllers uids\n */\n keys() {\n return Object.keys(controllers);\n },\n\n /**\n * Returns the instance of a controller. Instantiate the controller if not already done\n */\n get(uid: UID.Controller) {\n if (instances[uid]) {\n return instances[uid];\n }\n\n const controller = controllers[uid];\n\n if (controller) {\n instances[uid] = typeof controller === 'function' ? controller({ strapi }) : controller;\n return instances[uid];\n }\n },\n\n /**\n * Returns a map with all the controller in a namespace\n */\n getAll(namespace: string) {\n const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);\n\n const map = {};\n for (const uid of Object.keys(filteredControllers) as UID.Controller[]) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a controller\n */\n set(uid: UID.Controller, value: ControllerFactory) {\n controllers[uid] = value;\n delete instances[uid];\n return this;\n },\n\n /**\n * Registers a map of controllers for a specific namespace\n */\n add(namespace: string, newControllers: ControllerFactoryMap) {\n for (const controllerName of Object.keys(newControllers) as UID.Controller[]) {\n const controller = newControllers[controllerName];\n const uid = addNamespace(controllerName, namespace) as UID.Controller;\n\n if (has(uid, controllers)) {\n throw new Error(`Controller ${uid} has already been registered.`);\n }\n\n controllers[uid] = controller;\n }\n\n return this;\n },\n\n /**\n * Wraps a controller to extend it\n */\n extend(controllerUID: UID.Controller, extendFn: ControllerExtendFn) {\n const currentController = this.get(controllerUID);\n\n if (!currentController) {\n throw new Error(`Controller ${controllerUID} doesn't exist`);\n }\n\n const newController = extendFn(currentController);\n instances[controllerUID] = newController;\n\n return this;\n },\n };\n};\n\nexport default controllersRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AAWM,MAAA,sBAAsB,CAAC,WAAwB;AACnD,QAAM,cAAoC,CAAA;AAC1C,QAAM,YAA2B,CAAA;AAE1B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB;AACnB,UAAA,UAAU,GAAG,GAAG;AAClB,eAAO,UAAU,GAAG;AAAA,MACtB;AAEM,YAAA,aAAa,YAAY,GAAG;AAElC,UAAI,YAAY;AACJ,kBAAA,GAAG,IAAI,OAAO,eAAe,aAAa,WAAW,EAAE,QAAQ,IAAI;AA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require("lodash/fp");
3
3
  const ALLOWED_TYPES = [
4
4
  "biginteger",
5
5
  "boolean",
@@ -34,7 +34,7 @@ const customFieldsRegistry = (strapi) => {
34
34
  add(customField) {
35
35
  const customFieldList = Array.isArray(customField) ? customField : [customField];
36
36
  for (const cf of customFieldList) {
37
- if (!_.has("name", cf) || !_.has("type", cf)) {
37
+ if (!fp.has("name", cf) || !fp.has("type", cf)) {
38
38
  throw new Error(`Custom fields require a 'name' and 'type' key`);
39
39
  }
40
40
  const { name, plugin, type, inputSize } = cf;
@@ -48,7 +48,7 @@ const customFieldsRegistry = (strapi) => {
48
48
  throw new Error(`Custom field name: '${name}' is not a valid object key`);
49
49
  }
50
50
  if (inputSize) {
51
- if (!_.isPlainObject(inputSize) || !_.has("default", inputSize) || !_.has("isResizable", inputSize)) {
51
+ if (!fp.isPlainObject(inputSize) || !fp.has("default", inputSize) || !fp.has("isResizable", inputSize)) {
52
52
  throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);
53
53
  }
54
54
  if (![4, 6, 8, 12].includes(inputSize.default)) {
@@ -59,7 +59,7 @@ const customFieldsRegistry = (strapi) => {
59
59
  }
60
60
  }
61
61
  const uid = plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;
62
- if (_.has(uid, customFields)) {
62
+ if (fp.has(uid, customFields)) {
63
63
  throw new Error(`Custom field: '${uid}' has already been registered`);
64
64
  }
65
65
  customFields[uid] = cf;
@@ -1 +1 @@
1
- {"version":3,"file":"custom-fields.js","sources":["../../src/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Core, Modules } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Core.Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField:\n | Modules.CustomFields.CustomFieldServerOptions\n | Modules.CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["has","isPlainObject"],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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UAC5E;AAAA,QACF;AAGA,cAAM,MACJ,UAAU,OAAO,OAAO,MAAM,IAAI,WAAW,MAAM,IAAI,IAAI,KAAK,WAAW,IAAI;AAE7E,YAAAA,EAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,kBAAkB,GAAG,+BAA+B;AAAA,QACtE;AAEA,qBAAa,GAAG,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"custom-fields.js","sources":["../../src/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Core, Modules } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Core.Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField:\n | Modules.CustomFields.CustomFieldServerOptions\n | Modules.CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["has","isPlainObject"],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEM,MAAA,uBAAuB,CAAC,WAAwB;AACpD,QAAM,eAAwC,CAAA;AAEvC,SAAA;AAAA,IACL,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,aAAqB;AACjB,YAAA,wBAAwB,aAAa,WAAW;AACtD,UAAI,CAAC,uBAAuB;AAC1B,cAAM,IAAI,MAAM,gCAAgC,WAAW,EAAE;AAAA,MAC/D;AAEO,aAAA;AAAA,IACT;AAAA,IACA,IACE,aAGA;AACA,YAAM,kBAAkB,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW;AAE/E,iBAAW,MAAM,iBAAiB;AAC5B,YAAA,CAACA,GAAAA,IAAI,QAAQ,EAAE,KAAK,CAACA,OAAI,QAAQ,EAAE,GAAG;AAClC,gBAAA,IAAI,MAAM,+CAA+C;AAAA,QACjE;AAEA,cAAM,EAAE,MAAM,QAAQ,MAAM,cAAc;AAC1C,YAAI,CAAC,cAAc,SAAS,IAAI,GAAG;AACjC,gBAAM,IAAI;AAAA,YACR,uBAAuB,IAAI;AAAA,UAAA;AAAA,QAE/B;AAEA,cAAM,mBAAmB;AACzB,YAAI,CAAC,iBAAiB,KAAK,IAAI,GAAG;AAChC,gBAAM,IAAI,MAAM,uBAAuB,IAAI,6BAA6B;AAAA,QAC1E;AAGA,YAAI,WAAW;AACb,cACE,CAACC,GAAA,cAAc,SAAS,KACxB,CAACD,GAAAA,IAAI,WAAW,SAAS,KACzB,CAACA,GAAAA,IAAI,eAAe,SAAS,GAC7B;AACM,kBAAA,IAAI,MAAM,qEAAqE;AAAA,UACvF;AACI,cAAA,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,SAAS,UAAU,OAAO,GAAG;AACxC,kBAAA,IAAI,MAAM,kDAAkD;AAAA,UACpE;AACI,cAAA,OAAO,UAAU,gBAAgB,WAAW;AACxC,kBAAA,IAAI,MAAM,0DAA0D;AAAA,UAC5E;AAAA,QACF;AAGA,cAAM,MACJ,UAAU,OAAO,OAAO,MAAM,IAAI,WAAW,MAAM,IAAI,IAAI,KAAK,WAAW,IAAI;AAE7E,YAAAA,GAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,kBAAkB,GAAG,+BAA+B;AAAA,QACtE;AAEA,qBAAa,GAAG,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const namespace = require("./namespace.js");
4
4
  const hooksRegistry = () => {
5
5
  const hooks = {};
@@ -20,7 +20,7 @@ const hooksRegistry = () => {
20
20
  * Returns a map with all the hooks in a namespace
21
21
  */
22
22
  getAll(namespace$1) {
23
- return _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(hooks);
23
+ return fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(hooks);
24
24
  },
25
25
  /**
26
26
  * Registers a hook
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["../../src/registries/hooks.ts"],"sourcesContent":["import { pickBy } from 'lodash/fp';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype Handler = (context: any) => any;\n\ntype AsyncHook = {\n handlers: Handler[];\n register(handler: Handler): AsyncHook;\n delete(handler: Handler): AsyncHook;\n call(): Promise<void>;\n};\n\ntype SyncHook = {\n get handlers(): Handler[];\n register(handler: Handler): SyncHook;\n delete(handler: Handler): SyncHook;\n call(): void;\n};\n\nexport type Hook = AsyncHook | SyncHook;\n\ntype HookExtendFn = (hook: Hook) => Hook;\n\nconst hooksRegistry = () => {\n const hooks: Record<string, Hook> = {};\n\n return {\n /**\n * Returns this list of registered hooks uids\n */\n keys() {\n return Object.keys(hooks);\n },\n\n /**\n * Returns the instance of a hook.\n */\n get(uid: string) {\n return hooks[uid];\n },\n\n /**\n * Returns a map with all the hooks in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(hooks);\n },\n\n /**\n * Registers a hook\n */\n set(uid: string, hook: Hook) {\n hooks[uid] = hook;\n return this;\n },\n\n /**\n * Registers a map of hooks for a specific namespace\n */\n add(namespace: string, hooks: Record<string, Hook>) {\n for (const hookName of Object.keys(hooks)) {\n const hook = hooks[hookName];\n const uid = addNamespace(hookName, namespace);\n\n this.set(uid, hook);\n }\n\n return this;\n },\n\n /**\n * Wraps a hook to extend it\n */\n extend(uid: string, extendFn: HookExtendFn) {\n const currentHook = this.get(uid);\n\n if (!currentHook) {\n throw new Error(`Hook ${uid} doesn't exist`);\n }\n\n const newHook = extendFn(currentHook);\n hooks[uid] = newHook;\n\n return this;\n },\n };\n};\n\nexport default hooksRegistry;\n"],"names":["namespace","pickBy","_","hasNamespace","hooks","addNamespace"],"mappings":";;;AAuBA,MAAM,gBAAgB,MAAM;AAC1B,QAAM,QAA8B,CAAA;AAE7B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,KAAK;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa;AACf,aAAO,MAAM,GAAG;AAAA,IAClB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,EAAA,OAAO,CAACC,IAAG,QAAQC,UAAAA,aAAa,KAAKH,WAAS,CAAC,EAAE,KAAK;AAAA,IAC/D;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,MAAY;AAC3B,YAAM,GAAG,IAAI;AACN,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmBI,QAA6B;AAClD,iBAAW,YAAY,OAAO,KAAKA,MAAK,GAAG;AACnC,cAAA,OAAOA,OAAM,QAAQ;AACrB,cAAA,MAAMC,UAAAA,aAAa,UAAUL,WAAS;AAEvC,aAAA,IAAI,KAAK,IAAI;AAAA,MACpB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAa,UAAwB;AACpC,YAAA,cAAc,KAAK,IAAI,GAAG;AAEhC,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI,MAAM,QAAQ,GAAG,gBAAgB;AAAA,MAC7C;AAEM,YAAA,UAAU,SAAS,WAAW;AACpC,YAAM,GAAG,IAAI;AAEN,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"hooks.js","sources":["../../src/registries/hooks.ts"],"sourcesContent":["import { pickBy } from 'lodash/fp';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype Handler = (context: any) => any;\n\ntype AsyncHook = {\n handlers: Handler[];\n register(handler: Handler): AsyncHook;\n delete(handler: Handler): AsyncHook;\n call(): Promise<void>;\n};\n\ntype SyncHook = {\n get handlers(): Handler[];\n register(handler: Handler): SyncHook;\n delete(handler: Handler): SyncHook;\n call(): void;\n};\n\nexport type Hook = AsyncHook | SyncHook;\n\ntype HookExtendFn = (hook: Hook) => Hook;\n\nconst hooksRegistry = () => {\n const hooks: Record<string, Hook> = {};\n\n return {\n /**\n * Returns this list of registered hooks uids\n */\n keys() {\n return Object.keys(hooks);\n },\n\n /**\n * Returns the instance of a hook.\n */\n get(uid: string) {\n return hooks[uid];\n },\n\n /**\n * Returns a map with all the hooks in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(hooks);\n },\n\n /**\n * Registers a hook\n */\n set(uid: string, hook: Hook) {\n hooks[uid] = hook;\n return this;\n },\n\n /**\n * Registers a map of hooks for a specific namespace\n */\n add(namespace: string, hooks: Record<string, Hook>) {\n for (const hookName of Object.keys(hooks)) {\n const hook = hooks[hookName];\n const uid = addNamespace(hookName, namespace);\n\n this.set(uid, hook);\n }\n\n return this;\n },\n\n /**\n * Wraps a hook to extend it\n */\n extend(uid: string, extendFn: HookExtendFn) {\n const currentHook = this.get(uid);\n\n if (!currentHook) {\n throw new Error(`Hook ${uid} doesn't exist`);\n }\n\n const newHook = extendFn(currentHook);\n hooks[uid] = newHook;\n\n return this;\n },\n };\n};\n\nexport default hooksRegistry;\n"],"names":["namespace","pickBy","hasNamespace","hooks","addNamespace"],"mappings":";;;AAuBA,MAAM,gBAAgB,MAAM;AAC1B,QAAM,QAA8B,CAAA;AAE7B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,KAAK;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa;AACf,aAAO,MAAM,GAAG;AAAA,IAClB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,GAAA,OAAO,CAAC,GAAG,QAAQC,UAAAA,aAAa,KAAKF,WAAS,CAAC,EAAE,KAAK;AAAA,IAC/D;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,MAAY;AAC3B,YAAM,GAAG,IAAI;AACN,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmBG,QAA6B;AAClD,iBAAW,YAAY,OAAO,KAAKA,MAAK,GAAG;AACnC,cAAA,OAAOA,OAAM,QAAQ;AACrB,cAAA,MAAMC,UAAAA,aAAa,UAAUJ,WAAS;AAEvC,aAAA,IAAI,KAAK,IAAI;AAAA,MACpB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAa,UAAwB;AACpC,YAAA,cAAc,KAAK,IAAI,GAAG;AAEhC,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI,MAAM,QAAQ,GAAG,gBAAgB;AAAA,MAC7C;AAEM,YAAA,UAAU,SAAS,WAAW;AACpC,YAAM,GAAG,IAAI;AAEN,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const namespace = require("./namespace.js");
4
4
  const middlewaresRegistry = () => {
5
5
  const middlewares = {};
@@ -20,7 +20,7 @@ const middlewaresRegistry = () => {
20
20
  * Returns a map with all the middlewares in a namespace
21
21
  */
22
22
  getAll(namespace$1) {
23
- return _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(middlewares);
23
+ return fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(middlewares);
24
24
  },
25
25
  /**
26
26
  * Registers a middleware
@@ -36,7 +36,7 @@ const middlewaresRegistry = () => {
36
36
  for (const middlewareName of Object.keys(rawMiddlewares)) {
37
37
  const middleware = rawMiddlewares[middlewareName];
38
38
  const uid = namespace.addNamespace(middlewareName, namespace$1);
39
- if (_.has(uid, middlewares)) {
39
+ if (fp.has(uid, middlewares)) {
40
40
  throw new Error(`Middleware ${uid} has already been registered.`);
41
41
  }
42
42
  middlewares[uid] = middleware;
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares.js","sources":["../../src/registries/middlewares.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype MiddlewareExtendFn = (middleware: Core.Middleware) => Core.Middleware;\n\n// TODO: move instantiation part here instead of in the server service\nconst middlewaresRegistry = () => {\n const middlewares: Record<UID.Middleware, Core.Middleware> = {};\n\n return {\n /**\n * Returns this list of registered middlewares uids\n */\n keys() {\n return Object.keys(middlewares);\n },\n\n /**\n * Returns the instance of a middleware. Instantiate the middleware if not already done\n */\n get(uid: UID.Middleware) {\n return middlewares[uid];\n },\n\n /**\n * Returns a map with all the middlewares in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(middlewares);\n },\n\n /**\n * Registers a middleware\n */\n set(uid: UID.Middleware, middleware: Core.Middleware) {\n middlewares[uid] = middleware;\n return this;\n },\n\n /**\n * Registers a map of middlewares for a specific namespace\n */\n add(namespace: string, rawMiddlewares: Record<string, Core.Middleware> = {}) {\n for (const middlewareName of Object.keys(rawMiddlewares)) {\n const middleware = rawMiddlewares[middlewareName];\n const uid = addNamespace(middlewareName, namespace) as UID.Middleware;\n\n if (has(uid, middlewares)) {\n throw new Error(`Middleware ${uid} has already been registered.`);\n }\n middlewares[uid] = middleware;\n }\n },\n\n /**\n * Wraps a middleware to extend it\n */\n extend(uid: UID.Middleware, extendFn: MiddlewareExtendFn) {\n const currentMiddleware = this.get(uid);\n\n if (!currentMiddleware) {\n throw new Error(`Middleware ${uid} doesn't exist`);\n }\n\n const newMiddleware = extendFn(currentMiddleware);\n middlewares[uid] = newMiddleware;\n\n return this;\n },\n };\n};\n\nexport default middlewaresRegistry;\n"],"names":["namespace","pickBy","_","hasNamespace","addNamespace","has"],"mappings":";;;AAOA,MAAM,sBAAsB,MAAM;AAChC,QAAM,cAAuD,CAAA;AAEtD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB;AACvB,aAAO,YAAY,GAAG;AAAA,IACxB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,EAAA,OAAO,CAACC,IAAG,QAAQC,UAAAA,aAAa,KAAKH,WAAS,CAAC,EAAE,WAAW;AAAA,IACrE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB,YAA6B;AACpD,kBAAY,GAAG,IAAI;AACZ,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,iBAAkD,IAAI;AAC3E,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAG;AAClD,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMI,UAAAA,aAAa,gBAAgBJ,WAAS;AAE9C,YAAAK,EAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AACA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAqB,UAA8B;AAClD,YAAA,oBAAoB,KAAK,IAAI,GAAG;AAEtC,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,GAAG,gBAAgB;AAAA,MACnD;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,kBAAY,GAAG,IAAI;AAEZ,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"middlewares.js","sources":["../../src/registries/middlewares.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype MiddlewareExtendFn = (middleware: Core.Middleware) => Core.Middleware;\n\n// TODO: move instantiation part here instead of in the server service\nconst middlewaresRegistry = () => {\n const middlewares: Record<UID.Middleware, Core.Middleware> = {};\n\n return {\n /**\n * Returns this list of registered middlewares uids\n */\n keys() {\n return Object.keys(middlewares);\n },\n\n /**\n * Returns the instance of a middleware. Instantiate the middleware if not already done\n */\n get(uid: UID.Middleware) {\n return middlewares[uid];\n },\n\n /**\n * Returns a map with all the middlewares in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(middlewares);\n },\n\n /**\n * Registers a middleware\n */\n set(uid: UID.Middleware, middleware: Core.Middleware) {\n middlewares[uid] = middleware;\n return this;\n },\n\n /**\n * Registers a map of middlewares for a specific namespace\n */\n add(namespace: string, rawMiddlewares: Record<string, Core.Middleware> = {}) {\n for (const middlewareName of Object.keys(rawMiddlewares)) {\n const middleware = rawMiddlewares[middlewareName];\n const uid = addNamespace(middlewareName, namespace) as UID.Middleware;\n\n if (has(uid, middlewares)) {\n throw new Error(`Middleware ${uid} has already been registered.`);\n }\n middlewares[uid] = middleware;\n }\n },\n\n /**\n * Wraps a middleware to extend it\n */\n extend(uid: UID.Middleware, extendFn: MiddlewareExtendFn) {\n const currentMiddleware = this.get(uid);\n\n if (!currentMiddleware) {\n throw new Error(`Middleware ${uid} doesn't exist`);\n }\n\n const newMiddleware = extendFn(currentMiddleware);\n middlewares[uid] = newMiddleware;\n\n return this;\n },\n };\n};\n\nexport default middlewaresRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AAOA,MAAM,sBAAsB,MAAM;AAChC,QAAM,cAAuD,CAAA;AAEtD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB;AACvB,aAAO,YAAY,GAAG;AAAA,IACxB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,GAAA,OAAO,CAAC,GAAG,QAAQC,UAAAA,aAAa,KAAKF,WAAS,CAAC,EAAE,WAAW;AAAA,IACrE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB,YAA6B;AACpD,kBAAY,GAAG,IAAI;AACZ,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,iBAAkD,IAAI;AAC3E,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAG;AAClD,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMG,UAAAA,aAAa,gBAAgBH,WAAS;AAE9C,YAAAI,GAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AACA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAqB,UAA8B;AAClD,YAAA,oBAAoB,KAAK,IAAI,GAAG;AAEtC,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,GAAG,gBAAgB;AAAA,MACnD;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,kBAAY,GAAG,IAAI;AAEZ,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const index = require("../domain/module/index.js");
4
4
  const modulesRegistry = (strapi) => {
5
5
  const modules = {};
@@ -8,10 +8,10 @@ const modulesRegistry = (strapi) => {
8
8
  return modules[namespace];
9
9
  },
10
10
  getAll(prefix = "") {
11
- return _.pickBy((mod, namespace) => namespace.startsWith(prefix))(modules);
11
+ return fp.pickBy((mod, namespace) => namespace.startsWith(prefix))(modules);
12
12
  },
13
13
  add(namespace, rawModule) {
14
- if (_.has(namespace, modules)) {
14
+ if (fp.has(namespace, modules)) {
15
15
  throw new Error(`Module ${namespace} has already been registered.`);
16
16
  }
17
17
  modules[namespace] = index.createModule(namespace, rawModule, strapi);
@@ -1 +1 @@
1
- {"version":3,"file":"modules.js","sources":["../../src/registries/modules.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\nimport { createModule, RawModule, Module } from '../domain/module';\n\ntype ModuleMap = { [namespace: string]: Module };\n\nconst modulesRegistry = (strapi: Core.Strapi) => {\n const modules: ModuleMap = {};\n\n return {\n get(namespace: string) {\n return modules[namespace];\n },\n getAll(prefix = '') {\n return pickBy<ModuleMap>((mod, namespace) => namespace.startsWith(prefix))(modules);\n },\n add(namespace: string, rawModule: RawModule) {\n if (has(namespace, modules)) {\n throw new Error(`Module ${namespace} has already been registered.`);\n }\n\n modules[namespace] = createModule(namespace, rawModule, strapi);\n modules[namespace].load();\n\n return modules[namespace];\n },\n async bootstrap() {\n for (const mod of Object.values(modules)) {\n await mod.bootstrap();\n }\n },\n async register() {\n for (const mod of Object.values(modules)) {\n await mod.register();\n }\n },\n async destroy() {\n for (const mod of Object.values(modules)) {\n await mod.destroy();\n }\n },\n };\n};\n\nexport default modulesRegistry;\n"],"names":["pickBy","has","createModule"],"mappings":";;;AAMM,MAAA,kBAAkB,CAAC,WAAwB;AAC/C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,WAAmB;AACrB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,OAAO,SAAS,IAAI;AACX,aAAAA,EAAA,OAAkB,CAAC,KAAK,cAAc,UAAU,WAAW,MAAM,CAAC,EAAE,OAAO;AAAA,IACpF;AAAA,IACA,IAAI,WAAmB,WAAsB;AACvC,UAAAC,EAAA,IAAI,WAAW,OAAO,GAAG;AAC3B,cAAM,IAAI,MAAM,UAAU,SAAS,+BAA+B;AAAA,MACpE;AAEA,cAAQ,SAAS,IAAIC,MAAAA,aAAa,WAAW,WAAW,MAAM;AACtD,cAAA,SAAS,EAAE;AAEnB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,MAAM,YAAY;AAChB,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,WAAW;AACf,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,UAAU;AACd,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"modules.js","sources":["../../src/registries/modules.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\nimport { createModule, RawModule, Module } from '../domain/module';\n\ntype ModuleMap = { [namespace: string]: Module };\n\nconst modulesRegistry = (strapi: Core.Strapi) => {\n const modules: ModuleMap = {};\n\n return {\n get(namespace: string) {\n return modules[namespace];\n },\n getAll(prefix = '') {\n return pickBy<ModuleMap>((mod, namespace) => namespace.startsWith(prefix))(modules);\n },\n add(namespace: string, rawModule: RawModule) {\n if (has(namespace, modules)) {\n throw new Error(`Module ${namespace} has already been registered.`);\n }\n\n modules[namespace] = createModule(namespace, rawModule, strapi);\n modules[namespace].load();\n\n return modules[namespace];\n },\n async bootstrap() {\n for (const mod of Object.values(modules)) {\n await mod.bootstrap();\n }\n },\n async register() {\n for (const mod of Object.values(modules)) {\n await mod.register();\n }\n },\n async destroy() {\n for (const mod of Object.values(modules)) {\n await mod.destroy();\n }\n },\n };\n};\n\nexport default modulesRegistry;\n"],"names":["pickBy","has","createModule"],"mappings":";;;AAMM,MAAA,kBAAkB,CAAC,WAAwB;AAC/C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,WAAmB;AACrB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,OAAO,SAAS,IAAI;AACX,aAAAA,GAAA,OAAkB,CAAC,KAAK,cAAc,UAAU,WAAW,MAAM,CAAC,EAAE,OAAO;AAAA,IACpF;AAAA,IACA,IAAI,WAAmB,WAAsB;AACvC,UAAAC,GAAA,IAAI,WAAW,OAAO,GAAG;AAC3B,cAAM,IAAI,MAAM,UAAU,SAAS,+BAA+B;AAAA,MACpE;AAEA,cAAQ,SAAS,IAAIC,MAAAA,aAAa,WAAW,WAAW,MAAM;AACtD,cAAA,SAAS,EAAE;AAEnB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,MAAM,YAAY;AAChB,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,WAAW;AACf,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,UAAU;AACd,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const pluginsRegistry = (strapi) => {
4
4
  const plugins = {};
5
5
  return {
@@ -10,7 +10,7 @@ const pluginsRegistry = (strapi) => {
10
10
  return plugins;
11
11
  },
12
12
  add(name, pluginConfig) {
13
- if (_.has(name, plugins)) {
13
+ if (fp.has(name, plugins)) {
14
14
  throw new Error(`Plugin ${name} has already been registered.`);
15
15
  }
16
16
  const pluginModule = strapi.get("modules").add(`plugin::${name}`, pluginConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sources":["../../src/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\ntype PluginMap = Record<string, Core.Plugin>;\n\nconst pluginsRegistry = (strapi: Core.Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Core.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["has"],"mappings":";;AAMM,MAAA,kBAAkB,CAAC,WAAwB;AAC/C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAc,cAA2B;AACvC,UAAAA,EAAA,IAAI,MAAM,OAAO,GAAG;AACtB,cAAM,IAAI,MAAM,UAAU,IAAI,+BAA+B;AAAA,MAC/D;AAEM,YAAA,eAAe,OAAO,IAAI,SAAS,EAAE,IAAI,WAAW,IAAI,IAAI,YAAY;AAC9E,cAAQ,IAAI,IAAI;AAEhB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"plugins.js","sources":["../../src/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\ntype PluginMap = Record<string, Core.Plugin>;\n\nconst pluginsRegistry = (strapi: Core.Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Core.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["has"],"mappings":";;AAMM,MAAA,kBAAkB,CAAC,WAAwB;AAC/C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAc,cAA2B;AACvC,UAAAA,GAAA,IAAI,MAAM,OAAO,GAAG;AACtB,cAAM,IAAI,MAAM,UAAU,IAAI,+BAA+B;AAAA,MAC/D;AAEM,YAAA,eAAe,OAAO,IAAI,SAAS,EAAE,IAAI,WAAW,IAAI,IAAI,YAAY;AAC9E,cAAQ,IAAI,IAAI;AAEhB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const namespace = require("./namespace.js");
4
4
  const PLUGIN_PREFIX = "plugin::";
5
5
  const API_PREFIX = "api::";
@@ -68,7 +68,7 @@ const policiesRegistry = () => {
68
68
  * Returns a map with all the policies in a namespace
69
69
  */
70
70
  getAll(namespace$1) {
71
- return _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(Object.fromEntries(policies));
71
+ return fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(Object.fromEntries(policies));
72
72
  },
73
73
  /**
74
74
  * Registers a policy
@@ -84,7 +84,7 @@ const policiesRegistry = () => {
84
84
  for (const policyName of Object.keys(newPolicies)) {
85
85
  const policy = newPolicies[policyName];
86
86
  const uid = namespace.addNamespace(policyName, namespace$1);
87
- if (_.has(uid, policies)) {
87
+ if (fp.has(uid, policies)) {
88
88
  throw new Error(`Policy ${uid} has already been registered.`);
89
89
  }
90
90
  policies.set(uid, policy);
@@ -95,7 +95,7 @@ const policiesRegistry = () => {
95
95
  */
96
96
  resolve(config, namespaceInfo) {
97
97
  const { pluginName, apiName } = namespaceInfo ?? {};
98
- return _.castArray(config).map((policyConfig) => {
98
+ return fp.castArray(config).map((policyConfig) => {
99
99
  return {
100
100
  handler: resolveHandler(policyConfig, { pluginName, apiName }),
101
101
  config: typeof policyConfig === "object" && policyConfig.config || {}
@@ -1 +1 @@
1
- {"version":3,"file":"policies.js","sources":["../../src/registries/policies.ts"],"sourcesContent":["import { pickBy, has, castArray } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nconst PLUGIN_PREFIX = 'plugin::';\nconst API_PREFIX = 'api::';\n\ninterface PolicyInfo {\n name: string;\n config: unknown;\n}\n\ntype PolicyConfig = string | PolicyInfo;\n\ninterface NamespaceInfo {\n pluginName?: string;\n apiName?: string;\n}\n\nconst parsePolicy = (policy: string | PolicyInfo) => {\n if (typeof policy === 'string') {\n return { policyName: policy, config: {} };\n }\n\n const { name, config } = policy;\n return { policyName: name, config };\n};\n\nconst policiesRegistry = () => {\n const policies = new Map<string, Core.Policy>();\n\n const find = (name: string, namespaceInfo?: NamespaceInfo) => {\n const { pluginName, apiName } = namespaceInfo ?? {};\n\n // try to resolve a full name to avoid extra prefixing\n const policy = policies.get(name);\n\n if (policy) {\n return policy;\n }\n\n if (pluginName) {\n return policies.get(`${PLUGIN_PREFIX}${pluginName}.${name}`);\n }\n\n if (apiName) {\n return policies.get(`${API_PREFIX}${apiName}.${name}`);\n }\n };\n\n function resolveHandler(policyConfig: PolicyConfig, namespaceInfo?: NamespaceInfo): Core.Policy;\n function resolveHandler(\n policyConfig: PolicyConfig[],\n namespaceInfo?: NamespaceInfo\n ): Core.Policy[];\n function resolveHandler(\n policyConfig: PolicyConfig | PolicyConfig[],\n namespaceInfo?: NamespaceInfo\n ): Core.Policy | Core.Policy[] {\n if (Array.isArray(policyConfig)) {\n return policyConfig.map((config) => {\n return resolveHandler(config, namespaceInfo);\n });\n }\n\n const { policyName, config } = parsePolicy(policyConfig);\n\n const policy = find(policyName, namespaceInfo);\n\n if (!policy) {\n throw new Error(`Policy ${policyName} not found.`);\n }\n\n if (typeof policy === 'function') {\n return policy;\n }\n\n if (policy.validator) {\n policy.validator(config);\n }\n\n return policy.handler;\n }\n\n return {\n /**\n * Returns this list of registered policies uids\n */\n keys() {\n return policies.keys();\n },\n\n /**\n * Returns the instance of a policy. Instantiate the policy if not already done\n */\n get(name: string, namespaceInfo?: NamespaceInfo) {\n return find(name, namespaceInfo);\n },\n /**\n * Checks if a policy is registered\n */\n has(name: string, namespaceInfo?: NamespaceInfo) {\n const res = find(name, namespaceInfo);\n return !!res;\n },\n\n /**\n * Returns a map with all the policies in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(Object.fromEntries(policies));\n },\n\n /**\n * Registers a policy\n */\n set(uid: string, policy: Core.Policy) {\n policies.set(uid, policy);\n return this;\n },\n\n /**\n * Registers a map of policies for a specific namespace\n */\n add(namespace: string, newPolicies: Record<string, Core.Policy>) {\n for (const policyName of Object.keys(newPolicies)) {\n const policy = newPolicies[policyName];\n const uid = addNamespace(policyName, namespace);\n\n if (has(uid, policies)) {\n throw new Error(`Policy ${uid} has already been registered.`);\n }\n\n policies.set(uid, policy);\n }\n },\n\n /**\n * Resolves a list of policies\n */\n resolve(config: PolicyConfig | PolicyConfig[], namespaceInfo?: NamespaceInfo) {\n const { pluginName, apiName } = namespaceInfo ?? {};\n\n return castArray(config).map((policyConfig) => {\n return {\n handler: resolveHandler(policyConfig, { pluginName, apiName }),\n config: (typeof policyConfig === 'object' && policyConfig.config) || {},\n };\n });\n },\n };\n};\n\nexport default policiesRegistry;\n"],"names":["config","namespace","pickBy","_","hasNamespace","addNamespace","has","castArray"],"mappings":";;;AAIA,MAAM,gBAAgB;AACtB,MAAM,aAAa;AAcnB,MAAM,cAAc,CAAC,WAAgC;AAC/C,MAAA,OAAO,WAAW,UAAU;AAC9B,WAAO,EAAE,YAAY,QAAQ,QAAQ,CAAG,EAAA;AAAA,EAC1C;AAEM,QAAA,EAAE,MAAM,OAAW,IAAA;AAClB,SAAA,EAAE,YAAY,MAAM;AAC7B;AAEA,MAAM,mBAAmB,MAAM;AACvB,QAAA,+BAAe;AAEf,QAAA,OAAO,CAAC,MAAc,kBAAkC;AAC5D,UAAM,EAAE,YAAY,YAAY,iBAAiB,CAAA;AAG3C,UAAA,SAAS,SAAS,IAAI,IAAI;AAEhC,QAAI,QAAQ;AACH,aAAA;AAAA,IACT;AAEA,QAAI,YAAY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AKA,IAAIA,aAAmB,aAA0C;AAC/D,iBAAW,cAAc,OAAO,KAAK,WAAW,GAAG;AAC3C,cAAA,SAAS,YAAY,UAAU;AAC/B,cAAA,MAAMI,UAAAA,aAAa,YAAYJ,WAAS;AAE1C,YAAAK,EAAA,IAAI,KAAK,QAAQ,GAAG;AACtB,gBAAM,IAAI,MAAM,UAAU,GAAG,+BAA+B;AAAA,QAC9D;AAES,iBAAA,IAAI,KAAK,MAAM;AAAA,MAC1B;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,QAAQ,QAAuC,eAA+B;AAC5E,YAAM,EAAE,YAAY,YAAY,iBAAiB,CAAA;AAEjD,aAAOC,EAAU,UAAA,MAAM,EAAE,IAAI,CAAC,iBAAiB;AACtC,eAAA;AAAA,UACL,SAAS,eAAe,cAAc,EAAE,YAAY,SAAS;AAAA,UAC7D,QAAS,OAAO,iBAAiB,YAAY,aAAa,UAAW,CAAC;AAAA,QAAA;AAAA,MACxE,CACD;AAAA,IACH;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"policies.js","sources":["../../src/registries/policies.ts"],"sourcesContent":["import { pickBy, has, castArray } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nconst PLUGIN_PREFIX = 'plugin::';\nconst API_PREFIX = 'api::';\n\ninterface PolicyInfo {\n name: string;\n config: unknown;\n}\n\ntype PolicyConfig = string | PolicyInfo;\n\ninterface NamespaceInfo {\n pluginName?: string;\n apiName?: string;\n}\n\nconst parsePolicy = (policy: string | PolicyInfo) => {\n if (typeof policy === 'string') {\n return { policyName: policy, config: {} };\n }\n\n const { name, config } = policy;\n return { policyName: name, config };\n};\n\nconst policiesRegistry = () => {\n const policies = new Map<string, Core.Policy>();\n\n const find = (name: string, namespaceInfo?: NamespaceInfo) => {\n const { pluginName, apiName } = namespaceInfo ?? {};\n\n // try to resolve a full name to avoid extra prefixing\n const policy = policies.get(name);\n\n if (policy) {\n return policy;\n }\n\n if (pluginName) {\n return policies.get(`${PLUGIN_PREFIX}${pluginName}.${name}`);\n }\n\n if (apiName) {\n return policies.get(`${API_PREFIX}${apiName}.${name}`);\n }\n };\n\n function resolveHandler(policyConfig: PolicyConfig, namespaceInfo?: NamespaceInfo): Core.Policy;\n function resolveHandler(\n policyConfig: PolicyConfig[],\n namespaceInfo?: NamespaceInfo\n ): Core.Policy[];\n function resolveHandler(\n policyConfig: PolicyConfig | PolicyConfig[],\n namespaceInfo?: NamespaceInfo\n ): Core.Policy | Core.Policy[] {\n if (Array.isArray(policyConfig)) {\n return policyConfig.map((config) => {\n return resolveHandler(config, namespaceInfo);\n });\n }\n\n const { policyName, config } = parsePolicy(policyConfig);\n\n const policy = find(policyName, namespaceInfo);\n\n if (!policy) {\n throw new Error(`Policy ${policyName} not found.`);\n }\n\n if (typeof policy === 'function') {\n return policy;\n }\n\n if (policy.validator) {\n policy.validator(config);\n }\n\n return policy.handler;\n }\n\n return {\n /**\n * Returns this list of registered policies uids\n */\n keys() {\n return policies.keys();\n },\n\n /**\n * Returns the instance of a policy. Instantiate the policy if not already done\n */\n get(name: string, namespaceInfo?: NamespaceInfo) {\n return find(name, namespaceInfo);\n },\n /**\n * Checks if a policy is registered\n */\n has(name: string, namespaceInfo?: NamespaceInfo) {\n const res = find(name, namespaceInfo);\n return !!res;\n },\n\n /**\n * Returns a map with all the policies in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(Object.fromEntries(policies));\n },\n\n /**\n * Registers a policy\n */\n set(uid: string, policy: Core.Policy) {\n policies.set(uid, policy);\n return this;\n },\n\n /**\n * Registers a map of policies for a specific namespace\n */\n add(namespace: string, newPolicies: Record<string, Core.Policy>) {\n for (const policyName of Object.keys(newPolicies)) {\n const policy = newPolicies[policyName];\n const uid = addNamespace(policyName, namespace);\n\n if (has(uid, policies)) {\n throw new Error(`Policy ${uid} has already been registered.`);\n }\n\n policies.set(uid, policy);\n }\n },\n\n /**\n * Resolves a list of policies\n */\n resolve(config: PolicyConfig | PolicyConfig[], namespaceInfo?: NamespaceInfo) {\n const { pluginName, apiName } = namespaceInfo ?? {};\n\n return castArray(config).map((policyConfig) => {\n return {\n handler: resolveHandler(policyConfig, { pluginName, apiName }),\n config: (typeof policyConfig === 'object' && policyConfig.config) || {},\n };\n });\n },\n };\n};\n\nexport default policiesRegistry;\n"],"names":["config","namespace","pickBy","hasNamespace","addNamespace","has","castArray"],"mappings":";;;AAIA,MAAM,gBAAgB;AACtB,MAAM,aAAa;AAcnB,MAAM,cAAc,CAAC,WAAgC;AAC/C,MAAA,OAAO,WAAW,UAAU;AAC9B,WAAO,EAAE,YAAY,QAAQ,QAAQ,CAAG,EAAA;AAAA,EAC1C;AAEM,QAAA,EAAE,MAAM,OAAW,IAAA;AAClB,SAAA,EAAE,YAAY,MAAM;AAC7B;AAEA,MAAM,mBAAmB,MAAM;AACvB,QAAA,+BAAe;AAEf,QAAA,OAAO,CAAC,MAAc,kBAAkC;AAC5D,UAAM,EAAE,YAAY,YAAY,iBAAiB,CAAA;AAG3C,UAAA,SAAS,SAAS,IAAI,IAAI;AAEhC,QAAI,QAAQ;AACH,aAAA;AAAA,IACT;AAEA,QAAI,YAAY;AACP,aAAA,SAAS,IAAI,GAAG,aAAa,GAAG,UAAU,IAAI,IAAI,EAAE;AAAA,IAC7D;AAEA,QAAI,SAAS;AACJ,aAAA,SAAS,IAAI,GAAG,UAAU,GAAG,OAAO,IAAI,IAAI,EAAE;AAAA,IACvD;AAAA,EAAA;AAQO,WAAA,eACP,cACA,eAC6B;AACzB,QAAA,MAAM,QAAQ,YAAY,GAAG;AACxB,aAAA,aAAa,IAAI,CAACA,YAAW;AAC3B,eAAA,eAAeA,SAAQ,aAAa;AAAA,MAAA,CAC5C;AAAA,IACH;AAEA,UAAM,EAAE,YAAY,OAAO,IAAI,YAAY,YAAY;AAEjD,UAAA,SAAS,KAAK,YAAY,aAAa;AAE7C,QAAI,CAAC,QAAQ;AACX,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eAAA;AAAA,UACL,SAAS,eAAe,cAAc,EAAE,YAAY,SAAS;AAAA,UAC7D,QAAS,OAAO,iBAAiB,YAAY,aAAa,UAAW,CAAC;AAAA,QAAA;AAAA,MACxE,CACD;AAAA,IACH;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const namespace = require("./namespace.js");
4
4
  const servicesRegistry = (strapi) => {
5
5
  const services = {};
@@ -28,7 +28,7 @@ const servicesRegistry = (strapi) => {
28
28
  * Returns a map with all the services in a namespace
29
29
  */
30
30
  getAll(namespace$1) {
31
- const filteredServices = _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(services);
31
+ const filteredServices = fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(services);
32
32
  const map = {};
33
33
  for (const uid of Object.keys(filteredServices)) {
34
34
  Object.defineProperty(map, uid, {
@@ -55,7 +55,7 @@ const servicesRegistry = (strapi) => {
55
55
  for (const serviceName of Object.keys(newServices)) {
56
56
  const service = newServices[serviceName];
57
57
  const uid = namespace.addNamespace(serviceName, namespace$1);
58
- if (_.has(uid, services)) {
58
+ if (fp.has(uid, services)) {
59
59
  throw new Error(`Service ${uid} has already been registered.`);
60
60
  }
61
61
  services[uid] = service;
@@ -1 +1 @@
1
- {"version":3,"file":"services.js","sources":["../../src/registries/services.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nexport type ServiceFactory = (params: { strapi: Core.Strapi }) => Core.Service | Core.Service;\nexport type ServiceFactoryMap = Record<string, ServiceFactory>;\nexport type ServiceMap = Record<string, Core.Service>;\nexport type ServiceExtendFn = (service: Core.Service) => Core.Service;\n\nconst servicesRegistry = (strapi: Core.Strapi) => {\n const services: ServiceFactoryMap = {};\n const instantiatedServices: ServiceMap = {};\n\n return {\n /**\n * Returns this list of registered services uids\n */\n keys() {\n return Object.keys(services);\n },\n\n /**\n * Returns the instance of a service. Instantiate the service if not already done\n */\n get(uid: UID.Service) {\n if (instantiatedServices[uid]) {\n return instantiatedServices[uid];\n }\n\n const service = services[uid];\n if (service) {\n instantiatedServices[uid] = typeof service === 'function' ? service({ strapi }) : service;\n return instantiatedServices[uid];\n }\n },\n\n /**\n * Returns a map with all the services in a namespace\n */\n getAll(namespace: string): ServiceMap {\n const filteredServices = pickBy((_, uid) => hasNamespace(uid, namespace))(services);\n\n // create lazy accessor to avoid instantiating the services;\n const map = {};\n for (const uid of Object.keys(filteredServices)) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid as UID.Service);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a service\n */\n set(uid: string, service: ServiceFactory) {\n services[uid] = service;\n delete instantiatedServices[uid];\n return this;\n },\n\n /**\n * Registers a map of services for a specific namespace\n */\n add(namespace: string, newServices: ServiceFactoryMap) {\n for (const serviceName of Object.keys(newServices)) {\n const service = newServices[serviceName];\n const uid = addNamespace(serviceName, namespace);\n\n if (has(uid, services)) {\n throw new Error(`Service ${uid} has already been registered.`);\n }\n services[uid] = service;\n }\n\n return this;\n },\n\n /**\n * Wraps a service to extend it\n */\n extend(uid: UID.Service, extendFn: ServiceExtendFn) {\n const currentService = this.get(uid);\n\n if (!currentService) {\n throw new Error(`Service ${uid} doesn't exist`);\n }\n\n const newService = extendFn(currentService);\n instantiatedServices[uid] = newService;\n\n return this;\n },\n };\n};\n\nexport default servicesRegistry;\n"],"names":["namespace","pickBy","_","hasNamespace","addNamespace","has"],"mappings":";;;AASM,MAAA,mBAAmB,CAAC,WAAwB;AAChD,QAAM,WAA8B,CAAA;AACpC,QAAM,uBAAmC,CAAA;AAElC,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,QAAQ;AAAA,IAC7B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAkB;AA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AgB;AAAA,MAChD;AAEM,YAAA,aAAa,SAAS,cAAc;AAC1C,2BAAqB,GAAG,IAAI;AAErB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"services.js","sources":["../../src/registries/services.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nexport type ServiceFactory = (params: { strapi: Core.Strapi }) => Core.Service | Core.Service;\nexport type ServiceFactoryMap = Record<string, ServiceFactory>;\nexport type ServiceMap = Record<string, Core.Service>;\nexport type ServiceExtendFn = (service: Core.Service) => Core.Service;\n\nconst servicesRegistry = (strapi: Core.Strapi) => {\n const services: ServiceFactoryMap = {};\n const instantiatedServices: ServiceMap = {};\n\n return {\n /**\n * Returns this list of registered services uids\n */\n keys() {\n return Object.keys(services);\n },\n\n /**\n * Returns the instance of a service. Instantiate the service if not already done\n */\n get(uid: UID.Service) {\n if (instantiatedServices[uid]) {\n return instantiatedServices[uid];\n }\n\n const service = services[uid];\n if (service) {\n instantiatedServices[uid] = typeof service === 'function' ? service({ strapi }) : service;\n return instantiatedServices[uid];\n }\n },\n\n /**\n * Returns a map with all the services in a namespace\n */\n getAll(namespace: string): ServiceMap {\n const filteredServices = pickBy((_, uid) => hasNamespace(uid, namespace))(services);\n\n // create lazy accessor to avoid instantiating the services;\n const map = {};\n for (const uid of Object.keys(filteredServices)) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid as UID.Service);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a service\n */\n set(uid: string, service: ServiceFactory) {\n services[uid] = service;\n delete instantiatedServices[uid];\n return this;\n },\n\n /**\n * Registers a map of services for a specific namespace\n */\n add(namespace: string, newServices: ServiceFactoryMap) {\n for (const serviceName of Object.keys(newServices)) {\n const service = newServices[serviceName];\n const uid = addNamespace(serviceName, namespace);\n\n if (has(uid, services)) {\n throw new Error(`Service ${uid} has already been registered.`);\n }\n services[uid] = service;\n }\n\n return this;\n },\n\n /**\n * Wraps a service to extend it\n */\n extend(uid: UID.Service, extendFn: ServiceExtendFn) {\n const currentService = this.get(uid);\n\n if (!currentService) {\n throw new Error(`Service ${uid} doesn't exist`);\n }\n\n const newService = extendFn(currentService);\n instantiatedServices[uid] = newService;\n\n return this;\n },\n };\n};\n\nexport default servicesRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AASM,MAAA,mBAAmB,CAAC,WAAwB;AAChD,QAAM,WAA8B,CAAA;AACpC,QAAM,uBAAmC,CAAA;AAElC,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,QAAQ;AAAA,IAC7B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAkB;AAChB,UAAA,qBAAqB,GAAG,GAAG;AAC7B,eAAO,qBAAqB,GAAG;AAAA,MACjC;AAEM,YAAA,UAAU,SAAS,GAAG;AAC5B,UAAI,SAAS;AACU,6BAAA,GAAG,IAAI,OAAO,YAAY,aAAa,QAAQ,EAAE,QAAQ,IAAI;AAClF,eAAO,qBAAqB,GAAG;AAAA,MACjC;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAA+B;AAC9B,YAAA,mBAAmBC,GAAAA,OAAO,CAAC,GAAG,QAAQC,uBAAa,KAAKF,WAAS,CAAC,EAAE,QAAQ;AAGlF,YAAM,MAAM,CAAA;AACZ,iBAAW,OAAO,OAAO,KAAK,gBAAgB,GAAG;AACxC,eAAA,eAAe,KAAK,KAAK;AAAA,UAC9B,YAAY;AAAA,UACZ,KAAK,MAAM;AACF,mBAAA,KAAK,IAAI,GAAkB;AAAA,UACpC;AAAA,QAAA,CACD;AAAA,MACH;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,SAAyB;AACxC,eAAS,GAAG,IAAI;AAChB,aAAO,qBAAqB,GAAG;AACxB,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,aAAgC;AACrD,iBAAW,eAAe,OAAO,KAAK,WAAW,GAAG;AAC5C,cAAA,UAAU,YAAY,WAAW;AACjC,cAAA,MAAMG,UAAAA,aAAa,aAAaH,WAAS;AAE3C,YAAAI,GAAA,IAAI,KAAK,QAAQ,GAAG;AACtB,gBAAM,IAAI,MAAM,WAAW,GAAG,+BAA+B;AAAA,QAC/D;AACA,iBAAS,GAAG,IAAI;AAAA,MAClB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAkB,UAA2B;AAC5C,YAAA,iBAAiB,KAAK,IAAI,GAAG;AAEnC,UAAI,CAAC,gBAAgB;AACnB,cAAM,IAAI,MAAM,WAAW,GAAG,gBAAgB;AAAA,MAChD;AAEM,YAAA,aAAa,SAAS,cAAc;AAC1C,2BAAqB,GAAG,IAAI;AAErB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  const assert = require("assert/strict");
3
- const _ = require("lodash/fp");
3
+ const fp = require("lodash/fp");
4
4
  const strapiUtils = require("@strapi/utils");
5
5
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
6
6
  const assert__default = /* @__PURE__ */ _interopDefault(assert);
7
7
  const INVALID_STRATEGY_MSG = "Invalid auth strategy. Expecting an object with properties {name: string, authenticate: function, verify: function}";
8
8
  const validStrategy = (strategy) => {
9
- assert__default.default(_.has("authenticate", strategy), INVALID_STRATEGY_MSG);
9
+ assert__default.default(fp.has("authenticate", strategy), INVALID_STRATEGY_MSG);
10
10
  assert__default.default(typeof strategy.authenticate === "function", INVALID_STRATEGY_MSG);
11
- if (_.has("verify", strategy)) {
11
+ if (fp.has("verify", strategy)) {
12
12
  assert__default.default(typeof strategy.verify === "function", INVALID_STRATEGY_MSG);
13
13
  }
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/services/auth/index.ts"],"sourcesContent":["import assert from 'assert/strict';\nimport { has } from 'lodash/fp';\n\nimport { errors } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport type { ParameterizedContext } from 'koa';\n\ninterface AuthenticationResponse {\n authenticated?: boolean;\n credentials?: unknown;\n ability?: unknown;\n error?: Error | null;\n}\n\ninterface AuthenticationInfo {\n strategy: Strategy;\n credentials: unknown;\n ability: unknown;\n}\n\ninterface Strategy {\n name: string;\n authenticate: (ctx: ParameterizedContext) => Promise<AuthenticationResponse>;\n verify?: (auth: AuthenticationInfo, config: Core.RouteConfig['auth']) => Promise<any>;\n}\n\ninterface Authentication {\n register: (type: string, strategy: Strategy) => Authentication;\n authenticate: Core.MiddlewareHandler;\n verify: (auth: AuthenticationInfo, config?: Core.RouteConfig['auth']) => Promise<any>;\n}\n\nconst INVALID_STRATEGY_MSG =\n 'Invalid auth strategy. Expecting an object with properties {name: string, authenticate: function, verify: function}';\n\nconst validStrategy = (strategy: Strategy) => {\n assert(has('authenticate', strategy), INVALID_STRATEGY_MSG);\n assert(typeof strategy.authenticate === 'function', INVALID_STRATEGY_MSG);\n\n if (has('verify', strategy)) {\n assert(typeof strategy.verify === 'function', INVALID_STRATEGY_MSG);\n }\n};\n\nconst createAuthentication = (): Authentication => {\n const strategies: Record<string, Strategy[]> = {};\n\n return {\n register(type, strategy) {\n validStrategy(strategy);\n\n if (!strategies[type]) {\n strategies[type] = [];\n }\n\n strategies[type].push(strategy);\n\n return this;\n },\n\n async authenticate(ctx, next) {\n const route: Core.Route = ctx.state.route;\n\n // use route strategy\n const config = route?.config?.auth;\n\n if (config === false) {\n return next();\n }\n\n const routeStrategies = route.info.type ? strategies[route.info.type] : [];\n const configStrategies = (config?.strategies ?? routeStrategies ?? []) as Array<\n string | Strategy\n >;\n\n const strategiesToUse: Strategy[] = configStrategies.reduce(\n (acc, strategy: string | Strategy) => {\n // Resolve by strategy name\n if (typeof strategy === 'string') {\n const routeStrategy = routeStrategies.find((rs) => rs.name === strategy);\n\n if (routeStrategy) {\n acc.push(routeStrategy);\n }\n }\n\n // Use the given strategy as is\n else if (typeof strategy === 'object') {\n validStrategy(strategy);\n\n acc.push(strategy);\n }\n\n return acc;\n },\n [] as Strategy[]\n );\n\n for (const strategy of strategiesToUse) {\n const result = await strategy.authenticate(ctx);\n\n const { authenticated = false, credentials, ability = null, error = null } = result || {};\n\n if (error !== null) {\n return ctx.unauthorized(error);\n }\n\n if (authenticated) {\n ctx.state.isAuthenticated = true;\n ctx.state.auth = {\n strategy,\n credentials,\n ability,\n };\n\n return next();\n }\n }\n\n return ctx.unauthorized('Missing or invalid credentials');\n },\n\n async verify(auth, config = {}) {\n if (config === false) {\n return;\n }\n\n if (!auth) {\n throw new errors.UnauthorizedError();\n }\n\n if (typeof auth.strategy.verify === 'function') {\n return auth.strategy.verify(auth, config);\n }\n },\n };\n};\n\nexport default createAuthentication;\n"],"names":["assert","has","errors"],"mappings":";;;;;;AAgCA,MAAM,uBACJ;AAEF,MAAM,gBAAgB,CAAC,aAAuB;AAC5CA,kBAAAA,QAAOC,EAAAA,IAAI,gBAAgB,QAAQ,GAAG,oBAAoB;AAC1DD,kBAAAA,QAAO,OAAO,SAAS,iBAAiB,YAAY,oBAAoB;AAEpE,MAAAC,EAAA,IAAI,UAAU,QAAQ,GAAG;AAC3BD,oBAAAA,QAAO,OAAO,SAAS,WAAW,YAAY,oBAAoB;AAAA,EACpE;AACF;AAEA,MAAM,uBAAuB,MAAsB;AACjD,QAAM,aAAyC,CAAA;AAExC,SAAA;AAAA,IACL,SAAS,MAAM,UAAU;AACvB,oBAAc,QAAQ;AAElB,UAAA,CAAC,WAAW,IAAI,GAAG;AACV,mBAAA,IAAI,IAAI;MACrB;AAEW,iBAAA,IAAI,EAAE,KAAK,QAAQ;AAEvB,aAAA;AAAA,IACT;AAAA,IAEA,MAAM,aAAa,KAAK,MAAM;AACtB,YAAA,QAAoB,IAAI,MAAM;AAG9B,YAAA,SA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AA;AAEJ;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/services/auth/index.ts"],"sourcesContent":["import assert from 'assert/strict';\nimport { has } from 'lodash/fp';\n\nimport { errors } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport type { ParameterizedContext } from 'koa';\n\ninterface AuthenticationResponse {\n authenticated?: boolean;\n credentials?: unknown;\n ability?: unknown;\n error?: Error | null;\n}\n\ninterface AuthenticationInfo {\n strategy: Strategy;\n credentials: unknown;\n ability: unknown;\n}\n\ninterface Strategy {\n name: string;\n authenticate: (ctx: ParameterizedContext) => Promise<AuthenticationResponse>;\n verify?: (auth: AuthenticationInfo, config: Core.RouteConfig['auth']) => Promise<any>;\n}\n\ninterface Authentication {\n register: (type: string, strategy: Strategy) => Authentication;\n authenticate: Core.MiddlewareHandler;\n verify: (auth: AuthenticationInfo, config?: Core.RouteConfig['auth']) => Promise<any>;\n}\n\nconst INVALID_STRATEGY_MSG =\n 'Invalid auth strategy. Expecting an object with properties {name: string, authenticate: function, verify: function}';\n\nconst validStrategy = (strategy: Strategy) => {\n assert(has('authenticate', strategy), INVALID_STRATEGY_MSG);\n assert(typeof strategy.authenticate === 'function', INVALID_STRATEGY_MSG);\n\n if (has('verify', strategy)) {\n assert(typeof strategy.verify === 'function', INVALID_STRATEGY_MSG);\n }\n};\n\nconst createAuthentication = (): Authentication => {\n const strategies: Record<string, Strategy[]> = {};\n\n return {\n register(type, strategy) {\n validStrategy(strategy);\n\n if (!strategies[type]) {\n strategies[type] = [];\n }\n\n strategies[type].push(strategy);\n\n return this;\n },\n\n async authenticate(ctx, next) {\n const route: Core.Route = ctx.state.route;\n\n // use route strategy\n const config = route?.config?.auth;\n\n if (config === false) {\n return next();\n }\n\n const routeStrategies = route.info.type ? strategies[route.info.type] : [];\n const configStrategies = (config?.strategies ?? routeStrategies ?? []) as Array<\n string | Strategy\n >;\n\n const strategiesToUse: Strategy[] = configStrategies.reduce(\n (acc, strategy: string | Strategy) => {\n // Resolve by strategy name\n if (typeof strategy === 'string') {\n const routeStrategy = routeStrategies.find((rs) => rs.name === strategy);\n\n if (routeStrategy) {\n acc.push(routeStrategy);\n }\n }\n\n // Use the given strategy as is\n else if (typeof strategy === 'object') {\n validStrategy(strategy);\n\n acc.push(strategy);\n }\n\n return acc;\n },\n [] as Strategy[]\n );\n\n for (const strategy of strategiesToUse) {\n const result = await strategy.authenticate(ctx);\n\n const { authenticated = false, credentials, ability = null, error = null } = result || {};\n\n if (error !== null) {\n return ctx.unauthorized(error);\n }\n\n if (authenticated) {\n ctx.state.isAuthenticated = true;\n ctx.state.auth = {\n strategy,\n credentials,\n ability,\n };\n\n return next();\n }\n }\n\n return ctx.unauthorized('Missing or invalid credentials');\n },\n\n async verify(auth, config = {}) {\n if (config === false) {\n return;\n }\n\n if (!auth) {\n throw new errors.UnauthorizedError();\n }\n\n if (typeof auth.strategy.verify === 'function') {\n return auth.strategy.verify(auth, config);\n }\n },\n };\n};\n\nexport default createAuthentication;\n"],"names":["assert","has","errors"],"mappings":";;;;;;AAgCA,MAAM,uBACJ;AAEF,MAAM,gBAAgB,CAAC,aAAuB;AAC5CA,kBAAAA,QAAOC,GAAAA,IAAI,gBAAgB,QAAQ,GAAG,oBAAoB;AAC1DD,kBAAAA,QAAO,OAAO,SAAS,iBAAiB,YAAY,oBAAoB;AAEpE,MAAAC,GAAA,IAAI,UAAU,QAAQ,GAAG;AAC3BD,oBAAAA,QAAO,OAAO,SAAS,WAAW,YAAY,oBAAoB;AAAA,EACpE;AACF;AAEA,MAAM,uBAAuB,MAAsB;AACjD,QAAM,aAAyC,CAAA;AAExC,SAAA;AAAA,IACL,SAAS,MAAM,UAAU;AACvB,oBAAc,QAAQ;AAElB,UAAA,CAAC,WAAW,IAAI,GAAG;AACV,mBAAA,IAAI,IAAI;MACrB;AAEW,iBAAA,IAAI,EAAE,KAAK,QAAQ;AAEvB,aAAA;AAAA,IACT;AAAA,IAEA,MAAM,aAAa,KAAK,MAAM;AACtB,YAAA,QAAo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AA,MAC1C;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const _ = require("lodash/fp");
3
+ const fp = require("lodash/fp");
4
4
  const coreStoreModel = {
5
5
  uid: "strapi::core-store",
6
6
  singularName: "strapi_core_store_settings",
@@ -77,7 +77,7 @@ const createCoreStore = ({ db }) => {
77
77
  return db.query("strapi::core-store").update({
78
78
  where: { id: data.id },
79
79
  data: {
80
- value: JSON.stringify(value) || _.toString(value),
80
+ value: JSON.stringify(value) || fp.toString(value),
81
81
  type: typeof value
82
82
  }
83
83
  });
@@ -85,7 +85,7 @@ const createCoreStore = ({ db }) => {
85
85
  return db.query("strapi::core-store").create({
86
86
  data: {
87
87
  ...where,
88
- value: JSON.stringify(value) || _.toString(value),
88
+ value: JSON.stringify(value) || fp.toString(value),
89
89
  type: typeof value
90
90
  }
91
91
  });
@@ -1 +1 @@
1
- {"version":3,"file":"core-store.js","sources":["../../src/services/core-store.ts"],"sourcesContent":["import { toString } from 'lodash/fp';\nimport type { Database, Model } from '@strapi/database';\n\nconst coreStoreModel: Model = {\n uid: 'strapi::core-store',\n singularName: 'strapi_core_store_settings',\n tableName: 'strapi_core_store_settings',\n attributes: {\n id: {\n type: 'increments',\n },\n key: {\n type: 'string',\n },\n value: {\n type: 'text',\n },\n type: {\n type: 'string',\n },\n environment: {\n type: 'string',\n },\n tag: {\n type: 'string',\n },\n },\n};\n\ntype SetParams = {\n key: string;\n value: unknown;\n type?: string;\n environment?: string;\n name?: string;\n tag?: string;\n};\n\ntype GetParams = {\n key: string;\n type?: string;\n environment?: string;\n name?: string;\n tag?: string;\n};\n\ntype Params = SetParams & GetParams;\n\ninterface CoreStore {\n (defaultParams: Partial<Params>): {\n get(params: Partial<GetParams>): Promise<unknown>;\n set(params: Partial<SetParams>): Promise<void>;\n delete(params: Partial<GetParams>): Promise<void>;\n };\n get(params: GetParams): Promise<unknown>;\n set(params: SetParams): Promise<void>;\n delete(params: GetParams): Promise<void>;\n}\n\nconst createCoreStore = ({ db }: { db: Database }) => {\n const mergeParams = (defaultParams: Partial<Params>, params: Params): Params => {\n return {\n ...defaultParams,\n ...params,\n };\n };\n\n const store: CoreStore = function (defaultParams: Partial<Params>) {\n return {\n get: (params: Params) => store.get(mergeParams(defaultParams, params)),\n set: (params: Params) => store.set(mergeParams(defaultParams, params)),\n delete: (params: Params) => store.delete(mergeParams(defaultParams, params)),\n };\n };\n\n /**\n * Get value from the core store\n */\n store.get = async (params) => {\n const { key, type = 'core', environment, name, tag } = params;\n\n const prefix = `${type}${name ? `_${name}` : ''}`;\n\n const where = {\n key: `${prefix}_${key}`,\n environment: environment || null,\n tag: tag || null,\n };\n\n const data = await db.query('strapi::core-store').findOne({ where });\n\n if (!data) {\n return null;\n }\n\n if (\n data.type === 'object' ||\n data.type === 'array' ||\n data.type === 'boolean' ||\n data.type === 'string'\n ) {\n try {\n return JSON.parse(data.value);\n } catch (err) {\n return new Date(data.value);\n }\n } else if (data.type === 'number') {\n return Number(data.value);\n } else {\n return null;\n }\n };\n\n /**\n * Set value in the core store\n * @param {Object} params\n * @returns {*}\n */\n store.set = async (params) => {\n const { key, value, type, environment, name, tag } = params;\n\n const prefix = `${type}${name ? `_${name}` : ''}`;\n\n const where = {\n key: `${prefix}_${key}`,\n environment: environment || null,\n tag: tag || null,\n };\n\n const data = await db.query('strapi::core-store').findOne({ where });\n\n if (data) {\n return db.query('strapi::core-store').update({\n where: { id: data.id },\n data: {\n value: JSON.stringify(value) || toString(value),\n type: typeof value,\n },\n });\n }\n\n return db.query('strapi::core-store').create({\n data: {\n ...where,\n value: JSON.stringify(value) || toString(value),\n type: typeof value,\n },\n });\n };\n\n /**\n * Deletes a value from the core store\n * @param {Object} params\n * @returns {*}\n */\n store.delete = async (params) => {\n const { key, environment, type, name, tag } = params;\n\n const prefix = `${type}${name ? `_${name}` : ''}`;\n\n const where = {\n key: `${prefix}_${key}`,\n environment: environment || null,\n tag: tag || null,\n };\n\n return db.query('strapi::core-store').delete({ where });\n };\n\n return store;\n};\n\nexport { coreStoreModel, createCoreStore };\n"],"names":["toString"],"mappings":";;;AAGA,MAAM,iBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,cAAc;AAAA,EACd,WAAW;AAAA,EACX,YAAY;AAAA,IACV,IAAI;AAAA,MACF,MAAM;AAAA,IACR;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,IACR;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAgCA,MAAM,kBAAkB,CAAC,EAAE,SAA2B;AAC9C,QAAA,cAAc,CAAC,eAAgC,WAA2B;AACvE,WAAA;AAAA,MACL,GAAG;AAAA,MACH,GAAG;AAAA,IAAA;AAAA,EACL;AAGI,QAAA,QAAmB,SAAU,eAAgC;AAC1D,WAAA;AAAA,MACL,KAAK,CAAC,WAAmB,MAAM,IAAI,YAAY,eAAe,MAAM,CAAC;AAAA,MACrE,KAAK,CAAC,WAAmB,MAAM,IAAI,YAAY,eAAe,MAAM,CAAC;AAAA,MACrE,QAAQ,CAAC,WAAmB,MAAM,OAAO,YAAY,eAAe,MAAM,CAAC;AAAA,IAAA;AAAA,EAC7E;AAMI,QAAA,MAAM,OAAO,WAAW;AAC5B,UAAM,EAAE,KAAK,OAAO,QAAQ,aAAa,MAAM,IAAQ,IAAA;AAEjD,UAAA,SAAS,GAAG,IAAI,GAAG,OAAO,IAAI,IAAI,KAAK,EAAE;AAE/C,UAAM,QAAQ;AAAA,MACZ,KAAK,GAAG,MAAM,IAAI,GAAG;AAAA,MACrB,aAAa,eAAe;AAAA,MAC5B,KAAK,OAAO;AAAA,IAAA;AAGR,UAAA,OAAO,MAAM,G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AAA,SAAS,OAAO,WAAW;AAC/B,UAAM,EAAE,KAAK,aAAa,MAAM,MAAM,IAAQ,IAAA;AAExC,UAAA,SAAS,GAAG,IAAI,GAAG,OAAO,IAAI,IAAI,KAAK,EAAE;AAE/C,UAAM,QAAQ;AAAA,MACZ,KAAK,GAAG,MAAM,IAAI,GAAG;AAAA,MACrB,aAAa,eAAe;AAAA,MAC5B,KAAK,OAAO;AAAA,IAAA;AAGd,WAAO,GAAG,MAAM,oBAAoB,EAAE,OAAO,EAAE,OAAO;AAAA,EAAA;AAGjD,SAAA;AACT;;;"}
1
+ {"version":3,"file":"core-store.js","sources":["../../src/services/core-store.ts"],"sourcesContent":["import { toString } from 'lodash/fp';\nimport type { Database, Model } from '@strapi/database';\n\nconst coreStoreModel: Model = {\n uid: 'strapi::core-store',\n singularName: 'strapi_core_store_settings',\n tableName: 'strapi_core_store_settings',\n attributes: {\n id: {\n type: 'increments',\n },\n key: {\n type: 'string',\n },\n value: {\n type: 'text',\n },\n type: {\n type: 'string',\n },\n environment: {\n type: 'string',\n },\n tag: {\n type: 'string',\n },\n },\n};\n\ntype SetParams = {\n key: string;\n value: unknown;\n type?: string;\n environment?: string;\n name?: string;\n tag?: string;\n};\n\ntype GetParams = {\n key: string;\n type?: string;\n environment?: string;\n name?: string;\n tag?: string;\n};\n\ntype Params = SetParams & GetParams;\n\ninterface CoreStore {\n (defaultParams: Partial<Params>): {\n get(params: Partial<GetParams>): Promise<unknown>;\n set(params: Partial<SetParams>): Promise<void>;\n delete(params: Partial<GetParams>): Promise<void>;\n };\n get(params: GetParams): Promise<unknown>;\n set(params: SetParams): Promise<void>;\n delete(params: GetParams): Promise<void>;\n}\n\nconst createCoreStore = ({ db }: { db: Database }) => {\n const mergeParams = (defaultParams: Partial<Params>, params: Params): Params => {\n return {\n ...defaultParams,\n ...params,\n };\n };\n\n const store: CoreStore = function (defaultParams: Partial<Params>) {\n return {\n get: (params: Params) => store.get(mergeParams(defaultParams, params)),\n set: (params: Params) => store.set(mergeParams(defaultParams, params)),\n delete: (params: Params) => store.delete(mergeParams(defaultParams, params)),\n };\n };\n\n /**\n * Get value from the core store\n */\n store.get = async (params) => {\n const { key, type = 'core', environment, name, tag } = params;\n\n const prefix = `${type}${name ? `_${name}` : ''}`;\n\n const where = {\n key: `${prefix}_${key}`,\n environment: environment || null,\n tag: tag || null,\n };\n\n const data = await db.query('strapi::core-store').findOne({ where });\n\n if (!data) {\n return null;\n }\n\n if (\n data.type === 'object' ||\n data.type === 'array' ||\n data.type === 'boolean' ||\n data.type === 'string'\n ) {\n try {\n return JSON.parse(data.value);\n } catch (err) {\n return new Date(data.value);\n }\n } else if (data.type === 'number') {\n return Number(data.value);\n } else {\n return null;\n }\n };\n\n /**\n * Set value in the core store\n * @param {Object} params\n * @returns {*}\n */\n store.set = async (params) => {\n const { key, value, type, environment, name, tag } = params;\n\n const prefix = `${type}${name ? `_${name}` : ''}`;\n\n const where = {\n key: `${prefix}_${key}`,\n environment: environment || null,\n tag: tag || null,\n };\n\n const data = await db.query('strapi::core-store').findOne({ where });\n\n if (data) {\n return db.query('strapi::core-store').update({\n where: { id: data.id },\n data: {\n value: JSON.stringify(value) || toString(value),\n type: typeof value,\n },\n });\n }\n\n return db.query('strapi::core-store').create({\n data: {\n ...where,\n value: JSON.stringify(value) || toString(value),\n type: typeof value,\n },\n });\n };\n\n /**\n * Deletes a value from the core store\n * @param {Object} params\n * @returns {*}\n */\n store.delete = async (params) => {\n const { key, environment, type, name, tag } = params;\n\n const prefix = `${type}${name ? `_${name}` : ''}`;\n\n const where = {\n key: `${prefix}_${key}`,\n environment: environment || null,\n tag: tag || null,\n };\n\n return db.query('strapi::core-store').delete({ where });\n };\n\n return store;\n};\n\nexport { coreStoreModel, createCoreStore };\n"],"names":["toString"],"mappings":";;;AAGA,MAAM,iBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,cAAc;AAAA,EACd,WAAW;AAAA,EACX,YAAY;AAAA,IACV,IAAI;AAAA,MACF,MAAM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AK,OAAO;AAAA,IAAA;AAGd,WAAO,GAAG,MAAM,oBAAoB,EAAE,OAAO,EAAE,OAAO;AAAA,EAAA;AAGjD,SAAA;AACT;;;"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const nodeSchedule = require("node-schedule");
3
- const _ = require("lodash/fp");
3
+ const fp = require("lodash/fp");
4
4
  const createCronService = () => {
5
5
  let jobsSpecs = [];
6
6
  let running = false;
@@ -11,11 +11,11 @@ const createCronService = () => {
11
11
  let fn;
12
12
  let options;
13
13
  let taskName;
14
- if (_.isFunction(taskValue)) {
14
+ if (fp.isFunction(taskValue)) {
15
15
  taskName = null;
16
16
  fn = taskValue.bind(tasks);
17
17
  options = taskExpression;
18
- } else if (_.isFunction(taskValue.task)) {
18
+ } else if (fp.isFunction(taskValue.task)) {
19
19
  taskName = taskExpression;
20
20
  fn = taskValue.task.bind(taskValue);
21
21
  options = taskValue.options;
@@ -1 +1 @@
1
- {"version":3,"file":"cron.js","sources":["../../src/services/cron.ts"],"sourcesContent":["import { Job } from 'node-schedule';\nimport { isFunction } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\ninterface JobSpec {\n job: Job;\n options: string | number | Date;\n name: string | null;\n}\n\ntype TaskFn = ({ strapi }: { strapi: Core.Strapi }, ...args: unknown[]) => Promise<unknown>;\n\ntype Task =\n | TaskFn\n | {\n task: TaskFn;\n options: string;\n };\n\ninterface Tasks {\n [key: string]: Task;\n}\n\nconst createCronService = () => {\n let jobsSpecs: JobSpec[] = [];\n let running = false;\n\n return {\n add(tasks: Tasks = {}) {\n for (const taskExpression of Object.keys(tasks)) {\n const taskValue = tasks[taskExpression];\n\n let fn: TaskFn;\n let options: string | number | Date;\n let taskName: string | null;\n if (isFunction(taskValue)) {\n // don't use task name if key is the rule\n taskName = null;\n fn = taskValue.bind(tasks);\n options = taskExpression;\n } else if (isFunction(taskValue.task)) {\n // set task name if key is not the rule\n taskName = taskExpression;\n fn = taskValue.task.bind(taskValue);\n options = taskValue.options;\n } else {\n throw new Error(\n `Could not schedule a cron job for \"${taskExpression}\": no function found.`\n );\n }\n\n const fnWithStrapi = (...args: unknown[]) => fn({ strapi }, ...args);\n\n // const job = new Job(null, fnWithStrapi);\n const job = new Job(fnWithStrapi);\n jobsSpecs.push({ job, options, name: taskName });\n\n if (running) {\n job.schedule(options);\n }\n }\n return this;\n },\n\n remove(name: string) {\n if (!name) {\n throw new Error('You must provide a name to remove a cron job.');\n }\n\n jobsSpecs\n .filter(({ name: jobSpecName }) => jobSpecName === name)\n .forEach(({ job }) => job.cancel());\n\n jobsSpecs = jobsSpecs.filter(({ name: jobSpecName }) => jobSpecName !== name);\n return this;\n },\n\n start() {\n jobsSpecs.forEach(({ job, options }) => job.schedule(options));\n running = true;\n return this;\n },\n\n stop() {\n jobsSpecs.forEach(({ job }) => job.cancel());\n running = false;\n return this;\n },\n\n destroy() {\n this.stop();\n jobsSpecs = [];\n return this;\n },\n jobs: jobsSpecs,\n };\n};\n\nexport default createCronService;\n"],"names":["isFunction","Job"],"mappings":";;;AAuBA,MAAM,oBAAoB,MAAM;AAC9B,MAAI,YAAuB,CAAA;AAC3B,MAAI,UAAU;AAEP,SAAA;AAAA,IACL,IAAI,QAAe,IAAI;AACrB,iBAAW,kBAAkB,OAAO,KAAK,KAAK,GAAG;AACzC,cAAA,YAAY,MAAM,cAAc;AAElC,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAAA,EAAAA,WAAW,SAAS,GAAG;AAEd,qBAAA;AACN,eAAA,UAAU,KAAK,KAAK;AACf,oBAAA;AAAA,QACD,WAAAA,EAAA,WAAW,UAAU,IAAI,GAAG;AAE1B,qBAAA;AACN,eAAA,UAAU,KAAK,KAAK,SAAS;AAClC,oBAAU,UAAU;AAAA,QAAA,OACf;AACL,gBAAM,IAAI;AAAA,YACR,sCAAsC,cAAc;AAAA,UAAA;AAAA,QAExD;AAEM,cAAA,eAAe,IAAI,SAAoB,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI;AAG7D,cAAA,MAAM,IAAIC,iBAAI,YAAY;AAChC,kBAAU,KAAK,EAAE,KAAK,SAAS,MAAM,UAAU;AAE/C,YAAI,SAAS;AACX,cAAI,SAAS,OAAO;AAAA,QACtB;AAAA,MACF;AACO,aAAA;AAAA,IACT;AAAA,IAEA,OAAO,MAAc;AACnB,UAAI,CAAC,MAAM;AACH,cAAA,IAAI,MAAM,+CAA+C;AAAA,MACjE;AAEA,gBACG,OAAO,CAAC,EAAE,MAAM,YAAA,MAAkB,gBAAgB,IAAI,EACtD,QAAQ,CAAC,EAAE,IAAA,MAAU,IAAI,OAAQ,CAAA;AAExB,kBAAA,UAAU,OAAO,CAAC,EAAE,MAAM,YAAY,MAAM,gBAAgB,IAAI;AACrE,aAAA;AAAA,IACT;AAAA,IAEA,QAAQ;AACI,gBAAA,QAAQ,CAAC,EAAE,KAAK,QAAc,MAAA,IAAI,SAAS,OAAO,CAAC;AACnD,gBAAA;AACH,aAAA;AAAA,IACT;AAAA,IAEA,OAAO;AACL,gBAAU,QAAQ,CAAC,EAAE,IAAU,MAAA,IAAI,QAAQ;AACjC,gBAAA;AACH,aAAA;AAAA,IACT;AAAA,IAEA,UAAU;AACR,WAAK,KAAK;AACV,kBAAY,CAAA;AACL,aAAA;AAAA,IACT;AAAA,IACA,MAAM;AAAA,EAAA;AAEV;;"}
1
+ {"version":3,"file":"cron.js","sources":["../../src/services/cron.ts"],"sourcesContent":["import { Job } from 'node-schedule';\nimport { isFunction } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\ninterface JobSpec {\n job: Job;\n options: string | number | Date;\n name: string | null;\n}\n\ntype TaskFn = ({ strapi }: { strapi: Core.Strapi }, ...args: unknown[]) => Promise<unknown>;\n\ntype Task =\n | TaskFn\n | {\n task: TaskFn;\n options: string;\n };\n\ninterface Tasks {\n [key: string]: Task;\n}\n\nconst createCronService = () => {\n let jobsSpecs: JobSpec[] = [];\n let running = false;\n\n return {\n add(tasks: Tasks = {}) {\n for (const taskExpression of Object.keys(tasks)) {\n const taskValue = tasks[taskExpression];\n\n let fn: TaskFn;\n let options: string | number | Date;\n let taskName: string | null;\n if (isFunction(taskValue)) {\n // don't use task name if key is the rule\n taskName = null;\n fn = taskValue.bind(tasks);\n options = taskExpression;\n } else if (isFunction(taskValue.task)) {\n // set task name if key is not the rule\n taskName = taskExpression;\n fn = taskValue.task.bind(taskValue);\n options = taskValue.options;\n } else {\n throw new Error(\n `Could not schedule a cron job for \"${taskExpression}\": no function found.`\n );\n }\n\n const fnWithStrapi = (...args: unknown[]) => fn({ strapi }, ...args);\n\n // const job = new Job(null, fnWithStrapi);\n const job = new Job(fnWithStrapi);\n jobsSpecs.push({ job, options, name: taskName });\n\n if (running) {\n job.schedule(options);\n }\n }\n return this;\n },\n\n remove(name: string) {\n if (!name) {\n throw new Error('You must provide a name to remove a cron job.');\n }\n\n jobsSpecs\n .filter(({ name: jobSpecName }) => jobSpecName === name)\n .forEach(({ job }) => job.cancel());\n\n jobsSpecs = jobsSpecs.filter(({ name: jobSpecName }) => jobSpecName !== name);\n return this;\n },\n\n start() {\n jobsSpecs.forEach(({ job, options }) => job.schedule(options));\n running = true;\n return this;\n },\n\n stop() {\n jobsSpecs.forEach(({ job }) => job.cancel());\n running = false;\n return this;\n },\n\n destroy() {\n this.stop();\n jobsSpecs = [];\n return this;\n },\n jobs: jobsSpecs,\n };\n};\n\nexport default createCronService;\n"],"names":["isFunction","Job"],"mappings":";;;AAuBA,MAAM,oBAAoB,MAAM;AAC9B,MAAI,YAAuB,CAAA;AAC3B,MAAI,UAAU;AAEP,SAAA;AAAA,IACL,IAAI,QAAe,IAAI;AACrB,iBAAW,kBAAkB,OAAO,KAAK,KAAK,GAAG;AACzC,cAAA,YAAY,MAAM,cAAc;AAElC,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAAA,GAAAA,WAAW,SAAS,GAAG;AAEd,qBAAA;AACN,eAAA,UAAU,KAAK,KAAK;AACf,oBAAA;AAAA,QACD,WAAAA,GAAA,WAAW,UAAU,IAAI,GAAG;AAE1B,qBAAA;AACN,eAAA,UAAU,KAAK,KAAK,SAAS;AAClC,oBAAU,UAAU;AAAA,QAAA,OACf;AACL,gBAAM,IAAI;AAAA,YACR,sCAAsC,cAAc;AAAA,UAAA;AAAA,QAExD;AAEM,cAAA,eAAe,IAAI,SAAoB,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI;AAG7D,cAAA,MAAM,IAAIC,iBAAI,YAAY;AAChC,kBAAU,KAAK,EAAE,KAAK,SAAS,MAAM,UAAU;AAE/C,YAAI,SAAS;AACX,cAAI,SAAS,OAAO;AAAA,QACtB;AAAA,MACF;AACO,aAAA;AAAA,IACT;AAAA,IAEA,OAAO,MAAc;AACnB,UAAI,CAAC,MAAM;AACH,cAAA,IAAI,MAAM,+CAA+C;AAAA,MACjE;AAEA,gBACG,OAAO,CAAC,EAAE,MAAM,YAAA,MAAkB,gBAAgB,IAAI,EACtD,QAAQ,CAAC,EAAE,IAAA,MAAU,IAAI,OAAQ,CAAA;AAExB,kBAAA,UAAU,OAAO,CAAC,EAAE,MAAM,YAAY,MAAM,gBAAgB,IAAI;AACrE,aAAA;AAAA,IACT;AAAA,IAEA,QAAQ;AACI,gBAAA,QAAQ,CAAC,EAAE,KAAK,QAAc,MAAA,IAAI,SAAS,OAAO,CAAC;AACnD,gBAAA;AACH,aAAA;AAAA,IACT;AAAA,IAEA,OAAO;AACL,gBAAU,QAAQ,CAAC,EAAE,IAAU,MAAA,IAAI,QAAQ;AACjC,gBAAA;AACH,aAAA;AAAA,IACT;AAAA,IAEA,UAAU;AACR,WAAK,KAAK;AACV,kBAAY,CAAA;AACL,aAAA;AAAA,IACT;AAAA,IACA,MAAM;AAAA,EAAA;AAEV;;"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const _ = require("lodash/fp");
3
+ const fp = require("lodash/fp");
4
4
  const transforms = require("./transforms.js");
5
- const applyTransforms = _.curry((schema, data) => {
5
+ const applyTransforms = fp.curry((schema, data) => {
6
6
  const attributeNames = Object.keys(data);
7
7
  for (const attributeName of attributeNames) {
8
8
  const value = data[attributeName];