@domainkit/react 0.4.0 → 0.5.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/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { AlertDialog } from "@base-ui/react/alert-dialog";
3
3
  import { RegistryProvider, useAtomSet, useAtomValue } from "@effect/atom-react";
4
- import { Transport } from "domainkit";
4
+ import { DomainName, Transport } from "domainkit";
5
5
  import * as Data from "effect/Data";
6
6
  import * as Effect from "effect/Effect";
7
7
  import * as Atom from "effect/unstable/reactivity/Atom";
@@ -115,10 +115,11 @@ const english = {
115
115
  close: "Close",
116
116
  detectingProvider: "Detecting DNS provider…",
117
117
  disconnectDomain: "Disconnect",
118
- disconnectConsent: "The provider connection will be removed. Existing DNS records will be preserved.",
118
+ disconnectConsent: "This domain will be detached from the provider. Existing DNS records will be preserved.",
119
119
  disconnecting: "Disconnecting…",
120
- disconnectTitle: (provider) => `Disconnect ${provider}?`,
121
- domainDisconnected: "Domain disconnected. DNS records were preserved.",
120
+ detaching: "Detaching domain…",
121
+ disconnectTitle: (provider) => `Detach ${provider}?`,
122
+ domainDisconnected: "Domain detached. DNS records were preserved.",
122
123
  dialogDescription: (domain) => `Authorize DNS changes for ${domain}.`,
123
124
  dialogTitle: (provider) => `Connect ${provider}`,
124
125
  openingAuthorization: "Opening provider authorization…",
@@ -130,7 +131,9 @@ const english = {
130
131
  reviewCleanup: "Remove records",
131
132
  reviewDns: "Review changes",
132
133
  retry: "Try again",
133
- reuseConnection: (connection) => `Use ${connection}`,
134
+ existingConnection: "Existing provider connection",
135
+ targetUnavailable: "No provider targets are available for this connection.",
136
+ attachTarget: (target) => `Use ${target}`,
134
137
  tokenLabel: "API token"
135
138
  };
136
139
  const merge = (overrides = {}) => ({
@@ -327,8 +330,8 @@ function useModel$3(connection, receiptId, onCleaned) {
327
330
  if (current._tag === "Planning" || current._tag === "Cleaning") return Effect.void;
328
331
  get.set(state, State$3.Planning());
329
332
  return Effect.flatMap(Transport.Service, (transport) => transport.cleanup.plan({
330
- connectionId: connection.connectionId,
331
- domain: connection.domain,
333
+ attachmentId: connection.attachment.id,
334
+ domain: connection.attachment.domain,
332
335
  receiptId
333
336
  })).pipe(Effect.tap((plan) => Effect.sync(() => get.set(state, State$3.Review({ plan })))), Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))), Effect.asVoid);
334
337
  }
