@notificationapi/node 0.0.2-alpha.7 → 0.0.2-alpha.9
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/dist/generated/src/apis/MembersApi.d.ts +180 -0
- package/dist/generated/src/apis/MembersApi.js +408 -0
- package/dist/generated/src/apis/index.d.ts +1 -0
- package/dist/generated/src/apis/index.js +1 -0
- package/dist/generated/src/models/AutoJoinGetResponse.d.ts +38 -0
- package/dist/generated/src/models/AutoJoinGetResponse.js +54 -0
- package/dist/generated/src/models/AutoJoinPostResponse.d.ts +38 -0
- package/dist/generated/src/models/AutoJoinPostResponse.js +54 -0
- package/dist/generated/src/models/AutoJoinRequestBody.d.ts +32 -0
- package/dist/generated/src/models/AutoJoinRequestBody.js +50 -0
- package/dist/generated/src/models/GetMembersResponseInner.d.ts +56 -0
- package/dist/generated/src/models/GetMembersResponseInner.js +62 -0
- package/dist/generated/src/models/InvitePostResponse.d.ts +38 -0
- package/dist/generated/src/models/InvitePostResponse.js +50 -0
- package/dist/generated/src/models/MemberInviteRequest.d.ts +38 -0
- package/dist/generated/src/models/MemberInviteRequest.js +52 -0
- package/dist/generated/src/models/MemberUpdateRequest.d.ts +32 -0
- package/dist/generated/src/models/MemberUpdateRequest.js +50 -0
- package/dist/generated/src/models/index.d.ts +7 -0
- package/dist/generated/src/models/index.js +7 -0
- package/dist/src/client.d.ts +19 -4
- package/dist/src/client.js +31 -23
- package/dist/src/testing.js +3 -1
- package/package.json +1 -1
package/dist/src/client.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { HealthApi } from '../generated/src';
|
|
|
12
12
|
import { InsightsApi } from '../generated/src';
|
|
13
13
|
import { KeysApi } from '../generated/src';
|
|
14
14
|
import { LogsApi } from '../generated/src';
|
|
15
|
+
import { MembersApi } from '../generated/src';
|
|
15
16
|
import { SenderApi } from '../generated/src';
|
|
16
17
|
import { TemplatesApi } from '../generated/src';
|
|
17
18
|
import { TypesApi } from '../generated/src';
|
|
@@ -28,9 +29,9 @@ export type NotificationAPIRegion = 'us' | 'eu' | 'ca';
|
|
|
28
29
|
export interface NotificationAPIClientConfig {
|
|
29
30
|
/**
|
|
30
31
|
* API region (defaults to 'us')
|
|
31
|
-
* - 'us': api.
|
|
32
|
-
* - 'eu': api.eu.
|
|
33
|
-
* - 'ca': api.ca.
|
|
32
|
+
* - 'us': api.pingram.io (default)
|
|
33
|
+
* - 'eu': api.eu.pingram.io
|
|
34
|
+
* - 'ca': api.ca.pingram.io
|
|
34
35
|
*/
|
|
35
36
|
region?: NotificationAPIRegion;
|
|
36
37
|
/**
|
|
@@ -39,7 +40,20 @@ export interface NotificationAPIClientConfig {
|
|
|
39
40
|
*/
|
|
40
41
|
baseUrl?: string;
|
|
41
42
|
/**
|
|
42
|
-
* API Key
|
|
43
|
+
* API Key or JWT Token - Required. Can be either:
|
|
44
|
+
* - A string starting with 'pingram_sk_' for server-side API key authentication
|
|
45
|
+
* - A JWT token string (any other string) for JWT authentication
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // API Key authentication
|
|
49
|
+
* const client = new NotificationAPIClient({
|
|
50
|
+
* apiKey: 'pingram_sk_...'
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // JWT token authentication
|
|
54
|
+
* const client = new NotificationAPIClient({
|
|
55
|
+
* apiKey: 'eyJraWQiOiJJM0tuNitTVnp5K0lzam9TeXVvYlJKcFpCcDd...'
|
|
56
|
+
* });
|
|
43
57
|
*/
|
|
44
58
|
apiKey: string;
|
|
45
59
|
/**
|
|
@@ -93,6 +107,7 @@ export declare class NotificationAPIClient {
|
|
|
93
107
|
insights: InsightsApi;
|
|
94
108
|
keys: KeysApi;
|
|
95
109
|
logs: LogsApi;
|
|
110
|
+
members: MembersApi;
|
|
96
111
|
sender: SenderApi;
|
|
97
112
|
templates: TemplatesApi;
|
|
98
113
|
types: TypesApi;
|
package/dist/src/client.js
CHANGED
|
@@ -30,15 +30,16 @@ const src_13 = require("../generated/src");
|
|
|
30
30
|
const src_14 = require("../generated/src");
|
|
31
31
|
const src_15 = require("../generated/src");
|
|
32
32
|
const src_16 = require("../generated/src");
|
|
33
|
+
const src_17 = require("../generated/src");
|
|
33
34
|
const testing_1 = require("./testing");
|
|
34
35
|
/**
|
|
35
36
|
* Get the base URL for a given region
|
|
36
37
|
*/
|
|
37
38
|
function getRegionBaseUrl(region = 'us') {
|
|
38
39
|
const regionUrls = {
|
|
39
|
-
us: 'https://api.
|
|
40
|
-
eu: 'https://api.eu.
|
|
41
|
-
ca: 'https://api.ca.
|
|
40
|
+
us: 'https://api.pingram.io',
|
|
41
|
+
eu: 'https://api.eu.pingram.io',
|
|
42
|
+
ca: 'https://api.ca.pingram.io'
|
|
42
43
|
};
|
|
43
44
|
return regionUrls[region];
|
|
44
45
|
}
|
|
@@ -83,21 +84,26 @@ class NotificationAPIClient {
|
|
|
83
84
|
constructor(config) {
|
|
84
85
|
// Use explicit baseUrl if provided, otherwise derive from region
|
|
85
86
|
const baseUrl = config.baseUrl || getRegionBaseUrl(config.region);
|
|
86
|
-
//
|
|
87
|
-
|
|
87
|
+
// Validate that apiKey is provided
|
|
88
|
+
if (!config.apiKey) {
|
|
89
|
+
throw new Error('apiKey must be provided in NotificationAPIClientConfig');
|
|
90
|
+
}
|
|
88
91
|
// Auto-detect: if mock is set, use it!
|
|
89
92
|
let fetchApi = config.fetchApi;
|
|
90
93
|
if (!fetchApi && (0, testing_1.hasMock)()) {
|
|
91
94
|
fetchApi = (0, testing_1.createMockFetch)();
|
|
92
95
|
}
|
|
96
|
+
// Build headers
|
|
97
|
+
// Both API keys and JWT tokens use the same Bearer token format
|
|
98
|
+
const headers = {
|
|
99
|
+
'Content-Type': 'application/json',
|
|
100
|
+
'User-Agent': USER_AGENT,
|
|
101
|
+
Authorization: buildAuthorizationHeader(config.apiKey),
|
|
102
|
+
...config.headers
|
|
103
|
+
};
|
|
93
104
|
this.config = new src_1.Configuration({
|
|
94
105
|
basePath: baseUrl,
|
|
95
|
-
headers
|
|
96
|
-
Authorization: authHeader,
|
|
97
|
-
'Content-Type': 'application/json',
|
|
98
|
-
'User-Agent': USER_AGENT,
|
|
99
|
-
...config.headers
|
|
100
|
-
},
|
|
106
|
+
headers,
|
|
101
107
|
fetchApi: fetchApi
|
|
102
108
|
});
|
|
103
109
|
this.account = new src_2.AccountApi(this.config);
|
|
@@ -109,12 +115,13 @@ class NotificationAPIClient {
|
|
|
109
115
|
this.insights = new src_8.InsightsApi(this.config);
|
|
110
116
|
this.keys = new src_9.KeysApi(this.config);
|
|
111
117
|
this.logs = new src_10.LogsApi(this.config);
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
114
|
-
this.
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
117
|
-
this.
|
|
118
|
+
this.members = new src_11.MembersApi(this.config);
|
|
119
|
+
this.sender = new src_12.SenderApi(this.config);
|
|
120
|
+
this.templates = new src_13.TemplatesApi(this.config);
|
|
121
|
+
this.types = new src_14.TypesApi(this.config);
|
|
122
|
+
this.user = new src_15.UserApi(this.config);
|
|
123
|
+
this.users = new src_16.UsersApi(this.config);
|
|
124
|
+
this.defaultApi = new src_17.DefaultApi(this.config);
|
|
118
125
|
}
|
|
119
126
|
/**
|
|
120
127
|
* Update the base URL (overrides region)
|
|
@@ -133,12 +140,13 @@ class NotificationAPIClient {
|
|
|
133
140
|
this.insights = new src_8.InsightsApi(this.config);
|
|
134
141
|
this.keys = new src_9.KeysApi(this.config);
|
|
135
142
|
this.logs = new src_10.LogsApi(this.config);
|
|
136
|
-
this.
|
|
137
|
-
this.
|
|
138
|
-
this.
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
143
|
+
this.members = new src_11.MembersApi(this.config);
|
|
144
|
+
this.sender = new src_12.SenderApi(this.config);
|
|
145
|
+
this.templates = new src_13.TemplatesApi(this.config);
|
|
146
|
+
this.types = new src_14.TypesApi(this.config);
|
|
147
|
+
this.user = new src_15.UserApi(this.config);
|
|
148
|
+
this.users = new src_16.UsersApi(this.config);
|
|
149
|
+
this.defaultApi = new src_17.DefaultApi(this.config);
|
|
142
150
|
}
|
|
143
151
|
/**
|
|
144
152
|
* send
|
package/dist/src/testing.js
CHANGED
|
@@ -114,7 +114,9 @@ function createMockFetch() {
|
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
catch (error) {
|
|
117
|
-
|
|
117
|
+
// Pass through the full error body if available, otherwise create one from message
|
|
118
|
+
const errorBody = error.body || { error: error.message };
|
|
119
|
+
return new Response(JSON.stringify(errorBody), {
|
|
118
120
|
status: error.statusCode || 500,
|
|
119
121
|
headers: { 'Content-Type': 'application/json' }
|
|
120
122
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notificationapi/node",
|
|
3
|
-
"version": "0.0.2-alpha.
|
|
3
|
+
"version": "0.0.2-alpha.9",
|
|
4
4
|
"description": "Official Node.js SDK for NotificationAPI - Send notifications via Email, SMS, Push, In-App, and more",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|