@chainlink/cre-sdk 0.0.1-alpha → 0.0.2-alpha
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/internal/nodeaction/v1/node_action_pb.d.ts +69 -0
- package/dist/generated/capabilities/internal/nodeaction/v1/node_action_pb.js +29 -0
- package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +13 -18
- package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +71 -260
- package/dist/generated-sdk/capabilities/internal/actionandtrigger/v1/basic_sdk_gen.d.ts +4 -9
- package/dist/generated-sdk/capabilities/internal/actionandtrigger/v1/basic_sdk_gen.js +14 -45
- package/dist/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen.d.ts +3 -7
- package/dist/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen.js +9 -36
- package/dist/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen.d.ts +2 -8
- package/dist/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen.js +8 -21
- package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +5 -8
- package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.js +16 -60
- package/dist/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen.d.ts +19 -0
- package/dist/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen.js +36 -0
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +3 -7
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.js +9 -36
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.d.ts +2 -8
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +8 -21
- package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.d.ts +2 -8
- package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +8 -21
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/sdk/cre/index.d.ts +5 -19
- package/dist/sdk/cre/index.js +1 -17
- package/dist/sdk/errors.d.ts +12 -0
- package/dist/sdk/errors.js +21 -0
- package/dist/sdk/impl/runtime-impl.d.ts +38 -0
- package/dist/sdk/impl/runtime-impl.js +190 -0
- package/dist/sdk/impl/runtime-impl.test.js +334 -0
- package/dist/sdk/index.d.ts +3 -0
- package/dist/sdk/index.js +2 -0
- package/dist/sdk/runtime.d.ts +24 -0
- package/dist/sdk/utils/capabilities/capability-error.d.ts +0 -3
- package/dist/sdk/utils/capabilities/capability-error.js +0 -2
- package/dist/sdk/utils/config/configHandler.test.d.ts +1 -0
- package/dist/sdk/utils/config/configHandler.test.js +193 -0
- package/dist/sdk/utils/config/index.d.ts +4 -6
- package/dist/sdk/utils/config/index.js +10 -34
- package/dist/sdk/utils/index.d.ts +0 -3
- package/dist/sdk/utils/index.js +0 -3
- package/dist/sdk/utils/values/consensus_aggregators.d.ts +1 -1
- package/dist/sdk/{runtime → wasm}/host-bindings.d.ts +0 -1
- package/dist/sdk/{runtime → wasm}/host-bindings.js +0 -4
- package/dist/sdk/wasm/index.d.ts +1 -0
- package/dist/sdk/wasm/index.js +1 -0
- package/dist/sdk/wasm/runner.d.ts +14 -0
- package/dist/sdk/wasm/runner.js +114 -0
- package/dist/sdk/wasm/runner.test.d.ts +1 -0
- package/dist/sdk/wasm/runner.test.js +270 -0
- package/dist/sdk/wasm/runtime.d.ts +7 -0
- package/dist/sdk/wasm/runtime.js +55 -0
- package/dist/sdk/workflow.d.ts +13 -15
- package/dist/sdk/workflow.js +1 -21
- package/package.json +2 -2
- package/dist/sdk/engine/execute.d.ts +0 -4
- package/dist/sdk/engine/execute.js +0 -12
- package/dist/sdk/engine/execute.test.js +0 -129
- package/dist/sdk/engine/handleExecutionPhase.d.ts +0 -4
- package/dist/sdk/engine/handleExecutionPhase.js +0 -34
- package/dist/sdk/engine/handleSubscribePhase.d.ts +0 -3
- package/dist/sdk/engine/handleSubscribePhase.js +0 -23
- package/dist/sdk/logger.d.ts +0 -7
- package/dist/sdk/logger.js +0 -18
- package/dist/sdk/runtime/errors.d.ts +0 -23
- package/dist/sdk/runtime/errors.js +0 -30
- package/dist/sdk/runtime/index.d.ts +0 -3
- package/dist/sdk/runtime/index.js +0 -2
- package/dist/sdk/runtime/run-in-node-mode.d.ts +0 -12
- package/dist/sdk/runtime/run-in-node-mode.js +0 -47
- package/dist/sdk/runtime/run-in-node-mode.test.js +0 -116
- package/dist/sdk/runtime/runtime.d.ts +0 -36
- package/dist/sdk/runtime/runtime.js +0 -84
- package/dist/sdk/runtime/runtime.test.d.ts +0 -1
- package/dist/sdk/runtime/runtime.test.js +0 -58
- package/dist/sdk/testhelpers/dangerously-call-capability.d.ts +0 -10
- package/dist/sdk/testhelpers/dangerously-call-capability.js +0 -26
- package/dist/sdk/testhelpers/mock-host-bindings.d.ts +0 -15
- package/dist/sdk/testhelpers/mock-host-bindings.js +0 -25
- package/dist/sdk/testhelpers/mock-runtime.d.ts +0 -2
- package/dist/sdk/testhelpers/mock-runtime.js +0 -16
- package/dist/sdk/utils/await-async-request.d.ts +0 -9
- package/dist/sdk/utils/await-async-request.js +0 -27
- package/dist/sdk/utils/capabilities/call-capability.d.ts +0 -22
- package/dist/sdk/utils/capabilities/call-capability.js +0 -33
- package/dist/sdk/utils/capabilities/callback-id.d.ts +0 -3
- package/dist/sdk/utils/capabilities/callback-id.js +0 -22
- package/dist/sdk/utils/capabilities/http/fetch.d.ts +0 -44
- package/dist/sdk/utils/capabilities/http/fetch.js +0 -63
- package/dist/sdk/utils/do-request-async.d.ts +0 -12
- package/dist/sdk/utils/do-request-async.js +0 -17
- package/dist/sdk/utils/error-boundary.d.ts +0 -2
- package/dist/sdk/utils/error-boundary.js +0 -30
- package/dist/sdk/utils/get-request.d.ts +0 -1
- package/dist/sdk/utils/get-request.js +0 -15
- package/dist/sdk/utils/lazy-promise.d.ts +0 -59
- package/dist/sdk/utils/lazy-promise.js +0 -81
- package/dist/sdk/utils/random/get-rand.d.ts +0 -3
- package/dist/sdk/utils/random/get-rand.js +0 -6
- package/dist/sdk/utils/random/random.d.ts +0 -35
- package/dist/sdk/utils/random/random.js +0 -123
- package/dist/sdk/utils/secrets/await-async-secret.d.ts +0 -1
- package/dist/sdk/utils/secrets/await-async-secret.js +0 -29
- package/dist/sdk/utils/secrets/do-get-secret.d.ts +0 -1
- package/dist/sdk/utils/secrets/do-get-secret.js +0 -14
- package/dist/sdk/utils/secrets/get-secret.d.ts +0 -1
- package/dist/sdk/utils/secrets/get-secret.js +0 -10
- package/dist/sdk/utils/send-error.d.ts +0 -1
- package/dist/sdk/utils/send-error.js +0 -16
- package/dist/sdk/utils/send-response-value.d.ts +0 -2
- package/dist/sdk/utils/send-response-value.js +0 -15
- package/dist/sdk/utils/time/get-time.d.ts +0 -16
- package/dist/sdk/utils/time/get-time.js +0 -21
- /package/dist/sdk/{engine/execute.test.d.ts → impl/runtime-impl.test.d.ts} +0 -0
- /package/dist/sdk/{runtime/run-in-node-mode.test.d.ts → runtime.js} +0 -0
|
@@ -1,81 +1,53 @@
|
|
|
1
|
-
import { create,
|
|
2
|
-
import { AnySchema } from '@bufbuild/protobuf/wkt';
|
|
1
|
+
import { create, fromJson } from '@bufbuild/protobuf';
|
|
2
|
+
import { AnySchema, anyPack } from '@bufbuild/protobuf/wkt';
|
|
3
3
|
import { ConfigSchema, InputSchema, OutputSchema, TriggerEventSchema, } from '../../../../../generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb';
|
|
4
|
-
import {
|
|
5
|
-
import { callCapability } from '../../../../../sdk/utils/capabilities/call-capability';
|
|
6
|
-
import { CapabilityError } from '../../../../../sdk/utils/capabilities/capability-error';
|
|
4
|
+
import {} from '../../../../../sdk/runtime';
|
|
7
5
|
import {} from '../../../../../sdk/utils/triggers/trigger-interface';
|
|
8
|
-
import { getTypeUrl } from '../../../../../sdk/utils/typeurl';
|
|
9
6
|
/**
|
|
10
7
|
* Basic Capability
|
|
11
8
|
*
|
|
12
9
|
* Capability ID: basic-test-action-trigger@1.0.0
|
|
13
|
-
* Default Mode: Mode.DON
|
|
14
10
|
* Capability Name: basic-test-action-trigger
|
|
15
11
|
* Capability Version: 1.0.0
|
|
16
12
|
*/
|
|
17
13
|
export class BasicCapability {
|
|
18
|
-
mode;
|
|
19
14
|
/** The capability ID for this service */
|
|
20
15
|
static CAPABILITY_ID = 'basic-test-action-trigger@1.0.0';
|
|
21
|
-
/** The default execution mode for this capability */
|
|
22
|
-
static DEFAULT_MODE = Mode.DON;
|
|
23
16
|
static CAPABILITY_NAME = 'basic-test-action-trigger';
|
|
24
17
|
static CAPABILITY_VERSION = '1.0.0';
|
|
25
|
-
constructor(
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
action(input) {
|
|
18
|
+
constructor() { }
|
|
19
|
+
action(runtime, input) {
|
|
29
20
|
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
|
|
30
|
-
const
|
|
21
|
+
const payload = input.$typeName
|
|
31
22
|
? input
|
|
32
23
|
: fromJson(InputSchema, input);
|
|
33
|
-
const payload = {
|
|
34
|
-
typeUrl: getTypeUrl(InputSchema),
|
|
35
|
-
value: toBinary(InputSchema, value),
|
|
36
|
-
};
|
|
37
24
|
const capabilityId = BasicCapability.CAPABILITY_ID;
|
|
38
|
-
const capabilityResponse = callCapability({
|
|
25
|
+
const capabilityResponse = runtime.callCapability({
|
|
39
26
|
capabilityId,
|
|
40
27
|
method: 'Action',
|
|
41
|
-
mode: this.mode,
|
|
42
28
|
payload,
|
|
29
|
+
inputSchema: InputSchema,
|
|
30
|
+
outputSchema: OutputSchema,
|
|
43
31
|
});
|
|
44
32
|
return {
|
|
45
33
|
result: async () => {
|
|
46
|
-
|
|
47
|
-
if (response.case === 'error') {
|
|
48
|
-
throw new CapabilityError(response.value, {
|
|
49
|
-
capabilityId,
|
|
50
|
-
method: 'Action',
|
|
51
|
-
mode: this.mode,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
if (response.case !== 'payload') {
|
|
55
|
-
throw new CapabilityError('No payload in response', {
|
|
56
|
-
capabilityId,
|
|
57
|
-
method: 'Action',
|
|
58
|
-
mode: this.mode,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return fromBinary(OutputSchema, response.value.value);
|
|
34
|
+
return capabilityResponse.result();
|
|
62
35
|
},
|
|
63
36
|
};
|
|
64
37
|
}
|
|
65
38
|
trigger(config) {
|
|
66
|
-
|
|
39
|
+
const capabilityId = BasicCapability.CAPABILITY_ID;
|
|
40
|
+
return new BasicTrigger(config, capabilityId, 'Trigger');
|
|
67
41
|
}
|
|
68
42
|
}
|
|
69
43
|
/**
|
|
70
44
|
* Trigger implementation for Trigger
|
|
71
45
|
*/
|
|
72
46
|
class BasicTrigger {
|
|
73
|
-
mode;
|
|
74
47
|
_capabilityId;
|
|
75
48
|
_method;
|
|
76
49
|
config;
|
|
77
|
-
constructor(
|
|
78
|
-
this.mode = mode;
|
|
50
|
+
constructor(config, _capabilityId, _method) {
|
|
79
51
|
this._capabilityId = _capabilityId;
|
|
80
52
|
this._method = _method;
|
|
81
53
|
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
|
|
@@ -93,10 +65,7 @@ class BasicTrigger {
|
|
|
93
65
|
return TriggerEventSchema;
|
|
94
66
|
}
|
|
95
67
|
configAsAny() {
|
|
96
|
-
return
|
|
97
|
-
typeUrl: getTypeUrl(ConfigSchema),
|
|
98
|
-
value: toBinary(ConfigSchema, this.config),
|
|
99
|
-
});
|
|
68
|
+
return anyPack(ConfigSchema, this.config);
|
|
100
69
|
}
|
|
101
70
|
/**
|
|
102
71
|
* Transform the raw trigger output - override this method if needed
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import { type Inputs, type InputsJson, type Outputs } from '../../../../../generated/capabilities/internal/basicaction/v1/basic_action_pb';
|
|
2
|
-
import {
|
|
2
|
+
import { type Runtime } from '../../../../../sdk/runtime';
|
|
3
3
|
/**
|
|
4
4
|
* BasicAction Capability
|
|
5
5
|
*
|
|
6
6
|
* Capability ID: basic-test-action@1.0.0
|
|
7
|
-
* Default Mode: Mode.DON
|
|
8
7
|
* Capability Name: basic-test-action
|
|
9
8
|
* Capability Version: 1.0.0
|
|
10
9
|
*/
|
|
11
10
|
export declare class BasicActionCapability {
|
|
12
|
-
private readonly mode;
|
|
13
11
|
/** The capability ID for this service */
|
|
14
12
|
static readonly CAPABILITY_ID = "basic-test-action@1.0.0";
|
|
15
|
-
/** The default execution mode for this capability */
|
|
16
|
-
static readonly DEFAULT_MODE = Mode.DON;
|
|
17
13
|
static readonly CAPABILITY_NAME = "basic-test-action";
|
|
18
14
|
static readonly CAPABILITY_VERSION = "1.0.0";
|
|
19
|
-
constructor(
|
|
20
|
-
performAction(input: Inputs | InputsJson): {
|
|
15
|
+
constructor();
|
|
16
|
+
performAction(runtime: Runtime<any>, input: Inputs | InputsJson): {
|
|
21
17
|
result: () => Promise<Outputs>;
|
|
22
18
|
};
|
|
23
19
|
}
|
|
@@ -1,62 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fromJson } from '@bufbuild/protobuf';
|
|
2
2
|
import { InputsSchema, OutputsSchema, } from '../../../../../generated/capabilities/internal/basicaction/v1/basic_action_pb';
|
|
3
|
-
import {
|
|
4
|
-
import { callCapability } from '../../../../../sdk/utils/capabilities/call-capability';
|
|
5
|
-
import { CapabilityError } from '../../../../../sdk/utils/capabilities/capability-error';
|
|
6
|
-
import { getTypeUrl } from '../../../../../sdk/utils/typeurl';
|
|
3
|
+
import {} from '../../../../../sdk/runtime';
|
|
7
4
|
/**
|
|
8
5
|
* BasicAction Capability
|
|
9
6
|
*
|
|
10
7
|
* Capability ID: basic-test-action@1.0.0
|
|
11
|
-
* Default Mode: Mode.DON
|
|
12
8
|
* Capability Name: basic-test-action
|
|
13
9
|
* Capability Version: 1.0.0
|
|
14
10
|
*/
|
|
15
11
|
export class BasicActionCapability {
|
|
16
|
-
mode;
|
|
17
12
|
/** The capability ID for this service */
|
|
18
13
|
static CAPABILITY_ID = 'basic-test-action@1.0.0';
|
|
19
|
-
/** The default execution mode for this capability */
|
|
20
|
-
static DEFAULT_MODE = Mode.DON;
|
|
21
14
|
static CAPABILITY_NAME = 'basic-test-action';
|
|
22
15
|
static CAPABILITY_VERSION = '1.0.0';
|
|
23
|
-
constructor(
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
performAction(input) {
|
|
16
|
+
constructor() { }
|
|
17
|
+
performAction(runtime, input) {
|
|
27
18
|
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
|
|
28
|
-
const
|
|
19
|
+
const payload = input.$typeName
|
|
29
20
|
? input
|
|
30
21
|
: fromJson(InputsSchema, input);
|
|
31
|
-
const payload = {
|
|
32
|
-
typeUrl: getTypeUrl(InputsSchema),
|
|
33
|
-
value: toBinary(InputsSchema, value),
|
|
34
|
-
};
|
|
35
22
|
const capabilityId = BasicActionCapability.CAPABILITY_ID;
|
|
36
|
-
const capabilityResponse = callCapability({
|
|
23
|
+
const capabilityResponse = runtime.callCapability({
|
|
37
24
|
capabilityId,
|
|
38
25
|
method: 'PerformAction',
|
|
39
|
-
mode: this.mode,
|
|
40
26
|
payload,
|
|
27
|
+
inputSchema: InputsSchema,
|
|
28
|
+
outputSchema: OutputsSchema,
|
|
41
29
|
});
|
|
42
30
|
return {
|
|
43
31
|
result: async () => {
|
|
44
|
-
|
|
45
|
-
if (response.case === 'error') {
|
|
46
|
-
throw new CapabilityError(response.value, {
|
|
47
|
-
capabilityId,
|
|
48
|
-
method: 'PerformAction',
|
|
49
|
-
mode: this.mode,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (response.case !== 'payload') {
|
|
53
|
-
throw new CapabilityError('No payload in response', {
|
|
54
|
-
capabilityId,
|
|
55
|
-
method: 'PerformAction',
|
|
56
|
-
mode: this.mode,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return fromBinary(OutputsSchema, response.value.value);
|
|
32
|
+
return capabilityResponse.result();
|
|
60
33
|
},
|
|
61
34
|
};
|
|
62
35
|
}
|
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
import { type Any } from '@bufbuild/protobuf/wkt';
|
|
2
2
|
import { type Config, type ConfigJson, type Outputs } from '../../../../../generated/capabilities/internal/basictrigger/v1/basic_trigger_pb';
|
|
3
|
-
import { Mode } from '../../../../../generated/sdk/v1alpha/sdk_pb';
|
|
4
3
|
import { type Trigger } from '../../../../../sdk/utils/triggers/trigger-interface';
|
|
5
4
|
/**
|
|
6
5
|
* Basic Capability
|
|
7
6
|
*
|
|
8
7
|
* Capability ID: basic-test-trigger@1.0.0
|
|
9
|
-
* Default Mode: Mode.DON
|
|
10
8
|
* Capability Name: basic-test-trigger
|
|
11
9
|
* Capability Version: 1.0.0
|
|
12
10
|
*/
|
|
13
11
|
export declare class BasicCapability {
|
|
14
|
-
private readonly mode;
|
|
15
12
|
/** The capability ID for this service */
|
|
16
13
|
static readonly CAPABILITY_ID = "basic-test-trigger@1.0.0";
|
|
17
|
-
/** The default execution mode for this capability */
|
|
18
|
-
static readonly DEFAULT_MODE = Mode.DON;
|
|
19
14
|
static readonly CAPABILITY_NAME = "basic-test-trigger";
|
|
20
15
|
static readonly CAPABILITY_VERSION = "1.0.0";
|
|
21
|
-
constructor(
|
|
16
|
+
constructor();
|
|
22
17
|
trigger(config: ConfigJson): BasicTrigger;
|
|
23
18
|
}
|
|
24
19
|
/**
|
|
25
20
|
* Trigger implementation for Trigger
|
|
26
21
|
*/
|
|
27
22
|
declare class BasicTrigger implements Trigger<Outputs, Outputs> {
|
|
28
|
-
readonly mode: Mode;
|
|
29
23
|
private readonly _capabilityId;
|
|
30
24
|
private readonly _method;
|
|
31
25
|
readonly config: Config;
|
|
32
|
-
constructor(
|
|
26
|
+
constructor(config: Config | ConfigJson, _capabilityId: string, _method: string);
|
|
33
27
|
capabilityId(): string;
|
|
34
28
|
method(): string;
|
|
35
29
|
outputSchema(): import("@bufbuild/protobuf/codegenv2").GenMessage<Outputs, {
|
|
@@ -1,44 +1,34 @@
|
|
|
1
|
-
import { create,
|
|
2
|
-
import { AnySchema } from '@bufbuild/protobuf/wkt';
|
|
1
|
+
import { create, fromJson } from '@bufbuild/protobuf';
|
|
2
|
+
import { AnySchema, anyPack } from '@bufbuild/protobuf/wkt';
|
|
3
3
|
import { ConfigSchema, OutputsSchema, } from '../../../../../generated/capabilities/internal/basictrigger/v1/basic_trigger_pb';
|
|
4
|
-
import {
|
|
5
|
-
import { callCapability } from '../../../../../sdk/utils/capabilities/call-capability';
|
|
6
|
-
import { CapabilityError } from '../../../../../sdk/utils/capabilities/capability-error';
|
|
4
|
+
import {} from '../../../../../sdk/runtime';
|
|
7
5
|
import {} from '../../../../../sdk/utils/triggers/trigger-interface';
|
|
8
|
-
import { getTypeUrl } from '../../../../../sdk/utils/typeurl';
|
|
9
6
|
/**
|
|
10
7
|
* Basic Capability
|
|
11
8
|
*
|
|
12
9
|
* Capability ID: basic-test-trigger@1.0.0
|
|
13
|
-
* Default Mode: Mode.DON
|
|
14
10
|
* Capability Name: basic-test-trigger
|
|
15
11
|
* Capability Version: 1.0.0
|
|
16
12
|
*/
|
|
17
13
|
export class BasicCapability {
|
|
18
|
-
mode;
|
|
19
14
|
/** The capability ID for this service */
|
|
20
15
|
static CAPABILITY_ID = 'basic-test-trigger@1.0.0';
|
|
21
|
-
/** The default execution mode for this capability */
|
|
22
|
-
static DEFAULT_MODE = Mode.DON;
|
|
23
16
|
static CAPABILITY_NAME = 'basic-test-trigger';
|
|
24
17
|
static CAPABILITY_VERSION = '1.0.0';
|
|
25
|
-
constructor(
|
|
26
|
-
this.mode = mode;
|
|
27
|
-
}
|
|
18
|
+
constructor() { }
|
|
28
19
|
trigger(config) {
|
|
29
|
-
|
|
20
|
+
const capabilityId = BasicCapability.CAPABILITY_ID;
|
|
21
|
+
return new BasicTrigger(config, capabilityId, 'Trigger');
|
|
30
22
|
}
|
|
31
23
|
}
|
|
32
24
|
/**
|
|
33
25
|
* Trigger implementation for Trigger
|
|
34
26
|
*/
|
|
35
27
|
class BasicTrigger {
|
|
36
|
-
mode;
|
|
37
28
|
_capabilityId;
|
|
38
29
|
_method;
|
|
39
30
|
config;
|
|
40
|
-
constructor(
|
|
41
|
-
this.mode = mode;
|
|
31
|
+
constructor(config, _capabilityId, _method) {
|
|
42
32
|
this._capabilityId = _capabilityId;
|
|
43
33
|
this._method = _method;
|
|
44
34
|
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
|
|
@@ -56,10 +46,7 @@ class BasicTrigger {
|
|
|
56
46
|
return OutputsSchema;
|
|
57
47
|
}
|
|
58
48
|
configAsAny() {
|
|
59
|
-
return
|
|
60
|
-
typeUrl: getTypeUrl(ConfigSchema),
|
|
61
|
-
value: toBinary(ConfigSchema, this.config),
|
|
62
|
-
});
|
|
49
|
+
return anyPack(ConfigSchema, this.config);
|
|
63
50
|
}
|
|
64
51
|
/**
|
|
65
52
|
* Transform the raw trigger output - override this method if needed
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type ReportRequest, type ReportRequestJson, type ReportResponse, type SimpleConsensusInputs, type SimpleConsensusInputsJson } from '../../../../../generated/sdk/v1alpha/sdk_pb';
|
|
2
2
|
import { type Value } from '../../../../../generated/values/v1/values_pb';
|
|
3
|
+
import { type Runtime } from '../../../../../sdk/runtime';
|
|
3
4
|
/**
|
|
4
5
|
* Consensus Capability
|
|
5
6
|
*
|
|
6
7
|
* Capability ID: consensus@1.0.0-alpha
|
|
7
|
-
* Default Mode: Mode.DON
|
|
8
8
|
* Capability Name: consensus
|
|
9
9
|
* Capability Version: 1.0.0-alpha
|
|
10
10
|
*/
|
|
11
11
|
export declare class ConsensusCapability {
|
|
12
|
-
private readonly mode;
|
|
13
12
|
/** The capability ID for this service */
|
|
14
13
|
static readonly CAPABILITY_ID = "consensus@1.0.0-alpha";
|
|
15
|
-
/** The default execution mode for this capability */
|
|
16
|
-
static readonly DEFAULT_MODE = Mode.DON;
|
|
17
14
|
static readonly CAPABILITY_NAME = "consensus";
|
|
18
15
|
static readonly CAPABILITY_VERSION = "1.0.0-alpha";
|
|
19
|
-
constructor(
|
|
20
|
-
simple(input: SimpleConsensusInputs | SimpleConsensusInputsJson): {
|
|
16
|
+
constructor();
|
|
17
|
+
simple(runtime: Runtime<any>, input: SimpleConsensusInputs | SimpleConsensusInputsJson): {
|
|
21
18
|
result: () => Promise<Value>;
|
|
22
19
|
};
|
|
23
|
-
report(input: ReportRequest | ReportRequestJson): {
|
|
20
|
+
report(runtime: Runtime<any>, input: ReportRequest | ReportRequestJson): {
|
|
24
21
|
result: () => Promise<ReportResponse>;
|
|
25
22
|
};
|
|
26
23
|
}
|
|
@@ -1,99 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
+
import { ReportRequestSchema, ReportResponseSchema, SimpleConsensusInputsSchema, } from '../../../../../generated/sdk/v1alpha/sdk_pb';
|
|
3
3
|
import { ValueSchema } from '../../../../../generated/values/v1/values_pb';
|
|
4
|
-
import {
|
|
5
|
-
import { CapabilityError } from '../../../../../sdk/utils/capabilities/capability-error';
|
|
6
|
-
import { getTypeUrl } from '../../../../../sdk/utils/typeurl';
|
|
4
|
+
import {} from '../../../../../sdk/runtime';
|
|
7
5
|
/**
|
|
8
6
|
* Consensus Capability
|
|
9
7
|
*
|
|
10
8
|
* Capability ID: consensus@1.0.0-alpha
|
|
11
|
-
* Default Mode: Mode.DON
|
|
12
9
|
* Capability Name: consensus
|
|
13
10
|
* Capability Version: 1.0.0-alpha
|
|
14
11
|
*/
|
|
15
12
|
export class ConsensusCapability {
|
|
16
|
-
mode;
|
|
17
13
|
/** The capability ID for this service */
|
|
18
14
|
static CAPABILITY_ID = 'consensus@1.0.0-alpha';
|
|
19
|
-
/** The default execution mode for this capability */
|
|
20
|
-
static DEFAULT_MODE = Mode.DON;
|
|
21
15
|
static CAPABILITY_NAME = 'consensus';
|
|
22
16
|
static CAPABILITY_VERSION = '1.0.0-alpha';
|
|
23
|
-
constructor(
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
simple(input) {
|
|
17
|
+
constructor() { }
|
|
18
|
+
simple(runtime, input) {
|
|
27
19
|
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
|
|
28
|
-
const
|
|
20
|
+
const payload = input.$typeName
|
|
29
21
|
? input
|
|
30
22
|
: fromJson(SimpleConsensusInputsSchema, input);
|
|
31
|
-
const payload = {
|
|
32
|
-
typeUrl: getTypeUrl(SimpleConsensusInputsSchema),
|
|
33
|
-
value: toBinary(SimpleConsensusInputsSchema, value),
|
|
34
|
-
};
|
|
35
23
|
const capabilityId = ConsensusCapability.CAPABILITY_ID;
|
|
36
|
-
const capabilityResponse = callCapability({
|
|
24
|
+
const capabilityResponse = runtime.callCapability({
|
|
37
25
|
capabilityId,
|
|
38
26
|
method: 'Simple',
|
|
39
|
-
mode: this.mode,
|
|
40
27
|
payload,
|
|
28
|
+
inputSchema: SimpleConsensusInputsSchema,
|
|
29
|
+
outputSchema: ValueSchema,
|
|
41
30
|
});
|
|
42
31
|
return {
|
|
43
32
|
result: async () => {
|
|
44
|
-
|
|
45
|
-
if (response.case === 'error') {
|
|
46
|
-
throw new CapabilityError(response.value, {
|
|
47
|
-
capabilityId,
|
|
48
|
-
method: 'Simple',
|
|
49
|
-
mode: this.mode,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (response.case !== 'payload') {
|
|
53
|
-
throw new CapabilityError('No payload in response', {
|
|
54
|
-
capabilityId,
|
|
55
|
-
method: 'Simple',
|
|
56
|
-
mode: this.mode,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return fromBinary(ValueSchema, response.value.value);
|
|
33
|
+
return capabilityResponse.result();
|
|
60
34
|
},
|
|
61
35
|
};
|
|
62
36
|
}
|
|
63
|
-
report(input) {
|
|
37
|
+
report(runtime, input) {
|
|
64
38
|
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
|
|
65
|
-
const
|
|
39
|
+
const payload = input.$typeName
|
|
66
40
|
? input
|
|
67
41
|
: fromJson(ReportRequestSchema, input);
|
|
68
|
-
const payload = {
|
|
69
|
-
typeUrl: getTypeUrl(ReportRequestSchema),
|
|
70
|
-
value: toBinary(ReportRequestSchema, value),
|
|
71
|
-
};
|
|
72
42
|
const capabilityId = ConsensusCapability.CAPABILITY_ID;
|
|
73
|
-
const capabilityResponse = callCapability({
|
|
43
|
+
const capabilityResponse = runtime.callCapability({
|
|
74
44
|
capabilityId,
|
|
75
45
|
method: 'Report',
|
|
76
|
-
mode: this.mode,
|
|
77
46
|
payload,
|
|
47
|
+
inputSchema: ReportRequestSchema,
|
|
48
|
+
outputSchema: ReportResponseSchema,
|
|
78
49
|
});
|
|
79
50
|
return {
|
|
80
51
|
result: async () => {
|
|
81
|
-
|
|
82
|
-
if (response.case === 'error') {
|
|
83
|
-
throw new CapabilityError(response.value, {
|
|
84
|
-
capabilityId,
|
|
85
|
-
method: 'Report',
|
|
86
|
-
mode: this.mode,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
if (response.case !== 'payload') {
|
|
90
|
-
throw new CapabilityError('No payload in response', {
|
|
91
|
-
capabilityId,
|
|
92
|
-
method: 'Report',
|
|
93
|
-
mode: this.mode,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return fromBinary(ReportResponseSchema, response.value.value);
|
|
52
|
+
return capabilityResponse.result();
|
|
97
53
|
},
|
|
98
54
|
};
|
|
99
55
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type NodeInputs, type NodeInputsJson, type NodeOutputs } from '../../../../../generated/capabilities/internal/nodeaction/v1/node_action_pb';
|
|
2
|
+
import { type NodeRuntime } from '../../../../../sdk/runtime';
|
|
3
|
+
/**
|
|
4
|
+
* BasicAction Capability
|
|
5
|
+
*
|
|
6
|
+
* Capability ID: basic-test-node-action@1.0.0
|
|
7
|
+
* Capability Name: basic-test-node-action
|
|
8
|
+
* Capability Version: 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
export declare class BasicActionCapability {
|
|
11
|
+
/** The capability ID for this service */
|
|
12
|
+
static readonly CAPABILITY_ID = "basic-test-node-action@1.0.0";
|
|
13
|
+
static readonly CAPABILITY_NAME = "basic-test-node-action";
|
|
14
|
+
static readonly CAPABILITY_VERSION = "1.0.0";
|
|
15
|
+
constructor();
|
|
16
|
+
performAction(runtime: NodeRuntime<any>, input: NodeInputs | NodeInputsJson): {
|
|
17
|
+
result: () => Promise<NodeOutputs>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
+
import { NodeInputsSchema, NodeOutputsSchema, } from '../../../../../generated/capabilities/internal/nodeaction/v1/node_action_pb';
|
|
3
|
+
import {} from '../../../../../sdk/runtime';
|
|
4
|
+
/**
|
|
5
|
+
* BasicAction Capability
|
|
6
|
+
*
|
|
7
|
+
* Capability ID: basic-test-node-action@1.0.0
|
|
8
|
+
* Capability Name: basic-test-node-action
|
|
9
|
+
* Capability Version: 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
export class BasicActionCapability {
|
|
12
|
+
/** The capability ID for this service */
|
|
13
|
+
static CAPABILITY_ID = 'basic-test-node-action@1.0.0';
|
|
14
|
+
static CAPABILITY_NAME = 'basic-test-node-action';
|
|
15
|
+
static CAPABILITY_VERSION = '1.0.0';
|
|
16
|
+
constructor() { }
|
|
17
|
+
performAction(runtime, input) {
|
|
18
|
+
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
|
|
19
|
+
const payload = input.$typeName
|
|
20
|
+
? input
|
|
21
|
+
: fromJson(NodeInputsSchema, input);
|
|
22
|
+
const capabilityId = BasicActionCapability.CAPABILITY_ID;
|
|
23
|
+
const capabilityResponse = runtime.callCapability({
|
|
24
|
+
capabilityId,
|
|
25
|
+
method: 'PerformAction',
|
|
26
|
+
payload,
|
|
27
|
+
inputSchema: NodeInputsSchema,
|
|
28
|
+
outputSchema: NodeOutputsSchema,
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
result: async () => {
|
|
32
|
+
return capabilityResponse.result();
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import { type Request, type RequestJson, type Response } from '../../../../../generated/capabilities/networking/http/v1alpha/client_pb';
|
|
2
|
-
import {
|
|
2
|
+
import { type NodeRuntime } from '../../../../../sdk/runtime';
|
|
3
3
|
/**
|
|
4
4
|
* Client Capability
|
|
5
5
|
*
|
|
6
6
|
* Capability ID: http-actions@1.0.0-alpha
|
|
7
|
-
* Default Mode: Mode.NODE
|
|
8
7
|
* Capability Name: http-actions
|
|
9
8
|
* Capability Version: 1.0.0-alpha
|
|
10
9
|
*/
|
|
11
10
|
export declare class ClientCapability {
|
|
12
|
-
private readonly mode;
|
|
13
11
|
/** The capability ID for this service */
|
|
14
12
|
static readonly CAPABILITY_ID = "http-actions@1.0.0-alpha";
|
|
15
|
-
/** The default execution mode for this capability */
|
|
16
|
-
static readonly DEFAULT_MODE = Mode.NODE;
|
|
17
13
|
static readonly CAPABILITY_NAME = "http-actions";
|
|
18
14
|
static readonly CAPABILITY_VERSION = "1.0.0-alpha";
|
|
19
|
-
constructor(
|
|
20
|
-
sendRequest(input: Request | RequestJson): {
|
|
15
|
+
constructor();
|
|
16
|
+
sendRequest(runtime: NodeRuntime<any>, input: Request | RequestJson): {
|
|
21
17
|
result: () => Promise<Response>;
|
|
22
18
|
};
|
|
23
19
|
}
|
|
@@ -1,62 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fromJson } from '@bufbuild/protobuf';
|
|
2
2
|
import { RequestSchema, ResponseSchema, } from '../../../../../generated/capabilities/networking/http/v1alpha/client_pb';
|
|
3
|
-
import {
|
|
4
|
-
import { callCapability } from '../../../../../sdk/utils/capabilities/call-capability';
|
|
5
|
-
import { CapabilityError } from '../../../../../sdk/utils/capabilities/capability-error';
|
|
6
|
-
import { getTypeUrl } from '../../../../../sdk/utils/typeurl';
|
|
3
|
+
import {} from '../../../../../sdk/runtime';
|
|
7
4
|
/**
|
|
8
5
|
* Client Capability
|
|
9
6
|
*
|
|
10
7
|
* Capability ID: http-actions@1.0.0-alpha
|
|
11
|
-
* Default Mode: Mode.NODE
|
|
12
8
|
* Capability Name: http-actions
|
|
13
9
|
* Capability Version: 1.0.0-alpha
|
|
14
10
|
*/
|
|
15
11
|
export class ClientCapability {
|
|
16
|
-
mode;
|
|
17
12
|
/** The capability ID for this service */
|
|
18
13
|
static CAPABILITY_ID = 'http-actions@1.0.0-alpha';
|
|
19
|
-
/** The default execution mode for this capability */
|
|
20
|
-
static DEFAULT_MODE = Mode.NODE;
|
|
21
14
|
static CAPABILITY_NAME = 'http-actions';
|
|
22
15
|
static CAPABILITY_VERSION = '1.0.0-alpha';
|
|
23
|
-
constructor(
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
sendRequest(input) {
|
|
16
|
+
constructor() { }
|
|
17
|
+
sendRequest(runtime, input) {
|
|
27
18
|
// biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
|
|
28
|
-
const
|
|
19
|
+
const payload = input.$typeName
|
|
29
20
|
? input
|
|
30
21
|
: fromJson(RequestSchema, input);
|
|
31
|
-
const payload = {
|
|
32
|
-
typeUrl: getTypeUrl(RequestSchema),
|
|
33
|
-
value: toBinary(RequestSchema, value),
|
|
34
|
-
};
|
|
35
22
|
const capabilityId = ClientCapability.CAPABILITY_ID;
|
|
36
|
-
const capabilityResponse = callCapability({
|
|
23
|
+
const capabilityResponse = runtime.callCapability({
|
|
37
24
|
capabilityId,
|
|
38
25
|
method: 'SendRequest',
|
|
39
|
-
mode: this.mode,
|
|
40
26
|
payload,
|
|
27
|
+
inputSchema: RequestSchema,
|
|
28
|
+
outputSchema: ResponseSchema,
|
|
41
29
|
});
|
|
42
30
|
return {
|
|
43
31
|
result: async () => {
|
|
44
|
-
|
|
45
|
-
if (response.case === 'error') {
|
|
46
|
-
throw new CapabilityError(response.value, {
|
|
47
|
-
capabilityId,
|
|
48
|
-
method: 'SendRequest',
|
|
49
|
-
mode: this.mode,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (response.case !== 'payload') {
|
|
53
|
-
throw new CapabilityError('No payload in response', {
|
|
54
|
-
capabilityId,
|
|
55
|
-
method: 'SendRequest',
|
|
56
|
-
mode: this.mode,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return fromBinary(ResponseSchema, response.value.value);
|
|
32
|
+
return capabilityResponse.result();
|
|
60
33
|
},
|
|
61
34
|
};
|
|
62
35
|
}
|
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
import { type Any } from '@bufbuild/protobuf/wkt';
|
|
2
2
|
import { type Config, type ConfigJson, type Payload } from '../../../../../generated/capabilities/networking/http/v1alpha/trigger_pb';
|
|
3
|
-
import { Mode } from '../../../../../generated/sdk/v1alpha/sdk_pb';
|
|
4
3
|
import { type Trigger } from '../../../../../sdk/utils/triggers/trigger-interface';
|
|
5
4
|
/**
|
|
6
5
|
* HTTP Capability
|
|
7
6
|
*
|
|
8
7
|
* Capability ID: http-trigger@1.0.0-alpha
|
|
9
|
-
* Default Mode: Mode.DON
|
|
10
8
|
* Capability Name: http-trigger
|
|
11
9
|
* Capability Version: 1.0.0-alpha
|
|
12
10
|
*/
|
|
13
11
|
export declare class HTTPCapability {
|
|
14
|
-
private readonly mode;
|
|
15
12
|
/** The capability ID for this service */
|
|
16
13
|
static readonly CAPABILITY_ID = "http-trigger@1.0.0-alpha";
|
|
17
|
-
/** The default execution mode for this capability */
|
|
18
|
-
static readonly DEFAULT_MODE = Mode.DON;
|
|
19
14
|
static readonly CAPABILITY_NAME = "http-trigger";
|
|
20
15
|
static readonly CAPABILITY_VERSION = "1.0.0-alpha";
|
|
21
|
-
constructor(
|
|
16
|
+
constructor();
|
|
22
17
|
trigger(config: ConfigJson): HTTPTrigger;
|
|
23
18
|
}
|
|
24
19
|
/**
|
|
25
20
|
* Trigger implementation for Trigger
|
|
26
21
|
*/
|
|
27
22
|
declare class HTTPTrigger implements Trigger<Payload, Payload> {
|
|
28
|
-
readonly mode: Mode;
|
|
29
23
|
private readonly _capabilityId;
|
|
30
24
|
private readonly _method;
|
|
31
25
|
readonly config: Config;
|
|
32
|
-
constructor(
|
|
26
|
+
constructor(config: Config | ConfigJson, _capabilityId: string, _method: string);
|
|
33
27
|
capabilityId(): string;
|
|
34
28
|
method(): string;
|
|
35
29
|
outputSchema(): import("@bufbuild/protobuf/codegenv2").GenMessage<Payload, {
|