@krak-stack/registry 0.1.13 → 0.1.15

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 (44) hide show
  1. package/README.md +19 -0
  2. package/dist/components/ui/app-brand.d.ts +18 -13
  3. package/dist/components/ui/app-brand.js +48 -15
  4. package/dist/components/ui/code-block.js +10 -6
  5. package/dist/components/ui/copy-button.d.ts +1 -1
  6. package/dist/components/ui/copy-button.js +1 -1
  7. package/dist/components/ui/data-table.d.ts +1 -1
  8. package/dist/components/ui/data-table.js +21 -20
  9. package/dist/components/ui/effect-form.js +7 -6
  10. package/dist/components/ui/file-picker.js +2 -1
  11. package/dist/components/ui/form.js +17 -15
  12. package/dist/components/ui/google-map.d.ts +6 -10
  13. package/dist/components/ui/google-map.js +19 -14
  14. package/dist/components/ui/locale-switcher.js +7 -1
  15. package/dist/components/ui/sidebar-layout.js +19 -21
  16. package/dist/components/ui/theme-switcher.js +1 -1
  17. package/dist/lib/docs-core.js +165 -109
  18. package/dist/lib/documentation-toolkit.d.ts +1 -1
  19. package/dist/lib/documentation-toolkit.js +41 -40
  20. package/dist/lib/httpapi-cli.d.ts +6 -6
  21. package/dist/lib/httpapi-cli.js +83 -48
  22. package/dist/lib/httpapi-client.d.ts +11 -2
  23. package/dist/lib/httpapi-client.js +29 -9
  24. package/dist/lib/httpapi-helpers.d.ts +15 -21
  25. package/dist/lib/httpapi-helpers.js +38 -26
  26. package/dist/lib/httpapi-mcp.js +81 -50
  27. package/dist/lib/httpapi-toolkit.d.ts +3 -2
  28. package/dist/lib/httpapi-toolkit.js +101 -65
  29. package/dist/lib/seo.js +29 -17
  30. package/dist/oxlint/anti-slop/index.js +1592 -0
  31. package/dist/services/agent/client/atom.d.ts +7 -7
  32. package/dist/services/agent/client/index.js +100 -62
  33. package/dist/services/agent/index.d.ts +71 -71
  34. package/dist/services/agent/index.js +38 -19
  35. package/dist/services/notification/channels/index.d.ts +11 -9
  36. package/dist/services/notification/channels/ses/index.d.ts +6 -6
  37. package/dist/services/notification/channels/ses/index.js +15 -11
  38. package/dist/services/notification/client/index.js +3 -2
  39. package/dist/services/notification/client/notification-menu.d.ts +9 -9
  40. package/dist/services/notification/index.d.ts +7 -6
  41. package/dist/services/notification/public.js +3 -2
  42. package/dist/services/s3/index.d.ts +2 -16
  43. package/dist/services/s3/index.js +12 -9
  44. package/package.json +7 -1
@@ -1,18 +1,34 @@
1
1
  // ../../src/lib/httpapi-toolkit.ts
2
- import { Effect as Effect3, Layer as Layer3, Schema as Schema2 } from "effect";
2
+ import { Effect as Effect3, Layer as Layer3, Option as Option2, Schema as Schema3 } from "effect";
3
3
  import { Tool, Toolkit } from "effect/unstable/ai";
4
4
 
5
5
  // ../../src/lib/httpapi-client.ts
6
- import { Context, Effect, Layer } from "effect";
6
+ import { Context, Effect, Layer, Schema } from "effect";
7
7
  import { HttpClient } from "effect/unstable/http";
8
8
  import {
9
9
  HttpApiClient as EffectHttpApiClient
10
10
  } from "effect/unstable/httpapi";
