@crowdedkingdoms/crowdyjs 1.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.
- package/LICENSE +21 -0
- package/MIGRATION.md +247 -0
- package/README.md +303 -0
- package/dist/auth-state.d.ts +11 -0
- package/dist/auth-state.d.ts.map +1 -0
- package/dist/auth-state.js +13 -0
- package/dist/client.d.ts +135 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +150 -0
- package/dist/crowdy-client.d.ts +182 -0
- package/dist/crowdy-client.d.ts.map +1 -0
- package/dist/crowdy-client.js +146 -0
- package/dist/domains/actors.d.ts +117 -0
- package/dist/domains/actors.d.ts.map +1 -0
- package/dist/domains/actors.js +140 -0
- package/dist/domains/admin.d.ts +61 -0
- package/dist/domains/admin.d.ts.map +1 -0
- package/dist/domains/admin.js +33 -0
- package/dist/domains/appAccess.d.ts +141 -0
- package/dist/domains/appAccess.d.ts.map +1 -0
- package/dist/domains/appAccess.js +198 -0
- package/dist/domains/apps.d.ts +192 -0
- package/dist/domains/apps.d.ts.map +1 -0
- package/dist/domains/apps.js +217 -0
- package/dist/domains/auth.d.ts +163 -0
- package/dist/domains/auth.d.ts.map +1 -0
- package/dist/domains/auth.js +208 -0
- package/dist/domains/avatars.d.ts +94 -0
- package/dist/domains/avatars.d.ts.map +1 -0
- package/dist/domains/avatars.js +137 -0
- package/dist/domains/billing.d.ts +97 -0
- package/dist/domains/billing.d.ts.map +1 -0
- package/dist/domains/billing.js +131 -0
- package/dist/domains/channels.d.ts +293 -0
- package/dist/domains/channels.d.ts.map +1 -0
- package/dist/domains/channels.js +353 -0
- package/dist/domains/chunks.d.ts +133 -0
- package/dist/domains/chunks.d.ts.map +1 -0
- package/dist/domains/chunks.js +153 -0
- package/dist/domains/controlPlane.d.ts +174 -0
- package/dist/domains/controlPlane.d.ts.map +1 -0
- package/dist/domains/controlPlane.js +252 -0
- package/dist/domains/environments.d.ts +155 -0
- package/dist/domains/environments.d.ts.map +1 -0
- package/dist/domains/environments.js +223 -0
- package/dist/domains/gameApps.d.ts +114 -0
- package/dist/domains/gameApps.d.ts.map +1 -0
- package/dist/domains/gameApps.js +169 -0
- package/dist/domains/gameModel.d.ts +668 -0
- package/dist/domains/gameModel.d.ts.map +1 -0
- package/dist/domains/gameModel.js +816 -0
- package/dist/domains/host.d.ts +35 -0
- package/dist/domains/host.d.ts.map +1 -0
- package/dist/domains/host.js +40 -0
- package/dist/domains/organizations.d.ts +179 -0
- package/dist/domains/organizations.d.ts.map +1 -0
- package/dist/domains/organizations.js +269 -0
- package/dist/domains/payments.d.ts +104 -0
- package/dist/domains/payments.d.ts.map +1 -0
- package/dist/domains/payments.js +129 -0
- package/dist/domains/platform.d.ts +49 -0
- package/dist/domains/platform.d.ts.map +1 -0
- package/dist/domains/platform.js +50 -0
- package/dist/domains/quotas.d.ts +62 -0
- package/dist/domains/quotas.d.ts.map +1 -0
- package/dist/domains/quotas.js +79 -0
- package/dist/domains/serverStatus.d.ts +90 -0
- package/dist/domains/serverStatus.d.ts.map +1 -0
- package/dist/domains/serverStatus.js +104 -0
- package/dist/domains/sharedEnvironment.d.ts +133 -0
- package/dist/domains/sharedEnvironment.d.ts.map +1 -0
- package/dist/domains/sharedEnvironment.js +179 -0
- package/dist/domains/state.d.ts +64 -0
- package/dist/domains/state.d.ts.map +1 -0
- package/dist/domains/state.js +75 -0
- package/dist/domains/teams.d.ts +292 -0
- package/dist/domains/teams.d.ts.map +1 -0
- package/dist/domains/teams.js +352 -0
- package/dist/domains/teleport.d.ts +41 -0
- package/dist/domains/teleport.d.ts.map +1 -0
- package/dist/domains/teleport.js +43 -0
- package/dist/domains/udp.d.ts +405 -0
- package/dist/domains/udp.d.ts.map +1 -0
- package/dist/domains/udp.js +457 -0
- package/dist/domains/usage.d.ts +76 -0
- package/dist/domains/usage.d.ts.map +1 -0
- package/dist/domains/usage.js +110 -0
- package/dist/domains/users.d.ts +147 -0
- package/dist/domains/users.d.ts.map +1 -0
- package/dist/domains/users.js +195 -0
- package/dist/domains/voxels.d.ts +136 -0
- package/dist/domains/voxels.d.ts.map +1 -0
- package/dist/domains/voxels.js +153 -0
- package/dist/errors.d.ts +158 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +142 -0
- package/dist/generated/graphql.d.ts +12206 -0
- package/dist/generated/graphql.d.ts.map +1 -0
- package/dist/generated/graphql.js +474 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +1 -0
- package/dist/realtime.d.ts +319 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +390 -0
- package/dist/session.d.ts +73 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +96 -0
- package/dist/subscriptions.d.ts +2 -0
- package/dist/subscriptions.d.ts.map +1 -0
- package/dist/subscriptions.js +1 -0
- package/dist/types.d.ts +658 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +61 -0
- package/dist/utils.d.ts +98 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +136 -0
- package/dist/world.d.ts +236 -0
- package/dist/world.d.ts.map +1 -0
- package/dist/world.js +275 -0
- package/package.json +73 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { GraphQLClient } from '../client.js';
|
|
2
|
+
import { type SharedEnvPlansQuery, type OrgFreeAppQuotaQuery, type AppSharedSubscriptionQuery, type AppRuntimeStateQuery, type OrgAutoBillingQuery, type OrgPaymentMethodsQuery, type PublishAppToSharedMutation, type CancelSharedSubscriptionMutation, type SetAppSpendCapsMutation, type SetAutoBillingMutation, type SetupSharedPaymentMethodMutation, type RemoveSharedPaymentMethodMutation, type PaymentProvider } from '../generated/graphql.js';
|
|
3
|
+
/**
|
|
4
|
+
* Shared-environment app publishing, runtime gating, spend caps, and
|
|
5
|
+
* auto-billing — exposed as `client.sharedEnvironment` (and grouped under
|
|
6
|
+
* `client.admin`).
|
|
7
|
+
*
|
|
8
|
+
* Targets the **management-api**. {@link plans} is public; the read operations
|
|
9
|
+
* require org membership; spend-cap / auto-billing / subscription mutations
|
|
10
|
+
* require the `manage_billing` org permission; {@link publishApp} currently
|
|
11
|
+
* requires super-admin (preview). Monetary values are `*Cents` (minor units).
|
|
12
|
+
*
|
|
13
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` / `SCOPE_MISSING`
|
|
14
|
+
* per the permission notes above; `IDEMPOTENCY_CONFLICT` on key reuse with
|
|
15
|
+
* different args.
|
|
16
|
+
*/
|
|
17
|
+
export declare class SharedEnvironmentAPI {
|
|
18
|
+
private readonly management;
|
|
19
|
+
constructor(management: GraphQLClient);
|
|
20
|
+
/**
|
|
21
|
+
* Public catalog of paid shared-environment app-slot plans.
|
|
22
|
+
*
|
|
23
|
+
* @returns The available plans.
|
|
24
|
+
*/
|
|
25
|
+
plans(): Promise<SharedEnvPlansQuery['sharedEnvPlans']>;
|
|
26
|
+
/**
|
|
27
|
+
* An org's free shared-app slot quota and usage. Caller must be an org member.
|
|
28
|
+
*
|
|
29
|
+
* @param orgId - Numeric org id.
|
|
30
|
+
* @returns The {@link FreeAppQuota}.
|
|
31
|
+
*/
|
|
32
|
+
freeAppQuota(orgId: string): Promise<OrgFreeAppQuotaQuery['orgFreeAppQuota']>;
|
|
33
|
+
/**
|
|
34
|
+
* An app's paid shared subscription, or `null` when on the free quota.
|
|
35
|
+
*
|
|
36
|
+
* @param appId - Numeric app id.
|
|
37
|
+
* @returns The {@link AppSharedSubscription} or `null`.
|
|
38
|
+
*/
|
|
39
|
+
appSubscription(appId: string): Promise<AppSharedSubscriptionQuery['appSharedSubscription']>;
|
|
40
|
+
/**
|
|
41
|
+
* The shared-environment runtime gate + current usage for an app.
|
|
42
|
+
*
|
|
43
|
+
* @param appId - Numeric app id.
|
|
44
|
+
* @returns The {@link AppRuntimeState}.
|
|
45
|
+
*/
|
|
46
|
+
appRuntimeState(appId: string): Promise<AppRuntimeStateQuery['appRuntimeState']>;
|
|
47
|
+
/**
|
|
48
|
+
* An org's off-session auto-billing configuration.
|
|
49
|
+
*
|
|
50
|
+
* @param orgId - Numeric org id.
|
|
51
|
+
* @returns The {@link OrgAutoBilling} config.
|
|
52
|
+
*/
|
|
53
|
+
autoBilling(orgId: string): Promise<OrgAutoBillingQuery['orgAutoBilling']>;
|
|
54
|
+
/**
|
|
55
|
+
* List an org's saved (vaulted) payment methods.
|
|
56
|
+
*
|
|
57
|
+
* @param orgId - Numeric org id.
|
|
58
|
+
* @returns The saved payment methods.
|
|
59
|
+
*/
|
|
60
|
+
paymentMethods(orgId: string): Promise<OrgPaymentMethodsQuery['orgPaymentMethods']>;
|
|
61
|
+
/**
|
|
62
|
+
* Publish an app to the shared game-api. Free under the org quota (no charge);
|
|
63
|
+
* pass `planId` for a paid subscription (returns a checkout to complete).
|
|
64
|
+
* Currently super-admin only (preview).
|
|
65
|
+
*
|
|
66
|
+
* @param appId - Numeric app id.
|
|
67
|
+
* @param opts - Optional `planId`, `provider`, `successUrl`, `cancelUrl`, and
|
|
68
|
+
* `idempotencyKey`.
|
|
69
|
+
* @returns The {@link PublishAppResult} (free flag + optional checkout).
|
|
70
|
+
*/
|
|
71
|
+
publishApp(appId: string, opts?: {
|
|
72
|
+
planId?: string;
|
|
73
|
+
provider?: PaymentProvider;
|
|
74
|
+
successUrl?: string;
|
|
75
|
+
cancelUrl?: string;
|
|
76
|
+
idempotencyKey?: string;
|
|
77
|
+
}): Promise<PublishAppToSharedMutation['publishAppToShared']>;
|
|
78
|
+
/**
|
|
79
|
+
* Cancel an app's paid shared subscription. Requires `manage_billing`.
|
|
80
|
+
*
|
|
81
|
+
* @param appId - Numeric app id.
|
|
82
|
+
* @param idempotencyKey - Optional idempotency key for safe retries.
|
|
83
|
+
* @returns The updated {@link AppSharedSubscription}.
|
|
84
|
+
*/
|
|
85
|
+
cancelSubscription(appId: string, idempotencyKey?: string): Promise<CancelSharedSubscriptionMutation['cancelSharedSubscription']>;
|
|
86
|
+
/**
|
|
87
|
+
* Set per-app hourly/daily spend caps (cents); `null` clears a cap. Requires
|
|
88
|
+
* `manage_billing`. Returns the re-evaluated runtime state.
|
|
89
|
+
*
|
|
90
|
+
* @param appId - Numeric app id.
|
|
91
|
+
* @param caps - `hourlyLimitCents` and/or `dailyLimitCents` (decimal strings).
|
|
92
|
+
* @returns The updated {@link AppRuntimeState}.
|
|
93
|
+
*/
|
|
94
|
+
setSpendCaps(appId: string, caps?: {
|
|
95
|
+
hourlyLimitCents?: string | null;
|
|
96
|
+
dailyLimitCents?: string | null;
|
|
97
|
+
}): Promise<SetAppSpendCapsMutation['setAppSpendCaps']>;
|
|
98
|
+
/**
|
|
99
|
+
* Enable/disable and configure off-session auto-billing for an org. Requires
|
|
100
|
+
* `manage_billing`.
|
|
101
|
+
*
|
|
102
|
+
* @param orgId - Numeric org id.
|
|
103
|
+
* @param config - `enabled` plus optional `limitCents`, `rechargeAmountCents`,
|
|
104
|
+
* `lowWaterThresholdCents`, and `idempotencyKey`.
|
|
105
|
+
* @returns The updated {@link OrgAutoBilling} config.
|
|
106
|
+
*/
|
|
107
|
+
setAutoBilling(orgId: string, config: {
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
limitCents?: string | null;
|
|
110
|
+
rechargeAmountCents?: string | null;
|
|
111
|
+
lowWaterThresholdCents?: string | null;
|
|
112
|
+
idempotencyKey?: string;
|
|
113
|
+
}): Promise<SetAutoBillingMutation['setAutoBilling']>;
|
|
114
|
+
/**
|
|
115
|
+
* Begin vaulting a card for off-session auto-billing (returns a Stripe
|
|
116
|
+
* SetupIntent client secret). No charge here. Requires `manage_billing`.
|
|
117
|
+
*
|
|
118
|
+
* @param orgId - Numeric org id.
|
|
119
|
+
* @param idempotencyKey - Optional idempotency key.
|
|
120
|
+
* @returns The {@link PaymentMethodSetup} handle.
|
|
121
|
+
*/
|
|
122
|
+
setupPaymentMethod(orgId: string, idempotencyKey?: string): Promise<SetupSharedPaymentMethodMutation['setupSharedPaymentMethod']>;
|
|
123
|
+
/**
|
|
124
|
+
* Remove a saved payment method from an org. Requires `manage_billing`.
|
|
125
|
+
*
|
|
126
|
+
* @param orgId - Numeric org id.
|
|
127
|
+
* @param paymentMethodId - Numeric id of the saved method to remove.
|
|
128
|
+
* @param idempotencyKey - Optional idempotency key.
|
|
129
|
+
* @returns `true` on success.
|
|
130
|
+
*/
|
|
131
|
+
removePaymentMethod(orgId: string, paymentMethodId: string, idempotencyKey?: string): Promise<RemoveSharedPaymentMethodMutation['removeSharedPaymentMethod']>;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=sharedEnvironment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedEnvironment.d.ts","sourceRoot":"","sources":["../../src/domains/sharedEnvironment.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { SharedEnvPlansDocument, OrgFreeAppQuotaDocument, AppSharedSubscriptionDocument, AppRuntimeStateDocument, OrgAutoBillingDocument, OrgPaymentMethodsDocument, PublishAppToSharedDocument, CancelSharedSubscriptionDocument, SetAppSpendCapsDocument, SetAutoBillingDocument, SetupSharedPaymentMethodDocument, RemoveSharedPaymentMethodDocument, } from '../generated/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Shared-environment app publishing, runtime gating, spend caps, and
|
|
4
|
+
* auto-billing — exposed as `client.sharedEnvironment` (and grouped under
|
|
5
|
+
* `client.admin`).
|
|
6
|
+
*
|
|
7
|
+
* Targets the **management-api**. {@link plans} is public; the read operations
|
|
8
|
+
* require org membership; spend-cap / auto-billing / subscription mutations
|
|
9
|
+
* require the `manage_billing` org permission; {@link publishApp} currently
|
|
10
|
+
* requires super-admin (preview). Monetary values are `*Cents` (minor units).
|
|
11
|
+
*
|
|
12
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` / `SCOPE_MISSING`
|
|
13
|
+
* per the permission notes above; `IDEMPOTENCY_CONFLICT` on key reuse with
|
|
14
|
+
* different args.
|
|
15
|
+
*/
|
|
16
|
+
export class SharedEnvironmentAPI {
|
|
17
|
+
constructor(management) {
|
|
18
|
+
this.management = management;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Public catalog of paid shared-environment app-slot plans.
|
|
22
|
+
*
|
|
23
|
+
* @returns The available plans.
|
|
24
|
+
*/
|
|
25
|
+
async plans() {
|
|
26
|
+
const data = await this.management.request(SharedEnvPlansDocument, {});
|
|
27
|
+
return data.sharedEnvPlans;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* An org's free shared-app slot quota and usage. Caller must be an org member.
|
|
31
|
+
*
|
|
32
|
+
* @param orgId - Numeric org id.
|
|
33
|
+
* @returns The {@link FreeAppQuota}.
|
|
34
|
+
*/
|
|
35
|
+
async freeAppQuota(orgId) {
|
|
36
|
+
const data = await this.management.request(OrgFreeAppQuotaDocument, {
|
|
37
|
+
orgId,
|
|
38
|
+
});
|
|
39
|
+
return data.orgFreeAppQuota;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* An app's paid shared subscription, or `null` when on the free quota.
|
|
43
|
+
*
|
|
44
|
+
* @param appId - Numeric app id.
|
|
45
|
+
* @returns The {@link AppSharedSubscription} or `null`.
|
|
46
|
+
*/
|
|
47
|
+
async appSubscription(appId) {
|
|
48
|
+
const data = await this.management.request(AppSharedSubscriptionDocument, { appId });
|
|
49
|
+
return data.appSharedSubscription;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The shared-environment runtime gate + current usage for an app.
|
|
53
|
+
*
|
|
54
|
+
* @param appId - Numeric app id.
|
|
55
|
+
* @returns The {@link AppRuntimeState}.
|
|
56
|
+
*/
|
|
57
|
+
async appRuntimeState(appId) {
|
|
58
|
+
const data = await this.management.request(AppRuntimeStateDocument, {
|
|
59
|
+
appId,
|
|
60
|
+
});
|
|
61
|
+
return data.appRuntimeState;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* An org's off-session auto-billing configuration.
|
|
65
|
+
*
|
|
66
|
+
* @param orgId - Numeric org id.
|
|
67
|
+
* @returns The {@link OrgAutoBilling} config.
|
|
68
|
+
*/
|
|
69
|
+
async autoBilling(orgId) {
|
|
70
|
+
const data = await this.management.request(OrgAutoBillingDocument, {
|
|
71
|
+
orgId,
|
|
72
|
+
});
|
|
73
|
+
return data.orgAutoBilling;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* List an org's saved (vaulted) payment methods.
|
|
77
|
+
*
|
|
78
|
+
* @param orgId - Numeric org id.
|
|
79
|
+
* @returns The saved payment methods.
|
|
80
|
+
*/
|
|
81
|
+
async paymentMethods(orgId) {
|
|
82
|
+
const data = await this.management.request(OrgPaymentMethodsDocument, {
|
|
83
|
+
orgId,
|
|
84
|
+
});
|
|
85
|
+
return data.orgPaymentMethods;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Publish an app to the shared game-api. Free under the org quota (no charge);
|
|
89
|
+
* pass `planId` for a paid subscription (returns a checkout to complete).
|
|
90
|
+
* Currently super-admin only (preview).
|
|
91
|
+
*
|
|
92
|
+
* @param appId - Numeric app id.
|
|
93
|
+
* @param opts - Optional `planId`, `provider`, `successUrl`, `cancelUrl`, and
|
|
94
|
+
* `idempotencyKey`.
|
|
95
|
+
* @returns The {@link PublishAppResult} (free flag + optional checkout).
|
|
96
|
+
*/
|
|
97
|
+
async publishApp(appId, opts = {}) {
|
|
98
|
+
const data = await this.management.request(PublishAppToSharedDocument, {
|
|
99
|
+
appId,
|
|
100
|
+
planId: opts.planId,
|
|
101
|
+
provider: opts.provider,
|
|
102
|
+
successUrl: opts.successUrl,
|
|
103
|
+
cancelUrl: opts.cancelUrl,
|
|
104
|
+
idempotencyKey: opts.idempotencyKey,
|
|
105
|
+
});
|
|
106
|
+
return data.publishAppToShared;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Cancel an app's paid shared subscription. Requires `manage_billing`.
|
|
110
|
+
*
|
|
111
|
+
* @param appId - Numeric app id.
|
|
112
|
+
* @param idempotencyKey - Optional idempotency key for safe retries.
|
|
113
|
+
* @returns The updated {@link AppSharedSubscription}.
|
|
114
|
+
*/
|
|
115
|
+
async cancelSubscription(appId, idempotencyKey) {
|
|
116
|
+
const data = await this.management.request(CancelSharedSubscriptionDocument, { appId, idempotencyKey });
|
|
117
|
+
return data.cancelSharedSubscription;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Set per-app hourly/daily spend caps (cents); `null` clears a cap. Requires
|
|
121
|
+
* `manage_billing`. Returns the re-evaluated runtime state.
|
|
122
|
+
*
|
|
123
|
+
* @param appId - Numeric app id.
|
|
124
|
+
* @param caps - `hourlyLimitCents` and/or `dailyLimitCents` (decimal strings).
|
|
125
|
+
* @returns The updated {@link AppRuntimeState}.
|
|
126
|
+
*/
|
|
127
|
+
async setSpendCaps(appId, caps = {}) {
|
|
128
|
+
const data = await this.management.request(SetAppSpendCapsDocument, {
|
|
129
|
+
appId,
|
|
130
|
+
hourlyLimitCents: caps.hourlyLimitCents,
|
|
131
|
+
dailyLimitCents: caps.dailyLimitCents,
|
|
132
|
+
});
|
|
133
|
+
return data.setAppSpendCaps;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Enable/disable and configure off-session auto-billing for an org. Requires
|
|
137
|
+
* `manage_billing`.
|
|
138
|
+
*
|
|
139
|
+
* @param orgId - Numeric org id.
|
|
140
|
+
* @param config - `enabled` plus optional `limitCents`, `rechargeAmountCents`,
|
|
141
|
+
* `lowWaterThresholdCents`, and `idempotencyKey`.
|
|
142
|
+
* @returns The updated {@link OrgAutoBilling} config.
|
|
143
|
+
*/
|
|
144
|
+
async setAutoBilling(orgId, config) {
|
|
145
|
+
const data = await this.management.request(SetAutoBillingDocument, {
|
|
146
|
+
orgId,
|
|
147
|
+
enabled: config.enabled,
|
|
148
|
+
limitCents: config.limitCents,
|
|
149
|
+
rechargeAmountCents: config.rechargeAmountCents,
|
|
150
|
+
lowWaterThresholdCents: config.lowWaterThresholdCents,
|
|
151
|
+
idempotencyKey: config.idempotencyKey,
|
|
152
|
+
});
|
|
153
|
+
return data.setAutoBilling;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Begin vaulting a card for off-session auto-billing (returns a Stripe
|
|
157
|
+
* SetupIntent client secret). No charge here. Requires `manage_billing`.
|
|
158
|
+
*
|
|
159
|
+
* @param orgId - Numeric org id.
|
|
160
|
+
* @param idempotencyKey - Optional idempotency key.
|
|
161
|
+
* @returns The {@link PaymentMethodSetup} handle.
|
|
162
|
+
*/
|
|
163
|
+
async setupPaymentMethod(orgId, idempotencyKey) {
|
|
164
|
+
const data = await this.management.request(SetupSharedPaymentMethodDocument, { orgId, idempotencyKey });
|
|
165
|
+
return data.setupSharedPaymentMethod;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Remove a saved payment method from an org. Requires `manage_billing`.
|
|
169
|
+
*
|
|
170
|
+
* @param orgId - Numeric org id.
|
|
171
|
+
* @param paymentMethodId - Numeric id of the saved method to remove.
|
|
172
|
+
* @param idempotencyKey - Optional idempotency key.
|
|
173
|
+
* @returns `true` on success.
|
|
174
|
+
*/
|
|
175
|
+
async removePaymentMethod(orgId, paymentMethodId, idempotencyKey) {
|
|
176
|
+
const data = await this.management.request(RemoveSharedPaymentMethodDocument, { orgId, paymentMethodId, idempotencyKey });
|
|
177
|
+
return data.removeSharedPaymentMethod;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { GraphQLClient } from '../client.js';
|
|
2
|
+
import { type UserAppStateQuery, type UserAppStateQueryVariables, type UserAppStatesQuery, type UpdateUserAppStateMutation, type UpdateUserAppStateMutationVariables, type DeleteUserAppStateMutation, type DeleteUserAppStateMutationVariables } from '../generated/graphql.js';
|
|
3
|
+
/**
|
|
4
|
+
* Per-user, per-app state storage on the **game-api** (formerly `userMapState`).
|
|
5
|
+
* Exposed as `client.state`.
|
|
6
|
+
*
|
|
7
|
+
* Each row is the authenticated user's own opaque state blob scoped to one app
|
|
8
|
+
* (keyed by `appId` + `userId`) — a convenient place to persist small
|
|
9
|
+
* per-player, per-game data. The `state` blob is **base64-encoded** binary
|
|
10
|
+
* (null when cleared) and `appId` is a `BigInt` sent and received as a decimal
|
|
11
|
+
* string.
|
|
12
|
+
*
|
|
13
|
+
* Every method requires an authenticated session (a Bearer game token set via
|
|
14
|
+
* `client.auth.login()` or `client.setToken()`) and only ever reads or writes
|
|
15
|
+
* the **caller's own** state, otherwise {@link CrowdyGraphQLError} is thrown
|
|
16
|
+
* (`UNAUTHENTICATED`).
|
|
17
|
+
*/
|
|
18
|
+
export declare class StateAPI {
|
|
19
|
+
private gql;
|
|
20
|
+
constructor(gql: GraphQLClient);
|
|
21
|
+
/**
|
|
22
|
+
* Read the authenticated user's per-app state for `appId`.
|
|
23
|
+
*
|
|
24
|
+
* @param appId - App (game) id the state is scoped to (`BigInt` as a decimal
|
|
25
|
+
* string).
|
|
26
|
+
* @returns The {@link UserAppState} (its `state` blob base64-encoded), or
|
|
27
|
+
* `null` when no row exists.
|
|
28
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED`.
|
|
29
|
+
*/
|
|
30
|
+
getOne(appId: UserAppStateQueryVariables['appId']): Promise<UserAppStateQuery['userAppState']>;
|
|
31
|
+
/**
|
|
32
|
+
* List all of the authenticated user's per-app state rows, ordered
|
|
33
|
+
* newest-updated first. Takes no arguments.
|
|
34
|
+
*
|
|
35
|
+
* @returns The caller's {@link UserAppState} rows (each `state` blob
|
|
36
|
+
* base64-encoded).
|
|
37
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED`.
|
|
38
|
+
*/
|
|
39
|
+
getAll(): Promise<UserAppStatesQuery['userAppStates']>;
|
|
40
|
+
/**
|
|
41
|
+
* Create or replace (upsert) the authenticated user's per-app state for
|
|
42
|
+
* `input.appId`, keyed by `appId` + `userId`. Always writes the caller's own
|
|
43
|
+
* state.
|
|
44
|
+
*
|
|
45
|
+
* @param input - {@link CreateUserAppStateInput}: the target `appId` (decimal
|
|
46
|
+
* string) and the new `state` blob (base64-encoded binary; omit/null to clear
|
|
47
|
+
* it).
|
|
48
|
+
* @returns The upserted {@link UserAppState}.
|
|
49
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` or `UNAUTHENTICATED`.
|
|
50
|
+
*/
|
|
51
|
+
update(input: UpdateUserAppStateMutationVariables['input']): Promise<UpdateUserAppStateMutation['updateUserAppState']>;
|
|
52
|
+
/**
|
|
53
|
+
* **Destructive:** delete the authenticated user's per-app state row for
|
|
54
|
+
* `appId` and return the deleted row. Acts only on the caller's own state.
|
|
55
|
+
*
|
|
56
|
+
* @param appId - App (game) id whose state row to delete (`BigInt` as a decimal
|
|
57
|
+
* string).
|
|
58
|
+
* @returns The deleted {@link UserAppState}.
|
|
59
|
+
* @throws {CrowdyGraphQLError} when no state row exists for `appId`
|
|
60
|
+
* (not-found), or `UNAUTHENTICATED`.
|
|
61
|
+
*/
|
|
62
|
+
delete(appId: DeleteUserAppStateMutationVariables['appId']): Promise<DeleteUserAppStateMutation['deleteUserAppState']>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/domains/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAE/B,KAAK,kBAAkB,EAEvB,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EAExC,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EACzC,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEtC;;;;;;;;OAQG;IACG,MAAM,CACV,KAAK,EAAE,0BAA0B,CAAC,OAAO,CAAC,GACzC,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAK7C;;;;;;;OAOG;IACG,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAK5D;;;;;;;;;;OAUG;IACG,MAAM,CACV,KAAK,EAAE,mCAAmC,CAAC,OAAO,CAAC,GAClD,OAAO,CAAC,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;IAK5D;;;;;;;;;OASG;IACG,MAAM,CACV,KAAK,EAAE,mCAAmC,CAAC,OAAO,CAAC,GAClD,OAAO,CAAC,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;CAI7D"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { UserAppStateDocument, UserAppStatesDocument, UpdateUserAppStateDocument, DeleteUserAppStateDocument, } from '../generated/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Per-user, per-app state storage on the **game-api** (formerly `userMapState`).
|
|
4
|
+
* Exposed as `client.state`.
|
|
5
|
+
*
|
|
6
|
+
* Each row is the authenticated user's own opaque state blob scoped to one app
|
|
7
|
+
* (keyed by `appId` + `userId`) — a convenient place to persist small
|
|
8
|
+
* per-player, per-game data. The `state` blob is **base64-encoded** binary
|
|
9
|
+
* (null when cleared) and `appId` is a `BigInt` sent and received as a decimal
|
|
10
|
+
* string.
|
|
11
|
+
*
|
|
12
|
+
* Every method requires an authenticated session (a Bearer game token set via
|
|
13
|
+
* `client.auth.login()` or `client.setToken()`) and only ever reads or writes
|
|
14
|
+
* the **caller's own** state, otherwise {@link CrowdyGraphQLError} is thrown
|
|
15
|
+
* (`UNAUTHENTICATED`).
|
|
16
|
+
*/
|
|
17
|
+
export class StateAPI {
|
|
18
|
+
constructor(gql) {
|
|
19
|
+
this.gql = gql;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Read the authenticated user's per-app state for `appId`.
|
|
23
|
+
*
|
|
24
|
+
* @param appId - App (game) id the state is scoped to (`BigInt` as a decimal
|
|
25
|
+
* string).
|
|
26
|
+
* @returns The {@link UserAppState} (its `state` blob base64-encoded), or
|
|
27
|
+
* `null` when no row exists.
|
|
28
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED`.
|
|
29
|
+
*/
|
|
30
|
+
async getOne(appId) {
|
|
31
|
+
const data = await this.gql.request(UserAppStateDocument, { appId });
|
|
32
|
+
return data.userAppState;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* List all of the authenticated user's per-app state rows, ordered
|
|
36
|
+
* newest-updated first. Takes no arguments.
|
|
37
|
+
*
|
|
38
|
+
* @returns The caller's {@link UserAppState} rows (each `state` blob
|
|
39
|
+
* base64-encoded).
|
|
40
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED`.
|
|
41
|
+
*/
|
|
42
|
+
async getAll() {
|
|
43
|
+
const data = await this.gql.request(UserAppStatesDocument, undefined);
|
|
44
|
+
return data.userAppStates;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create or replace (upsert) the authenticated user's per-app state for
|
|
48
|
+
* `input.appId`, keyed by `appId` + `userId`. Always writes the caller's own
|
|
49
|
+
* state.
|
|
50
|
+
*
|
|
51
|
+
* @param input - {@link CreateUserAppStateInput}: the target `appId` (decimal
|
|
52
|
+
* string) and the new `state` blob (base64-encoded binary; omit/null to clear
|
|
53
|
+
* it).
|
|
54
|
+
* @returns The upserted {@link UserAppState}.
|
|
55
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` or `UNAUTHENTICATED`.
|
|
56
|
+
*/
|
|
57
|
+
async update(input) {
|
|
58
|
+
const data = await this.gql.request(UpdateUserAppStateDocument, { input });
|
|
59
|
+
return data.updateUserAppState;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* **Destructive:** delete the authenticated user's per-app state row for
|
|
63
|
+
* `appId` and return the deleted row. Acts only on the caller's own state.
|
|
64
|
+
*
|
|
65
|
+
* @param appId - App (game) id whose state row to delete (`BigInt` as a decimal
|
|
66
|
+
* string).
|
|
67
|
+
* @returns The deleted {@link UserAppState}.
|
|
68
|
+
* @throws {CrowdyGraphQLError} when no state row exists for `appId`
|
|
69
|
+
* (not-found), or `UNAUTHENTICATED`.
|
|
70
|
+
*/
|
|
71
|
+
async delete(appId) {
|
|
72
|
+
const data = await this.gql.request(DeleteUserAppStateDocument, { appId });
|
|
73
|
+
return data.deleteUserAppState;
|
|
74
|
+
}
|
|
75
|
+
}
|