@orpc/arktype 2.0.0-beta.46 → 2.0.0-beta.48

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/README.md CHANGED
@@ -156,10 +156,11 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
156
156
  <td align="center"><a href="https://github.com/christ12938?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="167" alt="christ12938"/><br />christ12938</a></td>
157
157
  <td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&amp;v=4" width="167" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
158
158
  <td align="center"><a href="https://github.com/itigoore01?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&amp;v=4" width="167" alt="shota"/><br />shota</a></td>
159
+ <td align="center"><a href="https://github.com/Nic13Gamer?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Nicholas"><img src="https://avatars.githubusercontent.com/u/54724556?u=56a7ab430ce7a80d648ab6eba051d454a818ed0b&amp;v=4" width="167" alt="Nicholas"/><br />Nicholas</a></td>
159
160
  <td align="center"><a href="https://github.com/ellis-driscoll?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&amp;v=4" width="167" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
160
- <td align="center"><a href="https://github.com/hoangbn?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&amp;v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
161
161
  </tr>
162
162
  <tr>
163
+ <td align="center"><a href="https://github.com/hoangbn?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&amp;v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
163
164
  <td align="center"><a href="https://opencollective.com/guest-ac41de3b?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Orestis Ioannou"><img src="https://images.opencollective.com/guest-ac41de3b/avatar/460.png" width="167" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
164
165
  <td align="center"><a href="https://automatio.ai/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Stefan Smiljkovic"><img src="https://avatars.githubusercontent.com/u/1984909?u=b7bf5bc40ed49df3c22f69d2da7b8d78709c49ed&amp;v=4" width="167" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
165
166
  </tr>
@@ -190,10 +191,9 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
190
191
  <td align="center"><a href="https://kellychan.im/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&amp;v=4" width="139" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
191
192
  <td align="center"><a href="https://guyariely.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&amp;v=4" width="139" alt="Guy Ariely"/><br />Guy Ariely</a></td>
192
193
  <td align="center"><a href="https://paulsenon.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="PaulSenon"><img src="https://avatars.githubusercontent.com/u/19531087?u=6385741eb91d200b8c513ec6045482e301767ca6&amp;v=4" width="139" alt="PaulSenon"/><br />PaulSenon</a></td>
193
- <td align="center"><a href="https://nakasyou.how/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Shotaro Nakamura"><img src="https://avatars.githubusercontent.com/u/79000684?u=f644df3f29f0e8677a90967115774564f1d9d6ab&amp;v=4" width="139" alt="Shotaro Nakamura"/><br />Shotaro Nakamura</a></td>
194
+ <td align="center"><a href="https://piscis.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="139" alt="Alex"/><br />Alex</a></td>
194
195
  </tr>
195
196
  <tr>
196
- <td align="center"><a href="https://piscis.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="139" alt="Alex"/><br />Alex</a></td>
197
197
  <td align="center"><a href="https://opensource.gubanov.eu/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&amp;v=4" width="139" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
198
198
  </tr>
199
199
  </table>
@@ -206,7 +206,9 @@ With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who h
206
206
 
207
207
  <table>
208
208
  <tr>
209
- <td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude for Open Source</a></td>
209
+ <td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude</a></td>
210
+ <td align="center"><a href="https://pullfrog.com/for-oss" target="_blank" rel="noopener" title="Pullfrog for OSS"><img src="https://avatars.githubusercontent.com/in/1768019?s=128&amp;v=4" width="64" alt="Pullfrog"/><br />Pullfrog</a></td>
211
+ <td align="center"><a href="https://macroscope.com/open-source" target="_blank" rel="noopener" title="Macroscope for Open Source"><img src="https://avatars.githubusercontent.com/in/900172?s=128&amp;v=4" width="64" alt="Macroscope"/><br />Macroscope</a></td>
210
212
  </tr>
211
213
  </table>
212
214
 
