weave-typescript 0.42.8 → 0.44.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.
@@ -455,6 +455,87 @@ export interface InsertAuthAuditEventArgs {
455
455
  metadata: any;
456
456
  }
457
457
  export declare function insertAuthAuditEvent(client: Client, args: InsertAuthAuditEventArgs): Promise<void>;
458
+ export declare const insertAuthorizationDecisionEventQuery = "-- name: InsertAuthorizationDecisionEvent :one\nINSERT INTO weave.authorization_decision_events (\n organization_id,\n acting_user_id,\n actor_organization_membership_id,\n actor_identity_link_id,\n rbac_role_ids,\n org_team_ids,\n platform_grant_ids,\n support_access_session_id,\n feature_flag_key,\n feature_flag_provider,\n feature_flag_variant,\n resource_id,\n resource_instance_id,\n action,\n decision,\n reason_code,\n safe_message,\n used_support_elevation,\n metadata\n) VALUES (\n $1,\n $2::uuid,\n $3::uuid,\n $4::uuid,\n $5,\n $6,\n $7,\n $8::uuid,\n $9,\n $10,\n $11,\n $12,\n $13,\n $14,\n $15,\n $16,\n $17,\n $18,\n $19\n)\nRETURNING\n id,\n organization_id,\n acting_user_id,\n actor_organization_membership_id,\n actor_identity_link_id,\n rbac_role_ids,\n org_team_ids,\n platform_grant_ids,\n support_access_session_id,\n feature_flag_key,\n feature_flag_provider,\n feature_flag_variant,\n resource_id,\n resource_instance_id,\n action,\n decision,\n reason_code,\n safe_message,\n used_support_elevation,\n metadata,\n created_at";
459
+ export interface InsertAuthorizationDecisionEventArgs {
460
+ organizationId: string;
461
+ actingUserId: string | null;
462
+ actorOrganizationMembershipId: string | null;
463
+ actorIdentityLinkId: string | null;
464
+ rbacRoleIds: string[];
465
+ orgTeamIds: string[];
466
+ platformGrantIds: string[];
467
+ supportAccessSessionId: string | null;
468
+ featureFlagKey: string;
469
+ featureFlagProvider: string;
470
+ featureFlagVariant: string;
471
+ resourceId: string;
472
+ resourceInstanceId: string;
473
+ action: string;
474
+ decision: string;
475
+ reasonCode: string;
476
+ safeMessage: string;
477
+ usedSupportElevation: boolean;
478
+ metadata: any;
479
+ }
480
+ export interface InsertAuthorizationDecisionEventRow {
481
+ id: string;
482
+ organizationId: string;
483
+ actingUserId: string | null;
484
+ actorOrganizationMembershipId: string | null;
485
+ actorIdentityLinkId: string | null;
486
+ rbacRoleIds: string[];
487
+ orgTeamIds: string[];
488
+ platformGrantIds: string[];
489
+ supportAccessSessionId: string | null;
490
+ featureFlagKey: string;
491
+ featureFlagProvider: string;
492
+ featureFlagVariant: string;
493
+ resourceId: string;
494
+ resourceInstanceId: string;
495
+ action: string;
496
+ decision: string;
497
+ reasonCode: string;
498
+ safeMessage: string;
499
+ usedSupportElevation: boolean;
500
+ metadata: any;
501
+ createdAt: Date;
502
+ }
503
+ export declare function insertAuthorizationDecisionEvent(client: Client, args: InsertAuthorizationDecisionEventArgs): Promise<InsertAuthorizationDecisionEventRow | null>;
504
+ export declare const listAuthorizationDecisionEventsByOrganizationQuery = "-- name: ListAuthorizationDecisionEventsByOrganization :many\nSELECT\n id,\n organization_id,\n acting_user_id,\n actor_organization_membership_id,\n actor_identity_link_id,\n rbac_role_ids,\n org_team_ids,\n platform_grant_ids,\n support_access_session_id,\n feature_flag_key,\n feature_flag_provider,\n feature_flag_variant,\n resource_id,\n resource_instance_id,\n action,\n decision,\n reason_code,\n safe_message,\n used_support_elevation,\n metadata,\n created_at\nFROM weave.authorization_decision_events\nWHERE organization_id = $1\n AND (\n $2::uuid IS NULL\n OR acting_user_id = $2::uuid\n )\n AND (\n $3::text IS NULL\n OR feature_flag_key = $3::text\n )\n AND (\n $4::text IS NULL\n OR resource_id = $4::text\n )\n AND (\n $5::text IS NULL\n OR action = $5::text\n )\n AND (\n $6::text IS NULL\n OR decision = $6::text\n )\nORDER BY created_at DESC, id DESC\nLIMIT $8 OFFSET $7";
505
+ export interface ListAuthorizationDecisionEventsByOrganizationArgs {
506
+ organizationId: string;
507
+ actingUserId: string | null;
508
+ featureFlagKey: string | null;
509
+ resourceId: string | null;
510
+ action: string | null;
511
+ decision: string | null;
512
+ pageOffset: string;
513
+ pageSize: string;
514
+ }
515
+ export interface ListAuthorizationDecisionEventsByOrganizationRow {
516
+ id: string;
517
+ organizationId: string;
518
+ actingUserId: string | null;
519
+ actorOrganizationMembershipId: string | null;
520
+ actorIdentityLinkId: string | null;
521
+ rbacRoleIds: string[];
522
+ orgTeamIds: string[];
523
+ platformGrantIds: string[];
524
+ supportAccessSessionId: string | null;
525
+ featureFlagKey: string;
526
+ featureFlagProvider: string;
527
+ featureFlagVariant: string;
528
+ resourceId: string;
529
+ resourceInstanceId: string;
530
+ action: string;
531
+ decision: string;
532
+ reasonCode: string;
533
+ safeMessage: string;
534
+ usedSupportElevation: boolean;
535
+ metadata: any;
536
+ createdAt: Date;
537
+ }
538
+ export declare function listAuthorizationDecisionEventsByOrganization(client: Client, args: ListAuthorizationDecisionEventsByOrganizationArgs): Promise<ListAuthorizationDecisionEventsByOrganizationRow[]>;
458
539
  export declare const createApplicationSessionQuery = "-- name: CreateApplicationSession :one\nINSERT INTO weave.application_sessions (\n user_id,\n active_organization_id,\n expires_at\n) VALUES (\n $1,\n $2,\n $3\n)\nRETURNING\n id,\n user_id,\n active_organization_id,\n status,\n expires_at,\n revoked_at,\n created_at,\n updated_at";
