@alpacakit/channels 0.1.0-beta.36 → 0.1.0-beta.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +204 -723
  2. package/dist/binding-compiler.d.ts +12 -2
  3. package/dist/binding-compiler.d.ts.map +1 -1
  4. package/dist/binding-compiler.js +25 -0
  5. package/dist/cli-coercion.d.ts +1 -1
  6. package/dist/cli-coercion.d.ts.map +1 -1
  7. package/dist/cli-coercion.js +14 -29
  8. package/dist/cli-compiler.d.ts +4 -17
  9. package/dist/cli-compiler.d.ts.map +1 -1
  10. package/dist/cli-compiler.js +78 -39
  11. package/dist/cli-help-projection.d.ts.map +1 -1
  12. package/dist/cli-help-projection.js +41 -36
  13. package/dist/cli-model.d.ts +50 -65
  14. package/dist/cli-model.d.ts.map +1 -1
  15. package/dist/cli-model.js +26 -34
  16. package/dist/cli-tree.d.ts +6 -3
  17. package/dist/cli-tree.d.ts.map +1 -1
  18. package/dist/cli-tree.js +161 -387
  19. package/dist/cli.d.ts +1 -5
  20. package/dist/cli.d.ts.map +1 -1
  21. package/dist/cli.js +1 -5
  22. package/dist/codecs.d.ts +20 -18
  23. package/dist/codecs.d.ts.map +1 -1
  24. package/dist/codecs.js +21 -31
  25. package/dist/contract.d.ts.map +1 -1
  26. package/dist/contract.js +8 -3
  27. package/dist/definition-error.d.ts +5 -0
  28. package/dist/definition-error.d.ts.map +1 -0
  29. package/dist/definition-error.js +8 -0
  30. package/dist/factory.d.ts +25 -11
  31. package/dist/factory.d.ts.map +1 -1
  32. package/dist/factory.js +28 -18
  33. package/dist/http-compiler.d.ts +15 -0
  34. package/dist/http-compiler.d.ts.map +1 -0
  35. package/dist/http-compiler.js +37 -0
  36. package/dist/http-model.d.ts +42 -0
  37. package/dist/http-model.d.ts.map +1 -0
  38. package/dist/http-model.js +20 -0
  39. package/dist/http-tree.d.ts +7 -0
  40. package/dist/http-tree.d.ts.map +1 -0
  41. package/dist/http-tree.js +181 -0
  42. package/dist/http.d.ts +3 -0
  43. package/dist/http.d.ts.map +1 -0
  44. package/dist/http.js +2 -0
  45. package/dist/index.d.ts +2 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +1 -1
  48. package/dist/input-compiler.d.ts +13 -0
  49. package/dist/input-compiler.d.ts.map +1 -0
  50. package/dist/input-compiler.js +122 -0
  51. package/dist/introspection.d.ts +1 -1
  52. package/dist/introspection.d.ts.map +1 -1
  53. package/dist/introspection.js +30 -16
  54. package/dist/mcp.d.ts +25 -24
  55. package/dist/mcp.d.ts.map +1 -1
  56. package/dist/mcp.js +87 -65
  57. package/dist/model.d.ts +44 -42
  58. package/dist/model.d.ts.map +1 -1
  59. package/dist/model.js +44 -9
  60. package/dist/owned.d.ts +12 -0
  61. package/dist/owned.d.ts.map +1 -0
  62. package/dist/owned.js +61 -0
  63. package/dist/registration.d.ts +41 -0
  64. package/dist/registration.d.ts.map +1 -0
  65. package/dist/registration.js +14 -0
  66. package/dist/runtime.d.ts +2 -35
  67. package/dist/runtime.d.ts.map +1 -1
  68. package/dist/runtime.js +2 -127
  69. package/dist/schema.d.ts +11 -8
  70. package/dist/schema.d.ts.map +1 -1
  71. package/dist/schema.js +110 -47
  72. package/dist/string-coercion.d.ts +4 -0
  73. package/dist/string-coercion.d.ts.map +1 -0
  74. package/dist/string-coercion.js +24 -0
  75. package/dist/tree-internal.d.ts +4 -2
  76. package/dist/tree-internal.d.ts.map +1 -1
  77. package/dist/tree-internal.js +5 -2
  78. package/dist/values.d.ts +1 -6
  79. package/dist/values.d.ts.map +1 -1
  80. package/dist/values.js +1 -6
  81. package/examples/README.md +28 -0
  82. package/examples/book-search.ts +151 -0
  83. package/examples/greeting.ts +193 -0
  84. package/package.json +9 -4
  85. package/dist/cli-application.d.ts +0 -40
  86. package/dist/cli-application.d.ts.map +0 -1
  87. package/dist/cli-application.js +0 -90
  88. package/dist/cli-executor.d.ts +0 -25
  89. package/dist/cli-executor.d.ts.map +0 -1
  90. package/dist/cli-executor.js +0 -44
  91. package/dist/cli-presentation.d.ts +0 -32
  92. package/dist/cli-presentation.d.ts.map +0 -1
  93. package/dist/cli-presentation.js +0 -293
  94. package/dist/cli-result-envelope.d.ts +0 -104
  95. package/dist/cli-result-envelope.d.ts.map +0 -1
  96. package/dist/cli-result-envelope.js +0 -137
  97. package/dist/cli-schema.d.ts +0 -4
  98. package/dist/cli-schema.d.ts.map +0 -1
  99. package/dist/cli-schema.js +0 -7
