rocketride 1.0.6 → 1.1.1

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 (175) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/account.js +284 -0
  3. package/dist/cjs/account.js.map +1 -0
  4. package/dist/cjs/billing.js +171 -0
  5. package/dist/cjs/billing.js.map +1 -0
  6. package/dist/cjs/client.js +1226 -756
  7. package/dist/cjs/client.js.map +1 -1
  8. package/dist/cjs/constants.js +10 -1
  9. package/dist/cjs/constants.js.map +1 -1
  10. package/dist/cjs/core/DAPBase.js +4 -1
  11. package/dist/cjs/core/DAPBase.js.map +1 -1
  12. package/dist/cjs/core/DAPClient.js +121 -50
  13. package/dist/cjs/core/DAPClient.js.map +1 -1
  14. package/dist/cjs/core/TransportBase.js +0 -10
  15. package/dist/cjs/core/TransportBase.js.map +1 -1
  16. package/dist/cjs/core/TransportWebSocket.js +30 -19
  17. package/dist/cjs/core/TransportWebSocket.js.map +1 -1
  18. package/dist/cjs/database.js +121 -0
  19. package/dist/cjs/database.js.map +1 -0
  20. package/dist/cjs/deploy.js +108 -0
  21. package/dist/cjs/deploy.js.map +1 -0
  22. package/dist/cjs/index.js +4 -0
  23. package/dist/cjs/index.js.map +1 -1
  24. package/dist/cjs/schema/Question.js +2 -0
  25. package/dist/cjs/schema/Question.js.map +1 -1
  26. package/dist/cjs/types/account.js +26 -0
  27. package/dist/cjs/types/account.js.map +1 -0
  28. package/dist/cjs/types/billing.js +26 -0
  29. package/dist/cjs/types/billing.js.map +1 -0
  30. package/dist/cjs/types/client.js +14 -0
  31. package/dist/cjs/types/client.js.map +1 -1
  32. package/dist/cjs/types/cprofile.js +26 -0
  33. package/dist/cjs/types/cprofile.js.map +1 -0
  34. package/dist/cjs/types/dashboard.js +26 -0
  35. package/dist/cjs/types/dashboard.js.map +1 -0
  36. package/dist/cjs/types/deploy.js +26 -0
  37. package/dist/cjs/types/deploy.js.map +1 -0
  38. package/dist/cjs/types/events.js +5 -1
  39. package/dist/cjs/types/events.js.map +1 -1
  40. package/dist/cjs/types/index.js +6 -0
  41. package/dist/cjs/types/index.js.map +1 -1
  42. package/dist/cjs/types/service.js +85 -0
  43. package/dist/cjs/types/service.js.map +1 -0
  44. package/dist/cli/cli/rocketride.js +335 -113
  45. package/dist/cli/cli/rocketride.js.map +1 -1
  46. package/dist/cli/client/account.js +284 -0
  47. package/dist/cli/client/account.js.map +1 -0
  48. package/dist/cli/client/billing.js +171 -0
  49. package/dist/cli/client/billing.js.map +1 -0
  50. package/dist/cli/client/client.js +1226 -756
  51. package/dist/cli/client/client.js.map +1 -1
  52. package/dist/cli/client/constants.js +10 -1
  53. package/dist/cli/client/constants.js.map +1 -1
  54. package/dist/cli/client/core/DAPBase.js +4 -1
  55. package/dist/cli/client/core/DAPBase.js.map +1 -1
  56. package/dist/cli/client/core/DAPClient.js +121 -50
  57. package/dist/cli/client/core/DAPClient.js.map +1 -1
  58. package/dist/cli/client/core/TransportBase.js +0 -10
  59. package/dist/cli/client/core/TransportBase.js.map +1 -1
  60. package/dist/cli/client/core/TransportWebSocket.js +30 -19
  61. package/dist/cli/client/core/TransportWebSocket.js.map +1 -1
  62. package/dist/cli/client/database.js +121 -0
  63. package/dist/cli/client/database.js.map +1 -0
  64. package/dist/cli/client/deploy.js +108 -0
  65. package/dist/cli/client/deploy.js.map +1 -0
  66. package/dist/cli/client/index.js +4 -0
  67. package/dist/cli/client/index.js.map +1 -1
  68. package/dist/cli/client/schema/Question.js +2 -0
  69. package/dist/cli/client/schema/Question.js.map +1 -1
  70. package/dist/cli/client/types/account.js +26 -0
  71. package/dist/cli/client/types/account.js.map +1 -0
  72. package/dist/cli/client/types/billing.js +26 -0
  73. package/dist/cli/client/types/billing.js.map +1 -0
  74. package/dist/cli/client/types/client.js +14 -0
  75. package/dist/cli/client/types/client.js.map +1 -1
  76. package/dist/cli/client/types/cprofile.js +26 -0
  77. package/dist/cli/client/types/cprofile.js.map +1 -0
  78. package/dist/cli/client/types/dashboard.js +26 -0
  79. package/dist/cli/client/types/dashboard.js.map +1 -0
  80. package/dist/cli/client/types/deploy.js +26 -0
  81. package/dist/cli/client/types/deploy.js.map +1 -0
  82. package/dist/cli/client/types/events.js +5 -1
  83. package/dist/cli/client/types/events.js.map +1 -1
  84. package/dist/cli/client/types/index.js +6 -0
  85. package/dist/cli/client/types/index.js.map +1 -1
  86. package/dist/cli/client/types/service.js +85 -0
  87. package/dist/cli/client/types/service.js.map +1 -0
  88. package/dist/esm/account.js +280 -0
  89. package/dist/esm/account.js.map +1 -0
  90. package/dist/esm/billing.js +167 -0
  91. package/dist/esm/billing.js.map +1 -0
  92. package/dist/esm/client.js +1226 -756
  93. package/dist/esm/client.js.map +1 -1
  94. package/dist/esm/constants.js +9 -0
  95. package/dist/esm/constants.js.map +1 -1
  96. package/dist/esm/core/DAPBase.js +4 -1
  97. package/dist/esm/core/DAPBase.js.map +1 -1
  98. package/dist/esm/core/DAPClient.js +121 -50
  99. package/dist/esm/core/DAPClient.js.map +1 -1
  100. package/dist/esm/core/TransportBase.js +0 -10
  101. package/dist/esm/core/TransportBase.js.map +1 -1
  102. package/dist/esm/core/TransportWebSocket.js +30 -19
  103. package/dist/esm/core/TransportWebSocket.js.map +1 -1
  104. package/dist/esm/database.js +117 -0
  105. package/dist/esm/database.js.map +1 -0
  106. package/dist/esm/deploy.js +104 -0
  107. package/dist/esm/deploy.js.map +1 -0
  108. package/dist/esm/index.js +4 -0
  109. package/dist/esm/index.js.map +1 -1
  110. package/dist/esm/schema/Question.js +2 -0
  111. package/dist/esm/schema/Question.js.map +1 -1
  112. package/dist/esm/types/account.js +25 -0
  113. package/dist/esm/types/account.js.map +1 -0
  114. package/dist/esm/types/billing.js +25 -0
  115. package/dist/esm/types/billing.js.map +1 -0
  116. package/dist/esm/types/client.js +13 -1
  117. package/dist/esm/types/client.js.map +1 -1
  118. package/dist/esm/types/cprofile.js +25 -0
  119. package/dist/esm/types/cprofile.js.map +1 -0
  120. package/dist/esm/types/dashboard.js +25 -0
  121. package/dist/esm/types/dashboard.js.map +1 -0
  122. package/dist/esm/types/deploy.js +25 -0
  123. package/dist/esm/types/deploy.js.map +1 -0
  124. package/dist/esm/types/events.js +5 -1
  125. package/dist/esm/types/events.js.map +1 -1
  126. package/dist/esm/types/index.js +6 -0
  127. package/dist/esm/types/index.js.map +1 -1
  128. package/dist/esm/types/service.js +82 -0
  129. package/dist/esm/types/service.js.map +1 -0
  130. package/dist/types/account.d.ts +209 -0
  131. package/dist/types/account.d.ts.map +1 -0
  132. package/dist/types/billing.d.ts +135 -0
  133. package/dist/types/billing.d.ts.map +1 -0
  134. package/dist/types/client.d.ts +568 -285
  135. package/dist/types/client.d.ts.map +1 -1
  136. package/dist/types/constants.d.ts +9 -0
  137. package/dist/types/constants.d.ts.map +1 -1
  138. package/dist/types/core/DAPBase.d.ts.map +1 -1
  139. package/dist/types/core/DAPClient.d.ts +89 -7
  140. package/dist/types/core/DAPClient.d.ts.map +1 -1
  141. package/dist/types/core/TransportBase.d.ts +1 -11
  142. package/dist/types/core/TransportBase.d.ts.map +1 -1
  143. package/dist/types/core/TransportWebSocket.d.ts +14 -11
  144. package/dist/types/core/TransportWebSocket.d.ts.map +1 -1
  145. package/dist/types/database.d.ts +90 -0
  146. package/dist/types/database.d.ts.map +1 -0
  147. package/dist/types/deploy.d.ts +90 -0
  148. package/dist/types/deploy.d.ts.map +1 -0
  149. package/dist/types/index.d.ts +2 -0
  150. package/dist/types/index.d.ts.map +1 -1
  151. package/dist/types/schema/Question.d.ts +3 -1
  152. package/dist/types/schema/Question.d.ts.map +1 -1
  153. package/dist/types/types/account.d.ts +171 -0
  154. package/dist/types/types/account.d.ts.map +1 -0
  155. package/dist/types/types/billing.d.ts +115 -0
  156. package/dist/types/types/billing.d.ts.map +1 -0
  157. package/dist/types/types/client.d.ts +241 -1
  158. package/dist/types/types/client.d.ts.map +1 -1
  159. package/dist/types/types/cprofile.d.ts +67 -0
  160. package/dist/types/types/cprofile.d.ts.map +1 -0
  161. package/dist/types/types/dashboard.d.ts +198 -0
  162. package/dist/types/types/dashboard.d.ts.map +1 -0
  163. package/dist/types/types/deploy.d.ts +48 -0
  164. package/dist/types/types/deploy.d.ts.map +1 -0
  165. package/dist/types/types/events.d.ts +90 -95
  166. package/dist/types/types/events.d.ts.map +1 -1
  167. package/dist/types/types/index.d.ts +6 -0
  168. package/dist/types/types/index.d.ts.map +1 -1
  169. package/dist/types/types/pipeline.d.ts +10 -2
  170. package/dist/types/types/pipeline.d.ts.map +1 -1
  171. package/dist/types/types/service.d.ts +189 -0
  172. package/dist/types/types/service.d.ts.map +1 -0
  173. package/dist/types/types/task.d.ts +5 -1
  174. package/dist/types/types/task.d.ts.map +1 -1
  175. package/package.json +12 -7
package/README.md CHANGED
@@ -7,10 +7,10 @@
7
7
  </p>
8
8
 
9
9
  <p align="center">
10
- <a href="https://www.npmjs.com/package/rocketride"><img src="https://img.shields.io/npm/v/rocketride?color=222223&label=npm" alt="npm"></a>
10
+ <a href="https://www.npmjs.com/package/rocketride"><img src="https://img.shields.io/npm/v/rocketride?color=222223&label=NPM" alt="npm"></a>
11
11
  <a href="https://github.com/rocketride-org/rocketride-server"><img src="https://img.shields.io/github/stars/rocketride-org/rocketride-server?style=flat&color=238636&label=GitHub&logo=github&logoColor=white" alt="GitHub"></a>
12
12
  <a href="https://discord.gg/9hr3tdZmEG"><img src="https://img.shields.io/badge/Discord-Join-370b7a?logo=discord&logoColor=white" alt="Discord"></a>
13
- <a href="https://github.com/rocketride-org/rocketride-server/blob/develop/LICENSE"><img src="https://img.shields.io/badge/license-MIT-41b6e6" alt="MIT License"></a>
13
+ <a href="https://github.com/rocketride-org/rocketride-server/blob/develop/LICENSE"><img src="https://img.shields.io/badge/License-MIT-41b6e6" alt="MIT License"></a>
14
14
  </p>
