@webiny/api-core 6.6.0-alpha.0 → 6.6.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/ApiCoreFeature.js +6 -0
  2. package/ApiCoreFeature.js.map +1 -1
  3. package/exports/api/security/api-key.d.ts +1 -0
  4. package/exports/api/security/api-key.js +1 -0
  5. package/features/ai/Ai.d.ts +3 -1
  6. package/features/ai/Ai.js +39 -4
  7. package/features/ai/Ai.js.map +1 -1
  8. package/features/ai/AnthropicSdkFactory.js +12 -0
  9. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  10. package/features/ai/OpenAiSdkFactory.js +16 -0
  11. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  12. package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
  13. package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
  14. package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
  15. package/features/ai/TextExtractor/abstractions.d.ts +12 -0
  16. package/features/ai/TextExtractor/abstractions.js +5 -0
  17. package/features/ai/TextExtractor/abstractions.js.map +1 -0
  18. package/features/ai/TextExtractor/index.d.ts +3 -0
  19. package/features/ai/TextExtractor/index.js +2 -0
  20. package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
  21. package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
  22. package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
  23. package/features/ai/abstractions.d.ts +19 -0
  24. package/features/ai/abstractions.js.map +1 -1
  25. package/features/ai/events.d.ts +59 -0
  26. package/features/ai/events.js +41 -0
  27. package/features/ai/events.js.map +1 -0
  28. package/features/ai/feature.js +2 -0
  29. package/features/ai/feature.js.map +1 -1
  30. package/features/ai/index.d.ts +5 -1
  31. package/features/ai/index.js +2 -0
  32. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  33. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  34. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  35. package/features/dateFormatter/abstractions.d.ts +13 -0
  36. package/features/dateFormatter/abstractions.js +5 -0
  37. package/features/dateFormatter/abstractions.js.map +1 -0
  38. package/features/dateFormatter/feature.d.ts +4 -0
  39. package/features/dateFormatter/feature.js +11 -0
  40. package/features/dateFormatter/feature.js.map +1 -0
  41. package/features/dateFormatter/index.d.ts +3 -0
  42. package/features/dateFormatter/index.js +2 -0
  43. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  44. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +49 -0
  45. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  46. package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
  47. package/features/security/IdentityContext/IdentityContext.js +6 -6
  48. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  49. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  50. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  51. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
  52. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
  53. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
  54. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
  55. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
  56. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
  57. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
  58. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
  59. package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
  60. package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
  61. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  62. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  63. package/features/security/apiKeys/feature.js +7 -2
  64. package/features/security/apiKeys/feature.js.map +1 -1
  65. package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
  66. package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
  67. package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
  68. package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
  69. package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
  70. package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
  71. package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
  72. package/features/security/apiKeys/shared/generateToken.js.map +1 -1
  73. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  74. package/features/security/apiKeys/shared/schemas.js +2 -2
  75. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  76. package/features/security/apiKeys/shared/types.d.ts +1 -1
  77. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  78. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  79. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  80. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  81. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  82. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  83. package/features/security/roles/CreateRole/schema.js +1 -1
  84. package/features/security/roles/CreateRole/schema.js.map +1 -1
  85. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  86. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  87. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  88. package/features/security/roles/UpdateRole/schema.js +1 -1
  89. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  90. package/features/security/shared/description.d.ts +4 -0
  91. package/features/security/shared/description.js +7 -0
  92. package/features/security/shared/description.js.map +1 -0
  93. package/features/security/shared/index.d.ts +1 -0
  94. package/features/security/shared/index.js +1 -0
  95. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  96. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  97. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  98. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  99. package/features/security/teams/CreateTeam/schema.js +1 -1
  100. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  101. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  102. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  103. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  104. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  105. package/features/security/teams/UpdateTeam/schema.js +1 -1
  106. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  107. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  108. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  109. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  110. package/features/slugify/DefaultSlugify.d.ts +8 -0
  111. package/features/slugify/DefaultSlugify.js +20 -0
  112. package/features/slugify/DefaultSlugify.js.map +1 -0
  113. package/features/slugify/abstractions.d.ts +12 -0
  114. package/features/slugify/abstractions.js +5 -0
  115. package/features/slugify/abstractions.js.map +1 -0
  116. package/features/slugify/feature.d.ts +4 -0
  117. package/features/slugify/feature.js +11 -0
  118. package/features/slugify/feature.js.map +1 -0
  119. package/features/slugify/index.d.ts +3 -0
  120. package/features/slugify/index.js +2 -0
  121. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  122. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  123. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  124. package/features/stringFormatter/abstractions.d.ts +11 -0
  125. package/features/stringFormatter/abstractions.js +5 -0
  126. package/features/stringFormatter/abstractions.js.map +1 -0
  127. package/features/stringFormatter/feature.d.ts +4 -0
  128. package/features/stringFormatter/feature.js +13 -0
  129. package/features/stringFormatter/feature.js.map +1 -0
  130. package/features/stringFormatter/index.d.ts +3 -0
  131. package/features/stringFormatter/index.js +2 -0
  132. package/features/task/TaskDefinition/abstractions.d.ts +76 -4
  133. package/features/task/TaskDefinition/abstractions.js +2 -1
  134. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  135. package/features/wcp/WcpContext/WcpContext.d.ts +6 -0
  136. package/features/wcp/WcpContext/WcpContext.js +18 -0
  137. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  138. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +18 -0
  139. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +57 -25
  140. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  141. package/features/wcp/WcpFeature.js +2 -0
  142. package/features/wcp/WcpFeature.js.map +1 -1
  143. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  144. package/features/wcp/WcpLicenseLoader.js +58 -0
  145. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  146. package/features/wcp/WcpLicenseProvider.d.ts +6 -14
  147. package/features/wcp/WcpLicenseProvider.js +3 -7
  148. package/features/wcp/WcpLicenseProvider.js.map +1 -1
  149. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  150. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  151. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  152. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +9 -0
  153. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +49 -0
  154. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  155. package/graphql/wcp/WcpSchemaFactory.js +2 -0
  156. package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
  157. package/package.json +18 -18
  158. package/testing/environment.d.ts +14 -0
  159. package/testing/environment.js +18 -0
  160. package/testing/environment.js.map +1 -0
  161. package/types/security.d.ts +1 -1
  162. package/features/wcp/loadWcpLicense.d.ts +0 -2
  163. package/features/wcp/loadWcpLicense.js +0 -51
  164. package/features/wcp/loadWcpLicense.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js","sources":["../../../../../src/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { WcpContext } from \"../abstractions.js\";\nimport { FeatureFlags } from \"../../../featureFlags/abstractions.js\";\n\nclass WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Interface {\n constructor(\n private featureFlags: FeatureFlags.Interface,\n private decoratee: WcpContext.Interface\n ) {}\n\n getRawLicense() {\n return this.decoratee.getRawLicense();\n }\n\n getProject() {\n return this.decoratee.getProject();\n }\n\n getProjectWithFeatureFlags() {\n const project = this.decoratee.getProjectWithFeatureFlags();\n if (!project) {\n return null;\n }\n\n const flags = this.featureFlags.get();\n\n return {\n ...project,\n package: {\n ...project.package,\n features: {\n ...project.package.features,\n multiTenancy: project.package.features.multiTenancy,\n advancedPublishingWorkflow: {\n ...project.package.features.advancedPublishingWorkflow,\n enabled: flags.isWorkflowsEnabled()\n ? project.package.features.advancedPublishingWorkflow.enabled\n : false\n },\n advancedAccessControlLayer: {\n ...project.package.features.advancedAccessControlLayer,\n enabled: flags.isAaclEnabled()\n ? project.package.features.advancedAccessControlLayer.enabled\n : false,\n options: {\n teams: flags.isTeamsEnabled()\n ? project.package.features.advancedAccessControlLayer.options.teams\n : false,\n privateFiles: flags.isPrivateFilesEnabled()\n ? project.package.features.advancedAccessControlLayer.options\n .privateFiles\n : false,\n folderLevelPermissions: flags.isFolderLevelPermissionsEnabled()\n ? project.package.features.advancedAccessControlLayer.options\n .folderLevelPermissions\n : false,\n hcmsFieldPermissions: flags.isHcmsFieldPermissionsEnabled()\n ? project.package.features.advancedAccessControlLayer.options\n .hcmsFieldPermissions\n : false\n }\n },\n auditLogs: {\n ...project.package.features.auditLogs,\n enabled: flags.isAuditLogsEnabled()\n ? project.package.features.auditLogs.enabled\n : false\n },\n recordLocking: {\n ...project.package.features.recordLocking,\n enabled: flags.isRecordLockingEnabled()\n ? project.package.features.recordLocking.enabled\n : false\n },\n fileManager: {\n ...project.package.features.fileManager,\n enabled: project.package.features.fileManager.enabled,\n options: {\n threatDetection: flags.isFileManagerThreatDetectionEnabled()\n ? project.package.features.fileManager.options.threatDetection\n : false\n }\n },\n aiPowerups: {\n ...project.package.features.aiPowerups,\n enabled: flags.isAiPowerupsEnabled()\n ? project.package.features.aiPowerups?.enabled\n : false,\n options: {\n websiteBuilder: {\n pageGeneration: flags.isAiPageGenerationEnabled()\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageGeneration\n : false\n },\n fileManager: {\n imageEnrichment: flags.isAiImageEnrichmentEnabled()\n ? project.package.features.aiPowerups?.options?.fileManager\n ?.imageEnrichment\n : false\n },\n lexicalGeneration: flags.isAiLexicalGenerationEnabled()\n ? project.package.features.aiPowerups?.options?.lexicalGeneration\n : false\n }\n }\n }\n }\n };\n }\n\n getProjectEnvironment() {\n return this.decoratee.getProjectEnvironment();\n }\n\n getProjectLicense() {\n return this.decoratee.getProjectLicense();\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl() {\n return this.decoratee.canUseAacl() && this.featureFlags.get().isAaclEnabled();\n }\n\n canUseTeams() {\n return this.decoratee.canUseTeams() && this.featureFlags.get().isTeamsEnabled();\n }\n\n canUseFolderLevelPermissions() {\n return (\n this.decoratee.canUseFolderLevelPermissions() &&\n this.featureFlags.get().isFolderLevelPermissionsEnabled()\n );\n }\n\n canUsePrivateFiles() {\n return (\n this.decoratee.canUsePrivateFiles() && this.featureFlags.get().isPrivateFilesEnabled()\n );\n }\n\n canUseAuditLogs() {\n return this.decoratee.canUseAuditLogs() && this.featureFlags.get().isAuditLogsEnabled();\n }\n\n canUseRecordLocking() {\n return (\n this.decoratee.canUseRecordLocking() && this.featureFlags.get().isRecordLockingEnabled()\n );\n }\n\n canUseFileManagerThreatDetection() {\n return (\n this.decoratee.canUseFileManagerThreatDetection() &&\n this.featureFlags.get().isFileManagerThreatDetectionEnabled()\n );\n }\n\n canUseWorkflows() {\n return this.decoratee.canUseWorkflows() && this.featureFlags.get().isWorkflowsEnabled();\n }\n\n canUseHcmsFieldPermissions() {\n return (\n this.decoratee.canUseHcmsFieldPermissions() &&\n this.featureFlags.get().isHcmsFieldPermissionsEnabled()\n );\n }\n\n canUseAiImageEnrichment() {\n return (\n this.decoratee.canUseAiImageEnrichment() &&\n this.featureFlags.get().isAiImageEnrichmentEnabled()\n );\n }\n\n canUseAiPageGeneration() {\n return (\n this.decoratee.canUseAiPageGeneration() &&\n this.featureFlags.get().isAiPageGenerationEnabled()\n );\n }\n\n canUseAiLexicalGeneration() {\n return (\n this.decoratee.canUseAiLexicalGeneration() &&\n this.featureFlags.get().isAiLexicalGenerationEnabled()\n );\n }\n\n ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.ensureCanUseFeature(featureId);\n }\n\n async incrementSeats() {\n return this.decoratee.incrementSeats();\n }\n\n async decrementSeats() {\n return this.decoratee.decrementSeats();\n }\n\n async incrementTenants() {\n return this.decoratee.incrementTenants();\n }\n\n async decrementTenants() {\n return this.decoratee.decrementTenants();\n }\n\n toDto() {\n return this.decoratee.toDto();\n }\n}\n\nexport const WcpContextWithFeatureFlagsDecorator = WcpContext.createDecorator({\n decorator: WcpContextWithFeatureFlagsDecoratorImpl,\n dependencies: [FeatureFlags]\n});\n"],"names":["WcpContextWithFeatureFlagsDecoratorImpl","featureFlags","decoratee","project","flags","wcpFeatureId","featureId","WcpContextWithFeatureFlagsDecorator","WcpContext","FeatureFlags"],"mappings":";;AAIA,MAAMA;IACF,YACYC,YAAoC,EACpCC,SAA+B,CACzC;aAFUD,YAAY,GAAZA;aACAC,SAAS,GAATA;IACT;IAEH,gBAAgB;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa;IACvC;IAEA,aAAa;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU;IACpC;IAEA,6BAA6B;QACzB,MAAMC,UAAU,IAAI,CAAC,SAAS,CAAC,0BAA0B;QACzD,IAAI,CAACA,SACD,OAAO;QAGX,MAAMC,QAAQ,IAAI,CAAC,YAAY,CAAC,GAAG;QAEnC,OAAO;YACH,GAAGD,OAAO;YACV,SAAS;gBACL,GAAGA,QAAQ,OAAO;gBAClB,UAAU;oBACN,GAAGA,QAAQ,OAAO,CAAC,QAAQ;oBAC3B,cAAcA,QAAQ,OAAO,CAAC,QAAQ,CAAC,YAAY;oBACnD,4BAA4B;wBACxB,GAAGA,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B;wBACtD,SAASC,MAAM,kBAAkB,KAC3BD,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,OAAO,GAC3D;oBACV;oBACA,4BAA4B;wBACxB,GAAGA,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B;wBACtD,SAASC,MAAM,aAAa,KACtBD,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,OAAO,GAC3D;wBACN,SAAS;4BACL,OAAOC,MAAM,cAAc,KACrBD,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,OAAO,CAAC,KAAK,GACjE;4BACN,cAAcC,MAAM,qBAAqB,KACnCD,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,OAAO,CACtD,YAAY,GACjB;4BACN,wBAAwBC,MAAM,+BA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6BAA6B;QACzB,OACI,IAAI,CAAC,SAAS,CAAC,0BAA0B,MACzC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,6BAA6B;IAE7D;IAEA,0BAA0B;QACtB,OACI,IAAI,CAAC,SAAS,CAAC,uBAAuB,MACtC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,0BAA0B;IAE1D;IAEA,yBAAyB;QACrB,OACI,IAAI,CAAC,SAAS,CAAC,sBAAsB,MACrC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,yBAAyB;IAEzD;IAEA,4BAA4B;QACxB,OACI,IAAI,CAAC,SAAS,CAAC,yBAAyB,MACxC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,4BAA4B;IAE5D;IAEA,oBAAoBC,SAAyC,EAAE;QAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAACA;IAC9C;IAEA,MAAM,iBAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc;IACxC;IAEA,MAAM,iBAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc;IACxC;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK;IAC/B;AACJ;AAEO,MAAMC,sCAAsCC,WAAW,eAAe,CAAC;IAC1E,WAAWR;IACX,cAAc;QAACS;KAAa;AAChC"}
