@lunora/values 1.0.0-alpha.43 → 1.0.0-alpha.45
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 +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{jsonSchemaFromNode-BSWBXSLL.mjs → acceptsAbsent-Biqy6mRN.mjs} +1 -1
- package/dist/packem_shared/argsToJsonSchema-ATrQFtr_.mjs +1 -0
- package/package.json +2 -2
- package/dist/packem_shared/argsToJsonSchema-BN05tFLL.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -361,6 +361,15 @@ declare const array: <V extends Validator>(inner: V) => ArrayColumnValidator<Inf
|
|
|
361
361
|
* inference (`InferValidatorMap` in `./validator-map`), so the two can never
|
|
362
362
|
* drift. (`InsertShape` stays separate — it additionally `Exclude`s `undefined`
|
|
363
363
|
* from the optional value, a deliberate insert-type difference.)
|
|
364
|
+
*
|
|
365
|
+
* `undefined extends M[K]` is the type-level spelling of "the parser accepts
|
|
366
|
+
* this field absent" — the same question `acceptsAbsent` in
|
|
367
|
+
* `./json-schema-core` answers structurally. It is broader than
|
|
368
|
+
* `v.optional(...)` on purpose: `v.any()` returns its input unchanged, so it
|
|
369
|
+
* parses an absent field happily, and a `v.union(...)` with an `any`/optional
|
|
370
|
+
* member does too. Anything narrower would mark a key required that the runtime
|
|
371
|
+
* does not require — which is how a generated `_generated/api.ts` came to reject
|
|
372
|
+
* args the server accepts (issue #688).
|
|
364
373
|
*/
|
|
365
374
|
type OptionalizeShape<M> = { [K in keyof M as undefined extends M[K] ? K : never]?: M[K]; } & { [K in keyof M as undefined extends M[K] ? never : K]: M[K]; };
|
|
366
375
|
type ObjectShape = Record<string, Validator>;
|
|
@@ -583,6 +592,24 @@ interface SchemaNodeReader<TNode> {
|
|
|
583
592
|
* so they ride inside the non-null branch rather than on the wrapping `anyOf`.
|
|
584
593
|
*/
|
|
585
594
|
declare const jsonSchemaFromNode: <TNode>(node: TNode, reader: SchemaNodeReader<TNode>) => JsonSchema;
|
|
595
|
+
/**
|
|
596
|
+
* True when the parser accepts this node's field ABSENT — the only honest test
|
|
597
|
+
* for whether a key is optional.
|
|
598
|
+
*
|
|
599
|
+
* `kind === "optional"` used to be the whole test, which called two kinds
|
|
600
|
+
* required that parse `{}` happily: `v.any()` (its parser returns `undefined`
|
|
601
|
+
* unchanged) and a `v.union(...)` with an optional or `any` member (the union
|
|
602
|
+
* tries members, one of which accepts `undefined`). A contract that requires a
|
|
603
|
+
* field the server does not cannot be satisfied by a generated client.
|
|
604
|
+
*
|
|
605
|
+
* Shared beyond JSON Schema's `required`: `@lunora/codegen`'s api emitter runs it
|
|
606
|
+
* over the build-time validator IR to decide `key?: T` vs `key: T`, so the
|
|
607
|
+
* generated `_generated/api.ts` argument types, the emitted OpenAPI/OpenRPC
|
|
608
|
+
* specs, and `Infer`'s `undefined extends …` optionality rule all answer this
|
|
609
|
+
* one question the same way.
|
|
610
|
+
* @returns `true` when an absent value parses.
|
|
611
|
+
*/
|
|
612
|
+
declare const acceptsAbsent: <TNode>(node: TNode, reader: SchemaNodeReader<TNode>) => boolean;
|
|
586
613
|
/**
|
|
587
614
|
* Build `{ type: "object", properties, required }` from a node shape.
|
|
588
615
|
*
|
|
@@ -678,4 +705,4 @@ declare const installCompiledValidatorMap: (validators: object, compiled: Compil
|
|
|
678
705
|
* which case the interpreted loop below runs and owns the result (and any error).
|
|
679
706
|
*/
|
|
680
707
|
declare const parseValidatorMap: (validators: ValidatorMap, source: Record<string, unknown>, label: string) => Record<string, unknown>;
|
|
681
|
-
export { type ArrayColumnValidator, type CheckOptions, type Column, type ColumnMeta, type ColumnValidator, type CompiledValidatorMap, DEFER_VALIDATION, type GeoPoint, type Id, type Infer, type InferInsert, type InferSelect, type InferStandardInput, type InferStandardOutput, type InferValidatorMap, type InsertShape, type JsonSchema, type JsonSchemaFragment, type MetaOptions, type NumberColumnValidator, type ObjectColumnValidator, type ParseOptions, type SchemaNodeReader, type SelectShape, type ServerDefaultContext, type StringColumnValidator, type TimestampColumnValidator, ValidationError, type ValidationPath, type Validator, type ValidatorKind, type ValidatorMap, argsToJsonSchema, describeValue, formatPath, installCompiledValidatorMap, isOrWrapsFromValidator, jsonSchemaFromNode, objectSchemaFromNodes, optionalInner, parseValidatorMap, toJsonSchema, v };
|
|
708
|
+
export { type ArrayColumnValidator, type CheckOptions, type Column, type ColumnMeta, type ColumnValidator, type CompiledValidatorMap, DEFER_VALIDATION, type GeoPoint, type Id, type Infer, type InferInsert, type InferSelect, type InferStandardInput, type InferStandardOutput, type InferValidatorMap, type InsertShape, type JsonSchema, type JsonSchemaFragment, type MetaOptions, type NumberColumnValidator, type ObjectColumnValidator, type ParseOptions, type SchemaNodeReader, type SelectShape, type ServerDefaultContext, type StringColumnValidator, type TimestampColumnValidator, ValidationError, type ValidationPath, type Validator, type ValidatorKind, type ValidatorMap, acceptsAbsent, argsToJsonSchema, describeValue, formatPath, installCompiledValidatorMap, isOrWrapsFromValidator, jsonSchemaFromNode, objectSchemaFromNodes, optionalInner, parseValidatorMap, toJsonSchema, v };
|
package/dist/index.d.ts
CHANGED
|
@@ -361,6 +361,15 @@ declare const array: <V extends Validator>(inner: V) => ArrayColumnValidator<Inf
|
|
|
361
361
|
* inference (`InferValidatorMap` in `./validator-map`), so the two can never
|
|
362
362
|
* drift. (`InsertShape` stays separate — it additionally `Exclude`s `undefined`
|
|
363
363
|
* from the optional value, a deliberate insert-type difference.)
|
|
364
|
+
*
|
|
365
|
+
* `undefined extends M[K]` is the type-level spelling of "the parser accepts
|
|
366
|
+
* this field absent" — the same question `acceptsAbsent` in
|
|
367
|
+
* `./json-schema-core` answers structurally. It is broader than
|
|
368
|
+
* `v.optional(...)` on purpose: `v.any()` returns its input unchanged, so it
|
|
369
|
+
* parses an absent field happily, and a `v.union(...)` with an `any`/optional
|
|
370
|
+
* member does too. Anything narrower would mark a key required that the runtime
|
|
371
|
+
* does not require — which is how a generated `_generated/api.ts` came to reject
|
|
372
|
+
* args the server accepts (issue #688).
|
|
364
373
|
*/
|
|
365
374
|
type OptionalizeShape<M> = { [K in keyof M as undefined extends M[K] ? K : never]?: M[K]; } & { [K in keyof M as undefined extends M[K] ? never : K]: M[K]; };
|
|
366
375
|
type ObjectShape = Record<string, Validator>;
|
|
@@ -583,6 +592,24 @@ interface SchemaNodeReader<TNode> {
|
|
|
583
592
|
* so they ride inside the non-null branch rather than on the wrapping `anyOf`.
|
|
584
593
|
*/
|
|
585
594
|
declare const jsonSchemaFromNode: <TNode>(node: TNode, reader: SchemaNodeReader<TNode>) => JsonSchema;
|
|
595
|
+
/**
|
|
596
|
+
* True when the parser accepts this node's field ABSENT — the only honest test
|
|
597
|
+
* for whether a key is optional.
|
|
598
|
+
*
|
|
599
|
+
* `kind === "optional"` used to be the whole test, which called two kinds
|
|
600
|
+
* required that parse `{}` happily: `v.any()` (its parser returns `undefined`
|
|
601
|
+
* unchanged) and a `v.union(...)` with an optional or `any` member (the union
|
|
602
|
+
* tries members, one of which accepts `undefined`). A contract that requires a
|
|
603
|
+
* field the server does not cannot be satisfied by a generated client.
|
|
604
|
+
*
|
|
605
|
+
* Shared beyond JSON Schema's `required`: `@lunora/codegen`'s api emitter runs it
|
|
606
|
+
* over the build-time validator IR to decide `key?: T` vs `key: T`, so the
|
|
607
|
+
* generated `_generated/api.ts` argument types, the emitted OpenAPI/OpenRPC
|
|
608
|
+
* specs, and `Infer`'s `undefined extends …` optionality rule all answer this
|
|
609
|
+
* one question the same way.
|
|
610
|
+
* @returns `true` when an absent value parses.
|
|
611
|
+
*/
|
|
612
|
+
declare const acceptsAbsent: <TNode>(node: TNode, reader: SchemaNodeReader<TNode>) => boolean;
|
|
586
613
|
/**
|
|
587
614
|
* Build `{ type: "object", properties, required }` from a node shape.
|
|
588
615
|
*
|
|
@@ -678,4 +705,4 @@ declare const installCompiledValidatorMap: (validators: object, compiled: Compil
|
|
|
678
705
|
* which case the interpreted loop below runs and owns the result (and any error).
|
|
679
706
|
*/
|
|
680
707
|
declare const parseValidatorMap: (validators: ValidatorMap, source: Record<string, unknown>, label: string) => Record<string, unknown>;
|
|
681
|
-
export { type ArrayColumnValidator, type CheckOptions, type Column, type ColumnMeta, type ColumnValidator, type CompiledValidatorMap, DEFER_VALIDATION, type GeoPoint, type Id, type Infer, type InferInsert, type InferSelect, type InferStandardInput, type InferStandardOutput, type InferValidatorMap, type InsertShape, type JsonSchema, type JsonSchemaFragment, type MetaOptions, type NumberColumnValidator, type ObjectColumnValidator, type ParseOptions, type SchemaNodeReader, type SelectShape, type ServerDefaultContext, type StringColumnValidator, type TimestampColumnValidator, ValidationError, type ValidationPath, type Validator, type ValidatorKind, type ValidatorMap, argsToJsonSchema, describeValue, formatPath, installCompiledValidatorMap, isOrWrapsFromValidator, jsonSchemaFromNode, objectSchemaFromNodes, optionalInner, parseValidatorMap, toJsonSchema, v };
|
|
708
|
+
export { type ArrayColumnValidator, type CheckOptions, type Column, type ColumnMeta, type ColumnValidator, type CompiledValidatorMap, DEFER_VALIDATION, type GeoPoint, type Id, type Infer, type InferInsert, type InferSelect, type InferStandardInput, type InferStandardOutput, type InferValidatorMap, type InsertShape, type JsonSchema, type JsonSchemaFragment, type MetaOptions, type NumberColumnValidator, type ObjectColumnValidator, type ParseOptions, type SchemaNodeReader, type SelectShape, type ServerDefaultContext, type StringColumnValidator, type TimestampColumnValidator, ValidationError, type ValidationPath, type Validator, type ValidatorKind, type ValidatorMap, acceptsAbsent, argsToJsonSchema, describeValue, formatPath, installCompiledValidatorMap, isOrWrapsFromValidator, jsonSchemaFromNode, objectSchemaFromNodes, optionalInner, parseValidatorMap, toJsonSchema, v };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError as a,describeValue as e,formatPath as t}from"./packem_shared/ValidationError-BdVoGndu.mjs";import{
|
|
1
|
+
import{ValidationError as a,describeValue as e,formatPath as t}from"./packem_shared/ValidationError-BdVoGndu.mjs";import{acceptsAbsent as p,jsonSchemaFromNode as s,objectSchemaFromNodes as i}from"./packem_shared/acceptsAbsent-Biqy6mRN.mjs";import{argsToJsonSchema as n,toJsonSchema as c}from"./packem_shared/argsToJsonSchema-ATrQFtr_.mjs";import{isOrWrapsFromValidator as f,optionalInner as V,v as h}from"./packem_shared/isOrWrapsFromValidator-Drhf5Ake.mjs";import{DEFER_VALIDATION as F,installCompiledValidatorMap as S,parseValidatorMap as b}from"./packem_shared/DEFER_VALIDATION-C0nIiPG-.mjs";export{F as DEFER_VALIDATION,a as ValidationError,p as acceptsAbsent,n as argsToJsonSchema,e as describeValue,t as formatPath,S as installCompiledValidatorMap,f as isOrWrapsFromValidator,s as jsonSchemaFromNode,i as objectSchemaFromNodes,V as optionalInner,b as parseValidatorMap,c as toJsonSchema,h as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const r=(e,t)=>{const i=(()=>{switch(t.kind(e)){case"any":return{};case"array":{const n=t.inner(e);return{items:n===void 0?{}:r(n,t),type:"array"}}case"bigint":return{format:"int64",type:"string"};case"boolean":return{type:"boolean"};case"bytes":return{contentEncoding:"base64",description:"binary (ArrayBuffer)",type:"string"};case"date":return{description:"epoch milliseconds (date)",type:"integer"};case"geoPoint":return{description:"geographic point (WGS84 decimal degrees)",properties:{lat:{maximum:90,minimum:-90,type:"number"},lng:{maximum:180,minimum:-180,type:"number"}},required:["lat","lng"],type:"object"};case"id":return{description:`Id<"${String(t.tableName(e))}">`,type:"string","x-lunora-table":t.tableName(e)};case"literal":return t.literalSchema(e);case"null":return{type:"null"};case"number":return{type:"number"};case"object":return u(t.shape(e),t);case"optional":{const n=t.inner(e);return n===void 0?{}:r(n,t)}case"record":{const n=t.valueChild(e),o=t.keyChild(e);return{additionalProperties:n===void 0?{}:r(n,t),...o===void 0?{}:{propertyNames:r(o,t)},type:"object"}}case"storage":return{description:"storage object key",type:"string","x-lunora-storage":!0};case"string":return{type:"string"};case"timestamp":return{description:"epoch milliseconds (timestamp)",type:"integer"};case"union":return{anyOf:t.members(e).map(n=>r(n,t))};default:return{}}})(),s=t.constraints(e),c=s===void 0?i:{...i,...s};return t.isNullable(e)?{anyOf:[c,{type:"null"}]}:c},a=(e,t)=>{const i=t.kind(e);return i==="any"||i==="optional"?!0:i==="union"&&t.members(e).some(s=>a(s,t))},u=(e,t)=>{const i={},s=[];for(const[c,n]of Object.entries(e))i[c]=r(n,t),a(n,t)||s.push(c);return{properties:i,required:s,type:"object"}};export{r as jsonSchemaFromNode,u as objectSchemaFromNodes};
|
|
1
|
+
const r=(e,t)=>{const i=(()=>{switch(t.kind(e)){case"any":return{};case"array":{const n=t.inner(e);return{items:n===void 0?{}:r(n,t),type:"array"}}case"bigint":return{format:"int64",type:"string"};case"boolean":return{type:"boolean"};case"bytes":return{contentEncoding:"base64",description:"binary (ArrayBuffer)",type:"string"};case"date":return{description:"epoch milliseconds (date)",type:"integer"};case"geoPoint":return{description:"geographic point (WGS84 decimal degrees)",properties:{lat:{maximum:90,minimum:-90,type:"number"},lng:{maximum:180,minimum:-180,type:"number"}},required:["lat","lng"],type:"object"};case"id":return{description:`Id<"${String(t.tableName(e))}">`,type:"string","x-lunora-table":t.tableName(e)};case"literal":return t.literalSchema(e);case"null":return{type:"null"};case"number":return{type:"number"};case"object":return u(t.shape(e),t);case"optional":{const n=t.inner(e);return n===void 0?{}:r(n,t)}case"record":{const n=t.valueChild(e),o=t.keyChild(e);return{additionalProperties:n===void 0?{}:r(n,t),...o===void 0?{}:{propertyNames:r(o,t)},type:"object"}}case"storage":return{description:"storage object key",type:"string","x-lunora-storage":!0};case"string":return{type:"string"};case"timestamp":return{description:"epoch milliseconds (timestamp)",type:"integer"};case"union":return{anyOf:t.members(e).map(n=>r(n,t))};default:return{}}})(),s=t.constraints(e),c=s===void 0?i:{...i,...s};return t.isNullable(e)?{anyOf:[c,{type:"null"}]}:c},a=(e,t)=>{const i=t.kind(e);return i==="any"||i==="optional"?!0:i==="union"&&t.members(e).some(s=>a(s,t))},u=(e,t)=>{const i={},s=[];for(const[c,n]of Object.entries(e))i[c]=r(n,t),a(n,t)||s.push(c);return{properties:i,required:s,type:"object"}};export{a as acceptsAbsent,r as jsonSchemaFromNode,u as objectSchemaFromNodes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{objectSchemaFromNodes as n,jsonSchemaFromNode as s}from"./acceptsAbsent-Biqy6mRN.mjs";const r=e=>e,t=e=>r(e)._meta??{},a={constraints:e=>t(e).constraints,inner:e=>t(e).inner,isNullable:e=>t(e).column?.notNull===!1,keyChild:e=>t(e).keyValidator,kind:e=>e.kind,literalSchema:e=>{const{value:o}=t(e);return typeof o=="bigint"?{const:o.toString(),format:"int64",type:"string"}:{const:o}},members:e=>t(e).members,shape:e=>t(e).shape,tableName:e=>t(e).tableName,valueChild:e=>t(e).valueValidator},l=e=>s(e,a),m=e=>n(e,a);export{m as argsToJsonSchema,l as toJsonSchema};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/values",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.45",
|
|
4
4
|
"description": "Validators for Lunora: the v.* validator suite with end-to-end return-type inference",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
49
|
+
"@lunora/errors": "1.0.0-alpha.36",
|
|
50
50
|
"@standard-schema/spec": "1.1.0"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{objectSchemaFromNodes as n,jsonSchemaFromNode as s}from"./jsonSchemaFromNode-BSWBXSLL.mjs";const r=e=>e,t=e=>r(e)._meta??{},a={constraints:e=>t(e).constraints,inner:e=>t(e).inner,isNullable:e=>t(e).column?.notNull===!1,keyChild:e=>t(e).keyValidator,kind:e=>e.kind,literalSchema:e=>{const{value:o}=t(e);return typeof o=="bigint"?{const:o.toString(),format:"int64",type:"string"}:{const:o}},members:e=>t(e).members,shape:e=>t(e).shape,tableName:e=>t(e).tableName,valueChild:e=>t(e).valueValidator},l=e=>s(e,a),m=e=>n(e,a);export{m as argsToJsonSchema,l as toJsonSchema};
|