@chainlink/cre-sdk 1.6.0-alpha.3 → 1.6.0
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/README.md +9 -0
- package/bin/cre-compile.ts +17 -5
- package/dist/sdk/cre/index.d.ts +0 -6
- package/dist/sdk/cre/index.js +0 -8
- package/dist/sdk/test/generated/index.d.ts +0 -2
- package/dist/sdk/test/generated/index.js +0 -2
- package/package.json +2 -2
- package/scripts/run-standard-tests.sh +3 -3
- package/scripts/src/compile-to-wasm.ts +39 -19
- package/scripts/src/compile-workflow.ts +31 -12
- package/scripts/src/generate-sdks.ts +0 -12
- package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +0 -1023
- package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +0 -290
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +0 -2904
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +0 -506
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +0 -52
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +0 -186
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +0 -92
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +0 -343
- package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +0 -25
- package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +0 -111
- package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.d.ts +0 -33
- package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +0 -178
package/README.md
CHANGED
|
@@ -516,6 +516,15 @@ This SDK uses [@bufbuild/protobuf](https://www.npmjs.com/package/@bufbuild/proto
|
|
|
516
516
|
- `buf.gen.yaml` - Code generation configuration using ts-proto
|
|
517
517
|
- Generated files are placed in `src/generated/`
|
|
518
518
|
|
|
519
|
+
**Opt-in proto allowlist:**
|
|
520
|
+
|
|
521
|
+
[`buf.gen.yaml`](./buf.gen.yaml) uses an explicit `paths:` allowlist under its `inputs`. Protos added to the `chainlink-protos` submodule are **not** picked up automatically — a new capability must be added to both:
|
|
522
|
+
|
|
523
|
+
1. [`packages/cre-sdk/buf.gen.yaml`](./buf.gen.yaml) — to generate the raw `*_pb.ts` types.
|
|
524
|
+
2. [`packages/cre-sdk/scripts/src/generate-sdks.ts`](./scripts/src/generate-sdks.ts) — to generate the SDK wrapper classes and mocks.
|
|
525
|
+
|
|
526
|
+
This prevents leaking in-progress or internal capabilities into the public SDK surface before they are ready.
|
|
527
|
+
|
|
519
528
|
### Chain Selectors Generation
|
|
520
529
|
|
|
521
530
|
Auto-generated TypeScript files for 200+ blockchain networks from the official [Chainlink chain-selectors repository](https://github.com/smartcontractkit/chain-selectors).
|
package/bin/cre-compile.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
3
|
import { main as compileWorkflow } from "../scripts/src/compile-workflow";
|
|
4
|
+
import { parseCompileFlags } from "@chainlink/cre-sdk-javy-plugin/scripts/parse-compile-flags";
|
|
4
5
|
import {
|
|
5
6
|
parseCompileCliArgs,
|
|
6
7
|
skipTypeChecksFlag,
|
|
@@ -9,26 +10,34 @@ import { WorkflowTypecheckError } from "../scripts/src/typecheck-workflow";
|
|
|
9
10
|
import { WorkflowRuntimeCompatibilityError } from "../scripts/src/validate-workflow-runtime-compat";
|
|
10
11
|
|
|
11
12
|
const main = async () => {
|
|
13
|
+
const cliArgs = process.argv.slice(2);
|
|
14
|
+
const { creExports, plugin, rest } = parseCompileFlags(cliArgs);
|
|
15
|
+
|
|
12
16
|
let inputPath: string | undefined;
|
|
13
17
|
let outputPathArg: string | undefined;
|
|
14
18
|
let skipTypeChecks = false;
|
|
15
19
|
|
|
16
20
|
try {
|
|
17
|
-
const parsed = parseCompileCliArgs(
|
|
21
|
+
const parsed = parseCompileCliArgs(rest);
|
|
18
22
|
inputPath = parsed.inputPath;
|
|
19
23
|
outputPathArg = parsed.outputPath;
|
|
20
24
|
skipTypeChecks = parsed.skipTypeChecks;
|
|
21
25
|
} catch (error) {
|
|
22
26
|
console.error(error instanceof Error ? error.message : error);
|
|
23
27
|
console.error(
|
|
24
|
-
`Usage: cre-compile <path/to/workflow.ts> [path/to/output.wasm] [${skipTypeChecksFlag}]`,
|
|
28
|
+
`Usage: cre-compile [--plugin <path>] [--cre-exports <crate-dir>]... <path/to/workflow.ts> [path/to/output.wasm] [${skipTypeChecksFlag}]`,
|
|
25
29
|
);
|
|
26
30
|
process.exit(1);
|
|
27
31
|
}
|
|
28
32
|
|
|
33
|
+
if (plugin !== null && creExports.length > 0) {
|
|
34
|
+
console.error("❌ Error: --plugin and --cre-exports are mutually exclusive.");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
if (!inputPath) {
|
|
30
39
|
console.error(
|
|
31
|
-
`Usage: cre-compile <path/to/workflow.ts> [path/to/output.wasm] [${skipTypeChecksFlag}]`,
|
|
40
|
+
`Usage: cre-compile [--plugin <path>] [--cre-exports <crate-dir>]... <path/to/workflow.ts> [path/to/output.wasm] [${skipTypeChecksFlag}]`,
|
|
32
41
|
);
|
|
33
42
|
console.error("Examples:");
|
|
34
43
|
console.error(" cre-compile src/standard_tests/secrets/test.ts");
|
|
@@ -41,10 +50,13 @@ const main = async () => {
|
|
|
41
50
|
process.exit(1);
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
await compileWorkflow(inputPath, outputPathArg, {
|
|
53
|
+
await compileWorkflow(inputPath, outputPathArg, {
|
|
54
|
+
skipTypeChecks,
|
|
55
|
+
creExports: creExports.length > 0 ? creExports : undefined,
|
|
56
|
+
plugin,
|
|
57
|
+
});
|
|
45
58
|
};
|
|
46
59
|
|
|
47
|
-
// CLI entry point
|
|
48
60
|
main().catch((e) => {
|
|
49
61
|
if (
|
|
50
62
|
e instanceof WorkflowRuntimeCompatibilityError ||
|
package/dist/sdk/cre/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public API for the CRE SDK.
|
|
3
3
|
*/
|
|
4
|
-
import { ClientCapability as AptosClient } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
|
|
5
4
|
import { ClientCapability as EVMClient } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
6
|
-
import { ClientCapability as SolanaClient } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
|
|
7
5
|
import { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
|
|
8
6
|
import { ClientCapability as HTTPClient } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
9
7
|
import { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
|
|
@@ -14,9 +12,7 @@ import { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/
|
|
|
14
12
|
export { type Log as EVMLog, TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
|
|
15
13
|
export type { Payload as HTTPPayload } from '../../generated/capabilities/networking/http/v1alpha/trigger_pb';
|
|
16
14
|
export type { Payload as CronPayload } from '../../generated/capabilities/scheduler/cron/v1/trigger_pb';
|
|
17
|
-
export { ClientCapability as AptosClient, type WriteCreReportRequest as AptosWriteCreReportRequest, type WriteCreReportRequestJson as AptosWriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
|
|
18
15
|
export { ClientCapability as EVMClient, type WriteCreReportRequest, type WriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
19
|
-
export { ClientCapability as SolanaClient, type WriteCreReportRequest as SolanaWriteCreReportRequest, type WriteCreReportRequestJson as SolanaWriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
|
|
20
16
|
export { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
|
|
21
17
|
export { ClientCapability as HTTPClient, type SendRequester as HTTPSendRequester, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
22
18
|
export { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
|
|
@@ -30,8 +26,6 @@ export declare const cre: {
|
|
|
30
26
|
ConfidentialHTTPClient: typeof ConfidentialHTTPClient;
|
|
31
27
|
HTTPClient: typeof HTTPClient;
|
|
32
28
|
EVMClient: typeof EVMClient;
|
|
33
|
-
AptosClient: typeof AptosClient;
|
|
34
|
-
SolanaClient: typeof SolanaClient;
|
|
35
29
|
};
|
|
36
30
|
handler: <TRawTriggerOutput extends import("@bufbuild/protobuf").Message<string>, TTriggerOutput, TConfig, TResult>(trigger: import("../utils/triggers/trigger-interface").Trigger<TRawTriggerOutput, TTriggerOutput>, fn: import("../workflow").HandlerFn<TConfig, TTriggerOutput, TResult>) => import("../workflow").HandlerEntry<TConfig, TRawTriggerOutput, TTriggerOutput, TResult>;
|
|
37
31
|
};
|
package/dist/sdk/cre/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public API for the CRE SDK.
|
|
3
3
|
*/
|
|
4
|
-
import { ClientCapability as AptosClient } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
|
|
5
4
|
import { ClientCapability as EVMClient } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
6
|
-
import { ClientCapability as SolanaClient } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
|
|
7
5
|
import { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
|
|
8
6
|
import { ClientCapability as HTTPClient } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
9
7
|
import { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
|
|
@@ -14,12 +12,8 @@ import { handler } from '../workflow';
|
|
|
14
12
|
* Public exports for the CRE SDK.
|
|
15
13
|
*/
|
|
16
14
|
export { TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
|
|
17
|
-
// Aptos Capability
|
|
18
|
-
export { ClientCapability as AptosClient, } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
|
|
19
15
|
// EVM Capability
|
|
20
16
|
export { ClientCapability as EVMClient, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
21
|
-
// Solana Capability
|
|
22
|
-
export { ClientCapability as SolanaClient, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
|
|
23
17
|
// Confidential HTTP Capability
|
|
24
18
|
export { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
|
|
25
19
|
// HTTP Capability
|
|
@@ -36,8 +30,6 @@ export const cre = {
|
|
|
36
30
|
ConfidentialHTTPClient,
|
|
37
31
|
HTTPClient,
|
|
38
32
|
EVMClient,
|
|
39
|
-
AptosClient,
|
|
40
|
-
SolanaClient,
|
|
41
33
|
},
|
|
42
34
|
handler,
|
|
43
35
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/** Auto-generated barrel of capability mocks. Do not edit. */
|
|
2
|
-
export { AptosMock } from './capabilities/blockchain/aptos/v1alpha/aptos_mock_gen';
|
|
3
2
|
export { EvmMock } from './capabilities/blockchain/evm/v1alpha/evm_mock_gen';
|
|
4
|
-
export { SolanaMock } from './capabilities/blockchain/solana/v1alpha/solana_mock_gen';
|
|
5
3
|
export { BasicTestActionTriggerMock } from './capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen';
|
|
6
4
|
export { BasicTestActionMock } from './capabilities/internal/basicaction/v1/basic_test_action_mock_gen';
|
|
7
5
|
export { ConsensusMock } from './capabilities/internal/consensus/v1alpha/consensus_mock_gen';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/** Auto-generated barrel of capability mocks. Do not edit. */
|
|
2
|
-
export { AptosMock } from './capabilities/blockchain/aptos/v1alpha/aptos_mock_gen';
|
|
3
2
|
export { EvmMock } from './capabilities/blockchain/evm/v1alpha/evm_mock_gen';
|
|
4
|
-
export { SolanaMock } from './capabilities/blockchain/solana/v1alpha/solana_mock_gen';
|
|
5
3
|
export { BasicTestActionTriggerMock } from './capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen';
|
|
6
4
|
export { BasicTestActionMock } from './capabilities/internal/basicaction/v1/basic_test_action_mock_gen';
|
|
7
5
|
export { ConsensusMock } from './capabilities/internal/consensus/v1alpha/consensus_mock_gen';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainlink/cre-sdk",
|
|
3
|
-
"version": "1.6.0
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@bufbuild/protobuf": "2.6.3",
|
|
62
62
|
"@bufbuild/protoc-gen-es": "2.6.3",
|
|
63
|
-
"@chainlink/cre-sdk-javy-plugin": "1.
|
|
63
|
+
"@chainlink/cre-sdk-javy-plugin": "1.6.0",
|
|
64
64
|
"@standard-schema/spec": "1.0.0",
|
|
65
65
|
"viem": "2.34.0",
|
|
66
66
|
"zod": "3.25.76"
|
|
@@ -8,9 +8,9 @@ set -e
|
|
|
8
8
|
# Create dist test workflow folder
|
|
9
9
|
mkdir -p ./dist/workflows/standard_tests
|
|
10
10
|
|
|
11
|
-
#
|
|
12
|
-
if [ ! -f ../cre-sdk-javy-plugin/dist/
|
|
13
|
-
echo "Error:
|
|
11
|
+
# Plugin package must be built (initialized plugin is what we ship).
|
|
12
|
+
if [ ! -f ../cre-sdk-javy-plugin/dist/javy-chainlink-sdk.plugin.wasm ]; then
|
|
13
|
+
echo "Error: javy-chainlink-sdk.plugin.wasm not found (run cre-sdk-javy-plugin build first)"
|
|
14
14
|
exit 1
|
|
15
15
|
fi
|
|
16
16
|
|
|
@@ -2,6 +2,7 @@ import { spawn } from 'node:child_process'
|
|
|
2
2
|
import { existsSync } from 'node:fs'
|
|
3
3
|
import { mkdir } from 'node:fs/promises'
|
|
4
4
|
import path from 'node:path'
|
|
5
|
+
import { parseCompileFlags } from '@chainlink/cre-sdk-javy-plugin/scripts/parse-compile-flags'
|
|
5
6
|
|
|
6
7
|
function runBun(args: string[]): Promise<void> {
|
|
7
8
|
return new Promise((resolve, reject) => {
|
|
@@ -19,20 +20,29 @@ function runBun(args: string[]): Promise<void> {
|
|
|
19
20
|
|
|
20
21
|
const isJsFile = (p: string) => ['.js', '.mjs', '.cjs'].includes(path.extname(p).toLowerCase())
|
|
21
22
|
|
|
22
|
-
export const main = async (
|
|
23
|
+
export const main = async (
|
|
24
|
+
inputFile?: string,
|
|
25
|
+
outputFile?: string,
|
|
26
|
+
creExportsPaths?: string[],
|
|
27
|
+
pluginPath?: string | null,
|
|
28
|
+
) => {
|
|
23
29
|
const cliArgs = process.argv.slice(3)
|
|
30
|
+
const { creExports: cliCreExports, plugin: cliPlugin, rest: cliRest } = parseCompileFlags(cliArgs)
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
32
|
+
const inputPath = inputFile ?? cliRest[0]
|
|
33
|
+
const outputPathArg = outputFile ?? cliRest[1]
|
|
34
|
+
const creExports = creExportsPaths ?? cliCreExports
|
|
35
|
+
const plugin = pluginPath !== undefined ? pluginPath : cliPlugin
|
|
36
|
+
|
|
37
|
+
if (plugin !== null && plugin !== undefined && creExports.length > 0) {
|
|
38
|
+
console.error('❌ Error: --plugin and --cre-exports are mutually exclusive.')
|
|
39
|
+
process.exit(1)
|
|
40
|
+
}
|
|
28
41
|
|
|
29
42
|
if (!inputPath) {
|
|
30
43
|
console.error(
|
|
31
44
|
'Usage: bun compile:js-to-wasm <path/to/input.(js|mjs|cjs)> [path/to/output.wasm]',
|
|
32
45
|
)
|
|
33
|
-
console.error('Examples:')
|
|
34
|
-
console.error(' bun compile:js-to-wasm ./build/workflows/test.js')
|
|
35
|
-
console.error(' bun compile:js-to-wasm ./build/workflows/test.mjs ./artifacts/test.wasm')
|
|
36
46
|
process.exit(1)
|
|
37
47
|
}
|
|
38
48
|
|
|
@@ -47,31 +57,41 @@ export const main = async (inputFile?: string, outputFile?: string) => {
|
|
|
47
57
|
process.exit(1)
|
|
48
58
|
}
|
|
49
59
|
|
|
50
|
-
// Default output = same dir, same basename, .wasm extension
|
|
51
60
|
const defaultOut = path.join(
|
|
52
61
|
path.dirname(resolvedInput),
|
|
53
62
|
path.basename(resolvedInput).replace(/\.(m|c)?js$/i, '.wasm'),
|
|
54
63
|
)
|
|
55
64
|
const resolvedOutput = outputPathArg ? path.resolve(outputPathArg) : defaultOut
|
|
56
65
|
|
|
57
|
-
// Ensure output directory exists
|
|
58
66
|
await mkdir(path.dirname(resolvedOutput), { recursive: true })
|
|
59
67
|
|
|
60
|
-
console.info(
|
|
68
|
+
console.info('🔨 Compiling to WASM')
|
|
61
69
|
console.info(`📁 Input: ${resolvedInput}`)
|
|
62
70
|
console.info(`🎯 Output: ${resolvedOutput}`)
|
|
63
71
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
72
|
+
const compileArgs: string[] = []
|
|
73
|
+
if (plugin != null && plugin !== '') {
|
|
74
|
+
compileArgs.push('--plugin', path.resolve(plugin))
|
|
75
|
+
} else {
|
|
76
|
+
compileArgs.push(...creExports.flatMap((p) => ['--cre-exports', path.resolve(p)]))
|
|
77
|
+
}
|
|
78
|
+
compileArgs.push(resolvedInput, resolvedOutput)
|
|
79
|
+
|
|
80
|
+
let javyPluginRoot: string
|
|
81
|
+
if (process.env.CRE_SDK_JAVY_PLUGIN_HOME) {
|
|
82
|
+
javyPluginRoot = path.resolve(process.env.CRE_SDK_JAVY_PLUGIN_HOME)
|
|
83
|
+
} else {
|
|
84
|
+
try {
|
|
85
|
+
javyPluginRoot = path.dirname(require.resolve('@chainlink/cre-sdk-javy-plugin/package.json'))
|
|
86
|
+
} catch {
|
|
87
|
+
javyPluginRoot = path.resolve(import.meta.dir, '../../../cre-sdk-javy-plugin')
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const compilerPath = path.join(javyPluginRoot, 'bin/compile-workflow.ts')
|
|
71
91
|
if (existsSync(compilerPath)) {
|
|
72
|
-
await runBun(['--bun', compilerPath,
|
|
92
|
+
await runBun(['--bun', compilerPath, ...compileArgs])
|
|
73
93
|
} else {
|
|
74
|
-
await runBun(['x', 'cre-compile-workflow',
|
|
94
|
+
await runBun(['x', 'cre-compile-workflow', ...compileArgs])
|
|
75
95
|
}
|
|
76
96
|
|
|
77
97
|
console.info(`✅ Compiled: ${resolvedOutput}`)
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs'
|
|
2
2
|
import { mkdir } from 'node:fs/promises'
|
|
3
3
|
import path from 'node:path'
|
|
4
|
+
import { parseCompileFlags } from '@chainlink/cre-sdk-javy-plugin/scripts/parse-compile-flags'
|
|
4
5
|
import { parseCompileCliArgs, skipTypeChecksFlag } from './compile-cli-args'
|
|
5
6
|
import { main as compileToJs } from './compile-to-js'
|
|
6
7
|
import { main as compileToWasm } from './compile-to-wasm'
|
|
7
8
|
|
|
8
9
|
type CompileWorkflowOptions = {
|
|
9
10
|
skipTypeChecks?: boolean
|
|
11
|
+
creExports?: string[]
|
|
12
|
+
plugin?: string | null
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
const printUsage = () => {
|
|
13
16
|
console.error(
|
|
14
|
-
`Usage: bun compile:workflow <path/to/workflow.ts> [path/to/output.wasm] [${skipTypeChecksFlag}]`,
|
|
17
|
+
`Usage: bun compile:workflow [--plugin <path>] [--cre-exports <crate-dir>]... <path/to/workflow.ts> [path/to/output.wasm] [${skipTypeChecksFlag}]`,
|
|
15
18
|
)
|
|
16
19
|
console.error('Examples:')
|
|
17
20
|
console.error(' bun compile:workflow src/standard_tests/secrets/test.ts')
|
|
@@ -31,17 +34,25 @@ export const main = async (
|
|
|
31
34
|
let parsedInputPath: string | undefined
|
|
32
35
|
let parsedOutputPath: string | undefined
|
|
33
36
|
let parsedSkipTypeChecks = false
|
|
37
|
+
let parsedCreExports: string[] = []
|
|
38
|
+
let parsedPlugin: string | null = null
|
|
34
39
|
|
|
35
|
-
if (inputFile != null || outputWasmFile != null || options
|
|
40
|
+
if (inputFile != null || outputWasmFile != null || options != null) {
|
|
36
41
|
parsedInputPath = inputFile
|
|
37
42
|
parsedOutputPath = outputWasmFile
|
|
38
43
|
parsedSkipTypeChecks = options?.skipTypeChecks ?? false
|
|
44
|
+
parsedCreExports = options?.creExports ?? []
|
|
45
|
+
parsedPlugin = options?.plugin !== undefined ? options.plugin : null
|
|
39
46
|
} else {
|
|
40
47
|
try {
|
|
41
|
-
const
|
|
48
|
+
const cliArgs = process.argv.slice(3)
|
|
49
|
+
const { creExports, plugin, rest } = parseCompileFlags(cliArgs)
|
|
50
|
+
const parsed = parseCompileCliArgs(rest)
|
|
42
51
|
parsedInputPath = parsed.inputPath
|
|
43
52
|
parsedOutputPath = parsed.outputPath
|
|
44
53
|
parsedSkipTypeChecks = parsed.skipTypeChecks
|
|
54
|
+
parsedCreExports = creExports
|
|
55
|
+
parsedPlugin = plugin
|
|
45
56
|
} catch (error) {
|
|
46
57
|
console.error(error instanceof Error ? error.message : error)
|
|
47
58
|
printUsage()
|
|
@@ -52,6 +63,11 @@ export const main = async (
|
|
|
52
63
|
const inputPath = parsedInputPath
|
|
53
64
|
const outputPathArg = parsedOutputPath
|
|
54
65
|
|
|
66
|
+
if (parsedPlugin != null && parsedPlugin !== '' && parsedCreExports.length > 0) {
|
|
67
|
+
console.error('❌ Error: --plugin and --cre-exports are mutually exclusive.')
|
|
68
|
+
process.exit(1)
|
|
69
|
+
}
|
|
70
|
+
|
|
55
71
|
if (!inputPath) {
|
|
56
72
|
printUsage()
|
|
57
73
|
process.exit(1)
|
|
@@ -63,33 +79,36 @@ export const main = async (
|
|
|
63
79
|
process.exit(1)
|
|
64
80
|
}
|
|
65
81
|
|
|
66
|
-
// Default final output = same dir, same basename, .wasm
|
|
67
82
|
const defaultWasmOut = path.join(
|
|
68
83
|
path.dirname(resolvedInput),
|
|
69
84
|
path.basename(resolvedInput).replace(/\.[^.]+$/, '.wasm'),
|
|
70
85
|
)
|
|
71
86
|
const resolvedWasmOutput = outputPathArg ? path.resolve(outputPathArg) : defaultWasmOut
|
|
72
|
-
|
|
73
|
-
// Put the intermediate JS next to the final wasm (so custom outputs stay together)
|
|
74
87
|
const resolvedJsOutput = resolvedWasmOutput.replace(/\.wasm$/i, '.js')
|
|
75
88
|
|
|
76
|
-
// Ensure directories exist (handles both intermediate JS dir and wasm dir)
|
|
77
89
|
await mkdir(path.dirname(resolvedJsOutput), { recursive: true })
|
|
78
90
|
|
|
79
|
-
console.info(
|
|
80
|
-
console.info(`📁 Input: ${resolvedInput}
|
|
91
|
+
console.info('🚀 Compiling workflow')
|
|
92
|
+
console.info(`📁 Input: ${resolvedInput}`)
|
|
93
|
+
console.info(`🧪 JS out: ${resolvedJsOutput}`)
|
|
94
|
+
console.info(`🎯 WASM out:${resolvedWasmOutput}\n`)
|
|
81
95
|
if (parsedSkipTypeChecks) {
|
|
82
96
|
console.info(`⚠️ Skipping TypeScript checks (${skipTypeChecksFlag})`)
|
|
83
97
|
}
|
|
84
98
|
|
|
85
|
-
// Step 1: TS/JS → JS (bundled)
|
|
86
99
|
console.info('📦 Step 1: Compiling JS...')
|
|
87
100
|
await compileToJs(resolvedInput, resolvedJsOutput, { skipTypeChecks: parsedSkipTypeChecks })
|
|
88
101
|
|
|
89
|
-
// Step 2: JS → WASM
|
|
90
102
|
console.info('\n🔨 Step 2: Compiling to WASM...')
|
|
91
|
-
await compileToWasm(resolvedJsOutput, resolvedWasmOutput)
|
|
103
|
+
await compileToWasm(resolvedJsOutput, resolvedWasmOutput, parsedCreExports, parsedPlugin)
|
|
92
104
|
|
|
93
105
|
console.info(`\n✅ Workflow built: ${resolvedWasmOutput}`)
|
|
94
106
|
return resolvedWasmOutput
|
|
95
107
|
}
|
|
108
|
+
|
|
109
|
+
if (import.meta.main) {
|
|
110
|
+
main().catch((e) => {
|
|
111
|
+
console.error(e)
|
|
112
|
+
process.exit(1)
|
|
113
|
+
})
|
|
114
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { rmSync } from 'node:fs'
|
|
2
|
-
import { file_capabilities_blockchain_aptos_v1alpha_client } from '@cre/generated/capabilities/blockchain/aptos/v1alpha/client_pb'
|
|
3
2
|
import { file_capabilities_blockchain_evm_v1alpha_client } from '@cre/generated/capabilities/blockchain/evm/v1alpha/client_pb'
|
|
4
|
-
import { file_capabilities_blockchain_solana_v1alpha_client } from '@cre/generated/capabilities/blockchain/solana/v1alpha/client_pb'
|
|
5
3
|
import { file_capabilities_internal_actionandtrigger_v1_action_and_trigger } from '@cre/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb'
|
|
6
4
|
import { file_capabilities_internal_basicaction_v1_basic_action } from '@cre/generated/capabilities/internal/basicaction/v1/basic_action_pb'
|
|
7
5
|
import { file_capabilities_internal_basictrigger_v1_basic_trigger } from '@cre/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb'
|
|
@@ -65,16 +63,6 @@ export const main = () => {
|
|
|
65
63
|
...generateMocks(file_capabilities_blockchain_evm_v1alpha_client, TEST_GENERATED_DIR),
|
|
66
64
|
)
|
|
67
65
|
|
|
68
|
-
generateSdk(file_capabilities_blockchain_aptos_v1alpha_client, './src/generated-sdk')
|
|
69
|
-
allMockExports.push(
|
|
70
|
-
...generateMocks(file_capabilities_blockchain_aptos_v1alpha_client, TEST_GENERATED_DIR),
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
generateSdk(file_capabilities_blockchain_solana_v1alpha_client, './src/generated-sdk')
|
|
74
|
-
allMockExports.push(
|
|
75
|
-
...generateMocks(file_capabilities_blockchain_solana_v1alpha_client, TEST_GENERATED_DIR),
|
|
76
|
-
)
|
|
77
|
-
|
|
78
66
|
generateSdk(file_capabilities_networking_http_v1alpha_client, './src/generated-sdk')
|
|
79
67
|
allMockExports.push(
|
|
80
68
|
...generateMocks(file_capabilities_networking_http_v1alpha_client, TEST_GENERATED_DIR),
|