@transai/connector-runner-gpms 0.1.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/CHANGELOG.md +13 -0
- package/README.md +11 -0
- package/index.cjs +370 -0
- package/index.cjs.map +7 -0
- package/libs/connector-runner-gpms/src/actions/action.interface.d.ts +8 -0
- package/libs/connector-runner-gpms/src/actions/actions-service.d.ts +6 -0
- package/libs/connector-runner-gpms/src/actions/create-client.action.d.ts +8 -0
- package/libs/connector-runner-gpms/src/actions/create-order-file.action.d.ts +8 -0
- package/libs/connector-runner-gpms/src/actions/create-order.action.d.ts +8 -0
- package/libs/connector-runner-gpms/src/actions/create-quote-file.action.d.ts +8 -0
- package/libs/connector-runner-gpms/src/actions/create-quote.action.d.ts +8 -0
- package/libs/connector-runner-gpms/src/actions/order-ready.action.d.ts +8 -0
- package/libs/connector-runner-gpms/src/actions/quote-ready.action.d.ts +8 -0
- package/libs/connector-runner-gpms/src/connector-runner-gpms.d.ts +9 -0
- package/libs/connector-runner-gpms/src/index.d.ts +1 -0
- package/libs/connector-runner-gpms/src/types.d.ts +6 -0
- package/libs/connector-runner-gpms/src/webhook-server.d.ts +9 -0
- package/libs/connector-runtime-sdk/src/index.d.ts +5 -0
- package/libs/connector-runtime-sdk/src/lib/connector-runtime.d.ts +16 -0
- package/libs/connector-runtime-sdk/src/lib/connector-runtime.interface.d.ts +5 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/files.sdk.interface.d.ts +19 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/http-client.interface.d.ts +47 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/index.d.ts +10 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/logger.sdk.interface.d.ts +7 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/offset-store.sdk.interface.d.ts +13 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.d.ts +30 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/receiver.sdk.interface.d.ts +14 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/sdk.interface.d.ts +31 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/sender.sdk.interface.d.ts +22 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/telemetry.sdk.interface.d.ts +15 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/templating.sdk.interface.d.ts +12 -0
- package/libs/connector-runtime-sdk/src/lib/support/index.d.ts +1 -0
- package/libs/connector-runtime-sdk/src/lib/support/null-logger.d.ts +8 -0
- package/libs/connector-runtime-sdk/src/lib/types/action.d.ts +49 -0
- package/libs/connector-runtime-sdk/src/lib/types/kafka.d.ts +40 -0
- package/libs/connector-runtime-sdk/src/lib/types.d.ts +26 -0
- package/package.json +19 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionInterface, ConnectorSDKInterface, HttpClientSDKInterface, KafkaCallbackResponse, XodBaseMessageType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
export interface GpmsActionInterface {
|
|
3
|
+
readonly identifier: string;
|
|
4
|
+
execute(inputs: Record<string, unknown>, action: ActionInterface): Promise<((message: XodBaseMessageType) => Promise<KafkaCallbackResponse>) | null>;
|
|
5
|
+
}
|
|
6
|
+
export interface GpmsActionInterfaceConstructor {
|
|
7
|
+
new (connectorSDK: ConnectorSDKInterface, httpClient: HttpClientSDKInterface): GpmsActionInterface;
|
|
8
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionInterface, ConnectorSDKInterface, HttpClientSDKInterface, KafkaCallbackResponse, XodJobType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
export declare class ActionsService {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(connectorSDK: ConnectorSDKInterface, httpClient: HttpClientSDKInterface);
|
|
5
|
+
get callbackFunctionChain(): (message: XodJobType, action: ActionInterface) => Promise<KafkaCallbackResponse>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionInterface, ConnectorSDKInterface, HttpClientSDKInterface, KafkaCallbackResponse, XodBaseMessageType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { GpmsActionInterface } from './action.interface';
|
|
3
|
+
export declare class CreateClientAction implements GpmsActionInterface {
|
|
4
|
+
#private;
|
|
5
|
+
readonly identifier = "create_client";
|
|
6
|
+
constructor(connectorSDK: ConnectorSDKInterface, httpClient: HttpClientSDKInterface);
|
|
7
|
+
execute(inputs: Record<string, string>, action: ActionInterface): Promise<((message: XodBaseMessageType) => Promise<KafkaCallbackResponse>) | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConnectorSDKInterface, HttpClientSDKInterface, KafkaCallbackResponse, XodBaseMessageType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { GpmsActionInterface } from './action.interface';
|
|
3
|
+
export declare class CreateOrderFileAction implements GpmsActionInterface {
|
|
4
|
+
#private;
|
|
5
|
+
readonly identifier = "create_order_file";
|
|
6
|
+
constructor(connectorSDK: ConnectorSDKInterface, httpClient: HttpClientSDKInterface);
|
|
7
|
+
execute(inputs: Record<string, string>): Promise<((message: XodBaseMessageType) => Promise<KafkaCallbackResponse>) | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionInterface, ConnectorSDKInterface, HttpClientSDKInterface, KafkaCallbackResponse, XodBaseMessageType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { GpmsActionInterface } from './action.interface';
|
|
3
|
+
export declare class CreateOrderAction implements GpmsActionInterface {
|
|
4
|
+
#private;
|
|
5
|
+
readonly identifier = "create_order";
|
|
6
|
+
constructor(connectorSDK: ConnectorSDKInterface, httpClient: HttpClientSDKInterface);
|
|
7
|
+
execute(inputs: Record<string, string>, action: ActionInterface): Promise<((message: XodBaseMessageType) => Promise<KafkaCallbackResponse>) | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConnectorSDKInterface, HttpClientSDKInterface, KafkaCallbackResponse, XodBaseMessageType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { GpmsActionInterface } from './action.interface';
|
|
3
|
+
export declare class CreateQuoteFileAction implements GpmsActionInterface {
|
|
4
|
+
#private;
|
|
5
|
+
readonly identifier = "create_quote_file";
|
|
6
|
+
constructor(connectorSDK: ConnectorSDKInterface, httpClient: HttpClientSDKInterface);
|
|
7
|
+
execute(inputs: Record<string, string>): Promise<((message: XodBaseMessageType) => Promise<KafkaCallbackResponse>) | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionInterface, ConnectorSDKInterface, HttpClientSDKInterface, KafkaCallbackResponse, XodBaseMessageType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { GpmsActionInterface } from './action.interface';
|
|
3
|
+
export declare class CreateQuoteAction implements GpmsActionInterface {
|
|
4
|
+
#private;
|
|
5
|
+
readonly identifier = "create_quote";
|
|
6
|
+
constructor(connectorSDK: ConnectorSDKInterface, httpClient: HttpClientSDKInterface);
|
|
7
|
+
execute(inputs: Record<string, string>, action: ActionInterface): Promise<((message: XodBaseMessageType) => Promise<KafkaCallbackResponse>) | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConnectorSDKInterface, HttpClientSDKInterface, KafkaCallbackResponse, XodBaseMessageType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { GpmsActionInterface } from './action.interface';
|
|
3
|
+
export declare class OrderReadyAction implements GpmsActionInterface {
|
|
4
|
+
#private;
|
|
5
|
+
readonly identifier = "order_ready";
|
|
6
|
+
constructor(connectorSDK: ConnectorSDKInterface, httpClient: HttpClientSDKInterface);
|
|
7
|
+
execute(inputs: Record<string, unknown>): Promise<((message: XodBaseMessageType) => Promise<KafkaCallbackResponse>) | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConnectorSDKInterface, HttpClientSDKInterface, KafkaCallbackResponse, XodBaseMessageType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { GpmsActionInterface } from './action.interface';
|
|
3
|
+
export declare class QuoteReadyAction implements GpmsActionInterface {
|
|
4
|
+
#private;
|
|
5
|
+
readonly identifier = "quote_ready";
|
|
6
|
+
constructor(connectorSDK: ConnectorSDKInterface, httpClient: HttpClientSDKInterface);
|
|
7
|
+
execute(inputs: Record<string, unknown>): Promise<((message: XodBaseMessageType) => Promise<KafkaCallbackResponse>) | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConnectorInterface, ConnectorRuntimeSDK, ConnectorSDKInterface } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { ConnectorConfig } from './types';
|
|
3
|
+
export declare class ConnectorRunnerGpms extends ConnectorRuntimeSDK<ConnectorConfig> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(connector: ConnectorInterface, connectorSDK: ConnectorSDKInterface);
|
|
6
|
+
init: () => Promise<void>;
|
|
7
|
+
start: () => Promise<void>;
|
|
8
|
+
stop: () => Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './connector-runner-gpms';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConnectorSDKInterface } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { ConnectorConfig } from './types';
|
|
3
|
+
export declare class WebhookServer {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(sdk: ConnectorSDKInterface<ConnectorConfig>);
|
|
6
|
+
init(): void;
|
|
7
|
+
start(): void;
|
|
8
|
+
stop(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ConnectorRuntimeInterface } from './connector-runtime.interface';
|
|
2
|
+
import { ConnectorSDKInterface } from './sdk';
|
|
3
|
+
import { ActionInterface, BaseConnectorConfig, ConnectorInterface, KafkaCallbackResponse, XodJobType } from './types';
|
|
4
|
+
export interface IpcMessage {
|
|
5
|
+
cmd: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export declare abstract class ConnectorRuntimeSDK<T extends BaseConnectorConfig = BaseConnectorConfig> implements ConnectorRuntimeInterface {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(connector: ConnectorInterface, connectorSDK: ConnectorSDKInterface);
|
|
11
|
+
init: () => Promise<void>;
|
|
12
|
+
start: () => Promise<void>;
|
|
13
|
+
stop: () => Promise<void>;
|
|
14
|
+
set callbackFunction(callback: (message: XodJobType, action: ActionInterface) => Promise<KafkaCallbackResponse>);
|
|
15
|
+
protected get connectorSDK(): ConnectorSDKInterface<T>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface FileInfo {
|
|
2
|
+
type: 'DIRECTORY' | 'FILE';
|
|
3
|
+
name: string;
|
|
4
|
+
size: number;
|
|
5
|
+
modifyTime: Date;
|
|
6
|
+
}
|
|
7
|
+
export interface FileHandleInterface {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
get(): Buffer;
|
|
10
|
+
close(): boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface FilesSDKInterface {
|
|
13
|
+
list(path: string): Promise<Array<FileInfo>>;
|
|
14
|
+
read(filePath: string): Promise<FileHandleInterface>;
|
|
15
|
+
write(filePath: string, data: FileHandleInterface | Buffer | string): Promise<boolean>;
|
|
16
|
+
delete(path: string): Promise<boolean>;
|
|
17
|
+
exists(path: string): Promise<boolean>;
|
|
18
|
+
pathAsDsn(path: string): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface HttpConfig {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
contentType?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
}
|
|
6
|
+
export type HttpRequestOptions<D = string | object> = {
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
params?: Record<string, string | number | boolean>;
|
|
9
|
+
data?: D;
|
|
10
|
+
withCredentials?: boolean;
|
|
11
|
+
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream' | 'formdata';
|
|
12
|
+
};
|
|
13
|
+
export type HttpRequestOptionsFormatter<D = string | object> = (requestOptions: HttpRequestOptions<D>, method: HttpMethod, url: string) => Promise<HttpRequestOptions<D>> | HttpRequestOptions<D>;
|
|
14
|
+
export type HttpErrorResponseCallbackRequest<D = string | object> = {
|
|
15
|
+
client: HttpClientSDKInterface;
|
|
16
|
+
method: HttpMethod;
|
|
17
|
+
url: string;
|
|
18
|
+
options?: HttpRequestOptions<D>;
|
|
19
|
+
};
|
|
20
|
+
export type HttpErrorResponseCallback<R = unknown, D = string | object> = (error: HttpError, request: HttpErrorResponseCallbackRequest<D>) => HttpClientPromise<R>;
|
|
21
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
22
|
+
export type HttpResponseHeader = string | Array<string> | number | boolean | null;
|
|
23
|
+
export type HttpResponse<D = unknown> = {
|
|
24
|
+
status: number;
|
|
25
|
+
data: D;
|
|
26
|
+
headers?: Record<string, HttpResponseHeader>;
|
|
27
|
+
};
|
|
28
|
+
export type HttpError = {
|
|
29
|
+
status: number;
|
|
30
|
+
error?: string;
|
|
31
|
+
};
|
|
32
|
+
interface PromiseWithReason<T = unknown, R = unknown> extends Promise<T> {
|
|
33
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: R) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
|
|
34
|
+
catch<TResult = never>(onrejected?: ((reason: R) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
|
|
35
|
+
}
|
|
36
|
+
export type HttpClientPromise<T> = PromiseWithReason<HttpResponse<T>, HttpError>;
|
|
37
|
+
export interface HttpClientSDKInterface {
|
|
38
|
+
get<R = unknown>(destination: string, options?: HttpRequestOptions): HttpClientPromise<R>;
|
|
39
|
+
post<R = unknown, D = string | object>(destination: string, data: D, options?: HttpRequestOptions<D>): HttpClientPromise<R>;
|
|
40
|
+
put<R = unknown, D = string | object>(destination: string, data: D, options?: HttpRequestOptions<D>): HttpClientPromise<R>;
|
|
41
|
+
patch<R = unknown, D = string | object>(destination: string, data: D, options?: HttpRequestOptions<D>): HttpClientPromise<R>;
|
|
42
|
+
delete<R = unknown>(destination: string, options?: HttpRequestOptions): HttpClientPromise<R>;
|
|
43
|
+
request<R = unknown, D = string | object>(method: HttpMethod, url: string, options?: HttpRequestOptions<D>): HttpClientPromise<R>;
|
|
44
|
+
setRequestOptionsFormatter<D = string | object>(formatter: HttpRequestOptionsFormatter<D>): HttpClientSDKInterface;
|
|
45
|
+
setErrorResponseHandler<R = unknown, D = string | object>(callback?: HttpErrorResponseCallback<R, D>): HttpClientSDKInterface;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './sdk.interface';
|
|
2
|
+
export * from './http-client.interface';
|
|
3
|
+
export * from './logger.sdk.interface';
|
|
4
|
+
export * from './offset-store.sdk.interface';
|
|
5
|
+
export * from './processing.sdk.interface';
|
|
6
|
+
export * from './receiver.sdk.interface';
|
|
7
|
+
export * from './sender.sdk.interface';
|
|
8
|
+
export * from './telemetry.sdk.interface';
|
|
9
|
+
export * from './templating.sdk.interface';
|
|
10
|
+
export * from './files.sdk.interface';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface StoredOffset {
|
|
2
|
+
timestamp: number;
|
|
3
|
+
id: number | string;
|
|
4
|
+
isoDate?: string;
|
|
5
|
+
date?: string;
|
|
6
|
+
rawTimestamp?: number | string;
|
|
7
|
+
[key: string]: string | number | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface OffsetStoreSDKInterface {
|
|
10
|
+
getOffset(identifier: string): Promise<StoredOffset>;
|
|
11
|
+
setOffset(offset: StoredOffset, identifier: string): void;
|
|
12
|
+
flush(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The default timeout is 10 minutes */
|
|
2
|
+
export declare const DEFAULT_TIMEOUT_SECONDS: number;
|
|
3
|
+
export interface IntervalHandler {
|
|
4
|
+
name?: string;
|
|
5
|
+
onInit?: () => Promise<void> | void;
|
|
6
|
+
onRun: () => Promise<void> | void;
|
|
7
|
+
onStop?: () => Promise<void> | void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Options for configuring an interval registered via {@link ProcessingSDKInterface.registerInterval}.
|
|
11
|
+
*/
|
|
12
|
+
export type RegisterIntervalOptions = {
|
|
13
|
+
/**
|
|
14
|
+
* If true, the handler will be invoked immediately once on registration,
|
|
15
|
+
* in addition to subsequent scheduled executions.
|
|
16
|
+
*/
|
|
17
|
+
immediate?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Optional timeout, in seconds, for the interval.
|
|
20
|
+
*
|
|
21
|
+
* This value should be a positive number representing the maximum time,
|
|
22
|
+
* in seconds, that the interval is allowed to run before being considered
|
|
23
|
+
* timed out. Callers should not pass 0 or negative values.
|
|
24
|
+
*/
|
|
25
|
+
timeout?: number;
|
|
26
|
+
};
|
|
27
|
+
export interface ProcessingSDKInterface {
|
|
28
|
+
registerInterval(intervalSeconds: number, handler: IntervalHandler, options?: RegisterIntervalOptions): Promise<string>;
|
|
29
|
+
stopInterval(name: string): Promise<void>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ActionInterface, KafkaCallbackResponse, KafkaCallbackResponseType, XodJobType } from '../types';
|
|
2
|
+
export interface ReceiverSDKInterface {
|
|
3
|
+
readonly responses: {
|
|
4
|
+
readonly ok: KafkaCallbackResponseType;
|
|
5
|
+
readonly created: KafkaCallbackResponseType;
|
|
6
|
+
readonly badRequest: KafkaCallbackResponseType;
|
|
7
|
+
readonly unprocessableEntity: KafkaCallbackResponseType;
|
|
8
|
+
readonly notFound: KafkaCallbackResponseType;
|
|
9
|
+
readonly internalServerError: KafkaCallbackResponseType;
|
|
10
|
+
};
|
|
11
|
+
registerCallback<T extends XodJobType = XodJobType>(callbackFunction: (message: T) => Promise<KafkaCallbackResponse>, eventType?: string, identifier?: string): void;
|
|
12
|
+
getActionConfig(message: XodJobType): Promise<ActionInterface | null>;
|
|
13
|
+
emitEventType<T extends XodJobType = XodJobType>(callbackFunction: (message: T) => Promise<KafkaCallbackResponse>): (message: T) => Promise<KafkaCallbackResponse>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseConnectorConfig } from '../types';
|
|
2
|
+
import { FilesSDKInterface } from './files.sdk.interface';
|
|
3
|
+
import { HttpClientSDKInterface, HttpConfig } from './http-client.interface';
|
|
4
|
+
import { LoggerSDKInterface } from './logger.sdk.interface';
|
|
5
|
+
import { OffsetStoreSDKInterface } from './offset-store.sdk.interface';
|
|
6
|
+
import { ProcessingSDKInterface } from './processing.sdk.interface';
|
|
7
|
+
import { ReceiverSDKInterface } from './receiver.sdk.interface';
|
|
8
|
+
import { SenderSDKInterface } from './sender.sdk.interface';
|
|
9
|
+
import { TelemetrySDKInterface } from './telemetry.sdk.interface';
|
|
10
|
+
import { TemplatingSDKInterface } from './templating.sdk.interface';
|
|
11
|
+
export interface ConnectorSDKInterface<T = BaseConnectorConfig> {
|
|
12
|
+
get config(): T;
|
|
13
|
+
get logger(): LoggerSDKInterface;
|
|
14
|
+
get sender(): SenderSDKInterface;
|
|
15
|
+
get receiver(): ReceiverSDKInterface;
|
|
16
|
+
get templating(): TemplatingSDKInterface;
|
|
17
|
+
/**
|
|
18
|
+
* Service to schedule and manage processing tasks that need monitoring and retries.
|
|
19
|
+
*/
|
|
20
|
+
get processing(): ProcessingSDKInterface;
|
|
21
|
+
get offsetStore(): OffsetStoreSDKInterface;
|
|
22
|
+
/**
|
|
23
|
+
* Ability to send telemetry data such as gauges and increments on how the connector is performing.
|
|
24
|
+
*/
|
|
25
|
+
get telemetry(): TelemetrySDKInterface;
|
|
26
|
+
/**
|
|
27
|
+
* Get file service instance to access files using a specified DSN. If no DSN is provided, defaults to local file system tmp dir.
|
|
28
|
+
*/
|
|
29
|
+
files(dsn?: string): FilesSDKInterface;
|
|
30
|
+
httpClient(httpConfig?: HttpConfig): HttpClientSDKInterface;
|
|
31
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Metric {
|
|
2
|
+
key: string;
|
|
3
|
+
value: number;
|
|
4
|
+
}
|
|
5
|
+
export type Metadata = {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
export interface Context {
|
|
9
|
+
timestamp?: Date;
|
|
10
|
+
ttl?: number;
|
|
11
|
+
extraPayload?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export type Result = boolean | {
|
|
16
|
+
[index: number]: boolean;
|
|
17
|
+
};
|
|
18
|
+
export interface SenderSDKInterface {
|
|
19
|
+
metrics(metrics: Array<Metric>, metadata?: Metadata, context?: Context): Promise<Result>;
|
|
20
|
+
metricsLegacy<T = never>(metrics: Array<T>, metadata?: Metadata, context?: Context, topic?: string): Promise<Result>;
|
|
21
|
+
documents<T = object>(documents: Array<T>, metadata?: Metadata, context?: Context): Promise<Result>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TelemetrySDKInterface {
|
|
2
|
+
/**
|
|
3
|
+
* Increment a telemetry counter by 1.
|
|
4
|
+
*/
|
|
5
|
+
increment(key: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Increment a telemetry counter by a specified value. 0 doesn't send any telemetry.
|
|
8
|
+
* A negative value will decrement the counter.
|
|
9
|
+
*/
|
|
10
|
+
increment(key: string, value: number): void;
|
|
11
|
+
/**
|
|
12
|
+
* Send a gauge telemetry metric.
|
|
13
|
+
*/
|
|
14
|
+
gauge(key: string, value: number): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type RuntimeOptions = {
|
|
2
|
+
partial?: boolean;
|
|
3
|
+
};
|
|
4
|
+
export type CompileDelegate<T = unknown> = {
|
|
5
|
+
(context: T, options?: RuntimeOptions): string;
|
|
6
|
+
};
|
|
7
|
+
export type CompileOptions = {
|
|
8
|
+
strict?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export interface TemplatingSDKInterface {
|
|
11
|
+
compile<T = unknown>(input: string, options?: CompileOptions): CompileDelegate<T>;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './null-logger';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare enum ConnectorOrigin {
|
|
2
|
+
from_template = "from_template",
|
|
3
|
+
manual = "manual"
|
|
4
|
+
}
|
|
5
|
+
export interface LegacyOutputParameterInterface {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
}
|
|
8
|
+
export type SupportedOutputTypes = 'string' | 'number' | 'boolean' | 'array' | 'null';
|
|
9
|
+
export interface OutputItemParameterInterface {
|
|
10
|
+
type: SupportedOutputTypes | Array<SupportedOutputTypes>;
|
|
11
|
+
description?: string;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ArrayOutputParameterInterface extends OutputItemParameterInterface {
|
|
15
|
+
type: 'array';
|
|
16
|
+
items: OutputParameterInterface;
|
|
17
|
+
}
|
|
18
|
+
export interface NumberOutputParameterInterface extends OutputItemParameterInterface {
|
|
19
|
+
type: 'number' | Array<'number' | 'null'>;
|
|
20
|
+
minimum?: number;
|
|
21
|
+
maximum?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface OutputParameterInterface {
|
|
24
|
+
[key: string]: OutputItemParameterInterface | ArrayOutputParameterInterface | NumberOutputParameterInterface;
|
|
25
|
+
}
|
|
26
|
+
export interface InputParameterInterface {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
type: 'string' | 'number' | 'boolean' | 'array';
|
|
30
|
+
required?: boolean;
|
|
31
|
+
items?: Array<InputParameterInterface>;
|
|
32
|
+
}
|
|
33
|
+
export interface ActionInterface {
|
|
34
|
+
identifier: string;
|
|
35
|
+
version: string;
|
|
36
|
+
tenantIdentifier: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
connectorIdentifier: string;
|
|
40
|
+
config: {
|
|
41
|
+
[key: string]: {
|
|
42
|
+
[key: string]: string | object;
|
|
43
|
+
} | string | object;
|
|
44
|
+
};
|
|
45
|
+
inputParameters: Array<InputParameterInterface>;
|
|
46
|
+
outputParameters: LegacyOutputParameterInterface | OutputParameterInterface;
|
|
47
|
+
mode?: ConnectorOrigin;
|
|
48
|
+
createdAt: Date;
|
|
49
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface KafkaBrokerConfig {
|
|
2
|
+
groupId: string;
|
|
3
|
+
clientId: string;
|
|
4
|
+
brokers: Array<string>;
|
|
5
|
+
sasl?: object;
|
|
6
|
+
intervalCheckForNewTopics?: number;
|
|
7
|
+
disableLogs?: boolean;
|
|
8
|
+
autoCommitThreshold?: number;
|
|
9
|
+
autoCommitInterval?: number;
|
|
10
|
+
partitionsConsumedConcurrently?: number;
|
|
11
|
+
useConfluentLibrary?: boolean;
|
|
12
|
+
newConsumerProtocol?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface KafkaCallbackResponse<T = unknown> {
|
|
15
|
+
success: boolean;
|
|
16
|
+
statusCode: number;
|
|
17
|
+
message: string;
|
|
18
|
+
payload?: T;
|
|
19
|
+
}
|
|
20
|
+
export type KafkaCallbackResponseType<T = string> = (additionalMessage?: T) => (message: XodBaseMessageType) => Promise<KafkaCallbackResponse>;
|
|
21
|
+
export interface XodBaseMessageType {
|
|
22
|
+
type: 'ACTION' | 'EVENT' | 'SOURCE' | 'JOB';
|
|
23
|
+
eventId: string;
|
|
24
|
+
eventType: string;
|
|
25
|
+
eventTopic?: string;
|
|
26
|
+
created: number;
|
|
27
|
+
payload: object;
|
|
28
|
+
ttl: number;
|
|
29
|
+
tenantIdentifier: string;
|
|
30
|
+
testRun?: boolean;
|
|
31
|
+
meta?: {
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface XodJobType extends XodBaseMessageType {
|
|
36
|
+
type: 'JOB';
|
|
37
|
+
actionIdentifier: string;
|
|
38
|
+
actionVersion: string;
|
|
39
|
+
payload: Record<string, unknown>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionInterface, ConnectorOrigin } from './types/action';
|
|
2
|
+
import { KafkaBrokerConfig } from './types/kafka';
|
|
3
|
+
export * from './types/action';
|
|
4
|
+
export * from './types/kafka';
|
|
5
|
+
export interface BaseConnectorConfig {
|
|
6
|
+
processIdentifier: string;
|
|
7
|
+
tenantIdentifier: string;
|
|
8
|
+
datasourceIdentifier: string;
|
|
9
|
+
kafka: KafkaBrokerConfig;
|
|
10
|
+
action?: {
|
|
11
|
+
timeSensitive: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ConnectorInterface<T = Partial<BaseConnectorConfig>> {
|
|
15
|
+
identifier: string;
|
|
16
|
+
connectorType: string;
|
|
17
|
+
tenantIdentifier: string;
|
|
18
|
+
name: string;
|
|
19
|
+
location: string;
|
|
20
|
+
config?: T;
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
actions?: Array<ActionInterface>;
|
|
23
|
+
mode?: ConnectorOrigin;
|
|
24
|
+
createdAt?: Date;
|
|
25
|
+
updatedAt?: Date;
|
|
26
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@transai/connector-runner-gpms",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"license": "LGPL-3.0-or-later",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "transAI",
|
|
10
|
+
"email": "samen@transai.com",
|
|
11
|
+
"url": "https://transai.com"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"express": "^4.0"
|
|
15
|
+
},
|
|
16
|
+
"type": "commonjs",
|
|
17
|
+
"main": "./index.cjs",
|
|
18
|
+
"typings": "./index.d.ts"
|
|
19
|
+
}
|