package/dist/model.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import type { CodecDecodeResult, JsonValue, RuntimeCodec } from "@alpacakit/core";
1
+ import type { JsonValue } from "@alpacakit/core";
2
2
  import type { z } from "zod";
3
3
  import { type Channel, PARAMETER_REQUIREMENT_KIND, type VALUE_SHAPE_KIND } from "./values.js";
4
4
  declare const EntryTreeDefinitionBrand: unique symbol;
5
5
  declare const EntryTreeNodeBrand: unique symbol;
6
+ declare const EntryTreeNodeEndpoints: unique symbol;
6
7
  declare const EntryTreeEndpointBrand: unique symbol;
7
8
  declare const ChannelSegmentOverrideBrand: unique symbol;
8
9
  declare const EntryChannelBindingBrand: unique symbol;
9
- declare const EntryChannelBindingParameterNames: unique symbol;
10
10
  export type StringValueShape = {
11
11
  readonly kind: typeof VALUE_SHAPE_KIND.string;
12
12
  };
@@ -28,22 +28,21 @@ export type ArrayValueShape<Element extends ScalarValueShape = ScalarValueShape>
28
28
  export type ValueShape = ScalarValueShape | ArrayValueShape;
29
29
  type ScalarJsonValue = string | number | boolean;
30
30
  type ScalarValueShapeFor<Value extends JsonValue> = [Value] extends [boolean] ? BooleanValueShape : [Value] extends [number] ? PositiveIntegerValueShape : [Value] extends [string] ? StringValueShape | StringEnumValueShape<readonly Value[]> : never;
