@fluid-app/portal-sdk 0.1.135 → 0.1.136

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.
Files changed (31) hide show
  1. package/dist/ProductsScreen-C7cXqLN8.cjs +110 -0
  2. package/dist/ProductsScreen-C7cXqLN8.cjs.map +1 -0
  3. package/dist/{ProductsScreen-CbKT2maZ.mjs → ProductsScreen-CTUejNR0.mjs} +2 -2
  4. package/dist/{ProductsScreen-T1tGuiGy.cjs → ProductsScreen-CcF3f9VD.cjs} +2 -2
  5. package/dist/ProductsScreen-Di6uVQCx.mjs +98 -0
  6. package/dist/ProductsScreen-Di6uVQCx.mjs.map +1 -0
  7. package/dist/ShareablesScreen-B-uZ3B5d.cjs +430 -0
  8. package/dist/ShareablesScreen-B-uZ3B5d.cjs.map +1 -0
  9. package/dist/{ShareablesScreen-DSW36iS7.mjs → ShareablesScreen-BHyxG-oy.mjs} +2 -2
  10. package/dist/{ShareablesScreen-BLbzr0Jb.cjs → ShareablesScreen-DAM01cxf.cjs} +2 -2
  11. package/dist/ShareablesScreen-iBUd6p7M.mjs +412 -0
  12. package/dist/ShareablesScreen-iBUd6p7M.mjs.map +1 -0
  13. package/dist/index.cjs +7 -7
  14. package/dist/index.d.cts.map +1 -1
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +7 -7
  17. package/dist/{src-BbjxT3sc.mjs → portal-tenant-product-media-adapter-Co9Kw-US.mjs} +980 -4
  18. package/dist/portal-tenant-product-media-adapter-Co9Kw-US.mjs.map +1 -0
  19. package/dist/{src-DmzXXBVt.cjs → portal-tenant-product-media-adapter-DM94zJXA.cjs} +1039 -3
  20. package/dist/portal-tenant-product-media-adapter-DM94zJXA.cjs.map +1 -0
  21. package/package.json +16 -16
  22. package/dist/ProductsScreen-B1OAGNQx.cjs +0 -283
  23. package/dist/ProductsScreen-B1OAGNQx.cjs.map +0 -1
  24. package/dist/ProductsScreen-CL71MQNL.mjs +0 -271
  25. package/dist/ProductsScreen-CL71MQNL.mjs.map +0 -1
  26. package/dist/ShareablesScreen-CecBPoFO.mjs +0 -1360
  27. package/dist/ShareablesScreen-CecBPoFO.mjs.map +0 -1
  28. package/dist/ShareablesScreen-DDutXKpW.cjs +0 -1378
  29. package/dist/ShareablesScreen-DDutXKpW.cjs.map +0 -1
  30. package/dist/src-BbjxT3sc.mjs.map +0 -1
  31. package/dist/src-DmzXXBVt.cjs.map +0 -1