459
540
  export interface CreateApplicationSessionArgs {
460
541
  userId: string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ 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.listAuthorizationDecisionEventsByOrganizationQuery = exports.insertAuthorizationDecisionEventQuery = 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 = exports.deleteOrgTeamQuery = exports.updateOrgTeamQuery = void 0;
5
5
  exports.createUser = createUser;
6
6
  exports.getUserByID = getUserByID;
7
7
  exports.setUserPrimaryOrganization = setUserPrimaryOrganization;
@@ -29,6 +29,8 @@ exports.listActivePlatformAdminGrantsForUser = listActivePlatformAdminGrantsForU
29
29
  exports.createPlatformAdminGrant = createPlatformAdminGrant;
30
30
  exports.createSupportAccessSession = createSupportAccessSession;
31
31
  exports.insertAuthAuditEvent = insertAuthAuditEvent;
32
+ exports.insertAuthorizationDecisionEvent = insertAuthorizationDecisionEvent;
33
+ exports.listAuthorizationDecisionEventsByOrganization = listAuthorizationDecisionEventsByOrganization;
32
34
  exports.createApplicationSession = createApplicationSession;
33
35
  exports.getApplicationSession = getApplicationSession;
34
36
  exports.setApplicationSessionActiveOrganization = setApplicationSessionActiveOrganization;
@@ -1117,6 +1119,183 @@ async function insertAuthAuditEvent(client, args) {
1117
1119
  rowMode: "array"
1118
1120
  });
1119
1121
  }
