@fnlb-project/shared 1.5.120 → 1.5.122
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/actions/index.d.ts +21 -8
- package/dist/actions/index.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/actions/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface IBaseActionInput {
|
|
|
16
16
|
id: string;
|
|
17
17
|
name: string;
|
|
18
18
|
type: ActionIOType;
|
|
19
|
-
dataType
|
|
19
|
+
dataType: ActionDataType;
|
|
20
20
|
description: string;
|
|
21
21
|
examples?: string[];
|
|
22
22
|
required?: boolean;
|
|
@@ -38,15 +38,28 @@ export interface IArrayInput extends IBaseActionInput {
|
|
|
38
38
|
type: ActionIOType.Array;
|
|
39
39
|
}
|
|
40
40
|
export type ActionInput = ISingleInput | ISelectInput | IArrayInput;
|
|
41
|
-
export
|
|
41
|
+
export type DataTypeToType<T extends ActionDataType> = T extends ActionDataType.Integer | ActionDataType.Float ? number : T extends ActionDataType.Boolean ? boolean : string;
|
|
42
|
+
export declare class ActionUsageClient<Schema extends Record<string, any> = {}> {
|
|
42
43
|
params: ActionInput[];
|
|
43
44
|
constructor(params?: ActionInput[]);
|
|
44
|
-
addParam(id:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
addParam<Id extends string, DT extends ActionDataType = ActionDataType.String>(id: Id, name: string, description: string, extended?: boolean, examples?: string[], dataType?: DT): ActionUsageClient<Schema & {
|
|
46
|
+
[K in Id]: DataTypeToType<DT>;
|
|
47
|
+
}>;
|
|
48
|
+
addOptionalParam<Id extends string, DT extends ActionDataType = ActionDataType.String>(id: Id, name: string, description: string, extended?: boolean, examples?: string[], dataType?: DT): ActionUsageClient<Schema & {
|
|
49
|
+
[K in Id]: DataTypeToType<DT>;
|
|
50
|
+
}>;
|
|
51
|
+
addSelect<Id extends string, DT extends ActionDataType = ActionDataType.String>(id: Id, name: string, description: string, options: ISelectInputOptions[], examples?: string[], dataType?: DT): ActionUsageClient<Schema & {
|
|
52
|
+
[K in Id]: DataTypeToType<DT>;
|
|
53
|
+
}>;
|
|
54
|
+
addOptionalSelect<Id extends string, DT extends ActionDataType = ActionDataType.String>(id: Id, name: string, description: string, options: ISelectInputOptions[], examples?: string[], dataType?: DT): ActionUsageClient<Schema & {
|
|
55
|
+
[K in Id]: DataTypeToType<DT>;
|
|
56
|
+
}>;
|
|
57
|
+
addArrayParam<Id extends string, DT extends ActionDataType = ActionDataType.String>(id: Id, name: string, description: string, examples?: string[], dataType?: DT): ActionUsageClient<Schema & {
|
|
58
|
+
[K in Id]: DataTypeToType<DT>[];
|
|
59
|
+
}>;
|
|
60
|
+
addOptionalArrayParam<Id extends string, DT extends ActionDataType = ActionDataType.String>(id: Id, name: string, description: string, examples?: string[], dataType?: DT): ActionUsageClient<Schema & {
|
|
61
|
+
[K in Id]: DataTypeToType<DT>[];
|
|
62
|
+
}>;
|
|
50
63
|
getUsage(): string;
|
|
51
64
|
getExample(): string;
|
|
52
65
|
static getParamUsage(param: ActionInput): string;
|
package/dist/actions/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
class z{params;constructor(f){this.params=f??[]}addParam(f,b,h,j,q,w="string"){return this.params.push({id:f,type:0,dataType:w,required:!0,name:b,description:h,extended:j??!1,examples:q}),this}addOptionalParam(f,b,h,j,q,w="string"){return this.params.push({id:f,type:0,dataType:w,required:!1,name:b,description:h,extended:j??!1,examples:q}),this}addSelect(f,b,h,j,q,w="string"){return this.params.push({id:f,type:1,dataType:w,required:!0,name:b,description:h,options:j,examples:q}),this}addOptionalSelect(f,b,h,j,q,w="string"){return this.params.push({id:f,type:1,dataType:w,required:!1,name:b,description:h,options:j,examples:q}),this}addArrayParam(f,b,h,j,q="string"){return this.params.push({id:f,type:2,dataType:q,required:!0,name:b,description:h,examples:j}),this}addOptionalArrayParam(f,b,h,j,q="string"){return this.params.push({id:f,type:2,dataType:q,required:!1,name:b,description:h,examples:j}),this}getUsage(){return this.params.map((f)=>z.getParamUsage(f)).join(" ")}getExample(){return this.params.map((f)=>z.getParamExample(f)).join(" ")}static getParamUsage(f){switch(f.type){case 0:return f.required?`<${f.extended?"...":""}${f.name}>`:`[${f.extended?"...":""}${f.name}]`;case 1:return f.required?`<${f.options.map((b)=>b.name).join(" | ")}>`:`[${f.options.map((b)=>b.name).join(" | ")}]`;case 2:return f.required?`<${f.name}[]>`:`[${f.name}[]]`;default:return""}}static getParamExample(f){let b=(v)=>v[Math.floor(Math.random()*v.length)],h=(v)=>v?b(v):b(["Angel","Brian","Catherine","David","Emma","Frank","Grace","Hannah","Ian","Julia","Josefina"]),j=(v)=>v?b(v):b(["Brian Stronghold","Catherine Joyful","David Noble","Emma Graceful","Frank Fearless","Grace Serene","Hannah Bold","Ian Clever","Julia Kindhearted","Romana Einstein"]),q=(v)=>b(v)?.name,w=(v)=>v?b(v):b(["Angel","Brian","Catherine","David","Emma","Frank","Grace","Hannah","Ian","Julia","Josefina"]);switch(f.type){case 0:return f.extended?j(f.examples):h(f.examples);case 1:return q(f.options);case 2:return w(f.examples);default:return""}}}export{z as ActionUsageClient};
|
package/dist/types/index.d.ts
CHANGED