@modern-js/bff-runtime 2.40.0 → 2.42.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.
@@ -1,7 +1,9 @@
1
1
  export type RequestOption<TQuery = never, TData = never> = ClearRecord<{
2
- query: TQuery;
3
- data: TData;
2
+ query: TQuery;
3
+ data: TData;
4
4
  }> & {
5
- dataType?: string;
5
+ dataType?: string;
6
+ };
7
+ export type ClearRecord<O extends Record<string, any>> = {
8
+ [K in keyof O as O[K] extends never ? never : K]: O[K];
6
9
  };
7
- export type ClearRecord<O extends Record<string, any>> = { [K in keyof O as O[K] extends never ? never : K]: O[K] };
@@ -2,5 +2,5 @@ export * from 'farrow-schema';
2
2
  export { match, isHandler, isSchemaHandler } from './match';
3
3
  export type { Handler, SchemaHandler } from './match';
4
4
  export type { RequestSchema, TypeOfRequestSchema, InputType } from './request';
5
- export type { HandleResult, HandleSuccess, InputValidationError, OutputValidationError } from './response';
6
- export type { RequestOption } from './compatible';
5
+ export type { HandleResult, HandleSuccess, InputValidationError, OutputValidationError, } from './response';
6
+ export type { RequestOption } from './compatible';
@@ -6,22 +6,22 @@ import { HandleResult } from './response';
6
6
  export type NormalHandler = (...args: any[]) => any;
7
7
  export type Handler<I, O> = (input: I) => MaybeAsync<O>;
8
8
  export type Schema<Req extends RequestSchema, Res extends SchemaCtorInput> = {
9
- request: Req;
10
- response: Res;
11
- description?: string;
12
- deprecated?: string;
9
+ request: Req;
10
+ response: Res;
11
+ description?: string;
12
+ deprecated?: string;
13
13
  };
14
14
  declare const HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
15
15
  export type BaseSchemaHandler<Req extends RequestSchema, Res extends SchemaCtorInput> = ((input: TypeOfRequestSchema<Req>) => Promise<HandleResult<TypeOfRouterRequestField<Res>>>) & {
16
- schema: Schema<Req, Res>;
17
- [HANDLER_WITH_SCHEMA]: true;
16
+ schema: Schema<Req, Res>;
17
+ [HANDLER_WITH_SCHEMA]: true;
18
18
  };
19
19
  export type SchemaHandler<Req extends RequestSchema, Res extends SchemaCtorInput> = ((input: TypeOfRequestSchema<Req>) => Promise<TypeOfRouterRequestField<Res>>) & {
20
- schema: Schema<Req, Res>;
21
- [HANDLER_WITH_SCHEMA]: true;
20
+ schema: Schema<Req, Res>;
21
+ [HANDLER_WITH_SCHEMA]: true;
22
22
  };
23
23
  export declare const isSchemaHandler: (input: any) => input is SchemaHandler<any, any>;
24
24
  export declare const isHandler: (input: any) => input is Handler<any, any>;
25
25
  export declare const baseMatch: <Req extends RequestSchema, Res extends SchemaCtorInput>(schema: Schema<Req, Res>, handler: Handler<TypeOfRequestSchema<Req>, TypeOfRouterRequestField<Res>>) => BaseSchemaHandler<Req, Res>;
26
26
  export declare const match: <Req extends RequestSchema, Res extends SchemaCtorInput>(schema: Schema<Req, Res>, handler: Handler<PureTypeOfRequestSchema<Req>, TypeOfRouterRequestField<Res>>) => SchemaHandler<Req, Res>;
27
- export {};
27
+ export {};
@@ -1,39 +1,47 @@
1
1
  import { TypeOfFieldDescriptor, TypeOfFieldDescriptors, FieldDescriptor, FieldDescriptors } from 'farrow-schema';
2
2
  import { MarkReadOnlyDeep, RouterSchemaDescriptor } from './types';
3
3
  export type RequestBaseSchema = {
4
- params?: RouterSchemaDescriptor;
5
- query?: RouterSchemaDescriptor;
6
- headers?: RouterSchemaDescriptor;
7
- cookies?: RouterSchemaDescriptor;
4
+ params?: RouterSchemaDescriptor;
5
+ query?: RouterSchemaDescriptor;
6
+ headers?: RouterSchemaDescriptor;
7
+ cookies?: RouterSchemaDescriptor;
8
8
  };
9
9
  export type RequestDataSchema = {
10
- data?: RouterSchemaDescriptor;
10
+ data?: RouterSchemaDescriptor;
11
11
  };
12
12
  export type RequestBodyType = {
13
- body?: string;
13
+ body?: string;
14
14
  };
15
15
  export type PureRequestFormDataType = {
16
- formData?: Record<string, any>;
16
+ formData?: Record<string, any>;
17
17
  };
18
18
  export type RequestFormDataType = {
19
- formData?: FormData;
19
+ formData?: FormData;
20
20
  };
21
21
  export type RequestFormUrlencodedType = {
22
- formUrlencoded?: URLSearchParams | Record<string, string> | string;
22
+ formUrlencoded?: URLSearchParams | Record<string, string> | string;
23
23
  };
24
24
  export type PureRequestFormUrlencodedType = {
25
- formUrlencoded?: Record<string, string>;
25
+ formUrlencoded?: Record<string, string>;
26
26
  };
27
27
  export type RequestExtraType = RequestBodyType & RequestFormDataType & RequestFormUrlencodedType;
