@bakers-build/addon-remote-drupal 0.5.1-next.850 → 0.5.1-next.851

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.
@@ -1,6 +1,6 @@
1
1
  import type { ActiveRun, AddonDefinitionV2, AddonRegistration, BbRemote, ClaimedRun, ClaimOptions, ClaimWithheld, ConductorRegistration, ConductorStatus, FinalizableRun, FrozenTicket, InboxSnapshot, RemotePlugin, RunMetrics, RunWriteAttributes, Ticket, TicketMetric, UncleanTicket } from '@bakers-build/conductor/contract';
2
2
  import type { MessageResult } from '@bakers-build/message';
3
- export { AmbiguousProjectNameError } from '@bakers-build/conductor/contract';
3
+ export { AmbiguousProjectNameError, ConductorTakeoverRequired, } from '@bakers-build/conductor/contract';
4
4
  export { createRunLogHttp, RunLogSizeError } from './run-log-http.js';
5
5
  import type { BbProjectSelection } from '@bakers-build/conductor/project-context';
6
6
  import { type AuthAdapter, type HttpClient, type JsonApiClient } from 'dropsh/plugin';
package/dist/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createBbConnectionContext, toUnixSeconds } from '@bakers-build/core';
2
- import { AmbiguousProjectNameError, resolveBbProjectContext, } from '@bakers-build/conductor/contract';
3
- export { AmbiguousProjectNameError } from '@bakers-build/conductor/contract';
2
+ import { AmbiguousProjectNameError, ConductorTakeoverRequired, resolveBbProjectContext, } from '@bakers-build/conductor/contract';
3
+ export { AmbiguousProjectNameError, ConductorTakeoverRequired, } from '@bakers-build/conductor/contract';
4
4
  export { createRunLogHttp, RunLogSizeError } from './run-log-http.js';
5
5
  import { HttpError, } from 'dropsh/plugin';
6
6
  import { createRunLogHttp, RunLogSizeError } from './run-log-http.js';
@@ -277,7 +277,10 @@ export class DrupalBbRemote {
277
277
  data: {
278
278
  attributes: {
279
279
  conductor_id: reg.id,
280
- host_key: reg.host_key ?? reg.id,
280
+ host_key: reg.host_key,
281
+ ...(reg.machine_label ? { machine_label: reg.machine_label } : {}),
282
+ ...(reg.adopt ? { adopt: reg.adopt } : {}),
283
+ ...(reg.create_new ? { create_new: true } : {}),
281
284
  project: reg.project,
282
285
  states: reg.states,
283
286
  workspace_root: reg.workspace,
@@ -295,7 +298,20 @@ export class DrupalBbRemote {
295
298
  }));
296
299
  }
297
300
  async registerConductor(reg) {
298
- const res = await this.postHeartbeatRegistration(reg);
301
+ let res;
302
+ try {
303
+ res = await this.postHeartbeatRegistration(reg);
304
+ }
305
+ catch (err) {
306
+ if (!(err instanceof HttpError) || err.status !== 409)
307
+ throw err;
308
+ const error = err.body?.errors?.[0];
309
+ const candidates = error?.meta?.candidates;
310
+ // Any other 409 (concurrent registration, foreign id) is no offer.
311
+ if (!Array.isArray(candidates))
312
+ throw err;
313
+ throw new ConductorTakeoverRequired(typeof error?.detail === 'string' ? error.detail : err.message, candidates.flatMap((c) => (typeof c.uuid === 'string' ? [c.uuid] : [])));
314
+ }
299
315
  const id = res?.data?.id;
300
316
  if (typeof id !== 'string' || id === '') {
301
317
  throw new Error('registerConductor: heartbeat response omitted data.id');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/addon-remote-drupal",
3
- "version": "0.5.1-next.850",
3
+ "version": "0.5.1-next.851",
4
4
  "description": "bakers.build conductor remote addon: the Drupal/JSON:API control-plane remote.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,12 +23,12 @@
23
23
  "dropsh": "^0.8.2"
24
24
  },
25
25
  "peerDependencies": {
26
- "@bakers-build/conductor": "^0.5.1-next.850",
27
- "@bakers-build/core": "^0.5.1-next.850",
28
- "@bakers-build/message": "^0.5.1-next.850"
26
+ "@bakers-build/conductor": "^0.5.1-next.851",
27
+ "@bakers-build/core": "^0.5.1-next.851",
28
+ "@bakers-build/message": "^0.5.1-next.851"
29
29
  },
30
30
  "bakersBuild": {
31
- "commit": "5f928492b2ed78efe1f782a9618ecf8bde49be3d",
31
+ "commit": "9547fdedfc72a8623ba101d72a39c20a9fef5a8e",
32
32
  "channel": "next"
33
33
  }
34
34
  }