@revstackhq/node 0.0.0-dev-20260226054346

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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/dist/errors.d.ts +106 -0
  4. package/dist/errors.d.ts.map +1 -0
  5. package/dist/errors.js +102 -0
  6. package/dist/index.d.ts +75 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +94 -0
  9. package/dist/modules/admin/entitlements.d.ts +68 -0
  10. package/dist/modules/admin/entitlements.d.ts.map +1 -0
  11. package/dist/modules/admin/entitlements.js +87 -0
  12. package/dist/modules/admin/environments.d.ts +71 -0
  13. package/dist/modules/admin/environments.d.ts.map +1 -0
  14. package/dist/modules/admin/environments.js +84 -0
  15. package/dist/modules/admin/index.d.ts +30 -0
  16. package/dist/modules/admin/index.d.ts.map +1 -0
  17. package/dist/modules/admin/index.js +31 -0
  18. package/dist/modules/admin/integrations.d.ts +79 -0
  19. package/dist/modules/admin/integrations.d.ts.map +1 -0
  20. package/dist/modules/admin/integrations.js +97 -0
  21. package/dist/modules/admin/plans.d.ts +72 -0
  22. package/dist/modules/admin/plans.d.ts.map +1 -0
  23. package/dist/modules/admin/plans.js +93 -0
  24. package/dist/modules/admin/system.d.ts +53 -0
  25. package/dist/modules/admin/system.d.ts.map +1 -0
  26. package/dist/modules/admin/system.js +61 -0
  27. package/dist/modules/base.d.ts +43 -0
  28. package/dist/modules/base.d.ts.map +1 -0
  29. package/dist/modules/base.js +84 -0
  30. package/dist/modules/customers.d.ts +56 -0
  31. package/dist/modules/customers.d.ts.map +1 -0
  32. package/dist/modules/customers.js +72 -0
  33. package/dist/modules/entitlements.d.ts +49 -0
  34. package/dist/modules/entitlements.d.ts.map +1 -0
  35. package/dist/modules/entitlements.js +64 -0
  36. package/dist/modules/invoices.d.ts +33 -0
  37. package/dist/modules/invoices.d.ts.map +1 -0
  38. package/dist/modules/invoices.js +37 -0
  39. package/dist/modules/plans.d.ts +35 -0
  40. package/dist/modules/plans.d.ts.map +1 -0
  41. package/dist/modules/plans.js +39 -0
  42. package/dist/modules/subscriptions.d.ts +55 -0
  43. package/dist/modules/subscriptions.d.ts.map +1 -0
  44. package/dist/modules/subscriptions.js +71 -0
  45. package/dist/modules/usage.d.ts +59 -0
  46. package/dist/modules/usage.d.ts.map +1 -0
  47. package/dist/modules/usage.js +80 -0
  48. package/dist/modules/wallets.d.ts +53 -0
  49. package/dist/modules/wallets.d.ts.map +1 -0
  50. package/dist/modules/wallets.js +69 -0
  51. package/dist/modules/webhooks.d.ts +51 -0
  52. package/dist/modules/webhooks.d.ts.map +1 -0
  53. package/dist/modules/webhooks.js +90 -0
  54. package/dist/src/errors.d.ts +91 -0
  55. package/dist/src/errors.d.ts.map +1 -0
  56. package/dist/src/errors.js +101 -0
  57. package/dist/src/index.d.ts +71 -0
  58. package/dist/src/index.d.ts.map +1 -0
  59. package/dist/src/index.js +91 -0
  60. package/dist/src/modules/admin/entitlements.d.ts +73 -0
  61. package/dist/src/modules/admin/entitlements.d.ts.map +1 -0
  62. package/dist/src/modules/admin/entitlements.js +90 -0
  63. package/dist/src/modules/admin/environments.d.ts +76 -0
  64. package/dist/src/modules/admin/environments.d.ts.map +1 -0
  65. package/dist/src/modules/admin/environments.js +87 -0
  66. package/dist/src/modules/admin/index.d.ts +16 -0
  67. package/dist/src/modules/admin/index.d.ts.map +1 -0
  68. package/dist/src/modules/admin/index.js +16 -0
  69. package/dist/src/modules/admin/integrations.d.ts +84 -0
  70. package/dist/src/modules/admin/integrations.d.ts.map +1 -0
  71. package/dist/src/modules/admin/integrations.js +100 -0
  72. package/dist/src/modules/admin/plans.d.ts +77 -0
  73. package/dist/src/modules/admin/plans.d.ts.map +1 -0
  74. package/dist/src/modules/admin/plans.js +96 -0
  75. package/dist/src/modules/admin/system.d.ts +53 -0
  76. package/dist/src/modules/admin/system.d.ts.map +1 -0
  77. package/dist/src/modules/admin/system.js +61 -0
  78. package/dist/src/modules/base.d.ts +43 -0
  79. package/dist/src/modules/base.d.ts.map +1 -0
  80. package/dist/src/modules/base.js +84 -0
  81. package/dist/src/modules/customers.d.ts +61 -0
  82. package/dist/src/modules/customers.d.ts.map +1 -0
  83. package/dist/src/modules/customers.js +75 -0
  84. package/dist/src/modules/entitlements.d.ts +54 -0
  85. package/dist/src/modules/entitlements.d.ts.map +1 -0
  86. package/dist/src/modules/entitlements.js +67 -0
  87. package/dist/src/modules/invoices.d.ts +38 -0
  88. package/dist/src/modules/invoices.d.ts.map +1 -0
  89. package/dist/src/modules/invoices.js +40 -0
  90. package/dist/src/modules/plans.d.ts +40 -0
  91. package/dist/src/modules/plans.d.ts.map +1 -0
  92. package/dist/src/modules/plans.js +42 -0
  93. package/dist/src/modules/subscriptions.d.ts +60 -0
  94. package/dist/src/modules/subscriptions.d.ts.map +1 -0
  95. package/dist/src/modules/subscriptions.js +74 -0
  96. package/dist/src/modules/usage.d.ts +64 -0
  97. package/dist/src/modules/usage.d.ts.map +1 -0
  98. package/dist/src/modules/usage.js +83 -0
  99. package/dist/src/modules/wallets.d.ts +58 -0
  100. package/dist/src/modules/wallets.d.ts.map +1 -0
  101. package/dist/src/modules/wallets.js +72 -0
  102. package/dist/src/modules/webhooks.d.ts +51 -0
  103. package/dist/src/modules/webhooks.d.ts.map +1 -0
  104. package/dist/src/modules/webhooks.js +90 -0
  105. package/dist/src/types.d.ts +676 -0
  106. package/dist/src/types.d.ts.map +1 -0
  107. package/dist/src/types.js +7 -0
  108. package/dist/types.d.ts +720 -0
  109. package/dist/types.d.ts.map +1 -0
  110. package/dist/types.js +7 -0
  111. package/package.json +40 -0
