@applica-software-guru/persona-sdk 0.1.109 → 0.1.111
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/dist/index.d.ts +21 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/triggers/types.ts +21 -1
- package/src/workflows/types.ts +2 -0
- package/tests/triggers-api.test.mjs +66 -0
package/dist/index.d.ts
CHANGED
|
@@ -401,6 +401,8 @@ export declare interface ExecuteRequest {
|
|
|
401
401
|
initialData?: Record<string, unknown>;
|
|
402
402
|
callbackUrl?: string;
|
|
403
403
|
eventsHook?: string;
|
|
404
|
+
/** Execution-level automatic recovery rounds (undefined = server default). */
|
|
405
|
+
recoveryAttempts?: number;
|
|
404
406
|
}
|
|
405
407
|
|
|
406
408
|
export declare interface Execution {
|
|
@@ -1422,9 +1424,11 @@ export declare interface Trigger {
|
|
|
1422
1424
|
|
|
1423
1425
|
export declare interface TriggerDestination {
|
|
1424
1426
|
type?: string;
|
|
1425
|
-
configuration?:
|
|
1427
|
+
configuration?: TriggerDestinationConfiguration;
|
|
1426
1428
|
}
|
|
1427
1429
|
|
|
1430
|
+
export declare type TriggerDestinationConfiguration = WorkflowDestinationConfiguration | Record<string, unknown>;
|
|
1431
|
+
|
|
1428
1432
|
export declare interface TriggerExecutionResult {
|
|
1429
1433
|
id?: string;
|
|
1430
1434
|
triggerId?: string;
|
|
@@ -1605,6 +1609,22 @@ export declare interface Workflow {
|
|
|
1605
1609
|
features?: Feature[];
|
|
1606
1610
|
}
|
|
1607
1611
|
|
|
1612
|
+
/**
|
|
1613
|
+
* Configuration for "workflow" trigger destinations.
|
|
1614
|
+
* `timeout` is the maximum time in seconds to wait for the workflow
|
|
1615
|
+
* execution callback; when not set the server applies its default (300s).
|
|
1616
|
+
* `recoveryAttempts` is the execution-level automatic recovery rounds the
|
|
1617
|
+
* engine applies when a node fails for good (0 disables); when not set the
|
|
1618
|
+
* server applies its default (1 round) and caps the upper bound.
|
|
1619
|
+
*/
|
|
1620
|
+
export declare interface WorkflowDestinationConfiguration {
|
|
1621
|
+
workflowId?: string;
|
|
1622
|
+
callbackUrl?: string;
|
|
1623
|
+
args?: Record<string, unknown>;
|
|
1624
|
+
timeout?: number;
|
|
1625
|
+
recoveryAttempts?: number;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1608
1628
|
export declare class WorkflowExecutionsApi extends HttpApi {
|
|
1609
1629
|
constructor(baseUrl: string, auth: string | AuthenticationProvider);
|
|
1610
1630
|
list(workflowId: string, page?: number, size?: number): Promise<Paginated<Execution>>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@applica-software-guru/persona-sdk",
|
|
3
3
|
"description": "Official TypeScript SDK for the Persona API — manage agents, sessions, projects, knowledge bases, workflows, triggers and more.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.111",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "vite",
|
package/src/index.ts
CHANGED
|
@@ -144,6 +144,8 @@ export type {
|
|
|
144
144
|
GmailTriggerSourceConfiguration,
|
|
145
145
|
ImapTriggerSourceConfiguration,
|
|
146
146
|
TriggerDestination,
|
|
147
|
+
TriggerDestinationConfiguration,
|
|
148
|
+
WorkflowDestinationConfiguration,
|
|
147
149
|
TriggerExecutionResult,
|
|
148
150
|
} from './triggers/types';
|
|
149
151
|
export { FeaturesApi } from './features/features-api';
|
package/src/triggers/types.ts
CHANGED
|
@@ -25,9 +25,29 @@ export interface TriggerSource {
|
|
|
25
25
|
configuration?: TriggerSourceConfiguration;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Configuration for "workflow" trigger destinations.
|
|
30
|
+
* `timeout` is the maximum time in seconds to wait for the workflow
|
|
31
|
+
* execution callback; when not set the server applies its default (300s).
|
|
32
|
+
* `recoveryAttempts` is the execution-level automatic recovery rounds the
|
|
33
|
+
* engine applies when a node fails for good (0 disables); when not set the
|
|
34
|
+
* server applies its default (1 round) and caps the upper bound.
|
|
35
|
+
*/
|
|
36
|
+
export interface WorkflowDestinationConfiguration {
|
|
37
|
+
workflowId?: string;
|
|
38
|
+
callbackUrl?: string;
|
|
39
|
+
args?: Record<string, unknown>;
|
|
40
|
+
timeout?: number;
|
|
41
|
+
recoveryAttempts?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type TriggerDestinationConfiguration =
|
|
45
|
+
| WorkflowDestinationConfiguration
|
|
46
|
+
| Record<string, unknown>;
|
|
47
|
+
|
|
28
48
|
export interface TriggerDestination {
|
|
29
49
|
type?: string;
|
|
30
|
-
configuration?:
|
|
50
|
+
configuration?: TriggerDestinationConfiguration;
|
|
31
51
|
}
|
|
32
52
|
|
|
33
53
|
export interface Trigger {
|
package/src/workflows/types.ts
CHANGED
|
@@ -137,6 +137,8 @@ export interface ExecuteRequest {
|
|
|
137
137
|
initialData?: Record<string, unknown>;
|
|
138
138
|
callbackUrl?: string;
|
|
139
139
|
eventsHook?: string;
|
|
140
|
+
/** Execution-level automatic recovery rounds (undefined = server default). */
|
|
141
|
+
recoveryAttempts?: number;
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
export interface HumanTask {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { TriggersApi } from '../dist/bundle.es.js';
|
|
5
|
+
|
|
6
|
+
function jsonResponse(body) {
|
|
7
|
+
return new Response(JSON.stringify(body), {
|
|
8
|
+
status: 200,
|
|
9
|
+
headers: { 'Content-Type': 'application/json' },
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const TRIGGER = {
|
|
14
|
+
name: 'email-trigger',
|
|
15
|
+
source: { type: 'imap' },
|
|
16
|
+
destination: {
|
|
17
|
+
type: 'workflow',
|
|
18
|
+
configuration: {
|
|
19
|
+
workflowId: 'wf-001',
|
|
20
|
+
recoveryAttempts: 2,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
enabled: true,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
test('trigger create forwards recoveryAttempts in the destination configuration', async (context) => {
|
|
27
|
+
const originalFetch = globalThis.fetch;
|
|
28
|
+
context.after(() => {
|
|
29
|
+
globalThis.fetch = originalFetch;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
let requestBody;
|
|
33
|
+
globalThis.fetch = async (url, init) => {
|
|
34
|
+
requestBody = JSON.parse(init.body);
|
|
35
|
+
return jsonResponse({ id: 'trigger-001', ...TRIGGER });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const api = new TriggersApi('https://example.test', 'api-key');
|
|
39
|
+
await api.create(TRIGGER);
|
|
40
|
+
|
|
41
|
+
assert.equal(requestBody.destination.configuration.recoveryAttempts, 2);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('trigger update forwards recoveryAttempts too', async (context) => {
|
|
45
|
+
const originalFetch = globalThis.fetch;
|
|
46
|
+
context.after(() => {
|
|
47
|
+
globalThis.fetch = originalFetch;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
let requestBody;
|
|
51
|
+
globalThis.fetch = async (url, init) => {
|
|
52
|
+
requestBody = JSON.parse(init.body);
|
|
53
|
+
return jsonResponse({ id: 'trigger-001', ...TRIGGER });
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const api = new TriggersApi('https://example.test', 'api-key');
|
|
57
|
+
await api.update('trigger-001', {
|
|
58
|
+
...TRIGGER,
|
|
59
|
+
destination: {
|
|
60
|
+
type: 'workflow',
|
|
61
|
+
configuration: { workflowId: 'wf-001', recoveryAttempts: 0 },
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
assert.equal(requestBody.destination.configuration.recoveryAttempts, 0);
|
|
66
|
+
});
|