every-plugin 2.10.1 → 3.0.0-rc.10
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.
- package/bin/every-plugin-serve.mjs +12 -0
- package/bin/every-plugin.mjs +59 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/build/artifact-names.cjs +119 -0
- package/dist/build/artifact-names.cjs.map +1 -0
- package/dist/build/artifact-names.d.cts +68 -0
- package/dist/build/artifact-names.d.cts.map +1 -0
- package/dist/build/artifact-names.d.mts +68 -0
- package/dist/build/artifact-names.d.mts.map +1 -0
- package/dist/build/artifact-names.mjs +102 -0
- package/dist/build/artifact-names.mjs.map +1 -0
- package/dist/build/contract-types.cjs +89 -0
- package/dist/build/contract-types.cjs.map +1 -0
- package/dist/build/contract-types.mjs +81 -0
- package/dist/build/contract-types.mjs.map +1 -0
- package/dist/build/rspack/build-report-plugin.cjs +37 -0
- package/dist/build/rspack/build-report-plugin.cjs.map +1 -0
- package/dist/build/rspack/build-report-plugin.d.cts +18 -0
- package/dist/build/rspack/build-report-plugin.d.cts.map +1 -0
- package/dist/build/rspack/build-report-plugin.d.mts +18 -0
- package/dist/build/rspack/build-report-plugin.d.mts.map +1 -0
- package/dist/build/rspack/build-report-plugin.mjs +37 -0
- package/dist/build/rspack/build-report-plugin.mjs.map +1 -0
- package/dist/build/rspack/chunk-completeness-plugin.cjs +59 -0
- package/dist/build/rspack/chunk-completeness-plugin.cjs.map +1 -0
- package/dist/build/rspack/chunk-completeness-plugin.mjs +59 -0
- package/dist/build/rspack/chunk-completeness-plugin.mjs.map +1 -0
- package/dist/build/rspack/compose.cjs +69 -0
- package/dist/build/rspack/compose.cjs.map +1 -0
- package/dist/build/rspack/compose.d.cts +20 -0
- package/dist/build/rspack/compose.d.cts.map +1 -0
- package/dist/build/rspack/compose.d.mts +20 -0
- package/dist/build/rspack/compose.d.mts.map +1 -0
- package/dist/build/rspack/compose.mjs +65 -0
- package/dist/build/rspack/compose.mjs.map +1 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +11 -11
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +2 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +2 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +11 -10
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -1
- package/dist/build/rspack/generated-config.cjs +35 -0
- package/dist/build/rspack/generated-config.cjs.map +1 -0
- package/dist/build/rspack/generated-config.mjs +32 -0
- package/dist/build/rspack/generated-config.mjs.map +1 -0
- package/dist/build/rspack/index.cjs +8 -5
- package/dist/build/rspack/index.d.cts +5 -3
- package/dist/build/rspack/index.d.mts +5 -3
- package/dist/build/rspack/index.mjs +5 -3
- package/dist/build/rspack/module-federation.cjs +2 -2
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs +1 -1
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/build/rspack/plugin.cjs +44 -69
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.d.cts +4 -13
- package/dist/build/rspack/plugin.d.cts.map +1 -1
- package/dist/build/rspack/plugin.d.mts +4 -13
- package/dist/build/rspack/plugin.d.mts.map +1 -1
- package/dist/build/rspack/plugin.mjs +44 -69
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/build/rspack/utils.cjs +7 -5
- package/dist/build/rspack/utils.cjs.map +1 -1
- package/dist/build/rspack/utils.mjs +7 -6
- package/dist/build/rspack/utils.mjs.map +1 -1
- package/dist/build/ui/factory.cjs +88 -0
- package/dist/build/ui/factory.cjs.map +1 -0
- package/dist/build/ui/factory.d.cts +11 -0
- package/dist/build/ui/factory.d.cts.map +1 -0
- package/dist/build/ui/factory.d.mts +11 -0
- package/dist/build/ui/factory.d.mts.map +1 -0
- package/dist/build/ui/factory.mjs +80 -0
- package/dist/build/ui/factory.mjs.map +1 -0
- package/dist/build/ui/generated-config.cjs +122 -0
- package/dist/build/ui/generated-config.cjs.map +1 -0
- package/dist/build/ui/generated-config.d.cts +33 -0
- package/dist/build/ui/generated-config.d.cts.map +1 -0
- package/dist/build/ui/generated-config.d.mts +33 -0
- package/dist/build/ui/generated-config.d.mts.map +1 -0
- package/dist/build/ui/generated-config.mjs +114 -0
- package/dist/build/ui/generated-config.mjs.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.cjs +61 -0
- package/dist/build/ui/hash-artifacts-plugin.cjs.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.d.cts +20 -0
- package/dist/build/ui/hash-artifacts-plugin.d.cts.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.d.mts +20 -0
- package/dist/build/ui/hash-artifacts-plugin.d.mts.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.mjs +58 -0
- package/dist/build/ui/hash-artifacts-plugin.mjs.map +1 -0
- package/dist/build/ui/index.cjs +90 -0
- package/dist/build/ui/index.cjs.map +1 -0
- package/dist/build/ui/index.d.cts +29 -0
- package/dist/build/ui/index.d.cts.map +1 -0
- package/dist/build/ui/index.d.mts +29 -0
- package/dist/build/ui/index.d.mts.map +1 -0
- package/dist/build/ui/index.mjs +68 -0
- package/dist/build/ui/index.mjs.map +1 -0
- package/dist/build/ui/manifest-plugin.cjs +37 -0
- package/dist/build/ui/manifest-plugin.cjs.map +1 -0
- package/dist/build/ui/manifest-plugin.d.cts +19 -0
- package/dist/build/ui/manifest-plugin.d.cts.map +1 -0
- package/dist/build/ui/manifest-plugin.d.mts +19 -0
- package/dist/build/ui/manifest-plugin.d.mts.map +1 -0
- package/dist/build/ui/manifest-plugin.mjs +37 -0
- package/dist/build/ui/manifest-plugin.mjs.map +1 -0
- package/dist/build/ui/rsbuild-config.cjs +203 -0
- package/dist/build/ui/rsbuild-config.cjs.map +1 -0
- package/dist/build/ui/rsbuild-config.d.cts +45 -0
- package/dist/build/ui/rsbuild-config.d.cts.map +1 -0
- package/dist/build/ui/rsbuild-config.d.mts +45 -0
- package/dist/build/ui/rsbuild-config.d.mts.map +1 -0
- package/dist/build/ui/rsbuild-config.mjs +200 -0
- package/dist/build/ui/rsbuild-config.mjs.map +1 -0
- package/dist/build/ui/stubs.cjs +107 -0
- package/dist/build/ui/stubs.cjs.map +1 -0
- package/dist/build/ui/stubs.d.cts +25 -0
- package/dist/build/ui/stubs.d.cts.map +1 -0
- package/dist/build/ui/stubs.d.mts +25 -0
- package/dist/build/ui/stubs.d.mts.map +1 -0
- package/dist/build/ui/stubs.mjs +106 -0
- package/dist/build/ui/stubs.mjs.map +1 -0
- package/dist/cli.cjs +83 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +6 -0
- package/dist/cli.d.cts.map +1 -0
- package/dist/cli.d.mts +6 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +82 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/client.cjs +69 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +15 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.mts +15 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +68 -0
- package/dist/client.mjs.map +1 -0
- package/dist/dev/host.cjs +149 -0
- package/dist/dev/host.cjs.map +1 -0
- package/dist/dev/host.d.cts +32 -0
- package/dist/dev/host.d.cts.map +1 -0
- package/dist/dev/host.d.mts +32 -0
- package/dist/dev/host.d.mts.map +1 -0
- package/dist/dev/host.mjs +148 -0
- package/dist/dev/host.mjs.map +1 -0
- package/dist/dev/serve.cjs +295 -0
- package/dist/dev/serve.cjs.map +1 -0
- package/dist/dev/serve.d.cts +23 -0
- package/dist/dev/serve.d.cts.map +1 -0
- package/dist/dev/serve.d.mts +23 -0
- package/dist/dev/serve.d.mts.map +1 -0
- package/dist/dev/serve.mjs +289 -0
- package/dist/dev/serve.mjs.map +1 -0
- package/dist/dev/watch-kill.cjs +39 -0
- package/dist/dev/watch-kill.cjs.map +1 -0
- package/dist/dev/watch-kill.mjs +38 -0
- package/dist/dev/watch-kill.mjs.map +1 -0
- package/dist/effect-helpers.cjs +23 -0
- package/dist/effect-helpers.cjs.map +1 -0
- package/dist/effect-helpers.d.cts +20 -0
- package/dist/effect-helpers.d.cts.map +1 -0
- package/dist/effect-helpers.d.mts +20 -0
- package/dist/effect-helpers.d.mts.map +1 -0
- package/dist/effect-helpers.mjs +22 -0
- package/dist/effect-helpers.mjs.map +1 -0
- package/dist/errors.cjs +50 -69
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +13 -96
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +13 -96
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +16 -34
- package/dist/errors.mjs.map +1 -1
- package/dist/identity.cjs +19 -0
- package/dist/identity.cjs.map +1 -0
- package/dist/identity.d.cts +33 -0
- package/dist/identity.d.cts.map +1 -0
- package/dist/identity.d.mts +33 -0
- package/dist/identity.d.mts.map +1 -0
- package/dist/identity.mjs +16 -0
- package/dist/identity.mjs.map +1 -0
- package/dist/index.cjs +11 -5
- package/dist/index.d.cts +9 -6
- package/dist/index.d.mts +9 -6
- package/dist/index.mjs +7 -4
- package/dist/plugin.cjs +13 -26
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +64 -25
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +64 -25
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +16 -29
- package/dist/plugin.mjs.map +1 -1
- package/dist/remote-entry.cjs +102 -0
- package/dist/remote-entry.cjs.map +1 -0
- package/dist/remote-entry.d.cts +52 -0
- package/dist/remote-entry.d.cts.map +1 -0
- package/dist/remote-entry.d.mts +52 -0
- package/dist/remote-entry.d.mts.map +1 -0
- package/dist/remote-entry.mjs +98 -0
- package/dist/remote-entry.mjs.map +1 -0
- package/dist/runtime/errors.cjs +159 -33
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.d.cts +64 -7
- package/dist/runtime/errors.d.cts.map +1 -1
- package/dist/runtime/errors.d.mts +64 -7
- package/dist/runtime/errors.d.mts.map +1 -1
- package/dist/runtime/errors.mjs +154 -30
- package/dist/runtime/errors.mjs.map +1 -1
- package/dist/runtime/index.cjs +95 -23
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +16 -0
- package/dist/runtime/index.d.cts.map +1 -1
- package/dist/runtime/index.d.mts +16 -0
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +98 -26
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +3 -78
- package/dist/runtime/mf-config.cjs.map +1 -1
- package/dist/runtime/mf-config.d.cts +3 -49
- package/dist/runtime/mf-config.d.cts.map +1 -1
- package/dist/runtime/mf-config.d.mts +3 -49
- package/dist/runtime/mf-config.d.mts.map +1 -1
- package/dist/runtime/mf-config.mjs +5 -78
- package/dist/runtime/mf-config.mjs.map +1 -1
- package/dist/runtime/services/module-federation.service.cjs +57 -12
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts +4 -13
- package/dist/runtime/services/module-federation.service.d.mts +4 -13
- package/dist/runtime/services/module-federation.service.mjs +57 -14
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/normalize.cjs +2 -22
- package/dist/runtime/services/normalize.d.cts +2 -21
- package/dist/runtime/services/normalize.d.mts +2 -21
- package/dist/runtime/services/normalize.mjs +2 -21
- package/dist/runtime/services/plugin-lifecycle.service.cjs +9 -11
- package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts +3 -16
- package/dist/runtime/services/plugin-lifecycle.service.d.mts +3 -16
- package/dist/runtime/services/plugin-lifecycle.service.mjs +10 -13
- package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +59 -30
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts +6 -53
- package/dist/runtime/services/plugin-loader.service.d.mts +6 -53
- package/dist/runtime/services/plugin-loader.service.mjs +58 -31
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
- package/dist/runtime/services/plugin.service.cjs +10 -12
- package/dist/runtime/services/plugin.service.cjs.map +1 -1
- package/dist/runtime/services/plugin.service.d.cts +14 -36
- package/dist/runtime/services/plugin.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin.service.d.mts +14 -36
- package/dist/runtime/services/plugin.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin.service.mjs +14 -18
- package/dist/runtime/services/plugin.service.mjs.map +1 -1
- package/dist/runtime/services/secrets.service.cjs +12 -12
- package/dist/runtime/services/secrets.service.cjs.map +1 -1
- package/dist/runtime/services/secrets.service.d.cts +3 -15
- package/dist/runtime/services/secrets.service.d.mts +3 -15
- package/dist/runtime/services/secrets.service.mjs +12 -13
- package/dist/runtime/services/secrets.service.mjs.map +1 -1
- package/dist/runtime/services/shared-identity.cjs +40 -0
- package/dist/runtime/services/shared-identity.cjs.map +1 -0
- package/dist/runtime/services/shared-identity.mjs +38 -0
- package/dist/runtime/services/shared-identity.mjs.map +1 -0
- package/dist/runtime/validation.cjs +2 -2
- package/dist/runtime/validation.cjs.map +1 -1
- package/dist/runtime/validation.mjs +2 -2
- package/dist/runtime/validation.mjs.map +1 -1
- package/dist/shared-deps-spec.cjs +384 -0
- package/dist/shared-deps-spec.cjs.map +1 -0
- package/dist/shared-deps-spec.d.cts +182 -0
- package/dist/shared-deps-spec.d.cts.map +1 -0
- package/dist/shared-deps-spec.d.mts +182 -0
- package/dist/shared-deps-spec.d.mts.map +1 -0
- package/dist/shared-deps-spec.mjs +368 -0
- package/dist/shared-deps-spec.mjs.map +1 -0
- package/dist/types.d.cts +47 -41
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +47 -41
- package/dist/types.d.mts.map +1 -1
- package/dist/ui/manifest/construct.cjs +319 -0
- package/dist/ui/manifest/construct.cjs.map +1 -0
- package/dist/ui/manifest/construct.d.cts +48 -0
- package/dist/ui/manifest/construct.d.cts.map +1 -0
- package/dist/ui/manifest/construct.d.mts +48 -0
- package/dist/ui/manifest/construct.d.mts.map +1 -0
- package/dist/ui/manifest/construct.mjs +319 -0
- package/dist/ui/manifest/construct.mjs.map +1 -0
- package/dist/ui/manifest/contract.cjs +34 -0
- package/dist/ui/manifest/contract.cjs.map +1 -0
- package/dist/ui/manifest/contract.d.cts +26 -0
- package/dist/ui/manifest/contract.d.cts.map +1 -0
- package/dist/ui/manifest/contract.d.mts +26 -0
- package/dist/ui/manifest/contract.d.mts.map +1 -0
- package/dist/ui/manifest/contract.mjs +26 -0
- package/dist/ui/manifest/contract.mjs.map +1 -0
- package/dist/ui/manifest/descriptor.cjs +64 -0
- package/dist/ui/manifest/descriptor.cjs.map +1 -0
- package/dist/ui/manifest/descriptor.d.cts +60 -0
- package/dist/ui/manifest/descriptor.d.cts.map +1 -0
- package/dist/ui/manifest/descriptor.d.mts +60 -0
- package/dist/ui/manifest/descriptor.d.mts.map +1 -0
- package/dist/ui/manifest/descriptor.mjs +61 -0
- package/dist/ui/manifest/descriptor.mjs.map +1 -0
- package/dist/ui/manifest/generator.cjs +128 -0
- package/dist/ui/manifest/generator.cjs.map +1 -0
- package/dist/ui/manifest/generator.d.cts +41 -0
- package/dist/ui/manifest/generator.d.cts.map +1 -0
- package/dist/ui/manifest/generator.d.mts +41 -0
- package/dist/ui/manifest/generator.d.mts.map +1 -0
- package/dist/ui/manifest/generator.mjs +125 -0
- package/dist/ui/manifest/generator.mjs.map +1 -0
- package/dist/ui/manifest/index.cjs +35 -0
- package/dist/ui/manifest/index.d.cts +9 -0
- package/dist/ui/manifest/index.d.mts +9 -0
- package/dist/ui/manifest/index.mjs +9 -0
- package/dist/ui/manifest/manifest-schema.cjs +97 -0
- package/dist/ui/manifest/manifest-schema.cjs.map +1 -0
- package/dist/ui/manifest/manifest-schema.d.cts +132 -0
- package/dist/ui/manifest/manifest-schema.d.cts.map +1 -0
- package/dist/ui/manifest/manifest-schema.d.mts +132 -0
- package/dist/ui/manifest/manifest-schema.d.mts.map +1 -0
- package/dist/ui/manifest/manifest-schema.mjs +90 -0
- package/dist/ui/manifest/manifest-schema.mjs.map +1 -0
- package/dist/ui/manifest/mount-registry.cjs +52 -0
- package/dist/ui/manifest/mount-registry.cjs.map +1 -0
- package/dist/ui/manifest/mount-registry.d.cts +61 -0
- package/dist/ui/manifest/mount-registry.d.cts.map +1 -0
- package/dist/ui/manifest/mount-registry.d.mts +61 -0
- package/dist/ui/manifest/mount-registry.d.mts.map +1 -0
- package/dist/ui/manifest/mount-registry.mjs +48 -0
- package/dist/ui/manifest/mount-registry.mjs.map +1 -0
- package/dist/ui/manifest/nav.cjs +13 -0
- package/dist/ui/manifest/nav.cjs.map +1 -0
- package/dist/ui/manifest/nav.d.cts +34 -0
- package/dist/ui/manifest/nav.d.cts.map +1 -0
- package/dist/ui/manifest/nav.d.mts +34 -0
- package/dist/ui/manifest/nav.d.mts.map +1 -0
- package/dist/ui/manifest/nav.mjs +13 -0
- package/dist/ui/manifest/nav.mjs.map +1 -0
- package/dist/ui/manifest/route-config.cjs +33 -0
- package/dist/ui/manifest/route-config.cjs.map +1 -0
- package/dist/ui/manifest/route-config.d.cts +40 -0
- package/dist/ui/manifest/route-config.d.cts.map +1 -0
- package/dist/ui/manifest/route-config.d.mts +40 -0
- package/dist/ui/manifest/route-config.d.mts.map +1 -0
- package/dist/ui/manifest/route-config.mjs +33 -0
- package/dist/ui/manifest/route-config.mjs.map +1 -0
- package/dist/version-manifest.cjs +77 -0
- package/dist/version-manifest.cjs.map +1 -0
- package/dist/version-manifest.d.cts +62 -0
- package/dist/version-manifest.d.cts.map +1 -0
- package/dist/version-manifest.d.mts +62 -0
- package/dist/version-manifest.d.mts.map +1 -0
- package/dist/version-manifest.mjs +75 -0
- package/dist/version-manifest.mjs.map +1 -0
- package/package.json +182 -68
- package/skills/plugin-client/SKILL.md +34 -9
- package/skills/plugin-development/SKILL.md +79 -47
- package/skills/plugin-testing/SKILL.md +42 -12
- package/src/build/artifact-names.ts +117 -0
- package/src/build/contract-types.ts +101 -0
- package/src/build/rspack/build-report-plugin.ts +34 -0
- package/src/build/rspack/chunk-completeness-plugin.ts +66 -0
- package/src/build/rspack/compose.ts +87 -0
- package/src/build/rspack/fix-mf-data-uri-plugin.ts +23 -12
- package/src/build/rspack/generated-config.ts +35 -0
- package/src/build/rspack/index.ts +10 -5
- package/src/build/rspack/module-federation.ts +1 -1
- package/src/build/rspack/plugin.ts +103 -105
- package/src/build/rspack/utils.ts +8 -2
- package/src/build/ui/factory.ts +96 -0
- package/src/build/ui/generated-config.ts +137 -0
- package/src/build/ui/hash-artifacts-plugin.ts +79 -0
- package/src/build/ui/index.ts +98 -0
- package/src/build/ui/manifest-plugin.ts +54 -0
- package/src/build/ui/rsbuild-config.ts +256 -0
- package/src/build/ui/stubs.ts +103 -0
- package/src/cli.ts +100 -0
- package/src/client.ts +111 -0
- package/src/dev/host.ts +235 -0
- package/src/dev/serve.ts +359 -0
- package/src/dev/watch-kill.ts +58 -0
- package/src/effect-helpers.ts +25 -0
- package/src/errors.ts +17 -18
- package/src/identity.ts +36 -0
- package/src/index.ts +13 -0
- package/src/plugin.ts +94 -91
- package/src/remote-entry.ts +170 -0
- package/src/runtime/errors.ts +229 -26
- package/src/runtime/index.ts +132 -43
- package/src/runtime/mf-config.ts +12 -107
- package/src/runtime/services/module-federation.service.ts +218 -117
- package/src/runtime/services/normalize.ts +1 -18
- package/src/runtime/services/plugin-lifecycle.service.ts +66 -75
- package/src/runtime/services/plugin-loader.service.ts +280 -209
- package/src/runtime/services/plugin.service.ts +61 -43
- package/src/runtime/services/secrets.service.ts +20 -15
- package/src/runtime/services/shared-identity.ts +68 -0
- package/src/runtime/validation.ts +5 -7
- package/src/shared-deps-spec.ts +478 -0
- package/src/types.ts +62 -50
- package/src/ui/manifest/construct.ts +456 -0
- package/src/ui/manifest/contract.ts +33 -0
- package/src/ui/manifest/descriptor.ts +96 -0
- package/src/ui/manifest/generator.ts +238 -0
- package/src/ui/manifest/index.ts +55 -0
- package/src/ui/manifest/manifest-schema.ts +107 -0
- package/src/ui/manifest/mount-registry.ts +50 -0
- package/src/ui/manifest/nav.ts +43 -0
- package/src/ui/manifest/route-config.ts +82 -0
- package/src/version-manifest.ts +106 -0
- package/dist/build/rspack/dev-server-middleware.cjs +0 -248
- package/dist/build/rspack/dev-server-middleware.cjs.map +0 -1
- package/dist/build/rspack/dev-server-middleware.mjs +0 -247
- package/dist/build/rspack/dev-server-middleware.mjs.map +0 -1
- package/dist/build/shared-deps.cjs +0 -83
- package/dist/build/shared-deps.cjs.map +0 -1
- package/dist/build/shared-deps.d.cts +0 -67
- package/dist/build/shared-deps.d.cts.map +0 -1
- package/dist/build/shared-deps.d.mts +0 -67
- package/dist/build/shared-deps.d.mts.map +0 -1
- package/dist/build/shared-deps.mjs +0 -79
- package/dist/build/shared-deps.mjs.map +0 -1
- package/dist/effect.cjs +0 -9
- package/dist/effect.d.cts +0 -1
- package/dist/effect.d.mts +0 -1
- package/dist/effect.mjs +0 -3
- package/dist/orpc-openapi.cjs +0 -17
- package/dist/orpc-openapi.d.cts +0 -2
- package/dist/orpc-openapi.d.mts +0 -2
- package/dist/orpc-openapi.mjs +0 -5
- package/dist/orpc.cjs +0 -46
- package/dist/orpc.d.cts +0 -7
- package/dist/orpc.d.mts +0 -7
- package/dist/orpc.mjs +0 -11
- package/dist/package.cjs +0 -23
- package/dist/package.cjs.map +0 -1
- package/dist/package.mjs +0 -17
- package/dist/package.mjs.map +0 -1
- package/dist/runtime/services/module-federation.service.d.cts.map +0 -1
- package/dist/runtime/services/module-federation.service.d.mts.map +0 -1
- package/dist/runtime/services/normalize.cjs.map +0 -1
- package/dist/runtime/services/normalize.d.cts.map +0 -1
- package/dist/runtime/services/normalize.d.mts.map +0 -1
- package/dist/runtime/services/normalize.mjs.map +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +0 -1
- package/dist/runtime/services/plugin-loader.service.d.cts.map +0 -1
- package/dist/runtime/services/plugin-loader.service.d.mts.map +0 -1
- package/dist/runtime/services/secrets.service.d.cts.map +0 -1
- package/dist/runtime/services/secrets.service.d.mts.map +0 -1
- package/dist/testing/index.cjs +0 -57
- package/dist/testing/index.cjs.map +0 -1
- package/dist/testing/index.d.cts +0 -54
- package/dist/testing/index.d.cts.map +0 -1
- package/dist/testing/index.d.mts +0 -54
- package/dist/testing/index.d.mts.map +0 -1
- package/dist/testing/index.mjs +0 -55
- package/dist/testing/index.mjs.map +0 -1
- package/dist/zod-core.cjs +0 -9
- package/dist/zod-core.d.cts +0 -1
- package/dist/zod-core.d.mts +0 -1
- package/dist/zod-core.mjs +0 -3
- package/dist/zod.cjs +0 -11
- package/dist/zod.d.cts +0 -2
- package/dist/zod.d.mts +0 -2
- package/dist/zod.mjs +0 -3
- package/src/build/rspack/dev-server-middleware.ts +0 -324
- package/src/build/shared-deps.ts +0 -102
- package/src/effect.ts +0 -1
- package/src/orpc-openapi.ts +0 -2
- package/src/orpc.ts +0 -9
- package/src/testing/index.ts +0 -87
- package/src/testing/mocks/module-federation.service.ts +0 -41
- package/src/zod-core.ts +0 -1
- package/src/zod.ts +0 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/identity.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Plugin identity: every name a plugin workspace carries, derived from one
|
|
4
|
+
* input. Two seams live here:
|
|
5
|
+
*
|
|
6
|
+
* - `remoteName`/`containerName` absorb the framework's two normalizers (the
|
|
7
|
+
* Module Federation remote name and the UI container name) — runtime,
|
|
8
|
+
* build, and host consumers delegate to these instead of keeping private
|
|
9
|
+
* copies, so a name can never disagree across contexts.
|
|
10
|
+
* - `identity` derives the full name set from the config layout key (the
|
|
11
|
+
* `plugins/<key>` attachment in `bos.config.json`): the key itself (the
|
|
12
|
+
* composition key), the npm package name under the scaffold convention,
|
|
13
|
+
* and the two normalized build names.
|
|
14
|
+
*
|
|
15
|
+
* Normalization rules:
|
|
16
|
+
* - remote: lowercase, strip a single leading '@', replace '/' with '_',
|
|
17
|
+
* preserve hyphens and other characters
|
|
18
|
+
* ("@scope/my-plugin" → "scope_my-plugin")
|
|
19
|
+
* - container: replace every character outside [A-Za-z0-9_] with '_'
|
|
20
|
+
* ("@everything-dev/auth-plugin" → "_everything_dev_auth_plugin")
|
|
21
|
+
*/
|
|
22
|
+
interface PluginIdentity {
|
|
23
|
+
key: string;
|
|
24
|
+
npm: string;
|
|
25
|
+
remote: string;
|
|
26
|
+
container: string;
|
|
27
|
+
}
|
|
28
|
+
declare const remoteName: (name: string) => string;
|
|
29
|
+
declare const containerName: (pkgName: string) => string;
|
|
30
|
+
declare const identity: (key: string) => PluginIdentity;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { PluginIdentity, containerName, identity, remoteName };
|
|
33
|
+
//# sourceMappingURL=identity.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.cts","names":[],"sources":["../src/identity.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;UAoBiB;EACf;EACA;EACA;EACA;;cAGW,aAAU;cAGV,gBAAa;cAEb,WAAQ,gBAAkB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/identity.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Plugin identity: every name a plugin workspace carries, derived from one
|
|
4
|
+
* input. Two seams live here:
|
|
5
|
+
*
|
|
6
|
+
* - `remoteName`/`containerName` absorb the framework's two normalizers (the
|
|
7
|
+
* Module Federation remote name and the UI container name) — runtime,
|
|
8
|
+
* build, and host consumers delegate to these instead of keeping private
|
|
9
|
+
* copies, so a name can never disagree across contexts.
|
|
10
|
+
* - `identity` derives the full name set from the config layout key (the
|
|
11
|
+
* `plugins/<key>` attachment in `bos.config.json`): the key itself (the
|
|
12
|
+
* composition key), the npm package name under the scaffold convention,
|
|
13
|
+
* and the two normalized build names.
|
|
14
|
+
*
|
|
15
|
+
* Normalization rules:
|
|
16
|
+
* - remote: lowercase, strip a single leading '@', replace '/' with '_',
|
|
17
|
+
* preserve hyphens and other characters
|
|
18
|
+
* ("@scope/my-plugin" → "scope_my-plugin")
|
|
19
|
+
* - container: replace every character outside [A-Za-z0-9_] with '_'
|
|
20
|
+
* ("@everything-dev/auth-plugin" → "_everything_dev_auth_plugin")
|
|
21
|
+
*/
|
|
22
|
+
interface PluginIdentity {
|
|
23
|
+
key: string;
|
|
24
|
+
npm: string;
|
|
25
|
+
remote: string;
|
|
26
|
+
container: string;
|
|
27
|
+
}
|
|
28
|
+
declare const remoteName: (name: string) => string;
|
|
29
|
+
declare const containerName: (pkgName: string) => string;
|
|
30
|
+
declare const identity: (key: string) => PluginIdentity;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { PluginIdentity, containerName, identity, remoteName };
|
|
33
|
+
//# sourceMappingURL=identity.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.mts","names":[],"sources":["../src/identity.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;UAoBiB;EACf;EACA;EACA;EACA;;cAGW,aAAU;cAGV,gBAAa;cAEb,WAAQ,gBAAkB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/identity.ts
|
|
2
|
+
const remoteName = (name) => name.toLowerCase().replace(/^@/, "").replace(/\//g, "_");
|
|
3
|
+
const containerName = (pkgName) => pkgName.replace(/[^A-Za-z0-9_]/g, "_");
|
|
4
|
+
const identity = (key) => {
|
|
5
|
+
const npm = `@everything-dev/${key}-plugin`;
|
|
6
|
+
return {
|
|
7
|
+
key,
|
|
8
|
+
npm,
|
|
9
|
+
remote: remoteName(npm),
|
|
10
|
+
container: containerName(npm)
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { containerName, identity, remoteName };
|
|
16
|
+
//# sourceMappingURL=identity.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.mjs","names":[],"sources":["../src/identity.ts"],"sourcesContent":["/**\n * Plugin identity: every name a plugin workspace carries, derived from one\n * input. Two seams live here:\n *\n * - `remoteName`/`containerName` absorb the framework's two normalizers (the\n * Module Federation remote name and the UI container name) — runtime,\n * build, and host consumers delegate to these instead of keeping private\n * copies, so a name can never disagree across contexts.\n * - `identity` derives the full name set from the config layout key (the\n * `plugins/<key>` attachment in `bos.config.json`): the key itself (the\n * composition key), the npm package name under the scaffold convention,\n * and the two normalized build names.\n *\n * Normalization rules:\n * - remote: lowercase, strip a single leading '@', replace '/' with '_',\n * preserve hyphens and other characters\n * (\"@scope/my-plugin\" → \"scope_my-plugin\")\n * - container: replace every character outside [A-Za-z0-9_] with '_'\n * (\"@everything-dev/auth-plugin\" → \"_everything_dev_auth_plugin\")\n */\nexport interface PluginIdentity {\n key: string;\n npm: string;\n remote: string;\n container: string;\n}\n\nexport const remoteName = (name: string): string =>\n name.toLowerCase().replace(/^@/, \"\").replace(/\\//g, \"_\");\n\nexport const containerName = (pkgName: string): string => pkgName.replace(/[^A-Za-z0-9_]/g, \"_\");\n\nexport const identity = (key: string): PluginIdentity => {\n const npm = `@everything-dev/${key}-plugin`;\n return { key, npm, remote: remoteName(npm), container: containerName(npm) };\n};\n"],"mappings":";AA2BA,MAAa,cAAc,SACzB,KAAK,YAAY,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,QAAQ,OAAO,GAAG;AAEzD,MAAa,iBAAiB,YAA4B,QAAQ,QAAQ,kBAAkB,GAAG;AAE/F,MAAa,YAAY,QAAgC;CACvD,MAAM,MAAM,mBAAmB,IAAI;CACnC,OAAO;EAAE;EAAK;EAAK,QAAQ,WAAW,GAAG;EAAG,WAAW,cAAc,GAAG;CAAE;AAC5E"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_client = require('./client.cjs');
|
|
3
|
+
const require_effect_helpers = require('./effect-helpers.cjs');
|
|
2
4
|
const require_errors = require('./runtime/errors.cjs');
|
|
3
5
|
const require_errors$1 = require('./errors.cjs');
|
|
4
6
|
const require_plugin = require('./plugin.cjs');
|
|
5
|
-
const
|
|
7
|
+
const require_identity = require('./identity.cjs');
|
|
6
8
|
const require_runtime_index = require('./runtime/index.cjs');
|
|
9
|
+
require("@orpc/openapi/extensions/route");
|
|
7
10
|
|
|
8
11
|
exports.BAD_REQUEST = require_errors$1.BAD_REQUEST;
|
|
9
12
|
exports.CONNECTION_ERROR = require_errors$1.CONNECTION_ERROR;
|
|
10
|
-
exports.CommonPluginErrors = require_errors$1.CommonPluginErrors;
|
|
11
|
-
exports.ERROR_PATTERNS = require_errors$1.ERROR_PATTERNS;
|
|
12
13
|
exports.FORBIDDEN = require_errors$1.FORBIDDEN;
|
|
13
14
|
exports.ModuleFederationError = require_errors.ModuleFederationError;
|
|
14
15
|
exports.NOT_FOUND = require_errors$1.NOT_FOUND;
|
|
16
|
+
exports.PLUGIN_ERROR_STATUS_MAP = require_errors$1.PLUGIN_ERROR_STATUS_MAP;
|
|
15
17
|
exports.PluginErrors = require_errors$1.PluginErrors;
|
|
16
18
|
exports.PluginIdTag = require_plugin.PluginIdTag;
|
|
17
19
|
exports.PluginRuntime = require_runtime_index.PluginRuntime;
|
|
@@ -21,12 +23,16 @@ exports.SERVICE_UNAVAILABLE = require_errors$1.SERVICE_UNAVAILABLE;
|
|
|
21
23
|
exports.TIMEOUT = require_errors$1.TIMEOUT;
|
|
22
24
|
exports.UNAUTHORIZED = require_errors$1.UNAUTHORIZED;
|
|
23
25
|
exports.ValidationError = require_errors.ValidationError;
|
|
26
|
+
exports.buildScoped = require_effect_helpers.buildScoped;
|
|
27
|
+
exports.buildScopedContext = require_effect_helpers.buildScopedContext;
|
|
28
|
+
exports.classifyPluginFailure = require_errors.classifyPluginFailure;
|
|
24
29
|
exports.createPlugin = require_plugin.createPlugin;
|
|
25
30
|
exports.createPluginRuntime = require_runtime_index.createPluginRuntime;
|
|
31
|
+
exports.createRpcClient = require_client.createRpcClient;
|
|
32
|
+
exports.defaultMissingSecretWarnings = require_errors.defaultMissingSecretWarnings;
|
|
26
33
|
exports.extractFromFiberFailure = require_errors.extractFromFiberFailure;
|
|
27
34
|
exports.formatORPCError = require_errors.formatORPCError;
|
|
28
|
-
exports.getNormalizedRemoteName =
|
|
29
|
-
exports.isRetryableORPCCode = require_errors.isRetryableORPCCode;
|
|
35
|
+
exports.getNormalizedRemoteName = require_identity.remoteName;
|
|
30
36
|
exports.toPluginRuntimeError = require_errors.toPluginRuntimeError;
|
|
31
37
|
exports.withPlugins = require_plugin.withPlugins;
|
|
32
38
|
exports.wrapORPCError = require_errors.wrapORPCError;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { remoteName } from "./identity.cjs";
|
|
2
|
+
import { RpcClientConfig, RpcConnectionErrorCopy, createRpcClient } from "./client.cjs";
|
|
3
|
+
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.cjs";
|
|
4
|
+
import { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.cjs";
|
|
5
|
+
import { buildScoped, buildScopedContext } from "./effect-helpers.cjs";
|
|
6
|
+
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, PluginInitializeInput, PluginWarningsFn, createPlugin, withPlugins } from "./plugin.cjs";
|
|
7
|
+
import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, ModuleClientEntry, ModuleEndpoint, ModuleSurface, ModuleTransport, PluginClientEntry, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginEndpoint, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginServicesEntry, PluginSurface, PluginTransport, PluginVariables, RegisteredPlugins, SecretsConfig, UsePluginResult } from "./types.cjs";
|
|
5
8
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.cjs";
|
|
6
|
-
import
|
|
7
|
-
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR,
|
|
9
|
+
import "@orpc/openapi/extensions/route";
|
|
10
|
+
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, type ModuleClientEntry, type ModuleEndpoint, ModuleFederationError, type ModuleSurface, type ModuleTransport, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientEntry, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginEndpoint, PluginEnv, PluginErrors, PluginIdTag, PluginInitializeInput, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginSurface, type PluginTransport, type PluginVariables, type PluginWarningInfo, PluginWarningsFn, RATE_LIMITED, type RegisteredPlugins, RpcClientConfig, RpcConnectionErrorCopy, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, createRpcClient, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { remoteName } from "./identity.mjs";
|
|
2
|
+
import { RpcClientConfig, RpcConnectionErrorCopy, createRpcClient } from "./client.mjs";
|
|
3
|
+
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
4
|
+
import { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
5
|
+
import { buildScoped, buildScopedContext } from "./effect-helpers.mjs";
|
|
6
|
+
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, PluginInitializeInput, PluginWarningsFn, createPlugin, withPlugins } from "./plugin.mjs";
|
|
7
|
+
import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, ModuleClientEntry, ModuleEndpoint, ModuleSurface, ModuleTransport, PluginClientEntry, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginEndpoint, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginServicesEntry, PluginSurface, PluginTransport, PluginVariables, RegisteredPlugins, SecretsConfig, UsePluginResult } from "./types.mjs";
|
|
5
8
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
|
|
6
|
-
import
|
|
7
|
-
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR,
|
|
9
|
+
import "@orpc/openapi/extensions/route";
|
|
10
|
+
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, type ModuleClientEntry, type ModuleEndpoint, ModuleFederationError, type ModuleSurface, type ModuleTransport, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientEntry, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginEndpoint, PluginEnv, PluginErrors, PluginIdTag, PluginInitializeInput, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginSurface, type PluginTransport, type PluginVariables, type PluginWarningInfo, PluginWarningsFn, RATE_LIMITED, type RegisteredPlugins, RpcClientConfig, RpcConnectionErrorCopy, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, createRpcClient, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createRpcClient } from "./client.mjs";
|
|
2
|
+
import { buildScoped, buildScopedContext } from "./effect-helpers.mjs";
|
|
3
|
+
import { ModuleFederationError, PluginRuntimeError, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
4
|
+
import { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
3
5
|
import { PluginIdTag, createPlugin, withPlugins } from "./plugin.mjs";
|
|
4
|
-
import {
|
|
6
|
+
import { remoteName } from "./identity.mjs";
|
|
5
7
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
|
|
8
|
+
import "@orpc/openapi/extensions/route";
|
|
6
9
|
|
|
7
|
-
export { BAD_REQUEST, CONNECTION_ERROR,
|
|
10
|
+
export { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, PluginIdTag, PluginRuntime, PluginRuntimeError, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, createRpcClient, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/plugin.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_errors = require('./runtime/errors.cjs');
|
|
2
|
-
let _orpc_contract = require("@orpc/contract");
|
|
3
2
|
let effect = require("effect");
|
|
4
3
|
let _orpc_server = require("@orpc/server");
|
|
4
|
+
require("@orpc/experimental-effect/extensions/effect");
|
|
5
5
|
|
|
6
6
|
//#region src/plugin.ts
|
|
7
|
-
var PluginIdTag = class extends effect.Context.
|
|
7
|
+
var PluginIdTag = class extends effect.Context.Service()("PluginId") {};
|
|
8
8
|
const createPlugin = function createPlugin(config) {
|
|
9
9
|
const configSchema = {
|
|
10
10
|
variables: config.variables,
|
|
@@ -16,30 +16,16 @@ const createPlugin = function createPlugin(config) {
|
|
|
16
16
|
id;
|
|
17
17
|
contract = config.contract;
|
|
18
18
|
configSchema = configSchema;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
servicesTag = config.servicesTag;
|
|
20
|
+
warnings = config.warnings;
|
|
21
|
+
initialize(pluginConfig, plugins = {}) {
|
|
22
|
+
const init = config.initialize;
|
|
23
|
+
if (!init) return effect.Effect.succeed(effect.Layer.empty);
|
|
24
|
+
return init(pluginConfig, plugins).pipe(effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, this.id, void 0, "initialize-plugin")));
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
if (config.shutdown && self._deps) yield* config.shutdown(self._deps).pipe(effect.Effect.catchAll((error) => effect.Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error)));
|
|
29
|
-
self._deps = null;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
createRouter(deps) {
|
|
33
|
-
const base = (0, _orpc_server.implement)(config.contract).$context();
|
|
34
|
-
const errorMiddleware = (0, _orpc_server.onError)((error) => {
|
|
35
|
-
const unwrapped = require_errors.extractFromFiberFailure(error);
|
|
36
|
-
if (unwrapped !== error && unwrapped instanceof _orpc_contract.ORPCError) throw unwrapped;
|
|
37
|
-
const formatted = require_errors.formatORPCError(error);
|
|
38
|
-
if (formatted) console.error(formatted);
|
|
39
|
-
throw error;
|
|
40
|
-
});
|
|
41
|
-
const builder = base.use(errorMiddleware);
|
|
42
|
-
return config.createRouter(deps, builder);
|
|
26
|
+
createRouter(plugins) {
|
|
27
|
+
const builder = (0, _orpc_server.implement)(config.contract).$context();
|
|
28
|
+
return config.createRouter(builder, plugins);
|
|
43
29
|
}
|
|
44
30
|
}
|
|
45
31
|
const PluginConstructor = CreatedPlugin;
|
|
@@ -47,7 +33,8 @@ const createPlugin = function createPlugin(config) {
|
|
|
47
33
|
contract: config.contract,
|
|
48
34
|
variables: config.variables,
|
|
49
35
|
secrets: config.secrets,
|
|
50
|
-
context: config.context
|
|
36
|
+
context: config.context,
|
|
37
|
+
servicesTag: config.servicesTag
|
|
51
38
|
};
|
|
52
39
|
return PluginConstructor;
|
|
53
40
|
};
|
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","names":["Context","Effect","extractFromFiberFailure","ORPCError","formatORPCError"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport { ORPCError } from \"@orpc/contract\";\nimport type { Implementer, Router } from \"@orpc/server\";\nimport { implement, onError } from \"@orpc/server\";\nimport { Context, Effect, type Context as EffectContext, type Layer, type Scope } from \"effect\";\nimport { extractFromFiberFailure, formatORPCError } from \"./runtime/errors\";\n\ntype ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;\n\nexport type PluginConfigFor<\n V extends AnySchema,\n S extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> = {\n variables: V;\n secrets: S;\n context: TRequestContext;\n};\n\ntype PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\n/**\n * Tools provided to plugin initialize/services for building long-lived scoped resources.\n */\ntype ServiceOf<T> = T extends EffectContext.Tag<any, infer S> ? S : never;\n\nexport type PluginServicesTools = {\n buildService: <T>(tag: T, layer: Layer.Layer<any, any, any>) => Effect.Effect<ServiceOf<T>>;\n};\n\nexport class PluginIdTag extends Context.Tag(\"PluginId\")<PluginIdTag, string>() {}\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Record<string, any>,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n /**\n * Initialize the plugin and build dependencies.\n * A third argument `tools` is provided for building long-lived scoped resources\n * (e.g. database pools) via `tools.buildService(tag, layer)`.\n */\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n tools: PluginServicesTools,\n ) => Effect.Effect<TDeps, Error, Scope.Scope>;\n createRouter: (\n deps: TDeps,\n builder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>,\n ) => Router<TContract, any>;\n shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;\n};\n\n/**\n * Loaded plugin with static binding property\n */\nexport interface LoadedPluginWithBinding<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n };\n}\n\n/**\n * Plugin interface\n */\nexport interface Plugin<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n tools: PluginServicesTools,\n ): Effect.Effect<TDeps, unknown, Scope.Scope>;\n\n shutdown(): Effect.Effect<void, never>;\n\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * The router's procedure types are inferred directly from the contract.\n * @param deps The initialized plugin dependencies\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(deps: TDeps): Router<TContract, any>;\n}\n\nexport interface CreatePluginFn {\n <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\n withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;\n}\n\nexport const createPlugin: CreatePluginFn = function createPlugin<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) {\n const configSchema: PluginConfigFor<V, S, TRequestContext> = {\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext, TDeps> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n\n private _deps: TDeps | null = null;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n tools: PluginServicesTools,\n ): Effect.Effect<TDeps, unknown, Scope.Scope> {\n const init = config.initialize ?? (() => Effect.succeed({} as TDeps));\n\n return init(pluginConfig, plugins as P, tools).pipe(\n Effect.tap((deps) =>\n Effect.sync(() => {\n this._deps = deps;\n }),\n ),\n Effect.map(() => this._deps as TDeps),\n Effect.mapError((error) => error as unknown),\n );\n }\n\n shutdown(): Effect.Effect<void, never> {\n const self = this;\n return Effect.gen(function* () {\n if (config.shutdown && self._deps) {\n yield* config\n .shutdown(self._deps)\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error),\n ),\n );\n }\n self._deps = null;\n });\n }\n\n createRouter(deps: TDeps): Router<TContract, any> {\n const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();\n const errorMiddleware = onError((error: unknown) => {\n const unwrapped = extractFromFiberFailure(error);\n\n if (unwrapped !== error && unwrapped instanceof ORPCError) {\n throw unwrapped;\n }\n\n const formatted = formatORPCError(error);\n if (formatted) console.error(formatted);\n throw error;\n }) as any;\n\n const builder = (base as any).use(errorMiddleware);\n const router = config.createRouter(deps, builder as any);\n return router as Router<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n };\n };\n\n PluginConstructor.binding = {\n contract: config.contract,\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n};\n\nexport type CreatePluginWithPlugins<P extends Record<string, unknown>> = <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n>(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\nexport function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {\n return <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, TDeps, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":";;;;;;AAiCA,IAAa,cAAb,cAAiCA,eAAQ,IAAI,UAAU,CAAC,CAAsB,CAAC,CAAC,CAAC;AAgGjF,MAAa,eAA+B,SAAS,aAOnD,QAAsE;CACtE,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;CAClB;CAEA,MAAM,cAAyE;;EAE7E;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EAExB,AAAQ,QAAsB;EAE9B,WACE,cACA,UAAmC,CAAC,GACpC,OAC4C;GAG5C,QAFa,OAAO,qBAAqBC,cAAO,QAAQ,CAAC,CAAU,GAExD,CAAC,cAAc,SAAc,KAAK,CAAC,CAAC,KAC7CA,cAAO,KAAK,SACVA,cAAO,WAAW;IAChB,KAAK,QAAQ;GACf,CAAC,CACH,GACAA,cAAO,UAAU,KAAK,KAAc,GACpCA,cAAO,UAAU,UAAU,KAAgB,CAC7C;EACF;EAEA,WAAuC;GACrC,MAAM,OAAO;GACb,OAAOA,cAAO,IAAI,aAAa;IAC7B,IAAI,OAAO,YAAY,KAAK,OAC1B,OAAO,OACJ,SAAS,KAAK,KAAK,CAAC,CACpB,KACCA,cAAO,UAAU,UACfA,cAAO,WAAW,mCAAmC,KAAK,MAAM,KAAK,CACvE,CACF;IAEJ,KAAK,QAAQ;GACf,CAAC;EACH;EAEA,aAAa,MAAqC;GAChD,MAAM,mCAAiB,OAAO,QAAQ,CAAC,CAAC,SAAyC;GACjF,MAAM,6CAA2B,UAAmB;IAClD,MAAM,YAAYC,uCAAwB,KAAK;IAE/C,IAAI,cAAc,SAAS,qBAAqBC,0BAC9C,MAAM;IAGR,MAAM,YAAYC,+BAAgB,KAAK;IACvC,IAAI,WAAW,QAAQ,MAAM,SAAS;IACtC,MAAM;GACR,CAAC;GAED,MAAM,UAAW,KAAa,IAAI,eAAe;GAEjD,OADe,OAAO,aAAa,MAAM,OAC7B;EACd;CACF;CAEA,MAAM,oBAAoB;CAU1B,kBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;CAClB;CAEA,OAAO;AACT;AAYA,SAAgB,cAA6E;CAC3F,QAOE,WACG,aAAyD,MAAa;AAC7E;AAEA,aAAa,cAAc"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["Context","Effect","Layer","toPluginRuntimeError","implement"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport type { WithEffectContext } from \"@orpc/experimental-effect\";\nimport \"@orpc/experimental-effect/extensions/effect\";\nimport type { ContractedRouter, Implementer } from \"@orpc/server\";\nimport { implement } from \"@orpc/server\";\nimport type { Scope } from \"effect\";\nimport { Context, Effect, Layer } from \"effect\";\nimport type { PluginWarningInfo } from \"./runtime/errors\";\nimport { type PluginRuntimeError, toPluginRuntimeError } from \"./runtime/errors\";\n\ntype ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;\n\nexport type PluginConfigFor<\n V extends AnySchema,\n S extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> = {\n variables: V;\n secrets: S;\n context: TRequestContext;\n};\n\nexport type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n /**\n * The framework-assigned plugin id — the same key the host uses for secret\n * injection and per-plugin database namespacing. Arrives as a value so\n * plugin code never needs the ambient `PluginIdTag`.\n */\n pluginId: string;\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\n/**\n * A plugin's own config-derived warnings, evaluated once with the validated\n * config after initialization. Declaring `warnings` opts the plugin out of\n * the loader's default missing-secret warning — these messages replace it.\n */\nexport type PluginWarningsFn<V extends AnySchema, S extends AnySchema> = (\n config: PluginInitializeInput<V, S>,\n) => PluginWarningInfo[] | string[];\n\nexport class PluginIdTag extends Context.Service<PluginIdTag, string>()(\"PluginId\") {}\n\n/**\n * The `initialize` effect's environment: the plugin lifecycle scope plus the\n * framework-assigned plugin id.\n */\nexport type PluginEnv = Scope.Scope | PluginIdTag;\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n /**\n * Optional tag under which `initialize` exposes the plugin's services.\n * The host uses it to read services (e.g. the auth plugin's Better Auth\n * handler) from the built Effect context without importing the plugin\n * module statically.\n */\n servicesTag?: Context.Key<any, any>;\n /**\n * Optional warnings function evaluated once with the validated config after\n * initialization. Returns structured non-fatal warnings (e.g. an optional\n * secret was not set, so the feature depending on it is disabled).\n * Declaring it opts out of the loader's default missing-secret warning.\n */\n warnings?: PluginWarningsFn<V, S>;\n /**\n * Initialize the plugin by returning an Effect `Layer`.\n *\n * The runtime builds the Layer against the plugin's lifecycle scope —\n * scoped resources (db pools, repositories, caches, publishers) release\n * when the plugin shuts down. Services are provided to `.effect()`\n * handlers via the oRPC context (`yield* Tag`).\n */\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n ) => Effect.Effect<Layer.Layer<any, Error, PluginEnv>, Error, PluginEnv>;\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * Services come from the Effect context — access them with\n * `yield* Tag` in `.effect()` handlers, or\n * `Context.get(context[\"effect/context\"], Tag)` in plain handlers.\n * Sibling plugin entries in `plugins` carry `{ client, router }`.\n */\n createRouter: (\n builder: Implementer<TContract, ContextOutput<TRequestContext> & WithEffectContext<any>>,\n plugins: P,\n ) => ContractedRouter<TContract, any>;\n};\n\n/**\n * Loaded plugin with static binding property\n */\nexport interface LoadedPluginWithBinding<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n servicesTag?: Context.Key<any, any>;\n };\n}\n\n/**\n * Plugin interface\n */\nexport interface Plugin<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n readonly servicesTag?: Context.Key<any, any>;\n readonly warnings?: PluginWarningsFn<TVariables, TSecrets>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n ): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv>;\n\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * The router's procedure types are inferred directly from the contract.\n * @param plugins Sibling plugin entries (`{ client, router }`) for\n * cross-plugin composition\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(plugins: Record<string, unknown>): ContractedRouter<TContract, any>;\n}\n\nexport interface CreatePluginFn {\n <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext>;\n\n withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;\n}\n\nexport const createPlugin: CreatePluginFn = function createPlugin<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, P>) {\n const configSchema: PluginConfigFor<V, S, TRequestContext> = {\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n readonly servicesTag = config.servicesTag;\n readonly warnings = config.warnings;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n ): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv> {\n const init = config.initialize;\n if (!init) {\n return Effect.succeed(Layer.empty as unknown as Layer.Layer<any, Error, PluginEnv>);\n }\n\n return init(pluginConfig, plugins as P).pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(error, this.id, undefined, \"initialize-plugin\"),\n ),\n );\n }\n\n createRouter(plugins: Record<string, unknown>): ContractedRouter<TContract, any> {\n const builder = implement(config.contract).$context<\n ContextOutput<TRequestContext> & WithEffectContext<any>\n >();\n return config.createRouter(builder as any, plugins as P) as ContractedRouter<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n servicesTag?: Context.Key<any, any>;\n };\n };\n\n PluginConstructor.binding = {\n contract: config.contract,\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n servicesTag: config.servicesTag,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext>;\n};\n\nexport type CreatePluginWithPlugins<P extends Record<string, unknown>> = <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n>(\n config: PluginDefinition<V, S, TContract, TRequestContext, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext>;\n\nexport function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {\n return <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":";;;;;;AA0CA,IAAa,cAAb,cAAiCA,eAAQ,QAA6B,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AAyHrF,MAAa,eAA+B,SAAS,aAMnD,QAA+D;CAC/D,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;CAClB;CAEA,MAAM,cAAkE;;EAEtE;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EACxB,AAAS,cAAc,OAAO;EAC9B,AAAS,WAAW,OAAO;EAE3B,WACE,cACA,UAAmC,CAAC,GAC8C;GAClF,MAAM,OAAO,OAAO;GACpB,IAAI,CAAC,MACH,OAAOC,cAAO,QAAQC,aAAM,KAAsD;GAGpF,OAAO,KAAK,cAAc,OAAY,CAAC,CAAC,KACtCD,cAAO,UAAU,UACfE,oCAAqB,OAAO,KAAK,IAAI,QAAW,mBAAmB,CACrE,CACF;EACF;EAEA,aAAa,SAAoE;GAC/E,MAAM,cAAUC,wBAAU,OAAO,QAAQ,CAAC,CAAC,SAEzC;GACF,OAAO,OAAO,aAAa,SAAgB,OAAY;EACzD;CACF;CAEA,MAAM,oBAAoB;CAW1B,kBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,aAAa,OAAO;CACtB;CAEA,OAAO;AACT;AAWA,SAAgB,cAA6E;CAC3F,QAME,WACG,aAAkD,MAAa;AACtE;AAEA,aAAa,cAAc"}
|
package/dist/plugin.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginRuntimeError, PluginWarningInfo } from "./runtime/errors.cjs";
|
|
2
2
|
import { AnyContractRouter, AnySchema, InferSchemaOutput } from "@orpc/contract";
|
|
3
|
-
import {
|
|
3
|
+
import { ContractedRouter, Implementer } from "@orpc/server";
|
|
4
|
+
import { Context, Effect, Layer, Scope } from "effect";
|
|
5
|
+
import { WithEffectContext } from "@orpc/experimental-effect";
|
|
6
|
+
import "@orpc/experimental-effect/extensions/effect";
|
|
4
7
|
//#region src/plugin.d.ts
|
|
5
8
|
type ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;
|
|
6
9
|
type PluginConfigFor<V extends AnySchema, S extends AnySchema, TRequestContext extends AnySchema | undefined> = {
|
|
@@ -9,68 +12,104 @@ type PluginConfigFor<V extends AnySchema, S extends AnySchema, TRequestContext e
|
|
|
9
12
|
context: TRequestContext;
|
|
10
13
|
};
|
|
11
14
|
type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {
|
|
15
|
+
/**
|
|
16
|
+
* The framework-assigned plugin id — the same key the host uses for secret
|
|
17
|
+
* injection and per-plugin database namespacing. Arrives as a value so
|
|
18
|
+
* plugin code never needs the ambient `PluginIdTag`.
|
|
19
|
+
*/
|
|
20
|
+
pluginId: string;
|
|
12
21
|
variables: InferSchemaOutput<V>;
|
|
13
22
|
secrets: InferSchemaOutput<S>;
|
|
14
23
|
};
|
|
15
24
|
/**
|
|
16
|
-
*
|
|
25
|
+
* A plugin's own config-derived warnings, evaluated once with the validated
|
|
26
|
+
* config after initialization. Declaring `warnings` opts the plugin out of
|
|
27
|
+
* the loader's default missing-secret warning — these messages replace it.
|
|
17
28
|
*/
|
|
18
|
-
type
|
|
19
|
-
|
|
20
|
-
buildService: <T>(tag: T, layer: Layer.Layer<any, any, any>) => Effect.Effect<ServiceOf<T>>;
|
|
21
|
-
};
|
|
22
|
-
declare const PluginIdTag_base: Context.TagClass<PluginIdTag, "PluginId", string>;
|
|
29
|
+
type PluginWarningsFn<V extends AnySchema, S extends AnySchema> = (config: PluginInitializeInput<V, S>) => PluginWarningInfo[] | string[];
|
|
30
|
+
declare const PluginIdTag_base: Context.ServiceClass<PluginIdTag, "PluginId", string>;
|
|
23
31
|
declare class PluginIdTag extends PluginIdTag_base {}
|
|
24
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The `initialize` effect's environment: the plugin lifecycle scope plus the
|
|
34
|
+
* framework-assigned plugin id.
|
|
35
|
+
*/
|
|
36
|
+
type PluginEnv = Scope.Scope | PluginIdTag;
|
|
37
|
+
type PluginDefinition<V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined, P extends Record<string, unknown>> = {
|
|
25
38
|
variables: V;
|
|
26
39
|
secrets: S;
|
|
27
40
|
contract: TContract;
|
|
28
41
|
context?: TRequestContext;
|
|
29
42
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
43
|
+
* Optional tag under which `initialize` exposes the plugin's services.
|
|
44
|
+
* The host uses it to read services (e.g. the auth plugin's Better Auth
|
|
45
|
+
* handler) from the built Effect context without importing the plugin
|
|
46
|
+
* module statically.
|
|
47
|
+
*/
|
|
48
|
+
servicesTag?: Context.Key<any, any>;
|
|
49
|
+
/**
|
|
50
|
+
* Optional warnings function evaluated once with the validated config after
|
|
51
|
+
* initialization. Returns structured non-fatal warnings (e.g. an optional
|
|
52
|
+
* secret was not set, so the feature depending on it is disabled).
|
|
53
|
+
* Declaring it opts out of the loader's default missing-secret warning.
|
|
54
|
+
*/
|
|
55
|
+
warnings?: PluginWarningsFn<V, S>;
|
|
56
|
+
/**
|
|
57
|
+
* Initialize the plugin by returning an Effect `Layer`.
|
|
58
|
+
*
|
|
59
|
+
* The runtime builds the Layer against the plugin's lifecycle scope —
|
|
60
|
+
* scoped resources (db pools, repositories, caches, publishers) release
|
|
61
|
+
* when the plugin shuts down. Services are provided to `.effect()`
|
|
62
|
+
* handlers via the oRPC context (`yield* Tag`).
|
|
63
|
+
*/
|
|
64
|
+
initialize?: (config: PluginInitializeInput<V, S>, plugins: P) => Effect.Effect<Layer.Layer<any, Error, PluginEnv>, Error, PluginEnv>;
|
|
65
|
+
/**
|
|
66
|
+
* Creates the strongly-typed oRPC router for this plugin.
|
|
67
|
+
* Services come from the Effect context — access them with
|
|
68
|
+
* `yield* Tag` in `.effect()` handlers, or
|
|
69
|
+
* `Context.get(context["effect/context"], Tag)` in plain handlers.
|
|
70
|
+
* Sibling plugin entries in `plugins` carry `{ client, router }`.
|
|
33
71
|
*/
|
|
34
|
-
|
|
35
|
-
createRouter: (deps: TDeps, builder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>) => Router<TContract, any>;
|
|
36
|
-
shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;
|
|
72
|
+
createRouter: (builder: Implementer<TContract, ContextOutput<TRequestContext> & WithEffectContext<any>>, plugins: P) => ContractedRouter<TContract, any>;
|
|
37
73
|
};
|
|
38
74
|
/**
|
|
39
75
|
* Loaded plugin with static binding property
|
|
40
76
|
*/
|
|
41
|
-
interface LoadedPluginWithBinding<TContract extends AnyContractRouter, TVariables extends AnySchema, TSecrets extends AnySchema, TRequestContext extends AnySchema | undefined
|
|
42
|
-
new (): Plugin<TContract, TVariables, TSecrets, TRequestContext
|
|
77
|
+
interface LoadedPluginWithBinding<TContract extends AnyContractRouter, TVariables extends AnySchema, TSecrets extends AnySchema, TRequestContext extends AnySchema | undefined> {
|
|
78
|
+
new (): Plugin<TContract, TVariables, TSecrets, TRequestContext>;
|
|
43
79
|
binding: {
|
|
44
80
|
contract: TContract;
|
|
45
81
|
variables: TVariables;
|
|
46
82
|
secrets: TSecrets;
|
|
47
83
|
context: TRequestContext;
|
|
84
|
+
servicesTag?: Context.Key<any, any>;
|
|
48
85
|
};
|
|
49
86
|
}
|
|
50
87
|
/**
|
|
51
88
|
* Plugin interface
|
|
52
89
|
*/
|
|
53
|
-
interface Plugin<TContract extends AnyContractRouter, TVariables extends AnySchema, TSecrets extends AnySchema, TRequestContext extends AnySchema | undefined
|
|
90
|
+
interface Plugin<TContract extends AnyContractRouter, TVariables extends AnySchema, TSecrets extends AnySchema, TRequestContext extends AnySchema | undefined> {
|
|
54
91
|
readonly id: string;
|
|
55
92
|
readonly contract: TContract;
|
|
56
93
|
readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;
|
|
57
|
-
|
|
58
|
-
|
|
94
|
+
readonly servicesTag?: Context.Key<any, any>;
|
|
95
|
+
readonly warnings?: PluginWarningsFn<TVariables, TSecrets>;
|
|
96
|
+
initialize(config: PluginInitializeInput<TVariables, TSecrets>, plugins: Record<string, unknown>): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv>;
|
|
59
97
|
/**
|
|
60
98
|
* Creates the strongly-typed oRPC router for this plugin.
|
|
61
99
|
* The router's procedure types are inferred directly from the contract.
|
|
62
|
-
* @param
|
|
100
|
+
* @param plugins Sibling plugin entries (`{ client, router }`) for
|
|
101
|
+
* cross-plugin composition
|
|
63
102
|
* @returns A router with procedures matching the plugin's contract
|
|
64
103
|
*/
|
|
65
|
-
createRouter(
|
|
104
|
+
createRouter(plugins: Record<string, unknown>): ContractedRouter<TContract, any>;
|
|
66
105
|
}
|
|
67
106
|
interface CreatePluginFn {
|
|
68
|
-
<V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined = undefined,
|
|
107
|
+
<V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined = undefined, P extends Record<string, unknown> = Record<string, never>>(config: PluginDefinition<V, S, TContract, TRequestContext, P>): LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
|
|
69
108
|
withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;
|
|
70
109
|
}
|
|
71
110
|
declare const createPlugin: CreatePluginFn;
|
|
72
|
-
type CreatePluginWithPlugins<P extends Record<string, unknown>> = <V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined = undefined
|
|
111
|
+
type CreatePluginWithPlugins<P extends Record<string, unknown>> = <V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined = undefined>(config: PluginDefinition<V, S, TContract, TRequestContext, P>) => LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
|
|
73
112
|
declare function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P>;
|
|
74
113
|
//#endregion
|
|
75
|
-
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginIdTag,
|
|
114
|
+
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, PluginInitializeInput, PluginWarningsFn, createPlugin, withPlugins };
|
|
76
115
|
//# sourceMappingURL=plugin.d.cts.map
|
package/dist/plugin.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;KAUK,cAAc,KAAK,UAAU,YAAY,kBAAkB,KAAK;KAEzD,gBACV,UAAU,WACV,UAAU,WACV,wBAAwB;EAExB,WAAW;EACX,SAAS;EACT,SAAS;;KAGC,sBAAsB,UAAU,WAAW,UAAU;;;;;;EAM/D;EACA,WAAW,kBAAkB;EAC7B,SAAS,kBAAkB;;;;;;;KAQjB,iBAAiB,UAAU,WAAW,UAAU,cAC1D,QAAQ,sBAAsB,GAAG,OAC9B;;cAEQ,oBAAoB;;;;;KAMrB,YAAY,MAAM,QAAQ;KAEjC,iBACH,UAAU,WACV,UAAU,WACV,kBAAkB,mBAClB,wBAAwB,uBACxB,UAAU;EAEV,WAAW;EACX,SAAS;EACT,UAAU;EACV,UAAU;;;;;;;EAOV,cAAc,QAAQ;;;;;;;EAOtB,WAAW,iBAAiB,GAAG;;;;;;;;;EAS/B,cACE,QAAQ,sBAAsB,GAAG,IACjC,SAAS,MACN,OAAO,OAAO,MAAM,WAAW,OAAO,YAAY,OAAO;;;;;;;;EAQ9D,eACE,SAAS,YAAY,WAAW,cAAc,mBAAmB,yBACjE,SAAS,MACN,iBAAiB;;;;;UAMP,wBACf,kBAAkB,mBAClB,mBAAmB,WACnB,iBAAiB,WACjB,wBAAwB;UAEhB,OAAO,WAAW,YAAY,UAAU;EAChD;IACE,UAAU;IACV,WAAW;IACX,SAAS;IACT,SAAS;IACT,cAAc,QAAQ;;;;;;UAOT,OACf,kBAAkB,mBAClB,mBAAmB,WACnB,iBAAiB,WACjB,wBAAwB;WAEf;WACA,UAAU;WACV,cAAc,gBAAgB,YAAY,UAAU;WACpD,cAAc,QAAQ;WACtB,WAAW,iBAAiB,YAAY;EAEjD,WACE,QAAQ,sBAAsB,YAAY,WAC1C,SAAS,0BACR,OAAO,OAAO,MAAM,WAAW,OAAO,YAAY,oBAAoB;;;;;;;;EASzE,aAAa,SAAS,0BAA0B,iBAAiB;;UAGlD;GAEb,UAAU,WACV,UAAU,WACV,kBAAkB,mBAClB,wBAAwB,mCACxB,UAAU,0BAA0B,uBAEpC,QAAQ,iBAAiB,GAAG,GAAG,WAAW,iBAAiB,KAC1D,wBAAwB,WAAW,GAAG,GAAG;EAE5C,cAAc,UAAU,8BAA8B,wBAAwB;;cAGnE,cAAc;KAmEf,wBAAwB,UAAU,4BAC5C,UAAU,WACV,UAAU,WACV,kBAAkB,mBAClB,wBAAwB,mCAExB,QAAQ,iBAAiB,GAAG,GAAG,WAAW,iBAAiB,OACxD,wBAAwB,WAAW,GAAG,GAAG;iBAE9B,YAAY,UAAU,4BAA4B,wBAAwB"}
|