@@ -0,0 +1,87 @@
1
+ import { BaseClient } from "@/modules/base";
2
+ /**
3
+ * Admin client for managing entitlement definitions (CRUD + upsert).
4
+ * Entitlements define the features and capabilities that can be gated behind plans.
5
+ *
6
+ * The `upsert()` method is idempotent by `slug`, making it safe for repeated
7
+ * CLI deployments without creating duplicates.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * await revstack.admin.entitlements.upsert({
12
+ * slug: "api-calls",
13
+ * name: "API Calls",
14
+ * type: "metered",
15
+ * unitType: "count",
16
+ * });
17
+ * ```
18
+ */
19
+ export class AdminEntitlementsClient extends BaseClient {
20
+ /**
21
+ * List all entitlement definitions with optional pagination.
22
+ *
23
+ * @param params - Pagination parameters.
24
+ * @returns A paginated list of entitlements.
25
+ */
26
+ async list(params) {
27
+ return this.request(`/admin/entitlements${this.buildQuery(params)}`, { method: "GET" });
28
+ }
29
+ /**
30
+ * Retrieve a single entitlement definition by ID.
31
+ *
32
+ * @param entitlementId - The entitlement's unique identifier.
33
+ * @returns The entitlement definition.
34
+ */
35
+ async get(entitlementId) {
36
+ return this.request(`/admin/entitlements/${entitlementId}`, {
37
+ method: "GET",
38
+ });
39
+ }
40
+ /**
41
+ * Create a new entitlement definition.
42
+ *
43
+ * @param params - Entitlement creation parameters.
44
+ * @returns The newly created entitlement.
45
+ */
46
+ async create(params) {
47
+ return this.request("/admin/entitlements", {
48
+ method: "POST",
49
+ body: JSON.stringify(params),
50
+ });
51
+ }
52
+ /**
53
+ * Partially update an existing entitlement definition.
54
+ *
55
+ * @param entitlementId - The entitlement's unique identifier.
56
+ * @param params - Fields to update.
57
+ * @returns The updated entitlement.
58
+ */
59
+ async update(entitlementId, params) {
60
+ return this.request(`/admin/entitlements/${entitlementId}`, {
61
+ method: "PATCH",
62
+ body: JSON.stringify(params),
63
+ });
64
+ }
65
+ /**
66
+ * Delete an entitlement definition. Fails if any active plans reference it.
67
+ *
68
+ * @param entitlementId - The entitlement's unique identifier.
69
+ * @returns Confirmation of deletion.
70
+ */
71
+ async delete(entitlementId) {
72
+ return this.request(`/admin/entitlements/${entitlementId}`, { method: "DELETE" });
73
+ }
74
+ /**
75
+ * Idempotently create or update an entitlement by its `slug`.
76
+ * If an entitlement with the given slug exists, it is updated; otherwise, it is created.
77
+ *
78
+ * @param params - Full entitlement state.
79
+ * @returns The created or updated entitlement.
80
+ */
81
+ async upsert(params) {
82
+ return this.request("/admin/entitlements", {
83
+ method: "PUT",
84
+ body: JSON.stringify(params),
85
+ });
86
+ }
87
+ }
@@ -0,0 +1,71 @@
1
+ import { BaseClient } from "@/modules/base";
2
+ import { Environment, CreateEnvironmentParams, UpdateEnvironmentParams, ListParams, PaginatedResponse } from "@/types";
3
+ /**
4
+ * Admin client for managing deployment environments.
5
+ * Each environment has its own API keys, auth configuration, and integrations.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Create a staging environment
10
+ * const env = await revstack.admin.environments.create({
11
+ * name: "staging",
12
+ * authProvider: "supabase",
13
+ * authJwksUri: "https://my-project.supabase.co/.well-known/jwks.json",
14
+ * });
15
+ *
16
+ * // Rotate API keys after a security incident
17
+ * const newKeys = await revstack.admin.environments.rotateKeys(env.id);
18
+ * ```
19
+ */
20
+ export declare class AdminEnvironmentsClient extends BaseClient {
21
+ /**
22
+ * List all environments with optional pagination.
23
+ *
24
+ * @param params - Pagination parameters.
25
+ * @returns A paginated list of environments.
26
+ */
27
+ list(params?: ListParams): Promise<PaginatedResponse<Environment>>;
28
+ /**
29
+ * Retrieve a single environment by ID.
30
+ *
31
+ * @param environmentId - The environment's unique identifier.
32
+ * @returns The environment record including API keys and auth config.
33
+ */
34
+ get(environmentId: string): Promise<Environment>;
35
+ /**
36
+ * Create a new deployment environment.
37
+ *
38
+ * @param params - Environment creation parameters.
39
+ * @returns The newly created environment with generated API keys.
40
+ */
41
+ create(params: CreateEnvironmentParams): Promise<Environment>;
42
+ /**
43
+ * Update an existing environment's name or auth configuration.
44
+ *
45
+ * @param environmentId - The environment's unique identifier.
46
+ * @param params - Fields to update.
47
+ * @returns The updated environment.
48
+ */
49
+ update(environmentId: string, params: UpdateEnvironmentParams): Promise<Environment>;
50
+ /**
51
+ * Delete an environment. This invalidates its API keys immediately.
52
+ *
53
+ * @param environmentId - The environment's unique identifier.
54
+ * @returns Confirmation of deletion.
55
+ */
56
+ delete(environmentId: string): Promise<{
57
+ success: boolean;
58
+ }>;
59
+ /**
60
+ * Rotate both the public and secret API keys for an environment.
61
+ * The old keys become invalid immediately. Use this after a security incident.
62
+ *
63
+ * @param environmentId - The environment whose keys to rotate.
64
+ * @returns The new API key pair.
65
+ */
66
+ rotateKeys(environmentId: string): Promise<{
67
+ apiKeyPublic: string;
68
+ apiKeySecret: string;
69
+ }>;
70
+ }
71
+ //# sourceMappingURL=environments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../../../src/modules/admin/environments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,uBAAwB,SAAQ,UAAU;IACrD;;;;;OAKG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAOxE;;;;;OAKG;IACG,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMtD;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC;IAOnE;;;;;;OAMG;IACG,MAAM,CACV,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,WAAW,CAAC;IAOvB;;;;;OAKG;IACG,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAOlE;;;;;;OAMG;IACG,UAAU,CACd,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;CAM3D"}
@@ -0,0 +1,84 @@
1
+ import { BaseClient } from "@/modules/base";
2
+ /**
3
+ * Admin client for managing deployment environments.
4
+ * Each environment has its own API keys, auth configuration, and integrations.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * // Create a staging environment
9
+ * const env = await revstack.admin.environments.create({
10
+ * name: "staging",
11
+ * authProvider: "supabase",
12
+ * authJwksUri: "https://my-project.supabase.co/.well-known/jwks.json",
13
+ * });
14
+ *
15
+ * // Rotate API keys after a security incident
16
+ * const newKeys = await revstack.admin.environments.rotateKeys(env.id);
17
+ * ```
18
+ */
19
+ export class AdminEnvironmentsClient extends BaseClient {
20
+ /**
21
+ * List all environments with optional pagination.
22
+ *
23
+ * @param params - Pagination parameters.
24
+ * @returns A paginated list of environments.
25
+ */
26
+ async list(params) {
27
+ return this.request(`/admin/environments${this.buildQuery(params)}`, { method: "GET" });
28
+ }
29
+ /**
30
+ * Retrieve a single environment by ID.
31
+ *
32
+ * @param environmentId - The environment's unique identifier.
33
+ * @returns The environment record including API keys and auth config.
34
+ */
35
+ async get(environmentId) {
36
+ return this.request(`/admin/environments/${environmentId}`, {
37
+ method: "GET",
38
+ });
39
+ }
40
+ /**
41
+ * Create a new deployment environment.
42
+ *
43
+ * @param params - Environment creation parameters.
44
+ * @returns The newly created environment with generated API keys.
45
+ */
46
+ async create(params) {
47
+ return this.request("/admin/environments", {
48
+ method: "POST",
49
+ body: JSON.stringify(params),
50
+ });
51
+ }
52
+ /**
53
+ * Update an existing environment's name or auth configuration.
54
+ *
55
+ * @param environmentId - The environment's unique identifier.
56
+ * @param params - Fields to update.
57
+ * @returns The updated environment.
58
+ */
59
+ async update(environmentId, params) {
60
+ return this.request(`/admin/environments/${environmentId}`, {
61
+ method: "PATCH",
62
+ body: JSON.stringify(params),
63
+ });
64
+ }
65
+ /**
66
+ * Delete an environment. This invalidates its API keys immediately.
67
+ *
68
+ * @param environmentId - The environment's unique identifier.
69
+ * @returns Confirmation of deletion.
70
+ */
71
+ async delete(environmentId) {
72
+ return this.request(`/admin/environments/${environmentId}`, { method: "DELETE" });
73
+ }
74
+ /**
75
+ * Rotate both the public and secret API keys for an environment.
76
+ * The old keys become invalid immediately. Use this after a security incident.
77
+ *
78
+ * @param environmentId - The environment whose keys to rotate.
79
+ * @returns The new API key pair.
80
+ */
81
+ async rotateKeys(environmentId) {
82
+ return this.request(`/admin/environments/${environmentId}/rotate-keys`, { method: "POST" });
83
+ }
84
+ }
@@ -0,0 +1,30 @@
1
+ import { AdminPlansClient } from "@/modules/admin/plans";
2
+ import { AdminEntitlementsClient } from "@/modules/admin/entitlements";
3
+ import { AdminIntegrationsClient } from "@/modules/admin/integrations";
4
+ import { AdminEnvironmentsClient } from "@/modules/admin/environments";
5
+ import { AdminSystemClient } from "@/modules/admin/system";
6
+ /**
7
+ * Aggregated admin client that bundles all Control Plane modules.
8
+ * Exposed as `revstack.admin` on the main {@link Revstack} class.
9
+ *
10
+ * Used by the CLI (`npx revstack push`) for Billing as Code deployments
11
+ * and by advanced integrations that need full infrastructure control.
12
+ */
13
+ export declare class AdminClient {
14
+ /** Manage billing plans (CRUD + idempotent upsert). */
15
+ readonly plans: AdminPlansClient;
16
+ /** Manage entitlement definitions (CRUD + idempotent upsert). */
17
+ readonly entitlements: AdminEntitlementsClient;
18
+ /** Manage payment provider integrations and their events/metrics. */
19
+ readonly integrations: AdminIntegrationsClient;
20
+ /** Manage deployment environments and API keys. */
21
+ readonly environments: AdminEnvironmentsClient;
22
+ /** Billing as Code orchestrator for atomic state synchronization. */
23
+ readonly system: AdminSystemClient;
24
+ constructor(config: {
25
+ secretKey: string;
26
+ baseUrl: string;
27
+ timeout: number;
28
+ });
29
+ }
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/admin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;;GAMG;AACH,qBAAa,WAAW;IACtB,uDAAuD;IACvD,SAAgB,KAAK,EAAE,gBAAgB,CAAC;IACxC,iEAAiE;IACjE,SAAgB,YAAY,EAAE,uBAAuB,CAAC;IACtD,qEAAqE;IACrE,SAAgB,YAAY,EAAE,uBAAuB,CAAC;IACtD,mDAAmD;IACnD,SAAgB,YAAY,EAAE,uBAAuB,CAAC;IACtD,qEAAqE;IACrE,SAAgB,MAAM,EAAE,iBAAiB,CAAC;gBAE9B,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAO5E"}
@@ -0,0 +1,31 @@
1
+ import { AdminPlansClient } from "@/modules/admin/plans";
2
+ import { AdminEntitlementsClient } from "@/modules/admin/entitlements";
3
+ import { AdminIntegrationsClient } from "@/modules/admin/integrations";
4
+ import { AdminEnvironmentsClient } from "@/modules/admin/environments";
5
+ import { AdminSystemClient } from "@/modules/admin/system";
6
+ /**
7
+ * Aggregated admin client that bundles all Control Plane modules.
8
+ * Exposed as `revstack.admin` on the main {@link Revstack} class.
9
+ *
10
+ * Used by the CLI (`npx revstack push`) for Billing as Code deployments
11
+ * and by advanced integrations that need full infrastructure control.
12
+ */
13
+ export class AdminClient {
14
+ /** Manage billing plans (CRUD + idempotent upsert). */
15
+ plans;
16
+ /** Manage entitlement definitions (CRUD + idempotent upsert). */
17
+ entitlements;
18
+ /** Manage payment provider integrations and their events/metrics. */
19
+ integrations;
20
+ /** Manage deployment environments and API keys. */
21
+ environments;
22
+ /** Billing as Code orchestrator for atomic state synchronization. */
23
+ system;
24
+ constructor(config) {
25
+ this.plans = new AdminPlansClient(config);
26
+ this.entitlements = new AdminEntitlementsClient(config);
27
+ this.integrations = new AdminIntegrationsClient(config);
28
+ this.environments = new AdminEnvironmentsClient(config);
29
+ this.system = new AdminSystemClient(config);
30
+ }
31
+ }
@@ -0,0 +1,79 @@
1
+ import { BaseClient } from "@/modules/base";
2
+ import { Integration, CreateIntegrationParams, UpdateIntegrationParams, ListIntegrationsParams, ProviderEvent, ListProviderEventsParams, IntegrationMetric, ListMetricsParams, PaginatedResponse } from "@/types";
3
+ /**
4
+ * Admin client for managing payment provider integrations.
5
+ * Supports CRUD operations on integrations (e.g. Stripe, Paddle) and
6
+ * read access to their webhook events and hourly metrics.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Create a Stripe integration
11
+ * await revstack.admin.integrations.create({
12
+ * provider: "stripe",
13
+ * credentials: { apiKey: "sk_live_..." },
14
+ * webhookSecret: "whsec_...",
15
+ * });
16
+ *
17
+ * // View recent webhook events
18
+ * const { data: events } = await revstack.admin.integrations.listEvents("int_abc");
19
+ * ```
20
+ */
21
+ export declare class AdminIntegrationsClient extends BaseClient {
22
+ /**
23
+ * List all integrations with optional filters.
24
+ *
25
+ * @param params - Filter and pagination parameters.
26
+ * @returns A paginated list of integrations.
27
+ */
28
+ list(params?: ListIntegrationsParams): Promise<PaginatedResponse<Integration>>;
29
+ /**
30
+ * Retrieve a single integration by ID.
31
+ *
32
+ * @param integrationId - The integration's unique identifier.
33
+ * @returns The integration record.
34
+ */
35
+ get(integrationId: string): Promise<Integration>;
36
+ /**
37
+ * Create a new payment provider integration.
38
+ *
39
+ * @param params - Integration creation parameters.
40
+ * @returns The newly created integration.
41
+ */
42
+ create(params: CreateIntegrationParams): Promise<Integration>;
43
+ /**
44
+ * Update an existing integration's credentials, webhook secret, or active status.
45
+ *
46
+ * @param integrationId - The integration's unique identifier.
47
+ * @param params - Fields to update.
48
+ * @returns The updated integration.
49
+ */
50
+ update(integrationId: string, params: UpdateIntegrationParams): Promise<Integration>;
51
+ /**
52
+ * Delete an integration. This stops webhook processing for the provider.
53
+ *
54
+ * @param integrationId - The integration's unique identifier.
55
+ * @returns Confirmation of deletion.
56
+ */
57
+ delete(integrationId: string): Promise<{
58
+ success: boolean;
59
+ }>;
60
+ /**
61
+ * List webhook events received by an integration.
62
+ * Useful for debugging webhook delivery and processing issues.
63
+ *
64
+ * @param integrationId - The integration to query events for.
65
+ * @param params - Filter and pagination parameters.
66
+ * @returns A paginated list of provider events.
67
+ */
68
+ listEvents(integrationId: string, params?: ListProviderEventsParams): Promise<PaginatedResponse<ProviderEvent>>;
69
+ /**
70
+ * List hourly aggregated metrics for an integration.
71
+ * Shows volume processed and event counts per hour.
72
+ *
73
+ * @param integrationId - The integration to query metrics for.
74
+ * @param params - Time range and pagination parameters.
75
+ * @returns A paginated list of hourly metrics.
76
+ */
77
+ listMetrics(integrationId: string, params?: ListMetricsParams): Promise<PaginatedResponse<IntegrationMetric>>;
78
+ }
79
+ //# sourceMappingURL=integrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../src/modules/admin/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,uBAAwB,SAAQ,UAAU;IACrD;;;;;OAKG;IACG,IAAI,CACR,MAAM,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAO1C;;;;;OAKG;IACG,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMtD;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC;IAOnE;;;;;;OAMG;IACG,MAAM,CACV,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,WAAW,CAAC;IAOvB;;;;;OAKG;IACG,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAOlE;;;;;;;OAOG;IACG,UAAU,CACd,aAAa,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAO5C;;;;;;;OAOG;IACG,WAAW,CACf,aAAa,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;CAMjD"}
@@ -0,0 +1,97 @@
1
+ import { BaseClient } from "@/modules/base";
2
+ /**
3
+ * Admin client for managing payment provider integrations.
4
+ * Supports CRUD operations on integrations (e.g. Stripe, Paddle) and
5
+ * read access to their webhook events and hourly metrics.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Create a Stripe integration
10
+ * await revstack.admin.integrations.create({
11
+ * provider: "stripe",
12
+ * credentials: { apiKey: "sk_live_..." },
13
+ * webhookSecret: "whsec_...",
14
+ * });
15
+ *
16
+ * // View recent webhook events
17
+ * const { data: events } = await revstack.admin.integrations.listEvents("int_abc");
18
+ * ```
19
+ */
20
+ export class AdminIntegrationsClient extends BaseClient {
21
+ /**
22
+ * List all integrations with optional filters.
23
+ *
24
+ * @param params - Filter and pagination parameters.
25
+ * @returns A paginated list of integrations.
26
+ */
27
+ async list(params) {
28
+ return this.request(`/admin/integrations${this.buildQuery(params)}`, { method: "GET" });
29
+ }
30
+ /**
31
+ * Retrieve a single integration by ID.
32
+ *
33
+ * @param integrationId - The integration's unique identifier.
34
+ * @returns The integration record.
35
+ */
36
+ async get(integrationId) {
37
+ return this.request(`/admin/integrations/${integrationId}`, {
38
+ method: "GET",
39
+ });
40
+ }
41
+ /**
42
+ * Create a new payment provider integration.
43
+ *
44
+ * @param params - Integration creation parameters.
45
+ * @returns The newly created integration.
46
+ */
47
+ async create(params) {
48
+ return this.request("/admin/integrations", {
49
+ method: "POST",
50
+ body: JSON.stringify(params),
51
+ });
52
+ }
53
+ /**
54
+ * Update an existing integration's credentials, webhook secret, or active status.
55
+ *
56
+ * @param integrationId - The integration's unique identifier.
57
+ * @param params - Fields to update.
58
+ * @returns The updated integration.
59
+ */
60
+ async update(integrationId, params) {
61
+ return this.request(`/admin/integrations/${integrationId}`, {
62
+ method: "PATCH",
63
+ body: JSON.stringify(params),
64
+ });
65
+ }
66
+ /**
67
+ * Delete an integration. This stops webhook processing for the provider.
68
+ *
69
+ * @param integrationId - The integration's unique identifier.
70
+ * @returns Confirmation of deletion.
71
+ */
72
+ async delete(integrationId) {
73
+ return this.request(`/admin/integrations/${integrationId}`, { method: "DELETE" });
74
+ }
75
+ /**
76
+ * List webhook events received by an integration.
77
+ * Useful for debugging webhook delivery and processing issues.
78
+ *
79
+ * @param integrationId - The integration to query events for.
80
+ * @param params - Filter and pagination parameters.
81
+ * @returns A paginated list of provider events.
82
+ */
83
+ async listEvents(integrationId, params) {
84
+ return this.request(`/admin/integrations/${integrationId}/events${this.buildQuery(params)}`, { method: "GET" });
85
+ }
86
+ /**
87
+ * List hourly aggregated metrics for an integration.
88
+ * Shows volume processed and event counts per hour.
89
+ *
90
+ * @param integrationId - The integration to query metrics for.
91
+ * @param params - Time range and pagination parameters.
92
+ * @returns A paginated list of hourly metrics.
93
+ */
94
+ async listMetrics(integrationId, params) {
95
+ return this.request(`/admin/integrations/${integrationId}/metrics${this.buildQuery(params)}`, { method: "GET" });
96
+ }
97
+ }
@@ -0,0 +1,72 @@
1
+ import { BaseClient } from "@/modules/base";
2
+ import { Plan, CreatePlanParams, UpdatePlanParams, UpsertPlanParams, ListPlansParams, PaginatedResponse } from "@/types";
3
+ /**
4
+ * Admin client for managing billing plans (CRUD + upsert).
5
+ * Used by the CLI (`npx revstack push`) and advanced integrations.
6
+ *
7
+ * The `upsert()` method is the primary primitive for Billing as Code —
8
+ * it creates or updates a plan by its `slug`, making deployments idempotent.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * await revstack.admin.plans.upsert({
13
+ * slug: "pro",
14
+ * name: "Pro",
15
+ * status: "active",
16
+ * prices: [{ amount: 4900, currency: "USD", billingInterval: "month" }],
17
+ * entitlements: [{ entitlementSlug: "api-calls", valueLimit: 10000 }],
18
+ * });
19
+ * ```
20
+ */
21
+ export declare class AdminPlansClient extends BaseClient {
22
+ /**
23
+ * List all plans with optional filters.
24
+ *
25
+ * @param params - Filter and pagination parameters.
26
+ * @returns A paginated list of plans.
27
+ */
28
+ list(params?: ListPlansParams): Promise<PaginatedResponse<Plan>>;
29
+ /**
30
+ * Retrieve a plan by ID, including nested prices and entitlements.
31
+ *
32
+ * @param planId - The plan's unique identifier.
33
+ * @returns The plan with populated `prices[]` and `entitlements[]`.
34
+ */
35
+ get(planId: string): Promise<Plan>;
36
+ /**
37
+ * Create a new billing plan with optional prices and entitlements.
38
+ *
39
+ * @param params - Plan creation parameters.
40
+ * @returns The newly created plan.
41
+ */
42
+ create(params: CreatePlanParams): Promise<Plan>;
43
+ /**
44
+ * Partially update an existing plan's attributes.
45
+ * Does not modify prices or entitlements — use `upsert()` for that.
46
+ *
47
+ * @param planId - The plan's unique identifier.
48
+ * @param params - Fields to update.
49
+ * @returns The updated plan.
50
+ */
51
+ update(planId: string, params: UpdatePlanParams): Promise<Plan>;
52
+ /**
53
+ * Delete a plan. Fails if the plan has active subscriptions.
54
+ *
55
+ * @param planId - The plan's unique identifier.
56
+ * @returns Confirmation of deletion.
57
+ */
58
+ delete(planId: string): Promise<{
59
+ success: boolean;
60
+ }>;
61
+ /**
62
+ * Idempotently create or update a plan by its `slug`.
63
+ * This is the primary method used by the CLI for Billing as Code deployments.
64
+ * If a plan with the given slug exists, it is updated; otherwise, it is created.
65
+ * Nested prices and entitlements are replaced atomically.
66
+ *
67
+ * @param params - Full plan state including prices and entitlements.
68
+ * @returns The created or updated plan.
69
+ */
70
+ upsert(params: UpsertPlanParams): Promise<Plan>;
71
+ }
72
+ //# sourceMappingURL=plans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plans.d.ts","sourceRoot":"","sources":["../../../src/modules/admin/plans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C;;;;;OAKG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAOtE;;;;;OAKG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxC;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrD;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrE;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAM3D;;;;;;;;OAQG;IACG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAMtD"}
@@ -0,0 +1,93 @@
1
+ import { BaseClient } from "@/modules/base";
2
+ /**
3
+ * Admin client for managing billing plans (CRUD + upsert).
4
+ * Used by the CLI (`npx revstack push`) and advanced integrations.
5
+ *
6
+ * The `upsert()` method is the primary primitive for Billing as Code —
7
+ * it creates or updates a plan by its `slug`, making deployments idempotent.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * await revstack.admin.plans.upsert({
12
+ * slug: "pro",
13
+ * name: "Pro",
14
+ * status: "active",
15
+ * prices: [{ amount: 4900, currency: "USD", billingInterval: "month" }],
16
+ * entitlements: [{ entitlementSlug: "api-calls", valueLimit: 10000 }],
17
+ * });
18
+ * ```
19
+ */
20
+ export class AdminPlansClient extends BaseClient {
21
+ /**
22
+ * List all plans with optional filters.
23
+ *
24
+ * @param params - Filter and pagination parameters.
25
+ * @returns A paginated list of plans.
26
+ */
27
+ async list(params) {
28
+ return this.request(`/admin/plans${this.buildQuery(params)}`, { method: "GET" });
29
+ }
30
+ /**
31
+ * Retrieve a plan by ID, including nested prices and entitlements.
32
+ *
33
+ * @param planId - The plan's unique identifier.
34
+ * @returns The plan with populated `prices[]` and `entitlements[]`.
35
+ */
36
+ async get(planId) {
37
+ return this.request(`/admin/plans/${planId}`, {
38
+ method: "GET",
39
+ });
40
+ }
41
+ /**
42
+ * Create a new billing plan with optional prices and entitlements.
43
+ *
44
+ * @param params - Plan creation parameters.
45
+ * @returns The newly created plan.
46
+ */
47
+ async create(params) {
48
+ return this.request("/admin/plans", {
49
+ method: "POST",
50
+ body: JSON.stringify(params),
51
+ });
52
+ }
53
+ /**
54
+ * Partially update an existing plan's attributes.
55
+ * Does not modify prices or entitlements — use `upsert()` for that.
56
+ *
57
+ * @param planId - The plan's unique identifier.
58
+ * @param params - Fields to update.
59
+ * @returns The updated plan.
60
+ */
61
+ async update(planId, params) {
62
+ return this.request(`/admin/plans/${planId}`, {
63
+ method: "PATCH",
64
+ body: JSON.stringify(params),
65
+ });
66
+ }
67
+ /**
68
+ * Delete a plan. Fails if the plan has active subscriptions.
69
+ *
70
+ * @param planId - The plan's unique identifier.
71
+ * @returns Confirmation of deletion.
72
+ */
73
+ async delete(planId) {
74
+ return this.request(`/admin/plans/${planId}`, {
75
+ method: "DELETE",
76
+ });
77
+ }
78
+ /**
79
+ * Idempotently create or update a plan by its `slug`.
80
+ * This is the primary method used by the CLI for Billing as Code deployments.
81
+ * If a plan with the given slug exists, it is updated; otherwise, it is created.
82
+ * Nested prices and entitlements are replaced atomically.
83
+ *
84
+ * @param params - Full plan state including prices and entitlements.
85
+ * @returns The created or updated plan.
86
+ */
87
+ async upsert(params) {
88
+ return this.request("/admin/plans", {
89
+ method: "PUT",
90
+ body: JSON.stringify(params),
91
+ });
92
+ }
93
+ }