@substrat-run/control-plane-api 0.119.0 → 0.120.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/api.d.ts.map +1 -1
- package/dist/api.js +34 -7
- package/dist/api.js.map +1 -1
- package/dist/cf-observability.d.ts.map +1 -1
- package/dist/cf-observability.js +10 -4
- package/dist/cf-observability.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/observability-window.d.ts +13 -0
- package/dist/observability-window.d.ts.map +1 -0
- package/dist/observability-window.js +20 -0
- package/dist/observability-window.js.map +1 -0
- package/dist/observability.d.ts +8 -0
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js.map +1 -1
- package/package.json +6 -6
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAyEL,CAAC,EAKF,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EAEpB,eAAe,EAGf,eAAe,EAQhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9F,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAqBrF,OAAO,KAAK,EAEV,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,aAAa,C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IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,CAqkLhG"}
|
package/dist/api.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveObservabilityWindow } from './observability-window.js';
|
|
1
2
|
import { Hono } from 'hono';
|
|
2
3
|
import { parseHostname, withLabel, RESERVED_LABEL_SEPARATOR, adminAction, ASSET_PART_PREFIX, assetHash, channelName, connectionActivity, connectionActivitySource, connectionCredential, connectionFilter, connectionHealthState, connectionProvider, connectorDispatchKind, PROVISION_SIBLING_KIND, ARCHIVE_SCOPE_KIND, PROVISION_TENANT_KIND, SET_ENTITLEMENTS_KIND, MODEL_USAGE_KIND, SWEEP_RUNS_KIND, toConnectionHealthEntry, CONNECTION_EXPIRY_WARNING_DAYS, CONNECTION_STALE_DAYS, connectionProbe, createTenantInput, entitlementGrantInput, hostname as hostnameSchema, hostnameRegion, hostnameStatus, identityLink, errorCode, issueStatus, issueStatusInput, listPageQuery, matchesOutboundHost, pageOf, platformRequestFilter, principalId as principalIdSchema, promotionAcknowledgement, provisionableJurisdiction, publishVersionInput, queryScopeInput, readScopeTableInput, entityHistoryInput, eventFacetInput, eventCauseInput, eventEffectsInput, invocationEventsInput, deadLettersInput, delegatedReadParams, createOrgInput, roleKey as roleKeySchema, peerSwitch, systemSwitch, DEFAULT_DENIAL_LIMIT, DENIAL_LIMIT_MAX, denialGroupBy, registerVerticalInput, serviceDimensions, sweepRunKind, sweepRunOutcome, scopeDump, dataSubjectId as dataSubjectIdSchema, scopeId as scopeIdSchema, scopeStatus, storageShape, surfaceName, tenantId as tenantIdSchema, tenantStatus, versionOrigin, z, PROBLEM_CONTENT_TYPE, toProblem, redrainEventsInput, REDRAIN_BATCH, } from '@substrat-run/contracts';
|
|
3
4
|
import { attributeFailure } from './failure-attribution.js';
|
|
@@ -1573,7 +1574,8 @@ export function createControlPlaneApi(options) {
|
|
|
1573
1574
|
* current dispatch — resolved BEFORE any version rebind), restore into the serving
|
|
1574
1575
|
* script (which re-projects the vertical's roles), and only then `setScopeServingRef` +
|
|
1575
1576
|
* advance the version pointer. A crash before the flip leaves the scope serving its old
|
|
1576
|
-
* script intact, and the adopt retries idempotently.
|
|
1577
|
+
* script intact, and the adopt retries idempotently. Previews are refused; already-adopted
|
|
1578
|
+
* installs short-circuit.
|
|
1577
1579
|
* Throws `ControlPlaneError` so callers surface an actionable status, never a bare 500.
|
|
1578
1580
|
*/
|
|
1579
1581
|
const adoptScopeOntoServing = async (c, tenantId, scopeId) => {
|
|
@@ -1582,6 +1584,9 @@ export function createControlPlaneApi(options) {
|
|
|
1582
1584
|
if (!scope) {
|
|
1583
1585
|
throw new ControlPlaneError(404, `unknown scope for tenant: (${tenantId}, ${scopeId})`);
|
|
1584
1586
|
}
|
|
1587
|
+
if (scope.kind === 'preview') {
|
|
1588
|
+
throw new ControlPlaneError(409, 'preview scopes cannot adopt the production serving script');
|
|
1589
|
+
}
|
|
1585
1590
|
if (scope.servingRef)
|
|
1586
1591
|
return { servingRef: scope.servingRef, alreadyAdopted: true };
|
|
1587
1592
|
if (!scope.vertical) {
|
|
@@ -1610,8 +1615,8 @@ export function createControlPlaneApi(options) {
|
|
|
1610
1615
|
* pointer to the promoted version so Update stops offering a crossing already made.
|
|
1611
1616
|
*
|
|
1612
1617
|
* Gated exactly where the host cascade would have run: PRIVATE (owned, unlisted) only,
|
|
1613
|
-
* active non-fork scopes only. Runs only when a serving script exists —
|
|
1614
|
-
* actually happened (dispatch-backed + deploy configured); for an embedded vertical the
|
|
1618
|
+
* active non-fork, non-preview scopes only. Runs only when a serving script exists —
|
|
1619
|
+
* i.e. the serve actually happened (dispatch-backed + deploy configured); for an embedded vertical the
|
|
1615
1620
|
* host cascade already rebound, and `verticalServing` is null, so this is a no-op.
|
|
1616
1621
|
* Idempotent and retry-safe: the host cascade never rebound these scopes, so their data
|
|
1617
1622
|
* is still findable on a retry after a failed serve.
|
|
@@ -1624,7 +1629,7 @@ export function createControlPlaneApi(options) {
|
|
|
1624
1629
|
const v = await verticalOf(actor, slug);
|
|
1625
1630
|
if (!v || v.ownerTenant === null || v.listed)
|
|
1626
1631
|
return; // private only, like the host cascade
|
|
1627
|
-
const owned = (await admin.listScopes(actor, { tenantId: v.ownerTenant, vertical: slug, status: ['active'] })).filter((s) => !s.forkedFrom);
|
|
1632
|
+
const owned = (await admin.listScopes(actor, { tenantId: v.ownerTenant, vertical: slug, status: ['active'] })).filter((s) => !s.forkedFrom && s.kind !== 'preview');
|
|
1628
1633
|
for (const s of owned) {
|
|
1629
1634
|
if (!s.servingRef) {
|
|
1630
1635
|
// Adopt: export from the scope's current (un-rebound) dispatch → serving script,
|
|
@@ -3205,7 +3210,7 @@ export function createControlPlaneApi(options) {
|
|
|
3205
3210
|
if (v.ownerTenant === null) {
|
|
3206
3211
|
return c.json({ error: 'adopt-serving is a private-vertical operation' }, 409);
|
|
3207
3212
|
}
|
|
3208
|
-
const owned = (await admin.listScopes(actor, { tenantId: v.ownerTenant, vertical: slug })).filter((s) => !s.forkedFrom && s.status === 'active');
|
|
3213
|
+
const owned = (await admin.listScopes(actor, { tenantId: v.ownerTenant, vertical: slug })).filter((s) => !s.forkedFrom && s.kind !== 'preview' && s.status === 'active');
|
|
3209
3214
|
const adopted = [];
|
|
3210
3215
|
const alreadyAdopted = [];
|
|
3211
3216
|
try {
|
|
@@ -4562,13 +4567,24 @@ export function createControlPlaneApi(options) {
|
|
|
4562
4567
|
scopeId: z.string().min(1).max(64).optional(),
|
|
4563
4568
|
vertical: z.string().min(1).max(200).optional(),
|
|
4564
4569
|
hours: z.coerce.number().int().min(1).max(72).default(24),
|
|
4570
|
+
since: z.string().datetime({ offset: true }).optional(),
|
|
4571
|
+
until: z.string().datetime({ offset: true }).optional(),
|
|
4565
4572
|
})
|
|
4566
4573
|
.parse({
|
|
4567
4574
|
tenantId,
|
|
4568
4575
|
scopeId: c.req.query('scopeId') || undefined,
|
|
4569
4576
|
vertical: c.req.query('vertical') || undefined,
|
|
4570
|
-
hours: c.req.query('hours'),
|
|
4577
|
+
hours: c.req.query('hours'), since: c.req.query('since'), until: c.req.query('until'),
|
|
4571
4578
|
});
|
|
4579
|
+
try {
|
|
4580
|
+
resolveObservabilityWindow(input);
|
|
4581
|
+
}
|
|
4582
|
+
catch (e) {
|
|
4583
|
+
throw new ControlPlaneError(400, e.message);
|
|
4584
|
+
}
|
|
4585
|
+
if (input.since !== undefined && !options.observability.absoluteTenantWindows) {
|
|
4586
|
+
throw new ControlPlaneError(501, 'absolute tenant telemetry windows are not supported by this backend');
|
|
4587
|
+
}
|
|
4572
4588
|
return c.json(await options.observability.tenantMetrics(input));
|
|
4573
4589
|
});
|
|
4574
4590
|
// The bucketed twin (#1447): the series a team-level chart plots, one line per app.
|
|
@@ -4592,8 +4608,19 @@ export function createControlPlaneApi(options) {
|
|
|
4592
4608
|
// zero rows rather than somebody else's, so no ownership check is needed here.
|
|
4593
4609
|
scopeIds: z.array(z.string().min(1).max(64)).min(1).max(TENANT_SERIES_SCOPE_CAP),
|
|
4594
4610
|
hours: z.coerce.number().int().min(1).max(72).default(24),
|
|
4611
|
+
since: z.string().datetime({ offset: true }).optional(),
|
|
4612
|
+
until: z.string().datetime({ offset: true }).optional(),
|
|
4595
4613
|
})
|
|
4596
|
-
.parse({ tenantId, scopeIds, hours: c.req.query('hours') });
|
|
4614
|
+
.parse({ tenantId, scopeIds, hours: c.req.query('hours'), since: c.req.query('since'), until: c.req.query('until') });
|
|
4615
|
+
try {
|
|
4616
|
+
resolveObservabilityWindow(input);
|
|
4617
|
+
}
|
|
4618
|
+
catch (e) {
|
|
4619
|
+
throw new ControlPlaneError(400, e.message);
|
|
4620
|
+
}
|
|
4621
|
+
if (input.since !== undefined && !options.observability.absoluteTenantWindows) {
|
|
4622
|
+
throw new ControlPlaneError(501, 'absolute tenant telemetry windows are not supported by this backend');
|
|
4623
|
+
}
|
|
4597
4624
|
return c.json(await options.observability.tenantMetricsSeries(input));
|
|
4598
4625
|
});
|
|
4599
4626
|
app.get('/observability/tenant-logs', async (c) => {
|