15
15
 
16
16
  ## Quick Start
@@ -0,0 +1,284 @@
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.AccountApi = void 0;
27
+ // =============================================================================
28
+ // ACCOUNT API CLASS
29
+ // =============================================================================
30
+ /**
31
+ * Typed wrapper around the `rrext_account_*` DAP commands.
32
+ *
33
+ * Accessed via `client.account` — not instantiated directly. All methods
34
+ * delegate to {@link RocketRideClient.dap} which handles envelope
35
+ * unwrapping and error propagation.
36
+ */
37
+ class AccountApi {
38
+ /** @param client - The parent RocketRideClient that owns this namespace. */
39
+ constructor(client) {
40
+ this.client = client;
41
+ }
42
+ // =========================================================================
43
+ // PROFILE
44
+ // =========================================================================
45
+ /**
46
+ * Fetches the current user's profile from the server.
47
+ *
48
+ * @returns The user's profile data.
49
+ */
50
+ async getProfile() {
51
+ return this.client.call('rrext_account_me', { subcommand: 'get' });
52
+ }
53
+ /**
54
+ * Persists updated profile fields.
55
+ *
56
+ * @param fields - The profile fields to update.
57
+ */
58
+ async updateProfile(fields) {
59
+ await this.client.call('rrext_account_me', { subcommand: 'update', ...fields });
60
+ }
61
+ /**
62
+ * Sets the user's preferred default team.
63
+ *
64
+ * @param teamId - The team ID to set as default.
65
+ */
66
+ async setDefaultTeam(teamId) {
67
+ await this.client.call('rrext_account_me', { subcommand: 'set_default_team', teamId });
68
+ }
69
+ /**
70
+ * Permanently deletes the current user's account.
71
+ */
72
+ async deleteAccount() {
73
+ await this.client.call('rrext_account_me', { subcommand: 'delete' });
74
+ }
75
+ // =========================================================================
76
+ // ORGANIZATION
77
+ // =========================================================================
78
+ /**
79
+ * Fetches the organization detail for the given org.
80
+ *
81
+ * @param orgId - Organisation UUID. The server may infer the org if omitted.
82
+ * @returns The organization detail (id, name, plan, memberCount, teamCount).
83
+ */
84
+ async getOrg(orgId) {
85
+ return this.client.call('rrext_account_org', { subcommand: 'get', ...(orgId ? { orgId } : {}) });
86
+ }
87
+ /**
88
+ * Updates the organization name.
89
+ *
90
+ * @param orgId - Organisation UUID.
91
+ * @param name - The new organization name.
92
+ */
93
+ async updateOrgName(orgId, name) {
94
+ await this.client.call('rrext_account_org', { subcommand: 'update', orgId, name });
95
+ }
96
+ // =========================================================================
97
+ // API KEYS
98
+ // =========================================================================
99
+ /**
100
+ * Fetches the list of API keys for the current user.
101
+ *
102
+ * @returns Array of API key records.
103
+ */
104
+ async listKeys() {
105
+ const body = await this.client.call('rrext_account_keys', { subcommand: 'list' });
106
+ return body.keys ?? [];
107
+ }
108
+ /**
109
+ * Creates a new API key and returns the raw key string.
110
+ *
111
+ * @param params - Key creation parameters (name, permissions, expiresAt).
112
+ * @returns Object containing the raw key string.
113
+ */
114
+ async createKey(params) {
115
+ const body = await this.client.call('rrext_account_keys', { subcommand: 'create', ...params });
116
+ return { key: body.key };
117
+ }
118
+ /**
119
+ * Revokes an API key by its ID.
120
+ *
121
+ * @param keyId - The key to revoke.
122
+ */
123
+ async revokeKey(keyId) {
124
+ await this.client.call('rrext_account_keys', { subcommand: 'revoke', keyId });
125
+ }
126
+ // =========================================================================
127
+ // MEMBERS
128
+ // =========================================================================
129
+ /**
130
+ * Fetches the flat list of organization members.
131
+ *
132
+ * @param orgId - Organisation UUID.
133
+ * @returns Array of member records.
134
+ */
135
+ async listMembers(orgId) {
136
+ const body = await this.client.call('rrext_account_members', { subcommand: 'list', orgId });
137
+ return body.members ?? [];
138
+ }
139
+ /**
140
+ * Sends an invitation to a new organization member.
141
+ *
142
+ * @param orgId - Organisation UUID.
143
+ * @param params - Invitation parameters (email, givenName, familyName, role).
144
+ */
145
+ async inviteMember(orgId, params) {
146
+ await this.client.call('rrext_account_members', { subcommand: 'invite', orgId, ...params });
147
+ }
148
+ /**
149
+ * Updates an organization member's role.
150
+ *
151
+ * @param orgId - Organisation UUID.
152
+ * @param userId - The member's user ID.
153
+ * @param role - The new role string.
154
+ */
155
+ async updateMemberRole(orgId, userId, role) {
156
+ await this.client.call('rrext_account_members', { subcommand: 'update', orgId, userId, role });
157
+ }
158
+ /**
159
+ * Removes an organization member.
160
+ *
161
+ * @param orgId - Organisation UUID.
162
+ * @param userId - The member's user ID.
163
+ */
164
+ async removeMember(orgId, userId) {
165
+ await this.client.call('rrext_account_members', { subcommand: 'delete', orgId, userId });
166
+ }
167
+ // =========================================================================
168
+ // TEAMS
169
+ // =========================================================================
170
+ /**
171
+ * Fetches the flat list of teams in the organization.
172
+ *
173
+ * @param orgId - Organisation UUID.
174
+ * @returns Array of team summary records.
175
+ */
176
+ async listTeams(orgId) {
177
+ const body = await this.client.call('rrext_account_teams', { subcommand: 'list', orgId });
178
+ return body.teams ?? [];
179
+ }
180
+ /**
181
+ * Fetches full detail (including member list) for a specific team.
182
+ *
183
+ * @param orgId - Organisation UUID.
184
+ * @param teamId - The team to load.
185
+ * @returns The team detail with nested members.
186
+ */
187
+ async getTeamDetail(orgId, teamId) {
188
+ return this.client.call('rrext_account_teams', { subcommand: 'get', orgId, teamId });
189
+ }
190
+ /**
191
+ * Creates a new team.
192
+ *
193
+ * @param orgId - Organisation UUID.
194
+ * @param name - The team name.
195
+ */
196
+ async createTeam(orgId, name) {
197
+ await this.client.call('rrext_account_teams', { subcommand: 'create', orgId, name });
198
+ }
199
+ /**
200
+ * Deletes a team.
201
+ *
202
+ * @param orgId - Organisation UUID.
203
+ * @param teamId - The team to delete.
204
+ */
205
+ async deleteTeam(orgId, teamId) {
206
+ await this.client.call('rrext_account_teams', { subcommand: 'delete', orgId, teamId });
207
+ }
208
+ /**
209
+ * Adds a member to a team with specified permissions.
210
+ *
211
+ * @param orgId - Organisation UUID.
212
+ * @param params - Parameters (teamId, userId, permissions).
213
+ */
214
+ async addTeamMember(orgId, params) {
215
+ await this.client.call('rrext_account_teams', { subcommand: 'add_member', orgId, ...params });
216
+ }
217
+ /**
218
+ * Updates a team member's permissions.
219
+ *
220
+ * @param orgId - Organisation UUID.
221
+ * @param params - Parameters (teamId, userId, permissions).
222
+ */
223
+ async updateTeamMemberPerms(orgId, params) {
224
+ await this.client.call('rrext_account_teams', { subcommand: 'update_member', orgId, ...params });
225
+ }
226
+ /**
227
+ * Removes a member from a team.
228
+ *
229
+ * @param orgId - Organisation UUID.
230
+ * @param params - Parameters (teamId, userId).
231
+ */
232
+ async removeTeamMember(orgId, params) {
233
+ await this.client.call('rrext_account_teams', { subcommand: 'delete_member', orgId, ...params });
234
+ }
235
+ // =========================================================================
236
+ // ENVIRONMENT SECRETS
237
+ // =========================================================================
238
+ /**
239
+ * Returns the available ROCKETRIDE_* key names from the merged environment.
240
+ * Does not return values — only key names for use in dropdowns.
241
+ *
242
+ * @returns Array of key names (e.g. ['ROCKETRIDE_ANTHROPIC_KEY', 'ROCKETRIDE_OPENAI_KEY']).
243
+ */
244
+ async getEnvironmentKeys() {
245
+ const body = await this.client.call('rrext_account_me', { subcommand: 'env_keys' });
246
+ return body.keys ?? [];
247
+ }
248
+ /**
249
+ * Reads the environment dict for a scope (org, team, or user).
250
+ *
251
+ * @param scope - One of 'org', 'team', 'user'.
252
+ * @param scopeId - For org: orgId. For team: teamId. For user: omit (uses current user).
253
+ * @returns Decrypted key-value dict.
254
+ */
255
+ async getEnv(scope, scopeId) {
256
+ const command = scope === 'org' ? 'rrext_account_org' : scope === 'team' ? 'rrext_account_teams' : 'rrext_account_me';
257
+ const args = { subcommand: 'get_env' };
258
+ if (scope === 'org' && scopeId)
259
+ args.orgId = scopeId;
260
+ if (scope === 'team' && scopeId)
261
+ args.teamId = scopeId;
262
+ const body = await this.client.call(command, args);
263
+ return body.env ?? {};
264
+ }
265
+ /**
266
+ * Writes the full environment dict for a scope (org, team, or user).
267
+ * Replaces the entire set of keys at that scope level.
268
+ *
269
+ * @param scope - One of 'org', 'team', 'user'.
270
+ * @param env - Full key-value dict to store.
271
+ * @param scopeId - For org: orgId. For team: teamId. For user: omit.
272
+ */
273
+ async setEnv(scope, env, scopeId) {
274
+ const command = scope === 'org' ? 'rrext_account_org' : scope === 'team' ? 'rrext_account_teams' : 'rrext_account_me';
275
+ const args = { subcommand: 'set_env', env };
276
+ if (scope === 'org' && scopeId)
277
+ args.orgId = scopeId;
278
+ if (scope === 'team' && scopeId)
279
+ args.teamId = scopeId;
280
+ await this.client.call(command, args);
281
+ }
282
+ }
283
+ exports.AccountApi = AccountApi;
284
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/client/account.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAcH,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAa,UAAU;IACtB,4EAA4E;IAC5E,YAAoB,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;IAAG,CAAC;IAEhD,4EAA4E;IAC5E,UAAU;IACV,4EAA4E;IAE5E;;;;OAIG;IACH,KAAK,CAAC,UAAU;QACf,OAAO,IAAI,CA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OAAO;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;QACrD,IAAI,KAAK,KAAK,MAAM,IAAI,OAAO;YAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACvD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAkC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;IACvB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,KAA8B,EAAE,GAA2B,EAAE,OAAgB;QACzF,MAAM,OAAO,GAAG,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,kBAAkB,CAAC;QACtH,MAAM,IAAI,GAA4B,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;QACrE,IAAI,KAAK,KAAK,KAAK,IAAI,OAAO;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;QACrD,IAAI,KAAK,KAAK,MAAM,IAAI,OAAO;YAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACvD,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;CACD;AA5QD,gCA4QC"}
@@ -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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