@nmtjs/type 0.16.1 → 0.17.0-beta.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/LICENSE.md +1 -1
- package/README.md +41 -1
- package/dist/standart-schema.js +1 -1
- package/dist/standart-schema.js.map +1 -1
- package/dist/temporal/polyfill.js +8 -24
- package/dist/temporal/polyfill.js.map +1 -1
- package/dist/types/base.d.ts +4 -4
- package/dist/types/base.js.map +1 -1
- package/dist/types/custom.d.ts +1 -1
- package/dist/types/custom.js +7 -2
- package/dist/types/custom.js.map +1 -1
- package/package.json +4 -7
- package/src/standart-schema.ts +5 -5
- package/src/temporal/polyfill.ts +8 -40
- package/src/types/base.ts +4 -5
- package/src/types/custom.ts +8 -2
- package/src/types/union.ts +4 -4
package/LICENSE.md
CHANGED
|
@@ -4,4 +4,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
4
4
|
|
|
5
5
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
6
|
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,9 +1,49 @@
|
|
|
1
1
|
# NeemataJS - RPC application server for real-time applications (proof of concept)
|
|
2
2
|
|
|
3
3
|
### Built with following in mind:
|
|
4
|
+
|
|
4
5
|
- transport-agnostic (like WebSockets, WebTransport, .etc)
|
|
5
6
|
- format-agnostic (like JSON, MessagePack, BSON, .etc)
|
|
6
7
|
- binary data streaming and event subscriptions
|
|
7
8
|
- contract-based API
|
|
8
9
|
- end-to-end type safety
|
|
9
|
-
- CPU-intensive task execution on separate workers
|
|
10
|
+
- CPU-intensive task execution on separate workers
|
|
11
|
+
|
|
12
|
+
## Neem CLI draft
|
|
13
|
+
|
|
14
|
+
`neem build` compiles config, app entries, plugin entries, and plugin-declared
|
|
15
|
+
artifacts into `dist` by default. It writes an internal `neem.manifest.json`
|
|
16
|
+
with relative artifact paths.
|
|
17
|
+
|
|
18
|
+
`neem start` consumes an existing built output directory. It reads the manifest
|
|
19
|
+
for executable artifacts and serialized runtime config, registers built plugin
|
|
20
|
+
hooks, and starts app workers in production mode.
|
|
21
|
+
|
|
22
|
+
`neem dev` uses `.neem` by default as a build-like watched output directory. It
|
|
23
|
+
uses the same manifest shape as `start`, restarts app workers after successful
|
|
24
|
+
config/app rebuilds, reloads plugin hooks after plugin entry rebuilds, and keeps
|
|
25
|
+
existing workers alive on rebuild errors.
|
|
26
|
+
|
|
27
|
+
## Service integration tests
|
|
28
|
+
|
|
29
|
+
Service-backed package integration tests live beside package owners under
|
|
30
|
+
`packages/*/tests/integration`.
|
|
31
|
+
|
|
32
|
+
Local services:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
docker compose up -d --wait redis valkey kafka
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Run required service tests:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
NMTJS_REQUIRE_SERVICE_TESTS=1 \
|
|
42
|
+
REDIS_URL=redis://localhost:6379 \
|
|
43
|
+
VALKEY_URL=redis://localhost:6380 \
|
|
44
|
+
KAFKA_BROKERS=localhost:9092 \
|
|
45
|
+
pnpm run test:integration:services
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Without service env, these tests skip in normal package/root test runs. In CI,
|
|
49
|
+
`NMTJS_REQUIRE_SERVICE_TESTS=1` makes missing service env fail instead of skip.
|
package/dist/standart-schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standart-schema.js","sourceRoot":"","sources":["../src/standart-schema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAK7C,MAAM,KAAW,QAAQ,CAsIxB;AAtID,WAAiB,QAAQ;IAoBV,eAAM,GAAG,CACpB,IAAO,EACP,QAA0B,EACE,EAAE;QAC9B,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC;gBACzB,MAAM,EAAE,cAAc;gBACtB,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,CAAC,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"standart-schema.js","sourceRoot":"","sources":["../src/standart-schema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAK7C,MAAM,KAAW,QAAQ,CAsIxB;AAtID,WAAiB,QAAQ;IAoBV,eAAM,GAAG,CACpB,IAAO,EACP,QAA0B,EACE,EAAE;QAC9B,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC;gBACzB,MAAM,EAAE,cAAc;gBACtB,OAAO,EAAE,CAAC;gBACV,Q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pC,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,CAAC,cAAc,IAAI,EAAE,CAE1C,CAAA;wBACD,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAA;wBACpD,OAAO,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE;4BACtC,MAAM;4BACN,EAAE,EAAE,OAAO;4BACX,MAAM;4BACN,MAAM;4BACN,eAAe,EAAE,KAAK;4BACtB,QAAQ,EAAE,QAAQ;yBACnB,CAAC,CAAA;oBACJ,CAAC;oBACD,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,EAAE;wBACrC,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,CAAC,cAAc,IAAI,EAAE,CAE1C,CAAA;wBACD,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAA;wBACpD,OAAO,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE;4BACtC,MAAM;4BACN,EAAE,EAAE,QAAQ;4BACZ,MAAM;4BACN,MAAM;4BACN,eAAe,EAAE,KAAK;yBACvB,CAAC,CAAA;oBACJ,CAAC;iBACF;aACkC,CAAC;SACvC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC,EAtIgB,QAAQ,KAAR,QAAQ,QAsIxB"}
|
|
@@ -1,27 +1,11 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
2
|
import { DurationType, InstantType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from '../types/temporal.js';
|
|
3
|
-
export const plainDate = PlainDateType.factory.bind(PlainDateType,
|
|
4
|
-
|
|
5
|
-
Temporal);
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
Temporal);
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
Temporal);
|
|
12
|
-
export const zonedDatetime = ZonedDateTimeType.factory.bind(ZonedDateTimeType,
|
|
13
|
-
// @ts-expect-error
|
|
14
|
-
Temporal);
|
|
15
|
-
export const instant = InstantType.factory.bind(InstantType,
|
|
16
|
-
// @ts-expect-error
|
|
17
|
-
Temporal);
|
|
18
|
-
export const duration = DurationType.factory.bind(DurationType,
|
|
19
|
-
// @ts-expect-error
|
|
20
|
-
Temporal);
|
|
21
|
-
export const plainYearMonth = PlainYearMonthType.factory.bind(PlainYearMonthType,
|
|
22
|
-
// @ts-expect-error
|
|
23
|
-
Temporal);
|
|
24
|
-
export const plainMonthDay = PlainMonthDayType.factory.bind(PlainMonthDayType,
|
|
25
|
-
// @ts-expect-error
|
|
26
|
-
Temporal);
|
|
3
|
+
export const plainDate = PlainDateType.factory.bind(PlainDateType, Temporal);
|
|
4
|
+
export const plainDatetime = PlainDateTimeType.factory.bind(PlainDateTimeType, Temporal);
|
|
5
|
+
export const plainTime = PlainTimeType.factory.bind(PlainTimeType, Temporal);
|
|
6
|
+
export const zonedDatetime = ZonedDateTimeType.factory.bind(ZonedDateTimeType, Temporal);
|
|
7
|
+
export const instant = InstantType.factory.bind(InstantType, Temporal);
|
|
8
|
+
export const duration = DurationType.factory.bind(DurationType, Temporal);
|
|
9
|
+
export const plainYearMonth = PlainYearMonthType.factory.bind(PlainYearMonthType, Temporal);
|
|
10
|
+
export const plainMonthDay = PlainMonthDayType.factory.bind(PlainMonthDayType, Temporal);
|
|
27
11
|
//# sourceMappingURL=polyfill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../src/temporal/polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,sBAAsB,CAAA;A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ts
CHANGED
|
@@ -4,8 +4,8 @@ import type { TypeMetadata } from './_metadata.ts';
|
|
|
4
4
|
import { standard } from '../standart-schema.ts';
|
|
5
5
|
export type PrimitiveValueType = string | number | boolean | null;
|
|
6
6
|
export type PrimitiveZodType = ZodMiniNever | ZodMiniDefault | ZodMiniNullable | ZodMiniOptional | ZodMiniString | ZodMiniObject | ZodMiniAny | ZodMiniArray | ZodMiniBoolean | ZodMiniNumber | ZodMiniEnum<any> | ZodMiniLiteral<PrimitiveValueType> | ZodMiniUnion | ZodMiniIntersection | ZodMiniRecord;
|
|
7
|
-
export type SimpleZodType = ZodMiniType
|
|
8
|
-
export type ZodType = SimpleZodType | ZodMiniType
|
|
7
|
+
export type SimpleZodType = ZodMiniType<any, any, any>;
|
|
8
|
+
export type ZodType = SimpleZodType | ZodMiniType<any, any, any>;
|
|
9
9
|
export type TypeProps = Record<string, any>;
|
|
10
10
|
export type TypeParams = {
|
|
11
11
|
encode?: (value: any) => any;
|
|
@@ -16,7 +16,7 @@ export type DefaultTypeParams = {
|
|
|
16
16
|
encode?: TypeParams['encode'];
|
|
17
17
|
metadata?: TypeMetadata;
|
|
18
18
|
};
|
|
19
|
-
export type BaseTypeAny<EncodedZodType extends SimpleZodType = SimpleZodType, DecodedZodType extends ZodType = ZodMiniType> = BaseType<EncodedZodType, DecodedZodType,
|
|
19
|
+
export type BaseTypeAny<EncodedZodType extends SimpleZodType = SimpleZodType, DecodedZodType extends ZodType = ZodMiniType> = BaseType<EncodedZodType, DecodedZodType, any>;
|
|
20
20
|
export declare const NeemataTypeError: core.$constructor<core.$ZodError<unknown>, core.$ZodIssue[]>;
|
|
21
21
|
export type NeemataTypeError = core.$ZodError;
|
|
22
22
|
export declare abstract class BaseType<EncodeZodType extends SimpleZodType = SimpleZodType, DecodeZodType extends ZodType = EncodeZodType, Props extends TypeProps = TypeProps> implements standard.Schema<DecodeZodType> {
|
|
@@ -29,7 +29,7 @@ export declare abstract class BaseType<EncodeZodType extends SimpleZodType = Sim
|
|
|
29
29
|
decode: standard.Schema<DecodeZodType>;
|
|
30
30
|
};
|
|
31
31
|
readonly '~standard': standard.Props<DecodeZodType>;
|
|
32
|
-
constructor({ encodeZodType, decodeZodType, props, params }: {
|
|
32
|
+
constructor({ encodeZodType, decodeZodType, props, params, }: {
|
|
33
33
|
encodeZodType: EncodeZodType;
|
|
34
34
|
decodeZodType?: DecodeZodType;
|
|
35
35
|
props?: Props;
|
package/dist/types/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/types/base.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAG7D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AA2C9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAA;AAG9C,MAAM,OAAgB,QAAQ;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/types/base.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAG7D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AA2C9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAA;AAG9C,MAAM,OAAgB,QAAQ;IAKnB,aAAa,CAAe;IAC5B,aAAa,CAAe;IAC5B,KAAK,CAAO;IACZ,MAAM,CAAY;IAClB,QAAQ,CAGhB;IACQ,WAAW,CAA+B;IAEnD,YAAY,EACV,aAAa,EACb,aAAa,GAAG,aAAyC,EACzD,KAAK,GAAG,EAAW,EACnB,MAAM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,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;YAC3C,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;SACvB,CAAC,CAAA;IACJ,CAAC;CACF;AAED,MAAM,OAAO,WAEX,SAAQ,QAIT;IACC,MAAM,CAAC,OAAO,CAA6B,IAAO,EAAE,YAAiB;QACnE,OAAO,IAAI,WAAW,CAAI;YACxB,aAAa,EAAE,QAAQ,CACrB,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,IAAI,YAAY,CACnD;YACD,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC;YACzD,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;SACvB,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/types/custom.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type CustomTransformFn<I, O> = (value: I) => O;
|
|
|
6
6
|
export declare abstract class TransformType<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>> extends BaseType<ZodMiniType<EncodeType['_zod']['output'], DecodeType['_zod']['input']>, ZodMiniType<DecodeType['_zod']['output'], EncodeType['_zod']['input']>> {
|
|
7
7
|
}
|
|
8
8
|
export declare class CustomType<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>> extends TransformType<Type, EncodeType, DecodeType> {
|
|
9
|
-
static factory<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>>({ decode, encode, validation, error, type, prototype }: {
|
|
9
|
+
static factory<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>>({ decode, encode, validation, error, type, prototype, }: {
|
|
10
10
|
decode: CustomTransformFn<EncodeType['_zod']['input'], DecodeType['_zod']['output']>;
|
|
11
11
|
encode: CustomTransformFn<DecodeType['_zod']['input'], EncodeType['_zod']['output']>;
|
|
12
12
|
validation?: ((value: EncodeType['_zod']['input'] | DecodeType['_zod']['output'], payload: core.$RefinementCtx<EncodeType['_zod']['output'] | DecodeType['_zod']['output']>) => MaybePromise<void>) | {
|
package/dist/types/custom.js
CHANGED
|
@@ -9,15 +9,20 @@ export class CustomType extends TransformType {
|
|
|
9
9
|
? { encode: validation, decode: validation }
|
|
10
10
|
: validation
|
|
11
11
|
: undefined;
|
|
12
|
+
const errorParams = typeof error === 'string'
|
|
13
|
+
? error
|
|
14
|
+
: error
|
|
15
|
+
? { error: error }
|
|
16
|
+
: undefined;
|
|
12
17
|
const instance = new CustomType({
|
|
13
|
-
encodeZodType: pipe(zodCustom().check(...[
|
|
18
|
+
encodeZodType: pipe(zodCustom(undefined, errorParams).check(...[
|
|
14
19
|
refine((val) => typeof val !== 'undefined', { abort: true }),
|
|
15
20
|
_validation?.encode ? superRefine(_validation.encode) : undefined,
|
|
16
21
|
overwrite(encode),
|
|
17
22
|
].filter((v) => !!v)), type),
|
|
18
23
|
decodeZodType: pipe(type,
|
|
19
24
|
// @ts-expect-error
|
|
20
|
-
zodCustom().check(...[
|
|
25
|
+
zodCustom(undefined, errorParams).check(...[
|
|
21
26
|
refine((val) => typeof val !== 'undefined', { abort: true }),
|
|
22
27
|
overwrite(decode),
|
|
23
28
|
_validation?.decode ? superRefine(_validation.decode) : undefined,
|
package/dist/types/custom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/types/custom.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EACH,SAAS,EACT,IAAI,EACJ,MAAM,EACN,WAAW,EACX,MAAM,IAAI,SAAS,GACpB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,MAAM,OAAgB,aAIpB,SAAQ,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polyfill": "^0.3.2",
|
|
43
43
|
"zod": "^4.0.0",
|
|
44
|
-
"@nmtjs/common": "0.
|
|
44
|
+
"@nmtjs/common": "0.17.0-beta.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"temporal-polyfill": "^0.
|
|
47
|
+
"temporal-polyfill": "^1.0.1",
|
|
48
48
|
"zod": "^4.0.0",
|
|
49
|
-
"@nmtjs/common": "0.
|
|
49
|
+
"@nmtjs/common": "0.17.0-beta.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"temporal-polyfill": {
|
|
53
53
|
"optional": true
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
"version": "0.
|
|
56
|
+
"version": "0.17.0-beta.1",
|
|
57
57
|
"repository": {
|
|
58
58
|
"type": "git",
|
|
59
59
|
"url": "https://github.com/neematajs/neemata"
|
|
60
|
-
},
|
|
61
|
-
"scripts": {
|
|
62
|
-
"clean-build": "rm -rf ./dist"
|
|
63
60
|
}
|
|
64
61
|
}
|
package/src/standart-schema.ts
CHANGED
|
@@ -37,7 +37,7 @@ export namespace standard {
|
|
|
37
37
|
'~standard': Object.freeze({
|
|
38
38
|
vendor: 'neemata-type',
|
|
39
39
|
version: 1,
|
|
40
|
-
validate: (value,
|
|
40
|
+
validate: (value, _options = {}) => {
|
|
41
41
|
try {
|
|
42
42
|
return { value: type.decode(value) }
|
|
43
43
|
} catch (e) {
|
|
@@ -56,7 +56,7 @@ export namespace standard {
|
|
|
56
56
|
jsonSchema: {
|
|
57
57
|
input: ({ target, libraryOptions }) => {
|
|
58
58
|
const { json = {} } = (libraryOptions || {}) as {
|
|
59
|
-
json
|
|
59
|
+
json?: ToJSONSchemaParams
|
|
60
60
|
}
|
|
61
61
|
const { cycles = 'throw', reused = 'inline' } = json
|
|
62
62
|
return toJSONSchema(type.decodeZodType, {
|
|
@@ -70,7 +70,7 @@ export namespace standard {
|
|
|
70
70
|
},
|
|
71
71
|
output: ({ target, libraryOptions }) => {
|
|
72
72
|
const { json = {} } = (libraryOptions || {}) as {
|
|
73
|
-
json
|
|
73
|
+
json?: ToJSONSchemaParams
|
|
74
74
|
}
|
|
75
75
|
const { cycles = 'throw', reused = 'inline' } = json
|
|
76
76
|
return toJSONSchema(type.decodeZodType, {
|
|
@@ -114,7 +114,7 @@ export namespace standard {
|
|
|
114
114
|
jsonSchema: {
|
|
115
115
|
input: ({ target, libraryOptions }) => {
|
|
116
116
|
const { json = {} } = (libraryOptions || {}) as {
|
|
117
|
-
json
|
|
117
|
+
json?: ToJSONSchemaParams
|
|
118
118
|
}
|
|
119
119
|
const { cycles = 'throw', reused = 'inline' } = json
|
|
120
120
|
return toJSONSchema(type.encodeZodType, {
|
|
@@ -128,7 +128,7 @@ export namespace standard {
|
|
|
128
128
|
},
|
|
129
129
|
output: ({ target, libraryOptions }) => {
|
|
130
130
|
const { json = {} } = (libraryOptions || {}) as {
|
|
131
|
-
json
|
|
131
|
+
json?: ToJSONSchemaParams
|
|
132
132
|
}
|
|
133
133
|
const { cycles = 'throw', reused = 'inline' } = json
|
|
134
134
|
return toJSONSchema(type.encodeZodType, {
|
package/src/temporal/polyfill.ts
CHANGED
|
@@ -13,72 +13,40 @@ import {
|
|
|
13
13
|
|
|
14
14
|
export const plainDate = PlainDateType.factory.bind(
|
|
15
15
|
PlainDateType,
|
|
16
|
-
// @ts-expect-error
|
|
17
16
|
Temporal,
|
|
18
|
-
) as () => PlainDateType<
|
|
19
|
-
// @ts-expect-error
|
|
20
|
-
typeof Temporal
|
|
21
|
-
>
|
|
17
|
+
) as () => PlainDateType<typeof Temporal>
|
|
22
18
|
|
|
23
19
|
export const plainDatetime = PlainDateTimeType.factory.bind(
|
|
24
20
|
PlainDateTimeType,
|
|
25
|
-
// @ts-expect-error
|
|
26
21
|
Temporal,
|
|
27
|
-
) as () => PlainDateTimeType<
|
|
28
|
-
// @ts-expect-error
|
|
29
|
-
typeof Temporal
|
|
30
|
-
>
|
|
22
|
+
) as () => PlainDateTimeType<typeof Temporal>
|
|
31
23
|
|
|
32
24
|
export const plainTime = PlainTimeType.factory.bind(
|
|
33
25
|
PlainTimeType,
|
|
34
|
-
// @ts-expect-error
|
|
35
26
|
Temporal,
|
|
36
|
-
) as () => PlainTimeType<
|
|
37
|
-
// @ts-expect-error
|
|
38
|
-
typeof Temporal
|
|
39
|
-
>
|
|
27
|
+
) as () => PlainTimeType<typeof Temporal>
|
|
40
28
|
|
|
41
29
|
export const zonedDatetime = ZonedDateTimeType.factory.bind(
|
|
42
30
|
ZonedDateTimeType,
|
|
43
|
-
// @ts-expect-error
|
|
44
31
|
Temporal,
|
|
45
|
-
) as () => ZonedDateTimeType<
|
|
46
|
-
// @ts-expect-error
|
|
47
|
-
typeof Temporal
|
|
48
|
-
>
|
|
32
|
+
) as () => ZonedDateTimeType<typeof Temporal>
|
|
49
33
|
|
|
50
34
|
export const instant = InstantType.factory.bind(
|
|
51
35
|
InstantType,
|
|
52
|
-
// @ts-expect-error
|
|
53
36
|
Temporal,
|
|
54
|
-
) as () => InstantType<
|
|
55
|
-
// @ts-expect-error
|
|
56
|
-
typeof Temporal
|
|
57
|
-
>
|
|
37
|
+
) as () => InstantType<typeof Temporal>
|
|
58
38
|
|
|
59
39
|
export const duration = DurationType.factory.bind(
|
|
60
40
|
DurationType,
|
|
61
|
-
// @ts-expect-error
|
|
62
41
|
Temporal,
|
|
63
|
-
) as () => DurationType<
|
|
64
|
-
// @ts-expect-error
|
|
65
|
-
typeof Temporal
|
|
66
|
-
>
|
|
42
|
+
) as () => DurationType<typeof Temporal>
|
|
67
43
|
|
|
68
44
|
export const plainYearMonth = PlainYearMonthType.factory.bind(
|
|
69
45
|
PlainYearMonthType,
|
|
70
|
-
// @ts-expect-error
|
|
71
46
|
Temporal,
|
|
72
|
-
) as () => PlainYearMonthType<
|
|
73
|
-
// @ts-expect-error
|
|
74
|
-
typeof Temporal
|
|
75
|
-
>
|
|
47
|
+
) as () => PlainYearMonthType<typeof Temporal>
|
|
76
48
|
|
|
77
49
|
export const plainMonthDay = PlainMonthDayType.factory.bind(
|
|
78
50
|
PlainMonthDayType,
|
|
79
|
-
// @ts-expect-error
|
|
80
51
|
Temporal,
|
|
81
|
-
) as () => PlainMonthDayType<
|
|
82
|
-
// @ts-expect-error
|
|
83
|
-
typeof Temporal
|
|
84
|
-
>
|
|
52
|
+
) as () => PlainMonthDayType<typeof Temporal>
|
package/src/types/base.ts
CHANGED
|
@@ -41,9 +41,9 @@ export type PrimitiveZodType =
|
|
|
41
41
|
| ZodMiniIntersection
|
|
42
42
|
| ZodMiniRecord
|
|
43
43
|
|
|
44
|
-
export type SimpleZodType = ZodMiniType
|
|
44
|
+
export type SimpleZodType = ZodMiniType<any, any, any>
|
|
45
45
|
|
|
46
|
-
export type ZodType = SimpleZodType | ZodMiniType
|
|
46
|
+
export type ZodType = SimpleZodType | ZodMiniType<any, any, any>
|
|
47
47
|
|
|
48
48
|
export type TypeProps = Record<string, any>
|
|
49
49
|
|
|
@@ -61,7 +61,7 @@ export type DefaultTypeParams = {
|
|
|
61
61
|
export type BaseTypeAny<
|
|
62
62
|
EncodedZodType extends SimpleZodType = SimpleZodType,
|
|
63
63
|
DecodedZodType extends ZodType = ZodMiniType,
|
|
64
|
-
> = BaseType<EncodedZodType, DecodedZodType,
|
|
64
|
+
> = BaseType<EncodedZodType, DecodedZodType, any>
|
|
65
65
|
|
|
66
66
|
export const NeemataTypeError = core.$ZodError
|
|
67
67
|
export type NeemataTypeError = core.$ZodError
|
|
@@ -70,8 +70,7 @@ export abstract class BaseType<
|
|
|
70
70
|
EncodeZodType extends SimpleZodType = SimpleZodType,
|
|
71
71
|
DecodeZodType extends ZodType = EncodeZodType,
|
|
72
72
|
Props extends TypeProps = TypeProps,
|
|
73
|
-
> implements standard.Schema<DecodeZodType>
|
|
74
|
-
{
|
|
73
|
+
> implements standard.Schema<DecodeZodType> {
|
|
75
74
|
readonly encodeZodType: EncodeZodType
|
|
76
75
|
readonly decodeZodType: DecodeZodType
|
|
77
76
|
readonly props: Props
|
package/src/types/custom.ts
CHANGED
|
@@ -73,10 +73,16 @@ export class CustomType<
|
|
|
73
73
|
? { encode: validation, decode: validation }
|
|
74
74
|
: validation
|
|
75
75
|
: undefined
|
|
76
|
+
const errorParams =
|
|
77
|
+
typeof error === 'string'
|
|
78
|
+
? error
|
|
79
|
+
: error
|
|
80
|
+
? { error: error as any }
|
|
81
|
+
: undefined
|
|
76
82
|
|
|
77
83
|
const instance = new CustomType<Type, EncodeType, DecodeType>({
|
|
78
84
|
encodeZodType: pipe(
|
|
79
|
-
zodCustom().check(
|
|
85
|
+
zodCustom(undefined, errorParams).check(
|
|
80
86
|
...[
|
|
81
87
|
refine((val) => typeof val !== 'undefined', { abort: true }),
|
|
82
88
|
_validation?.encode ? superRefine(_validation.encode) : undefined,
|
|
@@ -88,7 +94,7 @@ export class CustomType<
|
|
|
88
94
|
decodeZodType: pipe(
|
|
89
95
|
type,
|
|
90
96
|
// @ts-expect-error
|
|
91
|
-
zodCustom().check(
|
|
97
|
+
zodCustom(undefined, errorParams).check(
|
|
92
98
|
...[
|
|
93
99
|
refine((val) => typeof val !== 'undefined', { abort: true }),
|
|
94
100
|
overwrite(decode),
|
package/src/types/union.ts
CHANGED
|
@@ -78,8 +78,8 @@ export type DiscriminatedUnionOptionType<K extends string> = ObjectType<
|
|
|
78
78
|
|
|
79
79
|
export class DiscriminatedUnionType<
|
|
80
80
|
K extends string = string,
|
|
81
|
-
T extends
|
|
82
|
-
|
|
81
|
+
T extends readonly DiscriminatedUnionOptionType<K>[] =
|
|
82
|
+
DiscriminatedUnionOptionType<K>[],
|
|
83
83
|
> extends BaseType<
|
|
84
84
|
ZodMiniDiscriminatedUnion<ArrayMap<T, 'encodeZodType'>>,
|
|
85
85
|
ZodMiniDiscriminatedUnion<ArrayMap<T, 'decodeZodType'>>,
|
|
@@ -87,8 +87,8 @@ export class DiscriminatedUnionType<
|
|
|
87
87
|
> {
|
|
88
88
|
static factory<
|
|
89
89
|
K extends string = string,
|
|
90
|
-
T extends
|
|
91
|
-
|
|
90
|
+
T extends readonly DiscriminatedUnionOptionType<K>[] =
|
|
91
|
+
DiscriminatedUnionOptionType<K>[],
|
|
92
92
|
>(key: K, ...options: T) {
|
|
93
93
|
const encode = options.map((t) => t.encodeZodType) as ArrayMap<
|
|
94
94
|
T,
|