@crowdedkingdoms/crowdyjs 12.2.0 → 13.0.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.
@@ -1,238 +0,0 @@
1
- import { OrgEnvironmentsDocument, OrgEnvironmentDocument, EnvironmentVersionsDocument, EnvironmentForwardVersionsDocument, EnvironmentDatacentersDocument, EnvironmentFlavorsDocument, EnvironmentQuoteDocument, CreateEnvironmentDocument, DestroyEnvironmentDocument, PurgeEnvironmentDocument, ResumeEnvironmentDocument, UpdateEnvironmentScalingDocument, UpdateEnvironmentBillingTiersDocument, RedeployEnvironmentDocument, EnvironmentRedeployPlanDocument, RestartEnvironmentServicesDocument, LinkAppToEnvironmentDocument, } from '../generated/graphql.js';
2
- /**
3
- * Dedicated customer environments — exposed as `client.environments` (and
4
- * grouped under `client.admin`).
5
- *
6
- * Targets the **management-api**. Reads require the `view_environments` org
7
- * permission ({@link quote} requires `view_billing`); the deploy/scale/destroy
8
- * mutations require `manage_environments`. Lifecycle mutations are asynchronous:
9
- * they return a {@link CksEnvironmentChangeOrder} you poll via {@link get} until
10
- * its `status` is `succeeded`/`failed`. `BigInt` ids are decimal strings; `since`
11
- * args are ISO-8601 `DateTime` strings.
12
- *
13
- * WARNING: {@link create}, {@link destroy}, {@link purge}, and
14
- * {@link redeploy} provision or tear down real cloud resources (and reserve
15
- * wallet funds). Drive them only against a sandbox org in tests.
16
- *
17
- * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` / `SCOPE_MISSING`
18
- * per the permission notes above.
19
- */
20
- export class EnvironmentsAPI {
21
- constructor(management) {
22
- this.management = management;
23
- }
24
- /**
25
- * List every environment owned by an org (any lifecycle state). Summary rows
26
- * only — use {@link get} for full detail. Requires `view_environments`.
27
- *
28
- * @param orgId - Numeric org id.
29
- * @returns The org's environments.
30
- */
31
- async list(orgId) {
32
- const data = await this.management.request(OrgEnvironmentsDocument, {
33
- orgId,
34
- });
35
- return data.orgEnvironments;
36
- }
37
- /**
38
- * Full detail for one environment (components, change orders, outputs).
39
- * Requires `view_environments`.
40
- *
41
- * @param orgId - Numeric org id.
42
- * @param slug - Environment slug.
43
- * @returns The {@link CksEnvironmentDetail}, or `null` if not found.
44
- */
45
- async get(orgId, slug) {
46
- const data = await this.management.request(OrgEnvironmentDocument, {
47
- orgId,
48
- slug,
49
- });
50
- return data.orgEnvironment;
51
- }
52
- /**
53
- * Catalog of deployable environment release versions (newest first). Any
54
- * authenticated caller.
55
- *
56
- * @returns The available environment versions.
57
- */
58
- async versions() {
59
- const data = await this.management.request(EnvironmentVersionsDocument, {});
60
- return data.environmentVersions;
61
- }
62
- /**
63
- * Versions a specific environment may upgrade to (forward-only). Requires
64
- * `view_environments`.
65
- *
66
- * @param orgId - Numeric org id.
67
- * @param slug - Environment slug.
68
- * @returns The upgrade-target versions.
69
- */
70
- async forwardVersions(orgId, slug) {
71
- const data = await this.management.request(EnvironmentForwardVersionsDocument, { orgId, slug });
72
- return data.environmentForwardVersions;
73
- }
74
- /**
75
- * OVH datacenters with at least one customer-selectable flavor. Requires an
76
- * authenticated caller.
77
- *
78
- * @returns The selectable datacenters.
79
- */
80
- async datacenters() {
81
- const data = await this.management.request(EnvironmentDatacentersDocument, {});
82
- return data.environmentDatacenters;
83
- }
84
- /**
85
- * Customer-selectable instance flavors (with pricing) in a datacenter.
86
- *
87
- * @param datacenter - Datacenter/region code from {@link datacenters}.
88
- * @returns The available flavors.
89
- */
90
- async flavors(datacenter) {
91
- const data = await this.management.request(EnvironmentFlavorsDocument, {
92
- datacenter,
93
- });
94
- return data.environmentFlavors;
95
- }
96
- /**
97
- * Price a proposed environment selection and check the wallet can cover it.
98
- * Read-only (provisions nothing). Requires `view_billing`.
99
- *
100
- * @param input - {@link EnvironmentQuoteInput}: org, datacenter, flavors,
101
- * server counts.
102
- * @returns The {@link CksEnvironmentQuote} including the `canCreate` gate.
103
- */
104
- async quote(input) {
105
- const data = await this.management.request(EnvironmentQuoteDocument, {
106
- input,
107
- });
108
- return data.environmentQuote;
109
- }
110
- /**
111
- * Provision a new dedicated environment. Requires `manage_environments`.
112
- * Reserves wallet funds and starts cloud provisioning — poll {@link get}.
113
- *
114
- * @param input - {@link CreateEnvironmentInput}.
115
- * @returns The new environment's detail with its initial change order.
116
- */
117
- async create(input) {
118
- const data = await this.management.request(CreateEnvironmentDocument, {
119
- input,
120
- });
121
- return data.createEnvironment;
122
- }
123
- /**
124
- * Tear down an environment's runtime (keeps the record). Requires
125
- * `manage_environments`.
126
- *
127
- * @param input - {@link DestroyEnvironmentInput}.
128
- * @returns The destroy {@link CksEnvironmentChangeOrder}.
129
- */
130
- async destroy(input) {
131
- const data = await this.management.request(DestroyEnvironmentDocument, {
132
- input,
133
- });
134
- return data.destroyEnvironment;
135
- }
136
- /**
137
- * Permanently purge a destroyed environment's record. Requires
138
- * `manage_environments`. Irreversible.
139
- *
140
- * @param input - {@link PurgeEnvironmentInput}.
141
- * @returns `true` on success.
142
- */
143
- async purge(input) {
144
- const data = await this.management.request(PurgeEnvironmentDocument, {
145
- input,
146
- });
147
- return data.purgeEnvironment;
148
- }
149
- /**
150
- * Resume a suspended (non-payment) environment after funding the wallet.
151
- * Requires `manage_environments`.
152
- *
153
- * @param input - {@link ResumeEnvironmentInput}.
154
- * @returns The resume {@link CksEnvironmentChangeOrder}.
155
- */
156
- async resume(input) {
157
- const data = await this.management.request(ResumeEnvironmentDocument, {
158
- input,
159
- });
160
- return data.resumeEnvironment;
161
- }
162
- /**
163
- * Change min/max server counts (autoscaling bounds). Requires
164
- * `manage_environments`.
165
- *
166
- * @param input - {@link UpdateEnvironmentScalingInput}.
167
- * @returns The scaling {@link CksEnvironmentChangeOrder}.
168
- */
169
- async updateScaling(input) {
170
- const data = await this.management.request(UpdateEnvironmentScalingDocument, { input });
171
- return data.updateEnvironmentScaling;
172
- }
173
- /**
174
- * Set an environment's Buddy / GraphQL / Postgres capacity billing-tier
175
- * levels (from {@link BillingAPI.buddyTiers} / {@link BillingAPI.graphqlTiers}
176
- * / {@link BillingAPI.postgresTiers}). Requires `manage_environments`.
177
- *
178
- * @param input - {@link UpdateEnvironmentBillingTiersInput} (org, slug, and
179
- * the per-resource tier levels to set).
180
- * @returns The updated {@link CksEnvironment}.
181
- */
182
- async updateBillingTiers(input) {
183
- const data = await this.management.request(UpdateEnvironmentBillingTiersDocument, { input });
184
- return data.updateEnvironmentBillingTiers;
185
- }
186
- /**
187
- * DRY RUN of {@link redeploy}: what moving the environment to a target
188
- * release version would do — component version diffs (game-api, Buddy),
189
- * whether game-DB schema DDL applies or is skipped, and the pipeline
190
- * tasks/steps that would run — without creating a change order or touching
191
- * any VM. Anything that would make the real mutation fail is returned in
192
- * `blockers`. Read-only; requires `view_environments`.
193
- *
194
- * @param input - {@link RedeployEnvironmentInput} (same shape as redeploy).
195
- * @returns The plan preview.
196
- */
197
- async redeployPlan(input) {
198
- const data = await this.management.request(EnvironmentRedeployPlanDocument, { input });
199
- return data.environmentRedeployPlan;
200
- }
201
- /**
202
- * Deploy a (forward-only) environment release version. Requires
203
- * `manage_environments`. Preview first with {@link redeployPlan}.
204
- *
205
- * @param input - {@link RedeployEnvironmentInput} (target version).
206
- * @returns The deploy {@link CksEnvironmentChangeOrder}.
207
- */
208
- async redeploy(input) {
209
- const data = await this.management.request(RedeployEnvironmentDocument, {
210
- input,
211
- });
212
- return data.redeployEnvironment;
213
- }
214
- /**
215
- * Restart an environment's services without redeploying. Requires
216
- * `manage_environments`.
217
- *
218
- * @param input - {@link RestartEnvironmentServicesInput}.
219
- * @returns The restart {@link CksEnvironmentChangeOrder}.
220
- */
221
- async restartServices(input) {
222
- const data = await this.management.request(RestartEnvironmentServicesDocument, { input });
223
- return data.restartEnvironmentServices;
224
- }
225
- /**
226
- * Link an app to an environment so its runtime is served there. Requires
227
- * `manage_environments`.
228
- *
229
- * @param input - {@link LinkAppToEnvironmentInput}.
230
- * @returns The updated {@link App} (with its new routing fields).
231
- */
232
- async linkApp(input) {
233
- const data = await this.management.request(LinkAppToEnvironmentDocument, {
234
- input,
235
- });
236
- return data.linkAppToEnvironment;
237
- }
238
- }