@flipstream/sdk 0.11.0 → 0.13.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 (98) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +179 -424
  3. package/dist/api/backend.d.ts +21 -3
  4. package/dist/api/backend.js +50 -10
  5. package/dist/api/backend.js.map +1 -1
  6. package/dist/api/credentials.js +4 -4
  7. package/dist/api/credentials.js.map +1 -1
  8. package/dist/api/datasets.d.ts +82 -14
  9. package/dist/api/datasets.js +193 -57
  10. package/dist/api/datasets.js.map +1 -1
  11. package/dist/api/index.d.ts +1 -1
  12. package/dist/api/log.d.ts +25 -20
  13. package/dist/api/log.js +63 -48
  14. package/dist/api/log.js.map +1 -1
  15. package/dist/api/me.js +9 -5
  16. package/dist/api/me.js.map +1 -1
  17. package/dist/api/members.d.ts +34 -1
  18. package/dist/api/members.js +67 -27
  19. package/dist/api/members.js.map +1 -1
  20. package/dist/api/wallet.d.ts +8 -5
  21. package/dist/api/wallet.js +40 -25
  22. package/dist/api/wallet.js.map +1 -1
  23. package/dist/api/workspaces.d.ts +35 -14
  24. package/dist/api/workspaces.js +53 -23
  25. package/dist/api/workspaces.js.map +1 -1
  26. package/dist/auth/discovery.d.ts +19 -6
  27. package/dist/auth/discovery.js +30 -6
  28. package/dist/auth/discovery.js.map +1 -1
  29. package/dist/auth/signIn.d.ts +18 -14
  30. package/dist/auth/signIn.js +29 -22
  31. package/dist/auth/signIn.js.map +1 -1
  32. package/dist/core/call.d.ts +13 -1
  33. package/dist/core/call.js +34 -9
  34. package/dist/core/call.js.map +1 -1
  35. package/dist/core/deadline.d.ts +30 -0
  36. package/dist/core/deadline.js +51 -0
  37. package/dist/core/deadline.js.map +1 -0
  38. package/dist/core/identify.d.ts +59 -14
  39. package/dist/core/identify.js +54 -20
  40. package/dist/core/identify.js.map +1 -1
  41. package/dist/core/invalid.d.ts +10 -0
  42. package/dist/core/invalid.js +28 -0
  43. package/dist/core/invalid.js.map +1 -0
  44. package/dist/core/names.d.ts +13 -2
  45. package/dist/core/names.js +11 -2
  46. package/dist/core/names.js.map +1 -1
  47. package/dist/core/notFound.d.ts +8 -0
  48. package/dist/core/notFound.js +8 -0
  49. package/dist/core/notFound.js.map +1 -0
  50. package/dist/core/read.d.ts +9 -0
  51. package/dist/core/read.js +14 -5
  52. package/dist/core/read.js.map +1 -1
  53. package/dist/core/result.d.ts +22 -13
  54. package/dist/core/result.js +5 -5
  55. package/dist/core/result.js.map +1 -1
  56. package/dist/core/retry.d.ts +5 -2
  57. package/dist/core/retry.js +6 -3
  58. package/dist/core/retry.js.map +1 -1
  59. package/dist/core/scope.d.ts +20 -0
  60. package/dist/core/scope.js +54 -0
  61. package/dist/core/scope.js.map +1 -0
  62. package/dist/core/shared.d.ts +39 -0
  63. package/dist/core/shared.js +177 -0
  64. package/dist/core/shared.js.map +1 -0
  65. package/dist/core/signal.d.ts +12 -0
  66. package/dist/core/signal.js +25 -0
  67. package/dist/core/signal.js.map +1 -0
  68. package/dist/flipstream.d.ts +223 -72
  69. package/dist/flipstream.js +225 -88
  70. package/dist/flipstream.js.map +1 -1
  71. package/dist/index.d.ts +1 -1
  72. package/dist/node/clientSecret.js +7 -6
  73. package/dist/node/clientSecret.js.map +1 -1
  74. package/dist/node/headless.d.ts +14 -6
  75. package/dist/node/headless.js +8 -6
  76. package/dist/node/headless.js.map +1 -1
  77. package/dist/node/index.d.ts +1 -1
  78. package/dist/node/index.js +1 -1
  79. package/dist/node/index.js.map +1 -1
  80. package/dist/node/keychainChild.js +26 -14
  81. package/dist/node/keychainChild.js.map +1 -1
  82. package/dist/node/keychainError.d.ts +3 -3
  83. package/dist/node/keychainStore.d.ts +10 -7
  84. package/dist/node/keychainStore.js +44 -23
  85. package/dist/node/keychainStore.js.map +1 -1
  86. package/dist/node/loopback.d.ts +13 -3
  87. package/dist/node/loopback.js +47 -5
  88. package/dist/node/loopback.js.map +1 -1
  89. package/dist/node/session.d.ts +17 -9
  90. package/dist/node/session.js +68 -50
  91. package/dist/node/session.js.map +1 -1
  92. package/dist/node/store.d.ts +35 -2
  93. package/dist/node/store.js +56 -12
  94. package/dist/node/store.js.map +1 -1
  95. package/dist/version.gen.js +1 -1
  96. package/docs/admin.md +558 -0
  97. package/docs/node-sign-in.md +63 -39
  98. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"identify.js","sourceRoot":"","sources":["../../src/core/identify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAuB3C,sGAAsG;AACtG,MAAM,aAAa,GAAG,qCAAqC,CAAA;AAC3D,MAAM,eAAe,GAAG,0BAA0B,CAAA;AAClD,qEAAqE;AACrE,MAAM,WAAW,GAAG,kDAAkD,CAAA;AACtE,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AACpC,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAErC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA8C,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAA;AAE5H;;;GAGG;AACH,SAAS,OAAO,CAAC,MAAc,EAAE,IAAY;IAC3C,OAAO,IAAI,SAAS,CAAC,qBAAqB,MAAM,YAAY,IAAI,+BAA+B,CAAC,CAAA;AAClG,CAAC;AAED,MAAM,YAAY,GAAG,8EAA8E,CAAA;AACnG,MAAM,iBAAiB,GAAG,yDAAyD,CAAA;AAEnF,SAAS,OAAO,CAAC,KAAc,EAAE,MAAc;IAC7C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,MAAM,OAAO,CAAC,MAAM,EAAE,2BAA2B,YAAY,EAAE,CAAC,CAAA;IACtF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,KAAK,CAAA;IAC/C,IAAI,OAAO,IAAI,KAAK,QA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AI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAClG,CAAC;IACD,OAAO,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAClF,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAyF;IAC9G,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IACpC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE;IACrC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE;IACtC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE;IACnC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;CACtC,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,OAAoB,EAAE,gBAAyB;IAC9F,OAAO,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,IAAI,gBAAgB,CAAA;AAC7G,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ApiError, 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): {
4
+ readonly ok: false;
5
+ readonly error: ApiError;
6
+ };
7
+ /** `invalid`, found by a check of an answer whose route answers 200 by its backend's own code. */
8
+ export declare const invalidAnswer: (issues: string) => ApiResult<never>;
9
+ /** `invalid`, found by a check of an answer whose route's success status isn't known: a create's. */
10
+ export declare const invalidStatusUnknown: (issues: string) => ApiResult<never>;
@@ -0,0 +1,28 @@
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
+ * On our own backends' routes its `status` is assumed, never observed. A read takes any 2xx as ok,
7
+ * and its data carries no status (#368's decision log dropped carrying one, since that would change
8
+ * every read's shape). So it's the success status the route answers by its backend's own code: 200
9
+ * for every GET the SDK sends to pulse-admin, pulse-auth and pulse-wallet, and for the two PUTs, whose
10
+ * pulse-admin routes declare it at dff6bf9b
11
+ * (adapters/connection/ingress/fastapi/__init__.py:423 and adapters/event_log/ingress/fastapi/__init__.py:164).
12
+ * Where a route's success status isn't known, there's none: the two creates, POST /clients and POST
13
+ * /event-logs, which come from a generic router with no recording of their answer.
14
+ *
15
+ * An authorisation server is any one the app names, so nothing in our code says how it answers: the
16
+ * RFC 8414 metadata discover() reads and the OpenID configuration a session reads take the 2xx
17
+ * call() heard instead (its `answered`), through invalidWith. A credentialed failure keeps its own
18
+ * status (clientSecret.ts's vouchedFor). #385 would take the observed status for every check.
19
+ */
20
+ /** `invalid` with `status`, a status the SDK knows, or with none when it's undefined. */
21
+ export function invalidWith(issues, status) {
22
+ return { ok: false, error: status === undefined ? { kind: 'invalid', issues } : { kind: 'invalid', issues, status } };
23
+ }
24
+ /** `invalid`, found by a check of an answer whose route answers 200 by its backend's own code. */
25
+ export const invalidAnswer = (issues) => invalidWith(issues, 200);
26
+ /** `invalid`, found by a check of an answer whose route's success status isn't known: a create's. */
27
+ export const invalidStatusUnknown = (issues) => invalidWith(issues, undefined);
28
+ //# sourceMappingURL=invalid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalid.js","sourceRoot":"","sources":["../../src/core/invalid.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;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"}
@@ -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];
@@ -89,8 +96,12 @@ export declare const RANKED: readonly ["owner", "admin", "editor", "viewer"];
89
96
  * doesn't know reads as one it has never seen (#265), so this list must follow pulse-auth's. The one
90
97
  * list (#268): the live scripts read it from the build, through `roleFromBackend`, to stop a staff
91
98
  * sign-in, and the tests walk it. Frozen, so nobody changes the SDK's rule by changing it, and not
92
- * exported from the package. Two places name these roles in words and change with it by hand: the
93
- * README's role bullet and `Member.role`'s doc in src/api/members.ts.
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.
94
105
  */
95
106
  export declare const STAFF_ROLES: readonly string[];
96
107
  /**
@@ -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,
@@ -98,8 +103,12 @@ void everyRole; // read once, so unused-locals checks keep it
98
103
  * doesn't know reads as one it has never seen (#265), so this list must follow pulse-auth's. The one
99
104
  * list (#268): the live scripts read it from the build, through `roleFromBackend`, to stop a staff
100
105
  * sign-in, and the tests walk it. Frozen, so nobody changes the SDK's rule by changing it, and not
101
- * exported from the package. Two places name these roles in words and change with it by hand: the
102
- * README's role bullet and `Member.role`'s doc in src/api/members.ts.
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.
103
112
  */
104
113
  export const STAFF_ROLES = Object.freeze(['godmode', 'swapper']);
105
114
  const STAFF = new Set(STAFF_ROLES);
@@ -1 +1 @@
1
- {"version":3,"file":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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"}
@@ -4,6 +4,15 @@ import type { ServiceName, TransportResult } from './transport.js';
4
4
  type NoAnswer = Exclude<TransportResult, {
5
5
  readonly kind: 'response';
6
6
  }>;
7
+ /** readJson's issue for a 2xx whose body isn't JSON: a proxy's or a portal's page, never the host's answer. */
8
+ export declare const NOT_JSON = "the body is not JSON";
9
+ /**
10
+ * `value`, a 2xx's JSON, read by `schema`: the data, or `invalid` with the response's `status`.
11
+ * readJson's own last step, and the one a scope's shared read takes for each call (#377's code
12
+ * review, 10), so both give one shape, status and issue text. Zod's issues name paths and expected
13
+ * types, never the body's values.
14
+ */
15
+ export declare function readParsed<T>(value: unknown, schema: z.ZodType<T>, status: number): ApiResult<T>;
7
16
  /** Why a transport has no answer to read. */
8
17
  export declare function noAnswer(sent: NoAnswer): ApiError;
9
18
  /**
package/dist/core/read.js CHANGED
@@ -5,6 +5,18 @@ import { classifyStatus } from './result.js';
5
5
  // compile here until it's mapped. Checked as an own key, because an app's own transport may be
6
6
  // plain JavaScript and give any (#199).
7
7
  const FROM_TRANSPORT = { destination: true, identification: true };
8
+ /** readJson's issue for a 2xx whose body isn't JSON: a proxy's or a portal's page, never the host's answer. */
9
+ export const NOT_JSON = 'the body is not JSON';
10
+ /**
11
+ * `value`, a 2xx's JSON, read by `schema`: the data, or `invalid` with the response's `status`.
12
+ * readJson's own last step, and the one a scope's shared read takes for each call (#377's code
13
+ * review, 10), so both give one shape, status and issue text. Zod's issues name paths and expected
14
+ * types, never the body's values.
15
+ */
16
+ export function readParsed(value, schema, status) {
17
+ const parsed = schema.safeParse(value);
18
+ return parsed.success ? { ok: true, data: parsed.data } : failed({ kind: 'invalid', issues: z.prettifyError(parsed.error), status });
19
+ }
8
20
  /** Why a transport has no answer to read. */
9
21
  export function noAnswer(sent) {
10
22
  switch (sent.kind) {
@@ -53,11 +65,8 @@ export async function readJson(sent, schema, signal, service, keepsNoText = fals
53
65
  }
54
66
  const json = parseJson(body.text);
55
67
  if (!json.ok)
56
- return failed(keepsNoText ? { kind: 'invalid', issues: 'the body is not JSON', status } : { kind: 'invalid', issues: 'the body is not JSON', status, text: body.text });
57
- const parsed = schema.safeParse(json.value);
58
- if (!parsed.success)
59
- return failed({ kind: 'invalid', issues: z.prettifyError(parsed.error), status });
60
- return { ok: true, data: parsed.data };
68
+ return failed(keepsNoText ? { kind: 'invalid', issues: NOT_JSON, status } : { kind: 'invalid', issues: NOT_JSON, status, text: body.text });
69
+ return readParsed(json.value, schema, status);
61
70
  }
62
71
  /**
63
72
  * The whole body as text, or why there is none: the caller aborted, or it broke off. A
@@ -1 +1 @@
1
- {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/core/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAiC,MAAM,aAAa,CAAA;AAM3E,8FAA8F;AAC9F,+FAA+F;AAC/F,wCAAwC;AACxC,MAAM,cAAc,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAoD,CAAA;AAEpH,6CAA6C;AAC7C,MAAM,UAAU,QAAQ,CAAC,IAAc;IACrC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;YACvB,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;QAClG,CAAC;QACD,KAAK,aAAa;YAChB,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAA;QAChC,KAAK,WAAW;YACd,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;QAC9B,KAAK,SAAS;YACZ,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;QAC5B,KAAK,UAAU;YACb,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAA;QAChD,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,SAAS,GAAU,IAAI,CAAA;YAC7B,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC5E,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AED,MAAM,MAAM,GAAG,CAAC,KAAe,EAAoD,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA"}
@@ -1,17 +1,19 @@
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). `traceId` is the W3C
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
- * request carrying it went out, on either arm, and absent when nothing was sent.
5
+ * request carrying it went out, on either arm, and absent when nothing was sent. In a scope (#376),
6
+ * a shared read goes out under a trace of its own, and a call it answered names that trace: the
7
+ * read's whose failure is the answer, else the call's own, else the first shared read it asked for.
6
8
  */
7
9
  export type ApiResult<T> = {
8
10
  readonly ok: true;
9
11
  readonly data: T;
10
- readonly traceId?: string;
12
+ readonly trace_id?: string;
11
13
  } | {
12
14
  readonly ok: false;
13
15
  readonly error: ApiError;
14
- readonly traceId?: string;
16
+ readonly trace_id?: string;
15
17
  };
16
18
  /** The failures a status gives: the host answered, and said no. */
17
19
  export type StatusKind = 'unauthorized' | 'forbidden' | 'not_found' | 'conflict' | 'rejected' | 'unavailable';
@@ -32,25 +34,25 @@ export type Said = {
32
34
  readonly code: ErrorCode;
33
35
  readonly message: string;
34
36
  /** The request's id, once a host sends one. None does yet (D429). */
35
- readonly requestId?: string;
37
+ readonly request_id?: string;
36
38
  readonly text?: never;
37
39
  } | {
38
40
  readonly text: string;
39
41
  readonly code?: never;
40
42
  readonly message?: never;
41
- readonly requestId?: never;
43
+ readonly request_id?: never;
42
44
  } | {
43
45
  readonly text?: never;
44
46
  readonly code?: never;
45
47
  readonly message?: never;
46
- readonly requestId?: never;
48
+ readonly request_id?: never;
47
49
  };
48
50
  /** A failure the host answered with a status, and what came with it. */
49
51
  export type Answered = {
50
52
  readonly kind: StatusKind;
51
53
  readonly status: number;
52
54
  /** How long the host asked the caller to wait (`Retry-After`), when it said so. */
53
- readonly retryAfterMs?: number;
55
+ readonly retry_after_ms?: number;
54
56
  } & Said;
55
57
  export type ApiError = Answered
56
58
  /** No answer at all: offline, a body that broke off, or no token right now. */
@@ -59,8 +61,15 @@ export type ApiError = Answered
59
61
  readonly status?: never;
60
62
  }
61
63
  /**
62
- * Outside the contract: reported, never shown as empty. `status` is the response's, when one
63
- * arrived; `text` is its body, when a 2xx body is not JSON.
64
+ * Outside the contract: reported, never shown as empty. `status` is set on a failure from an
65
+ * answer whose status the SDK knows. When the answer's own status or shape is outside the
66
+ * contract, or a read after pause's or resume's write failed, it's the response's. When a check
67
+ * after the read found it (#368), on an authorisation server's answer (discover()'s metadata, a
68
+ * session's OpenID configuration) it's the 2xx that server answered, since any server can be
69
+ * named there. On Flipstream's own routes it's the success status that route answers by its
70
+ * backend's own code, 200 for every read and both PUTs, assumed from a 2xx and never observed
71
+ * until #385. A create's answer has none, since its route's success status isn't known. `text` is
72
+ * its body, when a 2xx body is not JSON.
64
73
  */
65
74
  | {
66
75
  readonly kind: 'invalid';
@@ -141,8 +150,8 @@ export type RefusedReason =
141
150
  | 'callback';
142
151
  /**
143
152
  * A failed call, thrown by `orThrow`, carrying its `ApiError`. When the call's requests went out
144
- * under a trace (#251), it carries that `traceId` too (#262), and its message ends with
145
- * `(request <traceId>)`, so whoever catches or prints it can find them in Logs.
153
+ * under a trace (#251), it carries that `trace_id` too (#262), and its message ends with
154
+ * `(request <trace_id>)`, so whoever catches or prints it can find them in Logs.
146
155
  */
147
156
  export declare class ApiFailure extends Error {
148
157
  readonly error: ApiError;
@@ -150,7 +159,7 @@ export declare class ApiFailure extends Error {
150
159
  * The call's W3C trace-id, when its requests went out under one; absent otherwise. Declared, not
151
160
  * defined, so a class field doesn't make it an own property holding `undefined`.
152
161
  */
153
- readonly traceId?: string;
162
+ readonly trace_id?: string;
154
163
  constructor(error: ApiError, traceId?: string);
155
164
  }
156
165
  /** The data, or the failure thrown as `ApiFailure`, for callers who want exceptions (D412). */
@@ -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 `traceId` too (#262), and its message ends with
54
- * `(request <traceId>)`, so whoever catches or prints it can find them in Logs.
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 `'traceId' in failure` means one went out.
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.traceId = traced;
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.traceId);
72
+ throw new ApiFailure(result.error, result.trace_id);
73
73
  return result.data;
74
74
  }
75
75
  //# sourceMappingURL=result.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/core/result.ts"],"names":[],"mappings":"AAoHA;;;;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;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long. A wait that would not end
25
- * before `deadline` is not started: the outcome is the answer, and the caller decides.
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, now: number, deadline: number): Decision;
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`.
@@ -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
- * before `deadline` is not started: the outcome is the answer, and the caller decides.
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, now, deadline) {
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 now + ms < deadline ? { kind: 'wait', ms } : STOP;
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
@@ -1 +1 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/core/retry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,oGAAoG;AACpG,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAC7E,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,IAAI,GAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AAEvC;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,IAAe,EAAE,OAAe,EAAE,OAAgB,EAAE,GAAW,EAAE,QAAgB;IACtG,IAAI,IAAI,KAAK,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,IAAI,OAAO,GAAG,WAAW;QAAE,OAAO,IAAI,CAAA;IACtF,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAA;IAClF,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC7F,wFAAwF;IACxF,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAChD,OAAO,GAAG,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAA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AC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAChD,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,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;IACD,IAAI,OAAmG,CAAA;IACvG,IAAI,CAAC;QACH,OAAO,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAA;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IAChC,CAAC;IACD,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAChB,6FAA6F;IAC7F,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAI,CAAC;QAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACjC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAA;QACrB,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAoC,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,CAAC,CAAA;IACvI,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,QAAQ,CAAC,MAAM,CAAA;IACjD,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,OAAO,CAAC,KAAK,CAAA;IACpC,OAAO,OAAO,CAAC,KAAK,CAAA;AACtB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { CallSpec } from './call.js';
2
+ import type { Deadline } from './deadline.js';
3
+ import { type ApiResult } from './result.js';
4
+ /** How a spec is shared in a scope (`CallSpec.shared`): its key, with its endpoint's, names one read. */
5
+ export interface SharedRule {
6
+ /** The path the read asks for, as the seam builds it, so no request is built to name it. */
7
+ readonly key: string;
8
+ }
9
+ /** One call waiting on a shared read: its own deadline, its caller's signal, and its own end (#349). */
10
+ export interface Waiter {
11
+ readonly deadline: Deadline;
12
+ readonly signal: AbortSignal | undefined;
13
+ readonly end: AbortSignal;
14
+ }
15
+ /**
16
+ * How a shared read is sent: `spec`, its answer read as JSON and left unchecked, under `deadlineMs`,
17
+ * its starter's, and ended by `end`, never by one call's signal. `answered` hears the 2xx's status.
18
+ * Its `origin` is what the scope hands each call it answers: the read's own trace, in the client.
19
+ */
20
+ export type StartRead<O> = (spec: CallSpec<unknown>, deadlineMs: number, end: AbortSignal, answered: (status: number) => void) => {
21
+ readonly answer: Promise<ApiResult<unknown>>;
22
+ readonly origin: O;
23
+ };
24
+ /** What a call heard from a shared read: its result, and the read that answered it, when one did. */
25
+ export interface Heard<T, O> {
26
+ readonly result: ApiResult<T>;
27
+ readonly origin: O | undefined;
28
+ }
29
+ /** A scope's shared reads. */
30
+ export interface SharedReads<O> {
31
+ /** True until the scope closes; then every call reads its own, as outside a scope. */
32
+ readonly isOpen: () => boolean;
33
+ /** `spec`'s answer for `waiter`, from the one read the scope makes of it, started with `start` when none is kept. */
34
+ read<T>(spec: CallSpec<T>, rule: SharedRule, waiter: Waiter, start: StartRead<O>): Promise<Heard<T, O>>;
35
+ /** Closes the scope: ends every shared read still in flight, and answers once each has settled. */
36
+ close(): Promise<void>;
37
+ }
38
+ /** The reads of one scope, empty and open. */
39
+ export declare function sharedReads<O>(): SharedReads<O>;