@geekmidas/edge 0.0.0-stage → 10.0.0-alpha.182

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 (84) hide show
  1. package/README.md +14 -2
  2. package/dist/certificates/local.cjs +393 -0
  3. package/dist/certificates/local.cjs.map +1 -0
  4. package/dist/certificates/local.d.cts +92 -0
  5. package/dist/certificates/local.d.cts.map +1 -0
  6. package/dist/certificates/local.d.mts +92 -0
  7. package/dist/certificates/local.d.mts.map +1 -0
  8. package/dist/certificates/local.mjs +361 -0
  9. package/dist/certificates/local.mjs.map +1 -0
  10. package/dist/compose-BHWyQvsD.cjs +22 -0
  11. package/dist/compose-BHWyQvsD.cjs.map +1 -0
  12. package/dist/compose-CcNlj65h.mjs +17 -0
  13. package/dist/compose-CcNlj65h.mjs.map +1 -0
  14. package/dist/dns/godaddy/index.cjs +448 -0
  15. package/dist/dns/godaddy/index.cjs.map +1 -0
  16. package/dist/dns/godaddy/index.d.cts +164 -0
  17. package/dist/dns/godaddy/index.d.cts.map +1 -0
  18. package/dist/dns/godaddy/index.d.mts +164 -0
  19. package/dist/dns/godaddy/index.d.mts.map +1 -0
  20. package/dist/dns/godaddy/index.mjs +435 -0
  21. package/dist/dns/godaddy/index.mjs.map +1 -0
  22. package/dist/dns/hostinger/index.cjs +252 -0
  23. package/dist/dns/hostinger/index.cjs.map +1 -0
  24. package/dist/dns/hostinger/index.d.cts +143 -0
  25. package/dist/dns/hostinger/index.d.cts.map +1 -0
  26. package/dist/dns/hostinger/index.d.mts +143 -0
  27. package/dist/dns/hostinger/index.d.mts.map +1 -0
  28. package/dist/dns/hostinger/index.mjs +249 -0
  29. package/dist/dns/hostinger/index.mjs.map +1 -0
  30. package/dist/dns/index.cjs +76 -0
  31. package/dist/dns/index.cjs.map +1 -0
  32. package/dist/dns/index.d.cts +144 -0
  33. package/dist/dns/index.d.cts.map +1 -0
  34. package/dist/dns/index.d.mts +144 -0
  35. package/dist/dns/index.d.mts.map +1 -0
  36. package/dist/dns/index.mjs +71 -0
  37. package/dist/dns/index.mjs.map +1 -0
  38. package/dist/dns/route53.cjs +210 -0
  39. package/dist/dns/route53.cjs.map +1 -0
  40. package/dist/dns/route53.d.cts +45 -0
  41. package/dist/dns/route53.d.cts.map +1 -0
  42. package/dist/dns/route53.d.mts +45 -0
  43. package/dist/dns/route53.d.mts.map +1 -0
  44. package/dist/dns/route53.mjs +209 -0
  45. package/dist/dns/route53.mjs.map +1 -0
  46. package/dist/errors-CO33_TDV.mjs +16 -0
  47. package/dist/errors-CO33_TDV.mjs.map +1 -0
  48. package/dist/errors-DBZfelEN.d.cts +13 -0
  49. package/dist/errors-DBZfelEN.d.cts.map +1 -0
  50. package/dist/errors-DBZfelEN.d.mts +13 -0
  51. package/dist/errors-DBZfelEN.d.mts.map +1 -0
  52. package/dist/errors-DlRLQOyZ.cjs +27 -0
  53. package/dist/errors-DlRLQOyZ.cjs.map +1 -0
  54. package/dist/index.cjs +6 -0
  55. package/dist/index.d.cts +15 -0
  56. package/dist/index.d.cts.map +1 -0
  57. package/dist/index.d.mts +15 -0
  58. package/dist/index.d.mts.map +1 -0
  59. package/dist/index.mjs +3 -0
  60. package/dist/proxy/caddy.cjs +167 -0
  61. package/dist/proxy/caddy.cjs.map +1 -0
  62. package/dist/proxy/caddy.d.cts +35 -0
  63. package/dist/proxy/caddy.d.cts.map +1 -0
  64. package/dist/proxy/caddy.d.mts +35 -0
  65. package/dist/proxy/caddy.d.mts.map +1 -0
  66. package/dist/proxy/caddy.mjs +164 -0
  67. package/dist/proxy/caddy.mjs.map +1 -0
  68. package/dist/proxy/traefik.cjs +460 -0
  69. package/dist/proxy/traefik.cjs.map +1 -0
  70. package/dist/proxy/traefik.d.cts +129 -0
  71. package/dist/proxy/traefik.d.cts.map +1 -0
  72. package/dist/proxy/traefik.d.mts +129 -0
  73. package/dist/proxy/traefik.d.mts.map +1 -0
  74. package/dist/proxy/traefik.mjs +437 -0
  75. package/dist/proxy/traefik.mjs.map +1 -0
  76. package/dist/routes/index.cjs +49 -0
  77. package/dist/routes/index.cjs.map +1 -0
  78. package/dist/routes/index.d.cts +205 -0
  79. package/dist/routes/index.d.cts.map +1 -0
  80. package/dist/routes/index.d.mts +205 -0
  81. package/dist/routes/index.d.mts.map +1 -0
  82. package/dist/routes/index.mjs +44 -0
  83. package/dist/routes/index.mjs.map +1 -0
  84. package/package.json +131 -3
