@thisispamela/sdk 1.0.4 → 1.1.1

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 CHANGED
@@ -40,8 +40,11 @@ console.log('Call status:', status.status);
40
40
 
41
41
  ### Webhook Verification
42
42
 
43
+ **Note:** Webhook functions are only available in Node.js environments (not browsers). Import from the `/webhooks` subpath:
44
+
43
45
  ```typescript
44
46
  import { PamelaClient } from '@thisispamela/sdk';
47
+ import { verifyWebhookSignature, parseToolWebhook } from '@thisispamela/sdk/webhooks';
45
48
  import express from 'express';
46
49
 
47
50
  const app = express();
@@ -51,7 +54,7 @@ app.post('/webhooks/pamela', express.json(), (req, res) => {
51
54
  const signature = req.headers['x-pamela-signature'] as string;
52
55
  const payload = req.body;
53
56
 
54
- if (!PamelaClient.verifyWebhookSignature(payload, signature, WEBHOOK_SECRET)) {
57
+ if (!verifyWebhookSignature(payload, signature, WEBHOOK_SECRET)) {
55
58
  return res.status(401).send('Invalid signature');
56
59
  }
57
60
 
@@ -63,6 +66,10 @@ app.post('/webhooks/pamela', express.json(), (req, res) => {
63
66
  });
64
67
  ```
65
68
 
69
+ **Available webhook functions:**
70
+ - `verifyWebhookSignature(payload, signature, secret)` - Verify webhook signature
71
+ - `parseToolWebhook(payload)` - Parse tool execution webhook payload
72
+
66
73
  ## Getting API Keys
67
74
 
68
75
  ### Obtaining Your API Key
@@ -297,6 +304,23 @@ console.log(`Quota: ${usage.quota?.partner_limit || 'Unlimited'}`);
297
304
 
298
305
  **Note:** Enterprise subscriptions have no quota limits - all usage is billed per-minute.
299
306
 
307
+ ## Browser Compatibility
308
+
309
+ The main SDK package (`@thisispamela/sdk`) is **browser-compatible**. Webhook verification functions (which use Node.js `crypto`) are available via the `/webhooks` subpath:
310
+
311
+ ```typescript
312
+ // Browser - main SDK works
313
+ import { PamelaClient } from '@thisispamela/sdk';
314
+
315
+ // Node.js only - webhook verification
316
+ import { verifyWebhookSignature } from '@thisispamela/sdk/webhooks';
317
+ ```
318
+
319
+ **Subpath exports:**
320
+ - `@thisispamela/sdk/webhooks` - Webhook verification (Node.js only)
321
+ - `@thisispamela/sdk/types` - TypeScript types
322
+ - `@thisispamela/sdk/errors` - Error classes
323
+
300
324
  ## API Reference
301
325
 
