@mochabug/adapt-sdk 0.1.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/LICENSE +201 -0
- package/README.md +873 -0
- package/dist/api.d.ts +1605 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.spec.d.ts +2 -0
- package/dist/api.spec.d.ts.map +1 -0
- package/dist/cjs/api.cjs +2 -0
- package/dist/cjs/api.cjs.map +7 -0
- package/dist/cjs/frontend.cjs +2 -0
- package/dist/cjs/frontend.cjs.map +7 -0
- package/dist/cjs/mime.cjs +2 -0
- package/dist/cjs/mime.cjs.map +7 -0
- package/dist/cjs/router.cjs +2 -0
- package/dist/cjs/router.cjs.map +7 -0
- package/dist/cjs/types.cjs +2 -0
- package/dist/cjs/types.cjs.map +7 -0
- package/dist/esm/api.mjs +2 -0
- package/dist/esm/api.mjs.map +7 -0
- package/dist/esm/frontend.mjs +2 -0
- package/dist/esm/frontend.mjs.map +7 -0
- package/dist/esm/mime.mjs +2 -0
- package/dist/esm/mime.mjs.map +7 -0
- package/dist/esm/router.mjs +2 -0
- package/dist/esm/router.mjs.map +7 -0
- package/dist/esm/types.mjs +1 -0
- package/dist/esm/types.mjs.map +7 -0
- package/dist/frontend.d.ts +10 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/genproto/buf/validate/validate_pb.d.ts +8491 -0
- package/dist/genproto/buf/validate/validate_pb.d.ts.map +1 -0
- package/dist/genproto/google/api/annotations_pb.d.ts +14 -0
- package/dist/genproto/google/api/annotations_pb.d.ts.map +1 -0
- package/dist/genproto/google/api/client_pb.d.ts +1432 -0
- package/dist/genproto/google/api/client_pb.d.ts.map +1 -0
- package/dist/genproto/google/api/http_pb.d.ts +843 -0
- package/dist/genproto/google/api/http_pb.d.ts.map +1 -0
- package/dist/genproto/google/api/launch_stage_pb.d.ts +94 -0
- package/dist/genproto/google/api/launch_stage_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/automations/v1/automations_pb.d.ts +1006 -0
- package/dist/genproto/mochabugapis/adapt/automations/v1/automations_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/exchange_pb.d.ts +77 -0
- package/dist/genproto/mochabugapis/adapt/graph/exchange_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/jtd_schema_pb.d.ts +401 -0
- package/dist/genproto/mochabugapis/adapt/graph/jtd_schema_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/receiver_pb.d.ts +69 -0
- package/dist/genproto/mochabugapis/adapt/graph/receiver_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/signal_binding_pb.d.ts +430 -0
- package/dist/genproto/mochabugapis/adapt/graph/signal_binding_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/signal_data_pb.d.ts +198 -0
- package/dist/genproto/mochabugapis/adapt/graph/signal_data_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.d.ts +161 -0
- package/dist/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/signal_format_pb.d.ts +305 -0
- package/dist/genproto/mochabugapis/adapt/graph/signal_format_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/transceiver_pb.d.ts +77 -0
- package/dist/genproto/mochabugapis/adapt/graph/transceiver_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/transmitter_pb.d.ts +120 -0
- package/dist/genproto/mochabugapis/adapt/graph/transmitter_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/graph/vertex_metadata_pb.d.ts +99 -0
- package/dist/genproto/mochabugapis/adapt/graph/vertex_metadata_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/compound_services_pb.d.ts +347 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/compound_services_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/file_pb.d.ts +64 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/file_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/http_proxy_service_pb.d.ts +1282 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/http_proxy_service_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/manifest_pb.d.ts +388 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/manifest_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/oauth2_service_pb.d.ts +805 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/oauth2_service_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/plugins_pb.d.ts +238 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/plugins_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/service_definition_pb.d.ts +241 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/service_definition_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/service_settings_pb.d.ts +539 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/service_settings_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/variable_service_pb.d.ts +190 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/variable_service_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/vertex_pb.d.ts +269 -0
- package/dist/genproto/mochabugapis/adapt/plugins/v1/vertex_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/runtime/v1/incoming_pb.d.ts +339 -0
- package/dist/genproto/mochabugapis/adapt/runtime/v1/incoming_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/runtime/v1/runtime_pb.d.ts +2721 -0
- package/dist/genproto/mochabugapis/adapt/runtime/v1/runtime_pb.d.ts.map +1 -0
- package/dist/genproto/mochabugapis/adapt/runtime/v1/store_pb.d.ts +872 -0
- package/dist/genproto/mochabugapis/adapt/runtime/v1/store_pb.d.ts.map +1 -0
- package/dist/grpcweb.d.ts +8 -0
- package/dist/grpcweb.d.ts.map +1 -0
- package/dist/mime.d.ts +11 -0
- package/dist/mime.d.ts.map +1 -0
- package/dist/router.d.ts +503 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.spec.d.ts +2 -0
- package/dist/router.spec.d.ts.map +1 -0
- package/dist/signal-api.spec.d.ts +17 -0
- package/dist/signal-api.spec.d.ts.map +1 -0
- package/dist/types.d.ts +149 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +80 -0
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,1605 @@
|
|
|
1
|
+
import { JsonValue } from '@bufbuild/protobuf';
|
|
2
|
+
import { ValueJson } from '@bufbuild/protobuf/wkt';
|
|
3
|
+
import { Client, Code, ConnectError } from '@connectrpc/connect';
|
|
4
|
+
import { SignalData } from './genproto/mochabugapis/adapt/graph/signal_data_pb';
|
|
5
|
+
import { SignalFormatJson } from './genproto/mochabugapis/adapt/graph/signal_format_pb';
|
|
6
|
+
import { VertexMetadataJson } from './genproto/mochabugapis/adapt/graph/vertex_metadata_pb';
|
|
7
|
+
import { ConfiguratorService, ExchangeOperation, ExecutorService, ListIncomingSignalsResponseJson, NamespaceJson, PluginService, Token } from './genproto/mochabugapis/adapt/runtime/v1/runtime_pb';
|
|
8
|
+
import { GetValue, SelectOpJson, WriteOperation } from './genproto/mochabugapis/adapt/runtime/v1/store_pb';
|
|
9
|
+
import { ConfiguratorEnvironment, Environment, ExecutorEnvironment } from './types';
|
|
10
|
+
export * from './genproto/mochabugapis/adapt/automations/v1/automations_pb';
|
|
11
|
+
export * from './genproto/mochabugapis/adapt/graph/exchange_pb';
|
|
12
|
+
export * from './genproto/mochabugapis/adapt/graph/jtd_schema_pb';
|
|
13
|
+
export * from './genproto/mochabugapis/adapt/graph/receiver_pb';
|
|
14
|
+
export * from './genproto/mochabugapis/adapt/graph/signal_binding_pb';
|
|
15
|
+
export * from './genproto/mochabugapis/adapt/graph/signal_data_pb';
|
|
16
|
+
export * from './genproto/mochabugapis/adapt/graph/signal_descriptor_pb';
|
|
17
|
+
export * from './genproto/mochabugapis/adapt/graph/signal_format_pb';
|
|
18
|
+
export * from './genproto/mochabugapis/adapt/graph/transceiver_pb';
|
|
19
|
+
export * from './genproto/mochabugapis/adapt/graph/transmitter_pb';
|
|
20
|
+
export * from './genproto/mochabugapis/adapt/graph/vertex_metadata_pb';
|
|
21
|
+
export * from './genproto/mochabugapis/adapt/runtime/v1/incoming_pb';
|
|
22
|
+
export * from './genproto/mochabugapis/adapt/runtime/v1/runtime_pb';
|
|
23
|
+
export * from './genproto/mochabugapis/adapt/runtime/v1/store_pb';
|
|
24
|
+
export * from './types';
|
|
25
|
+
export { Code, ConnectError };
|
|
26
|
+
export type { ValueJson };
|
|
27
|
+
/**
|
|
28
|
+
* Array representing asset directories.
|
|
29
|
+
*/
|
|
30
|
+
export type AssetDirectory = {
|
|
31
|
+
/**
|
|
32
|
+
* Name of the asset directory.
|
|
33
|
+
*/
|
|
34
|
+
name: string;
|
|
35
|
+
/**
|
|
36
|
+
* Type of the asset (file or directory).
|
|
37
|
+
*/
|
|
38
|
+
type: 'file' | 'directory';
|
|
39
|
+
}[];
|
|
40
|
+
/**
|
|
41
|
+
* Represents the content of an asset file.
|
|
42
|
+
*/
|
|
43
|
+
export type AssetFile = {
|
|
44
|
+
/**
|
|
45
|
+
* Content of the asset file as a readable stream.
|
|
46
|
+
*/
|
|
47
|
+
content: ReadableStream;
|
|
48
|
+
/**
|
|
49
|
+
* MIME type of the asset file.
|
|
50
|
+
*/
|
|
51
|
+
mime: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Base class for API interactions. Extended by specific API implementations.
|
|
55
|
+
* Not intended for direct use.
|
|
56
|
+
*/
|
|
57
|
+
export declare class ApiBase {
|
|
58
|
+
protected env: Environment;
|
|
59
|
+
protected pluginService: Client<typeof PluginService>;
|
|
60
|
+
protected pluginToken: string;
|
|
61
|
+
/**
|
|
62
|
+
* Initializes the ApiBase instance with environment settings and a plugin token.
|
|
63
|
+
*
|
|
64
|
+
* @param env - Environment configuration for API communication.
|
|
65
|
+
* @param pluginToken - Token for plugin authentication.
|
|
66
|
+
*/
|
|
67
|
+
constructor(env: Environment, pluginToken: string);
|
|
68
|
+
/**
|
|
69
|
+
* Retrieves a single plugin-scoped variable by its name.
|
|
70
|
+
* Supports dot notation for nested variable names (e.g., 'api.credentials.key').
|
|
71
|
+
*
|
|
72
|
+
* @param name - The name of the variable (1-100 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*(?:\.[_$a-zA-Z][_$a-zA-Z0-9]*)*$).
|
|
73
|
+
* @returns A promise that resolves with the variable value (undefined if not found).
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const apiUrl = await api.getSystemVariable<string>('api.url');
|
|
78
|
+
* const nested = await api.getSystemVariable<string>('config.database.host');
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
getSystemVariable<T = ValueJson>(name: string): Promise<T>;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves multiple plugin-scoped variables by their names with full type safety.
|
|
84
|
+
* Supports dot notation for nested variable names.
|
|
85
|
+
*
|
|
86
|
+
* @template T - Record type mapping variable names to their expected types.
|
|
87
|
+
* @param keys - Names of the variables to retrieve (1-100 unique names, each 1-100 chars).
|
|
88
|
+
* @returns A promise that resolves with an object mapping variable names to their typed values.
|
|
89
|
+
* @throws {ConnectError} Code.InvalidArgument if keys array is empty or exceeds 100 items.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const vars = await api.getSystemVariables<{
|
|
94
|
+
* 'api.url': string;
|
|
95
|
+
* 'api.timeout': number;
|
|
96
|
+
* 'api.enabled': boolean;
|
|
97
|
+
* }>('api.url', 'api.timeout', 'api.enabled');
|
|
98
|
+
*
|
|
99
|
+
* // Fully typed!
|
|
100
|
+
* vars['api.url']; // string
|
|
101
|
+
* vars['api.timeout']; // number
|
|
102
|
+
* vars['api.enabled']; // boolean
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
getSystemVariables<T extends Record<string, any>>(...keys: Array<keyof T & string>): Promise<T>;
|
|
106
|
+
/**
|
|
107
|
+
* Retrieves a single user-scoped variable by its name.
|
|
108
|
+
* Supports dot notation for nested variable names (e.g., 'user.preferences.theme').
|
|
109
|
+
*
|
|
110
|
+
* @param name - The name of the variable (1-100 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*(?:\.[_$a-zA-Z][_$a-zA-Z0-9]*)*$).
|
|
111
|
+
* @returns A promise that resolves with the user variable value (undefined if not found).
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const theme = await api.getUserVariable<string>('user.preferences.theme');
|
|
116
|
+
* const email = await api.getUserVariable<string>('user.email');
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
getUserVariable<T = ValueJson>(name: string): Promise<T>;
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves multiple user-scoped variables by their names with full type safety.
|
|
122
|
+
* Supports dot notation for nested variable names.
|
|
123
|
+
*
|
|
124
|
+
* @template T - Record type mapping variable names to their expected types.
|
|
125
|
+
* @param keys - Names of the user variables to retrieve (1-100 unique names, each 1-100 chars).
|
|
126
|
+
* @returns A promise that resolves with an object mapping variable names to their typed values.
|
|
127
|
+
* @throws {ConnectError} Code.InvalidArgument if keys array is empty or exceeds 100 items.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const vars = await api.getUserVariables<{
|
|
132
|
+
* 'user.email': string;
|
|
133
|
+
* 'user.age': number;
|
|
134
|
+
* 'user.verified': boolean;
|
|
135
|
+
* }>('user.email', 'user.age', 'user.verified');
|
|
136
|
+
*
|
|
137
|
+
* // Fully typed!
|
|
138
|
+
* vars['user.email']; // string
|
|
139
|
+
* vars['user.age']; // number
|
|
140
|
+
* vars['user.verified']; // boolean
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
getUserVariables<T extends Record<string, any>>(...keys: Array<keyof T & string>): Promise<T>;
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves a single user OAuth2 bearer token by its name.
|
|
146
|
+
* Returns a Token object containing the access token, type (typically 'Bearer'), and expiration timestamp.
|
|
147
|
+
*
|
|
148
|
+
* @param name - The name of the user token (1-100 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*(?:\.[_$a-zA-Z][_$a-zA-Z0-9]*)*$).
|
|
149
|
+
* @returns A promise that resolves with the Token object (undefined if not found).
|
|
150
|
+
* Token contains: { name, token, type, expires }
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const githubToken = await api.getUserToken('github');
|
|
155
|
+
* if (githubToken) {
|
|
156
|
+
* console.log(githubToken.token, githubToken.type, githubToken.expires);
|
|
157
|
+
* }
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
getUserToken(name: string): Promise<Token>;
|
|
161
|
+
/**
|
|
162
|
+
* Retrieves multiple user OAuth2 bearer tokens by their names.
|
|
163
|
+
* Each Token contains the access token, type (typically 'Bearer'), and expiration timestamp.
|
|
164
|
+
*
|
|
165
|
+
* @param names - Names of the user tokens to retrieve (1-100 unique names, each 1-100 chars).
|
|
166
|
+
* @returns A promise that resolves with an object mapping token names to their Token objects.
|
|
167
|
+
* Each Token contains: { name, token, type, expires }
|
|
168
|
+
* @throws {ConnectError} Code.InvalidArgument if names array is empty or exceeds 100 items.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* const tokens = await api.getUserTokens('github', 'google');
|
|
173
|
+
*
|
|
174
|
+
* tokens['github']; // Token | undefined
|
|
175
|
+
* tokens['google']; // Token | undefined
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
getUserTokens(...names: string[]): Promise<Record<string, Token>>;
|
|
179
|
+
/**
|
|
180
|
+
* Retrieves a single plugin OAuth2 bearer token from a service account by its name.
|
|
181
|
+
* Returns a Token object containing the access token, type (typically 'Bearer'), and expiration timestamp.
|
|
182
|
+
*
|
|
183
|
+
* @param name - The name of the plugin token (1-100 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*(?:\.[_$a-zA-Z][_$a-zA-Z0-9]*)*$).
|
|
184
|
+
* @returns A promise that resolves with the Token object (undefined if not found).
|
|
185
|
+
* Token contains: { name, token, type, expires }
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const serviceToken = await api.getSystemToken('service_account');
|
|
190
|
+
* if (serviceToken) {
|
|
191
|
+
* console.log(serviceToken.token, serviceToken.expires);
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
getSystemToken(name: string): Promise<Token>;
|
|
196
|
+
/**
|
|
197
|
+
* Retrieves multiple plugin OAuth2 bearer tokens from service accounts by their names.
|
|
198
|
+
* Each Token contains the access token, type (typically 'Bearer'), and expiration timestamp.
|
|
199
|
+
*
|
|
200
|
+
* @param names - Names of the plugin tokens to retrieve (1-100 unique names, each 1-100 chars).
|
|
201
|
+
* @returns A promise that resolves with an object mapping token names to their Token objects.
|
|
202
|
+
* Each Token contains: { name, token, type, expires }
|
|
203
|
+
* @throws {ConnectError} Code.InvalidArgument if names array is empty or exceeds 100 items.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const tokens = await api.getSystemTokens('service_account', 'backup_service');
|
|
208
|
+
*
|
|
209
|
+
* tokens['service_account']; // Token | undefined
|
|
210
|
+
* tokens['backup_service']; // Token | undefined
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
getSystemTokens(...names: string[]): Promise<Record<string, Token>>;
|
|
214
|
+
/**
|
|
215
|
+
* Creates a fetch function for user-level HTTP proxy requests.
|
|
216
|
+
*
|
|
217
|
+
* User services are vertex-level configurations where each user can provide
|
|
218
|
+
* their own certificates, API keys, and credentials.
|
|
219
|
+
*
|
|
220
|
+
* @param name - The service name defined in vertex user_services
|
|
221
|
+
* @returns A fetch function configured with HTTP proxy headers
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const fetch = api.userHttpProxy("stripe_api");
|
|
226
|
+
* const res = await fetch("https://api.stripe.com/v1/charges");
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
userHttpProxy(name: string): typeof fetch;
|
|
230
|
+
/**
|
|
231
|
+
* Creates a fetch function for system-level HTTP proxy requests.
|
|
232
|
+
*
|
|
233
|
+
* System services are plugin-wide configurations shared across all vertices.
|
|
234
|
+
* Configured once by plugin administrators.
|
|
235
|
+
*
|
|
236
|
+
* @param name - The service name defined in manifest system_services
|
|
237
|
+
* @returns A fetch function configured with HTTP proxy headers
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* const fetch = api.systemHttpProxy("internal_api");
|
|
242
|
+
* const res = await fetch("https://internal.example.com/data");
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
systemHttpProxy(name: string): typeof fetch;
|
|
246
|
+
/**
|
|
247
|
+
* Validates an access token to ensure it's authorized for the current plugin and execution context.
|
|
248
|
+
* The authorization check verifies the token has the required scopes for plugin operations.
|
|
249
|
+
*
|
|
250
|
+
* @param token - The access token to validate (max 10000 chars).
|
|
251
|
+
* @returns A promise that resolves when the token is successfully validated.
|
|
252
|
+
* @throws {ConnectError} Code.Unauthenticated if the token is invalid or Code.PermissionDenied if unauthorized.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* try {
|
|
257
|
+
* await api.authorize(userProvidedToken);
|
|
258
|
+
* // Token is valid, proceed with operations
|
|
259
|
+
* } catch (error) {
|
|
260
|
+
* // Token is invalid or lacks permissions
|
|
261
|
+
* }
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
authorize(token: string): Promise<void>;
|
|
265
|
+
/**
|
|
266
|
+
* Get information about configured system services.
|
|
267
|
+
* System services are plugin-wide configurations shared across all vertices.
|
|
268
|
+
*
|
|
269
|
+
* @returns A promise that resolves with a map of configured services where keys are service paths
|
|
270
|
+
* (using dot notation for nested services) and values indicate if the service is configured.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* const services = await api.getSystemServices();
|
|
275
|
+
* // Returns { "http_service": true, "oneof_service.option_a": true, "grouped.nested": true }
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
getSystemServices(): Promise<{
|
|
279
|
+
[key: string]: boolean;
|
|
280
|
+
}>;
|
|
281
|
+
/**
|
|
282
|
+
* Reads a file from the plugin's assets directory.
|
|
283
|
+
*
|
|
284
|
+
* @param path - The file path relative to the assets directory.
|
|
285
|
+
* @returns A promise that resolves with the file content and MIME type.
|
|
286
|
+
* @throws {ConnectError} If the file is not found or is actually a directory.
|
|
287
|
+
*/
|
|
288
|
+
readFile(path: string): Promise<AssetFile>;
|
|
289
|
+
/**
|
|
290
|
+
* Reads a directory listing from the plugin's assets directory.
|
|
291
|
+
*
|
|
292
|
+
* @param path - The directory path relative to the assets directory.
|
|
293
|
+
* @returns A promise that resolves with the directory content as an array of assets.
|
|
294
|
+
* @throws {ConnectError} If the directory is not found or is actually a file.
|
|
295
|
+
*/
|
|
296
|
+
readDirectory(path: string): Promise<AssetDirectory>;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Represents the result of a batch read operation from the store.
|
|
300
|
+
* Keys that were not found in the store are not present in the result.
|
|
301
|
+
*/
|
|
302
|
+
export declare class BatchReadResult {
|
|
303
|
+
readonly result: Record<string, GetValue>;
|
|
304
|
+
/**
|
|
305
|
+
* Constructs a BatchReadResult from the store's batch read response.
|
|
306
|
+
* @param result - Map of keys to their retrieved values (keys not found are excluded).
|
|
307
|
+
* @internal
|
|
308
|
+
*/
|
|
309
|
+
constructor(result: Record<string, GetValue>);
|
|
310
|
+
/**
|
|
311
|
+
* Retrieves the result of a specific read operation by its key as JSON.
|
|
312
|
+
*
|
|
313
|
+
* @param key - The key to retrieve from the batch result.
|
|
314
|
+
* @returns The value and metadata, or undefined if the key was not found in the store.
|
|
315
|
+
* - value: The parsed JSON value
|
|
316
|
+
* - ttl: Remaining TTL in seconds (0 = no expiration)
|
|
317
|
+
* - lastModified: When the value was last modified
|
|
318
|
+
* - etag: Entity tag for concurrency control
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```typescript
|
|
322
|
+
* const result = await store.readBatch(['user:1', 'user:2', 'user:3']);
|
|
323
|
+
* const user1 = result.get<User>('user:1');
|
|
324
|
+
* if (user1) {
|
|
325
|
+
* console.log(user1.value.name, 'TTL:', user1.ttl);
|
|
326
|
+
* }
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
get<T = any>(key: string): {
|
|
330
|
+
value: T;
|
|
331
|
+
ttl: number;
|
|
332
|
+
lastModified: Date;
|
|
333
|
+
etag: string;
|
|
334
|
+
} | undefined;
|
|
335
|
+
/**
|
|
336
|
+
* Retrieves the result of a specific read operation by its key as raw binary.
|
|
337
|
+
*
|
|
338
|
+
* @param key - The key to retrieve from the batch result.
|
|
339
|
+
* @returns The raw binary value and metadata, or undefined if the key was not found in the store.
|
|
340
|
+
* - value: The raw binary data as Uint8Array
|
|
341
|
+
* - ttl: Remaining TTL in seconds (0 = no expiration)
|
|
342
|
+
* - lastModified: When the value was last modified
|
|
343
|
+
* - etag: Entity tag for concurrency control
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* const result = await store.readBatch(['asset:1', 'asset:2']);
|
|
348
|
+
* const asset1 = result.getBinary('asset:1');
|
|
349
|
+
* if (asset1) {
|
|
350
|
+
* console.log('Size:', asset1.value.length, 'bytes');
|
|
351
|
+
* }
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
getBinary(key: string): {
|
|
355
|
+
ttl: number;
|
|
356
|
+
value: Uint8Array;
|
|
357
|
+
lastModified: Date;
|
|
358
|
+
etag: string;
|
|
359
|
+
} | undefined;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Utility class for constructing batch write operations for the KV store.
|
|
363
|
+
* Provides a fluent interface for building write batches.
|
|
364
|
+
*
|
|
365
|
+
* Note: Batch operations do not support preconditions. Use Store.insert() and Store.delete()
|
|
366
|
+
* methods directly for conditional writes.
|
|
367
|
+
*/
|
|
368
|
+
export declare class WriteBatchBuilder {
|
|
369
|
+
private ops;
|
|
370
|
+
/**
|
|
371
|
+
* Adds an insert operation to the batch for JSON data or raw binary data.
|
|
372
|
+
*
|
|
373
|
+
* @param key - The key to insert (max 4096 characters).
|
|
374
|
+
* @param value - The value to store (will be JSON-serialized unless it's Uint8Array).
|
|
375
|
+
* @param ttl - Optional time-to-live in seconds (0 = no expiration).
|
|
376
|
+
* @returns The current instance of the builder for chaining.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* const batch = new WriteBatchBuilder()
|
|
381
|
+
* .insert('user:1', { name: 'Alice' }, 3600)
|
|
382
|
+
* .insert('user:2', { name: 'Bob' })
|
|
383
|
+
* .build();
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
insert<T = any>(key: string, value: T, ttl?: number): this;
|
|
387
|
+
/**
|
|
388
|
+
* Adds a delete operation to the batch.
|
|
389
|
+
*
|
|
390
|
+
* @param key - The key to delete (max 4096 characters).
|
|
391
|
+
* @returns The current instance of the builder for chaining.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* const batch = new WriteBatchBuilder()
|
|
396
|
+
* .delete('temp:cache:1')
|
|
397
|
+
* .delete('temp:cache:2')
|
|
398
|
+
* .build();
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
delete(key: string): this;
|
|
402
|
+
/**
|
|
403
|
+
* Adds a range delete operation to the batch (lexicographic comparison).
|
|
404
|
+
*
|
|
405
|
+
* Range delete works like SelectOp for defining the range. Not setting any start or end will
|
|
406
|
+
* delete the entire store when this batch is executed.
|
|
407
|
+
*
|
|
408
|
+
* @param start - The start key of the range. If omitted, deletes from the empty key.
|
|
409
|
+
* @param end - The end key of the range. If omitted, deletes to the end.
|
|
410
|
+
* @param startInclusive - Include start (>= vs >). Defaults to `false`.
|
|
411
|
+
* @param endInclusive - Include end (<= vs <). Defaults to `false`.
|
|
412
|
+
* @returns The current instance for method chaining.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```typescript
|
|
416
|
+
* // Delete all keys with prefix "user/"
|
|
417
|
+
* builder.rangeDelete('user/', 'user/~');
|
|
418
|
+
*
|
|
419
|
+
* // Delete logs for a specific month
|
|
420
|
+
* builder.rangeDelete('logs/2024-01/', 'logs/2024-02/');
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
rangeDelete(start?: string, end?: string, startInclusive?: boolean, endInclusive?: boolean): this;
|
|
424
|
+
/**
|
|
425
|
+
* Finalizes the batch and returns the array of write operations.
|
|
426
|
+
*
|
|
427
|
+
* @returns The array of WriteOperation objects ready to be executed.
|
|
428
|
+
*/
|
|
429
|
+
build(): WriteOperation[];
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Options for lock operations.
|
|
433
|
+
*/
|
|
434
|
+
export interface LockOptions {
|
|
435
|
+
/**
|
|
436
|
+
* Maximum number of retries if the lock is not acquired immediately. Defaults to 5.
|
|
437
|
+
*/
|
|
438
|
+
maxRetries?: number;
|
|
439
|
+
/**
|
|
440
|
+
* Initial delay before retrying in milliseconds. Defaults to 50ms.
|
|
441
|
+
*/
|
|
442
|
+
initialDelay?: number;
|
|
443
|
+
/**
|
|
444
|
+
* Maximum delay between retries in milliseconds. Defaults to 2000ms.
|
|
445
|
+
*/
|
|
446
|
+
maxDelay?: number;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Preconditions for conditional insert operations.
|
|
450
|
+
* Used for implementing locks and optimistic concurrency control.
|
|
451
|
+
*
|
|
452
|
+
* IMPORTANT CONSTRAINTS (from proto validation):
|
|
453
|
+
* - failIfExists CANNOT be combined with etagEquals, timestampEquals, or timestampRange
|
|
454
|
+
* - When failIfExists is true, all other fields must be undefined
|
|
455
|
+
* - etagEquals and timestamp conditions can be used together
|
|
456
|
+
*/
|
|
457
|
+
export interface InsertCondition {
|
|
458
|
+
/**
|
|
459
|
+
* Fail the insert if the key already exists.
|
|
460
|
+
* When true, this cannot be combined with any other conditions.
|
|
461
|
+
* Useful for acquiring locks atomically.
|
|
462
|
+
*/
|
|
463
|
+
failIfExists?: boolean;
|
|
464
|
+
/**
|
|
465
|
+
* Only insert if the current etag matches this value.
|
|
466
|
+
* Cannot be used with failIfExists.
|
|
467
|
+
*/
|
|
468
|
+
etagEquals?: string;
|
|
469
|
+
/**
|
|
470
|
+
* Only insert if last_modified exactly matches this timestamp.
|
|
471
|
+
* Cannot be used with failIfExists or timestampRange.
|
|
472
|
+
*/
|
|
473
|
+
timestampEquals?: Date;
|
|
474
|
+
/**
|
|
475
|
+
* Only insert if last_modified falls within this time range.
|
|
476
|
+
* Cannot be used with failIfExists or timestampEquals.
|
|
477
|
+
*/
|
|
478
|
+
timestampRange: {
|
|
479
|
+
/**
|
|
480
|
+
* Start
|
|
481
|
+
*
|
|
482
|
+
* @generated from field: google.protobuf.Timestamp start = 1;
|
|
483
|
+
*/
|
|
484
|
+
start?: Date;
|
|
485
|
+
/**
|
|
486
|
+
* End
|
|
487
|
+
*
|
|
488
|
+
* @generated from field: google.protobuf.Timestamp end = 2;
|
|
489
|
+
*/
|
|
490
|
+
end?: Date;
|
|
491
|
+
/**
|
|
492
|
+
* Include start (>= vs >)
|
|
493
|
+
*
|
|
494
|
+
* @generated from field: bool start_inclusive = 3;
|
|
495
|
+
*/
|
|
496
|
+
startInclusive: boolean;
|
|
497
|
+
/**
|
|
498
|
+
* Include end (<= vs <)
|
|
499
|
+
*
|
|
500
|
+
* @generated from field: bool end_inclusive = 4;
|
|
501
|
+
*/
|
|
502
|
+
endInclusive: boolean;
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Preconditions for conditional delete operations.
|
|
507
|
+
* Used for safe deletion with verification.
|
|
508
|
+
*
|
|
509
|
+
* IMPORTANT CONSTRAINTS (from proto validation):
|
|
510
|
+
* - mustExists CANNOT be combined with etagEquals, timestampEquals, or timestampRange
|
|
511
|
+
* - When mustExists is true, all other fields must be undefined
|
|
512
|
+
* - etagEquals and timestamp conditions can be used together
|
|
513
|
+
*/
|
|
514
|
+
export interface DeleteCondition {
|
|
515
|
+
/**
|
|
516
|
+
* Fail the delete if the key doesn't exist.
|
|
517
|
+
* When true, this cannot be combined with any other conditions.
|
|
518
|
+
*/
|
|
519
|
+
mustExists?: boolean;
|
|
520
|
+
/**
|
|
521
|
+
* Only delete if the current etag matches this value.
|
|
522
|
+
* Cannot be used with mustExists.
|
|
523
|
+
*/
|
|
524
|
+
etagEquals?: string;
|
|
525
|
+
/**
|
|
526
|
+
* Only delete if last_modified exactly matches this timestamp.
|
|
527
|
+
* Cannot be used with mustExists or timestampRange.
|
|
528
|
+
*/
|
|
529
|
+
timestampEquals?: Date;
|
|
530
|
+
/**
|
|
531
|
+
* Only delete if last_modified falls within this time range.
|
|
532
|
+
* Cannot be used with mustExists or timestampEquals.
|
|
533
|
+
*/
|
|
534
|
+
timestampRange: {
|
|
535
|
+
/**
|
|
536
|
+
* Start
|
|
537
|
+
*
|
|
538
|
+
* @generated from field: google.protobuf.Timestamp start = 1;
|
|
539
|
+
*/
|
|
540
|
+
start?: Date;
|
|
541
|
+
/**
|
|
542
|
+
* End
|
|
543
|
+
*
|
|
544
|
+
* @generated from field: google.protobuf.Timestamp end = 2;
|
|
545
|
+
*/
|
|
546
|
+
end?: Date;
|
|
547
|
+
/**
|
|
548
|
+
* Include start (>= vs >)
|
|
549
|
+
*
|
|
550
|
+
* @generated from field: bool start_inclusive = 3;
|
|
551
|
+
*/
|
|
552
|
+
startInclusive: boolean;
|
|
553
|
+
/**
|
|
554
|
+
* Include end (<= vs <)
|
|
555
|
+
*
|
|
556
|
+
* @generated from field: bool end_inclusive = 4;
|
|
557
|
+
*/
|
|
558
|
+
endInclusive: boolean;
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Metadata returned from store write operations.
|
|
563
|
+
*/
|
|
564
|
+
export interface StoreMetadata {
|
|
565
|
+
/**
|
|
566
|
+
* Remaining time-to-live in seconds.
|
|
567
|
+
* 0 means no expiration (the value will not expire).
|
|
568
|
+
*/
|
|
569
|
+
ttl: number;
|
|
570
|
+
/**
|
|
571
|
+
* Timestamp when the value was last modified.
|
|
572
|
+
* All operations in a write batch share the same timestamp.
|
|
573
|
+
*/
|
|
574
|
+
lastModified: Date;
|
|
575
|
+
/**
|
|
576
|
+
* Entity tag for optimistic concurrency control.
|
|
577
|
+
* Changes with each modification of the value.
|
|
578
|
+
*/
|
|
579
|
+
etag: string;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Internal type for store service clients
|
|
583
|
+
* @internal
|
|
584
|
+
*/
|
|
585
|
+
type StoreServiceClient = Client<typeof ExecutorService> | Client<typeof ConfiguratorService>;
|
|
586
|
+
/**
|
|
587
|
+
* Represents a store in a specific namespace, providing key-value storage operations.
|
|
588
|
+
* Stores can be scoped to different namespaces with different lifetimes:
|
|
589
|
+
* - NAMESPACE_VERTEX: Lives as long as the plugin in the project (vertex scope)
|
|
590
|
+
* - NAMESPACE_PLUGIN: Lives as long as the plugin in the project (plugin-wide scope)
|
|
591
|
+
* - NAMESPACE_VERTEX_INSTANCE: Lives as long as the instance (vertex scope, session storage)
|
|
592
|
+
* - NAMESPACE_PLUGIN_INSTANCE: Lives as long as the instance (plugin-wide scope, session storage)
|
|
593
|
+
*/
|
|
594
|
+
export declare class Store {
|
|
595
|
+
private service;
|
|
596
|
+
private namespace;
|
|
597
|
+
/**
|
|
598
|
+
* Constructs a Store instance for a specific namespace.
|
|
599
|
+
* @param service - The gRPC service client (ExecutorService or ConfiguratorService).
|
|
600
|
+
* @param namespace - The namespace determining the store's scope and lifetime.
|
|
601
|
+
* @internal
|
|
602
|
+
*/
|
|
603
|
+
constructor(service: StoreServiceClient, namespace: NamespaceJson);
|
|
604
|
+
/**
|
|
605
|
+
* Inserts or updates a key-value pair in the store with JSON data.
|
|
606
|
+
* Supports conditional writes for implementing locks and optimistic concurrency control.
|
|
607
|
+
*
|
|
608
|
+
* @param key - The key to insert (max 4096 characters).
|
|
609
|
+
* @param value - The JSON value to store (will be JSON-serialized).
|
|
610
|
+
* @param ttl - Optional time-to-live in seconds (0 = no expiration).
|
|
611
|
+
* @param condition - Optional preconditions for the write:
|
|
612
|
+
* - failIfExists: Fail if key already exists (cannot be combined with other conditions)
|
|
613
|
+
* - etagEquals: Only write if current etag matches
|
|
614
|
+
* - timestampEquals: Only write if last_modified exactly matches
|
|
615
|
+
* - timestampRange: Only write if last_modified falls within range
|
|
616
|
+
* @returns A promise that resolves with metadata (ttl, lastModified, etag) when the operation completes.
|
|
617
|
+
* @throws {ConnectError} Code.FailedPrecondition if precondition fails, Code.InvalidArgument for invalid inputs.
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```typescript
|
|
621
|
+
* // Simple insert
|
|
622
|
+
* await store.insert('user:123', { name: 'Alice' }, 3600);
|
|
623
|
+
*
|
|
624
|
+
* // Conditional insert - fail if exists (for locks)
|
|
625
|
+
* await store.insert('lock:resource', { owner: 'process-1' }, 30, { failIfExists: true });
|
|
626
|
+
*
|
|
627
|
+
* // Optimistic concurrency with etag
|
|
628
|
+
* const data = await store.get('counter');
|
|
629
|
+
* await store.insert('counter', data.data + 1, undefined, { etagEquals: data.etag });
|
|
630
|
+
* ```
|
|
631
|
+
*/
|
|
632
|
+
insert<T = any>(key: string, value: T, ttl?: number, condition?: InsertCondition): Promise<StoreMetadata>;
|
|
633
|
+
/**
|
|
634
|
+
* Deletes a key-value pair from the store.
|
|
635
|
+
* Supports conditional deletes for safe removal operations.
|
|
636
|
+
*
|
|
637
|
+
* @param key - The key to delete (max 4096 characters).
|
|
638
|
+
* @param condition - Optional preconditions for the delete:
|
|
639
|
+
* - mustExists: Fail if key doesn't exist (cannot be combined with other conditions)
|
|
640
|
+
* - etagEquals: Only delete if current etag matches
|
|
641
|
+
* - timestampEquals: Only delete if last_modified exactly matches
|
|
642
|
+
* - timestampRange: Only delete if last_modified falls within range
|
|
643
|
+
* @returns A promise that resolves when the operation completes.
|
|
644
|
+
* @throws {ConnectError} Code.FailedPrecondition if precondition fails.
|
|
645
|
+
*
|
|
646
|
+
* @example
|
|
647
|
+
* ```typescript
|
|
648
|
+
* // Simple delete
|
|
649
|
+
* await store.delete('temp:data');
|
|
650
|
+
*
|
|
651
|
+
* // Conditional delete - only if exists
|
|
652
|
+
* await store.delete('lock:resource', { mustExists: true });
|
|
653
|
+
*
|
|
654
|
+
* // Delete with etag verification
|
|
655
|
+
* const data = await store.get('config');
|
|
656
|
+
* await store.delete('config', { etagEquals: data.etag });
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
delete(key: string, condition?: DeleteCondition): Promise<void>;
|
|
660
|
+
/**
|
|
661
|
+
* Deletes all items within a specified key range from the store (lexicographic comparison).
|
|
662
|
+
*
|
|
663
|
+
* Range delete works like SelectOp for defining the range. Not setting any start or end will
|
|
664
|
+
* delete the entire store.
|
|
665
|
+
*
|
|
666
|
+
* Note: Range delete operations do not support preconditions. For conditional deletes,
|
|
667
|
+
* use the {@link delete} method.
|
|
668
|
+
*
|
|
669
|
+
* @param start - The start key of the range. If omitted, deletes from the empty key.
|
|
670
|
+
* @param end - The end key of the range. If omitted, deletes to the end.
|
|
671
|
+
* @param startInclusive - Include start (>= vs >). Defaults to `false`.
|
|
672
|
+
* @param endInclusive - Include end (<= vs <). Defaults to `false`.
|
|
673
|
+
* @returns A promise that resolves when the range delete operation completes.
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* ```typescript
|
|
677
|
+
* // Delete all keys with prefix "user/"
|
|
678
|
+
* await store.rangeDelete('user/', 'user/~');
|
|
679
|
+
*
|
|
680
|
+
* // Delete logs for a specific month
|
|
681
|
+
* await store.rangeDelete('logs/2024-01/', 'logs/2024-02/');
|
|
682
|
+
*
|
|
683
|
+
* // Delete all items in the store
|
|
684
|
+
* await store.rangeDelete();
|
|
685
|
+
* ```
|
|
686
|
+
*/
|
|
687
|
+
rangeDelete(start?: string, end?: string, startInclusive?: boolean, endInclusive?: boolean): Promise<void>;
|
|
688
|
+
/**
|
|
689
|
+
* Retrieves a value by its key from the store as JSON.
|
|
690
|
+
*
|
|
691
|
+
* @param key - The key to retrieve (max 4096 characters).
|
|
692
|
+
* @returns A promise that resolves with the retrieved JSON value and metadata, or undefined if key not found.
|
|
693
|
+
* - data: The parsed JSON value
|
|
694
|
+
* - ttl: Remaining TTL in seconds (0 = no expiration)
|
|
695
|
+
* - etag: The ETag for optimistic concurrency control
|
|
696
|
+
* - lastModified: Timestamp of last modification
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* ```typescript
|
|
700
|
+
* const user = await store.get<User>('user:123');
|
|
701
|
+
* if (user) {
|
|
702
|
+
* console.log(user.data.name, 'expires in', user.ttl, 'seconds');
|
|
703
|
+
* }
|
|
704
|
+
* ```
|
|
705
|
+
*/
|
|
706
|
+
get<T = any>(key: string): Promise<{
|
|
707
|
+
data: T;
|
|
708
|
+
ttl: number;
|
|
709
|
+
etag: string;
|
|
710
|
+
lastModified: Date;
|
|
711
|
+
} | undefined>;
|
|
712
|
+
/**
|
|
713
|
+
* Retrieves a value by its key from the store as raw binary.
|
|
714
|
+
*
|
|
715
|
+
* @param key - The key to retrieve (max 4096 characters).
|
|
716
|
+
* @returns A promise that resolves with the retrieved binary value and metadata, or undefined if key not found.
|
|
717
|
+
* - data: The raw binary value as Uint8Array
|
|
718
|
+
* - ttl: Remaining TTL in seconds (0 = no expiration)
|
|
719
|
+
* - etag: The ETag for optimistic concurrency control
|
|
720
|
+
* - lastModified: Timestamp of last modification
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```typescript
|
|
724
|
+
* const asset = await store.getBinary('asset:image.png');
|
|
725
|
+
* if (asset) {
|
|
726
|
+
* console.log('Image size:', asset.data.length, 'bytes');
|
|
727
|
+
* }
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
730
|
+
getBinary(key: string): Promise<{
|
|
731
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
732
|
+
ttl: number;
|
|
733
|
+
etag: string;
|
|
734
|
+
lastModified: Date;
|
|
735
|
+
} | undefined>;
|
|
736
|
+
/**
|
|
737
|
+
* Performs a range query on keys using lexicographic comparison, returning parsed JSON data.
|
|
738
|
+
*
|
|
739
|
+
* Range queries allow scanning keys within a specific range. For example:
|
|
740
|
+
* - "user/" to "user/~" - all keys starting with "user/"
|
|
741
|
+
* - "logs/2024-01/" to "logs/2024-02/" - all logs from January 2024
|
|
742
|
+
*
|
|
743
|
+
* Not setting start or end will scan the entire store.
|
|
744
|
+
* Results are always returned in ascending order by key.
|
|
745
|
+
*
|
|
746
|
+
* @param select - The select operation specifying:
|
|
747
|
+
* - start: Optional start key (max 4096 chars). Omit to start from empty key
|
|
748
|
+
* - end: Optional end key (max 4096 chars)
|
|
749
|
+
* - startInclusive: Whether to include start key (>= vs >)
|
|
750
|
+
* - endInclusive: Whether to include end key (<= vs <)
|
|
751
|
+
* - limit: Max results (1-1000)
|
|
752
|
+
* - pageToken: Optional token to continue from previous query
|
|
753
|
+
* @returns A promise that resolves to an object containing:
|
|
754
|
+
* - items: Array of values with metadata (value as JSON type T, TTL, etag, lastModified)
|
|
755
|
+
* - nextToken: Optional pagination token to continue the query
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* ```typescript
|
|
759
|
+
* // Get all user keys
|
|
760
|
+
* const result = await store.selectRange<User>({
|
|
761
|
+
* start: 'user/',
|
|
762
|
+
* end: 'user/~',
|
|
763
|
+
* startInclusive: true,
|
|
764
|
+
* endInclusive: false,
|
|
765
|
+
* limit: 100
|
|
766
|
+
* });
|
|
767
|
+
*
|
|
768
|
+
* // Continue pagination
|
|
769
|
+
* if (result.nextToken) {
|
|
770
|
+
* const next = await store.selectRange({
|
|
771
|
+
* start: 'user/',
|
|
772
|
+
* end: 'user/~',
|
|
773
|
+
* startInclusive: true,
|
|
774
|
+
* endInclusive: false,
|
|
775
|
+
* limit: 100,
|
|
776
|
+
* pageToken: result.nextToken
|
|
777
|
+
* });
|
|
778
|
+
* }
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
selectRange<T = JsonValue>(select: SelectOpJson): Promise<{
|
|
782
|
+
nextToken?: string;
|
|
783
|
+
items: {
|
|
784
|
+
key: string;
|
|
785
|
+
value: T;
|
|
786
|
+
ttl: number;
|
|
787
|
+
etag: string;
|
|
788
|
+
lastModified: Date;
|
|
789
|
+
}[];
|
|
790
|
+
}>;
|
|
791
|
+
/**
|
|
792
|
+
* Performs a range query on keys using lexicographic comparison, returning raw binary data.
|
|
793
|
+
*
|
|
794
|
+
* Range queries allow scanning keys within a specific range. For example:
|
|
795
|
+
* - "user/" to "user/~" - all keys starting with "user/"
|
|
796
|
+
* - "logs/2024-01/" to "logs/2024-02/" - all logs from January 2024
|
|
797
|
+
*
|
|
798
|
+
* Not setting start or end will scan the entire store.
|
|
799
|
+
* Results are always returned in ascending order by key.
|
|
800
|
+
*
|
|
801
|
+
* @param select - The select operation specifying:
|
|
802
|
+
* - start: Optional start key (max 4096 chars). Omit to start from empty key
|
|
803
|
+
* - end: Optional end key (max 4096 chars)
|
|
804
|
+
* - startInclusive: Whether to include start key (>= vs >)
|
|
805
|
+
* - endInclusive: Whether to include end key (<= vs <)
|
|
806
|
+
* - limit: Max results (1-1000)
|
|
807
|
+
* - pageToken: Optional token to continue from previous query
|
|
808
|
+
* @returns A promise that resolves to an object containing:
|
|
809
|
+
* - items: Array of values with metadata (value as Uint8Array, TTL, etag, lastModified)
|
|
810
|
+
* - nextToken: Optional pagination token to continue the query
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```typescript
|
|
814
|
+
* // Get all binary assets
|
|
815
|
+
* const result = await store.selectRangeBinary({
|
|
816
|
+
* start: 'assets/',
|
|
817
|
+
* end: 'assets/~',
|
|
818
|
+
* startInclusive: true,
|
|
819
|
+
* endInclusive: false,
|
|
820
|
+
* limit: 50
|
|
821
|
+
* });
|
|
822
|
+
*
|
|
823
|
+
* // Continue pagination
|
|
824
|
+
* if (result.nextToken) {
|
|
825
|
+
* const next = await store.selectRangeBinary({
|
|
826
|
+
* start: 'assets/',
|
|
827
|
+
* end: 'assets/~',
|
|
828
|
+
* startInclusive: true,
|
|
829
|
+
* endInclusive: false,
|
|
830
|
+
* limit: 50,
|
|
831
|
+
* pageToken: result.nextToken
|
|
832
|
+
* });
|
|
833
|
+
* }
|
|
834
|
+
* ```
|
|
835
|
+
*/
|
|
836
|
+
selectRangeBinary(select: SelectOpJson): Promise<{
|
|
837
|
+
nextToken?: string;
|
|
838
|
+
items: {
|
|
839
|
+
value: Uint8Array<ArrayBufferLike>;
|
|
840
|
+
ttl: number;
|
|
841
|
+
etag: string;
|
|
842
|
+
lastModified: Date;
|
|
843
|
+
}[];
|
|
844
|
+
}>;
|
|
845
|
+
/**
|
|
846
|
+
* Executes a batch of write operations on the store.
|
|
847
|
+
* All operations are atomic - either all succeed or all fail.
|
|
848
|
+
* All operations in a batch share the same timestamp.
|
|
849
|
+
* Interfering operations on the same key have undefined order.
|
|
850
|
+
*
|
|
851
|
+
* Note: Batch operations do not support preconditions. Use the single insert/delete
|
|
852
|
+
* methods for conditional writes.
|
|
853
|
+
*
|
|
854
|
+
* @param ops - The write operations to execute (1-500 operations). Use WriteBatchBuilder to construct.
|
|
855
|
+
* @returns A promise that resolves with metadata for each inserted key (deletes don't return metadata).
|
|
856
|
+
* @throws {ConnectError} Code.InvalidArgument if invalid operations or limits exceeded.
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* ```typescript
|
|
860
|
+
* const ops = new WriteBatchBuilder()
|
|
861
|
+
* .insert('user:1', { name: 'Alice' }, 3600)
|
|
862
|
+
* .insert('user:2', { name: 'Bob' }, 3600)
|
|
863
|
+
* .delete('temp:old')
|
|
864
|
+
* .build();
|
|
865
|
+
*
|
|
866
|
+
* const metadata = await store.writeBatch(ops);
|
|
867
|
+
* console.log('Insert metadata:', metadata);
|
|
868
|
+
* ```
|
|
869
|
+
*/
|
|
870
|
+
writeBatch(ops: WriteOperation[]): Promise<{
|
|
871
|
+
[key: string]: StoreMetadata;
|
|
872
|
+
}>;
|
|
873
|
+
/**
|
|
874
|
+
* Executes a batch of read operations on the store.
|
|
875
|
+
* Keys not found are ignored (not present in the result).
|
|
876
|
+
*
|
|
877
|
+
* @param keys - The keys to read (1-10000 keys, each max 4096 characters).
|
|
878
|
+
* @returns A promise that resolves with a BatchReadResult containing found items.
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
* ```typescript
|
|
882
|
+
* const result = await store.readBatch(['user:1', 'user:2', 'user:3']);
|
|
883
|
+
* const user1 = result.get<User>('user:1');
|
|
884
|
+
* if (user1) {
|
|
885
|
+
* console.log(user1.value.name);
|
|
886
|
+
* }
|
|
887
|
+
* ```
|
|
888
|
+
*/
|
|
889
|
+
readBatch(keys: string[]): Promise<BatchReadResult>;
|
|
890
|
+
/**
|
|
891
|
+
* Attempts to acquire a lock for a specified duration.
|
|
892
|
+
* Uses an atomic insert operation with failIfExists precondition that fails if the key already exists.
|
|
893
|
+
*
|
|
894
|
+
* @param locker - The unique identifier for the lock (max 4096 chars).
|
|
895
|
+
* @param ttl - Time-to-live in seconds (defaults to 5 seconds if not specified).
|
|
896
|
+
* @returns A promise that resolves with true if the lock was acquired, false if already held.
|
|
897
|
+
*
|
|
898
|
+
* @example
|
|
899
|
+
* ```typescript
|
|
900
|
+
* // Try to acquire lock with default 5 second TTL
|
|
901
|
+
* const acquired = await store.acquire('resource_lock');
|
|
902
|
+
* if (acquired) {
|
|
903
|
+
* // Lock acquired, perform work
|
|
904
|
+
* }
|
|
905
|
+
*
|
|
906
|
+
* // Acquire lock with custom TTL
|
|
907
|
+
* const acquired2 = await store.acquire('long_operation', 30);
|
|
908
|
+
* ```
|
|
909
|
+
*/
|
|
910
|
+
acquire(locker: string, ttl?: number): Promise<boolean>;
|
|
911
|
+
/**
|
|
912
|
+
* Releases a previously acquired lock by deleting the lock key.
|
|
913
|
+
*
|
|
914
|
+
* @param locker - The unique identifier for the lock (max 4096 chars).
|
|
915
|
+
* @returns A promise that resolves when the lock is released.
|
|
916
|
+
*
|
|
917
|
+
* @example
|
|
918
|
+
* ```typescript
|
|
919
|
+
* await store.release('resource_lock');
|
|
920
|
+
* ```
|
|
921
|
+
*/
|
|
922
|
+
release(locker: string): Promise<void>;
|
|
923
|
+
/**
|
|
924
|
+
* Acquires a lock and executes a critical section of code with exponential backoff retry logic.
|
|
925
|
+
* Automatically releases the lock after the section completes or fails.
|
|
926
|
+
*
|
|
927
|
+
* The retry mechanism uses exponential backoff:
|
|
928
|
+
* - Delay = min(initialDelay * 2^attempt, maxDelay)
|
|
929
|
+
* - Default: 50ms, 100ms, 200ms, 400ms, 800ms (capped at maxDelay)
|
|
930
|
+
*
|
|
931
|
+
* @template T - The return type of the critical section function.
|
|
932
|
+
* @param key - The unique identifier for the lock (max 4096 chars).
|
|
933
|
+
* @param section - The critical section to execute once the lock is acquired.
|
|
934
|
+
* @param options - Optional lock options:
|
|
935
|
+
* - maxRetries: Maximum retry attempts (default: 5)
|
|
936
|
+
* - initialDelay: Initial delay in ms before first retry (default: 50ms)
|
|
937
|
+
* - maxDelay: Maximum delay in ms between retries (default: 2000ms)
|
|
938
|
+
* @returns A promise that resolves with the result of the critical section.
|
|
939
|
+
* @throws {Error} If the lock cannot be acquired after maxRetries attempts.
|
|
940
|
+
*
|
|
941
|
+
* @example
|
|
942
|
+
* ```typescript
|
|
943
|
+
* const result = await store.lock('counter_lock', async () => {
|
|
944
|
+
* const counter = await store.get<number>('counter');
|
|
945
|
+
* await store.insert('counter', (counter?.data ?? 0) + 1);
|
|
946
|
+
* return counter?.data ?? 0;
|
|
947
|
+
* });
|
|
948
|
+
*
|
|
949
|
+
* // With custom options
|
|
950
|
+
* const result2 = await store.lock('resource', async () => {
|
|
951
|
+
* // critical work
|
|
952
|
+
* }, { maxRetries: 10, initialDelay: 100, maxDelay: 5000 });
|
|
953
|
+
* ```
|
|
954
|
+
*/
|
|
955
|
+
lock<T>(key: string, section: () => Promise<T>, options?: LockOptions): Promise<T>;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Provides access to the least privileged Executor API, without session capabilities.
|
|
959
|
+
* This API allows plugins to interact with vertex configuration and local storage.
|
|
960
|
+
*/
|
|
961
|
+
export declare class ExecutorApi extends ApiBase {
|
|
962
|
+
protected executor: Client<typeof ExecutorService>;
|
|
963
|
+
/**
|
|
964
|
+
* Initializes an instance of ExecutorApi.
|
|
965
|
+
*
|
|
966
|
+
* @param env - The executor environment configuration.
|
|
967
|
+
* @param pluginToken - The plugin token for authorization.
|
|
968
|
+
*/
|
|
969
|
+
constructor(env: ExecutorEnvironment, pluginToken: string);
|
|
970
|
+
/**
|
|
971
|
+
* Get vertex configuration with JSON-parsed config field.
|
|
972
|
+
* Optionally specify which fields to include in the response.
|
|
973
|
+
*
|
|
974
|
+
* @template T - Type of the config object (defaults to any)
|
|
975
|
+
* @param fields - Optional field names to include. If not specified, returns all fields.
|
|
976
|
+
* @returns Object containing the requested fields with config as parsed JSON (type T).
|
|
977
|
+
*
|
|
978
|
+
* @example
|
|
979
|
+
* ```typescript
|
|
980
|
+
* // Get all fields (all fields are guaranteed to be present)
|
|
981
|
+
* const {config, metadata, services} = await api.getConfig<Settings>();
|
|
982
|
+
*
|
|
983
|
+
* // Get only config with type - result type is { config: Settings }
|
|
984
|
+
* const {config} = await api.getConfig<Settings>('config');
|
|
985
|
+
*
|
|
986
|
+
* // Get config and metadata - result type is { config: Settings; metadata: VertexMetadataJson }
|
|
987
|
+
* const {config, metadata} = await api.getConfig<Settings>('config', 'metadata');
|
|
988
|
+
* ```
|
|
989
|
+
*/
|
|
990
|
+
getConfig<T = any>(): Promise<{
|
|
991
|
+
config: T;
|
|
992
|
+
metadata: VertexMetadataJson;
|
|
993
|
+
configuredServices: {
|
|
994
|
+
[key: string]: boolean;
|
|
995
|
+
};
|
|
996
|
+
}>;
|
|
997
|
+
getConfig<T = any, K extends 'config' | 'metadata' | 'configuredServices' = 'config' | 'metadata' | 'configuredServices'>(...fields: K[]): Promise<Pick<{
|
|
998
|
+
config: T;
|
|
999
|
+
metadata: VertexMetadataJson;
|
|
1000
|
+
configuredServices: {
|
|
1001
|
+
[key: string]: boolean;
|
|
1002
|
+
};
|
|
1003
|
+
}, K>>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Get vertex configuration with binary config field (Uint8Array).
|
|
1006
|
+
* Optionally specify which fields to include in the response.
|
|
1007
|
+
*
|
|
1008
|
+
* @param fields - Optional field names to include. If not specified, returns all fields.
|
|
1009
|
+
* @returns Object containing the requested fields with config as raw Uint8Array.
|
|
1010
|
+
*
|
|
1011
|
+
* @example
|
|
1012
|
+
* ```typescript
|
|
1013
|
+
* // Get all fields with binary config (all guaranteed present)
|
|
1014
|
+
* const {config, metadata, services} = await api.getConfigBinary();
|
|
1015
|
+
*
|
|
1016
|
+
* // Get only binary config - result type is { config: Uint8Array }
|
|
1017
|
+
* const {config} = await api.getConfigBinary('config');
|
|
1018
|
+
* ```
|
|
1019
|
+
*/
|
|
1020
|
+
getConfigBinary(): Promise<{
|
|
1021
|
+
config: Uint8Array;
|
|
1022
|
+
metadata: VertexMetadataJson;
|
|
1023
|
+
configuredServices: {
|
|
1024
|
+
[key: string]: boolean;
|
|
1025
|
+
};
|
|
1026
|
+
}>;
|
|
1027
|
+
getConfigBinary<K extends 'config' | 'metadata' | 'configuredServices' = 'config' | 'metadata' | 'configuredServices'>(...fields: K[]): Promise<Pick<{
|
|
1028
|
+
config: Uint8Array;
|
|
1029
|
+
metadata: VertexMetadataJson;
|
|
1030
|
+
configuredServices: {
|
|
1031
|
+
[key: string]: boolean;
|
|
1032
|
+
};
|
|
1033
|
+
}, K>>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Provides access to a local store instance, scoped by namespace.
|
|
1036
|
+
*
|
|
1037
|
+
* Namespace lifetimes:
|
|
1038
|
+
* - 'vertex' (NAMESPACE_VERTEX): Vertex-scoped, lives as long as the plugin in the project
|
|
1039
|
+
* - 'plugin' (NAMESPACE_PLUGIN): Plugin-wide scope, lives as long as the plugin in the project
|
|
1040
|
+
*
|
|
1041
|
+
* Access scopes:
|
|
1042
|
+
* - NAMESPACE_VERTEX: runtimeapi/executor.store.vertex.app, runtimeapi/executor.store.vertex.app:read
|
|
1043
|
+
* - NAMESPACE_PLUGIN: runtimeapi/executor.store.plugin.app, runtimeapi/executor.store.plugin.app:read
|
|
1044
|
+
*
|
|
1045
|
+
* @param namespace - The namespace for the store, either 'vertex' or 'plugin'.
|
|
1046
|
+
* @returns An instance of Store configured for the specified namespace.
|
|
1047
|
+
*/
|
|
1048
|
+
getLocalStore(namespace: 'vertex' | 'plugin'): Store;
|
|
1049
|
+
/**
|
|
1050
|
+
* Retrieves a session-scoped API with the provided authorization header.
|
|
1051
|
+
* Session APIs have additional capabilities like sending signals and managing exchanges.
|
|
1052
|
+
*
|
|
1053
|
+
* @param authHeader - The authorization header to use for the session API (e.g., 'Bearer <access-token>').
|
|
1054
|
+
* @returns An instance of SessionExecutorApi configured with the provided auth header.
|
|
1055
|
+
*/
|
|
1056
|
+
getSessionApi(authHeader: string): SessionExecutorApi;
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Provides an API with session storage capabilities, specifically for use when a session is stopping.
|
|
1060
|
+
* This API allows access to session-scoped stores that persist for the lifetime of the instance.
|
|
1061
|
+
*/
|
|
1062
|
+
export declare class StopExecutorApi extends ExecutorApi {
|
|
1063
|
+
/**
|
|
1064
|
+
* The session authorization header for session-based operations.
|
|
1065
|
+
*/
|
|
1066
|
+
protected sessionAuthHeader: string;
|
|
1067
|
+
/**
|
|
1068
|
+
* Initializes an instance of StopExecutorApi.
|
|
1069
|
+
*
|
|
1070
|
+
* @param env - The executor environment configuration.
|
|
1071
|
+
* @param pluginToken - The plugin token for authorization.
|
|
1072
|
+
* @param sessionAuthHeader - The authorization header for session-based operations.
|
|
1073
|
+
*/
|
|
1074
|
+
constructor(env: ExecutorEnvironment, pluginToken: string, sessionAuthHeader: string);
|
|
1075
|
+
/**
|
|
1076
|
+
* Retrieves the session authorization header used for this API instance.
|
|
1077
|
+
* This header contains the session access token and can be used to create
|
|
1078
|
+
* additional session-scoped API instances or for custom authorization needs.
|
|
1079
|
+
*
|
|
1080
|
+
* @returns The session authorization header (format: 'Bearer <token>').
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* ```typescript
|
|
1084
|
+
* const authHeader = api.getAuthHeader();
|
|
1085
|
+
* // Use for creating another session API or custom requests
|
|
1086
|
+
* ```
|
|
1087
|
+
*/
|
|
1088
|
+
getAuthHeader(): string;
|
|
1089
|
+
/**
|
|
1090
|
+
* Retrieves a session-specific store instance based on the provided namespace.
|
|
1091
|
+
* Session stores persist for the lifetime of the instance (the running session).
|
|
1092
|
+
*
|
|
1093
|
+
* Namespace lifetimes:
|
|
1094
|
+
* - 'vertex' (NAMESPACE_VERTEX_INSTANCE): Vertex-scoped, lives as long as the instance
|
|
1095
|
+
* - 'plugin' (NAMESPACE_PLUGIN_INSTANCE): Plugin-wide scope, lives as long as the instance
|
|
1096
|
+
*
|
|
1097
|
+
* Access scopes:
|
|
1098
|
+
* - NAMESPACE_VERTEX_INSTANCE: runtimeapi/executor.store.vertex.instance, runtimeapi/executor.store.vertex.instance:read
|
|
1099
|
+
* - NAMESPACE_PLUGIN_INSTANCE: runtimeapi/executor.store.plugin.instance, runtimeapi/executor.store.plugin.instance:read
|
|
1100
|
+
*
|
|
1101
|
+
* @param namespace - The namespace for the store, either 'vertex' or 'plugin'.
|
|
1102
|
+
* @returns An instance of Store configured for the session's namespace.
|
|
1103
|
+
*/
|
|
1104
|
+
getSessionStore(namespace: 'vertex' | 'plugin'): Store;
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Options for listing bound receiver signals.
|
|
1108
|
+
*/
|
|
1109
|
+
export interface ListSignalsOptions {
|
|
1110
|
+
/**
|
|
1111
|
+
* Number of signals per page (max 500, defaults to 50 if not specified).
|
|
1112
|
+
*/
|
|
1113
|
+
pageSize?: number;
|
|
1114
|
+
/**
|
|
1115
|
+
* Whether to order signals in descending order.
|
|
1116
|
+
*/
|
|
1117
|
+
orderDescending?: boolean;
|
|
1118
|
+
/**
|
|
1119
|
+
* Cursor for pagination (max 500 chars).
|
|
1120
|
+
* Used internally by continueListSignals - typically you don't set this directly.
|
|
1121
|
+
* @internal
|
|
1122
|
+
*/
|
|
1123
|
+
cursor?: string;
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Provides access to the Privileged Executor API, allowing session-based operations.
|
|
1127
|
+
* This API enables sending signals, managing exchanges, and accessing receiver signals.
|
|
1128
|
+
*/
|
|
1129
|
+
export declare class SessionExecutorApi extends StopExecutorApi {
|
|
1130
|
+
/**
|
|
1131
|
+
* Initializes an instance of SessionExecutorApi.
|
|
1132
|
+
*
|
|
1133
|
+
* @param env - The executor environment configuration.
|
|
1134
|
+
* @param pluginToken - The plugin token for authorization.
|
|
1135
|
+
* @param sessionAuthHeader - The authorization header for session access.
|
|
1136
|
+
*/
|
|
1137
|
+
constructor(env: ExecutorEnvironment, pluginToken: string, sessionAuthHeader: string);
|
|
1138
|
+
/**
|
|
1139
|
+
* Lists signals bound to the receiver that activated this vertex, returning parsed JSON data.
|
|
1140
|
+
*
|
|
1141
|
+
* Signal retrieval is always scoped to the specific receiver that triggered
|
|
1142
|
+
* the vertex execution, providing access to the contextual data that initiated
|
|
1143
|
+
* this workflow.
|
|
1144
|
+
*
|
|
1145
|
+
* IMPORTANT: The response payload is limited to a maximum of 16MB.
|
|
1146
|
+
* If the total size of all signals would exceed this limit, the response
|
|
1147
|
+
* will be truncated and a cursor will be provided to continue fetching
|
|
1148
|
+
* the remaining signals in subsequent requests.
|
|
1149
|
+
*
|
|
1150
|
+
* @param options - Optional listing options:
|
|
1151
|
+
* - pageSize: Number of signals per page (max 500, defaults to 50)
|
|
1152
|
+
* - orderDescending: Whether to order signals in descending order
|
|
1153
|
+
* @returns A promise that resolves to the list of signals, receiver name, and a cursor for pagination.
|
|
1154
|
+
*
|
|
1155
|
+
* @example
|
|
1156
|
+
* ```typescript
|
|
1157
|
+
* const result = await api.listSignals({ pageSize: 10 });
|
|
1158
|
+
* result.signals // Record<string, ValueJson>
|
|
1159
|
+
* ```
|
|
1160
|
+
*/
|
|
1161
|
+
listSignals(options?: ListSignalsOptions): Promise<{
|
|
1162
|
+
signals: Record<string, ValueJson>;
|
|
1163
|
+
receiver: string;
|
|
1164
|
+
cursor?: string;
|
|
1165
|
+
}>;
|
|
1166
|
+
/**
|
|
1167
|
+
* Lists signals bound to the receiver that activated this vertex, returning raw binary data.
|
|
1168
|
+
*
|
|
1169
|
+
* Signal retrieval is always scoped to the specific receiver that triggered
|
|
1170
|
+
* the vertex execution, providing access to the contextual data that initiated
|
|
1171
|
+
* this workflow.
|
|
1172
|
+
*
|
|
1173
|
+
* IMPORTANT: The response payload is limited to a maximum of 16MB.
|
|
1174
|
+
* If the total size of all signals would exceed this limit, the response
|
|
1175
|
+
* will be truncated and a cursor will be provided to continue fetching
|
|
1176
|
+
* the remaining signals in subsequent requests.
|
|
1177
|
+
*
|
|
1178
|
+
* @param options - Optional listing options:
|
|
1179
|
+
* - pageSize: Number of signals per page (max 500, defaults to 50)
|
|
1180
|
+
* - orderDescending: Whether to order signals in descending order
|
|
1181
|
+
* @returns A promise that resolves to the list of binary signals, receiver name, and a cursor for pagination.
|
|
1182
|
+
*
|
|
1183
|
+
* @example
|
|
1184
|
+
* ```typescript
|
|
1185
|
+
* const result = await api.listSignalsBinary({ pageSize: 10 });
|
|
1186
|
+
* result.signals // Record<string, SignalData>
|
|
1187
|
+
* ```
|
|
1188
|
+
*/
|
|
1189
|
+
listSignalsBinary(options?: ListSignalsOptions): Promise<{
|
|
1190
|
+
signals: Record<string, SignalData>;
|
|
1191
|
+
receiver: string;
|
|
1192
|
+
cursor?: string;
|
|
1193
|
+
}>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Continues listing signals bound to the receiver that activated this vertex from a given cursor, returning parsed JSON data.
|
|
1196
|
+
*
|
|
1197
|
+
* Signal retrieval is always scoped to the specific receiver that triggered
|
|
1198
|
+
* the vertex execution, providing access to the contextual data that initiated
|
|
1199
|
+
* this workflow.
|
|
1200
|
+
*
|
|
1201
|
+
* @param cursor - The cursor to continue from.
|
|
1202
|
+
* @returns A promise that resolves to the next set of signals, receiver name, and a new cursor for further pagination.
|
|
1203
|
+
*
|
|
1204
|
+
* @example
|
|
1205
|
+
* ```typescript
|
|
1206
|
+
* const result = await api.continueListSignals(cursor);
|
|
1207
|
+
* result.signals // Record<string, ValueJson>
|
|
1208
|
+
* ```
|
|
1209
|
+
*/
|
|
1210
|
+
continueListSignals(cursor: string): Promise<{
|
|
1211
|
+
signals: Record<string, ValueJson>;
|
|
1212
|
+
receiver: string;
|
|
1213
|
+
cursor?: string;
|
|
1214
|
+
}>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Continues listing signals bound to the receiver that activated this vertex from a given cursor, returning raw binary data.
|
|
1217
|
+
*
|
|
1218
|
+
* Signal retrieval is always scoped to the specific receiver that triggered
|
|
1219
|
+
* the vertex execution, providing access to the contextual data that initiated
|
|
1220
|
+
* this workflow.
|
|
1221
|
+
*
|
|
1222
|
+
* @param cursor - The cursor to continue from.
|
|
1223
|
+
* @returns A promise that resolves to the next set of binary signals, receiver name, and a new cursor for further pagination.
|
|
1224
|
+
*
|
|
1225
|
+
* @example
|
|
1226
|
+
* ```typescript
|
|
1227
|
+
* const result = await api.continueListSignalsBinary(cursor);
|
|
1228
|
+
* result.signals // Record<string, Uint8Array<ArrayBufferLike>>
|
|
1229
|
+
* ```
|
|
1230
|
+
*/
|
|
1231
|
+
continueListSignalsBinary(cursor: string): Promise<{
|
|
1232
|
+
signals: Record<string, SignalData>;
|
|
1233
|
+
receiver: string;
|
|
1234
|
+
cursor?: string;
|
|
1235
|
+
}>;
|
|
1236
|
+
/**
|
|
1237
|
+
* Retrieves a signal bound to the receiver that activated this vertex, returning parsed JSON data.
|
|
1238
|
+
*
|
|
1239
|
+
* Signal retrieval is always scoped to the specific receiver that triggered
|
|
1240
|
+
* the vertex execution, providing access to the contextual data that initiated
|
|
1241
|
+
* this workflow.
|
|
1242
|
+
*
|
|
1243
|
+
* @param name - The name of the signal (1-512 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$).
|
|
1244
|
+
* @returns A promise that resolves to the signal data, or undefined if not set.
|
|
1245
|
+
*
|
|
1246
|
+
* @example
|
|
1247
|
+
* ```typescript
|
|
1248
|
+
* const user = await api.getSignal<{name: string}>('user'); // {name: string} | undefined
|
|
1249
|
+
* ```
|
|
1250
|
+
*/
|
|
1251
|
+
getSignal<T = ValueJson | undefined>(name: string): Promise<T>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Retrieves a signal bound to the receiver that activated this vertex, returning raw binary data.
|
|
1254
|
+
*
|
|
1255
|
+
* Signal retrieval is always scoped to the specific receiver that triggered
|
|
1256
|
+
* the vertex execution, providing access to the contextual data that initiated
|
|
1257
|
+
* this workflow.
|
|
1258
|
+
*
|
|
1259
|
+
* @param name - The name of the signal (1-512 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$).
|
|
1260
|
+
* @returns A promise that resolves to the signal data as Uint8Array, or undefined if not set.
|
|
1261
|
+
*
|
|
1262
|
+
* @example
|
|
1263
|
+
* ```typescript
|
|
1264
|
+
* const binary = await api.getSignalBinary('avatar'); // SignalData | undefined
|
|
1265
|
+
* ```
|
|
1266
|
+
*/
|
|
1267
|
+
getSignalBinary(name: string): Promise<SignalData | undefined>;
|
|
1268
|
+
/**
|
|
1269
|
+
* Retrieves multiple signals bound to the receiver that activated this vertex in a single batch operation with full type safety.
|
|
1270
|
+
*
|
|
1271
|
+
* Signal retrieval is always scoped to the specific receiver that triggered
|
|
1272
|
+
* the vertex execution, providing access to the contextual data that initiated
|
|
1273
|
+
* this workflow.
|
|
1274
|
+
*
|
|
1275
|
+
* @template T - Record type mapping signal names to their expected types.
|
|
1276
|
+
* @param names - Names of the signals to retrieve (1-500 unique names, each 1-512 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$).
|
|
1277
|
+
* @returns A promise that resolves with an object mapping signal names to their typed values.
|
|
1278
|
+
* @throws {ConnectError} Code.InvalidArgument if names array is empty or exceeds 500 items.
|
|
1279
|
+
*
|
|
1280
|
+
* @example
|
|
1281
|
+
* ```typescript
|
|
1282
|
+
* const signals = await api.getSignals<{
|
|
1283
|
+
* 'user': { name: string; email: string };
|
|
1284
|
+
* 'settings': { theme: string; notifications: boolean };
|
|
1285
|
+
* 'count': number;
|
|
1286
|
+
* }>('user', 'settings', 'count');
|
|
1287
|
+
*
|
|
1288
|
+
* // Fully typed!
|
|
1289
|
+
* signals['user']; // { name: string; email: string }
|
|
1290
|
+
* signals['settings']; // { theme: string; notifications: boolean }
|
|
1291
|
+
* signals['count']; // number
|
|
1292
|
+
* ```
|
|
1293
|
+
*/
|
|
1294
|
+
getSignals<T extends Record<string, any>>(...names: Array<keyof T & string>): Promise<T>;
|
|
1295
|
+
/**
|
|
1296
|
+
* Retrieves multiple signals bound to the receiver that activated this vertex in a single batch operation, returning raw binary data.
|
|
1297
|
+
*
|
|
1298
|
+
* Signal retrieval is always scoped to the specific receiver that triggered
|
|
1299
|
+
* the vertex execution, providing access to the contextual data that initiated
|
|
1300
|
+
* this workflow.
|
|
1301
|
+
*
|
|
1302
|
+
* @param names - The names of the signals to retrieve (1-500 unique names, each 1-512 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$).
|
|
1303
|
+
* @returns A promise that resolves to a record mapping signal names to their binary data.
|
|
1304
|
+
* @throws {ConnectError} Code.InvalidArgument if names array is empty or exceeds 500 items.
|
|
1305
|
+
*
|
|
1306
|
+
* @example
|
|
1307
|
+
* ```typescript
|
|
1308
|
+
* const binaries = await api.getSignalsBinary('avatar', 'thumbnail', 'document');
|
|
1309
|
+
* binaries['avatar']; // SignalData
|
|
1310
|
+
* binaries['thumbnail']; // SignalData
|
|
1311
|
+
* ```
|
|
1312
|
+
*/
|
|
1313
|
+
getSignalsBinary(...names: string[]): Promise<Record<string, SignalData>>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Sends data on the specified transmitter with the given signals.
|
|
1316
|
+
* For stream transmitters, this sends data but does not advance the cursor position in the graph.
|
|
1317
|
+
*
|
|
1318
|
+
* Signal values can be either JSON data or raw binary data (Uint8Array). The method
|
|
1319
|
+
* automatically detects the type and encodes accordingly.
|
|
1320
|
+
*
|
|
1321
|
+
* @param transmitter - The identifier of the transmitter (max 100 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$, optional).
|
|
1322
|
+
* @param signals - Signals to transmit (0-50 signals, each signal name 1-512 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$).
|
|
1323
|
+
* Values can be JSON or Uint8Array.
|
|
1324
|
+
* @returns A promise that resolves when the send operation is completed.
|
|
1325
|
+
* @throws {ConnectError} Code.InvalidArgument if transmitter or signal constraints are violated.
|
|
1326
|
+
*
|
|
1327
|
+
* @example
|
|
1328
|
+
* ```typescript
|
|
1329
|
+
* // Send JSON signals
|
|
1330
|
+
* await api.send('output', {
|
|
1331
|
+
* user: { name: 'John', age: 30 },
|
|
1332
|
+
* status: 'success'
|
|
1333
|
+
* });
|
|
1334
|
+
*
|
|
1335
|
+
* // Send binary signals
|
|
1336
|
+
* await api.send('output', {
|
|
1337
|
+
* avatar: new Uint8Array([...]),
|
|
1338
|
+
* document: new Uint8Array([...])
|
|
1339
|
+
* });
|
|
1340
|
+
*
|
|
1341
|
+
* // Mix JSON and binary
|
|
1342
|
+
* await api.send('output', {
|
|
1343
|
+
* user: { name: 'John' },
|
|
1344
|
+
* avatar: new Uint8Array([...])
|
|
1345
|
+
* });
|
|
1346
|
+
* ```
|
|
1347
|
+
*/
|
|
1348
|
+
send(transmitter?: string, signals?: {
|
|
1349
|
+
[name: string]: any | {
|
|
1350
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
1351
|
+
mimeType: string;
|
|
1352
|
+
filename?: string;
|
|
1353
|
+
};
|
|
1354
|
+
}): Promise<void>;
|
|
1355
|
+
/**
|
|
1356
|
+
* Dispatches an exchange operation with a specific receiver and set of signals.
|
|
1357
|
+
* Exchanges are asynchronous operations that can return results through transmitters.
|
|
1358
|
+
*
|
|
1359
|
+
* Signal values can be either JSON data or raw binary data (Uint8Array). The method
|
|
1360
|
+
* automatically detects the type and encodes accordingly.
|
|
1361
|
+
*
|
|
1362
|
+
* @param name - The name of the exchange to dispatch (1-100 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$).
|
|
1363
|
+
* @param receiver - The receiver to dispatch the exchange to (1-100 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$).
|
|
1364
|
+
* @param signals - Signals to send with the exchange (0-50 signals, each signal name 1-512 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$).
|
|
1365
|
+
* Values can be JSON or Uint8Array.
|
|
1366
|
+
* @returns A promise that resolves to the exchange operation details.
|
|
1367
|
+
* @throws {ConnectError} Code.InvalidArgument if name, receiver, or signal constraints are violated.
|
|
1368
|
+
*
|
|
1369
|
+
* @example
|
|
1370
|
+
* ```typescript
|
|
1371
|
+
* // Dispatch exchange with JSON signals
|
|
1372
|
+
* const op = await api.dispatchExchange('process_user', 'user_handler', {
|
|
1373
|
+
* user: { name: 'John', age: 30 },
|
|
1374
|
+
* action: 'create'
|
|
1375
|
+
* });
|
|
1376
|
+
*
|
|
1377
|
+
* // Dispatch exchange with binary signals
|
|
1378
|
+
* const op = await api.dispatchExchange('process_image', 'image_handler', {
|
|
1379
|
+
* image: new Uint8Array([...]),
|
|
1380
|
+
* metadata: { width: 800, height: 600 }
|
|
1381
|
+
* });
|
|
1382
|
+
* ```
|
|
1383
|
+
*/
|
|
1384
|
+
dispatchExchange(name: string, receiver: string, signals?: {
|
|
1385
|
+
[name: string]: any | {
|
|
1386
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
1387
|
+
mimeType: string;
|
|
1388
|
+
filename?: string;
|
|
1389
|
+
};
|
|
1390
|
+
}): Promise<ExchangeOperation>;
|
|
1391
|
+
/**
|
|
1392
|
+
* Retrieves an exchange operation by its ID to check its status and results.
|
|
1393
|
+
*
|
|
1394
|
+
* @param id - The UUID of the exchange operation (must be a valid UUID).
|
|
1395
|
+
* @returns A promise that resolves to the exchange operation details.
|
|
1396
|
+
* @throws {ConnectError} Code.NotFound if the exchange operation doesn't exist.
|
|
1397
|
+
*
|
|
1398
|
+
* @example
|
|
1399
|
+
* ```typescript
|
|
1400
|
+
* const op = await api.getExchange('550e8400-e29b-41d4-a716-446655440000');
|
|
1401
|
+
* console.log('Status:', op.status);
|
|
1402
|
+
* ```
|
|
1403
|
+
*/
|
|
1404
|
+
getExchange(id: string): Promise<ExchangeOperation>;
|
|
1405
|
+
/**
|
|
1406
|
+
* Cancels an ongoing exchange operation by its ID.
|
|
1407
|
+
* If the exchange is already completed or cancelled, this operation is idempotent.
|
|
1408
|
+
*
|
|
1409
|
+
* @param id - The UUID of the exchange operation to cancel (must be a valid UUID).
|
|
1410
|
+
* @returns A promise that resolves when the exchange is successfully canceled.
|
|
1411
|
+
*
|
|
1412
|
+
* @example
|
|
1413
|
+
* ```typescript
|
|
1414
|
+
* await api.cancelExchange('550e8400-e29b-41d4-a716-446655440000');
|
|
1415
|
+
* ```
|
|
1416
|
+
*/
|
|
1417
|
+
cancelExchange(id: string): Promise<void>;
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Options for posting vertex configuration.
|
|
1421
|
+
*
|
|
1422
|
+
* Config semantics:
|
|
1423
|
+
* - Set config to a value (object or Uint8Array) to update it
|
|
1424
|
+
* - Set config to empty Uint8Array (new Uint8Array()) to clear it
|
|
1425
|
+
* - Omit config (undefined) to keep existing config unchanged
|
|
1426
|
+
*
|
|
1427
|
+
* Metadata semantics:
|
|
1428
|
+
* - Set metadata to update it
|
|
1429
|
+
* - Omit metadata (undefined) to keep existing metadata unchanged
|
|
1430
|
+
* - Metadata cannot be cleared
|
|
1431
|
+
*
|
|
1432
|
+
* At least one of config or metadata MUST be provided.
|
|
1433
|
+
*/
|
|
1434
|
+
export interface PostConfigOptions<Config = any> {
|
|
1435
|
+
/**
|
|
1436
|
+
* Set this to true if you would like to override any bindings that already exist.
|
|
1437
|
+
* This should be used if the plugin is handling signal bindings itself.
|
|
1438
|
+
* When true, the plugin takes full control of receiver/transmitter bindings.
|
|
1439
|
+
*/
|
|
1440
|
+
overrideBindings?: boolean;
|
|
1441
|
+
/**
|
|
1442
|
+
* The configuration to set. Can be either a typed object (which will be JSON-serialized)
|
|
1443
|
+
* or raw Uint8Array.
|
|
1444
|
+
* - Set to value: Updates the config
|
|
1445
|
+
* - Set to empty Uint8Array: Clears the config
|
|
1446
|
+
* - Omit (undefined): Keeps existing config unchanged
|
|
1447
|
+
*/
|
|
1448
|
+
config?: Config | Uint8Array;
|
|
1449
|
+
/**
|
|
1450
|
+
* Metadata to update with the configuration.
|
|
1451
|
+
* - Set to value: Updates the metadata
|
|
1452
|
+
* - Omit (undefined): Keeps existing metadata unchanged
|
|
1453
|
+
* - Cannot be cleared (must always have a value if present)
|
|
1454
|
+
*/
|
|
1455
|
+
metadata?: VertexMetadataJson;
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* API for interacting with the Configurator service.
|
|
1459
|
+
* This API allows plugins to manage vertex configuration and access persistent storage.
|
|
1460
|
+
*/
|
|
1461
|
+
export declare class ConfiguratorApi extends ApiBase {
|
|
1462
|
+
private configurator;
|
|
1463
|
+
/**
|
|
1464
|
+
* Initializes an instance of ConfiguratorApi.
|
|
1465
|
+
*
|
|
1466
|
+
* @param env - The environment configuration for the Configurator.
|
|
1467
|
+
* @param pluginToken - The plugin token for authorization.
|
|
1468
|
+
*/
|
|
1469
|
+
constructor(env: ConfiguratorEnvironment, pluginToken: string);
|
|
1470
|
+
/**
|
|
1471
|
+
* Get vertex configuration with JSON-parsed config field.
|
|
1472
|
+
* Optionally specify which fields to include in the response.
|
|
1473
|
+
*
|
|
1474
|
+
* @template T - Type of the config object (defaults to any)
|
|
1475
|
+
* @param fields - Optional field names to include. If not specified, returns all fields.
|
|
1476
|
+
* @returns Object containing the requested fields with config as parsed JSON (type T).
|
|
1477
|
+
*/
|
|
1478
|
+
getConfig<T = any>(): Promise<{
|
|
1479
|
+
config: T;
|
|
1480
|
+
metadata: VertexMetadataJson;
|
|
1481
|
+
configuredServices: {
|
|
1482
|
+
[key: string]: boolean;
|
|
1483
|
+
};
|
|
1484
|
+
}>;
|
|
1485
|
+
getConfig<T = any, K extends 'config' | 'metadata' | 'configuredServices' = 'config' | 'metadata' | 'configuredServices'>(...fields: K[]): Promise<Pick<{
|
|
1486
|
+
config: T;
|
|
1487
|
+
metadata: VertexMetadataJson;
|
|
1488
|
+
configuredServices: {
|
|
1489
|
+
[key: string]: boolean;
|
|
1490
|
+
};
|
|
1491
|
+
}, K>>;
|
|
1492
|
+
/**
|
|
1493
|
+
* Get vertex configuration with binary config field (Uint8Array).
|
|
1494
|
+
* Optionally specify which fields to include in the response.
|
|
1495
|
+
*
|
|
1496
|
+
* @param fields - Optional field names to include. If not specified, returns all fields.
|
|
1497
|
+
* @returns Object containing the requested fields with config as raw Uint8Array.
|
|
1498
|
+
*/
|
|
1499
|
+
getConfigBinary(): Promise<{
|
|
1500
|
+
config: Uint8Array;
|
|
1501
|
+
metadata: VertexMetadataJson;
|
|
1502
|
+
configuredServices: {
|
|
1503
|
+
[key: string]: boolean;
|
|
1504
|
+
};
|
|
1505
|
+
}>;
|
|
1506
|
+
getConfigBinary<K extends 'config' | 'metadata' | 'configuredServices' = 'config' | 'metadata' | 'configuredServices'>(...fields: K[]): Promise<Pick<{
|
|
1507
|
+
config: Uint8Array;
|
|
1508
|
+
metadata: VertexMetadataJson;
|
|
1509
|
+
configuredServices: {
|
|
1510
|
+
[key: string]: boolean;
|
|
1511
|
+
};
|
|
1512
|
+
}, K>>;
|
|
1513
|
+
/**
|
|
1514
|
+
* Updates the vertex configuration and/or metadata.
|
|
1515
|
+
* At least one of config or metadata must be provided.
|
|
1516
|
+
*
|
|
1517
|
+
* Config handling:
|
|
1518
|
+
* - Set to a value (object or Uint8Array) to update the config
|
|
1519
|
+
* - Set to empty bytes to clear the config
|
|
1520
|
+
* - Omit (undefined) to keep existing config unchanged
|
|
1521
|
+
*
|
|
1522
|
+
* Metadata handling:
|
|
1523
|
+
* - Set to update the metadata
|
|
1524
|
+
* - Omit (undefined) to keep existing metadata unchanged
|
|
1525
|
+
* - Cannot be cleared
|
|
1526
|
+
*
|
|
1527
|
+
* @param opts - Configuration options:
|
|
1528
|
+
* - config: The configuration to set (will be JSON-serialized unless Uint8Array)
|
|
1529
|
+
* - metadata: Optional metadata to update
|
|
1530
|
+
* - overrideBindings: Set to true to override existing signal bindings (use when plugin handles bindings)
|
|
1531
|
+
* @returns A promise that resolves to the updated vertex metadata (useful for checking error codes after setting bindings).
|
|
1532
|
+
* @throws {ConnectError} Code.InvalidArgument if neither config nor metadata is provided.
|
|
1533
|
+
*
|
|
1534
|
+
* @example
|
|
1535
|
+
* ```typescript
|
|
1536
|
+
* // Update config only
|
|
1537
|
+
* await api.postConfig({ config: { apiKey: 'new-key' } });
|
|
1538
|
+
*
|
|
1539
|
+
* // Update metadata only
|
|
1540
|
+
* await api.postConfig({ metadata: { label: 'New Label' } });
|
|
1541
|
+
*
|
|
1542
|
+
* // Update both with binding override
|
|
1543
|
+
* await api.postConfig({
|
|
1544
|
+
* config: { enabled: true },
|
|
1545
|
+
* metadata: { description: 'Updated' },
|
|
1546
|
+
* overrideBindings: true
|
|
1547
|
+
* });
|
|
1548
|
+
* ```
|
|
1549
|
+
*/
|
|
1550
|
+
postConfig<T = any>(opts: PostConfigOptions<T>): Promise<VertexMetadataJson>;
|
|
1551
|
+
/**
|
|
1552
|
+
* Lists all available incoming signals on a specific receiver.
|
|
1553
|
+
* This endpoint enables the configurator to get information about incoming signals
|
|
1554
|
+
* from vertices that transmit to this vertex's receivers.
|
|
1555
|
+
*
|
|
1556
|
+
* If you have multiple receivers, call this endpoint multiple times (once per receiver).
|
|
1557
|
+
*
|
|
1558
|
+
* @param receiver - The receiver to check for signals (1-100 chars, pattern: ^[_$a-zA-Z][_$a-zA-Z0-9]*$).
|
|
1559
|
+
* If not set, the first connected receiver is used.
|
|
1560
|
+
* @param formats - Optional signal formats to filter by. Only returns signals that match at least one schema in the array.
|
|
1561
|
+
* This allows filtering incoming signals to only those that conform to specific JTD schemas.
|
|
1562
|
+
* @param fieldMask - Optional field mask to apply to the returned schema.
|
|
1563
|
+
* Example: Set to "vertices" to omit vertex logos and reduce response size.
|
|
1564
|
+
* @returns A promise that resolves to information about incoming vertices, their transmitters, and available signals.
|
|
1565
|
+
* - vertices: Array of incoming vertices with their transmitters and signal definitions
|
|
1566
|
+
* - vertexLogos: Map of vertex logo IDs to logo data (base64 or data URI)
|
|
1567
|
+
* - receiver: The receiver name the signals are fetched on
|
|
1568
|
+
*
|
|
1569
|
+
* @example
|
|
1570
|
+
* ```typescript
|
|
1571
|
+
* // Get all incoming signals on default receiver
|
|
1572
|
+
* const signals = await api.listIncomingSignals();
|
|
1573
|
+
*
|
|
1574
|
+
* // Get signals from specific receiver, filtered by format
|
|
1575
|
+
* const filtered = await api.listIncomingSignals('data_receiver', [mySignalFormat]);
|
|
1576
|
+
*
|
|
1577
|
+
* // Get signals without logos (smaller response)
|
|
1578
|
+
* const minimal = await api.listIncomingSignals('input', undefined, 'vertices');
|
|
1579
|
+
* ```
|
|
1580
|
+
*/
|
|
1581
|
+
listIncomingSignals(receiver?: string, formats?: SignalFormatJson[], fieldMask?: string): Promise<ListIncomingSignalsResponseJson>;
|
|
1582
|
+
/**
|
|
1583
|
+
* Provides access to a local store scoped by the specified namespace.
|
|
1584
|
+
* Local stores persist for the lifetime of the plugin in the project.
|
|
1585
|
+
*
|
|
1586
|
+
* @param namespace - The namespace for the store, either 'vertex' or 'plugin'.
|
|
1587
|
+
* @returns An instance of Store configured for the specified namespace.
|
|
1588
|
+
*/
|
|
1589
|
+
getLocalStore(namespace: 'vertex' | 'plugin'): Store;
|
|
1590
|
+
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Maps HTTP status codes to ConnectError instances.
|
|
1593
|
+
*
|
|
1594
|
+
* @param status - The HTTP status code.
|
|
1595
|
+
* @returns A ConnectError instance with the appropriate code and message.
|
|
1596
|
+
*/
|
|
1597
|
+
export declare function mapHttpError(status: number): ConnectError;
|
|
1598
|
+
/**
|
|
1599
|
+
* Maps a ConnectError to the corresponding HTTP status code.
|
|
1600
|
+
*
|
|
1601
|
+
* @param error - The ConnectError instance.
|
|
1602
|
+
* @returns The corresponding HTTP status code.
|
|
1603
|
+
*/
|
|
1604
|
+
export declare function mapConnectErrorToHttpStatus(error: ConnectError): number;
|
|
1605
|
+
//# sourceMappingURL=api.d.ts.map
|