scribase 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/README.md +220 -0
  2. package/dist/cli/credentials.d.ts +35 -0
  3. package/dist/cli/credentials.d.ts.map +1 -0
  4. package/dist/cli/credentials.js +125 -0
  5. package/dist/cli/credentials.js.map +1 -0
  6. package/dist/cli/envfile.d.ts +20 -0
  7. package/dist/cli/envfile.d.ts.map +1 -0
  8. package/dist/cli/envfile.js +86 -0
  9. package/dist/cli/envfile.js.map +1 -0
  10. package/dist/cli/framework.d.ts +45 -0
  11. package/dist/cli/framework.d.ts.map +1 -0
  12. package/dist/cli/framework.js +107 -0
  13. package/dist/cli/framework.js.map +1 -0
  14. package/dist/cli/index.d.ts +8 -0
  15. package/dist/cli/index.d.ts.map +1 -0
  16. package/dist/cli/index.js +239 -0
  17. package/dist/cli/index.js.map +1 -0
  18. package/dist/cli/init.d.ts +118 -0
  19. package/dist/cli/init.d.ts.map +1 -0
  20. package/dist/cli/init.js +455 -0
  21. package/dist/cli/init.js.map +1 -0
  22. package/dist/cli/login.d.ts +104 -0
  23. package/dist/cli/login.d.ts.map +1 -0
  24. package/dist/cli/login.js +306 -0
  25. package/dist/cli/login.js.map +1 -0
  26. package/dist/cli/pow.d.ts +9 -0
  27. package/dist/cli/pow.d.ts.map +1 -0
  28. package/dist/cli/pow.js +31 -0
  29. package/dist/cli/pow.js.map +1 -0
  30. package/dist/cli/vercel.d.ts +92 -0
  31. package/dist/cli/vercel.d.ts.map +1 -0
  32. package/dist/cli/vercel.js +230 -0
  33. package/dist/cli/vercel.js.map +1 -0
  34. package/dist/client.d.ts +137 -0
  35. package/dist/client.d.ts.map +1 -0
  36. package/dist/client.js +311 -0
  37. package/dist/client.js.map +1 -0
  38. package/dist/errors.d.ts +79 -0
  39. package/dist/errors.d.ts.map +1 -0
  40. package/dist/errors.js +139 -0
  41. package/dist/errors.js.map +1 -0
  42. package/dist/evidence.d.ts +78 -0
  43. package/dist/evidence.d.ts.map +1 -0
  44. package/dist/evidence.js +36 -0
  45. package/dist/evidence.js.map +1 -0
  46. package/dist/idempotency.d.ts +24 -0
  47. package/dist/idempotency.d.ts.map +1 -0
  48. package/dist/idempotency.js +59 -0
  49. package/dist/idempotency.js.map +1 -0
  50. package/dist/importers/firebase.d.ts +101 -0
  51. package/dist/importers/firebase.d.ts.map +1 -0
  52. package/dist/importers/firebase.js +251 -0
  53. package/dist/importers/firebase.js.map +1 -0
  54. package/dist/importers/index.d.ts +11 -0
  55. package/dist/importers/index.d.ts.map +1 -0
  56. package/dist/importers/index.js +9 -0
  57. package/dist/importers/index.js.map +1 -0
  58. package/dist/importers/instantdb.d.ts +76 -0
  59. package/dist/importers/instantdb.d.ts.map +1 -0
  60. package/dist/importers/instantdb.js +152 -0
  61. package/dist/importers/instantdb.js.map +1 -0
  62. package/dist/index.d.ts +78 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +53 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/pagination.d.ts +33 -0
  67. package/dist/pagination.d.ts.map +1 -0
  68. package/dist/pagination.js +68 -0
  69. package/dist/pagination.js.map +1 -0
  70. package/dist/resources/account.d.ts +156 -0
  71. package/dist/resources/account.d.ts.map +1 -0
  72. package/dist/resources/account.js +114 -0
  73. package/dist/resources/account.js.map +1 -0
  74. package/dist/resources/audit.d.ts +26 -0
  75. package/dist/resources/audit.d.ts.map +1 -0
  76. package/dist/resources/audit.js +43 -0
  77. package/dist/resources/audit.js.map +1 -0
  78. package/dist/resources/auth.d.ts +149 -0
  79. package/dist/resources/auth.d.ts.map +1 -0
  80. package/dist/resources/auth.js +70 -0
  81. package/dist/resources/auth.js.map +1 -0
  82. package/dist/resources/backups.d.ts +117 -0
  83. package/dist/resources/backups.d.ts.map +1 -0
  84. package/dist/resources/backups.js +92 -0
  85. package/dist/resources/backups.js.map +1 -0
  86. package/dist/resources/branches.d.ts +151 -0
  87. package/dist/resources/branches.d.ts.map +1 -0
  88. package/dist/resources/branches.js +62 -0
  89. package/dist/resources/branches.js.map +1 -0
  90. package/dist/resources/database.d.ts +107 -0
  91. package/dist/resources/database.d.ts.map +1 -0
  92. package/dist/resources/database.js +54 -0
  93. package/dist/resources/database.js.map +1 -0
  94. package/dist/resources/environments.d.ts +106 -0
  95. package/dist/resources/environments.d.ts.map +1 -0
  96. package/dist/resources/environments.js +131 -0
  97. package/dist/resources/environments.js.map +1 -0
  98. package/dist/resources/export.d.ts +101 -0
  99. package/dist/resources/export.d.ts.map +1 -0
  100. package/dist/resources/export.js +89 -0
  101. package/dist/resources/export.js.map +1 -0
  102. package/dist/resources/functions.d.ts +75 -0
  103. package/dist/resources/functions.d.ts.map +1 -0
  104. package/dist/resources/functions.js +58 -0
  105. package/dist/resources/functions.js.map +1 -0
  106. package/dist/resources/imports.d.ts +183 -0
  107. package/dist/resources/imports.d.ts.map +1 -0
  108. package/dist/resources/imports.js +168 -0
  109. package/dist/resources/imports.js.map +1 -0
  110. package/dist/resources/insights.d.ts +50 -0
  111. package/dist/resources/insights.d.ts.map +1 -0
  112. package/dist/resources/insights.js +21 -0
  113. package/dist/resources/insights.js.map +1 -0
  114. package/dist/resources/metrics.d.ts +61 -0
  115. package/dist/resources/metrics.d.ts.map +1 -0
  116. package/dist/resources/metrics.js +23 -0
  117. package/dist/resources/metrics.js.map +1 -0
  118. package/dist/resources/migrations.d.ts +24 -0
  119. package/dist/resources/migrations.d.ts.map +1 -0
  120. package/dist/resources/migrations.js +29 -0
  121. package/dist/resources/migrations.js.map +1 -0
  122. package/dist/resources/operations.d.ts +37 -0
  123. package/dist/resources/operations.d.ts.map +1 -0
  124. package/dist/resources/operations.js +81 -0
  125. package/dist/resources/operations.js.map +1 -0
  126. package/dist/resources/organizations.d.ts +171 -0
  127. package/dist/resources/organizations.d.ts.map +1 -0
  128. package/dist/resources/organizations.js +180 -0
  129. package/dist/resources/organizations.js.map +1 -0
  130. package/dist/resources/previews.d.ts +49 -0
  131. package/dist/resources/previews.d.ts.map +1 -0
  132. package/dist/resources/previews.js +62 -0
  133. package/dist/resources/previews.js.map +1 -0
  134. package/dist/resources/projects.d.ts +73 -0
  135. package/dist/resources/projects.d.ts.map +1 -0
  136. package/dist/resources/projects.js +84 -0
  137. package/dist/resources/projects.js.map +1 -0
  138. package/dist/resources/queues.d.ts +100 -0
  139. package/dist/resources/queues.d.ts.map +1 -0
  140. package/dist/resources/queues.js +77 -0
  141. package/dist/resources/queues.js.map +1 -0
  142. package/dist/resources/realtime.d.ts +37 -0
  143. package/dist/resources/realtime.d.ts.map +1 -0
  144. package/dist/resources/realtime.js +23 -0
  145. package/dist/resources/realtime.js.map +1 -0
  146. package/dist/resources/restores.d.ts +67 -0
  147. package/dist/resources/restores.d.ts.map +1 -0
  148. package/dist/resources/restores.js +90 -0
  149. package/dist/resources/restores.js.map +1 -0
  150. package/dist/resources/storage.d.ts +50 -0
  151. package/dist/resources/storage.d.ts.map +1 -0
  152. package/dist/resources/storage.js +38 -0
  153. package/dist/resources/storage.js.map +1 -0
  154. package/dist/resources/usage.d.ts +85 -0
  155. package/dist/resources/usage.d.ts.map +1 -0
  156. package/dist/resources/usage.js +37 -0
  157. package/dist/resources/usage.js.map +1 -0
  158. package/dist/types.gen.d.ts +473 -0
  159. package/dist/types.gen.d.ts.map +1 -0
  160. package/dist/types.gen.js +8 -0
  161. package/dist/types.gen.js.map +1 -0
  162. package/package.json +53 -0
