domainkit 0.2.2 → 0.3.1

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.
Files changed (58) hide show
  1. package/README.md +26 -26
  2. package/dist/index.d.mts +639 -187
  3. package/dist/index.mjs +301 -300
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/promise.d.mts +464 -0
  6. package/dist/promise.mjs +636 -0
  7. package/dist/promise.mjs.map +1 -0
  8. package/dist/{resolver-CxE-VDw4.mjs → resolver-CvK7JoJM.mjs} +401 -54
  9. package/dist/resolver-CvK7JoJM.mjs.map +1 -0
  10. package/dist/{resolver-Dc0hwV-J.d.mts → resolver-uqe1h5Vz.d.mts} +1513 -25
  11. package/dist/testing.d.mts +4 -5
  12. package/dist/testing.mjs +17 -3
  13. package/dist/testing.mjs.map +1 -1
  14. package/dist/verify-BoWy70ew.mjs +2420 -0
  15. package/dist/verify-BoWy70ew.mjs.map +1 -0
  16. package/dist/{verify-Dls29YC-.d.mts → verify-CkgVrwyl.d.mts} +318 -21
  17. package/package.json +6 -30
  18. package/dist/auth-BR-19zj-.mjs +0 -738
  19. package/dist/auth-BR-19zj-.mjs.map +0 -1
  20. package/dist/auth-g-waCHcz.mjs +0 -671
  21. package/dist/auth-g-waCHcz.mjs.map +0 -1
  22. package/dist/authorization-OeaSR47S.mjs +0 -284
  23. package/dist/authorization-OeaSR47S.mjs.map +0 -1
  24. package/dist/canonical-json-CpvqGMcr.mjs +0 -57
  25. package/dist/canonical-json-CpvqGMcr.mjs.map +0 -1
  26. package/dist/cloudflare-BrZPU9li.d.mts +0 -32
  27. package/dist/cloudflare-CGmasR8A.mjs +0 -69
  28. package/dist/cloudflare-CGmasR8A.mjs.map +0 -1
  29. package/dist/cloudflare.d.mts +0 -3
  30. package/dist/cloudflare.mjs +0 -2
  31. package/dist/connection-BfkloPZy.d.mts +0 -186
  32. package/dist/connection-BwtOwpH6.mjs +0 -195
  33. package/dist/connection-BwtOwpH6.mjs.map +0 -1
  34. package/dist/connection-CjNQe_E-.mjs +0 -58
  35. package/dist/connection-CjNQe_E-.mjs.map +0 -1
  36. package/dist/connection-api-DNuEZ_jR.d.mts +0 -7
  37. package/dist/dns-record-BLeqo56C.mjs +0 -289
  38. package/dist/dns-record-BLeqo56C.mjs.map +0 -1
  39. package/dist/effect-cloudflare.d.mts +0 -2
  40. package/dist/effect-cloudflare.mjs +0 -2
  41. package/dist/effect-vercel.d.mts +0 -2
  42. package/dist/effect-vercel.mjs +0 -2
  43. package/dist/effect.d.mts +0 -36
  44. package/dist/effect.mjs +0 -51
  45. package/dist/effect.mjs.map +0 -1
  46. package/dist/index-BHWRTThN.d.mts +0 -159
  47. package/dist/index-D3PVknwE.d.mts +0 -145
  48. package/dist/resolver-CxE-VDw4.mjs.map +0 -1
  49. package/dist/vercel-BsNDu4Np.d.mts +0 -31
  50. package/dist/vercel-CfoJaaCu.mjs +0 -60
  51. package/dist/vercel-CfoJaaCu.mjs.map +0 -1
  52. package/dist/vercel.d.mts +0 -3
  53. package/dist/vercel.mjs +0 -2
  54. package/dist/verify-BKbvq7IN.mjs +0 -642
  55. package/dist/verify-BKbvq7IN.mjs.map +0 -1
  56. package/dist/zone-discovery-BPnH3sLU.d.mts +0 -1397
  57. package/dist/zones-DKHTpX9C.mjs +0 -19
  58. package/dist/zones-DKHTpX9C.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,324 +1,325 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { A as invalid_input_exports, O as parse$1, S as layerFromAsync, T as Schema$2, _ as equals, a as Mx, b as Service, c as Opaque, d as Srv, f as Txt, i as Cname, l as RequirementMetadata, m as data, n as Aaaa, o as Ns, p as Type, r as Caa, s as Observed, t as A, u as Schema$1, v as parse, y as Error } from "./dns-record-BLeqo56C.mjs";
