@sponson/adapters 0.4.0 → 0.5.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.
Files changed (127) hide show
  1. package/README.md +1 -1
  2. package/dist/algolia.d.ts +6 -0
  3. package/dist/algolia.js +151 -0
  4. package/dist/algolia.js.map +1 -0
  5. package/dist/clerk.js +1 -1
  6. package/dist/clerk.js.map +1 -1
  7. package/dist/cloudflare.d.ts +25 -0
  8. package/dist/cloudflare.js +310 -0
  9. package/dist/cloudflare.js.map +1 -0
  10. package/dist/common.d.ts +2 -6
  11. package/dist/common.js.map +1 -1
  12. package/dist/digest.d.ts +46 -0
  13. package/dist/digest.js +129 -0
  14. package/dist/digest.js.map +1 -0
  15. package/dist/digitalocean.d.ts +5 -0
  16. package/dist/digitalocean.js +243 -0
  17. package/dist/digitalocean.js.map +1 -0
  18. package/dist/http-adapter-action.d.ts +63 -0
  19. package/dist/http-adapter-action.js +369 -0
  20. package/dist/http-adapter-action.js.map +1 -0
  21. package/dist/http-adapter-auth.d.ts +88 -0
  22. package/dist/http-adapter-auth.js +437 -0
  23. package/dist/http-adapter-auth.js.map +1 -0
  24. package/dist/http-adapter-client.d.ts +51 -0
  25. package/dist/http-adapter-client.js +156 -0
  26. package/dist/http-adapter-client.js.map +1 -0
  27. package/dist/http-adapter-graphql.d.ts +39 -0
  28. package/dist/http-adapter-graphql.js +157 -0
  29. package/dist/http-adapter-graphql.js.map +1 -0
  30. package/dist/http-adapter-list.d.ts +33 -0
  31. package/dist/http-adapter-list.js +421 -0
  32. package/dist/http-adapter-list.js.map +1 -0
  33. package/dist/http-adapter-resource.d.ts +29 -0
  34. package/dist/http-adapter-resource.js +462 -0
  35. package/dist/http-adapter-resource.js.map +1 -0
  36. package/dist/http-adapter-spec.d.ts +216 -0
  37. package/dist/http-adapter-spec.js +660 -0
  38. package/dist/http-adapter-spec.js.map +1 -0
  39. package/dist/http-adapter.d.ts +16 -0
  40. package/dist/http-adapter.js +28 -0
  41. package/dist/http-adapter.js.map +1 -0
  42. package/dist/http.d.ts +61 -2
  43. package/dist/http.js +79 -18
  44. package/dist/http.js.map +1 -1
  45. package/dist/index.d.ts +12 -0
  46. package/dist/index.js +24 -2
  47. package/dist/index.js.map +1 -1
  48. package/dist/launchdarkly.d.ts +15 -0
  49. package/dist/launchdarkly.js +337 -0
  50. package/dist/launchdarkly.js.map +1 -0
  51. package/dist/manual.d.ts +13 -0
  52. package/dist/manual.js +201 -0
  53. package/dist/manual.js.map +1 -0
  54. package/dist/neon.js +1 -1
  55. package/dist/neon.js.map +1 -1
  56. package/dist/netlify.d.ts +18 -0
  57. package/dist/netlify.js +436 -0
  58. package/dist/netlify.js.map +1 -0
  59. package/dist/planetscale.d.ts +10 -0
  60. package/dist/planetscale.js +311 -0
  61. package/dist/planetscale.js.map +1 -0
  62. package/dist/providers.d.ts +26 -0
  63. package/dist/providers.js +36 -0
  64. package/dist/providers.js.map +1 -0
  65. package/dist/recipes.d.ts +167 -0
  66. package/dist/recipes.js +246 -0
  67. package/dist/recipes.js.map +1 -0
  68. package/dist/secrets.d.ts +44 -0
  69. package/dist/secrets.js +279 -0
  70. package/dist/secrets.js.map +1 -1
  71. package/dist/sigv4.d.ts +56 -0
  72. package/dist/sigv4.js +118 -0
  73. package/dist/sigv4.js.map +1 -0
  74. package/dist/supabase.d.ts +9 -0
  75. package/dist/supabase.js +385 -0
  76. package/dist/supabase.js.map +1 -0
  77. package/dist/vercel.js +1 -1
  78. package/dist/vercel.js.map +1 -1
  79. package/dist/xata.d.ts +8 -0
  80. package/dist/xata.js +142 -0
  81. package/dist/xata.js.map +1 -0
  82. package/dist/xml.d.ts +25 -0
  83. package/dist/xml.js +211 -0
  84. package/dist/xml.js.map +1 -0
  85. package/package.json +11 -4
  86. package/recipes/amplify.yaml +147 -0
  87. package/recipes/auth0.yaml +178 -0
  88. package/recipes/azure_swa.yaml +116 -0
  89. package/recipes/cloud_run.yaml +97 -0
  90. package/recipes/cloudflare.yaml +108 -0
  91. package/recipes/cockroachdb.yaml +132 -0
  92. package/recipes/configcat.yaml +123 -0
  93. package/recipes/datadog.yaml +136 -0
  94. package/recipes/firebase.yaml +84 -0
  95. package/recipes/flagsmith.yaml +98 -0
  96. package/recipes/fly.yaml +97 -0
  97. package/recipes/fly_machines.yaml +67 -0
  98. package/recipes/gcs.yaml +102 -0
  99. package/recipes/github.yaml +123 -0
  100. package/recipes/growthbook.yaml +124 -0
  101. package/recipes/heroku.yaml +98 -0
  102. package/recipes/honeycomb.yaml +89 -0
  103. package/recipes/inngest.yaml +97 -0
  104. package/recipes/kinde.yaml +120 -0
  105. package/recipes/mongodb_atlas.yaml +119 -0
  106. package/recipes/okta.yaml +177 -0
  107. package/recipes/posthog.yaml +127 -0
  108. package/recipes/postmark.yaml +105 -0
  109. package/recipes/postmark_server.yaml +93 -0
  110. package/recipes/prisma.yaml +150 -0
  111. package/recipes/qstash.yaml +134 -0
  112. package/recipes/railway.yaml +130 -0
  113. package/recipes/render.yaml +103 -0
  114. package/recipes/resend.yaml +130 -0
  115. package/recipes/s3.yaml +108 -0
  116. package/recipes/sendgrid.yaml +165 -0
  117. package/recipes/sentry.yaml +158 -0
  118. package/recipes/split.yaml +121 -0
  119. package/recipes/statsig.yaml +124 -0
  120. package/recipes/stripe.yaml +310 -0
  121. package/recipes/stytch.yaml +113 -0
  122. package/recipes/svix.yaml +109 -0
  123. package/recipes/turso.yaml +98 -0
  124. package/recipes/unleash.yaml +149 -0
  125. package/recipes/upstash.yaml +130 -0
  126. package/recipes/vercel.yaml +116 -0
  127. package/recipes/workos.yaml +70 -0