1122
+ exports.insertAuthorizationDecisionEventQuery = `-- name: InsertAuthorizationDecisionEvent :one
1123
+ INSERT INTO weave.authorization_decision_events (
1124
+ organization_id,
1125
+ acting_user_id,
1126
+ actor_organization_membership_id,
1127
+ actor_identity_link_id,
1128
+ rbac_role_ids,
1129
+ org_team_ids,
1130
+ platform_grant_ids,
1131
+ support_access_session_id,
1132
+ feature_flag_key,
1133
+ feature_flag_provider,
1134
+ feature_flag_variant,
1135
+ resource_id,
1136
+ resource_instance_id,
1137
+ action,
1138
+ decision,
1139
+ reason_code,
1140
+ safe_message,
1141
+ used_support_elevation,
1142
+ metadata
1143
+ ) VALUES (
1144
+ $1,
1145
+ $2::uuid,
1146
+ $3::uuid,
1147
+ $4::uuid,
1148
+ $5,
1149
+ $6,
1150
+ $7,
1151
+ $8::uuid,
1152
+ $9,
1153
+ $10,
1154
+ $11,
1155
+ $12,
1156
+ $13,
1157
+ $14,
1158
+ $15,
1159
+ $16,
1160
+ $17,
1161
+ $18,
1162
+ $19
1163
+ )
1164
+ RETURNING
1165
+ id,
1166
+ organization_id,
1167
+ acting_user_id,
1168
+ actor_organization_membership_id,
1169
+ actor_identity_link_id,
1170
+ rbac_role_ids,
1171
+ org_team_ids,
1172
+ platform_grant_ids,
1173
+ support_access_session_id,
1174
+ feature_flag_key,
1175
+ feature_flag_provider,
1176
+ feature_flag_variant,
1177
+ resource_id,
1178
+ resource_instance_id,
1179
+ action,
1180
+ decision,
1181
+ reason_code,
1182
+ safe_message,
1183
+ used_support_elevation,
1184
+ metadata,
1185
+ created_at`;
1186
+ async function insertAuthorizationDecisionEvent(client, args) {
1187
+ const result = await client.query({
1188
+ text: exports.insertAuthorizationDecisionEventQuery,
1189
+ values: [args.organizationId, args.actingUserId, args.actorOrganizationMembershipId, args.actorIdentityLinkId, args.rbacRoleIds, args.orgTeamIds, args.platformGrantIds, args.supportAccessSessionId, args.featureFlagKey, args.featureFlagProvider, args.featureFlagVariant, args.resourceId, args.resourceInstanceId, args.action, args.decision, args.reasonCode, args.safeMessage, args.usedSupportElevation, args.metadata],
1190
+ rowMode: "array"
1191
+ });
1192
+ if (result.rows.length !== 1) {
1193
+ return null;
1194
+ }
1195
+ const row = result.rows[0];
1196
+ return {
1197
+ id: row[0],
1198
+ organizationId: row[1],
1199
+ actingUserId: row[2],
1200
+ actorOrganizationMembershipId: row[3],
1201
+ actorIdentityLinkId: row[4],
1202
+ rbacRoleIds: row[5],
1203
+ orgTeamIds: row[6],
1204
+ platformGrantIds: row[7],
1205
+ supportAccessSessionId: row[8],
1206
+ featureFlagKey: row[9],
1207
+ featureFlagProvider: row[10],
1208
+ featureFlagVariant: row[11],
1209
+ resourceId: row[12],
1210
+ resourceInstanceId: row[13],
1211
+ action: row[14],
1212
+ decision: row[15],
1213
+ reasonCode: row[16],
1214
+ safeMessage: row[17],
1215
+ usedSupportElevation: row[18],
1216
+ metadata: row[19],
1217
+ createdAt: row[20]
1218
+ };
1219
+ }
1220
+ exports.listAuthorizationDecisionEventsByOrganizationQuery = `-- name: ListAuthorizationDecisionEventsByOrganization :many
1221
+ SELECT
1222
+ id,
1223
+ organization_id,
1224
+ acting_user_id,
1225
+ actor_organization_membership_id,
1226
+ actor_identity_link_id,
1227
+ rbac_role_ids,
1228
+ org_team_ids,
1229
+ platform_grant_ids,
1230
+ support_access_session_id,
1231
+ feature_flag_key,
1232
+ feature_flag_provider,
1233
+ feature_flag_variant,
1234
+ resource_id,
1235
+ resource_instance_id,
1236
+ action,
1237
+ decision,
1238
+ reason_code,
1239
+ safe_message,
1240
+ used_support_elevation,
1241
+ metadata,
1242
+ created_at
1243
+ FROM weave.authorization_decision_events
1244
+ WHERE organization_id = $1
1245
+ AND (
1246
+ $2::uuid IS NULL
1247
+ OR acting_user_id = $2::uuid
1248
+ )
1249
+ AND (
1250
+ $3::text IS NULL
1251
+ OR feature_flag_key = $3::text
1252
+ )
1253
+ AND (
1254
+ $4::text IS NULL
1255
+ OR resource_id = $4::text
1256
+ )
1257
+ AND (
1258
+ $5::text IS NULL
1259
+ OR action = $5::text
1260
+ )
1261
+ AND (
1262
+ $6::text IS NULL
1263
+ OR decision = $6::text
1264
+ )
1265
+ ORDER BY created_at DESC, id DESC
1266
+ LIMIT $8 OFFSET $7`;
1267
+ async function listAuthorizationDecisionEventsByOrganization(client, args) {
1268
+ const result = await client.query({
1269
+ text: exports.listAuthorizationDecisionEventsByOrganizationQuery,
1270
+ values: [args.organizationId, args.actingUserId, args.featureFlagKey, args.resourceId, args.action, args.decision, args.pageOffset, args.pageSize],
1271
+ rowMode: "array"
1272
+ });
1273
+ return result.rows.map(row => {
1274
+ return {
1275
+ id: row[0],
1276
+ organizationId: row[1],
1277
+ actingUserId: row[2],
1278
+ actorOrganizationMembershipId: row[3],
1279
+ actorIdentityLinkId: row[4],
1280
+ rbacRoleIds: row[5],
1281
+ orgTeamIds: row[6],
1282
+ platformGrantIds: row[7],
1283
+ supportAccessSessionId: row[8],
1284
+ featureFlagKey: row[9],
1285
+ featureFlagProvider: row[10],
1286
+ featureFlagVariant: row[11],
1287
+ resourceId: row[12],
1288
+ resourceInstanceId: row[13],
1289
+ action: row[14],
1290
+ decision: row[15],
1291
+ reasonCode: row[16],
1292
+ safeMessage: row[17],
1293
+ usedSupportElevation: row[18],
1294
+ metadata: row[19],
1295
+ createdAt: row[20]
1296
+ };
1297
+ });
1298
+ }
1120
1299
  exports.createApplicationSessionQuery = `-- name: CreateApplicationSession :one
1121
1300
  INSERT INTO weave.application_sessions (
1122
1301
  user_id,