@maestro-js/iso-zod 1.0.0-alpha.10
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/index.d.ts +28 -0
- package/dist/index.js +67 -0
- package/package.json +39 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Iso } from 'iso-fns';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const isoZ: {
|
|
5
|
+
instant: (_params?: Parameters<typeof z.custom>[1]) => z.ZodCustom<Iso.Instant, Iso.Instant>;
|
|
6
|
+
dateTime: (_params?: Parameters<typeof z.custom>[1]) => z.ZodCustom<Iso.DateTime, Iso.DateTime>;
|
|
7
|
+
zonedDateTime: (_params?: Parameters<typeof z.custom>[1]) => z.ZodCustom<Iso.ZonedDateTime, Iso.ZonedDateTime>;
|
|
8
|
+
date: (_params?: Parameters<typeof z.custom>[1]) => z.ZodCustom<`${number}-${number}-${number}`, `${number}-${number}-${number}`>;
|
|
9
|
+
time: (_params?: Parameters<typeof z.custom>[1]) => z.ZodCustom<Iso.Time, Iso.Time>;
|
|
10
|
+
yearMonth: (_params?: Parameters<typeof z.custom>[1]) => z.ZodCustom<`${number}-${number}`, `${number}-${number}`>;
|
|
11
|
+
monthDay: (_params?: Parameters<typeof z.custom>[1]) => z.ZodCustom<`--${number}-${number}`, `--${number}-${number}`>;
|
|
12
|
+
duration: (_params?: Parameters<typeof z.custom>[1]) => z.ZodCustom<Iso.Duration, Iso.Duration>;
|
|
13
|
+
isoZRegistry: z.core.$ZodRegistry<{
|
|
14
|
+
isoTypeName: "Date" | "Instant" | "DateTime" | "ZonedDateTime" | "Time" | "YearMonth" | "MonthDay" | "Duration";
|
|
15
|
+
}, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
16
|
+
};
|
|
17
|
+
declare namespace isoZ {
|
|
18
|
+
type instant = ReturnType<typeof instant>;
|
|
19
|
+
type dateTime = ReturnType<typeof dateTime>;
|
|
20
|
+
type zonedDateTime = ReturnType<typeof zonedDateTime>;
|
|
21
|
+
type date = ReturnType<typeof date>;
|
|
22
|
+
type time = ReturnType<typeof time>;
|
|
23
|
+
type yearMonth = ReturnType<typeof yearMonth>;
|
|
24
|
+
type monthDay = ReturnType<typeof monthDay>;
|
|
25
|
+
type duration = ReturnType<typeof duration>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { isoZ };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
dateFns,
|
|
4
|
+
dateTimeFns,
|
|
5
|
+
durationFns,
|
|
6
|
+
instantFns,
|
|
7
|
+
monthDayFns,
|
|
8
|
+
timeFns,
|
|
9
|
+
yearMonthFns,
|
|
10
|
+
zonedDateTimeFns
|
|
11
|
+
} from "iso-fns";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
var isoZRegistry = z.registry();
|
|
14
|
+
var instant = (_params) => {
|
|
15
|
+
const schema = z.custom((val) => instantFns.isValid(val), _params).meta({ jsonSchema: { type: "string", format: "date-time" } });
|
|
16
|
+
isoZRegistry.add(schema, { isoTypeName: "Instant" });
|
|
17
|
+
return schema;
|
|
18
|
+
};
|
|
19
|
+
var dateTime = (_params) => {
|
|
20
|
+
const schema = z.custom((val) => dateTimeFns.isValid(val), _params).meta({ jsonSchema: { type: "string", format: "date-time" } });
|
|
21
|
+
isoZRegistry.add(schema, { isoTypeName: "DateTime" });
|
|
22
|
+
return schema;
|
|
23
|
+
};
|
|
24
|
+
var zonedDateTime = (_params) => {
|
|
25
|
+
const schema = z.custom((val) => zonedDateTimeFns.isValid(val), _params).meta({ jsonSchema: { type: "string", format: "date-time" } });
|
|
26
|
+
isoZRegistry.add(schema, { isoTypeName: "ZonedDateTime" });
|
|
27
|
+
return schema;
|
|
28
|
+
};
|
|
29
|
+
var date = (_params) => {
|
|
30
|
+
const schema = z.custom((val) => dateFns.isValid(val), _params).meta({ jsonSchema: { type: "string", format: "date" } });
|
|
31
|
+
isoZRegistry.add(schema, { isoTypeName: "Date" });
|
|
32
|
+
return schema;
|
|
33
|
+
};
|
|
34
|
+
var time = (_params) => {
|
|
35
|
+
const schema = z.custom((val) => timeFns.isValid(val), _params).meta({ jsonSchema: { type: "string", format: "time" } });
|
|
36
|
+
isoZRegistry.add(schema, { isoTypeName: "Time" });
|
|
37
|
+
return schema;
|
|
38
|
+
};
|
|
39
|
+
var yearMonth = (_params) => {
|
|
40
|
+
const schema = z.custom((val) => yearMonthFns.isValid(val), _params).meta({ jsonSchema: { type: "string" } });
|
|
41
|
+
isoZRegistry.add(schema, { isoTypeName: "YearMonth" });
|
|
42
|
+
return schema;
|
|
43
|
+
};
|
|
44
|
+
var monthDay = (_params) => {
|
|
45
|
+
const schema = z.custom((val) => monthDayFns.isValid(val), _params).meta({ jsonSchema: { type: "string" } });
|
|
46
|
+
isoZRegistry.add(schema, { isoTypeName: "MonthDay" });
|
|
47
|
+
return schema;
|
|
48
|
+
};
|
|
49
|
+
var duration = (_params) => {
|
|
50
|
+
const schema = z.custom((val) => durationFns.isValid(val), _params).meta({ jsonSchema: { type: "string", format: "duration" } });
|
|
51
|
+
isoZRegistry.add(schema, { isoTypeName: "Duration" });
|
|
52
|
+
return schema;
|
|
53
|
+
};
|
|
54
|
+
var isoZ = {
|
|
55
|
+
instant,
|
|
56
|
+
dateTime,
|
|
57
|
+
zonedDateTime,
|
|
58
|
+
date,
|
|
59
|
+
time,
|
|
60
|
+
yearMonth,
|
|
61
|
+
monthDay,
|
|
62
|
+
duration,
|
|
63
|
+
isoZRegistry
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
isoZ
|
|
67
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maestro-js/iso-zod",
|
|
3
|
+
"description": "Zod custom schemas for ISO 8601 temporal types (Instant, DateTime, ZonedDateTime, Date, Time, YearMonth, MonthDay, Duration) backed by iso-fns validation. Use when defining Zod schemas that include ISO temporal fields. Provides isoZ factory functions that return typed Zod schemas and an isoZRegistry for introspecting registered ISO type metadata.",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"default": "./dist/index.js"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"iso-fns": "^2.0.0-alpha.26",
|
|
13
|
+
"zod": "^4.0.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^22.19.11",
|
|
17
|
+
"iso-fns": "^2.0.0-alpha.26",
|
|
18
|
+
"zod": "^4.0.0"
|
|
19
|
+
},
|
|
20
|
+
"version": "1.0.0-alpha.10",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "restricted"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"license": "UNLICENSED",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22.18.0"
|
|
30
|
+
},
|
|
31
|
+
"repository": "https://github.com/Marcato-Partners/maestro-js",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
34
|
+
"typecheck": "tsc --noEmit",
|
|
35
|
+
"test": "beartest ./tests/**/*",
|
|
36
|
+
"format": "prettier --write src/",
|
|
37
|
+
"lint": "prettier --check src/"
|
|
38
|
+
}
|
|
39
|
+
}
|