better-effect 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +337 -88
  2. package/dist/adapters/iti.d.mts +2 -3
  3. package/dist/adapters/iti.d.mts.map +1 -1
  4. package/dist/adapters/iti.mjs +2 -2
  5. package/dist/bun.d.mts +75 -23
  6. package/dist/bun.d.mts.map +1 -1
  7. package/dist/bun.mjs +170 -33
  8. package/dist/bun.mjs.map +1 -1
  9. package/dist/{context-BphfFUMO.mjs → context-DSGSqcJj.mjs} +12 -3
  10. package/dist/context-DSGSqcJj.mjs.map +1 -0
  11. package/dist/{current-request-DDKNyymv.mjs → current-request-Bc1YHL0w.mjs} +3 -2
  12. package/dist/{current-request-DDKNyymv.mjs.map → current-request-Bc1YHL0w.mjs.map} +1 -1
  13. package/dist/{current-request-CIU7AHhF.d.mts → current-request-Dm-QQ3Xr.d.mts} +4 -4
  14. package/dist/current-request-Dm-QQ3Xr.d.mts.map +1 -0
  15. package/dist/{effect-CPdV7Yv8.mjs → effect-W0IQXY8P.mjs} +21 -2
  16. package/dist/effect-W0IQXY8P.mjs.map +1 -0
  17. package/dist/{errors-BKcsQ0ip.d.mts → errors-CpHMzPiP.d.mts} +6 -2
  18. package/dist/errors-CpHMzPiP.d.mts.map +1 -0
  19. package/dist/hono.d.mts +63 -27
  20. package/dist/hono.d.mts.map +1 -1
  21. package/dist/hono.mjs +111 -45
  22. package/dist/hono.mjs.map +1 -1
  23. package/dist/{index-CCi07kUw.d.mts → index-3Bkl-sxS.d.mts} +7 -2
  24. package/dist/{index-CCi07kUw.d.mts.map → index-3Bkl-sxS.d.mts.map} +1 -1
  25. package/dist/{index-cXgyMa0v.d.mts → index-C2ed9Ilq.d.mts} +32 -7
  26. package/dist/index-C2ed9Ilq.d.mts.map +1 -0
  27. package/dist/{index-BodMy6rO.d.mts → index-ClNndn2-.d.mts} +93 -63
  28. package/dist/index-ClNndn2-.d.mts.map +1 -0
  29. package/dist/{index-DAKn0qHk.d.mts → index-Cy1VsU-u.d.mts} +2 -4
  30. package/dist/index-Cy1VsU-u.d.mts.map +1 -0
  31. package/dist/index.d.mts +6 -8
  32. package/dist/index.mjs +8 -9
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/{internal-identity-CbXoZIfw.mjs → internal-identity-BuHBtP0k.mjs} +2 -2
  35. package/dist/{internal-identity-CbXoZIfw.mjs.map → internal-identity-BuHBtP0k.mjs.map} +1 -1
  36. package/dist/layer-2kjHVv4N.mjs +343 -0
  37. package/dist/layer-2kjHVv4N.mjs.map +1 -0
  38. package/dist/layer-C2OaqTmB.d.mts +987 -0
  39. package/dist/layer-C2OaqTmB.d.mts.map +1 -0
  40. package/dist/next.d.mts +102 -26
  41. package/dist/next.d.mts.map +1 -1
  42. package/dist/next.mjs +157 -40
  43. package/dist/next.mjs.map +1 -1
  44. package/dist/{node-context-DczjAcrX.d.mts → node-context-1YEjrU9g.d.mts} +2 -2
  45. package/dist/{node-context-DczjAcrX.d.mts.map → node-context-1YEjrU9g.d.mts.map} +1 -1
  46. package/dist/{node-context-Ca18oNSg.mjs → node-context-g3bCcY9t.mjs} +2 -2
  47. package/dist/{node-context-Ca18oNSg.mjs.map → node-context-g3bCcY9t.mjs.map} +1 -1
  48. package/dist/node.d.mts +11 -6
  49. package/dist/node.d.mts.map +1 -1
  50. package/dist/node.mjs +156 -10
  51. package/dist/node.mjs.map +1 -1
  52. package/dist/opentelemetry.d.mts +20 -2
  53. package/dist/opentelemetry.d.mts.map +1 -1
  54. package/dist/opentelemetry.mjs +423 -5
  55. package/dist/opentelemetry.mjs.map +1 -1
  56. package/dist/{registration-drnZk0SY.mjs → registration-Bwe2GbVu.mjs} +8 -2
  57. package/dist/registration-Bwe2GbVu.mjs.map +1 -0
  58. package/dist/runtime/explicit.d.mts +2 -2
  59. package/dist/runtime/explicit.mjs +1 -1
  60. package/dist/runtime/node.d.mts +3 -3
  61. package/dist/runtime/node.mjs +2 -2
  62. package/dist/runtime-qpcVwaz_.mjs +1680 -0
  63. package/dist/runtime-qpcVwaz_.mjs.map +1 -0
  64. package/dist/service-CO9VJQYa.mjs +74 -0
  65. package/dist/service-CO9VJQYa.mjs.map +1 -0
  66. package/dist/{signal-nfgFyNCk.mjs → signal-5Rg9bUUe.mjs} +2 -2
  67. package/dist/{signal-nfgFyNCk.mjs.map → signal-5Rg9bUUe.mjs.map} +1 -1
  68. package/dist/{standard-services-vnGIafkS.mjs → standard-services-B-iMM_W7.mjs} +38 -4
  69. package/dist/standard-services-B-iMM_W7.mjs.map +1 -0
  70. package/dist/standard-services.d.mts +4 -4
  71. package/dist/standard-services.mjs +3 -3
  72. package/dist/testing.d.mts +25 -7
  73. package/dist/testing.d.mts.map +1 -1
  74. package/dist/testing.mjs +51 -7
  75. package/dist/testing.mjs.map +1 -1
  76. package/dist/{types-oihI-ESv.d.mts → types-BFTqCCcw.d.mts} +32 -5
  77. package/dist/types-BFTqCCcw.d.mts.map +1 -0
  78. package/dist/web-effect-B9hp9jIe.mjs +380 -0
  79. package/dist/web-effect-B9hp9jIe.mjs.map +1 -0
  80. package/dist/web.d.mts +22 -13
  81. package/dist/web.d.mts.map +1 -1
  82. package/dist/web.mjs +1 -1
  83. package/package.json +10 -16
  84. package/dist/context-BphfFUMO.mjs.map +0 -1
  85. package/dist/current-request-CIU7AHhF.d.mts.map +0 -1
  86. package/dist/disposable-CP-Q2H3l.mjs +0 -57
  87. package/dist/disposable-CP-Q2H3l.mjs.map +0 -1
  88. package/dist/effect-CPdV7Yv8.mjs.map +0 -1
  89. package/dist/errors-BKcsQ0ip.d.mts.map +0 -1
  90. package/dist/index-AiKM71-u.d.mts +0 -376
  91. package/dist/index-AiKM71-u.d.mts.map +0 -1
  92. package/dist/index-BodMy6rO.d.mts.map +0 -1
  93. package/dist/index-DAKn0qHk.d.mts.map +0 -1
  94. package/dist/index-cXgyMa0v.d.mts.map +0 -1
  95. package/dist/layer-D16GKxuX.mjs +0 -269
  96. package/dist/layer-D16GKxuX.mjs.map +0 -1
  97. package/dist/observer-9nhbL7Pr.d.mts +0 -68
  98. package/dist/observer-9nhbL7Pr.d.mts.map +0 -1
  99. package/dist/outcome-DI8LPIQ4.d.mts +0 -387
  100. package/dist/outcome-DI8LPIQ4.d.mts.map +0 -1
  101. package/dist/program-metadata-BxjGkT17.mjs +0 -260
  102. package/dist/program-metadata-BxjGkT17.mjs.map +0 -1
  103. package/dist/registration-drnZk0SY.mjs.map +0 -1
  104. package/dist/runtime-C_55ofnL.mjs +0 -791
  105. package/dist/runtime-C_55ofnL.mjs.map +0 -1
  106. package/dist/standard-services-vnGIafkS.mjs.map +0 -1
  107. package/dist/types-oihI-ESv.d.mts.map +0 -1
  108. package/dist/web-Bq3MfMrj.mjs +0 -147
  109. package/dist/web-Bq3MfMrj.mjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-effect",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Effect-inspired application architecture for better-result with typechecked Services and environments, scoped resource lifetimes, and pluggable DI backends.",
5
5
  "keywords": [
6
6
  "better-result",
@@ -54,41 +54,35 @@
54
54
  "test": "bun test",
55
55
  "test:coverage": "bun test --coverage",
56
56
  "test:package-types": "tsc --version && tsc -p tests/package/public-type-namespaces/tsconfig.json",
57
- "test:package-types:minimum": "bunx --bun --package typescript@5.7.2 tsc --version && bunx --bun --package typescript@5.7.2 tsc -p tests/package/public-type-namespaces/tsconfig.json",
58
57
  "test:package-next": "tsc -p tests/package/next/tsconfig.json",
59
- "test:package-next:minimum": "bunx --bun --package typescript@5.7.2 tsc -p tests/package/next/tsconfig.json",
60
58
  "test:package-bun-types": "tsc -p tests/package/bun/tsconfig.json",
61
- "test:package-bun-types:minimum": "bunx --bun --package typescript@5.7.2 tsc -p tests/package/bun/tsconfig.json",
62
59
  "test:package-opentelemetry": "tsc -p tests/package/opentelemetry/tsconfig.json",
63
- "test:package-opentelemetry:minimum": "bunx --bun --package typescript@5.7.2 tsc -p tests/package/opentelemetry/tsconfig.json",
64
60
  "test:package-standard-services": "tsc -p tests/package/standard-services/tsconfig.json",
65
- "test:package-standard-services:minimum": "bunx --bun --package typescript@5.7.2 tsc -p tests/package/standard-services/tsconfig.json",
66
61
  "test:package-variance": "rm -rf tests/package/public-type-variance/out && tsc --version && tsc -p tests/package/public-type-variance/tsconfig.json && rm -rf tests/package/public-type-variance/out",
67
- "test:package-variance:minimum": "rm -rf tests/package/public-type-variance/out && bunx --bun --package typescript@5.7.2 tsc --version && bunx --bun --package typescript@5.7.2 tsc -p tests/package/public-type-variance/tsconfig.json && rm -rf tests/package/public-type-variance/out",
68
62
  "lint": "oxlint --type-aware .",
69
63
  "lint:fix": "oxlint --type-aware --fix .",
70
64
  "format": "oxfmt --write .",
71
65
  "format:check": "oxfmt --check .",
72
66
  "publint": "publint",
73
- "check:public-type-namespaces": "bun run test:package-types && bun run test:package-types:minimum && bun tests/package/public-type-namespaces/check.ts",
67
+ "check:public-type-namespaces": "bun run test:package-types && bun tests/package/public-type-namespaces/check.ts",
74
68
  "check:node-runtime": "bun tests/check-node-runtime.ts",
75
69
  "check:next-package": "bun tests/check-next-package.ts",
76
- "check:opentelemetry": "bun run test:package-opentelemetry && bun run test:package-opentelemetry:minimum && bun tests/check-opentelemetry-package.ts",
70
+ "check:opentelemetry": "bun run test:package-opentelemetry && bun tests/check-opentelemetry-package.ts",
77
71
  "check:web-package": "bun tests/check-web-package.ts",
78
72
  "check:hono-package": "bun tests/check-hono-package.ts",
79
73
  "check:bun-package": "bun tests/check-bun-package.ts",
80
- "check:bun-types": "bun run test:package-bun-types && bun run test:package-bun-types:minimum",
81
- "check:standard-services": "bun run test:package-standard-services && bun run test:package-standard-services:minimum",
82
- "check:public-type-variance": "bun run test:package-variance && bun run test:package-variance:minimum && bun tests/package/public-type-variance/check.ts",
74
+ "check:bun-types": "bun run test:package-bun-types",
75
+ "check:standard-services": "bun run test:package-standard-services",
76
+ "check:public-type-variance": "bun run test:package-variance && bun tests/package/public-type-variance/check.ts",
83
77
  "check:instance-requirements": "bun tests/package/instance-requirements/check.ts",
84
- "check": "bun run typecheck && bun test && bun run format:check && bun run check:node-runtime && bun run check:opentelemetry && bun run check:web-package && bun run check:hono-package && bun run check:next-package && bun run check:bun-package && bun run check:bun-types && bun run check:public-type-namespaces && bun run check:standard-services && bun run check:public-type-variance && bun run check:instance-requirements && bun run publint && bun run lint",
78
+ "check": "bun run typecheck && bun test && bun run format:check && bun run check:node-runtime && bun run check:opentelemetry && bun run check:web-package && bun run check:hono-package && bun run check:next-package && bun run check:bun-package && bun run check:bun-types && bun run check:public-type-namespaces && bun run check:standard-services && bun run check:public-type-variance && bun run check:instance-requirements && bun run publint && bun run release:dry && bun run lint",
85
79
  "prepublishOnly": "bun run check",
86
- "release:dry": "bun publish --dry-run"
80
+ "release:dry": "bun ../../scripts/release-artifact.ts --package better-effect"
87
81
  },
