@haverstack/wire-types 0.40.0 → 0.41.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/dist/index.js CHANGED
@@ -1,400 +1,23 @@
1
- import { NATIVE_SORT_FIELDS, StackError, StackValidationError, StackPermissionError, StackNotFoundError, StackConflictError, StackVersionConflictError, StackMigrationError, StackBadRequestError, StackSchemaDriftError, StackPayloadTooLargeError, StackTimeoutError, } from '@haverstack/core';
2
- /** Copied field by field, so a response never aliases a stored record's object. */
3
- function serializeActor(a) {
4
- const w = { subjectId: a.subjectId };
5
- if (a.principalId !== undefined)
6
- w.principalId = a.principalId;
7
- return w;
8
- }
9
- export function serializeRecord(r) {
10
- const w = {
11
- id: r.id,
12
- typeId: r.typeId,
13
- createdAt: r.createdAt.toISOString(),
14
- updatedAt: r.updatedAt.toISOString(),
15
- content: r.content,
16
- version: r.version,
17
- };
18
- if (r.parentId !== undefined)
19
- w.parentId = r.parentId;
20
- if (r.appId !== undefined)
21
- w.appId = r.appId;
22
- if (r.createdBy !== undefined)
23
- w.createdBy = serializeActor(r.createdBy);
24
- if (r.updatedBy !== undefined)
25
- w.updatedBy = serializeActor(r.updatedBy);
26
- if (r.deletedAt !== undefined)
27
- w.deletedAt = r.deletedAt.toISOString();
28
- if (r.unlistedAt !== undefined)
29
- w.unlistedAt = r.unlistedAt.toISOString();
30
- if (r.permissions !== undefined)
31
- w.permissions = r.permissions;
32
- if (r.associations !== undefined)
33
- w.associations = r.associations;
34
- return w;
35
- }
36
- export function serializeType(t) {
37
- const w = {
38
- id: t.id,
39
- baseId: t.baseId,
40
- version: t.version,
41
- name: t.name,
42
- schema: t.schema,
43
- schemaHash: t.schemaHash,
44
- createdAt: t.createdAt.toISOString(),
45
- };
46
- if (t.migratesFrom !== undefined)
47
- w.migratesFrom = t.migratesFrom;
48
- return w;
49
- }
50
- export function serializeVersion(v) {
51
- const w = {
52
- version: v.version,
53
- typeId: v.typeId,
54
- content: v.content,
55
- updatedAt: v.updatedAt.toISOString(),
56
- };
57
- if (v.createdBy !== undefined)
58
- w.createdBy = serializeActor(v.createdBy);
59
- if (v.updatedBy !== undefined)
60
- w.updatedBy = serializeActor(v.updatedBy);
61
- return w;
62
- }
63
- export function serializeJournalEntry(e) {
64
- const w = {
65
- seq: e.seq,
66
- at: e.at.toISOString(),
67
- kind: e.kind,
68
- // Copied for the same reason serializeChange() copies: the array
69
- // belongs to the entry the adapter read, not to this response.
70
- ops: [...e.ops],
71
- version: e.version,
72
- typeId: e.typeId,
73
- };
74
- if (e.parentId !== undefined)
75
- w.parentId = e.parentId;
76
- if (e.actor !== undefined)
77
- w.actor = serializeChangeActor(e.actor);
78
- // Presence, not truthiness: `null` is the root and has to survive.
79
- if (e.previousParentId !== undefined)
80
- w.previousParentId = e.previousParentId;
81
- if (e.associations !== undefined)
82
- w.associations = e.associations;
83
- return w;
84
- }
1
+ /**
2
+ * @haverstack/wire-types
3
+ * -------------------------------------------------------
4
+ * The HTTP wire format's shapes and the encodings between them and core's
5
+ * types, shared by `@haverstack/adapter-api` and any server implementation
6
+ * so both sides read the same contract. One module per endpoint group, the
7
+ * same split `@haverstack/conformance-fixtures` uses. See
8
+ * docs/spec/wire-format.md.
9
+ */
10
+ export { serializeChangeActor, serializeRecord, serializeType, serializeVersion, } from './records.js';
11
+ export { serializeJournalEntry } from './journal.js';
12
+ export { WIRE_ERROR_STATUS, STATUS_TO_CODE, isWireError, serializeError, deserializeError, errorForStatus, } from './errors.js';
13
+ export { WIRE_PROTOCOL_VERSION, normalizeCapabilities, parseProtocolVersion, isProtocolCompatible, } from './discovery.js';
14
+ export { AUTH_METHOD_DID_CHALLENGE, supportsDidChallenge, WIRE_AUTH_ERROR_STATUS, isWireAuthError, isRetryableAuthError, } from './auth.js';
15
+ export { CHANGE_TRANSPORT_SSE, supportsChangeFeed, serializeChange, CHANGE_FRAME_READY, CHANGE_FRAME_RECORD, CHANGE_FRAME_RESET, isValidCursor, } from './change-feed.js';
16
+ export { supportsInstallRequests } from './installs.js';
85
17
  /**
86
18
  * Re-exported from `@haverstack/core/wire`, which decodes wire dates on the
87
19
  * request side too — one definition, the same way `WireErrorCode` aliases
88
20
  * core's `StackErrorCode` rather than restating it.
89
21
  */
