@stackframe/js 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/esm/index.js +4 -0
- 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 +41 -4
- 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 +116 -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 +90 -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/index.d.mts +167 -29
- package/dist/index.d.ts +167 -29
- package/dist/index.js +9 -0
- 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 +40 -3
- 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 +116 -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 +89 -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/package.json +4 -3
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
|
|
|
16
18
|
type RedirectToOptions = {
|
|
@@ -32,12 +34,28 @@ type RedirectMethod = "window" | "none" | {
|
|
|
32
34
|
useNavigate: () => (to: string) => void;
|
|
33
35
|
navigate?: (to: string) => void;
|
|
34
36
|
};
|
|
35
|
-
type
|
|
37
|
+
type GetCurrentUserOptions<HasTokenStore> = {
|
|
36
38
|
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
|
|
37
39
|
tokenStore?: TokenStoreInit;
|
|
38
40
|
} & (HasTokenStore extends false ? {
|
|
39
41
|
tokenStore: TokenStoreInit;
|
|
40
42
|
} : {});
|
|
43
|
+
type ConvexCtx = GenericQueryCtx<any> | {
|
|
44
|
+
auth: {
|
|
45
|
+
getUserIdentity: () => Promise<UserIdentity | null>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type GetCurrentPartialUserOptions<HasTokenStore> = {
|
|
49
|
+
or?: 'return-null' | 'anonymous';
|
|
50
|
+
tokenStore?: TokenStoreInit;
|
|
51
|
+
} & ({
|
|
52
|
+
from: 'token';
|
|
53
|
+
} | {
|
|
54
|
+
from: 'convex';
|
|
55
|
+
ctx: ConvexCtx;
|
|
56
|
+
}) & (HasTokenStore extends false ? {
|
|
57
|
+
tokenStore: TokenStoreInit;
|
|
58
|
+
} : {});
|
|
41
59
|
type RequestLike = {
|
|
42
60
|
headers: {
|
|
43
61
|
get: (name: string) => string | null;
|
|
@@ -118,17 +136,30 @@ type AdminSentEmail = {
|
|
|
118
136
|
sentAt: Date;
|
|
119
137
|
error?: unknown;
|
|
120
138
|
};
|
|
121
|
-
type
|
|
122
|
-
userIds: string[];
|
|
139
|
+
type SendEmailOptionsBase = {
|
|
123
140
|
themeId?: string | null | false;
|
|
124
141
|
subject?: string;
|
|
125
142
|
notificationCategoryName?: string;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
143
|
+
};
|
|
144
|
+
type SendEmailOptions = SendEmailOptionsBase & XOR<[
|
|
145
|
+
{
|
|
146
|
+
userIds: string[];
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
allUsers: true;
|
|
150
|
+
}
|
|
151
|
+
]> & XOR<[
|
|
152
|
+
{
|
|
153
|
+
html: string;
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
templateId: string;
|
|
157
|
+
variables?: Record<string, any>;
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
draftId: string;
|
|
161
|
+
}
|
|
162
|
+
]>;
|
|
132
163
|
|
|
133
164
|
type InternalApiKeyBase = {
|
|
134
165
|
id: string;
|
|
@@ -298,6 +329,36 @@ type NotificationCategory = {
|
|
|
298
329
|
setEnabled(enabled: boolean): Promise<void>;
|
|
299
330
|
};
|
|
300
331
|
|
|
332
|
+
type OAuthProvider = {
|
|
333
|
+
readonly id: string;
|
|
334
|
+
readonly type: string;
|
|
335
|
+
readonly userId: string;
|
|
336
|
+
readonly accountId?: string;
|
|
337
|
+
readonly email?: string;
|
|
338
|
+
readonly allowSignIn: boolean;
|
|
339
|
+
readonly allowConnectedAccounts: boolean;
|
|
340
|
+
update(data: {
|
|
341
|
+
allowSignIn?: boolean;
|
|
342
|
+
allowConnectedAccounts?: boolean;
|
|
343
|
+
}): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
|
|
344
|
+
delete(): Promise<void>;
|
|
345
|
+
};
|
|
346
|
+
type ServerOAuthProvider = {
|
|
347
|
+
readonly id: string;
|
|
348
|
+
readonly type: string;
|
|
349
|
+
readonly userId: string;
|
|
350
|
+
readonly accountId: string;
|
|
351
|
+
readonly email?: string;
|
|
352
|
+
readonly allowSignIn: boolean;
|
|
353
|
+
readonly allowConnectedAccounts: boolean;
|
|
354
|
+
update(data: {
|
|
355
|
+
accountId?: string;
|
|
356
|
+
email?: string;
|
|
357
|
+
allowSignIn?: boolean;
|
|
358
|
+
allowConnectedAccounts?: boolean;
|
|
359
|
+
}): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
|
|
360
|
+
delete(): Promise<void>;
|
|
361
|
+
};
|
|
301
362
|
type Session = {
|
|
302
363
|
getTokens(): Promise<{
|
|
303
364
|
accessToken: string | null;
|
|
@@ -490,6 +551,8 @@ type UserExtra = {
|
|
|
490
551
|
revokeSession(sessionId: string): Promise<void>;
|
|
491
552
|
getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
|
|
492
553
|
createApiKey(options: ApiKeyCreationOptions<"user">): Promise<UserApiKeyFirstView>;
|
|
554
|
+
listOAuthProviders(): Promise<OAuthProvider[]>;
|
|
555
|
+
getOAuthProvider(id: string): Promise<OAuthProvider | null>;
|
|
493
556
|
} & AsyncStoreProperty<"apiKeys", [], UserApiKey[], true> & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
|
|
494
557
|
recursive?: boolean;
|
|
495
558
|
}], TeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
|
|
@@ -502,6 +565,8 @@ type User = BaseUser;
|
|
|
502
565
|
type CurrentUser = BaseUser & Auth & UserExtra & Customer;
|
|
503
566
|
type CurrentInternalUser = CurrentUser & InternalUserExtra;
|
|
504
567
|
type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
|
|
568
|
+
type TokenPartialUser = Pick<User, "id" | "displayName" | "primaryEmail" | "primaryEmailVerified" | "isAnonymous">;
|
|
569
|
+
type SyncedPartialUser = TokenPartialUser & Pick<User, "id" | "displayName" | "primaryEmail" | "primaryEmailVerified" | "profileImageUrl" | "signedUpAt" | "clientMetadata" | "clientReadOnlyMetadata" | "isAnonymous" | "hasPassword">;
|
|
505
570
|
type ActiveSession = {
|
|
506
571
|
id: string;
|
|
507
572
|
userId: string;
|
|
@@ -546,6 +611,8 @@ type ServerBaseUser = {
|
|
|
546
611
|
listPermissions(options?: {
|
|
547
612
|
recursive?: boolean;
|
|
548
613
|
}): Promise<TeamPermission[]>;
|
|
614
|
+
listOAuthProviders(): Promise<ServerOAuthProvider[]>;
|
|
615
|
+
getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>;
|
|
549
616
|
/**
|
|
550
617
|
* Creates a new session object with a refresh token for this user. Can be used to impersonate them.
|
|
551
618
|
*/
|
|
@@ -566,6 +633,7 @@ type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;
|
|
|
566
633
|
type CurrentServerUser = Auth & ServerUser;
|
|
567
634
|
type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;
|
|
568
635
|
type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
|
|
636
|
+
type SyncedPartialServerUser = SyncedPartialUser & Pick<ServerUser, "serverMetadata">;
|
|
569
637
|
type ServerUserUpdateOptions = {
|
|
570
638
|
primaryEmail?: string | null;
|
|
571
639
|
primaryEmailVerified?: boolean;
|
|
@@ -679,20 +747,33 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
679
747
|
*/
|
|
680
748
|
getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
681
749
|
createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
|
|
682
|
-
getUser(options:
|
|
750
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
683
751
|
or: 'redirect';
|
|
684
752
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
685
|
-
getUser(options:
|
|
753
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
686
754
|
or: 'throw';
|
|
687
755
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
688
|
-
getUser(options:
|
|
756
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
689
757
|
or: 'anonymous';
|
|
690
758
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
691
|
-
getUser(options?:
|
|
759
|
+
getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
692
760
|
getUser(id: string): Promise<ServerUser | null>;
|
|
693
761
|
getUser(options: {
|
|
694
762
|
apiKey: string;
|
|
763
|
+
or?: "return-null" | "anonymous";
|
|
764
|
+
}): Promise<ServerUser | null>;
|
|
765
|
+
getUser(options: {
|
|
766
|
+
from: "convex";
|
|
767
|
+
ctx: GenericQueryCtx<any>;
|
|
768
|
+
or?: "return-null" | "anonymous";
|
|
695
769
|
}): Promise<ServerUser | null>;
|
|
770
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
771
|
+
from: 'token';
|
|
772
|
+
}): Promise<TokenPartialUser | null>;
|
|
773
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
774
|
+
from: 'convex';
|
|
775
|
+
}): Promise<TokenPartialUser | null>;
|
|
776
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialServerUser | TokenPartialUser | null>;
|
|
696
777
|
getTeam(id: string): Promise<ServerTeam | null>;
|
|
697
778
|
getTeam(options: {
|
|
698
779
|
apiKey: string;
|
|
@@ -700,7 +781,15 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
700
781
|
listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
|
|
701
782
|
nextCursor: string | null;
|
|
702
783
|
}>;
|
|
703
|
-
|
|
784
|
+
createOAuthProvider(options: {
|
|
785
|
+
userId: string;
|
|
786
|
+
accountId: string;
|
|
787
|
+
providerConfigId: string;
|
|
788
|
+
email: string;
|
|
789
|
+
allowSignIn: boolean;
|
|
790
|
+
allowConnectedAccounts: boolean;
|
|
791
|
+
}): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
|
|
792
|
+
sendEmail(options: SendEmailOptions): Promise<void>;
|
|
704
793
|
} & 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", [
|
|
705
794
|
{
|
|
706
795
|
itemId: string;
|
|
@@ -737,17 +826,28 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
737
826
|
displayName: string;
|
|
738
827
|
themeId?: string;
|
|
739
828
|
tsxSource: string;
|
|
829
|
+
}[], true> & AsyncStoreProperty<"emailDrafts", [], {
|
|
830
|
+
id: string;
|
|
831
|
+
displayName: string;
|
|
832
|
+
themeId: string | undefined | false;
|
|
833
|
+
tsxSource: string;
|
|
834
|
+
sentAt: Date | null;
|
|
740
835
|
}[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
|
|
741
836
|
account_id: string;
|
|
742
837
|
charges_enabled: boolean;
|
|
743
838
|
details_submitted: boolean;
|
|
744
839
|
payouts_enabled: boolean;
|
|
745
|
-
} | null, false> &
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
840
|
+
} | null, false> & AsyncStoreProperty<"transactions", [
|
|
841
|
+
{
|
|
842
|
+
cursor?: string;
|
|
843
|
+
limit?: number;
|
|
844
|
+
type?: 'subscription' | 'one_time' | 'item_quantity_change';
|
|
845
|
+
customerType?: 'user' | 'team' | 'custom';
|
|
846
|
+
}
|
|
847
|
+
], {
|
|
848
|
+
transactions: AdminTransaction[];
|
|
849
|
+
nextCursor: string | null;
|
|
850
|
+
}, true> & {
|
|
751
851
|
createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>;
|
|
752
852
|
createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
|
|
753
853
|
updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
|
|
@@ -767,7 +867,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
767
867
|
id: string;
|
|
768
868
|
}>;
|
|
769
869
|
updateEmailTheme(id: string, tsxSource: string): Promise<void>;
|
|
770
|
-
sendChatMessage(threadId: string, contextType: "email-theme" | "email-template", messages: Array<{
|
|
870
|
+
sendChatMessage(threadId: string, contextType: "email-theme" | "email-template" | "email-draft", messages: Array<{
|
|
771
871
|
role: string;
|
|
772
872
|
content: any;
|
|
773
873
|
}>, abortSignal?: AbortSignal): Promise<{
|
|
@@ -789,6 +889,18 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
789
889
|
createStripeWidgetAccountSession(): Promise<{
|
|
790
890
|
client_secret: string;
|
|
791
891
|
}>;
|
|
892
|
+
createEmailDraft(options: {
|
|
893
|
+
displayName: string;
|
|
894
|
+
themeId?: string | undefined | false;
|
|
895
|
+
tsxSource?: string;
|
|
896
|
+
}): Promise<{
|
|
897
|
+
id: string;
|
|
898
|
+
}>;
|
|
899
|
+
updateEmailDraft(id: string, data: {
|
|
900
|
+
displayName?: string;
|
|
901
|
+
themeId?: string | undefined | false;
|
|
902
|
+
tsxSource?: string;
|
|
903
|
+
}): Promise<void>;
|
|
792
904
|
createItemQuantityChange(options: ({
|
|
793
905
|
userId: string;
|
|
794
906
|
itemId: string;
|
|
@@ -851,7 +963,7 @@ type AdminProjectConfig = {
|
|
|
851
963
|
readonly allowTeamApiKeys: boolean;
|
|
852
964
|
};
|
|
853
965
|
type AdminEmailConfig = ({
|
|
854
|
-
type: "standard";
|
|
966
|
+
type: "standard" | "resend";
|
|
855
967
|
senderName: string;
|
|
856
968
|
senderEmail: string;
|
|
857
969
|
host: string;
|
|
@@ -976,7 +1088,9 @@ type StackClientAppConstructor = {
|
|
|
976
1088
|
type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
|
|
977
1089
|
readonly projectId: ProjectId;
|
|
978
1090
|
readonly urls: Readonly<HandlerUrls>;
|
|
979
|
-
signInWithOAuth(provider: string
|
|
1091
|
+
signInWithOAuth(provider: string, options?: {
|
|
1092
|
+
returnTo?: string;
|
|
1093
|
+
}): Promise<void>;
|
|
980
1094
|
signInWithCredential(options: {
|
|
981
1095
|
email: string;
|
|
982
1096
|
password: string;
|
|
@@ -1020,16 +1134,31 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1020
1134
|
noRedirect?: boolean;
|
|
1021
1135
|
}): Promise<Result<undefined, KnownErrors["VerificationCodeError"] | KnownErrors["InvalidTotpCode"]>>;
|
|
1022
1136
|
redirectToOAuthCallback(): Promise<void>;
|
|
1023
|
-
|
|
1137
|
+
getConvexClientAuth(options: {
|
|
1138
|
+
tokenStore: TokenStoreInit;
|
|
1139
|
+
}): (args: {
|
|
1140
|
+
forceRefreshToken: boolean;
|
|
1141
|
+
}) => Promise<string | null>;
|
|
1142
|
+
getConvexHttpClientAuth(options: {
|
|
1143
|
+
tokenStore: TokenStoreInit;
|
|
1144
|
+
}): Promise<string>;
|
|
1145
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1024
1146
|
or: 'redirect';
|
|
1025
1147
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
1026
|
-
getUser(options:
|
|
1148
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1027
1149
|
or: 'throw';
|
|
1028
1150
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
1029
|
-
getUser(options:
|
|
1151
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1030
1152
|
or: 'anonymous';
|
|
1031
1153
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
1032
|
-
getUser(options?:
|
|
1154
|
+
getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>;
|
|
1155
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1156
|
+
from: 'token';
|
|
1157
|
+
}): Promise<TokenPartialUser | null>;
|
|
1158
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1159
|
+
from: 'convex';
|
|
1160
|
+
}): Promise<TokenPartialUser | null>;
|
|
1161
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialUser | TokenPartialUser | null>;
|
|
1033
1162
|
[stackAppInternalsSymbol]: {
|
|
1034
1163
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
1035
1164
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
|
@@ -1050,4 +1179,13 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1050
1179
|
});
|
|
1051
1180
|
declare const StackClientApp: StackClientAppConstructor;
|
|
1052
1181
|
|
|
1053
|
-
|
|
1182
|
+
declare function getConvexProvidersConfig(options: {
|
|
1183
|
+
projectId?: string;
|
|
1184
|
+
}): {
|
|
1185
|
+
type: string;
|
|
1186
|
+
issuer: string;
|
|
1187
|
+
jwks: string;
|
|
1188
|
+
algorithm: string;
|
|
1189
|
+
}[];
|
|
1190
|
+
|
|
1191
|
+
export { 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, type Connection, type ContactChannel, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetCurrentUserOptions, type GetCurrentUserOptions as GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, type OAuthConnection, type OAuthProvider, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerContactChannel, type ServerListUsersOptions, type ServerOAuthProvider, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamInvitation, type TeamMemberProfile, type TeamUpdateOptions, type TeamUser, type User, getConvexProvidersConfig, stackAppInternalsSymbol };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
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
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -16,10 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
20
|
|
|
17
21
|
// src/index.ts
|
|
18
22
|
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
getConvexProvidersConfig: () => import_convex.getConvexProvidersConfig
|
|
25
|
+
});
|
|
19
26
|
module.exports = __toCommonJS(index_exports);
|
|
20
27
|
__reExport(index_exports, require("./lib/stack-app/index.js"), module.exports);
|
|
28
|
+
var import_convex = require("./integrations/convex.js");
|
|
21
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
30
|
0 && (module.exports = {
|
|
31
|
+
getConvexProvidersConfig,
|
|
23
32
|
...require("./lib/stack-app/index.js")
|
|
24
33
|
});
|
|
25
34
|
//# sourceMappingURL=index.js.map
|
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\n"],"mappings":"
|
|
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\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAc,qCAJd;AAMA,oBAAyC;","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":[]}
|
|
@@ -40,7 +40,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
40
40
|
interface: new import_stack_shared.StackAdminInterface({
|
|
41
41
|
getBaseUrl: () => (0, import_common2.getBaseUrl)(options.baseUrl),
|
|
42
42
|
projectId: options.projectId ?? (0, import_common2.getDefaultProjectId)(),
|
|
43
|
-
extraRequestHeaders: options.extraRequestHeaders ??
|
|
43
|
+
extraRequestHeaders: options.extraRequestHeaders ?? (0, import_common2.getDefaultExtraRequestHeaders)(),
|
|
44
44
|
clientVersion: import_common2.clientVersion,
|
|
45
45
|
..."projectOwnerSession" in options ? {
|
|
46
46
|
projectOwnerSession: options.projectOwnerSession
|
|
@@ -74,6 +74,9 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
74
74
|
this._adminEmailTemplatesCache = (0, import_common2.createCache)(async () => {
|
|
75
75
|
return await this._interface.listInternalEmailTemplates();
|
|
76
76
|
});
|
|
77
|
+
this._adminEmailDraftsCache = (0, import_common2.createCache)(async () => {
|
|
78
|
+
return await this._interface.listInternalEmailDrafts();
|
|
79
|
+
});
|
|
77
80
|
this._adminTeamPermissionDefinitionsCache = (0, import_common2.createCache)(async () => {
|
|
78
81
|
return await this._interface.listTeamPermissionDefinitions();
|
|
79
82
|
});
|
|
@@ -83,8 +86,8 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
83
86
|
this._svixTokenCache = (0, import_common2.createCache)(async () => {
|
|
84
87
|
return await this._interface.getSvixToken();
|
|
85
88
|
});
|
|
86
|
-
this._metricsCache = (0, import_common2.createCache)(async () => {
|
|
87
|
-
return await this._interface.getMetrics();
|
|
89
|
+
this._metricsCache = (0, import_common2.createCache)(async ([includeAnonymous]) => {
|
|
90
|
+
return await this._interface.getMetrics(includeAnonymous);
|
|
88
91
|
});
|
|
89
92
|
this._emailPreviewCache = (0, import_common2.createCache)(async ([themeId, themeTsxSource, templateId, templateTsxSource]) => {
|
|
90
93
|
return await this._interface.renderEmailPreview({ themeId, themeTsxSource, templateId, templateTsxSource });
|
|
@@ -102,6 +105,9 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
102
105
|
throw error;
|
|
103
106
|
}
|
|
104
107
|
});
|
|
108
|
+
this._transactionsCache = (0, import_common2.createCache)(async ([cursor, limit, type, customerType]) => {
|
|
109
|
+
return await this._interface.listTransactions({ cursor, limit, type, customerType });
|
|
110
|
+
});
|
|
105
111
|
}
|
|
106
112
|
_adminConfigFromCrud(data) {
|
|
107
113
|
return JSON.parse(data.config_string);
|
|
@@ -274,6 +280,16 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
274
280
|
tsxSource: template.tsx_source
|
|
275
281
|
}));
|
|
276
282
|
}
|
|
283
|
+
async listEmailDrafts() {
|
|
284
|
+
const crud = import_results.Result.orThrow(await this._adminEmailDraftsCache.getOrWait([], "write-only"));
|
|
285
|
+
return crud.map((draft) => ({
|
|
286
|
+
id: draft.id,
|
|
287
|
+
displayName: draft.display_name,
|
|
288
|
+
themeId: draft.theme_id,
|
|
289
|
+
tsxSource: draft.tsx_source,
|
|
290
|
+
sentAt: draft.sent_at_millis ? new Date(draft.sent_at_millis) : null
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
277
293
|
async createTeamPermissionDefinition(data) {
|
|
278
294
|
const crud = await this._interface.createTeamPermissionDefinition((0, import_permissions.adminTeamPermissionDefinitionCreateOptionsToCrud)(data));
|
|
279
295
|
await this._adminTeamPermissionDefinitionsCache.refresh([]);
|
|
@@ -356,6 +372,23 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
356
372
|
await this._adminEmailTemplatesCache.refresh([]);
|
|
357
373
|
return result;
|
|
358
374
|
}
|
|
375
|
+
async createEmailDraft(options) {
|
|
376
|
+
const result = await this._interface.createEmailDraft({
|
|
377
|
+
display_name: options.displayName,
|
|
378
|
+
theme_id: options.themeId,
|
|
379
|
+
tsx_source: options.tsxSource
|
|
380
|
+
});
|
|
381
|
+
await this._adminEmailDraftsCache.refresh([]);
|
|
382
|
+
return result;
|
|
383
|
+
}
|
|
384
|
+
async updateEmailDraft(id, data) {
|
|
385
|
+
await this._interface.updateEmailDraft(id, {
|
|
386
|
+
display_name: data.displayName,
|
|
387
|
+
theme_id: data.themeId,
|
|
388
|
+
tsx_source: data.tsxSource
|
|
389
|
+
});
|
|
390
|
+
await this._adminEmailDraftsCache.refresh([]);
|
|
391
|
+
}
|
|
359
392
|
async sendChatMessage(threadId, contextType, messages, abortSignal) {
|
|
360
393
|
return await this._interface.sendChatMessage(threadId, contextType, messages, abortSignal);
|
|
361
394
|
}
|
|
@@ -400,6 +433,10 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
400
433
|
async testModePurchase(options) {
|
|
401
434
|
await this._interface.testModePurchase({ price_id: options.priceId, full_code: options.fullCode, quantity: options.quantity });
|
|
402
435
|
}
|
|
436
|
+
async listTransactions(params) {
|
|
437
|
+
const crud = import_results.Result.orThrow(await this._transactionsCache.getOrWait([params.cursor, params.limit, params.type, params.customerType], "write-only"));
|
|
438
|
+
return crud;
|
|
439
|
+
}
|
|
403
440
|
async getStripeAccountInfo() {
|
|
404
441
|
return await this._interface.getStripeAccountInfo();
|
|
405
442
|
}
|