@transai/connector-runner-control-office 0.0.0-stage → 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/DOCUMENTATION.md +67 -0
- package/README.md +32 -2
- package/index.cjs +63 -0
- package/index.cjs.map +7 -0
- package/integrations/connector-runner-control-office/src/index.d.ts +1 -0
- package/integrations/connector-runner-control-office/src/lib/actions/action.interface.d.ts +11 -0
- package/integrations/connector-runner-control-office/src/lib/actions/odata-resource.action.d.ts +11 -0
- package/integrations/connector-runner-control-office/src/lib/actions.service.d.ts +7 -0
- package/integrations/connector-runner-control-office/src/lib/connector-runner-control-office.d.ts +6 -0
- package/integrations/connector-runner-control-office/src/lib/error/invalid-input.error.d.ts +2 -0
- package/integrations/connector-runner-control-office/src/lib/error/record-not-found.error.d.ts +2 -0
- package/integrations/connector-runner-control-office/src/lib/error/too-many-records.error.d.ts +2 -0
- package/integrations/connector-runner-control-office/src/lib/extractor.service.d.ts +9 -0
- package/integrations/connector-runner-control-office/src/lib/helpers.d.ts +6 -0
- package/integrations/connector-runner-control-office/src/lib/odata-reader.d.ts +14 -0
- package/integrations/connector-runner-control-office/src/lib/resources.d.ts +2 -0
- package/integrations/connector-runner-control-office/src/lib/types.d.ts +44 -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 +25 -0
- package/libs/connector-runtime-sdk/src/lib/sdk/http-client.interface.d.ts +49 -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 +26 -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 +63 -0
- package/libs/connector-runtime-sdk/src/lib/types/kafka.d.ts +41 -0
- package/libs/connector-runtime-sdk/src/lib/types.d.ts +26 -0
- package/package.json +16 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/connector-runner-control-office';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ControlOfficeRecord, IBounds } from '../types';
|
|
2
|
+
export interface IActionResult {
|
|
3
|
+
data: Array<ControlOfficeRecord>;
|
|
4
|
+
single: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface IAction {
|
|
7
|
+
readonly identifier: string;
|
|
8
|
+
readonly identifierField: string;
|
|
9
|
+
run(params: unknown, testRun: boolean): Promise<IActionResult>;
|
|
10
|
+
pages(bounds: IBounds): AsyncGenerator<Array<ControlOfficeRecord>>;
|
|
11
|
+
}
|
package/integrations/connector-runner-control-office/src/lib/actions/odata-resource.action.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ODataReader } from '../odata-reader';
|
|
2
|
+
import { ControlOfficeRecord, IBounds, IResource } from '../types';
|
|
3
|
+
import { IAction, IActionResult } from './action.interface';
|
|
4
|
+
export declare class ODataResourceAction implements IAction {
|
|
5
|
+
#private;
|
|
6
|
+
readonly identifier: string;
|
|
7
|
+
readonly identifierField = "Id";
|
|
8
|
+
constructor(reader: ODataReader, resource: IResource);
|
|
9
|
+
run(params: unknown, testRun: boolean): Promise<IActionResult>;
|
|
10
|
+
pages(bounds: IBounds): AsyncGenerator<Array<ControlOfficeRecord>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ActionInterface, ConnectorSDKInterface, KafkaCallbackResponse, XodJobType } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { IAction } from './actions/action.interface';
|
|
3
|
+
export declare class ActionsService {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(sdk: ConnectorSDKInterface, actions: Array<IAction>);
|
|
6
|
+
get callbackFunctionChain(): (message: XodJobType, action: ActionInterface) => Promise<KafkaCallbackResponse>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConnectorSDKInterface, IntervalHandler } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { IAction } from './actions/action.interface';
|
|
3
|
+
import { ConnectorConfig } from './types';
|
|
4
|
+
export declare class ExtractorService implements IntervalHandler {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(sdk: ConnectorSDKInterface<ConnectorConfig>, action: IAction);
|
|
7
|
+
get name(): string;
|
|
8
|
+
onRun(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConnectorSDKInterface } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { ControlOfficeRecord } from './types';
|
|
3
|
+
export declare function sendDocuments(sdk: ConnectorSDKInterface, action: {
|
|
4
|
+
identifier: string;
|
|
5
|
+
identifierField: string;
|
|
6
|
+
}, rows: Array<ControlOfficeRecord>): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpClientSDKInterface } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { ControlOfficeRecord, IBounds, IResource, ValidatedConfig } from './types';
|
|
3
|
+
export declare class ODataReader {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(client: HttpClientSDKInterface, config: Pick<ValidatedConfig, 'url' | 'apiKey' | 'pageSize'>);
|
|
6
|
+
/**
|
|
7
|
+
* Pages continue from the last Modified seen and $skip only the records already read at that exact
|
|
8
|
+
* timestamp. Server nextLinks are ignored: they $skip from the start, so a record edited mid-read
|
|
9
|
+
* shifts every later page and one record is lost. Paging stops on an empty page, so a silently
|
|
10
|
+
* capped $top cannot truncate the read.
|
|
11
|
+
*/
|
|
12
|
+
pages(resource: IResource, bounds: IBounds): AsyncGenerator<Array<ControlOfficeRecord>>;
|
|
13
|
+
get(resource: IResource, id: string): Promise<ControlOfficeRecord>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BaseConnectorConfig } from '@transai/connector-runtime-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export interface ConnectorConfig extends BaseConnectorConfig {
|
|
4
|
+
url: string;
|
|
5
|
+
apiKey: string;
|
|
6
|
+
retrievers?: Array<string>;
|
|
7
|
+
interval?: number;
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const DEFAULT_DATASOURCE = "control-office";
|
|
11
|
+
export declare const DEFAULTS: {
|
|
12
|
+
readonly interval: 300;
|
|
13
|
+
readonly pageSize: 100;
|
|
14
|
+
readonly overlapMs: number;
|
|
15
|
+
readonly actionRecordLimit: 1000;
|
|
16
|
+
readonly syncTimeoutSeconds: number;
|
|
17
|
+
};
|
|
18
|
+
export declare const guidSchema: z.ZodString;
|
|
19
|
+
export declare const dateSchema: z.ZodISODateTime;
|
|
20
|
+
export declare const configSchema: z.ZodObject<{
|
|
21
|
+
url: z.ZodURL;
|
|
22
|
+
apiKey: z.ZodString;
|
|
23
|
+
retrievers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
+
interval: z.ZodDefault<z.ZodNumber>;
|
|
25
|
+
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type ValidatedConfig = z.infer<typeof configSchema>;
|
|
28
|
+
export interface IResource {
|
|
29
|
+
entity: string;
|
|
30
|
+
identifier: string;
|
|
31
|
+
}
|
|
32
|
+
export interface IBounds {
|
|
33
|
+
from?: string;
|
|
34
|
+
until: string;
|
|
35
|
+
}
|
|
36
|
+
export type ControlOfficeRecord = Record<string, unknown> & {
|
|
37
|
+
Id: string;
|
|
38
|
+
Modified: string;
|
|
39
|
+
};
|
|
40
|
+
export declare const actionParamsSchema: z.ZodObject<{
|
|
41
|
+
id: z.ZodOptional<z.ZodString>;
|
|
42
|
+
modifiedFrom: z.ZodOptional<z.ZodISODateTime>;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
export type ActionParams = z.infer<typeof actionParamsSchema>;
|
|
@@ -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,25 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* Publish a complete file on the same filesystem without replacing a destination.
|
|
20
|
+
* Resolves false only when nothing was renamed; rejects when the outcome is unknown.
|
|
21
|
+
*/
|
|
22
|
+
rename(source: string, destination: string): Promise<boolean>;
|
|
23
|
+
mkdir(directory: string): Promise<boolean>;
|
|
24
|
+
pathAsDsn(path: string): string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface HttpConfig {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
contentType?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
insecure?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type HttpRequestOptions<D = string | object> = {
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
params?: Record<string, string | number | boolean>;
|
|
10
|
+
data?: D;
|
|
11
|
+
withCredentials?: boolean;
|
|
12
|
+
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream' | 'formdata';
|
|
13
|
+
};
|
|
14
|
+
export type HttpRequestOptionsFormatter<D = string | object> = (requestOptions: HttpRequestOptions<D>, method: HttpMethod, url: string) => Promise<HttpRequestOptions<D>> | HttpRequestOptions<D>;
|
|
15
|
+
export type HttpErrorResponseCallbackRequest<D = string | object> = {
|
|
16
|
+
client: HttpClientSDKInterface;
|
|
17
|
+
method: HttpMethod;
|
|
18
|
+
url: string;
|
|
19
|
+
options?: HttpRequestOptions<D>;
|
|
20
|
+
};
|
|
21
|
+
export type HttpErrorResponseCallback<R = unknown, D = string | object> = (error: HttpError, request: HttpErrorResponseCallbackRequest<D>) => HttpClientPromise<R>;
|
|
22
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
23
|
+
export type HttpResponseHeader = string | Array<string> | number | boolean | null;
|
|
24
|
+
export type HttpResponse<D = unknown> = {
|
|
25
|
+
status: number;
|
|
26
|
+
data: D;
|
|
27
|
+
headers?: Record<string, HttpResponseHeader>;
|
|
28
|
+
};
|
|
29
|
+
export type HttpError = {
|
|
30
|
+
status: number;
|
|
31
|
+
error?: string;
|
|
32
|
+
headers?: Record<string, HttpResponseHeader>;
|
|
33
|
+
};
|
|
34
|
+
interface PromiseWithReason<T = unknown, R = unknown> extends Promise<T> {
|
|
35
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: R) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
|
|
36
|
+
catch<TResult = never>(onrejected?: ((reason: R) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
|
|
37
|
+
}
|
|
38
|
+
export type HttpClientPromise<T> = PromiseWithReason<HttpResponse<T>, HttpError>;
|
|
39
|
+
export interface HttpClientSDKInterface {
|
|
40
|
+
get<R = unknown>(destination: string, options?: HttpRequestOptions): HttpClientPromise<R>;
|
|
41
|
+
post<R = unknown, D = string | object>(destination: string, data: D, options?: HttpRequestOptions<D>): HttpClientPromise<R>;
|
|
42
|
+
put<R = unknown, D = string | object>(destination: string, data: D, options?: HttpRequestOptions<D>): HttpClientPromise<R>;
|
|
43
|
+
patch<R = unknown, D = string | object>(destination: string, data: D, options?: HttpRequestOptions<D>): HttpClientPromise<R>;
|
|
44
|
+
delete<R = unknown>(destination: string, options?: HttpRequestOptions): HttpClientPromise<R>;
|
|
45
|
+
request<R = unknown, D = string | object>(method: HttpMethod, url: string, options?: HttpRequestOptions<D>): HttpClientPromise<R>;
|
|
46
|
+
setRequestOptionsFormatter<D = string | object>(formatter: HttpRequestOptionsFormatter<D>): HttpClientSDKInterface;
|
|
47
|
+
setErrorResponseHandler<R = unknown, D = string | object>(callback?: HttpErrorResponseCallback<R, D>): HttpClientSDKInterface;
|
|
48
|
+
}
|
|
49
|
+
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,26 @@
|
|
|
1
|
+
export interface Metric {
|
|
2
|
+
key: string;
|
|
3
|
+
value: number;
|
|
4
|
+
}
|
|
5
|
+
export type Metadata = {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
export type SenderMetadata = {
|
|
9
|
+
collection?: string;
|
|
10
|
+
incrementalField?: string;
|
|
11
|
+
keyField?: string;
|
|
12
|
+
};
|
|
13
|
+
export interface Context {
|
|
14
|
+
timestamp?: Date;
|
|
15
|
+
ttl?: number;
|
|
16
|
+
extraPayload?: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export type Result = boolean | {
|
|
21
|
+
[index: number]: boolean;
|
|
22
|
+
};
|
|
23
|
+
export interface SenderSDKInterface {
|
|
24
|
+
metrics<T = never>(metrics: Array<T>, metadata?: Metadata & SenderMetadata, context?: Context, topic?: string): Promise<Result>;
|
|
25
|
+
documents<T = object>(documents: Array<T>, metadata?: Metadata & SenderMetadata, context?: Context): Promise<Result>;
|
|
26
|
+
}
|
|
@@ -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,63 @@
|
|
|
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
|
+
interface BaseInputParameter {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
required?: boolean;
|
|
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;
|
|
46
|
+
export interface ActionInterface {
|
|
47
|
+
identifier: string;
|
|
48
|
+
version: string;
|
|
49
|
+
tenantIdentifier: string;
|
|
50
|
+
name: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
connectorIdentifier: string;
|
|
53
|
+
config: {
|
|
54
|
+
[key: string]: {
|
|
55
|
+
[key: string]: string | number | object;
|
|
56
|
+
} | string | number | object;
|
|
57
|
+
};
|
|
58
|
+
inputParameters: Array<InputParameterInterface>;
|
|
59
|
+
outputParameters: LegacyOutputParameterInterface | OutputParameterInterface;
|
|
60
|
+
mode?: ConnectorOrigin;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
maxPollIntervalMs?: number;
|
|
12
|
+
useConfluentLibrary?: boolean;
|
|
13
|
+
newConsumerProtocol?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface KafkaCallbackResponse<T = unknown> {
|
|
16
|
+
success: boolean;
|
|
17
|
+
statusCode: number;
|
|
18
|
+
message: string;
|
|
19
|
+
payload?: T;
|
|
20
|
+
}
|
|
21
|
+
export type KafkaCallbackResponseType<T = string> = (additionalMessage?: T) => (message: XodBaseMessageType) => Promise<KafkaCallbackResponse>;
|
|
22
|
+
export interface XodBaseMessageType {
|
|
23
|
+
type: 'ACTION' | 'EVENT' | 'SOURCE' | 'JOB';
|
|
24
|
+
eventId: string;
|
|
25
|
+
eventType: string;
|
|
26
|
+
eventTopic?: string;
|
|
27
|
+
created: number;
|
|
28
|
+
payload: object;
|
|
29
|
+
ttl: number;
|
|
30
|
+
tenantIdentifier: string;
|
|
31
|
+
testRun?: boolean;
|
|
32
|
+
meta?: {
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface XodJobType extends XodBaseMessageType {
|
|
37
|
+
type: 'JOB';
|
|
38
|
+
actionIdentifier: string;
|
|
39
|
+
actionVersion: string;
|
|
40
|
+
payload: Record<string, unknown>;
|
|
41
|
+
}
|
|
@@ -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
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transai/connector-runner-control-office",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
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
|
+
"type": "commonjs",
|
|
14
|
+
"main": "./index.cjs",
|
|
15
|
+
"typings": "./index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"zod": "^4.6.7"
|
|
18
|
+
}
|
|
6
19
|
}
|