@ductape/sdk 0.2.7 → 0.2.8

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/index.d.ts CHANGED
@@ -4383,7 +4383,7 @@ export default class Ductape implements IDuctape {
4383
4383
  refreshedAt?: number;
4384
4384
  error?: string;
4385
4385
  };
4386
- connections: "degraded" | "ready" | "warming";
4386
+ connections: "ready" | "warming" | "degraded";
4387
4387
  };
4388
4388
  warmup: {
4389
4389
  databases: {
@@ -4465,6 +4465,7 @@ export default class Ductape implements IDuctape {
4465
4465
  private createNewJobsService;
4466
4466
  private createNewSecretsService;
4467
4467
  private applyRuntimeCredentialBundle;
4468
+ private prepareRuntimeCredentials;
4468
4469
  private createNewCloudService;
4469
4470
  /**
4470
4471
  * Create a new SessionsService instance with authenticated config
package/dist/index.js CHANGED
@@ -5806,7 +5806,12 @@ class Ductape {
5806
5806
  const scope = `${this.workspace_id}:${response.snapshot.product_tag}:${response.snapshot.env_slug}`;
5807
5807
  (0, bootstrap_cache_1.primeRuntimeBootstrapCache)(this.workspace_id, scope, response.snapshot.entries);
5808
5808
  this.runtimeManifest = response.manifest;
5809
- this.runtimeCredentialBundle = (_a = response.snapshot.credentials) !== null && _a !== void 0 ? _a : { referenced_keys: [], encrypted_secrets: [] };
5809
+ const derivedReferences = (0, secrets_1.findAllSecretReferences)(response.snapshot.entries.map((entry) => entry.data)).sort();
5810
+ this.runtimeCredentialBundle = response.snapshot.credentials
5811
+ ? Object.assign(Object.assign({}, response.snapshot.credentials), { referenced_keys: [...new Set([
5812
+ ...((_a = response.snapshot.credentials.referenced_keys) !== null && _a !== void 0 ? _a : []),
5813
+ ...derivedReferences,
5814
+ ])].sort() }) : { referenced_keys: derivedReferences, encrypted_secrets: [] };
5810
5815
  const referenced = (_c = (_b = this.runtimeCredentialBundle.referenced_keys) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : this.runtimeCredentialBundle.encrypted_secrets.length;
5811
5816
  const cached = this.runtimeCredentialBundle.encrypted_secrets.length;
5812
5817
  this.runtimeCredentialState = {
@@ -5951,7 +5956,7 @@ class Ductape {
5951
5956
  if (response) {
5952
5957
  this.applyRuntimeSnapshot(response);
5953
5958
  const secrets = await this.createNewSecretsService();
5954
- this.applyRuntimeCredentialBundle(secrets);
5959
+ await this.prepareRuntimeCredentials(secrets);
5955
5960
  }
5956
5961
  this.scheduleRuntimePoll(0);
5957
5962
  })().finally(() => { this.runtimeRefreshInFlight = undefined; });
@@ -6299,6 +6304,27 @@ class Ductape {
6299
6304
  throw error;
6300
6305
  }
6301
6306
  }
6307
+ async prepareRuntimeCredentials(service) {
6308
+ var _a, _b;
6309
+ this.applyRuntimeCredentialBundle(service);
6310
+ if (!this.runtimeCredentialBundle)
6311
+ return;
6312
+ const bundled = new Set(this.runtimeCredentialBundle.encrypted_secrets.map((secret) => secret.key));
6313
+ const missingKeys = ((_a = this.runtimeCredentialBundle.referenced_keys) !== null && _a !== void 0 ? _a : []).filter((key) => !bundled.has(key));
6314
+ if (!missingKeys.length)
6315
+ return;
6316
+ this.runtimeCredentialState = Object.assign(Object.assign({}, this.runtimeCredentialState), { status: 'loading', missing: missingKeys.length });
6317
+ const results = await Promise.allSettled(missingKeys.map((key) => service.fetch(key)));
6318
+ const failed = results.filter((result) => result.status === 'rejected').length;
6319
+ const cached = bundled.size + results.length - failed;
6320
+ this.runtimeCredentialState = {
6321
+ status: failed ? 'incomplete' : 'ready',
6322
+ referenced: ((_b = this.runtimeCredentialBundle.referenced_keys) !== null && _b !== void 0 ? _b : []).length,
6323
+ cached,
6324
+ missing: failed,
6325
+ refreshedAt: Date.now(),
6326
+ };
6327
+ }
6302
6328
  async createNewCloudService() {
6303
6329
  const subCheck = false;
6304
6330
  if (!this.token || !this.public_key) {