@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,129 @@
|
|
|
1
|
+
import { MyCheckoutsDocument, MyCheckoutsConnectionDocument, CheckoutsDocument, CheckoutsConnectionDocument, CreateCheckoutDocument, CapturePaypalCheckoutDocument, PaymentEventsDocument, PaymentEventsConnectionDocument, } from '../generated/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Payment checkouts (wallet top-ups, plan purchases) — exposed as
|
|
4
|
+
* `client.payments` (and grouped under `client.admin`).
|
|
5
|
+
*
|
|
6
|
+
* Targets the **management-api**. {@link create} and {@link mine} require an
|
|
7
|
+
* authenticated caller and act on their own checkouts; {@link all} is
|
|
8
|
+
* super-admin only. Amounts are minor currency units (`*Cents`).
|
|
9
|
+
*
|
|
10
|
+
* Note: {@link create} starts a real payment-provider checkout (Stripe /
|
|
11
|
+
* PayPal). In tests use sandbox provider keys only — never trigger real
|
|
12
|
+
* charges.
|
|
13
|
+
*
|
|
14
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` per the notes
|
|
15
|
+
* above.
|
|
16
|
+
*/
|
|
17
|
+
export class PaymentsAPI {
|
|
18
|
+
constructor(management) {
|
|
19
|
+
this.management = management;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Start a checkout (e.g. an `ORG_WALLET_TOPUP`). Requires authentication.
|
|
23
|
+
*
|
|
24
|
+
* @param input - {@link CreateCheckoutInput}: purpose, amount, provider, and
|
|
25
|
+
* return URLs.
|
|
26
|
+
* @returns The created checkout including the provider redirect/approval URL.
|
|
27
|
+
*/
|
|
28
|
+
async create(input) {
|
|
29
|
+
const data = await this.management.request(CreateCheckoutDocument, {
|
|
30
|
+
input,
|
|
31
|
+
});
|
|
32
|
+
return data.createCheckout;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* List the authenticated caller's own checkouts (newest first).
|
|
36
|
+
*
|
|
37
|
+
* @param opts - Optional `limit` / `offset` (default limit 50).
|
|
38
|
+
* @returns The caller's checkouts.
|
|
39
|
+
*/
|
|
40
|
+
async mine(opts = {}) {
|
|
41
|
+
const data = await this.management.request(MyCheckoutsDocument, {
|
|
42
|
+
limit: opts.limit,
|
|
43
|
+
offset: opts.offset,
|
|
44
|
+
});
|
|
45
|
+
return data.myCheckouts;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* List checkouts across all users with an optional filter. **Super-admin
|
|
49
|
+
* only.**
|
|
50
|
+
*
|
|
51
|
+
* @param opts - Optional {@link CheckoutFilterInput} `filter` and `limit` /
|
|
52
|
+
* `offset`.
|
|
53
|
+
* @returns The matching checkouts.
|
|
54
|
+
*/
|
|
55
|
+
async all(opts = {}) {
|
|
56
|
+
const data = await this.management.request(CheckoutsDocument, {
|
|
57
|
+
filter: opts.filter,
|
|
58
|
+
limit: opts.limit,
|
|
59
|
+
offset: opts.offset,
|
|
60
|
+
});
|
|
61
|
+
return data.checkouts;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Capture an approved PayPal order, finalizing the checkout it belongs to.
|
|
65
|
+
* Call this after the buyer approves the PayPal order returned by
|
|
66
|
+
* {@link create}. Requires authentication.
|
|
67
|
+
*
|
|
68
|
+
* Pass `idempotencyKey` to make retries safe: replaying with the same key
|
|
69
|
+
* returns the first result instead of re-capturing.
|
|
70
|
+
*
|
|
71
|
+
* @param orderId - The PayPal order id to capture.
|
|
72
|
+
* @param idempotencyKey - Optional key for safe retries.
|
|
73
|
+
* @returns The finalized {@link Checkout}.
|
|
74
|
+
*/
|
|
75
|
+
async capturePaypal(orderId, idempotencyKey) {
|
|
76
|
+
const data = await this.management.request(CapturePaypalCheckoutDocument, {
|
|
77
|
+
orderId,
|
|
78
|
+
idempotencyKey,
|
|
79
|
+
});
|
|
80
|
+
return data.capturePaypalCheckout;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Relay-style cursor pagination over the caller's own checkouts — the
|
|
84
|
+
* preferred alternative to {@link mine}. See
|
|
85
|
+
* https://docs.crowdedkingdoms.com/overview/pagination.
|
|
86
|
+
*
|
|
87
|
+
* @param args - Optional `first` and `after`.
|
|
88
|
+
* @returns A checkouts connection.
|
|
89
|
+
*/
|
|
90
|
+
async mineConnection(args = {}) {
|
|
91
|
+
const data = await this.management.request(MyCheckoutsConnectionDocument, args);
|
|
92
|
+
return data.myCheckoutsConnection;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Relay-style cursor pagination over all checkouts (with optional filter) —
|
|
96
|
+
* the preferred alternative to {@link all}. **Super-admin only.**
|
|
97
|
+
*
|
|
98
|
+
* @param args - Optional `first`, `after`, and {@link CheckoutFilterInput}.
|
|
99
|
+
* @returns A checkouts connection.
|
|
100
|
+
*/
|
|
101
|
+
async allConnection(args = {}) {
|
|
102
|
+
const data = await this.management.request(CheckoutsConnectionDocument, args);
|
|
103
|
+
return data.checkoutsConnection;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* List provider webhook events (offset pagination). **Super-admin only** — an
|
|
107
|
+
* audit view of received Stripe/PayPal/SES events.
|
|
108
|
+
*
|
|
109
|
+
* @param opts - Optional `limit` / `offset`.
|
|
110
|
+
* @returns A page of {@link PaymentEventRecord}s.
|
|
111
|
+
* @remarks Prefer {@link eventsConnection} (Relay cursor pagination); the
|
|
112
|
+
* offset args here are deprecated server-side.
|
|
113
|
+
*/
|
|
114
|
+
async events(opts = {}) {
|
|
115
|
+
const data = await this.management.request(PaymentEventsDocument, opts);
|
|
116
|
+
return data.paymentEvents;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Relay-style cursor pagination over provider webhook events. **Super-admin
|
|
120
|
+
* only.** See https://docs.crowdedkingdoms.com/overview/pagination.
|
|
121
|
+
*
|
|
122
|
+
* @param args - Optional `first` and `after`.
|
|
123
|
+
* @returns A payment-events connection.
|
|
124
|
+
*/
|
|
125
|
+
async eventsConnection(args = {}) {
|
|
126
|
+
const data = await this.management.request(PaymentEventsConnectionDocument, args);
|
|
127
|
+
return data.paymentEventsConnection;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { GraphQLClient } from '../client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Public platform discovery returned by {@link PlatformAPI.config}: how SDKs
|
|
4
|
+
* find the shared game-api so they can route apps deployed to the shared
|
|
5
|
+
* environment. All fields are public (no auth required to read them).
|
|
6
|
+
*/
|
|
7
|
+
export interface PlatformConfig {
|
|
8
|
+
/** Shared game-api HTTP/GraphQL root for shared-environment apps; `null` if unset. */
|
|
9
|
+
sharedGameApiUrl: string | null;
|
|
10
|
+
/** Shared game-api WebSocket root (subscriptions / UDP proxy); `null` if unset. */
|
|
11
|
+
sharedGameApiWsUrl: string | null;
|
|
12
|
+
/** Free shared app slots an org gets before a paid subscription is required. */
|
|
13
|
+
freeAppsPerOrg: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Public platform discovery — exposed as `client.platform`.
|
|
17
|
+
*
|
|
18
|
+
* Targets the **management-api** (every call routes to `managementUrl`).
|
|
19
|
+
* **Public**: no authentication required. Lets a client discover the shared
|
|
20
|
+
* game-api URL (for apps published to the shared environment) *before* it has a
|
|
21
|
+
* per-app endpoint, then build a game-api `CrowdyClient` against it.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const base = createCrowdyClient({ managementUrl: 'https://api.example.com' });
|
|
26
|
+
* const cfg = await base.platform.config();
|
|
27
|
+
* const gameClient = createCrowdyClient({
|
|
28
|
+
* managementUrl: 'https://api.example.com',
|
|
29
|
+
* httpUrl: cfg.sharedGameApiUrl ?? undefined,
|
|
30
|
+
* wsUrl: cfg.sharedGameApiWsUrl ?? undefined,
|
|
31
|
+
* tokenStore: base.session.tokenStore,
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class PlatformAPI {
|
|
36
|
+
private readonly management;
|
|
37
|
+
constructor(management: GraphQLClient);
|
|
38
|
+
/**
|
|
39
|
+
* Fetch public platform discovery: the shared game-api URL clients use for
|
|
40
|
+
* shared-environment apps, plus the free shared-app quota. **Public** — no
|
|
41
|
+
* authentication required.
|
|
42
|
+
*
|
|
43
|
+
* @returns A {@link PlatformConfig} (`sharedGameApiUrl`, `sharedGameApiWsUrl`,
|
|
44
|
+
* and `freeAppsPerOrg`).
|
|
45
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
46
|
+
*/
|
|
47
|
+
config(): Promise<PlatformConfig>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/domains/platform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,sFAAsF;IACtF,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,mFAAmF;IACnF,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gFAAgF;IAChF,cAAc,EAAE,MAAM,CAAC;CACxB;AAiBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,aAAa;IAEtD;;;;;;;;OAQG;IACG,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;CAIxC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { parse } from 'graphql';
|
|
2
|
+
// Hand-written document so the SDK can discover the shared game-api URL even
|
|
3
|
+
// before codegen picks up the new schema (see src/operations/platform/).
|
|
4
|
+
const PlatformConfigDocument = parse(/* GraphQL */ `
|
|
5
|
+
query PlatformConfig {
|
|
6
|
+
platformConfig {
|
|
7
|
+
sharedGameApiUrl
|
|
8
|
+
sharedGameApiWsUrl
|
|
9
|
+
freeAppsPerOrg
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`);
|
|
13
|
+
/**
|
|
14
|
+
* Public platform discovery — exposed as `client.platform`.
|
|
15
|
+
*
|
|
16
|
+
* Targets the **management-api** (every call routes to `managementUrl`).
|
|
17
|
+
* **Public**: no authentication required. Lets a client discover the shared
|
|
18
|
+
* game-api URL (for apps published to the shared environment) *before* it has a
|
|
19
|
+
* per-app endpoint, then build a game-api `CrowdyClient` against it.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const base = createCrowdyClient({ managementUrl: 'https://api.example.com' });
|
|
24
|
+
* const cfg = await base.platform.config();
|
|
25
|
+
* const gameClient = createCrowdyClient({
|
|
26
|
+
* managementUrl: 'https://api.example.com',
|
|
27
|
+
* httpUrl: cfg.sharedGameApiUrl ?? undefined,
|
|
28
|
+
* wsUrl: cfg.sharedGameApiWsUrl ?? undefined,
|
|
29
|
+
* tokenStore: base.session.tokenStore,
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export class PlatformAPI {
|
|
34
|
+
constructor(management) {
|
|
35
|
+
this.management = management;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Fetch public platform discovery: the shared game-api URL clients use for
|
|
39
|
+
* shared-environment apps, plus the free shared-app quota. **Public** — no
|
|
40
|
+
* authentication required.
|
|
41
|
+
*
|
|
42
|
+
* @returns A {@link PlatformConfig} (`sharedGameApiUrl`, `sharedGameApiWsUrl`,
|
|
43
|
+
* and `freeAppsPerOrg`).
|
|
44
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
45
|
+
*/
|
|
46
|
+
async config() {
|
|
47
|
+
const data = await this.management.request(PlatformConfigDocument, {});
|
|
48
|
+
return data.platformConfig;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { GraphQLClient } from '../client.js';
|
|
2
|
+
import { type QuotasForOrgQuery, type QuotasForAppQuery, type EffectiveQuotaQuery, type SetQuotaMutation, type DeleteQuotaMutation, type SetQuotaInput } from '../generated/graphql.js';
|
|
3
|
+
/**
|
|
4
|
+
* Usage quotas at the org and app scope — exposed as `client.quotas` (and
|
|
5
|
+
* grouped under `client.admin`).
|
|
6
|
+
*
|
|
7
|
+
* Targets the **management-api**. Reads require the `view_usage` org/app
|
|
8
|
+
* permission; {@link set} / {@link remove} require `manage_quotas` (global
|
|
9
|
+
* quotas are super-admin only). A quota is keyed by a `metric` string; the
|
|
10
|
+
* effective value resolves app → org → platform default.
|
|
11
|
+
*
|
|
12
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` / `SCOPE_MISSING`
|
|
13
|
+
* per the permission notes above.
|
|
14
|
+
*/
|
|
15
|
+
export declare class QuotasAPI {
|
|
16
|
+
private readonly management;
|
|
17
|
+
constructor(management: GraphQLClient);
|
|
18
|
+
/**
|
|
19
|
+
* List the quotas configured directly on an organization. Requires the
|
|
20
|
+
* `view_usage` org permission.
|
|
21
|
+
*
|
|
22
|
+
* @param orgId - Numeric org id (`BigInt` as a decimal string).
|
|
23
|
+
* @returns The org's quotas.
|
|
24
|
+
*/
|
|
25
|
+
forOrg(orgId: string): Promise<QuotasForOrgQuery['quotasForOrg']>;
|
|
26
|
+
/**
|
|
27
|
+
* List the quotas configured directly on an app. Requires the `view_usage`
|
|
28
|
+
* app permission.
|
|
29
|
+
*
|
|
30
|
+
* @param appId - Numeric app id.
|
|
31
|
+
* @returns The app's quotas.
|
|
32
|
+
*/
|
|
33
|
+
forApp(appId: string): Promise<QuotasForAppQuery['quotasForApp']>;
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the effective value of a metric for an org and/or app (app overrides
|
|
36
|
+
* org overrides platform default). Requires `view_usage` on the scope.
|
|
37
|
+
*
|
|
38
|
+
* @param metric - The quota metric key (e.g. `"replication_messages"`).
|
|
39
|
+
* @param scope - Optional `orgId` and/or `appId` to resolve against.
|
|
40
|
+
* @returns The effective quota for the metric.
|
|
41
|
+
*/
|
|
42
|
+
effective(metric: string, scope?: {
|
|
43
|
+
orgId?: string;
|
|
44
|
+
appId?: string;
|
|
45
|
+
}): Promise<EffectiveQuotaQuery['effectiveQuota']>;
|
|
46
|
+
/**
|
|
47
|
+
* Create or update a quota at an org or app scope. Requires `manage_quotas`
|
|
48
|
+
* (super-admin for platform-global quotas).
|
|
49
|
+
*
|
|
50
|
+
* @param input - {@link SetQuotaInput}: scope ids, `metric`, and `limit`.
|
|
51
|
+
* @returns The created/updated quota.
|
|
52
|
+
*/
|
|
53
|
+
set(input: SetQuotaInput): Promise<SetQuotaMutation['setQuota']>;
|
|
54
|
+
/**
|
|
55
|
+
* Delete a quota by id. Requires `manage_quotas` on the owning scope.
|
|
56
|
+
*
|
|
57
|
+
* @param quotaId - Numeric quota id.
|
|
58
|
+
* @returns `true` on success.
|
|
59
|
+
*/
|
|
60
|
+
remove(quotaId: string): Promise<DeleteQuotaMutation['deleteQuota']>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=quotas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotas.d.ts","sourceRoot":"","sources":["../../src/domains/quotas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;GAWG;AACH,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,aAAa;IAEtD;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAKvE;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAKvE;;;;;;;OAOG;IACG,SAAS,CACb,MAAM,EAAE,MAAM,EACd,KAAK,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAC7C,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IASjD;;;;;;OAMG;IACG,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAKtE;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;CAM3E"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { QuotasForOrgDocument, QuotasForAppDocument, EffectiveQuotaDocument, SetQuotaDocument, DeleteQuotaDocument, } from '../generated/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Usage quotas at the org and app scope — exposed as `client.quotas` (and
|
|
4
|
+
* grouped under `client.admin`).
|
|
5
|
+
*
|
|
6
|
+
* Targets the **management-api**. Reads require the `view_usage` org/app
|
|
7
|
+
* permission; {@link set} / {@link remove} require `manage_quotas` (global
|
|
8
|
+
* quotas are super-admin only). A quota is keyed by a `metric` string; the
|
|
9
|
+
* effective value resolves app → org → platform default.
|
|
10
|
+
*
|
|
11
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` / `SCOPE_MISSING`
|
|
12
|
+
* per the permission notes above.
|
|
13
|
+
*/
|
|
14
|
+
export class QuotasAPI {
|
|
15
|
+
constructor(management) {
|
|
16
|
+
this.management = management;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* List the quotas configured directly on an organization. Requires the
|
|
20
|
+
* `view_usage` org permission.
|
|
21
|
+
*
|
|
22
|
+
* @param orgId - Numeric org id (`BigInt` as a decimal string).
|
|
23
|
+
* @returns The org's quotas.
|
|
24
|
+
*/
|
|
25
|
+
async forOrg(orgId) {
|
|
26
|
+
const data = await this.management.request(QuotasForOrgDocument, { orgId });
|
|
27
|
+
return data.quotasForOrg;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* List the quotas configured directly on an app. Requires the `view_usage`
|
|
31
|
+
* app permission.
|
|
32
|
+
*
|
|
33
|
+
* @param appId - Numeric app id.
|
|
34
|
+
* @returns The app's quotas.
|
|
35
|
+
*/
|
|
36
|
+
async forApp(appId) {
|
|
37
|
+
const data = await this.management.request(QuotasForAppDocument, { appId });
|
|
38
|
+
return data.quotasForApp;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the effective value of a metric for an org and/or app (app overrides
|
|
42
|
+
* org overrides platform default). Requires `view_usage` on the scope.
|
|
43
|
+
*
|
|
44
|
+
* @param metric - The quota metric key (e.g. `"replication_messages"`).
|
|
45
|
+
* @param scope - Optional `orgId` and/or `appId` to resolve against.
|
|
46
|
+
* @returns The effective quota for the metric.
|
|
47
|
+
*/
|
|
48
|
+
async effective(metric, scope = {}) {
|
|
49
|
+
const data = await this.management.request(EffectiveQuotaDocument, {
|
|
50
|
+
metric,
|
|
51
|
+
orgId: scope.orgId,
|
|
52
|
+
appId: scope.appId,
|
|
53
|
+
});
|
|
54
|
+
return data.effectiveQuota;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create or update a quota at an org or app scope. Requires `manage_quotas`
|
|
58
|
+
* (super-admin for platform-global quotas).
|
|
59
|
+
*
|
|
60
|
+
* @param input - {@link SetQuotaInput}: scope ids, `metric`, and `limit`.
|
|
61
|
+
* @returns The created/updated quota.
|
|
62
|
+
*/
|
|
63
|
+
async set(input) {
|
|
64
|
+
const data = await this.management.request(SetQuotaDocument, { input });
|
|
65
|
+
return data.setQuota;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Delete a quota by id. Requires `manage_quotas` on the owning scope.
|
|
69
|
+
*
|
|
70
|
+
* @param quotaId - Numeric quota id.
|
|
71
|
+
* @returns `true` on success.
|
|
72
|
+
*/
|
|
73
|
+
async remove(quotaId) {
|
|
74
|
+
const data = await this.management.request(DeleteQuotaDocument, {
|
|
75
|
+
quotaId,
|
|
76
|
+
});
|
|
77
|
+
return data.deleteQuota;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { GraphQLClient } from '../client.js';
|
|
2
|
+
import { type ServerWithLeastClientsQuery, type GraphqlServersQuery, type ActiveGraphQlServersQuery, type VersionInfoQuery, type GameClientBootstrapQuery, type GameClientBootstrapQueryVariables } from '../generated/graphql.js';
|
|
3
|
+
/**
|
|
4
|
+
* Server discovery, version, and client-bootstrap queries on the **game-api**.
|
|
5
|
+
* Exposed as `client.serverStatus`.
|
|
6
|
+
*
|
|
7
|
+
* This is the **client bootstrap path**: call {@link ServerStatusAPI.gameClientBootstrap}
|
|
8
|
+
* once after login to get everything a play session needs (identity, version
|
|
9
|
+
* floors, UDP status, realtime protocol details, and spatial limits) in a single
|
|
10
|
+
* round-trip, and use {@link ServerStatusAPI.versionInfo} for standalone version
|
|
11
|
+
* discovery / update gating. The remaining queries expose UDP/GraphQL server
|
|
12
|
+
* fleet info for discovery and routing.
|
|
13
|
+
*
|
|
14
|
+
* NOTE: there is no separate "buddy server" query in the schema — the
|
|
15
|
+
* least-loaded UDP game server is selected automatically when a session is
|
|
16
|
+
* opened. {@link ServerStatusAPI.serverWithLeastClients} returns a hint of which
|
|
17
|
+
* UDP server a new session would land on.
|
|
18
|
+
*
|
|
19
|
+
* Auth varies per method: {@link ServerStatusAPI.gameClientBootstrap} and
|
|
20
|
+
* {@link ServerStatusAPI.serverWithLeastClients} require a Bearer game token (set
|
|
21
|
+
* via `client.auth.login()` or `client.setToken()`), while
|
|
22
|
+
* {@link ServerStatusAPI.listAll}, {@link ServerStatusAPI.listActiveGraphqlServers}
|
|
23
|
+
* and {@link ServerStatusAPI.versionInfo} need no authentication. `appId` is a
|
|
24
|
+
* `BigInt` sent as a decimal string.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ServerStatusAPI {
|
|
27
|
+
private gql;
|
|
28
|
+
constructor(gql: GraphQLClient);
|
|
29
|
+
/**
|
|
30
|
+
* Pick a low-load UDP game server for a **native (direct-UDP)** client to
|
|
31
|
+
* connect to: returns a random server from the least-loaded ~20% (by client
|
|
32
|
+
* count) of `ReadyForClients` servers to spread load. As a side effect it
|
|
33
|
+
* authorizes the token's P2P session with the chosen Buddy so the native
|
|
34
|
+
* client's spatial datagrams are accepted; connect the client to the returned
|
|
35
|
+
* `ip4` + `clientPort`. Browser clients should instead use the UDP proxy
|
|
36
|
+
* (`client.udp` / `udpNotifications`) and do not need this.
|
|
37
|
+
*
|
|
38
|
+
* @returns A {@link ServerStatus} describing the selected UDP server.
|
|
39
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if no valid game token is
|
|
40
|
+
* present.
|
|
41
|
+
*/
|
|
42
|
+
serverWithLeastClients(): Promise<ServerWithLeastClientsQuery['serverWithLeastClients']>;
|
|
43
|
+
/**
|
|
44
|
+
* List every registered GraphQL API server (both `management-api` and
|
|
45
|
+
* `game-api` kinds), regardless of health/state — for service discovery. To
|
|
46
|
+
* route clients, prefer {@link ServerStatusAPI.listActiveGraphqlServers}
|
|
47
|
+
* (healthy only). No authentication required.
|
|
48
|
+
*
|
|
49
|
+
* @returns Every registered {@link GraphQLServer}.
|
|
50
|
+
*/
|
|
51
|
+
listAll(): Promise<GraphqlServersQuery['graphqlServers']>;
|
|
52
|
+
/**
|
|
53
|
+
* List only healthy GraphQL API servers (`status = ReadyForClients`) for client
|
|
54
|
+
* routing/discovery. No authentication required.
|
|
55
|
+
*
|
|
56
|
+
* @returns The healthy {@link GraphQLServer}s.
|
|
57
|
+
*/
|
|
58
|
+
listActiveGraphqlServers(): Promise<ActiveGraphQlServersQuery['activeGraphQLServers']>;
|
|
59
|
+
/**
|
|
60
|
+
* Get the current server version and the minimum client version the server
|
|
61
|
+
* accepts. No authentication required — compare your build against
|
|
62
|
+
* `minimumClientVersion` before connecting and prompt an update if it is too
|
|
63
|
+
* old.
|
|
64
|
+
*
|
|
65
|
+
* @returns A {@link ServerVersionInfo} (`serverVersion` + `minimumClientVersion`,
|
|
66
|
+
* each a major/minor/patch/build {@link VersionInfo}).
|
|
67
|
+
*/
|
|
68
|
+
versionInfo(): Promise<VersionInfoQuery['versionInfo']>;
|
|
69
|
+
/**
|
|
70
|
+
* Single startup payload for browser game clients: the authenticated user,
|
|
71
|
+
* server/min-client version requirements, current UDP proxy status, realtime
|
|
72
|
+
* protocol details (subprotocol + subscription name), and the spatial send
|
|
73
|
+
* limits/constants. Read-only — does **not** open a UDP proxy session. Call this
|
|
74
|
+
* once after login to initialize a play session instead of issuing several
|
|
75
|
+
* separate queries.
|
|
76
|
+
*
|
|
77
|
+
* @param appId - The app (game) the client is initializing for (`BigInt` as a
|
|
78
|
+
* decimal string). Scopes the returned UDP status and mirrors the app's
|
|
79
|
+
* entitlements; reuse the same `appId` when subscribing and on every spatial
|
|
80
|
+
* send.
|
|
81
|
+
* @returns A {@link GameClientBootstrap}: `me`, `versionInfo`,
|
|
82
|
+
* `udpProxyConnectionStatus`, `realtimeProtocol`, `subscriptionName`, and the
|
|
83
|
+
* spatial limits `maxReplicationDistance` (max `distance` fan-out, in chunk
|
|
84
|
+
* units), `maxDecayRate`, and `sequenceNumberModulo` (256).
|
|
85
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a valid game token, or
|
|
86
|
+
* `FORBIDDEN` if not entitled to the app.
|
|
87
|
+
*/
|
|
88
|
+
gameClientBootstrap(appId: GameClientBootstrapQueryVariables['appId']): Promise<GameClientBootstrapQuery['gameClientBootstrap']>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=serverStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverStatus.d.ts","sourceRoot":"","sources":["../../src/domains/serverStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,2BAA2B,EAEhC,KAAK,mBAAmB,EAExB,KAAK,yBAAyB,EAE9B,KAAK,gBAAgB,EAErB,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACvC,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEtC;;;;;;;;;;;;OAYG;IACG,sBAAsB,IAAI,OAAO,CAAC,2BAA2B,CAAC,wBAAwB,CAAC,CAAC;IAK9F;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAK/D;;;;;OAKG;IACG,wBAAwB,IAAI,OAAO,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;IAK5F;;;;;;;;OAQG;IACG,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAK7D;;;;;;;;;;;;;;;;;;OAkBG;IACG,mBAAmB,CACvB,KAAK,EAAE,iCAAiC,CAAC,OAAO,CAAC,GAChD,OAAO,CAAC,wBAAwB,CAAC,qBAAqB,CAAC,CAAC;CAI5D"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ServerWithLeastClientsDocument, GraphqlServersDocument, ActiveGraphQlServersDocument, VersionInfoDocument, GameClientBootstrapDocument, } from '../generated/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Server discovery, version, and client-bootstrap queries on the **game-api**.
|
|
4
|
+
* Exposed as `client.serverStatus`.
|
|
5
|
+
*
|
|
6
|
+
* This is the **client bootstrap path**: call {@link ServerStatusAPI.gameClientBootstrap}
|
|
7
|
+
* once after login to get everything a play session needs (identity, version
|
|
8
|
+
* floors, UDP status, realtime protocol details, and spatial limits) in a single
|
|
9
|
+
* round-trip, and use {@link ServerStatusAPI.versionInfo} for standalone version
|
|
10
|
+
* discovery / update gating. The remaining queries expose UDP/GraphQL server
|
|
11
|
+
* fleet info for discovery and routing.
|
|
12
|
+
*
|
|
13
|
+
* NOTE: there is no separate "buddy server" query in the schema — the
|
|
14
|
+
* least-loaded UDP game server is selected automatically when a session is
|
|
15
|
+
* opened. {@link ServerStatusAPI.serverWithLeastClients} returns a hint of which
|
|
16
|
+
* UDP server a new session would land on.
|
|
17
|
+
*
|
|
18
|
+
* Auth varies per method: {@link ServerStatusAPI.gameClientBootstrap} and
|
|
19
|
+
* {@link ServerStatusAPI.serverWithLeastClients} require a Bearer game token (set
|
|
20
|
+
* via `client.auth.login()` or `client.setToken()`), while
|
|
21
|
+
* {@link ServerStatusAPI.listAll}, {@link ServerStatusAPI.listActiveGraphqlServers}
|
|
22
|
+
* and {@link ServerStatusAPI.versionInfo} need no authentication. `appId` is a
|
|
23
|
+
* `BigInt` sent as a decimal string.
|
|
24
|
+
*/
|
|
25
|
+
export class ServerStatusAPI {
|
|
26
|
+
constructor(gql) {
|
|
27
|
+
this.gql = gql;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Pick a low-load UDP game server for a **native (direct-UDP)** client to
|
|
31
|
+
* connect to: returns a random server from the least-loaded ~20% (by client
|
|
32
|
+
* count) of `ReadyForClients` servers to spread load. As a side effect it
|
|
33
|
+
* authorizes the token's P2P session with the chosen Buddy so the native
|
|
34
|
+
* client's spatial datagrams are accepted; connect the client to the returned
|
|
35
|
+
* `ip4` + `clientPort`. Browser clients should instead use the UDP proxy
|
|
36
|
+
* (`client.udp` / `udpNotifications`) and do not need this.
|
|
37
|
+
*
|
|
38
|
+
* @returns A {@link ServerStatus} describing the selected UDP server.
|
|
39
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if no valid game token is
|
|
40
|
+
* present.
|
|
41
|
+
*/
|
|
42
|
+
async serverWithLeastClients() {
|
|
43
|
+
const data = await this.gql.request(ServerWithLeastClientsDocument, undefined);
|
|
44
|
+
return data.serverWithLeastClients;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* List every registered GraphQL API server (both `management-api` and
|
|
48
|
+
* `game-api` kinds), regardless of health/state — for service discovery. To
|
|
49
|
+
* route clients, prefer {@link ServerStatusAPI.listActiveGraphqlServers}
|
|
50
|
+
* (healthy only). No authentication required.
|
|
51
|
+
*
|
|
52
|
+
* @returns Every registered {@link GraphQLServer}.
|
|
53
|
+
*/
|
|
54
|
+
async listAll() {
|
|
55
|
+
const data = await this.gql.request(GraphqlServersDocument, undefined);
|
|
56
|
+
return data.graphqlServers;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* List only healthy GraphQL API servers (`status = ReadyForClients`) for client
|
|
60
|
+
* routing/discovery. No authentication required.
|
|
61
|
+
*
|
|
62
|
+
* @returns The healthy {@link GraphQLServer}s.
|
|
63
|
+
*/
|
|
64
|
+
async listActiveGraphqlServers() {
|
|
65
|
+
const data = await this.gql.request(ActiveGraphQlServersDocument, undefined);
|
|
66
|
+
return data.activeGraphQLServers;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the current server version and the minimum client version the server
|
|
70
|
+
* accepts. No authentication required — compare your build against
|
|
71
|
+
* `minimumClientVersion` before connecting and prompt an update if it is too
|
|
72
|
+
* old.
|
|
73
|
+
*
|
|
74
|
+
* @returns A {@link ServerVersionInfo} (`serverVersion` + `minimumClientVersion`,
|
|
75
|
+
* each a major/minor/patch/build {@link VersionInfo}).
|
|
76
|
+
*/
|
|
77
|
+
async versionInfo() {
|
|
78
|
+
const data = await this.gql.request(VersionInfoDocument, undefined);
|
|
79
|
+
return data.versionInfo;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Single startup payload for browser game clients: the authenticated user,
|
|
83
|
+
* server/min-client version requirements, current UDP proxy status, realtime
|
|
84
|
+
* protocol details (subprotocol + subscription name), and the spatial send
|
|
85
|
+
* limits/constants. Read-only — does **not** open a UDP proxy session. Call this
|
|
86
|
+
* once after login to initialize a play session instead of issuing several
|
|
87
|
+
* separate queries.
|
|
88
|
+
*
|
|
89
|
+
* @param appId - The app (game) the client is initializing for (`BigInt` as a
|
|
90
|
+
* decimal string). Scopes the returned UDP status and mirrors the app's
|
|
91
|
+
* entitlements; reuse the same `appId` when subscribing and on every spatial
|
|
92
|
+
* send.
|
|
93
|
+
* @returns A {@link GameClientBootstrap}: `me`, `versionInfo`,
|
|
94
|
+
* `udpProxyConnectionStatus`, `realtimeProtocol`, `subscriptionName`, and the
|
|
95
|
+
* spatial limits `maxReplicationDistance` (max `distance` fan-out, in chunk
|
|
96
|
+
* units), `maxDecayRate`, and `sequenceNumberModulo` (256).
|
|
97
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a valid game token, or
|
|
98
|
+
* `FORBIDDEN` if not entitled to the app.
|
|
99
|
+
*/
|
|
100
|
+
async gameClientBootstrap(appId) {
|
|
101
|
+
const data = await this.gql.request(GameClientBootstrapDocument, { appId });
|
|
102
|
+
return data.gameClientBootstrap;
|
|
103
|
+
}
|
|
104
|
+
}
|