@mochabug/adapt-core 1.0.0-rc21 → 1.0.0-rc24

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 (65) hide show
  1. package/README.md +33 -0
  2. package/dist/esm/config.js +21 -0
  3. package/dist/esm/config.js.map +1 -0
  4. package/dist/esm/genproto/buf/validate/validate_pb.js +352 -0
  5. package/dist/esm/genproto/buf/validate/validate_pb.js.map +1 -0
  6. package/dist/esm/genproto/google/api/annotations_pb.js +27 -0
  7. package/dist/esm/genproto/google/api/annotations_pb.js.map +1 -0
  8. package/dist/esm/genproto/google/api/client_pb.js +287 -0
  9. package/dist/esm/genproto/google/api/client_pb.js.map +1 -0
  10. package/dist/esm/genproto/google/api/http_pb.js +34 -0
  11. package/dist/esm/genproto/google/api/http_pb.js.map +1 -0
  12. package/dist/esm/genproto/google/api/launch_stage_pb.js +101 -0
  13. package/dist/esm/genproto/google/api/launch_stage_pb.js.map +1 -0
  14. package/dist/esm/genproto/mochabugapis/adapt/automations/v1/automations_pb.js +176 -0
  15. package/dist/esm/genproto/mochabugapis/adapt/automations/v1/automations_pb.js.map +1 -0
  16. package/dist/esm/genproto/mochabugapis/adapt/graph/exchange_pb.js +26 -0
  17. package/dist/esm/genproto/mochabugapis/adapt/graph/exchange_pb.js.map +1 -0
  18. package/dist/esm/genproto/mochabugapis/adapt/graph/jtd_schema_pb.js +26 -0
  19. package/dist/esm/genproto/mochabugapis/adapt/graph/jtd_schema_pb.js.map +1 -0
  20. package/dist/esm/genproto/mochabugapis/adapt/graph/receiver_pb.js +26 -0
  21. package/dist/esm/genproto/mochabugapis/adapt/graph/receiver_pb.js.map +1 -0
  22. package/dist/esm/genproto/mochabugapis/adapt/graph/signal_binding_pb.js +85 -0
  23. package/dist/esm/genproto/mochabugapis/adapt/graph/signal_binding_pb.js.map +1 -0
  24. package/dist/esm/genproto/mochabugapis/adapt/graph/signal_data_pb.js +25 -0
  25. package/dist/esm/genproto/mochabugapis/adapt/graph/signal_data_pb.js.map +1 -0
  26. package/dist/esm/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.js +26 -0
  27. package/dist/esm/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.js.map +1 -0
  28. package/dist/esm/genproto/mochabugapis/adapt/graph/signal_format_pb.js +26 -0
  29. package/dist/esm/genproto/mochabugapis/adapt/graph/signal_format_pb.js.map +1 -0
  30. package/dist/esm/genproto/mochabugapis/adapt/graph/transceiver_pb.js +26 -0
  31. package/dist/esm/genproto/mochabugapis/adapt/graph/transceiver_pb.js.map +1 -0
  32. package/dist/esm/genproto/mochabugapis/adapt/graph/transmitter_pb.js +62 -0
  33. package/dist/esm/genproto/mochabugapis/adapt/graph/transmitter_pb.js.map +1 -0
  34. package/dist/esm/genproto/mochabugapis/adapt/graph/vertex_metadata_pb.js +28 -0
  35. package/dist/esm/genproto/mochabugapis/adapt/graph/vertex_metadata_pb.js.map +1 -0
  36. package/dist/esm/grpc.js +11 -0
  37. package/dist/esm/grpc.js.map +1 -0
  38. package/dist/esm/index.js +159 -36
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/pubsub-client.js +36 -8
  41. package/dist/esm/pubsub-client.js.map +1 -1
  42. package/dist/esm/types.js +2 -0
  43. package/dist/esm/types.js.map +1 -0
  44. package/dist/types/config.d.ts +8 -0
  45. package/dist/types/genproto/buf/validate/validate_pb.d.ts +8490 -0
  46. package/dist/types/genproto/google/api/annotations_pb.d.ts +13 -0
  47. package/dist/types/genproto/google/api/client_pb.d.ts +1431 -0
  48. package/dist/types/genproto/google/api/http_pb.d.ts +842 -0
  49. package/dist/types/genproto/google/api/launch_stage_pb.d.ts +93 -0
  50. package/dist/types/genproto/mochabugapis/adapt/automations/v1/automations_pb.d.ts +1005 -0
  51. package/dist/types/genproto/mochabugapis/adapt/graph/exchange_pb.d.ts +76 -0
  52. package/dist/types/genproto/mochabugapis/adapt/graph/jtd_schema_pb.d.ts +400 -0
  53. package/dist/types/genproto/mochabugapis/adapt/graph/receiver_pb.d.ts +68 -0
  54. package/dist/types/genproto/mochabugapis/adapt/graph/signal_binding_pb.d.ts +429 -0
  55. package/dist/types/genproto/mochabugapis/adapt/graph/signal_data_pb.d.ts +197 -0
  56. package/dist/types/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.d.ts +160 -0
  57. package/dist/types/genproto/mochabugapis/adapt/graph/signal_format_pb.d.ts +304 -0
  58. package/dist/types/genproto/mochabugapis/adapt/graph/transceiver_pb.d.ts +76 -0
  59. package/dist/types/genproto/mochabugapis/adapt/graph/transmitter_pb.d.ts +119 -0
  60. package/dist/types/genproto/mochabugapis/adapt/graph/vertex_metadata_pb.d.ts +98 -0
  61. package/dist/types/grpc.d.ts +6 -0
  62. package/dist/types/index.d.ts +14 -14
  63. package/dist/types/pubsub-client.d.ts +16 -17
  64. package/dist/types/types.d.ts +63 -0
  65. package/package.json +23 -4
