@chainlink/cre-sdk 1.17.0-alpha.3 → 1.17.0-alpha.4
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/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/sdk/v1alpha/sdk_pb.d.ts +6 -2
- package/dist/generated/sdk/v1alpha/sdk_pb.js +5 -1
- 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 +15 -0
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +116 -0
- 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 +12 -2
- 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 +29 -2
- package/dist/sdk/impl/runtime-impl.js +55 -6
- package/dist/sdk/runtime.d.ts +24 -2
- package/dist/sdk/tee-constraints.d.ts +68 -0
- package/dist/sdk/tee-constraints.js +59 -0
- 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/index.d.ts +1 -0
- package/dist/sdk/test/generated/index.js +1 -0
- 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/solana/solana-helpers.js +1 -1
- package/dist/sdk/utils/values/consensus_aggregators.d.ts +16 -8
- package/dist/sdk/utils/values/consensus_aggregators.js +20 -3
- package/dist/sdk/utils/values/serializer_types.d.ts +1 -1
- 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/frequency_list/test.ts +75 -0
- package/dist/workflows/standard_tests/restrictions/test.ts +41 -0
- package/dist/workflows/standard_tests/tee_runtime/test.ts +29 -0
- package/package.json +2 -2
- package/scripts/src/generate-sdks.ts +6 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Requirements } from '../generated/sdk/v1alpha/sdk_pb';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const REGIONS: readonly ["us-west-2"];
|
|
4
|
+
export declare const NITRO_REGIONS: readonly ["us-west-2"];
|
|
5
|
+
declare const regionSchema: z.ZodEnum<["us-west-2"]>;
|
|
6
|
+
declare const nitroRegionSchema: z.ZodEnum<["us-west-2"]>;
|
|
7
|
+
declare const nitroBindingSchema: z.ZodObject<{
|
|
8
|
+
tee: z.ZodLiteral<"nitro">;
|
|
9
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
|
|
10
|
+
}, "strict", z.ZodTypeAny, {
|
|
11
|
+
tee: "nitro";
|
|
12
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
tee: "nitro";
|
|
15
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
declare const teeBindingSchema: z.ZodDiscriminatedUnion<"tee", [z.ZodObject<{
|
|
18
|
+
tee: z.ZodLiteral<"nitro">;
|
|
19
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
|
|
20
|
+
}, "strict", z.ZodTypeAny, {
|
|
21
|
+
tee: "nitro";
|
|
22
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
tee: "nitro";
|
|
25
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
26
|
+
}>]>;
|
|
27
|
+
declare const oneOfTeesSchema: z.ZodArray<z.ZodDiscriminatedUnion<"tee", [z.ZodObject<{
|
|
28
|
+
tee: z.ZodLiteral<"nitro">;
|
|
29
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
|
|
30
|
+
}, "strict", z.ZodTypeAny, {
|
|
31
|
+
tee: "nitro";
|
|
32
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
tee: "nitro";
|
|
35
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
36
|
+
}>]>, "atleastone">;
|
|
37
|
+
declare const anyTeeConstraintSchema: z.ZodObject<{
|
|
38
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
|
|
39
|
+
}, "strict", z.ZodTypeAny, {
|
|
40
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
export declare const teeConstraintSchema: z.ZodUnion<[z.ZodArray<z.ZodDiscriminatedUnion<"tee", [z.ZodObject<{
|
|
45
|
+
tee: z.ZodLiteral<"nitro">;
|
|
46
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
|
|
47
|
+
}, "strict", z.ZodTypeAny, {
|
|
48
|
+
tee: "nitro";
|
|
49
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
tee: "nitro";
|
|
52
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
53
|
+
}>]>, "atleastone">, z.ZodObject<{
|
|
54
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
|
|
55
|
+
}, "strict", z.ZodTypeAny, {
|
|
56
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
|
|
59
|
+
}>]>;
|
|
60
|
+
export type Region = z.infer<typeof regionSchema>;
|
|
61
|
+
export type NitroRegion = z.infer<typeof nitroRegionSchema>;
|
|
62
|
+
export type NitroBinding = z.infer<typeof nitroBindingSchema>;
|
|
63
|
+
export type TeeBinding = z.infer<typeof teeBindingSchema>;
|
|
64
|
+
export type OneOfTees = z.infer<typeof oneOfTeesSchema>;
|
|
65
|
+
export type AnyTeeConstraint = z.infer<typeof anyTeeConstraintSchema>;
|
|
66
|
+
export type TeeConstraint = z.infer<typeof teeConstraintSchema>;
|
|
67
|
+
export declare function buildTeeRequirements(input: TeeConstraint): Requirements;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { create } from '@bufbuild/protobuf';
|
|
2
|
+
import { RegionsSchema, RequirementsSchema, TeeSchema, TeeType, TeeTypesAndRegionsSchema, } from '../generated/sdk/v1alpha/sdk_pb';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
// --- Region schemas (source of truth) ---
|
|
5
|
+
export const REGIONS = ['us-west-2'];
|
|
6
|
+
export const NITRO_REGIONS = ['us-west-2'];
|
|
7
|
+
const regionSchema = z.enum(REGIONS, {
|
|
8
|
+
message: `unknown region; expected one of: ${REGIONS.join(', ')}`,
|
|
9
|
+
});
|
|
10
|
+
const nitroRegionSchema = z.enum(NITRO_REGIONS, {
|
|
11
|
+
message: `aws nitro does not support this region; expected one of: ${NITRO_REGIONS.join(', ')}`,
|
|
12
|
+
});
|
|
13
|
+
// --- TeeConstraint schemas (types inferred from these) ---
|
|
14
|
+
const nitroBindingSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
tee: z.literal('nitro'),
|
|
17
|
+
regions: z.array(nitroRegionSchema).nonempty().optional(),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
const teeBindingSchema = z.discriminatedUnion('tee', [nitroBindingSchema]);
|
|
21
|
+
const oneOfTeesSchema = z.array(teeBindingSchema).nonempty();
|
|
22
|
+
const anyTeeConstraintSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
regions: z.array(regionSchema).nonempty().optional(),
|
|
25
|
+
})
|
|
26
|
+
.strict();
|
|
27
|
+
export const teeConstraintSchema = z.union([oneOfTeesSchema, anyTeeConstraintSchema]);
|
|
28
|
+
// --- Conversion to protobuf Requirements ---
|
|
29
|
+
export function buildTeeRequirements(input) {
|
|
30
|
+
const parsed = teeConstraintSchema.parse(input);
|
|
31
|
+
if (Array.isArray(parsed)) {
|
|
32
|
+
const teeTypes = parsed.map((binding) => ({
|
|
33
|
+
type: teeTypeFromBinding(binding),
|
|
34
|
+
regions: binding.regions ?? [],
|
|
35
|
+
}));
|
|
36
|
+
return create(RequirementsSchema, {
|
|
37
|
+
tee: create(TeeSchema, {
|
|
38
|
+
item: {
|
|
39
|
+
case: 'teeTypesAndRegions',
|
|
40
|
+
value: create(TeeTypesAndRegionsSchema, { teeTypeAndRegions: teeTypes }),
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return create(RequirementsSchema, {
|
|
46
|
+
tee: create(TeeSchema, {
|
|
47
|
+
item: {
|
|
48
|
+
case: 'anyRegions',
|
|
49
|
+
value: create(RegionsSchema, { regions: parsed.regions ?? [] }),
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function teeTypeFromBinding(binding) {
|
|
55
|
+
switch (binding.tee) {
|
|
56
|
+
case 'nitro':
|
|
57
|
+
return TeeType.AWS_NITRO;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type AccountAPTBalanceReply, type AccountAPTBalanceReplyJson, type AccountAPTBalanceRequest, type AccountTransactionsReply, type AccountTransactionsReplyJson, type AccountTransactionsRequest, type TransactionByHashReply, type TransactionByHashReplyJson, type TransactionByHashRequest, type ViewReply, type ViewReplyJson, type ViewRequest, type WriteReportReply, type WriteReportReplyJson, type WriteReportRequest } from '../../../../../../../generated/capabilities/blockchain/aptos/v1alpha/client_pb';
|
|
2
|
+
/**
|
|
3
|
+
* Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
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
|
+
*/
|
|
6
|
+
export declare class AptosMock {
|
|
7
|
+
static readonly CAPABILITY_ID = "aptos@1.0.0";
|
|
8
|
+
/** Set to define the return value for AccountAPTBalance. May return a plain object (AccountAPTBalanceReplyJson) or the message type. */
|
|
9
|
+
accountAPTBalance?: (input: AccountAPTBalanceRequest) => AccountAPTBalanceReply | AccountAPTBalanceReplyJson;
|
|
10
|
+
/** Set to define the return value for View. May return a plain object (ViewReplyJson) or the message type. */
|
|
11
|
+
view?: (input: ViewRequest) => ViewReply | ViewReplyJson;
|
|
12
|
+
/** Set to define the return value for TransactionByHash. May return a plain object (TransactionByHashReplyJson) or the message type. */
|
|
13
|
+
transactionByHash?: (input: TransactionByHashRequest) => TransactionByHashReply | TransactionByHashReplyJson;
|
|
14
|
+
/** Set to define the return value for AccountTransactions. May return a plain object (AccountTransactionsReplyJson) or the message type. */
|
|
15
|
+
accountTransactions?: (input: AccountTransactionsRequest) => AccountTransactionsReply | AccountTransactionsReplyJson;
|
|
16
|
+
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
17
|
+
writeReport?: (input: WriteReportRequest) => WriteReportReply | WriteReportReplyJson;
|
|
18
|
+
private constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Returns the mock instance for this capability and the specified tags.
|
|
21
|
+
* Multiple calls with the same tag values return the same instance.
|
|
22
|
+
* Must be called within the test framework's test() method.
|
|
23
|
+
*/
|
|
24
|
+
static testInstance(chainSelector: bigint): AptosMock;
|
|
25
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
+
import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
|
|
3
|
+
import { AccountAPTBalanceReplySchema, AccountAPTBalanceRequestSchema, AccountTransactionsReplySchema, AccountTransactionsRequestSchema, TransactionByHashReplySchema, TransactionByHashRequestSchema, ViewReplySchema, ViewRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/aptos/v1alpha/client_pb';
|
|
4
|
+
import { __getTestMockInstance, __setTestMockInstance, registerTestCapability, } from '../../../../../../testutils/test-runtime';
|
|
5
|
+
/**
|
|
6
|
+
* Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
7
|
+
* Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
|
|
8
|
+
*/
|
|
9
|
+
export class AptosMock {
|
|
10
|
+
static CAPABILITY_ID = 'aptos@1.0.0';
|
|
11
|
+
/** Set to define the return value for AccountAPTBalance. May return a plain object (AccountAPTBalanceReplyJson) or the message type. */
|
|
12
|
+
accountAPTBalance;
|
|
13
|
+
/** Set to define the return value for View. May return a plain object (ViewReplyJson) or the message type. */
|
|
14
|
+
view;
|
|
15
|
+
/** Set to define the return value for TransactionByHash. May return a plain object (TransactionByHashReplyJson) or the message type. */
|
|
16
|
+
transactionByHash;
|
|
17
|
+
/** Set to define the return value for AccountTransactions. May return a plain object (AccountTransactionsReplyJson) or the message type. */
|
|
18
|
+
accountTransactions;
|
|
19
|
+
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
20
|
+
writeReport;
|
|
21
|
+
constructor(chainSelector) {
|
|
22
|
+
const self = this;
|
|
23
|
+
const qualifiedId = `aptos:ChainSelector:${chainSelector}@1.0.0`;
|
|
24
|
+
try {
|
|
25
|
+
registerTestCapability(qualifiedId, (req) => {
|
|
26
|
+
switch (req.method) {
|
|
27
|
+
case 'AccountAPTBalance': {
|
|
28
|
+
const input = anyUnpack(req.payload, AccountAPTBalanceRequestSchema);
|
|
29
|
+
const handler = self.accountAPTBalance;
|
|
30
|
+
if (typeof handler !== 'function')
|
|
31
|
+
throw new Error("AccountAPTBalance: no implementation provided; set the mock's accountAPTBalance property to define the return value.");
|
|
32
|
+
const raw = handler(input);
|
|
33
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
34
|
+
? raw
|
|
35
|
+
: fromJson(AccountAPTBalanceReplySchema, raw);
|
|
36
|
+
return {
|
|
37
|
+
response: { case: 'payload', value: anyPack(AccountAPTBalanceReplySchema, output) },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
case 'View': {
|
|
41
|
+
const input = anyUnpack(req.payload, ViewRequestSchema);
|
|
42
|
+
const handler = self.view;
|
|
43
|
+
if (typeof handler !== 'function')
|
|
44
|
+
throw new Error("View: no implementation provided; set the mock's view property to define the return value.");
|
|
45
|
+
const raw = handler(input);
|
|
46
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
47
|
+
? raw
|
|
48
|
+
: fromJson(ViewReplySchema, raw);
|
|
49
|
+
return { response: { case: 'payload', value: anyPack(ViewReplySchema, output) } };
|
|
50
|
+
}
|
|
51
|
+
case 'TransactionByHash': {
|
|
52
|
+
const input = anyUnpack(req.payload, TransactionByHashRequestSchema);
|
|
53
|
+
const handler = self.transactionByHash;
|
|
54
|
+
if (typeof handler !== 'function')
|
|
55
|
+
throw new Error("TransactionByHash: no implementation provided; set the mock's transactionByHash property to define the return value.");
|
|
56
|
+
const raw = handler(input);
|
|
57
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
58
|
+
? raw
|
|
59
|
+
: fromJson(TransactionByHashReplySchema, raw);
|
|
60
|
+
return {
|
|
61
|
+
response: { case: 'payload', value: anyPack(TransactionByHashReplySchema, output) },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
case 'AccountTransactions': {
|
|
65
|
+
const input = anyUnpack(req.payload, AccountTransactionsRequestSchema);
|
|
66
|
+
const handler = self.accountTransactions;
|
|
67
|
+
if (typeof handler !== 'function')
|
|
68
|
+
throw new Error("AccountTransactions: no implementation provided; set the mock's accountTransactions property to define the return value.");
|
|
69
|
+
const raw = handler(input);
|
|
70
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
71
|
+
? raw
|
|
72
|
+
: fromJson(AccountTransactionsReplySchema, raw);
|
|
73
|
+
return {
|
|
74
|
+
response: { case: 'payload', value: anyPack(AccountTransactionsReplySchema, output) },
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
case 'WriteReport': {
|
|
78
|
+
const input = anyUnpack(req.payload, WriteReportRequestSchema);
|
|
79
|
+
const handler = self.writeReport;
|
|
80
|
+
if (typeof handler !== 'function')
|
|
81
|
+
throw new Error("WriteReport: no implementation provided; set the mock's writeReport property to define the return value.");
|
|
82
|
+
const raw = handler(input);
|
|
83
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
84
|
+
? raw
|
|
85
|
+
: fromJson(WriteReportReplySchema, raw);
|
|
86
|
+
return { response: { case: 'payload', value: anyPack(WriteReportReplySchema, output) } };
|
|
87
|
+
}
|
|
88
|
+
default:
|
|
89
|
+
return { response: { case: 'error', value: `unknown method ${req.method}` } };
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
throw new Error("Capability mocks must be used within the CRE test framework's test() method.");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns the mock instance for this capability and the specified tags.
|
|
99
|
+
* Multiple calls with the same tag values return the same instance.
|
|
100
|
+
* Must be called within the test framework's test() method.
|
|
101
|
+
*/
|
|
102
|
+
static testInstance(chainSelector) {
|
|
103
|
+
const qualifiedId = `aptos:ChainSelector:${chainSelector}@1.0.0`;
|
|
104
|
+
let instance = __getTestMockInstance(qualifiedId);
|
|
105
|
+
if (!instance) {
|
|
106
|
+
instance = new AptosMock(chainSelector);
|
|
107
|
+
__setTestMockInstance(qualifiedId, instance);
|
|
108
|
+
}
|
|
109
|
+
return instance;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -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';
|
|
@@ -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
|
|
@@ -133,7 +133,7 @@ export const prepareSubkeyValue = (value) => {
|
|
|
133
133
|
return u64BE(value);
|
|
134
134
|
}
|
|
135
135
|
if (typeof value === 'number') {
|
|
136
|
-
if (!Number.
|
|
136
|
+
if (!Number.isSafeInteger(value)) {
|
|
137
137
|
throw new Error('prepareSubkeyValue: non-integer number; use prepareSubkeyFloatValue for f32/f64 values');
|
|
138
138
|
}
|
|
139
139
|
return u64BE(BigInt(value));
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { type ConsensusDescriptor } from '../../../generated/sdk/v1alpha/sdk_pb';
|
|
2
2
|
import type { CreSerializable, NumericType, TypeVerifier } from './serializer_types';
|
|
3
|
-
|
|
3
|
+
import { Int64 } from './value';
|
|
4
|
+
export type ConsensusAggregation<TInput, TOutput, U> = {
|
|
4
5
|
readonly descriptor: ConsensusDescriptor;
|
|
5
|
-
readonly defaultValue?:
|
|
6
|
-
withDefault(t:
|
|
6
|
+
readonly defaultValue?: TInput;
|
|
7
|
+
withDefault(t: TInput): ConsensusAggregation<TInput, TOutput, U>;
|
|
7
8
|
_usesUToForceShape(u: U): void;
|
|
8
9
|
};
|
|
9
|
-
export declare function consensusMedianAggregation<T extends NumericType>(): ConsensusAggregation<T, TypeVerifier<T, CreSerializable<T>>>;
|
|
10
|
-
export declare function consensusIdenticalAggregation<T>(): ConsensusAggregation<T, TypeVerifier<T, CreSerializable<T>>>;
|
|
11
|
-
export declare function consensusCommonPrefixAggregation<T>(): ConsensusAggregation<T[], TypeVerifier<T[], CreSerializable<T[]>>>;
|
|
12
|
-
export declare function consensusCommonSuffixAggregation<T>(): ConsensusAggregation<T[], TypeVerifier<T[], CreSerializable<T[]>>>;
|
|
10
|
+
export declare function consensusMedianAggregation<T extends NumericType>(): ConsensusAggregation<T, T, TypeVerifier<T, CreSerializable<T>>>;
|
|
11
|
+
export declare function consensusIdenticalAggregation<T>(): ConsensusAggregation<T, T, TypeVerifier<T, CreSerializable<T>>>;
|
|
12
|
+
export declare function consensusCommonPrefixAggregation<T>(): ConsensusAggregation<T[], T[], TypeVerifier<T[], CreSerializable<T[]>>>;
|
|
13
|
+
export declare function consensusCommonSuffixAggregation<T>(): ConsensusAggregation<T[], T[], TypeVerifier<T[], CreSerializable<T[]>>>;
|
|
14
|
+
export declare class FrequencyListEntry<T> {
|
|
15
|
+
value: T;
|
|
16
|
+
count: Int64;
|
|
17
|
+
constructor(value: T, count: Int64);
|
|
18
|
+
}
|
|
19
|
+
export declare function consensusFrequencyListAggregation<T>(): ConsensusAggregation<T[], FrequencyListEntry<T>[], TypeVerifier<T[], CreSerializable<T[]>>>;
|
|
13
20
|
export declare function median<T extends NumericType>(): ConsensusFieldAggregation<T, true>;
|
|
14
21
|
export declare function identical<T>(): ConsensusFieldAggregation<T, TypeVerifier<T, CreSerializable<T>>>;
|
|
15
22
|
export declare function commonPrefix<T>(): ConsensusFieldAggregation<T[], TypeVerifier<T[], CreSerializable<T[]>>>;
|
|
16
23
|
export declare function commonSuffix<T>(): ConsensusFieldAggregation<T[], TypeVerifier<T[], CreSerializable<T[]>>>;
|
|
24
|
+
export declare function frequencyList<T>(): ConsensusFieldAggregation<T, TypeVerifier<T, CreSerializable<T>>>;
|
|
17
25
|
export declare function ignore<T>(): ConsensusFieldAggregation<T, true>;
|
|
18
26
|
export declare class ConsensusFieldAggregation<T, U> {
|
|
19
27
|
fieldDescriptor?: ConsensusDescriptor | undefined;
|
|
@@ -24,4 +32,4 @@ export declare class ConsensusFieldAggregation<T, U> {
|
|
|
24
32
|
export type ConsensusAggregationFields<T extends object> = {
|
|
25
33
|
[K in keyof T as K extends '$typeName' ? never : K]: () => ConsensusFieldAggregation<T[K], true>;
|
|
26
34
|
};
|
|
27
|
-
export declare function ConsensusAggregationByFields<T extends object>(aggregation: ConsensusAggregationFields<T>): ConsensusAggregation<T, true>;
|
|
35
|
+
export declare function ConsensusAggregationByFields<T extends object, TOutput = T>(aggregation: ConsensusAggregationFields<T>): ConsensusAggregation<T, TOutput, true>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { create } from '@bufbuild/protobuf';
|
|
2
2
|
import { AggregationType, ConsensusDescriptorSchema, FieldsMapSchema, } from '../../../generated/sdk/v1alpha/sdk_pb';
|
|
3
|
-
|
|
4
|
-
// Only take one type, but make the return type ConsensusAggregation<T, TypeVerifier<T, CreSerializable<T>>
|
|
5
|
-
// Similar for fields, but ignore would always return ConsensusAggregationFields<T, true> instead of ConsensusAggregationFields<T, CreSerializable<T>>, and so would ConsensusAggregationByFields :D
|
|
3
|
+
import { Int64 } from './value';
|
|
6
4
|
export function consensusMedianAggregation() {
|
|
7
5
|
return simpleConsensus(AggregationType.MEDIAN);
|
|
8
6
|
}
|
|
@@ -15,6 +13,17 @@ export function consensusCommonPrefixAggregation() {
|
|
|
15
13
|
export function consensusCommonSuffixAggregation() {
|
|
16
14
|
return simpleConsensus(AggregationType.COMMON_SUFFIX);
|
|
17
15
|
}
|
|
16
|
+
export class FrequencyListEntry {
|
|
17
|
+
value;
|
|
18
|
+
count;
|
|
19
|
+
constructor(value, count) {
|
|
20
|
+
this.value = value;
|
|
21
|
+
this.count = count;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function consensusFrequencyListAggregation() {
|
|
25
|
+
return simpleConsensus(AggregationType.FREQUENCY_LIST);
|
|
26
|
+
}
|
|
18
27
|
class ConsensusImpl {
|
|
19
28
|
descriptor;
|
|
20
29
|
defaultValue;
|
|
@@ -51,6 +60,9 @@ export function commonPrefix() {
|
|
|
51
60
|
export function commonSuffix() {
|
|
52
61
|
return new ConsensusFieldAggregation(simpleDescriptor(AggregationType.COMMON_SUFFIX));
|
|
53
62
|
}
|
|
63
|
+
export function frequencyList() {
|
|
64
|
+
return new ConsensusFieldAggregation(simpleDescriptor(AggregationType.FREQUENCY_LIST));
|
|
65
|
+
}
|
|
54
66
|
export function ignore() {
|
|
55
67
|
return new ConsensusFieldAggregation();
|
|
56
68
|
}
|
|
@@ -66,6 +78,11 @@ export class ConsensusFieldAggregation {
|
|
|
66
78
|
this.u = u;
|
|
67
79
|
}
|
|
68
80
|
}
|
|
81
|
+
// TOutput lets the consensus result type differ from the observed input type. It defaults to T
|
|
82
|
+
// (most field aggregators return the same shape they consume), but aggregators that reshape a
|
|
83
|
+
// field — e.g. `frequencyList`, which turns a field of type F into FrequencyListEntry<F>[] —
|
|
84
|
+
// change the result. Pass TOutput explicitly in that case so `.result()` is typed correctly
|
|
85
|
+
// instead of forcing callers to cast (`.result() as unknown as ...`).
|
|
69
86
|
export function ConsensusAggregationByFields(aggregation) {
|
|
70
87
|
const fieldMap = create(FieldsMapSchema);
|
|
71
88
|
Object.keys(aggregation).forEach((key) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Decimal, Int64, UInt64 } from './value';
|
|
2
2
|
export type NumericType = number | bigint | Date | Decimal | Int64 | UInt64;
|
|
3
|
-
export type PrimitiveTypes = NumericType | boolean | string;
|
|
3
|
+
export type PrimitiveTypes = NumericType | boolean | string | Uint8Array;
|
|
4
4
|
export type NonSerializable = null | Map<unknown, unknown> | Set<unknown> | RegExp | Int8Array | Promise<unknown>;
|
|
5
5
|
export type CreSerializableNested<T> = T extends PrimitiveTypes ? T : T extends Function ? T : T extends NonSerializable ? never : T extends any[] ? CreSerializableNested<T[number]>[] : T extends object ? {
|
|
6
6
|
[K in keyof T]: CreSerializableNested<T[K]>;
|
|
@@ -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;
|