@paid-ai/paid-node 1.0.1-alpha2 → 1.0.1-alpha5

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.
Files changed (77) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/Client.js +2 -2
  3. package/dist/cjs/api/resources/index.d.ts +1 -0
  4. package/dist/cjs/api/resources/index.js +1 -0
  5. package/dist/cjs/api/resources/plans/client/Client.d.ts +17 -0
  6. package/dist/cjs/api/resources/plans/client/Client.js +70 -0
  7. package/dist/cjs/api/resources/plans/client/requests/PlansGetCurrentRequest.d.ts +15 -0
  8. package/dist/cjs/api/resources/plans/client/requests/PlansGetCurrentRequest.js +3 -0
  9. package/dist/cjs/api/resources/plans/client/requests/index.d.ts +1 -0
  10. package/dist/cjs/api/resources/plans/index.d.ts +1 -0
  11. package/dist/cjs/api/resources/plans/index.js +1 -0
  12. package/dist/cjs/api/resources/plans/types/PlansGetCurrentResponse.d.ts +83 -0
  13. package/dist/cjs/api/resources/plans/types/PlansGetCurrentResponse.js +16 -0
  14. package/dist/cjs/api/resources/plans/types/index.d.ts +1 -0
  15. package/dist/cjs/api/resources/plans/types/index.js +17 -0
  16. package/dist/cjs/api/types/Plan.d.ts +1 -24
  17. package/dist/cjs/api/types/Plan.js +0 -9
  18. package/dist/cjs/api/types/PlanPricing.d.ts +23 -0
  19. package/dist/cjs/api/types/PlanPricing.js +15 -0
  20. package/dist/cjs/api/types/PlanWithFeatures.d.ts +2 -24
  21. package/dist/cjs/api/types/PlanWithFeatures.js +0 -9
  22. package/dist/cjs/api/types/index.d.ts +1 -0
  23. package/dist/cjs/api/types/index.js +1 -0
  24. package/dist/cjs/integrations/adapters/nextjs/index.d.ts +1 -1
  25. package/dist/cjs/integrations/adapters/nextjs/index.js +2 -1
  26. package/dist/cjs/integrations/adapters/nextjs/routes.d.ts +16 -0
  27. package/dist/cjs/integrations/adapters/nextjs/routes.js +21 -0
  28. package/dist/cjs/integrations/controllers/index.d.ts +1 -1
  29. package/dist/cjs/integrations/controllers/index.js +3 -1
  30. package/dist/cjs/integrations/controllers/plans.d.ts +40 -0
  31. package/dist/cjs/integrations/controllers/plans.js +62 -0
  32. package/dist/cjs/tracing/autoInstrumentation.d.ts +1 -1
  33. package/dist/cjs/tracing/autoInstrumentation.js +115 -39
  34. package/dist/cjs/tracing/signal.js +1 -4
  35. package/dist/cjs/tracing/spanProcessor.js +12 -0
  36. package/dist/cjs/tracing/tracing.js +3 -6
  37. package/dist/cjs/version.d.ts +1 -1
  38. package/dist/cjs/version.js +1 -1
  39. package/dist/esm/Client.mjs +2 -2
  40. package/dist/esm/api/resources/index.d.mts +1 -0
  41. package/dist/esm/api/resources/index.mjs +1 -0
  42. package/dist/esm/api/resources/plans/client/Client.d.mts +17 -0
  43. package/dist/esm/api/resources/plans/client/Client.mjs +70 -0
  44. package/dist/esm/api/resources/plans/client/requests/PlansGetCurrentRequest.d.mts +15 -0
  45. package/dist/esm/api/resources/plans/client/requests/PlansGetCurrentRequest.mjs +2 -0
  46. package/dist/esm/api/resources/plans/client/requests/index.d.mts +1 -0
  47. package/dist/esm/api/resources/plans/index.d.mts +1 -0
  48. package/dist/esm/api/resources/plans/index.mjs +1 -0
  49. package/dist/esm/api/resources/plans/types/PlansGetCurrentResponse.d.mts +83 -0
  50. package/dist/esm/api/resources/plans/types/PlansGetCurrentResponse.mjs +13 -0
  51. package/dist/esm/api/resources/plans/types/index.d.mts +1 -0
  52. package/dist/esm/api/resources/plans/types/index.mjs +1 -0
  53. package/dist/esm/api/types/Plan.d.mts +1 -24
  54. package/dist/esm/api/types/Plan.mjs +0 -9
  55. package/dist/esm/api/types/PlanPricing.d.mts +23 -0
  56. package/dist/esm/api/types/PlanPricing.mjs +12 -0
  57. package/dist/esm/api/types/PlanWithFeatures.d.mts +2 -24
  58. package/dist/esm/api/types/PlanWithFeatures.mjs +0 -9
  59. package/dist/esm/api/types/index.d.mts +1 -0
  60. package/dist/esm/api/types/index.mjs +1 -0
  61. package/dist/esm/integrations/adapters/nextjs/index.d.mts +1 -1
  62. package/dist/esm/integrations/adapters/nextjs/index.mjs +1 -1
  63. package/dist/esm/integrations/adapters/nextjs/routes.d.mts +16 -0
  64. package/dist/esm/integrations/adapters/nextjs/routes.mjs +21 -1
  65. package/dist/esm/integrations/controllers/index.d.mts +1 -1
  66. package/dist/esm/integrations/controllers/index.mjs +1 -1
  67. package/dist/esm/integrations/controllers/plans.d.mts +40 -0
  68. package/dist/esm/integrations/controllers/plans.mjs +60 -0
  69. package/dist/esm/tracing/autoInstrumentation.d.mts +1 -1
  70. package/dist/esm/tracing/autoInstrumentation.mjs +82 -39
  71. package/dist/esm/tracing/signal.mjs +1 -4
  72. package/dist/esm/tracing/spanProcessor.mjs +12 -0
  73. package/dist/esm/tracing/tracing.mjs +3 -6
  74. package/dist/esm/version.d.mts +1 -1
  75. package/dist/esm/version.mjs +1 -1
  76. package/package.json +1 -1
  77. package/reference.md +65 -0
