sanity-plugin-media 4.3.0 → 4.3.2

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 (145) hide show
  1. package/LICENSE +4 -4
  2. package/README.md +12 -12
  3. package/dist/index.d.mts +263 -195
  4. package/dist/index.d.ts +263 -195
  5. package/dist/index.js +83 -203
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +84 -203
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +42 -64
  10. package/src/__tests__/fixtures/createEpicTestStore.ts +5 -4
  11. package/src/__tests__/fixtures/mockSanityClient.ts +8 -8
  12. package/src/__tests__/fixtures/renderWithProviders.tsx +8 -7
  13. package/src/__tests__/fixtures/rootState.ts +4 -4
  14. package/src/components/AssetGridVirtualized/index.tsx +8 -7
  15. package/src/components/AssetMetadata/index.tsx +6 -5
  16. package/src/components/AssetTableVirtualized/index.tsx +7 -6
  17. package/src/components/AutoTagInputWrapper/index.tsx +9 -4
  18. package/src/components/Browser/Browser.test.tsx +9 -8
  19. package/src/components/Browser/index.tsx +2 -1
  20. package/src/components/Browser/useBrowserInit.ts +9 -9
  21. package/src/components/ButtonAssetCopy/index.tsx +1 -0
  22. package/src/components/ButtonViewGroup/index.tsx +4 -3
  23. package/src/components/CardAsset/CardAsset.test.tsx +53 -52
  24. package/src/components/CardAsset/index.tsx +52 -49
  25. package/src/components/CardUpload/index.tsx +7 -6
  26. package/src/components/Controls/index.tsx +7 -6
  27. package/src/components/DebugControls/index.tsx +5 -4
  28. package/src/components/DialogAssetEdit/Details.tsx +3 -2
  29. package/src/components/DialogAssetEdit/DialogAssetEdit.test.tsx +28 -27
  30. package/src/components/DialogAssetEdit/index.tsx +37 -37
  31. package/src/components/DialogConfirm/index.tsx +2 -1
  32. package/src/components/DialogSearchFacets/index.tsx +3 -2
  33. package/src/components/DialogTagCreate/DialogTagCreate.test.tsx +16 -15
  34. package/src/components/DialogTagCreate/index.tsx +11 -10
  35. package/src/components/DialogTagEdit/DialogTagEdit.test.tsx +28 -27
  36. package/src/components/DialogTagEdit/index.tsx +17 -16
  37. package/src/components/DialogTags/index.tsx +4 -3
  38. package/src/components/Dialogs/index.tsx +2 -3
  39. package/src/components/DocumentList/index.tsx +2 -3
  40. package/src/components/FileAssetPreview/index.tsx +2 -2
  41. package/src/components/FormBuilderTool/FormBuilderTool.test.tsx +12 -11
  42. package/src/components/FormBuilderTool/index.tsx +2 -1
  43. package/src/components/FormFieldInputLabel/index.tsx +1 -2
  44. package/src/components/FormFieldInputTags/index.tsx +4 -3
  45. package/src/components/FormSubmitButton/index.tsx +1 -1
  46. package/src/components/Header/index.tsx +3 -3
  47. package/src/components/Image/index.tsx +10 -4
  48. package/src/components/Items/index.tsx +5 -4
  49. package/src/components/Notifications/index.tsx +3 -2
  50. package/src/components/OrderSelect/index.tsx +4 -3
  51. package/src/components/PickedBar/index.tsx +2 -1
  52. package/src/components/Progress/index.tsx +3 -3
  53. package/src/components/ReduxProvider/index.tsx +15 -12
  54. package/src/components/SearchFacet/index.tsx +3 -2
  55. package/src/components/SearchFacetNumber/index.tsx +8 -8
  56. package/src/components/SearchFacetSelect/index.tsx +7 -8
  57. package/src/components/SearchFacetString/index.tsx +1 -1
  58. package/src/components/SearchFacetTags/index.tsx +13 -12
  59. package/src/components/SearchFacets/index.tsx +2 -3
  60. package/src/components/SearchFacetsControl/index.tsx +13 -12
  61. package/src/components/TableHeader/index.tsx +18 -17
  62. package/src/components/TableHeaderItem/index.tsx +4 -4
  63. package/src/components/TableRowAsset/index.tsx +37 -36
  64. package/src/components/TableRowUpload/index.tsx +7 -6
  65. package/src/components/Tag/index.tsx +8 -7
  66. package/src/components/TagView/index.tsx +2 -2
  67. package/src/components/TagViewHeader/index.tsx +5 -4
  68. package/src/components/TagsPanel/index.tsx +3 -3
  69. package/src/components/TagsVirtualized/index.tsx +25 -24
  70. package/src/components/TextInputSearch/index.tsx +3 -2
  71. package/src/components/UploadDropzone/UploadDropzone.test.tsx +8 -7
  72. package/src/components/UploadDropzone/index.tsx +14 -13
  73. package/src/config/orders.ts +6 -6
  74. package/src/config/searchFacets.ts +56 -55
  75. package/src/constants.ts +15 -14
  76. package/src/contexts/AssetSourceDispatchContext.tsx +1 -1
  77. package/src/contexts/ToolOptionsContext.tsx +6 -5
  78. package/src/formSchema/index.test.ts +6 -5
  79. package/src/formSchema/index.ts +5 -5
  80. package/src/hooks/useBreakpointIndex.ts +6 -6
  81. package/src/hooks/useKeyPress.ts +2 -2
  82. package/src/hooks/usePortalPopoverProps.ts +1 -1
  83. package/src/modules/assets/actions.ts +8 -7
  84. package/src/modules/assets/deleteAndUpdateEpics.test.ts +18 -17
  85. package/src/modules/assets/fetchEpic.test.ts +12 -11
  86. package/src/modules/assets/index.ts +134 -133
  87. package/src/modules/assets/reducer.test.ts +9 -8
  88. package/src/modules/assets/tagsAndListenerEpics.test.ts +36 -35
  89. package/src/modules/debug/index.ts +3 -3
  90. package/src/modules/dialog/actions.ts +2 -2
  91. package/src/modules/dialog/epics.test.ts +29 -28
  92. package/src/modules/dialog/index.ts +36 -35
  93. package/src/modules/dialog/reducer.test.ts +31 -30
  94. package/src/modules/index.ts +9 -9
  95. package/src/modules/notifications/epics.test.ts +71 -70
  96. package/src/modules/notifications/index.ts +50 -49
  97. package/src/modules/notifications/reducer.test.ts +8 -7
  98. package/src/modules/search/index.test.ts +2 -1
  99. package/src/modules/search/index.ts +22 -22
  100. package/src/modules/selected/index.ts +2 -2
  101. package/src/modules/selectors.test.ts +4 -3
  102. package/src/modules/selectors.ts +5 -5
  103. package/src/modules/tags/epics.test.ts +16 -15
  104. package/src/modules/tags/index.test.ts +2 -1
  105. package/src/modules/tags/index.ts +82 -81
  106. package/src/modules/uploads/actions.ts +3 -3
  107. package/src/modules/uploads/epics.test.ts +13 -12
  108. package/src/modules/uploads/index.test.ts +8 -7
  109. package/src/modules/uploads/index.ts +48 -47
  110. package/src/operators/checkTagName.test.ts +7 -6
  111. package/src/operators/checkTagName.ts +6 -5
  112. package/src/operators/debugThrottle.ts +4 -4
  113. package/src/plugin.tsx +18 -18
  114. package/src/schemas/tag.ts +7 -7
  115. package/src/styled/react-select/creatable.tsx +40 -39
  116. package/src/styled/react-select/single.tsx +39 -38
  117. package/src/types/index.ts +4 -3
  118. package/src/utils/applyMediaTags.ts +11 -10
  119. package/src/utils/blocksToText.test.ts +5 -4
  120. package/src/utils/blocksToText.ts +2 -2
  121. package/src/utils/constructFilter.test.ts +15 -14
  122. package/src/utils/constructFilter.ts +7 -7
  123. package/src/utils/generatePreviewBlobUrl.test.ts +6 -5
  124. package/src/utils/generatePreviewBlobUrl.ts +2 -2
  125. package/src/utils/getAssetResolution.test.ts +3 -2
  126. package/src/utils/getDocumentAssetIds.test.ts +7 -6
  127. package/src/utils/getDocumentAssetIds.ts +2 -2
  128. package/src/utils/getSchemeColor.test.ts +1 -0
  129. package/src/utils/getSchemeColor.ts +9 -9
  130. package/src/utils/getTagSelectOptions.test.ts +6 -5
  131. package/src/utils/getTagSelectOptions.ts +1 -1
  132. package/src/utils/getUniqueDocuments.test.ts +4 -3
  133. package/src/utils/getUniqueDocuments.ts +2 -2
  134. package/src/utils/imageDprUrl.test.ts +4 -3
  135. package/src/utils/imageDprUrl.ts +1 -1
  136. package/src/utils/isSupportedAssetType.test.ts +1 -0
  137. package/src/utils/mediaField.ts +4 -3
  138. package/src/utils/sanitizeFormData.test.ts +14 -13
  139. package/src/utils/typeGuards.test.ts +2 -1
  140. package/src/utils/uploadSanityAsset.test.ts +5 -4
  141. package/src/utils/uploadSanityAsset.ts +17 -16
  142. package/src/utils/withMaxConcurrency.test.ts +5 -4
  143. package/src/utils/withMaxConcurrency.ts +4 -4
  144. package/src/utils/zodFormResolver.ts +17 -0
  145. package/v2-incompatible.js +2 -2
