@stackframe/stack-shared 2.7.3 → 2.7.6
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 +21 -0
- package/dist/schema-fields.js +1 -1
- package/dist/utils/caches.d.ts +1 -0
- package/dist/utils/caches.js +11 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @stackframe/stack-shared
|
|
2
2
|
|
|
3
|
+
## 2.7.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed bugs, updated Neon requirements
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @stackframe/stack-sc@2.7.6
|
|
10
|
+
|
|
11
|
+
## 2.7.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Various changes
|
|
16
|
+
- @stackframe/stack-sc@2.7.5
|
|
17
|
+
|
|
18
|
+
## 2.7.4
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- @stackframe/stack-sc@2.7.4
|
|
23
|
+
|
|
3
24
|
## 2.7.3
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/schema-fields.js
CHANGED
|
@@ -243,7 +243,7 @@ export const emailUsernameSchema = yupString().meta({ openapiField: { descriptio
|
|
|
243
243
|
export const emailSenderEmailSchema = emailSchema.meta({ openapiField: { description: 'Email sender email. Needs to be specified when using type="standard"', exampleValue: 'example@your-domain.com' } });
|
|
244
244
|
export const emailPasswordSchema = passwordSchema.meta({ openapiField: { description: 'Email password. Needs to be specified when using type="standard"', exampleValue: 'your-email-password' } });
|
|
245
245
|
// Project domain config
|
|
246
|
-
export const projectTrustedDomainSchema =
|
|
246
|
+
export const projectTrustedDomainSchema = urlSchema.test('is-https', 'Trusted domain must start with https://', (value) => value?.startsWith('https://')).meta({ openapiField: { description: 'Your domain URL. Make sure you own and trust this domain. Needs to start with https://', exampleValue: 'https://example.com' } });
|
|
247
247
|
export const handlerPathSchema = yupString().test('is-handler-path', 'Handler path must start with /', (value) => value?.startsWith('/')).meta({ openapiField: { description: 'Handler path. If you did not setup a custom handler path, it should be "/handler" by default. It needs to start with /', exampleValue: '/handler' } });
|
|
248
248
|
// Users
|
|
249
249
|
export class ReplaceFieldWithOwnUserId extends Error {
|
package/dist/utils/caches.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ declare class AsyncValueCache<T> {
|
|
|
50
50
|
private readonly _rateLimitOptions;
|
|
51
51
|
private _subscriptionsCount;
|
|
52
52
|
private _unsubscribers;
|
|
53
|
+
private _mostRecentRefreshPromiseIndex;
|
|
53
54
|
constructor(fetcher: () => Promise<T>, _options?: {
|
|
54
55
|
onSubscribe?: (refresh: () => void) => (() => void);
|
|
55
56
|
rateLimiter?: Omit<RateLimitOptions, "batchCalls">;
|
package/dist/utils/caches.js
CHANGED
|
@@ -63,6 +63,7 @@ class AsyncValueCache {
|
|
|
63
63
|
this._options = _options;
|
|
64
64
|
this._subscriptionsCount = 0;
|
|
65
65
|
this._unsubscribers = [];
|
|
66
|
+
this._mostRecentRefreshPromiseIndex = 0;
|
|
66
67
|
this._store = new AsyncStore();
|
|
67
68
|
this._rateLimitOptions = {
|
|
68
69
|
concurrency: 1,
|
|
@@ -132,17 +133,8 @@ class AsyncValueCache {
|
|
|
132
133
|
const storeObj = this._store.onChange(callback);
|
|
133
134
|
runAsynchronously(this.getOrWait("read-write"));
|
|
134
135
|
if (this._subscriptionsCount++ === 0 && this._options.onSubscribe) {
|
|
135
|
-
let mostRecentRefreshPromiseIndex = 0;
|
|
136
136
|
const unsubscribe = this._options.onSubscribe(() => {
|
|
137
|
-
|
|
138
|
-
runAsynchronously(async () => {
|
|
139
|
-
// wait a few seconds; if anything changes during that time, we don't want to refresh
|
|
140
|
-
// else we do unnecessary requests if we unsubscribe and then subscribe again immediately
|
|
141
|
-
await wait(5000);
|
|
142
|
-
if (this._subscriptionsCount === 0 && currentRefreshPromiseIndex === mostRecentRefreshPromiseIndex) {
|
|
143
|
-
this.invalidate();
|
|
144
|
-
}
|
|
145
|
-
});
|
|
137
|
+
runAsynchronously(this.refresh());
|
|
146
138
|
});
|
|
147
139
|
this._unsubscribers.push(unsubscribe);
|
|
148
140
|
}
|
|
@@ -154,6 +146,15 @@ class AsyncValueCache {
|
|
|
154
146
|
hasUnsubscribed = true;
|
|
155
147
|
storeObj.unsubscribe();
|
|
156
148
|
if (--this._subscriptionsCount === 0) {
|
|
149
|
+
const currentRefreshPromiseIndex = ++this._mostRecentRefreshPromiseIndex;
|
|
150
|
+
runAsynchronously(async () => {
|
|
151
|
+
// wait a few seconds; if anything changes during that time, we don't want to refresh
|
|
152
|
+
// else we do unnecessary requests if we unsubscribe and then subscribe again immediately
|
|
153
|
+
await wait(5000);
|
|
154
|
+
if (this._subscriptionsCount === 0 && currentRefreshPromiseIndex === this._mostRecentRefreshPromiseIndex) {
|
|
155
|
+
this.invalidate();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
157
158
|
for (const unsubscribe of this._unsubscribers) {
|
|
158
159
|
unsubscribe();
|
|
159
160
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackframe/stack-shared",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.6",
|
|
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.
|
|
54
|
+
"@stackframe/stack-sc": "2.7.6"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@sentry/nextjs": "^8.40.0",
|