package/README.md CHANGED
@@ -142,7 +142,7 @@ For maximum convenience, you can use OpenTelemetry auto-instrumentation to autom
142
142
  ``` typescript
143
143
  // Import and call auto-instrumentation before importing instrumented libraries
144
144
  import { paidAutoInstrument } from "@paid-ai/paid-node/tracing";
145
- paidAutoInstrument()
145
+ await paidAutoInstrument()
146
146
 
147
147
  import openai from "openai";
148
148
 
@@ -192,7 +192,7 @@ import openai from "openai";
192
192
 
193
193
  // If your module management is too complex and the previous approach didn't work
194
194
  // you can provide libraries directly
195
- paidAutoInstrument({ openai })
195
+ await paidAutoInstrument({ openai })
196
196
  ```
197
197
 
198
198
 
@@ -310,7 +310,7 @@ async function main() {
310
310
 
311
311
  await trace({
312
312
  externalCustomerId: "<your_external_customer_id>",
313
- externalAgentId: "<your_external_agent_id>"
313
+ externalProductId: "<your_external_product_id>"
314
314
  }, async () => {
315
315
  // ...do some work...
316
316
  signal("<your_signal_name>", false, {
@@ -367,7 +367,7 @@ async function main() {
367
367
 
368
368
  await trace({
369
369
  externalCustomerId: "<your_external_customer_id>",
370
- externalAgentId: "<your_external_agent_id>"
370
+ externalProductId: "<your_external_product_id>"
371
371
  }, async () => {
372
372
  // ...do some work...
373
373
  signal("<your_signal_name>", false, {
@@ -50,8 +50,8 @@ class PaidClient {
50
50
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
51
51
  "X-Fern-Language": "JavaScript",
52
52
  "X-Fern-SDK-Name": "@paid-ai/paid-node",
53
- "X-Fern-SDK-Version": "1.0.1-alpha2",
54
- "User-Agent": "@paid-ai/paid-node/1.0.1-alpha2",
53
+ "X-Fern-SDK-Version": "1.0.1-alpha5",
54
+ "User-Agent": "@paid-ai/paid-node/1.0.1-alpha5",
55
55
  "X-Fern-Runtime": core.RUNTIME.type,
56
56
  "X-Fern-Runtime-Version": core.RUNTIME.version,
57
57
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -9,6 +9,7 @@ export * from "./orders/client/requests/index.js";
9
9
  export * as orders from "./orders/index.js";
10
10
  export * from "./plans/client/requests/index.js";
11
11
  export * as plans from "./plans/index.js";
12
+ export * from "./plans/types/index.js";
12
13
  export * from "./products/client/requests/index.js";
13
14
  export * as products from "./products/index.js";
14
15
  export * from "./traces/client/requests/index.js";
@@ -48,6 +48,7 @@ __exportStar(require("./orders/client/requests/index.js"), exports);
48
48
  exports.orders = __importStar(require("./orders/index.js"));
49
49
  __exportStar(require("./plans/client/requests/index.js"), exports);
50
50
  exports.plans = __importStar(require("./plans/index.js"));
51
+ __exportStar(require("./plans/types/index.js"), exports);
51
52
  __exportStar(require("./products/client/requests/index.js"), exports);
52
53
  exports.products = __importStar(require("./products/index.js"));
53
54
  __exportStar(require("./traces/client/requests/index.js"), exports);
@@ -10,6 +10,23 @@ export declare namespace Plans {
10
10
  export declare class Plans {
11
11
  protected readonly _options: Plans.Options;
12
12
  constructor(_options?: Plans.Options);
13
+ /**
14
+ * Retrieves the currently active plan subscription for a customer by their external ID. Returns the plan details and subscription information.
15
+ *
16
+ * @param {Paid.PlansGetCurrentRequest} request
17
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
18
+ *
19
+ * @throws {@link Paid.BadRequestError}
20
+ * @throws {@link Paid.ForbiddenError}
21
+ * @throws {@link Paid.NotFoundError}
22
+ *
23
+ * @example
24
+ * await client.plans.getCurrent({
25
+ * customerExternalId: "customerExternalId"
26
+ * })
27
+ */
28
+ getCurrent(request: Paid.PlansGetCurrentRequest, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.PlansGetCurrentResponse>;
29
+ private __getCurrent;
13
30
  /**
14
31
  * @param {string} planId - The ID of the plan
15
32
  * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
@@ -53,6 +53,76 @@ class Plans {
53
53
  constructor(_options = {}) {
54
54
  this._options = _options;
55
55
  }
56
+ /**
57
+ * Retrieves the currently active plan subscription for a customer by their external ID. Returns the plan details and subscription information.
58
+ *
59
+ * @param {Paid.PlansGetCurrentRequest} request
60
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
61
+ *
62
+ * @throws {@link Paid.BadRequestError}
63
+ * @throws {@link Paid.ForbiddenError}
64
+ * @throws {@link Paid.NotFoundError}
65
+ *
66
+ * @example
67
+ * await client.plans.getCurrent({
68
+ * customerExternalId: "customerExternalId"
69
+ * })
70
+ */
71
+ getCurrent(request, requestOptions) {
72
+ return core.HttpResponsePromise.fromPromise(this.__getCurrent(request, requestOptions));
73
+ }
74
+ __getCurrent(request, requestOptions) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ var _a, _b, _c, _d, _e, _f, _g, _h;
77
+ const { customerExternalId } = request;
78
+ const _queryParams = {};
79
+ _queryParams.customerExternalId = customerExternalId;
80
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
81
+ const _response = yield core.fetcher({
82
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, "plans/current"),
83
+ method: "GET",
84
+ headers: _headers,
85
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
86
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
87
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
88
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
89
+ });
90
+ if (_response.ok) {
91
+ return { data: _response.body, rawResponse: _response.rawResponse };
92
+ }
93
+ if (_response.error.reason === "status-code") {
94
+ switch (_response.error.statusCode) {
95
+ case 400:
96
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
97
+ case 403:
98
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
99
+ case 404:
100
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
101
+ default:
102
+ throw new errors.PaidError({
103
+ statusCode: _response.error.statusCode,
104
+ body: _response.error.body,
105
+ rawResponse: _response.rawResponse,
106
+ });
107
+ }
108
+ }
109
+ switch (_response.error.reason) {
110
+ case "non-json":
111
+ throw new errors.PaidError({
112
+ statusCode: _response.error.statusCode,
113
+ body: _response.error.rawBody,
114
+ rawResponse: _response.rawResponse,
115
+ });
116
+ case "timeout":
117
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /plans/current.");
118
+ case "unknown":
119
+ throw new errors.PaidError({
120
+ message: _response.error.errorMessage,
121
+ rawResponse: _response.rawResponse,
122
+ });
123
+ }
124
+ });
125
+ }
56
126
  /**
57
127
  * @param {string} planId - The ID of the plan
58
128
  * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * customerExternalId: "customerExternalId"
5
+ * }
6
+ *
7
+ * @example
8
+ * {
9
+ * customerExternalId: "customerExternalId"
10
+ * }
11
+ */
12
+ export interface PlansGetCurrentRequest {
13
+ /** The external ID of the customer */
14
+ customerExternalId: string;
15
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
+ export type { PlansGetCurrentRequest } from "./PlansGetCurrentRequest.js";
1
2
  export type { PlansGetUsageRequest } from "./PlansGetUsageRequest.js";
2
3
  export type { PlansSubscribeRequest } from "./PlansSubscribeRequest.js";
3
4
  export type { PlansUnsubscribeRequest } from "./PlansUnsubscribeRequest.js";
@@ -1 +1,2 @@
1
1
  export * from "./client/index.js";
2
+ export * from "./types/index.js";
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./client/index.js"), exports);
18
+ __exportStar(require("./types/index.js"), exports);
@@ -0,0 +1,83 @@
1
+ import type * as Paid from "../../../index.js";
2
+ export interface PlansGetCurrentResponse {
3
+ /** The plan details, or null if the customer has no active plan */
4
+ plan?: PlansGetCurrentResponse.Plan;
5
+ /** The subscription details, or null if the customer has no active plan */
6
+ subscription?: PlansGetCurrentResponse.Subscription;
7
+ }
8
+ export declare namespace PlansGetCurrentResponse {
9
+ /**
10
+ * The plan details, or null if the customer has no active plan
11
+ */
12
+ interface Plan {
13
+ /** The unique identifier of the plan */
14
+ id: string;
15
+ /** The name of the plan */
16
+ name: string;
17
+ /** The description of the plan */
18
+ description?: string;
19
+ /** The type of plan */
20
+ type: Plan.Type;
21
+ pricing: Paid.PlanPricing;
22
+ /** The plan group ID this plan belongs to */
23
+ planGroupId: string;
24
+ /** The ID of the next plan in the sequence */
25
+ nextPlanId?: string;
26
+ /** The ID of the previous plan in the sequence */
27
+ prevPlanId?: string;
28
+ /** The features (product-attribute pairs) included in this plan with usage and limits */
29
+ features: Plan.Features.Item[];
30
+ }
31
+ namespace Plan {
32
+ /** The type of plan */
33
+ const Type: {
34
+ readonly Flat: "flat";
35
+ readonly Usage: "usage";
36
+ readonly Credit: "credit";
37
+ };
38
+ type Type = (typeof Type)[keyof typeof Type];
39
+ type Features = Features.Item[];
40
+ namespace Features {
41
+ interface Item {
42
+ /** The name of the product */
43
+ productName: string;
44
+ /** The name of the product attribute */
45
+ attributeName: string;
46
+ /** The pricing configuration for this feature */
47
+ pricing: Record<string, unknown>;
48
+ /** Current usage and limits for this feature */
49
+ usage: Item.Usage;
50
+ }
51
+ namespace Item {
52
+ /**
53
+ * Current usage and limits for this feature
54
+ */
55
+ interface Usage {
56
+ /** The event name used to track usage for this feature */
57
+ eventName?: string;
58
+ /** The current usage quantity for this feature on the order */
59
+ currentUsage: number;
60
+ /** The usage limit for this feature (null if unlimited) */
61
+ limit?: number;
62
+ /** Whether this feature has unlimited usage */
63
+ isUnlimited: boolean;
64
+ }
65
+ }
66
+ }
67
+ }
68
+ /**
69
+ * The subscription details, or null if the customer has no active plan
70
+ */
71
+ interface Subscription {
72
+ /** The ID of the order */
73
+ orderId: string;
74
+ /** The display ID of the order */
75
+ orderDisplayId?: string;
76
+ /** The start date of the subscription */
77
+ startDate: string;
78
+ /** The end date of the subscription (null if ongoing) */
79
+ endDate?: string;
80
+ /** The total usage quantity across all features on this order */
81
+ totalUsage: number;
82
+ }
83
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PlansGetCurrentResponse = void 0;
5
+ var PlansGetCurrentResponse;
6
+ (function (PlansGetCurrentResponse) {
7
+ let Plan;
8
+ (function (Plan) {
9
+ /** The type of plan */
10
+ Plan.Type = {
11
+ Flat: "flat",
12
+ Usage: "usage",
13
+ Credit: "credit",
14
+ };
15
+ })(Plan = PlansGetCurrentResponse.Plan || (PlansGetCurrentResponse.Plan = {}));
16
+ })(PlansGetCurrentResponse || (exports.PlansGetCurrentResponse = PlansGetCurrentResponse = {}));
@@ -0,0 +1 @@
1
+ export * from "./PlansGetCurrentResponse.js";
@@ -0,0 +1,17 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./PlansGetCurrentResponse.js"), exports);
@@ -15,8 +15,7 @@ export interface Plan {
15
15
  description?: string;
16
16
  /** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
17
17
  type: Plan.Type;
18
- /** The pricing configuration for the plan */
19
- pricing: Plan.Pricing;
18
+ pricing: Paid.PlanPricing;
20
19
  /** The ID of the next plan in the sequence */
21
20
  nextPlanId?: string;
22
21
  /** The ID of the previous plan in the sequence */
@@ -36,28 +35,6 @@ export declare namespace Plan {
36
35
  readonly Credit: "credit";
37
36
  };
38
37
  type Type = (typeof Type)[keyof typeof Type];
39
- /**
40
- * The pricing configuration for the plan
41
- */
42
- interface Pricing {
43
- /** The currency code (e.g., "USD", "EUR") */
44
- currency: string;
45
- /** The fixed amount for flat plans (in smallest currency unit, e.g., cents) */
46
- amount?: number;
47
- /** The billing frequency for the plan */
48
- billingFrequency: Pricing.BillingFrequency;
49
- /** Custom billing frequency in months (if not using standard frequencies) */
50
- billingFrequencyCustomMonths?: number;
51
- }
52
- namespace Pricing {
53
- /** The billing frequency for the plan */
54
- const BillingFrequency: {
55
- readonly Monthly: "monthly";
56
- readonly Quarterly: "quarterly";
57
- readonly Annual: "annual";
58
- };
59
- type BillingFrequency = (typeof BillingFrequency)[keyof typeof BillingFrequency];
60
- }
61
38
  type PlanProducts = PlanProducts.Item[];
62
39
  namespace PlanProducts {
63
40
  interface Item {
@@ -10,13 +10,4 @@ var Plan;
10
10
  Usage: "usage",
11
11
  Credit: "credit",
12
12
  };
13
- let Pricing;
14
- (function (Pricing) {
15
- /** The billing frequency for the plan */
16
- Pricing.BillingFrequency = {
17
- Monthly: "monthly",
18
- Quarterly: "quarterly",
19
- Annual: "annual",
20
- };
21
- })(Pricing = Plan.Pricing || (Plan.Pricing = {}));
22
13
  })(Plan || (exports.Plan = Plan = {}));
@@ -0,0 +1,23 @@
1
+ import type * as Paid from "../index.js";
2
+ /**
3
+ * The pricing configuration for a plan. Uses the same PricePoints structure as product pricing.
4
+ */
5
+ export interface PlanPricing {
6
+ /** Price points keyed by currency code (e.g., "USD", "EUR") */
7
+ PricePoints: Record<string, Paid.PricePoint>;
8
+ /** The billing frequency for the plan */
9
+ billingFrequency: PlanPricing.BillingFrequency;
10
+ /** Custom billing frequency in months (when billingFrequency is "custom") */
11
+ billingFrequencyCustomMonths?: number;
12
+ }
13
+ export declare namespace PlanPricing {
14
+ /** The billing frequency for the plan */
15
+ const BillingFrequency: {
16
+ readonly Monthly: "monthly";
17
+ readonly Quarterly: "quarterly";
18
+ readonly SemiAnnually: "semi-annually";
19
+ readonly Yearly: "yearly";
20
+ readonly Custom: "custom";
21
+ };
22
+ type BillingFrequency = (typeof BillingFrequency)[keyof typeof BillingFrequency];
23
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PlanPricing = void 0;
5
+ var PlanPricing;
6
+ (function (PlanPricing) {
7
+ /** The billing frequency for the plan */
8
+ PlanPricing.BillingFrequency = {
9
+ Monthly: "monthly",
10
+ Quarterly: "quarterly",
11
+ SemiAnnually: "semi-annually",
12
+ Yearly: "yearly",
13
+ Custom: "custom",
14
+ };
15
+ })(PlanPricing || (exports.PlanPricing = PlanPricing = {}));
@@ -1,3 +1,4 @@
1
+ import type * as Paid from "../index.js";
1
2
  /**
2
3
  * A plan with its features (product-attribute pairs) for display
3
4
  */
@@ -10,8 +11,7 @@ export interface PlanWithFeatures {
10
11
  description?: string;
11
12
  /** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
12
13
  type: PlanWithFeatures.Type;
13
- /** The pricing configuration for the plan */
14
- pricing: PlanWithFeatures.Pricing;
14
+ pricing: Paid.PlanPricing;
15
15
  /** When the plan was created */
16
16
  createdAt: string;
17
17
  /** When the plan was last updated */
@@ -31,28 +31,6 @@ export declare namespace PlanWithFeatures {
31
31
  readonly Credit: "credit";
32
32
  };
33
33
  type Type = (typeof Type)[keyof typeof Type];
34
- /**
35
- * The pricing configuration for the plan
36
- */
37
- interface Pricing {
38
- /** The currency code (e.g., "USD", "EUR") */
39
- currency: string;
40
- /** The fixed amount for flat plans (in smallest currency unit, e.g., cents) */
41
- amount?: number;
42
- /** The billing frequency for the plan */
43
- billingFrequency: Pricing.BillingFrequency;
44
- /** Custom billing frequency in months (if not using standard frequencies) */
45
- billingFrequencyCustomMonths?: number;
46
- }
47
- namespace Pricing {
48
- /** The billing frequency for the plan */
49
- const BillingFrequency: {
50
- readonly Monthly: "monthly";
51
- readonly Quarterly: "quarterly";
52
- readonly Annual: "annual";
53
- };
54
- type BillingFrequency = (typeof BillingFrequency)[keyof typeof BillingFrequency];
55
- }
56
34
  type Features = Features.Item[];
57
35
  namespace Features {
58
36
  interface Item {
@@ -10,13 +10,4 @@ var PlanWithFeatures;
10
10
  Usage: "usage",
11
11
  Credit: "credit",
12
12
  };
13
- let Pricing;
14
- (function (Pricing) {
15
- /** The billing frequency for the plan */
16
- Pricing.BillingFrequency = {
17
- Monthly: "monthly",
18
- Quarterly: "quarterly",
19
- Annual: "annual",
20
- };
21
- })(Pricing = PlanWithFeatures.Pricing || (PlanWithFeatures.Pricing = {}));
22
13
  })(PlanWithFeatures || (exports.PlanWithFeatures = PlanWithFeatures = {}));
@@ -30,6 +30,7 @@ export * from "./PaginationMeta.js";
30
30
  export * from "./PaymentMethod.js";
31
31
  export * from "./Plan.js";
32
32
  export * from "./PlanGroup.js";
33
+ export * from "./PlanPricing.js";
33
34
  export * from "./PlanWithFeatures.js";
34
35
  export * from "./PricePoint.js";
35
36
  export * from "./Pricing.js";
@@ -46,6 +46,7 @@ __exportStar(require("./PaginationMeta.js"), exports);
46
46
  __exportStar(require("./PaymentMethod.js"), exports);
47
47
  __exportStar(require("./Plan.js"), exports);
48
48
  __exportStar(require("./PlanGroup.js"), exports);
49
+ __exportStar(require("./PlanPricing.js"), exports);
49
50
  __exportStar(require("./PlanWithFeatures.js"), exports);
50
51
  __exportStar(require("./PricePoint.js"), exports);
51
52
  __exportStar(require("./Pricing.js"), exports);
@@ -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, createGetPlanGroupByIdRoute, createGetGroupPlansRoute, createOrdersRoute, createPayInvoiceRoute, createProvisioningRoute, createSetupIntentRoute, createSubscribeRoute, createUnsubscribeRoute, createUpgradeRoute, type ActivateOrderSyncRouteConfig, type OrdersRouteConfig, type ProvisioningRouteConfig, type SetupIntentRouteConfig, } from "./routes.js";
5
+ export { createActivateOrderSyncRoute, createContactsRoute, createCustomerInvoicesRoute, createCustomersRoute, createGetCustomerRoute, createGetPlanGroupByIdRoute, createGetGroupPlansRoute, createGetCurrentRoute, createOrdersRoute, createPayInvoiceRoute, createProvisioningRoute, createSetupIntentRoute, createSubscribeRoute, createUnsubscribeRoute, createUpgradeRoute, type ActivateOrderSyncRouteConfig, type OrdersRouteConfig, type ProvisioningRouteConfig, type SetupIntentRouteConfig, } from "./routes.js";
@@ -4,7 +4,7 @@
4
4
  * Drop-in handlers for Next.js App Router
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createUpgradeRoute = exports.createUnsubscribeRoute = exports.createSubscribeRoute = exports.createSetupIntentRoute = exports.createProvisioningRoute = exports.createPayInvoiceRoute = exports.createOrdersRoute = exports.createGetGroupPlansRoute = exports.createGetPlanGroupByIdRoute = exports.createGetCustomerRoute = exports.createCustomersRoute = exports.createCustomerInvoicesRoute = exports.createContactsRoute = exports.createActivateOrderSyncRoute = void 0;
7
+ exports.createUpgradeRoute = exports.createUnsubscribeRoute = exports.createSubscribeRoute = exports.createSetupIntentRoute = exports.createProvisioningRoute = exports.createPayInvoiceRoute = exports.createOrdersRoute = exports.createGetCurrentRoute = exports.createGetGroupPlansRoute = 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; } });
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "createCustomersRoute", { enumerable: true, get:
13
13
  Object.defineProperty(exports, "createGetCustomerRoute", { enumerable: true, get: function () { return routes_js_1.createGetCustomerRoute; } });
14
14
  Object.defineProperty(exports, "createGetPlanGroupByIdRoute", { enumerable: true, get: function () { return routes_js_1.createGetPlanGroupByIdRoute; } });
15
15
  Object.defineProperty(exports, "createGetGroupPlansRoute", { enumerable: true, get: function () { return routes_js_1.createGetGroupPlansRoute; } });
16
+ Object.defineProperty(exports, "createGetCurrentRoute", { enumerable: true, get: function () { return routes_js_1.createGetCurrentRoute; } });
16
17
  Object.defineProperty(exports, "createOrdersRoute", { enumerable: true, get: function () { return routes_js_1.createOrdersRoute; } });
17
18
  Object.defineProperty(exports, "createPayInvoiceRoute", { enumerable: true, get: function () { return routes_js_1.createPayInvoiceRoute; } });
18
19
  Object.defineProperty(exports, "createProvisioningRoute", { enumerable: true, get: function () { return routes_js_1.createProvisioningRoute; } });
@@ -299,4 +299,20 @@ export declare function createUnsubscribeRoute(config?: BaseHandlerConfig): (req
299
299
  * ```
300
300
  */
301
301
  export declare function createUpgradeRoute(config?: BaseHandlerConfig): (request: any, context?: any) => Promise<any>;
302
+ /**
303
+ * Create a Next.js API route handler for getting a customer's current plan
304
+ *
305
+ * @param config - Handler configuration options
306
+ * @returns Next.js route handler function
307
+ *
308
+ * @example
309
+ * ```typescript
310
+ * // src/app/api/plans/current/[customerExternalId]/route.ts
311
+ * // GET /api/plans/current/customer-123
312
+ * import { createGetCurrentRoute } from '@paid-ai/paid-node/integrations/nextjs';
313
+ *
314
+ * export const GET = createGetCurrentRoute();
315
+ * ```
316
+ */
317
+ export declare function createGetCurrentRoute(config?: BaseHandlerConfig): (request: any, context?: any) => Promise<any>;
302
318
  export {};
@@ -14,6 +14,7 @@ exports.createGetGroupPlansRoute = createGetGroupPlansRoute;
14
14
  exports.createSubscribeRoute = createSubscribeRoute;
15
15
  exports.createUnsubscribeRoute = createUnsubscribeRoute;
16
16
  exports.createUpgradeRoute = createUpgradeRoute;
17
+ exports.createGetCurrentRoute = createGetCurrentRoute;
17
18
  const base_adapter_js_1 = require("./base-adapter.js");
18
19
  const contacts_js_1 = require("../../controllers/contacts.js");
19
20
  const invoices_js_1 = require("../../controllers/invoices.js");
@@ -354,3 +355,23 @@ function createUpgradeRoute(config = {}) {
354
355
  const adaptedHandler = (0, base_adapter_js_1.nextjsAdapter)(handler);
355
356
  return (request, context) => adaptedHandler(request, context, config);
356
357
  }
358
+ /**
359
+ * Create a Next.js API route handler for getting a customer's current plan
360
+ *
361
+ * @param config - Handler configuration options
362
+ * @returns Next.js route handler function
363
+ *
364
+ * @example
365
+ * ```typescript
366
+ * // src/app/api/plans/current/[customerExternalId]/route.ts
367
+ * // GET /api/plans/current/customer-123
368
+ * import { createGetCurrentRoute } from '@paid-ai/paid-node/integrations/nextjs';
369
+ *
370
+ * export const GET = createGetCurrentRoute();
371
+ * ```
372
+ */
373
+ function createGetCurrentRoute(config = {}) {
374
+ const handler = (0, plans_js_1.createGetCurrentHandler)();
375
+ const adaptedHandler = (0, base_adapter_js_1.nextjsAdapter)(handler);
376
+ return (request, context) => adaptedHandler(request, context, config);
377
+ }
@@ -4,4 +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 { getPlanById, getPlanGroupById, createGetPlanGroupByIdHandler, getGroupPlans, createGetGroupPlansHandler, subscribe, createSubscribeHandler, unsubscribe, createUnsubscribeHandler, upgrade, createUpgradeHandler, } from "./plans.js";
7
+ export { getPlanById, getPlanGroupById, createGetPlanGroupByIdHandler, getGroupPlans, createGetGroupPlansHandler, subscribe, createSubscribeHandler, unsubscribe, createUnsubscribeHandler, upgrade, createUpgradeHandler, getCurrent, createGetCurrentHandler, } from "./plans.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createUpgradeHandler = exports.upgrade = exports.createUnsubscribeHandler = exports.unsubscribe = exports.createSubscribeHandler = exports.subscribe = exports.createGetGroupPlansHandler = exports.getGroupPlans = exports.createGetPlanGroupByIdHandler = exports.getPlanGroupById = exports.getPlanById = 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.createGetCurrentHandler = exports.getCurrent = exports.createUpgradeHandler = exports.upgrade = exports.createUnsubscribeHandler = exports.unsubscribe = exports.createSubscribeHandler = exports.subscribe = exports.createGetGroupPlansHandler = exports.getGroupPlans = exports.createGetPlanGroupByIdHandler = exports.getPlanGroupById = exports.getPlanById = 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; } });
@@ -40,3 +40,5 @@ Object.defineProperty(exports, "unsubscribe", { enumerable: true, get: function
40
40
  Object.defineProperty(exports, "createUnsubscribeHandler", { enumerable: true, get: function () { return plans_js_1.createUnsubscribeHandler; } });
41
41
  Object.defineProperty(exports, "upgrade", { enumerable: true, get: function () { return plans_js_1.upgrade; } });
42
42
  Object.defineProperty(exports, "createUpgradeHandler", { enumerable: true, get: function () { return plans_js_1.createUpgradeHandler; } });
43
+ Object.defineProperty(exports, "getCurrent", { enumerable: true, get: function () { return plans_js_1.getCurrent; } });
44
+ Object.defineProperty(exports, "createGetCurrentHandler", { enumerable: true, get: function () { return plans_js_1.createGetCurrentHandler; } });