@@ -0,0 +1,29 @@
1
+ import type { ToJsonSchema } from "@ark/schema";
2
+ import type { AnySchema, JsonSchema, JsonSchemaConverter, JsonSchemaConverterDirection } from "@orpc/json-schema";
3
+ export interface ArkTypeToJsonSchemaConverterOptions extends Omit<ToJsonSchema.Options, "dialect" | "target"> {
4
+ /**
5
+ * Caches conversion results in a WeakMap keyed by the ArkType schema instance,
6
+ * so converting the same schema again is free.
7
+ *
8
+ * When enabled, repeated conversions return the same JSON schema object,
9
+ * so treat returned schemas as immutable.
10
+ *
11
+ * @default false
12
+ */
13
+ cache?: boolean | undefined;
14
+ }
15
+ /**
16
+ * Converts ArkType schemas into JSON Schema using ArkType's built-in `toJsonSchema`,
17
+ * with additional support for types such as `bigint` and `Date`.
18
+ *
19
+ * @see {@link https://orpc.dev/docs/integrations/arktype | ArkType Integration}
20
+ */
21
+ export declare class ArkTypeToJsonSchemaConverter implements JsonSchemaConverter {
22
+ private readonly toJsonSchemaOptions;
23
+ private readonly cache;
24
+ constructor({ cache, ...options }?: ArkTypeToJsonSchemaConverterOptions);
25
+ condition(schema: AnySchema | undefined, _direction: JsonSchemaConverterDirection): boolean;
26
+ convert(schema: AnySchema | undefined, direction: JsonSchemaConverterDirection): [jsonSchema: JsonSchema, optional: boolean];
27
+ private convertUncached;
28
+ private convertArkType;
29
+ }
@@ -0,0 +1,73 @@
1
+ import { isStandardSchemaOptional, JsonSchemaFormat, JsonSchemaXNativeType } from "@orpc/json-schema";
2
+
3
+ export class ArkTypeToJsonSchemaConverter {
4
+ toJsonSchemaOptions;
5
+ cache;
6
+ constructor({ cache, ...options } = {}) {
7
+ if (cache) {
8
+ this.cache = {
9
+ input: new WeakMap(),
10
+ output: new WeakMap()
11
+ };
12
+ }
13
+ this.toJsonSchemaOptions = {
14
+ ...options,
15
+ target: "draft-2020-12",
16
+ fallback: {
17
+ ...options.fallback && typeof options.fallback !== "function" ? options.fallback : undefined,
18
+ default: (ctx) => {
19
+ if (ctx.code === "domain") {
20
+ if (ctx.domain === "bigint") {
21
+ ;
22
+ ctx.base.type = "string";
23
+ ctx.base.pattern = "^-?[0-9]+$";
24
+ ctx.base["x-native-type"] = JsonSchemaXNativeType.BigInt;
25
+ }
26
+ } else if (ctx.code === "date") {
27
+ ;
28
+ ctx.base.type = "string";
29
+ ctx.base.format = JsonSchemaFormat.DateTime;
30
+ ctx.base["x-native-type"] = JsonSchemaXNativeType.Date;
31
+ }
32
+ if (typeof options.fallback === "function") {
33
+ return options.fallback(ctx);
34
+ }
35
+ if (options.fallback?.default) {
36
+ return options.fallback.default(ctx);
37
+ }
38
+ return ctx.base;
39
+ }
40
+ }
41
+ };
42
+ }
43
+ condition(schema, _direction) {
44
+ return schema?.["~standard"].vendor === "arktype";
45
+ }
46
+ convert(schema, direction) {
47
+ const arkTypeSchema = schema;
48
+ if (this.cache) {
49
+ const cached = this.cache[direction].get(arkTypeSchema);
50
+ if (cached) {
51
+ return cached;
52
+ }
53
+ }
54
+ const result = this.convertUncached(arkTypeSchema, direction);
55
+ if (this.cache) {
56
+ this.cache[direction].set(arkTypeSchema, result);
57
+ }
58
+ return result;
59
+ }
60
+ convertUncached(arkTypeSchema, direction) {
61
+ const jsonSchema = this.convertArkType(arkTypeSchema, direction);
62
+ return [jsonSchema, isStandardSchemaOptional(arkTypeSchema, direction)];
63
+ }
64
+ convertArkType(schema, direction) {
65
+
66
+
67
+ const jsonSchema = (direction === "output" ? schema.out : schema).toJsonSchema(this.toJsonSchemaOptions);
68
+
69
+
70
+ const { $schema, ...rest } = jsonSchema;
71
+ return rest;
72
+ }
73
+ }
package/dist/index.d.mts CHANGED
@@ -1,34 +1,2 @@
1
- import { ToJsonSchema } from '@ark/schema';
2
- import { JsonSchemaConverter, AnySchema, JsonSchemaConverterDirection, JsonSchema } from '@orpc/json-schema';
3
- export { JsonSchema } from '@orpc/json-schema';
4
-
5
- interface ArkTypeToJsonSchemaConverterOptions extends Omit<ToJsonSchema.Options, 'dialect' | 'target'> {
6
- /**
7
- * Caches conversion results in a WeakMap keyed by the ArkType schema instance,
8
- * so converting the same schema again is free.
9
- *
10
- * When enabled, repeated conversions return the same JSON schema object,
11
- * so treat returned schemas as immutable.
12
- *
13
- * @default false
14
- */
15
- cache?: boolean | undefined;
16
- }
17
- /**
18
- * Converts ArkType schemas into JSON Schema using ArkType's built-in `toJsonSchema`,
19
- * with additional support for types such as `bigint` and `Date`.
20
- *
21
- * @see {@link https://orpc.dev/docs/integrations/arktype | ArkType Integration}
22
- */
23
- declare class ArkTypeToJsonSchemaConverter implements JsonSchemaConverter {
24
- private readonly toJsonSchemaOptions;
25
- private readonly cache;
26
- constructor({ cache, ...options }?: ArkTypeToJsonSchemaConverterOptions);
27
- condition(schema: AnySchema | undefined, _direction: JsonSchemaConverterDirection): boolean;
28
- convert(schema: AnySchema | undefined, direction: JsonSchemaConverterDirection): [jsonSchema: JsonSchema, optional: boolean];
29
- private convertUncached;
30
- private convertArkType;
31
- }
32
-
33
- export { ArkTypeToJsonSchemaConverter };
34
- export type { ArkTypeToJsonSchemaConverterOptions };
1
+ export * from "./converter.mjs";
2
+ export type { JsonSchema } from "@orpc/json-schema";
package/dist/index.mjs CHANGED
@@ -1,66 +1 @@
1
- import { JsonSchemaXNativeType, JsonSchemaFormat, isStandardSchemaOptional } from '@orpc/json-schema';
2
-
3
- class ArkTypeToJsonSchemaConverter {
4
- toJsonSchemaOptions;
5
- cache;
6
- constructor({ cache, ...options } = {}) {
7
- if (cache) {
8
- this.cache = { input: /* @__PURE__ */ new WeakMap(), output: /* @__PURE__ */ new WeakMap() };
9
- }
10
- this.toJsonSchemaOptions = {
11
- ...options,
12
- target: "draft-2020-12",
13
- fallback: {
14
- ...options.fallback && typeof options.fallback !== "function" ? options.fallback : void 0,
15
- default: (ctx) => {
16
- if (ctx.code === "domain") {
17
- if (ctx.domain === "bigint") {
18
- ctx.base.type = "string";
19
- ctx.base.pattern = "^-?[0-9]+$";
20
- ctx.base["x-native-type"] = JsonSchemaXNativeType.BigInt;
21
- }
22
- } else if (ctx.code === "date") {
23
- ctx.base.type = "string";
24
- ctx.base.format = JsonSchemaFormat.DateTime;
25
- ctx.base["x-native-type"] = JsonSchemaXNativeType.Date;
26
- }
27
- if (typeof options.fallback === "function") {
28
- return options.fallback(ctx);
29
- }
30
- if (options.fallback?.default) {
31
- return options.fallback.default(ctx);
32
- }
33
- return ctx.base;
34
- }
35
- }
36
- };
37
- }
38
- condition(schema, _direction) {
39
- return schema?.["~standard"].vendor === "arktype";
40
- }
41
- convert(schema, direction) {
42
- const arkTypeSchema = schema;
43
- if (this.cache) {
44
- const cached = this.cache[direction].get(arkTypeSchema);
45
- if (cached) {
46
- return cached;
47
- }
48
- }
49
- const result = this.convertUncached(arkTypeSchema, direction);
50
- if (this.cache) {
51
- this.cache[direction].set(arkTypeSchema, result);
52
- }
53
- return result;
54
- }
55
- convertUncached(arkTypeSchema, direction) {
56
- const jsonSchema = this.convertArkType(arkTypeSchema, direction);
57
- return [jsonSchema, isStandardSchemaOptional(arkTypeSchema, direction)];
58
- }
59
- convertArkType(schema, direction) {
60
- const jsonSchema = (direction === "output" ? schema.out : schema).toJsonSchema(this.toJsonSchemaOptions);
61
- const { $schema, ...rest } = jsonSchema;
62
- return rest;
63
- }
64
- }
65
-
66
- export { ArkTypeToJsonSchemaConverter };
1
+ export * from "./converter.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/arktype",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.46",
4
+ "version": "2.0.0-beta.48",
5
5
  "description": "ArkType integration for oRPC: convert ArkType schemas into JSON Schema for OpenAPI generation",
