@paid-ai/paid-node 0.0.8 → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +122 -11
- package/dist/cjs/Client.d.ts +22 -0
- package/dist/cjs/Client.js +45 -2
- package/dist/cjs/anthropic-wrapper/index.d.ts +1 -0
- package/dist/cjs/anthropic-wrapper/index.js +5 -0
- package/dist/cjs/api/resources/agents/client/Client.d.ts +52 -4
- package/dist/cjs/api/resources/agents/client/Client.js +52 -4
- package/dist/cjs/api/resources/agents/client/requests/AgentCreate.d.ts +4 -2
- package/dist/cjs/api/resources/contacts/client/Client.d.ts +4 -7
- package/dist/cjs/api/resources/contacts/client/Client.js +4 -7
- package/dist/cjs/api/resources/contacts/client/requests/ContactCreate.d.ts +8 -11
- package/dist/cjs/api/resources/customers/client/Client.d.ts +8 -2
- package/dist/cjs/api/resources/customers/client/Client.js +8 -2
- package/dist/cjs/api/resources/customers/client/requests/CustomerCreate.d.ts +2 -1
- package/dist/cjs/api/resources/orders/client/Client.d.ts +6 -5
- package/dist/cjs/api/resources/orders/client/Client.js +6 -5
- package/dist/cjs/api/resources/orders/client/requests/OrderCreate.d.ts +8 -7
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +11 -1
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +11 -1
- package/dist/cjs/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.ts +11 -1
- package/dist/cjs/api/resources/usage/client/Client.d.ts +4 -2
- package/dist/cjs/api/resources/usage/client/Client.js +4 -2
- package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkRequest.d.ts +3 -1
- package/dist/cjs/api/types/BillingFrequency.d.ts +4 -4
- package/dist/cjs/api/types/BillingFrequency.js +3 -3
- package/dist/cjs/api/types/Pricing.d.ts +1 -0
- package/dist/cjs/api/types/PricingModelType.d.ts +2 -1
- package/dist/cjs/api/types/PricingModelType.js +1 -0
- package/dist/cjs/api/types/Signal.d.ts +1 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/langchain-wrapper/index.d.ts +1 -0
- package/dist/cjs/langchain-wrapper/index.js +5 -0
- package/dist/cjs/mistral-wrapper/index.d.ts +1 -0
- package/dist/cjs/mistral-wrapper/index.js +5 -0
- package/dist/cjs/openai-wrapper/index.d.ts +1 -0
- package/dist/cjs/openai-wrapper/index.js +5 -0
- package/dist/cjs/tracing/signal.d.ts +1 -0
- package/dist/cjs/tracing/signal.js +54 -0
- package/dist/cjs/tracing/tracing.d.ts +8 -0
- package/dist/cjs/tracing/tracing.js +127 -0
- package/dist/cjs/tracing/wrappers/anthropicWrapper.d.ts +16 -0
- package/dist/cjs/tracing/wrappers/anthropicWrapper.js +84 -0
- package/dist/cjs/tracing/wrappers/langchainCallback.d.ts +21 -0
- package/dist/cjs/tracing/wrappers/langchainCallback.js +142 -0
- package/dist/cjs/tracing/wrappers/mistralWrapper.d.ts +17 -0
- package/dist/cjs/tracing/wrappers/mistralWrapper.js +81 -0
- package/dist/cjs/tracing/wrappers/openAiWrapper.d.ts +48 -0
- package/dist/cjs/tracing/wrappers/openAiWrapper.js +241 -0
- package/dist/cjs/tracing/wrappers/vercelAIWrapper.d.ts +22 -0
- package/dist/cjs/tracing/wrappers/vercelAIWrapper.js +327 -0
- package/dist/cjs/vercel-wrapper/index.d.ts +1 -0
- package/dist/cjs/vercel-wrapper/index.js +10 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wrapper/BatchUsage.d.ts +3 -3
- package/dist/cjs/wrapper/BatchUsage.js +4 -4
- package/dist/esm/Client.d.mts +22 -0
- package/dist/esm/Client.mjs +45 -2
- package/dist/esm/anthropic-wrapper/index.d.mts +1 -0
- package/dist/esm/anthropic-wrapper/index.mjs +1 -0
- package/dist/esm/api/resources/agents/client/Client.d.mts +52 -4
- package/dist/esm/api/resources/agents/client/Client.mjs +52 -4
- package/dist/esm/api/resources/agents/client/requests/AgentCreate.d.mts +4 -2
- package/dist/esm/api/resources/contacts/client/Client.d.mts +4 -7
- package/dist/esm/api/resources/contacts/client/Client.mjs +4 -7
- package/dist/esm/api/resources/contacts/client/requests/ContactCreate.d.mts +8 -11
- package/dist/esm/api/resources/customers/client/Client.d.mts +8 -2
- package/dist/esm/api/resources/customers/client/Client.mjs +8 -2
- package/dist/esm/api/resources/customers/client/requests/CustomerCreate.d.mts +2 -1
- package/dist/esm/api/resources/orders/client/Client.d.mts +6 -5
- package/dist/esm/api/resources/orders/client/Client.mjs +6 -5
- package/dist/esm/api/resources/orders/client/requests/OrderCreate.d.mts +8 -7
- package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +11 -1
- package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +11 -1
- package/dist/esm/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.mts +11 -1
- package/dist/esm/api/resources/usage/client/Client.d.mts +4 -2
- package/dist/esm/api/resources/usage/client/Client.mjs +4 -2
- package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkRequest.d.mts +3 -1
- package/dist/esm/api/types/BillingFrequency.d.mts +4 -4
- package/dist/esm/api/types/BillingFrequency.mjs +3 -3
- package/dist/esm/api/types/Pricing.d.mts +1 -0
- package/dist/esm/api/types/PricingModelType.d.mts +2 -1
- package/dist/esm/api/types/PricingModelType.mjs +1 -0
- package/dist/esm/api/types/Signal.d.mts +1 -0
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/langchain-wrapper/index.d.mts +1 -0
- package/dist/esm/langchain-wrapper/index.mjs +1 -0
- package/dist/esm/mistral-wrapper/index.d.mts +1 -0
- package/dist/esm/mistral-wrapper/index.mjs +1 -0
- package/dist/esm/openai-wrapper/index.d.mts +1 -0
- package/dist/esm/openai-wrapper/index.mjs +1 -0
- package/dist/esm/tracing/signal.d.mts +1 -0
- package/dist/esm/tracing/signal.mjs +51 -0
- package/dist/esm/tracing/tracing.d.mts +8 -0
- package/dist/esm/tracing/tracing.mjs +116 -0
- package/dist/esm/tracing/wrappers/anthropicWrapper.d.mts +16 -0
- package/dist/esm/tracing/wrappers/anthropicWrapper.mjs +80 -0
- package/dist/esm/tracing/wrappers/langchainCallback.d.mts +21 -0
- package/dist/esm/tracing/wrappers/langchainCallback.mjs +138 -0
- package/dist/esm/tracing/wrappers/mistralWrapper.d.mts +17 -0
- package/dist/esm/tracing/wrappers/mistralWrapper.mjs +77 -0
- package/dist/esm/tracing/wrappers/openAiWrapper.d.mts +48 -0
- package/dist/esm/tracing/wrappers/openAiWrapper.mjs +237 -0
- package/dist/esm/tracing/wrappers/vercelAIWrapper.d.mts +22 -0
- package/dist/esm/tracing/wrappers/vercelAIWrapper.mjs +319 -0
- package/dist/esm/vercel-wrapper/index.d.mts +1 -0
- package/dist/esm/vercel-wrapper/index.mjs +1 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/dist/esm/wrapper/BatchUsage.d.mts +3 -3
- package/dist/esm/wrapper/BatchUsage.mjs +3 -3
- package/package.json +102 -4
- package/reference.md +96 -21
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Agent Paid Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,28 +1,45 @@
|
|
|
1
|
-
# Paid TypeScript Library
|
|
2
|
-
|
|
3
|
-
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FAgentPaid%2Fpaid-node)
|
|
4
|
-
[](https://www.npmjs.com/package/@paid-ai/paid-node)
|
|
5
1
|
|
|
2
|
+
<div align="center">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="./assets/paid_light.svg" width=600>
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="./assets/paid_dark.svg" width=600>
|
|
6
|
+
<img alt="Fallback image description" src="./assets/paid_light.svg" width=600>
|
|
7
|
+
</picture>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
<div align="center">
|
|
13
|
+
<a href="https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FAgentPaid%2Fpaid-node">
|
|
14
|
+
<img src="https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen" alt="fern shield">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@paid-ai/paid-node">
|
|
17
|
+
<img src="https://img.shields.io/npm/v/@paid-ai/paid-node" alt="npm shield">
|
|
18
|
+
</a>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
Paid is the all-in-one, drop-in Business Engine for AI Agents that handles your pricing, subscriptions, margins, billing, and renewals with just 5 lines of code.
|
|
6
22
|
The Paid TypeScript library provides convenient access to the Paid API from TypeScript.
|
|
7
23
|
|
|
24
|
+
## Documentation
|
|
25
|
+
|
|
26
|
+
See the full API docs [here](https://paid.docs.buildwithfern.com/api-reference/api-reference/customers/list)
|
|
27
|
+
|
|
8
28
|
## Installation
|
|
9
29
|
|
|
10
30
|
```sh
|
|
11
|
-
npm
|
|
31
|
+
npm install -s @paid-ai/paid-node
|
|
12
32
|
```
|
|
13
33
|
|
|
14
|
-
## Reference
|
|
15
|
-
|
|
16
|
-
A full reference for this library is available [here](https://github.com/AgentPaid/paid-node/blob/HEAD/./reference.md).
|
|
17
|
-
|
|
18
34
|
## Usage
|
|
19
35
|
|
|
20
|
-
|
|
36
|
+
The client needs to be configured with your account's API key, which is available in the [Paid dashboard](https://app.paid.ai/agent-integration/api-keys).
|
|
21
37
|
|
|
22
38
|
```typescript
|
|
23
39
|
import { PaidClient } from "@paid-ai/paid-node";
|
|
24
40
|
|
|
25
|
-
const client = new PaidClient({ token: "
|
|
41
|
+
const client = new PaidClient({ token: "API_KEY" });
|
|
42
|
+
|
|
26
43
|
await client.customers.create({
|
|
27
44
|
name: "name",
|
|
28
45
|
});
|
|
@@ -61,6 +78,100 @@ try {
|
|
|
61
78
|
}
|
|
62
79
|
```
|
|
63
80
|
|
|
81
|
+
## Logging
|
|
82
|
+
Logs are silent by default.
|
|
83
|
+
|
|
84
|
+
To enable logs, set the `PAID_LOG_LEVEL` environment variable. Available levels include:
|
|
85
|
+
`error`, `warn`, `info`, `http`, `verbose`, `debug`, and `silly`.
|
|
86
|
+
|
|
87
|
+
Example: `PAID_LOG_LEVEL=debug node your-app.js`
|
|
88
|
+
|
|
89
|
+
## Cost Tracking
|
|
90
|
+
|
|
91
|
+
It's possible to track usage costs by using Paid wrappers around you AI provider API.
|
|
92
|
+
As of now, the following AI providers are supported: `OpenAI`, `Anthropic`, `Mistral` (OCR), and `Langchain`.
|
|
93
|
+
|
|
94
|
+
Example usage:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { PaidClient, PaidOpenAI } from "@paid-ai/paid-node";
|
|
98
|
+
import OpenAI from "openai";
|
|
99
|
+
|
|
100
|
+
async function main() {
|
|
101
|
+
const client = new PaidClient({ token: "<your_paid_api_key>" });
|
|
102
|
+
|
|
103
|
+
// initialize cost tracking
|
|
104
|
+
await client.initializeTracing()
|
|
105
|
+
|
|
106
|
+
// wrap openai in paid wrapper
|
|
107
|
+
const openaiClient = new OpenAI({ apiKey: "<your_openai_api_key" });
|
|
108
|
+
const paidOpenAiWrapper = new PaidOpenAI(openaiClient);
|
|
109
|
+
|
|
110
|
+
// trace the call
|
|
111
|
+
await client.trace("<your_external_customer_id>", async () => {
|
|
112
|
+
const response = await paidOpenAiWrapper.images.generate({
|
|
113
|
+
prompt: "A beautiful sunset over the mountains",
|
|
114
|
+
n: 1,
|
|
115
|
+
size: "256x256"
|
|
116
|
+
});
|
|
117
|
+
if (response.data) {
|
|
118
|
+
console.log("Image generation:", response.data[0].url);
|
|
119
|
+
}
|
|
120
|
+
}, "<optional_external_agent_id>");
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Manual Cost Tracking
|
|
125
|
+
|
|
126
|
+
When using `client.usage.recordUsage()` API, it's possible to create cost traces manually
|
|
127
|
+
just by passing in the cost data.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
const additionalData = {
|
|
131
|
+
costData: {
|
|
132
|
+
vendor: "<vendor_name>", // can be anything
|
|
133
|
+
cost : {
|
|
134
|
+
amount: 0.0001,
|
|
135
|
+
currency: "USD"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
await client.usage.recordBulk({
|
|
140
|
+
signals: [{
|
|
141
|
+
agent_id: "<your_agent_id>",
|
|
142
|
+
event_name: "<your_signal_name>",
|
|
143
|
+
customer_id: "<your_customer_id>",
|
|
144
|
+
data: additionalData,
|
|
145
|
+
}]
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
await client.usage.flush(); // need to flush to send usage immediately
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Send signals over OTLP
|
|
152
|
+
|
|
153
|
+
Besides sending signals over REST, it's also possible to send signals as part or tracing
|
|
154
|
+
context, just like with cost tracking.
|
|
155
|
+
|
|
156
|
+
Example usage:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { PaidClient } from "@paid-ai/paid-node";
|
|
160
|
+
|
|
161
|
+
async function main() {
|
|
162
|
+
const client = new PaidClient({ token: "<your_paid_api_key>" });
|
|
163
|
+
|
|
164
|
+
// initialize cost tracking
|
|
165
|
+
await client.initializeTracing()
|
|
166
|
+
|
|
167
|
+
// trace the call
|
|
168
|
+
await client.trace("<your_external_customer_id>", async () => {
|
|
169
|
+
// ... your app logic, cost tracking LLM wrapper calls
|
|
170
|
+
client.signal("signal_name", { "data": { // ... additional data, e.g. costs } });
|
|
171
|
+
}, "<optional_external_agent_id>");
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
64
175
|
## Advanced
|
|
65
176
|
|
|
66
177
|
### Additional Headers
|
package/dist/cjs/Client.d.ts
CHANGED
|
@@ -41,4 +41,26 @@ export declare class PaidClient {
|
|
|
41
41
|
get contacts(): Contacts;
|
|
42
42
|
get orders(): Orders;
|
|
43
43
|
get usage(): Usage;
|
|
44
|
+
initializeTracing(collectorEndpoint?: string): Promise<void>;
|
|
45
|
+
trace<T extends (...args: any[]) => any>(externalCustomerId: string, fn: T, externalAgentId?: string, ...args: Parameters<T>): Promise<ReturnType<T>>;
|
|
46
|
+
/**
|
|
47
|
+
* Sends Paid signal. Needs to be called as part of callback to Paid.trace().
|
|
48
|
+
* When enableCostTracing flag is on, signal is associated
|
|
49
|
+
* with cost traces from the same Paid.trace() context.
|
|
50
|
+
*
|
|
51
|
+
* @param eventName - The name of the signal.
|
|
52
|
+
* @param enableCostTracing - Whether to associate this signal with cost traces
|
|
53
|
+
* from the current Paid.trace() context (default: false)
|
|
54
|
+
* @param data - Optional additional data to include with the signal
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* When enableCostTracing is on, the signal will be associated with cost
|
|
58
|
+
* traces within the same Paid.trace() context.
|
|
59
|
+
* It is advised to only make one call to this function
|
|
60
|
+
* with enableCostTracing per Paid.trace() context.
|
|
61
|
+
* Otherwise, there will be multiple signals that refer to the same costs.
|
|
62
|
+
*/
|
|
63
|
+
signal(eventName: string): void;
|
|
64
|
+
signal(eventName: string, data: Record<string, any>): void;
|
|
65
|
+
signal(eventName: string, enableCostTracing: boolean, data?: Record<string, any>): void;
|
|
44
66
|
}
|
package/dist/cjs/Client.js
CHANGED
|
@@ -35,6 +35,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
return result;
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
39
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
40
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
43
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
44
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
38
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
48
|
exports.PaidClient = void 0;
|
|
40
49
|
const core = __importStar(require("./core/index.js"));
|
|
@@ -44,13 +53,15 @@ const Client_js_2 = require("./api/resources/agents/client/Client.js");
|
|
|
44
53
|
const Client_js_3 = require("./api/resources/contacts/client/Client.js");
|
|
45
54
|
const Client_js_4 = require("./api/resources/orders/client/Client.js");
|
|
46
55
|
const BatchUsage_js_1 = require("./wrapper/BatchUsage.js");
|
|
56
|
+
const tracing_js_1 = require("./tracing/tracing.js");
|
|
57
|
+
const signal_js_1 = require("./tracing/signal.js");
|
|
47
58
|
class PaidClient {
|
|
48
59
|
constructor(_options) {
|
|
49
60
|
this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
|
|
50
61
|
"X-Fern-Language": "JavaScript",
|
|
51
62
|
"X-Fern-SDK-Name": "@paid-ai/paid-node",
|
|
52
|
-
"X-Fern-SDK-Version": "0.0
|
|
53
|
-
"User-Agent": "@paid-ai/paid-node/0.0
|
|
63
|
+
"X-Fern-SDK-Version": "0.2.0",
|
|
64
|
+
"User-Agent": "@paid-ai/paid-node/0.2.0",
|
|
54
65
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
55
66
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
56
67
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -75,5 +86,37 @@ class PaidClient {
|
|
|
75
86
|
var _a;
|
|
76
87
|
return ((_a = this._usage) !== null && _a !== void 0 ? _a : (this._usage = new BatchUsage_js_1.Usage(this._options)));
|
|
77
88
|
}
|
|
89
|
+
// Need to call this method before using tracing or creating wrappers.
|
|
90
|
+
initializeTracing(collectorEndpoint) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const tokenSupplier = this._options.token;
|
|
93
|
+
const token = typeof tokenSupplier === "function" ? yield tokenSupplier() : tokenSupplier;
|
|
94
|
+
const resolvedToken = yield Promise.resolve(token);
|
|
95
|
+
(0, tracing_js_1._initializeTracing)(resolvedToken, collectorEndpoint);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// Use this method to track actions like LLM costs and sending signals.
|
|
99
|
+
// The callback to this function is the work that you want to trace.
|
|
100
|
+
trace(externalCustomerId, fn, externalAgentId, ...args) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
return yield (0, tracing_js_1._trace)(externalCustomerId, fn, externalAgentId, ...args);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
signal(eventName, enableCostTracingOrData, data) {
|
|
106
|
+
let enableCostTracing = false;
|
|
107
|
+
let finalData;
|
|
108
|
+
if (typeof enableCostTracingOrData === 'boolean') {
|
|
109
|
+
// Case: signal(eventName, boolean, data?)
|
|
110
|
+
enableCostTracing = enableCostTracingOrData;
|
|
111
|
+
finalData = data;
|
|
112
|
+
}
|
|
113
|
+
else if (typeof enableCostTracingOrData === 'object') {
|
|
114
|
+
// Case: signal(eventName, data)
|
|
115
|
+
enableCostTracing = false;
|
|
116
|
+
finalData = enableCostTracingOrData;
|
|
117
|
+
}
|
|
118
|
+
// Case: signal(eventName) - both remain default/undefined
|
|
119
|
+
return (0, signal_js_1._signal)(eventName, enableCostTracing, finalData);
|
|
120
|
+
}
|
|
78
121
|
}
|
|
79
122
|
exports.PaidClient = PaidClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PaidAnthropic } from "../tracing/wrappers/anthropicWrapper.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaidAnthropic = void 0;
|
|
4
|
+
var anthropicWrapper_js_1 = require("../tracing/wrappers/anthropicWrapper.js");
|
|
5
|
+
Object.defineProperty(exports, "PaidAnthropic", { enumerable: true, get: function () { return anthropicWrapper_js_1.PaidAnthropic; } });
|
|
@@ -41,8 +41,9 @@ export declare class Agents {
|
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
43
|
* await client.agents.create({
|
|
44
|
-
* name: "
|
|
45
|
-
* description: "
|
|
44
|
+
* name: "Acme Agent",
|
|
45
|
+
* description: "Acme Agent is an AI agent that does things.",
|
|
46
|
+
* externalId: "acme-agent"
|
|
46
47
|
* })
|
|
47
48
|
*/
|
|
48
49
|
create(request: Paid.AgentCreate, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<Paid.Agent>;
|
|
@@ -62,7 +63,36 @@ export declare class Agents {
|
|
|
62
63
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
63
64
|
*
|
|
64
65
|
* @example
|
|
65
|
-
* await client.agents.update("agentId", {
|
|
66
|
+
* await client.agents.update("agentId", {
|
|
67
|
+
* name: "Acme Agent (Updated)",
|
|
68
|
+
* agentAttributes: [{
|
|
69
|
+
* name: "Emails sent signal",
|
|
70
|
+
* active: true,
|
|
71
|
+
* pricing: {
|
|
72
|
+
* eventName: "emails_sent",
|
|
73
|
+
* taxable: true,
|
|
74
|
+
* chargeType: "usage",
|
|
75
|
+
* pricingModel: "PerUnit",
|
|
76
|
+
* billingFrequency: "monthly",
|
|
77
|
+
* pricePoints: {
|
|
78
|
+
* "USD": {
|
|
79
|
+
* tiers: [{
|
|
80
|
+
* minQuantity: 0,
|
|
81
|
+
* maxQuantity: 10,
|
|
82
|
+
* unitPrice: 100
|
|
83
|
+
* }, {
|
|
84
|
+
* minQuantity: 11,
|
|
85
|
+
* maxQuantity: 100,
|
|
86
|
+
* unitPrice: 90
|
|
87
|
+
* }, {
|
|
88
|
+
* minQuantity: 101,
|
|
89
|
+
* unitPrice: 80
|
|
90
|
+
* }]
|
|
91
|
+
* }
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* }]
|
|
95
|
+
* })
|
|
66
96
|
*/
|
|
67
97
|
update(agentId: string, request: Paid.AgentUpdate, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<Paid.Agent>;
|
|
68
98
|
private __update;
|
|
@@ -90,7 +120,25 @@ export declare class Agents {
|
|
|
90
120
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
91
121
|
*
|
|
92
122
|
* @example
|
|
93
|
-
* await client.agents.updateByExternalId("externalId", {
|
|
123
|
+
* await client.agents.updateByExternalId("externalId", {
|
|
124
|
+
* name: "Acme Agent (Updated)",
|
|
125
|
+
* agentAttributes: [{
|
|
126
|
+
* name: "Emails sent signal",
|
|
127
|
+
* active: true,
|
|
128
|
+
* pricing: {
|
|
129
|
+
* eventName: "emails_sent",
|
|
130
|
+
* taxable: true,
|
|
131
|
+
* chargeType: "usage",
|
|
132
|
+
* pricingModel: "PerUnit",
|
|
133
|
+
* billingFrequency: "monthly",
|
|
134
|
+
* pricePoints: {
|
|
135
|
+
* "USD": {
|
|
136
|
+
* unitPrice: 150
|
|
137
|
+
* }
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* }]
|
|
141
|
+
* })
|
|
94
142
|
*/
|
|
95
143
|
updateByExternalId(externalId: string, request: Paid.AgentUpdate, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<Paid.Agent>;
|
|
96
144
|
private __updateByExternalId;
|
|
@@ -111,8 +111,9 @@ class Agents {
|
|
|
111
111
|
*
|
|
112
112
|
* @example
|
|
113
113
|
* await client.agents.create({
|
|
114
|
-
* name: "
|
|
115
|
-
* description: "
|
|
114
|
+
* name: "Acme Agent",
|
|
115
|
+
* description: "Acme Agent is an AI agent that does things.",
|
|
116
|
+
* externalId: "acme-agent"
|
|
116
117
|
* })
|
|
117
118
|
*/
|
|
118
119
|
create(request, requestOptions) {
|
|
@@ -213,7 +214,36 @@ class Agents {
|
|
|
213
214
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
214
215
|
*
|
|
215
216
|
* @example
|
|
216
|
-
* await client.agents.update("agentId", {
|
|
217
|
+
* await client.agents.update("agentId", {
|
|
218
|
+
* name: "Acme Agent (Updated)",
|
|
219
|
+
* agentAttributes: [{
|
|
220
|
+
* name: "Emails sent signal",
|
|
221
|
+
* active: true,
|
|
222
|
+
* pricing: {
|
|
223
|
+
* eventName: "emails_sent",
|
|
224
|
+
* taxable: true,
|
|
225
|
+
* chargeType: "usage",
|
|
226
|
+
* pricingModel: "PerUnit",
|
|
227
|
+
* billingFrequency: "monthly",
|
|
228
|
+
* pricePoints: {
|
|
229
|
+
* "USD": {
|
|
230
|
+
* tiers: [{
|
|
231
|
+
* minQuantity: 0,
|
|
232
|
+
* maxQuantity: 10,
|
|
233
|
+
* unitPrice: 100
|
|
234
|
+
* }, {
|
|
235
|
+
* minQuantity: 11,
|
|
236
|
+
* maxQuantity: 100,
|
|
237
|
+
* unitPrice: 90
|
|
238
|
+
* }, {
|
|
239
|
+
* minQuantity: 101,
|
|
240
|
+
* unitPrice: 80
|
|
241
|
+
* }]
|
|
242
|
+
* }
|
|
243
|
+
* }
|
|
244
|
+
* }
|
|
245
|
+
* }]
|
|
246
|
+
* })
|
|
217
247
|
*/
|
|
218
248
|
update(agentId, request, requestOptions) {
|
|
219
249
|
return core.HttpResponsePromise.fromPromise(this.__update(agentId, request, requestOptions));
|
|
@@ -361,7 +391,25 @@ class Agents {
|
|
|
361
391
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
362
392
|
*
|
|
363
393
|
* @example
|
|
364
|
-
* await client.agents.updateByExternalId("externalId", {
|
|
394
|
+
* await client.agents.updateByExternalId("externalId", {
|
|
395
|
+
* name: "Acme Agent (Updated)",
|
|
396
|
+
* agentAttributes: [{
|
|
397
|
+
* name: "Emails sent signal",
|
|
398
|
+
* active: true,
|
|
399
|
+
* pricing: {
|
|
400
|
+
* eventName: "emails_sent",
|
|
401
|
+
* taxable: true,
|
|
402
|
+
* chargeType: "usage",
|
|
403
|
+
* pricingModel: "PerUnit",
|
|
404
|
+
* billingFrequency: "monthly",
|
|
405
|
+
* pricePoints: {
|
|
406
|
+
* "USD": {
|
|
407
|
+
* unitPrice: 150
|
|
408
|
+
* }
|
|
409
|
+
* }
|
|
410
|
+
* }
|
|
411
|
+
* }]
|
|
412
|
+
* })
|
|
365
413
|
*/
|
|
366
414
|
updateByExternalId(externalId, request, requestOptions) {
|
|
367
415
|
return core.HttpResponsePromise.fromPromise(this.__updateByExternalId(externalId, request, requestOptions));
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @example
|
|
6
6
|
* {
|
|
7
|
-
* name: "
|
|
8
|
-
* description: "
|
|
7
|
+
* name: "Acme Agent",
|
|
8
|
+
* description: "Acme Agent is an AI agent that does things.",
|
|
9
|
+
* externalId: "acme-agent"
|
|
9
10
|
* }
|
|
10
11
|
*/
|
|
11
12
|
export interface AgentCreate {
|
|
@@ -13,4 +14,5 @@ export interface AgentCreate {
|
|
|
13
14
|
description: string;
|
|
14
15
|
agentCode?: string;
|
|
15
16
|
externalId?: string;
|
|
17
|
+
active?: boolean;
|
|
16
18
|
}
|
|
@@ -41,14 +41,11 @@ export declare class Contacts {
|
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
43
|
* await client.contacts.create({
|
|
44
|
+
* customerExternalId: "acme-inc",
|
|
44
45
|
* salutation: "Mr.",
|
|
45
|
-
* firstName: "
|
|
46
|
-
* lastName: "
|
|
47
|
-
* email: "
|
|
48
|
-
* billingStreet: "billingStreet",
|
|
49
|
-
* billingCity: "billingCity",
|
|
50
|
-
* billingCountry: "billingCountry",
|
|
51
|
-
* billingPostalCode: "billingPostalCode"
|
|
46
|
+
* firstName: "John",
|
|
47
|
+
* lastName: "Doe",
|
|
48
|
+
* email: "john.doe@example.com"
|
|
52
49
|
* })
|
|
53
50
|
*/
|
|
54
51
|
create(request: Paid.ContactCreate, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<Paid.Contact>;
|
|
@@ -111,14 +111,11 @@ class Contacts {
|
|
|
111
111
|
*
|
|
112
112
|
* @example
|
|
113
113
|
* await client.contacts.create({
|
|
114
|
+
* customerExternalId: "acme-inc",
|
|
114
115
|
* salutation: "Mr.",
|
|
115
|
-
* firstName: "
|
|
116
|
-
* lastName: "
|
|
117
|
-
* email: "
|
|
118
|
-
* billingStreet: "billingStreet",
|
|
119
|
-
* billingCity: "billingCity",
|
|
120
|
-
* billingCountry: "billingCountry",
|
|
121
|
-
* billingPostalCode: "billingPostalCode"
|
|
116
|
+
* firstName: "John",
|
|
117
|
+
* lastName: "Doe",
|
|
118
|
+
* email: "john.doe@example.com"
|
|
122
119
|
* })
|
|
123
120
|
*/
|
|
124
121
|
create(request, requestOptions) {
|
|
@@ -5,14 +5,11 @@ import * as Paid from "../../../../index.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* {
|
|
8
|
+
* customerExternalId: "acme-inc",
|
|
8
9
|
* salutation: "Mr.",
|
|
9
|
-
* firstName: "
|
|
10
|
-
* lastName: "
|
|
11
|
-
* email: "
|
|
12
|
-
* billingStreet: "billingStreet",
|
|
13
|
-
* billingCity: "billingCity",
|
|
14
|
-
* billingCountry: "billingCountry",
|
|
15
|
-
* billingPostalCode: "billingPostalCode"
|
|
10
|
+
* firstName: "John",
|
|
11
|
+
* lastName: "Doe",
|
|
12
|
+
* email: "john.doe@example.com"
|
|
16
13
|
* }
|
|
17
14
|
*/
|
|
18
15
|
export interface ContactCreate {
|
|
@@ -24,9 +21,9 @@ export interface ContactCreate {
|
|
|
24
21
|
lastName: string;
|
|
25
22
|
email: string;
|
|
26
23
|
phone?: string;
|
|
27
|
-
billingStreet
|
|
28
|
-
billingCity
|
|
24
|
+
billingStreet?: string;
|
|
25
|
+
billingCity?: string;
|
|
29
26
|
billingStateProvince?: string;
|
|
30
|
-
billingCountry
|
|
31
|
-
billingPostalCode
|
|
27
|
+
billingCountry?: string;
|
|
28
|
+
billingPostalCode?: string;
|
|
32
29
|
}
|
|
@@ -41,7 +41,8 @@ export declare class Customers {
|
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
43
|
* await client.customers.create({
|
|
44
|
-
* name: "
|
|
44
|
+
* name: "Acme, Inc.",
|
|
45
|
+
* externalId: "acme-inc"
|
|
45
46
|
* })
|
|
46
47
|
*/
|
|
47
48
|
create(request: Paid.CustomerCreate, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
|
|
@@ -61,7 +62,12 @@ export declare class Customers {
|
|
|
61
62
|
* @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
|
|
62
63
|
*
|
|
63
64
|
* @example
|
|
64
|
-
* await client.customers.update("customerId", {
|
|
65
|
+
* await client.customers.update("customerId", {
|
|
66
|
+
* name: "Acme, Inc. (Updated)",
|
|
67
|
+
* phone: "123-456-7890",
|
|
68
|
+
* employeeCount: 101,
|
|
69
|
+
* annualRevenue: 1000001
|
|
70
|
+
* })
|
|
65
71
|
*/
|
|
66
72
|
update(customerId: string, request: Paid.CustomerUpdate, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
|
|
67
73
|
private __update;
|
|
@@ -111,7 +111,8 @@ class Customers {
|
|
|
111
111
|
*
|
|
112
112
|
* @example
|
|
113
113
|
* await client.customers.create({
|
|
114
|
-
* name: "
|
|
114
|
+
* name: "Acme, Inc.",
|
|
115
|
+
* externalId: "acme-inc"
|
|
115
116
|
* })
|
|
116
117
|
*/
|
|
117
118
|
create(request, requestOptions) {
|
|
@@ -212,7 +213,12 @@ class Customers {
|
|
|
212
213
|
* @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
|
|
213
214
|
*
|
|
214
215
|
* @example
|
|
215
|
-
* await client.customers.update("customerId", {
|
|
216
|
+
* await client.customers.update("customerId", {
|
|
217
|
+
* name: "Acme, Inc. (Updated)",
|
|
218
|
+
* phone: "123-456-7890",
|
|
219
|
+
* employeeCount: 101,
|
|
220
|
+
* annualRevenue: 1000001
|
|
221
|
+
* })
|
|
216
222
|
*/
|
|
217
223
|
update(customerId, request, requestOptions) {
|
|
218
224
|
return core.HttpResponsePromise.fromPromise(this.__update(customerId, request, requestOptions));
|
|
@@ -44,11 +44,12 @@ export declare class Orders {
|
|
|
44
44
|
*
|
|
45
45
|
* @example
|
|
46
46
|
* await client.orders.create({
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* startDate: "
|
|
51
|
-
*
|
|
47
|
+
* customerExternalId: "acme-inc",
|
|
48
|
+
* name: "Acme Order",
|
|
49
|
+
* description: "Acme Order is an order for Acme, Inc.",
|
|
50
|
+
* startDate: "2025-01-01",
|
|
51
|
+
* endDate: "2026-01-01",
|
|
52
|
+
* currency: "USD"
|
|
52
53
|
* })
|
|
53
54
|
*/
|
|
54
55
|
create(request: Paid.OrderCreate, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.Order>;
|
|
@@ -116,11 +116,12 @@ class Orders {
|
|
|
116
116
|
*
|
|
117
117
|
* @example
|
|
118
118
|
* await client.orders.create({
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* startDate: "
|
|
123
|
-
*
|
|
119
|
+
* customerExternalId: "acme-inc",
|
|
120
|
+
* name: "Acme Order",
|
|
121
|
+
* description: "Acme Order is an order for Acme, Inc.",
|
|
122
|
+
* startDate: "2025-01-01",
|
|
123
|
+
* endDate: "2026-01-01",
|
|
124
|
+
* currency: "USD"
|
|
124
125
|
* })
|
|
125
126
|
*/
|
|
126
127
|
create(request, requestOptions) {
|
|
@@ -5,17 +5,18 @@ import * as Paid from "../../../../index.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* {
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* startDate: "
|
|
12
|
-
*
|
|
8
|
+
* customerExternalId: "acme-inc",
|
|
9
|
+
* name: "Acme Order",
|
|
10
|
+
* description: "Acme Order is an order for Acme, Inc.",
|
|
11
|
+
* startDate: "2025-01-01",
|
|
12
|
+
* endDate: "2026-01-01",
|
|
13
|
+
* currency: "USD"
|
|
13
14
|
* }
|
|
14
15
|
*/
|
|
15
16
|
export interface OrderCreate {
|
|
16
|
-
customerId
|
|
17
|
+
customerId?: string;
|
|
17
18
|
customerExternalId?: string;
|
|
18
|
-
billingContactId
|
|
19
|
+
billingContactId?: string;
|
|
19
20
|
name: string;
|
|
20
21
|
description?: string;
|
|
21
22
|
startDate: string;
|