@onlive.ai/flow-client 0.1.31 → 0.1.34
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/README.md +154 -9
- package/client/client.service.cjs +6 -6
- package/client/client.service.js +6 -6
- package/client/client.service.spec.cjs +6 -6
- package/client/client.service.spec.js +6 -6
- package/client/client.types.cjs +2 -2
- package/client/client.types.js +2 -2
- package/index.cjs +6 -6
- package/index.js +6 -6
- package/package.json +6 -5
- package/tracking/tracking.service.cjs +3 -3
- package/tracking/tracking.service.js +3 -3
- package/client/client.service.d.cts +0 -71
- package/client/client.service.d.ts +0 -71
- package/client/client.service.spec.d.cts +0 -2
- package/client/client.service.spec.d.ts +0 -2
- package/client/client.types.d.cts +0 -13421
- package/client/client.types.d.ts +0 -13421
- package/flow.types.d.cts +0 -49501
- package/flow.types.d.ts +0 -49501
- package/index.d.cts +0 -6
- package/index.d.ts +0 -6
- package/schema-generator.d.cts +0 -2
- package/schema-generator.d.ts +0 -2
- package/tracking/tracking.service.d.cts +0 -104
- package/tracking/tracking.service.d.ts +0 -104
- package/tracking/tracking.types.d.cts +0 -1489
- package/tracking/tracking.types.d.ts +0 -1489
package/README.md
CHANGED
|
@@ -1,8 +1,64 @@
|
|
|
1
1
|
# Onlive Flow Client
|
|
2
2
|
|
|
3
|
-
The Flow Client package offers a convenient interface for interacting with a multi-step process flow. The client helps you initiate, retrieve, and progress through flow steps while tracking events. It leverages robust type validation
|
|
3
|
+
The Flow Client package offers a convenient interface for interacting with a multi-step process flow. The client helps you initiate, retrieve, and progress through flow steps while tracking events. It leverages robust type validation and provides a modern TypeScript-first API.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Using pnpm (recommended)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @onlive.ai/flow-client
|
|
11
|
+
# or
|
|
12
|
+
npm install @onlive.ai/flow-client
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Package Structure
|
|
16
|
+
|
|
17
|
+
This package is organized into the following main components:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
packages/flow-client/
|
|
21
|
+
├── client/ # Core client implementation
|
|
22
|
+
│ ├── client.service.ts # Main FlowClient class
|
|
23
|
+
│ ├── client.types.ts # Type definitions and schemas
|
|
24
|
+
│ └── client.service.spec.ts # Unit tests
|
|
25
|
+
├── tracking/ # Event tracking functionality
|
|
26
|
+
│ ├── tracking.service.ts # Tracking service implementation
|
|
27
|
+
│ └── tracking.types.ts # Tracking-related types
|
|
28
|
+
├── flow.types.ts # Flow-specific type definitions
|
|
29
|
+
├── index.ts # Main package exports
|
|
30
|
+
├── schema-generator.ts # JSON schema generation utilities
|
|
31
|
+
└── README.md # This documentation
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Main Exports
|
|
35
|
+
|
|
36
|
+
The package exports the following main components:
|
|
37
|
+
|
|
38
|
+
- **FlowClient**: Main client class for flow interactions
|
|
39
|
+
- **Type definitions**: Comprehensive TypeScript types for flows, steps, actions, and events
|
|
40
|
+
- **Event types**: Types for tracking and event handling from `@onlive.ai/tracker`
|
|
41
|
+
|
|
42
|
+
## Dependencies
|
|
43
|
+
|
|
44
|
+
This package depends on:
|
|
45
|
+
|
|
46
|
+
- **@onlive.ai/tracker**: Event tracking functionality
|
|
47
|
+
- **@onlive.ai/calendar**: Calendar-related utilities
|
|
48
|
+
- **@onlive.ai/common-121**: Shared utilities and types
|
|
49
|
+
- **zod**: Runtime type validation and schema definitions
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
### Basic Import
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { FlowClient } from '@onlive.ai/flow-client';
|
|
57
|
+
// or
|
|
58
|
+
import { FlowClient, type FlowContext, type ClientOptions } from '@onlive.ai/flow-client';
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Initialization
|
|
6
62
|
|
|
7
63
|
Create an instance of the FlowClient by passing a valid ClientOptions object. The options must conform to the ClientOptionsSchema. The options include:
|
|
8
64
|
|
|
@@ -20,9 +76,15 @@ const client = new FlowClient({
|
|
|
20
76
|
});
|
|
21
77
|
```
|
|
22
78
|
|
|
23
|
-
|
|
79
|
+
### API Reference
|
|
80
|
+
|
|
81
|
+
#### FlowClient Class
|
|
82
|
+
|
|
83
|
+
The main class for interacting with flows. All methods are type-safe and include runtime validation.
|
|
84
|
+
|
|
85
|
+
#### Methods
|
|
24
86
|
|
|
25
|
-
|
|
87
|
+
##### firstStep(options?: GetStepOptions): Promise<FlowContext>
|
|
26
88
|
|
|
27
89
|
Initiates the first step of the flow.
|
|
28
90
|
|
|
@@ -35,7 +97,7 @@ Initiates the first step of the flow.
|
|
|
35
97
|
- Sends a POST request to `flow/{flowId}/first-step`.
|
|
36
98
|
- Analyzes and emits "track" events via the tracking service.
|
|
37
99
|
|
|
38
|
-
|
|
100
|
+
##### getStep(stepId: string, options?: GetStepOptions): Promise<FlowContext>
|
|
39
101
|
|
|
40
102
|
Retrieves a specific step in the flow.
|
|
41
103
|
|
|
@@ -49,7 +111,7 @@ Retrieves a specific step in the flow.
|
|
|
49
111
|
- Sends a POST request to `flow/{flowId}/steps/{stepId}`.
|
|
50
112
|
- Tracks request and response events.
|
|
51
113
|
|
|
52
|
-
|
|
114
|
+
##### nextStep(trigger: GetStepTrigger, options?: GetStepOptions): Promise<FlowContext>
|
|
53
115
|
|
|
54
116
|
Proceeds to the next step in the flow based on user actions.
|
|
55
117
|
|
|
@@ -65,9 +127,9 @@ Proceeds to the next step in the flow based on user actions.
|
|
|
65
127
|
- Sends a POST request to `flow/{flowId}/steps/{currentStepId}/action/{actionId}`.
|
|
66
128
|
- Analyzes both request and response by emitting tracking events.
|
|
67
129
|
|
|
68
|
-
|
|
130
|
+
#### Event Handling
|
|
69
131
|
|
|
70
|
-
|
|
132
|
+
##### on(type: EventType, listener: EventListener): void
|
|
71
133
|
|
|
72
134
|
Registers a listener for specific events.
|
|
73
135
|
|
|
@@ -81,11 +143,94 @@ Internally, FlowClient uses a private `emit` method to deliver events to all reg
|
|
|
81
143
|
|
|
82
144
|
## Types & Schemas
|
|
83
145
|
|
|
84
|
-
The methods and the overall flow behavior are governed by types and validation schemas defined in
|
|
146
|
+
The methods and the overall flow behavior are governed by types and validation schemas defined in the package:
|
|
85
147
|
|
|
86
148
|
- **FlowContext**: Contains the status of the flow, current step details, and flow metadata.
|
|
87
149
|
- **StepSchema**, **ActionSchema**, **FieldSchema**: Define properties and validation for steps, actions, and form fields.
|
|
88
150
|
- **GetStepOptions** and **GetStepTrigger**: Govern the payload structure for step operations.
|
|
89
151
|
- **EventData**: Structure for tracking events, ensuring consistency with the "track" event type.
|
|
90
152
|
|
|
153
|
+
## Features
|
|
154
|
+
|
|
155
|
+
- **Type Safety**: Full TypeScript support with runtime validation using Zod schemas
|
|
156
|
+
- **Event Tracking**: Built-in event tracking for flow interactions
|
|
157
|
+
- **Multi-format Support**: Supports both ESM and CommonJS
|
|
158
|
+
- **Modern API**: Promise-based API with async/await support
|
|
159
|
+
- **Flexible Configuration**: Configurable client options with validation
|
|
160
|
+
- **Error Handling**: Comprehensive error handling with type-safe error responses
|
|
161
|
+
|
|
162
|
+
## Development
|
|
163
|
+
|
|
164
|
+
### Building the Package
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
pnpm build:package
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Running Tests
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Run tests
|
|
174
|
+
pnpm test
|
|
175
|
+
|
|
176
|
+
# Run tests with coverage
|
|
177
|
+
pnpm test:coverage
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Cleaning Build Artifacts
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
pnpm clean
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Examples
|
|
187
|
+
|
|
188
|
+
### Complete Flow Example
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import { FlowClient } from '@onlive.ai/flow-client';
|
|
192
|
+
|
|
193
|
+
const client = new FlowClient({
|
|
194
|
+
baseUrl: "https://api.example.com",
|
|
195
|
+
flowId: "0123456789abcdef01234567",
|
|
196
|
+
organizationId: "550e8400-e29b-41d4-a716-446655440000",
|
|
197
|
+
lang: "en",
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// Set up event tracking
|
|
201
|
+
client.on('track', (eventType, eventData) => {
|
|
202
|
+
console.log('Flow event:', eventType, eventData);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Start the flow
|
|
206
|
+
try {
|
|
207
|
+
const firstStep = await client.firstStep();
|
|
208
|
+
console.log('First step:', firstStep);
|
|
209
|
+
|
|
210
|
+
// Progress through the flow
|
|
211
|
+
const nextStep = await client.nextStep({
|
|
212
|
+
currentStepId: firstStep.step.id,
|
|
213
|
+
actionId: 'continue'
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
console.log('Next step:', nextStep);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
console.error('Flow error:', error);
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Getting a Specific Step
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
const specificStep = await client.getStep('step-id-123', {
|
|
226
|
+
// optional additional parameters
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
This package is part of the Onlive workspace and follows the project's licensing terms.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
91
236
|
This documentation mirrors common npm package libraries by providing a straightforward interface with strong type validations and event tracking, ensuring that clients can interact with a dynamic flow efficiently.
|
|
@@ -26,12 +26,12 @@ __export(client_service_exports, {
|
|
|
26
26
|
default: () => client_service_default
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(client_service_exports);
|
|
29
|
-
var import_merge2 = require("@
|
|
29
|
+
var import_merge2 = require("@onlive.ai/common-121/utils/merge.js");
|
|
30
30
|
|
|
31
31
|
// tracking/tracking.service.ts
|
|
32
|
-
var import_tracker = require("@onlive.
|
|
33
|
-
var import_merge = require("@
|
|
34
|
-
var import_browser_preferences = require("@
|
|
32
|
+
var import_tracker = require("@onlive.ai/tracker");
|
|
33
|
+
var import_merge = require("@onlive.ai/common-121/utils/merge.js");
|
|
34
|
+
var import_browser_preferences = require("@onlive.ai/common-121/utils/browser-preferences.js");
|
|
35
35
|
|
|
36
36
|
// tracking/tracking.types.ts
|
|
37
37
|
var import_zod = require("zod");
|
|
@@ -237,12 +237,12 @@ var TrackingService = class {
|
|
|
237
237
|
var tracking_service_default = TrackingService;
|
|
238
238
|
|
|
239
239
|
// client/client.types.ts
|
|
240
|
-
var import_calendar = require("@onlive.
|
|
240
|
+
var import_calendar = require("@onlive.ai/calendar");
|
|
241
241
|
var import_zod2 = require("zod");
|
|
242
242
|
var DEFAULT_CLIENT_OPTIONS = {
|
|
243
243
|
tracking: {
|
|
244
244
|
removeExtraneousValues: true,
|
|
245
|
-
apiUrl: "https://srvless.onlive.
|
|
245
|
+
apiUrl: "https://srvless.onlive.ai/tracking",
|
|
246
246
|
data: {
|
|
247
247
|
widget_type: "OnliveAppFlow"
|
|
248
248
|
}
|
package/client/client.service.js
CHANGED
|
@@ -3,12 +3,12 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
|
|
5
5
|
// client/client.service.ts
|
|
6
|
-
import { merge as merge2 } from "@
|
|
6
|
+
import { merge as merge2 } from "@onlive.ai/common-121/utils/merge.js";
|
|
7
7
|
|
|
8
8
|
// tracking/tracking.service.ts
|
|
9
|
-
import { Session, Tracker } from "@onlive.
|
|
10
|
-
import { merge } from "@
|
|
11
|
-
import { browserPreferences } from "@
|
|
9
|
+
import { Session, Tracker } from "@onlive.ai/tracker";
|
|
10
|
+
import { merge } from "@onlive.ai/common-121/utils/merge.js";
|
|
11
|
+
import { browserPreferences } from "@onlive.ai/common-121/utils/browser-preferences.js";
|
|
12
12
|
|
|
13
13
|
// tracking/tracking.types.ts
|
|
14
14
|
import { z } from "zod";
|
|
@@ -214,12 +214,12 @@ var TrackingService = class {
|
|
|
214
214
|
var tracking_service_default = TrackingService;
|
|
215
215
|
|
|
216
216
|
// client/client.types.ts
|
|
217
|
-
import { GetAvailabilityFilters, GetAvailabilityOptions } from "@onlive.
|
|
217
|
+
import { GetAvailabilityFilters, GetAvailabilityOptions } from "@onlive.ai/calendar";
|
|
218
218
|
import { z as z2 } from "zod";
|
|
219
219
|
var DEFAULT_CLIENT_OPTIONS = {
|
|
220
220
|
tracking: {
|
|
221
221
|
removeExtraneousValues: true,
|
|
222
|
-
apiUrl: "https://srvless.onlive.
|
|
222
|
+
apiUrl: "https://srvless.onlive.ai/tracking",
|
|
223
223
|
data: {
|
|
224
224
|
widget_type: "OnliveAppFlow"
|
|
225
225
|
}
|
|
@@ -8,12 +8,12 @@ var import_vitest = require("vitest");
|
|
|
8
8
|
var import_zod3 = require("zod");
|
|
9
9
|
|
|
10
10
|
// client/client.service.ts
|
|
11
|
-
var import_merge2 = require("@
|
|
11
|
+
var import_merge2 = require("@onlive.ai/common-121/utils/merge.js");
|
|
12
12
|
|
|
13
13
|
// tracking/tracking.service.ts
|
|
14
|
-
var import_tracker = require("@onlive.
|
|
15
|
-
var import_merge = require("@
|
|
16
|
-
var import_browser_preferences = require("@
|
|
14
|
+
var import_tracker = require("@onlive.ai/tracker");
|
|
15
|
+
var import_merge = require("@onlive.ai/common-121/utils/merge.js");
|
|
16
|
+
var import_browser_preferences = require("@onlive.ai/common-121/utils/browser-preferences.js");
|
|
17
17
|
|
|
18
18
|
// tracking/tracking.types.ts
|
|
19
19
|
var import_zod = require("zod");
|
|
@@ -219,12 +219,12 @@ var TrackingService = class {
|
|
|
219
219
|
var tracking_service_default = TrackingService;
|
|
220
220
|
|
|
221
221
|
// client/client.types.ts
|
|
222
|
-
var import_calendar = require("@onlive.
|
|
222
|
+
var import_calendar = require("@onlive.ai/calendar");
|
|
223
223
|
var import_zod2 = require("zod");
|
|
224
224
|
var DEFAULT_CLIENT_OPTIONS = {
|
|
225
225
|
tracking: {
|
|
226
226
|
removeExtraneousValues: true,
|
|
227
|
-
apiUrl: "https://srvless.onlive.
|
|
227
|
+
apiUrl: "https://srvless.onlive.ai/tracking",
|
|
228
228
|
data: {
|
|
229
229
|
widget_type: "OnliveAppFlow"
|
|
230
230
|
}
|
|
@@ -7,12 +7,12 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
7
7
|
import { ZodError } from "zod";
|
|
8
8
|
|
|
9
9
|
// client/client.service.ts
|
|
10
|
-
import { merge as merge2 } from "@
|
|
10
|
+
import { merge as merge2 } from "@onlive.ai/common-121/utils/merge.js";
|
|
11
11
|
|
|
12
12
|
// tracking/tracking.service.ts
|
|
13
|
-
import { Session, Tracker } from "@onlive.
|
|
14
|
-
import { merge } from "@
|
|
15
|
-
import { browserPreferences } from "@
|
|
13
|
+
import { Session, Tracker } from "@onlive.ai/tracker";
|
|
14
|
+
import { merge } from "@onlive.ai/common-121/utils/merge.js";
|
|
15
|
+
import { browserPreferences } from "@onlive.ai/common-121/utils/browser-preferences.js";
|
|
16
16
|
|
|
17
17
|
// tracking/tracking.types.ts
|
|
18
18
|
import { z } from "zod";
|
|
@@ -218,12 +218,12 @@ var TrackingService = class {
|
|
|
218
218
|
var tracking_service_default = TrackingService;
|
|
219
219
|
|
|
220
220
|
// client/client.types.ts
|
|
221
|
-
import { GetAvailabilityFilters, GetAvailabilityOptions } from "@onlive.
|
|
221
|
+
import { GetAvailabilityFilters, GetAvailabilityOptions } from "@onlive.ai/calendar";
|
|
222
222
|
import { z as z2 } from "zod";
|
|
223
223
|
var DEFAULT_CLIENT_OPTIONS = {
|
|
224
224
|
tracking: {
|
|
225
225
|
removeExtraneousValues: true,
|
|
226
|
-
apiUrl: "https://srvless.onlive.
|
|
226
|
+
apiUrl: "https://srvless.onlive.ai/tracking",
|
|
227
227
|
data: {
|
|
228
228
|
widget_type: "OnliveAppFlow"
|
|
229
229
|
}
|
package/client/client.types.cjs
CHANGED
|
@@ -37,7 +37,7 @@ __export(client_types_exports, {
|
|
|
37
37
|
StepId: () => StepId
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(client_types_exports);
|
|
40
|
-
var import_calendar = require("@onlive.
|
|
40
|
+
var import_calendar = require("@onlive.ai/calendar");
|
|
41
41
|
var import_zod2 = require("zod");
|
|
42
42
|
|
|
43
43
|
// tracking/tracking.types.ts
|
|
@@ -60,7 +60,7 @@ var TrackingOptionsSchema = import_zod.z.object({
|
|
|
60
60
|
var DEFAULT_CLIENT_OPTIONS = {
|
|
61
61
|
tracking: {
|
|
62
62
|
removeExtraneousValues: true,
|
|
63
|
-
apiUrl: "https://srvless.onlive.
|
|
63
|
+
apiUrl: "https://srvless.onlive.ai/tracking",
|
|
64
64
|
data: {
|
|
65
65
|
widget_type: "OnliveAppFlow"
|
|
66
66
|
}
|
package/client/client.types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// client/client.types.ts
|
|
2
|
-
import { GetAvailabilityFilters, GetAvailabilityOptions } from "@onlive.
|
|
2
|
+
import { GetAvailabilityFilters, GetAvailabilityOptions } from "@onlive.ai/calendar";
|
|
3
3
|
import { z as z2 } from "zod";
|
|
4
4
|
|
|
5
5
|
// tracking/tracking.types.ts
|
|
@@ -22,7 +22,7 @@ var TrackingOptionsSchema = z.object({
|
|
|
22
22
|
var DEFAULT_CLIENT_OPTIONS = {
|
|
23
23
|
tracking: {
|
|
24
24
|
removeExtraneousValues: true,
|
|
25
|
-
apiUrl: "https://srvless.onlive.
|
|
25
|
+
apiUrl: "https://srvless.onlive.ai/tracking",
|
|
26
26
|
data: {
|
|
27
27
|
widget_type: "OnliveAppFlow"
|
|
28
28
|
}
|
package/index.cjs
CHANGED
|
@@ -45,12 +45,12 @@ __export(index_exports, {
|
|
|
45
45
|
module.exports = __toCommonJS(index_exports);
|
|
46
46
|
|
|
47
47
|
// client/client.service.ts
|
|
48
|
-
var import_merge2 = require("@
|
|
48
|
+
var import_merge2 = require("@onlive.ai/common-121/utils/merge.js");
|
|
49
49
|
|
|
50
50
|
// tracking/tracking.service.ts
|
|
51
|
-
var import_tracker = require("@onlive.
|
|
52
|
-
var import_merge = require("@
|
|
53
|
-
var import_browser_preferences = require("@
|
|
51
|
+
var import_tracker = require("@onlive.ai/tracker");
|
|
52
|
+
var import_merge = require("@onlive.ai/common-121/utils/merge.js");
|
|
53
|
+
var import_browser_preferences = require("@onlive.ai/common-121/utils/browser-preferences.js");
|
|
54
54
|
|
|
55
55
|
// tracking/tracking.types.ts
|
|
56
56
|
var import_zod = require("zod");
|
|
@@ -256,12 +256,12 @@ var TrackingService = class {
|
|
|
256
256
|
var tracking_service_default = TrackingService;
|
|
257
257
|
|
|
258
258
|
// client/client.types.ts
|
|
259
|
-
var import_calendar = require("@onlive.
|
|
259
|
+
var import_calendar = require("@onlive.ai/calendar");
|
|
260
260
|
var import_zod2 = require("zod");
|
|
261
261
|
var DEFAULT_CLIENT_OPTIONS = {
|
|
262
262
|
tracking: {
|
|
263
263
|
removeExtraneousValues: true,
|
|
264
|
-
apiUrl: "https://srvless.onlive.
|
|
264
|
+
apiUrl: "https://srvless.onlive.ai/tracking",
|
|
265
265
|
data: {
|
|
266
266
|
widget_type: "OnliveAppFlow"
|
|
267
267
|
}
|
package/index.js
CHANGED
|
@@ -3,12 +3,12 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
|
|
5
5
|
// client/client.service.ts
|
|
6
|
-
import { merge as merge2 } from "@
|
|
6
|
+
import { merge as merge2 } from "@onlive.ai/common-121/utils/merge.js";
|
|
7
7
|
|
|
8
8
|
// tracking/tracking.service.ts
|
|
9
|
-
import { Session, Tracker } from "@onlive.
|
|
10
|
-
import { merge } from "@
|
|
11
|
-
import { browserPreferences } from "@
|
|
9
|
+
import { Session, Tracker } from "@onlive.ai/tracker";
|
|
10
|
+
import { merge } from "@onlive.ai/common-121/utils/merge.js";
|
|
11
|
+
import { browserPreferences } from "@onlive.ai/common-121/utils/browser-preferences.js";
|
|
12
12
|
|
|
13
13
|
// tracking/tracking.types.ts
|
|
14
14
|
import { z } from "zod";
|
|
@@ -214,12 +214,12 @@ var TrackingService = class {
|
|
|
214
214
|
var tracking_service_default = TrackingService;
|
|
215
215
|
|
|
216
216
|
// client/client.types.ts
|
|
217
|
-
import { GetAvailabilityFilters, GetAvailabilityOptions } from "@onlive.
|
|
217
|
+
import { GetAvailabilityFilters, GetAvailabilityOptions } from "@onlive.ai/calendar";
|
|
218
218
|
import { z as z2 } from "zod";
|
|
219
219
|
var DEFAULT_CLIENT_OPTIONS = {
|
|
220
220
|
tracking: {
|
|
221
221
|
removeExtraneousValues: true,
|
|
222
|
-
apiUrl: "https://srvless.onlive.
|
|
222
|
+
apiUrl: "https://srvless.onlive.ai/tracking",
|
|
223
223
|
data: {
|
|
224
224
|
widget_type: "OnliveAppFlow"
|
|
225
225
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlive.ai/flow-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"**/*.d.ts",
|
|
9
9
|
"**/*.d.cts",
|
|
10
10
|
"!./*.iife.js",
|
|
11
|
+
"!./*.schema-generator.*",
|
|
11
12
|
"!./node_modules/**"
|
|
12
13
|
],
|
|
13
14
|
"main": "./index.cjs",
|
|
@@ -22,7 +23,9 @@
|
|
|
22
23
|
"./client/*": "./client/*"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@onlive.
|
|
26
|
+
"@onlive.ai/calendar": "^0.0.7",
|
|
27
|
+
"@onlive.ai/tracker": "^1.0.9",
|
|
28
|
+
"@onlive.ai/common-121": "^0.2.32",
|
|
26
29
|
"@types/node": "^22.15.18",
|
|
27
30
|
"@vitest/coverage-v8": "^2.1.9",
|
|
28
31
|
"dotenv": "^16.5.0",
|
|
@@ -31,9 +34,7 @@
|
|
|
31
34
|
"typescript": "~5.6.3",
|
|
32
35
|
"vite": "^6.3.5",
|
|
33
36
|
"vitest": "^2.1.9",
|
|
34
|
-
"zod": "^3.24.4"
|
|
35
|
-
"@onlive.site/calendar": "0.0.6",
|
|
36
|
-
"@packages/common": "0.2.29"
|
|
37
|
+
"zod": "^3.24.4"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"zod-to-json-schema": "^3.24.5"
|
|
@@ -26,9 +26,9 @@ __export(tracking_service_exports, {
|
|
|
26
26
|
default: () => tracking_service_default
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(tracking_service_exports);
|
|
29
|
-
var import_tracker = require("@onlive.
|
|
30
|
-
var import_merge = require("@
|
|
31
|
-
var import_browser_preferences = require("@
|
|
29
|
+
var import_tracker = require("@onlive.ai/tracker");
|
|
30
|
+
var import_merge = require("@onlive.ai/common-121/utils/merge.js");
|
|
31
|
+
var import_browser_preferences = require("@onlive.ai/common-121/utils/browser-preferences.js");
|
|
32
32
|
|
|
33
33
|
// tracking/tracking.types.ts
|
|
34
34
|
var import_zod = require("zod");
|
|
@@ -3,9 +3,9 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
|
|
5
5
|
// tracking/tracking.service.ts
|
|
6
|
-
import { Session, Tracker } from "@onlive.
|
|
7
|
-
import { merge } from "@
|
|
8
|
-
import { browserPreferences } from "@
|
|
6
|
+
import { Session, Tracker } from "@onlive.ai/tracker";
|
|
7
|
+
import { merge } from "@onlive.ai/common-121/utils/merge.js";
|
|
8
|
+
import { browserPreferences } from "@onlive.ai/common-121/utils/browser-preferences.js";
|
|
9
9
|
|
|
10
10
|
// tracking/tracking.types.ts
|
|
11
11
|
import { z } from "zod";
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import '@onlive.site/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 };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import '@onlive.site/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 };
|