28
28
  export type PureRequestExtraType = RequestBodyType & PureRequestFormDataType & PureRequestFormUrlencodedType;
29
29
  export type RequestSchema = RequestBaseSchema & RequestDataSchema;
30
30
  export type TypeOfRequestField<T> = T extends string ? string : T extends FormData ? FormData : T extends FieldDescriptor ? TypeOfFieldDescriptor<T> : T extends FieldDescriptors ? TypeOfFieldDescriptors<T> : never;
31
31
  export type TypeOfRequestDataSchema<T extends RequestDataSchema> = MarkReadOnlyDeep<T extends {
32
- data: any;
33
- } ? Pick<{ [key in keyof T]: TypeOfRequestField<T[key]> }, 'data'> : RequestExtraType>;
34
- export type TypeOfRequestSchema<T extends RequestSchema> = MarkReadOnlyDeep<Omit<{ [key in keyof T]: TypeOfRequestField<T[key]> }, 'data'> & TypeOfRequestDataSchema<T>>;
32
+ data: any;
33
+ } ? Pick<{
34
+ [key in keyof T]: TypeOfRequestField<T[key]>;
35
+ }, 'data'> : RequestExtraType>;
36
+ export type TypeOfRequestSchema<T extends RequestSchema> = MarkReadOnlyDeep<Omit<{
37
+ [key in keyof T]: TypeOfRequestField<T[key]>;
38
+ }, 'data'> & TypeOfRequestDataSchema<T>>;
35
39
  export type PureTypeOfRequestDataSchema<T extends RequestDataSchema> = MarkReadOnlyDeep<T extends {
36
- data: any;
37
- } ? Pick<{ [key in keyof T]: TypeOfRequestField<T[key]> }, 'data'> : PureRequestExtraType>;
38
- export type PureTypeOfRequestSchema<T extends RequestSchema> = MarkReadOnlyDeep<Omit<{ [key in keyof T]: TypeOfRequestField<T[key]> }, 'data'> & PureTypeOfRequestDataSchema<T>>;
39
- export type InputType = TypeOfRequestSchema<RequestSchema>;
40
+ data: any;
41
+ } ? Pick<{
42
+ [key in keyof T]: TypeOfRequestField<T[key]>;
43
+ }, 'data'> : PureRequestExtraType>;
44
+ export type PureTypeOfRequestSchema<T extends RequestSchema> = MarkReadOnlyDeep<Omit<{
45
+ [key in keyof T]: TypeOfRequestField<T[key]>;
46
+ }, 'data'> & PureTypeOfRequestDataSchema<T>>;
47
+ export type InputType = TypeOfRequestSchema<RequestSchema>;
@@ -1,16 +1,16 @@
1
1
  export type HandleSuccess<T> = {
2
- type: 'HandleSuccess';
3
- value: T;
2
+ type: 'HandleSuccess';
3
+ value: T;
4
4
  };
5
5
  export declare const HandleSuccess: <T>(output: T) => HandleSuccess<T>;
6
6
  export type InputValidationError = {
7
- type: 'InputValidationError';
8
- message: string;
7
+ type: 'InputValidationError';
8
+ message: string;
9
9
  };
10
10
  export declare const InputValidationError: (message: string) => InputValidationError;
11
11
  export type OutputValidationError = {
12
- type: 'OutputValidationError';
13
- message: string;
12
+ type: 'OutputValidationError';
13
+ message: string;
14
14
  };
15
15
  export declare const OutputValidationError: (message: string) => OutputValidationError;
16
- export type HandleResult<T> = HandleSuccess<T> | InputValidationError | OutputValidationError;
16
+ export type HandleResult<T> = HandleSuccess<T> | InputValidationError | OutputValidationError;
@@ -2,5 +2,7 @@ import * as Schema from 'farrow-schema';
2
2
  type Path = string | RegExp | Array<string | RegExp>;
3
3
  export type TypeOfRouterRequestField<T> = T extends string | string[] ? string : T extends Path ? string : T extends Schema.FieldDescriptor ? Schema.TypeOfFieldDescriptor<T> : T extends Schema.FieldDescriptors ? Schema.TypeOfFieldDescriptors<T> : never;
4
4
  export type RouterSchemaDescriptor = Schema.FieldDescriptors | (new () => Schema.ObjectType) | (new () => Schema.StructType);
5
- export type MarkReadOnlyDeep<T> = T extends {} | any[] ? { readonly [key in keyof T]: MarkReadOnlyDeep<T[key]> } : T;
6
- export {};
5
+ export type MarkReadOnlyDeep<T> = T extends {} | any[] ? {
6
+ readonly [key in keyof T]: MarkReadOnlyDeep<T[key]>;
7
+ } : T;
8
+ export {};
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.40.0",
18
+ "version": "2.42.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -34,7 +34,7 @@
34
34
  "farrow-api": "^1.10.8",
35
35
  "farrow-pipeline": "^1.10.6",
36
36
  "farrow-schema": "^1.10.8",
37
- "@swc/helpers": "0.5.1"
37
+ "@swc/helpers": "0.5.3"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/jest": "^29",
@@ -42,8 +42,8 @@
42
42
  "jest": "^29",
43
43
  "ts-jest": "^29.1.0",
44
44
  "typescript": "^5",
45
- "@scripts/build": "2.40.0",
46
- "@scripts/jest-config": "2.40.0"
45
+ "@scripts/build": "2.42.0",
46
+ "@scripts/jest-config": "2.42.0"
47
47
  },
48
48
  "publishConfig": {
49
49
  "registry": "https://registry.npmjs.org/",