6
6
  "license": "MIT",
7
7
  "funding": [
@@ -40,11 +40,11 @@
40
40
  "arktype": "*"
41
41
  },
42
42
  "dependencies": {
43
- "@orpc/json-schema": "2.0.0-beta.46"
43
+ "@orpc/json-schema": "2.0.0-beta.48"
44
44
  },
45
45
  "devDependencies": {
46
- "@ark/schema": "^0.56.7",
47
- "arktype": "^2.2.8",
46
+ "@ark/schema": "^0.56.8",
47
+ "arktype": "^2.2.9",
48
48
  "zod": "^4.6.7"
49
49
  },
50
50
  "scripts": {
package/dist/index.d.ts DELETED
@@ -1,34 +0,0 @@
1
- import { ToJsonSchema } from '@ark/schema';
2
- import { JsonSchemaConverter, AnySchema, JsonSchemaConverterDirection, JsonSchema } from '@orpc/json-schema';
3
- export { JsonSchema } from '@orpc/json-schema';
4
-
5
- interface ArkTypeToJsonSchemaConverterOptions extends Omit<ToJsonSchema.Options, 'dialect' | 'target'> {
6
- /**
7
- * Caches conversion results in a WeakMap keyed by the ArkType schema instance,
8
- * so converting the same schema again is free.
9
- *
10
- * When enabled, repeated conversions return the same JSON schema object,
11
- * so treat returned schemas as immutable.
12
- *
13
- * @default false
14
- */
15
- cache?: boolean | undefined;
16
- }
17
- /**
18
- * Converts ArkType schemas into JSON Schema using ArkType's built-in `toJsonSchema`,
19
- * with additional support for types such as `bigint` and `Date`.
20
- *
21
- * @see {@link https://orpc.dev/docs/integrations/arktype | ArkType Integration}
22
- */
23
- declare class ArkTypeToJsonSchemaConverter implements JsonSchemaConverter {
24
- private readonly toJsonSchemaOptions;
25
- private readonly cache;
26
- constructor({ cache, ...options }?: ArkTypeToJsonSchemaConverterOptions);
27
- condition(schema: AnySchema | undefined, _direction: JsonSchemaConverterDirection): boolean;
28
- convert(schema: AnySchema | undefined, direction: JsonSchemaConverterDirection): [jsonSchema: JsonSchema, optional: boolean];
29
- private convertUncached;
30
- private convertArkType;
31
- }
32
-
33
- export { ArkTypeToJsonSchemaConverter };
34
- export type { ArkTypeToJsonSchemaConverterOptions };