@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.
@@ -16,7 +16,7 @@ export interface IBaseActionInput {
16
16
  id: string;
17
17
  name: string;
18
18
  type: ActionIOType;
19
- dataType?: ActionDataType;
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 declare class ActionUsageClient {
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: string, name: string, description: string, extended?: boolean, examples?: string[]): this;
45
- addOptionalParam(id: string, name: string, description: string, extended?: boolean, examples?: string[]): this;
46
- addSelect(id: string, name: string, description: string, options: ISelectInputOptions[], examples?: string[]): this;
47
- addOptionalSelect(id: string, name: string, description: string, options: ISelectInputOptions[], examples?: string[]): this;
48
- addArrayParam(id: string, name: string, description: string, examples?: string[]): this;
49
- addOptionalArrayParam(id: string, name: string, description: string, examples?: string[]): this;
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;
@@ -1 +1 @@
1
- class w{params;constructor(f){this.params=f??[]}addParam(f,b,h,j,v){return this.params.push({id:f,type:0,required:!0,name:b,description:h,extended:j??!1,examples:v}),this}addOptionalParam(f,b,h,j,v){return this.params.push({id:f,type:0,required:!1,name:b,description:h,extended:j??!1,examples:v}),this}addSelect(f,b,h,j,v){return this.params.push({id:f,type:1,required:!0,name:b,description:h,options:j,examples:v}),this}addOptionalSelect(f,b,h,j,v){return this.params.push({id:f,type:1,required:!1,name:b,description:h,options:j,examples:v}),this}addArrayParam(f,b,h,j){return this.params.push({id:f,type:2,required:!0,name:b,description:h,examples:j}),this}addOptionalArrayParam(f,b,h,j){return this.params.push({id:f,type:2,required:!1,name:b,description:h,examples:j}),this}getUsage(){return this.params.map((f)=>w.getParamUsage(f)).join(" ")}getExample(){return this.params.map((f)=>w.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=(q)=>q[Math.floor(Math.random()*q.length)],h=(q)=>q?b(q):b(["Angel","Brian","Catherine","David","Emma","Frank","Grace","Hannah","Ian","Julia","Josefina"]),j=(q)=>q?b(q):b(["Brian Stronghold","Catherine Joyful","David Noble","Emma Graceful","Frank Fearless","Grace Serene","Hannah Bold","Ian Clever","Julia Kindhearted","Romana Einstein"]),v=(q)=>b(q)?.name,z=(q)=>q?b(q):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 v(f.options);case 2:return z(f.examples);default:return""}}}export{w as ActionUsageClient};
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};
@@ -107,7 +107,7 @@ export interface IBaseActionInput {
107
107
  id: string;
108
108
  name: string;
109
109
  type: ActionIOType;
110
- dataType?: ActionDataType;
110
+ dataType: ActionDataType;
111
111
  description: string;
112
112
  examples?: string[];
113
113
  required?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fnlb-project/shared",
3
- "version": "1.5.120",
3
+ "version": "1.5.122",
4
4
  "description": "FNLB Shared Library",
5
5
  "files": [
6
6
  "dist"