pgflow 0.1.2 → 0.1.3
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/deno/internal_compile.ts +105 -0
- package/dist/package.json +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* internal_compile.ts
|
|
3
|
+
*
|
|
4
|
+
* This script is executed by Deno to compile a Flow into SQL statements.
|
|
5
|
+
* It takes a path to a flow file as an argument, imports the default export,
|
|
6
|
+
* and passes it to compileFlow() from the DSL package.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Get the flow file path from command line arguments
|
|
10
|
+
const flowFilePath = Deno.args[0];
|
|
11
|
+
|
|
12
|
+
if (!flowFilePath) {
|
|
13
|
+
console.error('Error: No flow file path provided');
|
|
14
|
+
Deno.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// Dynamically import the flow file
|
|
19
|
+
const flowModule = await import(`file://${flowFilePath}`);
|
|
20
|
+
|
|
21
|
+
// Check if there's a default export
|
|
22
|
+
if (!flowModule.default) {
|
|
23
|
+
console.error(`Error: No default export found in ${flowFilePath}`);
|
|
24
|
+
Deno.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Import the DSL module
|
|
28
|
+
// The import map in deno.json will resolve this import
|
|
29
|
+
const dslModule = await import('npm:@pgflow/dsl');
|
|
30
|
+
|
|
31
|
+
// Debug available exports
|
|
32
|
+
console.error('Available exports from @pgflow/dsl:', Object.keys(dslModule));
|
|
33
|
+
|
|
34
|
+
// Get the flow instance
|
|
35
|
+
const flow = flowModule.default;
|
|
36
|
+
|
|
37
|
+
let compileFlow;
|
|
38
|
+
const sqlStatements;
|
|
39
|
+
|
|
40
|
+
// Try different ways to access the compileFlow function
|
|
41
|
+
if (typeof dslModule.compileFlow === 'function') {
|
|
42
|
+
// Direct export
|
|
43
|
+
compileFlow = dslModule.compileFlow;
|
|
44
|
+
} else if (
|
|
45
|
+
dslModule.default &&
|
|
46
|
+
typeof dslModule.default.compileFlow === 'function'
|
|
47
|
+
) {
|
|
48
|
+
// Default export with compileFlow as a property
|
|
49
|
+
compileFlow = dslModule.default.compileFlow;
|
|
50
|
+
} else {
|
|
51
|
+
// Try to import the compile-flow module directly
|
|
52
|
+
try {
|
|
53
|
+
const compileFlowModule = await import(
|
|
54
|
+
'npm:@pgflow/dsl/dist/compile-flow.js'
|
|
55
|
+
);
|
|
56
|
+
if (typeof compileFlowModule.compileFlow === 'function') {
|
|
57
|
+
compileFlow = compileFlowModule.compileFlow;
|
|
58
|
+
} else if (
|
|
59
|
+
compileFlowModule.default &&
|
|
60
|
+
typeof compileFlowModule.default === 'function'
|
|
61
|
+
) {
|
|
62
|
+
compileFlow = compileFlowModule.default;
|
|
63
|
+
}
|
|
64
|
+
} catch (importError) {
|
|
65
|
+
console.error(
|
|
66
|
+
'Failed to import compile-flow module:',
|
|
67
|
+
importError.message
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// Try another path
|
|
71
|
+
try {
|
|
72
|
+
const altModule = await import('npm:@pgflow/dsl/src/compile-flow.js');
|
|
73
|
+
if (typeof altModule.compileFlow === 'function') {
|
|
74
|
+
compileFlow = altModule.compileFlow;
|
|
75
|
+
} else if (
|
|
76
|
+
altModule.default &&
|
|
77
|
+
typeof altModule.default === 'function'
|
|
78
|
+
) {
|
|
79
|
+
compileFlow = altModule.default;
|
|
80
|
+
}
|
|
81
|
+
} catch (altError) {
|
|
82
|
+
console.error(
|
|
83
|
+
'Failed to import alternative compile-flow module:',
|
|
84
|
+
altError.message
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Check if we found a valid compileFlow function
|
|
91
|
+
if (typeof compileFlow !== 'function') {
|
|
92
|
+
console.error('Error: compileFlow function not found in @pgflow/dsl');
|
|
93
|
+
console.error('Available exports:', Object.keys(dslModule));
|
|
94
|
+
Deno.exit(1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Compile the flow to SQL
|
|
98
|
+
sqlStatements = compileFlow(flow);
|
|
99
|
+
|
|
100
|
+
// Output the SQL statements to stdout
|
|
101
|
+
console.log(sqlStatements.join('\n'));
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error(`Error compiling flow: ${error.message}`);
|
|
104
|
+
Deno.exit(1);
|
|
105
|
+
}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgflow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"chalk": "^5.4.1",
|
|
25
25
|
"commander": "^13.1.0",
|
|
26
26
|
"toml-patch": "^0.2.3",
|
|
27
|
-
"@pgflow/core": "0.1.
|
|
27
|
+
"@pgflow/core": "0.1.3"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public",
|