1 Commits

Author SHA1 Message Date
Sebastian 8de76f810e chore(deps): update vitest monorepo to v4.1.10
JS Unit Tests / test (pull_request) Failing after 10m43s
Build Test / test (pull_request) Failing after 10m54s
PHP Unit Tests / test (pull_request) Failing after 15m35s
2026-07-18 03:05:51 +00:00
7 changed files with 52 additions and 112 deletions
-19
View File
@@ -23,7 +23,6 @@ use KTXF\Resource\Identifier\EntityIdentifier;
use KTXF\Resource\Identifier\ResourceIdentifier; use KTXF\Resource\Identifier\ResourceIdentifier;
use KTXF\Resource\Identifier\ResourceIdentifiers; use KTXF\Resource\Identifier\ResourceIdentifiers;
use KTXF\Resource\Identifier\ServiceIdentifier; use KTXF\Resource\Identifier\ServiceIdentifier;
use KTXF\Mail\Provider\ProviderBaseInterface;
use KTXF\Resource\Provider\ResourceServiceLocationInterface; use KTXF\Resource\Provider\ResourceServiceLocationInterface;
use KTXF\Routing\Attributes\AuthenticatedRoute; use KTXF\Routing\Attributes\AuthenticatedRoute;
use KTXM\MailManager\Manager; use KTXM\MailManager\Manager;
@@ -83,24 +82,6 @@ class DefaultController extends ControllerAbstract {
$tenantId = $this->tenantIdentity->identifier(); $tenantId = $this->tenantIdentity->identifier();
$userId = $this->userIdentity->identifier(); $userId = $this->userIdentity->identifier();
// acting-user override: only the reserved system context is permitted,
// gated on the system mail management permission
if ($user !== null && $user !== $userId) {
if ($user !== ProviderBaseInterface::USER_SYSTEM || !$this->userIdentity->hasPermission('mail_manager.system')) {
return new JsonResponse([
'version' => $version,
'transaction' => $transaction,
'operation' => $operation,
'status' => 'error',
'data' => [
'code' => JsonResponse::HTTP_FORBIDDEN,
'message' => 'Not permitted to act as user: ' . $user
]
], JsonResponse::HTTP_FORBIDDEN);
}
$userId = $user;
}
try { try {
if ($operation !== null) { if ($operation !== null) {
+6 -14
View File
@@ -236,14 +236,7 @@ class Manager {
$serviceId = $provider->serviceCreate($tenantId, $userId, $service); $serviceId = $provider->serviceCreate($tenantId, $userId, $service);
// Fetch and return the created service // Fetch and return the created service
$createdService = $provider->serviceFetch($tenantId, $userId, $serviceId); return $provider->serviceFetch($tenantId, $userId, $serviceId);
if ($createdService === null) {
throw new \RuntimeException(
"Provider '$providerId' created service '$serviceId', but it could not be fetched"
);
}
return $createdService;
} }
/** /**
@@ -1271,13 +1264,9 @@ class Manager {
} }
public function entitySubmit(string $tenantId, string $userId, AddressInterface|string $sender, EntityIdentifierInterface|null $source = null, MessagePropertiesMutableInterface|array|null $message = null): EntitySubmitResult { public function entitySubmit(string $tenantId, string $userId, AddressInterface|string $sender, EntityIdentifierInterface|null $source = null, MessagePropertiesMutableInterface|array|null $message = null): EntitySubmitResult {
if ($sender instanceof AddressInterface === false) { $service = $this->serviceFindByAddress($tenantId, $userId, $sender);
$sender = new Address($sender);
}
$service = $this->serviceFindByAddress($tenantId, $userId, $sender->getAddress());
if ($service === null || $service->getEnabled() === false) { if ($service === null || $service->getEnabled() === false) {
throw new InvalidArgumentException("Service not found for sender '{$sender->getAddress()}' or service is disabled"); throw new InvalidArgumentException("Service not found for sender '{$sender}' or service is disabled");
} }
if ($service instanceof ServiceEntitySubmitInterface === false) { if ($service instanceof ServiceEntitySubmitInterface === false) {
throw new InvalidArgumentException("Service '{$service->identifier()}' does not support entity submission"); throw new InvalidArgumentException("Service '{$service->identifier()}' does not support entity submission");
@@ -1287,6 +1276,9 @@ class Manager {
throw new InvalidArgumentException("At least one of source or message must be provided for entity submission"); throw new InvalidArgumentException("At least one of source or message must be provided for entity submission");
} }
if ($sender instanceof AddressInterface === false) {
$sender = new Address($sender);
}
if ($message !== null && $message instanceof MessagePropertiesMutableInterface === false) { if ($message !== null && $message instanceof MessagePropertiesMutableInterface === false) {
$message = $service->entityFresh()->getProperties()->jsonDeserialize($message); $message = $service->entityFresh()->getProperties()->jsonDeserialize($message);
} }
-5
View File
@@ -50,11 +50,6 @@ class Module extends ModuleInstanceAbstract implements ModuleBrowserInterface
'description' => 'View and access the mail manager module', 'description' => 'View and access the mail manager module',
'group' => 'Mail Management' 'group' => 'Mail Management'
], ],
'mail_manager.system' => [
'label' => 'Manage System Mail',
'description' => 'Manage system mail accounts and routing rules (act in the reserved system user context)',
'group' => 'Mail Management'
],
]; ];
} }
+3 -7
View File
@@ -32,7 +32,6 @@ const MANUAL_STEPS = {
const props = defineProps<{ const props = defineProps<{
modelValue: boolean modelValue: boolean
user?: string
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
@@ -243,8 +242,7 @@ async function handleDiscover() {
discoverSecret.value || undefined, discoverSecret.value || undefined,
discoverHostname.value || undefined, discoverHostname.value || undefined,
identifier, identifier,
(service) => { discoveredService = service }, (service) => { discoveredService = service }
props.user
) )
// Success - check if we got results for this provider // Success - check if we got results for this provider
@@ -386,8 +384,7 @@ async function testConnection() {
selectedProvider.value.identifier, selectedProvider.value.identifier,
null, null,
selectedService.value.location, selectedService.value.location,
selectedService.value.identity, selectedService.value.identity
props.user
) )
return testResult return testResult
@@ -413,8 +410,7 @@ async function saveAccount() {
await servicesStore.create( await servicesStore.create(
selectedProvider.value.identifier, selectedProvider.value.identifier,
accountData, accountData
props.user
) )
emit('saved') emit('saved')
+4 -13
View File
@@ -14,7 +14,6 @@ const props = defineProps<{
modelValue: boolean modelValue: boolean
serviceProvider: string serviceProvider: string
serviceIdentifier: string | number serviceIdentifier: string | number
user?: string
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
@@ -104,10 +103,7 @@ async function load() {
try { try {
const [provider, service] = await Promise.all([ const [provider, service] = await Promise.all([
providersStore.provider(props.serviceProvider) ?? providersStore.fetch(props.serviceProvider), providersStore.provider(props.serviceProvider) ?? providersStore.fetch(props.serviceProvider),
// acting-user context always fetches fresh, bypassing the shared cache servicesStore.service(props.serviceProvider, props.serviceIdentifier) ?? servicesStore.fetch(props.serviceProvider, props.serviceIdentifier)
props.user
? servicesStore.fetch(props.serviceProvider, props.serviceIdentifier, props.user)
: servicesStore.service(props.serviceProvider, props.serviceIdentifier) ?? servicesStore.fetch(props.serviceProvider, props.serviceIdentifier)
]) ])
localProvider.value = provider.clone() localProvider.value = provider.clone()
@@ -165,16 +161,12 @@ async function testConnection() {
localService.value.provider, localService.value.provider,
null, null,
localService.value.location, localService.value.location,
localService.value.identity, localService.value.identity
props.user
) )
} else { } else {
testResult = await servicesStore.test( testResult = await servicesStore.test(
localService.value.provider, localService.value.provider,
localService.value.identifier, localService.value.identifier
undefined,
undefined,
props.user
) )
} }
@@ -207,8 +199,7 @@ async function saveAccount() {
localService.value.provider, localService.value.provider,
localService.value.identifier as string | number, localService.value.identifier as string | number,
true, // delta update true, // delta update
localService.value, localService.value
props.user
) )
emit('saved') emit('saved')
+16 -18
View File
@@ -47,8 +47,8 @@ export const serviceService = {
* *
* @returns Promise with service object list grouped by provider and keyed by service identifier * @returns Promise with service object list grouped by provider and keyed by service identifier
*/ */
async list(request: ServiceListRequest = {}, user?: string): Promise<Record<string, Record<string, ServiceObject>>> { async list(request: ServiceListRequest = {}): Promise<Record<string, Record<string, ServiceObject>>> {
const response = await transceivePost<ServiceListRequest, ServiceListResponse>('service.list', request, user); const response = await transceivePost<ServiceListRequest, ServiceListResponse>('service.list', request);
// Convert nested response to ServiceObject instances // Convert nested response to ServiceObject instances
const providerList: Record<string, Record<string, ServiceObject>> = {}; const providerList: Record<string, Record<string, ServiceObject>> = {};
@@ -70,8 +70,8 @@ export const serviceService = {
* *
* @returns Promise with service object * @returns Promise with service object
*/ */
async fetch(request: ServiceFetchRequest, user?: string): Promise<ServiceObject> { async fetch(request: ServiceFetchRequest): Promise<ServiceObject> {
const response = await transceivePost<ServiceFetchRequest, ServiceFetchResponse>('service.fetch', request, user); const response = await transceivePost<ServiceFetchRequest, ServiceFetchResponse>('service.fetch', request);
return createServiceObject(response); return createServiceObject(response);
}, },
@@ -82,8 +82,8 @@ export const serviceService = {
* *
* @returns Promise with service availability status * @returns Promise with service availability status
*/ */
async extant(request: ServiceExtantRequest, user?: string): Promise<ServiceExtantResponse> { async extant(request: ServiceExtantRequest): Promise<ServiceExtantResponse> {
return await transceivePost<ServiceExtantRequest, ServiceExtantResponse>('service.extant', request, user); return await transceivePost<ServiceExtantRequest, ServiceExtantResponse>('service.extant', request);
}, },
/** /**
@@ -96,8 +96,7 @@ export const serviceService = {
*/ */
async discover( async discover(
request: ServiceDiscoverRequest, request: ServiceDiscoverRequest,
onService: (service: ServiceObject) => void, onService: (service: ServiceObject) => void
user?: string
): Promise<{ total: number }> { ): Promise<{ total: number }> {
return await transceiveStream<ServiceDiscoverRequest, ServiceDiscoverResponse>( return await transceiveStream<ServiceDiscoverRequest, ServiceDiscoverResponse>(
'service.discover', 'service.discover',
@@ -112,8 +111,7 @@ export const serviceService = {
location: service.location, location: service.location,
}; };
onService(createServiceObject(serviceData)); onService(createServiceObject(serviceData));
}, }
user
); );
}, },
@@ -123,8 +121,8 @@ export const serviceService = {
* @param request - Service test request * @param request - Service test request
* @returns Promise with test results * @returns Promise with test results
*/ */
async test(request: ServiceTestRequest, user?: string): Promise<ServiceTestResponse> { async test(request: ServiceTestRequest): Promise<ServiceTestResponse> {
return await transceivePost<ServiceTestRequest, ServiceTestResponse>('service.test', request, user); return await transceivePost<ServiceTestRequest, ServiceTestResponse>('service.test', request);
}, },
/** /**
@@ -134,8 +132,8 @@ export const serviceService = {
* *
* @returns Promise with created service object * @returns Promise with created service object
*/ */
async create(request: ServiceCreateRequest, user?: string): Promise<ServiceObject> { async create(request: ServiceCreateRequest): Promise<ServiceObject> {
const response = await transceivePost<ServiceCreateRequest, ServiceCreateResponse>('service.create', request, user); const response = await transceivePost<ServiceCreateRequest, ServiceCreateResponse>('service.create', request);
return createServiceObject(response); return createServiceObject(response);
}, },
@@ -146,8 +144,8 @@ export const serviceService = {
* *
* @returns Promise with updated service object * @returns Promise with updated service object
*/ */
async update(request: ServiceUpdateRequest, user?: string): Promise<ServiceObject> { async update(request: ServiceUpdateRequest): Promise<ServiceObject> {
const response = await transceivePost<ServiceUpdateRequest, ServiceUpdateResponse>('service.update', request, user); const response = await transceivePost<ServiceUpdateRequest, ServiceUpdateResponse>('service.update', request);
return createServiceObject(response); return createServiceObject(response);
}, },
@@ -158,8 +156,8 @@ export const serviceService = {
* *
* @returns Promise with deletion result * @returns Promise with deletion result
*/ */
async delete(request: { provider: string; identifier: string | number }, user?: string): Promise<any> { async delete(request: { provider: string; identifier: string | number }): Promise<any> {
return await transceivePost<ServiceDeleteRequest, ServiceDeleteResponse>('service.delete', request, user); return await transceivePost<ServiceDeleteRequest, ServiceDeleteResponse>('service.delete', request);
}, },
}; };
+18 -31
View File
@@ -131,10 +131,10 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
* *
* @returns Promise with service object list keyed by provider and service identifier * @returns Promise with service object list keyed by provider and service identifier
*/ */
async function list(targets?: ServiceIdentifier[] | CollectionIdentifier[], user?: string): Promise<Record<string, ServiceObject>> { async function list(targets?: ServiceIdentifier[] | CollectionIdentifier[]): Promise<Record<string, ServiceObject>> {
transceiving.value = true transceiving.value = true
try { try {
const response = await serviceService.list({ targets }, user) const response = await serviceService.list({ targets })
// Flatten nested structure: provider-id: { service-id: object } -> "provider-id:service-id": object // Flatten nested structure: provider-id: { service-id: object } -> "provider-id:service-id": object
const services: Record<string, ServiceObject> = {} const services: Record<string, ServiceObject> = {}
@@ -145,10 +145,8 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
}) })
}) })
// Merge retrieved services into state (acting-user context stays out of the shared cache) // Merge retrieved services into state
if (!user) {
_services.value = { ..._services.value, ...services } _services.value = { ..._services.value, ...services }
}
console.debug('[Mail Manager][Store] - Successfully retrieved', Object.keys(services).length, 'services') console.debug('[Mail Manager][Store] - Successfully retrieved', Object.keys(services).length, 'services')
return services return services
@@ -168,16 +166,14 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
* *
* @returns Promise with service object * @returns Promise with service object
*/ */
async function fetch(provider: string, identifier: string | number, user?: string): Promise<ServiceObject> { async function fetch(provider: string, identifier: string | number): Promise<ServiceObject> {
transceiving.value = true transceiving.value = true
try { try {
const service = await serviceService.fetch({ provider, identifier }, user) const service = await serviceService.fetch({ provider, identifier })
// Merge fetched service into state (acting-user context stays out of the shared cache) // Merge fetched service into state
const key = identifierKey(service.provider, service.identifier) const key = identifierKey(service.provider, service.identifier)
if (!user) {
_services.value[key] = service _services.value[key] = service
}
console.debug('[Mail Manager][Store] - Successfully fetched service:', key) console.debug('[Mail Manager][Store] - Successfully fetched service:', key)
return service return service
@@ -196,10 +192,10 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
* *
* @returns Promise with service availability status * @returns Promise with service availability status
*/ */
async function extant(targets: ServiceIdentifier[], user?: string) { async function extant(targets: ServiceIdentifier[]) {
transceiving.value = true transceiving.value = true
try { try {
const response = await serviceService.extant({ targets }, user) const response = await serviceService.extant({ targets })
console.debug('[Mail Manager][Store] - Successfully checked', targets?.length ?? 0, 'services') console.debug('[Mail Manager][Store] - Successfully checked', targets?.length ?? 0, 'services')
return response return response
@@ -219,16 +215,14 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
* *
* @returns Promise with created service object * @returns Promise with created service object
*/ */
async function create(provider: string, data: Partial<ServiceInterface>, user?: string): Promise<ServiceObject> { async function create(provider: string, data: Partial<ServiceInterface>): Promise<ServiceObject> {
transceiving.value = true transceiving.value = true
try { try {
const service = await serviceService.create({ provider, data }, user) const service = await serviceService.create({ provider, data })
// Merge created service into state (acting-user context stays out of the shared cache) // Merge created service into state
const key = identifierKey(service.provider, service.identifier) const key = identifierKey(service.provider, service.identifier)
if (!user) {
_services.value[key] = service _services.value[key] = service
}
console.debug('[Mail Manager][Store] - Successfully created service:', key) console.debug('[Mail Manager][Store] - Successfully created service:', key)
return service return service
@@ -250,7 +244,7 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
* *
* @returns Promise with updated service object * @returns Promise with updated service object
*/ */
async function update(provider: string, identifier: string | number, delta: boolean, data: ServiceObject | Partial<ServiceInterface>, user?: string): Promise<ServiceObject> { async function update(provider: string, identifier: string | number, delta: boolean, data: ServiceObject | Partial<ServiceInterface>): Promise<ServiceObject> {
transceiving.value = true transceiving.value = true
try { try {
// convert ServiceObject to JSON if needed // convert ServiceObject to JSON if needed
@@ -261,13 +255,11 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
payload = data payload = data
} }
const service = await serviceService.update({ provider, identifier, delta, data: payload }, user) const service = await serviceService.update({ provider, identifier, delta, data: payload })
// Merge updated service into state (acting-user context stays out of the shared cache) // Merge updated service into state
const key = identifierKey(service.provider, service.identifier) const key = identifierKey(service.provider, service.identifier)
if (!user) {
_services.value[key] = service _services.value[key] = service
}
console.debug('[Mail Manager][Store] - Successfully updated service:', key) console.debug('[Mail Manager][Store] - Successfully updated service:', key)
return service return service
@@ -287,16 +279,14 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
* *
* @returns Promise with deletion result * @returns Promise with deletion result
*/ */
async function remove(provider: string, identifier: string | number, user?: string): Promise<any> { async function remove(provider: string, identifier: string | number): Promise<any> {
transceiving.value = true transceiving.value = true
try { try {
await serviceService.delete({ provider, identifier }, user) await serviceService.delete({ provider, identifier })
// Remove deleted service from state // Remove deleted service from state
const key = identifierKey(provider, identifier) const key = identifierKey(provider, identifier)
if (!user) {
delete _services.value[key] delete _services.value[key]
}
console.debug('[Mail Manager][Store] - Successfully deleted service:', key) console.debug('[Mail Manager][Store] - Successfully deleted service:', key)
} catch (error: any) { } catch (error: any) {
@@ -324,7 +314,6 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
location: string | undefined, location: string | undefined,
provider: string | undefined, provider: string | undefined,
onService?: (service: ServiceObject) => void, onService?: (service: ServiceObject) => void,
user?: string,
): Promise<{ total: number }> { ): Promise<{ total: number }> {
transceiving.value = true transceiving.value = true
@@ -333,8 +322,7 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
{ identity, secret, location, provider }, { identity, secret, location, provider },
(service: ServiceObject) => { (service: ServiceObject) => {
onService?.(service) onService?.(service)
}, }
user
) )
console.debug('[Mail Manager][Store] - Successfully discovered', result.total, 'services') console.debug('[Mail Manager][Store] - Successfully discovered', result.total, 'services')
@@ -362,7 +350,6 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
identifier?: string | number | null, identifier?: string | number | null,
location?: ServiceLocation | Location | null, location?: ServiceLocation | Location | null,
identity?: ServiceIdentity | Identity | null, identity?: ServiceIdentity | Identity | null,
user?: string,
): Promise<any> { ): Promise<any> {
transceiving.value = true transceiving.value = true
try { try {
@@ -385,7 +372,7 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
identity = identity.toJson() identity = identity.toJson()
} }
const response = await serviceService.test({ provider, identifier, location, identity }, user) const response = await serviceService.test({ provider, identifier, location, identity })
console.debug('[Mail Manager][Store] - Successfully tested service:', provider, identifier || location) console.debug('[Mail Manager][Store] - Successfully tested service:', provider, identifier || location)
return response return response