@nmtjs/contract 0.2.0 → 0.3.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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { t as baseT } from '@nmtjs/type'\nimport { EventContract, type TEventContract } from './schemas/event.ts'\n\nimport {\n ProcedureContract,\n type TBaseProcedureContract,\n type TProcedureContract,\n} from './schemas/procedure.ts'\nimport { ServiceContract, type TServiceContract } from './schemas/service.ts'\nimport {\n SubscriptionContract,\n type TSubscriptionContract,\n} from './schemas/subscription.ts'\nimport { blob as blobType } from './types/blob.ts'\n\nexport type {\n TEventContract,\n TProcedureContract,\n TBaseProcedureContract,\n TServiceContract,\n TSubscriptionContract,\n}\n\nexport namespace c {\n export const procedure = ProcedureContract\n export const event = EventContract\n export const subscription = SubscriptionContract\n export const service = ServiceContract\n export const blob = blobType\n}\n"],"names":["EventContract","ProcedureContract","ServiceContract","SubscriptionContract","blob","blobType","c","procedure","event","subscription","service"],"mappings":"AACA,SAASA,aAAa,QAA6B,qBAAoB;AAEvE,SACEC,iBAAiB,QAGZ,yBAAwB;AAC/B,SAASC,eAAe,QAA+B,uBAAsB;AAC7E,SACEC,oBAAoB,QAEf,4BAA2B;AAClC,SAASC,QAAQC,QAAQ,QAAQ,kBAAiB;;UAUjCC;MACFC,YAAYN;MACZO,QAAQR;MACRS,eAAeN;MACfO,UAAUR;MACVE,OAAOC;AACtB,GANiBC,MAAAA"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { EventContract, type TEventContract } from './schemas/event.ts'\n\nimport {\n ProcedureContract,\n type TBaseProcedureContract,\n type TProcedureContract,\n} from './schemas/procedure.ts'\nimport { ServiceContract, type TServiceContract } from './schemas/service.ts'\nimport {\n type SubcriptionOptions,\n SubscriptionContract,\n type TSubscriptionContract,\n} from './schemas/subscription.ts'\nimport { blob as blobType } from './types/blob.ts'\n\nexport type {\n TEventContract,\n TProcedureContract,\n TBaseProcedureContract,\n TServiceContract,\n TSubscriptionContract,\n SubcriptionOptions,\n}\n\nexport namespace c {\n export const procedure = ProcedureContract\n export const event = EventContract\n export const subscription = SubscriptionContract\n export const service = ServiceContract\n export const blob = blobType\n}\n"],"names":["EventContract","ProcedureContract","ServiceContract","SubscriptionContract","blob","blobType","c","procedure","event","subscription","service"],"mappings":"AAAA,SAASA,aAAa,QAA6B,qBAAoB;AAEvE,SACEC,iBAAiB,QAGZ,yBAAwB;AAC/B,SAASC,eAAe,QAA+B,uBAAsB;AAC7E,SAEEC,oBAAoB,QAEf,4BAA2B;AAClC,SAASC,QAAQC,QAAQ,QAAQ,kBAAiB;;UAWjCC;MACFC,YAAYN;MACZO,QAAQR;MACRS,eAAeN;MACfO,UAAUR;MACVE,OAAOC;AACtB,GANiBC,MAAAA"}
@@ -1,6 +1,5 @@
1
- import { createSchema } from "../utils.js";
2
1
  export const ProcedureContract = (input, output, timeout, schemaOptions = {})=>{
3
- return createSchema({
2
+ return {
4
3
  ...schemaOptions,
5
4
  type: 'neemata:procedure',
6
5
  input,
@@ -9,5 +8,5 @@ export const ProcedureContract = (input, output, timeout, schemaOptions = {})=>{
9
8
  name: undefined,
10
9
  serviceName: undefined,
11
10
  transports: undefined
12
- });
11
+ };
13
12
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/procedure.ts"],"sourcesContent":["import type { BaseType } from '@nmtjs/type'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\n\nexport interface TBaseProcedureContract<\n Type extends string = string,\n Input extends BaseType = BaseType,\n Output extends BaseType = BaseType,\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 BaseType = BaseType,\n Output extends BaseType = BaseType,\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 BaseType,\n Output extends BaseType,\n>(\n input: Input,\n output: Output,\n timeout?: number,\n schemaOptions: ContractSchemaOptions = {} as ContractSchemaOptions,\n) => {\n return createSchema<TProcedureContract<Input, Output>>({\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":["createSchema","ProcedureContract","input","output","timeout","schemaOptions","type","name","undefined","serviceName","transports"],"mappings":"AACA,SAAqCA,YAAY,QAAQ,cAAa;AAsCtE,OAAO,MAAMC,oBAAoB,CAI/BC,OACAC,QACAC,SACAC,gBAAuC,CAAC,CAA0B;IAElE,OAAOL,aAAgD;QACrD,GAAGK,aAAa;QAChBC,MAAM;QACNJ;QACAC;QACAC;QACAG,MAAMC;QACNC,aAAaD;QACbE,YAAYF;IACd;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/schemas/procedure.ts"],"sourcesContent":["import type { BaseType } from '@nmtjs/type'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\n\nexport interface TBaseProcedureContract<\n Type extends string = string,\n Input extends BaseType = BaseType,\n Output extends BaseType = BaseType,\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 BaseType = BaseType,\n Output extends BaseType = BaseType,\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 BaseType,\n Output extends BaseType,\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,15 +1,17 @@
1
1
  import { createSchema } from "../utils.js";
2
2
  export const SubscriptionContract = (input, output, events, timeout, schemaOptions = {})=>{
3
- return ()=>createSchema({
4
- ...schemaOptions,
5
- type: 'neemata:subscription',
6
- input,
7
- output,
8
- events,
9
- timeout,
10
- options: undefined,
11
- name: undefined,
12
- serviceName: undefined,
13
- transports: undefined
14
- });
3
+ return {
4
+ $withOptions: ()=>createSchema({
5
+ ...schemaOptions,
6
+ type: 'neemata:subscription',
7
+ input,
8
+ output,
9
+ events,
10
+ timeout,
11
+ options: undefined,
12
+ name: undefined,
13
+ serviceName: undefined,
14
+ transports: undefined
15
+ })
16
+ };
15
17
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/subscription.ts"],"sourcesContent":["import type { BaseType } 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 TSubcriptionOptions = Record<string, string | number>\n\nexport interface TSubscriptionContract<\n Input extends BaseType = BaseType,\n Output extends BaseType = BaseType,\n Options extends TSubcriptionOptions = TSubcriptionOptions,\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 BaseType = BaseType,\n Output extends BaseType = BaseType,\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 <Options extends TSubcriptionOptions>() =>\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"],"names":["createSchema","SubscriptionContract","input","output","events","timeout","schemaOptions","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,IACLN,aAAoE;YAClE,GAAGM,aAAa;YAChBC,MAAM;YACNL;YACAC;YACAC;YACAC;YACAG,SAASC;YACTC,MAAMD;YACNE,aAAaF;YACbG,YAAYH;QACd;AACJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/schemas/subscription.ts"],"sourcesContent":["import type { BaseType } 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 BaseType = BaseType,\n Output extends BaseType = BaseType,\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 BaseType = BaseType,\n Output extends BaseType = BaseType,\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,12 +9,12 @@
9
9
  }
10
10
  },
11
11
  "peerDependencies": {
12
- "@nmtjs/type": "0.2.0",
13
- "@nmtjs/common": "0.2.0"
12
+ "@nmtjs/type": "0.3.0",
13
+ "@nmtjs/common": "0.3.0"
14
14
  },
15
15
  "devDependencies": {
16
- "@nmtjs/common": "0.2.0",
17
- "@nmtjs/type": "0.2.0"
16
+ "@nmtjs/type": "0.3.0",
17
+ "@nmtjs/common": "0.3.0"
18
18
  },
19
19
  "files": [
20
20
  "src",
@@ -23,7 +23,7 @@
23
23
  "LICENSE.md",
24
24
  "README.md"
25
25
  ],
26
- "version": "0.2.0",
26
+ "version": "0.3.0",
27
27
  "scripts": {
28
28
  "build": "neemata-build -p neutral --root=./src './**/*.ts'",
29
29
  "type-check": "tsc --noEmit"
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as baseT } from '@nmtjs/type'
2
1
  import { EventContract, type TEventContract } from './schemas/event.ts'
3
2
 
4
3
  import {
@@ -8,6 +7,7 @@ import {
8
7
  } from './schemas/procedure.ts'
9
8
  import { ServiceContract, type TServiceContract } from './schemas/service.ts'
10
9
  import {
10
+ type SubcriptionOptions,
11
11
  SubscriptionContract,
12
12
  type TSubscriptionContract,
13
13
  } from './schemas/subscription.ts'
@@ -19,6 +19,7 @@ export type {
19
19
  TBaseProcedureContract,
20
20
  TServiceContract,
21
21
  TSubscriptionContract,
22
+ SubcriptionOptions,
22
23
  }
23
24
 
24
25
  export namespace c {
@@ -45,8 +45,8 @@ export const ProcedureContract = <
45
45
  output: Output,
46
46
  timeout?: number,
47
47
  schemaOptions: ContractSchemaOptions = {} as ContractSchemaOptions,
48
- ) => {
49
- return createSchema<TProcedureContract<Input, Output>>({
48
+ ): TProcedureContract<Input, Output> => {
49
+ return {
50
50
  ...schemaOptions,
51
51
  type: 'neemata:procedure',
52
52
  input,
@@ -55,5 +55,5 @@ export const ProcedureContract = <
55
55
  name: undefined,
56
56
  serviceName: undefined,
57
57
  transports: undefined,
58
- })
58
+ }
59
59
  }
@@ -3,12 +3,12 @@ import { type ContractSchemaOptions, createSchema } from '../utils.ts'
3
3
  import type { TEventContract } from './event.ts'
4
4
  import type { TBaseProcedureContract } from './procedure.ts'
5
5
 
6
- export type TSubcriptionOptions = Record<string, string | number>
6
+ export type SubcriptionOptions = Record<string, string | number>
7
7
 
8
8
  export interface TSubscriptionContract<
9
9
  Input extends BaseType = BaseType,
10
10
  Output extends BaseType = BaseType,
11
- Options extends TSubcriptionOptions = TSubcriptionOptions,
11
+ Options extends SubcriptionOptions = SubcriptionOptions,
12
12
  Events extends Record<string, TEventContract> = Record<
13
13
  string,
14
14
  TEventContract
@@ -44,17 +44,19 @@ export const SubscriptionContract = <
44
44
  timeout?: number,
45
45
  schemaOptions: ContractSchemaOptions = {} as ContractSchemaOptions,
46
46
  ) => {
47
- return <Options extends TSubcriptionOptions>() =>
48
- createSchema<TSubscriptionContract<Input, Output, Options, Events>>({
49
- ...schemaOptions,
50
- type: 'neemata:subscription',
51
- input,
52
- output,
53
- events,
54
- timeout,
55
- options: undefined as unknown as Options,
56
- name: undefined,
57
- serviceName: undefined,
58
- transports: undefined,
59
- })
47
+ return {
48
+ $withOptions: <Options extends SubcriptionOptions>() =>
49
+ createSchema<TSubscriptionContract<Input, Output, Options, Events>>({
50
+ ...schemaOptions,
51
+ type: 'neemata:subscription',
52
+ input,
53
+ output,
54
+ events,
55
+ timeout,
56
+ options: undefined as unknown as Options,
57
+ name: undefined,
58
+ serviceName: undefined,
59
+ transports: undefined,
60
+ }),
61
+ }
60
62
  }