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
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fleet member ceiling, mirrored — deliberately a literal.
|
|
3
|
+
*
|
|
4
|
+
* The canonical declaration is shared_libs/monitors/monitor-fleet-limits.ts,
|
|
5
|
+
* which the Convex commit mutation reads to size its transaction. This package
|
|
6
|
+
* cannot import it: the workspace-architecture ratchet forbids NEW shared_libs
|
|
7
|
+
* imports from packages absolutely (only relocations of pre-existing edges
|
|
8
|
+
* pass CI), because shared_libs is being migrated into workspace packages.
|
|
9
|
+
* Until a monitors package exists, the two copies are held equal by
|
|
10
|
+
* tests/lib/monitors/monitor-fleet-limits-mirror.test.ts — change one without
|
|
11
|
+
* the other and that test names both files.
|
|
12
|
+
*/
|
|
13
|
+
export const MONITOR_FLEET_MAX_MEMBERS = 1_000;
|
|
14
|
+
|
|
15
|
+
export const MONITOR_FLEET_FRONTIER_MAX_ROWS = 10_000;
|
|
16
|
+
/**
|
|
17
|
+
* Fleet definitions are admitted once and executed many times. Keep the
|
|
18
|
+
* edition beside the definition just as Plays keep their authoring-contract
|
|
19
|
+
* edition: a future syntax change can add a reader without reinterpreting a
|
|
20
|
+
* stored Fleet under new rules.
|
|
21
|
+
*/
|
|
22
|
+
export const MONITOR_FLEET_AUTHORING_CONTRACT_EDITION = 1 as const;
|
|
23
|
+
export const SUPPORTED_MONITOR_FLEET_AUTHORING_CONTRACT_EDITIONS = [
|
|
24
|
+
MONITOR_FLEET_AUTHORING_CONTRACT_EDITION,
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
27
|
+
export type MonitorFleetAuthoringContractEdition =
|
|
28
|
+
(typeof SUPPORTED_MONITOR_FLEET_AUTHORING_CONTRACT_EDITIONS)[number];
|
|
29
|
+
|
|
30
|
+
export const MONITOR_FLEET_AUTHORING_CONTRACT_CHANGELOG = [
|
|
31
|
+
{
|
|
32
|
+
edition: 1,
|
|
33
|
+
changed:
|
|
34
|
+
'Initial Fleet JSON contract: bounded sticky table membership, one daily sync, and a seven-day removal grace.',
|
|
35
|
+
compatibilityOwner: 'Monitors Runtime',
|
|
36
|
+
newWritesEnd: null,
|
|
37
|
+
readerRemoval: null,
|
|
38
|
+
},
|
|
39
|
+
] as const;
|
|
40
|
+
/**
|
|
41
|
+
* Fleets are deliberately opinionated in beta: a member absent from the
|
|
42
|
+
* source remains intact for seven days, then its ordinary monitor is
|
|
43
|
+
* deactivated. This prevents transient source refreshes from deleting a
|
|
44
|
+
* provider resource while keeping the customer contract small.
|
|
45
|
+
*/
|
|
46
|
+
export const MONITOR_FLEET_REMOVAL_GRACE_MS = 7 * 24 * 60 * 60_000;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Public, machine-readable guidance for every Monitor Fleet authoring
|
|
50
|
+
* surface. SDK clients may render this directly; the CLI uses the same fixed
|
|
51
|
+
* policy values in its help rather than maintaining another contract.
|
|
52
|
+
*/
|
|
53
|
+
export const MONITOR_FLEET_DOCUMENTATION = {
|
|
54
|
+
summary:
|
|
55
|
+
'A Monitor Fleet keeps one bounded, sticky set of ordinary monitors aligned with Customer DB rows.',
|
|
56
|
+
authoredFields: {
|
|
57
|
+
id: 'Stable lowercase fleet id used by sync, pause, resume, and deactivate.',
|
|
58
|
+
source:
|
|
59
|
+
'Customer DB table, unique row key, and optional equality filters that select candidate rows.',
|
|
60
|
+
member:
|
|
61
|
+
'Ordinary monitor tool, stable key template, and payload evaluated for each selected source row.',
|
|
62
|
+
selection:
|
|
63
|
+
'Deterministic ranking and an active-member limit between 1 and 1,000.',
|
|
64
|
+
},
|
|
65
|
+
fixedPolicy: {
|
|
66
|
+
cadence: 'daily',
|
|
67
|
+
membership: 'sticky',
|
|
68
|
+
removalGrace: '7d',
|
|
69
|
+
onRemoved: 'deactivate',
|
|
70
|
+
ownership:
|
|
71
|
+
'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.',
|
|
72
|
+
billing:
|
|
73
|
+
'No Fleet fee, permit, or renewal. Dry-run reports ordinary monitor lifecycle charges due now.',
|
|
74
|
+
},
|
|
75
|
+
stickyMembership:
|
|
76
|
+
'Ranking fills vacancies but never replaces a current member merely because another row ranks higher.',
|
|
77
|
+
columnExpression:
|
|
78
|
+
'Use { "$fleet": "column", "name": "column_name" } in a member key or payload to read a value from each source row.',
|
|
79
|
+
} as const;
|
|
80
|
+
|
|
81
|
+
export type MonitorFleetColumn = {
|
|
82
|
+
$fleet: 'column';
|
|
83
|
+
name: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type MonitorFleetTemplate = {
|
|
87
|
+
$fleet: 'template';
|
|
88
|
+
parts: Array<string | MonitorFleetColumn>;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type MonitorFleetExpression = MonitorFleetColumn | MonitorFleetTemplate;
|
|
92
|
+
|
|
93
|
+
export type MonitorFleetDefinition = {
|
|
94
|
+
/** Stable lowercase fleet id, used by CLI and API lifecycle commands. */
|
|
95
|
+
id: string;
|
|
96
|
+
/** Customer DB rows that may become members. */
|
|
97
|
+
source: {
|
|
98
|
+
kind: 'customer_db_table';
|
|
99
|
+
schema: string;
|
|
100
|
+
table: string;
|
|
101
|
+
key: { column: string; type: 'text' | 'uuid' | 'int4' | 'int8' };
|
|
102
|
+
where?: Record<string, string | number | boolean | null>;
|
|
103
|
+
};
|
|
104
|
+
/** One ordinary monitor definition, evaluated once for each selected row. */
|
|
105
|
+
member: {
|
|
106
|
+
tool: string;
|
|
107
|
+
key: MonitorFleetTemplate;
|
|
108
|
+
payload: Record<string, unknown>;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Bounded deterministic candidate selection. Membership is intentionally
|
|
112
|
+
* sticky: ranking chooses vacant slots but does not replace existing members
|
|
113
|
+
* merely because another row's score changed.
|
|
114
|
+
*/
|
|
115
|
+
selection: {
|
|
116
|
+
limit: number;
|
|
117
|
+
orderBy: Array<{
|
|
118
|
+
column: string;
|
|
119
|
+
direction: 'asc' | 'desc';
|
|
120
|
+
}>;
|
|
121
|
+
membership: 'sticky';
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type MonitorFleetContractIssue = {
|
|
126
|
+
path: string;
|
|
127
|
+
code: string;
|
|
128
|
+
message: string;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/** The durable, validated snapshot that a Fleet sync is allowed to execute. */
|
|
132
|
+
export type AdmittedMonitorFleetAuthoringContract = {
|
|
133
|
+
edition: MonitorFleetAuthoringContractEdition;
|
|
134
|
+
definition: MonitorFleetDefinition;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export type MonitorFleetAuthoringContractResult = {
|
|
138
|
+
valid: boolean;
|
|
139
|
+
contract?: AdmittedMonitorFleetAuthoringContract;
|
|
140
|
+
issues: MonitorFleetContractIssue[];
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
function record(value: unknown): Record<string, unknown> | null {
|
|
144
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
145
|
+
? (value as Record<string, unknown>)
|
|
146
|
+
: null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function identifier(value: unknown): value is string {
|
|
150
|
+
return typeof value === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(value);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function exactKeys(
|
|
154
|
+
input: Record<string, unknown> | null,
|
|
155
|
+
keys: readonly string[],
|
|
156
|
+
path: string,
|
|
157
|
+
issues: MonitorFleetContractIssue[],
|
|
158
|
+
): void {
|
|
159
|
+
if (!input) return;
|
|
160
|
+
for (const key of Object.keys(input)) {
|
|
161
|
+
if (keys.includes(key)) continue;
|
|
162
|
+
issues.push({
|
|
163
|
+
path: path ? `${path}.${key}` : key,
|
|
164
|
+
code: 'unknown_fleet_field',
|
|
165
|
+
message: `${path || 'Fleet'} does not accept '${key}'.`,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function jsonValue(
|
|
171
|
+
value: unknown,
|
|
172
|
+
path: string,
|
|
173
|
+
issues: MonitorFleetContractIssue[],
|
|
174
|
+
): void {
|
|
175
|
+
if (
|
|
176
|
+
value === null ||
|
|
177
|
+
typeof value === 'string' ||
|
|
178
|
+
typeof value === 'boolean' ||
|
|
179
|
+
(typeof value === 'number' && Number.isFinite(value))
|
|
180
|
+
) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (Array.isArray(value)) {
|
|
184
|
+
value.forEach((item, index) => jsonValue(item, `${path}.${index}`, issues));
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const input = record(value);
|
|
188
|
+
if (!input) {
|
|
189
|
+
issues.push({
|
|
190
|
+
path,
|
|
191
|
+
code: 'invalid_fleet_json_value',
|
|
192
|
+
message: 'Fleet payload values must be JSON values.',
|
|
193
|
+
});
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
for (const [key, item] of Object.entries(input)) {
|
|
197
|
+
jsonValue(item, `${path}.${key}`, issues);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function fleetColumn(name: string): MonitorFleetColumn {
|
|
202
|
+
if (!identifier(name)) throw new Error(`Invalid fleet column '${name}'.`);
|
|
203
|
+
return { $fleet: 'column', name };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function fleetKey(
|
|
207
|
+
...parts: Array<string | MonitorFleetColumn>
|
|
208
|
+
): MonitorFleetTemplate {
|
|
209
|
+
if (parts.length === 0)
|
|
210
|
+
throw new Error('A fleet key needs at least one part.');
|
|
211
|
+
return { $fleet: 'template', parts };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function defineMonitorFleet<const T extends MonitorFleetDefinition>(
|
|
215
|
+
definition: T,
|
|
216
|
+
): T {
|
|
217
|
+
return definition;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function validateExpression(
|
|
221
|
+
value: unknown,
|
|
222
|
+
path: string,
|
|
223
|
+
issues: MonitorFleetContractIssue[],
|
|
224
|
+
): void {
|
|
225
|
+
const input = record(value);
|
|
226
|
+
if (!input || input.$fleet !== 'column' || !identifier(input.name)) {
|
|
227
|
+
issues.push({
|
|
228
|
+
path,
|
|
229
|
+
code: 'invalid_fleet_expression',
|
|
230
|
+
message: 'Fleet expressions must be an exact tagged column reference.',
|
|
231
|
+
});
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
exactKeys(input, ['$fleet', 'name'], path, issues);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function walkPayload(
|
|
238
|
+
value: unknown,
|
|
239
|
+
path: string,
|
|
240
|
+
issues: MonitorFleetContractIssue[],
|
|
241
|
+
): void {
|
|
242
|
+
if (Array.isArray(value)) {
|
|
243
|
+
value.forEach((item, index) =>
|
|
244
|
+
walkPayload(item, `${path}.${index}`, issues),
|
|
245
|
+
);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const input = record(value);
|
|
249
|
+
if (!input) return;
|
|
250
|
+
if ('$fleet' in input) {
|
|
251
|
+
validateExpression(input, path, issues);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
for (const [key, item] of Object.entries(input)) {
|
|
255
|
+
walkPayload(item, `${path}.${key}`, issues);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function validateMonitorFleetDefinition(value: unknown): {
|
|
260
|
+
valid: boolean;
|
|
261
|
+
definition?: MonitorFleetDefinition;
|
|
262
|
+
issues: MonitorFleetContractIssue[];
|
|
263
|
+
} {
|
|
264
|
+
const issues: MonitorFleetContractIssue[] = [];
|
|
265
|
+
const input = record(value);
|
|
266
|
+
if (!input) {
|
|
267
|
+
return {
|
|
268
|
+
valid: false,
|
|
269
|
+
issues: [
|
|
270
|
+
{
|
|
271
|
+
path: '',
|
|
272
|
+
code: 'invalid_fleet',
|
|
273
|
+
message: 'Fleet must be an object.',
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
exactKeys(input, ['id', 'source', 'member', 'selection'], '', issues);
|
|
279
|
+
if (
|
|
280
|
+
typeof input.id !== 'string' ||
|
|
281
|
+
!/^[a-z][a-z0-9-]{0,199}$/.test(input.id)
|
|
282
|
+
) {
|
|
283
|
+
issues.push({
|
|
284
|
+
path: 'id',
|
|
285
|
+
code: 'invalid_fleet_id',
|
|
286
|
+
message: 'Fleet id must be lowercase kebab-case.',
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
const source = record(input.source);
|
|
290
|
+
exactKeys(
|
|
291
|
+
source,
|
|
292
|
+
['kind', 'schema', 'table', 'key', 'where'],
|
|
293
|
+
'source',
|
|
294
|
+
issues,
|
|
295
|
+
);
|
|
296
|
+
if (!source || source.kind !== 'customer_db_table') {
|
|
297
|
+
issues.push({
|
|
298
|
+
path: 'source.kind',
|
|
299
|
+
code: 'invalid_fleet_source',
|
|
300
|
+
message: 'Beta fleets require customer_db_table.',
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
if (!identifier(source?.schema) || !identifier(source?.table)) {
|
|
304
|
+
issues.push({
|
|
305
|
+
path: 'source',
|
|
306
|
+
code: 'invalid_fleet_table',
|
|
307
|
+
message: 'Source schema and table must be SQL identifiers.',
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
const sourceKey = record(source?.key);
|
|
311
|
+
exactKeys(sourceKey, ['column', 'type'], 'source.key', issues);
|
|
312
|
+
if (
|
|
313
|
+
!sourceKey ||
|
|
314
|
+
!identifier(sourceKey.column) ||
|
|
315
|
+
!['text', 'uuid', 'int4', 'int8'].includes(String(sourceKey.type))
|
|
316
|
+
) {
|
|
317
|
+
issues.push({
|
|
318
|
+
path: 'source.key',
|
|
319
|
+
code: 'invalid_fleet_source_key',
|
|
320
|
+
message: 'Source key must name a supported typed column.',
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
if (source?.where !== undefined) {
|
|
324
|
+
const where = record(source.where);
|
|
325
|
+
if (!where) {
|
|
326
|
+
issues.push({
|
|
327
|
+
path: 'source.where',
|
|
328
|
+
code: 'invalid_fleet_where',
|
|
329
|
+
message: 'source.where must be an object of equality values.',
|
|
330
|
+
});
|
|
331
|
+
} else {
|
|
332
|
+
for (const [column, expected] of Object.entries(where)) {
|
|
333
|
+
if (!identifier(column)) {
|
|
334
|
+
issues.push({
|
|
335
|
+
path: `source.where.${column}`,
|
|
336
|
+
code: 'invalid_fleet_where_column',
|
|
337
|
+
message: 'source.where keys must be SQL identifiers.',
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (
|
|
341
|
+
expected !== null &&
|
|
342
|
+
typeof expected !== 'string' &&
|
|
343
|
+
typeof expected !== 'boolean' &&
|
|
344
|
+
!(typeof expected === 'number' && Number.isFinite(expected))
|
|
345
|
+
) {
|
|
346
|
+
issues.push({
|
|
347
|
+
path: `source.where.${column}`,
|
|
348
|
+
code: 'invalid_fleet_where_value',
|
|
349
|
+
message: 'source.where values must be finite JSON scalars or null.',
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const member = record(input.member);
|
|
356
|
+
exactKeys(member, ['tool', 'key', 'payload'], 'member', issues);
|
|
357
|
+
const key = record(member?.key);
|
|
358
|
+
if (!member || typeof member.tool !== 'string' || !member.tool.trim()) {
|
|
359
|
+
issues.push({
|
|
360
|
+
path: 'member.tool',
|
|
361
|
+
code: 'invalid_fleet_tool',
|
|
362
|
+
message: 'Member tool is required.',
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
if (
|
|
366
|
+
!key ||
|
|
367
|
+
key.$fleet !== 'template' ||
|
|
368
|
+
!Array.isArray(key.parts) ||
|
|
369
|
+
key.parts.length === 0
|
|
370
|
+
) {
|
|
371
|
+
issues.push({
|
|
372
|
+
path: 'member.key',
|
|
373
|
+
code: 'invalid_fleet_key',
|
|
374
|
+
message: 'Member key must be a tagged fleet template.',
|
|
375
|
+
});
|
|
376
|
+
} else {
|
|
377
|
+
exactKeys(key, ['$fleet', 'parts'], 'member.key', issues);
|
|
378
|
+
for (const [index, part] of key.parts.entries()) {
|
|
379
|
+
if (typeof part !== 'string')
|
|
380
|
+
validateExpression(part, `member.key.parts.${index}`, issues);
|
|
381
|
+
}
|
|
382
|
+
if (
|
|
383
|
+
sourceKey &&
|
|
384
|
+
!key.parts.some(
|
|
385
|
+
(part) =>
|
|
386
|
+
record(part)?.$fleet === 'column' &&
|
|
387
|
+
record(part)?.name === sourceKey.column,
|
|
388
|
+
)
|
|
389
|
+
) {
|
|
390
|
+
issues.push({
|
|
391
|
+
path: 'member.key.parts',
|
|
392
|
+
code: 'fleet_key_missing_source_key',
|
|
393
|
+
message: 'Member key must include the source key column.',
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (!member || !('payload' in member)) {
|
|
398
|
+
issues.push({
|
|
399
|
+
path: 'member.payload',
|
|
400
|
+
code: 'invalid_fleet_payload',
|
|
401
|
+
message: 'Member payload is required.',
|
|
402
|
+
});
|
|
403
|
+
} else {
|
|
404
|
+
jsonValue(member.payload, 'member.payload', issues);
|
|
405
|
+
}
|
|
406
|
+
walkPayload(member?.payload, 'member.payload', issues);
|
|
407
|
+
const selection = record(input.selection);
|
|
408
|
+
exactKeys(selection, ['limit', 'orderBy', 'membership'], 'selection', issues);
|
|
409
|
+
if (
|
|
410
|
+
!selection ||
|
|
411
|
+
!Number.isSafeInteger(selection.limit) ||
|
|
412
|
+
Number(selection.limit) < 1 ||
|
|
413
|
+
Number(selection.limit) > MONITOR_FLEET_MAX_MEMBERS
|
|
414
|
+
) {
|
|
415
|
+
issues.push({
|
|
416
|
+
path: 'selection.limit',
|
|
417
|
+
code: 'MONITOR_FLEET_LIMIT_EXCEEDED',
|
|
418
|
+
message: 'selection.limit must be between 1 and 1,000.',
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
if (selection?.membership !== 'sticky') {
|
|
422
|
+
issues.push({
|
|
423
|
+
path: 'selection.membership',
|
|
424
|
+
code: 'invalid_fleet_membership',
|
|
425
|
+
message: `Fleet membership is fixed to ${MONITOR_FLEET_DOCUMENTATION.fixedPolicy.membership}. ${MONITOR_FLEET_DOCUMENTATION.stickyMembership}`,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
const orderBy = selection?.orderBy;
|
|
429
|
+
if (!Array.isArray(orderBy) || orderBy.length === 0) {
|
|
430
|
+
issues.push({
|
|
431
|
+
path: 'selection.orderBy',
|
|
432
|
+
code: 'invalid_fleet_order',
|
|
433
|
+
message: 'At least one deterministic order field is required.',
|
|
434
|
+
});
|
|
435
|
+
} else {
|
|
436
|
+
const orderColumns = new Set<string>();
|
|
437
|
+
for (const [index, order] of orderBy.entries()) {
|
|
438
|
+
const item = record(order);
|
|
439
|
+
exactKeys(
|
|
440
|
+
item,
|
|
441
|
+
['column', 'direction'],
|
|
442
|
+
`selection.orderBy.${index}`,
|
|
443
|
+
issues,
|
|
444
|
+
);
|
|
445
|
+
if (
|
|
446
|
+
!item ||
|
|
447
|
+
!identifier(item.column) ||
|
|
448
|
+
!['asc', 'desc'].includes(String(item.direction))
|
|
449
|
+
) {
|
|
450
|
+
issues.push({
|
|
451
|
+
path: `selection.orderBy.${index}`,
|
|
452
|
+
code: 'invalid_fleet_order',
|
|
453
|
+
message: 'Order fields need a column and asc/desc direction.',
|
|
454
|
+
});
|
|
455
|
+
} else if (orderColumns.has(item.column as string)) {
|
|
456
|
+
issues.push({
|
|
457
|
+
path: `selection.orderBy.${index}.column`,
|
|
458
|
+
code: 'duplicate_fleet_order_column',
|
|
459
|
+
message: 'Each selection order column may appear only once.',
|
|
460
|
+
});
|
|
461
|
+
} else {
|
|
462
|
+
orderColumns.add(item.column as string);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (sourceKey && record(orderBy.at(-1))?.column !== sourceKey.column) {
|
|
466
|
+
issues.push({
|
|
467
|
+
path: 'selection.orderBy',
|
|
468
|
+
code: 'fleet_order_missing_key',
|
|
469
|
+
message: 'The final order field must be the source key.',
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
for (const removedOption of ['spendLimits', 'lifecycle', 'reconciliation']) {
|
|
474
|
+
if (removedOption in input) {
|
|
475
|
+
issues.push({
|
|
476
|
+
path: removedOption,
|
|
477
|
+
code: 'unsupported_fleet_option',
|
|
478
|
+
message:
|
|
479
|
+
`${removedOption} is fixed by Monitor Fleets and must be omitted. ` +
|
|
480
|
+
`Fleets sync ${MONITOR_FLEET_DOCUMENTATION.fixedPolicy.cadence} and ${MONITOR_FLEET_DOCUMENTATION.fixedPolicy.onRemoved} members after ${MONITOR_FLEET_DOCUMENTATION.fixedPolicy.removalGrace} absent from the source.`,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return issues.length === 0
|
|
485
|
+
? { valid: true, definition: value as MonitorFleetDefinition, issues }
|
|
486
|
+
: { valid: false, issues };
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Compile JSON into the exact authoring snapshot persisted by a Fleet. This
|
|
491
|
+
* does not inspect the Customer DB or provider; use
|
|
492
|
+
* `fleets sync --file <fleet.json> --dry-run` for that environment-aware
|
|
493
|
+
* preflight, which returns the real plan and the credits due.
|
|
494
|
+
*/
|
|
495
|
+
export function admitMonitorFleetAuthoringContract(
|
|
496
|
+
value: unknown,
|
|
497
|
+
edition: number = MONITOR_FLEET_AUTHORING_CONTRACT_EDITION,
|
|
498
|
+
): MonitorFleetAuthoringContractResult {
|
|
499
|
+
if (
|
|
500
|
+
!SUPPORTED_MONITOR_FLEET_AUTHORING_CONTRACT_EDITIONS.includes(
|
|
501
|
+
edition as MonitorFleetAuthoringContractEdition,
|
|
502
|
+
)
|
|
503
|
+
) {
|
|
504
|
+
return {
|
|
505
|
+
valid: false,
|
|
506
|
+
issues: [
|
|
507
|
+
{
|
|
508
|
+
path: 'authoring_contract_edition',
|
|
509
|
+
code: 'unsupported_fleet_authoring_contract_edition',
|
|
510
|
+
message: `Monitor Fleet authoring contract edition ${edition} is not supported.`,
|
|
511
|
+
},
|
|
512
|
+
],
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
const result = validateMonitorFleetDefinition(value);
|
|
516
|
+
return result.valid && result.definition
|
|
517
|
+
? {
|
|
518
|
+
valid: true,
|
|
519
|
+
contract: {
|
|
520
|
+
edition: edition as MonitorFleetAuthoringContractEdition,
|
|
521
|
+
// JSON cloning prevents later caller mutation from changing the
|
|
522
|
+
// admitted snapshot.
|
|
523
|
+
definition: JSON.parse(
|
|
524
|
+
JSON.stringify(result.definition),
|
|
525
|
+
) as MonitorFleetDefinition,
|
|
526
|
+
},
|
|
527
|
+
issues: [],
|
|
528
|
+
}
|
|
529
|
+
: { valid: false, issues: result.issues };
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export function evaluateMonitorFleetValue(
|
|
533
|
+
value: unknown,
|
|
534
|
+
row: Record<string, unknown>,
|
|
535
|
+
): unknown {
|
|
536
|
+
if (Array.isArray(value))
|
|
537
|
+
return value.map((item) => evaluateMonitorFleetValue(item, row));
|
|
538
|
+
const input = record(value);
|
|
539
|
+
if (!input) return value;
|
|
540
|
+
if (input.$fleet === 'column') return row[String(input.name)];
|
|
541
|
+
if (input.$fleet === 'template' && Array.isArray(input.parts)) {
|
|
542
|
+
return input.parts
|
|
543
|
+
.map((part) =>
|
|
544
|
+
typeof part === 'string'
|
|
545
|
+
? part
|
|
546
|
+
: String(evaluateMonitorFleetValue(part, row) ?? ''),
|
|
547
|
+
)
|
|
548
|
+
.join('');
|
|
549
|
+
}
|
|
550
|
+
return Object.fromEntries(
|
|
551
|
+
Object.entries(input).map(([key, item]) => [
|
|
552
|
+
key,
|
|
553
|
+
evaluateMonitorFleetValue(item, row),
|
|
554
|
+
]),
|
|
555
|
+
);
|
|
556
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Monitor Fleet authoring helpers and AST types.
|
|
3
|
+
*
|
|
4
|
+
* Fleet definitions are stored and executed as tagged JSON. The contract lives
|
|
5
|
+
* in this package and the server imports it from here, so an SDK-authored
|
|
6
|
+
* definition and the server's `$fleet` representation cannot drift: there is
|
|
7
|
+
* one definition of the grammar, not a copy on each side.
|
|
8
|
+
*/
|
|
9
|
+
export {
|
|
10
|
+
admitMonitorFleetAuthoringContract,
|
|
11
|
+
MONITOR_FLEET_AUTHORING_CONTRACT_CHANGELOG,
|
|
12
|
+
MONITOR_FLEET_AUTHORING_CONTRACT_EDITION,
|
|
13
|
+
MONITOR_FLEET_FRONTIER_MAX_ROWS,
|
|
14
|
+
MONITOR_FLEET_DOCUMENTATION,
|
|
15
|
+
MONITOR_FLEET_MAX_MEMBERS,
|
|
16
|
+
defineMonitorFleet,
|
|
17
|
+
fleetColumn,
|
|
18
|
+
fleetKey,
|
|
19
|
+
validateMonitorFleetDefinition,
|
|
20
|
+
} from './monitor-fleet-contract.js';
|
|
21
|
+
|
|
22
|
+
export type {
|
|
23
|
+
AdmittedMonitorFleetAuthoringContract,
|
|
24
|
+
MonitorFleetAuthoringContractEdition,
|
|
25
|
+
MonitorFleetAuthoringContractResult,
|
|
26
|
+
MonitorFleetColumn,
|
|
27
|
+
MonitorFleetContractIssue,
|
|
28
|
+
MonitorFleetDefinition,
|
|
29
|
+
MonitorFleetExpression,
|
|
30
|
+
MonitorFleetTemplate,
|
|
31
|
+
} from './monitor-fleet-contract.js';
|
|
@@ -998,8 +998,7 @@ function createNamedPlayHandle<
|
|
|
998
998
|
/**
|
|
999
999
|
* High-level SDK context with tool shortcuts and play handles.
|
|
1000
1000
|
*
|
|
1001
|
-
* Created by {@link Deepline.connect}. Wraps a {@link DeeplineClient} with
|
|
1002
|
-
* a friendlier API for common operations.
|
|
1001
|
+
* Created by {@link Deepline.connect}. Wraps a {@link DeeplineClient} with a friendlier API for common operations.
|
|
1003
1002
|
*
|
|
1004
1003
|
* @example
|
|
1005
1004
|
* ```typescript
|
|
@@ -1532,12 +1531,7 @@ export function defineInput<TInput>(
|
|
|
1532
1531
|
/**
|
|
1533
1532
|
* Define a play — a composable TypeScript workflow for the Deepline platform.
|
|
1534
1533
|
*
|
|
1535
|
-
* The returned value is both
|
|
1536
|
-
* 1. **A callable function** — invoked by the Temporal worker with a runtime context
|
|
1537
|
-
* 2. **A named play handle** — with `.run()`, `.versions()`, `.get()`, `.publish()`, etc. for remote lifecycle management
|
|
1538
|
-
*
|
|
1539
|
-
* Plays are the primary abstraction for building repeatable data pipelines.
|
|
1540
|
-
* They run on Temporal for durable execution with automatic retries and timeouts.
|
|
1534
|
+
* The returned value is both a callable function, invoked by the Deepline runtime with a runtime context, and a named play handle carrying `.run()`, `.versions()`, `.get()` and `.publish()` for remote lifecycle management. Plays are the primary abstraction for repeatable data pipelines and execute durably, with automatic retries and timeouts.
|
|
1541
1535
|
*
|
|
1542
1536
|
* @typeParam TInput - The input type accepted by the play
|
|
1543
1537
|
* @typeParam TOutput - The return type of the play
|
|
@@ -199,7 +199,7 @@ export const SDK_RELEASE = {
|
|
|
199
199
|
// available at toolResponse.rawV2 while toolResponse.raw and all declared
|
|
200
200
|
// getters keep their established compatibility behavior.
|
|
201
201
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
202
|
-
version: '0.3.
|
|
202
|
+
version: '0.3.57',
|
|
203
203
|
updateSummary:
|
|
204
204
|
'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.',
|
|
205
205
|
packageCapabilities: {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How large one Monitor Fleet may be.
|
|
3
|
+
*
|
|
4
|
+
* This lives in `shared_libs` rather than in the SDK's fleet authoring contract
|
|
5
|
+
* because Convex needs it too: the commit mutation sizes its own transaction
|
|
6
|
+
* against the same number the authoring contract validates a fleet's selection
|
|
7
|
+
* limit against. Two copies of that number would drift, and the drift would
|
|
8
|
+
* only be visible as a mutation that refuses a plan the SDK admitted.
|
|
9
|
+
*
|
|
10
|
+
* `packages/sdk/src/monitor-fleet-contract.ts` re-exports it, so customer-facing
|
|
11
|
+
* code keeps importing it from the contract module and never learns this file
|
|
12
|
+
* exists.
|
|
13
|
+
*/
|
|
14
|
+
export const MONITOR_FLEET_MAX_MEMBERS = 1_000;
|