@nmtjs/contract 0.8.1 → 0.9.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/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas/api.js +2 -0
- package/dist/schemas/api.js.map +1 -1
- package/dist/schemas/event.js +2 -0
- package/dist/schemas/event.js.map +1 -1
- package/dist/schemas/namespace.js +2 -0
- package/dist/schemas/namespace.js.map +1 -1
- package/dist/schemas/procedure.js +2 -0
- package/dist/schemas/procedure.js.map +1 -1
- package/dist/schemas/subscription.js +2 -0
- package/dist/schemas/subscription.js.map +1 -1
- package/dist/types/blob.js +4 -2
- package/dist/types/blob.js.map +1 -1
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/types/blob.ts +3 -4
package/dist/constants.js
CHANGED
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,MAAM,OAAO,OAAO,IAAI,eAAe","names":[],"sources":["src/constants.ts"],"sourcesContent":["export const Kind = Symbol.for('neemata:kind')\n"],"version":3}
|
|
1
|
+
{"mappings":"AAAA,OAAO,MAAM,OAAO,OAAO,IAAI,eAAe","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const Kind = Symbol.for('neemata:kind')\n"],"version":3,"file":"constants.js"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,SAAS,mBAAmB,kBAAkB;AAC9C,SAAS,qBAAqB,oBAAoB;AAClD,SAAS,yBAAyB,wBAAwB;AAC1D,SAAS,yBAAyB,wBAAwB;AAC1D,SAAS,4BAA4B,2BAA2B;AAChE,SAAS,gBAAgB,iBAAiB;AAE1C,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;;AAEP;CACE,MAAM,kCAAY;CAClB,MAAM,0BAAQ;CACd,MAAM,wCAAe;CACrB,MAAM,kCAAY;CAClB,MAAM,sBAAM;CACZ,MAAM,wBAAO;;AAGtB,SAAS,YAAY;AAErB,eAAe","names":[],"sources":["src/index.ts"],"sourcesContent":["import { APIContract } from './schemas/api.ts'\nimport { EventContract } from './schemas/event.ts'\nimport { NamespaceContract } from './schemas/namespace.ts'\nimport { ProcedureContract } from './schemas/procedure.ts'\nimport { SubscriptionContract } from './schemas/subscription.ts'\nimport { BlobType } from './types/blob.ts'\n\nexport * from './schemas/api.ts'\nexport * from './schemas/event.ts'\nexport * from './schemas/namespace.ts'\nexport * from './schemas/procedure.ts'\nexport * from './schemas/subscription.ts'\n\nexport namespace contract {\n export const procedure = ProcedureContract\n export const event = EventContract\n export const subscription = SubscriptionContract\n export const namespace = NamespaceContract\n export const api = APIContract\n export const blob = BlobType\n}\n\nexport { contract as c }\n\nexport default contract\n"],"version":3}
|
|
1
|
+
{"mappings":"AAAA,SAAS,mBAAmB,kBAAkB;AAC9C,SAAS,qBAAqB,oBAAoB;AAClD,SAAS,yBAAyB,wBAAwB;AAC1D,SAAS,yBAAyB,wBAAwB;AAC1D,SAAS,4BAA4B,2BAA2B;AAChE,SAAS,gBAAgB,iBAAiB;AAE1C,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;;AAEP;CACE,MAAM,kCAAY;CAClB,MAAM,0BAAQ;CACd,MAAM,wCAAe;CACrB,MAAM,kCAAY;CAClB,MAAM,sBAAM;CACZ,MAAM,wBAAO;;AAGtB,SAAS,YAAY;AAErB,eAAe","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { APIContract } from './schemas/api.ts'\nimport { EventContract } from './schemas/event.ts'\nimport { NamespaceContract } from './schemas/namespace.ts'\nimport { ProcedureContract } from './schemas/procedure.ts'\nimport { SubscriptionContract } from './schemas/subscription.ts'\nimport { BlobType } from './types/blob.ts'\n\nexport * from './schemas/api.ts'\nexport * from './schemas/event.ts'\nexport * from './schemas/namespace.ts'\nexport * from './schemas/procedure.ts'\nexport * from './schemas/subscription.ts'\n\nexport namespace contract {\n export const procedure = ProcedureContract\n export const event = EventContract\n export const subscription = SubscriptionContract\n export const namespace = NamespaceContract\n export const api = APIContract\n export const blob = BlobType\n}\n\nexport { contract as c }\n\nexport default contract\n"],"version":3,"file":"index.js"}
|
package/dist/schemas/api.js
CHANGED
package/dist/schemas/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AAGtE,OAAO,MAAM,UAAU;AAoBvB,OAAO,MAAM,cAAc,CAEzBA,YAII;CACJ,MAAM,EAAE,aAAa,CAAE,GAAE,UAAU,KAAM,gBAAgB,CAAE,GAAE,GAAG,WAAW,CAAE;CAE7E,MAAM,cAAc,CAAE;AAEtB,MAAK,MAAM,gBAAgB,YAAY;EACrC,MAAM,YAAY,WAAW;EAC7B,MAAM,cAAc,CAAE;AACtB,OAAK,MAAM,gBAAgB,UAAU,YAAY;GAC/C,MAAM,YAAY,UAAU,WAAW;AACvC,eAAY,gBAAgB,OAAO,OAAO,CAAE,GAAE,WAAW;IACvD,MAAM;IACN,WAAW;GACZ,EAAC;EACH;EAED,MAAM,iBAAiB,CAAE;AACzB,OAAK,MAAM,mBAAmB,UAAU,eAAe;GACrD,MAAM,eAAe,UAAU,cAAc;GAC7C,MAAM,UAAU,CAAE;AAClB,QAAK,MAAM,YAAY,aAAa,QAAQ;IAC1C,MAAM,QAAQ,aAAa,OAAO;AAClC,YAAQ,YAAY,OAAO,OAAO,CAAE,GAAE,OAAO;KAC3C,MAAM;KACN,WAAW;KACX,cAAc;IACf,EAAC;GACH;AACD,kBAAe,mBAAmB,OAAO,OAAO,CAAE,GAAE,cAAc;IAChE,MAAM;IACN,WAAW;IACX,QAAQ;GACT,EAAC;EACH;EAED,MAAM,UAAU,CAAE;AAClB,OAAK,MAAM,YAAY,UAAU,QAAQ;GACvC,MAAM,QAAQ,UAAU,OAAO;AAC/B,WAAQ,YAAY,OAAO,OAAO,CAAE,GAAE,OAAO;IAC3C,MAAM;IACN,WAAW;GACZ,EAAC;EACH;AAED,cAAY,gBAAgB,OAAO,OAAO,CAAE,GAAE,WAAW;GACvD,MAAM;GACN,YAAY;GACZ,eAAe;GACf,QAAQ;EACT,EAAC;CACH;AAED,QAAO,aAAuC;EAC5C,GAAG;GACF,OAAO;EACR,MAAM;EACN,YAAY;EACZ;CACD,EAAC;AACH;AAED,OAAO,SAAS,cAAcC,OAAsC;AAClE,QAAO,QAAQ,SAAS,MAAM,UAAU;AACzC","names":["options?: {\n namespaces?: Namespaces\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n}","value: any"],"sources":["src/schemas/api.ts"],"sourcesContent":["import { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\nimport type { TAnyNamespaceContract, TNamespaceContract } from './namespace.ts'\n\nexport const APIKind = 'NeemataAPI'\n\nexport type TAnyAPIContract = TAPIContract<Record<string, any>>\n\nexport interface TAPIContract<Namespaces extends Record<string, unknown> = {}> {\n [Kind]: typeof APIKind\n type: 'neemata:api'\n namespaces: {\n [K in keyof Namespaces]: Namespaces[K] extends TAnyNamespaceContract\n ? TNamespaceContract<\n Namespaces[K]['procedures'],\n Namespaces[K]['subscriptions'],\n Namespaces[K]['events'],\n Extract<K, string>\n >\n : never\n }\n timeout?: number\n}\n\nexport const APIContract = <\n Namespaces extends Record<string, unknown> = {},\n>(options?: {\n namespaces?: Namespaces\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n}) => {\n const { namespaces = {}, timeout = 1000, schemaOptions = {} } = options || {}\n\n const _namespaces = {} as any\n\n for (const namespaceKey in namespaces) {\n const namespace = namespaces[namespaceKey]\n const _procedures = {} as any\n for (const procedureKey in namespace.procedures) {\n const procedure = namespace.procedures[procedureKey]\n _procedures[procedureKey] = Object.assign({}, procedure, {\n name: procedureKey,\n namespace: namespaceKey,\n })\n }\n\n const _subscriptions = {} as any\n for (const subscriptionKey in namespace.subscriptions) {\n const subscription = namespace.subscriptions[subscriptionKey]\n const _events = {} as any\n for (const eventKey in subscription.events) {\n const event = subscription.events[eventKey]\n _events[eventKey] = Object.assign({}, event, {\n name: eventKey,\n namespace: namespaceKey,\n subscription: subscriptionKey,\n })\n }\n _subscriptions[subscriptionKey] = Object.assign({}, subscription, {\n name: subscriptionKey,\n namespace: namespaceKey,\n events: _events,\n })\n }\n\n const _events = {} as any\n for (const eventKey in namespace.events) {\n const event = namespace.events[eventKey]\n _events[eventKey] = Object.assign({}, event, {\n name: eventKey,\n namespace: namespaceKey,\n })\n }\n\n _namespaces[namespaceKey] = Object.assign({}, namespace, {\n name: namespaceKey,\n procedures: _procedures,\n subscriptions: _subscriptions,\n events: _events,\n })\n }\n\n return createSchema<TAPIContract<Namespaces>>({\n ...schemaOptions,\n [Kind]: APIKind,\n type: 'neemata:api',\n namespaces: _namespaces,\n timeout,\n })\n}\n\nexport function IsAPIContract(value: any): value is TAnyAPIContract {\n return Kind in value && value[Kind] === APIKind\n}\n"],"version":3}
|
|
1
|
+
{"mappings":"AAAA,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AAGtE,OAAO,MAAM,UAAU;AAoBvB,OAAO,MAAM,cAAc,CAEzBA,YAII;CACJ,MAAM,EAAE,aAAa,CAAE,GAAE,UAAU,KAAM,gBAAgB,CAAE,GAAE,GAAG,WAAW,CAAE;CAE7E,MAAM,cAAc,CAAE;AAEtB,MAAK,MAAM,gBAAgB,YAAY;EACrC,MAAM,YAAY,WAAW;EAC7B,MAAM,cAAc,CAAE;AACtB,OAAK,MAAM,gBAAgB,UAAU,YAAY;GAC/C,MAAM,YAAY,UAAU,WAAW;AACvC,eAAY,gBAAgB,OAAO,OAAO,CAAE,GAAE,WAAW;IACvD,MAAM;IACN,WAAW;GACZ,EAAC;EACH;EAED,MAAM,iBAAiB,CAAE;AACzB,OAAK,MAAM,mBAAmB,UAAU,eAAe;GACrD,MAAM,eAAe,UAAU,cAAc;GAC7C,MAAM,UAAU,CAAE;AAClB,QAAK,MAAM,YAAY,aAAa,QAAQ;IAC1C,MAAM,QAAQ,aAAa,OAAO;AAClC,YAAQ,YAAY,OAAO,OAAO,CAAE,GAAE,OAAO;KAC3C,MAAM;KACN,WAAW;KACX,cAAc;IACf,EAAC;GACH;AACD,kBAAe,mBAAmB,OAAO,OAAO,CAAE,GAAE,cAAc;IAChE,MAAM;IACN,WAAW;IACX,QAAQ;GACT,EAAC;EACH;EAED,MAAM,UAAU,CAAE;AAClB,OAAK,MAAM,YAAY,UAAU,QAAQ;GACvC,MAAM,QAAQ,UAAU,OAAO;AAC/B,WAAQ,YAAY,OAAO,OAAO,CAAE,GAAE,OAAO;IAC3C,MAAM;IACN,WAAW;GACZ,EAAC;EACH;AAED,cAAY,gBAAgB,OAAO,OAAO,CAAE,GAAE,WAAW;GACvD,MAAM;GACN,YAAY;GACZ,eAAe;GACf,QAAQ;EACT,EAAC;CACH;AAED,QAAO,aAAuC;EAC5C,GAAG;GACF,OAAO;EACR,MAAM;EACN,YAAY;EACZ;CACD,EAAC;AACH;AAED,OAAO,SAAS,cAAcC,OAAsC;AAClE,QAAO,QAAQ,SAAS,MAAM,UAAU;AACzC","names":["options?: {\n namespaces?: Namespaces\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n}","value: any"],"sources":["../../src/schemas/api.ts"],"sourcesContent":["import { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\nimport type { TAnyNamespaceContract, TNamespaceContract } from './namespace.ts'\n\nexport const APIKind = 'NeemataAPI'\n\nexport type TAnyAPIContract = TAPIContract<Record<string, any>>\n\nexport interface TAPIContract<Namespaces extends Record<string, unknown> = {}> {\n [Kind]: typeof APIKind\n type: 'neemata:api'\n namespaces: {\n [K in keyof Namespaces]: Namespaces[K] extends TAnyNamespaceContract\n ? TNamespaceContract<\n Namespaces[K]['procedures'],\n Namespaces[K]['subscriptions'],\n Namespaces[K]['events'],\n Extract<K, string>\n >\n : never\n }\n timeout?: number\n}\n\nexport const APIContract = <\n Namespaces extends Record<string, unknown> = {},\n>(options?: {\n namespaces?: Namespaces\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n}) => {\n const { namespaces = {}, timeout = 1000, schemaOptions = {} } = options || {}\n\n const _namespaces = {} as any\n\n for (const namespaceKey in namespaces) {\n const namespace = namespaces[namespaceKey]\n const _procedures = {} as any\n for (const procedureKey in namespace.procedures) {\n const procedure = namespace.procedures[procedureKey]\n _procedures[procedureKey] = Object.assign({}, procedure, {\n name: procedureKey,\n namespace: namespaceKey,\n })\n }\n\n const _subscriptions = {} as any\n for (const subscriptionKey in namespace.subscriptions) {\n const subscription = namespace.subscriptions[subscriptionKey]\n const _events = {} as any\n for (const eventKey in subscription.events) {\n const event = subscription.events[eventKey]\n _events[eventKey] = Object.assign({}, event, {\n name: eventKey,\n namespace: namespaceKey,\n subscription: subscriptionKey,\n })\n }\n _subscriptions[subscriptionKey] = Object.assign({}, subscription, {\n name: subscriptionKey,\n namespace: namespaceKey,\n events: _events,\n })\n }\n\n const _events = {} as any\n for (const eventKey in namespace.events) {\n const event = namespace.events[eventKey]\n _events[eventKey] = Object.assign({}, event, {\n name: eventKey,\n namespace: namespaceKey,\n })\n }\n\n _namespaces[namespaceKey] = Object.assign({}, namespace, {\n name: namespaceKey,\n procedures: _procedures,\n subscriptions: _subscriptions,\n events: _events,\n })\n }\n\n return createSchema<TAPIContract<Namespaces>>({\n ...schemaOptions,\n [Kind]: APIKind,\n type: 'neemata:api',\n namespaces: _namespaces,\n timeout,\n })\n}\n\nexport function IsAPIContract(value: any): value is TAnyAPIContract {\n return Kind in value && value[Kind] === APIKind\n}\n"],"version":3,"file":"api.js"}
|
package/dist/schemas/event.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,SAAwC,SAAS,aAAa;AAC9D,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AAEtE,OAAO,MAAM,YAAY;AAuBzB,OAAO,MAAM,gBAAgB,CAG3BA,YAII;CACJ,MAAM,EACJ,UAAU,EAAE,OAAO,EACnB,gBAAgB,CAAE,GAClB,MACD,GAAG,WAAW,CAAE;AACjB,QAAO,aAA4C;EACjD,GAAG;GACF,OAAO;EACR,MAAM;EACN;EACM;EACN,cAAc;EACd,WAAW;CACZ,EAAC;AACH;AAED,OAAO,SAAS,gBAAgBC,OAAwC;AACtE,QAAO,QAAQ,SAAS,MAAM,UAAU;AACzC","names":["options?: {\n payload?: Payload\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}","value: any"],"sources":["src/schemas/event.ts"],"sourcesContent":["import { type BaseType, type NeverType, t } from '@nmtjs/type'\nimport { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\n\nexport const EventKind = 'NeemataEvent'\n\nexport type TAnyEventContract = TEventContract<\n BaseType,\n string | undefined,\n string | undefined,\n string | undefined\n>\n\nexport interface TEventContract<\n Payload extends BaseType = NeverType,\n Name extends string | undefined = undefined,\n Subscription extends string | undefined = undefined,\n Namespace extends string | undefined = undefined,\n> {\n [Kind]: typeof EventKind\n type: 'neemata:event'\n name: Name\n subscription: Subscription\n namespace: Namespace\n payload: Payload\n}\n\nexport const EventContract = <\n Payload extends BaseType,\n Name extends string | undefined = undefined,\n>(options?: {\n payload?: Payload\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}) => {\n const {\n payload = t.never() as unknown as Payload,\n schemaOptions = {},\n name,\n } = options ?? {}\n return createSchema<TEventContract<Payload, Name>>({\n ...schemaOptions,\n [Kind]: EventKind,\n type: 'neemata:event',\n payload,\n name: name as Name,\n subscription: undefined,\n namespace: undefined,\n })\n}\n\nexport function IsEventContract(value: any): value is TAnyEventContract {\n return Kind in value && value[Kind] === EventKind\n}\n"],"version":3}
|
|
1
|
+
{"mappings":"AAAA,SAAwC,SAAS,aAAa;AAC9D,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AAEtE,OAAO,MAAM,YAAY;AAuBzB,OAAO,MAAM,gBAAgB,CAG3BA,YAII;CACJ,MAAM,EACJ,UAAU,EAAE,OAAO,EACnB,gBAAgB,CAAE,GAClB,MACD,GAAG,WAAW,CAAE;AACjB,QAAO,aAA4C;EACjD,GAAG;GACF,OAAO;EACR,MAAM;EACN;EACM;EACN,cAAc;EACd,WAAW;CACZ,EAAC;AACH;AAED,OAAO,SAAS,gBAAgBC,OAAwC;AACtE,QAAO,QAAQ,SAAS,MAAM,UAAU;AACzC","names":["options?: {\n payload?: Payload\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}","value: any"],"sources":["../../src/schemas/event.ts"],"sourcesContent":["import { type BaseType, type NeverType, t } from '@nmtjs/type'\nimport { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\n\nexport const EventKind = 'NeemataEvent'\n\nexport type TAnyEventContract = TEventContract<\n BaseType,\n string | undefined,\n string | undefined,\n string | undefined\n>\n\nexport interface TEventContract<\n Payload extends BaseType = NeverType,\n Name extends string | undefined = undefined,\n Subscription extends string | undefined = undefined,\n Namespace extends string | undefined = undefined,\n> {\n [Kind]: typeof EventKind\n type: 'neemata:event'\n name: Name\n subscription: Subscription\n namespace: Namespace\n payload: Payload\n}\n\nexport const EventContract = <\n Payload extends BaseType,\n Name extends string | undefined = undefined,\n>(options?: {\n payload?: Payload\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}) => {\n const {\n payload = t.never() as unknown as Payload,\n schemaOptions = {},\n name,\n } = options ?? {}\n return createSchema<TEventContract<Payload, Name>>({\n ...schemaOptions,\n [Kind]: EventKind,\n type: 'neemata:event',\n payload,\n name: name as Name,\n subscription: undefined,\n namespace: undefined,\n })\n}\n\nexport function IsEventContract(value: any): value is TAnyEventContract {\n return Kind in value && value[Kind] === EventKind\n}\n"],"version":3,"file":"event.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AAQtE,OAAO,MAAM,gBAAgB;AA+D7B,OAAO,MAAM,oBAAoB,CAK/BA,YAOI;CACJ,MAAM,EACJ,aAAa,CAAE,GACf,gBAAgB,CAAE,GAClB,SAAS,CAAE,GACX,MACA,SACA,gBAAgB,CAAE,GACnB,GAAG,WAAW,CAAE;CACjB,MAAM,UAAU,CAAE;AAElB,MAAK,MAAM,YAAY,QAAQ;EAC7B,MAAM,QAAQ,OAAO;AACrB,UAAQ,YAAY,OAAO,OAAO,CAAE,GAAE,OAAO;GAC3C,MAAM;GACN,WAAW,SAAS;EACrB,EAAC;CACH;CAED,MAAM,cAAc,CAAE;AACtB,MAAK,MAAM,gBAAgB,YAAY;EACrC,MAAMC,YAAiB,WAAW;AAClC,cAAY,gBAAgB,OAAO,OAAO,CAAE,GAAE,WAAW;GACvD,MAAM;GACN,WAAW,SAAS;EACrB,EAAC;CACH;CAED,MAAM,iBAAiB,CAAE;AACzB,MAAK,MAAM,mBAAmB,eAAe;EAC3C,MAAMC,eAAoB,cAAc;EACxC,MAAM,UAAU,CAAE;AAElB,OAAK,MAAM,YAAY,aAAa,QAAQ;GAC1C,MAAM,QAAQ,aAAa,OAAO;AAClC,WAAQ,YAAY,OAAO,OAAO,CAAE,GAAE,OAAO;IAC3C,MAAM;IACN,cAAc;IACd,WAAW,SAAS;GACrB,EAAC;EACH;AAED,iBAAe,mBAAmB,OAAO,OAAO,CAAE,GAAE,cAAc;GAChE,MAAM;GACN,WAAW,SAAS;GACpB,QAAQ;EACT,EAAC;CACH;AAED,QAAO,aAEL;EACA,GAAG;GACF,OAAO;EACR,MAAM;EACA;EACN,YAAY;EACZ,eAAe;EACf,QAAQ;EACR;CACD,EAAC;AACH;AAED,OAAO,SAAS,oBACdC,OACgC;AAChC,QAAO,QAAQ,SAAS,MAAM,UAAU;AACzC","names":["options?: {\n procedures?: Procedures\n subscriptions?: Subscriptions\n events?: Events\n name?: Name\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n}","procedure: any","subscription: any","value: any"],"sources":["src/schemas/namespace.ts"],"sourcesContent":["import { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\nimport type { TAnyEventContract, TEventContract } from './event.ts'\nimport type { TAnyProcedureContract, TProcedureContract } from './procedure.ts'\nimport type {\n TAnySubscriptionContract,\n TSubscriptionContract,\n} from './subscription.ts'\n\nexport const NamespaceKind = 'NeemataNamespace'\n\nexport type TAnyNamespaceContract = TNamespaceContract<\n Record<string, any>,\n Record<string, any>,\n Record<string, any>,\n string | undefined\n>\n\nexport interface TNamespaceContract<\n Procedures extends Record<string, unknown> = {},\n Subscriptions extends Record<string, unknown> = {},\n Events extends Record<string, unknown> = {},\n Name extends string | undefined = undefined,\n> {\n [Kind]: typeof NamespaceKind\n type: 'neemata:namespace'\n name: Name\n procedures: {\n [K in keyof Procedures]: Procedures[K] extends TAnyProcedureContract\n ? TProcedureContract<\n Procedures[K]['input'],\n Procedures[K]['output'],\n Procedures[K]['stream'],\n Extract<K, string>,\n Name\n >\n : never\n }\n subscriptions: {\n [K in keyof Subscriptions]: Subscriptions[K] extends TAnySubscriptionContract\n ? TSubscriptionContract<\n Subscriptions[K]['input'],\n Subscriptions[K]['output'],\n Subscriptions[K]['options'],\n {\n [E in keyof Subscriptions[K]['events']]: Subscriptions[K]['events'][E] extends TAnyEventContract\n ? TEventContract<\n Subscriptions[K]['events'][E]['payload'],\n Extract<E, string>,\n Extract<K, string>,\n Name\n >\n : never\n },\n Extract<K, string>,\n Name\n >\n : never\n }\n events: {\n [K in keyof Events]: Events[K] extends TAnyEventContract\n ? TEventContract<\n Events[K]['payload'],\n Extract<K, string>,\n undefined,\n Name\n >\n : never\n }\n timeout?: number\n}\n\nexport const NamespaceContract = <\n Procedures extends Record<string, unknown> = {},\n Subscriptions extends Record<string, unknown> = {},\n Events extends Record<string, unknown> = {},\n Name extends string | undefined = undefined,\n>(options?: {\n procedures?: Procedures\n subscriptions?: Subscriptions\n events?: Events\n name?: Name\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n}) => {\n const {\n procedures = {} as Procedures,\n subscriptions = {} as Subscriptions,\n events = {} as Events,\n name,\n timeout,\n schemaOptions = {} as ContractSchemaOptions,\n } = options ?? {}\n const _events = {} as any\n\n for (const eventKey in events) {\n const event = events[eventKey]\n _events[eventKey] = Object.assign({}, event, {\n name: eventKey,\n namespace: options?.name,\n })\n }\n\n const _procedures = {} as any\n for (const procedureKey in procedures) {\n const procedure: any = procedures[procedureKey]\n _procedures[procedureKey] = Object.assign({}, procedure, {\n name: procedureKey,\n namespace: options?.name,\n })\n }\n\n const _subscriptions = {} as any\n for (const subscriptionKey in subscriptions) {\n const subscription: any = subscriptions[subscriptionKey]\n const _events = {} as any\n\n for (const eventKey in subscription.events) {\n const event = subscription.events[eventKey]\n _events[eventKey] = Object.assign({}, event, {\n name: eventKey,\n subscription: subscriptionKey,\n namespace: options?.name,\n })\n }\n\n _subscriptions[subscriptionKey] = Object.assign({}, subscription, {\n name: subscriptionKey,\n namespace: options?.name,\n events: _events,\n })\n }\n\n return createSchema<\n TNamespaceContract<Procedures, Subscriptions, Events, Name>\n >({\n ...schemaOptions,\n [Kind]: NamespaceKind,\n type: 'neemata:namespace',\n name: name as Name,\n procedures: _procedures,\n subscriptions: _subscriptions,\n events: _events,\n timeout,\n })\n}\n\nexport function IsNamespaceContract(\n value: any,\n): value is TAnyNamespaceContract {\n return Kind in value && value[Kind] === NamespaceKind\n}\n"],"version":3}
|
|
1
|
+
{"mappings":"AAAA,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AAQtE,OAAO,MAAM,gBAAgB;AA+D7B,OAAO,MAAM,oBAAoB,CAK/BA,YAOI;CACJ,MAAM,EACJ,aAAa,CAAE,GACf,gBAAgB,CAAE,GAClB,SAAS,CAAE,GACX,MACA,SACA,gBAAgB,CAAE,GACnB,GAAG,WAAW,CAAE;CACjB,MAAM,UAAU,CAAE;AAElB,MAAK,MAAM,YAAY,QAAQ;EAC7B,MAAM,QAAQ,OAAO;AACrB,UAAQ,YAAY,OAAO,OAAO,CAAE,GAAE,OAAO;GAC3C,MAAM;GACN,WAAW,SAAS;EACrB,EAAC;CACH;CAED,MAAM,cAAc,CAAE;AACtB,MAAK,MAAM,gBAAgB,YAAY;EACrC,MAAMC,YAAiB,WAAW;AAClC,cAAY,gBAAgB,OAAO,OAAO,CAAE,GAAE,WAAW;GACvD,MAAM;GACN,WAAW,SAAS;EACrB,EAAC;CACH;CAED,MAAM,iBAAiB,CAAE;AACzB,MAAK,MAAM,mBAAmB,eAAe;EAC3C,MAAMC,eAAoB,cAAc;EACxC,MAAM,UAAU,CAAE;AAElB,OAAK,MAAM,YAAY,aAAa,QAAQ;GAC1C,MAAM,QAAQ,aAAa,OAAO;AAClC,WAAQ,YAAY,OAAO,OAAO,CAAE,GAAE,OAAO;IAC3C,MAAM;IACN,cAAc;IACd,WAAW,SAAS;GACrB,EAAC;EACH;AAED,iBAAe,mBAAmB,OAAO,OAAO,CAAE,GAAE,cAAc;GAChE,MAAM;GACN,WAAW,SAAS;GACpB,QAAQ;EACT,EAAC;CACH;AAED,QAAO,aAEL;EACA,GAAG;GACF,OAAO;EACR,MAAM;EACA;EACN,YAAY;EACZ,eAAe;EACf,QAAQ;EACR;CACD,EAAC;AACH;AAED,OAAO,SAAS,oBACdC,OACgC;AAChC,QAAO,QAAQ,SAAS,MAAM,UAAU;AACzC","names":["options?: {\n procedures?: Procedures\n subscriptions?: Subscriptions\n events?: Events\n name?: Name\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n}","procedure: any","subscription: any","value: any"],"sources":["../../src/schemas/namespace.ts"],"sourcesContent":["import { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\nimport type { TAnyEventContract, TEventContract } from './event.ts'\nimport type { TAnyProcedureContract, TProcedureContract } from './procedure.ts'\nimport type {\n TAnySubscriptionContract,\n TSubscriptionContract,\n} from './subscription.ts'\n\nexport const NamespaceKind = 'NeemataNamespace'\n\nexport type TAnyNamespaceContract = TNamespaceContract<\n Record<string, any>,\n Record<string, any>,\n Record<string, any>,\n string | undefined\n>\n\nexport interface TNamespaceContract<\n Procedures extends Record<string, unknown> = {},\n Subscriptions extends Record<string, unknown> = {},\n Events extends Record<string, unknown> = {},\n Name extends string | undefined = undefined,\n> {\n [Kind]: typeof NamespaceKind\n type: 'neemata:namespace'\n name: Name\n procedures: {\n [K in keyof Procedures]: Procedures[K] extends TAnyProcedureContract\n ? TProcedureContract<\n Procedures[K]['input'],\n Procedures[K]['output'],\n Procedures[K]['stream'],\n Extract<K, string>,\n Name\n >\n : never\n }\n subscriptions: {\n [K in keyof Subscriptions]: Subscriptions[K] extends TAnySubscriptionContract\n ? TSubscriptionContract<\n Subscriptions[K]['input'],\n Subscriptions[K]['output'],\n Subscriptions[K]['options'],\n {\n [E in keyof Subscriptions[K]['events']]: Subscriptions[K]['events'][E] extends TAnyEventContract\n ? TEventContract<\n Subscriptions[K]['events'][E]['payload'],\n Extract<E, string>,\n Extract<K, string>,\n Name\n >\n : never\n },\n Extract<K, string>,\n Name\n >\n : never\n }\n events: {\n [K in keyof Events]: Events[K] extends TAnyEventContract\n ? TEventContract<\n Events[K]['payload'],\n Extract<K, string>,\n undefined,\n Name\n >\n : never\n }\n timeout?: number\n}\n\nexport const NamespaceContract = <\n Procedures extends Record<string, unknown> = {},\n Subscriptions extends Record<string, unknown> = {},\n Events extends Record<string, unknown> = {},\n Name extends string | undefined = undefined,\n>(options?: {\n procedures?: Procedures\n subscriptions?: Subscriptions\n events?: Events\n name?: Name\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n}) => {\n const {\n procedures = {} as Procedures,\n subscriptions = {} as Subscriptions,\n events = {} as Events,\n name,\n timeout,\n schemaOptions = {} as ContractSchemaOptions,\n } = options ?? {}\n const _events = {} as any\n\n for (const eventKey in events) {\n const event = events[eventKey]\n _events[eventKey] = Object.assign({}, event, {\n name: eventKey,\n namespace: options?.name,\n })\n }\n\n const _procedures = {} as any\n for (const procedureKey in procedures) {\n const procedure: any = procedures[procedureKey]\n _procedures[procedureKey] = Object.assign({}, procedure, {\n name: procedureKey,\n namespace: options?.name,\n })\n }\n\n const _subscriptions = {} as any\n for (const subscriptionKey in subscriptions) {\n const subscription: any = subscriptions[subscriptionKey]\n const _events = {} as any\n\n for (const eventKey in subscription.events) {\n const event = subscription.events[eventKey]\n _events[eventKey] = Object.assign({}, event, {\n name: eventKey,\n subscription: subscriptionKey,\n namespace: options?.name,\n })\n }\n\n _subscriptions[subscriptionKey] = Object.assign({}, subscription, {\n name: subscriptionKey,\n namespace: options?.name,\n events: _events,\n })\n }\n\n return createSchema<\n TNamespaceContract<Procedures, Subscriptions, Events, Name>\n >({\n ...schemaOptions,\n [Kind]: NamespaceKind,\n type: 'neemata:namespace',\n name: name as Name,\n procedures: _procedures,\n subscriptions: _subscriptions,\n events: _events,\n timeout,\n })\n}\n\nexport function IsNamespaceContract(\n value: any,\n): value is TAnyNamespaceContract {\n return Kind in value && value[Kind] === NamespaceKind\n}\n"],"version":3,"file":"namespace.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,SAAwC,SAAS,aAAa;AAC9D,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AA0BtE,OAAO,MAAM,gBAAgB;AA2B7B,OAAO,MAAM,oBAAoB,CAK/BA,YAOI;CACJ,MAAM,EACJ,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,OAAO,EAClB,SACA,gBAAgB,CAAE,GAClB,MACD,GAAG;AACJ,QAAO,aAA8D;EACnE,GAAG;GACF,OAAO;EACR,MAAM;EACN;EACA;EACA;EACA;EACM;EACN,WAAW;CACZ,EAAC;AACH;AAED,OAAO,SAAS,oBACdC,UACmC;AACnC,QAAO,QAAQ,YAAY,SAAS,UAAU;AAC/C","names":["options: {\n input?: Input\n output?: Output\n stream?: Stream\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}","contract: any"],"sources":["src/schemas/procedure.ts"],"sourcesContent":["import { type BaseType, type NeverType, t } from '@nmtjs/type'\nimport { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\n\nexport type TAnyBaseProcedureContract = TBaseProcedureContract<\n string,\n BaseType,\n BaseType,\n string | undefined,\n string | undefined\n>\n\nexport interface TBaseProcedureContract<\n Type extends string,\n Input extends BaseType,\n Output extends BaseType,\n Name extends string | undefined = undefined,\n Namespace extends string | undefined = undefined,\n> {\n [Kind]: string\n type: Type\n name: Name\n namespace: Namespace\n input: Input\n output: Output\n timeout?: number\n}\n\nexport const ProcedureKind = 'NeemataProcedure'\n\nexport type TAnyProcedureContract = TProcedureContract<\n BaseType,\n BaseType,\n BaseType,\n string | undefined,\n string | undefined\n>\n\nexport interface TProcedureContract<\n Input extends BaseType = NeverType,\n Output extends BaseType = NeverType,\n Stream extends BaseType = NeverType,\n Name extends string | undefined = undefined,\n Namespace extends string | undefined = undefined,\n> extends TBaseProcedureContract<\n 'neemata:procedure',\n Input,\n Output,\n Name,\n Namespace\n > {\n [Kind]: typeof ProcedureKind\n stream: Stream\n}\n\nexport const ProcedureContract = <\n Input extends BaseType = NeverType,\n Output extends BaseType = NeverType,\n Stream extends BaseType = NeverType,\n Name extends string | undefined = undefined,\n>(options: {\n input?: Input\n output?: Output\n stream?: Stream\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}) => {\n const {\n input = t.never() as unknown as Input,\n output = t.never() as unknown as Output,\n stream = t.never() as unknown as Stream,\n timeout,\n schemaOptions = {},\n name,\n } = options\n return createSchema<TProcedureContract<Input, Output, Stream, Name>>({\n ...schemaOptions,\n [Kind]: ProcedureKind,\n type: 'neemata:procedure',\n input,\n output,\n stream,\n timeout,\n name: name as Name,\n namespace: undefined,\n })\n}\n\nexport function IsProcedureContract(\n contract: any,\n): contract is TAnyProcedureContract {\n return Kind in contract && contract[Kind] === ProcedureKind\n}\n"],"version":3}
|
|
1
|
+
{"mappings":"AAAA,SAAwC,SAAS,aAAa;AAC9D,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AA0BtE,OAAO,MAAM,gBAAgB;AA2B7B,OAAO,MAAM,oBAAoB,CAK/BA,YAOI;CACJ,MAAM,EACJ,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,OAAO,EAClB,SACA,gBAAgB,CAAE,GAClB,MACD,GAAG;AACJ,QAAO,aAA8D;EACnE,GAAG;GACF,OAAO;EACR,MAAM;EACN;EACA;EACA;EACA;EACM;EACN,WAAW;CACZ,EAAC;AACH;AAED,OAAO,SAAS,oBACdC,UACmC;AACnC,QAAO,QAAQ,YAAY,SAAS,UAAU;AAC/C","names":["options: {\n input?: Input\n output?: Output\n stream?: Stream\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}","contract: any"],"sources":["../../src/schemas/procedure.ts"],"sourcesContent":["import { type BaseType, type NeverType, t } from '@nmtjs/type'\nimport { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\n\nexport type TAnyBaseProcedureContract = TBaseProcedureContract<\n string,\n BaseType,\n BaseType,\n string | undefined,\n string | undefined\n>\n\nexport interface TBaseProcedureContract<\n Type extends string,\n Input extends BaseType,\n Output extends BaseType,\n Name extends string | undefined = undefined,\n Namespace extends string | undefined = undefined,\n> {\n [Kind]: string\n type: Type\n name: Name\n namespace: Namespace\n input: Input\n output: Output\n timeout?: number\n}\n\nexport const ProcedureKind = 'NeemataProcedure'\n\nexport type TAnyProcedureContract = TProcedureContract<\n BaseType,\n BaseType,\n BaseType,\n string | undefined,\n string | undefined\n>\n\nexport interface TProcedureContract<\n Input extends BaseType = NeverType,\n Output extends BaseType = NeverType,\n Stream extends BaseType = NeverType,\n Name extends string | undefined = undefined,\n Namespace extends string | undefined = undefined,\n> extends TBaseProcedureContract<\n 'neemata:procedure',\n Input,\n Output,\n Name,\n Namespace\n > {\n [Kind]: typeof ProcedureKind\n stream: Stream\n}\n\nexport const ProcedureContract = <\n Input extends BaseType = NeverType,\n Output extends BaseType = NeverType,\n Stream extends BaseType = NeverType,\n Name extends string | undefined = undefined,\n>(options: {\n input?: Input\n output?: Output\n stream?: Stream\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}) => {\n const {\n input = t.never() as unknown as Input,\n output = t.never() as unknown as Output,\n stream = t.never() as unknown as Stream,\n timeout,\n schemaOptions = {},\n name,\n } = options\n return createSchema<TProcedureContract<Input, Output, Stream, Name>>({\n ...schemaOptions,\n [Kind]: ProcedureKind,\n type: 'neemata:procedure',\n input,\n output,\n stream,\n timeout,\n name: name as Name,\n namespace: undefined,\n })\n}\n\nexport function IsProcedureContract(\n contract: any,\n): contract is TAnyProcedureContract {\n return Kind in contract && contract[Kind] === ProcedureKind\n}\n"],"version":3,"file":"procedure.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,SAAwC,SAAS,aAAa;AAC9D,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AAItE,OAAO,MAAM,mBAAmB;AAyChC,OAAO,MAAM,uBAAuB,CAKlCA,YAOI;CACJ,MAAM,EACJ,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,OAAO,EAClB,SAAS,CAAE,GACX,SACA,gBAAgB,CAAE,GAClB,MACD,GAAG,WAAW,CAAE;CAEjB,MAAM,UAAU,CAAE;AAClB,MAAK,MAAM,OAAO,QAAQ;EACxB,MAAM,QAAQ,OAAO;AACrB,UAAQ,OAAO,OAAO,OAAO,CAAE,GAAE,OAAO,EAAE,cAAc,KAAM,EAAC;CAChE;AACD,QAAO,EACL,cAAc,MACZ,aACE;EACE,GAAG;GACF,OAAO;EACR,MAAM;EACN;EACA;EACA,QAAQ;EACR;EACM;EACN,WAAW;EACX,SAAS;CACV,EACF,CACJ;AACF;AAED,OAAO,SAAS,uBACdC,UACsC;AACtC,QAAO,QAAQ,YAAY,SAAS,UAAU;AAC/C","names":["options?: {\n input?: Input\n output?: Output\n events?: Events\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}","contract: any"],"sources":["src/schemas/subscription.ts"],"sourcesContent":["import { type BaseType, type NeverType, t } from '@nmtjs/type'\nimport { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\nimport type { TAnyEventContract, TEventContract } from './event.ts'\nimport type { TBaseProcedureContract } from './procedure.ts'\n\nexport const SubscriptionKind = 'NeemataSubscription'\n\nexport type SubcriptionOptions = Record<string, string | number | boolean>\n\nexport type TAnySubscriptionContract = TSubscriptionContract<\n BaseType,\n BaseType,\n SubcriptionOptions,\n Record<string, unknown>,\n string | undefined,\n string | undefined\n>\n\nexport interface TSubscriptionContract<\n Input extends BaseType = NeverType,\n Output extends BaseType = NeverType,\n Options extends SubcriptionOptions = {},\n Events extends Record<string, unknown> = {},\n Name extends string | undefined = undefined,\n Namespace extends string | undefined = undefined,\n> extends TBaseProcedureContract<\n 'neemata:subscription',\n Input,\n Output,\n Name,\n Namespace\n > {\n [Kind]: typeof SubscriptionKind\n options: Options\n events: {\n [K in keyof Events]: Events[K] extends TAnyEventContract\n ? TEventContract<\n Events[K]['payload'],\n Extract<K, string>,\n Name,\n Namespace\n >\n : never\n }\n}\n\nexport const SubscriptionContract = <\n Input extends BaseType = NeverType,\n Output extends BaseType = NeverType,\n Events extends Record<string, unknown> = {},\n Name extends string | undefined = undefined,\n>(options?: {\n input?: Input\n output?: Output\n events?: Events\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}) => {\n const {\n input = t.never() as unknown as Input,\n output = t.never() as unknown as Output,\n events = {} as Events,\n timeout,\n schemaOptions = {},\n name,\n } = options ?? {}\n\n const _events = {} as any\n for (const key in events) {\n const event = events[key]\n _events[key] = Object.assign({}, event, { subscription: name })\n }\n return {\n $withOptions: <Options extends SubcriptionOptions>() =>\n createSchema<TSubscriptionContract<Input, Output, Options, Events, Name>>(\n {\n ...schemaOptions,\n [Kind]: SubscriptionKind,\n type: 'neemata:subscription',\n input,\n output,\n events: _events,\n timeout,\n name: name as Name,\n namespace: undefined,\n options: undefined as unknown as Options,\n },\n ),\n }\n}\n\nexport function IsSubscriptionContract(\n contract: any,\n): contract is TAnySubscriptionContract {\n return Kind in contract && contract[Kind] === SubscriptionKind\n}\n"],"version":3}
|
|
1
|
+
{"mappings":"AAAA,SAAwC,SAAS,aAAa;AAC9D,SAAS,YAAY,iBAAiB;AACtC,SAAqC,oBAAoB,aAAa;AAItE,OAAO,MAAM,mBAAmB;AAyChC,OAAO,MAAM,uBAAuB,CAKlCA,YAOI;CACJ,MAAM,EACJ,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,OAAO,EAClB,SAAS,CAAE,GACX,SACA,gBAAgB,CAAE,GAClB,MACD,GAAG,WAAW,CAAE;CAEjB,MAAM,UAAU,CAAE;AAClB,MAAK,MAAM,OAAO,QAAQ;EACxB,MAAM,QAAQ,OAAO;AACrB,UAAQ,OAAO,OAAO,OAAO,CAAE,GAAE,OAAO,EAAE,cAAc,KAAM,EAAC;CAChE;AACD,QAAO,EACL,cAAc,MACZ,aACE;EACE,GAAG;GACF,OAAO;EACR,MAAM;EACN;EACA;EACA,QAAQ;EACR;EACM;EACN,WAAW;EACX,SAAS;CACV,EACF,CACJ;AACF;AAED,OAAO,SAAS,uBACdC,UACsC;AACtC,QAAO,QAAQ,YAAY,SAAS,UAAU;AAC/C","names":["options?: {\n input?: Input\n output?: Output\n events?: Events\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}","contract: any"],"sources":["../../src/schemas/subscription.ts"],"sourcesContent":["import { type BaseType, type NeverType, t } from '@nmtjs/type'\nimport { Kind } from '../constants.ts'\nimport { type ContractSchemaOptions, createSchema } from '../utils.ts'\nimport type { TAnyEventContract, TEventContract } from './event.ts'\nimport type { TBaseProcedureContract } from './procedure.ts'\n\nexport const SubscriptionKind = 'NeemataSubscription'\n\nexport type SubcriptionOptions = Record<string, string | number | boolean>\n\nexport type TAnySubscriptionContract = TSubscriptionContract<\n BaseType,\n BaseType,\n SubcriptionOptions,\n Record<string, unknown>,\n string | undefined,\n string | undefined\n>\n\nexport interface TSubscriptionContract<\n Input extends BaseType = NeverType,\n Output extends BaseType = NeverType,\n Options extends SubcriptionOptions = {},\n Events extends Record<string, unknown> = {},\n Name extends string | undefined = undefined,\n Namespace extends string | undefined = undefined,\n> extends TBaseProcedureContract<\n 'neemata:subscription',\n Input,\n Output,\n Name,\n Namespace\n > {\n [Kind]: typeof SubscriptionKind\n options: Options\n events: {\n [K in keyof Events]: Events[K] extends TAnyEventContract\n ? TEventContract<\n Events[K]['payload'],\n Extract<K, string>,\n Name,\n Namespace\n >\n : never\n }\n}\n\nexport const SubscriptionContract = <\n Input extends BaseType = NeverType,\n Output extends BaseType = NeverType,\n Events extends Record<string, unknown> = {},\n Name extends string | undefined = undefined,\n>(options?: {\n input?: Input\n output?: Output\n events?: Events\n timeout?: number\n schemaOptions?: ContractSchemaOptions\n name?: Name\n}) => {\n const {\n input = t.never() as unknown as Input,\n output = t.never() as unknown as Output,\n events = {} as Events,\n timeout,\n schemaOptions = {},\n name,\n } = options ?? {}\n\n const _events = {} as any\n for (const key in events) {\n const event = events[key]\n _events[key] = Object.assign({}, event, { subscription: name })\n }\n return {\n $withOptions: <Options extends SubcriptionOptions>() =>\n createSchema<TSubscriptionContract<Input, Output, Options, Events, Name>>(\n {\n ...schemaOptions,\n [Kind]: SubscriptionKind,\n type: 'neemata:subscription',\n input,\n output,\n events: _events,\n timeout,\n name: name as Name,\n namespace: undefined,\n options: undefined as unknown as Options,\n },\n ),\n }\n}\n\nexport function IsSubscriptionContract(\n contract: any,\n): contract is TAnySubscriptionContract {\n return Kind in contract && contract[Kind] === SubscriptionKind\n}\n"],"version":3,"file":"subscription.js"}
|
package/dist/types/blob.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t
|
|
1
|
+
import { t } from "@nmtjs/type";
|
|
2
2
|
export const BlobType = (options = {}) => t.custom({
|
|
3
3
|
decode: (value) => {
|
|
4
4
|
if ("metadata" in value) {
|
|
5
5
|
if (options.maxSize) {
|
|
6
6
|
const size = value.metadata.size;
|
|
7
|
-
if (size
|
|
7
|
+
if (typeof size !== "undefined" && size > options.maxSize) {
|
|
8
8
|
throw new Error("Blob size unknown or exceeds maximum allowed size");
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -13,3 +13,5 @@ export const BlobType = (options = {}) => t.custom({
|
|
|
13
13
|
},
|
|
14
14
|
encode: (value) => value
|
|
15
15
|
});
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=blob.js.map
|
package/dist/types/blob.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AACA,SAAS,
|
|
1
|
+
{"mappings":"AACA,SAAS,SAAS,aAAa;AAO/B,OAAO,MAAM,WAAW,CAACA,UAAuB,CAAE,MAChD,EAAE,OAA8B;CAC9B,QAAQ,CAAC,UAAU;AAEjB,MAAI,cAAc,OAAO;AACvB,OAAI,QAAQ,SAAS;IACnB,MAAM,OAAQ,MAAgC,SAAS;AACvD,eAAW,SAAS,eAAe,OAAO,QAAQ,SAAS;AACzD,WAAM,IAAI,MAAM;IACjB;GACF;EACF;AACD,SAAO;CACR;CACD,QAAQ,CAAC,UAAU;AACpB,EAAC","names":["options: BlobOptions"],"sources":["../../src/types/blob.ts"],"sourcesContent":["import type { ProtocolBlobInterface } from '@nmtjs/protocol/common'\nimport { t } from '@nmtjs/type'\n\nexport interface BlobOptions {\n maxSize?: number\n contentType?: string\n}\n\nexport const BlobType = (options: BlobOptions = {}) =>\n t.custom<ProtocolBlobInterface>({\n decode: (value) => {\n // TODO: here should be some validation logic to check if the value is an actual blob\n if ('metadata' in value) {\n if (options.maxSize) {\n const size = (value as ProtocolBlobInterface).metadata.size\n if (typeof size !== 'undefined' && size > options.maxSize) {\n throw new Error('Blob size unknown or exceeds maximum allowed size')\n }\n }\n }\n return value\n },\n encode: (value) => value,\n })\n"],"version":3,"file":"blob.js"}
|
package/dist/utils.js
CHANGED
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAKA,OAAO,MAAM,aAAa,CACxBA,QACAC,SACG;AACH,QAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG;EAAE,GAAG;EAAG,MAAM;EAAG,GAAG;CAAM,CAAC,EAAC,CACxE;AACF;AAED,OAAO,MAAM,eAAe,CAAIC,WAAc","names":["params: T","opts: { serviceName?: string; subscriptionName?: string }","schema: T"],"sources":["src/utils.ts"],"sourcesContent":["export type ContractSchemaOptions = {\n title?: string\n description?: string\n}\n\nexport const applyNames = <T extends Record<string, { serviceName?: string }>>(\n params: T,\n opts: { serviceName?: string; subscriptionName?: string },\n) => {\n return Object.fromEntries(\n Object.entries(params).map(([k, v]) => [k, { ...v, name: k, ...opts }]),\n )\n}\n\nexport const createSchema = <T>(schema: T) => schema as T\n"],"version":3}
|
|
1
|
+
{"mappings":"AAKA,OAAO,MAAM,aAAa,CACxBA,QACAC,SACG;AACH,QAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG;EAAE,GAAG;EAAG,MAAM;EAAG,GAAG;CAAM,CAAC,EAAC,CACxE;AACF;AAED,OAAO,MAAM,eAAe,CAAIC,WAAc","names":["params: T","opts: { serviceName?: string; subscriptionName?: string }","schema: T"],"sources":["../src/utils.ts"],"sourcesContent":["export type ContractSchemaOptions = {\n title?: string\n description?: string\n}\n\nexport const applyNames = <T extends Record<string, { serviceName?: string }>>(\n params: T,\n opts: { serviceName?: string; subscriptionName?: string },\n) => {\n return Object.fromEntries(\n Object.entries(params).map(([k, v]) => [k, { ...v, name: k, ...opts }]),\n )\n}\n\nexport const createSchema = <T>(schema: T) => schema as T\n"],"version":3,"file":"utils.js"}
|
package/package.json
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
}
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@nmtjs/protocol": "0.
|
|
12
|
-
"@nmtjs/type": "0.
|
|
11
|
+
"@nmtjs/protocol": "0.9.0",
|
|
12
|
+
"@nmtjs/type": "0.9.0"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"src",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"LICENSE.md",
|
|
18
18
|
"README.md"
|
|
19
19
|
],
|
|
20
|
-
"version": "0.
|
|
20
|
+
"version": "0.9.0",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "neemata-build --root=./src './**/*.ts'",
|
|
23
23
|
"type-check": "tsc --noEmit"
|
package/src/types/blob.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProtocolBlobInterface } from '@nmtjs/protocol/common'
|
|
2
|
-
import { t
|
|
2
|
+
import { t } from '@nmtjs/type'
|
|
3
3
|
|
|
4
4
|
export interface BlobOptions {
|
|
5
5
|
maxSize?: number
|
|
@@ -9,12 +9,11 @@ export interface BlobOptions {
|
|
|
9
9
|
export const BlobType = (options: BlobOptions = {}) =>
|
|
10
10
|
t.custom<ProtocolBlobInterface>({
|
|
11
11
|
decode: (value) => {
|
|
12
|
-
// TODO:
|
|
13
|
-
// ref: https://github.com/sinclairzx81/typebox/issues/977
|
|
12
|
+
// TODO: here should be some validation logic to check if the value is an actual blob
|
|
14
13
|
if ('metadata' in value) {
|
|
15
14
|
if (options.maxSize) {
|
|
16
15
|
const size = (value as ProtocolBlobInterface).metadata.size
|
|
17
|
-
if (size
|
|
16
|
+
if (typeof size !== 'undefined' && size > options.maxSize) {
|
|
18
17
|
throw new Error('Blob size unknown or exceeds maximum allowed size')
|
|
19
18
|
}
|
|
20
19
|
}
|