UNPKG

wa-chat-server

Version:

Watson Assistant powered chat server

62 lines (61 loc) 2.35 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConversationServicesMock = void 0; class ConversationServicesMock { constructor() { this.obligatorySchemas = new Set(); this.optionalSchemas = new Set(); this.schemaPathToSchema = new Map(); this.schemaStrings = new Map(); } getObligatorySchemas() { return this.obligatorySchemas; } getOptionalSchemas() { return this.optionalSchemas; } getSchemasOnFS() { return __awaiter(this, void 0, void 0, function* () { return new Set(this.schemaPathToSchema.keys()); }); } getSchemaAsStr(path) { return __awaiter(this, void 0, void 0, function* () { return this.schemaPathToSchema.get(path); }); } // eslint-disable-next-line @typescript-eslint/no-unused-vars getServiceByName(serviceName) { return this.serviceMock; } registerServiceMock(service) { this.serviceMock = service; } getServices() { return this.serviceMock ? [this.serviceMock] : []; } setService(service) { this.serviceMock = service; service.setServices(this); } isSchemaOnFS(path) { return __awaiter(this, void 0, void 0, function* () { return (this.serviceMock && ((/request/.test(path) && this.serviceMock.hasRequestValidation()) || (/response/.test(path) && this.serviceMock.hasResponseValidation()))); }); } absolutePath(path) { return `/${path}`; } } exports.ConversationServicesMock = ConversationServicesMock;