@orpc/nest 0.0.0-next.e710b76 → 0.0.0-next.e82d760

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.d.mts CHANGED
@@ -1,17 +1,9 @@
1
- import { DynamicModule, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
- import { AnySchema, ContractRouter, HTTPPath, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
- import { CreateProcedureClientOptions, Router } from '@orpc/server';
4
- export { ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ORPCError, ProcedureImplementer, RouterImplementer, RouterImplementerWithMiddlewares, implement, onError, onFinish, onStart, onSuccess } from '@orpc/server';
1
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
+ import { ContractRouter, HTTPPath, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
+ import { Router } from '@orpc/server';
4
+ export { ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ORPCError, ProcedureImplementer, RouterImplementer, RouterImplementerWithMiddlewares, implement } from '@orpc/server';
5
5
  import { Promisable } from '@orpc/shared';
6
6
  import { Observable } from 'rxjs';
7
- import { SendStandardResponseOptions } from '@orpc/standard-server-node';
8
-
9
- declare const ORPC_MODULE_CONFIG_SYMBOL: unique symbol;
10
- interface ORPCModuleConfig extends CreateProcedureClientOptions<object, AnySchema, object, object, object>, SendStandardResponseOptions {
11
- }
12
- declare class ORPCModule {
13
- static forRoot(config: ORPCModuleConfig): DynamicModule;
14
- }
15
7
 
16
8
  /**
17
9
  * Decorator in controller handler to implement a oRPC contract.
@@ -20,8 +12,6 @@ declare class ORPCModule {
20
12
  */
21
13
  declare function Implement<T extends ContractRouter<any>>(contract: T): <U extends Promisable<Router<T, Record<never, never>>>>(target: Record<PropertyKey, any>, propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => U>) => void;
22
14
  declare class ImplementInterceptor implements NestInterceptor {
23
- private readonly config;
24
- constructor(config: ORPCModuleConfig | undefined);
25
15
  intercept(ctx: ExecutionContext, next: CallHandler<any>): Observable<any>;
26
16
  }
27
17
 
@@ -42,5 +32,5 @@ interface PopulateContractRouterPathsOptions {
42
32
  */
43
33
  declare function populateContractRouterPaths<T extends AnyContractRouter>(router: T, options?: PopulateContractRouterPathsOptions): PopulatedContractRouterPaths<T>;
44
34
 
45
- export { Implement as Impl, Implement, ImplementInterceptor, ORPCModule, ORPC_MODULE_CONFIG_SYMBOL, populateContractRouterPaths, toNestPattern };
46
- export type { ORPCModuleConfig, PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };
35
+ export { Implement as Impl, Implement, ImplementInterceptor, populateContractRouterPaths, toNestPattern };
36
+ export type { PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,9 @@
1
- import { DynamicModule, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
- import { AnySchema, ContractRouter, HTTPPath, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
- import { CreateProcedureClientOptions, Router } from '@orpc/server';
4
- export { ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ORPCError, ProcedureImplementer, RouterImplementer, RouterImplementerWithMiddlewares, implement, onError, onFinish, onStart, onSuccess } from '@orpc/server';
1
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
+ import { ContractRouter, HTTPPath, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
+ import { Router } from '@orpc/server';
4
+ export { ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ORPCError, ProcedureImplementer, RouterImplementer, RouterImplementerWithMiddlewares, implement } from '@orpc/server';
5
5
  import { Promisable } from '@orpc/shared';
6
6
  import { Observable } from 'rxjs';
7
- import { SendStandardResponseOptions } from '@orpc/standard-server-node';
8
-
9
- declare const ORPC_MODULE_CONFIG_SYMBOL: unique symbol;
10
- interface ORPCModuleConfig extends CreateProcedureClientOptions<object, AnySchema, object, object, object>, SendStandardResponseOptions {
11
- }
12
- declare class ORPCModule {
13
- static forRoot(config: ORPCModuleConfig): DynamicModule;
14
- }
15
7
 
16
8
  /**
17
9
  * Decorator in controller handler to implement a oRPC contract.
@@ -20,8 +12,6 @@ declare class ORPCModule {
20
12
  */
21
13
  declare function Implement<T extends ContractRouter<any>>(contract: T): <U extends Promisable<Router<T, Record<never, never>>>>(target: Record<PropertyKey, any>, propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => U>) => void;
22
14
  declare class ImplementInterceptor implements NestInterceptor {
23
- private readonly config;
24
- constructor(config: ORPCModuleConfig | undefined);
25
15
  intercept(ctx: ExecutionContext, next: CallHandler<any>): Observable<any>;
26
16
  }
27
17
 
@@ -42,5 +32,5 @@ interface PopulateContractRouterPathsOptions {
42
32
  */
43
33
  declare function populateContractRouterPaths<T extends AnyContractRouter>(router: T, options?: PopulateContractRouterPathsOptions): PopulatedContractRouterPaths<T>;
44
34
 
45
- export { Implement as Impl, Implement, ImplementInterceptor, ORPCModule, ORPC_MODULE_CONFIG_SYMBOL, populateContractRouterPaths, toNestPattern };
46
- export type { ORPCModuleConfig, PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };
35
+ export { Implement as Impl, Implement, ImplementInterceptor, populateContractRouterPaths, toNestPattern };
36
+ export type { PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };
package/dist/index.mjs CHANGED
@@ -1,45 +1,16 @@
1
- import { Module, Injectable, Inject, Optional, applyDecorators, Delete, Patch, Put, Post, Get, Head, UseInterceptors } from '@nestjs/common';
1
+ import { applyDecorators, Delete, Patch, Put, Post, Get, Head, UseInterceptors } from '@nestjs/common';
2
2
  import { toORPCError } from '@orpc/client';
3
3
  import { isContractProcedure, ContractProcedure, fallbackContractConfig } from '@orpc/contract';
4
4
  import { standardizeHTTPPath, StandardOpenAPISerializer, StandardOpenAPIJsonSerializer, StandardBracketNotationSerializer } from '@orpc/openapi-client/standard';
5
5
  import { StandardOpenAPICodec } from '@orpc/openapi/standard';
6
6
  import { getRouter, unlazy, isProcedure, createProcedureClient, ORPCError } from '@orpc/server';
7
- export { ORPCError, implement, onError, onFinish, onStart, onSuccess } from '@orpc/server';
7
+ export { ORPCError, implement } from '@orpc/server';
8
8
  import { toArray, get } from '@orpc/shared';
9
9
  import { flattenHeader } from '@orpc/standard-server';
10
10
  import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
11
11
  import { mergeMap } from 'rxjs';
12
12
  import { toHttpPath } from '@orpc/client/standard';
13
13
 
14
- var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
15
- var __decorateClass$1 = (decorators, target, key, kind) => {
16
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
17
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
18
- if (decorator = decorators[i])
19
- result = (decorator(result)) || result;
20
- return result;
21
- };
22
- const ORPC_MODULE_CONFIG_SYMBOL = Symbol("ORPC_MODULE_CONFIG");
23
- let ORPCModule = class {
24
- static forRoot(config) {
25
- return {
26
- module: ORPCModule,
27
- providers: [
28
- {
29
- provide: ORPC_MODULE_CONFIG_SYMBOL,
30
- useValue: config
31
- },
32
- ImplementInterceptor
33
- ],
34
- exports: [ORPC_MODULE_CONFIG_SYMBOL, ImplementInterceptor],
35
- global: true
36
- };
37
- }
38
- };
39
- ORPCModule = __decorateClass$1([
40
- Module({})
41
- ], ORPCModule);
42
-
43
14
  function toNestPattern(path) {
44
15
  return standardizeHTTPPath(path).replace(/\/\{\+([^}]+)\}/g, "/*$1").replace(/\/\{([^}]+)\}/g, "/:$1");
45
16
  }
@@ -64,15 +35,6 @@ function populateContractRouterPaths(router, options = {}) {
64
35
  return populated;
65
36
  }
66
37
 
67
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
68
- var __decorateClass = (decorators, target, key, kind) => {
69
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
70
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
71
- if (decorator = decorators[i])
72
- result = (decorator(result)) || result;
73
- return result;
74
- };
75
- var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
76
38
  const MethodDecoratorMap = {
77
39
  HEAD: Head,
78
40
  GET: Get,
@@ -126,10 +88,7 @@ const codec = new StandardOpenAPICodec(
126
88
  new StandardBracketNotationSerializer()
127
89
  )
128
90
  );
129
- let ImplementInterceptor = class {
130
- constructor(config) {
131
- this.config = config;
132
- }
91
+ class ImplementInterceptor {
133
92
  intercept(ctx, next) {
134
93
  return next.handle().pipe(
135
94
  mergeMap(async (impl) => {
@@ -149,7 +108,7 @@ let ImplementInterceptor = class {
149
108
  const standardResponse = await (async () => {
150
109
  let isDecoding = false;
151
110
  try {
152
- const client = createProcedureClient(procedure, this.config);
111
+ const client = createProcedureClient(procedure);
153
112
  isDecoding = true;
154
113
  const input = await codec.decode(standardRequest, flattenParams(req.params), procedure);
155
114
  isDecoding = false;
@@ -166,16 +125,11 @@ let ImplementInterceptor = class {
166
125
  return codec.encodeError(error);
167
126
  }
168
127
  })();
169
- await sendStandardResponse(nodeRes, standardResponse, this.config);
128
+ await sendStandardResponse(nodeRes, standardResponse);
170
129
  })
171
130
  );
172
131
  }
173
- };
174
- ImplementInterceptor = __decorateClass([
175
- Injectable(),
176
- __decorateParam(0, Inject(ORPC_MODULE_CONFIG_SYMBOL)),
177
- __decorateParam(0, Optional())
178
- ], ImplementInterceptor);
132
+ }
179
133
  function flattenParams(params) {
180
134
  const flatten = {};
181
135
  for (const [key, value] of Object.entries(params)) {
@@ -188,4 +142,4 @@ function flattenParams(params) {
188
142
  return flatten;
189
143
  }
190
144
 
191
- export { Implement as Impl, Implement, ImplementInterceptor, ORPCModule, ORPC_MODULE_CONFIG_SYMBOL, populateContractRouterPaths, toNestPattern };
145
+ export { Implement as Impl, Implement, ImplementInterceptor, populateContractRouterPaths, toNestPattern };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/nest",
3
3
  "type": "module",
4
- "version": "0.0.0-next.e710b76",
4
+ "version": "0.0.0-next.e82d760",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -39,14 +39,14 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@orpc/client": "0.0.0-next.e710b76",
43
- "@orpc/contract": "0.0.0-next.e710b76",
44
- "@orpc/openapi": "0.0.0-next.e710b76",
45
- "@orpc/openapi-client": "0.0.0-next.e710b76",
46
- "@orpc/shared": "0.0.0-next.e710b76",
47
- "@orpc/server": "0.0.0-next.e710b76",
48
- "@orpc/standard-server": "0.0.0-next.e710b76",
49
- "@orpc/standard-server-node": "0.0.0-next.e710b76"
42
+ "@orpc/client": "0.0.0-next.e82d760",
43
+ "@orpc/openapi": "0.0.0-next.e82d760",
44
+ "@orpc/contract": "0.0.0-next.e82d760",
45
+ "@orpc/openapi-client": "0.0.0-next.e82d760",
46
+ "@orpc/shared": "0.0.0-next.e82d760",
47
+ "@orpc/server": "0.0.0-next.e82d760",
48
+ "@orpc/standard-server": "0.0.0-next.e82d760",
49
+ "@orpc/standard-server-node": "0.0.0-next.e82d760"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@nestjs/common": "^11.1.0",