@@ -336,8 +339,8 @@ function useModel$3(connection, receiptId, onCleaned) {
336
339
  const plan = current.plan;
337
340
  get.set(state, State$3.Cleaning({ plan }));
338
341
  return Effect.flatMap(Transport.Service, (transport) => transport.cleanup.apply({
339
- connectionId: connection.connectionId,
340
- domain: connection.domain,
342
+ attachmentId: connection.attachment.id,
343
+ domain: connection.attachment.domain,
341
344
  planDigest: plan.digest,
342
345
  receiptId
343
346
  })).pipe(Effect.tap((result) => Effect.sync(() => {
@@ -361,8 +364,8 @@ function useModel$3(connection, receiptId, onCleaned) {
361
364
  state
362
365
  };
363
366
  }, [
364
- connection.connectionId,
365
- connection.domain,
367
+ connection.attachment.domain,
368
+ connection.attachment.id,
366
369
  emit,
367
370
  receiptId,
368
371
  runtime
@@ -556,6 +559,7 @@ function Mark({ provider, ...props }) {
556
559
  //#endregion
557
560
  //#region src/connection.tsx
558
561
  var connection_exports = /* @__PURE__ */ __exportAll({
562
+ AttachAction: () => AttachAction,
559
563
  Card: () => Card$1,
560
564
  CardActions: () => CardActions,
561
565
  CardIdentity: () => CardIdentity,
@@ -564,18 +568,20 @@ var connection_exports = /* @__PURE__ */ __exportAll({
564
568
  Dialog: () => Dialog$2,
565
569
  DisconnectDialog: () => DisconnectDialog,
566
570
  Flow: () => Flow$2,
571
+ IntegrationAction: () => IntegrationAction,
567
572
  OAuthAction: () => OAuthAction,
568
573
  RetryAction: () => RetryAction$1,
569
- ReuseAction: () => ReuseAction,
570
574
  Root: () => Root$3,
571
575
  State: () => State$2,
572
576
  Status: () => Status$2,
573
577
  TokenAction: () => TokenAction,
574
578
  Trigger: () => Trigger,
579
+ targetLabel: () => targetLabel,
575
580
  useController: () => useController$2,
576
581
  useModel: () => useModel$2
577
582
  });
578
583
  const State$2 = Data.taggedEnum();
584
+ const sameTarget = (left, right) => left.accountId === right.accountId && left.accountKind === right.accountKind && left.zoneId === right.zoneId && left.zoneName === right.zoneName;
579
585
  const Command$2 = Data.taggedEnum();
580
586
  function useModel$2(domain) {
581
587
  const { emit, navigate, runtime } = useDomainKit();
@@ -601,33 +607,29 @@ function useModel$2(domain) {
601
607
  return Effect.void;
602
608
  }
603
609
  const snapshot = get(state);
604
- if (input._tag === "Disconnect") {
610
+ if (input._tag === "Detach") {
605
611
  if (snapshot._tag !== "Connected") return Effect.void;
606
- get.set(actionState, State$2.Disconnecting({ snapshot }));
607
- return Effect.flatMap(Transport.Service, (transport) => transport.connection.removeDomain({
608
- connectionId: snapshot.connectionId,
609
- domain: snapshot.domain,
612
+ get.set(actionState, State$2.Detaching({ snapshot }));
613
+ return Effect.flatMap(Transport.Service, (transport) => Effect.flatMap(transport.connection.detach({
614
+ attachmentId: snapshot.attachment.id,
610
615
  preserveDns: true
611
- })).pipe(Effect.tap((result) => Effect.sync(() => {
612
- get.set(actionState, {
616
+ }), (result) => {
617
+ const detached = {
613
618
  _tag: "Disconnected",
614
- domain: snapshot.domain,
619
+ domain: snapshot.attachment.domain,
615
620
  provider: snapshot.provider,
616
- ...result.remainingDomainCount > 0 ? { reusableConnection: {
617
- connectionId: result.connectionId,
618
- label: snapshot.provider.name
619
- } } : {}
620
- });
621
- emit(Event.DomainDisconnected({
622
- connection: snapshot,
623
- result
624
- }));
625
- })), Effect.catch((error) => Effect.sync(() => get.set(actionState, failureFromError(error)))), Effect.asVoid);
621
+ reusableConnections: []
622
+ };
623
+ return Effect.flatMap(Effect.sync(() => {
624
+ get.set(actionState, detached);
625
+ emit(Event.DomainDetached({
626
+ connection: snapshot,
627
+ result
628
+ }));
629
+ }), () => transport.connection.inspect({ domain }).pipe(Effect.catch(() => Effect.succeed(detached)), Effect.tap((refreshed) => Effect.sync(() => get.set(actionState, refreshed)))));
630
+ })).pipe(Effect.catch((error) => Effect.sync(() => get.set(actionState, failureFromError(error)))), Effect.asVoid);
626
631
  }
627
632
  if (snapshot._tag !== "Disconnected") return Effect.void;
628
- const reusableConnection = snapshot.reusableConnection;
629
- if (input._tag === "Reuse" && reusableConnection === void 0) return Effect.void;
630
- get.set(actionState, State$2.Submitting({ snapshot }));
631
633
  const complete = (request, source) => request.pipe(Effect.tap((result) => Effect.sync(() => {
632
634
  if (result._tag === "Redirect") {
633
635
  get.set(actionState, State$2.Redirecting({ snapshot }));
@@ -640,16 +642,25 @@ function useModel$2(domain) {
640
642
  }));
641
643
  }
642
644
  })), Effect.catch((error) => Effect.sync(() => get.set(actionState, failureFromError(error)))), Effect.asVoid);
645
+ if (input._tag === "Attach") {
646
+ const reusableConnection = snapshot.reusableConnections.find(({ connection }) => connection.id === input.connectionId);
647
+ if (reusableConnection === void 0) return Effect.void;
648
+ const target = reusableConnection.targets.find((candidate) => sameTarget(candidate, input.target));
649
+ if (target === void 0) return Effect.void;
650
+ get.set(actionState, State$2.Submitting({ snapshot }));
651
+ return complete(Effect.flatMap(Transport.Service, (transport) => transport.connection.attach({
652
+ connectionId: input.connectionId,
653
+ domain,
654
+ target
655
+ })), "attach");
656
+ }
657
+ get.set(actionState, State$2.Submitting({ snapshot }));
643
658
  if (input._tag === "Connect") return complete(Effect.flatMap(Transport.Service, (transport) => transport.connection.connect({
644
659
  domain,
645
660
  method: input.method,
646
661
  providerId: snapshot.provider.id
647
662
  })), "connect");
648
- if (reusableConnection === void 0) return Effect.void;
649
- return complete(Effect.flatMap(Transport.Service, (transport) => transport.connection.reuse({
650
- connectionId: reusableConnection.connectionId,
651
- domain
652
- })), "reuse");
663
+ return Effect.void;
653
664
  }),
654
665
  state
655
666
  };
@@ -665,10 +676,13 @@ function useController$2(domain) {
665
676
  const state = useAtomValue(model.state);
666
677
  const execute = useAtomSet(model.command);
667
678
  return {
679
+ attach: (connection, target) => execute(Command$2.Attach({
680
+ connectionId: connection.connection.id,
681
+ target
682
+ })),
668
683
  connect: (method) => execute(Command$2.Connect({ method })),
669
- disconnect: () => execute(Command$2.Disconnect()),
684
+ detach: () => execute(Command$2.Detach()),
670
685
  retry: () => execute(Command$2.Retry()),
671
- reuse: () => execute(Command$2.Reuse()),
672
686
  state
673
687
  };
674
688
  }
@@ -680,7 +694,7 @@ function Root$3({ children, status = "Loading", ...props }) {
680
694
  }
681
695
  function Status$2({ children, state, ...props }) {
682
696
  const { messages } = useDomainKit();
683
- const text = state._tag === "Loading" ? messages.detectingProvider : state._tag === "Connected" ? messages.connected(state.provider.name) : state._tag === "Disconnecting" ? messages.disconnecting : state._tag === "Unsupported" ? messages.automaticUnavailable : state._tag === "Failure" ? state.message : state._tag === "Redirecting" ? messages.openingAuthorization : state._tag === "Submitting" ? messages.connecting : messages.providerAvailable(state.provider.name);
697
+ const text = state._tag === "Loading" ? messages.detectingProvider : state._tag === "Connected" ? messages.connected(state.provider.name) : state._tag === "Detaching" ? messages.detaching : state._tag === "Unsupported" ? messages.automaticUnavailable : state._tag === "Failure" ? state.message : state._tag === "Redirecting" ? messages.openingAuthorization : state._tag === "Submitting" ? messages.connecting : messages.providerAvailable(state.provider.name);
684
698
  return usePart("div", props, { status: state._tag }, {
685
699
  children: children ?? text,
686
700
  "data-domainkit-part": "connection-status",
@@ -714,12 +728,21 @@ function OAuthAction({ controller, label, ...props }) {
714
728
  type: "button"
715
729
  });
716
730
  }
717
- function ReuseAction({ controller, label, ...props }) {
718
- return usePart("button", props, { authentication: "reuse" }, {
731
+ function IntegrationAction({ controller, label, ...props }) {
732
+ return usePart("button", props, { authentication: "integration" }, {
733
+ children: label,
734
+ "data-domainkit-part": "integration-connect",
735
+ disabled: controller.state._tag === "Submitting" || controller.state._tag === "Redirecting",
736
+ onClick: () => controller.connect(Transport.Method.Integration()),
737
+ type: "button"
738
+ });
739
+ }
740
+ function AttachAction({ connection, controller, label, target, ...props }) {
741
+ return usePart("button", props, { authentication: "attach" }, {
719
742
  children: label,
720
- "data-domainkit-part": "reuse-connection",
743
+ "data-domainkit-part": "attach-target",
721
744
  disabled: controller.state._tag === "Submitting" || controller.state._tag === "Redirecting",
722
- onClick: () => void controller.reuse(),
745
+ onClick: () => controller.attach(connection, target),
723
746
  type: "button"
724
747
  });
725
748
  }
@@ -779,12 +802,14 @@ function TokenAction({ controller, method, ...props }) {
779
802
  onSubmit: submit
780
803
  });
781
804
  }
805
+ const targetLabel = (target) => `${target.evidence?.accountName ?? target.accountId} · ${target.zoneName}`;
782
806
  function Dialog$2({ controller, snapshot }) {
783
807
  const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();
784
808
  const pending = controller.state._tag === "Submitting" || controller.state._tag === "Redirecting";
809
+ const integrationMethods = snapshot.provider.authentication.filter((method) => method._tag === "Integration");
785
810
  const oauthMethods = snapshot.provider.authentication.filter((method) => method._tag === "OAuth");
786
811
  const tokenMethods = snapshot.provider.authentication.filter((method) => method._tag === "Token");
787
- const hasProviderAccountPath = oauthMethods.length > 0 || snapshot.reusableConnection !== void 0;
812
+ const hasProviderAccountPath = integrationMethods.length > 0 || oauthMethods.length > 0 || snapshot.reusableConnections.length > 0;
788
813
  return /* @__PURE__ */ jsxs(Dialog.Portal, {
789
814
  container: portalContainer,
790
815
  children: [/* @__PURE__ */ jsx(Dialog.Backdrop, {
@@ -824,13 +849,36 @@ function Dialog$2({ controller, snapshot }) {
824
849
  children: [
825
850
  hasProviderAccountPath ? /* @__PURE__ */ jsxs("div", {
826
851
  "data-domainkit-part": "provider-authentication",
827
- children: [oauthMethods.map((method) => /* @__PURE__ */ jsx(OAuthAction, {
828
- controller,
829
- label: method.label
830
- }, method._tag)), snapshot.reusableConnection === void 0 ? null : /* @__PURE__ */ jsx(ReuseAction, {
831
- controller,
832
- label: messages.reuseConnection(snapshot.reusableConnection.label)
833
- })]
852
+ children: [
853
+ integrationMethods.map((method) => /* @__PURE__ */ jsx(IntegrationAction, {
854
+ controller,
855
+ label: method.label
856
+ }, method._tag)),
857
+ oauthMethods.map((method) => /* @__PURE__ */ jsx(OAuthAction, {
858
+ controller,
859
+ label: method.label
860
+ }, method._tag)),
861
+ snapshot.reusableConnections.map((connection) => /* @__PURE__ */ jsxs("section", {
862
+ "data-connection-id": connection.connection.id,
863
+ "data-domainkit-part": "reusable-connection",
864
+ children: [/* @__PURE__ */ jsxs("div", {
865
+ "data-domainkit-part": "reusable-connection-heading",
866
+ children: [/* @__PURE__ */ jsx("strong", { children: messages.existingConnection }), /* @__PURE__ */ jsx("span", { children: connection.connection.providerId })]
867
+ }), /* @__PURE__ */ jsx("div", {
868
+ "data-domainkit-part": "target-list",
869
+ "data-state": connection.targets.length === 0 ? "unavailable" : connection.targets.length === 1 ? "unique" : "ambiguous",
870
+ children: connection.targets.length === 0 ? /* @__PURE__ */ jsx("p", {
871
+ "data-domainkit-part": "target-unavailable",
872
+ children: messages.targetUnavailable
873
+ }) : connection.targets.map((target) => /* @__PURE__ */ jsx(AttachAction, {
874
+ connection,
875
+ controller,
876
+ label: messages.attachTarget(targetLabel(target)),
877
+ target
878
+ }, `${target.accountId}:${target.zoneId}`))
879
+ })]
880
+ }, connection.connection.id))
881
+ ]
834
882
  }) : null,
835
883
  hasProviderAccountPath && tokenMethods.length > 0 ? /* @__PURE__ */ jsx("div", {
836
884
  "aria-label": messages.authenticationAlternative,
@@ -918,10 +966,10 @@ function DisconnectDialog({ connection, controller, onOpenChange, open: openProp
918
966
  if (openProp === void 0) setInternalOpen(nextOpen);
919
967
  onOpenChange?.(nextOpen);
920
968
  };
921
- const disconnecting = controller.state._tag === "Disconnecting";
969
+ const detaching = controller.state._tag === "Detaching";
922
970
  return /* @__PURE__ */ jsxs(AlertDialog.Root, {
923
971
  onOpenChange: (nextOpen, eventDetails) => {
924
- if (!nextOpen && disconnecting) {
972
+ if (!nextOpen && detaching) {
925
973
  eventDetails.cancel();
926
974
  return;
927
975
  }
@@ -955,22 +1003,22 @@ function DisconnectDialog({ connection, controller, onOpenChange, open: openProp
955
1003
  "data-domainkit-part": "dialog-description",
956
1004
  children: messages.disconnectConsent
957
1005
  })]
958
- }), disconnecting ? null : /* @__PURE__ */ jsx(AlertDialog.Close, {
1006
+ }), detaching ? null : /* @__PURE__ */ jsx(AlertDialog.Close, {
959
1007
  "aria-label": messages.close,
960
1008
  "data-domainkit-part": "dialog-close",
961
1009
  children: "×"
962
1010
  })]
963
1011
  }), /* @__PURE__ */ jsxs("div", {
964
1012
  "data-domainkit-part": "dialog-footer",
965
- children: [disconnecting ? null : /* @__PURE__ */ jsx(AlertDialog.Close, {
1013
+ children: [detaching ? null : /* @__PURE__ */ jsx(AlertDialog.Close, {
966
1014
  "data-domainkit-part": "dialog-cancel",
967
1015
  children: messages.cancel
968
1016
  }), /* @__PURE__ */ jsx("button", {
969
1017
  "data-domainkit-part": "disconnect-action",
970
- disabled: disconnecting,
971
- onClick: () => controller.disconnect(),
1018
+ disabled: detaching,
1019
+ onClick: () => controller.detach(),
972
1020
  type: "button",
973
- children: disconnecting ? messages.disconnecting : messages.disconnectDomain
1021
+ children: detaching ? messages.detaching : messages.disconnectDomain
974
1022
  })]
975
1023
  })]
976
1024
  })]
@@ -1262,8 +1310,8 @@ function useModel$1(connection, records, onApplied) {
1262
1310
  if (current._tag === "Planning" || current._tag === "Applying") return Effect.void;
1263
1311
  get.set(state, State$1.Planning());
1264
1312
  return Effect.flatMap(Transport.Service, (transport) => transport.provisioning.plan({
1265
- connectionId: connection.connectionId,
1266
- domain: connection.domain,
1313
+ attachmentId: connection.attachment.id,
1314
+ domain: connection.attachment.domain,
1267
1315
  records
1268
1316
  })).pipe(Effect.tap((plan) => Effect.sync(() => get.set(state, State$1.Review({ plan })))), Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))), Effect.asVoid);
1269
1317
  }
@@ -1271,8 +1319,8 @@ function useModel$1(connection, records, onApplied) {
1271
1319
  const plan = current.plan;
1272
1320
  get.set(state, State$1.Applying({ plan }));
1273
1321
  return Effect.flatMap(Transport.Service, (transport) => transport.provisioning.apply({
1274
- connectionId: connection.connectionId,
1275
- domain: connection.domain,
1322
+ attachmentId: connection.attachment.id,
1323
+ domain: connection.attachment.domain,
1276
1324
  planDigest: plan.digest
1277
1325
  })).pipe(Effect.tap((result) => Effect.sync(() => {
1278
1326
  if (result._tag === "Applied") {
@@ -1295,8 +1343,8 @@ function useModel$1(connection, records, onApplied) {
1295
1343
  state
1296
1344
  };
1297
1345
  }, [
1298
- connection.connectionId,
1299
- connection.domain,
1346
+ connection.attachment.domain,
1347
+ connection.attachment.id,
1300
1348
  emit,
1301
1349
  recordKey,
1302
1350
  runtime
@@ -1482,7 +1530,7 @@ function useModel(config) {
1482
1530
  const previous = current._tag === "Observation" ? current : current._tag === "Failed" ? current.previous : void 0;
1483
1531
  get.set(state, State.Observing({ ...previous === void 0 ? {} : { previous } }));
1484
1532
  return Effect.flatMap(Transport.Service, (transport) => transport.verification.observe({
1485
- ...config.connection === void 0 ? {} : { connectionId: config.connection.connectionId },
1533
+ ...config.connection === void 0 ? {} : { attachmentId: config.connection.attachment.id },
1486
1534
  domain: config.domain,
1487
1535
  records: config.records,
1488
1536
  sources: {
@@ -1497,7 +1545,7 @@ function useModel(config) {
1497
1545
  state
1498
1546
  };
1499
1547
  }, [
1500
- config.connection?.connectionId,
1548
+ config.connection?.attachment.id,
1501
1549
  config.domain,
1502
1550
  provider,
1503
1551
  publicDns,
@@ -1627,11 +1675,11 @@ var domain_exports = /* @__PURE__ */ __exportAll({ Flow: () => Flow });
1627
1675
  function Flow({ domain, receiptId, records }) {
1628
1676
  const controller = useController$2(domain);
1629
1677
  const state = controller.state;
1630
- const connected = state._tag === "Connected" ? state : state._tag === "Disconnecting" ? state.snapshot : void 0;
1678
+ const connected = state._tag === "Connected" ? state : state._tag === "Detaching" ? state.snapshot : void 0;
1631
1679
  return /* @__PURE__ */ jsxs(Root$3, {
1632
1680
  status: state._tag,
1633
1681
  children: [
1634
- state._tag === "Connected" || state._tag === "Disconnecting" ? /* @__PURE__ */ jsx(ConnectedCard, {
1682
+ state._tag === "Connected" || state._tag === "Detaching" ? /* @__PURE__ */ jsx(ConnectedCard, {
1635
1683
  connection: state._tag === "Connected" ? state : state.snapshot,
1636
1684
  controller,
1637
1685
  ...receiptId === void 0 ? {} : { initialReceiptId: receiptId },
@@ -1689,7 +1737,7 @@ function ConnectedCard({ connection, controller, initialReceiptId, records, stat
1689
1737
  value: initialReceiptId
1690
1738
  });
1691
1739
  const receiptId = receipt.host === initialReceiptId ? receipt.value : initialReceiptId;
1692
- const disabled = status === "Disconnecting";
1740
+ const disabled = status === "Detaching";
1693
1741
  const actionsTriggerRef = useRef(null);
1694
1742
  return /* @__PURE__ */ jsxs(Card$1, {
1695
1743
  status,
@@ -1823,8 +1871,12 @@ function ProviderActions({ actionsTriggerRef: actionsTriggerRefProp, cleanup, co
1823
1871
  //#endregion
1824
1872
  //#region src/testing.ts
1825
1873
  var testing_exports = /* @__PURE__ */ __exportAll({
1874
+ attachment: () => attachment,
1875
+ connected: () => connected,
1876
+ connection: () => connection,
1826
1877
  makeFakeTransport: () => makeFakeTransport,
1827
- provider: () => provider
1878
+ provider: () => provider,
1879
+ target: () => target
1828
1880
  });
1829
1881
  const provider = (overrides = {}) => ({
1830
1882
  authentication: [{
@@ -1839,17 +1891,48 @@ const provider = (overrides = {}) => ({
1839
1891
  name: "Cloudflare",
1840
1892
  ...overrides
1841
1893
  });
1894
+ const target = (overrides = {}) => ({
1895
+ accountId: "account-1",
1896
+ accountKind: "account",
1897
+ zoneId: "zone-1",
1898
+ zoneName: DomainName.parse("example.com"),
1899
+ ...overrides
1900
+ });
1901
+ const connection = (overrides = {}) => ({
1902
+ createdAt: /* @__PURE__ */ new Date("2026-08-30T00:00:00.000Z"),
1903
+ id: "connection-1",
1904
+ method: "oauth2",
1905
+ ownerId: "organization-1",
1906
+ providerId: "cloudflare",
1907
+ status: "active",
1908
+ ...overrides
1909
+ });
1910
+ const attachment = (overrides = {}) => ({
1911
+ connectionId: "connection-1",
1912
+ createdAt: /* @__PURE__ */ new Date("2026-08-30T00:00:00.000Z"),
1913
+ domain: DomainName.parse("mail.example.com"),
1914
+ id: "attachment-1",
1915
+ target: target(),
1916
+ ...overrides
1917
+ });
1918
+ const connected = (overrides = {}) => ({
1919
+ _tag: "Connected",
1920
+ attachment: attachment(),
1921
+ connection: connection(),
1922
+ provider: provider(),
1923
+ ...overrides
1924
+ });
1842
1925
  function makeFakeTransport(options) {
1843
1926
  const calls = {
1844
1927
  apply: [],
1928
+ attach: [],
1845
1929
  cleanupApply: [],
1846
1930
  cleanupPlan: [],
1847
1931
  connect: [],
1932
+ detach: [],
1848
1933
  inspect: [],
1849
1934
  observe: [],
1850
- plan: [],
1851
- removeDomain: [],
1852
- reuse: []
1935
+ plan: []
1853
1936
  };
1854
1937
  const inspections = Array.isArray(options.inspect) ? [...options.inspect] : [options.inspect];
1855
1938
  const transport = {
@@ -1877,8 +1960,8 @@ function makeFakeTransport(options) {
1877
1960
  calls.connect.push(input);
1878
1961
  return options.connect ?? {
1879
1962
  _tag: "Connected",
1880
- connectionId: "connection-1",
1881
- domain: input.domain,
1963
+ attachment: attachment({ domain: DomainName.parse(input.domain) }),
1964
+ connection: connection(),
1882
1965
  provider: provider()
1883
1966
  };
1884
1967
  },
@@ -1893,22 +1976,26 @@ function makeFakeTransport(options) {
1893
1976
  });
1894
1977
  return snapshot;
1895
1978
  },
1896
- reuse: async (input) => {
1897
- calls.reuse.push(input);
1898
- return options.reuse ?? {
1979
+ attach: async (input) => {
1980
+ calls.attach.push(input);
1981
+ return options.attach ?? {
1899
1982
  _tag: "Connected",
1900
- connectionId: input.connectionId,
1901
- domain: input.domain,
1983
+ attachment: attachment({
1984
+ connectionId: input.connectionId,
1985
+ domain: DomainName.parse(input.domain),
1986
+ target: input.target
1987
+ }),
1988
+ connection: connection({ id: input.connectionId }),
1902
1989
  provider: provider()
1903
1990
  };
1904
1991
  },
1905
- removeDomain: async (input) => {
1906
- calls.removeDomain.push(input);
1907
- return options.removeDomain ?? {
1908
- _tag: "Removed",
1909
- connectionId: input.connectionId,
1910
- domain: input.domain,
1911
- remainingDomainCount: 0
1992
+ detach: async (input) => {
1993
+ calls.detach.push(input);
1994
+ return options.detach ?? {
1995
+ _tag: "Detached",
1996
+ attachment: attachment(),
1997
+ connection: connection(),
1998
+ remainingAttachments: 0
1912
1999
  };
1913
2000
  }
1914
2001
  },