activitysmith 0.1.1 → 0.1.2
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 +79 -25
- package/dist/src/ActivitySmith.d.ts +29 -2
- package/dist/src/ActivitySmith.js +53 -3
- package/package.json +21 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# ActivitySmith Node
|
|
1
|
+
# ActivitySmith Node SDK
|
|
2
2
|
|
|
3
|
-
The ActivitySmith Node
|
|
3
|
+
The ActivitySmith Node SDK provides convenient access to the ActivitySmith API from server-side JavaScript and TypeScript applications.
|
|
4
4
|
|
|
5
5
|
## Documentation
|
|
6
6
|
|
|
@@ -12,50 +12,104 @@ See [API reference](https://activitysmith.com/docs/api-reference/introduction)
|
|
|
12
12
|
npm install activitysmith
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
ESM:
|
|
15
|
+
## Setup
|
|
18
16
|
|
|
19
17
|
```ts
|
|
20
18
|
import ActivitySmith from "activitysmith";
|
|
21
19
|
|
|
22
|
-
const
|
|
20
|
+
const activitysmith = new ActivitySmith({
|
|
23
21
|
apiKey: process.env.ACTIVITYSMITH_API_KEY,
|
|
24
22
|
});
|
|
23
|
+
```
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
CommonJS:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
const ActivitySmith = require("activitysmith");
|
|
29
|
+
|
|
30
|
+
const activitysmith = new ActivitySmith({
|
|
31
|
+
apiKey: process.env.ACTIVITYSMITH_API_KEY,
|
|
31
32
|
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### Send a Push Notification
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
const response = await activitysmith.notifications.send({
|
|
41
|
+
title: "Build Failed",
|
|
42
|
+
message: "CI pipeline failed on main branch",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
console.log(response.success);
|
|
46
|
+
console.log(response.devices_notified);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Start a Live Activity
|
|
32
50
|
|
|
33
|
-
|
|
34
|
-
await
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
```ts
|
|
52
|
+
const start = await activitysmith.liveActivities.start({
|
|
53
|
+
content_state: {
|
|
54
|
+
title: "ActivitySmith API Deployment",
|
|
55
|
+
subtitle: "start",
|
|
56
|
+
number_of_steps: 4,
|
|
57
|
+
current_step: 1,
|
|
58
|
+
type: "segmented_progress",
|
|
59
|
+
color: "yellow",
|
|
37
60
|
},
|
|
38
61
|
});
|
|
62
|
+
|
|
63
|
+
const activityId = start.activity_id;
|
|
39
64
|
```
|
|
40
65
|
|
|
41
|
-
|
|
66
|
+
### Update a Live Activity
|
|
42
67
|
|
|
43
|
-
```
|
|
44
|
-
const
|
|
68
|
+
```ts
|
|
69
|
+
const update = await activitysmith.liveActivities.update({
|
|
70
|
+
activity_id: activityId,
|
|
71
|
+
content_state: {
|
|
72
|
+
title: "ActivitySmith API Deployment",
|
|
73
|
+
subtitle: "npm i & pm2",
|
|
74
|
+
current_step: 3,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
45
77
|
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
console.log(update.devices_notified);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### End a Live Activity
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const end = await activitysmith.liveActivities.end({
|
|
85
|
+
activity_id: activityId,
|
|
86
|
+
content_state: {
|
|
87
|
+
title: "ActivitySmith API Deployment",
|
|
88
|
+
subtitle: "done",
|
|
89
|
+
current_step: 4,
|
|
90
|
+
auto_dismiss_minutes: 3,
|
|
91
|
+
},
|
|
48
92
|
});
|
|
93
|
+
|
|
94
|
+
console.log(end.success);
|
|
49
95
|
```
|
|
50
96
|
|
|
51
|
-
##
|
|
97
|
+
## Error Handling
|
|
52
98
|
|
|
53
|
-
|
|
99
|
+
```ts
|
|
100
|
+
try {
|
|
101
|
+
await activitysmith.notifications.send({
|
|
102
|
+
title: "Build Failed",
|
|
103
|
+
});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error(error);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
54
108
|
|
|
55
|
-
|
|
56
|
-
- `client.notifications`
|
|
109
|
+
## API Surface
|
|
57
110
|
|
|
58
|
-
|
|
111
|
+
- `activitysmith.notifications`
|
|
112
|
+
- `activitysmith.liveActivities`
|
|
59
113
|
|
|
60
114
|
## TypeScript Support
|
|
61
115
|
|
|
@@ -2,8 +2,35 @@ import { PushNotificationsApi, LiveActivitiesApi } from "../generated/index";
|
|
|
2
2
|
export interface ActivitySmithOptions {
|
|
3
3
|
apiKey: string;
|
|
4
4
|
}
|
|
5
|
+
type PushRequestBody = Parameters<PushNotificationsApi["sendPushNotification"]>[0]["pushNotificationRequest"];
|
|
6
|
+
type SendInitOverrides = Parameters<PushNotificationsApi["sendPushNotification"]>[1];
|
|
7
|
+
type StartRequestBody = Parameters<LiveActivitiesApi["startLiveActivity"]>[0]["liveActivityStartRequest"];
|
|
8
|
+
type UpdateRequestBody = Parameters<LiveActivitiesApi["updateLiveActivity"]>[0]["liveActivityUpdateRequest"];
|
|
9
|
+
type EndRequestBody = Parameters<LiveActivitiesApi["endLiveActivity"]>[0]["liveActivityEndRequest"];
|
|
10
|
+
type LiveInitOverrides = Parameters<LiveActivitiesApi["startLiveActivity"]>[1];
|
|
11
|
+
export declare class NotificationsResource {
|
|
12
|
+
private readonly api;
|
|
13
|
+
constructor(api: PushNotificationsApi);
|
|
14
|
+
send(request: PushRequestBody, initOverrides?: SendInitOverrides): Promise<import("../generated/models").PushNotificationResponse>;
|
|
15
|
+
sendPushNotification(...args: Parameters<PushNotificationsApi["sendPushNotification"]>): Promise<import("../generated/models").PushNotificationResponse>;
|
|
16
|
+
sendPushNotificationRaw(...args: Parameters<PushNotificationsApi["sendPushNotificationRaw"]>): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").PushNotificationResponse>>;
|
|
17
|
+
}
|
|
18
|
+
export declare class LiveActivitiesResource {
|
|
19
|
+
private readonly api;
|
|
20
|
+
constructor(api: LiveActivitiesApi);
|
|
21
|
+
start(request: StartRequestBody, initOverrides?: LiveInitOverrides): Promise<import("../generated/models").LiveActivityStartResponse>;
|
|
22
|
+
update(request: UpdateRequestBody, initOverrides?: LiveInitOverrides): Promise<import("../generated/models").LiveActivityUpdateResponse>;
|
|
23
|
+
end(request: EndRequestBody, initOverrides?: LiveInitOverrides): Promise<import("../generated/models").LiveActivityEndResponse>;
|
|
24
|
+
startLiveActivity(...args: Parameters<LiveActivitiesApi["startLiveActivity"]>): Promise<import("../generated/models").LiveActivityStartResponse>;
|
|
25
|
+
updateLiveActivity(...args: Parameters<LiveActivitiesApi["updateLiveActivity"]>): Promise<import("../generated/models").LiveActivityUpdateResponse>;
|
|
26
|
+
endLiveActivity(...args: Parameters<LiveActivitiesApi["endLiveActivity"]>): Promise<import("../generated/models").LiveActivityEndResponse>;
|
|
27
|
+
startLiveActivityRaw(...args: Parameters<LiveActivitiesApi["startLiveActivityRaw"]>): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").LiveActivityStartResponse>>;
|
|
28
|
+
updateLiveActivityRaw(...args: Parameters<LiveActivitiesApi["updateLiveActivityRaw"]>): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").LiveActivityUpdateResponse>>;
|
|
29
|
+
endLiveActivityRaw(...args: Parameters<LiveActivitiesApi["endLiveActivityRaw"]>): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").LiveActivityEndResponse>>;
|
|
30
|
+
}
|
|
5
31
|
export declare class ActivitySmith {
|
|
6
|
-
readonly notifications:
|
|
7
|
-
readonly liveActivities:
|
|
32
|
+
readonly notifications: NotificationsResource;
|
|
33
|
+
readonly liveActivities: LiveActivitiesResource;
|
|
8
34
|
constructor(opts: ActivitySmithOptions);
|
|
9
35
|
}
|
|
36
|
+
export {};
|
|
@@ -1,7 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActivitySmith = void 0;
|
|
3
|
+
exports.ActivitySmith = exports.LiveActivitiesResource = exports.NotificationsResource = void 0;
|
|
4
4
|
const index_1 = require("../generated/index");
|
|
5
|
+
class NotificationsResource {
|
|
6
|
+
constructor(api) {
|
|
7
|
+
this.api = api;
|
|
8
|
+
}
|
|
9
|
+
send(request, initOverrides) {
|
|
10
|
+
return this.api.sendPushNotification({ pushNotificationRequest: request }, initOverrides);
|
|
11
|
+
}
|
|
12
|
+
// Backward-compatible alias.
|
|
13
|
+
sendPushNotification(...args) {
|
|
14
|
+
return this.api.sendPushNotification(...args);
|
|
15
|
+
}
|
|
16
|
+
sendPushNotificationRaw(...args) {
|
|
17
|
+
return this.api.sendPushNotificationRaw(...args);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.NotificationsResource = NotificationsResource;
|
|
21
|
+
class LiveActivitiesResource {
|
|
22
|
+
constructor(api) {
|
|
23
|
+
this.api = api;
|
|
24
|
+
}
|
|
25
|
+
start(request, initOverrides) {
|
|
26
|
+
return this.api.startLiveActivity({ liveActivityStartRequest: request }, initOverrides);
|
|
27
|
+
}
|
|
28
|
+
update(request, initOverrides) {
|
|
29
|
+
return this.api.updateLiveActivity({ liveActivityUpdateRequest: request }, initOverrides);
|
|
30
|
+
}
|
|
31
|
+
end(request, initOverrides) {
|
|
32
|
+
return this.api.endLiveActivity({ liveActivityEndRequest: request }, initOverrides);
|
|
33
|
+
}
|
|
34
|
+
// Backward-compatible aliases.
|
|
35
|
+
startLiveActivity(...args) {
|
|
36
|
+
return this.api.startLiveActivity(...args);
|
|
37
|
+
}
|
|
38
|
+
updateLiveActivity(...args) {
|
|
39
|
+
return this.api.updateLiveActivity(...args);
|
|
40
|
+
}
|
|
41
|
+
endLiveActivity(...args) {
|
|
42
|
+
return this.api.endLiveActivity(...args);
|
|
43
|
+
}
|
|
44
|
+
startLiveActivityRaw(...args) {
|
|
45
|
+
return this.api.startLiveActivityRaw(...args);
|
|
46
|
+
}
|
|
47
|
+
updateLiveActivityRaw(...args) {
|
|
48
|
+
return this.api.updateLiveActivityRaw(...args);
|
|
49
|
+
}
|
|
50
|
+
endLiveActivityRaw(...args) {
|
|
51
|
+
return this.api.endLiveActivityRaw(...args);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.LiveActivitiesResource = LiveActivitiesResource;
|
|
5
55
|
class ActivitySmith {
|
|
6
56
|
constructor(opts) {
|
|
7
57
|
if (!opts?.apiKey) {
|
|
@@ -11,8 +61,8 @@ class ActivitySmith {
|
|
|
11
61
|
const config = new index_1.Configuration({
|
|
12
62
|
accessToken: opts.apiKey,
|
|
13
63
|
});
|
|
14
|
-
this.notifications = new index_1.PushNotificationsApi(config);
|
|
15
|
-
this.liveActivities = new index_1.LiveActivitiesApi(config);
|
|
64
|
+
this.notifications = new NotificationsResource(new index_1.PushNotificationsApi(config));
|
|
65
|
+
this.liveActivities = new LiveActivitiesResource(new index_1.LiveActivitiesApi(config));
|
|
16
66
|
}
|
|
17
67
|
}
|
|
18
68
|
exports.ActivitySmith = ActivitySmith;
|
package/package.json
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activitysmith",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Official ActivitySmith Node.js SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"activitysmith",
|
|
7
|
-
"live
|
|
8
|
-
"push
|
|
9
|
-
"api"
|
|
7
|
+
"live-activities",
|
|
8
|
+
"push-notifications",
|
|
9
|
+
"api",
|
|
10
|
+
"sdk",
|
|
11
|
+
"deployment",
|
|
12
|
+
"publishing",
|
|
13
|
+
"monitoring",
|
|
14
|
+
"observability",
|
|
15
|
+
"logging",
|
|
16
|
+
"logs",
|
|
17
|
+
"automation",
|
|
18
|
+
"tracking",
|
|
19
|
+
"reporting"
|
|
10
20
|
],
|
|
11
|
-
"
|
|
21
|
+
"author": "ActivitySmith",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/ActivitySmithHQ/activitysmith-node.git"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://activitysmith.com/docs/sdks/node",
|
|
12
28
|
"main": "dist/src/index.js",
|
|
13
29
|
"types": "dist/src/index.d.ts",
|
|
14
30
|
"exports": {
|
|
@@ -24,7 +40,6 @@
|
|
|
24
40
|
"README.md",
|
|
25
41
|
"LICENSE"
|
|
26
42
|
],
|
|
27
|
-
"license": "MIT",
|
|
28
43
|
"engines": {
|
|
29
44
|
"node": ">=18"
|
|
30
45
|
},
|