@amritk/adapters 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.
@@ -0,0 +1,22 @@
1
+ import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
2
+ import type { SourceFormat } from './source-format';
3
+ /**
4
+ * Converts a schema authored in some external library into a Draft 2020-12
5
+ * JSON Schema, which is the single input shape the mjst generators understand.
6
+ *
7
+ * Adapters receive the already-loaded schema value (an imported module export),
8
+ * not a file path. Loading the module is the caller's job so adapters stay pure
9
+ * and trivial to unit test. When a source construct cannot be represented in
10
+ * JSON Schema, adapters should warn and continue on a best-effort basis rather
11
+ * than throw, so generation is not blocked by a single unsupported field.
12
+ */
13
+ export type Adapter = {
14
+ /** The source format this adapter handles, matching the `--input` CLI flag. */
15
+ readonly format: SourceFormat;
16
+ /**
17
+ * Convert a loaded source schema value into a JSON Schema. May be async:
18
+ * some adapters (e.g. Zod) dynamically import their source library to perform
19
+ * the conversion, so callers should always `await` the result.
20
+ */
21
+ readonly toJSONSchema: (source: unknown) => JSONSchema | Promise<JSONSchema>;
22
+ };
File without changes
@@ -0,0 +1,11 @@
1
+ import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
2
+ /**
3
+ * Converts an Effect `Schema` into a JSON Schema via `JSONSchema.make`.
4
+ *
5
+ * Effect models values as a decode/encode pair, so `JSONSchema.make` describes
6
+ * the *encoded* (wire) representation. For example `Schema.Date` decodes from a
7
+ * string, so it converts to a string schema rather than a runtime `Date`. We
8
+ * pass that representation straight through — it accurately reflects what Effect
9
+ * expects on the wire — only stripping the dialect marker.
10
+ */
11
+ export declare const effectToJsonSchema: (source: unknown) => Promise<JSONSchema>;