MCPcopy Create free account
hub / github.com/chieapp/chie / createService

Method createService

src/controller/service-manager.ts:89–100  ·  view source on GitHub ↗
(name: string, serviceName: string, credential: APICredential, options?: Partial<WebServiceOptions>)

Source from the content-addressed store, hash-verified

87 }
88
89 createService(name: string, serviceName: string, credential: APICredential, options?: Partial<WebServiceOptions>): WebService {
90 if (!(serviceName in this.#services))
91 throw new Error(`Service with name "${serviceName}" does not exist.`);
92 // Do runtime check of API type compatibility.
93 const {icon, apiClass} = apiManager.getAPIRecord(credential.type);
94 const {apiClasses, serviceClass} = this.#services[serviceName];
95 if (!apiClasses.find(A => matchClass(A, apiClass)))
96 throw new Error(`Service "${serviceName}" does not support API type "${credential.type}".`);
97 // Create service.
98 const serviceOptions = deepAssign({name, api: new apiClass(credential), icon}, options);
99 return new serviceClass(serviceOptions);
100 }
101}
102
103export default new ServiceManager;

Callers 1

createAssistantMethod · 0.80

Calls 3

matchClassFunction · 0.90
deepAssignFunction · 0.90
getAPIRecordMethod · 0.80

Tested by

no test coverage detected