@aiquants/auth-directory-drizzle 0.8.0 → 0.8.1

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/index.d.mts CHANGED
@@ -1,21 +1,10 @@
1
- import { AuthDirectoryCatalogGroup, AuthDirectoryCatalogSnapshot, AuthGroupExternalLink, AuthDirectoryMembershipMode, AuthDirectoryStatus, AuthAllowlistEntry } from '@aiquants/auth-core';
2
- import { TransactionRetryOptions } from '@aiquants/mssql';
3
- import * as drizzle_orm_mssql_core from 'drizzle-orm/mssql-core';
4
- import { AnyMsSqlColumn } from 'drizzle-orm/mssql-core';
5
- import { AuthzAdminStore } from '@aiquants/authz-core';
6
- import { AuthzTables, createAdminLockoutGuard } from '@aiquants/authz-drizzle';
7
- import { TenantMembershipPolicy, SyncAbort, AuthDirectoryMembershipMode as AuthDirectoryMembershipMode$1, LocalGroupSnapshot, DirectoryMember, ResolvedDirectoryMember, GroupSyncPlan, DirectoryGroup, DirectoryProvider, BlastRadiusPolicy } from '@aiquants/auth-directory-core';
8
-
9
- /**
10
- * @module db
11
- * @description Minimal query-builder shapes this adapter uses.
12
- * 本アダプタが使う最小の問い合わせビルダー形状。
13
- *
14
- * drizzle の具体型ではなく構造的な型で受けるのは、ホストが用意した `NodeMsSqlDatabase` の型
15
- * パラメータ (スキーマ・ロガー等) が配備ごとに違い、それを署名へ引き回すと利用側が
16
- * `as any` を書く羽目になるためである。実体は実行時にこれらを満たす。
17
- */
18
-
1
+ import { AuthDirectoryCatalogGroup, AuthDirectoryCatalogSnapshot, AuthGroupExternalLink, AuthDirectoryMembershipMode, AuthDirectoryStatus, AuthAllowlistEntry } from "@aiquants/auth-core";
2
+ import { TransactionRetryOptions } from "@aiquants/mssql";
3
+ import * as drizzle_orm_mssql_core from "drizzle-orm/mssql-core";
4
+ import { AnyMsSqlColumn } from "drizzle-orm/mssql-core";
5
+ import { AuthzAdminStore } from "@aiquants/authz-core";
6
+ import { AuthzTables, createAdminLockoutGuard } from "@aiquants/authz-drizzle";
7
+ import { TenantMembershipPolicy, SyncAbort, AuthDirectoryMembershipMode as AuthDirectoryMembershipMode$1, LocalGroupSnapshot, DirectoryMember, ResolvedDirectoryMember, GroupSyncPlan, DirectoryGroup, DirectoryProvider, BlastRadiusPolicy } from "@aiquants/auth-directory-core";
19
8
  type Rows<T> = PromiseLike<T[]>;
