@flipstream/sdk 0.10.1 → 0.12.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/CHANGELOG.md +75 -0
- package/README.md +98 -348
- package/dist/api/account.d.ts +50 -0
- package/dist/api/account.js +102 -0
- package/dist/api/account.js.map +1 -0
- package/dist/api/backend.d.ts +18 -0
- package/dist/api/backend.js +35 -4
- package/dist/api/backend.js.map +1 -1
- package/dist/api/created.d.ts +1 -1
- package/dist/api/created.js +3 -2
- package/dist/api/created.js.map +1 -1
- package/dist/api/credentials.js +4 -4
- package/dist/api/credentials.js.map +1 -1
- package/dist/api/datasets.d.ts +94 -14
- package/dist/api/datasets.js +210 -59
- package/dist/api/datasets.js.map +1 -1
- package/dist/api/index.d.ts +4 -3
- package/dist/api/log.d.ts +45 -24
- package/dist/api/log.js +113 -40
- package/dist/api/log.js.map +1 -1
- package/dist/api/me.d.ts +2 -0
- package/dist/api/me.js +9 -5
- package/dist/api/me.js.map +1 -1
- package/dist/api/members.d.ts +69 -7
- package/dist/api/members.js +110 -32
- package/dist/api/members.js.map +1 -1
- package/dist/api/time.js +4 -3
- package/dist/api/time.js.map +1 -1
- package/dist/api/wallet.d.ts +8 -5
- package/dist/api/wallet.js +36 -24
- package/dist/api/wallet.js.map +1 -1
- package/dist/api/workspaces.d.ts +42 -7
- package/dist/api/workspaces.js +80 -20
- package/dist/api/workspaces.js.map +1 -1
- package/dist/auth/discovery.d.ts +19 -6
- package/dist/auth/discovery.js +25 -4
- package/dist/auth/discovery.js.map +1 -1
- package/dist/auth/signIn.d.ts +18 -14
- package/dist/auth/signIn.js +29 -22
- package/dist/auth/signIn.js.map +1 -1
- package/dist/core/call.d.ts +4 -1
- package/dist/core/call.js +26 -6
- package/dist/core/call.js.map +1 -1
- package/dist/core/deadline.d.ts +30 -0
- package/dist/core/deadline.js +51 -0
- package/dist/core/deadline.js.map +1 -0
- package/dist/core/invalid.d.ts +7 -0
- package/dist/core/invalid.js +22 -0
- package/dist/core/invalid.js.map +1 -0
- package/dist/core/names.d.ts +31 -3
- package/dist/core/names.js +26 -6
- package/dist/core/names.js.map +1 -1
- package/dist/core/notFound.d.ts +8 -0
- package/dist/core/notFound.js +8 -0
- package/dist/core/notFound.js.map +1 -0
- package/dist/core/result.d.ts +17 -12
- package/dist/core/result.js +5 -5
- package/dist/core/result.js.map +1 -1
- package/dist/core/retry.d.ts +5 -2
- package/dist/core/retry.js +6 -3
- package/dist/core/retry.js.map +1 -1
- package/dist/core/scope.d.ts +20 -0
- package/dist/core/scope.js +54 -0
- package/dist/core/scope.js.map +1 -0
- package/dist/flipstream.d.ts +151 -70
- package/dist/flipstream.js +67 -45
- package/dist/flipstream.js.map +1 -1
- package/dist/node/clientSecret.js +5 -5
- package/dist/node/clientSecret.js.map +1 -1
- package/dist/node/headless.d.ts +14 -6
- package/dist/node/headless.js +8 -6
- package/dist/node/headless.js.map +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/keychainChild.js +27 -10
- package/dist/node/keychainChild.js.map +1 -1
- package/dist/node/keychainError.d.ts +3 -3
- package/dist/node/keychainStore.d.ts +16 -12
- package/dist/node/keychainStore.js +50 -28
- package/dist/node/keychainStore.js.map +1 -1
- package/dist/node/loopback.d.ts +8 -1
- package/dist/node/loopback.js +19 -2
- package/dist/node/loopback.js.map +1 -1
- package/dist/node/session.d.ts +17 -9
- package/dist/node/session.js +55 -44
- package/dist/node/session.js.map +1 -1
- package/dist/node/store.d.ts +35 -2
- package/dist/node/store.js +56 -12
- package/dist/node/store.js.map +1 -1
- package/dist/version.gen.js +1 -1
- package/docs/admin.md +503 -0
- package/docs/node-sign-in.md +60 -35
- package/package.json +1 -1
package/dist/core/call.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/core/call.ts"],"names":[],"mappings":"AACA,OAAO,EA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KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAA;AAEnF,qHAAqH;AACrH,SAAS,KAAK,CAAC,EAAU,EAAE,MAAmB;IAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,wFAAwF;QACxF,uFAAuF;QACvF,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,OAAO,EAAE,CAAA;QACpC,MAAM,IAAI,GAAG,GAAS,EAAE;YACtB,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;YACzC,OAAO,EAAE,CAAA;QACX,CAAC,CAAA;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAClC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,KAAe,EAAoD,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The longest a timer waits: setTimeout cuts a longer delay to 1 ms. The one ceiling for every
|
|
3
|
+
* deadline and wait the SDK takes from a caller (#340's code review, 1-3).
|
|
4
|
+
*/
|
|
5
|
+
export declare const MAX_TIMER_MS = 2147483647;
|
|
6
|
+
/**
|
|
7
|
+
* A wait a caller gives, `name` its option as the error names it (`signInWithLoopback: timeoutMs`),
|
|
8
|
+
* in whole ms, rounded down: `fallback` when it's left out, `undefined` or `null`. One that can't be
|
|
9
|
+
* a wait (not a number, NaN, ±Infinity, or more than MAX_TIMER_MS once rounded down) is a TypeError
|
|
10
|
+
* naming the option, never its value: a programming error. A spent wait, under 1 ms, is returned as
|
|
11
|
+
* it is, runtime data for each caller to end as its own timeout (#340, #344, #345's code review).
|
|
12
|
+
*/
|
|
13
|
+
export declare function callerWaitMs<F extends number | undefined>(name: string, value: unknown, fallback: F): number | F;
|
|
14
|
+
/** A deadline, set by `deadlineIn`. */
|
|
15
|
+
export interface Deadline {
|
|
16
|
+
/** The time left, in whole ms, rounded down: 0 once it has passed, never below, nor for NaN. */
|
|
17
|
+
readonly left: () => number;
|
|
18
|
+
/**
|
|
19
|
+
* Whether it has passed: exactly when `left()` reads 0, so a check that lets a turn through never
|
|
20
|
+
* hands it a deadline of 0 ms (#337's code review, 1-2).
|
|
21
|
+
*/
|
|
22
|
+
readonly passed: () => boolean;
|
|
23
|
+
}
|
|
24
|
+
/** A deadline `ms` from now, on the monotonic clock. */
|
|
25
|
+
export declare function deadlineIn(ms: number): Deadline;
|
|
26
|
+
/**
|
|
27
|
+
* An instant, in ms since the epoch: the wall clock, for expiry (a token's `expires_at`, computed
|
|
28
|
+
* from when its request was sent, and checked against now). Never a deadline: use `deadlineIn`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const wallClock: () => number;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The SDK's deadlines and its wall-clock reads for expiry (#333). Not exported from the package.
|
|
3
|
+
*
|
|
4
|
+
* A deadline runs on the monotonic clock, `performance.now()`, as the timers that end a call, a
|
|
5
|
+
* session's limit and a keychain step do. On the wall clock, a clock change, a virtual machine
|
|
6
|
+
* resuming or (on Linux, whose monotonic clock skips sleep) a laptop waking would fail a call early
|
|
7
|
+
* or let its retries run past the deadline, while its timer still ran (#157 items 10 and 21).
|
|
8
|
+
*
|
|
9
|
+
* Every file in src reads `Date` and `performance` only through this module: the lint refuses both
|
|
10
|
+
* elsewhere (eslint.config.js, held by test/lint/deadline-clocks.test.mjs). Its exceptions are named
|
|
11
|
+
* there, each with its reason: fileLock.ts's own clocks, which its tests own (#298's rule); the
|
|
12
|
+
* keychain helper process, which counts the time left it's handed (`msLeft`) on its own monotonic
|
|
13
|
+
* clock, inside the cut its parent's going sets; and the date arithmetic in api/time.ts and
|
|
14
|
+
* api/log.ts, which parses and builds instants and reads no clock.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The longest a timer waits: setTimeout cuts a longer delay to 1 ms. The one ceiling for every
|
|
18
|
+
* deadline and wait the SDK takes from a caller (#340's code review, 1-3).
|
|
19
|
+
*/
|
|
20
|
+
export const MAX_TIMER_MS = 2_147_483_647;
|
|
21
|
+
/**
|
|
22
|
+
* A wait a caller gives, `name` its option as the error names it (`signInWithLoopback: timeoutMs`),
|
|
23
|
+
* in whole ms, rounded down: `fallback` when it's left out, `undefined` or `null`. One that can't be
|
|
24
|
+
* a wait (not a number, NaN, ±Infinity, or more than MAX_TIMER_MS once rounded down) is a TypeError
|
|
25
|
+
* naming the option, never its value: a programming error. A spent wait, under 1 ms, is returned as
|
|
26
|
+
* it is, runtime data for each caller to end as its own timeout (#340, #344, #345's code review).
|
|
27
|
+
*/
|
|
28
|
+
export function callerWaitMs(name, value, fallback) {
|
|
29
|
+
if (value === undefined || value === null)
|
|
30
|
+
return fallback;
|
|
31
|
+
const whole = typeof value === 'number' ? Math.floor(value) : Number.NaN;
|
|
32
|
+
if (!Number.isFinite(whole) || whole > MAX_TIMER_MS)
|
|
33
|
+
throw new TypeError(`${name} must be a number of ms, at most ${String(MAX_TIMER_MS)}`);
|
|
34
|
+
return whole;
|
|
35
|
+
}
|
|
36
|
+
/** A deadline `ms` from now, on the monotonic clock. */
|
|
37
|
+
export function deadlineIn(ms) {
|
|
38
|
+
const at = performance.now() + ms;
|
|
39
|
+
const left = () => {
|
|
40
|
+
const whole = Math.floor(at - performance.now());
|
|
41
|
+
// Not `Math.max(0, …)`, which keeps NaN: a deadline that isn't a number has no time in it.
|
|
42
|
+
return whole > 0 ? whole : 0;
|
|
43
|
+
};
|
|
44
|
+
return { left, passed: () => left() === 0 };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* An instant, in ms since the epoch: the wall clock, for expiry (a token's `expires_at`, computed
|
|
48
|
+
* from when its request was sent, and checked against now). Never a deadline: use `deadlineIn`.
|
|
49
|
+
*/
|
|
50
|
+
export const wallClock = () => Date.now();
|
|
51
|
+
//# sourceMappingURL=deadline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline.js","sourceRoot":"","sources":["../../src/core/deadline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAA;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAA+B,IAAY,EAAE,KAAc,EAAE,QAAW;IAClG,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAA;IAC1D,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAA;IACxE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,YAAY;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,oCAAoC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;IAC3I,OAAO,KAAK,CAAA;AACd,CAAC;AAaD,wDAAwD;AACxD,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAA;IACjC,MAAM,IAAI,GAAG,GAAW,EAAE;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,CAAA;QAChD,2FAA2F;QAC3F,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9B,CAAC,CAAA;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAA;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ApiResult } from './result.js';
|
|
2
|
+
/** `invalid` with `status`, a status the SDK knows, or with none when it's undefined. */
|
|
3
|
+
export declare function invalidWith(issues: string, status: number | undefined): ApiResult<never>;
|
|
4
|
+
/** `invalid`, found by a check of an answer whose route answers 200 by its backend's own code. */
|
|
5
|
+
export declare const invalidAnswer: (issues: string) => ApiResult<never>;
|
|
6
|
+
/** `invalid`, found by a check of an answer whose route's success status isn't known: a create's. */
|
|
7
|
+
export declare const invalidStatusUnknown: (issues: string) => ApiResult<never>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* An `invalid` the SDK finds by checking an answer after its read (#368): a record that isn't the one
|
|
3
|
+
* asked for, another organisation's, a page that leaks, or an id that can't name the next path. It
|
|
4
|
+
* has one shape wherever it's found, and `issues` names a place or a rule, never an id or a value.
|
|
5
|
+
*
|
|
6
|
+
* Its `status` is assumed, never observed. A read takes any 2xx as ok, and its data carries no status
|
|
7
|
+
* (#368's decision log dropped carrying one, since that would change every read's shape). So it's the
|
|
8
|
+
* success status the route answers by its backend's own code: 200 for every GET the SDK sends, and
|
|
9
|
+
* for the two PUTs, whose pulse-admin routes declare it at dff6bf9b
|
|
10
|
+
* (adapters/connection/ingress/fastapi/__init__.py:423 and adapters/event_log/ingress/fastapi/__init__.py:164).
|
|
11
|
+
* Where a route's success status isn't known, there's none: the two creates, POST /clients and POST
|
|
12
|
+
* /event-logs, which come from a generic router with no recording of their answer.
|
|
13
|
+
*/
|
|
14
|
+
/** `invalid` with `status`, a status the SDK knows, or with none when it's undefined. */
|
|
15
|
+
export function invalidWith(issues, status) {
|
|
16
|
+
return { ok: false, error: status === undefined ? { kind: 'invalid', issues } : { kind: 'invalid', issues, status } };
|
|
17
|
+
}
|
|
18
|
+
/** `invalid`, found by a check of an answer whose route answers 200 by its backend's own code. */
|
|
19
|
+
export const invalidAnswer = (issues) => invalidWith(issues, 200);
|
|
20
|
+
/** `invalid`, found by a check of an answer whose route's success status isn't known: a create's. */
|
|
21
|
+
export const invalidStatusUnknown = (issues) => invalidWith(issues, undefined);
|
|
22
|
+
//# sourceMappingURL=invalid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid.js","sourceRoot":"","sources":["../../src/core/invalid.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,yFAAyF;AACzF,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,MAA0B;IACpE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAA;AACvH,CAAC;AAED,kGAAkG;AAClG,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAoB,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE3F,qGAAqG;AACrG,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAoB,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA"}
|
package/dist/core/names.d.ts
CHANGED
|
@@ -22,6 +22,13 @@ declare const CONCEPTS: {
|
|
|
22
22
|
readonly history: {
|
|
23
23
|
readonly history: "backfill";
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Where a dataset's refresh stands (#343): pulse-admin's `data_refresh_status` on a connection.
|
|
27
|
+
* The field is renamed, its values keep pulse-admin's spelling (D563).
|
|
28
|
+
*/
|
|
29
|
+
readonly refresh_status: {
|
|
30
|
+
readonly refresh_status: "data_refresh_status";
|
|
31
|
+
};
|
|
25
32
|
};
|
|
26
33
|
export type Concept = keyof typeof CONCEPTS;
|
|
27
34
|
type Pairs<C extends Concept> = (typeof CONCEPTS)[C];
|
|
@@ -82,7 +89,27 @@ export declare function fromBackend(call: Call, concepts: readonly Concept[], re
|
|
|
82
89
|
export type Role = 'owner' | 'admin' | 'editor' | 'viewer';
|
|
83
90
|
/** Our roles, highest first: a person holding several is read by the highest (D544). */
|
|
84
91
|
export declare const RANKED: readonly ["owner", "admin", "editor", "viewer"];
|
|
85
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Flipstream staff's roles, which no public type holds (D544): the roles that reach across
|
|
94
|
+
* organisations, pulse-auth's GODMODE_ONLY_ROLES (pulse-auth 0ae57c8, custom/domain/user/roles.py).
|
|
95
|
+
* Staff read as no role whatever else they hold, but only by these names: a staff role this version
|
|
96
|
+
* doesn't know reads as one it has never seen (#265), so this list must follow pulse-auth's. The one
|
|
97
|
+
* list (#268): the live scripts read it from the build, through `roleFromBackend`, to stop a staff
|
|
98
|
+
* sign-in, and the tests walk it. Frozen, so nobody changes the SDK's rule by changing it, and not
|
|
99
|
+
* exported from the package. Every place that restates the staff rule in words changes with it by
|
|
100
|
+
* hand (#335's code review, 5): in docs/admin.md (#327), the `role`, `roles` and `unknown_roles`
|
|
101
|
+
* bullets of "Who you are" and the member's paragraph of "Your organisation's members"; in
|
|
102
|
+
* src/api/members.ts, `Member.role`'s, `Member.roles`' and `Member.unknown_roles`' docs and `zRoles`'
|
|
103
|
+
* comment; and, in src/flipstream.ts, `flipstream.members`' doc, which points at those three fields
|
|
104
|
+
* (#335 round 2, O2.F1). docs/admin.md's `role` bullet names these roles.
|
|
105
|
+
*/
|
|
106
|
+
export declare const STAFF_ROLES: readonly string[];
|
|
107
|
+
/**
|
|
108
|
+
* How one of pulse-auth's role names reads: one of ours, staff's, a name this version knows and
|
|
109
|
+
* reads as no role of ours (`none`), or one it has never seen (`unknown`). The SDK reads `unknown`
|
|
110
|
+
* as no role of ours too (#265); the live scripts stop on it, since it could be a new staff role
|
|
111
|
+
* (#268).
|
|
112
|
+
*/
|
|
86
113
|
export type RoleRead = {
|
|
87
114
|
readonly kind: 'role';
|
|
88
115
|
readonly role: Role;
|
|
@@ -90,11 +117,12 @@ export type RoleRead = {
|
|
|
90
117
|
readonly kind: 'staff';
|
|
91
118
|
} | {
|
|
92
119
|
readonly kind: 'none';
|
|
120
|
+
} | {
|
|
121
|
+
readonly kind: 'unknown';
|
|
93
122
|
};
|
|
94
123
|
/**
|
|
95
124
|
* pulse-auth's role `name`, in our names. Any other name is no role of ours, never an error
|
|
96
|
-
* (#265): pulse-auth's `user`
|
|
97
|
-
* guest role (D559), and one the SDK has never seen.
|
|
125
|
+
* (#265): pulse-auth's `user` and `client` (`none`), and one the SDK has never seen (`unknown`).
|
|
98
126
|
*/
|
|
99
127
|
export declare function roleFromBackend(name: string): RoleRead;
|
|
100
128
|
export {};
|
package/dist/core/names.js
CHANGED
|
@@ -19,6 +19,11 @@ const CONCEPTS = {
|
|
|
19
19
|
* connection. The field is renamed, its values keep pulse-admin's spelling (D563).
|
|
20
20
|
*/
|
|
21
21
|
history: { history: 'backfill' },
|
|
22
|
+
/**
|
|
23
|
+
* Where a dataset's refresh stands (#343): pulse-admin's `data_refresh_status` on a connection.
|
|
24
|
+
* The field is renamed, its values keep pulse-admin's spelling (D563).
|
|
25
|
+
*/
|
|
26
|
+
refresh_status: { refresh_status: 'data_refresh_status' },
|
|
22
27
|
};
|
|
23
28
|
/**
|
|
24
29
|
* OAuth's and OpenID Connect's own calls, by endpoint: sign-in's exchange, refresh, revoke,
|
|
@@ -95,20 +100,35 @@ void everyRole; // read once, so unused-locals checks keep it
|
|
|
95
100
|
* Flipstream staff's roles, which no public type holds (D544): the roles that reach across
|
|
96
101
|
* organisations, pulse-auth's GODMODE_ONLY_ROLES (pulse-auth 0ae57c8, custom/domain/user/roles.py).
|
|
97
102
|
* Staff read as no role whatever else they hold, but only by these names: a staff role this version
|
|
98
|
-
* doesn't know reads as
|
|
99
|
-
*
|
|
103
|
+
* doesn't know reads as one it has never seen (#265), so this list must follow pulse-auth's. The one
|
|
104
|
+
* list (#268): the live scripts read it from the build, through `roleFromBackend`, to stop a staff
|
|
105
|
+
* sign-in, and the tests walk it. Frozen, so nobody changes the SDK's rule by changing it, and not
|
|
106
|
+
* exported from the package. Every place that restates the staff rule in words changes with it by
|
|
107
|
+
* hand (#335's code review, 5): in docs/admin.md (#327), the `role`, `roles` and `unknown_roles`
|
|
108
|
+
* bullets of "Who you are" and the member's paragraph of "Your organisation's members"; in
|
|
109
|
+
* src/api/members.ts, `Member.role`'s, `Member.roles`' and `Member.unknown_roles`' docs and `zRoles`'
|
|
110
|
+
* comment; and, in src/flipstream.ts, `flipstream.members`' doc, which points at those three fields
|
|
111
|
+
* (#335 round 2, O2.F1). docs/admin.md's `role` bullet names these roles.
|
|
112
|
+
*/
|
|
113
|
+
export const STAFF_ROLES = Object.freeze(['godmode', 'swapper']);
|
|
114
|
+
const STAFF = new Set(STAFF_ROLES);
|
|
115
|
+
/**
|
|
116
|
+
* pulse-auth's role names this version knows and reads as no role of ours: `user`, until Douwe says
|
|
117
|
+
* what it means (D544), and `client`, while there's no guest role (D559). Neither is staff's
|
|
118
|
+
* (GODMODE_ONLY_ROLES, pulse-auth 0ae57c8). Any other name is one this version has never seen.
|
|
100
119
|
*/
|
|
101
|
-
const
|
|
120
|
+
const NOT_OURS = new Set(['user', 'client']);
|
|
102
121
|
const OURS = new Map(RANKED.map((role) => [ROLES[role], role]));
|
|
103
122
|
/**
|
|
104
123
|
* pulse-auth's role `name`, in our names. Any other name is no role of ours, never an error
|
|
105
|
-
* (#265): pulse-auth's `user`
|
|
106
|
-
* guest role (D559), and one the SDK has never seen.
|
|
124
|
+
* (#265): pulse-auth's `user` and `client` (`none`), and one the SDK has never seen (`unknown`).
|
|
107
125
|
*/
|
|
108
126
|
export function roleFromBackend(name) {
|
|
109
127
|
const role = OURS.get(name);
|
|
110
128
|
if (role !== undefined)
|
|
111
129
|
return { kind: 'role', role };
|
|
112
|
-
|
|
130
|
+
if (STAFF.has(name))
|
|
131
|
+
return { kind: 'staff' };
|
|
132
|
+
return NOT_OURS.has(name) ? { kind: 'none' } : { kind: 'unknown' };
|
|
113
133
|
}
|
|
114
134
|
//# sourceMappingURL=names.js.map
|
package/dist/core/names.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../src/core/names.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,uFAAuF;AACvF,MAAM,QAAQ,GAAG;IACf,gFAAgF;IAChF,OAAO,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE;IACxC;;;;OAIG;IACH,SAAS,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE;IACxG;;;OAGG;IACH,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../src/core/names.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,uFAAuF;AACvF,MAAM,QAAQ,GAAG;IACf,gFAAgF;IAChF,OAAO,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE;IACxC;;;;OAIG;IACH,SAAS,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE;IACxG;;;OAGG;IACH,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;IAChC;;;OAGG;IACH,cAAc,EAAE,EAAE,cAAc,EAAE,qBAAqB,EAAE;CACoB,CAAA;AAmC/E;;;;;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B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAA;AACnF,MAAM,KAAK,GAAwB,IAAI,GAAG,CAAC,WAAW,CAAC,CAAA;AAEvD;;;;GAIG;AACH,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;AAEjE,MAAM,IAAI,GAA8B,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;AAU1F;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC3B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IACrD,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IAC7C,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApiResult } from './result.js';
|
|
2
|
+
/**
|
|
3
|
+
* `not_found` exactly as a service answers it for a record nobody has, its own `code` and `message`
|
|
4
|
+
* included, so an answer the SDK makes for a record you can't see says no more than that (D571,
|
|
5
|
+
* #372). A fresh object on each call: a caller that changes one answer never changes another's
|
|
6
|
+
* (#373's code review, 8).
|
|
7
|
+
*/
|
|
8
|
+
export declare const notFound: (code: string, message: string) => ApiResult<never>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `not_found` exactly as a service answers it for a record nobody has, its own `code` and `message`
|
|
3
|
+
* included, so an answer the SDK makes for a record you can't see says no more than that (D571,
|
|
4
|
+
* #372). A fresh object on each call: a caller that changes one answer never changes another's
|
|
5
|
+
* (#373's code review, 8).
|
|
6
|
+
*/
|
|
7
|
+
export const notFound = (code, message) => ({ ok: false, error: { kind: 'not_found', status: 404, code, message } });
|
|
8
|
+
//# sourceMappingURL=notFound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notFound.js","sourceRoot":"","sources":["../../src/core/notFound.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,OAAe,EAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAA"}
|
package/dist/core/result.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { PlannerErrorCode } from '../spec/query-planner/types.gen.js';
|
|
2
2
|
/**
|
|
3
|
-
* What every call returns: its data, or one failure with one meaning (D412). `
|
|
3
|
+
* What every call returns: its data, or one failure with one meaning (D412). `trace_id` is the W3C
|
|
4
4
|
* trace-id the call's requests carried (#251), so a person can find them in Logs: there when a
|
|
5
5
|
* request carrying it went out, on either arm, and absent when nothing was sent.
|
|
6
6
|
*/
|
|
7
7
|
export type ApiResult<T> = {
|
|
8
8
|
readonly ok: true;
|
|
9
9
|
readonly data: T;
|
|
10
|
-
readonly
|
|
10
|
+
readonly trace_id?: string;
|
|
11
11
|
} | {
|
|
12
12
|
readonly ok: false;
|
|
13
13
|
readonly error: ApiError;
|
|
14
|
-
readonly
|
|
14
|
+
readonly trace_id?: string;
|
|
15
15
|
};
|
|
16
16
|
/** The failures a status gives: the host answered, and said no. */
|
|
17
17
|
export type StatusKind = 'unauthorized' | 'forbidden' | 'not_found' | 'conflict' | 'rejected' | 'unavailable';
|
|
@@ -32,25 +32,25 @@ export type Said = {
|
|
|
32
32
|
readonly code: ErrorCode;
|
|
33
33
|
readonly message: string;
|
|
34
34
|
/** The request's id, once a host sends one. None does yet (D429). */
|
|
35
|
-
readonly
|
|
35
|
+
readonly request_id?: string;
|
|
36
36
|
readonly text?: never;
|
|
37
37
|
} | {
|
|
38
38
|
readonly text: string;
|
|
39
39
|
readonly code?: never;
|
|
40
40
|
readonly message?: never;
|
|
41
|
-
readonly
|
|
41
|
+
readonly request_id?: never;
|
|
42
42
|
} | {
|
|
43
43
|
readonly text?: never;
|
|
44
44
|
readonly code?: never;
|
|
45
45
|
readonly message?: never;
|
|
46
|
-
readonly
|
|
46
|
+
readonly request_id?: never;
|
|
47
47
|
};
|
|
48
48
|
/** A failure the host answered with a status, and what came with it. */
|
|
49
49
|
export type Answered = {
|
|
50
50
|
readonly kind: StatusKind;
|
|
51
51
|
readonly status: number;
|
|
52
52
|
/** How long the host asked the caller to wait (`Retry-After`), when it said so. */
|
|
53
|
-
readonly
|
|
53
|
+
readonly retry_after_ms?: number;
|
|
54
54
|
} & Said;
|
|
55
55
|
export type ApiError = Answered
|
|
56
56
|
/** No answer at all: offline, a body that broke off, or no token right now. */
|
|
@@ -59,8 +59,13 @@ export type ApiError = Answered
|
|
|
59
59
|
readonly status?: never;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* Outside the contract: reported, never shown as empty. `status` is
|
|
63
|
-
*
|
|
62
|
+
* Outside the contract: reported, never shown as empty. `status` is set on a failure from an
|
|
63
|
+
* answer whose status the SDK knows. When the answer's own status or shape is outside the
|
|
64
|
+
* contract, or a read after pause's or resume's write failed, it's the response's. When a check
|
|
65
|
+
* after the read found it (#368), it's the success status that route answers by its backend's
|
|
66
|
+
* own code, 200 for every read and both PUTs, assumed from a 2xx and never observed. A create's
|
|
67
|
+
* answer has none, since its route's success status isn't known. `text` is its body, when a 2xx
|
|
68
|
+
* body is not JSON.
|
|
64
69
|
*/
|
|
65
70
|
| {
|
|
66
71
|
readonly kind: 'invalid';
|
|
@@ -141,8 +146,8 @@ export type RefusedReason =
|
|
|
141
146
|
| 'callback';
|
|
142
147
|
/**
|
|
143
148
|
* A failed call, thrown by `orThrow`, carrying its `ApiError`. When the call's requests went out
|
|
144
|
-
* under a trace (#251), it carries that `
|
|
145
|
-
* `(request <
|
|
149
|
+
* under a trace (#251), it carries that `trace_id` too (#262), and its message ends with
|
|
150
|
+
* `(request <trace_id>)`, so whoever catches or prints it can find them in Logs.
|
|
146
151
|
*/
|
|
147
152
|
export declare class ApiFailure extends Error {
|
|
148
153
|
readonly error: ApiError;
|
|
@@ -150,7 +155,7 @@ export declare class ApiFailure extends Error {
|
|
|
150
155
|
* The call's W3C trace-id, when its requests went out under one; absent otherwise. Declared, not
|
|
151
156
|
* defined, so a class field doesn't make it an own property holding `undefined`.
|
|
152
157
|
*/
|
|
153
|
-
readonly
|
|
158
|
+
readonly trace_id?: string;
|
|
154
159
|
constructor(error: ApiError, traceId?: string);
|
|
155
160
|
}
|
|
156
161
|
/** The data, or the failure thrown as `ApiFailure`, for callers who want exceptions (D412). */
|
package/dist/core/result.js
CHANGED
|
@@ -50,8 +50,8 @@ function failureMessage(error) {
|
|
|
50
50
|
const TRACE_ID = /^[0-9a-f]{32}$/;
|
|
51
51
|
/**
|
|
52
52
|
* A failed call, thrown by `orThrow`, carrying its `ApiError`. When the call's requests went out
|
|
53
|
-
* under a trace (#251), it carries that `
|
|
54
|
-
* `(request <
|
|
53
|
+
* under a trace (#251), it carries that `trace_id` too (#262), and its message ends with
|
|
54
|
+
* `(request <trace_id>)`, so whoever catches or prints it can find them in Logs.
|
|
55
55
|
*/
|
|
56
56
|
export class ApiFailure extends Error {
|
|
57
57
|
error;
|
|
@@ -61,15 +61,15 @@ export class ApiFailure extends Error {
|
|
|
61
61
|
super(traced === undefined ? failureMessage(error) : `${failureMessage(error)} (request ${traced})`);
|
|
62
62
|
this.name = 'ApiFailure';
|
|
63
63
|
this.error = error;
|
|
64
|
-
// Only a trace-id, and only when there is one, so `'
|
|
64
|
+
// Only a trace-id, and only when there is one, so `'trace_id' in failure` means one went out.
|
|
65
65
|
if (traced !== undefined)
|
|
66
|
-
this.
|
|
66
|
+
this.trace_id = traced;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
/** The data, or the failure thrown as `ApiFailure`, for callers who want exceptions (D412). */
|
|
70
70
|
export function orThrow(result) {
|
|
71
71
|
if (!result.ok)
|
|
72
|
-
throw new ApiFailure(result.error, result.
|
|
72
|
+
throw new ApiFailure(result.error, result.trace_id);
|
|
73
73
|
return result.data;
|
|
74
74
|
}
|
|
75
75
|
//# sourceMappingURL=result.js.map
|
package/dist/core/result.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/core/result.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/core/result.ts"],"names":[],"mappings":"AAyHA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;QAAE,OAAO,kBAAkB,CAAA;IACxD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,SAAS,CAAA;IACpD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,cAAc,CAAA;IACzC,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,WAAW,CAAA;IACtC,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,WAAW,CAAA;IACtC,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,UAAU,CAAA;IACvD,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC;QAAE,OAAO,aAA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B,YAAY,KAAe,EAAE,OAAgB;QAC3C,8FAA8F;QAC9F,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;QAC1F,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,aAAa,MAAM,GAAG,CAAC,CAAA;QACpG,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,8FAA8F;QAC9F,IAAI,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAA;IAClD,CAAC;CACF;AAED,+FAA+F;AAC/F,MAAM,UAAU,OAAO,CAAI,MAAoB;IAC7C,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;IACnE,OAAO,MAAM,CAAC,IAAI,CAAA;AACpB,CAAC"}
|
package/dist/core/retry.d.ts
CHANGED
|
@@ -22,9 +22,12 @@ export type Decision = {
|
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Whether to try again after `attempt` attempts, and after how long. A wait that would not end
|
|
25
|
-
*
|
|
25
|
+
* within the `leftMs` left of the deadline is not started: the outcome is the answer, and the caller
|
|
26
|
+
* decides. The caller reads `leftMs` off its deadline (#333), in whole ms rounded down, and this reads
|
|
27
|
+
* no clock. So a wait that would leave under 1 ms for the attempt after it isn't started: that
|
|
28
|
+
* attempt couldn't be sent and answered in the time (#337's code review, 3).
|
|
26
29
|
*/
|
|
27
|
-
export declare function decide(rule: RetryRule, attempt: number, outcome: Outcome,
|
|
30
|
+
export declare function decide(rule: RetryRule, attempt: number, outcome: Outcome, leftMs: number): Decision;
|
|
28
31
|
/**
|
|
29
32
|
* The ceiling for a host's stated wait: a hostile or broken header must never park a caller for
|
|
30
33
|
* hours (`Retry-After: 999999999` is about 31 years). From the CLI's `api/http.ts`.
|
package/dist/core/retry.js
CHANGED
|
@@ -8,9 +8,12 @@ const MAX_RETRIES = 2;
|
|
|
8
8
|
const STOP = { kind: 'stop' };
|
|
9
9
|
/**
|
|
10
10
|
* Whether to try again after `attempt` attempts, and after how long. A wait that would not end
|
|
11
|
-
*
|
|
11
|
+
* within the `leftMs` left of the deadline is not started: the outcome is the answer, and the caller
|
|
12
|
+
* decides. The caller reads `leftMs` off its deadline (#333), in whole ms rounded down, and this reads
|
|
13
|
+
* no clock. So a wait that would leave under 1 ms for the attempt after it isn't started: that
|
|
14
|
+
* attempt couldn't be sent and answered in the time (#337's code review, 3).
|
|
12
15
|
*/
|
|
13
|
-
export function decide(rule, attempt, outcome,
|
|
16
|
+
export function decide(rule, attempt, outcome, leftMs) {
|
|
14
17
|
if (rule === 'never' || outcome.kind === 'final' || attempt > MAX_RETRIES)
|
|
15
18
|
return STOP;
|
|
16
19
|
if (outcome.kind === 'answered' && !READ_STATUSES.has(outcome.status))
|
|
@@ -18,7 +21,7 @@ export function decide(rule, attempt, outcome, now, deadline) {
|
|
|
18
21
|
const asked = outcome.kind === 'answered' ? parseRetryAfterMs(outcome.retryAfter) : undefined;
|
|
19
22
|
// When the host names no wait: 500 ms, then 1 s. No jitter, so the decision stays pure.
|
|
20
23
|
const ms = asked ?? (attempt === 1 ? 500 : 1000);
|
|
21
|
-
return
|
|
24
|
+
return ms < leftMs ? { kind: 'wait', ms } : STOP;
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* The ceiling for a host's stated wait: a hostile or broken header must never park a caller for
|
package/dist/core/retry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/core/retry.ts"],"names":[],"mappings":"A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,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAA;AAE3C;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAqB;IACrD,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IAC7B,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACtG,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** What a call's reads are sent with: the signal that ends them, and where each is recorded. */
|
|
2
|
+
export interface CallScope {
|
|
3
|
+
/** The call's own end, which each read also goes with (call()'s `callEnd`). Never a write's. */
|
|
4
|
+
readonly signal: AbortSignal;
|
|
5
|
+
/** `work`, a read or a write the call started, recorded in order; the same promise, returned. */
|
|
6
|
+
track<R>(work: Promise<R>): Promise<R>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `run`'s answer, once every read and write it started (`scope.track`) has settled (#349).
|
|
10
|
+
* - A read still on its way when `run` answers or rejects is ended (`scope.signal`), and so is every
|
|
11
|
+
* read the moment any one rejects, even one `run` is waiting on, so a hanging read never holds the
|
|
12
|
+
* call to its deadline. An ended read answers `aborted` at once, as call() does. A write is never
|
|
13
|
+
* ended, even beside a read that rejects, only waited for: an ended write's outcome would be a lie,
|
|
14
|
+
* since it may still have been made.
|
|
15
|
+
* - A rejection is an exception, never a result: when any read or write rejected, the call rejects
|
|
16
|
+
* with the first in the order started, whatever `run` answered. Otherwise `run`'s own rejection,
|
|
17
|
+
* or its answer.
|
|
18
|
+
* The caller's own signal isn't the scope's: each read gets it beside the scope's (call()'s `signal`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function withReads<T>(run: (scope: CallScope) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* One SDK call's reads (#349): the call scope. Each read and write the call starts is recorded, in
|
|
3
|
+
* the order started, and each read goes under the call's own end as well as the caller's signal
|
|
4
|
+
* (call()'s `callEnd`, kept apart, so the scope never listens to the caller's signal), so the call
|
|
5
|
+
* answers, or rejects, with none still being waited on. A transport may keep running after its read
|
|
6
|
+
* was ended or timed out: call() lets it go (#57), and nothing waits for it.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* `run`'s answer, once every read and write it started (`scope.track`) has settled (#349).
|
|
10
|
+
* - A read still on its way when `run` answers or rejects is ended (`scope.signal`), and so is every
|
|
11
|
+
* read the moment any one rejects, even one `run` is waiting on, so a hanging read never holds the
|
|
12
|
+
* call to its deadline. An ended read answers `aborted` at once, as call() does. A write is never
|
|
13
|
+
* ended, even beside a read that rejects, only waited for: an ended write's outcome would be a lie,
|
|
14
|
+
* since it may still have been made.
|
|
15
|
+
* - A rejection is an exception, never a result: when any read or write rejected, the call rejects
|
|
16
|
+
* with the first in the order started, whatever `run` answered. Otherwise `run`'s own rejection,
|
|
17
|
+
* or its answer.
|
|
18
|
+
* The caller's own signal isn't the scope's: each read gets it beside the scope's (call()'s `signal`).
|
|
19
|
+
*/
|
|
20
|
+
export async function withReads(run) {
|
|
21
|
+
const end = new AbortController();
|
|
22
|
+
const ended = new DOMException('the call has ended', 'AbortError');
|
|
23
|
+
const started = [];
|
|
24
|
+
const scope = {
|
|
25
|
+
signal: end.signal,
|
|
26
|
+
track: (work) => {
|
|
27
|
+
started.push(work);
|
|
28
|
+
// Seen at once, so a rejection is never unhandled while the call goes on, and it ends the rest.
|
|
29
|
+
void work.catch(() => end.abort(ended));
|
|
30
|
+
return work;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
let outcome;
|
|
34
|
+
try {
|
|
35
|
+
outcome = { ok: true, value: await run(scope) };
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
outcome = { ok: false, error };
|
|
39
|
+
}
|
|
40
|
+
end.abort(ended);
|
|
41
|
+
// Every one, a read begun as the call ends included: it goes out ended, and answers at once.
|
|
42
|
+
for (let seen = 0; seen < started.length;) {
|
|
43
|
+
const batch = started.slice(seen);
|
|
44
|
+
seen = started.length;
|
|
45
|
+
await Promise.allSettled(batch);
|
|
46
|
+
}
|
|
47
|
+
const rejected = (await Promise.allSettled(started)).find((settled) => settled.status === 'rejected');
|
|
48
|
+
if (rejected !== undefined)
|
|
49
|
+
throw rejected.reason;
|
|
50
|
+
if (!outcome.ok)
|
|
51
|
+
throw outcome.error;
|
|
52
|
+
return outcome.value;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/core/scope.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,GAAqC;IACtE,MAAM,GAAG,GAAG,IAAI,eAAe,EAAE,CAAA;IACjC,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAA;IAClE,MAAM,OAAO,GAAuB,EAAE,CAAA;IACtC,MAAM,KAAK,GAAc;QACvB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAClB,gGAAgG;YAChG,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;YACvC,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CAAA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