@transai/connector-runner-xylem 0.0.0-placeholder → 0.1.2

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/DOCUMENTATION.md +50 -0
  3. package/README.md +111 -0
  4. package/index.cjs +66 -0
  5. package/index.cjs.map +7 -0
  6. package/integrations/connector-runner-xylem/src/connector-runner-xylem.d.ts +5 -0
  7. package/integrations/connector-runner-xylem/src/index.d.ts +5 -0
  8. package/integrations/connector-runner-xylem/src/types.d.ts +16 -0
  9. package/integrations/connector-runner-xylem/src/xylem-controller-poller.d.ts +9 -0
  10. package/integrations/connector-runner-xylem/src/xylem-digest.d.ts +29 -0
  11. package/integrations/connector-runner-xylem/src/xylem-live-data.schema.d.ts +103 -0
  12. package/integrations/connector-runner-xylem/src/xylem-metrics.d.ts +8 -0
  13. package/integrations/connector-runner-xylem/src/xylem-metrics.types.d.ts +49 -0
  14. package/integrations/connector-runner-xylem/src/xylem-metrics.utils.d.ts +4 -0
  15. package/libs/connector-runtime-sdk/src/index.d.ts +5 -0
  16. package/libs/connector-runtime-sdk/src/lib/connector-runtime.d.ts +16 -0
  17. package/libs/connector-runtime-sdk/src/lib/connector-runtime.interface.d.ts +5 -0
  18. package/libs/connector-runtime-sdk/src/lib/sdk/files.sdk.interface.d.ts +19 -0
  19. package/libs/connector-runtime-sdk/src/lib/sdk/http-client.interface.d.ts +49 -0
  20. package/libs/connector-runtime-sdk/src/lib/sdk/index.d.ts +10 -0
  21. package/libs/connector-runtime-sdk/src/lib/sdk/logger.sdk.interface.d.ts +7 -0
  22. package/libs/connector-runtime-sdk/src/lib/sdk/offset-store.sdk.interface.d.ts +13 -0
  23. package/libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.d.ts +30 -0
  24. package/libs/connector-runtime-sdk/src/lib/sdk/receiver.sdk.interface.d.ts +14 -0
  25. package/libs/connector-runtime-sdk/src/lib/sdk/sdk.interface.d.ts +31 -0
  26. package/libs/connector-runtime-sdk/src/lib/sdk/sender.sdk.interface.d.ts +26 -0
  27. package/libs/connector-runtime-sdk/src/lib/sdk/telemetry.sdk.interface.d.ts +15 -0
  28. package/libs/connector-runtime-sdk/src/lib/sdk/templating.sdk.interface.d.ts +12 -0
  29. package/libs/connector-runtime-sdk/src/lib/support/index.d.ts +1 -0
  30. package/libs/connector-runtime-sdk/src/lib/support/null-logger.d.ts +8 -0
  31. package/libs/connector-runtime-sdk/src/lib/types/action.d.ts +63 -0
  32. package/libs/connector-runtime-sdk/src/lib/types/kafka.d.ts +40 -0
  33. package/libs/connector-runtime-sdk/src/lib/types.d.ts +26 -0
  34. package/package.json +13 -3
