@fluid-app/portal-sdk 0.1.159 → 0.1.161
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/README.md +2 -196
- package/dist/{FluidProvider-Cqf2kmUc.mjs → FluidProvider-B00jTGTH.mjs} +1510 -1624
- package/dist/FluidProvider-B00jTGTH.mjs.map +1 -0
- package/dist/{FluidProvider-Bc-3uN7M.cjs → FluidProvider-BtGi2jJt.cjs} +1458 -1614
- package/dist/FluidProvider-BtGi2jJt.cjs.map +1 -0
- package/dist/{MessagingScreen-BGqIn-c2.cjs → MessagingScreen-BRCUJDDZ.cjs} +2 -2
- package/dist/{MessagingScreen-CbmuvlH6.mjs → MessagingScreen-BWpSXB8Q.mjs} +2 -2
- package/dist/{MessagingScreen-CbmuvlH6.mjs.map → MessagingScreen-BWpSXB8Q.mjs.map} +1 -1
- package/dist/{MessagingScreen-CBPjP4du.cjs → MessagingScreen-C_OLIWCC.cjs} +2 -2
- package/dist/{MessagingScreen-CBPjP4du.cjs.map → MessagingScreen-C_OLIWCC.cjs.map} +1 -1
- package/dist/{MySiteScreen-DSDLDnCN.cjs → MySiteScreen-B90qzZPe.cjs} +2 -2
- package/dist/{MySiteScreen-Cl6nuU99.cjs → MySiteScreen-DLuHDXB1.cjs} +2 -2
- package/dist/{MySiteScreen-Cl6nuU99.cjs.map → MySiteScreen-DLuHDXB1.cjs.map} +1 -1
- package/dist/{MySiteScreen-BT1PBPsH.mjs → MySiteScreen-VaOB-vWk.mjs} +2 -2
- package/dist/{MySiteScreen-BT1PBPsH.mjs.map → MySiteScreen-VaOB-vWk.mjs.map} +1 -1
- package/dist/ProductsScreen-B8OynxlP.cjs +13 -0
- package/dist/{ProductsScreen-4WRrJcvw.mjs → ProductsScreen-CbVSNv1l.mjs} +3 -5
- package/dist/ProductsScreen-CbVSNv1l.mjs.map +1 -0
- package/dist/{ProductsScreen-BCs3YKVk.cjs → ProductsScreen-D1bw4ZIH.cjs} +3 -5
- package/dist/ProductsScreen-D1bw4ZIH.cjs.map +1 -0
- package/dist/ProductsScreen-Pq3j09nI.mjs +11 -0
- package/dist/{ProfileScreen-BgyrIQdL.mjs → ProfileScreen-BCHljkWD.mjs} +2 -2
- package/dist/{ProfileScreen-BgyrIQdL.mjs.map → ProfileScreen-BCHljkWD.mjs.map} +1 -1
- package/dist/{ProfileScreen-B0KNWXpV.cjs → ProfileScreen-Bf-lYNzz.cjs} +2 -2
- package/dist/{ProfileScreen-DLLLRNB2.cjs → ProfileScreen-ksdtbydb.cjs} +2 -2
- package/dist/{ProfileScreen-DLLLRNB2.cjs.map → ProfileScreen-ksdtbydb.cjs.map} +1 -1
- package/dist/{ShareablesScreen-ySSwCVSI.cjs → ShareablesScreen-6wgiwi_9.cjs} +3 -5
- package/dist/ShareablesScreen-6wgiwi_9.cjs.map +1 -0
- package/dist/{ShareablesScreen-B8cmh8JC.mjs → ShareablesScreen-BLCukNTk.mjs} +3 -5
- package/dist/{ShareablesScreen-B8cmh8JC.mjs.map → ShareablesScreen-BLCukNTk.mjs.map} +1 -1
- package/dist/ShareablesScreen-CM9OH-Nx.mjs +11 -0
- package/dist/ShareablesScreen-rmLcUhbL.cjs +13 -0
- package/dist/{ShopScreen-DhMo8bvP.cjs → ShopScreen-8KKwwjka.cjs} +3 -3
- package/dist/{ShopScreen-DhMo8bvP.cjs.map → ShopScreen-8KKwwjka.cjs.map} +1 -1
- package/dist/{ShopScreen-BkvyW0pE.cjs → ShopScreen-CjEbB3Q7.cjs} +2 -2
- package/dist/{ShopScreen-BFFGYwdV.mjs → ShopScreen-Dn5LwwYD.mjs} +3 -3
- package/dist/{ShopScreen-BFFGYwdV.mjs.map → ShopScreen-Dn5LwwYD.mjs.map} +1 -1
- package/dist/{SubscriptionsScreen-RScBCcY0.cjs → SubscriptionsScreen-B16wPAoA.cjs} +2 -2
- package/dist/SubscriptionsScreen-B16wPAoA.cjs.map +1 -0
- package/dist/{SubscriptionsScreen-CiNR7JUC.mjs → SubscriptionsScreen-B4cTlgDU.mjs} +2 -2
- package/dist/SubscriptionsScreen-B4cTlgDU.mjs.map +1 -0
- package/dist/{SubscriptionsScreen-DMh-GE6n.cjs → SubscriptionsScreen-nRUMdnx7.cjs} +1 -1
- package/dist/{dist-Bg8UyHyM.cjs → dist-lO2OG0T5.cjs} +1 -1
- package/dist/{dist-Bg8UyHyM.cjs.map → dist-lO2OG0T5.cjs.map} +1 -1
- package/dist/index.cjs +134 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +444 -655
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +444 -655
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +127 -130
- package/dist/index.mjs.map +1 -1
- package/dist/{sortable.esm-Cz-CP2N8.mjs → sortable.esm-DSrWP4x9.mjs} +1 -1
- package/dist/{sortable.esm-Cz-CP2N8.mjs.map → sortable.esm-DSrWP4x9.mjs.map} +1 -1
- package/dist/{use-portal-products-client-BmlUixy4.cjs → use-portal-products-client-BHSBT64s.cjs} +2 -2
- package/dist/use-portal-products-client-BHSBT64s.cjs.map +1 -0
- package/dist/{use-portal-products-client-DQK9nFxT.mjs → use-portal-products-client-tbqk6XUq.mjs} +2 -2
- package/dist/use-portal-products-client-tbqk6XUq.mjs.map +1 -0
- package/dist/{use-portal-shareables-api-KVPj0Jfr.mjs → use-portal-shareables-api-B9B4XTjw.mjs} +107 -201
- package/dist/use-portal-shareables-api-B9B4XTjw.mjs.map +1 -0
- package/dist/{use-portal-shareables-api-D5D6uIJy.cjs → use-portal-shareables-api-MBl0d0eQ.cjs} +106 -206
- package/dist/use-portal-shareables-api-MBl0d0eQ.cjs.map +1 -0
- package/package.json +13 -13
- package/dist/FluidProvider-Bc-3uN7M.cjs.map +0 -1
- package/dist/FluidProvider-Cqf2kmUc.mjs.map +0 -1
- package/dist/ProductsScreen-4WRrJcvw.mjs.map +0 -1
- package/dist/ProductsScreen-BCs3YKVk.cjs.map +0 -1
- package/dist/ProductsScreen-BR9TN4So.cjs +0 -48
- package/dist/ProductsScreen-Da6eWJ_c.mjs +0 -46
- package/dist/ShareablesScreen-DW0wCYOj.mjs +0 -46
- package/dist/ShareablesScreen-DbPJOtCF.cjs +0 -48
- package/dist/ShareablesScreen-ySSwCVSI.cjs.map +0 -1
- package/dist/SubscriptionsScreen-CiNR7JUC.mjs.map +0 -1
- package/dist/SubscriptionsScreen-RScBCcY0.cjs.map +0 -1
- package/dist/use-portal-products-client-BmlUixy4.cjs.map +0 -1
- package/dist/use-portal-products-client-DQK9nFxT.mjs.map +0 -1
- package/dist/use-portal-shareables-api-D5D6uIJy.cjs.map +0 -1
- package/dist/use-portal-shareables-api-KVPj0Jfr.mjs.map +0 -1
package/dist/{use-portal-products-client-BmlUixy4.cjs → use-portal-products-client-BHSBT64s.cjs}
RENAMED
|
@@ -2,7 +2,7 @@ require("./chunk-9hOWP6kD.cjs");
|
|
|
2
2
|
const require_portal_tenant = require("./portal_tenant-CSxWYAH-.cjs");
|
|
3
3
|
const require_PortalTenantClientProvider = require("./PortalTenantClientProvider-C4Gnq5tJ.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
|
-
//#region
|
|
5
|
+
//#region src/adapters/products-api-adapter.ts
|
|
6
6
|
/**
|
|
7
7
|
* Creates a PortalProductsApi-compatible adapter from a portal-tenant FetchClient.
|
|
8
8
|
*
|
|
@@ -63,4 +63,4 @@ Object.defineProperty(exports, "usePortalProductsClient", {
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
//# sourceMappingURL=use-portal-products-client-
|
|
66
|
+
//# sourceMappingURL=use-portal-products-client-BHSBT64s.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-portal-products-client-BHSBT64s.cjs","names":["usePortalTenantClient"],"sources":["../src/adapters/products-api-adapter.ts","../src/products/use-portal-products-client.ts"],"sourcesContent":["import type {\n PortalProductsApi,\n portalProducts,\n} from \"@fluid-app/products-core\";\nimport type { FetchClient } from \"@fluid-app/portal-tenant-api-client\";\nimport { portalTenant } from \"@fluid-app/portal-tenant-api-client\";\n\n/**\n * Creates a PortalProductsApi-compatible adapter from a portal-tenant FetchClient.\n *\n * This bridges the auto-generated portal-tenant API client to the abstract\n * PortalProductsApi interface defined in @fluid-app/products-core, closing\n * over the FetchClient so consumers don't need to pass it per-call.\n *\n * Each method maps the BFF response to the port type at runtime rather than\n * using type assertions, so TypeScript catches schema drift between the\n * generated client and the hand-authored port types at compile time.\n */\nexport function createPortalProductsApiAdapter(\n client: FetchClient,\n): PortalProductsApi {\n return {\n listProducts: async (params) => {\n const response = await portalTenant.products_list(client, {\n \"page[cursor]\": params?.cursor,\n });\n return {\n products: response.products ?? [],\n meta: response.meta,\n } satisfies portalProducts.PortalProductsResponse;\n },\n\n getProduct: async (id) => {\n const response = await portalTenant.products_show(client, id);\n return {\n product: response.product ?? {},\n meta: response.meta,\n } satisfies portalProducts.PortalProductResponse;\n },\n\n searchProducts: async (query, params) => {\n const response = await portalTenant.products_search(client, {\n q: query,\n \"page[cursor]\": params?.cursor,\n });\n return {\n products: response.products ?? [],\n meta: response.meta,\n } satisfies portalProducts.PortalProductsResponse;\n },\n\n getProductMedia: async (productId) => {\n const response = await portalTenant.products_media_list(\n client,\n productId,\n );\n return {\n media: response.media ?? [],\n meta: response.meta,\n } satisfies portalProducts.PortalProductMediaResponse;\n },\n };\n}\n","import { useMemo } from \"react\";\nimport type { PortalProductsApi } from \"@fluid-app/products-core\";\nimport { createPortalProductsApiAdapter } from \"../adapters/products-api-adapter\";\nimport { usePortalTenantClient } from \"../providers/PortalTenantClientProvider\";\n\nexport function usePortalProductsClient(): PortalProductsApi {\n const client = usePortalTenantClient();\n\n return useMemo(() => createPortalProductsApiAdapter(client), [client]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,SAAgB,+BACd,QACmB;AACnB,QAAO;EACL,cAAc,OAAO,WAAW;GAC9B,MAAM,WAAW,MAAA,sBAAA,cAAiC,QAAQ,EACxD,gBAAgB,QAAQ,QACzB,CAAC;AACF,UAAO;IACL,UAAU,SAAS,YAAY,EAAE;IACjC,MAAM,SAAS;IAChB;;EAGH,YAAY,OAAO,OAAO;GACxB,MAAM,WAAW,MAAA,sBAAA,cAAiC,QAAQ,GAAG;AAC7D,UAAO;IACL,SAAS,SAAS,WAAW,EAAE;IAC/B,MAAM,SAAS;IAChB;;EAGH,gBAAgB,OAAO,OAAO,WAAW;GACvC,MAAM,WAAW,MAAA,sBAAA,gBAAmC,QAAQ;IAC1D,GAAG;IACH,gBAAgB,QAAQ;IACzB,CAAC;AACF,UAAO;IACL,UAAU,SAAS,YAAY,EAAE;IACjC,MAAM,SAAS;IAChB;;EAGH,iBAAiB,OAAO,cAAc;GACpC,MAAM,WAAW,MAAA,sBAAA,oBACf,QACA,UACD;AACD,UAAO;IACL,OAAO,SAAS,SAAS,EAAE;IAC3B,MAAM,SAAS;IAChB;;EAEJ;;;;ACxDH,SAAgB,0BAA6C;CAC3D,MAAM,SAASA,mCAAAA,uBAAuB;AAEtC,SAAA,GAAA,MAAA,eAAqB,+BAA+B,OAAO,EAAE,CAAC,OAAO,CAAC"}
|
package/dist/{use-portal-products-client-DQK9nFxT.mjs → use-portal-products-client-tbqk6XUq.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as products_search, l as products_show, o as products_list, s as products_media_list } from "./portal_tenant-Taa7uJwV.mjs";
|
|
2
2
|
import { n as usePortalTenantClient } from "./PortalTenantClientProvider-_VXOs0t4.mjs";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
//#region
|
|
4
|
+
//#region src/adapters/products-api-adapter.ts
|
|
5
5
|
/**
|
|
6
6
|
* Creates a PortalProductsApi-compatible adapter from a portal-tenant FetchClient.
|
|
7
7
|
*
|
|
@@ -57,4 +57,4 @@ function usePortalProductsClient() {
|
|
|
57
57
|
//#endregion
|
|
58
58
|
export { usePortalProductsClient as t };
|
|
59
59
|
|
|
60
|
-
//# sourceMappingURL=use-portal-products-client-
|
|
60
|
+
//# sourceMappingURL=use-portal-products-client-tbqk6XUq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-portal-products-client-tbqk6XUq.mjs","names":["portalTenant.products_list","portalTenant.products_show","portalTenant.products_search","portalTenant.products_media_list"],"sources":["../src/adapters/products-api-adapter.ts","../src/products/use-portal-products-client.ts"],"sourcesContent":["import type {\n PortalProductsApi,\n portalProducts,\n} from \"@fluid-app/products-core\";\nimport type { FetchClient } from \"@fluid-app/portal-tenant-api-client\";\nimport { portalTenant } from \"@fluid-app/portal-tenant-api-client\";\n\n/**\n * Creates a PortalProductsApi-compatible adapter from a portal-tenant FetchClient.\n *\n * This bridges the auto-generated portal-tenant API client to the abstract\n * PortalProductsApi interface defined in @fluid-app/products-core, closing\n * over the FetchClient so consumers don't need to pass it per-call.\n *\n * Each method maps the BFF response to the port type at runtime rather than\n * using type assertions, so TypeScript catches schema drift between the\n * generated client and the hand-authored port types at compile time.\n */\nexport function createPortalProductsApiAdapter(\n client: FetchClient,\n): PortalProductsApi {\n return {\n listProducts: async (params) => {\n const response = await portalTenant.products_list(client, {\n \"page[cursor]\": params?.cursor,\n });\n return {\n products: response.products ?? [],\n meta: response.meta,\n } satisfies portalProducts.PortalProductsResponse;\n },\n\n getProduct: async (id) => {\n const response = await portalTenant.products_show(client, id);\n return {\n product: response.product ?? {},\n meta: response.meta,\n } satisfies portalProducts.PortalProductResponse;\n },\n\n searchProducts: async (query, params) => {\n const response = await portalTenant.products_search(client, {\n q: query,\n \"page[cursor]\": params?.cursor,\n });\n return {\n products: response.products ?? [],\n meta: response.meta,\n } satisfies portalProducts.PortalProductsResponse;\n },\n\n getProductMedia: async (productId) => {\n const response = await portalTenant.products_media_list(\n client,\n productId,\n );\n return {\n media: response.media ?? [],\n meta: response.meta,\n } satisfies portalProducts.PortalProductMediaResponse;\n },\n };\n}\n","import { useMemo } from \"react\";\nimport type { PortalProductsApi } from \"@fluid-app/products-core\";\nimport { createPortalProductsApiAdapter } from \"../adapters/products-api-adapter\";\nimport { usePortalTenantClient } from \"../providers/PortalTenantClientProvider\";\n\nexport function usePortalProductsClient(): PortalProductsApi {\n const client = usePortalTenantClient();\n\n return useMemo(() => createPortalProductsApiAdapter(client), [client]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,SAAgB,+BACd,QACmB;AACnB,QAAO;EACL,cAAc,OAAO,WAAW;GAC9B,MAAM,WAAW,MAAMA,cAA2B,QAAQ,EACxD,gBAAgB,QAAQ,QACzB,CAAC;AACF,UAAO;IACL,UAAU,SAAS,YAAY,EAAE;IACjC,MAAM,SAAS;IAChB;;EAGH,YAAY,OAAO,OAAO;GACxB,MAAM,WAAW,MAAMC,cAA2B,QAAQ,GAAG;AAC7D,UAAO;IACL,SAAS,SAAS,WAAW,EAAE;IAC/B,MAAM,SAAS;IAChB;;EAGH,gBAAgB,OAAO,OAAO,WAAW;GACvC,MAAM,WAAW,MAAMC,gBAA6B,QAAQ;IAC1D,GAAG;IACH,gBAAgB,QAAQ;IACzB,CAAC;AACF,UAAO;IACL,UAAU,SAAS,YAAY,EAAE;IACjC,MAAM,SAAS;IAChB;;EAGH,iBAAiB,OAAO,cAAc;GACpC,MAAM,WAAW,MAAMC,oBACrB,QACA,UACD;AACD,UAAO;IACL,OAAO,SAAS,SAAS,EAAE;IAC3B,MAAM,SAAS;IAChB;;EAEJ;;;;ACxDH,SAAgB,0BAA6C;CAC3D,MAAM,SAAS,uBAAuB;AAEtC,QAAO,cAAc,+BAA+B,OAAO,EAAE,CAAC,OAAO,CAAC"}
|
package/dist/{use-portal-shareables-api-KVPj0Jfr.mjs → use-portal-shareables-api-B9B4XTjw.mjs}
RENAMED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { t as useDropzone } from "./es-Bstiidl5.mjs";
|
|
2
|
-
import { n as useFluidContext, q as createFetchClient } from "./FluidProvider-Cqf2kmUc.mjs";
|
|
3
2
|
import { n as usePortalTenantClient } from "./PortalTenantClientProvider-_VXOs0t4.mjs";
|
|
4
3
|
import { $ as DialogDescription, A as SelectValue, B as Label, D as SelectContent, E as Select, F as FormControl, G as DropdownMenuSeparator, Gt as BreadcrumbPage, H as DropdownMenuContent, Ht as BreadcrumbItem, I as FormField, J as DropdownMenuSubTrigger, K as DropdownMenuSub, Kt as BreadcrumbSeparator, L as FormItem, O as SelectItem, P as Form, Q as DialogContent, R as FormLabel, St as Checkbox, T as Separator, U as DropdownMenuItem, Ut as BreadcrumbLink, V as DropdownMenu, Vt as Breadcrumb, Wt as BreadcrumbList, X as Dialog, Y as DropdownMenuTrigger, an as Button, at as Popover, et as DialogFooter, fn as useZodForm, g as Spinner, gt as Card, i as TooltipTrigger, it as DialogTitle, j as Input, k as SelectTrigger, m as Switch, n as TooltipContent, nt as DialogOverlay, on as Content, ot as PopoverContent, pn as cn, q as DropdownMenuSubContent, qt as Badge, r as TooltipProvider, rt as DialogPortal, st as PopoverTrigger, t as Tooltip, tt as DialogHeader, v as Slider, vt as CardContent, y as Skeleton, z as FormMessage } from "./src-BsT7Sq_P.mjs";
|
|
5
4
|
import { n as useScreenHeaderActions, r as useScreenHeaderBreadcrumbs } from "./ScreenHeaderContext-DjSO5A8k.mjs";
|
|
6
5
|
import { a as useEditor, o as Placeholder, r as EditorContent, t as StarterKit } from "./dist-CkIGP8my.mjs";
|
|
7
6
|
import { t as SearchSort } from "./SearchSort-Bsnis-kb.mjs";
|
|
8
7
|
import { n as TextAlign, t as Underline } from "./dist-C9vpl_rR.mjs";
|
|
9
|
-
import { t as
|
|
10
|
-
import {
|
|
8
|
+
import { a as verticalListSortingStrategy, c as PointerSensor, d as useSensors, f as CSS, i as useSortable, l as closestCenter, n as arrayMove, o as DndContext, r as sortableKeyboardCoordinates, s as KeyboardSensor, t as SortableContext, u as useSensor } from "./sortable.esm-DSrWP4x9.mjs";
|
|
9
|
+
import { t as usePortalProductsClient } from "./use-portal-products-client-tbqk6XUq.mjs";
|
|
11
10
|
import React, { PureComponent, createContext, createRef, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
12
11
|
import { keepPreviousData, useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
13
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -26,7 +25,7 @@ function ShareablesCoreProvider({ config, children }) {
|
|
|
26
25
|
function useShareablesClient() {
|
|
27
26
|
const ctx = useContext(ShareablesCoreContext);
|
|
28
27
|
if (!ctx) throw new Error("useShareablesClient must be used within a ShareablesCoreProvider");
|
|
29
|
-
return ctx.client;
|
|
28
|
+
return ctx.client ?? null;
|
|
30
29
|
}
|
|
31
30
|
function useShareablesUser() {
|
|
32
31
|
const ctx = useContext(ShareablesCoreContext);
|
|
@@ -564,6 +563,7 @@ function ProductsScreen({ countryCode, fetchProducts: fetchPortalProducts, onNav
|
|
|
564
563
|
countryCode
|
|
565
564
|
],
|
|
566
565
|
queryFn: async ({ pageParam = 1 }) => {
|
|
566
|
+
if (!client) throw new Error("Unreachable: client is null");
|
|
567
567
|
return (await listProducts(client, {
|
|
568
568
|
page: pageParam,
|
|
569
569
|
per_page: PAGE_SIZE$3,
|
|
@@ -579,7 +579,7 @@ function ProductsScreen({ countryCode, fetchProducts: fetchPortalProducts, onNav
|
|
|
579
579
|
},
|
|
580
580
|
getNextPageParam: (lastPage, allPages) => lastPage.length === PAGE_SIZE$3 ? allPages.length + 1 : void 0,
|
|
581
581
|
initialPageParam: 1,
|
|
582
|
-
enabled: !fetchPortalProducts
|
|
582
|
+
enabled: !fetchPortalProducts && !!client
|
|
583
583
|
});
|
|
584
584
|
const usePortal = !!fetchPortalProducts;
|
|
585
585
|
const { data, isLoading, isFetchingNextPage, hasNextPage, fetchNextPage, error } = usePortal ? portalQuery : legacyQuery;
|
|
@@ -1156,8 +1156,11 @@ function ProductDetailScreen({ productId, countryCode, fetchProduct: fetchPortal
|
|
|
1156
1156
|
});
|
|
1157
1157
|
const { data: legacyProductResponse, isLoading: isLoadingLegacyProduct } = useQuery({
|
|
1158
1158
|
queryKey: ["product", productId],
|
|
1159
|
-
queryFn: () =>
|
|
1160
|
-
|
|
1159
|
+
queryFn: () => {
|
|
1160
|
+
if (!client) throw new Error("Unreachable: client is null");
|
|
1161
|
+
return getProduct(client, productId, { country_code: countryCode });
|
|
1162
|
+
},
|
|
1163
|
+
enabled: !fetchPortalProduct && !!client
|
|
1161
1164
|
});
|
|
1162
1165
|
const isLoadingProduct = fetchPortalProduct ? isLoadingPortalProduct : isLoadingLegacyProduct;
|
|
1163
1166
|
const { data: productMediaResponse, isLoading: isLoadingMedia, error: mediaError } = useQuery({
|
|
@@ -8862,36 +8865,6 @@ function ProductsApp({ countryCode, companyLogoUrl, fetchProducts, fetchProduct,
|
|
|
8862
8865
|
});
|
|
8863
8866
|
}
|
|
8864
8867
|
//#endregion
|
|
8865
|
-
//#region src/account/use-account-clients.ts
|
|
8866
|
-
/**
|
|
8867
|
-
* Ensures baseUrl ends with /api.
|
|
8868
|
-
* Uncovered endpoints (e.g. /countries, points ledgers) use paths without the
|
|
8869
|
-
* /api prefix, so the base URL must include it.
|
|
8870
|
-
*/
|
|
8871
|
-
function withApiPrefix(baseUrl) {
|
|
8872
|
-
const base = baseUrl.replace(/\/+$/, "");
|
|
8873
|
-
return base.endsWith("/api") ? base : `${base}/api`;
|
|
8874
|
-
}
|
|
8875
|
-
/**
|
|
8876
|
-
* Generic SDK fetch client for endpoints not covered by domain-specific clients
|
|
8877
|
-
* (e.g. /countries, /v202506/customers/:id/points_ledgers).
|
|
8878
|
-
*
|
|
8879
|
-
* **Documented exception to the `usePortalTenantClient()` rule.**
|
|
8880
|
-
* This client requires `/api` in the base URL because its consumers
|
|
8881
|
-
* (products-api-client, shareables-core) call paths like `/company/v1/products`
|
|
8882
|
-
* and `/user_companies/:id/favorites/toggle.json` that are served under the
|
|
8883
|
-
* `/api` prefix. The shared portal-tenant client intentionally omits `/api`
|
|
8884
|
-
* because generated BFF namespace functions already include it in their paths.
|
|
8885
|
-
*/
|
|
8886
|
-
function useSdkClient() {
|
|
8887
|
-
const { config } = useFluidContext();
|
|
8888
|
-
return useMemo(() => createFetchClient({
|
|
8889
|
-
baseUrl: withApiPrefix(config.baseUrl),
|
|
8890
|
-
onAuthError: config.onAuthError,
|
|
8891
|
-
credentials: "include"
|
|
8892
|
-
}), [config.baseUrl, config.onAuthError]);
|
|
8893
|
-
}
|
|
8894
|
-
//#endregion
|
|
8895
8868
|
//#region ../../api-clients/portal-tenant-content/src/namespaces/portal_tenant_content.ts
|
|
8896
8869
|
/**
|
|
8897
8870
|
* List media (own uploads and company media)
|
|
@@ -9127,11 +9100,7 @@ async function dam_assets_discard(client, code) {
|
|
|
9127
9100
|
return client.patch(`/api/content/dam/assets/${code}/discard`);
|
|
9128
9101
|
}
|
|
9129
9102
|
//#endregion
|
|
9130
|
-
//#region
|
|
9131
|
-
/**
|
|
9132
|
-
* Maps a BFF media object to the port's Media shape, providing defaults
|
|
9133
|
-
* for optional fields returned by the generated client.
|
|
9134
|
-
*/
|
|
9103
|
+
//#region src/adapters/shareables-api-adapter.ts
|
|
9135
9104
|
function mapMedia(raw) {
|
|
9136
9105
|
return {
|
|
9137
9106
|
id: raw.id ?? 0,
|
|
@@ -9145,10 +9114,7 @@ function mapMedia(raw) {
|
|
|
9145
9114
|
updated_at: raw.updated_at ?? ""
|
|
9146
9115
|
};
|
|
9147
9116
|
}
|
|
9148
|
-
|
|
9149
|
-
* Maps the BFF meta envelope to the port's ApiMeta shape.
|
|
9150
|
-
*/
|
|
9151
|
-
function mapMeta$3(raw) {
|
|
9117
|
+
function mapMediaMeta(raw) {
|
|
9152
9118
|
return {
|
|
9153
9119
|
request_id: raw?.request_id ?? null,
|
|
9154
9120
|
timestamp: raw?.timestamp ?? "",
|
|
@@ -9162,10 +9128,6 @@ function mapMeta$3(raw) {
|
|
|
9162
9128
|
}
|
|
9163
9129
|
/**
|
|
9164
9130
|
* Creates a ContentMediaApi adapter backed by the portal-tenant content BFF.
|
|
9165
|
-
*
|
|
9166
|
-
* Maps the generated portal-tenant-content namespace functions to the abstract
|
|
9167
|
-
* ContentMediaApi port, closing over the FetchClient so consumers don't need
|
|
9168
|
-
* to pass it per-call.
|
|
9169
9131
|
*/
|
|
9170
9132
|
function createPortalTenantMediaAdapter(client) {
|
|
9171
9133
|
return {
|
|
@@ -9179,47 +9141,47 @@ function createPortalTenantMediaAdapter(client) {
|
|
|
9179
9141
|
});
|
|
9180
9142
|
return {
|
|
9181
9143
|
media: (response.media ?? []).map(mapMedia),
|
|
9182
|
-
meta:
|
|
9144
|
+
meta: mapMediaMeta(response.meta)
|
|
9183
9145
|
};
|
|
9184
9146
|
},
|
|
9185
9147
|
createMedia: async (body) => {
|
|
9186
9148
|
const response = await media_create(client, { media: body });
|
|
9187
9149
|
return {
|
|
9188
9150
|
media: mapMedia(response.media ?? {}),
|
|
9189
|
-
meta:
|
|
9151
|
+
meta: mapMediaMeta(response.meta)
|
|
9190
9152
|
};
|
|
9191
9153
|
},
|
|
9192
9154
|
getMedia: async (id) => {
|
|
9193
9155
|
const response = await media_show(client, id);
|
|
9194
9156
|
return {
|
|
9195
9157
|
media: mapMedia(response.media ?? {}),
|
|
9196
|
-
meta:
|
|
9158
|
+
meta: mapMediaMeta(response.meta)
|
|
9197
9159
|
};
|
|
9198
9160
|
},
|
|
9199
9161
|
updateMedia: async (id, body) => {
|
|
9200
9162
|
const response = await media_update(client, id, { media: body });
|
|
9201
9163
|
return {
|
|
9202
9164
|
media: mapMedia(response.media ?? {}),
|
|
9203
|
-
meta:
|
|
9165
|
+
meta: mapMediaMeta(response.meta)
|
|
9204
9166
|
};
|
|
9205
9167
|
},
|
|
9206
9168
|
deleteMedia: async (id) => {
|
|
9207
9169
|
const response = await media_destroy(client, id);
|
|
9208
9170
|
return {
|
|
9209
9171
|
media: { id: response.media?.id ?? 0 },
|
|
9210
|
-
meta:
|
|
9172
|
+
meta: mapMediaMeta(response.meta)
|
|
9211
9173
|
};
|
|
9212
9174
|
}
|
|
9213
9175
|
};
|
|
9214
9176
|
}
|
|
9215
|
-
function mediaKindFromType
|
|
9177
|
+
function mediaKindFromType(mediaType) {
|
|
9216
9178
|
if (mediaType === "video") return "video";
|
|
9217
9179
|
if (mediaType === "image") return "image";
|
|
9218
9180
|
if (mediaType === "document" || mediaType === "pdf") return "pdf";
|
|
9219
9181
|
return null;
|
|
9220
9182
|
}
|
|
9221
9183
|
function toBffMediumResponse(bff) {
|
|
9222
|
-
const kind = mediaKindFromType
|
|
9184
|
+
const kind = mediaKindFromType(bff.media_type);
|
|
9223
9185
|
const isVideo = bff.media_type === "video";
|
|
9224
9186
|
const isPdf = bff.media_type === "pdf" || bff.media_type === "document";
|
|
9225
9187
|
return {
|
|
@@ -9337,11 +9299,6 @@ function createPortalTenantMediaShareablesAdapter(client) {
|
|
|
9337
9299
|
}
|
|
9338
9300
|
};
|
|
9339
9301
|
}
|
|
9340
|
-
//#endregion
|
|
9341
|
-
//#region ../../shareables/api-client/src/portal-tenant-playlists-adapter.ts
|
|
9342
|
-
/**
|
|
9343
|
-
* Maps a BFF playlist object to the port's Playlist shape.
|
|
9344
|
-
*/
|
|
9345
9302
|
function mapPlaylist(raw) {
|
|
9346
9303
|
return {
|
|
9347
9304
|
id: raw.id ?? 0,
|
|
@@ -9355,9 +9312,6 @@ function mapPlaylist(raw) {
|
|
|
9355
9312
|
updated_at: raw.updated_at ?? ""
|
|
9356
9313
|
};
|
|
9357
9314
|
}
|
|
9358
|
-
/**
|
|
9359
|
-
* Maps a BFF playlist item to the port's PlaylistItem shape.
|
|
9360
|
-
*/
|
|
9361
9315
|
function mapPlaylistItem(raw) {
|
|
9362
9316
|
return {
|
|
9363
9317
|
id: raw.id ?? 0,
|
|
@@ -9371,10 +9325,7 @@ function mapPlaylistItem(raw) {
|
|
|
9371
9325
|
created_at: raw.created_at ?? ""
|
|
9372
9326
|
};
|
|
9373
9327
|
}
|
|
9374
|
-
|
|
9375
|
-
* Maps the BFF meta envelope to the port's ApiMeta shape.
|
|
9376
|
-
*/
|
|
9377
|
-
function mapMeta$2(raw) {
|
|
9328
|
+
function mapPlaylistsMeta(raw) {
|
|
9378
9329
|
return {
|
|
9379
9330
|
request_id: raw?.request_id ?? null,
|
|
9380
9331
|
timestamp: raw?.timestamp ?? "",
|
|
@@ -9388,10 +9339,6 @@ function mapMeta$2(raw) {
|
|
|
9388
9339
|
}
|
|
9389
9340
|
/**
|
|
9390
9341
|
* Creates a ContentPlaylistsApi adapter backed by the portal-tenant content BFF.
|
|
9391
|
-
*
|
|
9392
|
-
* Maps the generated portal-tenant-content namespace functions to the abstract
|
|
9393
|
-
* ContentPlaylistsApi port, closing over the FetchClient so consumers don't
|
|
9394
|
-
* need to pass it per-call.
|
|
9395
9342
|
*/
|
|
9396
9343
|
function createPortalTenantPlaylistsAdapter(client) {
|
|
9397
9344
|
return {
|
|
@@ -9404,35 +9351,35 @@ function createPortalTenantPlaylistsAdapter(client) {
|
|
|
9404
9351
|
});
|
|
9405
9352
|
return {
|
|
9406
9353
|
playlists: (response.playlists ?? []).map(mapPlaylist),
|
|
9407
|
-
meta:
|
|
9354
|
+
meta: mapPlaylistsMeta(response.meta)
|
|
9408
9355
|
};
|
|
9409
9356
|
},
|
|
9410
9357
|
createPlaylist: async (body) => {
|
|
9411
9358
|
const response = await playlists_create(client, { playlist: body });
|
|
9412
9359
|
return {
|
|
9413
9360
|
playlist: mapPlaylist(response.playlist ?? {}),
|
|
9414
|
-
meta:
|
|
9361
|
+
meta: mapPlaylistsMeta(response.meta)
|
|
9415
9362
|
};
|
|
9416
9363
|
},
|
|
9417
9364
|
getPlaylist: async (id) => {
|
|
9418
9365
|
const response = await playlists_show(client, id);
|
|
9419
9366
|
return {
|
|
9420
9367
|
playlist: mapPlaylist(response.playlist ?? {}),
|
|
9421
|
-
meta:
|
|
9368
|
+
meta: mapPlaylistsMeta(response.meta)
|
|
9422
9369
|
};
|
|
9423
9370
|
},
|
|
9424
9371
|
updatePlaylist: async (id, body) => {
|
|
9425
9372
|
const response = await playlists_update(client, id, { playlist: body });
|
|
9426
9373
|
return {
|
|
9427
9374
|
playlist: mapPlaylist(response.playlist ?? {}),
|
|
9428
|
-
meta:
|
|
9375
|
+
meta: mapPlaylistsMeta(response.meta)
|
|
9429
9376
|
};
|
|
9430
9377
|
},
|
|
9431
9378
|
deletePlaylist: async (id) => {
|
|
9432
9379
|
const response = await playlists_destroy(client, id);
|
|
9433
9380
|
return {
|
|
9434
9381
|
playlist: { id: response.playlist?.id ?? 0 },
|
|
9435
|
-
meta:
|
|
9382
|
+
meta: mapPlaylistsMeta(response.meta)
|
|
9436
9383
|
};
|
|
9437
9384
|
},
|
|
9438
9385
|
listPlaylistItems: async (playlistId, params) => {
|
|
@@ -9442,31 +9389,25 @@ function createPortalTenantPlaylistsAdapter(client) {
|
|
|
9442
9389
|
});
|
|
9443
9390
|
return {
|
|
9444
9391
|
playlist_items: (response.playlist_items ?? []).map(mapPlaylistItem),
|
|
9445
|
-
meta:
|
|
9392
|
+
meta: mapPlaylistsMeta(response.meta)
|
|
9446
9393
|
};
|
|
9447
9394
|
},
|
|
9448
9395
|
addPlaylistItem: async (playlistId, body) => {
|
|
9449
9396
|
const response = await playlists_items_add(client, playlistId, { item: body });
|
|
9450
9397
|
return {
|
|
9451
9398
|
playlist_item: mapPlaylistItem(response.playlist_item ?? {}),
|
|
9452
|
-
meta:
|
|
9399
|
+
meta: mapPlaylistsMeta(response.meta)
|
|
9453
9400
|
};
|
|
9454
9401
|
},
|
|
9455
9402
|
removePlaylistItem: async (playlistId, itemId) => {
|
|
9456
9403
|
const response = await playlists_items_remove(client, playlistId, itemId);
|
|
9457
9404
|
return {
|
|
9458
9405
|
playlist_item: { id: response.playlist_item?.id ?? 0 },
|
|
9459
|
-
meta:
|
|
9406
|
+
meta: mapPlaylistsMeta(response.meta)
|
|
9460
9407
|
};
|
|
9461
9408
|
}
|
|
9462
9409
|
};
|
|
9463
9410
|
}
|
|
9464
|
-
function mediaKindFromType(mediaType) {
|
|
9465
|
-
if (mediaType === "video") return "video";
|
|
9466
|
-
if (mediaType === "image") return "image";
|
|
9467
|
-
if (mediaType === "document" || mediaType === "pdf") return "pdf";
|
|
9468
|
-
return null;
|
|
9469
|
-
}
|
|
9470
9411
|
function toBffPlaylist(bff, items) {
|
|
9471
9412
|
return {
|
|
9472
9413
|
id: bff.id,
|
|
@@ -9591,11 +9532,80 @@ function createPortalTenantPlaylistsShareablesAdapter(client) {
|
|
|
9591
9532
|
}
|
|
9592
9533
|
};
|
|
9593
9534
|
}
|
|
9594
|
-
|
|
9595
|
-
|
|
9535
|
+
function isShareableType(value) {
|
|
9536
|
+
return value === "media" || value === "product" || value === "library" || value === "page";
|
|
9537
|
+
}
|
|
9538
|
+
function mapShare(raw) {
|
|
9539
|
+
return {
|
|
9540
|
+
id: raw.id ?? 0,
|
|
9541
|
+
url: raw.url ?? "",
|
|
9542
|
+
shareable_type: isShareableType(raw.shareable_type) ? raw.shareable_type : "media",
|
|
9543
|
+
shareable_id: raw.shareable_id ?? 0,
|
|
9544
|
+
created_at: raw.created_at ?? ""
|
|
9545
|
+
};
|
|
9546
|
+
}
|
|
9547
|
+
function mapSharesMeta(raw) {
|
|
9548
|
+
return {
|
|
9549
|
+
request_id: raw?.request_id ?? null,
|
|
9550
|
+
timestamp: raw?.timestamp ?? "",
|
|
9551
|
+
pagination: raw?.pagination ? {
|
|
9552
|
+
cursor: raw.pagination.cursor ?? null,
|
|
9553
|
+
limit: raw.pagination.limit,
|
|
9554
|
+
next_cursor: raw.pagination.next_cursor ?? null,
|
|
9555
|
+
prev_cursor: raw.pagination.prev_cursor ?? null
|
|
9556
|
+
} : void 0
|
|
9557
|
+
};
|
|
9558
|
+
}
|
|
9596
9559
|
/**
|
|
9597
|
-
*
|
|
9560
|
+
* Creates a ContentSharesApi adapter backed by the portal-tenant content BFF.
|
|
9598
9561
|
*/
|
|
9562
|
+
function createPortalTenantSharesAdapter(client) {
|
|
9563
|
+
return {
|
|
9564
|
+
listShares: async (params) => {
|
|
9565
|
+
const response = await shares_list(client, {
|
|
9566
|
+
"page[cursor]": params?.cursor,
|
|
9567
|
+
"page[limit]": params?.limit
|
|
9568
|
+
});
|
|
9569
|
+
return {
|
|
9570
|
+
shares: (response.shares ?? []).map(mapShare),
|
|
9571
|
+
meta: mapSharesMeta(response.meta)
|
|
9572
|
+
};
|
|
9573
|
+
},
|
|
9574
|
+
createShare: async (body) => {
|
|
9575
|
+
const response = await shares_create(client, { share: body });
|
|
9576
|
+
return {
|
|
9577
|
+
share: mapShare(response.share ?? {}),
|
|
9578
|
+
meta: mapSharesMeta(response.meta)
|
|
9579
|
+
};
|
|
9580
|
+
}
|
|
9581
|
+
};
|
|
9582
|
+
}
|
|
9583
|
+
const SHAREABLE_TYPE_MAP = {
|
|
9584
|
+
Medium: "media",
|
|
9585
|
+
media: "media",
|
|
9586
|
+
Product: "product",
|
|
9587
|
+
product: "product",
|
|
9588
|
+
Library: "library",
|
|
9589
|
+
library: "library",
|
|
9590
|
+
Page: "page",
|
|
9591
|
+
page: "page"
|
|
9592
|
+
};
|
|
9593
|
+
/**
|
|
9594
|
+
* Creates a ShareablesApi["share"]-compatible adapter backed by the
|
|
9595
|
+
* portal-tenant content BFF. Maps legacy model names to BFF shareable types.
|
|
9596
|
+
*/
|
|
9597
|
+
function createPortalTenantSharesShareablesAdapter(client) {
|
|
9598
|
+
const portAdapter = createPortalTenantSharesAdapter(client);
|
|
9599
|
+
return { createShareLink: async (input) => {
|
|
9600
|
+
if (!input.relateableId) throw new Error("Cannot create share link without a relateableId");
|
|
9601
|
+
const shareableType = SHAREABLE_TYPE_MAP[input.relateableType];
|
|
9602
|
+
if (!shareableType) throw new Error(`Unknown shareable type: "${input.relateableType}"`);
|
|
9603
|
+
return (await portAdapter.createShare({
|
|
9604
|
+
shareable_type: shareableType,
|
|
9605
|
+
shareable_id: input.relateableId
|
|
9606
|
+
})).share.url;
|
|
9607
|
+
} };
|
|
9608
|
+
}
|
|
9599
9609
|
function mapDamAsset(raw) {
|
|
9600
9610
|
return {
|
|
9601
9611
|
id: raw.id ?? 0,
|
|
@@ -9611,9 +9621,6 @@ function mapDamAsset(raw) {
|
|
|
9611
9621
|
updated_at: raw.updated_at ?? ""
|
|
9612
9622
|
};
|
|
9613
9623
|
}
|
|
9614
|
-
/**
|
|
9615
|
-
* Maps a BFF DAM asset path to the port's DamAssetPath shape.
|
|
9616
|
-
*/
|
|
9617
9624
|
function mapDamAssetPath(raw) {
|
|
9618
9625
|
return {
|
|
9619
9626
|
id: raw.id ?? 0,
|
|
@@ -9622,10 +9629,7 @@ function mapDamAssetPath(raw) {
|
|
|
9622
9629
|
created_at: raw.created_at ?? ""
|
|
9623
9630
|
};
|
|
9624
9631
|
}
|
|
9625
|
-
|
|
9626
|
-
* Maps the BFF meta envelope to the port's ApiMeta shape.
|
|
9627
|
-
*/
|
|
9628
|
-
function mapMeta$1(raw) {
|
|
9632
|
+
function mapDamAssetsMeta(raw) {
|
|
9629
9633
|
return {
|
|
9630
9634
|
request_id: raw?.request_id ?? null,
|
|
9631
9635
|
timestamp: raw?.timestamp ?? "",
|
|
@@ -9639,10 +9643,6 @@ function mapMeta$1(raw) {
|
|
|
9639
9643
|
}
|
|
9640
9644
|
/**
|
|
9641
9645
|
* Creates a ContentDamAssetsApi adapter backed by the portal-tenant content BFF.
|
|
9642
|
-
*
|
|
9643
|
-
* Maps the generated portal-tenant-content namespace functions to the abstract
|
|
9644
|
-
* ContentDamAssetsApi port, closing over the FetchClient so consumers don't
|
|
9645
|
-
* need to pass it per-call.
|
|
9646
9646
|
*/
|
|
9647
9647
|
function createPortalTenantDamAssetsAdapter(client) {
|
|
9648
9648
|
return {
|
|
@@ -9653,14 +9653,14 @@ function createPortalTenantDamAssetsAdapter(client) {
|
|
|
9653
9653
|
});
|
|
9654
9654
|
return {
|
|
9655
9655
|
assets: (response.assets ?? []).map(mapDamAsset),
|
|
9656
|
-
meta:
|
|
9656
|
+
meta: mapDamAssetsMeta(response.meta)
|
|
9657
9657
|
};
|
|
9658
9658
|
},
|
|
9659
9659
|
createAsset: async (body) => {
|
|
9660
9660
|
const response = await dam_assets_create(client, { asset: body });
|
|
9661
9661
|
return {
|
|
9662
9662
|
asset: mapDamAsset(response.asset ?? {}),
|
|
9663
|
-
meta:
|
|
9663
|
+
meta: mapDamAssetsMeta(response.meta)
|
|
9664
9664
|
};
|
|
9665
9665
|
},
|
|
9666
9666
|
listAssetPaths: async (assetCode, params) => {
|
|
@@ -9670,14 +9670,14 @@ function createPortalTenantDamAssetsAdapter(client) {
|
|
|
9670
9670
|
});
|
|
9671
9671
|
return {
|
|
9672
9672
|
asset_paths: (response.asset_paths ?? []).map(mapDamAssetPath),
|
|
9673
|
-
meta:
|
|
9673
|
+
meta: mapDamAssetsMeta(response.meta)
|
|
9674
9674
|
};
|
|
9675
9675
|
},
|
|
9676
9676
|
createAssetPath: async (assetCode, body) => {
|
|
9677
9677
|
const response = await dam_asset_paths_create(client, assetCode, { asset_path: body });
|
|
9678
9678
|
return {
|
|
9679
9679
|
asset_path: mapDamAssetPath(response.asset_path ?? {}),
|
|
9680
|
-
meta:
|
|
9680
|
+
meta: mapDamAssetsMeta(response.meta)
|
|
9681
9681
|
};
|
|
9682
9682
|
}
|
|
9683
9683
|
};
|
|
@@ -9728,100 +9728,6 @@ function createPortalTenantFilesShareablesAdapter(client) {
|
|
|
9728
9728
|
};
|
|
9729
9729
|
} };
|
|
9730
9730
|
}
|
|
9731
|
-
//#endregion
|
|
9732
|
-
//#region ../../shareables/api-client/src/portal-tenant-shares-adapter.ts
|
|
9733
|
-
/**
|
|
9734
|
-
* Narrows an unknown string to a valid ShareableType at runtime.
|
|
9735
|
-
*/
|
|
9736
|
-
function isShareableType(value) {
|
|
9737
|
-
return value === "media" || value === "product" || value === "library" || value === "page";
|
|
9738
|
-
}
|
|
9739
|
-
/**
|
|
9740
|
-
* Maps a BFF share to the port's Share shape.
|
|
9741
|
-
*/
|
|
9742
|
-
function mapShare(raw) {
|
|
9743
|
-
return {
|
|
9744
|
-
id: raw.id ?? 0,
|
|
9745
|
-
url: raw.url ?? "",
|
|
9746
|
-
shareable_type: isShareableType(raw.shareable_type) ? raw.shareable_type : "media",
|
|
9747
|
-
shareable_id: raw.shareable_id ?? 0,
|
|
9748
|
-
created_at: raw.created_at ?? ""
|
|
9749
|
-
};
|
|
9750
|
-
}
|
|
9751
|
-
/**
|
|
9752
|
-
* Maps the BFF meta envelope to the port's ApiMeta shape.
|
|
9753
|
-
*/
|
|
9754
|
-
function mapMeta(raw) {
|
|
9755
|
-
return {
|
|
9756
|
-
request_id: raw?.request_id ?? null,
|
|
9757
|
-
timestamp: raw?.timestamp ?? "",
|
|
9758
|
-
pagination: raw?.pagination ? {
|
|
9759
|
-
cursor: raw.pagination.cursor ?? null,
|
|
9760
|
-
limit: raw.pagination.limit,
|
|
9761
|
-
next_cursor: raw.pagination.next_cursor ?? null,
|
|
9762
|
-
prev_cursor: raw.pagination.prev_cursor ?? null
|
|
9763
|
-
} : void 0
|
|
9764
|
-
};
|
|
9765
|
-
}
|
|
9766
|
-
/**
|
|
9767
|
-
* Creates a ContentSharesApi adapter backed by the portal-tenant content BFF.
|
|
9768
|
-
*
|
|
9769
|
-
* Maps the generated portal-tenant-content namespace functions to the abstract
|
|
9770
|
-
* ContentSharesApi port, closing over the FetchClient so consumers don't need
|
|
9771
|
-
* to pass it per-call.
|
|
9772
|
-
*/
|
|
9773
|
-
function createPortalTenantSharesAdapter(client) {
|
|
9774
|
-
return {
|
|
9775
|
-
listShares: async (params) => {
|
|
9776
|
-
const response = await shares_list(client, {
|
|
9777
|
-
"page[cursor]": params?.cursor,
|
|
9778
|
-
"page[limit]": params?.limit
|
|
9779
|
-
});
|
|
9780
|
-
return {
|
|
9781
|
-
shares: (response.shares ?? []).map(mapShare),
|
|
9782
|
-
meta: mapMeta(response.meta)
|
|
9783
|
-
};
|
|
9784
|
-
},
|
|
9785
|
-
createShare: async (body) => {
|
|
9786
|
-
const response = await shares_create(client, { share: body });
|
|
9787
|
-
return {
|
|
9788
|
-
share: mapShare(response.share ?? {}),
|
|
9789
|
-
meta: mapMeta(response.meta)
|
|
9790
|
-
};
|
|
9791
|
-
}
|
|
9792
|
-
};
|
|
9793
|
-
}
|
|
9794
|
-
/**
|
|
9795
|
-
* Maps legacy Rails model names (used by the UI) to BFF shareable_type values.
|
|
9796
|
-
*/
|
|
9797
|
-
const SHAREABLE_TYPE_MAP = {
|
|
9798
|
-
Medium: "media",
|
|
9799
|
-
media: "media",
|
|
9800
|
-
Product: "product",
|
|
9801
|
-
product: "product",
|
|
9802
|
-
Library: "library",
|
|
9803
|
-
library: "library",
|
|
9804
|
-
Page: "page",
|
|
9805
|
-
page: "page"
|
|
9806
|
-
};
|
|
9807
|
-
/**
|
|
9808
|
-
* Creates a ShareablesApi["share"]-compatible adapter backed by the
|
|
9809
|
-
* portal-tenant content BFF. Maps legacy model names to BFF shareable types.
|
|
9810
|
-
*/
|
|
9811
|
-
function createPortalTenantSharesShareablesAdapter(client) {
|
|
9812
|
-
const portAdapter = createPortalTenantSharesAdapter(client);
|
|
9813
|
-
return { createShareLink: async (input) => {
|
|
9814
|
-
if (!input.relateableId) throw new Error("Cannot create share link without a relateableId");
|
|
9815
|
-
const shareableType = SHAREABLE_TYPE_MAP[input.relateableType];
|
|
9816
|
-
if (!shareableType) throw new Error(`Unknown shareable type: "${input.relateableType}"`);
|
|
9817
|
-
return (await portAdapter.createShare({
|
|
9818
|
-
shareable_type: shareableType,
|
|
9819
|
-
shareable_id: input.relateableId
|
|
9820
|
-
})).share.url;
|
|
9821
|
-
} };
|
|
9822
|
-
}
|
|
9823
|
-
//#endregion
|
|
9824
|
-
//#region ../../shareables/api-client/src/portal-tenant-product-media-adapter.ts
|
|
9825
9731
|
function mapProductMedia(raw) {
|
|
9826
9732
|
const isVideo = raw.media_type === "video";
|
|
9827
9733
|
const isPdf = raw.media_type === "pdf" || raw.media_type === "document";
|
|
@@ -9883,6 +9789,6 @@ function usePortalShareablesApi() {
|
|
|
9883
9789
|
]);
|
|
9884
9790
|
}
|
|
9885
9791
|
//#endregion
|
|
9886
|
-
export { dam_assets_discard as a,
|
|
9792
|
+
export { dam_assets_discard as a, ShareablesApp as c, ShareablesCoreProvider as d, dam_assets_destroy as i, ShareablesUIProvider as l, createPortalTenantPlaylistsAdapter as n, dam_query as o, dam_asset_paths_create as r, ProductsApp as s, usePortalShareablesApi as t, ShareablesApiProvider as u };
|
|
9887
9793
|
|
|
9888
|
-
//# sourceMappingURL=use-portal-shareables-api-
|
|
9794
|
+
//# sourceMappingURL=use-portal-shareables-api-B9B4XTjw.mjs.map
|