refactor: use resource identifiers
Build Test / test (pull_request) Successful in 26s
JS Unit Tests / test (pull_request) Failing after 29s
PHP Unit Tests / test (pull_request) Successful in 56s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-14 22:34:18 -04:00
parent 69d4b2f42c
commit c7ef2c5495
13 changed files with 425 additions and 621 deletions
+14 -18
View File
@@ -1,7 +1,7 @@
/**
* Collection type definitions
*/
import type { CollectionIdentifier, ListFilter, ListSort, SourceSelector } from './common';
import type { CollectionIdentifier, ListFilter, ListSort, ServiceIdentifier, SourceSelector } from './common';
/**
* Collection information
@@ -11,8 +11,8 @@ export interface CollectionInterface<T = CollectionPropertiesInterface> {
version: number;
provider: string;
service: string | number;
collection: string | number | null;
identifier: string | number;
collection: CollectionIdentifier | null;
identifier: CollectionIdentifier;
signature?: string | null;
created?: string | null;
modified?: string | null;
@@ -47,7 +47,7 @@ export interface CollectionPropertiesModelInterface extends Omit<CollectionPrope
* Collection list
*/
export interface CollectionListRequest {
sources?: SourceSelector;
sources?: ServiceIdentifier[] | CollectionIdentifier[];
filter?: ListFilter;
sort?: ListSort;
}
@@ -64,18 +64,18 @@ export interface CollectionListResponse {
* Collection fetch
*/
export interface CollectionFetchRequest {
provider: string;
service: string | number;
collection: string | number;
targets: CollectionIdentifier[];
}
export interface CollectionFetchResponse extends CollectionInterface {}
export interface CollectionFetchResponse {
[identifier: CollectionIdentifier]: CollectionInterface;
}
/**
* Collection extant
*/
export interface CollectionExtantRequest {
sources: SourceSelector;
targets: CollectionIdentifier[];
}
export interface CollectionExtantResponse {
@@ -92,7 +92,7 @@ export interface CollectionExtantResponse {
export interface CollectionCreateRequest {
provider: string;
service: string | number;
collection?: string | number | null; // Parent Collection Identifier
target?: CollectionIdentifier; // Optional parent target for the new collection
properties: CollectionMutableProperties;
}
@@ -102,9 +102,7 @@ export interface CollectionCreateResponse extends CollectionInterface {}
* Collection modify
*/
export interface CollectionUpdateRequest {
provider: string;
service: string | number;
identifier: string | number;
target: CollectionIdentifier;
properties: CollectionMutableProperties;
}
@@ -114,17 +112,15 @@ export interface CollectionUpdateResponse extends CollectionInterface {}
* Collection delete
*/
export interface CollectionDeleteRequest {
provider: string;
service: string | number;
identifier: string | number;
target: CollectionIdentifier;
options?: {
force?: boolean; // Whether to force delete even if collection is not empty
};
}
export interface CollectionDeleteResponse {
outcome: 'deleted' | 'moved';
data?: CollectionInterface | null; // If moved, the new location of the collection
disposition: 'deleted' | 'moved';
mutation?: CollectionInterface | null; // If moved, the new location of the collection
}
/**
+2 -2
View File
@@ -115,8 +115,8 @@ export type EntitySelector = (string | number)[];
export type ProviderIdentifier = `${string}`;
export type ServiceIdentifier = `${string}:${string}`;
export type CollectionIdentifier = `${string}:${string}:${string}`;
export type EntityIdentifier = `${string}:${string}:${string}:${string}`;
export type CollectionIdentifier = `${string}:${string}:${string | number}`;
export type EntityIdentifier = `${string}:${string}:${string}:${string | number}`;
/**
* Filter comparison for list operations
+9 -18
View File
@@ -4,7 +4,6 @@
import type {
CollectionIdentifier,
EntityIdentifier,
SourceSelector,
ListFilter,
ListRange,
ListSort,
@@ -19,8 +18,8 @@ export interface EntityInterface<T = MessageInterface> {
version: number;
provider: string;
service: string;
collection: string | number;
identifier: string | number;
collection: CollectionIdentifier;
identifier: EntityIdentifier;
signature: string | null;
created: string | null;
modified: string | null;
@@ -33,7 +32,7 @@ export interface EntityModelInterface extends Omit<EntityInterface<MessageModelI
* Entity list
*/
export interface EntityListRequest {
sources?: SourceSelector;
sources?: CollectionIdentifier[];
filter?: ListFilter;
sort?: ListSort;
range?: ListRange;
@@ -53,10 +52,7 @@ export interface EntityListResponse {
* Entity fetch
*/
export interface EntityFetchRequest {
provider: string;
service: string | number;
collection: string | number;
identifiers: (string | number)[];
targets: EntityIdentifier[];
}
export interface EntityFetchResponse {
@@ -67,7 +63,7 @@ export interface EntityFetchResponse {
* Entity extant
*/
export interface EntityExtantRequest {
sources: SourceSelector;
targets: EntityIdentifier[];
}
export interface EntityExtantResponse {
@@ -84,7 +80,7 @@ export interface EntityExtantResponse {
* Entity delta
*/
export interface EntityDeltaRequest {
sources: SourceSelector;
sources: CollectionIdentifier[];
}
export interface EntityDeltaResponse {
@@ -104,9 +100,7 @@ export interface EntityDeltaResponse {
* Entity create
*/
export interface EntityCreateRequest<T = MessageInterface> {
provider: string;
service: string | number;
collection: string | number;
target: CollectionIdentifier;
properties: T;
}
@@ -116,10 +110,7 @@ export interface EntityCreateResponse<T = MessageInterface> extends EntityInterf
* Entity update
*/
export interface EntityUpdateRequest<T = MessageInterface> {
provider: string;
service: string | number;
collection: string | number;
identifier: string | number;
target: EntityIdentifier;
properties: T;
}
@@ -193,7 +184,7 @@ export interface EntityTransmitResponse {
* Entity stream
*/
export interface EntityStreamRequest {
sources?: SourceSelector;
sources?: CollectionIdentifier[];
filter?: ListFilter;
sort?: ListSort;
range?: ListRange;
+10 -8
View File
@@ -10,21 +10,23 @@ export interface MessageModelInterface extends Omit<{
export interface MessageInterface {
'@type': string;
urid?: string | null;
size?: number | null;
date?: string | null;
receivedDate?: string | null;
sentDate?: string | null;
subject?: string | null;
snippet?: string | null;
headers?: Record<string, string> | null;
urid?: string | null;
inReplyTo?: string | null;
references?: string | null;
received?: string | null;
sent?: string | null;
sender?: MessageAddressInterface | null;
from?: MessageAddressInterface | null;
replyTo?: Array<MessageAddressInterface> | null;
to?: Array<MessageAddressInterface> | null;
cc?: Array<MessageAddressInterface> | null;
bcc?: Array<MessageAddressInterface> | null;
replyTo?: Array<MessageAddressInterface> | null;
flags?: MessageFlagsInterface | null;
subject?: string | null;
body?: MessagePartInterface | null;
attachments?: Array<MessagePartInterface> | [];
flags?: MessageFlagsInterface | null;
}
export interface MessageAddressInterface {