@@ -0,0 +1,421 @@
1
+ /**
2
+ * `http.list_item`: one value kept in a collection held by a parent object (an allowed origin, a callback URL, a
3
+ * config var), by read-modify-write. The collection is a JSON array, a delimited string or a keyed map (`shape`).
4
+ * See ADR 0017 and docs/plan-format.md#httplist_item.
5
+ *
6
+ * - Key: `<parent.path>#<list_path>=<item>`: which collection, and which item in it (for map items of an array,
7
+ * the value of `key_field`; for a keyed map, the entry's name). The provider block is part of the ledger
8
+ * identity already.
9
+ * - Id: the item's locator as canonical JSON (how to read and write the parent, where and how the collection is
10
+ * stored, which item), so `destroy` needs nothing but the ledger.
11
+ * - Hash: the item's state in canonical JSON: the value itself, the declared fields of a map item, or a keyed
12
+ * entry's value.
13
+ * - Writes replace the whole collection (`PUT`, or `PATCH`/`POST` sent as idempotent, so a dropped connection is
14
+ * retried), except a keyed map with `send: field`, which is sent as a merge patch of the one entry (`null`
15
+ * deletes it). Then the parent is read again: the write counts only once the item is seen as planned. A
16
+ * collection that loses the item to a concurrent writer is written again, up to MAX_ATTEMPTS times.
17
+ * - Lock: the parent object (`lockOn`, ADR 0019), so Sponson's writers in other scopes and environments never
18
+ * interleave between a read and a write. There is no precondition (ETag): only a writer outside Sponson can.
19
+ */
20
+ import { SponsonError, canonicalJson } from "@sponson/core";
21
+ import { ABSENT, SENSITIVE, assertNoPending, desiredSide, paramError } from "./common.js";
22
+ import { isObject } from "./http.js";
23
+ import { failedWith, httpClient, withLineCredential, write } from "./http-adapter-client.js";
24
+ import { expandRecipe } from "./recipes.js";
25
+ import { ADAPTER, apiBlock, apiEnvironment, at, credentialInputs, fieldTokens, fillPath, firstMarker, isKeep, parseApi, parseListItem, pointerTokens, projection, setAt, stateHash } from "./http-adapter-spec.js";
26
+ /** Read-modify-write rounds before giving up on a collection that keeps changing under us. */
27
+ export const MAX_ATTEMPTS = 3;
28
+ /** What `read` found, kept for `diff` and `apply` of the same inspection. */
29
+ const found = new WeakMap();
30
+ /** The item's identity: the value, the `key_field` of a map item, or a keyed entry's name (strings for both string shapes). */
31
+ function keyValue(spec) {
32
+ if (spec.shape !== "array")
33
+ return firstMarker(spec.item) ? spec.item : String(spec.item);
34
+ return spec.keyField === undefined ? spec.item : at(spec.item, fieldTokens(spec.keyField));
35
+ }
36
+ function text(v) {
37
+ return typeof v === "string" ? v : canonicalJson(v);
38
+ }
39
+ /** The locator, or undefined while a value it depends on is pending. */
40
+ function locatorOf(spec) {
41
+ const read = fillPath(spec.parent.readPath, spec.vars);
42
+ const path = fillPath(spec.parent.path, spec.vars);
43
+ const item = keyValue(spec);
44
+ if (read === undefined || path === undefined || firstMarker(item) !== undefined)
45
+ return undefined;
46
+ return {
47
+ read,
48
+ ...(spec.parent.readMethod === "POST" ? { read_method: "POST" } : {}),
49
+ write: `${spec.parent.method} ${path}`,
50
+ list: spec.listPath,
51
+ send: spec.parent.send,
52
+ ...(spec.parent.itemPath !== "" ? { item_path: spec.parent.itemPath } : {}),
53
+ shape: spec.shape,
54
+ ...(spec.shape === "delimited" ? { sep: spec.separator } : {}),
55
+ ...(spec.keyField !== undefined ? { key_field: spec.keyField } : {}),
56
+ ...(spec.parent.contentType ? { content_type: spec.parent.contentType } : {}),
57
+ item,
58
+ ...(spec.destroy === "keep" ? { keep: true } : {}),
59
+ ...(spec.parent.ifMissing === "empty" ? { missing_empty: true } : {}),
60
+ ...(spec.parent.whenEmpty === "delete" ? { delete_empty: true } : {}),
61
+ // Only when set, so the record ids of lines that do not use it are unchanged.
62
+ ...(spec.parent.writeListPath !== undefined ? { write_list: spec.parent.writeListPath } : {}),
63
+ };
64
+ }
65
+ function writePath(loc) {
66
+ return loc.write.slice(loc.write.indexOf(" ") + 1);
67
+ }
68
+ function keyOf(loc) {
69
+ return `${writePath(loc)}#${loc.list}=${text(loc.item)}`;
70
+ }
71
+ /**
72
+ * What the ledger knows a line's item by: its key and record id (the locator), or undefined while pending. The
73
+ * recipe identity lock (recipes.test.ts) pins it per recipe op.
74
+ */
75
+ export function listItemIdentity(spec) {
76
+ const loc = locatorOf(spec);
77
+ return loc ? { key: keyOf(loc), id: canonicalJson(loc) } : undefined;
78
+ }
79
+ function labelOf(spec, loc) {
80
+ return `${spec.api} ${writePath(loc)}${loc.list} item ${text(loc.item)}`;
81
+ }
82
+ function sameKey(a, b) {
83
+ return a !== undefined && canonicalJson(a) === canonicalJson(b);
84
+ }
85
+ // ---------------------------------------------------------------------------
86
+ // The three shapes
87
+ // ---------------------------------------------------------------------------
88
+ function badShape(loc, expected) {
89
+ return new SponsonError("PROVIDER_RESPONSE", `${ADAPTER}: ${loc.read_method ?? "GET"} ${loc.read}: expected ${expected} at \`list_path\` ${loc.list || '""'}`, { adapter: ADAPTER, param: "list_path" });
90
+ }
91
+ /** The identifying value of one array element: itself, or its `key_field`; undefined when it has none. */
92
+ function arrayKey(e, keyField) {
93
+ if (keyField === undefined)
94
+ return isObject(e) || Array.isArray(e) ? undefined : e;
95
+ return isObject(e) ? at(e, fieldTokens(keyField)) : undefined;
96
+ }
97
+ /**
98
+ * The collection as entries. Absent or null is empty. In an XML document a list of one is its element alone (and
99
+ * an empty element is ""), so for an XML API a lone value is a list of one.
100
+ */
101
+ function decode(raw, loc, xml) {
102
+ if (raw === undefined || raw === null || (xml && raw === ""))
103
+ return [];
104
+ if (loc.shape === "array") {
105
+ if (xml && !Array.isArray(raw))
106
+ raw = [raw];
107
+ if (!Array.isArray(raw))
108
+ throw badShape(loc, "a list");
109
+ return raw.map((value) => ({ key: arrayKey(value, loc.key_field), value }));
110
+ }
111
+ if (loc.shape === "delimited") {
112
+ if (typeof raw !== "string")
113
+ throw badShape(loc, `a string of values separated by "${loc.sep ?? ","}"`);
114
+ return raw
115
+ .split(loc.sep ?? ",")
116
+ .map((s) => s.trim())
117
+ .filter((s) => s !== "")
118
+ .map((s) => ({ key: s, value: s }));
119
+ }
120
+ if (!isObject(raw))
121
+ throw badShape(loc, "a map");
122
+ return Object.entries(raw).map(([key, value]) => ({ key, value }));
123
+ }
124
+ /** Entries as the collection the provider stores. */
125
+ function encode(entries, loc) {
126
+ if (loc.shape === "array")
127
+ return entries.map((e) => e.value);
128
+ if (loc.shape === "delimited")
129
+ return entries.map((e) => String(e.value)).join(loc.sep ?? ",");
130
+ return Object.fromEntries(entries.map((e) => [String(e.key), e.value]));
131
+ }
132
+ /** `value` placed at `tokens` in `doc`; at the root, the value is the whole body. */
133
+ function place(doc, tokens, value) {
134
+ return tokens.length === 0 ? value : setAt(doc, tokens, value);
135
+ }
136
+ /**
137
+ * The fields an entry is compared by, when the plan declares a map: an array's map item, or a keyed entry's map
138
+ * value (a merge patch leaves fields the plan no longer sets, so only the declared ones count).
139
+ */
140
+ function declaredFields(spec) {
141
+ const declared = spec.shape === "map" ? spec.value : spec.shape === "array" ? spec.item : undefined;
142
+ return isObject(declared) ? Object.keys(declared) : undefined;
143
+ }
144
+ /** The state an entry is compared by: the value, or the declared fields of a map. */
145
+ function entryState(spec, entry) {
146
+ const fields = declaredFields(spec);
147
+ return fields ? projection(entry.value, fields) : entry.value;
148
+ }
149
+ /** The desired state; `{ keep: true }` takes the live entry's value. */
150
+ function desiredState(spec, entry) {
151
+ if (spec.shape === "map")
152
+ return isKeep(spec.value) ? (entry ? entryState(spec, entry) : null) : spec.value;
153
+ if (spec.shape === "delimited" || !isObject(spec.item))
154
+ return spec.shape === "delimited" ? String(spec.item) : spec.item;
155
+ return Object.fromEntries(Object.entries(spec.item).map(([f, v]) => [f, isKeep(v) ? (at(entry?.value, fieldTokens(f)) ?? null) : v]));
156
+ }
157
+ /** The value to store: the item, a keyed entry's value, or a map item's declared (non-kept) fields over the live one. */
158
+ function nextValue(spec, entry) {
159
+ if (spec.shape === "map")
160
+ return spec.value;
161
+ if (spec.shape === "delimited" || !isObject(spec.item))
162
+ return desiredState(spec, entry);
163
+ const set = Object.entries(spec.item).filter(([, v]) => !isKeep(v));
164
+ return set.reduce((o, [f, v]) => setAt(o, fieldTokens(f), v), isObject(entry?.value) ? entry.value : {});
165
+ }
166
+ function hasKeep(spec) {
167
+ if (spec.shape === "map")
168
+ return isKeep(spec.value);
169
+ return isObject(spec.item) && Object.values(spec.item).some(isKeep);
170
+ }
171
+ /**
172
+ * In an XML document a field of one element reads as that element alone. Where the line's map item declares a field
173
+ * as a list (S3's `AllowedMethod: [GET]`), a lone value is that list of one, so a one-element list compares equal.
174
+ */
175
+ function xmlLists(spec, value) {
176
+ if (!isObject(spec.item) || !isObject(value))
177
+ return value;
178
+ let out = value;
179
+ for (const [f, declared] of Object.entries(spec.item)) {
180
+ const live = at(out, fieldTokens(f));
181
+ if (Array.isArray(declared) && live !== undefined && live !== null && !Array.isArray(live))
182
+ out = setAt(out, fieldTokens(f), [live]);
183
+ }
184
+ return out;
185
+ }
186
+ /** The parent object and its collection; with `if_missing: empty`, a parent that is not there is empty. */
187
+ async function readParent(conn, loc, spec) {
188
+ let body;
189
+ try {
190
+ // A read sent as a POST changes nothing, so it is retried like a GET.
191
+ body = loc.read_method === "POST" ? await conn.api.post(loc.read, undefined, undefined, { idempotent: true }) : await conn.api.get(loc.read);
192
+ }
193
+ catch (e) {
194
+ if (loc.missing_empty && failedWith(e, "PROVIDER_NOT_FOUND", []))
195
+ return { doc: {}, entries: [] };
196
+ throw e;
197
+ }
198
+ const doc = loc.item_path ? at(body, pointerTokens(loc.item_path)) : body;
199
+ if (!isObject(doc))
200
+ throw loc.item_path ? new SponsonError("PROVIDER_RESPONSE", `${ADAPTER}: ${loc.read_method ?? "GET"} ${loc.read}: no object at \`parent.item_path\` ${loc.item_path}`, { adapter: ADAPTER, param: "parent.item_path" }) : badShape(loc, "an object");
201
+ const entries = decode(at(doc, pointerTokens(loc.list)), loc, conn.xml);
202
+ return { doc, entries: conn.xml && spec?.shape === "array" ? entries.map((e) => ({ key: e.key, value: xmlLists(spec, e.value) })) : entries };
203
+ }
204
+ function clientFor(actx, loc) {
205
+ return { api: httpClient(actx, loc.content_type ? { contentType: loc.content_type } : {}), xml: parseApi(actx.provider, "providers.http.<api>").encoding === "xml" };
206
+ }
207
+ /** What a write sends besides the collection: nothing, the parent read just before, or the listed fields of it. */
208
+ function sentAlong(send, doc) {
209
+ if (send === "field" || send === "collection")
210
+ return {};
211
+ if (send === "parent")
212
+ return doc;
213
+ return send.reduce((body, f) => {
214
+ const v = at(doc, fieldTokens(f));
215
+ return v === undefined ? body : setAt(body, fieldTokens(f), v);
216
+ }, {});
217
+ }
218
+ /**
219
+ * Write the collection after one change (`value: null` removes `key`): a keyed map with `send: field` as a merge
220
+ * patch of that entry, anything else as the whole collection, alone or in the parent read just before.
221
+ */
222
+ async function writeChange(api, loc, doc, entries, change) {
223
+ const tokens = pointerTokens(loc.write_list ?? loc.list);
224
+ const space = loc.write.indexOf(" ");
225
+ if (loc.delete_empty && entries.length === 0) {
226
+ // An API that refuses an empty collection (S3 CORS needs at least one rule) removes it instead.
227
+ try {
228
+ await write(api, "DELETE", loc.write.slice(space + 1), undefined, true);
229
+ }
230
+ catch (e) {
231
+ if (!failedWith(e, "PROVIDER_NOT_FOUND", []))
232
+ throw e;
233
+ }
234
+ return;
235
+ }
236
+ let body;
237
+ if (loc.shape === "map" && loc.send === "field")
238
+ body = place({}, tokens, { [String(change.key)]: change.value });
239
+ else
240
+ body = place(sentAlong(loc.send, doc), tokens, encode(entries, loc));
241
+ await write(api, loc.write.slice(0, space), loc.write.slice(space + 1), body, true);
242
+ }
243
+ function raced(loc, what) {
244
+ return new SponsonError("PROVIDER_CONFLICT", `${ADAPTER}: ${loc.read}${loc.list}: ${what} after ${MAX_ATTEMPTS} read-modify-write attempts; another writer keeps changing it`, { adapter: ADAPTER, path: loc.read });
245
+ }
246
+ function keepWithoutItem(label) {
247
+ return paramError(ADAPTER, `${label} declares \`{ keep: true }\` but is not there, so there is no value to keep. Give it a value or remove it.`, "item");
248
+ }
249
+ function isPlanned(spec, entry) {
250
+ return entry !== undefined && stateHash(entryState(spec, entry)) === stateHash(desiredState(spec, entry));
251
+ }
252
+ /**
253
+ * Put the item in the collection until a fresh read shows it as planned. Returns whether this call added it (it
254
+ * was absent from the collection it read and wrote).
255
+ */
256
+ async function ensure(actx, spec, loc, label) {
257
+ const conn = clientFor(actx, loc);
258
+ let added = false;
259
+ for (let attempt = 0; attempt <= MAX_ATTEMPTS; attempt++) {
260
+ const { doc, entries } = await readParent(conn, loc, spec);
261
+ const idx = entries.findIndex((e) => sameKey(e.key, loc.item));
262
+ if (isPlanned(spec, entries[idx]))
263
+ return added;
264
+ if (attempt === MAX_ATTEMPTS)
265
+ break;
266
+ if (idx < 0) {
267
+ if (hasKeep(spec))
268
+ throw keepWithoutItem(label);
269
+ if (!added)
270
+ await actx.intend([keyOf(loc)]);
271
+ added = true;
272
+ }
273
+ actx.log(`${idx < 0 ? "add" : "update"} ${label}`);
274
+ const change = { key: loc.item, value: nextValue(spec, entries[idx]) };
275
+ const next = idx < 0 ? [...entries, change] : entries.map((e, i) => (i === idx ? change : e));
276
+ await writeChange(conn.api, loc, doc, next, change);
277
+ }
278
+ throw raced(loc, "the item is still not as planned");
279
+ }
280
+ /** Take the item out until a fresh read no longer shows it; a missing parent counts as gone. */
281
+ async function remove(conn, loc) {
282
+ for (let attempt = 0; attempt <= MAX_ATTEMPTS; attempt++) {
283
+ let parent;
284
+ try {
285
+ parent = await readParent(conn, loc);
286
+ }
287
+ catch (e) {
288
+ if (failedWith(e, "PROVIDER_NOT_FOUND", []))
289
+ return;
290
+ throw e;
291
+ }
292
+ const rest = parent.entries.filter((e) => !sameKey(e.key, loc.item));
293
+ if (rest.length === parent.entries.length)
294
+ return;
295
+ if (attempt === MAX_ATTEMPTS)
296
+ break;
297
+ await writeChange(conn.api, loc, parent.doc, rest, { key: loc.item, value: null });
298
+ }
299
+ throw raced(loc, "the item is still there");
300
+ }
301
+ function parseLocator(id, key) {
302
+ try {
303
+ const loc = JSON.parse(id);
304
+ if (typeof loc.read === "string" && typeof loc.write === "string" && typeof loc.list === "string")
305
+ return loc;
306
+ }
307
+ catch {
308
+ // reported below
309
+ }
310
+ throw new SponsonError("INTERNAL", `${ADAPTER}: ${key}: record id is not a list item locator`, { adapter: ADAPTER, key });
311
+ }
312
+ // ---------------------------------------------------------------------------
313
+ // The op
314
+ // ---------------------------------------------------------------------------
315
+ function recordOf(loc, spec, entry, label) {
316
+ return { key: keyOf(loc), id: canonicalJson(loc), hash: stateHash(entryState(spec, entry)), label };
317
+ }
318
+ function side(state) {
319
+ const marker = firstMarker(state);
320
+ return marker ? desiredSide(marker, false) : { state: "literal", value: text(state) };
321
+ }
322
+ function diffExisting(spec, key, label, current, entry) {
323
+ const before = entry === undefined ? SENSITIVE : { state: "literal", value: text(entryState(spec, entry)) };
324
+ const desired = desiredState(spec, entry);
325
+ if (firstMarker(desired) !== undefined)
326
+ return { key, kind: "update", label, before, after: side(desired) };
327
+ if (stateHash(desired) === current.hash)
328
+ return { key, kind: "unchanged", label };
329
+ return { key, kind: "update", label, before, after: side(desired) };
330
+ }
331
+ /**
332
+ * The parent object's identity for its lock (ADR 0019): `http:<base URL><parent path>`. The base URL is the API
333
+ * block's `base_url` (not its `base_url_env` override, so every runner names the object alike) without user info,
334
+ * query or fragment: an identity is written to receipts, so it never carries a credential. Every collection of
335
+ * one parent shares the lock, since `send: parent` writes them all back.
336
+ */
337
+ function parentLock(params, provider) {
338
+ const spec = parseListItem(params);
339
+ const path = fillPath(spec.parent.path, spec.vars);
340
+ if (path === undefined || typeof provider.base_url !== "string")
341
+ return null;
342
+ const base = new URL(provider.base_url);
343
+ return `${ADAPTER}:${base.protocol}//${base.host}${base.pathname.replace(/\/+$/, "")}${path}`;
344
+ }
345
+ /** `http.list_item`: one value kept in a collection on a parent object, by read-modify-write. */
346
+ export const listItem = {
347
+ outputs: {},
348
+ // A recipe line's params are checked before any request (PARAM_INVALID naming the param); it declares no outputs.
349
+ outputsFor: (params) => (params.recipe === undefined ? {} : (expandRecipe(params, "list_item"), {})),
350
+ providerFor: apiBlock,
351
+ credentialInputs: credentialInputs("list_item"),
352
+ lockOn: parentLock,
353
+ writesEnvironment: apiEnvironment,
354
+ async read(actx, params) {
355
+ const spec = parseListItem(params);
356
+ const loc = locatorOf(spec);
357
+ // Nothing can be in a list read with a credential that does not exist yet (its line is still to be created).
358
+ if (!loc || firstMarker(spec.credential) !== undefined)
359
+ return null;
360
+ const { entries } = await readParent(clientFor(withLineCredential(actx, spec.credential), loc), loc, spec);
361
+ const entry = entries.find((e) => sameKey(e.key, loc.item));
362
+ if (entry === undefined)
363
+ return null;
364
+ const state = { resources: [recordOf(loc, spec, entry, labelOf(spec, loc))], outputs: {} };
365
+ found.set(state, entry);
366
+ return state;
367
+ },
368
+ diff(live, params) {
369
+ const spec = parseListItem(params);
370
+ const loc = locatorOf(spec);
371
+ if (!loc)
372
+ return [{ key: "(pending)", kind: "create", label: `${spec.api} list item`, before: ABSENT, after: desiredSide(firstMarker(params) ?? "", false) }];
373
+ const key = keyOf(loc);
374
+ const label = labelOf(spec, loc);
375
+ const current = live?.resources.find((r) => r.key === key);
376
+ if (current)
377
+ return [diffExisting(spec, key, label, current, live ? found.get(live) : undefined)];
378
+ if (hasKeep(spec))
379
+ throw keepWithoutItem(label);
380
+ return [{ key, kind: "create", label, before: ABSENT, after: side(desiredState(spec, undefined)) }];
381
+ },
382
+ async apply(actx, params, live) {
383
+ assertNoPending(params, ADAPTER);
384
+ const spec = parseListItem(params);
385
+ const loc = locatorOf(spec);
386
+ const key = keyOf(loc);
387
+ const label = labelOf(spec, loc);
388
+ const current = live?.resources.find((r) => r.key === key);
389
+ const entry = live ? found.get(live) : undefined;
390
+ if (current && isPlanned(spec, entry))
391
+ return { resources: [current], outputs: {}, created: [] };
392
+ const added = await ensure(withLineCredential(actx, spec.credential), spec, loc, label);
393
+ const hash = stateHash(desiredState(spec, entry));
394
+ return { resources: [{ key, id: canonicalJson(loc), hash, label }], outputs: {}, created: added ? [key] : [] };
395
+ },
396
+ async destroy(actx, resources) {
397
+ for (const r of resources) {
398
+ if (r.id === "")
399
+ continue; // an intent never located: nothing was added under it
400
+ const loc = parseLocator(r.id, r.key);
401
+ if (loc.keep)
402
+ continue; // `destroy: keep`: left in place on purpose
403
+ await remove(clientFor(actx, loc), loc);
404
+ }
405
+ },
406
+ /** Every item of the collection: any of them may be one a scope (or nobody) manages. */
407
+ async listScope(actx, params) {
408
+ const spec = parseListItem(params);
409
+ const loc = locatorOf(spec);
410
+ if (!loc || firstMarker(spec.credential) !== undefined)
411
+ return [];
412
+ const { entries } = await readParent(clientFor(withLineCredential(actx, spec.credential), loc), loc, spec);
413
+ return entries.flatMap((e) => {
414
+ if (e.key === undefined || isObject(e.key) || Array.isArray(e.key))
415
+ return [];
416
+ const l = { ...loc, item: e.key };
417
+ return [recordOf(l, spec, e, labelOf(spec, l))];
418
+ });
419
+ },
420
+ };
421
+ //# sourceMappingURL=http-adapter-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-adapter-list.js","sourceRoot":"","sources":["../src/http-adapter-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAgI,MAAM,eAAe,CAAC;AAC1L,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAkB,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAsD,MAAM,wBAAwB,CAAC;AAEvQ,8FAA8F;AAC9F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAiC9B,6EAA6E;AAC7E,MAAM,KAAK,GAAG,IAAI,OAAO,EAAoB,CAAC;AAE9C,+HAA+H;AAC/H,SAAS,QAAQ,CAAC,IAAkB;IAClC,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO;QAAE,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAA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GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QAClE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC3G,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC3B,IAAI,CAAC,CAAC,GAAG,KAAK,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;gBAAE,OAAO,EAAE,CAAC;YAC9E,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;YAClC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `http.resource`: one object per item in a REST API (a feature flag, a webhook endpoint), declared entirely in the
3
+ * plan. See ADR 0017 and docs/plan-format.md#httpresource.
4
+ *
5
+ * - Key: where the object lives and what identifies it there: `<find.path>[<field>=<value>,…]` when it is located
6
+ * by `find`, else its `read.path` (a URL that names it). A GraphQL `find` or `read` stands in for the path as
7
+ * `graphql:<root field>(<variables>)<data path>`. The provider block (base URL, credential) is part of the ledger
8
+ * identity already.
9
+ * - Id: the request that removes it, `DELETE /things/<id>` (`KEEP /things/<id>` with `destroy: keep`), plus any
10
+ * `gone_status`, or `GRAPHQL {"query":…,"variables":…}` for a GraphQL delete, so `destroy` needs nothing but the
11
+ * ledger. A new provider id makes a new record id: replaced
12
+ * outside Sponson.
13
+ * - Hash: `sha256(canonicalJson({ <field>: <value> }))` over the declared `fields` only; `diff` compares the same
14
+ * form, so a console edit of a declared field is `changed` drift and anything else the provider stores is not.
15
+ */
16
+ import { type OpSpec } from "@sponson/core";
17
+ import { type ResourceSpec } from "./http-adapter-spec.js";
18
+ /** The resource key, or undefined while a value it depends on is pending. */
19
+ export declare function resourceKey(spec: ResourceSpec): string | undefined;
20
+ /**
21
+ * What the ledger knows a line's object by: its key, and its record id with `id` standing for the provider's id.
22
+ * The recipe identity lock (recipes.test.ts) pins it per recipe op.
23
+ */
24
+ export declare function resourceIdentity(spec: ResourceSpec, id: string): {
25
+ key: string | undefined;
26
+ id: string;
27
+ };
28
+ /** `http.resource`: one object per item, located by a path or by `find`, its declared `fields` kept as planned. */
29
+ export declare const resource: OpSpec;