UNPKG

fsm-sdk

Version:

Node.JS sdk to interface with SAP Field Service Management APIs.

127 lines (126 loc) 5.51 kB
import { ClientConfig } from '../client-config.model'; import { HttpService } from '../http/http-service'; import { OAuthService } from '../oauth/oauth.service'; import { RuleDto, PageRuleDto, PageCustomRuleExecutionRecordDto, EventType, HealthState, ExecutionStatus } from './rules.model'; /** * Rules API Service for FSM Business Rules * * Implements business rule engine to validate and execute custom rules. * Stores business rule definitions and rule executions. * * @see https://api.sap.com/api/cloud_rules_service_ext/overview */ export declare class RulesAPIService { private _config; private _http; private _auth; constructor(_config: Readonly<ClientConfig>, _http: Readonly<HttpService>, _auth: Readonly<OAuthService>); /** * Constructs the API URL for rules operations. * * @param {string} path - Path to append to the base URL. * @returns {string} The complete API URL. */ private getApiUrl; /** * Get all rules with optional filtering and pagination. * * @param {object} params - Optional query parameters for filtering, pagination, and sorting. * @param {string} params.kafkaEventName - Filter by Kafka event name. * @param {string} params.code - Filter by rule code. * @param {string} params.name - Filter by rule name. * @param {boolean} params.embedded - Filter by embedded status. * @param {boolean} params.enabled - Filter by enabled status. * @param {EventType} params.eventType - Filter by event type. * @param {string} params.objectType - Filter by object type. * @param {HealthState} params.healthState - Filter by health state. * @param {number} params.page - Page number for pagination. * @param {number} params.size - Page size for pagination. * @param {string} params.sortBy - Field to sort by (default: 'name'). * @param {string} params.order - Sort order: 'asc' or 'desc' (default: 'asc'). * @param {string} params.search - Search text. * @returns {Promise<PageRuleDto | null>} A promise resolving to paginated rules. */ getRules(params?: Partial<{ kafkaEventName: string; code: string; name: string; embedded: boolean; enabled: boolean; eventType: EventType; objectType: string; healthState: HealthState; page: number; size: number; sortBy: string; order: 'asc' | 'desc'; search: string; }>): Promise<PageRuleDto | null>; /** * Create a new rule. * * @param {object} data - Rule data to create. * @returns {Promise<RuleDto | null>} A promise resolving to the created rule. */ createRule(data: Partial<RuleDto>): Promise<RuleDto | null>; /** * Get a specific rule by ID. * * @param {string} id - Rule identifier (UUID). * @returns {Promise<RuleDto | null>} A promise resolving to the rule. */ getRule(id: string): Promise<RuleDto | null>; /** * Update an existing rule (partial update). * * @param {string} id - Rule identifier (UUID). * @param {object} data - Partial rule data to update. * @returns {Promise<RuleDto | null>} A promise resolving to the updated rule. */ updateRule(id: string, data: Partial<RuleDto>): Promise<RuleDto | null>; /** * Create or update a rule (full replace or create). * * @param {string} id - Rule identifier (UUID). * @param {object} data - Complete rule data. * @returns {Promise<RuleDto | null>} A promise resolving to the created or updated rule. */ createOrUpdateRule(id: string, data: Partial<RuleDto>): Promise<RuleDto | null>; /** * Get execution records for a specific rule. * * @param {string} id - Rule identifier (UUID). * @param {object} params - Optional query parameters for filtering, pagination, and sorting. * @param {string} params.executionDateFrom - Filter by execution date from (ISO date format). * @param {string} params.executionDateTo - Filter by execution date to (ISO date format). * @param {ExecutionStatus} params.status - Filter by execution status. * @param {string} params.objectId - Filter by object ID. * @param {string} params.userId - Filter by user ID. * @param {string} params.clientId - Filter by client ID. * @param {string} params.requestId - Filter by request ID. * @param {EventType} params.eventType - Filter by event type. * @param {string} params.errorMessage - Filter by error message. * @param {number} params.page - Page number for pagination. * @param {number} params.size - Page size for pagination. * @param {string} params.sortBy - Field to sort by. * @param {string} params.sortOrder - Sort order: 'asc' or 'desc'. * @param {string} params.search - Search text. * @returns {Promise<PageCustomRuleExecutionRecordDto | null>} A promise resolving to paginated execution records. */ getRuleExecutionRecords(id: string, params?: Partial<{ executionDateFrom: string; executionDateTo: string; status: ExecutionStatus; objectId: string; userId: string; clientId: string; requestId: string; eventType: EventType; errorMessage: string; page: number; size: number; sortBy: string; sortOrder: 'asc' | 'desc'; search: string; }>): Promise<PageCustomRuleExecutionRecordDto | null>; }