20
9
  interface SelectChain<T> extends Rows<T> {
21
10
  from(t: unknown): SelectChain<T>;
@@ -37,7 +26,6 @@ interface UpdateChain {
37
26
  interface DeleteChain {
38
27
  where(cond: unknown): PromiseLike<unknown>;
39
28
  }
40
- /** The database surface the directory adapter needs. ディレクトリアダプタが必要とする DB 面。 */
41
29
  interface DirectoryDb {
42
30
  select<T = Record<string, unknown>>(fields?: unknown): SelectChain<T>;
43
31
  insert(t: unknown): InsertChain;
@@ -45,62 +33,24 @@ interface DirectoryDb {
45
33
  delete(t: unknown): DeleteChain;
46
34
  transaction<T>(fn: (tx: DirectoryDb) => Promise<T>, config?: unknown): Promise<T>;
47
35
  }
48
- /** Ensures a connection exists before the first statement. 最初の文の前に接続を確立する処理。 */
49
36
  type EnsureConnection = () => Promise<void>;
50
- /** Options every factory in this adapter shares. 本アダプタの各ファクトリが共通で受ける設定。 */
51
37
  type TransactionalOptions = {
52
- /**
53
- * Retry policy for transactions SQL Server chose as the deadlock victim. See `@aiquants/mssql`.
54
- * サーバがロールバックしたトランザクションの再試行方針。
55
- *
56
- * 鍵の範囲が重なる並行操作はデッドロックしうる。犠牲に選ばれた側はサーバによって
57
- * ロールバックされる — 何もコミットされていないので、読み直して判定し直す再実行が正しい。
58
- * 既定で 3 回試す。`{ attempts: 1 }` で再試行しない。
59
- */
60
38
  transactionRetry?: TransactionRetryOptions;
61
39
  };
62
- /**
63
- * Builds the one function every transaction in this adapter goes through.
64
- *
65
- * 本アダプタの全トランザクションが通る、唯一の関数を組み立てる処理。
66
- *
67
- * 各呼び出し箇所で `db.transaction` を直に呼ぶと、再試行を足す・方針を変えるたびに 9 箇所を
68
- * 触ることになり、いずれ 1 箇所だけ取り残される。入口を 1 つにする。
69
- *
70
- * ⚠️ **閉包を DB の外へ波及させないこと。** 再実行は毎回はじめから走るため、ロールバックで元に
71
- * 戻らない副作用 (外部への送信・呼び出し元の配列への追加) を閉包へ入れてはならない。これは
72
- * 再試行の有無に関わらず、トランザクションに要求される性質である。
73
- *
74
- * @param db - 対象の DB 面。
75
- * @param opts - 再試行方針を含む設定。
76
- * @returns トランザクションを開いて閉包を走らせる関数。
77
- */
78
40
  declare function transactionRunner(db: DirectoryDb, opts: TransactionalOptions): <T>(fn: (tx: DirectoryDb) => Promise<T>) => Promise<T>;
79
-
80
- /** Minimal shape of a table this schema points a foreign key at. 外部キーの参照先に要る最小形。 */
81
41
  type ReferencedTable = {
82
42
  id: AnyMsSqlColumn;
83
43
  };
84
- /**
85
- * Physical name of the provenance discriminator carried by an external link row.
86
- * 外部リンク行が持つ供給元識別子の物理名。
87
- */
88
44
  declare const AUTH_DIRECTORY_PROVIDER_COLUMN = "provider";
89
- /**
90
- * Table names that carry {@link AUTHZ_TENANT_COLUMN}.
91
- * テナント列を持つ表の名前一覧。
92
- *
93
- * `TDGroupMemberEmail` が含まれないのは、親グループからテナントを継承するためである。
94
- */
95
- declare const AUTH_DIRECTORY_TENANT_SCOPED_TABLES: readonly ["TDGroupExternalLink", "TDTenantMembershipGroup", "TDAllowlistGroup", "TDDirectorySyncRequest", "TDDirectoryCatalog", "TMDirectoryCatalogObservation", "TMAllowlist"];
96
- /**
97
- * Builds the identity-side tables under an arbitrary schema name.
98
- * 任意のスキーマ名の下に identity 側テーブル群を構築する処理。
99
- *
100
- * @param schemaName Schema the tables live in. テーブルを配置するスキーマ名。
101
- * @param opts Injected tables the foreign keys point at. 外部キーの参照先として注入する表。
102
- * @returns Every identity-side table, keyed by table name. 表名をキーにしたテーブル群。
103
- */
45
+ declare const AUTH_DIRECTORY_TENANT_SCOPED_TABLES: readonly [
46
+ "TDGroupExternalLink",
47
+ "TDTenantMembershipGroup",
48
+ "TDAllowlistGroup",
49
+ "TDDirectorySyncRequest",
50
+ "TDDirectoryCatalog",
51
+ "TMDirectoryCatalogObservation",
52
+ "TMAllowlist"
53
+ ];
104
54
  declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts: {
105
55
  groupTable: ReferencedTable;
106
56
  userTable: ReferencedTable;
@@ -136,7 +86,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
136
86
  isPrimaryKey: false;
137
87
  isAutoincrement: false;
138
88
  hasRuntimeDefault: false;
139
- enumValues: [string, ...string[]];
89
+ enumValues: [
90
+ string,
91
+ ...string[]
92
+ ];
140
93
  baseColumn: never;
141
94
  identity: undefined;
142
95
  generated: undefined;
@@ -168,7 +121,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
168
121
  isPrimaryKey: false;
169
122
  isAutoincrement: false;
170
123
  hasRuntimeDefault: false;
171
- enumValues: [string, ...string[]];
124
+ enumValues: [
125
+ string,
126
+ ...string[]
127
+ ];
172
128
  baseColumn: never;
173
129
  identity: undefined;
174
130
  generated: undefined;
@@ -216,7 +172,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
216
172
  isPrimaryKey: false;
217
173
  isAutoincrement: false;
218
174
  hasRuntimeDefault: false;
219
- enumValues: [string, ...string[]];
175
+ enumValues: [
176
+ string,
177
+ ...string[]
178
+ ];
220
179
  baseColumn: never;
221
180
  identity: undefined;
222
181
  generated: undefined;
@@ -232,7 +191,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
232
191
  isPrimaryKey: false;
233
192
  isAutoincrement: false;
234
193
  hasRuntimeDefault: false;
235
- enumValues: [string, ...string[]];
194
+ enumValues: [
195
+ string,
196
+ ...string[]
197
+ ];
236
198
  baseColumn: never;
237
199
  identity: undefined;
238
200
  generated: undefined;
@@ -248,7 +210,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
248
210
  isPrimaryKey: false;
249
211
  isAutoincrement: false;
250
212
  hasRuntimeDefault: false;
251
- enumValues: [string, ...string[]];
213
+ enumValues: [
214
+ string,
215
+ ...string[]
216
+ ];
252
217
  baseColumn: never;
253
218
  identity: undefined;
254
219
  generated: undefined;
@@ -264,7 +229,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
264
229
  isPrimaryKey: false;
265
230
  isAutoincrement: false;
266
231
  hasRuntimeDefault: false;
267
- enumValues: [string, ...string[]];
232
+ enumValues: [
233
+ string,
234
+ ...string[]
235
+ ];
268
236
  baseColumn: never;
269
237
  identity: undefined;
270
238
  generated: undefined;
@@ -280,7 +248,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
280
248
  isPrimaryKey: false;
281
249
  isAutoincrement: false;
282
250
  hasRuntimeDefault: false;
283
- enumValues: [string, ...string[]];
251
+ enumValues: [
252
+ string,
253
+ ...string[]
254
+ ];
284
255
  baseColumn: never;
285
256
  identity: undefined;
286
257
  generated: undefined;
@@ -328,7 +299,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
328
299
  isPrimaryKey: false;
329
300
  isAutoincrement: false;
330
301
  hasRuntimeDefault: false;
331
- enumValues: [string, ...string[]];
302
+ enumValues: [
303
+ string,
304
+ ...string[]
305
+ ];
332
306
  baseColumn: never;
333
307
  identity: undefined;
334
308
  generated: undefined;
@@ -383,7 +357,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
383
357
  isPrimaryKey: false;
384
358
  isAutoincrement: false;
385
359
  hasRuntimeDefault: false;
386
- enumValues: [string, ...string[]];
360
+ enumValues: [
361
+ string,
362
+ ...string[]
363
+ ];
387
364
  baseColumn: never;
388
365
  identity: undefined;
389
366
  generated: undefined;
@@ -415,7 +392,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
415
392
  isPrimaryKey: false;
416
393
  isAutoincrement: false;
417
394
  hasRuntimeDefault: false;
418
- enumValues: [string, ...string[]];
395
+ enumValues: [
396
+ string,
397
+ ...string[]
398
+ ];
419
399
  baseColumn: never;
420
400
  identity: undefined;
421
401
  generated: undefined;
@@ -463,7 +443,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
463
443
  isPrimaryKey: false;
464
444
  isAutoincrement: false;
465
445
  hasRuntimeDefault: false;
466
- enumValues: [string, ...string[]];
446
+ enumValues: [
447
+ string,
448
+ ...string[]
449
+ ];
467
450
  baseColumn: never;
468
451
  identity: undefined;
469
452
  generated: undefined;
@@ -479,7 +462,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
479
462
  isPrimaryKey: false;
480
463
  isAutoincrement: false;
481
464
  hasRuntimeDefault: false;
482
- enumValues: [string, ...string[]];
465
+ enumValues: [
466
+ string,
467
+ ...string[]
468
+ ];
483
469
  baseColumn: never;
484
470
  identity: undefined;
485
471
  generated: undefined;
@@ -550,7 +536,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
550
536
  isPrimaryKey: false;
551
537
  isAutoincrement: false;
552
538
  hasRuntimeDefault: false;
553
- enumValues: [string, ...string[]];
539
+ enumValues: [
540
+ string,
541
+ ...string[]
542
+ ];
554
543
  baseColumn: never;
555
544
  identity: undefined;
556
545
  generated: undefined;
@@ -566,7 +555,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
566
555
  isPrimaryKey: false;
567
556
  isAutoincrement: false;
568
557
  hasRuntimeDefault: false;
569
- enumValues: [string, ...string[]];
558
+ enumValues: [
559
+ string,
560
+ ...string[]
561
+ ];
570
562
  baseColumn: never;
571
563
  identity: undefined;
572
564
  generated: undefined;
@@ -637,7 +629,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
637
629
  isPrimaryKey: false;
638
630
  isAutoincrement: false;
639
631
  hasRuntimeDefault: false;
640
- enumValues: [string, ...string[]];
632
+ enumValues: [
633
+ string,
634
+ ...string[]
635
+ ];
641
636
  baseColumn: never;
642
637
  identity: undefined;
643
638
  generated: undefined;
@@ -669,7 +664,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
669
664
  isPrimaryKey: false;
670
665
  isAutoincrement: false;
671
666
  hasRuntimeDefault: false;
672
- enumValues: [string, ...string[]];
667
+ enumValues: [
668
+ string,
669
+ ...string[]
670
+ ];
673
671
  baseColumn: never;
674
672
  identity: undefined;
675
673
  generated: undefined;
@@ -701,7 +699,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
701
699
  isPrimaryKey: false;
702
700
  isAutoincrement: false;
703
701
  hasRuntimeDefault: false;
704
- enumValues: [string, ...string[]];
702
+ enumValues: [
703
+ string,
704
+ ...string[]
705
+ ];
705
706
  baseColumn: never;
706
707
  identity: undefined;
707
708
  generated: undefined;
@@ -740,7 +741,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
740
741
  isPrimaryKey: false;
741
742
  isAutoincrement: false;
742
743
  hasRuntimeDefault: false;
743
- enumValues: [string, ...string[]];
744
+ enumValues: [
745
+ string,
746
+ ...string[]
747
+ ];
744
748
  baseColumn: never;
745
749
  identity: undefined;
746
750
  generated: undefined;
@@ -772,7 +776,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
772
776
  isPrimaryKey: false;
773
777
  isAutoincrement: false;
774
778
  hasRuntimeDefault: false;
775
- enumValues: [string, ...string[]];
779
+ enumValues: [
780
+ string,
781
+ ...string[]
782
+ ];
776
783
  baseColumn: never;
777
784
  identity: undefined;
778
785
  generated: undefined;
@@ -804,7 +811,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
804
811
  isPrimaryKey: false;
805
812
  isAutoincrement: false;
806
813
  hasRuntimeDefault: false;
807
- enumValues: [string, ...string[]];
814
+ enumValues: [
815
+ string,
816
+ ...string[]
817
+ ];
808
818
  baseColumn: never;
809
819
  identity: undefined;
810
820
  generated: undefined;
@@ -868,7 +878,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
868
878
  isPrimaryKey: false;
869
879
  isAutoincrement: false;
870
880
  hasRuntimeDefault: false;
871
- enumValues: [string, ...string[]];
881
+ enumValues: [
882
+ string,
883
+ ...string[]
884
+ ];
872
885
  baseColumn: never;
873
886
  identity: undefined;
874
887
  generated: undefined;
@@ -884,7 +897,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
884
897
  isPrimaryKey: false;
885
898
  isAutoincrement: false;
886
899
  hasRuntimeDefault: false;
887
- enumValues: [string, ...string[]];
900
+ enumValues: [
901
+ string,
902
+ ...string[]
903
+ ];
888
904
  baseColumn: never;
889
905
  identity: undefined;
890
906
  generated: undefined;
@@ -923,7 +939,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
923
939
  isPrimaryKey: false;
924
940
  isAutoincrement: false;
925
941
  hasRuntimeDefault: false;
926
- enumValues: [string, ...string[]];
942
+ enumValues: [
943
+ string,
944
+ ...string[]
945
+ ];
927
946
  baseColumn: never;
928
947
  identity: undefined;
929
948
  generated: undefined;
@@ -955,7 +974,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
955
974
  isPrimaryKey: false;
956
975
  isAutoincrement: false;
957
976
  hasRuntimeDefault: false;
958
- enumValues: [string, ...string[]];
977
+ enumValues: [
978
+ string,
979
+ ...string[]
980
+ ];
959
981
  baseColumn: never;
960
982
  identity: undefined;
961
983
  generated: undefined;
@@ -971,7 +993,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
971
993
  isPrimaryKey: false;
972
994
  isAutoincrement: false;
973
995
  hasRuntimeDefault: false;
974
- enumValues: [string, ...string[]];
996
+ enumValues: [
997
+ string,
998
+ ...string[]
999
+ ];
975
1000
  baseColumn: never;
976
1001
  identity: undefined;
977
1002
  generated: undefined;
@@ -987,7 +1012,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
987
1012
  isPrimaryKey: false;
988
1013
  isAutoincrement: false;
989
1014
  hasRuntimeDefault: false;
990
- enumValues: [string, ...string[]];
1015
+ enumValues: [
1016
+ string,
1017
+ ...string[]
1018
+ ];
991
1019
  baseColumn: never;
992
1020
  identity: undefined;
993
1021
  generated: undefined;
@@ -1003,7 +1031,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1003
1031
  isPrimaryKey: false;
1004
1032
  isAutoincrement: false;
1005
1033
  hasRuntimeDefault: false;
1006
- enumValues: [string, ...string[]];
1034
+ enumValues: [
1035
+ string,
1036
+ ...string[]
1037
+ ];
1007
1038
  baseColumn: never;
1008
1039
  identity: undefined;
1009
1040
  generated: undefined;
@@ -1019,7 +1050,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1019
1050
  isPrimaryKey: false;
1020
1051
  isAutoincrement: false;
1021
1052
  hasRuntimeDefault: false;
1022
- enumValues: [string, ...string[]];
1053
+ enumValues: [
1054
+ string,
1055
+ ...string[]
1056
+ ];
1023
1057
  baseColumn: never;
1024
1058
  identity: undefined;
1025
1059
  generated: undefined;
@@ -1035,7 +1069,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1035
1069
  isPrimaryKey: false;
1036
1070
  isAutoincrement: false;
1037
1071
  hasRuntimeDefault: false;
1038
- enumValues: [string, ...string[]];
1072
+ enumValues: [
1073
+ string,
1074
+ ...string[]
1075
+ ];
1039
1076
  baseColumn: never;
1040
1077
  identity: undefined;
1041
1078
  generated: undefined;
@@ -1106,7 +1143,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1106
1143
  isPrimaryKey: false;
1107
1144
  isAutoincrement: false;
1108
1145
  hasRuntimeDefault: false;
1109
- enumValues: [string, ...string[]];
1146
+ enumValues: [
1147
+ string,
1148
+ ...string[]
1149
+ ];
1110
1150
  baseColumn: never;
1111
1151
  identity: undefined;
1112
1152
  generated: undefined;
@@ -1138,7 +1178,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1138
1178
  isPrimaryKey: false;
1139
1179
  isAutoincrement: false;
1140
1180
  hasRuntimeDefault: false;
1141
- enumValues: [string, ...string[]];
1181
+ enumValues: [
1182
+ string,
1183
+ ...string[]
1184
+ ];
1142
1185
  baseColumn: never;
1143
1186
  identity: undefined;
1144
1187
  generated: undefined;
@@ -1170,7 +1213,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1170
1213
  isPrimaryKey: false;
1171
1214
  isAutoincrement: false;
1172
1215
  hasRuntimeDefault: false;
1173
- enumValues: [string, ...string[]];
1216
+ enumValues: [
1217
+ string,
1218
+ ...string[]
1219
+ ];
1174
1220
  baseColumn: never;
1175
1221
  identity: undefined;
1176
1222
  generated: undefined;
@@ -1186,7 +1232,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1186
1232
  isPrimaryKey: false;
1187
1233
  isAutoincrement: false;
1188
1234
  hasRuntimeDefault: false;
1189
- enumValues: [string, ...string[]];
1235
+ enumValues: [
1236
+ string,
1237
+ ...string[]
1238
+ ];
1190
1239
  baseColumn: never;
1191
1240
  identity: undefined;
1192
1241
  generated: undefined;
@@ -1257,7 +1306,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1257
1306
  isPrimaryKey: false;
1258
1307
  isAutoincrement: false;
1259
1308
  hasRuntimeDefault: false;
1260
- enumValues: [string, ...string[]];
1309
+ enumValues: [
1310
+ string,
1311
+ ...string[]
1312
+ ];
1261
1313
  baseColumn: never;
1262
1314
  identity: undefined;
1263
1315
  generated: undefined;
@@ -1289,7 +1341,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1289
1341
  isPrimaryKey: false;
1290
1342
  isAutoincrement: false;
1291
1343
  hasRuntimeDefault: false;
1292
- enumValues: [string, ...string[]];
1344
+ enumValues: [
1345
+ string,
1346
+ ...string[]
1347
+ ];
1293
1348
  baseColumn: never;
1294
1349
  identity: undefined;
1295
1350
  generated: undefined;
@@ -1305,7 +1360,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1305
1360
  isPrimaryKey: false;
1306
1361
  isAutoincrement: false;
1307
1362
  hasRuntimeDefault: false;
1308
- enumValues: [string, ...string[]];
1363
+ enumValues: [
1364
+ string,
1365
+ ...string[]
1366
+ ];
1309
1367
  baseColumn: never;
1310
1368
  identity: undefined;
1311
1369
  generated: undefined;
@@ -1321,7 +1379,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1321
1379
  isPrimaryKey: false;
1322
1380
  isAutoincrement: false;
1323
1381
  hasRuntimeDefault: false;
1324
- enumValues: [string, ...string[]];
1382
+ enumValues: [
1383
+ string,
1384
+ ...string[]
1385
+ ];
1325
1386
  baseColumn: never;
1326
1387
  identity: undefined;
1327
1388
  generated: undefined;
@@ -1337,7 +1398,10 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1337
1398
  isPrimaryKey: false;
1338
1399
  isAutoincrement: false;
1339
1400
  hasRuntimeDefault: false;
1340
- enumValues: [string, ...string[]];
1401
+ enumValues: [
1402
+ string,
1403
+ ...string[]
1404
+ ];
1341
1405
  baseColumn: never;
1342
1406
  identity: undefined;
1343
1407
  generated: undefined;
@@ -1346,7 +1410,6 @@ declare function defineAuthDirectorySchema<S extends string>(schemaName: S, opts
1346
1410
  dialect: "mssql";
1347
1411
  }>;
1348
1412
  };
1349
- /** Explicit alias for the tables `defineAuthDirectorySchema` returns (avoids TS2742). 明示型。 */
1350
1413
  type AuthDirectoryTables = {
1351
1414
  TDGroupExternalLink: ReturnType<typeof defineAuthDirectorySchema>["TDGroupExternalLink"];
1352
1415
  TDGroupMemberEmail: ReturnType<typeof defineAuthDirectorySchema>["TDGroupMemberEmail"];
@@ -1357,544 +1420,95 @@ type AuthDirectoryTables = {
1357
1420
  TMDirectoryCatalogObservation: ReturnType<typeof defineAuthDirectorySchema>["TMDirectoryCatalogObservation"];
1358
1421
  TMAllowlist: ReturnType<typeof defineAuthDirectorySchema>["TMAllowlist"];
1359
1422
  };
1360
-
1361
- /**
1362
- * @module catalog-store
1363
- * @description The upstream group list, written by the sync job and read by the web.
1364
- * 同期ジョブが書き、web が読む、上流のグループ一覧。
1365
- *
1366
- * ⚠️ **この表と、このモジュールが在る理由は境界である。** ドメイン全体委任の資格情報は組織の
1367
- * ディレクトリを丸ごと読めるため、外部からの要求を終端する web プロセスには置かない。上流へ
1368
- * 届くのは同期ジョブだけとし、web は「ジョブが書いた行」を読む。管理面の選択欄は利便のための
1369
- * 読み取りであり、その利便のために資格情報の置き場所を動かしてよい理由にはならない。
1370
- *
1371
- * ここには生産側 (`replace`) と消費側 (`read`) の両方が居る。プロセスを分ける仕掛けは
1372
- * import の可否ではなく **資格情報を持つかどうか** であり、`replace` を呼べても上流を
1373
- * 読めないプロセスは書くべき内容を持てない。
1374
- */
1375
-
1376
- /**
1377
- * One upstream group, as observed. 観測した上流グループ 1 件。
1378
- *
1379
- * ⚠️ 別名ではなく `@aiquants/auth-core` の型そのものである。層ごとに「同じ意味の別の型」を宣言すると、
1380
- * 構造的部分型のせいでどの境界も通ってしまい、上流へ足した欄が途中で黙って捨てられる。
1381
- */
1382
1423
  type DirectoryCatalogEntry = AuthDirectoryCatalogGroup;
1383
- /** What the web reads. web が読む内容 ({@link AuthDirectoryCatalogSnapshot} の項目名違いではなく同一契約)。 */
1384
1424
  type DirectoryCatalogSnapshot = AuthDirectoryCatalogSnapshot;
1385
- /** Options a reader needs. 読み手が必要とするオプション。 */
1386
1425
  type DirectoryCatalogReaderOptions = {
1387
1426
  ensureConnection?: EnsureConnection;
1388
1427
  };
1389
- /**
1390
- * Options a writer needs. 書き手が必要とするオプション。
1391
- *
1392
- * ⚠️ 読み手にこれを要求してはならない。読むだけの呼び出し側に時計と監査主体を持たせると、
1393
- * その場で `replace` を呼ぶ経路が「既に手元にあるもの」になり、上流を読めないプロセスが
1394
- * 観測時刻を詐称できてしまう。だから生成関数を 2 つに分けている。
1395
- */
1396
1428
  type DirectoryCatalogWriterOptions = DirectoryCatalogReaderOptions & TransactionalOptions & {
1397
- /** Injected clock — one observation must carry one timestamp. 注入時計。 */
1398
1429
  now: () => Date;
1399
- /** Who the audit columns record. 監査列に残す主体。 */
1400
1430
  actor: string;
1401
1431
  };
1402
- /**
1403
- * Creates the write side of the catalog. 候補一覧の **書き手** を生成する処理。
1404
- *
1405
- * ⚠️ これを呼べるのは上流の資格情報を持つプロセスだけであるべきである。読むだけの側は
1406
- * {@link createDirectoryCatalogReader} を使う — 分けているのは整理のためではなく、「読むだけの
1407
- * 呼び出し側の手元に `replace` が在る」状態そのものを作らないためである。
1408
- *
1409
- * @param dbUnknown - Drizzle database instance. drizzle のデータベースインスタンス。
1410
- * @param tables - Directory tables (owns the catalog). ディレクトリ表 (候補一覧の所有者)。
1411
- * @param opts - Connection, clock and actor. 接続・時計・監査主体。
1412
- * @returns The `replace` operation. 置き換え操作。
1413
- */
1414
1432
  declare function createDirectoryCatalogWriter(dbUnknown: unknown, tables: AuthDirectoryTables, opts: DirectoryCatalogWriterOptions): {
1415
- /**
1416
- * Replaces this tenant's catalog with what the upstream currently answers.
1417
- * このテナントの候補一覧を、上流の現在の答えで置き換える処理。
1418
- *
1419
- * ⚠️ 差分更新ではなく **全置換** である。消えたグループを残すと、管理面はそれを選ばせ続け、
1420
- * 選んだ運用者は 10 分後に「上流に無い」と言われる。1 つのトランザクションで消してから
1421
- * 書くことで、途中の状態を web に読ませない。
1422
- *
1423
- * @param tenantId - Owner tenant. 所有テナント。
1424
- * @param provider - Upstream provider key. 上流プロバイダのキー。
1425
- * @param entries - The upstream's current answer. 上流の現在の答え。
1426
- * @returns How many rows were written. 書き込んだ行数。
1427
- */
1428
1433
  replace(tenantId: string, provider: string, entries: readonly DirectoryCatalogEntry[]): Promise<number>;
1429
1434
  };
1430
- /**
1431
- * Creates the read side of the catalog. 候補一覧の **読み手** を生成する処理。
1432
- *
1433
- * 時計も監査主体も要らない。要らないものを求めないことが、この関数がここに在る理由である。
1434
- *
1435
- * @param dbUnknown - Drizzle database instance. drizzle のデータベースインスタンス。
1436
- * @param tables - Directory tables (owns the catalog). ディレクトリ表 (候補一覧の所有者)。
1437
- * @param opts - Connection handling. 接続の扱い。
1438
- * @returns The `read` operation. 読み取り操作。
1439
- */
1440
1435
  declare function createDirectoryCatalogReader(dbUnknown: unknown, tables: AuthDirectoryTables, opts?: DirectoryCatalogReaderOptions): {
1441
- /**
1442
- * Reads this tenant's catalog. このテナントの候補一覧を読む処理。
1443
- *
1444
- * ⚠️ **観測の有無は行数から導かない。** 上流を正しく読めて答えが 0 件だった配備 (借用先の
1445
- * 権限が狭い、対象 OU が空) と、同期が一度も走っていない配備は、候補一覧の行数ではどちらも
1446
- * 0 である。前者を「同期が動いていない」と診断すると、運用は健全な部品を調べに行く。
1447
- * `observedAt` は観測記録そのものから取り、`null` は **一度も観測していない** だけを意味する。
1448
- *
1449
- * @param tenantId - Owner tenant. 所有テナント。
1450
- * @param provider - Upstream provider key. 上流プロバイダのキー。
1451
- * @returns The groups and the observation time. グループと観測時刻。
1452
- */
1453
1436
  read(tenantId: string, provider: string): Promise<DirectoryCatalogSnapshot>;
1454
1437
  };
1455
-
1456
- /**
1457
- * @module guards
1458
- * @description Keeps administrative roles off groups whose membership an upstream directory owns.
1459
- * 所属の所有者が上流ディレクトリにあるグループへ、管理ロールが付かないようにする。
1460
- *
1461
- * **不変条件は状態の性質であって、遷移の性質ではない。**
1462
- *
1463
- * 最初の実装は `assignGroupRole` だけを差し替えていた。しかしそれは「外部グループへ管理ロールを
1464
- * 割り当てる」という 1 つの遷移を塞いだにすぎず、**無害なロールを外部グループへ割り当ててから、
1465
- * そのロールを管理ロールへ昇格させる**という順序が開いたままだった。不変条件を守るには、それを
1466
- * 崩し得るすべての遷移を塞ぐ必要がある。
1467
- *
1468
- * 崩し得る遷移は 3 つある。
1469
- *
1470
- * | # | 遷移 | 塞ぐもの |
1471
- * | --- | --- | --- |
1472
- * | 1 | 外部グループが管理ロールを得る | `assignGroupRole` |
1473
- * | 2 | 外部グループが持つロールが管理ロールになる | `createGrant` |
1474
- * | 3 | 管理ロールを持つグループが外部連携される | `assertGroupMayBeLinked` |
1475
- * | 4 | 外部グループが持つロールの付与が差し替わって管理ロールになる | `updateGrant` |
1476
- *
1477
- * ⚠️ `updateGrant` を「塞ぐ必要がない」と読んではならない。行数だけを見る論法 —
1478
- * 「`(role_id, resource_id, action)` は一意だから、アクションを差し替えても集合は増えない」 —
1479
- * は **ロール 1 つの中でしか成り立たない**。判定はこのファイルのどの遷移でも
1480
- * **グループの全ロールの合併** で行う。ロール 1 が `{read, create}`、ロール 2 が
1481
- * `{read, update}` を持つ外部グループでは合併は 3 アクションで、どちらの割当も正当に通る。
1482
- * そこでロール 2 の `read` を `delete` へ差し替えると、ロール 2 の行数は 2 のままなのに
1483
- * 合併は 4 アクションに達し、上流のディレクトリ管理者がこの配備の管理者を決められるようになる。
1484
- *
1485
- * `setRoleActive` も塞ぐ必要がない。遷移 1 の判定はロールの有効・無効を見ないため、無効な管理
1486
- * ロールも外部グループへは割り当てられない。したがって「無効な管理ロールを外部グループが保持した
1487
- * まま有効化される」という状態には到達し得ない。
1488
- *
1489
- * **なぜ認可パッケージの中で判定しないのか。** 判定を `@aiquants/authz-drizzle` の管理ストアへ
1490
- * 埋め込むと、認可パッケージがグループの「出所」という identity 側の概念を知ることになる。依存の
1491
- * 向きは auth → authz の一方通行で保ちたいので、包む側 (identity 側) から課す。
1492
- *
1493
- * **なぜ禁止するのか。** 外部グループの所属は上流の管理者が変更できる。そこへ管理ロールを付けると、
1494
- * 上流側の 1 操作がこの配備の管理者を増やしたり、逆に最後の管理者を奪ったりする。ブレークグラス
1495
- * 経路は常にローカルに残しておく必要がある。
1496
- */
1497
-
1498
- /** The link lookup this guard needs. 本ガードが必要とするリンク参照。 */
1499
1438
  type ExternalLinkLookup = {
1500
- /**
1501
- * The upstream key of the group, or `null` when its membership is locally managed.
1502
- * そのグループの上流キー。ローカル管理なら `null`。
1503
- *
1504
- * 「外部かどうか」と「拒否メッセージに出す名前」を 1 回の照会で返す。判定のためだけに
1505
- * 引いて、名前のためにもう一度引く形にすると、拒否のたびに往復が 2 倍になる。
1506
- *
1507
- * ⚠️ `runner` を渡された実装は、**必ずその上で** 引くこと。別接続で引くと、この読み取りの
1508
- * 結果を前提に書き込む呼び出し側にとって前提が保たれない (読んだ後・書く前に連携が作られる)。
1509
- */
1510
1439
  externalGroupKey(tenantId: string, groupId: number, runner?: unknown): Promise<string | null>;
1511
1440
  };
1512
- /** Configuration of the guard. ガードの構成。 */
1513
1441
  type ExternalGroupGuardOptions = {
1514
1442
  linkLookup: ExternalLinkLookup;
1515
- /** App key the administrative resource belongs to. 管理リソースが属するアプリキー。 */
1516
1443
  adminAppKey: string;
1517
- /** Resource key that grants administration. 管理を与えるリソースキー。 */
1518
1444
  adminResourceKey: string;
1519
- /**
1520
- * Refusal message. 拒否メッセージ。
1521
- *
1522
- * @param roleKey Role that would have conferred administration. 管理権を与えることになるロール。
1523
- * @param groupKey Group that would have held it. それを保持することになるグループ。
1524
- */
1525
1445
  message: (roleKey: string, groupKey: string) => string;
1526
1446
  };
1527
- /** Default refusal message (Japanese, matching the admin UI's locale). 既定の拒否メッセージ。 */
1528
1447
  declare const defaultExternalGroupGuardMessage: (roleKey: string, groupKey: string) => string;
1529
- /**
1530
- * Wraps an authorization admin store so administrative power cannot reach an external group.
1531
- * 外部グループへ管理権が届かないよう認可管理ストアを包む処理。
1532
- *
1533
- * `assignGroupRole` と `createGrant` を差し替え、残りは透過的に委譲する。3 番目の方向
1534
- * (連携の開始) は {@link assertGroupMayBeLinked} が担い、リンクを作る側が必ず通す。
1535
- *
1536
- * @param store Store to wrap. 包む対象のストア。
1537
- * @param opts Link lookup and administrative resource identity. リンク参照と管理リソースの同定。
1538
- * @returns A store with the same surface. 同一表面のストア。
1539
- */
1540
1448
  declare function withExternalGroupGuards<R>(store: AuthzAdminStore<R>, opts: ExternalGroupGuardOptions): AuthzAdminStore<R>;
1541
- /**
1542
- * Refuses to link a group that already holds an administrative role.
1543
- * 既に管理ロールを保持しているグループの外部連携を拒否する処理。
1544
- *
1545
- * 3 つ目の方向。これを通さずにリンクを作ると、ローカルで管理ロールを付けてから連携させる経路が
1546
- * 残る。{@link withExternalGroupGuards} と違って呼び出し側が忘れ得るため、リンクを作る側の
1547
- * 構成に必須ポートとして組み込むこと。
1548
- *
1549
- * @param store Authorization admin store used to read the grants. 付与を読む認可管理ストア。
1550
- * @param tenantId Tenant the group belongs to. グループが属するテナント。
1551
- * @param groupId Group about to be linked. 連携しようとしているグループ。
1552
- * @param opts Administrative resource identity and refusal message. 管理リソースの同定と文言。
1553
- * @returns Nothing; returns normally only when linking is allowed. 許可される場合のみ正常復帰。
1554
- * @throws {Error} When the group holds the administrative role. 管理ロールを保持している場合。
1555
- */
1556
1449
  declare function assertGroupMayBeLinked(store: AuthzAdminStore, tenantId: string, groupId: number, opts: Pick<ExternalGroupGuardOptions, "adminAppKey" | "adminResourceKey" | "message">): Promise<void>;
1557
-
1558
- /**
1559
- * Resolves which member-ledger rows belong to one identity.
1560
- * 台帳のどの行が 1 人の identity のものかを解決するモジュール。
1561
- *
1562
- * 台帳 (`TDGroupMemberEmail`) は「上流に居る人」を、ローカルユーザーへ解決できているかに
1563
- * 関わらず保持する。ここはその台帳から本人の行だけを取り出す唯一の場所であり、帰属証明
1564
- * (`listLedgerGroupIds`) と初回ログイン時の昇格 (`promoteLedgerForUser`) は同じ答えを見る。
1565
- * 突合規則が 2 箇所にあると、片方だけが「本人」と認めた瞬間に権限が食い違う。
1566
- */
1567
-
1568
- /** One ledger row attributed to an identity. identity に帰属した台帳 1 行。 */
1569
1450
  type LedgerIdentityRow = {
1570
1451
  ledgerId: number;
1571
1452
  groupId: number;
1572
- /** Inherited from the parent group — the ledger has no tenant column. 親グループ由来。 */
1573
1453
  tenantId: string;
1574
1454
  };
1575
- /** The two tables this resolution spans. この解決が跨る 2 表。 */
1576
1455
  type LedgerIdentityTables = {
1577
- /** `TDGroupMemberEmail`. */
1578
1456
  ledger: AuthDirectoryTables["TDGroupMemberEmail"];
1579
- /** `TMGroup` — owns the tenant and the active flag. テナントと有効フラグの所有者。 */
1580
1457
  group: AuthzTables["TMGroup"];
1581
1458
  };
1582
- /**
1583
- * Finds every ledger row that belongs to the identity, within one tenant.
1584
- * 1 テナント内で、その identity に属する台帳行をすべて探す処理。
1585
- *
1586
- * 上流 ID の一致は無条件に本人。アドレスの一致は、その行が **別の** 上流 ID に紐付いていない
1587
- * ときだけ本人である。単純な `OR` にすると後者の条件が消え、退職者のアドレスを再利用した
1588
- * 新入社員が前任者の所属をそのまま継承する。
1589
- *
1590
- * ⚠️ この優先順位は **行ごと** に適用する。「ID で当たったらアドレスは見ない」という打ち切りは
1591
- * 誤りで、同じ人物の行が ID 付きと ID 無しに混在すると ID 無しの行が丸ごと落ちる。
1592
- *
1593
- * @param db - Connected database surface. 接続済みの DB 面。
1594
- * @param tables - The ledger and its parent group table. 台帳と親グループ表。
1595
- * @param args - Tenant scope and the identity to match. テナント範囲と突合対象の identity。
1596
- * @returns Matching rows, deduplicated and ordered by ledger id. 重複排除・台帳 ID 昇順の一致行。
1597
- */
1598
1459
  declare function findLedgerRowsForIdentity(db: DirectoryDb, tables: LedgerIdentityTables, args: {
1599
1460
  tenantId: string;
1600
1461
  externalUserId: string | null;
1601
1462
  email: string;
1602
1463
  }): Promise<LedgerIdentityRow[]>;
1603
-
1604
- /**
1605
- * @module link-store
1606
- * @description Reads and writes the identity-side tables: external group links, the upstream member
1607
- * ledger, tenant membership proof, group-based login allowlist, and the sync request queue.
1608
- * identity 側テーブルの読み書き。外部グループリンク・上流メンバー台帳・テナント帰属証明・
1609
- * グループ単位のログイン許可・同期要求キュー。
1610
- *
1611
- * **テナントの扱いは 2 種類ある。混同すると事故になる。**
1612
- *
1613
- * - **絞り込み条件**: リンク・帰属証明グループ。読み書きの双方で SQL 述語になる。
1614
- * - **所有者**: グループ許可。管理 UI の編集スコープを決めるだけで、**ログイン判定では
1615
- * 述語にしない** — 認証はテナントの確定より前に起きるため、判定の時点でテナントは存在しない。
1616
- * このモジュールでは {@link createDirectoryLinkStore} の `isEmailAllowedByGroup` だけが
1617
- * その例外であり、意図的に全テナントを対象とする。
1618
- */
1619
-
1620
- /**
1621
- * Proves a group may become externally sourced. グループを外部供給にしてよいことの証明。
1622
- *
1623
- * `assertGroupMayBeLinked` を呼ぶだけのポートである。自由関数のままだと呼び出し側が忘れられ、
1624
- * 「ローカルで管理ロールを付けてから連携させる」経路が残る。必須の構成項目にすることで、
1625
- * 忘れることを構造的に不可能にする。
1626
- */
1627
1464
  type LinkableAssertion = {
1628
- /**
1629
- * Owns a transaction, proves the group may be linked on it, then runs `write` on the same runner.
1630
- * トランザクションを所有し、その上で連携可能であることを証明してから、同じランナーで `write` を実行する処理。
1631
- *
1632
- * ⚠️ **証明だけを返す形にしてはならない。** 証明と連携の作成が別のトランザクションだと、
1633
- * 証明を通った直後・リンクを作る前に、そのグループへ管理ロールを割り当てる操作が
1634
- * 割り込める。割り当て側の検査は「まだリンクが無い」と見て通り、連携側の検査は
1635
- * 「まだ管理ロールが無い」と見て通る — **どちらも単独では正しく、結果だけが不変条件を破る**。
1636
- *
1637
- * @param tenantId - Tenant that owns the group. グループを所有するテナント。
1638
- * @param groupId - Group about to become externally sourced. 外部供給にしようとしているグループ。
1639
- * @param write - The link creation, run on the proving transaction. 証明したトランザクション上で行う連携作成。
1640
- * @returns Nothing. 戻り値なし。
1641
- * @throws When the group holds an administrative role. 管理ロールを保持している場合。
1642
- */
1643
1465
  assertLinkableAndWrite(tenantId: string, groupId: number, write: (runner: unknown) => Promise<void>): Promise<void>;
1644
1466
  };
1645
- /** Options for the link store. リンクストアの構成。 */
1646
1467
  type DirectoryLinkStoreOptions = TransactionalOptions & {
1647
- /** Required — see {@link LinkableAssertion}. 必須 (忘れられる経路を作らないため)。 */
1648
1468
  linkable: LinkableAssertion;
1649
- /** Establishes the connection before the first statement. 最初の文の前に接続を確立する処理。 */
1650
1469
  ensureConnection?: EnsureConnection;
1651
- /**
1652
- * Seconds after which a successful sync counts as overdue. 同期が期限超過とみなされる秒数。
1653
- *
1654
- * 同期間隔の数倍を指定する。短すぎると常時警告が出て誰も読まなくなり、長すぎると停止に
1655
- * 気付けない。
1656
- */
1657
1470
  stalenessThresholdSec: number;
1658
- /** False when directory integration is not wired for this deployment. 未結線なら false。 */
1659
1471
  isEnabled: boolean;
1660
- /**
1661
- * Upstream system this deployment synchronizes against, e.g. `"google"`. 同期先の上流システム。
1662
- *
1663
- * 新しい連携を作る面へそのまま渡る。UI に供給元を焼き込ませないための注入点であり、
1664
- * 同期ランナーに設定する値と同一でなければならない — 食い違うと、作られたリンクは
1665
- * 同期側で「別プロバイダ」として恒久的に拒否される。
1666
- */
1667
1472
  provider: string;
1668
- /**
1669
- * Milliseconds to reuse a loaded tenant-membership policy. 帰属方針を再利用するミリ秒。
1670
- *
1671
- * 既定は 0 (毎回引き直す)。帰属証明は **権限を 1 件も読む前に毎リクエスト走る** ため、
1672
- * 証明グループを 1 つも宣言していない配備でも 3 表の結合が 1 往復増える。
1673
- *
1674
- * ⚠️ 既定を非 0 にしない。認可の判断材料を、頼まれてもいないのに黙って古くするライブラリは
1675
- * 信用できない。有効化は配備側が「どれだけ古くてよいか」を決めて明示する。
1676
- * 本ストア自身の書き込み (証明グループの増減・連携の作成解除) は自動で破棄するため、
1677
- * 遅れが出るのは **記憶域を直接編集した場合だけ** である。
1678
- */
1679
1473
  policyCacheTtlMs?: number;
1680
1474
  };
1681
- /** One external link row as the admin surface sees it. 管理面が見る外部リンク行。 */
1682
1475
  type DirectoryLinkRow = AuthGroupExternalLink & {
1683
1476
  linkId: number;
1684
1477
  groupId: number;
1685
1478
  tenantId: string;
1686
1479
  };
1687
- /** Input for creating a link. リンク作成の入力。 */
1688
1480
  type LinkGroupInput = {
1689
1481
  provider: string;
1690
1482
  externalId: string;
1691
1483
  externalKey: string;
1692
1484
  membershipMode: AuthDirectoryMembershipMode;
1693
1485
  };
1694
- /**
1695
- * What `requestSync` did. `requestSync` が行ったこと。
1696
- *
1697
- * ⚠️ `void` にしてはならない。同じ範囲の要求が既に待っているとき、積み増さないのは正しいが、
1698
- * それを成功と区別せずに返すと、押しても反応しない画面ができる — しかも詰まった 1 行が以後の
1699
- * 押下すべてを飲み込む。呼び出し側が運用者へ言えるだけの情報を返す。
1700
- */
1701
1486
  type SyncRequestOutcome = "queued" | "already-pending";
1702
- /**
1703
- * Creates the identity-side data store.
1704
- * identity 側のデータストアを生成する処理。
1705
- *
1706
- * @param dbUnknown Drizzle database instance. drizzle のデータベースインスタンス。
1707
- * @param tables Identity-side tables. identity 側テーブル群。
1708
- * @param authzTables Authorization tables (for the group master and the real membership).
1709
- * 認可テーブル群 (グループマスタと実所属表のため)。
1710
- * @param opts Store options. ストアの構成。
1711
- * @returns The store. ストア。
1712
- */
1713
1487
  declare function createDirectoryLinkStore(dbUnknown: unknown, tables: AuthDirectoryTables, authzTables: AuthzTables, opts: DirectoryLinkStoreOptions): {
1714
- /**
1715
- * Lists every external link of the tenant. 当該テナントの外部リンクを列挙する処理。
1716
- *
1717
- * @param tenantId Tenant to narrow on. 絞り込むテナント。
1718
- */
1719
1488
  listLinks(tenantId: string): Promise<DirectoryLinkRow[]>;
1720
- /**
1721
- * Returns the upstream key of the group, or `null` when it is locally managed.
1722
- * そのグループの上流キーを返す処理。ローカル管理なら `null`。
1723
- *
1724
- * `withExternalGroupGuards` の判定材料であり、同時に拒否メッセージの表示名でもある。
1725
- * 判定と名前を 1 回の照会で返すことで、拒否のたびの往復を 1 本に保つ。
1726
- */
1727
1489
  externalGroupKey(tenantId: string, groupId: number, runner?: unknown): Promise<string | null>;
1728
- /**
1729
- * Links a local group to an upstream group. ローカルグループを上流グループへ結び付ける処理。
1730
- *
1731
- * 既に管理ロールを持つグループは {@link LinkableAssertion} が拒否する。
1732
- *
1733
- * @throws {Error} When the group belongs to another tenant. 他テナントのグループの場合。
1734
- */
1735
1490
  linkGroup(tenantId: string, groupId: number, input: LinkGroupInput, actor: string): Promise<void>;
1736
- /**
1737
- * Removes the link, leaving the projected membership in place.
1738
- * リンクを解除する処理。射影済みの所属はそのまま残す。
1739
- *
1740
- * 所属まで消すと、連携を切っただけで全員がグループから外れる (= 大量剥奪) 。解除は
1741
- * 「上流の言うことを聞くのをやめる」であって「今の所属を捨てる」ではない。台帳と、
1742
- * 台帳を通してしか効かないグループ許可は、残しても意味を持たないため削除する。
1743
- */
1744
1491
  unlinkGroup(tenantId: string, groupId: number): Promise<void>;
1745
- /** Pauses or resumes synchronization for one group. 1 グループの同期を停止・再開する処理。 */
1746
1492
  setSyncEnabled(tenantId: string, groupId: number, isSyncEnabled: boolean, actor: string): Promise<void>;
1747
- /**
1748
- * Queues a synchronization request. 同期要求をキューへ積む処理。
1749
- *
1750
- * web プロセスは上流へ到達できないため、要求を行として残し同期ジョブに拾わせる。
1751
- * 誰がいつ何を要求し、結果がどうだったかがそのまま監査記録になる。
1752
- *
1753
- * @param groupId `null` requests every group of the tenant. `null` はテナント全件。
1754
- */
1755
1493
  requestSync(tenantId: string, groupId: number | null, requestedBy: string): Promise<SyncRequestOutcome>;
1756
- /**
1757
- * Summarizes synchronization health for the admin header.
1758
- * 管理ヘッダー向けに同期の健全性を要約する処理。
1759
- *
1760
- * 一度も成功していない場合も陳腐化として報告する。「不明」を健全側へ倒さない —
1761
- * 判定できないことは、健全であることの証明ではない。
1762
- */
1763
1494
  getStatus(tenantId: string): Promise<AuthDirectoryStatus>;
1764
- /**
1765
- * Builds the tenant's membership policy, proving every break-glass group is local.
1766
- * テナントの帰属方針を組み立てる処理。break-glass がローカル管理であることも証明する。
1767
- *
1768
- * 「証明を要求するか」を行数から推測しない。宣言が 1 行も無ければ `no-proof-required`
1769
- * という **方針** を返し、宣言があれば `require-proof` を返す。区別を型の上に残すことで、
1770
- * 「宣言し忘れ」や「障害で 0 件が返った」が「証明不要」に化ける経路を塞ぐ。
1771
- *
1772
- * @throws {Error} When a break-glass group is externally sourced. 上流所有だった場合。
1773
- * @throws {TypeError} When the resulting policy is unsatisfiable. 成立しない方針の場合。
1774
- */
1775
1495
  loadTenantMembershipPolicy(tenantId: string): Promise<TenantMembershipPolicy>;
1776
- /**
1777
- * Declares a group as proof of tenant membership. グループをテナント帰属の証明に指定する処理。
1778
- *
1779
- * この表に 1 行でも入った瞬間、そのテナントの帰属証明は「証明必須」へ切り替わる。行が
1780
- * 無い状態は「証明不要」であり、書き込み手段が無ければ機能そのものが到達不能になる。
1781
- *
1782
- * `isBreakGlass` は「同期が決して触れない復帰経路」を意味する。上流の事故はすべての
1783
- * 連携グループを同時に壊すため、そこにこそ外部供給でない経路が要る。
1784
- *
1785
- * @param tenantId - Owning tenant. 所有テナント。
1786
- * @param groupId - Group to declare. 指定するグループ。
1787
- * @param isBreakGlass - True for the locally-managed recovery path. 復帰経路なら true。
1788
- * @param actor - Who performed it. 実行者。
1789
- * @returns Nothing. 戻り値なし。
1790
- * @throws {Error} When the group is not in the tenant, when a break-glass group is linked,
1791
- * or when the result would be a proof with no break-glass path.
1792
- * 自テナントに無い場合、break-glass に連携済みグループを指定した場合、または結果が
1793
- * 「証明はあるが復帰経路が無い」方針になる場合。
1794
- */
1795
1496
  setTenantMembershipGroup(tenantId: string, groupId: number, isBreakGlass: boolean, actor: string): Promise<void>;
1796
- /**
1797
- * Withdraws a group from the tenant membership proof.
1798
- * グループをテナント帰属の証明から外す処理。
1799
- *
1800
- * 最後の break-glass 行を外すと、以降の証明は上流だけに依存する。上流の事故で全員が
1801
- * 締め出される状態になるため、読み取り側の検証 (`assertTenantMembershipPolicy`) が
1802
- * 成立しない方針を拒否する — ここで先に断る。
1803
- *
1804
- * @param tenantId - Owning tenant. 所有テナント。
1805
- * @param groupId - Group to withdraw. 外すグループ。
1806
- * @returns Nothing. 戻り値なし。
1807
- * @throws {Error} When it is the last break-glass group of a non-empty policy.
1808
- * 証明が残るのに最後の break-glass を外そうとした場合。
1809
- */
1810
1497
  removeTenantMembershipGroup(tenantId: string, groupId: number): Promise<void>;
1811
- /**
1812
- * Reactivates a group that was deactivated after vanishing upstream.
1813
- * 上流消滅で無効化されたグループを再有効化する処理。
1814
- *
1815
- * 同期は成功時に自動で再有効化するが、運用者が先に直したい場合の入口も要る。無効化を
1816
- * 一方通行の扉にしないための、もう 1 本の出口である。
1817
- */
1818
1498
  setGroupActive(tenantId: string, groupId: number, isActive: boolean, actor: string): Promise<void>;
1819
- /**
1820
- * Reports the groups the identity matches in the upstream ledger.
1821
- * 上流台帳で identity が一致するグループを報告する処理。
1822
- *
1823
- * ⚠️ 実所属表ではなく **台帳** を見ること。初回ログインでユーザー行が生まれた直後、
1824
- * まだ射影されていない瞬間に、正規の利用者が「非メンバー」として全拒否されるのを防ぐ。
1825
- */
1826
1499
  listLedgerGroupIds(tenantId: string, identity: {
1827
1500
  externalUserId: string | null;
1828
1501
  email: string | null | undefined;
1829
1502
  }): Promise<number[]>;
1830
- /**
1831
- * Reports whether an address may sign in through a group allowlist entry.
1832
- * グループ許可によってそのアドレスがサインインできるかを判定する処理。
1833
- *
1834
- * ⚠️ **テナント述語を持たない。意図的である。** 認証はテナントの確定より前に起きるため、
1835
- * 判定の時点でテナントは存在しない。この配備が受け持つ全テナントの和集合で判定する。
1836
- * ここに述語を足すと初回ログインが全滅する。
1837
- *
1838
- * 判定は実所属ではなく **台帳** を見る。初回ログインの時点では、そもそもユーザー行が
1839
- * まだ存在しない。
1840
- */
1841
1503
  isEmailAllowedByGroup(email: string | null | undefined): Promise<boolean>;
1842
- /**
1843
- * Lists group-based allowlist entries of the tenant. テナントのグループ許可を列挙する処理。
1844
- *
1845
- * `auth-core` の判別共用体をそのまま返す。別形で返すと、`type` と `readOnly` を消費側が
1846
- * 付け直すことになり、「未設定 = 編集可」という暗黙の既定が呼び出し地点ごとに復活する。
1847
- */
1848
1504
  listAllowlistGroups(tenantId: string): Promise<AuthAllowlistEntry[]>;
1849
- /** Adds a group-based allowlist entry. グループ許可を追加する処理。 */
1850
1505
  addAllowlistGroup(tenantId: string, groupId: number, description: string | undefined, actor: string): Promise<void>;
1851
- /** Removes a group-based allowlist entry. グループ許可を削除する処理。 */
1852
1506
  removeAllowlistGroup(tenantId: string, id: number): Promise<void>;
1853
- /**
1854
- * Reports the number of real membership rows the tenant's linked groups hold.
1855
- * テナントの連携グループが持つ実所属行の件数を報告する処理。
1856
- *
1857
- * 連携を切る前に「何人分の所属が残るのか」を運用者へ示すために使う。
1858
- */
1859
1507
  countProjectedMembers(tenantId: string, groupId: number): Promise<number>;
1860
1508
  };
1861
-
1862
- /**
1863
- * @module membership-mode
1864
- * @description The single reader of the `membership_mode` column.
1865
- * `membership_mode` 列を読む唯一の入口。
1866
- *
1867
- * 以前は読み手が 2 つあり、片方は未知の値を `TypeError` で拒否し、もう片方は黙って `"direct"` へ
1868
- * 倒していた。同じ列に相反する 2 つの方針が同居し、しかも倒すほうが削除を決める側だった。
1869
- * 入れ子展開のつもりのリンクが直接所属だけを返せば、入れ子側の全員が削除候補になる。
1870
- */
1871
-
1872
- /** The two modes, in one place. 2 つのモードの唯一の定義位置。 */
1873
1509
  declare const MEMBERSHIP_MODES: readonly AuthDirectoryMembershipMode[];
1874
- /**
1875
- * Rejects a membership mode that is not one of the two known values.
1876
- * 既知の 2 値でない所属展開モードを拒否する処理。
1877
- *
1878
- * 既定へ倒さないのは、入れ子展開が黙って有効になると権限が静かに広がり、逆に黙って無効になると
1879
- * 入れ子側の全員が削除候補になるためである。どちらの向きにも倒さない。
1880
- *
1881
- * @param value Raw column value. 列の生値。
1882
- * @returns The validated mode. 検証済みのモード。
1883
- * @throws {TypeError} When the value is unknown. 未知の値の場合。
1884
- */
1885
1510
  declare function assertMembershipMode(value: string): AuthDirectoryMembershipMode;
1886
-
1887
- /** Storage operations promotion performs. 昇格が行う記憶域操作。 */
1888
1511
  type PromotionRepository = {
1889
- /**
1890
- * Finds ledger rows matching the identity, across every linked group of the tenant.
1891
- * テナントの全連携グループを対象に、identity と一致する台帳行を探す処理。
1892
- *
1893
- * 突合順は上流 ID が第一キー、アドレスが第二キー。
1894
- *
1895
- * ⚠️ 各行が属するテナントも返すこと。`TDGroupMemberEmail` はテナント列を持たず親から継承する
1896
- * ため、台帳だけで絞った実装は静かにテナントを跨ぐ。呼び出し側はこの値で再検証する。
1897
- */
1898
1512
  findLedgerMatches(args: {
1899
1513
  tenantId: string;
1900
1514
  externalUserId: string | null;
@@ -1904,12 +1518,6 @@ type PromotionRepository = {
1904
1518
  groupId: number;
1905
1519
  tenantId: string;
1906
1520
  }>>;
1907
- /**
1908
- * Records the resolution and inserts the missing membership rows, atomically.
1909
- * 解決結果の記録と不足している所属行の挿入を、原子的に行う処理。
1910
- *
1911
- * @returns Group ids the user was actually added to. 実際に追加されたグループ ID。
1912
- */
1913
1521
  attachUserToGroups(args: {
1914
1522
  tenantId: string;
1915
1523
  userId: number;
@@ -1917,611 +1525,184 @@ type PromotionRepository = {
1917
1525
  groupIds: number[];
1918
1526
  }): Promise<number[]>;
1919
1527
  };
1920
- /** What the promotion did. 昇格が行ったこと。 */
1921
1528
  type PromotionResult = {
1922
- /** Groups the user gained membership of. 所属を得たグループ。 */
1923
1529
  addedGroupIds: number[];
1924
- /** Ledger rows the user was matched against. 突合した台帳行。 */
1925
1530
  matchedLedgerIds: number[];
1926
1531
  };
1927
- /**
1928
- * Promotes ledger rows to real memberships for one just-provisioned user.
1929
- * プロビジョニング直後の 1 ユーザーについて、台帳の行を実所属へ昇格させる処理。
1930
- *
1931
- * 追加しか行わないため、最後の管理者ロックアウト判定は不要である (所属が増えて管理者が
1932
- * 減ることはない)。それでも記憶域側では 1 トランザクションで書くこと — 台帳の解決記録だけが
1933
- * 残って所属が入らないと、次回の同期まで「解決済みなのに権限が無い」状態が続く。
1934
- *
1935
- * @param repository Storage operations. 記憶域操作。
1936
- * @param args Tenant, the resolved user, and the identity to match on. テナント・ユーザー・identity。
1937
- * @returns What was promoted. 昇格した内容。
1938
- * @throws {AuthzTenantError} When the tenant id is blank, or a matched row belongs to another
1939
- * tenant. テナント ID が空、または一致行が別テナントに属する場合。
1940
- * @throws {TypeError} When the user id is not a positive integer. ユーザー ID が正整数でない場合。
1941
- */
1942
1532
  declare function promoteLedgerForUser(repository: PromotionRepository, args: {
1943
1533
  tenantId: string;
1944
1534
  userId: number;
1945
1535
  externalUserId: string | null;
1946
1536
  email: string | null | undefined;
1947
1537
  }): Promise<PromotionResult>;
1948
-
1949
- /** Options for {@link createPromotionRepository}. 昇格リポジトリの生成オプション。 */
1950
1538
  type PromotionRepositoryOptions = TransactionalOptions & {
1951
- /** Establishes the connection before the first statement. 最初の文の前に接続を確立する処理。 */
1952
1539
  ensureConnection?: EnsureConnection;
1953
- /** Written to the audit columns of inserted membership rows. 挿入行の監査列に書く実行者。 */
1954
1540
  actor: string;
1955
- /** Injected clock — tests must not depend on wall time. 注入時計 (実時刻に依存させない)。 */
1956
1541
  now?: () => Date;
1957
1542
  };
1958
- /**
1959
- * Builds the promotion repository over the directory ledger and the authz membership table.
1960
- * ディレクトリ台帳と認可の所属表に対して、昇格リポジトリを構築する処理。
1961
- *
1962
- * @param dbUnknown - Drizzle database instance. drizzle のデータベースインスタンス。
1963
- * @param tables - Directory tables (owns the ledger). ディレクトリ表 (台帳の所有者)。
1964
- * @param authzTables - Authorization tables (owns groups and membership). 認可表 (グループと所属の所有者)。
1965
- * @param opts - Connection, actor and clock. 接続・実行者・時計。
1966
- * @returns A repository consumable by `promoteLedgerForUser`. `promoteLedgerForUser` が使うリポジトリ。
1967
- */
1968
1543
  declare function createPromotionRepository(dbUnknown: unknown, tables: AuthDirectoryTables, authzTables: AuthzTables, opts: PromotionRepositoryOptions): PromotionRepository;
1969
-
1970
- /**
1971
- * @module sync-messages
1972
- * @description Operator-facing text the synchronization records against a link.
1973
- * 同期がリンクへ記録する、運用者向けの文言。
1974
- *
1975
- * 文言を注入可能にしてあるのは、`sync_error` が管理 UI にそのまま出るためである。ホスト非依存を
1976
- * 求められるパッケージへ日本語を焼き込むと、日本語以外の配備がデータベースに日本語を持つことになる。
1977
- * 既定は日本語 (このリポジトリの管理 UI に合わせる)。
1978
- */
1979
-
1980
- /**
1981
- * Why a read or a write failed, classified for display. 読み書きが失敗した理由 (表示用の分類)。
1982
- *
1983
- * ⚠️ **例外文をそのまま `sync_error` へ入れてはならない。** この列は管理 UI のバナーとして
1984
- * **全タブに** 出るため、閲覧権限しか持たない主体が上流の生の応答本文 (サービスアカウントの
1985
- * アドレス、内部 URL、資格情報の断片) や DB の接続文字列・スキーマ名を読めてしまう。しかも
1986
- * それは、候補一覧の **グループ名すら** 見せないと決めた相手である。原文はログへ、画面へは分類を。
1987
- */
1988
1544
  type SyncFailureCause = "denied" | "rateLimited" | "upstreamError" | "timeout" | "localWriteError" | "unknown";
1989
- /**
1990
- * Classifies a thrown value without quoting it. 投げられた値を、引用せずに分類する処理。
1991
- *
1992
- * 上流アダプタの型に依存しないよう、`status` という数値プロパティの有無だけで判定する。
1993
- * 判別できないものは `unknown` へ倒す (推測した分類を出すより、判らないと言う方が正しい)。
1994
- *
1995
- * @param error - The thrown value. 投げられた値。
1996
- * @returns The display classification. 表示用の分類。
1997
- */
1998
1545
  declare function classifySyncFailure(error: unknown): SyncFailureCause;
1999
- /** The messages one synchronization can produce. 同期が生成し得る文言。 */
2000
1546
  type SyncMessages = {
2001
- /** The upstream could not be read at all. 上流をまったく読めなかった。 */
2002
1547
  upstreamUnreadable: (cause: SyncFailureCause) => string;
2003
- /** The local write failed. ローカルへの書込が失敗した。 */
2004
1548
  localWriteFailed: (cause: SyncFailureCause) => string;
2005
- /** The resolver returned fewer members than the upstream listed. 突合が件数を減らした。 */
2006
1549
  resolverIncomplete: (upstream: number, resolved: number) => string;
2007
- /** The group is missing upstream but not yet deactivated. 消滅の観測 (未確定)。 */
2008
1550
  groupMissing: (externalKey: string, observations: number, threshold: number) => string;
2009
- /** The group has been deactivated after repeated absence. 消滅確定・無効化。 */
2010
1551
  groupVanished: (externalKey: string, observations: number) => string;
2011
- /**
2012
- * Removals whose write failed for a transient reason. 一時的な理由で書けなかった削除。
2013
- *
2014
- * ⚠️ 拒否とは別の文言にする。「最後の管理者ガードが止めた」は人手を呼ぶ答えであり、
2015
- * デッドロックや接続断に対して同じ文言を出すと、待てば直る事象に人を動かすことになる。
2016
- */
2017
1552
  removalWritesFailed: (failures: readonly {
2018
1553
  userId: number;
2019
1554
  cause: SyncFailureCause;
2020
1555
  }[]) => string;
2021
- /** The reconciler refused the plan. 突合が plan を拒否した。 */
2022
1556
  planRefused: (abort: SyncAbort) => string;
2023
- /** The lockout guard refused some removals. ロックアウトガードが一部の削除を拒否した。 */
2024
1557
  removalsRefused: (refusals: readonly {
2025
1558
  userId: number;
2026
1559
  refusal?: string;
2027
1560
  }[]) => string;
2028
- /** The link belongs to a different provider. 他 provider のリンクだった。 */
2029
1561
  foreignProvider: (linkProvider: string, runnerProvider: string) => string;
2030
1562
  };
2031
1563
  declare const defaultSyncMessages: SyncMessages;
2032
-
2033
- /**
2034
- * @module sync-ports
2035
- * @description The narrow storage surface the synchronization orchestration depends on.
2036
- * 同期オーケストレーションが依存する、狭い記憶域の面。
2037
- *
2038
- * オーケストレーションを drizzle から切り離すために置いている。同期の手順そのもの
2039
- * (何を順に行い、どこで打ち切るか) は、データベースを起動せずに全分岐を検証できるべきである —
2040
- * 検証しにくい手順は検証されず、検証されない手順は「読めなかったら消さない」を静かに破る。
2041
- */
2042
-
2043
- /**
2044
- * One external group link, as the synchronization needs to see it.
2045
- * 同期が見る必要のある外部グループリンク 1 件。
2046
- */
2047
1564
  type SyncLink = {
2048
1565
  linkId: number;
2049
1566
  groupId: number;
2050
1567
  groupKey: string;
2051
1568
  tenantId: string;
2052
- /** Which upstream owns this group. どの上流がこのグループを所有するか。 */
2053
1569
  provider: string;
2054
1570
  externalId: string;
2055
1571
  externalKey: string;
2056
1572
  membershipMode: AuthDirectoryMembershipMode$1;
2057
- /** False when the group has been deactivated. グループが無効化されている場合 false。 */
2058
1573
  isGroupActive: boolean;
2059
- /**
2060
- * How many consecutive runs have found the group missing upstream.
2061
- * 上流でグループが見つからない状態が何回連続したか。
2062
- *
2063
- * 1 度の 404 で無効化すると、伝播待ちや権限変更の一瞬で生きているグループが落ちる。
2064
- */
2065
1574
  vanishedObservations: number;
2066
1575
  };
2067
- /**
2068
- * Which links a run covers. 1 回の実行が対象にするリンクの範囲。
2069
- *
2070
- * ⚠️ `tenantId` は **必須** である。1 つのジョブが持つ上流の資格情報は 1 つのテナントに対応する。
2071
- * 範囲を絞らないと、別テナントのリンクを読んだうえで **自分の資格情報で得た結果をその別テナントへ
2072
- * 書き込む**。上流が 404 を返せば (借用先の外にあるグループでは通常そうなる) 消滅と判定して
2073
- * 相手のグループを無効化し、外部 ID が偶然一致すれば相手のグループへ自分の所属を射影する。
2074
- * 要求した側の権限は一切関係しないため、既定値 1 つで越境が成立する形にしてはならない。
2075
- * 同じ理由で `createSyncRequestQueue` も構築時にテナントを固定する。
2076
- */
2077
1576
  type SyncScope = {
2078
1577
  tenantId: string;
2079
- /** Restrict further to one group within the tenant. テナント内の 1 グループへさらに絞る。 */
2080
1578
  groupId?: number;
2081
1579
  };
2082
- /** Why one group's synchronization ended the way it did. 1 グループの同期がどう終わったか。 */
2083
1580
  type SyncOutcome = {
2084
1581
  kind: "applied";
2085
1582
  link: SyncLink;
2086
1583
  plan: GroupSyncPlan;
2087
- }
2088
- /** Nothing changed. Not a failure — an idempotent run. 変化なし。失敗ではなく冪等な実行。 */
2089
- | {
1584
+ } | {
2090
1585
  kind: "unchanged";
2091
1586
  link: SyncLink;
2092
- }
2093
- /** The plan was refused by the reconciler's own guards. 突合自身のガードが plan を拒否した。 */
2094
- | {
1587
+ } | {
2095
1588
  kind: "aborted";
2096
1589
  link: SyncLink;
2097
1590
  plan: GroupSyncPlan;
2098
- }
2099
- /** The group is missing upstream, but not yet often enough to act on. 消滅の観測 (未確定)。 */
2100
- | {
1591
+ } | {
2101
1592
  kind: "missing";
2102
1593
  link: SyncLink;
2103
1594
  observations: number;
2104
- }
2105
- /** The group has been missing long enough that it was deactivated. 消滅確定・無効化した。 */
2106
- | {
1595
+ } | {
2107
1596
  kind: "vanished";
2108
1597
  link: SyncLink;
2109
- }
2110
- /**
2111
- * Still missing, and already deactivated on an earlier run. 消滅済みで、以前の実行で無効化済み。
2112
- *
2113
- * ⚠️ `vanished` と分ける理由は、**運用通知が状態ではなく変化に反応するべき** だからである。
2114
- * 同じ 1 件の消滅を掃引のたびに通知すると、本当に新しい消滅がその中に埋もれる。この結末は
2115
- * 「今回の掃引では何も変わっていない」ことの表明であり、健全ではないが新規でもない。
2116
- */
2117
- | {
1598
+ } | {
2118
1599
  kind: "already-vanished";
2119
1600
  link: SyncLink;
2120
- }
2121
- /** Reading upstream failed. 上流の読み取りが失敗した。 */
2122
- | {
1601
+ } | {
2123
1602
  kind: "upstream-failed";
2124
1603
  link: SyncLink;
2125
1604
  error: Error;
2126
- }
2127
- /** Writing locally failed. ローカルへの書込が失敗した。 */
2128
- | {
1605
+ } | {
2129
1606
  kind: "local-failed";
2130
1607
  link: SyncLink;
2131
1608
  error: Error;
2132
- }
2133
- /** The link belongs to another provider than the one running. 他 provider のリンクだった。 */
2134
- | {
1609
+ } | {
2135
1610
  kind: "foreign-provider";
2136
1611
  link: SyncLink;
2137
- }
2138
- /**
2139
- * The plan was applied only in part. plan の一部しか適用できなかった。
2140
- *
2141
- * ⚠️ `applied` と分ける。拒否や書込失敗が残ったまま「適用済み」と答えると、上流が外した人物が
2142
- * グループに残っているのに、鮮度は健全・通知は無音・要求キューの結果は成功になる — 収束して
2143
- * いないことを示す信号がどこにも出ない。
2144
- */
2145
- | {
1612
+ } | {
2146
1613
  kind: "not-converged";
2147
1614
  link: SyncLink;
2148
1615
  plan: GroupSyncPlan;
2149
1616
  refusals: RemovalOutcome[];
2150
1617
  failures: RemovalFailure[];
2151
1618
  };
2152
- /**
2153
- * Outcomes that mean something changed for the worse on this run. この実行で新たに悪化した結末。
2154
- *
2155
- * ⚠️ **状態ではなく変化を数える。** `already-vanished` は不健全な状態ではあるが、以前の実行で
2156
- * 既に記録・通知済みであり、今回の掃引では何も変わっていない。ここに入れると同じ 1 件が周期ぶん
2157
- * 通知され、本当に新しい消滅が埋もれる。「今どれだけ壊れているか」を数えたい呼び出し側は
2158
- * {@link UNHEALTHY_SYNC_OUTCOMES} を使う。
2159
- */
2160
1619
  declare const NEWLY_UNHEALTHY_SYNC_OUTCOMES: readonly SyncOutcome["kind"][];
2161
- /** Outcomes that mean the group is not in a healthy, converged state. 健全でない結末。 */
2162
1620
  declare const UNHEALTHY_SYNC_OUTCOMES: readonly SyncOutcome["kind"][];
2163
- /** What happened to one guarded removal. ガード付き削除 1 件の結末。 */
2164
1621
  type RemovalOutcome = {
2165
1622
  userId: number;
2166
1623
  applied: boolean;
2167
1624
  refusal?: string;
2168
1625
  };
2169
- /**
2170
- * One removal the write itself could not complete. 書き込み自体が完了しなかった削除 1 件。
2171
- *
2172
- * ⚠️ **拒否とは別に数える。** 「最後の管理者を失う」はガードの判断であり、運用者への答えは
2173
- * 「別の管理者を立てよ」である。一方でデッドロックの犠牲や接続断は待てば直るものであり、
2174
- * 答えは「再試行せよ」である。両方を同じ袋に入れると、待てば直る事象に対して人手を呼び、
2175
- * 人手が要る事象を放置することになる。
2176
- */
2177
1626
  type RemovalFailure = {
2178
1627
  userId: number;
2179
1628
  cause: SyncFailureCause;
2180
1629
  };
2181
- /** What `applyPlan` actually managed to do. `applyPlan` が実際に行えたこと。 */
2182
1630
  type ApplyReport = {
2183
- /** Removals the administrator lockout guard refused. ロックアウトガードが拒否した削除。 */
2184
1631
  refusals: RemovalOutcome[];
2185
- /** Removals whose write failed for a transient reason. 一時的な理由で書けなかった削除。 */
2186
1632
  failures: RemovalFailure[];
2187
1633
  };
2188
- /**
2189
- * Storage operations the synchronization performs.
2190
- * 同期が行う記憶域操作。
2191
- */
2192
1634
  type DirectorySyncRepository = {
2193
- /**
2194
- * Lists links that are eligible to run. 実行対象のリンクを列挙する処理。
2195
- *
2196
- * ⚠️ 無効化されたグループのリンクも返すこと。返さないと、上流が復旧しても二度と同期されず、
2197
- * 再有効化の機会が永久に失われる。
2198
- *
2199
- * @param scope Restrict to one tenant, or one group within it. テナント、または特定グループへ限定。
2200
- */
2201
1635
  listSyncableLinks(scope: SyncScope): Promise<SyncLink[]>;
2202
- /** Reads the local ledger and the real membership for one group. 台帳と実所属を読む処理。 */
2203
1636
  loadGroupSnapshot(link: SyncLink): Promise<LocalGroupSnapshot>;
2204
- /**
2205
- * Resolves upstream members against the local user table.
2206
- * 上流メンバーをローカルユーザー表へ突合する処理。
2207
- *
2208
- * 突合順は上流 ID が第一キー、アドレスが第二キー。再利用されたアドレスが他人の所属を
2209
- * 継承する事故を防ぐため、この順序は実装側の裁量ではなく契約である。
2210
- *
2211
- * ⚠️ **入力と同じ件数を返すこと。** 解決できないメンバーは省略せず `resolvedUserId: null` で
2212
- * 返す。省略すると、その人物は「上流から消えた」と解釈されて削除対象になる。
2213
- */
2214
1637
  resolveMembers(members: readonly DirectoryMember[]): Promise<ResolvedDirectoryMember[]>;
2215
- /**
2216
- * Applies one group's plan, taking every membership removal through the lockout guard.
2217
- * 1 グループ分の plan を適用する処理。実所属の削除は必ず最後の管理者ガードを通す。
2218
- *
2219
- * ⚠️ ロックアウトガードが 1 件の削除を拒否しても、**残りの削除を続けること**。1 件で打ち切ると、
2220
- * 拒否された行がグループ全体の収束を永久に止める (次回以降も同じ行で止まる)。拒否は
2221
- * {@link ApplyReport.refusals} で報告する。
2222
- *
2223
- * @returns What was refused. 拒否された内容。
2224
- * @throws When the write itself failed. 書込そのものが失敗した場合。
2225
- */
2226
1638
  applyPlan(link: SyncLink, plan: GroupSyncPlan, observedAt: Date): Promise<ApplyReport>;
2227
- /** Records a successful run and reactivates the group if it was deactivated. 成功の記録。 */
2228
- /**
2229
- * Persists the upstream's stable identity before any membership is applied.
2230
- * 所属を適用する **前** に、上流の安定 ID を確定させる処理。
2231
- *
2232
- * ⚠️ **順序がこの操作の意味である。** 管理面は、候補一覧が引けない配備ではアドレスを暫定の
2233
- * 安定 ID として保存する。同じ上流グループを別の綴り (アドレスと別名、あるいは本当の ID) で
2234
- * 2 回リンクできてしまい、`UNIQUE (tenant, provider, external_id)` も文字列が違うので通る。
2235
- * 確定を所属の適用より前に置くことで、重複したリンクは **何も投影しないまま** 一意制約に
2236
- * 当たって落ちる。後に置くと、二重の所属が先に commit され、両方のロールが配られてから
2237
- * 書き戻しだけが失敗し続ける。
2238
- *
2239
- * @param link - The link being synchronized. 同期中のリンク。
2240
- * @param upstreamGroup - What the upstream answered. 上流が答えた内容。
2241
- * @returns Nothing. 戻り値なし。
2242
- * @throws When another link already owns this upstream group. 同じ上流を別のリンクが持つ場合。
2243
- */
2244
1639
  resolveExternalIdentity(link: SyncLink, upstreamGroup: DirectoryGroup): Promise<void>;
2245
1640
  recordSuccess(link: SyncLink, group: DirectoryGroup, syncedAt: Date): Promise<void>;
2246
- /** Records a failure reason against the link, leaving membership untouched. 失敗を記録する処理。 */
2247
1641
  recordFailure(link: SyncLink, reason: string): Promise<void>;
2248
- /**
2249
- * Records one observation that the group is missing upstream. 上流での消滅を 1 回観測した記録。
2250
- *
2251
- * @returns How many consecutive observations there now are. 連続観測回数。
2252
- */
2253
1642
  recordVanishedObservation(link: SyncLink, reason: string): Promise<number>;
2254
- /** Marks a group inactive after it has been missing long enough. 消滅確定後の無効化。 */
2255
1643
  markGroupInactive(link: SyncLink): Promise<void>;
2256
1644
  };
2257
- /** Minimal logging surface. 最小のログ面。 */
2258
1645
  type SyncLoggerPort = {
2259
1646
  info(message: string, ...args: unknown[]): void;
2260
1647
  warn(message: string, ...args: unknown[]): void;
2261
1648
  error(message: string, ...args: unknown[]): void;
2262
1649
  };
2263
-
2264
- /**
2265
- * @module sync
2266
- * @description Orchestration of one synchronization run: read upstream, reconcile, apply — and
2267
- * stop at the first sign that "upstream said nothing" might mean "we could not read upstream".
2268
- * 1 回の同期実行のオーケストレーション。上流を読み、突合し、適用する。そして「上流が何も
2269
- * 言わなかった」が「上流を読めなかった」かもしれない兆候が出た時点で止める。
2270
- *
2271
- * 記憶域は {@link DirectorySyncRepository} 越しにしか触らないため、手順そのものは
2272
- * データベースを起動せずに全分岐を検証できる。
2273
- */
2274
-
2275
- /** Configuration of a synchronization runner. 同期ランナーの構成。 */
2276
1650
  type DirectorySyncConfig = {
2277
- /**
2278
- * Which upstream this runner speaks for. このランナーが担当する上流。
2279
- *
2280
- * リンク行の `provider` と照合する。照合しないと、別 provider のリンクを受け取った
2281
- * ランナーがそれを「上流に存在しない」と判定し、他 provider のグループを無効化してしまう。
2282
- */
2283
1651
  provider: string;
2284
1652
  directory: DirectoryProvider;
2285
1653
  repository: DirectorySyncRepository;
2286
- /** Per-axis removal limits. See `auth-directory-core`. 軸ごとの削除上限。 */
2287
1654
  policy: BlastRadiusPolicy;
2288
- /**
2289
- * Consecutive absences required before a group is deactivated. 無効化に要する連続不在回数。
2290
- *
2291
- * 1 度の 404 で無効化すると、伝播待ちや権限変更の一瞬で生きているグループが落ちる。
2292
- */
2293
1655
  vanishedThreshold: number;
2294
- /**
2295
- * Supplies the current time. 現在時刻を供給する処理。
2296
- *
2297
- * 注入するのは決定性のためだけではない。1 回の実行の中で「観測時刻」と「同期時刻」が
2298
- * 別々に進むと、どの行がどの実行で書かれたのかを後から辿れなくなる。
2299
- */
2300
1656
  now: () => Date;
2301
1657
  logger: SyncLoggerPort;
2302
- /** Operator-facing text. 運用者向けの文言。 */
2303
1658
  messages?: SyncMessages;
2304
1659
  };
2305
- /** Result of one run over a set of links. リンク集合 1 巡分の結果。 */
2306
1660
  type DirectorySyncRunResult = {
2307
1661
  outcomes: SyncOutcome[];
2308
- /**
2309
- * Links that did not end in a healthy, converged state. 健全に収束しなかったリンク数。
2310
- *
2311
- * 消滅の観測と無効化も含める。グループが恒久的に同期対象から外れることは、実行の中で
2312
- * 最も重い結末であり、それを「0 unhealthy」と報告しては監視の意味がない。
2313
- */
2314
1662
  unhealthyCount: number;
2315
- /**
2316
- * Links that became unhealthy on this run. この実行で新たに不健全になったリンク数。
2317
- *
2318
- * ⚠️ 通知はこちらで判断する。`unhealthyCount` は状態の量なので、消滅済みのグループが 1 つ
2319
- * 残っているだけで毎周期 1 以上になり、同じ 1 件を周期ぶん通知し続ける — 本当に新しい
2320
- * 消滅がその中に埋もれる。数えるのは状態、知らせるのは変化である。
2321
- */
2322
1663
  newlyUnhealthyCount: number;
2323
1664
  };
2324
- /**
2325
- * Creates a synchronization runner. 同期ランナーを生成する処理。
2326
- *
2327
- * @param config Injected provider, repository, limits, clock and logger. 注入する構成。
2328
- * @returns The runner. ランナー。
2329
- * @throws {TypeError} When the policy or the threshold is invalid. 方針・しきい値が不正な場合。
2330
- */
2331
1665
  declare function createDirectorySync(config: DirectorySyncConfig): {
2332
1666
  syncOne: (link: SyncLink) => Promise<SyncOutcome>;
2333
- /**
2334
- * Synchronizes every eligible link in scope. 対象範囲の全リンクを同期する処理。
2335
- *
2336
- * リンクは **逐次** 処理する。並列化すると上流のレート制限を一気に消費し、最初に
2337
- * 弾かれたグループだけが失敗して部分的に古い状態が残る。1 グループの失敗は他へ
2338
- * 波及させず、実行自体は最後まで続ける。
2339
- *
2340
- * @param scope Which tenant (and optionally which group) to cover. 対象テナントと範囲。
2341
- * @returns Every outcome, and how many ended unhealthy. 全結果と不健全件数。
2342
- */
2343
1667
  run(scope: SyncScope): Promise<DirectorySyncRunResult>;
2344
1668
  };
2345
-
2346
- /** One claimed request. 取得済みの要求 1 件。 */
2347
1669
  type ClaimedSyncRequest = {
2348
1670
  id: number;
2349
1671
  tenantId: string;
2350
- /** `null` means every group of the tenant. `null` はテナント全件を意味する。 */
2351
1672
  groupId: number | null;
2352
1673
  requestedBy: string;
2353
1674
  };
2354
- /**
2355
- * Requests that are not progressing. 進んでいない要求。
2356
- *
2357
- * ⚠️ 2 つを分けて数える。`stranded` は「掴まれたが終わっていない」— ジョブが落ちた跡である。
2358
- * `unclaimed` は「誰にも掴まれていない」— **そのテナントを担当するジョブが居ない** 跡であり、
2359
- * 掴まれた行だけを見ていると丸ごと見落とす。重複抑止が在るため、後者は 1 行で以後の要求すべてを
2360
- * 黙って捨てる。
2361
- */
2362
1675
  type StrandedRequests = {
2363
1676
  stranded: number[];
2364
1677
  unclaimed: number[];
2365
1678
  };
2366
- /**
2367
- * Recorded when a request is closed because the process that claimed it never finished it.
2368
- * 掴んだプロセスが終わりを書かなかったために閉じた要求へ記録される理由。
2369
- */
2370
1679
  declare const STRANDED_REASON = "The job that claimed this request ended without recording an outcome; whether the synchronization ran is unknown.";
2371
- /** How a claimed request ended. 取得した要求の終わり方。 */
2372
1680
  type SyncRequestResult = {
2373
1681
  result: "succeeded" | "failed";
2374
1682
  error?: string | null;
2375
1683
  };
2376
- /** Options for {@link createSyncRequestQueue}. キュー消費側の生成オプション。 */
2377
1684
  type SyncRequestQueueOptions = {
2378
1685
  ensureConnection?: EnsureConnection;
2379
- /**
2380
- * The only tenant this consumer may claim for. この消費側が取得してよい唯一のテナント。
2381
- *
2382
- * ⚠️ **必須である。** 1 つのジョブが持つ上流の資格情報は 1 つのテナントに対応する。範囲を
2383
- * 絞らないと、別テナントの要求を掴んだジョブが **自分の資格情報で読んだ結果を、その別テナントへ
2384
- * 書き込む**。要求を出した側の権限は一切関係しないため、これは要求 1 つで越境が起きる形になる。
2385
- *
2386
- * ⚠️ その代償として、**担当ジョブの居ないテナントの要求は誰にも観測されない**。`listStranded`
2387
- * もこのテナントに絞られる以上、消費側が存在しないテナントを数える主体はどこにも居ない。
2388
- * 見えるのは web 側だけである — `getStatus().pendingRequestCount` が管理面のバナーに出て、
2389
- * `requestSync` は 2 度目以降を `already-pending` として返す。配備時は、リンクを持つ
2390
- * すべてのテナントにジョブを 1 つずつ立てること。
2391
- */
2392
1686
  tenantId: string;
2393
- /** Injected clock — the run's timestamps must all come from one source. 注入時計。 */
2394
1687
  now: () => Date;
2395
- /**
2396
- * Reports a request that could not be closed. 閉じられなかった要求を報告する処理。
2397
- *
2398
- * ⚠️ {@link createSyncRequestQueue.abandonStranded} は 1 件の失敗で残りを諦めない。
2399
- * 諦めない以上、失敗そのものが黙って消える経路になってはならない — 記録の宛先は
2400
- * 呼び出し側が持っているので、ここから渡す。省略時は何もしない。
2401
- */
2402
1688
  onCloseFailed?: (id: number, error: unknown) => void;
2403
- /**
2404
- * Longest an error message may be, matching the column. 列に合わせたエラー文の上限長。
2405
- *
2406
- * 超過分は切り捨てる。切り捨てないと、記録そのものが失敗して「何が起きたか分からない
2407
- * まま要求が取得済みで固まる」という最悪の状態になる。
2408
- */
2409
1689
  maxErrorLength?: number;
2410
1690
  };
2411
- /**
2412
- * Creates the consumer for the synchronization request queue.
2413
- * 同期要求キューの消費側を生成する処理。
2414
- *
2415
- * @param dbUnknown - Drizzle database instance. drizzle のデータベースインスタンス。
2416
- * @param tables - Directory tables (owns the queue). ディレクトリ表 (キューの所有者)。
2417
- * @param opts - Connection, clock and truncation bound. 接続・時計・切り詰め上限。
2418
- * @returns The claim / finish pair. 取得と完了記録の 2 操作。
2419
- */
2420
1691
  declare function createSyncRequestQueue(dbUnknown: unknown, tables: AuthDirectoryTables, opts: SyncRequestQueueOptions): {
2421
- /**
2422
- * Claims the oldest unpicked request, marking it picked in the same statement.
2423
- * 最も古い未取得の要求を、同じ文で取得済みにしながら取り出す処理。
2424
- *
2425
- * 取得と印付けを分けると、2 つのジョブが同じ要求を拾って同じグループを二重に同期する。
2426
- * `UPDATE ... OUTPUT` は 1 文なので、行を掴んだのが誰かは常に 1 つに決まる。
2427
- *
2428
- * @returns The claimed request, or `null` when the queue is empty. 取得結果 (空なら `null`)。
2429
- */
2430
1692
  claim(): Promise<ClaimedSyncRequest | null>;
2431
- /**
2432
- * Records how a claimed request ended. 取得済みの要求がどう終わったかを記録する処理。
2433
- *
2434
- * ⚠️ 未完了の行にしか書かない。既に結末が記録されている行は **0 行更新** になるので、
2435
- * 「書けたかどうか」を返す。返さないと、呼び出し側は閉じていない行を閉じたと報告する。
2436
- *
2437
- * @param id - The claimed request id. 取得した要求の ID。
2438
- * @param outcome - Result and optional error text. 結果と (あれば) エラー文。
2439
- * @returns True when this call recorded the outcome. この呼び出しが結末を記録した場合に true。
2440
- */
2441
1693
  finish(id: number, outcome: SyncRequestResult): Promise<boolean>;
2442
- /**
2443
- * Lists requests that are not progressing. 進んでいない要求の一覧。
2444
- *
2445
- * ジョブが落ちると、行は取得済みのまま完了しない。放置すると要求した人はいつまでも
2446
- * 結果を見られないので、運用が拾えるよう明示的に数えられる形にしておく。
2447
- *
2448
- * ⚠️ **掴まれていない古い行も数える。** 取得済みだけを見ると、そのテナントを担当する
2449
- * ジョブが居ない場合が丸ごと盲点になる — その行は永久に処理されないのに、重複抑止の
2450
- * せいで以後の「今すぐ同期」まで黙って捨てられる。
2451
- *
2452
- * @param olderThan - Cutoff for both timestamps. 両方の時刻に対する締切時刻。
2453
- * @returns Stranded and unclaimed request ids. 取り残された要求と、掴まれていない要求の ID。
2454
- */
2455
1694
  listStranded(olderThan: Date): Promise<StrandedRequests>;
2456
- /**
2457
- * Closes stranded requests as failed, so the queue can move again.
2458
- * 取り残された要求を失敗として閉じ、キューを再び動かす処理。
2459
- *
2460
- * ⚠️ **掴んだ行を未処理へ戻さない。** 戻すと `UQ_..._pending` (未処理行の一意制約) に
2461
- * 衝突し得る — 同じ範囲の新しい要求が既に並んでいれば、戻す操作そのものが失敗する。
2462
- * 失敗として閉じれば、監査記録は残り、要求した人は結果 (失敗) を見られ、次の「今すぐ
2463
- * 同期」は重複抑止に掛からない。
2464
- *
2465
- * ⚠️ **走ったかどうかは分からない。** 記録する理由も、成否ではなく「掴んだプロセスが
2466
- * 終わりを書かなかった」という観測事実だけにする。推測を記録に混ぜない。
2467
- *
2468
- * ⚠️ 掴まれていない行 (`unclaimed`) には触れない。あれはジョブが落ちた跡ではなく
2469
- * **担当ジョブが居ない** 跡であり、閉じると原因が消えて再発し続ける。
2470
- *
2471
- * @param olderThan - Requests picked before this are considered abandoned.
2472
- * これより前に掴まれた要求を放棄と見なす締切時刻。
2473
- * @returns The ids this call actually closed. この呼び出しが実際に閉じた要求の ID。
2474
- */
2475
1695
  abandonStranded(olderThan: Date): Promise<number[]>;
2476
1696
  };
2477
-
2478
- /**
2479
- * Resolves upstream members against the host's identity tables.
2480
- * 上流メンバーをホストの identity 表へ突合するポート。
2481
- *
2482
- * ホストごとに identity の持ち方が違う (このリポジトリでは `TDOpenid` → `TDUsers`) ため、
2483
- * パッケージ側では表を名指しできない。突合順が **上流 ID 第一・アドレス第二** であることは
2484
- * 実装側の裁量ではなく契約である — 再利用されたアドレスが他人の所属を継承する事故を防ぐ。
2485
- *
2486
- * ⚠️ 入力と同じ件数を返すこと。解決できないメンバーを省略すると、その人物は削除対象になる。
2487
- */
2488
1697
  type MemberResolverPort = {
2489
1698
  resolve(members: readonly DirectoryMember[]): Promise<ResolvedDirectoryMember[]>;
2490
1699
  };
2491
- /** Options for the synchronization repository. 同期リポジトリの構成。 */
2492
1700
  type SyncRepositoryOptions = TransactionalOptions & {
2493
1701
  ensureConnection?: EnsureConnection;
2494
- /**
2495
- * Wall-clock supplier. 実行の時刻を供給する処理。
2496
- *
2497
- * ⚠️ 走査側 (`createDirectorySync`) は時計を注入されており、「1 回の実行の中で観測時刻と
2498
- * 同期時刻が別々に進むと、どの行がどの実行で書かれたのか後から辿れなくなる」という理由が
2499
- * 書いてある。記憶域側だけが `new Date()` を直に読むと、**同じ実行の中で 2 つの時計が進む** —
2500
- * 失敗の記録と成功の記録が別の時刻を持ち、その理由は誰にも判らない。省略時は実時計。
2501
- */
2502
1702
  now?: () => Date;
2503
1703
  memberResolver: MemberResolverPort;
2504
- /** Lockout guard from `@aiquants/authz-drizzle`. 認可側のロックアウトガード。 */
2505
1704
  lockoutGuard: ReturnType<typeof createAdminLockoutGuard>;
2506
- /**
2507
- * Actor recorded on rows the synchronization writes. 同期が書く行に記録する実行者。
2508
- *
2509
- * 空にすると、同期が作った行と手作業で入った行を監査上区別できなくなる。しかも更新系では
2510
- * 最後に触れた人間の名前が残ったまま更新時刻だけ進み、監査が同期の変更を人間の仕業として
2511
- * 記録することになる。
2512
- */
2513
1705
  actor: string;
2514
1706
  };
2515
- /**
2516
- * Creates the drizzle-backed synchronization repository.
2517
- * drizzle を用いた同期リポジトリを生成する処理。
2518
- *
2519
- * @param dbUnknown Drizzle database instance. drizzle のデータベースインスタンス。
2520
- * @param tables Identity-side tables. identity 側テーブル群。
2521
- * @param authzTables Authorization tables (group master and real membership). 認可テーブル群。
2522
- * @param opts Injected resolver, lockout guard and audit actor. 注入する構成。
2523
- * @returns The repository. リポジトリ。
2524
- */
2525
1707
  declare function createDirectorySyncRepository(dbUnknown: unknown, tables: AuthDirectoryTables, authzTables: AuthzTables, opts: SyncRepositoryOptions): DirectorySyncRepository;
2526
-
2527
1708
  export { AUTH_DIRECTORY_PROVIDER_COLUMN, AUTH_DIRECTORY_TENANT_SCOPED_TABLES, type ApplyReport, type AuthDirectoryTables, type ClaimedSyncRequest, type DeleteChain, type DirectoryCatalogEntry, type DirectoryCatalogReaderOptions, type DirectoryCatalogSnapshot, type DirectoryCatalogWriterOptions, type DirectoryDb, type DirectoryLinkRow, type DirectoryLinkStoreOptions, type DirectorySyncConfig, type DirectorySyncRepository, type DirectorySyncRunResult, type EnsureConnection, type ExternalGroupGuardOptions, type ExternalLinkLookup, type InsertChain, type LedgerIdentityRow, type LedgerIdentityTables, type LinkGroupInput, type LinkableAssertion, MEMBERSHIP_MODES, type MemberResolverPort, NEWLY_UNHEALTHY_SYNC_OUTCOMES, type PromotionRepository, type PromotionRepositoryOptions, type PromotionResult, type ReferencedTable, type RemovalFailure, type RemovalOutcome, STRANDED_REASON, type SelectChain, type StrandedRequests, type SyncFailureCause, type SyncLink, type SyncLoggerPort, type SyncMessages, type SyncOutcome, type SyncRepositoryOptions, type SyncRequestOutcome, type SyncRequestQueueOptions, type SyncRequestResult, type SyncScope, type TransactionalOptions, UNHEALTHY_SYNC_OUTCOMES, type UpdateChain, assertGroupMayBeLinked, assertMembershipMode, classifySyncFailure, createDirectoryCatalogReader, createDirectoryCatalogWriter, createDirectoryLinkStore, createDirectorySync, createDirectorySyncRepository, createPromotionRepository, createSyncRequestQueue, defaultExternalGroupGuardMessage, defaultSyncMessages, defineAuthDirectorySchema, findLedgerRowsForIdentity, promoteLedgerForUser, transactionRunner, withExternalGroupGuards };