@paid-ai/paid-node 1.0.0 → 1.0.1-alpha1
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/BaseClient.d.ts +4 -17
- package/dist/cjs/BaseClient.js +0 -59
- package/dist/cjs/Client.d.ts +28 -28
- package/dist/cjs/Client.js +52 -11
- package/dist/cjs/api/errors/BadRequestError.js +1 -5
- package/dist/cjs/api/errors/ForbiddenError.js +1 -5
- package/dist/cjs/api/errors/InternalServerError.js +1 -5
- package/dist/cjs/api/errors/NotFoundError.js +1 -5
- package/dist/cjs/api/resources/agents/client/Client.d.ts +23 -22
- package/dist/cjs/api/resources/agents/client/Client.js +158 -55
- package/dist/cjs/api/resources/contacts/client/Client.d.ts +19 -18
- package/dist/cjs/api/resources/contacts/client/Client.js +122 -43
- package/dist/cjs/api/resources/customers/client/Client.d.ts +37 -36
- package/dist/cjs/api/resources/customers/client/Client.js +315 -113
- package/dist/cjs/api/resources/orders/client/Client.d.ts +28 -27
- package/dist/cjs/api/resources/orders/client/Client.js +177 -62
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +9 -8
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +32 -13
- package/dist/cjs/api/resources/plans/client/Client.d.ts +25 -12
- package/dist/cjs/api/resources/plans/client/Client.js +143 -33
- package/dist/cjs/api/resources/products/client/Client.d.ts +23 -22
- package/dist/cjs/api/resources/products/client/Client.js +158 -55
- package/dist/cjs/api/resources/products/client/requests/index.d.ts +1 -1
- package/dist/cjs/api/resources/products/client/requests/index.js +0 -3
- package/dist/cjs/api/resources/traces/client/Client.d.ts +9 -8
- package/dist/cjs/api/resources/traces/client/Client.js +57 -23
- package/dist/cjs/api/resources/usage/client/Client.d.ts +16 -15
- package/dist/cjs/api/resources/usage/client/Client.js +71 -28
- package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.ts +3 -3
- package/dist/cjs/api/types/PlanWithFeatures.d.ts +34 -0
- package/dist/cjs/api/types/PlanWithFeatures.js +3 -0
- package/dist/cjs/api/types/SignalV2.d.ts +5 -5
- package/dist/cjs/api/types/index.d.ts +1 -0
- package/dist/cjs/api/types/index.js +1 -0
- package/dist/cjs/core/auth/AuthProvider.d.ts +1 -4
- package/dist/cjs/core/auth/BearerToken.d.ts +1 -3
- package/dist/cjs/core/auth/BearerToken.js +6 -7
- package/dist/cjs/core/auth/index.d.ts +0 -1
- package/dist/cjs/core/auth/index.js +1 -3
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +7 -6
- package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +2 -2
- package/dist/cjs/core/fetcher/Fetcher.d.ts +4 -10
- package/dist/cjs/core/fetcher/Fetcher.js +10 -204
- package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +4 -0
- package/dist/cjs/core/fetcher/ResponseWithBody.js +6 -0
- package/dist/cjs/core/fetcher/getRequestBody.d.ts +1 -1
- package/dist/cjs/core/fetcher/getRequestBody.js +0 -4
- package/dist/cjs/core/fetcher/getResponseBody.js +4 -18
- package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
- package/dist/cjs/core/fetcher/makeRequest.js +2 -0
- package/dist/cjs/core/fetcher/requestWithRetries.js +9 -0
- package/dist/cjs/core/fetcher/signals.d.ts +7 -1
- package/dist/cjs/core/fetcher/signals.js +12 -0
- package/dist/cjs/core/headers.d.ts +2 -2
- package/dist/cjs/core/headers.js +4 -6
- package/dist/cjs/core/index.d.ts +0 -1
- package/dist/cjs/core/index.js +1 -2
- package/dist/cjs/core/runtime/runtime.js +10 -11
- package/dist/cjs/core/url/join.js +1 -0
- package/dist/cjs/errors/PaidError.js +1 -5
- package/dist/cjs/errors/PaidTimeoutError.js +1 -5
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +0 -4
- package/dist/cjs/integrations/adapters/expressjs/index.d.ts +2 -2
- package/dist/cjs/integrations/adapters/expressjs/index.js +2 -1
- package/dist/cjs/integrations/adapters/expressjs/routes.d.ts +16 -0
- package/dist/cjs/integrations/adapters/expressjs/routes.js +28 -0
- package/dist/cjs/integrations/adapters/nextjs/index.d.ts +1 -1
- package/dist/cjs/integrations/adapters/nextjs/index.js +2 -1
- package/dist/cjs/integrations/adapters/nextjs/routes.d.ts +15 -0
- package/dist/cjs/integrations/adapters/nextjs/routes.js +21 -0
- package/dist/cjs/integrations/controllers/index.d.ts +1 -0
- package/dist/cjs/integrations/controllers/index.js +3 -1
- package/dist/cjs/integrations/controllers/orders.js +52 -17
- package/dist/cjs/integrations/controllers/plans.d.ts +50 -0
- package/dist/cjs/integrations/controllers/plans.js +88 -0
- package/dist/cjs/integrations/types.d.ts +5 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +4 -17
- package/dist/esm/BaseClient.mjs +1 -24
- package/dist/esm/Client.d.mts +28 -28
- package/dist/esm/Client.mjs +27 -19
- package/dist/esm/api/errors/BadRequestError.mjs +1 -5
- package/dist/esm/api/errors/ForbiddenError.mjs +1 -5
- package/dist/esm/api/errors/InternalServerError.mjs +1 -5
- package/dist/esm/api/errors/NotFoundError.mjs +1 -5
- package/dist/esm/api/resources/agents/client/Client.d.mts +23 -22
- package/dist/esm/api/resources/agents/client/Client.mjs +157 -54
- package/dist/esm/api/resources/contacts/client/Client.d.mts +19 -18
- package/dist/esm/api/resources/contacts/client/Client.mjs +121 -42
- package/dist/esm/api/resources/customers/client/Client.d.mts +37 -36
- package/dist/esm/api/resources/customers/client/Client.mjs +314 -112
- package/dist/esm/api/resources/orders/client/Client.d.mts +28 -27
- package/dist/esm/api/resources/orders/client/Client.mjs +177 -62
- package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +9 -8
- package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +31 -12
- package/dist/esm/api/resources/plans/client/Client.d.mts +25 -12
- package/dist/esm/api/resources/plans/client/Client.mjs +142 -32
- package/dist/esm/api/resources/products/client/Client.d.mts +23 -22
- package/dist/esm/api/resources/products/client/Client.mjs +157 -54
- package/dist/esm/api/resources/products/client/requests/index.d.mts +1 -1
- package/dist/esm/api/resources/products/client/requests/index.mjs +1 -1
- package/dist/esm/api/resources/traces/client/Client.d.mts +9 -8
- package/dist/esm/api/resources/traces/client/Client.mjs +56 -22
- package/dist/esm/api/resources/usage/client/Client.d.mts +16 -15
- package/dist/esm/api/resources/usage/client/Client.mjs +70 -27
- package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.mts +3 -3
- package/dist/esm/api/types/PlanWithFeatures.d.mts +34 -0
- package/dist/esm/api/types/PlanWithFeatures.mjs +2 -0
- package/dist/esm/api/types/SignalV2.d.mts +5 -5
- package/dist/esm/api/types/index.d.mts +1 -0
- package/dist/esm/api/types/index.mjs +1 -0
- package/dist/esm/core/auth/AuthProvider.d.mts +1 -4
- package/dist/esm/core/auth/BearerToken.d.mts +1 -3
- package/dist/esm/core/auth/BearerToken.mjs +6 -7
- package/dist/esm/core/auth/index.d.mts +0 -1
- package/dist/esm/core/auth/index.mjs +0 -1
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +7 -6
- package/dist/esm/core/fetcher/EndpointSupplier.d.mts +2 -2
- package/dist/esm/core/fetcher/Fetcher.d.mts +4 -10
- package/dist/esm/core/fetcher/Fetcher.mjs +10 -204
- package/dist/esm/core/fetcher/ResponseWithBody.d.mts +4 -0
- package/dist/esm/core/fetcher/ResponseWithBody.mjs +3 -0
- package/dist/esm/core/fetcher/getRequestBody.d.mts +1 -1
- package/dist/esm/core/fetcher/getRequestBody.mjs +0 -4
- package/dist/esm/core/fetcher/getResponseBody.mjs +4 -18
- package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
- package/dist/esm/core/fetcher/makeRequest.mjs +2 -0
- package/dist/esm/core/fetcher/requestWithRetries.mjs +9 -0
- package/dist/esm/core/fetcher/signals.d.mts +7 -1
- package/dist/esm/core/fetcher/signals.mjs +12 -0
- package/dist/esm/core/headers.d.mts +2 -2
- package/dist/esm/core/headers.mjs +4 -6
- package/dist/esm/core/index.d.mts +0 -1
- package/dist/esm/core/index.mjs +0 -1
- package/dist/esm/core/runtime/runtime.mjs +10 -11
- package/dist/esm/core/url/join.mjs +1 -0
- package/dist/esm/errors/PaidError.mjs +1 -5
- package/dist/esm/errors/PaidTimeoutError.mjs +1 -5
- package/dist/esm/index.d.mts +0 -1
- package/dist/esm/index.mjs +0 -1
- package/dist/esm/integrations/adapters/expressjs/index.d.mts +2 -2
- package/dist/esm/integrations/adapters/expressjs/index.mjs +2 -2
- package/dist/esm/integrations/adapters/expressjs/routes.d.mts +16 -0
- package/dist/esm/integrations/adapters/expressjs/routes.mjs +27 -0
- package/dist/esm/integrations/adapters/nextjs/index.d.mts +1 -1
- package/dist/esm/integrations/adapters/nextjs/index.mjs +1 -1
- package/dist/esm/integrations/adapters/nextjs/routes.d.mts +15 -0
- package/dist/esm/integrations/adapters/nextjs/routes.mjs +20 -0
- package/dist/esm/integrations/controllers/index.d.mts +1 -0
- package/dist/esm/integrations/controllers/index.mjs +1 -0
- package/dist/esm/integrations/controllers/orders.mjs +52 -17
- package/dist/esm/integrations/controllers/plans.d.mts +50 -0
- package/dist/esm/integrations/controllers/plans.mjs +84 -0
- package/dist/esm/integrations/types.d.mts +5 -2
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +38 -7
- package/reference.md +106 -57
- package/dist/cjs/auth/BearerAuthProvider.d.ts +0 -20
- package/dist/cjs/auth/BearerAuthProvider.js +0 -79
- package/dist/cjs/auth/index.d.ts +0 -1
- package/dist/cjs/auth/index.js +0 -5
- package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +0 -5
- package/dist/cjs/core/auth/NoOpAuthProvider.js +0 -9
- package/dist/cjs/core/exports.d.ts +0 -1
- package/dist/cjs/core/exports.js +0 -17
- package/dist/cjs/core/logging/exports.d.ts +0 -18
- package/dist/cjs/core/logging/exports.js +0 -45
- package/dist/cjs/core/logging/index.d.ts +0 -1
- package/dist/cjs/core/logging/index.js +0 -17
- package/dist/cjs/core/logging/logger.d.ts +0 -126
- package/dist/cjs/core/logging/logger.js +0 -144
- package/dist/cjs/errors/handleNonStatusCodeError.d.ts +0 -2
- package/dist/cjs/errors/handleNonStatusCodeError.js +0 -65
- package/dist/cjs/exports.d.ts +0 -1
- package/dist/cjs/exports.js +0 -17
- package/dist/esm/auth/BearerAuthProvider.d.mts +0 -20
- package/dist/esm/auth/BearerAuthProvider.mjs +0 -42
- package/dist/esm/auth/index.d.mts +0 -1
- package/dist/esm/auth/index.mjs +0 -1
- package/dist/esm/core/auth/NoOpAuthProvider.d.mts +0 -5
- package/dist/esm/core/auth/NoOpAuthProvider.mjs +0 -5
- package/dist/esm/core/exports.d.mts +0 -1
- package/dist/esm/core/exports.mjs +0 -1
- package/dist/esm/core/logging/exports.d.mts +0 -18
- package/dist/esm/core/logging/exports.mjs +0 -9
- package/dist/esm/core/logging/index.d.mts +0 -1
- package/dist/esm/core/logging/index.mjs +0 -1
- package/dist/esm/core/logging/logger.d.mts +0 -126
- package/dist/esm/core/logging/logger.mjs +0 -138
- package/dist/esm/errors/handleNonStatusCodeError.d.mts +0 -2
- package/dist/esm/errors/handleNonStatusCodeError.mjs +0 -29
- package/dist/esm/exports.d.mts +0 -1
- package/dist/esm/exports.mjs +0 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Drop-in handlers for ExpressJS controllers using Express Request/Response
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createSetupIntentRoute = exports.createProvisioningRoute = exports.createPayInvoiceRoute = exports.createOrdersRoute = exports.createGetCustomerRoute = exports.createCustomersRoute = exports.createCustomerInvoicesRoute = exports.createContactsRoute = exports.createActivateOrderSyncRoute = exports.createExpressJSResponseContext = exports.expressjsAdapter = void 0;
|
|
7
|
+
exports.createSetupIntentRoute = exports.createProvisioningRoute = exports.createPayInvoiceRoute = exports.createOrdersRoute = exports.createGetPlanGroupByIdRoute = exports.createGetCustomerRoute = exports.createCustomersRoute = exports.createCustomerInvoicesRoute = exports.createContactsRoute = exports.createActivateOrderSyncRoute = exports.createExpressJSResponseContext = exports.expressjsAdapter = void 0;
|
|
8
8
|
var base_adapter_js_1 = require("./base-adapter.js");
|
|
9
9
|
Object.defineProperty(exports, "expressjsAdapter", { enumerable: true, get: function () { return base_adapter_js_1.expressjsAdapter; } });
|
|
10
10
|
Object.defineProperty(exports, "createExpressJSResponseContext", { enumerable: true, get: function () { return base_adapter_js_1.createExpressJSResponseContext; } });
|
|
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "createContactsRoute", { enumerable: true, get: f
|
|
|
14
14
|
Object.defineProperty(exports, "createCustomerInvoicesRoute", { enumerable: true, get: function () { return routes_js_1.createCustomerInvoicesRoute; } });
|
|
15
15
|
Object.defineProperty(exports, "createCustomersRoute", { enumerable: true, get: function () { return routes_js_1.createCustomersRoute; } });
|
|
16
16
|
Object.defineProperty(exports, "createGetCustomerRoute", { enumerable: true, get: function () { return routes_js_1.createGetCustomerRoute; } });
|
|
17
|
+
Object.defineProperty(exports, "createGetPlanGroupByIdRoute", { enumerable: true, get: function () { return routes_js_1.createGetPlanGroupByIdRoute; } });
|
|
17
18
|
Object.defineProperty(exports, "createOrdersRoute", { enumerable: true, get: function () { return routes_js_1.createOrdersRoute; } });
|
|
18
19
|
Object.defineProperty(exports, "createPayInvoiceRoute", { enumerable: true, get: function () { return routes_js_1.createPayInvoiceRoute; } });
|
|
19
20
|
Object.defineProperty(exports, "createProvisioningRoute", { enumerable: true, get: function () { return routes_js_1.createProvisioningRoute; } });
|
|
@@ -161,4 +161,20 @@ export interface SetupIntentRouteConfig extends BaseHandlerConfig {
|
|
|
161
161
|
* ```
|
|
162
162
|
*/
|
|
163
163
|
export declare function createSetupIntentRoute(config?: SetupIntentRouteConfig): ExpressHandler;
|
|
164
|
+
/**
|
|
165
|
+
* Create an Express handler for getting a plan group by ID
|
|
166
|
+
*
|
|
167
|
+
* @param config - Handler configuration options
|
|
168
|
+
* @returns Express route handler function
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* import express from 'express';
|
|
173
|
+
* import { createGetPlanGroupByIdRoute } from '@paid-ai/paid-node/integrations/express';
|
|
174
|
+
*
|
|
175
|
+
* const app = express();
|
|
176
|
+
* app.get('/paid/plans/:planGroupId', createGetPlanGroupByIdRoute());
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export declare function createGetPlanGroupByIdRoute(config?: BaseHandlerConfig): (req: Request, res: Response) => Promise<any>;
|
|
164
180
|
export {};
|
|
@@ -13,6 +13,7 @@ exports.createOrdersRoute = createOrdersRoute;
|
|
|
13
13
|
exports.createPayInvoiceRoute = createPayInvoiceRoute;
|
|
14
14
|
exports.createProvisioningRoute = createProvisioningRoute;
|
|
15
15
|
exports.createSetupIntentRoute = createSetupIntentRoute;
|
|
16
|
+
exports.createGetPlanGroupByIdRoute = createGetPlanGroupByIdRoute;
|
|
16
17
|
const base_adapter_js_1 = require("./base-adapter.js");
|
|
17
18
|
const contacts_js_1 = require("../../controllers/contacts.js");
|
|
18
19
|
const invoices_js_1 = require("../../controllers/invoices.js");
|
|
@@ -20,6 +21,7 @@ const customers_js_1 = require("../../controllers/customers.js");
|
|
|
20
21
|
const orders_js_1 = require("../../controllers/orders.js");
|
|
21
22
|
const provision_users_js_1 = require("../../controllers/provision-users.js");
|
|
22
23
|
const billing_js_1 = require("../../controllers/billing.js");
|
|
24
|
+
const plans_js_1 = require("../../controllers/plans.js");
|
|
23
25
|
/**
|
|
24
26
|
* Helper to extract headers from Express Request
|
|
25
27
|
*/
|
|
@@ -276,3 +278,29 @@ function createSetupIntentRoute(config = {}) {
|
|
|
276
278
|
};
|
|
277
279
|
return route;
|
|
278
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Create an Express handler for getting a plan group by ID
|
|
283
|
+
*
|
|
284
|
+
* @param config - Handler configuration options
|
|
285
|
+
* @returns Express route handler function
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* import express from 'express';
|
|
290
|
+
* import { createGetPlanGroupByIdRoute } from '@paid-ai/paid-node/integrations/express';
|
|
291
|
+
*
|
|
292
|
+
* const app = express();
|
|
293
|
+
* app.get('/paid/plans/:planGroupId', createGetPlanGroupByIdRoute());
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
function createGetPlanGroupByIdRoute(config = {}) {
|
|
297
|
+
const handler = (0, plans_js_1.createGetPlanGroupByIdHandler)();
|
|
298
|
+
return (req, res) => {
|
|
299
|
+
return handler({
|
|
300
|
+
body: req.body,
|
|
301
|
+
headers: extractHeaders(req),
|
|
302
|
+
method: "GET",
|
|
303
|
+
params: req.params,
|
|
304
|
+
}, (0, base_adapter_js_1.createExpressJSResponseContext)(res), config);
|
|
305
|
+
};
|
|
306
|
+
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Next.js API Route handlers for Paid integration
|
|
3
3
|
* Drop-in handlers for Next.js App Router
|
|
4
4
|
*/
|
|
5
|
-
export { createActivateOrderSyncRoute, createContactsRoute, createCustomerInvoicesRoute, createCustomersRoute, createGetCustomerRoute, createOrdersRoute, createPayInvoiceRoute, createProvisioningRoute, createSetupIntentRoute, type ActivateOrderSyncRouteConfig, type OrdersRouteConfig, type ProvisioningRouteConfig, type SetupIntentRouteConfig, } from
|
|
5
|
+
export { createActivateOrderSyncRoute, createContactsRoute, createCustomerInvoicesRoute, createCustomersRoute, createGetCustomerRoute, createGetPlanGroupByIdRoute, createOrdersRoute, createPayInvoiceRoute, createProvisioningRoute, createSetupIntentRoute, type ActivateOrderSyncRouteConfig, type OrdersRouteConfig, type ProvisioningRouteConfig, type SetupIntentRouteConfig, } from "./routes.js";
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* Drop-in handlers for Next.js App Router
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createSetupIntentRoute = exports.createProvisioningRoute = exports.createPayInvoiceRoute = exports.createOrdersRoute = exports.createGetCustomerRoute = exports.createCustomersRoute = exports.createCustomerInvoicesRoute = exports.createContactsRoute = exports.createActivateOrderSyncRoute = void 0;
|
|
7
|
+
exports.createSetupIntentRoute = exports.createProvisioningRoute = exports.createPayInvoiceRoute = exports.createOrdersRoute = exports.createGetPlanGroupByIdRoute = exports.createGetCustomerRoute = exports.createCustomersRoute = exports.createCustomerInvoicesRoute = exports.createContactsRoute = exports.createActivateOrderSyncRoute = void 0;
|
|
8
8
|
var routes_js_1 = require("./routes.js");
|
|
9
9
|
Object.defineProperty(exports, "createActivateOrderSyncRoute", { enumerable: true, get: function () { return routes_js_1.createActivateOrderSyncRoute; } });
|
|
10
10
|
Object.defineProperty(exports, "createContactsRoute", { enumerable: true, get: function () { return routes_js_1.createContactsRoute; } });
|
|
11
11
|
Object.defineProperty(exports, "createCustomerInvoicesRoute", { enumerable: true, get: function () { return routes_js_1.createCustomerInvoicesRoute; } });
|
|
12
12
|
Object.defineProperty(exports, "createCustomersRoute", { enumerable: true, get: function () { return routes_js_1.createCustomersRoute; } });
|
|
13
13
|
Object.defineProperty(exports, "createGetCustomerRoute", { enumerable: true, get: function () { return routes_js_1.createGetCustomerRoute; } });
|
|
14
|
+
Object.defineProperty(exports, "createGetPlanGroupByIdRoute", { enumerable: true, get: function () { return routes_js_1.createGetPlanGroupByIdRoute; } });
|
|
14
15
|
Object.defineProperty(exports, "createOrdersRoute", { enumerable: true, get: function () { return routes_js_1.createOrdersRoute; } });
|
|
15
16
|
Object.defineProperty(exports, "createPayInvoiceRoute", { enumerable: true, get: function () { return routes_js_1.createPayInvoiceRoute; } });
|
|
16
17
|
Object.defineProperty(exports, "createProvisioningRoute", { enumerable: true, get: function () { return routes_js_1.createProvisioningRoute; } });
|
|
@@ -224,4 +224,19 @@ export interface SetupIntentRouteConfig extends BaseHandlerConfig {
|
|
|
224
224
|
* ```
|
|
225
225
|
*/
|
|
226
226
|
export declare function createSetupIntentRoute(config?: SetupIntentRouteConfig): NextJsHandler;
|
|
227
|
+
/**
|
|
228
|
+
* Create a Next.js API route handler for getting a plan group by ID
|
|
229
|
+
*
|
|
230
|
+
* @param config - Handler configuration options
|
|
231
|
+
* @returns Next.js route handler function
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* // src/app/api/plans/[planGroupId]/route.ts
|
|
236
|
+
* import { createGetPlanGroupByIdRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
237
|
+
*
|
|
238
|
+
* export const GET = createGetPlanGroupByIdRoute();
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export declare function createGetPlanGroupByIdRoute(config?: BaseHandlerConfig): (request: any, context?: any) => Promise<any>;
|
|
227
242
|
export {};
|
|
@@ -9,6 +9,7 @@ exports.createOrdersRoute = createOrdersRoute;
|
|
|
9
9
|
exports.createPayInvoiceRoute = createPayInvoiceRoute;
|
|
10
10
|
exports.createProvisioningRoute = createProvisioningRoute;
|
|
11
11
|
exports.createSetupIntentRoute = createSetupIntentRoute;
|
|
12
|
+
exports.createGetPlanGroupByIdRoute = createGetPlanGroupByIdRoute;
|
|
12
13
|
const base_adapter_js_1 = require("./base-adapter.js");
|
|
13
14
|
const contacts_js_1 = require("../../controllers/contacts.js");
|
|
14
15
|
const invoices_js_1 = require("../../controllers/invoices.js");
|
|
@@ -16,6 +17,7 @@ const customers_js_1 = require("../../controllers/customers.js");
|
|
|
16
17
|
const orders_js_1 = require("../../controllers/orders.js");
|
|
17
18
|
const provision_users_js_1 = require("../../controllers/provision-users.js");
|
|
18
19
|
const billing_js_1 = require("../../controllers/billing.js");
|
|
20
|
+
const plans_js_1 = require("../../controllers/plans.js");
|
|
19
21
|
/**
|
|
20
22
|
* Create a Next.js API route handler for synchronous order activation
|
|
21
23
|
*
|
|
@@ -253,3 +255,22 @@ function createSetupIntentRoute(config = {}) {
|
|
|
253
255
|
const route = (request, context) => adaptedHandler(request, context, config);
|
|
254
256
|
return route;
|
|
255
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Create a Next.js API route handler for getting a plan group by ID
|
|
260
|
+
*
|
|
261
|
+
* @param config - Handler configuration options
|
|
262
|
+
* @returns Next.js route handler function
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* // src/app/api/plans/[planGroupId]/route.ts
|
|
267
|
+
* import { createGetPlanGroupByIdRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
268
|
+
*
|
|
269
|
+
* export const GET = createGetPlanGroupByIdRoute();
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
function createGetPlanGroupByIdRoute(config = {}) {
|
|
273
|
+
const handler = (0, plans_js_1.createGetPlanGroupByIdHandler)();
|
|
274
|
+
const adaptedHandler = (0, base_adapter_js_1.nextjsAdapter)(handler);
|
|
275
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
276
|
+
}
|
|
@@ -4,3 +4,4 @@ export { createOrder, createOrderWithDefaults, createOrdersHandler, } from "./or
|
|
|
4
4
|
export { payInvoice, createPayInvoiceHandler, type PayInvoiceConfig, type PayInvoiceRequest, type PayInvoiceResult, activateOrderSync, createActivateOrderSyncHandler, type ActivateOrderSyncConfig, type ActivateOrderSyncRequest, type ActivateOrderSyncResult, createSetupIntent, createSetupIntentHandler, type SetupIntentConfig, type SetupIntentRequest, type SetupIntentResponse, } from "./billing.js";
|
|
5
5
|
export { getCustomerInvoices, createCustomerInvoicesHandler, type CustomerInvoicesResult, } from "./invoices.js";
|
|
6
6
|
export { provisionNewUser, createProvisioningHandler, } from "./provision-users.js";
|
|
7
|
+
export { createGetPlanGroupByIdHandler, } from "./plans.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createProvisioningHandler = exports.provisionNewUser = exports.createCustomerInvoicesHandler = exports.getCustomerInvoices = exports.createSetupIntentHandler = exports.createSetupIntent = exports.createActivateOrderSyncHandler = exports.activateOrderSync = exports.createPayInvoiceHandler = exports.payInvoice = exports.createOrdersHandler = exports.createOrderWithDefaults = exports.createOrder = exports.createContactsHandler = exports.createContactWithDefaults = exports.createContact = exports.createCustomersHandler = exports.createGetCustomerHandler = exports.getCustomer = exports.createCustomerWithDefaults = exports.createCustomer = void 0;
|
|
3
|
+
exports.createGetPlanGroupByIdHandler = exports.createProvisioningHandler = exports.provisionNewUser = exports.createCustomerInvoicesHandler = exports.getCustomerInvoices = exports.createSetupIntentHandler = exports.createSetupIntent = exports.createActivateOrderSyncHandler = exports.activateOrderSync = exports.createPayInvoiceHandler = exports.payInvoice = exports.createOrdersHandler = exports.createOrderWithDefaults = exports.createOrder = exports.createContactsHandler = exports.createContactWithDefaults = exports.createContact = exports.createCustomersHandler = exports.createGetCustomerHandler = exports.getCustomer = exports.createCustomerWithDefaults = exports.createCustomer = void 0;
|
|
4
4
|
var customers_js_1 = require("./customers.js");
|
|
5
5
|
Object.defineProperty(exports, "createCustomer", { enumerable: true, get: function () { return customers_js_1.createCustomer; } });
|
|
6
6
|
Object.defineProperty(exports, "createCustomerWithDefaults", { enumerable: true, get: function () { return customers_js_1.createCustomerWithDefaults; } });
|
|
@@ -28,3 +28,5 @@ Object.defineProperty(exports, "createCustomerInvoicesHandler", { enumerable: tr
|
|
|
28
28
|
var provision_users_js_1 = require("./provision-users.js");
|
|
29
29
|
Object.defineProperty(exports, "provisionNewUser", { enumerable: true, get: function () { return provision_users_js_1.provisionNewUser; } });
|
|
30
30
|
Object.defineProperty(exports, "createProvisioningHandler", { enumerable: true, get: function () { return provision_users_js_1.createProvisioningHandler; } });
|
|
31
|
+
var plans_js_1 = require("./plans.js");
|
|
32
|
+
Object.defineProperty(exports, "createGetPlanGroupByIdHandler", { enumerable: true, get: function () { return plans_js_1.createGetPlanGroupByIdHandler; } });
|
|
@@ -13,11 +13,17 @@ exports.createOrderWithDefaults = createOrderWithDefaults;
|
|
|
13
13
|
exports.createOrder = createOrder;
|
|
14
14
|
exports.createOrdersHandler = createOrdersHandler;
|
|
15
15
|
const base_handler_js_1 = require("../utils/base-handler.js");
|
|
16
|
+
const plans_js_1 = require("./plans.js");
|
|
17
|
+
function hasProductWithExternalId(pp) {
|
|
18
|
+
if (!pp.product) {
|
|
19
|
+
throw new Error(`Plan product ${pp.id} is missing nested product data`);
|
|
20
|
+
}
|
|
21
|
+
return !!pp.product.externalId;
|
|
22
|
+
}
|
|
16
23
|
/**
|
|
17
24
|
* Generate default values for missing order fields
|
|
18
25
|
*/
|
|
19
26
|
function generateOrderDefaults(config, options = {}) {
|
|
20
|
-
var _a;
|
|
21
27
|
const { defaultDurationDays = 365 } = options;
|
|
22
28
|
const startDate = config.startDate || new Date().toISOString().split("T")[0];
|
|
23
29
|
const endDate = config.endDate ||
|
|
@@ -27,20 +33,31 @@ function generateOrderDefaults(config, options = {}) {
|
|
|
27
33
|
const name = config.name || "Subscription Order";
|
|
28
34
|
const description = config.description || "Annual subscription";
|
|
29
35
|
const currency = config.currency || "USD";
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
// defensive guard
|
|
37
|
+
if (!config.orderLines && !config.planId && !config.agentExternalId) {
|
|
38
|
+
throw new Error("Either orderLines, planId, or agentExternalId must be provided");
|
|
39
|
+
}
|
|
40
|
+
const orderLines = config.orderLines
|
|
41
|
+
? config.orderLines.map(line => {
|
|
42
|
+
var _a;
|
|
43
|
+
return ({
|
|
44
|
+
agentExternalId: line.agentExternalId,
|
|
45
|
+
name: line.name || name,
|
|
46
|
+
description: line.description || description,
|
|
47
|
+
planProductId: (_a = line.planProductId) !== null && _a !== void 0 ? _a : undefined,
|
|
48
|
+
});
|
|
49
|
+
})
|
|
50
|
+
: [{
|
|
51
|
+
agentExternalId: config.agentExternalId,
|
|
52
|
+
name,
|
|
53
|
+
description,
|
|
54
|
+
}];
|
|
39
55
|
return {
|
|
40
56
|
customerId: config.customerId,
|
|
41
57
|
customerExternalId: config.customerExternalId,
|
|
42
58
|
billingContactId: config.billingContactId,
|
|
43
59
|
agentExternalId: config.agentExternalId,
|
|
60
|
+
planId: config.planId,
|
|
44
61
|
name,
|
|
45
62
|
description,
|
|
46
63
|
startDate,
|
|
@@ -69,8 +86,12 @@ function createAndActivateOrder(client, config, autoActivate) {
|
|
|
69
86
|
orderLine.name = line.name;
|
|
70
87
|
if (line.description)
|
|
71
88
|
orderLine.description = line.description;
|
|
89
|
+
// planProductId is not in the create orders api spec - this is functioning but greptile will complain
|
|
90
|
+
if (line.planProductId)
|
|
91
|
+
orderLine.planProductId = line.planProductId;
|
|
72
92
|
return orderLine;
|
|
73
93
|
}),
|
|
94
|
+
planId: config.planId,
|
|
74
95
|
});
|
|
75
96
|
if (!order.id) {
|
|
76
97
|
throw new Error("Order created but missing ID");
|
|
@@ -177,18 +198,32 @@ function createOrder(client_1, config_1) {
|
|
|
177
198
|
*/
|
|
178
199
|
function createOrdersHandler(helperOptions) {
|
|
179
200
|
return (0, base_handler_js_1.createHandler)((client, body) => __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
var _a, _b;
|
|
181
|
-
if (!body.customerId) {
|
|
182
|
-
throw new Error("customerId is required");
|
|
183
|
-
}
|
|
201
|
+
var _a, _b, _c;
|
|
184
202
|
if (!body.customerExternalId) {
|
|
185
203
|
throw new Error("customerExternalId is required");
|
|
186
204
|
}
|
|
187
|
-
if (!body.agentExternalId) {
|
|
188
|
-
throw new Error("agentExternalId
|
|
205
|
+
if (!body.agentExternalId && !body.planId) {
|
|
206
|
+
throw new Error("agentExternalId or planId are required");
|
|
189
207
|
}
|
|
190
208
|
const orderOptions = Object.assign(Object.assign({}, helperOptions), { autoActivate: (_b = (_a = body.autoActivate) !== null && _a !== void 0 ? _a : helperOptions === null || helperOptions === void 0 ? void 0 : helperOptions.autoActivate) !== null && _b !== void 0 ? _b : true });
|
|
209
|
+
if (body.planId) {
|
|
210
|
+
const plan = yield (0, plans_js_1.getPlanById)(client, body.planId);
|
|
211
|
+
if (!((_c = plan.planProducts) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
212
|
+
throw new Error(`Plan ${body.planId} has no products`);
|
|
213
|
+
}
|
|
214
|
+
body.orderLines = plan.planProducts
|
|
215
|
+
.filter(hasProductWithExternalId)
|
|
216
|
+
.map((pp) => ({
|
|
217
|
+
agentExternalId: pp.product.externalId,
|
|
218
|
+
name: pp.product.name,
|
|
219
|
+
description: pp.product.description,
|
|
220
|
+
planProductId: pp.id,
|
|
221
|
+
}));
|
|
222
|
+
if (body.orderLines.length === 0) {
|
|
223
|
+
throw new Error(`Plan ${body.planId} has no products with externalId`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
191
226
|
const order = yield createOrderWithDefaults(client, body, orderOptions);
|
|
192
227
|
return { success: true, data: order };
|
|
193
|
-
}), { requiredFields: ['
|
|
228
|
+
}), { requiredFields: ['customerExternalId'] });
|
|
194
229
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PaidClient } from "../../Client.js";
|
|
2
|
+
import type { PlanGroup } from "../../api/types/PlanGroup.js";
|
|
3
|
+
import type { Plan } from "../../api/types/Plan.js";
|
|
4
|
+
/**
|
|
5
|
+
* Get a plan by ID
|
|
6
|
+
*
|
|
7
|
+
* @param client - PaidClient instance
|
|
8
|
+
* @param planId - Plan's ID
|
|
9
|
+
* @returns Plan data
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const plan = await getPlanById(client, 'plan-123');
|
|
14
|
+
* console.log(plan.name, plan.id);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function getPlanById(client: PaidClient, planId: string): Promise<Plan>;
|
|
18
|
+
/**
|
|
19
|
+
* Get a plan group by ID
|
|
20
|
+
*
|
|
21
|
+
* @param client - PaidClient instance
|
|
22
|
+
* @param planGroupId - Plan group's ID
|
|
23
|
+
* @returns Plan group data
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const planGroup = await getPlanGroupById(client, 'plan-group-123');
|
|
28
|
+
* console.log(planGroup.name, planGroup.id);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getPlanGroupById(client: PaidClient, planGroupId: string): Promise<PlanGroup>;
|
|
32
|
+
/**
|
|
33
|
+
* Create a framework-agnostic handler for fetching a plan group by ID
|
|
34
|
+
*
|
|
35
|
+
* This handler can be used with any framework adapter.
|
|
36
|
+
* The plan group ID should be provided either in params or query string.
|
|
37
|
+
*
|
|
38
|
+
* @returns Handler function
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // In Next.js route: /api/plans/[planGroupId]/route.ts
|
|
43
|
+
* import { createGetPlanGroupByIdHandler } from '@paid-ai/paid-node/integrations';
|
|
44
|
+
* import { nextjsAdapter } from '@paid-ai/paid-node/integrations/nextjs';
|
|
45
|
+
*
|
|
46
|
+
* const handler = createGetPlanGroupByIdHandler();
|
|
47
|
+
* export const GET = nextjsAdapter(handler);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function createGetPlanGroupByIdHandler(): (request: any, response: any, config?: any) => Promise<any>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getPlanById = getPlanById;
|
|
13
|
+
exports.getPlanGroupById = getPlanGroupById;
|
|
14
|
+
exports.createGetPlanGroupByIdHandler = createGetPlanGroupByIdHandler;
|
|
15
|
+
const base_handler_js_1 = require("../utils/base-handler.js");
|
|
16
|
+
/**
|
|
17
|
+
* Get a plan by ID
|
|
18
|
+
*
|
|
19
|
+
* @param client - PaidClient instance
|
|
20
|
+
* @param planId - Plan's ID
|
|
21
|
+
* @returns Plan data
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const plan = await getPlanById(client, 'plan-123');
|
|
26
|
+
* console.log(plan.name, plan.id);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function getPlanById(client, planId) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const plan = yield client.plans.getById(planId);
|
|
32
|
+
return plan;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get a plan group by ID
|
|
37
|
+
*
|
|
38
|
+
* @param client - PaidClient instance
|
|
39
|
+
* @param planGroupId - Plan group's ID
|
|
40
|
+
* @returns Plan group data
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const planGroup = await getPlanGroupById(client, 'plan-group-123');
|
|
45
|
+
* console.log(planGroup.name, planGroup.id);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
function getPlanGroupById(client, planGroupId) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const planGroup = yield client.plans.getGroupById(planGroupId);
|
|
51
|
+
return planGroup;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a framework-agnostic handler for fetching a plan group by ID
|
|
56
|
+
*
|
|
57
|
+
* This handler can be used with any framework adapter.
|
|
58
|
+
* The plan group ID should be provided either in params or query string.
|
|
59
|
+
*
|
|
60
|
+
* @returns Handler function
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // In Next.js route: /api/plans/[planGroupId]/route.ts
|
|
65
|
+
* import { createGetPlanGroupByIdHandler } from '@paid-ai/paid-node/integrations';
|
|
66
|
+
* import { nextjsAdapter } from '@paid-ai/paid-node/integrations/nextjs';
|
|
67
|
+
*
|
|
68
|
+
* const handler = createGetPlanGroupByIdHandler();
|
|
69
|
+
* export const GET = nextjsAdapter(handler);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
function createGetPlanGroupByIdHandler() {
|
|
73
|
+
return (0, base_handler_js_1.createHandler)((client, _body, params) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const planGroupId = params === null || params === void 0 ? void 0 : params.planGroupId;
|
|
75
|
+
if (!planGroupId) {
|
|
76
|
+
return {
|
|
77
|
+
success: false,
|
|
78
|
+
error: "planGroupId is required",
|
|
79
|
+
status: 400,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const planGroup = yield getPlanGroupById(client, planGroupId);
|
|
83
|
+
return { success: true, data: planGroup };
|
|
84
|
+
}), {
|
|
85
|
+
allowedMethods: ['GET'],
|
|
86
|
+
requireOrganizationId: false,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -41,18 +41,20 @@ export interface OrderConfig {
|
|
|
41
41
|
customerId: string;
|
|
42
42
|
customerExternalId: string;
|
|
43
43
|
billingContactId?: string;
|
|
44
|
-
agentExternalId
|
|
44
|
+
agentExternalId?: string;
|
|
45
45
|
name?: string;
|
|
46
46
|
description?: string;
|
|
47
47
|
startDate?: string;
|
|
48
48
|
endDate?: string;
|
|
49
49
|
currency?: string;
|
|
50
50
|
orderLines?: OrderLineConfig[];
|
|
51
|
+
planId?: string;
|
|
51
52
|
}
|
|
52
53
|
export interface OrderLineConfig {
|
|
53
54
|
agentExternalId: string;
|
|
54
55
|
name?: string;
|
|
55
56
|
description?: string;
|
|
57
|
+
planProductId?: string;
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Note: orderLines is not required because if agentExternalId is provided,
|
|
@@ -62,13 +64,14 @@ export interface CompleteOrderConfig {
|
|
|
62
64
|
customerId: string;
|
|
63
65
|
customerExternalId: string;
|
|
64
66
|
billingContactId?: string;
|
|
65
|
-
agentExternalId
|
|
67
|
+
agentExternalId?: string;
|
|
66
68
|
name: string;
|
|
67
69
|
description: string;
|
|
68
70
|
startDate: string;
|
|
69
71
|
endDate: string;
|
|
70
72
|
currency: string;
|
|
71
73
|
orderLines: OrderLineConfig[];
|
|
74
|
+
planId?: string;
|
|
72
75
|
}
|
|
73
76
|
export interface OrderOptions {
|
|
74
77
|
/**
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.1-alpha1";
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as core from "./core/index.mjs";
|
|
1
|
+
import type * as core from "./core/index.mjs";
|
|
3
2
|
import type * as environments from "./environments.mjs";
|
|
4
|
-
export
|
|
3
|
+
export interface BaseClientOptions {
|
|
5
4
|
environment?: core.Supplier<environments.PaidEnvironment | string>;
|
|
6
5
|
/** Specify a custom URL to connect the client to. */
|
|
7
6
|
baseUrl?: core.Supplier<string>;
|
|
7
|
+
token?: core.Supplier<core.BearerToken | undefined>;
|
|
8
8
|
/** Additional headers to include in requests. */
|
|
9
9
|
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
10
10
|
/** The default maximum time to wait for a response in seconds. */
|
|
11
11
|
timeoutInSeconds?: number;
|
|
12
12
|
/** The default number of times to retry the request. Defaults to 2. */
|
|
13
13
|
maxRetries?: number;
|
|
14
|
-
|
|
15
|
-
fetch?: typeof fetch;
|
|
16
|
-
/** Configure logging for the client. */
|
|
17
|
-
logging?: core.logging.LogConfig | core.logging.Logger;
|
|
18
|
-
} & BearerAuthProvider.AuthOptions;
|
|
14
|
+
}
|
|
19
15
|
export interface BaseRequestOptions {
|
|
20
16
|
/** The maximum time to wait for a response in seconds. */
|
|
21
17
|
timeoutInSeconds?: number;
|
|
@@ -28,12 +24,3 @@ export interface BaseRequestOptions {
|
|
|
28
24
|
/** Additional headers to include in the request. */
|
|
29
25
|
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
30
26
|
}
|
|
31
|
-
export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
|
|
32
|
-
logging: core.logging.Logger;
|
|
33
|
-
authProvider?: core.AuthProvider;
|
|
34
|
-
};
|
|
35
|
-
export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions> = NormalizedClientOptions<T> & {
|
|
36
|
-
authProvider: core.AuthProvider;
|
|
37
|
-
};
|
|
38
|
-
export declare function normalizeClientOptions<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptions<T>;
|
|
39
|
-
export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
|
package/dist/esm/BaseClient.mjs
CHANGED
|
@@ -1,25 +1,2 @@
|
|
|
1
1
|
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
|
|
3
|
-
import { mergeHeaders } from "./core/headers.mjs";
|
|
4
|
-
import * as core from "./core/index.mjs";
|
|
5
|
-
export function normalizeClientOptions(options) {
|
|
6
|
-
const headers = mergeHeaders({
|
|
7
|
-
"X-Fern-Language": "JavaScript",
|
|
8
|
-
"X-Fern-SDK-Name": "@paid-ai/paid-node",
|
|
9
|
-
"X-Fern-SDK-Version": "1.0.0",
|
|
10
|
-
"User-Agent": "@paid-ai/paid-node/1.0.0",
|
|
11
|
-
"X-Fern-Runtime": core.RUNTIME.type,
|
|
12
|
-
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
13
|
-
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
14
|
-
return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
|
|
15
|
-
}
|
|
16
|
-
export function normalizeClientOptionsWithAuth(options) {
|
|
17
|
-
var _a;
|
|
18
|
-
const normalized = normalizeClientOptions(options);
|
|
19
|
-
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
20
|
-
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new BearerAuthProvider(normalizedWithNoOpAuthProvider));
|
|
21
|
-
return normalized;
|
|
22
|
-
}
|
|
23
|
-
function withNoOpAuthProvider(options) {
|
|
24
|
-
return Object.assign(Object.assign({}, options), { authProvider: new core.NoOpAuthProvider() });
|
|
25
|
-
}
|
|
2
|
+
export {};
|
package/dist/esm/Client.d.mts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { Agents } from "./api/resources/agents/client/Client.mjs";
|
|
2
|
+
import { Contacts } from "./api/resources/contacts/client/Client.mjs";
|
|
3
|
+
import { Customers } from "./api/resources/customers/client/Client.mjs";
|
|
4
|
+
import { Orders } from "./api/resources/orders/client/Client.mjs";
|
|
5
|
+
import { Plans } from "./api/resources/plans/client/Client.mjs";
|
|
6
|
+
import { Products } from "./api/resources/products/client/Client.mjs";
|
|
7
|
+
import { Traces } from "./api/resources/traces/client/Client.mjs";
|
|
8
|
+
import { Usage } from "./api/resources/usage/client/Client.mjs";
|
|
9
9
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.mjs";
|
|
10
|
-
import { type NormalizedClientOptions } from "./BaseClient.mjs";
|
|
11
10
|
export declare namespace PaidClient {
|
|
12
|
-
|
|
11
|
+
interface Options extends BaseClientOptions {
|
|
12
|
+
}
|
|
13
13
|
interface RequestOptions extends BaseRequestOptions {
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
export declare class PaidClient {
|
|
17
|
-
protected readonly _options:
|
|
18
|
-
protected _customers:
|
|
19
|
-
protected _agents:
|
|
20
|
-
protected _products:
|
|
21
|
-
protected _contacts:
|
|
22
|
-
protected _orders:
|
|
23
|
-
protected _plans:
|
|
24
|
-
protected _usage:
|
|
25
|
-
protected _traces:
|
|
26
|
-
constructor(
|
|
27
|
-
get customers():
|
|
28
|
-
get agents():
|
|
29
|
-
get products():
|
|
30
|
-
get contacts():
|
|
31
|
-
get orders():
|
|
32
|
-
get plans():
|
|
33
|
-
get usage():
|
|
34
|
-
get traces():
|
|
17
|
+
protected readonly _options: PaidClient.Options;
|
|
18
|
+
protected _customers: Customers | undefined;
|
|
19
|
+
protected _agents: Agents | undefined;
|
|
20
|
+
protected _products: Products | undefined;
|
|
21
|
+
protected _contacts: Contacts | undefined;
|
|
22
|
+
protected _orders: Orders | undefined;
|
|
23
|
+
protected _plans: Plans | undefined;
|
|
24
|
+
protected _usage: Usage | undefined;
|
|
25
|
+
protected _traces: Traces | undefined;
|
|
26
|
+
constructor(_options?: PaidClient.Options);
|
|
27
|
+
get customers(): Customers;
|
|
28
|
+
get agents(): Agents;
|
|
29
|
+
get products(): Products;
|
|
30
|
+
get contacts(): Contacts;
|
|
31
|
+
get orders(): Orders;
|
|
32
|
+
get plans(): Plans;
|
|
33
|
+
get usage(): Usage;
|
|
34
|
+
get traces(): Traces;
|
|
35
35
|
}
|