hanzio 1.2.0 → 2.1.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/README.md +786 -239
- package/dist/api-wrapper/builders.d.ts +4 -3
- package/dist/api-wrapper/create-client.d.ts +1 -1
- package/dist/api-wrapper/describe.d.ts +16 -0
- package/dist/api-wrapper/endpoint.d.ts +18 -0
- package/dist/api-wrapper/errors.d.ts +39 -2
- package/dist/api-wrapper/index.d.ts +5 -0
- package/dist/api-wrapper/otel.d.ts +44 -0
- package/dist/api-wrapper/paginate.d.ts +12 -0
- package/dist/api-wrapper/redaction.d.ts +2 -0
- package/dist/api-wrapper/shared.d.ts +16 -2
- package/dist/api-wrapper/testing.d.ts +23 -0
- package/dist/api-wrapper/transport.d.ts +4 -5
- package/dist/api-wrapper/types.d.ts +103 -18
- package/dist/array/index.d.ts +50 -4
- package/dist/cache/createCache.d.ts +31 -0
- package/dist/cache/index.d.ts +19 -2
- package/dist/color/contrast.d.ts +40 -0
- package/dist/color/index.d.ts +2 -0
- package/dist/{math → color}/metricsSeriesColors.d.ts +14 -7
- package/dist/cool-console-log/index.d.ts +34 -5
- package/dist/crypto/encoding.d.ts +18 -0
- package/dist/crypto/hash.d.ts +33 -0
- package/dist/crypto/index.d.ts +4 -0
- package/dist/crypto/sealer.d.ts +25 -0
- package/dist/crypto/webhook.d.ts +20 -0
- package/dist/date/index.d.ts +46 -2
- package/dist/emitter/index.d.ts +21 -0
- package/dist/error/index.d.ts +12 -0
- package/dist/format/index.d.ts +102 -0
- package/dist/function/index.d.ts +60 -0
- package/dist/guard/index.d.ts +20 -0
- package/dist/i18n/index.d.ts +37 -0
- package/dist/index-0zvtcbzy.js +224 -0
- package/dist/index-8r2vdzjg.js +87 -0
- package/dist/index-hy7kbb99.js +157 -0
- package/dist/index-hyt6c56h.js +290 -0
- package/dist/{src/secrets/infisical.js → index-j1ybktbr.js} +500 -538
- package/dist/index-k9yx6bne.js +89 -0
- package/dist/index-kj1phgrx.js +169 -0
- package/dist/index-ktynw3vs.js +37 -0
- package/dist/index-mnkcfyx8.js +78 -0
- package/dist/{p-queue/index.js → index-pwt0dz63.js} +7 -11
- package/dist/index-rp5pqghz.js +157 -0
- package/dist/index-w882zry3.js +29 -0
- package/dist/index.d.ts +7 -7
- package/dist/jwt/index.d.ts +50 -2
- package/dist/math/index.d.ts +2 -2
- package/dist/math/linearRegressionTrend.d.ts +14 -1
- package/dist/math/scale.d.ts +8 -0
- package/dist/object/index.d.ts +19 -0
- package/dist/p-queue/index.d.ts +1 -1
- package/dist/promise/index.d.ts +97 -2
- package/dist/secrets/core.d.ts +7 -0
- package/dist/secrets/index.d.ts +3 -1
- package/dist/secrets/public-config.d.ts +7 -0
- package/dist/secrets/vite.d.ts +1 -0
- package/dist/secrets/worker.d.ts +1 -0
- package/dist/sitemap/index.d.ts +48 -6
- package/dist/src/api-wrapper/index.js +60 -1130
- package/dist/src/api-wrapper/testing.js +20 -0
- package/dist/{cool-console-log → src/cool-console-log}/index.js +80 -33
- package/dist/src/crypto/index.js +195 -0
- package/dist/src/format/index.js +211 -0
- package/dist/src/i18n/index.js +36 -0
- package/dist/src/index.js +739 -3145
- package/dist/src/jwt/index.js +138 -92
- package/dist/src/p-queue/index.js +9 -437
- package/dist/src/secrets/index.js +50 -1428
- package/dist/src/secrets/vite.js +10 -39
- package/dist/src/secrets/worker.js +14 -273
- package/dist/src/sitemap/index.js +183 -511
- package/dist/src/storage/index.js +119 -0
- package/dist/src/zod/index.js +340 -167
- package/dist/state/index.d.ts +21 -0
- package/dist/storage/index.d.ts +58 -0
- package/dist/string/index.d.ts +75 -2
- package/dist/typedswitch/index.d.ts +31 -24
- package/dist/types/index.d.ts +11 -0
- package/dist/url/index.d.ts +50 -1
- package/dist/zod/index.d.ts +32 -3
- package/dist/zod/introspect.d.ts +19 -0
- package/dist/zod/jsonToZodSchemaMapper.d.ts +3 -1
- package/dist/zod/zodMinMaxFilter.d.ts +22 -3
- package/dist/zod/zodToTypeString.d.ts +8 -3
- package/package.json +78 -7
- package/src/api-wrapper/actions-impl.ts +11 -72
- package/src/api-wrapper/builders.ts +32 -25
- package/src/api-wrapper/create-client.ts +171 -41
- package/src/api-wrapper/describe.ts +157 -0
- package/src/api-wrapper/endpoint.ts +26 -0
- package/src/api-wrapper/error-reporting.ts +7 -1
- package/src/api-wrapper/errors.ts +107 -2
- package/src/api-wrapper/headers.ts +11 -6
- package/src/api-wrapper/index.ts +5 -0
- package/src/api-wrapper/otel.ts +139 -0
- package/src/api-wrapper/paginate.ts +28 -0
- package/src/api-wrapper/redaction.ts +42 -0
- package/src/api-wrapper/shared.ts +21 -2
- package/src/api-wrapper/testing.ts +48 -0
- package/src/api-wrapper/transport.ts +41 -43
- package/src/api-wrapper/types.ts +185 -18
- package/src/array/index.ts +195 -42
- package/src/cache/createCache.ts +157 -0
- package/src/cache/index.ts +132 -147
- package/src/color/contrast.ts +163 -0
- package/src/color/index.ts +22 -0
- package/src/{math → color}/metricsSeriesColors.ts +47 -49
- package/src/cool-console-log/index.ts +128 -41
- package/src/crypto/encoding.ts +83 -0
- package/src/crypto/hash.ts +170 -0
- package/src/crypto/index.ts +26 -0
- package/src/crypto/sealer.ts +168 -0
- package/src/crypto/webhook.ts +86 -0
- package/src/date/index.ts +109 -34
- package/src/emitter/index.ts +82 -0
- package/src/error/index.ts +63 -0
- package/src/format/index.ts +389 -0
- package/src/function/index.ts +201 -0
- package/src/guard/index.ts +80 -0
- package/src/i18n/index.ts +125 -0
- package/src/index.ts +11 -7
- package/src/jwt/index.ts +199 -125
- package/src/math/index.ts +5 -10
- package/src/math/linearRegressionTrend.ts +33 -8
- package/src/math/scale.ts +17 -0
- package/src/object/index.ts +99 -0
- package/src/p-queue/index.ts +2 -0
- package/src/promise/index.ts +304 -9
- package/src/secrets/core.ts +72 -16
- package/src/secrets/index.ts +16 -4
- package/src/secrets/public-config.ts +47 -0
- package/src/secrets/vite.ts +2 -0
- package/src/secrets/worker.ts +2 -0
- package/src/sitemap/index.ts +293 -130
- package/src/state/index.ts +133 -81
- package/src/storage/index.ts +187 -0
- package/src/string/index.ts +261 -23
- package/src/typedswitch/index.ts +58 -38
- package/src/types/index.ts +14 -0
- package/src/url/index.ts +146 -1
- package/src/zod/index.ts +105 -9
- package/src/zod/introspect.ts +103 -0
- package/src/zod/jsonToZodSchemaMapper.ts +44 -21
- package/src/zod/zodMinMaxFilter.ts +37 -13
- package/src/zod/zodToTypeString.ts +184 -181
- package/dist/api-wrapper/index.js +0 -250
- package/dist/gzip/index.d.ts +0 -2
- package/dist/gzip/index.js +0 -16
- package/dist/index.js +0 -1823
- package/dist/jwt/index.js +0 -19
- package/dist/sitemap/index.js +0 -552
- package/dist/src/gzip/index.js +0 -16
- package/dist/src/secrets/loaders.js +0 -1529
- package/dist/zod/index.js +0 -210
package/dist/zod/index.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
// src/zod/index.ts
|
|
2
|
-
import { z as z3 } from "zod";
|
|
3
|
-
|
|
4
|
-
// src/zod/jsonToZodSchemaMapper.ts
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
function jsonToZodSchemaMapper(jsonObject, zodSchema, config) {
|
|
7
|
-
const result = {};
|
|
8
|
-
const shape = zodSchema instanceof z.ZodObject ? zodSchema.shape : {};
|
|
9
|
-
for (const key of Object.keys(shape)) {
|
|
10
|
-
const fieldConfig = config[key];
|
|
11
|
-
let value = jsonObject[key];
|
|
12
|
-
if (fieldConfig) {
|
|
13
|
-
value = fieldConfig(jsonObject);
|
|
14
|
-
}
|
|
15
|
-
if (shape[key] instanceof z.ZodObject && value && typeof value === "object") {
|
|
16
|
-
result[key] = jsonToZodSchemaMapper(value, shape[key], config[key] || {});
|
|
17
|
-
} else {
|
|
18
|
-
result[key] = value;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return zodSchema.parse(result);
|
|
22
|
-
}
|
|
23
|
-
// src/zod/zodMinMaxFilter.ts
|
|
24
|
-
import { z as z2 } from "zod";
|
|
25
|
-
var zodMinMaxFilter = z2.object({
|
|
26
|
-
min: z2.number().optional(),
|
|
27
|
-
max: z2.number().optional()
|
|
28
|
-
});
|
|
29
|
-
function toGteLteFilter(filter) {
|
|
30
|
-
if (!filter)
|
|
31
|
-
return;
|
|
32
|
-
const hasMin = filter.min !== undefined;
|
|
33
|
-
const hasMax = filter.max !== undefined;
|
|
34
|
-
if (!hasMin && !hasMax)
|
|
35
|
-
return;
|
|
36
|
-
return {
|
|
37
|
-
...hasMin && { gte: filter.min },
|
|
38
|
-
...hasMax && { lte: filter.max }
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
// src/zod/zodToTypeString.ts
|
|
42
|
-
function getDefProp(def, prop) {
|
|
43
|
-
return def?.[prop];
|
|
44
|
-
}
|
|
45
|
-
function zodToTypeString(schema, indent = 0) {
|
|
46
|
-
const pad = " ".repeat(indent);
|
|
47
|
-
const innerPad = " ".repeat(indent + 1);
|
|
48
|
-
const def = schema._zod?.def ?? schema._def;
|
|
49
|
-
if (!def)
|
|
50
|
-
return "unknown";
|
|
51
|
-
const schemaType = getDefProp(def, "type") ?? getDefProp(def, "typeName");
|
|
52
|
-
switch (schemaType) {
|
|
53
|
-
case "object": {
|
|
54
|
-
const shape = getDefProp(def, "shape");
|
|
55
|
-
if (!shape || Object.keys(shape).length === 0)
|
|
56
|
-
return "{}";
|
|
57
|
-
const fields = Object.entries(shape).map(([key, value]) => {
|
|
58
|
-
const valueType = getDefProp(value._zod?.def ?? value._def, "type");
|
|
59
|
-
const isOptional = valueType === "optional";
|
|
60
|
-
const innerSchema = isOptional ? getDefProp(value._zod?.def ?? value._def, "innerType") ?? value : value;
|
|
61
|
-
const typeStr = zodToTypeString(innerSchema, indent + 1);
|
|
62
|
-
return `${innerPad}${key}${isOptional ? "?" : ""}: ${typeStr}`;
|
|
63
|
-
});
|
|
64
|
-
return `{
|
|
65
|
-
${fields.join(`
|
|
66
|
-
`)}
|
|
67
|
-
${pad}}`;
|
|
68
|
-
}
|
|
69
|
-
case "array": {
|
|
70
|
-
const itemType = getDefProp(def, "element") ?? getDefProp(def, "type");
|
|
71
|
-
return itemType ? `${zodToTypeString(itemType, indent)}[]` : "unknown[]";
|
|
72
|
-
}
|
|
73
|
-
case "string":
|
|
74
|
-
return "string";
|
|
75
|
-
case "number":
|
|
76
|
-
return "number";
|
|
77
|
-
case "boolean":
|
|
78
|
-
return "boolean";
|
|
79
|
-
case "date":
|
|
80
|
-
return "Date";
|
|
81
|
-
case "null":
|
|
82
|
-
return "null";
|
|
83
|
-
case "undefined":
|
|
84
|
-
return "undefined";
|
|
85
|
-
case "any":
|
|
86
|
-
return "any";
|
|
87
|
-
case "unknown":
|
|
88
|
-
return "unknown";
|
|
89
|
-
case "record": {
|
|
90
|
-
const valueType = getDefProp(def, "valueType");
|
|
91
|
-
return valueType ? `Record<string, ${zodToTypeString(valueType, indent)}>` : "Record<string, unknown>";
|
|
92
|
-
}
|
|
93
|
-
case "enum": {
|
|
94
|
-
const values = getDefProp(def, "values");
|
|
95
|
-
return values ? values.map((v) => `"${v}"`).join(" | ") : "string";
|
|
96
|
-
}
|
|
97
|
-
case "literal": {
|
|
98
|
-
const value = getDefProp(def, "value");
|
|
99
|
-
return typeof value === "string" ? `"${value}"` : String(value);
|
|
100
|
-
}
|
|
101
|
-
case "union": {
|
|
102
|
-
const options = getDefProp(def, "options");
|
|
103
|
-
return options ? options.map((o) => zodToTypeString(o, indent)).join(" | ") : "unknown";
|
|
104
|
-
}
|
|
105
|
-
case "optional": {
|
|
106
|
-
const inner = getDefProp(def, "innerType");
|
|
107
|
-
return inner ? `${zodToTypeString(inner, indent)} | undefined` : "unknown";
|
|
108
|
-
}
|
|
109
|
-
case "nullable": {
|
|
110
|
-
const inner = getDefProp(def, "innerType");
|
|
111
|
-
return inner ? `${zodToTypeString(inner, indent)} | null` : "unknown";
|
|
112
|
-
}
|
|
113
|
-
case "default": {
|
|
114
|
-
const inner = getDefProp(def, "innerType");
|
|
115
|
-
return inner ? zodToTypeString(inner, indent) : "unknown";
|
|
116
|
-
}
|
|
117
|
-
case "ZodObject":
|
|
118
|
-
case "ZodArray":
|
|
119
|
-
case "ZodString":
|
|
120
|
-
case "ZodNumber":
|
|
121
|
-
case "ZodBoolean":
|
|
122
|
-
case "ZodDate":
|
|
123
|
-
case "ZodNull":
|
|
124
|
-
case "ZodUndefined":
|
|
125
|
-
case "ZodAny":
|
|
126
|
-
case "ZodUnknown":
|
|
127
|
-
case "ZodRecord":
|
|
128
|
-
case "ZodEnum":
|
|
129
|
-
case "ZodLiteral":
|
|
130
|
-
case "ZodUnion":
|
|
131
|
-
case "ZodOptional":
|
|
132
|
-
case "ZodNullable":
|
|
133
|
-
case "ZodDefault":
|
|
134
|
-
return zodToTypeString(schema, indent);
|
|
135
|
-
default:
|
|
136
|
-
return "unknown";
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function zodToExample(schema) {
|
|
140
|
-
const def = schema._zod?.def ?? schema._def;
|
|
141
|
-
if (!def)
|
|
142
|
-
return null;
|
|
143
|
-
const schemaType = getDefProp(def, "type") ?? getDefProp(def, "typeName");
|
|
144
|
-
switch (schemaType) {
|
|
145
|
-
case "object": {
|
|
146
|
-
const shape = getDefProp(def, "shape");
|
|
147
|
-
if (!shape)
|
|
148
|
-
return {};
|
|
149
|
-
const result = {};
|
|
150
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
151
|
-
const valueType = getDefProp(value._zod?.def ?? value._def, "type");
|
|
152
|
-
const isOptional = valueType === "optional";
|
|
153
|
-
if (!isOptional) {
|
|
154
|
-
result[key] = zodToExample(value);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
case "array": {
|
|
160
|
-
const itemType = getDefProp(def, "element") ?? getDefProp(def, "type");
|
|
161
|
-
return itemType ? [zodToExample(itemType)] : [];
|
|
162
|
-
}
|
|
163
|
-
case "string":
|
|
164
|
-
return "";
|
|
165
|
-
case "number":
|
|
166
|
-
return 0;
|
|
167
|
-
case "boolean":
|
|
168
|
-
return false;
|
|
169
|
-
case "enum": {
|
|
170
|
-
const values = getDefProp(def, "values");
|
|
171
|
-
return values?.[0] ?? "";
|
|
172
|
-
}
|
|
173
|
-
case "literal":
|
|
174
|
-
return getDefProp(def, "value");
|
|
175
|
-
case "optional":
|
|
176
|
-
case "default": {
|
|
177
|
-
const inner = getDefProp(def, "innerType");
|
|
178
|
-
return inner ? zodToExample(inner) : null;
|
|
179
|
-
}
|
|
180
|
-
case "record":
|
|
181
|
-
return {};
|
|
182
|
-
default:
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// src/zod/index.ts
|
|
188
|
-
function createZId(typeName) {
|
|
189
|
-
return z3.string().min(1, `${typeName} ID is required`).brand();
|
|
190
|
-
}
|
|
191
|
-
function zSingleOrArray(schema) {
|
|
192
|
-
return z3.union([z3.array(schema), schema]);
|
|
193
|
-
}
|
|
194
|
-
function normalizeSingleOrArray(value) {
|
|
195
|
-
if (value == null)
|
|
196
|
-
return [];
|
|
197
|
-
if (Array.isArray(value))
|
|
198
|
-
return [...value];
|
|
199
|
-
return [value];
|
|
200
|
-
}
|
|
201
|
-
export {
|
|
202
|
-
zodToTypeString,
|
|
203
|
-
zodToExample,
|
|
204
|
-
zodMinMaxFilter,
|
|
205
|
-
zSingleOrArray,
|
|
206
|
-
toGteLteFilter,
|
|
207
|
-
normalizeSingleOrArray,
|
|
208
|
-
jsonToZodSchemaMapper,
|
|
209
|
-
createZId
|
|
210
|
-
};
|