@flipstream/sdk 0.6.0 → 0.8.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 (57) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +260 -43
  3. package/dist/auth/discovery.d.ts +5 -4
  4. package/dist/auth/discovery.js +10 -8
  5. package/dist/auth/discovery.js.map +1 -1
  6. package/dist/auth/signIn.js +10 -5
  7. package/dist/auth/signIn.js.map +1 -1
  8. package/dist/auth/transport.d.ts +20 -2
  9. package/dist/auth/transport.js +25 -5
  10. package/dist/auth/transport.js.map +1 -1
  11. package/dist/core/fetch.d.ts +5 -0
  12. package/dist/core/fetch.js +8 -1
  13. package/dist/core/fetch.js.map +1 -1
  14. package/dist/flipstream.d.ts +8 -0
  15. package/dist/flipstream.js +4 -3
  16. package/dist/flipstream.js.map +1 -1
  17. package/dist/index.d.ts +2 -1
  18. package/dist/index.js +2 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/node/fileLock.d.ts +21 -0
  21. package/dist/node/fileLock.js +23 -54
  22. package/dist/node/fileLock.js.map +1 -1
  23. package/dist/node/fileStore.d.ts +23 -1
  24. package/dist/node/fileStore.js +20 -18
  25. package/dist/node/fileStore.js.map +1 -1
  26. package/dist/node/index.d.ts +2 -0
  27. package/dist/node/index.js +1 -0
  28. package/dist/node/index.js.map +1 -1
  29. package/dist/node/keychainChild.js +146 -54
  30. package/dist/node/keychainChild.js.map +1 -1
  31. package/dist/node/keychainError.d.ts +53 -0
  32. package/dist/node/keychainError.js +48 -0
  33. package/dist/node/keychainError.js.map +1 -0
  34. package/dist/node/keychainStore.d.ts +20 -9
  35. package/dist/node/keychainStore.js +207 -58
  36. package/dist/node/keychainStore.js.map +1 -1
  37. package/dist/node/loopback.js +1 -1
  38. package/dist/node/loopback.js.map +1 -1
  39. package/dist/node/session.d.ts +42 -3
  40. package/dist/node/session.js +95 -18
  41. package/dist/node/session.js.map +1 -1
  42. package/dist/node/store.d.ts +5 -1
  43. package/dist/node/store.js +12 -4
  44. package/dist/node/store.js.map +1 -1
  45. package/dist/query/catalog.d.ts +271 -2
  46. package/dist/query/catalog.js +93 -5
  47. package/dist/query/catalog.js.map +1 -1
  48. package/dist/query/query.d.ts +14 -5
  49. package/dist/query/query.js +21 -6
  50. package/dist/query/query.js.map +1 -1
  51. package/dist/spec/query-planner/index.d.ts +1 -1
  52. package/dist/spec/query-planner/types.gen.d.ts +35 -4
  53. package/dist/spec/query-planner/zod.gen.d.ts +257 -64
  54. package/dist/spec/query-planner/zod.gen.js +31 -5
  55. package/dist/spec/query-planner/zod.gen.js.map +1 -1
  56. package/dist/version.gen.js +1 -1
  57. package/package.json +1 -1
@@ -1,12 +1,281 @@
1
+ import { z } from 'zod';
1
2
  import type { CallSpec } from '../core/call.js';
2
3
  import type { Catalog, CatalogSource } from '../spec/query-planner/types.gen.js';
4
+ /**
5
+ * Where the SDK's warnings go (#171, D509): an app's `onWarning`, or `console.warn`. A handler
6
+ * that throws is ignored, so it can't break the read that warned.
7
+ */
8
+ export type Warn = (message: string) => void;
9
+ /** The default handler, `console.warn` as it is when a warning is given, not when the SDK loaded. */
10
+ export declare const consoleWarn: Warn;
3
11
  /** `GET /catalog`: every source the caller may query, with its dimensions and metrics. */
4
- export declare function catalogList(base: string): CallSpec<Catalog>;
12
+ export declare function catalogList(base: string, warn?: Warn): CallSpec<Catalog>;
5
13
  /**
6
14
  * `GET /catalog/{source}`: one source. Null when `source` can't stay one path segment, so the
7
15
  * call is refused before anything is sent.
8
16
  */
