@krak-stack/registry 0.1.60 → 0.2.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/CHANGELOG.md +15 -0
- package/dist/components/ui/app-brand.js +17 -17
- package/dist/components/ui/code-block.js +6 -6
- package/dist/components/ui/color-picker.d.ts +30 -0
- package/dist/components/ui/color-picker.js +386 -0
- package/dist/components/ui/copy-button.js +4 -4
- package/dist/components/ui/data-table.js +468 -455
- package/dist/components/ui/editing-locale-switcher.js +10 -10
- package/dist/components/ui/effect-form.js +186 -185
- package/dist/components/ui/error-component.js +10 -18
- package/dist/components/ui/file-picker.js +2 -2
- package/dist/components/ui/form.d.ts +131 -335
- package/dist/components/ui/form.js +137 -136
- package/dist/components/ui/google-map.js +38 -6
- package/dist/components/ui/icon-input.js +48 -45
- package/dist/components/ui/krakstack-provider.js +2 -2
- package/dist/components/ui/locale-switcher.js +4 -4
- package/dist/components/ui/pagination.js +2 -2
- package/dist/components/ui/search-menu.js +2 -2
- package/dist/components/ui/sidebar-layout.js +82 -80
- package/dist/components/ui/theme-switcher.js +6 -6
- package/dist/components/ui/virtualized-combobox.js +34 -31
- package/dist/lib/docs.d.ts +2 -2
- package/dist/lib/docs.js +187 -185
- package/dist/lib/docs.server.js +45 -23
- package/dist/lib/documentation-toolkit.d.ts +2 -2
- package/dist/lib/documentation-toolkit.js +45 -23
- package/dist/lib/httpapi-adapter.d.ts +11 -3
- package/dist/lib/httpapi-adapter.js +42 -15
- package/dist/lib/httpapi-cli.d.ts +13 -4
- package/dist/lib/httpapi-cli.js +70 -28
- package/dist/lib/httpapi-toolkit.js +40 -13
- package/dist/lib/query.d.ts +4 -4
- package/dist/lib/query.js +13 -13
- package/dist/lib/seo.js +2 -2
- package/dist/lib/webfetch-toolkit.js +7 -7
- package/dist/oxlint/anti-slop/index.js +2 -2
- package/dist/services/agent/client/index.js +155 -153
- package/dist/services/agent/index.js +3 -3
- package/dist/services/agent/schema.js +5 -5
- package/dist/services/events/browser.js +38 -23
- package/dist/services/events/client/audit-log-table.js +472 -459
- package/dist/services/events/client/tracking-notice.js +9 -4
- package/dist/services/events/index.d.ts +3 -1
- package/dist/services/events/index.js +79 -74
- package/dist/services/events/migrations.js +2 -2
- package/dist/services/events/record.js +2 -2
- package/dist/services/events/schema.d.ts +18 -10
- package/dist/services/events/schema.js +42 -42
- package/dist/services/file-extraction/index.js +4 -4
- package/dist/services/file-extraction/schema.d.ts +3 -1
- package/dist/services/file-extraction/schema.js +2 -2
- package/dist/services/health/api.builder.d.ts +8 -8
- package/dist/services/health/api.group.d.ts +8 -8
- package/dist/services/health/index.d.ts +10 -6
- package/dist/services/health/index.js +17 -13
- package/dist/services/health/schema.d.ts +7 -7
- package/dist/services/notification/channels/ses/index.js +2 -2
- package/dist/services/notification/channels/ses/schema.js +2 -2
- package/dist/services/notification/client/index.js +5 -5
- package/dist/services/notification/index.js +3 -3
- package/dist/services/notification/persistence/drizzle.js +2 -2
- package/dist/services/notification/persistence/index.js +15 -15
- package/dist/services/notification/persistence/schema.js +12 -12
- package/dist/services/notification/public.js +8 -8
- package/dist/services/notification/schema.d.ts +3 -1
- package/dist/services/notification/schema.js +2 -2
- package/dist/services/opentelemetry/api.js +7 -5
- package/dist/services/opentelemetry/browser.js +9 -9
- package/dist/services/opentelemetry/index.js +2 -2
- package/dist/services/opentelemetry/processor.d.ts +3 -1
- package/dist/services/opentelemetry/web-vitals.js +12 -7
- package/dist/services/s3/index.js +2 -2
- package/dist/services/s3/schema.d.ts +3 -1
- package/dist/services/s3/schema.js +2 -2
- package/dist/services/speech/api.js +3 -1
- package/dist/services/speech/index.js +15 -8
- package/dist/services/speech/schema.d.ts +3 -1
- package/dist/services/speech/schema.js +12 -10
- package/dist/services/webhooks/client/delivery-table.d.ts +62 -0
- package/dist/services/webhooks/client/delivery-table.js +4711 -0
- package/dist/services/webhooks/http-client.d.ts +1 -0
- package/dist/services/webhooks/http-client.js +17 -5
- package/dist/services/webhooks/index.d.ts +2 -0
- package/dist/services/webhooks/index.js +249 -114
- package/dist/services/webhooks/migrations.d.ts +3 -0
- package/dist/services/webhooks/migrations.js +21 -2
- package/dist/services/webhooks/receiver.d.ts +45 -0
- package/dist/services/webhooks/schema.d.ts +15 -5
- package/dist/services/webhooks/schema.js +41 -21
- package/dist/services/webhooks/url.d.ts +5 -0
- package/dist/services/webhooks/url.js +18 -2
- package/package.json +10 -1
package/dist/lib/httpapi-cli.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// ../../src/lib/httpapi-cli.ts
|
|
2
|
+
import * as Data2 from "effect/Data";
|
|
2
3
|
import { Console, Effect as Effect2, Option as Option2, Schema as Schema2, Stream } from "effect";
|
|
3
4
|
import { Argument, Command, Flag } from "effect/cli";
|
|
4
5
|
|
|
5
6
|
// ../../src/lib/httpapi-adapter.ts
|
|
7
|
+
import * as Data from "effect/Data";
|
|
6
8
|
import {
|
|
7
9
|
Context,
|
|
8
10
|
Effect,
|
|
@@ -13,6 +15,9 @@ import {
|
|
|
13
15
|
} from "effect";
|
|
14
16
|
import { HttpClient } from "effect/http";
|
|
15
17
|
import { HttpApi, HttpApiClient, OpenApi } from "effect/http-api";
|
|
18
|
+
|
|
19
|
+
class HttpApiAdapterError extends Data.TaggedError("HttpApiAdapterError") {
|
|
20
|
+
}
|
|
16
21
|
var HttpApiMethods = [
|
|
17
22
|
"get",
|
|
18
23
|
"post",
|
|
@@ -49,7 +54,7 @@ var HttpApiOperationResultValue = Schema.suspend(() => Schema.Union([
|
|
|
49
54
|
Schema.Null,
|
|
50
55
|
UndefinedFromNull,
|
|
51
56
|
Schema.String,
|
|
52
|
-
Schema.
|
|
57
|
+
Schema.Finite,
|
|
53
58
|
Schema.Boolean,
|
|
54
59
|
Schema.DateFromString,
|
|
55
60
|
Schema.Uint8ArrayFromBase64,
|
|
@@ -60,9 +65,15 @@ var HttpApiOperationResult = Schema.Union([
|
|
|
60
65
|
HttpApiOperationResultValue,
|
|
61
66
|
Schema.Undefined
|
|
62
67
|
]).annotate({ identifier: "HttpApiOperationResult" });
|
|
63
|
-
var encodeHttpApiOperationResult = Effect.fn("HttpApiAdapter.encodeOperationResult")((result) => Schema.encodeUnknownEffect(HttpApiOperationResult)(result).pipe(Effect.map((encoded) => encoded ?? null), Effect.mapError((cause) => new
|
|
64
|
-
|
|
65
|
-
cause
|
|
68
|
+
var encodeHttpApiOperationResult = Effect.fn("HttpApiAdapter.encodeOperationResult")((result) => Schema.encodeUnknownEffect(HttpApiOperationResult)(result).pipe(Effect.map((encoded) => encoded ?? null), Effect.mapError((cause) => new HttpApiAdapterError({
|
|
69
|
+
message: "HTTP API result is not serializable",
|
|
70
|
+
cause: { cause }.cause
|
|
71
|
+
}))));
|
|
72
|
+
var encodeOperationResult = Effect.fn("HttpApiAdapter.encodeResult")((result, operation) => operation.successSchema ? Schema.encodeUnknownEffect(operation.successSchema)(result).pipe(Effect.flatMap(encodeHttpApiOperationResult), Effect.mapError((cause) => new HttpApiAdapterError({
|
|
73
|
+
message: "HTTP API result does not match its success schema",
|
|
74
|
+
cause: {
|
|
75
|
+
cause
|
|
76
|
+
}.cause
|
|
66
77
|
}))) : encodeHttpApiOperationResult(result));
|
|
67
78
|
var reflectedSchema = (schema) => Schema.make(schema.ast);
|
|
68
79
|
var sanitizeHttpName = (name) => name.replace(/[^a-zA-Z0-9_-]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -70,7 +81,9 @@ var httpApiToolName = (entry) => (entry.operation.operationId || `${entry.method
|
|
|
70
81
|
var makeCatalogue = (api, methods, include) => Effect.try({
|
|
71
82
|
try: () => {
|
|
72
83
|
if (!HttpApi.isHttpApi(api))
|
|
73
|
-
throw new
|
|
84
|
+
throw new HttpApiAdapterError({
|
|
85
|
+
message: "HttpApiAdapter requires a valid HttpApi"
|
|
86
|
+
});
|
|
74
87
|
const spec = OpenApi.fromApi(api);
|
|
75
88
|
const reflected = new Map;
|
|
76
89
|
HttpApi.reflect(api, {
|
|
@@ -80,7 +93,9 @@ var makeCatalogue = (api, methods, include) => Effect.try({
|
|
|
80
93
|
onEndpoint: ({ endpoint, group, successes }) => {
|
|
81
94
|
const operationId = Context.getOrElse(endpoint.annotations, OpenApi.Identifier, () => group.topLevel ? endpoint.identifier : `${group.identifier}.${endpoint.identifier}`);
|
|
82
95
|
if (reflected.has(operationId))
|
|
83
|
-
throw new
|
|
96
|
+
throw new HttpApiAdapterError({
|
|
97
|
+
message: `Duplicate HTTP API operation ID: ${operationId}`
|
|
98
|
+
});
|
|
84
99
|
const fields = {};
|
|
85
100
|
if (endpoint.params)
|
|
86
101
|
fields.params = Schema.toType(reflectedSchema(endpoint.params));
|
|
@@ -119,10 +134,14 @@ var makeCatalogue = (api, methods, include) => Effect.try({
|
|
|
119
134
|
continue;
|
|
120
135
|
const metadata = entry.operation.operationId ? reflected.get(entry.operation.operationId) : undefined;
|
|
121
136
|
if (!metadata)
|
|
122
|
-
throw new
|
|
137
|
+
throw new HttpApiAdapterError({
|
|
138
|
+
message: `Missing endpoint schema for ${entry.operation.operationId}`
|
|
139
|
+
});
|
|
123
140
|
const name = httpApiToolName(entry);
|
|
124
141
|
if (!name || names.has(name))
|
|
125
|
-
throw new
|
|
142
|
+
throw new HttpApiAdapterError({
|
|
143
|
+
message: `Duplicate or empty HTTP API tool name: ${name}`
|
|
144
|
+
});
|
|
126
145
|
names.add(name);
|
|
127
146
|
const document = Schema.toJsonSchemaDocument(metadata.inputSchema.annotate({ identifier: undefined }));
|
|
128
147
|
operations.push({
|
|
@@ -141,7 +160,10 @@ var makeCatalogue = (api, methods, include) => Effect.try({
|
|
|
141
160
|
}
|
|
142
161
|
return { info: spec.info, operations };
|
|
143
162
|
},
|
|
144
|
-
catch: (cause) => new
|
|
163
|
+
catch: (cause) => new HttpApiAdapterError({
|
|
164
|
+
message: "Failed to build HTTP API adapter catalogue",
|
|
165
|
+
cause: { cause }.cause
|
|
166
|
+
})
|
|
145
167
|
});
|
|
146
168
|
var GeneratedOperation = Schema.declare((value) => value instanceof Function).annotate({ identifier: "GeneratedOperation" });
|
|
147
169
|
var GeneratedOperationEffect = Schema.declare((value) => Effect.isEffect(value)).annotate({ identifier: "GeneratedOperationEffect" });
|
|
@@ -150,15 +172,19 @@ var executeGeneratedOperation = Effect.fn("HttpApiAdapter.executeGeneratedOperat
|
|
|
150
172
|
const candidate = Object.entries(Object(group)).find(([name]) => name === operation.endpointIdentifier)?.[1];
|
|
151
173
|
const endpoint = Schema.decodeUnknownOption(GeneratedOperation)(candidate);
|
|
152
174
|
if (Option.isNone(endpoint))
|
|
153
|
-
return yield*
|
|
154
|
-
|
|
175
|
+
return yield* new HttpApiAdapterError({
|
|
176
|
+
message: `No generated API client operation for ${operation.operation.operationId}`
|
|
177
|
+
});
|
|
178
|
+
const result = Schema.decodeOption(GeneratedOperationEffect)(endpoint.value({
|
|
155
179
|
headers: input.headers ?? {},
|
|
156
180
|
params: input.params ?? {},
|
|
157
181
|
query: input.query ?? {},
|
|
158
182
|
payload: input.body
|
|
159
183
|
}));
|
|
160
184
|
if (Option.isNone(result))
|
|
161
|
-
return yield*
|
|
185
|
+
return yield* new HttpApiAdapterError({
|
|
186
|
+
message: `Generated API client operation ${operation.operation.operationId} is invalid`
|
|
187
|
+
});
|
|
162
188
|
return yield* result.value;
|
|
163
189
|
});
|
|
164
190
|
|
|
@@ -176,7 +202,9 @@ class HttpApiAdapter extends Context.Service()("@krak-stack/registry/HttpApiAdap
|
|
|
176
202
|
execute: Effect.fn("HttpApiAdapter.execute")(function* (options) {
|
|
177
203
|
const operation = catalogue.operations.find((entry) => entry.method === options.operation.method && entry.path === options.operation.path && entry.operation.operationId === options.operation.operation.operationId);
|
|
178
204
|
if (!operation) {
|
|
179
|
-
return yield*
|
|
205
|
+
return yield* new HttpApiAdapterError({
|
|
206
|
+
message: "Operation is not in this HTTP API adapter catalogue"
|
|
207
|
+
});
|
|
180
208
|
}
|
|
181
209
|
return yield* executeGeneratedOperation(client, {
|
|
182
210
|
operation,
|
|
@@ -189,6 +217,8 @@ class HttpApiAdapter extends Context.Service()("@krak-stack/registry/HttpApiAdap
|
|
|
189
217
|
}
|
|
190
218
|
|
|
191
219
|
// ../../src/lib/httpapi-cli.ts
|
|
220
|
+
class HttpApiCliError extends Data2.TaggedError("HttpApiCliError") {
|
|
221
|
+
}
|
|
192
222
|
var CliJsonSchema = Schema2.Struct({
|
|
193
223
|
type: Schema2.optional(Schema2.Union([Schema2.String, Schema2.Array(Schema2.String)])),
|
|
194
224
|
description: Schema2.optional(Schema2.String),
|
|
@@ -236,7 +266,9 @@ var httpApiCliOperationGroups = (operations) => {
|
|
|
236
266
|
const group = groups.get(operation.groupName);
|
|
237
267
|
if (group) {
|
|
238
268
|
if (group.operations.some((entry) => entry.name === operation.name)) {
|
|
239
|
-
throw new
|
|
269
|
+
throw new HttpApiCliError({
|
|
270
|
+
message: `Duplicate CLI command ${operation.groupName} ${operation.name}`
|
|
271
|
+
});
|
|
240
272
|
}
|
|
241
273
|
group.operations.push(operation);
|
|
242
274
|
} else {
|
|
@@ -274,7 +306,7 @@ var schemaType = (schema) => {
|
|
|
274
306
|
return schemaType(effectiveSchema(schema));
|
|
275
307
|
};
|
|
276
308
|
var schemaEnum = (schema) => Schema2.decodeUnknownOption(Schema2.Array(Schema2.String))(effectiveSchema(schema).enum).pipe(Option2.getOrElse(() => []));
|
|
277
|
-
var jsonFlag = (name) => Flag.String(name).pipe(Flag.mapTryCatch((value) => Schema2.
|
|
309
|
+
var jsonFlag = (name) => Flag.String(name).pipe(Flag.mapTryCatch((value) => Schema2.decodeSync(JsonFromString)(value), () => `--${name} must be valid JSON`));
|
|
278
310
|
var primitiveFlag = (name, schema, required) => {
|
|
279
311
|
const type = schemaType(schema);
|
|
280
312
|
const choices = schemaEnum(schema);
|
|
@@ -370,7 +402,9 @@ var operationInputs = (operation) => {
|
|
|
370
402
|
return drafts.map((draft, index) => {
|
|
371
403
|
const optionName = draft.location === "params" || preferredCounts.get(draft.preferredName) === 1 ? draft.preferredName : `${draft.location.replace(/s$/, "")}-${draft.preferredName}`;
|
|
372
404
|
if (draft.location !== "params" && optionNames.has(optionName)) {
|
|
373
|
-
throw new
|
|
405
|
+
throw new HttpApiCliError({
|
|
406
|
+
message: `Duplicate CLI option --${optionName} for ${operation.groupName} ${operation.name}`
|
|
407
|
+
});
|
|
374
408
|
}
|
|
375
409
|
optionNames.add(optionName);
|
|
376
410
|
return {
|
|
@@ -386,7 +420,10 @@ var HttpApiCliResultStream = Schema2.declare((value) => Stream.isStream(value)).
|
|
|
386
420
|
var printHttpApiCliResult = Effect2.fn("HttpApiCli.printResult")(function* (response, operation, client) {
|
|
387
421
|
const stream = Schema2.decodeUnknownOption(HttpApiCliResultStream)(response);
|
|
388
422
|
if (stream._tag === "Some") {
|
|
389
|
-
return yield* stream.value.pipe(Stream.
|
|
423
|
+
return yield* stream.value.pipe(Stream.mapError((cause) => new HttpApiCliError({
|
|
424
|
+
message: cause instanceof Error ? cause.message : "HTTP API result stream failed",
|
|
425
|
+
cause
|
|
426
|
+
})), Stream.mapEffect((event) => client.encodeResult(event, operation)), Stream.runForEach((event) => print(JSON.stringify(event))));
|
|
390
427
|
}
|
|
391
428
|
const encoded = yield* client.encodeResult(response, operation);
|
|
392
429
|
return yield* print(JSON.stringify(encoded, null, 2) ?? "null");
|
|
@@ -399,27 +436,29 @@ var callOperation = Effect2.fn("HttpApiCli.callOperation")(function* (operation,
|
|
|
399
436
|
params: emptyValues(),
|
|
400
437
|
query: emptyValues()
|
|
401
438
|
};
|
|
402
|
-
for (const
|
|
403
|
-
const parsed = callConfig[
|
|
439
|
+
for (const input2 of inputs) {
|
|
440
|
+
const parsed = callConfig[input2.configKey];
|
|
404
441
|
const value = Option2.isOption(parsed) ? Option2.getOrUndefined(parsed) : parsed;
|
|
405
442
|
if (value !== undefined) {
|
|
406
|
-
assembled[
|
|
443
|
+
assembled[input2.location][input2.name] = value;
|
|
407
444
|
}
|
|
408
445
|
}
|
|
409
|
-
const bodyInput = inputs.some((
|
|
446
|
+
const bodyInput = inputs.some((input2) => input2.location === "body" && input2.name === "body") ? assembled.body.body : Object.keys(assembled.body).length > 0 || cliJsonSchema(operation.inputJsonSchema).required?.includes("body") ? assembled.body : undefined;
|
|
410
447
|
const rawInput = {};
|
|
411
|
-
if (inputs.some((
|
|
448
|
+
if (inputs.some((input2) => input2.location === "params")) {
|
|
412
449
|
rawInput.params = assembled.params;
|
|
413
450
|
}
|
|
414
|
-
if (inputs.some((
|
|
451
|
+
if (inputs.some((input2) => input2.location === "headers")) {
|
|
415
452
|
rawInput.headers = assembled.headers;
|
|
416
453
|
}
|
|
417
|
-
if (inputs.some((
|
|
454
|
+
if (inputs.some((input2) => input2.location === "query")) {
|
|
418
455
|
rawInput.query = assembled.query;
|
|
419
456
|
}
|
|
420
457
|
if (bodyInput !== undefined)
|
|
421
458
|
rawInput.body = bodyInput;
|
|
422
|
-
const input = yield* Schema2.
|
|
459
|
+
const input = yield* Schema2.decodeEffect(operation.inputSchema)(rawInput).pipe(Effect2.mapError((error) => new HttpApiCliError({
|
|
460
|
+
message: `Invalid input for ${operation.groupName} ${operation.name}: ${error.message}`
|
|
461
|
+
})));
|
|
423
462
|
const response = yield* client.execute({ operation, input });
|
|
424
463
|
return yield* printHttpApiCliResult(response, operation, client);
|
|
425
464
|
});
|
|
@@ -439,7 +478,7 @@ var operationCommand = (operation, client) => Effect2.sync(() => {
|
|
|
439
478
|
}
|
|
440
479
|
]));
|
|
441
480
|
});
|
|
442
|
-
var groupCommand = (group, client) => Effect2.
|
|
481
|
+
var groupCommand = (group, client) => Effect2.forEach(group.operations, (operation) => operationCommand(operation, client)).pipe(Effect2.map((operationCommands) => Command.make(group.name).pipe(Command.withDescription(group.title), Command.withSubcommands([
|
|
443
482
|
groupListCommand(group),
|
|
444
483
|
...operationCommands
|
|
445
484
|
]))));
|
|
@@ -449,9 +488,12 @@ var makeHttpApiCliCommand = Effect2.fn("HttpApiCli.makeCommand")(function* () {
|
|
|
449
488
|
const name = fallbackName(spec.info.title, "api");
|
|
450
489
|
const groups = yield* Effect2.try({
|
|
451
490
|
try: () => httpApiCliOperationGroups(spec.operations.map(toCliOperation)),
|
|
452
|
-
catch: (error) =>
|
|
491
|
+
catch: (error) => new HttpApiCliError({
|
|
492
|
+
message: error instanceof Error ? error.message : String(error),
|
|
493
|
+
cause: error
|
|
494
|
+
})
|
|
453
495
|
});
|
|
454
|
-
const groupCommands = yield* Effect2.
|
|
496
|
+
const groupCommands = yield* Effect2.forEach(groups, (group) => groupCommand(group, client));
|
|
455
497
|
return Command.make(name).pipe(Command.withDescription(spec.info.description ?? spec.info.title), Command.withSubcommands([listCommand(groups), ...groupCommands]));
|
|
456
498
|
});
|
|
457
499
|
export {
|
|
@@ -3,6 +3,7 @@ import { Effect as Effect2, Schema as Schema2 } from "effect";
|
|
|
3
3
|
import { Tool, Toolkit } from "effect/ai";
|
|
4
4
|
|
|
5
5
|
// ../../src/lib/httpapi-adapter.ts
|
|
6
|
+
import * as Data from "effect/Data";
|
|
6
7
|
import {
|
|
7
8
|
Context,
|
|
8
9
|
Effect,
|
|
@@ -13,6 +14,9 @@ import {
|
|
|
13
14
|
} from "effect";
|
|
14
15
|
import { HttpClient } from "effect/http";
|
|
15
16
|
import { HttpApi, HttpApiClient, OpenApi } from "effect/http-api";
|
|
17
|
+
|
|
18
|
+
class HttpApiAdapterError extends Data.TaggedError("HttpApiAdapterError") {
|
|
19
|
+
}
|
|
16
20
|
var HttpApiMethods = [
|
|
17
21
|
"get",
|
|
18
22
|
"post",
|
|
@@ -49,7 +53,7 @@ var HttpApiOperationResultValue = Schema.suspend(() => Schema.Union([
|
|
|
49
53
|
Schema.Null,
|
|
50
54
|
UndefinedFromNull,
|
|
51
55
|
Schema.String,
|
|
52
|
-
Schema.
|
|
56
|
+
Schema.Finite,
|
|
53
57
|
Schema.Boolean,
|
|
54
58
|
Schema.DateFromString,
|
|
55
59
|
Schema.Uint8ArrayFromBase64,
|
|
@@ -60,9 +64,15 @@ var HttpApiOperationResult = Schema.Union([
|
|
|
60
64
|
HttpApiOperationResultValue,
|
|
61
65
|
Schema.Undefined
|
|
62
66
|
]).annotate({ identifier: "HttpApiOperationResult" });
|
|
63
|
-
var encodeHttpApiOperationResult = Effect.fn("HttpApiAdapter.encodeOperationResult")((result) => Schema.encodeUnknownEffect(HttpApiOperationResult)(result).pipe(Effect.map((encoded) => encoded ?? null), Effect.mapError((cause) => new
|
|
64
|
-
|
|
65
|
-
cause
|
|
67
|
+
var encodeHttpApiOperationResult = Effect.fn("HttpApiAdapter.encodeOperationResult")((result) => Schema.encodeUnknownEffect(HttpApiOperationResult)(result).pipe(Effect.map((encoded) => encoded ?? null), Effect.mapError((cause) => new HttpApiAdapterError({
|
|
68
|
+
message: "HTTP API result is not serializable",
|
|
69
|
+
cause: { cause }.cause
|
|
70
|
+
}))));
|
|
71
|
+
var encodeOperationResult = Effect.fn("HttpApiAdapter.encodeResult")((result, operation) => operation.successSchema ? Schema.encodeUnknownEffect(operation.successSchema)(result).pipe(Effect.flatMap(encodeHttpApiOperationResult), Effect.mapError((cause) => new HttpApiAdapterError({
|
|
72
|
+
message: "HTTP API result does not match its success schema",
|
|
73
|
+
cause: {
|
|
74
|
+
cause
|
|
75
|
+
}.cause
|
|
66
76
|
}))) : encodeHttpApiOperationResult(result));
|
|
67
77
|
var reflectedSchema = (schema) => Schema.make(schema.ast);
|
|
68
78
|
var sanitizeHttpName = (name) => name.replace(/[^a-zA-Z0-9_-]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -70,7 +80,9 @@ var httpApiToolName = (entry) => (entry.operation.operationId || `${entry.method
|
|
|
70
80
|
var makeCatalogue = (api, methods, include) => Effect.try({
|
|
71
81
|
try: () => {
|
|
72
82
|
if (!HttpApi.isHttpApi(api))
|
|
73
|
-
throw new
|
|
83
|
+
throw new HttpApiAdapterError({
|
|
84
|
+
message: "HttpApiAdapter requires a valid HttpApi"
|
|
85
|
+
});
|
|
74
86
|
const spec = OpenApi.fromApi(api);
|
|
75
87
|
const reflected = new Map;
|
|
76
88
|
HttpApi.reflect(api, {
|
|
@@ -80,7 +92,9 @@ var makeCatalogue = (api, methods, include) => Effect.try({
|
|
|
80
92
|
onEndpoint: ({ endpoint, group, successes }) => {
|
|
81
93
|
const operationId = Context.getOrElse(endpoint.annotations, OpenApi.Identifier, () => group.topLevel ? endpoint.identifier : `${group.identifier}.${endpoint.identifier}`);
|
|
82
94
|
if (reflected.has(operationId))
|
|
83
|
-
throw new
|
|
95
|
+
throw new HttpApiAdapterError({
|
|
96
|
+
message: `Duplicate HTTP API operation ID: ${operationId}`
|
|
97
|
+
});
|
|
84
98
|
const fields = {};
|
|
85
99
|
if (endpoint.params)
|
|
86
100
|
fields.params = Schema.toType(reflectedSchema(endpoint.params));
|
|
@@ -119,10 +133,14 @@ var makeCatalogue = (api, methods, include) => Effect.try({
|
|
|
119
133
|
continue;
|
|
120
134
|
const metadata = entry.operation.operationId ? reflected.get(entry.operation.operationId) : undefined;
|
|
121
135
|
if (!metadata)
|
|
122
|
-
throw new
|
|
136
|
+
throw new HttpApiAdapterError({
|
|
137
|
+
message: `Missing endpoint schema for ${entry.operation.operationId}`
|
|
138
|
+
});
|
|
123
139
|
const name = httpApiToolName(entry);
|
|
124
140
|
if (!name || names.has(name))
|
|
125
|
-
throw new
|
|
141
|
+
throw new HttpApiAdapterError({
|
|
142
|
+
message: `Duplicate or empty HTTP API tool name: ${name}`
|
|
143
|
+
});
|
|
126
144
|
names.add(name);
|
|
127
145
|
const document = Schema.toJsonSchemaDocument(metadata.inputSchema.annotate({ identifier: undefined }));
|
|
128
146
|
operations.push({
|
|
@@ -141,7 +159,10 @@ var makeCatalogue = (api, methods, include) => Effect.try({
|
|
|
141
159
|
}
|
|
142
160
|
return { info: spec.info, operations };
|
|
143
161
|
},
|
|
144
|
-
catch: (cause) => new
|
|
162
|
+
catch: (cause) => new HttpApiAdapterError({
|
|
163
|
+
message: "Failed to build HTTP API adapter catalogue",
|
|
164
|
+
cause: { cause }.cause
|
|
165
|
+
})
|
|
145
166
|
});
|
|
146
167
|
var GeneratedOperation = Schema.declare((value) => value instanceof Function).annotate({ identifier: "GeneratedOperation" });
|
|
147
168
|
var GeneratedOperationEffect = Schema.declare((value) => Effect.isEffect(value)).annotate({ identifier: "GeneratedOperationEffect" });
|
|
@@ -150,15 +171,19 @@ var executeGeneratedOperation = Effect.fn("HttpApiAdapter.executeGeneratedOperat
|
|
|
150
171
|
const candidate = Object.entries(Object(group)).find(([name]) => name === operation.endpointIdentifier)?.[1];
|
|
151
172
|
const endpoint = Schema.decodeUnknownOption(GeneratedOperation)(candidate);
|
|
152
173
|
if (Option.isNone(endpoint))
|
|
153
|
-
return yield*
|
|
154
|
-
|
|
174
|
+
return yield* new HttpApiAdapterError({
|
|
175
|
+
message: `No generated API client operation for ${operation.operation.operationId}`
|
|
176
|
+
});
|
|
177
|
+
const result = Schema.decodeOption(GeneratedOperationEffect)(endpoint.value({
|
|
155
178
|
headers: input.headers ?? {},
|
|
156
179
|
params: input.params ?? {},
|
|
157
180
|
query: input.query ?? {},
|
|
158
181
|
payload: input.body
|
|
159
182
|
}));
|
|
160
183
|
if (Option.isNone(result))
|
|
161
|
-
return yield*
|
|
184
|
+
return yield* new HttpApiAdapterError({
|
|
185
|
+
message: `Generated API client operation ${operation.operation.operationId} is invalid`
|
|
186
|
+
});
|
|
162
187
|
return yield* result.value;
|
|
163
188
|
});
|
|
164
189
|
|
|
@@ -176,7 +201,9 @@ class HttpApiAdapter extends Context.Service()("@krak-stack/registry/HttpApiAdap
|
|
|
176
201
|
execute: Effect.fn("HttpApiAdapter.execute")(function* (options) {
|
|
177
202
|
const operation = catalogue.operations.find((entry) => entry.method === options.operation.method && entry.path === options.operation.path && entry.operation.operationId === options.operation.operation.operationId);
|
|
178
203
|
if (!operation) {
|
|
179
|
-
return yield*
|
|
204
|
+
return yield* new HttpApiAdapterError({
|
|
205
|
+
message: "Operation is not in this HTTP API adapter catalogue"
|
|
206
|
+
});
|
|
180
207
|
}
|
|
181
208
|
return yield* executeGeneratedOperation(client, {
|
|
182
209
|
operation,
|
package/dist/lib/query.d.ts
CHANGED
|
@@ -103,8 +103,8 @@ export declare const ColumnFilters: Schema.declare<readonly ({
|
|
|
103
103
|
readonly values: readonly [string, ...string[]];
|
|
104
104
|
})[]>;
|
|
105
105
|
export declare const Query: Schema.Struct<{
|
|
106
|
-
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
107
|
-
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
106
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
107
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
108
108
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
109
109
|
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
110
110
|
readonly id: string;
|
|
@@ -228,8 +228,8 @@ export declare const QueryStandard: import("effect/StandardSchema").StandardSche
|
|
|
228
228
|
readonly values: readonly [string, ...string[]];
|
|
229
229
|
})[] | undefined;
|
|
230
230
|
}> & Schema.Struct<{
|
|
231
|
-
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
232
|
-
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
231
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
232
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
233
233
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
234
234
|
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
235
235
|
readonly id: string;
|
package/dist/lib/query.js
CHANGED
|
@@ -125,11 +125,11 @@ var ColumnFilters = Schema.declare(Schema.is(ColumnFiltersArray), {
|
|
|
125
125
|
toCodecStringTree: () => Schema.link()(Schema.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
126
126
|
});
|
|
127
127
|
var Query = Schema.Struct({
|
|
128
|
-
page: Schema.optional(Schema.Union([Schema.
|
|
128
|
+
page: Schema.optional(Schema.Union([Schema.Finite, Schema.FiniteFromString]).check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), {
|
|
129
129
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
130
130
|
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
131
131
|
})),
|
|
132
|
-
pageSize: Schema.optional(Schema.Union([Schema.
|
|
132
|
+
pageSize: Schema.optional(Schema.Union([Schema.Finite, Schema.FiniteFromString]).check(Schema.isInt(), Schema.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })), {
|
|
133
133
|
decode: SchemaGetter.withDefault(Effect.succeed(20)),
|
|
134
134
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
|
|
135
135
|
})),
|
|
@@ -169,16 +169,16 @@ var PaginatedResponse = (items) => Schema.Struct({
|
|
|
169
169
|
meta: PaginationMeta
|
|
170
170
|
});
|
|
171
171
|
export {
|
|
172
|
-
|
|
173
|
-
ColumnFilters,
|
|
174
|
-
PaginatedResponse,
|
|
175
|
-
PaginationMeta,
|
|
176
|
-
Query,
|
|
177
|
-
QueryStandard,
|
|
178
|
-
SortDirection,
|
|
179
|
-
SortParam,
|
|
180
|
-
SortParamFromString,
|
|
181
|
-
SortParams,
|
|
172
|
+
TextFilterOperator,
|
|
182
173
|
SortParamsFromString,
|
|
183
|
-
|
|
174
|
+
SortParams,
|
|
175
|
+
SortParamFromString,
|
|
176
|
+
SortParam,
|
|
177
|
+
SortDirection,
|
|
178
|
+
QueryStandard,
|
|
179
|
+
Query,
|
|
180
|
+
PaginationMeta,
|
|
181
|
+
PaginatedResponse,
|
|
182
|
+
ColumnFilters,
|
|
183
|
+
ColumnFilter
|
|
184
184
|
};
|
package/dist/lib/seo.js
CHANGED
|
@@ -163,7 +163,7 @@ var SupportedMediaType = Schema2.Literals([
|
|
|
163
163
|
"text/xml"
|
|
164
164
|
]).annotate({ identifier: "WebFetchSupportedMediaType" });
|
|
165
165
|
var decodeMediaType = Schema2.decodeUnknownOption(SupportedMediaType);
|
|
166
|
-
var decodeContentLength = Schema2.decodeUnknownOption(Schema2.
|
|
166
|
+
var decodeContentLength = Schema2.decodeUnknownOption(Schema2.FiniteFromString.check(Schema2.isGreaterThanOrEqualTo(0)));
|
|
167
167
|
var WebFetchRequest = Schema2.Struct({
|
|
168
168
|
url: WebFetchUrl
|
|
169
169
|
}).annotate({
|
|
@@ -266,11 +266,11 @@ var WebFetchToolkitLayer = (options = {}) => WebFetchToolkit.toLayer(Effect2.gen
|
|
|
266
266
|
});
|
|
267
267
|
}));
|
|
268
268
|
export {
|
|
269
|
-
|
|
270
|
-
WebFetchRequest,
|
|
271
|
-
WebFetchResponse,
|
|
272
|
-
WebFetchToolkit,
|
|
273
|
-
WebFetchToolkitLayer,
|
|
269
|
+
defaultWebFetchToolkitOptions,
|
|
274
270
|
WebFetchToolkitOptions,
|
|
275
|
-
|
|
271
|
+
WebFetchToolkitLayer,
|
|
272
|
+
WebFetchToolkit,
|
|
273
|
+
WebFetchResponse,
|
|
274
|
+
WebFetchRequest,
|
|
275
|
+
WebFetchFailure
|
|
276
276
|
};
|
|
@@ -349,8 +349,8 @@ function classifyWideningTarget(type, environment) {
|
|
|
349
349
|
if (alias === undefined)
|
|
350
350
|
return null;
|
|
351
351
|
if ((alias.typeParameters?.params.length ?? 0) > 0) {
|
|
352
|
-
const
|
|
353
|
-
return
|
|
352
|
+
const substitutions2 = aliasSubstitution(alias, unwrapped, new Map);
|
|
353
|
+
return substitutions2 !== null && resolvesToDictionary(alias.typeAnnotation, environment, substitutions2, new Set([name])) ? { kind: "generic container" } : null;
|
|
354
354
|
}
|
|
355
355
|
const substitutions = aliasSubstitution(alias, unwrapped, new Map);
|
|
356
356
|
if (substitutions === null)
|