vovk 3.0.0-draft.217 → 3.0.0-draft.219

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.
@@ -30,7 +30,7 @@ const createRPC = (schema, segmentName, rpcModuleName, fetcher = fetcher_js_1.fe
30
30
  for (const [staticMethodName, handlerSchema] of Object.entries(controllerSchema.handlers ?? {})) {
31
31
  const { path, httpMethod, validation } = handlerSchema;
32
32
  const getEndpoint = ({ apiRoot, params, query, }) => {
33
- apiRoot ??= options?.apiRoot ?? '/api';
33
+ apiRoot = controllerSchema.forceApiRoot ?? apiRoot ?? options?.apiRoot ?? '/api';
34
34
  const endpoint = [
35
35
  apiRoot.startsWith('http://') || apiRoot.startsWith('https://') || apiRoot.startsWith('/') ? '' : '/',
36
36
  apiRoot,
@@ -124,7 +124,6 @@ function openAPIToVovkSchema({ apiRoot, source: { object: openAPIObject }, getMo
124
124
  $schema: types_1.VovkSchemaIdEnum.SEGMENT,
125
125
  emitSchema: true,
126
126
  segmentName: EXTENSIONS_SEGMENT_NAME,
127
- forceApiRoot,
128
127
  controllers: {},
129
128
  },
130
129
  },
@@ -154,6 +153,7 @@ function openAPIToVovkSchema({ apiRoot, source: { object: openAPIObject }, getMo
154
153
  operationObject: operation,
155
154
  });
156
155
  segment.controllers[rpcModuleName] ??= {
156
+ forceApiRoot,
157
157
  rpcModuleName,
158
158
  handlers: {},
159
159
  };
package/cjs/types.d.ts CHANGED
@@ -22,6 +22,7 @@ export type VovkControllerSchema<T = KnownAny> = {
22
22
  rpcModuleName: string;
23
23
  originalControllerName?: string;
24
24
  prefix?: string;
25
+ forceApiRoot?: string;
25
26
  handlers: Record<string, VovkHandlerSchema<T>>;
26
27
  };
27
28
  export type VovkSegmentSchema<T = KnownAny> = {
@@ -13,16 +13,7 @@ type CallerInput = {
13
13
  handlerName: string;
14
14
  rpcModuleName: string;
15
15
  };
16
- declare function defaultCaller({ handler, body, query, params, }: {
17
- handler: ((...args: KnownAny[]) => KnownAny) & {
18
- fn?: (req: KnownAny) => KnownAny;
19
- isRPC?: boolean;
20
- };
21
- body: KnownAny;
22
- query: KnownAny;
23
- params: KnownAny;
24
- schema: VovkHandlerSchema;
25
- }, _options: KnownAny): Promise<any>;
16
+ declare function defaultCaller({ handler, body, query, params }: CallerInput, _options: KnownAny): Promise<any>;
26
17
  export declare function createLLMFunctions({ modules, caller, onExecute, onError, }: {
27
18
  modules: Record<string, unknown>;
28
19
  caller?: typeof defaultCaller;
@@ -62,7 +62,7 @@ const createLLMFunction = ({ rpcModuleName, handlerName, caller, modules, onExec
62
62
  : {}),
63
63
  };
64
64
  };
65
- async function defaultCaller({ handler, body, query, params, },
65
+ async function defaultCaller({ handler, body, query, params },
66
66
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
67
67
  _options) {
68
68
  if (handler.isRPC) {
@@ -30,7 +30,7 @@ const createRPC = (schema, segmentName, rpcModuleName, fetcher = fetcher_js_1.fe
30
30
  for (const [staticMethodName, handlerSchema] of Object.entries(controllerSchema.handlers ?? {})) {
31
31
  const { path, httpMethod, validation } = handlerSchema;
32
32
  const getEndpoint = ({ apiRoot, params, query, }) => {
33
- apiRoot ??= options?.apiRoot ?? '/api';
33
+ apiRoot = controllerSchema.forceApiRoot ?? apiRoot ?? options?.apiRoot ?? '/api';
34
34
  const endpoint = [
35
35
  apiRoot.startsWith('http://') || apiRoot.startsWith('https://') || apiRoot.startsWith('/') ? '' : '/',
36
36
  apiRoot,
@@ -124,7 +124,6 @@ function openAPIToVovkSchema({ apiRoot, source: { object: openAPIObject }, getMo
124
124
  $schema: types_1.VovkSchemaIdEnum.SEGMENT,
125
125
  emitSchema: true,
126
126
  segmentName: EXTENSIONS_SEGMENT_NAME,
127
- forceApiRoot,
128
127
  controllers: {},
129
128
  },
130
129
  },
@@ -154,6 +153,7 @@ function openAPIToVovkSchema({ apiRoot, source: { object: openAPIObject }, getMo
154
153
  operationObject: operation,
155
154
  });
156
155
  segment.controllers[rpcModuleName] ??= {
156
+ forceApiRoot,
157
157
  rpcModuleName,
158
158
  handlers: {},
159
159
  };
package/mjs/types.d.ts CHANGED
@@ -22,6 +22,7 @@ export type VovkControllerSchema<T = KnownAny> = {
22
22
  rpcModuleName: string;
23
23
  originalControllerName?: string;
24
24
  prefix?: string;
25
+ forceApiRoot?: string;
25
26
  handlers: Record<string, VovkHandlerSchema<T>>;
26
27
  };
27
28
  export type VovkSegmentSchema<T = KnownAny> = {
@@ -13,16 +13,7 @@ type CallerInput = {
13
13
  handlerName: string;
14
14
  rpcModuleName: string;
15
15
  };
16
- declare function defaultCaller({ handler, body, query, params, }: {
17
- handler: ((...args: KnownAny[]) => KnownAny) & {
18
- fn?: (req: KnownAny) => KnownAny;
19
- isRPC?: boolean;
20
- };
21
- body: KnownAny;
22
- query: KnownAny;
23
- params: KnownAny;
24
- schema: VovkHandlerSchema;
25
- }, _options: KnownAny): Promise<any>;
16
+ declare function defaultCaller({ handler, body, query, params }: CallerInput, _options: KnownAny): Promise<any>;
26
17
  export declare function createLLMFunctions({ modules, caller, onExecute, onError, }: {
27
18
  modules: Record<string, unknown>;
28
19
  caller?: typeof defaultCaller;
@@ -62,7 +62,7 @@ const createLLMFunction = ({ rpcModuleName, handlerName, caller, modules, onExec
62
62
  : {}),
63
63
  };
64
64
  };
65
- async function defaultCaller({ handler, body, query, params, },
65
+ async function defaultCaller({ handler, body, query, params },
66
66
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
67
67
  _options) {
68
68
  if (handler.isRPC) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.217",
3
+ "version": "3.0.0-draft.219",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",