every-plugin 2.10.1 → 3.0.0-rc.3
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 +47 -0
- package/dist/build/rspack/chunk-completeness-plugin.cjs.map +1 -0
- package/dist/build/rspack/chunk-completeness-plugin.mjs +47 -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 +118 -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 +111 -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/dev/serve.cjs +390 -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 +384 -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 +9 -5
- package/dist/index.d.cts +8 -6
- package/dist/index.d.mts +8 -6
- package/dist/index.mjs +6 -4
- package/dist/plugin.cjs +13 -26
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +57 -24
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +58 -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 +103 -0
- package/dist/remote-entry.cjs.map +1 -0
- package/dist/remote-entry.d.cts +53 -0
- package/dist/remote-entry.d.cts.map +1 -0
- package/dist/remote-entry.d.mts +53 -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 +56 -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 +55 -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 +25 -41
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +25 -41
- package/dist/types.d.mts.map +1 -1
- package/dist/ui/manifest/construct.cjs +268 -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 +268 -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 +65 -0
- package/dist/version-manifest.cjs.map +1 -0
- package/dist/version-manifest.d.cts +52 -0
- package/dist/version-manifest.d.cts.map +1 -0
- package/dist/version-manifest.d.mts +52 -0
- package/dist/version-manifest.d.mts.map +1 -0
- package/dist/version-manifest.mjs +63 -0
- package/dist/version-manifest.mjs.map +1 -0
- package/package.json +165 -68
- package/skills/plugin-client/SKILL.md +24 -5
- package/skills/plugin-development/SKILL.md +79 -47
- package/skills/plugin-testing/SKILL.md +41 -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 +57 -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 +133 -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/dev/serve.ts +477 -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 +4 -0
- package/src/plugin.ts +88 -91
- package/src/remote-entry.ts +171 -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 +271 -212
- 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 +25 -48
- package/src/ui/manifest/construct.ts +403 -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 +88 -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 @@
|
|
|
1
|
+
{"version":3,"file":"remote-entry.mjs","names":[],"sources":["../src/remote-entry.ts"],"sourcesContent":["/**\n * Remote-entry loading resilience — the ONE contract every MF consumer in\n * the dev stack shares (plugin dev serves, the host's plugin loader).\n *\n * Two failure classes it exists for:\n * 1. Cold compile: remoteEntry.js 404s until the remote's first build —\n * the 404 body gets eval'd as JS (\"Unexpected identifier 'Found'\").\n * 2. Watch-rebuild poisoning: a failed entry load is memoized forever in\n * `globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__` (runtime-core never evicts\n * rejections), so retries without a purge await the same failure.\n */\nimport { Duration, Effect, Schedule } from \"effect\";\nimport type { PluginRuntimeError } from \"./runtime/errors\";\nimport {\n classifyPluginFailure,\n deepestErrorStack,\n type PluginFailureClassification,\n toPluginRuntimeError,\n} from \"./runtime/errors\";\n\nconst POLL_INTERVAL_MS = 300;\nconst DEFAULT_TIMEOUT_MS = 120_000;\nconst RETRY_BASE_DELAY_MS = 500;\nconst RETRY_MAX_DELAY_MS = 5_000;\n\nexport const sleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * Deletes the failed remote's keys from the process-global entry-load cache.\n * Deleting a RESOLVED entry would force a wasteful re-eval, so only call\n * this from failure paths.\n */\nexport const purgeRemoteEntryCache = (remoteUrl: string): void => {\n const globalLoading = (globalThis as Record<string, unknown>).__GLOBAL_LOADING_REMOTE_ENTRY__ as\n | Record<string, unknown>\n | undefined;\n if (!globalLoading) return;\n for (const key of Object.keys(globalLoading)) {\n if (key.endsWith(`:${remoteUrl}`)) delete globalLoading[key];\n }\n};\n\nexport const isRemoteEntryBody = (body: string): boolean =>\n !/not found|<(!doctype|html)/i.test(body.slice(0, 64));\n\nexport const waitForRemoteEntryReady = async (\n label: string,\n url: string,\n timeoutMs = DEFAULT_TIMEOUT_MS,\n): Promise<void> => {\n const deadline = Date.now() + timeoutMs;\n let announced = false;\n while (Date.now() < deadline) {\n const res = await fetch(url).catch(() => null);\n if (res?.ok && isRemoteEntryBody(await res.text().catch(() => \"\"))) return;\n if (!announced) {\n announced = true;\n console.log(`⏳ waiting for ${label} to compile (remote entry not ready)…`);\n }\n await sleep(POLL_INTERVAL_MS);\n }\n throw new Error(`${label} remote entry never became ready at ${url}`);\n};\n\nexport interface PluginLoadAttemptInfo {\n attempt: number;\n classification: PluginFailureClassification;\n}\n\nexport interface PluginLoadRetryOptions<T> {\n /** short plugin key for log prefixes (host entry key or plugin id) */\n label: string;\n remoteUrl: string;\n load: () => Promise<T>;\n /** wall-clock budget for the retry loop */\n timeoutMs?: number;\n /**\n * Budget for the readiness poll (cold-compile wait) — defaults to the\n * retry budget, preserving the historical behavior. Pass `0` to skip the\n * poll (useful when the caller stubs `load` and does not need network).\n */\n readinessTimeoutMs?: number;\n /**\n * Observes every failed attempt (including non-retryable ones that end the\n * loop). Defaults to classification-deduped console.error under the\n * `[Plugins]` prefix.\n */\n onAttempt?: ((error: unknown, info: PluginLoadAttemptInfo) => void) | undefined;\n}\n\n/**\n * The one plugin-load retry policy: poll the remote entry until it is actually\n * served, then load with capped exponential backoff — purging the poisoned\n * global entry cache between attempts so each retry genuinely re-fetches.\n *\n * Recovery policy is `classifyPluginFailure().retryable`: transient network\n * conditions retry until the wall-clock budget runs out; permanent failures\n * (MF identity skew, schema validation, dead remotes, TLS verification) fail\n * fast on the first attempt instead of burning the budget silently.\n *\n * Fails with the ORIGINAL error from `load` — the host builds\n * `PluginBootstrapError.cause` from it and classification walks it.\n */\nexport const loadRemoteWithRetry = <T>(\n options: PluginLoadRetryOptions<T>,\n): Effect.Effect<T, PluginRuntimeError> => {\n const {\n label,\n remoteUrl,\n load,\n timeoutMs = DEFAULT_TIMEOUT_MS,\n readinessTimeoutMs,\n onAttempt,\n } = options;\n const readinessTimeout = readinessTimeoutMs ?? timeoutMs;\n\n const schedule = Schedule.exponential(Duration.millis(RETRY_BASE_DELAY_MS)).pipe(\n Schedule.modifyDelay(({ output }) =>\n Effect.succeed(\n Duration.toMillis(output) > RETRY_MAX_DELAY_MS\n ? Duration.millis(RETRY_MAX_DELAY_MS)\n : output,\n ),\n ),\n Schedule.upTo({ duration: Duration.millis(timeoutMs) }),\n );\n\n let attempt = 0;\n let lastSignature: string | undefined;\n const reportFailure = (error: unknown): void => {\n attempt += 1;\n purgeRemoteEntryCache(remoteUrl);\n const classification = classifyPluginFailure(error);\n if (onAttempt) {\n onAttempt(error, { attempt, classification });\n return;\n }\n const signature = `${classification.kind}::${classification.message}`;\n if (signature === lastSignature) return;\n lastSignature = signature;\n // The message alone is rarely enough, and the wrapper's own stack points\n // at the wrapping frames — log the DEEPEST cause's stack (the original\n // throw site inside the evaluated remote entry).\n const stack = deepestErrorStack(error);\n console.error(\n `[Plugins][${label}] ❌ ${classification.kind} failure (attempt ${attempt}): ${classification.message}` +\n (classification.suggestion ? `\\n[Plugins][${label}] → ${classification.suggestion}` : \"\") +\n (stack ? `\\n[Plugins][${label}] ${stack}` : \"\"),\n );\n };\n\n const loadWithRetry = Effect.tryPromise({\n try: load,\n catch: (error) => toPluginRuntimeError(error, label, undefined, \"remote-entry-load\"),\n }).pipe(\n Effect.tapError((error) => Effect.sync(() => reportFailure(error))),\n Effect.retry({ schedule, while: (error) => classifyPluginFailure(error).retryable }),\n );\n\n // readinessTimeoutMs: 0 skips the cold-compile poll (tests stub `load` and\n // must not race a 1ms wall-clock window against the event loop).\n if (readinessTimeout === 0) {\n return loadWithRetry;\n }\n\n return Effect.tryPromise({\n try: () => waitForRemoteEntryReady(label, remoteUrl, readinessTimeout),\n catch: (error) => toPluginRuntimeError(error, label, undefined, \"remote-entry-readiness\"),\n }).pipe(Effect.flatMap(() => loadWithRetry));\n};\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAM,mBAAmB;AACzB,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAE3B,MAAa,SAAS,OACpB,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;;;;;;AAOlD,MAAa,yBAAyB,cAA4B;CAChE,MAAM,gBAAiB,WAAuC;CAG9D,IAAI,CAAC,eAAe;CACpB,KAAK,MAAM,OAAO,OAAO,KAAK,aAAa,GACzC,IAAI,IAAI,SAAS,IAAI,WAAW,GAAG,OAAO,cAAc;AAE5D;AAEA,MAAa,qBAAqB,SAChC,CAAC,8BAA8B,KAAK,KAAK,MAAM,GAAG,EAAE,CAAC;AAEvD,MAAa,0BAA0B,OACrC,OACA,KACA,YAAY,uBACM;CAClB,MAAM,WAAW,KAAK,IAAI,IAAI;CAC9B,IAAI,YAAY;CAChB,OAAO,KAAK,IAAI,IAAI,UAAU;EAC5B,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,YAAY,IAAI;EAC7C,IAAI,KAAK,MAAM,kBAAkB,MAAM,IAAI,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC,GAAG;EACpE,IAAI,CAAC,WAAW;GACd,YAAY;GACZ,QAAQ,IAAI,iBAAiB,MAA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rF;CAIA,IAAI,qBAAqB,GACvB,OAAO;CAGT,OAAO,OAAO,WAAW;EACvB,WAAW,wBAAwB,OAAO,WAAW,gBAAgB;EACrE,QAAQ,UAAU,qBAAqB,OAAO,OAAO,QAAW,wBAAwB;CAC1F,CAAC,CAAC,CAAC,KAAK,OAAO,cAAc,aAAa,CAAC;AAC7C"}
|
package/dist/runtime/errors.cjs
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
let _orpc_contract = require("@orpc/contract");
|
|
2
1
|
let effect = require("effect");
|
|
2
|
+
let _orpc_server = require("@orpc/server");
|
|
3
3
|
|
|
4
4
|
//#region src/runtime/errors.ts
|
|
5
|
-
var PluginRuntimeError = class extends effect.Data.TaggedError("PluginRuntimeError") {
|
|
5
|
+
var PluginRuntimeError = class extends effect.Data.TaggedError("PluginRuntimeError") {
|
|
6
|
+
get message() {
|
|
7
|
+
return this.cause?.message ?? "Plugin operation failed";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
6
10
|
var ModuleFederationError = class extends effect.Data.TaggedError("ModuleFederationError") {};
|
|
7
11
|
var ValidationError = class extends effect.Data.TaggedError("ValidationError") {};
|
|
12
|
+
const stringifyUnknown = (value) => {
|
|
13
|
+
if (value === null) return "null";
|
|
14
|
+
if (value === void 0) return "undefined";
|
|
15
|
+
if (value instanceof Error) return value.message;
|
|
16
|
+
if (typeof value === "string") return value;
|
|
17
|
+
if (typeof value === "number" || typeof value === "bigint" || typeof value === "boolean") return `${value}`;
|
|
18
|
+
if (typeof value === "symbol") return value.description ?? "";
|
|
19
|
+
try {
|
|
20
|
+
return JSON.stringify(value) ?? "[Unserializable value]";
|
|
21
|
+
} catch {
|
|
22
|
+
return "[Unserializable value]";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
8
25
|
const extractErrorMessage = (error) => {
|
|
9
26
|
if (!error) return "Unknown error";
|
|
10
27
|
if (error instanceof Error) {
|
|
@@ -13,7 +30,25 @@ const extractErrorMessage = (error) => {
|
|
|
13
30
|
}
|
|
14
31
|
if (error instanceof AggregateError && error.errors?.length) return error.errors.map((e) => extractErrorMessage(e)).join("; ");
|
|
15
32
|
if (typeof error === "object" && "message" in error) return String(error.message);
|
|
16
|
-
return
|
|
33
|
+
return stringifyUnknown(error);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The deepest Error along the cause chain — the original throw site. Wrapper
|
|
37
|
+
* errors (PluginRuntimeError, ModuleFederationError) carry their own stacks
|
|
38
|
+
* (the wrapping frames); diagnosis needs the cause's stack (the actual
|
|
39
|
+
* failing module inside the evaluated remote entry).
|
|
40
|
+
*/
|
|
41
|
+
const deepestErrorStack = (error) => {
|
|
42
|
+
let current = error;
|
|
43
|
+
let deepest;
|
|
44
|
+
let hops = 0;
|
|
45
|
+
while (current instanceof Error && hops < 8) {
|
|
46
|
+
if (current.stack) deepest = current.stack;
|
|
47
|
+
current = current.cause;
|
|
48
|
+
hops += 1;
|
|
49
|
+
}
|
|
50
|
+
if (current instanceof Error && current.stack) deepest = current.stack;
|
|
51
|
+
return deepest;
|
|
17
52
|
};
|
|
18
53
|
const formatValidationIssue = (issue, index, maxDisplay) => {
|
|
19
54
|
if (index >= maxDisplay) return "";
|
|
@@ -33,7 +68,7 @@ const formatDataPreview = (data, maxLength = 100) => {
|
|
|
33
68
|
}
|
|
34
69
|
return `${str.slice(0, maxLength)}...`;
|
|
35
70
|
} catch {
|
|
36
|
-
return
|
|
71
|
+
return stringifyUnknown(data).slice(0, maxLength);
|
|
37
72
|
}
|
|
38
73
|
};
|
|
39
74
|
const formatORPCValidationError = (error) => {
|
|
@@ -59,18 +94,31 @@ const formatORPCValidationError = (error) => {
|
|
|
59
94
|
lines.push(`╰${"─".repeat(50)}\n`);
|
|
60
95
|
return lines;
|
|
61
96
|
};
|
|
97
|
+
const formatUnknownError = (error) => {
|
|
98
|
+
if (!error) return null;
|
|
99
|
+
const message = extractErrorMessage(error);
|
|
100
|
+
const lines = [];
|
|
101
|
+
lines.push(`\n╭─ Unhandled error ${"─".repeat(37)}`);
|
|
102
|
+
for (const line of message.split("\n")) lines.push(`│ ${line}`);
|
|
103
|
+
const stack = error instanceof Error ? error.stack?.split("\n").slice(1, 6) : void 0;
|
|
104
|
+
if (stack && stack.length > 0) {
|
|
105
|
+
lines.push(`│`);
|
|
106
|
+
for (const line of stack) lines.push(`│ ${line.trim()}`);
|
|
107
|
+
}
|
|
108
|
+
lines.push(`╰${"─".repeat(50)}\n`);
|
|
109
|
+
return lines.join("\n");
|
|
110
|
+
};
|
|
62
111
|
const formatORPCError = (error) => {
|
|
63
|
-
if (!(error instanceof
|
|
112
|
+
if (!(error instanceof _orpc_server.ORPCError)) return formatUnknownError(error);
|
|
64
113
|
const validationLines = formatORPCValidationError(error);
|
|
65
114
|
if (validationLines) return validationLines.join("\n");
|
|
66
115
|
const lines = [];
|
|
67
116
|
const code = error.code || "UNKNOWN";
|
|
68
|
-
const status = error.status || 500;
|
|
69
117
|
const message = error.message || "An error occurred";
|
|
70
118
|
lines.push(`\n╭─ oRPC Error ${"─".repeat(40)}`);
|
|
71
119
|
const messageLines = message.split("\n");
|
|
72
120
|
for (const line of messageLines) lines.push(`│ ${line}`);
|
|
73
|
-
lines.push(`│ Code: ${code}
|
|
121
|
+
lines.push(`│ Code: ${code}`);
|
|
74
122
|
lines.push(`│`);
|
|
75
123
|
if (error.data) {
|
|
76
124
|
if (typeof error.data === "object" && error.data !== null) {
|
|
@@ -95,38 +143,115 @@ const formatORPCError = (error) => {
|
|
|
95
143
|
case "GATEWAY_TIMEOUT":
|
|
96
144
|
lines.push(`│ → The service may be temporarily unavailable`);
|
|
97
145
|
break;
|
|
98
|
-
case "TIMEOUT":
|
|
99
|
-
lines.push(`│ → The operation took too long`);
|
|
100
|
-
break;
|
|
146
|
+
case "TIMEOUT": lines.push(`│ → The operation took too long`);
|
|
101
147
|
}
|
|
102
148
|
lines.push(`╰${"─".repeat(50)}\n`);
|
|
103
149
|
return lines.join("\n");
|
|
104
150
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
151
|
+
/**
|
|
152
|
+
* The loader's default warning policy for declared-but-unset secrets: a
|
|
153
|
+
* successfully initialized plugin whose declared secret names resolved to
|
|
154
|
+
* nothing (missing or empty in the environment) gets one consolidated
|
|
155
|
+
* warning. `*_DATABASE_URL` keys are excluded — they have the shared-API-DB
|
|
156
|
+
* fallback, and a genuinely-missing DB URL fails initialization (a `failure`,
|
|
157
|
+
* not a warning). A plugin that declares its own `warnings` function opts out
|
|
158
|
+
* of this default.
|
|
159
|
+
*/
|
|
160
|
+
const defaultMissingSecretWarnings = (pluginKey, declaredKeys, resolvedKeys) => {
|
|
161
|
+
const resolved = new Set(resolvedKeys);
|
|
162
|
+
const missing = declaredKeys.filter((key) => !resolved.has(key) && !key.endsWith("_DATABASE_URL"));
|
|
163
|
+
if (missing.length === 0) return [];
|
|
164
|
+
return [{
|
|
165
|
+
pluginKey,
|
|
166
|
+
message: missing.length === 1 ? `Declared secret ${missing[0]} is not set — features depending on it are disabled` : `${missing.length} declared secrets are not set: ${missing.join(", ")} — features depending on them are disabled`,
|
|
167
|
+
hint: "Set the secret(s) in your environment (.env in development); see the plugin's config schema for what each enables"
|
|
168
|
+
}];
|
|
113
169
|
};
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
170
|
+
const NETWORK_RETRYABLE_PATTERNS = [
|
|
171
|
+
"ETIMEDOUT",
|
|
172
|
+
"ECONNRESET",
|
|
173
|
+
"timeout",
|
|
174
|
+
"503",
|
|
175
|
+
"429"
|
|
176
|
+
];
|
|
177
|
+
const NETWORK_DEAD_PATTERNS = [
|
|
178
|
+
"ECONNREFUSED",
|
|
179
|
+
"ENOTFOUND",
|
|
180
|
+
"EHOSTUNREACH"
|
|
181
|
+
];
|
|
182
|
+
const RETRYABLE_ORPC_CODES = /* @__PURE__ */ new Set([
|
|
183
|
+
"TOO_MANY_REQUESTS",
|
|
184
|
+
"SERVICE_UNAVAILABLE",
|
|
185
|
+
"BAD_GATEWAY",
|
|
186
|
+
"GATEWAY_TIMEOUT",
|
|
187
|
+
"TIMEOUT"
|
|
188
|
+
]);
|
|
189
|
+
/**
|
|
190
|
+
* One classification for plugin lifecycle failures across MF / validation /
|
|
191
|
+
* network sources. This is the recovery policy — nothing in the runtime
|
|
192
|
+
* retries on it today by design (the host degrades and runs without a failed
|
|
193
|
+
* plugin); consumers (host bootstrap messages, the dev server retry loop)
|
|
194
|
+
* read kind / retryable / suggestion to decide what to tell the author.
|
|
195
|
+
*/
|
|
196
|
+
const classifyPluginFailure = (error) => {
|
|
197
|
+
let current = extractFromFiberFailure(error);
|
|
198
|
+
let hops = 0;
|
|
199
|
+
while (current && typeof current === "object" && hops < 8) {
|
|
200
|
+
if (current instanceof ModuleFederationError) return {
|
|
201
|
+
kind: "mf",
|
|
202
|
+
retryable: false,
|
|
203
|
+
message: extractErrorMessage(current),
|
|
204
|
+
suggestion: "Run bos mf check — the deployed plugin bundle is likely stale (sharedDep / pluginVersion skew), then redeploy the plugin and bos publish --deploy --packages local"
|
|
205
|
+
};
|
|
206
|
+
if (current instanceof ValidationError) return {
|
|
207
|
+
kind: "validation",
|
|
208
|
+
retryable: false,
|
|
209
|
+
message: `${current.stage}: ${extractErrorMessage(current.zodError)}`,
|
|
210
|
+
suggestion: `Fix the plugin's ${current.stage} schema at plugins/${current.pluginId}`
|
|
211
|
+
};
|
|
212
|
+
if (current instanceof _orpc_server.ORPCError) {
|
|
213
|
+
const retryableByCode = RETRYABLE_ORPC_CODES.has(current.code);
|
|
214
|
+
return {
|
|
215
|
+
kind: "network",
|
|
216
|
+
retryable: retryableByCode,
|
|
217
|
+
message: current.message,
|
|
218
|
+
suggestion: retryableByCode ? "The plugin procedure failed transiently — retry the call" : void 0
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
current = current.cause;
|
|
222
|
+
hops += 1;
|
|
122
223
|
}
|
|
224
|
+
const message = extractErrorMessage(error);
|
|
225
|
+
const lower = message.toLowerCase();
|
|
226
|
+
if (NETWORK_RETRYABLE_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) return {
|
|
227
|
+
kind: "network",
|
|
228
|
+
retryable: true,
|
|
229
|
+
message,
|
|
230
|
+
suggestion: "The remote may be temporarily unavailable — retry after redeploying the plugin"
|
|
231
|
+
};
|
|
232
|
+
if (NETWORK_DEAD_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) return {
|
|
233
|
+
kind: "network",
|
|
234
|
+
retryable: false,
|
|
235
|
+
message,
|
|
236
|
+
suggestion: "The plugin host is unreachable — check plugins.<id> entry URLs in bos.config.json"
|
|
237
|
+
};
|
|
238
|
+
if (lower.includes("integrity") || lower.includes("sri")) return {
|
|
239
|
+
kind: "integrity",
|
|
240
|
+
retryable: true,
|
|
241
|
+
message,
|
|
242
|
+
suggestion: "The deployed bundle content does not match its recorded integrity — redeploy the plugin so bos.config.json is republished with a fresh hash"
|
|
243
|
+
};
|
|
244
|
+
return {
|
|
245
|
+
kind: "unknown",
|
|
246
|
+
retryable: false,
|
|
247
|
+
message
|
|
248
|
+
};
|
|
123
249
|
};
|
|
124
250
|
const wrapORPCError = (orpcError, pluginId, procedureName, operation) => {
|
|
125
251
|
return new PluginRuntimeError({
|
|
126
252
|
pluginId,
|
|
127
253
|
operation,
|
|
128
254
|
procedureName,
|
|
129
|
-
retryable: isRetryableORPCCode(orpcError.code),
|
|
130
255
|
cause: orpcError
|
|
131
256
|
});
|
|
132
257
|
};
|
|
@@ -141,21 +266,20 @@ const extractFromFiberFailure = (error) => {
|
|
|
141
266
|
const cause = error.cause;
|
|
142
267
|
if (cause && typeof cause === "object" && "_tag" in cause) try {
|
|
143
268
|
const squashed = effect.Cause.squash(cause);
|
|
144
|
-
if (squashed instanceof
|
|
269
|
+
if (squashed instanceof _orpc_server.ORPCError) return squashed;
|
|
145
270
|
return squashed;
|
|
146
271
|
} catch {}
|
|
147
|
-
if (cause instanceof
|
|
272
|
+
if (cause instanceof _orpc_server.ORPCError) return cause;
|
|
148
273
|
}
|
|
149
274
|
return error;
|
|
150
275
|
};
|
|
151
|
-
const toPluginRuntimeError = (error, pluginId, procedureName, operation
|
|
152
|
-
if (error instanceof
|
|
276
|
+
const toPluginRuntimeError = (error, pluginId, procedureName, operation) => {
|
|
277
|
+
if (error instanceof _orpc_server.ORPCError) return wrapORPCError(error, pluginId, procedureName, operation);
|
|
153
278
|
if (error instanceof PluginRuntimeError) return error;
|
|
154
279
|
return new PluginRuntimeError({
|
|
155
280
|
pluginId,
|
|
156
281
|
operation,
|
|
157
282
|
procedureName,
|
|
158
|
-
retryable: defaultRetryable || isRetryableError(extractErrorMessage(error)),
|
|
159
283
|
cause: error instanceof Error ? error : new Error(extractErrorMessage(error))
|
|
160
284
|
});
|
|
161
285
|
};
|
|
@@ -164,9 +288,11 @@ const toPluginRuntimeError = (error, pluginId, procedureName, operation, default
|
|
|
164
288
|
exports.ModuleFederationError = ModuleFederationError;
|
|
165
289
|
exports.PluginRuntimeError = PluginRuntimeError;
|
|
166
290
|
exports.ValidationError = ValidationError;
|
|
291
|
+
exports.classifyPluginFailure = classifyPluginFailure;
|
|
292
|
+
exports.deepestErrorStack = deepestErrorStack;
|
|
293
|
+
exports.defaultMissingSecretWarnings = defaultMissingSecretWarnings;
|
|
167
294
|
exports.extractFromFiberFailure = extractFromFiberFailure;
|
|
168
295
|
exports.formatORPCError = formatORPCError;
|
|
169
|
-
exports.isRetryableORPCCode = isRetryableORPCCode;
|
|
170
296
|
exports.toPluginRuntimeError = toPluginRuntimeError;
|
|
171
297
|
exports.wrapORPCError = wrapORPCError;
|
|
172
298
|
//# sourceMappingURL=errors.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":["Data","ORPCError","Cause"],"sources":["../../src/runtime/errors.ts"],"sourcesContent":["import { ORPCError } from \"@orpc/contract\";\nimport { Cause, Data } from \"effect\";\nimport type { z } from \"zod\";\n\nexport class PluginRuntimeError extends Data.TaggedError(\"PluginRuntimeError\")<{\n readonly pluginId?: string;\n readonly operation?: string;\n readonly procedureName?: string;\n readonly cause?: Error;\n readonly retryable: boolean;\n}> {}\n\nexport class ModuleFederationError extends Data.TaggedError(\"ModuleFederationError\")<{\n readonly pluginId: string;\n readonly remoteUrl: string;\n readonly cause?: Error;\n}> {}\n\nexport class ValidationError extends Data.TaggedError(\"ValidationError\")<{\n readonly pluginId: string;\n readonly stage: \"config\" | \"input\" | \"output\" | \"state\";\n readonly zodError: z.ZodError;\n}> {}\n\nconst extractErrorMessage = (error: unknown): string => {\n if (!error) return \"Unknown error\";\n\n if (error instanceof Error) {\n if (error.message) return error.message;\n if ((error as any).cause instanceof Error) {\n return extractErrorMessage((error as any).cause);\n }\n }\n\n if (error instanceof AggregateError && error.errors?.length) {\n return error.errors.map((e) => extractErrorMessage(e)).join(\"; \");\n }\n\n if (typeof error === \"object\" && \"message\" in error) {\n return String((error as any).message);\n }\n\n return String(error);\n};\n\nconst formatValidationIssue = (issue: any, index: number, maxDisplay: number): string => {\n if (index >= maxDisplay) return \"\";\n\n const path =\n Array.isArray(issue.path) && issue.path.length > 0\n ? issue.path.join(\".\")\n : issue.path || \"root\";\n\n const message = issue.message || \"Validation failed\";\n\n return `│ ${index + 1}. ${path}: ${message}`;\n};\n\nconst formatDataPreview = (data: unknown, maxLength = 100): string => {\n if (!data) return \"undefined\";\n\n try {\n const str = JSON.stringify(data);\n if (str.length <= maxLength) return str;\n\n if (typeof data === \"object\" && data !== null) {\n if (Array.isArray(data)) {\n return `Array(${data.length}) [...]`;\n }\n const keys = Object.keys(data);\n return `{ ${keys.slice(0, 3).join(\", \")}${keys.length > 3 ? \", ...\" : \"\"} }`;\n }\n\n return `${str.slice(0, maxLength)}...`;\n } catch {\n return String(data).slice(0, maxLength);\n }\n};\n\nconst formatORPCValidationError = (error: any): string[] | null => {\n const cause = error?.cause || error;\n\n if (!cause?.issues || !Array.isArray(cause.issues) || cause.issues.length === 0) {\n return null;\n }\n\n const lines: string[] = [];\n const errorType = error?.message || cause?.message || \"Validation failed\";\n\n lines.push(`\\n╭─ oRPC Validation Error ${\"─\".repeat(30)}`);\n lines.push(`│ ${errorType}`);\n lines.push(`│`);\n\n const maxDisplay = 10;\n const totalIssues = cause.issues.length;\n\n lines.push(`│ Issues (${totalIssues}):`);\n\n const displayedIssues = cause.issues.slice(0, maxDisplay);\n displayedIssues.forEach((issue: any, idx: number) => {\n const formatted = formatValidationIssue(issue, idx, maxDisplay);\n if (formatted) lines.push(formatted);\n });\n\n if (totalIssues > maxDisplay) {\n lines.push(`│ ... and ${totalIssues - maxDisplay} more`);\n }\n\n if (cause.data !== undefined) {\n lines.push(`│`);\n lines.push(`│ Data preview: ${formatDataPreview(cause.data, 80)}`);\n }\n\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n\n return lines;\n};\n\nexport const formatORPCError = (error: any): string | null => {\n if (!(error instanceof ORPCError)) {\n return null;\n }\n\n const validationLines = formatORPCValidationError(error);\n if (validationLines) {\n return validationLines.join(\"\\n\");\n }\n\n const lines: string[] = [];\n const code = error.code || \"UNKNOWN\";\n const status = error.status || 500;\n const message = error.message || \"An error occurred\";\n\n lines.push(`\\n╭─ oRPC Error ${\"─\".repeat(40)}`);\n const messageLines = message.split(\"\\n\");\n for (const line of messageLines) {\n lines.push(`│ ${line}`);\n }\n lines.push(`│ Code: ${code} (${status})`);\n lines.push(`│`);\n\n if (error.data) {\n const dataType = typeof error.data;\n if (dataType === \"object\" && error.data !== null) {\n if (\"retryAfter\" in error.data) {\n lines.push(`│ Retry after: ${error.data.retryAfter} seconds`);\n }\n if (\"remainingRequests\" in error.data) {\n lines.push(`│ Remaining: ${error.data.remainingRequests} requests`);\n }\n if (\"host\" in error.data) {\n lines.push(`│ Host: ${error.data.host}`);\n }\n if (\"port\" in error.data) {\n lines.push(`│ Port: ${error.data.port}`);\n }\n if (\"suggestion\" in error.data) {\n lines.push(`│ → ${error.data.suggestion}`);\n }\n if (\"resource\" in error.data) {\n lines.push(`│ Resource: ${error.data.resource}`);\n }\n if (\"resourceId\" in error.data) {\n lines.push(`│ ID: ${error.data.resourceId}`);\n }\n }\n }\n\n switch (code) {\n case \"UNAUTHORIZED\":\n lines.push(`│ → Check your API key or credentials`);\n break;\n case \"TOO_MANY_REQUESTS\":\n lines.push(`│ → Wait before retrying`);\n break;\n case \"SERVICE_UNAVAILABLE\":\n case \"BAD_GATEWAY\":\n case \"GATEWAY_TIMEOUT\":\n lines.push(`│ → The service may be temporarily unavailable`);\n break;\n case \"TIMEOUT\":\n lines.push(`│ → The operation took too long`);\n break;\n }\n\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n return lines.join(\"\\n\");\n};\n\nconst isRetryableError = (message: string): boolean => {\n const retryablePatterns = [\"ETIMEDOUT\", \"ECONNRESET\", \"timeout\", \"503\", \"429\"];\n return retryablePatterns.some((p) => message.toLowerCase().includes(p.toLowerCase()));\n};\n\n// Helper to determine if an oRPC error code is retryable\nexport const isRetryableORPCCode = (code: string): boolean => {\n switch (code) {\n case \"TOO_MANY_REQUESTS\":\n case \"SERVICE_UNAVAILABLE\":\n case \"BAD_GATEWAY\":\n case \"GATEWAY_TIMEOUT\":\n case \"TIMEOUT\":\n return true;\n default:\n return false;\n }\n};\n\n// Convert ORPC errors from plugin procedures to PluginRuntimeError\nexport const wrapORPCError = (\n orpcError: ORPCError<string, unknown>,\n pluginId?: string,\n procedureName?: string,\n operation?: string,\n): PluginRuntimeError => {\n return new PluginRuntimeError({\n pluginId,\n operation,\n procedureName,\n retryable: isRetryableORPCCode(orpcError.code),\n cause: orpcError as Error,\n });\n};\n\n/**\n * Extracts the underlying error from Effect's FiberFailure wrapper.\n * When Effect.runPromise rejects, errors are wrapped in FiberFailure.\n * This extracts the original error so oRPC can handle it properly.\n */\nexport const extractFromFiberFailure = (error: unknown): unknown => {\n if (!error || typeof error !== \"object\") return error;\n\n if (\"cause\" in error) {\n const cause = (error as { cause?: unknown }).cause;\n\n if (cause && typeof cause === \"object\" && \"_tag\" in cause) {\n try {\n const squashed = Cause.squash(cause as Cause.Cause<unknown>);\n if (squashed instanceof ORPCError) {\n return squashed;\n }\n return squashed;\n } catch {\n // Not a valid Cause\n }\n }\n\n if (cause instanceof ORPCError) {\n return cause;\n }\n }\n\n return error;\n};\n\n// Universal error converter for the runtime\nexport const toPluginRuntimeError = (\n error: unknown,\n pluginId?: string,\n procedureName?: string,\n operation?: string,\n defaultRetryable = false,\n): PluginRuntimeError => {\n if (error instanceof ORPCError) {\n return wrapORPCError(error, pluginId, procedureName, operation);\n }\n\n if (error instanceof PluginRuntimeError) {\n return error;\n }\n\n return new PluginRuntimeError({\n pluginId,\n operation,\n procedureName,\n retryable: defaultRetryable || isRetryableError(extractErrorMessage(error)),\n cause: error instanceof Error ? error : new Error(extractErrorMessage(error)),\n });\n};\n"],"mappings":";;;;AAIA,IAAa,qBAAb,cAAwCA,YAAK,YAAY,oBAAoB,CAAC,CAM3E,CAAC;AAEJ,IAAa,wBAAb,cAA2CA,YAAK,YAAY,uBAAuB,CAAC,CAIjF,CAAC;AAEJ,IAAa,kBAAb,cAAqCA,YAAK,YAAY,iBAAiB,CAAC,CAIrE,CAAC;AAEJ,MAAM,uBAAuB,UAA2B;CACtD,IAAI,CAAC,OAAO,OAAO;CAEnB,IAAI,iBAAiB,OAAO;EAC1B,IAAI,MAAM,SAAS,OAAO,MAAM;EAChC,IAAK,MAAc,iBAAiB,OAClC,OAAO,oBAAqB,MAAc,KAAK;CAEnD;CAEA,IAAI,iBAAiB,kBAAkB,MAAM,QAAQ,QACnD,OAAO,MAAM,OAAO,KAAK,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;CAGlE,IAAI,OAAO,UAAU,YAAY,aAAa,OAC5C,OAAO,OAAQ,MAAc,OAAO;CAGtC,OAAO,OAAO,K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O,KAA6B;GAC3D,IAAI,oBAAoBD,0BACtB,OAAO;GAET,OAAO;EACT,QAAQ,CAER;EAGF,IAAI,iBAAiBA,0BACnB,OAAO;CAEX;CAEA,OAAO;AACT;AAGA,MAAa,wBACX,OACA,UACA,eACA,WACA,mBAAmB,UACI;CACvB,IAAI,iBAAiBA,0BACnB,OAAO,cAAc,OAAO,UAAU,eAAe,SAAS;CAGhE,IAAI,iBAAiB,oBACnB,OAAO;CAGT,OAAO,IAAI,mBAAmB;EAC5B;EACA;EACA;EACA,WAAW,oBAAoB,iBAAiB,oBAAoB,KAAK,CAAC;EAC1E,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,oBAAoB,KAAK,CAAC;CAC9E,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":["Data","ORPCError","Cause"],"sources":["../../src/runtime/errors.ts"],"sourcesContent":["import { ORPCError } from \"@orpc/server\";\nimport { Cause, Data } from \"effect\";\nimport type { z } from \"zod\";\n\nexport class PluginRuntimeError extends Data.TaggedError(\"PluginRuntimeError\")<{\n readonly pluginId?: string;\n readonly operation?: string;\n readonly procedureName?: string;\n readonly cause?: Error;\n}> {\n override get message() {\n return this.cause?.message ?? \"Plugin operation failed\";\n }\n}\n\nexport class ModuleFederationError extends Data.TaggedError(\"ModuleFederationError\")<{\n readonly pluginId: string;\n readonly remoteUrl: string;\n readonly cause?: Error;\n}> {}\n\nexport class ValidationError extends Data.TaggedError(\"ValidationError\")<{\n readonly pluginId: string;\n readonly stage: \"config\" | \"input\" | \"output\" | \"state\";\n readonly zodError: z.ZodError;\n}> {}\n\nconst stringifyUnknown = (value: unknown): string => {\n if (value === null) return \"null\";\n if (value === undefined) return \"undefined\";\n if (value instanceof Error) return value.message;\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\") {\n return `${value}`;\n }\n if (typeof value === \"symbol\") return value.description ?? \"\";\n try {\n return JSON.stringify(value) ?? \"[Unserializable value]\";\n } catch {\n return \"[Unserializable value]\";\n }\n};\n\nconst extractErrorMessage = (error: unknown): string => {\n if (!error) return \"Unknown error\";\n\n if (error instanceof Error) {\n if (error.message) return error.message;\n if ((error as any).cause instanceof Error) {\n return extractErrorMessage((error as any).cause);\n }\n }\n\n if (error instanceof AggregateError && error.errors?.length) {\n return error.errors.map((e) => extractErrorMessage(e)).join(\"; \");\n }\n\n if (typeof error === \"object\" && \"message\" in error) {\n return String((error as any).message);\n }\n\n return stringifyUnknown(error);\n};\n\n/**\n * The deepest Error along the cause chain — the original throw site. Wrapper\n * errors (PluginRuntimeError, ModuleFederationError) carry their own stacks\n * (the wrapping frames); diagnosis needs the cause's stack (the actual\n * failing module inside the evaluated remote entry).\n */\nexport const deepestErrorStack = (error: unknown): string | undefined => {\n let current = error;\n let deepest: string | undefined;\n let hops = 0;\n while (current instanceof Error && hops < 8) {\n if (current.stack) deepest = current.stack;\n current = (current as { cause?: unknown }).cause as unknown;\n hops += 1;\n }\n if (current instanceof Error && current.stack) deepest = current.stack;\n return deepest;\n};\n\nconst formatValidationIssue = (issue: any, index: number, maxDisplay: number): string => {\n if (index >= maxDisplay) return \"\";\n\n const path =\n Array.isArray(issue.path) && issue.path.length > 0\n ? issue.path.join(\".\")\n : issue.path || \"root\";\n\n const message = issue.message || \"Validation failed\";\n\n return `│ ${index + 1}. ${path}: ${message}`;\n};\n\nconst formatDataPreview = (data: unknown, maxLength = 100): string => {\n if (!data) return \"undefined\";\n\n try {\n const str = JSON.stringify(data);\n if (str.length <= maxLength) return str;\n\n if (typeof data === \"object\" && data !== null) {\n if (Array.isArray(data)) {\n return `Array(${data.length}) [...]`;\n }\n const keys = Object.keys(data);\n return `{ ${keys.slice(0, 3).join(\", \")}${keys.length > 3 ? \", ...\" : \"\"} }`;\n }\n\n return `${str.slice(0, maxLength)}...`;\n } catch {\n return stringifyUnknown(data).slice(0, maxLength);\n }\n};\n\nconst formatORPCValidationError = (error: any): string[] | null => {\n const cause = error?.cause || error;\n\n if (!cause?.issues || !Array.isArray(cause.issues) || cause.issues.length === 0) {\n return null;\n }\n\n const lines: string[] = [];\n const errorType = error?.message || cause?.message || \"Validation failed\";\n\n lines.push(`\\n╭─ oRPC Validation Error ${\"─\".repeat(30)}`);\n lines.push(`│ ${errorType}`);\n lines.push(`│`);\n\n const maxDisplay = 10;\n const totalIssues = cause.issues.length;\n\n lines.push(`│ Issues (${totalIssues}):`);\n\n const displayedIssues = cause.issues.slice(0, maxDisplay);\n displayedIssues.forEach((issue: any, idx: number) => {\n const formatted = formatValidationIssue(issue, idx, maxDisplay);\n if (formatted) lines.push(formatted);\n });\n\n if (totalIssues > maxDisplay) {\n lines.push(`│ ... and ${totalIssues - maxDisplay} more`);\n }\n\n if (cause.data !== undefined) {\n lines.push(`│`);\n lines.push(`│ Data preview: ${formatDataPreview(cause.data, 80)}`);\n }\n\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n\n return lines;\n};\n\nconst formatUnknownError = (error: any): string | null => {\n if (!error) return null;\n const message = extractErrorMessage(error);\n const lines: string[] = [];\n lines.push(`\\n╭─ Unhandled error ${\"─\".repeat(37)}`);\n for (const line of message.split(\"\\n\")) {\n lines.push(`│ ${line}`);\n }\n const stack = error instanceof Error ? error.stack?.split(\"\\n\").slice(1, 6) : undefined;\n if (stack && stack.length > 0) {\n lines.push(`│`);\n for (const line of stack) {\n lines.push(`│ ${line.trim()}`);\n }\n }\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n return lines.join(\"\\n\");\n};\n\nexport const formatORPCError = (error: any): string | null => {\n if (!(error instanceof ORPCError)) {\n // Unknown errors used to return null, leaving internal failures (e.g. a\n // storage backend throw) invisible in host logs while oRPC serialized\n // them client-side as a bare INTERNAL_SERVER_ERROR.\n return formatUnknownError(error);\n }\n\n const validationLines = formatORPCValidationError(error);\n if (validationLines) {\n return validationLines.join(\"\\n\");\n }\n\n const lines: string[] = [];\n const code = error.code || \"UNKNOWN\";\n const message = error.message || \"An error occurred\";\n\n lines.push(`\\n╭─ oRPC Error ${\"─\".repeat(40)}`);\n const messageLines = message.split(\"\\n\");\n for (const line of messageLines) {\n lines.push(`│ ${line}`);\n }\n lines.push(`│ Code: ${code}`);\n lines.push(`│`);\n\n if (error.data) {\n const dataType = typeof error.data;\n if (dataType === \"object\" && error.data !== null) {\n if (\"retryAfter\" in error.data) {\n lines.push(`│ Retry after: ${error.data.retryAfter} seconds`);\n }\n if (\"remainingRequests\" in error.data) {\n lines.push(`│ Remaining: ${error.data.remainingRequests} requests`);\n }\n if (\"host\" in error.data) {\n lines.push(`│ Host: ${error.data.host}`);\n }\n if (\"port\" in error.data) {\n lines.push(`│ Port: ${error.data.port}`);\n }\n if (\"suggestion\" in error.data) {\n lines.push(`│ → ${error.data.suggestion}`);\n }\n if (\"resource\" in error.data) {\n lines.push(`│ Resource: ${error.data.resource}`);\n }\n if (\"resourceId\" in error.data) {\n lines.push(`│ ID: ${error.data.resourceId}`);\n }\n }\n }\n\n switch (code) {\n case \"UNAUTHORIZED\":\n lines.push(`│ → Check your API key or credentials`);\n break;\n case \"TOO_MANY_REQUESTS\":\n lines.push(`│ → Wait before retrying`);\n break;\n case \"SERVICE_UNAVAILABLE\":\n case \"BAD_GATEWAY\":\n case \"GATEWAY_TIMEOUT\":\n lines.push(`│ → The service may be temporarily unavailable`);\n break;\n case \"TIMEOUT\":\n lines.push(`│ → The operation took too long`);\n break;\n }\n\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n return lines.join(\"\\n\");\n};\n\nexport type PluginFailureKind =\n | \"mf\"\n | \"integrity\"\n | \"config\"\n | \"validation\"\n | \"network\"\n | \"unknown\";\n\nexport interface PluginFailureClassification {\n kind: PluginFailureKind;\n retryable: boolean;\n message: string;\n suggestion?: string;\n}\n\n/**\n * Structured report of one plugin-load failure, built by a loader (the host's\n * plugin boot, the dev server) from a `PluginFailureClassification` plus\n * loader context. This is the shape health endpoints and dashboards consume —\n * keep it serializable.\n */\nexport interface PluginLoadFailureInfo {\n /** loader-side key (host entry key, dev plugin id) */\n pluginKey: string;\n pluginUrl?: string;\n /** failing runtime stage when the cause is stage-attributed */\n operation?: string;\n kind: string;\n retryable: boolean;\n message: string;\n suggestion?: string;\n /** loader context: which env secret the plugin's DB binding expects */\n dbSecret?: string;\n dbUrlMasked?: string;\n}\n\n/**\n * Structured, serializable warning surfaced alongside plugin failures in\n * health endpoints and dashboards. Warnings are non-fatal: the plugin loaded\n * and initialized successfully, but runs with reduced functionality (e.g. an\n * optional secret was not set, so the feature depending on it is disabled).\n */\nexport interface PluginWarningInfo {\n /** loader-side key (host entry key, dev plugin id) */\n pluginKey: string;\n message: string;\n hint?: string;\n}\n\n/**\n * The loader's default warning policy for declared-but-unset secrets: a\n * successfully initialized plugin whose declared secret names resolved to\n * nothing (missing or empty in the environment) gets one consolidated\n * warning. `*_DATABASE_URL` keys are excluded — they have the shared-API-DB\n * fallback, and a genuinely-missing DB URL fails initialization (a `failure`,\n * not a warning). A plugin that declares its own `warnings` function opts out\n * of this default.\n */\nexport const defaultMissingSecretWarnings = (\n pluginKey: string,\n declaredKeys: readonly string[],\n resolvedKeys: readonly string[],\n): PluginWarningInfo[] => {\n const resolved = new Set(resolvedKeys);\n const missing = declaredKeys.filter(\n (key) => !resolved.has(key) && !key.endsWith(\"_DATABASE_URL\"),\n );\n if (missing.length === 0) return [];\n return [\n {\n pluginKey,\n message:\n missing.length === 1\n ? `Declared secret ${missing[0]} is not set — features depending on it are disabled`\n : `${missing.length} declared secrets are not set: ${missing.join(\", \")} — features depending on them are disabled`,\n hint: \"Set the secret(s) in your environment (.env in development); see the plugin's config schema for what each enables\",\n },\n ];\n};\n\nconst NETWORK_RETRYABLE_PATTERNS = [\"ETIMEDOUT\", \"ECONNRESET\", \"timeout\", \"503\", \"429\"] as const;\nconst NETWORK_DEAD_PATTERNS = [\"ECONNREFUSED\", \"ENOTFOUND\", \"EHOSTUNREACH\"] as const;\nconst RETRYABLE_ORPC_CODES = new Set([\n \"TOO_MANY_REQUESTS\",\n \"SERVICE_UNAVAILABLE\",\n \"BAD_GATEWAY\",\n \"GATEWAY_TIMEOUT\",\n \"TIMEOUT\",\n]);\n\n/**\n * One classification for plugin lifecycle failures across MF / validation /\n * network sources. This is the recovery policy — nothing in the runtime\n * retries on it today by design (the host degrades and runs without a failed\n * plugin); consumers (host bootstrap messages, the dev server retry loop)\n * read kind / retryable / suggestion to decide what to tell the author.\n */\nexport const classifyPluginFailure = (error: unknown): PluginFailureClassification => {\n let current: unknown = extractFromFiberFailure(error);\n let hops = 0;\n while (current && typeof current === \"object\" && hops < 8) {\n if (current instanceof ModuleFederationError) {\n return {\n kind: \"mf\",\n retryable: false,\n message: extractErrorMessage(current),\n suggestion:\n \"Run bos mf check — the deployed plugin bundle is likely stale (sharedDep / pluginVersion skew), then redeploy the plugin and bos publish --deploy --packages local\",\n };\n }\n if (current instanceof ValidationError) {\n return {\n kind: \"validation\",\n retryable: false,\n message: `${current.stage}: ${extractErrorMessage(current.zodError)}`,\n suggestion: `Fix the plugin's ${current.stage} schema at plugins/${current.pluginId}`,\n };\n }\n if (current instanceof ORPCError) {\n const retryableByCode = RETRYABLE_ORPC_CODES.has(current.code);\n return {\n kind: \"network\",\n retryable: retryableByCode,\n message: current.message,\n suggestion: retryableByCode\n ? \"The plugin procedure failed transiently — retry the call\"\n : undefined,\n };\n }\n current = (current as { cause?: unknown }).cause;\n hops += 1;\n }\n\n const message = extractErrorMessage(error);\n const lower = message.toLowerCase();\n\n if (NETWORK_RETRYABLE_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) {\n return {\n kind: \"network\",\n retryable: true,\n message,\n suggestion: \"The remote may be temporarily unavailable — retry after redeploying the plugin\",\n };\n }\n if (NETWORK_DEAD_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) {\n return {\n kind: \"network\",\n retryable: false,\n message,\n suggestion:\n \"The plugin host is unreachable — check plugins.<id> entry URLs in bos.config.json\",\n };\n }\n if (lower.includes(\"integrity\") || lower.includes(\"sri\")) {\n return {\n kind: \"integrity\",\n retryable: true,\n message,\n suggestion:\n \"The deployed bundle content does not match its recorded integrity — redeploy the plugin so bos.config.json is republished with a fresh hash\",\n };\n }\n\n return { kind: \"unknown\", retryable: false, message };\n};\n\n// Convert ORPC errors from plugin procedures to PluginRuntimeError\nexport const wrapORPCError = (\n orpcError: ORPCError<string, unknown>,\n pluginId?: string,\n procedureName?: string,\n operation?: string,\n): PluginRuntimeError => {\n return new PluginRuntimeError({\n pluginId,\n operation,\n procedureName,\n cause: orpcError as Error,\n });\n};\n\n/**\n * Extracts the underlying error from Effect's FiberFailure wrapper.\n * When Effect.runPromise rejects, errors are wrapped in FiberFailure.\n * This extracts the original error so oRPC can handle it properly.\n */\nexport const extractFromFiberFailure = (error: unknown): unknown => {\n if (!error || typeof error !== \"object\") return error;\n\n if (\"cause\" in error) {\n const cause = (error as { cause?: unknown }).cause;\n\n if (cause && typeof cause === \"object\" && \"_tag\" in cause) {\n try {\n const squashed = Cause.squash(cause as unknown as Cause.Cause<unknown>);\n if (squashed instanceof ORPCError) {\n return squashed;\n }\n return squashed;\n } catch {\n // Not a valid Cause\n }\n }\n\n if (cause instanceof ORPCError) {\n return cause;\n }\n }\n\n return error;\n};\n\n// Universal error converter for the runtime\nexport const toPluginRuntimeError = (\n error: unknown,\n pluginId?: string,\n procedureName?: string,\n operation?: string,\n): PluginRuntimeError => {\n if (error instanceof ORPCError) {\n return wrapORPCError(error, pluginId, procedureName, operation);\n }\n\n if (error instanceof PluginRuntimeError) {\n return error;\n }\n\n return new PluginRuntimeError({\n pluginId,\n operation,\n procedureName,\n cause: error instanceof Error ? error : new Error(extractErrorMessage(error)),\n });\n};\n"],"mappings":";;;;AAIA,IAAa,qBAAb,cAAwCA,YAAK,YAAY,oBAAoB,CAAC,CAK3E;CACD,IAAa,UAAU;EACrB,OAAO,KAAK,OAAO,WAAW;CAChC;AACF;AAEA,IAAa,wBAAb,cAA2CA,YAAK,YAAY,uBAAuB,CAAC,CAIjF,CAAC;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I,MAAM,SAAS,WAAW,KAAK,MAAM,SAAS,KAAK,GACrD,OAAO;EACL,MAAM;EACN,WAAW;EACX;EACA,YACE;CACJ;CAGF,OAAO;EAAE,MAAM;EAAW,WAAW;EAAO;CAAQ;AACtD;AAGA,MAAa,iBACX,WACA,UACA,eACA,cACuB;CACvB,OAAO,IAAI,mBAAmB;EAC5B;EACA;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;;;AAOA,MAAa,2BAA2B,UAA4B;CAClE,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAEhD,IAAI,WAAW,OAAO;EACpB,MAAM,QAAS,MAA8B;EAE7C,IAAI,SAAS,OAAO,UAAU,YAAY,UAAU,OAClD,IAAI;GACF,MAAM,WAAWC,aAAM,OAAO,KAAwC;GACtE,IAAI,oBAAoBD,wBACtB,OAAO;GAET,OAAO;EACT,QAAQ,CAER;EAGF,IAAI,iBAAiBA,wBACnB,OAAO;CAEX;CAEA,OAAO;AACT;AAGA,MAAa,wBACX,OACA,UACA,eACA,cACuB;CACvB,IAAI,iBAAiBA,wBACnB,OAAO,cAAc,OAAO,UAAU,eAAe,SAAS;CAGhE,IAAI,iBAAiB,oBACnB,OAAO;CAGT,OAAO,IAAI,mBAAmB;EAC5B;EACA;EACA;EACA,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,oBAAoB,KAAK,CAAC;CAC9E,CAAC;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Cause } from "effect";
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import { ORPCError } from "@orpc/
|
|
2
|
+
import { ORPCError } from "@orpc/server";
|
|
3
|
+
import { Cause } from "effect";
|
|
4
4
|
//#region src/runtime/errors.d.ts
|
|
5
5
|
declare const PluginRuntimeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
6
6
|
readonly _tag: "PluginRuntimeError";
|
|
@@ -10,8 +10,9 @@ declare class PluginRuntimeError extends PluginRuntimeError_base<{
|
|
|
10
10
|
readonly operation?: string;
|
|
11
11
|
readonly procedureName?: string;
|
|
12
12
|
readonly cause?: Error;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
}> {
|
|
14
|
+
get message(): string;
|
|
15
|
+
}
|
|
15
16
|
declare const ModuleFederationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
16
17
|
readonly _tag: "ModuleFederationError";
|
|
17
18
|
} & Readonly<A>;
|
|
@@ -29,7 +30,63 @@ declare class ValidationError extends ValidationError_base<{
|
|
|
29
30
|
readonly zodError: z.ZodError;
|
|
30
31
|
}> {}
|
|
31
32
|
declare const formatORPCError: (error: any) => string | null;
|
|
32
|
-
|
|
33
|
+
type PluginFailureKind = "mf" | "integrity" | "config" | "validation" | "network" | "unknown";
|
|
34
|
+
interface PluginFailureClassification {
|
|
35
|
+
kind: PluginFailureKind;
|
|
36
|
+
retryable: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
suggestion?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Structured report of one plugin-load failure, built by a loader (the host's
|
|
42
|
+
* plugin boot, the dev server) from a `PluginFailureClassification` plus
|
|
43
|
+
* loader context. This is the shape health endpoints and dashboards consume —
|
|
44
|
+
* keep it serializable.
|
|
45
|
+
*/
|
|
46
|
+
interface PluginLoadFailureInfo {
|
|
47
|
+
/** loader-side key (host entry key, dev plugin id) */
|
|
48
|
+
pluginKey: string;
|
|
49
|
+
pluginUrl?: string;
|
|
50
|
+
/** failing runtime stage when the cause is stage-attributed */
|
|
51
|
+
operation?: string;
|
|
52
|
+
kind: string;
|
|
53
|
+
retryable: boolean;
|
|
54
|
+
message: string;
|
|
55
|
+
suggestion?: string;
|
|
56
|
+
/** loader context: which env secret the plugin's DB binding expects */
|
|
57
|
+
dbSecret?: string;
|
|
58
|
+
dbUrlMasked?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Structured, serializable warning surfaced alongside plugin failures in
|
|
62
|
+
* health endpoints and dashboards. Warnings are non-fatal: the plugin loaded
|
|
63
|
+
* and initialized successfully, but runs with reduced functionality (e.g. an
|
|
64
|
+
* optional secret was not set, so the feature depending on it is disabled).
|
|
65
|
+
*/
|
|
66
|
+
interface PluginWarningInfo {
|
|
67
|
+
/** loader-side key (host entry key, dev plugin id) */
|
|
68
|
+
pluginKey: string;
|
|
69
|
+
message: string;
|
|
70
|
+
hint?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The loader's default warning policy for declared-but-unset secrets: a
|
|
74
|
+
* successfully initialized plugin whose declared secret names resolved to
|
|
75
|
+
* nothing (missing or empty in the environment) gets one consolidated
|
|
76
|
+
* warning. `*_DATABASE_URL` keys are excluded — they have the shared-API-DB
|
|
77
|
+
* fallback, and a genuinely-missing DB URL fails initialization (a `failure`,
|
|
78
|
+
* not a warning). A plugin that declares its own `warnings` function opts out
|
|
79
|
+
* of this default.
|
|
80
|
+
*/
|
|
81
|
+
declare const defaultMissingSecretWarnings: (pluginKey: string, declaredKeys: readonly string[], resolvedKeys: readonly string[]) => PluginWarningInfo[];
|
|
82
|
+
/**
|
|
83
|
+
* One classification for plugin lifecycle failures across MF / validation /
|
|
84
|
+
* network sources. This is the recovery policy — nothing in the runtime
|
|
85
|
+
* retries on it today by design (the host degrades and runs without a failed
|
|
86
|
+
* plugin); consumers (host bootstrap messages, the dev server retry loop)
|
|
87
|
+
* read kind / retryable / suggestion to decide what to tell the author.
|
|
88
|
+
*/
|
|
89
|
+
declare const classifyPluginFailure: (error: unknown) => PluginFailureClassification;
|
|
33
90
|
declare const wrapORPCError: (orpcError: ORPCError<string, unknown>, pluginId?: string, procedureName?: string, operation?: string) => PluginRuntimeError;
|
|
34
91
|
/**
|
|
35
92
|
* Extracts the underlying error from Effect's FiberFailure wrapper.
|
|
@@ -37,7 +94,7 @@ declare const wrapORPCError: (orpcError: ORPCError<string, unknown>, pluginId?:
|
|
|
37
94
|
* This extracts the original error so oRPC can handle it properly.
|
|
38
95
|
*/
|
|
39
96
|
declare const extractFromFiberFailure: (error: unknown) => unknown;
|
|
40
|
-
declare const toPluginRuntimeError: (error: unknown, pluginId?: string, procedureName?: string, operation?: string
|
|
97
|
+
declare const toPluginRuntimeError: (error: unknown, pluginId?: string, procedureName?: string, operation?: string) => PluginRuntimeError;
|
|
41
98
|
//#endregion
|
|
42
|
-
export { ModuleFederationError, PluginRuntimeError, ValidationError, extractFromFiberFailure, formatORPCError,
|
|
99
|
+
export { ModuleFederationError, PluginFailureClassification, PluginFailureKind, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
43
100
|
//# sourceMappingURL=errors.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","names":[],"sources":["../../src/runtime/errors.ts"],"mappings":";;;;;;;cAIa,2BAA2B;WAC7B;WACA;WACA;WACA,QAAQ
|
|
1
|
+
{"version":3,"file":"errors.d.cts","names":[],"sources":["../../src/runtime/errors.ts"],"mappings":";;;;;;;cAIa,2BAA2B;WAC7B;WACA;WACA;WACA,QAAQ;;MAEJ;;;;;cAKF,8BAA8B;WAChC;WACA;WACA,QAAQ;;;;;cAGN,wBAAwB;WAC1B;WACA;WACA,UAAU,EAAE;;cAuJV,kBAAe;KAyEhB;UAQK;EACf,MAAM;EACN;EACA;EACA;;;;;;;;UASe;;EAEf;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;;;;;;;;UASe;;EAEf;EACA;EACA;;;;;;;;;;;cAYW,+BAA4B,mBACtB,iCACc,oCAE9B;;;;;;;;cAmCU,wBAAqB,mBAAqB;cAsE1C,gBAAa,WACb,4BAA0B,mBACpB,wBACK,uBAErB;;;;;;cAcU,0BAAuB;cA2BvB,uBAAoB,gBACjB,mBACG,wBACK,uBAErB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { ORPCError } from "@orpc/contract";
|
|
3
1
|
import { Cause } from "effect";
|
|
2
|
+
import { ORPCError } from "@orpc/server";
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
//#region src/runtime/errors.d.ts
|
|
5
5
|
declare const PluginRuntimeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
6
6
|
readonly _tag: "PluginRuntimeError";
|
|
@@ -10,8 +10,9 @@ declare class PluginRuntimeError extends PluginRuntimeError_base<{
|
|
|
10
10
|
readonly operation?: string;
|
|
11
11
|
readonly procedureName?: string;
|
|
12
12
|
readonly cause?: Error;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
}> {
|
|
14
|
+
get message(): string;
|
|
15
|
+
}
|
|
15
16
|
declare const ModuleFederationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
16
17
|
readonly _tag: "ModuleFederationError";
|
|
17
18
|
} & Readonly<A>;
|
|
@@ -29,7 +30,63 @@ declare class ValidationError extends ValidationError_base<{
|
|
|
29
30
|
readonly zodError: z.ZodError;
|
|
30
31
|
}> {}
|
|
31
32
|
declare const formatORPCError: (error: any) => string | null;
|
|
32
|
-
|
|
33
|
+
type PluginFailureKind = "mf" | "integrity" | "config" | "validation" | "network" | "unknown";
|
|
34
|
+
interface PluginFailureClassification {
|
|
35
|
+
kind: PluginFailureKind;
|
|
36
|
+
retryable: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
suggestion?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Structured report of one plugin-load failure, built by a loader (the host's
|
|
42
|
+
* plugin boot, the dev server) from a `PluginFailureClassification` plus
|
|
43
|
+
* loader context. This is the shape health endpoints and dashboards consume —
|
|
44
|
+
* keep it serializable.
|
|
45
|
+
*/
|
|
46
|
+
interface PluginLoadFailureInfo {
|
|
47
|
+
/** loader-side key (host entry key, dev plugin id) */
|
|
48
|
+
pluginKey: string;
|
|
49
|
+
pluginUrl?: string;
|
|
50
|
+
/** failing runtime stage when the cause is stage-attributed */
|
|
51
|
+
operation?: string;
|
|
52
|
+
kind: string;
|
|
53
|
+
retryable: boolean;
|
|
54
|
+
message: string;
|
|
55
|
+
suggestion?: string;
|
|
56
|
+
/** loader context: which env secret the plugin's DB binding expects */
|
|
57
|
+
dbSecret?: string;
|
|
58
|
+
dbUrlMasked?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Structured, serializable warning surfaced alongside plugin failures in
|
|
62
|
+
* health endpoints and dashboards. Warnings are non-fatal: the plugin loaded
|
|
63
|
+
* and initialized successfully, but runs with reduced functionality (e.g. an
|
|
64
|
+
* optional secret was not set, so the feature depending on it is disabled).
|
|
65
|
+
*/
|
|
66
|
+
interface PluginWarningInfo {
|
|
67
|
+
/** loader-side key (host entry key, dev plugin id) */
|
|
68
|
+
pluginKey: string;
|
|
69
|
+
message: string;
|
|
70
|
+
hint?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The loader's default warning policy for declared-but-unset secrets: a
|
|
74
|
+
* successfully initialized plugin whose declared secret names resolved to
|
|
75
|
+
* nothing (missing or empty in the environment) gets one consolidated
|
|
76
|
+
* warning. `*_DATABASE_URL` keys are excluded — they have the shared-API-DB
|
|
77
|
+
* fallback, and a genuinely-missing DB URL fails initialization (a `failure`,
|
|
78
|
+
* not a warning). A plugin that declares its own `warnings` function opts out
|
|
79
|
+
* of this default.
|
|
80
|
+
*/
|
|
81
|
+
declare const defaultMissingSecretWarnings: (pluginKey: string, declaredKeys: readonly string[], resolvedKeys: readonly string[]) => PluginWarningInfo[];
|
|
82
|
+
/**
|
|
83
|
+
* One classification for plugin lifecycle failures across MF / validation /
|
|
84
|
+
* network sources. This is the recovery policy — nothing in the runtime
|
|
85
|
+
* retries on it today by design (the host degrades and runs without a failed
|
|
86
|
+
* plugin); consumers (host bootstrap messages, the dev server retry loop)
|
|
87
|
+
* read kind / retryable / suggestion to decide what to tell the author.
|
|
88
|
+
*/
|
|
89
|
+
declare const classifyPluginFailure: (error: unknown) => PluginFailureClassification;
|
|
33
90
|
declare const wrapORPCError: (orpcError: ORPCError<string, unknown>, pluginId?: string, procedureName?: string, operation?: string) => PluginRuntimeError;
|
|
34
91
|
/**
|
|
35
92
|
* Extracts the underlying error from Effect's FiberFailure wrapper.
|
|
@@ -37,7 +94,7 @@ declare const wrapORPCError: (orpcError: ORPCError<string, unknown>, pluginId?:
|
|
|
37
94
|
* This extracts the original error so oRPC can handle it properly.
|
|
38
95
|
*/
|
|
39
96
|
declare const extractFromFiberFailure: (error: unknown) => unknown;
|
|
40
|
-
declare const toPluginRuntimeError: (error: unknown, pluginId?: string, procedureName?: string, operation?: string
|
|
97
|
+
declare const toPluginRuntimeError: (error: unknown, pluginId?: string, procedureName?: string, operation?: string) => PluginRuntimeError;
|
|
41
98
|
//#endregion
|
|
42
|
-
export { ModuleFederationError, PluginRuntimeError, ValidationError, extractFromFiberFailure, formatORPCError,
|
|
99
|
+
export { ModuleFederationError, PluginFailureClassification, PluginFailureKind, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
43
100
|
//# sourceMappingURL=errors.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","names":[],"sources":["../../src/runtime/errors.ts"],"mappings":";;;;;;;cAIa,2BAA2B;WAC7B;WACA;WACA;WACA,QAAQ
|
|
1
|
+
{"version":3,"file":"errors.d.mts","names":[],"sources":["../../src/runtime/errors.ts"],"mappings":";;;;;;;cAIa,2BAA2B;WAC7B;WACA;WACA;WACA,QAAQ;;MAEJ;;;;;cAKF,8BAA8B;WAChC;WACA;WACA,QAAQ;;;;;cAGN,wBAAwB;WAC1B;WACA;WACA,UAAU,EAAE;;cAuJV,kBAAe;KAyEhB;UAQK;EACf,MAAM;EACN;EACA;EACA;;;;;;;;UASe;;EAEf;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;;;;;;;;UASe;;EAEf;EACA;EACA;;;;;;;;;;;cAYW,+BAA4B,mBACtB,iCACc,oCAE9B;;;;;;;;cAmCU,wBAAqB,mBAAqB;cAsE1C,gBAAa,WACb,4BAA0B,mBACpB,wBACK,uBAErB;;;;;;cAcU,0BAAuB;cA2BvB,uBAAoB,gBACjB,mBACG,wBACK,uBAErB"}
|