11
+ var HttpApiOperationResultValue = Schema.suspend(() => Schema.Union([
12
+ Schema.Null,
13
+ Schema.String,
14
+ Schema.Number,
15
+ Schema.Boolean,
16
+ Schema.DateFromString,
17
+ Schema.Uint8ArrayFromBase64,
18
+ Schema.Array(HttpApiOperationResultValue),
19
+ Schema.Record(Schema.String, HttpApiOperationResultValue)
20
+ ]));
21
+ var HttpApiOperationResult = Schema.Union([
22
+ HttpApiOperationResultValue,
23
+ Schema.Undefined
24
+ ]).annotate({ identifier: "HttpApiOperationResult" });
25
+ var encodeHttpApiOperationResult = Effect.fn("HttpApiClient.encodeOperationResult")((result) => Schema.encodeUnknownEffect(HttpApiOperationResult)(result).pipe(Effect.map((encoded) => encoded ?? null), Effect.mapError((cause) => new Error("HTTP API result is not serializable", { cause }))));
26
+ var GeneratedOperation = Schema.declare((value) => value instanceof Function).annotate({ identifier: "GeneratedOperation" });
27
+ var GeneratedOperationEffect = Schema.declare((value) => Effect.isEffect(value)).annotate({ identifier: "GeneratedOperationEffect" });
11
28
  var makeGeneratedClient = (api, http, baseUrl) => EffectHttpApiClient.makeWith(api, {
12
29
  baseUrl,
13
30
  httpClient: http
14
31
  });
