@usehercules/sdk 1.4.0 → 1.6.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +11 -3
  3. package/client.d.mts +3 -0
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +3 -0
  6. package/client.d.ts.map +1 -1
  7. package/client.js +3 -0
  8. package/client.js.map +1 -1
  9. package/client.mjs +3 -0
  10. package/client.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/resources/index.d.mts +1 -0
  13. package/resources/index.d.mts.map +1 -1
  14. package/resources/index.d.ts +1 -0
  15. package/resources/index.d.ts.map +1 -1
  16. package/resources/index.js +3 -1
  17. package/resources/index.js.map +1 -1
  18. package/resources/index.mjs +1 -0
  19. package/resources/index.mjs.map +1 -1
  20. package/resources/push-notifications/index.d.mts +4 -0
  21. package/resources/push-notifications/index.d.mts.map +1 -0
  22. package/resources/push-notifications/index.d.ts +4 -0
  23. package/resources/push-notifications/index.d.ts.map +1 -0
  24. package/resources/push-notifications/index.js +11 -0
  25. package/resources/push-notifications/index.js.map +1 -0
  26. package/resources/push-notifications/index.mjs +5 -0
  27. package/resources/push-notifications/index.mjs.map +1 -0
  28. package/resources/push-notifications/push-notifications.d.mts +88 -0
  29. package/resources/push-notifications/push-notifications.d.mts.map +1 -0
  30. package/resources/push-notifications/push-notifications.d.ts +88 -0
  31. package/resources/push-notifications/push-notifications.d.ts.map +1 -0
  32. package/resources/push-notifications/push-notifications.js +37 -0
  33. package/resources/push-notifications/push-notifications.js.map +1 -0
  34. package/resources/push-notifications/push-notifications.mjs +32 -0
  35. package/resources/push-notifications/push-notifications.mjs.map +1 -0
  36. package/resources/push-notifications/subscriptions.d.mts +74 -0
  37. package/resources/push-notifications/subscriptions.d.mts.map +1 -0
  38. package/resources/push-notifications/subscriptions.d.ts +74 -0
  39. package/resources/push-notifications/subscriptions.d.ts.map +1 -0
  40. package/resources/push-notifications/subscriptions.js +23 -0
  41. package/resources/push-notifications/subscriptions.js.map +1 -0
  42. package/resources/push-notifications/subscriptions.mjs +19 -0
  43. package/resources/push-notifications/subscriptions.mjs.map +1 -0
  44. package/resources/push-notifications/topics.d.mts +75 -0
  45. package/resources/push-notifications/topics.d.mts.map +1 -0
  46. package/resources/push-notifications/topics.d.ts +75 -0
  47. package/resources/push-notifications/topics.d.ts.map +1 -0
  48. package/resources/push-notifications/topics.js +28 -0
  49. package/resources/push-notifications/topics.js.map +1 -0
  50. package/resources/push-notifications/topics.mjs +24 -0
  51. package/resources/push-notifications/topics.mjs.map +1 -0
  52. package/resources/push-notifications.d.mts +2 -0
  53. package/resources/push-notifications.d.mts.map +1 -0
  54. package/resources/push-notifications.d.ts +2 -0
  55. package/resources/push-notifications.d.ts.map +1 -0
  56. package/resources/push-notifications.js +6 -0
  57. package/resources/push-notifications.js.map +1 -0
  58. package/resources/push-notifications.mjs +3 -0
  59. package/resources/push-notifications.mjs.map +1 -0
  60. package/src/client.ts +15 -0
  61. package/src/resources/index.ts +6 -0
  62. package/src/resources/push-notifications/index.ts +23 -0
  63. package/src/resources/push-notifications/push-notifications.ts +141 -0
  64. package/src/resources/push-notifications/subscriptions.ts +96 -0
  65. package/src/resources/push-notifications/topics.ts +101 -0
  66. package/src/resources/push-notifications.ts +3 -0
  67. package/src/version.ts +1 -1
  68. package/version.d.mts +1 -1
  69. package/version.d.ts +1 -1
  70. package/version.js +1 -1
  71. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -19,6 +19,12 @@ import * as Uploads from './core/uploads';
19
19
  import * as API from './resources/index';
20
20
  import { APIPromise } from './core/api-promise';
21
21
  import { Beta } from './resources/beta/beta';
22
+ import {
23
+ PushNotificationEnableResponse,
24
+ PushNotificationSendParams,
25
+ PushNotificationSendResponse,
26
+ PushNotifications,
27
+ } from './resources/push-notifications/push-notifications';
22
28
  import { type Fetch } from './internal/builtin-types';
23
29
  import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
