weave-typescript 0.36.0 → 0.38.0
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/dist/weaveapi/auth/v1/auth.pb.d.ts +63 -0
- package/dist/weaveapi/auth/v1/auth.pb.js +350 -1
- package/dist/weaveapi/auth/v1/service.pb.d.ts +147 -1
- package/dist/weaveapi/auth/v1/service.pb.js +2652 -1476
- package/dist/weavesql/weavedb/auth_identity_sql.d.ts +173 -2
- package/dist/weavesql/weavedb/auth_identity_sql.js +353 -10
- package/package.json +1 -1
|
@@ -339,7 +339,7 @@ export interface ListOrganizationMembershipsForUserRow {
|
|
|
339
339
|
updatedAt: Date;
|
|
340
340
|
}
|
|
341
341
|
export declare function listOrganizationMembershipsForUser(client: Client, args: ListOrganizationMembershipsForUserArgs): Promise<ListOrganizationMembershipsForUserRow[]>;
|
|
342
|
-
export declare const listOrganizationMembersQuery = "-- name: ListOrganizationMembers :many\nSELECT\n m.id,\n m.user_id,\n m.organization_id,\n m.identity_link_id,\n
|
|
342
|
+
export declare const listOrganizationMembersQuery = "-- name: ListOrganizationMembers :many\nSELECT\n m.id,\n m.user_id,\n m.organization_id,\n m.identity_link_id,\n m.status,\n m.role_ids,\n p.display_name,\n p.email,\n p.avatar_url,\n m.created_at,\n m.updated_at\nFROM weave.organization_memberships AS m\nJOIN weave.user_profiles AS p\n ON p.user_id = m.user_id\nLEFT JOIN weave.identity_links AS l\n ON l.id = m.identity_link_id\nWHERE m.organization_id = $1\nORDER BY p.display_name ASC, p.email ASC";
|
|
343
343
|
export interface ListOrganizationMembersArgs {
|
|
344
344
|
organizationId: string;
|
|
345
345
|
}
|
|
@@ -348,7 +348,6 @@ export interface ListOrganizationMembersRow {
|
|
|
348
348
|
userId: string;
|
|
349
349
|
organizationId: string;
|
|
350
350
|
identityLinkId: string | null;
|
|
351
|
-
stytchMemberId: string | null;
|
|
352
351
|
status: string;
|
|
353
352
|
roleIds: string[];
|
|
354
353
|
displayName: string;
|
|
@@ -358,6 +357,28 @@ export interface ListOrganizationMembersRow {
|
|
|
358
357
|
updatedAt: Date;
|
|
359
358
|
}
|
|
360
359
|
export declare function listOrganizationMembers(client: Client, args: ListOrganizationMembersArgs): Promise<ListOrganizationMembersRow[]>;
|
|
360
|
+
export declare const getOrganizationMemberAdminRecordQuery = "-- name: GetOrganizationMemberAdminRecord :one\nSELECT\n m.id AS organization_membership_id,\n m.user_id,\n m.organization_id,\n m.identity_link_id,\n m.status,\n m.role_ids,\n p.display_name,\n p.email,\n p.avatar_url,\n l.stytch_organization_id,\n l.stytch_member_id,\n l.stytch_member_email,\n m.created_at,\n m.updated_at\nFROM weave.organization_memberships AS m\nJOIN weave.user_profiles AS p\n ON p.user_id = m.user_id\nLEFT JOIN weave.identity_links AS l\n ON l.id = m.identity_link_id\nWHERE m.organization_id = $1\n AND m.id = $2";
|
|
361
|
+
export interface GetOrganizationMemberAdminRecordArgs {
|
|
362
|
+
organizationId: string;
|
|
363
|
+
organizationMembershipId: string;
|
|
364
|
+
}
|
|
365
|
+
export interface GetOrganizationMemberAdminRecordRow {
|
|
366
|
+
organizationMembershipId: string;
|
|
367
|
+
userId: string;
|
|
368
|
+
organizationId: string;
|
|
369
|
+
identityLinkId: string | null;
|
|
370
|
+
status: string;
|
|
371
|
+
roleIds: string[];
|
|
372
|
+
displayName: string;
|
|
373
|
+
email: string;
|
|
374
|
+
avatarUrl: string;
|
|
375
|
+
stytchOrganizationId: string | null;
|
|
376
|
+
stytchMemberId: string | null;
|
|
377
|
+
stytchMemberEmail: string | null;
|
|
378
|
+
createdAt: Date;
|
|
379
|
+
updatedAt: Date;
|
|
380
|
+
}
|
|
381
|
+
export declare function getOrganizationMemberAdminRecord(client: Client, args: GetOrganizationMemberAdminRecordArgs): Promise<GetOrganizationMemberAdminRecordRow | null>;
|
|
361
382
|
export declare const listActivePlatformAdminGrantsForUserQuery = "-- name: ListActivePlatformAdminGrantsForUser :many\nSELECT\n id,\n user_id,\n platform_role,\n organization_id,\n all_organizations,\n allowed_actions,\n expires_at,\n status,\n created_at,\n updated_at\nFROM weave.platform_admin_grants\nWHERE user_id = $1\n AND status = 'active'\n AND (expires_at IS NULL OR expires_at > now())";
|
|
362
383
|
export interface ListActivePlatformAdminGrantsForUserArgs {
|
|
363
384
|
userId: string;
|
|
@@ -746,4 +767,154 @@ export interface RevokeAuthInviteSessionsByMemberArgs {
|
|
|
746
767
|
stytchMemberId: string;
|
|
747
768
|
}
|
|
748
769
|
export declare const deleteExpiredAuthInviteSessionsQuery = "-- name: DeleteExpiredAuthInviteSessions :execrows\nDELETE FROM weave.auth_invite_sessions\nWHERE expires_at <= now()\n OR status IN ('completed', 'expired', 'revoked')";
|
|
770
|
+
export declare const createOrgTeamQuery = "-- name: CreateOrgTeam :one\nINSERT INTO weave.org_teams (\n organization_id,\n slug,\n name,\n description\n) VALUES (\n $1,\n $2,\n $3,\n $4\n)\nRETURNING id, organization_id, slug, name, description, created_at, updated_at";
|
|
771
|
+
export interface CreateOrgTeamArgs {
|
|
772
|
+
organizationId: string;
|
|
773
|
+
slug: string;
|
|
774
|
+
name: string;
|
|
775
|
+
description: string;
|
|
776
|
+
}
|
|
777
|
+
export interface CreateOrgTeamRow {
|
|
778
|
+
id: string;
|
|
779
|
+
organizationId: string;
|
|
780
|
+
slug: string;
|
|
781
|
+
name: string;
|
|
782
|
+
description: string;
|
|
783
|
+
createdAt: Date;
|
|
784
|
+
updatedAt: Date;
|
|
785
|
+
}
|
|
786
|
+
export declare function createOrgTeam(client: Client, args: CreateOrgTeamArgs): Promise<CreateOrgTeamRow | null>;
|
|
787
|
+
export declare const getOrgTeamQuery = "-- name: GetOrgTeam :one\nSELECT id, organization_id, slug, name, description, created_at, updated_at\nFROM weave.org_teams\nWHERE organization_id = $1\n AND id = $2";
|
|
788
|
+
export interface GetOrgTeamArgs {
|
|
789
|
+
organizationId: string;
|
|
790
|
+
id: string;
|
|
791
|
+
}
|
|
792
|
+
export interface GetOrgTeamRow {
|
|
793
|
+
id: string;
|
|
794
|
+
organizationId: string;
|
|
795
|
+
slug: string;
|
|
796
|
+
name: string;
|
|
797
|
+
description: string;
|
|
798
|
+
createdAt: Date;
|
|
799
|
+
updatedAt: Date;
|
|
800
|
+
}
|
|
801
|
+
export declare function getOrgTeam(client: Client, args: GetOrgTeamArgs): Promise<GetOrgTeamRow | null>;
|
|
802
|
+
export declare const listOrgTeamsQuery = "-- name: ListOrgTeams :many\nSELECT id, organization_id, slug, name, description, created_at, updated_at\nFROM weave.org_teams\nWHERE organization_id = $1\nORDER BY name ASC, slug ASC";
|
|
803
|
+
export interface ListOrgTeamsArgs {
|
|
804
|
+
organizationId: string;
|
|
805
|
+
}
|
|
806
|
+
export interface ListOrgTeamsRow {
|
|
807
|
+
id: string;
|
|
808
|
+
organizationId: string;
|
|
809
|
+
slug: string;
|
|
810
|
+
name: string;
|
|
811
|
+
description: string;
|
|
812
|
+
createdAt: Date;
|
|
813
|
+
updatedAt: Date;
|
|
814
|
+
}
|
|
815
|
+
export declare function listOrgTeams(client: Client, args: ListOrgTeamsArgs): Promise<ListOrgTeamsRow[]>;
|
|
816
|
+
export declare const updateOrgTeamQuery = "-- name: UpdateOrgTeam :one\nUPDATE weave.org_teams\nSET\n slug = $1,\n name = $2,\n description = $3,\n updated_at = now()\nWHERE organization_id = $4\n AND id = $5\nRETURNING id, organization_id, slug, name, description, created_at, updated_at";
|
|
817
|
+
export interface UpdateOrgTeamArgs {
|
|
818
|
+
slug: string;
|
|
819
|
+
name: string;
|
|
820
|
+
description: string;
|
|
821
|
+
organizationId: string;
|
|
822
|
+
id: string;
|
|
823
|
+
}
|
|
824
|
+
export interface UpdateOrgTeamRow {
|
|
825
|
+
id: string;
|
|
826
|
+
organizationId: string;
|
|
827
|
+
slug: string;
|
|
828
|
+
name: string;
|
|
829
|
+
description: string;
|
|
830
|
+
createdAt: Date;
|
|
831
|
+
updatedAt: Date;
|
|
832
|
+
}
|
|
833
|
+
export declare function updateOrgTeam(client: Client, args: UpdateOrgTeamArgs): Promise<UpdateOrgTeamRow | null>;
|
|
834
|
+
export declare const deleteOrgTeamQuery = "-- name: DeleteOrgTeam :execrows\nDELETE FROM weave.org_teams\nWHERE organization_id = $1\n AND id = $2";
|
|
835
|
+
export interface DeleteOrgTeamArgs {
|
|
836
|
+
organizationId: string;
|
|
837
|
+
id: string;
|
|
838
|
+
}
|
|
839
|
+
export declare const deleteOrgTeamMembershipsQuery = "-- name: DeleteOrgTeamMemberships :execrows\nDELETE FROM weave.org_team_memberships\nWHERE organization_id = $1\n AND org_team_id = $2";
|
|
840
|
+
export interface DeleteOrgTeamMembershipsArgs {
|
|
841
|
+
organizationId: string;
|
|
842
|
+
orgTeamId: string;
|
|
843
|
+
}
|
|
844
|
+
export declare const addOrgTeamMembershipQuery = "-- name: AddOrgTeamMembership :one\nINSERT INTO weave.org_team_memberships (\n organization_id,\n org_team_id,\n organization_membership_id,\n user_id\n) VALUES (\n $1,\n $2,\n $3,\n $4\n)\nRETURNING organization_id, org_team_id, organization_membership_id, user_id, created_at";
|
|
845
|
+
export interface AddOrgTeamMembershipArgs {
|
|
846
|
+
organizationId: string;
|
|
847
|
+
orgTeamId: string;
|
|
848
|
+
organizationMembershipId: string;
|
|
849
|
+
userId: string;
|
|
850
|
+
}
|
|
851
|
+
export interface AddOrgTeamMembershipRow {
|
|
852
|
+
organizationId: string;
|
|
853
|
+
orgTeamId: string;
|
|
854
|
+
organizationMembershipId: string;
|
|
855
|
+
userId: string;
|
|
856
|
+
createdAt: Date;
|
|
857
|
+
}
|
|
858
|
+
export declare function addOrgTeamMembership(client: Client, args: AddOrgTeamMembershipArgs): Promise<AddOrgTeamMembershipRow | null>;
|
|
859
|
+
export declare const deleteOrgTeamRoleGrantsQuery = "-- name: DeleteOrgTeamRoleGrants :execrows\nDELETE FROM weave.org_team_role_grants\nWHERE organization_id = $1\n AND org_team_id = $2";
|
|
860
|
+
export interface DeleteOrgTeamRoleGrantsArgs {
|
|
861
|
+
organizationId: string;
|
|
862
|
+
orgTeamId: string;
|
|
863
|
+
}
|
|
864
|
+
export declare const addOrgTeamRoleGrantQuery = "-- name: AddOrgTeamRoleGrant :one\nINSERT INTO weave.org_team_role_grants (\n organization_id,\n org_team_id,\n role_id\n) VALUES (\n $1,\n $2,\n $3\n)\nRETURNING organization_id, org_team_id, role_id, created_at";
|
|
865
|
+
export interface AddOrgTeamRoleGrantArgs {
|
|
866
|
+
organizationId: string;
|
|
867
|
+
orgTeamId: string;
|
|
868
|
+
roleId: string;
|
|
869
|
+
}
|
|
870
|
+
export interface AddOrgTeamRoleGrantRow {
|
|
871
|
+
organizationId: string;
|
|
872
|
+
orgTeamId: string;
|
|
873
|
+
roleId: string;
|
|
874
|
+
createdAt: Date;
|
|
875
|
+
}
|
|
876
|
+
export declare function addOrgTeamRoleGrant(client: Client, args: AddOrgTeamRoleGrantArgs): Promise<AddOrgTeamRoleGrantRow | null>;
|
|
877
|
+
export declare const listOrgTeamMembersQuery = "-- name: ListOrgTeamMembers :many\nSELECT\n tm.organization_id,\n tm.org_team_id,\n tm.organization_membership_id,\n tm.user_id,\n p.display_name,\n p.email,\n p.avatar_url,\n m.status,\n tm.created_at\nFROM weave.org_team_memberships AS tm\nJOIN weave.organization_memberships AS m\n ON m.id = tm.organization_membership_id\n AND m.organization_id = tm.organization_id\n AND m.user_id = tm.user_id\nJOIN weave.user_profiles AS p\n ON p.user_id = tm.user_id\nWHERE tm.organization_id = $1\n AND tm.org_team_id = $2\nORDER BY p.display_name ASC, p.email ASC";
|
|
878
|
+
export interface ListOrgTeamMembersArgs {
|
|
879
|
+
organizationId: string;
|
|
880
|
+
orgTeamId: string;
|
|
881
|
+
}
|
|
882
|
+
export interface ListOrgTeamMembersRow {
|
|
883
|
+
organizationId: string;
|
|
884
|
+
orgTeamId: string;
|
|
885
|
+
organizationMembershipId: string;
|
|
886
|
+
userId: string;
|
|
887
|
+
displayName: string;
|
|
888
|
+
email: string;
|
|
889
|
+
avatarUrl: string;
|
|
890
|
+
status: string;
|
|
891
|
+
createdAt: Date;
|
|
892
|
+
}
|
|
893
|
+
export declare function listOrgTeamMembers(client: Client, args: ListOrgTeamMembersArgs): Promise<ListOrgTeamMembersRow[]>;
|
|
894
|
+
export declare const listOrgTeamRoleGrantsQuery = "-- name: ListOrgTeamRoleGrants :many\nSELECT organization_id, org_team_id, role_id, created_at\nFROM weave.org_team_role_grants\nWHERE organization_id = $1\n AND org_team_id = $2\nORDER BY role_id ASC";
|
|
895
|
+
export interface ListOrgTeamRoleGrantsArgs {
|
|
896
|
+
organizationId: string;
|
|
897
|
+
orgTeamId: string;
|
|
898
|
+
}
|
|
899
|
+
export interface ListOrgTeamRoleGrantsRow {
|
|
900
|
+
organizationId: string;
|
|
901
|
+
orgTeamId: string;
|
|
902
|
+
roleId: string;
|
|
903
|
+
createdAt: Date;
|
|
904
|
+
}
|
|
905
|
+
export declare function listOrgTeamRoleGrants(client: Client, args: ListOrgTeamRoleGrantsArgs): Promise<ListOrgTeamRoleGrantsRow[]>;
|
|
906
|
+
export declare const listEffectiveOrganizationRoleIDsQuery = "-- name: ListEffectiveOrganizationRoleIDs :many\nSELECT DISTINCT role_id\nFROM (\n SELECT unnest(m.role_ids) AS role_id\n FROM weave.organization_memberships AS m\n WHERE m.organization_id = $1\n AND m.user_id = $2\n AND m.status = 'active'\n UNION\n SELECT r.role_id\n FROM weave.org_team_memberships AS tm\n JOIN weave.organization_memberships AS team_member\n ON team_member.id = tm.organization_membership_id\n AND team_member.organization_id = tm.organization_id\n AND team_member.user_id = tm.user_id\n AND team_member.status = 'active'\n JOIN weave.org_team_role_grants AS r\n ON r.organization_id = tm.organization_id\n AND r.org_team_id = tm.org_team_id\n WHERE tm.organization_id = $1\n AND tm.user_id = $2\n) AS roles\nWHERE role_id <> ''\nORDER BY role_id ASC";
|
|
907
|
+
export interface ListEffectiveOrganizationRoleIDsArgs {
|
|
908
|
+
organizationId: string;
|
|
909
|
+
userId: string;
|
|
910
|
+
}
|
|
911
|
+
export interface ListEffectiveOrganizationRoleIDsRow {
|
|
912
|
+
roleId: string;
|
|
913
|
+
}
|
|
914
|
+
export declare function listEffectiveOrganizationRoleIDs(client: Client, args: ListEffectiveOrganizationRoleIDsArgs): Promise<ListEffectiveOrganizationRoleIDsRow[]>;
|
|
915
|
+
export declare const deleteOrgTeamMembershipsForOrganizationMemberQuery = "-- name: DeleteOrgTeamMembershipsForOrganizationMember :execrows\nDELETE FROM weave.org_team_memberships\nWHERE organization_id = $1\n AND organization_membership_id = $2";
|
|
916
|
+
export interface DeleteOrgTeamMembershipsForOrganizationMemberArgs {
|
|
917
|
+
organizationId: string;
|
|
918
|
+
organizationMembershipId: string;
|
|
919
|
+
}
|
|
749
920
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteExpiredAuthInviteSessionsQuery = exports.revokeAuthInviteSessionsByMemberQuery = exports.markAuthInviteSessionRecoveryRequiredQuery = exports.markAuthInviteSessionCompletedQuery = exports.setAuthInviteSessionOAuthStateQuery = exports.getAuthInviteSessionQuery = exports.createAuthInviteSessionQuery = exports.deleteExpiredApplicationSessionsQuery = exports.markApplicationSessionOrganizationSessionStateQuery = exports.listApplicationSessionOrganizationSessionStatesQuery = exports.getApplicationSessionOrganizationSessionQuery = exports.upsertApplicationSessionOrganizationSessionQuery = exports.revokeApplicationSessionQuery = exports.setApplicationSessionActiveOrganizationQuery = exports.getApplicationSessionQuery = exports.createApplicationSessionQuery = exports.insertAuthAuditEventQuery = exports.endSupportAccessSessionQuery = exports.createSupportAccessSessionQuery = exports.createPlatformAdminGrantQuery = exports.listActivePlatformAdminGrantsForUserQuery = exports.listOrganizationMembersQuery = exports.listOrganizationMembershipsForUserQuery = exports.getOrganizationMembershipQuery = exports.upsertOrganizationMembershipQuery = exports.upsertOrganizationAuthLinkQuery = exports.getOrganizationAuthLinkByOrganizationIDQuery = exports.getOrganizationAuthLinkByStytchIDQuery = exports.upsertIdentityLinkQuery = exports.getIdentityLinkByStytchMemberQuery = exports.getUserProfileQuery = exports.upsertUserProfileQuery = exports.deleteOrganizationAuthDomainQuery = exports.listOrganizationAuthDomainsQuery = exports.upsertOrganizationAuthDomainQuery = exports.resolvePrimaryOrganizationAuthLinkByDomainQuery = exports.updateUserProfileThemeQuery = exports.setUserOrganizationPagePositionQuery = exports.setUserLastOrganizationQuery = exports.getUserAuthPreferencesQuery = exports.getUserPrimaryOrganizationAuthLinkQuery = exports.setUserPrimaryOrganizationQuery = exports.getUserByIDQuery = exports.createUserQuery = void 0;
|
|
3
|
+
exports.deleteOrgTeamQuery = exports.updateOrgTeamQuery = exports.listOrgTeamsQuery = exports.getOrgTeamQuery = exports.createOrgTeamQuery = exports.deleteExpiredAuthInviteSessionsQuery = exports.revokeAuthInviteSessionsByMemberQuery = exports.markAuthInviteSessionRecoveryRequiredQuery = exports.markAuthInviteSessionCompletedQuery = exports.setAuthInviteSessionOAuthStateQuery = exports.getAuthInviteSessionQuery = exports.createAuthInviteSessionQuery = exports.deleteExpiredApplicationSessionsQuery = exports.markApplicationSessionOrganizationSessionStateQuery = exports.listApplicationSessionOrganizationSessionStatesQuery = exports.getApplicationSessionOrganizationSessionQuery = exports.upsertApplicationSessionOrganizationSessionQuery = exports.revokeApplicationSessionQuery = exports.setApplicationSessionActiveOrganizationQuery = exports.getApplicationSessionQuery = exports.createApplicationSessionQuery = exports.insertAuthAuditEventQuery = exports.endSupportAccessSessionQuery = exports.createSupportAccessSessionQuery = exports.createPlatformAdminGrantQuery = exports.listActivePlatformAdminGrantsForUserQuery = exports.getOrganizationMemberAdminRecordQuery = exports.listOrganizationMembersQuery = exports.listOrganizationMembershipsForUserQuery = exports.getOrganizationMembershipQuery = exports.upsertOrganizationMembershipQuery = exports.upsertOrganizationAuthLinkQuery = exports.getOrganizationAuthLinkByOrganizationIDQuery = exports.getOrganizationAuthLinkByStytchIDQuery = exports.upsertIdentityLinkQuery = exports.getIdentityLinkByStytchMemberQuery = exports.getUserProfileQuery = exports.upsertUserProfileQuery = exports.deleteOrganizationAuthDomainQuery = exports.listOrganizationAuthDomainsQuery = exports.upsertOrganizationAuthDomainQuery = exports.resolvePrimaryOrganizationAuthLinkByDomainQuery = exports.updateUserProfileThemeQuery = exports.setUserOrganizationPagePositionQuery = exports.setUserLastOrganizationQuery = exports.getUserAuthPreferencesQuery = exports.getUserPrimaryOrganizationAuthLinkQuery = exports.setUserPrimaryOrganizationQuery = exports.getUserByIDQuery = exports.createUserQuery = void 0;
|
|
4
|
+
exports.deleteOrgTeamMembershipsForOrganizationMemberQuery = exports.listEffectiveOrganizationRoleIDsQuery = exports.listOrgTeamRoleGrantsQuery = exports.listOrgTeamMembersQuery = exports.addOrgTeamRoleGrantQuery = exports.deleteOrgTeamRoleGrantsQuery = exports.addOrgTeamMembershipQuery = exports.deleteOrgTeamMembershipsQuery = void 0;
|
|
4
5
|
exports.createUser = createUser;
|
|
5
6
|
exports.getUserByID = getUserByID;
|
|
6
7
|
exports.setUserPrimaryOrganization = setUserPrimaryOrganization;
|
|
@@ -23,6 +24,7 @@ exports.upsertOrganizationMembership = upsertOrganizationMembership;
|
|
|
23
24
|
exports.getOrganizationMembership = getOrganizationMembership;
|
|
24
25
|
exports.listOrganizationMembershipsForUser = listOrganizationMembershipsForUser;
|
|
25
26
|
exports.listOrganizationMembers = listOrganizationMembers;
|
|
27
|
+
exports.getOrganizationMemberAdminRecord = getOrganizationMemberAdminRecord;
|
|
26
28
|
exports.listActivePlatformAdminGrantsForUser = listActivePlatformAdminGrantsForUser;
|
|
27
29
|
exports.createPlatformAdminGrant = createPlatformAdminGrant;
|
|
28
30
|
exports.createSupportAccessSession = createSupportAccessSession;
|
|
@@ -39,6 +41,15 @@ exports.getAuthInviteSession = getAuthInviteSession;
|
|
|
39
41
|
exports.setAuthInviteSessionOAuthState = setAuthInviteSessionOAuthState;
|
|
40
42
|
exports.markAuthInviteSessionCompleted = markAuthInviteSessionCompleted;
|
|
41
43
|
exports.markAuthInviteSessionRecoveryRequired = markAuthInviteSessionRecoveryRequired;
|
|
44
|
+
exports.createOrgTeam = createOrgTeam;
|
|
45
|
+
exports.getOrgTeam = getOrgTeam;
|
|
46
|
+
exports.listOrgTeams = listOrgTeams;
|
|
47
|
+
exports.updateOrgTeam = updateOrgTeam;
|
|
48
|
+
exports.addOrgTeamMembership = addOrgTeamMembership;
|
|
49
|
+
exports.addOrgTeamRoleGrant = addOrgTeamRoleGrant;
|
|
50
|
+
exports.listOrgTeamMembers = listOrgTeamMembers;
|
|
51
|
+
exports.listOrgTeamRoleGrants = listOrgTeamRoleGrants;
|
|
52
|
+
exports.listEffectiveOrganizationRoleIDs = listEffectiveOrganizationRoleIDs;
|
|
42
53
|
exports.createUserQuery = `-- name: CreateUser :one
|
|
43
54
|
INSERT INTO weave.users (status)
|
|
44
55
|
VALUES ($1)
|
|
@@ -853,7 +864,6 @@ SELECT
|
|
|
853
864
|
m.user_id,
|
|
854
865
|
m.organization_id,
|
|
855
866
|
m.identity_link_id,
|
|
856
|
-
l.stytch_member_id,
|
|
857
867
|
m.status,
|
|
858
868
|
m.role_ids,
|
|
859
869
|
p.display_name,
|
|
@@ -880,17 +890,66 @@ async function listOrganizationMembers(client, args) {
|
|
|
880
890
|
userId: row[1],
|
|
881
891
|
organizationId: row[2],
|
|
882
892
|
identityLinkId: row[3],
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
updatedAt: row[11]
|
|
893
|
+
status: row[4],
|
|
894
|
+
roleIds: row[5],
|
|
895
|
+
displayName: row[6],
|
|
896
|
+
email: row[7],
|
|
897
|
+
avatarUrl: row[8],
|
|
898
|
+
createdAt: row[9],
|
|
899
|
+
updatedAt: row[10]
|
|
891
900
|
};
|
|
892
901
|
});
|
|
893
902
|
}
|
|
903
|
+
exports.getOrganizationMemberAdminRecordQuery = `-- name: GetOrganizationMemberAdminRecord :one
|
|
904
|
+
SELECT
|
|
905
|
+
m.id AS organization_membership_id,
|
|
906
|
+
m.user_id,
|
|
907
|
+
m.organization_id,
|
|
908
|
+
m.identity_link_id,
|
|
909
|
+
m.status,
|
|
910
|
+
m.role_ids,
|
|
911
|
+
p.display_name,
|
|
912
|
+
p.email,
|
|
913
|
+
p.avatar_url,
|
|
914
|
+
l.stytch_organization_id,
|
|
915
|
+
l.stytch_member_id,
|
|
916
|
+
l.stytch_member_email,
|
|
917
|
+
m.created_at,
|
|
918
|
+
m.updated_at
|
|
919
|
+
FROM weave.organization_memberships AS m
|
|
920
|
+
JOIN weave.user_profiles AS p
|
|
921
|
+
ON p.user_id = m.user_id
|
|
922
|
+
LEFT JOIN weave.identity_links AS l
|
|
923
|
+
ON l.id = m.identity_link_id
|
|
924
|
+
WHERE m.organization_id = $1
|
|
925
|
+
AND m.id = $2`;
|
|
926
|
+
async function getOrganizationMemberAdminRecord(client, args) {
|
|
927
|
+
const result = await client.query({
|
|
928
|
+
text: exports.getOrganizationMemberAdminRecordQuery,
|
|
929
|
+
values: [args.organizationId, args.organizationMembershipId],
|
|
930
|
+
rowMode: "array"
|
|
931
|
+
});
|
|
932
|
+
if (result.rows.length !== 1) {
|
|
933
|
+
return null;
|
|
934
|
+
}
|
|
935
|
+
const row = result.rows[0];
|
|
936
|
+
return {
|
|
937
|
+
organizationMembershipId: row[0],
|
|
938
|
+
userId: row[1],
|
|
939
|
+
organizationId: row[2],
|
|
940
|
+
identityLinkId: row[3],
|
|
941
|
+
status: row[4],
|
|
942
|
+
roleIds: row[5],
|
|
943
|
+
displayName: row[6],
|
|
944
|
+
email: row[7],
|
|
945
|
+
avatarUrl: row[8],
|
|
946
|
+
stytchOrganizationId: row[9],
|
|
947
|
+
stytchMemberId: row[10],
|
|
948
|
+
stytchMemberEmail: row[11],
|
|
949
|
+
createdAt: row[12],
|
|
950
|
+
updatedAt: row[13]
|
|
951
|
+
};
|
|
952
|
+
}
|
|
894
953
|
exports.listActivePlatformAdminGrantsForUserQuery = `-- name: ListActivePlatformAdminGrantsForUser :many
|
|
895
954
|
SELECT
|
|
896
955
|
id,
|
|
@@ -1754,3 +1813,287 @@ exports.deleteExpiredAuthInviteSessionsQuery = `-- name: DeleteExpiredAuthInvite
|
|
|
1754
1813
|
DELETE FROM weave.auth_invite_sessions
|
|
1755
1814
|
WHERE expires_at <= now()
|
|
1756
1815
|
OR status IN ('completed', 'expired', 'revoked')`;
|
|
1816
|
+
exports.createOrgTeamQuery = `-- name: CreateOrgTeam :one
|
|
1817
|
+
INSERT INTO weave.org_teams (
|
|
1818
|
+
organization_id,
|
|
1819
|
+
slug,
|
|
1820
|
+
name,
|
|
1821
|
+
description
|
|
1822
|
+
) VALUES (
|
|
1823
|
+
$1,
|
|
1824
|
+
$2,
|
|
1825
|
+
$3,
|
|
1826
|
+
$4
|
|
1827
|
+
)
|
|
1828
|
+
RETURNING id, organization_id, slug, name, description, created_at, updated_at`;
|
|
1829
|
+
async function createOrgTeam(client, args) {
|
|
1830
|
+
const result = await client.query({
|
|
1831
|
+
text: exports.createOrgTeamQuery,
|
|
1832
|
+
values: [args.organizationId, args.slug, args.name, args.description],
|
|
1833
|
+
rowMode: "array"
|
|
1834
|
+
});
|
|
1835
|
+
if (result.rows.length !== 1) {
|
|
1836
|
+
return null;
|
|
1837
|
+
}
|
|
1838
|
+
const row = result.rows[0];
|
|
1839
|
+
return {
|
|
1840
|
+
id: row[0],
|
|
1841
|
+
organizationId: row[1],
|
|
1842
|
+
slug: row[2],
|
|
1843
|
+
name: row[3],
|
|
1844
|
+
description: row[4],
|
|
1845
|
+
createdAt: row[5],
|
|
1846
|
+
updatedAt: row[6]
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1849
|
+
exports.getOrgTeamQuery = `-- name: GetOrgTeam :one
|
|
1850
|
+
SELECT id, organization_id, slug, name, description, created_at, updated_at
|
|
1851
|
+
FROM weave.org_teams
|
|
1852
|
+
WHERE organization_id = $1
|
|
1853
|
+
AND id = $2`;
|
|
1854
|
+
async function getOrgTeam(client, args) {
|
|
1855
|
+
const result = await client.query({
|
|
1856
|
+
text: exports.getOrgTeamQuery,
|
|
1857
|
+
values: [args.organizationId, args.id],
|
|
1858
|
+
rowMode: "array"
|
|
1859
|
+
});
|
|
1860
|
+
if (result.rows.length !== 1) {
|
|
1861
|
+
return null;
|
|
1862
|
+
}
|
|
1863
|
+
const row = result.rows[0];
|
|
1864
|
+
return {
|
|
1865
|
+
id: row[0],
|
|
1866
|
+
organizationId: row[1],
|
|
1867
|
+
slug: row[2],
|
|
1868
|
+
name: row[3],
|
|
1869
|
+
description: row[4],
|
|
1870
|
+
createdAt: row[5],
|
|
1871
|
+
updatedAt: row[6]
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
exports.listOrgTeamsQuery = `-- name: ListOrgTeams :many
|
|
1875
|
+
SELECT id, organization_id, slug, name, description, created_at, updated_at
|
|
1876
|
+
FROM weave.org_teams
|
|
1877
|
+
WHERE organization_id = $1
|
|
1878
|
+
ORDER BY name ASC, slug ASC`;
|
|
1879
|
+
async function listOrgTeams(client, args) {
|
|
1880
|
+
const result = await client.query({
|
|
1881
|
+
text: exports.listOrgTeamsQuery,
|
|
1882
|
+
values: [args.organizationId],
|
|
1883
|
+
rowMode: "array"
|
|
1884
|
+
});
|
|
1885
|
+
return result.rows.map(row => {
|
|
1886
|
+
return {
|
|
1887
|
+
id: row[0],
|
|
1888
|
+
organizationId: row[1],
|
|
1889
|
+
slug: row[2],
|
|
1890
|
+
name: row[3],
|
|
1891
|
+
description: row[4],
|
|
1892
|
+
createdAt: row[5],
|
|
1893
|
+
updatedAt: row[6]
|
|
1894
|
+
};
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
exports.updateOrgTeamQuery = `-- name: UpdateOrgTeam :one
|
|
1898
|
+
UPDATE weave.org_teams
|
|
1899
|
+
SET
|
|
1900
|
+
slug = $1,
|
|
1901
|
+
name = $2,
|
|
1902
|
+
description = $3,
|
|
1903
|
+
updated_at = now()
|
|
1904
|
+
WHERE organization_id = $4
|
|
1905
|
+
AND id = $5
|
|
1906
|
+
RETURNING id, organization_id, slug, name, description, created_at, updated_at`;
|
|
1907
|
+
async function updateOrgTeam(client, args) {
|
|
1908
|
+
const result = await client.query({
|
|
1909
|
+
text: exports.updateOrgTeamQuery,
|
|
1910
|
+
values: [args.slug, args.name, args.description, args.organizationId, args.id],
|
|
1911
|
+
rowMode: "array"
|
|
1912
|
+
});
|
|
1913
|
+
if (result.rows.length !== 1) {
|
|
1914
|
+
return null;
|
|
1915
|
+
}
|
|
1916
|
+
const row = result.rows[0];
|
|
1917
|
+
return {
|
|
1918
|
+
id: row[0],
|
|
1919
|
+
organizationId: row[1],
|
|
1920
|
+
slug: row[2],
|
|
1921
|
+
name: row[3],
|
|
1922
|
+
description: row[4],
|
|
1923
|
+
createdAt: row[5],
|
|
1924
|
+
updatedAt: row[6]
|
|
1925
|
+
};
|
|
1926
|
+
}
|
|
1927
|
+
exports.deleteOrgTeamQuery = `-- name: DeleteOrgTeam :execrows
|
|
1928
|
+
DELETE FROM weave.org_teams
|
|
1929
|
+
WHERE organization_id = $1
|
|
1930
|
+
AND id = $2`;
|
|
1931
|
+
exports.deleteOrgTeamMembershipsQuery = `-- name: DeleteOrgTeamMemberships :execrows
|
|
1932
|
+
DELETE FROM weave.org_team_memberships
|
|
1933
|
+
WHERE organization_id = $1
|
|
1934
|
+
AND org_team_id = $2`;
|
|
1935
|
+
exports.addOrgTeamMembershipQuery = `-- name: AddOrgTeamMembership :one
|
|
1936
|
+
INSERT INTO weave.org_team_memberships (
|
|
1937
|
+
organization_id,
|
|
1938
|
+
org_team_id,
|
|
1939
|
+
organization_membership_id,
|
|
1940
|
+
user_id
|
|
1941
|
+
) VALUES (
|
|
1942
|
+
$1,
|
|
1943
|
+
$2,
|
|
1944
|
+
$3,
|
|
1945
|
+
$4
|
|
1946
|
+
)
|
|
1947
|
+
RETURNING organization_id, org_team_id, organization_membership_id, user_id, created_at`;
|
|
1948
|
+
async function addOrgTeamMembership(client, args) {
|
|
1949
|
+
const result = await client.query({
|
|
1950
|
+
text: exports.addOrgTeamMembershipQuery,
|
|
1951
|
+
values: [args.organizationId, args.orgTeamId, args.organizationMembershipId, args.userId],
|
|
1952
|
+
rowMode: "array"
|
|
1953
|
+
});
|
|
1954
|
+
if (result.rows.length !== 1) {
|
|
1955
|
+
return null;
|
|
1956
|
+
}
|
|
1957
|
+
const row = result.rows[0];
|
|
1958
|
+
return {
|
|
1959
|
+
organizationId: row[0],
|
|
1960
|
+
orgTeamId: row[1],
|
|
1961
|
+
organizationMembershipId: row[2],
|
|
1962
|
+
userId: row[3],
|
|
1963
|
+
createdAt: row[4]
|
|
1964
|
+
};
|
|
1965
|
+
}
|
|
1966
|
+
exports.deleteOrgTeamRoleGrantsQuery = `-- name: DeleteOrgTeamRoleGrants :execrows
|
|
1967
|
+
DELETE FROM weave.org_team_role_grants
|
|
1968
|
+
WHERE organization_id = $1
|
|
1969
|
+
AND org_team_id = $2`;
|
|
1970
|
+
exports.addOrgTeamRoleGrantQuery = `-- name: AddOrgTeamRoleGrant :one
|
|
1971
|
+
INSERT INTO weave.org_team_role_grants (
|
|
1972
|
+
organization_id,
|
|
1973
|
+
org_team_id,
|
|
1974
|
+
role_id
|
|
1975
|
+
) VALUES (
|
|
1976
|
+
$1,
|
|
1977
|
+
$2,
|
|
1978
|
+
$3
|
|
1979
|
+
)
|
|
1980
|
+
RETURNING organization_id, org_team_id, role_id, created_at`;
|
|
1981
|
+
async function addOrgTeamRoleGrant(client, args) {
|
|
1982
|
+
const result = await client.query({
|
|
1983
|
+
text: exports.addOrgTeamRoleGrantQuery,
|
|
1984
|
+
values: [args.organizationId, args.orgTeamId, args.roleId],
|
|
1985
|
+
rowMode: "array"
|
|
1986
|
+
});
|
|
1987
|
+
if (result.rows.length !== 1) {
|
|
1988
|
+
return null;
|
|
1989
|
+
}
|
|
1990
|
+
const row = result.rows[0];
|
|
1991
|
+
return {
|
|
1992
|
+
organizationId: row[0],
|
|
1993
|
+
orgTeamId: row[1],
|
|
1994
|
+
roleId: row[2],
|
|
1995
|
+
createdAt: row[3]
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
exports.listOrgTeamMembersQuery = `-- name: ListOrgTeamMembers :many
|
|
1999
|
+
SELECT
|
|
2000
|
+
tm.organization_id,
|
|
2001
|
+
tm.org_team_id,
|
|
2002
|
+
tm.organization_membership_id,
|
|
2003
|
+
tm.user_id,
|
|
2004
|
+
p.display_name,
|
|
2005
|
+
p.email,
|
|
2006
|
+
p.avatar_url,
|
|
2007
|
+
m.status,
|
|
2008
|
+
tm.created_at
|
|
2009
|
+
FROM weave.org_team_memberships AS tm
|
|
2010
|
+
JOIN weave.organization_memberships AS m
|
|
2011
|
+
ON m.id = tm.organization_membership_id
|
|
2012
|
+
AND m.organization_id = tm.organization_id
|
|
2013
|
+
AND m.user_id = tm.user_id
|
|
2014
|
+
JOIN weave.user_profiles AS p
|
|
2015
|
+
ON p.user_id = tm.user_id
|
|
2016
|
+
WHERE tm.organization_id = $1
|
|
2017
|
+
AND tm.org_team_id = $2
|
|
2018
|
+
ORDER BY p.display_name ASC, p.email ASC`;
|
|
2019
|
+
async function listOrgTeamMembers(client, args) {
|
|
2020
|
+
const result = await client.query({
|
|
2021
|
+
text: exports.listOrgTeamMembersQuery,
|
|
2022
|
+
values: [args.organizationId, args.orgTeamId],
|
|
2023
|
+
rowMode: "array"
|
|
2024
|
+
});
|
|
2025
|
+
return result.rows.map(row => {
|
|
2026
|
+
return {
|
|
2027
|
+
organizationId: row[0],
|
|
2028
|
+
orgTeamId: row[1],
|
|
2029
|
+
organizationMembershipId: row[2],
|
|
2030
|
+
userId: row[3],
|
|
2031
|
+
displayName: row[4],
|
|
2032
|
+
email: row[5],
|
|
2033
|
+
avatarUrl: row[6],
|
|
2034
|
+
status: row[7],
|
|
2035
|
+
createdAt: row[8]
|
|
2036
|
+
};
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
exports.listOrgTeamRoleGrantsQuery = `-- name: ListOrgTeamRoleGrants :many
|
|
2040
|
+
SELECT organization_id, org_team_id, role_id, created_at
|
|
2041
|
+
FROM weave.org_team_role_grants
|
|
2042
|
+
WHERE organization_id = $1
|
|
2043
|
+
AND org_team_id = $2
|
|
2044
|
+
ORDER BY role_id ASC`;
|
|
2045
|
+
async function listOrgTeamRoleGrants(client, args) {
|
|
2046
|
+
const result = await client.query({
|
|
2047
|
+
text: exports.listOrgTeamRoleGrantsQuery,
|
|
2048
|
+
values: [args.organizationId, args.orgTeamId],
|
|
2049
|
+
rowMode: "array"
|
|
2050
|
+
});
|
|
2051
|
+
return result.rows.map(row => {
|
|
2052
|
+
return {
|
|
2053
|
+
organizationId: row[0],
|
|
2054
|
+
orgTeamId: row[1],
|
|
2055
|
+
roleId: row[2],
|
|
2056
|
+
createdAt: row[3]
|
|
2057
|
+
};
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
exports.listEffectiveOrganizationRoleIDsQuery = `-- name: ListEffectiveOrganizationRoleIDs :many
|
|
2061
|
+
SELECT DISTINCT role_id
|
|
2062
|
+
FROM (
|
|
2063
|
+
SELECT unnest(m.role_ids) AS role_id
|
|
2064
|
+
FROM weave.organization_memberships AS m
|
|
2065
|
+
WHERE m.organization_id = $1
|
|
2066
|
+
AND m.user_id = $2
|
|
2067
|
+
AND m.status = 'active'
|
|
2068
|
+
UNION
|
|
2069
|
+
SELECT r.role_id
|
|
2070
|
+
FROM weave.org_team_memberships AS tm
|
|
2071
|
+
JOIN weave.organization_memberships AS team_member
|
|
2072
|
+
ON team_member.id = tm.organization_membership_id
|
|
2073
|
+
AND team_member.organization_id = tm.organization_id
|
|
2074
|
+
AND team_member.user_id = tm.user_id
|
|
2075
|
+
AND team_member.status = 'active'
|
|
2076
|
+
JOIN weave.org_team_role_grants AS r
|
|
2077
|
+
ON r.organization_id = tm.organization_id
|
|
2078
|
+
AND r.org_team_id = tm.org_team_id
|
|
2079
|
+
WHERE tm.organization_id = $1
|
|
2080
|
+
AND tm.user_id = $2
|
|
2081
|
+
) AS roles
|
|
2082
|
+
WHERE role_id <> ''
|
|
2083
|
+
ORDER BY role_id ASC`;
|
|
2084
|
+
async function listEffectiveOrganizationRoleIDs(client, args) {
|
|
2085
|
+
const result = await client.query({
|
|
2086
|
+
text: exports.listEffectiveOrganizationRoleIDsQuery,
|
|
2087
|
+
values: [args.organizationId, args.userId],
|
|
2088
|
+
rowMode: "array"
|
|
2089
|
+
});
|
|
2090
|
+
return result.rows.map(row => {
|
|
2091
|
+
return {
|
|
2092
|
+
roleId: row[0]
|
|
2093
|
+
};
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
exports.deleteOrgTeamMembershipsForOrganizationMemberQuery = `-- name: DeleteOrgTeamMembershipsForOrganizationMember :execrows
|
|
2097
|
+
DELETE FROM weave.org_team_memberships
|
|
2098
|
+
WHERE organization_id = $1
|
|
2099
|
+
AND organization_membership_id = $2`;
|