@burdenoff/microfe-healthybowl 2026.918.3 → 2026.919.1

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.
@@ -34,7 +34,20 @@ var o = r`
34
34
  healthyBowlIncomingOrders(context: $context, status: $status, limit: $limit) {
35
35
  id
36
36
  orderNumber
37
- buyerId
37
+ # NO buyerId. It is not a field on Order in the composed supergraph -- not on any subgraph
38
+ # and not on backend main, where the only buyerId is a member of the input type
39
+ # CreateMarketplaceOrderInput. Selecting it made the WHOLE query fail validation, so the
40
+ # "Incoming from other farms" tab rendered "Something went wrong" and loaded nothing.
41
+ #
42
+ # This was SHIPPED, not a staging problem: verified live 2026-09-19 against prod, which runs
43
+ # microfe-healthybowl 2026.905.4. Clicking that tab produced exactly one error --
44
+ # GRAPHQL_VALIDATION_FAILED, Cannot query field "buyerId" on type "Order", operationName
45
+ # HbIncomingOrders. So it was never a repin regression; the stale pin was carrying it.
46
+ #
47
+ # Nothing consumed it. The field appeared once in this file -- in this selection -- and is
48
+ # absent from the SharedMarketOrder interface. The buyer linkage described elsewhere
49
+ # ("Order.buyerId = Contact.id") is a DATABASE column the GraphQL Order type does not expose.
50
+ # If a buyer is ever needed here, it has to be added to the schema first.
38
51
  total
39
52
  status
40
53
  paymentStatus
@@ -1 +1 @@
1
- {"version":3,"file":"useSharedMarket.js","names":[],"sources":["../../../src/healthybowl/hooks/useSharedMarket.ts"],"sourcesContent":["/**\n * Shared cross-farm marketplace (roadmap #6, acceptance D-1).\n *\n * `MarketplaceProduct` is workspace-scoped, so a buyer normally only ever sees their own farm's\n * listings. A farm OPTS IN per listing (`setHealthyBowlListingShared`) and the shared read then\n * returns listings from EVERY farm that has opted in — a narrowed projection\n * (`SharedMarketListing`) that carries the selling farm's identity, which is the entire point of a\n * cross-farm view.\n *\n * The offline codegen doesn't type these operations (they post-date the checked-in SDL), so —\n * mirroring the raw-gql pattern used for Auctions (`useAuctions`) and Irrigation (`useIrrigation`)\n * — they are hand-written `gql` documents executed directly against the live gateway. Every op\n * carries the workspace `context`.\n * @module healthybowl\n */\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A listing some farm has published to the shared cross-farm market. */\nexport interface SharedMarketListing {\n id: string;\n name: string;\n category: string;\n price: number;\n unit: string;\n stock: number;\n organicCertified: boolean;\n image?: string | null;\n description: string;\n /** The selling farm — what makes a cross-farm view legible. */\n seller?: string | null;\n sellerRating?: number | null;\n location?: string | null;\n rating: number;\n}\n\n/** Server-side filters for the shared-market read. */\nexport interface SharedMarketFilters {\n /** Exact category match; pass null/undefined (or 'All') for every category. */\n category?: string | null;\n /** Free-text match on name / description / seller. */\n search?: string | null;\n limit?: number | null;\n}\n\nconst SHARED_LISTING_FIELDS = `\n id\n name\n category\n price\n unit\n stock\n organicCertified\n image\n description\n seller\n sellerRating\n location\n rating\n`;\n\nconst SHARED_LISTINGS_QUERY = gql`\n query HealthyBowlSharedMarketListings($context: ContextInput!, $category: String, $search: String, $limit: Int) {\n healthyBowlSharedMarketListings(context: $context, category: $category, search: $search, limit: $limit) {\n ${SHARED_LISTING_FIELDS}\n }\n }\n`;\n\nconst SET_LISTING_SHARED = gql`\n mutation SetHealthyBowlListingShared($id: ID!, $shared: Boolean!, $context: ContextInput!) {\n setHealthyBowlListingShared(id: $id, shared: $shared, context: $context) {\n id\n name\n }\n }\n`;\n\ninterface SharedListingsQueryData {\n healthyBowlSharedMarketListings: SharedMarketListing[];\n}\n\ninterface SetListingSharedData {\n setHealthyBowlListingShared: { id: string; name: string };\n}\n\n/**\n * Loads the shared cross-farm listings. Filters are passed to the server (not applied client-side)\n * so the buyer searches every farm's catalogue, not just the page they happen to have loaded.\n *\n * `sharedListingIds` is the set of listing ids currently visible in the shared market. The\n * fixed-price tab uses it to show whether one of the farm's OWN listings is published — the\n * `MarketplaceProduct` type deliberately exposes no `sharedMarket` field, so this is the only\n * server-truth available. Caveat: the shared read excludes out-of-stock listings, so a published\n * listing with zero stock reads as unpublished until it is restocked; a toggle performed in-session\n * overrides that (see `MarketplacePage`).\n */\n/**\n * BOFF-6205 — place a shared-market order, fanning out into ONE ORDER PER SELLING FARM.\n *\n * A shared-market cart can mix produce from several farms. The server resolves each line to the farm\n * that published it and creates one order per farm, so each seller gets its own order, its own total\n * and its own fulfilment — a single row could not represent that.\n */\nconst CREATE_SHARED_ORDERS = gql`\n mutation HbCreateSharedMarketOrders($input: CreateMarketplaceOrderInput!) {\n createHealthyBowlSharedMarketOrders(input: $input) {\n id\n orderNumber\n total\n # BOFF-6090: the server-computed discount actually applied, so the confirmation the buyer\n # sees after placing the order reflects what was really charged, not a client guess.\n discountAmount\n status\n sellerWorkspaceId\n }\n }\n`;\n\n/** BOFF-6205 — orders placed AGAINST this farm by a buyer in another workspace. */\nconst INCOMING_ORDERS = gql`\n query HbIncomingOrders($context: ContextInput!, $status: String, $limit: Int) {\n healthyBowlIncomingOrders(context: $context, status: $status, limit: $limit) {\n id\n orderNumber\n buyerId\n total\n status\n paymentStatus\n date\n sellerWorkspaceId\n items {\n productName\n quantity\n price\n unit\n }\n }\n }\n`;\n\nexport interface SharedMarketOrder {\n id: string;\n orderNumber: string;\n total: number;\n /** BOFF-6090: the server-computed discount actually applied to this order; 0 when none was. */\n discountAmount: number;\n status: string;\n sellerWorkspaceId: string | null;\n}\n\n/** Place a cross-farm order. Returns one order per selling farm. */\nexport function useCreateSharedMarketOrders() {\n const { workspaceId } = useHealthyBowl();\n const [mutate, { loading }] = useMutation(CREATE_SHARED_ORDERS);\n\n const placeSharedOrders = useCallback(\n async (input: Record<string, unknown>): Promise<SharedMarketOrder[]> => {\n const res = await mutate({ variables: { input: { ...input, context: { workspaceId } } } });\n if (res.error) throw res.error;\n return (\n (res.data as { createHealthyBowlSharedMarketOrders: SharedMarketOrder[] } | undefined)\n ?.createHealthyBowlSharedMarketOrders ?? []\n );\n },\n [mutate, workspaceId]\n );\n\n return { placeSharedOrders, placing: loading };\n}\n\n/**\n * Orders other farms have placed against this one.\n *\n * ★ Deliberately does NOT fall back to a placeholder workspace id the way the read-only hooks do.\n * `healthyBowlIncomingOrders` filters on `sellerWorkspaceId = <caller>`, so querying with a\n * placeholder returns an empty list that is indistinguishable from \"nobody has ordered from you\" —\n * the UI would state, as fact, that a farm has no orders when we simply do not know which farm it\n * is. Instead the query is skipped and `workspaceReady` is false, so the caller can say so.\n */\nexport function useIncomingOrders(options: { status?: string | null; skip?: boolean } = {}) {\n const { workspaceId } = useHealthyBowl();\n const workspaceReady = Boolean(workspaceId);\n const { data, loading, error, refetch } = useQuery(INCOMING_ORDERS, {\n variables: { context: { workspaceId }, status: options.status ?? null, limit: 50 },\n fetchPolicy: 'cache-and-network',\n skip: options.skip === true || !workspaceReady,\n });\n return {\n incomingOrders:\n (data as { healthyBowlIncomingOrders?: Record<string, unknown>[] } | undefined)?.healthyBowlIncomingOrders ?? [],\n loading,\n error,\n refetch,\n workspaceReady,\n };\n}\n\nexport function useSharedMarketListings(filters: SharedMarketFilters = {}) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const category = filters.category && filters.category !== 'All' ? filters.category : null;\n const search = filters.search?.trim() ? filters.search.trim() : null;\n const limit = filters.limit ?? null;\n\n const { data, loading, error, refetch } = useQuery<SharedListingsQueryData>(SHARED_LISTINGS_QUERY, {\n variables: { context, category, search, limit },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const listings = useMemo(() => data?.healthyBowlSharedMarketListings ?? [], [data]);\n const sharedListingIds = useMemo(() => new Set(listings.map((l) => l.id)), [listings]);\n\n return { listings, sharedListingIds, loading, error, refetch };\n}\n\n/**\n * A live auction another farm has published to the shared cross-farm market (BOFF-6206).\n *\n * A narrow projection: it carries what a cross-farm bidder needs — the product, the selling farm, the\n * close time and the CURRENT high bid. It never exposes the reserve price or rival bidder identities.\n */\nexport interface SharedMarketAuction {\n id: string;\n productName: string;\n unit: string;\n /** The selling farm — what makes a cross-farm view legible. */\n seller?: string | null;\n /** Auction close time as an ISO-8601 string. */\n endTime: string;\n startingPrice: number;\n bidIncrement: number;\n /** The current high bid, or startingPrice when nobody has bid yet. Never the reserve. */\n currentBid: number;\n bidCount: number;\n status: string;\n}\n\nconst SHARED_AUCTIONS_QUERY = gql`\n query HealthyBowlSharedMarketAuctions($context: ContextInput!, $limit: Int) {\n healthyBowlSharedMarketAuctions(context: $context, limit: $limit) {\n id\n productName\n unit\n seller\n endTime\n startingPrice\n bidIncrement\n currentBid\n bidCount\n status\n }\n }\n`;\n\nconst PLACE_SHARED_BID = gql`\n mutation HealthyBowlPlaceSharedBid($auctionId: ID!, $amount: Float!, $context: ContextInput!) {\n placeHealthyBowlBid(auctionId: $auctionId, amount: $amount, context: $context) {\n id\n auctionId\n bidderId\n amount\n createdAt\n }\n }\n`;\n\ninterface SharedAuctionsQueryData {\n healthyBowlSharedMarketAuctions: SharedMarketAuction[];\n}\n\n/** The minimum acceptable next bid: startingPrice with no bids, else the current high + increment. */\nexport function minNextBid(\n auction: Pick<SharedMarketAuction, 'currentBid' | 'bidIncrement' | 'bidCount' | 'startingPrice'>\n): number {\n return auction.bidCount > 0 ? auction.currentBid + auction.bidIncrement : auction.startingPrice;\n}\n\n/**\n * Live auctions on shared listings from EVERY farm (BOFF-6206), plus cross-farm bid placement.\n *\n * The read is cross-workspace by design (`healthyBowlSharedMarketAuctions` runs unscoped server-side).\n * `placeBid` reuses the ordinary `placeHealthyBowlBid` mutation carrying the caller's own workspace\n * `context`; the server pins the seller's workspace, so a Farm B bid becomes the new high bid inside\n * Farm A's own auction. On success the shared list is refetched so the Current Bid updates in place.\n */\nexport function useSharedMarketAuctions(options: { limit?: number | null } = {}) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<SharedAuctionsQueryData>(SHARED_AUCTIONS_QUERY, {\n variables: { context, limit: options.limit ?? null },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [placeBidMutation, { loading: placing }] = useMutation(PLACE_SHARED_BID);\n\n const auctions = useMemo(() => data?.healthyBowlSharedMarketAuctions ?? [], [data]);\n\n const placeBid = useCallback(\n async (auctionId: string, amount: number) => {\n // This Apollo Client version's mutate resolves to a MutateResult whose GraphQL/network failure\n // is `error` (singular ApolloError) — not `errors`. Capture it so the caller's toast reports the\n // real rejection (e.g. \"Bid too low\"). Mirrors the shipped useCreateSharedMarketOrders.\n let bidError: unknown = null;\n try {\n // Build the context inline from workspaceId (its only ingredient) so the callback's deps are\n // honest and no eslint-disable is needed — the outer `context` object is a new ref each render.\n const res = await placeBidMutation({ variables: { auctionId, amount, context: { workspaceId } } });\n if (res.error) bidError = res.error;\n } catch (err) {\n bidError = err;\n }\n // Refresh either way — a rejection usually means a rival just raised the high bid, so the buyer\n // must see the new current bid, not fly blind. But this refresh is BEST-EFFORT: a refetch failure\n // must never turn a bid that actually landed into an apparent failure (nor swallow a real reject).\n await refetch().catch(() => undefined);\n if (bidError) throw bidError;\n },\n [placeBidMutation, refetch, workspaceId]\n );\n\n return { auctions, loading, error, refetch, placeBid, placing };\n}\n\n/**\n * Publish / unpublish one of the farm's OWN listings to the shared cross-farm market.\n * Workspace-scoped server-side: a farm can only ever change the flag on its own listings.\n */\nexport function useSetListingShared() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const [mutate, { loading }] = useMutation<SetListingSharedData>(SET_LISTING_SHARED);\n\n const setListingShared = useCallback(\n async (id: string, shared: boolean) => {\n const res = await mutate({ variables: { id, shared, context } });\n return res.data?.setHealthyBowlListingShared;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [mutate, workspaceId]\n );\n\n return { setListingShared, saving: loading };\n}\n"],"mappings":";;;;;AA+DA,IAAM,IAAwB,CAAG;;;QAGzB,qJAAsB;;;GAKxB,IAAqB,C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GAAQ,EAAE,gBAAa,EAAkC,CAAkB;CAWlF,OAAO;EAAE,kBATgB,EACvB,OAAO,GAAY,OAEV,MADW,EAAO,EAAE,WAAW;GAAE;GAAI;GAAQ;EAAQ,EAAE,CAAC,GACpD,MAAM,6BAGnB,CAAC,GAAQ,CAAW,CAGb;EAAkB,QAAQ;CAAQ;AAC7C"}
1
+ {"version":3,"file":"useSharedMarket.js","names":[],"sources":["../../../src/healthybowl/hooks/useSharedMarket.ts"],"sourcesContent":["/**\n * Shared cross-farm marketplace (roadmap #6, acceptance D-1).\n *\n * `MarketplaceProduct` is workspace-scoped, so a buyer normally only ever sees their own farm's\n * listings. A farm OPTS IN per listing (`setHealthyBowlListingShared`) and the shared read then\n * returns listings from EVERY farm that has opted in — a narrowed projection\n * (`SharedMarketListing`) that carries the selling farm's identity, which is the entire point of a\n * cross-farm view.\n *\n * The offline codegen doesn't type these operations (they post-date the checked-in SDL), so —\n * mirroring the raw-gql pattern used for Auctions (`useAuctions`) and Irrigation (`useIrrigation`)\n * — they are hand-written `gql` documents executed directly against the live gateway. Every op\n * carries the workspace `context`.\n * @module healthybowl\n */\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A listing some farm has published to the shared cross-farm market. */\nexport interface SharedMarketListing {\n id: string;\n name: string;\n category: string;\n price: number;\n unit: string;\n stock: number;\n organicCertified: boolean;\n image?: string | null;\n description: string;\n /** The selling farm — what makes a cross-farm view legible. */\n seller?: string | null;\n sellerRating?: number | null;\n location?: string | null;\n rating: number;\n}\n\n/** Server-side filters for the shared-market read. */\nexport interface SharedMarketFilters {\n /** Exact category match; pass null/undefined (or 'All') for every category. */\n category?: string | null;\n /** Free-text match on name / description / seller. */\n search?: string | null;\n limit?: number | null;\n}\n\nconst SHARED_LISTING_FIELDS = `\n id\n name\n category\n price\n unit\n stock\n organicCertified\n image\n description\n seller\n sellerRating\n location\n rating\n`;\n\nconst SHARED_LISTINGS_QUERY = gql`\n query HealthyBowlSharedMarketListings($context: ContextInput!, $category: String, $search: String, $limit: Int) {\n healthyBowlSharedMarketListings(context: $context, category: $category, search: $search, limit: $limit) {\n ${SHARED_LISTING_FIELDS}\n }\n }\n`;\n\nconst SET_LISTING_SHARED = gql`\n mutation SetHealthyBowlListingShared($id: ID!, $shared: Boolean!, $context: ContextInput!) {\n setHealthyBowlListingShared(id: $id, shared: $shared, context: $context) {\n id\n name\n }\n }\n`;\n\ninterface SharedListingsQueryData {\n healthyBowlSharedMarketListings: SharedMarketListing[];\n}\n\ninterface SetListingSharedData {\n setHealthyBowlListingShared: { id: string; name: string };\n}\n\n/**\n * Loads the shared cross-farm listings. Filters are passed to the server (not applied client-side)\n * so the buyer searches every farm's catalogue, not just the page they happen to have loaded.\n *\n * `sharedListingIds` is the set of listing ids currently visible in the shared market. The\n * fixed-price tab uses it to show whether one of the farm's OWN listings is published — the\n * `MarketplaceProduct` type deliberately exposes no `sharedMarket` field, so this is the only\n * server-truth available. Caveat: the shared read excludes out-of-stock listings, so a published\n * listing with zero stock reads as unpublished until it is restocked; a toggle performed in-session\n * overrides that (see `MarketplacePage`).\n */\n/**\n * BOFF-6205 — place a shared-market order, fanning out into ONE ORDER PER SELLING FARM.\n *\n * A shared-market cart can mix produce from several farms. The server resolves each line to the farm\n * that published it and creates one order per farm, so each seller gets its own order, its own total\n * and its own fulfilment — a single row could not represent that.\n */\nconst CREATE_SHARED_ORDERS = gql`\n mutation HbCreateSharedMarketOrders($input: CreateMarketplaceOrderInput!) {\n createHealthyBowlSharedMarketOrders(input: $input) {\n id\n orderNumber\n total\n # BOFF-6090: the server-computed discount actually applied, so the confirmation the buyer\n # sees after placing the order reflects what was really charged, not a client guess.\n discountAmount\n status\n sellerWorkspaceId\n }\n }\n`;\n\n/** BOFF-6205 — orders placed AGAINST this farm by a buyer in another workspace. */\nconst INCOMING_ORDERS = gql`\n query HbIncomingOrders($context: ContextInput!, $status: String, $limit: Int) {\n healthyBowlIncomingOrders(context: $context, status: $status, limit: $limit) {\n id\n orderNumber\n # NO buyerId. It is not a field on Order in the composed supergraph -- not on any subgraph\n # and not on backend main, where the only buyerId is a member of the input type\n # CreateMarketplaceOrderInput. Selecting it made the WHOLE query fail validation, so the\n # \"Incoming from other farms\" tab rendered \"Something went wrong\" and loaded nothing.\n #\n # This was SHIPPED, not a staging problem: verified live 2026-09-19 against prod, which runs\n # microfe-healthybowl 2026.905.4. Clicking that tab produced exactly one error --\n # GRAPHQL_VALIDATION_FAILED, Cannot query field \"buyerId\" on type \"Order\", operationName\n # HbIncomingOrders. So it was never a repin regression; the stale pin was carrying it.\n #\n # Nothing consumed it. The field appeared once in this file -- in this selection -- and is\n # absent from the SharedMarketOrder interface. The buyer linkage described elsewhere\n # (\"Order.buyerId = Contact.id\") is a DATABASE column the GraphQL Order type does not expose.\n # If a buyer is ever needed here, it has to be added to the schema first.\n total\n status\n paymentStatus\n date\n sellerWorkspaceId\n items {\n productName\n quantity\n price\n unit\n }\n }\n }\n`;\n\nexport interface SharedMarketOrder {\n id: string;\n orderNumber: string;\n total: number;\n /** BOFF-6090: the server-computed discount actually applied to this order; 0 when none was. */\n discountAmount: number;\n status: string;\n sellerWorkspaceId: string | null;\n}\n\n/** Place a cross-farm order. Returns one order per selling farm. */\nexport function useCreateSharedMarketOrders() {\n const { workspaceId } = useHealthyBowl();\n const [mutate, { loading }] = useMutation(CREATE_SHARED_ORDERS);\n\n const placeSharedOrders = useCallback(\n async (input: Record<string, unknown>): Promise<SharedMarketOrder[]> => {\n const res = await mutate({ variables: { input: { ...input, context: { workspaceId } } } });\n if (res.error) throw res.error;\n return (\n (res.data as { createHealthyBowlSharedMarketOrders: SharedMarketOrder[] } | undefined)\n ?.createHealthyBowlSharedMarketOrders ?? []\n );\n },\n [mutate, workspaceId]\n );\n\n return { placeSharedOrders, placing: loading };\n}\n\n/**\n * Orders other farms have placed against this one.\n *\n * ★ Deliberately does NOT fall back to a placeholder workspace id the way the read-only hooks do.\n * `healthyBowlIncomingOrders` filters on `sellerWorkspaceId = <caller>`, so querying with a\n * placeholder returns an empty list that is indistinguishable from \"nobody has ordered from you\" —\n * the UI would state, as fact, that a farm has no orders when we simply do not know which farm it\n * is. Instead the query is skipped and `workspaceReady` is false, so the caller can say so.\n */\nexport function useIncomingOrders(options: { status?: string | null; skip?: boolean } = {}) {\n const { workspaceId } = useHealthyBowl();\n const workspaceReady = Boolean(workspaceId);\n const { data, loading, error, refetch } = useQuery(INCOMING_ORDERS, {\n variables: { context: { workspaceId }, status: options.status ?? null, limit: 50 },\n fetchPolicy: 'cache-and-network',\n skip: options.skip === true || !workspaceReady,\n });\n return {\n incomingOrders:\n (data as { healthyBowlIncomingOrders?: Record<string, unknown>[] } | undefined)?.healthyBowlIncomingOrders ?? [],\n loading,\n error,\n refetch,\n workspaceReady,\n };\n}\n\nexport function useSharedMarketListings(filters: SharedMarketFilters = {}) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const category = filters.category && filters.category !== 'All' ? filters.category : null;\n const search = filters.search?.trim() ? filters.search.trim() : null;\n const limit = filters.limit ?? null;\n\n const { data, loading, error, refetch } = useQuery<SharedListingsQueryData>(SHARED_LISTINGS_QUERY, {\n variables: { context, category, search, limit },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const listings = useMemo(() => data?.healthyBowlSharedMarketListings ?? [], [data]);\n const sharedListingIds = useMemo(() => new Set(listings.map((l) => l.id)), [listings]);\n\n return { listings, sharedListingIds, loading, error, refetch };\n}\n\n/**\n * A live auction another farm has published to the shared cross-farm market (BOFF-6206).\n *\n * A narrow projection: it carries what a cross-farm bidder needs — the product, the selling farm, the\n * close time and the CURRENT high bid. It never exposes the reserve price or rival bidder identities.\n */\nexport interface SharedMarketAuction {\n id: string;\n productName: string;\n unit: string;\n /** The selling farm — what makes a cross-farm view legible. */\n seller?: string | null;\n /** Auction close time as an ISO-8601 string. */\n endTime: string;\n startingPrice: number;\n bidIncrement: number;\n /** The current high bid, or startingPrice when nobody has bid yet. Never the reserve. */\n currentBid: number;\n bidCount: number;\n status: string;\n}\n\nconst SHARED_AUCTIONS_QUERY = gql`\n query HealthyBowlSharedMarketAuctions($context: ContextInput!, $limit: Int) {\n healthyBowlSharedMarketAuctions(context: $context, limit: $limit) {\n id\n productName\n unit\n seller\n endTime\n startingPrice\n bidIncrement\n currentBid\n bidCount\n status\n }\n }\n`;\n\nconst PLACE_SHARED_BID = gql`\n mutation HealthyBowlPlaceSharedBid($auctionId: ID!, $amount: Float!, $context: ContextInput!) {\n placeHealthyBowlBid(auctionId: $auctionId, amount: $amount, context: $context) {\n id\n auctionId\n bidderId\n amount\n createdAt\n }\n }\n`;\n\ninterface SharedAuctionsQueryData {\n healthyBowlSharedMarketAuctions: SharedMarketAuction[];\n}\n\n/** The minimum acceptable next bid: startingPrice with no bids, else the current high + increment. */\nexport function minNextBid(\n auction: Pick<SharedMarketAuction, 'currentBid' | 'bidIncrement' | 'bidCount' | 'startingPrice'>\n): number {\n return auction.bidCount > 0 ? auction.currentBid + auction.bidIncrement : auction.startingPrice;\n}\n\n/**\n * Live auctions on shared listings from EVERY farm (BOFF-6206), plus cross-farm bid placement.\n *\n * The read is cross-workspace by design (`healthyBowlSharedMarketAuctions` runs unscoped server-side).\n * `placeBid` reuses the ordinary `placeHealthyBowlBid` mutation carrying the caller's own workspace\n * `context`; the server pins the seller's workspace, so a Farm B bid becomes the new high bid inside\n * Farm A's own auction. On success the shared list is refetched so the Current Bid updates in place.\n */\nexport function useSharedMarketAuctions(options: { limit?: number | null } = {}) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<SharedAuctionsQueryData>(SHARED_AUCTIONS_QUERY, {\n variables: { context, limit: options.limit ?? null },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [placeBidMutation, { loading: placing }] = useMutation(PLACE_SHARED_BID);\n\n const auctions = useMemo(() => data?.healthyBowlSharedMarketAuctions ?? [], [data]);\n\n const placeBid = useCallback(\n async (auctionId: string, amount: number) => {\n // This Apollo Client version's mutate resolves to a MutateResult whose GraphQL/network failure\n // is `error` (singular ApolloError) — not `errors`. Capture it so the caller's toast reports the\n // real rejection (e.g. \"Bid too low\"). Mirrors the shipped useCreateSharedMarketOrders.\n let bidError: unknown = null;\n try {\n // Build the context inline from workspaceId (its only ingredient) so the callback's deps are\n // honest and no eslint-disable is needed — the outer `context` object is a new ref each render.\n const res = await placeBidMutation({ variables: { auctionId, amount, context: { workspaceId } } });\n if (res.error) bidError = res.error;\n } catch (err) {\n bidError = err;\n }\n // Refresh either way — a rejection usually means a rival just raised the high bid, so the buyer\n // must see the new current bid, not fly blind. But this refresh is BEST-EFFORT: a refetch failure\n // must never turn a bid that actually landed into an apparent failure (nor swallow a real reject).\n await refetch().catch(() => undefined);\n if (bidError) throw bidError;\n },\n [placeBidMutation, refetch, workspaceId]\n );\n\n return { auctions, loading, error, refetch, placeBid, placing };\n}\n\n/**\n * Publish / unpublish one of the farm's OWN listings to the shared cross-farm market.\n * Workspace-scoped server-side: a farm can only ever change the flag on its own listings.\n */\nexport function useSetListingShared() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const [mutate, { loading }] = useMutation<SetListingSharedData>(SET_LISTING_SHARED);\n\n const setListingShared = useCallback(\n async (id: string, shared: boolean) => {\n const res = await mutate({ variables: { id, shared, context } });\n return res.data?.setHealthyBowlListingShared;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [mutate, workspaceId]\n );\n\n return { setListingShared, saving: loading };\n}\n"],"mappings":";;;;;AA+DA,IAAM,IAAwB,CAAG;;;QAGzB,qJAAsB;;;GAKxB,IAAqB,CAAG;;;;;;;GAmCxB,IAAuB,CAAG;;;;;;;;;;;;;GAgB1B,IAAkB,CAAG;;;;;;;;;;;;;;;;;;;;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Y,OAEV,MADW,EAAO,EAAE,WAAW;GAAE;GAAI;GAAQ;EAAQ,EAAE,CAAC,GACpD,MAAM,6BAGnB,CAAC,GAAQ,CAAW,CAGb;EAAkB,QAAQ;CAAQ;AAC7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useWorkspaceWriteAccess.js","names":[],"sources":["../../src/hooks/useWorkspaceWriteAccess.ts"],"sourcesContent":["/**\n * HealthyBowl's write-access probe.\n *\n * ★ The mechanism moved to `fe-libs/shared/assistant`; the RESOURCE TYPES stay\n * here, because which resources prove \"this user can write in this workspace\"\n * is the product's answer. The shared hook takes them with no default, so\n * another product cannot accidentally probe crops.\n */\nimport { useWorkspaceWriteAccess as useShared } from '@burdenoff/fe-libs/shared/assistant/useWorkspaceWriteAccess';\nexport type { WorkspaceWriteAccess } from '@burdenoff/fe-libs/shared/assistant/useWorkspaceWriteAccess';\n\n/**\n * Resources a Take-action turn is most likely to write. Not exhaustive — the\n * assistant can reach far more — but a representative probe.\n */\nconst PROBE_RESOURCES = ['healthybowl_crop', 'healthybowl_field', 'healthybowl_task'] as const;\n\nexport function useWorkspaceWriteAccess(actorId: string | null, workspaceId: string | null) {\n return useShared(actorId, workspaceId, PROBE_RESOURCES);\n}\n"],"mappings":";;AAeA,IAAM,IAAkB;CAAC;CAAoB;CAAqB;AAAkB;AAEpF,SAAgB,EAAwB,GAAwB,GAA4B;CAC1F,OAAO,EAAU,GAAS,GAAa,CAAe;AACxD"}
1
+ {"version":3,"file":"useWorkspaceWriteAccess.js","names":[],"sources":["../../src/hooks/useWorkspaceWriteAccess.ts"],"sourcesContent":["/**\n * HealthyBowl's write-access probe.\n *\n * ★ The mechanism moved to `fe-libs/shared/assistant`; the RESOURCE TYPES stay\n * here, because which resources prove \"this user can write in this workspace\"\n * is the product's answer. The shared hook takes them with no default, so\n * another product cannot accidentally probe crops.\n */\nimport { useWorkspaceWriteAccess as useShared } from '@burdenoff/fe-libs/shared/assistant/useWorkspaceWriteAccess';\nimport type { WorkspaceWriteAccess } from '@burdenoff/fe-libs/shared/assistant/useWorkspaceWriteAccess';\nexport type { WorkspaceWriteAccess } from '@burdenoff/fe-libs/shared/assistant/useWorkspaceWriteAccess';\n\n/**\n * Resources a Take-action turn is most likely to write. Not exhaustive — the\n * assistant can reach far more — but a representative probe.\n */\nconst PROBE_RESOURCES = ['healthybowl_crop', 'healthybowl_field', 'healthybowl_task'] as const;\n\n// ★ Annotated on purpose. Without it the return type is whatever fe-libs currently infers, so an\n// upstream shape change surfaces at every CALL SITE rather than here at the seam — the one file\n// whose job is to be where that break is noticed.\nexport function useWorkspaceWriteAccess(actorId: string | null, workspaceId: string | null): WorkspaceWriteAccess {\n return useShared(actorId, workspaceId, PROBE_RESOURCES);\n}\n"],"mappings":";;AAgBA,IAAM,IAAkB;CAAC;CAAoB;CAAqB;AAAkB;AAKpF,SAAgB,EAAwB,GAAwB,GAAkD;CAChH,OAAO,EAAU,GAAS,GAAa,CAAe;AACxD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.918.3",
3
+ "version": "2026.919.1",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [