vovk 3.0.0-draft.443 → 3.0.0-draft.445

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.
@@ -24,10 +24,16 @@ const createRPC = (givenSchema, segmentName, rpcModuleName, givenFetcher, option
24
24
  const segmentSchema = schema.segments[segmentName];
25
25
  if (!segmentSchema)
26
26
  throw new Error(`Unable to create RPC module. Segment schema is missing for segment "${segmentName}".`);
27
- const controllerSchema = schema.segments[segmentName]?.controllers[rpcModuleName];
27
+ let controllerSchema = schema.segments[segmentName]?.controllers[rpcModuleName];
28
28
  const client = {};
29
29
  if (!controllerSchema) {
30
- throw new Error(`Unable to create RPC module. Controller schema is missing for module "${rpcModuleName}" from segment "${segmentName}".`);
30
+ // eslint-disable-next-line no-console
31
+ console.warn(`Unable to create RPC module. Controller schema is missing for module "${rpcModuleName}" from segment "${segmentName}". Assuming that schema is not ready yet.`);
32
+ controllerSchema = {
33
+ rpcModuleName,
34
+ prefix: '',
35
+ handlers: {},
36
+ };
31
37
  }
32
38
  const controllerPrefix = trimPath(controllerSchema.prefix ?? '');
33
39
  const forceApiRoot = controllerSchema.forceApiRoot ?? segmentSchema.forceApiRoot;
package/cjs/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createVovkApp } from './createVovkApp';
2
- import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkGeneratorConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject } from './types';
2
+ import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkGeneratorConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkPackageJson, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject } from './types';
3
3
  import { type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkValidateOnClient, type VovkStreamAsyncIterable, createRPC, fetcher, createFetcher, progressive } from './client';
4
4
  import { operation, openAPIToVovkSchema, vovkSchemaToOpenAPI } from './openapi';
5
5
  import { HttpException } from './HttpException';
@@ -13,7 +13,7 @@ import { createLLMTools } from './utils/createLLMTools';
13
13
  import { createCodeSamples } from './utils/createCodeSamples';
14
14
  import { createValidateOnClient } from './utils/createValidateOnClient';
15
15
  import { resolveGeneratorConfigValues } from './utils/resolveGeneratorConfigValues';