@@ -0,0 +1,5 @@
1
+ import { ConnectorRuntimeSDK } from '@transai/connector-runtime-sdk';
2
+ import { XylemConfig } from './types';
3
+ export declare class ConnectorRunnerXylem extends ConnectorRuntimeSDK<XylemConfig> {
4
+ init: () => Promise<void>;
5
+ }
@@ -0,0 +1,5 @@
1
+ export * from './connector-runner-xylem';
2
+ export * from './types';
3
+ export * from './xylem-controller-poller';
4
+ export * from './xylem-live-data.schema';
5
+ export * from './xylem-metrics';
@@ -0,0 +1,16 @@
1
+ import { BaseConnectorConfig } from '@transai/connector-runtime-sdk';
2
+ export interface XylemControllerConfig {
3
+ id: string;
4
+ baseUrl: string;
5
+ username: string;
6
+ password: string;
7
+ intervalSeconds: number;
8
+ name?: string;
9
+ location?: string;
10
+ endpoint?: string;
11
+ timeoutMs?: number;
12
+ }
13
+ export interface XylemConfig extends BaseConnectorConfig {
14
+ controllers: Array<XylemControllerConfig>;
15
+ }
16
+ export type ConnectorConfig = XylemConfig;
@@ -0,0 +1,9 @@
1
+ import { ConnectorSDKInterface, IntervalHandler } from '@transai/connector-runtime-sdk';
2
+ import { XylemConfig, XylemControllerConfig } from './types';
3
+ export declare const DEFAULT_XYLEM_ENDPOINT = "/api/v1/livedata";
4
+ export declare class XylemControllerPoller implements IntervalHandler {
5
+ #private;
6
+ constructor(sdk: ConnectorSDKInterface<XylemConfig>, controller: XylemControllerConfig);
7
+ get name(): string;
8
+ onRun(): Promise<void>;
9
+ }
@@ -0,0 +1,29 @@
1
+ import { HttpClientSDKInterface, LoggerSDKInterface } from '@transai/connector-runtime-sdk';
2
+ export type DigestAlgorithm = 'MD5' | 'MD5-sess' | 'SHA-256' | 'SHA-256-sess';
3
+ export type DigestQop = 'auth' | 'auth-int';
4
+ export interface DigestChallenge {
5
+ scheme: string;
6
+ realm: string;
7
+ nonce: string;
8
+ opaque?: string;
9
+ algorithm?: string;
10
+ qop?: Array<string>;
11
+ }
12
+ export interface SelectedDigestChallenge extends Omit<DigestChallenge, 'algorithm' | 'qop'> {
13
+ algorithm?: DigestAlgorithm;
14
+ qop?: DigestQop;
15
+ }
16
+ export interface DigestAuthorizationInput {
17
+ username: string;
18
+ password: string;
19
+ method: string;
20
+ uri: string;
21
+ body?: string | Buffer;
22
+ challenge: SelectedDigestChallenge;
23
+ cnonce?: string;
24
+ nc?: string;
25
+ }
26
+ export declare function parseDigestChallenges(headers: Record<string, unknown>): Array<DigestChallenge>;
27
+ export declare function selectDigestChallenge(challenges: Array<DigestChallenge>): SelectedDigestChallenge | undefined;
28
+ export declare function createDigestAuthorization(input: DigestAuthorizationInput): string;
29
+ export declare function setDigestAuthentication(client: HttpClientSDKInterface, username: string, password: string, logger: LoggerSDKInterface): HttpClientSDKInterface;
@@ -0,0 +1,103 @@
1
+ import { z } from 'zod';
2
+ export declare const XylemValueSchema: z.ZodObject<{
3
+ valueState: z.ZodString;
4
+ value: z.ZodOptional<z.ZodNumber>;
5
+ UoM: z.ZodOptional<z.ZodString>;
6
+ valueToShow: z.ZodOptional<z.ZodString>;
7
+ UoMToShow: z.ZodOptional<z.ZodString>;
8
+ range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
9
+ }, z.core.$loose>;
10
+ export declare const XylemSensorSchema: z.ZodObject<{
11
+ id: z.ZodString;
12
+ name: z.ZodString;
13
+ model: z.ZodString;
14
+ typeCode: z.ZodString;
15
+ serialNo: z.ZodString;
16
+ sensorState: z.ZodString;
17
+ sensorPod: z.ZodOptional<z.ZodObject<{
18
+ typeCode: z.ZodString;
19
+ model: z.ZodString;
20
+ }, z.core.$loose>>;
21
+ measuringModeCode: z.ZodOptional<z.ZodNumber>;
22
+ statusInfo: z.ZodOptional<z.ZodNumber>;
23
+ mainValue: z.ZodOptional<z.ZodObject<{
24
+ valueState: z.ZodString;
25
+ value: z.ZodOptional<z.ZodNumber>;
26
+ UoM: z.ZodOptional<z.ZodString>;
27
+ valueToShow: z.ZodOptional<z.ZodString>;
28
+ UoMToShow: z.ZodOptional<z.ZodString>;
29
+ range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
30
+ }, z.core.$loose>>;
31
+ subValue: z.ZodOptional<z.ZodObject<{
32
+ valueState: z.ZodString;
33
+ value: z.ZodOptional<z.ZodNumber>;
34
+ UoM: z.ZodOptional<z.ZodString>;
35
+ valueToShow: z.ZodOptional<z.ZodString>;
36
+ UoMToShow: z.ZodOptional<z.ZodString>;
37
+ range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
38
+ }, z.core.$loose>>;
39
+ }, z.core.$loose>;
40
+ export declare const XylemNotificationSchema: z.ZodObject<{
41
+ id: z.ZodNumber;
42
+ timestamp: z.ZodNumber;
43
+ code: z.ZodString;
44
+ type: z.ZodString;
45
+ typeCode: z.ZodString;
46
+ serialNo: z.ZodString;
47
+ dw1: z.ZodNumber;
48
+ dw2: z.ZodNumber;
49
+ }, z.core.$loose>;
50
+ export declare const XylemLiveDataSchema: z.ZodObject<{
51
+ webServer: z.ZodString;
52
+ payloadType: z.ZodLiteral<"livedata">;
53
+ payloadVersion: z.ZodString;
54
+ controllerTime: z.ZodNumber;
55
+ controllerType: z.ZodString;
56
+ controllerSerial: z.ZodString;
57
+ controllerName: z.ZodString;
58
+ controllerSW: z.ZodString;
59
+ sensors: z.ZodArray<z.ZodObject<{
60
+ id: z.ZodString;
61
+ name: z.ZodString;
62
+ model: z.ZodString;
63
+ typeCode: z.ZodString;
64
+ serialNo: z.ZodString;
65
+ sensorState: z.ZodString;
66
+ sensorPod: z.ZodOptional<z.ZodObject<{
67
+ typeCode: z.ZodString;
68
+ model: z.ZodString;
69
+ }, z.core.$loose>>;
70
+ measuringModeCode: z.ZodOptional<z.ZodNumber>;
71
+ statusInfo: z.ZodOptional<z.ZodNumber>;
72
+ mainValue: z.ZodOptional<z.ZodObject<{
73
+ valueState: z.ZodString;
74
+ value: z.ZodOptional<z.ZodNumber>;
75
+ UoM: z.ZodOptional<z.ZodString>;
76
+ valueToShow: z.ZodOptional<z.ZodString>;
77
+ UoMToShow: z.ZodOptional<z.ZodString>;
78
+ range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
79
+ }, z.core.$loose>>;
80
+ subValue: z.ZodOptional<z.ZodObject<{
81
+ valueState: z.ZodString;
82
+ value: z.ZodOptional<z.ZodNumber>;
83
+ UoM: z.ZodOptional<z.ZodString>;
84
+ valueToShow: z.ZodOptional<z.ZodString>;
85
+ UoMToShow: z.ZodOptional<z.ZodString>;
86
+ range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
87
+ }, z.core.$loose>>;
88
+ }, z.core.$loose>>;
89
+ notifications: z.ZodArray<z.ZodObject<{
90
+ id: z.ZodNumber;
91
+ timestamp: z.ZodNumber;
92
+ code: z.ZodString;
93
+ type: z.ZodString;
94
+ typeCode: z.ZodString;
95
+ serialNo: z.ZodString;
96
+ dw1: z.ZodNumber;
97
+ dw2: z.ZodNumber;
98
+ }, z.core.$loose>>;
99
+ }, z.core.$loose>;
100
+ export type XylemValue = z.infer<typeof XylemValueSchema>;
101
+ export type XylemSensor = z.infer<typeof XylemSensorSchema>;
102
+ export type XylemNotification = z.infer<typeof XylemNotificationSchema>;
103
+ export type XylemLiveData = z.infer<typeof XylemLiveDataSchema>;
@@ -0,0 +1,8 @@
1
+ export declare const XYLEM_CONTROLLERS_COLLECTION = "controllers";
2
+ export declare const XYLEM_SENSORS_COLLECTION = "sensors";
3
+ export declare const XYLEM_MEASUREMENT_POINTS_COLLECTION = "measurement_points";
4
+ export declare const XYLEM_NOTIFICATIONS_COLLECTION = "notifications";
5
+ export declare const XYLEM_SENSOR_STATUS_COLLECTION = "sensor_status";
6
+ export declare const XYLEM_CONNECTOR_STATUS_COLLECTION = "connector_status";
7
+ export * from './xylem-metrics.types';
8
+ export { normalizeXylemLiveData } from './xylem-metrics.utils';
@@ -0,0 +1,49 @@
1
+ import { XylemLiveData, XylemNotification, XylemSensor } from './xylem-live-data.schema';
2
+ export type ControllerMetadata = Pick<XylemLiveData, 'webServer' | 'payloadType' | 'payloadVersion' | 'controllerType' | 'controllerSerial' | 'controllerSW'> & {
3
+ controllerName: string;
4
+ };
5
+ export type XylemSensorStatus = ControllerMetadata & Pick<XylemSensor, 'id' | 'name' | 'model' | 'typeCode' | 'serialNo' | 'sensorState' | 'sensorPod' | 'measuringModeCode' | 'statusInfo'> & {
6
+ sensorId: string;
7
+ state: number;
8
+ };
9
+ export type XylemControllerDocument = ControllerMetadata & {
10
+ lastSeenAt: Date;
11
+ };
12
+ export type XylemSensorDocument = ControllerMetadata & Pick<XylemSensor, 'id' | 'name' | 'model' | 'typeCode' | 'serialNo' | 'measuringModeCode' | 'statusInfo'> & {
13
+ sensorId: string;
14
+ sensorIdentity: string;
15
+ sensorPodTypeCode?: string;
16
+ sensorPodModel?: string;
17
+ };
18
+ export type XylemMeasurement = ControllerMetadata & Pick<XylemSensor, 'id' | 'name' | 'model' | 'typeCode' | 'serialNo'> & {
19
+ sensorId: string;
20
+ valueKind: 'main' | 'sub';
21
+ valueState: string;
22
+ valueStateCode: number;
23
+ value: number | undefined;
24
+ unit?: string;
25
+ valueToShow?: string;
26
+ unitToShow?: string;
27
+ range?: [number, number];
28
+ sensorPodTypeCode?: string;
29
+ sensorPodModel?: string;
30
+ measuringModeCode: number | undefined;
31
+ statusInfo: number | undefined;
32
+ };
33
+ export type XylemValueDocument = Omit<XylemMeasurement, 'value' | 'valueToShow' | 'unitToShow' | 'valueState' | 'valueStateCode'> & {
34
+ valueIdentity: string;
35
+ controllerTimestamp: number;
36
+ };
37
+ export type XylemMetricNotification = ControllerMetadata & Pick<XylemNotification, 'id' | 'code' | 'type' | 'typeCode' | 'serialNo' | 'dw1' | 'dw2'> & {
38
+ notificationIdentity: string;
39
+ timestamp: Date;
40
+ };
41
+ export interface NormalizedXylemLiveData {
42
+ timestamp: Date;
43
+ controllers: Array<XylemControllerDocument>;
44
+ sensors: Array<XylemSensorDocument>;
45
+ values: Array<XylemValueDocument>;
46
+ sensorStatuses: Array<XylemSensorStatus>;
47
+ measurements: Array<XylemMeasurement>;
48
+ notifications: Array<XylemMetricNotification>;
49
+ }
@@ -0,0 +1,4 @@
1
+ import { XylemControllerConfig } from './types';
2
+ import { XylemLiveData } from './xylem-live-data.schema';
3
+ import { NormalizedXylemLiveData } from './xylem-metrics.types';
4
+ export declare function normalizeXylemLiveData(controller: XylemControllerConfig, payload: XylemLiveData): NormalizedXylemLiveData;
@@ -0,0 +1,5 @@
1
+ export * from './lib/types';
2
+ export * from './lib/connector-runtime';
3
+ export * from './lib/connector-runtime.interface';
4
+ export * from './lib/sdk';
5
+ export * from './lib/support';
@@ -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,5 @@
1
+ export interface ConnectorRuntimeInterface {
2
+ init(): Promise<void>;
3
+ start(): Promise<void>;
4
+ stop(): Promise<void>;
5
+ }
@@ -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,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,7 @@
1
+ export interface LoggerSDKInterface {
2
+ info(...args: Array<unknown>): void;
3
+ debug(...args: Array<unknown>): void;
4
+ error(...args: Array<unknown>): void;
5
+ warn(...args: Array<unknown>): void;
6
+ verbose(...args: Array<unknown>): void;
7
+ }
@@ -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,8 @@
1
+ import { LoggerSDKInterface } from '../sdk';
2
+ export declare class NullLogger implements LoggerSDKInterface {
3
+ info(): void;
4
+ debug(): void;
5
+ error(): void;
6
+ warn(): void;
7
+ verbose(): void;
8
+ }
@@ -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,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
+ }