@transai/connector-runner-otto-fleet-manager-v2 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var y=Object.create;var m=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var A=(r,t)=>{for(var e in t)m(r,e,{get:t[e],enumerable:!0})},I=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of b(t))!h.call(r,o)&&o!==e&&m(r,o,{get:()=>t[o],enumerable:!(n=P(t,o))||n.enumerable});return r};var v=(r,t,e)=>(e=r!=null?y(x(r)):{},I(t||!r||!r.__esModule?m(e,"default",{value:r,enumerable:!0}):e,r)),k=r=>I(m({},"__esModule",{value:!0}),r);var O={};A(O,{ConnectorRunnerOttoFleetManagerV2:()=>d});module.exports=k(O);var i=v(require("node:process")),f=class{#e="connector-runtime";#t;constructor(t,e){this.#t=e,i.default.on?i.default.on("message",n=>{n.cmd===this.#e&&e.logger.verbose(`${i.default.pid} Received message from parent process:`,n)}):e.logger.warn("IPC channel is not available. process.on is undefined."),i.default.send||e.logger.warn("IPC channel is not available. process.send is undefined."),t.actions?.forEach(n=>{if(n.config.templates===void 0)return;let o={};Object.entries(n.config.templates).forEach(([a,p])=>{try{o[a]=e.templating.compile(p)}catch(g){e.logger.error(`Error compiling template ${a} for action ${n.identifier}`,g)}}),n.config.parsedTemplates=o})}init=()=>Promise.resolve();start=()=>Promise.resolve();stop=()=>Promise.resolve();set callbackFunction(t){this.connectorSDK.receiver.registerCallback(this.#r(t))}get connectorSDK(){return this.#t}#r(t){return async e=>{let n=await this.#t.receiver.getActionConfig(e);return n?t(e,n):this.#t.receiver.responses.badRequest("Action not found")(e)}}};var l=class{#e;constructor(t){this.#e=t}get jsonrpc(){return"2.0"}async execute(t){let e=Math.floor(1e7+Math.random()*9e7);return(await this.#e.post("/operations",{id:e,jsonrpc:this.jsonrpc,method:this.method,params:t})).data.result.id}};var s=class extends l{static TYPE="create-mission";get method(){return"createMission"}};var u=class{#e;#t;constructor(t,e){this.#e=t,this.#t={[s.TYPE]:new s(e)}}get callbackFunctionChain(){return this.#r(this.#e.receiver.emitEventType(this.#e.receiver.responses.created()))}#r(t){return async(e,n)=>{let o=n.config.parsedTemplates,a=o.action({inputs:e.payload}).trim(),p=this.#t[a];if(!p)return this.#e.receiver.responses.badRequest(`Action ${a} does not exist.`)(e);let g=o.params({inputs:e.payload}).trim(),C=await p.execute(JSON.parse(g));return this.#e.logger.info(`Action ${a} executed successfully with id: ${C}`),t(e)}}};var c=class r{static NAME="otto-fleet-manager-v2-extractor-missions";static INTERVAL=60;#e;#t;constructor(t,e){this.#e=t,this.#t=e}get name(){return r.NAME}async onRun(){let t=new URLSearchParams({limit:"100",offset:"0"});for(;;){let e=await this.#t.get(`/missions?${t.toString()}`);if(await this.#e.sender.documents(e.data.results,{collection:"missions",keyField:"id"}),!e.data.next)break;let n=new URL(e.data.next);if(!n.searchParams.get("offset"))break;t.set("offset",n.searchParams.get("offset")||"0")}}};var d=class extends f{#e;constructor(t,e){super(t,e);let{config:n}=this.connectorSDK;this.#e=this.connectorSDK.httpClient({baseUrl:`https://${n.hostname}/api/fleet/v2`});let o=new u(this.connectorSDK,this.#e);this.callbackFunction=o.callbackFunctionChain}init=async()=>{await Promise.all([this.connectorSDK.processing.registerInterval(c.INTERVAL,new c(this.connectorSDK,this.#e))])}};0&&(module.exports={ConnectorRunnerOttoFleetManagerV2});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -23,13 +23,26 @@ export interface NumberOutputParameterInterface extends OutputItemParameterInter
|
|
|
23
23
|
export interface OutputParameterInterface {
|
|
24
24
|
[key: string]: OutputItemParameterInterface | ArrayOutputParameterInterface | NumberOutputParameterInterface;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
interface BaseInputParameter {
|
|
27
27
|
name: string;
|
|
28
28
|
description?: string;
|
|
29
|
-
type: 'string' | 'number' | 'boolean' | 'array';
|
|
30
29
|
required?: boolean;
|
|
31
|
-
items?: Array<InputParameterInterface>;
|
|
32
30
|
}
|
|
31
|
+
export interface ValueInputParameter extends BaseInputParameter {
|
|
32
|
+
type: 'string' | 'number' | 'boolean';
|
|
33
|
+
}
|
|
34
|
+
export interface SimpleArrayInputParameter extends BaseInputParameter {
|
|
35
|
+
type: 'simple-array';
|
|
36
|
+
itemType: 'string' | 'number' | 'boolean';
|
|
37
|
+
}
|
|
38
|
+
export interface ArrayInputParameter extends BaseInputParameter {
|
|
39
|
+
type: 'array';
|
|
40
|
+
items: Array<InputParameterInterface>;
|
|
41
|
+
}
|
|
42
|
+
export interface UnknownInputParameter extends BaseInputParameter {
|
|
43
|
+
type: 'unknown';
|
|
44
|
+
}
|
|
45
|
+
export type InputParameterInterface = ValueInputParameter | SimpleArrayInputParameter | ArrayInputParameter | UnknownInputParameter;
|
|
33
46
|
export interface ActionInterface {
|
|
34
47
|
identifier: string;
|
|
35
48
|
version: string;
|
|
@@ -47,3 +60,4 @@ export interface ActionInterface {
|
|
|
47
60
|
mode?: ConnectorOrigin;
|
|
48
61
|
createdAt: Date;
|
|
49
62
|
}
|
|
63
|
+
export {};
|