16
- export { type KnownAny, type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type VovkGeneratorConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject, VovkSchemaIdEnum, JSONLinesResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, fetcher, createFetcher, generateStaticAPI, withValidationLibrary, createStandardValidation, multitenant, createLLMTools, createCodeSamples, createValidateOnClient, progressive, operation, openAPIToVovkSchema, vovkSchemaToOpenAPI, resolveGeneratorConfigValues, };
16
+ export { type KnownAny, type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type VovkGeneratorConfig, type VovkPackageJson, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject, VovkSchemaIdEnum, JSONLinesResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, fetcher, createFetcher, generateStaticAPI, withValidationLibrary, createStandardValidation, multitenant, createLLMTools, createCodeSamples, createValidateOnClient, progressive, operation, openAPIToVovkSchema, vovkSchemaToOpenAPI, resolveGeneratorConfigValues, };
17
17
  export declare const get: {
18
18
  (givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
19
19
  auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
@@ -31,7 +31,7 @@ const statusDisplayText = {
31
31
  [types_1.HttpStatus.METHOD_NOT_ALLOWED]: 'Method Not Allowed',
32
32
  [types_1.HttpStatus.NOT_ACCEPTABLE]: 'Not Acceptable',
33
33
  [types_1.HttpStatus.PROXY_AUTHENTICATION_REQUIRED]: 'Proxy Authentication Required',
34
- [types_1.HttpStatus.TRequest_TIMEOUT]: 'Request Timeout',
34
+ [types_1.HttpStatus.REQUEST_TIMEOUT]: 'Request Timeout',
35
35
  [types_1.HttpStatus.CONFLICT]: 'Conflict',
36
36
  [types_1.HttpStatus.GONE]: 'Gone',
37
37
  [types_1.HttpStatus.LENGTH_REQUIRED]: 'Length Required',
@@ -39,7 +39,7 @@ const statusDisplayText = {
39
39
  [types_1.HttpStatus.PAYLOAD_TOO_LARGE]: 'Payload Too Large',
40
40
  [types_1.HttpStatus.URI_TOO_LONG]: 'URI Too Long',
41
41
  [types_1.HttpStatus.UNSUPPORTED_MEDIA_TYPE]: 'Unsupported Media Type',
42
- [types_1.HttpStatus.TRequestED_RANGE_NOT_SATISFIABLE]: 'Requested Range Not Satisfiable',
42
+ [types_1.HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE]: 'Requested Range Not Satisfiable',
43
43
  [types_1.HttpStatus.EXPECTATION_FAILED]: 'Expectation Failed',
44
44
  [types_1.HttpStatus.I_AM_A_TEAPOT]: 'I am a teapot',
45
45
  [types_1.HttpStatus.MISDIRECTED]: 'Misdirected',
package/cjs/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { VovkStreamAsyncIterable } from './client/types';
5
5
  import type { PackageJson } from 'type-fest';
6
6
  export type KnownAny = any;
7
7
  export type StaticClass = Function;
8
- type VovkPackageJson = PackageJson & {
8
+ export type VovkPackageJson = PackageJson & {
9
9
  rs_name?: string;
10
10
  py_name?: string;
11
11
  };
@@ -219,7 +219,7 @@ export declare enum HttpStatus {
219
219
  METHOD_NOT_ALLOWED = 405,
220
220
  NOT_ACCEPTABLE = 406,
221
221
  PROXY_AUTHENTICATION_REQUIRED = 407,
222
- TRequest_TIMEOUT = 408,
222
+ REQUEST_TIMEOUT = 408,
223
223
  CONFLICT = 409,
224
224
  GONE = 410,
225
225
  LENGTH_REQUIRED = 411,
@@ -227,7 +227,7 @@ export declare enum HttpStatus {
227
227
  PAYLOAD_TOO_LARGE = 413,
228
228
  URI_TOO_LONG = 414,
229
229
  UNSUPPORTED_MEDIA_TYPE = 415,
230
- TRequestED_RANGE_NOT_SATISFIABLE = 416,
230
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
231
231
  EXPECTATION_FAILED = 417,
232
232
  I_AM_A_TEAPOT = 418,
233
233
  MISDIRECTED = 421,
@@ -346,8 +346,10 @@ type BundleConfig = {
346
346
  requires?: Record<string, string>;
347
347
  prebundleOutDir?: string;
348
348
  keepPrebundleDir?: boolean;
349
- tsdownBuildOptions?: Parameters<typeof import('tsdown').build>[0];
350
- generatorConfig?: VovkGeneratorConfig;
349
+ tsdownBuildOptions?: Parameters<typeof import('tsdown') extends {
350
+ build: infer T;
351
+ } ? T : never>[0];
352
+ generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports>;
351
353
  } & ({
352
354
  excludeSegments?: never;
353
355
  includeSegments?: string[];
@@ -355,18 +357,23 @@ type BundleConfig = {
355
357
  excludeSegments?: string[];
356
358
  includeSegments?: never;
357
359
  });
358
- export interface VovkGeneratorConfig {
360
+ type GeneratorConfigImports = {
361
+ fetcher?: string | [string, string] | [string];
362
+ validateOnClient?: string | [string, string] | [string] | null;
363
+ createRPC?: string | [string, string] | [string];
364
+ };
365
+ type SegmentConfigImports = {
366
+ fetcher?: string | [string, string] | [string];
367
+ validateOnClient?: string | [string, string] | [string] | null;
368
+ };
369
+ export interface VovkGeneratorConfig<TImports extends GeneratorConfigImports = GeneratorConfigImports> {
359
370
  origin?: string | null;
360
371
  package?: VovkPackageJson;
361
372
  readme?: VovkReadmeConfig;
362
373
  samples?: VovkSamplesConfig;
363
374
  openAPIObject?: Partial<OpenAPIObject>;
364
375
  reExports?: Record<string, string>;
365
- imports?: {
366
- fetcher?: string | [string, string] | [string];
367
- validateOnClient?: string | [string, string] | [string] | null;
368
- createRPC?: string | [string, string] | [string];
369
- };
376
+ imports?: TImports;
370
377
  }
371
378
  export type ClientTemplateDef = {
372
379
  extends?: string;
@@ -374,7 +381,7 @@ export type ClientTemplateDef = {
374
381
  composedClient?: Omit<ClientConfigComposed, 'fromTemplates' | 'enabled'>;
375
382
  segmentedClient?: Omit<ClientConfigSegmented, 'fromTemplates' | 'enabled'>;
376
383
  requires?: Record<string, string>;
377
- generatorConfig?: VovkGeneratorConfig;
384
+ generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports>;
378
385
  };
379
386
  export type GetOpenAPINameFn = (config: {
380
387
  operationObject: VovkOperationObject;
@@ -406,7 +413,7 @@ export interface VovkOpenAPIMixinNormalized extends Omit<VovkOpenAPIMixin, 'sour
406
413
  getMethodName: GetOpenAPINameFn;
407
414
  getModuleName: GetOpenAPINameFn;
408
415
  }
409
- export interface VovkSegmentConfig extends VovkGeneratorConfig {
416
+ export interface VovkSegmentConfig extends VovkGeneratorConfig<SegmentConfigImports> {
410
417
  rootEntry?: string;
411
418
  segmentNameOverride?: string;
412
419
  openAPIMixin?: VovkOpenAPIMixin;
@@ -433,18 +440,18 @@ type VovkUserConfig = {
433
440
  controller?: string;
434
441
  [key: string]: string | undefined;
435
442
  };
436
- generatorConfig?: VovkGeneratorConfig & {
443
+ generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports> & {
437
444
  segments?: Record<string, VovkSegmentConfig>;
438
445
  };
439
446
  };
440
447
  export type VovkConfig = VovkUserConfig;
441
- export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'libs' | 'imports' | 'composedClient' | 'segmentedClient' | 'bundle' | 'extendClientWithOpenAPI' | 'generator'>> & {
448
+ export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'libs' | 'composedClient' | 'segmentedClient' | 'bundle'>> & {
442
449
  emitConfig: (keyof VovkStrictConfig | string)[];
443
450
  bundle: RequireAllExcept<NonNullable<VovkUserConfig['bundle']>, 'includeSegments' | 'excludeSegments'>;
444
451
  libs: Record<string, KnownAny>;
445
452
  composedClient: RequireFields<ClientConfigComposed, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
446
453
  segmentedClient: RequireFields<ClientConfigSegmented, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
447
- generatorConfig: VovkGeneratorConfig & {
454
+ generatorConfig: VovkGeneratorConfig<GeneratorConfigImports> & {
448
455
  segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
449
456
  openAPIMixin?: VovkOpenAPIMixinNormalized;
450
457
  }>;
package/cjs/types.js CHANGED
@@ -41,7 +41,7 @@ var HttpStatus;
41
41
  HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
42
42
  HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
43
43
  HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
44
- HttpStatus[HttpStatus["TRequest_TIMEOUT"] = 408] = "TRequest_TIMEOUT";
44
+ HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
45
45
  HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
46
46
  HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
47
47
  HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
@@ -49,7 +49,7 @@ var HttpStatus;
49
49
  HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
50
50
  HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
51
51
  HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
52
- HttpStatus[HttpStatus["TRequestED_RANGE_NOT_SATISFIABLE"] = 416] = "TRequestED_RANGE_NOT_SATISFIABLE";
52
+ HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
53
53
  HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
54
54
  HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
55
55
  HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
@@ -4,7 +4,7 @@ export declare function createStandardValidation({ toJSONSchema, }: {
4
4
  toJSONSchema: (model: KnownAny, meta: {
5
5
  type: VovkValidationType;
6
6
  }) => KnownAny;
7
- }): <T extends (req: REQ, params: TParams extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TParams> : Record<string, string>) => KnownAny, TBody extends StandardSchemaV1, TQuery extends StandardSchemaV1, TParams extends StandardSchemaV1, OUTPUT extends StandardSchemaV1, ITERATION extends StandardSchemaV1, REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TBody> : undefined, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TQuery> : undefined, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TParams> : undefined>, IS_FORM extends boolean = false>({ isForm, body, query, params, output, iteration, handle, disableServerSideValidation, skipSchemaEmission, validateEachIteration, operationObject, }: {
7
+ }): <T extends (req: REQ, params: TParams extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TParams> : Record<string, string>) => KnownAny, TBody extends StandardSchemaV1, TQuery extends StandardSchemaV1, TParams extends StandardSchemaV1, OUTPUT extends StandardSchemaV1, ITERATION extends StandardSchemaV1, REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : undefined, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : undefined, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : undefined>, IS_FORM extends boolean = false>({ isForm, body, query, params, output, iteration, handle, disableServerSideValidation, skipSchemaEmission, validateEachIteration, operationObject, }: {
8
8
  isForm?: IS_FORM;
9
9
  body?: TBody;
10
10
  query?: TQuery;
@@ -1,43 +1,4 @@
1
1
  "use strict";
2
- /*
3
- Function "multitenant" accepts an object with "requestUrl", "requestHost", "targetHost" and "overrides" properties.
4
- The requestHost parameter comes from request headers and should be used instead of the hostname in the requestUrl.
5
- The keys in overrides are subdomains relative to the "targetHost". They can include a dot to indicate lower-level
6
- subdomains, and can use square brackets to indicate wildcard values. The values are arrays of objects with "from"
7
- and "to" properties, which are strings indicating the override paths for Next.js.
8
-
9
- If a path matches a specific subdomain name (e.g., "/admin" matches the "admin" subdomain),
10
- the request will be redirected to that specific subdomain instead of being processed on the current subdomain.
11
-
12
- If a path ends with "_schema_", it will not be processed by any overrides and will be passed through as-is.
13
-
14
- Example:
15
-
16
- const { action, destination, message, subdomains } = multitenant({
17
- requestUrl: request.url,
18
- requestHost: request.headers.get('host'),
19
- targetHost: "localhost:3000",
20
- overrides: {
21
- "[customer_name].customer": [
22
- { from: "api", to: "api/customer" }, // API
23
- { from: "", to: "[customer_name]" } // UI
24
- ],
25
- "pro.[customer_name].customer": [
26
- { from: "api", to: "api/customer/pro" }, // API
27
- { from: "", to: "pro/[customer_name]" } // UI
28
- ],
29
- "admin": [
30
- { from: "api", to: "api/admin" }, // API
31
- { from: "", to: "admin" } // UI
32
- ],
33
- },
34
- });
35
-
36
- subdomains is a Record<string, string> | null where keys are subdomain names and values are their corresponding values. If non-wildcard subdomains are used, should be equal to null.
37
- action is one of "rewrite", "redirect", "notfound", or null.
38
- message is a string describing the action taken
39
- destination is a string URL to redirect or rewrite to, or null if no action is taken or "notfound"
40
- */
41
2
  Object.defineProperty(exports, "__esModule", { value: true });
42
3
  exports.multitenant = multitenant;
43
4
  // Get the reserved paths from the overrides configuration
@@ -24,10 +24,16 @@ const createRPC = (givenSchema, segmentName, rpcModuleName, givenFetcher, option
24
24
  const segmentSchema = schema.segments[segmentName];
25
25
  if (!segmentSchema)
26
26
  throw new Error(`Unable to create RPC module. Segment schema is missing for segment "${segmentName}".`);
27
- const controllerSchema = schema.segments[segmentName]?.controllers[rpcModuleName];
27
+ let controllerSchema = schema.segments[segmentName]?.controllers[rpcModuleName];
28
28
  const client = {};
29
29
  if (!controllerSchema) {
30
- throw new Error(`Unable to create RPC module. Controller schema is missing for module "${rpcModuleName}" from segment "${segmentName}".`);
30
+ // eslint-disable-next-line no-console
31
+ console.warn(`Unable to create RPC module. Controller schema is missing for module "${rpcModuleName}" from segment "${segmentName}". Assuming that schema is not ready yet.`);
32
+ controllerSchema = {
33
+ rpcModuleName,
34
+ prefix: '',
35
+ handlers: {},
36
+ };
31
37
  }
32
38
  const controllerPrefix = trimPath(controllerSchema.prefix ?? '');
33
39
  const forceApiRoot = controllerSchema.forceApiRoot ?? segmentSchema.forceApiRoot;
package/mjs/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createVovkApp } from './createVovkApp';
2
- import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkGeneratorConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject } from './types';
2
+ import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkGeneratorConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkPackageJson, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject } from './types';
3
3
  import { type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkValidateOnClient, type VovkStreamAsyncIterable, createRPC, fetcher, createFetcher, progressive } from './client';
4
4
  import { operation, openAPIToVovkSchema, vovkSchemaToOpenAPI } from './openapi';
5
5
  import { HttpException } from './HttpException';
@@ -13,7 +13,7 @@ import { createLLMTools } from './utils/createLLMTools';
13
13
  import { createCodeSamples } from './utils/createCodeSamples';
14
14
  import { createValidateOnClient } from './utils/createValidateOnClient';
15
15
  import { resolveGeneratorConfigValues } from './utils/resolveGeneratorConfigValues';
16
- export { type KnownAny, type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type VovkGeneratorConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject, VovkSchemaIdEnum, JSONLinesResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, fetcher, createFetcher, generateStaticAPI, withValidationLibrary, createStandardValidation, multitenant, createLLMTools, createCodeSamples, createValidateOnClient, progressive, operation, openAPIToVovkSchema, vovkSchemaToOpenAPI, resolveGeneratorConfigValues, };
16
+ export { type KnownAny, type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type VovkGeneratorConfig, type VovkPackageJson, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject, VovkSchemaIdEnum, JSONLinesResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, fetcher, createFetcher, generateStaticAPI, withValidationLibrary, createStandardValidation, multitenant, createLLMTools, createCodeSamples, createValidateOnClient, progressive, operation, openAPIToVovkSchema, vovkSchemaToOpenAPI, resolveGeneratorConfigValues, };
17
17
  export declare const get: {
18
18
  (givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
19
19
  auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
@@ -31,7 +31,7 @@ const statusDisplayText = {
31
31
  [types_1.HttpStatus.METHOD_NOT_ALLOWED]: 'Method Not Allowed',
32
32
  [types_1.HttpStatus.NOT_ACCEPTABLE]: 'Not Acceptable',
33
33
  [types_1.HttpStatus.PROXY_AUTHENTICATION_REQUIRED]: 'Proxy Authentication Required',
34
- [types_1.HttpStatus.TRequest_TIMEOUT]: 'Request Timeout',
34
+ [types_1.HttpStatus.REQUEST_TIMEOUT]: 'Request Timeout',
35
35
  [types_1.HttpStatus.CONFLICT]: 'Conflict',
36
36
  [types_1.HttpStatus.GONE]: 'Gone',
37
37
  [types_1.HttpStatus.LENGTH_REQUIRED]: 'Length Required',
@@ -39,7 +39,7 @@ const statusDisplayText = {
39
39
  [types_1.HttpStatus.PAYLOAD_TOO_LARGE]: 'Payload Too Large',
40
40
  [types_1.HttpStatus.URI_TOO_LONG]: 'URI Too Long',
41
41
  [types_1.HttpStatus.UNSUPPORTED_MEDIA_TYPE]: 'Unsupported Media Type',
42
- [types_1.HttpStatus.TRequestED_RANGE_NOT_SATISFIABLE]: 'Requested Range Not Satisfiable',
42
+ [types_1.HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE]: 'Requested Range Not Satisfiable',
43
43
  [types_1.HttpStatus.EXPECTATION_FAILED]: 'Expectation Failed',
44
44
  [types_1.HttpStatus.I_AM_A_TEAPOT]: 'I am a teapot',
45
45
  [types_1.HttpStatus.MISDIRECTED]: 'Misdirected',
package/mjs/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { VovkStreamAsyncIterable } from './client/types';
5
5
  import type { PackageJson } from 'type-fest';
6
6
  export type KnownAny = any;
7
7
  export type StaticClass = Function;
8
- type VovkPackageJson = PackageJson & {
8
+ export type VovkPackageJson = PackageJson & {
9
9
  rs_name?: string;
10
10
  py_name?: string;
11
11
  };
@@ -219,7 +219,7 @@ export declare enum HttpStatus {
219
219
  METHOD_NOT_ALLOWED = 405,
220
220
  NOT_ACCEPTABLE = 406,
221
221
  PROXY_AUTHENTICATION_REQUIRED = 407,
222
- TRequest_TIMEOUT = 408,
222
+ REQUEST_TIMEOUT = 408,
223
223
  CONFLICT = 409,
224
224
  GONE = 410,
225
225
  LENGTH_REQUIRED = 411,
@@ -227,7 +227,7 @@ export declare enum HttpStatus {
227
227
  PAYLOAD_TOO_LARGE = 413,
228
228
  URI_TOO_LONG = 414,
229
229
  UNSUPPORTED_MEDIA_TYPE = 415,
230
- TRequestED_RANGE_NOT_SATISFIABLE = 416,
230
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
231
231
  EXPECTATION_FAILED = 417,
232
232
  I_AM_A_TEAPOT = 418,
233
233
  MISDIRECTED = 421,
@@ -346,8 +346,10 @@ type BundleConfig = {
346
346
  requires?: Record<string, string>;
347
347
  prebundleOutDir?: string;
348
348
  keepPrebundleDir?: boolean;
349
- tsdownBuildOptions?: Parameters<typeof import('tsdown').build>[0];
350
- generatorConfig?: VovkGeneratorConfig;
349
+ tsdownBuildOptions?: Parameters<typeof import('tsdown') extends {
350
+ build: infer T;
351
+ } ? T : never>[0];
352
+ generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports>;
351
353
  } & ({
352
354
  excludeSegments?: never;
353
355
  includeSegments?: string[];
@@ -355,18 +357,23 @@ type BundleConfig = {
355
357
  excludeSegments?: string[];
356
358
  includeSegments?: never;
357
359
  });
358
- export interface VovkGeneratorConfig {
360
+ type GeneratorConfigImports = {
361
+ fetcher?: string | [string, string] | [string];
362
+ validateOnClient?: string | [string, string] | [string] | null;
363
+ createRPC?: string | [string, string] | [string];
364
+ };
365
+ type SegmentConfigImports = {
366
+ fetcher?: string | [string, string] | [string];
367
+ validateOnClient?: string | [string, string] | [string] | null;
368
+ };
369
+ export interface VovkGeneratorConfig<TImports extends GeneratorConfigImports = GeneratorConfigImports> {
359
370
  origin?: string | null;
360
371
  package?: VovkPackageJson;
361
372
  readme?: VovkReadmeConfig;
362
373
  samples?: VovkSamplesConfig;
363
374
  openAPIObject?: Partial<OpenAPIObject>;
364
375
  reExports?: Record<string, string>;
365
- imports?: {
366
- fetcher?: string | [string, string] | [string];
367
- validateOnClient?: string | [string, string] | [string] | null;
368
- createRPC?: string | [string, string] | [string];
369
- };
376
+ imports?: TImports;
370
377
  }
371
378
  export type ClientTemplateDef = {
372
379
  extends?: string;
@@ -374,7 +381,7 @@ export type ClientTemplateDef = {
374
381
  composedClient?: Omit<ClientConfigComposed, 'fromTemplates' | 'enabled'>;
375
382
  segmentedClient?: Omit<ClientConfigSegmented, 'fromTemplates' | 'enabled'>;
376
383
  requires?: Record<string, string>;
377
- generatorConfig?: VovkGeneratorConfig;
384
+ generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports>;
378
385
  };
379
386
  export type GetOpenAPINameFn = (config: {
380
387
  operationObject: VovkOperationObject;
@@ -406,7 +413,7 @@ export interface VovkOpenAPIMixinNormalized extends Omit<VovkOpenAPIMixin, 'sour
406
413
  getMethodName: GetOpenAPINameFn;
407
414
  getModuleName: GetOpenAPINameFn;
408
415
  }
409
- export interface VovkSegmentConfig extends VovkGeneratorConfig {
416
+ export interface VovkSegmentConfig extends VovkGeneratorConfig<SegmentConfigImports> {
410
417
  rootEntry?: string;
411
418
  segmentNameOverride?: string;
412
419
  openAPIMixin?: VovkOpenAPIMixin;
@@ -433,18 +440,18 @@ type VovkUserConfig = {
433
440
  controller?: string;
434
441
  [key: string]: string | undefined;
435
442
  };
436
- generatorConfig?: VovkGeneratorConfig & {
443
+ generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports> & {
437
444
  segments?: Record<string, VovkSegmentConfig>;
438
445
  };
439
446
  };
440
447
  export type VovkConfig = VovkUserConfig;
441
- export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'libs' | 'imports' | 'composedClient' | 'segmentedClient' | 'bundle' | 'extendClientWithOpenAPI' | 'generator'>> & {
448
+ export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'libs' | 'composedClient' | 'segmentedClient' | 'bundle'>> & {
442
449
  emitConfig: (keyof VovkStrictConfig | string)[];
443
450
  bundle: RequireAllExcept<NonNullable<VovkUserConfig['bundle']>, 'includeSegments' | 'excludeSegments'>;
444
451
  libs: Record<string, KnownAny>;
445
452
  composedClient: RequireFields<ClientConfigComposed, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
446
453
  segmentedClient: RequireFields<ClientConfigSegmented, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
447
- generatorConfig: VovkGeneratorConfig & {
454
+ generatorConfig: VovkGeneratorConfig<GeneratorConfigImports> & {
448
455
  segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
449
456
  openAPIMixin?: VovkOpenAPIMixinNormalized;
450
457
  }>;
package/mjs/types.js CHANGED
@@ -41,7 +41,7 @@ var HttpStatus;
41
41
  HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
42
42
  HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
43
43
  HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
44
- HttpStatus[HttpStatus["TRequest_TIMEOUT"] = 408] = "TRequest_TIMEOUT";
44
+ HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
45
45
  HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
46
46
  HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
47
47
  HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
@@ -49,7 +49,7 @@ var HttpStatus;
49
49
  HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
50
50
  HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
51
51
  HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
52
- HttpStatus[HttpStatus["TRequestED_RANGE_NOT_SATISFIABLE"] = 416] = "TRequestED_RANGE_NOT_SATISFIABLE";
52
+ HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
53
53
  HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
54
54
  HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
55
55
  HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
@@ -4,7 +4,7 @@ export declare function createStandardValidation({ toJSONSchema, }: {
4
4
  toJSONSchema: (model: KnownAny, meta: {
5
5
  type: VovkValidationType;
6
6
  }) => KnownAny;
7
- }): <T extends (req: REQ, params: TParams extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TParams> : Record<string, string>) => KnownAny, TBody extends StandardSchemaV1, TQuery extends StandardSchemaV1, TParams extends StandardSchemaV1, OUTPUT extends StandardSchemaV1, ITERATION extends StandardSchemaV1, REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TBody> : undefined, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TQuery> : undefined, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TParams> : undefined>, IS_FORM extends boolean = false>({ isForm, body, query, params, output, iteration, handle, disableServerSideValidation, skipSchemaEmission, validateEachIteration, operationObject, }: {
7
+ }): <T extends (req: REQ, params: TParams extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TParams> : Record<string, string>) => KnownAny, TBody extends StandardSchemaV1, TQuery extends StandardSchemaV1, TParams extends StandardSchemaV1, OUTPUT extends StandardSchemaV1, ITERATION extends StandardSchemaV1, REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : undefined, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : undefined, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : undefined>, IS_FORM extends boolean = false>({ isForm, body, query, params, output, iteration, handle, disableServerSideValidation, skipSchemaEmission, validateEachIteration, operationObject, }: {
8
8
  isForm?: IS_FORM;
9
9
  body?: TBody;
10
10
  query?: TQuery;
@@ -1,43 +1,4 @@
1
1
  "use strict";
2
- /*
3
- Function "multitenant" accepts an object with "requestUrl", "requestHost", "targetHost" and "overrides" properties.
4
- The requestHost parameter comes from request headers and should be used instead of the hostname in the requestUrl.
5
- The keys in overrides are subdomains relative to the "targetHost". They can include a dot to indicate lower-level
6
- subdomains, and can use square brackets to indicate wildcard values. The values are arrays of objects with "from"
7
- and "to" properties, which are strings indicating the override paths for Next.js.
8
-
9
- If a path matches a specific subdomain name (e.g., "/admin" matches the "admin" subdomain),
10
- the request will be redirected to that specific subdomain instead of being processed on the current subdomain.
11
-
12
- If a path ends with "_schema_", it will not be processed by any overrides and will be passed through as-is.
13
-
14
- Example:
15
-
16
- const { action, destination, message, subdomains } = multitenant({
17
- requestUrl: request.url,
18
- requestHost: request.headers.get('host'),
19
- targetHost: "localhost:3000",
20
- overrides: {
21
- "[customer_name].customer": [
22
- { from: "api", to: "api/customer" }, // API
23
- { from: "", to: "[customer_name]" } // UI
24
- ],
25
- "pro.[customer_name].customer": [
26
- { from: "api", to: "api/customer/pro" }, // API
27
- { from: "", to: "pro/[customer_name]" } // UI
28
- ],
29
- "admin": [
30
- { from: "api", to: "api/admin" }, // API
31
- { from: "", to: "admin" } // UI
32
- ],
33
- },
34
- });
35
-
36
- subdomains is a Record<string, string> | null where keys are subdomain names and values are their corresponding values. If non-wildcard subdomains are used, should be equal to null.
37
- action is one of "rewrite", "redirect", "notfound", or null.
38
- message is a string describing the action taken
39
- destination is a string URL to redirect or rewrite to, or null if no action is taken or "notfound"
40
- */
41
2
  Object.defineProperty(exports, "__esModule", { value: true });
42
3
  exports.multitenant = multitenant;
43
4
  // Get the reserved paths from the overrides configuration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.443",
3
+ "version": "3.0.0-draft.445",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",