@paid-ai/paid-node 0.0.6 → 0.0.8
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/cjs/Client.d.ts +1 -1
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wrapper/BatchUsage.d.ts +8 -0
- package/dist/cjs/wrapper/BatchUsage.js +60 -0
- package/dist/esm/Client.d.mts +1 -1
- package/dist/esm/Client.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/dist/esm/wrapper/BatchUsage.d.mts +8 -0
- package/dist/esm/wrapper/BatchUsage.mjs +23 -0
- package/package.json +1 -1
package/dist/cjs/Client.d.ts
CHANGED
|
@@ -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 "./
|
|
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>;
|
package/dist/cjs/Client.js
CHANGED
|
@@ -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
|
|
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
|
|
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;
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.0.
|
|
1
|
+
export declare const SDK_VERSION = "0.0.8";
|
package/dist/cjs/version.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as core from "../core/index.js";
|
|
2
|
+
import { Usage as UsageClient } from "../api/resources/usage/client/Client";
|
|
3
|
+
import * as Paid from "../api/types/Signal.js";
|
|
4
|
+
export declare class Usage extends UsageClient {
|
|
5
|
+
private signals;
|
|
6
|
+
flush(requestOptions?: UsageClient.RequestOptions): core.HttpResponsePromise<unknown[]>;
|
|
7
|
+
recordUsage(signal?: Paid.Signal, requestOptions?: UsageClient.RequestOptions): core.HttpResponsePromise<unknown[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Usage = void 0;
|
|
37
|
+
const core = __importStar(require("../core/index.js"));
|
|
38
|
+
const Client_1 = require("../api/resources/usage/client/Client");
|
|
39
|
+
class Usage extends Client_1.Usage {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.signals = [];
|
|
43
|
+
}
|
|
44
|
+
flush(requestOptions) {
|
|
45
|
+
return this.recordBulk({ signals: this.signals }, requestOptions);
|
|
46
|
+
}
|
|
47
|
+
recordUsage(signal = {}, requestOptions) {
|
|
48
|
+
if (!this.signals) {
|
|
49
|
+
this.signals = [];
|
|
50
|
+
}
|
|
51
|
+
this.signals.push(signal);
|
|
52
|
+
if (this.signals.length >= 100) {
|
|
53
|
+
const response = this.recordBulk({ signals: this.signals }, requestOptions);
|
|
54
|
+
this.signals = [];
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
return core.HttpResponsePromise.fromResult({ data: [], rawResponse: {} });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Usage = Usage;
|
package/dist/esm/Client.d.mts
CHANGED
|
@@ -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 "./
|
|
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>;
|
package/dist/esm/Client.mjs
CHANGED
|
@@ -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 "./
|
|
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({
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.0.
|
|
1
|
+
export declare const SDK_VERSION = "0.0.8";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.0.
|
|
1
|
+
export const SDK_VERSION = "0.0.8";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as core from "../core/index.mjs";
|
|
2
|
+
import { Usage as UsageClient } from "../api/resources/usage/client/Client";
|
|
3
|
+
import * as Paid from "../api/types/Signal.mjs";
|
|
4
|
+
export declare class Usage extends UsageClient {
|
|
5
|
+
private signals;
|
|
6
|
+
flush(requestOptions?: UsageClient.RequestOptions): core.HttpResponsePromise<unknown[]>;
|
|
7
|
+
recordUsage(signal?: Paid.Signal, requestOptions?: UsageClient.RequestOptions): core.HttpResponsePromise<unknown[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as core from "../core/index.mjs";
|
|
2
|
+
import { Usage as UsageClient } from "../api/resources/usage/client/Client";
|
|
3
|
+
export class Usage extends UsageClient {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.signals = [];
|
|
7
|
+
}
|
|
8
|
+
flush(requestOptions) {
|
|
9
|
+
return this.recordBulk({ signals: this.signals }, requestOptions);
|
|
10
|
+
}
|
|
11
|
+
recordUsage(signal = {}, requestOptions) {
|
|
12
|
+
if (!this.signals) {
|
|
13
|
+
this.signals = [];
|
|
14
|
+
}
|
|
15
|
+
this.signals.push(signal);
|
|
16
|
+
if (this.signals.length >= 100) {
|
|
17
|
+
const response = this.recordBulk({ signals: this.signals }, requestOptions);
|
|
18
|
+
this.signals = [];
|
|
19
|
+
return response;
|
|
20
|
+
}
|
|
21
|
+
return core.HttpResponsePromise.fromResult({ data: [], rawResponse: {} });
|
|
22
|
+
}
|
|
23
|
+
}
|