@ts-runtypes/core 0.9.2 → 0.9.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/cjs/fnHash.d.ts +8 -0
- package/dist/cjs/fnHash.js +31 -0
- package/dist/cjs/fnHashes.generated.d.ts +130 -0
- package/dist/cjs/fnHashes.generated.js +31 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/fnHash.d.ts +9 -0
- package/dist/fnHash.d.ts.map +1 -0
- package/dist/fnHash.js +29 -0
- package/dist/fnHash.js.map +1 -0
- package/dist/fnHashes.generated.d.ts +131 -0
- package/dist/fnHashes.generated.d.ts.map +1 -0
- package/dist/fnHashes.generated.js +29 -0
- package/dist/fnHashes.generated.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/fnHash.ts +67 -0
- package/src/fnHashes.generated.ts +54 -0
- package/src/index.ts +9 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FN_HASHES } from './fnHashes.generated.ts';
|
|
2
|
+
export type FnHashKey = keyof typeof FN_HASHES;
|
|
3
|
+
export interface FnHashOptions {
|
|
4
|
+
noLiterals?: boolean;
|
|
5
|
+
noIsArrayCheck?: boolean;
|
|
6
|
+
strategy?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function getFnHash(fnKey: FnHashKey | (string & {}), options?: FnHashOptions): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFnHash = getFnHash;
|
|
4
|
+
const fnHashes_generated_ts_1 = require("./fnHashes.generated.js");
|
|
5
|
+
function validateVariantToken(options) {
|
|
6
|
+
if (!options)
|
|
7
|
+
return '';
|
|
8
|
+
let suffix = 'N';
|
|
9
|
+
let hit = false;
|
|
10
|
+
for (const [name, letter] of fnHashes_generated_ts_1.VALIDATE_OPTION_LETTERS) {
|
|
11
|
+
if (options[name]) {
|
|
12
|
+
suffix += letter;
|
|
13
|
+
hit = true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return hit ? suffix : '';
|
|
17
|
+
}
|
|
18
|
+
function getFnHash(fnKey, options) {
|
|
19
|
+
const entry = fnHashes_generated_ts_1.FN_HASHES[fnKey];
|
|
20
|
+
if (!entry)
|
|
21
|
+
throw new Error(`getFnHash: unknown fnKey ${JSON.stringify(fnKey)}`);
|
|
22
|
+
let token = '';
|
|
23
|
+
if (entry.axis === 'validateOptions')
|
|
24
|
+
token = validateVariantToken(options);
|
|
25
|
+
else if (entry.axis === 'jsonStrategy')
|
|
26
|
+
token = options?.strategy ?? entry.defaultVariant ?? '';
|
|
27
|
+
const hash = entry.variants[token];
|
|
28
|
+
if (hash === undefined)
|
|
29
|
+
throw new Error(`getFnHash: fnKey ${JSON.stringify(fnKey)} has no ${JSON.stringify(token)} variant`);
|
|
30
|
+
return hash;
|
|
31
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export type FnHashAxis = 'none' | 'validateOptions' | 'jsonStrategy';
|
|
2
|
+
export interface FnHashEntry {
|
|
3
|
+
readonly axis: FnHashAxis;
|
|
4
|
+
readonly defaultVariant?: string;
|
|
5
|
+
readonly variants: Readonly<Record<string, string>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const FN_HASHES: {
|
|
8
|
+
readonly cj: {
|
|
9
|
+
readonly axis: "none";
|
|
10
|
+
readonly variants: {
|
|
11
|
+
readonly '': "xnN";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
readonly cjr: {
|
|
15
|
+
readonly axis: "none";
|
|
16
|
+
readonly variants: {
|
|
17
|
+
readonly '': "Siw";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly fb: {
|
|
21
|
+
readonly axis: "none";
|
|
22
|
+
readonly variants: {
|
|
23
|
+
readonly '': "mY6";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
readonly fmt: {
|
|
27
|
+
readonly axis: "none";
|
|
28
|
+
readonly variants: {
|
|
29
|
+
readonly '': "SS6";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly huk: {
|
|
33
|
+
readonly axis: "none";
|
|
34
|
+
readonly variants: {
|
|
35
|
+
readonly '': "trR";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly jsonDecoder: {
|
|
39
|
+
readonly axis: "jsonStrategy";
|
|
40
|
+
readonly defaultVariant: "strip";
|
|
41
|
+
readonly variants: {
|
|
42
|
+
readonly compact: "MCy";
|
|
43
|
+
readonly preserve: "J5l";
|
|
44
|
+
readonly strip: "fDV";
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
readonly jsonEncoder: {
|
|
48
|
+
readonly axis: "jsonStrategy";
|
|
49
|
+
readonly defaultVariant: "clone";
|
|
50
|
+
readonly variants: {
|
|
51
|
+
readonly clone: "wUi";
|
|
52
|
+
readonly compact: "yeS";
|
|
53
|
+
readonly direct: "y0u";
|
|
54
|
+
readonly mutate: "z1L";
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
readonly pj: {
|
|
58
|
+
readonly axis: "none";
|
|
59
|
+
readonly variants: {
|
|
60
|
+
readonly '': "tt1";
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
readonly pjs: {
|
|
64
|
+
readonly axis: "none";
|
|
65
|
+
readonly variants: {
|
|
66
|
+
readonly '': "oak";
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
readonly rj: {
|
|
70
|
+
readonly axis: "none";
|
|
71
|
+
readonly variants: {
|
|
72
|
+
readonly '': "X13";
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
readonly sj: {
|
|
76
|
+
readonly axis: "none";
|
|
77
|
+
readonly variants: {
|
|
78
|
+
readonly '': "qm4";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
readonly suk: {
|
|
82
|
+
readonly axis: "none";
|
|
83
|
+
readonly variants: {
|
|
84
|
+
readonly '': "rRP";
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
readonly tb: {
|
|
88
|
+
readonly axis: "none";
|
|
89
|
+
readonly variants: {
|
|
90
|
+
readonly '': "plZ";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
readonly uke: {
|
|
94
|
+
readonly axis: "none";
|
|
95
|
+
readonly variants: {
|
|
96
|
+
readonly '': "XFJ";
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
readonly uku: {
|
|
100
|
+
readonly axis: "none";
|
|
101
|
+
readonly variants: {
|
|
102
|
+
readonly '': "emC";
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
readonly ukuw: {
|
|
106
|
+
readonly axis: "none";
|
|
107
|
+
readonly variants: {
|
|
108
|
+
readonly '': "N3x";
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
readonly val: {
|
|
112
|
+
readonly axis: "validateOptions";
|
|
113
|
+
readonly variants: {
|
|
114
|
+
readonly '': "nPZ";
|
|
115
|
+
readonly NA: "WeU";
|
|
116
|
+
readonly NL: "N7J";
|
|
117
|
+
readonly NLA: "GYK";
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
readonly verr: {
|
|
121
|
+
readonly axis: "validateOptions";
|
|
122
|
+
readonly variants: {
|
|
123
|
+
readonly '': "pBb";
|
|
124
|
+
readonly NA: "UKg";
|
|
125
|
+
readonly NL: "LD5";
|
|
126
|
+
readonly NLA: "Yk4";
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export declare const VALIDATE_OPTION_LETTERS: readonly [readonly ["noLiterals", "L"], readonly ["noIsArrayCheck", "A"]];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VALIDATE_OPTION_LETTERS = exports.FN_HASHES = void 0;
|
|
4
|
+
exports.FN_HASHES = {
|
|
5
|
+
cj: { axis: 'none', variants: { '': 'xnN' } },
|
|
6
|
+
cjr: { axis: 'none', variants: { '': 'Siw' } },
|
|
7
|
+
fb: { axis: 'none', variants: { '': 'mY6' } },
|
|
8
|
+
fmt: { axis: 'none', variants: { '': 'SS6' } },
|
|
9
|
+
huk: { axis: 'none', variants: { '': 'trR' } },
|
|
10
|
+
jsonDecoder: { axis: 'jsonStrategy', defaultVariant: 'strip', variants: { compact: 'MCy', preserve: 'J5l', strip: 'fDV' } },
|
|
11
|
+
jsonEncoder: {
|
|
12
|
+
axis: 'jsonStrategy',
|
|
13
|
+
defaultVariant: 'clone',
|
|
14
|
+
variants: { clone: 'wUi', compact: 'yeS', direct: 'y0u', mutate: 'z1L' },
|
|
15
|
+
},
|
|
16
|
+
pj: { axis: 'none', variants: { '': 'tt1' } },
|
|
17
|
+
pjs: { axis: 'none', variants: { '': 'oak' } },
|
|
18
|
+
rj: { axis: 'none', variants: { '': 'X13' } },
|
|
19
|
+
sj: { axis: 'none', variants: { '': 'qm4' } },
|
|
20
|
+
suk: { axis: 'none', variants: { '': 'rRP' } },
|
|
21
|
+
tb: { axis: 'none', variants: { '': 'plZ' } },
|
|
22
|
+
uke: { axis: 'none', variants: { '': 'XFJ' } },
|
|
23
|
+
uku: { axis: 'none', variants: { '': 'emC' } },
|
|
24
|
+
ukuw: { axis: 'none', variants: { '': 'N3x' } },
|
|
25
|
+
val: { axis: 'validateOptions', variants: { '': 'nPZ', NA: 'WeU', NL: 'N7J', NLA: 'GYK' } },
|
|
26
|
+
verr: { axis: 'validateOptions', variants: { '': 'pBb', NA: 'UKg', NL: 'LD5', NLA: 'Yk4' } },
|
|
27
|
+
};
|
|
28
|
+
exports.VALIDATE_OPTION_LETTERS = [
|
|
29
|
+
['noLiterals', 'L'],
|
|
30
|
+
['noIsArrayCheck', 'A'],
|
|
31
|
+
];
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { FriendlyText } from './enrich/friendlyText.ts';
|
|
|
9
9
|
export type FriendlyType<T> = FriendlyText<T>;
|
|
10
10
|
export { type MockData, type MockNode } from './enrich/mockData.ts';
|
|
11
11
|
export { createFriendlyText, createFriendlyTextI18n, resolveLocale, type FriendlyMessage, type FriendlyRenderer, type FriendlyI18nOptions, } from './enrich/createFriendlyText.ts';
|
|
12
|
+
export { getFnHash, type FnHashKey, type FnHashOptions } from './fnHash.ts';
|
|
12
13
|
export { registerPureFnFactory, type PureFnId } from './runtypes/pureFn.ts';
|
|
13
14
|
import './runtypes/pure-fns-utils.ts';
|
|
14
15
|
export { registerClassSerializer, type ClassSerializerHandler, type AnyClass, type SerializableClass, type DeserializeClassFn, } from './runtypes/classSerializerRegistry.ts';
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setSerializationOptions = exports.createDataViewDeserializer = exports.createDataViewSerializer = exports.CircularReferenceError = exports.isRejectCircularRefsEnabled = exports.setRejectCircularRefs = exports.runTypeErrorsToIssues = exports.createStandardSchema = exports.createMockData = exports.overrideJsonDecoder = exports.overrideJsonEncoder = exports.overrideBinaryDecoder = exports.overrideBinaryEncoder = exports.overrideFormatTransform = exports.overrideUnknownKeysToUndefined = exports.overrideUnknownKeyErrors = exports.overrideStripUnknownKeys = exports.overrideHasUnknownKeys = exports.overrideGetValidationErrors = exports.overrideValidate = exports.createBinaryDecoder = exports.createBinarySizer = exports.createBinaryEncoder = exports.createJsonDecoder = exports.createJsonEncoder = exports.createFormatTransform = exports.createUnknownKeysToUndefined = exports.createUnknownKeyErrors = exports.createStripUnknownKeys = exports.createHasUnknownKeys = exports.createGetValidationErrors = exports.createValidate = exports.getRTFunction = exports.RunTypeSubKind = exports.RunTypeKind = exports.registerFormatPattern = exports.registerMockingFunction = exports.registerClassSerializer = exports.registerPureFnFactory = exports.resolveLocale = exports.createFriendlyTextI18n = exports.createFriendlyText = exports.getRunType = exports.getRTFnCaches = exports.getRTUtils = exports.getRunTypeId = void 0;
|
|
3
|
+
exports.setSerializationOptions = exports.createDataViewDeserializer = exports.createDataViewSerializer = exports.CircularReferenceError = exports.isRejectCircularRefsEnabled = exports.setRejectCircularRefs = exports.runTypeErrorsToIssues = exports.createStandardSchema = exports.createMockData = exports.overrideJsonDecoder = exports.overrideJsonEncoder = exports.overrideBinaryDecoder = exports.overrideBinaryEncoder = exports.overrideFormatTransform = exports.overrideUnknownKeysToUndefined = exports.overrideUnknownKeyErrors = exports.overrideStripUnknownKeys = exports.overrideHasUnknownKeys = exports.overrideGetValidationErrors = exports.overrideValidate = exports.createBinaryDecoder = exports.createBinarySizer = exports.createBinaryEncoder = exports.createJsonDecoder = exports.createJsonEncoder = exports.createFormatTransform = exports.createUnknownKeysToUndefined = exports.createUnknownKeyErrors = exports.createStripUnknownKeys = exports.createHasUnknownKeys = exports.createGetValidationErrors = exports.createValidate = exports.getRTFunction = exports.RunTypeSubKind = exports.RunTypeKind = exports.registerFormatPattern = exports.registerMockingFunction = exports.registerClassSerializer = exports.registerPureFnFactory = exports.getFnHash = exports.resolveLocale = exports.createFriendlyTextI18n = exports.createFriendlyText = exports.getRunType = exports.getRTFnCaches = exports.getRTUtils = exports.getRunTypeId = void 0;
|
|
4
4
|
var markers_ts_1 = require("./markers.js");
|
|
5
5
|
Object.defineProperty(exports, "getRunTypeId", { enumerable: true, get: function () { return markers_ts_1.getRunTypeId; } });
|
|
6
6
|
var rtUtils_ts_1 = require("./runtypes/rtUtils.js");
|
|
@@ -12,6 +12,8 @@ var createFriendlyText_ts_1 = require("./enrich/createFriendlyText.js");
|
|
|
12
12
|
Object.defineProperty(exports, "createFriendlyText", { enumerable: true, get: function () { return createFriendlyText_ts_1.createFriendlyText; } });
|
|
13
13
|
Object.defineProperty(exports, "createFriendlyTextI18n", { enumerable: true, get: function () { return createFriendlyText_ts_1.createFriendlyTextI18n; } });
|
|
14
14
|
Object.defineProperty(exports, "resolveLocale", { enumerable: true, get: function () { return createFriendlyText_ts_1.resolveLocale; } });
|
|
15
|
+
var fnHash_ts_1 = require("./fnHash.js");
|
|
16
|
+
Object.defineProperty(exports, "getFnHash", { enumerable: true, get: function () { return fnHash_ts_1.getFnHash; } });
|
|
15
17
|
var pureFn_ts_1 = require("./runtypes/pureFn.js");
|
|
16
18
|
Object.defineProperty(exports, "registerPureFnFactory", { enumerable: true, get: function () { return pureFn_ts_1.registerPureFnFactory; } });
|
|
17
19
|
require("./runtypes/pure-fns-utils.js");
|
package/dist/fnHash.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FN_HASHES } from './fnHashes.generated.ts';
|
|
2
|
+
export type FnHashKey = keyof typeof FN_HASHES;
|
|
3
|
+
export interface FnHashOptions {
|
|
4
|
+
noLiterals?: boolean;
|
|
5
|
+
noIsArrayCheck?: boolean;
|
|
6
|
+
strategy?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function getFnHash(fnKey: FnHashKey | (string & {}), options?: FnHashOptions): string;
|
|
9
|
+
//# sourceMappingURL=fnHash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fnHash.d.ts","sourceRoot":"","sources":["../src/fnHash.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAC,SAAS,EAA4C,MAAM,yBAAyB,CAAC;AAK7F,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,SAAS,CAAC;AAO/C,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAuBD,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAS3F"}
|
package/dist/fnHash.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FN_HASHES, VALIDATE_OPTION_LETTERS } from "./fnHashes.generated.js";
|
|
2
|
+
function validateVariantToken(options) {
|
|
3
|
+
if (!options)
|
|
4
|
+
return '';
|
|
5
|
+
let suffix = 'N';
|
|
6
|
+
let hit = false;
|
|
7
|
+
for (const [name, letter] of VALIDATE_OPTION_LETTERS) {
|
|
8
|
+
if (options[name]) {
|
|
9
|
+
suffix += letter;
|
|
10
|
+
hit = true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return hit ? suffix : '';
|
|
14
|
+
}
|
|
15
|
+
export function getFnHash(fnKey, options) {
|
|
16
|
+
const entry = FN_HASHES[fnKey];
|
|
17
|
+
if (!entry)
|
|
18
|
+
throw new Error(`getFnHash: unknown fnKey ${JSON.stringify(fnKey)}`);
|
|
19
|
+
let token = '';
|
|
20
|
+
if (entry.axis === 'validateOptions')
|
|
21
|
+
token = validateVariantToken(options);
|
|
22
|
+
else if (entry.axis === 'jsonStrategy')
|
|
23
|
+
token = options?.strategy ?? entry.defaultVariant ?? '';
|
|
24
|
+
const hash = entry.variants[token];
|
|
25
|
+
if (hash === undefined)
|
|
26
|
+
throw new Error(`getFnHash: fnKey ${JSON.stringify(fnKey)} has no ${JSON.stringify(token)} variant`);
|
|
27
|
+
return hash;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=fnHash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fnHash.js","sourceRoot":"","sources":["../src/fnHash.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAmB,MAAM,yBAAyB,CAAC;AAsB7F,SAAS,oBAAoB,CAAC,OAAkC;IAC9D,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,IAAI,MAAM,GAAG,GAAG,CAAC;IACjB,IAAI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5
|
+
readonly variants: Readonly<Record<string, string>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const FN_HASHES: {
|
|
8
|
+
readonly cj: {
|
|
9
|
+
readonly axis: "none";
|
|
10
|
+
readonly variants: {
|
|
11
|
+
readonly '': "xnN";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
readonly cjr: {
|
|
15
|
+
readonly axis: "none";
|
|
16
|
+
readonly variants: {
|
|
17
|
+
readonly '': "Siw";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly fb: {
|
|
21
|
+
readonly axis: "none";
|
|
22
|
+
readonly variants: {
|
|
23
|
+
readonly '': "mY6";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
readonly fmt: {
|
|
27
|
+
readonly axis: "none";
|
|
28
|
+
readonly variants: {
|
|
29
|
+
readonly '': "SS6";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly huk: {
|
|
33
|
+
readonly axis: "none";
|
|
34
|
+
readonly variants: {
|
|
35
|
+
readonly '': "trR";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly jsonDecoder: {
|
|
39
|
+
readonly axis: "jsonStrategy";
|
|
40
|
+
readonly defaultVariant: "strip";
|
|
41
|
+
readonly variants: {
|
|
42
|
+
readonly compact: "MCy";
|
|
43
|
+
readonly preserve: "J5l";
|
|
44
|
+
readonly strip: "fDV";
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
readonly jsonEncoder: {
|
|
48
|
+
readonly axis: "jsonStrategy";
|
|
49
|
+
readonly defaultVariant: "clone";
|
|
50
|
+
readonly variants: {
|
|
51
|
+
readonly clone: "wUi";
|
|
52
|
+
readonly compact: "yeS";
|
|
53
|
+
readonly direct: "y0u";
|
|
54
|
+
readonly mutate: "z1L";
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
readonly pj: {
|
|
58
|
+
readonly axis: "none";
|
|
59
|
+
readonly variants: {
|
|
60
|
+
readonly '': "tt1";
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
readonly pjs: {
|
|
64
|
+
readonly axis: "none";
|
|
65
|
+
readonly variants: {
|
|
66
|
+
readonly '': "oak";
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
readonly rj: {
|
|
70
|
+
readonly axis: "none";
|
|
71
|
+
readonly variants: {
|
|
72
|
+
readonly '': "X13";
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
readonly sj: {
|
|
76
|
+
readonly axis: "none";
|
|
77
|
+
readonly variants: {
|
|
78
|
+
readonly '': "qm4";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
readonly suk: {
|
|
82
|
+
readonly axis: "none";
|
|
83
|
+
readonly variants: {
|
|
84
|
+
readonly '': "rRP";
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
readonly tb: {
|
|
88
|
+
readonly axis: "none";
|
|
89
|
+
readonly variants: {
|
|
90
|
+
readonly '': "plZ";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
readonly uke: {
|
|
94
|
+
readonly axis: "none";
|
|
95
|
+
readonly variants: {
|
|
96
|
+
readonly '': "XFJ";
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
readonly uku: {
|
|
100
|
+
readonly axis: "none";
|
|
101
|
+
readonly variants: {
|
|
102
|
+
readonly '': "emC";
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
readonly ukuw: {
|
|
106
|
+
readonly axis: "none";
|
|
107
|
+
readonly variants: {
|
|
108
|
+
readonly '': "N3x";
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
readonly val: {
|
|
112
|
+
readonly axis: "validateOptions";
|
|
113
|
+
readonly variants: {
|
|
114
|
+
readonly '': "nPZ";
|
|
115
|
+
readonly NA: "WeU";
|
|
116
|
+
readonly NL: "N7J";
|
|
117
|
+
readonly NLA: "GYK";
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
readonly verr: {
|
|
121
|
+
readonly axis: "validateOptions";
|
|
122
|
+
readonly variants: {
|
|
123
|
+
readonly '': "pBb";
|
|
124
|
+
readonly NA: "UKg";
|
|
125
|
+
readonly NL: "LD5";
|
|
126
|
+
readonly NLA: "Yk4";
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export declare const VALIDATE_OPTION_LETTERS: readonly [readonly ["noLiterals", "L"], readonly ["noIsArrayCheck", "A"]];
|
|
131
|
+
//# sourceMappingURL=fnHashes.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fnHashes.generated.d.ts","sourceRoot":"","sources":["../src/fnHashes.generated.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAErE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAE1B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAGjC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuB0B,CAAC;AAKjD,eAAO,MAAM,uBAAuB,2EAGyB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const FN_HASHES = {
|
|
2
|
+
cj: { axis: 'none', variants: { '': 'xnN' } },
|
|
3
|
+
cjr: { axis: 'none', variants: { '': 'Siw' } },
|
|
4
|
+
fb: { axis: 'none', variants: { '': 'mY6' } },
|
|
5
|
+
fmt: { axis: 'none', variants: { '': 'SS6' } },
|
|
6
|
+
huk: { axis: 'none', variants: { '': 'trR' } },
|
|
7
|
+
jsonDecoder: { axis: 'jsonStrategy', defaultVariant: 'strip', variants: { compact: 'MCy', preserve: 'J5l', strip: 'fDV' } },
|
|
8
|
+
jsonEncoder: {
|
|
9
|
+
axis: 'jsonStrategy',
|
|
10
|
+
defaultVariant: 'clone',
|
|
11
|
+
variants: { clone: 'wUi', compact: 'yeS', direct: 'y0u', mutate: 'z1L' },
|
|
12
|
+
},
|
|
13
|
+
pj: { axis: 'none', variants: { '': 'tt1' } },
|
|
14
|
+
pjs: { axis: 'none', variants: { '': 'oak' } },
|
|
15
|
+
rj: { axis: 'none', variants: { '': 'X13' } },
|
|
16
|
+
sj: { axis: 'none', variants: { '': 'qm4' } },
|
|
17
|
+
suk: { axis: 'none', variants: { '': 'rRP' } },
|
|
18
|
+
tb: { axis: 'none', variants: { '': 'plZ' } },
|
|
19
|
+
uke: { axis: 'none', variants: { '': 'XFJ' } },
|
|
20
|
+
uku: { axis: 'none', variants: { '': 'emC' } },
|
|
21
|
+
ukuw: { axis: 'none', variants: { '': 'N3x' } },
|
|
22
|
+
val: { axis: 'validateOptions', variants: { '': 'nPZ', NA: 'WeU', NL: 'N7J', NLA: 'GYK' } },
|
|
23
|
+
verr: { axis: 'validateOptions', variants: { '': 'pBb', NA: 'UKg', NL: 'LD5', NLA: 'Yk4' } },
|
|
24
|
+
};
|
|
25
|
+
export const VALIDATE_OPTION_LETTERS = [
|
|
26
|
+
['noLiterals', 'L'],
|
|
27
|
+
['noIsArrayCheck', 'A'],
|
|
28
|
+
];
|
|
29
|
+
//# sourceMappingURL=fnHashes.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fnHashes.generated.js","sourceRoot":"","sources":["../src/fnHashes.generated.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,EAAE,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAC,EAAE,EAAE,KAAK,EAAC,EAAC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,EAAC,EAAC;IAC1C,EAAE,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAC,EAAE,EAAE,KAAK,EAAC,EAAC;IACzC,GAAG,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAC,EAAE,EAAE,KAAK,EAAC,EAAC;IAC1C,GAAG,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAC,EAAE,EAAE,KAAK,EAAC,EAAC;IAC1C,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAC,EAAE,EAAE,KAAK,EAAC,EAAC;IAC3C,GAAG,EAAE,EAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAC,EAAC;IACvF,IAAI,EAAE,EAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAC,EAAC;CAC1C,CAAC;AAKjD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,CAAC,YAAY,EAAE,GAAG,CAAC;IACnB,CAAC,gBAAgB,EAAE,GAAG,CAAC;CACoC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { FriendlyText } from './enrich/friendlyText.ts';
|
|
|
9
9
|
export type FriendlyType<T> = FriendlyText<T>;
|
|
10
10
|
export { type MockData, type MockNode } from './enrich/mockData.ts';
|
|
11
11
|
export { createFriendlyText, createFriendlyTextI18n, resolveLocale, type FriendlyMessage, type FriendlyRenderer, type FriendlyI18nOptions, } from './enrich/createFriendlyText.ts';
|
|
12
|
+
export { getFnHash, type FnHashKey, type FnHashOptions } from './fnHash.ts';
|
|
12
13
|
export { registerPureFnFactory, type PureFnId } from './runtypes/pureFn.ts';
|
|
13
14
|
import './runtypes/pure-fns-utils.ts';
|
|
14
15
|
export { registerClassSerializer, type ClassSerializerHandler, type AnyClass, type SerializableClass, type DeserializeClassFn, } from './runtypes/classSerializerRegistry.ts';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,YAAY,GACb,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,KAAK,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAK9E,OAAO,EAAC,KAAK,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAIjD,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAC,KAAK,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAKlD,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAE3D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AAC9C,OAAO,EAAC,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAOlE,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,K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5B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,WAAW,GACjB,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { getRunTypeId, } from "./markers.js";
|
|
|
2
2
|
export { getRTUtils, getRTFnCaches } from "./runtypes/rtUtils.js";
|
|
3
3
|
export { getRunType } from "./getRunType.js";
|
|
4
4
|
export { createFriendlyText, createFriendlyTextI18n, resolveLocale, } from "./enrich/createFriendlyText.js";
|
|
5
|
+
export { getFnHash } from "./fnHash.js";
|
|
5
6
|
export { registerPureFnFactory } from "./runtypes/pureFn.js";
|
|
6
7
|
import "./runtypes/pure-fns-utils.js";
|
|
7
8
|
export { registerClassSerializer, } from "./runtypes/classSerializerRegistry.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAML,YAAY,GACb,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAC,UAAU,EAAE,aAAa,EAAe,MAAM,uBAAuB,CAAC;AAS9E,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AA2B3C,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,GAId,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAML,YAAY,GACb,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAC,UAAU,EAAE,aAAa,EAAe,MAAM,uBAAuB,CAAC;AAS9E,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AA2B3C,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,GAId,MAAM,gCAAgC,CAAC;AASxC,OAAO,EAAC,SAAS,EAAqC,MAAM,aAAa,CAAC;AA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+
"version": "0.9.3",
|
|
4
4
|
"description": "Sentinel marker + canonical reflection helper for ts-runtypes. The vite plugin rewrites every call of a function whose trailing parameter type is InjectRunTypeId<T> exported from this package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"directory": "packages/ts-runtypes"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@ts-runtypes/devtools": "0.9.
|
|
81
|
+
"@ts-runtypes/devtools": "0.9.3"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "tsc --build tsconfig.json && tsc -p tsconfig.cjs.json && node ../../scripts/lib/emit-cjs-pkg.mjs dist/cjs",
|
package/src/fnHash.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// getFnHash — derive the version-independent fnHash for an RT function family
|
|
2
|
+
// (+ its compile-time options) WITHOUT the plugin-injected function tuple.
|
|
3
|
+
//
|
|
4
|
+
// The runtime cache key every createX call site resolves is `<fnHash>_<typeId>`.
|
|
5
|
+
// The typeId half is always injected by the plugin (it needs the type-checker, so
|
|
6
|
+
// a consumer can never compute it — read it from getRunTypeId / an InjectRunTypeId
|
|
7
|
+
// marker). The fnHash half is a pure function of the operation family and its
|
|
8
|
+
// compile-time options, and — since the fnHash salt no longer folds the binary
|
|
9
|
+
// version (see internal/cachegen/operations/fnhash.go) — it is STABLE across
|
|
10
|
+
// ts-runtypes releases. So a framework (e.g. mion) that holds a type's injected
|
|
11
|
+
// typeId can rebuild the full key itself:
|
|
12
|
+
//
|
|
13
|
+
// const key = getFnHash('val') + '_' + typeId; // the validate entry for T
|
|
14
|
+
//
|
|
15
|
+
// instead of hand-pinning a `family → prefix` map that used to churn on every
|
|
16
|
+
// version bump. The values come from the Go-generated fnHashes table (the single
|
|
17
|
+
// source of truth is operations.FnHashFor); nothing is hashed at runtime.
|
|
18
|
+
|
|
19
|
+
import {FN_HASHES, VALIDATE_OPTION_LETTERS, type FnHashEntry} from './fnHashes.generated.ts';
|
|
20
|
+
|
|
21
|
+
/** The Fn tokens getFnHash accepts — the InjectTypeFnArgs Fn keys for every
|
|
22
|
+
* createX factory and JSON value-level primitive (`val`, `verr`, `tb`, `fb`,
|
|
23
|
+
* `jsonEncoder`, `jsonDecoder`, `huk`, `pjs`, `cj`, …). */
|
|
24
|
+
export type FnHashKey = keyof typeof FN_HASHES;
|
|
25
|
+
|
|
26
|
+
/** Compile-time options that refine a family's fnHash — the SAME bag the createX
|
|
27
|
+
* factory takes. `noLiterals` / `noIsArrayCheck` select validate /
|
|
28
|
+
* validationErrors variants; `strategy` selects a JSON encoder / decoder
|
|
29
|
+
* variant. Options that don't apply to the resolved family are ignored (an
|
|
30
|
+
* option-less family has one fnHash regardless). */
|
|
31
|
+
export interface FnHashOptions {
|
|
32
|
+
noLiterals?: boolean;
|
|
33
|
+
noIsArrayCheck?: boolean;
|
|
34
|
+
strategy?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Mirror of Go constants.ValidateVariantSuffix: 'N' + the letters of the present
|
|
38
|
+
// options concatenated in declaration order, or '' when none is set. The letter
|
|
39
|
+
// table itself is generated from the Go source, so only this assembly is
|
|
40
|
+
// hand-written (and it is pinned by fnHash.test.ts against the generated hashes).
|
|
41
|
+
function validateVariantToken(options: FnHashOptions | undefined): string {
|
|
42
|
+
if (!options) return '';
|
|
43
|
+
let suffix = 'N';
|
|
44
|
+
let hit = false;
|
|
45
|
+
for (const [name, letter] of VALIDATE_OPTION_LETTERS) {
|
|
46
|
+
if (options[name as 'noLiterals' | 'noIsArrayCheck']) {
|
|
47
|
+
suffix += letter;
|
|
48
|
+
hit = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return hit ? suffix : '';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Resolve the version-independent fnHash for a function family (+ options).
|
|
55
|
+
* Throws on an unknown fnKey or an option combination with no matching variant
|
|
56
|
+
* (e.g. an unknown JSON `strategy`). Accepts any string so a framework can pass
|
|
57
|
+
* a dynamic key; known keys get autocomplete via FnHashKey. */
|
|
58
|
+
export function getFnHash(fnKey: FnHashKey | (string & {}), options?: FnHashOptions): string {
|
|
59
|
+
const entry = FN_HASHES[fnKey as FnHashKey] as FnHashEntry | undefined;
|
|
60
|
+
if (!entry) throw new Error(`getFnHash: unknown fnKey ${JSON.stringify(fnKey)}`);
|
|
61
|
+
let token = '';
|
|
62
|
+
if (entry.axis === 'validateOptions') token = validateVariantToken(options);
|
|
63
|
+
else if (entry.axis === 'jsonStrategy') token = options?.strategy ?? entry.defaultVariant ?? '';
|
|
64
|
+
const hash = entry.variants[token];
|
|
65
|
+
if (hash === undefined) throw new Error(`getFnHash: fnKey ${JSON.stringify(fnKey)} has no ${JSON.stringify(token)} variant`);
|
|
66
|
+
return hash;
|
|
67
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Code generated by cmd/gen-fn-hashes. DO NOT EDIT.
|
|
2
|
+
// Source: internal/cachegen/operations (the registry + fnhash.go salt).
|
|
3
|
+
// Regenerate via `pnpm run gen:fn-hashes` after changing an operation, a
|
|
4
|
+
// validate option, a JSON strategy, or the fnHash salt.
|
|
5
|
+
//
|
|
6
|
+
// Every fnHash here is VERSION-INDEPENDENT (operations.fnHashSalt no longer
|
|
7
|
+
// folds constants.Version), so the same table ships for every ts-runtypes
|
|
8
|
+
// release: a consumer resolves `fnKey (+ options) → fnHash` once and never
|
|
9
|
+
// re-pins on a version bump. The runtime cache key is `<fnHash>_<typeId>`;
|
|
10
|
+
// its typeId half (injected by the plugin) still carries the version.
|
|
11
|
+
|
|
12
|
+
export type FnHashAxis = 'none' | 'validateOptions' | 'jsonStrategy';
|
|
13
|
+
|
|
14
|
+
export interface FnHashEntry {
|
|
15
|
+
readonly axis: FnHashAxis;
|
|
16
|
+
/** jsonStrategy only: the strategy token applied when options omit `strategy`. */
|
|
17
|
+
readonly defaultVariant?: string;
|
|
18
|
+
/** Variant token → fnHash. Token is '' for option-less families, the validate
|
|
19
|
+
* variant suffix ('', 'NL', 'NA', 'NLA'), or the JSON strategy name. */
|
|
20
|
+
readonly variants: Readonly<Record<string, string>>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const FN_HASHES = {
|
|
24
|
+
cj: {axis: 'none', variants: {'': 'xnN'}},
|
|
25
|
+
cjr: {axis: 'none', variants: {'': 'Siw'}},
|
|
26
|
+
fb: {axis: 'none', variants: {'': 'mY6'}},
|
|
27
|
+
fmt: {axis: 'none', variants: {'': 'SS6'}},
|
|
28
|
+
huk: {axis: 'none', variants: {'': 'trR'}},
|
|
29
|
+
jsonDecoder: {axis: 'jsonStrategy', defaultVariant: 'strip', variants: {compact: 'MCy', preserve: 'J5l', strip: 'fDV'}},
|
|
30
|
+
jsonEncoder: {
|
|
31
|
+
axis: 'jsonStrategy',
|
|
32
|
+
defaultVariant: 'clone',
|
|
33
|
+
variants: {clone: 'wUi', compact: 'yeS', direct: 'y0u', mutate: 'z1L'},
|
|
34
|
+
},
|
|
35
|
+
pj: {axis: 'none', variants: {'': 'tt1'}},
|
|
36
|
+
pjs: {axis: 'none', variants: {'': 'oak'}},
|
|
37
|
+
rj: {axis: 'none', variants: {'': 'X13'}},
|
|
38
|
+
sj: {axis: 'none', variants: {'': 'qm4'}},
|
|
39
|
+
suk: {axis: 'none', variants: {'': 'rRP'}},
|
|
40
|
+
tb: {axis: 'none', variants: {'': 'plZ'}},
|
|
41
|
+
uke: {axis: 'none', variants: {'': 'XFJ'}},
|
|
42
|
+
uku: {axis: 'none', variants: {'': 'emC'}},
|
|
43
|
+
ukuw: {axis: 'none', variants: {'': 'N3x'}},
|
|
44
|
+
val: {axis: 'validateOptions', variants: {'': 'nPZ', NA: 'WeU', NL: 'N7J', NLA: 'GYK'}},
|
|
45
|
+
verr: {axis: 'validateOptions', variants: {'': 'pBb', NA: 'UKg', NL: 'LD5', NLA: 'Yk4'}},
|
|
46
|
+
} as const satisfies Record<string, FnHashEntry>;
|
|
47
|
+
|
|
48
|
+
/** ValidateOptions name → single-letter token, in Go declaration order
|
|
49
|
+
* (constants.ValidateOptions). The validate variant suffix is 'N' followed by
|
|
50
|
+
* the letters of the present options concatenated in THIS order. */
|
|
51
|
+
export const VALIDATE_OPTION_LETTERS = [
|
|
52
|
+
['noLiterals', 'L'],
|
|
53
|
+
['noIsArrayCheck', 'A'],
|
|
54
|
+
] as const satisfies ReadonlyArray<readonly [string, string]>;
|
package/src/index.ts
CHANGED
|
@@ -56,6 +56,15 @@ export {
|
|
|
56
56
|
type FriendlyI18nOptions,
|
|
57
57
|
} from './enrich/createFriendlyText.ts';
|
|
58
58
|
|
|
59
|
+
// getFnHash derives the version-independent fnHash for a function family (+ its
|
|
60
|
+
// compile-time options) — the fnHash half of the `<fnHash>_<typeId>` runtime
|
|
61
|
+
// cache key. A framework holding a type's injected typeId can rebuild the key
|
|
62
|
+
// itself (`getFnHash('val') + '_' + typeId`) instead of hand-pinning a
|
|
63
|
+
// family→prefix map. The hashes ride a Go-generated table (single source of
|
|
64
|
+
// truth = operations.FnHashFor); stable across releases, so consumers derive
|
|
65
|
+
// once and never re-pin on a version bump.
|
|
66
|
+
export {getFnHash, type FnHashKey, type FnHashOptions} from './fnHash.ts';
|
|
67
|
+
|
|
59
68
|
// Run-type registration is per-entry now: each marker call site imports its
|
|
60
69
|
// type's virtual entry module and registers it (plus transitive children) on
|
|
61
70
|
// first use — there is no monolithic cache module to populate up front.
|