@burdenoff/microfe-healthybowl 2026.1202.1 → 2026.1202.2
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.
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DocumentNode } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* Merge several single-query documents into one query named `operationName`.
|
|
4
|
+
*
|
|
5
|
+
* Throws when the inputs cannot be merged safely:
|
|
6
|
+
* - a document is not exactly one `query` operation;
|
|
7
|
+
* - two documents declare the same variable with different types;
|
|
8
|
+
* - two documents select the same root response key (the merged selection
|
|
9
|
+
* would then depend on GraphQL field merging, which this helper does not
|
|
10
|
+
* attempt);
|
|
11
|
+
* - two documents define the same fragment name with different bodies;
|
|
12
|
+
* - a root selection is not a plain field (fragment spreads at the root are
|
|
13
|
+
* not used by the domain documents and are refused rather than guessed at).
|
|
14
|
+
*/
|
|
15
|
+
export declare function mergeQueryDocuments(operationName: string, documents: readonly DocumentNode[]): DocumentNode;
|
|
16
|
+
/** The root response keys a query document selects. */
|
|
17
|
+
export declare function rootFieldsOf(document: DocumentNode): string[];
|
|
18
|
+
/**
|
|
19
|
+
* The page-operation error that belongs to one domain, or undefined.
|
|
20
|
+
*
|
|
21
|
+
* A GraphQL error carries the path of the field that failed, so an error under
|
|
22
|
+
* `getHealthyBowlCropsData` belongs to the crops domain only. An error without
|
|
23
|
+
* a path (a network failure, a validation error for the whole document) belongs
|
|
24
|
+
* to every domain, because none of them received data.
|
|
25
|
+
*/
|
|
26
|
+
export declare function domainErrorFrom(error: Error | undefined, rootFields: readonly string[]): Error | undefined;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Kind as e, OperationTypeNode as t, print as n } from "graphql";
|
|
2
|
+
// src/healthybowl/hooks/pageOperation.ts
|
|
3
|
+
function r(t) {
|
|
4
|
+
return t.kind === e.OPERATION_DEFINITION;
|
|
5
|
+
}
|
|
6
|
+
function i(t) {
|
|
7
|
+
return t.kind === e.FRAGMENT_DEFINITION;
|
|
8
|
+
}
|
|
9
|
+
function a(e) {
|
|
10
|
+
return e.alias?.value ?? e.name.value;
|
|
11
|
+
}
|
|
12
|
+
function o(o, s) {
|
|
13
|
+
if (s.length === 0) throw Error("mergeQueryDocuments needs at least one document.");
|
|
14
|
+
let c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = [], d = /* @__PURE__ */ new Map();
|
|
15
|
+
for (let o of s) {
|
|
16
|
+
let s = o.definitions.filter(r), [f] = s;
|
|
17
|
+
if (s.length !== 1 || !f || f.operation !== t.QUERY) throw Error("mergeQueryDocuments accepts documents with exactly one query operation.");
|
|
18
|
+
let p = f.name?.value ?? "(anonymous)";
|
|
19
|
+
for (let e of f.variableDefinitions ?? []) {
|
|
20
|
+
let t = e.variable.name.value, r = c.get(t);
|
|
21
|
+
if (!r) c.set(t, e);
|
|
22
|
+
else if (n(r.type) !== n(e.type)) throw Error(`Variable $${t} is ${n(r.type)} in one document and ${n(e.type)} in ${p}.`);
|
|
23
|
+
}
|
|
24
|
+
for (let t of f.selectionSet.selections) {
|
|
25
|
+
if (t.kind !== e.FIELD) throw Error(`${p} has a root selection that is not a field; merge it by hand.`);
|
|
26
|
+
let n = a(t), r = l.get(n);
|
|
27
|
+
if (r) throw Error(`Root field "${n}" is selected by both ${r} and ${p}.`);
|
|
28
|
+
l.set(n, p), u.push(t);
|
|
29
|
+
}
|
|
30
|
+
for (let e of o.definitions.filter(i)) {
|
|
31
|
+
let t = e.name.value, r = d.get(t);
|
|
32
|
+
if (!r) d.set(t, e);
|
|
33
|
+
else if (n(r) !== n(e)) throw Error(`Fragment ${t} has two different definitions.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
let f = {
|
|
37
|
+
kind: e.OPERATION_DEFINITION,
|
|
38
|
+
operation: t.QUERY,
|
|
39
|
+
name: {
|
|
40
|
+
kind: e.NAME,
|
|
41
|
+
value: o
|
|
42
|
+
},
|
|
43
|
+
variableDefinitions: [...c.values()],
|
|
44
|
+
directives: [],
|
|
45
|
+
selectionSet: {
|
|
46
|
+
kind: e.SELECTION_SET,
|
|
47
|
+
selections: u
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
kind: e.DOCUMENT,
|
|
52
|
+
definitions: [f, ...d.values()]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function s(t) {
|
|
56
|
+
let n = t.definitions.find(r);
|
|
57
|
+
return n ? n.selectionSet.selections.flatMap((t) => t.kind === e.FIELD ? [a(t)] : []) : [];
|
|
58
|
+
}
|
|
59
|
+
function c(e) {
|
|
60
|
+
return !("errors" in e) || !Array.isArray(e.errors) ? [] : e.errors.map((e) => {
|
|
61
|
+
if (!e || typeof e != "object" || !("path" in e) || !Array.isArray(e.path)) return;
|
|
62
|
+
let [t] = e.path;
|
|
63
|
+
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function l(e, t) {
|
|
67
|
+
if (!e) return;
|
|
68
|
+
let n = c(e);
|
|
69
|
+
return n.length === 0 || n.some((e) => e === void 0 || typeof e == "string" && t.includes(e)) ? e : void 0;
|
|
70
|
+
}
|
|
71
|
+
export { l as domainErrorFrom, o as mergeQueryDocuments, s as rootFieldsOf };
|
|
@@ -409,6 +409,17 @@ export type HarvestRecordCreateArgs = Omit<CreateHarvestRecordInput, 'context'>
|
|
|
409
409
|
*/
|
|
410
410
|
clientMutationId?: string;
|
|
411
411
|
};
|
|
412
|
+
/**
|
|
413
|
+
* BOFF-17939 — the workspace data for every HealthyBowl page in ONE operation.
|
|
414
|
+
*
|
|
415
|
+
* Before, each page that mounts `useHealthyBowlData` sent the 15 domain queries
|
|
416
|
+
* above plus the consultations query as 16 operations, split over two HTTP requests by the gateway's limit of
|
|
417
|
+
* 10 operations per batch. The page operation selects the same root fields with
|
|
418
|
+
* the same arguments, so its result fills the same Apollo cache entries; the
|
|
419
|
+
* domain queries then read those entries `cache-first` and only reach the
|
|
420
|
+
* network when the page operation failed or a mutation refetches one slice.
|
|
421
|
+
*/
|
|
422
|
+
export declare const HEALTHYBOWL_WORKSPACE_DATA_DOC: import('graphql').DocumentNode;
|
|
412
423
|
export interface HealthyBowlDataBundle {
|
|
413
424
|
alerts: Alert[];
|
|
414
425
|
analyticsKPIs: AnalyticsKPI[];
|