@@ -0,0 +1,171 @@
1
+ import type { HttpTransport } from '../client.js';
2
+ import type { MutationOptions } from './environments.js';
3
+ import type { Membership, Role, Organization, PortableIdentifier, PutMembershipRequest, PutOrganizationRequest } from '../types.gen.js';
4
+ /** An organization the caller belongs to, with the caller's role in it. */
5
+ export interface OrganizationSummary {
6
+ organization_id: PortableIdentifier;
7
+ display_name: string;
8
+ role: Role;
9
+ }
10
+ /** Body of {@link OrganizationsResource.update}. */
11
+ export interface UpdateOrganizationRequest {
12
+ /** New human-readable name, 1..200 characters. */
13
+ display_name: string;
14
+ }
15
+ /** Result of {@link OrganizationsResource.scheduleDeletion}. */
16
+ export interface ScheduledDeletion {
17
+ scheduled: true;
18
+ organization_id: PortableIdentifier;
19
+ replayed: boolean;
20
+ }
21
+ export interface NotificationSettings {
22
+ emails_enabled: boolean;
23
+ security_alerts_enabled: boolean;
24
+ /** Epoch seconds of the last change. */
25
+ updated_at: number;
26
+ webhook_url?: string;
27
+ updated_by?: string;
28
+ }
29
+ export interface PutNotificationSettingsRequest {
30
+ emails_enabled: boolean;
31
+ security_alerts_enabled: boolean;
32
+ /** HTTPS endpoint for operational notifications; omit to clear. */
33
+ webhook_url?: string;
34
+ }
35
+ export type ApiKeyScope = 'read' | 'deploy' | 'admin';
36
+ /** A scoped agent token. The cleartext `secret` is present only on create. */
37
+ export interface ApiKey {
38
+ api_key_id: PortableIdentifier;
39
+ organization_id: PortableIdentifier;
40
+ name: string;
41
+ scopes: ApiKeyScope[];
42
+ created_at_epoch_seconds: number;
43
+ last_used_epoch_seconds?: number;
44
+ /** Returned exactly once, by {@link OrganizationsResource.createApiKey}. */
45
+ secret?: string;
46
+ }
47
+ export interface CreateApiKeyRequest {
48
+ /** 1..120 characters. */
49
+ name: string;
50
+ /** Non-empty subset of `read`, `deploy`, `admin`. */
51
+ scopes: ApiKeyScope[];
52
+ }
53
+ export interface RevokedApiKey {
54
+ api_key_id: PortableIdentifier;
55
+ revoked: true;
56
+ replayed: boolean;
57
+ }
58
+ /** An operational governance rule (which actions need approval or are denied). */
59
+ export interface OrgPolicy {
60
+ policy_id: PortableIdentifier;
61
+ action: string;
62
+ description: string;
63
+ effect: string;
64
+ applies_to_kinds: string[];
65
+ }
66
+ /** One MCP tool this deployment exposes to agents. */
67
+ export interface McpTool {
68
+ name: string;
69
+ description?: string;
70
+ [key: string]: unknown;
71
+ }
72
+ /**
73
+ * Organizations and their memberships.
74
+ *
75
+ * `put` is the bootstrap: it idempotently creates an organization with the
76
+ * caller as initial owner and requires only a verified identity, not a
77
+ * pre-existing membership. `putMembership` idempotently sets one subject's role.
78
+ */
79
+ /** One signed delivery of a control-plane event to the notification webhook. */
80
+ export interface EventDelivery {
81
+ delivery_id: string;
82
+ event_id: string;
83
+ /** `usage.threshold_reached`, `usage.cap_reached`, or `webhook.test`. */
84
+ event_type: string;
85
+ target_url: string;
86
+ status: 'pending' | 'delivered' | 'failed';
87
+ attempts: number;
88
+ last_status_code: number | null;
89
+ last_error: string | null;
90
+ created_epoch_seconds: number;
91
+ delivered_epoch_seconds: number | null;
92
+ next_attempt_epoch_seconds: number | null;
93
+ /** The exact signed body. */
94
+ payload: {
95
+ id: string;
96
+ type: string;
97
+ created_epoch_seconds: number;
98
+ organization_id: string;
99
+ project_id: string | null;
100
+ environment_id: string | null;
101
+ data: Record<string, unknown>;
102
+ };
103
+ }
104
+ export interface EventDeliveryList {
105
+ deliveries: EventDelivery[];
106
+ webhook_configured: boolean;
107
+ max_attempts: number;
108
+ }
109
+ /** The HMAC key for `Scribase-Signature` (`t=<unix>,v1=<hex HMAC-SHA256(secret, t.body)>`). */
110
+ export interface EventSigningSecret {
111
+ secret: string;
112
+ rotated: boolean;
113
+ header: string;
114
+ scheme: string;
115
+ }
116
+ export declare class OrganizationsResource {
117
+ #private;
118
+ constructor(http: HttpTransport);
119
+ /** `PUT /v1/organizations/{id}` — create-or-confirm; caller becomes owner. */
120
+ put(organizationId: PortableIdentifier, body: PutOrganizationRequest): Promise<Organization>;
121
+ /**
122
+ * `PATCH /v1/organizations/{id}` — rename an organization (owner or admin).
123
+ * Returns the updated organization record.
124
+ */
125
+ update(organizationId: PortableIdentifier, body: UpdateOrganizationRequest, options?: MutationOptions): Promise<Organization>;
126
+ /** `GET /v1/organizations/{id}` — visible to a current member. */
127
+ get(organizationId: PortableIdentifier): Promise<Organization>;
128
+ /** `PUT /v1/organizations/{id}/memberships` — add or change a subject's role. */
129
+ putMembership(organizationId: PortableIdentifier, body: PutMembershipRequest): Promise<Membership>;
130
+ /** `GET /v1/organizations` — every organization the caller belongs to. */
131
+ list(): Promise<OrganizationSummary[]>;
132
+ /** `GET /v1/organizations/{id}/memberships` — every member and role. */
133
+ listMemberships(organizationId: PortableIdentifier): Promise<Membership[]>;
134
+ /**
135
+ * `DELETE /v1/organizations/{id}` — schedule the organization for deletion
136
+ * (owner only). Irreversible once the grace window lapses; confirm with a
137
+ * human before calling.
138
+ */
139
+ scheduleDeletion(organizationId: PortableIdentifier, options?: MutationOptions): Promise<ScheduledDeletion>;
140
+ /** `GET /v1/organizations/{id}/notification-settings`. */
141
+ getNotificationSettings(organizationId: PortableIdentifier): Promise<NotificationSettings>;
142
+ /** `PUT /v1/organizations/{id}/notification-settings` — replace preferences. */
143
+ putNotificationSettings(organizationId: PortableIdentifier, body: PutNotificationSettingsRequest, options?: MutationOptions): Promise<NotificationSettings>;
144
+ /** `GET /v1/organizations/{id}/api-keys` — active scoped agent tokens. */
145
+ listApiKeys(organizationId: PortableIdentifier): Promise<ApiKey[]>;
146
+ /**
147
+ * `POST /v1/organizations/{id}/api-keys` — mint a scoped agent token. The
148
+ * returned `secret` is shown exactly once; store it in a secret manager.
149
+ */
150
+ createApiKey(organizationId: PortableIdentifier, body: CreateApiKeyRequest, options?: MutationOptions): Promise<ApiKey>;
151
+ /** `DELETE /v1/organizations/{id}/api-keys/{keyId}` — revoke a token. */
152
+ revokeApiKey(organizationId: PortableIdentifier, apiKeyId: PortableIdentifier, options?: MutationOptions): Promise<RevokedApiKey>;
153
+ /** `GET /v1/organizations/{id}/policies` — governance policies. */
154
+ listPolicies(organizationId: PortableIdentifier): Promise<OrgPolicy[]>;
155
+ /** `GET /v1/organizations/{id}/mcp/tools` — MCP tools this deployment exposes. */
156
+ listMcpTools(organizationId: PortableIdentifier): Promise<McpTool[]>;
157
+ /** `GET /v1/organizations/{org}/event-deliveries` — recent usage-event deliveries. */
158
+ eventDeliveries(organizationId: PortableIdentifier, options?: {
159
+ limit?: number;
160
+ }): Promise<EventDeliveryList>;
161
+ /** `POST /v1/organizations/{org}/event-deliveries/test` — send a signed `webhook.test` now. */
162
+ sendTestEvent(organizationId: PortableIdentifier): Promise<EventDelivery>;
163
+ /**
164
+ * Reveal (`GET`, created on first use) or rotate (`POST`) the secret that
165
+ * signs event deliveries. Owner or admin.
166
+ */
167
+ eventSigningSecret(organizationId: PortableIdentifier, options?: {
168
+ rotate?: boolean;
169
+ }): Promise<EventSigningSecret>;
170
+ }
171
+ //# sourceMappingURL=organizations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/resources/organizations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EACV,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,kBAAkB,CAAC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,oDAAoD;AACpD,MAAM,WAAW,yBAAyB;IACxC,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,gEAAgE;AAChE,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,IAAI,CAAC;IAChB,eAAe,EAAE,kBAAkB,CAAC;IACpC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB,EAAE,OAAO,CAAC;IACjC,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,8BAA8B;IAC7C,cA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AAC,cAAc,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAQ1E,sFAAsF;IAChF,eAAe,CACnB,cAAc,EAAE,kBAAkB,EAClC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3B,OAAO,CAAC,iBAAiB,CAAC;IAS7B,+FAA+F;IACzF,aAAa,CAAC,cAAc,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ/E;;;OAGG;IACG,kBAAkB,CACtB,cAAc,EAAE,kBAAkB,EAClC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAC7B,OAAO,CAAC,kBAAkB,CAAC;CAO/B"}
@@ -0,0 +1,180 @@
1
+ import { resolveIdempotencyKey } from '../idempotency.js';
2
+ export class OrganizationsResource {
3
+ #http;
4
+ constructor(http) {
5
+ this.#http = http;
6
+ }
7
+ /** `PUT /v1/organizations/{id}` — create-or-confirm; caller becomes owner. */
8
+ async put(organizationId, body) {
9
+ const result = await this.#http.send({
10
+ method: 'PUT',
11
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}`,
12
+ body,
13
+ });
14
+ return result.data;
15
+ }
16
+ /**
17
+ * `PATCH /v1/organizations/{id}` — rename an organization (owner or admin).
18
+ * Returns the updated organization record.
19
+ */
20
+ async update(organizationId, body, options) {
21
+ const result = await this.#http.send({
22
+ method: 'PATCH',
23
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}`,
24
+ body,
25
+ idempotencyKey: resolveIdempotencyKey(options?.idempotencyKey),
26
+ ...(options?.signal ? { signal: options.signal } : {}),
27
+ });
28
+ return result.data;
29
+ }
30
+ /** `GET /v1/organizations/{id}` — visible to a current member. */
31
+ async get(organizationId) {
32
+ const result = await this.#http.send({
33
+ method: 'GET',
34
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}`,
35
+ });
36
+ return result.data;
37
+ }
38
+ /** `PUT /v1/organizations/{id}/memberships` — add or change a subject's role. */
39
+ async putMembership(organizationId, body) {
40
+ const result = await this.#http.send({
41
+ method: 'PUT',
42
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}/memberships`,
43
+ body,
44
+ });
45
+ return result.data;
46
+ }
47
+ /** `GET /v1/organizations` — every organization the caller belongs to. */
48
+ async list() {
49
+ const result = await this.#http.send({
50
+ method: 'GET',
51
+ path: '/v1/organizations',
52
+ });
53
+ return result.data.items;
54
+ }
55
+ /** `GET /v1/organizations/{id}/memberships` — every member and role. */
56
+ async listMemberships(organizationId) {
57
+ const result = await this.#http.send({
58
+ method: 'GET',
59
+ path: `${orgPath(organizationId)}/memberships`,
60
+ });
61
+ return result.data.items;
62
+ }
63
+ /**
64
+ * `DELETE /v1/organizations/{id}` — schedule the organization for deletion
65
+ * (owner only). Irreversible once the grace window lapses; confirm with a
66
+ * human before calling.
67
+ */
68
+ async scheduleDeletion(organizationId, options) {
69
+ const result = await this.#http.send({
70
+ method: 'DELETE',
71
+ path: orgPath(organizationId),
72
+ idempotencyKey: resolveIdempotencyKey(options?.idempotencyKey),
73
+ ...(options?.signal ? { signal: options.signal } : {}),
74
+ });
75
+ return result.data;
76
+ }
77
+ /** `GET /v1/organizations/{id}/notification-settings`. */
78
+ async getNotificationSettings(organizationId) {
79
+ const result = await this.#http.send({
80
+ method: 'GET',
81
+ path: `${orgPath(organizationId)}/notification-settings`,
82
+ });
83
+ return result.data;
84
+ }
85
+ /** `PUT /v1/organizations/{id}/notification-settings` — replace preferences. */
86
+ async putNotificationSettings(organizationId, body, options) {
87
+ const result = await this.#http.send({
88
+ method: 'PUT',
89
+ path: `${orgPath(organizationId)}/notification-settings`,
90
+ body,
91
+ idempotencyKey: resolveIdempotencyKey(options?.idempotencyKey),
92
+ ...(options?.signal ? { signal: options.signal } : {}),
93
+ });
94
+ return result.data;
95
+ }
96
+ /** `GET /v1/organizations/{id}/api-keys` — active scoped agent tokens. */
97
+ async listApiKeys(organizationId) {
98
+ const result = await this.#http.send({
99
+ method: 'GET',
100
+ path: `${orgPath(organizationId)}/api-keys`,
101
+ });
102
+ return result.data.items;
103
+ }
104
+ /**
105
+ * `POST /v1/organizations/{id}/api-keys` — mint a scoped agent token. The
106
+ * returned `secret` is shown exactly once; store it in a secret manager.
107
+ */
108
+ async createApiKey(organizationId, body, options) {
109
+ if (body.scopes.length === 0) {
110
+ throw new RangeError('an API key needs at least one scope');
111
+ }
112
+ // The control plane requires an Idempotency-Key on API key creation.
113
+ const result = await this.#http.send({
114
+ method: 'POST',
115
+ path: `${orgPath(organizationId)}/api-keys`,
116
+ body,
117
+ idempotencyKey: resolveIdempotencyKey(options?.idempotencyKey),
118
+ ...(options?.signal ? { signal: options.signal } : {}),
119
+ });
120
+ return result.data;
121
+ }
122
+ /** `DELETE /v1/organizations/{id}/api-keys/{keyId}` — revoke a token. */
123
+ async revokeApiKey(organizationId, apiKeyId, options) {
124
+ const result = await this.#http.send({
125
+ method: 'DELETE',
126
+ path: `${orgPath(organizationId)}/api-keys/${encodeURIComponent(apiKeyId)}`,
127
+ idempotencyKey: resolveIdempotencyKey(options?.idempotencyKey),
128
+ ...(options?.signal ? { signal: options.signal } : {}),
129
+ });
130
+ return result.data;
131
+ }
132
+ /** `GET /v1/organizations/{id}/policies` — governance policies. */
133
+ async listPolicies(organizationId) {
134
+ const result = await this.#http.send({
135
+ method: 'GET',
136
+ path: `${orgPath(organizationId)}/policies`,
137
+ });
138
+ return result.data.items;
139
+ }
140
+ /** `GET /v1/organizations/{id}/mcp/tools` — MCP tools this deployment exposes. */
141
+ async listMcpTools(organizationId) {
142
+ const result = await this.#http.send({
143
+ method: 'GET',
144
+ path: `${orgPath(organizationId)}/mcp/tools`,
145
+ });
146
+ return result.data.tools;
147
+ }
148
+ /** `GET /v1/organizations/{org}/event-deliveries` — recent usage-event deliveries. */
149
+ async eventDeliveries(organizationId, options) {
150
+ const result = await this.#http.send({
151
+ method: 'GET',
152
+ path: `${orgPath(organizationId)}/event-deliveries`,
153
+ ...(options?.limit !== undefined ? { query: { limit: options.limit } } : {}),
154
+ });
155
+ return result.data;
156
+ }
157
+ /** `POST /v1/organizations/{org}/event-deliveries/test` — send a signed `webhook.test` now. */
158
+ async sendTestEvent(organizationId) {
159
+ const result = await this.#http.send({
160
+ method: 'POST',
161
+ path: `${orgPath(organizationId)}/event-deliveries/test`,
162
+ });
163
+ return result.data;
164
+ }
165
+ /**
166
+ * Reveal (`GET`, created on first use) or rotate (`POST`) the secret that
167
+ * signs event deliveries. Owner or admin.
168
+ */
169
+ async eventSigningSecret(organizationId, options) {
170
+ const result = await this.#http.send({
171
+ method: options?.rotate === true ? 'POST' : 'GET',
172
+ path: `${orgPath(organizationId)}/notification-settings/signing-secret`,
173
+ });
174
+ return result.data;
175
+ }
176
+ }
177
+ function orgPath(organizationId) {
178
+ return `/v1/organizations/${encodeURIComponent(organizationId)}`;
179
+ }
180
+ //# sourceMappingURL=organizations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizations.js","sourceRoot":"","sources":["../../src/resources/organizations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAyI1D,MAAM,OAAO,qBAAqB;IACvB,KAAK,CAAgB;IAE9B,YAAY,IAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,8EAA8E;IAC9E,KAAK,CAAC,GAAG,CACP,cAAkC,EAClC,IAA4B;QAE5B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAe;YACjD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,qBAAqB,kBAAkB,CAAC,cAAc,CAAC,EAAE;YAC/D,IAAI;SACL,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CACV,cAAkC,EAClC,IAA+B,EAC/B,OAAyB;QAEzB,MAAM,MAAM,GAAG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AAK,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7E,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,+FAA+F;IAC/F,KAAK,CAAC,aAAa,CAAC,cAAkC;QACpD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAgB;YAClD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,wBAAwB;SACzD,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,kBAAkB,CACtB,cAAkC,EAClC,OAA8B;QAE9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAqB;YACvD,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;YACjD,IAAI,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,uCAAuC;SACxE,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;CACF;AAED,SAAS,OAAO,CAAC,cAAkC;IACjD,OAAO,qBAAqB,kBAAkB,CAAC,cAAc,CAAC,EAAE,CAAC;AACnE,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { AcceptedOperation, HttpTransport } from '../client.js';
2
+ import type { EnvironmentRef, MutationOptions, RenewedEnvironment } from './environments.js';
3
+ import type { DataMode, Environment, PortableIdentifier } from '../types.gen.js';
4
+ /** Default lifetime for a preview when the caller does not set one (24h). */
5
+ export declare const DEFAULT_PREVIEW_TTL_HOURS = 24;
6
+ export interface CreatePreviewRequest {
7
+ organizationId: PortableIdentifier;
8
+ projectId: PortableIdentifier;
9
+ environmentId: PortableIdentifier;
10
+ region: PortableIdentifier;
11
+ postgres_major: 17;
12
+ /** How much data the preview carries. Defaults to `sanitized`. */
13
+ dataMode?: DataMode;
14
+ /** 1..720 hours; defaults to {@link DEFAULT_PREVIEW_TTL_HOURS}. */
15
+ ttlHours?: number;
16
+ }
17
+ export interface ListPreviewsParams {
18
+ organizationId: PortableIdentifier;
19
+ projectId?: PortableIdentifier;
20
+ limit?: number;
21
+ }
22
+ /**
23
+ * Previews — ephemeral, TTL-swept environments (`kind: 'preview'`), the
24
+ * per-branch answer to metered branching. This resource is a typed convenience
25
+ * over the environment contract: it forces `kind: 'preview'`, defaults the data
26
+ * mode to `sanitized` (never raw production data by accident), and always sets a
27
+ * TTL so a forgotten preview cannot run forever.
28
+ */
29
+ export declare class PreviewsResource {
30
+ #private;
31
+ constructor(http: HttpTransport);
32
+ /** Provision a preview environment (async). */
33
+ create(request: CreatePreviewRequest, options?: MutationOptions): Promise<AcceptedOperation>;
34
+ /** List only the preview environments in the organization/project. */
35
+ list(params: ListPreviewsParams): Promise<Environment[]>;
36
+ /** Fetch a single preview environment. */
37
+ get(ref: EnvironmentRef): Promise<Environment>;
38
+ /** Delete a preview immediately rather than waiting for TTL sweep (async). */
39
+ delete(ref: EnvironmentRef, options?: MutationOptions): Promise<AcceptedOperation>;
40
+ /**
41
+ * Extend a preview's lifetime to `ttlHours` (default
42
+ * {@link DEFAULT_PREVIEW_TTL_HOURS}) from now, so an active branch is not
43
+ * swept mid-review.
44
+ */
45
+ renew(ref: EnvironmentRef, ttlHours?: number): Promise<RenewedEnvironment>;
46
+ /** Remaining lifetime in seconds, or `null` if the preview has no expiry set. */
47
+ remainingSeconds(environment: Environment, now?: number): number | null;
48
+ }
49
+ //# sourceMappingURL=previews.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previews.d.ts","sourceRoot":"","sources":["../../src/resources/previews.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,k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AW,EAAE,WAAW,EAAE,GAAG,GAAE,MAAmB,GAAG,MAAM,GAAG,IAAI;CAMpF"}
@@ -0,0 +1,62 @@
1
+ import { EnvironmentsResource } from './environments.js';
2
+ /** Default lifetime for a preview when the caller does not set one (24h). */
3
+ export const DEFAULT_PREVIEW_TTL_HOURS = 24;
4
+ /**
5
+ * Previews — ephemeral, TTL-swept environments (`kind: 'preview'`), the
6
+ * per-branch answer to metered branching. This resource is a typed convenience
7
+ * over the environment contract: it forces `kind: 'preview'`, defaults the data
8
+ * mode to `sanitized` (never raw production data by accident), and always sets a
9
+ * TTL so a forgotten preview cannot run forever.
10
+ */
11
+ export class PreviewsResource {
12
+ #environments;
13
+ constructor(http) {
14
+ this.#environments = new EnvironmentsResource(http);
15
+ }
16
+ /** Provision a preview environment (async). */
17
+ async create(request, options) {
18
+ return this.#environments.create({
19
+ organization_id: request.organizationId,
20
+ project_id: request.projectId,
21
+ environment_id: request.environmentId,
22
+ kind: 'preview',
23
+ data_mode: request.dataMode ?? 'sanitized',
24
+ region: request.region,
25
+ postgres_major: request.postgres_major,
26
+ ttl_hours: request.ttlHours ?? DEFAULT_PREVIEW_TTL_HOURS,
27
+ }, options);
28
+ }
29
+ /** List only the preview environments in the organization/project. */
30
+ async list(params) {
31
+ const environments = await this.#environments.list({
32
+ organizationId: params.organizationId,
33
+ ...(params.projectId !== undefined ? { projectId: params.projectId } : {}),
34
+ ...(params.limit !== undefined ? { limit: params.limit } : {}),
35
+ });
36
+ return environments.filter((environment) => environment.kind === 'preview');
37
+ }
38
+ /** Fetch a single preview environment. */
39
+ async get(ref) {
40
+ return this.#environments.get(ref);
41
+ }
42
+ /** Delete a preview immediately rather than waiting for TTL sweep (async). */
43
+ async delete(ref, options) {
44
+ return this.#environments.delete(ref, options);
45
+ }
46
+ /**
47
+ * Extend a preview's lifetime to `ttlHours` (default
48
+ * {@link DEFAULT_PREVIEW_TTL_HOURS}) from now, so an active branch is not
49
+ * swept mid-review.
50
+ */
51
+ async renew(ref, ttlHours = DEFAULT_PREVIEW_TTL_HOURS) {
52
+ return this.#environments.renew(ref, ttlHours);
53
+ }
54
+ /** Remaining lifetime in seconds, or `null` if the preview has no expiry set. */
55
+ remainingSeconds(environment, now = Date.now()) {
56
+ if (environment.expires_at_epoch_seconds === undefined) {
57
+ return null;
58
+ }
59
+ return Math.max(0, environment.expires_at_epoch_seconds - Math.floor(now / 1000));
60
+ }
61
+ }
62
+ //# sourceMappingURL=previews.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previews.js","sourceRoot":"","sources":["../../src/resources/previews.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAIzD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAoB5C;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAClB,aAAa,CAAuB;IAE7C,YAAY,IAAmB;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,+CAA+C;IAC/C,KAAK,CAAC,MAAM,CACV,OAA6B,EAC7B,OAAyB;QAEzB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAC9B;YACE,eAAe,EAAE,OAAO,CAAC,cAAc;YACvC,UAAU,EAAE,OAAO,CAAC,SAAS;YAC7B,cAAc,EAAE,OAAO,CAAC,aAAa;YACrC,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,OAAO,CAAC,QAAQ,IAAI,WAAW;YAC1C,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,SAAS,EAAE,OAAO,CAAC,QAAQ,IAAI,yBAAyB;SACzD,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,KAAK,CAAC,IAAI,CAAC,MAA0B;QACnC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IA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}
@@ -0,0 +1,73 @@
1
+ import type { HttpTransport } from '../client.js';
2
+ import type { PortableIdentifier, Project, PutProjectRequest } from '../types.gen.js';
3
+ /** A custom domain bound to one of the project's environments. */
4
+ export interface CustomDomain {
5
+ domain: string;
6
+ environment_id: PortableIdentifier;
7
+ verified: boolean;
8
+ certificate_state: string;
9
+ /** The DNS TXT record to publish, while verification is pending. */
10
+ verification_txt_record?: string;
11
+ }
12
+ /** Metrics a per-project override can cap. */
13
+ export type QuotaMetric = 'database_gb' | 'storage_gb' | 'backup_gb' | 'preview_environments' | 'egress_gb' | 'compute_hours' | 'rows' | 'function_invocations';
14
+ export interface ProjectQuotaOverride {
15
+ metric: QuotaMetric;
16
+ label: string;
17
+ unit: string;
18
+ /** Hard cap applied to every environment of the project. */
19
+ cap: number;
20
+ updated_by: string;
21
+ updated_at_epoch_seconds: number;
22
+ }
23
+ /** Response of {@link ProjectsResource.getQuotas} / {@link ProjectsResource.setQuotas}. */
24
+ export interface ProjectQuotas {
25
+ organization_id: string;
26
+ project_id: string;
27
+ overrides: ProjectQuotaOverride[];
28
+ /** Every metric that can be capped, with its label and unit. */
29
+ metrics: Array<{
30
+ metric: QuotaMetric;
31
+ label: string;
32
+ unit: string;
33
+ }>;
34
+ /** Fraction of a cap at which `usage.threshold_reached` fires (0.8). */
35
+ threshold: number;
36
+ }
37
+ /** `metric -> cap`, or `null` to remove that override. */
38
+ export type QuotaOverrides = Partial<Record<QuotaMetric, number | null>>;
39
+ /**
40
+ * Projects — the immutable specification (region + Postgres major) that
41
+ * environments are provisioned against. `put` is idempotent create; the spec
42
+ * cannot be mutated afterwards, only re-confirmed.
43
+ */
44
+ export declare class ProjectsResource {
45
+ #private;
46
+ constructor(http: HttpTransport);
47
+ /** `PUT /v1/organizations/{org}/projects/{project}` — idempotent create. */
48
+ put(organizationId: PortableIdentifier, projectId: PortableIdentifier, body: PutProjectRequest): Promise<Project>;
49
+ /** `GET /v1/organizations/{org}/projects/{project}`. */
50
+ get(organizationId: PortableIdentifier, projectId: PortableIdentifier): Promise<Project>;
51
+ /** `GET /v1/organizations/{org}/projects` — every project the caller may read. */
52
+ list(organizationId: PortableIdentifier): Promise<Project[]>;
53
+ /** `GET /v1/organizations/{org}/projects/{project}/domains` — custom domains. */
54
+ listDomains(organizationId: PortableIdentifier, projectId: PortableIdentifier): Promise<CustomDomain[]>;
55
+ /**
56
+ * `GET /v1/organizations/{org}/projects/{project}/quotas` — per-project hard
57
+ * caps. The effective cap on each environment is the lower of the plan cap
58
+ * and the override; `rows` and `function_invocations` are capped only here.
59
+ */
60
+ getQuotas(organizationId: PortableIdentifier, projectId: PortableIdentifier): Promise<ProjectQuotas>;
61
+ /**
62
+ * `PUT /v1/organizations/{org}/projects/{project}/quotas` — set (number) or
63
+ * clear (`null`) overrides. Owner or admin. Takes effect immediately, and
64
+ * `usage.threshold_reached` / `usage.cap_reached` events are signed and sent
65
+ * to the organization's notification webhook when a tenant crosses them.
66
+ *
67
+ * ```ts
68
+ * await client.projects.setQuotas('agency', 'customer-42', { storage_gb: 5, rows: 100_000 });
69
+ * ```
70
+ */
71
+ setQuotas(organizationId: PortableIdentifier, projectId: PortableIdentifier, overrides: QuotaOverrides): Promise<ProjectQuotas>;
72
+ }
73
+ //# sourceMappingURL=projects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/resources/projects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,kBAAkB,EAClB,OAAO,EACP,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,kEAAkE;AAClE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,kBAAkB,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,uBAAuB,CAAC,EAAE,M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AO,EAAE,CAAC;IAQlE,iFAAiF;IAC3E,WAAW,CACf,cAAc,EAAE,kBAAkB,EAClC,SAAS,EAAE,kBAAkB,GAC5B,OAAO,CAAC,YAAY,EAAE,CAAC;IAU1B;;;;OAIG;IACG,SAAS,CACb,cAAc,EAAE,kBAAkB,EAClC,SAAS,EAAE,kBAAkB,GAC5B,OAAO,CAAC,aAAa,CAAC;IAUzB;;;;;;;;;OASG;IACG,SAAS,CACb,cAAc,EAAE,kBAAkB,EAClC,SAAS,EAAE,kBAAkB,EAC7B,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,aAAa,CAAC;CAmB1B"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Projects — the immutable specification (region + Postgres major) that
3
+ * environments are provisioned against. `put` is idempotent create; the spec
4
+ * cannot be mutated afterwards, only re-confirmed.
5
+ */
6
+ export class ProjectsResource {
7
+ #http;
8
+ constructor(http) {
9
+ this.#http = http;
10
+ }
11
+ /** `PUT /v1/organizations/{org}/projects/{project}` — idempotent create. */
12
+ async put(organizationId, projectId, body) {
13
+ const result = await this.#http.send({
14
+ method: 'PUT',
15
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}/projects/${encodeURIComponent(projectId)}`,
16
+ body,
17
+ });
18
+ return result.data;
19
+ }
20
+ /** `GET /v1/organizations/{org}/projects/{project}`. */
21
+ async get(organizationId, projectId) {
22
+ const result = await this.#http.send({
23
+ method: 'GET',
24
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}/projects/${encodeURIComponent(projectId)}`,
25
+ });
26
+ return result.data;
27
+ }
28
+ /** `GET /v1/organizations/{org}/projects` — every project the caller may read. */
29
+ async list(organizationId) {
30
+ const result = await this.#http.send({
31
+ method: 'GET',
32
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}/projects`,
33
+ });
34
+ return result.data.items;
35
+ }
36
+ /** `GET /v1/organizations/{org}/projects/{project}/domains` — custom domains. */
37
+ async listDomains(organizationId, projectId) {
38
+ const result = await this.#http.send({
39
+ method: 'GET',
40
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}/projects/${encodeURIComponent(projectId)}/domains`,
41
+ });
42
+ return result.data.items;
43
+ }
44
+ /**
45
+ * `GET /v1/organizations/{org}/projects/{project}/quotas` — per-project hard
46
+ * caps. The effective cap on each environment is the lower of the plan cap
47
+ * and the override; `rows` and `function_invocations` are capped only here.
48
+ */
49
+ async getQuotas(organizationId, projectId) {
50
+ const result = await this.#http.send({
51
+ method: 'GET',
52
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}/projects/${encodeURIComponent(projectId)}/quotas`,
53
+ });
54
+ return result.data;
55
+ }
56
+ /**
57
+ * `PUT /v1/organizations/{org}/projects/{project}/quotas` — set (number) or
58
+ * clear (`null`) overrides. Owner or admin. Takes effect immediately, and
59
+ * `usage.threshold_reached` / `usage.cap_reached` events are signed and sent
60
+ * to the organization's notification webhook when a tenant crosses them.
61
+ *
62
+ * ```ts
63
+ * await client.projects.setQuotas('agency', 'customer-42', { storage_gb: 5, rows: 100_000 });
64
+ * ```
65
+ */
66
+ async setQuotas(organizationId, projectId, overrides) {
67
+ const entries = Object.entries(overrides);
68
+ if (entries.length === 0) {
69
+ throw new RangeError('overrides must name at least one metric');
70
+ }
71
+ for (const [metric, cap] of entries) {
72
+ if (cap !== null && (typeof cap !== 'number' || !Number.isFinite(cap) || cap < 0)) {
73
+ throw new RangeError(`${metric} must be a non-negative number or null`);
74
+ }
75
+ }
76
+ const result = await this.#http.send({
77
+ method: 'PUT',
78
+ path: `/v1/organizations/${encodeURIComponent(organizationId)}/projects/${encodeURIComponent(projectId)}/quotas`,
79
+ body: { overrides },
80
+ });
81
+ return result.data;
82
+ }
83
+ }
84
+ //# sourceMappingURL=projects.js.map