Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 66 additions & 23 deletions src/integration-tests/EventClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect, describe, test, jest } from "@jest/globals";
import { orkesConductorClient, EventClient } from "../sdk";
import { describe, expect, jest, test } from "@jest/globals";
import type {
Action,
ConnectivityTestInput,
EventHandler,
Tag,
ConnectivityTestInput,
Action,
} from "../open-api";
import { EventClient, orkesConductorClient } from "../sdk";
import { describeForOrkesV5 } from "./utils/customJestDescribe";

describe("EventClient", () => {
Expand Down Expand Up @@ -531,12 +531,27 @@ describe("EventClient", () => {
expect(handlerAfterEvent.active).toBe(true);
expect(handlerAfterEvent.event).toEqual(eventName);

const executions = await eventClient.getEventExecutions(handlerName);
expect(Array.isArray(executions)).toBe(true);
// Wait for event execution to be created (async processing)
let ourExecution;
const maxWaitTime = 30000; // 30 seconds
const pollInterval = 500; // 500ms
const startTime = Date.now();

while (Date.now() - startTime < maxWaitTime) {
const executions = await eventClient.getEventExecutions(handlerName);
expect(Array.isArray(executions)).toBe(true);

ourExecution = executions.find(
(exec) => exec.event === eventName || exec.name === handlerName
);

if (ourExecution) {
break;
}

await new Promise((resolve) => setTimeout(resolve, pollInterval));
}

const ourExecution = executions.find(
(exec) => exec.event === eventName || exec.name === handlerName
);
expect(ourExecution).toBeDefined();
if (ourExecution?.event) {
expect(ourExecution.event).toEqual(eventName);
Expand Down Expand Up @@ -638,14 +653,27 @@ describe("EventClient", () => {
};
await eventClient.handleIncomingEvent(eventData);

const executions = await eventClient.getEventExecutions(handlerName, 0);
expect(Array.isArray(executions)).toBe(true);
expect(executions.length).toBeGreaterThan(0);
// Wait for event execution to be created (async processing)
let ourExecution;
const maxWaitTime = 30000; // 30 seconds
const pollInterval = 500; // 500ms
const startTime = Date.now();

while (Date.now() - startTime < maxWaitTime) {
const executions = await eventClient.getEventExecutions(handlerName, 0);
expect(Array.isArray(executions)).toBe(true);

ourExecution = executions.find(
(exec) => exec.name === handlerName && exec.event === eventName
);

if (ourExecution) {
break;
}

await new Promise((resolve) => setTimeout(resolve, pollInterval));
}

// Find our execution in the results
const ourExecution = executions.find(
(exec) => exec.name === handlerName && exec.event === eventName
);
expect(ourExecution).toBeDefined();
expect(ourExecution?.name).toBe(handlerName);
expect(ourExecution?.event).toBe(eventName);
Expand Down Expand Up @@ -689,14 +717,29 @@ describe("EventClient", () => {
};
await eventClient.handleIncomingEvent(eventData);

const response = await eventClient.getEventHandlersWithStats(0);
expect(response).toBeDefined();
expect(response).toHaveProperty("results");
expect(Array.isArray(response.results)).toBe(true);
expect(response.results?.length).toBeGreaterThan(0);
// Wait for statistics to be updated (async processing)
let foundHandler;
const maxWaitTime = 30000; // 30 seconds
const pollInterval = 500; // 500ms
const startTime = Date.now();

while (Date.now() - startTime < maxWaitTime) {
const response = await eventClient.getEventHandlersWithStats(0);
expect(response).toBeDefined();
expect(response).toHaveProperty("results");
expect(Array.isArray(response.results)).toBe(true);
expect(response.results?.length).toBeGreaterThan(0);

// Find our handler in the results
foundHandler = response.results?.find((h) => h.event === eventName);

if (foundHandler) {
break;
}

await new Promise((resolve) => setTimeout(resolve, pollInterval));
}

// Find our handler in the results
const foundHandler = response.results?.find((h) => h.event === eventName);
expect(foundHandler).toBeDefined();
expect(foundHandler?.event).toBe(eventName);
expect(foundHandler?.active).toBe(true);
Expand Down
3 changes: 2 additions & 1 deletion src/open-api/deprecated-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */
// TODO: remove everything below (whole file) after April 2026 (backward compatibility types)
// Legacy compatibility types: This file provides backward compatibility types.
// These types are maintained for legacy users and will not be removed.
// ------------------------------start------------------------------
import type {
HumanTaskEntry,
Expand Down
4 changes: 2 additions & 2 deletions src/open-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export type {

export * from "./types";

// todo: remove after April 2026 (backward compatibility types)
// Legacy compatibility types: maintained for backward compatibility
export * from "./deprecated-types";

/**
* Export types needed for client's return type in case if user is building another lib on top of sdk with declaration files
* @deprecated
* to import all the types below manually while using SDK since these types could change in future without backward compatibility
* TODO: remove after April 2026
* Legacy compatibility: maintained for backward compatibility
*/
export type {
Auth,
Expand Down
3 changes: 2 additions & 1 deletion src/sdk/createConductorClient/createConductorClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const createConductorClient = async (
await handleAuth(openApiClient, keyId, keySecret, refreshTokenInterval);
}

// DEPRECATED, should be replaced with return openApiClient after April 2026:
// Legacy compatibility: Adds resource-based API methods for backward compatibility.
// The modern API is available directly on openApiClient, but legacy methods are maintained.
return addResourcesBackwardCompatibility(openApiClient);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable */
// disable linter since related old functionality was not properly typed
// TODO: everything in this file is DEPRECATED and whole file should be removed after April 2026
// Legacy compatibility layer: This file provides backward compatibility for the old resource-based API.
// The legacy API is maintained for existing users, but new code should use the modern API methods.

import type { SignalResponse } from "../../../open-api";
import type { Client } from "../../../open-api/generated/client/types.gen";
Expand All @@ -21,7 +22,7 @@ import {

const warn = () => {
console.warn(
"[Conductor SDK Deprecation Warning] Accessing resources directly on the client is deprecated and will be removed after April 2026"
"[Conductor SDK Legacy API] You are using the legacy resource-based API. This API is maintained for backward compatibility. For new code, use higher-level clients (EventClient, TaskClient) or Resource classes directly."
);
};

Expand Down