@formless63/dns-plan 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +42 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/diff.d.ts +110 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +292 -0
- package/dist/diff.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/records.d.ts +118 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +71 -0
- package/dist/records.js.map +1 -0
- package/package.json +39 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 formless63
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @formless63/dns-plan
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A provider-neutral DNS record model with a diff and planner that will not touch records it does not own.
|
|
4
|
+
No dependencies, no I/O.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
const diff = diffRecords(desired, observed, { pending: removing }); // missing, modified, unexpected, unchanged
|
|
8
|
+
const plan = planOperations(diff, { remove: removing }); // creates, updates, explicit removals
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- **Unexpected records are never deleted or rewritten.** Deletes come only from `remove`.
|
|
12
|
+
- **Another record is never overwritten by guesswork.** A desired TXT beside an unrelated verification TXT is
|
|
13
|
+
added, not swapped in. Replacement needs certainty: the same `recordId`, a single-valued type, one address on
|
|
14
|
+
each side, or the same TXT version tag. `pairing: "positional"` opts out.
|
|
15
|
+
- **`managed: false`** records are compared and reported, never written.
|
|
16
|
+
- Equivalent spellings (case, trailing dots, IPv6 forms, TXT quoting and string splits) are not drift.
|
|
17
|
+
`normalizeContent` is the comparison form; store what was written.
|
|
18
|
+
|
|
19
|
+
## Replacing a record
|
|
20
|
+
|
|
21
|
+
Pass the records you are about to remove as `pending` to the diff and as `remove` to the planner. A record in
|
|
22
|
+
`pending` but not in `remove` stays where it is. The plan then runs:
|
|
23
|
+
|
|
24
|
+
1. **in place**: a removal and a new record of the same type that are certainly one record become one update;
|
|
25
|
+
2. **type changes**: the conflicting removals, then the creates that need the name, sharing a `group`;
|
|
26
|
+
3. other creates, before any other delete, so a set never has a gap;
|
|
27
|
+
4. updates;
|
|
28
|
+
5. other removals;
|
|
29
|
+
6. creates blocked by a record that stays. Nothing is removed to make room; the provider refuses them last.
|
|
30
|
+
|
|
31
|
+
`planChanges` returns the same plan with the desired or removed record behind each operation.
|
|
32
|
+
`recordsConflict(a, b)` is the coexistence rule it uses (CNAME, NS, single-valued types).
|
|
33
|
+
|
|
34
|
+
Because an unmatched desired record is added, check for a second SPF or DMARC record when you take over an
|
|
35
|
+
existing zone; those two are paired by version tag.
|
|
36
|
+
|
|
37
|
+
## Providers
|
|
38
|
+
|
|
39
|
+
Implement `DnsProvider` to add a host. Names are zone-relative (`@`, `*`, `www`); `ttlSeconds: null` means the
|
|
40
|
+
provider default. `apply` runs in order and rejects with `DnsApplyError` (the results so far, the failed
|
|
41
|
+
operation, and the cause's `kind`). A provider whose `capabilities().atomicGroups` is true applies each `group`
|
|
42
|
+
all or nothing; others apply it in order. A create refused because the name is taken is `already_present` only
|
|
43
|
+
when that record is read back, with `differingAttributes` for TTL or proxying.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"7.0.2","root":[[64,66]],"packageJsons":["../package.json"],"fileNames":["lib.es5.d.ts","lib.es2015.d.ts","lib.es2016.d.ts","lib.es2017.d.ts","lib.es2018.d.ts","lib.es2019.d.ts","lib.es2020.d.ts","lib.es2021.d.ts","lib.es2022.d.ts","lib.es2023.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts","lib.es2015.core.d.ts","lib.es2015.collection.d.ts","lib.es2015.generator.d.ts","lib.es2015.iterable.d.ts","lib.es2015.promise.d.ts","lib.es2015.proxy.d.ts","lib.es2015.reflect.d.ts","lib.es2015.symbol.d.ts","lib.es2015.symbol.wellknown.d.ts","lib.es2016.array.include.d.ts","lib.es2016.intl.d.ts","lib.es2017.arraybuffer.d.ts","lib.es2017.date.d.ts","lib.es2017.object.d.ts","lib.es2017.sharedmemory.d.ts","lib.es2017.string.d.ts","lib.es2017.intl.d.ts","lib.es2017.typedarrays.d.ts","lib.es2018.asyncgenerator.d.ts","lib.es2018.asynciterable.d.ts","lib.es2018.intl.d.ts","lib.es2018.promise.d.ts","lib.es2018.regexp.d.ts","lib.es2019.array.d.ts","lib.es2019.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2019.intl.d.ts","lib.es2020.bigint.d.ts","lib.es2020.date.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2020.intl.d.ts","lib.es2020.number.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.es2021.intl.d.ts","lib.es2022.array.d.ts","lib.es2022.error.d.ts","lib.es2022.intl.d.ts","lib.es2022.object.d.ts","lib.es2022.string.d.ts","lib.es2022.regexp.d.ts","lib.es2023.array.d.ts","lib.es2023.collection.d.ts","lib.es2023.intl.d.ts","lib.decorators.d.ts","lib.decorators.legacy.d.ts","../src/records.ts","../src/diff.ts","../src/index.ts"],"fileInfos":[{"version":"16934abaab7026ac114da441aabea1a0","affectsGlobalScope":true,"impliedNodeFormat":1},"d4306fb2e47f74835e8674ffac07d76f","e437c5c1302869326c3bb93da85bbbcf","e4324975a566567b21d350615f1fc6ac","333b1b9a2a9ac3b8497dba5c63b5ba50","6cffacd662b6eb5fa7a36aa2ea366bfa","b4c34f9c23304dbef2d23698637ed638","e5cb86a5fc491796ecd1d2dd348d208f","feb6c6fb19cdb246a5d8acb36a6901c7","9443a7f109277ffaa79d893ed2549995",{"version":"aae8996e8b5684814785a42cbbefcd79","affectsGlobalScope":true,"impliedNodeFormat":1},"abad6dd56cc8caf095c165df8124d237",{"version":"926204c28cd3d073865348473ae28d2e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f25e42c801b2cb3cf2b39792006a9beb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6344b55f26a4e81d9608777dbfb877dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3c0ed28e53d3695b363e256ec1c023fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4c2761daba7f17141c25baa0821ac5da","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b87656acabd63e69379ff6ffcfe52fc7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"597469522da047a5af5222cc6989f405","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1708ea4d34dc37fadadc63ca01127e80","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"55d97a8c6fbf34a30450a7b1e5f7a298","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0ee05eb59426d33e374226d8dcfa708b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e347c14030993906efcfbb88915b6a05","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b0231263857c9b6a03641acdc9280ceb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3b15c4a83b598cacb4067676e6f0abed","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b417d97b7934cef63b1889abec0bbfbf","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"09a6cf4032ebba60ce22a501e663f881","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2b056277dd138e8f5650fc04e20eaa8d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e22cc07e3f3cc242ba52fa3f8ea1fc58","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2c45da767a1bfbb220848df1bc4029e4","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b44c3e0fbaf2130cdcf6ac38b120ffa1","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b612fb5cf8e5d964b92063a75207632a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"02705151a5e1551b9162a9ed8ab763f7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"41025e398be9215d32e4337335da8f0b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"52684c2b1f353a5538e4f275182a54cd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6dedb6a4f90d1df3a6fbe5693e44886c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ca3f36fe3562c07e0f0d71c2bebd3f6d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"409974d6129befbb8226ddd1c6558568","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4d9cfde2a1ae1b4925f1f9bc10848e5d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7e1daecc66dd564144e3bb1a0266b5fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a8e1d9bb35fd0637f2f9fd2b2a54f2ec","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4f168501772a6543182765bfd5f2fbfe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a19c80aad1b2162103496f5ba293a732","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b69afa63cd5d059851c78adb2856ee09","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ae2fc5d954e9b0f5feee3d481b953c27","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1cfd3091a071d8b6feec15277643bafe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1da2c1f258970fd3cc91184f69e91a9d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a0d87491913d843139e0c993650a3235","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4ef72aa378127e7b7abba915b0110b1e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3ec74c6a7d4463f0254db3a74cf75646","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"84c2bdfa470d075526cce6322d81b0b6","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0b3844c2b8c73e4e1ab91431411cad11","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4fc71cf4a15b8d99675a31df77f26e07","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d1b49564ddaeca3df5b6dbae925d2242","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6a25be566d60ccfc2d6e8b7bfdeefa83","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8a20e27646985dfd58c57ca6566553dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9969f02ad3cdcbf4f709405cda44167f","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9c9be4792a7a4f42c15ae7360bf28779","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8cf777fe00349b71ee9c4b6f3fe7fd19","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"74f96bc192530c9723f572bfff3d3078","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1df91c56b25955c56387426f378173c5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f64453cbf9671f28158677fa5c43967a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"33f317af5428801f944a478d2c1e38e5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3b86c96a30ed4e5f788c8a2d366c870d","signature":"9def97ed7905e11459203adc36dea76e","impliedNodeFormat":99},{"version":"8d0073d4cca626ec5c1fd42d76491013","signature":"1c6822f90cde37c4807b4e1e452e1e2f","impliedNodeFormat":99},{"version":"f49517e6ddc649cf6785af18423804e0","impliedNodeFormat":99}],"fileIdsList":[[64],[64,65]],"options":{"allowImportingTsExtensions":true,"composite":true,"declaration":true,"declarationMap":true,"erasableSyntaxOnly":true,"exactOptionalPropertyTypes":true,"module":199,"noUncheckedIndexedAccess":true,"outDir":"./","rewriteRelativeImportExtensions":true,"rootDir":"../src","skipLibCheck":true,"strict":true,"sourceMap":true,"target":10,"tsBuildInfoFile":"./.tsbuildinfo","verbatimModuleSyntax":true},"referencedMap":[[65,1],[66,2]],"latestChangedDtsFile":"./index.d.ts"}
|
package/dist/diff.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type DnsOperation, type DnsRecord, type ObservedRecord } from './records.ts';
|
|
2
|
+
/** A record that should exist. */
|
|
3
|
+
export interface DesiredRecord extends DnsRecord {
|
|
4
|
+
/** `false` means compare it but never write it (a hand-maintained record). Default true. */
|
|
5
|
+
managed?: boolean;
|
|
6
|
+
/** The provider id last seen for this record, when known. Pairs it exactly. */
|
|
7
|
+
recordId?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export type RecordAttribute = 'content' | 'proxied' | 'ttlSeconds' | 'priority';
|
|
10
|
+
export interface MissingRecord<D extends DesiredRecord = DesiredRecord> {
|
|
11
|
+
kind: 'missing';
|
|
12
|
+
desired: D;
|
|
13
|
+
}
|
|
14
|
+
export interface ModifiedRecord<D extends DesiredRecord = DesiredRecord> {
|
|
15
|
+
kind: 'modified';
|
|
16
|
+
desired: D;
|
|
17
|
+
observed: ObservedRecord;
|
|
18
|
+
changed: RecordAttribute[];
|
|
19
|
+
}
|
|
20
|
+
export interface UnexpectedRecord {
|
|
21
|
+
kind: 'unexpected';
|
|
22
|
+
observed: ObservedRecord;
|
|
23
|
+
}
|
|
24
|
+
export interface UnchangedRecord<D extends DesiredRecord = DesiredRecord> {
|
|
25
|
+
kind: 'unchanged';
|
|
26
|
+
desired: D;
|
|
27
|
+
observed: ObservedRecord;
|
|
28
|
+
}
|
|
29
|
+
export interface DnsDiff<D extends DesiredRecord = DesiredRecord> {
|
|
30
|
+
missing: MissingRecord<D>[];
|
|
31
|
+
modified: ModifiedRecord<D>[];
|
|
32
|
+
/** At the provider but not described. Never deleted or rewritten by a plan. */
|
|
33
|
+
unexpected: UnexpectedRecord[];
|
|
34
|
+
unchanged: UnchangedRecord<D>[];
|
|
35
|
+
/** `DiffOptions.pending`, as given: observed records the caller is removing. */
|
|
36
|
+
pending?: ObservedRecord[];
|
|
37
|
+
}
|
|
38
|
+
export interface DiffOptions {
|
|
39
|
+
/**
|
|
40
|
+
* How a desired record with new content finds the record it replaces.
|
|
41
|
+
*
|
|
42
|
+
* `safe` (default) pairs only where the match is certain: the same recordId,
|
|
43
|
+
* single-valued types, one address each side, or the same TXT version tag
|
|
44
|
+
* (`v=spf1`, `v=DMARC1`). Otherwise it adds a record and reports the other as
|
|
45
|
+
* unexpected, so somebody else's record is never overwritten.
|
|
46
|
+
*
|
|
47
|
+
* `positional` pairs leftovers of a (type, name) in order. Use it only when
|
|
48
|
+
* the desired set is known to be complete for every name it mentions.
|
|
49
|
+
*/
|
|
50
|
+
pairing?: 'safe' | 'positional';
|
|
51
|
+
normalize?: (type: string, content: string) => string;
|
|
52
|
+
/**
|
|
53
|
+
* Observed records the caller is about to remove (and will pass to
|
|
54
|
+
* `planOperations` as `remove`, or keep on purpose). They are left out of the
|
|
55
|
+
* comparison, whether or not they are also in `observed`. A desired record
|
|
56
|
+
* that certainly replaces one of them stays `missing`, so the planner can
|
|
57
|
+
* replace that record, and is never paired with another record at the name.
|
|
58
|
+
*/
|
|
59
|
+
pending?: readonly ObservedRecord[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Whether two records cannot exist together at one name: a CNAME beside
|
|
63
|
+
* anything (at the apex, where providers flatten it, only beside an address
|
|
64
|
+
* or another CNAME), NS beside anything below the apex, two values of a
|
|
65
|
+
* single-valued type. Deliberately wide; the provider still decides.
|
|
66
|
+
*/
|
|
67
|
+
export declare function recordsConflict(a: Pick<DnsRecord, 'type' | 'name'>, b: Pick<DnsRecord, 'type' | 'name'>): boolean;
|
|
68
|
+
/** Compares desired records with observed ones. Pure: no network, no clock. */
|
|
69
|
+
export declare function diffRecords<D extends DesiredRecord>(desired: readonly D[], observed: readonly ObservedRecord[], options?: DiffOptions): DnsDiff<D>;
|
|
70
|
+
export interface PlanOptions<R extends ObservedRecord = ObservedRecord> {
|
|
71
|
+
/**
|
|
72
|
+
* Records to remove, each as it was observed. The only source of deletes.
|
|
73
|
+
* Anything else in `DnsDiff.pending` stays where it is.
|
|
74
|
+
*/
|
|
75
|
+
remove?: readonly R[];
|
|
76
|
+
}
|
|
77
|
+
/** One planned operation and what it carries out. */
|
|
78
|
+
export interface PlannedChange<D extends DesiredRecord = DesiredRecord, R extends ObservedRecord = ObservedRecord> {
|
|
79
|
+
operation: DnsOperation;
|
|
80
|
+
/** The desired record a create or update writes. */
|
|
81
|
+
desired?: D;
|
|
82
|
+
/** The record a delete removes, or the one an update replaces in place. */
|
|
83
|
+
removed?: R;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The operations a diff implies, each with what it carries out, in this order:
|
|
87
|
+
*
|
|
88
|
+
* 1. a removal and a missing record of the same type that are certainly one
|
|
89
|
+
* record become one update, so the name is never empty;
|
|
90
|
+
* 2. removals that conflict with a create (a type change), then those creates,
|
|
91
|
+
* as one `group` per name;
|
|
92
|
+
* 3. other creates, before any other delete, so a set never has a gap;
|
|
93
|
+
* 4. updates for modified records;
|
|
94
|
+
* 5. other removals;
|
|
95
|
+
* 6. creates blocked by a record that stays (unexpected, unmanaged, or pending
|
|
96
|
+
* and not removed). Nothing is deleted to make room for them; the provider
|
|
97
|
+
* refuses them, last, so the rest of the zone goes through.
|
|
98
|
+
*
|
|
99
|
+
* Unmanaged and unexpected records never produce an operation.
|
|
100
|
+
*/
|
|
101
|
+
export declare function planChanges<D extends DesiredRecord, R extends ObservedRecord = ObservedRecord>(diff: DnsDiff<D>, { remove }?: PlanOptions<R>, options?: Pick<DiffOptions, 'normalize'>): PlannedChange<D, R>[];
|
|
102
|
+
/** {@link planChanges}, operations only. */
|
|
103
|
+
export declare function planOperations(diff: DnsDiff, options?: PlanOptions): DnsOperation[];
|
|
104
|
+
/**
|
|
105
|
+
* Throws if a plan deletes or rewrites a record the diff found unexpected,
|
|
106
|
+
* other than those the caller explicitly listed in `remove`. A guard for
|
|
107
|
+
* hand-assembled plans.
|
|
108
|
+
*/
|
|
109
|
+
export declare function assertNoUnexpectedDeletes(diff: DnsDiff, operations: readonly DnsOperation[], { remove }?: PlanOptions): void;
|
|
110
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAExG,kCAAkC;AAClC,MAAM,WAAW,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A+FvB;AAED,4CAA4C;AAC5C,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,GAAE,WAAgB,GAAG,YAAY,EAAE,CAEvF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,SAAS,YAAY,EAAE,EACnC,EAAE,MAAW,EAAE,GAAE,WAAgB,GAChC,IAAI,CAWN"}
|
package/dist/diff.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { normalizeContent } from './records.js';
|
|
2
|
+
const SINGLE_VALUED = new Set(['CNAME', 'SOA', 'ALIAS', 'ANAME', 'DNAME']);
|
|
3
|
+
const ADDRESS = new Set(['A', 'AAAA']);
|
|
4
|
+
const keyOf = (record) => `${record.type.toUpperCase()} ${record.name.trim().toLowerCase().replace(/\.$/, '')}`;
|
|
5
|
+
function txtTag(content) {
|
|
6
|
+
return /^\s*(v=[A-Za-z0-9]+)/.exec(content)?.[1]?.toLowerCase() ?? null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Whether `have` is certainly the record `want` replaces, once equal content is
|
|
10
|
+
* ruled out. `onlyPair`: the (type, name) holds one record on each side.
|
|
11
|
+
*/
|
|
12
|
+
function certainlyReplaces(want, have, onlyPair, normalize) {
|
|
13
|
+
const type = want.type.toUpperCase();
|
|
14
|
+
if (SINGLE_VALUED.has(type))
|
|
15
|
+
return true;
|
|
16
|
+
if (ADDRESS.has(type))
|
|
17
|
+
return onlyPair;
|
|
18
|
+
if (type === 'TXT') {
|
|
19
|
+
const tag = txtTag(normalize(want.type, want.content));
|
|
20
|
+
return tag !== null && tag === txtTag(normalize(have.type, have.content));
|
|
21
|
+
}
|
|
22
|
+
// MX, NS, CAA, SRV and the rest are sets: another value is another record.
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const sameName = (a, b) => a.name.trim().toLowerCase().replace(/\.$/, '') === b.name.trim().toLowerCase().replace(/\.$/, '');
|
|
26
|
+
/**
|
|
27
|
+
* Whether two records cannot exist together at one name: a CNAME beside
|
|
28
|
+
* anything (at the apex, where providers flatten it, only beside an address
|
|
29
|
+
* or another CNAME), NS beside anything below the apex, two values of a
|
|
30
|
+
* single-valued type. Deliberately wide; the provider still decides.
|
|
31
|
+
*/
|
|
32
|
+
export function recordsConflict(a, b) {
|
|
33
|
+
if (!sameName(a, b))
|
|
34
|
+
return false;
|
|
35
|
+
const one = a.type.toUpperCase();
|
|
36
|
+
const other = b.type.toUpperCase();
|
|
37
|
+
if (one === other)
|
|
38
|
+
return SINGLE_VALUED.has(one);
|
|
39
|
+
const apex = a.name.trim() === '@';
|
|
40
|
+
for (const [x, y] of [
|
|
41
|
+
[one, other],
|
|
42
|
+
[other, one]
|
|
43
|
+
]) {
|
|
44
|
+
if (x === 'CNAME' && (!apex || ADDRESS.has(y)))
|
|
45
|
+
return true;
|
|
46
|
+
if (x === 'NS' && !apex)
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
function groupBy(items, key) {
|
|
52
|
+
const groups = new Map();
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
const group = groups.get(key(item));
|
|
55
|
+
if (group)
|
|
56
|
+
group.push(item);
|
|
57
|
+
else
|
|
58
|
+
groups.set(key(item), [item]);
|
|
59
|
+
}
|
|
60
|
+
return groups;
|
|
61
|
+
}
|
|
62
|
+
/** Compares desired records with observed ones. Pure: no network, no clock. */
|
|
63
|
+
export function diffRecords(desired, observed, options = {}) {
|
|
64
|
+
const normalize = options.normalize ?? normalizeContent;
|
|
65
|
+
const pairing = options.pairing ?? 'safe';
|
|
66
|
+
const pending = [...(options.pending ?? [])];
|
|
67
|
+
const pendingIds = new Set(pending.map((record) => record.recordId));
|
|
68
|
+
const diff = {
|
|
69
|
+
missing: [],
|
|
70
|
+
modified: [],
|
|
71
|
+
unexpected: [],
|
|
72
|
+
unchanged: [],
|
|
73
|
+
...(options.pending ? { pending } : {})
|
|
74
|
+
};
|
|
75
|
+
const pair = (want, have) => {
|
|
76
|
+
const changed = [];
|
|
77
|
+
if (normalize(want.type, want.content) !== normalize(have.type, have.content))
|
|
78
|
+
changed.push('content');
|
|
79
|
+
if (want.proxied !== have.proxied)
|
|
80
|
+
changed.push('proxied');
|
|
81
|
+
if (want.ttlSeconds !== have.ttlSeconds)
|
|
82
|
+
changed.push('ttlSeconds');
|
|
83
|
+
if ((want.priority ?? null) !== (have.priority ?? null))
|
|
84
|
+
changed.push('priority');
|
|
85
|
+
if (changed.length === 0)
|
|
86
|
+
diff.unchanged.push({ kind: 'unchanged', desired: want, observed: have });
|
|
87
|
+
else
|
|
88
|
+
diff.modified.push({ kind: 'modified', desired: want, observed: have, changed });
|
|
89
|
+
};
|
|
90
|
+
const observedGroups = groupBy(observed.filter((record) => !pendingIds.has(record.recordId)), keyOf);
|
|
91
|
+
const pendingGroups = groupBy(pending, keyOf);
|
|
92
|
+
for (const [key, wants] of groupBy(desired, keyOf)) {
|
|
93
|
+
const pool = [...(observedGroups.get(key) ?? [])];
|
|
94
|
+
observedGroups.delete(key);
|
|
95
|
+
let open = [...wants];
|
|
96
|
+
const match = (find) => {
|
|
97
|
+
open = open.filter((want) => {
|
|
98
|
+
const index = find(want);
|
|
99
|
+
if (index < 0)
|
|
100
|
+
return true;
|
|
101
|
+
pair(want, pool.splice(index, 1)[0]);
|
|
102
|
+
return false;
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
// Equal content (and priority, for repeated targets) first, so an unchanged
|
|
106
|
+
// member of a multi-valued set never reads as drift.
|
|
107
|
+
const sameContent = (want, have) => normalize(want.type, want.content) === normalize(have.type, have.content);
|
|
108
|
+
match((want) => pool.findIndex((have) => sameContent(want, have) && (want.priority ?? null) === (have.priority ?? null)));
|
|
109
|
+
match((want) => pool.findIndex((have) => sameContent(want, have)));
|
|
110
|
+
match((want) => (want.recordId ? pool.findIndex((have) => have.recordId === want.recordId) : -1));
|
|
111
|
+
const type = key.split(' ')[0];
|
|
112
|
+
const managed = (want) => want.managed !== false;
|
|
113
|
+
// A record that replaces one being removed is that record's successor,
|
|
114
|
+
// and must not take over somebody else's.
|
|
115
|
+
const successors = new Set(open.filter((want) => managed(want) &&
|
|
116
|
+
(pendingGroups.get(key) ?? []).some((have) => certainlyReplaces(want, have, true, normalize))));
|
|
117
|
+
const free = (want) => !successors.has(want);
|
|
118
|
+
if (pairing === 'positional') {
|
|
119
|
+
match((want) => (free(want) && pool.length > 0 ? 0 : -1));
|
|
120
|
+
}
|
|
121
|
+
else if (SINGLE_VALUED.has(type)) {
|
|
122
|
+
match((want) => (managed(want) && free(want) && pool.length > 0 ? 0 : -1));
|
|
123
|
+
}
|
|
124
|
+
else if (ADDRESS.has(type) && wants.length === 1 && open.length === 1 && pool.length === 1) {
|
|
125
|
+
match((want) => (managed(want) && free(want) ? 0 : -1));
|
|
126
|
+
}
|
|
127
|
+
else if (type === 'TXT') {
|
|
128
|
+
match((want) => {
|
|
129
|
+
const tag = txtTag(normalize(want.type, want.content));
|
|
130
|
+
if (tag === null || !managed(want) || !free(want))
|
|
131
|
+
return -1;
|
|
132
|
+
return pool.findIndex((have) => txtTag(normalize(have.type, have.content)) === tag);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
// Unmanaged records are never written, so claiming any leftover is harmless
|
|
136
|
+
// and reports a hand edit as a change rather than as two findings.
|
|
137
|
+
match((want) => (!managed(want) && pool.length > 0 ? 0 : -1));
|
|
138
|
+
for (const want of open)
|
|
139
|
+
diff.missing.push({ kind: 'missing', desired: want });
|
|
140
|
+
for (const have of pool)
|
|
141
|
+
diff.unexpected.push({ kind: 'unexpected', observed: have });
|
|
142
|
+
}
|
|
143
|
+
for (const group of observedGroups.values()) {
|
|
144
|
+
for (const have of group)
|
|
145
|
+
diff.unexpected.push({ kind: 'unexpected', observed: have });
|
|
146
|
+
}
|
|
147
|
+
return diff;
|
|
148
|
+
}
|
|
149
|
+
const payload = (record) => ({
|
|
150
|
+
type: record.type,
|
|
151
|
+
name: record.name,
|
|
152
|
+
content: record.content,
|
|
153
|
+
ttlSeconds: record.ttlSeconds,
|
|
154
|
+
priority: record.priority,
|
|
155
|
+
proxied: record.proxied
|
|
156
|
+
});
|
|
157
|
+
const nameKey = (record) => record.name.trim().toLowerCase().replace(/\.$/, '');
|
|
158
|
+
/**
|
|
159
|
+
* The operations a diff implies, each with what it carries out, in this order:
|
|
160
|
+
*
|
|
161
|
+
* 1. a removal and a missing record of the same type that are certainly one
|
|
162
|
+
* record become one update, so the name is never empty;
|
|
163
|
+
* 2. removals that conflict with a create (a type change), then those creates,
|
|
164
|
+
* as one `group` per name;
|
|
165
|
+
* 3. other creates, before any other delete, so a set never has a gap;
|
|
166
|
+
* 4. updates for modified records;
|
|
167
|
+
* 5. other removals;
|
|
168
|
+
* 6. creates blocked by a record that stays (unexpected, unmanaged, or pending
|
|
169
|
+
* and not removed). Nothing is deleted to make room for them; the provider
|
|
170
|
+
* refuses them, last, so the rest of the zone goes through.
|
|
171
|
+
*
|
|
172
|
+
* Unmanaged and unexpected records never produce an operation.
|
|
173
|
+
*/
|
|
174
|
+
export function planChanges(diff, { remove = [] } = {}, options = {}) {
|
|
175
|
+
const normalize = options.normalize ?? normalizeContent;
|
|
176
|
+
const managed = (desired) => desired.managed !== false;
|
|
177
|
+
const missing = diff.missing.map(({ desired }) => desired).filter(managed);
|
|
178
|
+
const removals = new Set(remove);
|
|
179
|
+
const removedIds = new Set(remove.map((record) => record.recordId));
|
|
180
|
+
// Everything at the provider that this plan leaves there.
|
|
181
|
+
const staying = [
|
|
182
|
+
...diff.unexpected.map(({ observed }) => observed),
|
|
183
|
+
...diff.unchanged.map(({ observed }) => observed),
|
|
184
|
+
...diff.modified.map(({ observed }) => observed),
|
|
185
|
+
...(diff.pending ?? [])
|
|
186
|
+
].filter((record) => !removedIds.has(record.recordId));
|
|
187
|
+
// 1. Replace in place.
|
|
188
|
+
const planned = [];
|
|
189
|
+
const creates = [];
|
|
190
|
+
for (const desired of missing) {
|
|
191
|
+
const sameKey = [...removals].filter((record) => keyOf(record) === keyOf(desired));
|
|
192
|
+
const onlyPair = sameKey.length === 1 && missing.filter((other) => keyOf(other) === keyOf(desired)).length === 1;
|
|
193
|
+
const replaced = sameKey.find((record) => certainlyReplaces(desired, record, onlyPair, normalize));
|
|
194
|
+
if (replaced === undefined) {
|
|
195
|
+
creates.push(desired);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
removals.delete(replaced);
|
|
199
|
+
planned.push({
|
|
200
|
+
operation: { kind: 'update', recordId: replaced.recordId, record: payload(desired) },
|
|
201
|
+
desired,
|
|
202
|
+
removed: replaced
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// 2. Creates a removal stands in the way of. Deleting first only helps when
|
|
206
|
+
// nothing that stays blocks the same name: otherwise the create fails anyway
|
|
207
|
+
// and the delete would just leave the name empty.
|
|
208
|
+
const inTheWay = (desired) => [...removals].filter((record) => recordsConflict(desired, record));
|
|
209
|
+
const blockedBy = (desired) => staying.some((record) => recordsConflict(desired, record));
|
|
210
|
+
const blockedNames = new Set(creates.filter(blockedBy).map(nameKey));
|
|
211
|
+
const swaps = new Map();
|
|
212
|
+
const plain = [];
|
|
213
|
+
const blocked = [];
|
|
214
|
+
const withheld = new Set();
|
|
215
|
+
for (const desired of creates) {
|
|
216
|
+
const conflicting = inTheWay(desired);
|
|
217
|
+
if (blockedBy(desired) || (blockedNames.has(nameKey(desired)) && conflicting.length > 0)) {
|
|
218
|
+
blocked.push(desired);
|
|
219
|
+
for (const record of conflicting)
|
|
220
|
+
withheld.add(record);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (conflicting.length === 0) {
|
|
224
|
+
plain.push(desired);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const swap = swaps.get(nameKey(desired)) ?? { deletes: [], creates: [] };
|
|
228
|
+
for (const record of conflicting)
|
|
229
|
+
if (!swap.deletes.includes(record))
|
|
230
|
+
swap.deletes.push(record);
|
|
231
|
+
swap.creates.push(desired);
|
|
232
|
+
swaps.set(nameKey(desired), swap);
|
|
233
|
+
}
|
|
234
|
+
const create = (desired, group) => ({
|
|
235
|
+
operation: { kind: 'create', record: payload(desired), ...(group === undefined ? {} : { group }) },
|
|
236
|
+
desired
|
|
237
|
+
});
|
|
238
|
+
const del = (record, group) => ({
|
|
239
|
+
operation: {
|
|
240
|
+
kind: 'delete',
|
|
241
|
+
recordId: record.recordId,
|
|
242
|
+
record: { type: record.type, name: record.name, content: record.content },
|
|
243
|
+
...(group === undefined ? {} : { group })
|
|
244
|
+
},
|
|
245
|
+
removed: record
|
|
246
|
+
});
|
|
247
|
+
for (const [name, swap] of swaps) {
|
|
248
|
+
const group = `replace ${name}`;
|
|
249
|
+
for (const record of swap.deletes) {
|
|
250
|
+
planned.push(del(record, group));
|
|
251
|
+
removals.delete(record);
|
|
252
|
+
}
|
|
253
|
+
planned.push(...swap.creates.map((desired) => create(desired, group)));
|
|
254
|
+
}
|
|
255
|
+
// 3.
|
|
256
|
+
planned.push(...plain.map((desired) => create(desired)));
|
|
257
|
+
// 4.
|
|
258
|
+
for (const { desired, observed } of diff.modified) {
|
|
259
|
+
if (!managed(desired))
|
|
260
|
+
continue;
|
|
261
|
+
planned.push({ operation: { kind: 'update', recordId: observed.recordId, record: payload(desired) }, desired });
|
|
262
|
+
}
|
|
263
|
+
// 5.
|
|
264
|
+
for (const record of removals)
|
|
265
|
+
if (!withheld.has(record))
|
|
266
|
+
planned.push(del(record));
|
|
267
|
+
// 6.
|
|
268
|
+
planned.push(...blocked.map((desired) => create(desired)));
|
|
269
|
+
return planned;
|
|
270
|
+
}
|
|
271
|
+
/** {@link planChanges}, operations only. */
|
|
272
|
+
export function planOperations(diff, options = {}) {
|
|
273
|
+
return planChanges(diff, options).map(({ operation }) => operation);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Throws if a plan deletes or rewrites a record the diff found unexpected,
|
|
277
|
+
* other than those the caller explicitly listed in `remove`. A guard for
|
|
278
|
+
* hand-assembled plans.
|
|
279
|
+
*/
|
|
280
|
+
export function assertNoUnexpectedDeletes(diff, operations, { remove = [] } = {}) {
|
|
281
|
+
const unexpected = new Set(diff.unexpected.map(({ observed }) => observed.recordId));
|
|
282
|
+
for (const { recordId } of remove)
|
|
283
|
+
unexpected.delete(recordId);
|
|
284
|
+
for (const operation of operations) {
|
|
285
|
+
if (operation.kind === 'create' || !unexpected.has(operation.recordId))
|
|
286
|
+
continue;
|
|
287
|
+
throw new Error(operation.kind === 'delete'
|
|
288
|
+
? 'refusing to delete an unexpected provider record'
|
|
289
|
+
: 'refusing to rewrite an unexpected provider record');
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=diff.js.map
|
package/dist/diff.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0D,MAAM,cAAc,CAAC;AAkExG,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvC,MAAM,KAAK,GAAG,CAAC,MAAiB,EAAU,EAAE,CAC1C,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;AAExF,SAAS,MAAM,CAAC,OAAe;IAC7B,OAAO,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,IAA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C7B,cAAc,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** A DNS record in provider-neutral form. */
|
|
2
|
+
export interface DnsRecord {
|
|
3
|
+
type: string;
|
|
4
|
+
/** Zone-relative: `@`, `*`, `www`, `key1._domainkey`. */
|
|
5
|
+
name: string;
|
|
6
|
+
content: string;
|
|
7
|
+
/** `null` means the provider's default. */
|
|
8
|
+
ttlSeconds: number | null;
|
|
9
|
+
priority: number | null;
|
|
10
|
+
/** The provider answers for the name and forwards to the origin. */
|
|
11
|
+
proxied: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** A record as it exists at a provider. */
|
|
14
|
+
export interface ObservedRecord extends DnsRecord {
|
|
15
|
+
recordId: string;
|
|
16
|
+
proxiable: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface DnsZone {
|
|
19
|
+
zoneId: string;
|
|
20
|
+
name: string;
|
|
21
|
+
/** The provider's own status word, verbatim. */
|
|
22
|
+
status: string;
|
|
23
|
+
nameservers: string[];
|
|
24
|
+
}
|
|
25
|
+
export type DnsOperation = ({
|
|
26
|
+
kind: 'create';
|
|
27
|
+
record: DnsRecord;
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'update';
|
|
30
|
+
recordId: string;
|
|
31
|
+
record: DnsRecord;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'delete';
|
|
34
|
+
recordId: string;
|
|
35
|
+
record: Pick<DnsRecord, 'type' | 'name' | 'content'>;
|
|
36
|
+
}) & {
|
|
37
|
+
/**
|
|
38
|
+
* Adjacent operations with the same group are one change: deletes, then the
|
|
39
|
+
* creates that need the name (a type change). A provider with
|
|
40
|
+
* `atomicGroups` applies them in one transaction; another applies them in
|
|
41
|
+
* order. Results stay one per operation.
|
|
42
|
+
*/
|
|
43
|
+
group?: string;
|
|
44
|
+
};
|
|
45
|
+
export interface DnsOperationResult {
|
|
46
|
+
kind: DnsOperation['kind'];
|
|
47
|
+
type: string;
|
|
48
|
+
name: string;
|
|
49
|
+
/** The `already_*` outcomes let a retried plan converge instead of failing. */
|
|
50
|
+
status: 'applied' | 'already_present' | 'already_absent';
|
|
51
|
+
/** The record written or removed; on `already_present`, the one found. */
|
|
52
|
+
recordId: string | null;
|
|
53
|
+
/**
|
|
54
|
+
* On `already_present`: attributes in which the record found differs from the
|
|
55
|
+
* one asked for. Type, name, content and (for MX and SRV) priority always match.
|
|
56
|
+
*/
|
|
57
|
+
differingAttributes?: ReadonlyArray<'ttlSeconds' | 'proxied'>;
|
|
58
|
+
}
|
|
59
|
+
export interface DnsCapabilities {
|
|
60
|
+
proxying: boolean;
|
|
61
|
+
proxiableTypes: readonly string[];
|
|
62
|
+
proxiedWildcards: boolean;
|
|
63
|
+
wildcardRecords: boolean;
|
|
64
|
+
automaticTtl: boolean;
|
|
65
|
+
minTtlSeconds: number;
|
|
66
|
+
maxTtlSeconds: number;
|
|
67
|
+
/** Applies a group of operations (see `DnsOperation.group`) all or nothing. Default false. */
|
|
68
|
+
atomicGroups?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface ZoneRef {
|
|
71
|
+
zoneId: string;
|
|
72
|
+
zoneName: string;
|
|
73
|
+
}
|
|
74
|
+
export interface RequestOptions {
|
|
75
|
+
signal?: AbortSignal;
|
|
76
|
+
}
|
|
77
|
+
/** What a DNS host adapter implements. */
|
|
78
|
+
export interface DnsProvider {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly label: string;
|
|
81
|
+
capabilities(): DnsCapabilities;
|
|
82
|
+
findZone(name: string, options?: RequestOptions): Promise<DnsZone | null>;
|
|
83
|
+
/** Every record in the zone, or an error: never a silently truncated list. */
|
|
84
|
+
listRecords(zone: ZoneRef, options?: RequestOptions): Promise<ObservedRecord[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Applies in order; rejects at the first failure. See `DnsApplyError`. A
|
|
87
|
+
* create refused because the name is taken succeeds only when that exact
|
|
88
|
+
* record is there.
|
|
89
|
+
*/
|
|
90
|
+
apply(zone: ZoneRef, operations: readonly DnsOperation[], options?: RequestOptions): Promise<DnsOperationResult[]>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The part of a plan that succeeded before `cause` stopped it. The failed
|
|
94
|
+
* operation is at index `completed.length`; when it was part of an atomic
|
|
95
|
+
* group, the group starts there and none of it was applied.
|
|
96
|
+
*/
|
|
97
|
+
export declare class DnsApplyError extends Error {
|
|
98
|
+
readonly completed: readonly DnsOperationResult[];
|
|
99
|
+
readonly failed: DnsOperation;
|
|
100
|
+
/** The cause's `kind` (`unauthorized`, `rate_limited`, …) when it has one, so callers can classify. */
|
|
101
|
+
readonly kind: string | null;
|
|
102
|
+
/** The cause's `retryable` flag when it has one. */
|
|
103
|
+
readonly retryable: boolean;
|
|
104
|
+
constructor(completed: readonly DnsOperationResult[], failed: DnsOperation, cause: unknown);
|
|
105
|
+
}
|
|
106
|
+
/** A zone-relative name as a fully qualified one. Already-qualified names pass through. */
|
|
107
|
+
export declare function toFqdn(name: string, zoneName: string): string;
|
|
108
|
+
/** A fully qualified name as a zone-relative one. */
|
|
109
|
+
export declare function toRelativeName(name: string, zoneName: string): string;
|
|
110
|
+
/**
|
|
111
|
+
* Content in a comparable form: host names (and SRV targets) lose case and the
|
|
112
|
+
* trailing dot, and IPv6 addresses are compressed. TXT content loses its
|
|
113
|
+
* zone-file quoting, with its character strings joined; its case is kept.
|
|
114
|
+
* Without this a correct zone can report drift forever. Compare with this,
|
|
115
|
+
* store what was written.
|
|
116
|
+
*/
|
|
117
|
+
export declare function normalizeContent(type: string, content: string): string;
|
|
118
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources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SAAQ,KAAK;IACtC,QAAQ,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAClD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,uGAAuG;IACvG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,YAAY,SAAS,EAAE,SAAS,kBAAkB,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAUzF;CACF;AAID,2FAA2F;AAC3F,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKrE;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAkBtE"}
|
package/dist/records.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part of a plan that succeeded before `cause` stopped it. The failed
|
|
3
|
+
* operation is at index `completed.length`; when it was part of an atomic
|
|
4
|
+
* group, the group starts there and none of it was applied.
|
|
5
|
+
*/
|
|
6
|
+
export class DnsApplyError extends Error {
|
|
7
|
+
completed;
|
|
8
|
+
failed;
|
|
9
|
+
/** The cause's `kind` (`unauthorized`, `rate_limited`, …) when it has one, so callers can classify. */
|
|
10
|
+
kind;
|
|
11
|
+
/** The cause's `retryable` flag when it has one. */
|
|
12
|
+
retryable;
|
|
13
|
+
constructor(completed, failed, cause) {
|
|
14
|
+
super(`DNS ${failed.kind} of ${failed.record.type} ${failed.record.name} failed after ${completed.length} change(s)`, {
|
|
15
|
+
cause
|
|
16
|
+
});
|
|
17
|
+
this.name = 'DnsApplyError';
|
|
18
|
+
this.completed = completed;
|
|
19
|
+
this.failed = failed;
|
|
20
|
+
const facts = typeof cause === 'object' && cause !== null ? cause : {};
|
|
21
|
+
this.kind = typeof facts.kind === 'string' ? facts.kind : null;
|
|
22
|
+
this.retryable = facts.retryable === true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const clean = (name) => name.trim().toLowerCase().replace(/\.$/, '');
|
|
26
|
+
/** A zone-relative name as a fully qualified one. Already-qualified names pass through. */
|
|
27
|
+
export function toFqdn(name, zoneName) {
|
|
28
|
+
const relative = clean(name);
|
|
29
|
+
const zone = clean(zoneName);
|
|
30
|
+
if (relative === '' || relative === '@' || relative === zone)
|
|
31
|
+
return zone;
|
|
32
|
+
return relative.endsWith(`.${zone}`) ? relative : `${relative}.${zone}`;
|
|
33
|
+
}
|
|
34
|
+
/** A fully qualified name as a zone-relative one. */
|
|
35
|
+
export function toRelativeName(name, zoneName) {
|
|
36
|
+
const fqdn = clean(name);
|
|
37
|
+
const zone = clean(zoneName);
|
|
38
|
+
if (fqdn === zone)
|
|
39
|
+
return '@';
|
|
40
|
+
return fqdn.endsWith(`.${zone}`) ? fqdn.slice(0, -(zone.length + 1)) : fqdn;
|
|
41
|
+
}
|
|
42
|
+
const HOST_CONTENT = new Set(['CNAME', 'NS', 'MX', 'PTR', 'SRV', 'ALIAS', 'ANAME', 'DNAME']);
|
|
43
|
+
/**
|
|
44
|
+
* Content in a comparable form: host names (and SRV targets) lose case and the
|
|
45
|
+
* trailing dot, and IPv6 addresses are compressed. TXT content loses its
|
|
46
|
+
* zone-file quoting, with its character strings joined; its case is kept.
|
|
47
|
+
* Without this a correct zone can report drift forever. Compare with this,
|
|
48
|
+
* store what was written.
|
|
49
|
+
*/
|
|
50
|
+
export function normalizeContent(type, content) {
|
|
51
|
+
const kind = type.toUpperCase();
|
|
52
|
+
if (HOST_CONTENT.has(kind))
|
|
53
|
+
return clean(content);
|
|
54
|
+
if (kind === 'AAAA') {
|
|
55
|
+
try {
|
|
56
|
+
return new URL(`http://[${content.trim()}]`).hostname.slice(1, -1);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return content.trim().toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (kind === 'TXT') {
|
|
63
|
+
const text = content.trim();
|
|
64
|
+
const parts = /^"(?:[^"\\]|\\.)*"(?:\s*"(?:[^"\\]|\\.)*")*$/s.test(text)
|
|
65
|
+
? [...text.matchAll(/"((?:[^"\\]|\\.)*)"/gs)].map((match) => match[1].replace(/\\(.)/gs, '$1'))
|
|
66
|
+
: null;
|
|
67
|
+
return parts ? parts.join('') : text;
|
|
68
|
+
}
|
|
69
|
+
return content.trim();
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAiGA;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,SAAS,CAAgC;IACzC,MAAM,CAAe;IAC9B,uGAAuG;IAC9F,IAAI,CAAgB;IAC7B,oDAAoD;IAC3C,SAAS,CAAU;IAE5B,YAAY,SAAwC,EAAE,MAAoB,EAAE,KAAc;QACxF,KAAK,CAAC,OAAO,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,iBAAiB,SAAS,CAAC,MAAM,YAAY,EAAE;YACpH,KAAK;SACN,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAE,KAAiD,CAAC,CAAC,CAAC,EAAE,CAAC;QACpH,IAAI,CAAC,IAA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.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formless63/dns-plan",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Provider-neutral DNS record model, safe diff and change planning.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dns",
|
|
7
|
+
"reconcile",
|
|
8
|
+
"diff",
|
|
9
|
+
"zone"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/formless63/netlibs.git",
|
|
15
|
+
"directory": "packages/dns-plan"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/formless63/netlibs/tree/main/packages/dns-plan#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/formless63/netlibs/issues"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|