@comake/skl-js-engine
Version:
Standard Knowledge Language Javascript Engine
114 lines (113 loc) • 6.15 kB
TypeScript
import type { GraphObject, NodeObject } from 'jsonld';
import type { Frame } from 'jsonld/jsonld-spec';
import { globalHooks } from './hooks/globalHooks';
import type { ExecutionOptions } from './JsExecutor';
import type { ICodeExecutor } from './JsExecutor/types';
import type { SklEngineOptions } from './SklEngineOptions';
import type { FindAllOptions, FindOneOptions, FindOptionsWhere } from './storage/FindOptionsTypes';
import type { GroupByOptions, GroupByResponse } from './storage/GroupOptionTypes';
import type { RawQueryResult } from './storage/query-adapter/QueryAdapter';
import type { Capability, CapabilityConfig, Entity, JSONObject, JSONValue, Mapping, OrArray, SKLEngineInterface } from './util/Types';
export declare type CapabilityHandler = <T extends OrArray<NodeObject> = OrArray<NodeObject>>(params: JSONObject, capabilityConfig?: CapabilityConfig) => Promise<T>;
export declare type CapabilityInterface = Record<string, CapabilityHandler>;
export declare type MappingResponseOption<T extends boolean> = T extends true ? JSONObject : NodeObject;
export declare class SKLEngine implements SKLEngineInterface {
private readonly queryAdapter;
private readonly functions?;
private readonly inputFiles?;
private readonly globalCallbacks?;
private readonly disableValidation?;
readonly capability: CapabilityInterface;
private readonly isDebugMode;
private codeExecutor;
private readonly skdsEndpointUrl;
private readonly scriptPath;
constructor(options: SklEngineOptions);
setCodeExecutor(codeExecutor: ICodeExecutor): void;
executeRawQuery<T extends RawQueryResult>(query: string): Promise<T[]>;
executeRawUpdate(query: string): Promise<void>;
executeRawConstructQuery(query: string, frame?: Frame): Promise<GraphObject>;
find(options?: FindOneOptions): Promise<Entity>;
findBy(where: FindOptionsWhere, notFoundErrorMessage?: string): Promise<Entity>;
findByIfExists(options: FindOptionsWhere): Promise<Entity | undefined>;
findAll(options?: FindAllOptions): Promise<Entity[]>;
groupBy(options: GroupByOptions): Promise<GroupByResponse>;
findAllBy(where: FindOptionsWhere): Promise<Entity[]>;
exists(options?: FindAllOptions): Promise<boolean>;
count(options?: FindAllOptions): Promise<number>;
save(entity: Entity): Promise<Entity>;
save(entities: Entity[]): Promise<Entity[]>;
update(id: string, attributes: Partial<Entity>): Promise<void>;
update(ids: string[], attributes: Partial<Entity>): Promise<void>;
private validateEntitiesConformToNounSchema;
private groupEntitiesByType;
private getSuperClassesOfNoun;
private getSuperClassesOfNouns;
private getParentsOfSelector;
private validateEntityConformsToNounSchema;
private validateEntitiesWithIdsConformsToNounSchemaForAttributes;
private getNounsAndParentNounsOfEntity;
private validateEntityWithIdConformsToNounSchemaForAttributes;
delete(id: string): Promise<void>;
delete(ids: string[]): Promise<void>;
destroy(entity: Entity): Promise<Entity>;
destroy(entities: Entity[]): Promise<Entity[]>;
destroyAll(): Promise<void>;
performMapping(args: JSONValue, mapping: OrArray<NodeObject>, frame?: Record<string, any>, capabilityConfig?: CapabilityConfig, jsExecutionOptions?: ExecutionOptions): Promise<NodeObject>;
executeTrigger(integration: string, payload: any): Promise<void>;
private findTriggerCapabilityMapping;
private executeCapabilityByName;
private findCapabilityWithName;
executeCapability(capability: Capability, capabilityArgs: JSONObject, capabilityConfig?: CapabilityConfig): Promise<OrArray<NodeObject>>;
private findMappingForCapabilityContextually;
executeMapping(mapping: Mapping, args: JSONObject, capabilityConfig?: CapabilityConfig, account?: Entity): Promise<OrArray<NodeObject>>;
private shouldValidate;
private executeOperationMapping;
private executeSeriesMapping;
private rdfListToArray;
private executeSeriesFromList;
private executeCapabilityMapping;
private addPreProcessingMappingToArgs;
private replaceTypeAndId;
private updateEntityFromcapabilityArgs;
private saveEntityOrEntitiesFromcapabilityArgs;
private destroyEntityOrEntitiesFromcapabilityArgs;
private countAndWrapValueFromcapabilityArgs;
private existsAndWrapValueFromcapabilityArgs;
findAndExecuteCapability(capabilityId: string, args: Record<string, any>, capabilityConfig?: CapabilityConfig): Promise<OrArray<NodeObject>>;
private executeParallelMapping;
private findCapabilityIntegrationMapping;
private performOperationMappingWithArgs;
private performOperation;
private axiosResponseAndParamsToOperationResponse;
private performReturnValueMappingWithFrameIfDefined;
private performParameterMappingOnArgsIfDefined;
private getDataAtReference;
private getOpenApiDescriptionForIntegratedProduct;
private findSecurityCredentialsForAccountIfDefined;
private findgetOpenApiRuntimeAuthorizationCapabilityIfDefined;
private getRuntimeCredentialsWithSecurityCredentials;
private createOpenApiOperationExecutorWithSpec;
private findCapabilityNounMapping;
private performCapabilityMappingWithArgs;
private assertCapabilityParamsMatchParameterSchemas;
private performOpenapiOperationWithCredentials;
private getHeadersFromRuntimeCredentials;
private getAuthorizationHeaderFromRuntimeCredentials;
private isInvalidTokenError;
private refreshSecurityCredentials;
private getOauthConfigurationFromSecurityCredentials;
private assertCapabilityReturnValueMatchesReturnTypeSchema;
private convertToQuadsAndValidateAgainstShape;
private performOauthSecuritySchemeStageWithCredentials;
private getDataFromDataSource;
private getDataFromJsonDataSource;
private getJsonDataFromSource;
private throwValidationReportError;
private validationReportToMessages;
private ifCapabilityStreaming;
private isJavaScriptCode;
private ensureNodeObject;
private executeJavaScriptMapping;
get hooks(): typeof globalHooks;
}