@anzusystems/common-admin 2.0.0-rc.22 → 2.0.0-rc.23

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 (150) hide show
  1. package/dist/AnzuSystemsCommonAdmin.d.ts +2 -0
  2. package/dist/AnzuSystemsCommonAdmin.js.map +1 -1
  3. package/dist/common-admin.css +1 -1
  4. package/dist/common-admin.js +33 -29
  5. package/dist/domains/dam/api/damAssetApi.d.ts +12 -5
  6. package/dist/domains/dam/api/damAssetApi.js +66 -55
  7. package/dist/domains/dam/api/damAssetApi.js.map +1 -1
  8. package/dist/domains/dam/assetDetail/components/AssetDetailSidebarMetadata.vue_vue_type_script_setup_true_lang.js +1 -1
  9. package/dist/domains/dam/assetDetail/components/AssetDetailSidebarMetadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
  10. package/dist/domains/dam/assetDetail/components/AssetMetadata.vue_vue_type_script_setup_true_lang.js +100 -108
  11. package/dist/domains/dam/assetDetail/components/AssetMetadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/domains/dam/assetDetail/store/assetDetailStore.d.ts +2 -0
  13. package/dist/domains/dam/assetSelect/components/AAssetListInner.vue.d.ts +2 -0
  14. package/dist/domains/dam/assetSelect/components/AAssetSelect.vue.d.ts +1 -0
  15. package/dist/domains/dam/assetSelect/composables/assetSelectListActions.js +1 -1
  16. package/dist/domains/dam/assetSelect/composables/assetSelectListActions.js.map +1 -1
  17. package/dist/domains/dam/assetSelect/store/assetSelectStore.d.ts +112 -0
  18. package/dist/domains/dam/author/components/AuthorCreateButton.vue.d.ts +6 -0
  19. package/dist/domains/dam/author/components/AuthorCreateButton.vue_vue_type_script_setup_true_lang.js +13 -5
  20. package/dist/domains/dam/author/components/AuthorCreateButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.js +4 -2
  22. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.js.map +1 -1
  23. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.vue_vue_type_script_setup_true_lang.js +45 -39
  24. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.js +1 -1
  26. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue.d.ts +15 -2
  27. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js +118 -96
  28. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js.map +1 -1
  29. package/dist/domains/dam/author/components/DamAuthorFilterRemoteAutocomplete.vue.d.ts +3 -0
  30. package/dist/domains/dam/author/components/DamAuthorFilterRemoteAutocomplete.vue_vue_type_script_setup_true_lang.js +5 -1
  31. package/dist/domains/dam/author/components/DamAuthorFilterRemoteAutocomplete.vue_vue_type_script_setup_true_lang.js.map +1 -1
  32. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.js +8 -0
  33. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.js.map +1 -0
  34. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.vue.d.ts +67 -0
  35. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.vue_vue_type_script_setup_true_lang.js +144 -0
  36. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.vue_vue_type_script_setup_true_lang.js.map +1 -0
  37. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.js +8 -0
  38. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.js.map +1 -0
  39. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.vue.d.ts +27 -0
  40. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.vue_vue_type_script_setup_true_lang.js +47 -0
  41. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.vue_vue_type_script_setup_true_lang.js.map +1 -0
  42. package/dist/domains/dam/author/composables/authorActions.js +2 -1
  43. package/dist/domains/dam/author/composables/authorActions.js.map +1 -1
  44. package/dist/domains/dam/author/composables/authorFieldRouting.d.ts +15 -0
  45. package/dist/domains/dam/author/composables/authorFieldRouting.js +18 -0
  46. package/dist/domains/dam/author/composables/authorFieldRouting.js.map +1 -0
  47. package/dist/domains/dam/author/composables/authorValidation.js +1 -1
  48. package/dist/domains/dam/author/composables/authorValidation.js.map +1 -1
  49. package/dist/domains/dam/author/composables/cachedAuthors.js +4 -2
  50. package/dist/domains/dam/author/composables/cachedAuthors.js.map +1 -1
  51. package/dist/domains/dam/author/composables/damAuthorConfig.d.ts +5 -0
  52. package/dist/domains/dam/author/composables/damAuthorConfig.js +5 -2
  53. package/dist/domains/dam/author/composables/damAuthorConfig.js.map +1 -1
  54. package/dist/domains/dam/author/composables/damCredit.d.ts +35 -0
  55. package/dist/domains/dam/author/composables/damCredit.js +44 -0
  56. package/dist/domains/dam/author/composables/damCredit.js.map +1 -0
  57. package/dist/domains/dam/author/composables/damSourceConfig.d.ts +15 -0
  58. package/dist/domains/dam/author/composables/damSourceConfig.js +19 -0
  59. package/dist/domains/dam/author/composables/damSourceConfig.js.map +1 -0
  60. package/dist/domains/dam/author/factory/AuthorFactory.js +3 -1
  61. package/dist/domains/dam/author/factory/AuthorFactory.js.map +1 -1
  62. package/dist/domains/dam/author/filter/AuthorFilter.d.ts +38 -4
  63. package/dist/domains/dam/author/filter/AuthorFilter.js +20 -6
  64. package/dist/domains/dam/author/filter/AuthorFilter.js.map +1 -1
  65. package/dist/domains/dam/author/types/DamAuthor.d.ts +4 -0
  66. package/dist/domains/dam/composables/commonAdminCoreDamOptions.d.ts +1 -0
  67. package/dist/domains/dam/composables/commonAdminCoreDamOptions.js +1 -0
  68. package/dist/domains/dam/composables/commonAdminCoreDamOptions.js.map +1 -1
  69. package/dist/domains/dam/imageWidget/components/ImageDetailDialogMetadata.vue.d.ts +9 -1
  70. package/dist/domains/dam/imageWidget/components/ImageDetailDialogMetadata.vue_vue_type_script_setup_true_lang.js +206 -204
  71. package/dist/domains/dam/imageWidget/components/ImageDetailDialogMetadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
  72. package/dist/domains/dam/imageWidget/components/ImageMassOperations.vue_vue_type_script_setup_true_lang.js +165 -131
  73. package/dist/domains/dam/imageWidget/components/ImageMassOperations.vue_vue_type_script_setup_true_lang.js.map +1 -1
  74. package/dist/domains/dam/imageWidget/components/ImageMediaWidgetInner.vue_vue_type_script_setup_true_lang.js +344 -335
  75. package/dist/domains/dam/imageWidget/components/ImageMediaWidgetInner.vue_vue_type_script_setup_true_lang.js.map +1 -1
  76. package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue.d.ts +1 -0
  77. package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue_vue_type_script_setup_true_lang.js +251 -242
  78. package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue_vue_type_script_setup_true_lang.js.map +1 -1
  79. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue.d.ts +1 -0
  80. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue_vue_type_script_setup_true_lang.js +308 -303
  81. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue_vue_type_script_setup_true_lang.js.map +1 -1
  82. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue.d.ts +1 -0
  83. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue_vue_type_script_setup_true_lang.js +84 -87
  84. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
  85. package/dist/domains/dam/imageWidget/composables/imageDialogDamAuthors.d.ts +6 -3
  86. package/dist/domains/dam/imageWidget/composables/imageDialogDamAuthors.js +82 -77
  87. package/dist/domains/dam/imageWidget/composables/imageDialogDamAuthors.js.map +1 -1
  88. package/dist/domains/dam/imageWidget/composables/useImageMassOperations.d.ts +2 -0
  89. package/dist/domains/dam/imageWidget/composables/useImageMassOperations.js +59 -37
  90. package/dist/domains/dam/imageWidget/composables/useImageMassOperations.js.map +1 -1
  91. package/dist/domains/dam/imageWidget/store/imageStore.d.ts +2 -0
  92. package/dist/domains/dam/imageWidget/utils/metadataToImageMap.d.ts +3 -1
  93. package/dist/domains/dam/imageWidget/utils/metadataToImageMap.js +13 -22
  94. package/dist/domains/dam/imageWidget/utils/metadataToImageMap.js.map +1 -1
  95. package/dist/domains/dam/types/Asset.d.ts +1 -0
  96. package/dist/domains/dam/types/Asset.js.map +1 -1
  97. package/dist/domains/dam/types/DamConfig.d.ts +6 -0
  98. package/dist/domains/dam/types/DamConfig.js.map +1 -1
  99. package/dist/domains/dam/types/ImageAware.d.ts +1 -0
  100. package/dist/domains/dam/types/UploadQueue.d.ts +1 -0
  101. package/dist/domains/dam/types/UploadQueue.js.map +1 -1
  102. package/dist/domains/dam/uploadQueue/components/AssetQueueSelectedSidebar.vue_vue_type_script_setup_true_lang.js +204 -175
  103. package/dist/domains/dam/uploadQueue/components/AssetQueueSelectedSidebar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  104. package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue_vue_type_script_setup_true_lang.js +67 -65
  105. package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
  106. package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingle.vue_vue_type_script_setup_true_lang.js +71 -70
  107. package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingle.vue_vue_type_script_setup_true_lang.js.map +1 -1
  108. package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingleSidebarMetadataContent.vue_vue_type_script_setup_true_lang.js +83 -91
  109. package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingleSidebarMetadataContent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  110. package/dist/domains/dam/uploadQueue/components/UploadQueueEditable.vue_vue_type_script_setup_true_lang.js +4 -0
  111. package/dist/domains/dam/uploadQueue/components/UploadQueueEditable.vue_vue_type_script_setup_true_lang.js.map +1 -1
  112. package/dist/domains/dam/uploadQueue/components/UploadQueueItemEditable.vue.d.ts +10 -2
  113. package/dist/domains/dam/uploadQueue/components/UploadQueueItemEditable.vue_vue_type_script_setup_true_lang.js +178 -177
  114. package/dist/domains/dam/uploadQueue/components/UploadQueueItemEditable.vue_vue_type_script_setup_true_lang.js.map +1 -1
  115. package/dist/domains/dam/uploadQueue/components/uploadQueueBindings.d.ts +2 -0
  116. package/dist/domains/dam/uploadQueue/components/uploadQueueBindings.js +4 -3
  117. package/dist/domains/dam/uploadQueue/components/uploadQueueBindings.js.map +1 -1
  118. package/dist/domains/dam/uploadQueue/composables/uploadQueueMassOperations.d.ts +1 -0
  119. package/dist/domains/dam/uploadQueue/composables/uploadQueueMassOperations.js +11 -8
  120. package/dist/domains/dam/uploadQueue/composables/uploadQueueMassOperations.js.map +1 -1
  121. package/dist/domains/dam/uploadQueue/core/uploadQueueFill.d.ts +2 -0
  122. package/dist/domains/dam/uploadQueue/core/uploadQueueFill.js +4 -1
  123. package/dist/domains/dam/uploadQueue/core/uploadQueueFill.js.map +1 -1
  124. package/dist/domains/dam/uploadQueue/factory/UploadQueueItemFactory.js +1 -0
  125. package/dist/domains/dam/uploadQueue/factory/UploadQueueItemFactory.js.map +1 -1
  126. package/dist/domains/dam/uploadQueue/settlement/uploadSettle.js +4 -4
  127. package/dist/domains/dam/uploadQueue/settlement/uploadSettle.js.map +1 -1
  128. package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.d.ts +1 -0
  129. package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.js +7 -4
  130. package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.js.map +1 -1
  131. package/dist/domains/filters/datatable/components/ADatatableSidePanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
  132. package/dist/domains/filters/datatable/components/ALiveListingPill.vue_vue_type_script_setup_true_lang.js.map +1 -1
  133. package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue.d.ts +3 -0
  134. package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js +6 -2
  135. package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js.map +1 -1
  136. package/dist/lib.d.ts +5 -1
  137. package/dist/locales/cs/common/assetSelect.js +1 -1
  138. package/dist/locales/cs/common/damImage.js +84 -10
  139. package/dist/locales/cs/common/damImage.js.map +1 -1
  140. package/dist/locales/cs.d.ts +6 -0
  141. package/dist/locales/en/common/assetSelect.js +1 -1
  142. package/dist/locales/en/common/damImage.js +84 -10
  143. package/dist/locales/en/common/damImage.js.map +1 -1
  144. package/dist/locales/en.d.ts +6 -0
  145. package/dist/locales/sk/common/assetSelect.js +1 -1
  146. package/dist/locales/sk/common/damImage.js +84 -10
  147. package/dist/locales/sk/common/damImage.js.map +1 -1
  148. package/dist/locales/sk.d.ts +6 -0
  149. package/dist/plugins/i18n.d.ts +6 -0
  150. package/package.json +26 -26