88
82
  "devDependencies": {
89
83
  "@opentelemetry/api": "1.9.1",
90
84
  "@opentelemetry/sdk-trace-base": "2.10.0",
91
- "@types/bun": "1.3.14",
85
+ "@types/bun": "1.4.1",
92
86
  "@types/jsdom": "21.1.7",
93
87
  "@types/node": "^26.1.2",
94
88
  "@types/react": "^19.2.18",
@@ -112,7 +106,7 @@
112
106
  "hono": ">=4.0.0",
113
107
  "iti": "^0.8.0",
114
108
  "next": "16.3.0",
115
- "typescript": ">=5.7.0"
109
+ "typescript": ">=6.0.0"
116
110
  },
117
111
  "peerDependenciesMeta": {
118
112
  "@opentelemetry/api": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-BphfFUMO.mjs","names":[],"sources":["../src/runtime/errors.ts","../src/runtime/context.ts"],"sourcesContent":["/** Thrown when no RuntimeContext is active in the selected storage. */\nexport class RuntimeContextNotConfiguredError extends Error {\n constructor() {\n super('No RuntimeContext is available in the current execution context')\n\n this.name = 'RuntimeContextNotConfiguredError'\n }\n}\n\n/** Thrown when ExplicitRuntimeContextStorage cannot safely overlap lineages. */\nexport class RuntimeContextOverlapError extends Error {\n constructor() {\n super(\n 'ExplicitRuntimeContextStorage does not support overlapping root or derived context runs; use NodeRuntimeContextStorage for concurrent async branches'\n )\n\n this.name = 'RuntimeContextOverlapError'\n }\n}\n","import { RuntimeContextNotConfiguredError } from './errors'\n\nimport type { Scope } from '../scope/scope'\nimport type { AnyServiceToken, ServiceResolver } from '../service'\nimport { isPromiseLike } from '../utils/runtime'\n\n/** Contextual state shared by Service, Scope and Layer resolution. */\nexport interface RuntimeContext {\n readonly resolver?: ServiceResolver\n readonly scope?: Scope\n readonly signal?: AbortSignal\n readonly resolutionPath: readonly AnyServiceToken[]\n /** Runtime execution owner, omitted for warmup and Runtime-root activity. */\n readonly executionId?: string\n}\n\n/** A context with both channels required by a Runtime execution. */\nexport type CompleteRuntimeContext = RuntimeContext & {\n readonly resolver: ServiceResolver\n readonly scope: Scope\n}\n\n/** Host-specific storage for the current RuntimeContext. */\nexport interface RuntimeContextStorage {\n run<A>(context: RuntimeContext, program: () => A): A\n current(): RuntimeContext\n}\n\nconst unconfiguredRuntimeContextStorage: RuntimeContextStorage = {\n run: (_context, program) => program(),\n current: () => {\n throw new RuntimeContextNotConfiguredError()\n }\n}\n\nconst contextLineages = new WeakMap<object, RuntimeContext>()\n\n/** Associate a derived context with the root context of its execution lineage. */\nexport const inheritRuntimeContextLineage = (\n context: RuntimeContext,\n parent: RuntimeContext\n): RuntimeContext => {\n const lineage = contextLineages.get(parent) ?? parent\n contextLineages.set(context, lineage)\n return context\n}\n\n/** Return the root context associated with a contextual value, when known. */\nexport const getRuntimeContextLineage = (context: RuntimeContext): RuntimeContext | undefined =>\n contextLineages.get(context)\n\n/** Associate a newly-entered root context with itself. */\nexport const setRuntimeContextLineage = (context: RuntimeContext): RuntimeContext => {\n contextLineages.set(context, context)\n return context\n}\n\nconst hasPathPrefix = (\n parent: readonly AnyServiceToken[],\n child: readonly AnyServiceToken[]\n): boolean =>\n child.length >= parent.length && parent.every((token, index) => child[index] === token)\n\n/** Recognize contexts created by a nested Service, Scope, or Layer operation. */\nexport const isDerivedRuntimeContext = (parent: RuntimeContext, child: RuntimeContext): boolean =>\n parent.resolver !== undefined &&\n child.resolver === parent.resolver &&\n parent.resolutionPath.length > 0 &&\n hasPathPrefix(parent.resolutionPath, child.resolutionPath) &&\n (child.resolutionPath.length > parent.resolutionPath.length || child.scope !== parent.scope)\n\n/** Build a context while retaining only channels that are actually available. */\nexport function makeRuntimeContext(\n resolver: ServiceResolver,\n scope: Scope,\n resolutionPath: readonly AnyServiceToken[],\n signal: AbortSignal | undefined,\n parent?: RuntimeContext,\n executionId?: string\n): CompleteRuntimeContext\nexport function makeRuntimeContext(\n resolver: ServiceResolver | undefined,\n scope: Scope | undefined,\n resolutionPath: readonly AnyServiceToken[],\n signal: AbortSignal | undefined,\n parent?: RuntimeContext,\n executionId?: string\n): RuntimeContext\nexport function makeRuntimeContext(\n resolver: ServiceResolver | undefined,\n scope: Scope | undefined,\n resolutionPath: readonly AnyServiceToken[],\n signal: AbortSignal | undefined,\n parent?: RuntimeContext,\n executionId?: string\n): RuntimeContext {\n const context: RuntimeContext = { resolutionPath }\n const ownerExecutionId = executionId ?? parent?.executionId\n\n if (resolver !== undefined) {\n Object.assign(context, { resolver })\n }\n\n if (scope !== undefined) {\n Object.assign(context, { scope })\n }\n\n if (signal !== undefined) {\n Object.assign(context, { signal })\n }\n\n if (ownerExecutionId !== undefined) {\n Object.assign(context, { executionId: ownerExecutionId })\n }\n\n if (parent !== undefined) {\n inheritRuntimeContextLineage(context, parent)\n }\n\n return context\n}\n\n/** A context frame selected for one logical Runtime execution branch. */\nexport type ActiveRuntimeContextFrame = {\n readonly storage: RuntimeContextStorage\n readonly context: RuntimeContext\n readonly parent?: ActiveRuntimeContextFrame\n}\n\n/** Host-provided propagation for Runtime context frames. */\nexport interface RuntimeContextFrameCarrier {\n run<A>(frame: ActiveRuntimeContextFrame, program: () => A): A\n current(): ActiveRuntimeContextFrame | undefined\n}\n\nlet defaultStorage = unconfiguredRuntimeContextStorage\nlet fallbackFrame: ActiveRuntimeContextFrame | undefined\nconst fallbackFrames = new Set<ActiveRuntimeContextFrame>()\n\nconst settleWithRuntimeStorage = <A>(value: A, restore: () => void): A => {\n let promiseLike: boolean\n\n try {\n promiseLike = isPromiseLike(value)\n } catch (cause) {\n restore()\n throw cause\n }\n\n if (!promiseLike) {\n restore()\n return value\n }\n\n try {\n // SAFETY: PromiseLike values are normalized only to restore the storage after settlement; the public generic retains the callback's awaited shape.\n return Promise.resolve(value).then(\n (resolved) => {\n restore()\n return resolved\n },\n (cause) => {\n restore()\n throw cause\n }\n ) as A\n } catch (cause) {\n restore()\n throw cause\n }\n}\n\nconst restoreFallbackFrame = (frame: ActiveRuntimeContextFrame): void => {\n fallbackFrames.delete(frame)\n\n if (fallbackFrame !== frame) {\n return\n }\n\n let parent = frame.parent\n\n while (parent !== undefined && !fallbackFrames.has(parent)) {\n parent = parent.parent\n }\n\n fallbackFrame = parent\n}\n\nconst fallbackRuntimeContextFrameCarrier: RuntimeContextFrameCarrier = {\n run<A>(frame: ActiveRuntimeContextFrame, program: () => A): A {\n fallbackFrames.add(frame)\n fallbackFrame = frame\n const restore = (): void => restoreFallbackFrame(frame)\n\n try {\n return settleWithRuntimeStorage(program(), restore)\n } catch (cause) {\n restore()\n throw cause\n }\n },\n\n current: () => fallbackFrame\n}\n\nlet runtimeContextFrameCarrier: RuntimeContextFrameCarrier = fallbackRuntimeContextFrameCarrier\n\n/** Install host async-context propagation for Runtime context frames. */\nexport const setRuntimeContextFrameCarrier = (carrier: RuntimeContextFrameCarrier): void => {\n runtimeContextFrameCarrier = carrier\n}\n\n/** Return whether a host async-context carrier has been installed. */\nexport const isRuntimeContextFrameCarrierInstalled = (): boolean =>\n runtimeContextFrameCarrier !== fallbackRuntimeContextFrameCarrier\n\n/** Return the frame associated with the executing callback. */\nexport const currentRuntimeContextFrame = (): ActiveRuntimeContextFrame | undefined =>\n runtimeContextFrameCarrier.current()\n\n/** Install the host default used by the main Runtime entrypoint. */\nexport const setDefaultRuntimeContextStorage = (storage: RuntimeContextStorage): void => {\n defaultStorage = storage\n}\n\n/** Return the storage currently associated with the executing callback. */\nexport const activeRuntimeContextStorage = (): RuntimeContextStorage =>\n currentRuntimeContextFrame()?.storage ?? defaultStorage\n\n/** Return the active context, or undefined when the storage has not been entered. */\nexport const getRuntimeContext = (\n storage: RuntimeContextStorage = activeRuntimeContextStorage()\n): RuntimeContext | undefined => {\n const frame = currentRuntimeContextFrame()\n\n if (frame?.storage === storage) {\n return frame.context\n }\n\n try {\n return storage.current()\n } catch (cause) {\n if (cause instanceof RuntimeContextNotConfiguredError) {\n return undefined\n }\n\n throw cause\n }\n}\n\n/** Return the active context or throw the storage's standard missing-context error. */\nexport const currentRuntimeContext = (): RuntimeContext => {\n const frame = currentRuntimeContextFrame()\n\n return frame?.context ?? defaultStorage.current()\n}\n\n/** Keep a storage discoverable to Service and Scope compatibility bridges. */\nexport const withActiveRuntimeContextStorage = <A>(\n storage: RuntimeContextStorage,\n context: RuntimeContext,\n program: () => A\n): A => {\n const current = currentRuntimeContextFrame()\n\n if (current?.storage === storage && current.context === context) {\n return program()\n }\n\n const frame: ActiveRuntimeContextFrame =\n current === undefined ? { storage, context } : { storage, context, parent: current }\n\n return runtimeContextFrameCarrier.run(frame, program)\n}\n\n/** Run a callback in a context while keeping the selected storage discoverable to bridges. */\nexport const runRuntimeContext = <A>(\n storage: RuntimeContextStorage,\n context: RuntimeContext,\n program: () => A\n): A => {\n const current = getRuntimeContext(storage)\n const contextual =\n current !== undefined && isDerivedRuntimeContext(current, context)\n ? inheritRuntimeContextLineage(context, current)\n : context\n\n return storage.run(contextual, () =>\n withActiveRuntimeContextStorage(storage, contextual, program)\n )\n}\n"],"mappings":";;;AACA,IAAa,mCAAb,cAAsD,MAAM;CAC1D,cAAc;EACZ,MAAM,iEAAiE;EAEvE,KAAK,OAAO;CACd;AACF;;AAGA,IAAa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CAGf,IAAI;EACF,OAAO,QAAQ,QAAQ;CACzB,SAAS,OAAO;EACd,IAAI,iBAAiB,kCACnB;EAGF,MAAM;CACR;AACF;;AAGA,MAAa,8BAA8C;CAGzD,OAFc,2BAEH,CAAC,EAAE,WAAW,eAAe,QAAQ;AAClD;;AAGA,MAAa,mCACX,SACA,SACA,YACM;CACN,MAAM,UAAU,2BAA2B;CAE3C,IAAI,SAAS,YAAY,WAAW,QAAQ,YAAY,SACtD,OAAO,QAAQ;CAGjB,MAAM,QACJ,YAAY,KAAA,IAAY;EAAE;EAAS;CAAQ,IAAI;EAAE;EAAS;EAAS,QAAQ;CAAQ;CAErF,OAAO,2BAA2B,IAAI,OAAO,OAAO;AACtD;;AAGA,MAAa,qBACX,SACA,SACA,YACM;CACN,MAAM,UAAU,kBAAkB,OAAO;CACzC,MAAM,aACJ,YAAY,KAAA,KAAa,wBAAwB,SAAS,OAAO,IAC7D,6BAA6B,SAAS,OAAO,IAC7C;CAEN,OAAO,QAAQ,IAAI,kBACjB,gCAAgC,SAAS,YAAY,OAAO,CAC9D;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"current-request-CIU7AHhF.d.mts","names":[],"sources":["../src/standard-services/current-request.ts"],"mappings":";;;;;;;;;;;;cAIa,uBAAuB;WAIb;WAHZ;EAGY,YAAA;SAMd,MAAM,iBAAc,YAAA,cAAA;;cAMhB,sBAAuB,mBAAc,YAAA,cAAA"}
@@ -1,57 +0,0 @@
1
- import { d as setDefaultRuntimeContextStorage } from "./context-BphfFUMO.mjs";
2
- import { n as nodeRuntimeContextStorage } from "./node-context-Ca18oNSg.mjs";
3
- //#region src/runtime/default.ts
4
- /** The Node/Bun storage used by the main Runtime entrypoint. */
5
- const defaultRuntimeContextStorage = nodeRuntimeContextStorage;
6
- setDefaultRuntimeContextStorage(defaultRuntimeContextStorage);
7
- //#endregion
8
- //#region src/scope/errors.ts
9
- /** Thrown when Scope context is accessed outside an active Scope execution. */
10
- var ScopeRuntimeNotConfiguredError = class extends Error {
11
- constructor() {
12
- super("No Scope is available in the current execution context");
13
- this.name = "ScopeRuntimeNotConfiguredError";
14
- }
15
- };
16
- /** Thrown when a resource or finalizer is added after Scope closure begins. */
17
- var ScopeClosedError = class extends Error {
18
- constructor() {
19
- super("Cannot add resources or finalizers to a closed Scope");
20
- this.name = "ScopeClosedError";
21
- }
22
- };
23
- /** Aggregates finalizer failures encountered while closing a Scope. */
24
- var ScopeCloseError = class extends Error {
25
- causes;
26
- constructor(causes) {
27
- super(`Failed to close Scope (${causes.length} finalizer${causes.length === 1 ? "" : "s"} failed)`);
28
- this.causes = causes;
29
- this.name = "ScopeCloseError";
30
- }
31
- };
32
- /** Thrown when a value has neither Symbol.dispose nor Symbol.asyncDispose. */
33
- var ResourceNotDisposableError = class extends Error {
34
- constructor() {
35
- super("Resource does not implement Symbol.dispose or Symbol.asyncDispose");
36
- this.name = "ResourceNotDisposableError";
37
- }
38
- };
39
- //#endregion
40
- //#region src/scope/disposable.ts
41
- const SCOPE_SUCCESS = { status: "success" };
42
- /** Return a Scope finalizer for a value's async or sync disposal protocol. */
43
- const getDisposeFinalizer = (resource) => {
44
- const candidate = Object(resource);
45
- const asyncDispose = candidate[Symbol.asyncDispose];
46
- if (asyncDispose instanceof Function) return () => asyncDispose.call(resource);
47
- const dispose = candidate[Symbol.dispose];
48
- if (dispose instanceof Function) return () => dispose.call(resource);
49
- };
50
- /** Dispose a value immediately when it implements a disposal protocol. */
51
- const disposeResource = (resource) => {
52
- return getDisposeFinalizer(resource)?.(SCOPE_SUCCESS);
53
- };
54
- //#endregion
55
- export { ScopeClosedError as a, ScopeCloseError as i, getDisposeFinalizer as n, ScopeRuntimeNotConfiguredError as o, ResourceNotDisposableError as r, defaultRuntimeContextStorage as s, disposeResource as t };
56
-
57
- //# sourceMappingURL=disposable-CP-Q2H3l.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"disposable-CP-Q2H3l.mjs","names":[],"sources":["../src/runtime/default.ts","../src/scope/errors.ts","../src/scope/disposable.ts"],"sourcesContent":["import { nodeRuntimeContextStorage } from './node-context'\n\nimport { setDefaultRuntimeContextStorage } from './context'\n\n/** The Node/Bun storage used by the main Runtime entrypoint. */\nexport const defaultRuntimeContextStorage = nodeRuntimeContextStorage\n\nsetDefaultRuntimeContextStorage(defaultRuntimeContextStorage)\n","/** Thrown when Scope context is accessed outside an active Scope execution. */\nexport class ScopeRuntimeNotConfiguredError extends Error {\n constructor() {\n super('No Scope is available in the current execution context')\n\n this.name = 'ScopeRuntimeNotConfiguredError'\n }\n}\n\n/** Thrown when a resource or finalizer is added after Scope closure begins. */\nexport class ScopeClosedError extends Error {\n constructor() {\n super('Cannot add resources or finalizers to a closed Scope')\n\n this.name = 'ScopeClosedError'\n }\n}\n\n/** Aggregates finalizer failures encountered while closing a Scope. */\nexport class ScopeCloseError extends Error {\n constructor(readonly causes: readonly unknown[]) {\n super(\n `Failed to close Scope (${causes.length} finalizer${causes.length === 1 ? '' : 's'} failed)`\n )\n\n this.name = 'ScopeCloseError'\n }\n}\n\n/** Thrown when a value has neither Symbol.dispose nor Symbol.asyncDispose. */\nexport class ResourceNotDisposableError extends Error {\n constructor() {\n super('Resource does not implement Symbol.dispose or Symbol.asyncDispose')\n\n this.name = 'ResourceNotDisposableError'\n }\n}\n","import type { ScopeFinalizer } from './types'\n\nconst SCOPE_SUCCESS = { status: 'success' } as const\n\ntype Disposer = (...args: never[]) => void | PromiseLike<void>\n\ntype DisposableCandidate = {\n [Symbol.dispose]?: Disposer\n\n [Symbol.asyncDispose]?: Disposer\n}\n\n/** Return a Scope finalizer for a value's async or sync disposal protocol. */\nexport const getDisposeFinalizer = <Resource>(resource: Resource): ScopeFinalizer | undefined => {\n // SAFETY: Object() provides a property-bearing view for protocol lookup; each method is checked for callability before invocation.\n const candidate = Object(resource) as DisposableCandidate\n const asyncDispose = candidate[Symbol.asyncDispose]\n\n if (asyncDispose instanceof Function) {\n return () => asyncDispose.call(resource)\n }\n\n const dispose = candidate[Symbol.dispose]\n\n if (dispose instanceof Function) {\n return () => dispose.call(resource)\n }\n\n return undefined\n}\n\n/** Dispose a value immediately when it implements a disposal protocol. */\nexport const disposeResource = <Resource>(resource: Resource): void | PromiseLike<void> => {\n const finalizer = getDisposeFinalizer(resource)\n\n return finalizer?.(SCOPE_SUCCESS)\n}\n"],"mappings":";;;;AAKA,MAAa,+BAA+B;AAE5C,gCAAgC,4BAA4B;;;;ACN5D,IAAa,iCAAb,cAAoD,MAAM;CACxD,cAAc;EACZ,MAAM,wDAAwD;EAE9D,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,mBAAb,cAAsC,MAAM;CAC1C,cAAc;EACZ,MAAM,sDAAsD;EAE5D,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CACpB;CAArB,YAAY,QAAqC;EAC/C,MACE,0BAA0B,OAAO,OAAO,YAAY,OAAO,WAAW,IAAI,KAAK,IAAI,SACrF;EAHmB,KAAA,SAAA;EAKnB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,6BAAb,cAAgD,MAAM;CACpD,cAAc;EACZ,MAAM,mEAAmE;EAEzE,KAAK,OAAO;CACd;AACF;;;AClCA,MAAM,gBAAgB,EAAE,QAAQ,UAAU;;AAW1C,MAAa,uBAAiC,aAAmD;CAE/F,MAAM,YAAY,OAAO,QAAQ;CACjC,MAAM,eAAe,UAAU,OAAO;CAEtC,IAAI,wBAAwB,UAC1B,aAAa,aAAa,KAAK,QAAQ;CAGzC,MAAM,UAAU,UAAU,OAAO;CAEjC,IAAI,mBAAmB,UACrB,aAAa,QAAQ,KAAK,QAAQ;AAItC;;AAGA,MAAa,mBAA6B,aAAiD;CAGzF,OAFkB,oBAAoB,QAEvB,CAAC,GAAG,aAAa;AAClC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"effect-CPdV7Yv8.mjs","names":["map","mapError","andThen","next","resultMatchError","resultMatchErrorPartial","tap","tapError","matchError","matchErrorPartial","recover","programMap","programMapError","programAndThen","programTap","programTapError","programRecover"],"sources":["../src/effect/combinators.ts","../src/effect/program-combinators.ts","../src/effect/program-scheduler.ts","../src/effect/effect.ts"],"sourcesContent":["import {\n matchError as resultMatchError,\n matchErrorPartial as resultMatchErrorPartial,\n Result\n} from 'better-result'\n\nimport type { Result as ResultType } from 'better-result'\n\nimport type { AnyService } from '../service'\nimport { isPromiseLike } from '../utils/runtime'\nimport type { Effect, EffectError, EffectRequirements, EffectSuccess } from './types'\n\ntype EffectInput<A, E> = ResultType<A, E> | PromiseLike<ResultType<A, E>>\n\ntype AnyEffectInput = EffectInput<any, any>\ntype AnyEffectValue = ResultType<any, any>\ntype AnyAsyncEffectInput = PromiseLike<ResultType<any, any>>\ntype CombinatorCallback = (value: any) => any\ntype CombinatorInput = AnyEffectInput | CombinatorCallback\n\ntype PreserveAsync<Input, Output> = Input extends PromiseLike<unknown> ? Promise<Output> : Output\n\ntype MappedResult<Input, B> = Effect<B, EffectError<Input>, EffectRequirements<Input>>\n\ntype ErrorMappedResult<Input, E2> = Effect<EffectSuccess<Input>, E2, EffectRequirements<Input>>\n\ntype ChainedResult<First, Next> = Effect<\n EffectSuccess<Next>,\n EffectError<First> | EffectError<Next>,\n EffectRequirements<First> | EffectRequirements<Next>\n>\n\ntype ChainedOutput<First, Next> = ChainedResult<First, Next>\n\ntype AsyncChainedOutput<First, Next> = Promise<ChainedResult<First, Next>>\n\ntype MapOperation<A, B> = {\n <Input>(effect: Input & EffectInput<A, any>): PreserveAsync<Input, MappedResult<Input, B>>\n}\n\ntype MapErrorOperation<E1, E2> = {\n <Input>(effect: Input & EffectInput<any, E1>): PreserveAsync<Input, ErrorMappedResult<Input, E2>>\n}\n\ntype AndThenOperation<Next> = {\n <Input>(effect: Input & AnyEffectValue): ChainedOutput<Input, Next>\n}\n\ntype AndThenAsyncOperation<A, Next> = {\n <Input>(effect: Input & EffectInput<A, any>): AsyncChainedOutput<Input, Next>\n}\n\ntype TappedResult<Input> = Effect<\n EffectSuccess<Input>,\n EffectError<Input>,\n EffectRequirements<Input>\n>\n\ntype RecoveredResult<Input, Next> = Effect<\n EffectSuccess<Input> | EffectSuccess<Next>,\n EffectError<Next>,\n EffectRequirements<Input> | EffectRequirements<Next>\n>\n\ntype FlattenedResult<Input> = Effect<\n EffectSuccess<EffectSuccess<Input>>,\n EffectError<Input> | EffectError<EffectSuccess<Input>>,\n EffectRequirements<Input> | EffectRequirements<EffectSuccess<Input>>\n>\n\ntype AsResult<Input, Value> = Effect<Value, EffectError<Input>, EffectRequirements<Input>>\n\ntype MatchedResult<Input, OkResult, ErrResult> = Effect<\n EffectSuccess<OkResult> | EffectSuccess<ErrResult>,\n EffectError<OkResult> | EffectError<ErrResult>,\n EffectRequirements<Input> | EffectRequirements<OkResult> | EffectRequirements<ErrResult>\n>\n\ntype AllResult<Results extends readonly AnyEffectValue[]> = Effect<\n { -readonly [Index in keyof Results]: EffectSuccess<Results[Index]> },\n EffectError<Results[number]>,\n EffectRequirements<Results[number]>\n>\n\ntype ZipResult<Left, Right> = Effect<\n [EffectSuccess<Left>, EffectSuccess<Right>],\n EffectError<Left> | EffectError<Right>,\n EffectRequirements<Left> | EffectRequirements<Right>\n>\n\ntype TapOperation = {\n <Input>(\n effect: Input & AnyEffectInput,\n fn: (value: EffectSuccess<Input>) => void\n ): PreserveAsync<Input, TappedResult<Input>>\n}\n\ntype TapErrorOperation = {\n <Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => void\n ): PreserveAsync<Input, TappedResult<Input>>\n}\n\ntype TapBothOperation = {\n <Input>(\n effect: Input & AnyEffectInput,\n handlers: {\n ok: (value: EffectSuccess<Input>) => void\n err: (error: EffectError<Input>) => void\n }\n ): PreserveAsync<Input, TappedResult<Input>>\n}\n\ntype TapAsyncOperation = {\n <Input>(effect: Input & AnyEffectInput): Promise<TappedResult<Input>>\n}\n\ntype TapErrorAsyncOperation = {\n <Input>(effect: Input & AnyEffectInput): Promise<TappedResult<Input>>\n}\n\ntype TapBothAsyncOperation = {\n <Input>(effect: Input & AnyEffectInput): Promise<TappedResult<Input>>\n}\n\ntype TaggedErrorLike = Error & { readonly _tag: string }\n\ntype TaggedErrorHandlers<ErrorValue extends TaggedErrorLike> = {\n // oxlint-disable-next-line anti-slop/no-unknown-returns -- better-result matchers allow arbitrary handler results.\n [Tag in ErrorValue['_tag']]: (error: Extract<ErrorValue, { readonly _tag: Tag }>) => unknown\n}\n\ntype TaggedErrorOf<Input> = Extract<EffectError<Input>, TaggedErrorLike>\n\ntype TaggedErrorHandlersFor<Input> = [EffectError<Input>] extends [TaggedErrorLike]\n ? TaggedErrorHandlers<TaggedErrorOf<Input>>\n : never\n\ntype HandlerReturn<Handlers> = {\n [Key in keyof Handlers]-?: NonNullable<Handlers[Key]> extends (error: never) => infer Return\n ? Return\n : never\n}[keyof Handlers]\n\ntype RequiredHandlerKeys<Handlers> = {\n [Key in keyof Handlers]-?: {} extends Pick<Handlers, Key>\n ? never\n : undefined extends Handlers[Key]\n ? never\n : Key\n}[keyof Handlers]\n\ntype UnhandledTaggedErrors<ErrorValue extends TaggedErrorLike, Handlers> = Exclude<\n ErrorValue,\n { readonly _tag: Extract<RequiredHandlerKeys<Handlers>, ErrorValue['_tag']> }\n>\n\ntype MatchErrorResult<Input, Handlers> = Effect<\n EffectSuccess<Input>,\n HandlerReturn<Handlers>,\n EffectRequirements<Input>\n>\n\ntype MatchErrorPartialResult<Input, Handlers> = Effect<\n EffectSuccess<Input>,\n HandlerReturn<Handlers> | UnhandledTaggedErrors<TaggedErrorOf<Input>, Handlers>,\n EffectRequirements<Input>\n>\n\ntype RecoverOperation<Next> = {\n <Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => Next\n ): PreserveAsync<Input, RecoveredResult<Input, Next>>\n}\n\ntype RecoverAsyncOperation<Next> = {\n <Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => Next\n ): Promise<RecoveredResult<Input, Next>>\n}\n\nconst asResult = <Value>(value: Value): ResultType<any, any> => {\n // SAFETY: Effect is the declaration-only Result facade, so every runtime value is a Result.\n return value as ResultType<any, any>\n}\n\nconst mapResult = <A, B, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (value: A) => B\n): Effect<B, E, Requirements> => {\n // SAFETY: Result.map changes only the success channel; the declaration-only Effect marker is restored by this adapter.\n return Result.map(result, fn) as Effect<B, E, Requirements>\n}\n\nconst mapErrorResult = <A, E1, E2, Requirements extends AnyService>(\n result: ResultType<A, E1>,\n fn: (error: E1) => E2\n): Effect<A, E2, Requirements> => {\n // SAFETY: Result.mapError changes only the error channel; the declaration-only Effect marker is restored by this adapter.\n return Result.mapError(result, fn) as Effect<A, E2, Requirements>\n}\n\nconst andThenResult = <\n A,\n B,\n E1,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<A, E1>,\n next: (value: A) => ResultType<B, E2>\n): Effect<B, E1 | E2, Requirements1 | Requirements2> => {\n // SAFETY: The public callback returns an Effect, whose only runtime contract is the underlying Result.\n const resultNext = next as (value: A) => ResultType<B, E2>\n\n // SAFETY: Result.andThen unions Result errors; the declaration-only Effect marker is restored by this adapter.\n return Result.andThen(result, resultNext) as Effect<B, E1 | E2, Requirements1 | Requirements2>\n}\n\nconst andThenAsyncResult = <\n A,\n B,\n E1,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<A, E1>,\n next: (value: A) => PromiseLike<ResultType<B, E2>>\n): Promise<Effect<B, E1 | E2, Requirements1 | Requirements2>> => {\n // SAFETY: The public callback returns an Effect, whose only runtime contract is the underlying Result.\n const resultNext = (value: A) => {\n // SAFETY: Promise resolution preserves the callback's Result value; only declaration-only Effect metadata is erased.\n return Promise.resolve(next(value)) as Promise<ResultType<B, E2>>\n }\n\n // SAFETY: Result.andThenAsync unions Result errors; the declaration-only Effect marker is restored by this adapter.\n return Result.andThenAsync(result, resultNext) as Promise<\n Effect<B, E1 | E2, Requirements1 | Requirements2>\n >\n}\n\n/**\n * Map the successful value of a Result or Effect result.\n *\n * Supports both data-first and data-last forms and preserves asynchronous\n * results and declaration-only Service requirements.\n *\n * @example\n * ```ts\n * const doubled = Effect.map(Result.ok(2), (value) => value * 2)\n * const toLabel = Effect.map((value: number) => `#${value}`)\n * ```\n */\nexport function map<A, B>(fn: (value: A) => B): MapOperation<A, B>\nexport function map<Input, B>(\n effect: Input & AnyEffectInput,\n fn: (value: EffectSuccess<Input>) => B\n): PreserveAsync<Input, MappedResult<Input, B>>\nexport function map(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n // SAFETY: The curried overload accepts a unary mapping callback in this branch.\n const callback = first as CombinatorCallback\n\n return (effect: AnyEffectInput) => {\n // SAFETY: The overload implementation has already established the callback and Effect input positions.\n return map(effect as never, callback as never)\n }\n }\n\n // SAFETY: The data-first overload requires the second argument to be a unary mapping callback.\n const fn = second as CombinatorCallback\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => {\n // SAFETY: Result is the runtime representation shared by Effect and better-result.\n return mapResult(result as ResultType<any, any>, fn)\n })\n }\n\n // SAFETY: The data-first overload supplies a Result-compatible Effect value.\n return mapResult(first as ResultType<any, any>, fn)\n}\n\n/**\n * Map the error value of a Result or Effect result while preserving its\n * successful value, asynchronous shape, and declaration-only Service requirements.\n *\n * @example\n * ```ts\n * const labelled = Effect.mapError(Result.err('missing'), (error) => ({ error }))\n * ```\n */\nexport function mapError<E1, E2>(fn: (error: E1) => E2): MapErrorOperation<E1, E2>\nexport function mapError<Input, E2>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => E2\n): PreserveAsync<Input, ErrorMappedResult<Input, E2>>\nexport function mapError(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n // SAFETY: The curried overload accepts a unary error-mapping callback in this branch.\n const callback = first as CombinatorCallback\n\n return (effect: AnyEffectInput) => {\n // SAFETY: The overload implementation has already established the callback and Effect input positions.\n return mapError(effect as never, callback as never)\n }\n }\n\n // SAFETY: The data-first overload requires the second argument to be a unary error-mapping callback.\n const fn = second as CombinatorCallback\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => {\n // SAFETY: Result is the runtime representation shared by Effect and better-result.\n return mapErrorResult(result as ResultType<any, any>, fn)\n })\n }\n\n // SAFETY: The data-first overload supplies a Result-compatible Effect value.\n return mapErrorResult(first as ResultType<any, any>, fn)\n}\n\n/**\n * Chain a synchronous Result-producing operation after a successful result.\n *\n * The next operation is skipped when the input is an error. Both error types\n * and both sets of Service requirements are preserved in the output.\n *\n * @example\n * ```ts\n * const user = Effect.andThen(Result.ok('u1'), (id) => repository.find(id))\n * ```\n */\nexport function andThen<A, Next extends AnyEffectValue>(\n next: (value: A) => Next\n): AndThenOperation<Next>\nexport function andThen<Input, Next extends AnyEffectValue>(\n effect: Input & AnyEffectValue,\n next: (value: EffectSuccess<Input>) => Next\n): ChainedOutput<Input, Next>\nexport function andThen(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n // SAFETY: The curried overload accepts a unary continuation in this branch.\n const callback = first as CombinatorCallback\n\n return (effect: AnyEffectInput) => {\n // SAFETY: The overload implementation has already established the callback and Effect input positions.\n return andThen(effect as never, callback as never)\n }\n }\n\n // SAFETY: The data-first overload requires the second argument to return a Result.\n const next = second as CombinatorCallback\n\n // SAFETY: The data-first overload supplies a Result-compatible Effect value.\n return andThenResult(first as ResultType<any, any>, next)\n}\n\n/**\n * Chain an asynchronous Result-producing operation after a successful result.\n *\n * The returned value is always a Promise and retains both operations' error\n * and Service-requirement metadata.\n *\n * @example\n * ```ts\n * const user = Effect.andThenAsync(loadUser(), (user) => fetchProfile(user.id))\n * ```\n */\nexport function andThenAsync<A, Next extends AnyAsyncEffectInput>(\n next: (value: A) => Next\n): AndThenAsyncOperation<A, Next>\nexport function andThenAsync<Input, Next extends AnyAsyncEffectInput>(\n effect: Input & AnyEffectInput,\n next: (value: EffectSuccess<Input>) => Next\n): AsyncChainedOutput<Input, Next>\nexport function andThenAsync(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n // SAFETY: The curried overload accepts a unary asynchronous continuation in this branch.\n const callback = first as CombinatorCallback\n\n return (effect: AnyEffectInput) => {\n // SAFETY: The overload implementation has already established the callback and Effect input positions.\n return andThenAsync(effect as never, callback as never)\n }\n }\n\n // SAFETY: The data-first overload requires the second argument to return a PromiseLike Effect.\n const next = second as CombinatorCallback\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => {\n // SAFETY: Result is the runtime representation shared by Effect and better-result.\n return andThenAsyncResult(result as ResultType<any, any>, next)\n })\n }\n\n // SAFETY: The data-first overload supplies a Result-compatible Effect value.\n return andThenAsyncResult(first as ResultType<any, any>, next)\n}\n\nconst tapResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (value: A) => void\n): Effect<A, E, Requirements> =>\n // SAFETY: Result.tap preserves the Result value; the declaration-only Effect marker is restored here.\n Result.tap(result, fn) as Effect<A, E, Requirements>\n\nconst tapErrorResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (error: E) => void\n): Effect<A, E, Requirements> =>\n // SAFETY: Result.tapError preserves the Result value; the declaration-only Effect marker is restored here.\n Result.tapError(result, fn) as Effect<A, E, Requirements>\n\nconst tapBothResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n handlers: { ok: (value: A) => void; err: (error: E) => void }\n): Effect<A, E, Requirements> =>\n // SAFETY: Result.tapBoth preserves the Result value; the declaration-only Effect marker is restored here.\n Result.tapBoth(result, handlers) as Effect<A, E, Requirements>\n\nconst tapAsyncResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (value: A) => PromiseLike<void>\n): Promise<Effect<A, E, Requirements>> =>\n // SAFETY: Result.tapAsync preserves the Result value and owns observer defect behavior; only the Effect marker is restored here.\n Result.tapAsync(result, (value) => Promise.resolve(fn(value))) as Promise<\n Effect<A, E, Requirements>\n >\n\nconst tapErrorAsyncResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (error: E) => PromiseLike<void>\n): Promise<Effect<A, E, Requirements>> =>\n // SAFETY: Result.tapErrorAsync preserves the Result value and owns observer defect behavior; only the Effect marker is restored here.\n Result.tapErrorAsync(result, (error) => Promise.resolve(fn(error))) as Promise<\n Effect<A, E, Requirements>\n >\n\nconst tapBothAsyncResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n handlers: { ok: (value: A) => PromiseLike<void>; err: (error: E) => PromiseLike<void> }\n): Promise<Effect<A, E, Requirements>> =>\n // SAFETY: Result.tapBothAsync selects one branch and preserves the Result; only the Effect marker is restored here.\n Result.tapBothAsync(result, {\n ok: (value) => Promise.resolve(handlers.ok(value)),\n err: (error) => Promise.resolve(handlers.err(error))\n }) as Promise<Effect<A, E, Requirements>>\n\nconst asTaggedResult = (\n result: ResultType<unknown, unknown>\n): ResultType<unknown, TaggedErrorLike> => {\n // SAFETY: The public matcher overload restricts error values to TaggedErrorLike before reaching this runtime boundary.\n return result as ResultType<unknown, TaggedErrorLike>\n}\n\nconst matchErrorResult = <\n A,\n E extends TaggedErrorLike,\n Requirements extends AnyService,\n Handlers extends TaggedErrorHandlers<E>\n>(\n result: ResultType<A, E>,\n handlers: Handlers\n): Effect<A, HandlerReturn<Handlers>, Requirements> => {\n // SAFETY: Result.mapError selects Err and preserves Ok; the declaration-only Effect marker is restored here.\n return Result.mapError(result, (error) => resultMatchError(error, handlers)) as Effect<\n A,\n HandlerReturn<Handlers>,\n Requirements\n >\n}\n\nconst matchErrorPartialResult = <\n A,\n E extends TaggedErrorLike,\n Requirements extends AnyService,\n Handlers extends Partial<TaggedErrorHandlers<E>>\n>(\n result: ResultType<A, E>,\n handlers: Handlers\n): Effect<A, HandlerReturn<Handlers> | UnhandledTaggedErrors<E, Handlers>, Requirements> => {\n // SAFETY: Result.mapError selects Err and preserves Ok; the declaration-only Effect marker is restored here.\n return Result.mapError(result, (error) => resultMatchErrorPartial(error, handlers)) as Effect<\n A,\n HandlerReturn<Handlers> | UnhandledTaggedErrors<E, Handlers>,\n Requirements\n >\n}\n\nconst recoverResult = <\n A,\n E,\n B,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<A, E>,\n fn: (error: E) => ResultType<B, E2>\n): Effect<A | B, E2, Requirements1 | Requirements2> =>\n // SAFETY: Result.tryRecover owns recovery and short-circuiting; only Effect metadata is restored here.\n Result.tryRecover(result, fn) as Effect<A | B, E2, Requirements1 | Requirements2>\n\nconst recoverAsyncResult = <\n A,\n E,\n B,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<A, E>,\n fn: (error: E) => PromiseLike<ResultType<B, E2>>\n): Promise<Effect<A | B, E2, Requirements1 | Requirements2>> =>\n // SAFETY: Result.tryRecoverAsync owns asynchronous recovery; only Effect metadata is restored here.\n Result.tryRecoverAsync(result, (error) => Promise.resolve(fn(error))) as Promise<\n Effect<A | B, E2, Requirements1 | Requirements2>\n >\n\nconst flattenResult = <\n A,\n E1,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<ResultType<A, E2>, E1>\n): Effect<A, E1 | E2, Requirements1 | Requirements2> =>\n // SAFETY: Result.flatten removes one Result layer; the outer and inner Effect markers are restored here.\n Result.flatten(result) as Effect<A, E1 | E2, Requirements1 | Requirements2>\n\nconst matchResult = <A, E, OkResult, ErrResult>(\n result: ResultType<A, E>,\n handlers: { ok: (value: A) => OkResult; err: (error: E) => ErrResult }\n): OkResult | ErrResult =>\n // SAFETY: Result.match invokes only the selected branch; handler Results remain ordinary runtime values.\n Result.match(result, handlers as never) as OkResult | ErrResult\n\nconst allResult = <const Results extends readonly AnyEffectValue[]>(\n results: Results\n): AllResult<Results> =>\n // SAFETY: Result.all preserves tuple order and short-circuiting; the declaration-only channels are restored here.\n Result.all(results as readonly ResultType<any, any>[]) as AllResult<Results>\n\n/** Observe a successful value without changing the Result. */\nexport function tap(fn: (value: any) => void): TapOperation\nexport function tap<Input>(\n effect: Input & AnyEffectInput,\n fn: (value: EffectSuccess<Input>) => void\n): PreserveAsync<Input, TappedResult<Input>>\nexport function tap(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => tap(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.tap requires a callback')\n }\n\n const fn = second\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapResult(asResult(result), fn))\n }\n\n return tapResult(asResult(first), fn)\n}\n\n/** Observe an error value without changing the Result. */\nexport function tapError(fn: (error: any) => void): TapErrorOperation\nexport function tapError<Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => void\n): PreserveAsync<Input, TappedResult<Input>>\nexport function tapError(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => tapError(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.tapError requires a callback')\n }\n\n const fn = second\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapErrorResult(asResult(result), fn))\n }\n\n return tapErrorResult(asResult(first), fn)\n}\n\n/** Observe whichever Result branch is active without changing the Result. */\nexport function tapBoth(handlers: {\n ok: (value: any) => void\n err: (error: any) => void\n}): TapBothOperation\nexport function tapBoth<Input>(\n effect: Input & AnyEffectInput,\n handlers: {\n ok: (value: EffectSuccess<Input>) => void\n err: (error: EffectError<Input>) => void\n }\n): PreserveAsync<Input, TappedResult<Input>>\nexport function tapBoth(first: any, second?: any): any {\n if (second === undefined) {\n return (effect: AnyEffectInput) => tapBoth(effect, first)\n }\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapBothResult(result, second))\n }\n\n return tapBothResult(asResult(first), second)\n}\n\n/** Observe a successful value asynchronously without changing the Result. */\nexport function tapAsync(fn: (value: any) => PromiseLike<void>): TapAsyncOperation\nexport function tapAsync<Input>(\n effect: Input & AnyEffectInput,\n fn: (value: EffectSuccess<Input>) => PromiseLike<void>\n): Promise<TappedResult<Input>>\nexport function tapAsync(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => tapAsync(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.tapAsync requires a callback')\n }\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapAsyncResult(asResult(result), second))\n }\n\n return tapAsyncResult(asResult(first), second)\n}\n\n/** Observe an error value asynchronously without changing the Result. */\nexport function tapErrorAsync(fn: (error: any) => PromiseLike<void>): TapErrorAsyncOperation\nexport function tapErrorAsync<Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => PromiseLike<void>\n): Promise<TappedResult<Input>>\nexport function tapErrorAsync(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => tapErrorAsync(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.tapErrorAsync requires a callback')\n }\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapErrorAsyncResult(asResult(result), second))\n }\n\n return tapErrorAsyncResult(asResult(first), second)\n}\n\n/** Observe the active Result branch asynchronously without changing the Result. */\nexport function tapBothAsync(handlers: {\n ok: (value: any) => PromiseLike<void>\n err: (error: any) => PromiseLike<void>\n}): TapBothAsyncOperation\nexport function tapBothAsync<Input>(\n effect: Input & AnyEffectInput,\n handlers: {\n ok: (value: EffectSuccess<Input>) => PromiseLike<void>\n err: (error: EffectError<Input>) => PromiseLike<void>\n }\n): Promise<TappedResult<Input>>\nexport function tapBothAsync(first: any, second?: any): any {\n if (second === undefined) {\n return (effect: AnyEffectInput) => tapBothAsync(effect, first)\n }\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapBothAsyncResult(result, second))\n }\n\n return tapBothAsyncResult(asResult(first), second)\n}\n\n/** Match every tagged error variant and map it to a new error value. */\nexport function matchError<Input, Handlers extends TaggedErrorHandlersFor<Input>>(\n effect: Input & AnyEffectInput,\n handlers: Handlers\n): PreserveAsync<Input, MatchErrorResult<Input, Handlers>>\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- overload implementation is narrowed by the typed public signature.\nexport function matchError(first: AnyEffectInput, second?: unknown): any {\n if (second === undefined) {\n throw new TypeError('Effect.matchError requires handlers')\n }\n\n // SAFETY: The public matcher overload checks the handler map against the source tagged-error union.\n const handlers = second as TaggedErrorHandlers<TaggedErrorLike>\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) =>\n matchErrorResult(asTaggedResult(asResult(result)), handlers)\n )\n }\n\n return matchErrorResult(asTaggedResult(asResult(first)), handlers)\n}\n\n/** Match selected tagged errors and retain unhandled variants unchanged. */\nexport function matchErrorPartial<Input, Handlers extends Partial<TaggedErrorHandlersFor<Input>>>(\n effect: Input & AnyEffectInput,\n handlers: Handlers\n): PreserveAsync<Input, MatchErrorPartialResult<Input, Handlers>>\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- overload implementation is narrowed by the typed public signature.\nexport function matchErrorPartial(first: AnyEffectInput, second?: unknown): any {\n if (second === undefined) {\n throw new TypeError('Effect.matchErrorPartial requires handlers')\n }\n\n // SAFETY: The public matcher overload checks the handler map against the source tagged-error union.\n const handlers = second as Partial<TaggedErrorHandlers<TaggedErrorLike>>\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) =>\n matchErrorPartialResult(asTaggedResult(asResult(result)), handlers)\n )\n }\n\n return matchErrorPartialResult(asTaggedResult(asResult(first)), handlers)\n}\n\n/** Recover an Err with a synchronous Result-producing callback. */\nexport function recover<Next extends AnyEffectValue>(\n fn: (error: any) => Next\n): RecoverOperation<Next>\nexport function recover<Input, Next extends AnyEffectValue>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => Next\n): PreserveAsync<Input, RecoveredResult<Input, Next>>\nexport function recover(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => recover(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.recover requires a callback')\n }\n\n const fn = second\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => recoverResult(asResult(result), fn))\n }\n\n return recoverResult(asResult(first), fn)\n}\n\n/** Recover an Err with an asynchronous Result-producing callback. */\nexport function recoverAsync<Next extends AnyAsyncEffectInput>(\n fn: (error: any) => Next\n): RecoverAsyncOperation<Next>\nexport function recoverAsync<Input, Next extends AnyAsyncEffectInput>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => Next\n): Promise<RecoveredResult<Input, Next>>\nexport function recoverAsync(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => recoverAsync(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.recoverAsync requires a callback')\n }\n\n const fn = second\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => recoverAsyncResult(asResult(result), fn))\n }\n\n return recoverAsyncResult(asResult(first), fn)\n}\n\n/** Remove one nested Result/Effect layer. */\nexport function flatten<Input>(effect: Input & AnyEffectValue): FlattenedResult<Input> {\n // SAFETY: flattenResult restores the nested Effect channels after Result.flatten removes one runtime layer.\n return flattenResult(asResult(effect)) as FlattenedResult<Input>\n}\n\n/** Replace a successful value while preserving errors and requirements. */\nexport function as<Value>(\n value: Value\n): <Input>(effect: Input & AnyEffectValue) => AsResult<Input, Value>\nexport function as<Input, Value>(\n effect: Input & AnyEffectValue,\n value: Value\n): AsResult<Input, Value>\nexport function as(first: any, second?: any): any {\n if (arguments.length < 2) {\n return (effect: AnyEffectValue) => as(effect, first)\n }\n\n return mapResult(asResult(first), () => second)\n}\n\n/** Replace a successful value with void. */\nexport function asVoid<Input>(effect: Input & AnyEffectValue): AsResult<Input, void> {\n return mapResult(asResult(effect), () => undefined)\n}\n\n/** Match an Effect and return branch Effects with their channels unioned. */\nexport function match<Input, OkResult extends AnyEffectValue, ErrResult extends AnyEffectValue>(\n effect: Input & AnyEffectValue,\n handlers: {\n ok: (value: EffectSuccess<Input>) => OkResult\n err: (error: EffectError<Input>) => ErrResult\n }\n): PreserveAsync<Input, MatchedResult<Input, OkResult, ErrResult>>\nexport function match<Input, OkValue, ErrValue>(\n effect: Input & AnyEffectValue,\n handlers: {\n ok: (value: EffectSuccess<Input>) => OkValue\n err: (error: EffectError<Input>) => ErrValue\n }\n): PreserveAsync<Input, OkValue | ErrValue>\nexport function match(first: AnyEffectInput, second?: any): any {\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => match(asResult(result), second))\n }\n\n return matchResult(asResult(first), second)\n}\n\n/** Collect already-created Effects in input order. */\nexport function all<const Results extends readonly AnyEffectValue[]>(\n results: Results\n): AllResult<Results> {\n return allResult(results)\n}\n\n/** Combine two already-created Effects in input order. */\nexport function zip<Left, Right>(\n left: Left & AnyEffectValue,\n right: Right & AnyEffectValue\n): ZipResult<Left, Right> {\n // SAFETY: Result.all returns the ordered pair; ZipResult restores only the declaration-only Effect channels.\n return Result.all([left, right]) as ZipResult<Left, Right>\n}\n","import { Result } from 'better-result'\n\nimport type { Result as ResultType } from 'better-result'\n\nimport type { AnyService } from '../service'\nimport { inheritProgramName } from './program-metadata'\nimport { isPromiseLike } from '../utils/runtime'\n\nimport type { EffectError, EffectRequirements, EffectSuccess, Program } from './types'\n\ntype AnyResult = ResultType<any, any>\ntype RuntimeEffect = AnyResult | PromiseLike<AnyResult>\ntype RuntimeProgram = () => RuntimeEffect\ntype RuntimeProgramOutput = RuntimeEffect | RuntimeProgram\ntype RuntimeCallback = (value: any) => any\ntype RuntimeContinuation = (value: any) => RuntimeProgramOutput\ntype AnyProgram = Program<any, any, AnyService>\n\ntype ProgramInput<Input extends RuntimeProgram> = Input &\n Program<EffectSuccess<Input>, EffectError<Input>, EffectRequirements<Input>>\n\ntype CompatibleSuccess<Input, A> = EffectSuccess<Input> extends A ? unknown : never\ntype CompatibleError<Input, E> = EffectError<Input> extends E ? unknown : never\n\ntype ProgramOutput<Output> =\n Output extends Program<infer _Success, infer _Error, infer _Requirements extends AnyService>\n ? Output\n : Output extends PromiseLike<infer AsyncOutput>\n ? AsyncOutput extends ResultType<infer _Success, infer _Error>\n ? Output\n : never\n : Output extends ResultType<infer _Success, infer _Error>\n ? Output\n : never\n\ntype MappedProgram<Input, B> = Program<B, EffectError<Input>, EffectRequirements<Input>>\n\ntype ErrorMappedProgram<Input, E2> = Program<EffectSuccess<Input>, E2, EffectRequirements<Input>>\n\ntype ChainedProgram<Input, Next> = Program<\n EffectSuccess<Next>,\n EffectError<Input> | EffectError<Next>,\n EffectRequirements<Input> | EffectRequirements<Next>\n>\n\ntype TappedProgram<Input> = Program<\n EffectSuccess<Input>,\n EffectError<Input>,\n EffectRequirements<Input>\n>\n\ntype RecoveredProgram<Input, Next> = Program<\n EffectSuccess<Input> | EffectSuccess<Next>,\n EffectError<Next>,\n EffectRequirements<Input> | EffectRequirements<Next>\n>\n\ntype MapOperation<A, B> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleSuccess<Input, A>\n ): MappedProgram<Input, B>\n}\n\ntype MapErrorOperation<E1, E2> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleError<Input, E1>\n ): ErrorMappedProgram<Input, E2>\n}\n\ntype AndThenOperation<A, Next> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleSuccess<Input, A>\n ): ChainedProgram<Input, Next>\n}\n\ntype TapOperation<A> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleSuccess<Input, A>\n ): TappedProgram<Input>\n}\n\ntype TapErrorOperation<E> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleError<Input, E>\n ): TappedProgram<Input>\n}\n\ntype RecoverOperation<E, Next> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleError<Input, E>\n ): RecoveredProgram<Input, Next>\n}\n\nconst asProgram = <Output extends AnyProgram>(program: RuntimeProgram): Output =>\n // SAFETY: Program's channels and nominal marker are declaration-only; callers derive them from typed inputs.\n program as Output\n\nconst isAsyncEffect = (effect: RuntimeEffect): effect is PromiseLike<AnyResult> =>\n isPromiseLike(effect)\n\nconst mapRuntime = (effect: RuntimeEffect, fn: RuntimeCallback): RuntimeEffect => {\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.map(result, fn))\n }\n\n return Result.map(effect, fn)\n}\n\nconst mapErrorRuntime = (effect: RuntimeEffect, fn: RuntimeCallback): RuntimeEffect => {\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.mapError(result, fn))\n }\n\n return Result.mapError(effect, fn)\n}\n\nconst tapRuntime = (effect: RuntimeEffect, fn: RuntimeCallback): RuntimeEffect => {\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.tap(result, fn))\n }\n\n return Result.tap(effect, fn)\n}\n\nconst tapErrorRuntime = (effect: RuntimeEffect, fn: RuntimeCallback): RuntimeEffect => {\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.tapError(result, fn))\n }\n\n return Result.tapError(effect, fn)\n}\n\nconst invoke = (output: RuntimeProgramOutput): RuntimeEffect =>\n output instanceof Function ? output() : output\n\nconst andThenRuntime = (effect: RuntimeEffect, next: RuntimeContinuation): Promise<AnyResult> => {\n const continueWith = (value: any) => Promise.resolve(invoke(next(value)))\n\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.andThenAsync(result, continueWith))\n }\n\n return Result.andThenAsync(effect, continueWith)\n}\n\nconst recoverRuntime = (\n effect: RuntimeEffect,\n recover: RuntimeContinuation\n): Promise<AnyResult> => {\n const continueWith = (error: any) => Promise.resolve(invoke(recover(error)))\n\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.tryRecoverAsync(result, continueWith))\n }\n\n return Result.tryRecoverAsync(effect, continueWith)\n}\n\nconst mapProgram = <Input extends RuntimeProgram, B>(\n program: ProgramInput<Input>,\n fn: (value: EffectSuccess<Input>) => B\n): MappedProgram<Input, B> => {\n const mapped = asProgram<MappedProgram<Input, B>>(() => mapRuntime(program(), fn))\n\n return inheritProgramName(program, mapped)\n}\n\nconst mapErrorProgram = <Input extends RuntimeProgram, E2>(\n program: ProgramInput<Input>,\n fn: (error: EffectError<Input>) => E2\n): ErrorMappedProgram<Input, E2> => {\n const mapped = asProgram<ErrorMappedProgram<Input, E2>>(() => mapErrorRuntime(program(), fn))\n\n return inheritProgramName(program, mapped)\n}\n\nconst tapProgram = <Input extends RuntimeProgram>(\n program: ProgramInput<Input>,\n fn: (value: EffectSuccess<Input>) => any\n): TappedProgram<Input> => {\n const tapped = asProgram<TappedProgram<Input>>(() => tapRuntime(program(), fn))\n\n return inheritProgramName(program, tapped)\n}\n\nconst tapErrorProgram = <Input extends RuntimeProgram>(\n program: ProgramInput<Input>,\n fn: (error: EffectError<Input>) => any\n): TappedProgram<Input> => {\n const tapped = asProgram<TappedProgram<Input>>(() => tapErrorRuntime(program(), fn))\n\n return inheritProgramName(program, tapped)\n}\n\n/** Lazily map the successful Result value of a Program. */\nexport function map<A, B>(fn: (value: A) => B): MapOperation<A, B>\nexport function map<Input extends RuntimeProgram, B>(\n program: ProgramInput<Input>,\n fn: (value: EffectSuccess<Input>) => B\n): MappedProgram<Input, B>\nexport function map(first: RuntimeProgram | RuntimeCallback, second?: RuntimeCallback): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a callback that accepts its success channel.\n return mapProgram(program as ProgramInput<typeof program>, first)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return mapProgram(first as ProgramInput<RuntimeProgram>, second)\n}\n\n/** Lazily map the error Result value of a Program. */\nexport function mapError<E1, E2>(fn: (error: E1) => E2): MapErrorOperation<E1, E2>\nexport function mapError<Input extends RuntimeProgram, E2>(\n program: ProgramInput<Input>,\n fn: (error: EffectError<Input>) => E2\n): ErrorMappedProgram<Input, E2>\nexport function mapError(first: RuntimeProgram | RuntimeCallback, second?: RuntimeCallback): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a callback that accepts its error channel.\n return mapErrorProgram(program as ProgramInput<typeof program>, first)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return mapErrorProgram(first as ProgramInput<RuntimeProgram>, second)\n}\n\n/** Lazily continue a successful Program with an Effect or Program. */\nexport function andThen<A, Next>(\n next: (value: A) => Next & ProgramOutput<Next>\n): AndThenOperation<A, Next>\nexport function andThen<Input extends RuntimeProgram, Next>(\n program: ProgramInput<Input>,\n next: (value: EffectSuccess<Input>) => Next & ProgramOutput<Next>\n): ChainedProgram<Input, Next>\nexport function andThen(\n first: RuntimeProgram | RuntimeContinuation,\n second?: RuntimeContinuation\n): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a continuation for its success channel.\n const chained = () => andThenRuntime(program(), first as RuntimeContinuation)\n\n return inheritProgramName(program, chained)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n const source = first as RuntimeProgram\n const chained = () => andThenRuntime(source(), second)\n\n return inheritProgramName(source, chained)\n}\n\n/** Lazily observe a successful Program value without changing its Result. */\nexport function tap<A>(fn: (value: A) => void): TapOperation<A>\nexport function tap<Input extends RuntimeProgram>(\n program: ProgramInput<Input>,\n fn: (value: EffectSuccess<Input>) => void\n): TappedProgram<Input>\nexport function tap(first: RuntimeProgram | RuntimeCallback, second?: RuntimeCallback): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a callback that accepts its success channel.\n return tapProgram(program as ProgramInput<typeof program>, first)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return tapProgram(first as ProgramInput<RuntimeProgram>, second)\n}\n\n/** Lazily observe a failed Program value without changing its Result. */\nexport function tapError<E>(fn: (error: E) => void): TapErrorOperation<E>\nexport function tapError<Input extends RuntimeProgram>(\n program: ProgramInput<Input>,\n fn: (error: EffectError<Input>) => void\n): TappedProgram<Input>\nexport function tapError(first: RuntimeProgram | RuntimeCallback, second?: RuntimeCallback): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a callback that accepts its error channel.\n return tapErrorProgram(program as ProgramInput<typeof program>, first)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return tapErrorProgram(first as ProgramInput<RuntimeProgram>, second)\n}\n\n/** Lazily recover a failed Program with an Effect or Program. */\nexport function recover<E, Next>(\n fn: (error: E) => Next & ProgramOutput<Next>\n): RecoverOperation<E, Next>\nexport function recover<Input extends RuntimeProgram, Next>(\n program: ProgramInput<Input>,\n recover: (error: EffectError<Input>) => Next & ProgramOutput<Next>\n): RecoveredProgram<Input, Next>\nexport function recover(\n first: RuntimeProgram | RuntimeContinuation,\n second?: RuntimeContinuation\n): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a recovery callback for its error channel.\n const recovered = () => recoverRuntime(program(), first as RuntimeContinuation)\n\n return inheritProgramName(program, recovered)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n const source = first as RuntimeProgram\n const recovered = () => recoverRuntime(source(), second)\n\n return inheritProgramName(source, recovered)\n}\n","import { Err } from 'better-result'\n\nimport type { Result as ResultType } from 'better-result'\n\ntype AnyResult = ResultType<any, any>\n\ntype ProgramCollectionFailure =\n | { readonly kind: 'result'; readonly result: AnyResult }\n | { readonly kind: 'defect'; readonly cause: unknown }\n\ntype ProgramCollectionDefect = { readonly cause: unknown }\n\ntype ProgramCollectionOutcome = {\n readonly results: Array<AnyResult | undefined>\n readonly defects: Array<ProgramCollectionDefect | undefined>\n}\n\nexport type ProgramCollectionOptions = {\n readonly concurrency: number | undefined\n readonly stopOnResultError: boolean\n}\n\ntype ProgramTask = (index: number) => AnyResult | PromiseLike<AnyResult>\n\ntype SchedulerState = {\n nextIndex: number\n stopScheduling: boolean\n readonly results: Array<AnyResult | undefined>\n readonly defects: Array<ProgramCollectionDefect | undefined>\n}\n\n/** Validate the shared bounded-concurrency option before a Program is run. */\nexport const validateProgramConcurrency = (concurrency: number | undefined): void => {\n if (\n concurrency !== undefined &&\n (!Number.isFinite(concurrency) || !Number.isInteger(concurrency) || concurrency <= 0)\n ) {\n throw new RangeError('Program.all concurrency must be a positive integer')\n }\n}\n\nconst runWorker = async (\n length: number,\n task: ProgramTask,\n stopOnResultError: boolean,\n state: SchedulerState\n): Promise<void> => {\n while (!state.stopScheduling) {\n const index = state.nextIndex++\n\n if (index >= length) {\n return\n }\n\n try {\n const result = await task(index)\n state.results[index] = result\n\n if (result instanceof Err) {\n state.stopScheduling ||= stopOnResultError\n }\n } catch (cause) {\n state.defects[index] = { cause }\n state.stopScheduling = true\n }\n }\n}\n\n/** Run claimed Programs with a shared FIFO worker pool and no cancellation. */\nexport const runProgramCollection = async (\n length: number,\n task: ProgramTask,\n options: ProgramCollectionOptions\n): Promise<ProgramCollectionOutcome> => {\n const state: SchedulerState = {\n nextIndex: 0,\n stopScheduling: false,\n results: Array.from({ length }),\n defects: Array.from({ length })\n }\n const workerCount = Math.min(options.concurrency ?? length, length)\n const workers = Array.from({ length: workerCount }, () =>\n runWorker(length, task, options.stopOnResultError, state)\n )\n\n await Promise.all(workers)\n\n return state\n}\n\n/** Select the first defect by input index, independent of settlement order. */\nexport const firstProgramDefect = (\n defects: readonly (ProgramCollectionDefect | undefined)[]\n): ProgramCollectionDefect | undefined => {\n for (const defect of defects) {\n if (defect !== undefined) {\n return defect\n }\n }\n\n return undefined\n}\n\n/** Select the first short-circuiting failure by input index. */\nexport const firstProgramFailure = (\n results: readonly (AnyResult | undefined)[],\n defects: readonly (ProgramCollectionDefect | undefined)[]\n): ProgramCollectionFailure | undefined => {\n const length = Math.max(results.length, defects.length)\n\n for (let index = 0; index < length; index++) {\n const defect = defects[index]\n if (defect !== undefined) {\n return { kind: 'defect', cause: defect.cause }\n }\n\n const result = results[index]\n if (result instanceof Err) {\n return { kind: 'result', result }\n }\n }\n\n return undefined\n}\n","import { Result } from 'better-result'\n\nimport type { Err, Result as ResultType, UnhandledException } from 'better-result'\n\nimport { Scope } from '../scope'\n\nimport type { DisposableResource, MaybePromise, ScopeOutcome } from '../scope'\n\nimport { setProgramName } from './program-metadata'\nimport type { AnyService } from '../service'\n\nimport type {\n AnyEffect,\n Effect as EffectType,\n EffectError,\n EffectFromGenerator,\n EffectRequirements,\n EffectSuccess,\n EffectYield,\n Program as ProgramType,\n ProgramFromGenerator\n} from './types'\n\nimport {\n all,\n andThen,\n andThenAsync,\n as,\n asVoid,\n flatten,\n map,\n mapError,\n match,\n matchError,\n matchErrorPartial,\n recover,\n recoverAsync,\n tap,\n tapAsync,\n tapBoth,\n tapBothAsync,\n tapError,\n tapErrorAsync,\n zip\n} from './combinators'\nimport {\n andThen as programAndThen,\n map as programMap,\n mapError as programMapError,\n recover as programRecover,\n tap as programTap,\n tapError as programTapError\n} from './program-combinators'\nimport {\n firstProgramDefect,\n firstProgramFailure,\n runProgramCollection,\n validateProgramConcurrency\n} from './program-scheduler'\n\nexport type Effect<A, E, R extends AnyService = never> = EffectType<A, E, R>\n\ntype LazyProgram<A, E, R extends AnyService = never> = ProgramType<A, E, R>\n\n/** A nominal lazy computation that produces an Effect when invoked. */\nexport type Program<A, E, R extends AnyService = never> = LazyProgram<A, E, R>\n\ntype AnyResult = ResultType<any, any>\n\ntype AnyProgram = ProgramType<any, any, AnyService>\n\ntype ProgramAllSuccess<Programs extends readonly AnyProgram[]> = {\n -readonly [Index in keyof Programs]: EffectSuccess<Programs[Index]>\n}\n\ntype ProgramAllError<Programs extends readonly AnyProgram[]> = EffectError<Programs[number]>\n\ntype ProgramAllRequirements<Programs extends readonly AnyProgram[]> = EffectRequirements<\n Programs[number]\n>\n\ntype ProgramAllResult<Programs extends readonly AnyProgram[]> = ProgramType<\n ProgramAllSuccess<Programs>,\n ProgramAllError<Programs>,\n ProgramAllRequirements<Programs>\n>\n\ntype ProgramResultFor<Child> = Child extends AnyProgram\n ? ResultType<EffectSuccess<Child>, EffectError<Child>>\n : never\n\ntype ProgramAllResultsSuccess<Programs extends readonly AnyProgram[]> =\n number extends Programs['length']\n ? ReadonlyArray<ResultType<EffectSuccess<Programs[number]>, EffectError<Programs[number]>>>\n : { readonly [Index in keyof Programs]: ProgramResultFor<Programs[Index]> }\n\ntype ProgramAllResultsResult<Programs extends readonly AnyProgram[]> = ProgramType<\n ProgramAllResultsSuccess<Programs>,\n never,\n ProgramAllRequirements<Programs>\n>\n\ntype ProgramForEachResult<Child extends AnyProgram> = ProgramType<\n ReadonlyArray<EffectSuccess<Child>>,\n EffectError<Child>,\n EffectRequirements<Child>\n>\n\nexport type ProgramAllOptions = {\n readonly concurrency?: number\n /** Optional diagnostic name for the collection execution. */\n readonly name?: string\n}\n\ntype EffectGenerator =\n | (() => Generator<EffectYield, AnyResult, unknown>)\n | (() => AsyncGenerator<EffectYield, AnyResult, unknown>)\n\ntype RuntimeResultGenerator = (body: EffectGenerator) => AnyResult | Promise<AnyResult>\n\n// SAFETY: Service iterators yield no runtime markers, so Result.gen receives only the Err values that exist at runtime.\nconst runResultGenerator = Result.gen as RuntimeResultGenerator\n\n/**\n * Compose `better-result` operations while preserving Service requirements in\n * a declaration-only type channel.\n *\n * A generator may yield Service tokens and Result operations. It must return a\n * `Result` as its final value; Service yields are resolved by the active\n * Runtime and do not add runtime values to the Result stream.\n * Use `fn` when generator execution should wait for a Runtime boundary.\n *\n * @example\n * ```ts\n * const loadUser = Effect.gen(async function* () {\n * const database = yield* Database\n * const user = yield* Result.await(database.findUser('u1'))\n *\n * return Result.ok(user)\n * })\n * ```\n */\nexport function gen<Yield extends EffectYield, Returned extends AnyResult>(\n body: () => Generator<Yield, Returned, unknown>\n): EffectFromGenerator<Yield, Returned>\n\nexport function gen<Yield extends EffectYield, Returned extends AnyResult>(\n body: () => AsyncGenerator<Yield, Returned, unknown>\n): Promise<EffectFromGenerator<Yield, Returned>>\n\nexport function gen(body: EffectGenerator): AnyResult | Promise<AnyResult> {\n return runResultGenerator(body)\n}\n\n/** Build a lazy Program without running its generator. */\nexport function fn<Yield extends EffectYield, Returned extends AnyResult>(\n body: () => Generator<Yield, Returned, unknown>\n): ProgramFromGenerator<Yield, Returned>\n\nexport function fn<Yield extends EffectYield, Returned extends AnyResult>(\n body: () => AsyncGenerator<Yield, Returned, unknown>\n): ProgramFromGenerator<Yield, Returned>\n\nexport function fn(body: EffectGenerator): Program<any, any, AnyService> {\n const program = () => runResultGenerator(body)\n\n // SAFETY: The generator overloads derive the Program channels; this cast only adds the declaration-only nominal marker.\n return program as Program<any, any, AnyService>\n}\n\ntype ProgramNamedOperation = {\n <Input extends AnyProgram>(program: Input): Input\n}\n\nconst validateProgramName = (name: string): void => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate JavaScript callers at the public boundary.\n if (typeof name !== 'string') {\n throw new TypeError('Program name must be a string')\n }\n}\n\n/** Attach a lazy diagnostic name to a Program without invoking it. */\nfunction programNamed(name: string): ProgramNamedOperation\nfunction programNamed<Input extends AnyProgram>(name: string, program: Input): Input\nfunction programNamed(name: string, program?: AnyProgram): AnyProgram | ProgramNamedOperation {\n validateProgramName(name)\n\n if (program === undefined) {\n return (source) => setProgramName(source, name)\n }\n\n return setProgramName(program, name)\n}\n\nconst runShortCircuitingCollection = async (\n length: number,\n task: (index: number) => AnyResult | PromiseLike<AnyResult>,\n concurrency: number | undefined\n): Promise<AnyResult> => {\n const outcome = await runProgramCollection(length, task, {\n concurrency,\n stopOnResultError: true\n })\n const failure = firstProgramFailure(outcome.results, outcome.defects)\n\n if (failure?.kind === 'defect') {\n throw failure.cause\n }\n\n if (failure?.kind === 'result') {\n return failure.result\n }\n\n // SAFETY: The scheduler records one Result per claimed index before completing successfully.\n return Result.all(outcome.results as AnyResult[])\n}\n\nconst runAllResultsCollection = async (\n length: number,\n task: (index: number) => AnyResult | PromiseLike<AnyResult>,\n concurrency: number | undefined\n): Promise<AnyResult> => {\n const outcome = await runProgramCollection(length, task, {\n concurrency,\n stopOnResultError: false\n })\n const defect = firstProgramDefect(outcome.defects)\n\n if (defect !== undefined) {\n throw defect.cause\n }\n\n // SAFETY: The scheduler records each Result object at its input index.\n return Result.ok(outcome.results as AnyResult[])\n}\n\n/** Build a lazy Program collection with optional bounded concurrency. */\nexport function programAll<const Programs extends readonly AnyProgram[]>(\n programs: Programs,\n options: ProgramAllOptions = {}\n): ProgramAllResult<Programs> {\n const concurrency = options.concurrency\n const name = options?.name\n validateProgramConcurrency(concurrency)\n const program = () =>\n runShortCircuitingCollection(programs.length, (index) => programs[index]!(), concurrency)\n\n if (name !== undefined) {\n validateProgramName(name)\n setProgramName(program, name)\n }\n\n // SAFETY: Program channels are declaration-only and are restored from the input tuple here.\n return program as ProgramAllResult<Programs>\n}\n\n/** Build a lazy Program collection from an input array and Program factory. */\nexport function programForEach<const Items extends readonly unknown[], Child extends AnyProgram>(\n items: Items,\n makeProgram: (item: Items[number], index: number) => Child,\n options: ProgramAllOptions = {}\n): ProgramForEachResult<Child> {\n const concurrency = options.concurrency\n const name = options?.name\n validateProgramConcurrency(concurrency)\n const program = () =>\n runShortCircuitingCollection(\n items.length,\n (index) => makeProgram(items[index]!, index)(),\n concurrency\n )\n\n if (name !== undefined) {\n validateProgramName(name)\n setProgramName(program, name)\n }\n\n // SAFETY: Program channels are declaration-only and are restored from the factory's result type.\n return program as ProgramForEachResult<Child>\n}\n\n/** Build a lazy Program collection that retains every child Result. */\nexport function programAllResults<const Programs extends readonly AnyProgram[]>(\n programs: Programs,\n options: ProgramAllOptions = {}\n): ProgramAllResultsResult<Programs> {\n const concurrency = options.concurrency\n const name = options?.name\n validateProgramConcurrency(concurrency)\n const program = () =>\n runAllResultsCollection(programs.length, (index) => programs[index]!(), concurrency)\n\n if (name !== undefined) {\n validateProgramName(name)\n setProgramName(program, name)\n }\n\n // SAFETY: Program channels are declaration-only and are restored from the input tuple here.\n return program as ProgramAllResultsResult<Programs>\n}\n\n/** Value-level namespace for lazy Program combinators. */\nexport const Program = {\n named: programNamed,\n all: programAll,\n forEach: programForEach,\n allResults: programAllResults,\n map: programMap,\n mapError: programMapError,\n andThen: programAndThen,\n tap: programTap,\n tapError: programTapError,\n recover: programRecover\n} as const\n\n/**\n * Acquire a resource in the current Scope and register its release callback.\n *\n * Acquisition failures are represented in the Effect Result error channel;\n * release failures remain owned by Scope cleanup. The release callback\n * receives the final outcome chosen by the enclosing execution boundary.\n *\n * @example\n * ```ts\n * const connection = yield* Effect.acquireRelease(\n * () => pool.connect(),\n * (connection, outcome) => connection.close(outcome)\n * )\n * ```\n */\nexport function acquireRelease<R>(\n acquire: () => MaybePromise<R>,\n release: (resource: R, outcome: ScopeOutcome) => MaybePromise<void>\n): AsyncGenerator<Err<never, UnhandledException>, R, unknown> {\n const scope = Scope.current()\n\n return Result.await(Result.tryPromise(() => scope.acquire(acquire, release)))\n}\n\nclass AcquireReleaseResultFailure<R, E> {\n constructor(readonly result: Err<R, E>) {}\n}\n\n/**\n * Acquire a Result-valued resource and register only successful acquisitions.\n *\n * Typed acquisition failures remain unchanged in the Effect error channel;\n * unexpected acquisition and registration failures are normalized by\n * `better-result`. Release failures remain Scope cleanup failures.\n */\nexport function acquireReleaseResult<R, E>(\n acquire: () => MaybePromise<ResultType<R, E>>,\n release: (resource: R, outcome: ScopeOutcome) => MaybePromise<void>\n): AsyncGenerator<Err<never, E | UnhandledException>, R, unknown> {\n const scope = Scope.current()\n const registered = Result.tryPromise(async (): Promise<ResultType<R, E>> => {\n try {\n const resource = await scope.acquire(async () => {\n const result = await acquire()\n\n if (Result.isError(result)) {\n throw new AcquireReleaseResultFailure(result)\n }\n\n return result.value\n }, release)\n\n return Result.ok(resource)\n } catch (cause) {\n if (cause instanceof AcquireReleaseResultFailure) {\n return cause.result\n }\n\n throw cause\n }\n })\n\n return Result.await(registered.then((result) => result.andThen((acquired) => acquired)))\n}\n\n/**\n * Lazily acquire and register a disposable resource in the current Scope.\n *\n * Disposal is delegated to `Scope.add`, including protocol preference,\n * validation, race-safe registration, and cleanup error handling.\n */\nexport function acquireDisposable<R extends DisposableResource>(\n acquire: () => MaybePromise<R>\n): AsyncGenerator<Err<never, UnhandledException>, R, unknown> {\n const scope = Scope.current()\n\n return Result.await(Result.tryPromise(async () => scope.add(await acquire())))\n}\n\n/**\n * Register an already-acquired disposable resource in the current Scope.\n *\n * The resource is not acquired by this helper. Registration failures are\n * represented in the Effect Result error channel; disposal failures remain\n * owned by Scope cleanup.\n *\n * @example\n * ```ts\n * const file = yield* Effect.add(await openFile('notes.txt'))\n * ```\n */\nexport function add<R extends DisposableResource>(\n resource: R\n): AsyncGenerator<Err<never, UnhandledException>, R, unknown> {\n const scope = Scope.current()\n\n return Result.await(Result.tryPromise(() => scope.add(resource)))\n}\n\n/**\n * Effect namespace containing generator, resource, and Result combinators.\n *\n * Prefer these helpers when a program needs typed Service requirements or\n * Scope-aware acquisition and cleanup.\n */\ntype EffectNamespace = {\n readonly gen: typeof gen\n readonly fn: typeof fn\n readonly acquireRelease: typeof acquireRelease\n readonly acquireReleaseResult: typeof acquireReleaseResult\n readonly acquireDisposable: typeof acquireDisposable\n readonly add: typeof add\n readonly map: typeof map\n readonly mapError: typeof mapError\n readonly andThen: typeof andThen\n readonly andThenAsync: typeof andThenAsync\n readonly tap: typeof tap\n readonly tapAsync: typeof tapAsync\n readonly tapError: typeof tapError\n readonly tapErrorAsync: typeof tapErrorAsync\n readonly tapBoth: typeof tapBoth\n readonly tapBothAsync: typeof tapBothAsync\n readonly matchError: typeof matchError\n readonly matchErrorPartial: typeof matchErrorPartial\n readonly recover: typeof recover\n readonly recoverAsync: typeof recoverAsync\n readonly flatten: typeof flatten\n readonly as: typeof as\n readonly asVoid: typeof asVoid\n readonly match: typeof match\n readonly all: typeof all\n readonly zip: typeof zip\n}\n\nexport const Effect: EffectNamespace = {\n /** Compose a generator-based Effect program. */\n gen,\n /** Build a lazy Program from a generator. */\n fn,\n /** Acquire and register a resource in the current Scope. */\n acquireRelease,\n /** Acquire a Result-valued resource and register successful acquisitions. */\n acquireReleaseResult,\n /** Acquire and register a disposable resource in the current Scope. */\n acquireDisposable,\n /** Register an already-acquired disposable in the current Scope. */\n add,\n /** Map a successful Effect result. */\n map,\n /** Map an Effect error. */\n mapError,\n /** Chain a synchronous Effect result. */\n andThen,\n /** Chain an asynchronous Effect result. */\n andThenAsync,\n /** Observe successful values without changing the Result. */\n tap,\n /** Observe successful values asynchronously without changing the Result. */\n tapAsync,\n /** Observe error values without changing the Result. */\n tapError,\n /** Observe error values asynchronously without changing the Result. */\n tapErrorAsync,\n /** Observe the active Result branch without changing the Result. */\n tapBoth,\n /** Observe the active Result branch asynchronously without changing the Result. */\n tapBothAsync,\n /** Match every tagged error variant and map it to a new error value. */\n matchError,\n /** Match selected tagged errors and retain unhandled variants. */\n matchErrorPartial,\n /** Recover an error with another Effect. */\n recover,\n /** Recover an error asynchronously with another Effect. */\n recoverAsync,\n /** Remove one nested Effect layer. */\n flatten,\n /** Replace a successful value. */\n as,\n /** Replace a successful value with void. */\n asVoid,\n /** Match either Result branch. */\n match,\n /** Collect Effects in input order. */\n all,\n /** Zip two Effects in input order. */\n zip\n} as const\n\n/** Type-level aliases for inspecting Effect result channels and requirements. */\nexport declare namespace Effect {\n /** A nominal lazy computation that produces an Effect when invoked. */\n export type Program<A, E, R extends AnyService = never> = LazyProgram<A, E, R>\n\n /** Extract the success channel from an Effect result or Promise. */\n export type Success<T> = EffectSuccess<T>\n\n /** Extract the error channel from an Effect result or Promise. */\n export type Error<T> = EffectError<T>\n\n /** Extract the Service requirements from an Effect result or Promise. */\n export type Requirements<T> = EffectRequirements<T>\n\n /** An Effect with erased success, error, and requirements. */\n export type Any = AnyEffect\n}\n"],"mappings":";;;;AAwLA,MAAM,YAAmB,UAAuC;CAE9D,OAAO;AACT;AAEA,MAAM,aACJ,QACA,OAC+B;CAE/B,OAAO,OAAO,IAAI,QAAQ,EAAE;AAC9B;AAEA,MAAM,kBACJ,QACA,OACgC;CAEhC,OAAO,OAAO,SAAS,QAAQ,EAAE;AACnC;AAEA,MAAM,iBAQJ,QACA,SACsD;CAEtD,MAAM,aAAa;CAGnB,OAAO,OAAO,QAAQ,QAAQ,UAAU;AAC1C;AAEA,MAAM,sBAQJ,QACA,SAC+D;CAE/D,MAAM,cAAc,UAAa;EAE/B,OAAO,QAAQ,QAAQ,KAAK,KAAK,CAAC;CACpC;CAGA,OAAO,OAAO,aAAa,QAAQ,UAAU;AAG/C;AAmBA,SAAgBA,MAAI,OAAwB,QAAkC;CAC5E,IAAI,iBAAiB,YAAY,WAAW,KAAA,GAAW;EAErD,MAAM,WAAW;EAEjB,QAAQ,WAA2B;GAEjC,OAAOA,MAAI,QAAiB,QAAiB;EAC/C;CACF;CAGA,MAAM,KAAK;CAEX,IAAI,cAAc,KAAK,GACrB,OAAO,QAAQ,QAAQ,KAAK,CAAC,CAAC,MAAM,WAAW;EAE7C,OAAO,UAAU,QAAgC,EAAE;CACrD,CAAC;CAIH,OAAO,UAAU,OAA+B,EAAE;AACpD;AAgBA,SAAgBC,WAAS,OAAwB,QAAkC;CACjF,IAAI,iBAAiB,YAAY,WAAW,KAAA,GAAW;EAErD,MAAM,WAAW;EAEjB,QAAQ,WAA2B;GAEjC,OAAOA,WAAS,QAAiB,QAAiB;EACpD;CACF;CAGA,MAAM,KAAK;CAEX,IAAI,cAAc,KAAK,GACrB,OAAO,QAAQ,QAAQ,KAAK,CAAC,CAAC,MAAM,WAAW;EAE7C,OAAO,eAAe,QAAgC,EAAE;CAC1D,CAAC;CAIH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