@substrat-run/control-plane-api 0.55.0 → 0.56.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 CHANGED
@@ -3,7 +3,7 @@ import type { PlatformActorId } from '@substrat-run/contracts';
3
3
  import type { ScopeHost } from '@substrat-run/kernel';
4
4
  import type { PlatformActorAuth, BuilderAuth, Principal } from './auth.js';
5
5
  import type { VerticalClient } from './vertical-client.js';
6
- import type { DeployVerticalFn, FetchVerticalModulesFn } from './deploy.js';
6
+ import type { DeployVerticalFn, FetchVerticalAssetFn, FetchVerticalModulesFn } from './deploy.js';
7
7
  import type { PatchScriptBindingsFn } from './wfp.js';
8
8
  import type { ObservabilityReader } from './observability.js';
9
9
  import type { PlatformRuntime } from './platform-runtime.js';
@@ -63,6 +63,15 @@ export interface ControlPlaneApiOptions {
63
63
  * place (the pre-#286 behavior: scopes stay on per-version dispatch).
64
64
  */
65
65
  fetchVerticalModules?: FetchVerticalModulesFn;
66
+ /**
67
+ * Reads one static file back from a script's runtime-served assets (#578) — how a
68
+ * serving upload recovers asset bytes the stable script's upload session reports
69
+ * missing (the asset store dedups per script, so the push's upload to the archive
70
+ * script does not cover a re-serve). Host-injected like `fetchVerticalModules`.
71
+ * Absent ⇒ a re-serve of an asset-carrying version refuses when the runtime wants
72
+ * bytes (the pre-#578 behavior).
73
+ */
74
+ fetchVerticalAsset?: FetchVerticalAssetFn;
66
75
  /**
67
76
  * Ensures per-tenant store D1 bindings exist on a dispatch script without a redeploy
68
77
  * (#301) — the attach step that makes a freshly-minted tenant store reachable in the
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,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAgC5B,OAAO,KAAK,EAGV,eAAe,EAMhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAA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B,CAAC;IAClC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,sBAAsB,CAAC;IAC9C;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,oBAAoB,CAAC;IAC1C;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,qBAAqB,CAAC;IAC5C;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C;;;;OAIG;IACH,YAAY,EAAE,iBAAiB,CAAC;IAChC;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,yBAAyB,CAAC;IAC9C;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC;AAKD,KAAK,IAAI,GAAG;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AA2P7D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,CA+uGhG"}
package/dist/api.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { adminAction, ASSET_PART_PREFIX, assetHash, channelName, createTenantInput, entitlementGrantInput, hostname as hostnameSchema, hostnameRegion, hostnameStatus, identityLink, listPageQuery, pageOf, principalId as principalIdSchema, promotionAcknowledgement, provisionableJurisdiction, publishVersionInput, queryScopeInput, readScopeTableInput, registerVerticalInput, scopeDump, dataSubjectId as dataSubjectIdSchema, scopeId as scopeIdSchema, scopeStatus, storageShape, surfaceName, tenantId as tenantIdSchema, tenantStatus, z, } from '@substrat-run/contracts';
2
+ import { adminAction, ASSET_PART_PREFIX, assetHash, channelName, createTenantInput, entitlementGrantInput, hostname as hostnameSchema, hostnameRegion, hostnameStatus, identityLink, listPageQuery, pageOf, principalId as principalIdSchema, promotionAcknowledgement, provisionableJurisdiction, publishVersionInput, queryScopeInput, readScopeTableInput, registerVerticalInput, scopeDump, dataSubjectId as dataSubjectIdSchema, scopeId as scopeIdSchema, scopeStatus, storageShape, surfaceName, tenantId as tenantIdSchema, tenantStatus, versionOrigin, z, } from '@substrat-run/contracts';
3
3
  import { migrationProgress, ulid } from '@substrat-run/kernel';
4
4
  import { TENANT_HEADER } from './auth.js';
5
5
  import { ControlPlaneError } from './client.js';
@@ -2236,12 +2236,26 @@ export function createControlPlaneApi(options) {
2236
2236
  doClasses: manifest.doClasses,
2237
2237
  bindings: [...manifest.bindings, ...storeBindings],
2238
2238
  // #340: the version's static files travel with it onto the serving script — from
2239
- // the RETAINED manifest, with no bytes. An asset upload session is driven by
2240
- // content addresses, and the runtime's asset store is namespace-wide and deduped,
2241
- // so re-declaring the same hashes re-attaches the same files. This is why the
2242
- // manifest is retained rather than the bytes: the archive script gives back the
2243
- // modules (#286), and the asset store gives back the assets.
2244
- ...(manifest.assets ? { assets: manifest.assets } : {}),
2239
+ // the RETAINED manifest, with no bytes up front. The asset store dedups PER
2240
+ // SCRIPT (#578), so hashes the push uploaded to the archive script are still
2241
+ // missing for the stable script each file therefore carries a `fetchContent`
2242
+ // that reads the bytes back from the archive script's runtime-served assets,
2243
+ // invoked (and hash-verified) only for hashes the upload session reports
2244
+ // missing. The archive script gives back the modules (#286) AND the assets:
2245
+ // nothing but the manifest is retained.
2246
+ ...(manifest.assets
2247
+ ? {
2248
+ assets: {
2249
+ ...manifest.assets,
2250
+ files: manifest.assets.files.map((f) => ({
2251
+ ...f,
2252
+ ...(options.fetchVerticalAsset
2253
+ ? { fetchContent: () => options.fetchVerticalAsset(version.deploymentRef, f.path) }
2254
+ : {}),
2255
+ })),
2256
+ },
2257
+ }
2258
+ : {}),
2245
2259
  }, serving
2246
2260
  ? { priorDoClasses: serving.doClasses, priorMigrationTag: serving.migrationTag }
2247
2261
  : undefined);
@@ -2350,6 +2364,21 @@ export function createControlPlaneApi(options) {
2350
2364
  // silently dropped. An old CLI that sends no pin keeps today's behavior on all paths.
2351
2365
  const pinField = form.get('tenant');
2352
2366
  const pin = typeof pinField === 'string' && pinField.length > 0 ? pinField : null;
2367
+ // The push's self-reported provenance (git CI vs a terminal) — a label the dashboard
2368
+ // shows, never authority, so a missing or malformed field must not fail the push
2369
+ // (an old CLI sends none). Lenient by construction: safeParse, drop on mismatch.
2370
+ const originField = form.get('origin');
2371
+ const origin = (() => {
2372
+ if (typeof originField !== 'string')
2373
+ return undefined;
2374
+ try {
2375
+ const parsed = versionOrigin.safeParse(JSON.parse(originField));
2376
+ return parsed.success ? parsed.data : undefined;
2377
+ }
2378
+ catch {
2379
+ return undefined;
2380
+ }
2381
+ })();
2353
2382
  // Resolve the registry id + owner this push acts on. Checked BEFORE the upload so a
2354
2383
  // refused push never leaves an orphaned namespace script.
2355
2384
  const bare = c.req.param('slug');
@@ -2586,6 +2615,7 @@ export function createControlPlaneApi(options) {
2586
2615
  permissionDigest: manifest.digests.permission,
2587
2616
  migrationDigest: manifest.digests.migration,
2588
2617
  deploymentRef,
2618
+ ...(origin ? { origin } : {}),
2589
2619
  // Retained for the serving upload (#286): the archive script keeps the module
2590
2620
  // bytes, this keeps their shape (entry, compat, doClasses, bindings).
2591
2621
  manifestJson: JSON.stringify(manifest),