@brazosd/node 0.1.9 → 0.1.11

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/README.md CHANGED
@@ -146,7 +146,9 @@ and PKCE. Service credentials remain on the app server. Store the verified
146
146
  identity or user credentials in your own server session and send an opaque
147
147
  session cookie to the browser. Identity JWTs contain `account_id`, `org_id`,
148
148
  `user_id` and `sub=String(account_id)`; `(iss, sub)` is the recommended identity
149
- key. They cannot call Brazosd APIs or refresh API credentials.
149
+ key. The boolean `identity.is_org_owner` reports whether the user owned the
150
+ selected organization when the JWT was issued. Older tokens omit this field.
151
+ Identity JWTs cannot call Brazosd APIs or refresh API credentials.
150
152
 
151
153
  `sso.userClient({getTokens, saveTokens})` refreshes org-user credentials and
152
154
  keeps each user's identity isolated. Shared session stores must compare-and-swap
package/browser.d.ts CHANGED
@@ -3538,7 +3538,7 @@ type SSOTokens = {
3538
3538
  expiresAt: string;
3539
3539
  grantId?: string;
3540
3540
  /**
3541
- * Only present in identity mode. JWT with sub=string(account_id), account_id, org_id, user_id, iss, aud=app ID, iat, exp and token_use=sso_identity. Never accepted as a brazosd API credential.
3541
+ * Only present in identity mode. JWT with sub=string(account_id), account_id, org_id, user_id, is_org_owner, iss, aud=app ID, iat, exp and token_use=sso_identity. The boolean is_org_owner records whether the user owned the selected organization at issuance. Never accepted as a brazosd API credential.
3542
3542
  */
3543
3543
  identityToken?: string;
3544
3544
  mode: SSOMode;
@@ -7860,6 +7860,52 @@ type AppLogPage = {
7860
7860
  */
7861
7861
  retryAfterSeconds?: number;
7862
7862
  };
7863
+ type RuntimeMetricPoint = {
7864
+ /**
7865
+ * Inclusive end of this observation window in Unix seconds.
7866
+ */
7867
+ timestamp: number;
7868
+ /**
7869
+ * Observed main-container CPU in millicores.
7870
+ */
7871
+ cpuMillicores?: number;
7872
+ /**
7873
+ * CPU as a percentage of the admitted CPU allocation.
7874
+ */
7875
+ cpuPercent?: number;
7876
+ /**
7877
+ * Main-container working set in MiB.
7878
+ */
7879
+ memoryMiB?: number;
7880
+ /**
7881
+ * Working set as a percentage of the admitted memory allocation.
7882
+ */
7883
+ memoryPercent?: number;
7884
+ /**
7885
+ * Sampled HTTP requests or SQL executions in progress.
7886
+ */
7887
+ inFlight?: number;
7888
+ /**
7889
+ * Observed completions between sampled histogram counters.
7890
+ */
7891
+ completedRequests?: number;
7892
+ latencyAvgMs?: number;
7893
+ latencyP50Ms?: number;
7894
+ latencyP95Ms?: number;
7895
+ };
7896
+ type FunctionInstanceMetrics = {
7897
+ instanceId: string;
7898
+ points: Array<RuntimeMetricPoint>;
7899
+ };
7900
+ type AppMetrics = {
7901
+ from: number;
7902
+ to: number;
7903
+ /**
7904
+ * Window length in seconds selected by the server for the queried range and runtime activations. The last window may be shorter.
7905
+ */
7906
+ stepSeconds: number;
7907
+ instances: Array<FunctionInstanceMetrics>;
7908
+ };
7863
7909
  type AppSettings = {
7864
7910
  enabled?: boolean;
7865
7911
  runtime?: "nodejs";
@@ -8061,6 +8107,15 @@ type DatabaseInput = {
8061
8107
  type DatabaseMaintenance = {
8062
8108
  maintenanceStartedAt: string | null;
8063
8109
  };
8110
+ type DatabaseMetrics = {
8111
+ from: number;
8112
+ to: number;
8113
+ /**
8114
+ * Window length in seconds selected by the server for the queried range and runtime activations. The last window may be shorter.
8115
+ */
8116
+ stepSeconds: number;
8117
+ points: Array<RuntimeMetricPoint>;
8118
+ };
8064
8119
  type DatabaseRollback = {
8065
8120
  id: string;
8066
8121
  databaseId: string;
@@ -8416,6 +8471,22 @@ declare class DefaultService$2 {
8416
8471
  deleteApp({ id, }: {
8417
8472
  id: string;
8418
8473
  }): CancelablePromise<any>;
8474
+ /**
8475
+ * Read aligned runtime metrics for the instances of one function, including retired instances
8476
+ * @returns AppMetrics Observed runtime metrics. Missing observations and latency without completed requests are omitted.
8477
+ * @throws ApiError
8478
+ */
8479
+ getAppMetrics({ id, from, to, }: {
8480
+ id: string;
8481
+ /**
8482
+ * Start of the first observation window, in Unix seconds.
8483
+ */
8484
+ from: number;
8485
+ /**
8486
+ * Inclusive end in Unix seconds. Each query may cover up to 24 hours and must end no later than the current time.
8487
+ */
8488
+ to: number;
8489
+ }): CancelablePromise<AppMetrics>;
8419
8490
  /**
8420
8491
  * Keep an active function instance running while it processes background work
8421
8492
  * @returns void
@@ -8548,6 +8619,22 @@ declare class DefaultService$2 {
8548
8619
  deleteDatabase({ id, }: {
8549
8620
  id: string;
8550
8621
  }): CancelablePromise<any>;
8622
+ /**
8623
+ * Read the compute metrics of one SQLite database over time
8624
+ * @returns DatabaseMetrics Observed runtime metrics. Missing observations and latency without completed requests are omitted.
8625
+ * @throws ApiError
8626
+ */
8627
+ getDatabaseMetrics({ id, from, to, }: {
8628
+ id: string;
8629
+ /**
8630
+ * Start of the first observation window, in Unix seconds.
8631
+ */
8632
+ from: number;
8633
+ /**
8634
+ * Inclusive end in Unix seconds. Each query may cover up to 24 hours and must end no later than the current time.
8635
+ */
8636
+ to: number;
8637
+ }): CancelablePromise<DatabaseMetrics>;
8551
8638
  /**
8552
8639
  * @returns TransactionalEventQueue Recent committed events and the shared organization delivery limit
8553
8640
  * @throws ApiError
package/browser.js CHANGED
@@ -8290,6 +8290,37 @@ var DefaultService3 = class {
8290
8290
  }
8291
8291
  });
8292
8292
  }
8293
+ /**
8294
+ * Read aligned runtime metrics for the instances of one function, including retired instances
8295
+ * @returns AppMetrics Observed runtime metrics. Missing observations and latency without completed requests are omitted.
8296
+ * @throws ApiError
8297
+ */
8298
+ getAppMetrics({
8299
+ id,
8300
+ from,
8301
+ to
8302
+ }) {
8303
+ return this.httpRequest.request({
8304
+ method: "GET",
8305
+ url: "/apps/{id}/metrics",
8306
+ path: {
8307
+ "id": id
8308
+ },
8309
+ query: {
8310
+ "from": from,
8311
+ "to": to
8312
+ },
8313
+ errors: {
8314
+ 400: `Invalid time range`,
8315
+ 401: `Unauthorized`,
8316
+ 403: `Permission denied`,
8317
+ 404: `Resource not found in this organization`,
8318
+ 422: `Query exceeds the instance or sample budget. Narrow the time range.`,
8319
+ 502: `Metrics provider query failed`,
8320
+ 503: `Metrics provider unavailable`
8321
+ }
8322
+ });
8323
+ }
8293
8324
  /**
8294
8325
  * Keep an active function instance running while it processes background work
8295
8326
  * @returns void
@@ -8609,6 +8640,37 @@ var DefaultService3 = class {
8609
8640
  }
8610
8641
  });
8611
8642
  }
8643
+ /**
8644
+ * Read the compute metrics of one SQLite database over time
8645
+ * @returns DatabaseMetrics Observed runtime metrics. Missing observations and latency without completed requests are omitted.
8646
+ * @throws ApiError
8647
+ */
8648
+ getDatabaseMetrics({
8649
+ id,
8650
+ from,
8651
+ to
8652
+ }) {
8653
+ return this.httpRequest.request({
8654
+ method: "GET",
8655
+ url: "/databases/{id}/metrics",
8656
+ path: {
8657
+ "id": id
8658
+ },
8659
+ query: {
8660
+ "from": from,
8661
+ "to": to
8662
+ },
8663
+ errors: {
8664
+ 400: `Invalid time range`,
8665
+ 401: `Unauthorized`,
8666
+ 403: `Permission denied`,
8667
+ 404: `Resource not found in this organization`,
8668
+ 422: `Query exceeds the instance or sample budget. Narrow the time range.`,
8669
+ 502: `Metrics provider query failed`,
8670
+ 503: `Metrics provider unavailable`
8671
+ }
8672
+ });
8673
+ }
8612
8674
  /**
8613
8675
  * @returns TransactionalEventQueue Recent committed events and the shared organization delivery limit
8614
8676
  * @throws ApiError
@@ -12550,6 +12612,20 @@ var operations = {
12550
12612
  "503": "void"
12551
12613
  }
12552
12614
  },
12615
+ "GET /apps/{id}/metrics": {
12616
+ "authenticated": true,
12617
+ "redirect": false,
12618
+ "responses": {
12619
+ "200": "json",
12620
+ "400": "void",
12621
+ "401": "void",
12622
+ "403": "void",
12623
+ "404": "void",
12624
+ "422": "void",
12625
+ "502": "void",
12626
+ "503": "void"
12627
+ }
12628
+ },
12553
12629
  "POST /apps/{id}/instances/{instanceId}/activity": {
12554
12630
  "authenticated": true,
12555
12631
  "redirect": false,
@@ -12698,6 +12774,20 @@ var operations = {
12698
12774
  "503": "void"
12699
12775
  }
12700
12776
  },
12777
+ "GET /databases/{id}/metrics": {
12778
+ "authenticated": true,
12779
+ "redirect": false,
12780
+ "responses": {
12781
+ "200": "json",
12782
+ "400": "void",
12783
+ "401": "void",
12784
+ "403": "void",
12785
+ "404": "void",
12786
+ "422": "void",
12787
+ "502": "void",
12788
+ "503": "void"
12789
+ }
12790
+ },
12701
12791
  "GET /databases/{id}/event-queue": {
12702
12792
  "authenticated": true,
12703
12793
  "redirect": false,
package/index.d.ts CHANGED
@@ -3540,7 +3540,7 @@ export type SSOTokens = {
3540
3540
  expiresAt: string;
3541
3541
  grantId?: string;
3542
3542
  /**
3543
- * Only present in identity mode. JWT with sub=string(account_id), account_id, org_id, user_id, iss, aud=app ID, iat, exp and token_use=sso_identity. Never accepted as a brazosd API credential.
3543
+ * Only present in identity mode. JWT with sub=string(account_id), account_id, org_id, user_id, is_org_owner, iss, aud=app ID, iat, exp and token_use=sso_identity. The boolean is_org_owner records whether the user owned the selected organization at issuance. Never accepted as a brazosd API credential.
3544
3544
  */
3545
3545
  identityToken?: string;
3546
3546
  mode: SSOMode;
@@ -7862,6 +7862,52 @@ type AppLogPage = {
7862
7862
  */
7863
7863
  retryAfterSeconds?: number;
7864
7864
  };
7865
+ type RuntimeMetricPoint = {
7866
+ /**
7867
+ * Inclusive end of this observation window in Unix seconds.
7868
+ */
7869
+ timestamp: number;
7870
+ /**
7871
+ * Observed main-container CPU in millicores.
7872
+ */
7873
+ cpuMillicores?: number;
7874
+ /**
7875
+ * CPU as a percentage of the admitted CPU allocation.
7876
+ */
7877
+ cpuPercent?: number;
7878
+ /**
7879
+ * Main-container working set in MiB.
7880
+ */
7881
+ memoryMiB?: number;
7882
+ /**
7883
+ * Working set as a percentage of the admitted memory allocation.
7884
+ */
7885
+ memoryPercent?: number;
7886
+ /**
7887
+ * Sampled HTTP requests or SQL executions in progress.
7888
+ */
7889
+ inFlight?: number;
7890
+ /**
7891
+ * Observed completions between sampled histogram counters.
7892
+ */
7893
+ completedRequests?: number;
7894
+ latencyAvgMs?: number;
7895
+ latencyP50Ms?: number;
7896
+ latencyP95Ms?: number;
7897
+ };
7898
+ type FunctionInstanceMetrics = {
7899
+ instanceId: string;
7900
+ points: Array<RuntimeMetricPoint>;
7901
+ };
7902
+ type AppMetrics = {
7903
+ from: number;
7904
+ to: number;
7905
+ /**
7906
+ * Window length in seconds selected by the server for the queried range and runtime activations. The last window may be shorter.
7907
+ */
7908
+ stepSeconds: number;
7909
+ instances: Array<FunctionInstanceMetrics>;
7910
+ };
7865
7911
  type AppSettings = {
7866
7912
  enabled?: boolean;
7867
7913
  runtime?: "nodejs";
@@ -8063,6 +8109,15 @@ type DatabaseInput = {
8063
8109
  type DatabaseMaintenance = {
8064
8110
  maintenanceStartedAt: string | null;
8065
8111
  };
8112
+ type DatabaseMetrics = {
8113
+ from: number;
8114
+ to: number;
8115
+ /**
8116
+ * Window length in seconds selected by the server for the queried range and runtime activations. The last window may be shorter.
8117
+ */
8118
+ stepSeconds: number;
8119
+ points: Array<RuntimeMetricPoint>;
8120
+ };
8066
8121
  type DatabaseRollback = {
8067
8122
  id: string;
8068
8123
  databaseId: string;
@@ -8418,6 +8473,22 @@ declare class DefaultService$2 {
8418
8473
  deleteApp({ id, }: {
8419
8474
  id: string;
8420
8475
  }): CancelablePromise<any>;
8476
+ /**
8477
+ * Read aligned runtime metrics for the instances of one function, including retired instances
8478
+ * @returns AppMetrics Observed runtime metrics. Missing observations and latency without completed requests are omitted.
8479
+ * @throws ApiError
8480
+ */
8481
+ getAppMetrics({ id, from, to, }: {
8482
+ id: string;
8483
+ /**
8484
+ * Start of the first observation window, in Unix seconds.
8485
+ */
8486
+ from: number;
8487
+ /**
8488
+ * Inclusive end in Unix seconds. Each query may cover up to 24 hours and must end no later than the current time.
8489
+ */
8490
+ to: number;
8491
+ }): CancelablePromise<AppMetrics>;
8421
8492
  /**
8422
8493
  * Keep an active function instance running while it processes background work
8423
8494
  * @returns void
@@ -8550,6 +8621,22 @@ declare class DefaultService$2 {
8550
8621
  deleteDatabase({ id, }: {
8551
8622
  id: string;
8552
8623
  }): CancelablePromise<any>;
8624
+ /**
8625
+ * Read the compute metrics of one SQLite database over time
8626
+ * @returns DatabaseMetrics Observed runtime metrics. Missing observations and latency without completed requests are omitted.
8627
+ * @throws ApiError
8628
+ */
8629
+ getDatabaseMetrics({ id, from, to, }: {
8630
+ id: string;
8631
+ /**
8632
+ * Start of the first observation window, in Unix seconds.
8633
+ */
8634
+ from: number;
8635
+ /**
8636
+ * Inclusive end in Unix seconds. Each query may cover up to 24 hours and must end no later than the current time.
8637
+ */
8638
+ to: number;
8639
+ }): CancelablePromise<DatabaseMetrics>;
8553
8640
  /**
8554
8641
  * @returns TransactionalEventQueue Recent committed events and the shared organization delivery limit
8555
8642
  * @throws ApiError
@@ -8855,6 +8942,8 @@ export interface SSOIdentity {
8855
8942
  account_id: number;
8856
8943
  org_id: number;
8857
8944
  user_id: number;
8945
+ /** Ownership of the selected organization at issuance. Older tokens omit this claim. */
8946
+ is_org_owner?: boolean;
8858
8947
  iat: number;
8859
8948
  exp: number;
8860
8949
  token_use: "sso_identity";
package/index.js CHANGED
@@ -8290,6 +8290,37 @@ var DefaultService3 = class {
8290
8290
  }
8291
8291
  });
8292
8292
  }
8293
+ /**
8294
+ * Read aligned runtime metrics for the instances of one function, including retired instances
8295
+ * @returns AppMetrics Observed runtime metrics. Missing observations and latency without completed requests are omitted.
8296
+ * @throws ApiError
8297
+ */
8298
+ getAppMetrics({
8299
+ id,
8300
+ from,
8301
+ to
8302
+ }) {
8303
+ return this.httpRequest.request({
8304
+ method: "GET",
8305
+ url: "/apps/{id}/metrics",
8306
+ path: {
8307
+ "id": id
8308
+ },
8309
+ query: {
8310
+ "from": from,
8311
+ "to": to
8312
+ },
8313
+ errors: {
8314
+ 400: `Invalid time range`,
8315
+ 401: `Unauthorized`,
8316
+ 403: `Permission denied`,
8317
+ 404: `Resource not found in this organization`,
8318
+ 422: `Query exceeds the instance or sample budget. Narrow the time range.`,
8319
+ 502: `Metrics provider query failed`,
8320
+ 503: `Metrics provider unavailable`
8321
+ }
8322
+ });
8323
+ }
8293
8324
  /**
8294
8325
  * Keep an active function instance running while it processes background work
8295
8326
  * @returns void
@@ -8609,6 +8640,37 @@ var DefaultService3 = class {
8609
8640
  }
8610
8641
  });
8611
8642
  }
8643
+ /**
8644
+ * Read the compute metrics of one SQLite database over time
8645
+ * @returns DatabaseMetrics Observed runtime metrics. Missing observations and latency without completed requests are omitted.
8646
+ * @throws ApiError
8647
+ */
8648
+ getDatabaseMetrics({
8649
+ id,
8650
+ from,
8651
+ to
8652
+ }) {
8653
+ return this.httpRequest.request({
8654
+ method: "GET",
8655
+ url: "/databases/{id}/metrics",
8656
+ path: {
8657
+ "id": id
8658
+ },
8659
+ query: {
8660
+ "from": from,
8661
+ "to": to
8662
+ },
8663
+ errors: {
8664
+ 400: `Invalid time range`,
8665
+ 401: `Unauthorized`,
8666
+ 403: `Permission denied`,
8667
+ 404: `Resource not found in this organization`,
8668
+ 422: `Query exceeds the instance or sample budget. Narrow the time range.`,
8669
+ 502: `Metrics provider query failed`,
8670
+ 503: `Metrics provider unavailable`
8671
+ }
8672
+ });
8673
+ }
8612
8674
  /**
8613
8675
  * @returns TransactionalEventQueue Recent committed events and the shared organization delivery limit
8614
8676
  * @throws ApiError
@@ -12550,6 +12612,20 @@ var operations = {
12550
12612
  "503": "void"
12551
12613
  }
12552
12614
  },
12615
+ "GET /apps/{id}/metrics": {
12616
+ "authenticated": true,
12617
+ "redirect": false,
12618
+ "responses": {
12619
+ "200": "json",
12620
+ "400": "void",
12621
+ "401": "void",
12622
+ "403": "void",
12623
+ "404": "void",
12624
+ "422": "void",
12625
+ "502": "void",
12626
+ "503": "void"
12627
+ }
12628
+ },
12553
12629
  "POST /apps/{id}/instances/{instanceId}/activity": {
12554
12630
  "authenticated": true,
12555
12631
  "redirect": false,
@@ -12698,6 +12774,20 @@ var operations = {
12698
12774
  "503": "void"
12699
12775
  }
12700
12776
  },
12777
+ "GET /databases/{id}/metrics": {
12778
+ "authenticated": true,
12779
+ "redirect": false,
12780
+ "responses": {
12781
+ "200": "json",
12782
+ "400": "void",
12783
+ "401": "void",
12784
+ "403": "void",
12785
+ "404": "void",
12786
+ "422": "void",
12787
+ "502": "void",
12788
+ "503": "void"
12789
+ }
12790
+ },
12701
12791
  "GET /databases/{id}/event-queue": {
12702
12792
  "authenticated": true,
12703
12793
  "redirect": false,
@@ -13635,6 +13725,7 @@ var SSOIdentityVerifier = class {
13635
13725
  if (claims.iss !== this.options.issuer || claims.aud !== this.options.audience || claims.token_use !== "sso_identity") throw new Error("SSO JWT issuer, audience or purpose mismatch");
13636
13726
  const now = Math.floor(Date.now() / 1e3);
13637
13727
  if (![claims.account_id, claims.org_id, claims.user_id].every((id) => typeof id === "number" && Number.isSafeInteger(id) && id > 0) || claims.sub !== String(claims.account_id)) throw new Error("Invalid SSO identity");
13728
+ if (claims.is_org_owner !== void 0 && typeof claims.is_org_owner !== "boolean") throw new Error("Invalid SSO is_org_owner claim");
13638
13729
  if (typeof claims.exp !== "number" || typeof claims.iat !== "number" || !Number.isSafeInteger(claims.exp) || !Number.isSafeInteger(claims.iat) || claims.exp <= now || claims.iat > now + 30 || claims.exp <= claims.iat || claims.exp - claims.iat > 300 || claims.nbf !== void 0 && (typeof claims.nbf !== "number" || !Number.isSafeInteger(claims.nbf) || claims.nbf > now + 30)) throw new Error("SSO JWT expired or has invalid timestamps");
13639
13730
  let set = await this.keys();
13640
13731
  let key = set.keys.find((item) => item.kid === header.kid);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brazosd/node",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Brazosd Node.js SDK with automatic cloud function identity",
5
5
  "repository": {
6
6
  "type": "git",