@flipstream/sdk 0.8.0 → 0.10.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 (104) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/README.md +707 -66
  3. package/dist/api/backend.d.ts +182 -0
  4. package/dist/api/backend.js +314 -0
  5. package/dist/api/backend.js.map +1 -0
  6. package/dist/api/created.d.ts +5 -0
  7. package/dist/api/created.js +15 -0
  8. package/dist/api/created.js.map +1 -0
  9. package/dist/api/credentials.d.ts +36 -0
  10. package/dist/api/credentials.js +94 -0
  11. package/dist/api/credentials.js.map +1 -0
  12. package/dist/api/datasets.d.ts +94 -0
  13. package/dist/api/datasets.js +212 -0
  14. package/dist/api/datasets.js.map +1 -0
  15. package/dist/api/handoff.d.ts +34 -0
  16. package/dist/api/handoff.js +52 -0
  17. package/dist/api/handoff.js.map +1 -0
  18. package/dist/api/ids.d.ts +7 -0
  19. package/dist/api/ids.js +27 -0
  20. package/dist/api/ids.js.map +1 -0
  21. package/dist/api/index.d.ts +9 -1
  22. package/dist/api/log.d.ts +95 -0
  23. package/dist/api/log.js +213 -0
  24. package/dist/api/log.js.map +1 -0
  25. package/dist/api/me.d.ts +58 -0
  26. package/dist/api/me.js +64 -0
  27. package/dist/api/me.js.map +1 -0
  28. package/dist/api/members.d.ts +48 -0
  29. package/dist/api/members.js +102 -0
  30. package/dist/api/members.js.map +1 -0
  31. package/dist/api/organization.d.ts +11 -0
  32. package/dist/api/organization.js +15 -0
  33. package/dist/api/organization.js.map +1 -0
  34. package/dist/api/page.d.ts +33 -0
  35. package/dist/api/page.js +38 -0
  36. package/dist/api/page.js.map +1 -0
  37. package/dist/api/time.d.ts +3 -0
  38. package/dist/api/time.js +49 -0
  39. package/dist/api/time.js.map +1 -0
  40. package/dist/api/unsent.d.ts +6 -0
  41. package/dist/api/unsent.js +9 -0
  42. package/dist/api/unsent.js.map +1 -0
  43. package/dist/api/wallet.d.ts +45 -0
  44. package/dist/api/wallet.js +102 -0
  45. package/dist/api/wallet.js.map +1 -0
  46. package/dist/api/workspaces.d.ts +70 -0
  47. package/dist/api/workspaces.js +108 -0
  48. package/dist/api/workspaces.js.map +1 -0
  49. package/dist/auth/discovery.js +1 -1
  50. package/dist/auth/discovery.js.map +1 -1
  51. package/dist/auth/signIn.js +7 -2
  52. package/dist/auth/signIn.js.map +1 -1
  53. package/dist/core/body.js +23 -5
  54. package/dist/core/body.js.map +1 -1
  55. package/dist/core/call.d.ts +6 -0
  56. package/dist/core/call.js +1 -1
  57. package/dist/core/call.js.map +1 -1
  58. package/dist/core/fetch.d.ts +5 -0
  59. package/dist/core/fetch.js +7 -1
  60. package/dist/core/fetch.js.map +1 -1
  61. package/dist/core/identify.d.ts +63 -0
  62. package/dist/core/identify.js +122 -0
  63. package/dist/core/identify.js.map +1 -0
  64. package/dist/core/names.d.ts +100 -0
  65. package/dist/core/names.js +114 -0
  66. package/dist/core/names.js.map +1 -0
  67. package/dist/core/read.d.ts +1 -1
  68. package/dist/core/read.js +15 -6
  69. package/dist/core/read.js.map +1 -1
  70. package/dist/core/result.d.ts +67 -6
  71. package/dist/core/result.js +39 -6
  72. package/dist/core/result.js.map +1 -1
  73. package/dist/core/secrets.d.ts +2 -0
  74. package/dist/core/secrets.js +33 -0
  75. package/dist/core/secrets.js.map +1 -0
  76. package/dist/core/transport.d.ts +12 -4
  77. package/dist/flipstream.d.ts +341 -5
  78. package/dist/flipstream.js +203 -13
  79. package/dist/flipstream.js.map +1 -1
  80. package/dist/index.d.ts +2 -2
  81. package/dist/index.js +1 -1
  82. package/dist/index.js.map +1 -1
  83. package/dist/node/clientSecret.js +2 -1
  84. package/dist/node/clientSecret.js.map +1 -1
  85. package/dist/node/index.d.ts +1 -0
  86. package/dist/node/index.js +1 -0
  87. package/dist/node/index.js.map +1 -1
  88. package/dist/node/keychainChild.js +10 -6
  89. package/dist/node/keychainChild.js.map +1 -1
  90. package/dist/node/keychainStore.d.ts +6 -3
  91. package/dist/node/keychainStore.js +6 -3
  92. package/dist/node/keychainStore.js.map +1 -1
  93. package/dist/node/session.d.ts +78 -29
  94. package/dist/node/session.js +74 -52
  95. package/dist/node/session.js.map +1 -1
  96. package/dist/node/store.d.ts +11 -1
  97. package/dist/node/store.js +14 -1
  98. package/dist/node/store.js.map +1 -1
  99. package/dist/query/query.d.ts +15 -10
  100. package/dist/query/query.js +21 -11
  101. package/dist/query/query.js.map +1 -1
  102. package/dist/version.gen.js +1 -1
  103. package/dist/version.gen.js.map +1 -1
  104. package/package.json +2 -2
