@nmtjs/contract 0.4.7 → 0.5.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/schemas/event.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/schemas/event.ts"],"sourcesContent":["import type { BaseType, BaseTypeAny } from '@nmtjs/type'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\n\nexport const EventKind = 'NeemataEvent'\n\nexport interface TEventContract<\n Payload extends BaseTypeAny = BaseTypeAny,\n Name extends string | undefined = string | undefined,\n ServiceName extends string | undefined = string | undefined,\n SubscriptionName extends string | undefined = string | undefined,\n> {\n type: 'neemata:event'\n name: Name\n serviceName: ServiceName\n subscriptionName: SubscriptionName\n payload: Payload\n}\n\nexport const EventContract = <Payload extends BaseTypeAny>(\n payload: Payload,\n schemaOptions: ContractSchemaOptions = {} as ContractSchemaOptions,\n) => {\n return createSchema<TEventContract<Payload>>({\n ...schemaOptions,\n type: 'neemata:event',\n payload,\n name: undefined,\n serviceName: undefined,\n subscriptionName: undefined,\n })\n}\n"],"names":["createSchema","EventKind","EventContract","payload","schemaOptions","type","name","undefined","serviceName","subscriptionName"],"mappings":"AACA,SAAqCA,YAAY,QAAQ,cAAa;AAEtE,OAAO,MAAMC,YAAY,eAAc;AAevC,OAAO,MAAMC,gBAAgB,CAC3BC,SACAC,gBAAuC,CAAC,CAA0B;IAElE,OAAOJ,aAAsC;QAC3C,GAAGI,aAAa;QAChBC,MAAM;QACNF;QACAG,MAAMC;QACNC,aAAaD;QACbE,kBAAkBF;IACpB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/schemas/procedure.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/schemas/procedure.ts"],"sourcesContent":["import type { BaseTypeAny } from '@nmtjs/type'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\n\nexport interface TBaseProcedureContract<\n Type extends string = string,\n Input extends BaseTypeAny = BaseTypeAny,\n Output extends BaseTypeAny = BaseTypeAny,\n Name extends string | undefined = string | undefined,\n ServiceName extends string | undefined = string | undefined,\n Transports extends { [K in string]?: true } | undefined =\n | { [K in string]?: true }\n | undefined,\n> {\n type: Type\n name: Name\n serviceName: ServiceName\n transports: Transports\n input: Input\n output: Output\n timeout?: number\n}\n\nexport interface TProcedureContract<\n Input extends BaseTypeAny = BaseTypeAny,\n Output extends BaseTypeAny = BaseTypeAny,\n Name extends string | undefined = string | undefined,\n ServiceName extends string | undefined = string | undefined,\n Transports extends { [K in string]?: true } | undefined =\n | { [K in string]?: true }\n | undefined,\n> extends TBaseProcedureContract<\n 'neemata:procedure',\n Input,\n Output,\n Name,\n ServiceName,\n Transports\n > {}\n\nexport const ProcedureContract = <\n Input extends BaseTypeAny,\n Output extends BaseTypeAny,\n>(\n input: Input,\n output: Output,\n timeout?: number,\n schemaOptions: ContractSchemaOptions = {} as ContractSchemaOptions,\n): TProcedureContract<Input, Output> => {\n return {\n ...schemaOptions,\n type: 'neemata:procedure',\n input,\n output,\n timeout,\n name: undefined,\n serviceName: undefined,\n transports: undefined,\n }\n}\n"],"names":["ProcedureContract","input","output","timeout","schemaOptions","type","name","undefined","serviceName","transports"],"mappings":"AAuCA,OAAO,MAAMA,oBAAoB,CAI/BC,OACAC,QACAC,SACAC,gBAAuC,CAAC,CAA0B;IAElE,OAAO;QACL,GAAGA,aAAa;QAChBC,MAAM;QACNJ;QACAC;QACAC;QACAG,MAAMC;QACNC,aAAaD;QACbE,YAAYF;IACd;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/schemas/subscription.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/schemas/subscription.ts"],"sourcesContent":["import type { BaseTypeAny } from '@nmtjs/type'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\nimport type { TEventContract } from './event.ts'\nimport type { TBaseProcedureContract } from './procedure.ts'\n\nexport type SubcriptionOptions = Record<string, string | number>\n\nexport interface TSubscriptionContract<\n Input extends BaseTypeAny = BaseTypeAny,\n Output extends BaseTypeAny = BaseTypeAny,\n Options extends SubcriptionOptions = SubcriptionOptions,\n Events extends Record<string, TEventContract> = Record<\n string,\n TEventContract\n >,\n Name extends string | undefined = string | undefined,\n ServiceName extends string | undefined = string | undefined,\n Transports extends { [K in string]?: true } | undefined =\n | { [K in string]?: true }\n | undefined,\n> extends TBaseProcedureContract<\n 'neemata:subscription',\n Input,\n Output,\n Name,\n ServiceName,\n Transports\n > {\n options: Options\n events: Events\n}\n\nexport const SubscriptionContract = <\n Input extends BaseTypeAny = BaseTypeAny,\n Output extends BaseTypeAny = BaseTypeAny,\n Events extends Record<string, TEventContract> = Record<\n string,\n TEventContract\n >,\n>(\n input: Input,\n output: Output,\n events: Events,\n timeout?: number,\n schemaOptions: ContractSchemaOptions = {} as ContractSchemaOptions,\n) => {\n return {\n $withOptions: <Options extends SubcriptionOptions>() =>\n createSchema<TSubscriptionContract<Input, Output, Options, Events>>({\n ...schemaOptions,\n type: 'neemata:subscription',\n input,\n output,\n events,\n timeout,\n options: undefined as unknown as Options,\n name: undefined,\n serviceName: undefined,\n transports: undefined,\n }),\n }\n}\n"],"names":["createSchema","SubscriptionContract","input","output","events","timeout","schemaOptions","$withOptions","type","options","undefined","name","serviceName","transports"],"mappings":"AACA,SAAqCA,YAAY,QAAQ,cAAa;AA+BtE,OAAO,MAAMC,uBAAuB,CAQlCC,OACAC,QACAC,QACAC,SACAC,gBAAuC,CAAC,CAA0B;IAElE,OAAO;QACLC,cAAc,IACZP,aAAoE;gBAClE,GAAGM,aAAa;gBAChBE,MAAM;gBACNN;gBACAC;gBACAC;gBACAC;gBACAI,SAASC;gBACTC,MAAMD;gBACNE,aAAaF;gBACbG,YAAYH;YACd;IACJ;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@nmtjs/
|
|
13
|
-
"@nmtjs/
|
|
12
|
+
"@nmtjs/common": "0.5.0",
|
|
13
|
+
"@nmtjs/type": "0.5.0"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"src",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"LICENSE.md",
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
|
-
"version": "0.
|
|
22
|
+
"version": "0.5.0",
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "neemata-build -p neutral --root=./src './**/*.ts'",
|
|
25
25
|
"type-check": "tsc --noEmit"
|
package/src/schemas/event.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BaseType, BaseTypeAny } from '@nmtjs/type'
|
|
2
2
|
import { type ContractSchemaOptions, createSchema } from '../utils.ts'
|
|
3
3
|
|
|
4
4
|
export const EventKind = 'NeemataEvent'
|
|
5
5
|
|
|
6
6
|
export interface TEventContract<
|
|
7
|
-
Payload extends
|
|
7
|
+
Payload extends BaseTypeAny = BaseTypeAny,
|
|
8
8
|
Name extends string | undefined = string | undefined,
|
|
9
9
|
ServiceName extends string | undefined = string | undefined,
|
|
10
10
|
SubscriptionName extends string | undefined = string | undefined,
|
|
@@ -16,7 +16,7 @@ export interface TEventContract<
|
|
|
16
16
|
payload: Payload
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const EventContract = <Payload extends
|
|
19
|
+
export const EventContract = <Payload extends BaseTypeAny>(
|
|
20
20
|
payload: Payload,
|
|
21
21
|
schemaOptions: ContractSchemaOptions = {} as ContractSchemaOptions,
|
|
22
22
|
) => {
|
package/src/schemas/procedure.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BaseTypeAny } from '@nmtjs/type'
|
|
2
2
|
import { type ContractSchemaOptions, createSchema } from '../utils.ts'
|
|
3
3
|
|
|
4
4
|
export interface TBaseProcedureContract<
|
|
5
5
|
Type extends string = string,
|
|
6
|
-
Input extends
|
|
7
|
-
Output extends
|
|
6
|
+
Input extends BaseTypeAny = BaseTypeAny,
|
|
7
|
+
Output extends BaseTypeAny = BaseTypeAny,
|
|
8
8
|
Name extends string | undefined = string | undefined,
|
|
9
9
|
ServiceName extends string | undefined = string | undefined,
|
|
10
10
|
Transports extends { [K in string]?: true } | undefined =
|
|
@@ -21,8 +21,8 @@ export interface TBaseProcedureContract<
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface TProcedureContract<
|
|
24
|
-
Input extends
|
|
25
|
-
Output extends
|
|
24
|
+
Input extends BaseTypeAny = BaseTypeAny,
|
|
25
|
+
Output extends BaseTypeAny = BaseTypeAny,
|
|
26
26
|
Name extends string | undefined = string | undefined,
|
|
27
27
|
ServiceName extends string | undefined = string | undefined,
|
|
28
28
|
Transports extends { [K in string]?: true } | undefined =
|
|
@@ -38,8 +38,8 @@ export interface TProcedureContract<
|
|
|
38
38
|
> {}
|
|
39
39
|
|
|
40
40
|
export const ProcedureContract = <
|
|
41
|
-
Input extends
|
|
42
|
-
Output extends
|
|
41
|
+
Input extends BaseTypeAny,
|
|
42
|
+
Output extends BaseTypeAny,
|
|
43
43
|
>(
|
|
44
44
|
input: Input,
|
|
45
45
|
output: Output,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BaseTypeAny } from '@nmtjs/type'
|
|
2
2
|
import { type ContractSchemaOptions, createSchema } from '../utils.ts'
|
|
3
3
|
import type { TEventContract } from './event.ts'
|
|
4
4
|
import type { TBaseProcedureContract } from './procedure.ts'
|
|
@@ -6,8 +6,8 @@ import type { TBaseProcedureContract } from './procedure.ts'
|
|
|
6
6
|
export type SubcriptionOptions = Record<string, string | number>
|
|
7
7
|
|
|
8
8
|
export interface TSubscriptionContract<
|
|
9
|
-
Input extends
|
|
10
|
-
Output extends
|
|
9
|
+
Input extends BaseTypeAny = BaseTypeAny,
|
|
10
|
+
Output extends BaseTypeAny = BaseTypeAny,
|
|
11
11
|
Options extends SubcriptionOptions = SubcriptionOptions,
|
|
12
12
|
Events extends Record<string, TEventContract> = Record<
|
|
13
13
|
string,
|
|
@@ -31,8 +31,8 @@ export interface TSubscriptionContract<
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const SubscriptionContract = <
|
|
34
|
-
Input extends
|
|
35
|
-
Output extends
|
|
34
|
+
Input extends BaseTypeAny = BaseTypeAny,
|
|
35
|
+
Output extends BaseTypeAny = BaseTypeAny,
|
|
36
36
|
Events extends Record<string, TEventContract> = Record<
|
|
37
37
|
string,
|
|
38
38
|
TEventContract
|