@c9up/rune 0.1.6 → 0.1.8
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 +45 -0
- package/dist/MessagesProvider.d.ts.map +1 -0
- package/dist/MessagesProvider.js +77 -0
- package/dist/MessagesProvider.js.map +1 -0
- package/dist/Schema.d.ts +912 -38
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2841 -219
- 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 +42 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +37 -0
- package/dist/errors.js.map +1 -1
- package/dist/formats.d.ts +149 -0
- package/dist/formats.d.ts.map +1 -0
- package/dist/formats.js +612 -0
- package/dist/formats.js.map +1 -0
- package/dist/index.d.ts +152 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +181 -2
- 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/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 +11 -1
- package/src/MessagesProvider.ts +115 -0
- package/src/Schema.ts +3970 -215
- package/src/date.ts +320 -0
- package/src/errors.ts +59 -0
- package/src/formats.ts +721 -0
- package/src/index.ts +266 -1
- package/src/magic.ts +181 -0
- package/src/types.ts +55 -0
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,156 @@
|
|
|
3
3
|
* @description Rune — Validation engine for the Ream framework
|
|
4
4
|
* @implements FR38, FR39, FR40, FR41, FR42
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export type { DateFormat } from "./date.js";
|
|
7
|
+
/**
|
|
8
|
+
* Namespace import, mirroring `import { errors } from '@vinejs/vine'` — Adonis
|
|
9
|
+
* code catches on `errors.E_VALIDATION_ERROR`, so the namespace has to exist at
|
|
10
|
+
* the root and not only on the subpath.
|
|
11
|
+
*/
|
|
12
|
+
export * as errors from "./errors.js";
|
|
13
|
+
export { RuneError, RuneValidationError } from "./errors.js";
|
|
14
|
+
export type { AlphaOptions, EmailOptions, NormalizeEmailOptions, NormalizeUrlOptions, UrlOptions, } from "./formats.js";
|
|
15
|
+
export type { MessagesProviderContract } from "./MessagesProvider.js";
|
|
16
|
+
export { SimpleMessagesProvider } from "./MessagesProvider.js";
|
|
17
|
+
export type { AsyncCompiledRule, AsyncRuleValidator, CompiledRule, CreateRuleOptions, DatabaseLookup, DatabaseResolver, DatabaseRuleOptions, FieldContext, Infer, RuleChain, RuleValidator, ValidateOptions, ValidationError, ValidationMessageParams, ValidationResult, ValidationSchema, ValidationTranslator, } from "./Schema.js";
|
|
18
|
+
export { bindDatabase, bindHostResolver, bindRosetta, compile, create, createAsyncRule, createRule, rules, schema, setConvertEmptyStringsToNull, setDateTransform, setGlobalErrorReporter, setValidationTranslator, } from "./Schema.js";
|
|
19
|
+
import type { MessagesProviderContract } from "./MessagesProvider.js";
|
|
20
|
+
import type { RuleChain, ValidateOptions } from "./Schema.js";
|
|
21
|
+
import { bindDatabase, bindHostResolver, bindRosetta, compile, create, createAsyncRule, createRule, getGlobalErrorReporter, group, groupElse, groupIf, schema, setDateTransform, setGlobalErrorReporter, setValidationTranslator } from "./Schema.js";
|
|
22
|
+
/**
|
|
23
|
+
* A validator whose entry points REQUIRE `{ meta }`.
|
|
24
|
+
*
|
|
25
|
+
* VineJS refuses `validate(data)` once `withMetaData<T>()` declared metadata as
|
|
26
|
+
* required; keeping `meta` optional meant the guard existed at runtime but the
|
|
27
|
+
* compiler still waved the missing-metadata call through.
|
|
28
|
+
*/
|
|
29
|
+
type WithRequiredMeta<V, M> = {
|
|
30
|
+
[K in keyof V]: V[K] extends (data: infer D, options?: infer O) => infer R ? (data: D, options: Omit<O & object, "meta"> & {
|
|
31
|
+
meta: M;
|
|
32
|
+
}) => R : V[K];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Default export, mirroring `import vine from '@vinejs/vine'`.
|
|
36
|
+
*
|
|
37
|
+
* Named `rune`, not `vine` — the deviation is the package name, nothing else:
|
|
38
|
+
* the type factories (`rune.string()`, `rune.date()`, …) and the validator
|
|
39
|
+
* factories (`rune.create`, `rune.compile`) sit on one object exactly like
|
|
40
|
+
* VineJS, so an Adonis validator transcribes line for line.
|
|
41
|
+
*/
|
|
42
|
+
declare const rune: {
|
|
43
|
+
schema: typeof schema;
|
|
44
|
+
create: typeof create;
|
|
45
|
+
compile: typeof compile;
|
|
46
|
+
createRule: typeof createRule;
|
|
47
|
+
createAsyncRule: typeof createAsyncRule;
|
|
48
|
+
group: typeof group & {
|
|
49
|
+
if: typeof groupIf;
|
|
50
|
+
else: typeof groupElse;
|
|
51
|
+
otherwise: typeof groupElse;
|
|
52
|
+
};
|
|
53
|
+
bindDatabase: typeof bindDatabase;
|
|
54
|
+
bindHostResolver: typeof bindHostResolver;
|
|
55
|
+
bindRosetta: typeof bindRosetta;
|
|
56
|
+
setDateTransform: typeof setDateTransform;
|
|
57
|
+
setValidationTranslator: typeof setValidationTranslator;
|
|
58
|
+
/**
|
|
59
|
+
* Convert `""` to `null` before validating (VineJS
|
|
60
|
+
* `convertEmptyStringsToNull`). An HTML form posts empty inputs as `""`, and
|
|
61
|
+
* an optional field should read that as "absent", not as a present empty
|
|
62
|
+
* string that fails `minLength`.
|
|
63
|
+
*/
|
|
64
|
+
convertEmptyStringsToNull: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Predicate helpers VineJS exposes as `vine.helpers`, for writing custom
|
|
67
|
+
* rules without reimplementing the same three checks each time.
|
|
68
|
+
*/
|
|
69
|
+
helpers: {
|
|
70
|
+
/** `true` for `true`, `1`, `"1"`, `"true"`, `"on"`, `"yes"`. */
|
|
71
|
+
isTrue: (value: unknown) => boolean;
|
|
72
|
+
/** `true` for `false`, `0`, `"0"`, `"false"`, `"off"`, `"no"`. */
|
|
73
|
+
isFalse: (value: unknown) => boolean;
|
|
74
|
+
/** Neither `undefined` nor `null` (an empty string IS defined). */
|
|
75
|
+
exists: (value: unknown) => boolean;
|
|
76
|
+
/** `undefined` or `null`. */
|
|
77
|
+
isMissing: (value: unknown) => boolean;
|
|
78
|
+
/** A plain object, not an array and not `null`. */
|
|
79
|
+
isObject: (value: unknown) => value is Record<string, unknown>;
|
|
80
|
+
/** An array. */
|
|
81
|
+
isArray: (arg: any) => arg is any[];
|
|
82
|
+
/** Every listed key is present on the object (VineJS `helpers.hasKeys`). */
|
|
83
|
+
hasKeys: (value: unknown, keys: readonly string[]) => boolean;
|
|
84
|
+
/**
|
|
85
|
+
* No duplicate in the data set, optionally compared on one or more fields
|
|
86
|
+
* (VineJS `helpers.isDistinct`). `null` / `undefined` items are ignored,
|
|
87
|
+
* and items missing a compared key are SKIPPED, so two absent values are
|
|
88
|
+
* not a duplicate of each other.
|
|
89
|
+
*/
|
|
90
|
+
isDistinct: (dataSet: readonly unknown[], fields?: string | string[]) => boolean;
|
|
91
|
+
/** Read a dotted path off the validated data (VineJS `helpers.getNestedValue`). */
|
|
92
|
+
getNestedValue: (key: string, field: {
|
|
93
|
+
data: Record<string, unknown>;
|
|
94
|
+
}) => unknown;
|
|
95
|
+
/** Make every property of a shape optional (VineJS `helpers.optional`). */
|
|
96
|
+
optional: (props: Record<string, RuleChain>) => Record<string, RuleChain>;
|
|
97
|
+
};
|
|
98
|
+
/** One-shot validation, VineJS `vine.validate({ schema, data })`. */
|
|
99
|
+
validate<T extends Record<string, RuleChain>>(options: {
|
|
100
|
+
schema: T | RuleChain;
|
|
101
|
+
data: unknown;
|
|
102
|
+
} & ValidateOptions): Promise<{ [K_2 in Exclude<keyof T, { [K_1 in keyof T]: undefined extends (T[K_1] extends infer T_2 ? T_2 extends T[K_1] ? T_2 extends RuleChain<infer O> ? O : never : never : never) ? K_1 : never; }[keyof T]>]: T[K_2] extends infer T_2 ? T_2 extends T[K_2] ? T_2 extends RuleChain<infer O> ? O : never : never : never; } & { [K_3 in { [K_1 in keyof T]: undefined extends (T[K_1] extends infer T_2 ? T_2 extends T[K_1] ? T_2 extends RuleChain<infer O> ? O : never : never : never) ? K_1 : never; }[keyof T]]?: Exclude<T[K_3] extends infer T_2 ? T_2 extends T[K_3] ? T_2 extends RuleChain<infer O> ? O : never : never : never, undefined> | undefined; } extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never>;
|
|
103
|
+
/** One-shot non-throwing validation, VineJS `vine.tryValidate`. */
|
|
104
|
+
tryValidate<T extends Record<string, RuleChain>>(options: {
|
|
105
|
+
schema: T | RuleChain;
|
|
106
|
+
data: unknown;
|
|
107
|
+
} & ValidateOptions): Promise<[import("./errors.js").RuneValidationError, null] | [null, { [K_2 in Exclude<keyof T, { [K_1 in keyof T]: undefined extends (T[K_1] extends infer T_2 ? T_2 extends T[K_1] ? T_2 extends RuleChain<infer O> ? O : never : never : never) ? K_1 : never; }[keyof T]>]: T[K_2] extends infer T_2 ? T_2 extends T[K_2] ? T_2 extends RuleChain<infer O> ? O : never : never : never; } & { [K_3 in { [K_1 in keyof T]: undefined extends (T[K_1] extends infer T_2 ? T_2 extends T[K_1] ? T_2 extends RuleChain<infer O> ? O : never : never : never) ? K_1 : never; }[keyof T]]?: Exclude<T[K_3] extends infer T_2 ? T_2 extends T[K_3] ? T_2 extends RuleChain<infer O> ? O : never : never : never, undefined> | undefined; } extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never]>;
|
|
108
|
+
/**
|
|
109
|
+
* Type the `meta` passed to `validate(data, { meta })` (VineJS
|
|
110
|
+
* `withMetaData`). Purely a typing seam — rune carries meta on the call.
|
|
111
|
+
*/
|
|
112
|
+
withMetaData<M extends Record<string, unknown>>(validateMeta?: (meta: M) => void): {
|
|
113
|
+
create<T extends Record<string, RuleChain>>(fields: T): WithRequiredMeta<ReturnType<typeof create<T>>, M>;
|
|
114
|
+
};
|
|
115
|
+
get errorReporter(): ReturnType<typeof getGlobalErrorReporter>;
|
|
116
|
+
/** Process-wide error reporter (VineJS `vine.errorReporter`). */
|
|
117
|
+
set errorReporter(reporter: Parameters<typeof setGlobalErrorReporter>[0]);
|
|
118
|
+
/** Bind the global messages provider (VineJS `vine.messagesProvider`). */
|
|
119
|
+
messagesProvider: MessagesProviderContract | null;
|
|
120
|
+
string: () => RuleChain<string>;
|
|
121
|
+
number: (options?: {
|
|
122
|
+
strict?: boolean;
|
|
123
|
+
}) => RuleChain<number>;
|
|
124
|
+
boolean: (options?: {
|
|
125
|
+
strict?: boolean;
|
|
126
|
+
}) => RuleChain<boolean>;
|
|
127
|
+
any: () => RuleChain<unknown>;
|
|
128
|
+
date: (options?: {
|
|
129
|
+
formats?: import("./date.js").DateFormat[];
|
|
130
|
+
}) => RuleChain<Date>;
|
|
131
|
+
accepted: () => RuleChain<true>;
|
|
132
|
+
file: (options?: {
|
|
133
|
+
size?: number | string;
|
|
134
|
+
extnames?: readonly string[];
|
|
135
|
+
verifyContent?: boolean;
|
|
136
|
+
}) => RuleChain<import("./Schema.js").FileLike>;
|
|
137
|
+
nativeFile: (options?: {
|
|
138
|
+
minSize?: number | string;
|
|
139
|
+
maxSize?: number | string;
|
|
140
|
+
mimeTypes?: readonly string[];
|
|
141
|
+
}) => RuleChain<import("./Schema.js").FileLike>;
|
|
142
|
+
record: <Item extends RuleChain>(valueChain: Item) => RuleChain<Record<string, Item extends RuleChain<infer O> ? O : never>>;
|
|
143
|
+
tuple: <const Items extends readonly RuleChain[]>(items: Items) => RuleChain<{ [K in keyof Items]: Items[K] extends infer T ? T extends Items[K] ? T extends RuleChain<infer O> ? O : never : never : never; }>;
|
|
144
|
+
union: ((chains: readonly import("./Schema.js").UnionBranch[]) => RuleChain) & {
|
|
145
|
+
if: typeof import("./Schema.js").unionIf;
|
|
146
|
+
else: typeof import("./Schema.js").unionElse;
|
|
147
|
+
otherwise: typeof import("./Schema.js").unionElse;
|
|
148
|
+
};
|
|
149
|
+
optional: () => RuleChain<undefined>;
|
|
150
|
+
null: () => RuleChain<null>;
|
|
151
|
+
unionOfTypes: (chains: readonly RuleChain[]) => RuleChain;
|
|
152
|
+
object: <Sh extends Record<string, RuleChain>>(shape: Sh) => RuleChain<import("./Schema.js").Infer<Sh>>;
|
|
153
|
+
array: <Item extends RuleChain>(item?: Item) => RuleChain<(Item extends RuleChain<infer O> ? O : never)[]>;
|
|
154
|
+
enum: <const V extends readonly (string | number | boolean)[]>(values: V) => RuleChain<V[number]>;
|
|
155
|
+
literal: <V extends string | number | boolean>(value: V) => RuleChain<V>;
|
|
156
|
+
};
|
|
157
|
+
export default rune;
|
|
9
158
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,GACV,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,wBAAwB,EAAE,MAAM,uB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C9B;QACF,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EACzC,MAAM,EAAE,CAAC,GACP,gBAAgB,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACrD;yBAoCoB,UAAU,CAAC,OAAO,sBAAsB,CAAC;IAJ9D,iEAAiE;gCACrC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAMxE,0EAA0E;sBAC3C,wBAAwB,GAAG,IAAI;;;cASw95H,CAAC;;;cAAmG,CAAC;;;;eAAoJ,CAAC;;;;YAA+J,CAAC;gBAA6B,CAAC;qBAAoC,CAAC;;;eAAyG,CAAC;eAA4B,CAAC;iBAA8B,CAAC;;;;;;;;;;;;;;;;CAHzp7H,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,185 @@
|
|
|
3
3
|
* @description Rune — Validation engine for the Ream framework
|
|
4
4
|
* @implements FR38, FR39, FR40, FR41, FR42
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Namespace import, mirroring `import { errors } from '@vinejs/vine'` — Adonis
|
|
8
|
+
* code catches on `errors.E_VALIDATION_ERROR`, so the namespace has to exist at
|
|
9
|
+
* the root and not only on the subpath.
|
|
10
|
+
*/
|
|
11
|
+
export * as errors from "./errors.js";
|
|
12
|
+
export { RuneError, RuneValidationError } from "./errors.js";
|
|
13
|
+
export { SimpleMessagesProvider } from "./MessagesProvider.js";
|
|
14
|
+
export { bindDatabase, bindHostResolver, bindRosetta, compile, create, createAsyncRule, createRule, rules, schema, setConvertEmptyStringsToNull, setDateTransform, setGlobalErrorReporter, setValidationTranslator, } from "./Schema.js";
|
|
15
|
+
import { bindDatabase, bindHostResolver, bindRosetta, compile, create, createAsyncRule, createRule, getConvertEmptyStringsToNull, getGlobalErrorReporter, getGlobalMessagesProvider, group, groupElse, groupIf, rules, schema, setConvertEmptyStringsToNull, setDateTransform, setGlobalErrorReporter, setGlobalMessagesProvider, setValidationTranslator, } from "./Schema.js";
|
|
16
|
+
/**
|
|
17
|
+
* Default export, mirroring `import vine from '@vinejs/vine'`.
|
|
18
|
+
*
|
|
19
|
+
* Named `rune`, not `vine` — the deviation is the package name, nothing else:
|
|
20
|
+
* the type factories (`rune.string()`, `rune.date()`, …) and the validator
|
|
21
|
+
* factories (`rune.create`, `rune.compile`) sit on one object exactly like
|
|
22
|
+
* VineJS, so an Adonis validator transcribes line for line.
|
|
23
|
+
*/
|
|
24
|
+
const rune = {
|
|
25
|
+
...rules,
|
|
26
|
+
schema,
|
|
27
|
+
create,
|
|
28
|
+
compile,
|
|
29
|
+
createRule,
|
|
30
|
+
createAsyncRule,
|
|
31
|
+
// `group` carries its branch factories, mirroring `vine.group.if/else`.
|
|
32
|
+
group: Object.assign(group, {
|
|
33
|
+
if: groupIf,
|
|
34
|
+
else: groupElse,
|
|
35
|
+
otherwise: groupElse,
|
|
36
|
+
}),
|
|
37
|
+
bindDatabase,
|
|
38
|
+
bindHostResolver,
|
|
39
|
+
bindRosetta,
|
|
40
|
+
setDateTransform,
|
|
41
|
+
setValidationTranslator,
|
|
42
|
+
/**
|
|
43
|
+
* Convert `""` to `null` before validating (VineJS
|
|
44
|
+
* `convertEmptyStringsToNull`). An HTML form posts empty inputs as `""`, and
|
|
45
|
+
* an optional field should read that as "absent", not as a present empty
|
|
46
|
+
* string that fails `minLength`.
|
|
47
|
+
*/
|
|
48
|
+
set convertEmptyStringsToNull(enabled) {
|
|
49
|
+
setConvertEmptyStringsToNull(enabled);
|
|
50
|
+
},
|
|
51
|
+
get convertEmptyStringsToNull() {
|
|
52
|
+
return getConvertEmptyStringsToNull();
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Predicate helpers VineJS exposes as `vine.helpers`, for writing custom
|
|
56
|
+
* rules without reimplementing the same three checks each time.
|
|
57
|
+
*/
|
|
58
|
+
helpers: {
|
|
59
|
+
/** `true` for `true`, `1`, `"1"`, `"true"`, `"on"`, `"yes"`. */
|
|
60
|
+
isTrue: (value) => value === true ||
|
|
61
|
+
value === 1 ||
|
|
62
|
+
(typeof value === "string" &&
|
|
63
|
+
["1", "true", "on", "yes"].includes(value.toLowerCase())),
|
|
64
|
+
/** `true` for `false`, `0`, `"0"`, `"false"`, `"off"`, `"no"`. */
|
|
65
|
+
isFalse: (value) => value === false ||
|
|
66
|
+
value === 0 ||
|
|
67
|
+
(typeof value === "string" &&
|
|
68
|
+
["0", "false", "off", "no"].includes(value.toLowerCase())),
|
|
69
|
+
/** Neither `undefined` nor `null` (an empty string IS defined). */
|
|
70
|
+
exists: (value) => value !== undefined && value !== null,
|
|
71
|
+
/** `undefined` or `null`. */
|
|
72
|
+
isMissing: (value) => value === undefined || value === null,
|
|
73
|
+
/** A plain object, not an array and not `null`. */
|
|
74
|
+
isObject: (value) => typeof value === "object" && value !== null && !Array.isArray(value),
|
|
75
|
+
/** An array. */
|
|
76
|
+
isArray: Array.isArray,
|
|
77
|
+
/** Every listed key is present on the object (VineJS `helpers.hasKeys`). */
|
|
78
|
+
hasKeys: (value, keys) => typeof value === "object" &&
|
|
79
|
+
value !== null &&
|
|
80
|
+
keys.every((key) => key in value),
|
|
81
|
+
/**
|
|
82
|
+
* No duplicate in the data set, optionally compared on one or more fields
|
|
83
|
+
* (VineJS `helpers.isDistinct`). `null` / `undefined` items are ignored,
|
|
84
|
+
* and items missing a compared key are SKIPPED, so two absent values are
|
|
85
|
+
* not a duplicate of each other.
|
|
86
|
+
*/
|
|
87
|
+
isDistinct: (dataSet, fields) => {
|
|
88
|
+
const list = fields === undefined ? null : [fields].flat();
|
|
89
|
+
const keys = [];
|
|
90
|
+
for (const item of dataSet) {
|
|
91
|
+
if (item === null || item === undefined)
|
|
92
|
+
continue;
|
|
93
|
+
if (list === null) {
|
|
94
|
+
keys.push(JSON.stringify(item));
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (typeof item !== "object" || item === null)
|
|
98
|
+
continue;
|
|
99
|
+
const record = { ...item };
|
|
100
|
+
if (list.some((k) => record[k] === undefined || record[k] === null)) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
keys.push(JSON.stringify(list.map((k) => record[k])));
|
|
104
|
+
}
|
|
105
|
+
return new Set(keys).size === keys.length;
|
|
106
|
+
},
|
|
107
|
+
/** Read a dotted path off the validated data (VineJS `helpers.getNestedValue`). */
|
|
108
|
+
getNestedValue: (key, field) => {
|
|
109
|
+
let cursor = field.data;
|
|
110
|
+
for (const segment of key.split(".")) {
|
|
111
|
+
if (typeof cursor !== "object" || cursor === null)
|
|
112
|
+
return undefined;
|
|
113
|
+
cursor = cursor[segment];
|
|
114
|
+
}
|
|
115
|
+
return cursor;
|
|
116
|
+
},
|
|
117
|
+
/** Make every property of a shape optional (VineJS `helpers.optional`). */
|
|
118
|
+
optional: (props) => Object.fromEntries(Object.entries(props).map(([key, chain]) => [
|
|
119
|
+
key,
|
|
120
|
+
chain.clone().optional(),
|
|
121
|
+
])),
|
|
122
|
+
},
|
|
123
|
+
/** One-shot validation, VineJS `vine.validate({ schema, data })`. */
|
|
124
|
+
validate(options) {
|
|
125
|
+
// Spread the whole ValidateOptions rather than re-listing its keys: the
|
|
126
|
+
// hand-listed version silently dropped `errorReporter` when it was added.
|
|
127
|
+
const { schema: fields, data, ...validateOptions } = options;
|
|
128
|
+
return create(fields).validate(data, validateOptions);
|
|
129
|
+
},
|
|
130
|
+
/** One-shot non-throwing validation, VineJS `vine.tryValidate`. */
|
|
131
|
+
tryValidate(options) {
|
|
132
|
+
// Spread the whole ValidateOptions rather than re-listing its keys: the
|
|
133
|
+
// hand-listed version silently dropped `errorReporter` when it was added.
|
|
134
|
+
const { schema: fields, data, ...validateOptions } = options;
|
|
135
|
+
return create(fields).tryValidate(data, validateOptions);
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* Type the `meta` passed to `validate(data, { meta })` (VineJS
|
|
139
|
+
* `withMetaData`). Purely a typing seam — rune carries meta on the call.
|
|
140
|
+
*/
|
|
141
|
+
withMetaData(validateMeta) {
|
|
142
|
+
return {
|
|
143
|
+
create(fields) {
|
|
144
|
+
const validator = create(fields);
|
|
145
|
+
if (!validateMeta) {
|
|
146
|
+
return validator;
|
|
147
|
+
}
|
|
148
|
+
// The callback runs BEFORE the payload: meta that is wrong makes
|
|
149
|
+
// every rule reading it meaningless, so failing early is the only
|
|
150
|
+
// honest outcome.
|
|
151
|
+
const guard = (run) => {
|
|
152
|
+
return (...args) => {
|
|
153
|
+
const options = args[1];
|
|
154
|
+
validateMeta((options?.meta ?? {}));
|
|
155
|
+
return run(...args);
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
return {
|
|
159
|
+
...validator,
|
|
160
|
+
validate: guard(validator.validate),
|
|
161
|
+
validateResult: guard(validator.validateResult),
|
|
162
|
+
validateResultAsync: guard(validator.validateResultAsync),
|
|
163
|
+
validateOrThrow: guard(validator.validateOrThrow),
|
|
164
|
+
validateOrThrowAsync: guard(validator.validateOrThrowAsync),
|
|
165
|
+
tryValidate: guard(validator.tryValidate),
|
|
166
|
+
tryValidateSync: guard(validator.tryValidateSync),
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
/** Process-wide error reporter (VineJS `vine.errorReporter`). */
|
|
172
|
+
set errorReporter(reporter) {
|
|
173
|
+
setGlobalErrorReporter(reporter);
|
|
174
|
+
},
|
|
175
|
+
get errorReporter() {
|
|
176
|
+
return getGlobalErrorReporter();
|
|
177
|
+
},
|
|
178
|
+
/** Bind the global messages provider (VineJS `vine.messagesProvider`). */
|
|
179
|
+
set messagesProvider(provider) {
|
|
180
|
+
setGlobalMessagesProvider(provider);
|
|
181
|
+
},
|
|
182
|
+
get messagesProvider() {
|
|
183
|
+
return getGlobalMessagesProvider();
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
export default rune;
|
|
8
187
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAS7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAoB/D,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,MAAM,EACN,eAAe,EACf,UAAU,EACV,KAAK,EACL,MAAM,EACN,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,GACvB,MAAM,aAAa,CAAC;AAIrB,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,MAAM,EACN,eAAe,EACf,UAAU,EACV,4BAA4B,EAC5B,sBAAsB,EACtB,yBAAyB,EACzB,KAAK,EACL,SAAS,EACT,OAAO,EACP,KAAK,EACL,MAAM,EACN,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,GACvB,MAAM,aAAa,CAAC;AAerB;;;;;;;GAOG;AACH,MAAM,IAAI,GAAG;IACZ,GAAG,KAAK;IACR,MAAM;IACN,MAAM;IACN,OAAO;IACP,UAAU;IACV,eAAe;IACf,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;QAC3B,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,SAAS;QACf,SAAS,EAAE,SAAS;KACpB,CAAC;IACF,YAAY;IACZ,gBAAgB;IAChB,WAAW;IAC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AC;IACD,IAAI,gBAAgB;QACnB,OAAO,yBAAyB,EAAE,CAAC;IACpC,CAAC;CACD,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/dist/magic.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-based file type detection — magic numbers.
|
|
3
|
+
*
|
|
4
|
+
* Adonis rejects a `.exe` renamed to `.jpg` because its bodyparser sniffs the
|
|
5
|
+
* real bytes. rune validates a structural object, so on its own it can only
|
|
6
|
+
* trust what the upload DECLARES. This module closes that gap when a byte
|
|
7
|
+
* source is reachable: no external dependency, just the signature table and
|
|
8
|
+
* `node:fs` to read the first bytes.
|
|
9
|
+
*
|
|
10
|
+
* Signatures are matched at their documented offsets, longest-first, so a
|
|
11
|
+
* container that shares a prefix with another format is not mistaken for it.
|
|
12
|
+
*/
|
|
13
|
+
/** How many leading bytes are enough for every signature above. */
|
|
14
|
+
export declare const MAGIC_HEAD_BYTES = 32;
|
|
15
|
+
/** The detected type of a byte head, or `null` when nothing matches. */
|
|
16
|
+
export interface DetectedType {
|
|
17
|
+
ext: string;
|
|
18
|
+
mime: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Detect the type of a byte head. Returns `null` when no signature matches —
|
|
22
|
+
* never a guess: an unrecognised head must be reported as unrecognised, not
|
|
23
|
+
* silently accepted as whatever was declared.
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectFileType(head: Uint8Array): DetectedType | null;
|
|
26
|
+
/** Read the leading bytes of a file. */
|
|
27
|
+
export declare function readHead(path: string, length?: number): Promise<Uint8Array>;
|
|
28
|
+
/** Is `declared` an acceptable spelling of `detected`? */
|
|
29
|
+
export declare function extensionMatches(detected: string, declared: string): boolean;
|
|
30
|
+
//# sourceMappingURL=magic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magic.d.ts","sourceRoot":"","sources":["../src/magic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA8GH,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACb;AAWD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY,GAAG,IAAI,CAMpE;AAED,wCAAwC;AACxC,wBAAsB,QAAQ,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,SAAmB,GACvB,OAAO,CAAC,UAAU,CAAC,CASrB;AAWD,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG5E"}
|
package/dist/magic.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-based file type detection — magic numbers.
|
|
3
|
+
*
|
|
4
|
+
* Adonis rejects a `.exe` renamed to `.jpg` because its bodyparser sniffs the
|
|
5
|
+
* real bytes. rune validates a structural object, so on its own it can only
|
|
6
|
+
* trust what the upload DECLARES. This module closes that gap when a byte
|
|
7
|
+
* source is reachable: no external dependency, just the signature table and
|
|
8
|
+
* `node:fs` to read the first bytes.
|
|
9
|
+
*
|
|
10
|
+
* Signatures are matched at their documented offsets, longest-first, so a
|
|
11
|
+
* container that shares a prefix with another format is not mistaken for it.
|
|
12
|
+
*/
|
|
13
|
+
import { open } from "node:fs/promises";
|
|
14
|
+
const ascii = (text) => [...text].map((char) => char.charCodeAt(0));
|
|
15
|
+
/**
|
|
16
|
+
* Ordered longest-pattern-first within an offset group. `zip` sits LAST of the
|
|
17
|
+
* PK family because docx/xlsx/pptx are zip containers: matching `zip` first
|
|
18
|
+
* would label every Office document a zip.
|
|
19
|
+
*/
|
|
20
|
+
const SIGNATURES = [
|
|
21
|
+
{
|
|
22
|
+
ext: "png",
|
|
23
|
+
mime: "image/png",
|
|
24
|
+
offset: 0,
|
|
25
|
+
bytes: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a],
|
|
26
|
+
},
|
|
27
|
+
{ ext: "jpg", mime: "image/jpeg", offset: 0, bytes: [0xff, 0xd8, 0xff] },
|
|
28
|
+
{ ext: "gif", mime: "image/gif", offset: 0, bytes: ascii("GIF8") },
|
|
29
|
+
{ ext: "bmp", mime: "image/bmp", offset: 0, bytes: ascii("BM") },
|
|
30
|
+
{ ext: "webp", mime: "image/webp", offset: 8, bytes: ascii("WEBP") },
|
|
31
|
+
{ ext: "avif", mime: "image/avif", offset: 4, bytes: ascii("ftypavif") },
|
|
32
|
+
{ ext: "heic", mime: "image/heic", offset: 4, bytes: ascii("ftypheic") },
|
|
33
|
+
{
|
|
34
|
+
ext: "tif",
|
|
35
|
+
mime: "image/tiff",
|
|
36
|
+
offset: 0,
|
|
37
|
+
bytes: [0x49, 0x49, 0x2a, 0x00],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
ext: "tif",
|
|
41
|
+
mime: "image/tiff",
|
|
42
|
+
offset: 0,
|
|
43
|
+
bytes: [0x4d, 0x4d, 0x00, 0x2a],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
ext: "ico",
|
|
47
|
+
mime: "image/x-icon",
|
|
48
|
+
offset: 0,
|
|
49
|
+
bytes: [0x00, 0x00, 0x01, 0x00],
|
|
50
|
+
},
|
|
51
|
+
{ ext: "pdf", mime: "application/pdf", offset: 0, bytes: ascii("%PDF-") },
|
|
52
|
+
{ ext: "mp4", mime: "video/mp4", offset: 4, bytes: ascii("ftyp") },
|
|
53
|
+
{
|
|
54
|
+
ext: "webm",
|
|
55
|
+
mime: "video/webm",
|
|
56
|
+
offset: 0,
|
|
57
|
+
bytes: [0x1a, 0x45, 0xdf, 0xa3],
|
|
58
|
+
},
|
|
59
|
+
{ ext: "ogg", mime: "audio/ogg", offset: 0, bytes: ascii("OggS") },
|
|
60
|
+
{ ext: "wav", mime: "audio/wav", offset: 8, bytes: ascii("WAVE") },
|
|
61
|
+
{ ext: "mp3", mime: "audio/mpeg", offset: 0, bytes: ascii("ID3") },
|
|
62
|
+
{ ext: "mp3", mime: "audio/mpeg", offset: 0, bytes: [0xff, 0xfb] },
|
|
63
|
+
{ ext: "flac", mime: "audio/flac", offset: 0, bytes: ascii("fLaC") },
|
|
64
|
+
{ ext: "gz", mime: "application/gzip", offset: 0, bytes: [0x1f, 0x8b] },
|
|
65
|
+
{ ext: "bz2", mime: "application/x-bzip2", offset: 0, bytes: ascii("BZh") },
|
|
66
|
+
{
|
|
67
|
+
ext: "7z",
|
|
68
|
+
mime: "application/x-7z-compressed",
|
|
69
|
+
offset: 0,
|
|
70
|
+
bytes: [0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c],
|
|
71
|
+
},
|
|
72
|
+
{ ext: "rar", mime: "application/vnd.rar", offset: 0, bytes: ascii("Rar!") },
|
|
73
|
+
{
|
|
74
|
+
ext: "zip",
|
|
75
|
+
mime: "application/zip",
|
|
76
|
+
offset: 0,
|
|
77
|
+
bytes: [0x50, 0x4b, 0x03, 0x04],
|
|
78
|
+
},
|
|
79
|
+
// Executables — the whole point of sniffing: these must never pass as media.
|
|
80
|
+
{
|
|
81
|
+
ext: "exe",
|
|
82
|
+
mime: "application/vnd.microsoft.portable-executable",
|
|
83
|
+
offset: 0,
|
|
84
|
+
bytes: ascii("MZ"),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
ext: "elf",
|
|
88
|
+
mime: "application/x-elf",
|
|
89
|
+
offset: 0,
|
|
90
|
+
bytes: [0x7f, 0x45, 0x4c, 0x46],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
ext: "class",
|
|
94
|
+
mime: "application/java-vm",
|
|
95
|
+
offset: 0,
|
|
96
|
+
bytes: [0xca, 0xfe, 0xba, 0xbe],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
ext: "wasm",
|
|
100
|
+
mime: "application/wasm",
|
|
101
|
+
offset: 0,
|
|
102
|
+
bytes: [0x00, 0x61, 0x73, 0x6d],
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
/** How many leading bytes are enough for every signature above. */
|
|
106
|
+
export const MAGIC_HEAD_BYTES = 32;
|
|
107
|
+
/** Does `head` carry `signature` at its documented offset? */
|
|
108
|
+
function matches(head, signature) {
|
|
109
|
+
if (head.length < signature.offset + signature.bytes.length)
|
|
110
|
+
return false;
|
|
111
|
+
return signature.bytes.every((byte, index) => {
|
|
112
|
+
if (byte === null)
|
|
113
|
+
return true;
|
|
114
|
+
return head[signature.offset + index] === byte;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Detect the type of a byte head. Returns `null` when no signature matches —
|
|
119
|
+
* never a guess: an unrecognised head must be reported as unrecognised, not
|
|
120
|
+
* silently accepted as whatever was declared.
|
|
121
|
+
*/
|
|
122
|
+
export function detectFileType(head) {
|
|
123
|
+
for (const signature of SIGNATURES) {
|
|
124
|
+
if (matches(head, signature))
|
|
125
|
+
return { ext: signature.ext, mime: signature.mime };
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
/** Read the leading bytes of a file. */
|
|
130
|
+
export async function readHead(path, length = MAGIC_HEAD_BYTES) {
|
|
131
|
+
const handle = await open(path, "r");
|
|
132
|
+
try {
|
|
133
|
+
const buffer = new Uint8Array(length);
|
|
134
|
+
const { bytesRead } = await handle.read(buffer, 0, length, 0);
|
|
135
|
+
return buffer.subarray(0, bytesRead);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
await handle.close();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Extensions that a given detected type legitimately covers. */
|
|
142
|
+
const ALIASES = {
|
|
143
|
+
jpg: ["jpg", "jpeg"],
|
|
144
|
+
tif: ["tif", "tiff"],
|
|
145
|
+
// A zip container is what an Office document actually is on the wire.
|
|
146
|
+
zip: ["zip", "docx", "xlsx", "pptx", "odt", "ods", "odp", "epub", "jar"],
|
|
147
|
+
mp4: ["mp4", "m4v", "m4a", "mov"],
|
|
148
|
+
};
|
|
149
|
+
/** Is `declared` an acceptable spelling of `detected`? */
|
|
150
|
+
export function extensionMatches(detected, declared) {
|
|
151
|
+
const normalized = declared.replace(/^\./, "").toLowerCase();
|
|
152
|
+
return (ALIASES[detected] ?? [detected]).includes(normalized);
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=magic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magic.js","sourceRoot":"","sources":["../src/magic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAcxC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAY,EAAE,CACxC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7C;;;;GAIG;AACH,MAAM,UAAU,GAAyB;IACxC;QACC,GAAG,EAAE,KAAK;QACV,IAAI,EAAE,WAAW;QACjB,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;KACvD;IACD,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;IACxE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE;IAClE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,WA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AE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;CACjC,CAAC;AAEF,0DAA0D;AAC1D,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,QAAgB;IAClE,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC7D,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,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
|