refactor: remove sources selector from frontend
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -182,6 +182,10 @@ async function testConnection() {
|
||||
}
|
||||
|
||||
async function saveAccount() {
|
||||
if (!localService.value) {
|
||||
console.error('[Mail Manager][Edit Account Dialog] - No service data to save')
|
||||
return
|
||||
}
|
||||
// No changes made, just close the dialog
|
||||
if (!localService.value.mutated() && !localService.value.location?.mutated() && !localService.value.identity?.mutated()) {
|
||||
close()
|
||||
|
||||
@@ -41,7 +41,7 @@ function createServiceObject(data: ServiceInterface): ServiceObject {
|
||||
export const serviceService = {
|
||||
|
||||
/**
|
||||
* Retrieve list of services, optionally filtered by source selector
|
||||
* Retrieve list of services, optionally filtered by provider/service identifiers
|
||||
*
|
||||
* @param request - list request parameters
|
||||
*
|
||||
@@ -76,7 +76,7 @@ export const serviceService = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve service availability status for a given source selector
|
||||
* Retrieve service availability status for the given service identifiers
|
||||
*
|
||||
* @param request - extant request parameters
|
||||
*
|
||||
|
||||
@@ -180,10 +180,10 @@ export const useEntitiesStore = defineStore('mailEntitiesStore', () => {
|
||||
* Note: Delta returns only identifiers, not full entities.
|
||||
* Caller should fetch full entities for additions/modifications separately.
|
||||
*/
|
||||
async function delta(sources: CollectionIdentifier[]) {
|
||||
async function delta(targets: CollectionIdentifier[]) {
|
||||
transceiving.value = true
|
||||
try {
|
||||
const response = await entityService.delta({ sources })
|
||||
const response = await entityService.delta({ targets })
|
||||
|
||||
// Process delta and update store
|
||||
Object.entries(response).forEach(([, providerData]) => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ref, computed, readonly } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { providerService } from '../services'
|
||||
import { ProviderObject } from '../models/provider'
|
||||
import type { SourceSelector } from '../types'
|
||||
import type { ProviderIdentifier } from '../types'
|
||||
|
||||
export const useProvidersStore = defineStore('mailProvidersStore', () => {
|
||||
// State
|
||||
@@ -50,14 +50,14 @@ export const useProvidersStore = defineStore('mailProvidersStore', () => {
|
||||
/**
|
||||
* Retrieve all or specific providers, optionally filtered by source selector
|
||||
*
|
||||
* @param request - list request parameters
|
||||
* @param targets - list request parameters
|
||||
*
|
||||
* @returns Promise with provider object list keyed by provider identifier
|
||||
*/
|
||||
async function list(sources?: SourceSelector): Promise<Record<string, ProviderObject>> {
|
||||
async function list(targets?: ProviderIdentifier[]): Promise<Record<string, ProviderObject>> {
|
||||
transceiving.value = true
|
||||
try {
|
||||
const providers = await providerService.list({ sources })
|
||||
const providers = await providerService.list({ targets })
|
||||
|
||||
// Merge retrieved providers into state
|
||||
_providers.value = { ..._providers.value, ...providers }
|
||||
@@ -75,14 +75,14 @@ export const useProvidersStore = defineStore('mailProvidersStore', () => {
|
||||
/**
|
||||
* Retrieve a specific provider by identifier
|
||||
*
|
||||
* @param identifier - provider identifier
|
||||
* @param target - fetch target identifier
|
||||
*
|
||||
* @returns Promise with provider object
|
||||
*/
|
||||
async function fetch(identifier: string): Promise<ProviderObject> {
|
||||
async function fetch(target: string): Promise<ProviderObject> {
|
||||
transceiving.value = true
|
||||
try {
|
||||
const provider = await providerService.fetch({ identifier })
|
||||
const provider = await providerService.fetch({ target })
|
||||
|
||||
// Merge fetched provider into state
|
||||
_providers.value[provider.identifier] = provider
|
||||
@@ -100,14 +100,14 @@ export const useProvidersStore = defineStore('mailProvidersStore', () => {
|
||||
/**
|
||||
* Retrieve provider availability status for a given source selector
|
||||
*
|
||||
* @param sources - source selector to check availability for
|
||||
* @param targets - list of provider identifiers to check availability for
|
||||
*
|
||||
* @returns Promise with provider availability status
|
||||
*/
|
||||
async function extant(sources: SourceSelector) {
|
||||
async function extant(targets: ProviderIdentifier[]) {
|
||||
transceiving.value = true
|
||||
try {
|
||||
const response = await providerService.extant({ sources })
|
||||
const response = await providerService.extant({ targets })
|
||||
|
||||
Object.entries(response).forEach(([providerId, providerStatus]) => {
|
||||
if (providerStatus === false) {
|
||||
@@ -115,7 +115,7 @@ export const useProvidersStore = defineStore('mailProvidersStore', () => {
|
||||
}
|
||||
})
|
||||
|
||||
console.debug('[Mail Manager][Store] - Successfully checked', sources ? Object.keys(sources).length : 0, 'providers')
|
||||
console.debug('[Mail Manager][Store] - Successfully checked', targets ? targets.length : 0, 'providers')
|
||||
return response
|
||||
} catch (error: any) {
|
||||
console.error('[Mail Manager][Store] - Failed to check providers:', error)
|
||||
|
||||
+15
-15
@@ -7,9 +7,9 @@ import { defineStore } from 'pinia'
|
||||
import { serviceService } from '../services'
|
||||
import { ServiceObject } from '../models/service'
|
||||
import type {
|
||||
CollectionIdentifier,
|
||||
ServiceIdentifier,
|
||||
ServiceLocation,
|
||||
SourceSelector,
|
||||
ServiceIdentity,
|
||||
ServiceInterface,
|
||||
} from '../types'
|
||||
@@ -125,16 +125,16 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
|
||||
// Actions
|
||||
|
||||
/**
|
||||
* Retrieve all or specific services, optionally filtered by source selector
|
||||
*
|
||||
* @param sources - optional source selector
|
||||
*
|
||||
* Retrieve all or specific services, optionally filtered by provider/service identifiers
|
||||
*
|
||||
* @param targets - optional array of provider:service (or provider:service:collection) identifiers
|
||||
*
|
||||
* @returns Promise with service object list keyed by provider and service identifier
|
||||
*/
|
||||
async function list(sources?: SourceSelector): Promise<Record<string, ServiceObject>> {
|
||||
async function list(targets?: ServiceIdentifier[] | CollectionIdentifier[]): Promise<Record<string, ServiceObject>> {
|
||||
transceiving.value = true
|
||||
try {
|
||||
const response = await serviceService.list({ sources })
|
||||
const response = await serviceService.list({ targets })
|
||||
|
||||
// Flatten nested structure: provider-id: { service-id: object } -> "provider-id:service-id": object
|
||||
const services: Record<string, ServiceObject> = {}
|
||||
@@ -186,18 +186,18 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve service availability status for a given source selector
|
||||
*
|
||||
* @param sources - source selector to check availability for
|
||||
*
|
||||
* Retrieve service availability status for the given service identifiers
|
||||
*
|
||||
* @param targets - array of provider:service identifiers to check availability for
|
||||
*
|
||||
* @returns Promise with service availability status
|
||||
*/
|
||||
async function extant(sources: SourceSelector) {
|
||||
async function extant(targets: ServiceIdentifier[]) {
|
||||
transceiving.value = true
|
||||
try {
|
||||
const response = await serviceService.extant({ sources })
|
||||
|
||||
console.debug('[Mail Manager][Store] - Successfully checked', sources ? Object.keys(sources).length : 0, 'services')
|
||||
const response = await serviceService.extant({ targets })
|
||||
|
||||
console.debug('[Mail Manager][Store] - Successfully checked', targets?.length ?? 0, 'services')
|
||||
return response
|
||||
} catch (error: any) {
|
||||
console.error('[Mail Manager][Store] - Failed to check services:', error)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Collection type definitions
|
||||
*/
|
||||
import type { CollectionIdentifier, ListFilter, ListSort, ServiceIdentifier, SourceSelector } from './common';
|
||||
import type { CollectionIdentifier, ListFilter, ListSort, ServiceIdentifier } from './common';
|
||||
|
||||
/**
|
||||
* Collection information
|
||||
|
||||
+2
-27
@@ -85,33 +85,8 @@ export type ApiStreamResponse<T = any> =
|
||||
| ApiStreamDataResponse<T>;
|
||||
|
||||
/**
|
||||
* Selector for targeting specific providers, services, collections, or entities in list or extant operations.
|
||||
*
|
||||
* Example usage:
|
||||
* {
|
||||
* "provider1": true, // Select all services/collections/entities under provider1
|
||||
* "provider2": {
|
||||
* "serviceA": true, // Select all collections/entities under serviceA of provider2
|
||||
* "serviceB": {
|
||||
* "collectionX": true, // Select all entities under collectionX of serviceB of provider2
|
||||
* "collectionY": [1, 2, 3] // Select entities with identifiers 1, 2, and 3 under collectionY of serviceB of provider2
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
export type SourceSelector = {
|
||||
[provider: string]: boolean | ServiceSelector;
|
||||
};
|
||||
|
||||
export type ServiceSelector = {
|
||||
[service: string]: boolean | CollectionSelector;
|
||||
};
|
||||
|
||||
export type CollectionSelector = {
|
||||
[collection: string | number]: boolean | EntitySelector;
|
||||
};
|
||||
|
||||
export type EntitySelector = (string | number)[];
|
||||
* Identifiers for targeting specific providers, services, collections, or entities in list or extant operations.
|
||||
*
|
||||
|
||||
export type ProviderIdentifier = `${string}`;
|
||||
export type ServiceIdentifier = `${string}:${string}`;
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ export interface EntityExtantResponse {
|
||||
* Entity delta
|
||||
*/
|
||||
export interface EntityDeltaRequest {
|
||||
sources: CollectionIdentifier[];
|
||||
targets: CollectionIdentifier[];
|
||||
}
|
||||
|
||||
export interface EntityDeltaResponse {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Provider type definitions
|
||||
*/
|
||||
import type { SourceSelector } from "./common";
|
||||
import type { ProviderIdentifier } from "./common";
|
||||
|
||||
/**
|
||||
* Provider capabilities
|
||||
@@ -35,7 +35,7 @@ export interface ProviderModelInterface extends Omit<ProviderInterface, '@type'
|
||||
* Provider list
|
||||
*/
|
||||
export interface ProviderListRequest {
|
||||
sources?: SourceSelector;
|
||||
targets?: ProviderIdentifier[];
|
||||
}
|
||||
|
||||
export interface ProviderListResponse {
|
||||
@@ -46,7 +46,7 @@ export interface ProviderListResponse {
|
||||
* Provider fetch
|
||||
*/
|
||||
export interface ProviderFetchRequest {
|
||||
identifier: string;
|
||||
target: string;
|
||||
}
|
||||
|
||||
export interface ProviderFetchResponse extends ProviderInterface {}
|
||||
@@ -55,7 +55,7 @@ export interface ProviderFetchResponse extends ProviderInterface {}
|
||||
* Provider extant
|
||||
*/
|
||||
export interface ProviderExtantRequest {
|
||||
sources: SourceSelector;
|
||||
targets: ProviderIdentifier[];
|
||||
}
|
||||
|
||||
export interface ProviderExtantResponse {
|
||||
|
||||
@@ -5,8 +5,9 @@ import type { ServiceAddressObject } from '@/models/address';
|
||||
import type { Identity } from '@/models/identity';
|
||||
import type { Location } from '@/models/location';
|
||||
import type {
|
||||
CollectionIdentifier,
|
||||
ListFilterComparisonOperator,
|
||||
SourceSelector,
|
||||
ServiceIdentifier,
|
||||
} from './common';
|
||||
|
||||
/**
|
||||
@@ -81,7 +82,7 @@ export interface ServiceModelInterface extends Omit<{
|
||||
* Service list
|
||||
*/
|
||||
export interface ServiceListRequest {
|
||||
sources?: SourceSelector;
|
||||
targets?: ServiceIdentifier[] | CollectionIdentifier[];
|
||||
}
|
||||
|
||||
export interface ServiceListResponse {
|
||||
@@ -104,7 +105,7 @@ export interface ServiceFetchResponse extends ServiceInterface {}
|
||||
* Service extant
|
||||
*/
|
||||
export interface ServiceExtantRequest {
|
||||
sources: SourceSelector;
|
||||
targets: ServiceIdentifier[];
|
||||
}
|
||||
|
||||
export interface ServiceExtantResponse {
|
||||
|
||||
Reference in New Issue
Block a user