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