@dads-framework/client 0.0.0-stage → 0.4.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/LICENSE.md +21 -0
- package/README.md +83 -2
- package/dist/client.tsbuildinfo +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/access-refusal.d.ts +8 -0
- package/dist/lib/access-refusal.d.ts.map +1 -0
- package/dist/lib/access-refusal.js +11 -0
- package/dist/lib/access-refusal.js.map +1 -0
- package/dist/lib/api-error.d.ts +86 -0
- package/dist/lib/api-error.d.ts.map +1 -0
- package/dist/lib/api-error.js +124 -0
- package/dist/lib/api-error.js.map +1 -0
- package/dist/lib/api-exchange-channel.d.ts +47 -0
- package/dist/lib/api-exchange-channel.d.ts.map +1 -0
- package/dist/lib/api-exchange-channel.js +43 -0
- package/dist/lib/api-exchange-channel.js.map +1 -0
- package/dist/lib/api-verbs.d.ts +115 -0
- package/dist/lib/api-verbs.d.ts.map +1 -0
- package/dist/lib/api-verbs.js +148 -0
- package/dist/lib/api-verbs.js.map +1 -0
- package/dist/lib/build-client-context.d.ts +44 -0
- package/dist/lib/build-client-context.d.ts.map +1 -0
- package/dist/lib/build-client-context.js +74 -0
- package/dist/lib/build-client-context.js.map +1 -0
- package/dist/lib/call-api.d.ts +77 -0
- package/dist/lib/call-api.d.ts.map +1 -0
- package/dist/lib/call-api.js +149 -0
- package/dist/lib/call-api.js.map +1 -0
- package/dist/lib/client-context.d.ts +32 -0
- package/dist/lib/client-context.d.ts.map +1 -0
- package/dist/lib/client-context.js +33 -0
- package/dist/lib/client-context.js.map +1 -0
- package/dist/lib/create-request-id.d.ts +14 -0
- package/dist/lib/create-request-id.d.ts.map +1 -0
- package/dist/lib/create-request-id.js +25 -0
- package/dist/lib/create-request-id.js.map +1 -0
- package/dist/lib/failure-presentation.d.ts +21 -0
- package/dist/lib/failure-presentation.d.ts.map +1 -0
- package/dist/lib/failure-presentation.js +9 -0
- package/dist/lib/failure-presentation.js.map +1 -0
- package/dist/lib/optimistic-cache.d.ts +84 -0
- package/dist/lib/optimistic-cache.d.ts.map +1 -0
- package/dist/lib/optimistic-cache.js +117 -0
- package/dist/lib/optimistic-cache.js.map +1 -0
- package/dist/lib/read-client-environment.d.ts +67 -0
- package/dist/lib/read-client-environment.d.ts.map +1 -0
- package/dist/lib/read-client-environment.js +85 -0
- package/dist/lib/read-client-environment.js.map +1 -0
- package/dist/lib/request-locale.d.ts +6 -0
- package/dist/lib/request-locale.d.ts.map +1 -0
- package/dist/lib/request-locale.js +31 -0
- package/dist/lib/request-locale.js.map +1 -0
- package/dist/lib/request-metadata.d.ts +22 -0
- package/dist/lib/request-metadata.d.ts.map +1 -0
- package/dist/lib/request-metadata.js +26 -0
- package/dist/lib/request-metadata.js.map +1 -0
- package/dist/lib/save-with-refresh.d.ts +13 -0
- package/dist/lib/save-with-refresh.d.ts.map +1 -0
- package/dist/lib/save-with-refresh.js +16 -0
- package/dist/lib/save-with-refresh.js.map +1 -0
- package/dist/lib/search-params.d.ts +11 -0
- package/dist/lib/search-params.d.ts.map +1 -0
- package/dist/lib/search-params.js +41 -0
- package/dist/lib/search-params.js.map +1 -0
- package/dist/lib/send-api-request.d.ts +24 -0
- package/dist/lib/send-api-request.d.ts.map +1 -0
- package/dist/lib/send-api-request.js +98 -0
- package/dist/lib/send-api-request.js.map +1 -0
- package/dist/lib/signed-url-upload.d.ts +18 -0
- package/dist/lib/signed-url-upload.d.ts.map +1 -0
- package/dist/lib/signed-url-upload.js +26 -0
- package/dist/lib/signed-url-upload.js.map +1 -0
- package/dist/lib/unauthorized-response-channel.d.ts +30 -0
- package/dist/lib/unauthorized-response-channel.d.ts.map +1 -0
- package/dist/lib/unauthorized-response-channel.js +38 -0
- package/dist/lib/unauthorized-response-channel.js.map +1 -0
- package/dist/telemetry/core/index.d.ts +3 -0
- package/dist/telemetry/core/index.d.ts.map +1 -0
- package/dist/telemetry/core/index.js +3 -0
- package/dist/telemetry/core/index.js.map +1 -0
- package/dist/telemetry/core/lib/client-telemetry-conformance.d.ts +13 -0
- package/dist/telemetry/core/lib/client-telemetry-conformance.d.ts.map +1 -0
- package/dist/telemetry/core/lib/client-telemetry-conformance.js +38 -0
- package/dist/telemetry/core/lib/client-telemetry-conformance.js.map +1 -0
- package/dist/telemetry/core/lib/client-telemetry.d.ts +48 -0
- package/dist/telemetry/core/lib/client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/core/lib/client-telemetry.js +26 -0
- package/dist/telemetry/core/lib/client-telemetry.js.map +1 -0
- package/dist/telemetry/core/lib/in-memory-client-telemetry.d.ts +20 -0
- package/dist/telemetry/core/lib/in-memory-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/core/lib/in-memory-client-telemetry.js +23 -0
- package/dist/telemetry/core/lib/in-memory-client-telemetry.js.map +1 -0
- package/dist/telemetry/core/lib/none-client-telemetry.d.ts +16 -0
- package/dist/telemetry/core/lib/none-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/core/lib/none-client-telemetry.js +22 -0
- package/dist/telemetry/core/lib/none-client-telemetry.js.map +1 -0
- package/dist/telemetry/index.d.ts +19 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +19 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/lib/create-client-telemetry.d.ts +38 -0
- package/dist/telemetry/lib/create-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/lib/create-client-telemetry.js +65 -0
- package/dist/telemetry/lib/create-client-telemetry.js.map +1 -0
- package/dist/telemetry/lib/fan-out-client-telemetry.d.ts +24 -0
- package/dist/telemetry/lib/fan-out-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/lib/fan-out-client-telemetry.js +56 -0
- package/dist/telemetry/lib/fan-out-client-telemetry.js.map +1 -0
- package/dist/telemetry/lib/install-global-error-reporting.d.ts +27 -0
- package/dist/telemetry/lib/install-global-error-reporting.d.ts.map +1 -0
- package/dist/telemetry/lib/install-global-error-reporting.js +43 -0
- package/dist/telemetry/lib/install-global-error-reporting.js.map +1 -0
- package/dist/telemetry/lib/local-client-telemetry.d.ts +44 -0
- package/dist/telemetry/lib/local-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/lib/local-client-telemetry.js +120 -0
- package/dist/telemetry/lib/local-client-telemetry.js.map +1 -0
- package/dist/telemetry/lib/logic/describe-client-error.d.ts +24 -0
- package/dist/telemetry/lib/logic/describe-client-error.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/describe-client-error.js +124 -0
- package/dist/telemetry/lib/logic/describe-client-error.js.map +1 -0
- package/dist/telemetry/lib/logic/is-chunk-load-failure.d.ts +16 -0
- package/dist/telemetry/lib/logic/is-chunk-load-failure.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/is-chunk-load-failure.js +34 -0
- package/dist/telemetry/lib/logic/is-chunk-load-failure.js.map +1 -0
- package/dist/telemetry/lib/logic/refused-read.d.ts +24 -0
- package/dist/telemetry/lib/logic/refused-read.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/refused-read.js +33 -0
- package/dist/telemetry/lib/logic/refused-read.js.map +1 -0
- package/dist/telemetry/lib/logic/sentry-configuration.d.ts +67 -0
- package/dist/telemetry/lib/logic/sentry-configuration.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/sentry-configuration.js +74 -0
- package/dist/telemetry/lib/logic/sentry-configuration.js.map +1 -0
- package/dist/telemetry/lib/logic/should-report-failure.d.ts +19 -0
- package/dist/telemetry/lib/logic/should-report-failure.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/should-report-failure.js +41 -0
- package/dist/telemetry/lib/logic/should-report-failure.js.map +1 -0
- package/dist/telemetry/lib/optional-peer.d.ts +12 -0
- package/dist/telemetry/lib/optional-peer.d.ts.map +1 -0
- package/dist/telemetry/lib/optional-peer.js +37 -0
- package/dist/telemetry/lib/optional-peer.js.map +1 -0
- package/dist/telemetry/lib/sentry-client-telemetry.d.ts +74 -0
- package/dist/telemetry/lib/sentry-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/lib/sentry-client-telemetry.js +189 -0
- package/dist/telemetry/lib/sentry-client-telemetry.js.map +1 -0
- package/dist/telemetry/testing.d.ts +3 -0
- package/dist/telemetry/testing.d.ts.map +1 -0
- package/dist/telemetry/testing.js +3 -0
- package/dist/telemetry/testing.js.map +1 -0
- package/package.json +58 -4
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@link optimisticRecordWrite} for a write that takes no input — opening one
|
|
3
|
+
* order, closing one release — whose effect is known when the factory is
|
|
4
|
+
* built.
|
|
5
|
+
*
|
|
6
|
+
* Its options name no input, so the mutation keeps taking none. The snapshot
|
|
7
|
+
* to restore is the one its latest send took: such a write is sent from one
|
|
8
|
+
* control at a time, and the refetch on settle corrects any overlap.
|
|
9
|
+
*/
|
|
10
|
+
export function optimisticRecordWriteWithoutInput(queryClient, scope, effect) {
|
|
11
|
+
const write = optimisticRecordWrite(queryClient, scope, () => effect);
|
|
12
|
+
let latest;
|
|
13
|
+
return {
|
|
14
|
+
onMutate: async () => {
|
|
15
|
+
latest = await write.onMutate(undefined);
|
|
16
|
+
return latest;
|
|
17
|
+
},
|
|
18
|
+
onError: (error) => {
|
|
19
|
+
write.onError(error, undefined, latest);
|
|
20
|
+
},
|
|
21
|
+
onSettled: write.onSettled,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Mutation options that show a write before the server answers it.
|
|
26
|
+
*
|
|
27
|
+
* The screen changes the moment the reader acts: every cached read under
|
|
28
|
+
* `scope` is patched with the expected effect. If the server refuses, each
|
|
29
|
+
* read is restored exactly as it was, and the refusal is explained by the
|
|
30
|
+
* app's single failure notice — or, when the hook declares
|
|
31
|
+
* `FAILURE_PRESENTED_INLINE` and its screen stays mounted, by that screen's
|
|
32
|
+
* own inline message. Either way the scope is refetched once the write
|
|
33
|
+
* settles, so the server's answer — not the guess — is what stays on screen.
|
|
34
|
+
*
|
|
35
|
+
* Spread it into a mutation factory beside its own `onSuccess`. The patch is
|
|
36
|
+
* structural: it recognises `{ items, meta }` pages, arrays of records, and
|
|
37
|
+
* records by their identifying field, so a resource's key factory never has
|
|
38
|
+
* to enumerate the views that show it. An effect that names a field a view
|
|
39
|
+
* does not carry changes nothing there, and the refetch corrects it.
|
|
40
|
+
*/
|
|
41
|
+
export function optimisticRecordWrite(queryClient, scope, effectOf) {
|
|
42
|
+
return {
|
|
43
|
+
onMutate: async (variables) => {
|
|
44
|
+
const effect = effectOf(variables);
|
|
45
|
+
if (effect === null)
|
|
46
|
+
return { entries: [] };
|
|
47
|
+
await queryClient.cancelQueries({ queryKey: scope });
|
|
48
|
+
const entries = queryClient.getQueriesData({ queryKey: scope });
|
|
49
|
+
queryClient.setQueriesData({ queryKey: scope }, (cached) => applyRecordEffect(cached, effect));
|
|
50
|
+
return { entries };
|
|
51
|
+
},
|
|
52
|
+
onError: (_error, _variables, snapshot) => {
|
|
53
|
+
for (const [queryKey, data] of snapshot?.entries ?? []) {
|
|
54
|
+
queryClient.setQueryData(queryKey, data);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
onSettled: () => queryClient.invalidateQueries({ queryKey: scope }),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One cached read with the effect applied; the same reference when the read
|
|
62
|
+
* does not hold the record, so untouched views do not re-render.
|
|
63
|
+
*/
|
|
64
|
+
export function applyRecordEffect(cached, effect) {
|
|
65
|
+
if (Array.isArray(cached)) {
|
|
66
|
+
return applyToRecords(cached, effect) ?? cached;
|
|
67
|
+
}
|
|
68
|
+
if (!isObject(cached))
|
|
69
|
+
return cached;
|
|
70
|
+
if (Array.isArray(cached["items"]) && isObject(cached["meta"])) {
|
|
71
|
+
const items = applyToRecords(cached["items"], effect);
|
|
72
|
+
if (items === null)
|
|
73
|
+
return cached;
|
|
74
|
+
return {
|
|
75
|
+
...cached,
|
|
76
|
+
items,
|
|
77
|
+
meta: decrementPageTotal(cached["meta"], cached["items"].length - items.length),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (isTarget(cached, effect)) {
|
|
81
|
+
return "change" in effect ? { ...cached, ...effect.change } : cached;
|
|
82
|
+
}
|
|
83
|
+
return applyToNestedRows(cached, effect);
|
|
84
|
+
}
|
|
85
|
+
function decrementPageTotal(meta, removed) {
|
|
86
|
+
const total = meta["total"];
|
|
87
|
+
return typeof total === "number" && removed > 0 ? { ...meta, total: Math.max(0, total - removed) } : meta;
|
|
88
|
+
}
|
|
89
|
+
function applyToNestedRows(record, effect) {
|
|
90
|
+
let patched = null;
|
|
91
|
+
for (const [field, value] of Object.entries(record)) {
|
|
92
|
+
const next = Array.isArray(value)
|
|
93
|
+
? applyToRecords(value, effect)
|
|
94
|
+
: isTarget(value, effect) && "change" in effect
|
|
95
|
+
? { ...value, ...effect.change }
|
|
96
|
+
: null;
|
|
97
|
+
if (next === null)
|
|
98
|
+
continue;
|
|
99
|
+
patched = { ...(patched ?? record), [field]: next };
|
|
100
|
+
}
|
|
101
|
+
return patched ?? record;
|
|
102
|
+
}
|
|
103
|
+
function applyToRecords(records, effect) {
|
|
104
|
+
if (!records.some((record) => isTarget(record, effect)))
|
|
105
|
+
return null;
|
|
106
|
+
if ("remove" in effect) {
|
|
107
|
+
return records.filter((record) => !isTarget(record, effect));
|
|
108
|
+
}
|
|
109
|
+
return records.map((record) => (isTarget(record, effect) ? { ...record, ...effect.change } : record));
|
|
110
|
+
}
|
|
111
|
+
function isTarget(record, effect) {
|
|
112
|
+
return isObject(record) && record[effect.key ?? "id"] === effect.id;
|
|
113
|
+
}
|
|
114
|
+
function isObject(value) {
|
|
115
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=optimistic-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AS,cAAc,CAAC,OAA2B,EAAE,MAA8B;IACjF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACrE,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;QACvB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACxG,CAAC;AAED,SAAS,QAAQ,CAAC,MAAe,EAAE,MAA8B;IAC/D,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC;AACtE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ClientEnvironmentSnapshot } from "./build-client-context.js";
|
|
2
|
+
/**
|
|
3
|
+
* The window fields the client context reads, and nothing else. Declaring the
|
|
4
|
+
* shape here rather than taking `Window` keeps a test free to pass a two-field
|
|
5
|
+
* object, and keeps this module honest about how little of the browser it
|
|
6
|
+
* touches. The real `Window` satisfies it.
|
|
7
|
+
*/
|
|
8
|
+
export type ClientWindowLike = {
|
|
9
|
+
readonly innerWidth?: number;
|
|
10
|
+
readonly innerHeight?: number;
|
|
11
|
+
readonly devicePixelRatio?: number;
|
|
12
|
+
readonly screen?: {
|
|
13
|
+
readonly width?: number;
|
|
14
|
+
readonly height?: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The navigator fields the client context reads. `connection` and
|
|
19
|
+
* `deviceMemory` are not in the DOM types because they are not on the
|
|
20
|
+
* standards track — this narrow declaration is what lets them be read without
|
|
21
|
+
* an escape hatch, and optional is the truth: plenty of browsers omit them.
|
|
22
|
+
*/
|
|
23
|
+
export type ClientNavigatorLike = {
|
|
24
|
+
readonly language?: string;
|
|
25
|
+
readonly maxTouchPoints?: number;
|
|
26
|
+
readonly onLine?: boolean;
|
|
27
|
+
readonly connection?: {
|
|
28
|
+
readonly effectiveType?: string;
|
|
29
|
+
};
|
|
30
|
+
readonly deviceMemory?: number;
|
|
31
|
+
readonly hardwareConcurrency?: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Everything the reader needs handed to it: the baked build stamp (the app
|
|
35
|
+
* owns `import.meta.env`, this lib must not), the two globals, and the clock.
|
|
36
|
+
*/
|
|
37
|
+
export type ClientEnvironmentSources = {
|
|
38
|
+
readonly build: string | undefined;
|
|
39
|
+
readonly window: ClientWindowLike;
|
|
40
|
+
readonly navigator: ClientNavigatorLike;
|
|
41
|
+
readonly nowMs: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Record when this tab started, as the same millisecond clock the reader is
|
|
45
|
+
* later handed. The app's composition root calls this once at boot; an
|
|
46
|
+
* embedder that does not simply gets no `tabAgeMs`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function markTabStarted(nowMs: number): void;
|
|
49
|
+
/**
|
|
50
|
+
* Record the route the reader is on, as the router's matched route id
|
|
51
|
+
* (`/orders/$orderId`), never the pathname — the same identifier the request
|
|
52
|
+
* log stores instead of a path, and for the same reason.
|
|
53
|
+
*
|
|
54
|
+
* The app's composition root is the one place that holds the router, so it is
|
|
55
|
+
* what calls this.
|
|
56
|
+
*/
|
|
57
|
+
export declare function setCurrentRouteId(routeId: string | undefined): void;
|
|
58
|
+
/**
|
|
59
|
+
* Read what this tab can say about itself right now.
|
|
60
|
+
*
|
|
61
|
+
* Every read is guarded: a missing API, or a getter that throws on a hardened
|
|
62
|
+
* browser, yields `undefined` for that one field rather than failing the
|
|
63
|
+
* request that asked. Nothing here is fingerprinting — each field answers a
|
|
64
|
+
* debugging question the request log is expected to be asked.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readClientEnvironment(sources: ClientEnvironmentSources): ClientEnvironmentSnapshot;
|
|
67
|
+
//# sourceMappingURL=read-client-environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-client-environment.d.ts","sourceRoot":"","sources":["../../src/lib/read-client-environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACzE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE;QAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACvC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAcF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAElD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAEnE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,wBAAwB,GAAG,yBAAyB,CAgBlG"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When this tab loaded — the only thing `tabAgeMs` can be measured from.
|
|
3
|
+
*
|
|
4
|
+
* Stamped by the app rather than read from a module-level `Date.now()`: a
|
|
5
|
+
* clock that runs at import time is one no caller can see and no test can
|
|
6
|
+
* control. Until it is stamped there is no age to report, which is the honest
|
|
7
|
+
* answer — not a zero that reads like a freshly opened tab.
|
|
8
|
+
*/
|
|
9
|
+
let tabStartedAtMs = undefined;
|
|
10
|
+
let currentRouteId = undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Record when this tab started, as the same millisecond clock the reader is
|
|
13
|
+
* later handed. The app's composition root calls this once at boot; an
|
|
14
|
+
* embedder that does not simply gets no `tabAgeMs`.
|
|
15
|
+
*/
|
|
16
|
+
export function markTabStarted(nowMs) {
|
|
17
|
+
tabStartedAtMs = nowMs;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Record the route the reader is on, as the router's matched route id
|
|
21
|
+
* (`/orders/$orderId`), never the pathname — the same identifier the request
|
|
22
|
+
* log stores instead of a path, and for the same reason.
|
|
23
|
+
*
|
|
24
|
+
* The app's composition root is the one place that holds the router, so it is
|
|
25
|
+
* what calls this.
|
|
26
|
+
*/
|
|
27
|
+
export function setCurrentRouteId(routeId) {
|
|
28
|
+
currentRouteId = routeId;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Read what this tab can say about itself right now.
|
|
32
|
+
*
|
|
33
|
+
* Every read is guarded: a missing API, or a getter that throws on a hardened
|
|
34
|
+
* browser, yields `undefined` for that one field rather than failing the
|
|
35
|
+
* request that asked. Nothing here is fingerprinting — each field answers a
|
|
36
|
+
* debugging question the request log is expected to be asked.
|
|
37
|
+
*/
|
|
38
|
+
export function readClientEnvironment(sources) {
|
|
39
|
+
const { window, navigator } = sources;
|
|
40
|
+
return {
|
|
41
|
+
build: sources.build,
|
|
42
|
+
timeZone: read(() => Intl.DateTimeFormat().resolvedOptions().timeZone),
|
|
43
|
+
locale: read(() => navigator.language),
|
|
44
|
+
routeId: currentRouteId,
|
|
45
|
+
viewport: read(() => readViewport(window)),
|
|
46
|
+
screen: read(() => readScreen(window)),
|
|
47
|
+
touch: read(() => readTouch(navigator)),
|
|
48
|
+
online: read(() => navigator.onLine),
|
|
49
|
+
connection: read(() => navigator.connection?.effectiveType),
|
|
50
|
+
deviceMemory: read(() => navigator.deviceMemory),
|
|
51
|
+
hardwareConcurrency: read(() => navigator.hardwareConcurrency),
|
|
52
|
+
tabAgeMs: tabStartedAtMs === undefined ? undefined : sources.nowMs - tabStartedAtMs,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** One field's read, where nothing it can do ends the request. */
|
|
56
|
+
function read(readValue) {
|
|
57
|
+
try {
|
|
58
|
+
return readValue();
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** All three numbers or none: half a viewport says nothing worth logging. */
|
|
65
|
+
function readViewport(window) {
|
|
66
|
+
const w = window.innerWidth;
|
|
67
|
+
const h = window.innerHeight;
|
|
68
|
+
const dpr = window.devicePixelRatio;
|
|
69
|
+
if (w === undefined || h === undefined || dpr === undefined)
|
|
70
|
+
return undefined;
|
|
71
|
+
return { w, h, dpr };
|
|
72
|
+
}
|
|
73
|
+
function readScreen(window) {
|
|
74
|
+
const w = window.screen?.width;
|
|
75
|
+
const h = window.screen?.height;
|
|
76
|
+
if (w === undefined || h === undefined)
|
|
77
|
+
return undefined;
|
|
78
|
+
return { w, h };
|
|
79
|
+
}
|
|
80
|
+
/** A touch screen is a device with at least one contact point. */
|
|
81
|
+
function readTouch(navigator) {
|
|
82
|
+
const points = navigator.maxTouchPoints;
|
|
83
|
+
return points === undefined ? undefined : points > 0;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=read-client-environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-client-environment.js","sourceRoot":"","sources":["../../src/lib/read-client-environment.ts"],"names":[],"mappings":"AAyCA;;;;;;;GAOG;AACH,IAAI,cAAc,GAAuB,SAAS,CAAC;AAEnD,IAAI,cAAc,GAAuB,SAAS,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,cAAc,GAAG,KAAK,CAAC;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,cAAc,GAAG,OAAO,CAAC;AAC3B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAiC;IACrE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACtC,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,QAAQ,EAAE,IAAI,CAAC,GAAG,E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AAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9E,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AACvB,CAAC;AAED,SAAS,UAAU,CAAC,MAAwB;IAC1C,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAC/B,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAChC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzD,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAClB,CAAC;AAED,kEAAkE;AAClE,SAAS,SAAS,CAAC,SAA8B;IAC/C,MAAM,MAAM,GAAG,SAAS,CAAC,cAAc,CAAC;IACxC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Locale } from "@dads-framework/core/contract";
|
|
2
|
+
/** Ask the API to answer in this language from here on. */
|
|
3
|
+
export declare function setRequestLocale(locale: Locale): void;
|
|
4
|
+
/** The language the next request will ask for. */
|
|
5
|
+
export declare function currentRequestLocale(): Locale;
|
|
6
|
+
//# sourceMappingURL=request-locale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-locale.d.ts","sourceRoot":"","sources":["../../src/lib/request-locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAyB/E,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAErD;AAED,kDAAkD;AAClD,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SUPPORTED_LOCALES } from "@dads-framework/core/contract";
|
|
2
|
+
/**
|
|
3
|
+
* The language every outbound request asks to be answered in.
|
|
4
|
+
*
|
|
5
|
+
* A module-level channel rather than an argument on each call, mirroring
|
|
6
|
+
* `unauthorized-response-channel.ts` and for the same reason: every request
|
|
7
|
+
* carries it, and no call site should have to remember. It is also why the
|
|
8
|
+
* language rides a header — a query parameter would have to be threaded
|
|
9
|
+
* through every route contract that returns a label, which is exactly the wire
|
|
10
|
+
* change this design avoids.
|
|
11
|
+
*
|
|
12
|
+
* This module holds no React and reaches no copy kit — the boundary forbids the
|
|
13
|
+
* latter outright (`scope:web` cannot import a `scope:shared` lib's provider
|
|
14
|
+
* state, and a transport should not hold render state anyway). The app's
|
|
15
|
+
* composition root is the one place that holds both, and it is what calls
|
|
16
|
+
* `setRequestLocale` when the reader changes language, alongside clearing the
|
|
17
|
+
* query cache so nothing already fetched answers in the old one.
|
|
18
|
+
*
|
|
19
|
+
* The default is English, and nothing sets it today: the reader's preference
|
|
20
|
+
* will live in a future user-settings document.
|
|
21
|
+
*/
|
|
22
|
+
let requestedLocale = SUPPORTED_LOCALES[0];
|
|
23
|
+
/** Ask the API to answer in this language from here on. */
|
|
24
|
+
export function setRequestLocale(locale) {
|
|
25
|
+
requestedLocale = locale;
|
|
26
|
+
}
|
|
27
|
+
/** The language the next request will ask for. */
|
|
28
|
+
export function currentRequestLocale() {
|
|
29
|
+
return requestedLocale;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=request-locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-locale.js","sourceRoot":"","sources":["../../src/lib/request-locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAe,MAAM,+BAA+B,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,IAAI,eAAe,GAAW,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAEnD,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,eAAe,GAAG,MAAM,CAAC;AAC3B,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,oBAAoB;IAClC,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ApiRequestHeaders, ApiRequestDispatch } from "./send-api-request.js";
|
|
2
|
+
/**
|
|
3
|
+
* A composition seam for metadata which belongs to a particular request context.
|
|
4
|
+
*
|
|
5
|
+
* The transport deliberately knows neither feature flags nor business contexts.
|
|
6
|
+
* It only gives an application runtime the exact headers that the caller already
|
|
7
|
+
* captured for this request, so overlapping requests cannot read ambient state.
|
|
8
|
+
*/
|
|
9
|
+
export type RequestMetadataProvider = (request: Pick<ApiRequestDispatch, "path" | "method" | "headers">) => ApiRequestHeaders | undefined;
|
|
10
|
+
/** Observes an HTTP response before success/error conversion consumes it. */
|
|
11
|
+
export type ApiResponseObserver = (response: Response, request: Pick<ApiRequestDispatch, "path" | "method" | "headers">) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Install application-owned metadata behavior for every request.
|
|
14
|
+
*
|
|
15
|
+
* Registration is intentionally singular: browser composition has one feature
|
|
16
|
+
* state runtime. Returning a cleanup function keeps isolated tests and browser
|
|
17
|
+
* teardown from leaking a prior runtime into the next application instance.
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerRequestMetadata(provider: RequestMetadataProvider | undefined, observer: ApiResponseObserver | undefined): () => void;
|
|
20
|
+
export declare function requestMetadataFor(request: Pick<ApiRequestDispatch, "path" | "method" | "headers">): ApiRequestHeaders | undefined;
|
|
21
|
+
export declare function observeApiResponse(response: Response, request: Pick<ApiRequestDispatch, "path" | "method" | "headers">): void;
|
|
22
|
+
//# sourceMappingURL=request-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-metadata.d.ts","sourceRoot":"","sources":["../../src/lib/request-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEnF;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,CACpC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,KAC7D,iBAAiB,GAAG,SAAS,CAAC;AAEnC,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG,CAChC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,KAC7D,IAAI,CAAC;AAKV;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,uBAAuB,GAAG,SAAS,EAC7C,QAAQ,EAAE,mBAAmB,GAAG,SAAS,GACxC,MAAM,IAAI,CAOZ;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,GAC/D,iBAAiB,GAAG,SAAS,CAE/B;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,GAC/D,IAAI,CAEN"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
let metadataProvider;
|
|
2
|
+
let responseObserver;
|
|
3
|
+
/**
|
|
4
|
+
* Install application-owned metadata behavior for every request.
|
|
5
|
+
*
|
|
6
|
+
* Registration is intentionally singular: browser composition has one feature
|
|
7
|
+
* state runtime. Returning a cleanup function keeps isolated tests and browser
|
|
8
|
+
* teardown from leaking a prior runtime into the next application instance.
|
|
9
|
+
*/
|
|
10
|
+
export function registerRequestMetadata(provider, observer) {
|
|
11
|
+
metadataProvider = provider;
|
|
12
|
+
responseObserver = observer;
|
|
13
|
+
return () => {
|
|
14
|
+
if (metadataProvider === provider)
|
|
15
|
+
metadataProvider = undefined;
|
|
16
|
+
if (responseObserver === observer)
|
|
17
|
+
responseObserver = undefined;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function requestMetadataFor(request) {
|
|
21
|
+
return metadataProvider?.(request);
|
|
22
|
+
}
|
|
23
|
+
export function observeApiResponse(response, request) {
|
|
24
|
+
responseObserver?.(response, request);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=request-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-metadata.js","sourceRoot":"","sources":["../../src/lib/request-metadata.ts"],"names":[],"mappings":"AAmBA,IAAI,gBAAqD,CAAC;AAC1D,IAAI,gBAAiD,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAA6C,EAC7C,QAAyC;IAEzC,gBAAgB,GAAG,QAAQ,CAAC;IAC5B,gBAAgB,GAAG,QAAQ,CAAC;IAC5B,OAAO,GAAG,EAAE;QACV,IAAI,gBAAgB,KAAK,QAAQ;YAAE,gBAAgB,GAAG,SAAS,CAAC;QAChE,IAAI,gBAAgB,KAAK,QAAQ;YAAE,gBAAgB,GAAG,SAAS,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAAgE;IAEhE,OAAO,gBAAgB,EAAE,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,QAAkB,EAClB,OAAgE;IAEhE,gBAAgB,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SaveWithRefreshResult<Saved, Latest> = {
|
|
2
|
+
readonly kind: "saved";
|
|
3
|
+
readonly value: Saved;
|
|
4
|
+
} | {
|
|
5
|
+
readonly kind: "stale";
|
|
6
|
+
readonly latest: Latest;
|
|
7
|
+
};
|
|
8
|
+
/** Run a save once. Refresh a stale record so the caller can review its draft. */
|
|
9
|
+
export declare function saveWithRefresh<Saved, Latest>(options: {
|
|
10
|
+
readonly save: () => Promise<Saved>;
|
|
11
|
+
readonly refresh: () => Promise<Latest>;
|
|
12
|
+
}): Promise<SaveWithRefreshResult<Saved, Latest>>;
|
|
13
|
+
//# sourceMappingURL=save-with-refresh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-with-refresh.d.ts","sourceRoot":"","sources":["../../src/lib/save-with-refresh.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,qBAAqB,CAAC,KAAK,EAAE,MAAM,IAC7C;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1G,kFAAkF;AAClF,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAUhD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ROW_VERSION_CONFLICT } from "@dads-framework/core/contract";
|
|
2
|
+
import { readClientFailure } from "./api-error.js";
|
|
3
|
+
/** Run a save once. Refresh a stale record so the caller can review its draft. */
|
|
4
|
+
export async function saveWithRefresh(options) {
|
|
5
|
+
try {
|
|
6
|
+
return { kind: "saved", value: await options.save() };
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
const failure = readClientFailure(error);
|
|
10
|
+
if (failure.kind !== "api" || failure.status !== 409 || failure.code !== ROW_VERSION_CONFLICT) {
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
return { kind: "stale", latest: await options.refresh() };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=save-with-refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-with-refresh.js","sourceRoot":"","sources":["../../src/lib/save-with-refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAKnD,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,eAAe,CAAgB,OAGpD;IACC,IAAI,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;YAC9F,MAAM,KAAK,CAAC;QACd,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn a contract-validated query object into a query string.
|
|
3
|
+
*
|
|
4
|
+
* Runs on the OUTPUT of the endpoint's query schema, so the shapes it has to
|
|
5
|
+
* handle are exactly the shapes a contract can describe: primitives, arrays of
|
|
6
|
+
* primitives, dates, and absent values. Anything else is a contract this
|
|
7
|
+
* serializer has never been taught, and it says so rather than sending
|
|
8
|
+
* `[object Object]` to the API.
|
|
9
|
+
*/
|
|
10
|
+
export declare function toSearchParams(query: Record<string, unknown>): URLSearchParams;
|
|
11
|
+
//# sourceMappingURL=search-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-params.d.ts","sourceRoot":"","sources":["../../src/lib/search-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,CAM9E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn a contract-validated query object into a query string.
|
|
3
|
+
*
|
|
4
|
+
* Runs on the OUTPUT of the endpoint's query schema, so the shapes it has to
|
|
5
|
+
* handle are exactly the shapes a contract can describe: primitives, arrays of
|
|
6
|
+
* primitives, dates, and absent values. Anything else is a contract this
|
|
7
|
+
* serializer has never been taught, and it says so rather than sending
|
|
8
|
+
* `[object Object]` to the API.
|
|
9
|
+
*/
|
|
10
|
+
export function toSearchParams(query) {
|
|
11
|
+
const params = new URLSearchParams();
|
|
12
|
+
for (const [key, value] of Object.entries(query)) {
|
|
13
|
+
appendValue(params, key, value);
|
|
14
|
+
}
|
|
15
|
+
return params;
|
|
16
|
+
}
|
|
17
|
+
function appendValue(params, key, value) {
|
|
18
|
+
if (value === undefined || value === null) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
for (const item of value) {
|
|
23
|
+
params.append(key, serializeScalar(key, item));
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
params.append(key, serializeScalar(key, value));
|
|
28
|
+
}
|
|
29
|
+
function serializeScalar(key, value) {
|
|
30
|
+
if (typeof value === "string") {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
34
|
+
return String(value);
|
|
35
|
+
}
|
|
36
|
+
if (value instanceof Date) {
|
|
37
|
+
return value.toISOString();
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`Query parameter "${key}" is not serializable as a query string value`);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=search-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-params.js","sourceRoot":"","sources":["../../src/lib/search-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,KAA8B;IAC3D,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,MAAuB,EAAE,GAAW,EAAE,KAAc;IACvE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QACjD,CAAC;QACD,OAAO;IACT,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,eAAe,CAAC,GAAW,EAAE,KAAc;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,+CAA+C,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type HttpMethod } from "@dads-framework/core/contract";
|
|
2
|
+
export type { HttpMethod } from "@dads-framework/core/contract";
|
|
3
|
+
/** Explicit request-local metadata; the transport never selects an authorization context. */
|
|
4
|
+
export type ApiRequestHeaders = Readonly<Record<string, string>>;
|
|
5
|
+
/** One wire call, with every value already validated by its contract schema. */
|
|
6
|
+
export type ApiRequestDispatch = {
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly method: HttpMethod;
|
|
9
|
+
readonly body: unknown;
|
|
10
|
+
readonly search: URLSearchParams | undefined;
|
|
11
|
+
readonly signal: AbortSignal | undefined;
|
|
12
|
+
readonly headers?: ApiRequestHeaders | undefined;
|
|
13
|
+
readonly accept?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Perform one request and return the response only when the API accepted it.
|
|
17
|
+
*
|
|
18
|
+
* Everything that must be true of every call lives here: the session cookie
|
|
19
|
+
* rides along, a fresh correlation id is minted for the logs, a failure
|
|
20
|
+
* becomes a typed `ApiError` instead of a raw `Response`, and a 401 announces
|
|
21
|
+
* itself on the unauthorized-response channel on its way out.
|
|
22
|
+
*/
|
|
23
|
+
export declare function sendApiRequest(dispatch: ApiRequestDispatch): Promise<Response>;
|
|
24
|
+
//# sourceMappingURL=send-api-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-api-request.d.ts","sourceRoot":"","sources":["../../src/lib/send-api-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,+BAA+B,CAAC;AAWvC,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,6FAA6F;AAC7F,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEjE,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAQpF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ACCESS_REFUSAL_HEADER, CLIENT_CONTEXT_HEADER, LOCALE_HEADER, REQUEST_ID_HEADER, } from "@dads-framework/core/contract";
|
|
2
|
+
import { isAccessRefusal } from "./access-refusal.js";
|
|
3
|
+
import { NetworkError, toApiError } from "./api-error.js";
|
|
4
|
+
import { announceApiExchange } from "./api-exchange-channel.js";
|
|
5
|
+
import { currentClientContextHeader } from "./client-context.js";
|
|
6
|
+
import { createRequestId } from "./create-request-id.js";
|
|
7
|
+
import { currentRequestLocale } from "./request-locale.js";
|
|
8
|
+
import { observeApiResponse, requestMetadataFor } from "./request-metadata.js";
|
|
9
|
+
import { announceUnauthorizedResponse } from "./unauthorized-response-channel.js";
|
|
10
|
+
/**
|
|
11
|
+
* Perform one request and return the response only when the API accepted it.
|
|
12
|
+
*
|
|
13
|
+
* Everything that must be true of every call lives here: the session cookie
|
|
14
|
+
* rides along, a fresh correlation id is minted for the logs, a failure
|
|
15
|
+
* becomes a typed `ApiError` instead of a raw `Response`, and a 401 announces
|
|
16
|
+
* itself on the unauthorized-response channel on its way out.
|
|
17
|
+
*/
|
|
18
|
+
export async function sendApiRequest(dispatch) {
|
|
19
|
+
const requestId = createRequestId();
|
|
20
|
+
const response = await requestApi(dispatch, requestId);
|
|
21
|
+
if (response.ok) {
|
|
22
|
+
return response;
|
|
23
|
+
}
|
|
24
|
+
throw await toRejection(response, requestId);
|
|
25
|
+
}
|
|
26
|
+
async function requestApi(dispatch, requestId) {
|
|
27
|
+
const startedAt = performance.now();
|
|
28
|
+
try {
|
|
29
|
+
const response = await fetch(buildRequestUrl(dispatch), {
|
|
30
|
+
method: dispatch.method,
|
|
31
|
+
credentials: "include",
|
|
32
|
+
headers: buildHeaders(dispatch, requestId),
|
|
33
|
+
...(dispatch.body === undefined ? {} : { body: JSON.stringify(dispatch.body) }),
|
|
34
|
+
...(dispatch.signal === undefined ? {} : { signal: dispatch.signal }),
|
|
35
|
+
});
|
|
36
|
+
// Observers see both accepted and rejected HTTP responses. Feature state
|
|
37
|
+
// hashes on a 409 are just as meaningful as hashes on a 200.
|
|
38
|
+
observeApiResponse(response, dispatch);
|
|
39
|
+
announce(dispatch, requestId, startedAt, {
|
|
40
|
+
status: response.status,
|
|
41
|
+
refusedForAccess: isAccessRefusal(response.status, response.headers.get(ACCESS_REFUSAL_HEADER)),
|
|
42
|
+
});
|
|
43
|
+
return response;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
// A call that never reached the API is still an exchange worth reporting:
|
|
50
|
+
// it is what a telemetry breadcrumb needs to explain what came next.
|
|
51
|
+
announce(dispatch, requestId, startedAt, {
|
|
52
|
+
status: null,
|
|
53
|
+
refusedForAccess: false,
|
|
54
|
+
});
|
|
55
|
+
throw new NetworkError(error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** The path, never the query string — a query can carry whatever a caller put there. */
|
|
59
|
+
function announce(dispatch, requestId, startedAt, answer) {
|
|
60
|
+
announceApiExchange({
|
|
61
|
+
method: dispatch.method,
|
|
62
|
+
path: dispatch.path,
|
|
63
|
+
status: answer.status,
|
|
64
|
+
requestId,
|
|
65
|
+
durationMs: Math.round(performance.now() - startedAt),
|
|
66
|
+
refusedForAccess: answer.refusedForAccess,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function buildRequestUrl(dispatch) {
|
|
70
|
+
const query = dispatch.search?.toString() ?? "";
|
|
71
|
+
return query.length > 0 ? `${dispatch.path}?${query}` : dispatch.path;
|
|
72
|
+
}
|
|
73
|
+
function buildHeaders(dispatch, requestId) {
|
|
74
|
+
const headers = new Headers(dispatch.headers);
|
|
75
|
+
const metadata = requestMetadataFor(dispatch);
|
|
76
|
+
if (metadata !== undefined) {
|
|
77
|
+
for (const [name, value] of Object.entries(metadata))
|
|
78
|
+
headers.set(name, value);
|
|
79
|
+
}
|
|
80
|
+
headers.set("Accept", dispatch.accept ?? "application/json");
|
|
81
|
+
headers.set(REQUEST_ID_HEADER, requestId);
|
|
82
|
+
headers.set(LOCALE_HEADER, currentRequestLocale());
|
|
83
|
+
const clientContext = currentClientContextHeader();
|
|
84
|
+
if (clientContext !== undefined)
|
|
85
|
+
headers.set(CLIENT_CONTEXT_HEADER, clientContext);
|
|
86
|
+
if (dispatch.body !== undefined)
|
|
87
|
+
headers.set("Content-Type", "application/json");
|
|
88
|
+
return Object.fromEntries(headers.entries());
|
|
89
|
+
}
|
|
90
|
+
async function toRejection(response, requestId) {
|
|
91
|
+
const body = await response.json().catch(() => undefined);
|
|
92
|
+
const error = toApiError(response.status, body, requestId);
|
|
93
|
+
if (response.status === 401) {
|
|
94
|
+
announceUnauthorizedResponse();
|
|
95
|
+
}
|
|
96
|
+
return error;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=send-api-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-api-request.js","sourceRoot":"","sources":["../../src/lib/send-api-request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,GAElB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAkBlF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAA4B;IAC/D,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEvD,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,QAA4B,EAAE,SAAiB;IACvE,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,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