Initial commit
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* Entity management service
|
||||
*/
|
||||
|
||||
import { createFetchWrapper } from '@KTXC/utils/helpers/fetch-wrapper-core';
|
||||
|
||||
const fetchWrapper = createFetchWrapper();
|
||||
import type {
|
||||
EntityListRequest,
|
||||
EntityListResponse,
|
||||
EntityDeltaRequest,
|
||||
EntityDeltaResponse,
|
||||
EntityExtantRequest,
|
||||
EntityExtantResponse,
|
||||
EntityFetchRequest,
|
||||
EntityFetchResponse,
|
||||
EntityCreateRequest,
|
||||
EntityCreateResponse,
|
||||
EntityModifyRequest,
|
||||
EntityModifyResponse,
|
||||
EntityDestroyRequest,
|
||||
EntityDestroyResponse,
|
||||
} from '../types/entity';
|
||||
|
||||
const BASE_URL = '/m/chrono_manager/entity';
|
||||
|
||||
export const entityService = {
|
||||
|
||||
/**
|
||||
* List all available entities (events, tasks, journals)
|
||||
*
|
||||
* @param request - Entity list request parameters
|
||||
* @returns Promise with entity list grouped by provider, service, and collection
|
||||
*/
|
||||
async list(request: EntityListRequest = {}): Promise<EntityListResponse> {
|
||||
return await fetchWrapper.post(`${BASE_URL}/list`, request);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get delta changes for entities
|
||||
*
|
||||
* @param request - Entity delta request with source selector
|
||||
* @returns Promise with delta changes (created, modified, deleted)
|
||||
*/
|
||||
async delta(request: EntityDeltaRequest): Promise<EntityDeltaResponse> {
|
||||
return await fetchWrapper.post(`${BASE_URL}/delta`, request);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check which entities exist/are available
|
||||
*
|
||||
* @param request - Entity extant request with source selector
|
||||
* @returns Promise with entity availability status
|
||||
*/
|
||||
async extant(request: EntityExtantRequest): Promise<EntityExtantResponse> {
|
||||
return await fetchWrapper.post(`${BASE_URL}/extant`, request);
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetch specific entities
|
||||
*
|
||||
* @param request - Entity fetch request
|
||||
* @returns Promise with entity details
|
||||
*/
|
||||
async fetch(request: EntityFetchRequest): Promise<EntityFetchResponse> {
|
||||
return await fetchWrapper.post(`${BASE_URL}/fetch`, request);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a new entity
|
||||
*
|
||||
* @param request - Entity create request
|
||||
* @returns Promise with created entity
|
||||
*/
|
||||
async create(request: EntityCreateRequest): Promise<EntityCreateResponse> {
|
||||
return await fetchWrapper.post(`${BASE_URL}/create`, request);
|
||||
},
|
||||
|
||||
/**
|
||||
* Modify an existing entity
|
||||
*
|
||||
* @param request - Entity modify request
|
||||
* @returns Promise with modified entity
|
||||
*/
|
||||
async modify(request: EntityModifyRequest): Promise<EntityModifyResponse> {
|
||||
return await fetchWrapper.post(`${BASE_URL}/modify`, request);
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete an entity
|
||||
*
|
||||
* @param request - Entity destroy request
|
||||
* @returns Promise with deletion result
|
||||
*/
|
||||
async destroy(request: EntityDestroyRequest): Promise<EntityDestroyResponse> {
|
||||
return await fetchWrapper.post(`${BASE_URL}/destroy`, request);
|
||||
},
|
||||
};
|
||||
|
||||
export default entityService;
|
||||
Reference in New Issue
Block a user