@stackframe/stack 2.8.36 → 2.8.40
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 +40 -0
- package/dist/components/user-button.js +2 -2
- package/dist/components/user-button.js.map +1 -1
- package/dist/esm/components/user-button.js +2 -2
- package/dist/esm/components/user-button.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/integrations/convex.js +18 -0
- package/dist/esm/integrations/convex.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +59 -6
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +140 -3
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +7 -7
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +112 -4
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/esm/lib/stack-app/common.js.map +1 -1
- package/dist/esm/lib/stack-app/index.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/esm/providers/stack-provider-client.js.map +1 -1
- package/dist/index.d.mts +200 -43
- package/dist/index.d.ts +200 -43
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/convex.js +43 -0
- package/dist/integrations/convex.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +58 -5
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +140 -3
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +7 -7
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +111 -3
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/lib/stack-app/common.js.map +1 -1
- package/dist/lib/stack-app/email/index.js.map +1 -1
- package/dist/lib/stack-app/index.js.map +1 -1
- package/dist/lib/stack-app/project-configs/index.js.map +1 -1
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/dist/providers/stack-provider-client.js.map +1 -1
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -2,15 +2,17 @@ import { KnownErrors } from '@stackframe/stack-shared';
|
|
|
2
2
|
import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/current-user';
|
|
3
3
|
import { Result } from '@stackframe/stack-shared/dist/utils/results';
|
|
4
4
|
import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
5
|
+
import { GenericQueryCtx, UserIdentity } from 'convex/server';
|
|
5
6
|
import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
6
7
|
import * as yup from 'yup';
|
|
7
8
|
import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
|
|
8
9
|
import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
|
|
9
10
|
import { ChatContent } from '@stackframe/stack-shared/dist/interface/admin-interface';
|
|
11
|
+
import { AdminTransaction } from '@stackframe/stack-shared/dist/interface/crud/transactions';
|
|
10
12
|
import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
|
|
13
|
+
import { XOR, PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
|
|
11
14
|
import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/internal-api-keys';
|
|
12
15
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
13
|
-
import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
|
|
14
16
|
import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
|
|
15
17
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
16
18
|
import * as lucide_react from 'lucide-react';
|
|
@@ -37,12 +39,28 @@ type RedirectMethod = "window" | "nextjs" | "none" | {
|
|
|
37
39
|
useNavigate: () => (to: string) => void;
|
|
38
40
|
navigate?: (to: string) => void;
|
|
39
41
|
};
|
|
40
|
-
type
|
|
42
|
+
type GetCurrentUserOptions<HasTokenStore> = {
|
|
41
43
|
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
|
|
42
44
|
tokenStore?: TokenStoreInit;
|
|
43
45
|
} & (HasTokenStore extends false ? {
|
|
44
46
|
tokenStore: TokenStoreInit;
|
|
45
47
|
} : {});
|
|
48
|
+
type ConvexCtx = GenericQueryCtx<any> | {
|
|
49
|
+
auth: {
|
|
50
|
+
getUserIdentity: () => Promise<UserIdentity | null>;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
type GetCurrentPartialUserOptions<HasTokenStore> = {
|
|
54
|
+
or?: 'return-null' | 'anonymous';
|
|
55
|
+
tokenStore?: TokenStoreInit;
|
|
56
|
+
} & ({
|
|
57
|
+
from: 'token';
|
|
58
|
+
} | {
|
|
59
|
+
from: 'convex';
|
|
60
|
+
ctx: ConvexCtx;
|
|
61
|
+
}) & (HasTokenStore extends false ? {
|
|
62
|
+
tokenStore: TokenStoreInit;
|
|
63
|
+
} : {});
|
|
46
64
|
type RequestLike = {
|
|
47
65
|
headers: {
|
|
48
66
|
get: (name: string) => string | null;
|
|
@@ -123,17 +141,30 @@ type AdminSentEmail = {
|
|
|
123
141
|
sentAt: Date;
|
|
124
142
|
error?: unknown;
|
|
125
143
|
};
|
|
126
|
-
type
|
|
127
|
-
userIds: string[];
|
|
144
|
+
type SendEmailOptionsBase = {
|
|
128
145
|
themeId?: string | null | false;
|
|
129
146
|
subject?: string;
|
|
130
147
|
notificationCategoryName?: string;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
148
|
+
};
|
|
149
|
+
type SendEmailOptions = SendEmailOptionsBase & XOR<[
|
|
150
|
+
{
|
|
151
|
+
userIds: string[];
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
allUsers: true;
|
|
155
|
+
}
|
|
156
|
+
]> & XOR<[
|
|
157
|
+
{
|
|
158
|
+
html: string;
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
templateId: string;
|
|
162
|
+
variables?: Record<string, any>;
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
draftId: string;
|
|
166
|
+
}
|
|
167
|
+
]>;
|
|
137
168
|
|
|
138
169
|
type InternalApiKeyBase = {
|
|
139
170
|
id: string;
|
|
@@ -306,6 +337,36 @@ type NotificationCategory = {
|
|
|
306
337
|
setEnabled(enabled: boolean): Promise<void>;
|
|
307
338
|
};
|
|
308
339
|
|
|
340
|
+
type OAuthProvider = {
|
|
341
|
+
readonly id: string;
|
|
342
|
+
readonly type: string;
|
|
343
|
+
readonly userId: string;
|
|
344
|
+
readonly accountId?: string;
|
|
345
|
+
readonly email?: string;
|
|
346
|
+
readonly allowSignIn: boolean;
|
|
347
|
+
readonly allowConnectedAccounts: boolean;
|
|
348
|
+
update(data: {
|
|
349
|
+
allowSignIn?: boolean;
|
|
350
|
+
allowConnectedAccounts?: boolean;
|
|
351
|
+
}): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
|
|
352
|
+
delete(): Promise<void>;
|
|
353
|
+
};
|
|
354
|
+
type ServerOAuthProvider = {
|
|
355
|
+
readonly id: string;
|
|
356
|
+
readonly type: string;
|
|
357
|
+
readonly userId: string;
|
|
358
|
+
readonly accountId: string;
|
|
359
|
+
readonly email?: string;
|
|
360
|
+
readonly allowSignIn: boolean;
|
|
361
|
+
readonly allowConnectedAccounts: boolean;
|
|
362
|
+
update(data: {
|
|
363
|
+
accountId?: string;
|
|
364
|
+
email?: string;
|
|
365
|
+
allowSignIn?: boolean;
|
|
366
|
+
allowConnectedAccounts?: boolean;
|
|
367
|
+
}): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
|
|
368
|
+
delete(): Promise<void>;
|
|
369
|
+
};
|
|
309
370
|
type Session = {
|
|
310
371
|
getTokens(): Promise<{
|
|
311
372
|
accessToken: string | null;
|
|
@@ -517,6 +578,10 @@ type UserExtra = {
|
|
|
517
578
|
getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
|
|
518
579
|
useTeamProfile(team: Team): EditableTeamMemberProfile;
|
|
519
580
|
createApiKey(options: ApiKeyCreationOptions<"user">): Promise<UserApiKeyFirstView>;
|
|
581
|
+
useOAuthProviders(): OAuthProvider[];
|
|
582
|
+
listOAuthProviders(): Promise<OAuthProvider[]>;
|
|
583
|
+
useOAuthProvider(id: string): OAuthProvider | null;
|
|
584
|
+
getOAuthProvider(id: string): Promise<OAuthProvider | null>;
|
|
520
585
|
} & AsyncStoreProperty<"apiKeys", [], UserApiKey[], true> & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
|
|
521
586
|
recursive?: boolean;
|
|
522
587
|
}], TeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
|
|
@@ -529,6 +594,8 @@ type User = BaseUser;
|
|
|
529
594
|
type CurrentUser = BaseUser & Auth & UserExtra & Customer;
|
|
530
595
|
type CurrentInternalUser = CurrentUser & InternalUserExtra;
|
|
531
596
|
type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
|
|
597
|
+
type TokenPartialUser = Pick<User, "id" | "displayName" | "primaryEmail" | "primaryEmailVerified" | "isAnonymous">;
|
|
598
|
+
type SyncedPartialUser = TokenPartialUser & Pick<User, "id" | "displayName" | "primaryEmail" | "primaryEmailVerified" | "profileImageUrl" | "signedUpAt" | "clientMetadata" | "clientReadOnlyMetadata" | "isAnonymous" | "hasPassword">;
|
|
532
599
|
type ActiveSession = {
|
|
533
600
|
id: string;
|
|
534
601
|
userId: string;
|
|
@@ -582,6 +649,10 @@ type ServerBaseUser = {
|
|
|
582
649
|
}): TeamPermission[];
|
|
583
650
|
usePermission(scope: Team, permissionId: string): TeamPermission | null;
|
|
584
651
|
usePermission(permissionId: string): TeamPermission | null;
|
|
652
|
+
useOAuthProviders(): ServerOAuthProvider[];
|
|
653
|
+
listOAuthProviders(): Promise<ServerOAuthProvider[]>;
|
|
654
|
+
useOAuthProvider(id: string): ServerOAuthProvider | null;
|
|
655
|
+
getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>;
|
|
585
656
|
/**
|
|
586
657
|
* Creates a new session object with a refresh token for this user. Can be used to impersonate them.
|
|
587
658
|
*/
|
|
@@ -602,6 +673,7 @@ type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;
|
|
|
602
673
|
type CurrentServerUser = Auth & ServerUser;
|
|
603
674
|
type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;
|
|
604
675
|
type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
|
|
676
|
+
type SyncedPartialServerUser = SyncedPartialUser & Pick<ServerUser, "serverMetadata">;
|
|
605
677
|
type ServerUserUpdateOptions = {
|
|
606
678
|
primaryEmail?: string | null;
|
|
607
679
|
primaryEmailVerified?: boolean;
|
|
@@ -718,34 +790,60 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
718
790
|
*/
|
|
719
791
|
getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
720
792
|
createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
|
|
721
|
-
useUser(options:
|
|
793
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
722
794
|
or: 'redirect';
|
|
723
795
|
}): ProjectCurrentServerUser<ProjectId>;
|
|
724
|
-
useUser(options:
|
|
796
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
725
797
|
or: 'throw';
|
|
726
798
|
}): ProjectCurrentServerUser<ProjectId>;
|
|
727
|
-
useUser(options:
|
|
799
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
728
800
|
or: 'anonymous';
|
|
729
801
|
}): ProjectCurrentServerUser<ProjectId>;
|
|
730
|
-
useUser(options?:
|
|
802
|
+
useUser(options?: GetCurrentUserOptions<HasTokenStore>): ProjectCurrentServerUser<ProjectId> | null;
|
|
731
803
|
useUser(id: string): ServerUser | null;
|
|
732
804
|
useUser(options: {
|
|
733
805
|
apiKey: string;
|
|
806
|
+
or?: "return-null" | "anonymous";
|
|
734
807
|
}): ServerUser | null;
|
|
735
|
-
|
|
808
|
+
useUser(options: {
|
|
809
|
+
from: "convex";
|
|
810
|
+
ctx: GenericQueryCtx<any>;
|
|
811
|
+
or?: "return-null" | "anonymous";
|
|
812
|
+
}): ServerUser | null;
|
|
813
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
736
814
|
or: 'redirect';
|
|
737
815
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
738
|
-
getUser(options:
|
|
816
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
739
817
|
or: 'throw';
|
|
740
818
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
741
|
-
getUser(options:
|
|
819
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
742
820
|
or: 'anonymous';
|
|
743
821
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
744
|
-
getUser(options?:
|
|
822
|
+
getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
745
823
|
getUser(id: string): Promise<ServerUser | null>;
|
|
746
824
|
getUser(options: {
|
|
747
825
|
apiKey: string;
|
|
826
|
+
or?: "return-null" | "anonymous";
|
|
827
|
+
}): Promise<ServerUser | null>;
|
|
828
|
+
getUser(options: {
|
|
829
|
+
from: "convex";
|
|
830
|
+
ctx: GenericQueryCtx<any>;
|
|
831
|
+
or?: "return-null" | "anonymous";
|
|
748
832
|
}): Promise<ServerUser | null>;
|
|
833
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
834
|
+
from: 'token';
|
|
835
|
+
}): Promise<TokenPartialUser | null>;
|
|
836
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
837
|
+
from: 'convex';
|
|
838
|
+
}): Promise<TokenPartialUser | null>;
|
|
839
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialServerUser | TokenPartialUser | null>;
|
|
840
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
841
|
+
from: 'token';
|
|
842
|
+
}): TokenPartialUser | null;
|
|
843
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
844
|
+
from: 'convex';
|
|
845
|
+
}): TokenPartialUser | null;
|
|
846
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): SyncedPartialServerUser | TokenPartialUser | null;
|
|
749
847
|
useTeam(id: string): ServerTeam | null;
|
|
750
848
|
useTeam(options: {
|
|
751
849
|
apiKey: string;
|
|
@@ -760,7 +858,15 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
760
858
|
listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
|
|
761
859
|
nextCursor: string | null;
|
|
762
860
|
}>;
|
|
763
|
-
|
|
861
|
+
createOAuthProvider(options: {
|
|
862
|
+
userId: string;
|
|
863
|
+
accountId: string;
|
|
864
|
+
providerConfigId: string;
|
|
865
|
+
email: string;
|
|
866
|
+
allowSignIn: boolean;
|
|
867
|
+
allowConnectedAccounts: boolean;
|
|
868
|
+
}): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
|
|
869
|
+
sendEmail(options: SendEmailOptions): Promise<void>;
|
|
764
870
|
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"dataVaultStore", [id: string], DataVaultStore, false> & AsyncStoreProperty<"item", [
|
|
765
871
|
{
|
|
766
872
|
itemId: string;
|
|
@@ -797,22 +903,28 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
797
903
|
displayName: string;
|
|
798
904
|
themeId?: string;
|
|
799
905
|
tsxSource: string;
|
|
906
|
+
}[], true> & AsyncStoreProperty<"emailDrafts", [], {
|
|
907
|
+
id: string;
|
|
908
|
+
displayName: string;
|
|
909
|
+
themeId: string | undefined | false;
|
|
910
|
+
tsxSource: string;
|
|
911
|
+
sentAt: Date | null;
|
|
800
912
|
}[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
|
|
801
913
|
account_id: string;
|
|
802
914
|
charges_enabled: boolean;
|
|
803
915
|
details_submitted: boolean;
|
|
804
916
|
payouts_enabled: boolean;
|
|
805
|
-
} | null, false> &
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
917
|
+
} | null, false> & AsyncStoreProperty<"transactions", [
|
|
918
|
+
{
|
|
919
|
+
cursor?: string;
|
|
920
|
+
limit?: number;
|
|
921
|
+
type?: 'subscription' | 'one_time' | 'item_quantity_change';
|
|
922
|
+
customerType?: 'user' | 'team' | 'custom';
|
|
923
|
+
}
|
|
924
|
+
], {
|
|
925
|
+
transactions: AdminTransaction[];
|
|
926
|
+
nextCursor: string | null;
|
|
927
|
+
}, true> & {
|
|
816
928
|
createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>;
|
|
817
929
|
createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
|
|
818
930
|
updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
|
|
@@ -837,7 +949,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
837
949
|
id: string;
|
|
838
950
|
}>;
|
|
839
951
|
updateEmailTheme(id: string, tsxSource: string): Promise<void>;
|
|
840
|
-
sendChatMessage(threadId: string, contextType: "email-theme" | "email-template", messages: Array<{
|
|
952
|
+
sendChatMessage(threadId: string, contextType: "email-theme" | "email-template" | "email-draft", messages: Array<{
|
|
841
953
|
role: string;
|
|
842
954
|
content: any;
|
|
843
955
|
}>, abortSignal?: AbortSignal): Promise<{
|
|
@@ -859,6 +971,18 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
859
971
|
createStripeWidgetAccountSession(): Promise<{
|
|
860
972
|
client_secret: string;
|
|
861
973
|
}>;
|
|
974
|
+
createEmailDraft(options: {
|
|
975
|
+
displayName: string;
|
|
976
|
+
themeId?: string | undefined | false;
|
|
977
|
+
tsxSource?: string;
|
|
978
|
+
}): Promise<{
|
|
979
|
+
id: string;
|
|
980
|
+
}>;
|
|
981
|
+
updateEmailDraft(id: string, data: {
|
|
982
|
+
displayName?: string;
|
|
983
|
+
themeId?: string | undefined | false;
|
|
984
|
+
tsxSource?: string;
|
|
985
|
+
}): Promise<void>;
|
|
862
986
|
createItemQuantityChange(options: ({
|
|
863
987
|
userId: string;
|
|
864
988
|
itemId: string;
|
|
@@ -921,7 +1045,7 @@ type AdminProjectConfig = {
|
|
|
921
1045
|
readonly allowTeamApiKeys: boolean;
|
|
922
1046
|
};
|
|
923
1047
|
type AdminEmailConfig = ({
|
|
924
|
-
type: "standard";
|
|
1048
|
+
type: "standard" | "resend";
|
|
925
1049
|
senderName: string;
|
|
926
1050
|
senderEmail: string;
|
|
927
1051
|
host: string;
|
|
@@ -1048,7 +1172,9 @@ type StackClientAppConstructor = {
|
|
|
1048
1172
|
type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
|
|
1049
1173
|
readonly projectId: ProjectId;
|
|
1050
1174
|
readonly urls: Readonly<HandlerUrls>;
|
|
1051
|
-
signInWithOAuth(provider: string
|
|
1175
|
+
signInWithOAuth(provider: string, options?: {
|
|
1176
|
+
returnTo?: string;
|
|
1177
|
+
}): Promise<void>;
|
|
1052
1178
|
signInWithCredential(options: {
|
|
1053
1179
|
email: string;
|
|
1054
1180
|
password: string;
|
|
@@ -1092,26 +1218,48 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1092
1218
|
noRedirect?: boolean;
|
|
1093
1219
|
}): Promise<Result<undefined, KnownErrors["VerificationCodeError"] | KnownErrors["InvalidTotpCode"]>>;
|
|
1094
1220
|
redirectToOAuthCallback(): Promise<void>;
|
|
1095
|
-
|
|
1221
|
+
getConvexClientAuth(options: {
|
|
1222
|
+
tokenStore: TokenStoreInit;
|
|
1223
|
+
}): (args: {
|
|
1224
|
+
forceRefreshToken: boolean;
|
|
1225
|
+
}) => Promise<string | null>;
|
|
1226
|
+
getConvexHttpClientAuth(options: {
|
|
1227
|
+
tokenStore: TokenStoreInit;
|
|
1228
|
+
}): Promise<string>;
|
|
1229
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1096
1230
|
or: 'redirect';
|
|
1097
1231
|
}): ProjectCurrentUser<ProjectId>;
|
|
1098
|
-
useUser(options:
|
|
1232
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1099
1233
|
or: 'throw';
|
|
1100
1234
|
}): ProjectCurrentUser<ProjectId>;
|
|
1101
|
-
useUser(options:
|
|
1235
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1102
1236
|
or: 'anonymous';
|
|
1103
1237
|
}): ProjectCurrentUser<ProjectId>;
|
|
1104
|
-
useUser(options?:
|
|
1105
|
-
getUser(options:
|
|
1238
|
+
useUser(options?: GetCurrentUserOptions<HasTokenStore>): ProjectCurrentUser<ProjectId> | null;
|
|
1239
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1106
1240
|
or: 'redirect';
|
|
1107
1241
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
1108
|
-
getUser(options:
|
|
1242
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1109
1243
|
or: 'throw';
|
|
1110
1244
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
1111
|
-
getUser(options:
|
|
1245
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1112
1246
|
or: 'anonymous';
|
|
1113
1247
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
1114
|
-
getUser(options?:
|
|
1248
|
+
getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>;
|
|
1249
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1250
|
+
from: 'token';
|
|
1251
|
+
}): Promise<TokenPartialUser | null>;
|
|
1252
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1253
|
+
from: 'convex';
|
|
1254
|
+
}): Promise<TokenPartialUser | null>;
|
|
1255
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialUser | TokenPartialUser | null>;
|
|
1256
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1257
|
+
from: 'token';
|
|
1258
|
+
}): TokenPartialUser | null;
|
|
1259
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1260
|
+
from: 'convex';
|
|
1261
|
+
}): TokenPartialUser | null;
|
|
1262
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): SyncedPartialUser | TokenPartialUser | null;
|
|
1115
1263
|
useNavigate(): (to: string) => void;
|
|
1116
1264
|
[stackAppInternalsSymbol]: {
|
|
1117
1265
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
@@ -1133,6 +1281,15 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1133
1281
|
});
|
|
1134
1282
|
declare const StackClientApp: StackClientAppConstructor;
|
|
1135
1283
|
|
|
1284
|
+
declare function getConvexProvidersConfig(options: {
|
|
1285
|
+
projectId?: string;
|
|
1286
|
+
}): {
|
|
1287
|
+
type: string;
|
|
1288
|
+
issuer: string;
|
|
1289
|
+
jwks: string;
|
|
1290
|
+
algorithm: string;
|
|
1291
|
+
}[];
|
|
1292
|
+
|
|
1136
1293
|
declare const iconMap: {
|
|
1137
1294
|
readonly Contact: React$1.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & React$1.RefAttributes<SVGSVGElement>>;
|
|
1138
1295
|
readonly ShieldCheck: React$1.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & React$1.RefAttributes<SVGSVGElement>>;
|
|
@@ -1265,7 +1422,7 @@ declare function NextStackHandler<HasTokenStore extends boolean>(props: BaseHand
|
|
|
1265
1422
|
routeProps: RouteProps | unknown;
|
|
1266
1423
|
})): Promise<any>;
|
|
1267
1424
|
|
|
1268
|
-
type GetUserOptions =
|
|
1425
|
+
type GetUserOptions = GetCurrentUserOptions<true> & {
|
|
1269
1426
|
projectIdMustMatch?: string;
|
|
1270
1427
|
};
|
|
1271
1428
|
/**
|
|
@@ -1507,4 +1664,4 @@ type UserButtonProps = {
|
|
|
1507
1664
|
};
|
|
1508
1665
|
declare function UserButton(props: UserButtonProps): react_jsx_runtime.JSX.Element;
|
|
1509
1666
|
|
|
1510
|
-
export { AccountSettings, type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectPermission, type AdminProjectPermissionDefinition, type AdminProjectPermissionDefinitionCreateOptions, type AdminProjectPermissionDefinitionUpdateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type Auth, AuthPage, CliAuthConfirmation, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type
|
|
1667
|
+
export { AccountSettings, type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectPermission, type AdminProjectPermissionDefinition, type AdminProjectPermissionDefinitionCreateOptions, type AdminProjectPermissionDefinitionUpdateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type Auth, AuthPage, CliAuthConfirmation, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type GetCurrentUserOptions, type GetCurrentUserOptions as GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, MagicLinkSignIn, MessageCard, OAuthButton, OAuthButtonGroup, type OAuthConnection, type OAuthProvider, type OAuthProviderConfig, type OAuthScopesOnSignIn, PasswordReset, type Project, type ProjectConfig, SelectedTeamSwitcher, type ServerContactChannel, type ServerListUsersOptions, type ServerOAuthProvider, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, SignIn, SignUp, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, NextStackHandler as StackHandler, NextStackProvider as StackProvider, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, StackTheme, type Team, type TeamCreateOptions, type TeamInvitation$1 as TeamInvitation, type TeamMemberProfile, TeamSwitcher, type TeamUpdateOptions, type TeamUser, type User, UserAvatar, UserButton, getConvexProvidersConfig, stackAppInternalsSymbol, useStackApp, useUser };
|
package/dist/index.js
CHANGED
|
@@ -52,17 +52,20 @@ __export(src_exports, {
|
|
|
52
52
|
TeamSwitcher: () => import_team_switcher.TeamSwitcher,
|
|
53
53
|
UserAvatar: () => import_user_avatar.UserAvatar,
|
|
54
54
|
UserButton: () => import_user_button.UserButton,
|
|
55
|
+
getConvexProvidersConfig: () => import_convex.getConvexProvidersConfig,
|
|
55
56
|
useStackApp: () => import_hooks.useStackApp,
|
|
56
57
|
useUser: () => import_hooks.useUser
|
|
57
58
|
});
|
|
58
59
|
module.exports = __toCommonJS(src_exports);
|
|
59
60
|
__reExport(src_exports, require("./lib/stack-app/index.js"), module.exports);
|
|
61
|
+
var import_convex = require("./integrations/convex.js");
|
|
60
62
|
var import_stack_handler = __toESM(require("./components-page/stack-handler.js"));
|
|
61
63
|
var import_hooks = require("./lib/hooks.js");
|
|
62
64
|
var import_stack_provider = __toESM(require("./providers/stack-provider.js"));
|
|
63
65
|
var import_theme_provider = require("./providers/theme-provider.js");
|
|
64
66
|
var import_account_settings = require("./components-page/account-settings.js");
|
|
65
67
|
var import_auth_page = require("./components-page/auth-page.js");
|
|
68
|
+
var import_cli_auth_confirm = require("./components-page/cli-auth-confirm.js");
|
|
66
69
|
var import_email_verification = require("./components-page/email-verification.js");
|
|
67
70
|
var import_forgot_password = require("./components-page/forgot-password.js");
|
|
68
71
|
var import_password_reset = require("./components-page/password-reset.js");
|
|
@@ -78,7 +81,6 @@ var import_oauth_button_group = require("./components/oauth-button-group.js");
|
|
|
78
81
|
var import_selected_team_switcher = require("./components/selected-team-switcher.js");
|
|
79
82
|
var import_team_switcher = require("./components/team-switcher.js");
|
|
80
83
|
var import_user_button = require("./components/user-button.js");
|
|
81
|
-
var import_cli_auth_confirm = require("./components-page/cli-auth-confirm.js");
|
|
82
84
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
85
|
0 && (module.exports = {
|
|
84
86
|
AccountSettings,
|
|
@@ -102,6 +104,7 @@ var import_cli_auth_confirm = require("./components-page/cli-auth-confirm.js");
|
|
|
102
104
|
TeamSwitcher,
|
|
103
105
|
UserAvatar,
|
|
104
106
|
UserButton,
|
|
107
|
+
getConvexProvidersConfig,
|
|
105
108
|
useStackApp,
|
|
106
109
|
useUser,
|
|
107
110
|
...require("./lib/stack-app/index.js")
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nexport * from './lib/stack-app';\n\nexport { default as StackHandler } from \"./components-page/stack-handler\";\nexport { useStackApp, useUser } from \"./lib/hooks\";\nexport { default as StackProvider } from \"./providers/stack-provider\";\nexport { StackTheme } from './providers/theme-provider';\n\nexport { AccountSettings } from \"./components-page/account-settings\";\nexport { AuthPage } from \"./components-page/auth-page\";\nexport { EmailVerification } from \"./components-page/email-verification\";\nexport { ForgotPassword } from \"./components-page/forgot-password\";\nexport { PasswordReset } from \"./components-page/password-reset\";\nexport { SignIn } from \"./components-page/sign-in\";\nexport { SignUp } from \"./components-page/sign-up\";\nexport { CredentialSignIn as CredentialSignIn } from \"./components/credential-sign-in\";\nexport { CredentialSignUp as CredentialSignUp } from \"./components/credential-sign-up\";\nexport { UserAvatar } from \"./components/elements/user-avatar\";\nexport { MagicLinkSignIn as MagicLinkSignIn } from \"./components/magic-link-sign-in\";\nexport { MessageCard } from \"./components/message-cards/message-card\";\nexport { OAuthButton } from \"./components/oauth-button\";\nexport { OAuthButtonGroup } from \"./components/oauth-button-group\";\nexport { SelectedTeamSwitcher } from \"./components/selected-team-switcher\";\nexport { TeamSwitcher } from \"./components/team-switcher\";\nexport { UserButton } from \"./components/user-button\";\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nexport * from './lib/stack-app';\n\nexport { getConvexProvidersConfig } from \"./integrations/convex\";\n\nexport { default as StackHandler } from \"./components-page/stack-handler\";\nexport { useStackApp, useUser } from \"./lib/hooks\";\nexport { default as StackProvider } from \"./providers/stack-provider\";\nexport { StackTheme } from './providers/theme-provider';\n\nexport { AccountSettings } from \"./components-page/account-settings\";\nexport { AuthPage } from \"./components-page/auth-page\";\nexport { CliAuthConfirmation } from \"./components-page/cli-auth-confirm\";\nexport { EmailVerification } from \"./components-page/email-verification\";\nexport { ForgotPassword } from \"./components-page/forgot-password\";\nexport { PasswordReset } from \"./components-page/password-reset\";\nexport { SignIn } from \"./components-page/sign-in\";\nexport { SignUp } from \"./components-page/sign-up\";\nexport { CredentialSignIn as CredentialSignIn } from \"./components/credential-sign-in\";\nexport { CredentialSignUp as CredentialSignUp } from \"./components/credential-sign-up\";\nexport { UserAvatar } from \"./components/elements/user-avatar\";\nexport { MagicLinkSignIn as MagicLinkSignIn } from \"./components/magic-link-sign-in\";\nexport { MessageCard } from \"./components/message-cards/message-card\";\nexport { OAuthButton } from \"./components/oauth-button\";\nexport { OAuthButtonGroup } from \"./components/oauth-button-group\";\nexport { SelectedTeamSwitcher } from \"./components/selected-team-switcher\";\nexport { TeamSwitcher } from \"./components/team-switcher\";\nexport { UserButton } from \"./components/user-button\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,wBAAc,qCAJd;AAMA,oBAAyC;AAEzC,2BAAwC;AACxC,mBAAqC;AACrC,4BAAyC;AACzC,4BAA2B;AAE3B,8BAAgC;AAChC,uBAAyB;AACzB,8BAAoC;AACpC,gCAAkC;AAClC,6BAA+B;AAC/B,4BAA8B;AAC9B,qBAAuB;AACvB,qBAAuB;AACvB,gCAAqD;AACrD,gCAAqD;AACrD,yBAA2B;AAC3B,gCAAmD;AACnD,0BAA4B;AAC5B,0BAA4B;AAC5B,gCAAiC;AACjC,oCAAqC;AACrC,2BAA6B;AAC7B,yBAA2B;","names":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/integrations/convex.ts
|
|
21
|
+
var convex_exports = {};
|
|
22
|
+
__export(convex_exports, {
|
|
23
|
+
getConvexProvidersConfig: () => getConvexProvidersConfig
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(convex_exports);
|
|
26
|
+
var import_urls = require("@stackframe/stack-shared/dist/utils/urls");
|
|
27
|
+
var import_common = require("../lib/stack-app/apps/implementations/common.js");
|
|
28
|
+
function getConvexProvidersConfig(options) {
|
|
29
|
+
const projectId = options.projectId ?? (0, import_common.getDefaultProjectId)();
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
type: "customJwt",
|
|
33
|
+
issuer: import_urls.urlString`https://api.stack-auth.com/api/v1/projects/${projectId}`,
|
|
34
|
+
jwks: import_urls.urlString`https://api.stack-auth.com/api/v1/projects/${projectId}/.well-known/jwks.json?include_anonymous=true`,
|
|
35
|
+
algorithm: "ES256"
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
getConvexProvidersConfig
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=convex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/convex.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { urlString } from \"@stackframe/stack-shared/dist/utils/urls\";\nimport { getDefaultProjectId } from \"../lib/stack-app/apps/implementations/common\";\n\nexport function getConvexProvidersConfig(options: {\n projectId?: string,\n}) {\n const projectId = options.projectId ?? getDefaultProjectId();\n return [\n {\n type: \"customJwt\",\n issuer: urlString`https://api.stack-auth.com/api/v1/projects/${projectId}`,\n jwks: urlString`https://api.stack-auth.com/api/v1/projects/${projectId}/.well-known/jwks.json?include_anonymous=true`,\n algorithm: \"ES256\",\n },\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAA0B;AAC1B,oBAAoC;AAE7B,SAAS,yBAAyB,SAEtC;AACD,QAAM,YAAY,QAAQ,iBAAa,mCAAoB;AAC3D,SAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,QAAQ,mEAAuD,SAAS;AAAA,MACxE,MAAM,mEAAuD,SAAS;AAAA,MACtE,WAAW;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
|
|
@@ -42,7 +42,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
42
42
|
interface: new import_stack_shared.StackAdminInterface({
|
|
43
43
|
getBaseUrl: () => (0, import_common2.getBaseUrl)(options.baseUrl),
|
|
44
44
|
projectId: options.projectId ?? (0, import_common2.getDefaultProjectId)(),
|
|
45
|
-
extraRequestHeaders: options.extraRequestHeaders ??
|
|
45
|
+
extraRequestHeaders: options.extraRequestHeaders ?? (0, import_common2.getDefaultExtraRequestHeaders)(),
|
|
46
46
|
clientVersion: import_common2.clientVersion,
|
|
47
47
|
..."projectOwnerSession" in options ? {
|
|
48
48
|
projectOwnerSession: options.projectOwnerSession
|
|
@@ -76,6 +76,9 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
76
76
|
this._adminEmailTemplatesCache = (0, import_common2.createCache)(async () => {
|
|
77
77
|
return await this._interface.listInternalEmailTemplates();
|
|
78
78
|
});
|
|
79
|
+
this._adminEmailDraftsCache = (0, import_common2.createCache)(async () => {
|
|
80
|
+
return await this._interface.listInternalEmailDrafts();
|
|
81
|
+
});
|
|
79
82
|
this._adminTeamPermissionDefinitionsCache = (0, import_common2.createCache)(async () => {
|
|
80
83
|
return await this._interface.listTeamPermissionDefinitions();
|
|
81
84
|
});
|
|
@@ -85,8 +88,8 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
85
88
|
this._svixTokenCache = (0, import_common2.createCache)(async () => {
|
|
86
89
|
return await this._interface.getSvixToken();
|
|
87
90
|
});
|
|
88
|
-
this._metricsCache = (0, import_common2.createCache)(async () => {
|
|
89
|
-
return await this._interface.getMetrics();
|
|
91
|
+
this._metricsCache = (0, import_common2.createCache)(async ([includeAnonymous]) => {
|
|
92
|
+
return await this._interface.getMetrics(includeAnonymous);
|
|
90
93
|
});
|
|
91
94
|
this._emailPreviewCache = (0, import_common2.createCache)(async ([themeId, themeTsxSource, templateId, templateTsxSource]) => {
|
|
92
95
|
return await this._interface.renderEmailPreview({ themeId, themeTsxSource, templateId, templateTsxSource });
|
|
@@ -104,6 +107,9 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
104
107
|
throw error;
|
|
105
108
|
}
|
|
106
109
|
});
|
|
110
|
+
this._transactionsCache = (0, import_common2.createCache)(async ([cursor, limit, type, customerType]) => {
|
|
111
|
+
return await this._interface.listTransactions({ cursor, limit, type, customerType });
|
|
112
|
+
});
|
|
107
113
|
}
|
|
108
114
|
_adminConfigFromCrud(data) {
|
|
109
115
|
return JSON.parse(data.config_string);
|
|
@@ -300,6 +306,18 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
300
306
|
}));
|
|
301
307
|
}, [crud]);
|
|
302
308
|
}
|
|
309
|
+
useEmailDrafts() {
|
|
310
|
+
const crud = (0, import_common3.useAsyncCache)(this._adminEmailDraftsCache, [], "useEmailDrafts()");
|
|
311
|
+
return (0, import_react.useMemo)(() => {
|
|
312
|
+
return crud.map((draft) => ({
|
|
313
|
+
id: draft.id,
|
|
314
|
+
displayName: draft.display_name,
|
|
315
|
+
themeId: draft.theme_id,
|
|
316
|
+
tsxSource: draft.tsx_source,
|
|
317
|
+
sentAt: draft.sent_at_millis ? new Date(draft.sent_at_millis) : null
|
|
318
|
+
}));
|
|
319
|
+
}, [crud]);
|
|
320
|
+
}
|
|
303
321
|
async listEmailThemes() {
|
|
304
322
|
const crud = import_results.Result.orThrow(await this._adminEmailThemesCache.getOrWait([], "write-only"));
|
|
305
323
|
return crud.map((theme) => ({
|
|
@@ -316,6 +334,16 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
316
334
|
tsxSource: template.tsx_source
|
|
317
335
|
}));
|
|
318
336
|
}
|
|
337
|
+
async listEmailDrafts() {
|
|
338
|
+
const crud = import_results.Result.orThrow(await this._adminEmailDraftsCache.getOrWait([], "write-only"));
|
|
339
|
+
return crud.map((draft) => ({
|
|
340
|
+
id: draft.id,
|
|
341
|
+
displayName: draft.display_name,
|
|
342
|
+
themeId: draft.theme_id,
|
|
343
|
+
tsxSource: draft.tsx_source,
|
|
344
|
+
sentAt: draft.sent_at_millis ? new Date(draft.sent_at_millis) : null
|
|
345
|
+
}));
|
|
346
|
+
}
|
|
319
347
|
async createTeamPermissionDefinition(data) {
|
|
320
348
|
const crud = await this._interface.createTeamPermissionDefinition((0, import_permissions.adminTeamPermissionDefinitionCreateOptionsToCrud)(data));
|
|
321
349
|
await this._adminTeamPermissionDefinitionsCache.refresh([]);
|
|
@@ -378,8 +406,8 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
378
406
|
get [import_common.stackAppInternalsSymbol]() {
|
|
379
407
|
return {
|
|
380
408
|
...super[import_common.stackAppInternalsSymbol],
|
|
381
|
-
useMetrics: () => {
|
|
382
|
-
return (0, import_common3.useAsyncCache)(this._metricsCache, [], "useMetrics()");
|
|
409
|
+
useMetrics: (includeAnonymous = false) => {
|
|
410
|
+
return (0, import_common3.useAsyncCache)(this._metricsCache, [includeAnonymous], "useMetrics()");
|
|
383
411
|
}
|
|
384
412
|
};
|
|
385
413
|
}
|
|
@@ -417,6 +445,23 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
417
445
|
await this._adminEmailTemplatesCache.refresh([]);
|
|
418
446
|
return result;
|
|
419
447
|
}
|
|
448
|
+
async createEmailDraft(options) {
|
|
449
|
+
const result = await this._interface.createEmailDraft({
|
|
450
|
+
display_name: options.displayName,
|
|
451
|
+
theme_id: options.themeId,
|
|
452
|
+
tsx_source: options.tsxSource
|
|
453
|
+
});
|
|
454
|
+
await this._adminEmailDraftsCache.refresh([]);
|
|
455
|
+
return result;
|
|
456
|
+
}
|
|
457
|
+
async updateEmailDraft(id, data) {
|
|
458
|
+
await this._interface.updateEmailDraft(id, {
|
|
459
|
+
display_name: data.displayName,
|
|
460
|
+
theme_id: data.themeId,
|
|
461
|
+
tsx_source: data.tsxSource
|
|
462
|
+
});
|
|
463
|
+
await this._adminEmailDraftsCache.refresh([]);
|
|
464
|
+
}
|
|
420
465
|
async sendChatMessage(threadId, contextType, messages, abortSignal) {
|
|
421
466
|
return await this._interface.sendChatMessage(threadId, contextType, messages, abortSignal);
|
|
422
467
|
}
|
|
@@ -472,6 +517,14 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
472
517
|
async testModePurchase(options) {
|
|
473
518
|
await this._interface.testModePurchase({ price_id: options.priceId, full_code: options.fullCode, quantity: options.quantity });
|
|
474
519
|
}
|
|
520
|
+
async listTransactions(params) {
|
|
521
|
+
const crud = import_results.Result.orThrow(await this._transactionsCache.getOrWait([params.cursor, params.limit, params.type, params.customerType], "write-only"));
|
|
522
|
+
return crud;
|
|
523
|
+
}
|
|
524
|
+
useTransactions(params) {
|
|
525
|
+
const data = (0, import_common3.useAsyncCache)(this._transactionsCache, [params.cursor, params.limit, params.type, params.customerType], "useTransactions()");
|
|
526
|
+
return data;
|
|
527
|
+
}
|
|
475
528
|
async getStripeAccountInfo() {
|
|
476
529
|
return await this._interface.getStripeAccountInfo();
|
|
477
530
|
}
|