@homeflare/alchemy 0.28.0 → 0.29.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/README.md +2 -0
- package/dist/caddy/admin-address.d.ts +27 -0
- package/dist/caddy/admin-address.d.ts.map +1 -0
- package/dist/caddy/admin-calls.d.ts +25 -28
- package/dist/caddy/admin-calls.d.ts.map +1 -1
- package/dist/caddy/admin.d.ts +28 -38
- package/dist/caddy/admin.d.ts.map +1 -1
- package/dist/caddy/caddy-http-client.d.ts +25 -0
- package/dist/caddy/caddy-http-client.d.ts.map +1 -0
- package/dist/caddy/config-errors.d.ts +24 -0
- package/dist/caddy/config-errors.d.ts.map +1 -0
- package/dist/caddy/config-lifecycle.d.ts +20 -49
- package/dist/caddy/config-lifecycle.d.ts.map +1 -1
- package/dist/caddy/config-reconcile.d.ts +45 -0
- package/dist/caddy/config-reconcile.d.ts.map +1 -0
- package/dist/caddy/config.d.ts +4 -3
- package/dist/caddy/config.d.ts.map +1 -1
- package/dist/caddy/fake-caddy.d.ts +10 -2
- package/dist/caddy/fake-caddy.d.ts.map +1 -1
- package/dist/caddy/index.d.ts +3 -3
- package/dist/caddy/index.d.ts.map +1 -1
- package/dist/caddy/index.js +487 -444
- package/dist/caddy/index.js.map +16 -12
- package/dist/caddy/local-admin.d.ts +20 -34
- package/dist/caddy/local-admin.d.ts.map +1 -1
- package/dist/caddy/providers.d.ts +19 -3
- package/dist/caddy/providers.d.ts.map +1 -1
- package/dist/cloudflare/mesh-node-token.d.ts +1 -1
- package/dist/cloudflare/mesh-node-token.d.ts.map +1 -1
- package/dist/forgejo/branch-protection.d.ts +4 -4
- package/dist/forgejo/org-actions-secrets.d.ts +4 -4
- package/dist/forgejo/org-label.d.ts +4 -4
- package/dist/forgejo/org-team.d.ts +4 -4
- package/dist/forgejo/repo-webhook.d.ts +4 -4
- package/dist/forgejo/repository.d.ts +4 -4
- package/dist/forgejo/team-member.d.ts +4 -4
- package/dist/github/declare-repo-baseline.d.ts +1 -1
- package/dist/github/declare-repo-baseline.d.ts.map +1 -1
- package/dist/github/index.d.ts +8 -4
- package/dist/github/index.d.ts.map +1 -1
- package/dist/github/index.js +63 -23
- package/dist/github/index.js.map +13 -12
- package/dist/github/repo-baseline-data.d.ts +10 -1
- package/dist/github/repo-baseline-data.d.ts.map +1 -1
- package/dist/github/repo-policy.d.ts +1 -1
- package/dist/github/repo-policy.d.ts.map +1 -1
- package/dist/github/repository-ruleset-errors.d.ts +3 -2
- package/dist/github/repository-ruleset-errors.d.ts.map +1 -1
- package/dist/github/repository-ruleset-form.d.ts.map +1 -1
- package/dist/github/repository-ruleset-guards.d.ts +3 -2
- package/dist/github/repository-ruleset-guards.d.ts.map +1 -1
- package/dist/github/repository-ruleset-octokit.d.ts +49 -0
- package/dist/github/repository-ruleset-octokit.d.ts.map +1 -1
- package/dist/github/repository-ruleset-probe.d.ts +2 -1
- package/dist/github/repository-ruleset-probe.d.ts.map +1 -1
- package/dist/github/repository-ruleset-props.d.ts +7 -4
- package/dist/github/repository-ruleset-props.d.ts.map +1 -1
- package/dist/github/repository-ruleset-providers.d.ts +42 -0
- package/dist/github/repository-ruleset-providers.d.ts.map +1 -0
- package/dist/github/repository-ruleset.d.ts +26 -4
- package/dist/github/repository-ruleset.d.ts.map +1 -1
- package/dist/litellm/fake-litellm.d.ts +27 -16
- package/dist/litellm/fake-litellm.d.ts.map +1 -1
- package/dist/litellm/fake-stack.d.ts +9 -4
- package/dist/litellm/fake-stack.d.ts.map +1 -1
- package/dist/litellm/index.d.ts +7 -5
- package/dist/litellm/index.d.ts.map +1 -1
- package/dist/litellm/index.js +53 -123
- package/dist/litellm/index.js.map +8 -8
- package/dist/litellm/operations.d.ts +60 -0
- package/dist/litellm/operations.d.ts.map +1 -0
- package/dist/litellm/pass-through-endpoint.d.ts +10 -28
- package/dist/litellm/pass-through-endpoint.d.ts.map +1 -1
- package/dist/litellm/pass-through-errors.d.ts +37 -0
- package/dist/litellm/pass-through-errors.d.ts.map +1 -0
- package/dist/litellm/pass-through-form.d.ts +11 -4
- package/dist/litellm/pass-through-form.d.ts.map +1 -1
- package/dist/litellm/providers.d.ts +7 -5
- package/dist/litellm/providers.d.ts.map +1 -1
- package/dist/netbox/prefix.d.ts +4 -4
- package/dist/paperless/custom-field.d.ts +21 -21
- package/dist/paperless/custom-field.d.ts.map +1 -1
- package/dist/paperless/document-type.d.ts +34 -4
- package/dist/paperless/document-type.d.ts.map +1 -1
- package/dist/paperless/fake-paperless.d.ts +36 -19
- package/dist/paperless/fake-paperless.d.ts.map +1 -1
- package/dist/paperless/index.d.ts +7 -2
- package/dist/paperless/index.d.ts.map +1 -1
- package/dist/paperless/index.js +164 -228
- package/dist/paperless/index.js.map +10 -13
- package/dist/paperless/matching-locate.d.ts +42 -20
- package/dist/paperless/matching-locate.d.ts.map +1 -1
- package/dist/paperless/matching-types.d.ts +47 -18
- package/dist/paperless/matching-types.d.ts.map +1 -1
- package/dist/paperless/matching.d.ts +30 -27
- package/dist/paperless/matching.d.ts.map +1 -1
- package/dist/paperless/providers.d.ts +13 -7
- package/dist/paperless/providers.d.ts.map +1 -1
- package/dist/paperless/storage-path.d.ts +34 -4
- package/dist/paperless/storage-path.d.ts.map +1 -1
- package/dist/paperless/tag.d.ts +43 -8
- package/dist/paperless/tag.d.ts.map +1 -1
- package/dist/proxmox/acl.d.ts +30 -23
- package/dist/proxmox/acl.d.ts.map +1 -1
- package/dist/proxmox/distilled-pve.d.ts +89 -0
- package/dist/proxmox/distilled-pve.d.ts.map +1 -0
- package/dist/proxmox/index.js +663 -609
- package/dist/proxmox/index.js.map +12 -11
- package/dist/proxmox/members.d.ts +29 -10
- package/dist/proxmox/members.d.ts.map +1 -1
- package/docs/caddy-admin.md +1 -1
- package/docs/caddy.md +3 -2
- package/docs/credentials.md +16 -0
- package/docs/litellm.md +21 -13
- package/docs/paperless.md +12 -0
- package/docs/peers.md +5 -0
- package/docs/repo-policy.md +16 -1
- package/docs/repository-ruleset.md +53 -13
- package/docs/upstream-conformance.md +126 -10
- package/package.json +5 -2
- package/src/caddy/admin-address.ts +71 -0
- package/src/caddy/admin-calls.ts +48 -100
- package/src/caddy/admin.ts +37 -41
- package/src/caddy/adopt-scope.test.ts +1 -1
- package/src/caddy/caddy-http-client.ts +229 -0
- package/src/caddy/config-adopt-provider.test.ts +139 -0
- package/src/caddy/config-adopt.test.ts +60 -126
- package/src/caddy/config-errors.ts +47 -0
- package/src/caddy/config-lifecycle.test.ts +55 -42
- package/src/caddy/config-lifecycle.ts +72 -162
- package/src/caddy/config-reconcile.ts +138 -0
- package/src/caddy/config.ts +36 -42
- package/src/caddy/fake-caddy.ts +20 -2
- package/src/caddy/index.ts +3 -8
- package/src/caddy/local-admin.test.ts +35 -21
- package/src/caddy/local-admin.ts +60 -167
- package/src/caddy/providers.test.ts +14 -6
- package/src/caddy/providers.ts +20 -4
- package/src/github/declare-repo-baseline.ts +6 -6
- package/src/github/index.ts +8 -4
- package/src/github/repo-baseline-data.test.ts +13 -0
- package/src/github/repo-baseline-data.ts +11 -2
- package/src/github/repo-policy-stack.test.ts +59 -0
- package/src/github/repo-policy.ts +3 -2
- package/src/github/repository-ruleset-errors.ts +6 -4
- package/src/github/repository-ruleset-exact-adopt-k1.test.ts +109 -0
- package/src/github/repository-ruleset-exact-adopt.test.ts +14 -9
- package/src/github/repository-ruleset-form.ts +7 -3
- package/src/github/repository-ruleset-guards.ts +3 -2
- package/src/github/repository-ruleset-octokit.test.ts +141 -0
- package/src/github/repository-ruleset-octokit.ts +121 -30
- package/src/github/repository-ruleset-probe.ts +2 -1
- package/src/github/repository-ruleset-props.ts +7 -4
- package/src/github/repository-ruleset-providers.ts +46 -0
- package/src/github/repository-ruleset-wire.test.ts +38 -27
- package/src/github/repository-ruleset.ts +27 -3
- package/src/litellm/fake-litellm.ts +83 -78
- package/src/litellm/fake-stack.ts +13 -5
- package/src/litellm/index.ts +7 -21
- package/src/litellm/operations.ts +149 -0
- package/src/litellm/pass-through-endpoint-delete-swallow.test.ts +17 -20
- package/src/litellm/pass-through-endpoint-replace.test.ts +3 -4
- package/src/litellm/pass-through-endpoint.test.ts +8 -8
- package/src/litellm/pass-through-endpoint.ts +21 -31
- package/src/litellm/pass-through-errors.ts +37 -0
- package/src/litellm/pass-through-form.ts +20 -10
- package/src/litellm/providers.ts +8 -7
- package/src/paperless/custom-field.test.ts +49 -40
- package/src/paperless/custom-field.ts +57 -33
- package/src/paperless/document-type.test.ts +48 -0
- package/src/paperless/document-type.ts +51 -22
- package/src/paperless/fake-paperless.ts +63 -72
- package/src/paperless/index.ts +7 -13
- package/src/paperless/matching-locate.test.ts +102 -0
- package/src/paperless/matching-locate.ts +80 -86
- package/src/paperless/matching-types.ts +49 -16
- package/src/paperless/matching.ts +77 -90
- package/src/paperless/providers.ts +14 -10
- package/src/paperless/storage-path.test.ts +56 -0
- package/src/paperless/storage-path.ts +53 -24
- package/src/paperless/tag-identity.test.ts +127 -0
- package/src/paperless/tag.test.ts +100 -0
- package/src/paperless/tag.ts +62 -32
- package/src/proxmox/acl.test.ts +145 -0
- package/src/proxmox/acl.ts +128 -150
- package/src/proxmox/distilled-pve.test.ts +231 -0
- package/src/proxmox/distilled-pve.ts +147 -0
- package/src/proxmox/members-timeout.test.ts +161 -0
- package/src/proxmox/members.test.ts +9 -0
- package/src/proxmox/members.ts +36 -2
- package/dist/litellm/client.d.ts +0 -76
- package/dist/litellm/client.d.ts.map +0 -1
- package/dist/litellm/credentials.d.ts +0 -48
- package/dist/litellm/credentials.d.ts.map +0 -1
- package/dist/litellm/generated/pass-through.d.ts +0 -71
- package/dist/litellm/generated/pass-through.d.ts.map +0 -1
- package/dist/paperless/client.d.ts +0 -37
- package/dist/paperless/client.d.ts.map +0 -1
- package/dist/paperless/credentials.d.ts +0 -40
- package/dist/paperless/credentials.d.ts.map +0 -1
- package/dist/paperless/errors.d.ts +0 -49
- package/dist/paperless/errors.d.ts.map +0 -1
- package/src/litellm/client.ts +0 -195
- package/src/litellm/credentials.ts +0 -73
- package/src/litellm/generated/pass-through.ts +0 -73
- package/src/paperless/client.ts +0 -88
- package/src/paperless/credentials.ts +0 -69
- package/src/paperless/errors.ts +0 -62
- package/src/paperless/matching-identity.test.ts +0 -194
- package/src/paperless/matching.test.ts +0 -128
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ Custom [Alchemy](https://alchemy.run) providers for gaps the vendor SDK leaves.
|
|
|
6
6
|
bun add @homeflare/alchemy alchemy@2.0.0-beta.79 effect@4.0.0-rc.115 \
|
|
7
7
|
@effect/platform-node@4.0.0-rc.115 mime@4.1.0 \
|
|
8
8
|
@distilled.cloud/cloudflare@1.0.0-rc.12 @distilled.cloud/forgejo@1.0.0-rc.12 \
|
|
9
|
+
@distilled.cloud/discord@1.0.0-rc.12 @distilled.cloud/google-workspace@1.0.0-rc.12 \
|
|
10
|
+
@distilled.cloud/grafana@1.0.0-rc.12 \
|
|
9
11
|
@effect/sql-pg@4.0.0-rc.115
|
|
10
12
|
```
|
|
11
13
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a `localCaddyAdmin()` address into a dial target and the listener Caddy checks requests
|
|
3
|
+
* against — pure, so admin-guard.ts and local-admin.ts's tests exercise it with no transport at all.
|
|
4
|
+
*
|
|
5
|
+
* ★ LOOPBACK OR A UNIX SOCKET, NOTHING ELSE. The admin API is unauthenticated plaintext; an address
|
|
6
|
+
* off this machine means it is reachable from the network, which decision 23 forbids. Reaching
|
|
7
|
+
* another host's Caddy means forwarding its socket or port to here (SSH), never exposing :2019.
|
|
8
|
+
* ★ HOST, AS CADDY's OWN CLI SENDS IT (cmd/commandfuncs.go AdminAPIRequest): `host:port`, over TCP.
|
|
9
|
+
* MEASURED against a Mac host's Caddy 2.11.4: any other Host gets 403 `host not allowed`, a
|
|
10
|
+
* forwarded port included — hence `hostHeader`.
|
|
11
|
+
*/
|
|
12
|
+
import type { CaddyAdminListener } from './admin.ts';
|
|
13
|
+
export type Target = {
|
|
14
|
+
readonly kind: 'tcp';
|
|
15
|
+
readonly host: string;
|
|
16
|
+
readonly port: number;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'unix';
|
|
19
|
+
readonly socketPath: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const DEFAULT_ADMIN_ADDRESS = "http://127.0.0.1:2019";
|
|
22
|
+
/** The dial target and listener for an address, or a refusal naming what is wrong with it. */
|
|
23
|
+
export declare const parseAdminAddress: (address: string, hostHeader?: string) => {
|
|
24
|
+
target: Target;
|
|
25
|
+
listener: CaddyAdminListener;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=admin-address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-address.d.ts","sourceRoot":"","sources":["../../src/caddy/admin-address.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,MAAM,MAAM,GACd;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAW7D,8FAA8F;AAC9F,eAAO,MAAM,iBAAiB,YACnB,MAAM,eACF,MAAM,KAClB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,kBAAkB,CAAA;CAsChD,CAAC"}
|
|
@@ -1,48 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The three admin API calls the provider makes,
|
|
3
|
-
*
|
|
2
|
+
* The three admin API calls the provider makes, through `@distilled.cloud/caddy`'s typed `admin`
|
|
3
|
+
* operations — `catchTag`-able errors, never a status check in this file.
|
|
4
4
|
*
|
|
5
5
|
* Read in caddyserver/caddy v2.11.4 (and the API docs, caddyserver.com/docs/api):
|
|
6
|
-
* · `POST /adapt` — adapts without running (load.go handleAdapt)
|
|
7
|
-
*
|
|
8
|
-
* · `POST /load` — Content-Type `text/caddyfile` picks the adapter (load.go
|
|
9
|
-
* "if the new config fails for any reason, the old config is rolled back
|
|
10
|
-
* downtime" (docs; caddy.go changeConfig restores the previous raw config).
|
|
11
|
-
* config is a no-op without `Cache-Control: must-revalidate`.
|
|
12
|
-
* · `GET /config/` — the running config as JSON, `null` when empty (admin.go
|
|
6
|
+
* · `POST /adapt` (`adaptConfig`) — adapts without running (load.go handleAdapt). Side-effect
|
|
7
|
+
* free, so it is what plan-time validation uses.
|
|
8
|
+
* · `POST /load` (`loadConfig`) — Content-Type `text/caddyfile` picks the adapter (load.go
|
|
9
|
+
* adaptByContentType); "if the new config fails for any reason, the old config is rolled back
|
|
10
|
+
* into place without downtime" (docs; caddy.go changeConfig restores the previous raw config).
|
|
11
|
+
* An identical config is a no-op without `Cache-Control: must-revalidate`.
|
|
12
|
+
* · `GET /config/` (`getConfig`) — the running config as JSON, `null` when empty (admin.go
|
|
13
|
+
* handleConfig).
|
|
13
14
|
* ⛔ A FAILED LOAD CAN ANSWER 200. load.go writes the adapter's WARNINGS to the body before it
|
|
14
15
|
* runs the config; if the run then fails, the error JSON is appended to a response whose status
|
|
15
|
-
* is already 200
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* status
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* `[{"file":"Caddyfile","line":8,"message":"Caddyfile input is not formatted; …"}]{"error":"loading
|
|
22
|
-
* config: … bind: address already in use"}`, and Caddy kept serving the previous config.
|
|
16
|
+
* is already 200. The Caddyfile adapter warns on every unformatted input (adapter.go
|
|
17
|
+
* FormattingDifference), so this is the COMMON failure shape, not an edge. The SDK's own
|
|
18
|
+
* `CaddyProtocol` (`packages/distilled-caddy/src/protocol.ts`) scans `loadConfig`'s body for the
|
|
19
|
+
* embedded error on every status and fails with the typed `LoadRefused` — `catchTag`'d below,
|
|
20
|
+
* never a status check here. The lifecycle also reads the config back after every load anyway
|
|
21
|
+
* (config-lifecycle.ts).
|
|
23
22
|
*/
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
readonly status: number;
|
|
27
|
-
readonly method: string;
|
|
28
|
-
readonly path: string;
|
|
29
|
-
constructor(status: number, method: string, path: string, reason: string);
|
|
30
|
-
}
|
|
23
|
+
import * as Effect from 'effect/Effect';
|
|
24
|
+
import * as Caddy from '@distilled.cloud/caddy';
|
|
31
25
|
export type Adapted = {
|
|
32
26
|
readonly config: unknown;
|
|
33
27
|
readonly warnings: readonly string[];
|
|
34
28
|
};
|
|
35
29
|
/** Adapt a Caddyfile to JSON on the running Caddy, without loading it. */
|
|
36
|
-
export declare const adaptCaddyfile: (
|
|
30
|
+
export declare const adaptCaddyfile: (caddyfile: string) => Effect.Effect<Adapted, Caddy.CaddyOpError, Caddy.CaddyOpContext>;
|
|
37
31
|
/** The running config, parsed; `null` when Caddy runs with none. */
|
|
38
|
-
export declare const readRunningConfig: (
|
|
32
|
+
export declare const readRunningConfig: () => Effect.Effect<unknown, Caddy.CaddyOpError, Caddy.CaddyOpContext>;
|
|
39
33
|
/**
|
|
40
|
-
* Apply a Caddyfile with `POST /load`; resolves with the adapter's warnings.
|
|
34
|
+
* Apply a Caddyfile with `POST /load`; resolves with the adapter's warnings. A refused load
|
|
35
|
+
* (`LoadRefused` — the ⛔ above) propagates as that typed error, unretried by anything in this
|
|
36
|
+
* file — config-lifecycle.ts's `reconcileConfig` is where a refusal turns into a message naming
|
|
37
|
+
* what is still running.
|
|
41
38
|
*
|
|
42
39
|
* ★ `sourceFile` RIDES AS `Caddy-Config-Source-File` (+ `-Adapter: caddyfile`), the headers
|
|
43
40
|
* `caddy reload` sends (cmd/commandfuncs.go). A load WITHOUT them makes Caddy forget the file it
|
|
44
41
|
* was started with (caddy.go ClearLastConfigIfDifferent), and SIGUSR1 then no longer reloads
|
|
45
42
|
* from that file. With them, and the same path, it keeps it.
|
|
46
43
|
*/
|
|
47
|
-
export declare const loadCaddyfile: (
|
|
44
|
+
export declare const loadCaddyfile: (caddyfile: string, sourceFile?: string) => Effect.Effect<readonly string[], Caddy.CaddyOpError, Caddy.CaddyOpContext>;
|
|
48
45
|
//# sourceMappingURL=admin-calls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-calls.d.ts","sourceRoot":"","sources":["../../src/caddy/admin-calls.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin-calls.d.ts","sourceRoot":"","sources":["../../src/caddy/admin-calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAShD,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEzF,0EAA0E;AAC1E,eAAO,MAAM,cAAc,cACd,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,cAAc,CAO/D,CAAC;AAEJ,oEAAoE;AACpE,eAAO,MAAM,iBAAiB,QAAO,MAAM,CAAC,MAAM,CAChD,OAAO,EACP,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,cAAc,CAC6E,CAAC;AAEpG;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,cACb,MAAM,eACJ,MAAM,KAClB,MAAM,CAAC,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,cAAc,CAQzE,CAAC"}
|
package/dist/caddy/admin.d.ts
CHANGED
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The one seam between the Caddy provider and a running Caddy: every
|
|
3
|
-
*
|
|
2
|
+
* The one seam between the Caddy provider and a running Caddy: every operation goes through
|
|
3
|
+
* `@distilled.cloud/caddy`'s typed `Services.admin.*` calls (admin-calls.ts), over the
|
|
4
|
+
* `CaddyAdminService` metadata and the `Credentials` + `HttpClient` layers `localCaddyAdmin()`
|
|
5
|
+
* builds (local-admin.ts) — nothing in this directory reaches Caddy any other way.
|
|
4
6
|
*
|
|
5
7
|
* ★ CADDY's OWN MANAGEMENT API, NOT A FILE AND A SIGNAL. Decision 23 (vault consolidation plan,
|
|
6
8
|
* 2026-09-21): `POST /load` applies a Caddyfile with a graceful reload and rolls back a config
|
|
7
9
|
* Caddy refuses; `GET /config/` reports what is running. Read in caddyserver/caddy v2.11.4,
|
|
8
10
|
* caddyconfig/load.go and admin.go, and in the API docs (caddyserver.com/docs/api).
|
|
9
|
-
* ★
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* ★ `CaddyAdminService` CARRIES ONLY MESSAGE/GUARD METADATA (endpoint, listener) — never a
|
|
12
|
+
* credential, and never the transport itself. The transport is `@distilled.cloud/caddy`'s own
|
|
13
|
+
* `Credentials` and `HttpClient.HttpClient` services, provided alongside it by `caddyAdminLayer`,
|
|
14
|
+
* so admin-calls.ts calls the SDK's operations directly rather than through a house-specific
|
|
15
|
+
* `.request()` seam. A consumer plugs in another route to the API (an SSH-forwarded socket today;
|
|
16
|
+
* a remote runner later) by providing a different `CaddyTransport` to `caddyAdminLayer`.
|
|
13
17
|
* ⛔ THE ADMIN API HAS NO AUTHENTICATION. Anyone who reaches it can replace every site. It stays on
|
|
14
18
|
* loopback or a unix socket; localCaddyAdmin() refuses anything else (local-admin.ts).
|
|
15
19
|
*/
|
|
20
|
+
import type * as HttpClient from 'effect/unstable/http/HttpClient';
|
|
16
21
|
import * as Context from 'effect/Context';
|
|
17
22
|
import * as Layer from 'effect/Layer';
|
|
18
|
-
|
|
19
|
-
export type CaddyAdminResponse = {
|
|
20
|
-
readonly status: number;
|
|
21
|
-
readonly body: string;
|
|
22
|
-
};
|
|
23
|
-
export type CaddyAdminRequest = {
|
|
24
|
-
readonly method: 'GET' | 'POST';
|
|
25
|
-
/** Absolute API path: `/load`, `/adapt`, `/config/`. */
|
|
26
|
-
readonly path: string;
|
|
27
|
-
readonly headers?: Readonly<Record<string, string>>;
|
|
28
|
-
readonly body?: string;
|
|
29
|
-
};
|
|
23
|
+
import type { Credentials } from '@distilled.cloud/caddy';
|
|
30
24
|
/**
|
|
31
25
|
* Where the admin listener is, in the terms Caddy's own `admin` option uses — so a Caddyfile that
|
|
32
26
|
* would move the listener away from where the provider talks to it can be refused (admin-guard.ts).
|
|
@@ -39,35 +33,31 @@ export type CaddyAdminListener = {
|
|
|
39
33
|
readonly kind: 'unix';
|
|
40
34
|
readonly path: string;
|
|
41
35
|
};
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
/** Message/guard metadata for the Caddy this stack talks to — never a credential. */
|
|
37
|
+
export interface CaddyTarget {
|
|
38
|
+
/** Where requests go, for error messages and the resource's attributes. */
|
|
44
39
|
readonly endpoint: string;
|
|
45
40
|
/**
|
|
46
41
|
* The listener as Caddy sees it. `hostHeader` is the Host every request carries: Caddy checks it
|
|
47
42
|
* against `admin.origins` (admin.go checkHost) on any loopback TCP listener.
|
|
48
43
|
*/
|
|
49
44
|
readonly listener: CaddyAdminListener;
|
|
50
|
-
/**
|
|
51
|
-
* Send one request. Resolves with ANY status — classifying it is the caller's job
|
|
52
|
-
* (admin-calls.ts). Rejects only when there was no HTTP exchange at all: with a
|
|
53
|
-
* CaddyUnreachableError when nothing accepted the connection, any other Error otherwise.
|
|
54
|
-
*/
|
|
55
|
-
request(request: CaddyAdminRequest): Promise<CaddyAdminResponse>;
|
|
56
45
|
}
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
* PLAN that would bring it back (its launchd job in the same stack) — see config.ts.
|
|
62
|
-
*/
|
|
63
|
-
export declare class CaddyUnreachableError extends Error {
|
|
64
|
-
readonly name = "CaddyUnreachableError";
|
|
46
|
+
/** What `localCaddyAdmin()` (or a consumer's own transport) hands `caddyAdminLayer`. */
|
|
47
|
+
export interface CaddyTransport extends CaddyTarget {
|
|
48
|
+
/** Provides the SDK's own `Credentials` and `HttpClient.HttpClient` — see local-admin.ts. */
|
|
49
|
+
readonly layer: Layer.Layer<Credentials | HttpClient.HttpClient>;
|
|
65
50
|
}
|
|
66
|
-
declare const CaddyAdminService_base: Context.ServiceClass<CaddyAdminService, "homeflare/caddy/CaddyAdmin",
|
|
67
|
-
/** The Effect service the Caddy provider reads its admin
|
|
51
|
+
declare const CaddyAdminService_base: Context.ServiceClass<CaddyAdminService, "homeflare/caddy/CaddyAdmin", CaddyTarget>;
|
|
52
|
+
/** The Effect service the Caddy provider reads its admin target's metadata from. */
|
|
68
53
|
export declare class CaddyAdminService extends CaddyAdminService_base {
|
|
69
54
|
}
|
|
70
|
-
/**
|
|
71
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Provide a transport to the provider: `CaddyConfigProvider().pipe(Layer.provideMerge(caddyAdminLayer(localCaddyAdmin())))`
|
|
57
|
+
* — never plain `Layer.provide` here (see providers.ts's own ⚠️): `CaddyConfigProvider()`'s handlers
|
|
58
|
+
* keep needing these services every time the engine calls them, not just once while it is built. Merges
|
|
59
|
+
* the target metadata with the SDK's `Credentials`/`HttpClient` layers `transport.layer` carries.
|
|
60
|
+
*/
|
|
61
|
+
export declare const caddyAdminLayer: (transport: CaddyTransport) => Layer.Layer<CaddyAdminService | Credentials | HttpClient.HttpClient>;
|
|
72
62
|
export {};
|
|
73
63
|
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/caddy/admin.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/caddy/admin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,KAAK,UAAU,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5E;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,qFAAqF;AACrF,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;CACvC;AAED,wFAAwF;AACxF,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;CAClE;;AAED,oFAAoF;AACpF,qBAAa,iBAAkB,SAAQ,sBAEtC;CAAG;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,eAAe,cACf,cAAc,KACxB,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAOnE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as Layer from 'effect/Layer';
|
|
2
|
+
import * as HttpClient from 'effect/unstable/http/HttpClient';
|
|
3
|
+
import * as HttpClientError from 'effect/unstable/http/HttpClientError';
|
|
4
|
+
import type { Target } from './admin-address.ts';
|
|
5
|
+
export type LocalHttpClientOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Abort an exchange after this long. @default 60_000
|
|
8
|
+
* ⚠️ A `shutdown_delay` in the Caddyfile makes `/load` block that long (caddyhttp app.go Stop);
|
|
9
|
+
* a timeout then fails the deploy while Caddy goes on to apply — the next plan converges.
|
|
10
|
+
*/
|
|
11
|
+
readonly timeoutMs?: number;
|
|
12
|
+
/** Retries when the connection is REFUSED — see the module doc. @default 2 */
|
|
13
|
+
readonly retries?: number;
|
|
14
|
+
/** @default 500 */
|
|
15
|
+
readonly retryDelayMs?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Nothing accepted the connection — see the module doc's ★. A type guard, not just a predicate, so
|
|
19
|
+
* config-lifecycle.ts's error-wrapping can pass through the raw error unchanged (still typed) and
|
|
20
|
+
* config.ts's plan-time escape hatch (`Effect.catchIf`) narrows to it directly.
|
|
21
|
+
*/
|
|
22
|
+
export declare const isUnreachable: (error: unknown) => error is HttpClientError.HttpClientError;
|
|
23
|
+
/** The transport `localCaddyAdmin()` provides as `HttpClient.HttpClient` — see local-admin.ts. */
|
|
24
|
+
export declare const makeLocalHttpClient: (target: Target, options?: LocalHttpClientOptions) => Layer.Layer<HttpClient.HttpClient>;
|
|
25
|
+
//# sourceMappingURL=caddy-http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caddy-http-client.d.ts","sourceRoot":"","sources":["../../src/caddy/caddy-http-client.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,eAAe,MAAM,sCAAsC,CAAC;AAGxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB;IACnB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AASF;;;;GAIG;AACH,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,KAAK,IAAI,eAAe,CAAC,eAGjB,CAAC;AA4JxD,kGAAkG;AAClG,eAAO,MAAM,mBAAmB,WACtB,MAAM,YACL,sBAAsB,KAC9B,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAWnC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a distilled `@distilled.cloud/caddy` operation failure into a readable refusal — shared
|
|
3
|
+
* by config-lifecycle.ts and config-reconcile.ts, so both read the same way.
|
|
4
|
+
*/
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import type * as Caddy from '@distilled.cloud/caddy';
|
|
7
|
+
export declare const refuse: (endpoint: string, message: string) => Error;
|
|
8
|
+
export declare const short: (digest: string) => string;
|
|
9
|
+
/** Every `CaddyOpError` member carries `.message` (a `Schema.TaggedError` field) — see errors.ts. */
|
|
10
|
+
export declare const messageOf: (error: Caddy.CaddyOpError) => string;
|
|
11
|
+
/**
|
|
12
|
+
* A distilled operation's typed failure, read the way this resource's own refusals read:
|
|
13
|
+
* `LoadRefused` (the 200-embedded-error trap admin-calls.ts's module doc describes) says so
|
|
14
|
+
* explicitly, so a grep for "kept the previous config" is never mistaken for an ordinary 4xx/5xx.
|
|
15
|
+
*/
|
|
16
|
+
export declare const operationFailure: (endpoint: string, op: string, error: Caddy.CaddyOpError) => Error;
|
|
17
|
+
/**
|
|
18
|
+
* Humanizes every failure from a distilled operation EXCEPT one nothing accepted the connection
|
|
19
|
+
* for — that stays the raw, still-typed `HttpClientError` so config.ts's plan-time escape hatch
|
|
20
|
+
* (`Effect.catchIf(isUnreachable, …)`) can keep narrowing to it after this wrapping, the same way
|
|
21
|
+
* it could inspect the un-wrapped error before this function ran.
|
|
22
|
+
*/
|
|
23
|
+
export declare const wrapOperation: (endpoint: string, op: string) => <A>(effect: Effect.Effect<A, Caddy.CaddyOpError, Caddy.CaddyOpContext>) => Effect.Effect<A, Error | Caddy.CaddyOpError, Caddy.CaddyOpContext>;
|
|
24
|
+
//# sourceMappingURL=config-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-errors.d.ts","sourceRoot":"","sources":["../../src/caddy/config-errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAGrD,eAAO,MAAM,MAAM,aAAc,MAAM,WAAW,MAAM,KAAG,KACL,CAAC;AAEvD,eAAO,MAAM,KAAK,WAAY,MAAM,KAAG,MAA6B,CAAC;AAErE,qGAAqG;AACrG,eAAO,MAAM,SAAS,UAAW,KAAK,CAAC,YAAY,KAAG,MACmC,CAAC;AAE1F;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,aAAc,MAAM,MAAM,MAAM,SAAS,KAAK,CAAC,YAAY,KAAG,KAOf,CAAC;AAE7E;;;;;GAKG;AACH,eAAO,MAAM,aAAa,aACb,MAAM,MAAM,MAAM,MAC5B,CAAC,UACQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,KACjE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,cAAc,CAKjE,CAAC"}
|
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CaddyConfig's
|
|
3
|
-
* lifecycle runs against a fake admin server in tests
|
|
2
|
+
* CaddyConfig's validate / read / probe as Effects over `@distilled.cloud/caddy`'s typed `admin`
|
|
3
|
+
* operations (admin-calls.ts), so the lifecycle runs against a fake admin server in tests — and,
|
|
4
|
+
* since fake-caddy.ts is a real HTTP server, against the real distilled wire protocol too.
|
|
5
|
+
* config-reconcile.ts covers `diff`/`reconcile`, the other half of the same lifecycle.
|
|
4
6
|
*
|
|
5
7
|
* The comparison is always between DIGESTS OF ADAPTED JSON (digest.ts): what `POST /adapt` makes
|
|
6
|
-
* of the declared Caddyfile
|
|
7
|
-
*
|
|
8
|
-
* · declared ≠ stored — the declaration changed.
|
|
9
|
-
* · live ≠ stored — DRIFT: a hand `curl` to the API, or a restart that loaded a different file
|
|
10
|
-
* (or an `autosave.json` holding someone else's change, under `--resume`).
|
|
11
|
-
* · declared = live — nothing to load, whatever the state says.
|
|
12
|
-
* With NO state there is no stored digest, and the question is whose config is running: see
|
|
13
|
-
* `claimable` below, which both the adoption probe and the apply ask.
|
|
8
|
+
* of the declared Caddyfile and what `GET /config/` reports — `claimable` below asks whether a
|
|
9
|
+
* running config is provably the declared one, which both the adoption probe and the apply need.
|
|
14
10
|
*/
|
|
15
|
-
import
|
|
16
|
-
import
|
|
11
|
+
import * as Effect from 'effect/Effect';
|
|
12
|
+
import type * as Caddy from '@distilled.cloud/caddy';
|
|
13
|
+
import { CaddyAdminService } from './admin.ts';
|
|
17
14
|
import { type CaddyConfigAttributes, type CaddyConfigProps } from './config-form.ts';
|
|
18
15
|
type Desired = {
|
|
19
16
|
readonly digest: string;
|
|
20
17
|
readonly warnings: readonly string[];
|
|
21
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* ⛔ A CONFIG WITH NO APPS SERVES NOTHING. A Caddyfile of only comments or only global options
|
|
21
|
+
* passes the empty-text check (config-form.ts) yet adapts to `{}` or `{"admin":…}` — MEASURED
|
|
22
|
+
* 2026-09-21 on a throwaway Caddy 2.11.4 — and loading it stops every server: the same outage,
|
|
23
|
+
* from the same templating bug, that the empty check exists to prevent.
|
|
24
|
+
*/
|
|
25
|
+
export declare const servesNothing: (config: unknown) => boolean;
|
|
22
26
|
/**
|
|
23
27
|
* Validate the props, adapt the Caddyfile on the running Caddy, and check its `admin` block.
|
|
24
28
|
* ★ Every refusal happens HERE, before anything is loaded — and diff calls this at plan time, so a
|
|
25
29
|
* Caddyfile that does not adapt, carries a literal secret, or would strand the admin API fails the
|
|
26
30
|
* PLAN, before any resource (a HostFile holding the same text included) is applied.
|
|
27
31
|
*/
|
|
28
|
-
export declare const desiredConfig: (
|
|
32
|
+
export declare const desiredConfig: (props: CaddyConfigProps) => Effect.Effect<Desired, Error | Caddy.CaddyOpError, CaddyAdminService | Caddy.CaddyOpContext>;
|
|
33
|
+
export declare const attributesOf: (endpoint: string, running: unknown, sourceFile?: string) => CaddyConfigAttributes;
|
|
29
34
|
/** What is running now, as attributes. `sourceFile` is carried over, never discovered. */
|
|
30
|
-
export declare const readLive: (
|
|
35
|
+
export declare const readLive: (sourceFile?: string) => Effect.Effect<CaddyConfigAttributes, Error | Caddy.CaddyOpError, CaddyAdminService | Caddy.CaddyOpContext>;
|
|
31
36
|
/**
|
|
32
37
|
* ⛔ WITH NO STATE, A RUNNING CONFIG IS THIS STACK'S ONLY IF IT IS THE DECLARED ONE (decision,
|
|
33
38
|
* 2026-09-21: CaddyConfig must not adopt silently — the house rule HostFile and LaunchdJob keep).
|
|
@@ -52,40 +57,6 @@ export type Probe = {
|
|
|
52
57
|
* adapt then would fail every later plan, the one carrying the fix included. What cannot be
|
|
53
58
|
* compared is "not proven ours", with the reason; the next diff or apply validates the Caddyfile.
|
|
54
59
|
*/
|
|
55
|
-
export declare const probeLive: (
|
|
56
|
-
/**
|
|
57
|
-
* ★ NEVER `replace`. Nothing in the props names a different object: a new Caddyfile is a reload of
|
|
58
|
-
* the same Caddy, and `sourceFile` is a header. (Which Caddy is the transport's business — see
|
|
59
|
-
* the ⚠️ on `endpoint` in the diff.)
|
|
60
|
-
*/
|
|
61
|
-
export declare const diffConfig: (admin: CaddyAdmin, news: CaddyConfigProps, output: CaddyConfigAttributes) => Promise<Diff>;
|
|
62
|
-
export type Applied = {
|
|
63
|
-
readonly attributes: CaddyConfigAttributes;
|
|
64
|
-
/** The adapter's warnings (e.g. "Caddyfile input is not formatted") — log them, never refuse. */
|
|
65
|
-
readonly warnings: readonly string[];
|
|
66
|
-
/** Whether a `POST /load` was sent (false when Caddy already ran this config). */
|
|
67
|
-
readonly loaded: boolean;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* What this apply may load over — config.ts decides from the state and the adopt setting:
|
|
71
|
-
* · `takeOver` — any running config: the state was applied to THIS Caddy (an update, drift
|
|
72
|
-
* correction, or a create the engine adopted), or adoption is on (`--adopt`, or the
|
|
73
|
-
* resource's own `adopt(true)` — ownership/adopt.ts adoptEnabled).
|
|
74
|
-
* · otherwise only a claimable one — plus, as `stored`, the digest the state last recorded: a
|
|
75
|
-
* Caddy reached at a NEW endpoint that runs exactly that is the same config under another name.
|
|
76
|
-
*/
|
|
77
|
-
export type Authority = {
|
|
78
|
-
readonly takeOver: boolean;
|
|
79
|
-
readonly stored?: string;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Load the Caddyfile unless Caddy already runs it, then read it back and insist it matches.
|
|
83
|
-
* ⛔ WITHOUT `takeOver`, A CONFIG THE STACK CANNOT CLAIM IS NEVER LOADED OVER. The engine's adoption
|
|
84
|
-
* probe cannot guard every create: it is skipped while `news` holds an Output — ALWAYS on
|
|
85
|
-
* caddyWithFile's first deploy (`sourceFile` is its HostFile's path) — and a Caddy that was down at
|
|
86
|
-
* plan time read as nothing. Nor does state vouch for a Caddy the transport NOW reaches at another
|
|
87
|
-
* endpoint (diff plans that as an update). Refused here, before any `/load`, like HostFile's.
|
|
88
|
-
*/
|
|
89
|
-
export declare const reconcileConfig: (admin: CaddyAdmin, props: CaddyConfigProps, authority: Authority) => Promise<Applied>;
|
|
60
|
+
export declare const probeLive: (caddyfile: string | undefined, sourceFile?: string) => Effect.Effect<Probe | undefined, Caddy.CaddyOpError, CaddyAdminService | Caddy.CaddyOpContext>;
|
|
90
61
|
export {};
|
|
91
62
|
//# sourceMappingURL=config-lifecycle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-lifecycle.d.ts","sourceRoot":"","sources":["../../src/caddy/config-lifecycle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config-lifecycle.d.ts","sourceRoot":"","sources":["../../src/caddy/config-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,KAAK,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAK/C,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EAEtB,MAAM,kBAAkB,CAAC;AAG1B,KAAK,OAAO,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEjF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,WAAY,OAAO,KAAG,OAI/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,UACjB,gBAAgB,KACtB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,EAAE,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAgB1F,CAAC;AAEL,eAAO,MAAM,YAAY,aACb,MAAM,WACP,OAAO,eACH,MAAM,KAClB,qBAID,CAAC;AAEH,0FAA0F;AAC1F,eAAO,MAAM,QAAQ,gBACN,MAAM,KAClB,MAAM,CAAC,MAAM,CACd,qBAAqB,EACrB,KAAK,GAAG,KAAK,CAAC,YAAY,EAC1B,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAMtC,CAAC;AAEL;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,YAAa,OAAO,kBAAkB,MAAM,KAAG,OACD,CAAC;AAErE,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,iGAAiG;IACjG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,cACT,MAAM,GAAG,SAAS,eAChB,MAAM,KAClB,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,SAAS,EAAE,KAAK,CAAC,YAAY,EAAE,iBAAiB,GAAG,KAAK,CAAC,cAAc,CA6B5F,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CaddyConfig's diff / reconcile — the apply half of the lifecycle config-lifecycle.ts's
|
|
3
|
+
* `desiredConfig`/`readLive`/`probeLive` compute the inputs for. Split out at the 250-line file
|
|
4
|
+
* cap; the two files together are one lifecycle, read config-lifecycle.ts's module doc first.
|
|
5
|
+
*/
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import type * as Diff from 'alchemy/Diff';
|
|
8
|
+
import type * as Caddy from '@distilled.cloud/caddy';
|
|
9
|
+
import { CaddyAdminService } from './admin.ts';
|
|
10
|
+
import type { CaddyConfigAttributes, CaddyConfigProps } from './config-form.ts';
|
|
11
|
+
/**
|
|
12
|
+
* ★ NEVER `replace`. Nothing in the props names a different object: a new Caddyfile is a reload of
|
|
13
|
+
* the same Caddy, and `sourceFile` is a header. (Which Caddy is the transport's business — see
|
|
14
|
+
* the ⚠️ on `endpoint` in the diff.)
|
|
15
|
+
*/
|
|
16
|
+
export declare const diffConfig: (news: CaddyConfigProps, output: CaddyConfigAttributes) => Effect.Effect<Diff.Diff, Error | Caddy.CaddyOpError, CaddyAdminService | Caddy.CaddyOpContext>;
|
|
17
|
+
export type Applied = {
|
|
18
|
+
readonly attributes: CaddyConfigAttributes;
|
|
19
|
+
/** The adapter's warnings (e.g. "Caddyfile input is not formatted") — log them, never refuse. */
|
|
20
|
+
readonly warnings: readonly string[];
|
|
21
|
+
/** Whether a `POST /load` was sent (false when Caddy already ran this config). */
|
|
22
|
+
readonly loaded: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* What this apply may load over — config.ts decides from the state and the adopt setting:
|
|
26
|
+
* · `takeOver` — any running config: the state was applied to THIS Caddy (an update, drift
|
|
27
|
+
* correction, or a create the engine adopted), or adoption is on (`--adopt`, or the
|
|
28
|
+
* resource's own `adopt(true)` — ownership/adopt.ts adoptEnabled).
|
|
29
|
+
* · otherwise only a claimable one — plus, as `stored`, the digest the state last recorded: a
|
|
30
|
+
* Caddy reached at a NEW endpoint that runs exactly that is the same config under another name.
|
|
31
|
+
*/
|
|
32
|
+
export type Authority = {
|
|
33
|
+
readonly takeOver: boolean;
|
|
34
|
+
readonly stored?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Load the Caddyfile unless Caddy already runs it, then read it back and insist it matches.
|
|
38
|
+
* ⛔ WITHOUT `takeOver`, A CONFIG THE STACK CANNOT CLAIM IS NEVER LOADED OVER. The engine's adoption
|
|
39
|
+
* probe cannot guard every create: it is skipped while `news` holds an Output — ALWAYS on
|
|
40
|
+
* caddyWithFile's first deploy (`sourceFile` is its HostFile's path) — and a Caddy that was down at
|
|
41
|
+
* plan time read as nothing. Nor does state vouch for a Caddy the transport NOW reaches at another
|
|
42
|
+
* endpoint (diff plans that as an update). Refused here, before any `/load`, like HostFile's.
|
|
43
|
+
*/
|
|
44
|
+
export declare const reconcileConfig: (props: CaddyConfigProps, authority: Authority) => Effect.Effect<Applied, Error | Caddy.CaddyOpError, CaddyAdminService | Caddy.CaddyOpContext>;
|
|
45
|
+
//# sourceMappingURL=config-reconcile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-reconcile.d.ts","sourceRoot":"","sources":["../../src/caddy/config-reconcile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,IAAI,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,KAAK,KAAK,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIhF;;;;GAIG;AACH,eAAO,MAAM,UAAU,SACf,gBAAgB,UACd,qBAAqB,KAC5B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,EAAE,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAc5F,CAAC;AAEL,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,iGAAiG;IACjG,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UACnB,gBAAgB,aACZ,SAAS,KACnB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,EAAE,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAmE1F,CAAC"}
|
package/dist/caddy/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `Caddy.Config` — a running Caddy's whole config, declared as Caddyfile text and applied through
|
|
3
|
-
* Caddy's own admin API (decision 23).
|
|
3
|
+
* Caddy's own admin API (decision 23), via `@distilled.cloud/caddy`'s typed `admin` operations.
|
|
4
4
|
*
|
|
5
5
|
* - create / update — `POST /adapt` (validate), `POST /load` with `text/caddyfile` (a graceful
|
|
6
6
|
* reload; Caddy keeps the old config if it refuses the new one, and the error names why), then
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
* the deploy runs with `--adopt`. A Caddy serving nothing reads as absent: a create. Where the
|
|
21
21
|
* engine skips that probe, reconcile refuses the same takeover (config-lifecycle.ts).
|
|
22
22
|
* ⛔ `caddyfile` IS NEVER A SECRET — see config-form.ts; refused before anything is sent.
|
|
23
|
-
* ⚠️ WHICH CADDY is the transport's (providers.ts)
|
|
23
|
+
* ⚠️ WHICH CADDY is the transport's (providers.ts): `CaddyAdminService` plus the `Credentials`/
|
|
24
|
+
* `HttpClient` layers `caddyAdminLayer` merges — one per stack, not a prop.
|
|
24
25
|
*/
|
|
25
26
|
import { Resource } from 'alchemy';
|
|
26
27
|
import * as Provider from 'alchemy/Provider';
|
|
@@ -30,5 +31,5 @@ export type { CaddyConfigAttributes, CaddyConfigProps } from './config-form.ts';
|
|
|
30
31
|
export interface CaddyConfig extends Resource<'Caddy.Config', CaddyConfigProps, CaddyConfigAttributes> {
|
|
31
32
|
}
|
|
32
33
|
export declare const CaddyConfig: import("alchemy").ResourceClass<CaddyConfig>;
|
|
33
|
-
export declare const CaddyConfigProvider: () => import("effect/Layer").Layer<Provider.Provider<CaddyConfig>, never, CaddyAdminService>;
|
|
34
|
+
export declare const CaddyConfigProvider: () => import("effect/Layer").Layer<Provider.Provider<CaddyConfig>, never, CaddyAdminService | import("@distilled.cloud/caddy").CaddyOpContext>;
|
|
34
35
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/caddy/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/caddy/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAI7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIhF,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,WAAW,WAAY,SAAQ,QAAQ,CAC3C,cAAc,EACd,gBAAgB,EAChB,qBAAqB,CACtB;CAAG;AAEJ,eAAO,MAAM,WAAW,8CAEtB,CAAC;AAoBH,eAAO,MAAM,mBAAmB,gJA+E7B,CAAC"}
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
* ★ `listenPort` is the port Caddy BELIEVES it listens on — its Host check uses it — while the
|
|
18
18
|
* fake really listens on an ephemeral one: a Caddy on its default :2019 behind a forward.
|
|
19
19
|
*/
|
|
20
|
-
import
|
|
20
|
+
import * as Effect from 'effect/Effect';
|
|
21
|
+
import type * as Caddy from '@distilled.cloud/caddy';
|
|
22
|
+
import { type CaddyAdminService, type CaddyTransport } from './admin.ts';
|
|
21
23
|
export type Seen = {
|
|
22
24
|
readonly method: string;
|
|
23
25
|
readonly path: string;
|
|
@@ -48,7 +50,13 @@ export declare const fakeCaddy: (options?: {
|
|
|
48
50
|
* move it (admin-guard.ts).
|
|
49
51
|
*/
|
|
50
52
|
export declare const fakeDefaultCaddy: (running?: unknown) => {
|
|
51
|
-
admin:
|
|
53
|
+
admin: CaddyTransport;
|
|
52
54
|
caddy: FakeCaddy;
|
|
53
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Runs an Effect that needs `CaddyAdminService` and `@distilled.cloud/caddy`'s own `Credentials`/
|
|
58
|
+
* `HttpClient` against one transport — the one line every test in this directory used to spend on
|
|
59
|
+
* `Effect.provide(caddyAdminLayer(admin))` before this helper existed.
|
|
60
|
+
*/
|
|
61
|
+
export declare const runCaddy: <A, E>(effect: Effect.Effect<A, E, CaddyAdminService | Caddy.CaddyOpContext>, admin: CaddyTransport) => Promise<A>;
|
|
54
62
|
//# sourceMappingURL=fake-caddy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-caddy.d.ts","sourceRoot":"","sources":["../../src/caddy/fake-caddy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"fake-caddy.d.ts","sourceRoot":"","sources":["../../src/caddy/fake-caddy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,KAAK,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAmB,MAAM,YAAY,CAAC;AAG1F,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IACtB,+DAA+D;IAC/D,OAAO,EAAE,OAAO,CAAC;IACjB,+EAA+E;IAC/E,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,IAAI,IAAI,IAAI,CAAC;CACd,CAAC;AAqDF,eAAO,MAAM,SAAS,aACX;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,KACrF,SAwEF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aACjB,OAAO,KAChB;IAAE,KAAK,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAQ3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,CAAC,UACnB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,SAC9D,cAAc,KACpB,OAAO,CAAC,CAAC,CAA2E,CAAC"}
|
package/dist/caddy/index.d.ts
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* `@homeflare/cloudflare/access-auth`. Guide: docs/access-auth.md.
|
|
16
16
|
*/
|
|
17
17
|
export { accessForwardAuth, verifierProblems, type AccessForwardAuthProps, } from './access-forward-auth.ts';
|
|
18
|
-
export type {
|
|
19
|
-
export { CaddyAdminService,
|
|
20
|
-
export {
|
|
18
|
+
export type { CaddyAdminListener, CaddyTarget, CaddyTransport } from './admin.ts';
|
|
19
|
+
export { CaddyAdminService, caddyAdminLayer } from './admin.ts';
|
|
20
|
+
export { isUnreachable } from './caddy-http-client.ts';
|
|
21
21
|
export type { CaddyConfigAttributes, CaddyConfigProps } from './config.ts';
|
|
22
22
|
export { CaddyConfig, CaddyConfigProvider } from './config.ts';
|
|
23
23
|
export type { LocalCaddyAdminOptions } from './local-admin.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caddy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH;;;;GAIG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,sBAAsB,GAC5B,MAAM,0BAA0B,CAAC;AAClC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caddy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH;;;;GAIG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,sBAAsB,GAC5B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/D,YAAY,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|