Initial commit

This commit is contained in:
root
2025-12-21 09:57:43 -05:00
committed by Sebastian Krupinski
commit db42b6699c
35 changed files with 6458 additions and 0 deletions

262
src/types/api.ts Normal file
View File

@@ -0,0 +1,262 @@
/**
* File Manager API Types - Request and Response interfaces
*/
import type { SourceSelector, FilterCondition, SortCondition, RangeCondition, ApiResponse } from '@/types/common';
import type { ProviderRecord } from '@/types/provider';
import type { ServiceInterface, ServiceRecord } from '@/types/service';
import type { FileCollection, FileEntity, FileNode } from '@/types/node';
// ==================== Provider Types ====================
export type ProviderListResponse = ApiResponse<ProviderRecord>;
export interface ProviderExtantRequest {
sources: SourceSelector;
}
export type ProviderExtantResponse = ApiResponse<Record<string, boolean>>;
// ==================== Service Types ====================
export type ServiceListResponse = ApiResponse<ServiceRecord>;
export interface ServiceExtantRequest {
sources: SourceSelector;
}
export type ServiceExtantResponse = ApiResponse<Record<string, boolean>>;
export interface ServiceFetchRequest {
provider: string;
identifier: string;
}
export type ServiceFetchResponse = ApiResponse<ServiceInterface>;
// ==================== Collection Types ====================
export interface CollectionListRequest {
provider: string;
service: string;
location?: string | null;
filter?: FilterCondition[] | null;
sort?: SortCondition[] | null;
}
export type CollectionListResponse = ApiResponse<FileCollection[]>;
export interface CollectionExtantRequest {
provider: string;
service: string;
identifier: string;
}
export type CollectionExtantResponse = ApiResponse<{ extant: boolean }>;
export interface CollectionFetchRequest {
provider: string;
service: string;
identifier: string;
}
export type CollectionFetchResponse = ApiResponse<FileCollection>;
export interface CollectionCreateRequest {
provider: string;
service: string;
location?: string | null;
data: Partial<FileCollection>;
options?: Record<string, unknown>;
}
export type CollectionCreateResponse = ApiResponse<FileCollection>;
export interface CollectionModifyRequest {
provider: string;
service: string;
identifier: string;
data: Partial<FileCollection>;
}
export type CollectionModifyResponse = ApiResponse<FileCollection>;
export interface CollectionDestroyRequest {
provider: string;
service: string;
identifier: string;
}
export type CollectionDestroyResponse = ApiResponse<{ success: boolean }>;
export interface CollectionCopyRequest {
provider: string;
service: string;
identifier: string;
location?: string | null;
}
export type CollectionCopyResponse = ApiResponse<FileCollection>;
export interface CollectionMoveRequest {
provider: string;
service: string;
identifier: string;
location?: string | null;
}
export type CollectionMoveResponse = ApiResponse<FileCollection>;
// ==================== Entity Types ====================
export interface EntityListRequest {
provider: string;
service: string;
collection: string;
filter?: FilterCondition[] | null;
sort?: SortCondition[] | null;
range?: RangeCondition | null;
}
export type EntityListResponse = ApiResponse<FileEntity[]>;
export interface EntityDeltaRequest {
provider: string;
service: string;
collection: string;
signature: string;
detail?: 'ids' | 'full';
}
export interface EntityDeltaResult {
added: string[] | FileEntity[];
modified: string[] | FileEntity[];
removed: string[];
signature: string;
}
export type EntityDeltaResponse = ApiResponse<EntityDeltaResult>;
export interface EntityExtantRequest {
provider: string;
service: string;
collection: string;
identifiers: string[];
}
export type EntityExtantResponse = ApiResponse<Record<string, boolean>>;
export interface EntityFetchRequest {
provider: string;
service: string;
collection: string;
identifiers: string[];
}
export type EntityFetchResponse = ApiResponse<FileEntity[]>;
export interface EntityReadRequest {
provider: string;
service: string;
collection: string;
identifier: string;
}
export interface EntityReadResult {
content: string | null;
encoding: 'base64';
}
export type EntityReadResponse = ApiResponse<EntityReadResult>;
export interface EntityCreateRequest {
provider: string;
service: string;
collection?: string | null;
data: Partial<FileEntity>;
options?: Record<string, unknown>;
}
export type EntityCreateResponse = ApiResponse<FileEntity>;
export interface EntityModifyRequest {
provider: string;
service: string;
collection?: string | null;
identifier: string;
data: Partial<FileEntity>;
}
export type EntityModifyResponse = ApiResponse<FileEntity>;
export interface EntityDestroyRequest {
provider: string;
service: string;
collection?: string | null;
identifier: string;
}
export type EntityDestroyResponse = ApiResponse<{ success: boolean }>;
export interface EntityCopyRequest {
provider: string;
service: string;
collection?: string | null;
identifier: string;
destination?: string | null;
}
export type EntityCopyResponse = ApiResponse<FileEntity>;
export interface EntityMoveRequest {
provider: string;
service: string;
collection?: string | null;
identifier: string;
destination?: string | null;
}
export type EntityMoveResponse = ApiResponse<FileEntity>;
export interface EntityWriteRequest {
provider: string;
service: string;
collection?: string | null;
identifier: string;
content: string;
encoding?: 'base64';
}
export type EntityWriteResponse = ApiResponse<{ bytesWritten: number }>;
// ==================== Node Types (Unified/Recursive) ====================
export interface NodeListRequest {
provider: string;
service: string;
location?: string | null;
recursive?: boolean;
filter?: FilterCondition[] | null;
sort?: SortCondition[] | null;
range?: RangeCondition | null;
}
export type NodeListResponse = ApiResponse<FileNode[]>;
export interface NodeDeltaRequest {
provider: string;
service: string;
location?: string | null;
signature: string;
recursive?: boolean;
detail?: 'ids' | 'full';
}
export interface NodeDeltaResult {
added: string[] | FileNode[];
modified: string[] | FileNode[];
removed: string[];
signature: string;
}
export type NodeDeltaResponse = ApiResponse<NodeDeltaResult>;

