pingram 0.0.2-alpha.11 → 0.0.2-alpha.12
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 +3 -3
- package/dist/src/client.d.ts +10 -10
- package/dist/src/client.js +7 -7
- package/dist/src/index.d.ts +15 -20
- package/dist/src/index.js +16 -21
- package/dist/src/testing.d.ts +6 -6
- package/dist/src/testing.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,10 +20,10 @@ npm install pingram
|
|
|
20
20
|
Import and initialize the client:
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
import {
|
|
23
|
+
import { Pingram } from 'pingram';
|
|
24
24
|
|
|
25
25
|
// Server-side: Secret Key (Bearer token)
|
|
26
|
-
const apiClient = new
|
|
26
|
+
const apiClient = new Pingram({
|
|
27
27
|
apiKey: 'pingram_sk_...'
|
|
28
28
|
});
|
|
29
29
|
```
|
|
@@ -31,7 +31,7 @@ const apiClient = new NotificationAPIClient({
|
|
|
31
31
|
For connecting to Canada or EU regions, set the region option:
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
const apiClient = new
|
|
34
|
+
const apiClient = new Pingram({
|
|
35
35
|
apiKey: 'pingram_sk_...',
|
|
36
36
|
region: 'eu'
|
|
37
37
|
});
|
package/dist/src/client.d.ts
CHANGED
|
@@ -22,18 +22,18 @@ import { DefaultApi } from '../generated/src';
|
|
|
22
22
|
/**
|
|
23
23
|
* Supported Pingram regions
|
|
24
24
|
*/
|
|
25
|
-
export type
|
|
25
|
+
export type PingramRegion = 'us' | 'eu' | 'ca';
|
|
26
26
|
/**
|
|
27
27
|
* Configuration options for the Pingram client
|
|
28
28
|
*/
|
|
29
|
-
export interface
|
|
29
|
+
export interface PingramConfig {
|
|
30
30
|
/**
|
|
31
31
|
* API region (defaults to 'us')
|
|
32
32
|
* - 'us': api.pingram.io (default)
|
|
33
33
|
* - 'eu': api.eu.pingram.io
|
|
34
34
|
* - 'ca': api.ca.pingram.io
|
|
35
35
|
*/
|
|
36
|
-
region?:
|
|
36
|
+
region?: PingramRegion;
|
|
37
37
|
/**
|
|
38
38
|
* Base URL for the API (overrides region setting)
|
|
39
39
|
* Only use this if you need a custom endpoint
|
|
@@ -46,12 +46,12 @@ export interface NotificationAPIClientConfig {
|
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* // API Key authentication
|
|
49
|
-
* const client = new
|
|
49
|
+
* const client = new Pingram({
|
|
50
50
|
* apiKey: 'pingram_sk_...'
|
|
51
51
|
* });
|
|
52
52
|
*
|
|
53
53
|
* // JWT token authentication
|
|
54
|
-
* const client = new
|
|
54
|
+
* const client = new Pingram({
|
|
55
55
|
* apiKey: 'eyJraWQiOiJJM0tuNitTVnp5K0lzam9TeXVvYlJKcFpCcDd...'
|
|
56
56
|
* });
|
|
57
57
|
*/
|
|
@@ -73,18 +73,18 @@ export interface NotificationAPIClientConfig {
|
|
|
73
73
|
* @example
|
|
74
74
|
* ```typescript
|
|
75
75
|
* // Basic usage with default US region
|
|
76
|
-
* const client = new
|
|
76
|
+
* const client = new Pingram({
|
|
77
77
|
* apiKey: 'pingram_sk_...'
|
|
78
78
|
* });
|
|
79
79
|
*
|
|
80
80
|
* // With specific region
|
|
81
|
-
* const euClient = new
|
|
81
|
+
* const euClient = new Pingram({
|
|
82
82
|
* region: 'eu',
|
|
83
83
|
* apiKey: 'pingram_sk_...'
|
|
84
84
|
* });
|
|
85
85
|
*
|
|
86
86
|
* // With custom base URL
|
|
87
|
-
* const customClient = new
|
|
87
|
+
* const customClient = new Pingram({
|
|
88
88
|
* apiKey: 'pingram_sk_...',
|
|
89
89
|
* baseUrl: 'https://custom.api.example.com'
|
|
90
90
|
* });
|
|
@@ -96,7 +96,7 @@ export interface NotificationAPIClientConfig {
|
|
|
96
96
|
* });
|
|
97
97
|
* ```
|
|
98
98
|
*/
|
|
99
|
-
export declare class
|
|
99
|
+
export declare class Pingram {
|
|
100
100
|
private config;
|
|
101
101
|
account: AccountApi;
|
|
102
102
|
components: ComponentsApi;
|
|
@@ -114,7 +114,7 @@ export declare class NotificationAPIClient {
|
|
|
114
114
|
user: UserApi;
|
|
115
115
|
users: UsersApi;
|
|
116
116
|
private defaultApi;
|
|
117
|
-
constructor(config:
|
|
117
|
+
constructor(config: PingramConfig);
|
|
118
118
|
/**
|
|
119
119
|
* Update the base URL (overrides region)
|
|
120
120
|
*/
|
package/dist/src/client.js
CHANGED
|
@@ -8,7 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
11
|
+
exports.Pingram = void 0;
|
|
12
12
|
const src_1 = require("../generated/src");
|
|
13
13
|
// @ts-expect-error - Path is correct at runtime (from dist/src/), not during compilation
|
|
14
14
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
@@ -57,18 +57,18 @@ function buildAuthorizationHeader(apiKey) {
|
|
|
57
57
|
* @example
|
|
58
58
|
* ```typescript
|
|
59
59
|
* // Basic usage with default US region
|
|
60
|
-
* const client = new
|
|
60
|
+
* const client = new Pingram({
|
|
61
61
|
* apiKey: 'pingram_sk_...'
|
|
62
62
|
* });
|
|
63
63
|
*
|
|
64
64
|
* // With specific region
|
|
65
|
-
* const euClient = new
|
|
65
|
+
* const euClient = new Pingram({
|
|
66
66
|
* region: 'eu',
|
|
67
67
|
* apiKey: 'pingram_sk_...'
|
|
68
68
|
* });
|
|
69
69
|
*
|
|
70
70
|
* // With custom base URL
|
|
71
|
-
* const customClient = new
|
|
71
|
+
* const customClient = new Pingram({
|
|
72
72
|
* apiKey: 'pingram_sk_...',
|
|
73
73
|
* baseUrl: 'https://custom.api.example.com'
|
|
74
74
|
* });
|
|
@@ -80,13 +80,13 @@ function buildAuthorizationHeader(apiKey) {
|
|
|
80
80
|
* });
|
|
81
81
|
* ```
|
|
82
82
|
*/
|
|
83
|
-
class
|
|
83
|
+
class Pingram {
|
|
84
84
|
constructor(config) {
|
|
85
85
|
// Use explicit baseUrl if provided, otherwise derive from region
|
|
86
86
|
const baseUrl = config.baseUrl || getRegionBaseUrl(config.region);
|
|
87
87
|
// Validate that apiKey is provided
|
|
88
88
|
if (!config.apiKey) {
|
|
89
|
-
throw new Error('apiKey must be provided in
|
|
89
|
+
throw new Error('apiKey must be provided in PingramConfig');
|
|
90
90
|
}
|
|
91
91
|
// Auto-detect: if mock is set, use it!
|
|
92
92
|
let fetchApi = config.fetchApi;
|
|
@@ -155,4 +155,4 @@ class NotificationAPIClient {
|
|
|
155
155
|
return this.defaultApi.send(requestParameters);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
exports.
|
|
158
|
+
exports.Pingram = Pingram;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -18,32 +18,27 @@
|
|
|
18
18
|
* ## Usage
|
|
19
19
|
*
|
|
20
20
|
* ```typescript
|
|
21
|
-
* import {
|
|
21
|
+
* import { Pingram } from 'pingram';
|
|
22
22
|
*
|
|
23
|
-
* //
|
|
24
|
-
* const client =
|
|
25
|
-
*
|
|
26
|
-
* // Client-side: End User
|
|
27
|
-
* const client = NotificationAPIClient.withEndUser('clientId', 'userId');
|
|
28
|
-
*
|
|
29
|
-
* // Get a user
|
|
30
|
-
* const user = await client.users.usersGet({
|
|
31
|
-
* accountId: 'abc123',
|
|
32
|
-
* userId: 'user456'
|
|
23
|
+
* // Initialize with API key
|
|
24
|
+
* const client = new Pingram({
|
|
25
|
+
* apiKey: 'pingram_sk_...'
|
|
33
26
|
* });
|
|
34
27
|
*
|
|
35
|
-
* //
|
|
36
|
-
* const
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
28
|
+
* // Get a user
|
|
29
|
+
* const user = await client.user.getUser('user456');
|
|
30
|
+
*
|
|
31
|
+
* // Send a notification
|
|
32
|
+
* await client.send({
|
|
33
|
+
* type: 'welcome_email',
|
|
34
|
+
* to: {
|
|
35
|
+
* id: 'user456',
|
|
36
|
+
* email: 'user@example.com'
|
|
42
37
|
* }
|
|
43
38
|
* });
|
|
44
39
|
* ```
|
|
45
40
|
*/
|
|
46
|
-
export {
|
|
47
|
-
export {
|
|
41
|
+
export { Pingram, PingramConfig, PingramRegion } from './client';
|
|
42
|
+
export { PingramMock } from './testing';
|
|
48
43
|
export * from '../generated/src/models';
|
|
49
44
|
export * from '../generated/src/apis';
|
package/dist/src/index.js
CHANGED
|
@@ -19,27 +19,22 @@
|
|
|
19
19
|
* ## Usage
|
|
20
20
|
*
|
|
21
21
|
* ```typescript
|
|
22
|
-
* import {
|
|
22
|
+
* import { Pingram } from 'pingram';
|
|
23
23
|
*
|
|
24
|
-
* //
|
|
25
|
-
* const client =
|
|
26
|
-
*
|
|
27
|
-
* // Client-side: End User
|
|
28
|
-
* const client = NotificationAPIClient.withEndUser('clientId', 'userId');
|
|
29
|
-
*
|
|
30
|
-
* // Get a user
|
|
31
|
-
* const user = await client.users.usersGet({
|
|
32
|
-
* accountId: 'abc123',
|
|
33
|
-
* userId: 'user456'
|
|
24
|
+
* // Initialize with API key
|
|
25
|
+
* const client = new Pingram({
|
|
26
|
+
* apiKey: 'pingram_sk_...'
|
|
34
27
|
* });
|
|
35
28
|
*
|
|
36
|
-
* //
|
|
37
|
-
* const
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
29
|
+
* // Get a user
|
|
30
|
+
* const user = await client.user.getUser('user456');
|
|
31
|
+
*
|
|
32
|
+
* // Send a notification
|
|
33
|
+
* await client.send({
|
|
34
|
+
* type: 'welcome_email',
|
|
35
|
+
* to: {
|
|
36
|
+
* id: 'user456',
|
|
37
|
+
* email: 'user@example.com'
|
|
43
38
|
* }
|
|
44
39
|
* });
|
|
45
40
|
* ```
|
|
@@ -59,10 +54,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
59
54
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
60
55
|
};
|
|
61
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.
|
|
57
|
+
exports.PingramMock = exports.Pingram = void 0;
|
|
63
58
|
var client_1 = require("./client");
|
|
64
|
-
Object.defineProperty(exports, "
|
|
59
|
+
Object.defineProperty(exports, "Pingram", { enumerable: true, get: function () { return client_1.Pingram; } });
|
|
65
60
|
var testing_1 = require("./testing");
|
|
66
|
-
Object.defineProperty(exports, "
|
|
61
|
+
Object.defineProperty(exports, "PingramMock", { enumerable: true, get: function () { return testing_1.PingramMock; } });
|
|
67
62
|
__exportStar(require("../generated/src/models"), exports);
|
|
68
63
|
__exportStar(require("../generated/src/apis"), exports);
|
package/dist/src/testing.d.ts
CHANGED
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
|
-
* import {
|
|
8
|
+
* import { Pingram, PingramMock } from 'pingram';
|
|
9
9
|
*
|
|
10
10
|
* // Mock all SDK requests
|
|
11
|
-
*
|
|
11
|
+
* PingramMock.mock((request) => {
|
|
12
12
|
* expect(request.body.name).toBe('Test');
|
|
13
13
|
* return { id: 'key123', name: 'Test' };
|
|
14
14
|
* });
|
|
15
15
|
*
|
|
16
|
-
* const client = new
|
|
16
|
+
* const client = new Pingram({ apiKey: 'test' });
|
|
17
17
|
* await client.keys.createAPIKey(...);
|
|
18
18
|
*
|
|
19
19
|
* // Clear mocks
|
|
20
|
-
*
|
|
20
|
+
* PingramMock.clearMock();
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export type MockRequest = {
|
|
@@ -33,13 +33,13 @@ export type MockImplementation = (request: MockRequest) => any | Promise<any>;
|
|
|
33
33
|
* Pingram Testing utilities
|
|
34
34
|
* Jest-style API for mocking SDK behavior
|
|
35
35
|
*/
|
|
36
|
-
export declare const
|
|
36
|
+
export declare const PingramMock: {
|
|
37
37
|
/**
|
|
38
38
|
* Set mock implementation for all SDK requests
|
|
39
39
|
* Similar to jest.fn().mockImplementation()
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
|
-
*
|
|
42
|
+
* PingramMock.mock((request) => {
|
|
43
43
|
* expect(request.body.name).toBe('Test');
|
|
44
44
|
* return { id: 'key123' };
|
|
45
45
|
* });
|
package/dist/src/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.PingramMock = void 0;
|
|
5
5
|
exports.getMockImplementation = getMockImplementation;
|
|
6
6
|
exports.hasMock = hasMock;
|
|
7
7
|
exports.createMockFetch = createMockFetch;
|
|
@@ -10,13 +10,13 @@ let mockImplementation = null;
|
|
|
10
10
|
* Pingram Testing utilities
|
|
11
11
|
* Jest-style API for mocking SDK behavior
|
|
12
12
|
*/
|
|
13
|
-
exports.
|
|
13
|
+
exports.PingramMock = {
|
|
14
14
|
/**
|
|
15
15
|
* Set mock implementation for all SDK requests
|
|
16
16
|
* Similar to jest.fn().mockImplementation()
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
|
-
*
|
|
19
|
+
* PingramMock.mock((request) => {
|
|
20
20
|
* expect(request.body.name).toBe('Test');
|
|
21
21
|
* return { id: 'key123' };
|
|
22
22
|
* });
|
package/package.json
CHANGED