@orpc/contract 0.10.0 → 0.12.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 +0 -1
- package/dist/src/builder.d.ts +0 -1
- package/dist/src/constants.d.ts +0 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/procedure.d.ts +0 -1
- package/dist/src/router-builder.d.ts +0 -1
- package/dist/src/router.d.ts +0 -1
- package/dist/src/types.d.ts +0 -1
- package/dist/src/utils.d.ts +0 -1
- package/package.json +7 -12
- package/dist/index.js.map +0 -1
- package/dist/src/builder.d.ts.map +0 -1
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/procedure.d.ts.map +0 -1
- package/dist/src/router-builder.d.ts.map +0 -1
- package/dist/src/router.d.ts.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/builder.test.ts +0 -179
- package/src/builder.ts +0 -52
- package/src/constants.ts +0 -2
- package/src/index.ts +0 -12
- package/src/procedure.test.ts +0 -99
- package/src/procedure.ts +0 -125
- package/src/router-builder.test.ts +0 -70
- package/src/router-builder.ts +0 -46
- package/src/router.test-d.ts +0 -63
- package/src/router.test.ts +0 -24
- package/src/router.ts +0 -55
- package/src/types.test-d.ts +0 -16
- package/src/types.ts +0 -25
- package/src/utils.test.ts +0 -18
- package/src/utils.ts +0 -17
package/dist/index.js
CHANGED
package/dist/src/builder.d.ts
CHANGED
package/dist/src/constants.d.ts
CHANGED
package/dist/src/index.d.ts
CHANGED
package/dist/src/procedure.d.ts
CHANGED
|
@@ -43,4 +43,3 @@ export declare class DecoratedContractProcedure<TInputSchema extends Schema, TOu
|
|
|
43
43
|
}
|
|
44
44
|
export type WELL_DEFINED_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>;
|
|
45
45
|
export declare function isContractProcedure(item: unknown): item is WELL_DEFINED_CONTRACT_PROCEDURE;
|
|
46
|
-
//# sourceMappingURL=procedure.d.ts.map
|
package/dist/src/router.d.ts
CHANGED
|
@@ -13,4 +13,3 @@ export type InferContractRouterInputs<T extends ContractRouter> = {
|
|
|
13
13
|
export type InferContractRouterOutputs<T extends ContractRouter> = {
|
|
14
14
|
[K in keyof T]: T[K] extends ContractProcedure<any, infer UOutputSchema> ? SchemaOutput<UOutputSchema> : T[K] extends ContractRouter ? InferContractRouterOutputs<T[K]> : never;
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=router.d.ts.map
|
package/dist/src/types.d.ts
CHANGED
|
@@ -5,4 +5,3 @@ export type HTTPStatus = number;
|
|
|
5
5
|
export type Schema = ZodType<any, any, any> | undefined;
|
|
6
6
|
export type SchemaInput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends ZodType<any, any, any> ? input<TSchema> : TFallback;
|
|
7
7
|
export type SchemaOutput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends ZodType<any, any, any> ? output<TSchema> : TFallback;
|
|
8
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/utils.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/contract",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "unnoq",
|
|
7
|
-
"email": "contact@unnoq.com",
|
|
8
|
-
"url": "https://unnoq.com"
|
|
9
|
-
},
|
|
4
|
+
"version": "0.12.0",
|
|
10
5
|
"license": "MIT",
|
|
11
|
-
"homepage": "https://
|
|
6
|
+
"homepage": "https://orpc.unnoq.com",
|
|
12
7
|
"repository": {
|
|
13
8
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/unnoq/orpc.git",
|
|
9
|
+
"url": "git+https://github.com/unnoq/orpc.git",
|
|
15
10
|
"directory": "packages/contract"
|
|
16
11
|
},
|
|
17
12
|
"keywords": [
|
|
@@ -29,17 +24,17 @@
|
|
|
29
24
|
}
|
|
30
25
|
},
|
|
31
26
|
"files": [
|
|
32
|
-
"dist",
|
|
33
|
-
"
|
|
27
|
+
"!dist/*.tsbuildinfo",
|
|
28
|
+
"dist"
|
|
34
29
|
],
|
|
35
30
|
"peerDependencies": {
|
|
36
31
|
"zod": ">=3.23.0"
|
|
37
32
|
},
|
|
38
33
|
"dependencies": {
|
|
39
|
-
"@orpc/shared": "0.
|
|
34
|
+
"@orpc/shared": "0.12.0"
|
|
40
35
|
},
|
|
41
36
|
"scripts": {
|
|
42
|
-
"build": "tsup --clean --
|
|
37
|
+
"build": "tsup --clean --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|
|
43
38
|
"build:watch": "pnpm run build --watch",
|
|
44
39
|
"type:check": "tsc -b"
|
|
45
40
|
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/procedure.ts","../src/router-builder.ts","../src/builder.ts","../src/constants.ts","../src/router.ts","../src/utils.ts","../src/index.ts"],"sourcesContent":["import type {\n HTTPMethod,\n HTTPPath,\n Schema,\n SchemaInput,\n SchemaOutput,\n} from './types'\n\nexport interface RouteOptions {\n method?: HTTPMethod\n path?: HTTPPath\n summary?: string\n description?: string\n deprecated?: boolean\n tags?: string[]\n}\n\nexport class ContractProcedure<\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n> {\n constructor(\n public zz$cp: {\n path?: HTTPPath\n method?: HTTPMethod\n summary?: string\n description?: string\n deprecated?: boolean\n tags?: string[]\n InputSchema: TInputSchema\n inputExample?: SchemaOutput<TInputSchema>\n OutputSchema: TOutputSchema\n outputExample?: SchemaOutput<TOutputSchema>\n },\n ) {}\n}\n\nexport class DecoratedContractProcedure<\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n> extends ContractProcedure<TInputSchema, TOutputSchema> {\n static decorate<TInputSchema extends Schema, TOutputSchema extends Schema>(\n cp: ContractProcedure<TInputSchema, TOutputSchema>,\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n if (cp instanceof DecoratedContractProcedure)\n return cp\n return new DecoratedContractProcedure(cp.zz$cp)\n }\n\n route(\n opts: RouteOptions,\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n ...opts,\n method: opts.method,\n path: opts.path,\n })\n }\n\n prefix(\n prefix: HTTPPath,\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n if (!this.zz$cp.path)\n return this\n\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n path: `${prefix}${this.zz$cp.path}`,\n })\n }\n\n addTags(\n ...tags: string[]\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n if (!tags.length)\n return this\n\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n tags: [...(this.zz$cp.tags ?? []), ...tags],\n })\n }\n\n input<USchema extends Schema>(\n schema: USchema,\n example?: SchemaInput<USchema>,\n ): DecoratedContractProcedure<USchema, TOutputSchema> {\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n InputSchema: schema,\n inputExample: example,\n })\n }\n\n output<USchema extends Schema>(\n schema: USchema,\n example?: SchemaOutput<USchema>,\n ): DecoratedContractProcedure<TInputSchema, USchema> {\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n OutputSchema: schema,\n outputExample: example,\n })\n }\n}\n\nexport type WELL_DEFINED_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>\n\nexport function isContractProcedure(\n item: unknown,\n): item is WELL_DEFINED_CONTRACT_PROCEDURE {\n if (item instanceof ContractProcedure)\n return true\n\n return (\n (typeof item === 'object' || typeof item === 'function')\n && item !== null\n && 'zz$cp' in item\n && typeof item.zz$cp === 'object'\n && item.zz$cp !== null\n && 'InputSchema' in item.zz$cp\n && 'OutputSchema' in item.zz$cp\n )\n}\n","import type { ContractRouter, HandledContractRouter } from './router'\nimport type { HTTPPath } from './types'\nimport { DecoratedContractProcedure, isContractProcedure } from './procedure'\n\nexport class ContractRouterBuilder {\n constructor(public zz$crb: { prefix?: HTTPPath, tags?: string[] }) {}\n\n prefix(prefix: HTTPPath): ContractRouterBuilder {\n return new ContractRouterBuilder({\n ...this.zz$crb,\n prefix: `${this.zz$crb.prefix ?? ''}${prefix}`,\n })\n }\n\n tags(...tags: string[]): ContractRouterBuilder {\n if (!tags.length)\n return this\n\n return new ContractRouterBuilder({\n ...this.zz$crb,\n tags: [...(this.zz$crb.tags ?? []), ...tags],\n })\n }\n\n router<T extends ContractRouter>(router: T): HandledContractRouter<T> {\n const handled: ContractRouter = {}\n\n for (const key in router) {\n const item = router[key]\n if (isContractProcedure(item)) {\n const decorated = DecoratedContractProcedure.decorate(item).addTags(\n ...(this.zz$crb.tags ?? []),\n )\n\n handled[key] = this.zz$crb.prefix\n ? decorated.prefix(this.zz$crb.prefix)\n : decorated\n }\n else {\n handled[key] = this.router(item as ContractRouter)\n }\n }\n\n return handled as HandledContractRouter<T>\n }\n}\n","import type { ContractRouter } from './router'\nimport type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types'\nimport { DecoratedContractProcedure, type RouteOptions } from './procedure'\nimport { ContractRouterBuilder } from './router-builder'\n\nexport class ContractBuilder {\n prefix(prefix: HTTPPath): ContractRouterBuilder {\n return new ContractRouterBuilder({\n prefix,\n })\n }\n\n tags(...tags: string[]): ContractRouterBuilder {\n return new ContractRouterBuilder({\n tags,\n })\n }\n\n route(opts: RouteOptions): DecoratedContractProcedure<undefined, undefined> {\n return new DecoratedContractProcedure({\n InputSchema: undefined,\n OutputSchema: undefined,\n ...opts,\n })\n }\n\n input<USchema extends Schema>(\n schema: USchema,\n example?: SchemaInput<USchema>,\n ): DecoratedContractProcedure<USchema, undefined> {\n return new DecoratedContractProcedure({\n InputSchema: schema,\n inputExample: example,\n OutputSchema: undefined,\n })\n }\n\n output<USchema extends Schema>(\n schema: USchema,\n example?: SchemaOutput<USchema>,\n ): DecoratedContractProcedure<undefined, USchema> {\n return new DecoratedContractProcedure({\n InputSchema: undefined,\n OutputSchema: schema,\n outputExample: example,\n })\n }\n\n router<T extends ContractRouter>(router: T): T {\n return router\n }\n}\n","export const ORPC_HEADER = 'x-orpc-transformer'\nexport const ORPC_HEADER_VALUE = 't'\n","import type { SchemaInput, SchemaOutput } from './types'\nimport {\n type ContractProcedure,\n type DecoratedContractProcedure,\n isContractProcedure,\n type WELL_DEFINED_CONTRACT_PROCEDURE,\n} from './procedure'\n\nexport interface ContractRouter {\n [k: string]: ContractProcedure<any, any> | ContractRouter\n}\n\nexport type HandledContractRouter<TContract extends ContractRouter> = {\n [K in keyof TContract]: TContract[K] extends ContractProcedure<\n infer UInputSchema,\n infer UOutputSchema\n >\n ? DecoratedContractProcedure<UInputSchema, UOutputSchema>\n : TContract[K] extends ContractRouter\n ? HandledContractRouter<TContract[K]>\n : never\n}\n\nexport function eachContractRouterLeaf(\n router: ContractRouter,\n callback: (item: WELL_DEFINED_CONTRACT_PROCEDURE, path: string[]) => void,\n prefix: string[] = [],\n) {\n for (const key in router) {\n const item = router[key]\n\n if (isContractProcedure(item)) {\n callback(item, [...prefix, key])\n }\n else {\n eachContractRouterLeaf(item as ContractRouter, callback, [...prefix, key])\n }\n }\n}\n\nexport type InferContractRouterInputs<T extends ContractRouter> = {\n [K in keyof T]: T[K] extends ContractProcedure<infer UInputSchema, any>\n ? SchemaInput<UInputSchema>\n : T[K] extends ContractRouter\n ? InferContractRouterInputs<T[K]>\n : never\n}\n\nexport type InferContractRouterOutputs<T extends ContractRouter> = {\n [K in keyof T]: T[K] extends ContractProcedure<any, infer UOutputSchema>\n ? SchemaOutput<UOutputSchema>\n : T[K] extends ContractRouter\n ? InferContractRouterOutputs<T[K]>\n : never\n}\n","import type { HTTPPath } from './types'\n\nexport function standardizeHTTPPath(path: HTTPPath): HTTPPath {\n return `/${path.replace(/\\/{2,}/g, '/').replace(/^\\/|\\/$/g, '')}`\n}\n\nexport function prefixHTTPPath(prefix: HTTPPath, path: HTTPPath): HTTPPath {\n const prefix_ = standardizeHTTPPath(prefix)\n const path_ = standardizeHTTPPath(path)\n\n if (prefix_ === '/')\n return path_\n if (path_ === '/')\n return prefix_\n\n return `${prefix_}${path_}`\n}\n","/** unnoq */\n\nimport { ContractBuilder } from './builder'\n\nexport * from './builder'\nexport * from './constants'\nexport * from './procedure'\nexport * from './router'\nexport * from './types'\nexport * from './utils'\n\nexport const oc = new ContractBuilder()\n"],"mappings":";AAiBO,IAAM,oBAAN,MAGL;AAAA,EACA,YACS,OAYP;AAZO;AAAA,EAYN;AACL;AAEO,IAAM,6BAAN,MAAM,oCAGH,kBAA+C;AAAA,EACvD,OAAO,SACL,IACyD;AACzD,QAAI,cAAc;AAChB,aAAO;AACT,WAAO,IAAI,4BAA2B,GAAG,KAAK;AAAA,EAChD;AAAA,EAEA,MACE,MACyD;AACzD,WAAO,IAAI,4BAA2B;AAAA,MACpC,GAAG,KAAK;AAAA,MACR,GAAG;AAAA,MACH,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK;AAAA,IACb,CAAC;AAAA,EACH;AAAA,EAEA,OACE,QACyD;AACzD,QAAI,CAAC,KAAK,MAAM;AACd,aAAO;AAET,WAAO,IAAI,4BAA2B;AAAA,MACpC,GAAG,KAAK;AAAA,MACR,MAAM,GAAG,MAAM,GAAG,KAAK,MAAM,IAAI;AAAA,IACnC,CAAC;AAAA,EACH;AAAA,EAEA,WACK,MACsD;AACzD,QAAI,CAAC,KAAK;AACR,aAAO;AAET,WAAO,IAAI,4BAA2B;AAAA,MACpC,GAAG,KAAK;AAAA,MACR,MAAM,CAAC,GAAI,KAAK,MAAM,QAAQ,CAAC,GAAI,GAAG,IAAI;AAAA,IAC5C,CAAC;AAAA,EACH;AAAA,EAEA,MACE,QACA,SACoD;AACpD,WAAO,IAAI,4BAA2B;AAAA,MACpC,GAAG,KAAK;AAAA,MACR,aAAa;AAAA,MACb,cAAc;AA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ourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,uBAAuB,CAAA;AAC/C,eAAO,MAAM,iBAAiB,MAAM,CAAA"}
|
package/dist/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AAEvB,eAAO,MAAM,EAAE,iBAAwB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,MAAM,EACN,WAAW,EACX,YAAY,EACb,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,qBAAa,iBAAiB,CAC5B,YAAY,SAAS,MAAM,EAC3B,aAAa,SAAS,MAAM;IAGnB,KAAK,EAAE;QACZ,IAAI,CAAC,EAAE,QAAQ,CAAA;QACf,MAAM,CAAC,EAAE,UAAU,CAAA;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,IAAI,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,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,GAC7B,0BAA0B,CAAC,OAAO,EAAE,aAAa,CAAC;IAQrD,MAAM,CAAC,OAAO,SAAS,MAAM,EAC3B,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,GAC9B,0BAA0B,CAAC,YAAY,EAAE,OAAO,CAAC;CAOrD;AAED,MAAM,MAAM,+BAA+B,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE/E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,+BAA+B,CAazC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router-builder.d.ts","sourceRoot":"","sources":["../../src/router-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGvC,qBAAa,qBAAqB;IACb,MAAM,EAAE;QAAE,MAAM,CAAC,EAAE,QAAQ,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;gBAA9C,MAAM,EAAE;QAAE,MAAM,CAAC,EAAE,QAAQ,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;IAEjE,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,qBAAqB;IAO/C,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,qBAAqB;IAU9C,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,MAAM,EAAE,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC;CAqBtE"}
|
package/dist/src/router.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/router.ts"],"names":[],"mappings":"A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AAiB,CAAC,GAAG,EAAE,MAAM,aAAa,CAAC,GACpE,YAAY,CAAC,aAAa,CAAC,GAC3B,CAAC,CAAC,CAAC,CAAC,SAAS,cAAc,GACzB,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAChC,KAAK;CACZ,CAAA"}
|
package/dist/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAEjD,MAAM,MAAM,QAAQ,GAAG,IAAI,MAAM,EAAE,CAAA;AACnC,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAA;AACpE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAE/B,MAAM,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;AAEvD,MAAM,MAAM,WAAW,CACrB,OAAO,SAAS,MAAM,EACtB,SAAS,GAAG,OAAO,IACjB,OAAO,SAAS,SAAS,GACzB,SAAS,GACT,OAAO,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GACpC,KAAK,CAAC,OAAO,CAAC,GACd,SAAS,CAAA;AAEf,MAAM,MAAM,YAAY,CACtB,OAAO,SAAS,MAAM,EACtB,SAAS,GAAG,OAAO,IACjB,OAAO,SAAS,SAAS,GACzB,SAAS,GACT,OAAO,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GACpC,MAAM,CAAC,OAAO,CAAC,GACf,SAAS,CAAA"}
|
package/dist/src/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAE5D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAUzE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"fileNames":["../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/@types+react@18.3.12/node_modules/@types/react/global.d.ts","../../../node_modules/.pnpm/csstype@3.1.3/node_modules/csstype/index.d.ts","../../../node_modules/.pnpm/@types+prop-types@15.7.13/node_modules/@types/prop-types/index.d.ts","../../../node_modules/.pnpm/@types+react@18.3.12/node_modules/@types/react/index.d.ts","../../../node_modules/.pnpm/@types+react@18.3.12/node_modules/@types/react/jsx-runtime.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/helpers/typeAliases.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/helpers/util.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/ZodError.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/locales/en.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/errors.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/helpers/parseUtil.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/helpers/enumUtil.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/helpers/errorUtil.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/helpers/partialUtil.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/types.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/external.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.d.ts","../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/index.d.ts","../src/types.ts","../src/procedure.ts","../src/router.ts","../src/router-builder.ts","../src/builder.ts","../src/constants.ts","../src/utils.ts","../src/index.ts"],"fileIdsList":[[58,59,60],[61],[74],[63,64,74],[65,66],[63,64,65,67,68,72],[64,65],[73],[65],[63,64,65,68,69,70,71],[62,76,77,78,79],[62],[62,76,77,78,80,81,82],[62,76],[62,76,77,78],[62,76,77],[62,75]],"fileInfos":[{"version":"e41c290ef7dd7dab3493e6cbe5909e0148edf4a8dad0271be08edec368a0f7b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"62bb211266ee48b2d0edf0d8d1b191f0c24fc379a82bd4c1692a082c540bc6b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"fef8cfad2e2dc5f5b3d97a6f4f2e92848eb1b88e897bb7318cef0e2820bceaab","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"f1e2a172204962276504466a6393426d2ca9c54894b1ad0a6c9dad867a65f876","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"b5ce7a470bc3628408429040c4e3a53a27755022a32fd05e2cb694e7015386c7","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"36a2e4c9a67439aca5f91bb304611d5ae6e20d420503e96c230cf8fcdc948d94","affectsGlobalScope":true,"impliedFormat":1},{"version":"8a8eb4ebffd85e589a1cc7c178e291626c359543403d58c9cd22b81fab5b1fb9","impliedFormat":1},{"version":"ed6b820c54de95b2510bb673490d61c7f2187f532a339d8d04981645a918961f","impliedFormat":1},{"version":"aa17748c522bd586f8712b1a308ea23af59c309b2fd278f6d4f406647c72e659","affectsGlobalScope":true,"impliedFormat":1},{"version":"42c169fb8c2d42f4f668c624a9a11e719d5d07dacbebb63cbcf7ef365b0a75b3","impliedFormat":1},{"version":"5487b97cfa28b26b4a9ef0770f872bdbebd4c46124858de00f242c3eed7519f4","impliedFormat":1},{"version":"c2869c4f2f79fd2d03278a68ce7c061a5a8f4aed59efb655e25fe502e3e471d5","impliedFormat":1},{"version":"b8fe42dbf4b0efba2eb4dbfb2b95a3712676717ff8469767dc439e75d0c1a3b6","impliedFormat":1},{"version":"8485b6da53ec35637d072e516631d25dae53984500de70a6989058f24354666f","impliedFormat":1},{"version":"ebe80346928736532e4a822154eb77f57ef3389dbe2b3ba4e571366a15448ef2","impliedFormat":1},{"version":"83306c97a4643d78420f082547ea0d488a0d134c922c8e65fc0b4f08ef66d92b","impliedFormat":1},{"version":"f672c876c1a04a223cf2023b3d91e8a52bb1544c576b81bf64a8fec82be9969c","impliedFormat":1},{"version":"98a9cc18f661d28e6bd31c436e1984f3980f35e0f0aa9cf795c54f8ccb667ffe","impliedFormat":1},{"version":"c76b0c5727302341d0bdfa2cc2cee4b19ff185b554edb6e8543f0661d8487116","impliedFormat":1},{"version":"dccd26a5c85325a011aff40f401e0892bd0688d44132ba79e803c67e68fffea5","impliedFormat":1},{"version":"f5ef066942e4f0bd98200aa6a6694b831e73200c9b3ade77ad0aa2409e8fe1b1","impliedFormat":1},{"version":"b9e99cd94f4166a245f5158f7286c05406e2a4c694619bceb7a4f3519d1d768e","impliedFormat":1},{"version":"5568d7c32e5cf5f35e092649f4e5e168c3114c800b1d7545b7ae5e0415704802","impliedFormat":1},{"version":"153be41d5211bf58f172a62610a788d39b9ea48065cca3a93700a56f9f358a3c","signature":"0f2dbe9fce173b2c5c10df4a97157d7cb6b082af310abe70759572eef943d3df"},{"version":"6f2c35eb86ba29841d341129ddc8167922d2de9debc11f37a6be2cf29d463d9a","signature":"92523237895f96fdb73233b41807f16c9586032cc58e10777c9b44466b232121"},{"version":"b59ee36d1eac2fcf2895634a83e6bca43d22870c07e9a195b014d0b2d3c7d4fd","signature":"649ef9f17aada1037b29b13da8d7be3fca68661add5f0c423408ab402e3e4c95"},{"version":"1a716331ed29e665f72f1fe730f07c7e9abaca4e5734834753f5847a3c22e813","signature":"40e6a5252b059c72bdf941ef3e3554b2d594b3afb2b3d960fc99e45dc111db6b"},{"version":"df12b0d62e4176fe2a86aa6afc1c3ede1989db925818b0f28c54a4f92286ed50","signature":"c525b73cc35a91182a74352d183af74c84c7dab2b0bcb7af7f28913ee5f834da"},{"version":"09c71b329e2998997dc43b4ca46302bf0d4ca6f1e0769f5f8e5fcccbcf86d8ab","signature":"5cc386bba6024e9e937e97db6bc9b02aafc9450109fa0dee4ad64c34f2d99779"},{"version":"9283f04b75500569cf2865fe93419666c77ff7c3f134673243f6052abe0406d6","signature":"6c418dc23ed07c2d22255b3fe284dc06aa33bda643457144a8d07e48669135e6"},{"version":"732649b7018adb1bba48b07681ee2f2dabb09f77dd72c5d31e49eda63e6c3d7c","signature":"332bba04d0943565dc5346621a3a399e18885bc2ca809072f63c0806bfcdfcd3"}],"root":[[76,83]],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"jsx":4,"module":7,"noImplicitOverride":true,"noUncheckedIndexedAccess":true,"noUncheckedSideEffectImports":true,"outDir":"./","skipLibCheck":true,"strict":true,"target":9,"useDefineForClassFields":true},"referencedMap":[[61,1],[62,2],[75,3],[65,4],[67,5],[73,6],[68,7],[71,3],[74,8],[66,9],[72,10],[80,11],[81,12],[83,13],[77,14],[79,15],[78,16],[76,17],[82,14]],"semanticDiagnosticsPerFile":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83],"latestChangedDtsFile":"./src/index.d.ts","checkPending":true,"version":"5.7.2"}
|
package/src/builder.test.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { type DecoratedContractProcedure, oc } from '.'
|
|
3
|
-
|
|
4
|
-
describe('define a procedure', () => {
|
|
5
|
-
it('use route method', () => {
|
|
6
|
-
const procedure = oc.route({
|
|
7
|
-
method: 'GET',
|
|
8
|
-
path: '/users/{id}',
|
|
9
|
-
deprecated: true,
|
|
10
|
-
summary: 'Get user',
|
|
11
|
-
description: 'Get user by id',
|
|
12
|
-
tags: ['bbbb'],
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
expectTypeOf(procedure).toEqualTypeOf<
|
|
16
|
-
DecoratedContractProcedure<undefined, undefined>
|
|
17
|
-
>()
|
|
18
|
-
|
|
19
|
-
expect(procedure.zz$cp).toMatchObject({
|
|
20
|
-
method: 'GET',
|
|
21
|
-
path: '/users/{id}',
|
|
22
|
-
deprecated: true,
|
|
23
|
-
summary: 'Get user',
|
|
24
|
-
description: 'Get user by id',
|
|
25
|
-
tags: ['bbbb'],
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('use input method', () => {
|
|
30
|
-
const schema = z.object({
|
|
31
|
-
id: z.string(),
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const procedure = oc.input(schema, { id: '123' })
|
|
35
|
-
|
|
36
|
-
expectTypeOf(procedure).toEqualTypeOf<
|
|
37
|
-
DecoratedContractProcedure<typeof schema, undefined>
|
|
38
|
-
>()
|
|
39
|
-
|
|
40
|
-
expect(procedure.zz$cp).toMatchObject({
|
|
41
|
-
InputSchema: schema,
|
|
42
|
-
inputExample: { id: '123' },
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('use output method', () => {
|
|
47
|
-
const schema = z.object({ id: z.string() })
|
|
48
|
-
|
|
49
|
-
const procedure = oc.output(schema, { id: '123' })
|
|
50
|
-
|
|
51
|
-
expectTypeOf(procedure).toEqualTypeOf<
|
|
52
|
-
DecoratedContractProcedure<undefined, typeof schema>
|
|
53
|
-
>()
|
|
54
|
-
|
|
55
|
-
expect(procedure.zz$cp).toMatchObject({
|
|
56
|
-
OutputSchema: schema,
|
|
57
|
-
outputExample: { id: '123' },
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe('define a router', () => {
|
|
63
|
-
it('simple', () => {
|
|
64
|
-
const schema1 = z.string()
|
|
65
|
-
const schema2 = z.object({ id: z.string() })
|
|
66
|
-
const ping = oc.output(schema1)
|
|
67
|
-
const find = oc.output(schema2)
|
|
68
|
-
|
|
69
|
-
const router = oc.router({
|
|
70
|
-
ping,
|
|
71
|
-
user: {
|
|
72
|
-
find,
|
|
73
|
-
},
|
|
74
|
-
user2: oc.router({
|
|
75
|
-
find,
|
|
76
|
-
}),
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
expectTypeOf(router).toMatchTypeOf<{
|
|
80
|
-
ping: typeof ping
|
|
81
|
-
user: {
|
|
82
|
-
find: typeof find
|
|
83
|
-
}
|
|
84
|
-
user2: {
|
|
85
|
-
find: typeof find
|
|
86
|
-
}
|
|
87
|
-
}>()
|
|
88
|
-
|
|
89
|
-
expect(router).toMatchObject({
|
|
90
|
-
ping,
|
|
91
|
-
user: {
|
|
92
|
-
find,
|
|
93
|
-
},
|
|
94
|
-
user2: {
|
|
95
|
-
find,
|
|
96
|
-
},
|
|
97
|
-
})
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
it('with prefix', () => {
|
|
101
|
-
const schema1 = z.string()
|
|
102
|
-
const schema2 = z.object({ id: z.string() })
|
|
103
|
-
const ping = oc.output(schema1)
|
|
104
|
-
const find = oc.output(schema2)
|
|
105
|
-
|
|
106
|
-
const router = oc.router({
|
|
107
|
-
ping: ping.prefix('/ping'),
|
|
108
|
-
user: {
|
|
109
|
-
find,
|
|
110
|
-
},
|
|
111
|
-
user2: oc
|
|
112
|
-
.prefix('/internal')
|
|
113
|
-
.prefix('/user2')
|
|
114
|
-
.router({
|
|
115
|
-
find2: find.prefix('/find2'),
|
|
116
|
-
}),
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
expectTypeOf(router).toMatchTypeOf<{
|
|
120
|
-
ping: typeof ping
|
|
121
|
-
user: {
|
|
122
|
-
find: typeof find
|
|
123
|
-
}
|
|
124
|
-
user2: {
|
|
125
|
-
find2: typeof find
|
|
126
|
-
}
|
|
127
|
-
}>()
|
|
128
|
-
|
|
129
|
-
expect(router).toMatchObject({
|
|
130
|
-
ping: ping.prefix('/ping'),
|
|
131
|
-
user: {
|
|
132
|
-
find,
|
|
133
|
-
},
|
|
134
|
-
user2: {
|
|
135
|
-
find2: find.prefix('/internal/user2/find2'),
|
|
136
|
-
},
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
it('with tags', () => {
|
|
141
|
-
const schema1 = z.string()
|
|
142
|
-
const schema2 = z.object({ id: z.string() })
|
|
143
|
-
const ping = oc.output(schema1)
|
|
144
|
-
const find = oc.output(schema2)
|
|
145
|
-
|
|
146
|
-
const router = oc.router({
|
|
147
|
-
ping: ping.prefix('/ping'),
|
|
148
|
-
user: {
|
|
149
|
-
find,
|
|
150
|
-
},
|
|
151
|
-
user2: oc
|
|
152
|
-
.tags('user')
|
|
153
|
-
.tags('internal')
|
|
154
|
-
.router({
|
|
155
|
-
find2: find.prefix('/find2'),
|
|
156
|
-
}),
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
expectTypeOf(router).toMatchTypeOf<{
|
|
160
|
-
ping: typeof ping
|
|
161
|
-
user: {
|
|
162
|
-
find: typeof find
|
|
163
|
-
}
|
|
164
|
-
user2: {
|
|
165
|
-
find2: typeof find
|
|
166
|
-
}
|
|
167
|
-
}>()
|
|
168
|
-
|
|
169
|
-
expect(router).toMatchObject({
|
|
170
|
-
ping: ping.prefix('/ping'),
|
|
171
|
-
user: {
|
|
172
|
-
find,
|
|
173
|
-
},
|
|
174
|
-
user2: {
|
|
175
|
-
find2: find.addTags('user', 'internal'),
|
|
176
|
-
},
|
|
177
|
-
})
|
|
178
|
-
})
|
|
179
|
-
})
|
package/src/builder.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { ContractRouter } from './router'
|
|
2
|
-
import type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types'
|
|
3
|
-
import { DecoratedContractProcedure, type RouteOptions } from './procedure'
|
|
4
|
-
import { ContractRouterBuilder } from './router-builder'
|
|
5
|
-
|
|
6
|
-
export class ContractBuilder {
|
|
7
|
-
prefix(prefix: HTTPPath): ContractRouterBuilder {
|
|
8
|
-
return new ContractRouterBuilder({
|
|
9
|
-
prefix,
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
tags(...tags: string[]): ContractRouterBuilder {
|
|
14
|
-
return new ContractRouterBuilder({
|
|
15
|
-
tags,
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
route(opts: RouteOptions): DecoratedContractProcedure<undefined, undefined> {
|
|
20
|
-
return new DecoratedContractProcedure({
|
|
21
|
-
InputSchema: undefined,
|
|
22
|
-
OutputSchema: undefined,
|
|
23
|
-
...opts,
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
input<USchema extends Schema>(
|
|
28
|
-
schema: USchema,
|
|
29
|
-
example?: SchemaInput<USchema>,
|
|
30
|
-
): DecoratedContractProcedure<USchema, undefined> {
|
|
31
|
-
return new DecoratedContractProcedure({
|
|
32
|
-
InputSchema: schema,
|
|
33
|
-
inputExample: example,
|
|
34
|
-
OutputSchema: undefined,
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
output<USchema extends Schema>(
|
|
39
|
-
schema: USchema,
|
|
40
|
-
example?: SchemaOutput<USchema>,
|
|
41
|
-
): DecoratedContractProcedure<undefined, USchema> {
|
|
42
|
-
return new DecoratedContractProcedure({
|
|
43
|
-
InputSchema: undefined,
|
|
44
|
-
OutputSchema: schema,
|
|
45
|
-
outputExample: example,
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
router<T extends ContractRouter>(router: T): T {
|
|
50
|
-
return router
|
|
51
|
-
}
|
|
52
|
-
}
|
package/src/constants.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** unnoq */
|
|
2
|
-
|
|
3
|
-
import { ContractBuilder } from './builder'
|
|
4
|
-
|
|
5
|
-
export * from './builder'
|
|
6
|
-
export * from './constants'
|
|
7
|
-
export * from './procedure'
|
|
8
|
-
export * from './router'
|
|
9
|
-
export * from './types'
|
|
10
|
-
export * from './utils'
|
|
11
|
-
|
|
12
|
-
export const oc = new ContractBuilder()
|
package/src/procedure.test.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { DecoratedContractProcedure } from './procedure'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
import { isContractProcedure, oc } from '.'
|
|
4
|
-
|
|
5
|
-
it('prefix method', () => {
|
|
6
|
-
const os = oc
|
|
7
|
-
const p1 = os.route({
|
|
8
|
-
method: 'GET',
|
|
9
|
-
path: '/ping',
|
|
10
|
-
})
|
|
11
|
-
const p2 = os.input(z.object({}))
|
|
12
|
-
|
|
13
|
-
expect(p1.prefix('/prefix').zz$cp.path).toEqual('/prefix/ping')
|
|
14
|
-
expect(p2.prefix('/prefix').zz$cp.path).toEqual(undefined)
|
|
15
|
-
|
|
16
|
-
expect(p1.prefix('/1').prefix('/2').zz$cp.path).toEqual('/2/1/ping')
|
|
17
|
-
expect(p2.prefix('/1').prefix('/2').zz$cp.path).toEqual(undefined)
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('route method', () => {
|
|
21
|
-
const p = oc
|
|
22
|
-
.route({
|
|
23
|
-
method: 'POST',
|
|
24
|
-
})
|
|
25
|
-
.route({
|
|
26
|
-
method: 'GET',
|
|
27
|
-
path: '/abc',
|
|
28
|
-
deprecated: true,
|
|
29
|
-
description: 'abc',
|
|
30
|
-
summary: 'abc',
|
|
31
|
-
tags: ['user'],
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
expectTypeOf(p).toEqualTypeOf<
|
|
35
|
-
DecoratedContractProcedure<undefined, undefined>
|
|
36
|
-
>()
|
|
37
|
-
|
|
38
|
-
expect(p.zz$cp).toMatchObject({
|
|
39
|
-
method: 'GET',
|
|
40
|
-
path: '/abc',
|
|
41
|
-
deprecated: true,
|
|
42
|
-
description: 'abc',
|
|
43
|
-
summary: 'abc',
|
|
44
|
-
tags: ['user'],
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('input method', () => {
|
|
49
|
-
const schema = z.string()
|
|
50
|
-
const p = oc.route({}).input(schema)
|
|
51
|
-
|
|
52
|
-
expectTypeOf(p).toEqualTypeOf<
|
|
53
|
-
DecoratedContractProcedure<typeof schema, undefined>
|
|
54
|
-
>()
|
|
55
|
-
|
|
56
|
-
expect(p.zz$cp).toMatchObject({
|
|
57
|
-
InputSchema: schema,
|
|
58
|
-
inputExample: undefined,
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('output method', () => {
|
|
63
|
-
const schema = z.string()
|
|
64
|
-
const p = oc.route({}).output(schema)
|
|
65
|
-
|
|
66
|
-
expectTypeOf(p).toEqualTypeOf<
|
|
67
|
-
DecoratedContractProcedure<undefined, typeof schema>
|
|
68
|
-
>()
|
|
69
|
-
|
|
70
|
-
expect(p.zz$cp).toMatchObject({
|
|
71
|
-
OutputSchema: schema,
|
|
72
|
-
outputExample: undefined,
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('addTags method', () => {
|
|
77
|
-
const schema = z.string()
|
|
78
|
-
const p = oc.route({}).output(schema)
|
|
79
|
-
|
|
80
|
-
expect(p.zz$cp.tags).toBe(undefined)
|
|
81
|
-
|
|
82
|
-
const p2 = p.addTags('foo', 'bar')
|
|
83
|
-
|
|
84
|
-
expect(p2.zz$cp.tags).toEqual(['foo', 'bar'])
|
|
85
|
-
|
|
86
|
-
const p3 = p2.addTags('baz')
|
|
87
|
-
|
|
88
|
-
expect(p3.zz$cp.tags).toEqual(['foo', 'bar', 'baz'])
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('isContractProcedure function', () => {
|
|
92
|
-
expect(isContractProcedure(oc)).toBe(false)
|
|
93
|
-
expect(isContractProcedure(oc.router({}))).toBe(false)
|
|
94
|
-
expect(isContractProcedure(oc.route({}))).toBe(true)
|
|
95
|
-
|
|
96
|
-
expect(isContractProcedure(oc.router({ prefix: oc.route({}) }).prefix)).toBe(
|
|
97
|
-
true,
|
|
98
|
-
)
|
|
99
|
-
})
|
package/src/procedure.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
HTTPMethod,
|
|
3
|
-
HTTPPath,
|
|
4
|
-
Schema,
|
|
5
|
-
SchemaInput,
|
|
6
|
-
SchemaOutput,
|
|
7
|
-
} from './types'
|
|
8
|
-
|
|
9
|
-
export interface RouteOptions {
|
|
10
|
-
method?: HTTPMethod
|
|
11
|
-
path?: HTTPPath
|
|
12
|
-
summary?: string
|
|
13
|
-
description?: string
|
|
14
|
-
deprecated?: boolean
|
|
15
|
-
tags?: string[]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class ContractProcedure<
|
|
19
|
-
TInputSchema extends Schema,
|
|
20
|
-
TOutputSchema extends Schema,
|
|
21
|
-
> {
|
|
22
|
-
constructor(
|
|
23
|
-
public zz$cp: {
|
|
24
|
-
path?: HTTPPath
|
|
25
|
-
method?: HTTPMethod
|
|
26
|
-
summary?: string
|
|
27
|
-
description?: string
|
|
28
|
-
deprecated?: boolean
|
|
29
|
-
tags?: string[]
|
|
30
|
-
InputSchema: TInputSchema
|
|
31
|
-
inputExample?: SchemaOutput<TInputSchema>
|
|
32
|
-
OutputSchema: TOutputSchema
|
|
33
|
-
outputExample?: SchemaOutput<TOutputSchema>
|
|
34
|
-
},
|
|
35
|
-
) {}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class DecoratedContractProcedure<
|
|
39
|
-
TInputSchema extends Schema,
|
|
40
|
-
TOutputSchema extends Schema,
|
|
41
|
-
> extends ContractProcedure<TInputSchema, TOutputSchema> {
|
|
42
|
-
static decorate<TInputSchema extends Schema, TOutputSchema extends Schema>(
|
|
43
|
-
cp: ContractProcedure<TInputSchema, TOutputSchema>,
|
|
44
|
-
): DecoratedContractProcedure<TInputSchema, TOutputSchema> {
|
|
45
|
-
if (cp instanceof DecoratedContractProcedure)
|
|
46
|
-
return cp
|
|
47
|
-
return new DecoratedContractProcedure(cp.zz$cp)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
route(
|
|
51
|
-
opts: RouteOptions,
|
|
52
|
-
): DecoratedContractProcedure<TInputSchema, TOutputSchema> {
|
|
53
|
-
return new DecoratedContractProcedure({
|
|
54
|
-
...this.zz$cp,
|
|
55
|
-
...opts,
|
|
56
|
-
method: opts.method,
|
|
57
|
-
path: opts.path,
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
prefix(
|
|
62
|
-
prefix: HTTPPath,
|
|
63
|
-
): DecoratedContractProcedure<TInputSchema, TOutputSchema> {
|
|
64
|
-
if (!this.zz$cp.path)
|
|
65
|
-
return this
|
|
66
|
-
|
|
67
|
-
return new DecoratedContractProcedure({
|
|
68
|
-
...this.zz$cp,
|
|
69
|
-
path: `${prefix}${this.zz$cp.path}`,
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
addTags(
|
|
74
|
-
...tags: string[]
|
|
75
|
-
): DecoratedContractProcedure<TInputSchema, TOutputSchema> {
|
|
76
|
-
if (!tags.length)
|
|
77
|
-
return this
|
|
78
|
-
|
|
79
|
-
return new DecoratedContractProcedure({
|
|
80
|
-
...this.zz$cp,
|
|
81
|
-
tags: [...(this.zz$cp.tags ?? []), ...tags],
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
input<USchema extends Schema>(
|
|
86
|
-
schema: USchema,
|
|
87
|
-
example?: SchemaInput<USchema>,
|
|
88
|
-
): DecoratedContractProcedure<USchema, TOutputSchema> {
|
|
89
|
-
return new DecoratedContractProcedure({
|
|
90
|
-
...this.zz$cp,
|
|
91
|
-
InputSchema: schema,
|
|
92
|
-
inputExample: example,
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
output<USchema extends Schema>(
|
|
97
|
-
schema: USchema,
|
|
98
|
-
example?: SchemaOutput<USchema>,
|
|
99
|
-
): DecoratedContractProcedure<TInputSchema, USchema> {
|
|
100
|
-
return new DecoratedContractProcedure({
|
|
101
|
-
...this.zz$cp,
|
|
102
|
-
OutputSchema: schema,
|
|
103
|
-
outputExample: example,
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export type WELL_DEFINED_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>
|
|
109
|
-
|
|
110
|
-
export function isContractProcedure(
|
|
111
|
-
item: unknown,
|
|
112
|
-
): item is WELL_DEFINED_CONTRACT_PROCEDURE {
|
|
113
|
-
if (item instanceof ContractProcedure)
|
|
114
|
-
return true
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
(typeof item === 'object' || typeof item === 'function')
|
|
118
|
-
&& item !== null
|
|
119
|
-
&& 'zz$cp' in item
|
|
120
|
-
&& typeof item.zz$cp === 'object'
|
|
121
|
-
&& item.zz$cp !== null
|
|
122
|
-
&& 'InputSchema' in item.zz$cp
|
|
123
|
-
&& 'OutputSchema' in item.zz$cp
|
|
124
|
-
)
|
|
125
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { ContractProcedure, DecoratedContractProcedure, oc } from '.'
|
|
3
|
-
import { ContractRouterBuilder } from './router-builder'
|
|
4
|
-
|
|
5
|
-
it('prefix method', () => {
|
|
6
|
-
expect(oc.prefix('/1').prefix('/2').zz$crb.prefix).toEqual('/1/2')
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
it('tags method', () => {
|
|
10
|
-
expect(oc.tags('1').tags('2').zz$crb.tags).toEqual(['1', '2'])
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('define a router', () => {
|
|
14
|
-
const ping = oc.route({ method: 'GET', path: '/ping' })
|
|
15
|
-
const pong = oc.input(z.object({ id: z.string() }))
|
|
16
|
-
|
|
17
|
-
const router = oc.router({
|
|
18
|
-
ping,
|
|
19
|
-
pong,
|
|
20
|
-
|
|
21
|
-
internal: oc
|
|
22
|
-
.prefix('/internal')
|
|
23
|
-
.tags('internal')
|
|
24
|
-
.router({
|
|
25
|
-
ping,
|
|
26
|
-
pong,
|
|
27
|
-
|
|
28
|
-
nested: {
|
|
29
|
-
ping,
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
expect(router.ping.zz$cp.path).toEqual('/ping')
|
|
35
|
-
expect(router.pong.zz$cp.path).toEqual(undefined)
|
|
36
|
-
|
|
37
|
-
expect(router.internal.ping.zz$cp.path).toEqual('/internal/ping')
|
|
38
|
-
expect(router.internal.pong.zz$cp.path).toEqual(undefined)
|
|
39
|
-
expect(router.internal.nested.ping.zz$cp.path).toEqual('/internal/ping')
|
|
40
|
-
|
|
41
|
-
expect(router.internal.ping.zz$cp.tags).toEqual(['internal'])
|
|
42
|
-
expect(router.internal.pong.zz$cp.tags).toEqual(['internal'])
|
|
43
|
-
expect(router.internal.nested.ping.zz$cp.tags).toEqual(['internal'])
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('router: decorate items', () => {
|
|
47
|
-
const builder = new ContractRouterBuilder({})
|
|
48
|
-
|
|
49
|
-
const ping = new ContractProcedure({
|
|
50
|
-
InputSchema: undefined,
|
|
51
|
-
OutputSchema: undefined,
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
const decorated = new DecoratedContractProcedure({
|
|
55
|
-
InputSchema: undefined,
|
|
56
|
-
OutputSchema: undefined,
|
|
57
|
-
method: 'GET',
|
|
58
|
-
path: '/ping',
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
const router = builder.router({ ping, nested: { ping } })
|
|
62
|
-
|
|
63
|
-
expectTypeOf(router).toEqualTypeOf<{
|
|
64
|
-
ping: typeof decorated
|
|
65
|
-
nested: { ping: typeof decorated }
|
|
66
|
-
}>()
|
|
67
|
-
|
|
68
|
-
expect(router.ping).instanceOf(DecoratedContractProcedure)
|
|
69
|
-
expect(router.nested.ping).instanceOf(DecoratedContractProcedure)
|
|
70
|
-
})
|
package/src/router-builder.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { ContractRouter, HandledContractRouter } from './router'
|
|
2
|
-
import type { HTTPPath } from './types'
|
|
3
|
-
import { DecoratedContractProcedure, isContractProcedure } from './procedure'
|
|
4
|
-
|
|
5
|
-
export class ContractRouterBuilder {
|
|
6
|
-
constructor(public zz$crb: { prefix?: HTTPPath, tags?: string[] }) {}
|
|
7
|
-
|
|
8
|
-
prefix(prefix: HTTPPath): ContractRouterBuilder {
|
|
9
|
-
return new ContractRouterBuilder({
|
|
10
|
-
...this.zz$crb,
|
|
11
|
-
prefix: `${this.zz$crb.prefix ?? ''}${prefix}`,
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
tags(...tags: string[]): ContractRouterBuilder {
|
|
16
|
-
if (!tags.length)
|
|
17
|
-
return this
|
|
18
|
-
|
|
19
|
-
return new ContractRouterBuilder({
|
|
20
|
-
...this.zz$crb,
|
|
21
|
-
tags: [...(this.zz$crb.tags ?? []), ...tags],
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
router<T extends ContractRouter>(router: T): HandledContractRouter<T> {
|
|
26
|
-
const handled: ContractRouter = {}
|
|
27
|
-
|
|
28
|
-
for (const key in router) {
|
|
29
|
-
const item = router[key]
|
|
30
|
-
if (isContractProcedure(item)) {
|
|
31
|
-
const decorated = DecoratedContractProcedure.decorate(item).addTags(
|
|
32
|
-
...(this.zz$crb.tags ?? []),
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
handled[key] = this.zz$crb.prefix
|
|
36
|
-
? decorated.prefix(this.zz$crb.prefix)
|
|
37
|
-
: decorated
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
handled[key] = this.router(item as ContractRouter)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return handled as HandledContractRouter<T>
|
|
45
|
-
}
|
|
46
|
-
}
|
package/src/router.test-d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { InferContractRouterInputs, InferContractRouterOutputs } from '.'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
import { oc } from '.'
|
|
4
|
-
|
|
5
|
-
const router = {
|
|
6
|
-
ping: oc.route({
|
|
7
|
-
method: 'GET',
|
|
8
|
-
path: '/ping',
|
|
9
|
-
})
|
|
10
|
-
.input(z.object({
|
|
11
|
-
ping: z.string().transform(() => 1),
|
|
12
|
-
}))
|
|
13
|
-
.output(z.object({
|
|
14
|
-
pong: z.string().transform(() => 1),
|
|
15
|
-
})),
|
|
16
|
-
user: {
|
|
17
|
-
find: oc.route({
|
|
18
|
-
method: 'GET',
|
|
19
|
-
path: '/users/{id}',
|
|
20
|
-
})
|
|
21
|
-
.input(z.object({
|
|
22
|
-
find: z.number().transform(() => '1'),
|
|
23
|
-
}))
|
|
24
|
-
.output(z.object({
|
|
25
|
-
user: z.object({
|
|
26
|
-
id: z.number().transform(() => '1'),
|
|
27
|
-
}),
|
|
28
|
-
}))
|
|
29
|
-
,
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
it('InferContractRouterInputs', () => {
|
|
34
|
-
type Inputs = InferContractRouterInputs<typeof router>
|
|
35
|
-
|
|
36
|
-
expectTypeOf<Inputs>().toEqualTypeOf<{
|
|
37
|
-
ping: {
|
|
38
|
-
ping: string
|
|
39
|
-
}
|
|
40
|
-
user: {
|
|
41
|
-
find: {
|
|
42
|
-
find: number
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}>()
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('InferContractRouterOutputs', () => {
|
|
49
|
-
type Outputs = InferContractRouterOutputs<typeof router>
|
|
50
|
-
|
|
51
|
-
expectTypeOf<Outputs>().toEqualTypeOf<{
|
|
52
|
-
ping: {
|
|
53
|
-
pong: number
|
|
54
|
-
}
|
|
55
|
-
user: {
|
|
56
|
-
find: {
|
|
57
|
-
user: {
|
|
58
|
-
id: string
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}>()
|
|
63
|
-
})
|
package/src/router.test.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { eachContractRouterLeaf, oc } from '.'
|
|
2
|
-
|
|
3
|
-
it('each router leaf', () => {
|
|
4
|
-
const router = {
|
|
5
|
-
ping: oc.route({
|
|
6
|
-
method: 'GET',
|
|
7
|
-
path: '/ping',
|
|
8
|
-
}),
|
|
9
|
-
user: {
|
|
10
|
-
find: oc.route({
|
|
11
|
-
method: 'GET',
|
|
12
|
-
path: '/users/{id}',
|
|
13
|
-
}),
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const calls: string[] = []
|
|
18
|
-
|
|
19
|
-
eachContractRouterLeaf(router, (procedure, path) => {
|
|
20
|
-
calls.push(path.join('.'))
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
expect(calls).toEqual(['ping', 'user.find'])
|
|
24
|
-
})
|
package/src/router.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { SchemaInput, SchemaOutput } from './types'
|
|
2
|
-
import {
|
|
3
|
-
type ContractProcedure,
|
|
4
|
-
type DecoratedContractProcedure,
|
|
5
|
-
isContractProcedure,
|
|
6
|
-
type WELL_DEFINED_CONTRACT_PROCEDURE,
|
|
7
|
-
} from './procedure'
|
|
8
|
-
|
|
9
|
-
export interface ContractRouter {
|
|
10
|
-
[k: string]: ContractProcedure<any, any> | ContractRouter
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type HandledContractRouter<TContract extends ContractRouter> = {
|
|
14
|
-
[K in keyof TContract]: TContract[K] extends ContractProcedure<
|
|
15
|
-
infer UInputSchema,
|
|
16
|
-
infer UOutputSchema
|
|
17
|
-
>
|
|
18
|
-
? DecoratedContractProcedure<UInputSchema, UOutputSchema>
|
|
19
|
-
: TContract[K] extends ContractRouter
|
|
20
|
-
? HandledContractRouter<TContract[K]>
|
|
21
|
-
: never
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function eachContractRouterLeaf(
|
|
25
|
-
router: ContractRouter,
|
|
26
|
-
callback: (item: WELL_DEFINED_CONTRACT_PROCEDURE, path: string[]) => void,
|
|
27
|
-
prefix: string[] = [],
|
|
28
|
-
) {
|
|
29
|
-
for (const key in router) {
|
|
30
|
-
const item = router[key]
|
|
31
|
-
|
|
32
|
-
if (isContractProcedure(item)) {
|
|
33
|
-
callback(item, [...prefix, key])
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
eachContractRouterLeaf(item as ContractRouter, callback, [...prefix, key])
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type InferContractRouterInputs<T extends ContractRouter> = {
|
|
42
|
-
[K in keyof T]: T[K] extends ContractProcedure<infer UInputSchema, any>
|
|
43
|
-
? SchemaInput<UInputSchema>
|
|
44
|
-
: T[K] extends ContractRouter
|
|
45
|
-
? InferContractRouterInputs<T[K]>
|
|
46
|
-
: never
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export type InferContractRouterOutputs<T extends ContractRouter> = {
|
|
50
|
-
[K in keyof T]: T[K] extends ContractProcedure<any, infer UOutputSchema>
|
|
51
|
-
? SchemaOutput<UOutputSchema>
|
|
52
|
-
: T[K] extends ContractRouter
|
|
53
|
-
? InferContractRouterOutputs<T[K]>
|
|
54
|
-
: never
|
|
55
|
-
}
|
package/src/types.test-d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { SchemaInput, SchemaOutput } from './types'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
test('SchemaInput', () => {
|
|
5
|
-
const schema = z.string()
|
|
6
|
-
|
|
7
|
-
expectTypeOf<SchemaInput<undefined>>().toEqualTypeOf<unknown>()
|
|
8
|
-
expectTypeOf<SchemaInput<typeof schema>>().toEqualTypeOf<string>()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
test('SchemaOutput', () => {
|
|
12
|
-
const schema = z.string().transform(v => Number.parseFloat(v))
|
|
13
|
-
|
|
14
|
-
expectTypeOf<SchemaOutput<undefined>>().toEqualTypeOf<unknown>()
|
|
15
|
-
expectTypeOf<SchemaOutput<typeof schema>>().toEqualTypeOf<number>()
|
|
16
|
-
})
|
package/src/types.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { input, output, ZodType } from 'zod'
|
|
2
|
-
|
|
3
|
-
export type HTTPPath = `/${string}`
|
|
4
|
-
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
|
|
5
|
-
export type HTTPStatus = number
|
|
6
|
-
|
|
7
|
-
export type Schema = ZodType<any, any, any> | undefined
|
|
8
|
-
|
|
9
|
-
export type SchemaInput<
|
|
10
|
-
TSchema extends Schema,
|
|
11
|
-
TFallback = unknown,
|
|
12
|
-
> = TSchema extends undefined
|
|
13
|
-
? TFallback
|
|
14
|
-
: TSchema extends ZodType<any, any, any>
|
|
15
|
-
? input<TSchema>
|
|
16
|
-
: TFallback
|
|
17
|
-
|
|
18
|
-
export type SchemaOutput<
|
|
19
|
-
TSchema extends Schema,
|
|
20
|
-
TFallback = unknown,
|
|
21
|
-
> = TSchema extends undefined
|
|
22
|
-
? TFallback
|
|
23
|
-
: TSchema extends ZodType<any, any, any>
|
|
24
|
-
? output<TSchema>
|
|
25
|
-
: TFallback
|
package/src/utils.test.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { prefixHTTPPath, standardizeHTTPPath } from './utils'
|
|
2
|
-
|
|
3
|
-
it('standardizeHTTPPath', () => {
|
|
4
|
-
expect(standardizeHTTPPath('/abc')).toBe('/abc')
|
|
5
|
-
expect(standardizeHTTPPath('/abc/')).toBe('/abc')
|
|
6
|
-
expect(standardizeHTTPPath('/abc//')).toBe('/abc')
|
|
7
|
-
expect(standardizeHTTPPath('//abc//')).toBe('/abc')
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
it('prefixHTTPPath', () => {
|
|
11
|
-
expect(prefixHTTPPath('/', '/abc')).toBe('/abc')
|
|
12
|
-
expect(prefixHTTPPath('/', '/abc/')).toBe('/abc')
|
|
13
|
-
expect(prefixHTTPPath('/', '/abc//')).toBe('/abc')
|
|
14
|
-
expect(prefixHTTPPath('/', '//abc//')).toBe('/abc')
|
|
15
|
-
expect(prefixHTTPPath('/abc', '/abc')).toBe('/abc/abc')
|
|
16
|
-
expect(prefixHTTPPath('/abc', '/abc/')).toBe('/abc/abc')
|
|
17
|
-
expect(prefixHTTPPath('/abc', '/abc//')).toBe('/abc/abc')
|
|
18
|
-
})
|
package/src/utils.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { HTTPPath } from './types'
|
|
2
|
-
|
|
3
|
-
export function standardizeHTTPPath(path: HTTPPath): HTTPPath {
|
|
4
|
-
return `/${path.replace(/\/{2,}/g, '/').replace(/^\/|\/$/g, '')}`
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function prefixHTTPPath(prefix: HTTPPath, path: HTTPPath): HTTPPath {
|
|
8
|
-
const prefix_ = standardizeHTTPPath(prefix)
|
|
9
|
-
const path_ = standardizeHTTPPath(path)
|
|
10
|
-
|
|
11
|
-
if (prefix_ === '/')
|
|
12
|
-
return path_
|
|
13
|
-
if (path_ === '/')
|
|
14
|
-
return prefix_
|
|
15
|
-
|
|
16
|
-
return `${prefix_}${path_}`
|
|
17
|
-
}
|