1
+ {"version":3,"file":"features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js","sources":["../../../../../src/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { WcpContext } from \"../abstractions.js\";\nimport { FeatureFlags } from \"../../../featureFlags/abstractions.js\";\n\nclass WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Interface {\n constructor(\n private featureFlags: FeatureFlags.Interface,\n private decoratee: WcpContext.Interface\n ) {}\n\n getRawLicense() {\n return this.decoratee.getRawLicense();\n }\n\n getProject() {\n return this.decoratee.getProject();\n }\n\n getProjectWithFeatureFlags() {\n const project = this.decoratee.getProjectWithFeatureFlags();\n if (!project) {\n return null;\n }\n\n const flags = this.featureFlags.get();\n\n return {\n ...project,\n package: {\n ...project.package,\n features: {\n ...project.package.features,\n multiTenancy: project.package.features.multiTenancy,\n advancedPublishingWorkflow: {\n ...project.package.features.advancedPublishingWorkflow,\n enabled: flags.isEnabled(\"advancedPublishingWorkflow\")\n ? project.package.features.advancedPublishingWorkflow.enabled\n : false\n },\n advancedAccessControlLayer: {\n ...project.package.features.advancedAccessControlLayer,\n enabled: flags.isEnabled(\"advancedAccessControlLayer\")\n ? project.package.features.advancedAccessControlLayer.enabled\n : false,\n options: {\n teams: flags.isEnabled(\"advancedAccessControlLayer.teams\")\n ? project.package.features.advancedAccessControlLayer.options.teams\n : false,\n privateFiles: flags.isEnabled(\"advancedAccessControlLayer.privateFiles\")\n ? project.package.features.advancedAccessControlLayer.options\n .privateFiles\n : false,\n folderLevelPermissions: flags.isEnabled(\n \"advancedAccessControlLayer.folderLevelPermissions\"\n )\n ? project.package.features.advancedAccessControlLayer.options\n .folderLevelPermissions\n : false,\n hcmsFieldPermissions: flags.isEnabled(\n \"advancedAccessControlLayer.hcmsFieldPermissions\"\n )\n ? project.package.features.advancedAccessControlLayer.options\n .hcmsFieldPermissions\n : false\n }\n },\n auditLogs: {\n ...project.package.features.auditLogs,\n enabled: flags.isEnabled(\"auditLogs\")\n ? project.package.features.auditLogs.enabled\n : false\n },\n recordLocking: {\n ...project.package.features.recordLocking,\n enabled: flags.isEnabled(\"recordLocking\")\n ? project.package.features.recordLocking.enabled\n : false\n },\n fileManager: {\n ...project.package.features.fileManager,\n enabled: project.package.features.fileManager.enabled,\n options: {\n threatDetection: flags.isEnabled(\"fileManager.threatDetection\")\n ? project.package.features.fileManager.options.threatDetection\n : false\n }\n },\n aiPowerups: {\n ...project.package.features.aiPowerups,\n enabled: flags.isEnabled(\"aiPowerups\")\n ? project.package.features.aiPowerups?.enabled\n : false,\n options: {\n websiteBuilder: {\n pageGeneration: flags.isEnabled(\n \"aiPowerups.websiteBuilder.pageGeneration\"\n )\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageGeneration\n : false,\n pageTranslation: flags.isEnabled(\n \"aiPowerups.websiteBuilder.pageTranslation\"\n )\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageTranslation\n : false\n },\n fileManager: {\n imageEnrichment: flags.isEnabled(\n \"aiPowerups.fileManager.imageEnrichment\"\n )\n ? project.package.features.aiPowerups?.options?.fileManager\n ?.imageEnrichment\n : false\n },\n lexicalGeneration: flags.isEnabled(\"aiPowerups.lexicalGeneration\")\n ? project.package.features.aiPowerups?.options?.lexicalGeneration\n : false,\n cms: {\n entryGeneration: flags.isEnabled(\"aiPowerups.cms.entryGeneration\")\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryGeneration\n : false,\n entryComparison: flags.isEnabled(\"aiPowerups.cms.entryComparison\")\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryComparison\n : false,\n entryTranslation: flags.isEnabled(\"aiPowerups.cms.entryTranslation\")\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryTranslation\n : false\n }\n }\n },\n abTesting: {\n ...project.package.features.abTesting,\n enabled: flags.isEnabled(\"abTesting\")\n ? project.package.features.abTesting?.enabled\n : false\n },\n remoteComponents: {\n ...project.package.features.remoteComponents,\n enabled: flags.isEnabled(\"remoteComponents\")\n ? project.package.features.remoteComponents?.enabled\n : false\n }\n }\n }\n };\n }\n\n getProjectEnvironment() {\n return this.decoratee.getProjectEnvironment();\n }\n\n getProjectLicense() {\n return this.decoratee.getProjectLicense();\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl() {\n return (\n this.decoratee.canUseAacl() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer\")\n );\n }\n\n canUseTeams() {\n return (\n this.decoratee.canUseTeams() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.teams\")\n );\n }\n\n canUseFolderLevelPermissions() {\n return (\n this.decoratee.canUseFolderLevelPermissions() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.folderLevelPermissions\")\n );\n }\n\n canUsePrivateFiles() {\n return (\n this.decoratee.canUsePrivateFiles() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.privateFiles\")\n );\n }\n\n canUseAuditLogs() {\n return this.decoratee.canUseAuditLogs() && this.featureFlags.get().isEnabled(\"auditLogs\");\n }\n\n canUseRecordLocking() {\n return (\n this.decoratee.canUseRecordLocking() &&\n this.featureFlags.get().isEnabled(\"recordLocking\")\n );\n }\n\n canUseFileManagerThreatDetection() {\n return (\n this.decoratee.canUseFileManagerThreatDetection() &&\n this.featureFlags.get().isEnabled(\"fileManager.threatDetection\")\n );\n }\n\n canUseWorkflows() {\n return (\n this.decoratee.canUseWorkflows() &&\n this.featureFlags.get().isEnabled(\"advancedPublishingWorkflow\")\n );\n }\n\n canUseHcmsFieldPermissions() {\n return (\n this.decoratee.canUseHcmsFieldPermissions() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.hcmsFieldPermissions\")\n );\n }\n\n canUseAiImageEnrichment() {\n return (\n this.decoratee.canUseAiImageEnrichment() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.fileManager.imageEnrichment\")\n );\n }\n\n canUseAiPageGeneration() {\n return (\n this.decoratee.canUseAiPageGeneration() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.websiteBuilder.pageGeneration\")\n );\n }\n\n canUseAiPageTranslation() {\n return (\n this.decoratee.canUseAiPageTranslation() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.websiteBuilder.pageTranslation\")\n );\n }\n\n canUseAiLexicalGeneration() {\n return (\n this.decoratee.canUseAiLexicalGeneration() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.lexicalGeneration\")\n );\n }\n\n canUseAiEntryGeneration() {\n return (\n this.decoratee.canUseAiEntryGeneration() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.cms.entryGeneration\")\n );\n }\n\n canUseAiEntryComparison() {\n return (\n this.decoratee.canUseAiEntryComparison() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.cms.entryComparison\")\n );\n }\n\n canUseAiEntryTranslation() {\n return (\n this.decoratee.canUseAiEntryTranslation() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.cms.entryTranslation\")\n );\n }\n\n canUseAbTesting() {\n return this.decoratee.canUseAbTesting() && this.featureFlags.get().isEnabled(\"abTesting\");\n }\n\n canUseRemoteComponents() {\n return (\n this.decoratee.canUseRemoteComponents() &&\n this.featureFlags.get().isEnabled(\"remoteComponents\")\n );\n }\n\n ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.ensureCanUseFeature(featureId);\n }\n\n async incrementSeats() {\n return this.decoratee.incrementSeats();\n }\n\n async decrementSeats() {\n return this.decoratee.decrementSeats();\n }\n\n async incrementTenants() {\n return this.decoratee.incrementTenants();\n }\n\n async decrementTenants() {\n return this.decoratee.decrementTenants();\n }\n\n toDto() {\n return this.decoratee.toDto();\n }\n}\n\nexport const WcpContextWithFeatureFlagsDecorator = WcpContext.createDecorator({\n decorator: WcpContextWithFeatureFlagsDecoratorImpl,\n dependencies: [FeatureFlags]\n});\n"],"names":["WcpContextWithFeatureFlagsDecoratorImpl","featureFlags","decoratee","project","flags","wcpFeatureId","featureId","WcpContextWithFeatureFlagsDecorator","WcpContext","FeatureFlags"],"mappings":";;AAIA,MAAMA;IACF,YACYC,YAAoC,EACpCC,SAA+B,CACzC;aAFUD,YAAY,GAAZA;aACAC,SAAS,GAATA;IACT;IAEH,gB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IAE1C;IAEA,0BAA0B;QACtB,OACI,IAAI,CAAC,SAAS,CAAC,uBAAuB,MACtC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IAE1C;IAEA,0BAA0B;QACtB,OACI,IAAI,CAAC,SAAS,CAAC,uBAAuB,MACtC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IAE1C;IAEA,2BAA2B;QACvB,OACI,IAAI,CAAC,SAAS,CAAC,wBAAwB,MACvC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IAE1C;IAEA,kBAAkB;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IACjF;IAEA,yBAAyB;QACrB,OACI,IAAI,CAAC,SAAS,CAAC,sBAAsB,MACrC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IAE1C;IAEA,oBAAoBC,SAAyC,EAAE;QAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAACA;IAC9C;IAEA,MAAM,iBAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc;IACxC;IAEA,MAAM,iBAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc;IACxC;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK;IAC/B;AACJ;AAEO,MAAMC,sCAAsCC,WAAW,eAAe,CAAC;IAC1E,WAAWR;IACX,cAAc;QAACS;KAAa;AAChC"}
@@ -1,6 +1,7 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { WcpContextFeature } from "./WcpContext/feature.js";
3
3
  import { WcpContextWithFeatureFlagsDecorator } from "./WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js";
