@onlive.ai/flow-client 0.1.34 → 0.1.35

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.
@@ -0,0 +1,71 @@
1
+ import '@onlive.ai/tracker';
2
+ import TrackingService from '../tracking/tracking.service.cjs';
3
+ import { ClientOptions, GetStepOptions, FlowContext, GetStepTrigger } from './client.types.cjs';
4
+ import '../tracking/tracking.types.cjs';
5
+ import 'zod';
6
+
7
+ /**
8
+ * Client for interacting with the Flow API.
9
+ * Manages user journey through a flow by handling step transitions and tracking user interactions.
10
+ */
11
+ declare class FlowClient {
12
+ /**
13
+ * The base URL for API requests.
14
+ */
15
+ private baseURL;
16
+ /**
17
+ * HTTP headers to be sent with each request.
18
+ */
19
+ private headers;
20
+ /**
21
+ * The unique identifier of the flow.
22
+ */
23
+ private flowId;
24
+ /**
25
+ * Service for tracking user interactions and events.
26
+ * Only available if tracking is enabled in the options.
27
+ */
28
+ tracking: TrackingService;
29
+ /**
30
+ * Creates a new FlowClient instance.
31
+ * @param _options - Configuration options for the client
32
+ */
33
+ constructor(_options: ClientOptions);
34
+ /**
35
+ * Sends an HTTP request to the specified path and returns the response as a JSON object.
36
+ *
37
+ * @template T - The expected response type.
38
+ * @param {string} path - The path to which the request is sent.
39
+ * @param {RequestInit} [options={}] - Optional configuration for the request.
40
+ * @returns {Promise<T>} - A promise that resolves to the response data.
41
+ * @throws {Error} - Throws an error if the response status is not ok.
42
+ */
43
+ private request;
44
+ /**
45
+ * Initiates the first step of the flow process.
46
+ *
47
+ * @param {GetStepOptions} options - Optional parameters for getting the step.
48
+ * @returns {Promise<FlowContext>} A promise that resolves to the flow context.
49
+ */
50
+ firstStep(options?: GetStepOptions): Promise<FlowContext>;
51
+ /**
52
+ * Retrieves a specific step in the flow based on the provided step ID.
53
+ *
54
+ * @param {string} stepId - The unique identifier of the step to retrieve.
55
+ * @param {GetStepOptions} options - Optional parameters for customizing the step request.
56
+ * @returns {Promise<FlowContext>} A promise that resolves to the flow context containing the requested step information.
57
+ * @throws {Error} If the step ID is invalid or the step cannot be found.
58
+ */
59
+ getStep(stepId: string, options?: GetStepOptions): Promise<FlowContext>;
60
+ /**
61
+ * Advances to the next step in the flow based on the provided trigger action.
62
+ *
63
+ * @param {GetStepTrigger} trigger - Contains the current step ID and action ID to determine the next step.
64
+ * @param {GetStepOptions} options - Optional parameters to customize the step transition.
65
+ * @returns {Promise<FlowContext>} A promise that resolves to the updated flow context containing the next step information.
66
+ * @throws {Error} If the action is invalid or the next step cannot be determined.
67
+ */
68
+ nextStep(trigger: GetStepTrigger, options?: GetStepOptions): Promise<FlowContext>;
69
+ }
70
+
71
+ export { FlowClient, FlowClient as default };
@@ -0,0 +1,71 @@
1
+ import '@onlive.ai/tracker';
2
+ import TrackingService from '../tracking/tracking.service.js';
3
+ import { ClientOptions, GetStepOptions, FlowContext, GetStepTrigger } from './client.types.js';
4
+ import '../tracking/tracking.types.js';
5
+ import 'zod';
6
+
7
+ /**
8
+ * Client for interacting with the Flow API.
9
+ * Manages user journey through a flow by handling step transitions and tracking user interactions.
10
+ */
11
+ declare class FlowClient {
12
+ /**
13
+ * The base URL for API requests.
14
+ */
15
+ private baseURL;
16
+ /**
17
+ * HTTP headers to be sent with each request.
18
+ */
19
+ private headers;
20
+ /**
21
+ * The unique identifier of the flow.
22
+ */
23
+ private flowId;
24
+ /**
25
+ * Service for tracking user interactions and events.
26
+ * Only available if tracking is enabled in the options.
27
+ */
28
+ tracking: TrackingService;
29
+ /**
30
+ * Creates a new FlowClient instance.
31
+ * @param _options - Configuration options for the client
32
+ */
33
+ constructor(_options: ClientOptions);
34
+ /**
35
+ * Sends an HTTP request to the specified path and returns the response as a JSON object.
36
+ *
37
+ * @template T - The expected response type.
38
+ * @param {string} path - The path to which the request is sent.
39
+ * @param {RequestInit} [options={}] - Optional configuration for the request.
40
+ * @returns {Promise<T>} - A promise that resolves to the response data.
41
+ * @throws {Error} - Throws an error if the response status is not ok.
42
+ */
43
+ private request;
44
+ /**
45
+ * Initiates the first step of the flow process.
46
+ *
47
+ * @param {GetStepOptions} options - Optional parameters for getting the step.
48
+ * @returns {Promise<FlowContext>} A promise that resolves to the flow context.
49
+ */
50
+ firstStep(options?: GetStepOptions): Promise<FlowContext>;
51
+ /**
52
+ * Retrieves a specific step in the flow based on the provided step ID.
53
+ *
54
+ * @param {string} stepId - The unique identifier of the step to retrieve.
55
+ * @param {GetStepOptions} options - Optional parameters for customizing the step request.
56
+ * @returns {Promise<FlowContext>} A promise that resolves to the flow context containing the requested step information.
57
+ * @throws {Error} If the step ID is invalid or the step cannot be found.
58
+ */
59
+ getStep(stepId: string, options?: GetStepOptions): Promise<FlowContext>;
60
+ /**
61
+ * Advances to the next step in the flow based on the provided trigger action.
62
+ *
63
+ * @param {GetStepTrigger} trigger - Contains the current step ID and action ID to determine the next step.
64
+ * @param {GetStepOptions} options - Optional parameters to customize the step transition.
65
+ * @returns {Promise<FlowContext>} A promise that resolves to the updated flow context containing the next step information.
66
+ * @throws {Error} If the action is invalid or the next step cannot be determined.
67
+ */
68
+ nextStep(trigger: GetStepTrigger, options?: GetStepOptions): Promise<FlowContext>;
69
+ }
70
+
71
+ export { FlowClient, FlowClient as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }