weave-typescript 0.30.0 → 0.31.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.
@@ -0,0 +1,295 @@
1
+ import { QueryArrayConfig, QueryArrayResult } from "pg";
2
+ interface Client {
3
+ query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
4
+ }
5
+ export declare const createUserQuery = "-- name: CreateUser :one\nINSERT INTO weave.users (status)\nVALUES ($1)\nRETURNING id, status, created_at, updated_at";
6
+ export interface CreateUserArgs {
7
+ status: string;
8
+ }
9
+ export interface CreateUserRow {
10
+ id: string;
11
+ status: string;
12
+ createdAt: Date;
13
+ updatedAt: Date;
14
+ }
15
+ export declare function createUser(client: Client, args: CreateUserArgs): Promise<CreateUserRow | null>;
16
+ export declare const getUserByIDQuery = "-- name: GetUserByID :one\nSELECT id, status, created_at, updated_at\nFROM weave.users\nWHERE id = $1";
17
+ export interface GetUserByIDArgs {
18
+ id: string;
19
+ }
20
+ export interface GetUserByIDRow {
21
+ id: string;
22
+ status: string;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ }
26
+ export declare function getUserByID(client: Client, args: GetUserByIDArgs): Promise<GetUserByIDRow | null>;
27
+ export declare const upsertUserProfileQuery = "-- name: UpsertUserProfile :one\nINSERT INTO weave.user_profiles (\n user_id,\n display_name,\n job_title,\n email,\n avatar_url,\n theme\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6\n)\nON CONFLICT (user_id) DO UPDATE\nSET\n display_name = EXCLUDED.display_name,\n job_title = EXCLUDED.job_title,\n email = EXCLUDED.email,\n avatar_url = EXCLUDED.avatar_url,\n theme = EXCLUDED.theme,\n updated_at = now()\nRETURNING\n user_id,\n display_name,\n job_title,\n email,\n avatar_url,\n theme,\n created_at,\n updated_at";
28
+ export interface UpsertUserProfileArgs {
29
+ userId: string;
30
+ displayName: string;
31
+ jobTitle: string;
32
+ email: string;
33
+ avatarUrl: string;
34
+ theme: string;
35
+ }
36
+ export interface UpsertUserProfileRow {
37
+ userId: string;
38
+ displayName: string;
39
+ jobTitle: string;
40
+ email: string;
41
+ avatarUrl: string;
42
+ theme: string;
43
+ createdAt: Date;
44
+ updatedAt: Date;
45
+ }
46
+ export declare function upsertUserProfile(client: Client, args: UpsertUserProfileArgs): Promise<UpsertUserProfileRow | null>;
47
+ export declare const getUserProfileQuery = "-- name: GetUserProfile :one\nSELECT\n user_id,\n display_name,\n job_title,\n email,\n avatar_url,\n theme,\n created_at,\n updated_at\nFROM weave.user_profiles\nWHERE user_id = $1";
48
+ export interface GetUserProfileArgs {
49
+ userId: string;
50
+ }
51
+ export interface GetUserProfileRow {
52
+ userId: string;
53
+ displayName: string;
54
+ jobTitle: string;
55
+ email: string;
56
+ avatarUrl: string;
57
+ theme: string;
58
+ createdAt: Date;
59
+ updatedAt: Date;
60
+ }
61
+ export declare function getUserProfile(client: Client, args: GetUserProfileArgs): Promise<GetUserProfileRow | null>;
62
+ export declare const getIdentityLinkByStytchMemberQuery = "-- name: GetIdentityLinkByStytchMember :one\nSELECT\n id,\n user_id,\n organization_id,\n provider,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_email,\n last_seen_at,\n created_at,\n updated_at\nFROM weave.identity_links\nWHERE provider = 'stytch_b2b'\n AND stytch_organization_id = $1\n AND stytch_member_id = $2";
63
+ export interface GetIdentityLinkByStytchMemberArgs {
64
+ stytchOrganizationId: string;
65
+ stytchMemberId: string;
66
+ }
67
+ export interface GetIdentityLinkByStytchMemberRow {
68
+ id: string;
69
+ userId: string;
70
+ organizationId: string;
71
+ provider: string;
72
+ stytchOrganizationId: string;
73
+ stytchMemberId: string;
74
+ stytchMemberEmail: string;
75
+ lastSeenAt: Date | null;
76
+ createdAt: Date;
77
+ updatedAt: Date;
78
+ }
79
+ export declare function getIdentityLinkByStytchMember(client: Client, args: GetIdentityLinkByStytchMemberArgs): Promise<GetIdentityLinkByStytchMemberRow | null>;
80
+ export declare const upsertIdentityLinkQuery = "-- name: UpsertIdentityLink :one\nINSERT INTO weave.identity_links (\n user_id,\n organization_id,\n provider,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_email,\n last_seen_at\n) VALUES (\n $1,\n $2,\n 'stytch_b2b',\n $3,\n $4,\n $5,\n now()\n)\nON CONFLICT (provider, stytch_organization_id, stytch_member_id) DO UPDATE\nSET\n user_id = EXCLUDED.user_id,\n organization_id = EXCLUDED.organization_id,\n stytch_member_email = EXCLUDED.stytch_member_email,\n last_seen_at = now(),\n updated_at = now()\nRETURNING\n id,\n user_id,\n organization_id,\n provider,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_email,\n last_seen_at,\n created_at,\n updated_at";
81
+ export interface UpsertIdentityLinkArgs {
82
+ userId: string;
83
+ organizationId: string;
84
+ stytchOrganizationId: string;
85
+ stytchMemberId: string;
86
+ stytchMemberEmail: string;
87
+ }
88
+ export interface UpsertIdentityLinkRow {
89
+ id: string;
90
+ userId: string;
91
+ organizationId: string;
92
+ provider: string;
93
+ stytchOrganizationId: string;
94
+ stytchMemberId: string;
95
+ stytchMemberEmail: string;
96
+ lastSeenAt: Date | null;
97
+ createdAt: Date;
98
+ updatedAt: Date;
99
+ }
100
+ export declare function upsertIdentityLink(client: Client, args: UpsertIdentityLinkArgs): Promise<UpsertIdentityLinkRow | null>;
101
+ export declare const getOrganizationAuthLinkByStytchIDQuery = "-- name: GetOrganizationAuthLinkByStytchID :one\nSELECT\n organization_id,\n stytch_organization_id,\n stytch_organization_slug,\n stytch_organization_kind,\n allowed_domains,\n auth_policy_summary,\n created_at,\n updated_at\nFROM weave.organization_auth_links\nWHERE stytch_organization_id = $1";
102
+ export interface GetOrganizationAuthLinkByStytchIDArgs {
103
+ stytchOrganizationId: string;
104
+ }
105
+ export interface GetOrganizationAuthLinkByStytchIDRow {
106
+ organizationId: string;
107
+ stytchOrganizationId: string;
108
+ stytchOrganizationSlug: string;
109
+ stytchOrganizationKind: string;
110
+ allowedDomains: string[];
111
+ authPolicySummary: any;
112
+ createdAt: Date;
113
+ updatedAt: Date;
114
+ }
115
+ export declare function getOrganizationAuthLinkByStytchID(client: Client, args: GetOrganizationAuthLinkByStytchIDArgs): Promise<GetOrganizationAuthLinkByStytchIDRow | null>;
116
+ export declare const getOrganizationAuthLinkByOrganizationIDQuery = "-- name: GetOrganizationAuthLinkByOrganizationID :one\nSELECT\n organization_id,\n stytch_organization_id,\n stytch_organization_slug,\n stytch_organization_kind,\n allowed_domains,\n auth_policy_summary,\n created_at,\n updated_at\nFROM weave.organization_auth_links\nWHERE organization_id = $1";
117
+ export interface GetOrganizationAuthLinkByOrganizationIDArgs {
118
+ organizationId: string;
119
+ }
120
+ export interface GetOrganizationAuthLinkByOrganizationIDRow {
121
+ organizationId: string;
122
+ stytchOrganizationId: string;
123
+ stytchOrganizationSlug: string;
124
+ stytchOrganizationKind: string;
125
+ allowedDomains: string[];
126
+ authPolicySummary: any;
127
+ createdAt: Date;
128
+ updatedAt: Date;
129
+ }
130
+ export declare function getOrganizationAuthLinkByOrganizationID(client: Client, args: GetOrganizationAuthLinkByOrganizationIDArgs): Promise<GetOrganizationAuthLinkByOrganizationIDRow | null>;
131
+ export declare const upsertOrganizationAuthLinkQuery = "-- name: UpsertOrganizationAuthLink :one\nINSERT INTO weave.organization_auth_links (\n organization_id,\n stytch_organization_id,\n stytch_organization_slug,\n stytch_organization_kind,\n allowed_domains,\n auth_policy_summary\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6\n)\nON CONFLICT (organization_id) DO UPDATE\nSET\n stytch_organization_id = EXCLUDED.stytch_organization_id,\n stytch_organization_slug = EXCLUDED.stytch_organization_slug,\n stytch_organization_kind = EXCLUDED.stytch_organization_kind,\n allowed_domains = EXCLUDED.allowed_domains,\n auth_policy_summary = EXCLUDED.auth_policy_summary,\n updated_at = now()\nRETURNING\n organization_id,\n stytch_organization_id,\n stytch_organization_slug,\n stytch_organization_kind,\n allowed_domains,\n auth_policy_summary,\n created_at,\n updated_at";
132
+ export interface UpsertOrganizationAuthLinkArgs {
133
+ organizationId: string;
134
+ stytchOrganizationId: string;
135
+ stytchOrganizationSlug: string;
136
+ stytchOrganizationKind: string;
137
+ allowedDomains: string[];
138
+ authPolicySummary: any;
139
+ }
140
+ export interface UpsertOrganizationAuthLinkRow {
141
+ organizationId: string;
142
+ stytchOrganizationId: string;
143
+ stytchOrganizationSlug: string;
144
+ stytchOrganizationKind: string;
145
+ allowedDomains: string[];
146
+ authPolicySummary: any;
147
+ createdAt: Date;
148
+ updatedAt: Date;
149
+ }
150
+ export declare function upsertOrganizationAuthLink(client: Client, args: UpsertOrganizationAuthLinkArgs): Promise<UpsertOrganizationAuthLinkRow | null>;
151
+ export declare const upsertOrganizationMembershipQuery = "-- name: UpsertOrganizationMembership :one\nINSERT INTO weave.organization_memberships (\n user_id,\n organization_id,\n identity_link_id,\n status,\n role_ids\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5\n)\nON CONFLICT (user_id, organization_id) DO UPDATE\nSET\n identity_link_id = EXCLUDED.identity_link_id,\n status = EXCLUDED.status,\n role_ids = EXCLUDED.role_ids,\n updated_at = now()\nRETURNING\n id,\n user_id,\n organization_id,\n identity_link_id,\n status,\n role_ids,\n created_at,\n updated_at";
152
+ export interface UpsertOrganizationMembershipArgs {
153
+ userId: string;
154
+ organizationId: string;
155
+ identityLinkId: string | null;
156
+ status: string;
157
+ roleIds: string[];
158
+ }
159
+ export interface UpsertOrganizationMembershipRow {
160
+ id: string;
161
+ userId: string;
162
+ organizationId: string;
163
+ identityLinkId: string | null;
164
+ status: string;
165
+ roleIds: string[];
166
+ createdAt: Date;
167
+ updatedAt: Date;
168
+ }
169
+ export declare function upsertOrganizationMembership(client: Client, args: UpsertOrganizationMembershipArgs): Promise<UpsertOrganizationMembershipRow | null>;
170
+ export declare const getOrganizationMembershipQuery = "-- name: GetOrganizationMembership :one\nSELECT\n id,\n user_id,\n organization_id,\n identity_link_id,\n status,\n role_ids,\n created_at,\n updated_at\nFROM weave.organization_memberships\nWHERE user_id = $1\n AND organization_id = $2";
171
+ export interface GetOrganizationMembershipArgs {
172
+ userId: string;
173
+ organizationId: string;
174
+ }
175
+ export interface GetOrganizationMembershipRow {
176
+ id: string;
177
+ userId: string;
178
+ organizationId: string;
179
+ identityLinkId: string | null;
180
+ status: string;
181
+ roleIds: string[];
182
+ createdAt: Date;
183
+ updatedAt: Date;
184
+ }
185
+ export declare function getOrganizationMembership(client: Client, args: GetOrganizationMembershipArgs): Promise<GetOrganizationMembershipRow | null>;
186
+ export declare const listOrganizationMembershipsForUserQuery = "-- name: ListOrganizationMembershipsForUser :many\nSELECT\n id,\n user_id,\n organization_id,\n identity_link_id,\n status,\n role_ids,\n created_at,\n updated_at\nFROM weave.organization_memberships\nWHERE user_id = $1\nORDER BY created_at ASC";
187
+ export interface ListOrganizationMembershipsForUserArgs {
188
+ userId: string;
189
+ }
190
+ export interface ListOrganizationMembershipsForUserRow {
191
+ id: string;
192
+ userId: string;
193
+ organizationId: string;
194
+ identityLinkId: string | null;
195
+ status: string;
196
+ roleIds: string[];
197
+ createdAt: Date;
198
+ updatedAt: Date;
199
+ }
200
+ export declare function listOrganizationMembershipsForUser(client: Client, args: ListOrganizationMembershipsForUserArgs): Promise<ListOrganizationMembershipsForUserRow[]>;
201
+ 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\nWHERE m.organization_id = $1\nORDER BY p.display_name ASC, p.email ASC";
202
+ export interface ListOrganizationMembersArgs {
203
+ organizationId: string;
204
+ }
205
+ export interface ListOrganizationMembersRow {
206
+ id: string;
207
+ userId: string;
208
+ organizationId: string;
209
+ identityLinkId: string | null;
210
+ status: string;
211
+ roleIds: string[];
212
+ displayName: string;
213
+ email: string;
214
+ avatarUrl: string;
215
+ createdAt: Date;
216
+ updatedAt: Date;
217
+ }
218
+ export declare function listOrganizationMembers(client: Client, args: ListOrganizationMembersArgs): Promise<ListOrganizationMembersRow[]>;
219
+ 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())";
220
+ export interface ListActivePlatformAdminGrantsForUserArgs {
221
+ userId: string;
222
+ }
223
+ export interface ListActivePlatformAdminGrantsForUserRow {
224
+ id: string;
225
+ userId: string;
226
+ platformRole: string;
227
+ organizationId: string | null;
228
+ allOrganizations: boolean;
229
+ allowedActions: string[];
230
+ expiresAt: Date | null;
231
+ status: string;
232
+ createdAt: Date;
233
+ updatedAt: Date;
234
+ }
235
+ export declare function listActivePlatformAdminGrantsForUser(client: Client, args: ListActivePlatformAdminGrantsForUserArgs): Promise<ListActivePlatformAdminGrantsForUserRow[]>;
236
+ export declare const createPlatformAdminGrantQuery = "-- name: CreatePlatformAdminGrant :one\nINSERT INTO weave.platform_admin_grants (\n user_id,\n platform_role,\n organization_id,\n all_organizations,\n allowed_actions,\n expires_at,\n status\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7\n)\nRETURNING\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";
237
+ export interface CreatePlatformAdminGrantArgs {
238
+ userId: string;
239
+ platformRole: string;
240
+ organizationId: string | null;
241
+ allOrganizations: boolean;
242
+ allowedActions: string[];
243
+ expiresAt: Date | null;
244
+ status: string;
245
+ }
246
+ export interface CreatePlatformAdminGrantRow {
247
+ id: string;
248
+ userId: string;
249
+ platformRole: string;
250
+ organizationId: string | null;
251
+ allOrganizations: boolean;
252
+ allowedActions: string[];
253
+ expiresAt: Date | null;
254
+ status: string;
255
+ createdAt: Date;
256
+ updatedAt: Date;
257
+ }
258
+ export declare function createPlatformAdminGrant(client: Client, args: CreatePlatformAdminGrantArgs): Promise<CreatePlatformAdminGrantRow | null>;
259
+ export declare const createSupportAccessSessionQuery = "-- name: CreateSupportAccessSession :one\nINSERT INTO weave.support_access_sessions (\n acting_user_id,\n target_organization_id,\n reason,\n allowed_actions\n) VALUES (\n $1,\n $2,\n $3,\n $4\n)\nRETURNING\n id,\n acting_user_id,\n target_organization_id,\n reason,\n allowed_actions,\n started_at,\n ended_at,\n created_at";
260
+ export interface CreateSupportAccessSessionArgs {
261
+ actingUserId: string;
262
+ targetOrganizationId: string;
263
+ reason: string;
264
+ allowedActions: string[];
265
+ }
266
+ export interface CreateSupportAccessSessionRow {
267
+ id: string;
268
+ actingUserId: string;
269
+ targetOrganizationId: string;
270
+ reason: string;
271
+ allowedActions: string[];
272
+ startedAt: Date;
273
+ endedAt: Date | null;
274
+ createdAt: Date;
275
+ }
276
+ export declare function createSupportAccessSession(client: Client, args: CreateSupportAccessSessionArgs): Promise<CreateSupportAccessSessionRow | null>;
277
+ export declare const endSupportAccessSessionQuery = "-- name: EndSupportAccessSession :execrows\nUPDATE weave.support_access_sessions\nSET ended_at = now()\nWHERE id = $1\n AND ended_at IS NULL";
278
+ export interface EndSupportAccessSessionArgs {
279
+ id: string;
280
+ }
281
+ export declare const insertAuthAuditEventQuery = "-- name: InsertAuthAuditEvent :exec\nINSERT INTO weave.auth_audit_events (\n organization_id,\n acting_user_id,\n target_user_id,\n event_type,\n auth_method,\n stytch_request_id,\n stytch_organization_id,\n stytch_member_id,\n support_access_session_id,\n metadata\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10\n)";
282
+ export interface InsertAuthAuditEventArgs {
283
+ organizationId: string | null;
284
+ actingUserId: string | null;
285
+ targetUserId: string | null;
286
+ eventType: string;
287
+ authMethod: string;
288
+ stytchRequestId: string;
289
+ stytchOrganizationId: string;
290
+ stytchMemberId: string;
291
+ supportAccessSessionId: string | null;
292
+ metadata: any;
293
+ }
294
+ export declare function insertAuthAuditEvent(client: Client, args: InsertAuthAuditEventArgs): Promise<void>;
295
+ export {};