4
+ import { FeatureFlagsWithLicenseDecorator } from "../featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js";
4
5
  import { WcpLicenseProvider, WcpLicenseProviderImpl } from "./WcpLicenseProvider.js";
5
6
  const WcpFeature = createFeature({
6
7
  name: "WebinyControlPanel",
@@ -9,6 +10,7 @@ const WcpFeature = createFeature({
9
10
  container.registerInstance(WcpLicenseProvider, provider);
10
11
  WcpContextFeature.register(container, provider);
11
12
  container.registerDecorator(WcpContextWithFeatureFlagsDecorator);
13
+ container.registerDecorator(FeatureFlagsWithLicenseDecorator);
12
14
  }
13
15
  });
14
16
  export { WcpFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"features/wcp/WcpFeature.js","sources":["../../../src/features/wcp/WcpFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { WcpContextFeature } from \"./WcpContext/feature.js\";\nimport { WcpContextWithFeatureFlagsDecorator } from \"./WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js\";\nimport { WcpLicenseProvider, WcpLicenseProviderImpl } from \"./WcpLicenseProvider.js\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\n\nexport const WcpFeature = createFeature<ILicense | undefined>({\n name: \"WebinyControlPanel\",\n register(container, initialLicense?) {\n const provider = new WcpLicenseProviderImpl(initialLicense);\n container.registerInstance(WcpLicenseProvider, provider);\n WcpContextFeature.register(container, provider);\n container.registerDecorator(WcpContextWithFeatureFlagsDecorator);\n // Per-request license refresh (RequestInitializer) is registered by api-event-handler-core's\n // registerApiRequestStack, keeping the domain layer free of the transport lifecycle contract.\n }\n});\n"],"names":["WcpFeature","createFeature","container","initialLicense","provider","WcpLicenseProviderImpl","WcpLicenseProvider","WcpContextFeature","WcpContextWithFeatureFlagsDecorator"],"mappings":";;;;AAMO,MAAMA,aAAaC,cAAoC;IAC1D,MAAM;IACN,UAASC,SAAS,EAAEC,cAAe;QAC/B,MAAMC,WAAW,IAAIC,uBAAuBF;QAC5CD,UAAU,gBAAgB,CAACI,oBAAoBF;QAC/CG,kBAAkB,QAAQ,CAACL,WAAWE;QACtCF,UAAU,iBAAiB,CAACM;IAGhC;AACJ"}
1
+ {"version":3,"file":"features/wcp/WcpFeature.js","sources":["../../../src/features/wcp/WcpFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { WcpContextFeature } from \"./WcpContext/feature.js\";\nimport { WcpContextWithFeatureFlagsDecorator } from \"./WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js\";\nimport { FeatureFlagsWithLicenseDecorator } from \"../featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js\";\nimport { WcpLicenseProvider, WcpLicenseProviderImpl } from \"./WcpLicenseProvider.js\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\n\nexport const WcpFeature = createFeature<ILicense | undefined>({\n name: \"WebinyControlPanel\",\n register(container, initialLicense?) {\n const provider = new WcpLicenseProviderImpl(initialLicense);\n container.registerInstance(WcpLicenseProvider, provider);\n WcpContextFeature.register(container, provider);\n container.registerDecorator(WcpContextWithFeatureFlagsDecorator);\n container.registerDecorator(FeatureFlagsWithLicenseDecorator);\n // The per-request license refresh is loaded pre-register by api-event-handler-core's\n // registerApiRequestStack, keeping the domain layer free of the transport lifecycle contract.\n }\n});\n"],"names":["WcpFeature","createFeature","container","initialLicense","provider","WcpLicenseProviderImpl","WcpLicenseProvider","WcpContextFeature","WcpContextWithFeatureFlagsDecorator","FeatureFlagsWithLicenseDecorator"],"mappings":";;;;;AAOO,MAAMA,aAAaC,cAAoC;IAC1D,MAAM;IACN,UAASC,SAAS,EAAEC,cAAe;QAC/B,MAAMC,WAAW,IAAIC,uBAAuBF;QAC5CD,UAAU,gBAAgB,CAACI,oBAAoBF;QAC/CG,kBAAkB,QAAQ,CAACL,WAAWE;QACtCF,UAAU,iBAAiB,CAACM;QAC5BN,UAAU,iBAAiB,CAACO;IAGhC;AACJ"}
@@ -0,0 +1,25 @@
1
+ import type { DecryptedWcpProjectLicense, ILicense } from "@webiny/wcp/types.js";
2
+ /**
3
+ * Loads and process-caches the WCP project license. Static because the cache is process-global (one
4
+ * license per deployment): the pre-register refresh in `registerApiRequestStack` calls `load()` to
5
+ * populate it, and `WcpLicenseProvider` / register-time feature-flag gates read it synchronously via
6
+ * `getCached()`. Not DI — it must be usable before any container exists (before register).
7
+ */
8
+ export declare class WcpLicenseLoader {
9
+ private static readonly wcpProjectEnvironment;
10
+ private static cached;
11
+ private static inflight;
12
+ /**
13
+ * Synchronously read the currently cached license. `load()` must have been awaited at least once
14
+ * this request (the pre-register refresh does this), so this reflects the live license — letting
15
+ * register()-time feature-flag checks read it synchronously.
16
+ */
17
+ static getCached(): ILicense;
18
+ /**
19
+ * Seed the cache with an already-resolved license (tests pass a pre-built one). Marks it fresh so
20
+ * a subsequent `load()` returns it without a fetch. This is how `WcpLicenseProviderImpl` installs
21
+ * an initial license.
22
+ */
23
+ static seed(license: ILicense): void;
24
+ static load(testProjectLicense?: DecryptedWcpProjectLicense): Promise<ILicense>;
25
+ }
@@ -0,0 +1,58 @@
1
+ import { License, NullLicense, getWcpProjectLicense } from "@webiny/wcp";
2
+ import { getWcpProjectLicenseCacheKey } from "./WcpContext/utils.js";
3
+ import { resolveWcpProjectEnvironment } from "./resolveWcpProjectEnvironment.js";
4
+ class WcpLicenseLoader {
5
+ static{
6
+ this.wcpProjectEnvironment = resolveWcpProjectEnvironment();
7
+ }
8
+ static{
9
+ this.cached = {
10
+ cacheKey: null,
11
+ project: null,
12
+ license: new NullLicense()
13
+ };
14
+ }
15
+ static{
16
+ this.inflight = null;
17
+ }
18
+ static getCached() {
19
+ return WcpLicenseLoader.cached.license;
20
+ }
21
+ static seed(license) {
22
+ WcpLicenseLoader.cached.license = license;
23
+ WcpLicenseLoader.cached.cacheKey = getWcpProjectLicenseCacheKey();
24
+ }
25
+ static async load(testProjectLicense) {
26
+ const cached = WcpLicenseLoader.cached;
27
+ if (testProjectLicense) {
28
+ cached.license = License.fromLicenseDto(testProjectLicense);
29
+ return cached.license;
30
+ }
31
+ const env = WcpLicenseLoader.wcpProjectEnvironment;
32
+ if (!env) return cached.license;
33
+ const currentCacheKey = getWcpProjectLicenseCacheKey();
34
+ if (cached.cacheKey === currentCacheKey) return cached.license;
35
+ if (WcpLicenseLoader.inflight) return WcpLicenseLoader.inflight;
36
+ WcpLicenseLoader.inflight = (async ()=>{
37
+ const decryptedLicenseDto = await getWcpProjectLicense({
38
+ orgId: env.org.id,
39
+ projectId: env.project.id,
40
+ projectEnvironmentApiKey: env.apiKey
41
+ });
42
+ if (decryptedLicenseDto) cached.project = {
43
+ orgId: decryptedLicenseDto.orgId,
44
+ projectId: decryptedLicenseDto.projectId,
45
+ package: decryptedLicenseDto.package
46
+ };
47
+ cached.license = License.fromLicenseDto(decryptedLicenseDto);
48
+ cached.cacheKey = currentCacheKey;
49
+ return cached.license;
50
+ })().finally(()=>{
51
+ WcpLicenseLoader.inflight = null;
52
+ });
53
+ return WcpLicenseLoader.inflight;
54
+ }
55
+ }
56
+ export { WcpLicenseLoader };
57
+
58
+ //# sourceMappingURL=WcpLicenseLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/wcp/WcpLicenseLoader.js","sources":["../../../src/features/wcp/WcpLicenseLoader.ts"],"sourcesContent":["import { getWcpProjectLicense, NullLicense, License } from \"@webiny/wcp\";\nimport type { DecryptedWcpProjectLicense, ILicense } from \"@webiny/wcp/types.js\";\nimport type { CachedWcpProjectLicense } from \"~/features/wcp/WcpContext/types.js\";\nimport { getWcpProjectLicenseCacheKey } from \"~/features/wcp/WcpContext/utils.js\";\nimport { resolveWcpProjectEnvironment } from \"~/features/wcp/resolveWcpProjectEnvironment.js\";\n\n/**\n * Loads and process-caches the WCP project license. Static because the cache is process-global (one\n * license per deployment): the pre-register refresh in `registerApiRequestStack` calls `load()` to\n * populate it, and `WcpLicenseProvider` / register-time feature-flag gates read it synchronously via\n * `getCached()`. Not DI — it must be usable before any container exists (before register).\n */\nexport class WcpLicenseLoader {\n private static readonly wcpProjectEnvironment = resolveWcpProjectEnvironment();\n\n private static cached: CachedWcpProjectLicense = {\n cacheKey: null,\n project: null,\n license: new NullLicense()\n };\n\n // In-flight fetch, memoized so concurrent cache-miss callers coalesce onto a single WCP request\n // (self-hosted runs many requests in one process; we never want two license fetches at once).\n private static inflight: Promise<ILicense> | null = null;\n\n /**\n * Synchronously read the currently cached license. `load()` must have been awaited at least once\n * this request (the pre-register refresh does this), so this reflects the live license — letting\n * register()-time feature-flag checks read it synchronously.\n */\n static getCached(): ILicense {\n return WcpLicenseLoader.cached.license;\n }\n\n /**\n * Seed the cache with an already-resolved license (tests pass a pre-built one). Marks it fresh so\n * a subsequent `load()` returns it without a fetch. This is how `WcpLicenseProviderImpl` installs\n * an initial license.\n */\n static seed(license: ILicense): void {\n WcpLicenseLoader.cached.license = license;\n WcpLicenseLoader.cached.cacheKey = getWcpProjectLicenseCacheKey();\n }\n\n static async load(testProjectLicense?: DecryptedWcpProjectLicense): Promise<ILicense> {\n const cached = WcpLicenseLoader.cached;\n\n if (testProjectLicense) {\n cached.license = License.fromLicenseDto(testProjectLicense);\n return cached.license;\n }\n\n const env = WcpLicenseLoader.wcpProjectEnvironment;\n if (!env) {\n return cached.license;\n }\n\n const currentCacheKey = getWcpProjectLicenseCacheKey();\n if (cached.cacheKey === currentCacheKey) {\n return cached.license;\n }\n\n // Cache miss (first load or the ~5-min key rotated). Coalesce concurrent callers onto one fetch.\n if (WcpLicenseLoader.inflight) {\n return WcpLicenseLoader.inflight;\n }\n\n WcpLicenseLoader.inflight = (async () => {\n // Pull the project license from the WCP API.\n const decryptedLicenseDto = await getWcpProjectLicense({\n orgId: env.org.id,\n projectId: env.project.id,\n projectEnvironmentApiKey: env.apiKey\n });\n\n if (decryptedLicenseDto) {\n cached.project = {\n orgId: decryptedLicenseDto.orgId,\n projectId: decryptedLicenseDto.projectId,\n package: decryptedLicenseDto.package\n };\n }\n\n cached.license = License.fromLicenseDto(decryptedLicenseDto);\n // Mark fresh only after a successful fetch — a throw leaves the key unset so the next call retries.\n cached.cacheKey = currentCacheKey;\n return cached.license;\n })().finally(() => {\n WcpLicenseLoader.inflight = null;\n });\n\n return WcpLicenseLoader.inflight;\n }\n}\n"],"names":["WcpLicenseLoader","resolveWcpProjectEnvironment","NullLicense","license","getWcpProjectLicenseCacheKey","testProjectLicense","cached","License","env","currentCacheKey","decryptedLicenseDto","getWcpProjectLicense"],"mappings":";;;AAYO,MAAMA;;aACe,qBAAqB,GAAGC;;;aAEjC,MAAM,GAA4B;YAC7C,UAAU;YACV,SAAS;YACT,SAAS,IAAIC;QACjB;;;aAIe,QAAQ,GAA6B;;IAOpD,OAAO,YAAsB;QACzB,OAAOF,iBAAiB,MAAM,CAAC,OAAO;IAC1C;IAOA,OAAO,KAAKG,OAAiB,EAAQ;QACjCH,iBAAiB,MAAM,CAAC,OAAO,GAAGG;QAClCH,iBAAiB,MAAM,CAAC,QAAQ,GAAGI;IACvC;IAEA,aAAa,KAAKC,kBAA+C,EAAqB;QAClF,MAAMC,SAASN,iBAAiB,MAAM;QAEtC,IAAIK,oBAAoB;YACpBC,OAAO,OAAO,GAAGC,QAAQ,cAAc,CAACF;YACxC,OAAOC,OAAO,OAAO;QACzB;QAEA,MAAME,MAAMR,iBAAiB,qBAAqB;QAClD,IAAI,CAACQ,KACD,OAAOF,OAAO,OAAO;QAGzB,MAAMG,kBAAkBL;QACxB,IAAIE,OAAO,QAAQ,KAAKG,iBACpB,OAAOH,OAAO,OAAO;QAIzB,IAAIN,iBAAiB,QAAQ,EACzB,OAAOA,iBAAiB,QAAQ;QAGpCA,iBAAiB,QAAQ,GAAI;YAEzB,MAAMU,sBAAsB,MAAMC,qBAAqB;gBACnD,OAAOH,IAAI,GAAG,CAAC,EAAE;gBACjB,WAAWA,IAAI,OAAO,CAAC,EAAE;gBACzB,0BAA0BA,IAAI,MAAM;YACxC;YAEA,IAAIE,qBACAJ,OAAO,OAAO,GAAG;gBACb,OAAOI,oBAAoB,KAAK;gBAChC,WAAWA,oBAAoB,SAAS;gBACxC,SAASA,oBAAoB,OAAO;YACxC;YAGJJ,OAAO,OAAO,GAAGC,QAAQ,cAAc,CAACG;YAExCJ,OAAO,QAAQ,GAAGG;YAClB,OAAOH,OAAO,OAAO;QACzB,KAAK,OAAO,CAAC;YACTN,iBAAiB,QAAQ,GAAG;QAChC;QAEA,OAAOA,iBAAiB,QAAQ;IACpC;AACJ"}
@@ -1,29 +1,21 @@
1
1
  import type { ILicense } from "@webiny/wcp/types.js";
2
2
  export interface IWcpLicenseProvider {
3
3
  get(): ILicense;
4
- refresh(): Promise<void>;
5
4
  }
6
5
  export declare const WcpLicenseProvider: import("@webiny/di").Abstraction<IWcpLicenseProvider>;
7
6
  export declare namespace WcpLicenseProvider {
8
7
  type Interface = IWcpLicenseProvider;
9
8
  }
10
9
  /**
11
- * Holds the current WCP license. `get()` is synchronous so the canUse* consumers (IdentityContext,
12
- * GroupsTeamsAuthorizer, the WCP GraphQL query) stay sync. `refresh()` is driven once per request
13
- * by WcpLicenseInitializer (a RequestInitializer), BEFORE resolvers run:
10
+ * Synchronous read-through to the process-cached WCP license. `get()` stays sync so the canUse*
11
+ * consumers (WcpContext, IdentityContext, the WCP GraphQL query) do too. The license is refreshed
12
+ * once per request BEFORE any feature registers — `registerApiRequestStack` awaits
13
+ * `WcpLicenseLoader.load()` (process-cached, ~5-min TTL, single-flighted) — so `get()` reflects the
14
+ * live license at both register() time (feature-flag gates) and resolver time.
14
15
  *
15
- * - It re-reads `loadWcpLicense()`, whose process-global cache rotates ~every 5 minutes, so a
16
- * license change (upgrade/downgrade/expiry) takes effect mid-Lambda-lifetime instead of only on
17
- * the next cold start.
18
- * - Awaiting it per request before resolvers closes the NullLicense race (no window where a
19
- * resolver sees the placeholder).
20
- *
21
- * An optional initial license can be supplied (tests pass the pre-resolved license); otherwise it
22
- * starts as NullLicense and the first refresh() (before resolvers) installs the real one.
16
+ * An optional initial license can be supplied (tests pass a pre-resolved one); it seeds the cache.
23
17
  */
24
18
  export declare class WcpLicenseProviderImpl implements IWcpLicenseProvider {
25
- private current;
26
19
  constructor(initialLicense?: ILicense);
27
20
  get(): ILicense;
28
- refresh(): Promise<void>;
29
21
  }
@@ -1,16 +1,12 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- import { NullLicense } from "@webiny/wcp";
3
- import { loadWcpLicense } from "./loadWcpLicense.js";
2
+ import { WcpLicenseLoader } from "./WcpLicenseLoader.js";
4
3
  const WcpLicenseProvider = createAbstraction("WcpLicenseProvider");
5
4
  class WcpLicenseProviderImpl {
6
5
  constructor(initialLicense){
7
- this.current = initialLicense ?? new NullLicense();
6
+ if (initialLicense) WcpLicenseLoader.seed(initialLicense);
8
7
  }
9
8
  get() {
10
- return this.current;
11
- }
12
- async refresh() {
13
- this.current = await loadWcpLicense();
9
+ return WcpLicenseLoader.getCached();
14
10
  }
15
11
  }
16
12
  export { WcpLicenseProvider, WcpLicenseProviderImpl };
@@ -1 +1 @@
1
- {"version":3,"file":"features/wcp/WcpLicenseProvider.js","sources":["../../../src/features/wcp/WcpLicenseProvider.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { NullLicense } from \"@webiny/wcp\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\nimport { loadWcpLicense } from \"~/features/wcp/loadWcpLicense.js\";\n\nexport interface IWcpLicenseProvider {\n get(): ILicense;\n refresh(): Promise<void>;\n}\n\nexport const WcpLicenseProvider = createAbstraction<IWcpLicenseProvider>(\"WcpLicenseProvider\");\n\nexport namespace WcpLicenseProvider {\n export type Interface = IWcpLicenseProvider;\n}\n\n/**\n * Holds the current WCP license. `get()` is synchronous so the canUse* consumers (IdentityContext,\n * GroupsTeamsAuthorizer, the WCP GraphQL query) stay sync. `refresh()` is driven once per request\n * by WcpLicenseInitializer (a RequestInitializer), BEFORE resolvers run:\n *\n * - It re-reads `loadWcpLicense()`, whose process-global cache rotates ~every 5 minutes, so a\n * license change (upgrade/downgrade/expiry) takes effect mid-Lambda-lifetime instead of only on\n * the next cold start.\n * - Awaiting it per request before resolvers closes the NullLicense race (no window where a\n * resolver sees the placeholder).\n *\n * An optional initial license can be supplied (tests pass the pre-resolved license); otherwise it\n * starts as NullLicense and the first refresh() (before resolvers) installs the real one.\n */\nexport class WcpLicenseProviderImpl implements IWcpLicenseProvider {\n private current: ILicense;\n\n constructor(initialLicense?: ILicense) {\n this.current = initialLicense ?? new NullLicense();\n }\n\n get(): ILicense {\n return this.current;\n }\n\n async refresh(): Promise<void> {\n this.current = await loadWcpLicense();\n }\n}\n"],"names":["WcpLicenseProvider","createAbstraction","WcpLicenseProviderImpl","initialLicense","NullLicense","loadWcpLicense"],"mappings":";;;AAUO,MAAMA,qBAAqBC,kBAAuC;AAoBlE,MAAMC;IAGT,YAAYC,cAAyB,CAAE;QACnC,IAAI,CAAC,OAAO,GAAGA,kBAAkB,IAAIC;IACzC;IAEA,MAAgB;QACZ,OAAO,IAAI,CAAC,OAAO;IACvB;IAEA,MAAM,UAAyB;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAMC;IACzB;AACJ"}
1
+ {"version":3,"file":"features/wcp/WcpLicenseProvider.js","sources":["../../../src/features/wcp/WcpLicenseProvider.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\nimport { WcpLicenseLoader } from \"~/features/wcp/WcpLicenseLoader.js\";\n\nexport interface IWcpLicenseProvider {\n get(): ILicense;\n}\n\nexport const WcpLicenseProvider = createAbstraction<IWcpLicenseProvider>(\"WcpLicenseProvider\");\n\nexport namespace WcpLicenseProvider {\n export type Interface = IWcpLicenseProvider;\n}\n\n/**\n * Synchronous read-through to the process-cached WCP license. `get()` stays sync so the canUse*\n * consumers (WcpContext, IdentityContext, the WCP GraphQL query) do too. The license is refreshed\n * once per request BEFORE any feature registers — `registerApiRequestStack` awaits\n * `WcpLicenseLoader.load()` (process-cached, ~5-min TTL, single-flighted) — so `get()` reflects the\n * live license at both register() time (feature-flag gates) and resolver time.\n *\n * An optional initial license can be supplied (tests pass a pre-resolved one); it seeds the cache.\n */\nexport class WcpLicenseProviderImpl implements IWcpLicenseProvider {\n constructor(initialLicense?: ILicense) {\n if (initialLicense) {\n WcpLicenseLoader.seed(initialLicense);\n }\n }\n\n get(): ILicense {\n return WcpLicenseLoader.getCached();\n }\n}\n"],"names":["WcpLicenseProvider","createAbstraction","WcpLicenseProviderImpl","initialLicense","WcpLicenseLoader"],"mappings":";;AAQO,MAAMA,qBAAqBC,kBAAuC;AAelE,MAAMC;IACT,YAAYC,cAAyB,CAAE;QACnC,IAAIA,gBACAC,iBAAiB,IAAI,CAACD;IAE9B;IAEA,MAAgB;QACZ,OAAOC,iBAAiB,SAAS;IACrC;AACJ"}
@@ -0,0 +1,9 @@
1
+ import type { WcpProjectEnvironment } from "@webiny/wcp/types.js";
2
+ /**
3
+ * Resolve the WCP project environment used to fetch the license. Prefer the CLI-computed
4
+ * WCP_PROJECT_ENVIRONMENT blob (set by `applyWcpEnvVars` during `webiny serve` and the AWS deploy).
5
+ * When it's absent — a CLI-less self-hosted deploy that boots the built handler directly (e.g.
6
+ * `node start.mjs`) — derive the same org, project and api key straight from the runtime env, so a
7
+ * fresh license can still be fetched.
8
+ */
9
+ export declare function resolveWcpProjectEnvironment(): WcpProjectEnvironment | null;
@@ -0,0 +1,23 @@
1
+ import { getWcpProjectEnvironment } from "@webiny/wcp";
2
+ function resolveWcpProjectEnvironment() {
3
+ const fromBlob = getWcpProjectEnvironment();
4
+ if (fromBlob) return fromBlob;
5
+ const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;
6
+ const apiKey = process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;
7
+ if (!projectId || !apiKey) return null;
8
+ const [orgId, project] = projectId.split("/");
9
+ if (!orgId || !project) return null;
10
+ return {
11
+ id: "",
12
+ apiKey,
13
+ org: {
14
+ id: orgId
15
+ },
16
+ project: {
17
+ id: project
18
+ }
19
+ };
20
+ }
21
+ export { resolveWcpProjectEnvironment };
22
+
23
+ //# sourceMappingURL=resolveWcpProjectEnvironment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/wcp/resolveWcpProjectEnvironment.js","sources":["../../../src/features/wcp/resolveWcpProjectEnvironment.ts"],"sourcesContent":["import { getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport type { WcpProjectEnvironment } from \"@webiny/wcp/types.js\";\n\n/**\n * Resolve the WCP project environment used to fetch the license. Prefer the CLI-computed\n * WCP_PROJECT_ENVIRONMENT blob (set by `applyWcpEnvVars` during `webiny serve` and the AWS deploy).\n * When it's absent — a CLI-less self-hosted deploy that boots the built handler directly (e.g.\n * `node start.mjs`) — derive the same org, project and api key straight from the runtime env, so a\n * fresh license can still be fetched.\n */\nexport function resolveWcpProjectEnvironment(): WcpProjectEnvironment | null {\n const fromBlob = getWcpProjectEnvironment();\n if (fromBlob) {\n return fromBlob;\n }\n\n const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;\n const apiKey =\n process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;\n if (!projectId || !apiKey) {\n return null;\n }\n\n // WEBINY_PROJECT_ID has an \"orgId/projectId\" shape.\n const [orgId, project] = projectId.split(\"/\");\n if (!orgId || !project) {\n return null;\n }\n\n // `id` is intentionally empty. The WCP backend identifies the specific project environment\n // from the api key (sent as the request's authorization header); the license fetch only uses\n // org/project (URL path) + apiKey (auth), never the environment id. So there's nothing to fill.\n return { id: \"\", apiKey, org: { id: orgId }, project: { id: project } };\n}\n"],"names":["resolveWcpProjectEnvironment","fromBlob","getWcpProjectEnvironment","projectId","process","apiKey","orgId","project"],"mappings":";AAUO,SAASA;IACZ,MAAMC,WAAWC;IACjB,IAAID,UACA,OAAOA;IAGX,MAAME,YAAYC,QAAQ,GAAG,CAAC,iBAAiB,IAAIA,QAAQ,GAAG,CAAC,cAAc;IAC7E,MAAMC,SACFD,QAAQ,GAAG,CAAC,sBAAsB,IAAIA,QAAQ,GAAG,CAAC,+BAA+B;IACrF,IAAI,CAACD,aAAa,CAACE,QACf,OAAO;IAIX,MAAM,CAACC,OAAOC,QAAQ,GAAGJ,UAAU,KAAK,CAAC;IACzC,IAAI,CAACG,SAAS,CAACC,SACX,OAAO;IAMX,OAAO;QAAE,IAAI;QAAIF;QAAQ,KAAK;YAAE,IAAIC;QAAM;QAAG,SAAS;YAAE,IAAIC;QAAQ;IAAE;AAC1E"}
@@ -0,0 +1,9 @@
1
+ import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
+ import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
3
+ declare class FeatureFlagsSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
4
+ execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
5
+ }
6
+ export declare const FeatureFlagsSchemaFactory: typeof FeatureFlagsSchemaFactoryImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.core").ICoreGraphQLSchemaFactory>;
8
+ };
9
+ export {};
@@ -0,0 +1,49 @@
1
+ import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
+ import { ErrorResponse, Response } from "@webiny/api-graphql/responses.js";
3
+ import { FeatureFlags } from "../../features/featureFlags/abstractions.js";
4
+ class FeatureFlagsSchemaFactoryImpl {
5
+ async execute(builder) {
6
+ builder.addTypeDefs(`
7
+ type FeatureFlagsError {
8
+ code: String
9
+ message: String
10
+ data: JSON
11
+ }
12
+
13
+ type FeatureFlagsResponse {
14
+ data: JSON
15
+ error: FeatureFlagsError
16
+ }
17
+
18
+ extend type Query {
19
+ featureFlags: FeatureFlagsResponse
20
+ }
21
+ `);
22
+ builder.addResolver({
23
+ path: "Query.featureFlags",
24
+ dependencies: [
25
+ FeatureFlags
26
+ ],
27
+ resolver: (featureFlags)=>async ()=>{
28
+ try {
29
+ return new Response(featureFlags.get().toDto());
30
+ } catch (e) {
31
+ return new ErrorResponse({
32
+ code: "COULD_NOT_GET_FEATURE_FLAGS",
33
+ message: e.message,
34
+ data: null,
35
+ stack: e.stack
36
+ });
37
+ }
38
+ }
39
+ });
40
+ return builder;
41
+ }
42
+ }
43
+ const FeatureFlagsSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
44
+ implementation: FeatureFlagsSchemaFactoryImpl,
45
+ dependencies: []
46
+ });
47
+ export { FeatureFlagsSchemaFactory };
48
+
49
+ //# sourceMappingURL=FeatureFlagsSchemaFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql/featureFlags/FeatureFlagsSchemaFactory.js","sources":["../../../src/graphql/featureFlags/FeatureFlagsSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { FeatureFlags } from \"~/features/featureFlags/abstractions.js\";\n\nclass FeatureFlagsSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type FeatureFlagsError {\n code: String\n message: String\n data: JSON\n }\n\n type FeatureFlagsResponse {\n data: JSON\n error: FeatureFlagsError\n }\n\n extend type Query {\n featureFlags: FeatureFlagsResponse\n }\n `);\n\n builder.addResolver({\n path: \"Query.featureFlags\",\n dependencies: [FeatureFlags],\n resolver: (featureFlags: FeatureFlags.Interface) => async () => {\n try {\n return new Response(featureFlags.get().toDto());\n } catch (e) {\n return new ErrorResponse({\n code: \"COULD_NOT_GET_FEATURE_FLAGS\",\n message: e.message,\n data: null,\n stack: e.stack\n });\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const FeatureFlagsSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: FeatureFlagsSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["FeatureFlagsSchemaFactoryImpl","builder","FeatureFlags","featureFlags","Response","e","ErrorResponse","FeatureFlagsSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;AAKA,MAAMA;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;QAenC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAa;YAC5B,UAAU,CAACC,eAAyC;oBAChD,IAAI;wBACA,OAAO,IAAIC,SAASD,aAAa,GAAG,GAAG,KAAK;oBAChD,EAAE,OAAOE,GAAG;wBACR,OAAO,IAAIC,cAAc;4BACrB,MAAM;4BACN,SAASD,EAAE,OAAO;4BAClB,MAAM;4BACN,OAAOA,EAAE,KAAK;wBAClB;oBACJ;gBACJ;QACJ;QAEA,OAAOJ;IACX;AACJ;AAEO,MAAMM,4BAA4BC,yBAAyB,oBAAoB,CAAC;IACnF,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
@@ -18,6 +18,8 @@ class WcpSchemaFactoryImpl {
18
18
  recordLocking: WcpProjectPackageFeaturesFeature
19
19
  fileManager: WcpProjectPackageFeaturesFeature
20
20
  aiPowerups: WcpProjectPackageFeaturesFeature
21
+ abTesting: WcpProjectPackageFeaturesFeature
22
+ remoteComponents: WcpProjectPackageFeaturesFeature
21
23
  }
