Skip to content

Commit

Permalink
rename types
Browse files Browse the repository at this point in the history
  • Loading branch information
volar committed Nov 16, 2023
1 parent 496abd3 commit 6e72793
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 92 deletions.
10 changes: 5 additions & 5 deletions src/composables/system/appNotificationListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useNotification } from '@/composables/system/notifications'
import { useUploadQueuesStore } from '@/stores/coreDam/uploadQueuesStore'
import { updateCurrentUser } from '@/composables/system/currentUser'
import { useDistributionListStore } from '@/stores/coreDam/distributionListStore'
import { DistributionStatus } from '@/model/coreDam/valueObject/DistributionStatus'
import { DamDistributionStatus } from '@/model/coreDam/valueObject/DamDistributionStatus'

export const initAppNotificationListeners = () => {
const { openConnection, addNotificationListener } = useNotification()
Expand Down Expand Up @@ -39,22 +39,22 @@ export const initAppNotificationListeners = () => {
const distributionListStore = useDistributionListStore()
addNotificationListener('distribution_distributing', (message: Event) => {
if (message instanceof CustomEvent) {
distributionListStore.listItemMessageUpdate(message.detail.id, DistributionStatus.Distributing)
distributionListStore.listItemMessageUpdate(message.detail.id, DamDistributionStatus.Distributing)
}
})
addNotificationListener('distribution_remote_processing', (message: Event) => {
if (message instanceof CustomEvent) {
distributionListStore.listItemMessageUpdate(message.detail.id, DistributionStatus.RemoteProcessing)
distributionListStore.listItemMessageUpdate(message.detail.id, DamDistributionStatus.RemoteProcessing)
}
})
addNotificationListener('distribution_distributed', (message: Event) => {
if (message instanceof CustomEvent) {
distributionListStore.listItemMessageUpdate(message.detail.id, DistributionStatus.Distributed)
distributionListStore.listItemMessageUpdate(message.detail.id, DamDistributionStatus.Distributed)
}
})
addNotificationListener('distribution_failed', (message: Event) => {
if (message instanceof CustomEvent) {
distributionListStore.listItemMessageUpdate(message.detail.id, DistributionStatus.Failed)
distributionListStore.listItemMessageUpdate(message.detail.id, DamDistributionStatus.Failed)
}
})
addNotificationListener('distribution_authorized', (message: Event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import type { ValueObjectOption } from '@anzusystems/common-admin'

export enum DistributionStatus {
export enum DamDistributionStatus {
Waiting = 'waiting',
Distributing = 'distributing',
RemoteProcessing = 'remote_processing',
Expand All @@ -14,35 +14,35 @@ export enum DistributionStatus {
export function useDistributionStatus() {
const { t } = useI18n()

const DistributionStatusOptions = ref<ValueObjectOption<DistributionStatus>[]>([
const DistributionStatusOptions = ref<ValueObjectOption<DamDistributionStatus>[]>([
{
value: DistributionStatus.Waiting,
value: DamDistributionStatus.Waiting,
title: t('coreDam.distribution.distributionStatus.waiting'),
color: 'default',
},
{
value: DistributionStatus.Distributing,
value: DamDistributionStatus.Distributing,
title: t('coreDam.distribution.distributionStatus.distributing'),
color: 'warning',
},
{
value: DistributionStatus.RemoteProcessing,
value: DamDistributionStatus.RemoteProcessing,
title: t('coreDam.distribution.distributionStatus.remoteProcessing'),
color: 'primary',
},
{
value: DistributionStatus.Distributed,
value: DamDistributionStatus.Distributed,
title: t('coreDam.distribution.distributionStatus.distributed'),
color: 'success',
},
{
value: DistributionStatus.Failed,
value: DamDistributionStatus.Failed,
title: t('coreDam.distribution.distributionStatus.failed'),
color: 'error',
},
])

const getDistributionStatusOption = (value: DistributionStatus) => {
const getDistributionStatusOption = (value: DamDistributionStatus) => {
return DistributionStatusOptions.value.find((item) => item.value === value)
}

Expand Down
6 changes: 3 additions & 3 deletions src/services/api/coreDam/configurationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { damClient } from '@/services/api/clients/damClient'
import type { IntegerId } from '@anzusystems/common-admin'
import { apiFetchOne } from '@anzusystems/common-admin'
import { SYSTEM_CORE_DAM } from '@/model/systems'
import type { DamConfig, DamConfigExtSystem, DamPubConfig } from '@/types/coreDam/DamConfig'
import type { DamPrvConfig, DamExtSystemConfig, DamPubConfig } from '@/types/coreDam/DamConfig'

const END_POINT = '/adm/v1/configuration'
export const PUB_END_POINT_PREFIX = '/pub'
Expand All @@ -12,7 +12,7 @@ export const ENTITY = 'settings'
export const fetchPubConfiguration = () =>
apiFetchOne<DamPubConfig>(damClient, PUB_END_POINT, {}, SYSTEM_CORE_DAM, ENTITY)

export const fetchConfiguration = () => apiFetchOne<DamConfig>(damClient, END_POINT, {}, SYSTEM_CORE_DAM, ENTITY)
export const fetchConfiguration = () => apiFetchOne<DamPrvConfig>(damClient, END_POINT, {}, SYSTEM_CORE_DAM, ENTITY)

export const fetchExtSystemConfiguration = (extSystem: IntegerId) =>
apiFetchOne<DamConfigExtSystem>(damClient, END_POINT + '/ext-system/' + extSystem, {}, SYSTEM_CORE_DAM, ENTITY)
apiFetchOne<DamExtSystemConfig>(damClient, END_POINT + '/ext-system/' + extSystem, {}, SYSTEM_CORE_DAM, ENTITY)
8 changes: 4 additions & 4 deletions src/stores/coreDam/distributionListStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DistributionCustomItem, DistributionJwItem, DistributionYoutubeIte
import type { DamDistributionServiceName } from '@anzusystems/common-admin'
import type { DocId } from '@anzusystems/common-admin'
import { isNull } from '@anzusystems/common-admin'
import { DistributionStatus } from '@/model/coreDam/valueObject/DistributionStatus'
import { DamDistributionStatus } from '@/model/coreDam/valueObject/DamDistributionStatus'
import { fetchDistribution } from '@/services/api/coreDam/distributionApi'
import type { DistributionAuth } from '@/types/coreDam/DistributionAuth'
import { DistributionAuthStatus } from '@/types/coreDam/DistributionAuth'
Expand Down Expand Up @@ -50,10 +50,10 @@ export const useDistributionListStore = defineStore('damDistributionListStore',
status: success ? DistributionAuthStatus.Success : DistributionAuthStatus.Error,
})
},
async listItemMessageUpdate(distributionId: DocId, status: DistributionStatus) {
async listItemMessageUpdate(distributionId: DocId, status: DamDistributionStatus) {
switch (status) {
case DistributionStatus.Distributing:
case DistributionStatus.RemoteProcessing:
case DamDistributionStatus.Distributing:
case DamDistributionStatus.RemoteProcessing:
{
const foundIndex = this.list.findIndex((item) => item.id === distributionId)
if (foundIndex > -1) {
Expand Down
56 changes: 31 additions & 25 deletions src/types/coreDam/DamConfig.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import type { DamAssetType } from '@/model/coreDam/valueObject/DamAssetType'
import type { DistributionStatus } from '@/model/coreDam/valueObject/DistributionStatus'
import type { DamDistributionStatus } from '@/model/coreDam/valueObject/DamDistributionStatus'
import type { DamDistributionServiceName } from '@anzusystems/common-admin'

export enum DistributionServiceType {
export enum DamDistributionServiceType {
Youtube = 'youtubeDistribution',
Jw = 'jwDistribution',
Custom = 'customDistribution',
}

export interface DamConfig {
export interface DamPrvConfig {
assetExternalProviders: {
[key: string]: { title: string }
}
distributionServices: {
[key: string]: {
title: string
iconPath: string
type: DistributionServiceType
allowedRedistributeStatuses: Array<DistributionStatus>
type: DamDistributionServiceType
allowedRedistributeStatuses: Array<DamDistributionStatus>
}
}
colorSet: {
Expand Down Expand Up @@ -48,57 +48,63 @@ export enum UserAuthType {
Default = JsonCredentials,
}

export type ExternalProviderAssetName = string
export type DamExternalProviderAssetName = string

export type ExternalProviderAssetConfig = Record<ExternalProviderAssetName, { listingLimit: number; title: string }>
export type DamExternalProviderAssetConfig = Record<
DamExternalProviderAssetName,
{
listingLimit: number
title: string
}
>

export interface ExtSystemAssetTypeExifMetadata {
export interface DamExtSystemAssetTypeExifMetadata {
enabled: boolean
required: boolean
}

export interface DistributionRequirementsCategorySelectConfig {
export interface DamDistributionRequirementsCategorySelectConfig {
enabled: boolean
required: boolean
}

export enum DistributionRequirementStrategy {
export enum DamDistributionRequirementStrategy {
None = 'none',
AtLeastOne = 'at_least_one',
OneFromType = 'one_from_type',
WaitForAll = 'wait_for_all',
Default = None,
}

export interface DistributionRequirementsConfig {
export interface DamDistributionRequirementsConfig {
title: string
requiredAuth: boolean
blockedBy: Array<DamDistributionServiceName>
categorySelect: DistributionRequirementsCategorySelectConfig
strategy: DistributionRequirementStrategy
categorySelect: DamDistributionRequirementsCategorySelectConfig
strategy: DamDistributionRequirementStrategy
}

export interface DistributionConfig {
export interface DamDistributionConfig {
distributionServices: Array<DamDistributionServiceName>
distributionRequirements: Record<DamDistributionServiceName, DistributionRequirementsConfig>
distributionRequirements: Record<DamDistributionServiceName, DamDistributionRequirementsConfig>
}

export interface ExtSystemConfig {
export interface DamExtSystemConfigItem {
sizeLimit: number
defaultFileVersion: string
versions: Array<string>
mimeTypes: Array<string>
distribution: DistributionConfig
authors: ExtSystemAssetTypeExifMetadata
keywords: ExtSystemAssetTypeExifMetadata
distribution: DamDistributionConfig
authors: DamExtSystemAssetTypeExifMetadata
keywords: DamExtSystemAssetTypeExifMetadata
customMetadataPinnedAmount: number
slots: string[]
}

export interface DamConfigExtSystem extends Record<DamAssetType, ExtSystemConfig> {
assetExternalProviders: ExternalProviderAssetConfig
audio: ExtSystemConfig
video: ExtSystemConfig
image: ExtSystemConfig
document: ExtSystemConfig
export interface DamExtSystemConfig extends Record<DamAssetType, DamExtSystemConfigItem> {
assetExternalProviders: DamExternalProviderAssetConfig
audio: DamExtSystemConfigItem
video: DamExtSystemConfigItem
image: DamExtSystemConfigItem
document: DamExtSystemConfigItem
}
4 changes: 2 additions & 2 deletions src/types/coreDam/Distribution.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DamDistributionServiceName } from '@anzusystems/common-admin'
import type { DatetimeUTCNullable, DocId } from '@anzusystems/common-admin'
import { isDefined } from '@anzusystems/common-admin'
import type { DistributionStatus } from '@/model/coreDam/valueObject/DistributionStatus'
import type { DamDistributionStatus } from '@/model/coreDam/valueObject/DamDistributionStatus'
import type { DistributionYoutubePrivacy } from '@/model/coreDam/valueObject/DistributionYoutubePrivacy'
import type { DistributionFailReason } from '@/model/coreDam/valueObject/DistributionFailReason'

Expand Down Expand Up @@ -51,7 +51,7 @@ export interface DistributionItem {
assetFileId: DocId
extId: string
distributionService: DamDistributionServiceName
status: DistributionStatus
status: DamDistributionStatus
failReason: DistributionFailReason
blockedBy: DocId[]
publishAt: DatetimeUTCNullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { DistributionRequirementsConfig } from '@/types/coreDam/DamConfig'
import { DistributionRequirementStrategy } from '@/types/coreDam/DamConfig'
import type { DamDistributionRequirementsConfig } from '@/types/coreDam/DamConfig'
import { DamDistributionRequirementStrategy } from '@/types/coreDam/DamConfig'
import {
cloneDeep,
type DamDistributionServiceName,
Expand All @@ -13,7 +13,7 @@ import { computed, ref, watch } from 'vue'
import { fetchAssetFileDistributionList } from '@/services/api/coreDam/distributionApi'
import type { DistributionCustomItem, DistributionJwItem, DistributionYoutubeItem } from '@/types/coreDam/Distribution'
import { useDistributionFilter } from '@/model/coreDam/filter/DistributionFilter'
import { useDistributionStatus } from '@/model/coreDam/valueObject/DistributionStatus'
import { useDistributionStatus } from '@/model/coreDam/valueObject/DamDistributionStatus'
import type { DamAssetType } from '@/model/coreDam/valueObject/DamAssetType'
import useVuelidate, { type ErrorObject } from '@vuelidate/core'
import { useI18n } from 'vue-i18n'
Expand All @@ -24,7 +24,7 @@ const props = withDefaults(
defineProps<{
modelValue: any
distributionServiceName: DamDistributionServiceName
config: DistributionRequirementsConfig
config: DamDistributionRequirementsConfig
assetFileId: DocIdNullable
assetType: DamAssetType
}>(),
Expand Down Expand Up @@ -77,7 +77,7 @@ const itemsComputed = computed(() => {
const { required } = useValidate()
const rules = computed(() => {
if (props.config.strategy === DistributionRequirementStrategy.AtLeastOne) {
if (props.config.strategy === DamDistributionRequirementStrategy.AtLeastOne) {
return {
required,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ref } from 'vue'
import { ADialogToolbar, isNull, useAlerts } from '@anzusystems/common-admin'
import { useI18n } from 'vue-i18n'
import { useAssetDetailDistributionDialogCancel } from '@/views/coreDam/asset/detail/composables/assetDetailDistributionDialogCancel'
import { DistributionServiceType } from '@/types/coreDam/DamConfig'
import { DamDistributionServiceType } from '@/types/coreDam/DamConfig'
import { cancelCustomDistribution } from '@/services/api/coreDam/distributionCustomApi'
const emit = defineEmits<{
Expand All @@ -25,7 +25,7 @@ const onConfirm = async () => {
if (
isNull(distributionIdToCancel.value) ||
isNull(distributionTypeToCancel.value) ||
distributionTypeToCancel.value !== DistributionServiceType.Custom
distributionTypeToCancel.value !== DamDistributionServiceType.Custom
)
return
buttonLoading.value = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import DistributionListItemCustom from '@/views/coreDam/asset/detail/components/
import DistributionListItemEmpty from '@/views/coreDam/asset/detail/components/distribution/DistributionListItemEmpty.vue'
import type { DamAssetType } from '@/model/coreDam/valueObject/DamAssetType'
import type { DistributionCustomItem, DistributionJwItem, DistributionYoutubeItem } from '@/types/coreDam/Distribution'
import { DistributionServiceType } from '@/types/coreDam/DamConfig'
import { DamDistributionServiceType } from '@/types/coreDam/DamConfig'
import { useAssetDetailDistributionDialog } from '@/views/coreDam/asset/detail/composables/assetDetailDistributionDialog'
import { useAssetDetailDistributionDialogCancel } from '@/views/coreDam/asset/detail/composables/assetDetailDistributionDialogCancel'
import { useDamConfigState } from '@anzusystems/common-admin'
Expand Down Expand Up @@ -36,11 +36,11 @@ const showRedistribute = computed(() => {
const componentComputed = computed(() => {
switch (distributionType.value) {
case DistributionServiceType.Jw:
case DamDistributionServiceType.Jw:
return DistributionListItemJw
case DistributionServiceType.Youtube:
case DamDistributionServiceType.Youtube:
return DistributionListItemYoutube
case DistributionServiceType.Custom:
case DamDistributionServiceType.Custom:
return DistributionListItemCustom
default:
return DistributionListItemEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type { DamAssetType } from '@/model/coreDam/valueObject/DamAssetType'
import DistributionStatusChip from '@/views/coreDam/asset/detail/components/distribution/DistributionStatusChip.vue'
import type { DistributionCustomItem, DistributionJwItem, DistributionYoutubeItem } from '@/types/coreDam/Distribution'
import { isDistributionCustomItem } from '@/types/coreDam/Distribution'
import type { DistributionServiceType } from '@/types/coreDam/DamConfig'
import type { DamDistributionServiceType } from '@/types/coreDam/DamConfig'
import { useI18n } from 'vue-i18n'
import { DistributionStatus } from '@/model/coreDam/valueObject/DistributionStatus'
import { DamDistributionStatus } from '@/model/coreDam/valueObject/DamDistributionStatus'
import DistributionFailReasonChip from '@/views/coreDam/asset/detail/components/distribution/DistributionFailReasonChip.vue'
import DistributionListItemCustomDistributionDataItem from '@/views/coreDam/asset/detail/components/distribution/DistributionListItemCustomDistributionDataItem.vue'
import { ACopyText, useDamConfigState } from '@anzusystems/common-admin'
Expand All @@ -15,7 +15,7 @@ const props = withDefaults(
defineProps<{
item: DistributionJwItem | DistributionYoutubeItem | DistributionCustomItem
assetType: DamAssetType
distributionType: DistributionServiceType | null
distributionType: DamDistributionServiceType | null
showRedistribute: boolean
}>(),
{}
Expand Down Expand Up @@ -59,7 +59,7 @@ const serviceRequirements = computed(() => {
{{ t('coreDam.distribution.common.redistributeButton') }}
</ABtnTertiary>
<ABtnTertiary
v-if="item.status === DistributionStatus.Waiting"
v-if="item.status === DamDistributionStatus.Waiting"
class="ml-2"
size="small"
@click.stop="emit('openCancel')"
Expand All @@ -68,7 +68,7 @@ const serviceRequirements = computed(() => {
</ABtnTertiary>
</VCol>
</VRow>
<VRow v-if="item.status === DistributionStatus.Failed">
<VRow v-if="item.status === DamDistributionStatus.Failed">
<VCol>
{{ t('coreDam.distribution.common.failReason') }}:
<DistributionFailReasonChip :status="item.failReason" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
import type { DamAssetType } from '@/model/coreDam/valueObject/DamAssetType'
import type { DistributionCustomItem, DistributionJwItem, DistributionYoutubeItem } from '@/types/coreDam/Distribution'
import type { DistributionServiceType } from '@/types/coreDam/DamConfig'
import type { DamDistributionServiceType } from '@/types/coreDam/DamConfig'
withDefaults(
defineProps<{
item: DistributionJwItem | DistributionYoutubeItem | DistributionCustomItem
assetType: DamAssetType
distributionType: DistributionServiceType | null
distributionType: DamDistributionServiceType | null
showRedistribute: boolean
}>(),
{}
Expand Down
Loading

0 comments on commit 6e72793

Please sign in to comment.