15
- var isClientEffect = (value) => Effect.isEffect(value);
16
32
  var executeGeneratedOperation = Effect.fn("HttpApiClient.executeGeneratedOperation")(function* (client, { input, operation: entry }) {
17
33
  const operationId = entry.operation.operationId;
18
34
  if (!operationId) {
@@ -20,22 +36,23 @@ var executeGeneratedOperation = Effect.fn("HttpApiClient.executeGeneratedOperati
20
36
  }
21
37
  const target = Object(client);
22
38
  const groupName = Object.keys(target).filter((name) => operationId.startsWith(`${name}.`)).sort((a, b) => b.length - a.length)[0];
23
- const group = groupName ? Reflect.get(target, groupName) : target;
39
+ const group = groupName ? Object.entries(target).find(([name]) => name === groupName)?.[1] : target;
24
40
  const endpointName = groupName ? operationId.slice(groupName.length + 1) : operationId;
25
- const endpoint = Reflect.get(Object(group), endpointName);
26
- if (typeof endpoint !== "function") {
41
+ const endpointCandidate = group instanceof Function ? undefined : Object.entries(Object(group)).find(([name]) => name === endpointName)?.[1];
42
+ const endpoint = Schema.decodeUnknownOption(GeneratedOperation)(endpointCandidate);
43
+ if (endpoint._tag === "None") {
27
44
  return yield* Effect.fail(new Error(`No generated API client operation for ${operationId}`));
28
45
  }
29
- const result = endpoint({
46
+ const result = Schema.decodeUnknownOption(GeneratedOperationEffect)(endpoint.value({
30
47
  headers: input.headers,
31
48
  params: input.params,
32
49
  query: input.query,
33
50
  payload: input.body
34
- });
35
- if (!isClientEffect(result)) {
51
+ }));
52
+ if (result._tag === "None") {
36
53
  return yield* Effect.fail(new Error(`Generated API client operation ${operationId} is invalid`));
37
54
  }
38
- return yield* result;
55
+ return yield* result.value;
39
56
  });
40
57
 
41
58
  class ApiClient extends Context.Service()("ApiClient") {
@@ -43,6 +60,7 @@ class ApiClient extends Context.Service()("ApiClient") {
43
60
  const http = yield* HttpClient.HttpClient;
44
61
  const client = yield* makeGeneratedClient(config.api, http, config.baseUrl);
45
62
  return {
63
+ encodeResult: config.encodeResult ?? ((result) => encodeHttpApiOperationResult(result)),
46
64
  execute: Effect.fn("ApiClient.execute")(function* (options) {
47
65
  return yield* executeGeneratedOperation(client, options);
48
66
  })
@@ -57,29 +75,29 @@ import {
57
75
  JsonSchema,
58
76
  Layer as Layer2,
59
77
  Option,
60
- Schema,
78
+ Schema as Schema2,
61
79
  SchemaRepresentation
62
80
  } from "effect";
63
81
  import { HttpApi as HttpApi2, OpenApi } from "effect/unstable/httpapi";
64
- var JsonObjectSchema = Schema.Record(Schema.String, Schema.Unknown).annotate({
82
+ var JsonObjectSchema = Schema2.Record(Schema2.String, Schema2.Json).annotate({
65
83
  identifier: "HttpJsonObject",
66
84
  title: "HTTP JSON object",
67
85
  description: "A JSON object passed to an HTTP API operation.",
68
86
  examples: [{ id: "example-id" }]
69
87
  });
70
- var JsonObjectFromString = Schema.fromJsonString(JsonObjectSchema);
71
- var JsonValueFromString = Schema.fromJsonString(Schema.Unknown);
72
- var JsonSchemaAnnotations = Schema.Struct({
73
- title: Schema.optional(Schema.String),
74
- description: Schema.optional(Schema.String),
75
- examples: Schema.optional(Schema.Array(Schema.Unknown))
88
+ var JsonObjectFromString = Schema2.fromJsonString(JsonObjectSchema);
89
+ var JsonValueFromString = Schema2.fromJsonString(Schema2.Json);
90
+ var JsonSchemaAnnotations = Schema2.Struct({
91
+ title: Schema2.optional(Schema2.String),
92
+ description: Schema2.optional(Schema2.String),
93
+ examples: Schema2.optional(Schema2.Array(Schema2.Json))
76
94
  }).annotate({
77
95
  identifier: "HttpJsonSchemaAnnotations",
78
96
  title: "HTTP JSON Schema annotations",
79
97
  description: "JSON Schema annotations surfaced on generated tool inputs."
80
98
  });
81
- var HttpApiToolInputSchema = Schema.Struct({
82
- body: Schema.optional(Schema.Unknown)
99
+ var HttpApiToolInputSchema = Schema2.Struct({
100
+ body: Schema2.optional(Schema2.Json)
83
101
  }).annotate({
84
102
  identifier: "HttpApiToolInput",
85
103
  title: "HTTP API tool input",
@@ -93,6 +111,8 @@ var HttpApiMethods = [
93
111
  "patch",
94
112
  "delete"
95
113
  ];
114
+ var HttpApiOperationSchema = Schema2.declare((value) => Schema2.is(JsonObjectSchema)(value)).annotate({ identifier: "HttpApiOperation" });
115
+ var decodeHttpApiOperation = Schema2.decodeUnknownOption(HttpApiOperationSchema);
96
116
  var toHttpError = (message, error) => new Error(message, { cause: error });
97
117
  var httpApiToolName = (method, path, operation) => {
98
118
  const fallback = `${method}_${path.replace(/^\/api\//, "").replace(/[/:{}]/g, "_")}`;
@@ -105,9 +125,10 @@ var httpApiOperations = ({
105
125
  const operations = [];
106
126
  for (const [path, pathItem] of Object.entries(spec.paths)) {
107
127
  for (const method of methods) {
108
- const operation = pathItem[method];
109
- if (operation)
110
- operations.push({ method, path, operation });
128
+ const operation = decodeHttpApiOperation(pathItem[method]);
129
+ if (Option.isSome(operation)) {
130
+ operations.push({ method, path, operation: operation.value });
131
+ }
111
132
  }
112
133
  }
113
134
  return operations;
@@ -128,7 +149,7 @@ var httpApiToolEntries = Effect2.fn("Http.toolEntries")(function* (operations) {
128
149
  catch: (error) => error instanceof Error ? error : new Error(String(error))
129
150
  });
130
151
  });
131
- var decodeAnnotations = Schema.decodeUnknownOption(JsonSchemaAnnotations);
152
+ var decodeAnnotations = Schema2.decodeUnknownOption(JsonSchemaAnnotations);
132
153
  var schemaWithVisibleAnnotations = (schema) => {
133
154
  const directAnnotations = decodeAnnotations(schema).pipe(Option.getOrElse(() => ({})));
134
155
  const allOf = Array.isArray(schema.allOf) ? schema.allOf : [];
@@ -136,30 +157,36 @@ var schemaWithVisibleAnnotations = (schema) => {
136
157
  ...acc,
137
158
  ...decodeAnnotations(item).pipe(Option.getOrElse(() => ({})))
138
159
  }), directAnnotations);
139
- return {
140
- ...schema,
141
- ..."title" in annotations && !("title" in schema) ? { title: annotations.title } : {},
142
- ..."description" in annotations && !("description" in schema) ? { description: annotations.description } : {},
143
- ..."examples" in annotations && !("examples" in schema) ? { examples: annotations.examples } : {}
144
- };
160
+ const visible = { ...schema };
161
+ if ("title" in annotations && !("title" in schema)) {
162
+ visible.title = annotations.title;
163
+ }
164
+ if ("description" in annotations && !("description" in schema)) {
165
+ visible.description = annotations.description;
166
+ }
167
+ if ("examples" in annotations && !("examples" in schema)) {
168
+ visible.examples = annotations.examples;
169
+ }
170
+ return visible;
145
171
  };
146
172
  var referencedDefinitions = (schema, definitions) => {
147
173
  const names = new Set;
148
- const pending = [schema];
174
+ const pending = [Schema2.decodeUnknownSync(Schema2.Json)(schema)];
149
175
  while (pending.length > 0) {
150
176
  const current = pending.pop();
151
- if (!current || typeof current !== "object")
152
- continue;
153
177
  if (Array.isArray(current)) {
154
178
  pending.push(...current);
155
179
  continue;
156
180
  }
157
- for (const [key, value] of Object.entries(current)) {
158
- if (key === "$ref" && typeof value === "string") {
181
+ const record = Schema2.decodeUnknownOption(Schema2.Record(Schema2.String, Schema2.Json))(current);
182
+ if (Option.isNone(record))
183
+ continue;
184
+ for (const [key, value] of Object.entries(record.value)) {
185
+ if (key === "$ref" && Schema2.is(Schema2.String)(value)) {
159
186
  const name = value.match(/^#\/(?:\$defs|components\/schemas)\/(.+)$/)?.[1];
160
187
  if (name && !names.has(name) && definitions[name]) {
161
188
  names.add(name);
162
- pending.push(definitions[name]);
189
+ pending.push(Schema2.decodeUnknownSync(Schema2.Json)(definitions[name]));
163
190
  }
164
191
  } else if (key !== "$defs") {
165
192
  pending.push(value);
@@ -182,10 +209,12 @@ var httpApiOperationInputSchema = (operation) => {
182
209
  ...queryParameters,
183
210
  ...headerParameters
184
211
  ]) {
185
- properties[parameter.name] = {
186
- ...parameter.schema ? schemaWithVisibleAnnotations(parameter.schema) : { type: "string" },
187
- ...parameter.description ? { description: parameter.description } : {}
212
+ const property = {
213
+ ...parameter.schema ? schemaWithVisibleAnnotations(parameter.schema) : { type: "string" }
188
214
  };
215
+ if (parameter.description)
216
+ property.description = parameter.description;
217
+ properties[parameter.name] = property;
189
218
  if (parameter.required)
190
219
  required.push(parameter.name);
191
220
  }
@@ -201,10 +230,10 @@ var httpApiOperationInputSchema = (operation) => {
201
230
  additionalProperties: false
202
231
  };
203
232
  };
204
- var decodeJsonObject = Schema.decodeUnknownOption(JsonObjectSchema);
233
+ var decodeJsonObject = Schema2.decodeUnknownOption(JsonObjectSchema);
205
234
  var decodeHttpApiOperationInput = Effect2.fn("Http.decodeApiOperationInput")(function* (input, operation) {
206
- const payload = yield* Schema.decodeUnknownEffect(JsonObjectSchema)(input ?? {}).pipe(Effect2.mapError(() => new Error("Tool input must be a JSON object")));
207
- const decoded = yield* Schema.decodeUnknownEffect(HttpApiToolInputSchema)(payload).pipe(Effect2.mapError(() => new Error("Tool input must be a JSON object")));
235
+ const payload = yield* Schema2.decodeUnknownEffect(JsonObjectSchema)(input ?? {}).pipe(Effect2.mapError(() => new Error("Tool input must be a JSON object")));
236
+ const decoded = yield* Schema2.decodeUnknownEffect(HttpApiToolInputSchema)(payload).pipe(Effect2.mapError(() => new Error("Tool input must be a JSON object")));
208
237
  const parameters = operation.parameters ?? [];
209
238
  const pickParameters = (location) => {
210
239
  const nestedKey = location === "path" ? "params" : location;
@@ -224,12 +253,12 @@ var decodeHttpApiOperationInput = Effect2.fn("Http.decodeApiOperationInput")(fun
224
253
  var parseJsonObject = Effect2.fn("Http.parseJsonObject")(function* (value, label) {
225
254
  if (!value)
226
255
  return {};
227
- return yield* Schema.decodeUnknownEffect(JsonObjectFromString)(value).pipe(Effect2.mapError(() => new Error(`${label} must be a JSON object`)));
256
+ return yield* Schema2.decodeUnknownEffect(JsonObjectFromString)(value).pipe(Effect2.mapError(() => new Error(`${label} must be a JSON object`)));
228
257
  });
229
258
  var parseJsonValue = Effect2.fn("Http.parseJsonValue")(function* (value, label) {
230
259
  if (!value)
231
260
  return;
232
- return yield* Schema.decodeUnknownEffect(JsonValueFromString)(value).pipe(Effect2.mapError(() => new Error(`${label} must be valid JSON`)));
261
+ return yield* Schema2.decodeUnknownEffect(JsonValueFromString)(value).pipe(Effect2.mapError(() => new Error(`${label} must be valid JSON`)));
233
262
  });
234
263
 
235
264
  class HttpApiSpec extends Context2.Service()("HttpApiSpec", {
@@ -251,10 +280,11 @@ class HttpApiSpec extends Context2.Service()("HttpApiSpec", {
251
280
  });
252
281
  const definitions = document.definitions ?? {};
253
282
  const usedDefinitions = referencedDefinitions(document.schema, definitions);
254
- return {
255
- ...document.schema,
256
- ...Object.keys(usedDefinitions).length > 0 ? { $defs: usedDefinitions } : {}
257
- };
283
+ const result = { ...document.schema };
284
+ if (Object.keys(usedDefinitions).length > 0) {
285
+ result.$defs = usedDefinitions;
286
+ }
287
+ return result;
258
288
  };
259
289
  return {
260
290
  info: spec.info,
@@ -274,33 +304,38 @@ class HttpApiSpec extends Context2.Service()("HttpApiSpec", {
274
304
  }
275
305
 
276
306
  // ../../src/lib/httpapi-toolkit.ts
277
- var HttpApiToolParameters = Schema2.Struct({}).annotate({
307
+ var HttpApiToolParameters = Schema3.Struct({}).annotate({
278
308
  identifier: "HttpApiToolParameters"
279
309
  });
280
310
  var makeOpenAiStrictJsonSchema = (schema) => {
311
+ const JsonRecord = Schema3.Record(Schema3.String, Schema3.Json);
281
312
  const visit = (value) => {
282
313
  if (Array.isArray(value))
283
314
  return value.map(visit);
284
- if (!value || typeof value !== "object")
315
+ const record = Schema3.decodeUnknownOption(JsonRecord)(value);
316
+ if (Option2.isNone(record))
285
317
  return value;
286
- const transformed = Object.fromEntries(Object.entries(value).map(([key, child]) => [key, visit(child)]));
287
- const allOf = transformed.allOf;
318
+ let transformed2 = Object.fromEntries(Object.entries(record.value).map(([key, child]) => [key, visit(child)]));
319
+ const allOf = transformed2.allOf;
288
320
  if (Array.isArray(allOf)) {
289
- delete transformed.allOf;
321
+ delete transformed2.allOf;
290
322
  for (const item of allOf) {
291
- if (item && typeof item === "object")
292
- Object.assign(transformed, item);
323
+ const itemRecord = Schema3.decodeUnknownOption(JsonRecord)(item);
324
+ if (Option2.isSome(itemRecord)) {
325
+ transformed2 = { ...transformed2, ...itemRecord.value };
326
+ }
293
327
  }
294
328
  }
295
- if (transformed.type === "object") {
296
- const properties = transformed.properties && typeof transformed.properties === "object" ? transformed.properties : {};
297
- transformed.properties = properties;
298
- transformed.required = Object.keys(properties);
299
- transformed.additionalProperties = false;
329
+ if (transformed2.type === "object") {
330
+ const properties = Schema3.decodeUnknownOption(JsonRecord)(transformed2.properties).pipe(Option2.getOrElse(() => ({})));
331
+ transformed2.properties = properties;
332
+ transformed2.required = Object.keys(properties);
333
+ transformed2.additionalProperties = false;
300
334
  }
301
- return transformed;
335
+ return transformed2;
302
336
  };
303
- return visit(schema);
337
+ const transformed = Schema3.decodeUnknownSync(JsonRecord)(visit(Schema3.decodeUnknownSync(Schema3.Json)(schema)));
338
+ return { ...schema, ...transformed };
304
339
  };
305
340
  var makeOperationTool = (entry, config, spec) => {
306
341
  const { method, operation } = entry;
@@ -314,8 +349,8 @@ var makeOperationTool = (entry, config, spec) => {
314
349
 
315
350
  ${guidance}` : guidance,
316
351
  parameters: strict ? makeOpenAiStrictJsonSchema(parameters) : parameters,
317
- success: Schema2.Unknown,
318
- failure: Schema2.String,
352
+ success: Schema3.Json,
353
+ failure: Schema3.String,
319
354
  failureMode: "return",
320
355
  needsApproval: config.needsApproval?.(entry) ?? !readOnly
321
356
  }).setParameters(HttpApiToolParameters).annotate(Tool.Title, operation.summary ?? operation.operationId ?? entry.name).annotate(Tool.Strict, strict).annotate(Tool.Readonly, readOnly).annotate(Tool.Destructive, method === "delete").annotate(Tool.Idempotent, method === "get" || method === "put" || method === "delete").annotate(Tool.OpenWorld, false);
@@ -346,7 +381,8 @@ var HttpApiToolkitLayer = (config) => Layer3.unwrap(buildHttpApiToolkit(config).
346
381
  query: decoded.query
347
382
  }
348
383
  });
349
- return config.transformResult?.(entry, result) ?? result;
384
+ const encoded = yield* client.encodeResult(result, entry);
385
+ return config.transformResult?.(entry, encoded) ?? encoded;
350
386
  }).pipe(Effect3.mapError((error) => error instanceof Error ? error.message : String(error)))
351
387
  ])))))));
352
388
  export {
package/dist/lib/seo.js CHANGED
@@ -65,24 +65,36 @@ var seo = ({
65
65
  const siteUrl = origin?.replace(/\/$/, "") ?? canonical;
66
66
  const publisher = {
67
67
  "@type": "Organization",
68
- name: siteName,
69
- ...siteUrl ? { url: siteUrl } : {},
70
- ...sameAs?.length ? { sameAs } : {}
71
- };
72
- const structuredData = type === "article" ? {
73
- "@type": "Article",
74
- headline: title,
75
- description,
76
- ...canonical ? { url: canonical } : {},
77
- ...locale ? { inLanguage: locale } : {},
78
- ...image ? { image } : {},
79
- publisher
80
- } : {
81
- "@type": "WebSite",
82
- name: siteName,
83
- ...siteUrl ? { url: siteUrl } : {},
84
- publisher
68
+ name: siteName
85
69
  };
70
+ if (siteUrl)
71
+ publisher.url = siteUrl;
72
+ if (sameAs?.length)
73
+ publisher.sameAs = sameAs;
74
+ const structuredData = type === "article" ? (() => {
75
+ const article = {
76
+ "@type": "Article",
77
+ headline: title,
78
+ description,
79
+ publisher
80
+ };
81
+ if (canonical)
82
+ article.url = canonical;
83
+ if (locale)
84
+ article.inLanguage = locale;
85
+ if (image)
86
+ article.image = image;
87
+ return article;
88
+ })() : (() => {
89
+ const website = {
90
+ "@type": "WebSite",
91
+ name: siteName,
92
+ publisher
93
+ };
94
+ if (siteUrl)
95
+ website.url = siteUrl;
96
+ return website;
97
+ })();
86
98
  const scripts = [
87
99
  {
88
100
  type: "application/ld+json",