@@ -0,0 +1,98 @@
1
+ import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
2
+ import type { Exchange, ExchangeJson } from "./exchange_pb.js";
3
+ import type { Receiver, ReceiverJson } from "./receiver_pb.js";
4
+ import type { Transmitter, TransmitterJson } from "./transmitter_pb.js";
5
+ import type { Message } from "@bufbuild/protobuf";
6
+ /**
7
+ * Describes the file mochabugapis/adapt/graph/vertex_metadata.proto.
8
+ */
9
+ export declare const file_mochabugapis_adapt_graph_vertex_metadata: GenFile;
10
+ /**
11
+ * VertexMetadata represents the configuration for a vertex, detailing its inputs,
12
+ * outputs, and processes (such as procedures and streams).
13
+ *
14
+ * @generated from message mochabugapis.adapt.graph.VertexMetadata
15
+ */
16
+ export type VertexMetadata = Message<"mochabugapis.adapt.graph.VertexMetadata"> & {
17
+ /**
18
+ * Indicates if the vertex configuration is complete. Defaults to 'false'.
19
+ *
20
+ * @generated from field: bool complete = 1;
21
+ */
22
+ complete: boolean;
23
+ /**
24
+ * Input points for the vertex. Must contain between 1 and 50 receivers,
25
+ * each with a unique name.
26
+ *
27
+ * @generated from field: repeated mochabugapis.adapt.graph.Receiver receivers = 2;
28
+ */
29
+ receivers: Receiver[];
30
+ /**
31
+ * Output points for the vertex. Can contain up to 50 transmitters,
32
+ * each with a unique name.
33
+ *
34
+ * @generated from field: repeated mochabugapis.adapt.graph.Transmitter transmitters = 3;
35
+ */
36
+ transmitters: Transmitter[];
37
+ /**
38
+ * Processes initiated by transmitters and responded to by receivers.
39
+ * Limited to 10 unique procedures.
40
+ *
41
+ * @generated from field: repeated mochabugapis.adapt.graph.Exchange exchanges = 4;
42
+ */
43
+ exchanges: Exchange[];
44
+ /**
45
+ * A unix cron expression to determine when the task should run.
46
+ *
47
+ * @generated from field: optional string cron_schedule = 6;
48
+ */
49
+ cronSchedule?: string;
50
+ };
51
+ /**
52
+ * VertexMetadata represents the configuration for a vertex, detailing its inputs,
53
+ * outputs, and processes (such as procedures and streams).
54
+ *
55
+ * @generated from message mochabugapis.adapt.graph.VertexMetadata
56
+ */
57
+ export type VertexMetadataJson = {
58
+ /**
59
+ * Indicates if the vertex configuration is complete. Defaults to 'false'.
60
+ *
61
+ * @generated from field: bool complete = 1;
62
+ */
63
+ complete?: boolean;
64
+ /**
65
+ * Input points for the vertex. Must contain between 1 and 50 receivers,
66
+ * each with a unique name.
67
+ *
68
+ * @generated from field: repeated mochabugapis.adapt.graph.Receiver receivers = 2;
69
+ */
70
+ receivers?: ReceiverJson[];
71
+ /**
72
+ * Output points for the vertex. Can contain up to 50 transmitters,
73
+ * each with a unique name.
74
+ *
75
+ * @generated from field: repeated mochabugapis.adapt.graph.Transmitter transmitters = 3;
76
+ */
77
+ transmitters?: TransmitterJson[];
78
+ /**
79
+ * Processes initiated by transmitters and responded to by receivers.
80
+ * Limited to 10 unique procedures.
81
+ *
82
+ * @generated from field: repeated mochabugapis.adapt.graph.Exchange exchanges = 4;
83
+ */
84
+ exchanges?: ExchangeJson[];
85
+ /**
86
+ * A unix cron expression to determine when the task should run.
87
+ *
88
+ * @generated from field: optional string cron_schedule = 6;
89
+ */
90
+ cronSchedule?: string;
91
+ };
92
+ /**
93
+ * Describes the message mochabugapis.adapt.graph.VertexMetadata.
94
+ * Use `create(VertexMetadataSchema)` to create a new message.
95
+ */
96
+ export declare const VertexMetadataSchema: GenMessage<VertexMetadata, {
97
+ jsonType: VertexMetadataJson;
98
+ }>;
@@ -0,0 +1,6 @@
1
+ import type { Client } from "@connectrpc/connect";
2
+ import { type GrpcTransportOptions } from "@connectrpc/connect-node";
3
+ import { AutomationService } from "./genproto/mochabugapis/adapt/automations/v1/automations_pb";
4
+ type AutomationClient = Client<typeof AutomationService>;
5
+ export type { AutomationClient, GrpcTransportOptions };
6
+ export declare function createGrpcClient(options: GrpcTransportOptions): AutomationClient;
@@ -1,24 +1,24 @@
1
- import type { GetSessionResponseJson, InheritSessionResponseJson, ReadOutputResponseJson, ReadUrlsResponseJson, StartSessionRequestJson, StartSessionResponseJson } from "@mochabug/genproto/mochabugapis/adapt/automations/v1/automations_pb.js";
1
+ import type { OutputBinaryResponse, OutputResponse, Session, SessionInfo, StartSessionReq, UrlResponse } from "./types.js";
2
2
  export * from "./pubsub-client.js";
