@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,182 @@
1
+ import { z } from 'zod';
2
+ import type { CallSpec } from '../core/call.js';
3
+ import { type Concept } from '../core/names.js';
4
+ import type { ApiRequest } from '../core/transport.js';
5
+ import { type Page, type PageRequest } from './page.js';
6
+ /**
7
+ * The seam's hosts, each a base URL with no trailing slash. `console` is never called: it's the base
8
+ * of the addresses a hand-off gives a person (D542), or undefined when no console can be named.
9
+ */
10
+ export interface BackendHosts {
11
+ readonly admin: string;
12
+ readonly auth: string;
13
+ readonly console: string | undefined;
14
+ readonly wallet: string;
15
+ }
16
+ /**
17
+ * The console a hand-off's address uses, or none: the caller's own `hosts.console` always; otherwise
18
+ * Flipstream's own, but only once it's `live` and only beside Flipstream's own admin host
19
+ * (`adminIsDefault`). A client pointed at a staging or local admin host would otherwise hand out
20
+ * production console addresses carrying that host's short names and ids. So it fails closed: no
21
+ * address.
22
+ */
23
+ export declare function consoleBase(configured: string | undefined, adminIsDefault: boolean, live?: boolean): string | undefined;
24
+ type Call = Pick<ApiRequest, 'service' | 'endpoint'>;
25
+ /** The fields pulse-admin's log entry contract requires, in our names: what an add or an update sends. */
26
+ export interface LogContract {
27
+ readonly description: string;
28
+ readonly start_date: string;
29
+ readonly end_date: string;
30
+ readonly organization_id: string;
31
+ readonly workspace_id: string;
32
+ }
33
+ /**
34
+ * A GET of the list at `path` on `base`, for `call`: one page, as `page` asks (`pageQuery`'s
35
+ * rules, so a bad limit or offset throws here, with nothing sent), with `query`'s fixed values
36
+ * beside it. Each record comes back in our names of `concepts`, is read by `item`, and must be
37
+ * `inScope`, or the answer is invalid.
38
+ */
39
+ export declare function getList<T>(base: string, call: Call, path: string, page: PageRequest, concepts: readonly Concept[], item: z.ZodType<T>, inScope: (item: T) => boolean, query?: Readonly<Record<string, string>>): CallSpec<Page<T>>;
40
+ /** Every operation on today's backends, each given the schema its answer is read with. */
41
+ export declare function backend(hosts: BackendHosts): {
42
+ /**
43
+ * `GET /organizations/me`: the one organisation the token's account speaks for (pulse-admin's
44
+ * `MeQuery`). It answers 400 for a token with no account, 404 when the organisation was merged
45
+ * away, and 409 when the account has two.
46
+ */
47
+ myOrganization: <T>(schema: z.ZodType<T>) => CallSpec<T>;
48
+ /**
49
+ * `GET /oauth/userinfo` (OIDC): pulse-auth verifies the token and names its subject, `sub`, which
50
+ * for a person's token is their user id (pulse-auth 0ae57c8, `userinfo`). The SDK never reads
51
+ * the token itself, since only the transport holds it. The spec declares no security, but the
52
+ * route needs the bearer token.
53
+ */
54
+ userinfo: <T>(schema: z.ZodType<T>) => CallSpec<T>;
55
+ /**
56
+ * `GET /organizations/{id}/clients`: one page of an organisation's workspaces, pulse-admin's
57
+ * clients. Never the global `GET /clients`, which lists every organisation's for a staff token.
58
+ * Null when `organizationId` can't stay one path segment.
59
+ */
60
+ workspacesOf<T>(organizationId: string, page: PageRequest, item: z.ZodType<T>, inScope: (item: T) => boolean): CallSpec<Page<T>> | null;
61
+ /**
62
+ * The console's page for a workspace's settings (os M56): `/<organisation>/<workspace id>/settings`,
63
+ * by the organisation's short name and the workspace's full id, which the console rewrites to
64
+ * its written address (os D251). Undefined when no console can be named.
65
+ */
66
+ workspaceSettings: (organizationSlug: string, workspaceId: string) => string | undefined;
67
+ /**
68
+ * The console's page for your organisation's settings (os M56): `/<organisation>/o/settings`, by
69
+ * its short name. Undefined when no console can be named.
70
+ */
71
+ organizationSettings: (organizationSlug: string) => string | undefined;
72
+ /**
73
+ * The console's page for a dataset (os D1334): `/<organisation>/<workspace id>/warehouse/datasets/<dataset id>`,
74
+ * by the full ids, which the console rewrites to its short ones. Undefined when no console can be
75
+ * named.
76
+ */
77
+ datasetPage: (organizationSlug: string, workspaceId: string, datasetId: string) => string | undefined;
78
+ /**
79
+ * `POST /clients`: a new workspace, pulse-admin's client, in `organizationId`, sending `name` and
80
+ * nothing else (the console's D368), so pulse-admin keeps its own defaults and makes the short
81
+ * name from the name, unique within the organisation. The seam's first write (D541's phase 2),
82
+ * never tried again. pulse-admin answers 201 with the client it made.
83
+ */
84
+ createWorkspace: <T>(organizationId: string, name: string, schema: z.ZodType<T>) => CallSpec<T>;
85
+ /** `GET /clients/{id}`: one workspace, pulse-admin's client. Null when `id` can't stay one path segment. */
86
+ workspace<T>(id: string, schema: z.ZodType<T>): CallSpec<T> | null;
87
+ /**
88
+ * `GET /wallets/get-balance/{organisation}`: the organisation's wallet as a list of rows, one per
89
+ * wallet, `[{ wallet_id, balance_micro }]`. The wallet's id is the organisation's, by
90
+ * convention. pulse-wallet answers the caller's own wallet for another organisation's id (#244's
91
+ * recording), so the reader holds each row to the organisation it read. Null when
92
+ * `organizationId` can't stay one path segment.
93
+ */
94
+ balanceOf<T>(organizationId: string, row: z.ZodType<T>): CallSpec<T[]> | null;
95
+ /**
96
+ * `GET /wallets/get-transactions/{organisation}`: the organisation's whole ledger in one list,
97
+ * with no paging. Each row's `connection_id` comes back as `dataset_id`. Null when
98
+ * `organizationId` can't stay one path segment.
99
+ */
100
+ ledgerOf<T>(organizationId: string, row: z.ZodType<T>): CallSpec<T[]> | null;
101
+ /**
102
+ * `GET /users`: one page of the people the token may see, pulse-auth's users, the console's
103
+ * source. Admin's `GET /organizations/{id}/users` is a mirror that #226's recording answered with
104
+ * one person of four, and with no paging. People only, never keys: an API user is a service
105
+ * account, which the console never lists or counts (os #100 step 4), so pulse-auth filters them
106
+ * out itself, with its own DSL (`filter`, at pulse-auth 0ae57c8), and `count` counts people. A
107
+ * malformed filter is pulse-auth's 400, never an unfiltered page. No `sort` or `q` is sent
108
+ * (D550), so the order is pulse-auth's UserRepository's own, `email` (its `order_by`).
109
+ */
110
+ people: <T>(page: PageRequest, item: z.ZodType<T>, inScope: (item: T) => boolean) => CallSpec<Page<T>>;
111
+ /** `GET /users/{id}`: a person, as pulse-auth has them. Null when `id` can't stay one path segment. */
112
+ user<T>(id: string, schema: z.ZodType<T>): CallSpec<T> | null;
113
+ /**
114
+ * `GET /clients/{id}/event-logs`: one page of a workspace's logbook. No `sort` is sent (D550),
115
+ * so the order is pulse-admin's EventLogRepository's own, `-created_on`, newest first (its
116
+ * `order_by`, at 72ec7efe). Null when `workspaceId` can't stay one path segment.
117
+ */
118
+ workspaceLog<T>(workspaceId: string, page: PageRequest, item: z.ZodType<T>, inScope: (item: T) => boolean): CallSpec<Page<T>> | null;
119
+ /**
120
+ * `GET /clients/{id}/connections`: one page of a workspace's datasets, pulse-admin's connections.
121
+ * Never the global `GET /connections`, which ignores a workspace filter. No `sort` is sent
122
+ * (D550), so the order is pulse-admin's ConnectionRepository's own, `name` (its `order_by`, at
123
+ * 72ec7efe), with no tiebreaker. Null when `workspaceId` can't stay one path segment.
124
+ */
125
+ workspaceDatasets<T>(workspaceId: string, page: PageRequest, item: z.ZodType<T>, inScope: (item: T) => boolean): CallSpec<Page<T>> | null;
126
+ /**
127
+ * `GET /connections/{id}`: one dataset, pulse-admin's connection. Its `refresh`, a read past
128
+ * pulse-admin's cache, isn't sent. Its answer embeds the dataset's sign-in, so no body's text is
129
+ * kept (#279). Null when `id` can't stay one path segment.
130
+ */
131
+ dataset<T>(id: string, schema: z.ZodType<T>): CallSpec<T> | null;
132
+ /**
133
+ * `GET /connections/{id}?refresh=true`: one dataset, read past pulse-admin's cache, before and
134
+ * after a pause or a resume (#212). It keeps no body's text, as `dataset` doesn't (#279). Null when
135
+ * `id` can't stay one path segment.
136
+ */
137
+ freshDataset<T>(id: string, schema: z.ZodType<T>): CallSpec<T> | null;
138
+ /**
139
+ * `PUT /connections/{id}` with `{ active }` alone (#212, os D313). pulse-admin's PUT takes
140
+ * UpdateConnectionContract, every field optional, and writes only the fields sent: it sets
141
+ * `model_fields_set` on a fresh read of the connection (pulse-admin 72ec7efe and dff6bf9b, since
142
+ * 51a0b205). Admin spec 0.0.126 is stale there: it still names ConnectionContract, which
143
+ * requires `name` and `client_id`. Sending only `active` never overwrites a rename or a move
144
+ * made since the read. Never pulse-admin's toggle route, which flips the current value, so a
145
+ * pause sent twice would resume (#212's step 5 greps for it). Never tried again. Null when `id`
146
+ * can't stay one path segment.
147
+ */
148
+ setDatasetActive<T>(id: string, active: boolean, schema: z.ZodType<T>): CallSpec<T> | null;
149
+ /**
150
+ * `GET /organizations/{id}/secrets`: one page of the organisation's provider sign-ins (#70),
151
+ * credentials in our names. No `sort` is sent (D550). pulse-admin doesn't mask a sign-in
152
+ * (`Secret.secret_fields` is empty at dff6bf9b), so `item` is what keeps a value out. Null when
153
+ * `organizationId` can't stay one path segment.
154
+ */
155
+ organizationCredentials<T>(organizationId: string, page: PageRequest, item: z.ZodType<T>, inScope: (item: T) => boolean): CallSpec<Page<T>> | null;
156
+ /**
157
+ * `GET /secrets/{id}`: one sign-in, read before a hand-off (#70). The SDK has no call for its
158
+ * value, its download, its revoke or its delete. Null when `id` can't stay one path segment.
159
+ */
160
+ credential<T>(id: string, schema: z.ZodType<T>): CallSpec<T> | null;
161
+ /** `GET /event-logs/{id}`: one logbook entry. Null when `id` can't stay one path segment. */
162
+ logEntry<T>(id: string, schema: z.ZodType<T>): CallSpec<T> | null;
163
+ /**
164
+ * `POST /event-logs`: a new logbook entry, with the five fields pulse-admin's contract requires
165
+ * (CreateEventLogContract, admin 0.0.126) and nothing else; `workspace_id` goes as `client_id`.
166
+ * Never tried again. pulse-admin answers 201 with the entry it made.
167
+ */
168
+ addLogEntry: <T>(entry: LogContract, schema: z.ZodType<T>) => CallSpec<T>;
169
+ /**
170
+ * `PUT /event-logs/{id}`: the entry, replaced whole by the same five fields (EventLogContract,
171
+ * all required). Never tried again. Null when `id` can't stay one path segment.
172
+ */
173
+ updateLogEntry<T>(id: string, entry: LogContract, schema: z.ZodType<T>): CallSpec<T> | null;
174
+ /**
175
+ * `DELETE /event-logs/{id}`: the entry, removed. A log entry's remove is direct: D542's hand-offs
176
+ * are workspaces, datasets and members. Never tried again. Null when `id` can't stay one path
177
+ * segment.
178
+ */
179
+ removeLogEntry<T>(id: string, schema: z.ZodType<T>): CallSpec<T> | null;
180
+ };
181
+ export type Backend = ReturnType<typeof backend>;
182
+ export {};
@@ -0,0 +1,314 @@
1
+ import { z } from 'zod';
2
+ import { fromBackend, toBackend } from '../core/names.js';
3
+ import { segment } from '../query/catalog.js';
4
+ import { pageOf, pageQuery } from './page.js';
5
+ /**
6
+ * Whether the console is live (os-sdk2). Its base, below, is the planned production console, but it
7
+ * isn't deployed yet, so no hand-off names it until the lead turns this on, once the os lead says
8
+ * the console is live and confirms its routes. Typed wide, so turning it on is this one change in
9
+ * the code; the test of #210's step 2b (no url with the flag off) then changes its answer, by
10
+ * design.
11
+ */
12
+ const CONSOLE_LIVE = false;
13
+ const CONSOLE = 'https://cloud.flipstream.io';
14
+ /**
15
+ * The console a hand-off's address uses, or none: the caller's own `hosts.console` always; otherwise
16
+ * Flipstream's own, but only once it's `live` and only beside Flipstream's own admin host
17
+ * (`adminIsDefault`). A client pointed at a staging or local admin host would otherwise hand out
18
+ * production console addresses carrying that host's short names and ids. So it fails closed: no
19
+ * address.
20
+ */
21
+ export function consoleBase(configured, adminIsDefault, live = CONSOLE_LIVE) {
22
+ if (configured !== undefined)
23
+ return configured;
24
+ return live && adminIsDefault ? CONSOLE : undefined;
25
+ }
26
+ /**
27
+ * The console's address of the page made of `parts`, each one path segment, or undefined when no
28
+ * console can be named, or a part can't stay one segment (an organisation with no short name).
29
+ */
30
+ function consoleUrl(base, parts) {
31
+ if (base === undefined)
32
+ return undefined;
33
+ const segments = parts.map(segment);
34
+ return segments.every((part) => part !== null) ? `${base}/${segments.join('/')}` : undefined;
35
+ }
36
+ const READ = { effect: 'read', deadlineMs: 30_000, retry: 'read' };
37
+ // A write is never tried again: an answer that didn't arrive may still have been acted on (#15).
38
+ const WRITE = { effect: 'write', deadlineMs: 30_000, retry: 'never' };
39
+ /**
40
+ * `schema`, written in our names, read after the answer's record has been given ours. A record
41
+ * holding both names of one pair is outside the contract; what isn't a record is left for `schema`
42
+ * to refuse.
43
+ */
44
+ function inOurNames(call, concepts, schema) {
45
+ if (concepts.length === 0)
46
+ return schema;
47
+ return z.preprocess((answer, context) => {
48
+ if (typeof answer !== 'object' || answer === null || Array.isArray(answer))
49
+ return answer;
50
+ const ours = fromBackend(call, concepts, answer);
51
+ if (ours !== null)
52
+ return ours;
53
+ context.addIssue({ code: 'custom', message: "the answer names one field twice, by our name and the backend's" });
54
+ return z.NEVER;
55
+ }, schema);
56
+ }
57
+ /** A GET of `path` on `base`, for `call`, whose one record comes back in our names of `concepts`. */
58
+ function get(base, call, path, concepts, schema) {
59
+ return {
60
+ ...READ,
61
+ ...call,
62
+ makeRequest: () => new Request(`${base}${path}`, { headers: { accept: 'application/json' } }),
63
+ schema: inOurNames(call, concepts, schema),
64
+ };
65
+ }
66
+ /**
67
+ * A GET of `path` on `base`, for `call`, whose answer is a bare list, all of it in one answer:
68
+ * each row comes back in our names of `concepts` and is read by `row`.
69
+ */
70
+ function getRows(base, call, path, concepts, row) {
71
+ return {
72
+ ...READ,
73
+ ...call,
74
+ makeRequest: () => new Request(`${base}${path}`, { headers: { accept: 'application/json' } }),
75
+ schema: z.array(inOurNames(call, concepts, row)),
76
+ };
77
+ }
78
+ /** A write's JSON body: `record` in the backend's names of `concepts`, with its headers. */
79
+ const jsonOf = (call, concepts, record) => ({
80
+ headers: { accept: 'application/json', 'content-type': 'application/json' },
81
+ body: JSON.stringify(toBackend(call, concepts, record)),
82
+ });
83
+ /**
84
+ * A POST of `record` as JSON to `path` on `base`, for `call`: the record goes out in the backend's
85
+ * names of `concepts`, and the answer's one record comes back in ours. Built inside the transport's
86
+ * attempt, so a resend after a 401 sends a fresh body. Each write's method is named once, in its
87
+ * own helper, here (#210's step 6 counts the helpers' calls against the writes listed).
88
+ */
89
+ function post(base, call, path, concepts, record, schema) {
90
+ return { ...WRITE, ...call, makeRequest: () => new Request(`${base}${path}`, { method: 'POST', ...jsonOf(call, concepts, record) }), schema: inOurNames(call, concepts, schema) };
91
+ }
92
+ /** A PUT of `record`, as `post` sends one: a write that replaces the record at `path` whole. */
93
+ function put(base, call, path, concepts, record, schema) {
94
+ return { ...WRITE, ...call, makeRequest: () => new Request(`${base}${path}`, { method: 'PUT', ...jsonOf(call, concepts, record) }), schema: inOurNames(call, concepts, schema) };
95
+ }
96
+ /** A DELETE of `path` on `base`, for `call`, with no body; its answer is read by `schema`. */
97
+ function del(base, call, path, schema) {
98
+ return { ...WRITE, ...call, makeRequest: () => new Request(`${base}${path}`, { method: 'DELETE', headers: { accept: 'application/json' } }), schema };
99
+ }
100
+ /**
101
+ * A GET of the list at `path` on `base`, for `call`: one page, as `page` asks (`pageQuery`'s
102
+ * rules, so a bad limit or offset throws here, with nothing sent), with `query`'s fixed values
103
+ * beside it. Each record comes back in our names of `concepts`, is read by `item`, and must be
104
+ * `inScope`, or the answer is invalid.
105
+ */
106
+ export function getList(base, call, path, page, concepts, item, inScope, query = {}) {
107
+ const sent = pageQuery(page);
108
+ const url = new URL(`${base}${path}`);
109
+ url.searchParams.set('limit', String(sent.limit));
110
+ url.searchParams.set('offset', String(sent.offset));
111
+ for (const [name, value] of Object.entries(query))
112
+ url.searchParams.set(name, value);
113
+ return {
114
+ ...READ,
115
+ ...call,
116
+ makeRequest: () => new Request(url, { headers: { accept: 'application/json' } }),
117
+ schema: pageOf(inOurNames(call, concepts, item), sent, inScope),
118
+ };
119
+ }
120
+ /** Every operation on today's backends, each given the schema its answer is read with. */
121
+ export function backend(hosts) {
122
+ return {
123
+ /**
124
+ * `GET /organizations/me`: the one organisation the token's account speaks for (pulse-admin's
125
+ * `MeQuery`). It answers 400 for a token with no account, 404 when the organisation was merged
126
+ * away, and 409 when the account has two.
127
+ */
128
+ myOrganization: (schema) => get(hosts.admin, { service: 'admin', endpoint: 'admin.organizations.me' }, '/organizations/me', ['workspace'], schema),
129
+ /**
130
+ * `GET /oauth/userinfo` (OIDC): pulse-auth verifies the token and names its subject, `sub`, which
131
+ * for a person's token is their user id (pulse-auth 0ae57c8, `userinfo`). The SDK never reads
132
+ * the token itself, since only the transport holds it. The spec declares no security, but the
133
+ * route needs the bearer token.
134
+ */
135
+ userinfo: (schema) => get(hosts.auth, { service: 'auth', endpoint: 'auth.userinfo' }, '/oauth/userinfo', [], schema),
136
+ /**
137
+ * `GET /organizations/{id}/clients`: one page of an organisation's workspaces, pulse-admin's
138
+ * clients. Never the global `GET /clients`, which lists every organisation's for a staff token.
139
+ * Null when `organizationId` can't stay one path segment.
140
+ */
141
+ workspacesOf(organizationId, page, item, inScope) {
142
+ const name = segment(organizationId);
143
+ return name === null ? null : getList(hosts.admin, { service: 'admin', endpoint: 'admin.organizations.clients' }, `/organizations/${name}/clients`, page, ['workspace'], item, inScope);
144
+ },
145
+ /**
146
+ * The console's page for a workspace's settings (os M56): `/<organisation>/<workspace id>/settings`,
147
+ * by the organisation's short name and the workspace's full id, which the console rewrites to
148
+ * its written address (os D251). Undefined when no console can be named.
149
+ */
150
+ workspaceSettings: (organizationSlug, workspaceId) => consoleUrl(hosts.console, [organizationSlug, workspaceId, 'settings']),
151
+ /**
152
+ * The console's page for your organisation's settings (os M56): `/<organisation>/o/settings`, by
153
+ * its short name. Undefined when no console can be named.
154
+ */
155
+ organizationSettings: (organizationSlug) => consoleUrl(hosts.console, [organizationSlug, 'o', 'settings']),
156
+ /**
157
+ * The console's page for a dataset (os D1334): `/<organisation>/<workspace id>/warehouse/datasets/<dataset id>`,
158
+ * by the full ids, which the console rewrites to its short ones. Undefined when no console can be
159
+ * named.
160
+ */
161
+ datasetPage: (organizationSlug, workspaceId, datasetId) => consoleUrl(hosts.console, [organizationSlug, workspaceId, 'warehouse', 'datasets', datasetId]),
162
+ /**
163
+ * `POST /clients`: a new workspace, pulse-admin's client, in `organizationId`, sending `name` and
164
+ * nothing else (the console's D368), so pulse-admin keeps its own defaults and makes the short
165
+ * name from the name, unique within the organisation. The seam's first write (D541's phase 2),
166
+ * never tried again. pulse-admin answers 201 with the client it made.
167
+ */
168
+ createWorkspace: (organizationId, name, schema) => post(hosts.admin, { service: 'admin', endpoint: 'admin.clients.create' }, '/clients', ['workspace'], { name, organization_id: organizationId }, schema),
169
+ /** `GET /clients/{id}`: one workspace, pulse-admin's client. Null when `id` can't stay one path segment. */
170
+ workspace(id, schema) {
171
+ const name = segment(id);
172
+ return name === null ? null : get(hosts.admin, { service: 'admin', endpoint: 'admin.clients.get' }, `/clients/${name}`, ['workspace'], schema);
173
+ },
174
+ /**
175
+ * `GET /wallets/get-balance/{organisation}`: the organisation's wallet as a list of rows, one per
176
+ * wallet, `[{ wallet_id, balance_micro }]`. The wallet's id is the organisation's, by
177
+ * convention. pulse-wallet answers the caller's own wallet for another organisation's id (#244's
178
+ * recording), so the reader holds each row to the organisation it read. Null when
179
+ * `organizationId` can't stay one path segment.
180
+ */
181
+ balanceOf(organizationId, row) {
182
+ const name = segment(organizationId);
183
+ return name === null ? null : getRows(hosts.wallet, { service: 'wallet', endpoint: 'wallet.balance' }, `/wallets/get-balance/${name}`, [], row);
184
+ },
185
+ /**
186
+ * `GET /wallets/get-transactions/{organisation}`: the organisation's whole ledger in one list,
187
+ * with no paging. Each row's `connection_id` comes back as `dataset_id`. Null when
188
+ * `organizationId` can't stay one path segment.
189
+ */
190
+ ledgerOf(organizationId, row) {
191
+ const name = segment(organizationId);
192
+ return name === null ? null : getRows(hosts.wallet, { service: 'wallet', endpoint: 'wallet.transactions' }, `/wallets/get-transactions/${name}`, ['dataset'], row);
193
+ },
194
+ /**
195
+ * `GET /users`: one page of the people the token may see, pulse-auth's users, the console's
196
+ * source. Admin's `GET /organizations/{id}/users` is a mirror that #226's recording answered with
197
+ * one person of four, and with no paging. People only, never keys: an API user is a service
198
+ * account, which the console never lists or counts (os #100 step 4), so pulse-auth filters them
199
+ * out itself, with its own DSL (`filter`, at pulse-auth 0ae57c8), and `count` counts people. A
200
+ * malformed filter is pulse-auth's 400, never an unfiltered page. No `sort` or `q` is sent
201
+ * (D550), so the order is pulse-auth's UserRepository's own, `email` (its `order_by`).
202
+ */
203
+ people: (page, item, inScope) => getList(hosts.auth, { service: 'auth', endpoint: 'auth.users.list' }, '/users', page, ['workspace'], item, inScope, { filter: 'is_api_user == False' }),
204
+ /** `GET /users/{id}`: a person, as pulse-auth has them. Null when `id` can't stay one path segment. */
205
+ user(id, schema) {
206
+ const name = segment(id);
207
+ return name === null ? null : get(hosts.auth, { service: 'auth', endpoint: 'auth.users.get' }, `/users/${name}`, ['workspace'], schema);
208
+ },
209
+ /**
210
+ * `GET /clients/{id}/event-logs`: one page of a workspace's logbook. No `sort` is sent (D550),
211
+ * so the order is pulse-admin's EventLogRepository's own, `-created_on`, newest first (its
212
+ * `order_by`, at 72ec7efe). Null when `workspaceId` can't stay one path segment.
213
+ */
214
+ workspaceLog(workspaceId, page, item, inScope) {
215
+ const name = segment(workspaceId);
216
+ return name === null ? null : getList(hosts.admin, { service: 'admin', endpoint: 'admin.clients.event-logs' }, `/clients/${name}/event-logs`, page, ['workspace'], item, inScope);
217
+ },
218
+ /**
219
+ * `GET /clients/{id}/connections`: one page of a workspace's datasets, pulse-admin's connections.
220
+ * Never the global `GET /connections`, which ignores a workspace filter. No `sort` is sent
221
+ * (D550), so the order is pulse-admin's ConnectionRepository's own, `name` (its `order_by`, at
222
+ * 72ec7efe), with no tiebreaker. Null when `workspaceId` can't stay one path segment.
223
+ */
224
+ workspaceDatasets(workspaceId, page, item, inScope) {
225
+ const name = segment(workspaceId);
226
+ // A connection embeds its sign-in (pulse-admin dff6bf9b, connection _enrich), so, as on the
227
+ // sign-in routes, no body's text is ever kept (#279). The allowlist keeps the rest out.
228
+ return name === null ? null : { ...getList(hosts.admin, { service: 'admin', endpoint: 'admin.clients.connections' }, `/clients/${name}/connections`, page, ['workspace', 'history'], item, inScope), keepsNoText: true };
229
+ },
230
+ /**
231
+ * `GET /connections/{id}`: one dataset, pulse-admin's connection. Its `refresh`, a read past
232
+ * pulse-admin's cache, isn't sent. Its answer embeds the dataset's sign-in, so no body's text is
233
+ * kept (#279). Null when `id` can't stay one path segment.
234
+ */
235
+ dataset(id, schema) {
236
+ const name = segment(id);
237
+ return name === null ? null : { ...get(hosts.admin, { service: 'admin', endpoint: 'admin.connections.get' }, `/connections/${name}`, ['workspace', 'history'], schema), keepsNoText: true };
238
+ },
239
+ /**
240
+ * `GET /connections/{id}?refresh=true`: one dataset, read past pulse-admin's cache, before and
241
+ * after a pause or a resume (#212). It keeps no body's text, as `dataset` doesn't (#279). Null when
242
+ * `id` can't stay one path segment.
243
+ */
244
+ freshDataset(id, schema) {
245
+ const name = segment(id);
246
+ return name === null ? null : { ...get(hosts.admin, { service: 'admin', endpoint: 'admin.connections.get' }, `/connections/${name}?refresh=true`, ['workspace', 'history'], schema), keepsNoText: true };
247
+ },
248
+ /**
249
+ * `PUT /connections/{id}` with `{ active }` alone (#212, os D313). pulse-admin's PUT takes
250
+ * UpdateConnectionContract, every field optional, and writes only the fields sent: it sets
251
+ * `model_fields_set` on a fresh read of the connection (pulse-admin 72ec7efe and dff6bf9b, since
252
+ * 51a0b205). Admin spec 0.0.126 is stale there: it still names ConnectionContract, which
253
+ * requires `name` and `client_id`. Sending only `active` never overwrites a rename or a move
254
+ * made since the read. Never pulse-admin's toggle route, which flips the current value, so a
255
+ * pause sent twice would resume (#212's step 5 greps for it). Never tried again. Null when `id`
256
+ * can't stay one path segment.
257
+ */
258
+ setDatasetActive(id, active, schema) {
259
+ const name = segment(id);
260
+ // Its answer is the connection, sign-in embedded, so no body's text is kept (#279).
261
+ return name === null ? null : { ...put(hosts.admin, { service: 'admin', endpoint: 'admin.connections.update' }, `/connections/${name}`, ['workspace', 'history'], { active }, schema), keepsNoText: true };
262
+ },
263
+ /**
264
+ * `GET /organizations/{id}/secrets`: one page of the organisation's provider sign-ins (#70),
265
+ * credentials in our names. No `sort` is sent (D550). pulse-admin doesn't mask a sign-in
266
+ * (`Secret.secret_fields` is empty at dff6bf9b), so `item` is what keeps a value out. Null when
267
+ * `organizationId` can't stay one path segment.
268
+ */
269
+ organizationCredentials(organizationId, page, item, inScope) {
270
+ const name = segment(organizationId);
271
+ if (name === null)
272
+ return null;
273
+ // An answer here may hold a sign-in's value, so no body's text is ever kept (#278 round 1).
274
+ return { ...getList(hosts.admin, { service: 'admin', endpoint: 'admin.organizations.secrets' }, `/organizations/${name}/secrets`, page, [], item, inScope), keepsNoText: true };
275
+ },
276
+ /**
277
+ * `GET /secrets/{id}`: one sign-in, read before a hand-off (#70). The SDK has no call for its
278
+ * value, its download, its revoke or its delete. Null when `id` can't stay one path segment.
279
+ */
280
+ credential(id, schema) {
281
+ const name = segment(id);
282
+ return name === null ? null : { ...get(hosts.admin, { service: 'admin', endpoint: 'admin.secrets.get' }, `/secrets/${name}`, [], schema), keepsNoText: true };
283
+ },
284
+ /** `GET /event-logs/{id}`: one logbook entry. Null when `id` can't stay one path segment. */
285
+ logEntry(id, schema) {
286
+ const name = segment(id);
287
+ return name === null ? null : get(hosts.admin, { service: 'admin', endpoint: 'admin.event-logs.get' }, `/event-logs/${name}`, ['workspace'], schema);
288
+ },
289
+ /**
290
+ * `POST /event-logs`: a new logbook entry, with the five fields pulse-admin's contract requires
291
+ * (CreateEventLogContract, admin 0.0.126) and nothing else; `workspace_id` goes as `client_id`.
292
+ * Never tried again. pulse-admin answers 201 with the entry it made.
293
+ */
294
+ addLogEntry: (entry, schema) => post(hosts.admin, { service: 'admin', endpoint: 'admin.event-logs.create' }, '/event-logs', ['workspace'], entry, schema),
295
+ /**
296
+ * `PUT /event-logs/{id}`: the entry, replaced whole by the same five fields (EventLogContract,
297
+ * all required). Never tried again. Null when `id` can't stay one path segment.
298
+ */
299
+ updateLogEntry(id, entry, schema) {
300
+ const name = segment(id);
301
+ return name === null ? null : put(hosts.admin, { service: 'admin', endpoint: 'admin.event-logs.update' }, `/event-logs/${name}`, ['workspace'], entry, schema);
302
+ },
303
+ /**
304
+ * `DELETE /event-logs/{id}`: the entry, removed. A log entry's remove is direct: D542's hand-offs
305
+ * are workspaces, datasets and members. Never tried again. Null when `id` can't stay one path
306
+ * segment.
307
+ */
308
+ removeLogEntry(id, schema) {
309
+ const name = segment(id);
310
+ return name === null ? null : del(hosts.admin, { service: 'admin', endpoint: 'admin.event-logs.delete' }, `/event-logs/${name}`, schema);
311
+ },
312
+ };
313
+ }
314
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../../src/api/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAgB,MAAM,kBAAkB,CAAA;AAEvE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,SAAS,EAA+B,MAAM,WAAW,CAAA;AAuB1E;;;;;;GAMG;AACH,MAAM,YAAY,GAAY,KAAK,CAAA;AACnC,MAAM,OAAO,GAAG,6BAA6B,CAAA;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,UAA8B,EAAE,cAAuB,EAAE,OAAgB,YAAY;IAC/G,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,UAAU,CAAA;IAC/C,OAAO,IAAI,IAAI,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;AACrD,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAwB,EAAE,KAAwB;IACpE,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACxC,MAAM,QAAQ,GAAG,KAAK,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const createdOn: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>, z.ZodTransform<string | null, string | null | undefined>>;
4
+ /** `created_by_id`: a person's id, or null when the admin API holds none, or its empty default. */
5
+ export declare const createdById: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null, string | null | undefined>>;
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { instant } from './time.js';
3
+ /*
4
+ * When a record was made, and by whom, as the admin API sends them on a connection (#231) and on a
5
+ * logbook entry (#229): one reading for both, so a dataset and an entry say it the same way. The
6
+ * embedded `created_by` is never read (#67); the person is named through `flipstream.members.get`.
7
+ */
8
+ /** `created_on`: an ISO 8601 instant in UTC, or null when the admin API holds none. */
9
+ export const createdOn = instant.nullish().transform((time) => time ?? null);
10
+ /** `created_by_id`: a person's id, or null when the admin API holds none, or its empty default. */
11
+ export const createdById = z
12
+ .string()
13
+ .nullish()
14
+ .transform((maker) => (maker === undefined || maker === null || maker === '' ? null : maker));
15
+ //# sourceMappingURL=created.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"created.js","sourceRoot":"","sources":["../../src/api/created.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC;;;;GAIG;AAEH,uFAAuF;AACvF,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,CAAA;AAE5E,mGAAmG;AACnG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC;KACzB,MAAM,EAAE;KACR,OAAO,EAAE;KACT,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA"}
@@ -0,0 +1,36 @@
1
+ import type { ApiResult } from '../core/result.js';
2
+ import type { Backend } from './backend.js';
3
+ import type { DatasetType } from './datasets.js';
4
+ import { type CredentialHandOff } from './handoff.js';
5
+ import type { Read } from './me.js';
6
+ import { type Page, type PageRequest } from './page.js';
7
+ /** A provider sign-in your organisation holds (#70): who it signs in as, and what it serves. Never its value. */
8
+ export interface Credential {
9
+ readonly id: string;
10
+ /** The provider account it signs in as: for a Google sign-in, that account's email address. */
11
+ readonly name: string;
12
+ /**
13
+ * What kind of sign-in it is, such as `'oauth2'` or `'service_account'`, as pulse-admin's
14
+ * SecretType names it; a kind this version doesn't know is kept as it came, and null when the
15
+ * backend holds none.
16
+ */
17
+ readonly type: string | null;
18
+ /** The kinds of dataset it serves, such as `'google_search_console'`. */
19
+ readonly datasource_types: readonly (DatasetType | (string & Record<never, never>))[];
20
+ /** When it was made: an ISO 8601 instant in UTC. */
21
+ readonly created_on: string;
22
+ }
23
+ /**
24
+ * `flipstream.credentials.list()`: one page of your organisation's sign-ins, as metadata. A bad
25
+ * limit or offset throws, with nothing sent. Your organisation is read first, for its id; its
26
+ * failure is the answer. A sign-in of another organisation, or one holding what may be a value, makes
27
+ * the answer invalid, naming its place.
28
+ */
29
+ export declare function listCredentials(seam: Backend, read: Read, request?: PageRequest): Promise<ApiResult<Page<Credential>>>;
30
+ /**
31
+ * `flipstream.credentials.revoke()` and `delete()`: D542 hand-offs (D546). The sign-in is read
32
+ * beside your organisation, under `list`'s check: one nobody has is `not_found`, and another
33
+ * organisation's, or an answer that isn't the one asked for, is invalid, echoing no id. Then
34
+ * `needs_person`, never a write.
35
+ */
36
+ export declare function handOffCredential(seam: Backend, read: Read, credentialId: string, action: CredentialHandOff): Promise<ApiResult<never>>;