@stackframe/stack-shared 2.7.1 → 2.7.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Various changes
8
+ - @stackframe/stack-sc@2.7.3
9
+
10
+ ## 2.7.2
11
+
12
+ ### Patch Changes
13
+
14
+ - Various changes
15
+ - @stackframe/stack-sc@2.7.2
16
+
3
17
  ## 2.7.1
4
18
 
5
19
  ### Patch Changes
@@ -268,9 +268,11 @@ export class StackClientInterface {
268
268
  // Rate limited, so retry if we can
269
269
  const retryAfter = res.headers.get("Retry-After");
270
270
  if (retryAfter !== null) {
271
+ console.log(`Rate limited while sending request to ${url}. Will retry after ${retryAfter} seconds...`);
271
272
  await wait(Number(retryAfter) * 1000);
272
273
  return Result.error(new Error(`Rate limited, retrying after ${retryAfter} seconds`));
273
274
  }
275
+ console.log(`Rate limited while sending request to ${url}, no retry-after header received. Retrying...`);
274
276
  return Result.error(new Error("Rate limited, no retry-after header received"));
275
277
  }
276
278
  else {
@@ -121,17 +121,17 @@ export const projectsCrud = createCrud({
121
121
  docs: {
122
122
  clientRead: {
123
123
  summary: 'Get the current project',
124
- description: 'Get the current project information including display name, oauth providers and authentication methods. Useful for display the available login options to the user.',
124
+ description: 'Get the current project information including display name, OAuth providers and authentication methods. Useful for display the available login options to the user.',
125
125
  tags: ['Projects'],
126
126
  },
127
127
  adminRead: {
128
128
  summary: 'Get the current project',
129
- description: 'Get the current project information and configuration including display name, oauth providers, email configuration, etc.',
129
+ description: 'Get the current project information and configuration including display name, OAuth providers, email configuration, etc.',
130
130
  tags: ['Projects'],
131
131
  },
132
132
  adminUpdate: {
133
133
  summary: 'Update the current project',
134
- description: 'Update the current project information and configuration including display name, oauth providers, email configuration, etc.',
134
+ description: 'Update the current project information and configuration including display name, OAuth providers, email configuration, etc.',
135
135
  tags: ['Projects'],
136
136
  },
137
137
  adminDelete: {
@@ -1,5 +1,6 @@
1
1
  import { globalVar } from "./globals";
2
2
  import { pick } from "./objects";
3
+ import { nicify } from "./strings";
3
4
  export function throwErr(...args) {
4
5
  if (typeof args[0] === "string") {
5
6
  throw new StackAssertionError(args[0], args[1]);
@@ -67,11 +68,11 @@ StackAssertionError.prototype.name = "StackAssertionError";
67
68
  export function errorToNiceString(error) {
68
69
  if (!(error instanceof Error))
69
70
  return `${typeof error}<${error}>`;
70
- const stack = error.stack ?? "";
71
+ let stack = error.stack ?? "";
71
72
  const toString = error.toString();
72
- if (stack.startsWith(toString))
73
- return stack;
74
- return `${toString}\n${stack}`;
73
+ if (!stack.startsWith(toString))
74
+ stack = `${toString}\n${stack}`; // some browsers don't include the error message in the stack, some do
75
+ return `${stack} ${nicify(Object.fromEntries(Object.entries(error)), { maxDepth: 8 })}`;
75
76
  }
76
77
  const errorSinks = new Set();
77
78
  export function registerErrorSink(sink) {
@@ -1,3 +1,4 @@
1
+ export declare function isNotNull<T>(value: T): value is NonNullable<T>;
1
2
  export type DeepPartial<T> = T extends object ? {
2
3
  [P in keyof T]?: DeepPartial<T[P]>;
3
4
  } : T;
@@ -1,4 +1,7 @@
1
1
  import { StackAssertionError } from "./errors";
2
+ export function isNotNull(value) {
3
+ return value !== null && value !== undefined;
4
+ }
2
5
  /**
3
6
  * Assumes both objects are primitives, arrays, or non-function plain objects, and compares them deeply.
4
7
  *
@@ -1,6 +1,10 @@
1
1
  export declare function typedToLowercase<S extends string>(s: S): Lowercase<S>;
2
2
  export declare function typedToUppercase<S extends string>(s: S): Uppercase<S>;
3
3
  export declare function typedCapitalize<S extends string>(s: S): Capitalize<S>;
4
+ /**
5
+ * Compares two strings in a way that is not dependent on the current locale.
6
+ */
7
+ export declare function stringCompare(a: string, b: string): number;
4
8
  /**
5
9
  * Returns all whitespace character at the start of the string.
6
10
  *
@@ -10,6 +10,13 @@ export function typedToUppercase(s) {
10
10
  export function typedCapitalize(s) {
11
11
  return s.charAt(0).toUpperCase() + s.slice(1);
12
12
  }
13
+ /**
14
+ * Compares two strings in a way that is not dependent on the current locale.
15
+ */
16
+ export function stringCompare(a, b) {
17
+ const cmp = (a, b) => a < b ? -1 : a > b ? 1 : 0;
18
+ return cmp(a.toUpperCase(), b.toUpperCase()) || cmp(b, a);
19
+ }
13
20
  /**
14
21
  * Returns all whitespace character at the start of the string.
15
22
  *
@@ -269,7 +276,7 @@ function getNicifiableEntries(value) {
269
276
  return recordLikes.some(x => value instanceof x);
270
277
  }
271
278
  if (isRecordLike(value)) {
272
- return [...value.entries()].sort(([a], [b]) => String(a).localeCompare(String(b)));
279
+ return [...value.entries()].sort(([a], [b]) => stringCompare(`${a}`, `${b}`));
273
280
  }
274
281
  const keys = getNicifiableKeys(value);
275
282
  return keys.map((k) => [k, value[k]]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackframe/stack-shared",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -51,7 +51,7 @@
51
51
  "oauth4webapi": "^2.10.3",
52
52
  "semver": "^7.6.3",
53
53
  "uuid": "^9.0.1",
54
- "@stackframe/stack-sc": "2.7.1"
54
+ "@stackframe/stack-sc": "2.7.3"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@sentry/nextjs": "^8.40.0",