deepline 0.3.55 → 0.3.57
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/bundling-sources/sdk/src/client.ts +232 -0
- package/dist/bundling-sources/sdk/src/http.ts +1 -1
- package/dist/bundling-sources/sdk/src/index.ts +29 -0
- package/dist/bundling-sources/sdk/src/monitor-fleet-contract.ts +556 -0
- package/dist/bundling-sources/sdk/src/monitor-fleets.ts +31 -0
- package/dist/bundling-sources/sdk/src/play.ts +2 -8
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/monitor-fleet-limits.ts +14 -0
- package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +102 -0
- package/dist/bundling-sources/shared_libs/monitors/validation.ts +244 -0
- package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +1 -1
- package/dist/cli/index.js +1688 -356
- package/dist/cli/index.mjs +1624 -292
- package/dist/index.d.mts +220 -9
- package/dist/index.d.ts +220 -9
- package/dist/index.js +474 -14
- package/dist/index.mjs +464 -14
- package/dist/install-integrity.json +5 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -738,7 +738,7 @@ var SDK_RELEASE = {
|
|
|
738
738
|
// available at toolResponse.rawV2 while toolResponse.raw and all declared
|
|
739
739
|
// getters keep their established compatibility behavior.
|
|
740
740
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
741
|
-
version: "0.3.
|
|
741
|
+
version: "0.3.57",
|
|
742
742
|
updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
|
|
743
743
|
packageCapabilities: {
|
|
744
744
|
updatePreferences: 1
|
|
@@ -2744,9 +2744,9 @@ function nonEmptyString(value) {
|
|
|
2744
2744
|
}
|
|
2745
2745
|
function normalizeDatasetBornFrom(value) {
|
|
2746
2746
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
2747
|
-
const
|
|
2748
|
-
const table = nonEmptyString(
|
|
2749
|
-
const rowCountIn = finiteNonNegativeInteger2(
|
|
2747
|
+
const record2 = value;
|
|
2748
|
+
const table = nonEmptyString(record2.table);
|
|
2749
|
+
const rowCountIn = finiteNonNegativeInteger2(record2.rowCountIn);
|
|
2750
2750
|
if (!table || rowCountIn === null) return null;
|
|
2751
2751
|
return { table, rowCountIn };
|
|
2752
2752
|
}
|
|
@@ -3806,21 +3806,21 @@ function normalizePlayRuntimeNamespace(value) {
|
|
|
3806
3806
|
}
|
|
3807
3807
|
function normalizePlayRuntimeSelection(value) {
|
|
3808
3808
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
3809
|
-
const
|
|
3810
|
-
if (Object.keys(
|
|
3809
|
+
const record2 = value;
|
|
3810
|
+
if (Object.keys(record2).some(
|
|
3811
3811
|
(key) => key !== "environment" && key !== "namespace" && key !== "backend"
|
|
3812
|
-
) ||
|
|
3812
|
+
) || record2.environment !== "preview") {
|
|
3813
3813
|
return null;
|
|
3814
3814
|
}
|
|
3815
|
-
const namespace = normalizePlayRuntimeNamespace(
|
|
3815
|
+
const namespace = normalizePlayRuntimeNamespace(record2.namespace);
|
|
3816
3816
|
if (!namespace) return null;
|
|
3817
|
-
if (
|
|
3817
|
+
if (record2.backend === void 0) {
|
|
3818
3818
|
return { environment: "preview", namespace };
|
|
3819
3819
|
}
|
|
3820
|
-
if (
|
|
3820
|
+
if (record2.backend !== PLAY_RUNTIME_BACKENDS.daytona && record2.backend !== PLAY_RUNTIME_BACKENDS.modal) {
|
|
3821
3821
|
return null;
|
|
3822
3822
|
}
|
|
3823
|
-
return { environment: "preview", namespace, backend:
|
|
3823
|
+
return { environment: "preview", namespace, backend: record2.backend };
|
|
3824
3824
|
}
|
|
3825
3825
|
function normalizePlayRuntimeEnvironment(value) {
|
|
3826
3826
|
return typeof value === "string" && PLAY_RUNTIME_ENVIRONMENTS.includes(value) ? value : null;
|
|
@@ -4404,7 +4404,14 @@ var DeeplineClient = class {
|
|
|
4404
4404
|
dependents: (key) => this.getMonitorDependents(key),
|
|
4405
4405
|
update: (key, patch) => this.updateMonitor(key, patch),
|
|
4406
4406
|
delete: (key, options2) => this.deleteMonitor(key, options2),
|
|
4407
|
-
reactivate: (key, options2) => this.reactivateMonitor(key, options2)
|
|
4407
|
+
reactivate: (key, options2) => this.reactivateMonitor(key, options2),
|
|
4408
|
+
fleets: {
|
|
4409
|
+
sync: (definitionOrId, options2) => this.syncMonitorFleet(definitionOrId, options2),
|
|
4410
|
+
get: (fleetId, options2) => fleetId === void 0 ? this.listMonitorFleets() : this.getMonitorFleet(fleetId, options2),
|
|
4411
|
+
list: () => this.listMonitorFleets(),
|
|
4412
|
+
deactivate: (fleetId, options2) => this.deactivateMonitorFleet(fleetId, options2),
|
|
4413
|
+
waitForConvergence: (fleetId, options2) => this.waitForMonitorFleetConvergence(fleetId, options2)
|
|
4414
|
+
}
|
|
4408
4415
|
};
|
|
4409
4416
|
}
|
|
4410
4417
|
/** The resolved base URL this client is targeting (e.g. `"http://localhost:3000"`). */
|
|
@@ -6712,6 +6719,104 @@ var DeeplineClient = class {
|
|
|
6712
6719
|
{ method: "POST", body: {} }
|
|
6713
6720
|
);
|
|
6714
6721
|
}
|
|
6722
|
+
// ——————————————————————————————————————————————————————————
|
|
6723
|
+
// Monitor Fleets
|
|
6724
|
+
// ——————————————————————————————————————————————————————————
|
|
6725
|
+
monitorFleetIdempotencyKey(operation) {
|
|
6726
|
+
const uuid = globalThis.crypto?.randomUUID?.();
|
|
6727
|
+
return `monitor-fleet-${operation}-${uuid ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`}`;
|
|
6728
|
+
}
|
|
6729
|
+
monitorFleetHeaders(operation, idempotencyKey) {
|
|
6730
|
+
return {
|
|
6731
|
+
"Idempotency-Key": idempotencyKey?.trim() || this.monitorFleetIdempotencyKey(operation)
|
|
6732
|
+
};
|
|
6733
|
+
}
|
|
6734
|
+
monitorFleetPath(fleetId) {
|
|
6735
|
+
return `/api/v2/monitors/fleets/${encodeURIComponent(fleetId)}`;
|
|
6736
|
+
}
|
|
6737
|
+
/**
|
|
6738
|
+
* Create, update, or re-plan one fleet.
|
|
6739
|
+
*
|
|
6740
|
+
* The fleet id is always the resource path, so the same definition PUT twice
|
|
6741
|
+
* is the same operation and the server can answer `replayed: true` instead of
|
|
6742
|
+
* building a second set of monitors. Re-planning an existing fleet from its
|
|
6743
|
+
* stored definition sends an EMPTY body: there is no second definition to
|
|
6744
|
+
* send, and an empty body cannot be mistaken for "replace the definition with
|
|
6745
|
+
* nothing".
|
|
6746
|
+
*/
|
|
6747
|
+
async syncMonitorFleet(definitionOrId, options) {
|
|
6748
|
+
const fleetId = typeof definitionOrId === "string" ? definitionOrId : definitionOrId.id;
|
|
6749
|
+
const body = {
|
|
6750
|
+
...typeof definitionOrId === "string" ? {} : { definition: definitionOrId },
|
|
6751
|
+
...options?.dryRun ? { dry_run: true } : {},
|
|
6752
|
+
...options?.expectedGeneration !== void 0 ? { expected_generation: options.expectedGeneration } : {}
|
|
6753
|
+
};
|
|
6754
|
+
return this.http.request(
|
|
6755
|
+
this.monitorFleetPath(fleetId),
|
|
6756
|
+
{
|
|
6757
|
+
method: "PUT",
|
|
6758
|
+
body,
|
|
6759
|
+
headers: this.monitorFleetHeaders("sync", options?.idempotencyKey),
|
|
6760
|
+
maxRetries: 0,
|
|
6761
|
+
exactUrlOnly: true
|
|
6762
|
+
}
|
|
6763
|
+
);
|
|
6764
|
+
}
|
|
6765
|
+
async listMonitorFleets() {
|
|
6766
|
+
return this.http.request("/api/v2/monitors/fleets", {
|
|
6767
|
+
method: "GET"
|
|
6768
|
+
});
|
|
6769
|
+
}
|
|
6770
|
+
async getMonitorFleet(fleetId, options) {
|
|
6771
|
+
const params = new URLSearchParams();
|
|
6772
|
+
if (options?.drift) params.set("drift", "1");
|
|
6773
|
+
if (options?.limit !== void 0)
|
|
6774
|
+
params.set("limit", String(options.limit));
|
|
6775
|
+
const query = params.toString();
|
|
6776
|
+
return this.http.request(
|
|
6777
|
+
`${this.monitorFleetPath(fleetId)}${query ? `?${query}` : ""}`,
|
|
6778
|
+
{ method: "GET" }
|
|
6779
|
+
);
|
|
6780
|
+
}
|
|
6781
|
+
async deactivateMonitorFleet(fleetId, options) {
|
|
6782
|
+
return this.http.request(
|
|
6783
|
+
this.monitorFleetPath(fleetId),
|
|
6784
|
+
{
|
|
6785
|
+
method: "DELETE",
|
|
6786
|
+
body: options?.dryRun ? { dry_run: true } : {},
|
|
6787
|
+
headers: this.monitorFleetHeaders(
|
|
6788
|
+
"deactivate",
|
|
6789
|
+
options?.idempotencyKey
|
|
6790
|
+
),
|
|
6791
|
+
maxRetries: 0,
|
|
6792
|
+
exactUrlOnly: true
|
|
6793
|
+
}
|
|
6794
|
+
);
|
|
6795
|
+
}
|
|
6796
|
+
/**
|
|
6797
|
+
* Poll one fleet until the server reports a terminal status.
|
|
6798
|
+
*
|
|
6799
|
+
* Convergence is the server's verdict, read from `status`. The timeout is not
|
|
6800
|
+
* a failure and does not throw: a fleet still `converging` after ten minutes
|
|
6801
|
+
* is healthy and slow, not broken, so the caller gets the last snapshot and
|
|
6802
|
+
* decides what that means. Throwing here would have made "still working" look
|
|
6803
|
+
* identical to "the request failed".
|
|
6804
|
+
*/
|
|
6805
|
+
async waitForMonitorFleetConvergence(fleetId, options) {
|
|
6806
|
+
const timeoutMs = Math.max(1, options?.timeoutMs ?? 10 * 6e4);
|
|
6807
|
+
const pollIntervalMs = Math.max(1, options?.pollIntervalMs ?? 2e3);
|
|
6808
|
+
const terminal = options?.until === "deactivated" ? /* @__PURE__ */ new Set(["deactivated", "degraded"]) : /* @__PURE__ */ new Set(["converged", "degraded", "deactivated"]);
|
|
6809
|
+
const startedAt = Date.now();
|
|
6810
|
+
let latest = await this.getMonitorFleet(fleetId);
|
|
6811
|
+
while (true) {
|
|
6812
|
+
options?.onProgress?.(latest);
|
|
6813
|
+
const status = typeof latest.status === "string" ? latest.status : void 0;
|
|
6814
|
+
if (status && terminal.has(status)) return latest;
|
|
6815
|
+
if (Date.now() - startedAt >= timeoutMs) return latest;
|
|
6816
|
+
await sleep2(pollIntervalMs);
|
|
6817
|
+
latest = await this.getMonitorFleet(fleetId);
|
|
6818
|
+
}
|
|
6819
|
+
}
|
|
6715
6820
|
/**
|
|
6716
6821
|
* Check API connectivity and server health.
|
|
6717
6822
|
*
|
|
@@ -7758,8 +7863,8 @@ function firstExperienceDate(value) {
|
|
|
7758
7863
|
return null;
|
|
7759
7864
|
}
|
|
7760
7865
|
function normalizeJobChange(value) {
|
|
7761
|
-
const
|
|
7762
|
-
const nested = isRecord8(
|
|
7866
|
+
const record2 = isRecord8(value) ? value : {};
|
|
7867
|
+
const nested = isRecord8(record2.job_change) ? record2.job_change : record2;
|
|
7763
7868
|
const output = isRecord8(nested.output) ? nested.output : nested;
|
|
7764
7869
|
const person = isRecord8(output.person) ? output.person : {};
|
|
7765
7870
|
const status = normalizeJobChangeStatus(
|
|
@@ -10306,6 +10411,341 @@ function defineMonitor(definition) {
|
|
|
10306
10411
|
return definition;
|
|
10307
10412
|
}
|
|
10308
10413
|
|
|
10414
|
+
// src/monitor-fleet-contract.ts
|
|
10415
|
+
var MONITOR_FLEET_MAX_MEMBERS = 1e3;
|
|
10416
|
+
var MONITOR_FLEET_FRONTIER_MAX_ROWS = 1e4;
|
|
10417
|
+
var MONITOR_FLEET_AUTHORING_CONTRACT_EDITION = 1;
|
|
10418
|
+
var SUPPORTED_MONITOR_FLEET_AUTHORING_CONTRACT_EDITIONS = [
|
|
10419
|
+
MONITOR_FLEET_AUTHORING_CONTRACT_EDITION
|
|
10420
|
+
];
|
|
10421
|
+
var MONITOR_FLEET_AUTHORING_CONTRACT_CHANGELOG = [
|
|
10422
|
+
{
|
|
10423
|
+
edition: 1,
|
|
10424
|
+
changed: "Initial Fleet JSON contract: bounded sticky table membership, one daily sync, and a seven-day removal grace.",
|
|
10425
|
+
compatibilityOwner: "Monitors Runtime",
|
|
10426
|
+
newWritesEnd: null,
|
|
10427
|
+
readerRemoval: null
|
|
10428
|
+
}
|
|
10429
|
+
];
|
|
10430
|
+
var MONITOR_FLEET_REMOVAL_GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
10431
|
+
var MONITOR_FLEET_DOCUMENTATION = {
|
|
10432
|
+
summary: "A Monitor Fleet keeps one bounded, sticky set of ordinary monitors aligned with Customer DB rows.",
|
|
10433
|
+
authoredFields: {
|
|
10434
|
+
id: "Stable lowercase fleet id used by sync, pause, resume, and deactivate.",
|
|
10435
|
+
source: "Customer DB table, unique row key, and optional equality filters that select candidate rows.",
|
|
10436
|
+
member: "Ordinary monitor tool, stable key template, and payload evaluated for each selected source row.",
|
|
10437
|
+
selection: "Deterministic ranking and an active-member limit between 1 and 1,000."
|
|
10438
|
+
},
|
|
10439
|
+
fixedPolicy: {
|
|
10440
|
+
cadence: "daily",
|
|
10441
|
+
membership: "sticky",
|
|
10442
|
+
removalGrace: "7d",
|
|
10443
|
+
onRemoved: "deactivate",
|
|
10444
|
+
ownership: "A Fleet may adopt a same-tool ordinary monitor with its deterministic member key. The first Fleet claim wins; another Fleet or a different tool receives a conflict.",
|
|
10445
|
+
billing: "No Fleet fee, permit, or renewal. Dry-run reports ordinary monitor lifecycle charges due now."
|
|
10446
|
+
},
|
|
10447
|
+
stickyMembership: "Ranking fills vacancies but never replaces a current member merely because another row ranks higher.",
|
|
10448
|
+
columnExpression: 'Use { "$fleet": "column", "name": "column_name" } in a member key or payload to read a value from each source row.'
|
|
10449
|
+
};
|
|
10450
|
+
function record(value) {
|
|
10451
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
10452
|
+
}
|
|
10453
|
+
function identifier(value) {
|
|
10454
|
+
return typeof value === "string" && /^[A-Za-z_][A-Za-z0-9_]*$/.test(value);
|
|
10455
|
+
}
|
|
10456
|
+
function exactKeys(input, keys, path, issues) {
|
|
10457
|
+
if (!input) return;
|
|
10458
|
+
for (const key of Object.keys(input)) {
|
|
10459
|
+
if (keys.includes(key)) continue;
|
|
10460
|
+
issues.push({
|
|
10461
|
+
path: path ? `${path}.${key}` : key,
|
|
10462
|
+
code: "unknown_fleet_field",
|
|
10463
|
+
message: `${path || "Fleet"} does not accept '${key}'.`
|
|
10464
|
+
});
|
|
10465
|
+
}
|
|
10466
|
+
}
|
|
10467
|
+
function jsonValue(value, path, issues) {
|
|
10468
|
+
if (value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value)) {
|
|
10469
|
+
return;
|
|
10470
|
+
}
|
|
10471
|
+
if (Array.isArray(value)) {
|
|
10472
|
+
value.forEach((item, index) => jsonValue(item, `${path}.${index}`, issues));
|
|
10473
|
+
return;
|
|
10474
|
+
}
|
|
10475
|
+
const input = record(value);
|
|
10476
|
+
if (!input) {
|
|
10477
|
+
issues.push({
|
|
10478
|
+
path,
|
|
10479
|
+
code: "invalid_fleet_json_value",
|
|
10480
|
+
message: "Fleet payload values must be JSON values."
|
|
10481
|
+
});
|
|
10482
|
+
return;
|
|
10483
|
+
}
|
|
10484
|
+
for (const [key, item] of Object.entries(input)) {
|
|
10485
|
+
jsonValue(item, `${path}.${key}`, issues);
|
|
10486
|
+
}
|
|
10487
|
+
}
|
|
10488
|
+
function fleetColumn(name) {
|
|
10489
|
+
if (!identifier(name)) throw new Error(`Invalid fleet column '${name}'.`);
|
|
10490
|
+
return { $fleet: "column", name };
|
|
10491
|
+
}
|
|
10492
|
+
function fleetKey(...parts) {
|
|
10493
|
+
if (parts.length === 0)
|
|
10494
|
+
throw new Error("A fleet key needs at least one part.");
|
|
10495
|
+
return { $fleet: "template", parts };
|
|
10496
|
+
}
|
|
10497
|
+
function defineMonitorFleet(definition) {
|
|
10498
|
+
return definition;
|
|
10499
|
+
}
|
|
10500
|
+
function validateExpression(value, path, issues) {
|
|
10501
|
+
const input = record(value);
|
|
10502
|
+
if (!input || input.$fleet !== "column" || !identifier(input.name)) {
|
|
10503
|
+
issues.push({
|
|
10504
|
+
path,
|
|
10505
|
+
code: "invalid_fleet_expression",
|
|
10506
|
+
message: "Fleet expressions must be an exact tagged column reference."
|
|
10507
|
+
});
|
|
10508
|
+
return;
|
|
10509
|
+
}
|
|
10510
|
+
exactKeys(input, ["$fleet", "name"], path, issues);
|
|
10511
|
+
}
|
|
10512
|
+
function walkPayload(value, path, issues) {
|
|
10513
|
+
if (Array.isArray(value)) {
|
|
10514
|
+
value.forEach(
|
|
10515
|
+
(item, index) => walkPayload(item, `${path}.${index}`, issues)
|
|
10516
|
+
);
|
|
10517
|
+
return;
|
|
10518
|
+
}
|
|
10519
|
+
const input = record(value);
|
|
10520
|
+
if (!input) return;
|
|
10521
|
+
if ("$fleet" in input) {
|
|
10522
|
+
validateExpression(input, path, issues);
|
|
10523
|
+
return;
|
|
10524
|
+
}
|
|
10525
|
+
for (const [key, item] of Object.entries(input)) {
|
|
10526
|
+
walkPayload(item, `${path}.${key}`, issues);
|
|
10527
|
+
}
|
|
10528
|
+
}
|
|
10529
|
+
function validateMonitorFleetDefinition(value) {
|
|
10530
|
+
const issues = [];
|
|
10531
|
+
const input = record(value);
|
|
10532
|
+
if (!input) {
|
|
10533
|
+
return {
|
|
10534
|
+
valid: false,
|
|
10535
|
+
issues: [
|
|
10536
|
+
{
|
|
10537
|
+
path: "",
|
|
10538
|
+
code: "invalid_fleet",
|
|
10539
|
+
message: "Fleet must be an object."
|
|
10540
|
+
}
|
|
10541
|
+
]
|
|
10542
|
+
};
|
|
10543
|
+
}
|
|
10544
|
+
exactKeys(input, ["id", "source", "member", "selection"], "", issues);
|
|
10545
|
+
if (typeof input.id !== "string" || !/^[a-z][a-z0-9-]{0,199}$/.test(input.id)) {
|
|
10546
|
+
issues.push({
|
|
10547
|
+
path: "id",
|
|
10548
|
+
code: "invalid_fleet_id",
|
|
10549
|
+
message: "Fleet id must be lowercase kebab-case."
|
|
10550
|
+
});
|
|
10551
|
+
}
|
|
10552
|
+
const source = record(input.source);
|
|
10553
|
+
exactKeys(
|
|
10554
|
+
source,
|
|
10555
|
+
["kind", "schema", "table", "key", "where"],
|
|
10556
|
+
"source",
|
|
10557
|
+
issues
|
|
10558
|
+
);
|
|
10559
|
+
if (!source || source.kind !== "customer_db_table") {
|
|
10560
|
+
issues.push({
|
|
10561
|
+
path: "source.kind",
|
|
10562
|
+
code: "invalid_fleet_source",
|
|
10563
|
+
message: "Beta fleets require customer_db_table."
|
|
10564
|
+
});
|
|
10565
|
+
}
|
|
10566
|
+
if (!identifier(source?.schema) || !identifier(source?.table)) {
|
|
10567
|
+
issues.push({
|
|
10568
|
+
path: "source",
|
|
10569
|
+
code: "invalid_fleet_table",
|
|
10570
|
+
message: "Source schema and table must be SQL identifiers."
|
|
10571
|
+
});
|
|
10572
|
+
}
|
|
10573
|
+
const sourceKey = record(source?.key);
|
|
10574
|
+
exactKeys(sourceKey, ["column", "type"], "source.key", issues);
|
|
10575
|
+
if (!sourceKey || !identifier(sourceKey.column) || !["text", "uuid", "int4", "int8"].includes(String(sourceKey.type))) {
|
|
10576
|
+
issues.push({
|
|
10577
|
+
path: "source.key",
|
|
10578
|
+
code: "invalid_fleet_source_key",
|
|
10579
|
+
message: "Source key must name a supported typed column."
|
|
10580
|
+
});
|
|
10581
|
+
}
|
|
10582
|
+
if (source?.where !== void 0) {
|
|
10583
|
+
const where = record(source.where);
|
|
10584
|
+
if (!where) {
|
|
10585
|
+
issues.push({
|
|
10586
|
+
path: "source.where",
|
|
10587
|
+
code: "invalid_fleet_where",
|
|
10588
|
+
message: "source.where must be an object of equality values."
|
|
10589
|
+
});
|
|
10590
|
+
} else {
|
|
10591
|
+
for (const [column, expected] of Object.entries(where)) {
|
|
10592
|
+
if (!identifier(column)) {
|
|
10593
|
+
issues.push({
|
|
10594
|
+
path: `source.where.${column}`,
|
|
10595
|
+
code: "invalid_fleet_where_column",
|
|
10596
|
+
message: "source.where keys must be SQL identifiers."
|
|
10597
|
+
});
|
|
10598
|
+
}
|
|
10599
|
+
if (expected !== null && typeof expected !== "string" && typeof expected !== "boolean" && !(typeof expected === "number" && Number.isFinite(expected))) {
|
|
10600
|
+
issues.push({
|
|
10601
|
+
path: `source.where.${column}`,
|
|
10602
|
+
code: "invalid_fleet_where_value",
|
|
10603
|
+
message: "source.where values must be finite JSON scalars or null."
|
|
10604
|
+
});
|
|
10605
|
+
}
|
|
10606
|
+
}
|
|
10607
|
+
}
|
|
10608
|
+
}
|
|
10609
|
+
const member = record(input.member);
|
|
10610
|
+
exactKeys(member, ["tool", "key", "payload"], "member", issues);
|
|
10611
|
+
const key = record(member?.key);
|
|
10612
|
+
if (!member || typeof member.tool !== "string" || !member.tool.trim()) {
|
|
10613
|
+
issues.push({
|
|
10614
|
+
path: "member.tool",
|
|
10615
|
+
code: "invalid_fleet_tool",
|
|
10616
|
+
message: "Member tool is required."
|
|
10617
|
+
});
|
|
10618
|
+
}
|
|
10619
|
+
if (!key || key.$fleet !== "template" || !Array.isArray(key.parts) || key.parts.length === 0) {
|
|
10620
|
+
issues.push({
|
|
10621
|
+
path: "member.key",
|
|
10622
|
+
code: "invalid_fleet_key",
|
|
10623
|
+
message: "Member key must be a tagged fleet template."
|
|
10624
|
+
});
|
|
10625
|
+
} else {
|
|
10626
|
+
exactKeys(key, ["$fleet", "parts"], "member.key", issues);
|
|
10627
|
+
for (const [index, part] of key.parts.entries()) {
|
|
10628
|
+
if (typeof part !== "string")
|
|
10629
|
+
validateExpression(part, `member.key.parts.${index}`, issues);
|
|
10630
|
+
}
|
|
10631
|
+
if (sourceKey && !key.parts.some(
|
|
10632
|
+
(part) => record(part)?.$fleet === "column" && record(part)?.name === sourceKey.column
|
|
10633
|
+
)) {
|
|
10634
|
+
issues.push({
|
|
10635
|
+
path: "member.key.parts",
|
|
10636
|
+
code: "fleet_key_missing_source_key",
|
|
10637
|
+
message: "Member key must include the source key column."
|
|
10638
|
+
});
|
|
10639
|
+
}
|
|
10640
|
+
}
|
|
10641
|
+
if (!member || !("payload" in member)) {
|
|
10642
|
+
issues.push({
|
|
10643
|
+
path: "member.payload",
|
|
10644
|
+
code: "invalid_fleet_payload",
|
|
10645
|
+
message: "Member payload is required."
|
|
10646
|
+
});
|
|
10647
|
+
} else {
|
|
10648
|
+
jsonValue(member.payload, "member.payload", issues);
|
|
10649
|
+
}
|
|
10650
|
+
walkPayload(member?.payload, "member.payload", issues);
|
|
10651
|
+
const selection = record(input.selection);
|
|
10652
|
+
exactKeys(selection, ["limit", "orderBy", "membership"], "selection", issues);
|
|
10653
|
+
if (!selection || !Number.isSafeInteger(selection.limit) || Number(selection.limit) < 1 || Number(selection.limit) > MONITOR_FLEET_MAX_MEMBERS) {
|
|
10654
|
+
issues.push({
|
|
10655
|
+
path: "selection.limit",
|
|
10656
|
+
code: "MONITOR_FLEET_LIMIT_EXCEEDED",
|
|
10657
|
+
message: "selection.limit must be between 1 and 1,000."
|
|
10658
|
+
});
|
|
10659
|
+
}
|
|
10660
|
+
if (selection?.membership !== "sticky") {
|
|
10661
|
+
issues.push({
|
|
10662
|
+
path: "selection.membership",
|
|
10663
|
+
code: "invalid_fleet_membership",
|
|
10664
|
+
message: `Fleet membership is fixed to ${MONITOR_FLEET_DOCUMENTATION.fixedPolicy.membership}. ${MONITOR_FLEET_DOCUMENTATION.stickyMembership}`
|
|
10665
|
+
});
|
|
10666
|
+
}
|
|
10667
|
+
const orderBy = selection?.orderBy;
|
|
10668
|
+
if (!Array.isArray(orderBy) || orderBy.length === 0) {
|
|
10669
|
+
issues.push({
|
|
10670
|
+
path: "selection.orderBy",
|
|
10671
|
+
code: "invalid_fleet_order",
|
|
10672
|
+
message: "At least one deterministic order field is required."
|
|
10673
|
+
});
|
|
10674
|
+
} else {
|
|
10675
|
+
const orderColumns = /* @__PURE__ */ new Set();
|
|
10676
|
+
for (const [index, order] of orderBy.entries()) {
|
|
10677
|
+
const item = record(order);
|
|
10678
|
+
exactKeys(
|
|
10679
|
+
item,
|
|
10680
|
+
["column", "direction"],
|
|
10681
|
+
`selection.orderBy.${index}`,
|
|
10682
|
+
issues
|
|
10683
|
+
);
|
|
10684
|
+
if (!item || !identifier(item.column) || !["asc", "desc"].includes(String(item.direction))) {
|
|
10685
|
+
issues.push({
|
|
10686
|
+
path: `selection.orderBy.${index}`,
|
|
10687
|
+
code: "invalid_fleet_order",
|
|
10688
|
+
message: "Order fields need a column and asc/desc direction."
|
|
10689
|
+
});
|
|
10690
|
+
} else if (orderColumns.has(item.column)) {
|
|
10691
|
+
issues.push({
|
|
10692
|
+
path: `selection.orderBy.${index}.column`,
|
|
10693
|
+
code: "duplicate_fleet_order_column",
|
|
10694
|
+
message: "Each selection order column may appear only once."
|
|
10695
|
+
});
|
|
10696
|
+
} else {
|
|
10697
|
+
orderColumns.add(item.column);
|
|
10698
|
+
}
|
|
10699
|
+
}
|
|
10700
|
+
if (sourceKey && record(orderBy.at(-1))?.column !== sourceKey.column) {
|
|
10701
|
+
issues.push({
|
|
10702
|
+
path: "selection.orderBy",
|
|
10703
|
+
code: "fleet_order_missing_key",
|
|
10704
|
+
message: "The final order field must be the source key."
|
|
10705
|
+
});
|
|
10706
|
+
}
|
|
10707
|
+
}
|
|
10708
|
+
for (const removedOption of ["spendLimits", "lifecycle", "reconciliation"]) {
|
|
10709
|
+
if (removedOption in input) {
|
|
10710
|
+
issues.push({
|
|
10711
|
+
path: removedOption,
|
|
10712
|
+
code: "unsupported_fleet_option",
|
|
10713
|
+
message: `${removedOption} is fixed by Monitor Fleets and must be omitted. Fleets sync ${MONITOR_FLEET_DOCUMENTATION.fixedPolicy.cadence} and ${MONITOR_FLEET_DOCUMENTATION.fixedPolicy.onRemoved} members after ${MONITOR_FLEET_DOCUMENTATION.fixedPolicy.removalGrace} absent from the source.`
|
|
10714
|
+
});
|
|
10715
|
+
}
|
|
10716
|
+
}
|
|
10717
|
+
return issues.length === 0 ? { valid: true, definition: value, issues } : { valid: false, issues };
|
|
10718
|
+
}
|
|
10719
|
+
function admitMonitorFleetAuthoringContract(value, edition = MONITOR_FLEET_AUTHORING_CONTRACT_EDITION) {
|
|
10720
|
+
if (!SUPPORTED_MONITOR_FLEET_AUTHORING_CONTRACT_EDITIONS.includes(
|
|
10721
|
+
edition
|
|
10722
|
+
)) {
|
|
10723
|
+
return {
|
|
10724
|
+
valid: false,
|
|
10725
|
+
issues: [
|
|
10726
|
+
{
|
|
10727
|
+
path: "authoring_contract_edition",
|
|
10728
|
+
code: "unsupported_fleet_authoring_contract_edition",
|
|
10729
|
+
message: `Monitor Fleet authoring contract edition ${edition} is not supported.`
|
|
10730
|
+
}
|
|
10731
|
+
]
|
|
10732
|
+
};
|
|
10733
|
+
}
|
|
10734
|
+
const result = validateMonitorFleetDefinition(value);
|
|
10735
|
+
return result.valid && result.definition ? {
|
|
10736
|
+
valid: true,
|
|
10737
|
+
contract: {
|
|
10738
|
+
edition,
|
|
10739
|
+
// JSON cloning prevents later caller mutation from changing the
|
|
10740
|
+
// admitted snapshot.
|
|
10741
|
+
definition: JSON.parse(
|
|
10742
|
+
JSON.stringify(result.definition)
|
|
10743
|
+
)
|
|
10744
|
+
},
|
|
10745
|
+
issues: []
|
|
10746
|
+
} : { valid: false, issues: result.issues };
|
|
10747
|
+
}
|
|
10748
|
+
|
|
10309
10749
|
// ../plays/bootstrap-routes.ts
|
|
10310
10750
|
var DEEPLINE_TOOL_CATEGORIES = [
|
|
10311
10751
|
"company_search",
|
|
@@ -10593,6 +11033,11 @@ export {
|
|
|
10593
11033
|
DeeplineContext,
|
|
10594
11034
|
DeeplineError,
|
|
10595
11035
|
JOB_CHANGE_STATUS_VALUES,
|
|
11036
|
+
MONITOR_FLEET_AUTHORING_CONTRACT_CHANGELOG,
|
|
11037
|
+
MONITOR_FLEET_AUTHORING_CONTRACT_EDITION,
|
|
11038
|
+
MONITOR_FLEET_DOCUMENTATION,
|
|
11039
|
+
MONITOR_FLEET_FRONTIER_MAX_ROWS,
|
|
11040
|
+
MONITOR_FLEET_MAX_MEMBERS,
|
|
10596
11041
|
PHONE_STATUS_VALUES,
|
|
10597
11042
|
PLAY_BOOTSTRAP_COMPANY_FIELDS,
|
|
10598
11043
|
PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY,
|
|
@@ -10612,11 +11057,15 @@ export {
|
|
|
10612
11057
|
SDK_VERSION,
|
|
10613
11058
|
ToolExecutionError,
|
|
10614
11059
|
ToolRateLimitError,
|
|
11060
|
+
admitMonitorFleetAuthoringContract,
|
|
10615
11061
|
defineInput,
|
|
10616
11062
|
defineMonitor,
|
|
11063
|
+
defineMonitorFleet,
|
|
10617
11064
|
definePlay,
|
|
10618
11065
|
defineWorkflow,
|
|
10619
11066
|
extractSummaryFields,
|
|
11067
|
+
fleetColumn,
|
|
11068
|
+
fleetKey,
|
|
10620
11069
|
formatPlayBootstrapFinderKinds,
|
|
10621
11070
|
formatPlayBootstrapFinderKindsForSentence,
|
|
10622
11071
|
formatPlayBootstrapTemplates,
|
|
@@ -10631,6 +11080,7 @@ export {
|
|
|
10631
11080
|
runIf,
|
|
10632
11081
|
steps,
|
|
10633
11082
|
tryConvertToList,
|
|
11083
|
+
validateMonitorFleetDefinition,
|
|
10634
11084
|
writeCsvOutputFile,
|
|
10635
11085
|
writeJsonOutputFile
|
|
10636
11086
|
};
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"dist/bundling-sources/sdk/src/helpers.ts",
|
|
11
11
|
"dist/bundling-sources/sdk/src/http.ts",
|
|
12
12
|
"dist/bundling-sources/sdk/src/index.ts",
|
|
13
|
+
"dist/bundling-sources/sdk/src/monitor-fleet-contract.ts",
|
|
14
|
+
"dist/bundling-sources/sdk/src/monitor-fleets.ts",
|
|
13
15
|
"dist/bundling-sources/sdk/src/monitors.ts",
|
|
14
16
|
"dist/bundling-sources/sdk/src/play.ts",
|
|
15
17
|
"dist/bundling-sources/sdk/src/plays/bundle-play-file.ts",
|
|
@@ -23,6 +25,9 @@
|
|
|
23
25
|
"dist/bundling-sources/sdk/src/version.ts",
|
|
24
26
|
"dist/bundling-sources/shared_libs/integrations/bettercontact-execution-policy.ts",
|
|
25
27
|
"dist/bundling-sources/shared_libs/integrations/theirstack-execution-policy.ts",
|
|
28
|
+
"dist/bundling-sources/shared_libs/monitors/monitor-fleet-limits.ts",
|
|
29
|
+
"dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts",
|
|
30
|
+
"dist/bundling-sources/shared_libs/monitors/validation.ts",
|
|
26
31
|
"dist/bundling-sources/shared_libs/observability/node-tracing.ts",
|
|
27
32
|
"dist/bundling-sources/shared_libs/observability/redaction.ts",
|
|
28
33
|
"dist/bundling-sources/shared_libs/observability/scheduled-job-errors.ts",
|