302
326
  See the [Pamela Enterprise API Documentation](https://docs.thisispamela.com/enterprise) for full API reference.
@@ -0,0 +1,50 @@
1
+ // src/errors.ts
2
+ var PamelaError = class extends Error {
3
+ constructor(message, options) {
4
+ super(message);
5
+ this.name = "PamelaError";
6
+ this.errorCode = options?.errorCode;
7
+ this.details = options?.details;
8
+ this.statusCode = options?.statusCode;
9
+ }
10
+ };
11
+ var AuthenticationError = class extends PamelaError {
12
+ constructor(message, options) {
13
+ super(message, options);
14
+ this.name = "AuthenticationError";
15
+ }
16
+ };
17
+ var SubscriptionError = class extends PamelaError {
18
+ constructor(message, options) {
19
+ super(message, options);
20
+ this.name = "SubscriptionError";
21
+ }
22
+ };
23
+ var RateLimitError = class extends PamelaError {
24
+ constructor(message, options) {
25
+ super(message, options);
26
+ this.name = "RateLimitError";
27
+ }
28
+ };
29
+ var ValidationError = class extends PamelaError {
30
+ constructor(message, options) {
31
+ super(message, options);
32
+ this.name = "ValidationError";
33
+ }
34
+ };
35
+ var CallError = class extends PamelaError {
36
+ constructor(message, options) {
37
+ super(message, options);
38
+ this.name = "CallError";
39
+ }
40
+ };
41
+
42
+ export {
43
+ PamelaError,
44
+ AuthenticationError,
45
+ SubscriptionError,
46
+ RateLimitError,
47
+ ValidationError,
48
+ CallError
49
+ };
50
+ //# sourceMappingURL=chunk-NQIPPPEL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["export class PamelaError extends Error {\n public errorCode?: number;\n public details?: Record<string, any>;\n public statusCode?: number;\n\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message);\n this.name = 'PamelaError';\n this.errorCode = options?.errorCode;\n this.details = options?.details;\n this.statusCode = options?.statusCode;\n }\n}\n\nexport class AuthenticationError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class SubscriptionError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'SubscriptionError';\n }\n}\n\nexport class RateLimitError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'RateLimitError';\n }\n}\n\nexport class ValidationError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'ValidationError';\n }\n}\n\nexport class CallError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'CallError';\n }\n}\n"],"mappings":";AAAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAKrC,YAAY,SAAiB,SAAsF;AACjH,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY,SAAS;AAC1B,SAAK,UAAU,SAAS;AACxB,SAAK,aAAa,SAAS;AAAA,EAC7B;AACF;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,oBAAN,cAAgC,YAAY;AAAA,EACjD,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,YAAY;AAAA,EAC9C,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,YAAN,cAAwB,YAAY;AAAA,EACzC,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
@@ -0,0 +1,50 @@
1
+ // src/types.ts
2
+ var ErrorCodes = {
3
+ // Auth errors (1000-1999)
4
+ AUTH_REQUIRED: 1001,
5
+ AUTH_INVALID: 1002,
6
+ AUTH_EXPIRED: 1003,
7
+ AUTH_INSUFFICIENT_PERMISSIONS: 1004,
8
+ AUTH_FORBIDDEN: 1005,
9
+ // Validation errors (2000-2999)
10
+ VALIDATION_ERROR: 2001,
11
+ INVALID_PHONE: 2002,
12
+ INVALID_EMAIL: 2003,
13
+ INVALID_PASSWORD: 2004,
14
+ MISSING_REQUIRED_FIELD: 2005,
15
+ INVALID_JSON: 2006,
16
+ INVALID_REQUEST_BODY: 2007,
17
+ // Not found errors (3000-3999)
18
+ NOT_FOUND: 3001,
19
+ USER_NOT_FOUND: 3002,
20
+ CONVERSATION_NOT_FOUND: 3003,
21
+ CALL_SESSION_NOT_FOUND: 3004,
22
+ RESOURCE_NOT_FOUND: 3005,
23
+ MESSAGE_NOT_FOUND: 3006,
24
+ // Conflict errors (4000-4999)
25
+ RESOURCE_ALREADY_EXISTS: 4001,
26
+ EMAIL_ALREADY_REGISTERED: 4002,
27
+ ACCOUNT_LINKING_REQUIRED: 4003,
28
+ // Server errors (5000-5999)
29
+ INTERNAL_ERROR: 5001,
30
+ EXTERNAL_SERVICE_ERROR: 5002,
31
+ DATABASE_ERROR: 5003,
32
+ CONFIGURATION_ERROR: 5004,
33
+ // Rate limiting (6000-6999)
34
+ RATE_LIMIT_EXCEEDED: 6001,
35
+ QUOTA_EXCEEDED: 6002,
36
+ // B2B errors (7000-7999)
37
+ B2B_PARTNER_NOT_FOUND: 7001,
38
+ B2B_PROJECT_NOT_FOUND: 7002,
39
+ B2B_CALL_NOT_FOUND: 7003,
40
+ B2B_NO_PHONE_NUMBER: 7004,
41
+ B2B_UNSUPPORTED_COUNTRY: 7005,
42
+ B2B_TOOL_EXECUTION_FAILED: 7006,
43
+ B2B_WEBHOOK_DELIVERY_FAILED: 7007,
44
+ SUBSCRIPTION_EXPIRED: 7008
45
+ };
46
+
47
+ export {
48
+ ErrorCodes
49
+ };
50
+ //# sourceMappingURL=chunk-WMXO6YYV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["export interface PamelaClientConfig {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport interface CreateCallRequest {\n to: string;\n country?: string;\n locale?: string;\n task: string;\n instructions?: string;\n max_duration_seconds?: number;\n voice?: 'male' | 'female' | 'auto';\n agent_name?: string;\n caller_name?: string;\n end_user_id?: string;\n metadata?: Record<string, any>;\n tools?: Array<Record<string, any>>;\n webhooks?: {\n webhook_url?: string;\n tool_webhook_url?: string;\n };\n}\n\nexport type CallStatusValue =\n | 'initiating'\n | 'queued'\n | 'ringing'\n | 'in_progress'\n | 'completed'\n | 'failed'\n | 'cancelled'\n | 'timeout_terminated'\n | 'in-progress';\n\nexport interface CallResponse {\n id: string;\n status: CallStatusValue | string;\n call_session_id: string;\n created_at: string;\n}\n\nexport interface CallStatus {\n id: string;\n status: CallStatusValue | string;\n to: string;\n from_: string; // Backend uses from_ (Python keyword)\n country: string;\n created_at: string;\n started_at?: string;\n completed_at?: string;\n duration_seconds?: number;\n max_duration_seconds?: number;\n transcript?: Array<Record<string, any>>;\n summary?: string;\n metadata: Record<string, any>;\n end_user_id?: string; // Marketplace end-user ID for privacy isolation\n}\n\nexport interface ToolDefinition {\n name: string;\n description: string;\n input_schema: Record<string, any>;\n output_schema?: Record<string, any>;\n timeout_ms?: number;\n}\n\nexport interface WebhookPayload {\n event: string;\n call_id: string;\n call_session_id: string;\n timestamp: string;\n data: Record<string, any>;\n}\n\n/** Standard error codes (aligned with backend models/errors.py) */\nexport const ErrorCodes = {\n // Auth errors (1000-1999)\n AUTH_REQUIRED: 1001,\n AUTH_INVALID: 1002,\n AUTH_EXPIRED: 1003,\n AUTH_INSUFFICIENT_PERMISSIONS: 1004,\n AUTH_FORBIDDEN: 1005,\n\n // Validation errors (2000-2999)\n VALIDATION_ERROR: 2001,\n INVALID_PHONE: 2002,\n INVALID_EMAIL: 2003,\n INVALID_PASSWORD: 2004,\n MISSING_REQUIRED_FIELD: 2005,\n INVALID_JSON: 2006,\n INVALID_REQUEST_BODY: 2007,\n\n // Not found errors (3000-3999)\n NOT_FOUND: 3001,\n USER_NOT_FOUND: 3002,\n CONVERSATION_NOT_FOUND: 3003,\n CALL_SESSION_NOT_FOUND: 3004,\n RESOURCE_NOT_FOUND: 3005,\n MESSAGE_NOT_FOUND: 3006,\n\n // Conflict errors (4000-4999)\n RESOURCE_ALREADY_EXISTS: 4001,\n EMAIL_ALREADY_REGISTERED: 4002,\n ACCOUNT_LINKING_REQUIRED: 4003,\n\n // Server errors (5000-5999)\n INTERNAL_ERROR: 5001,\n EXTERNAL_SERVICE_ERROR: 5002,\n DATABASE_ERROR: 5003,\n CONFIGURATION_ERROR: 5004,\n\n // Rate limiting (6000-6999)\n RATE_LIMIT_EXCEEDED: 6001,\n QUOTA_EXCEEDED: 6002,\n\n // B2B errors (7000-7999)\n B2B_PARTNER_NOT_FOUND: 7001,\n B2B_PROJECT_NOT_FOUND: 7002,\n B2B_CALL_NOT_FOUND: 7003,\n B2B_NO_PHONE_NUMBER: 7004,\n B2B_UNSUPPORTED_COUNTRY: 7005,\n B2B_TOOL_EXECUTION_FAILED: 7006,\n B2B_WEBHOOK_DELIVERY_FAILED: 7007,\n SUBSCRIPTION_EXPIRED: 7008,\n} as const;\n"],"mappings":";AA4EO,IAAM,aAAa;AAAA;AAAA,EAExB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,cAAc;AAAA,EACd,+BAA+B;AAAA,EAC/B,gBAAgB;AAAA;AAAA,EAGhB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,wBAAwB;AAAA,EACxB,cAAc;AAAA,EACd,sBAAsB;AAAA;AAAA,EAGtB,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA;AAAA,EAGnB,yBAAyB;AAAA,EACzB,0BAA0B;AAAA,EAC1B,0BAA0B;AAAA;AAAA,EAG1B,gBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,gBAAgB;AAAA,EAChB,qBAAqB;AAAA;AAAA,EAGrB,qBAAqB;AAAA,EACrB,gBAAgB;AAAA;AAAA,EAGhB,uBAAuB;AAAA,EACvB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,sBAAsB;AACxB;","names":[]}
@@ -0,0 +1,47 @@
1
+ declare class PamelaError extends Error {
2
+ errorCode?: number;
3
+ details?: Record<string, any>;
4
+ statusCode?: number;
5
+ constructor(message: string, options?: {
6
+ errorCode?: number;
7
+ details?: Record<string, any>;
8
+ statusCode?: number;
9
+ });
10
+ }
11
+ declare class AuthenticationError extends PamelaError {
12
+ constructor(message: string, options?: {
13
+ errorCode?: number;
14
+ details?: Record<string, any>;
15
+ statusCode?: number;
16
+ });
17
+ }
18
+ declare class SubscriptionError extends PamelaError {
19
+ constructor(message: string, options?: {
20
+ errorCode?: number;
21
+ details?: Record<string, any>;
22
+ statusCode?: number;
23
+ });
24
+ }
25
+ declare class RateLimitError extends PamelaError {
26
+ constructor(message: string, options?: {
27
+ errorCode?: number;
28
+ details?: Record<string, any>;
29
+ statusCode?: number;
30
+ });
31
+ }
32
+ declare class ValidationError extends PamelaError {
33
+ constructor(message: string, options?: {
34
+ errorCode?: number;
35
+ details?: Record<string, any>;
36
+ statusCode?: number;
37
+ });
38
+ }
39
+ declare class CallError extends PamelaError {
40
+ constructor(message: string, options?: {
41
+ errorCode?: number;
42
+ details?: Record<string, any>;
43
+ statusCode?: number;
44
+ });
45
+ }
46
+
47
+ export { AuthenticationError, CallError, PamelaError, RateLimitError, SubscriptionError, ValidationError };
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare class PamelaError extends Error {
1
+ declare class PamelaError extends Error {
2
2
  errorCode?: number;
3
3
  details?: Record<string, any>;
4
4
  statusCode?: number;
@@ -8,38 +8,40 @@ export declare class PamelaError extends Error {
8
8
  statusCode?: number;
9
9
  });
10
10
  }
11
- export declare class AuthenticationError extends PamelaError {
11
+ declare class AuthenticationError extends PamelaError {
12
12
  constructor(message: string, options?: {
13
13
  errorCode?: number;
14
14
  details?: Record<string, any>;
15
15
  statusCode?: number;
16
16
  });
17
17
  }
18
- export declare class SubscriptionError extends PamelaError {
18
+ declare class SubscriptionError extends PamelaError {
19
19
  constructor(message: string, options?: {
20
20
  errorCode?: number;
21
21
  details?: Record<string, any>;
22
22
  statusCode?: number;
23
23
  });
24
24
  }
25
- export declare class RateLimitError extends PamelaError {
25
+ declare class RateLimitError extends PamelaError {
26
26
  constructor(message: string, options?: {
27
27
  errorCode?: number;
28
28
  details?: Record<string, any>;
29
29
  statusCode?: number;
30
30
  });
31
31
  }
32
- export declare class ValidationError extends PamelaError {
32
+ declare class ValidationError extends PamelaError {
33
33
  constructor(message: string, options?: {
34
34
  errorCode?: number;
35
35
  details?: Record<string, any>;
36
36
  statusCode?: number;
37
37
  });
38
38
  }
39
- export declare class CallError extends PamelaError {
39
+ declare class CallError extends PamelaError {
40
40
  constructor(message: string, options?: {
41
41
  errorCode?: number;
42
42
  details?: Record<string, any>;
43
43
  statusCode?: number;
44
44
  });
45
45
  }
46
+
47
+ export { AuthenticationError, CallError, PamelaError, RateLimitError, SubscriptionError, ValidationError };
package/dist/errors.js CHANGED
@@ -1,48 +1,79 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CallError = exports.ValidationError = exports.RateLimitError = exports.SubscriptionError = exports.AuthenticationError = exports.PamelaError = void 0;
4
- class PamelaError extends Error {
5
- constructor(message, options) {
6
- super(message);
7
- this.name = 'PamelaError';
8
- this.errorCode = options?.errorCode;
9
- this.details = options?.details;
10
- this.statusCode = options?.statusCode;
11
- }
12
- }
13
- exports.PamelaError = PamelaError;
14
- class AuthenticationError extends PamelaError {
15
- constructor(message, options) {
16
- super(message, options);
17
- this.name = 'AuthenticationError';
18
- }
19
- }
20
- exports.AuthenticationError = AuthenticationError;
21
- class SubscriptionError extends PamelaError {
22
- constructor(message, options) {
23
- super(message, options);
24
- this.name = 'SubscriptionError';
25
- }
26
- }
27
- exports.SubscriptionError = SubscriptionError;
28
- class RateLimitError extends PamelaError {
29
- constructor(message, options) {
30
- super(message, options);
31
- this.name = 'RateLimitError';
32
- }
33
- }
34
- exports.RateLimitError = RateLimitError;
35
- class ValidationError extends PamelaError {
36
- constructor(message, options) {
37
- super(message, options);
38
- this.name = 'ValidationError';
39
- }
40
- }
41
- exports.ValidationError = ValidationError;
42
- class CallError extends PamelaError {
43
- constructor(message, options) {
44
- super(message, options);
45
- this.name = 'CallError';
46
- }
47
- }
48
- exports.CallError = CallError;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/errors.ts
21
+ var errors_exports = {};
22
+ __export(errors_exports, {
23
+ AuthenticationError: () => AuthenticationError,
24
+ CallError: () => CallError,
25
+ PamelaError: () => PamelaError,
26
+ RateLimitError: () => RateLimitError,
27
+ SubscriptionError: () => SubscriptionError,
28
+ ValidationError: () => ValidationError
29
+ });
30
+ module.exports = __toCommonJS(errors_exports);
31
+ var PamelaError = class extends Error {
32
+ constructor(message, options) {
33
+ super(message);
34
+ this.name = "PamelaError";
35
+ this.errorCode = options?.errorCode;
36
+ this.details = options?.details;
37
+ this.statusCode = options?.statusCode;
38
+ }
39
+ };
40
+ var AuthenticationError = class extends PamelaError {
41
+ constructor(message, options) {
42
+ super(message, options);
43
+ this.name = "AuthenticationError";
44
+ }
45
+ };
46
+ var SubscriptionError = class extends PamelaError {
47
+ constructor(message, options) {
48
+ super(message, options);
49
+ this.name = "SubscriptionError";
50
+ }
51
+ };
52
+ var RateLimitError = class extends PamelaError {
53
+ constructor(message, options) {
54
+ super(message, options);
55
+ this.name = "RateLimitError";
56
+ }
57
+ };
58
+ var ValidationError = class extends PamelaError {
59
+ constructor(message, options) {
60
+ super(message, options);
61
+ this.name = "ValidationError";
62
+ }
63
+ };
64
+ var CallError = class extends PamelaError {
65
+ constructor(message, options) {
66
+ super(message, options);
67
+ this.name = "CallError";
68
+ }
69
+ };
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ AuthenticationError,
73
+ CallError,
74
+ PamelaError,
75
+ RateLimitError,
76
+ SubscriptionError,
77
+ ValidationError
78
+ });
79
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["export class PamelaError extends Error {\n public errorCode?: number;\n public details?: Record<string, any>;\n public statusCode?: number;\n\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message);\n this.name = 'PamelaError';\n this.errorCode = options?.errorCode;\n this.details = options?.details;\n this.statusCode = options?.statusCode;\n }\n}\n\nexport class AuthenticationError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class SubscriptionError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'SubscriptionError';\n }\n}\n\nexport class RateLimitError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'RateLimitError';\n }\n}\n\nexport class ValidationError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'ValidationError';\n }\n}\n\nexport class CallError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'CallError';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAKrC,YAAY,SAAiB,SAAsF;AACjH,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY,SAAS;AAC1B,SAAK,UAAU,SAAS;AACxB,SAAK,aAAa,SAAS;AAAA,EAC7B;AACF;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,oBAAN,cAAgC,YAAY;AAAA,EACjD,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,YAAY;AAAA,EAC9C,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,YAAN,cAAwB,YAAY;AAAA,EACzC,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
@@ -0,0 +1,17 @@
1
+ import {
2
+ AuthenticationError,
3
+ CallError,
4
+ PamelaError,
5
+ RateLimitError,
6
+ SubscriptionError,
7
+ ValidationError
8
+ } from "./chunk-NQIPPPEL.mjs";
9
+ export {
10
+ AuthenticationError,
11
+ CallError,
12
+ PamelaError,
13
+ RateLimitError,
14
+ SubscriptionError,
15
+ ValidationError
16
+ };
17
+ //# sourceMappingURL=errors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,108 @@
1
+ import { AxiosInstance } from 'axios';
2
+ export { AuthenticationError, CallError, PamelaError, RateLimitError, SubscriptionError, ValidationError } from './errors.mjs';
3
+ import { PamelaClientConfig, CreateCallRequest, CallResponse, CallStatus, ToolDefinition } from './types.mjs';
4
+ export { CallStatusValue, ErrorCodes, WebhookPayload } from './types.mjs';
5
+
6
+ /**
7
+ * Pamela Enterprise Voice API SDK for JavaScript/TypeScript
8
+ */
9
+
10
+ declare class UsageClient {
11
+ private client;
12
+ constructor(client: AxiosInstance);
13
+ /**
14
+ * Get usage statistics for partner/project.
15
+ */
16
+ get(period?: string): Promise<{
17
+ partner_id: string;
18
+ project_id?: string;
19
+ period: string;
20
+ call_count: number;
21
+ last_updated?: string;
22
+ quota?: {
23
+ partner_limit?: number;
24
+ project_limit?: number;
25
+ };
26
+ }>;
27
+ }
28
+ declare class PamelaClient {
29
+ private client;
30
+ private apiKey;
31
+ usage: UsageClient;
32
+ constructor(config: PamelaClientConfig);
33
+ /**
34
+ * Create a new call.
35
+ */
36
+ createCall(request: CreateCallRequest): Promise<CallResponse>;
37
+ /**
38
+ * Get call status and details.
39
+ */
40
+ getCall(callId: string): Promise<CallStatus>;
41
+ /**
42
+ * List calls for the authenticated partner/project.
43
+ */
44
+ listCalls(params?: {
45
+ status?: string;
46
+ status_filter?: string;
47
+ limit?: number;
48
+ offset?: number;
49
+ start_date?: string;
50
+ end_date?: string;
51
+ }): Promise<{
52
+ items: CallStatus[];
53
+ total: number;
54
+ limit: number;
55
+ offset: number;
56
+ }>;
57
+ /**
58
+ * Cancel an in-progress call.
59
+ */
60
+ cancelCall(callId: string): Promise<{
61
+ success: boolean;
62
+ call_id: string;
63
+ status: string;
64
+ }>;
65
+ /**
66
+ * Force hangup an in-progress call.
67
+ */
68
+ hangupCall(callId: string): Promise<{
69
+ success: boolean;
70
+ call_id: string;
71
+ status: string;
72
+ }>;
73
+ /**
74
+ * Register a tool.
75
+ */
76
+ registerTool(tool: ToolDefinition): Promise<{
77
+ id: string;
78
+ project_id: string;
79
+ name: string;
80
+ description: string;
81
+ input_schema: Record<string, any>;
82
+ output_schema: Record<string, any>;
83
+ timeout_ms: number;
84
+ created_at: string;
85
+ }>;
86
+ /**
87
+ * List all tools for the project.
88
+ */
89
+ listTools(): Promise<Array<{
90
+ id: string;
91
+ project_id: string;
92
+ name: string;
93
+ description: string;
94
+ input_schema: Record<string, any>;
95
+ output_schema: Record<string, any>;
96
+ timeout_ms: number;
97
+ created_at: string;
98
+ }>>;
99
+ /**
100
+ * Delete a tool.
101
+ */
102
+ deleteTool(toolId: string): Promise<{
103
+ success: boolean;
104
+ tool_id: string;
105
+ }>;
106
+ }
107
+
108
+ export { CallResponse, CallStatus, CreateCallRequest, PamelaClient as Pamela, PamelaClient, PamelaClientConfig, ToolDefinition, UsageClient, PamelaClient as default };
package/dist/index.d.ts CHANGED
@@ -1,67 +1,13 @@
1
+ import { AxiosInstance } from 'axios';
2
+ export { AuthenticationError, CallError, PamelaError, RateLimitError, SubscriptionError, ValidationError } from './errors.js';
3
+ import { PamelaClientConfig, CreateCallRequest, CallResponse, CallStatus, ToolDefinition } from './types.js';
4
+ export { CallStatusValue, ErrorCodes, WebhookPayload } from './types.js';
5
+
1
6
  /**
2
7
  * Pamela Enterprise Voice API SDK for JavaScript/TypeScript
3
8
  */
4
- import { AxiosInstance } from 'axios';
5
- import { PamelaError, AuthenticationError, SubscriptionError, RateLimitError, ValidationError, CallError } from './errors';
6
- export interface PamelaClientConfig {
7
- apiKey: string;
8
- baseUrl?: string;
9
- }
10
- export interface CreateCallRequest {
11
- to: string;
12
- country?: string;
13
- locale?: string;
14
- task: string;
15
- instructions?: string;
16
- max_duration_seconds?: number;
17
- voice?: 'male' | 'female' | 'auto';
18
- agent_name?: string;
19
- caller_name?: string;
20
- end_user_id?: string;
21
- metadata?: Record<string, any>;
22
- tools?: Array<Record<string, any>>;
23
- webhooks?: {
24
- webhook_url?: string;
25
- tool_webhook_url?: string;
26
- };
27
- }
28
- export interface CallResponse {
29
- id: string;
30
- status: string;
31
- call_session_id: string;
32
- created_at: string;
33
- }
34
- export interface CallStatus {
35
- id: string;
36
- status: string;
37
- to: string;
38
- from_: string;
39
- country: string;
40
- created_at: string;
41
- started_at?: string;
42
- completed_at?: string;
43
- duration_seconds?: number;
44
- max_duration_seconds?: number;
45
- transcript?: Array<Record<string, any>>;
46
- summary?: string;
47
- metadata: Record<string, any>;
48
- end_user_id?: string;
49
- }
50
- export interface ToolDefinition {
51
- name: string;
52
- description: string;
53
- input_schema: Record<string, any>;
54
- output_schema?: Record<string, any>;
55
- timeout_ms?: number;
56
- }
57
- export interface WebhookPayload {
58
- event: string;
59
- call_id: string;
60
- call_session_id: string;
61
- timestamp: string;
62
- data: Record<string, any>;
63
- }
64
- export declare class UsageClient {
9
+
10
+ declare class UsageClient {
65
11
  private client;
66
12
  constructor(client: AxiosInstance);
67
13
  /**
@@ -79,7 +25,7 @@ export declare class UsageClient {
79
25
  };
80
26
  }>;
81
27
  }
82
- export declare class PamelaClient {
28
+ declare class PamelaClient {
83
29
  private client;
84
30
  private apiKey;
85
31
  usage: UsageClient;
@@ -157,11 +103,6 @@ export declare class PamelaClient {
157
103
  success: boolean;
158
104
  tool_id: string;
159
105
  }>;
160
- /**
161
- * Verify webhook signature.
162
- */
163
- static verifyWebhookSignature(payload: string | object, signature: string, secret: string): boolean;
164
106
  }
165
- export default PamelaClient;
166
- export { PamelaClient as Pamela };
167
- export { PamelaError, AuthenticationError, SubscriptionError, RateLimitError, ValidationError, CallError, };
107
+
108
+ export { CallResponse, CallStatus, CreateCallRequest, PamelaClient as Pamela, PamelaClient, PamelaClientConfig, ToolDefinition, UsageClient, PamelaClient as default };