@@ -0,0 +1,249 @@
1
+ //#region src/dns/hostinger/api.ts
2
+ /**
3
+ * Hostinger DNS API client
4
+ *
5
+ * API Documentation: https://developers.hostinger.com/
6
+ * Authentication: Bearer token from hpanel.hostinger.com/profile/api
7
+ */
8
+ const HOSTINGER_API_BASE = "https://developers.hostinger.com";
9
+ /**
10
+ * Hostinger API error
11
+ */
12
+ var HostingerApiError = class extends Error {
13
+ status;
14
+ statusText;
15
+ errors;
16
+ constructor(message, status, statusText, errors) {
17
+ super(message);
18
+ this.status = status;
19
+ this.statusText = statusText;
20
+ this.errors = errors;
21
+ this.name = "HostingerApiError";
22
+ }
23
+ };
24
+ /**
25
+ * Hostinger DNS API client
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const api = new HostingerApi(token);
30
+ *
31
+ * // Get all records for a domain
32
+ * const records = await api.getRecords('traflabs.io');
33
+ *
34
+ * // Create/update records
35
+ * await api.upsertRecords('traflabs.io', [
36
+ * { name: 'api.joemoer', type: 'A', ttl: 300, records: ['1.2.3.4'] }
37
+ * ]);
38
+ * ```
39
+ */
40
+ var HostingerApi = class {
41
+ token;
42
+ constructor(token) {
43
+ this.token = token;
44
+ }
45
+ /**
46
+ * Make a request to the Hostinger API
47
+ */
48
+ async request(method, endpoint, body) {
49
+ const url = `${HOSTINGER_API_BASE}${endpoint}`;
50
+ const response = await fetch(url, {
51
+ method,
52
+ headers: {
53
+ "Content-Type": "application/json",
54
+ Authorization: `Bearer ${this.token}`
55
+ },
56
+ body: body ? JSON.stringify(body) : void 0
57
+ });
58
+ if (!response.ok) {
59
+ let errorMessage = `Hostinger API error: ${response.status} ${response.statusText}`;
60
+ let errors;
61
+ try {
62
+ const errorBody = await response.json();
63
+ if (errorBody.message) errorMessage = `Hostinger API error: ${errorBody.message}`;
64
+ errors = errorBody.errors;
65
+ } catch {}
66
+ throw new HostingerApiError(errorMessage, response.status, response.statusText, errors);
67
+ }
68
+ const text = await response.text();
69
+ if (!text || text.trim() === "") return;
70
+ return JSON.parse(text);
71
+ }
72
+ /**
73
+ * Get all DNS records for a domain
74
+ *
75
+ * @param domain - Root domain (e.g., 'traflabs.io')
76
+ */
77
+ async getRecords(domain) {
78
+ const response = await this.request("GET", `/api/dns/v1/zones/${domain}`);
79
+ if (Array.isArray(response)) return response;
80
+ return response?.data ?? [];
81
+ }
82
+ /**
83
+ * Create or update DNS records
84
+ *
85
+ * @param domain - Root domain (e.g., 'traflabs.io')
86
+ * @param records - Records to create/update
87
+ * @param overwrite - If true, replaces all existing records. If false, merges with existing.
88
+ */
89
+ async upsertRecords(domain, records, overwrite = false) {
90
+ await this.request("PUT", `/api/dns/v1/zones/${domain}`, {
91
+ overwrite,
92
+ zone: records
93
+ });
94
+ }
95
+ /**
96
+ * Validate DNS records before applying
97
+ *
98
+ * @param domain - Root domain (e.g., 'traflabs.io')
99
+ * @param records - Records to validate
100
+ * @returns true if valid, throws if invalid
101
+ */
102
+ async validateRecords(domain, records) {
103
+ await this.request("POST", `/api/dns/v1/zones/${domain}/validate`, {
104
+ overwrite: false,
105
+ zone: records
106
+ });
107
+ return true;
108
+ }
109
+ /**
110
+ * Delete specific DNS records
111
+ *
112
+ * @param domain - Root domain (e.g., 'traflabs.io')
113
+ * @param filters - Filters to match records for deletion
114
+ */
115
+ async deleteRecords(domain, filters) {
116
+ await this.request("DELETE", `/api/dns/v1/zones/${domain}`, { filters });
117
+ }
118
+ /**
119
+ * Check if a specific record exists
120
+ *
121
+ * @param domain - Root domain (e.g., 'traflabs.io')
122
+ * @param name - Subdomain name (e.g., 'api.joemoer')
123
+ * @param type - Record type (e.g., 'A')
124
+ */
125
+ async recordExists(domain, name, type = "A") {
126
+ return (await this.getRecords(domain)).some((r) => r.name === name && r.type === type);
127
+ }
128
+ /**
129
+ * Create a single A record if it doesn't exist
130
+ *
131
+ * @param domain - Root domain (e.g., 'traflabs.io')
132
+ * @param subdomain - Subdomain name (e.g., 'api.joemoer')
133
+ * @param ip - IP address to point to
134
+ * @param ttl - TTL in seconds (default: 300)
135
+ * @returns true if created, false if already exists
136
+ */
137
+ async createARecordIfNotExists(domain, subdomain, ip, ttl = 300) {
138
+ if (await this.recordExists(domain, subdomain, "A")) return false;
139
+ await this.upsertRecords(domain, [{
140
+ name: subdomain,
141
+ type: "A",
142
+ ttl,
143
+ records: [{ content: ip }]
144
+ }]);
145
+ return true;
146
+ }
147
+ };
148
+ //#endregion
149
+ //#region src/dns/hostinger/index.ts
150
+ /** A value compared the way DNS does: case, a trailing dot and spacing aside. */
151
+ function normalize(value) {
152
+ return value.trim().replace(/\.$/, "").replace(/\s+/g, " ").toLowerCase();
153
+ }
154
+ /**
155
+ * Hostinger DNS provider implementation.
156
+ */
157
+ var HostingerProvider = class {
158
+ credential;
159
+ name = "hostinger";
160
+ api = null;
161
+ /**
162
+ * `credential`: where the token comes from, asked the first time the API
163
+ * is called. It throws when there is none: what to do about a missing
164
+ * token is the caller's to say.
165
+ */
166
+ constructor(credential) {
167
+ this.credential = credential;
168
+ }
169
+ /**
170
+ * Get or create the Hostinger API client.
171
+ */
172
+ async getApi() {
173
+ if (this.api) return this.api;
174
+ const { token } = await this.credential();
175
+ this.api = new HostingerApi(token);
176
+ return this.api;
177
+ }
178
+ async getRecords(domain) {
179
+ return (await (await this.getApi()).getRecords(domain)).map((r) => ({
180
+ name: r.name,
181
+ type: r.type,
182
+ ttl: r.ttl,
183
+ values: r.records.map((rec) => rec.content)
184
+ }));
185
+ }
186
+ async upsertRecords(domain, records) {
187
+ const api = await this.getApi();
188
+ const results = [];
189
+ const existingRecords = await api.getRecords(domain);
190
+ for (const record of records) {
191
+ const existing = existingRecords.find((r) => r.name === record.name && r.type === record.type);
192
+ const existingValue = existing?.records?.[0]?.content;
193
+ if (existing && existingValue !== void 0 && normalize(existingValue) === normalize(record.value)) {
194
+ results.push({
195
+ record,
196
+ created: false,
197
+ unchanged: true
198
+ });
199
+ continue;
200
+ }
201
+ await api.upsertRecords(domain, [{
202
+ name: record.name,
203
+ type: record.type,
204
+ ttl: record.ttl,
205
+ records: [{ content: record.value }]
206
+ }], true);
207
+ results.push({
208
+ record,
209
+ created: !existing,
210
+ unchanged: false
211
+ });
212
+ }
213
+ return results;
214
+ }
215
+ async deleteRecords(domain, records) {
216
+ const api = await this.getApi();
217
+ const results = [];
218
+ const existingRecords = await api.getRecords(domain);
219
+ const recordsToDelete = records.filter((record) => existingRecords.some((r) => r.name === record.name && r.type === record.type));
220
+ if (recordsToDelete.length > 0) try {
221
+ await api.deleteRecords(domain, recordsToDelete.map((r) => ({
222
+ name: r.name,
223
+ type: r.type
224
+ })));
225
+ for (const record of recordsToDelete) results.push({
226
+ record,
227
+ deleted: true,
228
+ notFound: false
229
+ });
230
+ } catch (error) {
231
+ for (const record of recordsToDelete) results.push({
232
+ record,
233
+ deleted: false,
234
+ notFound: false,
235
+ error: String(error)
236
+ });
237
+ }
238
+ for (const record of records) if (!existingRecords.find((r) => r.name === record.name && r.type === record.type)) results.push({
239
+ record,
240
+ deleted: false,
241
+ notFound: true
242
+ });
243
+ return results;
244
+ }
245
+ };
246
+ //#endregion
247
+ export { HostingerApi, HostingerApiError, HostingerProvider };
248
+
249
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/dns/hostinger/api.ts","../../../src/dns/hostinger/index.ts"],"sourcesContent":["/**\n * Hostinger DNS API client\n *\n * API Documentation: https://developers.hostinger.com/\n * Authentication: Bearer token from hpanel.hostinger.com/profile/api\n */\n\nconst HOSTINGER_API_BASE = 'https://developers.hostinger.com';\n\n/**\n * DNS record types supported by Hostinger\n */\nexport type DnsRecordType =\n\t| 'A'\n\t| 'AAAA'\n\t| 'CNAME'\n\t| 'MX'\n\t| 'TXT'\n\t| 'NS'\n\t| 'SRV'\n\t| 'CAA';\n\n/**\n * A single DNS record\n */\nexport interface DnsRecord {\n\t/** Subdomain name (e.g., 'api.joemoer' for api.joemoer.traflabs.io) */\n\tname: string;\n\t/** Record type */\n\ttype: DnsRecordType;\n\t/** TTL in seconds */\n\tttl: number;\n\t/** Record values */\n\trecords: Array<{ content: string }>;\n}\n\n/**\n * Filter for deleting specific records\n */\nexport interface DnsRecordFilter {\n\tname: string;\n\ttype: DnsRecordType;\n}\n\n/**\n * API error response\n */\nexport interface HostingerErrorResponse {\n\tmessage?: string;\n\terrors?: Record<string, string[]>;\n}\n\n/**\n * Hostinger API error\n */\nexport class HostingerApiError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic status: number,\n\t\tpublic statusText: string,\n\t\tpublic errors?: Record<string, string[]>,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'HostingerApiError';\n\t}\n}\n\n/**\n * Hostinger DNS API client\n *\n * @example\n * ```ts\n * const api = new HostingerApi(token);\n *\n * // Get all records for a domain\n * const records = await api.getRecords('traflabs.io');\n *\n * // Create/update records\n * await api.upsertRecords('traflabs.io', [\n * { name: 'api.joemoer', type: 'A', ttl: 300, records: ['1.2.3.4'] }\n * ]);\n * ```\n */\nexport class HostingerApi {\n\tprivate token: string;\n\n\tconstructor(token: string) {\n\t\tthis.token = token;\n\t}\n\n\t/**\n\t * Make a request to the Hostinger API\n\t */\n\tprivate async request<T>(\n\t\tmethod: 'GET' | 'POST' | 'PUT' | 'DELETE',\n\t\tendpoint: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst url = `${HOSTINGER_API_BASE}${endpoint}`;\n\n\t\tconst response = await fetch(url, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\n\t\t\t},\n\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tlet errorMessage = `Hostinger API error: ${response.status} ${response.statusText}`;\n\t\t\tlet errors: Record<string, string[]> | undefined;\n\n\t\t\ttry {\n\t\t\t\tconst errorBody = (await response.json()) as HostingerErrorResponse;\n\t\t\t\tif (errorBody.message) {\n\t\t\t\t\terrorMessage = `Hostinger API error: ${errorBody.message}`;\n\t\t\t\t}\n\t\t\t\terrors = errorBody.errors;\n\t\t\t} catch {\n\t\t\t\t// Ignore JSON parse errors\n\t\t\t}\n\n\t\t\tthrow new HostingerApiError(\n\t\t\t\terrorMessage,\n\t\t\t\tresponse.status,\n\t\t\t\tresponse.statusText,\n\t\t\t\terrors,\n\t\t\t);\n\t\t}\n\n\t\t// Handle empty responses\n\t\tconst text = await response.text();\n\t\tif (!text || text.trim() === '') {\n\t\t\treturn undefined as T;\n\t\t}\n\t\treturn JSON.parse(text) as T;\n\t}\n\n\t/**\n\t * Get all DNS records for a domain\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t */\n\tasync getRecords(domain: string): Promise<DnsRecord[]> {\n\t\t// The zone comes back as a **bare array**, not `{ data: [...] }`.\n\t\t//\n\t\t// This read `response.data || []`, so every call returned zero records\n\t\t// against the real API while every mocked test passed. Silently: no error,\n\t\t// no warning, just an empty zone. `upsertRecords` uses this to decide what\n\t\t// already exists, so everything looked new and every write was reported as\n\t\t// a creation — harmless only because the PUT merges rather than replaces.\n\t\t//\n\t\t// Both shapes are accepted because one of them is a guess: the wrapper was\n\t\t// written against documentation and the array is what the API actually\n\t\t// sends, so tolerating an envelope costs a line and survives it appearing.\n\t\tconst response = await this.request<DnsRecord[] | { data?: DnsRecord[] }>(\n\t\t\t'GET',\n\t\t\t`/api/dns/v1/zones/${domain}`,\n\t\t);\n\n\t\tif (Array.isArray(response)) return response;\n\n\t\treturn response?.data ?? [];\n\t}\n\n\t/**\n\t * Create or update DNS records\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param records - Records to create/update\n\t * @param overwrite - If true, replaces all existing records. If false, merges with existing.\n\t */\n\tasync upsertRecords(\n\t\tdomain: string,\n\t\trecords: DnsRecord[],\n\t\toverwrite = false,\n\t): Promise<void> {\n\t\tawait this.request('PUT', `/api/dns/v1/zones/${domain}`, {\n\t\t\toverwrite,\n\t\t\tzone: records,\n\t\t});\n\t}\n\n\t/**\n\t * Validate DNS records before applying\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param records - Records to validate\n\t * @returns true if valid, throws if invalid\n\t */\n\tasync validateRecords(\n\t\tdomain: string,\n\t\trecords: DnsRecord[],\n\t): Promise<boolean> {\n\t\tawait this.request('POST', `/api/dns/v1/zones/${domain}/validate`, {\n\t\t\toverwrite: false,\n\t\t\tzone: records,\n\t\t});\n\t\treturn true;\n\t}\n\n\t/**\n\t * Delete specific DNS records\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param filters - Filters to match records for deletion\n\t */\n\tasync deleteRecords(\n\t\tdomain: string,\n\t\tfilters: DnsRecordFilter[],\n\t): Promise<void> {\n\t\tawait this.request('DELETE', `/api/dns/v1/zones/${domain}`, {\n\t\t\tfilters,\n\t\t});\n\t}\n\n\t/**\n\t * Check if a specific record exists\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param name - Subdomain name (e.g., 'api.joemoer')\n\t * @param type - Record type (e.g., 'A')\n\t */\n\tasync recordExists(\n\t\tdomain: string,\n\t\tname: string,\n\t\ttype: DnsRecordType = 'A',\n\t): Promise<boolean> {\n\t\tconst records = await this.getRecords(domain);\n\t\treturn records.some((r) => r.name === name && r.type === type);\n\t}\n\n\t/**\n\t * Create a single A record if it doesn't exist\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param subdomain - Subdomain name (e.g., 'api.joemoer')\n\t * @param ip - IP address to point to\n\t * @param ttl - TTL in seconds (default: 300)\n\t * @returns true if created, false if already exists\n\t */\n\tasync createARecordIfNotExists(\n\t\tdomain: string,\n\t\tsubdomain: string,\n\t\tip: string,\n\t\tttl = 300,\n\t): Promise<boolean> {\n\t\tconst exists = await this.recordExists(domain, subdomain, 'A');\n\t\tif (exists) {\n\t\t\treturn false;\n\t\t}\n\n\t\tawait this.upsertRecords(domain, [\n\t\t\t{\n\t\t\t\tname: subdomain,\n\t\t\t\ttype: 'A',\n\t\t\t\tttl,\n\t\t\t\trecords: [{ content: ip }],\n\t\t\t},\n\t\t]);\n\n\t\treturn true;\n\t}\n}\n","/**\n * Hostinger DNS Provider\n *\n * Implements DnsProvider interface using the Hostinger DNS API. A record's\n * `content` is its zone-file value — an MX record's is `<priority> <host>`,\n * Hostinger having no field of its own for the priority — so values pass\n * through as they are. Each write replaces its one name and type\n * (`overwrite: true`): without it Hostinger appends, and a record with\n * another value would end up holding both.\n */\n\nimport type {\n\tDeleteDnsRecord,\n\tDeleteResult,\n\tDnsProvider,\n\tDnsRecord,\n\tUpsertDnsRecord,\n\tUpsertResult,\n} from '../index';\nimport { HostingerApi } from './api';\n\n/** A Hostinger API token, from hpanel.hostinger.com/profile/api. */\nexport interface HostingerCredential {\n\ttoken: string;\n}\n\n/** A value compared the way DNS does: case, a trailing dot and spacing aside. */\nfunction normalize(value: string): string {\n\treturn value.trim().replace(/\\.$/, '').replace(/\\s+/g, ' ').toLowerCase();\n}\n\n/**\n * Hostinger DNS provider implementation.\n */\nexport class HostingerProvider implements DnsProvider {\n\treadonly name = 'hostinger';\n\tprivate api: HostingerApi | null = null;\n\n\t/**\n\t * `credential`: where the token comes from, asked the first time the API\n\t * is called. It throws when there is none: what to do about a missing\n\t * token is the caller's to say.\n\t */\n\tconstructor(\n\t\tprivate readonly credential: () => Promise<HostingerCredential>,\n\t) {}\n\n\t/**\n\t * Get or create the Hostinger API client.\n\t */\n\tprivate async getApi(): Promise<HostingerApi> {\n\t\tif (this.api) {\n\t\t\treturn this.api;\n\t\t}\n\n\t\tconst { token } = await this.credential();\n\n\t\tthis.api = new HostingerApi(token);\n\t\treturn this.api;\n\t}\n\n\tasync getRecords(domain: string): Promise<DnsRecord[]> {\n\t\tconst api = await this.getApi();\n\t\tconst records = await api.getRecords(domain);\n\n\t\treturn records.map((r) => ({\n\t\t\tname: r.name,\n\t\t\ttype: r.type,\n\t\t\tttl: r.ttl,\n\t\t\tvalues: r.records.map((rec) => rec.content),\n\t\t}));\n\t}\n\n\tasync upsertRecords(\n\t\tdomain: string,\n\t\trecords: UpsertDnsRecord[],\n\t): Promise<UpsertResult[]> {\n\t\tconst api = await this.getApi();\n\t\tconst results: UpsertResult[] = [];\n\n\t\t// Get existing records to check what already exists\n\t\tconst existingRecords = await api.getRecords(domain);\n\n\t\tfor (const record of records) {\n\t\t\tconst existing = existingRecords.find(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t);\n\n\t\t\tconst existingValue = existing?.records?.[0]?.content;\n\n\t\t\tif (\n\t\t\t\texisting &&\n\t\t\t\texistingValue !== undefined &&\n\t\t\t\tnormalize(existingValue) === normalize(record.value)\n\t\t\t) {\n\t\t\t\t// Record exists with same value - unchanged\n\t\t\t\tresults.push({\n\t\t\t\t\trecord,\n\t\t\t\t\tcreated: false,\n\t\t\t\t\tunchanged: true,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Create the record, or replace this name's records of this type.\n\t\t\tawait api.upsertRecords(\n\t\t\t\tdomain,\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tname: record.name,\n\t\t\t\t\t\ttype: record.type,\n\t\t\t\t\t\tttl: record.ttl,\n\t\t\t\t\t\trecords: [{ content: record.value }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tresults.push({\n\t\t\t\trecord,\n\t\t\t\tcreated: !existing,\n\t\t\t\tunchanged: false,\n\t\t\t});\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tasync deleteRecords(\n\t\tdomain: string,\n\t\trecords: DeleteDnsRecord[],\n\t): Promise<DeleteResult[]> {\n\t\tconst api = await this.getApi();\n\t\tconst results: DeleteResult[] = [];\n\n\t\t// Get existing records to check what exists\n\t\tconst existingRecords = await api.getRecords(domain);\n\n\t\t// Filter to only records that exist\n\t\tconst recordsToDelete = records.filter((record) =>\n\t\t\texistingRecords.some(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t),\n\t\t);\n\n\t\t// Delete existing records\n\t\tif (recordsToDelete.length > 0) {\n\t\t\ttry {\n\t\t\t\tawait api.deleteRecords(\n\t\t\t\t\tdomain,\n\t\t\t\t\trecordsToDelete.map((r) => ({\n\t\t\t\t\t\tname: r.name,\n\t\t\t\t\t\ttype: r.type as\n\t\t\t\t\t\t\t| 'A'\n\t\t\t\t\t\t\t| 'AAAA'\n\t\t\t\t\t\t\t| 'CNAME'\n\t\t\t\t\t\t\t| 'MX'\n\t\t\t\t\t\t\t| 'TXT'\n\t\t\t\t\t\t\t| 'SRV'\n\t\t\t\t\t\t\t| 'CAA',\n\t\t\t\t\t})),\n\t\t\t\t);\n\n\t\t\t\tfor (const record of recordsToDelete) {\n\t\t\t\t\tresults.push({\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\tdeleted: true,\n\t\t\t\t\t\tnotFound: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// If batch delete fails, report error for all records\n\t\t\t\tfor (const record of recordsToDelete) {\n\t\t\t\t\tresults.push({\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t\tnotFound: false,\n\t\t\t\t\t\terror: String(error),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Mark non-existent records as not found\n\t\tfor (const record of records) {\n\t\t\tconst existing = existingRecords.find(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t);\n\t\t\tif (!existing) {\n\t\t\t\tresults.push({\n\t\t\t\t\trecord,\n\t\t\t\t\tdeleted: false,\n\t\t\t\t\tnotFound: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n}\n\nexport { HostingerApi, HostingerApiError } from './api';\n"],"mappings":"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"}
@@ -0,0 +1,76 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_errors = require("../errors-DlRLQOyZ.cjs");
3
+ //#region src/dns/index.ts
4
+ /**
5
+ * DNS Provider Interface
6
+ *
7
+ * Abstracts DNS operations for different providers.
8
+ * Built-in providers: HostingerProvider, Route53Provider, GoDaddyProvider
9
+ * Users can also supply custom implementations.
10
+ *
11
+ * Every value is the record's zone-file form, read and written alike: an MX
12
+ * record's is `<priority> <host>` (see {@link mxValue}).
13
+ */
14
+ /**
15
+ * An MX record's value as every provider here reads and writes it — the zone
16
+ * file's `<priority> <host>`, which is what Route53 and Hostinger take as is.
17
+ * A provider whose API keeps the priority apart (GoDaddy) splits it with
18
+ * {@link parseMxValue}.
19
+ */
20
+ function mxValue(priority, host) {
21
+ return `${priority} ${host.trim().replace(/\.$/, "")}`;
22
+ }
23
+ /** An MX value that is not `<priority> <host>`. */
24
+ var MxValueInvalid = class extends require_errors.EdgeError {
25
+ value;
26
+ constructor(value) {
27
+ super(`'${value}' is not an MX record's value: it is written '<priority> <host>', like '10 inbound-smtp.eu-west-1.amazonaws.com'. Build it with mxValue(priority, host).`);
28
+ this.value = value;
29
+ this.name = "MxValueInvalid";
30
+ }
31
+ };
32
+ /**
33
+ * The priority and host of an MX value.
34
+ *
35
+ * @throws {MxValueInvalid} for a value that is not `<priority> <host>`
36
+ */
37
+ function parseMxValue(value) {
38
+ const match = value.trim().match(/^(\d{1,5})\s+(\S+)$/);
39
+ const priority = match ? Number(match[1]) : NaN;
40
+ if (!match || priority > 65535) throw new MxValueInvalid(value);
41
+ return {
42
+ priority,
43
+ host: match[2].replace(/\.$/, "")
44
+ };
45
+ }
46
+ /**
47
+ * Check if value is a DnsProvider implementation.
48
+ */
49
+ function isDnsProvider(value) {
50
+ return typeof value === "object" && value !== null && typeof value.name === "string" && typeof value.getRecords === "function" && typeof value.upsertRecords === "function" && typeof value.deleteRecords === "function";
51
+ }
52
+ /**
53
+ * The provider's credentials can write records and not read them — a key
54
+ * scoped to updates only. What reads them falls back to writing every record,
55
+ * which is idempotent, without a diff.
56
+ */
57
+ var DnsRecordsUnreadable = class extends require_errors.EdgeError {
58
+ provider;
59
+ domain;
60
+ reason;
61
+ constructor(provider, domain, reason) {
62
+ super(`The ${provider} key cannot read ${domain}'s DNS records (${reason}), so changes cannot be compared with what is there: every record is written, which leaves one that already has its value as it was.`);
63
+ this.provider = provider;
64
+ this.domain = domain;
65
+ this.reason = reason;
66
+ this.name = "DnsRecordsUnreadable";
67
+ }
68
+ };
69
+ //#endregion
70
+ exports.DnsRecordsUnreadable = DnsRecordsUnreadable;
71
+ exports.MxValueInvalid = MxValueInvalid;
72
+ exports.isDnsProvider = isDnsProvider;
73
+ exports.mxValue = mxValue;
74
+ exports.parseMxValue = parseMxValue;
75
+
76
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["EdgeError"],"sources":["../../src/dns/index.ts"],"sourcesContent":["/**\n * DNS Provider Interface\n *\n * Abstracts DNS operations for different providers.\n * Built-in providers: HostingerProvider, Route53Provider, GoDaddyProvider\n * Users can also supply custom implementations.\n *\n * Every value is the record's zone-file form, read and written alike: an MX\n * record's is `<priority> <host>` (see {@link mxValue}).\n */\n\nimport { EdgeError } from '../errors';\n\n// =============================================================================\n// DNS Record Types (derived from Zod schemas)\n// =============================================================================\n\n/** DNS record types supported across providers. */\nexport type DnsRecordType =\n\t| 'A'\n\t| 'AAAA'\n\t| 'CNAME'\n\t| 'MX'\n\t| 'TXT'\n\t| 'NS'\n\t| 'SRV'\n\t| 'CAA';\n\n/** A DNS record as returned by the provider. */\nexport interface DnsRecord {\n\t/** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */\n\tname: string;\n\ttype: DnsRecordType;\n\t/** TTL in seconds */\n\tttl: number;\n\t/**\n\t * Record values, as a zone file writes them: an MX record's is\n\t * `<priority> <host>` (`10 inbound-smtp.eu-west-1.amazonaws.com`).\n\t */\n\tvalues: string[];\n}\n\n/** A DNS record to create or update. */\nexport interface UpsertDnsRecord {\n\t/** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */\n\tname: string;\n\ttype: DnsRecordType;\n\t/** TTL in seconds */\n\tttl: number;\n\t/**\n\t * Record value (IP address, hostname, etc.), as a zone file writes it: an\n\t * MX record's is `<priority> <host>` — see `mxValue`.\n\t */\n\tvalue: string;\n}\n\n/** Result of an upsert operation. */\nexport interface UpsertResult {\n\t/** The record that was upserted */\n\trecord: UpsertDnsRecord;\n\t/** Whether the record was created (true) or updated (false) */\n\tcreated: boolean;\n\t/** Whether the record already existed with the same value */\n\tunchanged: boolean;\n}\n\n// =============================================================================\n// MX values\n// =============================================================================\n\n/**\n * An MX record's value as every provider here reads and writes it — the zone\n * file's `<priority> <host>`, which is what Route53 and Hostinger take as is.\n * A provider whose API keeps the priority apart (GoDaddy) splits it with\n * {@link parseMxValue}.\n */\nexport function mxValue(priority: number, host: string): string {\n\treturn `${priority} ${host.trim().replace(/\\.$/, '')}`;\n}\n\n/** An MX value that is not `<priority> <host>`. */\nexport class MxValueInvalid extends EdgeError {\n\tconstructor(readonly value: string) {\n\t\tsuper(\n\t\t\t`'${value}' is not an MX record's value: it is written ` +\n\t\t\t\t\"'<priority> <host>', like '10 inbound-smtp.eu-west-1.amazonaws.com'. \" +\n\t\t\t\t'Build it with mxValue(priority, host).',\n\t\t);\n\t\tthis.name = 'MxValueInvalid';\n\t}\n}\n\n/**\n * The priority and host of an MX value.\n *\n * @throws {MxValueInvalid} for a value that is not `<priority> <host>`\n */\nexport function parseMxValue(value: string): {\n\tpriority: number;\n\thost: string;\n} {\n\tconst match = value.trim().match(/^(\\d{1,5})\\s+(\\S+)$/);\n\tconst priority = match ? Number(match[1]) : Number.NaN;\n\tif (!match || priority > 65535) throw new MxValueInvalid(value);\n\treturn { priority, host: match[2]!.replace(/\\.$/, '') };\n}\n\n// =============================================================================\n// DNS Provider Interface\n// =============================================================================\n\n/**\n * A record to delete from DNS.\n */\nexport interface DeleteDnsRecord {\n\t/** Record name/subdomain (e.g., 'api' or '@' for root) */\n\tname: string;\n\t/** Record type (A, CNAME, etc.) */\n\ttype: DnsRecordType;\n}\n\n/**\n * Result of a delete operation.\n */\nexport interface DeleteResult {\n\t/** The record that was requested for deletion */\n\trecord: DeleteDnsRecord;\n\t/** Whether the record was deleted */\n\tdeleted: boolean;\n\t/** Whether the record was not found (already deleted) */\n\tnotFound: boolean;\n\t/** Error message if deletion failed */\n\terror?: string;\n}\n\n/**\n * Interface for DNS providers.\n *\n * Implementations must handle:\n * - Getting all records for a domain\n * - Creating or updating records for a domain\n * - Deleting records from a domain\n */\nexport interface DnsProvider {\n\t/** Provider name for logging */\n\treadonly name: string;\n\n\t/**\n\t * Get all DNS records for a domain.\n\t *\n\t * @param domain - Root domain (e.g., 'example.com')\n\t * @returns Array of DNS records\n\t */\n\tgetRecords(domain: string): Promise<DnsRecord[]>;\n\n\t/**\n\t * The records of exactly these names and types, where the provider can\n\t * read them one at a time — cheaper than the whole zone on an API that\n\t * counts requests. Optional: without it, `getRecords` is filtered.\n\t * Throws {@link DnsRecordsUnreadable} when the credentials can only write.\n\t *\n\t * @param domain - Root domain (e.g., 'example.com')\n\t * @param wanted - The names ('@' for the root) and types to read\n\t */\n\treadRecords?(\n\t\tdomain: string,\n\t\twanted: readonly DeleteDnsRecord[],\n\t): Promise<DnsRecord[]>;\n\n\t/**\n\t * Create or update DNS records.\n\t *\n\t * @param domain - Root domain (e.g., 'example.com')\n\t * @param records - Records to create or update\n\t * @returns Results of the upsert operations\n\t */\n\tupsertRecords(\n\t\tdomain: string,\n\t\trecords: UpsertDnsRecord[],\n\t): Promise<UpsertResult[]>;\n\n\t/**\n\t * Delete DNS records.\n\t *\n\t * @param domain - Root domain (e.g., 'example.com')\n\t * @param records - Records to delete\n\t * @returns Results of the delete operations\n\t */\n\tdeleteRecords(\n\t\tdomain: string,\n\t\trecords: DeleteDnsRecord[],\n\t): Promise<DeleteResult[]>;\n}\n\n/**\n * Check if value is a DnsProvider implementation.\n */\nexport function isDnsProvider(value: unknown): value is DnsProvider {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof (value as DnsProvider).name === 'string' &&\n\t\ttypeof (value as DnsProvider).getRecords === 'function' &&\n\t\ttypeof (value as DnsProvider).upsertRecords === 'function' &&\n\t\ttypeof (value as DnsProvider).deleteRecords === 'function'\n\t);\n}\n\n/**\n * The provider's credentials can write records and not read them — a key\n * scoped to updates only. What reads them falls back to writing every record,\n * which is idempotent, without a diff.\n */\nexport class DnsRecordsUnreadable extends EdgeError {\n\tconstructor(\n\t\treadonly provider: string,\n\t\treadonly domain: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`The ${provider} key cannot read ${domain}'s DNS records (${reason}), so ` +\n\t\t\t\t'changes cannot be compared with what is there: every record is ' +\n\t\t\t\t'written, which leaves one that already has its value as it was.',\n\t\t);\n\t\tthis.name = 'DnsRecordsUnreadable';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,QAAQ,UAAkB,MAAsB;CAC/D,OAAO,GAAG,SAAS,GAAG,KAAK,KAAK,CAAC,CAAC,QAAQ,OAAO,EAAE;AACpD;;AAGA,IAAa,iBAAb,cAAoCA,eAAAA,UAAU;CACxB;CAArB,YAAY,OAAwB;EACnC,MACC,IAAI,MAAM,yJAGX;EALoB,KAAA,QAAA;EAMpB,KAAK,OAAO;CACb;AACD;;;;;;AAOA,SAAgB,aAAa,OAG3B;CACD,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC,MAAM,qBAAqB;CACtD,MAAM,WAAW,QAAQ,OAAO,MAAM,EAAE,IAAI;CAC5C,IAAI,CAAC,SAAS,WAAW,OAAO,MAAM,IAAI,eAAe,KAAK;CAC9D,OAAO;EAAE;EAAU,MAAM,MAAM,EAAE,CAAE,QAAQ,OAAO,EAAE;CAAE;AACvD;;;;AA4FA,SAAgB,cAAc,OAAsC;CACnE,OACC,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAsB,SAAS,YACvC,OAAQ,MAAsB,eAAe,cAC7C,OAAQ,MAAsB,kBAAkB,cAChD,OAAQ,MAAsB,kBAAkB;AAElD;;;;;;AAOA,IAAa,uBAAb,cAA0CA,eAAAA,UAAU;CAEzC;CACA;CACA;CAHV,YACC,UACA,QACA,QACC;EACD,MACC,OAAO,SAAS,mBAAmB,OAAO,kBAAkB,OAAO,qIAGpE;EARS,KAAA,WAAA;EACA,KAAA,SAAA;EACA,KAAA,SAAA;EAOT,KAAK,OAAO;CACb;AACD"}
@@ -0,0 +1,144 @@
1
+ import { t as EdgeError } from "../errors-DBZfelEN.cjs";
2
+ //#region src/dns/index.d.ts
3
+ /** DNS record types supported across providers. */
4
+ export type DnsRecordType = 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA';
5
+ /** A DNS record as returned by the provider. */
6
+ export interface DnsRecord {
7
+ /** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
8
+ name: string;
9
+ type: DnsRecordType;
10
+ /** TTL in seconds */
11
+ ttl: number;
12
+ /**
13
+ * Record values, as a zone file writes them: an MX record's is
14
+ * `<priority> <host>` (`10 inbound-smtp.eu-west-1.amazonaws.com`).
15
+ */
16
+ values: string[];
17
+ }
18
+ /** A DNS record to create or update. */
19
+ export interface UpsertDnsRecord {
20
+ /** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
21
+ name: string;
22
+ type: DnsRecordType;
23
+ /** TTL in seconds */
24
+ ttl: number;
25
+ /**
26
+ * Record value (IP address, hostname, etc.), as a zone file writes it: an
27
+ * MX record's is `<priority> <host>` — see `mxValue`.
28
+ */
29
+ value: string;
30
+ }
31
+ /** Result of an upsert operation. */
32
+ export interface UpsertResult {
33
+ /** The record that was upserted */
34
+ record: UpsertDnsRecord;
35
+ /** Whether the record was created (true) or updated (false) */
36
+ created: boolean;
37
+ /** Whether the record already existed with the same value */
38
+ unchanged: boolean;
39
+ }
40
+ /**
41
+ * An MX record's value as every provider here reads and writes it — the zone
42
+ * file's `<priority> <host>`, which is what Route53 and Hostinger take as is.
43
+ * A provider whose API keeps the priority apart (GoDaddy) splits it with
44
+ * {@link parseMxValue}.
45
+ */
46
+ export declare function mxValue(priority: number, host: string): string;
47
+ /** An MX value that is not `<priority> <host>`. */
48
+ export declare class MxValueInvalid extends EdgeError {
49
+ readonly value: string;
50
+ constructor(value: string);
51
+ }
52
+ /**
53
+ * The priority and host of an MX value.
54
+ *
55
+ * @throws {MxValueInvalid} for a value that is not `<priority> <host>`
56
+ */
57
+ export declare function parseMxValue(value: string): {
58
+ priority: number;
59
+ host: string;
60
+ };
61
+ /**
62
+ * A record to delete from DNS.
63
+ */
64
+ export interface DeleteDnsRecord {
65
+ /** Record name/subdomain (e.g., 'api' or '@' for root) */
66
+ name: string;
67
+ /** Record type (A, CNAME, etc.) */
68
+ type: DnsRecordType;
69
+ }
70
+ /**
71
+ * Result of a delete operation.
72
+ */
73
+ export interface DeleteResult {
74
+ /** The record that was requested for deletion */
75
+ record: DeleteDnsRecord;
76
+ /** Whether the record was deleted */
77
+ deleted: boolean;
78
+ /** Whether the record was not found (already deleted) */
79
+ notFound: boolean;
80
+ /** Error message if deletion failed */
81
+ error?: string;
82
+ }
83
+ /**
84
+ * Interface for DNS providers.
85
+ *
86
+ * Implementations must handle:
87
+ * - Getting all records for a domain
88
+ * - Creating or updating records for a domain
89
+ * - Deleting records from a domain
90
+ */
91
+ export interface DnsProvider {
92
+ /** Provider name for logging */
93
+ readonly name: string;
94
+ /**
95
+ * Get all DNS records for a domain.
96
+ *
97
+ * @param domain - Root domain (e.g., 'example.com')
98
+ * @returns Array of DNS records
99
+ */
100
+ getRecords(domain: string): Promise<DnsRecord[]>;
101
+ /**
102
+ * The records of exactly these names and types, where the provider can
103
+ * read them one at a time — cheaper than the whole zone on an API that
104
+ * counts requests. Optional: without it, `getRecords` is filtered.
105
+ * Throws {@link DnsRecordsUnreadable} when the credentials can only write.
106
+ *
107
+ * @param domain - Root domain (e.g., 'example.com')
108
+ * @param wanted - The names ('@' for the root) and types to read
109
+ */
110
+ readRecords?(domain: string, wanted: readonly DeleteDnsRecord[]): Promise<DnsRecord[]>;
111
+ /**
112
+ * Create or update DNS records.
113
+ *
114
+ * @param domain - Root domain (e.g., 'example.com')
115
+ * @param records - Records to create or update
116
+ * @returns Results of the upsert operations
117
+ */
118
+ upsertRecords(domain: string, records: UpsertDnsRecord[]): Promise<UpsertResult[]>;
119
+ /**
120
+ * Delete DNS records.
121
+ *
122
+ * @param domain - Root domain (e.g., 'example.com')
123
+ * @param records - Records to delete
124
+ * @returns Results of the delete operations
125
+ */
126
+ deleteRecords(domain: string, records: DeleteDnsRecord[]): Promise<DeleteResult[]>;
127
+ }
128
+ /**
129
+ * Check if value is a DnsProvider implementation.
130
+ */
131
+ export declare function isDnsProvider(value: unknown): value is DnsProvider;
132
+ /**
133
+ * The provider's credentials can write records and not read them — a key
134
+ * scoped to updates only. What reads them falls back to writing every record,
135
+ * which is idempotent, without a diff.
136
+ */
137
+ export declare class DnsRecordsUnreadable extends EdgeError {
138
+ readonly provider: string;
139
+ readonly domain: string;
140
+ readonly reason: string;
141
+ constructor(provider: string, domain: string, reason: string);
142
+ }
143
+ //#endregion
144
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/dns/index.ts"],"mappings":";;;YAkBY;;iBAWK;;EAEhB;EACA,MAAM;;EAEN;;;;;EAKA;;;iBAIgB;;EAEhB;EACA,MAAM;;EAEN;;;;;EAKA;;;iBAIgB;;EAEhB,QAAQ;;EAER;;EAEA;;;;;;;;wBAae,QAAQ,kBAAkB;;qBAK7B,uBAAuB;WACd;EAArB,YAAqB;;;;;;;wBAeN,aAAa;EAC5B;EACA;;;;;iBAegB;;EAEhB;;EAEA,MAAM;;;;;iBAMU;;EAEhB,QAAQ;;EAER;;EAEA;;EAEA;;;;;;;;;;iBAWgB;;WAEP;;;;;;;EAQT,WAAW,iBAAiB,QAAQ;;;;;;;;;;EAWpC,aACC,gBACA,iBAAiB,oBACf,QAAQ;;;;;;;;EASX,cACC,gBACA,SAAS,oBACP,QAAQ;;;;;;;;EASX,cACC,gBACA,SAAS,oBACP,QAAQ;;;;;wBAMI,cAAc,iBAAiB,SAAS;;;;;;qBAgB3C,6BAA6B;WAE/B;WACA;WACA;EAHV,YACU,kBACA,gBACA"}
@@ -0,0 +1,144 @@
1
+ import { t as EdgeError } from "../errors-DBZfelEN.mjs";
2
+ //#region src/dns/index.d.ts
3
+ /** DNS record types supported across providers. */
4
+ export type DnsRecordType = 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA';
5
+ /** A DNS record as returned by the provider. */
6
+ export interface DnsRecord {
7
+ /** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
8
+ name: string;
9
+ type: DnsRecordType;
10
+ /** TTL in seconds */
11
+ ttl: number;
12
+ /**
13
+ * Record values, as a zone file writes them: an MX record's is
14
+ * `<priority> <host>` (`10 inbound-smtp.eu-west-1.amazonaws.com`).
15
+ */
16
+ values: string[];
17
+ }
18
+ /** A DNS record to create or update. */
19
+ export interface UpsertDnsRecord {
20
+ /** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
21
+ name: string;
22
+ type: DnsRecordType;
23
+ /** TTL in seconds */
24
+ ttl: number;
25
+ /**
26
+ * Record value (IP address, hostname, etc.), as a zone file writes it: an
27
+ * MX record's is `<priority> <host>` — see `mxValue`.
28
+ */
29
+ value: string;
30
+ }
31
+ /** Result of an upsert operation. */
32
+ export interface UpsertResult {
33
+ /** The record that was upserted */
34
+ record: UpsertDnsRecord;
35
+ /** Whether the record was created (true) or updated (false) */
36
+ created: boolean;
37
+ /** Whether the record already existed with the same value */
38
+ unchanged: boolean;
39
+ }
40
+ /**
41
+ * An MX record's value as every provider here reads and writes it — the zone
42
+ * file's `<priority> <host>`, which is what Route53 and Hostinger take as is.
43
+ * A provider whose API keeps the priority apart (GoDaddy) splits it with
44
+ * {@link parseMxValue}.
45
+ */
46
+ export declare function mxValue(priority: number, host: string): string;
47
+ /** An MX value that is not `<priority> <host>`. */
48
+ export declare class MxValueInvalid extends EdgeError {
49
+ readonly value: string;
50
+ constructor(value: string);
51
+ }
52
+ /**
53
+ * The priority and host of an MX value.
54
+ *
55
+ * @throws {MxValueInvalid} for a value that is not `<priority> <host>`
56
+ */
57
+ export declare function parseMxValue(value: string): {
58
+ priority: number;
59
+ host: string;
60
+ };
61
+ /**
62
+ * A record to delete from DNS.
63
+ */
64
+ export interface DeleteDnsRecord {
65
+ /** Record name/subdomain (e.g., 'api' or '@' for root) */
66
+ name: string;
67
+ /** Record type (A, CNAME, etc.) */
68
+ type: DnsRecordType;
69
+ }
70
+ /**
71
+ * Result of a delete operation.
72
+ */
73
+ export interface DeleteResult {
74
+ /** The record that was requested for deletion */
75
+ record: DeleteDnsRecord;
76
+ /** Whether the record was deleted */
77
+ deleted: boolean;
78
+ /** Whether the record was not found (already deleted) */
79
+ notFound: boolean;
80
+ /** Error message if deletion failed */
81
+ error?: string;
82
+ }
83
+ /**
84
+ * Interface for DNS providers.
85
+ *
86
+ * Implementations must handle:
87
+ * - Getting all records for a domain
88
+ * - Creating or updating records for a domain
89
+ * - Deleting records from a domain
90
+ */
91
+ export interface DnsProvider {
92
+ /** Provider name for logging */
93
+ readonly name: string;
94
+ /**
95
+ * Get all DNS records for a domain.
96
+ *
97
+ * @param domain - Root domain (e.g., 'example.com')
98
+ * @returns Array of DNS records
99
+ */
100
+ getRecords(domain: string): Promise<DnsRecord[]>;
101
+ /**
102
+ * The records of exactly these names and types, where the provider can
103
+ * read them one at a time — cheaper than the whole zone on an API that
104
+ * counts requests. Optional: without it, `getRecords` is filtered.
105
+ * Throws {@link DnsRecordsUnreadable} when the credentials can only write.
106
+ *
107
+ * @param domain - Root domain (e.g., 'example.com')
108
+ * @param wanted - The names ('@' for the root) and types to read
109
+ */
110
+ readRecords?(domain: string, wanted: readonly DeleteDnsRecord[]): Promise<DnsRecord[]>;
111
+ /**
112
+ * Create or update DNS records.
113
+ *
114
+ * @param domain - Root domain (e.g., 'example.com')
115
+ * @param records - Records to create or update
116
+ * @returns Results of the upsert operations
117
+ */
118
+ upsertRecords(domain: string, records: UpsertDnsRecord[]): Promise<UpsertResult[]>;
119
+ /**
120
+ * Delete DNS records.
121
+ *
122
+ * @param domain - Root domain (e.g., 'example.com')
123
+ * @param records - Records to delete
124
+ * @returns Results of the delete operations
125
+ */
126
+ deleteRecords(domain: string, records: DeleteDnsRecord[]): Promise<DeleteResult[]>;
127
+ }
128
+ /**
129
+ * Check if value is a DnsProvider implementation.
130
+ */
131
+ export declare function isDnsProvider(value: unknown): value is DnsProvider;
132
+ /**
133
+ * The provider's credentials can write records and not read them — a key
134
+ * scoped to updates only. What reads them falls back to writing every record,
135
+ * which is idempotent, without a diff.
136
+ */
137
+ export declare class DnsRecordsUnreadable extends EdgeError {
138
+ readonly provider: string;
139
+ readonly domain: string;
140
+ readonly reason: string;
141
+ constructor(provider: string, domain: string, reason: string);
142
+ }
143
+ //#endregion
144
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/dns/index.ts"],"mappings":";;;YAkBY;;iBAWK;;EAEhB;EACA,MAAM;;EAEN;;;;;EAKA;;;iBAIgB;;EAEhB;EACA,MAAM;;EAEN;;;;;EAKA;;;iBAIgB;;EAEhB,QAAQ;;EAER;;EAEA;;;;;;;;wBAae,QAAQ,kBAAkB;;qBAK7B,uBAAuB;WACd;EAArB,YAAqB;;;;;;;wBAeN,aAAa;EAC5B;EACA;;;;;iBAegB;;EAEhB;;EAEA,MAAM;;;;;iBAMU;;EAEhB,QAAQ;;EAER;;EAEA;;EAEA;;;;;;;;;;iBAWgB;;WAEP;;;;;;;EAQT,WAAW,iBAAiB,QAAQ;;;;;;;;;;EAWpC,aACC,gBACA,iBAAiB,oBACf,QAAQ;;;;;;;;EASX,cACC,gBACA,SAAS,oBACP,QAAQ;;;;;;;;EASX,cACC,gBACA,SAAS,oBACP,QAAQ;;;;;wBAMI,cAAc,iBAAiB,SAAS;;;;;;qBAgB3C,6BAA6B;WAE/B;WACA;WACA;EAHV,YACU,kBACA,gBACA"}