@strapi/core 0.0.0-experimental.b74470bad5a933136da63d001641ca7d2e170f04 → 0.0.0-experimental.b7cfb5022f2343257445f9e7feb75c7465742c85

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.

Potentially problematic release.


This version of @strapi/core might be problematic. Click here for more details.

Files changed (211) hide show
  1. package/dist/Strapi.d.ts.map +1 -1
  2. package/dist/Strapi.js +4 -1
  3. package/dist/Strapi.js.map +1 -1
  4. package/dist/Strapi.mjs +4 -1
  5. package/dist/Strapi.mjs.map +1 -1
  6. package/dist/configuration/index.d.ts +1 -0
  7. package/dist/configuration/index.d.ts.map +1 -1
  8. package/dist/configuration/index.js +1 -0
  9. package/dist/configuration/index.js.map +1 -1
  10. package/dist/configuration/index.mjs +1 -0
  11. package/dist/configuration/index.mjs.map +1 -1
  12. package/dist/core-api/controller/index.d.ts.map +1 -1
  13. package/dist/core-api/controller/index.js +2 -1
  14. package/dist/core-api/controller/index.js.map +1 -1
  15. package/dist/core-api/controller/index.mjs +2 -1
  16. package/dist/core-api/controller/index.mjs.map +1 -1
  17. package/dist/core-api/controller/transform.d.ts +3 -2
  18. package/dist/core-api/controller/transform.d.ts.map +1 -1
  19. package/dist/core-api/controller/transform.js +13 -3
  20. package/dist/core-api/controller/transform.js.map +1 -1
  21. package/dist/core-api/controller/transform.mjs +13 -3
  22. package/dist/core-api/controller/transform.mjs.map +1 -1
  23. package/dist/core-api/routes/index.d.ts +4 -22
  24. package/dist/core-api/routes/index.d.ts.map +1 -1
  25. package/dist/core-api/routes/index.js +150 -8
  26. package/dist/core-api/routes/index.js.map +1 -1
  27. package/dist/core-api/routes/index.mjs +131 -8
  28. package/dist/core-api/routes/index.mjs.map +1 -1
  29. package/dist/core-api/routes/validation/attributes.d.ts +244 -0
  30. package/dist/core-api/routes/validation/attributes.d.ts.map +1 -0
  31. package/dist/core-api/routes/validation/attributes.js +560 -0
  32. package/dist/core-api/routes/validation/attributes.js.map +1 -0
  33. package/dist/core-api/routes/validation/attributes.mjs +521 -0
  34. package/dist/core-api/routes/validation/attributes.mjs.map +1 -0
  35. package/dist/core-api/routes/validation/common.d.ts +105 -0
  36. package/dist/core-api/routes/validation/common.d.ts.map +1 -0
  37. package/dist/core-api/routes/validation/common.js +116 -0
  38. package/dist/core-api/routes/validation/common.js.map +1 -0
  39. package/dist/core-api/routes/validation/common.mjs +95 -0
  40. package/dist/core-api/routes/validation/common.mjs.map +1 -0
  41. package/dist/core-api/routes/validation/component.d.ts +34 -0
  42. package/dist/core-api/routes/validation/component.d.ts.map +1 -0
  43. package/dist/core-api/routes/validation/component.js +45 -0
  44. package/dist/core-api/routes/validation/component.js.map +1 -0
  45. package/dist/core-api/routes/validation/component.mjs +43 -0
  46. package/dist/core-api/routes/validation/component.mjs.map +1 -0
  47. package/dist/core-api/routes/validation/constants.d.ts +8 -0
  48. package/dist/core-api/routes/validation/constants.d.ts.map +1 -0
  49. package/dist/core-api/routes/validation/constants.js +18 -0
  50. package/dist/core-api/routes/validation/constants.js.map +1 -0
  51. package/dist/core-api/routes/validation/constants.mjs +16 -0
  52. package/dist/core-api/routes/validation/constants.mjs.map +1 -0
  53. package/dist/core-api/routes/validation/content-type.d.ts +128 -0
  54. package/dist/core-api/routes/validation/content-type.d.ts.map +1 -0
  55. package/dist/core-api/routes/validation/content-type.js +201 -0
  56. package/dist/core-api/routes/validation/content-type.js.map +1 -0
  57. package/dist/core-api/routes/validation/content-type.mjs +180 -0
  58. package/dist/core-api/routes/validation/content-type.mjs.map +1 -0
  59. package/dist/core-api/routes/validation/index.d.ts +5 -0
  60. package/dist/core-api/routes/validation/index.d.ts.map +1 -0
  61. package/dist/core-api/routes/validation/mappers.d.ts +105 -0
  62. package/dist/core-api/routes/validation/mappers.d.ts.map +1 -0
  63. package/dist/core-api/routes/validation/mappers.js +238 -0
  64. package/dist/core-api/routes/validation/mappers.js.map +1 -0
  65. package/dist/core-api/routes/validation/mappers.mjs +214 -0
  66. package/dist/core-api/routes/validation/mappers.mjs.map +1 -0
  67. package/dist/core-api/routes/validation/utils.d.ts +47 -0
  68. package/dist/core-api/routes/validation/utils.d.ts.map +1 -0
  69. package/dist/core-api/routes/validation/utils.js +128 -0
  70. package/dist/core-api/routes/validation/utils.js.map +1 -0
  71. package/dist/core-api/routes/validation/utils.mjs +106 -0
  72. package/dist/core-api/routes/validation/utils.mjs.map +1 -0
  73. package/dist/domain/content-type/index.d.ts.map +1 -1
  74. package/dist/domain/content-type/index.js +17 -1
  75. package/dist/domain/content-type/index.js.map +1 -1
  76. package/dist/domain/content-type/index.mjs +17 -1
  77. package/dist/domain/content-type/index.mjs.map +1 -1
  78. package/dist/domain/module/index.d.ts.map +1 -1
  79. package/dist/domain/module/index.js +3 -0
  80. package/dist/domain/module/index.js.map +1 -1
  81. package/dist/domain/module/index.mjs +3 -0
  82. package/dist/domain/module/index.mjs.map +1 -1
  83. package/dist/ee/index.d.ts +6 -0
  84. package/dist/ee/index.d.ts.map +1 -1
  85. package/dist/ee/index.js +29 -3
  86. package/dist/ee/index.js.map +1 -1
  87. package/dist/ee/index.mjs +30 -4
  88. package/dist/ee/index.mjs.map +1 -1
  89. package/dist/ee/license.d.ts +3 -1
  90. package/dist/ee/license.d.ts.map +1 -1
  91. package/dist/ee/license.js +8 -2
  92. package/dist/ee/license.js.map +1 -1
  93. package/dist/ee/license.mjs +9 -4
  94. package/dist/ee/license.mjs.map +1 -1
  95. package/dist/factories.d.ts +3 -1
  96. package/dist/factories.d.ts.map +1 -1
  97. package/dist/factories.js +10 -2
  98. package/dist/factories.js.map +1 -1
  99. package/dist/factories.mjs +10 -3
  100. package/dist/factories.mjs.map +1 -1
  101. package/dist/index.js +1 -1
  102. package/dist/index.mjs +1 -1
  103. package/dist/middlewares/cors.d.ts +9 -1
  104. package/dist/middlewares/cors.d.ts.map +1 -1
  105. package/dist/middlewares/cors.js +39 -17
  106. package/dist/middlewares/cors.js.map +1 -1
  107. package/dist/middlewares/cors.mjs +39 -18
  108. package/dist/middlewares/cors.mjs.map +1 -1
  109. package/dist/migrations/first-published-at.d.ts +4 -0
  110. package/dist/migrations/first-published-at.d.ts.map +1 -0
  111. package/dist/migrations/first-published-at.js +51 -0
  112. package/dist/migrations/first-published-at.js.map +1 -0
  113. package/dist/migrations/first-published-at.mjs +49 -0
  114. package/dist/migrations/first-published-at.mjs.map +1 -0
  115. package/dist/migrations/index.d.ts.map +1 -1
  116. package/dist/migrations/index.js +5 -0
  117. package/dist/migrations/index.js.map +1 -1
  118. package/dist/migrations/index.mjs +5 -0
  119. package/dist/migrations/index.mjs.map +1 -1
  120. package/dist/package.json.js +18 -14
  121. package/dist/package.json.js.map +1 -1
  122. package/dist/package.json.mjs +18 -14
  123. package/dist/package.json.mjs.map +1 -1
  124. package/dist/services/content-api/index.d.ts +1 -1
  125. package/dist/services/content-api/index.d.ts.map +1 -1
  126. package/dist/services/content-api/index.js +1 -1
  127. package/dist/services/content-api/index.js.map +1 -1
  128. package/dist/services/content-api/index.mjs +2 -2
  129. package/dist/services/content-api/index.mjs.map +1 -1
  130. package/dist/services/content-source-maps.d.ts +12 -0
  131. package/dist/services/content-source-maps.d.ts.map +1 -0
  132. package/dist/services/content-source-maps.js +84 -0
  133. package/dist/services/content-source-maps.js.map +1 -0
  134. package/dist/services/content-source-maps.mjs +82 -0
  135. package/dist/services/content-source-maps.mjs.map +1 -0
  136. package/dist/services/core-store.d.ts +2 -2
  137. package/dist/services/core-store.d.ts.map +1 -1
  138. package/dist/services/core-store.js.map +1 -1
  139. package/dist/services/core-store.mjs.map +1 -1
  140. package/dist/services/document-service/entries.d.ts.map +1 -1
  141. package/dist/services/document-service/entries.js +42 -0
  142. package/dist/services/document-service/entries.js.map +1 -1
  143. package/dist/services/document-service/entries.mjs +43 -1
  144. package/dist/services/document-service/entries.mjs.map +1 -1
  145. package/dist/services/document-service/first-published-at.d.ts +7 -0
  146. package/dist/services/document-service/first-published-at.d.ts.map +1 -0
  147. package/dist/services/document-service/first-published-at.js +31 -0
  148. package/dist/services/document-service/first-published-at.js.map +1 -0
  149. package/dist/services/document-service/first-published-at.mjs +28 -0
  150. package/dist/services/document-service/first-published-at.mjs.map +1 -0
  151. package/dist/services/document-service/internationalization.d.ts +6 -1
  152. package/dist/services/document-service/internationalization.d.ts.map +1 -1
  153. package/dist/services/document-service/internationalization.js +32 -0
  154. package/dist/services/document-service/internationalization.js.map +1 -1
  155. package/dist/services/document-service/internationalization.mjs +32 -1
  156. package/dist/services/document-service/internationalization.mjs.map +1 -1
  157. package/dist/services/document-service/repository.d.ts.map +1 -1
  158. package/dist/services/document-service/repository.js +12 -8
  159. package/dist/services/document-service/repository.js.map +1 -1
  160. package/dist/services/document-service/repository.mjs +13 -9
  161. package/dist/services/document-service/repository.mjs.map +1 -1
  162. package/dist/services/entity-validator/index.d.ts.map +1 -1
  163. package/dist/services/entity-validator/index.js +9 -0
  164. package/dist/services/entity-validator/index.js.map +1 -1
  165. package/dist/services/entity-validator/index.mjs +9 -0
  166. package/dist/services/entity-validator/index.mjs.map +1 -1
  167. package/dist/services/entity-validator/validators.d.ts +1 -0
  168. package/dist/services/entity-validator/validators.d.ts.map +1 -1
  169. package/dist/services/entity-validator/validators.js +3 -0
  170. package/dist/services/entity-validator/validators.js.map +1 -1
  171. package/dist/services/entity-validator/validators.mjs +3 -0
  172. package/dist/services/entity-validator/validators.mjs.map +1 -1
  173. package/dist/services/metrics/admin-user-hash.d.ts.map +1 -1
  174. package/dist/services/metrics/admin-user-hash.js.map +1 -1
  175. package/dist/services/metrics/admin-user-hash.mjs.map +1 -1
  176. package/dist/services/metrics/index.d.ts +1 -1
  177. package/dist/services/metrics/index.d.ts.map +1 -1
  178. package/dist/services/metrics/index.js +9 -8
  179. package/dist/services/metrics/index.js.map +1 -1
  180. package/dist/services/metrics/index.mjs +9 -8
  181. package/dist/services/metrics/index.mjs.map +1 -1
  182. package/dist/services/metrics/sender.d.ts.map +1 -1
  183. package/dist/services/metrics/sender.js +5 -5
  184. package/dist/services/metrics/sender.js.map +1 -1
  185. package/dist/services/metrics/sender.mjs +6 -6
  186. package/dist/services/metrics/sender.mjs.map +1 -1
  187. package/dist/services/server/register-routes.js +22 -2
  188. package/dist/services/server/register-routes.js.map +1 -1
  189. package/dist/services/server/register-routes.mjs +22 -2
  190. package/dist/services/server/register-routes.mjs.map +1 -1
  191. package/dist/services/server/routing.d.ts +10 -0
  192. package/dist/services/server/routing.d.ts.map +1 -1
  193. package/dist/services/server/routing.js +7 -1
  194. package/dist/services/server/routing.js.map +1 -1
  195. package/dist/services/server/routing.mjs +7 -1
  196. package/dist/services/server/routing.mjs.map +1 -1
  197. package/dist/services/utils/conditional-fields.d.ts +3 -0
  198. package/dist/services/utils/conditional-fields.d.ts.map +1 -0
  199. package/dist/services/utils/conditional-fields.js +22 -0
  200. package/dist/services/utils/conditional-fields.js.map +1 -0
  201. package/dist/services/utils/conditional-fields.mjs +20 -0
  202. package/dist/services/utils/conditional-fields.mjs.map +1 -0
  203. package/dist/utils/fetch.d.ts +5 -1
  204. package/dist/utils/fetch.d.ts.map +1 -1
  205. package/dist/utils/fetch.js +8 -4
  206. package/dist/utils/fetch.js.map +1 -1
  207. package/dist/utils/fetch.mjs +8 -4
  208. package/dist/utils/fetch.mjs.map +1 -1
  209. package/dist/utils/transform-content-types-to-models.d.ts +197 -0
  210. package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
  211. package/package.json +18 -14