9
- export declare function catalogGet(base: string, source: string): CallSpec<CatalogSource> | null;
17
+ export declare function catalogGet(base: string, source: string, warn?: Warn): CallSpec<CatalogSource> | null;
18
+ /**
19
+ * The catalogue's answers as the SDK reads them: each format whose type this SDK doesn't know read
20
+ * as the unknown arm first, then the spec's schema. Read a catalogue with these, never with the
21
+ * bare generated schema, which refuses such a type and so the whole answer (D493).
22
+ */
23
+ export declare const catalogAnswerFor: (warn: Warn) => z.ZodPreprocess<z.ZodObject<{
24
+ catalogVersion: z.ZodString;
25
+ generatedAt: z.ZodString;
26
+ modelContractVersion: z.ZodString;
27
+ homepage: z.ZodString;
28
+ license: z.ZodString;
29
+ defaultSource: z.ZodString;
30
+ sources: z.ZodArray<z.ZodObject<{
31
+ name: z.ZodString;
32
+ label: z.ZodString;
33
+ description: z.ZodString;
34
+ dimensions: z.ZodArray<z.ZodObject<{
35
+ name: z.ZodString;
36
+ label: z.ZodString;
37
+ description: z.ZodString;
38
+ format: z.ZodDiscriminatedUnion<[z.ZodObject<{
39
+ type: z.ZodLiteral<"number">;
40
+ decimals: z.ZodInt;
41
+ thousandSeparator: z.ZodExactOptional<z.ZodBoolean>;
42
+ }, z.core.$loose>, z.ZodObject<{
43
+ type: z.ZodLiteral<"currency">;
44
+ decimals: z.ZodInt;
45
+ }, z.core.$loose>, z.ZodObject<{
46
+ type: z.ZodLiteral<"percentage">;
47
+ decimals: z.ZodInt;
48
+ }, z.core.$loose>, z.ZodObject<{
49
+ type: z.ZodLiteral<"date">;
50
+ format: z.ZodLiteral<"YYYY-MM-DD">;
51
+ }, z.core.$loose>, z.ZodObject<{
52
+ type: z.ZodLiteral<"string">;
53
+ }, z.core.$loose>, z.ZodObject<{
54
+ type: z.ZodLiteral<"unknown">;
55
+ declared: z.ZodString;
56
+ }, z.core.$loose>], "type">;
57
+ }, z.core.$loose>>;
58
+ metrics: z.ZodArray<z.ZodObject<{
59
+ name: z.ZodString;
60
+ label: z.ZodString;
61
+ description: z.ZodString;
62
+ format: z.ZodDiscriminatedUnion<[z.ZodObject<{
63
+ type: z.ZodLiteral<"number">;
64
+ decimals: z.ZodInt;
65
+ thousandSeparator: z.ZodExactOptional<z.ZodBoolean>;
66
+ }, z.core.$loose>, z.ZodObject<{
67
+ type: z.ZodLiteral<"currency">;
68
+ decimals: z.ZodInt;
69
+ }, z.core.$loose>, z.ZodObject<{
70
+ type: z.ZodLiteral<"percentage">;
71
+ decimals: z.ZodInt;
72
+ }, z.core.$loose>, z.ZodObject<{
73
+ type: z.ZodLiteral<"date">;
74
+ format: z.ZodLiteral<"YYYY-MM-DD">;
75
+ }, z.core.$loose>, z.ZodObject<{
76
+ type: z.ZodLiteral<"string">;
77
+ }, z.core.$loose>, z.ZodObject<{
78
+ type: z.ZodLiteral<"unknown">;
79
+ declared: z.ZodString;
80
+ }, z.core.$loose>], "type">;
81
+ lowerIsBetter: z.ZodExactOptional<z.ZodBoolean>;
82
+ }, z.core.$loose>>;
83
+ customDimensions: z.ZodExactOptional<z.ZodObject<{
84
+ supported: z.ZodBoolean;
85
+ max: z.ZodInt;
86
+ resolve: z.ZodString;
87
+ }, z.core.$loose>>;
88
+ }, z.core.$loose>>;
89
+ }, z.core.$loose>, unknown>;
90
+ export declare const sourceAnswerFor: (warn: Warn) => z.ZodPreprocess<z.ZodIntersection<z.ZodObject<{
91
+ name: z.ZodString;
92
+ label: z.ZodString;
93
+ description: z.ZodString;
94
+ dimensions: z.ZodArray<z.ZodObject<{
95
+ name: z.ZodString;
96
+ label: z.ZodString;
97
+ description: z.ZodString;
98
+ format: z.ZodDiscriminatedUnion<[z.ZodObject<{
99
+ type: z.ZodLiteral<"number">;
100
+ decimals: z.ZodInt;
101
+ thousandSeparator: z.ZodExactOptional<z.ZodBoolean>;
102
+ }, z.core.$loose>, z.ZodObject<{
103
+ type: z.ZodLiteral<"currency">;
104
+ decimals: z.ZodInt;
105
+ }, z.core.$loose>, z.ZodObject<{
106
+ type: z.ZodLiteral<"percentage">;
107
+ decimals: z.ZodInt;
108
+ }, z.core.$loose>, z.ZodObject<{
109
+ type: z.ZodLiteral<"date">;
110
+ format: z.ZodLiteral<"YYYY-MM-DD">;
111
+ }, z.core.$loose>, z.ZodObject<{
112
+ type: z.ZodLiteral<"string">;
113
+ }, z.core.$loose>, z.ZodObject<{
114
+ type: z.ZodLiteral<"unknown">;
115
+ declared: z.ZodString;
116
+ }, z.core.$loose>], "type">;
117
+ }, z.core.$loose>>;
118
+ metrics: z.ZodArray<z.ZodObject<{
119
+ name: z.ZodString;
120
+ label: z.ZodString;
121
+ description: z.ZodString;
122
+ format: z.ZodDiscriminatedUnion<[z.ZodObject<{
123
+ type: z.ZodLiteral<"number">;
124
+ decimals: z.ZodInt;
125
+ thousandSeparator: z.ZodExactOptional<z.ZodBoolean>;
126
+ }, z.core.$loose>, z.ZodObject<{
127
+ type: z.ZodLiteral<"currency">;
128
+ decimals: z.ZodInt;
129
+ }, z.core.$loose>, z.ZodObject<{
130
+ type: z.ZodLiteral<"percentage">;
131
+ decimals: z.ZodInt;
132
+ }, z.core.$loose>, z.ZodObject<{
133
+ type: z.ZodLiteral<"date">;
134
+ format: z.ZodLiteral<"YYYY-MM-DD">;
135
+ }, z.core.$loose>, z.ZodObject<{
136
+ type: z.ZodLiteral<"string">;
137
+ }, z.core.$loose>, z.ZodObject<{
138
+ type: z.ZodLiteral<"unknown">;
139
+ declared: z.ZodString;
140
+ }, z.core.$loose>], "type">;
141
+ lowerIsBetter: z.ZodExactOptional<z.ZodBoolean>;
142
+ }, z.core.$loose>>;
143
+ customDimensions: z.ZodExactOptional<z.ZodObject<{
144
+ supported: z.ZodBoolean;
145
+ max: z.ZodInt;
146
+ resolve: z.ZodString;
147
+ }, z.core.$loose>>;
148
+ }, z.core.$loose>, z.ZodObject<{
149
+ catalogVersion: z.ZodString;
150
+ }, z.core.$loose>>, unknown>;
151
+ export declare const catalogAnswer: z.ZodPreprocess<z.ZodObject<{
152
+ catalogVersion: z.ZodString;
153
+ generatedAt: z.ZodString;
154
+ modelContractVersion: z.ZodString;
155
+ homepage: z.ZodString;
156
+ license: z.ZodString;
157
+ defaultSource: z.ZodString;
158
+ sources: z.ZodArray<z.ZodObject<{
159
+ name: z.ZodString;
160
+ label: z.ZodString;
161
+ description: z.ZodString;
162
+ dimensions: z.ZodArray<z.ZodObject<{
163
+ name: z.ZodString;
164
+ label: z.ZodString;
165
+ description: z.ZodString;
166
+ format: z.ZodDiscriminatedUnion<[z.ZodObject<{
167
+ type: z.ZodLiteral<"number">;
168
+ decimals: z.ZodInt;
169
+ thousandSeparator: z.ZodExactOptional<z.ZodBoolean>;
170
+ }, z.core.$loose>, z.ZodObject<{
171
+ type: z.ZodLiteral<"currency">;
172
+ decimals: z.ZodInt;
173
+ }, z.core.$loose>, z.ZodObject<{
174
+ type: z.ZodLiteral<"percentage">;
175
+ decimals: z.ZodInt;
176
+ }, z.core.$loose>, z.ZodObject<{
177
+ type: z.ZodLiteral<"date">;
178
+ format: z.ZodLiteral<"YYYY-MM-DD">;
179
+ }, z.core.$loose>, z.ZodObject<{
180
+ type: z.ZodLiteral<"string">;
181
+ }, z.core.$loose>, z.ZodObject<{
182
+ type: z.ZodLiteral<"unknown">;
183
+ declared: z.ZodString;
184
+ }, z.core.$loose>], "type">;
185
+ }, z.core.$loose>>;
186
+ metrics: z.ZodArray<z.ZodObject<{
187
+ name: z.ZodString;
188
+ label: z.ZodString;
189
+ description: z.ZodString;
190
+ format: z.ZodDiscriminatedUnion<[z.ZodObject<{
191
+ type: z.ZodLiteral<"number">;
192
+ decimals: z.ZodInt;
193
+ thousandSeparator: z.ZodExactOptional<z.ZodBoolean>;
194
+ }, z.core.$loose>, z.ZodObject<{
195
+ type: z.ZodLiteral<"currency">;
196
+ decimals: z.ZodInt;
197
+ }, z.core.$loose>, z.ZodObject<{
198
+ type: z.ZodLiteral<"percentage">;
199
+ decimals: z.ZodInt;
200
+ }, z.core.$loose>, z.ZodObject<{
201
+ type: z.ZodLiteral<"date">;
202
+ format: z.ZodLiteral<"YYYY-MM-DD">;
203
+ }, z.core.$loose>, z.ZodObject<{
204
+ type: z.ZodLiteral<"string">;
205
+ }, z.core.$loose>, z.ZodObject<{
206
+ type: z.ZodLiteral<"unknown">;
207
+ declared: z.ZodString;
208
+ }, z.core.$loose>], "type">;
209
+ lowerIsBetter: z.ZodExactOptional<z.ZodBoolean>;
210
+ }, z.core.$loose>>;
211
+ customDimensions: z.ZodExactOptional<z.ZodObject<{
212
+ supported: z.ZodBoolean;
213
+ max: z.ZodInt;
214
+ resolve: z.ZodString;
215
+ }, z.core.$loose>>;
216
+ }, z.core.$loose>>;
217
+ }, z.core.$loose>, unknown>;
218
+ export declare const sourceAnswer: z.ZodPreprocess<z.ZodIntersection<z.ZodObject<{
219
+ name: z.ZodString;
220
+ label: z.ZodString;
221
+ description: z.ZodString;
222
+ dimensions: z.ZodArray<z.ZodObject<{
223
+ name: z.ZodString;
224
+ label: z.ZodString;
225
+ description: z.ZodString;
226
+ format: z.ZodDiscriminatedUnion<[z.ZodObject<{
227
+ type: z.ZodLiteral<"number">;
228
+ decimals: z.ZodInt;
229
+ thousandSeparator: z.ZodExactOptional<z.ZodBoolean>;
230
+ }, z.core.$loose>, z.ZodObject<{
231
+ type: z.ZodLiteral<"currency">;
232
+ decimals: z.ZodInt;
233
+ }, z.core.$loose>, z.ZodObject<{
234
+ type: z.ZodLiteral<"percentage">;
235
+ decimals: z.ZodInt;
236
+ }, z.core.$loose>, z.ZodObject<{
237
+ type: z.ZodLiteral<"date">;
238
+ format: z.ZodLiteral<"YYYY-MM-DD">;
239
+ }, z.core.$loose>, z.ZodObject<{
240
+ type: z.ZodLiteral<"string">;
241
+ }, z.core.$loose>, z.ZodObject<{
242
+ type: z.ZodLiteral<"unknown">;
243
+ declared: z.ZodString;
244
+ }, z.core.$loose>], "type">;
245
+ }, z.core.$loose>>;
246
+ metrics: z.ZodArray<z.ZodObject<{
247
+ name: z.ZodString;
248
+ label: z.ZodString;
249
+ description: z.ZodString;
250
+ format: z.ZodDiscriminatedUnion<[z.ZodObject<{
251
+ type: z.ZodLiteral<"number">;
252
+ decimals: z.ZodInt;
253
+ thousandSeparator: z.ZodExactOptional<z.ZodBoolean>;
254
+ }, z.core.$loose>, z.ZodObject<{
255
+ type: z.ZodLiteral<"currency">;
256
+ decimals: z.ZodInt;
257
+ }, z.core.$loose>, z.ZodObject<{
258
+ type: z.ZodLiteral<"percentage">;
259
+ decimals: z.ZodInt;
260
+ }, z.core.$loose>, z.ZodObject<{
261
+ type: z.ZodLiteral<"date">;
262
+ format: z.ZodLiteral<"YYYY-MM-DD">;
263
+ }, z.core.$loose>, z.ZodObject<{
264
+ type: z.ZodLiteral<"string">;
265
+ }, z.core.$loose>, z.ZodObject<{
266
+ type: z.ZodLiteral<"unknown">;
267
+ declared: z.ZodString;
268
+ }, z.core.$loose>], "type">;
269
+ lowerIsBetter: z.ZodExactOptional<z.ZodBoolean>;
270
+ }, z.core.$loose>>;
271
+ customDimensions: z.ZodExactOptional<z.ZodObject<{
272
+ supported: z.ZodBoolean;
273
+ max: z.ZodInt;
274
+ resolve: z.ZodString;
275
+ }, z.core.$loose>>;
276
+ }, z.core.$loose>, z.ZodObject<{
277
+ catalogVersion: z.ZodString;
278
+ }, z.core.$loose>>, unknown>;
10
279
  /**
11
280
  * A value bound for one path segment, encoded, so `/`, `?` and `#` stay inside it; or null for
12
281
  * '', '.' and '..', which a URL reads as steps, not names (`/catalog/..` is `/`), and for a value
@@ -1,18 +1,24 @@
1
- import { zCatalogCatalogGetResponse, zCatalogSourceCatalogSourceGetResponse } from '../spec/query-planner/zod.gen.js';
1
+ import { z } from 'zod';
2
+ import { zCatalogCatalogGetResponse, zCatalogSourceCatalogSourceGetResponse, zFormat } from '../spec/query-planner/zod.gen.js';
3
+ import { version } from '../version.gen.js';
2
4
  /*
3
5
  * The planner's catalogue: what each call sends, and the rules it is sent under, next to its
4
6
  * schema. Reads, so a failed connection or an outage is tried again (D414).
5
7
  */