3
- export interface AdaptConfig {
4
- baseUrl: string;
5
- wsBaseUrl: string;
6
- }
7
- export declare function configure(config: Partial<AdaptConfig>): void;
8
- export declare function getConfig(): AdaptConfig;
9
- export declare function resetConfig(): void;
10
- export declare function startSession(req: StartSessionRequestJson, token?: string): Promise<StartSessionResponseJson>;
11
- export declare function inheritSession(id: string, sessionToken: string): Promise<InheritSessionResponseJson>;
12
- export declare function getSession(id: string, sessionToken: string): Promise<GetSessionResponseJson>;
3
+ export { configure, getConfig, resetConfig } from "./config.js";
4
+ export * from "./types.js";
5
+ export declare function startSession(req: StartSessionReq): Promise<Session>;
6
+ export declare function inheritSession(id: string, sessionToken: string): Promise<Session>;
7
+ export declare function getSession(id: string, sessionToken: string): Promise<SessionInfo>;
13
8
  export declare function readOutput(id: string, sessionToken: string, options?: {
14
9
  pageSize?: number;
15
10
  vertex?: string;
16
- newerThan?: string;
17
- }): Promise<ReadOutputResponseJson>;
11
+ newerThan?: Date;
12
+ }): Promise<OutputResponse>;
13
+ export declare function readOutputBinary(id: string, sessionToken: string, options?: {
14
+ pageSize?: number;
15
+ vertex?: string;
16
+ newerThan?: Date;
17
+ }): Promise<OutputBinaryResponse>;
18
18
  export declare function readUrls(id: string, sessionToken: string, options?: {
19
19
  pageSize?: number;
20
20
  newerThan?: string;
21
- }): Promise<ReadUrlsResponseJson>;
21
+ }): Promise<UrlResponse>;
22
22
  export declare function stopSession(id: string, sessionToken: string): Promise<void>;
