@embeddable.com/sdk-core 3.13.5 → 3.13.6-next.1
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 +248 -68
- 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 +21 -9
- 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/index.js +0 -22627
- package/lib/index.js.map +0 -1
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 });
|
|
@@ -456,9 +460,10 @@ async function injectCSS(ctx, pluginName) {
|
|
|
456
460
|
await fs.writeFile(path.resolve(ctx.client.componentDir, "style.css"), content.replace(STYLE_IMPORTS_TOKEN, cssFilesImportsStr));
|
|
457
461
|
}
|
|
458
462
|
async function injectBundleRender(ctx, pluginName) {
|
|
463
|
+
var _a;
|
|
459
464
|
const importStr = `import render from '../${ctx[pluginName].outputOptions.buildName}/${ctx[pluginName].outputOptions.fileName}';`;
|
|
460
465
|
let content = await fs.readFile(path.resolve(ctx.core.templatesDir, "component.tsx.template"), "utf8");
|
|
461
|
-
if (!!ctx.dev) {
|
|
466
|
+
if (!!((_a = ctx.dev) === null || _a === undefined ? undefined : _a.watch)) {
|
|
462
467
|
content = content.replace(COMPONENT_TAG_TOKEN, "embeddable-component");
|
|
463
468
|
}
|
|
464
469
|
await fs.writeFile(path.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr));
|
|
@@ -482,10 +487,10 @@ async function addComponentTagName(filePath, bundleHash) {
|
|
|
482
487
|
]);
|
|
483
488
|
}
|
|
484
489
|
async function runStencil(ctx) {
|
|
485
|
-
var _a, _b;
|
|
490
|
+
var _a, _b, _c;
|
|
486
491
|
const logger = ((_a = ctx.dev) === null || _a === undefined ? undefined : _a.logger) || createNodeLogger();
|
|
487
492
|
const sys = ((_b = ctx.dev) === null || _b === undefined ? undefined : _b.sys) || createNodeSys({ process });
|
|
488
|
-
const devMode = !!ctx.dev;
|
|
493
|
+
const devMode = !!((_c = ctx.dev) === null || _c === undefined ? undefined : _c.watch);
|
|
489
494
|
const isWindows = process.platform === "win32";
|
|
490
495
|
const validated = await loadConfig({
|
|
491
496
|
initTsConfig: true,
|
|
@@ -973,6 +978,9 @@ const quotelessJson = (obj) => {
|
|
|
973
978
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
974
979
|
};
|
|
975
980
|
class ZodError extends Error {
|
|
981
|
+
get errors() {
|
|
982
|
+
return this.issues;
|
|
983
|
+
}
|
|
976
984
|
constructor(issues) {
|
|
977
985
|
super();
|
|
978
986
|
this.issues = [];
|
|
@@ -993,9 +1001,6 @@ class ZodError extends Error {
|
|
|
993
1001
|
this.name = "ZodError";
|
|
994
1002
|
this.issues = issues;
|
|
995
1003
|
}
|
|
996
|
-
get errors() {
|
|
997
|
-
return this.issues;
|
|
998
|
-
}
|
|
999
1004
|
format(_mapper) {
|
|
1000
1005
|
const mapper = _mapper ||
|
|
1001
1006
|
function (issue) {
|
|
@@ -1251,9 +1256,9 @@ function addIssueToContext(ctx, issueData) {
|
|
|
1251
1256
|
data: ctx.data,
|
|
1252
1257
|
path: ctx.path,
|
|
1253
1258
|
errorMaps: [
|
|
1254
|
-
ctx.common.contextualErrorMap,
|
|
1255
|
-
ctx.schemaErrorMap,
|
|
1256
|
-
overrideMap,
|
|
1259
|
+
ctx.common.contextualErrorMap, // contextual error map is first priority
|
|
1260
|
+
ctx.schemaErrorMap, // then schema-bound map if available
|
|
1261
|
+
overrideMap, // then global override map
|
|
1257
1262
|
overrideMap === errorMap ? undefined : errorMap, // then global default map
|
|
1258
1263
|
].filter((x) => !!x),
|
|
1259
1264
|
});
|
|
@@ -1426,35 +1431,6 @@ function processCreateParams(params) {
|
|
|
1426
1431
|
return { errorMap: customMap, description };
|
|
1427
1432
|
}
|
|
1428
1433
|
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
1434
|
get description() {
|
|
1459
1435
|
return this._def.description;
|
|
1460
1436
|
}
|
|
@@ -1518,6 +1494,48 @@ class ZodType {
|
|
|
1518
1494
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
1519
1495
|
return handleResult(ctx, result);
|
|
1520
1496
|
}
|
|
1497
|
+
"~validate"(data) {
|
|
1498
|
+
var _a, _b;
|
|
1499
|
+
const ctx = {
|
|
1500
|
+
common: {
|
|
1501
|
+
issues: [],
|
|
1502
|
+
async: !!this["~standard"].async,
|
|
1503
|
+
},
|
|
1504
|
+
path: [],
|
|
1505
|
+
schemaErrorMap: this._def.errorMap,
|
|
1506
|
+
parent: null,
|
|
1507
|
+
data,
|
|
1508
|
+
parsedType: getParsedType(data),
|
|
1509
|
+
};
|
|
1510
|
+
if (!this["~standard"].async) {
|
|
1511
|
+
try {
|
|
1512
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
1513
|
+
return isValid(result)
|
|
1514
|
+
? {
|
|
1515
|
+
value: result.value,
|
|
1516
|
+
}
|
|
1517
|
+
: {
|
|
1518
|
+
issues: ctx.common.issues,
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
catch (err) {
|
|
1522
|
+
if ((_b = (_a = err === null || err === undefined ? undefined : err.message) === null || _a === undefined ? undefined : _a.toLowerCase()) === null || _b === undefined ? undefined : _b.includes("encountered")) {
|
|
1523
|
+
this["~standard"].async = true;
|
|
1524
|
+
}
|
|
1525
|
+
ctx.common = {
|
|
1526
|
+
issues: [],
|
|
1527
|
+
async: true,
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result)
|
|
1532
|
+
? {
|
|
1533
|
+
value: result.value,
|
|
1534
|
+
}
|
|
1535
|
+
: {
|
|
1536
|
+
issues: ctx.common.issues,
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1521
1539
|
async parseAsync(data, params) {
|
|
1522
1540
|
const result = await this.safeParseAsync(data, params);
|
|
1523
1541
|
if (result.success)
|
|
@@ -1604,6 +1622,40 @@ class ZodType {
|
|
|
1604
1622
|
superRefine(refinement) {
|
|
1605
1623
|
return this._refinement(refinement);
|
|
1606
1624
|
}
|
|
1625
|
+
constructor(def) {
|
|
1626
|
+
/** Alias of safeParseAsync */
|
|
1627
|
+
this.spa = this.safeParseAsync;
|
|
1628
|
+
this._def = def;
|
|
1629
|
+
this.parse = this.parse.bind(this);
|
|
1630
|
+
this.safeParse = this.safeParse.bind(this);
|
|
1631
|
+
this.parseAsync = this.parseAsync.bind(this);
|
|
1632
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
1633
|
+
this.spa = this.spa.bind(this);
|
|
1634
|
+
this.refine = this.refine.bind(this);
|
|
1635
|
+
this.refinement = this.refinement.bind(this);
|
|
1636
|
+
this.superRefine = this.superRefine.bind(this);
|
|
1637
|
+
this.optional = this.optional.bind(this);
|
|
1638
|
+
this.nullable = this.nullable.bind(this);
|
|
1639
|
+
this.nullish = this.nullish.bind(this);
|
|
1640
|
+
this.array = this.array.bind(this);
|
|
1641
|
+
this.promise = this.promise.bind(this);
|
|
1642
|
+
this.or = this.or.bind(this);
|
|
1643
|
+
this.and = this.and.bind(this);
|
|
1644
|
+
this.transform = this.transform.bind(this);
|
|
1645
|
+
this.brand = this.brand.bind(this);
|
|
1646
|
+
this.default = this.default.bind(this);
|
|
1647
|
+
this.catch = this.catch.bind(this);
|
|
1648
|
+
this.describe = this.describe.bind(this);
|
|
1649
|
+
this.pipe = this.pipe.bind(this);
|
|
1650
|
+
this.readonly = this.readonly.bind(this);
|
|
1651
|
+
this.isNullable = this.isNullable.bind(this);
|
|
1652
|
+
this.isOptional = this.isOptional.bind(this);
|
|
1653
|
+
this["~standard"] = {
|
|
1654
|
+
version: 1,
|
|
1655
|
+
vendor: "zod",
|
|
1656
|
+
validate: (data) => this["~validate"](data),
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1607
1659
|
optional() {
|
|
1608
1660
|
return ZodOptional.create(this, this._def);
|
|
1609
1661
|
}
|
|
@@ -1614,7 +1666,7 @@ class ZodType {
|
|
|
1614
1666
|
return this.nullable().optional();
|
|
1615
1667
|
}
|
|
1616
1668
|
array() {
|
|
1617
|
-
return ZodArray.create(this
|
|
1669
|
+
return ZodArray.create(this);
|
|
1618
1670
|
}
|
|
1619
1671
|
promise() {
|
|
1620
1672
|
return ZodPromise.create(this, this._def);
|
|
@@ -1680,11 +1732,12 @@ class ZodType {
|
|
|
1680
1732
|
}
|
|
1681
1733
|
const cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1682
1734
|
const cuid2Regex = /^[0-9a-z]+$/;
|
|
1683
|
-
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}
|
|
1735
|
+
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
1684
1736
|
// const uuidRegex =
|
|
1685
1737
|
// /^([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
1738
|
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
1739
|
const nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
1740
|
+
const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
1688
1741
|
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
1742
|
// from https://stackoverflow.com/a/46181/1550155
|
|
1690
1743
|
// old version: too slow, didn't support unicode
|
|
@@ -1706,9 +1759,15 @@ const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
|
1706
1759
|
let emojiRegex;
|
|
1707
1760
|
// faster, simpler, safer
|
|
1708
1761
|
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
|
|
1762
|
+
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])$/;
|
|
1763
|
+
// const ipv6Regex =
|
|
1764
|
+
// /^(([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})))$/;
|
|
1765
|
+
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]))$/;
|
|
1766
|
+
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
1767
|
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
|
1711
1768
|
const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
1769
|
+
// https://base64.guru/standards/base64url
|
|
1770
|
+
const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
1712
1771
|
// simple
|
|
1713
1772
|
// const dateRegexSource = `\\d{4}-\\d{2}-\\d{2}`;
|
|
1714
1773
|
// no leap year validation
|
|
@@ -1749,6 +1808,38 @@ function isValidIP(ip, version) {
|
|
|
1749
1808
|
}
|
|
1750
1809
|
return false;
|
|
1751
1810
|
}
|
|
1811
|
+
function isValidJWT(jwt, alg) {
|
|
1812
|
+
if (!jwtRegex.test(jwt))
|
|
1813
|
+
return false;
|
|
1814
|
+
try {
|
|
1815
|
+
const [header] = jwt.split(".");
|
|
1816
|
+
// Convert base64url to base64
|
|
1817
|
+
const base64 = header
|
|
1818
|
+
.replace(/-/g, "+")
|
|
1819
|
+
.replace(/_/g, "/")
|
|
1820
|
+
.padEnd(header.length + ((4 - (header.length % 4)) % 4), "=");
|
|
1821
|
+
const decoded = JSON.parse(atob(base64));
|
|
1822
|
+
if (typeof decoded !== "object" || decoded === null)
|
|
1823
|
+
return false;
|
|
1824
|
+
if (!decoded.typ || !decoded.alg)
|
|
1825
|
+
return false;
|
|
1826
|
+
if (alg && decoded.alg !== alg)
|
|
1827
|
+
return false;
|
|
1828
|
+
return true;
|
|
1829
|
+
}
|
|
1830
|
+
catch (_a) {
|
|
1831
|
+
return false;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
function isValidCidr(ip, version) {
|
|
1835
|
+
if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
|
|
1836
|
+
return true;
|
|
1837
|
+
}
|
|
1838
|
+
if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
|
|
1839
|
+
return true;
|
|
1840
|
+
}
|
|
1841
|
+
return false;
|
|
1842
|
+
}
|
|
1752
1843
|
class ZodString extends ZodType {
|
|
1753
1844
|
_parse(input) {
|
|
1754
1845
|
if (this._def.coerce) {
|
|
@@ -2030,6 +2121,28 @@ class ZodString extends ZodType {
|
|
|
2030
2121
|
status.dirty();
|
|
2031
2122
|
}
|
|
2032
2123
|
}
|
|
2124
|
+
else if (check.kind === "jwt") {
|
|
2125
|
+
if (!isValidJWT(input.data, check.alg)) {
|
|
2126
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2127
|
+
addIssueToContext(ctx, {
|
|
2128
|
+
validation: "jwt",
|
|
2129
|
+
code: ZodIssueCode.invalid_string,
|
|
2130
|
+
message: check.message,
|
|
2131
|
+
});
|
|
2132
|
+
status.dirty();
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
else if (check.kind === "cidr") {
|
|
2136
|
+
if (!isValidCidr(input.data, check.version)) {
|
|
2137
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2138
|
+
addIssueToContext(ctx, {
|
|
2139
|
+
validation: "cidr",
|
|
2140
|
+
code: ZodIssueCode.invalid_string,
|
|
2141
|
+
message: check.message,
|
|
2142
|
+
});
|
|
2143
|
+
status.dirty();
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2033
2146
|
else if (check.kind === "base64") {
|
|
2034
2147
|
if (!base64Regex.test(input.data)) {
|
|
2035
2148
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -2041,6 +2154,17 @@ class ZodString extends ZodType {
|
|
|
2041
2154
|
status.dirty();
|
|
2042
2155
|
}
|
|
2043
2156
|
}
|
|
2157
|
+
else if (check.kind === "base64url") {
|
|
2158
|
+
if (!base64urlRegex.test(input.data)) {
|
|
2159
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2160
|
+
addIssueToContext(ctx, {
|
|
2161
|
+
validation: "base64url",
|
|
2162
|
+
code: ZodIssueCode.invalid_string,
|
|
2163
|
+
message: check.message,
|
|
2164
|
+
});
|
|
2165
|
+
status.dirty();
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2044
2168
|
else {
|
|
2045
2169
|
util$1.assertNever(check);
|
|
2046
2170
|
}
|
|
@@ -2087,9 +2211,22 @@ class ZodString extends ZodType {
|
|
|
2087
2211
|
base64(message) {
|
|
2088
2212
|
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
2089
2213
|
}
|
|
2214
|
+
base64url(message) {
|
|
2215
|
+
// base64url encoding is a modification of base64 that can safely be used in URLs and filenames
|
|
2216
|
+
return this._addCheck({
|
|
2217
|
+
kind: "base64url",
|
|
2218
|
+
...errorUtil.errToObj(message),
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
jwt(options) {
|
|
2222
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
2223
|
+
}
|
|
2090
2224
|
ip(options) {
|
|
2091
2225
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
2092
2226
|
}
|
|
2227
|
+
cidr(options) {
|
|
2228
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
2229
|
+
}
|
|
2093
2230
|
datetime(options) {
|
|
2094
2231
|
var _a, _b;
|
|
2095
2232
|
if (typeof options === "string") {
|
|
@@ -2180,8 +2317,7 @@ class ZodString extends ZodType {
|
|
|
2180
2317
|
});
|
|
2181
2318
|
}
|
|
2182
2319
|
/**
|
|
2183
|
-
*
|
|
2184
|
-
* @see {@link ZodString.min}
|
|
2320
|
+
* Equivalent to `.min(1)`
|
|
2185
2321
|
*/
|
|
2186
2322
|
nonempty(message) {
|
|
2187
2323
|
return this.min(1, errorUtil.errToObj(message));
|
|
@@ -2243,9 +2379,16 @@ class ZodString extends ZodType {
|
|
|
2243
2379
|
get isIP() {
|
|
2244
2380
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
2245
2381
|
}
|
|
2382
|
+
get isCIDR() {
|
|
2383
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
2384
|
+
}
|
|
2246
2385
|
get isBase64() {
|
|
2247
2386
|
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
2248
2387
|
}
|
|
2388
|
+
get isBase64url() {
|
|
2389
|
+
// base64url encoding is a modification of base64 that can safely be used in URLs and filenames
|
|
2390
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
2391
|
+
}
|
|
2249
2392
|
get minLength() {
|
|
2250
2393
|
let min = null;
|
|
2251
2394
|
for (const ch of this._def.checks) {
|
|
@@ -2538,17 +2681,16 @@ class ZodBigInt extends ZodType {
|
|
|
2538
2681
|
}
|
|
2539
2682
|
_parse(input) {
|
|
2540
2683
|
if (this._def.coerce) {
|
|
2541
|
-
|
|
2684
|
+
try {
|
|
2685
|
+
input.data = BigInt(input.data);
|
|
2686
|
+
}
|
|
2687
|
+
catch (_a) {
|
|
2688
|
+
return this._getInvalidInput(input);
|
|
2689
|
+
}
|
|
2542
2690
|
}
|
|
2543
2691
|
const parsedType = this._getType(input);
|
|
2544
2692
|
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;
|
|
2693
|
+
return this._getInvalidInput(input);
|
|
2552
2694
|
}
|
|
2553
2695
|
let ctx = undefined;
|
|
2554
2696
|
const status = new ParseStatus();
|
|
@@ -2602,6 +2744,15 @@ class ZodBigInt extends ZodType {
|
|
|
2602
2744
|
}
|
|
2603
2745
|
return { status: status.value, value: input.data };
|
|
2604
2746
|
}
|
|
2747
|
+
_getInvalidInput(input) {
|
|
2748
|
+
const ctx = this._getOrReturnCtx(input);
|
|
2749
|
+
addIssueToContext(ctx, {
|
|
2750
|
+
code: ZodIssueCode.invalid_type,
|
|
2751
|
+
expected: ZodParsedType.bigint,
|
|
2752
|
+
received: ctx.parsedType,
|
|
2753
|
+
});
|
|
2754
|
+
return INVALID;
|
|
2755
|
+
}
|
|
2605
2756
|
gte(value, message) {
|
|
2606
2757
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
2607
2758
|
}
|
|
@@ -4808,7 +4959,23 @@ ZodReadonly.create = (type, params) => {
|
|
|
4808
4959
|
...processCreateParams(params),
|
|
4809
4960
|
});
|
|
4810
4961
|
};
|
|
4811
|
-
|
|
4962
|
+
////////////////////////////////////////
|
|
4963
|
+
////////////////////////////////////////
|
|
4964
|
+
////////// //////////
|
|
4965
|
+
////////// z.custom //////////
|
|
4966
|
+
////////// //////////
|
|
4967
|
+
////////////////////////////////////////
|
|
4968
|
+
////////////////////////////////////////
|
|
4969
|
+
function cleanParams(params, data) {
|
|
4970
|
+
const p = typeof params === "function"
|
|
4971
|
+
? params(data)
|
|
4972
|
+
: typeof params === "string"
|
|
4973
|
+
? { message: params }
|
|
4974
|
+
: params;
|
|
4975
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
|
4976
|
+
return p2;
|
|
4977
|
+
}
|
|
4978
|
+
function custom(check, _params = {},
|
|
4812
4979
|
/**
|
|
4813
4980
|
* @deprecated
|
|
4814
4981
|
*
|
|
@@ -4823,16 +4990,23 @@ fatal) {
|
|
|
4823
4990
|
if (check)
|
|
4824
4991
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
4825
4992
|
var _a, _b;
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4993
|
+
const r = check(data);
|
|
4994
|
+
if (r instanceof Promise) {
|
|
4995
|
+
return r.then((r) => {
|
|
4996
|
+
var _a, _b;
|
|
4997
|
+
if (!r) {
|
|
4998
|
+
const params = cleanParams(_params, data);
|
|
4999
|
+
const _fatal = (_b = (_a = params.fatal) !== null && _a !== undefined ? _a : fatal) !== null && _b !== undefined ? _b : true;
|
|
5000
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
5001
|
+
}
|
|
5002
|
+
});
|
|
5003
|
+
}
|
|
5004
|
+
if (!r) {
|
|
5005
|
+
const params = cleanParams(_params, data);
|
|
5006
|
+
const _fatal = (_b = (_a = params.fatal) !== null && _a !== undefined ? _a : fatal) !== null && _b !== undefined ? _b : true;
|
|
5007
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
4835
5008
|
}
|
|
5009
|
+
return;
|
|
4836
5010
|
});
|
|
4837
5011
|
return ZodAny.create();
|
|
4838
5012
|
}
|
|
@@ -22168,6 +22342,12 @@ var defineConfig = (config) => {
|
|
|
22168
22342
|
outputOptions: {
|
|
22169
22343
|
typesEntryPointFilename: "embeddable-types-entry-point.js",
|
|
22170
22344
|
},
|
|
22345
|
+
buildTime: undefined, // This will be set by the build process
|
|
22346
|
+
dev: {
|
|
22347
|
+
watch: false,
|
|
22348
|
+
logger: undefined,
|
|
22349
|
+
sys: undefined,
|
|
22350
|
+
},
|
|
22171
22351
|
pushModels,
|
|
22172
22352
|
pushComponents,
|
|
22173
22353
|
pushBaseUrl: pushBaseUrl !== null && pushBaseUrl !== undefined ? pushBaseUrl : regionConfig.pushBaseUrl,
|