@easyrpa/script-creator 1.0.5 → 1.0.6

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/index.d.ts CHANGED
@@ -1,8 +1,5 @@
1
+ import { ExternalDataNodeType, ExternalDataEdgeType, MetaDataType, VariablesNamesType, CollectionType } from "./types";
1
2
  export interface IScriptCreator {
2
- collections: CollectionType[];
3
- metaData?: MetaDataType;
4
- isDebugMode?: boolean;
5
- isRunMode?: boolean;
6
3
  createScript(dirPath: string, nodes: ExternalDataNodeType[], edges: ExternalDataEdgeType[], parentNode?: ExternalDataNodeType): Promise<string>;
7
4
  }
8
5
  export type ScriptCreatorConfig = {
@@ -13,13 +10,13 @@ export type ScriptCreatorConfig = {
13
10
  variablesNames?: Partial<VariablesNamesType>;
14
11
  };
15
12
  export declare class ScriptCreator implements IScriptCreator {
16
- collections: CollectionType[];
17
13
  metaData?: MetaDataType;
18
14
  isDebugMode?: boolean;
19
15
  isRunMode?: boolean;
20
16
  variablesNames: VariablesNamesType;
21
17
  logDebugVariablesPath?: string;
22
- constructor(collections: CollectionType[], config?: ScriptCreatorConfig);
18
+ handleGetCollections: () => Promise<CollectionType[]>;
19
+ constructor(handleGetCollections: () => Promise<CollectionType[]>, config: ScriptCreatorConfig);
23
20
  createScript(dirPath: string, nodes: ExternalDataNodeType[], edges: ExternalDataEdgeType[], parentNode?: ExternalDataNodeType | undefined): Promise<string>;
24
21
  private topologicalSorting;
25
22
  private getInputVars;
@@ -29,92 +26,3 @@ export declare class ScriptCreator implements IScriptCreator {
29
26
  private createCallNodeFunction;
30
27
  private createScriptString;
31
28
  }
32
- export type CollectionType = {
33
- name: string;
34
- nodes: ExternalDataNodeType[];
35
- };
36
- export type ExternalDataNodeType = {
37
- name: string;
38
- label: {
39
- ru: string;
40
- en: string;
41
- };
42
- collection: string;
43
- cid: string;
44
- parentsId: string[];
45
- type: NodeTypes;
46
- path: string;
47
- scriptPath: string;
48
- id: string;
49
- inputHandles: ExternalDataHandleType[];
50
- outputHandles: ExternalDataHandleType[];
51
- stateTerminals: ExternalDataStateTerminalType[];
52
- connectedEdges: ExternalDataEdgeType[];
53
- contentValues?: ContentValuesType;
54
- children?: ExternalDataNodeType[];
55
- dataSubFlow?: ExternalDataDefaultFlowType;
56
- scriptLineNumber?: number;
57
- };
58
- export type ExternalDataDefaultFlowType = {
59
- nodes: ExternalDataNodeType[];
60
- edges: ExternalDataEdgeType[];
61
- };
62
- export type ContentValuesType = {
63
- [key: string]: string | number | {
64
- [key: string]: string | number;
65
- } | (string | number)[];
66
- };
67
- export type ExternalDataEdgeType = {
68
- target: string;
69
- targetCid: string;
70
- targetHandle?: string;
71
- source: string;
72
- sourceCid: string;
73
- sourceHandle?: string;
74
- isReplacement: boolean;
75
- };
76
- export type ExternalDataStateTerminalType = {
77
- inputHandles: ExternalDataHandleType[];
78
- outputHandles: ExternalDataHandleType[];
79
- handlesType: HandleTypes;
80
- cid: string;
81
- };
82
- export type ExternalDataHandleType = {
83
- name: string;
84
- hidden: boolean;
85
- value: string;
86
- connectedEdges: ExternalDataEdgeType[];
87
- dataHandleSubFlowTerminal?: ExternalDataHandleType;
88
- nodeСid: string;
89
- };
90
- export declare enum HandleTypes {
91
- INPUT = "input",
92
- OUTPUT = "output"
93
- }
94
- export declare enum NodeTypes {
95
- CONTROL = "control",
96
- CONTAINER = "container",
97
- STATETERMINAL = "stateTerminal",
98
- SUBFLOW = "subFlow",
99
- EXTERNALSTATETERMINAL = "externalStateTerminal"
100
- }
101
- export declare enum LanguageNames {
102
- RU = "ru",
103
- EN = "en"
104
- }
105
- export type VariablesNamesType = {
106
- nodesVariableName: string;
107
- containerDataName: string;
108
- nodesJsonVariableName: string;
109
- inputDictName: string;
110
- inHandlesName: string;
111
- defaultScriptName: string;
112
- };
113
- export type MetaDataType = {
114
- appLanguage?: LanguageNames;
115
- };
116
- export type EdgeSortedType = ExternalDataEdgeType & {
117
- visited?: boolean;
118
- };
119
- export declare const getSubFlowName: (subFlow: ExternalDataNodeType) => string;
120
- export declare const normalize: (p: string) => string;
package/dist/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import fsPromises from "fs/promises";
2
2
  import path from "path";
3
+ import { HandleTypes, NodeTypes, } from "./types";
4
+ import { getSubFlowName, normalize } from "./utils";
3
5
  export class ScriptCreator {
4
- constructor(collections, config) {
5
- this.logDebugVariablesPath = config?.logDebugVariablesPath;
6
- this.metaData = config?.metaData;
7
- this.isDebugMode = config?.isDebugMode;
8
- this.isRunMode = config?.isRunMode;
6
+ constructor(handleGetCollections, config) {
7
+ this.logDebugVariablesPath = config.logDebugVariablesPath;
8
+ this.metaData = config.metaData;
9
+ this.isDebugMode = config.isDebugMode;
10
+ this.isRunMode = config.isRunMode;
9
11
  this.variablesNames = {
10
12
  nodesVariableName: "nodes",
11
13
  containerDataName: "container_data",
@@ -13,14 +15,15 @@ export class ScriptCreator {
13
15
  inputDictName: "input_dict",
14
16
  inHandlesName: "in_handles",
15
17
  defaultScriptName: "script.py",
16
- ...(config?.variablesNames || {}),
18
+ ...(config.variablesNames || {}),
17
19
  };
18
- this.collections = collections;
20
+ this.handleGetCollections = handleGetCollections;
19
21
  }
20
22
  //создание директории скрипта по заданному пути
21
23
  async createScript(dirPath, nodes, edges, parentNode = undefined) {
22
24
  // проверяем наличие всех необходимых блоков
23
- const allAvailableNodes = this.collections.reduce((allNodes, collection) => {
25
+ const collections = await this.handleGetCollections();
26
+ const allAvailableNodes = collections.reduce((allNodes, collection) => {
24
27
  return [
25
28
  ...allNodes,
26
29
  ...collection.nodes
@@ -456,30 +459,3 @@ export class ScriptCreator {
456
459
  return resultArray.join("\n");
457
460
  }
458
461
  }
459
- export var HandleTypes;
460
- (function (HandleTypes) {
461
- HandleTypes["INPUT"] = "input";
462
- HandleTypes["OUTPUT"] = "output";
463
- })(HandleTypes || (HandleTypes = {}));
464
- export var NodeTypes;
465
- (function (NodeTypes) {
466
- NodeTypes["CONTROL"] = "control";
467
- NodeTypes["CONTAINER"] = "container";
468
- NodeTypes["STATETERMINAL"] = "stateTerminal";
469
- NodeTypes["SUBFLOW"] = "subFlow";
470
- NodeTypes["EXTERNALSTATETERMINAL"] = "externalStateTerminal";
471
- })(NodeTypes || (NodeTypes = {}));
472
- export var LanguageNames;
473
- (function (LanguageNames) {
474
- LanguageNames["RU"] = "ru";
475
- LanguageNames["EN"] = "en";
476
- })(LanguageNames || (LanguageNames = {}));
477
- ;
478
- //utils
479
- //получение имени SubFLow
480
- export const getSubFlowName = (subFlow) => {
481
- return `${subFlow.name}_${subFlow.cid}`;
482
- };
483
- export const normalize = (p) => {
484
- return path.normalize(p.replaceAll('\\', '/'));
485
- };
@@ -0,0 +1,87 @@
1
+ export type CollectionType = {
2
+ name: string;
3
+ nodes: ExternalDataNodeType[];
4
+ };
5
+ export type ExternalDataNodeType = {
6
+ name: string;
7
+ label: {
8
+ ru: string;
9
+ en: string;
10
+ };
11
+ collection: string;
12
+ cid: string;
13
+ parentsId: string[];
14
+ type: NodeTypes;
15
+ path: string;
16
+ scriptPath: string;
17
+ id: string;
18
+ inputHandles: ExternalDataHandleType[];
19
+ outputHandles: ExternalDataHandleType[];
20
+ stateTerminals: ExternalDataStateTerminalType[];
21
+ connectedEdges: ExternalDataEdgeType[];
22
+ contentValues?: ContentValuesType;
23
+ children?: ExternalDataNodeType[];
24
+ dataSubFlow?: ExternalDataDefaultFlowType;
25
+ scriptLineNumber?: number;
26
+ };
27
+ export type ExternalDataDefaultFlowType = {
28
+ nodes: ExternalDataNodeType[];
29
+ edges: ExternalDataEdgeType[];
30
+ };
31
+ export type ContentValuesType = {
32
+ [key: string]: string | number | {
33
+ [key: string]: string | number;
34
+ } | (string | number)[];
35
+ };
36
+ export type ExternalDataEdgeType = {
37
+ target: string;
38
+ targetCid: string;
39
+ targetHandle?: string;
40
+ source: string;
41
+ sourceCid: string;
42
+ sourceHandle?: string;
43
+ isReplacement: boolean;
44
+ };
45
+ export type ExternalDataStateTerminalType = {
46
+ inputHandles: ExternalDataHandleType[];
47
+ outputHandles: ExternalDataHandleType[];
48
+ handlesType: HandleTypes;
49
+ cid: string;
50
+ };
51
+ export type ExternalDataHandleType = {
52
+ name: string;
53
+ hidden: boolean;
54
+ value: string;
55
+ connectedEdges: ExternalDataEdgeType[];
56
+ dataHandleSubFlowTerminal?: ExternalDataHandleType;
57
+ nodeСid: string;
58
+ };
59
+ export declare enum HandleTypes {
60
+ INPUT = "input",
61
+ OUTPUT = "output"
62
+ }
63
+ export declare enum NodeTypes {
64
+ CONTROL = "control",
65
+ CONTAINER = "container",
66
+ STATETERMINAL = "stateTerminal",
67
+ SUBFLOW = "subFlow",
68
+ EXTERNALSTATETERMINAL = "externalStateTerminal"
69
+ }
70
+ export declare enum LanguageNames {
71
+ RU = "ru",
72
+ EN = "en"
73
+ }
74
+ export type VariablesNamesType = {
75
+ nodesVariableName: string;
76
+ containerDataName: string;
77
+ nodesJsonVariableName: string;
78
+ inputDictName: string;
79
+ inHandlesName: string;
80
+ defaultScriptName: string;
81
+ };
82
+ export type MetaDataType = {
83
+ appLanguage?: LanguageNames;
84
+ };
85
+ export type EdgeSortedType = ExternalDataEdgeType & {
86
+ visited?: boolean;
87
+ };
package/dist/types.js ADDED
@@ -0,0 +1,19 @@
1
+ export var HandleTypes;
2
+ (function (HandleTypes) {
3
+ HandleTypes["INPUT"] = "input";
4
+ HandleTypes["OUTPUT"] = "output";
5
+ })(HandleTypes || (HandleTypes = {}));
6
+ export var NodeTypes;
7
+ (function (NodeTypes) {
8
+ NodeTypes["CONTROL"] = "control";
9
+ NodeTypes["CONTAINER"] = "container";
10
+ NodeTypes["STATETERMINAL"] = "stateTerminal";
11
+ NodeTypes["SUBFLOW"] = "subFlow";
12
+ NodeTypes["EXTERNALSTATETERMINAL"] = "externalStateTerminal";
13
+ })(NodeTypes || (NodeTypes = {}));
14
+ export var LanguageNames;
15
+ (function (LanguageNames) {
16
+ LanguageNames["RU"] = "ru";
17
+ LanguageNames["EN"] = "en";
18
+ })(LanguageNames || (LanguageNames = {}));
19
+ ;
@@ -0,0 +1,3 @@
1
+ import { ExternalDataNodeType } from "./types";
2
+ export declare const getSubFlowName: (subFlow: ExternalDataNodeType) => string;
3
+ export declare const normalize: (p: string) => string;
package/dist/utils.js ADDED
@@ -0,0 +1,8 @@
1
+ import path from 'path';
2
+ //получение имени SubFLow
3
+ export const getSubFlowName = (subFlow) => {
4
+ return `${subFlow.name}_${subFlow.cid}`;
5
+ };
6
+ export const normalize = (p) => {
7
+ return path.normalize(p.replaceAll('\\', '/'));
8
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@easyrpa/script-creator",
3
3
  "description": "Pyton script creator for easy rpa",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",