24
30
  import { FinalRequestOptions, RequestOptions } from './internal/request-options';
@@ -754,9 +760,11 @@ export class Hercules {
754
760
  static toFile = Uploads.toFile;
755
761
 
756
762
  beta: API.Beta = new API.Beta(this);
763
+ pushNotifications: API.PushNotifications = new API.PushNotifications(this);
757
764
  }
758
765
 
759
766
  Hercules.Beta = Beta;
767
+ Hercules.PushNotifications = PushNotifications;
760
768
 
761
769
  export declare namespace Hercules {
762
770
  export type RequestOptions = Opts.RequestOptions;
@@ -765,4 +773,11 @@ export declare namespace Hercules {
765
773
  export { type CursorIDPageParams as CursorIDPageParams, type CursorIDPageResponse as CursorIDPageResponse };
766
774
 
767
775
  export { Beta as Beta };
776
+
777
+ export {
778
+ PushNotifications as PushNotifications,
779
+ type PushNotificationEnableResponse as PushNotificationEnableResponse,
780
+ type PushNotificationSendResponse as PushNotificationSendResponse,
781
+ type PushNotificationSendParams as PushNotificationSendParams,
782
+ };
768
783
  }
@@ -1,3 +1,9 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  export { Beta } from './beta/beta';
4
+ export {
5
+ PushNotifications,
6
+ type PushNotificationEnableResponse,
7
+ type PushNotificationSendResponse,
8
+ type PushNotificationSendParams,
9
+ } from './push-notifications/push-notifications';
@@ -0,0 +1,23 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ PushNotifications,
5
+ type PushNotificationEnableResponse,
6
+ type PushNotificationSendResponse,
7
+ type PushNotificationSendParams,
8
+ } from './push-notifications';
9
+ export {
10
+ Subscriptions,
11
+ type SubscriptionCreateResponse,
12
+ type SubscriptionDeleteResponse,
13
+ type SubscriptionCreateParams,
14
+ } from './subscriptions';
15
+ export {
16
+ Topics,
17
+ type TopicListResponse,
18
+ type TopicSubscribeResponse,
19
+ type TopicUnsubscribeResponse,
20
+ type TopicListParams,
21
+ type TopicSubscribeParams,
22
+ type TopicUnsubscribeParams,
23
+ } from './topics';
@@ -0,0 +1,141 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as SubscriptionsAPI from './subscriptions';
5
+ import {
6
+ SubscriptionCreateParams,
7
+ SubscriptionCreateResponse,
8
+ SubscriptionDeleteResponse,
9
+ Subscriptions,
10
+ } from './subscriptions';
11
+ import * as TopicsAPI from './topics';
12
+ import {
13
+ TopicListParams,
14
+ TopicListResponse,
15
+ TopicSubscribeParams,
16
+ TopicSubscribeResponse,
17
+ TopicUnsubscribeParams,
18
+ TopicUnsubscribeResponse,
19
+ Topics,
20
+ } from './topics';
21
+ import { APIPromise } from '../../core/api-promise';
22
+ import { RequestOptions } from '../../internal/request-options';
23
+
24
+ export class PushNotifications extends APIResource {
25
+ subscriptions: SubscriptionsAPI.Subscriptions = new SubscriptionsAPI.Subscriptions(this._client);
26
+ topics: TopicsAPI.Topics = new TopicsAPI.Topics(this._client);
27
+
28
+ /**
29
+ * Enables push notifications for the app by generating VAPID keys. Idempotent -
30
+ * returns existing keys if already enabled. Hercules recommends calling this
31
+ * during app initialization.
32
+ */
33
+ enable(options?: RequestOptions): APIPromise<PushNotificationEnableResponse> {
34
+ return this._client.post('/v1/push-notifications/enable', options);
35
+ }
36
+
37
+ /**
38
+ * Sends push notifications to specified visitors and/or topics. Specify
39
+ * visitorIds, topics, or both (combined as union). Omit both to broadcast to all
40
+ * subscribers.
41
+ */
42
+ send(body: PushNotificationSendParams, options?: RequestOptions): APIPromise<PushNotificationSendResponse> {
43
+ return this._client.post('/v1/push-notifications/send', { body, ...options });
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Response containing the VAPID public key for push subscriptions.
49
+ */
50
+ export interface PushNotificationEnableResponse {
51
+ /**
52
+ * VAPID public key for push subscription (base64url encoded)
53
+ */
54
+ vapidPublicKey: string;
55
+ }
56
+
57
+ /**
58
+ * Result of the send operation with success and failure counts.
59
+ */
60
+ export interface PushNotificationSendResponse {
61
+ /**
62
+ * Number of notifications that failed to send
63
+ */
64
+ failed: number;
65
+
66
+ /**
67
+ * Number of notifications successfully sent
68
+ */
69
+ sent: number;
70
+ }
71
+
72
+ export interface PushNotificationSendParams {
73
+ /**
74
+ * Notification title
75
+ */
76
+ title: string;
77
+
78
+ /**
79
+ * Badge URL for mobile devices
80
+ */
81
+ badge?: string;
82
+
83
+ /**
84
+ * Notification body text
85
+ */
86
+ body?: string;
87
+
88
+ /**
89
+ * Custom data payload to include with the notification
90
+ */
91
+ data?: { [key: string]: unknown };
92
+
93
+ /**
94
+ * Icon URL (small icon displayed in the notification)
95
+ */
96
+ icon?: string;
97
+
98
+ /**
99
+ * Image URL (larger image displayed in the notification body)
100
+ */
101
+ image?: string;
102
+
103
+ /**
104
+ * Topics to send to. All visitors subscribed to any of these topics will receive
105
+ * the notification. Combined with visitorIds as a union.
106
+ */
107
+ topics?: Array<string>;
108
+
109
+ /**
110
+ * Visitor IDs to send to. Combined with topics as a union.
111
+ */
112
+ visitorIds?: Array<string>;
113
+ }
114
+
115
+ PushNotifications.Subscriptions = Subscriptions;
116
+ PushNotifications.Topics = Topics;
117
+
118
+ export declare namespace PushNotifications {
119
+ export {
120
+ type PushNotificationEnableResponse as PushNotificationEnableResponse,
121
+ type PushNotificationSendResponse as PushNotificationSendResponse,
122
+ type PushNotificationSendParams as PushNotificationSendParams,
123
+ };
124
+
125
+ export {
126
+ Subscriptions as Subscriptions,
127
+ type SubscriptionCreateResponse as SubscriptionCreateResponse,
128
+ type SubscriptionDeleteResponse as SubscriptionDeleteResponse,
129
+ type SubscriptionCreateParams as SubscriptionCreateParams,
130
+ };
131
+
132
+ export {
133
+ Topics as Topics,
134
+ type TopicListResponse as TopicListResponse,
135
+ type TopicSubscribeResponse as TopicSubscribeResponse,
136
+ type TopicUnsubscribeResponse as TopicUnsubscribeResponse,
137
+ type TopicListParams as TopicListParams,
138
+ type TopicSubscribeParams as TopicSubscribeParams,
139
+ type TopicUnsubscribeParams as TopicUnsubscribeParams,
140
+ };
141
+ }
@@ -0,0 +1,96 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { RequestOptions } from '../../internal/request-options';
6
+ import { path } from '../../internal/utils/path';
7
+
8
+ export class Subscriptions extends APIResource {
9
+ /**
10
+ * Registers a push subscription for a visitor. Upserts by endpoint to handle
11
+ * re-subscriptions gracefully.
12
+ */
13
+ create(body: SubscriptionCreateParams, options?: RequestOptions): APIPromise<SubscriptionCreateResponse> {
14
+ return this._client.post('/v1/push-notifications/subscriptions', { body, ...options });
15
+ }
16
+
17
+ /**
18
+ * Removes a push subscription by ID.
19
+ */
20
+ delete(id: string, options?: RequestOptions): APIPromise<SubscriptionDeleteResponse> {
21
+ return this._client.delete(path`/v1/push-notifications/subscriptions/${id}`, options);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * The created or updated subscription.
27
+ */
28
+ export interface SubscriptionCreateResponse {
29
+ /**
30
+ * Subscription ID
31
+ */
32
+ id: string;
33
+ }
34
+
35
+ /**
36
+ * Result of the unsubscribe operation.
37
+ */
38
+ export interface SubscriptionDeleteResponse {
39
+ /**
40
+ * Whether the subscription was removed
41
+ */
42
+ success: boolean;
43
+ }
44
+
45
+ export interface SubscriptionCreateParams {
46
+ /**
47
+ * Web Push subscription object from pushManager.subscribe()
48
+ */
49
+ subscription: SubscriptionCreateParams.Subscription;
50
+
51
+ /**
52
+ * Unique identifier for the subscriber (e.g., userId)
53
+ */
54
+ visitorId: string;
55
+ }
56
+
57
+ export namespace SubscriptionCreateParams {
58
+ /**
59
+ * Web Push subscription object from pushManager.subscribe()
60
+ */
61
+ export interface Subscription {
62
+ /**
63
+ * Push service endpoint URL
64
+ */
65
+ endpoint: string;
66
+
67
+ keys: Subscription.Keys;
68
+
69
+ /**
70
+ * Subscription expiration timestamp
71
+ */
72
+ expirationTime?: number | null;
73
+ }
74
+
75
+ export namespace Subscription {
76
+ export interface Keys {
77
+ /**
78
+ * Authentication secret (base64url encoded)
79
+ */
80
+ auth: string;
81
+
82
+ /**
83
+ * P-256 Diffie-Hellman public key (base64url encoded)
84
+ */
85
+ p256dh: string;
86
+ }
87
+ }
88
+ }
89
+
90
+ export declare namespace Subscriptions {
91
+ export {
92
+ type SubscriptionCreateResponse as SubscriptionCreateResponse,
93
+ type SubscriptionDeleteResponse as SubscriptionDeleteResponse,
94
+ type SubscriptionCreateParams as SubscriptionCreateParams,
95
+ };
96
+ }
@@ -0,0 +1,101 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { RequestOptions } from '../../internal/request-options';
6
+
7
+ export class Topics extends APIResource {
8
+ /**
9
+ * Lists all topics a visitor is subscribed to.
10
+ */
11
+ list(query: TopicListParams, options?: RequestOptions): APIPromise<TopicListResponse> {
12
+ return this._client.get('/v1/push-notifications/topics', { query, ...options });
13
+ }
14
+
15
+ /**
16
+ * Subscribes a visitor to topics. Topics are per-visitor, so all devices for this
17
+ * visitor will receive notifications sent to these topics.
18
+ */
19
+ subscribe(body: TopicSubscribeParams, options?: RequestOptions): APIPromise<TopicSubscribeResponse> {
20
+ return this._client.post('/v1/push-notifications/topics/subscribe', { body, ...options });
21
+ }
22
+
23
+ /**
24
+ * Unsubscribes a visitor from specified topics.
25
+ */
26
+ unsubscribe(body: TopicUnsubscribeParams, options?: RequestOptions): APIPromise<TopicUnsubscribeResponse> {
27
+ return this._client.post('/v1/push-notifications/topics/unsubscribe', { body, ...options });
28
+ }
29
+ }
30
+
31
+ /**
32
+ * List of topics the visitor is subscribed to.
33
+ */
34
+ export interface TopicListResponse {
35
+ /**
36
+ * Topics the visitor is subscribed to
37
+ */
38
+ topics: Array<string>;
39
+ }
40
+
41
+ /**
42
+ * The visitor's updated topic subscriptions.
43
+ */
44
+ export interface TopicSubscribeResponse {
45
+ /**
46
+ * Topics the visitor is now subscribed to
47
+ */
48
+ topics: Array<string>;
49
+ }
50
+
51
+ /**
52
+ * The visitor's remaining topic subscriptions after unsubscribing.
53
+ */
54
+ export interface TopicUnsubscribeResponse {
55
+ /**
56
+ * Topics the visitor is still subscribed to
57
+ */
58
+ topics: Array<string>;
59
+ }
60
+
61
+ export interface TopicListParams {
62
+ /**
63
+ * Visitor ID to list topics for
64
+ */
65
+ visitorId: string;
66
+ }
67
+
68
+ export interface TopicSubscribeParams {
69
+ /**
70
+ * Topic names to subscribe to (e.g., 'announcements', 'channel:general')
71
+ */
72
+ topics: Array<string>;
73
+
74
+ /**
75
+ * Visitor ID to subscribe to topics
76
+ */
77
+ visitorId: string;
78
+ }
79
+
80
+ export interface TopicUnsubscribeParams {
81
+ /**
82
+ * Topic names to unsubscribe from
83
+ */
84
+ topics: Array<string>;
85
+
86
+ /**
87
+ * Visitor ID to unsubscribe from topics
88
+ */
89
+ visitorId: string;
90
+ }
91
+
92
+ export declare namespace Topics {
93
+ export {
94
+ type TopicListResponse as TopicListResponse,
95
+ type TopicSubscribeResponse as TopicSubscribeResponse,
96
+ type TopicUnsubscribeResponse as TopicUnsubscribeResponse,
97
+ type TopicListParams as TopicListParams,
98
+ type TopicSubscribeParams as TopicSubscribeParams,
99
+ type TopicUnsubscribeParams as TopicUnsubscribeParams,
100
+ };
101
+ }
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './push-notifications/index';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.4.0'; // x-release-please-version
1
+ export const VERSION = '1.6.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.4.0";
1
+ export declare const VERSION = "1.6.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.4.0";
1
+ export declare const VERSION = "1.6.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '1.4.0'; // x-release-please-version
4
+ exports.VERSION = '1.6.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.4.0'; // x-release-please-version
1
+ export const VERSION = '1.6.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map