@@ -1 +1 @@
1
- {"version":3,"file":"routing.mjs","sources":["../../../src/services/server/routing.ts"],"sourcesContent":["import Router from '@koa/router';\nimport { has } from 'lodash/fp';\nimport { yup } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nimport createEndpointComposer from './compose-endpoint';\n\nconst policyOrMiddlewareSchema = yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (typeof value === 'function') {\n return yup.mixed().isFunction();\n }\n\n return yup.object({\n name: yup.string().required(),\n options: yup.object().notRequired(), // any options\n });\n});\n\nconst routeSchema = yup.object({\n method: yup.string().oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL']).required(),\n path: yup.string().required(),\n handler: yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (Array.isArray(value)) {\n return yup.array().required();\n }\n\n return yup.mixed().isFunction().required();\n }),\n config: yup\n .object({\n auth: yup.lazy((value) => {\n if (value === false) {\n return yup.boolean().required();\n }\n\n return yup.object({\n scope: yup.array().of(yup.string()).required(),\n });\n }),\n policies: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n middlewares: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n })\n .notRequired(),\n});\n\nconst validateRouteConfig = (routeConfig: Core.RouteInput) => {\n try {\n return routeSchema.validateSync(routeConfig, {\n strict: true,\n abortEarly: false,\n stripUnknown: true,\n });\n } catch (error) {\n if (error instanceof yup.ValidationError) {\n throw new Error(`Invalid route config ${error.message}`);\n }\n }\n};\n\nconst createRouteManager = (strapi: Core.Strapi, opts: { type?: string } = {}) => {\n const { type } = opts;\n\n const composeEndpoint = createEndpointComposer(strapi);\n\n const createRoute = (route: Core.RouteInput, router: Router) => {\n validateRouteConfig(route);\n\n // NOTE: the router type is used to tag controller actions and for authentication / authorization so we need to pass this info down to the route level\n const routeWithInfo = Object.assign(route, {\n info: {\n ...(route.info ?? {}),\n type: type || 'api',\n },\n });\n\n composeEndpoint(routeWithInfo, { router });\n };\n\n const addRoutes = (routes: Core.Router | Core.RouteInput[], router: Router) => {\n if (Array.isArray(routes)) {\n routes.forEach((route) => createRoute(route, router));\n } else if (routes.routes) {\n const subRouter = new Router({ prefix: routes.prefix });\n\n routes.routes.forEach((route) => {\n const hasPrefix = has('prefix', route.config);\n createRoute(route, hasPrefix ? router : subRouter);\n });\n\n return router.use(subRouter.routes(), subRouter.allowedMethods());\n }\n };\n\n return {\n addRoutes,\n };\n};\n\nexport { validateRouteConfig, createRouteManager };\n"],"names":["policyOrMiddlewareSchema","yup","lazy","value","string","required","mixed","isFunction","object","name","options","notRequired","routeSchema","method","oneOf","path","handler","Array","isArray","array","config","auth","boolean","scope","of","policies","middlewares","validateRouteConfig","routeConfig","validateSync","strict","abortEarly","stripUnknown","error","ValidationError","Error","message","createRouteManager","strapi","opts","type","composeEndpoint","createEndpointComposer","createRoute","route","router","routeWithInfo","Object","assign","info","addRoutes","routes","forEach","subRouter","Router","prefix","hasPrefix","has","use","allowedMethods"],"mappings":";;;;;AAOA,MAAMA,wBAA2BC,GAAAA,GAAAA,CAAIC,IAAI,CAAC,CAACC,KAAAA,GAAAA;IACzC,IAAI,OAAOA,UAAU,QAAU,EAAA;QAC7B,OAAOF,GAAAA,CAAIG,MAAM,EAAA,CAAGC,QAAQ,EAAA;AAC9B;IAEA,IAAI,OAAOF,UAAU,UAAY,EAAA;QAC/B,OAAOF,GAAAA,CAAIK,KAAK,EAAA,CAAGC,UAAU,EAAA;AAC/B;IAEA,OAAON,GAAAA,CAAIO,MAAM,CAAC;QAChBC,IAAMR,EAAAA,GAAAA,CAAIG,MAAM,EAAA,CAAGC,QAAQ,EAAA;QAC3BK,OAAST,EAAAA,GAAAA,CAAIO,MAAM,EAAA,CAAGG,WAAW;AACnC,KAAA,CAAA;AACF,CAAA,CAAA;AAEA,MAAMC,WAAAA,GAAcX,GAAIO,CAAAA,MAAM,CAAC;AAC7BK,IAAAA,MAAAA,EAAQZ,GAAIG,CAAAA,MAAM,EAAGU,CAAAA,KAAK,CAAC;AAAC,QAAA,KAAA;AAAO,QAAA,MAAA;AAAQ,QAAA,KAAA;AAAO,QAAA,OAAA;AAAS,QAAA,QAAA;AAAU,QAAA;AAAM,KAAA,CAAA,CAAET,QAAQ,EAAA;IACrFU,IAAMd,EAAAA,GAAAA,CAAIG,MAAM,EAAA,CAAGC,QAAQ,EAAA;IAC3BW,OAASf,EAAAA,GAAAA,CAAIC,IAAI,CAAC,CAACC,K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AAA,CAAMxB,MAAM,CAAA;gBAC5CuB,WAAYC,CAAAA,KAAAA,EAAOY,YAAYX,MAASQ,GAAAA,SAAAA,CAAAA;AAC1C,aAAA,CAAA;AAEA,YAAA,OAAOR,OAAOa,GAAG,CAACL,UAAUF,MAAM,EAAA,EAAIE,UAAUM,cAAc,EAAA,CAAA;AAChE;AACF,KAAA;IAEA,OAAO;AACLT,QAAAA;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"routing.mjs","sources":["../../../src/services/server/routing.ts"],"sourcesContent":["import Router from '@koa/router';\nimport { has } from 'lodash/fp';\nimport { yup } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nimport createEndpointComposer from './compose-endpoint';\n\nconst policyOrMiddlewareSchema = yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (typeof value === 'function') {\n return yup.mixed().isFunction();\n }\n\n return yup.object({\n name: yup.string().required(),\n options: yup.object().notRequired(), // any options\n });\n});\n\nconst routeSchema = yup.object({\n method: yup.string().oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL']).required(),\n path: yup.string().required(),\n handler: yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (Array.isArray(value)) {\n return yup.array().required();\n }\n\n return yup.mixed().isFunction().required();\n }),\n request: yup\n .object({\n params: yup.object().notRequired(),\n query: yup.object().notRequired(),\n body: yup.object().notRequired(),\n })\n .notRequired(),\n response: yup.object().notRequired(),\n config: yup\n .object({\n auth: yup.lazy((value) => {\n if (value === false) {\n return yup.boolean().required();\n }\n\n return yup.object({\n scope: yup.array().of(yup.string()).required(),\n });\n }),\n policies: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n middlewares: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n })\n .notRequired(),\n});\n\nconst validateRouteConfig = (routeConfig: Core.RouteInput) => {\n try {\n return routeSchema.validateSync(routeConfig, {\n strict: true,\n abortEarly: false,\n stripUnknown: true,\n });\n } catch (error) {\n if (error instanceof yup.ValidationError) {\n throw new Error(`Invalid route config ${error.message}`);\n }\n }\n};\n\nconst createRouteManager = (strapi: Core.Strapi, opts: { type?: string } = {}) => {\n const { type } = opts;\n\n const composeEndpoint = createEndpointComposer(strapi);\n\n const createRoute = (route: Core.RouteInput, router: Router) => {\n validateRouteConfig(route);\n\n // NOTE: the router type is used to tag controller actions and for authentication / authorization so we need to pass this info down to the route level\n const routeWithInfo = Object.assign(route, {\n info: {\n ...(route.info ?? {}),\n type: type ?? 'api',\n },\n });\n\n composeEndpoint(routeWithInfo, { router });\n };\n\n const addRoutes = (routes: Core.Router | Core.RouteInput[], router: Router) => {\n if (Array.isArray(routes)) {\n routes.forEach((route) => createRoute(route, router));\n } else if (routes.routes) {\n const subRouter = new Router({ prefix: routes.prefix });\n\n routes.routes.forEach((route) => {\n const hasPrefix = has('prefix', route.config);\n createRoute(route, hasPrefix ? router : subRouter);\n });\n\n return router.use(subRouter.routes(), subRouter.allowedMethods());\n }\n };\n\n return {\n addRoutes,\n };\n};\n\nexport { validateRouteConfig, createRouteManager };\n"],"names":["policyOrMiddlewareSchema","yup","lazy","value","string","required","mixed","isFunction","object","name","options","notRequired","routeSchema","method","oneOf","path","handler","Array","isArray","array","request","params","query","body","response","config","auth","boolean","scope","of","policies","middlewares","validateRouteConfig","routeConfig","validateSync","strict","abortEarly","stripUnknown","error","ValidationError","Error","message","createRouteManager","strapi","opts","type","composeEndpoint","createEndpointComposer","createRoute","route","router","routeWithInfo","Object","assign","info","addRoutes","routes","forEach","subRouter","Router","prefix","hasPrefix","has","use","allowedMethods"],"mappings":";;;;;AAOA,MAAMA,wBAA2BC,GAAAA,GAAAA,CAAIC,IAAI,CAAC,CAACC,KAAAA,GAAAA;IACzC,IAAI,OAAOA,UAAU,QAAU,EAAA;QAC7B,OAAOF,GAAAA,CAAIG,MAAM,EAAA,CAAGC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GAAG,CAACL,UAAUF,MAAM,EAAA,EAAIE,UAAUM,cAAc,EAAA,CAAA;AAChE;AACF,KAAA;IAEA,OAAO;AACLT,QAAAA;AACF,KAAA;AACF;;;;"}
@@ -0,0 +1,3 @@
1
+ declare const getNumberOfConditionalFields: () => any;
2
+ export default getNumberOfConditionalFields;
3
+ //# sourceMappingURL=conditional-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditional-fields.d.ts","sourceRoot":"","sources":["../../../src/services/utils/conditional-fields.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,4BAA4B,WAuBjC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var fp = require('lodash/fp');
4
+
5
+ const getNumberOfConditionalFields = ()=>{
6
+ const contentTypes = strapi.contentTypes;
7
+ const components = strapi.components;
8
+ const countConditionalFieldsInSchema = (schema)=>{
9
+ return fp.pipe(fp.map('attributes'), fp.flatMap(fp.values), fp.sumBy((attribute)=>{
10
+ if (attribute.conditions && typeof attribute.conditions === 'object') {
11
+ return 1;
12
+ }
13
+ return 0;
14
+ }))(schema);
15
+ };
16
+ const contentTypeCount = countConditionalFieldsInSchema(contentTypes);
17
+ const componentCount = countConditionalFieldsInSchema(components);
18
+ return contentTypeCount + componentCount;
19
+ };
20
+
21
+ module.exports = getNumberOfConditionalFields;
22
+ //# sourceMappingURL=conditional-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditional-fields.js","sources":["../../../src/services/utils/conditional-fields.ts"],"sourcesContent":["import { map, values, sumBy, pipe, flatMap } from 'lodash/fp';\nimport type { Schema, UID } from '@strapi/types';\n\nconst getNumberOfConditionalFields = () => {\n const contentTypes: Record<UID.ContentType, Schema.ContentType> = strapi.contentTypes;\n const components: Record<UID.Component, Schema.Component> = strapi.components;\n\n const countConditionalFieldsInSchema = (\n schema: Record<string, Schema.ContentType | Schema.Component>\n ) => {\n return pipe(\n map('attributes'),\n flatMap(values),\n sumBy((attribute: Schema.Attribute.AnyAttribute) => {\n if (attribute.conditions && typeof attribute.conditions === 'object') {\n return 1;\n }\n return 0;\n })\n )(schema);\n };\n\n const contentTypeCount = countConditionalFieldsInSchema(contentTypes);\n const componentCount = countConditionalFieldsInSchema(components);\n\n return contentTypeCount + componentCount;\n};\n\nexport default getNumberOfConditionalFields;\n"],"names":["getNumberOfConditionalFields","contentTypes","strapi","components","countConditionalFieldsInSchema","schema","pipe","map","flatMap","values","sumBy","attribute","conditions","contentTypeCount","componentCount"],"mappings":";;;;AAGA,MAAMA,4BAA+B,GAAA,IAAA;IACnC,MAAMC,YAAAA,GAA4DC,OAAOD,YAAY;IACrF,MAAME,UAAAA,GAAsDD,OAAOC,UAAU;AAE7E,IAAA,MAAMC,iCAAiC,CACrCC,MAAAA,GAAAA;AAEA,QAAA,OAAOC,QACLC,MAAI,CAAA,YAAA,CAAA,EACJC,UAAQC,CAAAA,SAAAA,CAAAA,EACRC,SAAM,CAACC,SAAAA,GAAAA;AACL,YAAA,IAAIA,UAAUC,UAAU,IAAI,OAAOD,SAAUC,CAAAA,UAAU,KAAK,QAAU,EAAA;gBACpE,OAAO,CAAA;AACT;YACA,OAAO,CAAA;SAETP,CAAAA,CAAAA,CAAAA,MAAAA,CAAAA;AACJ,KAAA;AAEA,IAAA,MAAMQ,mBAAmBT,8BAA+BH,CAAAA,YAAAA,CAAAA;AACxD,IAAA,MAAMa,iBAAiBV,8BAA+BD,CAAAA,UAAAA,CAAAA;AAEtD,IAAA,OAAOU,gBAAmBC,GAAAA,cAAAA;AAC5B;;;;"}
@@ -0,0 +1,20 @@
1
+ import { pipe, map, flatMap, values, sumBy } from 'lodash/fp';
2
+
3
+ const getNumberOfConditionalFields = ()=>{
4
+ const contentTypes = strapi.contentTypes;
5
+ const components = strapi.components;
6
+ const countConditionalFieldsInSchema = (schema)=>{
7
+ return pipe(map('attributes'), flatMap(values), sumBy((attribute)=>{
8
+ if (attribute.conditions && typeof attribute.conditions === 'object') {
9
+ return 1;
10
+ }
11
+ return 0;
12
+ }))(schema);
13
+ };
14
+ const contentTypeCount = countConditionalFieldsInSchema(contentTypes);
15
+ const componentCount = countConditionalFieldsInSchema(components);
16
+ return contentTypeCount + componentCount;
17
+ };
18
+
19
+ export { getNumberOfConditionalFields as default };
20
+ //# sourceMappingURL=conditional-fields.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditional-fields.mjs","sources":["../../../src/services/utils/conditional-fields.ts"],"sourcesContent":["import { map, values, sumBy, pipe, flatMap } from 'lodash/fp';\nimport type { Schema, UID } from '@strapi/types';\n\nconst getNumberOfConditionalFields = () => {\n const contentTypes: Record<UID.ContentType, Schema.ContentType> = strapi.contentTypes;\n const components: Record<UID.Component, Schema.Component> = strapi.components;\n\n const countConditionalFieldsInSchema = (\n schema: Record<string, Schema.ContentType | Schema.Component>\n ) => {\n return pipe(\n map('attributes'),\n flatMap(values),\n sumBy((attribute: Schema.Attribute.AnyAttribute) => {\n if (attribute.conditions && typeof attribute.conditions === 'object') {\n return 1;\n }\n return 0;\n })\n )(schema);\n };\n\n const contentTypeCount = countConditionalFieldsInSchema(contentTypes);\n const componentCount = countConditionalFieldsInSchema(components);\n\n return contentTypeCount + componentCount;\n};\n\nexport default getNumberOfConditionalFields;\n"],"names":["getNumberOfConditionalFields","contentTypes","strapi","components","countConditionalFieldsInSchema","schema","pipe","map","flatMap","values","sumBy","attribute","conditions","contentTypeCount","componentCount"],"mappings":";;AAGA,MAAMA,4BAA+B,GAAA,IAAA;IACnC,MAAMC,YAAAA,GAA4DC,OAAOD,YAAY;IACrF,MAAME,UAAAA,GAAsDD,OAAOC,UAAU;AAE7E,IAAA,MAAMC,iCAAiC,CACrCC,MAAAA,GAAAA;AAEA,QAAA,OAAOC,KACLC,GAAI,CAAA,YAAA,CAAA,EACJC,OAAQC,CAAAA,MAAAA,CAAAA,EACRC,MAAM,CAACC,SAAAA,GAAAA;AACL,YAAA,IAAIA,UAAUC,UAAU,IAAI,OAAOD,SAAUC,CAAAA,UAAU,KAAK,QAAU,EAAA;gBACpE,OAAO,CAAA;AACT;YACA,OAAO,CAAA;SAETP,CAAAA,CAAAA,CAAAA,MAAAA,CAAAA;AACJ,KAAA;AAEA,IAAA,MAAMQ,mBAAmBT,8BAA+BH,CAAAA,YAAAA,CAAAA;AACxD,IAAA,MAAMa,iBAAiBV,8BAA+BD,CAAAA,UAAAA,CAAAA;AAEtD,IAAA,OAAOU,gBAAmBC,GAAAA,cAAAA;AAC5B;;;;"}
@@ -1,4 +1,8 @@
1
1
  import type { Core, Modules } from '@strapi/types';
2
- export declare const createStrapiFetch: (strapi: Core.Strapi) => Modules.Fetch.Fetch;
2
+ interface StrapiFetchOptions {
3
+ logs?: boolean;
4
+ }
5
+ export declare const createStrapiFetch: (strapi: Core.Strapi, options?: StrapiFetchOptions) => Modules.Fetch.Fetch;
3
6
  export type Fetch = Modules.Fetch.Fetch;
7
+ export {};
4
8
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/utils/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAMnD,eAAO,MAAM,iBAAiB,WAAY,KAAK,MAAM,KAAG,aAAa,MAoBpE,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/utils/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAKnD,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,eAAO,MAAM,iBAAiB,WACpB,KAAK,MAAM,YACT,kBAAkB,KAC3B,aAAa,MA4Bf,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC"}
@@ -2,9 +2,9 @@
2
2
 
3
3
  var undici = require('undici');
4
4
 
5
- // TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici
6
5
  // Create a wrapper for Node's Fetch API that applies a global proxy
7
- const createStrapiFetch = (strapi)=>{
6
+ const createStrapiFetch = (strapi, options)=>{
7
+ const { logs = true } = options ?? {};
8
8
  function strapiFetch(url, options) {
9
9
  const fetchOptions = {
10
10
  ...strapiFetch.dispatcher ? {
@@ -12,12 +12,16 @@ const createStrapiFetch = (strapi)=>{
12
12
  } : {},
13
13
  ...options
14
14
  };
15
- strapi.log.debug(`Making request for ${url}`);
15
+ if (logs) {
16
+ strapi.log.debug(`Making request for ${url}`);
17
+ }
16
18
  return fetch(url, fetchOptions);
17
19
  }
18
20
  const proxy = strapi.config.get('server.proxy.fetch') || strapi.config.get('server.proxy.global');
19
21
  if (proxy) {
20
- strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);
22
+ if (logs) {
23
+ strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);
24
+ }
21
25
  strapiFetch.dispatcher = new undici.ProxyAgent(proxy);
22
26
  }
23
27
  return strapiFetch;
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (strapi: Core.Strapi): Modules.Fetch.Fetch => {\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n strapi.log.debug(`Making request for ${url}`);\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","strapiFetch","url","options","fetchOptions","dispatcher","log","debug","fetch","proxy","config","get","info","ProxyAgent"],"mappings":";;;;AAGA;AAEA;AACO,MAAMA,oBAAoB,CAACC,MAAAA,GAAAA;IAChC,SAASC,WAAAA,CAAYC,GAAsB,EAAEC,OAAqB,EAAA;AAChE,QAAA,MAAMC,YAAe,GAAA;YACnB,GAAIH,WAAAA,CAAYI,UAAU,GAAG;AAAEA,gBAAAA,UAAAA,EAAYJ,YAAYI;AAAW,aAAA,GAAI,EAAE;AACxE,YAAA,GAAGF;AACL,SAAA;QACAH,MAAOM,CAAAA,GAAG,CAACC,KAAK,CAAC,CAAC,mBAAmB,EAAEL,IAAI,CAAC,CAAA;AAC5C,QAAA,OAAOM,MAAMN,GAAKE,EAAAA,YAAAA,CAAAA;AACpB;IAEA,MAAMK,KAAAA,GACJT,MAAOU,CAAAA,MAAM,CAACC,GAAG,CAA8C,oBAAA,CAAA,IAC/DX,MAAOU,CAAAA,MAAM,CAACC,GAAG,CAAS,qBAAA,CAAA;AAE5B,IAAA,IAAIF,KAAO,EAAA;QACTT,MAAOM,CAAAA,GAAG,CAACM,IAAI,CAAC,CAAC,gCAAgC,EAAEH,MAAM,CAAC,CAAA;QAC1DR,WAAYI,CAAAA,UAAU,GAAG,IAAIQ,iBAAWJ,CAAAA,KAAAA,CAAAA;AAC1C;IAEA,OAAOR,WAAAA;AACT;;;;"}
1
+ {"version":3,"file":"fetch.js","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\ninterface StrapiFetchOptions {\n logs?: boolean;\n}\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (\n strapi: Core.Strapi,\n options?: StrapiFetchOptions\n): Modules.Fetch.Fetch => {\n const { logs = true } = options ?? {};\n\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n\n if (logs) {\n strapi.log.debug(`Making request for ${url}`);\n }\n\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n if (logs) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n }\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","options","logs","strapiFetch","url","fetchOptions","dispatcher","log","debug","fetch","proxy","config","get","info","ProxyAgent"],"mappings":";;;;AASA;AACO,MAAMA,iBAAoB,GAAA,CAC/BC,MACAC,EAAAA,OAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,IAAO,GAAA,IAAI,EAAE,GAAGD,WAAW,EAAC;IAEpC,SAASE,WAAAA,CAAYC,GAAsB,EAAEH,OAAqB,EAAA;AAChE,QAAA,MAAMI,YAAe,GAAA;YACnB,GAAIF,WAAAA,CAAYG,UAAU,GAAG;AAAEA,gBAAAA,UAAAA,EAAYH,YAAYG;AAAW,aAAA,GAAI,EAAE;AACxE,YAAA,GAAGL;AACL,SAAA;AAEA,QAAA,IAAIC,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACC,KAAK,CAAC,CAAC,mBAAmB,EAAEJ,IAAI,CAAC,CAAA;AAC9C;AAEA,QAAA,OAAOK,MAAML,GAAKC,EAAAA,YAAAA,CAAAA;AACpB;IAEA,MAAMK,KAAAA,GACJV,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAA8C,oBAAA,CAAA,IAC/DZ,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAAS,qBAAA,CAAA;AAE5B,IAAA,IAAIF,KAAO,EAAA;AACT,QAAA,IAAIR,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACM,IAAI,CAAC,CAAC,gCAAgC,EAAEH,MAAM,CAAC,CAAA;AAC5D;QACAP,WAAYG,CAAAA,UAAU,GAAG,IAAIQ,iBAAWJ,CAAAA,KAAAA,CAAAA;AAC1C;IAEA,OAAOP,WAAAA;AACT;;;;"}
@@ -1,8 +1,8 @@
1
1
  import { ProxyAgent } from 'undici';
2
2
 
3
- // TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici
4
3
  // Create a wrapper for Node's Fetch API that applies a global proxy
5
- const createStrapiFetch = (strapi)=>{
4
+ const createStrapiFetch = (strapi, options)=>{
5
+ const { logs = true } = options ?? {};
6
6
  function strapiFetch(url, options) {
7
7
  const fetchOptions = {
8
8
  ...strapiFetch.dispatcher ? {
@@ -10,12 +10,16 @@ const createStrapiFetch = (strapi)=>{
10
10
  } : {},
11
11
  ...options
12
12
  };
13
- strapi.log.debug(`Making request for ${url}`);
13
+ if (logs) {
14
+ strapi.log.debug(`Making request for ${url}`);
15
+ }
14
16
  return fetch(url, fetchOptions);
15
17
  }
16
18
  const proxy = strapi.config.get('server.proxy.fetch') || strapi.config.get('server.proxy.global');
17
19
  if (proxy) {
18
- strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);
20
+ if (logs) {
21
+ strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);
22
+ }
19
23
  strapiFetch.dispatcher = new ProxyAgent(proxy);
20
24
  }
21
25
  return strapiFetch;
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.mjs","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (strapi: Core.Strapi): Modules.Fetch.Fetch => {\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n strapi.log.debug(`Making request for ${url}`);\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","strapiFetch","url","options","fetchOptions","dispatcher","log","debug","fetch","proxy","config","get","info","ProxyAgent"],"mappings":";;AAGA;AAEA;AACO,MAAMA,oBAAoB,CAACC,MAAAA,GAAAA;IAChC,SAASC,WAAAA,CAAYC,GAAsB,EAAEC,OAAqB,EAAA;AAChE,QAAA,MAAMC,YAAe,GAAA;YACnB,GAAIH,WAAAA,CAAYI,UAAU,GAAG;AAAEA,gBAAAA,UAAAA,EAAYJ,YAAYI;AAAW,aAAA,GAAI,EAAE;AACxE,YAAA,GAAGF;AACL,SAAA;QACAH,MAAOM,CAAAA,GAAG,CAACC,KAAK,CAAC,CAAC,mBAAmB,EAAEL,IAAI,CAAC,CAAA;AAC5C,QAAA,OAAOM,MAAMN,GAAKE,EAAAA,YAAAA,CAAAA;AACpB;IAEA,MAAMK,KAAAA,GACJT,MAAOU,CAAAA,MAAM,CAACC,GAAG,CAA8C,oBAAA,CAAA,IAC/DX,MAAOU,CAAAA,MAAM,CAACC,GAAG,CAAS,qBAAA,CAAA;AAE5B,IAAA,IAAIF,KAAO,EAAA;QACTT,MAAOM,CAAAA,GAAG,CAACM,IAAI,CAAC,CAAC,gCAAgC,EAAEH,MAAM,CAAC,CAAA;QAC1DR,WAAYI,CAAAA,UAAU,GAAG,IAAIQ,UAAWJ,CAAAA,KAAAA,CAAAA;AAC1C;IAEA,OAAOR,WAAAA;AACT;;;;"}
1
+ {"version":3,"file":"fetch.mjs","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\ninterface StrapiFetchOptions {\n logs?: boolean;\n}\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (\n strapi: Core.Strapi,\n options?: StrapiFetchOptions\n): Modules.Fetch.Fetch => {\n const { logs = true } = options ?? {};\n\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n\n if (logs) {\n strapi.log.debug(`Making request for ${url}`);\n }\n\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n if (logs) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n }\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","options","logs","strapiFetch","url","fetchOptions","dispatcher","log","debug","fetch","proxy","config","get","info","ProxyAgent"],"mappings":";;AASA;AACO,MAAMA,iBAAoB,GAAA,CAC/BC,MACAC,EAAAA,OAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,IAAO,GAAA,IAAI,EAAE,GAAGD,WAAW,EAAC;IAEpC,SAASE,WAAAA,CAAYC,GAAsB,EAAEH,OAAqB,EAAA;AAChE,QAAA,MAAMI,YAAe,GAAA;YACnB,GAAIF,WAAAA,CAAYG,UAAU,GAAG;AAAEA,gBAAAA,UAAAA,EAAYH,YAAYG;AAAW,aAAA,GAAI,EAAE;AACxE,YAAA,GAAGL;AACL,SAAA;AAEA,QAAA,IAAIC,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACC,KAAK,CAAC,CAAC,mBAAmB,EAAEJ,IAAI,CAAC,CAAA;AAC9C;AAEA,QAAA,OAAOK,MAAML,GAAKC,EAAAA,YAAAA,CAAAA;AACpB;IAEA,MAAMK,KAAAA,GACJV,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAA8C,oBAAA,CAAA,IAC/DZ,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAAS,qBAAA,CAAA;AAE5B,IAAA,IAAIF,KAAO,EAAA;AACT,QAAA,IAAIR,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACM,IAAI,CAAC,CAAC,gCAAgC,EAAEH,MAAM,CAAC,CAAA;AAC5D;QACAP,WAAYG,CAAAA,UAAU,GAAG,IAAIQ,UAAWJ,CAAAA,KAAAA,CAAAA;AAC1C;IAEA,OAAOP,WAAAA;AACT;;;;"}