@sponson/adapters 0.0.0-stage → 0.4.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 ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # @sponson/adapters
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The resource adapters and secret sources that ship with [Sponson](https://github.com/MishaBear94/Sponson#readme). `createRegistry()` returns all of them; the [built-in ops](https://github.com/MishaBear94/Sponson/blob/main/docs/plan-format.md#built-in-ops) and [secret schemes](https://github.com/MishaBear94/Sponson/blob/main/docs/plan-format.md#secret-schemes) are listed in the plan format reference.
4
+
5
+ Most users want the `sponson` CLI instead. Documentation: <https://sponson.mintlify.site>. Source and issues: [GitHub](https://github.com/MishaBear94/Sponson).
@@ -0,0 +1,8 @@
1
+ import { type ResourceAdapter } from "@sponson/core";
2
+ /** Clerk's API base URL; `CLERK_API_URL` overrides it (the sim and tests use that). */
3
+ export declare const CLERK_DEFAULT_API_URL = "https://api.clerk.com/v1";
4
+ /**
5
+ * Clerk: op `redirect_allow` keeps a redirect URL (e.g. a preview URL) on the allow-list. Needs
6
+ * `CLERK_SECRET_KEY`.
7
+ */
8
+ export declare const clerkAdapter: ResourceAdapter;
package/dist/clerk.js ADDED
@@ -0,0 +1,107 @@
1
+ import { isPendingMarker, sha256 } from "@sponson/core";
2
+ import { assertNoPending, clientFor, deleteIgnoringNotFound, diffValue, optionalEnv, requireEnv, stringParam } from "./common.js";
3
+ import { ShapeError, isObject, isProviderError, listAll, records } from "./http.js";
4
+ /** The environment clerk reads; declared once, used by the code below and by the generated docs. */
5
+ const ABOUT = { credentialEnv: "CLERK_SECRET_KEY", baseUrlEnv: "CLERK_API_URL" };
6
+ /** Clerk's API base URL; `CLERK_API_URL` overrides it (the sim and tests use that). */
7
+ export const CLERK_DEFAULT_API_URL = "https://api.clerk.com/v1";
8
+ /** Page size asked for (the spec's `limit` allows 1–500, default 10). */
9
+ const CLERK_PAGE_LIMIT = 100;
10
+ function client(actx) {
11
+ const token = requireEnv(actx.env, ABOUT.credentialEnv, "clerk");
12
+ return clientFor(actx, "clerk", { baseUrl: optionalEnv(actx.env, ABOUT.baseUrlEnv) ?? CLERK_DEFAULT_API_URL, token });
13
+ }
14
+ const REDIRECT_PREFIX = "redirect:";
15
+ function redirectKey(url) {
16
+ return `${REDIRECT_PREFIX}${url}`;
17
+ }
18
+ function record(r) {
19
+ return { key: redirectKey(r.url), id: r.id, hash: sha256(r.url), label: `Clerk redirect ${r.url}` };
20
+ }
21
+ /**
22
+ * GET /redirect_urls?paginated=true answers `{ data, total_count }`, paged by `offset`/`limit` (Clerk's own SDKs ask
23
+ * for it the same way; without `paginated` the spec documents a bare array). A bare array is still accepted;
24
+ * anything else is a PROVIDER_RESPONSE naming the endpoint.
25
+ */
26
+ function parseRedirects(body) {
27
+ if (Array.isArray(body))
28
+ return { items: records(body, "the redirect URL list", ["id", "url"]) };
29
+ if (!isObject(body))
30
+ throw new ShapeError(`expected a list of redirect URLs or { data, total_count }, got ${body === null ? "null" : typeof body}`);
31
+ const items = records(body.data, "`data`", ["id", "url"]);
32
+ if (typeof body.total_count !== "number")
33
+ throw new ShapeError("expected `total_count` to be a number");
34
+ return { items, total: body.total_count };
35
+ }
36
+ async function list(api) {
37
+ let seen = 0;
38
+ return listAll(api, `/redirect_urls?paginated=true&limit=${CLERK_PAGE_LIMIT}`, (body) => {
39
+ const p = parseRedirects(body);
40
+ seen += p.items.length;
41
+ const more = p.total !== undefined && seen < p.total;
42
+ return { items: p.items.map((r) => ({ id: r.id, url: r.url })), next: more ? { offset: String(seen) } : null };
43
+ });
44
+ }
45
+ const redirect_allow = {
46
+ outputs: { id: { available: "immediate" } },
47
+ async read(actx, params) {
48
+ if (isPendingMarker(params.url))
49
+ return null;
50
+ const url = stringParam(params, "url", "clerk");
51
+ const found = (await list(client(actx))).find((r) => r.url === url);
52
+ if (!found)
53
+ return null;
54
+ return { resources: [record(found)], outputs: { id: found.id } };
55
+ },
56
+ diff(live, params) {
57
+ const url = params.url;
58
+ const key = isPendingMarker(url) ? "redirect:(pending)" : redirectKey(String(url));
59
+ const current = live?.resources.find((r) => r.key === key);
60
+ return [diffValue({ key, label: "Clerk redirect", live: current, desired: url, sensitive: false, liveValue: String(url) })];
61
+ },
62
+ async apply(actx, params, live) {
63
+ assertNoPending(params, "clerk");
64
+ const url = stringParam(params, "url", "clerk");
65
+ const key = redirectKey(url);
66
+ if (live?.resources.some((r) => r.key === key))
67
+ return { resources: live.resources, outputs: live.outputs, created: [] };
68
+ const api = client(actx);
69
+ await actx.intend([key]);
70
+ actx.log(`allow redirect ${url}`);
71
+ try {
72
+ const r = await api.post("/redirect_urls", { url }, (b) => records([b], "the created redirect URL", ["id", "url"])[0]);
73
+ return { resources: [record(r)], outputs: { id: r.id }, created: [key] };
74
+ }
75
+ catch (e) {
76
+ // The spec documents 400 and 422 for a refused create without saying which a duplicate gets, so any refusal
77
+ // is checked against the list before it is reported.
78
+ const refused = isProviderError(e, "PROVIDER_INVALID") && (e.details.status === 400 || e.details.status === 422);
79
+ if (!isProviderError(e, "PROVIDER_CONFLICT") && !refused)
80
+ throw e;
81
+ // It exists already: registered by someone else, or by an earlier attempt of ours whose answer was lost.
82
+ // Either way it is not created by this call; the engine claims it if an earlier intent of ours named it.
83
+ const found = (await list(api)).find((r) => r.url === url);
84
+ if (!found)
85
+ throw e;
86
+ return { resources: [record(found)], outputs: { id: found.id }, created: [] };
87
+ }
88
+ },
89
+ async destroy(actx, resources) {
90
+ const api = client(actx);
91
+ for (const r of resources)
92
+ await deleteIgnoringNotFound(api, `/redirect_urls/${encodeURIComponent(r.id)}`);
93
+ },
94
+ async listScope(actx) {
95
+ return (await list(client(actx))).map(record);
96
+ },
97
+ /** One line per allowed URL. */
98
+ adopt(resources) {
99
+ return resources.map((r) => ({ id: "callback", params: { url: r.key.slice(REDIRECT_PREFIX.length) }, keys: [r.key] }));
100
+ },
101
+ };
102
+ /**
103
+ * Clerk: op `redirect_allow` keeps a redirect URL (e.g. a preview URL) on the allow-list. Needs
104
+ * `CLERK_SECRET_KEY`.
105
+ */
106
+ export const clerkAdapter = { name: "clerk", ops: { redirect_allow }, about: ABOUT };
107
+ //# sourceMappingURL=clerk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clerk.js","sourceRoot":"","sources":["../src/clerk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAA+E,MAAM,eAAe,CAAC;AACrI,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,sBAAsB,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClI,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAA6B,MAAM,WAAW,CAAC;AAE/G,oGAAoG;AACpG,MAAM,KAAK,GAAG,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAW,CAAC;AAE1F,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAChE,yEAAyE;AACzE,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAO7B,SAAS,MAAM,CAAC,IAAoB;IAClC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACjE,OAAO,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,qBAAqB,EAAE,KAAK,EAAE,CAAC,CAAC;AACxH,CAAC;AAED,MAAM,eAAe,GAAG,W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MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,SAAS;YAAE,MAAM,sBAAsB,CAAC,GAAG,EAAE,kBAAkB,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7G,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAI;QAClB,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,gCAAgC;IAChC,KAAK,CAAC,SAAS;QACb,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACzH,CAAC;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { SponsonError, type AdapterContext, type DiffSide, type ResolvedParams, type ResourceDiff, type ResourceRecord } from "@sponson/core";
2
+ import { type ApiClient } from "./http.js";
3
+ /**
4
+ * The adapter authoring API. These helpers are stable and exported from `@sponson/adapters`; third-party
5
+ * adapters should use them rather than re-implementing the contracts they encode:
6
+ *
7
+ * clientFor HTTP client with retry policy and redaction from the adapter context
8
+ * requireEnv a credential from the environment, PROVIDER_AUTH when missing
9
+ * optionalEnv an optional setting from the environment (a base URL override)
10
+ * requireProvider a `providers.<adapter>.<key>` value, PLAN_INVALID when missing
11
+ * stringParam/paramError a string param with a default, PARAM_INVALID otherwise
12
+ * desiredSide/diffValue the marker contract (pending / secret / keep) applied to one value's diff
13
+ * assertNoPending apply-time guard that the engine resolved every reference
14
+ * deleteIgnoringNotFound destroy's "already gone is success" rule
15
+ *
16
+ * The HTTP side of the authoring API (ApiClient, Page, Shape, ShapeError, isObject, obj, records, listAll,
17
+ * withQuery, isProviderError) lives in http.ts; packages/adapters/src/index.ts lists the whole API.
18
+ * Anything else in this file is internal and may change.
19
+ */
20
+ /** A credential from the environment; PROVIDER_AUTH naming the variable when it is unset or blank. */
21
+ export declare function requireEnv(env: NodeJS.ProcessEnv, name: string, adapter: string): string;
22
+ /** An optional setting from the environment (a base URL override); blank counts as unset. Stable authoring API. */
23
+ export declare function optionalEnv(env: NodeJS.ProcessEnv, name: string): string | undefined;
24
+ /**
25
+ * A `providers.<adapter>.<key>` string from the plan; PLAN_INVALID when missing. Use it for project and team
26
+ * ids.
27
+ */
28
+ export declare function requireProvider(actx: AdapterContext, key: string, adapter: string): string;
29
+ /** A `providers.<adapter>.<key>` string from the plan, or undefined. */
30
+ export declare function optionalProvider(actx: AdapterContext, key: string): string | undefined;
31
+ /**
32
+ * The HTTP client for an adapter call: the context's environment sets the policy and its redactor masks error text.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * // inside an op's read():
37
+ * const token = requireEnv(actx.env, "ACME_TOKEN", "acme");
38
+ * const api = clientFor(actx, "acme", { baseUrl: "https://api.acme.dev", token });
39
+ * // Retries, timeouts and classification happen inside: a 404 throws PROVIDER_NOT_FOUND, and so on.
40
+ * const site = await api.get(`/sites/${stringParam(params, "name", "acme")}`);
41
+ * ```
42
+ */
43
+ export declare function clientFor(actx: AdapterContext, adapter: string, opts: {
44
+ baseUrl: string;
45
+ token: string;
46
+ authHeader?: "bearer" | `header:${string}`;
47
+ }): ApiClient;
48
+ /**
49
+ * The PARAM_INVALID error for a bad param, prefixed with the adapter name. Throw it from `diff`/`apply`
50
+ * validation.
51
+ */
52
+ export declare function paramError(adapter: string, message: string, param: string): SponsonError;
53
+ /** The engine never passes a pending marker into apply; if one arrives, something upstream is wrong. */
54
+ export declare function assertNoPending(params: ResolvedParams, adapter: string): void;
55
+ export declare const ABSENT: DiffSide;
56
+ export declare const SENSITIVE: DiffSide;
57
+ /** A desired value as a diff side: pending markers name their reference (secret refs are URLs: `env://X`). */
58
+ export declare function desiredSide(v: unknown, sensitive: boolean): DiffSide;
59
+ /**
60
+ * Diff one desired value against the live record by hash. `liveValue` is what `before` shows for a non-sensitive
61
+ * value (the live record carries only a hash). Unchanged diffs carry no sides: there is nothing to show.
62
+ */
63
+ export declare function diffValue(opts: {
64
+ key: string;
65
+ label: string;
66
+ live: ResourceRecord | undefined;
67
+ desired: unknown;
68
+ sensitive: boolean;
69
+ liveValue?: string;
70
+ }): ResourceDiff;
71
+ /**
72
+ * A string param, or `fallback` when absent or empty; PARAM_INVALID when missing without a fallback or not a
73
+ * string.
74
+ */
75
+ export declare function stringParam(params: ResolvedParams, name: string, adapter: string, fallback?: string): string;
76
+ /** DELETE that treats 404 as success: the contract says a resource that is already gone is not an error. */
77
+ export declare function deleteIgnoringNotFound(api: ApiClient, path: string): Promise<void>;
package/dist/common.js ADDED
@@ -0,0 +1,140 @@
1
+ import { SponsonError, markerKind, pendingRef, sha256 } from "@sponson/core";
2
+ import { apiClient, isProviderError } from "./http.js";
3
+ /**
4
+ * The adapter authoring API. These helpers are stable and exported from `@sponson/adapters`; third-party
5
+ * adapters should use them rather than re-implementing the contracts they encode:
6
+ *
7
+ * clientFor HTTP client with retry policy and redaction from the adapter context
8
+ * requireEnv a credential from the environment, PROVIDER_AUTH when missing
9
+ * optionalEnv an optional setting from the environment (a base URL override)
10
+ * requireProvider a `providers.<adapter>.<key>` value, PLAN_INVALID when missing
11
+ * stringParam/paramError a string param with a default, PARAM_INVALID otherwise
12
+ * desiredSide/diffValue the marker contract (pending / secret / keep) applied to one value's diff
13
+ * assertNoPending apply-time guard that the engine resolved every reference
14
+ * deleteIgnoringNotFound destroy's "already gone is success" rule
15
+ *
16
+ * The HTTP side of the authoring API (ApiClient, Page, Shape, ShapeError, isObject, obj, records, listAll,
17
+ * withQuery, isProviderError) lives in http.ts; packages/adapters/src/index.ts lists the whole API.
18
+ * Anything else in this file is internal and may change.
19
+ */
20
+ /** A credential from the environment; PROVIDER_AUTH naming the variable when it is unset or blank. */
21
+ export function requireEnv(env, name, adapter) {
22
+ const v = env[name];
23
+ if (!v)
24
+ throw new SponsonError("PROVIDER_AUTH", `${adapter}: environment variable ${name} is not set`, { adapter, variable: name });
25
+ return v;
26
+ }
27
+ /** An optional setting from the environment (a base URL override); blank counts as unset. Stable authoring API. */
28
+ export function optionalEnv(env, name) {
29
+ const v = env[name];
30
+ return v === undefined || v === "" ? undefined : v;
31
+ }
32
+ /**
33
+ * A `providers.<adapter>.<key>` string from the plan; PLAN_INVALID when missing. Use it for project and team
34
+ * ids.
35
+ */
36
+ export function requireProvider(actx, key, adapter) {
37
+ const v = actx.provider[key];
38
+ if (typeof v !== "string" || v === "")
39
+ throw new SponsonError("PLAN_INVALID", `${adapter}: providers.${adapter}.${key} is required in the plan`, { adapter, key });
40
+ return v;
41
+ }
42
+ /** A `providers.<adapter>.<key>` string from the plan, or undefined. */
43
+ export function optionalProvider(actx, key) {
44
+ const v = actx.provider[key];
45
+ return typeof v === "string" && v !== "" ? v : undefined;
46
+ }
47
+ /**
48
+ * The HTTP client for an adapter call: the context's environment sets the policy and its redactor masks error text.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * // inside an op's read():
53
+ * const token = requireEnv(actx.env, "ACME_TOKEN", "acme");
54
+ * const api = clientFor(actx, "acme", { baseUrl: "https://api.acme.dev", token });
55
+ * // Retries, timeouts and classification happen inside: a 404 throws PROVIDER_NOT_FOUND, and so on.
56
+ * const site = await api.get(`/sites/${stringParam(params, "name", "acme")}`);
57
+ * ```
58
+ */
59
+ export function clientFor(actx, adapter, opts) {
60
+ return apiClient({ adapter, ...opts, redact: actx.redact, env: actx.env });
61
+ }
62
+ /**
63
+ * The PARAM_INVALID error for a bad param, prefixed with the adapter name. Throw it from `diff`/`apply`
64
+ * validation.
65
+ */
66
+ export function paramError(adapter, message, param) {
67
+ return new SponsonError("PARAM_INVALID", `${adapter}: ${message}`, { adapter, param });
68
+ }
69
+ /** The engine never passes a pending marker into apply; if one arrives, something upstream is wrong. */
70
+ export function assertNoPending(params, adapter) {
71
+ const walk = (v, path) => {
72
+ const marker = markerKind(v);
73
+ if (marker === "pending" || marker === "secret")
74
+ throw new SponsonError("INTERNAL", `${adapter}: param ${path} is still pending (${pendingRef(v)}); apply must not be called before its inputs resolve`, { adapter, param: path });
75
+ if (Array.isArray(v))
76
+ v.forEach((x, i) => walk(x, `${path}[${i}]`));
77
+ else if (v && typeof v === "object")
78
+ for (const [k, x] of Object.entries(v))
79
+ walk(x, path ? `${path}.${k}` : k);
80
+ };
81
+ walk(params, "");
82
+ }
83
+ // ---------------------------------------------------------------------------
84
+ // Diff sides: data only. Renderers turn them into text.
85
+ // ---------------------------------------------------------------------------
86
+ export const ABSENT = { state: "absent" };
87
+ export const SENSITIVE = { state: "sensitive" };
88
+ /** A desired value as a diff side: pending markers name their reference (secret refs are URLs: `env://X`). */
89
+ export function desiredSide(v, sensitive) {
90
+ const marker = markerKind(v);
91
+ if (marker === "pending" || marker === "secret")
92
+ return { state: marker, ref: pendingRef(v) };
93
+ return sensitive ? SENSITIVE : { state: "literal", value: String(v) };
94
+ }
95
+ /**
96
+ * Diff one desired value against the live record by hash. `liveValue` is what `before` shows for a non-sensitive
97
+ * value (the live record carries only a hash). Unchanged diffs carry no sides: there is nothing to show.
98
+ */
99
+ export function diffValue(opts) {
100
+ const { key, label, live, desired, sensitive } = opts;
101
+ const marker = markerKind(desired);
102
+ if (marker === "keep") {
103
+ if (live)
104
+ return { key, kind: "unchanged", label };
105
+ throw new SponsonError("PARAM_INVALID", `${label} is declared \`{ keep: true }\` but does not exist, so there is no value to keep. Give it a value or remove it.`, { key });
106
+ }
107
+ const after = desiredSide(desired, sensitive);
108
+ if (!live)
109
+ return { key, kind: "create", label, before: ABSENT, after };
110
+ const before = sensitive || opts.liveValue === undefined ? SENSITIVE : { state: "literal", value: opts.liveValue };
111
+ if (marker === null && live.hash === sha256(String(desired)))
112
+ return { key, kind: "unchanged", label };
113
+ return { key, kind: "update", label, before, after };
114
+ }
115
+ /**
116
+ * A string param, or `fallback` when absent or empty; PARAM_INVALID when missing without a fallback or not a
117
+ * string.
118
+ */
119
+ export function stringParam(params, name, adapter, fallback) {
120
+ const v = params[name];
121
+ if (v === undefined || v === null || v === "") {
122
+ if (fallback !== undefined)
123
+ return fallback;
124
+ throw paramError(adapter, `param \`${name}\` is required`, name);
125
+ }
126
+ if (typeof v !== "string")
127
+ throw paramError(adapter, `param \`${name}\` must be a string`, name);
128
+ return v;
129
+ }
130
+ /** DELETE that treats 404 as success: the contract says a resource that is already gone is not an error. */
131
+ export async function deleteIgnoringNotFound(api, path) {
132
+ try {
133
+ await api.delete(path);
134
+ }
135
+ catch (e) {
136
+ if (!isProviderError(e, "PROVIDER_NOT_FOUND"))
137
+ throw e;
138
+ }
139
+ }
140
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAmG,MAAM,eAAe,CAAC;AAC9K,OAAO,EAAE,SAAS,EAAE,eAAe,EAAkB,MAAM,WAAW,CAAC;AAEvE;;;;;;;;;;;;;;;;GAgBG;AAEH,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,GAAsB,EAAE,IAAY,EAAE,OAAe;IAC9E,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,YAAY,CAAC,eAAe,EAAE,GAAG,OAAO,0BAA0B,IAAI,aAAa,EAAE,EAAE,OAAO,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