@alva-ai/toolkit 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.global.js +31 -6
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +55 -1
- package/dist/cli.js +412 -36
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +56 -2
- package/dist/dispatch.js +163 -13
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +331 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -2
- package/dist/index.d.ts +62 -2
- package/dist/index.js +329 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6143,6 +6143,134 @@ var FsResource = class {
|
|
|
6143
6143
|
}
|
|
6144
6144
|
};
|
|
6145
6145
|
|
|
6146
|
+
// src/jsonPayload.ts
|
|
6147
|
+
var MAX_SAFE_INTEGER_DIGITS = "9007199254740991";
|
|
6148
|
+
function scaledIntegerGreater(left, leftTrailingZeros, right, rightTrailingZeros) {
|
|
6149
|
+
const leftLength = left.length + leftTrailingZeros;
|
|
6150
|
+
const rightLength = right.length + rightTrailingZeros;
|
|
6151
|
+
if (leftLength !== rightLength) return leftLength > rightLength;
|
|
6152
|
+
for (let index = 0; index < leftLength; index++) {
|
|
6153
|
+
const leftDigit = index < left.length ? left[index] : "0";
|
|
6154
|
+
const rightDigit = index < right.length ? right[index] : "0";
|
|
6155
|
+
if (leftDigit !== rightDigit) return leftDigit > rightDigit;
|
|
6156
|
+
}
|
|
6157
|
+
return false;
|
|
6158
|
+
}
|
|
6159
|
+
function numberOutsideSafeRange(token) {
|
|
6160
|
+
const match = token.match(
|
|
6161
|
+
/^-?(?<whole>\d+)(?:\.(?<fraction>\d+))?(?:[eE](?<exponent>[+-]?\d+))?$/
|
|
6162
|
+
);
|
|
6163
|
+
if (!match?.groups) return true;
|
|
6164
|
+
const whole = match.groups.whole;
|
|
6165
|
+
const fraction = match.groups.fraction ?? "";
|
|
6166
|
+
const exponent = Number(match.groups.exponent ?? "0");
|
|
6167
|
+
if (!Number.isSafeInteger(exponent)) return true;
|
|
6168
|
+
const digits = (whole + fraction).replace(/^0+/, "") || "0";
|
|
6169
|
+
if (digits === "0") return false;
|
|
6170
|
+
const scale = exponent - fraction.length;
|
|
6171
|
+
return scale >= 0 ? scaledIntegerGreater(digits, scale, MAX_SAFE_INTEGER_DIGITS, 0) : scaledIntegerGreater(digits, 0, MAX_SAFE_INTEGER_DIGITS, -scale);
|
|
6172
|
+
}
|
|
6173
|
+
function validateJSONNumberTokens(raw) {
|
|
6174
|
+
let index = 0;
|
|
6175
|
+
while (index < raw.length) {
|
|
6176
|
+
if (raw[index] === '"') {
|
|
6177
|
+
index++;
|
|
6178
|
+
while (index < raw.length) {
|
|
6179
|
+
if (raw[index] === "\\") {
|
|
6180
|
+
index += 2;
|
|
6181
|
+
} else if (raw[index++] === '"') {
|
|
6182
|
+
break;
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
continue;
|
|
6186
|
+
}
|
|
6187
|
+
if (raw[index] === "-" || /\d/.test(raw[index] ?? "")) {
|
|
6188
|
+
const match = raw.slice(index).match(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/);
|
|
6189
|
+
if (match) {
|
|
6190
|
+
if (numberOutsideSafeRange(match[0])) {
|
|
6191
|
+
throw new TypeError(
|
|
6192
|
+
"args contains a number outside JavaScript's safe range; use a string for int64 and identifier values"
|
|
6193
|
+
);
|
|
6194
|
+
}
|
|
6195
|
+
index += match[0].length;
|
|
6196
|
+
continue;
|
|
6197
|
+
}
|
|
6198
|
+
}
|
|
6199
|
+
index++;
|
|
6200
|
+
}
|
|
6201
|
+
}
|
|
6202
|
+
function assertPlainJSONData(value, path, seen) {
|
|
6203
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
6204
|
+
return;
|
|
6205
|
+
if (typeof value === "number") {
|
|
6206
|
+
if (!Number.isFinite(value)) {
|
|
6207
|
+
throw new TypeError(`${path} must contain only finite numbers`);
|
|
6208
|
+
}
|
|
6209
|
+
if (Number.isInteger(value) && !Number.isSafeInteger(value)) {
|
|
6210
|
+
throw new TypeError(
|
|
6211
|
+
`${path} contains a number outside JavaScript's safe range; use a string for int64 and identifier values`
|
|
6212
|
+
);
|
|
6213
|
+
}
|
|
6214
|
+
return;
|
|
6215
|
+
}
|
|
6216
|
+
if (typeof value !== "object") {
|
|
6217
|
+
throw new TypeError(`${path} must contain only JSON data`);
|
|
6218
|
+
}
|
|
6219
|
+
if (seen.has(value)) {
|
|
6220
|
+
throw new TypeError(`${path} must not contain circular references`);
|
|
6221
|
+
}
|
|
6222
|
+
seen.add(value);
|
|
6223
|
+
if (Array.isArray(value)) {
|
|
6224
|
+
value.forEach(
|
|
6225
|
+
(item, index) => assertPlainJSONData(item, `${path}[${index}]`, seen)
|
|
6226
|
+
);
|
|
6227
|
+
} else {
|
|
6228
|
+
const prototype = Object.getPrototypeOf(value);
|
|
6229
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
6230
|
+
throw new TypeError(`${path} must contain only plain JSON objects`);
|
|
6231
|
+
}
|
|
6232
|
+
for (const [key, descriptor] of Object.entries(
|
|
6233
|
+
Object.getOwnPropertyDescriptors(value)
|
|
6234
|
+
)) {
|
|
6235
|
+
if (!descriptor.enumerable) continue;
|
|
6236
|
+
if (!("value" in descriptor)) {
|
|
6237
|
+
throw new TypeError(`${path} must not contain accessors`);
|
|
6238
|
+
}
|
|
6239
|
+
assertPlainJSONData(descriptor.value, `${path}.${key}`, seen);
|
|
6240
|
+
}
|
|
6241
|
+
}
|
|
6242
|
+
seen.delete(value);
|
|
6243
|
+
}
|
|
6244
|
+
function serializeStructuredArgs(value) {
|
|
6245
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
6246
|
+
throw new TypeError("args must be a JSON object");
|
|
6247
|
+
}
|
|
6248
|
+
assertPlainJSONData(value, "args", /* @__PURE__ */ new Set());
|
|
6249
|
+
const serialized = JSON.stringify(value);
|
|
6250
|
+
validateSerializedArgs(serialized);
|
|
6251
|
+
return serialized;
|
|
6252
|
+
}
|
|
6253
|
+
function validateSerializedArgs(raw) {
|
|
6254
|
+
const value = JSON.parse(raw);
|
|
6255
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
6256
|
+
throw new TypeError("args must be a JSON object");
|
|
6257
|
+
}
|
|
6258
|
+
validateJSONNumberTokens(raw);
|
|
6259
|
+
}
|
|
6260
|
+
function objectWithRawJSONField(fields, fieldName, rawValue) {
|
|
6261
|
+
const entries = Object.entries(fields).filter(
|
|
6262
|
+
([key, value]) => value !== void 0 && (rawValue === void 0 || key !== fieldName)
|
|
6263
|
+
);
|
|
6264
|
+
if (rawValue !== void 0) {
|
|
6265
|
+
validateSerializedArgs(rawValue);
|
|
6266
|
+
entries.push([fieldName, rawValue]);
|
|
6267
|
+
}
|
|
6268
|
+
return `{${entries.map(([key, value]) => {
|
|
6269
|
+
const encodedValue = key === fieldName && rawValue !== void 0 ? rawValue : JSON.stringify(value);
|
|
6270
|
+
return `${JSON.stringify(key)}:${encodedValue}`;
|
|
6271
|
+
}).join(",")}}`;
|
|
6272
|
+
}
|
|
6273
|
+
|
|
6146
6274
|
// src/resources/run.ts
|
|
6147
6275
|
var RunResource = class {
|
|
6148
6276
|
constructor(client) {
|
|
@@ -6151,13 +6279,24 @@ var RunResource = class {
|
|
|
6151
6279
|
client;
|
|
6152
6280
|
async execute(params) {
|
|
6153
6281
|
this.client._requireAuth();
|
|
6282
|
+
return params.args === void 0 ? this.request(params) : this.request(params, serializeStructuredArgs(params.args));
|
|
6283
|
+
}
|
|
6284
|
+
/** @internal Used by the CLI to preserve the exact --args JSON text. */
|
|
6285
|
+
async _executeSerializedArgs(params, serializedArgs) {
|
|
6286
|
+
this.client._requireAuth();
|
|
6287
|
+
return this.request(params, serializedArgs);
|
|
6288
|
+
}
|
|
6289
|
+
request(params, serializedArgs) {
|
|
6290
|
+
const body = {
|
|
6291
|
+
code: params.code,
|
|
6292
|
+
entry_path: params.entry_path,
|
|
6293
|
+
working_dir: params.working_dir,
|
|
6294
|
+
args: params.args,
|
|
6295
|
+
max_heap_size_mb: params.max_heap_size_mb
|
|
6296
|
+
};
|
|
6154
6297
|
return this.client._request("POST", "/api/v1/run", {
|
|
6155
|
-
body: {
|
|
6156
|
-
|
|
6157
|
-
entry_path: params.entry_path,
|
|
6158
|
-
working_dir: params.working_dir,
|
|
6159
|
-
args: params.args,
|
|
6160
|
-
max_heap_size_mb: params.max_heap_size_mb
|
|
6298
|
+
...serializedArgs === void 0 ? { body } : {
|
|
6299
|
+
jsonBody: objectWithRawJSONField(body, "args", serializedArgs)
|
|
6161
6300
|
},
|
|
6162
6301
|
timeoutMs: params.timeout_ms
|
|
6163
6302
|
});
|
|
@@ -6172,19 +6311,30 @@ var DeployResource = class {
|
|
|
6172
6311
|
client;
|
|
6173
6312
|
async create(params) {
|
|
6174
6313
|
this.client._requireAuth();
|
|
6314
|
+
return params.args === void 0 ? this.createRequest(params) : this.createRequest(params, serializeStructuredArgs(params.args));
|
|
6315
|
+
}
|
|
6316
|
+
/** @internal Used by the CLI to preserve the exact --args JSON text. */
|
|
6317
|
+
async _createSerializedArgs(params, serializedArgs) {
|
|
6318
|
+
this.client._requireAuth();
|
|
6319
|
+
return this.createRequest(params, serializedArgs);
|
|
6320
|
+
}
|
|
6321
|
+
createRequest(params, serializedArgs) {
|
|
6322
|
+
const body = {
|
|
6323
|
+
name: params.name,
|
|
6324
|
+
path: params.path,
|
|
6325
|
+
cron_expression: params.cron_expression,
|
|
6326
|
+
args: params.args,
|
|
6327
|
+
push_notify: params.push_notify,
|
|
6328
|
+
max_heap_size_mb: params.max_heap_size_mb,
|
|
6329
|
+
execution_timeout_seconds: params.execution_timeout_seconds,
|
|
6330
|
+
run_as_user_id: params.run_as_user_id,
|
|
6331
|
+
start_at: params.start_at,
|
|
6332
|
+
end_at: params.end_at,
|
|
6333
|
+
max_runs: params.max_runs
|
|
6334
|
+
};
|
|
6175
6335
|
return this.client._request("POST", "/api/v1/deploy/cronjob", {
|
|
6176
|
-
body: {
|
|
6177
|
-
|
|
6178
|
-
path: params.path,
|
|
6179
|
-
cron_expression: params.cron_expression,
|
|
6180
|
-
args: params.args,
|
|
6181
|
-
push_notify: params.push_notify,
|
|
6182
|
-
max_heap_size_mb: params.max_heap_size_mb,
|
|
6183
|
-
execution_timeout_seconds: params.execution_timeout_seconds,
|
|
6184
|
-
run_as_user_id: params.run_as_user_id,
|
|
6185
|
-
start_at: params.start_at,
|
|
6186
|
-
end_at: params.end_at,
|
|
6187
|
-
max_runs: params.max_runs
|
|
6336
|
+
...serializedArgs === void 0 ? { body } : {
|
|
6337
|
+
jsonBody: objectWithRawJSONField(body, "args", serializedArgs)
|
|
6188
6338
|
}
|
|
6189
6339
|
});
|
|
6190
6340
|
}
|
|
@@ -6203,9 +6353,19 @@ var DeployResource = class {
|
|
|
6203
6353
|
}
|
|
6204
6354
|
async update(params) {
|
|
6205
6355
|
this.client._requireAuth();
|
|
6356
|
+
return params.args === void 0 ? this.updateRequest(params) : this.updateRequest(params, serializeStructuredArgs(params.args));
|
|
6357
|
+
}
|
|
6358
|
+
/** @internal Used by the CLI to preserve the exact --args JSON text. */
|
|
6359
|
+
async _updateSerializedArgs(params, serializedArgs) {
|
|
6360
|
+
this.client._requireAuth();
|
|
6361
|
+
return this.updateRequest(params, serializedArgs);
|
|
6362
|
+
}
|
|
6363
|
+
updateRequest(params, serializedArgs) {
|
|
6206
6364
|
const { id, ...body } = params;
|
|
6207
6365
|
return this.client._request("PATCH", `/api/v1/deploy/cronjob/${id}`, {
|
|
6208
|
-
body
|
|
6366
|
+
...serializedArgs === void 0 ? { body } : {
|
|
6367
|
+
jsonBody: objectWithRawJSONField(body, "args", serializedArgs)
|
|
6368
|
+
}
|
|
6209
6369
|
});
|
|
6210
6370
|
}
|
|
6211
6371
|
async delete(params) {
|
|
@@ -6461,11 +6621,40 @@ function requireFeedID(id) {
|
|
|
6461
6621
|
}
|
|
6462
6622
|
|
|
6463
6623
|
// src/resources/automation.ts
|
|
6624
|
+
var AUTOMATION_ALERT_DELIVERY_QUERY = `
|
|
6625
|
+
query ToolkitAutomationAlertDelivery($automationId: ID!) {
|
|
6626
|
+
automation(id: $automationId) {
|
|
6627
|
+
alertDelivery {
|
|
6628
|
+
isEnabled
|
|
6629
|
+
alvaChannels { id }
|
|
6630
|
+
email { isEnabled isAvailable address }
|
|
6631
|
+
}
|
|
6632
|
+
}
|
|
6633
|
+
}
|
|
6634
|
+
`.trim();
|
|
6635
|
+
var UPDATE_AUTOMATION_ALERT_DELIVERY = `
|
|
6636
|
+
mutation ToolkitUpdateAutomationAlertDelivery(
|
|
6637
|
+
$input: UpdateAutomationAlertDeliveryInput!
|
|
6638
|
+
$includeAlvaChannels: Boolean!
|
|
6639
|
+
$includeEmail: Boolean!
|
|
6640
|
+
) {
|
|
6641
|
+
updateAutomationAlertDelivery(input: $input) {
|
|
6642
|
+
automation { id }
|
|
6643
|
+
alertDelivery {
|
|
6644
|
+
isEnabled
|
|
6645
|
+
alvaChannels @include(if: $includeAlvaChannels) { id }
|
|
6646
|
+
email @include(if: $includeEmail) { isEnabled isAvailable address }
|
|
6647
|
+
}
|
|
6648
|
+
}
|
|
6649
|
+
}
|
|
6650
|
+
`.trim();
|
|
6464
6651
|
var AutomationResource = class {
|
|
6465
6652
|
constructor(client) {
|
|
6466
6653
|
this.client = client;
|
|
6654
|
+
this.delivery = new AutomationAlertDeliveryResource(client);
|
|
6467
6655
|
}
|
|
6468
6656
|
client;
|
|
6657
|
+
delivery;
|
|
6469
6658
|
list(params = {}) {
|
|
6470
6659
|
return this.client.feed.list(params);
|
|
6471
6660
|
}
|
|
@@ -6517,6 +6706,90 @@ var AutomationResource = class {
|
|
|
6517
6706
|
return this.client.release.feed(params);
|
|
6518
6707
|
}
|
|
6519
6708
|
};
|
|
6709
|
+
var AutomationAlertDeliveryResource = class {
|
|
6710
|
+
constructor(client) {
|
|
6711
|
+
this.client = client;
|
|
6712
|
+
}
|
|
6713
|
+
client;
|
|
6714
|
+
async get(params) {
|
|
6715
|
+
this.client._requireAuth();
|
|
6716
|
+
const id = requireAutomationIDString(params.id);
|
|
6717
|
+
const data = await this.graphql(
|
|
6718
|
+
AUTOMATION_ALERT_DELIVERY_QUERY,
|
|
6719
|
+
{ automationId: id }
|
|
6720
|
+
);
|
|
6721
|
+
const delivery = data.automation?.alertDelivery;
|
|
6722
|
+
if (!delivery) {
|
|
6723
|
+
throw new AlvaError(
|
|
6724
|
+
"GRAPHQL_EMPTY_RESPONSE",
|
|
6725
|
+
"GraphQL response did not include automation.alertDelivery",
|
|
6726
|
+
502
|
|
6727
|
+
);
|
|
6728
|
+
}
|
|
6729
|
+
return delivery;
|
|
6730
|
+
}
|
|
6731
|
+
async update(params) {
|
|
6732
|
+
this.client._requireAuth();
|
|
6733
|
+
const id = requireAutomationIDString(params.id);
|
|
6734
|
+
const includeAlvaChannels = params.alvaChannelIds !== void 0;
|
|
6735
|
+
const includeEmail = params.emailEnabled !== void 0;
|
|
6736
|
+
if (!includeAlvaChannels && !includeEmail) {
|
|
6737
|
+
throw new Error(
|
|
6738
|
+
"automation delivery update requires alvaChannelIds or emailEnabled"
|
|
6739
|
+
);
|
|
6740
|
+
}
|
|
6741
|
+
const alvaChannelIds = includeAlvaChannels ? uniqueAlvaChannelIDs(params.alvaChannelIds ?? []) : void 0;
|
|
6742
|
+
const data = await this.graphql(
|
|
6743
|
+
UPDATE_AUTOMATION_ALERT_DELIVERY,
|
|
6744
|
+
{
|
|
6745
|
+
input: {
|
|
6746
|
+
automationId: id,
|
|
6747
|
+
...includeAlvaChannels ? { alvaChannelIds } : {},
|
|
6748
|
+
...includeEmail ? { emailEnabled: params.emailEnabled } : {}
|
|
6749
|
+
},
|
|
6750
|
+
includeAlvaChannels,
|
|
6751
|
+
includeEmail
|
|
6752
|
+
}
|
|
6753
|
+
);
|
|
6754
|
+
const result = data.updateAutomationAlertDelivery;
|
|
6755
|
+
if (!result) {
|
|
6756
|
+
throw new AlvaError(
|
|
6757
|
+
"GRAPHQL_EMPTY_RESPONSE",
|
|
6758
|
+
"GraphQL response did not include updateAutomationAlertDelivery",
|
|
6759
|
+
502
|
|
6760
|
+
);
|
|
6761
|
+
}
|
|
6762
|
+
return result;
|
|
6763
|
+
}
|
|
6764
|
+
async graphql(query, variables) {
|
|
6765
|
+
const response = await this.client._request("POST", "/query", {
|
|
6766
|
+
body: { query, variables }
|
|
6767
|
+
});
|
|
6768
|
+
if (!response) {
|
|
6769
|
+
throw new AlvaError(
|
|
6770
|
+
"GRAPHQL_EMPTY_RESPONSE",
|
|
6771
|
+
"GraphQL response was empty",
|
|
6772
|
+
502
|
|
6773
|
+
);
|
|
6774
|
+
}
|
|
6775
|
+
if (response.errors && response.errors.length > 0) {
|
|
6776
|
+
throw new AlvaError(
|
|
6777
|
+
"GRAPHQL_ERROR",
|
|
6778
|
+
graphQLErrorMessage(response.errors),
|
|
6779
|
+
400,
|
|
6780
|
+
{ errors: response.errors }
|
|
6781
|
+
);
|
|
6782
|
+
}
|
|
6783
|
+
if (!response.data) {
|
|
6784
|
+
throw new AlvaError(
|
|
6785
|
+
"GRAPHQL_EMPTY_RESPONSE",
|
|
6786
|
+
"GraphQL response did not include data",
|
|
6787
|
+
502
|
|
6788
|
+
);
|
|
6789
|
+
}
|
|
6790
|
+
return response.data;
|
|
6791
|
+
}
|
|
6792
|
+
};
|
|
6520
6793
|
function requireAutomationID(id) {
|
|
6521
6794
|
if (!Number.isInteger(id) || id <= 0) {
|
|
6522
6795
|
throw new Error("automation id must be a positive integer");
|
|
@@ -6532,6 +6805,23 @@ function requireAutomationIDString(id) {
|
|
|
6532
6805
|
function hasAutomationUpdate(params) {
|
|
6533
6806
|
return params.version !== void 0 || params.cronjob_id !== void 0 || params.description !== void 0 || params.changelog !== void 0 || params.agent_type !== void 0 || params.trigger === true;
|
|
6534
6807
|
}
|
|
6808
|
+
function uniqueAlvaChannelIDs(values) {
|
|
6809
|
+
const ids = [...new Set(values)];
|
|
6810
|
+
for (const id of ids) {
|
|
6811
|
+
if (!/^(0|[1-9]\d*)$/.test(id)) {
|
|
6812
|
+
throw new Error(
|
|
6813
|
+
"Alva channel ids must be positive integer strings or the agent sentinel 0"
|
|
6814
|
+
);
|
|
6815
|
+
}
|
|
6816
|
+
}
|
|
6817
|
+
return ids;
|
|
6818
|
+
}
|
|
6819
|
+
function graphQLErrorMessage(errors) {
|
|
6820
|
+
const messages = errors.map(
|
|
6821
|
+
(error) => error && typeof error.message === "string" && error.message ? error.message : void 0
|
|
6822
|
+
).filter((message) => Boolean(message));
|
|
6823
|
+
return messages.length > 0 ? messages.join("; ") : "GraphQL request failed";
|
|
6824
|
+
}
|
|
6535
6825
|
|
|
6536
6826
|
// src/resources/playbooks.ts
|
|
6537
6827
|
var PLAYBOOK_VISIBILITIES = [
|
|
@@ -8388,7 +8678,7 @@ query ToolkitCreditWalletItems($input: CreditWalletItemConnectionInput!) {
|
|
|
8388
8678
|
}
|
|
8389
8679
|
}
|
|
8390
8680
|
`.trim();
|
|
8391
|
-
function
|
|
8681
|
+
function graphQLErrorMessage2(errors) {
|
|
8392
8682
|
const messages = errors.map(
|
|
8393
8683
|
(error) => typeof error.message === "string" && error.message ? error.message : void 0
|
|
8394
8684
|
).filter((message) => Boolean(message));
|
|
@@ -8443,7 +8733,7 @@ var CreditsResource = class {
|
|
|
8443
8733
|
if (response.errors && response.errors.length > 0) {
|
|
8444
8734
|
throw new AlvaError(
|
|
8445
8735
|
"GRAPHQL_ERROR",
|
|
8446
|
-
|
|
8736
|
+
graphQLErrorMessage2(response.errors),
|
|
8447
8737
|
400,
|
|
8448
8738
|
{ errors: response.errors }
|
|
8449
8739
|
);
|
|
@@ -8600,7 +8890,7 @@ query ToolkitCompanyEarnings($ticker: String!, $input: CompanyEarningsInput) {
|
|
|
8600
8890
|
}
|
|
8601
8891
|
}
|
|
8602
8892
|
`.trim();
|
|
8603
|
-
function
|
|
8893
|
+
function graphQLErrorMessage3(errors) {
|
|
8604
8894
|
const messages = errors.map(
|
|
8605
8895
|
(error) => typeof error.message === "string" && error.message ? error.message : void 0
|
|
8606
8896
|
).filter((message) => Boolean(message));
|
|
@@ -8756,7 +9046,7 @@ var MarketsResource = class {
|
|
|
8756
9046
|
if (response.errors && response.errors.length > 0) {
|
|
8757
9047
|
throw new AlvaError(
|
|
8758
9048
|
"GRAPHQL_ERROR",
|
|
8759
|
-
|
|
9049
|
+
graphQLErrorMessage3(response.errors),
|
|
8760
9050
|
400,
|
|
8761
9051
|
{ errors: response.errors }
|
|
8762
9052
|
);
|
|
@@ -9451,6 +9741,12 @@ var COMMAND_DEFINITIONS = [
|
|
|
9451
9741
|
],
|
|
9452
9742
|
booleans: ["trigger"]
|
|
9453
9743
|
}),
|
|
9744
|
+
command("automation delivery"),
|
|
9745
|
+
command("automation delivery get", { values: ["id"] }),
|
|
9746
|
+
command("automation delivery update", {
|
|
9747
|
+
values: ["id", "alva-channel-ids"],
|
|
9748
|
+
booleans: ["email-enabled"]
|
|
9749
|
+
}),
|
|
9454
9750
|
command("automation stop", { values: ["id"] }),
|
|
9455
9751
|
command("automation resume", { values: ["id"] }),
|
|
9456
9752
|
command("automation delete", { values: ["id"] }),
|
|
@@ -13976,7 +14272,7 @@ ${formatReport(report, "human")}
|
|
|
13976
14272
|
}
|
|
13977
14273
|
|
|
13978
14274
|
// src/cli/dispatch.ts
|
|
13979
|
-
var CLI_VERSION = true ? "0.
|
|
14275
|
+
var CLI_VERSION = true ? "0.24.0" : "dev";
|
|
13980
14276
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
13981
14277
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
13982
14278
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -14022,7 +14318,7 @@ Commands:
|
|
|
14022
14318
|
service-account Restricted run-as identities (create, list, delete, grant, revoke)
|
|
14023
14319
|
release Feed and playbook releases (feed, playbook-draft, playbook)
|
|
14024
14320
|
lint Design-system lint (playbook)
|
|
14025
|
-
automation Automation management (list, inspect, publish, update, stop, resume, delete)
|
|
14321
|
+
automation Automation management (list, inspect, publish, update, delivery, stop, resume, delete)
|
|
14026
14322
|
alert Alert management (list, follows, enable, disable, history, preferences, enable-session-completed, disable-session-completed)
|
|
14027
14323
|
feed Legacy automation alias (list, stop, resume, delete, set-visibility)
|
|
14028
14324
|
playbooks Playbook discovery (trending, get, list) and visibility
|
|
@@ -14450,6 +14746,7 @@ Subcommands:
|
|
|
14450
14746
|
inspect Inspect one automation and show its flow config path when available
|
|
14451
14747
|
publish First-publish/register a new automation after deploying its cronjob
|
|
14452
14748
|
update Partially update an existing automation by numeric id
|
|
14749
|
+
delivery Get or partially update per-automation alert destinations
|
|
14453
14750
|
stop Stop an automation's producer cronjob
|
|
14454
14751
|
resume Resume a stopped automation's producer cronjob
|
|
14455
14752
|
delete Soft-delete an automation
|
|
@@ -14485,6 +14782,16 @@ Update flags:
|
|
|
14485
14782
|
--agent-type <type> Replace agent kind; explicit empty clears it
|
|
14486
14783
|
--trigger Trigger one run after the update commits
|
|
14487
14784
|
|
|
14785
|
+
Delivery subcommands:
|
|
14786
|
+
delivery get Read Alva channel and verified-email destinations
|
|
14787
|
+
delivery update Update only the destination fields explicitly provided
|
|
14788
|
+
|
|
14789
|
+
Delivery flags:
|
|
14790
|
+
--id <automation_id> Existing automation id (required)
|
|
14791
|
+
--alva-channel-ids <a,b> Replace Alva destinations; empty clears them
|
|
14792
|
+
--email-enabled Enable verified-account email delivery
|
|
14793
|
+
--no-email-enabled Disable email delivery
|
|
14794
|
+
|
|
14488
14795
|
Lifecycle flags:
|
|
14489
14796
|
--id <automation_id> Numeric automation id (required for inspect/update/stop/resume/delete)
|
|
14490
14797
|
|
|
@@ -14495,6 +14802,10 @@ Examples:
|
|
|
14495
14802
|
alva automation publish --name btc-ema --version 1.0.0 --cronjob-id 42
|
|
14496
14803
|
alva automation update --id 42 --description "Updated BTC EMA"
|
|
14497
14804
|
alva automation update --id 42 --version 2.0.0 --trigger
|
|
14805
|
+
alva automation delivery get --id 42
|
|
14806
|
+
alva automation delivery update --id 42 --email-enabled
|
|
14807
|
+
alva automation delivery update --id 42 --no-email-enabled
|
|
14808
|
+
alva automation delivery update --id 42 --alva-channel-ids 0,123
|
|
14498
14809
|
alva automation stop --id 42
|
|
14499
14810
|
alva automation resume --id 42
|
|
14500
14811
|
alva automation delete --id 42`,
|
|
@@ -15278,6 +15589,18 @@ function boolFlag(val) {
|
|
|
15278
15589
|
if (val === "false") return false;
|
|
15279
15590
|
return void 0;
|
|
15280
15591
|
}
|
|
15592
|
+
function serializedJSONFlag(value, command2) {
|
|
15593
|
+
if (value === void 0) return void 0;
|
|
15594
|
+
try {
|
|
15595
|
+
validateSerializedArgs(value);
|
|
15596
|
+
} catch (error) {
|
|
15597
|
+
throw new CliUsageError(
|
|
15598
|
+
`--args must contain valid JSON for '${command2}': ${error instanceof Error ? error.message : String(error)}`,
|
|
15599
|
+
command2.split(" ")[0]
|
|
15600
|
+
);
|
|
15601
|
+
}
|
|
15602
|
+
return value;
|
|
15603
|
+
}
|
|
15281
15604
|
function requireFlag(flags, name, command2) {
|
|
15282
15605
|
const val = flags[name];
|
|
15283
15606
|
if (val === void 0) {
|
|
@@ -15553,6 +15876,23 @@ function automationUpdateParams(flags) {
|
|
|
15553
15876
|
}
|
|
15554
15877
|
return params;
|
|
15555
15878
|
}
|
|
15879
|
+
function automationDeliveryUpdateParams(flags) {
|
|
15880
|
+
const command2 = "automation delivery update";
|
|
15881
|
+
const id = requirePositiveIntegerStringFlag(flags, "id", command2);
|
|
15882
|
+
const alvaChannelIds = flags["alva-channel-ids"] === void 0 ? void 0 : csvList(flags["alva-channel-ids"]) ?? [];
|
|
15883
|
+
const emailEnabled = boolFlag(flags["email-enabled"]);
|
|
15884
|
+
if (alvaChannelIds === void 0 && emailEnabled === void 0) {
|
|
15885
|
+
throw new CliUsageError(
|
|
15886
|
+
"automation delivery update requires --alva-channel-ids or --email-enabled/--no-email-enabled",
|
|
15887
|
+
"automation"
|
|
15888
|
+
);
|
|
15889
|
+
}
|
|
15890
|
+
return {
|
|
15891
|
+
id,
|
|
15892
|
+
alvaChannelIds,
|
|
15893
|
+
emailEnabled
|
|
15894
|
+
};
|
|
15895
|
+
}
|
|
15556
15896
|
function trendingPlaybooksSort(val) {
|
|
15557
15897
|
if (val === void 0) return void 0;
|
|
15558
15898
|
const normalized = val.trim().toUpperCase();
|
|
@@ -16115,11 +16455,10 @@ async function dispatch(client, args, meta, deps) {
|
|
|
16115
16455
|
}
|
|
16116
16456
|
const timeout_ms = runTimeoutMs(flags, deps);
|
|
16117
16457
|
configureRunFetchTimeout(timeout_ms, deps);
|
|
16118
|
-
|
|
16458
|
+
const params = {
|
|
16119
16459
|
code,
|
|
16120
16460
|
entry_path: flags["entry-path"],
|
|
16121
16461
|
working_dir: flags["working-dir"],
|
|
16122
|
-
args: jsonParse(flags["args"]),
|
|
16123
16462
|
max_heap_size_mb: optionalBoundedIntegerFlag(
|
|
16124
16463
|
flags,
|
|
16125
16464
|
"max-heap-size-mb",
|
|
@@ -16128,18 +16467,19 @@ async function dispatch(client, args, meta, deps) {
|
|
|
16128
16467
|
2048
|
|
16129
16468
|
),
|
|
16130
16469
|
timeout_ms
|
|
16131
|
-
}
|
|
16470
|
+
};
|
|
16471
|
+
const serializedArgs = serializedJSONFlag(flags["args"], "run");
|
|
16472
|
+
return serializedArgs === void 0 ? client.run.execute(params) : client.run._executeSerializedArgs(params, serializedArgs);
|
|
16132
16473
|
}
|
|
16133
16474
|
case "deploy": {
|
|
16134
16475
|
if (!subcommand)
|
|
16135
16476
|
throw new CliUsageError("Missing subcommand for deploy", "deploy");
|
|
16136
16477
|
switch (subcommand) {
|
|
16137
|
-
case "create":
|
|
16138
|
-
|
|
16478
|
+
case "create": {
|
|
16479
|
+
const params = {
|
|
16139
16480
|
name: requireFlag(flags, "name", "deploy create"),
|
|
16140
16481
|
path: requireFlag(flags, "path", "deploy create"),
|
|
16141
16482
|
cron_expression: requireFlag(flags, "cron", "deploy create"),
|
|
16142
|
-
args: jsonParse(flags["args"]),
|
|
16143
16483
|
push_notify: boolFlag(flags["push-notify"]),
|
|
16144
16484
|
max_heap_size_mb: optionalBoundedIntegerFlag(
|
|
16145
16485
|
flags,
|
|
@@ -16159,7 +16499,13 @@ async function dispatch(client, args, meta, deps) {
|
|
|
16159
16499
|
flags,
|
|
16160
16500
|
"deploy create"
|
|
16161
16501
|
)
|
|
16162
|
-
}
|
|
16502
|
+
};
|
|
16503
|
+
const serializedArgs = serializedJSONFlag(
|
|
16504
|
+
flags["args"],
|
|
16505
|
+
"deploy create"
|
|
16506
|
+
);
|
|
16507
|
+
return serializedArgs === void 0 ? client.deploy.create(params) : client.deploy._createSerializedArgs(params, serializedArgs);
|
|
16508
|
+
}
|
|
16163
16509
|
case "list":
|
|
16164
16510
|
return client.deploy.list({
|
|
16165
16511
|
limit: num(flags["limit"]),
|
|
@@ -16169,12 +16515,11 @@ async function dispatch(client, args, meta, deps) {
|
|
|
16169
16515
|
return client.deploy.get({
|
|
16170
16516
|
id: requireNumericFlag(flags, "id", "deploy get")
|
|
16171
16517
|
});
|
|
16172
|
-
case "update":
|
|
16173
|
-
|
|
16518
|
+
case "update": {
|
|
16519
|
+
const params = {
|
|
16174
16520
|
id: requireNumericFlag(flags, "id", "deploy update"),
|
|
16175
16521
|
name: flags["name"],
|
|
16176
16522
|
cron_expression: flags["cron"],
|
|
16177
|
-
args: jsonParse(flags["args"]),
|
|
16178
16523
|
push_notify: boolFlag(flags["push-notify"]),
|
|
16179
16524
|
max_heap_size_mb: optionalBoundedIntegerFlag(
|
|
16180
16525
|
flags,
|
|
@@ -16191,7 +16536,13 @@ async function dispatch(client, args, meta, deps) {
|
|
|
16191
16536
|
3600
|
|
16192
16537
|
),
|
|
16193
16538
|
run_as_user_id: resolveRunAsFlag(flags, "deploy update")
|
|
16194
|
-
}
|
|
16539
|
+
};
|
|
16540
|
+
const serializedArgs = serializedJSONFlag(
|
|
16541
|
+
flags["args"],
|
|
16542
|
+
"deploy update"
|
|
16543
|
+
);
|
|
16544
|
+
return serializedArgs === void 0 ? client.deploy.update(params) : client.deploy._updateSerializedArgs(params, serializedArgs);
|
|
16545
|
+
}
|
|
16195
16546
|
case "delete":
|
|
16196
16547
|
return client.deploy.delete({
|
|
16197
16548
|
id: requireNumericFlag(flags, "id", "deploy delete")
|
|
@@ -16422,6 +16773,31 @@ async function dispatch(client, args, meta, deps) {
|
|
|
16422
16773
|
);
|
|
16423
16774
|
case "update":
|
|
16424
16775
|
return client.automation.update(automationUpdateParams(flags));
|
|
16776
|
+
case "delivery": {
|
|
16777
|
+
const leaf = parsedCommand.path[2];
|
|
16778
|
+
if (!leaf || leaf === "--help" || leaf === "-h") {
|
|
16779
|
+
return { _help: true, text: COMMAND_HELP.automation };
|
|
16780
|
+
}
|
|
16781
|
+
switch (leaf) {
|
|
16782
|
+
case "get":
|
|
16783
|
+
return client.automation.delivery.get({
|
|
16784
|
+
id: requirePositiveIntegerStringFlag(
|
|
16785
|
+
flags,
|
|
16786
|
+
"id",
|
|
16787
|
+
"automation delivery get"
|
|
16788
|
+
)
|
|
16789
|
+
});
|
|
16790
|
+
case "update":
|
|
16791
|
+
return client.automation.delivery.update(
|
|
16792
|
+
automationDeliveryUpdateParams(flags)
|
|
16793
|
+
);
|
|
16794
|
+
default:
|
|
16795
|
+
throw new CliUsageError(
|
|
16796
|
+
`Unknown subcommand: automation delivery ${leaf}`,
|
|
16797
|
+
"automation"
|
|
16798
|
+
);
|
|
16799
|
+
}
|
|
16800
|
+
}
|
|
16425
16801
|
case "stop":
|
|
16426
16802
|
return client.automation.stop({
|
|
16427
16803
|
id: requireNumericFlag(flags, "id", "automation stop")
|