@stackframe/stack 2.6.25 → 2.6.26
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 +10 -0
- package/dist/esm/lib/stack-app.js +41 -33
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/generated/quetzal-translations.d.mts +2 -2
- package/dist/generated/quetzal-translations.d.ts +2 -2
- package/dist/lib/stack-app.js +40 -32
- package/dist/lib/stack-app.js.map +1 -1
- package/package.json +4 -4
package/dist/lib/stack-app.js
CHANGED
|
@@ -64,7 +64,7 @@ var import_url = require("../utils/url");
|
|
|
64
64
|
var import_auth = require("./auth");
|
|
65
65
|
var import_cookie = require("./cookie");
|
|
66
66
|
var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
|
|
67
|
-
var clientVersion = "js @stackframe/stack@2.6.
|
|
67
|
+
var clientVersion = "js @stackframe/stack@2.6.26";
|
|
68
68
|
function getUrls(partial) {
|
|
69
69
|
const handler = partial.handler ?? "/handler";
|
|
70
70
|
const home = partial.home ?? "/";
|
|
@@ -145,19 +145,27 @@ function useAsyncCache(cache, dependencies, caller) {
|
|
|
145
145
|
getSnapshot,
|
|
146
146
|
() => (0, import_errors.throwErr)(new Error("getServerSnapshot should never be called in useAsyncCache because we restrict to CSR earlier"))
|
|
147
147
|
);
|
|
148
|
-
|
|
148
|
+
const result = import_react2.default.use(promise);
|
|
149
|
+
if (result.status === "error") {
|
|
150
|
+
const error = result.error;
|
|
151
|
+
if (error instanceof Error) {
|
|
152
|
+
(0, import_errors.concatStacktraces)(error, new Error());
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
return result.data;
|
|
149
157
|
}
|
|
150
158
|
var stackAppInternalsSymbol = Symbol.for("StackAppInternals");
|
|
151
159
|
var allClientApps = /* @__PURE__ */ new Map();
|
|
152
160
|
var createCache = (fetcher) => {
|
|
153
161
|
return new import_caches.AsyncCache(
|
|
154
|
-
async (dependencies) => await fetcher(dependencies),
|
|
162
|
+
async (dependencies) => await import_results.Result.fromThrowingAsync(async () => await fetcher(dependencies)),
|
|
155
163
|
{}
|
|
156
164
|
);
|
|
157
165
|
};
|
|
158
166
|
var createCacheBySession = (fetcher) => {
|
|
159
167
|
return new import_caches.AsyncCache(
|
|
160
|
-
async ([session, ...extraDependencies]) => await fetcher(session, extraDependencies),
|
|
168
|
+
async ([session, ...extraDependencies]) => await import_results.Result.fromThrowingAsync(async () => await fetcher(session, extraDependencies)),
|
|
161
169
|
{
|
|
162
170
|
onSubscribe: ([session], refresh) => {
|
|
163
171
|
const handler = session.onInvalidate(() => refresh());
|
|
@@ -207,8 +215,8 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
207
215
|
this._currentUserOAuthConnectionCache = createCacheBySession(
|
|
208
216
|
async (session, [providerId, scope, redirect]) => {
|
|
209
217
|
return await this._getUserOAuthConnectionCacheFn({
|
|
210
|
-
getUser: async () => await this._currentUserCache.getOrWait([session], "write-only"),
|
|
211
|
-
getOrWaitOAuthToken: async () => await this._currentUserOAuthConnectionAccessTokensCache.getOrWait([session, providerId, scope || ""], "write-only"),
|
|
218
|
+
getUser: async () => import_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only")),
|
|
219
|
+
getOrWaitOAuthToken: async () => import_results.Result.orThrow(await this._currentUserOAuthConnectionAccessTokensCache.getOrWait([session, providerId, scope || ""], "write-only")),
|
|
212
220
|
useOAuthToken: () => useAsyncCache(this._currentUserOAuthConnectionAccessTokensCache, [session, providerId, scope || ""], "useOAuthToken"),
|
|
213
221
|
providerId,
|
|
214
222
|
scope,
|
|
@@ -593,7 +601,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
593
601
|
});
|
|
594
602
|
},
|
|
595
603
|
async listUsers() {
|
|
596
|
-
const result = await app._teamMemberProfilesCache.getOrWait([session, crud.id], "write-only");
|
|
604
|
+
const result = import_results.Result.orThrow(await app._teamMemberProfilesCache.getOrWait([session, crud.id], "write-only"));
|
|
597
605
|
return result.map((crud2) => app._clientTeamUserFromCrud(crud2));
|
|
598
606
|
},
|
|
599
607
|
useUsers() {
|
|
@@ -723,7 +731,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
723
731
|
const app = this;
|
|
724
732
|
async function getConnectedAccount(id, options) {
|
|
725
733
|
const scopeString = options?.scopes?.join(" ");
|
|
726
|
-
return await app._currentUserOAuthConnectionCache.getOrWait([session, id, scopeString || "", options?.or === "redirect"], "write-only");
|
|
734
|
+
return import_results.Result.orThrow(await app._currentUserOAuthConnectionCache.getOrWait([session, id, scopeString || "", options?.or === "redirect"], "write-only"));
|
|
727
735
|
}
|
|
728
736
|
function useConnectedAccount(id, options) {
|
|
729
737
|
const scopeString = options?.scopes?.join(" ");
|
|
@@ -752,7 +760,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
752
760
|
}, [teams, teamId]);
|
|
753
761
|
},
|
|
754
762
|
async listTeams() {
|
|
755
|
-
const teams = await app._currentUserTeamsCache.getOrWait([session], "write-only");
|
|
763
|
+
const teams = import_results.Result.orThrow(await app._currentUserTeamsCache.getOrWait([session], "write-only"));
|
|
756
764
|
return teams.map((crud2) => app._clientTeamFromCrud(crud2, session));
|
|
757
765
|
},
|
|
758
766
|
useTeams() {
|
|
@@ -772,7 +780,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
772
780
|
},
|
|
773
781
|
async listPermissions(scope, options) {
|
|
774
782
|
const recursive = options?.recursive ?? true;
|
|
775
|
-
const permissions = await app._currentUserPermissionsCache.getOrWait([session, scope.id, recursive], "write-only");
|
|
783
|
+
const permissions = import_results.Result.orThrow(await app._currentUserPermissionsCache.getOrWait([session, scope.id, recursive], "write-only"));
|
|
776
784
|
return permissions.map((crud2) => app._clientTeamPermissionFromCrud(crud2));
|
|
777
785
|
},
|
|
778
786
|
usePermissions(scope, options) {
|
|
@@ -812,7 +820,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
812
820
|
},
|
|
813
821
|
selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team, session),
|
|
814
822
|
async getTeamProfile(team) {
|
|
815
|
-
const result = await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only");
|
|
823
|
+
const result = import_results.Result.orThrow(await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only"));
|
|
816
824
|
return app._editableTeamProfileFromCrud(result, session);
|
|
817
825
|
},
|
|
818
826
|
useTeamProfile(team) {
|
|
@@ -824,7 +832,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
824
832
|
session.markInvalid();
|
|
825
833
|
},
|
|
826
834
|
async listContactChannels() {
|
|
827
|
-
const result = await app._clientContactChannelsCache.getOrWait([session], "write-only");
|
|
835
|
+
const result = import_results.Result.orThrow(await app._clientContactChannelsCache.getOrWait([session], "write-only"));
|
|
828
836
|
return result.map((crud2) => app._clientContactChannelFromCrud(crud2, session));
|
|
829
837
|
},
|
|
830
838
|
useContactChannels() {
|
|
@@ -1025,7 +1033,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1025
1033
|
async getUser(options) {
|
|
1026
1034
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1027
1035
|
const session = await this._getSession(options?.tokenStore);
|
|
1028
|
-
const crud = await this._currentUserCache.getOrWait([session], "write-only");
|
|
1036
|
+
const crud = import_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
1029
1037
|
if (crud === null) {
|
|
1030
1038
|
switch (options?.or) {
|
|
1031
1039
|
case "redirect": {
|
|
@@ -1257,7 +1265,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1257
1265
|
}
|
|
1258
1266
|
}
|
|
1259
1267
|
async getProject() {
|
|
1260
|
-
const crud = await this._currentProjectCache.getOrWait([], "write-only");
|
|
1268
|
+
const crud = import_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
1261
1269
|
return this._clientProjectFromCrud(crud);
|
|
1262
1270
|
}
|
|
1263
1271
|
useProject() {
|
|
@@ -1266,7 +1274,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1266
1274
|
}
|
|
1267
1275
|
async _listOwnedProjects(session) {
|
|
1268
1276
|
this._ensureInternalProject();
|
|
1269
|
-
const crud = await this._ownedProjectsCache.getOrWait([session], "write-only");
|
|
1277
|
+
const crud = import_results.Result.orThrow(await this._ownedProjectsCache.getOrWait([session], "write-only"));
|
|
1270
1278
|
return crud.map((j) => this._getOwnedAdminApp(j.id, session)._adminOwnedProjectFromCrud(
|
|
1271
1279
|
j,
|
|
1272
1280
|
() => this._refreshOwnedProjects(session)
|
|
@@ -1343,7 +1351,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1343
1351
|
},
|
|
1344
1352
|
setCurrentUser: (userJsonPromise) => {
|
|
1345
1353
|
(0, import_promises.runAsynchronously)(async () => {
|
|
1346
|
-
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], userJsonPromise);
|
|
1354
|
+
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], import_results.Result.fromPromise(userJsonPromise));
|
|
1347
1355
|
});
|
|
1348
1356
|
}
|
|
1349
1357
|
};
|
|
@@ -1401,8 +1409,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1401
1409
|
this._serverUserOAuthConnectionCache = createCache(
|
|
1402
1410
|
async ([userId, providerId, scope, redirect]) => {
|
|
1403
1411
|
return await this._getUserOAuthConnectionCacheFn({
|
|
1404
|
-
getUser: async () => await this._serverUserCache.getOrWait([userId], "write-only"),
|
|
1405
|
-
getOrWaitOAuthToken: async () => await this._serverUserOAuthConnectionAccessTokensCache.getOrWait([userId, providerId, scope || ""], "write-only"),
|
|
1412
|
+
getUser: async () => import_results.Result.orThrow(await this._serverUserCache.getOrWait([userId], "write-only")),
|
|
1413
|
+
getOrWaitOAuthToken: async () => import_results.Result.orThrow(await this._serverUserOAuthConnectionAccessTokensCache.getOrWait([userId, providerId, scope || ""], "write-only")),
|
|
1406
1414
|
useOAuthToken: () => useAsyncCache(this._serverUserOAuthConnectionAccessTokensCache, [userId, providerId, scope || ""], "user.useConnectedAccount()"),
|
|
1407
1415
|
providerId,
|
|
1408
1416
|
scope,
|
|
@@ -1474,7 +1482,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1474
1482
|
const app = this;
|
|
1475
1483
|
async function getConnectedAccount(id, options) {
|
|
1476
1484
|
const scopeString = options?.scopes?.join(" ");
|
|
1477
|
-
return await app._serverUserOAuthConnectionCache.getOrWait([crud.id, id, scopeString || "", options?.or === "redirect"], "write-only");
|
|
1485
|
+
return import_results.Result.orThrow(await app._serverUserOAuthConnectionCache.getOrWait([crud.id, id, scopeString || "", options?.or === "redirect"], "write-only"));
|
|
1478
1486
|
}
|
|
1479
1487
|
function useConnectedAccount(id, options) {
|
|
1480
1488
|
const scopeString = options?.scopes?.join(" ");
|
|
@@ -1541,7 +1549,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1541
1549
|
}, [teams, teamId]);
|
|
1542
1550
|
},
|
|
1543
1551
|
async listTeams() {
|
|
1544
|
-
const teams = await app._serverTeamsCache.getOrWait([crud.id], "write-only");
|
|
1552
|
+
const teams = import_results.Result.orThrow(await app._serverTeamsCache.getOrWait([crud.id], "write-only"));
|
|
1545
1553
|
return teams.map((t) => app._serverTeamFromCrud(t));
|
|
1546
1554
|
},
|
|
1547
1555
|
useTeams() {
|
|
@@ -1561,7 +1569,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1561
1569
|
},
|
|
1562
1570
|
async listPermissions(scope, options) {
|
|
1563
1571
|
const recursive = options?.recursive ?? true;
|
|
1564
|
-
const permissions = await app._serverTeamUserPermissionsCache.getOrWait([scope.id, crud.id, recursive], "write-only");
|
|
1572
|
+
const permissions = import_results.Result.orThrow(await app._serverTeamUserPermissionsCache.getOrWait([scope.id, crud.id, recursive], "write-only"));
|
|
1565
1573
|
return permissions.map((crud2) => app._serverPermissionFromCrud(crud2));
|
|
1566
1574
|
},
|
|
1567
1575
|
usePermissions(scope, options) {
|
|
@@ -1597,7 +1605,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1597
1605
|
return result;
|
|
1598
1606
|
},
|
|
1599
1607
|
async getTeamProfile(team) {
|
|
1600
|
-
const result = await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], "write-only");
|
|
1608
|
+
const result = import_results.Result.orThrow(await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], "write-only"));
|
|
1601
1609
|
return app._serverEditableTeamProfileFromCrud(result);
|
|
1602
1610
|
},
|
|
1603
1611
|
useTeamProfile(team) {
|
|
@@ -1605,7 +1613,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1605
1613
|
return (0, import_react2.useMemo)(() => app._serverEditableTeamProfileFromCrud(result), [result]);
|
|
1606
1614
|
},
|
|
1607
1615
|
async listContactChannels() {
|
|
1608
|
-
const result = await app._serverContactChannelsCache.getOrWait([crud.id], "write-only");
|
|
1616
|
+
const result = import_results.Result.orThrow(await app._serverContactChannelsCache.getOrWait([crud.id], "write-only"));
|
|
1609
1617
|
return result.map((data) => app._serverContactChannelFromCrud(crud.id, data));
|
|
1610
1618
|
},
|
|
1611
1619
|
useContactChannels() {
|
|
@@ -1657,7 +1665,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1657
1665
|
await app._serverTeamsCache.refresh([void 0]);
|
|
1658
1666
|
},
|
|
1659
1667
|
async listUsers() {
|
|
1660
|
-
const result = await app._serverTeamMemberProfilesCache.getOrWait([crud.id], "write-only");
|
|
1668
|
+
const result = import_results.Result.orThrow(await app._serverTeamMemberProfilesCache.getOrWait([crud.id], "write-only"));
|
|
1661
1669
|
return result.map((u) => app._serverTeamUserFromCrud(u));
|
|
1662
1670
|
},
|
|
1663
1671
|
useUsers() {
|
|
@@ -1701,7 +1709,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1701
1709
|
} else {
|
|
1702
1710
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1703
1711
|
const session = await this._getSession(options?.tokenStore);
|
|
1704
|
-
const crud = await this._currentServerUserCache.getOrWait([session], "write-only");
|
|
1712
|
+
const crud = import_results.Result.orThrow(await this._currentServerUserCache.getOrWait([session], "write-only"));
|
|
1705
1713
|
if (crud === null) {
|
|
1706
1714
|
switch (options?.or) {
|
|
1707
1715
|
case "redirect": {
|
|
@@ -1724,7 +1732,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1724
1732
|
return await this.getUser();
|
|
1725
1733
|
}
|
|
1726
1734
|
async getServerUserById(userId) {
|
|
1727
|
-
const crud = await this._serverUserCache.getOrWait([userId], "write-only");
|
|
1735
|
+
const crud = import_results.Result.orThrow(await this._serverUserCache.getOrWait([userId], "write-only"));
|
|
1728
1736
|
return crud && this._serverUserFromCrud(crud);
|
|
1729
1737
|
}
|
|
1730
1738
|
useUser(options) {
|
|
@@ -1762,7 +1770,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1762
1770
|
}, [crud]);
|
|
1763
1771
|
}
|
|
1764
1772
|
async listUsers(options) {
|
|
1765
|
-
const crud = await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query], "write-only");
|
|
1773
|
+
const crud = import_results.Result.orThrow(await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query], "write-only"));
|
|
1766
1774
|
const result = crud.items.map((j) => this._serverUserFromCrud(j));
|
|
1767
1775
|
result.nextCursor = crud.pagination?.next_cursor ?? null;
|
|
1768
1776
|
return result;
|
|
@@ -1786,7 +1794,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1786
1794
|
};
|
|
1787
1795
|
}
|
|
1788
1796
|
async listTeams() {
|
|
1789
|
-
const teams = await this._serverTeamsCache.getOrWait([void 0], "write-only");
|
|
1797
|
+
const teams = import_results.Result.orThrow(await this._serverTeamsCache.getOrWait([void 0], "write-only"));
|
|
1790
1798
|
return teams.map((t) => this._serverTeamFromCrud(t));
|
|
1791
1799
|
}
|
|
1792
1800
|
async createTeam(data) {
|
|
@@ -1947,7 +1955,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1947
1955
|
}
|
|
1948
1956
|
async getProject() {
|
|
1949
1957
|
return this._adminProjectFromCrud(
|
|
1950
|
-
await this._adminProjectCache.getOrWait([], "write-only"),
|
|
1958
|
+
import_results.Result.orThrow(await this._adminProjectCache.getOrWait([], "write-only")),
|
|
1951
1959
|
() => this._refreshProject()
|
|
1952
1960
|
);
|
|
1953
1961
|
}
|
|
@@ -1998,7 +2006,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1998
2006
|
};
|
|
1999
2007
|
}
|
|
2000
2008
|
async listApiKeys() {
|
|
2001
|
-
const crud = await this._apiKeysCache.getOrWait([], "write-only");
|
|
2009
|
+
const crud = import_results.Result.orThrow(await this._apiKeysCache.getOrWait([], "write-only"));
|
|
2002
2010
|
return crud.map((j) => this._createApiKeyFromCrud(j));
|
|
2003
2011
|
}
|
|
2004
2012
|
useApiKeys() {
|
|
@@ -2019,7 +2027,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
2019
2027
|
}, [crud]);
|
|
2020
2028
|
}
|
|
2021
2029
|
async listEmailTemplates() {
|
|
2022
|
-
const crud = await this._adminEmailTemplatesCache.getOrWait([], "write-only");
|
|
2030
|
+
const crud = import_results.Result.orThrow(await this._adminEmailTemplatesCache.getOrWait([], "write-only"));
|
|
2023
2031
|
return crud.map((j) => this._adminEmailTemplateFromCrud(j));
|
|
2024
2032
|
}
|
|
2025
2033
|
async updateEmailTemplate(type, data) {
|
|
@@ -2044,7 +2052,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
2044
2052
|
await this._adminTeamPermissionDefinitionsCache.refresh([]);
|
|
2045
2053
|
}
|
|
2046
2054
|
async listTeamPermissionDefinitions() {
|
|
2047
|
-
const crud = await this._adminTeamPermissionDefinitionsCache.getOrWait([], "write-only");
|
|
2055
|
+
const crud = import_results.Result.orThrow(await this._adminTeamPermissionDefinitionsCache.getOrWait([], "write-only"));
|
|
2048
2056
|
return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));
|
|
2049
2057
|
}
|
|
2050
2058
|
useTeamPermissionDefinitions() {
|