@orpc/json-schema 2.0.0-beta.2 → 2.0.0-beta.3
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/dist/index.d.mts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.mjs +15 -17
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -30,6 +30,7 @@ declare class JsonSchemaCoercer {
|
|
|
30
30
|
* and exclusively use absolute JSON pointers for `$ref` values.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
+
declare function isJsonPrimitiveSchema(schema: JsonSchema): schema is JsonSchema & object;
|
|
33
34
|
type JsonFileSchema = JsonSchema & object & {
|
|
34
35
|
type: 'string';
|
|
35
36
|
contentMediaType?: string;
|
|
@@ -70,10 +71,6 @@ declare function ensureJsonSchemaObject(schema: JsonSchema): Exclude<JsonSchema,
|
|
|
70
71
|
* Combines multiple schemas under the requested composition keyword, promoting branch `$defs` to the root.
|
|
71
72
|
*/
|
|
72
73
|
declare function combineJsonSchemasWithComposition(keyword: 'allOf' | 'anyOf' | 'oneOf', schemas: JsonSchema[]): JsonSchema;
|
|
73
|
-
/**
|
|
74
|
-
* Returns true when every branch in the schema describes a primitive value.
|
|
75
|
-
*/
|
|
76
|
-
declare function isJsonPrimitiveSchema(schema: JsonSchema): boolean;
|
|
77
74
|
type JsonObjectSchemaEntry = [name: string, schema: JsonSchema, optional: boolean];
|
|
78
75
|
/**
|
|
79
76
|
* Combines object property entries back into a single object schema.
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare class JsonSchemaCoercer {
|
|
|
30
30
|
* and exclusively use absolute JSON pointers for `$ref` values.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
+
declare function isJsonPrimitiveSchema(schema: JsonSchema): schema is JsonSchema & object;
|
|
33
34
|
type JsonFileSchema = JsonSchema & object & {
|
|
34
35
|
type: 'string';
|
|
35
36
|
contentMediaType?: string;
|
|
@@ -70,10 +71,6 @@ declare function ensureJsonSchemaObject(schema: JsonSchema): Exclude<JsonSchema,
|
|
|
70
71
|
* Combines multiple schemas under the requested composition keyword, promoting branch `$defs` to the root.
|
|
71
72
|
*/
|
|
72
73
|
declare function combineJsonSchemasWithComposition(keyword: 'allOf' | 'anyOf' | 'oneOf', schemas: JsonSchema[]): JsonSchema;
|
|
73
|
-
/**
|
|
74
|
-
* Returns true when every branch in the schema describes a primitive value.
|
|
75
|
-
*/
|
|
76
|
-
declare function isJsonPrimitiveSchema(schema: JsonSchema): boolean;
|
|
77
74
|
type JsonObjectSchemaEntry = [name: string, schema: JsonSchema, optional: boolean];
|
|
78
75
|
/**
|
|
79
76
|
* Combines object property entries back into a single object schema.
|
package/dist/index.mjs
CHANGED
|
@@ -473,6 +473,21 @@ function arrayToMap(value) {
|
|
|
473
473
|
return result;
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
+
function isJsonPrimitiveSchema(schema) {
|
|
477
|
+
if (typeof schema === "boolean") {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
if (typeof schema.type === "string" && JSON_SCHEMA_PRIMITIVE_TYPES.has(schema.type)) {
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
if (schema.const !== void 0) {
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
if (schema.enum !== void 0) {
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
476
491
|
function isJsonFileSchema(schema) {
|
|
477
492
|
return typeof schema !== "boolean" && schema.type === "string" && (typeof schema.contentMediaType === "string" || schema.format === "binary" || schema.contentEncoding === "binary");
|
|
478
493
|
}
|
|
@@ -568,23 +583,6 @@ function combineJsonSchemasWithComposition(keyword, schemas) {
|
|
|
568
583
|
}
|
|
569
584
|
return result;
|
|
570
585
|
}
|
|
571
|
-
function isJsonPrimitiveSchema(schema) {
|
|
572
|
-
return flattenJsonUnionSchema(schema).every((s) => {
|
|
573
|
-
if (typeof s === "boolean") {
|
|
574
|
-
return false;
|
|
575
|
-
}
|
|
576
|
-
if (typeof s.type === "string" && JSON_SCHEMA_PRIMITIVE_TYPES.has(s.type)) {
|
|
577
|
-
return true;
|
|
578
|
-
}
|
|
579
|
-
if (s.const !== void 0) {
|
|
580
|
-
return true;
|
|
581
|
-
}
|
|
582
|
-
if (s.enum !== void 0) {
|
|
583
|
-
return true;
|
|
584
|
-
}
|
|
585
|
-
return false;
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
586
|
function combineJsonObjectSchemaEntries(entries) {
|
|
589
587
|
const properties = {};
|
|
590
588
|
const required = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/json-schema",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@standard-schema/spec": "^1.1.0",
|
|
29
29
|
"json-schema-typed": "^8.0.2",
|
|
30
|
-
"@orpc/
|
|
31
|
-
"@orpc/
|
|
32
|
-
"@orpc/
|
|
33
|
-
"@orpc/
|
|
30
|
+
"@orpc/client": "2.0.0-beta.3",
|
|
31
|
+
"@orpc/server": "2.0.0-beta.3",
|
|
32
|
+
"@orpc/shared": "2.0.0-beta.3",
|
|
33
|
+
"@orpc/contract": "2.0.0-beta.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"zod": "^4.4.3"
|