@@ -1 +1 @@
1
- {"version":3,"file":"uploadSettle.js","names":["createUploadSettleMemory","isFinalFileStatus","status","AssetFileProcessStatus","resolveReadStatus","isNull","target","asset","intent","readStatus","clearRowError","AssetFileFailReasonDefault","isEmptyMetadataValue","isUndefined","value","isArray","mergeLoadedMetadata","useAssetSuggestions","row","customData","isObject","key","authorSuggestions","updateNewNames","queue","getAuthorConflicts","caches","decorateRow","mainFile","hadMetadata","role","UploadRowRole","markAsDuplicate","createUploadSettle","policyOf","profile","concerns","queueKey","purpose","byConfiguration","names","name","namedQueues","cachesOf","ids","fetchNames","queueKeys","rows","all","isStopped","UploadQueueItemStatus","isLive","raw","toRaw","item","isMarkedDuplicate","isDisposed","options","decorate","memory","revisionOf","bump","mark","isStale","startedAt","startRead","trackStateOf","untrack","state","setRefreshMayHelp","mayHelp","noticeOf","notice","dropNotice","showsOwnText","syncNotice","wants","text","clear","loadMetadata","settleProcessed","wasFailed","settleFailed","failReason","settleKnownFailed","entry","settleProcessedByEvent","announceProcessed","duplicateRows","eligible","policy","markDuplicates","marked","originFileId","assetType","file","error","becomeOriginals","DamAssetType","candidates","untouched","original","leftWithout","mightHelp","failsHere","settleDuplicate","targets","one","left","settleKnownDuplicate","tryLoadMetadata","applyAssetRead","duplicateSettled","maySettle","candidate","awaitsMetadata","withoutMetadata"],"sources":["../../../../../src/domains/dam/uploadQueue/settlement/uploadSettle.ts"],"sourcesContent":["import { toRaw } from 'vue'\nimport type { DocIdNullable } from '@/shared/types/common'\nimport { type AssetDetailItemDto, DamAssetType, type DamAssetTypeType } from '@/domains/dam/types/Asset'\nimport {\n type AssetFile,\n AssetFileFailReasonDefault,\n type AssetFileFailReasonType,\n type AssetFileNullable,\n AssetFileProcessStatus,\n type AssetFileProcessStatusType,\n} from '@/domains/dam/types/AssetFile'\nimport {\n type UploadQueue,\n type UploadQueueItem,\n UploadQueueItemStatus,\n type UploadQueueKey,\n} from '@/domains/dam/types/UploadQueue'\nimport { useAssetSuggestions } from '@/domains/dam/uploadQueue/composables/assetSuggestions'\nimport {\n UploadRowRole,\n type UploadRowRoleType,\n type UploadSettlementProfile,\n type UploadSettlementTarget,\n} from '@/domains/dam/uploadQueue/settlement/uploadSettlementTypes'\nimport { isArray, isNull, isObject, isUndefined } from '@/shared/utils/common'\n\nexport interface UploadTrackState {\n queueKey: UploadQueueKey\n /** When the row started waiting for the server, in scheduler time. */\n eligibleSince: number\n /** The client failed the row on its finish request. The server may still have finished the file. */\n clientFailed: boolean\n /** Consecutive successful reads that did not include the row's asset, or its file among the slots. */\n misses: number\n readFailures: number\n /**\n * A failed read or a missing asset was already reported, and no read has found the asset since.\n * Further failures are not reported.\n */\n reported: boolean\n}\n\nexport interface UploadRowNotice {\n /** The row has waited longer than processing should take. */\n slow: boolean\n readWarning: boolean\n /** Which of the two notices the settlement wrote into `row.error`. */\n shown: 'slow' | 'readWarning' | null\n /** The text written then. If the row's message differs now, the error belongs to someone else. */\n text: string | null\n}\n\n/** What a read should do for one target. */\nexport interface UploadReadIntent {\n /** State carried by the event. It applies when the read shows no final state. */\n hint: 'processed' | null\n /** When the row settles as processed, load its metadata as well. */\n metadata: boolean\n /** Set by the metadata notification. Metadata may arrive before the final state. */\n early: boolean\n /** The read tells a row with `settleOn: 'never'` that its file is processed. */\n seen: boolean\n}\n\n/** What the settlement remembers about rows. Every key is `toRaw(row)`. */\nexport interface UploadSettleMemory {\n tracked: WeakMap<UploadQueueItem, UploadTrackState>\n /** The last write an event made into the row. A read started before it is stale. Never cleared. */\n revision: WeakMap<UploadQueueItem, number>\n metadataLoaded: WeakSet<UploadQueueItem>\n /** Failed rows revived by an event. Their next read loads the metadata. */\n reviveWithMetadata: WeakSet<UploadQueueItem>\n /** Failed rows a refresh may still change: given up by the client, or left without their duplicate's original. */\n refreshMayHelp: WeakSet<UploadQueueItem>\n /** Rows failed because too many reads found no asset, while the server settles them by nothing else. */\n givenUpMissing: WeakSet<UploadQueueItem>\n notices: WeakMap<UploadQueueItem, UploadRowNotice>\n /** Shared counter for revisions and read starts. */\n clock: number\n}\n\nexport const createUploadSettleMemory = (): UploadSettleMemory => ({\n tracked: new WeakMap(),\n revision: new WeakMap(),\n metadataLoaded: new WeakSet(),\n reviveWithMetadata: new WeakSet(),\n refreshMayHelp: new WeakSet(),\n givenUpMissing: new WeakSet(),\n notices: new WeakMap(),\n clock: 0,\n})\n\nexport interface UploadSettleRow {\n queueKey: UploadQueueKey\n queue: UploadQueue\n row: UploadQueueItem\n}\n\nexport interface UploadSettleOptions {\n /** A row stopped being tracked, by a settlement write or by the store. */\n onUntrack?(queueKey: UploadQueueKey): void\n /** The settlement was disposed. Results of an original read that arrive later are not written. */\n isDisposed?(): boolean\n}\n\nexport const isFinalFileStatus = (\n status: AssetFileProcessStatusType | null | undefined\n): status is 'processed' | 'duplicate' | 'failed' =>\n status === AssetFileProcessStatus.Processed ||\n status === AssetFileProcessStatus.Duplicate ||\n status === AssetFileProcessStatus.Failed\n\n/**\n * The file state a read gives the target.\n * An asset reports only its main file state. A final state from the asset wins, otherwise the event state applies.\n * For another file (a slot) the asset says nothing, so only the event state applies.\n */\nexport const resolveReadStatus = (\n asset: AssetDetailItemDto,\n target: Pick<UploadSettlementTarget, 'fileId'>,\n intent: Pick<UploadReadIntent, 'hint'>\n): AssetFileProcessStatusType | undefined => {\n if (!isNull(target.fileId) && target.fileId !== asset.mainFile?.id) return intent.hint ?? undefined\n const readStatus = asset.mainFile?.fileAttributes?.status\n return isFinalFileStatus(readStatus) ? readStatus : (intent.hint ?? readStatus)\n}\n\nexport const clearRowError = (row: UploadQueueItem) => {\n row.error = { hasError: false, message: '', assetFileFailReason: AssetFileFailReasonDefault }\n}\n\n// \"Empty\" as the queue's mass operations define it.\nexport const isEmptyMetadataValue = (value: unknown) =>\n isUndefined(value) || isNull(value) || value === '' || (isArray(value) && !value.length)\n\n/**\n * First metadata load of a row. Values the user set earlier (via a queue mass operation) stay.\n * Only empty lists and empty custom fields are filled.\n */\nexport function mergeLoadedMetadata(\n queue: UploadQueue,\n row: UploadQueueItem,\n asset: AssetDetailItemDto,\n caches: Pick<UploadSettlementProfile['caches'], 'addAuthors' | 'addKeywords'>\n) {\n const { updateNewNames, getAuthorConflicts } = useAssetSuggestions()\n if (isEmptyMetadataValue(row.keywords)) row.keywords = [...(asset.keywords ?? [])]\n if (isEmptyMetadataValue(row.authors)) row.authors = [...(asset.authors ?? [])]\n const customData: Record<string, unknown> = isObject(asset.metadata.customData)\n ? { ...asset.metadata.customData }\n : {}\n if (isObject(row.customData)) {\n for (const [key, value] of Object.entries(row.customData)) {\n if (!isEmptyMetadataValue(value)) customData[key] = value\n }\n }\n row.customData = customData\n // Not mass-operation fields. These come from the server.\n row.mainFileSingleUse = asset.mainFileSingleUse\n row.mainFileInternal = asset.mainFileInternal\n const authorSuggestions = asset.metadata.authorSuggestions ?? {}\n updateNewNames(authorSuggestions, queue.suggestions.newAuthorNames)\n updateNewNames(asset.metadata.keywordSuggestions ?? {}, queue.suggestions.newKeywordNames)\n row.authorConflicts = getAuthorConflicts(authorSuggestions)\n caches.addKeywords(row.keywords)\n caches.addAuthors(row.authors)\n caches.addAuthors(row.authorConflicts)\n}\n\n/**\n * Applies a read asset to a row without changing its state.\n * `hadMetadata`: the row's metadata was loaded once, whether or not the form is shown now.\n */\nexport function decorateRow(\n row: UploadQueueItem,\n asset: AssetDetailItemDto,\n mainFile: AssetFile,\n role: UploadRowRoleType,\n hadMetadata: boolean\n) {\n row.assetStatus = asset.attributes.assetStatus\n // Only for the main-file row. A slot row would get a preview of another file.\n if (!isNull(row.fileId) && row.fileId !== mainFile.id) return\n if (mainFile.links?.image_detail) row.imagePreview = mainFile.links.image_detail\n // Skip mass-edit rows and rows that have or had metadata. There these switches are form fields the user may have set.\n // This includes a row that lost its form on failure and gets it back.\n if (!row.canEditMetadata && !hadMetadata && role !== UploadRowRole.MassEdit) {\n row.mainFileSingleUse = asset.mainFileSingleUse\n row.mainFileInternal = asset.mainFileInternal\n }\n}\n\n// Both duplicate policies mark the row through here.\nconst markAsDuplicate = (row: UploadQueueItem) => {\n row.isDuplicate = true\n // Set once, before anything can overwrite `assetId` with the original.\n row.uploadedAssetId ??= row.assetId\n}\n\n/**\n * Settlement writes: a read asset or a known state into queue rows.\n * No timers and no reads of its own, except reading a duplicate's original.\n */\nexport function createUploadSettle(\n profile: UploadSettlementProfile,\n memory: UploadSettleMemory = createUploadSettleMemory(),\n options: UploadSettleOptions = {}\n) {\n const policyOf = (row: UploadQueueItem) => profile.policyFor(profile.roleOf(row))\n\n /**\n * Whether the target concerns a row of queue `queueKey`, by the profile's `matches`.\n * When the profile provides `configOf`, only queues of a configuration the target names match.\n */\n const concerns = (\n queueKey: UploadQueueKey,\n row: UploadQueueItem,\n target: UploadSettlementTarget,\n purpose: 'settle' | 'decorate' | 'metadata'\n ) =>\n (!profile.configOf || !target.configNames?.length || target.configNames.includes(profile.configOf(queueKey))) &&\n profile.matches(row, target, purpose)\n\n /**\n * Splits the target per named configuration when it names several and the profile provides `configOf`.\n * Each copy is read separately, by a queue of that configuration, and written only into its rows.\n * Otherwise returns the target itself.\n */\n const byConfiguration = (target: UploadSettlementTarget): UploadSettlementTarget[] => {\n const names = profile.configOf ? [...new Set(target.configNames ?? [])] : []\n return names.length > 1 ? names.map((name) => ({ ...target, configNames: [name] })) : [target]\n }\n\n // Queues whose rows got names since the caches last fetched.\n const namedQueues = new Set<UploadQueueKey>()\n /** Where the row names go. A profile with `configOf` is given the queue key, one without is not. */\n const cachesOf = (\n queueKey: UploadQueueKey\n ): Pick<UploadSettlementProfile['caches'], 'addAuthors' | 'addKeywords'> => {\n namedQueues.add(queueKey)\n if (!profile.configOf) {\n return {\n addAuthors: (ids) => profile.caches.addAuthors(ids),\n addKeywords: (ids) => profile.caches.addKeywords(ids),\n }\n }\n return {\n addAuthors: (ids) => profile.caches.addAuthors(ids, queueKey),\n addKeywords: (ids) => profile.caches.addKeywords(ids, queueKey),\n }\n }\n /** Fetches caches for each queue that got names, or once without a queue for a profile without `configOf`. */\n const fetchNames = () => {\n const queueKeys = [...namedQueues]\n namedQueues.clear()\n if (!profile.configOf) {\n profile.caches.fetchAuthors()\n profile.caches.fetchKeywords()\n return\n }\n for (const queueKey of queueKeys) {\n profile.caches.fetchAuthors(queueKey)\n profile.caches.fetchKeywords(queueKey)\n }\n }\n\n /** All queue rows at this moment. */\n const rows = (): UploadSettleRow[] => {\n const all: UploadSettleRow[] = []\n for (const [queueKey, queue] of profile.queues()) {\n for (const row of queue.items) all.push({ queueKey, queue, row })\n }\n return all\n }\n\n // Nothing writes into a stopped row. Check again after every await: the row may have been stopped meanwhile.\n const isStopped = (row: UploadQueueItem) => row.status === UploadQueueItemStatus.Stop\n\n const isLive = (row: UploadQueueItem) => {\n const raw = toRaw(row)\n for (const [, queue] of profile.queues()) {\n if (toRaw(queue.items).some((item) => toRaw(item) === raw)) return true\n }\n return false\n }\n\n // A row marked as a duplicate is settled and read-only.\n // A row that became its original is a normal editable row.\n const isMarkedDuplicate = (row: UploadQueueItem) => row.isDuplicate && policyOf(row).duplicate === 'markDuplicate'\n const isDisposed = () => options.isDisposed?.() === true\n\n const decorate = (row: UploadQueueItem, asset: AssetDetailItemDto, mainFile: AssetFile) =>\n decorateRow(row, asset, mainFile, profile.roleOf(row), memory.metadataLoaded.has(toRaw(row)))\n\n const revisionOf = (row: UploadQueueItem) => memory.revision.get(toRaw(row)) ?? 0\n /** An event wrote into the row. Reads started before this are stale for it. */\n const bump = (row: UploadQueueItem) => {\n const mark = ++memory.clock\n memory.revision.set(toRaw(row), mark)\n return mark\n }\n const isStale = (row: UploadQueueItem, startedAt: number) => startedAt <= revisionOf(row)\n /** Mark of a read starting now. */\n const startRead = () => ++memory.clock\n\n const trackStateOf = (row: UploadQueueItem) => memory.tracked.get(toRaw(row))\n const untrack = (row: UploadQueueItem) => {\n const raw = toRaw(row)\n const state = memory.tracked.get(raw)\n if (!state) return\n memory.tracked.delete(raw)\n options.onUntrack?.(state.queueKey)\n }\n\n /** Whether a refresh may still change a failed row. The store is notified on change. */\n const setRefreshMayHelp = (queueKey: UploadQueueKey, row: UploadQueueItem, mayHelp: boolean) => {\n const raw = toRaw(row)\n if (memory.refreshMayHelp.has(raw) === mayHelp) return\n if (mayHelp) memory.refreshMayHelp.add(raw)\n else memory.refreshMayHelp.delete(raw)\n profile.hooks.onRefreshMayHelp?.(queueKey, row, mayHelp)\n }\n\n const noticeOf = (row: UploadQueueItem) => {\n const raw = toRaw(row)\n let notice = memory.notices.get(raw)\n if (!notice) {\n notice = { slow: false, readWarning: false, shown: null, text: null }\n memory.notices.set(raw, notice)\n }\n return notice\n }\n const dropNotice = (row: UploadQueueItem) => memory.notices.delete(toRaw(row))\n // Whether the row message is still the text the settlement wrote.\n // The store also writes `row.error` (failed upload), and the settlement must not clear that error.\n const showsOwnText = (row: UploadQueueItem) => {\n const notice = memory.notices.get(toRaw(row))\n return !!notice?.shown && row.error.message === notice.text\n }\n\n /**\n * Writes the applicable settlement text into `row.error`, or removes its own text.\n * Only its own text, and only while the row still shows it.\n * `clear` also removes an error the settlement did not write, because the row settled as processed.\n */\n const syncNotice = (row: UploadQueueItem, { clear = false }: { clear?: boolean } = {}) => {\n const notice = noticeOf(row)\n let wants: UploadRowNotice['shown'] = null\n if (\n notice.readWarning &&\n policyOf(row).metadata === 'load' &&\n !row.canEditMetadata &&\n !isMarkedDuplicate(row) &&\n row.status !== UploadQueueItemStatus.Failed\n ) {\n wants = 'readWarning'\n } else if (notice.slow && row.status === UploadQueueItemStatus.Processing) {\n wants = 'slow'\n }\n if (wants) {\n const text = wants === 'slow' ? profile.messages.processingTooLong(row) : profile.messages.readFailed(row)\n row.error.hasError = true\n row.error.message = text\n notice.shown = wants\n notice.text = text\n return\n }\n if (clear) {\n clearRowError(row)\n } else if (showsOwnText(row)) {\n // Remove the text. Also clear the flag, unless the row has failed since. Then the flag belongs to the failure.\n if (row.status === UploadQueueItemStatus.Failed) row.error = { ...row.error, message: '' }\n else clearRowError(row)\n }\n notice.shown = null\n notice.text = null\n }\n\n const loadMetadata = (\n { queueKey, queue, row }: Pick<UploadSettleRow, 'queueKey' | 'queue' | 'row'>,\n asset: AssetDetailItemDto\n ) => {\n mergeLoadedMetadata(queue, row, asset, cachesOf(queueKey))\n memory.metadataLoaded.add(toRaw(row))\n }\n\n const settleProcessed = (\n { queueKey, queue, row }: UploadSettleRow,\n asset: AssetDetailItemDto,\n mainFile: AssetFile,\n intent: UploadReadIntent\n ) => {\n const raw = toRaw(row)\n // The client marks an upload failed when one of its requests fails, but the server may still finish it.\n // Such a row lost its form on failure and gets it back here, with its metadata.\n const wasFailed = row.status === UploadQueueItemStatus.Failed || memory.reviveWithMetadata.has(raw)\n row.status = UploadQueueItemStatus.Uploaded\n // A licence copy knows only its asset. The image is built from the file id.\n if (isNull(row.fileId)) row.fileId = mainFile.id\n decorate(row, asset, mainFile)\n const notice = noticeOf(row)\n if (policyOf(row).metadata === 'load' && !isMarkedDuplicate(row) && (intent.metadata || wasFailed)) {\n // Loaded once, and never into a row with the form shown, so user input is kept.\n if (!row.canEditMetadata && !memory.metadataLoaded.has(raw)) loadMetadata({ queueKey, queue, row }, asset)\n row.canEditMetadata = true\n notice.readWarning = false\n profile.hooks.afterMetadataLoaded?.(queueKey, row)\n }\n memory.reviveWithMetadata.delete(raw)\n memory.givenUpMissing.delete(raw)\n notice.slow = false\n syncNotice(row, { clear: true })\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n\n const settleFailed = (\n { queueKey, row }: Pick<UploadSettleRow, 'queueKey' | 'row'>,\n failReason: AssetFileFailReasonType\n ) => {\n row.status = UploadQueueItemStatus.Failed\n // Drop the old text. The row shows a message for the reason, and the old text is not the cause.\n row.error = { hasError: true, message: '', assetFileFailReason: failReason }\n row.canEditMetadata = false\n dropNotice(row)\n memory.reviveWithMetadata.delete(toRaw(row))\n memory.givenUpMissing.delete(toRaw(row))\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n\n /** A failure known by the caller, without a read. */\n const settleKnownFailed = (target: UploadSettlementTarget, failReason: AssetFileFailReasonType) => {\n for (const entry of rows()) {\n if (entry.row.status === UploadQueueItemStatus.Stop || !concerns(entry.queueKey, entry.row, target, 'settle')) {\n continue\n }\n settleFailed(entry, failReason)\n bump(entry.row)\n }\n }\n\n /**\n * Applies a `processed` event immediately to rows that settle on the event.\n * A tick also uses it for a slot row whose file the slot list shows processed.\n */\n const settleProcessedByEvent = (target: UploadSettlementTarget) => {\n for (const { queueKey, row } of rows()) {\n if (row.status === UploadQueueItemStatus.Stop || policyOf(row).settleOn !== 'event') continue\n if (!concerns(queueKey, row, target, 'settle')) continue\n const raw = toRaw(row)\n if (row.status === UploadQueueItemStatus.Failed) memory.reviveWithMetadata.add(raw)\n memory.givenUpMissing.delete(raw)\n row.status = UploadQueueItemStatus.Uploaded\n // A row the client gave up on that already had metadata gets its form back as the user left it.\n if (!isMarkedDuplicate(row) && memory.metadataLoaded.has(raw)) row.canEditMetadata = true\n noticeOf(row).slow = false\n syncNotice(row, { clear: true })\n bump(row)\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n }\n\n /** Handles a `processed` event for rows whose state it does not change. */\n const announceProcessed = (target: UploadSettlementTarget) => {\n for (const { queueKey, row } of rows()) {\n if (row.status === UploadQueueItemStatus.Stop || policyOf(row).settleOn !== 'never') continue\n if (concerns(queueKey, row, target, 'decorate')) profile.hooks.onProcessedSeen?.(queueKey, row)\n }\n }\n\n const duplicateRows = (\n target: UploadSettlementTarget,\n policy: 'becomeOriginal' | 'markDuplicate',\n eligible: (row: UploadQueueItem) => boolean\n ) =>\n rows().filter(\n ({ queueKey, row }) =>\n row.status !== UploadQueueItemStatus.Stop &&\n eligible(row) &&\n policyOf(row).duplicate === policy &&\n concerns(queueKey, row, target, 'settle')\n )\n\n // The row stays and is marked. It is settled first and completed from the original file later.\n // This way the wait for that file does not hold an upload slot.\n const markDuplicates = async (\n target: UploadSettlementTarget,\n originFileId: DocIdNullable,\n assetType: DamAssetTypeType | null,\n eligible: (row: UploadQueueItem) => boolean\n ) => {\n const marked: Array<{ row: UploadQueueItem; mark: number }> = []\n for (const { queueKey, row } of duplicateRows(target, 'markDuplicate', eligible)) {\n markAsDuplicate(row)\n row.status = UploadQueueItemStatus.Uploaded\n row.canEditMetadata = false\n clearRowError(row)\n dropNotice(row)\n memory.reviveWithMetadata.delete(toRaw(row))\n memory.givenUpMissing.delete(toRaw(row))\n marked.push({ row, mark: bump(row) })\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n if (!marked.length || !originFileId || !assetType || !profile.readers.duplicateOriginFile) return\n let file: AssetFileNullable = null\n try {\n file = await profile.readers.duplicateOriginFile(originFileId, assetType)\n } catch (error) {\n console.error('uploadQueue: the duplicated file could not be read', error)\n }\n if (!file || isDisposed()) return\n for (const { row, mark } of marked) {\n // Only rows still present and not written into meanwhile.\n if (!isLive(row) || row.status === UploadQueueItemStatus.Stop || !row.isDuplicate) continue\n if (revisionOf(row) !== mark) continue\n row.fileId = file.id\n row.duplicateAssetId = file.asset\n row.mainFileSingleUse = file.flags.singleUse\n if (file.links?.image_detail) row.imagePreview = file.links.image_detail\n }\n }\n\n // The row becomes the original: its asset and file are replaced and it takes the original's metadata.\n // Returns whether the original could not be read and a row remains that a refresh may still help.\n const becomeOriginals = async (\n target: UploadSettlementTarget,\n originFileId: DocIdNullable,\n assetType: DamAssetTypeType | null,\n eligible: (row: UploadQueueItem) => boolean\n ): Promise<boolean> => {\n if (!originFileId || assetType !== DamAssetType.Image) return false\n // Recorded before requesting the original. After the await, only rows still in\n // their queue, not stopped and not written by an event meanwhile are written.\n // The caller that reports a duplicate is outside the read\n // ordering, so an earlier answer must not undo a later event.\n const candidates = duplicateRows(target, 'becomeOriginal', eligible).map((entry) => ({\n ...entry,\n mark: revisionOf(entry.row),\n }))\n if (!candidates.length) return false\n const untouched = () =>\n candidates.filter(({ row, mark }) => isLive(row) && !isStopped(row) && revisionOf(row) === mark)\n const { updateNewNames, getAuthorConflicts } = useAssetSuggestions()\n let original: AssetDetailItemDto\n try {\n if (!profile.readers.duplicateOriginAsset) throw new Error('uploadSettlement: no reader of the original asset')\n original = await profile.readers.duplicateOriginAsset(originFileId, { queueKey: candidates[0]!.queueKey })\n } catch {\n if (isDisposed()) return false\n let leftWithout = false\n for (const { queueKey, row } of untouched()) {\n // Read before untracking, so a row the client gave up on keeps its way back.\n const mightHelp = memory.refreshMayHelp.has(toRaw(row))\n // Untrack regardless of state. The next tick would only retry the same read.\n untrack(row)\n // Only a row still waiting for this answer fails: a settled one must not be flipped back to failed.\n const failsHere = row.status === UploadQueueItemStatus.Processing\n if (failsHere) {\n row.status = UploadQueueItemStatus.Failed\n // Drop a text the settlement wrote. It no longer describes what is wrong with the row.\n row.error = { ...row.error, hasError: true, message: showsOwnText(row) ? '' : row.error.message }\n row.canEditMetadata = false\n dropNotice(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n // Failed because a read failed, not the file. A row refresh requests the original again.\n // Not for a row the server had already failed, which no refresh can undo.\n if (failsHere || mightHelp) {\n setRefreshMayHelp(queueKey, row, true)\n leftWithout = true\n }\n }\n return leftWithout\n }\n if (isDisposed()) return false\n for (const { queueKey, queue, row } of untouched()) {\n const authorSuggestions = original.metadata.authorSuggestions ?? {}\n markAsDuplicate(row)\n row.status = UploadQueueItemStatus.Uploaded\n clearRowError(row)\n row.fileId = originFileId\n row.duplicateAssetId = original.id\n row.assetStatus = original.attributes.assetStatus\n if (original.mainFile?.links?.image_detail) row.imagePreview = original.mainFile.links.image_detail\n row.keywords = [...(original.keywords ?? [])]\n row.authors = [...(original.authors ?? [])]\n row.customData = isObject(original.metadata.customData) ? { ...original.metadata.customData } : {}\n updateNewNames(authorSuggestions, queue.suggestions.newAuthorNames)\n updateNewNames(original.metadata.keywordSuggestions ?? {}, queue.suggestions.newKeywordNames)\n row.authorConflicts = getAuthorConflicts(authorSuggestions)\n const caches = cachesOf(queueKey)\n caches.addKeywords(row.keywords)\n caches.addAuthors(row.authors)\n caches.addAuthors(row.authorConflicts)\n row.assetId = original.id\n row.mainFileSingleUse = original.mainFileSingleUse\n row.mainFileInternal = original.mainFileInternal\n memory.metadataLoaded.add(toRaw(row))\n row.canEditMetadata = true\n dropNotice(row)\n memory.reviveWithMetadata.delete(toRaw(row))\n memory.givenUpMissing.delete(toRaw(row))\n bump(row)\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n fetchNames()\n return false\n }\n\n /**\n * Handles a duplicate file for every row passing `matches(…, 'settle')`, by the policy of its role.\n * `eligible` excludes rows the read is stale for.\n * Returns whether a row is left without its duplicate's original\n * because it could not be read. A refresh may still help it.\n */\n const settleDuplicate = async (\n target: UploadSettlementTarget,\n originFileId: DocIdNullable,\n assetType: DamAssetTypeType | null,\n eligible: (row: UploadQueueItem) => boolean = () => true\n ) => {\n // Both start at once, not one after the other, so each records its rows now.\n // The original is read once per configuration the target names, by a queue of that configuration.\n const targets = byConfiguration(target)\n const [, leftWithout] = await Promise.all([\n markDuplicates(target, originFileId, assetType, eligible),\n targets.length === 1\n ? becomeOriginals(target, originFileId, assetType, eligible)\n : Promise.all(targets.map((one) => becomeOriginals(one, originFileId, assetType, eligible))).then((left) =>\n left.some(Boolean)\n ),\n ])\n return leftWithout\n }\n\n /** A duplicate known by the caller, without reading its asset. Never rejects. */\n const settleKnownDuplicate = async (\n target: UploadSettlementTarget,\n originFileId: DocIdNullable,\n assetType: DamAssetTypeType | null\n ) => {\n try {\n await settleDuplicate(target, originFileId, assetType)\n } catch (error) {\n console.error('uploadQueue: the duplicate could not be settled', error)\n }\n }\n\n /** Metadata notification: loads the metadata and the form, regardless of the file state. */\n const tryLoadMetadata = ({ queueKey, queue, row }: UploadSettleRow, asset: AssetDetailItemDto) => {\n if (policyOf(row).metadata !== 'load' || row.canEditMetadata) return\n // A marked duplicate is settled and has no metadata of its own to load.\n if (isMarkedDuplicate(row)) return\n // Skip a row whose file failed, except one that failed for lack of this metadata.\n if (row.status === UploadQueueItemStatus.Failed && profile.metadataGate?.(queueKey, row) !== 'load') return\n if (!memory.metadataLoaded.has(toRaw(row))) loadMetadata({ queueKey, queue, row }, asset)\n row.canEditMetadata = true\n noticeOf(row).readWarning = false\n syncNotice(row)\n profile.hooks.afterMetadataLoaded?.(queueKey, row)\n }\n\n /**\n * Applies one read asset to every row it concerns. `startedAt` is the read mark.\n * A row written by an event since keeps the event's state.\n * Returns like `settleDuplicate`: whether a row is left without its duplicate's original.\n */\n const applyAssetRead = async (\n asset: AssetDetailItemDto,\n target: UploadSettlementTarget,\n intent: UploadReadIntent,\n startedAt: number\n ) => {\n const mainFile = asset.mainFile ?? null\n const status = resolveReadStatus(asset, target, intent)\n let duplicateSettled = false\n let leftWithout = false\n for (const entry of rows()) {\n const { queueKey, row } = entry\n // The duplicate's original read was awaited. The row may have left its queue meanwhile.\n if (duplicateSettled && !isLive(row)) continue\n if (isStopped(row)) continue\n\n // Apply the file state and row details unless an event wrote\n // into the row after this read started. The event is newer.\n if (!isStale(row, startedAt) && mainFile && concerns(queueKey, row, target, 'decorate')) {\n const maySettle = concerns(queueKey, row, target, 'settle')\n if (status === AssetFileProcessStatus.Processed) {\n if (policyOf(row).settleOn === 'never') {\n decorate(row, asset, mainFile)\n if (intent.seen) profile.hooks.onProcessedSeen?.(queueKey, row)\n } else if (maySettle) {\n settleProcessed(entry, asset, mainFile, intent)\n }\n } else if (status === AssetFileProcessStatus.Duplicate && maySettle) {\n // Once for all rows of the target. The original is read only once.\n if (!duplicateSettled) {\n duplicateSettled = true\n leftWithout = await settleDuplicate(\n target,\n mainFile.originAssetFile,\n asset.attributes.assetType,\n (candidate) => !isStale(candidate, startedAt)\n )\n if (isDisposed()) return leftWithout\n if (!isLive(row) || isStopped(row)) continue\n }\n } else if (status === AssetFileProcessStatus.Failed && maySettle) {\n settleFailed(entry, mainFile.fileAttributes.failReason)\n }\n }\n\n // Applied to such a row as well, because metadata is not file state. It loads once, whenever it arrives.\n // Rows the event failed or marked as duplicate are refused there.\n // Otherwise a `processed` event that overtakes the metadata read would leave the row uploaded without its form.\n if (intent.early && concerns(queueKey, row, target, 'metadata')) tryLoadMetadata(entry, asset)\n }\n profile.hooks.onAssetRead?.(asset)\n return leftWithout\n }\n\n /**\n * An uploaded row without its metadata, which a refresh would load.\n * It is no longer tracked, but reads that find no asset are still counted for it.\n */\n const awaitsMetadata = (row: UploadQueueItem) =>\n row.status === UploadQueueItemStatus.Uploaded &&\n !row.canEditMetadata &&\n policyOf(row).metadata === 'load' &&\n !isMarkedDuplicate(row)\n\n /**\n * The row's asset was missing from enough reads, for a tracked row or one a refresh may still help.\n * A processing row fails. An uploaded row without metadata fails with `assetGone`.\n * Any other row (given up by the client, or left without its duplicate's original) is left alone.\n */\n const giveUpOnMissing = ({ queueKey, row }: Pick<UploadSettleRow, 'queueKey' | 'row'>) => {\n // There is no asset a refresh could read.\n setRefreshMayHelp(queueKey, row, false)\n const withoutMetadata = awaitsMetadata(row)\n if (row.status !== UploadQueueItemStatus.Processing && !withoutMetadata) {\n untrack(row)\n return\n }\n row.status = UploadQueueItemStatus.Failed\n row.error.hasError = true\n row.error.message = withoutMetadata\n ? (profile.messages.assetGone?.(row) ?? profile.messages.assetMissing(row))\n : profile.messages.assetMissing(row)\n row.canEditMetadata = false\n memory.givenUpMissing.add(toRaw(row))\n dropNotice(row)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n\n return {\n memory,\n policyOf,\n concerns,\n byConfiguration,\n fetchNames,\n rows,\n isLive,\n bump,\n isStale,\n startRead,\n trackStateOf,\n untrack,\n setRefreshMayHelp,\n noticeOf,\n syncNotice,\n applyAssetRead,\n settleProcessedByEvent,\n announceProcessed,\n settleFailed,\n settleKnownFailed,\n settleDuplicate,\n settleKnownDuplicate,\n awaitsMetadata,\n giveUpOnMissing,\n }\n}\n\nexport type UploadSettle = ReturnType<typeof createUploadSettle>\n"],"mappings":";;;;;;;;AAiFA,IAAaA,WAAsD;CACjE,yBAAS,IAAI,QAAQ;CACrB,0BAAU,IAAI,QAAQ;CACtB,gCAAgB,IAAI,QAAQ;CAC5B,oCAAoB,IAAI,QAAQ;CAChC,gCAAgB,IAAI,QAAQ;CAC5B,gCAAgB,IAAI,QAAQ;CAC5B,yBAAS,IAAI,QAAQ;CACrB,OAAO;AACT,IAeaC,KACX,MAEAC,MAAWC,EAAuB,aAClCD,MAAWC,EAAuB,aAClCD,MAAWC,EAAuB,QAOvBC,KACX,GACA,GACA,MAC2C;CAC3C,IAAI,CAACC,EAAOC,EAAO,MAAM,KAAKA,EAAO,WAAWC,EAAM,UAAU,IAAI,OAAOC,EAAO,QAAQ,KAAA;CAC1F,IAAMC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CAACwD,EAAQmD,GAAWlD,CAAS,CAC9C,GACIR,EAAW,GAAG,OAAO8C;OACzB,IAAI,CAACnD,EAAOjC,CAAG,KAAK+B,EAAU/B,CAAG,GAAG;MACtC;YACK,AAAIhB,MAAWC,EAAuB,UAAU8G,KACrD/B,EAAaG,GAAOzD,EAAS,eAAe,UAAU;IAE1D;IAKA,AAAIpB,EAAO,SAAS4B,EAASC,GAAUnB,GAAKZ,GAAQ,UAAU,KAAGwG,EAAgBzB,GAAO9E,CAAK;GAL7F;EAMF;EAEA,OADA4B,EAAQ,MAAM,cAAc5B,CAAK,GAC1B+F;CACT,GAMMa,KAAkB,MACtBjG,EAAI,WAAWgC,EAAsB,YACrC,CAAChC,EAAI,mBACLgB,EAAShB,CAAG,CAAC,CAAC,aAAa,UAC3B,CAACqC,EAAkBrC,CAAG;CA2BxB,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBA5CuB,EAAE,aAAU,aAAqD;GAExF,EAAkBmB,GAAUnB,GAAK,EAAK;GACtC,IAAMkG,IAAkBD,EAAejG,CAAG;GAC1C,AAAIA,EAAI,WAAWgC,EAAsB,cAAc,CAACkE,IACtDjD,EAAQjD,CAAG,KAGb,EAAI,SAASgC,EAAsB,QACnC,EAAI,MAAM,WAAW,IACrB,EAAI,MAAM,UAAUkE,IACfjF,EAAQ,SAAS,YAAYjB,CAAG,KAAKiB,EAAQ,SAAS,aAAajB,CAAG,IACvEiB,EAAQ,SAAS,aAAajB,CAAG,GACrC,EAAI,kBAAkB,IACtByC,EAAO,eAAe,IAAIN,EAAMnC,CAAG,CAAC,GACpCuD,EAAWvD,CAAG,GACdiD,EAAQjD,CAAG,GACXiB,EAAQ,MAAM,WAAWE,GAAUnB,CAAG;EACxC;CA2BA;AACF"}
1
+ {"version":3,"file":"uploadSettle.js","names":["createUploadSettleMemory","isFinalFileStatus","status","AssetFileProcessStatus","resolveReadStatus","isNull","target","asset","intent","readStatus","clearRowError","AssetFileFailReasonDefault","isEmptyMetadataValue","isUndefined","value","isArray","mergeLoadedMetadata","useAssetSuggestions","row","customData","isObject","key","authorSuggestions","updateNewNames","queue","getAuthorConflicts","caches","decorateRow","mainFile","hadMetadata","role","UploadRowRole","markAsDuplicate","createUploadSettle","policyOf","profile","concerns","queueKey","purpose","byConfiguration","names","name","namedQueues","cachesOf","ids","fetchNames","queueKeys","rows","all","isStopped","UploadQueueItemStatus","isLive","raw","toRaw","item","isMarkedDuplicate","isDisposed","options","decorate","memory","revisionOf","bump","mark","isStale","startedAt","startRead","trackStateOf","untrack","state","setRefreshMayHelp","mayHelp","noticeOf","notice","dropNotice","showsOwnText","syncNotice","wants","text","clear","loadMetadata","settleProcessed","wasFailed","settleFailed","failReason","settleKnownFailed","entry","settleProcessedByEvent","announceProcessed","duplicateRows","eligible","policy","markDuplicates","marked","originFileId","assetType","file","error","becomeOriginals","DamAssetType","candidates","untouched","original","leftWithout","mightHelp","failsHere","settleDuplicate","targets","one","left","settleKnownDuplicate","tryLoadMetadata","applyAssetRead","duplicateSettled","maySettle","candidate","awaitsMetadata","withoutMetadata"],"sources":["../../../../../src/domains/dam/uploadQueue/settlement/uploadSettle.ts"],"sourcesContent":["import { toRaw } from 'vue'\nimport type { DocIdNullable } from '@/shared/types/common'\nimport { type AssetDetailItemDto, DamAssetType, type DamAssetTypeType } from '@/domains/dam/types/Asset'\nimport {\n type AssetFile,\n AssetFileFailReasonDefault,\n type AssetFileFailReasonType,\n type AssetFileNullable,\n AssetFileProcessStatus,\n type AssetFileProcessStatusType,\n} from '@/domains/dam/types/AssetFile'\nimport {\n type UploadQueue,\n type UploadQueueItem,\n UploadQueueItemStatus,\n type UploadQueueKey,\n} from '@/domains/dam/types/UploadQueue'\nimport { useAssetSuggestions } from '@/domains/dam/uploadQueue/composables/assetSuggestions'\nimport {\n UploadRowRole,\n type UploadRowRoleType,\n type UploadSettlementProfile,\n type UploadSettlementTarget,\n} from '@/domains/dam/uploadQueue/settlement/uploadSettlementTypes'\nimport { isArray, isNull, isObject, isUndefined } from '@/shared/utils/common'\n\nexport interface UploadTrackState {\n queueKey: UploadQueueKey\n /** When the row started waiting for the server, in scheduler time. */\n eligibleSince: number\n /** The client failed the row on its finish request. The server may still have finished the file. */\n clientFailed: boolean\n /** Consecutive successful reads that did not include the row's asset, or its file among the slots. */\n misses: number\n readFailures: number\n /**\n * A failed read or a missing asset was already reported, and no read has found the asset since.\n * Further failures are not reported.\n */\n reported: boolean\n}\n\nexport interface UploadRowNotice {\n /** The row has waited longer than processing should take. */\n slow: boolean\n readWarning: boolean\n /** Which of the two notices the settlement wrote into `row.error`. */\n shown: 'slow' | 'readWarning' | null\n /** The text written then. If the row's message differs now, the error belongs to someone else. */\n text: string | null\n}\n\n/** What a read should do for one target. */\nexport interface UploadReadIntent {\n /** State carried by the event. It applies when the read shows no final state. */\n hint: 'processed' | null\n /** When the row settles as processed, load its metadata as well. */\n metadata: boolean\n /** Set by the metadata notification. Metadata may arrive before the final state. */\n early: boolean\n /** The read tells a row with `settleOn: 'never'` that its file is processed. */\n seen: boolean\n}\n\n/** What the settlement remembers about rows. Every key is `toRaw(row)`. */\nexport interface UploadSettleMemory {\n tracked: WeakMap<UploadQueueItem, UploadTrackState>\n /** The last write an event made into the row. A read started before it is stale. Never cleared. */\n revision: WeakMap<UploadQueueItem, number>\n metadataLoaded: WeakSet<UploadQueueItem>\n /** Failed rows revived by an event. Their next read loads the metadata. */\n reviveWithMetadata: WeakSet<UploadQueueItem>\n /** Failed rows a refresh may still change: given up by the client, or left without their duplicate's original. */\n refreshMayHelp: WeakSet<UploadQueueItem>\n /** Rows failed because too many reads found no asset, while the server settles them by nothing else. */\n givenUpMissing: WeakSet<UploadQueueItem>\n notices: WeakMap<UploadQueueItem, UploadRowNotice>\n /** Shared counter for revisions and read starts. */\n clock: number\n}\n\nexport const createUploadSettleMemory = (): UploadSettleMemory => ({\n tracked: new WeakMap(),\n revision: new WeakMap(),\n metadataLoaded: new WeakSet(),\n reviveWithMetadata: new WeakSet(),\n refreshMayHelp: new WeakSet(),\n givenUpMissing: new WeakSet(),\n notices: new WeakMap(),\n clock: 0,\n})\n\nexport interface UploadSettleRow {\n queueKey: UploadQueueKey\n queue: UploadQueue\n row: UploadQueueItem\n}\n\nexport interface UploadSettleOptions {\n /** A row stopped being tracked, by a settlement write or by the store. */\n onUntrack?(queueKey: UploadQueueKey): void\n /** The settlement was disposed. Results of an original read that arrive later are not written. */\n isDisposed?(): boolean\n}\n\nexport const isFinalFileStatus = (\n status: AssetFileProcessStatusType | null | undefined\n): status is 'processed' | 'duplicate' | 'failed' =>\n status === AssetFileProcessStatus.Processed ||\n status === AssetFileProcessStatus.Duplicate ||\n status === AssetFileProcessStatus.Failed\n\n/**\n * The file state a read gives the target.\n * An asset reports only its main file state. A final state from the asset wins, otherwise the event state applies.\n * For another file (a slot) the asset says nothing, so only the event state applies.\n */\nexport const resolveReadStatus = (\n asset: AssetDetailItemDto,\n target: Pick<UploadSettlementTarget, 'fileId'>,\n intent: Pick<UploadReadIntent, 'hint'>\n): AssetFileProcessStatusType | undefined => {\n if (!isNull(target.fileId) && target.fileId !== asset.mainFile?.id) return intent.hint ?? undefined\n const readStatus = asset.mainFile?.fileAttributes?.status\n return isFinalFileStatus(readStatus) ? readStatus : (intent.hint ?? readStatus)\n}\n\nexport const clearRowError = (row: UploadQueueItem) => {\n row.error = { hasError: false, message: '', assetFileFailReason: AssetFileFailReasonDefault }\n}\n\n// \"Empty\" as the queue's mass operations define it.\nexport const isEmptyMetadataValue = (value: unknown) =>\n isUndefined(value) || isNull(value) || value === '' || (isArray(value) && !value.length)\n\n/**\n * First metadata load of a row. Values the user set earlier (via a queue mass operation) stay.\n * Only empty lists and empty custom fields are filled.\n */\nexport function mergeLoadedMetadata(\n queue: UploadQueue,\n row: UploadQueueItem,\n asset: AssetDetailItemDto,\n caches: Pick<UploadSettlementProfile['caches'], 'addAuthors' | 'addKeywords'>\n) {\n const { updateNewNames, getAuthorConflicts } = useAssetSuggestions()\n if (isEmptyMetadataValue(row.keywords)) row.keywords = [...(asset.keywords ?? [])]\n if (isEmptyMetadataValue(row.authors)) row.authors = [...(asset.authors ?? [])]\n if (isEmptyMetadataValue(row.sources)) row.sources = [...(asset.sources ?? [])]\n const customData: Record<string, unknown> = isObject(asset.metadata.customData)\n ? { ...asset.metadata.customData }\n : {}\n if (isObject(row.customData)) {\n for (const [key, value] of Object.entries(row.customData)) {\n if (!isEmptyMetadataValue(value)) customData[key] = value\n }\n }\n row.customData = customData\n // Not mass-operation fields. These come from the server.\n row.mainFileSingleUse = asset.mainFileSingleUse\n row.mainFileInternal = asset.mainFileInternal\n const authorSuggestions = asset.metadata.authorSuggestions ?? {}\n updateNewNames(authorSuggestions, queue.suggestions.newAuthorNames)\n updateNewNames(asset.metadata.keywordSuggestions ?? {}, queue.suggestions.newKeywordNames)\n row.authorConflicts = getAuthorConflicts(authorSuggestions)\n caches.addKeywords(row.keywords)\n caches.addAuthors([...row.authors, ...(row.sources ?? [])])\n caches.addAuthors(row.authorConflicts)\n}\n\n/**\n * Applies a read asset to a row without changing its state.\n * `hadMetadata`: the row's metadata was loaded once, whether or not the form is shown now.\n */\nexport function decorateRow(\n row: UploadQueueItem,\n asset: AssetDetailItemDto,\n mainFile: AssetFile,\n role: UploadRowRoleType,\n hadMetadata: boolean\n) {\n row.assetStatus = asset.attributes.assetStatus\n // Only for the main-file row. A slot row would get a preview of another file.\n if (!isNull(row.fileId) && row.fileId !== mainFile.id) return\n if (mainFile.links?.image_detail) row.imagePreview = mainFile.links.image_detail\n // Skip mass-edit rows and rows that have or had metadata. There these switches are form fields the user may have set.\n // This includes a row that lost its form on failure and gets it back.\n if (!row.canEditMetadata && !hadMetadata && role !== UploadRowRole.MassEdit) {\n row.mainFileSingleUse = asset.mainFileSingleUse\n row.mainFileInternal = asset.mainFileInternal\n }\n}\n\n// Both duplicate policies mark the row through here.\nconst markAsDuplicate = (row: UploadQueueItem) => {\n row.isDuplicate = true\n // Set once, before anything can overwrite `assetId` with the original.\n row.uploadedAssetId ??= row.assetId\n}\n\n/**\n * Settlement writes: a read asset or a known state into queue rows.\n * No timers and no reads of its own, except reading a duplicate's original.\n */\nexport function createUploadSettle(\n profile: UploadSettlementProfile,\n memory: UploadSettleMemory = createUploadSettleMemory(),\n options: UploadSettleOptions = {}\n) {\n const policyOf = (row: UploadQueueItem) => profile.policyFor(profile.roleOf(row))\n\n /**\n * Whether the target concerns a row of queue `queueKey`, by the profile's `matches`.\n * When the profile provides `configOf`, only queues of a configuration the target names match.\n */\n const concerns = (\n queueKey: UploadQueueKey,\n row: UploadQueueItem,\n target: UploadSettlementTarget,\n purpose: 'settle' | 'decorate' | 'metadata'\n ) =>\n (!profile.configOf || !target.configNames?.length || target.configNames.includes(profile.configOf(queueKey))) &&\n profile.matches(row, target, purpose)\n\n /**\n * Splits the target per named configuration when it names several and the profile provides `configOf`.\n * Each copy is read separately, by a queue of that configuration, and written only into its rows.\n * Otherwise returns the target itself.\n */\n const byConfiguration = (target: UploadSettlementTarget): UploadSettlementTarget[] => {\n const names = profile.configOf ? [...new Set(target.configNames ?? [])] : []\n return names.length > 1 ? names.map((name) => ({ ...target, configNames: [name] })) : [target]\n }\n\n // Queues whose rows got names since the caches last fetched.\n const namedQueues = new Set<UploadQueueKey>()\n /** Where the row names go. A profile with `configOf` is given the queue key, one without is not. */\n const cachesOf = (\n queueKey: UploadQueueKey\n ): Pick<UploadSettlementProfile['caches'], 'addAuthors' | 'addKeywords'> => {\n namedQueues.add(queueKey)\n if (!profile.configOf) {\n return {\n addAuthors: (ids) => profile.caches.addAuthors(ids),\n addKeywords: (ids) => profile.caches.addKeywords(ids),\n }\n }\n return {\n addAuthors: (ids) => profile.caches.addAuthors(ids, queueKey),\n addKeywords: (ids) => profile.caches.addKeywords(ids, queueKey),\n }\n }\n /** Fetches caches for each queue that got names, or once without a queue for a profile without `configOf`. */\n const fetchNames = () => {\n const queueKeys = [...namedQueues]\n namedQueues.clear()\n if (!profile.configOf) {\n profile.caches.fetchAuthors()\n profile.caches.fetchKeywords()\n return\n }\n for (const queueKey of queueKeys) {\n profile.caches.fetchAuthors(queueKey)\n profile.caches.fetchKeywords(queueKey)\n }\n }\n\n /** All queue rows at this moment. */\n const rows = (): UploadSettleRow[] => {\n const all: UploadSettleRow[] = []\n for (const [queueKey, queue] of profile.queues()) {\n for (const row of queue.items) all.push({ queueKey, queue, row })\n }\n return all\n }\n\n // Nothing writes into a stopped row. Check again after every await: the row may have been stopped meanwhile.\n const isStopped = (row: UploadQueueItem) => row.status === UploadQueueItemStatus.Stop\n\n const isLive = (row: UploadQueueItem) => {\n const raw = toRaw(row)\n for (const [, queue] of profile.queues()) {\n if (toRaw(queue.items).some((item) => toRaw(item) === raw)) return true\n }\n return false\n }\n\n // A row marked as a duplicate is settled and read-only.\n // A row that became its original is a normal editable row.\n const isMarkedDuplicate = (row: UploadQueueItem) => row.isDuplicate && policyOf(row).duplicate === 'markDuplicate'\n const isDisposed = () => options.isDisposed?.() === true\n\n const decorate = (row: UploadQueueItem, asset: AssetDetailItemDto, mainFile: AssetFile) =>\n decorateRow(row, asset, mainFile, profile.roleOf(row), memory.metadataLoaded.has(toRaw(row)))\n\n const revisionOf = (row: UploadQueueItem) => memory.revision.get(toRaw(row)) ?? 0\n /** An event wrote into the row. Reads started before this are stale for it. */\n const bump = (row: UploadQueueItem) => {\n const mark = ++memory.clock\n memory.revision.set(toRaw(row), mark)\n return mark\n }\n const isStale = (row: UploadQueueItem, startedAt: number) => startedAt <= revisionOf(row)\n /** Mark of a read starting now. */\n const startRead = () => ++memory.clock\n\n const trackStateOf = (row: UploadQueueItem) => memory.tracked.get(toRaw(row))\n const untrack = (row: UploadQueueItem) => {\n const raw = toRaw(row)\n const state = memory.tracked.get(raw)\n if (!state) return\n memory.tracked.delete(raw)\n options.onUntrack?.(state.queueKey)\n }\n\n /** Whether a refresh may still change a failed row. The store is notified on change. */\n const setRefreshMayHelp = (queueKey: UploadQueueKey, row: UploadQueueItem, mayHelp: boolean) => {\n const raw = toRaw(row)\n if (memory.refreshMayHelp.has(raw) === mayHelp) return\n if (mayHelp) memory.refreshMayHelp.add(raw)\n else memory.refreshMayHelp.delete(raw)\n profile.hooks.onRefreshMayHelp?.(queueKey, row, mayHelp)\n }\n\n const noticeOf = (row: UploadQueueItem) => {\n const raw = toRaw(row)\n let notice = memory.notices.get(raw)\n if (!notice) {\n notice = { slow: false, readWarning: false, shown: null, text: null }\n memory.notices.set(raw, notice)\n }\n return notice\n }\n const dropNotice = (row: UploadQueueItem) => memory.notices.delete(toRaw(row))\n // Whether the row message is still the text the settlement wrote.\n // The store also writes `row.error` (failed upload), and the settlement must not clear that error.\n const showsOwnText = (row: UploadQueueItem) => {\n const notice = memory.notices.get(toRaw(row))\n return !!notice?.shown && row.error.message === notice.text\n }\n\n /**\n * Writes the applicable settlement text into `row.error`, or removes its own text.\n * Only its own text, and only while the row still shows it.\n * `clear` also removes an error the settlement did not write, because the row settled as processed.\n */\n const syncNotice = (row: UploadQueueItem, { clear = false }: { clear?: boolean } = {}) => {\n const notice = noticeOf(row)\n let wants: UploadRowNotice['shown'] = null\n if (\n notice.readWarning &&\n policyOf(row).metadata === 'load' &&\n !row.canEditMetadata &&\n !isMarkedDuplicate(row) &&\n row.status !== UploadQueueItemStatus.Failed\n ) {\n wants = 'readWarning'\n } else if (notice.slow && row.status === UploadQueueItemStatus.Processing) {\n wants = 'slow'\n }\n if (wants) {\n const text = wants === 'slow' ? profile.messages.processingTooLong(row) : profile.messages.readFailed(row)\n row.error.hasError = true\n row.error.message = text\n notice.shown = wants\n notice.text = text\n return\n }\n if (clear) {\n clearRowError(row)\n } else if (showsOwnText(row)) {\n // Remove the text. Also clear the flag, unless the row has failed since. Then the flag belongs to the failure.\n if (row.status === UploadQueueItemStatus.Failed) row.error = { ...row.error, message: '' }\n else clearRowError(row)\n }\n notice.shown = null\n notice.text = null\n }\n\n const loadMetadata = (\n { queueKey, queue, row }: Pick<UploadSettleRow, 'queueKey' | 'queue' | 'row'>,\n asset: AssetDetailItemDto\n ) => {\n mergeLoadedMetadata(queue, row, asset, cachesOf(queueKey))\n memory.metadataLoaded.add(toRaw(row))\n }\n\n const settleProcessed = (\n { queueKey, queue, row }: UploadSettleRow,\n asset: AssetDetailItemDto,\n mainFile: AssetFile,\n intent: UploadReadIntent\n ) => {\n const raw = toRaw(row)\n // The client marks an upload failed when one of its requests fails, but the server may still finish it.\n // Such a row lost its form on failure and gets it back here, with its metadata.\n const wasFailed = row.status === UploadQueueItemStatus.Failed || memory.reviveWithMetadata.has(raw)\n row.status = UploadQueueItemStatus.Uploaded\n // A licence copy knows only its asset. The image is built from the file id.\n if (isNull(row.fileId)) row.fileId = mainFile.id\n decorate(row, asset, mainFile)\n const notice = noticeOf(row)\n if (policyOf(row).metadata === 'load' && !isMarkedDuplicate(row) && (intent.metadata || wasFailed)) {\n // Loaded once, and never into a row with the form shown, so user input is kept.\n if (!row.canEditMetadata && !memory.metadataLoaded.has(raw)) loadMetadata({ queueKey, queue, row }, asset)\n row.canEditMetadata = true\n notice.readWarning = false\n profile.hooks.afterMetadataLoaded?.(queueKey, row)\n }\n memory.reviveWithMetadata.delete(raw)\n memory.givenUpMissing.delete(raw)\n notice.slow = false\n syncNotice(row, { clear: true })\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n\n const settleFailed = (\n { queueKey, row }: Pick<UploadSettleRow, 'queueKey' | 'row'>,\n failReason: AssetFileFailReasonType\n ) => {\n row.status = UploadQueueItemStatus.Failed\n // Drop the old text. The row shows a message for the reason, and the old text is not the cause.\n row.error = { hasError: true, message: '', assetFileFailReason: failReason }\n row.canEditMetadata = false\n dropNotice(row)\n memory.reviveWithMetadata.delete(toRaw(row))\n memory.givenUpMissing.delete(toRaw(row))\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n\n /** A failure known by the caller, without a read. */\n const settleKnownFailed = (target: UploadSettlementTarget, failReason: AssetFileFailReasonType) => {\n for (const entry of rows()) {\n if (entry.row.status === UploadQueueItemStatus.Stop || !concerns(entry.queueKey, entry.row, target, 'settle')) {\n continue\n }\n settleFailed(entry, failReason)\n bump(entry.row)\n }\n }\n\n /**\n * Applies a `processed` event immediately to rows that settle on the event.\n * A tick also uses it for a slot row whose file the slot list shows processed.\n */\n const settleProcessedByEvent = (target: UploadSettlementTarget) => {\n for (const { queueKey, row } of rows()) {\n if (row.status === UploadQueueItemStatus.Stop || policyOf(row).settleOn !== 'event') continue\n if (!concerns(queueKey, row, target, 'settle')) continue\n const raw = toRaw(row)\n if (row.status === UploadQueueItemStatus.Failed) memory.reviveWithMetadata.add(raw)\n memory.givenUpMissing.delete(raw)\n row.status = UploadQueueItemStatus.Uploaded\n // A row the client gave up on that already had metadata gets its form back as the user left it.\n if (!isMarkedDuplicate(row) && memory.metadataLoaded.has(raw)) row.canEditMetadata = true\n noticeOf(row).slow = false\n syncNotice(row, { clear: true })\n bump(row)\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n }\n\n /** Handles a `processed` event for rows whose state it does not change. */\n const announceProcessed = (target: UploadSettlementTarget) => {\n for (const { queueKey, row } of rows()) {\n if (row.status === UploadQueueItemStatus.Stop || policyOf(row).settleOn !== 'never') continue\n if (concerns(queueKey, row, target, 'decorate')) profile.hooks.onProcessedSeen?.(queueKey, row)\n }\n }\n\n const duplicateRows = (\n target: UploadSettlementTarget,\n policy: 'becomeOriginal' | 'markDuplicate',\n eligible: (row: UploadQueueItem) => boolean\n ) =>\n rows().filter(\n ({ queueKey, row }) =>\n row.status !== UploadQueueItemStatus.Stop &&\n eligible(row) &&\n policyOf(row).duplicate === policy &&\n concerns(queueKey, row, target, 'settle')\n )\n\n // The row stays and is marked. It is settled first and completed from the original file later.\n // This way the wait for that file does not hold an upload slot.\n const markDuplicates = async (\n target: UploadSettlementTarget,\n originFileId: DocIdNullable,\n assetType: DamAssetTypeType | null,\n eligible: (row: UploadQueueItem) => boolean\n ) => {\n const marked: Array<{ row: UploadQueueItem; mark: number }> = []\n for (const { queueKey, row } of duplicateRows(target, 'markDuplicate', eligible)) {\n markAsDuplicate(row)\n row.status = UploadQueueItemStatus.Uploaded\n row.canEditMetadata = false\n clearRowError(row)\n dropNotice(row)\n memory.reviveWithMetadata.delete(toRaw(row))\n memory.givenUpMissing.delete(toRaw(row))\n marked.push({ row, mark: bump(row) })\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n if (!marked.length || !originFileId || !assetType || !profile.readers.duplicateOriginFile) return\n let file: AssetFileNullable = null\n try {\n file = await profile.readers.duplicateOriginFile(originFileId, assetType)\n } catch (error) {\n console.error('uploadQueue: the duplicated file could not be read', error)\n }\n if (!file || isDisposed()) return\n for (const { row, mark } of marked) {\n // Only rows still present and not written into meanwhile.\n if (!isLive(row) || row.status === UploadQueueItemStatus.Stop || !row.isDuplicate) continue\n if (revisionOf(row) !== mark) continue\n row.fileId = file.id\n row.duplicateAssetId = file.asset\n row.mainFileSingleUse = file.flags.singleUse\n if (file.links?.image_detail) row.imagePreview = file.links.image_detail\n }\n }\n\n // The row becomes the original: its asset and file are replaced and it takes the original's metadata.\n // Returns whether the original could not be read and a row remains that a refresh may still help.\n const becomeOriginals = async (\n target: UploadSettlementTarget,\n originFileId: DocIdNullable,\n assetType: DamAssetTypeType | null,\n eligible: (row: UploadQueueItem) => boolean\n ): Promise<boolean> => {\n if (!originFileId || assetType !== DamAssetType.Image) return false\n // Recorded before requesting the original. After the await, only rows still in\n // their queue, not stopped and not written by an event meanwhile are written.\n // The caller that reports a duplicate is outside the read\n // ordering, so an earlier answer must not undo a later event.\n const candidates = duplicateRows(target, 'becomeOriginal', eligible).map((entry) => ({\n ...entry,\n mark: revisionOf(entry.row),\n }))\n if (!candidates.length) return false\n const untouched = () =>\n candidates.filter(({ row, mark }) => isLive(row) && !isStopped(row) && revisionOf(row) === mark)\n const { updateNewNames, getAuthorConflicts } = useAssetSuggestions()\n let original: AssetDetailItemDto\n try {\n if (!profile.readers.duplicateOriginAsset) throw new Error('uploadSettlement: no reader of the original asset')\n original = await profile.readers.duplicateOriginAsset(originFileId, { queueKey: candidates[0]!.queueKey })\n } catch {\n if (isDisposed()) return false\n let leftWithout = false\n for (const { queueKey, row } of untouched()) {\n // Read before untracking, so a row the client gave up on keeps its way back.\n const mightHelp = memory.refreshMayHelp.has(toRaw(row))\n // Untrack regardless of state. The next tick would only retry the same read.\n untrack(row)\n // Only a row still waiting for this answer fails: a settled one must not be flipped back to failed.\n const failsHere = row.status === UploadQueueItemStatus.Processing\n if (failsHere) {\n row.status = UploadQueueItemStatus.Failed\n // Drop a text the settlement wrote. It no longer describes what is wrong with the row.\n row.error = { ...row.error, hasError: true, message: showsOwnText(row) ? '' : row.error.message }\n row.canEditMetadata = false\n dropNotice(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n // Failed because a read failed, not the file. A row refresh requests the original again.\n // Not for a row the server had already failed, which no refresh can undo.\n if (failsHere || mightHelp) {\n setRefreshMayHelp(queueKey, row, true)\n leftWithout = true\n }\n }\n return leftWithout\n }\n if (isDisposed()) return false\n for (const { queueKey, queue, row } of untouched()) {\n const authorSuggestions = original.metadata.authorSuggestions ?? {}\n markAsDuplicate(row)\n row.status = UploadQueueItemStatus.Uploaded\n clearRowError(row)\n row.fileId = originFileId\n row.duplicateAssetId = original.id\n row.assetStatus = original.attributes.assetStatus\n if (original.mainFile?.links?.image_detail) row.imagePreview = original.mainFile.links.image_detail\n row.keywords = [...(original.keywords ?? [])]\n row.authors = [...(original.authors ?? [])]\n row.sources = [...(original.sources ?? [])]\n row.customData = isObject(original.metadata.customData) ? { ...original.metadata.customData } : {}\n updateNewNames(authorSuggestions, queue.suggestions.newAuthorNames)\n updateNewNames(original.metadata.keywordSuggestions ?? {}, queue.suggestions.newKeywordNames)\n row.authorConflicts = getAuthorConflicts(authorSuggestions)\n const caches = cachesOf(queueKey)\n caches.addKeywords(row.keywords)\n caches.addAuthors([...row.authors, ...(row.sources ?? [])])\n caches.addAuthors(row.authorConflicts)\n row.assetId = original.id\n row.mainFileSingleUse = original.mainFileSingleUse\n row.mainFileInternal = original.mainFileInternal\n memory.metadataLoaded.add(toRaw(row))\n row.canEditMetadata = true\n dropNotice(row)\n memory.reviveWithMetadata.delete(toRaw(row))\n memory.givenUpMissing.delete(toRaw(row))\n bump(row)\n setRefreshMayHelp(queueKey, row, false)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n fetchNames()\n return false\n }\n\n /**\n * Handles a duplicate file for every row passing `matches(…, 'settle')`, by the policy of its role.\n * `eligible` excludes rows the read is stale for.\n * Returns whether a row is left without its duplicate's original\n * because it could not be read. A refresh may still help it.\n */\n const settleDuplicate = async (\n target: UploadSettlementTarget,\n originFileId: DocIdNullable,\n assetType: DamAssetTypeType | null,\n eligible: (row: UploadQueueItem) => boolean = () => true\n ) => {\n // Both start at once, not one after the other, so each records its rows now.\n // The original is read once per configuration the target names, by a queue of that configuration.\n const targets = byConfiguration(target)\n const [, leftWithout] = await Promise.all([\n markDuplicates(target, originFileId, assetType, eligible),\n targets.length === 1\n ? becomeOriginals(target, originFileId, assetType, eligible)\n : Promise.all(targets.map((one) => becomeOriginals(one, originFileId, assetType, eligible))).then((left) =>\n left.some(Boolean)\n ),\n ])\n return leftWithout\n }\n\n /** A duplicate known by the caller, without reading its asset. Never rejects. */\n const settleKnownDuplicate = async (\n target: UploadSettlementTarget,\n originFileId: DocIdNullable,\n assetType: DamAssetTypeType | null\n ) => {\n try {\n await settleDuplicate(target, originFileId, assetType)\n } catch (error) {\n console.error('uploadQueue: the duplicate could not be settled', error)\n }\n }\n\n /** Metadata notification: loads the metadata and the form, regardless of the file state. */\n const tryLoadMetadata = ({ queueKey, queue, row }: UploadSettleRow, asset: AssetDetailItemDto) => {\n if (policyOf(row).metadata !== 'load' || row.canEditMetadata) return\n // A marked duplicate is settled and has no metadata of its own to load.\n if (isMarkedDuplicate(row)) return\n // Skip a row whose file failed, except one that failed for lack of this metadata.\n if (row.status === UploadQueueItemStatus.Failed && profile.metadataGate?.(queueKey, row) !== 'load') return\n if (!memory.metadataLoaded.has(toRaw(row))) loadMetadata({ queueKey, queue, row }, asset)\n row.canEditMetadata = true\n noticeOf(row).readWarning = false\n syncNotice(row)\n profile.hooks.afterMetadataLoaded?.(queueKey, row)\n }\n\n /**\n * Applies one read asset to every row it concerns. `startedAt` is the read mark.\n * A row written by an event since keeps the event's state.\n * Returns like `settleDuplicate`: whether a row is left without its duplicate's original.\n */\n const applyAssetRead = async (\n asset: AssetDetailItemDto,\n target: UploadSettlementTarget,\n intent: UploadReadIntent,\n startedAt: number\n ) => {\n const mainFile = asset.mainFile ?? null\n const status = resolveReadStatus(asset, target, intent)\n let duplicateSettled = false\n let leftWithout = false\n for (const entry of rows()) {\n const { queueKey, row } = entry\n // The duplicate's original read was awaited. The row may have left its queue meanwhile.\n if (duplicateSettled && !isLive(row)) continue\n if (isStopped(row)) continue\n\n // Apply the file state and row details unless an event wrote\n // into the row after this read started. The event is newer.\n if (!isStale(row, startedAt) && mainFile && concerns(queueKey, row, target, 'decorate')) {\n const maySettle = concerns(queueKey, row, target, 'settle')\n if (status === AssetFileProcessStatus.Processed) {\n if (policyOf(row).settleOn === 'never') {\n decorate(row, asset, mainFile)\n if (intent.seen) profile.hooks.onProcessedSeen?.(queueKey, row)\n } else if (maySettle) {\n settleProcessed(entry, asset, mainFile, intent)\n }\n } else if (status === AssetFileProcessStatus.Duplicate && maySettle) {\n // Once for all rows of the target. The original is read only once.\n if (!duplicateSettled) {\n duplicateSettled = true\n leftWithout = await settleDuplicate(\n target,\n mainFile.originAssetFile,\n asset.attributes.assetType,\n (candidate) => !isStale(candidate, startedAt)\n )\n if (isDisposed()) return leftWithout\n if (!isLive(row) || isStopped(row)) continue\n }\n } else if (status === AssetFileProcessStatus.Failed && maySettle) {\n settleFailed(entry, mainFile.fileAttributes.failReason)\n }\n }\n\n // Applied to such a row as well, because metadata is not file state. It loads once, whenever it arrives.\n // Rows the event failed or marked as duplicate are refused there.\n // Otherwise a `processed` event that overtakes the metadata read would leave the row uploaded without its form.\n if (intent.early && concerns(queueKey, row, target, 'metadata')) tryLoadMetadata(entry, asset)\n }\n profile.hooks.onAssetRead?.(asset)\n return leftWithout\n }\n\n /**\n * An uploaded row without its metadata, which a refresh would load.\n * It is no longer tracked, but reads that find no asset are still counted for it.\n */\n const awaitsMetadata = (row: UploadQueueItem) =>\n row.status === UploadQueueItemStatus.Uploaded &&\n !row.canEditMetadata &&\n policyOf(row).metadata === 'load' &&\n !isMarkedDuplicate(row)\n\n /**\n * The row's asset was missing from enough reads, for a tracked row or one a refresh may still help.\n * A processing row fails. An uploaded row without metadata fails with `assetGone`.\n * Any other row (given up by the client, or left without its duplicate's original) is left alone.\n */\n const giveUpOnMissing = ({ queueKey, row }: Pick<UploadSettleRow, 'queueKey' | 'row'>) => {\n // There is no asset a refresh could read.\n setRefreshMayHelp(queueKey, row, false)\n const withoutMetadata = awaitsMetadata(row)\n if (row.status !== UploadQueueItemStatus.Processing && !withoutMetadata) {\n untrack(row)\n return\n }\n row.status = UploadQueueItemStatus.Failed\n row.error.hasError = true\n row.error.message = withoutMetadata\n ? (profile.messages.assetGone?.(row) ?? profile.messages.assetMissing(row))\n : profile.messages.assetMissing(row)\n row.canEditMetadata = false\n memory.givenUpMissing.add(toRaw(row))\n dropNotice(row)\n untrack(row)\n profile.hooks.onRowFinal(queueKey, row)\n }\n\n return {\n memory,\n policyOf,\n concerns,\n byConfiguration,\n fetchNames,\n rows,\n isLive,\n bump,\n isStale,\n startRead,\n trackStateOf,\n untrack,\n setRefreshMayHelp,\n noticeOf,\n syncNotice,\n applyAssetRead,\n settleProcessedByEvent,\n announceProcessed,\n settleFailed,\n settleKnownFailed,\n settleDuplicate,\n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ACrC,CAAChC,EAAI,mBACLgB,EAAShB,CAAG,CAAC,CAAC,aAAa,UAC3B,CAACqC,EAAkBrC,CAAG;CA2BxB,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBA5CuB,EAAE,aAAU,aAAqD;GAExF,EAAkBmB,GAAUnB,GAAK,EAAK;GACtC,IAAMkG,IAAkBD,EAAejG,CAAG;GAC1C,AAAIA,EAAI,WAAWgC,EAAsB,cAAc,CAACkE,IACtDjD,EAAQjD,CAAG,KAGb,EAAI,SAASgC,EAAsB,QACnC,EAAI,MAAM,WAAW,IACrB,EAAI,MAAM,UAAUkE,IACfjF,EAAQ,SAAS,YAAYjB,CAAG,KAAKiB,EAAQ,SAAS,aAAajB,CAAG,IACvEiB,EAAQ,SAAS,aAAajB,CAAG,GACrC,EAAI,kBAAkB,IACtByC,EAAO,eAAe,IAAIN,EAAMnC,CAAG,CAAC,GACpCuD,EAAWvD,CAAG,GACdiD,EAAQjD,CAAG,GACXiB,EAAQ,MAAM,WAAWE,GAAUnB,CAAG;EACxC;CA2BA;AACF"}
@@ -7,6 +7,7 @@ import { UploadQueue, UploadQueueItem, UploadQueueKey } from '../../types/Upload
7
7
  export interface EditableFields {
8
8
  keywords: DocId[];
9
9
  authors: DocId[];
10
+ sources: DocId[];
10
11
  customData: UploadQueueItem['customData'];
11
12
  mainFileSingleUse: boolean | null | undefined;
12
13
  }
@@ -27,6 +27,7 @@ import { defineStore as N } from "pinia";
27
27
  var re = (e) => O({
28
28
  keywords: e.keywords,
29
29
  authors: e.authors,
30
+ sources: e.sources,
30
31
  customData: e.customData,
31
32
  mainFileSingleUse: e.mainFileSingleUse
32
33
  }), P = (e, t) => JSON.stringify(e) === JSON.stringify(t), F = (e, t, n) => {
@@ -34,7 +35,7 @@ var re = (e) => O({
34
35
  fields: /* @__PURE__ */ new Set(),
35
36
  customKeys: /* @__PURE__ */ new Set()
36
37
  }, i = (n) => !t || P(e[n], t[n]) ? !0 : (r.fields.add(n), !1);
37
- i("keywords") && (e.keywords = [...n.keywords]), i("authors") && (e.authors = [...n.authors]);
38
+ i("keywords") && (e.keywords = [...n.keywords]), i("authors") && (e.authors = [...n.authors]), i("sources") && (e.sources = [...n.sources ?? []]);
38
39
  let a = O(n.customData);
39
40
  if (t && a) {
40
41
  let n = e.customData ?? {}, i = t.customData ?? {};
@@ -46,7 +47,7 @@ var re = (e) => O({
46
47
  }, ie = (e, t, n) => {
47
48
  let r = e.rows.get(t);
48
49
  if (!r) return;
49
- n.fields.has("keywords") || (r.keywords = [...t.keywords]), n.fields.has("authors") || (r.authors = [...t.authors]), n.fields.has("mainFileSingleUse") || (r.mainFileSingleUse = t.mainFileSingleUse);
50
+ n.fields.has("keywords") || (r.keywords = [...t.keywords]), n.fields.has("authors") || (r.authors = [...t.authors]), n.fields.has("sources") || (r.sources = [...t.sources ?? []]), n.fields.has("mainFileSingleUse") || (r.mainFileSingleUse = t.mainFileSingleUse);
50
51
  let i = t.customData ?? {}, a = r.customData = { ...r.customData };
51
52
  (/* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(a)])).forEach((e) => {
52
53
  n.customKeys.has(e) || (e in i ? a[e] = O(i[e]) : delete a[e]);
@@ -264,10 +265,11 @@ var re = (e) => O({
264
265
  let r = F(e, v.get(e), {
265
266
  keywords: t.keywords,
266
267
  authors: t.authors,
268
+ sources: t.sources,
267
269
  customData: t.metadata.customData,
268
270
  mainFileSingleUse: t.mainFileSingleUse
269
271
  });
270
- $(_, e, r), i(t.metadata.authorSuggestions, n.suggestions.newAuthorNames), i(t.metadata.keywordSuggestions, n.suggestions.newKeywordNames), e.authorConflicts = o(t.metadata.authorSuggestions), l(e.keywords), f(e.authors), f(e.authorConflicts);
272
+ $(_, e, r), i(t.metadata.authorSuggestions, n.suggestions.newAuthorNames), i(t.metadata.keywordSuggestions, n.suggestions.newKeywordNames), e.authorConflicts = o(t.metadata.authorSuggestions), l(e.keywords), f(e.authors), f(e.sources), f(e.authorConflicts);
271
273
  }
272
274
  }), R.recalculateQueueCounts(e), m(), u();
273
275
  });
@@ -279,10 +281,11 @@ var re = (e) => O({
279
281
  let r = F(t, v.get(t), {
280
282
  keywords: e.keywords,
281
283
  authors: e.authors,
284
+ sources: e.sources,
282
285
  customData: e.metadata.customData,
283
286
  mainFileSingleUse: j(n) ? void 0 : n
284
287
  });
285
- $(_, t, r), l(t.keywords), f(t.authors);
288
+ $(_, t, r), l(t.keywords), f(t.authors), f(t.sources);
286
289
  }
287
290
  });
288
291
  }), m(), u();
@@ -1 +1 @@
1
- {"version":3,"file":"uploadQueuesStore.js","names":["editableFieldsOf","cloneDeep","item","sameValue","one","other","writeUnchanged","kept","unchanged","was","field","saved","customData","now","then","key","isUndefined","takeWrite","entry","note","written","noted","useUploadQueuesStore","defineStore","queues","ref","useUploadQueueItemFactory","configNames","configOf","queueKey","damOf","useCommonAdminCoreDamOptions","profile","row","UploadQueueItemType","UploadRowRole","target","options","fetchAsset","damClient","endPointAsset","assetId","error","apiErrorStatus","fetchAssetListByIds","assetIds","licenceId","failure","answer","isArray","url","context","SYSTEM_CORE_DAM","ENTITY","requestedUrl","AnzuApiResponseCodeError","report","mapApiError","fetchAssetByFileId","originFileId","apiErrorIsReported","useDamCachedAuthors","ids","useDamCachedKeywords","commonT","useDamNotificationsConnection","core","createUploadQueueCore","libraryQueuePreset","addRowUnder","known","configName","storeScope","getCurrentScope","toSettlementEvent","event","DamNotificationName","useDamNotifications","listening","listenToNotifications","listen","addDamNotificationListener","settlementEvent","origin","settlement","addByCopyToLicence","useDamConfigState","configExtSystem","getDamConfigExtSystem","extSystem","assets","queueItem","createDefault","UploadQueueItemStatus","DamAssetType","UPLOAD_QUEUE_ITEM_CHUNK_SIZE","assetLicence","added","addByFiles","file","files","type","getAssetTypeByMimeType","damFileTypeFix","targetOf","isString","of","queueItemProcessed","queueItemFullyProcessed","queueItemDuplicate","originAssetFile","assetType","queueItemFailed","failReason","refreshAsset","stopItemUpload","detailWrites","detailWriteKey","lastDetailWrite","openNotes","noteRowsOfAsset","rows","queue","forgetRowsNote","othersTakeWrite","own","updateFromDetail","useAssetSuggestions","dam","queuesOfConfig","asset","rowsAtSave","before","turn","writeKey","isLatest","assetRes","updateNewNames","getAuthorConflicts","addToCachedKeywords","addToCachedAuthors","fetchCachedAuthors","fetchCachedKeywords","mainFileSingleUse"],"sources":["../../../../../src/domains/dam/uploadQueue/store/uploadQueuesStore.ts"],"sourcesContent":["import { requestedUrl } from '@/domains/api/composables/request'\nimport { apiErrorIsReported, apiErrorStatus, mapApiError, report } from '@/domains/api/utils/apiErrors'\nimport { useCommonAdminCoreDamOptions } from '@/domains/dam/composables/commonAdminCoreDamOptions'\nimport { ENTITY, fetchAsset, fetchAssetByFileId, fetchAssetListByIds } from '@/domains/dam/api/damAssetApi'\nimport { SYSTEM_CORE_DAM } from '@/domains/dam/api/damConstants'\nimport { useDamCachedAuthors } from '@/domains/dam/author/composables/cachedAuthors'\nimport { useUploadQueueItemFactory } from '@/domains/dam/uploadQueue/factory/UploadQueueItemFactory'\nimport { useAssetSuggestions } from '@/domains/dam/uploadQueue/composables/assetSuggestions'\nimport { useDamConfigState } from '@/domains/dam/config/composables/damConfigState'\nimport { useDamNotifications } from '@/domains/dam/composables/damNotifications'\nimport { useDamNotificationsConnection } from '@/domains/dam/composables/damNotificationsConnection'\nimport { type DamNotification, DamNotificationName } from '@/domains/dam/composables/damNotificationsEventBus'\nimport { getAssetTypeByMimeType } from '@/domains/dam/uploadQueue/utils/mimeTypeHelper'\nimport { createUploadQueueCore, UPLOAD_QUEUE_ITEM_CHUNK_SIZE } from '@/domains/dam/uploadQueue/core/uploadQueueCore'\nimport type { UploadQueueSettlementProfile } from '@/domains/dam/uploadQueue/core/uploadQueueCoreTypes'\nimport { libraryQueuePreset } from '@/domains/dam/uploadQueue/presets/queuePresets'\nimport {\n type UploadReadOptions,\n type UploadRefreshOutcome,\n UploadRowRole,\n type UploadSettlementEvent,\n} from '@/domains/dam/uploadQueue/settlement/uploadSettlementTypes'\nimport { useDamCachedKeywords } from '@/domains/dam/keyword/composables/cachedKeywords'\nimport { damFileTypeFix } from '@/domains/ui/file/utils/fileType'\nimport type { AxiosRequestConfig } from 'axios'\nimport type { DocId, DocIdNullable, IntegerId } from '@/shared/types/common'\nimport { type AssetDetailItemDto, DamAssetType, type DamAssetTypeType } from '@/domains/dam/types/Asset'\nimport type { AssetFileFailReasonType } from '@/domains/dam/types/AssetFile'\nimport {\n type UploadQueue,\n type UploadQueueItem,\n UploadQueueItemStatus,\n UploadQueueItemType,\n type UploadQueueKey,\n} from '@/domains/dam/types/UploadQueue'\nimport { AnzuApiResponseCodeError } from '@/shared/error/AnzuApiResponseCodeError'\nimport { cloneDeep, isArray, isString, isUndefined } from '@/shared/utils/common'\nimport { commonT } from '@/plugins/i18n'\nimport { defineStore } from 'pinia'\nimport { getCurrentScope, ref } from 'vue'\n\n/** Fields the user edits and a detail save writes. */\nexport interface EditableFields {\n keywords: DocId[]\n authors: DocId[]\n customData: UploadQueueItem['customData']\n mainFileSingleUse: boolean | null | undefined\n}\n\nconst editableFieldsOf = (item: UploadQueueItem): EditableFields =>\n cloneDeep({\n keywords: item.keywords,\n authors: item.authors,\n customData: item.customData,\n mainFileSingleUse: item.mainFileSingleUse,\n })\n\nconst sameValue = (one: unknown, other: unknown) => JSON.stringify(one) === JSON.stringify(other)\n\n/** Field-by-field snapshot of an asset's rows (`noteRowsOfAsset`). */\nexport interface RowsNote {\n assetId: DocId\n /** DAM configuration of the queues the rows are in. */\n configName: string\n rows: Map<UploadQueueItem, EditableFields>\n}\n\n/**\n * Which rows a settle function targets: queues of the named DAM configuration, or of the configuration of `queueKey`.\n * Required because two DAMs may share an asset id.\n */\nexport type UploadQueueRowsOf = string | { queueKey: UploadQueueKey }\n\n/** What a write left as the user had changed it: these fields and these custom data keys. */\ninterface KeptByWrite {\n fields: Set<'keywords' | 'authors' | 'mainFileSingleUse'>\n customKeys: Set<string>\n}\n\n/**\n * Writes the saved detail into a row of its asset. Each row gets its own copies.\n * A field the user changed since `was` (the row when save was pressed)\n * keeps the user's value. Custom data keys are compared one by one.\n * A row unknown to `was` (it became a row of the asset meanwhile)\n * takes everything. `mainFileSingleUse` undefined is left as is.\n * Returns what it kept.\n */\nconst writeUnchanged = (item: UploadQueueItem, was: EditableFields | undefined, saved: EditableFields) => {\n const kept: KeptByWrite = { fields: new Set(), customKeys: new Set() }\n const unchanged = (field: 'keywords' | 'authors' | 'mainFileSingleUse') => {\n if (!was || sameValue(item[field], was[field])) return true\n kept.fields.add(field)\n return false\n }\n if (unchanged('keywords')) item.keywords = [...saved.keywords]\n if (unchanged('authors')) item.authors = [...saved.authors]\n const customData = cloneDeep(saved.customData)\n if (was && customData) {\n const now = item.customData ?? {}\n const then = was.customData ?? {}\n new Set([...Object.keys(now), ...Object.keys(then)]).forEach((key) => {\n if (sameValue(now[key], then[key])) return\n kept.customKeys.add(key)\n if (key in now) customData[key] = cloneDeep(now[key])\n else delete customData[key]\n })\n }\n item.customData = customData\n if (isUndefined(saved.mainFileSingleUse)) kept.fields.add('mainFileSingleUse')\n else if (unchanged('mainFileSingleUse')) item.mainFileSingleUse = saved.mainFileSingleUse\n return kept\n}\n\n/**\n * Another pending save of the same asset takes over what a write just put into `item`.\n * That value is not a user change. Otherwise the later save would keep the earlier save's values.\n */\nconst takeWrite = (note: RowsNote, item: UploadQueueItem, kept: KeptByWrite) => {\n const entry = note.rows.get(item)\n if (!entry) return\n if (!kept.fields.has('keywords')) entry.keywords = [...item.keywords]\n if (!kept.fields.has('authors')) entry.authors = [...item.authors]\n if (!kept.fields.has('mainFileSingleUse')) entry.mainFileSingleUse = item.mainFileSingleUse\n const written = item.customData ?? {}\n const noted = (entry.customData = { ...entry.customData })\n new Set([...Object.keys(written), ...Object.keys(noted)]).forEach((key) => {\n if (kept.customKeys.has(key)) return\n if (key in written) noted[key] = cloneDeep(written[key])\n else delete noted[key]\n })\n}\n\nexport const useUploadQueuesStore = defineStore('commonAdminUploadQueuesStore', () => {\n const queues = ref<Map<UploadQueueKey, UploadQueue>>(new Map())\n\n const { createDefault } = useUploadQueueItemFactory()\n\n // The DAM configuration each queue was created under. Its files are sent\n // and its rows read with that configuration's client and endpoints.\n // A queue without a given name uses `default`.\n const configNames = new Map<UploadQueueKey, string>()\n const configOf = (queueKey?: UploadQueueKey) =>\n (isUndefined(queueKey) ? undefined : configNames.get(queueKey)) ?? 'default'\n // Resolved per request, from the queue it is for.\n const damOf = (queueKey?: UploadQueueKey) => useCommonAdminCoreDamOptions(configOf(queueKey))\n\n // The poll repeats while a row waits. The settlement decides per request\n // whether a failure starts a streak, and only that one is reported.\n\n // A missing asset is an answer the settlement counts. Anything else is a failed read.\n const readAsset = async (assetId: DocId, options?: UploadReadOptions) => {\n const { damClient, endPointAsset } = damOf(options?.queueKey)\n try {\n return options?.report === false\n ? await fetchAsset(damClient, endPointAsset, assetId, { report: false })\n : await fetchAsset(damClient, endPointAsset, assetId)\n } catch (error) {\n if (apiErrorStatus(error) === 404) return null\n throw error\n }\n }\n\n // The list request reports nothing by itself. A reported failure is\n // rethrown as reported, so the settlement can check whether it was logged.\n const readAssets = async (licenceId: IntegerId, assetIds: DocId[], options?: UploadReadOptions) => {\n const { damClient, endPointAsset } = damOf(options?.queueKey)\n try {\n return await fetchAssetListByIds(damClient, endPointAsset, assetIds, licenceId)\n } catch (failure) {\n if (options?.report) {\n // An answer without an asset list is rejected like the failed answers.\n const answer = isArray<{ status?: number; config?: AxiosRequestConfig }>(failure) ? failure.at(-1) : undefined\n const url = `${endPointAsset}/licence/${licenceId}/ids/${assetIds.join(',')}`\n const context = {\n system: SYSTEM_CORE_DAM,\n entity: ENTITY,\n // The URL as sent, with the client's base address, when axios kept the config.\n url: requestedUrl(damClient, url, {}, failure, answer?.config),\n }\n const error = isArray(failure) ? new AnzuApiResponseCodeError(answer?.status ?? 0) : failure\n throw report(mapApiError(error, context), context)\n }\n throw failure\n }\n }\n\n // Handles a row once its file is on the server. The queue poll,\n // notifications and the refresh button all go through here.\n // The core counts the queue, starts the next row after a final\n // state, and keeps failed rows a refresh may still change.\n const profile: UploadQueueSettlementProfile = {\n roleOf: (row) => (row.type === UploadQueueItemType.Asset ? UploadRowRole.Copy : UploadRowRole.Upload),\n policyFor: () => ({ reader: 'asset', settleOn: 'read', duplicate: 'becomeOriginal', metadata: 'load' }),\n // Matched by asset only, whatever file an event names.\n matches: (row, target) => row.assetId === target.assetId,\n readers: {\n asset: readAsset,\n assets: readAssets,\n duplicateOriginAsset: async (originFileId, options) => {\n const { damClient, endPointAsset } = damOf(options?.queueKey)\n return fetchAssetByFileId(damClient, endPointAsset, originFileId)\n },\n failureReported: apiErrorIsReported,\n },\n // Two DAMs may use the same asset id, so rows are settled only within the queues of their configuration.\n configOf,\n // Names of a queue's rows come from the DAM of its configuration.\n caches: {\n addAuthors: (ids, queueKey) => useDamCachedAuthors(configOf(queueKey)).addToCachedAuthors(ids),\n addKeywords: (ids, queueKey) => useDamCachedKeywords(configOf(queueKey)).addToCachedKeywords(ids),\n fetchAuthors: (queueKey) => useDamCachedAuthors(configOf(queueKey)).fetchCachedAuthors(),\n fetchKeywords: (queueKey) => useDamCachedKeywords(configOf(queueKey)).fetchCachedKeywords(),\n },\n messages: {\n processingTooLong: () => commonT('common.damImage.uploadErrors.processingTooLong'),\n readFailed: () => commonT('common.damImage.uploadErrors.readFailed'),\n assetMissing: () => commonT('common.damImage.uploadErrors.unknownError'),\n assetGone: () => commonT('common.damImage.queueItem.assetGone'),\n },\n // Uses the socket of the queue's configuration. A configuration without a socket is polled more often.\n connection: {\n isPushAlive: (queueKey) => useDamNotificationsConnection(configOf(queueKey)).isPushAlive(),\n onChange: useDamNotificationsConnection().onChange,\n },\n }\n\n // Created in the store's scope, so a disposed store leaves no poll timer and no tab or socket listener.\n const core = createUploadQueueCore(libraryQueuePreset({ queues, settlement: profile, configOf }))\n const { settlement } = core\n\n // A queue key belongs to one widget and so to one configuration. A queue with\n // rows refuses another configuration name instead of sending under its own.\n // The name is set together with the row, with no await in between.\n // Of two overlapping adds, the first row in the queue sets the name.\n function addRowUnder(queueKey: UploadQueueKey, configName: string, item: UploadQueueItem) {\n const known = configNames.get(queueKey)\n if (!isUndefined(known) && known !== configName && core.getQueueItems(queueKey).length > 0) {\n throw new Error(\n `useUploadQueuesStore: the queue \"${queueKey}\" has rows under the DAM configuration \"${known}\", none is added under \"${configName}\".`\n )\n }\n configNames.set(queueKey, configName)\n core.addRow(queueKey, item)\n }\n\n const storeScope = getCurrentScope()\n\n // The file a notification names is dropped. Rows match by asset only,\n // and a read for a non-main file would take that file's state unchecked.\n // `configNames`: configurations of the socket it came through. Only their queues are affected.\n const toSettlementEvent = (event: DamNotification, configNames: string[]): UploadSettlementEvent | null => {\n switch (event.name) {\n case DamNotificationName.AssetFileProcessed:\n return { kind: 'processed', assetId: event.data.asset, fileId: null, configNames }\n case DamNotificationName.AssetFileFailed:\n return {\n kind: 'failed',\n assetId: event.data.asset,\n fileId: null,\n failReason: event.data.failReason,\n configNames,\n }\n case DamNotificationName.AssetFileDuplicate:\n return {\n kind: 'duplicate',\n assetId: event.data.asset,\n fileId: null,\n originAssetFile: event.data.originAssetFile,\n assetType: event.data.assetType,\n configNames,\n }\n case DamNotificationName.AssetMetadataProcessed:\n return { kind: 'metadata', assetId: event.data.asset, fileId: null, configNames }\n case DamNotificationName.AssetFileCopied:\n return { kind: 'copied', assetId: event.data.asset, fileId: null, configNames }\n }\n return null\n }\n\n const { addDamNotificationListener } = useDamNotifications()\n // Starts with the first row, not with the store. An application with its own queue store\n // keeps this one alive too, and both would answer every notification. Never removed.\n let listening = false\n function listenToNotifications() {\n if (listening) return\n listening = true\n // Listens on every socket of the page. An event concerns only the queues of its socket's configurations.\n const listen = () =>\n addDamNotificationListener(\n (event, origin) => {\n const settlementEvent = toSettlementEvent(event, origin)\n // Not awaited: the read it triggers happens later.\n if (settlementEvent) void settlement.notify(settlementEvent)\n },\n { all: true }\n )\n // Run in the store's scope. The first row is added from a component,\n // and a listener in that component's scope would be disposed with it.\n if (storeScope) storeScope.run(listen)\n else listen()\n }\n\n async function addByCopyToLicence(\n queueKey: UploadQueueKey,\n extSystem: IntegerId,\n assetLicence: IntegerId,\n assets: DocId[],\n configName: string\n ) {\n // Throws here for an unknown configuration, before anything is done, so its DAM config store is not created.\n useCommonAdminCoreDamOptions(configName)\n const { getDamConfigExtSystem } = useDamConfigState(undefined, configName)\n\n const configExtSystem = getDamConfigExtSystem(extSystem)\n if (isUndefined(configExtSystem)) {\n throw new Error('useUploadQueuesStore.addByCopyToLicence: Ext system must be initialised.')\n }\n listenToNotifications()\n for (const assetId of assets) {\n const queueItem = createDefault(\n core.uniqueKey('asset_' + assetId),\n UploadQueueItemType.Asset,\n UploadQueueItemStatus.Processing,\n DamAssetType.Image, // only image now\n UPLOAD_QUEUE_ITEM_CHUNK_SIZE,\n assetLicence\n )\n queueItem.assetId = assetId\n addRowUnder(queueKey, configName, queueItem)\n // Nothing is uploaded for a copy. It waits for the server from the start.\n const added = core.getQueueItems(queueKey).at(-1)\n if (added) core.track(queueKey, added)\n }\n }\n\n async function addByFiles(\n queueKey: UploadQueueKey,\n extSystem: IntegerId,\n assetLicence: IntegerId,\n files: File[],\n configName: string\n ) {\n // Throws here for an unknown configuration, before anything is done, so its DAM config store is not created.\n useCommonAdminCoreDamOptions(configName)\n const { getDamConfigExtSystem } = useDamConfigState(undefined, configName)\n\n const configExtSystem = getDamConfigExtSystem(extSystem)\n if (isUndefined(configExtSystem)) {\n throw new Error('useUploadQueuesStore.addByFiles: Ext system must be initialised.')\n }\n listenToNotifications()\n for await (const file of files) {\n const type = getAssetTypeByMimeType(damFileTypeFix(file), configExtSystem)\n if (!type || type !== DamAssetType.Image) continue // only image now\n const queueItem = createDefault(\n core.uniqueKey('file_' + file.name),\n UploadQueueItemType.File,\n UploadQueueItemStatus.Waiting,\n type,\n UPLOAD_QUEUE_ITEM_CHUNK_SIZE,\n assetLicence\n )\n queueItem.file = file\n queueItem.displayTitle = file.name\n addRowUnder(queueKey, configName, queueItem)\n }\n }\n\n // Legacy names kept for callers until the queues are unified. `of`:\n // whose rows they settle, read with that configuration's client.\n\n const targetOf = (assetId: DocId, of: UploadQueueRowsOf) => ({\n assetId,\n fileId: null,\n configNames: [isString(of) ? of : configOf(of.queueKey)],\n })\n\n function queueItemProcessed(assetId: DocId, of: UploadQueueRowsOf) {\n return settlement.notify({ kind: 'processed', ...targetOf(assetId, of) })\n }\n\n function queueItemFullyProcessed(assetId: DocId, of: UploadQueueRowsOf) {\n return settlement.settleKnownProcessed(targetOf(assetId, of), { withMetadata: true })\n }\n\n function queueItemDuplicate(\n assetId: DocId,\n originAssetFile: DocIdNullable,\n assetType: DamAssetTypeType | null,\n of: UploadQueueRowsOf\n ) {\n return settlement.settleKnownDuplicate(targetOf(assetId, of), originAssetFile, assetType)\n }\n\n async function queueItemFailed(assetId: DocId, failReason: AssetFileFailReasonType, of: UploadQueueRowsOf) {\n settlement.settleKnownFailed(targetOf(assetId, of), failReason)\n }\n\n /** Row refresh button: reads the file's current state and settles the asset's rows by it. */\n function refreshAsset(assetId: DocId, of: UploadQueueRowsOf): Promise<UploadRefreshOutcome> {\n return settlement.refreshAsset(targetOf(assetId, of))\n }\n\n async function stopItemUpload(queueKey: UploadQueueKey, queueItem: UploadQueueItem, _index?: number) {\n core.stopItemUpload(queueKey, queueItem)\n }\n\n // Pending detail-save writes per configuration and asset. Only the latest one writes.\n // Otherwise overlapping saves left rows with whichever read\n // answered last, and the later save kept the earlier values.\n // Two DAMs may share an asset id, so saves under two configurations concern two assets.\n const detailWrites = new Map<string, number>()\n const detailWriteKey = (configName: string, assetId: DocId) => `${configName}\\u0000${assetId}`\n // Write numbers come from one global counter and are never reused.\n // A per-asset counter let a third save reuse the first save's\n // number, and the first save's late read wrote over the third.\n let lastDetailWrite = 0\n\n // Notes of pending detail saves. A write updates the other notes.\n const openNotes = new Set<RowsNote>()\n\n /**\n * Snapshots the rows of `assetId` in every queue of `configName`, field by field, when a detail save is pressed.\n * Pass it to `updateFromDetail` on success or to `forgetRowsNote` on failure.\n */\n function noteRowsOfAsset(assetId: DocId, configName: string): RowsNote {\n const rows = new Map<UploadQueueItem, EditableFields>()\n queues.value.forEach((queue, queueKey) => {\n if (configOf(queueKey) !== configName) return\n queue.items.forEach((item) => {\n if (item.assetId === assetId && item.type) rows.set(item, editableFieldsOf(item))\n })\n })\n const note = { assetId, configName, rows }\n openNotes.add(note)\n return note\n }\n\n /** The save for this note failed. Nothing is written from it. */\n function forgetRowsNote(note: RowsNote) {\n openNotes.delete(note)\n }\n\n /**\n * `kept`: what the write into `item` left as the user had it.\n * Every other note of that asset and configuration takes the rest.\n */\n const othersTakeWrite = (own: RowsNote, item: UploadQueueItem, kept: KeptByWrite) => {\n openNotes.forEach((note) => {\n if (note === own || note.assetId !== own.assetId) return\n if (note.configName === own.configName) takeWrite(note, item, kept)\n })\n }\n\n /**\n * `configName`: the DAM configuration the detail was saved under.\n * Only its queues are written, and names go to its caches.\n * `mainFileSingleUse`: the switch saved with the detail. `rowsAtSave`: the\n * rows when save was pressed (`noteRowsOfAsset`); current rows if omitted.\n * A field the user changed since keeps the user's value, custom data\n * keys each on their own. Unchanged fields take the saved values.\n * Of two concurrent writes of one asset under one configuration, only the later one writes.\n */\n async function updateFromDetail(\n asset: AssetDetailItemDto,\n configName: string,\n mainFileSingleUse?: boolean | null,\n rowsAtSave?: RowsNote\n ) {\n const { updateNewNames, getAuthorConflicts } = useAssetSuggestions()\n let dam: ReturnType<typeof useCommonAdminCoreDamOptions>\n try {\n dam = useCommonAdminCoreDamOptions(configName)\n } catch (e) {\n // Unknown configuration name: rows are left alone silently.\n return\n }\n const { addToCachedKeywords, fetchCachedKeywords } = useDamCachedKeywords(configName)\n const { addToCachedAuthors, fetchCachedAuthors } = useDamCachedAuthors(configName)\n // Only this configuration's queues: another DAM may have an asset with the same id.\n const queuesOfConfig = () =>\n Array.from(queues.value.entries()).filter(([queueKey]) => configOf(queueKey) === configName)\n // A detail opened from a row keeps notifying the queue even when no queue has a row of the\n // asset. Then there is nothing to write, and the save would wait for the read in vain.\n const rows = queuesOfConfig().flatMap(([, queue]) => queue.items)\n const isRowOfAsset = (item: UploadQueueItem) => item.assetId === asset.id && !!item.type\n // A processing row may become a row of the asset during the read,\n // when its file turns out to be a duplicate of the asset's file.\n // It gets the write like any row of the asset, since the asset was not read while no row had it.\n // The DAM detects duplicates only within the file's licence, so rows of another licence are excluded.\n const mayBecomeRowOfAsset = (item: UploadQueueItem) =>\n !!item.type && item.status === UploadQueueItemStatus.Processing && item.licenceId === asset.licence\n if (!rows.some(isRowOfAsset) && !rows.some(mayBecomeRowOfAsset)) {\n if (rowsAtSave) forgetRowsNote(rowsAtSave)\n return\n }\n const note = rowsAtSave ?? noteRowsOfAsset(asset.id, configName)\n const before = note.rows\n const turn = ++lastDetailWrite\n const writeKey = detailWriteKey(configName, asset.id)\n detailWrites.set(writeKey, turn)\n // A later save of this asset under this configuration started its write since. That one writes.\n const isLatest = () => detailWrites.get(writeKey) === turn\n try {\n const assetRes = await fetchAsset(dam.damClient, dam.endPointAsset, asset.id)\n if (!isLatest()) return\n // One answer serves the asset's rows in every queue of the configuration, but each row gets its own copies.\n // Filling a custom field writes into custom data in place, so a shared\n // object would change another queue's row and that queue would send it.\n queuesOfConfig().forEach(([queueKey, queue]) => {\n queue.items.forEach((item) => {\n if (item.assetId === assetRes.id && item.type) {\n // The detail saves the switch too. Left unchanged, the next queue save would send the old value.\n const kept = writeUnchanged(item, before.get(item), {\n keywords: assetRes.keywords,\n authors: assetRes.authors,\n customData: assetRes.metadata.customData,\n mainFileSingleUse: assetRes.mainFileSingleUse,\n })\n othersTakeWrite(note, item, kept)\n updateNewNames(assetRes.metadata.authorSuggestions, queue.suggestions.newAuthorNames)\n updateNewNames(assetRes.metadata.keywordSuggestions, queue.suggestions.newKeywordNames)\n item.authorConflicts = getAuthorConflicts(assetRes.metadata.authorSuggestions)\n addToCachedKeywords(item.keywords)\n addToCachedAuthors(item.authors)\n addToCachedAuthors(item.authorConflicts)\n }\n })\n core.recalculateQueueCounts(queueKey)\n fetchCachedAuthors()\n fetchCachedKeywords()\n })\n } catch (e) {\n if (!isLatest()) return\n // The detail is saved anyway. Unchanged rows would send their\n // old values with the next queue save, over the detail's values.\n // Each row gets its own copies, not the detail's lists.\n // Suggestions come from the server and stay as the rows have them.\n queuesOfConfig().forEach(([, queue]) => {\n queue.items.forEach((item) => {\n if (item.assetId === asset.id && item.type) {\n const kept = writeUnchanged(item, before.get(item), {\n keywords: asset.keywords,\n authors: asset.authors,\n customData: asset.metadata.customData,\n mainFileSingleUse: isUndefined(mainFileSingleUse) ? undefined : mainFileSingleUse,\n })\n othersTakeWrite(note, item, kept)\n addToCachedKeywords(item.keywords)\n addToCachedAuthors(item.authors)\n }\n })\n })\n fetchCachedAuthors()\n fetchCachedKeywords()\n } finally {\n forgetRowsNote(note)\n if (isLatest()) detailWrites.delete(writeKey)\n }\n }\n\n return {\n getQueue: core.getQueue,\n getQueueItems: core.getQueueItems,\n addByFiles,\n addByCopyToLicence,\n queueItemProcessed,\n queueItemFullyProcessed,\n queueItemDuplicate,\n queueItemFailed,\n refreshAsset,\n /**\n * Whether a refresh may still change a failed row. True when its finish request went out before the client gave\n * up and the server has said nothing final since, or when it is a duplicate whose original could not be read.\n */\n refreshMayHelp: core.refreshMayHelp,\n /** The row failed because its asset was missing from enough reads (\"Asset už neexistuje.\"). */\n isGivenUpMissing: (item: UploadQueueItem) => settlement.isGivenUpMissing(item),\n removeByIndex: core.removeByIndex,\n stopItemUpload,\n getQueueTotalCount: core.getQueueTotalCount,\n getQueueProcessedCount: core.getQueueProcessedCount,\n stopUpload: core.stopUpload,\n getQueueItemsTypes: core.getQueueItemsTypes,\n updateFromDetail,\n noteRowsOfAsset,\n forgetRowsNote,\n forceReloadFileInput: core.forceReloadFileInput,\n }\n})\n"],"mappings":";;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AAC;EACH,QAAY;GACV,IAAI,CAACP,EAAS,GAAG;GAqBjB,AAhBAN,EAAe,CAAC,CAAC,SAAS,GAAGP,OAAW;IACtC,EAAM,MAAM,SAAS,MAAS;KAC5B,IAAIxH,EAAK,YAAYgI,EAAM,MAAMhI,EAAK,MAAM;MAC1C,IAAMK,IAAOD,EAAeJ,GAAMkI,EAAO,IAAIlI,CAAI,GAAG;OAClD,UAAUgI,EAAM;OAChB,SAASA,EAAM;OACf,YAAYA,EAAM,SAAS;OAC3B,mBAAmBlH,EAAY+H,CAAiB,IAAI,KAAA,IAAYA;MAClE,CAAC;MAGD,AAFAnB,EAAgBzG,GAAMjB,GAAMK,CAAI,GAChCoI,EAAoBzI,EAAK,QAAQ,GACjC0I,EAAmB1I,EAAK,OAAO;KACjC;IACF,CAAC;GACH,CAAC,GACD2I,EAAmB,GACnBC,EAAoB;EACtB,UAAU;GAER,AADAnB,EAAexG,CAAI,GACfoH,EAAS,KAAGnB,EAAa,OAAOkB,CAAQ;EAC9C;CACF;CAEA,OAAO;EACL,UAAUpE,EAAK;EACf,eAAeA,EAAK;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EAKA,gBAAgBA,EAAK;EAErB,mBAAmB,MAA0BkB,EAAW,iBAAiBlF,CAAI;EAC7E,eAAegE,EAAK;EACpB;EACA,oBAAoBA,EAAK;EACzB,wBAAwBA,EAAK;EAC7B,YAAYA,EAAK;EACjB,oBAAoBA,EAAK;EACzB;EACA;EACA;EACA,sBAAsBA,EAAK;CAC7B;AACF,CAAC"}
1
+ {"version":3,"file":"uploadQueuesStore.js","names":["editableFieldsOf","cloneDeep","item","sameValue","one","other","writeUnchanged","kept","unchanged","was","field","saved","customData","now","then","key","isUndefined","takeWrite","entry","note","written","noted","useUploadQueuesStore","defineStore","queues","ref","useUploadQueueItemFactory","configNames","configOf","queueKey","damOf","useCommonAdminCoreDamOptions","profile","row","UploadQueueItemType","UploadRowRole","target","options","fetchAsset","damClient","endPointAsset","assetId","error","apiErrorStatus","fetchAssetListByIds","assetIds","licenceId","failure","answer","isArray","url","context","SYSTEM_CORE_DAM","ENTITY","requestedUrl","AnzuApiResponseCodeError","report","mapApiError","fetchAssetByFileId","originFileId","apiErrorIsReported","useDamCachedAuthors","ids","useDamCachedKeywords","commonT","useDamNotificationsConnection","core","createUploadQueueCore","libraryQueuePreset","addRowUnder","known","configName","storeScope","getCurrentScope","toSettlementEvent","event","DamNotificationName","useDamNotifications","listening","listenToNotifications","listen","addDamNotificationListener","settlementEvent","origin","settlement","addByCopyToLicence","useDamConfigState","configExtSystem","getDamConfigExtSystem","extSystem","assets","queueItem","createDefault","UploadQueueItemStatus","DamAssetType","UPLOAD_QUEUE_ITEM_CHUNK_SIZE","assetLicence","added","addByFiles","file","files","type","getAssetTypeByMimeType","damFileTypeFix","targetOf","isString","of","queueItemProcessed","queueItemFullyProcessed","queueItemDuplicate","originAssetFile","assetType","queueItemFailed","failReason","refreshAsset","stopItemUpload","detailWrites","detailWriteKey","lastDetailWrite","openNotes","noteRowsOfAsset","rows","queue","forgetRowsNote","othersTakeWrite","own","updateFromDetail","useAssetSuggestions","dam","queuesOfConfig","asset","rowsAtSave","before","turn","writeKey","isLatest","assetRes","updateNewNames","getAuthorConflicts","addToCachedKeywords","addToCachedAuthors","fetchCachedAuthors","fetchCachedKeywords","mainFileSingleUse"],"sources":["../../../../../src/domains/dam/uploadQueue/store/uploadQueuesStore.ts"],"sourcesContent":["import { requestedUrl } from '@/domains/api/composables/request'\nimport { apiErrorIsReported, apiErrorStatus, mapApiError, report } from '@/domains/api/utils/apiErrors'\nimport { useCommonAdminCoreDamOptions } from '@/domains/dam/composables/commonAdminCoreDamOptions'\nimport { ENTITY, fetchAsset, fetchAssetByFileId, fetchAssetListByIds } from '@/domains/dam/api/damAssetApi'\nimport { SYSTEM_CORE_DAM } from '@/domains/dam/api/damConstants'\nimport { useDamCachedAuthors } from '@/domains/dam/author/composables/cachedAuthors'\nimport { useUploadQueueItemFactory } from '@/domains/dam/uploadQueue/factory/UploadQueueItemFactory'\nimport { useAssetSuggestions } from '@/domains/dam/uploadQueue/composables/assetSuggestions'\nimport { useDamConfigState } from '@/domains/dam/config/composables/damConfigState'\nimport { useDamNotifications } from '@/domains/dam/composables/damNotifications'\nimport { useDamNotificationsConnection } from '@/domains/dam/composables/damNotificationsConnection'\nimport { type DamNotification, DamNotificationName } from '@/domains/dam/composables/damNotificationsEventBus'\nimport { getAssetTypeByMimeType } from '@/domains/dam/uploadQueue/utils/mimeTypeHelper'\nimport { createUploadQueueCore, UPLOAD_QUEUE_ITEM_CHUNK_SIZE } from '@/domains/dam/uploadQueue/core/uploadQueueCore'\nimport type { UploadQueueSettlementProfile } from '@/domains/dam/uploadQueue/core/uploadQueueCoreTypes'\nimport { libraryQueuePreset } from '@/domains/dam/uploadQueue/presets/queuePresets'\nimport {\n type UploadReadOptions,\n type UploadRefreshOutcome,\n UploadRowRole,\n type UploadSettlementEvent,\n} from '@/domains/dam/uploadQueue/settlement/uploadSettlementTypes'\nimport { useDamCachedKeywords } from '@/domains/dam/keyword/composables/cachedKeywords'\nimport { damFileTypeFix } from '@/domains/ui/file/utils/fileType'\nimport type { AxiosRequestConfig } from 'axios'\nimport type { DocId, DocIdNullable, IntegerId } from '@/shared/types/common'\nimport { type AssetDetailItemDto, DamAssetType, type DamAssetTypeType } from '@/domains/dam/types/Asset'\nimport type { AssetFileFailReasonType } from '@/domains/dam/types/AssetFile'\nimport {\n type UploadQueue,\n type UploadQueueItem,\n UploadQueueItemStatus,\n UploadQueueItemType,\n type UploadQueueKey,\n} from '@/domains/dam/types/UploadQueue'\nimport { AnzuApiResponseCodeError } from '@/shared/error/AnzuApiResponseCodeError'\nimport { cloneDeep, isArray, isString, isUndefined } from '@/shared/utils/common'\nimport { commonT } from '@/plugins/i18n'\nimport { defineStore } from 'pinia'\nimport { getCurrentScope, ref } from 'vue'\n\n/** Fields the user edits and a detail save writes. */\nexport interface EditableFields {\n keywords: DocId[]\n authors: DocId[]\n sources: DocId[]\n customData: UploadQueueItem['customData']\n mainFileSingleUse: boolean | null | undefined\n}\n\nconst editableFieldsOf = (item: UploadQueueItem): EditableFields =>\n cloneDeep({\n keywords: item.keywords,\n authors: item.authors,\n sources: item.sources,\n customData: item.customData,\n mainFileSingleUse: item.mainFileSingleUse,\n })\n\nconst sameValue = (one: unknown, other: unknown) => JSON.stringify(one) === JSON.stringify(other)\n\n/** Field-by-field snapshot of an asset's rows (`noteRowsOfAsset`). */\nexport interface RowsNote {\n assetId: DocId\n /** DAM configuration of the queues the rows are in. */\n configName: string\n rows: Map<UploadQueueItem, EditableFields>\n}\n\n/**\n * Which rows a settle function targets: queues of the named DAM configuration, or of the configuration of `queueKey`.\n * Required because two DAMs may share an asset id.\n */\nexport type UploadQueueRowsOf = string | { queueKey: UploadQueueKey }\n\n/** What a write left as the user had changed it: these fields and these custom data keys. */\ninterface KeptByWrite {\n fields: Set<'keywords' | 'authors' | 'sources' | 'mainFileSingleUse'>\n customKeys: Set<string>\n}\n\n/**\n * Writes the saved detail into a row of its asset. Each row gets its own copies.\n * A field the user changed since `was` (the row when save was pressed)\n * keeps the user's value. Custom data keys are compared one by one.\n * A row unknown to `was` (it became a row of the asset meanwhile)\n * takes everything. `mainFileSingleUse` undefined is left as is.\n * Returns what it kept.\n */\nconst writeUnchanged = (item: UploadQueueItem, was: EditableFields | undefined, saved: EditableFields) => {\n const kept: KeptByWrite = { fields: new Set(), customKeys: new Set() }\n const unchanged = (field: 'keywords' | 'authors' | 'sources' | 'mainFileSingleUse') => {\n if (!was || sameValue(item[field], was[field])) return true\n kept.fields.add(field)\n return false\n }\n if (unchanged('keywords')) item.keywords = [...saved.keywords]\n if (unchanged('authors')) item.authors = [...saved.authors]\n if (unchanged('sources')) item.sources = [...(saved.sources ?? [])]\n const customData = cloneDeep(saved.customData)\n if (was && customData) {\n const now = item.customData ?? {}\n const then = was.customData ?? {}\n new Set([...Object.keys(now), ...Object.keys(then)]).forEach((key) => {\n if (sameValue(now[key], then[key])) return\n kept.customKeys.add(key)\n if (key in now) customData[key] = cloneDeep(now[key])\n else delete customData[key]\n })\n }\n item.customData = customData\n if (isUndefined(saved.mainFileSingleUse)) kept.fields.add('mainFileSingleUse')\n else if (unchanged('mainFileSingleUse')) item.mainFileSingleUse = saved.mainFileSingleUse\n return kept\n}\n\n/**\n * Another pending save of the same asset takes over what a write just put into `item`.\n * That value is not a user change. Otherwise the later save would keep the earlier save's values.\n */\nconst takeWrite = (note: RowsNote, item: UploadQueueItem, kept: KeptByWrite) => {\n const entry = note.rows.get(item)\n if (!entry) return\n if (!kept.fields.has('keywords')) entry.keywords = [...item.keywords]\n if (!kept.fields.has('authors')) entry.authors = [...item.authors]\n if (!kept.fields.has('sources')) entry.sources = [...(item.sources ?? [])]\n if (!kept.fields.has('mainFileSingleUse')) entry.mainFileSingleUse = item.mainFileSingleUse\n const written = item.customData ?? {}\n const noted = (entry.customData = { ...entry.customData })\n new Set([...Object.keys(written), ...Object.keys(noted)]).forEach((key) => {\n if (kept.customKeys.has(key)) return\n if (key in written) noted[key] = cloneDeep(written[key])\n else delete noted[key]\n })\n}\n\nexport const useUploadQueuesStore = defineStore('commonAdminUploadQueuesStore', () => {\n const queues = ref<Map<UploadQueueKey, UploadQueue>>(new Map())\n\n const { createDefault } = useUploadQueueItemFactory()\n\n // The DAM configuration each queue was created under. Its files are sent\n // and its rows read with that configuration's client and endpoints.\n // A queue without a given name uses `default`.\n const configNames = new Map<UploadQueueKey, string>()\n const configOf = (queueKey?: UploadQueueKey) =>\n (isUndefined(queueKey) ? undefined : configNames.get(queueKey)) ?? 'default'\n // Resolved per request, from the queue it is for.\n const damOf = (queueKey?: UploadQueueKey) => useCommonAdminCoreDamOptions(configOf(queueKey))\n\n // The poll repeats while a row waits. The settlement decides per request\n // whether a failure starts a streak, and only that one is reported.\n\n // A missing asset is an answer the settlement counts. Anything else is a failed read.\n const readAsset = async (assetId: DocId, options?: UploadReadOptions) => {\n const { damClient, endPointAsset } = damOf(options?.queueKey)\n try {\n return options?.report === false\n ? await fetchAsset(damClient, endPointAsset, assetId, { report: false })\n : await fetchAsset(damClient, endPointAsset, assetId)\n } catch (error) {\n if (apiErrorStatus(error) === 404) return null\n throw error\n }\n }\n\n // The list request reports nothing by itself. A reported failure is\n // rethrown as reported, so the settlement can check whether it was logged.\n const readAssets = async (licenceId: IntegerId, assetIds: DocId[], options?: UploadReadOptions) => {\n const { damClient, endPointAsset } = damOf(options?.queueKey)\n try {\n return await fetchAssetListByIds(damClient, endPointAsset, assetIds, licenceId)\n } catch (failure) {\n if (options?.report) {\n // An answer without an asset list is rejected like the failed answers.\n const answer = isArray<{ status?: number; config?: AxiosRequestConfig }>(failure) ? failure.at(-1) : undefined\n const url = `${endPointAsset}/licence/${licenceId}/ids/${assetIds.join(',')}`\n const context = {\n system: SYSTEM_CORE_DAM,\n entity: ENTITY,\n // The URL as sent, with the client's base address, when axios kept the config.\n url: requestedUrl(damClient, url, {}, failure, answer?.config),\n }\n const error = isArray(failure) ? new AnzuApiResponseCodeError(answer?.status ?? 0) : failure\n throw report(mapApiError(error, context), context)\n }\n throw failure\n }\n }\n\n // Handles a row once its file is on the server. The queue poll,\n // notifications and the refresh button all go through here.\n // The core counts the queue, starts the next row after a final\n // state, and keeps failed rows a refresh may still change.\n const profile: UploadQueueSettlementProfile = {\n roleOf: (row) => (row.type === UploadQueueItemType.Asset ? UploadRowRole.Copy : UploadRowRole.Upload),\n policyFor: () => ({ reader: 'asset', settleOn: 'read', duplicate: 'becomeOriginal', metadata: 'load' }),\n // Matched by asset only, whatever file an event names.\n matches: (row, target) => row.assetId === target.assetId,\n readers: {\n asset: readAsset,\n assets: readAssets,\n duplicateOriginAsset: async (originFileId, options) => {\n const { damClient, endPointAsset } = damOf(options?.queueKey)\n return fetchAssetByFileId(damClient, endPointAsset, originFileId)\n },\n failureReported: apiErrorIsReported,\n },\n // Two DAMs may use the same asset id, so rows are settled only within the queues of their configuration.\n configOf,\n // Names of a queue's rows come from the DAM of its configuration.\n caches: {\n addAuthors: (ids, queueKey) => useDamCachedAuthors(configOf(queueKey)).addToCachedAuthors(ids),\n addKeywords: (ids, queueKey) => useDamCachedKeywords(configOf(queueKey)).addToCachedKeywords(ids),\n fetchAuthors: (queueKey) => useDamCachedAuthors(configOf(queueKey)).fetchCachedAuthors(),\n fetchKeywords: (queueKey) => useDamCachedKeywords(configOf(queueKey)).fetchCachedKeywords(),\n },\n messages: {\n processingTooLong: () => commonT('common.damImage.uploadErrors.processingTooLong'),\n readFailed: () => commonT('common.damImage.uploadErrors.readFailed'),\n assetMissing: () => commonT('common.damImage.uploadErrors.unknownError'),\n assetGone: () => commonT('common.damImage.queueItem.assetGone'),\n },\n // Uses the socket of the queue's configuration. A configuration without a socket is polled more often.\n connection: {\n isPushAlive: (queueKey) => useDamNotificationsConnection(configOf(queueKey)).isPushAlive(),\n onChange: useDamNotificationsConnection().onChange,\n },\n }\n\n // Created in the store's scope, so a disposed store leaves no poll timer and no tab or socket listener.\n const core = createUploadQueueCore(libraryQueuePreset({ queues, settlement: profile, configOf }))\n const { settlement } = core\n\n // A queue key belongs to one widget and so to one configuration. A queue with\n // rows refuses another configuration name instead of sending under its own.\n // The name is set together with the row, with no await in between.\n // Of two overlapping adds, the first row in the queue sets the name.\n function addRowUnder(queueKey: UploadQueueKey, configName: string, item: UploadQueueItem) {\n const known = configNames.get(queueKey)\n if (!isUndefined(known) && known !== configName && core.getQueueItems(queueKey).length > 0) {\n throw new Error(\n `useUploadQueuesStore: the queue \"${queueKey}\" has rows under the DAM configuration \"${known}\", none is added under \"${configName}\".`\n )\n }\n configNames.set(queueKey, configName)\n core.addRow(queueKey, item)\n }\n\n const storeScope = getCurrentScope()\n\n // The file a notification names is dropped. Rows match by asset only,\n // and a read for a non-main file would take that file's state unchecked.\n // `configNames`: configurations of the socket it came through. Only their queues are affected.\n const toSettlementEvent = (event: DamNotification, configNames: string[]): UploadSettlementEvent | null => {\n switch (event.name) {\n case DamNotificationName.AssetFileProcessed:\n return { kind: 'processed', assetId: event.data.asset, fileId: null, configNames }\n case DamNotificationName.AssetFileFailed:\n return {\n kind: 'failed',\n assetId: event.data.asset,\n fileId: null,\n failReason: event.data.failReason,\n configNames,\n }\n case DamNotificationName.AssetFileDuplicate:\n return {\n kind: 'duplicate',\n assetId: event.data.asset,\n fileId: null,\n originAssetFile: event.data.originAssetFile,\n assetType: event.data.assetType,\n configNames,\n }\n case DamNotificationName.AssetMetadataProcessed:\n return { kind: 'metadata', assetId: event.data.asset, fileId: null, configNames }\n case DamNotificationName.AssetFileCopied:\n return { kind: 'copied', assetId: event.data.asset, fileId: null, configNames }\n }\n return null\n }\n\n const { addDamNotificationListener } = useDamNotifications()\n // Starts with the first row, not with the store. An application with its own queue store\n // keeps this one alive too, and both would answer every notification. Never removed.\n let listening = false\n function listenToNotifications() {\n if (listening) return\n listening = true\n // Listens on every socket of the page. An event concerns only the queues of its socket's configurations.\n const listen = () =>\n addDamNotificationListener(\n (event, origin) => {\n const settlementEvent = toSettlementEvent(event, origin)\n // Not awaited: the read it triggers happens later.\n if (settlementEvent) void settlement.notify(settlementEvent)\n },\n { all: true }\n )\n // Run in the store's scope. The first row is added from a component,\n // and a listener in that component's scope would be disposed with it.\n if (storeScope) storeScope.run(listen)\n else listen()\n }\n\n async function addByCopyToLicence(\n queueKey: UploadQueueKey,\n extSystem: IntegerId,\n assetLicence: IntegerId,\n assets: DocId[],\n configName: string\n ) {\n // Throws here for an unknown configuration, before anything is done, so its DAM config store is not created.\n useCommonAdminCoreDamOptions(configName)\n const { getDamConfigExtSystem } = useDamConfigState(undefined, configName)\n\n const configExtSystem = getDamConfigExtSystem(extSystem)\n if (isUndefined(configExtSystem)) {\n throw new Error('useUploadQueuesStore.addByCopyToLicence: Ext system must be initialised.')\n }\n listenToNotifications()\n for (const assetId of assets) {\n const queueItem = createDefault(\n core.uniqueKey('asset_' + assetId),\n UploadQueueItemType.Asset,\n UploadQueueItemStatus.Processing,\n DamAssetType.Image, // only image now\n UPLOAD_QUEUE_ITEM_CHUNK_SIZE,\n assetLicence\n )\n queueItem.assetId = assetId\n addRowUnder(queueKey, configName, queueItem)\n // Nothing is uploaded for a copy. It waits for the server from the start.\n const added = core.getQueueItems(queueKey).at(-1)\n if (added) core.track(queueKey, added)\n }\n }\n\n async function addByFiles(\n queueKey: UploadQueueKey,\n extSystem: IntegerId,\n assetLicence: IntegerId,\n files: File[],\n configName: string\n ) {\n // Throws here for an unknown configuration, before anything is done, so its DAM config store is not created.\n useCommonAdminCoreDamOptions(configName)\n const { getDamConfigExtSystem } = useDamConfigState(undefined, configName)\n\n const configExtSystem = getDamConfigExtSystem(extSystem)\n if (isUndefined(configExtSystem)) {\n throw new Error('useUploadQueuesStore.addByFiles: Ext system must be initialised.')\n }\n listenToNotifications()\n for await (const file of files) {\n const type = getAssetTypeByMimeType(damFileTypeFix(file), configExtSystem)\n if (!type || type !== DamAssetType.Image) continue // only image now\n const queueItem = createDefault(\n core.uniqueKey('file_' + file.name),\n UploadQueueItemType.File,\n UploadQueueItemStatus.Waiting,\n type,\n UPLOAD_QUEUE_ITEM_CHUNK_SIZE,\n assetLicence\n )\n queueItem.file = file\n queueItem.displayTitle = file.name\n addRowUnder(queueKey, configName, queueItem)\n }\n }\n\n // Legacy names kept for callers until the queues are unified. `of`:\n // whose rows they settle, read with that configuration's client.\n\n const targetOf = (assetId: DocId, of: UploadQueueRowsOf) => ({\n assetId,\n fileId: null,\n configNames: [isString(of) ? of : configOf(of.queueKey)],\n })\n\n function queueItemProcessed(assetId: DocId, of: UploadQueueRowsOf) {\n return settlement.notify({ kind: 'processed', ...targetOf(assetId, of) })\n }\n\n function queueItemFullyProcessed(assetId: DocId, of: UploadQueueRowsOf) {\n return settlement.settleKnownProcessed(targetOf(assetId, of), { withMetadata: true })\n }\n\n function queueItemDuplicate(\n assetId: DocId,\n originAssetFile: DocIdNullable,\n assetType: DamAssetTypeType | null,\n of: UploadQueueRowsOf\n ) {\n return settlement.settleKnownDuplicate(targetOf(assetId, of), originAssetFile, assetType)\n }\n\n async function queueItemFailed(assetId: DocId, failReason: AssetFileFailReasonType, of: UploadQueueRowsOf) {\n settlement.settleKnownFailed(targetOf(assetId, of), failReason)\n }\n\n /** Row refresh button: reads the file's current state and settles the asset's rows by it. */\n function refreshAsset(assetId: DocId, of: UploadQueueRowsOf): Promise<UploadRefreshOutcome> {\n return settlement.refreshAsset(targetOf(assetId, of))\n }\n\n async function stopItemUpload(queueKey: UploadQueueKey, queueItem: UploadQueueItem, _index?: number) {\n core.stopItemUpload(queueKey, queueItem)\n }\n\n // Pending detail-save writes per configuration and asset. Only the latest one writes.\n // Otherwise overlapping saves left rows with whichever read\n // answered last, and the later save kept the earlier values.\n // Two DAMs may share an asset id, so saves under two configurations concern two assets.\n const detailWrites = new Map<string, number>()\n const detailWriteKey = (configName: string, assetId: DocId) => `${configName}\\u0000${assetId}`\n // Write numbers come from one global counter and are never reused.\n // A per-asset counter let a third save reuse the first save's\n // number, and the first save's late read wrote over the third.\n let lastDetailWrite = 0\n\n // Notes of pending detail saves. A write updates the other notes.\n const openNotes = new Set<RowsNote>()\n\n /**\n * Snapshots the rows of `assetId` in every queue of `configName`, field by field, when a detail save is pressed.\n * Pass it to `updateFromDetail` on success or to `forgetRowsNote` on failure.\n */\n function noteRowsOfAsset(assetId: DocId, configName: string): RowsNote {\n const rows = new Map<UploadQueueItem, EditableFields>()\n queues.value.forEach((queue, queueKey) => {\n if (configOf(queueKey) !== configName) return\n queue.items.forEach((item) => {\n if (item.assetId === assetId && item.type) rows.set(item, editableFieldsOf(item))\n })\n })\n const note = { assetId, configName, rows }\n openNotes.add(note)\n return note\n }\n\n /** The save for this note failed. Nothing is written from it. */\n function forgetRowsNote(note: RowsNote) {\n openNotes.delete(note)\n }\n\n /**\n * `kept`: what the write into `item` left as the user had it.\n * Every other note of that asset and configuration takes the rest.\n */\n const othersTakeWrite = (own: RowsNote, item: UploadQueueItem, kept: KeptByWrite) => {\n openNotes.forEach((note) => {\n if (note === own || note.assetId !== own.assetId) return\n if (note.configName === own.configName) takeWrite(note, item, kept)\n })\n }\n\n /**\n * `configName`: the DAM configuration the detail was saved under.\n * Only its queues are written, and names go to its caches.\n * `mainFileSingleUse`: the switch saved with the detail. `rowsAtSave`: the\n * rows when save was pressed (`noteRowsOfAsset`); current rows if omitted.\n * A field the user changed since keeps the user's value, custom data\n * keys each on their own. Unchanged fields take the saved values.\n * Of two concurrent writes of one asset under one configuration, only the later one writes.\n */\n async function updateFromDetail(\n asset: AssetDetailItemDto,\n configName: string,\n mainFileSingleUse?: boolean | null,\n rowsAtSave?: RowsNote\n ) {\n const { updateNewNames, getAuthorConflicts } = useAssetSuggestions()\n let dam: ReturnType<typeof useCommonAdminCoreDamOptions>\n try {\n dam = useCommonAdminCoreDamOptions(configName)\n } catch (e) {\n // Unknown configuration name: rows are left alone silently.\n return\n }\n const { addToCachedKeywords, fetchCachedKeywords } = useDamCachedKeywords(configName)\n const { addToCachedAuthors, fetchCachedAuthors } = useDamCachedAuthors(configName)\n // Only this configuration's queues: another DAM may have an asset with the same id.\n const queuesOfConfig = () =>\n Array.from(queues.value.entries()).filter(([queueKey]) => configOf(queueKey) === configName)\n // A detail opened from a row keeps notifying the queue even when no queue has a row of the\n // asset. Then there is nothing to write, and the save would wait for the read in vain.\n const rows = queuesOfConfig().flatMap(([, queue]) => queue.items)\n const isRowOfAsset = (item: UploadQueueItem) => item.assetId === asset.id && !!item.type\n // A processing row may become a row of the asset during the read,\n // when its file turns out to be a duplicate of the asset's file.\n // It gets the write like any row of the asset, since the asset was not read while no row had it.\n // The DAM detects duplicates only within the file's licence, so rows of another licence are excluded.\n const mayBecomeRowOfAsset = (item: UploadQueueItem) =>\n !!item.type && item.status === UploadQueueItemStatus.Processing && item.licenceId === asset.licence\n if (!rows.some(isRowOfAsset) && !rows.some(mayBecomeRowOfAsset)) {\n if (rowsAtSave) forgetRowsNote(rowsAtSave)\n return\n }\n const note = rowsAtSave ?? noteRowsOfAsset(asset.id, configName)\n const before = note.rows\n const turn = ++lastDetailWrite\n const writeKey = detailWriteKey(configName, asset.id)\n detailWrites.set(writeKey, turn)\n // A later save of this asset under this configuration started its write since. That one writes.\n const isLatest = () => detailWrites.get(writeKey) === turn\n try {\n const assetRes = await fetchAsset(dam.damClient, dam.endPointAsset, asset.id)\n if (!isLatest()) return\n // One answer serves the asset's rows in every queue of the configuration, but each row gets its own copies.\n // Filling a custom field writes into custom data in place, so a shared\n // object would change another queue's row and that queue would send it.\n queuesOfConfig().forEach(([queueKey, queue]) => {\n queue.items.forEach((item) => {\n if (item.assetId === assetRes.id && item.type) {\n // The detail saves the switch too. Left unchanged, the next queue save would send the old value.\n const kept = writeUnchanged(item, before.get(item), {\n keywords: assetRes.keywords,\n authors: assetRes.authors,\n sources: assetRes.sources,\n customData: assetRes.metadata.customData,\n mainFileSingleUse: assetRes.mainFileSingleUse,\n })\n othersTakeWrite(note, item, kept)\n updateNewNames(assetRes.metadata.authorSuggestions, queue.suggestions.newAuthorNames)\n updateNewNames(assetRes.metadata.keywordSuggestions, queue.suggestions.newKeywordNames)\n item.authorConflicts = getAuthorConflicts(assetRes.metadata.authorSuggestions)\n addToCachedKeywords(item.keywords)\n addToCachedAuthors(item.authors)\n addToCachedAuthors(item.sources)\n addToCachedAuthors(item.authorConflicts)\n }\n })\n core.recalculateQueueCounts(queueKey)\n fetchCachedAuthors()\n fetchCachedKeywords()\n })\n } catch (e) {\n if (!isLatest()) return\n // The detail is saved anyway. Unchanged rows would send their\n // old values with the next queue save, over the detail's values.\n // Each row gets its own copies, not the detail's lists.\n // Suggestions come from the server and stay as the rows have them.\n queuesOfConfig().forEach(([, queue]) => {\n queue.items.forEach((item) => {\n if (item.assetId === asset.id && item.type) {\n const kept = writeUnchanged(item, before.get(item), {\n keywords: asset.keywords,\n authors: asset.authors,\n sources: asset.sources,\n customData: asset.metadata.customData,\n mainFileSingleUse: isUndefined(mainFileSingleUse) ? undefined : mainFileSingleUse,\n })\n othersTakeWrite(note, item, kept)\n addToCachedKeywords(item.keywords)\n addToCachedAuthors(item.authors)\n addToCachedAuthors(item.sources)\n }\n })\n })\n fetchCachedAuthors()\n fetchCachedKeywords()\n } finally {\n forgetRowsNote(note)\n if (isLatest()) detailWrites.delete(writeKey)\n }\n }\n\n return {\n getQueue: core.getQueue,\n getQueueItems: core.getQueueItems,\n addByFiles,\n addByCopyToLicence,\n queueItemProcessed,\n queueItemFullyProcessed,\n queueItemDuplicate,\n queueItemFailed,\n refreshAsset,\n /**\n * Whether a refresh may still change a failed row. True when its finish request went out before the client gave\n * up and the server has said nothing final since, or when it is a duplicate whose original could not be read.\n */\n refreshMayHelp: core.refreshMayHelp,\n /** The row failed because its asset was missing from enough reads (\"Asset už neexistuje.\"). */\n isGivenUpMissing: (item: UploadQueueItem) => settlement.isGivenUpMissing(item),\n removeByIndex: core.removeByIndex,\n stopItemUpload,\n getQueueTotalCount: core.getQueueTotalCount,\n getQueueProcessedCount: core.getQueueProcessedCount,\n stopUpload: core.stopUpload,\n getQueueItemsTypes: core.getQueueItemsTypes,\n updateFromDetail,\n noteRowsOfAsset,\n forgetRowsNote,\n forceReloadFileInput: core.forceReloadFileInput,\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAMA,MAAoB,MACxBC,EAAU;CACR,UAAUC,EAAK;CACf,SAASA,EAAK;CACd,SAASA,EAAK;CACd,YAAYA,EAAK;CACjB,mBAAmBA,EAAK;AAC1B,CAAC,GAEGC,KAAa,GAAc,MAAmB,KAAK,UAAUC,CAAG,MAAM,KAAK,UAAUC,CAAK,GA8B1FC,KAAkB,GAAuB,GAAiC,MAA0B;CACxG,IAAMC,IAAoB;EAAE,wBAAQ,IAAI,IAAI;EAAG,4BAAY,IAAI,IAAI;CAAE,GAC/DC,KAAa,MACb,CAACC,KAAON,EAAUD,EAAKQ,IAAQD,EAAIC,EAAM,IAAU,MACvDH,EAAK,OAAO,IAAIG,CAAK,GACd;CAIT,AAFIF,EAAU,UAAU,MAAG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AM;OAChB,SAASA,EAAM;OACf,SAASA,EAAM;OACf,YAAYA,EAAM,SAAS;OAC3B,mBAAmBlH,EAAY+H,CAAiB,IAAI,KAAA,IAAYA;MAClE,CAAC;MAID,AAHAnB,EAAgBzG,GAAMjB,GAAMK,CAAI,GAChCoI,EAAoBzI,EAAK,QAAQ,GACjC0I,EAAmB1I,EAAK,OAAO,GAC/B0I,EAAmB1I,EAAK,OAAO;KACjC;IACF,CAAC;GACH,CAAC,GACD2I,EAAmB,GACnBC,EAAoB;EACtB,UAAU;GAER,AADAnB,EAAexG,CAAI,GACfoH,EAAS,KAAGnB,EAAa,OAAOkB,CAAQ;EAC9C;CACF;CAEA,OAAO;EACL,UAAUpE,EAAK;EACf,eAAeA,EAAK;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EAKA,gBAAgBA,EAAK;EAErB,mBAAmB,MAA0BkB,EAAW,iBAAiBlF,CAAI;EAC7E,eAAegE,EAAK;EACpB;EACA,oBAAoBA,EAAK;EACzB,wBAAwBA,EAAK;EAC7B,YAAYA,EAAK;EACjB,oBAAoBA,EAAK;EACzB;EACA;EACA;EACA,sBAAsBA,EAAK;CAC7B;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ADatatableSidePanel.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_renderSlot","_normalizeStyle","_withDirectives","_createVNode","_component_VBtn","_unref","_withModifiers","_directive_tooltip","_hoisted_1","_hoisted_2","_hoisted_3","ADatatableSidePanel_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","useI18n","listRef","useTemplateRef","bodyRef","revealSelectedRow","nextTick","watch","open","useEventListener","event","openBlock","createElementBlock","createElementVNode","renderSlot","_ctx","normalizeStyle","withDirectives","createVNode","VBtn","unref","t","_cache","withModifiers","Tooltip","createCommentVNode"],"sources":["../../../../../src/domains/filters/datatable/components/ADatatableSidePanel.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { useEventListener } from '@vueuse/core'\nimport { nextTick, useTemplateRef, watch } from 'vue'\nimport { useI18n } from 'vue-i18n'\n\nconst props = withDefaults(\n defineProps<{\n /** Whether the panel shows; `isOpen` of `useDatatableSidePanel`. */\n open: boolean\n /** Panel width in px; `width` of `useDatatableSidePanel`. */\n width: number\n /** The shown record; when it changes, its text scrolls back to the top. */\n itemKey?: unknown\n /** The selected row in the list, scrolled into view when the panel narrows the list. */\n selectedRowSelector?: string\n }>(),\n {\n itemKey: undefined,\n selectedRowSelector: '.tr--selected',\n }\n)\nconst emit = defineEmits<{\n (e: 'close'): void\n}>()\n\nconst { t } = useI18n()\n\nconst listRef = useTemplateRef<HTMLElement>('listRef')\nconst bodyRef = useTemplateRef<HTMLElement>('bodyRef')\n\nconst revealSelectedRow = async () => {\n await nextTick()\n listRef.value?.querySelector(props.selectedRowSelector)?.scrollIntoView({ block: 'nearest' })\n}\n\nwatch(\n () => props.itemKey,\n async () => {\n if (!props.open) return\n await nextTick()\n bodyRef.value?.scrollTo({ top: 0 })\n await revealSelectedRow()\n }\n)\n\nwatch(\n () => props.open,\n (open) => {\n if (open) void revealSelectedRow()\n }\n)\n\n// Esc closes the panel, unless it closes a dialog or a menu first: that overlay is still active when the key reaches the document.\nuseEventListener(document, 'keydown', (event: KeyboardEvent) => {\n if (!props.open || event.key !== 'Escape' || event.defaultPrevented) return\n if (document.querySelector('.v-dialog.v-overlay--active, .v-menu.v-overlay--active')) return\n emit('close')\n})\n</script>\n\n<template>\n <div class=\"a-datatable-side-panel\">\n <div\n ref=\"listRef\"\n class=\"a-datatable-side-panel__list\"\n >\n <slot />\n </div>\n <aside\n v-if=\"open\"\n class=\"a-datatable-side-panel__panel\"\n :style=\"{ width: `${width}px`, flexBasis: `${width}px` }\"\n >\n <div class=\"a-datatable-side-panel__header\">\n <div class=\"a-datatable-side-panel__header-content\">\n <slot name=\"header\" />\n </div>\n <VBtn\n v-tooltip=\"t('common.button.close')\"\n :aria-label=\"t('common.button.close')\"\n icon=\"mdi-close\"\n variant=\"text\"\n size=\"small\"\n class=\"a-datatable-side-panel__close\"\n @click.stop=\"emit('close')\"\n />\n </div>\n <div\n ref=\"bodyRef\"\n class=\"a-datatable-side-panel__body\"\n >\n <slot name=\"panel\" />\n </div>\n </aside>\n </div>\n</template>\n\n<style lang=\"scss\">\n// The list narrows next to the panel; the panel stays in the window while the list scrolls,\n// and only its body scrolls, so the header with the actions stays in view.\n.a-datatable-side-panel {\n display: flex;\n align-items: flex-start;\n gap: 1rem;\n min-width: 0;\n\n &__list {\n flex: 1 1 auto;\n min-width: 0;\n }\n\n &__panel {\n position: sticky;\n top: var(--v-layout-top, 0);\n flex: 0 0 auto;\n display: flex;\n flex-direction: column;\n height: calc(100dvh - var(--v-layout-top, 0px) - var(--v-layout-bottom, 0px));\n border-left: thin solid rgb(var(--v-border-color), var(--v-border-opacity));\n }\n\n &__header {\n flex: 0 0 auto;\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n padding: 0.75rem 0.5rem 0.75rem 1rem;\n border-bottom: thin solid rgb(var(--v-border-color), var(--v-border-opacity));\n }\n\n &__header-content {\n flex: 1 1 auto;\n min-width: 0;\n }\n\n &__close {\n flex: 0 0 auto;\n }\n\n &__body {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n padding: 1rem;\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;EAKA,IAAMgB,IAAQC,GAgBRC,IAAOH,GAIP,EAAE,SAAMI,EAAQ,GAEhBC,IAAUC,EAA4B,SAAS,GAC/CC,IAAUD,EAA4B,SAAS,GAE/CE,IAAoB,YAAY;GAEpC,AADA,MAAMC,EAAS,GACfJ,EAAQ,OAAO,cAAcJ,EAAM,mBAAmB,CAAC,EAAE,eAAe,EAAE,OAAO,UAAU,CAAC;EAC9F;E,OAEAS,QACQT,EAAM,SACZ,YAAY;GACV,AAAKA,EAAM,SACX,MAAMQ,EAAS,GACfF,EAAQ,OAAO,SAAS,EAAE,KAAK,EAAE,CAAC,GAClC,MAAMC,EAAkB;EAC1B,CACF,GAEAE,QACQT,EAAM,OACX,MAAS;GACR,AAAIU,KAAMH,EAAuB;EACnC,CACF,GAGAI,EAAiB,UAAU,YAAY,MAAyB;GAC9D,AAAKX,EAAM,QAAQY,EAAM,QAAQ,YAAY,GAAM,qBAC/C,SAAS,cAAc,wDAAwD,KACnFV,EAAK,OAAO;EACd,CAAC,I,UAIClB,EAAA,GAAAC,EAiCM,OAjCNU,GAiCM,CAhCJT,EAKM,OAAA;GAJA,SAAA;GAAJ,KAAIkB;GACJ,OAAM;E,IAENjB,EAAQ8B,EAAA,QAAA,SAAA,C,SAGFhB,EAAA,QADRjB,EAAA,GAAAC,EAyBQ,SAAA;;GAvBN,OAAM;GACL,OAAKG,EAAA;IAAA,OAAA,GAAca,EAAA,MAAK;IAAA,WAAA,GAAoBA,EAAA,MAAK;GAAA,CAAA;E,IAElDf,EAaM,OAbNU,GAaM,CAZJV,EAEM,OAFNW,GAEM,CADJV,EAAsB8B,EAAA,QAAA,QAAA,C,IAExB5B,EAAAC,EAQEC,GAAA;GANC,cAAYC,EAAA+B,CAAA,CAAC,CAAA,qBAAA;GACd,MAAK;GACL,SAAQ;GACR,MAAK;GACL,OAAM;GACL,SAAK,AAAAC,EAAA,OAAA/B,GAAA,MAAOS,EAAI,OAAA,GAAA,CAAA,MAAA,CAAA;E,8BANN,CAAAR,GAAAF,EAAA+B,CAAA,CAAC,CAAA,qBAAA,CAAA,C,MAShBrC,EAKM,OAAA;GAJA,SAAA;GAAJ,KAAIoB;GACJ,OAAM;E,IAENnB,EAAqB8B,EAAA,QAAA,OAAA,C"}
1
+ {"version":3,"file":"ADatatableSidePanel.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_renderSlot","_normalizeStyle","_withDirectives","_createVNode","_component_VBtn","_unref","_withModifiers","_directive_tooltip","_hoisted_1","_hoisted_2","_hoisted_3","ADatatableSidePanel_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","useI18n","listRef","useTemplateRef","bodyRef","revealSelectedRow","nextTick","watch","open","useEventListener","event","openBlock","createElementBlock","createElementVNode","renderSlot","_ctx","normalizeStyle","withDirectives","createVNode","VBtn","unref","t","_cache","withModifiers","Tooltip","createCommentVNode"],"sources":["../../../../../src/domains/filters/datatable/components/ADatatableSidePanel.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { useEventListener } from '@vueuse/core'\nimport { nextTick, useTemplateRef, watch } from 'vue'\nimport { useI18n } from 'vue-i18n'\n\nconst props = withDefaults(\n defineProps<{\n /** Whether the panel shows; `isOpen` of `useDatatableSidePanel`. */\n open: boolean\n /** Panel width in px; `width` of `useDatatableSidePanel`. */\n width: number\n /** The shown record; when it changes, its text scrolls back to the top. */\n itemKey?: unknown\n /** The selected row in the list, scrolled into view when the panel narrows the list. */\n selectedRowSelector?: string\n }>(),\n {\n itemKey: undefined,\n selectedRowSelector: '.tr--selected',\n }\n)\nconst emit = defineEmits<{\n (e: 'close'): void\n}>()\n\nconst { t } = useI18n()\n\nconst listRef = useTemplateRef<HTMLElement>('listRef')\nconst bodyRef = useTemplateRef<HTMLElement>('bodyRef')\n\nconst revealSelectedRow = async () => {\n await nextTick()\n listRef.value?.querySelector(props.selectedRowSelector)?.scrollIntoView({ block: 'nearest' })\n}\n\nwatch(\n () => props.itemKey,\n async () => {\n if (!props.open) return\n await nextTick()\n bodyRef.value?.scrollTo({ top: 0 })\n await revealSelectedRow()\n }\n)\n\nwatch(\n () => props.open,\n (open) => {\n if (open) void revealSelectedRow()\n }\n)\n\n// Esc closes the panel, unless it closes a dialog or a menu first: that overlay is still active when the key reaches the document.\nuseEventListener(document, 'keydown', (event: KeyboardEvent) => {\n if (!props.open || event.key !== 'Escape' || event.defaultPrevented) return\n if (document.querySelector('.v-dialog.v-overlay--active, .v-menu.v-overlay--active')) return\n emit('close')\n})\n</script>\n\n<template>\n <div class=\"a-datatable-side-panel\">\n <div\n ref=\"listRef\"\n class=\"a-datatable-side-panel__list\"\n >\n <slot />\n </div>\n <aside\n v-if=\"open\"\n class=\"a-datatable-side-panel__panel\"\n :style=\"{ width: `${width}px`, flexBasis: `${width}px` }\"\n >\n <div class=\"a-datatable-side-panel__header\">\n <div class=\"a-datatable-side-panel__header-content\">\n <slot name=\"header\" />\n </div>\n <VBtn\n v-tooltip=\"t('common.button.close')\"\n :aria-label=\"t('common.button.close')\"\n icon=\"mdi-close\"\n variant=\"text\"\n size=\"small\"\n class=\"a-datatable-side-panel__close\"\n @click.stop=\"emit('close')\"\n />\n </div>\n <div\n ref=\"bodyRef\"\n class=\"a-datatable-side-panel__body\"\n >\n <slot name=\"panel\" />\n </div>\n </aside>\n </div>\n</template>\n\n<style lang=\"scss\">\n// The list narrows next to the panel; the panel stays in the window while the list scrolls,\n// and only its body scrolls, so the header with the actions stays in view.\n.a-datatable-side-panel {\n display: flex;\n align-items: flex-start;\n gap: 1rem;\n min-width: 0;\n\n &__list {\n flex: 1 1 auto;\n min-width: 0;\n }\n\n &__panel {\n position: sticky;\n top: var(--v-layout-top, 0);\n flex: 0 0 auto;\n display: flex;\n flex-direction: column;\n height: calc(100dvh - var(--v-layout-top, 0px) - var(--v-layout-bottom, 0px));\n border-left: thin solid rgb(var(--v-border-color), var(--v-border-opacity));\n }\n\n &__header {\n flex: 0 0 auto;\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n padding: 0.75rem 0.5rem 0.75rem 1rem;\n border-bottom: thin solid rgb(var(--v-border-color), var(--v-border-opacity));\n }\n\n &__header-content {\n flex: 1 1 auto;\n min-width: 0;\n }\n\n &__close {\n flex: 0 0 auto;\n }\n\n &__body {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n padding: 1rem;\n }\n}\n\n// A card around the list clips with overflow: hidden, which keeps the panel from sticking; clip cuts the same edges.\n.v-card:has(.a-datatable-side-panel__panel) {\n overflow: clip;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;EAKA,IAAMgB,IAAQC,GAgBR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AAC,CAAA,qBAAA,CAAA,C,MAShBrC,EAKM,OAAA;GAJA,SAAA;GAAJ,KAAIoB;GACJ,OAAM;E,IAENnB,EAAqB8B,EAAA,QAAA,OAAA,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"ALiveListingPill.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createBlock","_component_VBtn","_withModifiers","_withCtx","_createTextVNode","_toDisplayString","_unref","_component_VChip","_hoisted_1","ALiveListingPill_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","useI18n","text","computed","overflow","count","t","openBlock","createElementBlock","createBlock","VBtn","_cache","withModifiers","withCtx","createTextVNode","toDisplayString","unref","VChip","createCommentVNode"],"sources":["../../../../../src/domains/filters/datatable/components/ALiveListingPill.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useI18n } from 'vue-i18n'\n\nconst props = withDefaults(\n defineProps<{\n count: number\n max?: number\n failed?: boolean\n /** Records already listed changed: the pill offers a reload while nothing new is counted. */\n changed?: boolean\n /** New records are looked for less promptly than usual, e.g. while backend signals are down. */\n degraded?: boolean\n /** Key with the plural forms `1 | 2–4 | 5+`; `{count}` is the number, or `max+` above `max`. */\n textKey?: string\n }>(),\n {\n max: 9,\n failed: false,\n changed: false,\n degraded: false,\n textKey: 'common.system.datatable.liveListing.newRecords',\n }\n)\nconst emit = defineEmits<{\n (e: 'click'): void\n}>()\n\nconst { t } = useI18n()\n\nconst text = computed(() => {\n const overflow = props.count > props.max\n const count = overflow ? `${props.max}+` : props.count\n return t(props.textKey, { count }, overflow ? props.max + 1 : props.count)\n})\n</script>\n\n<template>\n <div class=\"a-live-listing-pill\">\n <!-- An offered reload stays clickable after a failed probe: the click loads the list anyway. -->\n <VBtn\n v-if=\"count > 0\"\n color=\"primary\"\n size=\"small\"\n rounded=\"pill\"\n prepend-icon=\"mdi-arrow-up\"\n class=\"a-live-listing-pill__item\"\n @click.stop=\"emit('click')\"\n >\n {{ text }}\n </VBtn>\n <VBtn\n v-else-if=\"changed\"\n color=\"primary\"\n size=\"small\"\n rounded=\"pill\"\n prepend-icon=\"mdi-refresh\"\n class=\"a-live-listing-pill__item\"\n @click.stop=\"emit('click')\"\n >\n {{ t('common.system.datatable.liveListing.changes') }}\n </VBtn>\n <VChip\n v-else-if=\"failed\"\n color=\"warning\"\n variant=\"flat\"\n size=\"small\"\n prepend-icon=\"mdi-alert-outline\"\n class=\"a-live-listing-pill__item\"\n >\n {{ t('common.system.datatable.liveListing.failed') }}\n </VChip>\n <VChip\n v-else-if=\"degraded\"\n color=\"warning\"\n variant=\"flat\"\n size=\"small\"\n prepend-icon=\"mdi-lan-disconnect\"\n class=\"a-live-listing-pill__item\"\n >\n {{ t('common.system.datatable.liveListing.degraded') }}\n </VChip>\n </div>\n</template>\n\n<style lang=\"scss\">\n// Floats over the top of the list and stays there while it scrolls; it takes no height, so no row moves.\n.a-live-listing-pill {\n position: sticky;\n top: calc(var(--v-layout-top, 0px) + 0.25rem);\n z-index: 3;\n display: flex;\n justify-content: center;\n height: 0;\n overflow: visible;\n\n &__item {\n margin-top: 0.25rem;\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAIA,IAAMa,IAAQC,GAoBRC,IAAOH,GAIP,EAAE,SAAMI,EAAQ,GAEhBC,IAAOC,QAAe;GAC1B,IAAMC,IAAWN,EAAM,QAAQA,EAAM,KAC/BO,IAAQD,IAAW,GAAGN,EAAM,IAAI,KAAKA,EAAM;GACjD,OAAOQ,EAAER,EAAM,SAAS,EAAE,SAAM,GAAGM,IAAWN,EAAM,MAAM,IAAIA,EAAM,KAAK;EAC3E,CAAC;E,kBAICb,EAAA,GAAAC,EA4CM,OA5CNS,GA4CM,CAzCII,EAAA,QAAK,KADbd,EAAA,GAAAE,EAUOC,GAAA;;GARL,OAAM;GACN,MAAK;GACL,SAAQ;GACR,gBAAa;GACb,OAAM;GACL,SAAK,AAAAuB,EAAA,OAAAtB,GAAA,MAAOW,EAAI,OAAA,GAAA,CAAA,MAAA,CAAA;;GAEjB,SAAAV,QAAU,CAAPC,EAAAC,EAAAU,EAAA,KAAI,GAAA,CAAA,C;;E,MAGIH,EAAA,WADbd,EAAA,GAAAE,EAUOC,GAAA;;GARL,OAAM;GACN,MAAK;GACL,SAAQ;GACR,gBAAa;GACb,OAAM;GACL,SAAK,AAAAuB,EAAA,OAAAtB,GAAA,MAAOW,EAAI,OAAA,GAAA,CAAA,MAAA,CAAA;;GAEjB,SAAAV,QAAsD,CAAnDC,EAAAC,EAAAC,EAAAa,CAAA,CAAC,CAAA,6CAAA,CAAA,GAAA,CAAA,C;;E,MAGOP,EAAA,UADbd,EAAA,GAAAE,EASQO,GAAA;;GAPN,OAAM;GACN,SAAQ;GACR,MAAK;GACL,gBAAa;GACb,OAAM;;GAEN,SAAAJ,QAAqD,CAAlDC,EAAAC,EAAAC,EAAAa,CAAA,CAAC,CAAA,4CAAA,CAAA,GAAA,CAAA,C;;E,MAGOP,EAAA,YADbd,EAAA,GAAAE,EASQO,GAAA;;GAPN,OAAM;GACN,SAAQ;GACR,MAAK;GACL,gBAAa;GACb,OAAM;;GAEN,SAAAJ,QAAuD,CAApDC,EAAAC,EAAAC,EAAAa,CAAA,CAAC,CAAA,8CAAA,CAAA,GAAA,CAAA,C"}
1
+ {"version":3,"file":"ALiveListingPill.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createBlock","_component_VBtn","_withModifiers","_withCtx","_createTextVNode","_toDisplayString","_unref","_component_VChip","_hoisted_1","ALiveListingPill_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","useI18n","text","computed","overflow","count","t","openBlock","createElementBlock","createBlock","VBtn","_cache","withModifiers","withCtx","createTextVNode","toDisplayString","unref","VChip","createCommentVNode"],"sources":["../../../../../src/domains/filters/datatable/components/ALiveListingPill.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useI18n } from 'vue-i18n'\n\nconst props = withDefaults(\n defineProps<{\n count: number\n max?: number\n failed?: boolean\n /** Records already listed changed: the pill offers a reload while nothing new is counted. */\n changed?: boolean\n /** New records are looked for less promptly than usual, e.g. while backend signals are down. */\n degraded?: boolean\n /** Key with the plural forms `1 | 2–4 | 5+`; `{count}` is the number, or `max+` above `max`. */\n textKey?: string\n }>(),\n {\n max: 9,\n failed: false,\n changed: false,\n degraded: false,\n textKey: 'common.system.datatable.liveListing.newRecords',\n }\n)\nconst emit = defineEmits<{\n (e: 'click'): void\n}>()\n\nconst { t } = useI18n()\n\nconst text = computed(() => {\n const overflow = props.count > props.max\n const count = overflow ? `${props.max}+` : props.count\n return t(props.textKey, { count }, overflow ? props.max + 1 : props.count)\n})\n</script>\n\n<template>\n <div class=\"a-live-listing-pill\">\n <!-- An offered reload stays clickable after a failed probe: the click loads the list anyway. -->\n <VBtn\n v-if=\"count > 0\"\n color=\"primary\"\n size=\"small\"\n rounded=\"pill\"\n prepend-icon=\"mdi-arrow-up\"\n class=\"a-live-listing-pill__item\"\n @click.stop=\"emit('click')\"\n >\n {{ text }}\n </VBtn>\n <VBtn\n v-else-if=\"changed\"\n color=\"primary\"\n size=\"small\"\n rounded=\"pill\"\n prepend-icon=\"mdi-refresh\"\n class=\"a-live-listing-pill__item\"\n @click.stop=\"emit('click')\"\n >\n {{ t('common.system.datatable.liveListing.changes') }}\n </VBtn>\n <VChip\n v-else-if=\"failed\"\n color=\"warning\"\n variant=\"flat\"\n size=\"small\"\n prepend-icon=\"mdi-alert-outline\"\n class=\"a-live-listing-pill__item\"\n >\n {{ t('common.system.datatable.liveListing.failed') }}\n </VChip>\n <VChip\n v-else-if=\"degraded\"\n color=\"warning\"\n variant=\"flat\"\n size=\"small\"\n prepend-icon=\"mdi-lan-disconnect\"\n class=\"a-live-listing-pill__item\"\n >\n {{ t('common.system.datatable.liveListing.degraded') }}\n </VChip>\n </div>\n</template>\n\n<style lang=\"scss\">\n// Floats over the top of the list and stays there while it scrolls; it takes no height, so no row moves.\n.a-live-listing-pill {\n position: sticky;\n top: calc(var(--v-layout-top, 0px) + 0.25rem);\n z-index: 3;\n display: flex;\n justify-content: center;\n height: 0;\n overflow: visible;\n\n &__item {\n margin-top: 0.25rem;\n }\n}\n\n// A card clips its content with overflow: hidden, which also makes it the box the pill sticks in, so the pill would\n// scroll away with the list; clip cuts the same edges and leaves the pill stuck to the window.\n.v-card:has(.a-live-listing-pill) {\n overflow: clip;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAIA,IAAMa,IAAQC,GAoBRC,IAAOH,GAIP,EAAE,SAAMI,EAAQ,GAEhBC,IAAOC,QAAe;GAC1B,IAAMC,IAAWN,EAAM,QAAQA,EAAM,KAC/BO,IAAQD,IAAW,GAAGN,EAAM,IAAI,KAAKA,EAAM;GACjD,OAAOQ,EAAER,EAAM,SAAS,EAAE,SAAM,GAAGM,IAAWN,EAAM,MAAM,IAAIA,EAAM,KAAK;EAC3E,CAAC;E,kBAICb,EAAA,GAAAC,EA4CM,OA5CNS,GA4CM,CAzCII,EAAA,QAAK,KADbd,EAAA,GAAAE,EAUOC,GAAA;;GARL,OAAM;GACN,MAAK;GACL,SAAQ;GACR,gBAAa;GACb,OAAM;GACL,SAAK,AAAAuB,EAAA,OAAAtB,GAAA,MAAOW,EAAI,OAAA,GAAA,CAAA,MAAA,CAAA;;GAEjB,SAAAV,QAAU,CAAPC,EAAAC,EAAAU,EAAA,KAAI,GAAA,CAAA,C;;E,MAGIH,EAAA,WADbd,EAAA,GAAAE,EAUOC,GAAA;;GARL,OAAM;GACN,MAAK;GACL,SAAQ;GACR,gBAAa;GACb,OAAM;GACL,SAAK,AAAAuB,EAAA,OAAAtB,GAAA,MAAOW,EAAI,OAAA,GAAA,CAAA,MAAA,CAAA;;GAEjB,SAAAV,QAAsD,CAAnDC,EAAAC,EAAAC,EAAAa,CAAA,CAAC,CAAA,6CAAA,CAAA,GAAA,CAAA,C;;E,MAGOP,EAAA,UADbd,EAAA,GAAAE,EASQO,GAAA;;GAPN,OAAM;GACN,SAAQ;GACR,MAAK;GACL,gBAAa;GACb,OAAM;;GAEN,SAAAJ,QAAqD,CAAlDC,EAAAC,EAAAC,EAAAa,CAAA,CAAC,CAAA,4CAAA,CAAA,GAAA,CAAA,C;;E,MAGOP,EAAA,YADbd,EAAA,GAAAE,EASQO,GAAA;;GAPN,OAAM;GACN,SAAQ;GACR,MAAK;GACL,gBAAa;GACb,OAAM;;GAEN,SAAAJ,QAAuD,CAApDC,EAAAC,EAAAC,EAAAa,CAAA,CAAC,CAAA,8CAAA,CAAA,GAAA,CAAA,C"}
@@ -28,6 +28,8 @@ type __VLS_Props = {
28
28
  itemValue?: string;
29
29
  minSearchChars?: number;
30
30
  minSearchText?: string | undefined;
31
+ /** `focus`: searches on focus while nothing is loaded, for short lists offered without typing. */
32
+ prefetch?: 'focus' | false;
31
33
  };
32
34
  type __VLS_ModelProps = {
33
35
  'search'?: string;
@@ -76,6 +78,7 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {
76
78
  key: string;
77
79
  order: import('../../../lib').SortOrderType;
78
80
  } | null;
81
+ prefetch: false | "focus";
79
82
  minSearchChars: number;
80
83
  minSearchText: string;
81
84
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;