zentao-api 0.5.4 → 0.6.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/browser/zentao-api.global.js +2 -2
- package/dist/modules/generated.d.ts +9540 -3955
- package/dist/modules/generated.js +4848 -702
- package/dist/modules/object-props.js +330 -0
- package/dist/modules/override.js +42 -0
- package/dist/modules/registry.d.ts +8836 -3955
- package/dist/request/index.d.ts +9 -87
- package/dist/version.js +2 -2
- package/package.json +1 -1
package/dist/request/index.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type { DataRecord, RequestOptions, ResponseData } from '../types/index.js';
|
|
2
|
-
import type {
|
|
3
|
-
type
|
|
4
|
-
type BuiltinModuleName = BuiltinModuleDefinition['name'];
|
|
5
|
-
type BuiltinAction<M extends BuiltinModuleName> = Extract<BuiltinModuleDefinition, {
|
|
6
|
-
name: M;
|
|
7
|
-
}>['actions'][number];
|
|
8
|
-
type BuiltinActionName<M extends BuiltinModuleName> = BuiltinAction<M>['name'] & string;
|
|
2
|
+
import type { BuiltinActionMeta, BuiltinModuleName } from '../modules/generated.js';
|
|
3
|
+
type BuiltinActionName<M extends BuiltinModuleName> = Extract<keyof BuiltinActionMeta[M], string>;
|
|
9
4
|
type BuiltinListRequestName = BuiltinModuleName;
|
|
10
5
|
type BuiltinNamedRequestName = {
|
|
11
6
|
[M in BuiltinModuleName]: `${M}/${BuiltinActionName<M>}`;
|
|
@@ -15,88 +10,15 @@ type BuiltinIdRequestName = `${BuiltinModuleName}/${number}`;
|
|
|
15
10
|
export type BuiltinRequestName = BuiltinListRequestName | BuiltinNamedRequestName | BuiltinIdRequestName;
|
|
16
11
|
type ModuleNameOf<Name extends BuiltinRequestName> = Name extends `${infer M}/${string}` ? Extract<M, BuiltinModuleName> : Extract<Name, BuiltinModuleName>;
|
|
17
12
|
type ActionNameOf<Name extends BuiltinRequestName> = Name extends `${string}/${infer A}` ? A extends `${number}` ? 'get' : A : 'list';
|
|
18
|
-
type
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type
|
|
23
|
-
type BooleanInput = boolean | 0 | 1 | 'true' | 'false' | '1' | '0' | 'yes' | 'no' | 'on' | 'off';
|
|
24
|
-
type OptionValue<T> = T extends readonly (infer Option)[] ? Option extends {
|
|
25
|
-
value: infer Value;
|
|
26
|
-
} ? Value : never : never;
|
|
27
|
-
type ParamInput<T> = (T extends {
|
|
28
|
-
options: infer Options;
|
|
29
|
-
} ? OptionValue<Options> : never) | (T extends {
|
|
30
|
-
type: 'number' | 'integer';
|
|
31
|
-
} ? NumericInput : T extends {
|
|
32
|
-
type: 'boolean';
|
|
33
|
-
} ? BooleanInput : string);
|
|
34
|
-
type QueryParams<A> = A extends {
|
|
35
|
-
params: readonly (infer Param)[];
|
|
36
|
-
} ? UnionToIntersection<Param extends {
|
|
37
|
-
name: infer Name extends string;
|
|
38
|
-
} ? {
|
|
39
|
-
[K in Name]?: ParamInput<Param>;
|
|
40
|
-
} : unknown> : {};
|
|
41
|
-
type SchemaProperties<S> = S extends {
|
|
42
|
-
properties: infer Properties;
|
|
43
|
-
} ? Properties : {};
|
|
44
|
-
type SchemaRequiredKeys<S> = S extends {
|
|
45
|
-
required: readonly (infer Key)[];
|
|
46
|
-
} ? Extract<Key, keyof SchemaProperties<S> & string> : never;
|
|
47
|
-
type SchemaValue<S> = S extends {
|
|
48
|
-
type: 'integer' | 'number';
|
|
49
|
-
} ? NumericInput : S extends {
|
|
50
|
-
type: 'boolean';
|
|
51
|
-
} ? BooleanInput : S extends {
|
|
52
|
-
type: 'array';
|
|
53
|
-
items?: infer Items;
|
|
54
|
-
} ? Array<SchemaValue<Items>> | readonly SchemaValue<Items>[] | string | Record<string, unknown> : S extends {
|
|
55
|
-
type: 'object';
|
|
56
|
-
} ? Record<string, unknown> : string;
|
|
57
|
-
type BodyParams<A> = A extends {
|
|
58
|
-
requestBody: {
|
|
59
|
-
schema: infer Schema;
|
|
60
|
-
};
|
|
61
|
-
} ? {
|
|
62
|
-
[K in SchemaRequiredKeys<Schema>]: SchemaValue<SchemaProperties<Schema>[K]>;
|
|
63
|
-
} & {
|
|
64
|
-
[K in Exclude<keyof SchemaProperties<Schema> & string, SchemaRequiredKeys<Schema>>]?: SchemaValue<SchemaProperties<Schema>[K]>;
|
|
65
|
-
} & {
|
|
66
|
-
data?: string | Partial<{
|
|
67
|
-
[K in keyof SchemaProperties<Schema> & string]: SchemaValue<SchemaProperties<Schema>[K]>;
|
|
68
|
-
}>;
|
|
69
|
-
} : {
|
|
70
|
-
data?: string | Record<string, unknown>;
|
|
71
|
-
};
|
|
72
|
-
type ScopedParams<PathParams> = 'scope' extends keyof PathParams ? {
|
|
73
|
-
scope?: 'products' | 'projects' | 'executions' | (string & {});
|
|
74
|
-
scopeID?: string | number;
|
|
75
|
-
product?: string | number;
|
|
76
|
-
productID?: string | number;
|
|
77
|
-
project?: string | number;
|
|
78
|
-
projectID?: string | number;
|
|
79
|
-
execution?: string | number;
|
|
80
|
-
executionID?: string | number;
|
|
81
|
-
} : {};
|
|
82
|
-
type PathParams<A> = A extends {
|
|
83
|
-
pathParams: infer Params;
|
|
84
|
-
} ? {
|
|
85
|
-
[K in Exclude<keyof Params & string, 'scope' | 'scopeID'>]?: string | number;
|
|
86
|
-
} & ScopedParams<Params> & {
|
|
87
|
-
id?: string | number;
|
|
88
|
-
} : {
|
|
89
|
-
id?: string | number;
|
|
90
|
-
};
|
|
91
|
-
/** 根据内置请求名推导出的参数类型。 */
|
|
92
|
-
export type RequestParamsFor<Name extends BuiltinRequestName> = PathParams<ActionOfRequest<Name>> & QueryParams<ActionOfRequest<Name>> & BodyParams<ActionOfRequest<Name>> & {
|
|
93
|
-
page?: string | number;
|
|
94
|
-
recPerPage?: string | number;
|
|
95
|
-
} & Record<string, unknown>;
|
|
13
|
+
type ActionMetaOf<Name extends BuiltinRequestName> = ModuleNameOf<Name> extends infer M extends BuiltinModuleName ? ActionNameOf<Name> extends infer A ? A extends keyof BuiltinActionMeta[M] ? BuiltinActionMeta[M][A] : {
|
|
14
|
+
resultType: 'object';
|
|
15
|
+
} : never : never;
|
|
16
|
+
/** 根据内置请求名推导出的参数类型。字段细节以运行时 registry 为准,这里保持可扩展。 */
|
|
17
|
+
export type RequestParamsFor<Name extends BuiltinRequestName> = Record<string, unknown>;
|
|
96
18
|
/** 根据内置请求名推导出的 `ResponseData.data` 类型。 */
|
|
97
|
-
export type RequestResultFor<Name extends BuiltinRequestName> =
|
|
19
|
+
export type RequestResultFor<Name extends BuiltinRequestName> = ActionMetaOf<Name> extends {
|
|
98
20
|
resultType: 'list';
|
|
99
|
-
} ? DataRecord[] :
|
|
21
|
+
} ? DataRecord[] : ActionMetaOf<Name> extends {
|
|
100
22
|
resultType: 'object';
|
|
101
23
|
} ? DataRecord : unknown;
|
|
102
24
|
/**
|
package/dist/version.js
CHANGED