90
22
  export { parseDate } from '@haverstack/core/wire';
91
- /** Canonical HTTP status for each wire error code. */
92
- export const WIRE_ERROR_STATUS = {
93
- bad_request: 400,
94
- permission: 403,
95
- not_found: 404,
96
- conflict: 409,
97
- // 412 (not 409): RFC 7232's status for a failed If-Match precondition,
98
- // and distinct from 'conflict' — StackVersionConflictError is not a
99
- // StackConflictError subtype (see its doc comment), so each code keeps
100
- // its own unambiguous status, including for the status-only fallback
101
- // below.
102
- version_conflict: 412,
103
- validation: 422,
104
- /**
105
- * No core code path currently produces a StackMigrationError over the
106
- * wire (migration-graph errors are thrown during client-side migration
107
- * registration, never as a server response) — this entry exists so a
108
- * future server-side migration-graph check has a defined status to use.
109
- */
110
- migration: 500,
111
- // Shares 409 with 'conflict', so a schema-drift response without a
112
- // parseable body degrades to a generic StackConflictError in
113
- // status-only reconstruction. See docs/spec/wire-format.md § Wire error
114
- // body.
115
- schema_drift: 409,
116
- // 413 is unambiguous — no other wire code shares it — so status-only
117
- // reconstruction (STATUS_TO_CODE below) recovers this class even from a
118
- // bodyless response (e.g. a reverse proxy's own request-entity-too-large
119
- // page, not the server's JSON error body).
120
- payload_too_large: 413,
121
- /**
122
- * 503, not 408 or 504: the request arrived fine (408 says it didn't) and
123
- * the server is not a gateway (504 says it is) — it declined to keep
124
- * spending its own time on this one. Retryable, which is the part a
125
- * client acts on, and the reason a query timeout must not reuse
126
- * `bad_request`: that code means "malformed, retrying won't help."
127
- */
128
- timeout: 503,
129
- };
130
- /**
131
- * Statuses that unambiguously imply a wire error code, for reconstructing
132
- * an error from status alone when a response has no parseable wire error
133
- * body. 500 is deliberately excluded — it would misclassify ordinary
134
- * server bugs as StackMigrationError. See docs/spec/wire-format.md
135
- * § Wire error body.
136
- */
137
- export const STATUS_TO_CODE = {
138
- 400: 'bad_request',
139
- 403: 'permission',
140
- 404: 'not_found',
141
- 409: 'conflict',
142
- 412: 'version_conflict',
143
- 422: 'validation',
144
- 413: 'payload_too_large',
145
- // 503 is deliberately excluded, for the same reason as 500: a bodyless
146
- // 503 is a load balancer or a restarting process saying "not right now",
147
- // and reporting that as StackTimeoutError would tell an app its query
148
- // was too expensive when the server never saw it. The typed body is
149
- // what distinguishes the two, so `timeout` only reconstructs from one.
150
- };
151
- const KNOWN_CODES = new Set(Object.keys(WIRE_ERROR_STATUS));
152
- /** Type guard: does this parsed JSON body look like a WireError? */
153
- export function isWireError(body) {
154
- if (!body || typeof body !== 'object')
155
- return false;
156
- const err = body.error;
157
- if (!err || typeof err !== 'object')
158
- return false;
159
- const code = err.code;
160
- const message = err.message;
161
- return typeof code === 'string' && KNOWN_CODES.has(code) && typeof message === 'string';
162
- }
163
- /**
164
- * Convert a thrown core error into its wire response. Used by server
165
- * implementations. Returns null for anything that isn't a StackError —
166
- * callers fall back to their own generic error handling, so an ordinary bug
167
- * stays a bare 500 rather than being dressed as a protocol error.
168
- */
169
- export function serializeError(err) {
170
- if (!(err instanceof StackError))
171
- return null;
172
- const error = { code: err.code, message: err.message };
173
- // The three classes carrying structured payload still need instanceof: a
174
- // literal `code` doesn't narrow a class type to its subclass in TypeScript.
175
- // Order-independent, since these are leaves with no subtype relation.
176
- if (err instanceof StackValidationError) {
177
- error.details = err.errors;
178
- }
179
- else if (err instanceof StackVersionConflictError) {
180
- error.versionConflict = {
181
- recordId: err.recordId,
182
- expectedVersion: err.expectedVersion,
183
- actualVersion: err.actualVersion,
184
- };
185
- }
186
- else if (err instanceof StackSchemaDriftError) {
187
- error.schemaDrift = { typeId: err.typeId, violations: err.violations };
188
- }
189
- return { status: WIRE_ERROR_STATUS[err.code], body: { error } };
190
- }
191
- /** Reconstruct the core error a WireError body describes. */
192
- export function deserializeError(body) {
193
- const { code, message, details, versionConflict, schemaDrift } = body.error;
194
- switch (code) {
195
- case 'validation':
196
- return new StackValidationError(details ?? []);
197
- case 'permission':
198
- return new StackPermissionError(message);
199
- case 'not_found':
200
- return new StackNotFoundError(message);
201
- case 'conflict':
202
- return new StackConflictError(message);
203
- case 'version_conflict':
204
- return new StackVersionConflictError(message, versionConflict?.recordId ?? '', versionConflict?.expectedVersion ?? -1, versionConflict?.actualVersion ?? -1);
205
- case 'bad_request':
206
- return new StackBadRequestError(message);
207
- case 'migration':
208
- return new StackMigrationError(message);
209
- case 'schema_drift':
210
- return new StackSchemaDriftError(schemaDrift?.typeId ?? '', schemaDrift?.violations ?? []);
211
- case 'payload_too_large':
212
- return new StackPayloadTooLargeError(message);
213
- case 'timeout':
214
- return new StackTimeoutError(message);
215
- }
216
- }
217
- /**
218
- * Reconstruct a core error from an HTTP status alone (no usable wire error
219
- * body). Returns null for statuses with no unambiguous code — callers
220
- * should fall back to a generic adapter-level error.
221
- */
222
- export function errorForStatus(status, message) {
223
- const code = STATUS_TO_CODE[status];
224
- return code ? deserializeError({ error: { code, message } }) : null;
225
- }
226
- // -------------------------------------------------------
227
- // Discovery
228
- // -------------------------------------------------------
229
- /**
230
- * The wire protocol this package describes. Bump the major when a change
231
- * would make an older client read a response wrongly; bump the minor for
232
- * additions an older client can ignore. See docs/spec/wire-format.md
233
- * § Version negotiation.
234
- */
235
- export const WIRE_PROTOCOL_VERSION = '1.0';
236
- const CONTENT_FILTER_REACHES = new Set(['none', 'field', 'path']);
237
- const SORT_FIELDS = new Set(NATIVE_SORT_FIELDS);
238
- /**
239
- * Read a discovery response's capabilities, resolving anything absent,
240
- * malformed or unrecognized to the least capable value it could stand for
241
- * — one rule, applied once, rather than a default per key at each call
242
- * site. Silence is never a claim in either direction: a client that read
243
- * an omitted flag as support would send a query the server drops and
244
- * present the unfiltered superset that comes back as a filtered result.
245
- *
246
- * A `null` limit is the one entry that reads as permissive, because it
247
- * says only that this client cannot pre-check; the server's own ceiling
248
- * still answers with a 413.
249
- * See docs/spec/adapters.md § Adapter capabilities.
250
- */
251
- export function normalizeCapabilities(capabilities) {
252
- const filter = capabilities?.filter;
253
- const sort = capabilities?.sort;
254
- const limits = capabilities?.limits;
255
- const reach = filter?.content;
256
- return {
257
- filter: {
258
- content: CONTENT_FILTER_REACHES.has(reach) ? reach : 'none',
259
- contentPresent: filter?.contentPresent === true,
260
- search: filter?.search === true,
261
- },
262
- sort: {
263
- fields: (sort?.fields ?? []).filter((f) => SORT_FIELDS.has(f)),
264
- contentField: sort?.contentField === true,
265
- },
266
- limits: {
267
- attachmentBytes: finiteOrNull(limits?.attachmentBytes),
268
- contentBytes: finiteOrNull(limits?.contentBytes),
269
- },
270
- };
271
- }
272
- /** A ceiling this client can compare against, or null for "cannot pre-check". */
273
- const finiteOrNull = (value) => typeof value === 'number' && Number.isFinite(value) ? value : null;
274
- /** The challenge–response handshake of docs/spec/wire-format.md § Authentication. */
275
- export const AUTH_METHOD_DID_CHALLENGE = 'did-challenge';
276
- /** Whether a server advertises the DID challenge–response handshake. */
277
- export function supportsDidChallenge(discovery) {
278
- return discovery.auth?.methods?.includes(AUTH_METHOD_DID_CHALLENGE) ?? false;
279
- }
280
- /** Server→client streaming over `fetch`. The only transport in this version. */
281
- export const CHANGE_TRANSPORT_SSE = 'sse';
282
- /**
283
- * Whether a server offers a change feed this client can consume. A client
284
- * checks this and fails locally rather than learning it as a 404 partway
285
- * through a connection — the same reason `auth.methods` exists.
286
- */
287
- export function supportsChangeFeed(discovery) {
288
- return discovery.changes?.transports?.includes(CHANGE_TRANSPORT_SSE) ?? false;
289
- }
290
- export const WIRE_AUTH_ERROR_STATUS = {
291
- // Malformed input, not a rejected credential — there is nothing here to
292
- // authenticate yet.
293
- invalid_did: 400,
294
- unknown_nonce: 401,
295
- expired_nonce: 401,
296
- invalid_signature: 401,
297
- };
298
- /** Codes a fresh handshake can resolve. Anything else is fatal to retry. */
299
- const RETRYABLE_AUTH_CODES = new Set(['unknown_nonce', 'expired_nonce']);
300
- const KNOWN_AUTH_CODES = new Set(Object.keys(WIRE_AUTH_ERROR_STATUS));
301
- /** Type guard: does this parsed JSON body look like a WireAuthError? */
302
- export function isWireAuthError(body) {
303
- if (!body || typeof body !== 'object')
304
- return false;
305
- const err = body.error;
306
- if (!err || typeof err !== 'object')
307
- return false;
308
- const code = err.code;
309
- const message = err.message;
310
- return typeof code === 'string' && KNOWN_AUTH_CODES.has(code) && typeof message === 'string';
311
- }
312
- /** Whether retrying the handshake from a fresh nonce could succeed. */
313
- export function isRetryableAuthError(code) {
314
- return RETRYABLE_AUTH_CODES.has(code);
315
- }
316
- /** Shared by a change frame and a journal entry — one actor encoding, not two. */
317
- export function serializeChangeActor(actor) {
318
- const w = serializeActor(actor);
319
- if (actor.appId !== undefined)
320
- w.appId = actor.appId;
321
- return w;
322
- }
323
- /**
324
- * A change as a server frames it. A purge carries neither the record nor
325
- * its parent, whatever the subscriber asked for: purge is the
326
- * erasure primitive, and a frame carrying the body — or anything else
327
- * pointing at it — hands every subscriber a permanent copy of what the
328
- * stack has just destroyed.
329
- *
330
- * The rule lives here rather than at each call site because a server holds
331
- * the purged record at that moment, for the readability check it can only
332
- * make before the write, and so is in exactly the position to leak it. See
333
- * docs/spec/events.md § Purged records carry nothing.
334
- */
335
- export function serializeChange(c) {
336
- const w = {
337
- kind: c.kind,
338
- // Copied, not aliased: a frame is serialized once and delivered to
339
- // every subscriber, and the array it came from belongs to the emission.
340
- ops: [...c.ops],
341
- recordId: c.recordId,
342
- typeId: c.typeId,
343
- version: c.version,
344
- updatedAt: c.updatedAt.toISOString(),
345
- };
346
- if (c.actor !== undefined)
347
- w.actor = serializeChangeActor(c.actor);
348
- if (c.cursor !== undefined)
349
- w.cursor = c.cursor;
350
- if (c.kind === 'purged')
351
- return w;
352
- if (c.parentId !== undefined)
353
- w.parentId = c.parentId;
354
- if (c.associationsAdded !== undefined)
355
- w.associationsAdded = c.associationsAdded;
356
- if (c.associationsRemoved !== undefined)
357
- w.associationsRemoved = c.associationsRemoved;
358
- if (c.record !== undefined)
359
- w.record = serializeRecord(c.record);
360
- return w;
361
- }
362
- /**
363
- * Frame names. Every frame carries one, and a client MUST ignore a name it
364
- * does not recognize — which is what makes a new frame an additive, minor
365
- * change rather than a break. See docs/spec/change-feed.md.
366
- */
367
- export const CHANGE_FRAME_READY = 'ready';
368
- export const CHANGE_FRAME_RECORD = 'record';
369
- export const CHANGE_FRAME_RESET = 'reset';
370
- /**
371
- * A cursor travels in an SSE `id:` field, so a value spanning a line would
372
- * truncate the frame carrying it. Same charset and same reason as the auth
373
- * nonce — see docs/spec/wire-format.md § The handshake.
374
- */
375
- const CURSOR_FORMAT = /^[A-Za-z0-9_-]+$/;
376
- /** Whether a cursor is framable: unreserved base64url characters only. */
377
- export function isValidCursor(cursor) {
378
- return CURSOR_FORMAT.test(cursor);
379
- }
380
- /** Splits a MAJOR.MINOR protocol version. Returns null if it isn't one. */
381
- export function parseProtocolVersion(version) {
382
- const match = /^(\d+)\.(\d+)$/.exec(version);
383
- return match ? { major: Number(match[1]), minor: Number(match[2]) } : null;
384
- }
385
- /**
386
- * Majors must match; minors never have to. A higher server minor is additive
387
- * fields this client ignores, and a higher client minor is optional fields
388
- * the server may omit — neither can make a response read wrongly, which is
389
- * the only thing a major bump signals.
390
- */
391
- export function isProtocolCompatible(version, against = WIRE_PROTOCOL_VERSION) {
392
- const server = parseProtocolVersion(version);
393
- const client = parseProtocolVersion(against);
394
- return server !== null && client !== null && server.major === client.major;
395
- }
396
- /** Whether a server advertises `POST /installs`. */
397
- export function supportsInstallRequests(discovery) {
398
- return discovery.installs?.requests === true;
399
- }
400
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,mBAAmB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AAE,QAAQ,KAAK,IAAI,CAAC;AAC/C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,oBAAoB,GACrB,MAAM,WAAW,CAAC;AAUnB,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Installs
3
+ * -------------------------------------------------------
4
+ * `POST /installs`: an app asking the owner to approve its manifest.
5
+ * See docs/spec/wire-format.md § Installs.
6
+ */
7
+ import type { AppManifest } from '@haverstack/core';
8
+ import type { WireRecord } from './records.js';
9
+ /**
10
+ * Whether a server takes install requests at `POST /installs`. Absent means
11
+ * it does not, and a client says so locally rather than learning it as a
12
+ * 404. An object for the same reason `changes` is one.
13
+ * See docs/spec/wire-format.md § Installs.
14
+ */
15
+ export type DiscoveryInstalls = {
16
+ requests: boolean;
17
+ };
18
+ /** Whether a server advertises `POST /installs`. */
19
+ export declare function supportsInstallRequests(discovery: {
20
+ installs?: DiscoveryInstalls;
21
+ }): boolean;
22
+ /** POST /installs. The key being installed is the session's, never named here. */
23
+ export type WireInstallRequest = {
24
+ manifest: AppManifest;
25
+ };
26
+ /**
27
+ * POST /installs answers `pending` (202) while the owner has not approved
28
+ * this manifest for this key, and `installed` (200) once applying it would
29
+ * change nothing.
30
+ */
31
+ export type WireInstallResponse = {
32
+ status: 'pending';
33
+ } | {
34
+ status: 'installed';
35
+ install: WireRecord;
36
+ };
37
+ //# sourceMappingURL=installs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installs.d.ts","sourceRoot":"","sources":["../src/installs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oDAAoD;AACpD,wBAAgB,uBAAuB,CAAC,SAAS,EAAE;IAAE,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAAG,OAAO,CAE5F;AAED,kFAAkF;AAClF,MAAM,MAAM,kBAAkB,GAAG;IAAE,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Installs
3
+ * -------------------------------------------------------
4
+ * `POST /installs`: an app asking the owner to approve its manifest.
5
+ * See docs/spec/wire-format.md § Installs.
6
+ */
7
+ /** Whether a server advertises `POST /installs`. */
8
+ export function supportsInstallRequests(discovery) {
9
+ return discovery.installs?.requests === true;
10
+ }
11
+ //# sourceMappingURL=installs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installs.js","sourceRoot":"","sources":["../src/installs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,oDAAoD;AACpD,MAAM,UAAU,uBAAuB,CAAC,SAA2C;IACjF,OAAO,SAAS,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Change journal
3
+ * -------------------------------------------------------
4
+ * `GET /records/:id/journal`: the per-record log of what each write did.
5
+ * See docs/spec/wire-format.md § Journal.
6
+ */
7
+ import type { AssociationChange, ChangeKind, ChangeOp, RecordJournalEntry } from '@haverstack/core';
8
+ import { type WireChangeActor } from './records.js';
9
+ /**
10
+ * Every field a `RecordJournalEntry` holds, since the whole entry is what
11
+ * makes a change recoverable; `content` lives on a snapshot instead. `seq`
12
+ * is dense per record and never the change feed's `cursor`. See
13
+ * docs/spec/wire-format.md § Journal.
14
+ */
15
+ export type WireJournalEntry = {
16
+ seq: number;
17
+ at: string;
18
+ kind: ChangeKind;
19
+ ops: ChangeOp[];
20
+ version: number;
21
+ typeId: string;
22
+ parentId?: string;
23
+ actor?: WireChangeActor;
24
+ /**
25
+ * The container the move took the record out of — and the one field on
26
+ * any response where `null` is a value rather than an input spelling.
27
+ * Absent means this entry is not a reparent; present and `null` means it
28
+ * moved out of the root. Collapsing the two would lose which one
29
+ * happened, so the root sentinel travels here as it does on a request.
30
+ */
31
+ previousParentId?: string | null;
32
+ /**
33
+ * One tagged edit per association the write moved, each carrying its own
34
+ * `previous` where it had one. Has no counterpart on the change feed,
35
+ * which reports what is true now across two flat lists.
36
+ */
37
+ associations?: AssociationChange[];
38
+ };
39
+ /**
40
+ * The response envelope of `GET /records/:id/journal`. `cursor` is the only
41
+ * end-of-log signal, since a server may cap a page below the `limit` asked
42
+ * for. It carries the `seq` to send as the next `afterSeq`, and is null
43
+ * once nothing follows.
44
+ */
45
+ export type WireJournalResponse = {
46
+ entries: WireJournalEntry[];
47
+ cursor: number | null;
48
+ };
49
+ export declare function serializeJournalEntry(e: RecordJournalEntry): WireJournalEntry;
50
+ //# sourceMappingURL=journal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../src/journal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,EAAE,QAAQ,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC;;;;OAIG;IACH,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACpC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,kBAAkB,GAAG,gBAAgB,CAiB7E"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Change journal
3
+ * -------------------------------------------------------
4
+ * `GET /records/:id/journal`: the per-record log of what each write did.
5
+ * See docs/spec/wire-format.md § Journal.
6
+ */
7
+ import { serializeChangeActor } from './records.js';
8
+ export function serializeJournalEntry(e) {
9
+ const w = {
10
+ seq: e.seq,
11
+ at: e.at.toISOString(),
12
+ kind: e.kind,
13
+ // Copied for the same reason serializeChange() copies: the array
14
+ // belongs to the entry the adapter read, not to this response.
15
+ ops: [...e.ops],
16
+ version: e.version,
17
+ typeId: e.typeId,
18
+ };
19
+ if (e.parentId !== undefined)
20
+ w.parentId = e.parentId;
21
+ if (e.actor !== undefined)
22
+ w.actor = serializeChangeActor(e.actor);
23
+ // Presence, not truthiness: `null` is the root and has to survive.
24
+ if (e.previousParentId !== undefined)
25
+ w.previousParentId = e.previousParentId;
26
+ if (e.associations !== undefined)
27
+ w.associations = e.associations;
28
+ return w;
29
+ }
30
+ //# sourceMappingURL=journal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal.js","sourceRoot":"","sources":["../src/journal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,oBAAoB,EAAwB,MAAM,cAAc,CAAC;AA4C1E,MAAM,UAAU,qBAAqB,CAAC,CAAqB;IACzD,MAAM,CAAC,GAAqB;QAC1B,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE;QACtB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,iEAAiE;QACjE,+DAA+D;QAC/D,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;QACf,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB,CAAC;IACF,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;QAAE,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;IACtD,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS;QAAE,CAAC,CAAC,KAAK,GAAG,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACnE,mEAAmE;IACnE,IAAI,CAAC,CAAC,gBAAgB,KAAK,SAAS;QAAE,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB,CAAC;IAC9E,IAAI,CAAC,CAAC,YAAY,KAAK,SAAS;QAAE,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC;IAClE,OAAO,CAAC,CAAC;AACX,CAAC"}