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