31
- export type ValueShapeFor<Value extends JsonValue> = [Value] extends [
31
+ export type ValueShapeFor<Raw extends JsonValue> = [Raw] extends [
32
32
  ScalarJsonValue
33
- ] ? ScalarValueShapeFor<Value> : [Value] extends [readonly (infer Element extends JsonValue)[]] ? ArrayValueShape<ScalarValueShapeFor<Element>> : JsonValue extends Value ? ValueShape : never;
34
- export type ValueForShape<Shape extends ValueShape> = Shape extends BooleanValueShape ? boolean : Shape extends PositiveIntegerValueShape ? number : Shape extends StringEnumValueShape<infer Values> ? Values[number] : Shape extends StringValueShape ? string : Shape extends ArrayValueShape<infer Element> ? readonly ValueForShape<Element>[] : never;
35
- export interface ValueCodec<Value extends JsonValue> extends RuntimeCodec<Value> {
36
- readonly schema: z.ZodType<Value>;
37
- readonly shape: ValueShapeFor<Value>;
33
+ ] ? ScalarValueShapeFor<Raw> : [Raw] extends [readonly (infer Element extends JsonValue)[]] ? [Element] extends [ScalarJsonValue] ? ArrayValueShape<ScalarValueShapeFor<Element>> : StringValueShape : ValueShape;
34
+ /** A schema input (`Raw`) and its decoded output (`Value`) are distinct. */
35
+ type JsonInput<Raw> = Raw extends JsonValue ? Raw : JsonValue;
36
+ export interface ValueCodec<Raw = JsonValue, Value extends JsonValue = JsonValue> {
37
+ readonly schema: z.ZodType<Value, Raw>;
38
+ readonly shape: ValueShapeFor<JsonInput<Raw>>;
38
39
  }
39
40
  export type ErasedValueCodec = {
40
41
  readonly schema: z.ZodType;
41
42
  readonly shape: ValueShape;
42
- decode(input: unknown): CodecDecodeResult<JsonValue>;
43
43
  };
44
44
  export interface OutputContract<Value extends JsonValue> {
45
45
  readonly schema: z.ZodType<Value>;
46
- decode(input: unknown): CodecDecodeResult<Value>;
47
46
  }
48
47
  export type RequiredParameterRequirement = {
49
48
  readonly kind: typeof PARAMETER_REQUIREMENT_KIND.required;
@@ -51,14 +50,14 @@ export type RequiredParameterRequirement = {
51
50
  export type OptionalParameterRequirement = {
52
51
  readonly kind: typeof PARAMETER_REQUIREMENT_KIND.optional;
53
52
  };
54
- export type OptionalWithDefaultParameterRequirement<Value extends JsonValue> = {
53
+ export type OptionalWithDefaultParameterRequirement<Raw extends JsonValue> = {
55
54
  readonly kind: typeof PARAMETER_REQUIREMENT_KIND.optionalWithDefault;
56
- readonly defaultValue: Value;
55
+ readonly defaultValue: Raw;
57
56
  };
58
- export type ParameterRequirement<Value extends JsonValue> = RequiredParameterRequirement | OptionalParameterRequirement | OptionalWithDefaultParameterRequirement<Value>;
59
- export type ParameterDefinition<Name extends string, Value extends JsonValue, Requirement extends ParameterRequirement<Value> = ParameterRequirement<Value>> = {
57
+ export type ParameterRequirement<Raw extends JsonValue> = RequiredParameterRequirement | OptionalParameterRequirement | OptionalWithDefaultParameterRequirement<Raw>;
58
+ export type ParameterDefinition<Name extends string, Raw, Value extends JsonValue, Requirement extends ParameterRequirement<JsonInput<Raw>> = ParameterRequirement<JsonInput<Raw>>> = {
60
59
  readonly name: Name;
61
- readonly codec: ValueCodec<Value>;
60
+ readonly codec: ValueCodec<Raw, Value>;
62
61
  readonly requirement: Requirement;
63
62
  readonly description: string;
64
63
  };
@@ -72,7 +71,7 @@ export type ParameterSet = readonly ErasedParameterDefinition[];
72
71
  export type RawValueMap = {
73
72
  readonly [key: string]: unknown;
74
73
  };
75
- type ParameterValue<Parameter extends ErasedParameterDefinition> = Parameter extends ParameterDefinition<string, infer Value> ? Value : never;
74
+ type ParameterValue<Parameter extends ErasedParameterDefinition> = Parameter["codec"] extends ValueCodec<infer _Raw, infer Value> ? Value : never;
76
75
  type ParameterMaterialization<Parameter extends ParameterSet[number]> = Parameter["requirement"]["kind"] extends typeof PARAMETER_REQUIREMENT_KIND.required | typeof PARAMETER_REQUIREMENT_KIND.optionalWithDefault ? true : false;
77
76
  type MaterializedParameter<Parameter extends ParameterSet[number]> = ParameterMaterialization<Parameter> extends true ? Parameter : never;
78
77
  type OmittedParameter<Parameter extends ParameterSet[number]> = ParameterMaterialization<Parameter> extends false ? Parameter : never;
@@ -91,14 +90,13 @@ type EntryDefinitionBase<Name extends string, Parameters extends ParameterSet, P
91
90
  export type EntryDefinitionInput<Name extends string, Parameters extends ParameterSet, Projection, Output extends JsonValue = JsonValue> = EntryDefinitionBase<Name, Parameters, Projection> & {
92
91
  readonly output?: OutputContract<Output>;
93
92
  };
94
- export type EntryDefinition<Name extends string, Parameters extends ParameterSet, Projection, Output extends JsonValue = JsonValue> = (EntryDefinitionBase<Name, Parameters, Projection> & {
93
+ export type EntryDefinition<Name extends string = string, Parameters extends ParameterSet = ParameterSet, Projection = unknown, Output extends JsonValue = JsonValue> = (EntryDefinitionBase<Name, Parameters, Projection> & {
95
94
  readonly output: null;
96
95
  }) | (EntryDefinitionBase<Name, Parameters, Projection> & {
97
96
  readonly output: OutputContract<Output>;
98
97
  });
99
98
  export type ErasedOutputContract = {
100
99
  readonly schema: z.ZodType;
101
- decode(input: unknown): CodecDecodeResult<JsonValue>;
102
100
  };
103
101
  export type ErasedEntryDefinition = {
104
102
  readonly name: string;
@@ -111,9 +109,22 @@ export type ErasedEntryDefinition = {
111
109
  readonly project: (input: never) => unknown;
112
110
  readonly output: ErasedOutputContract;
113
111
  };
114
- export type EntryTreeDefinition = {
115
- readonly root: EntryTreeNode;
116
- readonly [EntryTreeDefinitionBrand]: true;
112
+ export type Callable = (...args: never[]) => unknown;
113
+ export type EntryChannelBinding<ChannelName extends Channel = Channel, Binding = unknown> = {
114
+ readonly channel: ChannelName;
115
+ readonly binding: Binding;
116
+ readonly [EntryChannelBindingBrand]: true;
117
+ };
118
+ export type ChannelSegmentOverride<ChannelName extends Channel = Channel, Segment = unknown> = {
119
+ readonly channel: ChannelName;
120
+ readonly segment: Segment;
121
+ readonly [ChannelSegmentOverrideBrand]: true;
122
+ };
123
+ export type EntryTreeEndpoint<Entry extends ErasedEntryDefinition = ErasedEntryDefinition, Handler extends Callable = Callable, Channels extends readonly EntryChannelBinding[] = readonly EntryChannelBinding[]> = {
124
+ readonly entry: Entry;
125
+ readonly handler: Handler;
126
+ readonly channels: Channels;
127
+ readonly [EntryTreeEndpointBrand]: true;
117
128
  };
118
129
  export type CommandDocumentation = {
119
130
  readonly remarks: readonly string[];
@@ -123,44 +134,35 @@ export type CommandDocumentationInput = {
123
134
  readonly remarks?: readonly string[];
124
135
  readonly relatedDocs?: readonly string[];
125
136
  };
126
- export type EntryTreeNode = {
137
+ export type EntryTreeNode<Endpoints extends EntryTreeEndpoint = EntryTreeEndpoint> = {
127
138
  readonly name: string;
128
139
  readonly description: string;
129
140
  readonly documentation: CommandDocumentation;
130
141
  readonly segments: readonly ChannelSegmentOverride[];
131
142
  readonly endpoints: readonly EntryTreeEndpoint[];
132
143
  readonly children: readonly EntryTreeNode[];
144
+ readonly [EntryTreeNodeEndpoints]: Endpoints;
133
145
  readonly [EntryTreeNodeBrand]: true;
134
146
  };
135
- export type EntryTreeEndpoint<Entry extends ErasedEntryDefinition = ErasedEntryDefinition> = {
136
- readonly entry: Entry;
137
- readonly channels: readonly EntryChannelBinding[];
138
- readonly [EntryTreeEndpointBrand]: true;
139
- };
140
- export type ChannelSegmentOverride = {
141
- readonly channel: Channel;
142
- readonly segment: unknown;
143
- readonly [ChannelSegmentOverrideBrand]: true;
144
- };
145
- export type EntryChannelBinding<ChannelName extends Channel = Channel, ParameterName extends string = string> = {
146
- readonly channel: ChannelName;
147
- readonly binding: unknown;
148
- readonly [EntryChannelBindingBrand]: true;
149
- readonly [EntryChannelBindingParameterNames]: ParameterName;
147
+ export type EntryTreeDefinition<Endpoints extends EntryTreeEndpoint = EntryTreeEndpoint> = {
148
+ readonly root: EntryTreeNode<Endpoints>;
149
+ readonly [EntryTreeDefinitionBrand]: true;
150
150
  };
151
+ export type EndpointsOfNode<Node extends EntryTreeNode> = Node extends EntryTreeNode<infer Endpoints> ? Endpoints : never;
152
+ export type EndpointsOfTree<Tree extends EntryTreeDefinition> = Tree extends EntryTreeDefinition<infer Endpoints> ? Endpoints : never;
151
153
  export type EntryDefinitionWithOutput<Name extends string, Parameters extends ParameterSet, Projection, Output extends JsonValue> = Extract<EntryDefinition<Name, Parameters, Projection, Output>, {
152
154
  readonly output: OutputContract<Output>;
153
155
  }>;
154
156
  export type EntryDefinitionInputWithOutput<Name extends string, Parameters extends ParameterSet, Projection, Output extends JsonValue> = EntryDefinitionInput<Name, Parameters, Projection, Output> & {
155
157
  readonly output: OutputContract<Output>;
156
158
  };
157
- export declare function defineParameter<const Name extends string, Value extends JsonValue, const Requirement extends ParameterRequirement<Value>>(parameter: ParameterDefinition<Name, Value, Requirement>): ParameterDefinition<Name, Value, Requirement>;
159
+ export declare function defineParameter<const Name extends string, Raw, Value extends JsonValue, const Requirement extends ParameterRequirement<JsonInput<Raw>>>(parameter: ParameterDefinition<Name, Raw, Value, Requirement>): ParameterDefinition<Name, Raw, Value, Requirement>;
158
160
  export declare function defineEntry<const Name extends string, const Parameters extends ParameterSet, Projection, Output extends JsonValue>(entry: EntryDefinitionInputWithOutput<Name, Parameters, Projection, Output>): EntryDefinitionWithOutput<Name, Parameters, Projection, Output>;
159
161
  export declare function defineEntry<const Name extends string, const Parameters extends ParameterSet, Projection, Output extends JsonValue = JsonValue>(entry: EntryDefinitionInput<Name, Parameters, Projection, Output>): EntryDefinition<Name, Parameters, Projection, Output>;
160
162
  export declare function required(): RequiredParameterRequirement;
161
- export declare function optional<_Value extends JsonValue>(): OptionalParameterRequirement;
162
- export declare function optional<Value extends JsonValue>(input: {
163
- readonly default: Value;
164
- }): OptionalWithDefaultParameterRequirement<Value>;
163
+ export declare function optional<_Raw extends JsonValue>(): OptionalParameterRequirement;
164
+ export declare function optional<const Raw extends JsonValue>(input: {
165
+ readonly default: Raw;
166
+ }): OptionalWithDefaultParameterRequirement<Raw>;
165
167
  export {};
166
168
  //# sourceMappingURL=model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,SAAS,EACT,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EACL,KAAK,OAAO,EACZ,0BAA0B,EAC1B,KAAK,gBA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ionError } from "./definition-error.js";
2
+ import { ownedArray, ownedRecord, snapshotJsonValue, snapshotValueShape, } from "./owned.js";
1
3
  import { PARAMETER_REQUIREMENT_KIND, } from "./values.js";
2
4
  export function defineParameter(parameter) {
3
- return parameter;
5
+ return snapshotParameter(parameter);
4
6
  }
5
7
  export function defineEntry(entry) {
6
- if (entry.output === undefined) {
7
- return { ...entry, output: null };
8
+ const parameters = ownedArray(entry.parameters.map((parameter) => snapshotParameter(parameter)));
9
+ const names = new Set();
10
+ const issues = [];
11
+ for (const parameter of parameters) {
12
+ if (names.has(parameter.name)) {
13
+ issues.push(`${entry.name}: duplicate parameter name ${JSON.stringify(parameter.name)}`);
14
+ }
15
+ names.add(parameter.name);
8
16
  }
9
- return { ...entry, output: entry.output };
17
+ if (issues.length > 0) {
18
+ throw new EntryTreeDefinitionError(issues);
19
+ }
20
+ const output = entry.output === undefined
21
+ ? null
22
+ : ownedRecord({ schema: entry.output.schema });
23
+ return ownedRecord({ ...entry, parameters, output });
10
24
  }
11
25
  export function required() {
12
- return { kind: PARAMETER_REQUIREMENT_KIND.required };
26
+ return ownedRecord({ kind: PARAMETER_REQUIREMENT_KIND.required });
13
27
  }
14
28
  export function optional(input) {
15
29
  if (input === undefined) {
16
- return { kind: PARAMETER_REQUIREMENT_KIND.optional };
30
+ return ownedRecord({ kind: PARAMETER_REQUIREMENT_KIND.optional });
17
31
  }
18
- return {
32
+ return ownedRecord({
19
33
  kind: PARAMETER_REQUIREMENT_KIND.optionalWithDefault,
20
- defaultValue: input.default,
21
- };
34
+ defaultValue: snapshotJsonValue(input.default),
35
+ });
36
+ }
37
+ function snapshotParameter(parameter) {
38
+ if (parameter.name.length === 0) {
39
+ throw new EntryTreeDefinitionError(["parameter name must not be empty"]);
40
+ }
41
+ const requirement = parameter.requirement.kind ===
42
+ PARAMETER_REQUIREMENT_KIND.optionalWithDefault
43
+ ? ownedRecord({
44
+ kind: parameter.requirement.kind,
45
+ defaultValue: snapshotJsonValue(parameter.requirement.defaultValue),
46
+ })
47
+ : ownedRecord({ kind: parameter.requirement.kind });
48
+ return ownedRecord({
49
+ name: parameter.name,
50
+ codec: ownedRecord({
51
+ schema: parameter.codec.schema,
52
+ shape: snapshotValueShape(parameter.codec.shape),
53
+ }),
54
+ requirement,
55
+ description: parameter.description,
56
+ });
22
57
  }
@@ -0,0 +1,12 @@
1
+ import type { JsonValue } from "@alpacakit/core";
2
+ import type { ValueShape } from "./model.js";
3
+ /** Copies and freezes an array whose contents are already owned snapshots. */
4
+ export declare function ownedArray<const Values extends readonly unknown[]>(values: Values): Values;
5
+ /** Freezes one library-created record after all of its fields are prepared. */
6
+ export declare function ownedRecord<Value extends object>(value: Value): Value;
7
+ /** Copies and freezes JSON data without traversing schemas or user functions. */
8
+ export declare function snapshotJsonValue<const Value extends JsonValue>(value: Value): Value;
9
+ /** Copies stored JSON into an invocation-owned mutable input value. */
10
+ export declare function copyJsonValue<const Value extends JsonValue>(value: Value): Value;
11
+ export declare function snapshotValueShape<const Shape extends ValueShape>(shape: Shape): Shape;
12
+ //# sourceMappingURL=owned.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owned.d.ts","sourceRoot":"","sources":["../src/owned.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,KAAK,CAAC,MAAM,SAAS,SAAS,OAAO,EAAE,EAChE,MAAM,EAAE,MAAM,GACb,MAAM,CAER;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAErE;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,EAC7D,KAAK,EAAE,KAAK,GACX,KAAK,CAEP;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,EACzD,KAAK,EAAE,KAAK,GACX,KAAK,CAEP;AAED,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,KAAK,SAAS,UAAU,EAC/D,KAAK,EAAE,KAAK,GACX,KAAK,CAcP"}
package/dist/owned.js ADDED
@@ -0,0 +1,61 @@
1
+ import { VALUE_SHAPE_KIND } from "./values.js";
2
+ /** Copies and freezes an array whose contents are already owned snapshots. */
3
+ export function ownedArray(values) {
4
+ return Object.freeze([...values]);
5
+ }
6
+ /** Freezes one library-created record after all of its fields are prepared. */
7
+ export function ownedRecord(value) {
8
+ return Object.freeze(value);
9
+ }
10
+ /** Copies and freezes JSON data without traversing schemas or user functions. */
11
+ export function snapshotJsonValue(value) {
12
+ return copyJson(value, new Set(), true);
13
+ }
14
+ /** Copies stored JSON into an invocation-owned mutable input value. */
15
+ export function copyJsonValue(value) {
16
+ return copyJson(value, new Set(), false);
17
+ }
18
+ export function snapshotValueShape(shape) {
19
+ if (shape.kind === VALUE_SHAPE_KIND.array) {
20
+ return ownedRecord({
21
+ kind: shape.kind,
22
+ element: snapshotValueShape(shape.element),
23
+ });
24
+ }
25
+ if (shape.kind === VALUE_SHAPE_KIND.stringEnum) {
26
+ return ownedRecord({
27
+ kind: shape.kind,
28
+ values: ownedArray(shape.values),
29
+ });
30
+ }
31
+ return ownedRecord({ kind: shape.kind });
32
+ }
33
+ function copyJson(value, ancestors, freeze) {
34
+ if (value === null || typeof value !== "object") {
35
+ return value;
36
+ }
37
+ if (ancestors.has(value)) {
38
+ throw new TypeError("JSON values must not contain cycles");
39
+ }
40
+ ancestors.add(value);
41
+ try {
42
+ if (Array.isArray(value)) {
43
+ const result = value.map((item) => copyJson(item, ancestors, freeze));
44
+ return freeze ? Object.freeze(result) : result;
45
+ }
46
+ const record = value;
47
+ const result = {};
48
+ for (const key of Object.keys(record)) {
49
+ Object.defineProperty(result, key, {
50
+ configurable: !freeze,
51
+ enumerable: true,
52
+ value: copyJson(record[key], ancestors, freeze),
53
+ writable: !freeze,
54
+ });
55
+ }
56
+ return freeze ? Object.freeze(result) : result;
57
+ }
58
+ finally {
59
+ ancestors.delete(value);
60
+ }
61
+ }
@@ -0,0 +1,41 @@
1
+ import type { z } from "zod";
2
+ import type { ParameterDescription } from "./introspection.js";
3
+ import type { Callable, EndpointsOfNode, EndpointsOfTree, EntryChannelBinding, EntryTreeDefinition, EntryTreeEndpoint, EntryTreeNode, ErasedEntryDefinition, RawValueMap } from "./model.js";
4
+ import type { Channel } from "./values.js";
5
+ export type ContextOf<Handler extends Callable> = number extends Parameters<Handler>["length"] ? never : 2 extends Parameters<Handler>["length"] ? Parameters<Handler>[1] : unknown;
6
+ export type CollectionContext<Handler extends Callable> = [Handler] extends [
7
+ never
8
+ ] ? unknown : (Handler extends Callable ? (context: ContextOf<Handler>) => void : never) extends (context: infer Context) => void ? Context : never;
9
+ export type ContextArgs<Context> = undefined extends Context ? [context?: Context] : [context: Context];
10
+ export type HandlerView<Input, Context, Output> = (input: Input, ...context: ContextArgs<Context>) => Output | PromiseLike<Output>;
11
+ export type InputPlan<Values extends RawValueMap, Input> = {
12
+ readonly schema: z.ZodType<Values>;
13
+ readonly parse: (raw: RawValueMap) => Input;
14
+ readonly project: (values: Values) => Input;
15
+ };
16
+ export type ReadonlyEntryMetadata = Pick<ErasedEntryDefinition, "name" | "parameters" | "output">;
17
+ export type ReadonlyEndpointMetadata = {
18
+ readonly entry: ReadonlyEntryMetadata;
19
+ readonly channels: readonly EntryChannelBinding[];
20
+ };
21
+ export type Registration<Values extends RawValueMap, Input, Context, Output> = {
22
+ readonly endpoint: ReadonlyEndpointMetadata;
23
+ readonly entry: ReadonlyEntryMetadata;
24
+ readonly binding: EntryChannelBinding;
25
+ readonly parameters: readonly ParameterDescription[];
26
+ readonly input: InputPlan<Values, Input>;
27
+ readonly handler: HandlerView<Input, Context, Output>;
28
+ };
29
+ type HandlerOf<Endpoint extends EntryTreeEndpoint> = Endpoint extends EntryTreeEndpoint<ErasedEntryDefinition, infer Handler, readonly EntryChannelBinding[]> ? Handler : never;
30
+ export type ContextFor<Endpoint extends EntryTreeEndpoint> = CollectionContext<HandlerOf<Endpoint>>;
31
+ export type OutputFor<Endpoint extends EntryTreeEndpoint> = Endpoint extends EntryTreeEndpoint<ErasedEntryDefinition, infer Handler, readonly EntryChannelBinding[]> ? Awaited<ReturnType<Handler>> : never;
32
+ export type EndpointForChannel<Endpoint extends EntryTreeEndpoint, ChannelName extends Channel> = Endpoint extends EntryTreeEndpoint<ErasedEntryDefinition, Callable, infer Channels> ? ChannelName extends Channels[number]["channel"] ? Endpoint : never : never;
33
+ export type EntryTreeSource = EntryTreeDefinition | EntryTreeNode;
34
+ export type EndpointsOfSource<Source extends EntryTreeSource> = Source extends EntryTreeDefinition ? EndpointsOfTree<Source> : Source extends EntryTreeNode ? EndpointsOfNode<Source> : never;
35
+ /**
36
+ * The one intentional type-erasure boundary. Runtime collections retain the
37
+ * original registrations; this package, and not a consumer, pays the cast.
38
+ */
39
+ export declare function packRegistrationCollection<Collection>(registrations: readonly unknown[]): Collection;
40
+ export {};
41
+ //# sourceMappingURL=registration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../src/registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,SAAS,CAAC,OAAO,SAAS,QAAQ,IAC5C,MAAM,SAAS,UAAU,CAAC,OAA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AAW,SAAS,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAC7C,QAAQ,GACR,KAAK,GACP,KAAK,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,aAAa,CAAC;AAElE,MAAM,MAAM,iBAAiB,CAAC,MAAM,SAAS,eAAe,IAC1D,MAAM,SAAS,mBAAmB,GAC9B,eAAe,CAAC,MAAM,CAAC,GACvB,MAAM,SAAS,aAAa,GAC1B,eAAe,CAAC,MAAM,CAAC,GACvB,KAAK,CAAC;AAEd;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EACnD,aAAa,EAAE,SAAS,OAAO,EAAE,GAChC,UAAU,CAQZ"}
@@ -0,0 +1,14 @@
1
+ import { ownedArray, ownedRecord } from "./owned.js";
2
+ /**
3
+ * The one intentional type-erasure boundary. Runtime collections retain the
4
+ * original registrations; this package, and not a consumer, pays the cast.
5
+ */
6
+ export function packRegistrationCollection(registrations) {
7
+ const items = ownedArray(registrations);
8
+ return ownedRecord({
9
+ length: items.length,
10
+ forEach(visit) {
11
+ items.forEach(visit);
12
+ },
13
+ });
14
+ }
package/dist/runtime.d.ts CHANGED
@@ -1,47 +1,14 @@
1
- import type { ErasedEntryDefinition, ErasedParameterDefinition, ParameterSet, ParameterValues, RawValueMap } from "./model.js";
2
- import { ENTRY_DECODE_RESULT_KIND, ENTRY_INPUT_TARGET_KIND } from "./values.js";
1
+ import { ENTRY_INPUT_TARGET_KIND } from "./values.js";
3
2
  export type EntryInputTarget = {
4
3
  readonly kind: typeof ENTRY_INPUT_TARGET_KIND.entry;
5
4
  } | {
6
5
  readonly kind: typeof ENTRY_INPUT_TARGET_KIND.parameter;
7
6
  readonly parameterName: string;
8
7
  };
8
+ /** Expected invalid caller input. Unexpected schema/project faults propagate. */
9
9
  export declare class EntryInputError extends Error {
10
10
  readonly issues: readonly string[];
11
11
  readonly target: EntryInputTarget;
12
12
  constructor(issues: readonly string[], target?: EntryInputTarget);
13
13
  }
14
- export type EntryDecodeResult<Projection> = {
15
- readonly kind: typeof ENTRY_DECODE_RESULT_KIND.resolved;
16
- readonly projection: Projection;
17
- } | {
18
- readonly kind: typeof ENTRY_DECODE_RESULT_KIND.invalidInput;
19
- readonly issues: readonly string[];
20
- } | InvalidParameterDecodeResult | {
21
- readonly kind: typeof ENTRY_DECODE_RESULT_KIND.internalError;
22
- readonly error: unknown;
23
- };
24
- type InvalidParameterDecodeResult = {
25
- readonly kind: typeof ENTRY_DECODE_RESULT_KIND.invalidParameter;
26
- readonly parameterName: string;
27
- readonly issues: readonly string[];
28
- };
29
- export type ParameterDecodeResult<Parameters extends ParameterSet> = {
30
- readonly kind: typeof ENTRY_DECODE_RESULT_KIND.resolved;
31
- readonly values: ParameterValues<Parameters>;
32
- } | InvalidParameterDecodeResult;
33
- export type RawValueCoercer = (parameter: ErasedParameterDefinition, rawValue: unknown) => unknown;
34
- export declare function decodeParameterValues<const Parameters extends ParameterSet>(input: {
35
- readonly parameters: Parameters;
36
- readonly parameterNames: readonly string[];
37
- readonly raw: RawValueMap;
38
- readonly coerce?: RawValueCoercer;
39
- }): ParameterDecodeResult<Parameters>;
40
- export declare function decodeEntryInput<const Entry extends ErasedEntryDefinition>(input: {
41
- readonly entry: Entry;
42
- readonly parameterNames: readonly string[];
43
- readonly raw: RawValueMap;
44
- readonly coerce?: RawValueCoercer;
45
- }): EntryDecodeResult<ReturnType<Entry["project"]>>;
46
- export {};
47
14
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EACzB,YAAY,EACZ,eAAe,EACf,WAAW,EACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EAExB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAA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AE,gBAAgB;gBADxB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,GAAE,gBAAqC;CAKzD"}
package/dist/runtime.js CHANGED
@@ -1,9 +1,8 @@
1
- import { CODEC_DECODE_RESULT_KIND } from "@alpacakit/core";
2
- import { findParameter } from "./internal.js";
3
- import { ENTRY_DECODE_RESULT_KIND, ENTRY_INPUT_TARGET_KIND, PARAMETER_REQUIREMENT_KIND, } from "./values.js";
1
+ import { ENTRY_INPUT_TARGET_KIND } from "./values.js";
4
2
  const ENTRY_INPUT_TARGET = {
5
3
  kind: ENTRY_INPUT_TARGET_KIND.entry,
6
4
  };
5
+ /** Expected invalid caller input. Unexpected schema/project faults propagate. */
7
6
  export class EntryInputError extends Error {
8
7
  issues;
9
8
  target;
@@ -14,127 +13,3 @@ export class EntryInputError extends Error {
14
13
  this.name = EntryInputError.name;
15
14
  }
16
15
  }
17
- const PARAMETER_CANDIDATE_KIND = {
18
- omitted: "omitted",
19
- raw: "raw",
20
- default: "default",
21
- invalid: "invalid",
22
- };
23
- export function decodeParameterValues(input) {
24
- const output = new Map();
25
- const boundParameterNames = new Set(input.parameterNames);
26
- for (const parameterName of input.parameterNames) {
27
- const parameter = findParameter(input.parameters, parameterName);
28
- if (parameter === null) {
29
- return invalidParameter(parameterName, [
30
- `Unknown parameter binding: ${parameterName}`,
31
- ]);
32
- }
33
- }
34
- for (const parameter of input.parameters) {
35
- const candidate = resolveParameterCandidate(parameter, boundParameterNames.has(parameter.name)
36
- ? input.raw[parameter.name]
37
- : undefined);
38
- if (candidate.kind === PARAMETER_CANDIDATE_KIND.omitted) {
39
- continue;
40
- }
41
- if (candidate.kind === PARAMETER_CANDIDATE_KIND.invalid) {
42
- return invalidParameter(parameter.name, candidate.issues);
43
- }
44
- let value;
45
- try {
46
- value =
47
- candidate.kind === PARAMETER_CANDIDATE_KIND.raw && input.coerce
48
- ? input.coerce(parameter, candidate.value)
49
- : candidate.value;
50
- }
51
- catch (error) {
52
- return invalidParameter(parameter.name, [errorMessage(error)]);
53
- }
54
- try {
55
- const decoded = parameter.codec.decode(value);
56
- if (decoded.kind === CODEC_DECODE_RESULT_KIND.invalid) {
57
- return invalidParameter(parameter.name, decoded.issues);
58
- }
59
- output.set(parameter.name, decoded.value);
60
- }
61
- catch (error) {
62
- return invalidParameter(parameter.name, [errorMessage(error)]);
63
- }
64
- }
65
- return {
66
- kind: ENTRY_DECODE_RESULT_KIND.resolved,
67
- values: Object.fromEntries(output),
68
- };
69
- }
70
- function resolveParameterCandidate(parameter, rawValue) {
71
- if (rawValue !== undefined) {
72
- return { kind: PARAMETER_CANDIDATE_KIND.raw, value: rawValue };
73
- }
74
- switch (parameter.requirement.kind) {
75
- case PARAMETER_REQUIREMENT_KIND.required:
76
- return {
77
- kind: PARAMETER_CANDIDATE_KIND.invalid,
78
- issues: [`Missing required parameter ${parameter.name}`],
79
- };
80
- case PARAMETER_REQUIREMENT_KIND.optional:
81
- return { kind: PARAMETER_CANDIDATE_KIND.omitted };
82
- case PARAMETER_REQUIREMENT_KIND.optionalWithDefault:
83
- return {
84
- kind: PARAMETER_CANDIDATE_KIND.default,
85
- value: parameter.requirement.defaultValue,
86
- };
87
- }
88
- }
89
- export function decodeEntryInput(input) {
90
- const decoded = decodeParameterValues({
91
- parameters: input.entry.parameters,
92
- parameterNames: input.parameterNames,
93
- raw: input.raw,
94
- ...(input.coerce ? { coerce: input.coerce } : {}),
95
- });
96
- if (decoded.kind === ENTRY_DECODE_RESULT_KIND.invalidParameter) {
97
- return decoded;
98
- }
99
- const project = input.entry.project;
100
- try {
101
- return {
102
- kind: ENTRY_DECODE_RESULT_KIND.resolved,
103
- projection: project({
104
- values: decoded.values,
105
- }),
106
- };
107
- }
108
- catch (error) {
109
- if (error instanceof EntryInputError) {
110
- const target = error.target;
111
- switch (target.kind) {
112
- case ENTRY_INPUT_TARGET_KIND.entry:
113
- return {
114
- kind: ENTRY_DECODE_RESULT_KIND.invalidInput,
115
- issues: error.issues,
116
- };
117
- case ENTRY_INPUT_TARGET_KIND.parameter:
118
- if (!input.entry.parameters.some((parameter) => parameter.name === target.parameterName)) {
119
- return { kind: ENTRY_DECODE_RESULT_KIND.internalError, error };
120
- }
121
- return {
122
- kind: ENTRY_DECODE_RESULT_KIND.invalidParameter,
123
- parameterName: target.parameterName,
124
- issues: error.issues,
125
- };
126
- }
127
- }
128
- return { kind: ENTRY_DECODE_RESULT_KIND.internalError, error };
129
- }
130
- }
131
- function invalidParameter(parameterName, issues) {
132
- return {
133
- kind: ENTRY_DECODE_RESULT_KIND.invalidParameter,
134
- parameterName,
135
- issues,
136
- };
137
- }
138
- function errorMessage(error) {
139
- return error instanceof Error ? error.message : String(error);
140
- }