@substrat-run/control-plane-api 0.197.1 → 0.199.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 +31 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +107 -4
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +3 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js.map +1 -1
- package/dist/connection-binding-relay.d.ts +18 -1
- package/dist/connection-binding-relay.d.ts.map +1 -1
- package/dist/connection-binding-relay.js +35 -1
- package/dist/connection-binding-relay.js.map +1 -1
- package/dist/deploy.d.ts +1 -1
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +1 -1
- package/dist/deploy.js.map +1 -1
- package/dist/github-app.d.ts +5 -1
- package/dist/github-app.d.ts.map +1 -1
- package/dist/github-app.js +6 -2
- package/dist/github-app.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/issuer-config.d.ts +16 -0
- package/dist/issuer-config.d.ts.map +1 -0
- package/dist/issuer-config.js +26 -0
- package/dist/issuer-config.js.map +1 -0
- package/dist/platform-drain.d.ts +6 -0
- package/dist/platform-drain.d.ts.map +1 -1
- package/dist/platform-drain.js +110 -11
- package/dist/platform-drain.js.map +1 -1
- package/dist/platform-entry.generated.d.ts +1 -1
- package/dist/platform-entry.generated.d.ts.map +1 -1
- package/dist/platform-entry.generated.js +2 -2
- package/dist/platform-entry.generated.js.map +1 -1
- package/dist/source-builds.d.ts.map +1 -1
- package/dist/source-builds.js +12 -1
- package/dist/source-builds.js.map +1 -1
- package/dist/tenant-token.d.ts +6 -0
- package/dist/tenant-token.d.ts.map +1 -1
- package/dist/tenant-token.js +6 -2
- package/dist/tenant-token.js.map +1 -1
- package/dist/vertical-client.d.ts +13 -0
- package/dist/vertical-client.d.ts.map +1 -1
- package/dist/vertical-client.js +7 -2
- package/dist/vertical-client.js.map +1 -1
- package/package.json +9 -9
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SourceBuildService } from '@substrat-run/contracts';
|
|
1
|
+
import { type SourceBuildService, type VerticalChange } from '@substrat-run/contracts';
|
|
2
2
|
import type { BuilderTurnsService } from './builder-turns.js';
|
|
3
3
|
import type { ConnectionScopeBinding, ConnectionScopeBindingInput } from '@substrat-run/control-plane-client';
|
|
4
4
|
import { Hono } from 'hono';
|
|
@@ -85,6 +85,10 @@ export interface ConnectionInspector {
|
|
|
85
85
|
*/
|
|
86
86
|
certificate?: (host: ScopeHost, connection: Connection) => Promise<ConnectionCertificate | null>;
|
|
87
87
|
}
|
|
88
|
+
/** One open pull request as `githubChanges` reads it; the route adds its preview. */
|
|
89
|
+
export type GithubChange = Omit<VerticalChange, 'preview'> & {
|
|
90
|
+
number: number;
|
|
91
|
+
};
|
|
88
92
|
export interface ControlPlaneApiOptions {
|
|
89
93
|
/** Monotonic clock for the bounded tenant usage composition (injectable in tests). */
|
|
90
94
|
meteredUsageNow?: () => number;
|
|
@@ -215,6 +219,24 @@ export interface ControlPlaneApiOptions {
|
|
|
215
219
|
remote: string;
|
|
216
220
|
token: string;
|
|
217
221
|
}>;
|
|
222
|
+
/**
|
|
223
|
+
* The open pull requests of one GitHub repository, newest first, each with its head's checks
|
|
224
|
+
* (`GET /verticals/:slug/changes`). Injected like `githubRepositoryAccess`, so this package
|
|
225
|
+
* makes no GitHub reads of its own; a read-only token, never returned. `unavailable` is a
|
|
226
|
+
* repository the installation cannot read, as the sentence the caller is shown; `reason`, a
|
|
227
|
+
* part it could not read (checks). Absent ⇒ the route answers no provider and says why.
|
|
228
|
+
*/
|
|
229
|
+
githubChanges?: (input: {
|
|
230
|
+
tenantId: string;
|
|
231
|
+
owner: string;
|
|
232
|
+
repo: string;
|
|
233
|
+
installationId: string;
|
|
234
|
+
}) => Promise<{
|
|
235
|
+
changes: GithubChange[];
|
|
236
|
+
reason?: string;
|
|
237
|
+
} | {
|
|
238
|
+
unavailable: string;
|
|
239
|
+
}>;
|
|
218
240
|
/**
|
|
219
241
|
* Uploads the store script for each declared scope store before the vertical's own
|
|
220
242
|
* upload (#2210). Absent ⇒ a push that declares a store and has a registered driver is
|
|
@@ -352,6 +374,14 @@ export interface ControlPlaneApiOptions {
|
|
|
352
374
|
* re-mints on its next request, so that is the revocation lever, not an outage.
|
|
353
375
|
*/
|
|
354
376
|
tenantTokenSecret?: string;
|
|
377
|
+
/**
|
|
378
|
+
* #3177: `POST /tenants/:t/scopes/:s/configure` refuses an issuer-only key
|
|
379
|
+
* (`issuer-config.ts`) from a tenant credential minted without `issuerConfig`. Off by
|
|
380
|
+
* default: a dashboard isolate holding a token minted before it asked for the claim would
|
|
381
|
+
* fail its deliveries until it recycled. Turn it on once a dashboard that mints with
|
|
382
|
+
* `issuerConfig: true` has been deployed.
|
|
383
|
+
*/
|
|
384
|
+
requireIssuerConfigClaim?: boolean;
|
|
355
385
|
/**
|
|
356
386
|
* Keys the pseudonymizer behind a masked export (#1034, `pseudonymize.ts`). The salt
|
|
357
387
|
* never reaches the dump and no mapping is stored, so it is not a decryption key —
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,kBAAkB,EAAoB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,kBAAkB,EAAoB,KAAK,cAAc,EAAwB,MAAM,yBAAyB,CAAC;AAC5K,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAE9G,OAAO,EAAE,I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Refusal, connectionBindingOptions, refusesBindingChange } from './connection-binding-options.js';
|
|
5
5
|
import { resolveObservabilityWindow } from './observability-window.js';
|
|
6
6
|
import { Hono } from 'hono';
|
|
7
|
-
import { permissionKey, parseHostname, withLabel, RESERVED_LABEL_SEPARATOR, adminAction, lakeEventsInput, ownerTransferInput, memberInviteInput, memberRoleInput, ASSET_PART_PREFIX, assetHash, STORE_DRIVERS, storeDriverErasesSubjects, storeDriverServesVertical, storeCatalogOperation, storeDriverBasisAdmits, channelName, connectLinkId, connectionActivity, connectionActivitySource, connectionCredential, connectionCertificate, 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, connectionSendTest, connectionSendTestResult, connectionSenders, createTenantInput, entitlementGrantInput, hostname as hostnameSchema, hostnameRegion, hostnameStatus, identityLink, errorCode, issueStatus, issueStatusInput, FINDINGS_LIMIT_DEFAULT, FINDINGS_LIMIT_MAX, findingCursorOf, findingKind, findingRuleInput, findingStatus, findingStatusInput, listPageQuery, matchesOutboundHost, pageOf, platformRequestFilter, principalId as principalIdSchema, impersonationStamp, promotionAcknowledgement, bindAcknowledgement, rebindAcknowledgement, provisionableJurisdiction, publishVersionInput, queryScopeInput, readScopeTableInput, entityHistoryInput, eventFacetInput, eventCauseInput, eventEffectsInput, invocationEventsInput, deadLettersInput, lifecycleFlowInput, operationSeriesCount, operationSeriesInput, delegatedReadParams, createOrgInput, roleKey as roleKeySchema, peerSwitch, verticalSlug, scopeText, systemSwitch, DEFAULT_DENIAL_LIMIT, DENIAL_LIMIT_MAX, denialGroupBy, registerVerticalInput, platformScriptCollision, platformScriptRefusal, PLATFORM_SCRIPT_NAMES, serviceDimensions, sweepRunKind, sweepRunOutcome, scopeDump, mergeDumpPages, dataSubjectId as dataSubjectIdSchema, scopeId as scopeIdSchema, scopeStatus, requestRollupReading, meterDaysReading, verticalOwnersReading, utcDay, storageShape, surfaceName, modelUsageLine, tenantId as tenantIdSchema, tenantStatus, versionOrigin, z, PROBLEM_CONTENT_TYPE, toProblem, validationIssuesFrom, redrainEventsInput, importCursorMove, importCursorAcknowledgementMissing, REDRAIN_BATCH, migrationsOnTop, substratError, errorCodeOf, envVarSpec, capabilityFilterQuery, capabilityId as capabilityIdSchema, PLATFORM_FEATURES_HEADER, PLATFORM_FEATURE_SCOPE_SWEEPER, PLATFORM_FEATURE_SOURCE_BUILDS, SOCIAL_RELAY_VERTICALS, isVerticalConnectorProvider, } from '@substrat-run/contracts';
|
|
7
|
+
import { permissionKey, parseHostname, withLabel, RESERVED_LABEL_SEPARATOR, adminAction, lakeEventsInput, ownerTransferInput, memberInviteInput, memberRoleInput, ASSET_PART_PREFIX, assetHash, STORE_DRIVERS, storeDriverErasesSubjects, storeDriverServesVertical, storeCatalogOperation, storeDriverBasisAdmits, channelName, connectLinkId, connectionActivity, connectionActivitySource, connectionCredential, connectionCertificate, 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, connectionSendTest, connectionSendTestResult, connectionSenders, createTenantInput, entitlementGrantInput, hostname as hostnameSchema, hostnameRegion, hostnameStatus, identityLink, errorCode, issueStatus, issueStatusInput, FINDINGS_LIMIT_DEFAULT, FINDINGS_LIMIT_MAX, findingCursorOf, findingKind, findingRuleInput, findingStatus, findingStatusInput, listPageQuery, matchesOutboundHost, pageOf, platformRequestFilter, principalId as principalIdSchema, impersonationStamp, promotionAcknowledgement, bindAcknowledgement, rebindAcknowledgement, provisionableJurisdiction, publishVersionInput, queryScopeInput, readScopeTableInput, entityHistoryInput, eventFacetInput, eventCauseInput, eventEffectsInput, invocationEventsInput, deadLettersInput, lifecycleFlowInput, operationSeriesCount, operationSeriesInput, delegatedReadParams, createOrgInput, roleKey as roleKeySchema, peerSwitch, verticalSlug, scopeText, systemSwitch, DEFAULT_DENIAL_LIMIT, DENIAL_LIMIT_MAX, denialGroupBy, registerVerticalInput, platformScriptCollision, platformScriptRefusal, PLATFORM_SCRIPT_NAMES, serviceDimensions, sweepRunKind, sweepRunOutcome, scopeDump, mergeDumpPages, dataSubjectId as dataSubjectIdSchema, scopeId as scopeIdSchema, scopeStatus, requestRollupReading, meterDaysReading, verticalOwnersReading, utcDay, storageShape, surfaceName, modelUsageLine, tenantId as tenantIdSchema, tenantStatus, versionOrigin, z, PROBLEM_CONTENT_TYPE, toProblem, validationIssuesFrom, redrainEventsInput, importCursorMove, importCursorAcknowledgementMissing, REDRAIN_BATCH, migrationsOnTop, substratError, errorCodeOf, envVarSpec, capabilityFilterQuery, capabilityId as capabilityIdSchema, PLATFORM_FEATURES_HEADER, PLATFORM_FEATURE_SCOPE_SWEEPER, PLATFORM_FEATURE_SOURCE_BUILDS, SOCIAL_RELAY_VERTICALS, isVerticalConnectorProvider, previewTag, buildPreviewTagPrefix, } from '@substrat-run/contracts';
|
|
8
8
|
import { upstreamHandleIn, upstreamReferenceOf, withUpstreamReference } from '@substrat-run/contracts';
|
|
9
9
|
import { ENGINE_ENTITLEMENT_KEYS, bareSlug, declarableEntitlementKey, entitlementNamespaceRefusal, grantableEntitlements } from '@substrat-run/contracts';
|
|
10
10
|
import { SCOPE_COPY_LEASE_MS, copyRestoreFence, publishedMigrationDigest, replayStoreErasures, storesFencedRefusal } from '@substrat-run/kernel';
|
|
@@ -13,6 +13,7 @@ import { auditedChange, withAuditedOutcomes } from './audited-change.js';
|
|
|
13
13
|
import { BIND_EXPORT_BREAK_REFUSAL, CARRIED_AWAY_KEY, bindExportBreakRefusal, carriedAwayDump, dumpMetaValue, metaValueIn, crossVerticalHealth, exportBreakRefusal, isBindExportBreakRefusal, isExportBreakRefusal, listedPromoteRefusal, isExportBreakUnjudged, isPrimaryScope, promoteReviewDigest, rebindReviewDigest, assertRebindReviewCurrent, migrationProgress, ulid, auditWarningOf, REQUEST_ROLLUP_LIMIT_DEFAULT, REQUEST_ROLLUP_LIMIT_MAX, STORAGE_HISTORY_LIMIT_MAX, STORAGE_GAUGE_RETENTION_MONTHS, BUILD_USAGE_RETENTION_DAYS, MODEL_USAGE_RETENTION_DAYS, BILLING_ROLLUP_RETENTION_MONTHS, METER_DAYS_LIMIT_DEFAULT, METER_DAYS_LIMIT_MAX, releaseRolesAskScopes, releaseRoleSetRefusal, withheldOpsFailure, } from '@substrat-run/kernel';
|
|
14
14
|
import { TENANT_HEADER, confinedTenant } from './auth.js';
|
|
15
15
|
import { mintTenantToken } from './tenant-token.js';
|
|
16
|
+
import { issuerOnlyConfigKeyOf } from './issuer-config.js';
|
|
16
17
|
import { abandonCopy, beginTransfer, connectionGrantsForScope, transferScope, isScopeNotHeld, notHeldIsBenign } from './vertical-client.js';
|
|
17
18
|
import { COPY_JOB_MAX_MS, copyJobAt, copyJobHeld, copyJobId, copyJobLive, copyTagId, versionIdOfOrder, versionOrderOf, } from './copy-job.js';
|
|
18
19
|
import { exportStoreDumps, runningVersionOf, runningVersionStoresOf, scopeStoreReachOf, scopeStoresOf, unrouteScope } from './platform-scope-stores.js';
|
|
@@ -32,7 +33,7 @@ import { NON_PROBLEM_REFUSAL, coded, mapError, relayed } from './errors.js';
|
|
|
32
33
|
import { maskDump, maskRecords } from './mask.js';
|
|
33
34
|
import { createPseudonymizer } from './pseudonymize.js';
|
|
34
35
|
import { openDump, sealDump } from './seal.js';
|
|
35
|
-
import { assertSandboxContract, verticalUploadBindings, migrationsDigestBindings, deployManifest, storedDeployManifest, pushedOwnerGrantProblems, pushedConnectorProblems, pushedModuleRegistryProblems, pushedLandingProblems, pushedPermissionRegistry, deploymentRefFor, stableDeploymentRefFor, nextMigrationTag, upstreamStatusOf, } from './deploy.js';
|
|
36
|
+
import { assertSandboxContract, verticalUploadBindings, migrationsDigestBindings, deployManifest, storedDeployManifest, pushedOwnerGrantProblems, pushedConnectorProblems, pushedModuleRegistryProblems, pushedLandingProblems, pushedDelegationProblems, pushedPermissionRegistry, delegationsOf, deploymentRefFor, stableDeploymentRefFor, nextMigrationTag, upstreamStatusOf, } from './deploy.js';
|
|
36
37
|
/**
|
|
37
38
|
* Answer with a problem document (#113 phase 4).
|
|
38
39
|
*
|
|
@@ -907,6 +908,8 @@ const TENANT_ROUTES = [
|
|
|
907
908
|
{ method: 'POST', re: /\/verticals\/[^/]+\/channels\/[^/]+\/promote$/, pin: 'owner' },
|
|
908
909
|
{ method: 'GET', re: /\/verticals\/[^/]+\/channels\/[^/]+\/promote-impact$/, pin: 'owner' },
|
|
909
910
|
{ method: 'GET', re: /\/verticals\/[^/]+\/previews$/, pin: 'owner' },
|
|
911
|
+
// The open pull requests or hosted chat branches of a vertical the tenant owns, with checks and previews.
|
|
912
|
+
{ method: 'GET', re: /\/verticals\/[^/]+\/changes$/, pin: 'owner' },
|
|
910
913
|
{ method: 'POST', re: /\/verticals\/[^/]+\/previews$/, pin: 'owner' },
|
|
911
914
|
// #3108: whether a fork would be admitted, and why not — read before offering one.
|
|
912
915
|
{ method: 'GET', re: /\/verticals\/[^/]+\/previews\/fork-check$/, pin: 'owner' },
|
|
@@ -1292,6 +1295,7 @@ export function createControlPlaneApi(options) {
|
|
|
1292
1295
|
actor: tenant.actor,
|
|
1293
1296
|
tenantId: tenant.tenantId,
|
|
1294
1297
|
...(tenant.onBehalfOf ? { onBehalfOf: tenant.onBehalfOf } : {}),
|
|
1298
|
+
...(tenant.issuerConfig ? { issuerConfig: true } : {}),
|
|
1295
1299
|
};
|
|
1296
1300
|
}
|
|
1297
1301
|
}
|
|
@@ -1369,6 +1373,10 @@ export function createControlPlaneApi(options) {
|
|
|
1369
1373
|
{ method: 'GET', re: /\/verticals\/[^/]+\/channels$/ },
|
|
1370
1374
|
{ method: 'GET', re: /\/verticals\/[^/]+\/channels\/[^/]+\/history$/ },
|
|
1371
1375
|
{ method: 'POST', re: /\/verticals\/[^/]+\/channels\/[^/]+\/promote$/ },
|
|
1376
|
+
// Whom a promote would break, read before promoting (#1705 PR 3) — the listing the promote's own
|
|
1377
|
+
// 409 already hands a builder, so `substrat promote --review-only` shows the whole review
|
|
1378
|
+
// without promoting. Owner-checked and narrowed to the caller in the handler.
|
|
1379
|
+
{ method: 'GET', re: /\/verticals\/[^/]+\/channels\/[^/]+\/promote-impact$/ },
|
|
1372
1380
|
{ method: 'GET', re: /\/projects$/ },
|
|
1373
1381
|
{ method: 'POST', re: /\/projects$/ },
|
|
1374
1382
|
{ method: 'POST', re: /\/verticals\/[^/]+\/deploy$/ },
|
|
@@ -1408,6 +1416,9 @@ export function createControlPlaneApi(options) {
|
|
|
1408
1416
|
{ method: 'POST', re: /\/verticals\/[^/]+\/previews$/ },
|
|
1409
1417
|
{ method: 'GET', re: /\/verticals\/[^/]+\/previews$/ },
|
|
1410
1418
|
{ method: 'DELETE', re: /\/verticals\/[^/]+\/previews\/[^/]+$/ },
|
|
1419
|
+
// The open changes of the builder's OWN vertical (`substrat changes`): its pull requests or
|
|
1420
|
+
// hosted chat branches, checks and previews. Owner-checked in the handler like the previews.
|
|
1421
|
+
{ method: 'GET', re: /\/verticals\/[^/]+\/changes$/ },
|
|
1411
1422
|
// The builder's slice of the ops-failure record (#559 step 5): why did MY deploy /
|
|
1412
1423
|
// preview / provision fail. Tenant-narrowed in the handler (the forced-filter
|
|
1413
1424
|
// pattern, like GET /scopes); the allowlist alone is not authz.
|
|
@@ -5186,6 +5197,14 @@ export function createControlPlaneApi(options) {
|
|
|
5186
5197
|
const tenantId = tenantIdSchema.parse(c.req.param('tenantId'));
|
|
5187
5198
|
const scopeId = scopeIdSchema.parse(c.req.param('scopeId'));
|
|
5188
5199
|
const input = configureInstanceBody.parse(await c.req.json());
|
|
5200
|
+
// #3177: an issuer applies what it is handed, so a key only the platform writes needs a
|
|
5201
|
+
// credential minted to write it. The refusal names the prefix, never the value.
|
|
5202
|
+
const p = c.get('principal');
|
|
5203
|
+
if (options.requireIssuerConfigClaim && p.kind === 'tenant' && !p.issuerConfig) {
|
|
5204
|
+
const held = input.entries.map((e) => issuerOnlyConfigKeyOf(e.key)).find((k) => k !== undefined);
|
|
5205
|
+
if (held)
|
|
5206
|
+
return refuse(c, 'forbidden', `forbidden: '${held}' is issuer-only config, and this credential may not deliver it`);
|
|
5207
|
+
}
|
|
5189
5208
|
const scope = await c.var.admin.getScopeRecord(c.get('actor'), tenantId, scopeId);
|
|
5190
5209
|
if (!scope)
|
|
5191
5210
|
return refuse(c, 'not_found', `unknown scope for tenant: (${tenantId}, ${scopeId})`);
|
|
@@ -7799,6 +7818,10 @@ export function createControlPlaneApi(options) {
|
|
|
7799
7818
|
const landingProblems = pushedLandingProblems(checked.data.modules, registry.data);
|
|
7800
7819
|
if (landingProblems.length > 0)
|
|
7801
7820
|
return refuseManifest({ path: ['registry', 'connections'], message: landingProblems.join('; ') });
|
|
7821
|
+
// #3161: the digest-covered copy of the delegations says what the modules declare.
|
|
7822
|
+
const delegationProblems = pushedDelegationProblems(checked.data.modules, registry.data);
|
|
7823
|
+
if (delegationProblems.length > 0)
|
|
7824
|
+
return refuseManifest({ path: ['registry', 'delegations'], message: delegationProblems.join('; ') });
|
|
7802
7825
|
}
|
|
7803
7826
|
// #2430: an owner grant is a person's, so it holds no key the registry reserves.
|
|
7804
7827
|
const ownerGrants = pushedOwnerGrantProblems(checked.data);
|
|
@@ -7917,6 +7940,7 @@ export function createControlPlaneApi(options) {
|
|
|
7917
7940
|
}
|
|
7918
7941
|
const json = await c.var.admin.versionManifest(c.get('actor'), slug, c.req.param('id'));
|
|
7919
7942
|
const parsed = json ? storedDeployManifest.parse(JSON.parse(json)) : null;
|
|
7943
|
+
const delegations = parsed ? delegationsOf(parsed) : null;
|
|
7920
7944
|
return c.json({
|
|
7921
7945
|
declaredEvents: parsed?.declaredEvents ?? null,
|
|
7922
7946
|
// Whether that surface is the whole declaration or a sample cut at the cap. The
|
|
@@ -7935,6 +7959,10 @@ export function createControlPlaneApi(options) {
|
|
|
7935
7959
|
// pushed before the declaration existed is unenforced, which a reader must be able
|
|
7936
7960
|
// to tell from a version that declares it calls nothing.
|
|
7937
7961
|
calls: parsed?.calls ?? null,
|
|
7962
|
+
// #3161: which apps may act for a person in this version, off its registry. Left out when the
|
|
7963
|
+
// version cannot say (`delegationsOf`: pushed before the field), which a reader keeps apart
|
|
7964
|
+
// from `[]`: it revokes on `[]` and must never revoke on a version that did not say.
|
|
7965
|
+
...(delegations === null ? {} : { delegations }),
|
|
7938
7966
|
});
|
|
7939
7967
|
});
|
|
7940
7968
|
// Published documentation only, never source files. Same owner/listed visibility as model.
|
|
@@ -8936,6 +8964,9 @@ export function createControlPlaneApi(options) {
|
|
|
8936
8964
|
const landingProblems = pushedLandingProblems(manifest.modules, manifest.registry);
|
|
8937
8965
|
if (landingProblems.length > 0)
|
|
8938
8966
|
return refuse(c, 'validation_failed', `manifest registry.connections: ${landingProblems.join('; ')}`);
|
|
8967
|
+
const delegationProblems = pushedDelegationProblems(manifest.modules, manifest.registry);
|
|
8968
|
+
if (delegationProblems.length > 0)
|
|
8969
|
+
return refuse(c, 'validation_failed', `manifest registry.delegations: ${delegationProblems.join('; ')}`);
|
|
8939
8970
|
// #2430: an owner grant is a person's, so it holds no key the registry reserves.
|
|
8940
8971
|
const ownerGrants = pushedOwnerGrantProblems(manifest);
|
|
8941
8972
|
if (ownerGrants.length > 0)
|
|
@@ -9855,7 +9886,7 @@ export function createControlPlaneApi(options) {
|
|
|
9855
9886
|
if (!options.tenantTokenSecret) {
|
|
9856
9887
|
return refuseStatus(c, 501, 'tenant tokens are not configured on this control plane');
|
|
9857
9888
|
}
|
|
9858
|
-
const { tenantId, principal, impersonation } = z
|
|
9889
|
+
const { tenantId, principal, impersonation, issuerConfig } = z
|
|
9859
9890
|
.object({
|
|
9860
9891
|
tenantId: tenantIdSchema,
|
|
9861
9892
|
// #977: the signed-in person the token will act for — attribution on every admin
|
|
@@ -9863,6 +9894,8 @@ export function createControlPlaneApi(options) {
|
|
|
9863
9894
|
principal: principalIdSchema.optional(),
|
|
9864
9895
|
// K-42: the staff member acting as `principal`. Meaningless without the person.
|
|
9865
9896
|
impersonation: impersonationStamp.optional(),
|
|
9897
|
+
// #3177: may deliver the issuer-only config keys. Only the dashboard asks for it.
|
|
9898
|
+
issuerConfig: z.boolean().optional(),
|
|
9866
9899
|
})
|
|
9867
9900
|
.refine((b) => !b.impersonation || b.principal, { message: 'impersonation names no principal' })
|
|
9868
9901
|
.parse(await c.req.json());
|
|
@@ -9870,7 +9903,7 @@ export function createControlPlaneApi(options) {
|
|
|
9870
9903
|
// for a tenant with no directory row reaches nothing except creating that row
|
|
9871
9904
|
// (`POST /tenants`, body-pinned to the same id), which is the sign-up bootstrap.
|
|
9872
9905
|
// See the mint's docblock in tenant-token.ts.
|
|
9873
|
-
const token = await mintTenantToken(options.tenantTokenSecret, { tenantId, principal, impersonation });
|
|
9906
|
+
const token = await mintTenantToken(options.tenantTokenSecret, { tenantId, principal, impersonation, issuerConfig });
|
|
9874
9907
|
return c.json({ token }, 201);
|
|
9875
9908
|
});
|
|
9876
9909
|
// -- the hostname map (§4.7, K-26) -----------------------------------------
|
|
@@ -11263,6 +11296,76 @@ export function createControlPlaneApi(options) {
|
|
|
11263
11296
|
}
|
|
11264
11297
|
return c.json(out);
|
|
11265
11298
|
});
|
|
11299
|
+
// The open changes of one vertical the caller owns, whichever provider holds them: a GitHub
|
|
11300
|
+
// repository's open pull requests, or a hosted repository's `builder/<id>` chat branches, each
|
|
11301
|
+
// with its checks and its preview. The repository is the studio's project for the slug, else
|
|
11302
|
+
// the GitHub repository the newest CI push came from. A repository that cannot be read is an
|
|
11303
|
+
// answer, not a failure: `provider: null` and the reason, never a 5xx for "not connected".
|
|
11304
|
+
app.get('/verticals/:slug/changes', async (c) => {
|
|
11305
|
+
const gate = await previewVertical(c);
|
|
11306
|
+
if ('error' in gate)
|
|
11307
|
+
return refuse(c, gate.refused, gate.error);
|
|
11308
|
+
const { tenantId, slug } = gate;
|
|
11309
|
+
const actor = c.get('actor');
|
|
11310
|
+
const none = (reason, repository = null) => c.json({ provider: null, repository, changes: [], reason });
|
|
11311
|
+
try {
|
|
11312
|
+
const hosted = options.sourceBuilds ? await options.sourceBuilds.changes(tenantId, slug) : null;
|
|
11313
|
+
const project = hosted?.repository ?? null;
|
|
11314
|
+
if (hosted && project?.kind === 'artifacts') {
|
|
11315
|
+
// A hosted chat runs no checks and has no preview of its own (studio-preview.ts).
|
|
11316
|
+
const changes = hosted.changes.map((ch) => ({
|
|
11317
|
+
...ch, url: null, author: null, checks: { state: 'none', failing: [] }, preview: null,
|
|
11318
|
+
}));
|
|
11319
|
+
return c.json({ provider: 'artifacts', repository: project.name, changes });
|
|
11320
|
+
}
|
|
11321
|
+
let github = project?.kind === 'github' ? { owner: project.owner, repo: project.repo } : null;
|
|
11322
|
+
if (!github) {
|
|
11323
|
+
const pushed = (await c.var.admin.listVersions(actor, slug, { limit: 20, order: 'desc' }))
|
|
11324
|
+
.map((v) => v.origin?.gitRepo)
|
|
11325
|
+
.find((r) => r !== undefined && /^[\w-]+\/[\w.-]+$/.test(r));
|
|
11326
|
+
const [owner, repo] = pushed?.split('/') ?? [];
|
|
11327
|
+
if (owner && repo)
|
|
11328
|
+
github = { owner, repo };
|
|
11329
|
+
}
|
|
11330
|
+
if (!github) {
|
|
11331
|
+
return none(`no repository is known for '${slug}': it is no studio project, and none of its recent versions was pushed from GitHub Actions`);
|
|
11332
|
+
}
|
|
11333
|
+
const repository = `${github.owner}/${github.repo}`;
|
|
11334
|
+
if (!options.githubChanges)
|
|
11335
|
+
return none('this control plane does not read GitHub repositories', repository);
|
|
11336
|
+
const connection = await c.var.admin.openConnection(tenantId, 'dashboard', 'github', github.owner);
|
|
11337
|
+
const installationId = connection?.secret.installationId;
|
|
11338
|
+
if (typeof installationId !== 'string') {
|
|
11339
|
+
return none(`this team has no GitHub connection for '${github.owner}': connect it in the dashboard to read ${repository}`, repository);
|
|
11340
|
+
}
|
|
11341
|
+
const read = await options.githubChanges({ tenantId, ...github, installationId });
|
|
11342
|
+
if ('unavailable' in read)
|
|
11343
|
+
return none(read.unavailable, repository);
|
|
11344
|
+
// A PR's preview: its sticky tag, else its newest per-build one (`ci.ts`). Newest by id: a
|
|
11345
|
+
// scope id is a ULID, minted when the scope is, so it orders clean-room previews (which
|
|
11346
|
+
// carry no `forkedAt`) as well as forks.
|
|
11347
|
+
const previews = (await c.var.admin.listScopes(actor, { tenantId, vertical: slug }))
|
|
11348
|
+
.filter((s) => s.kind === 'preview')
|
|
11349
|
+
.sort((a, b) => (a.id < b.id ? 1 : a.id > b.id ? -1 : 0))
|
|
11350
|
+
.map((s) => ({ id: s.id, tag: s.slug?.split('--').at(-1) ?? '' }));
|
|
11351
|
+
const previewOf = async (n) => {
|
|
11352
|
+
const hit = previews.find((p) => p.tag === previewTag(n)) ?? previews.find((p) => p.tag.startsWith(buildPreviewTagPrefix(n)));
|
|
11353
|
+
if (!hit)
|
|
11354
|
+
return null;
|
|
11355
|
+
const hostname = (await c.var.admin.listHostnames(actor, { scopeId: hit.id }))[0]?.hostname;
|
|
11356
|
+
return { tag: hit.tag, url: hostname ? `https://${hostname}` : null };
|
|
11357
|
+
};
|
|
11358
|
+
const changes = [];
|
|
11359
|
+
for (const { number, ...change } of read.changes)
|
|
11360
|
+
changes.push({ ...change, preview: await previewOf(number) });
|
|
11361
|
+
return c.json({ provider: 'github', repository, changes, ...(read.reason ? { reason: read.reason } : {}) });
|
|
11362
|
+
}
|
|
11363
|
+
catch (e) {
|
|
11364
|
+
if (e instanceof ControlPlaneError)
|
|
11365
|
+
return relayRefusal(c, e);
|
|
11366
|
+
throw e;
|
|
11367
|
+
}
|
|
11368
|
+
});
|
|
11266
11369
|
app.delete('/verticals/:slug/previews/:tag', async (c) => {
|
|
11267
11370
|
const gate = await previewVertical(c);
|
|
11268
11371
|
if ('error' in gate)
|