@flowripple/sdk 1.0.1 → 3.0.0
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 +22 -20
- package/dist/index.d.mts +8 -10
- package/dist/index.d.ts +8 -10
- package/dist/index.js +10 -16
- package/dist/index.mjs +10 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @flowripple/sdk
|
|
2
2
|
|
|
3
|
-
The official Node.js SDK for Flowripple - a
|
|
3
|
+
The official Node.js SDK for Flowripple - a visual workflow automation platform.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -16,30 +16,35 @@ Or using yarn:
|
|
|
16
16
|
yarn add @flowripple/sdk
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
Or using pnpm:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @flowripple/sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
19
25
|
## Usage
|
|
20
26
|
|
|
21
|
-
First, import and initialize the FlowrippleClient with your API
|
|
27
|
+
First, import and initialize the FlowrippleClient with your API key:
|
|
22
28
|
|
|
23
29
|
```typescript
|
|
24
30
|
import { FlowrippleClient } from '@flowripple/sdk';
|
|
25
31
|
|
|
26
32
|
const client = new FlowrippleClient({
|
|
27
|
-
|
|
28
|
-
apiKey: 'YOUR_API_KEY'
|
|
33
|
+
apiKey: 'frp_your-api-key'
|
|
29
34
|
});
|
|
30
35
|
```
|
|
31
36
|
|
|
32
|
-
Then use the client to
|
|
37
|
+
Then use the client to trigger workflow events:
|
|
33
38
|
|
|
34
39
|
```typescript
|
|
35
|
-
//
|
|
36
|
-
await client.
|
|
40
|
+
// Trigger a simple event
|
|
41
|
+
await client.trigger('user.signup', {
|
|
37
42
|
userId: '123',
|
|
38
43
|
email: 'user@example.com'
|
|
39
44
|
});
|
|
40
45
|
|
|
41
|
-
//
|
|
42
|
-
await client.
|
|
46
|
+
// Trigger an event with custom data
|
|
47
|
+
await client.trigger('order.completed', {
|
|
43
48
|
orderId: 'ord_123',
|
|
44
49
|
amount: 99.99,
|
|
45
50
|
currency: 'USD',
|
|
@@ -59,20 +64,18 @@ The `FlowrippleClient` constructor accepts a configuration object with the follo
|
|
|
59
64
|
|
|
60
65
|
| Option | Type | Required | Default | Description |
|
|
61
66
|
|--------|------|----------|---------|-------------|
|
|
62
|
-
| `
|
|
63
|
-
| `apiKey` | string | Yes | - | Your Flowripple API Key |
|
|
67
|
+
| `apiKey` | string | Yes | - | Your Flowripple API Key (starts with `frp_`) |
|
|
64
68
|
| `baseUrl` | string | No | 'https://api.flowripple.com' | Custom API base URL |
|
|
65
69
|
| `silent` | boolean | No | false | If true, failed API calls return false instead of throwing errors |
|
|
66
|
-
| `version` | 'v1' | No | 'v1' | API version to use |
|
|
67
70
|
|
|
68
71
|
#### Methods
|
|
69
72
|
|
|
70
|
-
##### `
|
|
73
|
+
##### `trigger(identifier: string, data?: Record<string, any>): Promise<false | void>`
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
Triggers a workflow by sending an event to the Flowripple API.
|
|
73
76
|
|
|
74
|
-
- `
|
|
75
|
-
- `
|
|
77
|
+
- `identifier`: The event identifier to trigger (e.g., 'user.signup', 'order.completed')
|
|
78
|
+
- `data`: Optional object containing the event data
|
|
76
79
|
- Returns: A promise that resolves to `void` on success, or `false` if the request fails and silent mode is enabled
|
|
77
80
|
- Throws: An error if the request fails and silent mode is not enabled
|
|
78
81
|
|
|
@@ -82,15 +85,14 @@ By default, the SDK will throw errors when API requests fail. You can enable sil
|
|
|
82
85
|
|
|
83
86
|
```typescript
|
|
84
87
|
const client = new FlowrippleClient({
|
|
85
|
-
|
|
86
|
-
apiKey: 'YOUR_API_KEY',
|
|
88
|
+
apiKey: 'frp_your-api-key',
|
|
87
89
|
silent: true
|
|
88
90
|
});
|
|
89
91
|
|
|
90
92
|
// This will return false instead of throwing if the request fails
|
|
91
|
-
const result = await client.
|
|
93
|
+
const result = await client.trigger('user.signup', { userId: '123' });
|
|
92
94
|
if (result === false) {
|
|
93
|
-
console.log('Event
|
|
95
|
+
console.log('Event trigger failed');
|
|
94
96
|
}
|
|
95
97
|
```
|
|
96
98
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* Configuration options for initializing the FlowrippleClient
|
|
3
3
|
*/
|
|
4
4
|
interface FlowrippleClientOptions {
|
|
5
|
-
/** (Required) Flowripple
|
|
6
|
-
apiClientId: number;
|
|
7
|
-
/** (Required) API key for authentication with Flowripple */
|
|
5
|
+
/** (Required) API key for authentication with Flowripple (starts with frp_) */
|
|
8
6
|
apiKey: string;
|
|
9
7
|
/** (Optional) Base URL for the Flowripple API. Defaults to https://api.flowripple.com */
|
|
10
8
|
baseUrl?: string;
|
|
@@ -19,10 +17,10 @@ interface FlowrippleClientOptions {
|
|
|
19
17
|
* @example
|
|
20
18
|
* ```typescript
|
|
21
19
|
* const client = new FlowrippleClient({
|
|
22
|
-
* apiKey: '
|
|
20
|
+
* apiKey: 'frp_your-api-key'
|
|
23
21
|
* });
|
|
24
22
|
*
|
|
25
|
-
* await client.
|
|
23
|
+
* await client.trigger('user.signup', {
|
|
26
24
|
* userId: '123',
|
|
27
25
|
* email: 'user@example.com'
|
|
28
26
|
* });
|
|
@@ -37,14 +35,14 @@ declare class FlowrippleClient {
|
|
|
37
35
|
*/
|
|
38
36
|
constructor(options: FlowrippleClientOptions);
|
|
39
37
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @returns Promise that resolves to
|
|
38
|
+
* Triggers a workflow by sending an event to the Flowripple API
|
|
39
|
+
* @param identifier - The event identifier to trigger
|
|
40
|
+
* @param data - Optional data payload associated with the event
|
|
41
|
+
* @returns Promise that resolves to void on success,
|
|
44
42
|
* or false if silent mode is enabled and the request failed
|
|
45
43
|
* @throws {Error} If the request fails and silent mode is not enabled
|
|
46
44
|
*/
|
|
47
|
-
|
|
45
|
+
trigger(identifier: string, data?: Record<string, any>): Promise<false | void>;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
export { FlowrippleClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* Configuration options for initializing the FlowrippleClient
|
|
3
3
|
*/
|
|
4
4
|
interface FlowrippleClientOptions {
|
|
5
|
-
/** (Required) Flowripple
|
|
6
|
-
apiClientId: number;
|
|
7
|
-
/** (Required) API key for authentication with Flowripple */
|
|
5
|
+
/** (Required) API key for authentication with Flowripple (starts with frp_) */
|
|
8
6
|
apiKey: string;
|
|
9
7
|
/** (Optional) Base URL for the Flowripple API. Defaults to https://api.flowripple.com */
|
|
10
8
|
baseUrl?: string;
|
|
@@ -19,10 +17,10 @@ interface FlowrippleClientOptions {
|
|
|
19
17
|
* @example
|
|
20
18
|
* ```typescript
|
|
21
19
|
* const client = new FlowrippleClient({
|
|
22
|
-
* apiKey: '
|
|
20
|
+
* apiKey: 'frp_your-api-key'
|
|
23
21
|
* });
|
|
24
22
|
*
|
|
25
|
-
* await client.
|
|
23
|
+
* await client.trigger('user.signup', {
|
|
26
24
|
* userId: '123',
|
|
27
25
|
* email: 'user@example.com'
|
|
28
26
|
* });
|
|
@@ -37,14 +35,14 @@ declare class FlowrippleClient {
|
|
|
37
35
|
*/
|
|
38
36
|
constructor(options: FlowrippleClientOptions);
|
|
39
37
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @returns Promise that resolves to
|
|
38
|
+
* Triggers a workflow by sending an event to the Flowripple API
|
|
39
|
+
* @param identifier - The event identifier to trigger
|
|
40
|
+
* @param data - Optional data payload associated with the event
|
|
41
|
+
* @returns Promise that resolves to void on success,
|
|
44
42
|
* or false if silent mode is enabled and the request failed
|
|
45
43
|
* @throws {Error} If the request fails and silent mode is not enabled
|
|
46
44
|
*/
|
|
47
|
-
|
|
45
|
+
trigger(identifier: string, data?: Record<string, any>): Promise<false | void>;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
export { FlowrippleClient };
|
package/dist/index.js
CHANGED
|
@@ -54,7 +54,6 @@ __export(index_exports, {
|
|
|
54
54
|
});
|
|
55
55
|
module.exports = __toCommonJS(index_exports);
|
|
56
56
|
var import_axios = __toESM(require("axios"));
|
|
57
|
-
var import_crypto = __toESM(require("crypto"));
|
|
58
57
|
var FlowrippleClient = class {
|
|
59
58
|
/**
|
|
60
59
|
* Creates a new FlowrippleClient instance
|
|
@@ -65,31 +64,26 @@ var FlowrippleClient = class {
|
|
|
65
64
|
this.baseUrl = options.baseUrl || "https://api.flowripple.com";
|
|
66
65
|
}
|
|
67
66
|
/**
|
|
68
|
-
*
|
|
69
|
-
* @param
|
|
70
|
-
* @param
|
|
71
|
-
* @returns Promise that resolves to
|
|
67
|
+
* Triggers a workflow by sending an event to the Flowripple API
|
|
68
|
+
* @param identifier - The event identifier to trigger
|
|
69
|
+
* @param data - Optional data payload associated with the event
|
|
70
|
+
* @returns Promise that resolves to void on success,
|
|
72
71
|
* or false if silent mode is enabled and the request failed
|
|
73
72
|
* @throws {Error} If the request fails and silent mode is not enabled
|
|
74
73
|
*/
|
|
75
|
-
|
|
74
|
+
trigger(identifier, data) {
|
|
76
75
|
return __async(this, null, function* () {
|
|
77
76
|
var _a, _b;
|
|
78
77
|
try {
|
|
79
78
|
const body = {
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
identifier,
|
|
80
|
+
data: data || {}
|
|
82
81
|
};
|
|
83
|
-
const
|
|
84
|
-
const stringToSign = timestamp + JSON.stringify(body);
|
|
85
|
-
const hmac = import_crypto.default.createHmac("sha256", this.options.apiKey).update(stringToSign).digest("hex");
|
|
86
|
-
const url = `${this.baseUrl.replace(/^\/+/, "")}/sdk/${(_a = this.options.version) != null ? _a : "v1"}/capture`;
|
|
82
|
+
const url = `${this.baseUrl.replace(/\/+$/, "")}/api/${(_a = this.options.version) != null ? _a : "v1"}/trigger`;
|
|
87
83
|
yield import_axios.default.post(url, body, {
|
|
88
84
|
headers: {
|
|
89
85
|
"Content-Type": "application/json",
|
|
90
|
-
"
|
|
91
|
-
"X-Flowripple-Signature": hmac,
|
|
92
|
-
"X-Flowripple-Timestamp": timestamp
|
|
86
|
+
"x-api-key": this.options.apiKey
|
|
93
87
|
}
|
|
94
88
|
});
|
|
95
89
|
return;
|
|
@@ -98,7 +92,7 @@ var FlowrippleClient = class {
|
|
|
98
92
|
return false;
|
|
99
93
|
}
|
|
100
94
|
throw new Error(
|
|
101
|
-
`Failed to
|
|
95
|
+
`Failed to trigger event: ${(_b = error == null ? void 0 : error.message) != null ? _b : error}`
|
|
102
96
|
);
|
|
103
97
|
}
|
|
104
98
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
21
21
|
|
|
22
22
|
// src/index.ts
|
|
23
23
|
import axios from "axios";
|
|
24
|
-
import crypto from "crypto";
|
|
25
24
|
var FlowrippleClient = class {
|
|
26
25
|
/**
|
|
27
26
|
* Creates a new FlowrippleClient instance
|
|
@@ -32,31 +31,26 @@ var FlowrippleClient = class {
|
|
|
32
31
|
this.baseUrl = options.baseUrl || "https://api.flowripple.com";
|
|
33
32
|
}
|
|
34
33
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @returns Promise that resolves to
|
|
34
|
+
* Triggers a workflow by sending an event to the Flowripple API
|
|
35
|
+
* @param identifier - The event identifier to trigger
|
|
36
|
+
* @param data - Optional data payload associated with the event
|
|
37
|
+
* @returns Promise that resolves to void on success,
|
|
39
38
|
* or false if silent mode is enabled and the request failed
|
|
40
39
|
* @throws {Error} If the request fails and silent mode is not enabled
|
|
41
40
|
*/
|
|
42
|
-
|
|
41
|
+
trigger(identifier, data) {
|
|
43
42
|
return __async(this, null, function* () {
|
|
44
43
|
var _a, _b;
|
|
45
44
|
try {
|
|
46
45
|
const body = {
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
identifier,
|
|
47
|
+
data: data || {}
|
|
49
48
|
};
|
|
50
|
-
const
|
|
51
|
-
const stringToSign = timestamp + JSON.stringify(body);
|
|
52
|
-
const hmac = crypto.createHmac("sha256", this.options.apiKey).update(stringToSign).digest("hex");
|
|
53
|
-
const url = `${this.baseUrl.replace(/^\/+/, "")}/sdk/${(_a = this.options.version) != null ? _a : "v1"}/capture`;
|
|
49
|
+
const url = `${this.baseUrl.replace(/\/+$/, "")}/api/${(_a = this.options.version) != null ? _a : "v1"}/trigger`;
|
|
54
50
|
yield axios.post(url, body, {
|
|
55
51
|
headers: {
|
|
56
52
|
"Content-Type": "application/json",
|
|
57
|
-
"
|
|
58
|
-
"X-Flowripple-Signature": hmac,
|
|
59
|
-
"X-Flowripple-Timestamp": timestamp
|
|
53
|
+
"x-api-key": this.options.apiKey
|
|
60
54
|
}
|
|
61
55
|
});
|
|
62
56
|
return;
|
|
@@ -65,7 +59,7 @@ var FlowrippleClient = class {
|
|
|
65
59
|
return false;
|
|
66
60
|
}
|
|
67
61
|
throw new Error(
|
|
68
|
-
`Failed to
|
|
62
|
+
`Failed to trigger event: ${(_b = error == null ? void 0 : error.message) != null ? _b : error}`
|
|
69
63
|
);
|
|
70
64
|
}
|
|
71
65
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowripple/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "FlowRipple SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
39
39
|
"test": "jest",
|
|
40
|
-
"ci:publish": "pnpm
|
|
40
|
+
"ci:publish": "pnpm build && changeset publish --access public"
|
|
41
41
|
}
|
|
42
42
|
}
|