@intuned/runtime-dev 1.3.18-interface.12 → 1.3.18-interface.13

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.
@@ -0,0 +1,61 @@
1
+ import type { ImportFunction } from "@intuned/runtime/dist/common/runApi";
2
+ import { err, ok } from "neverthrow";
3
+
4
+ export const importModule: ImportFunction = async (path: string) => {
5
+ const [folderName, ...functionNameParts] = path.split("/");
6
+ const functionNameDepth = functionNameParts.length;
7
+
8
+ // string literals should be inline
9
+ // currently we support only 5 levels of depth
10
+ // rollup dynamic import does not support multiple levels of dynamic imports so we need to specify the possible paths explicitly
11
+ let imported: any = undefined;
12
+ try {
13
+ switch (functionNameDepth) {
14
+ case 1:
15
+ imported = await import(`./${folderName}/${functionNameParts[0]}.ts`);
16
+ break;
17
+ case 2:
18
+ imported = await import(
19
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}.ts`
20
+ );
21
+ break;
22
+ case 3:
23
+ imported = await import(
24
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}.ts`
25
+ );
26
+ break;
27
+ case 4:
28
+ imported = await import(
29
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}.ts`
30
+ );
31
+ break;
32
+ case 5:
33
+ imported = await import(
34
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}.ts`
35
+ );
36
+ break;
37
+ default:
38
+ return err({
39
+ type: "other",
40
+ error: new Error(
41
+ `intuned supports maximum 5 levels of depth in the api folder`
42
+ ),
43
+ });
44
+ }
45
+ return ok(imported);
46
+ } catch (e: any) {
47
+ if (
48
+ "message" in e &&
49
+ typeof e.message === "string" &&
50
+ e.message.includes("Unknown variable dynamic import")
51
+ ) {
52
+ return err({
53
+ type: "not_found",
54
+ });
55
+ }
56
+ return err({
57
+ type: "other",
58
+ error: e,
59
+ });
60
+ }
61
+ };
@@ -0,0 +1,6 @@
1
+ require("@intuned/runtime/dist/common/binStartupScript");
2
+ import { runAutomationCLI } from "@intuned/runtime/dist/commands/interface/run";
3
+
4
+ import { importModule } from "./__utils";
5
+
6
+ runAutomationCLI(importModule);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "1.3.18-interface.12",
3
+ "version": "1.3.18-interface.13",
4
4
  "description": "Intuned runtime",
5
5
  "packageManager": "yarn@4.12.0",
6
6
  "main": "./dist/index.js",
@@ -74,7 +74,8 @@
74
74
  },
75
75
  "files": [
76
76
  "dist",
77
- "bin"
77
+ "bin",
78
+ "InterfaceTemplate"
78
79
  ],
79
80
  "author": "Intuned Team",
80
81
  "license": "Elastic-2.0",