@@ -1,16 +1,5 @@
1
1
  import {createSelector, createSlice, type PayloadAction} from '@reduxjs/toolkit'
2
2
  import type {ClientError, Patch, Transaction} from '@sanity/client'
3
- import type {
4
- Asset,
5
- AssetItem,
6
- AssetType,
7
- BrowserView,
8
- HttpError,
9
- MyEpic,
10
- Order,
11
- OrderDirection,
12
- Tag
13
- } from '../../types'
14
3
  import groq from 'groq'
15
4
  import {nanoid} from 'nanoid'
16
5
  import type {Selector} from 'react-redux'
@@ -23,11 +12,23 @@ import {
23
12
  filter,
24
13
  mergeMap,
25
14
  switchMap,
26
- withLatestFrom
15
+ withLatestFrom,
27
16
  } from 'rxjs/operators'
17
+
28
18
  import {getOrderTitle} from '../../config/orders'
29
19
  import {ORDER_OPTIONS} from '../../constants'
30
20
  import debugThrottle from '../../operators/debugThrottle'
21
+ import type {
22
+ Asset,
23
+ AssetItem,
24
+ AssetType,
25
+ BrowserView,
26
+ HttpError,
27
+ MyEpic,
28
+ Order,
29
+ OrderDirection,
30
+ Tag,
31
+ } from '../../types'
31
32
  import constructFilter from '../../utils/constructFilter'
