@nmtjs/contract 0.1.1 → 0.2.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 +2 -5
- package/dist/index.js.map +1 -1
- package/dist/types/blob.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +2 -3
- package/src/types/blob.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { t as baseT } from '@nmtjs/type';
|
|
2
1
|
import { EventContract } from "./schemas/event.js";
|
|
3
2
|
import { ProcedureContract } from "./schemas/procedure.js";
|
|
4
3
|
import { ServiceContract } from "./schemas/service.js";
|
|
5
4
|
import { SubscriptionContract } from "./schemas/subscription.js";
|
|
6
|
-
import { blob } from "./types/blob.js";
|
|
5
|
+
import { blob as blobType } from "./types/blob.js";
|
|
7
6
|
export var c;
|
|
8
7
|
(function(c) {
|
|
9
8
|
c.procedure = ProcedureContract;
|
|
10
9
|
c.event = EventContract;
|
|
11
10
|
c.subscription = SubscriptionContract;
|
|
12
11
|
c.service = ServiceContract;
|
|
12
|
+
c.blob = blobType;
|
|
13
13
|
})(c || (c = {}));
|
|
14
|
-
export const t = Object.assign({}, baseT, {
|
|
15
|
-
blob
|
|
16
|
-
});
|
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 } 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
|
|
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"}
|
package/dist/types/blob.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/blob.ts"],"sourcesContent":["import type { ApiBlobInterface } from '@nmtjs/common'\nimport { t } from '@nmtjs/type'\n\nexport const BlobKind = 'ApiBlob'\n\nexport interface BlobOptions {\n maxSize?: number\n contentType?: string\n}\n\nexport const blob = (options: BlobOptions = {}) =>\n t.custom<ApiBlobInterface>(\n (value) => {\n if ('metadata' in value) {\n if (options.maxSize) {\n const size = (value as ApiBlobInterface).metadata.size\n if (size === -1 || size > options.maxSize) {\n throw new Error('Blob size unknown or exceeds maximum allowed size')\n }\n }\n }\n return value\n },\n (value) => value,\n )\n"],"names":["t","BlobKind","blob","options","custom","value","maxSize","size","metadata","Error"],"mappings":"AACA,SAASA,CAAC,QAAQ,cAAa;AAE/B,OAAO,MAAMC,WAAW,UAAS;AAOjC,OAAO,MAAMC,OAAO,CAACC,UAAuB,CAAC,CAAC,GAC5CH,EAAEI,MAAM,CACN,CAACC;
|
|
1
|
+
{"version":3,"sources":["../../../src/types/blob.ts"],"sourcesContent":["import type { ApiBlobInterface } from '@nmtjs/common'\nimport { t } from '@nmtjs/type'\n\nexport const BlobKind = 'ApiBlob'\n\nexport interface BlobOptions {\n maxSize?: number\n contentType?: string\n}\n\nexport const blob = (options: BlobOptions = {}) =>\n t.custom<ApiBlobInterface>(\n (value) => {\n // TODO: this should be registered separately for server and client\n // ref: https://github.com/sinclairzx81/typebox/issues/977\n if ('metadata' in value) {\n if (options.maxSize) {\n const size = (value as ApiBlobInterface).metadata.size\n if (size === -1 || size > options.maxSize) {\n throw new Error('Blob size unknown or exceeds maximum allowed size')\n }\n }\n }\n return value\n },\n (value) => value,\n )\n"],"names":["t","BlobKind","blob","options","custom","value","maxSize","size","metadata","Error"],"mappings":"AACA,SAASA,CAAC,QAAQ,cAAa;AAE/B,OAAO,MAAMC,WAAW,UAAS;AAOjC,OAAO,MAAMC,OAAO,CAACC,UAAuB,CAAC,CAAC,GAC5CH,EAAEI,MAAM,CACN,CAACC;QAGC,IAAI,cAAcA,OAAO;YACvB,IAAIF,QAAQG,OAAO,EAAE;gBACnB,MAAMC,OAAO,AAACF,MAA2BG,QAAQ,CAACD,IAAI;gBACtD,IAAIA,SAAS,CAAC,KAAKA,OAAOJ,QAAQG,OAAO,EAAE;oBACzC,MAAM,IAAIG,MAAM;gBAClB;YACF;QACF;QACA,OAAOJ;IACT,GACA,CAACA,QAAUA,OACZ"}
|
package/package.json
CHANGED
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@nmtjs/
|
|
13
|
-
"@nmtjs/
|
|
12
|
+
"@nmtjs/type": "0.2.0",
|
|
13
|
+
"@nmtjs/common": "0.2.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@nmtjs/common": "0.
|
|
17
|
-
"@nmtjs/type": "0.
|
|
16
|
+
"@nmtjs/common": "0.2.0",
|
|
17
|
+
"@nmtjs/type": "0.2.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.
|
|
26
|
+
"version": "0.2.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
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
SubscriptionContract,
|
|
12
12
|
type TSubscriptionContract,
|
|
13
13
|
} from './schemas/subscription.ts'
|
|
14
|
-
import { blob } from './types/blob.ts'
|
|
14
|
+
import { blob as blobType } from './types/blob.ts'
|
|
15
15
|
|
|
16
16
|
export type {
|
|
17
17
|
TEventContract,
|
|
@@ -26,6 +26,5 @@ export namespace c {
|
|
|
26
26
|
export const event = EventContract
|
|
27
27
|
export const subscription = SubscriptionContract
|
|
28
28
|
export const service = ServiceContract
|
|
29
|
+
export const blob = blobType
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
export const t = Object.assign({}, baseT, { blob })
|
package/src/types/blob.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface BlobOptions {
|
|
|
11
11
|
export const blob = (options: BlobOptions = {}) =>
|
|
12
12
|
t.custom<ApiBlobInterface>(
|
|
13
13
|
(value) => {
|
|
14
|
+
// TODO: this should be registered separately for server and client
|
|
15
|
+
// ref: https://github.com/sinclairzx81/typebox/issues/977
|
|
14
16
|
if ('metadata' in value) {
|
|
15
17
|
if (options.maxSize) {
|
|
16
18
|
const size = (value as ApiBlobInterface).metadata.size
|