@paid-ai/paid-node 0.0.6 → 0.0.7

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.
@@ -7,7 +7,7 @@ import { Customers } from "./api/resources/customers/client/Client.js";
7
7
  import { Agents } from "./api/resources/agents/client/Client.js";
8
8
  import { Contacts } from "./api/resources/contacts/client/Client.js";
9
9
  import { Orders } from "./api/resources/orders/client/Client.js";
10
- import { Usage } from "./api/resources/usage/client/Client.js";
10
+ import { Usage } from "./wrapper/BatchUsage.js";
11
11
  export declare namespace PaidClient {
12
12
  interface Options {
13
13
  environment?: core.Supplier<environments.PaidEnvironment | string>;
@@ -43,7 +43,7 @@ const Client_js_1 = require("./api/resources/customers/client/Client.js");
43
43
  const Client_js_2 = require("./api/resources/agents/client/Client.js");
44
44
  const Client_js_3 = require("./api/resources/contacts/client/Client.js");
45
45
  const Client_js_4 = require("./api/resources/orders/client/Client.js");
46
- const Client_js_5 = require("./api/resources/usage/client/Client.js");
46
+ const BatchUsage_js_1 = require("./wrapper/BatchUsage.js");
47
47
  class PaidClient {
48
48
  constructor(_options) {
49
49
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
@@ -73,7 +73,7 @@ class PaidClient {
73
73
  }
74
74
  get usage() {
75
75
  var _a;
76
- return ((_a = this._usage) !== null && _a !== void 0 ? _a : (this._usage = new Client_js_5.Usage(this._options)));
76
+ return ((_a = this._usage) !== null && _a !== void 0 ? _a : (this._usage = new BatchUsage_js_1.Usage(this._options)));
77
77
  }
78
78
  }
79
79
  exports.PaidClient = PaidClient;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.0.6";
1
+ export declare const SDK_VERSION = "0.0.7";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.0.6";
4
+ exports.SDK_VERSION = "0.0.7";
@@ -0,0 +1,6 @@
1
+ import { Usage as UsageFernClient } from "../api/resources/usage/client/Client";
2
+ export declare class Usage extends UsageFernClient {
3
+ private signals;
4
+ flush(requestOptions?: any): Promise<unknown[]>;
5
+ recordUsage(signal: any, requestOptions?: any): void;
6
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Usage = void 0;
4
+ const Client_1 = require("../api/resources/usage/client/Client");
5
+ class Usage extends Client_1.Usage {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.signals = [];
9
+ }
10
+ flush(requestOptions) {
11
+ return this.recordBulk({ signals: this.signals }, requestOptions);
12
+ }
13
+ recordUsage(signal, requestOptions) {
14
+ if (!this.signals) {
15
+ this.signals = [];
16
+ }
17
+ this.signals.push(signal);
18
+ if (this.signals.length >= 100) {
19
+ this.recordBulk({ signals: this.signals }, requestOptions);
20
+ this.signals = [];
21
+ }
22
+ }
23
+ }
24
+ exports.Usage = Usage;
@@ -7,7 +7,7 @@ import { Customers } from "./api/resources/customers/client/Client.mjs";
7
7
  import { Agents } from "./api/resources/agents/client/Client.mjs";
8
8
  import { Contacts } from "./api/resources/contacts/client/Client.mjs";
9
9
  import { Orders } from "./api/resources/orders/client/Client.mjs";
10
- import { Usage } from "./api/resources/usage/client/Client.mjs";
10
+ import { Usage } from "./wrapper/BatchUsage.mjs";
11
11
  export declare namespace PaidClient {
12
12
  interface Options {
13
13
  environment?: core.Supplier<environments.PaidEnvironment | string>;
@@ -7,7 +7,7 @@ import { Customers } from "./api/resources/customers/client/Client.mjs";
7
7
  import { Agents } from "./api/resources/agents/client/Client.mjs";
8
8
  import { Contacts } from "./api/resources/contacts/client/Client.mjs";
9
9
  import { Orders } from "./api/resources/orders/client/Client.mjs";
10
- import { Usage } from "./api/resources/usage/client/Client.mjs";
10
+ import { Usage } from "./wrapper/BatchUsage.mjs";
11
11
  export class PaidClient {
12
12
  constructor(_options) {
13
13
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.0.6";
1
+ export declare const SDK_VERSION = "0.0.7";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.0.6";
1
+ export const SDK_VERSION = "0.0.7";
@@ -0,0 +1,6 @@
1
+ import { Usage as UsageFernClient } from "../api/resources/usage/client/Client";
2
+ export declare class Usage extends UsageFernClient {
3
+ private signals;
4
+ flush(requestOptions?: any): Promise<unknown[]>;
5
+ recordUsage(signal: any, requestOptions?: any): void;
6
+ }
@@ -0,0 +1,20 @@
1
+ import { Usage as UsageFernClient } from "../api/resources/usage/client/Client";
2
+ export class Usage extends UsageFernClient {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.signals = [];
6
+ }
7
+ flush(requestOptions) {
8
+ return this.recordBulk({ signals: this.signals }, requestOptions);
9
+ }
10
+ recordUsage(signal, requestOptions) {
11
+ if (!this.signals) {
12
+ this.signals = [];
13
+ }
14
+ this.signals.push(signal);
15
+ if (this.signals.length >= 100) {
16
+ this.recordBulk({ signals: this.signals }, requestOptions);
17
+ this.signals = [];
18
+ }
19
+ }
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paid-ai/paid-node",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "private": false,
5
5
  "repository": "https://github.com/AgentPaid/paid-node",
6
6
  "type": "commonjs",