23
23
  export declare class RestClientError extends Error {
24
24
  status: number;
@@ -1,19 +1,8 @@
1
- import type { Output as OutputMessage, Session, SessionJson, Session as SessionMessage, StatusJson, Url, UrlJson, Url as UrlMessage } from "@mochabug/genproto/mochabugapis/adapt/automations/v1/automations_pb.js";
2
- import { Status } from "@mochabug/genproto/mochabugapis/adapt/automations/v1/automations_pb.js";
3
- import type { SignalData } from "@mochabug/genproto/mochabugapis/adapt/graph/signal_data_pb.js";
4
- export type { OutputMessage, Session, SessionJson, SessionMessage, SignalData, Status, StatusJson, Url, UrlJson, UrlMessage, };
5
- export interface Output {
6
- vertex: string;
7
- fork: string;
8
- data: {
9
- [key: string]: SignalData;
10
- };
11
- created?: Date;
12
- }
1
+ import type { OutputBinary, SessionInfo, SignalData, UrlInfo } from "./types.js";
13
2
  export interface MessageHandlers {
14
- onOutput?: (output: Output) => void;
15
- onSession?: (session: SessionJson) => void;
16
- onUrl?: (url: UrlJson) => void;
3
+ onOutput?: (output: OutputBinary) => void;
4
+ onSession?: (session: SessionInfo) => void;
5
+ onUrl?: (url: UrlInfo) => void;
17
6
  }
18
7
  export interface SubscriptionOptions extends MessageHandlers {
19
8
  sessionToken: string;
@@ -26,7 +15,7 @@ export declare enum ConnectionState {
26
15
  CONNECTED = "connected",
27
16
  CLOSING = "closing"
28
17
  }
29
- export interface SessionInfo {
18
+ interface SessionCredentials {
30
19
  id: string;
31
20
  token: string;
32
21
  }
@@ -45,7 +34,7 @@ export declare class PubsubClient {
45
34
  unsubscribe(): Promise<void>;
46
35
  isConnected(): boolean;
47
36
  getConnectionState(): ConnectionState;
48
- getSessionInfo(): SessionInfo;
37
+ getSessionInfo(): SessionCredentials;
49
38
  private connect;
50
39
  private handleOpen;
51
40
  private handleMessage;
@@ -57,3 +46,13 @@ export declare class PubsubClient {
57
46
  private isSameSession;
58
47
  private updateHandlers;
59
48
  }
49
+ /**
50
+ * Converts a SignalData object to its JSON representation.
51
+ * This function validates that the mimeType is "application/json" before conversion.
52
+ *
53
+ * @param signalData - The SignalData object to convert
54
+ * @returns The parsed JSON object
55
+ * @throws Error if the mimeType is not "application/json"
56
+ */
57
+ export declare function signalDataToJson(signalData: SignalData): any;
58
+ export {};
@@ -0,0 +1,63 @@
1
+ import type { StatusJson } from "./genproto/mochabugapis/adapt/automations/v1/automations_pb.js";
2
+ export type { StatusJson };
3
+ export type SignalData = {
4
+ mimeType: string;
5
+ data: Uint8Array<ArrayBufferLike>;
6
+ filename?: string;
7
+ };
8
+ export type SignalValue = any | SignalData;
9
+ export interface StartSessionReq {
10
+ id: string;
11
+ transmitter?: string;
12
+ signals?: {
13
+ [name: string]: SignalValue;
14
+ };
15
+ token?: string;
16
+ }
17
+ export interface Session {
18
+ sessionToken: string;
19
+ expiresAt?: Date;
20
+ }
21
+ export interface SessionInfo {
22
+ status: StatusJson;
23
+ fork?: string;
24
+ }
25
+ export interface OutputBinary {
26
+ vertex: string;
27
+ fork: string;
28
+ data: {
29
+ [key: string]: SignalData;
30
+ };
31
+ created: Date;
32
+ }
33
+ export interface OutputBinaryResponse {
34
+ session: SessionInfo;
35
+ outputs: OutputBinary[];
36
+ nextPageCursor?: string;
37
+ }
38
+ export interface Output {
39
+ vertex: string;
40
+ fork?: string;
41
+ data: {
42
+ [key: string]: any;
43
+ };
44
+ created: Date;
45
+ }
46
+ export interface OutputResponse {
47
+ session: SessionInfo;
48
+ outputs: Output[];
49
+ nextPageCursor?: string;
50
+ }
51
+ export interface UrlInfo {
52
+ url: string;
53
+ vertex: string;
54
+ done: boolean;
55
+ created: Date;
56
+ token?: string;
57
+ fork?: string;
58
+ }
59
+ export interface UrlResponse {
60
+ session: SessionInfo;
61
+ urls: UrlInfo[];
62
+ nextPageCursor?: string;
63
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mochabug/adapt-core",
3
- "version": "1.0.0-rc21",
3
+ "version": "1.0.0-rc24",
4
4
  "description": "Cross-platform core client library for Adapt automation platform",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -9,15 +9,20 @@
9
9
  ".": {
10
10
  "types": "./dist/types/index.d.ts",
11
11
  "import": "./dist/esm/index.js"
12
+ },
13
+ "./grpc": {
14
+ "types": "./dist/types/grpc.d.ts",
15
+ "import": "./dist/esm/grpc.js"
12
16
  }
13
17
  },
14
18
  "files": [
15
19
  "dist"
16
20
  ],
17
21
  "scripts": {
22
+ "generate": "rm -rf src/genproto && cd ../../.. && buf generate --template clients/js/core/buf.gen.yaml --include-imports --path public-api/mochabugapis/adapt/automations --path public-api/mochabugapis/adapt/graph",
18
23
  "build:esm": "tsc --project tsconfig.esm.json",
19
24
  "build:types": "tsc --project tsconfig.types.json",
20
- "build": "rm -rf dist && npm run build:esm && npm run build:types",
25
+ "build": "rm -rf dist && npm run generate && npm run build:esm && npm run build:types",
21
26
  "test": "vitest run",
22
27
  "test:ui": "vitest --ui"
23
28
  },
@@ -29,10 +34,12 @@
29
34
  "author": "mochabug AB",
30
35
  "license": "ISC",
31
36
  "devDependencies": {
37
+ "@connectrpc/connect": "^2.1.1",
38
+ "@connectrpc/connect-node": "^2.1.1",
32
39
  "@types/ws": "^8.18.1",
33
- "@vitest/ui": "^4.0.12",
40
+ "@vitest/ui": "^4.0.13",
34
41
  "typescript": "^5.9.3",
35
- "vitest": "^4.0.12",
42
+ "vitest": "^4.0.13",
36
43
  "ws": "^8.18.3"
37
44
  },
38
45
  "dependencies": {
@@ -40,5 +47,17 @@
40
47
  "@types/uuid": "^11.0.0",
41
48
  "isomorphic-ws": "^5.0.0",
42
49
  "uuid": "^13.0.0"
50
+ },
51
+ "peerDependencies": {
52
+ "@connectrpc/connect": "^2.1.1",
53
+ "@connectrpc/connect-node": "^2.1.1"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "@connectrpc/connect": {
57
+ "optional": true
58
+ },
59
+ "@connectrpc/connect-node": {
60
+ "optional": true
61
+ }
43
62
  }
44
63
  }