3
- import { a as Schema$3, c as encode, d as provider_context_exports, i as EvidenceSchema, m as secret_exports, n as CapabilityEvidence, r as Evidence, s as decode$3, t as Capability } from "./authorization-OeaSR47S.mjs";
4
- import { n as zones_exports } from "./zones-DKHTpX9C.mjs";
5
- import { i as webCryptoLayer } from "./canonical-json-CpvqGMcr.mjs";
6
- import { i as authorization_lifecycle_exports, t as connection_exports } from "./connection-BwtOwpH6.mjs";
7
- import { t as cloudflare_exports } from "./cloudflare-CGmasR8A.mjs";
8
- import { C as selection_exports, E as decode$4, O as diagnostic_exports, T as Schema$4, _ as toAsync$1, a as Result, c as Observation, d as defaultMake$1, f as make$4, h as toAsync$3, i as PublicDnsObservation, k as version, l as Policy, n as ProviderObservation, o as observe$1, r as PublicDns$1, t as Provider$1, u as Service$1, w as Method, x as authorize$2, y as toAsync$2 } from "./verify-BKbvq7IN.mjs";
9
- import { A as decodeReceipt$1, D as Receipt, E as Operation, F as Service$2, I as make$5, M as encodeReceipt, O as Schema$5, P as Candidate, S as create$3, T as Authorization, a as Authorization$1, b as apply$3, c as PartialError, d as apply$2, f as authorize$3, g as CreateResult, j as encode$1, k as decode$5, l as Plan, o as Error$1, p as create$2, s as Operation$1, t as Error$2, u as Receipt$1, w as renderManualInstructions$1, x as authorize$4, y as Target } from "./resolver-CxE-VDw4.mjs";
10
- import { r as vercel_exports } from "./vercel-CfoJaaCu.mjs";
11
- import { Data, Effect, Layer } from "effect";
12
- //#region src/promise/provider-auth.ts
13
- var provider_auth_exports = /* @__PURE__ */ __exportAll({
14
- Method: () => Method,
15
- Schema: () => Schema$4,
16
- decode: () => decode$2
2
+ import { $ as RemoveDomainResult$1, A as make$1, B as discovery, G as secret_exports, O as client_exports$1, Q as Method$1, Tt as version, U as connection_authorization_exports, V as make, W as selection_exports, X as diagnostic_exports, Y as manifest_exports, Z as Error, at as AuthorizationError, b as dns_data_exports, ct as assertGrant, dt as decode, et as StartResult, ft as encode, g as cloudflare_doh_exports, ht as validate, it as start, j as auth_exports, k as discovery$1, lt as authorizationError, m as google_doh_exports, mt as removeDomain$1, nt as extend, ot as Grant, p as resolver_pool_exports, pt as includeDomains, rt as removeDomain, s as verify_exports, st as Schema$1, tt as complete, ut as coversDomain, v as doh_exports, wt as provider_context_exports, x as auth_exports$1, xt as authorization_exports, z as client_exports } from "./verify-BoWy70ew.mjs";
3
+ import { B as provider_exports, C as plan_exports, N as types_exports, P as canonical_json_exports, _t as domain_name_exports, bt as invalid_input_exports, dt as zones_exports, lt as zone_discovery_exports, m as deletion_exports, mt as lifecycle_repository_exports, r as resolver_exports, rt as dns_record_exports } from "./resolver-CvK7JoJM.mjs";
4
+ import { Context, Data, Effect, Layer, Schema } from "effect";
5
+ //#region src/auth/connection-api.ts
6
+ var connection_api_exports = /* @__PURE__ */ __exportAll({
7
+ AuthorizationError: () => AuthorizationError,
8
+ Error: () => Error,
9
+ Grant: () => Grant,
10
+ Method: () => Method$1,
11
+ RemoveDomainResult: () => RemoveDomainResult$1,
12
+ Schema: () => Schema$1,
13
+ StartResult: () => StartResult,
14
+ assertGrant: () => assertGrant,
15
+ authorizationError: () => authorizationError,
16
+ complete: () => complete,
17
+ coversDomain: () => coversDomain,
18
+ decode: () => decode,
19
+ encode: () => encode,
20
+ extend: () => extend,
21
+ includeDomains: () => includeDomains,
22
+ removeDomain: () => removeDomain,
23
+ removeDomainFromGrant: () => removeDomain$1,
24
+ start: () => start,
25
+ validate: () => validate
26
+ });
27
+ //#endregion
28
+ //#region src/providers/cloudflare/index.ts
29
+ var cloudflare_exports = /* @__PURE__ */ __exportAll({
30
+ Auth: () => auth_exports,
31
+ Client: () => client_exports,
32
+ discovery: () => discovery,
33
+ make: () => make
17
34
  });
18
- function decode$2(input) {
19
- return Effect.runPromise(decode$4(input));
20
- }
21
35
  //#endregion
22
- //#region src/promise/provider-authorization.ts
23
- var provider_authorization_exports = /* @__PURE__ */ __exportAll({
24
- Capability: () => Capability,
25
- CapabilityEvidence: () => CapabilityEvidence,
26
- Evidence: () => Evidence,
27
- EvidenceSchema: () => EvidenceSchema,
28
- Schema: () => Schema$3,
29
- decode: () => decode$1,
30
- encode: () => encode
36
+ //#region src/providers/vercel/index.ts
37
+ var vercel_exports = /* @__PURE__ */ __exportAll({
38
+ Auth: () => auth_exports$1,
39
+ Client: () => client_exports$1,
40
+ discovery: () => discovery$1,
41
+ make: () => make$1
31
42
  });
32
- function decode$1(input) {
33
- return Effect.runPromise(decode$3(input));
34
- }
35
43
  //#endregion
36
- //#region src/promise/zone-discovery.ts
37
- var zone_discovery_exports = /* @__PURE__ */ __exportAll({
38
- Candidate: () => Candidate,
39
- discover: () => discover,
40
- toEffectSource: () => toEffectSource
44
+ //#region src/transport.ts
45
+ var transport_exports = /* @__PURE__ */ __exportAll({
46
+ ApplyResult: () => ApplyResult,
47
+ AuthenticationMethod: () => AuthenticationMethod,
48
+ AuthenticationParameter: () => AuthenticationParameter,
49
+ CleanupOperation: () => CleanupOperation,
50
+ CleanupPlan: () => CleanupPlan,
51
+ CleanupResult: () => CleanupResult,
52
+ Connected: () => Connected,
53
+ ConnectionResult: () => ConnectionResult,
54
+ ConnectionSnapshot: () => ConnectionSnapshot,
55
+ Disconnected: () => Disconnected,
56
+ DnsRecord: () => DnsRecord,
57
+ Failure: () => Failure,
58
+ Method: () => Method,
59
+ Observation: () => Observation,
60
+ ObservationEvidence: () => ObservationEvidence,
61
+ OperationResult: () => OperationResult,
62
+ PlanOperation: () => PlanOperation,
63
+ Provider: () => Provider,
64
+ ProvisioningPlan: () => ProvisioningPlan,
65
+ Redirect: () => Redirect,
66
+ RemoveDomainResult: () => RemoveDomainResult,
67
+ ReusableConnection: () => ReusableConnection,
68
+ Service: () => Service,
69
+ Unsupported: () => Unsupported,
70
+ fromAsync: () => fromAsync,
71
+ fromDnsRecord: () => fromDnsRecord,
72
+ layerFromAsync: () => layerFromAsync,
73
+ toAsync: () => toAsync
74
+ });
75
+ /** A user-presentable failure at the application transport boundary. */
76
+ var Failure = class extends Schema.TaggedError()("Failure", {
77
+ message: Schema.String,
78
+ operation: Schema.String,
79
+ retry: Schema.Literals([
80
+ "never",
81
+ "after-user-action",
82
+ "safe",
83
+ "unknown"
84
+ ])
85
+ }) {};
86
+ const AuthenticationParameter = Schema.Struct({
87
+ description: Schema.optionalKey(Schema.String),
88
+ key: Schema.String,
89
+ label: Schema.String,
90
+ placeholder: Schema.optionalKey(Schema.String),
91
+ required: Schema.optionalKey(Schema.Boolean)
92
+ });
93
+ const AuthenticationMethod = Schema.TaggedUnion({
94
+ OAuth: { label: Schema.String },
95
+ Token: {
96
+ label: Schema.String,
97
+ parameters: Schema.optionalKey(Schema.Array(AuthenticationParameter)),
98
+ placeholder: Schema.optionalKey(Schema.String)
99
+ }
41
100
  });
42
- function discover(input) {
43
- return Effect.runPromise(make$5(input.sources.map(toEffectSource)).discover(input.domain).pipe(Effect.map(projectOutcome)));
44
- }
45
- function toEffectSource(source) {
46
- return {
47
- listZones: (name) => Effect.tryPromise({
48
- try: () => source.listZones(name),
49
- catch: (cause) => new Error({
50
- cause,
51
- message: cause instanceof globalThis.Error ? cause.message : String(cause),
52
- operation: "ZoneDiscovery.listZones",
53
- providerId: source.provider.id,
54
- reason: "transport"
55
- })
56
- }),
57
- provider: Service.of({
58
- id: source.provider.id,
59
- createRecord: (zone, record) => Effect.tryPromise({
60
- try: () => source.provider.createRecord(zone, record),
61
- catch: (cause) => providerFailure(source.provider.id, "createRecord", cause)
62
- }),
63
- deleteRecord: (zone, providerRecordId) => Effect.tryPromise({
64
- try: () => source.provider.deleteRecord(zone, providerRecordId),
65
- catch: (cause) => providerFailure(source.provider.id, "deleteRecord", cause)
66
- }),
67
- getRecord: (zone, providerRecordId) => Effect.tryPromise({
68
- try: () => source.provider.getRecord(zone, providerRecordId),
69
- catch: (cause) => providerFailure(source.provider.id, "getRecord", cause)
70
- }),
71
- listRecords: (zone) => Effect.tryPromise({
72
- try: () => source.provider.listRecords(zone),
73
- catch: (cause) => providerFailure(source.provider.id, "listRecords", cause)
74
- })
75
- })
76
- };
77
- }
78
- function projectOutcome(outcome) {
79
- switch (outcome._tag) {
80
- case "NotFound": return outcome;
81
- case "Resolved": return {
82
- _tag: "Resolved",
83
- candidate: outcome.candidate
101
+ const Method = Data.taggedEnum();
102
+ const Provider = Schema.Struct({
103
+ authentication: Schema.Array(AuthenticationMethod),
104
+ id: Schema.String,
105
+ name: Schema.String
106
+ });
107
+ const Connected = Schema.TaggedStruct("Connected", {
108
+ connectionId: Schema.String,
109
+ domain: Schema.String,
110
+ provider: Provider
111
+ });
112
+ const ReusableConnection = Schema.Struct({
113
+ connectionId: Schema.String,
114
+ label: Schema.String
115
+ });
116
+ const Disconnected = Schema.TaggedStruct("Disconnected", {
117
+ domain: Schema.String,
118
+ provider: Provider,
119
+ reusableConnection: Schema.optionalKey(ReusableConnection)
120
+ });
121
+ const Unsupported = Schema.TaggedStruct("Unsupported", { domain: Schema.String });
122
+ const ConnectionSnapshot = Schema.Union([
123
+ Connected,
124
+ Disconnected,
125
+ Unsupported
126
+ ]).pipe(Schema.toTaggedUnion("_tag"));
127
+ const Redirect = Schema.TaggedStruct("Redirect", { authorizationUrl: Schema.String });
128
+ const ConnectionResult = Schema.Union([Connected, Redirect]).pipe(Schema.toTaggedUnion("_tag"));
129
+ const RemoveDomainResult = Schema.TaggedStruct("Removed", {
130
+ connectionId: Schema.String,
131
+ domain: Schema.String,
132
+ remainingDomainCount: Schema.Int
133
+ });
134
+ /** A presentation projection of a DNS requirement. */
135
+ const DnsRecord = Schema.Struct({
136
+ id: Schema.String,
137
+ name: Schema.String,
138
+ priority: Schema.optionalKey(Schema.Int),
139
+ type: Schema.String,
140
+ value: Schema.String
141
+ });
142
+ /** Projects DomainKit's operational record into its application transport representation. */
143
+ const fromDnsRecord = (id, record) => {
144
+ switch (record._tag) {
145
+ case "A":
146
+ case "AAAA": return {
147
+ id,
148
+ name: record.name,
149
+ type: record._tag,
150
+ value: record.address
151
+ };
152
+ case "CNAME":
153
+ case "NS": return {
154
+ id,
155
+ name: record.name,
156
+ type: record._tag,
157
+ value: record.target
158
+ };
159
+ case "TXT": return {
160
+ id,
161
+ name: record.name,
162
+ type: record._tag,
163
+ value: record.value
164
+ };
165
+ case "MX": return {
166
+ id,
167
+ name: record.name,
168
+ priority: record.priority,
169
+ type: record._tag,
170
+ value: record.exchange
171
+ };
172
+ case "CAA": return {
173
+ id,
174
+ name: record.name,
175
+ type: record._tag,
176
+ value: `${record.flags} ${record.tag} ${record.value}`
177
+ };
178
+ case "SRV": return {
179
+ id,
180
+ name: record.name,
181
+ priority: record.priority,
182
+ type: record._tag,
183
+ value: `${record.weight} ${record.port} ${record.target}`
84
184
  };
85
- case "SelectionRequired": return outcome;
86
185
  }
87
- }
88
- function providerFailure(providerId, operation, cause) {
89
- return cause instanceof Error ? cause : new Error({
90
- cause,
91
- message: cause instanceof globalThis.Error ? cause.message : String(cause),
92
- operation,
93
- providerId
94
- });
95
- }
96
- //#endregion
97
- //#region src/promise/dns-record.ts
98
- var dns_record_exports = /* @__PURE__ */ __exportAll({
99
- A: () => A,
100
- Aaaa: () => Aaaa,
101
- Caa: () => Caa,
102
- Cname: () => Cname,
103
- Mx: () => Mx,
104
- Ns: () => Ns,
105
- Observed: () => Observed,
106
- Opaque: () => Opaque,
107
- RequirementMetadata: () => RequirementMetadata,
108
- Schema: () => Schema$1,
109
- Srv: () => Srv,
110
- Txt: () => Txt,
111
- Type: () => Type,
112
- data: () => data,
113
- equals: () => equals,
114
- parse: () => parse
186
+ };
187
+ const PlanOperation = Schema.TaggedUnion({
188
+ Conflict: {
189
+ id: Schema.String,
190
+ reason: Schema.String,
191
+ record: DnsRecord
192
+ },
193
+ Create: {
194
+ id: Schema.String,
195
+ record: DnsRecord
196
+ },
197
+ Noop: {
198
+ id: Schema.String,
199
+ record: DnsRecord
200
+ }
115
201
  });
116
- //#endregion
117
- //#region src/promise/domain-name.ts
118
- var domain_name_exports = /* @__PURE__ */ __exportAll({
119
- Schema: () => Schema$2,
120
- parse: () => parse$1
202
+ const ProvisioningPlan = Schema.TaggedStruct("Plan", {
203
+ digest: Schema.String,
204
+ expiresAt: Schema.String,
205
+ operations: Schema.Array(PlanOperation)
121
206
  });
122
- //#endregion
123
- //#region src/promise/dns-plan.ts
124
- var dns_plan_exports = /* @__PURE__ */ __exportAll({
125
- Authorization: () => Authorization,
126
- Operation: () => Operation,
127
- Receipt: () => Receipt,
128
- Schema: () => Schema$5,
129
- decode: () => decode,
130
- decodeReceipt: () => decodeReceipt,
131
- encode: () => encode$1,
132
- encodeReceipt: () => encodeReceipt
207
+ const OperationResult = Schema.TaggedUnion({
208
+ Applied: { operationId: Schema.String },
209
+ Failed: {
210
+ message: Schema.String,
211
+ operationId: Schema.String
212
+ },
213
+ Unchanged: { operationId: Schema.String }
133
214
  });
134
- function decode(input) {
135
- return Effect.runPromise(decode$5(input));
136
- }
137
- function decodeReceipt(input) {
138
- return Effect.runPromise(decodeReceipt$1(input));
139
- }
140
- //#endregion
141
- //#region src/promise/deletion.ts
142
- var deletion_exports = /* @__PURE__ */ __exportAll({
143
- Authorization: () => Authorization$1,
144
- Error: () => Error$1,
145
- Operation: () => Operation$1,
146
- PartialError: () => PartialError,
147
- Plan: () => Plan,
148
- Receipt: () => Receipt$1,
149
- apply: () => apply$1,
150
- authorize: () => authorize$1,
151
- create: () => create$1
215
+ const ApplyOutcomeFields = {
216
+ operationId: Schema.String,
217
+ receiptId: Schema.String,
218
+ results: Schema.Array(OperationResult)
219
+ };
220
+ const ApplyResult = Schema.TaggedUnion({
221
+ Applied: ApplyOutcomeFields,
222
+ Partial: ApplyOutcomeFields,
223
+ Stale: { message: Schema.String }
152
224
  });
153
- function create$1(input) {
154
- return Effect.runPromise(create$2({
155
- plan: input.plan,
156
- receipt: input.receipt,
157
- ...input.ttlMs === void 0 ? {} : { ttlMs: input.ttlMs }
158
- }).pipe(Effect.provide(Layer.merge(layerFromAsync(input.provider), webCryptoLayer))));
159
- }
160
- function authorize$1(plan, operationIds) {
161
- return Effect.runPromise(authorize$3(plan, operationIds).pipe(Effect.provide(webCryptoLayer)));
162
- }
163
- function apply$1(input) {
164
- return Effect.runPromise(apply$2({
165
- authorization: input.authorization,
166
- plan: input.plan,
167
- ...input.priorReceipt === void 0 ? {} : { priorReceipt: input.priorReceipt }
168
- }).pipe(Effect.provide(Layer.merge(layerFromAsync(input.provider), webCryptoLayer))));
169
- }
170
- //#endregion
171
- //#region src/promise/provisioning.ts
172
- var provisioning_exports = /* @__PURE__ */ __exportAll({
173
- CreateResult: () => CreateResult,
174
- Target: () => Target,
175
- apply: () => apply,
176
- authorize: () => authorize,
177
- authorizeForConnection: () => authorizeForConnection,
178
- create: () => create,
179
- renderManualInstructions: () => renderManualInstructions
225
+ const ObservationEvidence = Schema.TaggedUnion({
226
+ Found: { recordId: Schema.String },
227
+ Mismatch: {
228
+ message: Schema.String,
229
+ recordId: Schema.String
230
+ },
231
+ Missing: { recordId: Schema.String },
232
+ Unavailable: {
233
+ message: Schema.String,
234
+ recordId: Schema.String
235
+ }
180
236
  });
181
- function create(input) {
182
- if ("sources" in input) {
183
- const { sources, ...programInput } = input;
184
- return Effect.runPromise(create$3(programInput).pipe(Effect.provide(Layer.merge(Layer.succeed(Service$2, make$5(sources.map(toEffectSource))), webCryptoLayer))));
237
+ const Observation = Schema.TaggedStruct("Observation", {
238
+ provider: Schema.Array(ObservationEvidence),
239
+ publicDns: Schema.Array(ObservationEvidence)
240
+ });
241
+ const CleanupOperation = Schema.TaggedUnion({
242
+ AlreadyAbsent: {
243
+ id: Schema.String,
244
+ record: DnsRecord
245
+ },
246
+ Blocked: {
247
+ id: Schema.String,
248
+ reason: Schema.String,
249
+ record: DnsRecord
250
+ },
251
+ Delete: {
252
+ id: Schema.String,
253
+ record: DnsRecord
185
254
  }
186
- const { provider, ...programInput } = input;
187
- return Effect.runPromise(create$3(programInput).pipe(Effect.provide(Layer.merge(layerFromAsync(provider), webCryptoLayer))));
188
- }
189
- function authorize(plan, operationIds, options = {}) {
190
- return Effect.runPromise(authorize$4(plan, operationIds, options).pipe(Effect.provide(webCryptoLayer)));
191
- }
192
- function apply(input) {
193
- return Effect.runPromise(apply$3({
194
- authorization: input.authorization,
195
- plan: input.plan
196
- }).pipe(Effect.provide(Layer.merge(layerFromAsync(input.provider), webCryptoLayer))));
197
- }
198
- function authorizeForConnection(input) {
199
- return Effect.runPromise(authorize$2(input).pipe(Effect.provide(webCryptoLayer)));
200
- }
201
- const renderManualInstructions = renderManualInstructions$1;
202
- //#endregion
203
- //#region src/promise/verification.ts
204
- var verification_exports = /* @__PURE__ */ __exportAll({
205
- Provider: () => Provider,
206
- ProviderObservation: () => ProviderObservation,
207
- PublicDns: () => PublicDns,
208
- PublicDnsObservation: () => PublicDnsObservation,
209
- Result: () => Result,
210
- observe: () => observe
211
255
  });
212
- const PublicDns = PublicDns$1;
213
- const Provider = Data.taggedEnum();
214
- function observe(input) {
215
- const provider = input.provider ?? Provider.Disabled();
216
- let program = provider._tag === "Enabled" ? observe$1({
217
- record: input.record,
218
- ...input.publicDns === void 0 ? {} : { publicDns: input.publicDns },
219
- provider: Provider$1.Enabled({ zone: provider.zone })
220
- }).pipe(Effect.provide(layerFromAsync(provider.provider))) : observe$1({
221
- record: input.record,
222
- ...input.publicDns === void 0 ? {} : { publicDns: input.publicDns },
223
- provider: Provider$1.Disabled()
224
- });
225
- if (input.resolvers !== void 0) program = program.pipe(Effect.provide(Layer.succeed(Service$1, make$4(input.resolvers.map((entry) => ({
226
- id: entry.id,
227
- resolver: fromAsyncResolver(entry.resolver),
228
- ...entry.timeoutMs === void 0 ? {} : { timeoutMs: entry.timeoutMs }
229
- }))))));
230
- return Effect.runPromise(program);
231
- }
232
- function fromAsyncResolver(resolver) {
233
- return { resolve: (query) => Effect.tryPromise({
234
- try: () => resolver.resolve(query),
235
- catch: (cause) => new Error$2({
236
- cause,
237
- message: cause instanceof globalThis.Error ? cause.message : String(cause),
238
- reason: "transport"
239
- })
240
- }).pipe(Effect.flatMap((resolution) => {
241
- switch (resolution._tag) {
242
- case "answer":
243
- case "nodata": return Effect.succeed(resolution);
244
- case "timeout": return Effect.fail(new Error$2({
245
- message: "DNS query timed out",
246
- reason: "timeout"
247
- }));
248
- case "failure": return Effect.fail(new Error$2({
249
- message: resolution.message,
250
- reason: "transport"
251
- }));
252
- }
253
- })) };
254
- }
255
- //#endregion
256
- //#region src/promise/cloudflare-doh.ts
257
- var cloudflare_doh_exports = /* @__PURE__ */ __exportAll({ make: () => make$3 });
258
- function make$3(options = {}) {
259
- return toAsync$1(options);
260
- }
261
- //#endregion
262
- //#region src/promise/doh.ts
263
- var doh_exports = /* @__PURE__ */ __exportAll({ make: () => make$2 });
264
- function make$2(options) {
265
- return toAsync$2(options);
266
- }
267
- //#endregion
268
- //#region src/promise/google-doh.ts
269
- var google_doh_exports = /* @__PURE__ */ __exportAll({ make: () => make$1 });
270
- function make$1(options = {}) {
271
- return toAsync$3(options);
272
- }
273
- //#endregion
274
- //#region src/promise/resolver-pool.ts
275
- var resolver_pool_exports = /* @__PURE__ */ __exportAll({
276
- Observation: () => Observation,
277
- Policy: () => Policy,
278
- defaultMake: () => defaultMake,
279
- make: () => make
256
+ const CleanupPlan = Schema.TaggedStruct("CleanupPlan", {
257
+ digest: Schema.String,
258
+ expiresAt: Schema.String,
259
+ operations: Schema.Array(CleanupOperation)
260
+ });
261
+ const CleanupOutcomeFields = {
262
+ operationId: Schema.String,
263
+ results: Schema.Array(OperationResult)
264
+ };
265
+ const CleanupResult = Schema.TaggedUnion({
266
+ Cleaned: CleanupOutcomeFields,
267
+ Partial: CleanupOutcomeFields,
268
+ Stale: { message: Schema.String }
280
269
  });
281
- function make(entries) {
282
- return toAsync(make$4(entries.map((entry) => ({
283
- id: entry.id,
284
- resolver: asyncResolver(entry.resolver),
285
- ...entry.timeoutMs === void 0 ? {} : { timeoutMs: entry.timeoutMs }
286
- }))));
287
- }
288
- function defaultMake(options = {}) {
289
- return toAsync(defaultMake$1(options));
290
- }
291
- function toAsync(pool) {
292
- return { observe: (query) => Effect.runPromise(pool.observe(query)) };
293
- }
294
- function asyncResolver(resolver) {
295
- return { resolve: (query) => Effect.tryPromise({
296
- try: () => resolver.resolve(query),
297
- catch: (cause) => new Error$2({
298
- cause,
270
+ var Service = class extends Context.Service()("@domainkit/Transport") {};
271
+ /** Converts a Promise-shaped host implementation into the canonical Effect service. */
272
+ const fromAsync = (transport, options = {}) => {
273
+ const attempt = (operation, evaluate) => Effect.tryPromise({
274
+ try: evaluate,
275
+ catch: (cause) => options.onError?.(operation, cause) ?? (cause instanceof Failure ? cause : new Failure({
299
276
  message: cause instanceof globalThis.Error ? cause.message : String(cause),
300
- reason: "transport"
301
- })
302
- }).pipe(Effect.flatMap((resolution) => {
303
- switch (resolution._tag) {
304
- case "answer":
305
- case "nodata": return Effect.succeed(resolution);
306
- case "timeout": return Effect.fail(new Error$2({
307
- message: "DNS query timed out",
308
- reason: "timeout"
309
- }));
310
- case "failure": return Effect.fail(new Error$2({
311
- message: resolution.message,
312
- reason: "transport"
313
- }));
314
- }
315
- })) };
316
- }
277
+ operation,
278
+ retry: "unknown"
279
+ }))
280
+ });
281
+ return Service.of({
282
+ cleanup: {
283
+ apply: (input) => attempt("cleanup.apply", () => transport.cleanup.apply(input)),
284
+ plan: (input) => attempt("cleanup.plan", () => transport.cleanup.plan(input))
285
+ },
286
+ connection: {
287
+ connect: (input) => attempt("connection.connect", () => transport.connection.connect(input)),
288
+ inspect: (input) => attempt("connection.inspect", () => transport.connection.inspect(input)),
289
+ removeDomain: (input) => attempt("connection.removeDomain", () => transport.connection.removeDomain(input)),
290
+ reuse: (input) => attempt("connection.reuse", () => transport.connection.reuse(input))
291
+ },
292
+ provisioning: {
293
+ apply: (input) => attempt("provisioning.apply", () => transport.provisioning.apply(input)),
294
+ plan: (input) => attempt("provisioning.plan", () => transport.provisioning.plan(input))
295
+ },
296
+ verification: { observe: (input) => attempt("verification.observe", () => transport.verification.observe(input)) }
297
+ });
298
+ };
299
+ const layerFromAsync = (transport, options) => Layer.succeed(Service, fromAsync(transport, options));
300
+ /** Converts an environment-free Effect service into its Promise-shaped host seam. */
301
+ const toAsync = (transport) => ({
302
+ cleanup: {
303
+ apply: (input) => Effect.runPromise(transport.cleanup.apply(input)),
304
+ plan: (input) => Effect.runPromise(transport.cleanup.plan(input))
305
+ },
306
+ connection: {
307
+ connect: (input) => Effect.runPromise(transport.connection.connect(input)),
308
+ inspect: (input) => Effect.runPromise(transport.connection.inspect(input)),
309
+ removeDomain: (input) => Effect.runPromise(transport.connection.removeDomain(input)),
310
+ reuse: (input) => Effect.runPromise(transport.connection.reuse(input))
311
+ },
312
+ provisioning: {
313
+ apply: (input) => Effect.runPromise(transport.provisioning.apply(input)),
314
+ plan: (input) => Effect.runPromise(transport.provisioning.plan(input))
315
+ },
316
+ verification: { observe: (input) => Effect.runPromise(transport.verification.observe(input)) }
317
+ });
317
318
  //#endregion
318
319
  //#region src/index.ts
319
320
  /** The current package version from the package manifest. */
320
321
  const VERSION = version;
321
322
  //#endregion
322
- export { authorization_lifecycle_exports as AuthorizationLifecycle, cloudflare_exports as Cloudflare, cloudflare_doh_exports as CloudflareDnsOverHttps, connection_exports as Connection, deletion_exports as Deletion, diagnostic_exports as Diagnostic, doh_exports as DnsOverHttps, dns_plan_exports as DnsPlan, dns_record_exports as DnsRecord, resolver_pool_exports as DnsResolverPool, domain_name_exports as DomainName, google_doh_exports as GoogleDnsOverHttps, invalid_input_exports as InvalidInput, provider_auth_exports as ProviderAuth, provider_authorization_exports as ProviderAuthorization, provider_context_exports as ProviderContext, selection_exports as ProviderDiscovery, provisioning_exports as Provisioning, secret_exports as Secret, VERSION, vercel_exports as Vercel, verification_exports as Verification, zone_discovery_exports as ZoneDiscovery, zones_exports as Zones };
323
+ export { lifecycle_repository_exports as AuthorizationLifecycle, cloudflare_exports as Cloudflare, cloudflare_doh_exports as CloudflareDnsOverHttps, connection_api_exports as Connection, connection_authorization_exports as ConnectionAuthorization, deletion_exports as Deletion, diagnostic_exports as Diagnostic, canonical_json_exports as Digest, dns_data_exports as DnsData, doh_exports as DnsOverHttps, types_exports as DnsPlan, provider_exports as DnsProvider, dns_record_exports as DnsRecord, resolver_exports as DnsResolver, resolver_pool_exports as DnsResolverPool, domain_name_exports as DomainName, google_doh_exports as GoogleDnsOverHttps, invalid_input_exports as InvalidInput, manifest_exports as ProviderAuth, authorization_exports as ProviderAuthorization, provider_context_exports as ProviderContext, selection_exports as ProviderDiscovery, plan_exports as Provisioning, secret_exports as Secret, transport_exports as Transport, VERSION, vercel_exports as Vercel, verify_exports as Verification, zone_discovery_exports as ZoneDiscovery, zones_exports as Zones };
323
324
 
324
325
  //# sourceMappingURL=index.mjs.map