@authhero/multi-tenancy 15.2.0 → 15.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/multi-tenancy.cjs +1 -1
- package/dist/multi-tenancy.mjs +2968 -1176
- package/dist/types/index.d.ts +5 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/inheritance/legacy.d.ts.map +1 -1
- package/dist/types/inheritance/merge.d.ts +1 -0
- package/dist/types/inheritance/merge.d.ts.map +1 -1
- package/dist/types/inheritance/read.d.ts.map +1 -1
- package/dist/types/inheritance/report.d.ts +6 -2
- package/dist/types/inheritance/report.d.ts.map +1 -1
- package/dist/types/inheritance/types.d.ts +3 -1
- package/dist/types/inheritance/types.d.ts.map +1 -1
- package/dist/types/init.d.ts +84 -1
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/middleware/config-sync-mode.d.ts +39 -0
- package/dist/types/middleware/config-sync-mode.d.ts.map +1 -0
- package/dist/types/middleware/index.d.ts +3 -1
- package/dist/types/middleware/index.d.ts.map +1 -1
- package/dist/types/middleware/protect-synced.d.ts +1 -1
- package/dist/types/middleware/protect-synced.d.ts.map +1 -1
- package/dist/types/middleware/settings-inheritance.d.ts +20 -2
- package/dist/types/middleware/settings-inheritance.d.ts.map +1 -1
- package/dist/types/operations/detach.d.ts +85 -0
- package/dist/types/operations/detach.d.ts.map +1 -0
- package/dist/types/operations/enqueue.d.ts +8 -1
- package/dist/types/operations/enqueue.d.ts.map +1 -1
- package/dist/types/operations/index.d.ts +7 -1
- package/dist/types/operations/index.d.ts.map +1 -1
- package/dist/types/operations/recorder.d.ts +2 -0
- package/dist/types/operations/recorder.d.ts.map +1 -1
- package/dist/types/operations/sync-defaults.d.ts +58 -0
- package/dist/types/operations/sync-defaults.d.ts.map +1 -0
- package/dist/types/operations/tenant-members-request.d.ts +97 -0
- package/dist/types/operations/tenant-members-request.d.ts.map +1 -0
- package/dist/types/operations/types.d.ts +2 -0
- package/dist/types/operations/types.d.ts.map +1 -1
- package/dist/types/rollout/index.d.ts +2 -0
- package/dist/types/rollout/index.d.ts.map +1 -1
- package/dist/types/rollout/payload.d.ts +15 -0
- package/dist/types/rollout/payload.d.ts.map +1 -1
- package/dist/types/rollout/resolved-sync.d.ts +112 -0
- package/dist/types/rollout/resolved-sync.d.ts.map +1 -0
- package/dist/types/rollouts/advance.d.ts +44 -0
- package/dist/types/rollouts/advance.d.ts.map +1 -0
- package/dist/types/rollouts/config.d.ts +54 -0
- package/dist/types/rollouts/config.d.ts.map +1 -0
- package/dist/types/rollouts/controller.d.ts +29 -0
- package/dist/types/rollouts/controller.d.ts.map +1 -0
- package/dist/types/rollouts/enumerate.d.ts +25 -0
- package/dist/types/rollouts/enumerate.d.ts.map +1 -0
- package/dist/types/rollouts/hashes.d.ts +10 -0
- package/dist/types/rollouts/hashes.d.ts.map +1 -0
- package/dist/types/rollouts/index.d.ts +21 -0
- package/dist/types/rollouts/index.d.ts.map +1 -0
- package/dist/types/rollouts/plan.d.ts +29 -0
- package/dist/types/rollouts/plan.d.ts.map +1 -0
- package/dist/types/rollouts/reconcile.d.ts +38 -0
- package/dist/types/rollouts/reconcile.d.ts.map +1 -0
- package/dist/types/rollouts/status.d.ts +28 -0
- package/dist/types/rollouts/status.d.ts.map +1 -0
- package/dist/types/rollouts/trigger.d.ts +52 -0
- package/dist/types/rollouts/trigger.d.ts.map +1 -0
- package/dist/types/rollouts/types.d.ts +25 -0
- package/dist/types/rollouts/types.d.ts.map +1 -0
- package/dist/types/rollouts/verify.d.ts +50 -0
- package/dist/types/rollouts/verify.d.ts.map +1 -0
- package/dist/types/routes/tenants.d.ts.map +1 -1
- package/dist/types/types.d.ts +20 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/tenant-settings.d.ts +13 -0
- package/dist/types/utils/tenant-settings.d.ts.map +1 -0
- package/dist/types/utils/tenant-tree.d.ts +2 -1
- package/dist/types/utils/tenant-tree.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/types/index.d.ts
CHANGED
|
@@ -3,14 +3,17 @@ import { MultiTenancyConfig, MultiTenancyHooks, MultiTenancyBindings, MultiTenan
|
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export { initMultiTenant } from "./init";
|
|
5
5
|
export type { MultiTenantConfig, MultiTenantResult, ControlPlaneConfig, } from "./init";
|
|
6
|
-
export { createDirectRolloutAdapter, projectControlPlaneDefaults, buildControlPlaneDefaultsPayload, applyControlPlaneDefaultsPayload, } from "./rollout";
|
|
7
|
-
export type { ControlPlaneRolloutAdapter, DefaultsProjectionConfig, DefaultsProjectionEntities, DefaultsProjectionResult, EntityProjectionOutcome, ProjectableDefaults, ControlPlaneDefaultsPayload, ControlPlaneDefaultsApplyResult, ControlPlaneTenantSeed, DefaultsPayloadEntities, } from "./rollout";
|
|
6
|
+
export { createDirectRolloutAdapter, projectControlPlaneDefaults, buildControlPlaneDefaultsPayload, applyControlPlaneDefaultsPayload, applyResolvedConfigBlock, buildResolvedConfigBlock, findUndecryptableKeyIds, syncedRowId, } from "./rollout";
|
|
7
|
+
export type { ControlPlaneRolloutAdapter, DefaultsProjectionConfig, DefaultsProjectionEntities, DefaultsProjectionResult, EntityProjectionOutcome, ProjectableDefaults, ControlPlaneDefaultsPayload, ControlPlaneDefaultsApplyResult, ControlPlaneTenantSeed, DefaultsPayloadEntities, ApplyResolvedBlockOptions, ApplyResolvedBlockResult, BuildResolvedBlockOptions, ResolvedConfigBlock, SyncEntity, SyncEntityOutcome, } from "./rollout";
|
|
8
8
|
export * from "./operations";
|
|
9
|
+
export * from "./rollouts";
|
|
9
10
|
export { createSyncHooks } from "./hooks/sync";
|
|
10
11
|
export type { EntitySyncConfig, SyncHooksResult } from "./hooks/sync";
|
|
11
12
|
export { createTenantsOpenAPIRouter } from "./routes";
|
|
12
13
|
export { createMultiTenancyMiddleware, createAccessControlMiddleware, createControlPlaneTenantMiddleware, createSubdomainMiddleware, createDatabaseMiddleware, createProtectSyncedMiddleware, createRuntimeFallbackAdapter, withRuntimeFallback, withSystemResourceServerInheritance, mergeClientWithFallback, } from "./middleware";
|
|
13
14
|
export type { RuntimeFallbackConfig, ControlPlaneResolver } from "./middleware";
|
|
15
|
+
export { createConfigSyncResolver } from "./middleware";
|
|
16
|
+
export type { ConfigSyncResolver, ConfigSyncResolverOptions, } from "./middleware";
|
|
14
17
|
export * from "./inheritance";
|
|
15
18
|
export { createMultiTenancyPlugin } from "./plugin";
|
|
16
19
|
export type { AuthHeroPlugin } from "./plugin";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAajB,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAKhB,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,gCAAgC,EAChC,gCAAgC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAajB,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAKhB,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,gCAAgC,EAChC,gCAAgC,EAChC,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ExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,kBAAkB,GACzB,iBAAiB,CAgBnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB;cAE/C,oBAAoB;eACnB,qBAAqB;0CASnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB;;;;;;;kBAnD9C,oBAAoB;mBACnB,qBAAqB;;;IAwDhC;;;;;;;OAOG;6BAES,OAAO,UAAU,EAAE,YAAY,qBACtB;QAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;KAAE;EAOzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/inheritance/legacy.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAiCrC;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,UAAU,GAAG,SAAS,GACnC,UAAU,
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/inheritance/legacy.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAiCrC;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,UAAU,GAAG,SAAS,GACnC,UAAU,CAkCZ"}
|
|
@@ -17,6 +17,7 @@ export declare function effectiveScope(entity: ConfigEntity, row: Publishable):
|
|
|
17
17
|
* legacy merge behaves: the tenant's values win.
|
|
18
18
|
*/
|
|
19
19
|
export declare function effectiveOverride(row: Publishable): ConfigOverride;
|
|
20
|
+
export declare const SECRET_KEY: RegExp;
|
|
20
21
|
type Layer = ConfigRows;
|
|
21
22
|
/**
|
|
22
23
|
* Merges the config of a parent chain with the tenant's own, with no I/O.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/inheritance/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACd,WAAW,
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/inheritance/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACd,WAAW,EAKZ,MAAM,UAAU,CAAC;AAKlB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EAEf,MAAM,SAAS,CAAC;AAEjB,KAAK,WAAW,GAAG;IACjB,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,WAAW,GACf,WAAW,CAcb;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CAElE;AAED,eAAO,MAAM,UAAU,QAA+C,CAAC;AA0EvE,KAAK,KAAK,GAAG,UAAU,CAAC;AAExB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,GAAG,cAAc,CA0HzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/inheritance/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/inheritance/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA8B,MAAM,UAAU,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,6DAA6D;AAC7D,wBAAsB,cAAc,CAClC,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,UAAU,CAAC,CA8BrB"}
|
|
@@ -13,8 +13,12 @@ export interface InheritanceShadowOptions {
|
|
|
13
13
|
includeExpected?: boolean;
|
|
14
14
|
}
|
|
15
15
|
export interface ShadowReporter {
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Starts a comparison for `tenantId` in the background, if due, and returns
|
|
18
|
+
* it (never rejecting) so a host that must keep the work alive, such as a
|
|
19
|
+
* Worker with `ctx.waitUntil`, can wait for it. Undefined when none started.
|
|
20
|
+
*/
|
|
21
|
+
schedule(tenantId: string, legacyControlPlane: string | undefined): Promise<void> | undefined;
|
|
18
22
|
}
|
|
19
23
|
export declare function createShadowReporter(adapters: DataAdapters, options: InheritanceShadowOptions): ShadowReporter;
|
|
20
24
|
//# sourceMappingURL=report.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/inheritance/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAY,MAAM,UAAU,CAAC;AAGlD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+FAA+F;IAC/F,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAKD,MAAM,WAAW,cAAc;IAC7B
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/inheritance/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAY,MAAM,UAAU,CAAC;AAGlD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+FAA+F;IAC/F,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAKD,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,GAAG,SAAS,GACrC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;CAC9B;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,wBAAwB,GAChC,cAAc,CAiDhB"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { Action, Branding, Connection, EmailProvider, Hook, PromptSetting, ResourceServer } from "authhero";
|
|
1
|
+
import type { Action, Branding, Connection, EmailProvider, Hook, HookCode, PromptSetting, ResourceServer } from "authhero";
|
|
2
2
|
/** Plain config rows for one tenant. Singletons are `null` when unset. */
|
|
3
3
|
export interface ConfigRows {
|
|
4
4
|
connections: Connection[];
|
|
5
5
|
resourceServers: ResourceServer[];
|
|
6
6
|
hooks: Hook[];
|
|
7
|
+
/** Code referenced by `code_id` of the code hooks in `hooks`. */
|
|
8
|
+
hookCode: HookCode[];
|
|
7
9
|
actions: Action[];
|
|
8
10
|
emailProvider: EmailProvider | null;
|
|
9
11
|
branding: Branding | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/inheritance/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,aAAa,EACb,IAAI,EACJ,aAAa,EACb,cAAc,EACf,MAAM,UAAU,CAAC;AAElB,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,aAAa,GAAG,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,eAAe,QAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/inheritance/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,cAAc,EACf,MAAM,UAAU,CAAC;AAElB,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,iEAAiE;IACjE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,aAAa,GAAG,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,eAAe,QAAO,UASjC,CAAC;AAEH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,gBAAgB,GAChB,MAAM,GACN,QAAQ,GACR,eAAe,GACf,UAAU,GACV,gBAAgB,CAAC;AAErB,iEAAiE;AACjE,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD;;;OAGG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
|
package/dist/types/init.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { init, AuthHeroConfig, DataAdapters } from "authhero";
|
|
1
|
+
import { init, AuthHeroConfig, DataAdapters, type ExecuteTenantMemberRequestOptions, type TenantMembersBackend } from "authhero";
|
|
2
|
+
import { enqueueTenantMemberRequest } from "./operations";
|
|
3
|
+
import type { DetachConfigFn, ReconcileTenantMemberRequestsDeps, ReconcileTenantMemberRequestsResult, SyncConfigFn, TenantMemberRequestStore, TenantOperationExecutor } from "./operations";
|
|
4
|
+
import { type RolloutDeps } from "./rollouts";
|
|
2
5
|
import type { ControlPlaneResolver } from "./middleware";
|
|
3
6
|
import type { InheritanceShadowOptions } from "./inheritance";
|
|
4
7
|
/**
|
|
@@ -63,6 +66,55 @@ export interface MultiTenantConfig extends Omit<AuthHeroConfig, "entityHooks" |
|
|
|
63
66
|
* @default false
|
|
64
67
|
*/
|
|
65
68
|
inheritanceShadow?: boolean | InheritanceShadowOptions;
|
|
69
|
+
/**
|
|
70
|
+
* How the `sync-defaults` tenant operation reaches a tenant's database. The
|
|
71
|
+
* default syncs tenants that share the control plane's database in-process
|
|
72
|
+
* and refuses tenants with their own worker and database; pass a transport
|
|
73
|
+
* (for example a dispatch push to the tenant worker) to reach those.
|
|
74
|
+
*/
|
|
75
|
+
syncDefaults?: SyncConfigFn;
|
|
76
|
+
/**
|
|
77
|
+
* How the `detach` tenant operation reaches a tenant's database. The default
|
|
78
|
+
* works on tenants that share the control plane's database, in-process, and
|
|
79
|
+
* refuses tenants with their own worker and database.
|
|
80
|
+
*/
|
|
81
|
+
detachTenant?: DetachConfigFn;
|
|
82
|
+
/**
|
|
83
|
+
* Carries out the team changes that tenants register as requests (issue
|
|
84
|
+
* #1550) as `tenant-members-request` tenant operations, and answers the
|
|
85
|
+
* request with the outcome. Needs the tenant operations adapters, and
|
|
86
|
+
* returns `memberRequests` for the notify endpoint and the scheduled sweep.
|
|
87
|
+
*/
|
|
88
|
+
tenantMemberRequests?: {
|
|
89
|
+
/**
|
|
90
|
+
* The control-plane team backend, built without a request in hand
|
|
91
|
+
* (`createLocalTenantMembersBackend` bound to the control-plane database).
|
|
92
|
+
*/
|
|
93
|
+
getBackend: () => TenantMembersBackend | Promise<TenantMembersBackend>;
|
|
94
|
+
/**
|
|
95
|
+
* How the requests are read and answered. The default reaches tenants that
|
|
96
|
+
* share the control plane's database; pass a transport (for example a
|
|
97
|
+
* dispatch push to the tenant worker) for tenants with their own database.
|
|
98
|
+
*/
|
|
99
|
+
store?: TenantMemberRequestStore;
|
|
100
|
+
/** Who may still ask. See `executeTenantMemberRequest`. */
|
|
101
|
+
isRequesterAllowed?: ExecuteTenantMemberRequestOptions["isRequesterAllowed"];
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* How long each isolate remembers a tenant's `config_sync` mode. The
|
|
105
|
+
* isolates that did not handle the `PATCH` notice a flip within this time.
|
|
106
|
+
* It does not cover a cached client bundle, which can keep serving what was
|
|
107
|
+
* read under the old mode for up to 15 minutes. Lower it for a faster flip at the cost of
|
|
108
|
+
* one more `tenants.get` per isolate and tenant per period.
|
|
109
|
+
* @default 10000
|
|
110
|
+
*/
|
|
111
|
+
configSyncCacheTtlMs?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Starts the per-tenant operations of a fleet rollout. Defaults to the same
|
|
114
|
+
* inline executor as `sync-defaults` requests; Workflows deployments pass
|
|
115
|
+
* `createCloudflareWorkflowsExecutor(...)` so waves run durably.
|
|
116
|
+
*/
|
|
117
|
+
rolloutExecutor?: TenantOperationExecutor;
|
|
66
118
|
/**
|
|
67
119
|
* Control which entities to sync from control plane to child tenants.
|
|
68
120
|
* Set to `false` to disable all syncing.
|
|
@@ -112,6 +164,37 @@ export interface MultiTenantResult {
|
|
|
112
164
|
app: ReturnType<typeof init>["app"];
|
|
113
165
|
/** The control plane tenant ID */
|
|
114
166
|
controlPlaneTenantId: string;
|
|
167
|
+
/**
|
|
168
|
+
* What a scheduled handler needs to keep fleet rollouts moving, present when
|
|
169
|
+
* the control plane carries the rollouts and tenant operations adapters:
|
|
170
|
+
*
|
|
171
|
+
* ```typescript
|
|
172
|
+
* async scheduled(_event, env) {
|
|
173
|
+
* if (!rollouts) return;
|
|
174
|
+
* await reconcileConfigDrift(rollouts); // catches lost triggers
|
|
175
|
+
* await advanceRollouts(rollouts); // starts the next wave
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
rollouts?: RolloutDeps;
|
|
180
|
+
/**
|
|
181
|
+
* Present when `tenantMemberRequests` is configured and the control plane
|
|
182
|
+
* carries the tenant operations adapters.
|
|
183
|
+
*
|
|
184
|
+
* ```typescript
|
|
185
|
+
* // proxyControlPlane.tenantMembers.requests
|
|
186
|
+
* onNotify: (_c, tenantId, requestId) =>
|
|
187
|
+
* memberRequests.enqueue(tenantId, requestId).then(() => {}),
|
|
188
|
+
* // and in a scheduled handler, because a tenant worker cannot run a cron
|
|
189
|
+
* await memberRequests.reconcile();
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
memberRequests?: {
|
|
193
|
+
/** Runs the request for a tenant, once however often it is called. */
|
|
194
|
+
enqueue(tenantId: string, requestId: string): ReturnType<typeof enqueueTenantMemberRequest>;
|
|
195
|
+
/** Finds requests that were never run, or whose run failed, and runs them. */
|
|
196
|
+
reconcile(options?: Partial<Pick<ReconcileTenantMemberRequestsDeps, "tenantIds" | "graceMs" | "maxAttempts">>): Promise<ReconcileTenantMemberRequestsResult>;
|
|
197
|
+
};
|
|
115
198
|
}
|
|
116
199
|
/**
|
|
117
200
|
* Initialize a multi-tenant AuthHero application with sensible defaults.
|
package/dist/types/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,cAAc,EAEd,YAAY,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,cAAc,EAEd,YAAY,EAGZ,KAAK,iCAAiC,EACtC,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AED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CA+Z5E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ResolvedControlPlane } from "./settings-inheritance";
|
|
2
|
+
/**
|
|
3
|
+
* Per-tenant config sync mode (docs/design/tenant-config-inheritance.md,
|
|
4
|
+
* section 5 step 3). A tenant in `synced` mode reads only its own database:
|
|
5
|
+
* the resolver below answers `undefined` ("do not inherit") for it, which every
|
|
6
|
+
* read-time inheritance path already understands.
|
|
7
|
+
*/
|
|
8
|
+
export interface ConfigSyncResolver {
|
|
9
|
+
/** The control plane to inherit from, or `undefined` for opted-out and synced tenants. */
|
|
10
|
+
resolve(params: {
|
|
11
|
+
tenant_id: string;
|
|
12
|
+
}): Promise<ResolvedControlPlane>;
|
|
13
|
+
/** Whether the tenant is in `synced` mode. Cached; never throws. */
|
|
14
|
+
isSynced(tenantId: string): Promise<boolean>;
|
|
15
|
+
/** Forget a tenant's cached mode (or all of them). */
|
|
16
|
+
invalidate(tenantId?: string): void;
|
|
17
|
+
}
|
|
18
|
+
export interface ConfigSyncResolverOptions {
|
|
19
|
+
/** The inheritance target for a tenant before the mode is considered. */
|
|
20
|
+
base: (tenantId: string) => Promise<ResolvedControlPlane>;
|
|
21
|
+
/** Reads the tenant row, from the raw (uncached) adapter. */
|
|
22
|
+
getTenant: (tenantId: string) => Promise<{
|
|
23
|
+
config_sync?: string | null;
|
|
24
|
+
} | null>;
|
|
25
|
+
/** The control plane tenant, which is never treated as synced. */
|
|
26
|
+
controlPlaneTenantId?: string;
|
|
27
|
+
/**
|
|
28
|
+
* How long a tenant's mode is remembered, per isolate. A mode change reaches
|
|
29
|
+
* other isolates within this time, so it is also how long to wait after a flip
|
|
30
|
+
* before judging the result. @default 10000
|
|
31
|
+
*/
|
|
32
|
+
ttlMs?: number;
|
|
33
|
+
/** Upper bound on remembered tenants. @default 1000 */
|
|
34
|
+
maxEntries?: number;
|
|
35
|
+
}
|
|
36
|
+
/** How long an isolate remembers a tenant's `config_sync` mode. */
|
|
37
|
+
export declare const DEFAULT_CONFIG_SYNC_TTL_MS = 10000;
|
|
38
|
+
export declare function createConfigSyncResolver(options: ConfigSyncResolverOptions): ConfigSyncResolver;
|
|
39
|
+
//# sourceMappingURL=config-sync-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-sync-mode.d.ts","sourceRoot":"","sources":["../../../src/middleware/config-sync-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE;;;;;GAKG;AAEH,MAAM,WAAW,kBAAkB;IACjC,0FAA0F;IAC1F,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACtE,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,sDAAsD;IACtD,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,yBAAyB;IACxC,yEAAyE;IACzE,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC1D,6DAA6D;IAC7D,SAAS,EAAE,CACT,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC;QAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACrD,kEAAkE;IAClE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,mEAAmE;AACnE,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GACjC,kBAAkB,CA2CpB"}
|
|
@@ -109,6 +109,8 @@ export declare function createMultiTenancyMiddleware(config: MultiTenancyConfig)
|
|
|
109
109
|
Variables: MultiTenancyVariables;
|
|
110
110
|
}>;
|
|
111
111
|
export { createProtectSyncedMiddleware } from "./protect-synced";
|
|
112
|
-
export { createRuntimeFallbackAdapter, withRuntimeFallback, withSystemResourceServerInheritance, mergeClientWithFallback, } from "./settings-inheritance";
|
|
112
|
+
export { createRuntimeFallbackAdapter, withRuntimeFallback, withSystemResourceServerInheritance, mergeClientWithFallback, buildResolver, } from "./settings-inheritance";
|
|
113
|
+
export { createConfigSyncResolver } from "./config-sync-mode";
|
|
114
|
+
export type { ConfigSyncResolver, ConfigSyncResolverOptions, } from "./config-sync-mode";
|
|
113
115
|
export type { RuntimeFallbackConfig, ControlPlaneResolver, } from "./settings-inheritance";
|
|
114
116
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAGzC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAIlB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kCAAkC,CAChD,oBAAoB,EAAE,MAAM,GAC3B,iBAAiB,CAAC;IACnB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,qBAAqB,CAAC;CAClC,CAAC,CAUD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,kBAAkB,GACzB,iBAAiB,CAAC;IACnB,QAAQ,EAAE,oBAAoB,CAAC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;IACnB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,qBAAqB,CAAC;CAClC,CAAC,CAsDD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,kBAAkB,GACzB,iBAAiB,CAAC;IACnB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,qBAAqB,CAAC;CAClC,CAAC,CAsED;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,kBAAkB,GACzB,iBAAiB,CAAC;IACnB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,qBAAqB,CAAC;CAClC,CAAC,CAiCD;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,kBAAkB,GACzB,iBAAiB,CAAC;IACnB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,qBAAqB,CAAC;CAClC,CAAC,CAiBD;AAGD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,mCAAmC,EACnC,uBAAuB,EACvB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protect-synced.d.ts","sourceRoot":"","sources":["../../../src/middleware/protect-synced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"protect-synced.d.ts","sourceRoot":"","sources":["../../../src/middleware/protect-synced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAG5D;;GAEG;AACH,UAAU,qBAAqB;IAC7B,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,sBAAsB;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAoRD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,6BAA6B,IAAI,iBAAiB,CAAC;IACjE,QAAQ,EAAE,qBAAqB,CAAC;IAChC,SAAS,EAAE,sBAAsB,CAAC;CACnC,CAAC,CA0CD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataAdapters, Connection, Client, ResourceServer, ResourceServerScope } from "authhero";
|
|
2
2
|
import { InheritanceShadowOptions } from "../inheritance/report";
|
|
3
|
+
import { ConfigSyncResolver } from "./config-sync-mode";
|
|
3
4
|
/**
|
|
4
5
|
* Merges a connection with control plane fallback options.
|
|
5
6
|
*/
|
|
@@ -30,7 +31,7 @@ export declare function mergeClientWithFallback(client: Client, controlPlaneClie
|
|
|
30
31
|
* Resolved inheritance target for a single tenant. `undefined` means the
|
|
31
32
|
* tenant opts out of inheritance entirely.
|
|
32
33
|
*/
|
|
33
|
-
type ResolvedControlPlane = {
|
|
34
|
+
export type ResolvedControlPlane = {
|
|
34
35
|
tenantId: string;
|
|
35
36
|
clientId?: string;
|
|
36
37
|
} | undefined;
|
|
@@ -45,6 +46,17 @@ type ResolvedControlPlane = {
|
|
|
45
46
|
export type ControlPlaneResolver = (params: {
|
|
46
47
|
tenant_id: string;
|
|
47
48
|
}) => ResolvedControlPlane | Promise<ResolvedControlPlane>;
|
|
49
|
+
/**
|
|
50
|
+
* Builds a single resolver from either a static `{tenantId, clientId}` pair
|
|
51
|
+
* or a user-supplied resolver. The user-supplied resolver, when present,
|
|
52
|
+
* fully replaces the static fallback — that's the lever a caller uses to
|
|
53
|
+
* disable inheritance for individual tenants by returning `undefined`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function buildResolver(config: {
|
|
56
|
+
controlPlaneTenantId?: string;
|
|
57
|
+
controlPlaneClientId?: string;
|
|
58
|
+
resolveControlPlane?: ControlPlaneResolver;
|
|
59
|
+
}): (tenantId: string) => Promise<ResolvedControlPlane>;
|
|
48
60
|
/**
|
|
49
61
|
* Wraps data adapters with is_system-gated resource server scope inheritance
|
|
50
62
|
* from a control plane tenant.
|
|
@@ -98,6 +110,13 @@ export interface RuntimeFallbackConfig {
|
|
|
98
110
|
* @default false
|
|
99
111
|
*/
|
|
100
112
|
inheritanceShadow?: boolean | InheritanceShadowOptions;
|
|
113
|
+
/**
|
|
114
|
+
* Per-tenant `config_sync` mode support. Tenants in `synced` mode read only
|
|
115
|
+
* their own database. Pass a resolver to share its cache with other adapters
|
|
116
|
+
* (the management adapter); omit it and one is created. Failed lookups fall
|
|
117
|
+
* back to inheriting.
|
|
118
|
+
*/
|
|
119
|
+
configSync?: ConfigSyncResolver;
|
|
101
120
|
}
|
|
102
121
|
/**
|
|
103
122
|
* Creates a data adapter wrapper that provides runtime settings fallback from a control plane tenant.
|
|
@@ -162,5 +181,4 @@ export declare function isInheritableHook(hook: unknown): boolean;
|
|
|
162
181
|
* ```
|
|
163
182
|
*/
|
|
164
183
|
export declare function withRuntimeFallback(baseAdapters: DataAdapters, config: RuntimeFallbackConfig): DataAdapters;
|
|
165
|
-
export {};
|
|
166
184
|
//# sourceMappingURL=settings-inheritance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-inheritance.d.ts","sourceRoot":"","sources":["../../../src/middleware/settings-inheritance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,UAAU,EACV,MAAM,EACN,cAAc,EACd,mBAAmB,EAGpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,UAAU,EACtB,uBAAuB,EAAE,UAAU,EAAE,GACpC,UAAU,CAwBZ;AAcD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,mBAAmB,EAAE,GAAG,SAAS,EAC/C,kBAAkB,EAAE,mBAAmB,EAAE,GAAG,SAAS,GACpD,mBAAmB,EAAE,CAmBvB;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,cAAc,EAAE,cAAc,EAC9B,0BAA0B,EAAE,cAAc,GAAG,IAAI,GAChD,cAAc,CAYhB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAChC,MAAM,CAqBR;AAED;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"settings-inheritance.d.ts","sourceRoot":"","sources":["../../../src/middleware/settings-inheritance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,UAAU,EACV,MAAM,EACN,cAAc,EACd,mBAAmB,EAGpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,UAAU,EACtB,uBAAuB,EAAE,UAAU,EAAE,GACpC,UAAU,CAwBZ;AAcD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,mBAAmB,EAAE,GAAG,SAAS,EAC/C,kBAAkB,EAAE,mBAAmB,EAAE,GAAG,SAAS,GACpD,mBAAmB,EAAE,CAmBvB;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,cAAc,EAAE,cAAc,EAC9B,0BAA0B,EAAE,cAAc,GAAG,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CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,qBAAqB,GAC5B,YAAY,CA6Ld;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAKxD;AA2FD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,qBAAqB,GAC5B,YAAY,CAEd"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { DataAdapters, TenantOperation } from "authhero";
|
|
2
|
+
import type { OperationRecorder } from "./recorder";
|
|
3
|
+
/**
|
|
4
|
+
* `detach`: a synced tenant leaves its parent (docs/design/tenant-config-
|
|
5
|
+
* inheritance.md, open question 1). The copies a sync delivered (`sy` ids) are
|
|
6
|
+
* either turned into the tenant's own rows (a snapshot: the content is kept,
|
|
7
|
+
* the ids are normal, and `scope`, `override` and `enforce` are dropped, so
|
|
8
|
+
* nothing locks them), or with `clean` removed. The tenant row then gets
|
|
9
|
+
* `config_sync: "detached"` and no parent, so nothing inherits or syncs into it
|
|
10
|
+
* again.
|
|
11
|
+
*
|
|
12
|
+
* Platform rows (`scope: "platform"`) run for the tenant but are hidden from
|
|
13
|
+
* its admins, so converting them would expose code and secrets. They are kept
|
|
14
|
+
* as copies and reported; only `clean` removes them.
|
|
15
|
+
*/
|
|
16
|
+
export type DetachEntity = "connection" | "resourceServer" | "hookCode" | "action" | "hook";
|
|
17
|
+
export interface DetachOptions {
|
|
18
|
+
/** Report what would happen; write nothing. */
|
|
19
|
+
dryRun: boolean;
|
|
20
|
+
/** Remove the copies instead of turning them into the tenant's own rows. */
|
|
21
|
+
clean: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface DetachEntityOutcome {
|
|
24
|
+
converted: number;
|
|
25
|
+
removed: number;
|
|
26
|
+
skipped: number;
|
|
27
|
+
errors: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface DetachRow {
|
|
30
|
+
entity: DetachEntity;
|
|
31
|
+
key: string;
|
|
32
|
+
/** `kept`: a platform row that stays as a copy (or code it runs). */
|
|
33
|
+
action: "converted" | "removed" | "kept";
|
|
34
|
+
}
|
|
35
|
+
export interface DetachResult {
|
|
36
|
+
status: "detached" | "dry-run" | "already-detached" | "partial";
|
|
37
|
+
/** `convert|remove|skip <entity>:<key>` for every row looked at. */
|
|
38
|
+
changes: string[];
|
|
39
|
+
/** The same rows, structured. */
|
|
40
|
+
rows: DetachRow[];
|
|
41
|
+
entities: Record<DetachEntity, DetachEntityOutcome>;
|
|
42
|
+
}
|
|
43
|
+
export type DetachConfigFn = (tenantId: string, options: DetachOptions) => Promise<DetachResult>;
|
|
44
|
+
/** Reads the operation's `input` (fixed at creation, never secrets). */
|
|
45
|
+
export declare function detachOptionsOf(operation: Pick<TenantOperation, "input">): DetachOptions;
|
|
46
|
+
/** Every per-entity error message the detach reported. */
|
|
47
|
+
export declare function detachErrors(result: DetachResult): string[];
|
|
48
|
+
/** The JSON-serialisable outcome stored in the operation's `result`. */
|
|
49
|
+
export declare function summarizeDetachResult(result: DetachResult, options: DetachOptions): Record<string, unknown>;
|
|
50
|
+
/** The step the executors run: detach, record the outcome, fail on errors. */
|
|
51
|
+
export declare function runDetachStep(params: {
|
|
52
|
+
operation: Pick<TenantOperation, "id" | "tenant_id" | "input">;
|
|
53
|
+
detachTenant: DetachConfigFn;
|
|
54
|
+
recorder: Pick<OperationRecorder, "setResult">;
|
|
55
|
+
/** Called after a run that really detached the tenant (not a preview). */
|
|
56
|
+
onDetached?: (tenantId: string) => void;
|
|
57
|
+
}): Promise<Record<string, unknown>>;
|
|
58
|
+
/** An empty result with the given status, for when nothing is looked at. */
|
|
59
|
+
export declare function emptyDetachResult(status: DetachResult["status"]): DetachResult;
|
|
60
|
+
/**
|
|
61
|
+
* Throws unless a tenant can be detached. Detaching keeps what the tenant
|
|
62
|
+
* holds, so the inherited config has to be in its database: a tenant that
|
|
63
|
+
* inherits on read has none of it there, and would lose it silently.
|
|
64
|
+
*/
|
|
65
|
+
export declare function assertDetachEligible(tenantId: string, tenant: {
|
|
66
|
+
config_sync?: string | null;
|
|
67
|
+
}): void;
|
|
68
|
+
/** The tenant row of a detached tenant: no parent and no sync state. */
|
|
69
|
+
export declare function markTenantDetached(adapters: Pick<DataAdapters, "tenants">, tenantId: string): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* The row work of a detach, in the database `adapters` reads and writes (the
|
|
72
|
+
* raw layer, so secrets are copied as stored). It does not look at the tenant
|
|
73
|
+
* row or change it: the caller checks eligibility and, when the status comes
|
|
74
|
+
* back `detached`, marks the tenant. A tenant worker runs this on its own
|
|
75
|
+
* database while the control plane holds the tenant row that decides.
|
|
76
|
+
* Rows are created before the copies they replace are removed.
|
|
77
|
+
*/
|
|
78
|
+
export declare function detachTenantRows(adapters: DataAdapters, tenantId: string, options: DetachOptions): Promise<DetachResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Detaches `tenantId` from its parent in the database `adapters` reads and
|
|
81
|
+
* writes, which should be the raw layer so secrets are copied as stored
|
|
82
|
+
* (ciphertext).
|
|
83
|
+
*/
|
|
84
|
+
export declare function createInProcessDetach(adapters: DataAdapters): DetachConfigFn;
|
|
85
|
+
//# sourceMappingURL=detach.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detach.d.ts","sourceRoot":"","sources":["../../../src/operations/detach.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EAQhB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,gBAAgB,GAChB,UAAU,GACV,QAAQ,GACR,MAAM,CAAC;AAEX,MAAM,WAA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I,GAAG,WAAW,GAAG,OAAO,CAAC,CAAC;IAC/D,YAAY,EAAE,cAAc,CAAC;IAC7B,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;IAC/C,0EAA0E;IAC1E,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAwBnC;AA4BD,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,GAC7B,YAAY,CAad;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACtC,IAAI,CAMN;AAED,wEAAwE;AACxE,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,EACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAwUvB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,YAAY,GAAG,cAAc,CAoB5E"}
|
|
@@ -13,5 +13,12 @@ export declare function createOperationRow(stores: TenantOperationStores, params
|
|
|
13
13
|
* finalized it) and the error is rethrown so callers keep their existing
|
|
14
14
|
* failure semantics.
|
|
15
15
|
*/
|
|
16
|
-
export declare function enqueueTenantOperation(stores: TenantOperationStores, executor: TenantOperationExecutor, params: EnqueueTenantOperationParams
|
|
16
|
+
export declare function enqueueTenantOperation(stores: TenantOperationStores, executor: TenantOperationExecutor, params: EnqueueTenantOperationParams, options?: {
|
|
17
|
+
/**
|
|
18
|
+
* Resolve with the failed operation row instead of rethrowing when the
|
|
19
|
+
* executor's run fails. For operations whose row is the deliverable
|
|
20
|
+
* (a sync reports its outcome there), not for callers that need the error.
|
|
21
|
+
*/
|
|
22
|
+
returnFailed?: boolean;
|
|
23
|
+
}): Promise<TenantOperation>;
|
|
17
24
|
//# sourceMappingURL=enqueue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enqueue.d.ts","sourceRoot":"","sources":["../../../src/operations/enqueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAIjB;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,4BAA4B,EACpC,MAAM,EAAE,uBAAuB,CAAC,QAAQ,CAAC,GACxC,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"enqueue.d.ts","sourceRoot":"","sources":["../../../src/operations/enqueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAIjB;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,4BAA4B,EACpC,MAAM,EAAE,uBAAuB,CAAC,QAAQ,CAAC,GACxC,OAAO,CAAC,eAAe,CAAC,CA0B1B;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,EAAE,uBAAuB,EACjC,MAAM,EAAE,4BAA4B,EACpC,OAAO,GAAE;IACP;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACnB,GACL,OAAO,CAAC,eAAe,CAAC,CAmC1B"}
|
|
@@ -4,6 +4,12 @@ export { createOperationRecorder, errorToMessage, isTerminalStatus, } from "./re
|
|
|
4
4
|
export type { OperationRecorder } from "./recorder";
|
|
5
5
|
export { createInlineExecutor, inlineStepRunner } from "./inline-executor";
|
|
6
6
|
export type { InlineExecutorConfig, TenantOperationDefinitions, TenantOperationStep, TenantOperationStepContext, } from "./inline-executor";
|
|
7
|
-
export { enqueueTenantOperation } from "./enqueue";
|
|
7
|
+
export { createOperationRow, enqueueTenantOperation } from "./enqueue";
|
|
8
|
+
export { createInProcessSyncConfig, runSyncDefaultsStep, summarizeSyncResult, syncErrors, syncOptionsOf, } from "./sync-defaults";
|
|
9
|
+
export type { SyncConfigFn, SyncConfigOptions } from "./sync-defaults";
|
|
10
|
+
export { assertDetachEligible, createInProcessDetach, detachTenantRows, emptyDetachResult, markTenantDetached, detachErrors, detachOptionsOf, runDetachStep, summarizeDetachResult, } from "./detach";
|
|
11
|
+
export type { DetachConfigFn, DetachOptions, DetachResult } from "./detach";
|
|
8
12
|
export { runRecordedTenantOperation } from "./record-provision";
|
|
13
|
+
export { MAX_MEMBER_REQUEST_ATTEMPTS, createInProcessMemberRequestStore, enqueueTenantMemberRequest, memberRequestIdOf, reconcileTenantMemberRequests, runTenantMembersRequestStep, } from "./tenant-members-request";
|
|
14
|
+
export type { ReconcileTenantMemberRequestsDeps, ReconcileTenantMemberRequestsResult, RunTenantMembersRequestParams, TenantMemberRequestStore, } from "./tenant-members-request";
|
|
9
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/operations/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,YAAY,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/operations/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,YAAY,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACV,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EACL,2BAA2B,EAC3B,iCAAiC,EACjC,0BAA0B,EAC1B,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,iCAAiC,EACjC,mCAAmC,EACnC,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,0BAA0B,CAAC"}
|
|
@@ -20,6 +20,8 @@ export declare function createOperationRecorder(stores: TenantOperationStores):
|
|
|
20
20
|
detail?: Record<string, unknown>;
|
|
21
21
|
attempt?: number;
|
|
22
22
|
}): Promise<void>;
|
|
23
|
+
/** Stores the operation's outcome (e.g. a dry-run diff). Idempotent. */
|
|
24
|
+
setResult(operationId: string, result: Record<string, unknown>): Promise<void>;
|
|
23
25
|
markSucceeded(operationId: string): Promise<void>;
|
|
24
26
|
markFailed(operationId: string, error: unknown): Promise<void>;
|
|
25
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../../../src/operations/recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAIhD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAcrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,qBAAqB;6BAIlC,MAAM,gBAAgB,MAAM;gCAOzB,MAAM,QAAQ,MAAM;6BAKvC,MAAM,SACZ;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EACH,SAAS,GACT,WAAW,GACX,QAAQ,GACR,SAAS,GACT,SAAS,GACT,YAAY,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;+
|
|
1
|
+
{"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../../../src/operations/recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAIhD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAcrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,qBAAqB;6BAIlC,MAAM,gBAAgB,MAAM;gCAOzB,MAAM,QAAQ,MAAM;6BAKvC,MAAM,SACZ;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EACH,SAAS,GACT,WAAW,GACX,QAAQ,GACR,SAAS,GACT,SAAS,GACT,YAAY,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAWH,wEAAwE;2BAC3C,MAAM,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;+BAInC,MAAM;4BAQT,MAAM,SAAS,OAAO;EAQvD;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE3E,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,OAAO,CAI3E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { DataAdapters, TenantOperation } from "authhero";
|
|
2
|
+
import { ApplyResolvedBlockResult } from "../rollout/resolved-sync";
|
|
3
|
+
import type { ControlPlaneResolver } from "../middleware";
|
|
4
|
+
import type { OperationRecorder } from "./recorder";
|
|
5
|
+
/**
|
|
6
|
+
* The `sync-defaults` tenant operation (docs/design/tenant-config-inheritance.md
|
|
7
|
+
* sections 4.1 and 5 step 4): sync one tenant's resolved parent-chain config
|
|
8
|
+
* into its own database, as a tracked operation with history.
|
|
9
|
+
*
|
|
10
|
+
* Execution is split from transport. The steps below are shared by the inline
|
|
11
|
+
* and the Cloudflare Workflows executor; how the block reaches the tenant's
|
|
12
|
+
* database (in-process, or pushed to a tenant worker) is a `SyncConfigFn`.
|
|
13
|
+
*/
|
|
14
|
+
export interface SyncConfigOptions {
|
|
15
|
+
/** Compute and report the diff; write nothing. */
|
|
16
|
+
dryRun: boolean;
|
|
17
|
+
/** Apply even when the tenant's stored hash equals the block's. */
|
|
18
|
+
force: boolean;
|
|
19
|
+
/** Remove synced copies the parent no longer shares. */
|
|
20
|
+
prune?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Syncs one tenant and returns what happened (or, for a dry run, what would). */
|
|
23
|
+
export type SyncConfigFn = (tenantId: string, options: SyncConfigOptions) => Promise<ApplyResolvedBlockResult>;
|
|
24
|
+
/** Reads the operation's `input` (fixed at creation, never secrets). */
|
|
25
|
+
export declare function syncOptionsOf(operation: Pick<TenantOperation, "input">): SyncConfigOptions;
|
|
26
|
+
/** Every per-entity error message the sync reported. */
|
|
27
|
+
export declare function syncErrors(result: ApplyResolvedBlockResult): string[];
|
|
28
|
+
/**
|
|
29
|
+
* The JSON-serialisable outcome stored in the operation's `result`: the status,
|
|
30
|
+
* hash, per-entity counts, the changed `entity:key` list, the same changes as
|
|
31
|
+
* structured `rows`, and a capped list of the error messages. Never row content
|
|
32
|
+
* or secrets.
|
|
33
|
+
*/
|
|
34
|
+
export declare function summarizeSyncResult(result: ApplyResolvedBlockResult, options: SyncConfigOptions): Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* The step both executors run: sync, record the outcome on the operation row,
|
|
37
|
+
* and fail the step when any row reported an error. The result is written
|
|
38
|
+
* before the failure is raised so a failed run still shows what it did.
|
|
39
|
+
*/
|
|
40
|
+
export declare function runSyncDefaultsStep(params: {
|
|
41
|
+
operation: Pick<TenantOperation, "id" | "tenant_id" | "input">;
|
|
42
|
+
syncConfig: SyncConfigFn;
|
|
43
|
+
recorder: Pick<OperationRecorder, "setResult">;
|
|
44
|
+
}): Promise<Record<string, unknown>>;
|
|
45
|
+
/**
|
|
46
|
+
* Sync for tenants whose database is the control plane's own (shared
|
|
47
|
+
* deployments). Reads the chain from, and applies the block to, `adapters`,
|
|
48
|
+
* which should be the layer that returns secrets as stored (ciphertext) so they
|
|
49
|
+
* are copied without being decrypted. A tenant with its own worker and database
|
|
50
|
+
* (`deployment_type: "wfp"`) is not reachable this way: use a dispatch
|
|
51
|
+
* transport.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createInProcessSyncConfig(adapters: DataAdapters, config: {
|
|
54
|
+
controlPlaneTenantId: string;
|
|
55
|
+
resolveControlPlane?: ControlPlaneResolver;
|
|
56
|
+
maxDepth?: number;
|
|
57
|
+
}): SyncConfigFn;
|
|
58
|
+
//# sourceMappingURL=sync-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-defaults.d.ts","sourceRoot":"","sources":["../../../src/operations/sync-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EACL,wBAAwB,EAGzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;;GAQG;AAEH,MAAM,WAAW,iBAAiB;IAChC,kDAAkD;IAClD,MAAM,EAAE,OAAO,CAAC;IAChB,mEAAmE;IACnE,KAAK,EAAE,OAAO,CAAC;IACf,wDAAwD;IACxD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA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