6
8
  const READ = { effect: 'read', service: 'query', deadlineMs: 30_000, retry: 'read' };
9
+ /** The default handler, `console.warn` as it is when a warning is given, not when the SDK loaded. */
10
+ export const consoleWarn = (message) => {
11
+ console.warn(message);
12
+ };
7
13
  /** `GET /catalog`: every source the caller may query, with its dimensions and metrics. */
8
- export function catalogList(base) {
9
- return { ...READ, endpoint: 'catalog.list', makeRequest: () => new Request(`${base}/catalog`), schema: zCatalogCatalogGetResponse };
14
+ export function catalogList(base, warn = consoleWarn) {
15
+ return { ...READ, endpoint: 'catalog.list', makeRequest: () => new Request(`${base}/catalog`), schema: catalogAnswerFor(warn) };
10
16
  }
11
17
  /**
12
18
  * `GET /catalog/{source}`: one source. Null when `source` can't stay one path segment, so the
13
19
  * call is refused before anything is sent.
14
20
  */
15
- export function catalogGet(base, source) {
21
+ export function catalogGet(base, source, warn = consoleWarn) {
16
22
  const name = segment(source);
17
23
  if (name === null)
18
24
  return null;
@@ -20,9 +26,91 @@ export function catalogGet(base, source) {
20
26
  ...READ,
21
27
  endpoint: 'catalog.get',
22
28
  makeRequest: () => new Request(`${base}/catalog/${name}`),
23
- schema: zCatalogSourceCatalogSourceGetResponse,
29
+ schema: sourceAnswerFor(warn),
24
30
  };
25
31
  }
32
+ /*
33
+ * A field's format (#35, D493). data-model leaves a format's `type` an open string, so the
34
+ * catalogue can add one in a minor release. A type this SDK doesn't know is read as the unknown
35
+ * arm, naming the type it came as, so one field never makes the whole catalogue unreadable. A
36
+ * known type still needs its whole shape: the schema checks that next, and a part missing fails
37
+ * the answer, naming the field. Anything that isn't shaped like a catalogue is left for the schema
38
+ * to refuse.
39
+ */
40
+ // The types the spec gives a shape, read from its schema, so the overlay stays their one list.
41
+ // `unknown` is the SDK's own arm, never a type the catalogue sends.
42
+ const KNOWN = new Set(zFormat.options.map((option) => option.shape.type.value).filter((type) => type !== 'unknown'));
43
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
44
+ function readCatalog(answer, warn) {
45
+ if (!isRecord(answer) || !Array.isArray(answer.sources))
46
+ return answer;
47
+ return { ...answer, sources: answer.sources.map((entry) => readSource(entry, warn)) };
48
+ }
49
+ function readSource(entry, warn) {
50
+ if (!isRecord(entry))
51
+ return entry;
52
+ const read = { ...entry };
53
+ for (const key of ['metrics', 'dimensions']) {
54
+ const fields = entry[key];
55
+ if (!Array.isArray(fields))
56
+ continue;
57
+ read[key] = fields.map((field) => {
58
+ if (!isRecord(field) || !Object.hasOwn(field, 'format'))
59
+ return field;
60
+ return { ...field, format: readFormat(field.format, () => `${nameOf(entry)}.${nameOf(field)}`, warn) };
61
+ });
62
+ }
63
+ return read;
64
+ }
65
+ // A source's or a field's name, as the catalogue gives it; the schema refuses one that isn't a string.
66
+ const nameOf = (named) => (typeof named.name === 'string' ? named.name : '?');
67
+ /** `format`, or the unknown arm when its type is one this SDK doesn't know; `where` names the field. */
68
+ function readFormat(format, where, warn) {
69
+ // A type that isn't a name isn't a type this SDK might learn: the schema refuses it.
70
+ if (!isRecord(format) || typeof format.type !== 'string' || KNOWN.has(format.type))
71
+ return format;
72
+ warnOnce(format.type, where, warn);
73
+ return { ...format, type: 'unknown', declared: format.type };
74
+ }
75
+ // Every control, format or separator character JSON leaves as it is (DEL, C1 and NEL, bidi
76
+ // overrides, U+2028 and U+2029), escaped, so a viewer can't split or reorder a log line. By UTF-16
77
+ // code unit, as JSON does: a character outside the BMP becomes its surrogate pair, so the text
78
+ // still reads back as it came.
79
+ const unit = (char, index) => `\\u${char.charCodeAt(index).toString(16).padStart(4, '0')}`;
80
+ const visible = (text) => text.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu, (char) => Array.from({ length: char.length }, (_, index) => unit(char, index)).join(''));
81
+ // A note that the SDK needs updating, once per process for each type, never per field or call
82
+ // (D494), handed to the reading client's `warn` (#171): a type is reported once, to whichever
83
+ // client read it first. It names the SDK's version, the type (quoted as JSON), where it was first seen (the
84
+ // source and the field's name, as a builder can search the catalogue for them), and how to
85
+ // update. Never a label, a value or a token.
86
+ const warned = new Set();
87
+ function warnOnce(type, where, warn) {
88
+ if (warned.has(type))
89
+ return;
90
+ warned.add(type);
91
+ const quoted = visible(JSON.stringify(type));
92
+ const seen = visible(JSON.stringify(where()).slice(1, -1));
93
+ // The app's handler may fail, or be async and reject: either way the read goes on, with the
94
+ // unknown arm, and no rejection is left unhandled to end the process (#171).
95
+ try {
96
+ const returned = warn(`@flipstream/sdk ${version} doesn't know format type ${quoted} (first seen on ${seen}); update with npm install @flipstream/sdk@latest`);
97
+ // Any promise or thenable, from any realm (node:vm, an iframe): `instanceof Promise` misses
98
+ // another realm's.
99
+ Promise.resolve(returned).catch(() => undefined);
100
+ }
101
+ catch {
102
+ // Ignored, as above.
103
+ }
104
+ }
105
+ /**
106
+ * The catalogue's answers as the SDK reads them: each format whose type this SDK doesn't know read
107
+ * as the unknown arm first, then the spec's schema. Read a catalogue with these, never with the
108
+ * bare generated schema, which refuses such a type and so the whole answer (D493).
109
+ */
110
+ export const catalogAnswerFor = (warn) => z.preprocess((answer) => readCatalog(answer, warn), zCatalogCatalogGetResponse);
111
+ export const sourceAnswerFor = (warn) => z.preprocess((entry) => readSource(entry, warn), zCatalogSourceCatalogSourceGetResponse);
112
+ export const catalogAnswer = catalogAnswerFor(consoleWarn);
113
+ export const sourceAnswer = sourceAnswerFor(consoleWarn);
26
114
  /**
27
115
  * A value bound for one path segment, encoded, so `/`, `?` and `#` stay inside it; or null for
28
116
  * '', '.' and '..', which a URL reads as steps, not names (`/catalog/..` is `/`), and for a value
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/query/catalog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,sCAAsC,EAAE,MAAM,kCAAkC,CAAA;AAErH;;;GAGG;AAEH,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAW,CAAA;AAE7F,0FAA0F;AAC1F,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC,EAAE,MAAM,EAAE,0BAA0B,EAAE,CAAA;AACrI,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,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I,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IAChE,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
@@ -25,11 +25,20 @@ export interface QueryRequest {
25
25
  * planner has a deadline of its own (DW38).
26
26
  */
27
27
  export declare function queryRun(base: string, request: QueryRequest): CallSpec<QueryResponse>;
28
+ /** The fields a query sends, each picked from the request (D435). `table` is not one (DW50). */
29
+ declare const FIELDS: readonly ["source", "connection_id", "dimensions", "metrics", "filters", "sort", "offset", "rows"];
28
30
  /**
29
- * The request's own keys that aren't FIELDS, in its order, or null when it has none. These are
30
- * the keys JSON would have carried and the planner refuses (`additionalProperties: false`), so
31
- * fs.query refuses a request with any rather than send it without them: a misspelt `dimension`
32
- * would otherwise run, and change the numbers without a word (#113). The key is the mistake,
33
- * whatever its value, so `undefined` counts too.
31
+ * `true` when FIELDS picks every field of `Request`, and otherwise the fields it doesn't, so that
32
+ * `= true` fails to compile. Exported for its type test only (#183).
34
33
  */
34
+ export type EveryFieldPicked<Request> = [Exclude<keyof Request, (typeof FIELDS)[number]>] extends [never] ? true : Exclude<keyof Request, (typeof FIELDS)[number]>;
35
+ /** The keys fs.query refuses, in the request's order, or null when it has none. */
35
36
  export declare function unsentFields(request: QueryRequest): readonly [string, ...string[]] | null;
37
+ /**
38
+ * The fields `fs.query` would refuse in `request`, sorted by code unit, or `[]` for a request it
39
+ * would send. It's fs.query's own check, on the same list, run with no client and nothing sent,
40
+ * so an app can refuse a request before anything else it does (#183, D513). It reads only the
41
+ * keys: a missing `source`, or a value of the wrong type, is still the planner's to refuse.
42
+ */
43
+ export declare function refusedQueryFields(request: object): readonly string[];
44
+ export {};
@@ -21,20 +21,35 @@ export function queryRun(base, request) {
21
21
  }
22
22
  /** The fields a query sends, each picked from the request (D435). `table` is not one (DW50). */
23
23
  const FIELDS = ['source', 'connection_id', 'dimensions', 'metrics', 'filters', 'sort', 'offset', 'rows'];
24
+ // Fails to compile when the spec gives QueryRequest a field FIELDS doesn't pick, so a new field
25
+ // can't be dropped from what is sent without anyone deciding it.
24
26
  const everyFieldPicked = true;
25
27
  void everyFieldPicked; // read once, so unused-locals checks keep it
26
28
  const SENT = new Set(FIELDS);
27
29
  /**
28
- * The request's own keys that aren't FIELDS, in its order, or null when it has none. These are
29
- * the keys JSON would have carried and the planner refuses (`additionalProperties: false`), so
30
- * fs.query refuses a request with any rather than send it without them: a misspelt `dimension`
31
- * would otherwise run, and change the numbers without a word (#113). The key is the mistake,
32
- * whatever its value, so `undefined` counts too.
30
+ * The request's own keys that aren't FIELDS, in its order. These are the keys JSON would have
31
+ * carried and the planner refuses (`additionalProperties: false`), so fs.query refuses a request
32
+ * with any rather than send it without them: a misspelt `dimension` would otherwise run, and
33
+ * change the numbers without a word (#113). The key is the mistake, whatever its value, so
34
+ * `undefined` counts too.
33
35
  */
36
+ function unsent(request) {
37
+ return Object.keys(request).filter((key) => !SENT.has(key));
38
+ }
39
+ /** The keys fs.query refuses, in the request's order, or null when it has none. */
34
40
  export function unsentFields(request) {
35
- const [first, ...rest] = Object.keys(request).filter((key) => !SENT.has(key));
41
+ const [first, ...rest] = unsent(request);
36
42
  return first === undefined ? null : [first, ...rest];
37
43
  }
44
+ /**
45
+ * The fields `fs.query` would refuse in `request`, sorted by code unit, or `[]` for a request it
46
+ * would send. It's fs.query's own check, on the same list, run with no client and nothing sent,
47
+ * so an app can refuse a request before anything else it does (#183, D513). It reads only the
48
+ * keys: a missing `source`, or a value of the wrong type, is still the planner's to refuse.
49
+ */
50
+ export function refusedQueryFields(request) {
51
+ return unsent(request).sort();
52
+ }
38
53
  /** The request as JSON: the declared fields, each left out when it's undefined. */
39
54
  function bodyOf(request) {
40
55
  const picked = {};
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/query/query.ts"],"names":[],"mappings":"AAEA,OAA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AAiE;AACjE,MAAM,gBAAgB,GAAmC,IAAI,CAAA;AAC7D,KAAK,gBAAgB,CAAA,CAAC,6CAA6C;AAEnE,MAAM,IAAI,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,CAAA;AAEjD;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,OAAe;IAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AAC7D,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,OAAqB;IAChD,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;IACxC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAA;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;AAC/B,CAAC;AAED,mFAAmF;AACnF,SAAS,MAAM,CAAC,OAAqB;IACnC,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,SAAS;YAAE,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IAClE,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;AAC/B,CAAC"}
@@ -1 +1 @@
1
- export type { Catalog, CatalogCatalogGetData, CatalogCatalogGetError, CatalogCatalogGetErrors, CatalogCatalogGetResponse, CatalogCatalogGetResponses, CatalogSource, CatalogSourceCatalogSourceGetData, CatalogSourceCatalogSourceGetError, CatalogSourceCatalogSourceGetErrors, CatalogSourceCatalogSourceGetResponse, CatalogSourceCatalogSourceGetResponses, ClientOptions, CustomDimensions, Dimension, ErrorBody, Format, HealthHealthGetData, HealthHealthGetResponse, HealthHealthGetResponses, HttpValidationError, LogicalRequest, Metric, PlannerErrorCode, QueryQueryPostData, QueryQueryPostError, QueryQueryPostErrors, QueryQueryPostResponse, QueryQueryPostResponses, QueryResponse, Row, SortSpec, Source, ValidationError } from './types.gen.js';
1
+ export type { Catalog, CatalogCatalogGetData, CatalogCatalogGetError, CatalogCatalogGetErrors, CatalogCatalogGetResponse, CatalogCatalogGetResponses, CatalogSource, CatalogSourceCatalogSourceGetData, CatalogSourceCatalogSourceGetError, CatalogSourceCatalogSourceGetErrors, CatalogSourceCatalogSourceGetResponse, CatalogSourceCatalogSourceGetResponses, ClientOptions, CurrencyFormat, CustomDimensions, DateFormat, Dimension, ErrorBody, Format, HealthHealthGetData, HealthHealthGetResponse, HealthHealthGetResponses, HttpValidationError, LogicalRequest, Metric, NumberFormat, PercentageFormat, PlannerErrorCode, QueryQueryPostData, QueryQueryPostError, QueryQueryPostErrors, QueryQueryPostResponse, QueryQueryPostResponses, QueryResponse, Row, SortSpec, Source, StringFormat, UnknownFormat, ValidationError } from './types.gen.js';
@@ -123,11 +123,42 @@ export type Metric = {
123
123
  format: Format;
124
124
  lowerIsBetter?: boolean;
125
125
  };
126
- export type Format = {
127
- type: string;
128
- decimals?: number;
126
+ export type Format = ({
127
+ type: 'number';
128
+ } & NumberFormat) | ({
129
+ type: 'currency';
130
+ } & CurrencyFormat) | ({
131
+ type: 'percentage';
132
+ } & PercentageFormat) | ({
133
+ type: 'date';
134
+ } & DateFormat) | ({
135
+ type: 'string';
136
+ } & StringFormat) | ({
137
+ type: 'unknown';
138
+ } & UnknownFormat);
139
+ export type NumberFormat = {
140
+ type: 'number';
141
+ decimals: number;
129
142
  thousandSeparator?: boolean;
130
- format?: string;
143
+ };
144
+ export type CurrencyFormat = {
145
+ type: 'currency';
146
+ decimals: number;
147
+ };
148
+ export type PercentageFormat = {
149
+ type: 'percentage';
150
+ decimals: number;
151
+ };
152
+ export type DateFormat = {
153
+ type: 'date';
154
+ format: 'YYYY-MM-DD';
155
+ };
156
+ export type StringFormat = {
157
+ type: 'string';
158
+ };
159
+ export type UnknownFormat = {
160
+ type: 'unknown';
161
+ declared: string;
131
162
  };
132
163
  export type CustomDimensions = {
133
164
  supported: boolean;