@embeddable.com/sdk-core 3.13.5-next.0 → 3.13.6-next.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/lib/buildTypes.d.ts +2 -1
- package/lib/cleanup.d.ts +3 -2
- package/lib/defineConfig.d.ts +25 -2
- package/lib/generate.d.ts +2 -1
- package/lib/globalCleanup.d.ts +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.esm.js +246 -67
- package/lib/index.esm.js.map +1 -1
- package/lib/prepare.d.ts +3 -2
- package/lib/provideConfig.d.ts +2 -1
- package/lib/validate.d.ts +2 -1
- package/lib/workspaceUtils.d.ts +4 -2
- package/package.json +4 -3
- package/src/build.test.ts +4 -1
- package/src/buildTypes.test.ts +6 -3
- package/src/buildTypes.ts +5 -5
- package/src/cleanup.test.ts +2 -2
- package/src/cleanup.ts +5 -4
- package/src/defineConfig.test.ts +6 -0
- package/src/defineConfig.ts +26 -2
- package/src/dev.test.ts +4 -2
- package/src/dev.ts +20 -14
- package/src/generate.test.ts +4 -3
- package/src/generate.ts +20 -8
- package/src/globalCleanup.ts +4 -2
- package/src/index.ts +1 -0
- package/src/prepare.ts +12 -7
- package/src/provideConfig.ts +2 -1
- package/src/push.test.ts +12 -6
- package/src/rollbar.test.ts +4 -1
- package/src/validate.ts +2 -2
- package/src/workspaceUtils.test.ts +24 -9
- package/src/workspaceUtils.ts +9 -3
package/lib/buildTypes.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { ResolvedEmbeddableConfig } from "./defineConfig";
|
|
1
2
|
export declare const EMB_TYPE_FILE_REGEX: RegExp;
|
|
2
3
|
export declare const EMB_OPTIONS_FILE_REGEX: RegExp;
|
|
3
|
-
declare const _default: (ctx:
|
|
4
|
+
declare const _default: (ctx: ResolvedEmbeddableConfig) => Promise<void>;
|
|
4
5
|
export default _default;
|
package/lib/cleanup.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { ResolvedEmbeddableConfig } from "./defineConfig";
|
|
2
|
+
declare const _default: (ctx: ResolvedEmbeddableConfig) => Promise<void>;
|
|
2
3
|
export default _default;
|
|
3
4
|
type ManifestArgs = {
|
|
4
|
-
ctx:
|
|
5
|
+
ctx: ResolvedEmbeddableConfig;
|
|
5
6
|
typesFileName: string;
|
|
6
7
|
metaFileName: string;
|
|
7
8
|
editorsMetaFileName: string;
|
package/lib/defineConfig.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export type EmbeddableConfig = {
|
|
|
30
30
|
rollupOptions?: RollupOptions;
|
|
31
31
|
region?: Region;
|
|
32
32
|
};
|
|
33
|
+
declare const PLUGIN_NAME: "sdk-react";
|
|
34
|
+
export type PluginName = typeof PLUGIN_NAME;
|
|
33
35
|
export type ResolvedEmbeddableConfig = {
|
|
34
36
|
core: {
|
|
35
37
|
rootDir: string;
|
|
@@ -39,8 +41,8 @@ export type ResolvedEmbeddableConfig = {
|
|
|
39
41
|
client: {
|
|
40
42
|
rootDir: string;
|
|
41
43
|
srcDir: string;
|
|
42
|
-
modelsSrc
|
|
43
|
-
presetsSrc
|
|
44
|
+
modelsSrc: string;
|
|
45
|
+
presetsSrc: string;
|
|
44
46
|
buildDir: string;
|
|
45
47
|
tmpDir: string;
|
|
46
48
|
globalCss: string;
|
|
@@ -69,6 +71,21 @@ export type ResolvedEmbeddableConfig = {
|
|
|
69
71
|
applicationEnvironment: string;
|
|
70
72
|
rollbarAccessToken: string;
|
|
71
73
|
plugins: EmbeddableConfig["plugins"];
|
|
74
|
+
buildTime: [number, number];
|
|
75
|
+
dev: {
|
|
76
|
+
watch: boolean;
|
|
77
|
+
logger: any;
|
|
78
|
+
sys: any;
|
|
79
|
+
};
|
|
80
|
+
[PLUGIN_NAME]: {
|
|
81
|
+
rootDir: string;
|
|
82
|
+
templatesDir: string;
|
|
83
|
+
outputOptions: {
|
|
84
|
+
fileName: string;
|
|
85
|
+
buildName: string;
|
|
86
|
+
componentsEntryPointFilename: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
72
89
|
};
|
|
73
90
|
export declare const embeddableConfigSchema: z.ZodObject<{
|
|
74
91
|
plugins: z.ZodArray<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, "many">;
|
|
@@ -181,6 +198,12 @@ declare const _default: (config: EmbeddableConfig) => {
|
|
|
181
198
|
outputOptions: {
|
|
182
199
|
typesEntryPointFilename: string;
|
|
183
200
|
};
|
|
201
|
+
buildTime: undefined;
|
|
202
|
+
dev: {
|
|
203
|
+
watch: boolean;
|
|
204
|
+
logger: undefined;
|
|
205
|
+
sys: undefined;
|
|
206
|
+
};
|
|
184
207
|
pushModels: boolean;
|
|
185
208
|
pushComponents: boolean;
|
|
186
209
|
pushBaseUrl: string;
|
package/lib/generate.d.ts
CHANGED
package/lib/globalCleanup.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.esm.js
CHANGED
|
@@ -169,6 +169,9 @@ const ZodIssueCode$1 = util$2.arrayToEnum([
|
|
|
169
169
|
"not_finite",
|
|
170
170
|
]);
|
|
171
171
|
let ZodError$1 = class ZodError extends Error {
|
|
172
|
+
get errors() {
|
|
173
|
+
return this.issues;
|
|
174
|
+
}
|
|
172
175
|
constructor(issues) {
|
|
173
176
|
super();
|
|
174
177
|
this.issues = [];
|
|
@@ -189,9 +192,6 @@ let ZodError$1 = class ZodError extends Error {
|
|
|
189
192
|
this.name = "ZodError";
|
|
190
193
|
this.issues = issues;
|
|
191
194
|
}
|
|
192
|
-
get errors() {
|
|
193
|
-
return this.issues;
|
|
194
|
-
}
|
|
195
195
|
format(_mapper) {
|
|
196
196
|
const mapper = _mapper ||
|
|
197
197
|
function (issue) {
|
|
@@ -423,10 +423,14 @@ var prepare = async (ctx) => {
|
|
|
423
423
|
await createComponentDir(ctx.client.componentDir);
|
|
424
424
|
};
|
|
425
425
|
async function removeIfExists(ctx) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
426
|
+
const promises = [];
|
|
427
|
+
if (fs$1.existsSync(ctx.client.buildDir)) {
|
|
428
|
+
promises.push(fs.rm(ctx.client.buildDir, { recursive: true }));
|
|
429
|
+
}
|
|
430
|
+
if (fs$1.existsSync(ctx.client.tmpDir)) {
|
|
431
|
+
promises.push(fs.rm(ctx.client.tmpDir, { recursive: true }));
|
|
432
|
+
}
|
|
433
|
+
await Promise.all(promises);
|
|
430
434
|
}
|
|
431
435
|
async function copyStencilConfigsToClient(ctx) {
|
|
432
436
|
await fs.cp(ctx.core.configsDir, ctx.client.buildDir, { recursive: true });
|
|
@@ -482,10 +486,10 @@ async function addComponentTagName(filePath, bundleHash) {
|
|
|
482
486
|
]);
|
|
483
487
|
}
|
|
484
488
|
async function runStencil(ctx) {
|
|
485
|
-
var _a, _b;
|
|
489
|
+
var _a, _b, _c;
|
|
486
490
|
const logger = ((_a = ctx.dev) === null || _a === undefined ? undefined : _a.logger) || createNodeLogger();
|
|
487
491
|
const sys = ((_b = ctx.dev) === null || _b === undefined ? undefined : _b.sys) || createNodeSys({ process });
|
|
488
|
-
const devMode = !!ctx.dev;
|
|
492
|
+
const devMode = !!((_c = ctx.dev) === null || _c === undefined ? undefined : _c.watch);
|
|
489
493
|
const isWindows = process.platform === "win32";
|
|
490
494
|
const validated = await loadConfig({
|
|
491
495
|
initTsConfig: true,
|
|
@@ -973,6 +977,9 @@ const quotelessJson = (obj) => {
|
|
|
973
977
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
974
978
|
};
|
|
975
979
|
class ZodError extends Error {
|
|
980
|
+
get errors() {
|
|
981
|
+
return this.issues;
|
|
982
|
+
}
|
|
976
983
|
constructor(issues) {
|
|
977
984
|
super();
|
|
978
985
|
this.issues = [];
|
|
@@ -993,9 +1000,6 @@ class ZodError extends Error {
|
|
|
993
1000
|
this.name = "ZodError";
|
|
994
1001
|
this.issues = issues;
|
|
995
1002
|
}
|
|
996
|
-
get errors() {
|
|
997
|
-
return this.issues;
|
|
998
|
-
}
|
|
999
1003
|
format(_mapper) {
|
|
1000
1004
|
const mapper = _mapper ||
|
|
1001
1005
|
function (issue) {
|
|
@@ -1251,9 +1255,9 @@ function addIssueToContext(ctx, issueData) {
|
|
|
1251
1255
|
data: ctx.data,
|
|
1252
1256
|
path: ctx.path,
|
|
1253
1257
|
errorMaps: [
|
|
1254
|
-
ctx.common.contextualErrorMap,
|
|
1255
|
-
ctx.schemaErrorMap,
|
|
1256
|
-
overrideMap,
|
|
1258
|
+
ctx.common.contextualErrorMap, // contextual error map is first priority
|
|
1259
|
+
ctx.schemaErrorMap, // then schema-bound map if available
|
|
1260
|
+
overrideMap, // then global override map
|
|
1257
1261
|
overrideMap === errorMap ? undefined : errorMap, // then global default map
|
|
1258
1262
|
].filter((x) => !!x),
|
|
1259
1263
|
});
|
|
@@ -1426,35 +1430,6 @@ function processCreateParams(params) {
|
|
|
1426
1430
|
return { errorMap: customMap, description };
|
|
1427
1431
|
}
|
|
1428
1432
|
class ZodType {
|
|
1429
|
-
constructor(def) {
|
|
1430
|
-
/** Alias of safeParseAsync */
|
|
1431
|
-
this.spa = this.safeParseAsync;
|
|
1432
|
-
this._def = def;
|
|
1433
|
-
this.parse = this.parse.bind(this);
|
|
1434
|
-
this.safeParse = this.safeParse.bind(this);
|
|
1435
|
-
this.parseAsync = this.parseAsync.bind(this);
|
|
1436
|
-
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
1437
|
-
this.spa = this.spa.bind(this);
|
|
1438
|
-
this.refine = this.refine.bind(this);
|
|
1439
|
-
this.refinement = this.refinement.bind(this);
|
|
1440
|
-
this.superRefine = this.superRefine.bind(this);
|
|
1441
|
-
this.optional = this.optional.bind(this);
|
|
1442
|
-
this.nullable = this.nullable.bind(this);
|
|
1443
|
-
this.nullish = this.nullish.bind(this);
|
|
1444
|
-
this.array = this.array.bind(this);
|
|
1445
|
-
this.promise = this.promise.bind(this);
|
|
1446
|
-
this.or = this.or.bind(this);
|
|
1447
|
-
this.and = this.and.bind(this);
|
|
1448
|
-
this.transform = this.transform.bind(this);
|
|
1449
|
-
this.brand = this.brand.bind(this);
|
|
1450
|
-
this.default = this.default.bind(this);
|
|
1451
|
-
this.catch = this.catch.bind(this);
|
|
1452
|
-
this.describe = this.describe.bind(this);
|
|
1453
|
-
this.pipe = this.pipe.bind(this);
|
|
1454
|
-
this.readonly = this.readonly.bind(this);
|
|
1455
|
-
this.isNullable = this.isNullable.bind(this);
|
|
1456
|
-
this.isOptional = this.isOptional.bind(this);
|
|
1457
|
-
}
|
|
1458
1433
|
get description() {
|
|
1459
1434
|
return this._def.description;
|
|
1460
1435
|
}
|
|
@@ -1518,6 +1493,48 @@ class ZodType {
|
|
|
1518
1493
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
1519
1494
|
return handleResult(ctx, result);
|
|
1520
1495
|
}
|
|
1496
|
+
"~validate"(data) {
|
|
1497
|
+
var _a, _b;
|
|
1498
|
+
const ctx = {
|
|
1499
|
+
common: {
|
|
1500
|
+
issues: [],
|
|
1501
|
+
async: !!this["~standard"].async,
|
|
1502
|
+
},
|
|
1503
|
+
path: [],
|
|
1504
|
+
schemaErrorMap: this._def.errorMap,
|
|
1505
|
+
parent: null,
|
|
1506
|
+
data,
|
|
1507
|
+
parsedType: getParsedType(data),
|
|
1508
|
+
};
|
|
1509
|
+
if (!this["~standard"].async) {
|
|
1510
|
+
try {
|
|
1511
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
1512
|
+
return isValid(result)
|
|
1513
|
+
? {
|
|
1514
|
+
value: result.value,
|
|
1515
|
+
}
|
|
1516
|
+
: {
|
|
1517
|
+
issues: ctx.common.issues,
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
catch (err) {
|
|
1521
|
+
if ((_b = (_a = err === null || err === undefined ? undefined : err.message) === null || _a === undefined ? undefined : _a.toLowerCase()) === null || _b === undefined ? undefined : _b.includes("encountered")) {
|
|
1522
|
+
this["~standard"].async = true;
|
|
1523
|
+
}
|
|
1524
|
+
ctx.common = {
|
|
1525
|
+
issues: [],
|
|
1526
|
+
async: true,
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result)
|
|
1531
|
+
? {
|
|
1532
|
+
value: result.value,
|
|
1533
|
+
}
|
|
1534
|
+
: {
|
|
1535
|
+
issues: ctx.common.issues,
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1521
1538
|
async parseAsync(data, params) {
|
|
1522
1539
|
const result = await this.safeParseAsync(data, params);
|
|
1523
1540
|
if (result.success)
|
|
@@ -1604,6 +1621,40 @@ class ZodType {
|
|
|
1604
1621
|
superRefine(refinement) {
|
|
1605
1622
|
return this._refinement(refinement);
|
|
1606
1623
|
}
|
|
1624
|
+
constructor(def) {
|
|
1625
|
+
/** Alias of safeParseAsync */
|
|
1626
|
+
this.spa = this.safeParseAsync;
|
|
1627
|
+
this._def = def;
|
|
1628
|
+
this.parse = this.parse.bind(this);
|
|
1629
|
+
this.safeParse = this.safeParse.bind(this);
|
|
1630
|
+
this.parseAsync = this.parseAsync.bind(this);
|
|
1631
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
1632
|
+
this.spa = this.spa.bind(this);
|
|
1633
|
+
this.refine = this.refine.bind(this);
|
|
1634
|
+
this.refinement = this.refinement.bind(this);
|
|
1635
|
+
this.superRefine = this.superRefine.bind(this);
|
|
1636
|
+
this.optional = this.optional.bind(this);
|
|
1637
|
+
this.nullable = this.nullable.bind(this);
|
|
1638
|
+
this.nullish = this.nullish.bind(this);
|
|
1639
|
+
this.array = this.array.bind(this);
|
|
1640
|
+
this.promise = this.promise.bind(this);
|
|
1641
|
+
this.or = this.or.bind(this);
|
|
1642
|
+
this.and = this.and.bind(this);
|
|
1643
|
+
this.transform = this.transform.bind(this);
|
|
1644
|
+
this.brand = this.brand.bind(this);
|
|
1645
|
+
this.default = this.default.bind(this);
|
|
1646
|
+
this.catch = this.catch.bind(this);
|
|
1647
|
+
this.describe = this.describe.bind(this);
|
|
1648
|
+
this.pipe = this.pipe.bind(this);
|
|
1649
|
+
this.readonly = this.readonly.bind(this);
|
|
1650
|
+
this.isNullable = this.isNullable.bind(this);
|
|
1651
|
+
this.isOptional = this.isOptional.bind(this);
|
|
1652
|
+
this["~standard"] = {
|
|
1653
|
+
version: 1,
|
|
1654
|
+
vendor: "zod",
|
|
1655
|
+
validate: (data) => this["~validate"](data),
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1607
1658
|
optional() {
|
|
1608
1659
|
return ZodOptional.create(this, this._def);
|
|
1609
1660
|
}
|
|
@@ -1614,7 +1665,7 @@ class ZodType {
|
|
|
1614
1665
|
return this.nullable().optional();
|
|
1615
1666
|
}
|
|
1616
1667
|
array() {
|
|
1617
|
-
return ZodArray.create(this
|
|
1668
|
+
return ZodArray.create(this);
|
|
1618
1669
|
}
|
|
1619
1670
|
promise() {
|
|
1620
1671
|
return ZodPromise.create(this, this._def);
|
|
@@ -1680,11 +1731,12 @@ class ZodType {
|
|
|
1680
1731
|
}
|
|
1681
1732
|
const cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1682
1733
|
const cuid2Regex = /^[0-9a-z]+$/;
|
|
1683
|
-
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}
|
|
1734
|
+
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
1684
1735
|
// const uuidRegex =
|
|
1685
1736
|
// /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
1686
1737
|
const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
1687
1738
|
const nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
1739
|
+
const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
1688
1740
|
const durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
1689
1741
|
// from https://stackoverflow.com/a/46181/1550155
|
|
1690
1742
|
// old version: too slow, didn't support unicode
|
|
@@ -1706,9 +1758,15 @@ const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
|
1706
1758
|
let emojiRegex;
|
|
1707
1759
|
// faster, simpler, safer
|
|
1708
1760
|
const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
1709
|
-
const
|
|
1761
|
+
const ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
|
|
1762
|
+
// const ipv6Regex =
|
|
1763
|
+
// /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
|
1764
|
+
const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
1765
|
+
const ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
1710
1766
|
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
|
1711
1767
|
const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
1768
|
+
// https://base64.guru/standards/base64url
|
|
1769
|
+
const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
1712
1770
|
// simple
|
|
1713
1771
|
// const dateRegexSource = `\\d{4}-\\d{2}-\\d{2}`;
|
|
1714
1772
|
// no leap year validation
|
|
@@ -1749,6 +1807,38 @@ function isValidIP(ip, version) {
|
|
|
1749
1807
|
}
|
|
1750
1808
|
return false;
|
|
1751
1809
|
}
|
|
1810
|
+
function isValidJWT(jwt, alg) {
|
|
1811
|
+
if (!jwtRegex.test(jwt))
|
|
1812
|
+
return false;
|
|
1813
|
+
try {
|
|
1814
|
+
const [header] = jwt.split(".");
|
|
1815
|
+
// Convert base64url to base64
|
|
1816
|
+
const base64 = header
|
|
1817
|
+
.replace(/-/g, "+")
|
|
1818
|
+
.replace(/_/g, "/")
|
|
1819
|
+
.padEnd(header.length + ((4 - (header.length % 4)) % 4), "=");
|
|
1820
|
+
const decoded = JSON.parse(atob(base64));
|
|
1821
|
+
if (typeof decoded !== "object" || decoded === null)
|
|
1822
|
+
return false;
|
|
1823
|
+
if (!decoded.typ || !decoded.alg)
|
|
1824
|
+
return false;
|
|
1825
|
+
if (alg && decoded.alg !== alg)
|
|
1826
|
+
return false;
|
|
1827
|
+
return true;
|
|
1828
|
+
}
|
|
1829
|
+
catch (_a) {
|
|
1830
|
+
return false;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
function isValidCidr(ip, version) {
|
|
1834
|
+
if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
|
|
1835
|
+
return true;
|
|
1836
|
+
}
|
|
1837
|
+
if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
|
|
1838
|
+
return true;
|
|
1839
|
+
}
|
|
1840
|
+
return false;
|
|
1841
|
+
}
|
|
1752
1842
|
class ZodString extends ZodType {
|
|
1753
1843
|
_parse(input) {
|
|
1754
1844
|
if (this._def.coerce) {
|
|
@@ -2030,6 +2120,28 @@ class ZodString extends ZodType {
|
|
|
2030
2120
|
status.dirty();
|
|
2031
2121
|
}
|
|
2032
2122
|
}
|
|
2123
|
+
else if (check.kind === "jwt") {
|
|
2124
|
+
if (!isValidJWT(input.data, check.alg)) {
|
|
2125
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2126
|
+
addIssueToContext(ctx, {
|
|
2127
|
+
validation: "jwt",
|
|
2128
|
+
code: ZodIssueCode.invalid_string,
|
|
2129
|
+
message: check.message,
|
|
2130
|
+
});
|
|
2131
|
+
status.dirty();
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
else if (check.kind === "cidr") {
|
|
2135
|
+
if (!isValidCidr(input.data, check.version)) {
|
|
2136
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2137
|
+
addIssueToContext(ctx, {
|
|
2138
|
+
validation: "cidr",
|
|
2139
|
+
code: ZodIssueCode.invalid_string,
|
|
2140
|
+
message: check.message,
|
|
2141
|
+
});
|
|
2142
|
+
status.dirty();
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2033
2145
|
else if (check.kind === "base64") {
|
|
2034
2146
|
if (!base64Regex.test(input.data)) {
|
|
2035
2147
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -2041,6 +2153,17 @@ class ZodString extends ZodType {
|
|
|
2041
2153
|
status.dirty();
|
|
2042
2154
|
}
|
|
2043
2155
|
}
|
|
2156
|
+
else if (check.kind === "base64url") {
|
|
2157
|
+
if (!base64urlRegex.test(input.data)) {
|
|
2158
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2159
|
+
addIssueToContext(ctx, {
|
|
2160
|
+
validation: "base64url",
|
|
2161
|
+
code: ZodIssueCode.invalid_string,
|
|
2162
|
+
message: check.message,
|
|
2163
|
+
});
|
|
2164
|
+
status.dirty();
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2044
2167
|
else {
|
|
2045
2168
|
util$1.assertNever(check);
|
|
2046
2169
|
}
|
|
@@ -2087,9 +2210,22 @@ class ZodString extends ZodType {
|
|
|
2087
2210
|
base64(message) {
|
|
2088
2211
|
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
2089
2212
|
}
|
|
2213
|
+
base64url(message) {
|
|
2214
|
+
// base64url encoding is a modification of base64 that can safely be used in URLs and filenames
|
|
2215
|
+
return this._addCheck({
|
|
2216
|
+
kind: "base64url",
|
|
2217
|
+
...errorUtil.errToObj(message),
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
jwt(options) {
|
|
2221
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
2222
|
+
}
|
|
2090
2223
|
ip(options) {
|
|
2091
2224
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
2092
2225
|
}
|
|
2226
|
+
cidr(options) {
|
|
2227
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
2228
|
+
}
|
|
2093
2229
|
datetime(options) {
|
|
2094
2230
|
var _a, _b;
|
|
2095
2231
|
if (typeof options === "string") {
|
|
@@ -2180,8 +2316,7 @@ class ZodString extends ZodType {
|
|
|
2180
2316
|
});
|
|
2181
2317
|
}
|
|
2182
2318
|
/**
|
|
2183
|
-
*
|
|
2184
|
-
* @see {@link ZodString.min}
|
|
2319
|
+
* Equivalent to `.min(1)`
|
|
2185
2320
|
*/
|
|
2186
2321
|
nonempty(message) {
|
|
2187
2322
|
return this.min(1, errorUtil.errToObj(message));
|
|
@@ -2243,9 +2378,16 @@ class ZodString extends ZodType {
|
|
|
2243
2378
|
get isIP() {
|
|
2244
2379
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
2245
2380
|
}
|
|
2381
|
+
get isCIDR() {
|
|
2382
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
2383
|
+
}
|
|
2246
2384
|
get isBase64() {
|
|
2247
2385
|
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
2248
2386
|
}
|
|
2387
|
+
get isBase64url() {
|
|
2388
|
+
// base64url encoding is a modification of base64 that can safely be used in URLs and filenames
|
|
2389
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
2390
|
+
}
|
|
2249
2391
|
get minLength() {
|
|
2250
2392
|
let min = null;
|
|
2251
2393
|
for (const ch of this._def.checks) {
|
|
@@ -2538,17 +2680,16 @@ class ZodBigInt extends ZodType {
|
|
|
2538
2680
|
}
|
|
2539
2681
|
_parse(input) {
|
|
2540
2682
|
if (this._def.coerce) {
|
|
2541
|
-
|
|
2683
|
+
try {
|
|
2684
|
+
input.data = BigInt(input.data);
|
|
2685
|
+
}
|
|
2686
|
+
catch (_a) {
|
|
2687
|
+
return this._getInvalidInput(input);
|
|
2688
|
+
}
|
|
2542
2689
|
}
|
|
2543
2690
|
const parsedType = this._getType(input);
|
|
2544
2691
|
if (parsedType !== ZodParsedType.bigint) {
|
|
2545
|
-
|
|
2546
|
-
addIssueToContext(ctx, {
|
|
2547
|
-
code: ZodIssueCode.invalid_type,
|
|
2548
|
-
expected: ZodParsedType.bigint,
|
|
2549
|
-
received: ctx.parsedType,
|
|
2550
|
-
});
|
|
2551
|
-
return INVALID;
|
|
2692
|
+
return this._getInvalidInput(input);
|
|
2552
2693
|
}
|
|
2553
2694
|
let ctx = undefined;
|
|
2554
2695
|
const status = new ParseStatus();
|
|
@@ -2602,6 +2743,15 @@ class ZodBigInt extends ZodType {
|
|
|
2602
2743
|
}
|
|
2603
2744
|
return { status: status.value, value: input.data };
|
|
2604
2745
|
}
|
|
2746
|
+
_getInvalidInput(input) {
|
|
2747
|
+
const ctx = this._getOrReturnCtx(input);
|
|
2748
|
+
addIssueToContext(ctx, {
|
|
2749
|
+
code: ZodIssueCode.invalid_type,
|
|
2750
|
+
expected: ZodParsedType.bigint,
|
|
2751
|
+
received: ctx.parsedType,
|
|
2752
|
+
});
|
|
2753
|
+
return INVALID;
|
|
2754
|
+
}
|
|
2605
2755
|
gte(value, message) {
|
|
2606
2756
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
2607
2757
|
}
|
|
@@ -4808,7 +4958,23 @@ ZodReadonly.create = (type, params) => {
|
|
|
4808
4958
|
...processCreateParams(params),
|
|
4809
4959
|
});
|
|
4810
4960
|
};
|
|
4811
|
-
|
|
4961
|
+
////////////////////////////////////////
|
|
4962
|
+
////////////////////////////////////////
|
|
4963
|
+
////////// //////////
|
|
4964
|
+
////////// z.custom //////////
|
|
4965
|
+
////////// //////////
|
|
4966
|
+
////////////////////////////////////////
|
|
4967
|
+
////////////////////////////////////////
|
|
4968
|
+
function cleanParams(params, data) {
|
|
4969
|
+
const p = typeof params === "function"
|
|
4970
|
+
? params(data)
|
|
4971
|
+
: typeof params === "string"
|
|
4972
|
+
? { message: params }
|
|
4973
|
+
: params;
|
|
4974
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
|
4975
|
+
return p2;
|
|
4976
|
+
}
|
|
4977
|
+
function custom(check, _params = {},
|
|
4812
4978
|
/**
|
|
4813
4979
|
* @deprecated
|
|
4814
4980
|
*
|
|
@@ -4823,16 +4989,23 @@ fatal) {
|
|
|
4823
4989
|
if (check)
|
|
4824
4990
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
4825
4991
|
var _a, _b;
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4992
|
+
const r = check(data);
|
|
4993
|
+
if (r instanceof Promise) {
|
|
4994
|
+
return r.then((r) => {
|
|
4995
|
+
var _a, _b;
|
|
4996
|
+
if (!r) {
|
|
4997
|
+
const params = cleanParams(_params, data);
|
|
4998
|
+
const _fatal = (_b = (_a = params.fatal) !== null && _a !== undefined ? _a : fatal) !== null && _b !== undefined ? _b : true;
|
|
4999
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
5000
|
+
}
|
|
5001
|
+
});
|
|
5002
|
+
}
|
|
5003
|
+
if (!r) {
|
|
5004
|
+
const params = cleanParams(_params, data);
|
|
5005
|
+
const _fatal = (_b = (_a = params.fatal) !== null && _a !== undefined ? _a : fatal) !== null && _b !== undefined ? _b : true;
|
|
5006
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
4835
5007
|
}
|
|
5008
|
+
return;
|
|
4836
5009
|
});
|
|
4837
5010
|
return ZodAny.create();
|
|
4838
5011
|
}
|
|
@@ -22168,6 +22341,12 @@ var defineConfig = (config) => {
|
|
|
22168
22341
|
outputOptions: {
|
|
22169
22342
|
typesEntryPointFilename: "embeddable-types-entry-point.js",
|
|
22170
22343
|
},
|
|
22344
|
+
buildTime: undefined, // This will be set by the build process
|
|
22345
|
+
dev: {
|
|
22346
|
+
watch: false,
|
|
22347
|
+
logger: undefined,
|
|
22348
|
+
sys: undefined,
|
|
22349
|
+
},
|
|
22171
22350
|
pushModels,
|
|
22172
22351
|
pushComponents,
|
|
22173
22352
|
pushBaseUrl: pushBaseUrl !== null && pushBaseUrl !== undefined ? pushBaseUrl : regionConfig.pushBaseUrl,
|