@@ -0,0 +1,95 @@
1
+ import type { ApiResult } from '../core/result.js';
2
+ import type { Backend } from './backend.js';
3
+ import type { Page } from './page.js';
4
+ import type { Read } from './me.js';
5
+ /** A logbook entry (#218): a note on a time range in a workspace, such as a launch or a migration. */
6
+ export interface LogEntry {
7
+ readonly id: string;
8
+ readonly description: string;
9
+ /** When it starts: an ISO 8601 instant in UTC, as `2026-10-05T00:00:00.000Z`. */
10
+ readonly start_date: string;
11
+ /** When it ends, in the same form. A point in time starts and ends at once. */
12
+ readonly end_date: string;
13
+ readonly workspace_id: string;
14
+ /** When it was written: an ISO 8601 instant in UTC (#229). Null when the backend holds none. */
15
+ readonly created_on: string | null;
16
+ /**
17
+ * Who wrote it: a person's id (#229). Name them with `flipstream.members.get`; when it doesn't
18
+ * answer ok (see its docs), show the writer as unknown, for example for an entry Flipstream staff
19
+ * wrote through a swap token. Null when the backend holds none, or holds its empty default.
20
+ */
21
+ readonly created_by_id: string | null;
22
+ }
23
+ /** What `flipstream.log.list()` takes: the workspace, and the page, as every list does. */
24
+ export interface LogListRequest {
25
+ readonly workspace_id: string;
26
+ /** At most 1,000, and 100 when left out. */
27
+ readonly limit?: number;
28
+ readonly offset?: number;
29
+ }
30
+ /** What `flipstream.log.add()` takes: the workspace, the words, and the range. */
31
+ export interface LogAddRequest {
32
+ readonly workspace_id: string;
33
+ /** The entry's words: a string with more than spaces in it. */
34
+ readonly description: string;
35
+ /**
36
+ * When it starts: a date and time with seconds, as `2026-10-05T00:00:00Z`. A fraction may follow the
37
+ * seconds, and an offset such as `+02:00`, or none (read as UTC), may take the place of the `Z`.
38
+ */
39
+ readonly start_date: string;
40
+ /** When it ends, in the same form, and never before it starts. A point in time starts and ends at once. */
41
+ readonly end_date: string;
42
+ }
43
+ /** What `flipstream.log.update()` takes: the entry, and at least one of its words and its range. */
44
+ export interface LogUpdateRequest {
45
+ readonly log_id: string;
46
+ readonly description?: string;
47
+ readonly start_date?: string;
48
+ readonly end_date?: string;
49
+ }
50
+ /**
51
+ * `flipstream.log.list()`: one page of a workspace's logbook, in the backend's own order, newest
52
+ * first (no sort is sent, D550). The workspace is read beside the list, by `readOwnWorkspace`'s
53
+ * rules (D556, as amended), so one nobody has is `not_found` and another organisation's is invalid,
54
+ * never an empty page. An entry of another workspace is invalid, naming its place; the caller's id
55
+ * may be any form pulse-admin reads as the same UUID (sameUuid). An entry of another organisation is
56
+ * invalid too, naming its place, never an id (D556). The organisation's failure, then the
57
+ * workspace's, then the list's, is the answer, whichever finishes first. A bad limit or offset
58
+ * throws, as every list's does.
59
+ */
60
+ export declare function listLog(seam: Backend, read: Read, request: LogListRequest): Promise<ApiResult<Page<LogEntry>>>;
61
+ /**
62
+ * `flipstream.log.get()`: one logbook entry, by its id, read beside your organisation (D556): an
63
+ * answer that isn't the entry asked for, or is another organisation's, is invalid, echoing no id,
64
+ * as workspaces.get()'s is. The organisation's failure, then the entry's, is the answer.
65
+ */
66
+ export declare function getLog(seam: Backend, read: Read, request: {
67
+ readonly log_id: string;
68
+ }): Promise<ApiResult<LogEntry>>;
69
+ /**
70
+ * `flipstream.log.add()`: a new entry in a workspace's logbook (#219), by D557's rules. Before
71
+ * anything is sent, a key it doesn't send is `refused` (`fields`), and a description that isn't a
72
+ * non-blank string, a time it can't read, or a start after the end is a TypeError. Then the
73
+ * workspace is proved yours (`readOwnWorkspace`: one nobody has is `not_found`, another
74
+ * organisation's `invalid`, with nothing written), and one POST sends the five fields, the times
75
+ * as UTC instants. The answer is the entry made, held to that workspace and organisation.
76
+ */
77
+ export declare function addLog(seam: Backend, send: Read, request: LogAddRequest): Promise<ApiResult<LogEntry>>;
78
+ /**
79
+ * `flipstream.log.update()`: an entry's words or range changed (#219), by D557's rules: refused keys
80
+ * and TypeErrors as `add()`'s, and at least one change. The entry is read first, beside your
81
+ * organisation (`readOwnEntry`). Then one PUT sends the contract's five fields: the changed ones,
82
+ * times as UTC instants, and the rest exactly as stored. When it gives a time, a start after the
83
+ * end, the stored one included, is a TypeError, with nothing written. The answer is held to the
84
+ * entry, its workspace and your organisation.
85
+ */
86
+ export declare function updateLog(seam: Backend, send: Read, request: LogUpdateRequest): Promise<ApiResult<LogEntry>>;
87
+ /**
88
+ * `flipstream.log.remove()`: an entry removed (#219), directly, not handed off: D542's hand-offs
89
+ * are workspaces, datasets and members. A key it doesn't send is `refused`. The entry is read first,
90
+ * beside your organisation (`readOwnEntry`), then one DELETE; its answer holds nothing, so an ok is
91
+ * `null`.
92
+ */
93
+ export declare function removeLog(seam: Backend, send: Read, request: {
94
+ readonly log_id: string;
95
+ }): Promise<ApiResult<null>>;
@@ -0,0 +1,213 @@
1
+ import { z } from 'zod';
2
+ import { sameUuid } from './ids.js';
3
+ import { createdById, createdOn } from './created.js';
4
+ import { instant } from './time.js';
5
+ import { unsent } from './unsent.js';
6
+ import { readOwnWorkspace } from './workspaces.js';
7
+ const id = z.string().min(1);
8
+ const refusedPath = { ok: false, error: { kind: 'refused', reason: 'path' } };
9
+ const invalid = (issues) => ({ ok: false, error: { kind: 'invalid', issues } });
10
+ // An entry as read or written, in our names (so client_id is workspace_id), with the organisation
11
+ // it's in, so one of another organisation or workspace is caught (D556); the public LogEntry drops
12
+ // it. An object schema keeps only the fields it names, so the rest pulse-admin sends (account_id and
13
+ // the embedded organization, client and created_by, a person's email and roles) never reaches a
14
+ // caller: the writer reaches it as created_by_id alone.
15
+ const zWritten = z.object({
16
+ id,
17
+ description: z.string(),
18
+ start_date: instant,
19
+ end_date: instant,
20
+ workspace_id: id,
21
+ organization_id: id,
22
+ created_on: createdOn,
23
+ created_by_id: createdById,
24
+ });
25
+ const publicOf = ({ id: entryId, description, start_date, end_date, workspace_id, created_on, created_by_id }) => ({
26
+ id: entryId,
27
+ description,
28
+ start_date,
29
+ end_date,
30
+ workspace_id,
31
+ created_on,
32
+ created_by_id,
33
+ });
34
+ // An entry as stored, read before an update or a remove: its times kept exactly as pulse-admin wrote
35
+ // them, so an update sends an unchanged one back as it was (D557), but each one a real time.
36
+ const storedTime = z.string().refine((text) => instant.safeParse(text).success, { message: 'not an ISO 8601 date and time' });
37
+ const zStored = z.object({ id, description: z.string(), start_date: storedTime, end_date: storedTime, workspace_id: id, organization_id: id });
38
+ const zOrganizationId = z.object({ id });
39
+ /** `value` as an instant in UTC, `…Z`, or a TypeError naming `field`: a write never sends a time it can't read. */
40
+ function timeOf(call, field, value) {
41
+ const read = typeof value === 'string' ? instant.safeParse(value) : null;
42
+ if (read?.success !== true)
43
+ throw new TypeError(`log.${call}: ${field} must be a date and time with seconds, as 2026-10-05T00:00:00Z or 2026-10-05T02:00:00+02:00`);
44
+ return read.data;
45
+ }
46
+ function wordsOf(call, value) {
47
+ if (typeof value !== 'string' || value.trim() === '')
48
+ throw new TypeError(`log.${call}: description must be a string with more than spaces in it`);
49
+ return value;
50
+ }
51
+ function idOf(call, field, value) {
52
+ if (typeof value !== 'string')
53
+ throw new TypeError(`log.${call}: ${field} must be a string`);
54
+ return value;
55
+ }
56
+ /** A TypeError unless `start` (a UTC instant) is at or before `end`: a point in time starts and ends at once. */
57
+ function inOrder(call, start, end) {
58
+ if (Date.parse(start) > Date.parse(end))
59
+ throw new TypeError(`log.${call}: start_date must not be after end_date`);
60
+ }
61
+ /**
62
+ * The entry `log_id` names, read by `schema` beside your organisation (D556, D557): one of another
63
+ * organisation, or an answer that isn't the entry asked for, is invalid, echoing no id. The
64
+ * organisation's failure, then the entry's, is the answer. A write reads it as stored, and `get`
65
+ * as a caller sees it.
66
+ */
67
+ async function readOwnEntry(seam, read, logId, schema) {
68
+ const spec = seam.logEntry(logId, schema);
69
+ if (spec === null)
70
+ return refusedPath;
71
+ const [organization, entry] = await Promise.all([read(seam.myOrganization(zOrganizationId)), read(spec)]);
72
+ if (!organization.ok)
73
+ return organization;
74
+ if (!entry.ok)
75
+ return entry;
76
+ if (!sameUuid(entry.data.id, logId))
77
+ return invalid("the log entry read isn't the one asked for");
78
+ if (!sameUuid(entry.data.organization_id, organization.data.id))
79
+ return invalid("the log entry read is another organisation's");
80
+ return entry;
81
+ }
82
+ /** A write's answer, held to the entry, the workspace and the organisation it was written for. */
83
+ function checked(written, expected) {
84
+ if (!written.ok)
85
+ return written;
86
+ if (expected.id !== undefined && !sameUuid(written.data.id, expected.id))
87
+ return invalid("the log entry written isn't the one asked for");
88
+ if (!sameUuid(written.data.workspace_id, expected.workspace_id))
89
+ return invalid("the log entry written is another workspace's");
90
+ if (!sameUuid(written.data.organization_id, expected.organization_id))
91
+ return invalid("the log entry written is another organisation's");
92
+ return { ok: true, data: publicOf(written.data) };
93
+ }
94
+ /**
95
+ * `flipstream.log.list()`: one page of a workspace's logbook, in the backend's own order, newest
96
+ * first (no sort is sent, D550). The workspace is read beside the list, by `readOwnWorkspace`'s
97
+ * rules (D556, as amended), so one nobody has is `not_found` and another organisation's is invalid,
98
+ * never an empty page. An entry of another workspace is invalid, naming its place; the caller's id
99
+ * may be any form pulse-admin reads as the same UUID (sameUuid). An entry of another organisation is
100
+ * invalid too, naming its place, never an id (D556). The organisation's failure, then the
101
+ * workspace's, then the list's, is the answer, whichever finishes first. A bad limit or offset
102
+ * throws, as every list's does.
103
+ */
104
+ export async function listLog(seam, read, request) {
105
+ const { workspace_id, ...page } = request;
106
+ const spec = seam.workspaceLog(workspace_id, page, zWritten, (entry) => sameUuid(entry.workspace_id, workspace_id));
107
+ if (spec === null)
108
+ return refusedPath;
109
+ const [own, listed] = await Promise.all([readOwnWorkspace(seam, read, workspace_id, zOrganizationId), read(spec)]);
110
+ if (!own.ok)
111
+ return own;
112
+ if (!listed.ok)
113
+ return listed;
114
+ const foreign = listed.data.items.findIndex((entry) => !sameUuid(entry.organization_id, own.data.organization.id));
115
+ if (foreign !== -1)
116
+ return invalid(`records[${String(foreign)}] is another organisation's log entry`);
117
+ return { ok: true, data: { ...listed.data, items: listed.data.items.map(publicOf) } };
118
+ }
119
+ /**
120
+ * `flipstream.log.get()`: one logbook entry, by its id, read beside your organisation (D556): an
121
+ * answer that isn't the entry asked for, or is another organisation's, is invalid, echoing no id,
122
+ * as workspaces.get()'s is. The organisation's failure, then the entry's, is the answer.
123
+ */
124
+ export async function getLog(seam, read, request) {
125
+ const entry = await readOwnEntry(seam, read, request.log_id, zWritten);
126
+ return entry.ok ? { ok: true, data: publicOf(entry.data) } : entry;
127
+ }
128
+ /**
129
+ * `flipstream.log.add()`: a new entry in a workspace's logbook (#219), by D557's rules. Before
130
+ * anything is sent, a key it doesn't send is `refused` (`fields`), and a description that isn't a
131
+ * non-blank string, a time it can't read, or a start after the end is a TypeError. Then the
132
+ * workspace is proved yours (`readOwnWorkspace`: one nobody has is `not_found`, another
133
+ * organisation's `invalid`, with nothing written), and one POST sends the five fields, the times
134
+ * as UTC instants. The answer is the entry made, held to that workspace and organisation.
135
+ */
136
+ export async function addLog(seam, send, request) {
137
+ const refused = unsent(request, ['workspace_id', 'description', 'start_date', 'end_date']);
138
+ if (refused !== null)
139
+ return refused;
140
+ const workspaceId = idOf('add', 'workspace_id', request.workspace_id);
141
+ const description = wordsOf('add', request.description);
142
+ const start = timeOf('add', 'start_date', request.start_date);
143
+ const end = timeOf('add', 'end_date', request.end_date);
144
+ inOrder('add', start, end);
145
+ const own = await readOwnWorkspace(seam, send, workspaceId, zOrganizationId);
146
+ if (!own.ok)
147
+ return own;
148
+ const entry = { description, start_date: start, end_date: end, organization_id: own.data.organization.id, workspace_id: own.data.workspace.id };
149
+ return checked(await send(seam.addLogEntry(entry, zWritten)), entry);
150
+ }
151
+ /**
152
+ * `flipstream.log.update()`: an entry's words or range changed (#219), by D557's rules: refused keys
153
+ * and TypeErrors as `add()`'s, and at least one change. The entry is read first, beside your
154
+ * organisation (`readOwnEntry`). Then one PUT sends the contract's five fields: the changed ones,
155
+ * times as UTC instants, and the rest exactly as stored. When it gives a time, a start after the
156
+ * end, the stored one included, is a TypeError, with nothing written. The answer is held to the
157
+ * entry, its workspace and your organisation.
158
+ */
159
+ export async function updateLog(seam, send, request) {
160
+ const refused = unsent(request, ['log_id', 'description', 'start_date', 'end_date']);
161
+ if (refused !== null)
162
+ return refused;
163
+ const logId = idOf('update', 'log_id', request.log_id);
164
+ if (request.description === undefined && request.start_date === undefined && request.end_date === undefined) {
165
+ throw new TypeError('log.update: give at least one of description, start_date and end_date');
166
+ }
167
+ const description = request.description === undefined ? undefined : wordsOf('update', request.description);
168
+ const start = request.start_date === undefined ? undefined : timeOf('update', 'start_date', request.start_date);
169
+ const end = request.end_date === undefined ? undefined : timeOf('update', 'end_date', request.end_date);
170
+ if (start !== undefined && end !== undefined)
171
+ inOrder('update', start, end);
172
+ const stored = await readOwnEntry(seam, send, logId, zStored);
173
+ if (!stored.ok)
174
+ return stored;
175
+ const was = stored.data;
176
+ // The range is checked only when the update gives a time: pulse-admin checks no order, so a stored
177
+ // range may already be reversed, and words alone send it back as it was. Both stored times are
178
+ // real ones, so these reads succeed; they only put the two in one form.
179
+ if (start !== undefined || end !== undefined)
180
+ inOrder('update', start ?? timeOf('update', 'start_date', was.start_date), end ?? timeOf('update', 'end_date', was.end_date));
181
+ const entry = {
182
+ description: description ?? was.description,
183
+ start_date: start ?? was.start_date,
184
+ end_date: end ?? was.end_date,
185
+ organization_id: was.organization_id,
186
+ workspace_id: was.workspace_id,
187
+ };
188
+ const spec = seam.updateLogEntry(was.id, entry, zWritten);
189
+ if (spec === null)
190
+ return refusedPath;
191
+ return checked(await send(spec), { id: was.id, workspace_id: was.workspace_id, organization_id: was.organization_id });
192
+ }
193
+ /**
194
+ * `flipstream.log.remove()`: an entry removed (#219), directly, not handed off: D542's hand-offs
195
+ * are workspaces, datasets and members. A key it doesn't send is `refused`. The entry is read first,
196
+ * beside your organisation (`readOwnEntry`), then one DELETE; its answer holds nothing, so an ok is
197
+ * `null`.
198
+ */
199
+ export async function removeLog(seam, send, request) {
200
+ const refused = unsent(request, ['log_id']);
201
+ if (refused !== null)
202
+ return refused;
203
+ const logId = idOf('remove', 'log_id', request.log_id);
204
+ const stored = await readOwnEntry(seam, send, logId, zStored);
205
+ if (!stored.ok)
206
+ return stored;
207
+ const spec = seam.removeLogEntry(stored.data.id, z.looseObject({}));
208
+ if (spec === null)
209
+ return refusedPath;
210
+ const removed = await send(spec);
211
+ return removed.ok ? { ok: true, data: null } : removed;
212
+ }
213
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/api/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAmDlD,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAE5B,MAAM,WAAW,GAAqB,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAA;AAC/F,MAAM,OAAO,GAAG,CAAC,MAAc,EAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAA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EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,eAAe,EAAE,GAAG,CAAC,eAAe,EAAE,CAAC,CAAA;AACxH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAa,EAAE,IAAU,EAAE,OAAoC;IAC7F,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC3C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,OAAO,CAAA;IACpC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACtD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;IAC7D,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAA;IAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;IACnE,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,WAAW,CAAA;IACrC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA;IAChC,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;AACxD,CAAC"}
@@ -0,0 +1,58 @@
1
+ import type { CallSpec } from '../core/call.js';
2
+ import type { ApiResult } from '../core/result.js';
3
+ import type { Backend } from './backend.js';
4
+ import { type Member } from './members.js';
5
+ /** Who you are (#67): your organisation, and you in it. */
6
+ export interface Me {
7
+ readonly organization: Organization;
8
+ readonly user: Member;
9
+ }
10
+ /** An organisation. */
11
+ export interface Organization {
12
+ readonly id: string;
13
+ readonly name: string;
14
+ /** Its short name, as the console's addresses spell it. */
15
+ readonly slug: string;
16
+ /** Whether it may use Flipstream: in trial, active, expired, or unknown, never read as active (#292). */
17
+ readonly access: OrganizationAccess;
18
+ }
19
+ /**
20
+ * Whether an organisation may use Flipstream, read from its billing settings by the console's rules
21
+ * (#292), in the backend's own words. The status is the truth: a trial past its last day is still
22
+ * `trial` until the backend says otherwise, and the SDK never reads the clock for it. Every role
23
+ * reads the same, a viewer limited to some workspaces and Flipstream's own staff included.
24
+ */
25
+ export type OrganizationAccess =
26
+ /**
27
+ * `trial_ends_on` is the trial's last day, `YYYY-MM-DD` (the backend's `trial_end_date`), or
28
+ * `null` when the settings hold none that is a real day.
29
+ */
30
+ {
31
+ readonly status: 'trial';
32
+ readonly trial_ends_on: string | null;
33
+ } | {
34
+ readonly status: 'active';
35
+ }
36
+ /**
37
+ * The backend's `expired`. It doesn't say why: today it only ever follows a trial, but nothing
38
+ * promises that. `trial_ends_on` is the trial's end, as on `trial`, not necessarily the day
39
+ * access ended.
40
+ */
41
+ | {
42
+ readonly status: 'expired';
43
+ readonly trial_ends_on: string | null;
44
+ }
45
+ /** Settings that can't be read, or a status this version doesn't know: never read as active. */
46
+ | {
47
+ readonly status: 'unknown';
48
+ };
49
+ /**
50
+ * One call through the client, under what is left of the call's deadline, and its signal: each
51
+ * read, and `workspaces.create()`'s one write.
52
+ */
53
+ export type Read = <T>(spec: CallSpec<T>) => Promise<ApiResult<T>>;
54
+ /**
55
+ * `flipstream.me()`: the organisation, read beside userinfo, and then the person userinfo names.
56
+ * The first failure, in that order whatever finishes first, is the answer.
57
+ */
58
+ export declare function readMe(seam: Backend, read: Read): Promise<ApiResult<Me>>;
package/dist/api/me.js ADDED
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod';
2
+ import { parseJson } from '../core/body.js';
3
+ import { zMember } from './members.js';
4
+ const id = z.string().min(1);
5
+ // pulse-admin keeps billing in the organisation's `settings`, a JSON string
6
+ // (domain/organization/commands/add.py at dff6bf9b). These two keys are read, each only as a
7
+ // string, as the console's `accessFrom` reads them (os whoami.ts): settings that don't parse, aren't
8
+ // an object, or hold either key as anything but a string are unknown, and so is a status that isn't
9
+ // one of SubscriptionStatus's names.
10
+ const zBilling = z.object({ subscription_status: z.string().optional(), trial_end_date: z.string().optional() });
11
+ const zDay = z.iso.date();
12
+ /** The organisation's access from its `settings`, whatever was answered there (#292). */
13
+ function accessOf(settings) {
14
+ const json = typeof settings === 'string' ? parseJson(settings) : null;
15
+ const billing = json?.ok === true ? zBilling.safeParse(json.value) : null;
16
+ if (billing?.success !== true)
17
+ return { status: 'unknown' };
18
+ const { subscription_status: status, trial_end_date: last } = billing.data;
19
+ // A day that isn't a real `YYYY-MM-DD` is no day, as the console's isDay has it; the status stands.
20
+ const trial_ends_on = last !== undefined && zDay.safeParse(last).success ? last : null;
21
+ switch (status) {
22
+ case 'trial':
23
+ return { status: 'trial', trial_ends_on };
24
+ case 'active':
25
+ return { status: 'active' };
26
+ case 'expired':
27
+ return { status: 'expired', trial_ends_on };
28
+ default:
29
+ return { status: 'unknown' };
30
+ }
31
+ }
32
+ // Each answer, in our names. An object schema keeps only the fields it names, so anything else the
33
+ // backend sends (`account_id`, `database`, `scope_roles`) never reaches a caller, and `settings`
34
+ // only as the access read from it.
35
+ const zOrganization = z
36
+ .object({ id, name: z.string(), slug: z.string(), settings: z.unknown().optional() })
37
+ .transform(({ settings, ...organization }) => ({ ...organization, access: accessOf(settings) }));
38
+ const zUserinfo = z.object({ sub: id });
39
+ const invalid = (issues) => ({ ok: false, error: { kind: 'invalid', issues } });
40
+ /**
41
+ * `flipstream.me()`: the organisation, read beside userinfo, and then the person userinfo names.
42
+ * The first failure, in that order whatever finishes first, is the answer.
43
+ */
44
+ export async function readMe(seam, read) {
45
+ const [organization, user] = await Promise.all([read(seam.myOrganization(zOrganization)), readUser(seam, read)]);
46
+ if (!organization.ok)
47
+ return organization;
48
+ if (!user.ok)
49
+ return user;
50
+ return { ok: true, data: { organization: organization.data, user: user.data } };
51
+ }
52
+ async function readUser(seam, read) {
53
+ const info = await read(seam.userinfo(zUserinfo));
54
+ if (!info.ok)
55
+ return info;
56
+ const { sub } = info.data;
57
+ const spec = seam.user(sub, zMember);
58
+ if (spec === null)
59
+ return invalid("userinfo's sub can't name a user");
60
+ const user = await read(spec);
61
+ // A person other than the one the token names is someone else's account, never yours.
62
+ return user.ok && user.data.id !== sub ? invalid("the user read isn't the one userinfo names") : user;
63
+ }
64
+ //# sourceMappingURL=me.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"me.js","sourceRoot":"","sources":["../../src/api/me.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,OAAO,EAAE,OAAO,EAAe,MAAM,cAAc,CAAA;AAwCnD,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAE5B,4EAA4E;AAC5E,6FAA6F;AAC7F,qGAAqG;AACrG,oGAAoG;AACpG,qCAAqC;AACrC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AAChH,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;AAEzB,yFAAyF;AACzF,SAAS,QAAQ,CAAC,QAAiB;IACjC,MAAM,IAAI,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACtE,MAAM,OAAO,GAAG,IAAI,EAAE,EAAE,KAAK,IAAI,CAAC,CA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AAI,CAAC,IAAI,CAAC,CAAA;IAC7B,sFAAsF;IACtF,OAAO,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACvG,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { z } from 'zod';
2
+ import { type Role } from '../core/names.js';
3
+ import type { ApiResult } from '../core/result.js';
4
+ import type { Backend } from './backend.js';
5
+ import type { Read } from './me.js';
6
+ import type { Page, PageRequest } from './page.js';
7
+ /** A person in an organisation. */
8
+ export interface Member {
9
+ readonly id: string;
10
+ readonly email: string;
11
+ readonly first_name: string;
12
+ readonly last_name: string;
13
+ /**
14
+ * Their role in the organisation: the highest they hold. Null when they hold none of ours, and
15
+ * for Flipstream's staff whatever else they hold, since a swap token's organisation isn't theirs
16
+ * (D544).
17
+ */
18
+ readonly role: Role | null;
19
+ /** Whether their account is switched on. */
20
+ readonly active: boolean;
21
+ /**
22
+ * The workspaces their account names, as pulse-auth lists them. For a person whose only role is
23
+ * viewer, they're the workspaces the viewer may open; a viewer with none opens every workspace of
24
+ * the organisation. No other role is limited by them. (pulse-auth mints the token's clients from
25
+ * them, at 0ae57c8, and pulse-admin limits only a viewer, and only by a list that isn't empty, at
26
+ * dff6bf9b.)
27
+ */
28
+ readonly workspace_ids: readonly string[];
29
+ }
30
+ /** A person, as `flipstream.me()` answers its user: pulse-auth's user, in our names. */
31
+ export declare const zMember: z.ZodType<Member>;
32
+ /**
33
+ * `flipstream.members.list()`: one page of your organisation's people, not keys, in pulse-auth's
34
+ * own order, by email (no sort is sent, D550). pulse-auth leaves keys out itself; one it sends all
35
+ * the same makes the page invalid, naming its place, as does a person of another organisation,
36
+ * never with an id. The organisation's failure, then the list's, is the answer, whichever finishes
37
+ * first. A bad limit or offset throws, as every list's does.
38
+ */
39
+ export declare function listMembers(seam: Backend, read: Read, page: PageRequest): Promise<ApiResult<Page<Member>>>;
40
+ /**
41
+ * `flipstream.members.get()`: one of your organisation's people, by their id. An answer that isn't
42
+ * the person asked for, or is another organisation's, is invalid, echoing no id; an API user's is
43
+ * `not_found`, as an id nobody has, whatever else its record holds. Only then is the person read.
44
+ * The organisation's failure, then the person's, is the answer.
45
+ */
46
+ export declare function getMember(seam: Backend, read: Read, request: {
47
+ readonly member_id: string;
48
+ }): Promise<ApiResult<Member>>;
@@ -0,0 +1,102 @@
1
+ import { z } from 'zod';
2
+ import { RANKED, roleFromBackend } from '../core/names.js';
3
+ import { sameUuid } from './ids.js';
4
+ const id = z.string().min(1);
5
+ /**
6
+ * pulse-auth's roles, read as one of ours: the highest one held, or null for none, and null for
7
+ * staff whatever else they hold (D544). A role the SDK doesn't know is none of ours, never an
8
+ * error, and its name is never kept (#265): a known role beside it still wins. So the staff rule
9
+ * covers the staff roles this version knows, godmode and swapper, which are pulse-auth's own
10
+ * (GODMODE_ONLY_ROLES, at 0ae57c8).
11
+ */
12
+ const zRole = z
13
+ .array(z.string())
14
+ .nullable()
15
+ .transform((names) => {
16
+ const held = new Set();
17
+ let staff = false;
18
+ for (const name of names ?? []) {
19
+ const read = roleFromBackend(name);
20
+ if (read.kind === 'role')
21
+ held.add(read.role);
22
+ if (read.kind === 'staff')
23
+ staff = true;
24
+ }
25
+ return staff ? null : (RANKED.find((role) => held.has(role)) ?? null);
26
+ });
27
+ // A person's fields as pulse-auth answers them. An object schema keeps only the fields it names, so
28
+ // `account_id`, `scope_roles`, `idp_uid`, `meta` and the backend's `roles` never reach a caller.
29
+ const PERSON = {
30
+ id,
31
+ email: z.string(),
32
+ first_name: z.string(),
33
+ last_name: z.string(),
34
+ roles: zRole,
35
+ active: z.boolean(),
36
+ workspace_ids: z.array(z.string()).nullable(),
37
+ };
38
+ /** A person in our names: one role, and no workspaces read as none. */
39
+ function inOurs({ roles, workspace_ids, ...person }) {
40
+ return { ...person, role: roles, workspace_ids: workspace_ids ?? [] };
41
+ }
42
+ /** A person, as `flipstream.me()` answers its user: pulse-auth's user, in our names. */
43
+ export const zMember = z.object(PERSON).transform(inOurs);
44
+ // A member as read, with the organisation they're in, so a person of another one is caught, and
45
+ // whether they're an API user, a key, which is never a member; the public Member drops both.
46
+ const zRecord = z.object({ ...PERSON, organization_id: z.string(), is_api_user: z.boolean() }).transform(inOurs);
47
+ const zOrganizationId = z.object({ id });
48
+ // What get reads first of the record pulse-auth answers: whose it is, and whether it's a key. The
49
+ // rest is kept, unread, for the person schema, which only a person meets: so a key answers
50
+ // not_found whatever else it holds, and its id says nothing more than an id nobody has.
51
+ const zWho = z.looseObject({ id, organization_id: z.string(), is_api_user: z.boolean() });
52
+ const publicOf = ({ id: memberId, email, first_name, last_name, role, active, workspace_ids }) => ({ id: memberId, email, first_name, last_name, role, active, workspace_ids });
53
+ const invalid = (issues) => ({ ok: false, error: { kind: 'invalid', issues } });
54
+ // A key's id is answered exactly as pulse-auth answers an id nobody has, so it says nothing more.
55
+ const noSuchMember = { ok: false, error: { kind: 'not_found', status: 404, code: 'USER_NOT_FOUND', message: 'User not found!' } };
56
+ /**
57
+ * `flipstream.members.list()`: one page of your organisation's people, not keys, in pulse-auth's
58
+ * own order, by email (no sort is sent, D550). pulse-auth leaves keys out itself; one it sends all
59
+ * the same makes the page invalid, naming its place, as does a person of another organisation,
60
+ * never with an id. The organisation's failure, then the list's, is the answer, whichever finishes
61
+ * first. A bad limit or offset throws, as every list's does.
62
+ */
63
+ export async function listMembers(seam, read, page) {
64
+ const spec = seam.people(page, zRecord, () => true);
65
+ const [organization, listed] = await Promise.all([read(seam.myOrganization(zOrganizationId)), read(spec)]);
66
+ if (!organization.ok)
67
+ return organization;
68
+ if (!listed.ok)
69
+ return listed;
70
+ const foreign = listed.data.items.findIndex((member) => !sameUuid(member.organization_id, organization.data.id));
71
+ if (foreign !== -1)
72
+ return invalid(`records[${String(foreign)}] is another organisation's member`);
73
+ const key = listed.data.items.findIndex((member) => member.is_api_user);
74
+ if (key !== -1)
75
+ return invalid(`records[${String(key)}] is an API user, not a person`);
76
+ return { ok: true, data: { ...listed.data, items: listed.data.items.map(publicOf) } };
77
+ }
78
+ /**
79
+ * `flipstream.members.get()`: one of your organisation's people, by their id. An answer that isn't
80
+ * the person asked for, or is another organisation's, is invalid, echoing no id; an API user's is
81
+ * `not_found`, as an id nobody has, whatever else its record holds. Only then is the person read.
82
+ * The organisation's failure, then the person's, is the answer.
83
+ */
84
+ export async function getMember(seam, read, request) {
85
+ const spec = seam.user(request.member_id, zWho);
86
+ if (spec === null)
87
+ return { ok: false, error: { kind: 'refused', reason: 'path' } };
88
+ const [organization, who] = await Promise.all([read(seam.myOrganization(zOrganizationId)), read(spec)]);
89
+ if (!organization.ok)
90
+ return organization;
91
+ if (!who.ok)
92
+ return who;
93
+ if (!sameUuid(who.data.id, request.member_id))
94
+ return invalid("the member read isn't the one asked for");
95
+ if (!sameUuid(who.data.organization_id, organization.data.id))
96
+ return invalid("the member read is another organisation's");
97
+ if (who.data.is_api_user)
98
+ return noSuchMember;
99
+ const person = zRecord.safeParse(who.data);
100
+ return person.success ? { ok: true, data: publicOf(person.data) } : invalid(z.prettifyError(person.error));
101
+ }
102
+ //# sourceMappingURL=members.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"members.js","sourceRoot":"","sources":["../../src/api/members.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,MAAM,EAAE,eAAe,EAAa,MAAM,kBAAkB,CAAA;AAGrE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAqCnC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAE5B;;;;;;GAMG;AACH,MAAM,KAAK,GAAG,CAAC;KACZ,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KACjB,QAAQ,EAAE;KACV,SAAS,CAAC,CAAC,KAAK,EAAe,E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AC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AAC5G,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ApiResult } from '../core/result.js';
2
+ import type { Backend } from './backend.js';
3
+ import type { Read } from './me.js';
4
+ /**
5
+ * `flipstream.organization.rename()`: a D542 hand-off (item 1), as `workspaces.rename` is. It reads
6
+ * `/organizations/me` alone, for the short name, and its failure is the answer. Then
7
+ * `needs_person`, never a write (the SDK never sends `PUT /organizations/{id}`, a full replace that
8
+ * also carries `settings`, B10), with the organisation's settings page where a console can be
9
+ * named. The name the caller gave is never echoed.
10
+ */
11
+ export declare function handOffOrganizationRename(seam: Backend, read: Read): Promise<ApiResult<never>>;