@@ -88,9 +88,24 @@ const shareablesKeys = {
88
88
  //#endregion
89
89
  //#region ../../shareables/core/src/api-context.tsx
90
90
  const ShareablesApiContext = createContext(null);
91
- function ShareablesApiProvider({ api, children }) {
91
+ function ShareablesApiProvider({ media, playlists, fileResources, share, productMedia, children }) {
92
+ const value = useMemo(() => ({
93
+ media,
94
+ playlists,
95
+ fileResources,
96
+ share,
97
+ productMedia: productMedia ?? { getProductMedia: () => {
98
+ throw new Error("ProductMediaApi not provided to ShareablesApiProvider");
99
+ } }
100
+ }), [
101
+ media,
102
+ playlists,
103
+ fileResources,
104
+ share,
105
+ productMedia
106
+ ]);
92
107
  return /* @__PURE__ */ jsx(ShareablesApiContext.Provider, {
93
- value: api,
108
+ value,
94
109
  children
95
110
  });
96
111
  }
@@ -8895,6 +8910,967 @@ function ProductsApp({ countryCode, companyLogoUrl, fetchProducts, fetchProduct,
8895
8910
  });
8896
8911
  }
8897
8912
  //#endregion
8898
- export { ShareablesCoreProvider as a, ShareablesApiProvider as i, ShareablesApp as n, ShareablesUIProvider as r, ProductsApp as t };
8913
+ //#region ../../api-clients/portal-tenant-content/src/namespaces/portal_tenant_content.ts
8914
+ /**
8915
+ * List media (own uploads and company media)
8916
+ * Returns a paginated list of the member's own uploads and company-owned media.
8917
+ *
8918
+ * @param client - Fetch client instance
8919
+ * @param [params] - params
8920
+ */
8921
+ async function media_list(client, params) {
8922
+ return client.get(`/api/content/media`, params);
8923
+ }
8924
+ /**
8925
+ * Create a new media item
8926
+ * Creates a new media item record.
8927
+ *
8928
+ * @param client - Fetch client instance
8929
+ * @param body - body
8930
+ */
8931
+ async function media_create(client, body) {
8932
+ return client.post(`/api/content/media`, body);
8933
+ }
8934
+ /**
8935
+ * Get a specific media item
8936
+ * Returns a single media item by ID.
8937
+ *
8938
+ * @param client - Fetch client instance
8939
+ * @param id - id
8940
+ */
8941
+ async function media_show(client, id) {
8942
+ return client.get(`/api/content/media/${id}`);
8943
+ }
8944
+ /**
8945
+ * Update a media item (own uploads only)
8946
+ * Updates a media item's title or description.
8947
+ *
8948
+ * @param client - Fetch client instance
8949
+ * @param id - id
8950
+ * @param body - body
8951
+ */
8952
+ async function media_update(client, id, body) {
8953
+ return client.patch(`/api/content/media/${id}`, body);
8954
+ }
8955
+ /**
8956
+ * Delete a media item (own uploads only)
8957
+ * Removes a media item.
8958
+ *
8959
+ * @param client - Fetch client instance
8960
+ * @param id - id
8961
+ */
8962
+ async function media_destroy(client, id) {
8963
+ return client.delete(`/api/content/media/${id}`);
8964
+ }
8965
+ /**
8966
+ * List playlists with cursor pagination
8967
+ * Returns a paginated list of playlists.
8968
+ *
8969
+ * @param client - Fetch client instance
8970
+ * @param [params] - params
8971
+ */
8972
+ async function playlists_list(client, params) {
8973
+ return client.get(`/api/content/playlists`, params);
8974
+ }
8975
+ /**
8976
+ * Create a new playlist
8977
+ * Creates a new playlist.
8978
+ *
8979
+ * @param client - Fetch client instance
8980
+ * @param body - body
8981
+ */
8982
+ async function playlists_create(client, body) {
8983
+ return client.post(`/api/content/playlists`, body);
8984
+ }
8985
+ /**
8986
+ * Get a specific playlist
8987
+ * Returns a single playlist by ID.
8988
+ *
8989
+ * @param client - Fetch client instance
8990
+ * @param id - id
8991
+ */
8992
+ async function playlists_show(client, id) {
8993
+ return client.get(`/api/content/playlists/${id}`);
8994
+ }
8995
+ /**
8996
+ * Update a playlist
8997
+ * Updates a playlist's title or metadata.
8998
+ *
8999
+ * @param client - Fetch client instance
9000
+ * @param id - id
9001
+ * @param body - body
9002
+ */
9003
+ async function playlists_update(client, id, body) {
9004
+ return client.patch(`/api/content/playlists/${id}`, body);
9005
+ }
9006
+ /**
9007
+ * Delete a playlist
9008
+ * Removes a playlist.
9009
+ *
9010
+ * @param client - Fetch client instance
9011
+ * @param id - id
9012
+ */
9013
+ async function playlists_destroy(client, id) {
9014
+ return client.delete(`/api/content/playlists/${id}`);
9015
+ }
9016
+ /**
9017
+ * List items in a playlist
9018
+ * Returns a paginated list of items in a playlist.
9019
+ *
9020
+ * @param client - Fetch client instance
9021
+ * @param playlist_id - playlist_id
9022
+ * @param [params] - params
9023
+ */
9024
+ async function playlists_items_list(client, playlist_id, params) {
9025
+ return client.get(`/api/content/playlists/${playlist_id}/items`, params);
9026
+ }
9027
+ /**
9028
+ * Add an item to a playlist
9029
+ * Adds a media item to a playlist.
9030
+ *
9031
+ * @param client - Fetch client instance
9032
+ * @param playlist_id - playlist_id
9033
+ * @param body - body
9034
+ */
9035
+ async function playlists_items_add(client, playlist_id, body) {
9036
+ return client.post(`/api/content/playlists/${playlist_id}/items`, body);
9037
+ }
9038
+ /**
9039
+ * Remove an item from a playlist
9040
+ * Removes a single item from a playlist.
9041
+ *
9042
+ * @param client - Fetch client instance
9043
+ * @param playlist_id - playlist_id
9044
+ * @param id - id
9045
+ */
9046
+ async function playlists_items_remove(client, playlist_id, id) {
9047
+ return client.delete(`/api/content/playlists/${playlist_id}/items/${id}`);
9048
+ }
9049
+ /**
9050
+ * List share links for the current user
9051
+ * Returns a paginated list of share links.
9052
+ *
9053
+ * @param client - Fetch client instance
9054
+ * @param [params] - params
9055
+ */
9056
+ async function shares_list(client, params) {
9057
+ return client.get(`/api/shares`, params);
9058
+ }
9059
+ /**
9060
+ * Create a share link
9061
+ * Creates a new share link for content.
9062
+ *
9063
+ * @param client - Fetch client instance
9064
+ * @param body - body
9065
+ */
9066
+ async function shares_create(client, body) {
9067
+ return client.post(`/api/shares`, body);
9068
+ }
9069
+ /**
9070
+ * List DAM assets
9071
+ * Returns a paginated list of DAM assets for the company.
9072
+ *
9073
+ * @param client - Fetch client instance
9074
+ * @param [params] - params
9075
+ */
9076
+ async function dam_assets_list(client, params) {
9077
+ return client.get(`/api/content/dam/assets`, params);
9078
+ }
9079
+ /**
9080
+ * Create a DAM asset
9081
+ * Creates a new DAM asset. Supports two modes:
9082
+ 1. **JSON placeholder** — send `application/json` with `asset[name]` to
9083
+ create a placeholder record for later file upload.
9084
+
9085
+ 2. **File upload** — send `multipart/form-data` with `asset[file]`,
9086
+ `asset[name]`, and optionally `asset[description]` and `asset[tags]`
9087
+ to upload a file and create the full asset with variants.
9088
+ *
9089
+ * @param client - Fetch client instance
9090
+ * @param body - body
9091
+ */
9092
+ async function dam_assets_create(client, body) {
9093
+ return client.post(`/api/content/dam/assets`, body);
9094
+ }
9095
+ /**
9096
+ * List paths for a DAM asset
9097
+ * Returns a paginated list of path aliases for a DAM asset.
9098
+ *
9099
+ * @param client - Fetch client instance
9100
+ * @param asset_code - asset_code
9101
+ * @param [params] - params
9102
+ */
9103
+ async function dam_asset_paths_list(client, asset_code, params) {
9104
+ return client.get(`/api/content/dam/assets/${asset_code}/paths`, params);
9105
+ }
9106
+ /**
9107
+ * Create a path alias for a DAM asset
9108
+ * Creates a new path alias for an existing DAM asset.
9109
+ *
9110
+ * @param client - Fetch client instance
9111
+ * @param asset_code - asset_code
9112
+ * @param body - body
9113
+ */
9114
+ async function dam_asset_paths_create(client, asset_code, body) {
9115
+ return client.post(`/api/content/dam/assets/${asset_code}/paths`, body);
9116
+ }
9117
+ /**
9118
+ * Query DAM assets using tree paths and tags
9119
+ * Searches and retrieves DAM assets using tree path pattern matching, tag-based variant filtering, wildcard name matching, and partial search. Supports cursor pagination for large result sets.
9120
+ *
9121
+ * @param client - Fetch client instance
9122
+ * @param body - body
9123
+ */
9124
+ async function dam_query(client, body) {
9125
+ return client.post(`/api/content/dam/query`, body);
9126
+ }
9127
+ /**
9128
+ * Delete a DAM asset
9129
+ * Permanently destroys a DAM asset, including its ImageKit storage, variants, and database records.
9130
+ *
9131
+ * @param client - Fetch client instance
9132
+ * @param code - code
9133
+ */
9134
+ async function dam_assets_destroy(client, code) {
9135
+ return client.delete(`/api/content/dam/assets/${code}`);
9136
+ }
9137
+ /**
9138
+ * Discard (soft-delete) a DAM asset
9139
+ * Soft-deletes a DAM asset. Used to discard an in-progress upload without permanently removing the record.
9140
+ *
9141
+ * @param client - Fetch client instance
9142
+ * @param code - code
9143
+ */
9144
+ async function dam_assets_discard(client, code) {
9145
+ return client.patch(`/api/content/dam/assets/${code}/discard`);
9146
+ }
9147
+ //#endregion
9148
+ //#region ../../shareables/api-client/src/portal-tenant-media-adapter.ts
9149
+ /**
9150
+ * Maps a BFF media object to the port's Media shape, providing defaults
9151
+ * for optional fields returned by the generated client.
9152
+ */
9153
+ function mapMedia(raw) {
9154
+ return {
9155
+ id: raw.id ?? 0,
9156
+ title: raw.title ?? "",
9157
+ description: raw.description ?? null,
9158
+ media_type: raw.media_type ?? "",
9159
+ url: raw.url ?? null,
9160
+ thumbnail_url: raw.thumbnail_url ?? null,
9161
+ owner_type: raw.owner_type ?? "",
9162
+ created_at: raw.created_at ?? "",
9163
+ updated_at: raw.updated_at ?? ""
9164
+ };
9165
+ }
9166
+ /**
9167
+ * Maps the BFF meta envelope to the port's ApiMeta shape.
9168
+ */
9169
+ function mapMeta$3(raw) {
9170
+ return {
9171
+ request_id: raw?.request_id ?? null,
9172
+ timestamp: raw?.timestamp ?? "",
9173
+ pagination: raw?.pagination ? {
9174
+ cursor: raw.pagination.cursor ?? null,
9175
+ limit: raw.pagination.limit,
9176
+ next_cursor: raw.pagination.next_cursor ?? null,
9177
+ prev_cursor: raw.pagination.prev_cursor ?? null
9178
+ } : void 0
9179
+ };
9180
+ }
9181
+ /**
9182
+ * Creates a ContentMediaApi adapter backed by the portal-tenant content BFF.
9183
+ *
9184
+ * Maps the generated portal-tenant-content namespace functions to the abstract
9185
+ * ContentMediaApi port, closing over the FetchClient so consumers don't need
9186
+ * to pass it per-call.
9187
+ */
9188
+ function createPortalTenantMediaAdapter(client) {
9189
+ return {
9190
+ listMedia: async (params) => {
9191
+ const response = await media_list(client, {
9192
+ "page[cursor]": params?.cursor,
9193
+ "page[limit]": params?.limit,
9194
+ media_type: params?.media_type,
9195
+ "filter[title]": params?.["filter[title]"],
9196
+ sort: params?.sort
9197
+ });
9198
+ return {
9199
+ media: (response.media ?? []).map(mapMedia),
9200
+ meta: mapMeta$3(response.meta)
9201
+ };
9202
+ },
9203
+ createMedia: async (body) => {
9204
+ const response = await media_create(client, { media: body });
9205
+ return {
9206
+ media: mapMedia(response.media ?? {}),
9207
+ meta: mapMeta$3(response.meta)
9208
+ };
9209
+ },
9210
+ getMedia: async (id) => {
9211
+ const response = await media_show(client, id);
9212
+ return {
9213
+ media: mapMedia(response.media ?? {}),
9214
+ meta: mapMeta$3(response.meta)
9215
+ };
9216
+ },
9217
+ updateMedia: async (id, body) => {
9218
+ const response = await media_update(client, id, { media: body });
9219
+ return {
9220
+ media: mapMedia(response.media ?? {}),
9221
+ meta: mapMeta$3(response.meta)
9222
+ };
9223
+ },
9224
+ deleteMedia: async (id) => {
9225
+ const response = await media_destroy(client, id);
9226
+ return {
9227
+ media: { id: response.media?.id ?? 0 },
9228
+ meta: mapMeta$3(response.meta)
9229
+ };
9230
+ }
9231
+ };
9232
+ }
9233
+ function mediaKindFromType$1(mediaType) {
9234
+ if (mediaType === "video") return "video";
9235
+ if (mediaType === "image") return "image";
9236
+ if (mediaType === "document" || mediaType === "pdf") return "pdf";
9237
+ return null;
9238
+ }
9239
+ function toBffMediumResponse(bff) {
9240
+ const kind = mediaKindFromType$1(bff.media_type);
9241
+ const isVideo = bff.media_type === "video";
9242
+ const isPdf = bff.media_type === "pdf" || bff.media_type === "document";
9243
+ return {
9244
+ id: bff.id,
9245
+ user_id: null,
9246
+ media_type: bff.media_type,
9247
+ media_format: bff.media_type,
9248
+ image_url: !isVideo && !isPdf ? bff.url ?? bff.thumbnail_url ?? null : bff.thumbnail_url ?? null,
9249
+ video_url: isVideo ? bff.url ?? null : null,
9250
+ pdf_url: isPdf ? bff.url ?? null : null,
9251
+ title: bff.title,
9252
+ description: {
9253
+ id: null,
9254
+ name: null,
9255
+ body: bff.description ?? null,
9256
+ record_type: null,
9257
+ record_id: null,
9258
+ created_at: bff.created_at ?? null,
9259
+ updated_at: bff.updated_at ?? null,
9260
+ locale: null
9261
+ },
9262
+ stripped: bff.description ?? null,
9263
+ kind,
9264
+ active: true,
9265
+ visibility: null,
9266
+ share_link: null,
9267
+ views: 0,
9268
+ leads: 0,
9269
+ watch: null,
9270
+ video_status: null,
9271
+ duration: null,
9272
+ cta_url: null,
9273
+ cta_button_text: null,
9274
+ cta_enabled: false,
9275
+ cta_action_type: null,
9276
+ video_shopping_enabled: false,
9277
+ prompts_enabled: false,
9278
+ ranks: [],
9279
+ preview_link: null,
9280
+ attached_shareables: [],
9281
+ created_at: bff.created_at
9282
+ };
9283
+ }
9284
+ /**
9285
+ * Creates a ShareablesApi["media"]-compatible adapter backed by the
9286
+ * portal-tenant content BFF. Includes cursor-to-page-number caching
9287
+ * for bridging the legacy UI's page-number pagination.
9288
+ */
9289
+ function createPortalTenantMediaShareablesAdapter(client) {
9290
+ const portAdapter = createPortalTenantMediaAdapter(client);
9291
+ const cursorByPage = /* @__PURE__ */ new Map();
9292
+ let lastFilterKey = "";
9293
+ return {
9294
+ getMedia: async (options) => {
9295
+ const pageNumber = options?.page ?? 1;
9296
+ const filterKey = `${options?.search_query ?? ""}|${options?.sorted_by ?? ""}|${options?.media_type ?? options?.with_type ?? ""}`;
9297
+ if (filterKey !== lastFilterKey) {
9298
+ cursorByPage.clear();
9299
+ lastFilterKey = filterKey;
9300
+ }
9301
+ const cursor = pageNumber > 1 ? cursorByPage.get(pageNumber) : void 0;
9302
+ const rawSort = options?.sorted_by;
9303
+ let bffSort;
9304
+ if (rawSort === "title_asc") bffSort = "title_asc";
9305
+ else if (rawSort === "title_desc") bffSort = "title_desc";
9306
+ const response = await portAdapter.listMedia({
9307
+ cursor,
9308
+ limit: options?.per_page,
9309
+ media_type: options?.media_type ?? options?.with_type,
9310
+ "filter[title]": options?.search_query,
9311
+ sort: bffSort
9312
+ });
9313
+ const nextCursor = response.meta.pagination?.next_cursor;
9314
+ if (nextCursor) cursorByPage.set(pageNumber + 1, nextCursor);
9315
+ const transformedItems = response.media.map(toBffMediumResponse);
9316
+ return {
9317
+ data: transformedItems,
9318
+ status: "success",
9319
+ media: transformedItems,
9320
+ meta: {
9321
+ total_count: transformedItems.length,
9322
+ current: pageNumber,
9323
+ per_page: options?.per_page ?? 24,
9324
+ pages: nextCursor ? pageNumber + 1 : pageNumber,
9325
+ next: nextCursor ? pageNumber + 1 : null,
9326
+ previous: pageNumber > 1 ? pageNumber - 1 : null
9327
+ }
9328
+ };
9329
+ },
9330
+ getMediaById: async (id) => {
9331
+ const medium = toBffMediumResponse((await portAdapter.getMedia(id)).media);
9332
+ return {
9333
+ data: medium,
9334
+ status: "success",
9335
+ media: medium
9336
+ };
9337
+ },
9338
+ createMedia: async (mediaData) => {
9339
+ return toBffMediumResponse((await portAdapter.createMedia({
9340
+ title: mediaData.title ?? "",
9341
+ description: mediaData.description,
9342
+ media_type: mediaData.media_type ?? "image",
9343
+ url: mediaData.image_url ?? mediaData.video_url ?? mediaData.pdf_url ?? void 0
9344
+ })).media);
9345
+ },
9346
+ updateMedia: async (id, mediaData) => {
9347
+ return toBffMediumResponse((await portAdapter.updateMedia(id, {
9348
+ title: mediaData.title,
9349
+ description: mediaData.description
9350
+ })).media);
9351
+ },
9352
+ deleteMedia: async (id) => {
9353
+ await portAdapter.deleteMedia(id);
9354
+ return { success: true };
9355
+ }
9356
+ };
9357
+ }
9358
+ //#endregion
9359
+ //#region ../../shareables/api-client/src/portal-tenant-playlists-adapter.ts
9360
+ /**
9361
+ * Maps a BFF playlist object to the port's Playlist shape.
9362
+ */
9363
+ function mapPlaylist(raw) {
9364
+ return {
9365
+ id: raw.id ?? 0,
9366
+ title: raw.title ?? "",
9367
+ description: raw.description ?? null,
9368
+ items_count: raw.items_count ?? 0,
9369
+ user_id: raw.user_id,
9370
+ is_favorited: raw.is_favorited,
9371
+ image_url: raw.image_url ?? null,
9372
+ created_at: raw.created_at ?? "",
9373
+ updated_at: raw.updated_at ?? ""
9374
+ };
9375
+ }
9376
+ /**
9377
+ * Maps a BFF playlist item to the port's PlaylistItem shape.
9378
+ */
9379
+ function mapPlaylistItem(raw) {
9380
+ return {
9381
+ id: raw.id ?? 0,
9382
+ media_id: raw.media_id ?? 0,
9383
+ position: raw.position ?? null,
9384
+ title: raw.title,
9385
+ image_url: raw.image_url ?? null,
9386
+ media_type: raw.media_type,
9387
+ video_url: raw.video_url ?? null,
9388
+ duration: raw.duration ?? null,
9389
+ created_at: raw.created_at ?? ""
9390
+ };
9391
+ }
9392
+ /**
9393
+ * Maps the BFF meta envelope to the port's ApiMeta shape.
9394
+ */
9395
+ function mapMeta$2(raw) {
9396
+ return {
9397
+ request_id: raw?.request_id ?? null,
9398
+ timestamp: raw?.timestamp ?? "",
9399
+ pagination: raw?.pagination ? {
9400
+ cursor: raw.pagination.cursor ?? null,
9401
+ limit: raw.pagination.limit,
9402
+ next_cursor: raw.pagination.next_cursor ?? null,
9403
+ prev_cursor: raw.pagination.prev_cursor ?? null
9404
+ } : void 0
9405
+ };
9406
+ }
9407
+ /**
9408
+ * Creates a ContentPlaylistsApi adapter backed by the portal-tenant content BFF.
9409
+ *
9410
+ * Maps the generated portal-tenant-content namespace functions to the abstract
9411
+ * ContentPlaylistsApi port, closing over the FetchClient so consumers don't
9412
+ * need to pass it per-call.
9413
+ */
9414
+ function createPortalTenantPlaylistsAdapter(client) {
9415
+ return {
9416
+ listPlaylists: async (params) => {
9417
+ const response = await playlists_list(client, {
9418
+ "page[cursor]": params?.cursor,
9419
+ "page[limit]": params?.limit,
9420
+ "filter[title]": params?.["filter[title]"],
9421
+ sort: params?.sort
9422
+ });
9423
+ return {
9424
+ playlists: (response.playlists ?? []).map(mapPlaylist),
9425
+ meta: mapMeta$2(response.meta)
9426
+ };
9427
+ },
9428
+ createPlaylist: async (body) => {
9429
+ const response = await playlists_create(client, { playlist: body });
9430
+ return {
9431
+ playlist: mapPlaylist(response.playlist ?? {}),
9432
+ meta: mapMeta$2(response.meta)
9433
+ };
9434
+ },
9435
+ getPlaylist: async (id) => {
9436
+ const response = await playlists_show(client, id);
9437
+ return {
9438
+ playlist: mapPlaylist(response.playlist ?? {}),
9439
+ meta: mapMeta$2(response.meta)
9440
+ };
9441
+ },
9442
+ updatePlaylist: async (id, body) => {
9443
+ const response = await playlists_update(client, id, { playlist: body });
9444
+ return {
9445
+ playlist: mapPlaylist(response.playlist ?? {}),
9446
+ meta: mapMeta$2(response.meta)
9447
+ };
9448
+ },
9449
+ deletePlaylist: async (id) => {
9450
+ const response = await playlists_destroy(client, id);
9451
+ return {
9452
+ playlist: { id: response.playlist?.id ?? 0 },
9453
+ meta: mapMeta$2(response.meta)
9454
+ };
9455
+ },
9456
+ listPlaylistItems: async (playlistId, params) => {
9457
+ const response = await playlists_items_list(client, playlistId, {
9458
+ "page[cursor]": params?.cursor,
9459
+ "page[limit]": params?.limit
9460
+ });
9461
+ return {
9462
+ playlist_items: (response.playlist_items ?? []).map(mapPlaylistItem),
9463
+ meta: mapMeta$2(response.meta)
9464
+ };
9465
+ },
9466
+ addPlaylistItem: async (playlistId, body) => {
9467
+ const response = await playlists_items_add(client, playlistId, { item: body });
9468
+ return {
9469
+ playlist_item: mapPlaylistItem(response.playlist_item ?? {}),
9470
+ meta: mapMeta$2(response.meta)
9471
+ };
9472
+ },
9473
+ removePlaylistItem: async (playlistId, itemId) => {
9474
+ const response = await playlists_items_remove(client, playlistId, itemId);
9475
+ return {
9476
+ playlist_item: { id: response.playlist_item?.id ?? 0 },
9477
+ meta: mapMeta$2(response.meta)
9478
+ };
9479
+ }
9480
+ };
9481
+ }
9482
+ function mediaKindFromType(mediaType) {
9483
+ if (mediaType === "video") return "video";
9484
+ if (mediaType === "image") return "image";
9485
+ if (mediaType === "document" || mediaType === "pdf") return "pdf";
9486
+ return null;
9487
+ }
9488
+ function toBffPlaylist(bff, items) {
9489
+ return {
9490
+ id: bff.id,
9491
+ title: bff.title,
9492
+ description: bff.description ?? null,
9493
+ image_url: bff.image_url ?? null,
9494
+ slug: null,
9495
+ active: true,
9496
+ user_id: bff.user_id ?? null,
9497
+ is_favorited: bff.is_favorited ?? false,
9498
+ items: items ?? [],
9499
+ items_count: bff.items_count
9500
+ };
9501
+ }
9502
+ /**
9503
+ * Creates a ShareablesApi["playlists"]-compatible adapter backed by the
9504
+ * portal-tenant content BFF. Fetches playlist + items in parallel for
9505
+ * detail views and maps enriched flat fields onto playlist items.
9506
+ */
9507
+ function createPortalTenantPlaylistsShareablesAdapter(client) {
9508
+ const portAdapter = createPortalTenantPlaylistsAdapter(client);
9509
+ return {
9510
+ getPlaylists: async (options) => {
9511
+ const rawSort = options?.sort;
9512
+ let bffSort;
9513
+ if (rawSort === "title_asc" || rawSort === "title") bffSort = "title_asc";
9514
+ else if (rawSort === "title_desc" || rawSort === "-title") bffSort = "title_desc";
9515
+ else if (rawSort === "created_at_asc" || rawSort === "created_at") bffSort = "created_at_asc";
9516
+ else if (rawSort === "created_at_desc" || rawSort === "-created_at") bffSort = "created_at_desc";
9517
+ const response = await portAdapter.listPlaylists({
9518
+ cursor: options?.["page[cursor]"],
9519
+ limit: options?.["page[limit]"],
9520
+ "filter[title]": options?.["filter[title]"],
9521
+ sort: bffSort
9522
+ });
9523
+ return {
9524
+ playlists: response.playlists.map((p) => toBffPlaylist(p)),
9525
+ meta: {
9526
+ request_id: response.meta.request_id ?? "",
9527
+ timestamp: response.meta.timestamp ?? "",
9528
+ pagination: {
9529
+ cursor: response.meta.pagination?.cursor ?? null,
9530
+ limit: response.meta.pagination?.limit ?? 12,
9531
+ prev_cursor: response.meta.pagination?.prev_cursor ?? null,
9532
+ next_cursor: response.meta.pagination?.next_cursor ?? null,
9533
+ total_count: 0,
9534
+ total_pages: 0
9535
+ }
9536
+ }
9537
+ };
9538
+ },
9539
+ getPlaylistById: async (id) => {
9540
+ const response = await portAdapter.getPlaylist(id);
9541
+ const allItems = [];
9542
+ let cursor;
9543
+ const MAX_PAGES = 50;
9544
+ for (let i = 0; i < MAX_PAGES; i++) {
9545
+ const page = await portAdapter.listPlaylistItems(id, {
9546
+ cursor,
9547
+ limit: 100
9548
+ });
9549
+ allItems.push(...page.playlist_items);
9550
+ cursor = page.meta.pagination?.next_cursor ?? void 0;
9551
+ if (!cursor) break;
9552
+ }
9553
+ const items = allItems.map((item) => ({
9554
+ id: item.id,
9555
+ order: item.position ?? void 0,
9556
+ relateable_type: "Medium",
9557
+ relateable: { id: item.media_id },
9558
+ title: item.title ?? "Untitled",
9559
+ image_url: item.image_url ?? null,
9560
+ kind: mediaKindFromType(item.media_type ?? ""),
9561
+ video_url: item.video_url ?? null,
9562
+ duration: item.duration ?? null,
9563
+ media_format: item.media_type ?? null
9564
+ }));
9565
+ return {
9566
+ playlist: toBffPlaylist(response.playlist, items),
9567
+ meta: {
9568
+ request_id: response.meta.request_id ?? "",
9569
+ timestamp: response.meta.timestamp ?? ""
9570
+ }
9571
+ };
9572
+ },
9573
+ createPlaylist: async (data) => {
9574
+ const response = await portAdapter.createPlaylist({
9575
+ title: data.playlist.title,
9576
+ description: data.playlist.description
9577
+ });
9578
+ return {
9579
+ playlist: toBffPlaylist(response.playlist),
9580
+ meta: {
9581
+ request_id: response.meta.request_id ?? "",
9582
+ timestamp: response.meta.timestamp ?? ""
9583
+ }
9584
+ };
9585
+ },
9586
+ updatePlaylist: async (id, data) => {
9587
+ const response = await portAdapter.updatePlaylist(id, {
9588
+ title: data.playlist.title,
9589
+ description: data.playlist.description
9590
+ });
9591
+ return {
9592
+ playlist: toBffPlaylist(response.playlist),
9593
+ meta: {
9594
+ request_id: response.meta.request_id ?? "",
9595
+ timestamp: response.meta.timestamp ?? ""
9596
+ }
9597
+ };
9598
+ },
9599
+ addItemToPlaylist: async (id, data) => {
9600
+ await Promise.all(data.items.map((item) => portAdapter.addPlaylistItem(id, {
9601
+ media_id: item.relateable_id,
9602
+ position: typeof item.order === "number" ? item.order : Number(item.order)
9603
+ })));
9604
+ return toBffPlaylist((await portAdapter.getPlaylist(id)).playlist);
9605
+ },
9606
+ removeItemsFromPlaylist: async (playlistId, data) => {
9607
+ await Promise.all(data.item_ids.map((itemId) => portAdapter.removePlaylistItem(playlistId, itemId)));
9608
+ return toBffPlaylist((await portAdapter.getPlaylist(playlistId)).playlist);
9609
+ }
9610
+ };
9611
+ }
9612
+ //#endregion
9613
+ //#region ../../shareables/api-client/src/portal-tenant-dam-assets-adapter.ts
9614
+ /**
9615
+ * Maps a BFF DAM asset to the port's DamAsset shape.
9616
+ */
9617
+ function mapDamAsset(raw) {
9618
+ return {
9619
+ id: raw.id ?? 0,
9620
+ code: raw.code ?? "",
9621
+ name: raw.name ?? "",
9622
+ description: raw.description ?? null,
9623
+ category: raw.category ?? null,
9624
+ company: raw.company ?? null,
9625
+ default_variant_id: raw.default_variant_id ?? null,
9626
+ default_variant_url: raw.default_variant_url ?? null,
9627
+ canonical_path: raw.canonical_path ?? null,
9628
+ created_at: raw.created_at ?? "",
9629
+ updated_at: raw.updated_at ?? ""
9630
+ };
9631
+ }
9632
+ /**
9633
+ * Maps a BFF DAM asset path to the port's DamAssetPath shape.
9634
+ */
9635
+ function mapDamAssetPath(raw) {
9636
+ return {
9637
+ id: raw.id ?? 0,
9638
+ asset_code: raw.asset_code ?? "",
9639
+ path: raw.path ?? "",
9640
+ created_at: raw.created_at ?? ""
9641
+ };
9642
+ }
9643
+ /**
9644
+ * Maps the BFF meta envelope to the port's ApiMeta shape.
9645
+ */
9646
+ function mapMeta$1(raw) {
9647
+ return {
9648
+ request_id: raw?.request_id ?? null,
9649
+ timestamp: raw?.timestamp ?? "",
9650
+ pagination: raw?.pagination ? {
9651
+ cursor: raw.pagination.cursor ?? null,
9652
+ limit: raw.pagination.limit,
9653
+ next_cursor: raw.pagination.next_cursor ?? null,
9654
+ prev_cursor: raw.pagination.prev_cursor ?? null
9655
+ } : void 0
9656
+ };
9657
+ }
9658
+ /**
9659
+ * Creates a ContentDamAssetsApi adapter backed by the portal-tenant content BFF.
9660
+ *
9661
+ * Maps the generated portal-tenant-content namespace functions to the abstract
9662
+ * ContentDamAssetsApi port, closing over the FetchClient so consumers don't
9663
+ * need to pass it per-call.
9664
+ */
9665
+ function createPortalTenantDamAssetsAdapter(client) {
9666
+ return {
9667
+ listAssets: async (params) => {
9668
+ const response = await dam_assets_list(client, {
9669
+ "page[cursor]": params?.cursor,
9670
+ "page[limit]": params?.limit
9671
+ });
9672
+ return {
9673
+ assets: (response.assets ?? []).map(mapDamAsset),
9674
+ meta: mapMeta$1(response.meta)
9675
+ };
9676
+ },
9677
+ createAsset: async (body) => {
9678
+ const response = await dam_assets_create(client, { asset: body });
9679
+ return {
9680
+ asset: mapDamAsset(response.asset ?? {}),
9681
+ meta: mapMeta$1(response.meta)
9682
+ };
9683
+ },
9684
+ listAssetPaths: async (assetCode, params) => {
9685
+ const response = await dam_asset_paths_list(client, assetCode, {
9686
+ "page[cursor]": params?.cursor,
9687
+ "page[limit]": params?.limit
9688
+ });
9689
+ return {
9690
+ asset_paths: (response.asset_paths ?? []).map(mapDamAssetPath),
9691
+ meta: mapMeta$1(response.meta)
9692
+ };
9693
+ },
9694
+ createAssetPath: async (assetCode, body) => {
9695
+ const response = await dam_asset_paths_create(client, assetCode, { asset_path: body });
9696
+ return {
9697
+ asset_path: mapDamAssetPath(response.asset_path ?? {}),
9698
+ meta: mapMeta$1(response.meta)
9699
+ };
9700
+ }
9701
+ };
9702
+ }
9703
+ /**
9704
+ * Creates a ShareablesApi["fileResources"]-compatible adapter backed by the
9705
+ * portal-tenant content BFF. Maps DamAsset to FileResource shape and
9706
+ * includes cursor-to-page-number caching for legacy UI pagination.
9707
+ */
9708
+ function createPortalTenantFilesShareablesAdapter(client) {
9709
+ const portAdapter = createPortalTenantDamAssetsAdapter(client);
9710
+ const cursorByPage = /* @__PURE__ */ new Map();
9711
+ return { getFileResources: async (params) => {
9712
+ const pageNumber = params?.pageParam ? Number(params.pageParam) : 1;
9713
+ const pageSize = params?.pageSize ? Number(params.pageSize) : 25;
9714
+ const cursor = pageNumber > 1 ? cursorByPage.get(pageNumber) : void 0;
9715
+ const response = await portAdapter.listAssets({
9716
+ cursor,
9717
+ limit: pageSize
9718
+ });
9719
+ const nextCursor = response.meta.pagination?.next_cursor;
9720
+ if (nextCursor) cursorByPage.set(pageNumber + 1, nextCursor);
9721
+ const fileResources = response.assets.map((asset) => ({
9722
+ id: asset.id,
9723
+ alt_text: asset.name,
9724
+ url: asset.default_variant_url ?? "",
9725
+ filename: asset.name,
9726
+ content_type: "application/octet-stream",
9727
+ content_size: 0,
9728
+ handle: asset.code,
9729
+ dam_asset_code: asset.code,
9730
+ preview_image_url: asset.default_variant_url ?? "",
9731
+ created_at: asset.created_at,
9732
+ updated_at: asset.updated_at ?? "",
9733
+ relateable_type: null,
9734
+ relateable_id: null,
9735
+ content: null
9736
+ }));
9737
+ const hasNextPage = !!nextCursor;
9738
+ return {
9739
+ file_resources: fileResources,
9740
+ meta: {
9741
+ total_count: fileResources.length,
9742
+ per_page: pageSize,
9743
+ current_page: pageNumber,
9744
+ total_pages: hasNextPage ? pageNumber + 1 : pageNumber
9745
+ }
9746
+ };
9747
+ } };
9748
+ }
9749
+ //#endregion
9750
+ //#region ../../shareables/api-client/src/portal-tenant-shares-adapter.ts
9751
+ /**
9752
+ * Narrows an unknown string to a valid ShareableType at runtime.
9753
+ */
9754
+ function isShareableType(value) {
9755
+ return value === "media" || value === "product" || value === "library" || value === "page";
9756
+ }
9757
+ /**
9758
+ * Maps a BFF share to the port's Share shape.
9759
+ */
9760
+ function mapShare(raw) {
9761
+ return {
9762
+ id: raw.id ?? 0,
9763
+ url: raw.url ?? "",
9764
+ shareable_type: isShareableType(raw.shareable_type) ? raw.shareable_type : "media",
9765
+ shareable_id: raw.shareable_id ?? 0,
9766
+ created_at: raw.created_at ?? ""
9767
+ };
9768
+ }
9769
+ /**
9770
+ * Maps the BFF meta envelope to the port's ApiMeta shape.
9771
+ */
9772
+ function mapMeta(raw) {
9773
+ return {
9774
+ request_id: raw?.request_id ?? null,
9775
+ timestamp: raw?.timestamp ?? "",
9776
+ pagination: raw?.pagination ? {
9777
+ cursor: raw.pagination.cursor ?? null,
9778
+ limit: raw.pagination.limit,
9779
+ next_cursor: raw.pagination.next_cursor ?? null,
9780
+ prev_cursor: raw.pagination.prev_cursor ?? null
9781
+ } : void 0
9782
+ };
9783
+ }
9784
+ /**
9785
+ * Creates a ContentSharesApi adapter backed by the portal-tenant content BFF.
9786
+ *
9787
+ * Maps the generated portal-tenant-content namespace functions to the abstract
9788
+ * ContentSharesApi port, closing over the FetchClient so consumers don't need
9789
+ * to pass it per-call.
9790
+ */
9791
+ function createPortalTenantSharesAdapter(client) {
9792
+ return {
9793
+ listShares: async (params) => {
9794
+ const response = await shares_list(client, {
9795
+ "page[cursor]": params?.cursor,
9796
+ "page[limit]": params?.limit
9797
+ });
9798
+ return {
9799
+ shares: (response.shares ?? []).map(mapShare),
9800
+ meta: mapMeta(response.meta)
9801
+ };
9802
+ },
9803
+ createShare: async (body) => {
9804
+ const response = await shares_create(client, { share: body });
9805
+ return {
9806
+ share: mapShare(response.share ?? {}),
9807
+ meta: mapMeta(response.meta)
9808
+ };
9809
+ }
9810
+ };
9811
+ }
9812
+ /**
9813
+ * Maps legacy Rails model names (used by the UI) to BFF shareable_type values.
9814
+ */
9815
+ const SHAREABLE_TYPE_MAP = {
9816
+ Medium: "media",
9817
+ media: "media",
9818
+ Product: "product",
9819
+ product: "product",
9820
+ Library: "library",
9821
+ library: "library",
9822
+ Page: "page",
9823
+ page: "page"
9824
+ };
9825
+ /**
9826
+ * Creates a ShareablesApi["share"]-compatible adapter backed by the
9827
+ * portal-tenant content BFF. Maps legacy model names to BFF shareable types.
9828
+ */
9829
+ function createPortalTenantSharesShareablesAdapter(client) {
9830
+ const portAdapter = createPortalTenantSharesAdapter(client);
9831
+ return { createShareLink: async (input) => {
9832
+ if (!input.relateableId) throw new Error("Cannot create share link without a relateableId");
9833
+ const shareableType = SHAREABLE_TYPE_MAP[input.relateableType];
9834
+ if (!shareableType) throw new Error(`Unknown shareable type: "${input.relateableType}"`);
9835
+ return (await portAdapter.createShare({
9836
+ shareable_type: shareableType,
9837
+ shareable_id: input.relateableId
9838
+ })).share.url;
9839
+ } };
9840
+ }
9841
+ //#endregion
9842
+ //#region ../../shareables/api-client/src/portal-tenant-product-media-adapter.ts
9843
+ function mapProductMedia(raw) {
9844
+ const isVideo = raw.media_type === "video";
9845
+ const isPdf = raw.media_type === "pdf" || raw.media_type === "document";
9846
+ return {
9847
+ id: raw.id ?? 0,
9848
+ slug: null,
9849
+ title: raw.title ?? "",
9850
+ kind: isVideo ? "video" : isPdf ? "pdf" : "image",
9851
+ media_type: raw.media_type ?? "image",
9852
+ media_format: raw.media_type ?? "image",
9853
+ image_url: !isVideo && !isPdf ? raw.url ?? null : null,
9854
+ video_url: isVideo ? raw.url ?? null : null,
9855
+ pdf_url: isPdf ? raw.url ?? null : null,
9856
+ powerpoint_url: null,
9857
+ duration: 0,
9858
+ description: null,
9859
+ subtitles: {},
9860
+ comments_count: 0
9861
+ };
9862
+ }
9863
+ /**
9864
+ * Creates a ShareablesApi["productMedia"]-compatible adapter that bridges
9865
+ * the products BFF into the shareables domain. Takes any object satisfying
9866
+ * ProductMediaSource (e.g. PortalProductsApi from products-core).
9867
+ */
9868
+ function createPortalTenantProductMediaShareablesAdapter(source) {
9869
+ return { getProductMedia: async (productId) => {
9870
+ return { media: ((await source.getProductMedia(productId)).media ?? []).map(mapProductMedia) };
9871
+ } };
9872
+ }
9873
+ //#endregion
9874
+ export { createPortalTenantPlaylistsShareablesAdapter as a, dam_assets_destroy as c, ProductsApp as d, ShareablesApp as f, ShareablesCoreProvider as h, createPortalTenantPlaylistsAdapter as i, dam_assets_discard as l, ShareablesApiProvider as m, createPortalTenantSharesShareablesAdapter as n, createPortalTenantMediaShareablesAdapter as o, ShareablesUIProvider as p, createPortalTenantFilesShareablesAdapter as r, dam_asset_paths_create as s, createPortalTenantProductMediaShareablesAdapter as t, dam_query as u };
8899
9875
 
8900
- //# sourceMappingURL=src-BbjxT3sc.mjs.map
9876
+ //# sourceMappingURL=portal-tenant-product-media-adapter-Co9Kw-US.mjs.map