22
24
 
23
25
  type WcpProjectPackage {
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/wcp/WcpSchemaFactory.js","sources":["../../../src/graphql/wcp/WcpSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { WcpContext } from \"~/features/wcp/WcpContext/index.js\";\n\nclass WcpSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type WcpProjectPackageFeaturesFeature {\n enabled: Boolean\n options: JSON\n }\n\n type WcpProjectPackageFeatures {\n seats: WcpProjectPackageFeaturesFeature\n multiTenancy: WcpProjectPackageFeaturesFeature\n advancedPublishingWorkflow: WcpProjectPackageFeaturesFeature\n advancedAccessControlLayer: WcpProjectPackageFeaturesFeature\n auditLogs: WcpProjectPackageFeaturesFeature\n recordLocking: WcpProjectPackageFeaturesFeature\n fileManager: WcpProjectPackageFeaturesFeature\n aiPowerups: WcpProjectPackageFeaturesFeature\n }\n\n type WcpProjectPackage {\n features: WcpProjectPackageFeatures\n }\n\n type WcpProject {\n orgId: ID\n projectId: ID\n package: WcpProjectPackage\n }\n\n type WcpError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type WcpProjectResponse {\n data: WcpProject\n error: WcpError\n }\n\n type WcpQuery {\n getProject: WcpProjectResponse\n }\n\n type WcpMutation {\n updateProject: WcpProjectResponse\n }\n\n extend type Query {\n wcp: WcpQuery\n }\n\n extend type Mutation {\n wcp: WcpMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.wcp\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"WcpQuery.getProject\",\n dependencies: [WcpContext],\n resolver: (wcpContext: WcpContext.Interface) => async () => {\n try {\n const project = wcpContext.getProjectWithFeatureFlags();\n\n if (!project) {\n throw Error(`Could not get project!`);\n }\n\n return new Response(project);\n } catch (e) {\n return new ErrorResponse({\n code: \"COULD_NOT_GET_PROJECT\",\n message: e.message,\n data: null,\n stack: e.stack\n });\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const WcpSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: WcpSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["WcpSchemaFactoryImpl","builder","WcpContext","wcpContext","project","Error","Response","e","ErrorResponse","WcpSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;AAKA,MAAMA;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsDnC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAW;YAC1B,UAAU,CAACC,aAAqC;oBAC5C,IAAI;wBACA,MAAMC,UAAUD,WAAW,0BAA0B;wBAErD,IAAI,CAACC,SACD,MAAMC,MAAM;wBAGhB,OAAO,IAAIC,SAASF;oBACxB,EAAE,OAAOG,GAAG;wBACR,OAAO,IAAIC,cAAc;4BACrB,MAAM;4BACN,SAASD,EAAE,OAAO;4BAClB,MAAM;4BACN,OAAOA,EAAE,KAAK;wBAClB;oBACJ;gBACJ;QACJ;QAEA,OAAON;IACX;AACJ;AAEO,MAAMQ,mBAAmBC,yBAAyB,oBAAoB,CAAC;IAC1E,gBAAgBV;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"graphql/wcp/WcpSchemaFactory.js","sources":["../../../src/graphql/wcp/WcpSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { WcpContext } from \"~/features/wcp/WcpContext/index.js\";\n\nclass WcpSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type WcpProjectPackageFeaturesFeature {\n enabled: Boolean\n options: JSON\n }\n\n type WcpProjectPackageFeatures {\n seats: WcpProjectPackageFeaturesFeature\n multiTenancy: WcpProjectPackageFeaturesFeature\n advancedPublishingWorkflow: WcpProjectPackageFeaturesFeature\n advancedAccessControlLayer: WcpProjectPackageFeaturesFeature\n auditLogs: WcpProjectPackageFeaturesFeature\n recordLocking: WcpProjectPackageFeaturesFeature\n fileManager: WcpProjectPackageFeaturesFeature\n aiPowerups: WcpProjectPackageFeaturesFeature\n abTesting: WcpProjectPackageFeaturesFeature\n remoteComponents: WcpProjectPackageFeaturesFeature\n }\n\n type WcpProjectPackage {\n features: WcpProjectPackageFeatures\n }\n\n type WcpProject {\n orgId: ID\n projectId: ID\n package: WcpProjectPackage\n }\n\n type WcpError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type WcpProjectResponse {\n data: WcpProject\n error: WcpError\n }\n\n type WcpQuery {\n getProject: WcpProjectResponse\n }\n\n type WcpMutation {\n updateProject: WcpProjectResponse\n }\n\n extend type Query {\n wcp: WcpQuery\n }\n\n extend type Mutation {\n wcp: WcpMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.wcp\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"WcpQuery.getProject\",\n dependencies: [WcpContext],\n resolver: (wcpContext: WcpContext.Interface) => async () => {\n try {\n const project = wcpContext.getProjectWithFeatureFlags();\n\n if (!project) {\n throw Error(`Could not get project!`);\n }\n\n return new Response(project);\n } catch (e) {\n return new ErrorResponse({\n code: \"COULD_NOT_GET_PROJECT\",\n message: e.message,\n data: null,\n stack: e.stack\n });\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const WcpSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: WcpSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["WcpSchemaFactoryImpl","builder","WcpContext","wcpContext","project","Error","Response","e","ErrorResponse","WcpSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;AAKA,MAAMA;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwDnC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAW;YAC1B,UAAU,CAACC,aAAqC;oBAC5C,IAAI;wBACA,MAAMC,UAAUD,WAAW,0BAA0B;wBAErD,IAAI,CAACC,SACD,MAAMC,MAAM;wBAGhB,OAAO,IAAIC,SAASF;oBACxB,EAAE,OAAOG,GAAG;wBACR,OAAO,IAAIC,cAAc;4BACrB,MAAM;4BACN,SAASD,EAAE,OAAO;4BAClB,MAAM;4BACN,OAAOA,EAAE,KAAK;wBAClB;oBACJ;gBACJ;QACJ;QAEA,OAAON;IACX;AACJ;AAEO,MAAMQ,mBAAmBC,yBAAyB,oBAAoB,CAAC;IAC1E,gBAAgBV;IAChB,cAAc,EAAE;AACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-core",
3
- "version": "6.6.0-alpha.0",
3
+ "version": "6.6.0-alpha.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,36 +14,36 @@
14
14
  "./*": "./*"
15
15
  },
16
16
  "dependencies": {
17
- "@ai-sdk/anthropic": "4.0.23",
18
- "@ai-sdk/openai": "4.0.22",
19
- "@webiny/api": "6.6.0-alpha.0",
20
- "@webiny/api-graphql": "6.6.0-alpha.0",
21
- "@webiny/di": "1.0.2",
22
- "@webiny/error": "6.6.0-alpha.0",
23
- "@webiny/feature": "6.6.0-alpha.0",
24
- "@webiny/feature-flags": "6.6.0-alpha.0",
25
- "@webiny/handler": "6.6.0-alpha.0",
26
- "@webiny/utils": "6.6.0-alpha.0",
27
- "@webiny/wcp": "6.6.0-alpha.0",
28
- "ai": "7.0.40",
17
+ "@ai-sdk/anthropic": "4.0.40",
18
+ "@ai-sdk/openai": "4.0.45",
19
+ "@webiny/api": "6.6.0-alpha.1",
20
+ "@webiny/api-graphql": "6.6.0-alpha.1",
21
+ "@webiny/di": "1.1.0",
22
+ "@webiny/error": "6.6.0-alpha.1",
23
+ "@webiny/feature": "6.6.0-alpha.1",
24
+ "@webiny/feature-flags": "6.6.0-alpha.1",
25
+ "@webiny/handler": "6.6.0-alpha.1",
26
+ "@webiny/utils": "6.6.0-alpha.1",
27
+ "@webiny/wcp": "6.6.0-alpha.1",
28
+ "ai": "7.0.73",
29
29
  "dataloader": "2.2.3",
30
30
  "graphql": "16.14.2",
31
- "jose": "6.2.4",
31
+ "jose": "6.2.9",
32
32
  "jsonwebtoken": "9.0.3",
33
33
  "lodash": "4.18.1",
34
34
  "minimatch": "10.2.6",
35
35
  "pino": "10.3.1",
36
36
  "pino-lambda": "4.4.1",
37
+ "slugify": "1.6.9",
37
38
  "zod": "4.4.3"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/jsonwebtoken": "9.0.10",
41
- "@webiny/build-tools": "6.6.0-alpha.0",
42
- "@webiny/event-handler-core": "6.6.0-alpha.0",
43
- "@webiny/project-utils": "6.6.0-alpha.0",
42
+ "@webiny/build-tools": "6.6.0-alpha.1",
43
+ "@webiny/event-handler-core": "6.6.0-alpha.1",
44
44
  "rimraf": "6.1.3",
45
45
  "typescript": "7.0.2",
46
- "vitest": "4.1.10"
46
+ "vitest": "4.1.11"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
@@ -0,0 +1,14 @@
1
+ export type Plugin<T = Record<string, any>> = {
2
+ type: string;
3
+ name?: string;
4
+ init?: () => void;
5
+ [key: string]: any;
6
+ } & T;
7
+ export type PluginCollection = (Plugin | PluginCollection)[];
8
+ export interface StorageOperations<T = any> {
9
+ storageOperations: T;
10
+ plugins: PluginCollection;
11
+ }
12
+ export declare const getStorageOps: <T = any>(app: string) => StorageOperations<T>;
13
+ export declare const setStorageOps: (app: string, factory: () => StorageOperations) => void;
14
+ export declare const clearStorageOps: () => void;
@@ -0,0 +1,18 @@
1
+ const getStorageOps = (app)=>{
2
+ const storageOps = globalThis["__storageOps"];
3
+ if (void 0 === storageOps) throw new Error("Storage ops are not configured!");
4
+ const appStorageOps = storageOps[app];
5
+ if (void 0 === appStorageOps) throw new Error(`Storage ops for "${app}" are not configured! Have you configured "jest.setup.js" correctly?`);
6
+ return appStorageOps();
7
+ };
8
+ const setStorageOps = (app, factory)=>{
9
+ const storageOps = globalThis["__storageOps"] || {};
10
+ storageOps[app] = factory;
11
+ globalThis["__storageOps"] = storageOps;
12
+ };
13
+ const clearStorageOps = ()=>{
14
+ delete globalThis["__storageOps"];
15
+ };
16
+ export { clearStorageOps, getStorageOps, setStorageOps };
17
+
18
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing/environment.js","sources":["../../src/testing/environment.ts"],"sourcesContent":["export type Plugin<T = Record<string, any>> = {\n type: string;\n name?: string;\n init?: () => void;\n [key: string]: any;\n} & T;\n\nexport type PluginCollection = (Plugin | PluginCollection)[];\n\nexport interface StorageOperations<T = any> {\n storageOperations: T;\n plugins: PluginCollection;\n}\n\nexport const getStorageOps = <T = any>(app: string): StorageOperations<T> => {\n const storageOps = (globalThis as Record<string, any>)[\"__storageOps\"];\n\n if (typeof storageOps === \"undefined\") {\n throw new Error(`Storage ops are not configured!`);\n }\n\n const appStorageOps = storageOps[app];\n if (typeof appStorageOps === \"undefined\") {\n throw new Error(\n `Storage ops for \"${app}\" are not configured! Have you configured \"jest.setup.js\" correctly?`\n );\n }\n\n return appStorageOps();\n};\n\nexport const setStorageOps = (app: string, factory: () => StorageOperations): void => {\n const storageOps = (globalThis as Record<string, any>)[\"__storageOps\"] || {};\n storageOps[app] = factory;\n (globalThis as Record<string, any>)[\"__storageOps\"] = storageOps;\n};\n\nexport const clearStorageOps = (): void => {\n delete (globalThis as Record<string, any>)[\"__storageOps\"];\n};\n"],"names":["getStorageOps","app","storageOps","globalThis","Error","appStorageOps","setStorageOps","factory","clearStorageOps"],"mappings":"AAcO,MAAMA,gBAAgB,CAAUC;IACnC,MAAMC,aAAcC,UAAkC,CAAC,eAAe;IAEtE,IAAI,AAAsB,WAAfD,YACP,MAAM,IAAIE,MAAM;IAGpB,MAAMC,gBAAgBH,UAAU,CAACD,IAAI;IACrC,IAAI,AAAyB,WAAlBI,eACP,MAAM,IAAID,MACN,CAAC,iBAAiB,EAAEH,IAAI,oEAAoE,CAAC;IAIrG,OAAOI;AACX;AAEO,MAAMC,gBAAgB,CAACL,KAAaM;IACvC,MAAML,aAAcC,UAAkC,CAAC,eAAe,IAAI,CAAC;IAC3ED,UAAU,CAACD,IAAI,GAAGM;IACjBJ,UAAkC,CAAC,eAAe,GAAGD;AAC1D;AAEO,MAAMM,kBAAkB;IAC3B,OAAQL,UAAkC,CAAC,eAAe;AAC9D"}
@@ -129,7 +129,7 @@ export interface StorageApiKey {
129
129
  name: string;
130
130
  slug: string;
131
131
  description: string;
132
- token: string;
132
+ token: `wat_${string}`;
133
133
  permissions: SecurityPermission[];
134
134
  createdBy: CreatedBy;
135
135
  createdOn: string;
@@ -1,2 +0,0 @@
1
- import type { DecryptedWcpProjectLicense, ILicense } from "@webiny/wcp/types.js";
2
- export declare function loadWcpLicense(testProjectLicense?: DecryptedWcpProjectLicense): Promise<ILicense>;
@@ -1,51 +0,0 @@
1
- import { License, NullLicense, getWcpProjectEnvironment, getWcpProjectLicense } from "@webiny/wcp";
2
- import { getWcpProjectLicenseCacheKey } from "./WcpContext/utils.js";
3
- function resolveWcpProjectEnvironment() {
4
- const fromBlob = getWcpProjectEnvironment();
5
- if (fromBlob) return fromBlob;
6
- const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;
7
- const apiKey = process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;
8
- if (!projectId || !apiKey) return null;
9
- const [orgId, project] = projectId.split("/");
10
- if (!orgId || !project) return null;
11
- return {
12
- id: "",
13
- apiKey,
14
- org: {
15
- id: orgId
16
- },
17
- project: {
18
- id: project
19
- }
20
- };
21
- }
22
- const wcpProjectEnvironment = resolveWcpProjectEnvironment();
23
- const cachedLicense = {
24
- cacheKey: null,
25
- project: null,
26
- license: new NullLicense()
27
- };
28
- async function loadWcpLicense(testProjectLicense) {
29
- if (testProjectLicense) cachedLicense.license = License.fromLicenseDto(testProjectLicense);
30
- else if (wcpProjectEnvironment) {
31
- const currentCacheKey = getWcpProjectLicenseCacheKey();
32
- if (cachedLicense.cacheKey !== currentCacheKey) {
33
- cachedLicense.cacheKey = currentCacheKey;
34
- const decryptedLicenseDto = await getWcpProjectLicense({
35
- orgId: wcpProjectEnvironment.org.id,
36
- projectId: wcpProjectEnvironment.project.id,
37
- projectEnvironmentApiKey: wcpProjectEnvironment.apiKey
38
- });
39
- if (decryptedLicenseDto) cachedLicense.project = {
40
- orgId: decryptedLicenseDto.orgId,
41
- projectId: decryptedLicenseDto.projectId,
42
- package: decryptedLicenseDto.package
43
- };
44
- cachedLicense.license = License.fromLicenseDto(decryptedLicenseDto);
45
- }
46
- }
47
- return cachedLicense.license;
48
- }
49
- export { loadWcpLicense };
50
-
51
- //# sourceMappingURL=loadWcpLicense.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/wcp/loadWcpLicense.js","sources":["../../../src/features/wcp/loadWcpLicense.ts"],"sourcesContent":["import { getWcpProjectLicense, getWcpProjectEnvironment, NullLicense } from \"@webiny/wcp\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProjectEnvironment\n} from \"@webiny/wcp/types.js\";\nimport { License } from \"@webiny/wcp\";\nimport type { CachedWcpProjectLicense } from \"~/features/wcp/WcpContext/types.js\";\nimport { getWcpProjectLicenseCacheKey } from \"~/features/wcp/WcpContext/utils.js\";\n\n/**\n * Resolve the WCP project environment used to fetch the license. Prefer the CLI-computed\n * WCP_PROJECT_ENVIRONMENT blob (set by `applyWcpEnvVars` during `webiny serve` and the AWS deploy).\n * When it's absent — a CLI-less self-hosted deploy that boots the built handler directly (e.g.\n * `node start.mjs`) — derive the same org, project and api key straight from the runtime env, so a\n * fresh license can still be fetched.\n */\nfunction resolveWcpProjectEnvironment(): WcpProjectEnvironment | null {\n const fromBlob = getWcpProjectEnvironment();\n if (fromBlob) {\n return fromBlob;\n }\n\n const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;\n const apiKey =\n process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;\n if (!projectId || !apiKey) {\n return null;\n }\n\n // WEBINY_PROJECT_ID has an \"orgId/projectId\" shape.\n const [orgId, project] = projectId.split(\"/\");\n if (!orgId || !project) {\n return null;\n }\n\n // `id` is intentionally empty. The WCP backend identifies the specific project environment\n // from the api key (sent as the request's authorization header); the license fetch only uses\n // org/project (URL path) + apiKey (auth), never the environment id. So there's nothing to fill.\n return { id: \"\", apiKey, org: { id: orgId }, project: { id: project } };\n}\n\nconst wcpProjectEnvironment = resolveWcpProjectEnvironment();\n\nconst cachedLicense: CachedWcpProjectLicense = {\n cacheKey: null,\n project: null,\n license: new NullLicense()\n};\n\nexport async function loadWcpLicense(\n testProjectLicense?: DecryptedWcpProjectLicense\n): Promise<ILicense> {\n if (testProjectLicense) {\n cachedLicense.license = License.fromLicenseDto(testProjectLicense);\n } else if (wcpProjectEnvironment) {\n const currentCacheKey = getWcpProjectLicenseCacheKey();\n if (cachedLicense.cacheKey !== currentCacheKey) {\n cachedLicense.cacheKey = currentCacheKey;\n // Pull the project license from the WCP API.\n const decryptedLicenseDto = await getWcpProjectLicense({\n orgId: wcpProjectEnvironment.org.id,\n projectId: wcpProjectEnvironment.project.id,\n projectEnvironmentApiKey: wcpProjectEnvironment.apiKey\n });\n\n if (decryptedLicenseDto) {\n cachedLicense.project = {\n orgId: decryptedLicenseDto.orgId,\n projectId: decryptedLicenseDto.projectId,\n package: decryptedLicenseDto.package\n };\n }\n\n cachedLicense.license = License.fromLicenseDto(decryptedLicenseDto);\n }\n }\n\n return cachedLicense.license;\n}\n"],"names":["resolveWcpProjectEnvironment","fromBlob","getWcpProjectEnvironment","projectId","process","apiKey","orgId","project","wcpProjectEnvironment","cachedLicense","NullLicense","loadWcpLicense","testProjectLicense","License","currentCacheKey","getWcpProjectLicenseCacheKey","decryptedLicenseDto","getWcpProjectLicense"],"mappings":";;AAiBA,SAASA;IACL,MAAMC,WAAWC;IACjB,IAAID,UACA,OAAOA;IAGX,MAAME,YAAYC,QAAQ,GAAG,CAAC,iBAAiB,IAAIA,QAAQ,GAAG,CAAC,cAAc;IAC7E,MAAMC,SACFD,QAAQ,GAAG,CAAC,sBAAsB,IAAIA,QAAQ,GAAG,CAAC,+BAA+B;IACrF,IAAI,CAACD,aAAa,CAACE,QACf,OAAO;IAIX,MAAM,CAACC,OAAOC,QAAQ,GAAGJ,UAAU,KAAK,CAAC;IACzC,IAAI,CAACG,SAAS,CAACC,SACX,OAAO;IAMX,OAAO;QAAE,IAAI;QAAIF;QAAQ,KAAK;YAAE,IAAIC;QAAM;QAAG,SAAS;YAAE,IAAIC;QAAQ;IAAE;AAC1E;AAEA,MAAMC,wBAAwBR;AAE9B,MAAMS,gBAAyC;IAC3C,UAAU;IACV,SAAS;IACT,SAAS,IAAIC;AACjB;AAEO,eAAeC,eAClBC,kBAA+C;IAE/C,IAAIA,oBACAH,cAAc,OAAO,GAAGI,QAAQ,cAAc,CAACD;SAC5C,IAAIJ,uBAAuB;QAC9B,MAAMM,kBAAkBC;QACxB,IAAIN,cAAc,QAAQ,KAAKK,iBAAiB;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