85
src/types/common.ts Normal file
View File

@@ -0,0 +1,85 @@
/**
* Common types for file manager
*/
export type SourceSelector = {
[provider: string]: boolean | ServiceSelector;
};
export type ServiceSelector = {
[service: string]: boolean;
};
export const SortDirection = {
Ascending: 'asc',
Descending: 'desc'
} as const;
export type SortDirection = typeof SortDirection[keyof typeof SortDirection];
export const RangeType = {
Tally: 'tally',
Date: 'date'
} as const;
export type RangeType = typeof RangeType[keyof typeof RangeType];
export const RangeAnchorType = {
Absolute: 'absolute',
Relative: 'relative'
} as const;
export type RangeAnchorType = typeof RangeAnchorType[keyof typeof RangeAnchorType];
export const FilterOperator = {
Equals: 'eq',
NotEquals: 'ne',
GreaterThan: 'gt',
LessThan: 'lt',
GreaterThanOrEquals: 'gte',
LessThanOrEquals: 'lte',
Contains: 'contains',
StartsWith: 'startsWith',
EndsWith: 'endsWith',
In: 'in',
NotIn: 'notIn'
} as const;
export type FilterOperator = typeof FilterOperator[keyof typeof FilterOperator];
export interface FilterCondition {
attribute: string;
value: unknown;
operator?: FilterOperator;
}
export interface SortCondition {
attribute: string;
direction: SortDirection;
}
export interface RangeCondition {
type: RangeType;
anchor?: RangeAnchorType;
position?: string | number;
tally?: number;
}
export interface ApiRequest {
version: number;
transaction: string;
operation: string;
data?: Record<string, unknown>;
}
export interface ApiResponse<T = unknown> {
version: number;
transaction: string;
operation: string;
status: 'success' | 'error';
data?: T;
error?: {
code: number;
message: string;
};
}

9
src/types/index.ts Normal file
View File

@@ -0,0 +1,9 @@
/**
* File manager types barrel export
*/
export * from './common';
export * from './provider';
export * from './service';
export * from './node';
export * from './api';

65
src/types/node.ts Normal file
View File

@@ -0,0 +1,65 @@
/**
* Node types for file manager (collections and entities)
*/
export type NodeType = 'files.collection' | 'files.entity';
export interface NodeBase {
'@type': NodeType;
in: string | null;
id: string;
createdBy: string;
createdOn: string;
modifiedBy: string;
modifiedOn: string;
owner: string;
signature: string;
label: string;
}
export interface FileCollection extends NodeBase {
'@type': 'files.collection';
}
export interface FileEntity extends NodeBase {
'@type': 'files.entity';
size: number;
mime: string;
format: string;
encoding: string;
}
export type FileNode = FileCollection | FileEntity;
export interface NodeListResult {
items: FileNode[];
total: number;
hasMore?: boolean;
}
export interface EntityListResult {
items: FileEntity[];
total: number;
hasMore?: boolean;
}
export interface CollectionListResult {
items: FileCollection[];
total: number;
hasMore?: boolean;
}
export interface DeltaResult {
added: FileNode[];
modified: FileNode[];
removed: string[];
signature: string;
}
export function isFileCollection(node: FileNode): node is FileCollection {
return node['@type'] === 'files.collection';
}
export function isFileEntity(node: FileNode): node is FileEntity {
return node['@type'] === 'files.entity';
}

49
src/types/provider.ts Normal file
View File

@@ -0,0 +1,49 @@
/**
* Provider types for file manager
*/
export interface ProviderCapabilitiesInterface {
CollectionList?: boolean;
CollectionListFilter?: boolean | Record<string, string>;
CollectionListSort?: boolean | string[];
CollectionExtant?: boolean;
CollectionFetch?: boolean;
CollectionCreate?: boolean;
CollectionModify?: boolean;
CollectionDestroy?: boolean;
CollectionCopy?: boolean;
CollectionMove?: boolean;
EntityList?: boolean;
EntityListFilter?: boolean | Record<string, string>;
EntityListSort?: boolean | string[];
EntityListRange?: boolean | Record<string, string[]>;
EntityDelta?: boolean;
EntityExtant?: boolean;
EntityFetch?: boolean;
EntityRead?: boolean;
EntityReadStream?: boolean;
EntityReadChunk?: boolean;
EntityCreate?: boolean;
EntityModify?: boolean;
EntityDestroy?: boolean;
EntityCopy?: boolean;
EntityMove?: boolean;
EntityWrite?: boolean;
EntityWriteStream?: boolean;
EntityWriteChunk?: boolean;
NodeList?: boolean;
NodeListFilter?: boolean | Record<string, string>;
NodeListSort?: boolean | string[];
NodeListRange?: boolean | Record<string, string[]>;
NodeDelta?: boolean;
[key: string]: boolean | string[] | Record<string, string> | Record<string, string[]> | undefined;
}
export interface ProviderInterface {
'@type': string;
id: string;
label: string;
capabilities: ProviderCapabilitiesInterface;
}
export type ProviderRecord = Record<string, ProviderInterface>;

13
src/types/service.ts Normal file
View File

@@ -0,0 +1,13 @@
/**
* Service types for file manager
*/
export interface ServiceInterface {
'@type': string;
id: string;
provider: string;
label: string;
rootId: string;
}
export type ServiceRecord = Record<string, ServiceInterface>;