@burdenoff/microfe-healthybowl 2026.813.26 → 2026.813.27

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.
@@ -21,7 +21,7 @@ var a = "FARM", o = "Farm Tasks", s = i`
21
21
  }
22
22
  `;
23
23
  function l(i, l, u) {
24
- let [d, f] = r(null), [p, m] = r(!1), [h, g] = r(null), [_, v] = r(0), y = n(!1), b = e(() => {
24
+ let [d, f] = r(null), [p, m] = r(!1), [h, g] = r(null), [_, v] = r(0), y = n(null), b = e(() => {
25
25
  g(null), f(null), v((e) => e + 1);
26
26
  }, []);
27
27
  return t(() => {
@@ -30,35 +30,38 @@ function l(i, l, u) {
30
30
  return;
31
31
  }
32
32
  let e = !1;
33
- return y.current = !0, m(!0), g(null), (async () => {
34
- try {
35
- let t = (await i.query({
36
- query: s,
37
- variables: { workspaceId: l },
38
- fetchPolicy: "network-only"
39
- })).data?.planmagnetProjects?.items ?? [], n = t.find((e) => e.key === "FARM") ?? t[0];
40
- if (n) {
41
- e || f(n.id);
42
- return;
43
- }
44
- if (!u) throw Error("Cannot create the Farm Tasks project without a current user.");
45
- let r = (await i.mutate({
46
- mutation: c,
47
- variables: { input: {
48
- name: o,
49
- key: a,
50
- ownerId: u,
51
- methodology: "KANBAN"
52
- } }
53
- })).data?.planmagnetCreateProject?.id;
54
- if (!r) throw Error("createProject did not return a project id.");
55
- e || f(r);
56
- } catch (t) {
57
- e || g(t instanceof Error ? t : Error(String(t)));
58
- } finally {
59
- y.current = !1, e || m(!1);
60
- }
61
- })(), () => {
33
+ m(!0), g(null);
34
+ let t = async () => {
35
+ let e = (await i.query({
36
+ query: s,
37
+ variables: { workspaceId: l },
38
+ fetchPolicy: "network-only"
39
+ })).data?.planmagnetProjects?.items ?? [], t = e.find((e) => e.key === "FARM") ?? e[0];
40
+ if (t) return t.id;
41
+ if (!u) throw Error("Cannot create the Farm Tasks project without a current user.");
42
+ let n = await i.mutate({
43
+ mutation: c,
44
+ variables: { input: {
45
+ name: o,
46
+ key: a,
47
+ ownerId: u,
48
+ methodology: "KANBAN"
49
+ } }
50
+ }), r = n.data?.planmagnetCreateProject?.id;
51
+ if (r) return r;
52
+ let d = n.error?.message?.trim();
53
+ throw Error(d ? `Could not create the Farm Tasks project: ${d}` : "Could not create the Farm Tasks project: the server reported success but returned no project id.");
54
+ }, n = `${l}::${u ?? ""}::${_}`;
55
+ return (!y.current || y.current.key !== n) && (y.current = {
56
+ key: n,
57
+ promise: t()
58
+ }), y.current.promise.then((t) => {
59
+ e || f(t);
60
+ }).catch((t) => {
61
+ y.current?.key === n && (y.current = null), e || g(t instanceof Error ? t : Error(String(t)));
62
+ }).finally(() => {
63
+ e || m(!1);
64
+ }), () => {
62
65
  e = !0;
63
66
  };
64
67
  }, [
@@ -1 +1 @@
1
- {"version":3,"file":"useDefaultTaskProject.js","names":[],"sources":["../../../../src/healthybowl/pages/tasks/useDefaultTaskProject.ts"],"sourcesContent":["/**\n * useDefaultTaskProject — resolves the workspace's default PlanMagnet project\n * that Farm Tasks are created in.\n *\n * The embedded `<TasksPageCore/>` (from `@burdenoff/planmagnet-fe-sdk`) needs a\n * non-null `projectId` to enable the create flow (the backend\n * `PlanmagnetCreateWorkItemInput.projectId` is required). HealthyBowl farmers\n * never see PlanMagnet's project concept, so we transparently get-or-create a\n * single per-workspace \"Farm Tasks\" project and hand its id to the SDK.\n *\n * Strategy:\n * 1. Query `planmagnetProjects(workspaceId)` (prefixed composed root).\n * 2. Reuse the first project whose `key` is FARM_TASKS_PROJECT_KEY, else the\n * first project of any kind (a workspace usually has just this one).\n * 3. If none exist, `planmagnetCreateProject` a \"Farm Tasks\" project.\n *\n * BYO-Apollo: takes the workspace Apollo client as an arg (the same client the\n * SDK board uses) so both the project bootstrap and the board hit the same\n * workspaces gateway with identical auth/context.\n *\n * @module healthybowl\n */\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { gql, type ApolloClient } from '@apollo/client';\n\n/**\n * Deterministic key for the single HealthyBowl \"Farm Tasks\" project per\n * workspace. Used both to create the project and to recognise it on re-load so\n * we never create a second one.\n */\nexport const FARM_TASKS_PROJECT_KEY = 'FARM';\nconst FARM_TASKS_PROJECT_NAME = 'Farm Tasks';\n\n// The composed supergraph exposes PlanMagnet project ops under the\n// `planmagnet*` prefix (WorkItem/Project ops are prefixed post-federation).\nconst LIST_PROJECTS = gql`\n query HealthyBowlListTaskProjects($workspaceId: ID!) {\n planmagnetProjects(workspaceId: $workspaceId) {\n items {\n id\n key\n name\n }\n }\n }\n`;\n\nconst CREATE_PROJECT = gql`\n mutation HealthyBowlCreateTaskProject($input: PlanmagnetCreateProjectInput!) {\n planmagnetCreateProject(input: $input) {\n id\n key\n name\n }\n }\n`;\n\ninterface ProjectRow {\n id: string;\n key: string;\n name: string;\n}\n\ninterface ListProjectsData {\n planmagnetProjects: { items: ProjectRow[] } | null;\n}\n\ninterface CreateProjectData {\n planmagnetCreateProject: ProjectRow;\n}\n\nexport interface UseDefaultTaskProjectResult {\n /** The resolved default-project id, or null while resolving / on error. */\n projectId: string | null;\n loading: boolean;\n error: Error | null;\n /** Re-run the get-or-create flow (e.g. after an error). */\n retry: () => void;\n}\n\n/**\n * Resolve (and lazily create) the workspace's default Farm Tasks project.\n *\n * @param client Workspace Apollo client (BYO — same client the SDK board uses).\n * @param workspaceId Active workspace id (empty string = not ready; hook idles).\n * @param ownerId Actor id to own a freshly-created project (current user).\n */\nexport function useDefaultTaskProject(\n client: ApolloClient | null,\n workspaceId: string,\n ownerId: string | undefined\n): UseDefaultTaskProjectResult {\n const [projectId, setProjectId] = useState<string | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [attempt, setAttempt] = useState(0);\n\n // Guards a get-or-create in flight so a re-render (or React 18 double-invoke\n // in dev) can't fire a second createProject and produce a duplicate project.\n const inFlightRef = useRef(false);\n\n const retry = useCallback(() => {\n setError(null);\n setProjectId(null);\n setAttempt((n) => n + 1);\n }, []);\n\n useEffect(() => {\n if (!client || !workspaceId) {\n setLoading(false);\n return;\n }\n\n let cancelled = false;\n inFlightRef.current = true;\n setLoading(true);\n setError(null);\n\n void (async () => {\n try {\n // 1. Look for an existing project (prefer the canonical FARM key).\n const listed = await client.query<ListProjectsData>({\n query: LIST_PROJECTS,\n variables: { workspaceId },\n fetchPolicy: 'network-only',\n });\n const items = listed.data?.planmagnetProjects?.items ?? [];\n const existing = items.find((p) => p.key === FARM_TASKS_PROJECT_KEY) ?? items[0];\n\n if (existing) {\n if (!cancelled) setProjectId(existing.id);\n return;\n }\n\n // 2. None exist — create the default Farm Tasks project. ownerId is\n // required by the backend; without a current user we can't create.\n if (!ownerId) {\n throw new Error('Cannot create the Farm Tasks project without a current user.');\n }\n\n const created = await client.mutate<CreateProjectData>({\n mutation: CREATE_PROJECT,\n variables: {\n input: {\n name: FARM_TASKS_PROJECT_NAME,\n key: FARM_TASKS_PROJECT_KEY,\n ownerId,\n methodology: 'KANBAN',\n },\n },\n });\n const newId = created.data?.planmagnetCreateProject?.id;\n if (!newId) {\n throw new Error('createProject did not return a project id.');\n }\n if (!cancelled) setProjectId(newId);\n } catch (err) {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n } finally {\n inFlightRef.current = false;\n if (!cancelled) setLoading(false);\n }\n })();\n\n return () => {\n cancelled = true;\n };\n // `attempt` is the retry trigger; ownerId/workspaceId/client re-resolve on change.\n }, [client, workspaceId, ownerId, attempt]);\n\n return { projectId, loading, error, retry };\n}\n"],"mappings":";;;AA+BA,IAAa,IAAyB,QAChC,IAA0B,cAI1B,IAAgB,CAAG;;;;;;;;;;GAYnB,IAAiB,CAAG;;;;;;;;;AAwC1B,SAAgB,EACd,GACA,GACA,GAC6B;CAC7B,IAAM,CAAC,GAAW,KAAgB,EAAwB,KAAK,EACzD,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,CAAC,GAAO,KAAY,EAAuB,KAAK,EAChD,CAAC,GAAS,KAAc,EAAS,EAAE,EAInC,IAAc,EAAO,GAAM,EAE3B,IAAQ,QAAkB;AAG9B,EAFA,EAAS,KAAK,EACd,EAAa,KAAK,EAClB,GAAY,MAAM,IAAI,EAAE;IACvB,EAAE,CAAC;AAmEN,QAjEA,QAAgB;AACd,MAAI,CAAC,KAAU,CAAC,GAAa;AAC3B,KAAW,GAAM;AACjB;;EAGF,IAAI,IAAY;AAqDhB,SApDA,EAAY,UAAU,IACtB,EAAW,GAAK,EAChB,EAAS,KAAK,GAER,YAAY;AAChB,OAAI;IAOF,IAAM,KALS,MAAM,EAAO,MAAwB;KAClD,OAAO;KACP,WAAW,EAAE,gBAAa;KAC1B,aAAa;KACd,CAAC,EACmB,MAAM,oBAAoB,SAAS,EAAE,EACpD,IAAW,EAAM,MAAM,MAAM,EAAE,QAAA,OAA+B,IAAI,EAAM;AAE9E,QAAI,GAAU;AACZ,KAAK,KAAW,EAAa,EAAS,GAAG;AACzC;;AAKF,QAAI,CAAC,EACH,OAAU,MAAM,+DAA+D;IAcjF,IAAM,KAXU,MAAM,EAAO,OAA0B;KACrD,UAAU;KACV,WAAW,EACT,OAAO;MACL,MAAM;MACN,KAAK;MACL;MACA,aAAa;MACd,EACF;KACF,CAAC,EACoB,MAAM,yBAAyB;AACrD,QAAI,CAAC,EACH,OAAU,MAAM,6CAA6C;AAE/D,IAAK,KAAW,EAAa,EAAM;YAC5B,GAAK;AACZ,IAAK,KACH,EAAS,aAAe,QAAQ,IAAU,MAAM,OAAO,EAAI,CAAC,CAAC;aAEvD;AAER,IADA,EAAY,UAAU,IACjB,KAAW,EAAW,GAAM;;MAEjC,QAES;AACX,OAAY;;IAGb;EAAC;EAAQ;EAAa;EAAS;EAAQ,CAAC,EAEpC;EAAE;EAAW;EAAS;EAAO;EAAO"}
1
+ {"version":3,"file":"useDefaultTaskProject.js","names":[],"sources":["../../../../src/healthybowl/pages/tasks/useDefaultTaskProject.ts"],"sourcesContent":["/**\n * useDefaultTaskProject — resolves the workspace's default PlanMagnet project\n * that Farm Tasks are created in.\n *\n * The embedded `<TasksPageCore/>` (from `@burdenoff/planmagnet-fe-sdk`) needs a\n * non-null `projectId` to enable the create flow (the backend\n * `PlanmagnetCreateWorkItemInput.projectId` is required). HealthyBowl farmers\n * never see PlanMagnet's project concept, so we transparently get-or-create a\n * single per-workspace \"Farm Tasks\" project and hand its id to the SDK.\n *\n * Strategy:\n * 1. Query `planmagnetProjects(workspaceId)` (prefixed composed root).\n * 2. Reuse the first project whose `key` is FARM_TASKS_PROJECT_KEY, else the\n * first project of any kind (a workspace usually has just this one).\n * 3. If none exist, `planmagnetCreateProject` a \"Farm Tasks\" project.\n *\n * BYO-Apollo: takes the workspace Apollo client as an arg (the same client the\n * SDK board uses) so both the project bootstrap and the board hit the same\n * workspaces gateway with identical auth/context.\n *\n * @module healthybowl\n */\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { gql, type ApolloClient } from '@apollo/client';\n\n/**\n * Deterministic key for the single HealthyBowl \"Farm Tasks\" project per\n * workspace. Used both to create the project and to recognise it on re-load so\n * we never create a second one.\n */\nexport const FARM_TASKS_PROJECT_KEY = 'FARM';\nconst FARM_TASKS_PROJECT_NAME = 'Farm Tasks';\n\n// The composed supergraph exposes PlanMagnet project ops under the\n// `planmagnet*` prefix (WorkItem/Project ops are prefixed post-federation).\nconst LIST_PROJECTS = gql`\n query HealthyBowlListTaskProjects($workspaceId: ID!) {\n planmagnetProjects(workspaceId: $workspaceId) {\n items {\n id\n key\n name\n }\n }\n }\n`;\n\nconst CREATE_PROJECT = gql`\n mutation HealthyBowlCreateTaskProject($input: PlanmagnetCreateProjectInput!) {\n planmagnetCreateProject(input: $input) {\n id\n key\n name\n }\n }\n`;\n\ninterface ProjectRow {\n id: string;\n key: string;\n name: string;\n}\n\ninterface ListProjectsData {\n planmagnetProjects: { items: ProjectRow[] } | null;\n}\n\ninterface CreateProjectData {\n planmagnetCreateProject: ProjectRow;\n}\n\nexport interface UseDefaultTaskProjectResult {\n /** The resolved default-project id, or null while resolving / on error. */\n projectId: string | null;\n loading: boolean;\n error: Error | null;\n /** Re-run the get-or-create flow (e.g. after an error). */\n retry: () => void;\n}\n\n/**\n * Resolve (and lazily create) the workspace's default Farm Tasks project.\n *\n * @param client Workspace Apollo client (BYO — same client the SDK board uses).\n * @param workspaceId Active workspace id (empty string = not ready; hook idles).\n * @param ownerId Actor id to own a freshly-created project (current user).\n */\nexport function useDefaultTaskProject(\n client: ApolloClient | null,\n workspaceId: string,\n ownerId: string | undefined\n): UseDefaultTaskProjectResult {\n const [projectId, setProjectId] = useState<string | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [attempt, setAttempt] = useState(0);\n\n /**\n * Dedupes the get-or-create across concurrent mounts and React's StrictMode\n * double-invoke, so two resolvers cannot race and create two \"Farm Tasks\"\n * projects for one workspace.\n *\n * ★ This used to be a plain `useRef(false)` that was assigned on entry and\n * cleared in `finally` and **never read** — the comment promised a guard that\n * did not exist (BOFF-6316). Holding the in-flight promise instead of a\n * boolean is what makes it real: a second caller awaits the first rather than\n * being dropped, so cancelling one mount cannot strand the other.\n *\n * Keyed so that changing workspace/owner, or pressing Retry, genuinely\n * re-resolves instead of reusing a stale answer.\n */\n const inFlightRef = useRef<{ key: string; promise: Promise<string> } | null>(null);\n\n const retry = useCallback(() => {\n setError(null);\n setProjectId(null);\n setAttempt((n) => n + 1);\n }, []);\n\n useEffect(() => {\n if (!client || !workspaceId) {\n setLoading(false);\n return;\n }\n\n let cancelled = false;\n setLoading(true);\n setError(null);\n\n const resolveProject = async (): Promise<string> => {\n // 1. Look for an existing project (prefer the canonical FARM key).\n const listed = await client.query<ListProjectsData>({\n query: LIST_PROJECTS,\n variables: { workspaceId },\n fetchPolicy: 'network-only',\n });\n const items = listed.data?.planmagnetProjects?.items ?? [];\n const existing = items.find((p) => p.key === FARM_TASKS_PROJECT_KEY) ?? items[0];\n if (existing) {\n return existing.id;\n }\n\n // 2. None exist — create the default Farm Tasks project. ownerId is\n // required by the backend; without a current user we can't create.\n if (!ownerId) {\n throw new Error('Cannot create the Farm Tasks project without a current user.');\n }\n\n const created = await client.mutate<CreateProjectData>({\n mutation: CREATE_PROJECT,\n variables: {\n input: {\n name: FARM_TASKS_PROJECT_NAME,\n key: FARM_TASKS_PROJECT_KEY,\n ownerId,\n methodology: 'KANBAN',\n },\n },\n });\n\n const newId = created.data?.planmagnetCreateProject?.id;\n if (newId) {\n return newId;\n }\n\n // ★ BOFF-6316. This used to throw a bare \"createProject did not return a\n // project id.\" — the hook's own local disappointment, which told the\n // farmer nothing and hid whatever the gateway actually said. Under\n // `errorPolicy: 'all'` the reason arrives on `result.error` with `data`\n // null, and it was being discarded. Quota refusals, permission denials\n // and network failures all looked identical.\n const reason = created.error?.message?.trim();\n if (reason) {\n throw new Error(`Could not create the Farm Tasks project: ${reason}`);\n }\n // No error AND no id: the mutation reported success but the payload had\n // no id — a genuinely different failure worth naming separately, since it\n // points at the selection set or the resolver rather than at the caller.\n throw new Error(\n 'Could not create the Farm Tasks project: the server reported success but returned no project id.'\n );\n };\n\n const key = `${workspaceId}::${ownerId ?? ''}::${attempt}`;\n if (!inFlightRef.current || inFlightRef.current.key !== key) {\n inFlightRef.current = { key, promise: resolveProject() };\n }\n\n void inFlightRef.current.promise\n .then((id) => {\n if (!cancelled) setProjectId(id);\n })\n .catch((err: unknown) => {\n // Clear the cache so Retry re-runs rather than replaying the rejection.\n if (inFlightRef.current?.key === key) inFlightRef.current = null;\n if (!cancelled) setError(err instanceof Error ? err : new Error(String(err)));\n })\n .finally(() => {\n if (!cancelled) setLoading(false);\n });\n\n return () => {\n cancelled = true;\n };\n // `attempt` is the retry trigger; ownerId/workspaceId/client re-resolve on change.\n }, [client, workspaceId, ownerId, attempt]);\n\n return { projectId, loading, error, retry };\n}\n"],"mappings":";;;AA+BA,IAAa,IAAyB,QAChC,IAA0B,cAI1B,IAAgB,CAAG;;;;;;;;;;GAYnB,IAAiB,CAAG;;;;;;;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AO;AACZ,GAAK,KAAW,EAAa,EAAG;IAChC,CACD,OAAO,MAAiB;AAGvB,GADI,EAAY,SAAS,QAAQ,MAAK,EAAY,UAAU,OACvD,KAAW,EAAS,aAAe,QAAQ,IAAU,MAAM,OAAO,EAAI,CAAC,CAAC;IAC7E,CACD,cAAc;AACb,GAAK,KAAW,EAAW,GAAM;IACjC,QAES;AACX,OAAY;;IAGb;EAAC;EAAQ;EAAa;EAAS;EAAQ,CAAC,EAEpC;EAAE;EAAW;EAAS;EAAO;EAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.813.26",
3
+ "version": "2026.813.27",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [