@relkit/app 0.5.1 → 0.5.4
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/dist/app-config.types.d.ts +32 -0
- package/dist/app-config.types.d.ts.map +1 -0
- package/dist/app-config.types.js +2 -0
- package/dist/app-config.types.js.map +1 -0
- package/dist/app-observability.d.ts +21 -0
- package/dist/app-observability.d.ts.map +1 -0
- package/dist/app-observability.js +41 -0
- package/dist/app-observability.js.map +1 -0
- package/dist/app-observability.types.d.ts +18 -0
- package/dist/app-observability.types.d.ts.map +1 -0
- package/dist/app-observability.types.js +2 -0
- package/dist/app-observability.types.js.map +1 -0
- package/dist/app-provider-capabilities.d.ts +3 -0
- package/dist/app-provider-capabilities.d.ts.map +1 -0
- package/dist/{define-app-types.js → app-provider-capabilities.js} +2 -1
- package/dist/app-provider-capabilities.js.map +1 -0
- package/dist/app-provider-normalization.d.ts +32 -0
- package/dist/app-provider-normalization.d.ts.map +1 -0
- package/dist/app-provider-normalization.js +58 -0
- package/dist/app-provider-normalization.js.map +1 -0
- package/dist/{define-app-types.d.ts → app-provider.types.d.ts} +19 -50
- package/dist/app-provider.types.d.ts.map +1 -0
- package/dist/app-provider.types.js +2 -0
- package/dist/app-provider.types.js.map +1 -0
- package/dist/app-validation.d.ts +67 -1
- package/dist/app-validation.d.ts.map +1 -1
- package/dist/app-validation.js +100 -13
- package/dist/app-validation.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/context-descriptors.d.ts +39 -26
- package/dist/context-descriptors.d.ts.map +1 -1
- package/dist/context-descriptors.js +105 -27
- package/dist/context-descriptors.js.map +1 -1
- package/dist/context-descriptors.types.d.ts +58 -0
- package/dist/context-descriptors.types.d.ts.map +1 -0
- package/dist/context-descriptors.types.js +2 -0
- package/dist/context-descriptors.types.js.map +1 -0
- package/dist/context-resolution-service.d.ts +16 -0
- package/dist/context-resolution-service.d.ts.map +1 -0
- package/dist/context-resolution-service.js +31 -0
- package/dist/context-resolution-service.js.map +1 -0
- package/dist/context-resolution-service.types.d.ts +21 -0
- package/dist/context-resolution-service.types.d.ts.map +1 -0
- package/dist/context-resolution-service.types.js +2 -0
- package/dist/context-resolution-service.types.js.map +1 -0
- package/dist/context-resolver.d.ts +24 -15
- package/dist/context-resolver.d.ts.map +1 -1
- package/dist/context-resolver.js +85 -12
- package/dist/context-resolver.js.map +1 -1
- package/dist/context-resolver.types.d.ts +45 -0
- package/dist/context-resolver.types.d.ts.map +1 -0
- package/dist/context-resolver.types.js +2 -0
- package/dist/context-resolver.types.js.map +1 -0
- package/dist/define-app.d.ts +16 -15
- package/dist/define-app.d.ts.map +1 -1
- package/dist/define-app.js +67 -60
- package/dist/define-app.js.map +1 -1
- package/dist/define-app.types.d.ts +43 -0
- package/dist/define-app.types.d.ts.map +1 -0
- package/dist/define-app.types.js +2 -0
- package/dist/define-app.types.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +25 -18
- package/dist/define-app-types.d.ts.map +0 -1
- package/dist/define-app-types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-validation.js","sourceRoot":"","sources":["../src/app-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAqC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"app-validation.js","sourceRoot":"","sources":["../src/app-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAqC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AA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AE,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC;AAED,2CAA2C;AAC3C,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./app-validation.js";
|
|
2
|
+
export { AppTelemetry, AppTelemetryLive } from "./app-observability.js";
|
|
2
3
|
export * from "./define-app.js";
|
|
3
4
|
export * from "@relkit/config";
|
|
4
5
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxE,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./app-validation.js";
|
|
2
|
+
export { AppTelemetry, AppTelemetryLive } from "./app-observability.js";
|
|
2
3
|
export * from "./define-app.js";
|
|
3
4
|
export * from "@relkit/config";
|
|
4
5
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxE,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,30 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import type { ConstantsDescriptor, ConstantsShape, ContextDescriptorOptions, PromptDescriptor, PromptValue } from "./context-descriptors.types.js";
|
|
3
|
+
export * from "./context-descriptors.types.js";
|
|
4
|
+
declare const ContextDescriptorFailure_base: Schema.Class<ContextDescriptorFailure, Schema.TaggedStruct<"ContextDescriptorFailure", {
|
|
5
|
+
readonly message: Schema.String;
|
|
6
|
+
readonly cause: Schema.Defect;
|
|
7
|
+
}>, import("effect/Cause").YieldableError>;
|
|
8
|
+
/** Expected invalid constant or prompt descriptor input.
|
|
9
|
+
* @example if (error._tag === "ContextDescriptorFailure") console.error(error.message);
|
|
10
|
+
*/
|
|
11
|
+
export declare class ContextDescriptorFailure extends ContextDescriptorFailure_base {
|
|
8
12
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
readonly [Key in keyof Descriptor["values"]]: ResolveConstant<Descriptor["values"][Key]>;
|
|
24
|
-
};
|
|
25
|
-
export type ResolvedPrompt<Descriptor extends PromptDescriptor> = Descriptor["value"];
|
|
26
|
-
type ResolveConstant<Value> = Value extends (...args: never[]) => infer Result ? Awaited<Result> : Value extends EnvRef<string, infer Result> ? Result : Value;
|
|
13
|
+
/** Defines a frozen constants descriptor in Effect.
|
|
14
|
+
* @param values - Named JSON values, environment references, or resolver functions.
|
|
15
|
+
* @param options - Optional stable descriptor identity.
|
|
16
|
+
* @returns A constants descriptor or ContextDescriptorFailure.
|
|
17
|
+
* @example Effect.runSync(defineConstantsEffect({ region: "eu" }));
|
|
18
|
+
*/
|
|
19
|
+
export declare const defineConstantsEffect: <const Values extends ConstantsShape>(values: Values, options?: ContextDescriptorOptions | undefined) => Effect.Effect<ConstantsDescriptor<Values>, ContextDescriptorFailure, never>;
|
|
20
|
+
/** Synchronous constants descriptor adapter.
|
|
21
|
+
* @param values - Named constants and resolver functions.
|
|
22
|
+
* @param options - Optional stable descriptor identity.
|
|
23
|
+
* @returns A frozen constants descriptor.
|
|
24
|
+
* @throws The original validation error for invalid values.
|
|
25
|
+
* @example defineConstants({ region: "eu" });
|
|
26
|
+
*/
|
|
27
27
|
export declare function defineConstants<const Values extends ConstantsShape>(values: Values, options?: ContextDescriptorOptions): ConstantsDescriptor<Values>;
|
|
28
|
+
/** Defines a frozen prompt descriptor in Effect.
|
|
29
|
+
* @param value - Nonempty text or ordered text fragments.
|
|
30
|
+
* @param options - Optional stable descriptor identity.
|
|
31
|
+
* @returns A prompt descriptor or ContextDescriptorFailure.
|
|
32
|
+
* @example Effect.runSync(definePromptEffect("Be concise."));
|
|
33
|
+
*/
|
|
34
|
+
export declare const definePromptEffect: <const Value extends PromptValue>(value: Value, options?: ContextDescriptorOptions | undefined) => Effect.Effect<PromptDescriptor<Value>, ContextDescriptorFailure, never>;
|
|
35
|
+
/** Synchronous prompt descriptor adapter.
|
|
36
|
+
* @param value - Nonempty text or ordered text fragments.
|
|
37
|
+
* @param options - Optional stable descriptor identity.
|
|
38
|
+
* @returns A frozen prompt descriptor.
|
|
39
|
+
* @throws The original validation error for invalid text.
|
|
40
|
+
* @example definePrompt("Be concise.");
|
|
41
|
+
*/
|
|
28
42
|
export declare function definePrompt<const Value extends PromptValue>(value: Value, options?: ContextDescriptorOptions): PromptDescriptor<Value>;
|
|
29
|
-
export {};
|
|
30
43
|
//# sourceMappingURL=context-descriptors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-descriptors.d.ts","sourceRoot":"","sources":["../src/context-descriptors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context-descriptors.d.ts","sourceRoot":"","sources":["../src/context-descriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,gBAAgB,EAChB,WAAW,EACZ,MAAM,gCAAgC,CAAC;AACxC,cAAc,gCAAgC,CAAC;;;;;AAC/C;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,6BAG7C;CAAG;AACJ;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,SACzB,MAAM,SAAS,cAAc,gJA0BrC,CAAC;AACF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,CAAC,MAAM,SAAS,cAAc,EACjE,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,wBAA6B,GACrC,mBAAmB,CAAC,MAAM,CAAC,CAE7B;AACD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,SACtB,KAAK,SAAS,WAAW,0IAyBjC,CAAC;AACF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,KAAK,SAAS,WAAW,EAC1D,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,wBAA6B,GACrC,gBAAgB,CAAC,KAAK,CAAC,CAEzB"}
|
|
@@ -1,46 +1,124 @@
|
|
|
1
1
|
import { isEnvRef } from "@relkit/config";
|
|
2
|
-
import { createDescriptorBase, deepFreeze
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { createDescriptorBase, deepFreeze } from "@relkit/contracts";
|
|
3
|
+
import { createUnboundIdentityEffect, DescriptorIdentityFailure } from "@relkit/invocation";
|
|
4
|
+
import { Effect, Result, Schema } from "effect";
|
|
5
|
+
import { observeApp } from "./app-observability.js";
|
|
6
|
+
export * from "./context-descriptors.types.js";
|
|
7
|
+
/** Expected invalid constant or prompt descriptor input.
|
|
8
|
+
* @example if (error._tag === "ContextDescriptorFailure") console.error(error.message);
|
|
9
|
+
*/
|
|
10
|
+
export class ContextDescriptorFailure extends Schema.TaggedError()("ContextDescriptorFailure", { message: Schema.String, cause: Schema.Defect() }) {
|
|
11
|
+
}
|
|
12
|
+
/** Defines a frozen constants descriptor in Effect.
|
|
13
|
+
* @param values - Named JSON values, environment references, or resolver functions.
|
|
14
|
+
* @param options - Optional stable descriptor identity.
|
|
15
|
+
* @returns A constants descriptor or ContextDescriptorFailure.
|
|
16
|
+
* @example Effect.runSync(defineConstantsEffect({ region: "eu" }));
|
|
17
|
+
*/
|
|
18
|
+
export const defineConstantsEffect = Effect.fn("App.defineConstants")((values, options = {}) => observeApp("constants.define", Effect.gen(function* () {
|
|
5
19
|
if (!isRecord(values))
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
}
|
|
20
|
+
return yield* invalid("Constants must be an object map");
|
|
21
|
+
if (!isRecord(options))
|
|
22
|
+
return yield* invalid("Constants options must be an object");
|
|
10
23
|
for (const [key, value] of Object.entries(values)) {
|
|
11
|
-
if (key.trim() === "" ||
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
if (key.trim() === "" ||
|
|
25
|
+
(!isEnvRef(value) && typeof value !== "function" && !(yield* isJsonEffect(value))))
|
|
26
|
+
return yield* invalid(`Constant "${key}" is invalid`);
|
|
14
27
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
const authoredId = options.id;
|
|
29
|
+
const id = authoredId ?? (yield* createUnboundIdentityEffect().pipe(Effect.mapError(failure)));
|
|
30
|
+
return yield* Effect.try({
|
|
31
|
+
try: () => deepFreeze({
|
|
32
|
+
...createDescriptorBase("constants", id),
|
|
33
|
+
values: { ...values },
|
|
34
|
+
}),
|
|
35
|
+
catch: failure,
|
|
18
36
|
});
|
|
37
|
+
})));
|
|
38
|
+
/** Synchronous constants descriptor adapter.
|
|
39
|
+
* @param values - Named constants and resolver functions.
|
|
40
|
+
* @param options - Optional stable descriptor identity.
|
|
41
|
+
* @returns A frozen constants descriptor.
|
|
42
|
+
* @throws The original validation error for invalid values.
|
|
43
|
+
* @example defineConstants({ region: "eu" });
|
|
44
|
+
*/
|
|
45
|
+
export function defineConstants(values, options = {}) {
|
|
46
|
+
return runDescriptor(defineConstantsEffect(values, options));
|
|
19
47
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
48
|
+
/** Defines a frozen prompt descriptor in Effect.
|
|
49
|
+
* @param value - Nonempty text or ordered text fragments.
|
|
50
|
+
* @param options - Optional stable descriptor identity.
|
|
51
|
+
* @returns A prompt descriptor or ContextDescriptorFailure.
|
|
52
|
+
* @example Effect.runSync(definePromptEffect("Be concise."));
|
|
53
|
+
*/
|
|
54
|
+
export const definePromptEffect = Effect.fn("App.definePrompt")((value, options = {}) => observeApp("prompt.define", Effect.gen(function* () {
|
|
55
|
+
if (!isRecord(options))
|
|
56
|
+
return yield* invalid("Prompt options must be an object");
|
|
24
57
|
const values = typeof value === "string" ? [value] : value;
|
|
25
58
|
if (!Array.isArray(values) ||
|
|
26
59
|
values.length === 0 ||
|
|
27
|
-
values.some((entry) => entry.trim() === ""))
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
60
|
+
values.some((entry) => typeof entry !== "string" || entry.trim() === ""))
|
|
61
|
+
return yield* invalid("A prompt must contain nonempty text");
|
|
62
|
+
const authoredId = options.id;
|
|
63
|
+
const id = authoredId ?? (yield* createUnboundIdentityEffect().pipe(Effect.mapError(failure)));
|
|
64
|
+
return yield* Effect.try({
|
|
65
|
+
try: () => deepFreeze({
|
|
66
|
+
...createDescriptorBase("prompt", id),
|
|
67
|
+
value: Array.isArray(value) ? [...value] : value,
|
|
68
|
+
}),
|
|
69
|
+
catch: failure,
|
|
33
70
|
});
|
|
71
|
+
})));
|
|
72
|
+
/** Synchronous prompt descriptor adapter.
|
|
73
|
+
* @param value - Nonempty text or ordered text fragments.
|
|
74
|
+
* @param options - Optional stable descriptor identity.
|
|
75
|
+
* @returns A frozen prompt descriptor.
|
|
76
|
+
* @throws The original validation error for invalid text.
|
|
77
|
+
* @example definePrompt("Be concise.");
|
|
78
|
+
*/
|
|
79
|
+
export function definePrompt(value, options = {}) {
|
|
80
|
+
return runDescriptor(definePromptEffect(value, options));
|
|
34
81
|
}
|
|
35
|
-
|
|
82
|
+
/** Checks JSON values recursively without parallelizing pure traversal. */
|
|
83
|
+
const isJsonEffect = Effect.fn("App.isJson")((value) => Effect.gen(function* () {
|
|
36
84
|
if (value === null || ["string", "boolean"].includes(typeof value))
|
|
37
85
|
return true;
|
|
38
86
|
if (typeof value === "number")
|
|
39
87
|
return Number.isFinite(value);
|
|
40
|
-
if (Array.isArray(value))
|
|
41
|
-
|
|
42
|
-
|
|
88
|
+
if (Array.isArray(value)) {
|
|
89
|
+
for (const entry of value)
|
|
90
|
+
if (!(yield* isJsonEffect(entry)))
|
|
91
|
+
return false;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
if (!isRecord(value))
|
|
95
|
+
return false;
|
|
96
|
+
for (const entry of Object.values(value))
|
|
97
|
+
if (!(yield* isJsonEffect(entry)))
|
|
98
|
+
return false;
|
|
99
|
+
return true;
|
|
100
|
+
}));
|
|
101
|
+
/** Turns an invalid input into a typed failure. */
|
|
102
|
+
function invalid(message) {
|
|
103
|
+
return Effect.fail(failure(new TypeError(message)));
|
|
104
|
+
}
|
|
105
|
+
/** Retains the original validation cause for synchronous callers. */
|
|
106
|
+
function failure(cause) {
|
|
107
|
+
if (cause instanceof DescriptorIdentityFailure)
|
|
108
|
+
cause = cause.cause;
|
|
109
|
+
return new ContextDescriptorFailure({
|
|
110
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
111
|
+
cause,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/** Runs a descriptor Effect and rethrows its original compatibility error. */
|
|
115
|
+
function runDescriptor(effect) {
|
|
116
|
+
const result = Effect.runSync(Effect.result(effect));
|
|
117
|
+
if (Result.isFailure(result))
|
|
118
|
+
throw result.failure.cause;
|
|
119
|
+
return result.success;
|
|
43
120
|
}
|
|
121
|
+
/** Checks for a non-array object record. */
|
|
44
122
|
function isRecord(value) {
|
|
45
123
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
46
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-descriptors.js","sourceRoot":"","sources":["../src/context-descriptors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"context-descriptors.js","sourceRoot":"","sources":["../src/context-descriptors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAQpD,cAAc,gCAAgC,CAAC;AAC/C;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,MAAM,CAAC,WAAW,EAA4B,CAC1F,0BAA0B,EAC1B,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CACnD;CAAG;AACJ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,EAAE,CAAC,qBAAqB,C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AS,OAAO,CAAC,OAAe;IAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AACD,qEAAqE;AACrE,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI,KAAK,YAAY,yBAAyB;QAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACpE,OAAO,IAAI,wBAAwB,CAAC;QAClC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/D,KAAK;KACN,CAAC,CAAC;AACL,CAAC;AACD,8EAA8E;AAC9E,SAAS,aAAa,CAAI,MAAkD;IAC1E,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;QAAE,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC;AACD,4CAA4C;AAC5C,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { EnvRef } from "@relkit/config";
|
|
2
|
+
import type { DescriptorBase, JsonValue, MaybePromise } from "@relkit/contracts";
|
|
3
|
+
import type { PublicLogger } from "@relkit/invocation";
|
|
4
|
+
/** Inputs available to a dynamic constant resolver.
|
|
5
|
+
* @example const options: ContextResolverOptions = { env: {}, signal, log };
|
|
6
|
+
*/
|
|
7
|
+
export interface ContextResolverOptions {
|
|
8
|
+
readonly env: Readonly<Record<string, unknown>>;
|
|
9
|
+
readonly signal: AbortSignal;
|
|
10
|
+
readonly log: PublicLogger;
|
|
11
|
+
}
|
|
12
|
+
/** Computes one constant for each context resolution.
|
|
13
|
+
* @example const region: ConstantResolver<string> = ({ env }) => String(env.REGION);
|
|
14
|
+
*/
|
|
15
|
+
export type ConstantResolver<Value = unknown> = (options: ContextResolverOptions) => MaybePromise<Value>;
|
|
16
|
+
/** Accepted static, environment, or dynamic constant input.
|
|
17
|
+
* @example const value: ConstantValue = "eu-west-1";
|
|
18
|
+
*/
|
|
19
|
+
export type ConstantValue = JsonValue | EnvRef | ConstantResolver;
|
|
20
|
+
/** Named constant inputs for one descriptor.
|
|
21
|
+
* @example const values: ConstantsShape = { region: "eu-west-1" };
|
|
22
|
+
*/
|
|
23
|
+
export type ConstantsShape = Readonly<Record<string, ConstantValue>>;
|
|
24
|
+
/** Immutable descriptor for one set of constants.
|
|
25
|
+
* @example const descriptor: ConstantsDescriptor = defineConstants({ region: "eu" });
|
|
26
|
+
*/
|
|
27
|
+
export interface ConstantsDescriptor<Values extends ConstantsShape = ConstantsShape> extends DescriptorBase<"constants", string> {
|
|
28
|
+
readonly values: Values;
|
|
29
|
+
}
|
|
30
|
+
/** Prompt text or an ordered list of prompt fragments.
|
|
31
|
+
* @example const prompt: PromptValue = ["Be concise.", "Use tools."];
|
|
32
|
+
*/
|
|
33
|
+
export type PromptValue = string | readonly string[];
|
|
34
|
+
/** Immutable descriptor for one prompt.
|
|
35
|
+
* @example const descriptor: PromptDescriptor = definePrompt("Be concise.");
|
|
36
|
+
*/
|
|
37
|
+
export interface PromptDescriptor<Value extends PromptValue = PromptValue> extends DescriptorBase<"prompt", string> {
|
|
38
|
+
readonly value: Value;
|
|
39
|
+
}
|
|
40
|
+
/** Optional stable identity for a context descriptor.
|
|
41
|
+
* @example const options: ContextDescriptorOptions = { id: "support.prompt" };
|
|
42
|
+
*/
|
|
43
|
+
export interface ContextDescriptorOptions {
|
|
44
|
+
readonly id?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Resolved values inferred from a constants descriptor.
|
|
47
|
+
* @example type Values = ResolvedConstants<typeof constants>;
|
|
48
|
+
*/
|
|
49
|
+
export type ResolvedConstants<Descriptor extends ConstantsDescriptor> = {
|
|
50
|
+
readonly [Key in keyof Descriptor["values"]]: ResolveConstant<Descriptor["values"][Key]>;
|
|
51
|
+
};
|
|
52
|
+
/** Resolved prompt text inferred from a prompt descriptor.
|
|
53
|
+
* @example type Text = ResolvedPrompt<typeof prompt>;
|
|
54
|
+
*/
|
|
55
|
+
export type ResolvedPrompt<Descriptor extends PromptDescriptor> = Descriptor["value"];
|
|
56
|
+
type ResolveConstant<Value> = Value extends (...args: never[]) => infer Result ? Awaited<Result> : Value extends EnvRef<string, infer Result> ? Result : Value;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=context-descriptors.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-descriptors.types.d.ts","sourceRoot":"","sources":["../src/context-descriptors.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,KAAK,GAAG,OAAO,IAAI,CAC9C,OAAO,EAAE,sBAAsB,KAC5B,YAAY,CAAC,KAAK,CAAC,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,aAA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1
|
+
{"version":3,"file":"context-descriptors.types.js","sourceRoot":"","sources":["../src/context-descriptors.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
|
+
import type { AppConstantRunnerService } from "./context-resolution-service.types.js";
|
|
3
|
+
export type { AppConstantRunnerService } from "./context-resolution-service.types.js";
|
|
4
|
+
declare const AppConstantRunner_base: Context.ServiceClass<AppConstantRunner, "relkit/app/AppConstantRunner", AppConstantRunnerService>;
|
|
5
|
+
/** Replaceable boundary for dynamic constant callback execution.
|
|
6
|
+
* @example Effect.provide(resolver.resolveEffect(context), AppConstantRunnerLive);
|
|
7
|
+
*/
|
|
8
|
+
export declare class AppConstantRunner extends AppConstantRunner_base {
|
|
9
|
+
}
|
|
10
|
+
/** Live runner that propagates Effect interruption into callback AbortSignals.
|
|
11
|
+
* @example Effect.provide(resolver.resolveEffect(context), AppConstantRunnerLive);
|
|
12
|
+
*/
|
|
13
|
+
export declare const AppConstantRunnerLive: Layer.Layer<AppConstantRunner, never, never>;
|
|
14
|
+
/** Compatibility runner that passes the caller's exact signal to callbacks. */
|
|
15
|
+
export declare const AppConstantRunnerPromiseLive: Layer.Layer<AppConstantRunner, never, never>;
|
|
16
|
+
//# sourceMappingURL=context-resolution-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-resolution-service.d.ts","sourceRoot":"","sources":["../src/context-resolution-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAEtF,YAAY,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;;AACtF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,sBAGJ;CAAG;AACtC;;GAEG;AACH,eAAO,MAAM,qBAAqB,8CAUhC,CAAC;AACH,+EAA+E;AAC/E,eAAO,MAAM,4BAA4B,8CAOvC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import { ContextResolutionFailure } from "./context-resolver.js";
|
|
3
|
+
/** Replaceable boundary for dynamic constant callback execution.
|
|
4
|
+
* @example Effect.provide(resolver.resolveEffect(context), AppConstantRunnerLive);
|
|
5
|
+
*/
|
|
6
|
+
export class AppConstantRunner extends Context.Service()("relkit/app/AppConstantRunner") {
|
|
7
|
+
}
|
|
8
|
+
/** Live runner that propagates Effect interruption into callback AbortSignals.
|
|
9
|
+
* @example Effect.provide(resolver.resolveEffect(context), AppConstantRunnerLive);
|
|
10
|
+
*/
|
|
11
|
+
export const AppConstantRunnerLive = Layer.succeed(AppConstantRunner, {
|
|
12
|
+
run: Effect.fn("App.ConstantRunner.run")((resolver, options) => Effect.tryPromise({
|
|
13
|
+
try: (signal) => Promise.resolve(resolver({ ...options, signal: AbortSignal.any([options.signal, signal]) })),
|
|
14
|
+
catch: failure,
|
|
15
|
+
})),
|
|
16
|
+
});
|
|
17
|
+
/** Compatibility runner that passes the caller's exact signal to callbacks. */
|
|
18
|
+
export const AppConstantRunnerPromiseLive = Layer.succeed(AppConstantRunner, {
|
|
19
|
+
run: Effect.fn("App.ConstantRunner.runPromise")((resolver, options) => Effect.tryPromise({
|
|
20
|
+
try: () => Promise.resolve(resolver(options)),
|
|
21
|
+
catch: failure,
|
|
22
|
+
})),
|
|
23
|
+
});
|
|
24
|
+
/** Maps callback failures into the context error channel. */
|
|
25
|
+
function failure(cause) {
|
|
26
|
+
return new ContextResolutionFailure({
|
|
27
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
28
|
+
cause,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=context-resolution-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-resolution-service.js","sourceRoot":"","sources":["../src/context-resolution-service.ts"],"names":[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AAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/D,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PublicLogger } from "@relkit/invocation";
|
|
2
|
+
import type { Effect } from "effect";
|
|
3
|
+
import type { ConstantResolver } from "./context-descriptors.types.js";
|
|
4
|
+
import type { ContextResolutionFailure } from "./context-resolver.js";
|
|
5
|
+
/** Replaceable execution boundary for dynamic constant callbacks.
|
|
6
|
+
* @example const runner: AppConstantRunnerService = { run: () => Effect.succeed("eu") };
|
|
7
|
+
*/
|
|
8
|
+
export interface AppConstantRunnerService {
|
|
9
|
+
/** Invokes a dynamic constant resolver.
|
|
10
|
+
* @param resolver - User supplied constant callback.
|
|
11
|
+
* @param options - Environment, logger, and caller signal available to the callback.
|
|
12
|
+
* @returns The callback result or ContextResolutionFailure.
|
|
13
|
+
* @example runner.run(() => "eu", { env: {}, log });
|
|
14
|
+
*/
|
|
15
|
+
readonly run: (resolver: ConstantResolver, options: {
|
|
16
|
+
readonly env: Readonly<Record<string, unknown>>;
|
|
17
|
+
readonly log: PublicLogger;
|
|
18
|
+
readonly signal: AbortSignal;
|
|
19
|
+
}) => Effect.Effect<unknown, ContextResolutionFailure>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=context-resolution-service.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-resolution-service.types.d.ts","sourceRoot":"","sources":["../src/context-resolution-service.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,CACZ,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE;QACP,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAChD,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;QAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;KAC9B,KACE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,wBAAwB,CAAC,CAAC;CACvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-resolution-service.types.js","sourceRoot":"","sources":["../src/context-resolution-service.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import type { ApplicationContextOptions, ApplicationContextResolver } from "./context-resolver.types.js";
|
|
3
|
+
export type * from "./context-resolver.types.js";
|
|
4
|
+
declare const ContextResolutionFailure_base: Schema.Class<ContextResolutionFailure, Schema.TaggedStruct<"ContextResolutionFailure", {
|
|
5
|
+
readonly message: Schema.String;
|
|
6
|
+
readonly cause: Schema.Defect;
|
|
7
|
+
}>, import("effect/Cause").YieldableError>;
|
|
8
|
+
/** Expected context registration or resolution failure with its original cause.
|
|
9
|
+
* @example if (error._tag === "ContextResolutionFailure") console.error(error.message);
|
|
10
|
+
*/
|
|
11
|
+
export declare class ContextResolutionFailure extends ContextResolutionFailure_base {
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
/** Builds an application context resolver in Effect.
|
|
14
|
+
* @param options - Constants, prompts, and resolved environment values.
|
|
15
|
+
* @returns A resolver or ContextResolutionFailure for duplicate names.
|
|
16
|
+
* @example Effect.runSync(createApplicationContextResolverEffect({ env: {} }));
|
|
17
|
+
*/
|
|
18
|
+
export declare const createApplicationContextResolverEffect: (options: ApplicationContextOptions) => Effect.Effect<ApplicationContextResolver, ContextResolutionFailure, never>;
|
|
19
|
+
/** Builds a context resolver synchronously for existing application callers.
|
|
20
|
+
* @param options - Constants, prompts, and resolved environment values.
|
|
21
|
+
* @returns A resolver with Promise and Effect execution paths.
|
|
22
|
+
* @throws TypeError when constant names collide.
|
|
23
|
+
* @example createApplicationContextResolver({ env: {} });
|
|
24
|
+
*/
|
|
25
|
+
export declare function createApplicationContextResolver(options: ApplicationContextOptions): ApplicationContextResolver;
|
|
17
26
|
//# sourceMappingURL=context-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-resolver.d.ts","sourceRoot":"","sources":["../src/context-resolver.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"context-resolver.d.ts","sourceRoot":"","sources":["../src/context-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhD,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAG3B,MAAM,6BAA6B,CAAC;AACrC,mBAAmB,6BAA6B,CAAC;;;;;AACjD;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,6BAG7C;CAAG;AACJ;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,oHA+ElD,CAAC;AACF;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,yBAAyB,GACjC,0BAA0B,CAI5B"}
|