@chainlink/cre-sdk 1.16.0 → 1.17.0-alpha.1
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 +2 -62
- package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +1035 -0
- package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +290 -0
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +2885 -15
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +459 -7
- package/dist/generated/capabilities/networking/http/v1alpha/client_pb.js +1 -1
- package/dist/generated/sdk/v1alpha/sdk_pb.d.ts +505 -0
- package/dist/generated/sdk/v1alpha/sdk_pb.js +121 -15
- package/dist/generated/tools/generator/v1alpha/cre_metadata_pb.d.ts +30 -1
- package/dist/generated/tools/generator/v1alpha/cre_metadata_pb.js +20 -2
- package/dist/generated/workflows/v2/cre_info_pb.d.ts +123 -0
- package/dist/generated/workflows/v2/cre_info_pb.js +17 -0
- package/dist/generated/workflows/v2/workflow_key_pb.d.ts +55 -0
- package/dist/generated/workflows/v2/workflow_key_pb.js +17 -0
- package/dist/generated/workflows/v2/workflow_user_metric_pb.d.ts +118 -0
- package/dist/generated/workflows/v2/workflow_user_metric_pb.js +41 -0
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +63 -0
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +247 -0
- package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +13 -0
- package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +94 -0
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +69 -2
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +403 -1
- package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +5 -1
- package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.js +22 -0
- package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.d.ts +4 -0
- package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.js +12 -0
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +11 -1
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.js +12 -0
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.d.ts +2 -0
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +2 -0
- package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.d.ts +2 -0
- package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +2 -0
- package/dist/sdk/cre/index.d.ts +30 -15
- package/dist/sdk/cre/index.js +29 -14
- package/dist/sdk/impl/runtime-impl.d.ts +28 -1
- package/dist/sdk/impl/runtime-impl.js +52 -1
- package/dist/sdk/runtime.d.ts +23 -1
- package/dist/sdk/tee-constraints.d.ts +68 -0
- package/dist/sdk/tee-constraints.js +59 -0
- package/dist/sdk/test/evm-contract-mock.js +58 -60
- package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +25 -0
- package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +111 -0
- package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.d.ts +19 -1
- package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +141 -1
- package/dist/sdk/test/generated/index.d.ts +1 -0
- package/dist/sdk/test/generated/index.js +1 -0
- package/dist/sdk/test/index.d.ts +0 -1
- package/dist/sdk/test/index.js +0 -1
- package/dist/sdk/testutils/index.d.ts +1 -1
- package/dist/sdk/testutils/index.js +1 -1
- package/dist/sdk/testutils/test-runtime.d.ts +17 -4
- package/dist/sdk/testutils/test-runtime.js +31 -5
- package/dist/sdk/testutils/test-writer.d.ts +7 -1
- package/dist/sdk/testutils/test-writer.js +13 -1
- package/dist/sdk/types/global.d.ts +8 -0
- package/dist/sdk/utils/capabilities/blockchain/{evm/evm-helpers.d.ts → blockchain-helpers.d.ts} +6 -7
- package/dist/sdk/utils/capabilities/blockchain/{evm/evm-helpers.js → blockchain-helpers.js} +8 -6
- package/dist/sdk/utils/hex-utils.d.ts +0 -6
- package/dist/sdk/utils/hex-utils.js +0 -8
- package/dist/sdk/utils/index.d.ts +1 -3
- package/dist/sdk/utils/index.js +1 -2
- package/dist/sdk/wasm/host-bindings.d.ts +4 -0
- package/dist/sdk/wasm/host-bindings.js +4 -0
- package/dist/sdk/wasm/runner.d.ts +10 -4
- package/dist/sdk/wasm/runner.js +86 -13
- package/dist/sdk/wasm/runtime.d.ts +4 -1
- package/dist/sdk/wasm/runtime.js +9 -1
- package/dist/sdk/workflow.d.ts +16 -7
- package/dist/sdk/workflow.js +10 -2
- package/dist/workflows/standard_tests/restrictions/test.ts +41 -0
- package/dist/workflows/standard_tests/tee_runtime/test.ts +29 -0
- package/package.json +3 -6
- package/scripts/src/generate-sdks.ts +6 -0
- package/dist/sdk/test/contract-mock-core.d.ts +0 -16
- package/dist/sdk/test/contract-mock-core.js +0 -21
- package/dist/sdk/test/solana-contract-mock.d.ts +0 -54
- package/dist/sdk/test/solana-contract-mock.js +0 -63
- package/dist/sdk/utils/capabilities/blockchain/report-helpers.d.ts +0 -19
- package/dist/sdk/utils/capabilities/blockchain/report-helpers.js +0 -16
- package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.d.ts +0 -101
- package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.js +0 -100
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import { type WriteReportReply, type WriteReportReplyJson, type WriteReportRequest } from '../../../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
|
|
1
|
+
import { type GetAccountInfoWithOptsReply, type GetAccountInfoWithOptsReplyJson, type GetAccountInfoWithOptsRequest, type GetBalanceReply, type GetBalanceReplyJson, type GetBalanceRequest, type GetBlockReply, type GetBlockReplyJson, type GetBlockRequest, type GetFeeForMessageReply, type GetFeeForMessageReplyJson, type GetFeeForMessageRequest, type GetMultipleAccountsWithOptsReply, type GetMultipleAccountsWithOptsReplyJson, type GetMultipleAccountsWithOptsRequest, type GetProgramAccountsReply, type GetProgramAccountsReplyJson, type GetProgramAccountsRequest, type GetSignatureStatusesReply, type GetSignatureStatusesReplyJson, type GetSignatureStatusesRequest, type GetSlotHeightReply, type GetSlotHeightReplyJson, type GetSlotHeightRequest, type GetTransactionReply, type GetTransactionReplyJson, type GetTransactionRequest, type WriteReportReply, type WriteReportReplyJson, type WriteReportRequest } from '../../../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
|
|
2
2
|
/**
|
|
3
3
|
* Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
4
4
|
* Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
|
|
5
5
|
*/
|
|
6
6
|
export declare class SolanaMock {
|
|
7
7
|
static readonly CAPABILITY_ID = "solana@1.0.0";
|
|
8
|
+
/** Set to define the return value for GetAccountInfoWithOpts. May return a plain object (GetAccountInfoWithOptsReplyJson) or the message type. */
|
|
9
|
+
getAccountInfoWithOpts?: (input: GetAccountInfoWithOptsRequest) => GetAccountInfoWithOptsReply | GetAccountInfoWithOptsReplyJson;
|
|
10
|
+
/** Set to define the return value for GetBalance. May return a plain object (GetBalanceReplyJson) or the message type. */
|
|
11
|
+
getBalance?: (input: GetBalanceRequest) => GetBalanceReply | GetBalanceReplyJson;
|
|
12
|
+
/** Set to define the return value for GetBlock. May return a plain object (GetBlockReplyJson) or the message type. */
|
|
13
|
+
getBlock?: (input: GetBlockRequest) => GetBlockReply | GetBlockReplyJson;
|
|
14
|
+
/** Set to define the return value for GetFeeForMessage. May return a plain object (GetFeeForMessageReplyJson) or the message type. */
|
|
15
|
+
getFeeForMessage?: (input: GetFeeForMessageRequest) => GetFeeForMessageReply | GetFeeForMessageReplyJson;
|
|
16
|
+
/** Set to define the return value for GetMultipleAccountsWithOpts. May return a plain object (GetMultipleAccountsWithOptsReplyJson) or the message type. */
|
|
17
|
+
getMultipleAccountsWithOpts?: (input: GetMultipleAccountsWithOptsRequest) => GetMultipleAccountsWithOptsReply | GetMultipleAccountsWithOptsReplyJson;
|
|
18
|
+
/** Set to define the return value for GetProgramAccounts. May return a plain object (GetProgramAccountsReplyJson) or the message type. */
|
|
19
|
+
getProgramAccounts?: (input: GetProgramAccountsRequest) => GetProgramAccountsReply | GetProgramAccountsReplyJson;
|
|
20
|
+
/** Set to define the return value for GetSignatureStatuses. May return a plain object (GetSignatureStatusesReplyJson) or the message type. */
|
|
21
|
+
getSignatureStatuses?: (input: GetSignatureStatusesRequest) => GetSignatureStatusesReply | GetSignatureStatusesReplyJson;
|
|
22
|
+
/** Set to define the return value for GetSlotHeight. May return a plain object (GetSlotHeightReplyJson) or the message type. */
|
|
23
|
+
getSlotHeight?: (input: GetSlotHeightRequest) => GetSlotHeightReply | GetSlotHeightReplyJson;
|
|
24
|
+
/** Set to define the return value for GetTransaction. May return a plain object (GetTransactionReplyJson) or the message type. */
|
|
25
|
+
getTransaction?: (input: GetTransactionRequest) => GetTransactionReply | GetTransactionReplyJson;
|
|
8
26
|
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
9
27
|
writeReport?: (input: WriteReportRequest) => WriteReportReply | WriteReportReplyJson;
|
|
10
28
|
private constructor();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fromJson } from '@bufbuild/protobuf';
|
|
2
2
|
import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
|
|
3
|
-
import { WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
|
|
3
|
+
import { GetAccountInfoWithOptsReplySchema, GetAccountInfoWithOptsRequestSchema, GetBalanceReplySchema, GetBalanceRequestSchema, GetBlockReplySchema, GetBlockRequestSchema, GetFeeForMessageReplySchema, GetFeeForMessageRequestSchema, GetMultipleAccountsWithOptsReplySchema, GetMultipleAccountsWithOptsRequestSchema, GetProgramAccountsReplySchema, GetProgramAccountsRequestSchema, GetSignatureStatusesReplySchema, GetSignatureStatusesRequestSchema, GetSlotHeightReplySchema, GetSlotHeightRequestSchema, GetTransactionReplySchema, GetTransactionRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
|
|
4
4
|
import { __getTestMockInstance, __setTestMockInstance, registerTestCapability, } from '../../../../../../testutils/test-runtime';
|
|
5
5
|
/**
|
|
6
6
|
* Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
@@ -8,6 +8,24 @@ import { __getTestMockInstance, __setTestMockInstance, registerTestCapability, }
|
|
|
8
8
|
*/
|
|
9
9
|
export class SolanaMock {
|
|
10
10
|
static CAPABILITY_ID = 'solana@1.0.0';
|
|
11
|
+
/** Set to define the return value for GetAccountInfoWithOpts. May return a plain object (GetAccountInfoWithOptsReplyJson) or the message type. */
|
|
12
|
+
getAccountInfoWithOpts;
|
|
13
|
+
/** Set to define the return value for GetBalance. May return a plain object (GetBalanceReplyJson) or the message type. */
|
|
14
|
+
getBalance;
|
|
15
|
+
/** Set to define the return value for GetBlock. May return a plain object (GetBlockReplyJson) or the message type. */
|
|
16
|
+
getBlock;
|
|
17
|
+
/** Set to define the return value for GetFeeForMessage. May return a plain object (GetFeeForMessageReplyJson) or the message type. */
|
|
18
|
+
getFeeForMessage;
|
|
19
|
+
/** Set to define the return value for GetMultipleAccountsWithOpts. May return a plain object (GetMultipleAccountsWithOptsReplyJson) or the message type. */
|
|
20
|
+
getMultipleAccountsWithOpts;
|
|
21
|
+
/** Set to define the return value for GetProgramAccounts. May return a plain object (GetProgramAccountsReplyJson) or the message type. */
|
|
22
|
+
getProgramAccounts;
|
|
23
|
+
/** Set to define the return value for GetSignatureStatuses. May return a plain object (GetSignatureStatusesReplyJson) or the message type. */
|
|
24
|
+
getSignatureStatuses;
|
|
25
|
+
/** Set to define the return value for GetSlotHeight. May return a plain object (GetSlotHeightReplyJson) or the message type. */
|
|
26
|
+
getSlotHeight;
|
|
27
|
+
/** Set to define the return value for GetTransaction. May return a plain object (GetTransactionReplyJson) or the message type. */
|
|
28
|
+
getTransaction;
|
|
11
29
|
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
12
30
|
writeReport;
|
|
13
31
|
constructor(chainSelector) {
|
|
@@ -16,6 +34,128 @@ export class SolanaMock {
|
|
|
16
34
|
try {
|
|
17
35
|
registerTestCapability(qualifiedId, (req) => {
|
|
18
36
|
switch (req.method) {
|
|
37
|
+
case 'GetAccountInfoWithOpts': {
|
|
38
|
+
const input = anyUnpack(req.payload, GetAccountInfoWithOptsRequestSchema);
|
|
39
|
+
const handler = self.getAccountInfoWithOpts;
|
|
40
|
+
if (typeof handler !== 'function')
|
|
41
|
+
throw new Error("GetAccountInfoWithOpts: no implementation provided; set the mock's getAccountInfoWithOpts property to define the return value.");
|
|
42
|
+
const raw = handler(input);
|
|
43
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
44
|
+
? raw
|
|
45
|
+
: fromJson(GetAccountInfoWithOptsReplySchema, raw);
|
|
46
|
+
return {
|
|
47
|
+
response: {
|
|
48
|
+
case: 'payload',
|
|
49
|
+
value: anyPack(GetAccountInfoWithOptsReplySchema, output),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
case 'GetBalance': {
|
|
54
|
+
const input = anyUnpack(req.payload, GetBalanceRequestSchema);
|
|
55
|
+
const handler = self.getBalance;
|
|
56
|
+
if (typeof handler !== 'function')
|
|
57
|
+
throw new Error("GetBalance: no implementation provided; set the mock's getBalance property to define the return value.");
|
|
58
|
+
const raw = handler(input);
|
|
59
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
60
|
+
? raw
|
|
61
|
+
: fromJson(GetBalanceReplySchema, raw);
|
|
62
|
+
return { response: { case: 'payload', value: anyPack(GetBalanceReplySchema, output) } };
|
|
63
|
+
}
|
|
64
|
+
case 'GetBlock': {
|
|
65
|
+
const input = anyUnpack(req.payload, GetBlockRequestSchema);
|
|
66
|
+
const handler = self.getBlock;
|
|
67
|
+
if (typeof handler !== 'function')
|
|
68
|
+
throw new Error("GetBlock: no implementation provided; set the mock's getBlock property to define the return value.");
|
|
69
|
+
const raw = handler(input);
|
|
70
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
71
|
+
? raw
|
|
72
|
+
: fromJson(GetBlockReplySchema, raw);
|
|
73
|
+
return { response: { case: 'payload', value: anyPack(GetBlockReplySchema, output) } };
|
|
74
|
+
}
|
|
75
|
+
case 'GetFeeForMessage': {
|
|
76
|
+
const input = anyUnpack(req.payload, GetFeeForMessageRequestSchema);
|
|
77
|
+
const handler = self.getFeeForMessage;
|
|
78
|
+
if (typeof handler !== 'function')
|
|
79
|
+
throw new Error("GetFeeForMessage: no implementation provided; set the mock's getFeeForMessage property to define the return value.");
|
|
80
|
+
const raw = handler(input);
|
|
81
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
82
|
+
? raw
|
|
83
|
+
: fromJson(GetFeeForMessageReplySchema, raw);
|
|
84
|
+
return {
|
|
85
|
+
response: { case: 'payload', value: anyPack(GetFeeForMessageReplySchema, output) },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
case 'GetMultipleAccountsWithOpts': {
|
|
89
|
+
const input = anyUnpack(req.payload, GetMultipleAccountsWithOptsRequestSchema);
|
|
90
|
+
const handler = self.getMultipleAccountsWithOpts;
|
|
91
|
+
if (typeof handler !== 'function')
|
|
92
|
+
throw new Error("GetMultipleAccountsWithOpts: no implementation provided; set the mock's getMultipleAccountsWithOpts property to define the return value.");
|
|
93
|
+
const raw = handler(input);
|
|
94
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
95
|
+
? raw
|
|
96
|
+
: fromJson(GetMultipleAccountsWithOptsReplySchema, raw);
|
|
97
|
+
return {
|
|
98
|
+
response: {
|
|
99
|
+
case: 'payload',
|
|
100
|
+
value: anyPack(GetMultipleAccountsWithOptsReplySchema, output),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
case 'GetProgramAccounts': {
|
|
105
|
+
const input = anyUnpack(req.payload, GetProgramAccountsRequestSchema);
|
|
106
|
+
const handler = self.getProgramAccounts;
|
|
107
|
+
if (typeof handler !== 'function')
|
|
108
|
+
throw new Error("GetProgramAccounts: no implementation provided; set the mock's getProgramAccounts property to define the return value.");
|
|
109
|
+
const raw = handler(input);
|
|
110
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
111
|
+
? raw
|
|
112
|
+
: fromJson(GetProgramAccountsReplySchema, raw);
|
|
113
|
+
return {
|
|
114
|
+
response: { case: 'payload', value: anyPack(GetProgramAccountsReplySchema, output) },
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
case 'GetSignatureStatuses': {
|
|
118
|
+
const input = anyUnpack(req.payload, GetSignatureStatusesRequestSchema);
|
|
119
|
+
const handler = self.getSignatureStatuses;
|
|
120
|
+
if (typeof handler !== 'function')
|
|
121
|
+
throw new Error("GetSignatureStatuses: no implementation provided; set the mock's getSignatureStatuses property to define the return value.");
|
|
122
|
+
const raw = handler(input);
|
|
123
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
124
|
+
? raw
|
|
125
|
+
: fromJson(GetSignatureStatusesReplySchema, raw);
|
|
126
|
+
return {
|
|
127
|
+
response: {
|
|
128
|
+
case: 'payload',
|
|
129
|
+
value: anyPack(GetSignatureStatusesReplySchema, output),
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
case 'GetSlotHeight': {
|
|
134
|
+
const input = anyUnpack(req.payload, GetSlotHeightRequestSchema);
|
|
135
|
+
const handler = self.getSlotHeight;
|
|
136
|
+
if (typeof handler !== 'function')
|
|
137
|
+
throw new Error("GetSlotHeight: no implementation provided; set the mock's getSlotHeight property to define the return value.");
|
|
138
|
+
const raw = handler(input);
|
|
139
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
140
|
+
? raw
|
|
141
|
+
: fromJson(GetSlotHeightReplySchema, raw);
|
|
142
|
+
return {
|
|
143
|
+
response: { case: 'payload', value: anyPack(GetSlotHeightReplySchema, output) },
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
case 'GetTransaction': {
|
|
147
|
+
const input = anyUnpack(req.payload, GetTransactionRequestSchema);
|
|
148
|
+
const handler = self.getTransaction;
|
|
149
|
+
if (typeof handler !== 'function')
|
|
150
|
+
throw new Error("GetTransaction: no implementation provided; set the mock's getTransaction property to define the return value.");
|
|
151
|
+
const raw = handler(input);
|
|
152
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
153
|
+
? raw
|
|
154
|
+
: fromJson(GetTransactionReplySchema, raw);
|
|
155
|
+
return {
|
|
156
|
+
response: { case: 'payload', value: anyPack(GetTransactionReplySchema, output) },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
19
159
|
case 'WriteReport': {
|
|
20
160
|
const input = anyUnpack(req.payload, WriteReportRequestSchema);
|
|
21
161
|
const handler = self.writeReport;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Auto-generated barrel of capability mocks. Do not edit. */
|
|
2
|
+
export { AptosMock } from './capabilities/blockchain/aptos/v1alpha/aptos_mock_gen';
|
|
2
3
|
export { EvmMock } from './capabilities/blockchain/evm/v1alpha/evm_mock_gen';
|
|
3
4
|
export { SolanaMock } from './capabilities/blockchain/solana/v1alpha/solana_mock_gen';
|
|
4
5
|
export { BasicTestActionTriggerMock } from './capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Auto-generated barrel of capability mocks. Do not edit. */
|
|
2
|
+
export { AptosMock } from './capabilities/blockchain/aptos/v1alpha/aptos_mock_gen';
|
|
2
3
|
export { EvmMock } from './capabilities/blockchain/evm/v1alpha/evm_mock_gen';
|
|
3
4
|
export { SolanaMock } from './capabilities/blockchain/solana/v1alpha/solana_mock_gen';
|
|
4
5
|
export { BasicTestActionTriggerMock } from './capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen';
|
package/dist/sdk/test/index.d.ts
CHANGED
|
@@ -6,4 +6,3 @@ export { type CapabilityHandler, DEFAULT_MAX_RESPONSE_SIZE_BYTES, getTestCapabil
|
|
|
6
6
|
export { TestWriter } from '../testutils/test-writer';
|
|
7
7
|
export { type AddContractMockOptions, addContractMock, type ContractMock, type WriteReportMockInput, } from './evm-contract-mock';
|
|
8
8
|
export * from './generated';
|
|
9
|
-
export { type AddSolanaContractMockOptions, addSolanaContractMock, type SolanaContractMock, type SolanaWriteReportMockInput, } from './solana-contract-mock';
|
package/dist/sdk/test/index.js
CHANGED
|
@@ -6,4 +6,3 @@ export { DEFAULT_MAX_RESPONSE_SIZE_BYTES, getTestCapabilityHandler, newTestRunti
|
|
|
6
6
|
export { TestWriter } from '../testutils/test-writer';
|
|
7
7
|
export { addContractMock, } from './evm-contract-mock';
|
|
8
8
|
export * from './generated';
|
|
9
|
-
export { addSolanaContractMock, } from './solana-contract-mock';
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Test-only utilities for the CRE SDK runtime. Not part of the public API.
|
|
3
3
|
* Use for unit testing runtime logic without the WASM execution environment.
|
|
4
4
|
*/
|
|
5
|
-
export { type CapabilityHandler, DEFAULT_MAX_RESPONSE_SIZE_BYTES, getTestCapabilityHandler, type NewTestRuntimeOptions, newTestRuntime, REPORT_METADATA_HEADER_LENGTH, RESPONSE_BUFFER_TOO_SMALL, registerTestCapability, type Secrets, TestRuntime, type TestRuntimeState, test, } from './test-runtime';
|
|
5
|
+
export { type CapabilityHandler, DEFAULT_MAX_RESPONSE_SIZE_BYTES, getTestCapabilityHandler, type NewTestRuntimeOptions, newTestRuntime, REPORT_METADATA_HEADER_LENGTH, RESPONSE_BUFFER_TOO_SMALL, registerTestCapability, type Secrets, TestRuntime, type TestRuntimeState, TestTeeRuntime, test, } from './test-runtime';
|
|
6
6
|
export { TestWriter } from './test-writer';
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Test-only utilities for the CRE SDK runtime. Not part of the public API.
|
|
3
3
|
* Use for unit testing runtime logic without the WASM execution environment.
|
|
4
4
|
*/
|
|
5
|
-
export { DEFAULT_MAX_RESPONSE_SIZE_BYTES, getTestCapabilityHandler, newTestRuntime, REPORT_METADATA_HEADER_LENGTH, RESPONSE_BUFFER_TOO_SMALL, registerTestCapability, TestRuntime, test, } from './test-runtime';
|
|
5
|
+
export { DEFAULT_MAX_RESPONSE_SIZE_BYTES, getTestCapabilityHandler, newTestRuntime, REPORT_METADATA_HEADER_LENGTH, RESPONSE_BUFFER_TOO_SMALL, registerTestCapability, TestRuntime, TestTeeRuntime, test, } from './test-runtime';
|
|
6
6
|
export { TestWriter } from './test-writer';
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Registry is scoped per test via AsyncLocalStorage; use testWithRuntime to run tests with a registry.
|
|
4
4
|
*/
|
|
5
5
|
import type { Any } from '@bufbuild/protobuf/wkt';
|
|
6
|
+
import type { WorkflowUserMetric } from '../../generated/workflows/v2/workflow_user_metric_pb';
|
|
6
7
|
import type { RuntimeHelpers } from '../impl/runtime-impl';
|
|
7
|
-
import { RuntimeImpl } from '../impl/runtime-impl';
|
|
8
|
+
import { RuntimeImpl, TeeRuntimeImpl } from '../impl/runtime-impl';
|
|
8
9
|
import { TestWriter } from './test-writer';
|
|
9
10
|
/** Error message when response exceeds max size. Used by the harness when its await implements the size check. */
|
|
10
11
|
export declare const RESPONSE_BUFFER_TOO_SMALL = "response buffer too small";
|
|
@@ -70,15 +71,27 @@ export declare function test(title: string, fn: () => void | Promise<void>): voi
|
|
|
70
71
|
/**
|
|
71
72
|
* Creates a test runtime. This must be called from within a test in this package.
|
|
72
73
|
*/
|
|
73
|
-
export declare function newTestRuntime(secrets?: Secrets | null, options?: NewTestRuntimeOptions): TestRuntime
|
|
74
|
+
export declare function newTestRuntime<T = unknown>(secrets?: Secrets | null, options?: NewTestRuntimeOptions, config?: T | undefined): TestRuntime<T>;
|
|
74
75
|
/**
|
|
75
76
|
* TestRuntime is a Runtime implementation for unit tests. Extends RuntimeImpl; construct via newTestRuntime.
|
|
76
77
|
* Adds getLogs() and setTimeProvider(). Registry is accessed via getTestCapabilityHandler when inside testWithRuntime.
|
|
77
78
|
*/
|
|
78
|
-
export declare class TestRuntime extends RuntimeImpl<
|
|
79
|
+
export declare class TestRuntime<T> extends RuntimeImpl<T> {
|
|
79
80
|
private readonly testWriter;
|
|
80
81
|
private readonly state;
|
|
81
|
-
constructor(helpers: RuntimeHelpers, maxResponseSize: bigint, testWriter: TestWriter, state: TestRuntimeState);
|
|
82
|
+
constructor(helpers: RuntimeHelpers, maxResponseSize: bigint, testWriter: TestWriter, state: TestRuntimeState, config?: T | undefined);
|
|
82
83
|
getLogs(): string[];
|
|
83
84
|
setTimeProvider(timeProvider: () => number): void;
|
|
84
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* TestTeeRuntime is a TeeRuntime implementation for unit tests. Extends TeeRuntimeImpl; construct via newTestTEERuntime.
|
|
88
|
+
* Adds getLogs() and setTimeProvider(). Registry is accessed via getTestCapabilityHandler when inside testWithRuntime.
|
|
89
|
+
*/
|
|
90
|
+
export declare class TestTeeRuntime<T> extends TeeRuntimeImpl<T> {
|
|
91
|
+
private readonly testWriter;
|
|
92
|
+
private readonly state;
|
|
93
|
+
constructor(helpers: RuntimeHelpers, maxResponseSize: bigint, testWriter: TestWriter, state: TestRuntimeState, config: T);
|
|
94
|
+
getLogs(): string[];
|
|
95
|
+
getMetrics(): WorkflowUserMetric[];
|
|
96
|
+
setTimeProvider(timeProvider: () => number): void;
|
|
97
|
+
}
|
|
@@ -8,7 +8,7 @@ import { create, toBinary } from '@bufbuild/protobuf';
|
|
|
8
8
|
import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
|
|
9
9
|
import { AttributedSignatureSchema, AwaitCapabilitiesResponseSchema, AwaitSecretsResponseSchema, CapabilityResponseSchema, ReportRequestSchema, ReportResponseSchema, SecretErrorSchema, SecretResponseSchema, SecretResponsesSchema, SecretSchema, SimpleConsensusInputsSchema, } from '../../generated/sdk/v1alpha/sdk_pb';
|
|
10
10
|
import { ValueSchema } from '../../generated/values/v1/values_pb';
|
|
11
|
-
import { RuntimeImpl } from '../impl/runtime-impl';
|
|
11
|
+
import { RuntimeImpl, TeeRuntimeImpl } from '../impl/runtime-impl';
|
|
12
12
|
import { TestWriter } from './test-writer';
|
|
13
13
|
/** Error message when response exceeds max size. Used by the harness when its await implements the size check. */
|
|
14
14
|
export const RESPONSE_BUFFER_TOO_SMALL = 'response buffer too small';
|
|
@@ -239,6 +239,10 @@ function createTestRuntimeHelpers(registry, secrets, testWriter, state, _maxResp
|
|
|
239
239
|
log(message) {
|
|
240
240
|
testWriter.log(message);
|
|
241
241
|
},
|
|
242
|
+
emitMetric(payload) {
|
|
243
|
+
testWriter.emitMetric(payload);
|
|
244
|
+
return true;
|
|
245
|
+
},
|
|
242
246
|
};
|
|
243
247
|
}
|
|
244
248
|
/**
|
|
@@ -258,7 +262,7 @@ export function test(title, fn) {
|
|
|
258
262
|
/**
|
|
259
263
|
* Creates a test runtime. This must be called from within a test in this package.
|
|
260
264
|
*/
|
|
261
|
-
export function newTestRuntime(secrets, options = {}) {
|
|
265
|
+
export function newTestRuntime(secrets, options = {}, config = undefined) {
|
|
262
266
|
const secretsMap = secrets ?? new Map();
|
|
263
267
|
const testWriter = new TestWriter();
|
|
264
268
|
const registry = registryStorage.getStore() ?? new Registry();
|
|
@@ -297,7 +301,7 @@ export function newTestRuntime(secrets, options = {}) {
|
|
|
297
301
|
}
|
|
298
302
|
const maxResponseSize = BigInt(configuredMaxResponseSize);
|
|
299
303
|
const helpers = createTestRuntimeHelpers(registry, secretsMap, testWriter, state, maxResponseSize);
|
|
300
|
-
return new TestRuntime(helpers, maxResponseSize, testWriter, state);
|
|
304
|
+
return new TestRuntime(helpers, maxResponseSize, testWriter, state, config);
|
|
301
305
|
}
|
|
302
306
|
/**
|
|
303
307
|
* TestRuntime is a Runtime implementation for unit tests. Extends RuntimeImpl; construct via newTestRuntime.
|
|
@@ -306,14 +310,36 @@ export function newTestRuntime(secrets, options = {}) {
|
|
|
306
310
|
export class TestRuntime extends RuntimeImpl {
|
|
307
311
|
testWriter;
|
|
308
312
|
state;
|
|
309
|
-
constructor(helpers, maxResponseSize, testWriter, state) {
|
|
310
|
-
super({}, 0, helpers, maxResponseSize);
|
|
313
|
+
constructor(helpers, maxResponseSize, testWriter, state, config = undefined) {
|
|
314
|
+
super(config ?? {}, 0, helpers, maxResponseSize);
|
|
315
|
+
this.testWriter = testWriter;
|
|
316
|
+
this.state = state;
|
|
317
|
+
}
|
|
318
|
+
getLogs() {
|
|
319
|
+
return this.testWriter.getLogs();
|
|
320
|
+
}
|
|
321
|
+
setTimeProvider(timeProvider) {
|
|
322
|
+
this.state.timeProvider = timeProvider;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* TestTeeRuntime is a TeeRuntime implementation for unit tests. Extends TeeRuntimeImpl; construct via newTestTEERuntime.
|
|
327
|
+
* Adds getLogs() and setTimeProvider(). Registry is accessed via getTestCapabilityHandler when inside testWithRuntime.
|
|
328
|
+
*/
|
|
329
|
+
export class TestTeeRuntime extends TeeRuntimeImpl {
|
|
330
|
+
testWriter;
|
|
331
|
+
state;
|
|
332
|
+
constructor(helpers, maxResponseSize, testWriter, state, config) {
|
|
333
|
+
super(config, 0, helpers, maxResponseSize);
|
|
311
334
|
this.testWriter = testWriter;
|
|
312
335
|
this.state = state;
|
|
313
336
|
}
|
|
314
337
|
getLogs() {
|
|
315
338
|
return this.testWriter.getLogs();
|
|
316
339
|
}
|
|
340
|
+
getMetrics() {
|
|
341
|
+
return this.testWriter.getMetrics();
|
|
342
|
+
}
|
|
317
343
|
setTimeProvider(timeProvider) {
|
|
318
344
|
this.state.timeProvider = timeProvider;
|
|
319
345
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { type WorkflowUserMetric } from '../../generated/workflows/v2/workflow_user_metric_pb';
|
|
1
2
|
/**
|
|
2
3
|
* In-memory log sink for tests. Captures messages so tests can assert on log output.
|
|
3
4
|
* Equivalent to Go's cre/testutils/test_writer.go.
|
|
4
5
|
*/
|
|
5
6
|
export declare class TestWriter {
|
|
6
7
|
private logs;
|
|
8
|
+
private metrics;
|
|
7
9
|
/** Appends a message to the captured log buffer. */
|
|
8
10
|
log(message: string): void;
|
|
9
11
|
/** Returns a copy of all captured log messages in order. */
|
|
10
12
|
getLogs(): string[];
|
|
11
|
-
/**
|
|
13
|
+
/** Captures a serialized WorkflowUserMetric payload. */
|
|
14
|
+
emitMetric(payload: Uint8Array): void;
|
|
15
|
+
/** Returns captured metric payloads decoded as `WorkflowUserMetric` protos. */
|
|
16
|
+
getMetrics(): WorkflowUserMetric[];
|
|
17
|
+
/** Clears captured logs and metrics. */
|
|
12
18
|
clear(): void;
|
|
13
19
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { fromBinary } from '@bufbuild/protobuf';
|
|
2
|
+
import { WorkflowUserMetricSchema, } from '../../generated/workflows/v2/workflow_user_metric_pb';
|
|
1
3
|
/**
|
|
2
4
|
* In-memory log sink for tests. Captures messages so tests can assert on log output.
|
|
3
5
|
* Equivalent to Go's cre/testutils/test_writer.go.
|
|
4
6
|
*/
|
|
5
7
|
export class TestWriter {
|
|
6
8
|
logs = [];
|
|
9
|
+
metrics = [];
|
|
7
10
|
/** Appends a message to the captured log buffer. */
|
|
8
11
|
log(message) {
|
|
9
12
|
this.logs.push(message);
|
|
@@ -12,8 +15,17 @@ export class TestWriter {
|
|
|
12
15
|
getLogs() {
|
|
13
16
|
return [...this.logs];
|
|
14
17
|
}
|
|
15
|
-
/**
|
|
18
|
+
/** Captures a serialized WorkflowUserMetric payload. */
|
|
19
|
+
emitMetric(payload) {
|
|
20
|
+
this.metrics.push(payload);
|
|
21
|
+
}
|
|
22
|
+
/** Returns captured metric payloads decoded as `WorkflowUserMetric` protos. */
|
|
23
|
+
getMetrics() {
|
|
24
|
+
return this.metrics.map((bytes) => fromBinary(WorkflowUserMetricSchema, bytes));
|
|
25
|
+
}
|
|
26
|
+
/** Clears captured logs and metrics. */
|
|
16
27
|
clear() {
|
|
17
28
|
this.logs = [];
|
|
29
|
+
this.metrics = [];
|
|
18
30
|
}
|
|
19
31
|
}
|
|
@@ -45,6 +45,14 @@ declare global {
|
|
|
45
45
|
*/
|
|
46
46
|
function log(message: string): void
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Emits a user metric to the host. The payload is a protobuf-encoded
|
|
50
|
+
* `workflows.v2.WorkflowUserMetric` message.
|
|
51
|
+
* @param payload - protobuf-encoded WorkflowUserMetric bytes
|
|
52
|
+
* @returns 0 on success, negative on error (rate-limited, oversized, invalid name, etc.)
|
|
53
|
+
*/
|
|
54
|
+
function emitMetric(payload: Uint8Array): number
|
|
55
|
+
|
|
48
56
|
/**
|
|
49
57
|
* Sends a response back to the host
|
|
50
58
|
* @param response - bytes response
|
package/dist/sdk/utils/capabilities/blockchain/{evm/evm-helpers.d.ts → blockchain-helpers.d.ts}
RENAMED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { CallMsgJson, FilterLogTriggerRequestJson } from '
|
|
2
|
-
import type { ReportRequestJson } from '
|
|
3
|
-
import { type BigInt as GeneratedBigInt } from '
|
|
1
|
+
import type { CallMsgJson, FilterLogTriggerRequestJson } from '../../../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
|
|
2
|
+
import type { ReportRequestJson } from '../../../../generated/sdk/v1alpha/sdk_pb';
|
|
3
|
+
import { type BigInt as GeneratedBigInt } from '../../../../generated/values/v1/values_pb';
|
|
4
4
|
import type { Address, Hex } from 'viem';
|
|
5
|
-
import { type ReportEncoder } from '../report-helpers';
|
|
6
5
|
/**
|
|
7
6
|
* Protobuf BigInt structure returned by SDK methods (e.g., headerByNumber).
|
|
8
7
|
* Uses Pick to extract just the data fields from the generated type.
|
|
@@ -21,7 +20,7 @@ export type ProtoBigInt = Pick<GeneratedBigInt, 'absVal' | 'sign'>;
|
|
|
21
20
|
* @param n - The native bigint, number, or string value.
|
|
22
21
|
* @returns The protobuf BigInt JSON representation.
|
|
23
22
|
*/
|
|
24
|
-
export declare const bigintToProtoBigInt: (n: number | bigint | string) => import("
|
|
23
|
+
export declare const bigintToProtoBigInt: (n: number | bigint | string) => import("../../../../generated/values/v1/values_pb").BigIntJson;
|
|
25
24
|
/**
|
|
26
25
|
* Converts a protobuf BigInt to a native JS bigint.
|
|
27
26
|
* Use this when extracting bigint values from SDK responses.
|
|
@@ -42,7 +41,7 @@ export declare const protoBigIntToBigint: (pb: ProtoBigInt) => bigint;
|
|
|
42
41
|
* @param n - The block number.
|
|
43
42
|
* @returns The protobuf BigInt JSON representation.
|
|
44
43
|
*/
|
|
45
|
-
export declare const blockNumber: (n: number | bigint | string) => import("
|
|
44
|
+
export declare const blockNumber: (n: number | bigint | string) => import("../../../../generated/values/v1/values_pb").BigIntJson;
|
|
46
45
|
/**
|
|
47
46
|
* EVM Capability Helper.
|
|
48
47
|
*
|
|
@@ -107,7 +106,7 @@ export declare const EVM_DEFAULT_REPORT_ENCODER: {
|
|
|
107
106
|
* @param reportEncoder - The report encoder to be used. Defaults to EVM_DEFAULT_REPORT_ENCODER.
|
|
108
107
|
* @returns The prepared report request.
|
|
109
108
|
*/
|
|
110
|
-
export declare const prepareReportRequest: (hexEncodedPayload: Hex, reportEncoder?:
|
|
109
|
+
export declare const prepareReportRequest: (hexEncodedPayload: Hex, reportEncoder?: Omit<ReportRequestJson, "encodedPayload">) => ReportRequestJson;
|
|
111
110
|
export interface LogTriggerConfigOptions {
|
|
112
111
|
/** EVM addresses to monitor — hex strings with 0x prefix (20 bytes each) */
|
|
113
112
|
addresses: Hex[];
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { create, toJson } from '@bufbuild/protobuf';
|
|
2
|
-
import { BigIntSchema } from '
|
|
3
|
-
import { EVMClient } from '
|
|
4
|
-
import { bigintToBytes, bytesToBigint, hexToBase64, hexToBytes } from '
|
|
5
|
-
import { assertSafeIntegerNumber } from '
|
|
6
|
-
import { prepareReportRequestFromBytes } from '../report-helpers';
|
|
2
|
+
import { BigIntSchema } from '../../../../generated/values/v1/values_pb';
|
|
3
|
+
import { EVMClient } from '../../../cre';
|
|
4
|
+
import { bigintToBytes, bytesToBigint, hexToBase64, hexToBytes } from '../../hex-utils';
|
|
5
|
+
import { assertSafeIntegerNumber } from '../../safe-integer';
|
|
7
6
|
/**
|
|
8
7
|
* Converts a native JS bigint to a protobuf BigInt JSON representation.
|
|
9
8
|
* Use this when passing bigint values to SDK methods.
|
|
@@ -127,7 +126,10 @@ export const EVM_DEFAULT_REPORT_ENCODER = {
|
|
|
127
126
|
* @param reportEncoder - The report encoder to be used. Defaults to EVM_DEFAULT_REPORT_ENCODER.
|
|
128
127
|
* @returns The prepared report request.
|
|
129
128
|
*/
|
|
130
|
-
export const prepareReportRequest = (hexEncodedPayload, reportEncoder = EVM_DEFAULT_REPORT_ENCODER) =>
|
|
129
|
+
export const prepareReportRequest = (hexEncodedPayload, reportEncoder = EVM_DEFAULT_REPORT_ENCODER) => ({
|
|
130
|
+
encodedPayload: hexToBase64(hexEncodedPayload),
|
|
131
|
+
...reportEncoder,
|
|
132
|
+
});
|
|
131
133
|
/**
|
|
132
134
|
* Validates a hex string and checks that the decoded bytes have the expected length.
|
|
133
135
|
*/
|
|
@@ -13,12 +13,6 @@ export declare const hexToBytes: (hexStr: string) => Uint8Array;
|
|
|
13
13
|
* Convert Uint8Array to hex string with 0x prefix
|
|
14
14
|
*/
|
|
15
15
|
export declare const bytesToHex: (bytes: Uint8Array) => Hex;
|
|
16
|
-
/**
|
|
17
|
-
* Encode raw bytes as base64 string
|
|
18
|
-
* @param bytes
|
|
19
|
-
* @returns
|
|
20
|
-
*/
|
|
21
|
-
export declare const bytesToBase64: (bytes: Uint8Array) => string;
|
|
22
16
|
/**
|
|
23
17
|
* Encode hex as base64 string
|
|
24
18
|
* @param hex
|
|
@@ -28,14 +28,6 @@ export const bytesToHex = (bytes) => {
|
|
|
28
28
|
.map((b) => b.toString(16).padStart(2, '0'))
|
|
29
29
|
.join('')}`;
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
32
|
-
* Encode raw bytes as base64 string
|
|
33
|
-
* @param bytes
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
export const bytesToBase64 = (bytes) => {
|
|
37
|
-
return Buffer.from(bytes).toString('base64');
|
|
38
|
-
};
|
|
39
31
|
/**
|
|
40
32
|
* Encode hex as base64 string
|
|
41
33
|
* @param hex
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export * from './capabilities/blockchain/
|
|
2
|
-
export type { ReportEncoder } from './capabilities/blockchain/report-helpers';
|
|
3
|
-
export * from './capabilities/blockchain/solana/solana-helpers';
|
|
1
|
+
export * from './capabilities/blockchain/blockchain-helpers';
|
|
4
2
|
export * from './capabilities/http/http-helpers';
|
|
5
3
|
export * from './chain-selectors';
|
|
6
4
|
export * from './decode-json';
|
package/dist/sdk/utils/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export * from './capabilities/blockchain/
|
|
2
|
-
export * from './capabilities/blockchain/solana/solana-helpers';
|
|
1
|
+
export * from './capabilities/blockchain/blockchain-helpers';
|
|
3
2
|
export * from './capabilities/http/http-helpers';
|
|
4
3
|
export * from './chain-selectors';
|
|
5
4
|
export * from './decode-json';
|
|
@@ -11,6 +11,7 @@ export declare const globalHostBindingsSchema: z.ZodObject<{
|
|
|
11
11
|
awaitSecrets: z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>, z.ZodNumber], z.ZodUnknown>, z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>>;
|
|
12
12
|
getWasiArgs: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodString>;
|
|
13
13
|
now: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodNumber>;
|
|
14
|
+
emitMetric: z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>], z.ZodUnknown>, z.ZodNumber>;
|
|
14
15
|
sleep: z.ZodFunction<z.ZodTuple<[z.ZodNumber], z.ZodUnknown>, z.ZodVoid>;
|
|
15
16
|
}, "strip", z.ZodTypeAny, {
|
|
16
17
|
callCapability: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
@@ -18,6 +19,7 @@ export declare const globalHostBindingsSchema: z.ZodObject<{
|
|
|
18
19
|
getSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => any;
|
|
19
20
|
awaitSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
|
|
20
21
|
log: (args_0: string, ...args: unknown[]) => void;
|
|
22
|
+
emitMetric: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
21
23
|
sendResponse: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
22
24
|
switchModes: (args_0: Mode, ...args: unknown[]) => void;
|
|
23
25
|
versionV2: (...args: unknown[]) => void;
|
|
@@ -30,6 +32,7 @@ export declare const globalHostBindingsSchema: z.ZodObject<{
|
|
|
30
32
|
getSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => any;
|
|
31
33
|
awaitSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
|
|
32
34
|
log: (args_0: string, ...args: unknown[]) => void;
|
|
35
|
+
emitMetric: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
33
36
|
sendResponse: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
34
37
|
switchModes: (args_0: Mode, ...args: unknown[]) => void;
|
|
35
38
|
versionV2: (...args: unknown[]) => void;
|
|
@@ -43,6 +46,7 @@ export declare const hostBindings: {
|
|
|
43
46
|
getSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => any;
|
|
44
47
|
awaitSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
|
|
45
48
|
log: (args_0: string, ...args: unknown[]) => void;
|
|
49
|
+
emitMetric: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
46
50
|
sendResponse: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
47
51
|
switchModes: (args_0: Mode, ...args: unknown[]) => void;
|
|
48
52
|
versionV2: (...args: unknown[]) => void;
|
|
@@ -27,6 +27,10 @@ export const globalHostBindingsSchema = z.object({
|
|
|
27
27
|
.returns(z.union([z.instanceof(Uint8Array), z.custom()])),
|
|
28
28
|
getWasiArgs: z.function().args().returns(z.string()),
|
|
29
29
|
now: z.function().args().returns(z.number()),
|
|
30
|
+
emitMetric: z
|
|
31
|
+
.function()
|
|
32
|
+
.args(z.union([z.instanceof(Uint8Array), z.custom()]))
|
|
33
|
+
.returns(z.number()),
|
|
30
34
|
sleep: z.function().args(z.number()).returns(z.void()),
|
|
31
35
|
});
|
|
32
36
|
// Validate global host functions at runtime
|
|
@@ -2,13 +2,19 @@ import { type ExecuteRequest, type ExecutionResult } from '../../generated/sdk/v
|
|
|
2
2
|
import { type ConfigHandlerParams } from '../utils/config';
|
|
3
3
|
import type { SecretsProvider, Workflow } from '../workflow';
|
|
4
4
|
import { Runtime } from './runtime';
|
|
5
|
-
|
|
5
|
+
declare class RunnerBase<TConfig> {
|
|
6
6
|
private readonly config;
|
|
7
7
|
private readonly request;
|
|
8
|
-
|
|
9
|
-
static
|
|
8
|
+
protected constructor(config: TConfig, request: ExecuteRequest);
|
|
9
|
+
protected static newRunnerHelper<TConfig, TIntermediateConfig, TRunner>(newRunner: (config: TConfig, request: ExecuteRequest) => TRunner, configHandlerParams?: ConfigHandlerParams<TConfig, TIntermediateConfig>): Promise<TRunner>;
|
|
10
10
|
private static getRequest;
|
|
11
11
|
run(initFn: (config: TConfig, secretsProvider: SecretsProvider) => Promise<Workflow<TConfig>> | Workflow<TConfig>): Promise<void>;
|
|
12
|
-
handleExecutionPhase
|
|
12
|
+
handleExecutionPhase(req: ExecuteRequest, workflow: Workflow<TConfig>, runtime: Runtime<TConfig>): Promise<ExecutionResult>;
|
|
13
|
+
handlePreHookPhase(req: ExecuteRequest, workflow: Workflow<TConfig>): ExecutionResult;
|
|
13
14
|
handleSubscribePhase(req: ExecuteRequest, workflow: Workflow<TConfig>): ExecutionResult;
|
|
14
15
|
}
|
|
16
|
+
export declare class Runner<TConfig> extends RunnerBase<TConfig> {
|
|
17
|
+
private constructor();
|
|
18
|
+
static newRunner<TConfig, TIntermediateConfig = TConfig>(configHandlerParams?: ConfigHandlerParams<TConfig, TIntermediateConfig>): Promise<Runner<TConfig>>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|