better-effect 0.12.0 → 0.13.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.
- package/README.md +327 -7
- package/dist/adapters/iti.d.mts +3 -3
- package/dist/bun.d.mts +43 -0
- package/dist/bun.d.mts.map +1 -0
- package/dist/bun.mjs +40 -0
- package/dist/bun.mjs.map +1 -0
- package/dist/{context-BUEf1qjL.mjs → context-BphfFUMO.mjs} +4 -2
- package/dist/context-BphfFUMO.mjs.map +1 -0
- package/dist/current-request-CIU7AHhF.d.mts +22 -0
- package/dist/current-request-CIU7AHhF.d.mts.map +1 -0
- package/dist/current-request-DDKNyymv.mjs +20 -0
- package/dist/current-request-DDKNyymv.mjs.map +1 -0
- package/dist/{signal-D2UTcaaG.mjs → disposable-CP-Q2H3l.mjs} +4 -52
- package/dist/disposable-CP-Q2H3l.mjs.map +1 -0
- package/dist/{effect-CK4YZaX0.mjs → effect-CPdV7Yv8.mjs} +2 -2
- package/dist/{effect-CK4YZaX0.mjs.map → effect-CPdV7Yv8.mjs.map} +1 -1
- package/dist/hono.d.mts +7 -5
- package/dist/hono.d.mts.map +1 -1
- package/dist/hono.mjs +88 -30
- package/dist/hono.mjs.map +1 -1
- package/dist/{index-heuaRmXR.d.mts → index-AiKM71-u.d.mts} +3 -1
- package/dist/{index-heuaRmXR.d.mts.map → index-AiKM71-u.d.mts.map} +1 -1
- package/dist/{index-GYJ4qm9K.d.mts → index-BodMy6rO.d.mts} +6 -5
- package/dist/index-BodMy6rO.d.mts.map +1 -0
- package/dist/{index-CX6iAoCB.d.mts → index-CCi07kUw.d.mts} +2 -2
- package/dist/{index-CX6iAoCB.d.mts.map → index-CCi07kUw.d.mts.map} +1 -1
- package/dist/{index-BMdU_Z72.d.mts → index-DAKn0qHk.d.mts} +4 -3
- package/dist/index-DAKn0qHk.d.mts.map +1 -0
- package/dist/{index-B1nH4luq.d.mts → index-cXgyMa0v.d.mts} +6 -20
- package/dist/index-cXgyMa0v.d.mts.map +1 -0
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +7 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{layer-D56fRdLt.mjs → layer-D16GKxuX.mjs} +4 -4
- package/dist/layer-D16GKxuX.mjs.map +1 -0
- package/dist/next.d.mts +116 -0
- package/dist/next.d.mts.map +1 -0
- package/dist/next.mjs +68 -0
- package/dist/next.mjs.map +1 -0
- package/dist/{node-context-lggRF4bR.mjs → node-context-Ca18oNSg.mjs} +2 -2
- package/dist/{node-context-lggRF4bR.mjs.map → node-context-Ca18oNSg.mjs.map} +1 -1
- package/dist/{node-context-DWsCUBRa.d.mts → node-context-DczjAcrX.d.mts} +2 -2
- package/dist/{node-context-DWsCUBRa.d.mts.map → node-context-DczjAcrX.d.mts.map} +1 -1
- package/dist/node.d.mts +4 -4
- package/dist/node.mjs +4 -4
- package/dist/observer-9nhbL7Pr.d.mts +68 -0
- package/dist/observer-9nhbL7Pr.d.mts.map +1 -0
- package/dist/opentelemetry.d.mts +94 -0
- package/dist/opentelemetry.d.mts.map +1 -0
- package/dist/opentelemetry.mjs +453 -0
- package/dist/opentelemetry.mjs.map +1 -0
- package/dist/{outcome-CB43bnFW.d.mts → outcome-DI8LPIQ4.d.mts} +14 -69
- package/dist/outcome-DI8LPIQ4.d.mts.map +1 -0
- package/dist/{program-metadata-DhQCCirO.mjs → program-metadata-BxjGkT17.mjs} +3 -3
- package/dist/{program-metadata-DhQCCirO.mjs.map → program-metadata-BxjGkT17.mjs.map} +1 -1
- package/dist/runtime/explicit.d.mts +1 -1
- package/dist/runtime/explicit.mjs +1 -1
- package/dist/runtime/node.d.mts +2 -2
- package/dist/runtime/node.mjs +2 -2
- package/dist/{runtime-CBMrX8Wl.mjs → runtime-C_55ofnL.mjs} +42 -27
- package/dist/runtime-C_55ofnL.mjs.map +1 -0
- package/dist/signal-nfgFyNCk.mjs +52 -0
- package/dist/signal-nfgFyNCk.mjs.map +1 -0
- package/dist/{standard-services-GBZ32tll.mjs → standard-services-vnGIafkS.mjs} +3 -17
- package/dist/standard-services-vnGIafkS.mjs.map +1 -0
- package/dist/standard-services.d.mts +3 -2
- package/dist/standard-services.mjs +3 -2
- package/dist/testing.d.mts +6 -5
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +6 -6
- package/dist/types-oihI-ESv.d.mts +54 -0
- package/dist/types-oihI-ESv.d.mts.map +1 -0
- package/dist/web-Bq3MfMrj.mjs +147 -0
- package/dist/web-Bq3MfMrj.mjs.map +1 -0
- package/dist/web.d.mts +47 -0
- package/dist/web.d.mts.map +1 -0
- package/dist/web.mjs +2 -0
- package/package.json +33 -2
- package/dist/context-BUEf1qjL.mjs.map +0 -1
- package/dist/index-B1nH4luq.d.mts.map +0 -1
- package/dist/index-BMdU_Z72.d.mts.map +0 -1
- package/dist/index-GYJ4qm9K.d.mts.map +0 -1
- package/dist/layer-D56fRdLt.mjs.map +0 -1
- package/dist/outcome-CB43bnFW.d.mts.map +0 -1
- package/dist/runtime-CBMrX8Wl.mjs.map +0 -1
- package/dist/signal-D2UTcaaG.mjs.map +0 -1
- package/dist/standard-services-GBZ32tll.mjs.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { t as Layer } from "./layer-D16GKxuX.mjs";
|
|
2
|
+
import { t as CurrentRequest } from "./current-request-DDKNyymv.mjs";
|
|
3
|
+
import { Result } from "better-result";
|
|
4
|
+
//#region src/web/responses.ts
|
|
5
|
+
const DEFAULT_FAILURE_MESSAGE = "Internal Server Error";
|
|
6
|
+
/** An unsupported value encountered by the default Web JSON policy. */
|
|
7
|
+
var WebEffectSerializationError = class extends TypeError {
|
|
8
|
+
constructor(detail) {
|
|
9
|
+
super(`WebEffect default success serialization ${detail}`);
|
|
10
|
+
this.name = "WebEffectSerializationError";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const isObject = (value) => typeof value === "object" && value !== null;
|
|
14
|
+
const isCallable = (value) => typeof value === "function";
|
|
15
|
+
const isHeaders = (value) => {
|
|
16
|
+
if (!isObject(value)) return false;
|
|
17
|
+
const candidate = value;
|
|
18
|
+
return isCallable(candidate.append) && isCallable(candidate.delete) && isCallable(candidate.get) && isCallable(candidate.getSetCookie) && isCallable(candidate.has) && isCallable(candidate.set) && isCallable(candidate.forEach);
|
|
19
|
+
};
|
|
20
|
+
const isBody = (value) => {
|
|
21
|
+
if (value === null) return true;
|
|
22
|
+
if (!isObject(value)) return false;
|
|
23
|
+
const candidate = value;
|
|
24
|
+
return typeof candidate.locked === "boolean" && isCallable(candidate.cancel) && isCallable(candidate.getReader) && isCallable(candidate.pipeThrough) && isCallable(candidate.pipeTo) && isCallable(candidate.tee);
|
|
25
|
+
};
|
|
26
|
+
const isResponseStatus = (value) => typeof value === "number" && Number.isInteger(value) && (value === 0 || value >= 200 && value <= 599);
|
|
27
|
+
const isResponseType = (value) => value === "basic" || value === "cors" || value === "default" || value === "error" || value === "opaque" || value === "opaqueredirect";
|
|
28
|
+
/** Accept native, cross-realm, and standards-compatible Web Response values. */
|
|
29
|
+
const isWebResponse = (value) => {
|
|
30
|
+
if (!isObject(value)) return false;
|
|
31
|
+
try {
|
|
32
|
+
const candidate = value;
|
|
33
|
+
const status = candidate.status;
|
|
34
|
+
if (!isResponseStatus(status)) return false;
|
|
35
|
+
return isBody(candidate.body) && typeof candidate.bodyUsed === "boolean" && isHeaders(candidate.headers) && typeof candidate.ok === "boolean" && candidate.ok === (status >= 200 && status <= 299) && typeof candidate.redirected === "boolean" && typeof candidate.statusText === "string" && isResponseType(candidate.type) && typeof candidate.url === "string" && isCallable(candidate.arrayBuffer) && isCallable(candidate.blob) && isCallable(candidate.bytes) && isCallable(candidate.clone) && isCallable(candidate.formData) && isCallable(candidate.json) && isCallable(candidate.text);
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const propertyPath = (path, property) => `${path}.${property}`;
|
|
41
|
+
const unsupported = (path, kind) => {
|
|
42
|
+
throw new WebEffectSerializationError(`cannot encode ${kind} at ${path}`);
|
|
43
|
+
};
|
|
44
|
+
const ownDataProperties = (value, path) => {
|
|
45
|
+
if (Object.getOwnPropertySymbols(value).length > 0) unsupported(path, "symbol-keyed properties");
|
|
46
|
+
return Object.getOwnPropertyNames(value).map((property) => {
|
|
47
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, property);
|
|
48
|
+
if (descriptor === void 0 || !("value" in descriptor) || descriptor.enumerable !== true) unsupported(propertyPath(path, property), "non-enumerable or accessor properties");
|
|
49
|
+
return [property, descriptor.value];
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const arrayIndex = (property) => {
|
|
53
|
+
const index = Number(property);
|
|
54
|
+
return Number.isInteger(index) && index >= 0 && index < 2 ** 32 - 1 && String(index) === property ? index : void 0;
|
|
55
|
+
};
|
|
56
|
+
const sanitizeArray = (value, path, ancestors) => {
|
|
57
|
+
if (Object.getOwnPropertySymbols(value).length > 0) unsupported(path, "symbol-keyed properties");
|
|
58
|
+
const properties = Object.getOwnPropertyNames(value);
|
|
59
|
+
if (properties.length !== value.length + 1 || !properties.includes("length")) unsupported(path, "sparse or augmented arrays");
|
|
60
|
+
const output = [];
|
|
61
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
62
|
+
const property = String(index);
|
|
63
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, property);
|
|
64
|
+
if (descriptor === void 0 || !("value" in descriptor) || descriptor.enumerable !== true || arrayIndex(property) === void 0) unsupported(propertyPath(path, property), "sparse or accessor array elements");
|
|
65
|
+
const dataDescriptor = descriptor;
|
|
66
|
+
output.push(sanitizeJsonValue(dataDescriptor.value, propertyPath(path, property), ancestors));
|
|
67
|
+
}
|
|
68
|
+
return output;
|
|
69
|
+
};
|
|
70
|
+
const sanitizeObject = (value, path, ancestors) => {
|
|
71
|
+
const prototype = Object.getPrototypeOf(value);
|
|
72
|
+
if (prototype !== Object.prototype && prototype !== null) unsupported(path, "non-plain objects");
|
|
73
|
+
const output = Object.create(null);
|
|
74
|
+
for (const [property, child] of ownDataProperties(value, path)) output[property] = sanitizeJsonValue(child, propertyPath(path, property), ancestors);
|
|
75
|
+
return output;
|
|
76
|
+
};
|
|
77
|
+
const sanitizeJsonValue = (value, path, ancestors = /* @__PURE__ */ new Set()) => {
|
|
78
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") return value;
|
|
79
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : unsupported(path, "non-finite numbers");
|
|
80
|
+
if (typeof value === "undefined") return unsupported(path, "undefined values");
|
|
81
|
+
if (typeof value === "bigint" || typeof value === "function" || typeof value === "symbol") return unsupported(path, `${typeof value} values`);
|
|
82
|
+
if (!isObject(value)) return unsupported(path, "unsupported values");
|
|
83
|
+
if (ancestors.has(value)) return unsupported(path, "circular values");
|
|
84
|
+
ancestors.add(value);
|
|
85
|
+
try {
|
|
86
|
+
return Array.isArray(value) ? sanitizeArray(value, path, ancestors) : sanitizeObject(value, path, ancestors);
|
|
87
|
+
} finally {
|
|
88
|
+
ancestors.delete(value);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/** Convert a successful value using the boundary's constrained JSON policy. */
|
|
92
|
+
const defaultSuccess = ({ value }) => {
|
|
93
|
+
if (isWebResponse(value)) return value;
|
|
94
|
+
if (value === void 0) return new Response(null, { status: 204 });
|
|
95
|
+
return Response.json({ data: sanitizeJsonValue(value, "$") });
|
|
96
|
+
};
|
|
97
|
+
/** Redact typed failures unless the failure is an intentional Response. */
|
|
98
|
+
const defaultFailure = (error) => {
|
|
99
|
+
if (isWebResponse(error)) return error;
|
|
100
|
+
return Response.json({ error: DEFAULT_FAILURE_MESSAGE }, { status: 500 });
|
|
101
|
+
};
|
|
102
|
+
/** Validate policy output at the JavaScript boundary before returning it. */
|
|
103
|
+
const assertResponse = (response) => {
|
|
104
|
+
if (!isWebResponse(response)) throw new TypeError("WebEffect response policies must return a Response");
|
|
105
|
+
return response;
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/web/web-effect.ts
|
|
109
|
+
const combineRequestLayer = (request, customLayer) => {
|
|
110
|
+
const currentRequestLayer = CurrentRequest.layer(request);
|
|
111
|
+
if (customLayer === void 0) return currentRequestLayer;
|
|
112
|
+
return Layer.override(currentRequestLayer, customLayer);
|
|
113
|
+
};
|
|
114
|
+
/** Execute one Result-valued Program inside a framework-neutral Web request boundary. */
|
|
115
|
+
var WebEffect = class {
|
|
116
|
+
constructor() {}
|
|
117
|
+
static async handle(runtime, request, program, options) {
|
|
118
|
+
const boundaryOptions = options;
|
|
119
|
+
const onSuccess = boundaryOptions?.onSuccess ?? defaultSuccess;
|
|
120
|
+
const onFailure = boundaryOptions?.onFailure ?? defaultFailure;
|
|
121
|
+
const requestLayer = combineRequestLayer(request, boundaryOptions?.requestLayer?.(request));
|
|
122
|
+
let response;
|
|
123
|
+
let failurePolicyFailed = false;
|
|
124
|
+
let failurePolicyCause;
|
|
125
|
+
await runtime.runWith(requestLayer, async () => {
|
|
126
|
+
const result = await program();
|
|
127
|
+
if (Result.isError(result)) {
|
|
128
|
+
try {
|
|
129
|
+
response = assertResponse(await onFailure(result.error));
|
|
130
|
+
} catch (cause) {
|
|
131
|
+
failurePolicyFailed = true;
|
|
132
|
+
failurePolicyCause = cause;
|
|
133
|
+
}
|
|
134
|
+
return Result.err(result.error);
|
|
135
|
+
}
|
|
136
|
+
response = assertResponse(await onSuccess({ value: result.value }));
|
|
137
|
+
return Result.ok(response);
|
|
138
|
+
}, { signal: request.signal });
|
|
139
|
+
if (failurePolicyFailed) throw failurePolicyCause;
|
|
140
|
+
if (response === void 0) throw new Error("WebEffect response policy did not produce a Response");
|
|
141
|
+
return response;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
//#endregion
|
|
145
|
+
export { WebEffectSerializationError as n, assertResponse as r, WebEffect as t };
|
|
146
|
+
|
|
147
|
+
//# sourceMappingURL=web-Bq3MfMrj.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-Bq3MfMrj.mjs","names":["dataDescriptor"],"sources":["../src/web/responses.ts","../src/web/web-effect.ts"],"sourcesContent":["import type { WebEffectSuccess, WebJsonValue } from './types'\n\n/* oxlint-disable anti-slop/no-object-parameters -- Web Response values are validated structurally at this boundary. */\n/* oxlint-disable anti-slop/no-runtime-typeof -- Web Response and JSON values require runtime protocol validation. */\n/* oxlint-disable anti-slop/no-unknown-parameters -- Web Response and JSON policies accept opaque JavaScript values. */\n/* oxlint-disable anti-slop/no-unknown-returns -- Web Response and JSON policies narrow opaque JavaScript values locally. */\n\nconst DEFAULT_FAILURE_MESSAGE = 'Internal Server Error'\n\ntype BodyCandidate = {\n readonly cancel: unknown\n readonly getReader: unknown\n readonly locked: unknown\n readonly pipeThrough: unknown\n readonly pipeTo: unknown\n readonly tee: unknown\n}\n\ntype ResponseCandidate = {\n readonly body: unknown\n readonly bodyUsed: unknown\n readonly headers: unknown\n readonly ok: unknown\n readonly redirected: unknown\n readonly status: unknown\n readonly statusText: unknown\n readonly type: unknown\n readonly url: unknown\n readonly arrayBuffer: unknown\n readonly blob: unknown\n readonly bytes: unknown\n readonly clone: unknown\n readonly formData: unknown\n readonly json: unknown\n readonly text: unknown\n}\n\n/** An unsupported value encountered by the default Web JSON policy. */\nexport class WebEffectSerializationError extends TypeError {\n constructor(detail: string) {\n super(`WebEffect default success serialization ${detail}`)\n this.name = 'WebEffectSerializationError'\n }\n}\n\nconst isObject = (value: unknown): value is object => typeof value === 'object' && value !== null\n\nconst isCallable = (value: unknown): value is (...arguments_: never[]) => unknown =>\n typeof value === 'function'\n\ntype HeadersCandidate = {\n readonly append: unknown\n readonly delete: unknown\n readonly get: unknown\n readonly getSetCookie: unknown\n readonly has: unknown\n readonly set: unknown\n readonly forEach: unknown\n}\n\nconst isHeaders = (value: unknown): boolean => {\n if (!isObject(value)) {\n return false\n }\n\n // SAFETY: isObject above establishes the runtime object shape before structural field inspection.\n const candidate = value as HeadersCandidate\n\n return (\n isCallable(candidate.append) &&\n isCallable(candidate.delete) &&\n isCallable(candidate.get) &&\n isCallable(candidate.getSetCookie) &&\n isCallable(candidate.has) &&\n isCallable(candidate.set) &&\n isCallable(candidate.forEach)\n )\n}\n\nconst isBody = (value: unknown): boolean => {\n if (value === null) {\n return true\n }\n\n if (!isObject(value)) {\n return false\n }\n\n // SAFETY: isObject above establishes the runtime object shape before structural field inspection.\n const candidate = value as BodyCandidate\n\n return (\n typeof candidate.locked === 'boolean' &&\n isCallable(candidate.cancel) &&\n isCallable(candidate.getReader) &&\n isCallable(candidate.pipeThrough) &&\n isCallable(candidate.pipeTo) &&\n isCallable(candidate.tee)\n )\n}\n\nconst isResponseStatus = (value: unknown): value is number =>\n typeof value === 'number' &&\n Number.isInteger(value) &&\n (value === 0 || (value >= 200 && value <= 599))\n\nconst isResponseType = (value: unknown): value is Response['type'] =>\n value === 'basic' ||\n value === 'cors' ||\n value === 'default' ||\n value === 'error' ||\n value === 'opaque' ||\n value === 'opaqueredirect'\n\n/** Accept native, cross-realm, and standards-compatible Web Response values. */\nconst isWebResponse = (value: unknown): value is Response => {\n if (!isObject(value)) {\n return false\n }\n\n try {\n // SAFETY: isObject above establishes the runtime object shape before structural field inspection.\n const candidate = value as ResponseCandidate\n\n const status = candidate.status\n\n if (!isResponseStatus(status)) {\n return false\n }\n\n return (\n isBody(candidate.body) &&\n typeof candidate.bodyUsed === 'boolean' &&\n isHeaders(candidate.headers) &&\n typeof candidate.ok === 'boolean' &&\n candidate.ok === (status >= 200 && status <= 299) &&\n typeof candidate.redirected === 'boolean' &&\n typeof candidate.statusText === 'string' &&\n isResponseType(candidate.type) &&\n typeof candidate.url === 'string' &&\n isCallable(candidate.arrayBuffer) &&\n isCallable(candidate.blob) &&\n isCallable(candidate.bytes) &&\n isCallable(candidate.clone) &&\n isCallable(candidate.formData) &&\n isCallable(candidate.json) &&\n isCallable(candidate.text)\n )\n } catch {\n return false\n }\n}\n\nconst propertyPath = (path: string, property: string): string => `${path}.${property}`\n\nconst unsupported = (path: string, kind: string): never => {\n throw new WebEffectSerializationError(`cannot encode ${kind} at ${path}`)\n}\n\nconst ownDataProperties = (\n value: object,\n path: string\n): readonly (readonly [string, unknown])[] => {\n const symbols = Object.getOwnPropertySymbols(value)\n\n if (symbols.length > 0) {\n unsupported(path, 'symbol-keyed properties')\n }\n\n return Object.getOwnPropertyNames(value).map((property) => {\n const descriptor = Object.getOwnPropertyDescriptor(value, property)\n\n if (descriptor === undefined || !('value' in descriptor) || descriptor.enumerable !== true) {\n unsupported(propertyPath(path, property), 'non-enumerable or accessor properties')\n }\n\n // SAFETY: the preceding descriptor guard establishes a data descriptor with an enumerable value.\n const dataDescriptor = descriptor as PropertyDescriptor & { readonly value: unknown }\n\n return [property, dataDescriptor.value] as const\n })\n}\n\nconst arrayIndex = (property: string): number | undefined => {\n const index = Number(property)\n\n return Number.isInteger(index) && index >= 0 && index < 2 ** 32 - 1 && String(index) === property\n ? index\n : undefined\n}\n\nconst sanitizeArray = (\n value: readonly unknown[],\n path: string,\n ancestors: Set<object>\n): readonly WebJsonValue[] => {\n const symbols = Object.getOwnPropertySymbols(value)\n\n if (symbols.length > 0) {\n unsupported(path, 'symbol-keyed properties')\n }\n\n const properties = Object.getOwnPropertyNames(value)\n\n if (properties.length !== value.length + 1 || !properties.includes('length')) {\n unsupported(path, 'sparse or augmented arrays')\n }\n\n const output: WebJsonValue[] = []\n\n for (let index = 0; index < value.length; index += 1) {\n const property = String(index)\n const descriptor = Object.getOwnPropertyDescriptor(value, property)\n\n if (\n descriptor === undefined ||\n !('value' in descriptor) ||\n descriptor.enumerable !== true ||\n arrayIndex(property) === undefined\n ) {\n unsupported(propertyPath(path, property), 'sparse or accessor array elements')\n }\n\n // SAFETY: the preceding descriptor guard establishes a data descriptor with an enumerable value.\n const dataDescriptor = descriptor as PropertyDescriptor & { readonly value: unknown }\n\n output.push(sanitizeJsonValue(dataDescriptor.value, propertyPath(path, property), ancestors))\n }\n\n return output\n}\n\nconst sanitizeObject = (\n value: object,\n path: string,\n ancestors: Set<object>\n): { readonly [key: string]: WebJsonValue } => {\n const prototype = Object.getPrototypeOf(value)\n\n if (prototype !== Object.prototype && prototype !== null) {\n unsupported(path, 'non-plain objects')\n }\n\n // SAFETY: Object.create(null) is an empty dictionary that is populated only with sanitized values.\n const output: { [key: string]: WebJsonValue } = Object.create(null) as {\n [key: string]: WebJsonValue\n }\n\n for (const [property, child] of ownDataProperties(value, path)) {\n output[property] = sanitizeJsonValue(child, propertyPath(path, property), ancestors)\n }\n\n return output\n}\n\nconst sanitizeJsonValue = (\n value: unknown,\n path: string,\n ancestors: Set<object> = new Set()\n): WebJsonValue => {\n if (value === null || typeof value === 'boolean' || typeof value === 'string') {\n return value\n }\n\n if (typeof value === 'number') {\n return Number.isFinite(value) ? value : unsupported(path, 'non-finite numbers')\n }\n\n if (typeof value === 'undefined') {\n return unsupported(path, 'undefined values')\n }\n\n if (typeof value === 'bigint' || typeof value === 'function' || typeof value === 'symbol') {\n return unsupported(path, `${typeof value} values`)\n }\n\n if (!isObject(value)) {\n return unsupported(path, 'unsupported values')\n }\n\n if (ancestors.has(value)) {\n return unsupported(path, 'circular values')\n }\n\n ancestors.add(value)\n\n try {\n return Array.isArray(value)\n ? sanitizeArray(value, path, ancestors)\n : sanitizeObject(value, path, ancestors)\n } finally {\n ancestors.delete(value)\n }\n}\n\n/** Convert a successful value using the boundary's constrained JSON policy. */\nexport const defaultSuccess = ({ value }: WebEffectSuccess): Response => {\n if (isWebResponse(value)) {\n return value\n }\n\n if (value === undefined) {\n return new Response(null, { status: 204 })\n }\n\n return Response.json({ data: sanitizeJsonValue(value, '$') })\n}\n\n/** Redact typed failures unless the failure is an intentional Response. */\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Typed Result errors are intentionally opaque at this HTTP boundary.\nexport const defaultFailure = (error: unknown): Response => {\n if (isWebResponse(error)) {\n return error\n }\n\n return Response.json({ error: DEFAULT_FAILURE_MESSAGE }, { status: 500 })\n}\n\n/** Validate policy output at the JavaScript boundary before returning it. */\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Policy callbacks are opaque JavaScript inputs at this boundary.\nexport const assertResponse = (response: unknown): Response => {\n if (!isWebResponse(response)) {\n throw new TypeError('WebEffect response policies must return a Response')\n }\n\n return response\n}\n","import { Result } from 'better-result'\n\nimport { Layer } from '../layer'\nimport type { LayerInput } from '../layer/inference'\nimport { CurrentRequest } from '../standard-services/current-request'\nimport type { Runtime } from '../runtime'\nimport type { AnyService } from '../service'\nimport type { EffectError, EffectSuccess } from '../effect/types'\nimport { assertResponse, defaultFailure, defaultSuccess } from './responses'\nimport type {\n AnyProgram,\n CompleteWebProgram,\n DefaultRequestLayer,\n WebEffectOptions,\n WebEffectProgram,\n WebProgramChecks,\n WebRequestLayerChecks\n} from './types'\n\nconst combineRequestLayer = <RequestLayer extends LayerInput>(\n request: Request,\n customLayer: RequestLayer | undefined\n): LayerInput => {\n const currentRequestLayer = CurrentRequest.layer(request)\n\n if (customLayer === undefined) {\n return currentRequestLayer\n }\n\n // SAFETY: WebEffect.handle validates the custom Layer's shape and override contract at its public boundary.\n return Layer.override(currentRequestLayer, customLayer as never)\n}\n\n/** Execute one Result-valued Program inside a framework-neutral Web request boundary. */\nexport class WebEffect {\n private constructor() {}\n\n /**\n * Run one lazy Program and map its Result to a standard Web Response.\n *\n * The request Layer and execution Scope are owned by the supplied Runtime;\n * request resources close before this Promise resolves, while Runtime-root\n * resources remain owned by the Runtime.\n */\n static handle<\n Provided extends AnyService,\n const Program extends AnyProgram,\n RequestLayer extends LayerInput,\n Failure = EffectError<Program>\n >(\n runtime: Runtime<Provided>,\n request: Request,\n program: Program,\n options: WebEffectOptions<NoInfer<Failure>, RequestLayer, EffectSuccess<Program>> & {\n readonly requestLayer: (request: Request) => RequestLayer\n } & WebRequestLayerChecks<Provided, RequestLayer> &\n WebProgramChecks<Provided, RequestLayer, Program, NoInfer<Failure>>\n ): Promise<Response>\n\n static handle<\n Provided extends AnyService,\n const Program extends AnyProgram,\n Failure = EffectError<Program>\n >(\n runtime: Runtime<Provided>,\n request: Request,\n program: Program & CompleteWebProgram<Provided, DefaultRequestLayer, Program, NoInfer<Failure>>,\n options: WebEffectOptions<NoInfer<Failure>, DefaultRequestLayer, EffectSuccess<Program>>\n ): Promise<Response>\n\n static handle<Provided extends AnyService, const Program extends AnyProgram>(\n runtime: Runtime<Provided>,\n request: Request,\n program: Program & CompleteWebProgram<Provided, DefaultRequestLayer, Program>,\n options?: undefined\n ): Promise<Response>\n\n static async handle(\n runtime: Runtime<AnyService>,\n request: Request,\n program: AnyProgram,\n options?: WebEffectOptions<unknown, LayerInput, unknown>\n ): Promise<Response> {\n const boundaryOptions = options\n const onSuccess = boundaryOptions?.onSuccess ?? defaultSuccess\n const onFailure = boundaryOptions?.onFailure ?? defaultFailure\n const requestLayer = combineRequestLayer(request, boundaryOptions?.requestLayer?.(request))\n let response: Response | undefined\n let failurePolicyFailed = false\n let failurePolicyCause: unknown\n\n // Return a Result from the execution even after mapping it so Runtime can\n // classify typed failures and give request finalizers the original cause.\n // A policy defect is rethrown after this Result settles so it cannot replace\n // the typed failure supplied to the request Scope.\n // SAFETY: Public overloads validate the request Layer before this erased Runtime boundary.\n await runtime.runWith(\n requestLayer as Layer.Any,\n async () => {\n const result = await program()\n\n if (Result.isError(result)) {\n try {\n response = assertResponse(await onFailure(result.error))\n } catch (cause) {\n failurePolicyFailed = true\n failurePolicyCause = cause\n }\n\n return Result.err(result.error)\n }\n\n response = assertResponse(\n await onSuccess({\n value: result.value\n })\n )\n return Result.ok(response)\n },\n { signal: request.signal }\n )\n\n if (failurePolicyFailed) {\n throw failurePolicyCause\n }\n\n if (response === undefined) {\n throw new Error('WebEffect response policy did not produce a Response')\n }\n\n return response\n }\n}\n\n/** Type-level aliases for the framework-neutral Web boundary. */\nexport declare namespace WebEffect {\n /** Options used by `WebEffect.handle`. */\n export type Options<\n Failure = unknown,\n RequestLayer extends LayerInput = DefaultRequestLayer,\n Success = unknown\n > = WebEffectOptions<Failure, RequestLayer, Success>\n\n /** The success value passed to `onSuccess`. */\n export type Success<A = unknown> = {\n readonly value: A\n }\n\n /** A standard Web response or an asynchronous response. */\n export type ResponseLike = Response | PromiseLike<Response>\n\n /** A lazy Result-valued Program accepted by `handle`. */\n export type Program<A = unknown, E = unknown, R extends AnyService = never> = WebEffectProgram<\n A,\n E,\n R\n >\n\n /** Extract a Program's success channel. */\n export type Value<Program extends WebEffectProgram<any, any, AnyService>> = EffectSuccess<Program>\n\n /** Extract a Program's typed failure channel. */\n export type Failure<Program extends WebEffectProgram<any, any, AnyService>> = EffectError<Program>\n}\n"],"mappings":";;;;AAOA,MAAM,0BAA0B;;AA+BhC,IAAa,8BAAb,cAAiD,UAAU;CACzD,YAAY,QAAgB;EAC1B,MAAM,2CAA2C,QAAQ;EACzD,KAAK,OAAO;CACd;AACF;AAEA,MAAM,YAAY,UAAoC,OAAO,UAAU,YAAY,UAAU;AAE7F,MAAM,cAAc,UAClB,OAAO,UAAU;AAYnB,MAAM,aAAa,UAA4B;CAC7C,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO;CAIT,MAAM,YAAY;CAElB,OACE,WAAW,UAAU,MAAM,KAC3B,WAAW,UAAU,MAAM,KAC3B,WAAW,UAAU,GAAG,KACxB,WAAW,UAAU,YAAY,KACjC,WAAW,UAAU,GAAG,KACxB,WAAW,UAAU,GAAG,KACxB,WAAW,UAAU,OAAO;AAEhC;AAEA,MAAM,UAAU,UAA4B;CAC1C,IAAI,UAAU,MACZ,OAAO;CAGT,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO;CAIT,MAAM,YAAY;CAElB,OACE,OAAO,UAAU,WAAW,aAC5B,WAAW,UAAU,MAAM,KAC3B,WAAW,UAAU,SAAS,KAC9B,WAAW,UAAU,WAAW,KAChC,WAAW,UAAU,MAAM,KAC3B,WAAW,UAAU,GAAG;AAE5B;AAEA,MAAM,oBAAoB,UACxB,OAAO,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,MAAM,OAAO;CAExD,IAAI,gBAAgB,KAAA,GAClB,OAAO;CAIT,OAAO,MAAM,SAAS,qBAAqB,WAAoB;AACjE;;AAGA,IAAa,YAAb,MAAuB;CACrB,cAAsB,CAAC;CA0CvB,aAAa,OACX,SACA,SACA,SACA,SACmB;EACnB,MAAM,kBAAkB;EACxB,MAAM,YAAY,iBAAiB,aAAa;EAChD,MAAM,YAAY,iBAAiB,aAAa;EAChD,MAAM,eAAe,oBAAoB,SAAS,iBAAiB,eAAe,OAAO,CAAC;EAC1F,IAAI;EACJ,IAAI,sBAAsB;EAC1B,IAAI;EAOJ,MAAM,QAAQ,QACZ,cACA,YAAY;GACV,MAAM,SAAS,MAAM,QAAQ;GAE7B,IAAI,OAAO,QAAQ,MAAM,GAAG;IAC1B,IAAI;KACF,WAAW,eAAe,MAAM,UAAU,OAAO,KAAK,CAAC;IACzD,SAAS,OAAO;KACd,sBAAsB;KACtB,qBAAqB;IACvB;IAEA,OAAO,OAAO,IAAI,OAAO,KAAK;GAChC;GAEA,WAAW,eACT,MAAM,UAAU,EACd,OAAO,OAAO,MAChB,CAAC,CACH;GACA,OAAO,OAAO,GAAG,QAAQ;EAC3B,GACA,EAAE,QAAQ,QAAQ,OAAO,CAC3B;EAEA,IAAI,qBACF,MAAM;EAGR,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MAAM,sDAAsD;EAGxE,OAAO;CACT;AACF"}
|
package/dist/web.d.mts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { C as EffectError, E as EffectSuccess, M as AnyService } from "./index-AiKM71-u.mjs";
|
|
2
|
+
import { y as LayerInput } from "./outcome-DI8LPIQ4.mjs";
|
|
3
|
+
import { l as Runtime } from "./index-BodMy6rO.mjs";
|
|
4
|
+
import { a as WebEffectOptions, i as ResponseLike, l as WebProgramChecks, n as CompleteWebProgram, o as WebEffectProgram, r as DefaultRequestLayer, s as WebEffectSuccess, t as AnyProgram, u as WebRequestLayerChecks } from "./types-oihI-ESv.mjs";
|
|
5
|
+
//#region src/web/web-effect.d.ts
|
|
6
|
+
/** Execute one Result-valued Program inside a framework-neutral Web request boundary. */
|
|
7
|
+
declare class WebEffect {
|
|
8
|
+
private constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Run one lazy Program and map its Result to a standard Web Response.
|
|
11
|
+
*
|
|
12
|
+
* The request Layer and execution Scope are owned by the supplied Runtime;
|
|
13
|
+
* request resources close before this Promise resolves, while Runtime-root
|
|
14
|
+
* resources remain owned by the Runtime.
|
|
15
|
+
*/
|
|
16
|
+
static handle<Provided extends AnyService, const Program extends AnyProgram, RequestLayer extends LayerInput, Failure = EffectError<Program>>(runtime: Runtime<Provided>, request: Request, program: Program, options: WebEffectOptions<NoInfer<Failure>, RequestLayer, EffectSuccess<Program>> & {
|
|
17
|
+
readonly requestLayer: (request: Request) => RequestLayer;
|
|
18
|
+
} & WebRequestLayerChecks<Provided, RequestLayer> & WebProgramChecks<Provided, RequestLayer, Program, NoInfer<Failure>>): Promise<Response>;
|
|
19
|
+
static handle<Provided extends AnyService, const Program extends AnyProgram, Failure = EffectError<Program>>(runtime: Runtime<Provided>, request: Request, program: Program & CompleteWebProgram<Provided, DefaultRequestLayer, Program, NoInfer<Failure>>, options: WebEffectOptions<NoInfer<Failure>, DefaultRequestLayer, EffectSuccess<Program>>): Promise<Response>;
|
|
20
|
+
static handle<Provided extends AnyService, const Program extends AnyProgram>(runtime: Runtime<Provided>, request: Request, program: Program & CompleteWebProgram<Provided, DefaultRequestLayer, Program>, options?: undefined): Promise<Response>;
|
|
21
|
+
}
|
|
22
|
+
/** Type-level aliases for the framework-neutral Web boundary. */
|
|
23
|
+
declare namespace WebEffect {
|
|
24
|
+
/** Options used by `WebEffect.handle`. */
|
|
25
|
+
type Options<Failure = unknown, RequestLayer extends LayerInput = DefaultRequestLayer, Success = unknown> = WebEffectOptions<Failure, RequestLayer, Success>;
|
|
26
|
+
/** The success value passed to `onSuccess`. */
|
|
27
|
+
type Success<A = unknown> = {
|
|
28
|
+
readonly value: A;
|
|
29
|
+
};
|
|
30
|
+
/** A standard Web response or an asynchronous response. */
|
|
31
|
+
type ResponseLike = Response | PromiseLike<Response>;
|
|
32
|
+
/** A lazy Result-valued Program accepted by `handle`. */
|
|
33
|
+
type Program<A = unknown, E = unknown, R extends AnyService = never> = WebEffectProgram<A, E, R>;
|
|
34
|
+
/** Extract a Program's success channel. */
|
|
35
|
+
type Value<Program extends WebEffectProgram<any, any, AnyService>> = EffectSuccess<Program>;
|
|
36
|
+
/** Extract a Program's typed failure channel. */
|
|
37
|
+
type Failure<Program extends WebEffectProgram<any, any, AnyService>> = EffectError<Program>;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/web/responses.d.ts
|
|
41
|
+
/** An unsupported value encountered by the default Web JSON policy. */
|
|
42
|
+
declare class WebEffectSerializationError extends TypeError {
|
|
43
|
+
constructor(detail: string);
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { type ResponseLike, WebEffect, type WebEffectOptions, type WebEffectProgram, WebEffectSerializationError, type WebEffectSuccess };
|
|
47
|
+
//# sourceMappingURL=web.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.mts","names":[],"sources":["../src/web/web-effect.ts","../src/web/responses.ts"],"mappings":";;;;;;cAkCa;UACJ;;;;;;;;SASA,OACL,iBAAiB,kBACX,gBAAgB,YACtB,qBAAqB,YACrB,UAAU,YAAY,UAEtB,SAAS,QAAQ,WACjB,SAAS,SACT,SAAS,SACT,SAAS,iBAAiB,QAAQ,UAAU,cAAc,cAAc;aAC7D,eAAe,SAAS,YAAY;MAC3C,sBAAsB,UAAU,gBAClC,iBAAiB,UAAU,cAAc,SAAS,QAAQ,YAC3D,QAAQ;SAEJ,OACL,iBAAiB,kBACX,gBAAgB,YACtB,UAAU,YAAY,UAEtB,SAAS,QAAQ,WACjB,SAAS,SACT,SAAS,UAAU,mBAAmB,UAAU,qBAAqB,SAAS,QAAQ,WACtF,SAAS,iBAAiB,QAAQ,UAAU,qBAAqB,cAAc,YAC9E,QAAQ;SAEJ,OAAO,iBAAiB,kBAAkB,gBAAgB,YAC/D,SAAS,QAAQ,WACjB,SAAS,SACT,SAAS,UAAU,mBAAmB,UAAU,qBAAqB,UACrE,sBACC,QAAQ;;;kBA4DY;;OAEX,QACV,mBACA,qBAAqB,aAAa,qBAClC,qBACE,iBAAiB,SAAS,cAAc;;OAGhC,QAAQ;aACT,OAAO;;;OAIN,eAAe,WAAW,YAAY;;OAGtC,QAAQ,aAAa,aAAa,UAAU,sBAAsB,iBAC5E,GACA,GACA;;OAIU,MAAM,gBAAgB,2BAA2B,eAAe,cAAc;;OAG9E,QAAQ,gBAAgB,2BAA2B,eAAe,YAAY;;;;;cC5H/E,oCAAoC;EACnC,YAAA"}
|
package/dist/web.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-effect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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",
|
|
@@ -30,12 +30,16 @@
|
|
|
30
30
|
"exports": {
|
|
31
31
|
".": "./dist/index.mjs",
|
|
32
32
|
"./adapters/iti": "./dist/adapters/iti.mjs",
|
|
33
|
+
"./bun": "./dist/bun.mjs",
|
|
33
34
|
"./hono": "./dist/hono.mjs",
|
|
35
|
+
"./next": "./dist/next.mjs",
|
|
34
36
|
"./node": "./dist/node.mjs",
|
|
37
|
+
"./opentelemetry": "./dist/opentelemetry.mjs",
|
|
35
38
|
"./runtime/explicit": "./dist/runtime/explicit.mjs",
|
|
36
39
|
"./runtime/node": "./dist/runtime/node.mjs",
|
|
37
40
|
"./standard-services": "./dist/standard-services.mjs",
|
|
38
41
|
"./testing": "./dist/testing.mjs",
|
|
42
|
+
"./web": "./dist/web.mjs",
|
|
39
43
|
"./package.json": "./package.json"
|
|
40
44
|
},
|
|
41
45
|
"publishConfig": {
|
|
@@ -51,6 +55,12 @@
|
|
|
51
55
|
"test:coverage": "bun test --coverage",
|
|
52
56
|
"test:package-types": "tsc --version && tsc -p tests/package/public-type-namespaces/tsconfig.json",
|
|
53
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
|
+
"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
|
+
"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
|
+
"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",
|
|
54
64
|
"test:package-standard-services": "tsc -p tests/package/standard-services/tsconfig.json",
|
|
55
65
|
"test:package-standard-services:minimum": "bunx --bun --package typescript@5.7.2 tsc -p tests/package/standard-services/tsconfig.json",
|
|
56
66
|
"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",
|
|
@@ -62,39 +72,60 @@
|
|
|
62
72
|
"publint": "publint",
|
|
63
73
|
"check:public-type-namespaces": "bun run test:package-types && bun run test:package-types:minimum && bun tests/package/public-type-namespaces/check.ts",
|
|
64
74
|
"check:node-runtime": "bun tests/check-node-runtime.ts",
|
|
75
|
+
"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",
|
|
77
|
+
"check:web-package": "bun tests/check-web-package.ts",
|
|
78
|
+
"check:hono-package": "bun tests/check-hono-package.ts",
|
|
79
|
+
"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",
|
|
65
81
|
"check:standard-services": "bun run test:package-standard-services && bun run test:package-standard-services:minimum",
|
|
66
82
|
"check:public-type-variance": "bun run test:package-variance && bun run test:package-variance:minimum && bun tests/package/public-type-variance/check.ts",
|
|
67
83
|
"check:instance-requirements": "bun tests/package/instance-requirements/check.ts",
|
|
68
|
-
"check": "bun run typecheck && bun test && bun run format:check && bun run check:node-runtime && 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",
|
|
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",
|
|
69
85
|
"prepublishOnly": "bun run check",
|
|
70
86
|
"release:dry": "bun publish --dry-run"
|
|
71
87
|
},
|
|
72
88
|
"devDependencies": {
|
|
89
|
+
"@opentelemetry/api": "1.9.1",
|
|
90
|
+
"@opentelemetry/sdk-trace-base": "2.10.0",
|
|
73
91
|
"@types/bun": "1.3.14",
|
|
74
92
|
"@types/jsdom": "21.1.7",
|
|
93
|
+
"@types/node": "^26.1.2",
|
|
94
|
+
"@types/react": "^19.2.18",
|
|
75
95
|
"hono": "^4.9.0",
|
|
76
96
|
"iti": "^0.8.0",
|
|
77
97
|
"jsdom": "26.1.0",
|
|
78
98
|
"lefthook": "^2.1.10",
|
|
79
99
|
"mermaid": "11.17.2",
|
|
100
|
+
"next": "16.3.0",
|
|
80
101
|
"oxfmt": "^0.63.0",
|
|
81
102
|
"oxlint": "^1.78.0",
|
|
82
103
|
"oxlint-tsgolint": "^7.0.2001",
|
|
83
104
|
"publint": "^0.3.23",
|
|
105
|
+
"react": "^19.2.8",
|
|
106
|
+
"react-dom": "^19.2.8",
|
|
84
107
|
"tsdown": "^0.22.14"
|
|
85
108
|
},
|
|
86
109
|
"peerDependencies": {
|
|
110
|
+
"@opentelemetry/api": ">=1.9.0 <1.10.0",
|
|
87
111
|
"better-result": "^3.0.0",
|
|
88
112
|
"hono": ">=4.0.0",
|
|
89
113
|
"iti": "^0.8.0",
|
|
114
|
+
"next": "16.3.0",
|
|
90
115
|
"typescript": ">=5.7.0"
|
|
91
116
|
},
|
|
92
117
|
"peerDependenciesMeta": {
|
|
118
|
+
"@opentelemetry/api": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
93
121
|
"hono": {
|
|
94
122
|
"optional": true
|
|
95
123
|
},
|
|
96
124
|
"iti": {
|
|
97
125
|
"optional": true
|
|
126
|
+
},
|
|
127
|
+
"next": {
|
|
128
|
+
"optional": true
|
|
98
129
|
}
|
|
99
130
|
}
|
|
100
131
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-BUEf1qjL.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}\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): CompleteRuntimeContext\nexport function makeRuntimeContext(\n resolver: ServiceResolver | undefined,\n scope: Scope | undefined,\n resolutionPath: readonly AnyServiceToken[],\n signal: AbortSignal | undefined,\n parent?: RuntimeContext\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): RuntimeContext {\n const context: RuntimeContext = { resolutionPath }\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 (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,6BAAb,cAAgD,MAAM;CACpD,cAAc;EACZ,MACE,sJACF;EAEA,KAAK,OAAO;CACd;AACF;;;ACQA,MAAM,oCAA2D;CAC/D,MAAM,UAAU,YAAY,QAAQ;CACpC,eAAe;EACb,MAAM,IAAI,iCAAiC;CAC7C;AACF;AAEA,MAAM,kCAAkB,IAAI,QAAgC;;AAG5D,MAAa,gCACX,SACA,WACmB;CACnB,MAAM,UAAU,gBAAgB,IAAI,MAAM,KAAK;CAC/C,gBAAgB,IAAI,SAAS,OAAO;CACpC,OAAO;AACT;;AAGA,MAAa,4BAA4B,YACvC,gBAAgB,IAAI,OAAO;;AAG7B,MAAa,4BAA4B,YAA4C;CACnF,gBAAgB,I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,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":"index-B1nH4luq.d.mts","names":[],"sources":["../src/standard-services/config.ts","../src/standard-services/id-generator.ts","../src/standard-services/index.ts"],"mappings":";;;;;;KAcY,eAAe,SAAS;;KAGxB;WACD;WACA,YAAY;;;KAIX,qBAAqB,eAAe,oBAAoB;WACzD,QAAQ;;;KAIP,aAAa,eAAe,oBAAoB,iBAAiB,YAAY;;KAG7E,YAAY,eAAe,oBAAoB,iBAAiB,WAAW;;KAG3E,cAAc,iBAAiB;;;cAG9B,8BAA8B;WAChC,QAAQ,cAAc;WACtB;;;;cAIE,0BAA0B;WAC5B;WACA;WACA;;;KAIC,cAAc,wBAAwB,oBAAoB;KAEjE,YAAY,qBAAqB,QAAQ,KAAK,SAC/C,WAAW,SACX,mBAAmB;;KAGX,YACV,eAAe,kBACf,qBAAqB,QAAQ,aAC7B,QAAQ;GAEP,OAAO,kBAAkB,eACxB,YAAY,cAAc,QAC1B,aAAa;;;;;;;;;;cAuNJ,eAAe;WACL,QAAQ;EAAR,YAAA,QAAQ;;EAK7B,IAAI;;SAKG,MAAM,QAAQ,eAAY,YAAA,cAAA;;SAK1B,aAAa,UAAS,sBAAwB,YAAA,cAAA;;SAW9C,OAAO,eAAe,kBAAkB,QAAQ,SAAS,YAAY,QAAQ;;SAK7E,QAAQ,eAAe,kBAC5B,SAAS,qBAAqB,UAC7B,YAAY;;SAmBR,QAAQ,SAAS,uBACd,eAAe,kBAAkB,qBAAqB,QAAQ,KAAK,QAAQ,aACjF,OAAO,YAAY,QAAQ,cAAc,WACxC,YAAY,QAAQ,cAAc;;;cAmB5B,YAAU,YAAA,cAAA;;;;cCrVV,oCAAoC;EAAA;;;cASpC,kCAAkC;WACxB;EAAA,YAAA;;;;;;;;;;cAUV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EACX,IAAI,OAAO,aAAa,iBAAiB,OAAO;EAOhD,MAAM,iBAAiB,OAAO;EAI9B,KAAK,iBAAiB,OAAO;EAI7B,KAAK,iBAAiB,OAAO;EAI7B,MAAM,iBAAiB,OAAO;EAI9B;SAIO;;;;SAKA,MAAM,SAAQ,aAA6B,YAAA,cAAA;;cAKvC,uBAAe,YAAA,cAAA;;;;;;;;;cAGf,uBAAuB;WAIb;WAHZ;EAGY,YAAA;SAMd,MAAM,iBAAc,YAAA,cAAA;;cAMhB,sBAAuB,mBAAc,YAAA,cAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BMdU_Z72.d.mts","names":[],"sources":["../src/layer/map-layer-backend.ts"],"mappings":";;;;cAca,2BAA2B;mBACrB;mBAEA;mBAEA;;EAGjB,SAAS,cAAc;;EAiBjB,QAAQ,UAAU,iBAAiB,OAAO,IAAI,QAAQ,aAAa;;EA6CnE,WAAW,UAAU,6BAA6B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-GYJ4qm9K.d.mts","names":[],"sources":["../src/runtime/types.ts","../src/runtime/runtime.ts","../src/runtime/signal.ts","../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/types.ts","../src/resource/resource.ts"],"mappings":";;;;;;;KAMY;WACD;WACA;WACA;;;;;;;;;KAUC;WACD;WACA;WACA;WACA,qBAAqB;WACrB;WACA;;;;;;;;;;;KAYC,WAAW,UAAU,cAAc,QAAQ,MAAM,SAAS;;;KCNjE,sBAAsB,iBAAiB;;;;;;;;;;;;;;;;cA8C/B,QAAQ,iBAAiB;mBACC;UAA9B;;;;;;;;;;;SAYA,KAAK,UAAU,YACpB,OAAO,IAAI,cAAc,IACzB,SAAS,cACT,UAAU,iBACT,QAAQ,QAAQ,oBAAoB;SAEhC,KAAK,UAAU,YACpB,OAAO,IAAI,cAAc,IACzB,UAAU,iBACT,QAAQ,QAAQ,oBAAoB;;;;;;;SAwBhC,IAAI,GAAG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MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,KACZ;iBACa,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GACjD,OAAO,GACP,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,KACZ;;;;;cC3FU,+BAA+B;WACjC;WACA;WACA;;;;;KCCC,aAAa,KAAK,IAAI,YAAY;;KAGlC,YAAY,GAAG,KAAK,aAAa,OAAW,GAAG;;KAG/C,wBAAwB;;KAGxB,0BAA0B,SAAS,2BAA2B;;KAG9D,yBAAyB,GAAG,GAAG,cAAc;;WAE9C;;WAGA,eAAe,YAAY,GAAG;;WAG9B,MAAM,UAAU,MAAM,YAAY,GAAG;;WAGrC,WAAW,UAAU,MAAM,aAAa;;;;;WAMxC,mBAAmB;;;;cCqBjB;;WA3Bc,oBAAA,GAAG,GAAG,cAAc,YAAQ,MAAA,SAAA,KAAA,SAAA,oBAMpD,yBAAyB,GAAG,GAAG,cAAc,cAAY,QAC1D,OAAW,GAAG,eAAe,WAAW,qBAAqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layer-D56fRdLt.mjs","names":["Constructor"],"sources":["../src/service/runtime.ts","../src/service/service.ts","../src/layer/internal.ts","../src/layer/layer.ts"],"sourcesContent":["import { ServiceRuntimeNotConfiguredError } from './errors'\nimport { captureServiceTag } from './tag'\n\nimport { RuntimeContextNotConfiguredError } from '../runtime/errors'\n\nimport {\n currentRuntimeContext,\n getRuntimeContext,\n makeRuntimeContext,\n runRuntimeContext\n} from '../runtime/context'\n\nimport { defaultRuntimeContextStorage } from '../runtime/default'\n\nimport type { AnyServiceToken } from './types'\n\nimport type { RuntimeContextStorage } from '../runtime/context'\n\n/** Resolves class-backed Service tokens for a runtime execution. */\nexport interface ServiceResolver {\n /** Resolve a token to its corresponding Service instance. */\n resolve<T extends AnyServiceToken>(token: T): InstanceType<T> | PromiseLike<InstanceType<T>>\n}\n\n/** Provides the resolver context used by Service tokens during execution. */\nexport class ServiceRuntime {\n /**\n * Run a callback with a resolver available to `yield* Service` expressions.\n *\n * The context is scoped to the callback and is restored afterward.\n *\n * @example\n * ```ts\n * const value = ServiceRuntime.run(resolver, () => {\n * return ServiceRuntime.resolve(Database)\n * })\n * ```\n */\n static run<A>(\n resolver: ServiceResolver,\n program: () => A,\n storage: RuntimeContextStorage = defaultRuntimeContextStorage\n ): A {\n const current = getRuntimeContext(storage)\n const context = makeRuntimeContext(\n resolver,\n current?.scope,\n current?.resolver === resolver ? current.resolutionPath : [],\n current?.signal,\n current?.resolver === resolver ? current : undefined\n )\n\n return runRuntimeContext(storage, context, program)\n }\n\n /** Return the resolver active in the current execution context. */\n static current(): ServiceResolver {\n let context\n\n try {\n context = currentRuntimeContext()\n } catch (cause) {\n if (cause instanceof RuntimeContextNotConfiguredError) {\n throw new ServiceRuntimeNotConfiguredError()\n }\n\n throw cause\n }\n\n if (!context.resolver) {\n throw new ServiceRuntimeNotConfiguredError()\n }\n\n return context.resolver\n }\n\n /** Resolve a Service token using the active resolver. */\n static async resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>> {\n captureServiceTag(token)\n const resolver = ServiceRuntime.current()\n\n return await resolver.resolve(token)\n }\n}\n","import { ServiceRuntime } from './runtime'\nimport { registerServiceTag, validateServiceTag } from './tag'\n\nimport type { ServiceRequirement } from '../effect/types'\n\nimport type {\n AnyService,\n AnyServiceToken,\n ServiceClass,\n ServiceContract,\n ServiceIdentity,\n ServiceIdentityTypeId,\n ServiceInstance,\n ServiceRequirements,\n ServiceTag,\n ServiceToken,\n ServiceTokenOf\n} from './types'\n\ntype ServiceTagLiteral<Tag extends string> = string extends Tag\n ? never\n : Tag extends ''\n ? never\n : Tag\n\ninterface ServiceFactory<Self> {\n <const Tag extends string>(\n tag: ServiceTagLiteral<Tag>\n ): (abstract new () => ServiceIdentity<Tag>) & {\n readonly name: string\n readonly serviceTag: Tag\n } & {\n readonly of: Service.FactoryOf<Self, Tag>\n readonly [Symbol.asyncIterator]: (\n this: ServiceToken<Tag, Self & ServiceIdentity<Tag>>\n ) => AsyncGenerator<ServiceRequirement<Self>, Self, unknown>\n }\n}\n\n/**\n * Declare a class-backed Service with a stable string-literal identity.\n *\n * The returned class is simultaneously the implementation type, the runtime\n * dependency token, and the value yielded by `yield*` in an Effect generator.\n * The explicit self type preserves exact instance inference, while the second\n * call captures the tag as a literal for Layer composition and diagnostics.\n *\n * @example\n * ```ts\n * class Database extends Service<Database>()('Database') {\n * query(): string {\n * return 'ok'\n * }\n * }\n *\n * const database = yield* Database\n * database.query()\n * ```\n *\n * @typeParam Self The instance type implemented by the declared Service.\n */\nexport function Service<Self>(): ServiceFactory<Self> {\n return function <const Tag extends string>(tag: ServiceTagLiteral<Tag>) {\n validateServiceTag(tag)\n\n abstract class BaseService implements ServiceIdentity<Tag> {\n /** The stable logical identity used by Layers and resolver backends. */\n static readonly serviceTag: Tag = tag\n declare readonly [ServiceIdentityTypeId]: Tag\n\n /**\n * Type-check a structural implementation of this Service.\n *\n * This is an identity helper. It returns the supplied value unchanged\n * and does not invoke a constructor or modify its prototype.\n *\n * @example\n * ```ts\n * class Database extends Service<Database>()('Database') {\n * query(sql: string): string {\n * return sql\n * }\n * }\n *\n * const database = Database.of({\n * query: (sql) => `Result: ${sql}`\n * })\n *\n * database.query('SELECT 1')\n * // 'Result: SELECT 1'\n * // database is the original object, not an instance of Database\n * ```\n */\n static of(this: void, implementation: ServiceContract<Self & ServiceIdentity<Tag>>): Self {\n // SAFETY: ServiceContract removes only the phantom marker; this boundary restores Self.\n return implementation as Self\n }\n\n /** Resolve this Service from the resolver active in the current runtime. */\n // oxlint-disable-next-line require-yield\n static async *[Symbol.asyncIterator](\n this: ServiceToken<Tag, Self & ServiceIdentity<Tag>>\n ): AsyncGenerator<ServiceRequirement<Self>, Self, unknown> {\n return await ServiceRuntime.resolve(this)\n }\n }\n\n registerServiceTag(BaseService, tag)\n\n return BaseService\n }\n}\n\n/** Type-level aliases for Service tokens and their instance contracts. */\nexport declare namespace Service {\n /** The widened Service instance constraint. */\n export type Any = AnyService\n\n /** A class-backed Service token with a stable tag and instance contract. */\n export type Token<Tag extends string = string, Instance extends AnyService = any> = ServiceToken<\n Tag,\n Instance\n >\n\n /** A constructible Service class with a stable tag and instance contract. */\n export type Class<\n Tag extends string = string,\n Instance extends AnyService = AnyService\n > = ServiceClass<Tag, Instance>\n\n /** Extract the instance represented by a Service token. */\n export type Instance<T extends AnyServiceToken> = ServiceInstance<T>\n\n /** Extract the stable tag represented by a Service instance. */\n export type Tag<S extends AnyService> = ServiceTag<S>\n\n /** A branded Service instance identity with a stable tag. */\n export type Identity<Tag extends string = string> = ServiceIdentity<Tag>\n\n /** Remove the internal identity marker from a Service implementation contract. */\n export type Contract<S extends AnyService> = ServiceContract<S>\n\n /** Extract the Service token represented by a branded Service instance. */\n export type TokenOf<S extends AnyService> = ServiceTokenOf<S>\n\n /** Declaration bridge for the recursive structural `Service.of` signature. */\n export type FactoryOf<Self, Tag extends string> = (\n this: void,\n implementation: ServiceContract<Self & ServiceIdentity<Tag>>\n ) => Self\n\n /** Extract Effect Service requirements from a Service instance. */\n export type Requirements<S extends AnyService> = ServiceRequirements<S>\n}\n","import { LayerGeneratorYieldError } from './errors'\n\nimport type { ServiceRequirement } from '../effect/types'\nimport type { ServiceClass } from '../service'\n\nimport type { LayerGenerator } from './types'\n\nexport const runLayerGenerator = async <\n S extends ServiceClass<any, any>,\n Yield extends ServiceRequirement<unknown>\n>(\n service: S,\n factory: LayerGenerator<S, Yield>\n): Promise<InstanceType<S>> => {\n const iterator = factory()\n\n const state = await iterator.next()\n\n if (!state.done) {\n try {\n // SAFETY: The iterator is closed only to discard an invalid yield; its return value is ignored.\n await iterator.return(undefined as never)\n } finally {\n // oxlint-disable-next-line no-unsafe-finally\n throw new LayerGeneratorYieldError(service)\n }\n }\n\n // SAFETY: The public generator boundary accepts only the requested Service contract.\n return state.value as InstanceType<S>\n}\n","import type { ServiceRequirement } from '../effect/types'\nimport { ServiceRuntime } from '../service'\nimport { captureServiceTag } from '../service/tag'\nimport type { AnyService, ServiceClass, ServiceContract, ServiceRequirements } from '../service'\nimport { ResourceNotDisposableError } from '../scope'\nimport { getDisposeFinalizer } from '../scope/disposable'\n\nimport type { DisposableResource, ScopeFinalizer, ScopeOutcome } from '../scope'\nimport type { Covariant, Invariant } from '../internal/variance'\nimport type { MaybePromise } from '../utils/types'\n\nimport { DuplicateServiceError, ServiceTagCollisionError } from './errors'\nimport { runLayerGenerator } from './internal'\nimport { captureLayerRegistrationTag } from './registration'\n\nimport type {\n LayerInput,\n CompleteInput,\n LayerResult,\n MergeResult,\n OverrideLayerResult,\n ValidateLayerInput,\n ValidateLayerTuple,\n ValidateOverrides,\n ProvidedEnvironment,\n RequiredEnvironment\n} from './inference'\nimport type { ProviderEntry } from './metadata'\nimport type { LayerGenerator, LayerGeneratorRequirements, LayerRegistration } from './types'\n\ndeclare const LayerTypeId: unique symbol\n\ninterface LayerVariance<in out Provided, out Required> {\n readonly _Provided: Invariant<Provided>\n readonly _Required: Covariant<Required>\n}\n\ntype CapturedLayerAcquisition = {\n readonly instance: unknown\n readonly release: ScopeFinalizer\n}\n\ninterface LayerProvider extends LayerRegistration {\n /** The tag captured before this provider can cross an asynchronous boundary. */\n readonly serviceTag: string\n\n /** Provider storage deliberately erases the concrete instance type. */\n // oxlint-disable-next-line anti-slop/no-unknown-parameters\n readonly release?: (instance: unknown, outcome: ScopeOutcome) => MaybePromise<void>\n\n /** Capture acquisition-local cleanup without retaining the acquired instance. */\n readonly acquireWithRelease?: () => MaybePromise<CapturedLayerAcquisition>\n}\n\n/** A Service class whose constructor can be called without arguments. */\ntype DefaultConstructibleServiceClass<\n Tag extends string = string,\n Instance extends AnyService = AnyService\n> = ServiceClass<Tag, Instance> & (new () => Instance)\n\ntype IsUnion<Type, Candidate = Type> = Type extends unknown\n ? [Candidate] extends [Type]\n ? false\n : true\n : never\n\ntype InvalidUnionAliasToken = {\n readonly __betterEffectUnionLayerAliasToken: unique symbol\n}\n\ntype RejectUnionAliasToken<Token> = IsUnion<Token> extends true ? InvalidUnionAliasToken : unknown\n\ntype LayerAliasOptions<From extends ServiceClass<any, any>, To extends ServiceClass<any, any>> = {\n readonly from: From\n readonly to: To\n} & RejectUnionAliasToken<From> &\n RejectUnionAliasToken<To> &\n ([ServiceContract<InstanceType<From>>] extends [ServiceContract<InstanceType<To>>]\n ? unknown\n : {\n readonly __betterEffectIncompatibleLayerAlias: unique symbol\n })\n\n/**\n * Declarative collection of Service providers.\n *\n * A Layer describes how to acquire implementations; it does not execute\n * providers until a `Runtime` is created. Use `merge` to compose distinct\n * providers and `override` when replacing an existing provider intentionally.\n *\n * @example\n * ```ts\n * const AppLive = Layer.merge(\n * Layer.succeed(Database, database),\n * Layer.make(UserRepository)\n * )\n *\n * const runtime = await Runtime.make(AppLive, backend)\n * ```\n */\nexport class Layer<\n in out Provided extends AnyService = AnyService,\n out Required extends AnyService = AnyService\n> {\n declare readonly [LayerTypeId]: LayerVariance<Provided, Required>\n\n /** The provider registrations retained by this Layer. */\n readonly providers: readonly LayerProvider[]\n\n private constructor(providers: readonly LayerProvider[]) {\n this.providers = Object.freeze(\n providers.map((provider) =>\n Object.freeze({\n ...provider,\n serviceTag: captureLayerRegistrationTag(provider)\n })\n )\n )\n }\n\n /** A stable provider-free Layer for composition roots with no Services. */\n static readonly empty: Layer<never, never> = Object.freeze(new Layer<never, never>([]))\n\n /** Create a Layer that lazily acquires a Service instance. */\n static make<S extends DefaultConstructibleServiceClass<any, any>>(\n service: S\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n\n static make<S extends ServiceClass<any, any>>(\n service: S,\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n\n static make<S extends ServiceClass<any, any>>(\n service: S,\n acquire?: () => MaybePromise<ServiceContract<InstanceType<S>>>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const serviceTag = captureServiceTag(service)\n const defaultAcquire = (): InstanceType<S> => {\n // SAFETY: The no-argument overload constrains `service` to a default constructible class.\n const Constructor = service as new () => InstanceType<S>\n\n return new Constructor()\n }\n\n const normalizedAcquire = normalizeAcquire<S>(acquire ?? defaultAcquire)\n\n // SAFETY: Runtime storage erases only the concrete provider metadata; the public constructor result restores its typed provenance.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: normalizedAcquire\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Create a Layer from an already-constructed Service instance. */\n static succeed<S extends ServiceClass<any, any>>(\n service: S,\n instance: ServiceContract<InstanceType<S>>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const serviceTag = captureServiceTag(service)\n const normalizedAcquire = normalizeAcquire<S>(() => instance)\n\n // SAFETY: The structural instance has been checked against the requested Service contract.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: normalizedAcquire\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Alias a source Service under a compatible target contract. */\n static alias<From extends ServiceClass<any, any>, To extends ServiceClass<any, any>>(\n options: LayerAliasOptions<From, To>\n ): LayerResult<\n ProviderEntry<InstanceType<To>, InstanceType<From> | ServiceRequirements<InstanceType<To>>>\n > {\n const { from, to } = options\n void captureServiceTag(from)\n\n // Keep alias acquisition in the normal Layer generator path so Runtime supplies the active resolver and resolution diagnostics.\n // oxlint-disable-next-line require-yield\n const alias = Layer.gen(to, async function* () {\n const source = await ServiceRuntime.resolve(from)\n\n // SAFETY: LayerAliasOptions checks that the source implementation satisfies the target contract.\n return source as ServiceContract<InstanceType<To>>\n })\n\n // SAFETY: The alias factory resolves the declared source token before returning the target contract.\n return alias as LayerResult<\n ProviderEntry<InstanceType<To>, InstanceType<From> | ServiceRequirements<InstanceType<To>>>\n >\n }\n\n /** Define a provider with Runtime-root cleanup. */\n static scoped<S extends ServiceClass<any, any>>(\n service: S,\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>,\n release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise<void>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The public callbacks constrain acquisition and release to the requested Service.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: normalizeAcquire<S>(acquire),\n release: (instance, outcome) => {\n // SAFETY: The backend invokes release with the instance acquired for this token.\n return release(instance as InstanceType<S>, outcome)\n }\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Define a provider with Runtime-root cleanup through its disposal protocol. */\n static scopedDisposable<S extends ServiceClass<any, any>>(\n service: S,\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>> & DisposableResource>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const acquireWithRelease = async (): Promise<CapturedLayerAcquisition> => {\n const instance = await acquire()\n const finalizer = getDisposeFinalizer(instance)\n\n if (!finalizer) {\n throw new ResourceNotDisposableError()\n }\n\n return { instance, release: finalizer }\n }\n\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The public callback constrains the acquired value and this runtime-only carrier is erased at the Layer boundary.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: async () => (await acquireWithRelease()).instance,\n acquireWithRelease\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Define a provider whose acquisition can yield contextual Services. */\n static scopedGen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(\n service: S,\n factory: LayerGenerator<S, Yield>,\n release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise<void>\n ): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>> {\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The generator and release callback are checked against the requested Service.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: () => runLayerGenerator(service, factory),\n release: (instance, outcome) => {\n // SAFETY: The backend invokes release with the instance acquired for this token.\n return release(instance as InstanceType<S>, outcome)\n }\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>\n }\n\n /** Define a provider whose acquisition can yield contextual Services. */\n static gen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(\n service: S,\n factory: LayerGenerator<S, Yield>\n ): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>> {\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The generator result is normalized to the requested Service at the runtime boundary.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: () => runLayerGenerator(service, factory)\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>\n }\n\n /** Compose Layers without replacing providers. */\n static merge<const Layers extends readonly LayerInput[]>(\n ...layers: Layers & ValidateLayerTuple<Layers>\n ): MergeResult<Layers> {\n const providers = new Map<string, LayerProvider>()\n\n for (const layer of layers) {\n for (const provider of layer.providers) {\n const service = provider.service\n const serviceTag = captureLayerRegistrationTag(provider)\n const existing = providers.get(serviceTag)\n\n if (existing) {\n if (existing.service !== service) {\n throw new ServiceTagCollisionError(existing.service, service)\n }\n\n throw new DuplicateServiceError(service)\n }\n\n providers.set(serviceTag, provider)\n }\n }\n\n // SAFETY: The heterogeneous provider list is erased only at this internal storage boundary.\n return new Layer([...providers.values()]) as MergeResult<Layers>\n }\n\n /** Mark a Layer composition root as complete without changing its runtime value. */\n static complete<L extends LayerInput>(layer: L & CompleteInput<L>): L {\n return layer\n }\n\n /** Replace providers in a base Layer, using tag identity and compatible contracts. */\n static override<Base extends LayerInput>(\n base: Base & ValidateLayerInput<Base>\n ): OverrideLayerResult<Base, readonly []>\n\n static override<\n Base extends LayerInput,\n const Overrides extends readonly [LayerInput, ...LayerInput[]]\n >(\n base: Base & ValidateLayerInput<Base>,\n ...overrides: Overrides & ValidateOverrides<Base, Overrides>\n ): OverrideLayerResult<Base, Overrides>\n\n static override<Base extends LayerInput, const Overrides extends readonly LayerInput[]>(\n base: Base & ValidateLayerInput<Base>,\n ...overrides: Overrides & ValidateOverrides<Base, Overrides>\n ): OverrideLayerResult<Base, Overrides>\n\n static override(base: LayerInput, ...overrides: readonly LayerInput[]): Layer<any, any> {\n const providers = new Map<string, LayerProvider>()\n\n for (const provider of base.providers) {\n providers.set(captureLayerRegistrationTag(provider), provider)\n }\n\n for (const layer of overrides) {\n for (const provider of layer.providers) {\n providers.set(captureLayerRegistrationTag(provider), provider)\n }\n }\n\n // SAFETY: Runtime provider replacement preserves the computed override metadata.\n return new Layer([...providers.values()]) as Layer<any, any>\n }\n}\n\n// TypeScript's `readonly` does not affect the runtime property descriptor. Keep\n// the class field's enumerable behavior while locking the singleton binding.\nObject.defineProperty(Layer, 'empty', {\n value: Layer.empty,\n writable: false,\n enumerable: true,\n configurable: false\n})\n\nconst normalizeAcquire =\n <S extends ServiceClass<any, any>>(\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>\n ): (() => MaybePromise<InstanceType<S>>) =>\n () => {\n // SAFETY: ServiceContract removes only the declaration-only identity; runtime values are unchanged.\n return acquire() as MaybePromise<InstanceType<S>>\n }\n\n/** Type-level aliases for inspecting Layer environments and completeness. */\nexport declare namespace Layer {\n /** The widened Layer shape accepted by generic Layer infrastructure. */\n export type Any = LayerInput\n\n /** Extract the branded Service instances provided by a Layer. */\n export type Provided<L extends LayerInput> = ProvidedEnvironment<L>\n\n /** Extract the external Service requirements of a Layer. */\n export type Required<L extends LayerInput> = RequiredEnvironment<L>\n\n /** Extract the Services still missing from a Layer composition. */\n export type Missing<L extends LayerInput> = RequiredEnvironment<L>\n\n /** Validate a Layer's requirements and input shape. */\n export type Complete<L extends LayerInput> = CompleteInput<L>\n}\n"],"mappings":";;;;;AAyBA,IAAa,iBAAb,MAAa,eAAe;;;;;;;;;;;;;CAa1B,OAAO,IACL,UACA,SACA,UAAiC,8BAC9B;EACH,MAAM,UAAU,kBAAkB,OAAO;EACzC,MAAM,UAAU,mBACd,UACA,SAAS,OACT,SAAS,aAAa,WAAW,QAAQ,iBAAiB,CAAC,GAC3D,SAAS,QACT,SAAS,aAAa,WAAW,UAAU,KAAA,CAC7C;EAEA,OAAO,kBAAkB,SAAS,SAAS,OAAO;CACpD;;CAGA,OAAO,UAA2B;EAChC,IAAI;EAEJ,IAAI;GACF,UAAU,sBAAsB;EAClC,SAAS,OAAO;GACd,IAAI,iBAAiB,kCACnB,MAAM,IAAI,iCAAiC;GAG7C,MAAM;EACR;EAEA,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,iCAAiC;EAG7C,OAAO,QAAQ;CACjB;;CAGA,aAAa,QAAmC,OAAoC;EAClF,kBAAkB,KAAK;EAGvB,OAAO,MAFU,eAAe,QAEZ,CAAC,CAAC,QAAQ,KAAK;CACrC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;ACtBA,SAAgB,UAAsC;CACpD,OAAO,SAAoC,KAA6B;EACtE,mBAAmB,GAAG;EAEtB,MAAe,YAA4C;;GAEzD,OAAgB,aAAkB;;;;;;;;;;;;;;;;;;;;;;;;GA0BlC,OAAO,GAAe,gBAAoE;IAExF,OAAO;GACT;;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AO;IAG9D,MAAM,IAAI,sBAAsB,OAAO;GACzC;GAEA,UAAU,IAAI,YAAY,QAAQ;EACpC;EAIF,OAAO,IAAI,MAAM,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC;CAC1C;;CAGA,OAAO,SAA+B,OAAgC;EACpE,OAAO;CACT;CAoBA,OAAO,SAAS,MAAkB,GAAG,WAAmD;EACtF,MAAM,4BAAY,IAAI,IAA2B;EAEjD,KAAK,MAAM,YAAY,KAAK,WAC1B,UAAU,IAAI,4BAA4B,QAAQ,GAAG,QAAQ;EAG/D,KAAK,MAAM,SAAS,WAClB,KAAK,MAAM,YAAY,MAAM,WAC3B,UAAU,IAAI,4BAA4B,QAAQ,GAAG,QAAQ;EAKjE,OAAO,IAAI,MAAM,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC;CAC1C;AACF;AAIA,OAAO,eAAe,OAAO,SAAS;CACpC,OAAO,MAAM;CACb,UAAU;CACV,YAAY;CACZ,cAAc;AAChB,CAAC;AAED,MAAM,oBAEF,kBAEI;CAEJ,OAAO,QAAQ;AACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outcome-CB43bnFW.d.mts","names":[],"sources":["../src/internal/variance.ts","../src/utils/types.ts","../src/internal/missing-dependencies.ts","../src/layer/metadata.ts","../src/layer/inference.ts","../src/layer/types.ts","../src/layer/layer.ts","../src/layer/backend.ts","../src/layer/errors.ts","../src/runtime/observer.ts","../src/runtime/outcome.ts"],"mappings":";;;KACY,UAAU,WAAW;;KAGrB,UAAU,MAAM,OAAO,MAAM;;;KCJ7B,aAAa,KAAK,IAAI,YAAY;;;KCElC,oBAAoB,gBAAgB;;WAErC,iBAAiB;;;;;cCCP;UAEJ,kBACX,iBAAiB,gBACjB,oBAAoB;WAEf,UAAU;WACV,UAAU;;UAGJ,qBACX,iBAAiB,gBACjB,uBAAuB;WAElB,UAAU;WACV,gBAAgB;;UAGV,oBACX,gBAAgB,cAAc,YAAY,yBAC1C,eAA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