rocketride 1.0.5 → 1.1.0
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/README.md +4 -4
- package/dist/cjs/account.js +284 -0
- package/dist/cjs/account.js.map +1 -0
- package/dist/cjs/billing.js +171 -0
- package/dist/cjs/billing.js.map +1 -0
- package/dist/cjs/client.js +1208 -756
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/constants.js +10 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/core/DAPBase.js +4 -1
- package/dist/cjs/core/DAPBase.js.map +1 -1
- package/dist/cjs/core/DAPClient.js +121 -50
- package/dist/cjs/core/DAPClient.js.map +1 -1
- package/dist/cjs/core/TransportBase.js +0 -10
- package/dist/cjs/core/TransportBase.js.map +1 -1
- package/dist/cjs/core/TransportWebSocket.js +30 -19
- package/dist/cjs/core/TransportWebSocket.js.map +1 -1
- package/dist/cjs/database.js +121 -0
- package/dist/cjs/database.js.map +1 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/schema/Question.js +2 -0
- package/dist/cjs/schema/Question.js.map +1 -1
- package/dist/cjs/types/account.js +26 -0
- package/dist/cjs/types/account.js.map +1 -0
- package/dist/cjs/types/billing.js +26 -0
- package/dist/cjs/types/billing.js.map +1 -0
- package/dist/cjs/types/client.js +14 -0
- package/dist/cjs/types/client.js.map +1 -1
- package/dist/cjs/types/cprofile.js +26 -0
- package/dist/cjs/types/cprofile.js.map +1 -0
- package/dist/cjs/types/dashboard.js +26 -0
- package/dist/cjs/types/dashboard.js.map +1 -0
- package/dist/cjs/types/events.js +5 -1
- package/dist/cjs/types/events.js.map +1 -1
- package/dist/cjs/types/index.js +5 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/service.js +85 -0
- package/dist/cjs/types/service.js.map +1 -0
- package/dist/cli/cli/rocketride.js +335 -113
- package/dist/cli/cli/rocketride.js.map +1 -1
- package/dist/cli/client/account.js +284 -0
- package/dist/cli/client/account.js.map +1 -0
- package/dist/cli/client/billing.js +171 -0
- package/dist/cli/client/billing.js.map +1 -0
- package/dist/cli/client/client.js +1208 -756
- package/dist/cli/client/client.js.map +1 -1
- package/dist/cli/client/constants.js +10 -1
- package/dist/cli/client/constants.js.map +1 -1
- package/dist/cli/client/core/DAPBase.js +4 -1
- package/dist/cli/client/core/DAPBase.js.map +1 -1
- package/dist/cli/client/core/DAPClient.js +121 -50
- package/dist/cli/client/core/DAPClient.js.map +1 -1
- package/dist/cli/client/core/TransportBase.js +0 -10
- package/dist/cli/client/core/TransportBase.js.map +1 -1
- package/dist/cli/client/core/TransportWebSocket.js +30 -19
- package/dist/cli/client/core/TransportWebSocket.js.map +1 -1
- package/dist/cli/client/database.js +121 -0
- package/dist/cli/client/database.js.map +1 -0
- package/dist/cli/client/index.js +4 -0
- package/dist/cli/client/index.js.map +1 -1
- package/dist/cli/client/schema/Question.js +2 -0
- package/dist/cli/client/schema/Question.js.map +1 -1
- package/dist/cli/client/types/account.js +26 -0
- package/dist/cli/client/types/account.js.map +1 -0
- package/dist/cli/client/types/billing.js +26 -0
- package/dist/cli/client/types/billing.js.map +1 -0
- package/dist/cli/client/types/client.js +14 -0
- package/dist/cli/client/types/client.js.map +1 -1
- package/dist/cli/client/types/cprofile.js +26 -0
- package/dist/cli/client/types/cprofile.js.map +1 -0
- package/dist/cli/client/types/dashboard.js +26 -0
- package/dist/cli/client/types/dashboard.js.map +1 -0
- package/dist/cli/client/types/events.js +5 -1
- package/dist/cli/client/types/events.js.map +1 -1
- package/dist/cli/client/types/index.js +5 -0
- package/dist/cli/client/types/index.js.map +1 -1
- package/dist/cli/client/types/service.js +85 -0
- package/dist/cli/client/types/service.js.map +1 -0
- package/dist/esm/account.js +280 -0
- package/dist/esm/account.js.map +1 -0
- package/dist/esm/billing.js +167 -0
- package/dist/esm/billing.js.map +1 -0
- package/dist/esm/client.js +1208 -756
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/constants.js +9 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/core/DAPBase.js +4 -1
- package/dist/esm/core/DAPBase.js.map +1 -1
- package/dist/esm/core/DAPClient.js +121 -50
- package/dist/esm/core/DAPClient.js.map +1 -1
- package/dist/esm/core/TransportBase.js +0 -10
- package/dist/esm/core/TransportBase.js.map +1 -1
- package/dist/esm/core/TransportWebSocket.js +30 -19
- package/dist/esm/core/TransportWebSocket.js.map +1 -1
- package/dist/esm/database.js +117 -0
- package/dist/esm/database.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schema/Question.js +2 -0
- package/dist/esm/schema/Question.js.map +1 -1
- package/dist/esm/types/account.js +25 -0
- package/dist/esm/types/account.js.map +1 -0
- package/dist/esm/types/billing.js +25 -0
- package/dist/esm/types/billing.js.map +1 -0
- package/dist/esm/types/client.js +13 -1
- package/dist/esm/types/client.js.map +1 -1
- package/dist/esm/types/cprofile.js +25 -0
- package/dist/esm/types/cprofile.js.map +1 -0
- package/dist/esm/types/dashboard.js +25 -0
- package/dist/esm/types/dashboard.js.map +1 -0
- package/dist/esm/types/events.js +5 -1
- package/dist/esm/types/events.js.map +1 -1
- package/dist/esm/types/index.js +5 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/service.js +82 -0
- package/dist/esm/types/service.js.map +1 -0
- package/dist/types/account.d.ts +209 -0
- package/dist/types/account.d.ts.map +1 -0
- package/dist/types/billing.d.ts +135 -0
- package/dist/types/billing.d.ts.map +1 -0
- package/dist/types/client.d.ts +553 -285
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/constants.d.ts +9 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/core/DAPBase.d.ts.map +1 -1
- package/dist/types/core/DAPClient.d.ts +89 -7
- package/dist/types/core/DAPClient.d.ts.map +1 -1
- package/dist/types/core/TransportBase.d.ts +1 -11
- package/dist/types/core/TransportBase.d.ts.map +1 -1
- package/dist/types/core/TransportWebSocket.d.ts +14 -11
- package/dist/types/core/TransportWebSocket.d.ts.map +1 -1
- package/dist/types/database.d.ts +90 -0
- package/dist/types/database.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/schema/Question.d.ts +3 -1
- package/dist/types/schema/Question.d.ts.map +1 -1
- package/dist/types/types/account.d.ts +171 -0
- package/dist/types/types/account.d.ts.map +1 -0
- package/dist/types/types/billing.d.ts +115 -0
- package/dist/types/types/billing.d.ts.map +1 -0
- package/dist/types/types/client.d.ts +241 -1
- package/dist/types/types/client.d.ts.map +1 -1
- package/dist/types/types/cprofile.d.ts +67 -0
- package/dist/types/types/cprofile.d.ts.map +1 -0
- package/dist/types/types/dashboard.d.ts +198 -0
- package/dist/types/types/dashboard.d.ts.map +1 -0
- package/dist/types/types/events.d.ts +90 -95
- package/dist/types/types/events.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +5 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/pipeline.d.ts +10 -2
- package/dist/types/types/pipeline.d.ts.map +1 -1
- package/dist/types/types/service.d.ts +189 -0
- package/dist/types/types/service.d.ts.map +1 -0
- package/dist/types/types/task.d.ts +5 -1
- package/dist/types/types/task.d.ts.map +1 -1
- package/package.json +12 -7
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2026 Aparavi Software AG
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.BillingApi = void 0;
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// BILLING API CLASS
|
|
29
|
+
// =============================================================================
|
|
30
|
+
/**
|
|
31
|
+
* Typed wrapper around the `rrext_account_billing` DAP command.
|
|
32
|
+
*
|
|
33
|
+
* Accessed via `client.billing` — not instantiated directly. All methods
|
|
34
|
+
* delegate to {@link RocketRideClient.dap} which handles envelope
|
|
35
|
+
* unwrapping and error propagation.
|
|
36
|
+
*/
|
|
37
|
+
class BillingApi {
|
|
38
|
+
/** @param client - The parent RocketRideClient that owns this namespace. */
|
|
39
|
+
constructor(client) {
|
|
40
|
+
this.client = client;
|
|
41
|
+
}
|
|
42
|
+
// =========================================================================
|
|
43
|
+
// SUBSCRIPTION OPERATIONS
|
|
44
|
+
// =========================================================================
|
|
45
|
+
/**
|
|
46
|
+
* Fetches the per-app subscription details for the given org.
|
|
47
|
+
*
|
|
48
|
+
* @param orgId - Organisation UUID whose subscriptions to load.
|
|
49
|
+
* @returns Array of BillingDetail rows (one per subscribed app).
|
|
50
|
+
*/
|
|
51
|
+
async getDetails(orgId) {
|
|
52
|
+
const body = await this.client.call('rrext_account_billing', { subcommand: 'list', orgId });
|
|
53
|
+
return body.subscriptions ?? [];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Fetches the active subscription plans (prices) for an app.
|
|
57
|
+
*
|
|
58
|
+
* Plans are returned sorted month-first, year-second, formatted for
|
|
59
|
+
* display in the checkout plan picker. The server resolves the app's
|
|
60
|
+
* Stripe product internally and calls `stripe.Price.list()` so pricing
|
|
61
|
+
* changes in the Stripe dashboard are reflected immediately.
|
|
62
|
+
*
|
|
63
|
+
* @param appId - App identifier (e.g. "rocketride.pipeBuilder").
|
|
64
|
+
* @returns Array of StripePlan objects ready for display.
|
|
65
|
+
*/
|
|
66
|
+
async getProductPrices(appId) {
|
|
67
|
+
const body = await this.client.call('rrext_account_billing', { subcommand: 'prices', appId });
|
|
68
|
+
return body.plans ?? [];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates a Stripe subscription and returns the Stripe Elements client_secret.
|
|
72
|
+
*
|
|
73
|
+
* The returned client_secret is passed to `stripe.confirmPayment()` to
|
|
74
|
+
* complete the checkout without a browser redirect to Stripe.
|
|
75
|
+
*
|
|
76
|
+
* @param orgId - Organisation UUID to subscribe.
|
|
77
|
+
* @param appId - App being subscribed (e.g. "brandi").
|
|
78
|
+
* @param priceId - Stripe price_* identifier for the plan.
|
|
79
|
+
* @returns Object with client_secret for Stripe Elements and subscription_id.
|
|
80
|
+
*/
|
|
81
|
+
async createCheckoutSession(orgId, appId, priceId) {
|
|
82
|
+
return this.client.call('rrext_account_billing', {
|
|
83
|
+
subcommand: 'subscribe',
|
|
84
|
+
orgId,
|
|
85
|
+
appId,
|
|
86
|
+
priceId,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Creates a Stripe Billing Portal session for managing payment methods.
|
|
91
|
+
*
|
|
92
|
+
* @param orgId - Organisation UUID whose Stripe customer portal to open.
|
|
93
|
+
* @param returnUrl - URL to redirect the user back to after portal interaction.
|
|
94
|
+
* @returns Object with portal URL to redirect the user to.
|
|
95
|
+
*/
|
|
96
|
+
async createPortalSession(orgId, returnUrl) {
|
|
97
|
+
return this.client.call('rrext_account_billing', {
|
|
98
|
+
subcommand: 'portal',
|
|
99
|
+
orgId,
|
|
100
|
+
returnUrl,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Schedules an app subscription for cancellation at the end of the current period.
|
|
105
|
+
*
|
|
106
|
+
* The user retains access until the period ends. The webhook handler will
|
|
107
|
+
* update `cancel_at_period_end` in the database asynchronously.
|
|
108
|
+
*
|
|
109
|
+
* @param orgId - Organisation UUID that owns the subscription.
|
|
110
|
+
* @param appId - App to cancel (e.g. "brandi").
|
|
111
|
+
* @returns Object with canceled: true on success.
|
|
112
|
+
*/
|
|
113
|
+
async cancelSubscription(orgId, appId) {
|
|
114
|
+
return this.client.call('rrext_account_billing', {
|
|
115
|
+
subcommand: 'cancel',
|
|
116
|
+
orgId,
|
|
117
|
+
appId,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// =========================================================================
|
|
121
|
+
// COMPUTE CREDITS WALLET
|
|
122
|
+
// =========================================================================
|
|
123
|
+
/**
|
|
124
|
+
* Reads the org's compute credit balance.
|
|
125
|
+
*
|
|
126
|
+
* The balance lives in a Redis-backed wallet on the engine side; this
|
|
127
|
+
* call is cheap and safe to poll (~1 req/s is fine for a live widget).
|
|
128
|
+
*
|
|
129
|
+
* @param orgId - Organisation UUID to query.
|
|
130
|
+
* @returns The credit balance with lifetime stats.
|
|
131
|
+
*/
|
|
132
|
+
async getCreditBalance(orgId) {
|
|
133
|
+
return this.client.call('rrext_account_billing', {
|
|
134
|
+
subcommand: 'credits_balance',
|
|
135
|
+
orgId,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Loads the purchasable credit packs, sourced from the Stripe catalog
|
|
140
|
+
* that Terraform maintains. Call once on modal mount.
|
|
141
|
+
*
|
|
142
|
+
* @returns Array of credit pack pricing rows.
|
|
143
|
+
*/
|
|
144
|
+
async listCreditPacks() {
|
|
145
|
+
const body = await this.client.call('rrext_account_billing', { subcommand: 'credits_packs' });
|
|
146
|
+
return body.packs ?? [];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Creates a one-off Stripe Checkout session for a credit pack purchase
|
|
150
|
+
* and returns the redirect URL.
|
|
151
|
+
*
|
|
152
|
+
* The frontend redirects the user to Stripe-hosted checkout; on success
|
|
153
|
+
* Stripe redirects back to the app, and the `checkout.session.completed`
|
|
154
|
+
* webhook increments the wallet server-side.
|
|
155
|
+
*
|
|
156
|
+
* @param orgId - Organisation UUID that the credits belong to.
|
|
157
|
+
* @param packId - Pack key returned by {@link listCreditPacks}.
|
|
158
|
+
* @param returnUrl - Where Stripe sends the user after payment.
|
|
159
|
+
* @returns Object with the Stripe checkout URL.
|
|
160
|
+
*/
|
|
161
|
+
async createCreditCheckout(orgId, packId, returnUrl) {
|
|
162
|
+
return this.client.call('rrext_account_billing', {
|
|
163
|
+
subcommand: 'credits_checkout',
|
|
164
|
+
orgId,
|
|
165
|
+
packId,
|
|
166
|
+
returnUrl,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.BillingApi = BillingApi;
|
|
171
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/client/billing.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAaH,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAa,UAAU;IACtB,4EAA4E;IAC5E,YAAoB,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;IAAG,CA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