@authhero/multi-tenancy 15.2.0 → 15.3.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 +2251 -1204
- 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/types.d.ts +3 -1
- package/dist/types/inheritance/types.d.ts.map +1 -1
- package/dist/types/init.d.ts +28 -0
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/middleware/config-sync-mode.d.ts +36 -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/enqueue.d.ts +8 -1
- package/dist/types/operations/enqueue.d.ts.map +1 -1
- package/dist/types/operations/index.d.ts +3 -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 +55 -0
- package/dist/types/operations/sync-defaults.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 +91 -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 +19 -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/routes/tenants.d.ts.map +1 -1
- package/dist/types/types.d.ts +12 -0
- package/dist/types/types.d.ts.map +1 -1
- 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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Rollout } from "authhero";
|
|
2
|
+
import type { RolloutDeps } from "./types";
|
|
3
|
+
export type RolloutTickOutcome = "skipped" | "waiting" | "planned-empty" | "paused" | "started" | "running" | "done";
|
|
4
|
+
export interface RolloutTickResult {
|
|
5
|
+
rolloutId: string;
|
|
6
|
+
outcome: RolloutTickOutcome;
|
|
7
|
+
/** Operations started by this tick. */
|
|
8
|
+
started: number;
|
|
9
|
+
/** The wave being worked on, when there is one. */
|
|
10
|
+
wave?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Advances one rollout by one step. Stateless and idempotent: all state is the
|
|
14
|
+
* rollout row and its operations, so a tick can run from a cron, after a
|
|
15
|
+
* request, or twice at once.
|
|
16
|
+
*
|
|
17
|
+
* 1. A write-triggered rollout waits out its debounce, then is planned.
|
|
18
|
+
* 2. The current wave is the lowest one with unfinished operations. Before it
|
|
19
|
+
* starts, the previous wave is checked: the canary pauses the rollout on any
|
|
20
|
+
* failure, later waves when the failed fraction exceeds the threshold.
|
|
21
|
+
* 3. Up to `max_concurrent` pending operations of the current wave are started.
|
|
22
|
+
* 4. When every operation is finished the rollout is `done`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function advanceRollout(deps: RolloutDeps, rolloutOrId: Rollout | string): Promise<RolloutTickResult>;
|
|
25
|
+
export interface AdvanceRolloutsOptions {
|
|
26
|
+
/** Most rollouts to advance in one call. @default 20 */
|
|
27
|
+
limit?: number;
|
|
28
|
+
logger?: Pick<Console, "warn">;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Advances every open `config-sync` rollout one step. Meant for a host's
|
|
32
|
+
* scheduled handler (every few minutes). A rollout that throws does not stop
|
|
33
|
+
* the others.
|
|
34
|
+
*/
|
|
35
|
+
export declare function advanceRollouts(deps: RolloutDeps, options?: AdvanceRolloutsOptions): Promise<RolloutTickResult[]>;
|
|
36
|
+
/** Pauses a rollout; nothing further is started until it is resumed. */
|
|
37
|
+
export declare function pauseRollout(deps: RolloutDeps, rolloutId: string, reason?: string): Promise<Rollout | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Resumes a paused rollout, accepting the failures that paused it: the waves
|
|
40
|
+
* finished so far are no longer checked, and the next wave starts on the next
|
|
41
|
+
* tick. Tenants that failed are picked up again by the next drift reconcile.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resumeRollout(deps: RolloutDeps, rolloutId: string): Promise<Rollout | null>;
|
|
44
|
+
//# sourceMappingURL=advance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advance.d.ts","sourceRoot":"","sources":["../../../src/rollouts/advance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AAUzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,SAAS,GACT,eAAe,GACf,QAAQ,GACR,SAAS,GACT,SAAS,GACT,MAAM,CAAC;AAEX,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAiCD;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,WAAW,EACjB,WAAW,EAAE,OAAO,GAAG,MAAM,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CA6G5B;AAED,MAAM,WAAW,sBAAsB;IACrC,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAiB9B;AAED,wEAAwE;AACxE,wBAAsB,YAAY,CAChC,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,SAA0B,GAC/B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAOzB;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAoBzB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Rollout } from "authhero";
|
|
2
|
+
/**
|
|
3
|
+
* Settings of a `config-sync` rollout, stored in the rollout's `config` column.
|
|
4
|
+
* Waves are cumulative percentages of the rolled-out tenants; the canary is a
|
|
5
|
+
* count that goes first. A wave is checked when it finishes: the canary pauses
|
|
6
|
+
* the rollout on any failure, later waves when the failed fraction exceeds
|
|
7
|
+
* `failure_threshold`.
|
|
8
|
+
*/
|
|
9
|
+
export interface ConfigSyncRolloutConfig {
|
|
10
|
+
/** Tenants synced first, on their own. */
|
|
11
|
+
canary: number;
|
|
12
|
+
/** Cumulative percentages, ascending, ending at 100. */
|
|
13
|
+
waves: number[];
|
|
14
|
+
/** Failed fraction of a wave (0..1) above which the rollout pauses. */
|
|
15
|
+
failure_threshold: number;
|
|
16
|
+
/** Operations started per tick. */
|
|
17
|
+
max_concurrent: number;
|
|
18
|
+
/** Quiet time after the last write before a write-triggered rollout plans. */
|
|
19
|
+
debounce_ms: number;
|
|
20
|
+
/** What started it. */
|
|
21
|
+
trigger: "write" | "reconcile" | "manual";
|
|
22
|
+
/** The tenant whose descendants are rolled out to. */
|
|
23
|
+
root_tenant_id: string;
|
|
24
|
+
/** The tenant whose write requested it (write trigger). */
|
|
25
|
+
origin_tenant_id?: string;
|
|
26
|
+
/** Sync nothing, only report the diff. */
|
|
27
|
+
dry_run?: boolean;
|
|
28
|
+
/** Apply even when a tenant's stored hash matches. */
|
|
29
|
+
force?: boolean;
|
|
30
|
+
/** False while a write-triggered request waits out its debounce. */
|
|
31
|
+
planned?: boolean;
|
|
32
|
+
/** Tenants in the rollout, set when planned. */
|
|
33
|
+
tenant_count?: number;
|
|
34
|
+
/** Waves up to and including this one have been accepted by an operator. */
|
|
35
|
+
accepted_through?: number;
|
|
36
|
+
}
|
|
37
|
+
export declare const DEFAULT_ROLLOUT_WAVES: number[];
|
|
38
|
+
export declare const DEFAULT_ROLLOUT_SETTINGS: {
|
|
39
|
+
readonly canary: 1;
|
|
40
|
+
readonly waves: number[];
|
|
41
|
+
readonly failure_threshold: 0.1;
|
|
42
|
+
readonly max_concurrent: 25;
|
|
43
|
+
readonly debounce_ms: 60000;
|
|
44
|
+
};
|
|
45
|
+
/** Reads a rollout's config, filling defaults for anything missing. */
|
|
46
|
+
export declare function readRolloutConfig(rollout: Pick<Rollout, "config">): ConfigSyncRolloutConfig;
|
|
47
|
+
/**
|
|
48
|
+
* Assigns each of `count` tenants (already in rollout order) to a wave: wave 0
|
|
49
|
+
* is the canary, then one wave per percentage step. Boundaries are
|
|
50
|
+
* `ceil(count * pct / 100)`; empty waves are dropped and the last wave always
|
|
51
|
+
* reaches the end.
|
|
52
|
+
*/
|
|
53
|
+
export declare function assignWaves(count: number, canary: number, waves: number[]): number[];
|
|
54
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/rollouts/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uEAAuE;IACvE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IAEpB,uBAAuB;IACvB,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC1C,sDAAsD;IACtD,cAAc,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sDAAsD;IACtD,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,qBAAqB,UAAgB,CAAC;AAEnD,eAAO,MAAM,wBAAwB;;;;;;CAM3B,CAAC;AAEX,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAC/B,uBAAuB,CAYzB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,EAAE,CA0BV"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Rollout } from "authhero";
|
|
2
|
+
import type { RolloutDeps } from "./types";
|
|
3
|
+
export interface CreateRolloutParams {
|
|
4
|
+
/** Roll out to the synced descendants of this tenant. Defaults to the control plane. */
|
|
5
|
+
rootTenantId?: string;
|
|
6
|
+
/** Limit the rollout to these tenants (those that are synced descendants). */
|
|
7
|
+
tenantIds?: string[];
|
|
8
|
+
canary?: number;
|
|
9
|
+
waves?: number[];
|
|
10
|
+
failureThreshold?: number;
|
|
11
|
+
/** Operations started per tick. */
|
|
12
|
+
maxConcurrent?: number;
|
|
13
|
+
dryRun?: boolean;
|
|
14
|
+
force?: boolean;
|
|
15
|
+
initiatedBy?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface RolloutController {
|
|
18
|
+
/** Plans a manual rollout and starts its canary. */
|
|
19
|
+
create(params: CreateRolloutParams): Promise<Rollout>;
|
|
20
|
+
pause(id: string, reason?: string): Promise<Rollout | null>;
|
|
21
|
+
resume(id: string): Promise<Rollout | null>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The operations a management API needs on rollouts that go beyond reading and
|
|
25
|
+
* updating rows. Wired by `initMultiTenant`, like the tenant operation
|
|
26
|
+
* executor.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createRolloutController(deps: RolloutDeps): RolloutController;
|
|
29
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/rollouts/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAOxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,WAAW,mBAAmB;IAClC,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mCAAmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtD,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC5D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,iBAAiB,CAgC5E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type DataAdapters } from "authhero";
|
|
2
|
+
export interface FleetTenant {
|
|
3
|
+
tenantId: string;
|
|
4
|
+
/** Levels below the root; 1 for a direct child. */
|
|
5
|
+
depth: number;
|
|
6
|
+
/** The content hash last applied to the tenant, if any. */
|
|
7
|
+
appliedHash: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface EnumerateOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The control plane a tenant without a `parent_tenant_id` inherits from, as
|
|
12
|
+
* `resolveTenantChain` uses it (`undefined` when the tenant opts out).
|
|
13
|
+
*/
|
|
14
|
+
resolveLegacyParent: (tenantId: string) => Promise<string | undefined>;
|
|
15
|
+
/** Longest chain to follow before giving up on a tenant (cycle guard). */
|
|
16
|
+
maxDepth?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The tenants below `rootId` that receive pushes (`config_sync: "synced"`),
|
|
20
|
+
* ordered by depth and then id, so a parent is always rolled out before its
|
|
21
|
+
* children. Parents are resolved like `resolveTenantChain`: `parent_tenant_id`,
|
|
22
|
+
* else the legacy control plane. Reads every tenant once.
|
|
23
|
+
*/
|
|
24
|
+
export declare function listSyncedDescendants(adapters: Pick<DataAdapters, "tenants">, rootId: string, options: EnumerateOptions): Promise<FleetTenant[]>;
|
|
25
|
+
//# sourceMappingURL=enumerate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumerate.d.ts","sourceRoot":"","sources":["../../../src/rollouts/enumerate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAe,MAAM,UAAU,CAAC;AAEpE,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACvE,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,EACvC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,WAAW,EAAE,CAAC,CA4CxB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RolloutDeps } from "./types";
|
|
2
|
+
/** The tenant the sync would treat as the implicit parent of `tenantId`. */
|
|
3
|
+
export declare function resolveLegacyParent(deps: Pick<RolloutDeps, "controlPlaneTenantId" | "resolveControlPlane">, tenantId: string): Promise<string | undefined>;
|
|
4
|
+
/**
|
|
5
|
+
* The hash a sync of `tenantId` would store right now. The hash depends on the
|
|
6
|
+
* chain and its content, not on the tenant, so tenants that share a chain share
|
|
7
|
+
* one computation (memoised for the life of the returned function).
|
|
8
|
+
*/
|
|
9
|
+
export declare function createExpectedHash(deps: Pick<RolloutDeps, "adapters" | "controlPlaneTenantId" | "resolveControlPlane" | "maxDepth">): (tenantId: string) => Promise<string>;
|
|
10
|
+
//# sourceMappingURL=hashes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashes.d.ts","sourceRoot":"","sources":["../../../src/rollouts/hashes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,4EAA4E;AAC5E,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,sBAAsB,GAAG,qBAAqB,CAAC,EACvE,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAG7B;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,CACR,WAAW,EACX,UAAU,GAAG,sBAAsB,GAAG,qBAAqB,GAAG,UAAU,CACzE,GACA,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAuBvC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { DEFAULT_ROLLOUT_SETTINGS, DEFAULT_ROLLOUT_WAVES, assignWaves, readRolloutConfig, } from "./config";
|
|
2
|
+
export type { ConfigSyncRolloutConfig } from "./config";
|
|
3
|
+
export { listSyncedDescendants } from "./enumerate";
|
|
4
|
+
export type { EnumerateOptions, FleetTenant } from "./enumerate";
|
|
5
|
+
export { createExpectedHash } from "./hashes";
|
|
6
|
+
export { listRolloutOperations, planRollout } from "./plan";
|
|
7
|
+
export type { PlanResult } from "./plan";
|
|
8
|
+
export { advanceRollout, advanceRollouts, pauseRollout, resumeRollout, } from "./advance";
|
|
9
|
+
export type { AdvanceRolloutsOptions, RolloutTickOutcome, RolloutTickResult, } from "./advance";
|
|
10
|
+
export { getConfigSyncStatus } from "./status";
|
|
11
|
+
export type { ConfigSyncStatus, ConfigSyncStatusDeps } from "./status";
|
|
12
|
+
export { reconcileConfigDrift } from "./reconcile";
|
|
13
|
+
export type { ReconcileConfigDriftOptions, ReconcileConfigDriftResult, } from "./reconcile";
|
|
14
|
+
export { createRolloutWriteHooks, isPublishedRow, requestRollout, } from "./trigger";
|
|
15
|
+
export type { PublishableEntity, RolloutWriteHooks } from "./trigger";
|
|
16
|
+
export { createRolloutController } from "./controller";
|
|
17
|
+
export type { CreateRolloutParams, RolloutController } from "./controller";
|
|
18
|
+
export type { RolloutDeps } from "./types";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rollouts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,WAAW,EACX,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC5D,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,cAAc,EACd,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC3E,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Rollout, TenantOperation } from "authhero";
|
|
2
|
+
import type { RolloutDeps } from "./types";
|
|
3
|
+
export declare const OPEN_ROLLOUT_STATUSES: readonly ["pending", "canary", "rolling", "paused"];
|
|
4
|
+
export declare function storesOf(deps: RolloutDeps): {
|
|
5
|
+
tenantOperations: import("authhero").TenantOperationsAdapter;
|
|
6
|
+
tenantOperationEvents: import("authhero").TenantOperationEventsAdapter;
|
|
7
|
+
};
|
|
8
|
+
export declare function rolloutsOf(deps: RolloutDeps): import("authhero").RolloutsAdapter;
|
|
9
|
+
export interface PlanResult {
|
|
10
|
+
/** Tenants that get a sync operation. */
|
|
11
|
+
planned: number;
|
|
12
|
+
/** Candidates left out because they are already up to date. */
|
|
13
|
+
upToDate: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Turns a rollout into per-tenant `sync-defaults` operations: lists the synced
|
|
17
|
+
* descendants of the rollout's root (parents before children), leaves out the
|
|
18
|
+
* ones whose stored hash already matches (unless `force`), splits the rest into
|
|
19
|
+
* a canary and percentage waves, and creates one `pending` operation each. The
|
|
20
|
+
* rollout's `config` records the result. A rollout with nothing to do ends
|
|
21
|
+
* `done` (a write-triggered one, which exists only because something was
|
|
22
|
+
* written, is removed instead of leaving noise).
|
|
23
|
+
*/
|
|
24
|
+
export declare function planRollout(deps: RolloutDeps, rollout: Rollout, options?: {
|
|
25
|
+
tenantIds?: string[];
|
|
26
|
+
}): Promise<PlanResult>;
|
|
27
|
+
/** Every operation of a rollout, oldest first. */
|
|
28
|
+
export declare function listRolloutOperations(deps: RolloutDeps, rolloutId: string): Promise<TenantOperation[]>;
|
|
29
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/rollouts/plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAKzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,qBAAqB,qDAKxB,CAAC;AAEX,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW;;;EAMzC;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,sCAK3C;AAED,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GACrC,OAAO,CAAC,UAAU,CAAC,CAyErB;AAED,kDAAkD;AAClD,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,EAAE,CAAC,CAsB5B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RolloutDeps } from "./types";
|
|
2
|
+
export interface ReconcileConfigDriftOptions {
|
|
3
|
+
/** The tenant whose descendants are checked. Defaults to the control plane. */
|
|
4
|
+
rootTenantId?: string;
|
|
5
|
+
/** Most tenants to report and roll out in one call. @default 500 */
|
|
6
|
+
limit?: number;
|
|
7
|
+
/**
|
|
8
|
+
* A tenant whose latest sync failed less than this long ago is reported but
|
|
9
|
+
* not rolled out again, so a tenant that keeps failing does not get a new
|
|
10
|
+
* rollout on every run. @default 3600000 (one hour)
|
|
11
|
+
*/
|
|
12
|
+
retryAfterMs?: number;
|
|
13
|
+
logger?: Pick<Console, "warn">;
|
|
14
|
+
}
|
|
15
|
+
export interface ReconcileConfigDriftResult {
|
|
16
|
+
/** Synced tenants compared. */
|
|
17
|
+
checked: number;
|
|
18
|
+
/** Tenants whose applied hash differs from what their chain publishes. */
|
|
19
|
+
drifted: number;
|
|
20
|
+
/** Drifted tenants a running rollout already covers. */
|
|
21
|
+
alreadyCovered: number;
|
|
22
|
+
/** Drifted tenants left out because their latest sync failed recently. */
|
|
23
|
+
recentlyFailed: number;
|
|
24
|
+
/** The rollout created for the rest, if any. */
|
|
25
|
+
rolloutId?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The safety net for lost triggers (design 4.3): compares every synced
|
|
29
|
+
* tenant's applied hash with the hash its chain would produce now. Drifted
|
|
30
|
+
* tenants get a `cfgdrift` log (queryable per tenant) and, unless an open
|
|
31
|
+
* rollout already covers them, one new rollout. Idempotent: running it again
|
|
32
|
+
* before the rollout finishes creates nothing, and once the tenants are synced
|
|
33
|
+
* there is nothing left to find.
|
|
34
|
+
*
|
|
35
|
+
* Run it from a scheduled handler, followed by `advanceRollouts`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function reconcileConfigDrift(deps: RolloutDeps, options?: ReconcileConfigDriftOptions): Promise<ReconcileConfigDriftResult>;
|
|
38
|
+
//# sourceMappingURL=reconcile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../../src/rollouts/reconcile.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,MAAM,WAAW,2BAA2B;IAC1C,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B;IACzC,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,cAAc,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,0BAA0B,CAAC,CA0IrC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RolloutDeps } from "./types";
|
|
2
|
+
export type ConfigSyncStatusDeps = Pick<RolloutDeps, "adapters" | "controlPlaneTenantId" | "resolveControlPlane" | "maxDepth">;
|
|
3
|
+
export interface ConfigSyncStatus {
|
|
4
|
+
tenant_id: string;
|
|
5
|
+
parent_tenant_id: string | null;
|
|
6
|
+
config_sync: "inherit-on-read" | "synced";
|
|
7
|
+
config_sync_hash: string | null;
|
|
8
|
+
config_synced_at: string | null;
|
|
9
|
+
/** The hash a sync would store now; null for a tenant that is not synced. */
|
|
10
|
+
expected_hash: string | null;
|
|
11
|
+
/** A synced tenant whose stored hash differs from `expected_hash`. */
|
|
12
|
+
drifted: boolean;
|
|
13
|
+
/** Ancestors the config resolves from, nearest first. */
|
|
14
|
+
chain: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Which ancestor published each inherited row, keyed by the id the row has
|
|
17
|
+
* in this tenant (`con_sy...`, singletons by `emailProvider`, `branding` and
|
|
18
|
+
* `promptSettings`). Platform rows are left out: a child never sees them.
|
|
19
|
+
*/
|
|
20
|
+
inherited: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Sync status of one tenant, for the admin UI: the stored and expected hash,
|
|
24
|
+
* whether they differ, and where its inherited rows come from. Content and
|
|
25
|
+
* secrets never leave this function, only ids and tenant names.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getConfigSyncStatus(deps: ConfigSyncStatusDeps, tenantId: string): Promise<ConfigSyncStatus | null>;
|
|
28
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/rollouts/status.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,WAAW,EACX,UAAU,GAAG,sBAAsB,GAAG,qBAAqB,GAAG,UAAU,CACzE,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,EAAE,iBAAiB,GAAG,QAAQ,CAAC;IAC1C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAkElC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Rollout } from "authhero";
|
|
2
|
+
import type { ConfigEntity } from "../inheritance/types";
|
|
3
|
+
import type { RolloutDeps } from "./types";
|
|
4
|
+
/** The entities whose writes can change what descendants should hold. */
|
|
5
|
+
export type PublishableEntity = ConfigEntity | "hookCode";
|
|
6
|
+
/**
|
|
7
|
+
* Whether a written row is something a parent publishes. A row counts when it
|
|
8
|
+
* is shared or platform scoped, which for rows nobody has annotated follows
|
|
9
|
+
* what read-time inheritance does today (system resource servers and actions,
|
|
10
|
+
* inheritable hooks, connections and the email provider). Hook code always
|
|
11
|
+
* counts, since it cannot be told from the code of an unpublished hook.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isPublishedRow(entity: PublishableEntity, row: unknown): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Records that `originTenantId` published a change (the write trigger). Writes
|
|
16
|
+
* are coalesced through the rollout row itself: if a write-triggered rollout
|
|
17
|
+
* for this origin is still waiting out its debounce it is touched (its
|
|
18
|
+
* `updated_at` moves), otherwise one is created. The tick plans it once writes
|
|
19
|
+
* have been quiet for `debounce_ms`. Cheap, durable, and safe to call from a
|
|
20
|
+
* request: nothing is rolled out here.
|
|
21
|
+
*/
|
|
22
|
+
export declare function requestRollout(deps: RolloutDeps, originTenantId: string, initiatedBy?: string): Promise<Rollout>;
|
|
23
|
+
/** The entity hooks that turn a published write into a rollout request. */
|
|
24
|
+
export interface RolloutWriteHooks {
|
|
25
|
+
actions: EntityWriteHooks;
|
|
26
|
+
hooks: EntityWriteHooks;
|
|
27
|
+
hookCode: EntityWriteHooks;
|
|
28
|
+
connections: EntityWriteHooks;
|
|
29
|
+
resourceServers: EntityWriteHooks;
|
|
30
|
+
}
|
|
31
|
+
interface EntityWriteHooks {
|
|
32
|
+
afterCreate: (ctx: {
|
|
33
|
+
tenantId: string;
|
|
34
|
+
}, entity: unknown) => Promise<void>;
|
|
35
|
+
afterUpdate: (ctx: {
|
|
36
|
+
tenantId: string;
|
|
37
|
+
}, id: string, entity: unknown) => Promise<void>;
|
|
38
|
+
afterDelete: (ctx: {
|
|
39
|
+
tenantId: string;
|
|
40
|
+
}, id: string) => Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Entity hooks for the write trigger (design 4.3, trigger 1). After a published
|
|
44
|
+
* row is created, updated or deleted, `requestRollout` records the change; a
|
|
45
|
+
* burst of writes becomes one rollout. A failure here never fails the write:
|
|
46
|
+
* the drift reconcile finds whatever a lost request would have rolled out.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createRolloutWriteHooks(deps: RolloutDeps, options?: {
|
|
49
|
+
logger?: Pick<Console, "warn">;
|
|
50
|
+
}): RolloutWriteHooks;
|
|
51
|
+
export {};
|
|
52
|
+
//# sour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EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAuBD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;CAAO,GAC/C,iBAAiB,CAgCnB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DataAdapters } from "authhero";
|
|
2
|
+
import type { ControlPlaneResolver } from "../middleware";
|
|
3
|
+
import type { TenantOperationExecutor } from "../operations";
|
|
4
|
+
/** Everything the rollout functions need, wired once by the host. */
|
|
5
|
+
export interface RolloutDeps {
|
|
6
|
+
/**
|
|
7
|
+
* Control-plane adapters: tenants, tenant operations and events, rollouts and
|
|
8
|
+
* logs. Must be the layer that returns secrets as stored (ciphertext).
|
|
9
|
+
*/
|
|
10
|
+
adapters: DataAdapters;
|
|
11
|
+
/**
|
|
12
|
+
* Starts the per-tenant `sync-defaults` operations: the inline executor, or
|
|
13
|
+
* the Cloudflare Workflows executor.
|
|
14
|
+
*/
|
|
15
|
+
executor: TenantOperationExecutor;
|
|
16
|
+
/** The control plane, parent of tenants that have no `parent_tenant_id`. */
|
|
17
|
+
controlPlaneTenantId: string;
|
|
18
|
+
/** Per-tenant override of the implicit parent, as for `initMultiTenant`. */
|
|
19
|
+
resolveControlPlane?: ControlPlaneResolver;
|
|
20
|
+
/** Longest parent chain, see `resolveTenantChain`. */
|
|
21
|
+
maxDepth?: number;
|
|
22
|
+
/** Clock override for tests. */
|
|
23
|
+
now?: () => number;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/rollouts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,EAAE,YAAY,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,uBAAuB,CAAC;IAClC,4EAA4E;IAC5E,oBAAoB,EAAE,MAAM,CAAC;IAC7B,4EAA4E;IAC5E,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;IAC3C,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenants.d.ts","sourceRoot":"","sources":["../../../src/routes/tenants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"tenants.d.ts","sourceRoot":"","sources":["../../../src/routes/tenants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAYhE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,UAAU,CAAC;AA0DlB;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,iBAAiB;cAGZ,oBAAoB;eACnB,qBAAqB;YAyrBnC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CreateTenantParams, DataAdapters, Tenant } from "authhero";
|
|
2
2
|
import { Context } from "hono";
|
|
3
3
|
import type { StepReporter } from "./operations/types";
|
|
4
|
+
import type { ConfigSyncStatus } from "./rollouts/status";
|
|
4
5
|
/**
|
|
5
6
|
* Bindings type from authhero core - simplified version for this package
|
|
6
7
|
*/
|
|
@@ -207,6 +208,17 @@ export interface MultiTenancyConfig {
|
|
|
207
208
|
* Subdomain-based tenant routing configuration.
|
|
208
209
|
*/
|
|
209
210
|
subdomainRouting?: SubdomainRoutingConfig;
|
|
211
|
+
/**
|
|
212
|
+
* Reads a tenant's config sync status for `GET /tenants/{id}/config-sync`.
|
|
213
|
+
* Supplied by `initMultiTenant`; the route is not mounted without it.
|
|
214
|
+
*/
|
|
215
|
+
configSyncStatus?: (tenantId: string) => Promise<ConfigSyncStatus | null>;
|
|
216
|
+
/**
|
|
217
|
+
* Called after a tenant is created or its `config_sync` mode is changed, so
|
|
218
|
+
* the sync mode the runtime remembers for it is dropped. Other isolates still
|
|
219
|
+
* take up to the resolver's TTL (30 s) to notice. Supplied by `initMultiTenant`.
|
|
220
|
+
*/
|
|
221
|
+
onConfigSyncChange?: (tenantId: string) => void;
|
|
210
222
|
}
|
|
211
223
|
/**
|
|
212
224
|
* Context passed to tenant entity hooks.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW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;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE;QACb,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -12,7 +12,8 @@ export declare const DEFAULT_MAX_TENANT_DEPTH = 2;
|
|
|
12
12
|
* longer than `maxDepth`.
|
|
13
13
|
*
|
|
14
14
|
* Pure with respect to storage: ancestors are read through `getTenant`.
|
|
15
|
-
*
|
|
15
|
+
* The parent decides which config a tenant inherits (see `resolveTenantChain`);
|
|
16
|
+
* this keeps the stored tree valid.
|
|
16
17
|
*/
|
|
17
18
|
export declare function validateTenantParent(params: {
|
|
18
19
|
tenantId: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant-tree.d.ts","sourceRoot":"","sources":["../../../src/utils/tenant-tree.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"tenant-tree.d.ts","sourceRoot":"","sources":["../../../src/utils/tenant-tree.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,SAAS,EAAE,CACT,EAAE,EAAE,MAAM,KACP,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACtE;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkEhB"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/sesamyab/authhero"
|
|
13
13
|
},
|
|
14
|
-
"version": "15.
|
|
14
|
+
"version": "15.3.0",
|
|
15
15
|
"description": "Multi-tenancy support for AuthHero with organization-based access control and per-tenant database isolation",
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"typescript": "^5.6.0",
|
|
37
37
|
"vite": "^8.0.14",
|
|
38
38
|
"vitest": "^4.1.7",
|
|
39
|
-
"@authhero/adapter-interfaces": "4.
|
|
40
|
-
"@authhero/kysely-adapter": "12.
|
|
41
|
-
"authhero": "9.
|
|
39
|
+
"@authhero/adapter-interfaces": "4.23.0",
|
|
40
|
+
"@authhero/kysely-adapter": "12.17.0",
|
|
41
|
+
"authhero": "9.26.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"zod": "^4.4.3"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@authhero/adapter-interfaces": "^14.0.0",
|
|
48
48
|
"@hono/zod-openapi": "^1.4.0",
|
|
49
|
-
"authhero": "^
|
|
49
|
+
"authhero": "^9.26.0",
|
|
50
50
|
"hono": "^4.7.0"
|
|
51
51
|
},
|
|
52
52
|
"license": "AGPL-3.0-only",
|