@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/auth.d.ts +67 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +34 -0
- package/dist/auth.js.map +1 -0
- package/dist/change-feed.d.ts +92 -0
- package/dist/change-feed.d.ts.map +1 -0
- package/dist/change-feed.js +69 -0
- package/dist/change-feed.js.map +1 -0
- package/dist/discovery.d.ts +73 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +74 -0
- package/dist/discovery.js.map +1 -0
- package/dist/errors.d.ts +68 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +151 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +22 -440
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -393
- package/dist/index.js.map +1 -1
- package/dist/installs.d.ts +37 -0
- package/dist/installs.d.ts.map +1 -0
- package/dist/installs.js +11 -0
- package/dist/installs.js.map +1 -0
- package/dist/journal.d.ts +50 -0
- package/dist/journal.d.ts.map +1 -0
- package/dist/journal.js +30 -0
- package/dist/journal.js.map +1 -0
- package/dist/records.d.ts +81 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +76 -0
- package/dist/records.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records, types, versions and actors
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* The stored shapes as a response carries them — dates as ISO strings,
|
|
5
|
+
* optional fields absent rather than undefined — and the envelopes that
|
|
6
|
+
* page them. See docs/spec/wire-format.md.
|
|
7
|
+
*/
|
|
8
|
+
import type { Actor, ChangeActor, RecordVersion, StackRecord, StackType, AuthorityAssociation, DataAssociation } from '@haverstack/core';
|
|
9
|
+
/**
|
|
10
|
+
* An Actor on the wire — the same two fields, spelled the same way, so an
|
|
11
|
+
* alias rather than a second definition to drift.
|
|
12
|
+
*/
|
|
13
|
+
export type WireActor = Actor;
|
|
14
|
+
/** Who performed a change. Never who authored the record. Same shape as core's. */
|
|
15
|
+
export type WireChangeActor = ChangeActor;
|
|
16
|
+
/** Shared by a change frame and a journal entry — one actor encoding, not two. */
|
|
17
|
+
export declare function serializeChangeActor(actor: ChangeActor): WireChangeActor;
|
|
18
|
+
export type WireRecord = {
|
|
19
|
+
id: string;
|
|
20
|
+
typeId: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
content: Record<string, unknown>;
|
|
24
|
+
version: number;
|
|
25
|
+
parentId?: string;
|
|
26
|
+
appId?: string;
|
|
27
|
+
createdBy?: WireActor;
|
|
28
|
+
updatedBy?: WireActor;
|
|
29
|
+
deletedAt?: string;
|
|
30
|
+
unlistedAt?: string;
|
|
31
|
+
permissions?: AuthorityAssociation[];
|
|
32
|
+
associations?: DataAssociation[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The response envelope of `GET /records` and `POST /records/query`.
|
|
36
|
+
* `cursor` is the only end-of-results signal — a page may be empty while
|
|
37
|
+
* it is non-null — and there is no count of the whole match. See
|
|
38
|
+
* docs/spec/wire-format.md § Response envelope.
|
|
39
|
+
*/
|
|
40
|
+
export type WireQueryResponse = {
|
|
41
|
+
records: WireRecord[];
|
|
42
|
+
cursor: string | null;
|
|
43
|
+
};
|
|
44
|
+
export type WireType = {
|
|
45
|
+
id: string;
|
|
46
|
+
baseId: string;
|
|
47
|
+
version: number;
|
|
48
|
+
name: string;
|
|
49
|
+
schema: Record<string, unknown>;
|
|
50
|
+
schemaHash: string;
|
|
51
|
+
migratesFrom?: string;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* No `associations`, `permissions`, `parentId` or `unlistedAt`: none of the
|
|
56
|
+
* four bumps `version`, so no version ever snapshots them. See
|
|
57
|
+
* docs/spec/wire-format.md § Versions.
|
|
58
|
+
*/
|
|
59
|
+
export type WireVersion = {
|
|
60
|
+
version: number;
|
|
61
|
+
typeId: string;
|
|
62
|
+
content: Record<string, unknown>;
|
|
63
|
+
updatedAt: string;
|
|
64
|
+
createdBy?: WireActor;
|
|
65
|
+
updatedBy?: WireActor;
|
|
66
|
+
};
|
|
67
|
+
export declare function serializeRecord(r: StackRecord): WireRecord;
|
|
68
|
+
export declare function serializeType(t: StackType): WireType;
|
|
69
|
+
export declare function serializeVersion(v: RecordVersion): WireVersion;
|
|
70
|
+
/**
|
|
71
|
+
* The response envelope of `GET /records/:id/versions`.
|
|
72
|
+
*
|
|
73
|
+
* `cursor` is the only end-of-history signal, as on the journal: a server
|
|
74
|
+
* may cap a page below the `limit` asked for. It carries the `version` to
|
|
75
|
+
* send as the next `beforeVersion`, and is null once nothing follows.
|
|
76
|
+
*/
|
|
77
|
+
export type WireVersionsResponse = {
|
|
78
|
+
versions: WireVersion[];
|
|
79
|
+
cursor: number | null;
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,aAAa,EACb,WAAW,EACX,SAAS,EACT,oBAAoB,EACpB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC;AAS9B,mFAAmF;AACnF,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC;AAE1C,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,CAIxE;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;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AC,EAAE,SAAS,GAAG,QAAQ,CAYpD;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,aAAa,GAAG,WAAW,CAU9D;AAED;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC"}
|
package/dist/records.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records, types, versions and actors
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* The stored shapes as a response carries them — dates as ISO strings,
|
|
5
|
+
* optional fields absent rather than undefined — and the envelopes that
|
|
6
|
+
* page them. See docs/spec/wire-format.md.
|
|
7
|
+
*/
|
|
8
|
+
/** Copied field by field, so a response never aliases a stored record's object. */
|
|
9
|
+
function serializeActor(a) {
|
|
10
|
+
const w = { subjectId: a.subjectId };
|
|
11
|
+
if (a.principalId !== undefined)
|
|
12
|
+
w.principalId = a.principalId;
|
|
13
|
+
return w;
|
|
14
|
+
}
|
|
15
|
+
/** Shared by a change frame and a journal entry — one actor encoding, not two. */
|
|
16
|
+
export function serializeChangeActor(actor) {
|
|
17
|
+
const w = serializeActor(actor);
|
|
18
|
+
if (actor.appId !== undefined)
|
|
19
|
+
w.appId = actor.appId;
|
|
20
|
+
return w;
|
|
21
|
+
}
|
|
22
|
+
export function serializeRecord(r) {
|
|
23
|
+
const w = {
|
|
24
|
+
id: r.id,
|
|
25
|
+
typeId: r.typeId,
|
|
26
|
+
createdAt: r.createdAt.toISOString(),
|
|
27
|
+
updatedAt: r.updatedAt.toISOString(),
|
|
28
|
+
content: r.content,
|
|
29
|
+
version: r.version,
|
|
30
|
+
};
|
|
31
|
+
if (r.parentId !== undefined)
|
|
32
|
+
w.parentId = r.parentId;
|
|
33
|
+
if (r.appId !== undefined)
|
|
34
|
+
w.appId = r.appId;
|
|
35
|
+
if (r.createdBy !== undefined)
|
|
36
|
+
w.createdBy = serializeActor(r.createdBy);
|
|
37
|
+
if (r.updatedBy !== undefined)
|
|
38
|
+
w.updatedBy = serializeActor(r.updatedBy);
|
|
39
|
+
if (r.deletedAt !== undefined)
|
|
40
|
+
w.deletedAt = r.deletedAt.toISOString();
|
|
41
|
+
if (r.unlistedAt !== undefined)
|
|
42
|
+
w.unlistedAt = r.unlistedAt.toISOString();
|
|
43
|
+
if (r.permissions !== undefined)
|
|
44
|
+
w.permissions = r.permissions;
|
|
45
|
+
if (r.associations !== undefined)
|
|
46
|
+
w.associations = r.associations;
|
|
47
|
+
return w;
|
|
48
|
+
}
|
|
49
|
+
export function serializeType(t) {
|
|
50
|
+
const w = {
|
|
51
|
+
id: t.id,
|
|
52
|
+
baseId: t.baseId,
|
|
53
|
+
version: t.version,
|
|
54
|
+
name: t.name,
|
|
55
|
+
schema: t.schema,
|
|
56
|
+
schemaHash: t.schemaHash,
|
|
57
|
+
createdAt: t.createdAt.toISOString(),
|
|
58
|
+
};
|
|
59
|
+
if (t.migratesFrom !== undefined)
|
|
60
|
+
w.migratesFrom = t.migratesFrom;
|
|
61
|
+
return w;
|
|
62
|
+
}
|
|
63
|
+
export function serializeVersion(v) {
|
|
64
|
+
const w = {
|
|
65
|
+
version: v.version,
|
|
66
|
+
typeId: v.typeId,
|
|
67
|
+
content: v.content,
|
|
68
|
+
updatedAt: v.updatedAt.toISOString(),
|
|
69
|
+
};
|
|
70
|
+
if (v.createdBy !== undefined)
|
|
71
|
+
w.createdBy = serializeActor(v.createdBy);
|
|
72
|
+
if (v.updatedBy !== undefined)
|
|
73
|
+
w.updatedBy = serializeActor(v.updatedBy);
|
|
74
|
+
return w;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH,mFAAmF;AACnF,SAAS,cAAc,CAAC,C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AAC,SAAS,CAAC,CAAC;IACzE,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS;QAAE,CAAC,CAAC,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACzE,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haverstack/wire-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "HTTP wire types and serialization for Haverstack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "CC0-1.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@haverstack/core": "^0.
|
|
24
|
+
"@haverstack/core": "^0.42.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^22.0.0",
|