@c9up/rune 0.1.7 → 0.1.9
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/MessagesProvider.d.ts +5 -0
- package/dist/MessagesProvider.d.ts.map +1 -1
- package/dist/MessagesProvider.js +1 -1
- package/dist/MessagesProvider.js.map +1 -1
- package/dist/Schema.d.ts +831 -35
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2342 -140
- package/dist/Schema.js.map +1 -1
- package/dist/date.d.ts +36 -0
- package/dist/date.d.ts.map +1 -0
- package/dist/date.js +275 -0
- package/dist/date.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -0
- package/dist/errors.js.map +1 -1
- package/dist/formats.d.ts +148 -0
- package/dist/formats.d.ts.map +1 -0
- package/dist/formats.js +671 -0
- package/dist/formats.js.map +1 -0
- package/dist/index.d.ts +150 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +180 -1
- package/dist/index.js.map +1 -1
- package/dist/magic.d.ts +30 -0
- package/dist/magic.d.ts.map +1 -0
- package/dist/magic.js +154 -0
- package/dist/magic.js.map +1 -0
- package/dist/native.d.ts +18 -6
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js +34 -19
- package/dist/native.js.map +1 -1
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +9 -1
- package/src/MessagesProvider.ts +1 -1
- package/src/Schema.ts +3389 -177
- package/src/date.ts +320 -0
- package/src/errors.ts +11 -0
- package/src/formats.ts +776 -0
- package/src/index.ts +269 -0
- package/src/magic.ts +181 -0
- package/src/native.ts +36 -21
- package/src/types.ts +55 -0
package/dist/native.d.ts
CHANGED
|
@@ -16,12 +16,24 @@ export declare function validateNative(requestJson: string): {
|
|
|
16
16
|
data?: Record<string, unknown>;
|
|
17
17
|
};
|
|
18
18
|
export declare function isNativeAvailable(): boolean;
|
|
19
|
+
/** Raised when a schema needs the Rust engine and it is not there. */
|
|
20
|
+
export declare class RuneNativeRequiredError extends Error {
|
|
21
|
+
readonly code: "RUNE_NAPI_REQUIRED";
|
|
22
|
+
constructor();
|
|
23
|
+
}
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
+
* Refuse to validate without the native engine.
|
|
26
|
+
*
|
|
27
|
+
* There is a TypeScript validator, and it used to take over silently with a
|
|
28
|
+
* one-time warning. That made a schema's verdict depend on whether a prebuilt
|
|
29
|
+
* binary happened to load: two deployments of the same code could disagree on
|
|
30
|
+
* whether a payload is valid, and the one that fell back lost the reason to
|
|
31
|
+
* have Rust at all. A schema the engine can run is now run BY the engine or
|
|
32
|
+
* not at all.
|
|
33
|
+
*
|
|
34
|
+
* The TypeScript path stays for what the engine genuinely cannot do — custom
|
|
35
|
+
* rules, a translator, a messages provider — where it is the only
|
|
36
|
+
* implementation, not a second one.
|
|
25
37
|
*/
|
|
26
|
-
export declare function
|
|
38
|
+
export declare function assertNativeAvailable(): void;
|
|
27
39
|
//# sourceMappingURL=native.d.ts.map
|
package/dist/native.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG;IACpD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,CAaA;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG;IACpD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,CAaA;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAaD,sEAAsE;AACtE,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,EAAG,oBAAoB,CAAU;;CAQ9C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
package/dist/native.js
CHANGED
|
@@ -43,26 +43,41 @@ export function validateNative(requestJson) {
|
|
|
43
43
|
export function isNativeAvailable() {
|
|
44
44
|
return native !== undefined;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
/** Why the engine could not be loaded, phrased for whoever has to fix it. */
|
|
47
|
+
function unavailableReason() {
|
|
48
|
+
const target = `${platform}-${arch}`;
|
|
49
|
+
if (loadError !== undefined) {
|
|
50
|
+
return `failed to load (${loadError instanceof Error ? loadError.message : String(loadError)})`;
|
|
51
|
+
}
|
|
52
|
+
return platformMap[target] !== undefined
|
|
53
|
+
? "binary not found"
|
|
54
|
+
: `no prebuilt binary for ${target}`;
|
|
55
|
+
}
|
|
56
|
+
/** Raised when a schema needs the Rust engine and it is not there. */
|
|
57
|
+
export class RuneNativeRequiredError extends Error {
|
|
58
|
+
code = "RUNE_NAPI_REQUIRED";
|
|
59
|
+
constructor() {
|
|
60
|
+
super(`[RUNE_NAPI_REQUIRED] The Rust validation engine is required but not loaded — ${unavailableReason()}.\n` +
|
|
61
|
+
"Install the prebuilt binary for this platform, or build it with `pnpm build:napi`.");
|
|
62
|
+
this.name = "RuneNativeRequiredError";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
47
65
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
66
|
+
* Refuse to validate without the native engine.
|
|
67
|
+
*
|
|
68
|
+
* There is a TypeScript validator, and it used to take over silently with a
|
|
69
|
+
* one-time warning. That made a schema's verdict depend on whether a prebuilt
|
|
70
|
+
* binary happened to load: two deployments of the same code could disagree on
|
|
71
|
+
* whether a payload is valid, and the one that fell back lost the reason to
|
|
72
|
+
* have Rust at all. A schema the engine can run is now run BY the engine or
|
|
73
|
+
* not at all.
|
|
74
|
+
*
|
|
75
|
+
* The TypeScript path stays for what the engine genuinely cannot do — custom
|
|
76
|
+
* rules, a translator, a messages provider — where it is the only
|
|
77
|
+
* implementation, not a second one.
|
|
53
78
|
*/
|
|
54
|
-
export function
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
warnedFallback = true;
|
|
58
|
-
const target = `${platform}-${arch}`;
|
|
59
|
-
const reason = loadError !== undefined
|
|
60
|
-
? `failed to load (${loadError instanceof Error ? loadError.message : String(loadError)})`
|
|
61
|
-
: platformMap[target] !== undefined
|
|
62
|
-
? "binary not found"
|
|
63
|
-
: `no prebuilt binary for ${target}`;
|
|
64
|
-
console.warn(`[rune] native validation engine unavailable — ${reason}. Falling back to the ` +
|
|
65
|
-
"TypeScript validator, whose results can differ subtly from the Rust engine — " +
|
|
66
|
-
"validation is platform-dependent for this process.");
|
|
79
|
+
export function assertNativeAvailable() {
|
|
80
|
+
if (native === undefined)
|
|
81
|
+
throw new RuneNativeRequiredError();
|
|
67
82
|
}
|
|
68
83
|
//# sourceMappingURL=native.js.map
|
package/dist/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE3D,MAAM,WAAW,GAA2B;IAC3C,WAAW,EAAE,eAAe;IAC5B,aAAa,EAAE,iBAAiB;IAChC,YAAY,EAAE,YAAY;IAC1B,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,gBAAgB;CAC7B,CAAC;AAEF,IAAI,MAA0D,CAAC;AAC/D,IAAI,SAAkB,CAAC;AAEvB,IAAI,CAAC;IACJ,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;IAClD,IAAI,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,MAAM,OAAO,CAAC,CAAC,CAAC;IAChE,CAAC;AACF,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC;IACZ,SAAS,GAAG,CAAC,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,WAAmB;IAKjD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,I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CAAC,kBAAkB;QACpB,CAAC,CAAC,0BAA0B,MAAM,EAAE,CAAC;AACvC,CAAC;AAED,sEAAsE;AACtE,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,IAAI,GAAG,oBAA6B,CAAC;IAC9C;QACC,KAAK,CACJ,gFAAgF,iBAAiB,EAAE,KAAK;YACvG,oFAAoF,CACrF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB;IACpC,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,IAAI,uBAAuB,EAAE,CAAC;AAC/D,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @c9up/rune/types
|
|
3
|
+
* @description
|
|
4
|
+
* Type-only surface, mirroring `@vinejs/vine/types`.
|
|
5
|
+
*
|
|
6
|
+
* A separate subpath so a consumer can `import type { FieldContext } from
|
|
7
|
+
* "@c9up/rune/types"` exactly as it would from Vine — importing types through
|
|
8
|
+
* the value entrypoint pulls the whole module graph into a file that only
|
|
9
|
+
* needed a signature.
|
|
10
|
+
*/
|
|
11
|
+
export type { DateFormat } from "./date.js";
|
|
12
|
+
export type { AlphaOptions, EmailOptions, NormalizeEmailOptions, NormalizeUrlOptions, UrlOptions, } from "./formats.js";
|
|
13
|
+
export type { MessageArgs, MessagesProviderContract, ValidationFields, ValidationMessages, } from "./MessagesProvider.js";
|
|
14
|
+
export type { AsyncCompiledRule, AsyncRuleValidator, CompiledRule, ConditionalBranch, ConditionalGroup, CreateRuleOptions, DatabaseLookup, DatabaseResolver, DatabaseRuleOptions, ErrorReporterContract, ErrorReporterFactory, FieldContext, FileLike, HostResolver, Infer, JsonSchemaModifier, ParseContext, RuleChain, RuleDef, RuleValidator, SchemaIntrospection, UnionBranch, ValidateOptions, ValidationError, ValidationMessageParams, ValidationResult, ValidationSchema, ValidationTranslator, } from "./Schema.js";
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,GACV,MAAM,cAAc,CAAC;AACtB,YAAY,EACX,WAAW,EACX,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACX,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACpB,MAAM,aAAa,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @c9up/rune/types
|
|
3
|
+
* @description
|
|
4
|
+
* Type-only surface, mirroring `@vinejs/vine/types`.
|
|
5
|
+
*
|
|
6
|
+
* A separate subpath so a consumer can `import type { FieldContext } from
|
|
7
|
+
* "@c9up/rune/types"` exactly as it would from Vine — importing types through
|
|
8
|
+
* the value entrypoint pulls the whole module graph into a file that only
|
|
9
|
+
* needed a signature.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
package/index.darwin-arm64.node
CHANGED
|
Binary file
|
package/index.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
package/index.linux-x64-gnu.node
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c9up/rune",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Rune — Validation engine for the Ream framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,6 +27,14 @@
|
|
|
27
27
|
".": {
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./types": {
|
|
32
|
+
"types": "./dist/types.d.ts",
|
|
33
|
+
"import": "./dist/types.js"
|
|
34
|
+
},
|
|
35
|
+
"./errors": {
|
|
36
|
+
"types": "./dist/errors.d.ts",
|
|
37
|
+
"import": "./dist/errors.js"
|
|
30
38
|
}
|
|
31
39
|
},
|
|
32
40
|
"publishConfig": {
|
package/src/MessagesProvider.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface MessagesProviderContract {
|
|
|
39
39
|
* Replace a dotted field path's numeric segments with `*` so array items share
|
|
40
40
|
* a single wildcard message key — `tags.0.name` → `tags.*.name` (VineJS parity).
|
|
41
41
|
*/
|
|
42
|
-
function toWildcardPath(field: string): string {
|
|
42
|
+
export function toWildcardPath(field: string): string {
|
|
43
43
|
return field
|
|
44
44
|
.split(".")
|
|
45
45
|
.map((segment) => (/^\d+$/.test(segment) ? "*" : segment))
|