32
33
  import {searchActions} from '../search'
33
34
  import type {RootReducerState} from '../types'
@@ -83,18 +84,18 @@ export const initialState = {
83
84
  order: {
84
85
  direction: defaultOrder.direction,
85
86
  field: defaultOrder.field,
86
- title: getOrderTitle(defaultOrder.field, defaultOrder.direction)
87
+ title: getOrderTitle(defaultOrder.field, defaultOrder.direction),
87
88
  },
88
89
  pageIndex: 0,
89
90
  pageSize: 100,
90
91
  // totalCount: -1,
91
- view: 'grid'
92
+ view: 'grid',
92
93
  } as AssetsReducerState
93
94
 
94
95
  const assetsSlice = createSlice({
95
96
  name: 'assets',
96
97
  initialState,
97
- extraReducers: builder => {
98
+ extraReducers: (builder) => {
98
99
  builder //
99
100
  .addCase(UPLOADS_ACTIONS.uploadComplete, (state, action) => {
100
101
  const {asset} = action.payload
@@ -103,42 +104,42 @@ const assetsSlice = createSlice({
103
104
  _type: 'asset',
104
105
  asset: asset as Asset,
105
106
  picked: false,
106
- updating: false
107
+ updating: false,
107
108
  }
108
109
  })
109
110
  .addCase(ASSETS_ACTIONS.tagsAddComplete, (state, action) => {
110
111
  const {assets} = action.payload
111
- assets.forEach(asset => {
112
+ assets.forEach((asset) => {
112
113
  state.byIds[asset.asset._id].updating = false
113
114
  })
114
115
  })
115
116
  .addCase(ASSETS_ACTIONS.tagsAddError, (state, action) => {
116
117
  const {assets} = action.payload
117
- assets.forEach(asset => {
118
+ assets.forEach((asset) => {
118
119
  state.byIds[asset.asset._id].updating = false
119
120
  })
120
121
  })
121
122
  .addCase(ASSETS_ACTIONS.tagsAddRequest, (state, action) => {
122
123
  const {assets} = action.payload
123
- assets.forEach(asset => {
124
+ assets.forEach((asset) => {
124
125
  state.byIds[asset.asset._id].updating = true
125
126
  })
126
127
  })
127
128
  .addCase(ASSETS_ACTIONS.tagsRemoveComplete, (state, action) => {
128
129
  const {assets} = action.payload
129
- assets.forEach(asset => {
130
+ assets.forEach((asset) => {
130
131
  state.byIds[asset.asset._id].updating = false
131
132
  })
132
133
  })
133
134
  .addCase(ASSETS_ACTIONS.tagsRemoveError, (state, action) => {
134
135
  const {assets} = action.payload
135
- assets.forEach(asset => {
136
+ assets.forEach((asset) => {
136
137
  state.byIds[asset.asset._id].updating = false
137
138
  })
138
139
  })
139
140
  .addCase(ASSETS_ACTIONS.tagsRemoveRequest, (state, action) => {
140
141
  const {assets} = action.payload
141
- assets.forEach(asset => {
142
+ assets.forEach((asset) => {
142
143
  state.byIds[asset.asset._id].updating = true
143
144
  })
144
145
  })
@@ -152,7 +153,7 @@ const assetsSlice = createSlice({
152
153
  deleteComplete(state, action: PayloadAction<{assetIds: string[]}>) {
153
154
  const {assetIds} = action.payload
154
155
 
155
- assetIds?.forEach(id => {
156
+ assetIds?.forEach((id) => {
156
157
  const deleteIndex = state.allIds.indexOf(id)
157
158
  if (deleteIndex >= 0) {
158
159
  state.allIds.splice(deleteIndex, 1)
@@ -165,23 +166,23 @@ const assetsSlice = createSlice({
165
166
  deleteError(state, action: PayloadAction<{assetIds: string[]; error: ClientError}>) {
166
167
  const {assetIds, error} = action.payload
167
168
  const itemErrors: ItemError[] = error?.response?.body?.error?.items?.map(
168
- (item: any) => item.error
169
+ (item: any) => item.error,
169
170
  )
170
171
 
171
- assetIds?.forEach(id => {
172
+ assetIds?.forEach((id) => {
172
173
  state.byIds[id].updating = false
173
174
  })
174
- itemErrors?.forEach(item => {
175
+ itemErrors?.forEach((item) => {
175
176
  state.byIds[item.id].error = item.description
176
177
  })
177
178
  },
178
179
  deleteRequest(state, action: PayloadAction<{assets: Asset[]; closeDialogId?: string}>) {
179
180
  const {assets} = action.payload
180
- assets.forEach(asset => {
181
+ assets.forEach((asset) => {
181
182
  state.byIds[asset?._id].updating = true
182
183
  })
183
184
 
184
- Object.keys(state.byIds).forEach(key => {
185
+ Object.keys(state.byIds).forEach((key) => {
185
186
  delete state.byIds[key].error
186
187
  })
187
188
  },
@@ -189,7 +190,7 @@ const assetsSlice = createSlice({
189
190
  const assets = action.payload?.assets || []
190
191
 
191
192
  if (assets) {
192
- assets.forEach(asset => {
193
+ assets.forEach((asset) => {
193
194
  if (!state.allIds.includes(asset._id)) {
194
195
  state.allIds.push(asset._id)
195
196
  }
@@ -197,7 +198,7 @@ const assetsSlice = createSlice({
197
198
  _type: 'asset',
198
199
  asset: asset,
199
200
  picked: false,
200
- updating: false
201
+ updating: false,
201
202
  }
202
203
  })
203
204
  }
@@ -220,7 +221,7 @@ const assetsSlice = createSlice({
220
221
  params = {},
221
222
  queryFilter,
222
223
  selector = ``,
223
- sort = groq`order(_updatedAt desc)`
224
+ sort = groq`order(_updatedAt desc)`,
224
225
  }: {
225
226
  params?: Record<string, any>
226
227
  queryFilter: string
@@ -265,7 +266,7 @@ const assetsSlice = createSlice({
265
266
  `
266
267
 
267
268
  return {payload: {params, query}}
268
- }
269
+ },
269
270
  },
270
271
  insertUploads(state, action: PayloadAction<{results: Record<string, string | null>}>) {
271
272
  const {results} = action.payload
@@ -281,7 +282,7 @@ const assetsSlice = createSlice({
281
282
  },
282
283
  listenerCreateQueueComplete(state, action: PayloadAction<{assets: Asset[]}>) {
283
284
  const {assets} = action.payload
284
- assets?.forEach(asset => {
285
+ assets?.forEach((asset) => {
285
286
  if (state.byIds[asset?._id]?.asset) {
286
287
  state.byIds[asset._id].asset = asset
287
288
  }
@@ -292,7 +293,7 @@ const assetsSlice = createSlice({
292
293
  },
293
294
  listenerDeleteQueueComplete(state, action: PayloadAction<{assetIds: string[]}>) {
294
295
  const {assetIds} = action.payload
295
- assetIds?.forEach(assetId => {
296
+ assetIds?.forEach((assetId) => {
296
297
  const deleteIndex = state.allIds.indexOf(assetId)
297
298
  if (deleteIndex >= 0) {
298
299
  state.allIds.splice(deleteIndex, 1)
@@ -305,7 +306,7 @@ const assetsSlice = createSlice({
305
306
  },
306
307
  listenerUpdateQueueComplete(state, action: PayloadAction<{assets: Asset[]}>) {
307
308
  const {assets} = action.payload
308
- assets?.forEach(asset => {
309
+ assets?.forEach((asset) => {
309
310
  if (state.byIds[asset?._id]?.asset) {
310
311
  state.byIds[asset._id].asset = asset
311
312
  }
@@ -329,24 +330,24 @@ const assetsSlice = createSlice({
329
330
  state.lastPicked = picked ? assetId : undefined
330
331
  },
331
332
  pickAll(state) {
332
- state.allIds.forEach(id => {
333
+ state.allIds.forEach((id) => {
333
334
  state.byIds[id].picked = true
334
335
  })
335
336
  },
336
337
  pickClear(state) {
337
338
  state.lastPicked = undefined
338
- Object.values(state.byIds).forEach(asset => {
339
+ Object.values(state.byIds).forEach((asset) => {
339
340
  state.byIds[asset.asset._id].picked = false
340
341
  })
341
342
  },
342
343
  pickRange(state, action: PayloadAction<{endId: string; startId: string}>) {
343
- const startIndex = state.allIds.findIndex(id => id === action.payload.startId)
344
- const endIndex = state.allIds.findIndex(id => id === action.payload.endId)
344
+ const startIndex = state.allIds.findIndex((id) => id === action.payload.startId)
345
+ const endIndex = state.allIds.findIndex((id) => id === action.payload.endId)
345
346
 
346
347
  // Sort numerically, ascending order
347
348
  const indices = [startIndex, endIndex].sort((a, b) => a - b)
348
349
 
349
- state.allIds.slice(indices[0], indices[1] + 1).forEach(key => {
350
+ state.allIds.slice(indices[0], indices[1] + 1).forEach((key) => {
350
351
  state.byIds[key].picked = true
351
352
  })
352
353
  state.lastPicked = state.allIds[endIndex]
@@ -378,15 +379,15 @@ const assetsSlice = createSlice({
378
379
  },
379
380
  updateRequest(
380
381
  state,
381
- action: PayloadAction<{asset: Asset; closeDialogId?: string; formData: Record<string, any>}>
382
+ action: PayloadAction<{asset: Asset; closeDialogId?: string; formData: Record<string, any>}>,
382
383
  ) {
383
384
  const assetId = action.payload?.asset?._id
384
385
  state.byIds[assetId].updating = true
385
386
  },
386
387
  viewSet(state, action: PayloadAction<{view: BrowserView}>) {
387
388
  state.view = action.payload?.view
388
- }
389
- }
389
+ },
390
+ },
390
391
  })
391
392
 
392
393
  // Epics
@@ -394,21 +395,21 @@ const assetsSlice = createSlice({
394
395
  export const assetsDeleteEpic: MyEpic = (action$, _state$, {client}) =>
395
396
  action$.pipe(
396
397
  filter(assetsActions.deleteRequest.match),
397
- mergeMap(action => {
398
+ mergeMap((action) => {
398
399
  const {assets} = action.payload
399
- const assetIds = assets.map(asset => asset._id)
400
+ const assetIds = assets.map((asset) => asset._id)
400
401
  return of(assets).pipe(
401
402
  mergeMap(() =>
402
403
  client.observable.delete({
403
- query: groq`*[_id in ${JSON.stringify(assetIds)}]`
404
- })
404
+ query: groq`*[_id in ${JSON.stringify(assetIds)}]`,
405
+ }),
405
406
  ),
406
407
  mergeMap(() => of(assetsActions.deleteComplete({assetIds}))),
407
408
  catchError((error: ClientError) => {
408
409
  return of(assetsActions.deleteError({assetIds, error}))
409
- })
410
+ }),
410
411
  )
411
- })
412
+ }),
412
413
  )
413
414
 
414
415
  export const assetsFetchEpic: MyEpic = (action$, state$, {client}) =>
@@ -424,11 +425,11 @@ export const assetsFetchEpic: MyEpic = (action$, state$, {client}) =>
424
425
  mergeMap(() =>
425
426
  client.observable.fetch<{
426
427
  items: Asset[]
427
- }>(query, params)
428
+ }>(query, params),
428
429
  ),
429
- mergeMap(result => {
430
+ mergeMap((result) => {
430
431
  const {
431
- items
432
+ items,
432
433
  // totalCount
433
434
  } = result
434
435
  return of(assetsActions.fetchComplete({assets: items}))
@@ -437,12 +438,12 @@ export const assetsFetchEpic: MyEpic = (action$, state$, {client}) =>
437
438
  of(
438
439
  assetsActions.fetchError({
439
440
  message: error?.message || 'Internal error',
440
- statusCode: error?.statusCode || 500
441
- })
442
- )
443
- )
441
+ statusCode: error?.statusCode || 500,
442
+ }),
443
+ ),
444
+ ),
444
445
  )
445
- })
446
+ }),
446
447
  )
447
448
 
448
449
  export const assetsFetchPageIndexEpic: MyEpic = (action$, state$) =>
@@ -461,12 +462,12 @@ export const assetsFetchPageIndexEpic: MyEpic = (action$, state$) =>
461
462
  const constructedFilter = constructFilter({
462
463
  assetTypes: state.assets.assetTypes,
463
464
  searchFacets: state.search.facets,
464
- searchQuery: state.search.query
465
+ searchQuery: state.search.query,
465
466
  })
466
467
 
467
468
  const params = {
468
469
  ...(documentId ? {documentId} : {}),
469
- documentAssetIds
470
+ documentAssetIds,
470
471
  }
471
472
 
472
473
  return of(
@@ -474,10 +475,10 @@ export const assetsFetchPageIndexEpic: MyEpic = (action$, state$) =>
474
475
  params,
475
476
  queryFilter: constructedFilter,
476
477
  selector: groq`[${start}...${end}]`,
477
- sort: groq`order(${state.assets?.order?.field} ${state.assets?.order?.direction})`
478
- })
478
+ sort: groq`order(${state.assets?.order?.field} ${state.assets?.order?.direction})`,
479
+ }),
479
480
  )
480
- })
481
+ }),
481
482
  )
482
483
 
483
484
  export const assetsFetchNextPageEpic: MyEpic = (action$, state$) =>
@@ -485,8 +486,8 @@ export const assetsFetchNextPageEpic: MyEpic = (action$, state$) =>
485
486
  filter(assetsActions.loadNextPage.match),
486
487
  withLatestFrom(state$),
487
488
  switchMap(([_action, state]) =>
488
- of(assetsActions.loadPageIndex({pageIndex: state.assets.pageIndex + 1}))
489
- )
489
+ of(assetsActions.loadPageIndex({pageIndex: state.assets.pageIndex + 1})),
490
+ ),
490
491
  )
491
492
 
492
493
  export const assetsFetchAfterDeleteAllEpic: MyEpic = (action$, state$) =>
@@ -500,11 +501,11 @@ export const assetsFetchAfterDeleteAllEpic: MyEpic = (action$, state$) =>
500
501
  }
501
502
 
502
503
  return EMPTY
503
- })
504
+ }),
504
505
  )
505
506
 
506
507
  const filterAssetWithoutTag = (tag: Tag) => (asset: AssetItem) => {
507
- const tagIndex = asset?.asset?.opt?.media?.tags?.findIndex(t => t._ref === tag?._id) ?? -1
508
+ const tagIndex = asset?.asset?.opt?.media?.tags?.findIndex((t) => t._ref === tag?._id) ?? -1
508
509
  return tagIndex < 0
509
510
  }
510
511
 
@@ -541,7 +542,7 @@ export const assetsRemoveTagsEpic: MyEpic = (action$, state$, {client}) => {
541
542
 
542
543
  const transaction: Transaction = pickedAssetsFiltered.reduce(
543
544
  (tx, pickedAsset) => tx.patch(pickedAsset?.asset?._id, patchOperationTagAppend({tag})),
544
- client.transaction()
545
+ client.transaction(),
545
546
  )
546
547
 
547
548
  return from(transaction.commit())
@@ -554,29 +555,29 @@ export const assetsRemoveTagsEpic: MyEpic = (action$, state$, {client}) => {
554
555
  assets,
555
556
  error: {
556
557
  message: error?.message || 'Internal error',
557
- statusCode: error?.statusCode || 500
558
+ statusCode: error?.statusCode || 500,
558
559
  },
559
- tag
560
- })
561
- )
562
- )
560
+ tag,
561
+ }),
562
+ ),
563
+ ),
563
564
  )
564
- })
565
+ }),
565
566
  )
566
567
  }
567
568
 
568
- export const assetsOrderSetEpic: MyEpic = action$ =>
569
+ export const assetsOrderSetEpic: MyEpic = (action$) =>
569
570
  action$.pipe(
570
571
  filter(assetsActions.orderSet.match),
571
572
  mergeMap(() => {
572
573
  return of(
573
574
  assetsActions.clear(), //
574
- assetsActions.loadPageIndex({pageIndex: 0})
575
+ assetsActions.loadPageIndex({pageIndex: 0}),
575
576
  )
576
- })
577
+ }),
577
578
  )
578
579
 
579
- export const assetsSearchEpic: MyEpic = action$ =>
580
+ export const assetsSearchEpic: MyEpic = (action$) =>
580
581
  action$.pipe(
581
582
  ofType(
582
583
  searchActions.facetsAdd.type,
@@ -586,59 +587,59 @@ export const assetsSearchEpic: MyEpic = action$ =>
586
587
  searchActions.facetsRemoveByTag.type,
587
588
  searchActions.facetsUpdate.type,
588
589
  searchActions.facetsUpdateById.type,
589
- searchActions.querySet.type
590
+ searchActions.querySet.type,
590
591
  ),
591
592
  debounceTime(400),
592
593
  mergeMap(() => {
593
594
  return of(
594
595
  assetsActions.clear(), //
595
- assetsActions.loadPageIndex({pageIndex: 0})
596
+ assetsActions.loadPageIndex({pageIndex: 0}),
596
597
  )
597
- })
598
+ }),
598
599
  )
599
600
 
600
- export const assetsListenerCreateQueueEpic: MyEpic = action$ =>
601
+ export const assetsListenerCreateQueueEpic: MyEpic = (action$) =>
601
602
  action$.pipe(
602
603
  filter(assetsActions.listenerCreateQueue.match),
603
604
  bufferTime(2000),
604
- filter(actions => actions.length > 0),
605
- mergeMap(actions => {
606
- const assets = actions?.map(action => action.payload.asset)
605
+ filter((actions) => actions.length > 0),
606
+ mergeMap((actions) => {
607
+ const assets = actions?.map((action) => action.payload.asset)
607
608
  return of(assetsActions.listenerCreateQueueComplete({assets}))
608
- })
609
+ }),
609
610
  )
610
611
 
611
- export const assetsListenerDeleteQueueEpic: MyEpic = action$ =>
612
+ export const assetsListenerDeleteQueueEpic: MyEpic = (action$) =>
612
613
  action$.pipe(
613
614
  filter(assetsActions.listenerDeleteQueue.match),
614
615
  bufferTime(2000),
615
- filter(actions => actions.length > 0),
616
- mergeMap(actions => {
617
- const assetIds = actions?.map(action => action.payload.assetId)
616
+ filter((actions) => actions.length > 0),
617
+ mergeMap((actions) => {
618
+ const assetIds = actions?.map((action) => action.payload.assetId)
618
619
  return of(assetsActions.listenerDeleteQueueComplete({assetIds}))
619
- })
620
+ }),
620
621
  )
621
622
 
622
- export const assetsListenerUpdateQueueEpic: MyEpic = action$ =>
623
+ export const assetsListenerUpdateQueueEpic: MyEpic = (action$) =>
623
624
  action$.pipe(
624
625
  filter(assetsActions.listenerUpdateQueue.match),
625
626
  bufferTime(2000),
626
- filter(actions => actions.length > 0),
627
- mergeMap(actions => {
628
- const assets = actions?.map(action => action.payload.asset)
627
+ filter((actions) => actions.length > 0),
628
+ mergeMap((actions) => {
629
+ const assets = actions?.map((action) => action.payload.asset)
629
630
  return of(assetsActions.listenerUpdateQueueComplete({assets}))
630
- })
631
+ }),
631
632
  )
632
633
 
633
634
  // Re-sort on all updates (immediate and batched listener events)
634
- export const assetsSortEpic: MyEpic = action$ =>
635
+ export const assetsSortEpic: MyEpic = (action$) =>
635
636
  action$.pipe(
636
637
  ofType(
637
638
  assetsActions.insertUploads.type,
638
639
  assetsActions.listenerUpdateQueueComplete.type,
639
- assetsActions.updateComplete.type
640
+ assetsActions.updateComplete.type,
640
641
  ),
641
- mergeMap(() => of(assetsActions.sort()))
642
+ mergeMap(() => of(assetsActions.sort())),
642
643
  )
643
644
 
644
645
  export const assetsTagsAddEpic: MyEpic = (action$, state$, {client}) => {
@@ -660,7 +661,7 @@ export const assetsTagsAddEpic: MyEpic = (action$, state$, {client}) => {
660
661
 
661
662
  const transaction: Transaction = pickedAssetsFiltered.reduce(
662
663
  (tx, pickedAsset) => tx.patch(pickedAsset?.asset?._id, patchOperationTagAppend({tag})),
663
- client.transaction()
664
+ client.transaction(),
664
665
  )
665
666
 
666
667
  return from(transaction.commit())
@@ -673,14 +674,14 @@ export const assetsTagsAddEpic: MyEpic = (action$, state$, {client}) => {
673
674
  assets,
674
675
  error: {
675
676
  message: error?.message || 'Internal error',
676
- statusCode: error?.statusCode || 500
677
+ statusCode: error?.statusCode || 500,
677
678
  },
678
- tag
679
- })
680
- )
681
- )
679
+ tag,
680
+ }),
681
+ ),
682
+ ),
682
683
  )
683
- })
684
+ }),
684
685
  )
685
686
  }
686
687
 
@@ -701,7 +702,7 @@ export const assetsTagsRemoveEpic: MyEpic = (action$, state$, {client}) => {
701
702
  const transaction: Transaction = pickedAssets.reduce(
702
703
  (tx, pickedAsset) =>
703
704
  tx.patch(pickedAsset?.asset?._id, patchOperationTagUnset({asset: pickedAsset, tag})),
704
- client.transaction()
705
+ client.transaction(),
705
706
  )
706
707
 
707
708
  return from(transaction.commit())
@@ -714,18 +715,18 @@ export const assetsTagsRemoveEpic: MyEpic = (action$, state$, {client}) => {
714
715
  assets,
715
716
  error: {
716
717
  message: error?.message || 'Internal error',
717
- statusCode: error?.statusCode || 500
718
+ statusCode: error?.statusCode || 500,
718
719
  },
719
- tag
720
- })
721
- )
722
- )
720
+ tag,
721
+ }),
722
+ ),
723
+ ),
723
724
  )
724
- })
725
+ }),
725
726
  )
726
727
  }
727
728
 
728
- export const assetsUnpickEpic: MyEpic = action$ =>
729
+ export const assetsUnpickEpic: MyEpic = (action$) =>
729
730
  action$.pipe(
730
731
  ofType(
731
732
  assetsActions.orderSet.type,
@@ -737,11 +738,11 @@ export const assetsUnpickEpic: MyEpic = action$ =>
737
738
  searchActions.facetsRemoveByTag.type,
738
739
  searchActions.facetsUpdate.type,
739
740
  searchActions.facetsUpdateById.type,
740
- searchActions.querySet.type
741
+ searchActions.querySet.type,
741
742
  ),
742
743
  mergeMap(() => {
743
744
  return of(assetsActions.pickClear())
744
- })
745
+ }),
745
746
  )
746
747
 
747
748
  export const assetsUpdateEpic: MyEpic = (action$, state$, {client}) =>
@@ -760,16 +761,16 @@ export const assetsUpdateEpic: MyEpic = (action$, state$, {client}) =>
760
761
  .setIfMissing({opt: {}})
761
762
  .setIfMissing({'opt.media': {}})
762
763
  .set(formData)
763
- .commit()
764
- )
764
+ .commit(),
765
+ ),
765
766
  ),
766
767
  mergeMap((updatedAsset: any) =>
767
768
  of(
768
769
  assetsActions.updateComplete({
769
770
  asset: updatedAsset,
770
- closeDialogId
771
- })
772
- )
771
+ closeDialogId,
772
+ }),
773
+ ),
773
774
  ),
774
775
  catchError((error: ClientError) =>
775
776
  of(
@@ -777,13 +778,13 @@ export const assetsUpdateEpic: MyEpic = (action$, state$, {client}) =>
777
778
  asset,
778
779
  error: {
779
780
  message: error?.message || 'Internal error',
780
- statusCode: error?.statusCode || 500
781
- }
782
- })
783
- )
784
- )
781
+ statusCode: error?.statusCode || 500,
782
+ },
783
+ }),
784
+ ),
785
+ ),
785
786
  )
786
- })
787
+ }),
787
788
  )
788
789
 
789
790
  // Selectors
@@ -795,28 +796,28 @@ const selectAssetsAllIds = (state: RootReducerState) => state.assets.allIds
795
796
  export const selectAssetById = createSelector(
796
797
  [
797
798
  (state: RootReducerState) => state.assets.byIds,
798
- (_state: RootReducerState, assetId: string) => assetId
799
+ (_state: RootReducerState, assetId: string) => assetId,
799
800
  ],
800
801
  (byIds, assetId) => {
801
802
  const asset = byIds[assetId]
802
803
  return asset ? asset : undefined
803
- }
804
+ },
804
805
  )
805
806
 
806
807
  export const selectAssets: Selector<RootReducerState, AssetItem[]> = createSelector(
807
808
  [selectAssetsByIds, selectAssetsAllIds],
808
- (byIds, allIds) => allIds.map(id => byIds[id])
809
+ (byIds, allIds) => allIds.map((id) => byIds[id]),
809
810
  )
810
811
 
811
- export const selectAssetsLength = createSelector([selectAssets], assets => assets.length)
812
+ export const selectAssetsLength = createSelector([selectAssets], (assets) => assets.length)
812
813
 
813
- export const selectAssetsPicked = createSelector([selectAssets], assets =>
814
- assets.filter(item => item?.picked)
814
+ export const selectAssetsPicked = createSelector([selectAssets], (assets) =>
815
+ assets.filter((item) => item?.picked),
815
816
  )
816
817
 
817
818
  export const selectAssetsPickedLength = createSelector(
818
819
  [selectAssetsPicked],
819
- assetsPicked => assetsPicked.length
820
+ (assetsPicked) => assetsPicked.length,
820
821
  )
821
822
 
822
823
  export const assetsActions = {...assetsSlice.actions}