libshv-js 3.17.0 → 3.20.0
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/access.d.ts +69 -0
- package/dist/access.js +98 -0
- package/dist/chainpack.d.ts +39 -0
- package/dist/chainpack.js +562 -0
- package/dist/cpcontext.d.ts +18 -0
- package/dist/cpcontext.js +78 -0
- package/dist/cpon.d.ts +55 -0
- package/dist/cpon.js +900 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +26 -0
- package/dist/json.d.ts +3 -0
- package/dist/json.js +118 -0
- package/dist/rpcmessage.d.ts +285 -0
- package/dist/rpcmessage.js +111 -0
- package/dist/rpcvalue.d.ts +56 -0
- package/dist/rpcvalue.js +100 -0
- package/dist/vue-shv.d.ts +91 -0
- package/dist/vue-shv.js +424 -0
- package/dist/ws-client.d.ts +232 -0
- package/dist/ws-client.js +586 -0
- package/dist/zod.d.ts +30 -0
- package/dist/zod.js +112 -0
- package/package.json +1 -1
package/dist/zod.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.withMeta = exports.rpcvalue = exports.list = exports.blob = exports.decimal = exports.double = exports.uint = exports.recmap = exports.metamap = exports.imap = exports.map = void 0;
|
|
18
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
19
|
+
const v4_1 = require("zod/v4");
|
|
20
|
+
const rpcvalue_1 = require("./rpcvalue");
|
|
21
|
+
const implMakeMapParser = (mapValidator, _mapBrand, mapName, objectParser) => v4_1.z.custom().check(ctx => {
|
|
22
|
+
if (!mapValidator(ctx.value)) {
|
|
23
|
+
ctx.issues.push({
|
|
24
|
+
expected: 'map',
|
|
25
|
+
code: 'invalid_type',
|
|
26
|
+
input: ctx.value,
|
|
27
|
+
message: `Invalid input: expected ${mapName}, received ${(0, rpcvalue_1.typeName)(ctx.value)}`,
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// For record, Zod finds out map brand, and calls the record's value parser with the value. There's no way to detect
|
|
32
|
+
// it, because Zod does not supply the parser with the key. To prevent this, remove the key before passing the value
|
|
33
|
+
// to Zod. This unfortunately means that we need to copy the whole object. :/
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
+
const { [rpcvalue_1.shvMapType]: zodMustNotHaveThis, ...rest } = { ...ctx.value };
|
|
36
|
+
const parsedObject = objectParser.safeParse(rest);
|
|
37
|
+
if (!parsedObject.success) {
|
|
38
|
+
ctx.issues = parsedObject.error.issues;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const map = (schema) => implMakeMapParser(rpcvalue_1.isShvMap, 'map', 'ShvMap', v4_1.z.object(schema));
|
|
42
|
+
exports.map = map;
|
|
43
|
+
const imap = (schema) => implMakeMapParser(rpcvalue_1.isIMap, 'imap', 'IMap', v4_1.z.object(schema));
|
|
44
|
+
exports.imap = imap;
|
|
45
|
+
const metamap = (schema) => implMakeMapParser(rpcvalue_1.isMetaMap, 'metamap', 'MetaMap', v4_1.z.object(schema));
|
|
46
|
+
exports.metamap = metamap;
|
|
47
|
+
const recmap = (schema) => implMakeMapParser(val => (0, rpcvalue_1.isShvMap)(val) || (0, rpcvalue_1.isIMap)(val), 'map', 'ShvMap', v4_1.z.record(v4_1.z.any(), schema));
|
|
48
|
+
exports.recmap = recmap;
|
|
49
|
+
const uint = () => v4_1.z.instanceof((rpcvalue_1.UInt));
|
|
50
|
+
exports.uint = uint;
|
|
51
|
+
const double = () => v4_1.z.instanceof(rpcvalue_1.Double);
|
|
52
|
+
exports.double = double;
|
|
53
|
+
const decimal = () => v4_1.z.instanceof(rpcvalue_1.Decimal);
|
|
54
|
+
exports.decimal = decimal;
|
|
55
|
+
const blob = () => v4_1.z.instanceof(ArrayBuffer);
|
|
56
|
+
exports.blob = blob;
|
|
57
|
+
const list = () => v4_1.z.array(v4_1.z.lazy(exports.rpcvalue));
|
|
58
|
+
exports.list = list;
|
|
59
|
+
const withMetaInstanceParser = v4_1.z.instanceof(rpcvalue_1.RpcValueWithMetaData);
|
|
60
|
+
const rpcvalue = () => v4_1.z.lazy(() => v4_1.z.union([
|
|
61
|
+
v4_1.z.undefined(),
|
|
62
|
+
v4_1.z.boolean(),
|
|
63
|
+
v4_1.z.number(),
|
|
64
|
+
(0, exports.uint)(),
|
|
65
|
+
(0, exports.double)(),
|
|
66
|
+
(0, exports.decimal)(),
|
|
67
|
+
(0, exports.blob)(),
|
|
68
|
+
v4_1.z.string(),
|
|
69
|
+
v4_1.z.date(),
|
|
70
|
+
(0, exports.list)(),
|
|
71
|
+
(0, exports.recmap)((0, exports.rpcvalue)()),
|
|
72
|
+
withMetaInstanceParser,
|
|
73
|
+
]));
|
|
74
|
+
exports.rpcvalue = rpcvalue;
|
|
75
|
+
const withMeta = (metaParser, valueParser) => v4_1.z.custom().check(ctx => {
|
|
76
|
+
if (!withMetaInstanceParser.safeParse(ctx.value).success) {
|
|
77
|
+
ctx.issues.push({
|
|
78
|
+
expected: 'map',
|
|
79
|
+
code: 'invalid_type',
|
|
80
|
+
input: ctx.value,
|
|
81
|
+
message: 'Invalid input: expected a value with metadata, got a value with no metadata}',
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const parsedMeta = metaParser.safeParse(ctx.value.meta);
|
|
86
|
+
if (!parsedMeta.success) {
|
|
87
|
+
ctx.issues = [
|
|
88
|
+
{
|
|
89
|
+
expected: 'map',
|
|
90
|
+
code: 'invalid_type',
|
|
91
|
+
input: ctx.value,
|
|
92
|
+
message: 'Wrong RpcValueWithMetaData meta',
|
|
93
|
+
},
|
|
94
|
+
...parsedMeta.error.issues,
|
|
95
|
+
];
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const parsedValue = valueParser.safeParse(ctx.value.value);
|
|
99
|
+
if (!parsedValue.success) {
|
|
100
|
+
ctx.issues = [
|
|
101
|
+
{
|
|
102
|
+
expected: 'map',
|
|
103
|
+
code: 'invalid_type',
|
|
104
|
+
input: ctx.value,
|
|
105
|
+
message: 'Wrong RpcValueWithMetaData value',
|
|
106
|
+
},
|
|
107
|
+
...parsedValue.error.issues,
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
exports.withMeta = withMeta;
|
|
112
|
+
__exportStar(require("zod/v4"), exports);
|