@authhero/multi-tenancy 15.1.2 → 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 +2145 -703
- package/dist/types/index.d.ts +6 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/inheritance/chain.d.ts +18 -0
- package/dist/types/inheritance/chain.d.ts.map +1 -0
- package/dist/types/inheritance/index.d.ts +10 -0
- package/dist/types/inheritance/index.d.ts.map +1 -0
- package/dist/types/inheritance/legacy.d.ts +7 -0
- package/dist/types/inheritance/legacy.d.ts.map +1 -0
- package/dist/types/inheritance/merge.d.ts +40 -0
- package/dist/types/inheritance/merge.d.ts.map +1 -0
- package/dist/types/inheritance/read.d.ts +5 -0
- package/dist/types/inheritance/read.d.ts.map +1 -0
- package/dist/types/inheritance/report.d.ts +20 -0
- package/dist/types/inheritance/report.d.ts.map +1 -0
- package/dist/types/inheritance/shadow.d.ts +30 -0
- package/dist/types/inheritance/shadow.d.ts.map +1 -0
- package/dist/types/inheritance/types.d.ts +24 -0
- package/dist/types/inheritance/types.d.ts.map +1 -0
- package/dist/types/init.d.ts +38 -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 +51 -3
- 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/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/tenant-tree.d.ts +33 -0
- package/dist/types/utils/tenant-tree.d.ts.map +1 -0
- package/package.json +5 -5
package/dist/types/index.d.ts
CHANGED
|
@@ -3,14 +3,18 @@ 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";
|
|
17
|
+
export * from "./inheritance";
|
|
14
18
|
export { createMultiTenancyPlugin } from "./plugin";
|
|
15
19
|
export type { AuthHeroPlugin } from "./plugin";
|
|
16
20
|
export { createAccessControlHooks, createDatabaseHooks, createProvisioningHooks, } from "./hooks";
|
|
@@ -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,kBA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;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a tenant's ancestors, nearest first.
|
|
3
|
+
*
|
|
4
|
+
* A tenant with `parent_tenant_id` follows that chain. A tenant without one
|
|
5
|
+
* falls back to the legacy control plane as an implicit single parent, so the
|
|
6
|
+
* result matches what read-time inheritance does today. `legacyControlPlane`
|
|
7
|
+
* is `undefined` when the tenant opts out of inheritance.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveTenantChain(params: {
|
|
10
|
+
tenantId: string;
|
|
11
|
+
getTenant: (id: string) => Promise<{
|
|
12
|
+
id: string;
|
|
13
|
+
parent_tenant_id?: string | null;
|
|
14
|
+
} | null>;
|
|
15
|
+
legacyControlPlane?: string;
|
|
16
|
+
maxDepth?: number;
|
|
17
|
+
}): Promise<string[]>;
|
|
18
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/inheritance/chain.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,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,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgCpB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { resolveTenantChain } from "./chain";
|
|
2
|
+
export { effectiveOverride, effectiveScope, mergeConfig } from "./merge";
|
|
3
|
+
export { computeLegacyConfig } from "./legacy";
|
|
4
|
+
export { readConfigRows } from "./read";
|
|
5
|
+
export { compareShadow, diffConfig } from "./shadow";
|
|
6
|
+
export type { ShadowDiff } from "./shadow";
|
|
7
|
+
export { createShadowReporter } from "./report";
|
|
8
|
+
export type { InheritanceShadowOptions, ShadowReporter } from "./report";
|
|
9
|
+
export type { ConfigRows, ConfigEntity, ResolvedConfig } from "./types";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/inheritance/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,YAAY,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfigRows } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* What read-time inheritance returns for a tenant today, computed from plain
|
|
4
|
+
* rows with the very helpers the runtime fallback adapter uses.
|
|
5
|
+
*/
|
|
6
|
+
export declare function computeLegacyConfig(tenant: ConfigRows, controlPlane: ConfigRows | undefined): ConfigRows;
|
|
7
|
+
//# sourceMappingURL=legacy.d.ts.map
|
|
@@ -0,0 +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,CAkCZ"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ConfigOverride, ConfigScope } from "authhero";
|
|
2
|
+
import { ConfigEntity, ConfigRows, ResolvedConfig } from "./types";
|
|
3
|
+
type Publishable = {
|
|
4
|
+
scope?: ConfigScope | null;
|
|
5
|
+
override?: ConfigOverride | null;
|
|
6
|
+
is_system?: boolean;
|
|
7
|
+
metadata?: unknown;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Scope of a row. An explicit `scope` wins. Unset falls back to what
|
|
11
|
+
* read-time inheritance does today for that entity, so rows nobody has
|
|
12
|
+
* annotated behave as before.
|
|
13
|
+
*/
|
|
14
|
+
export declare function effectiveScope(entity: ConfigEntity, row: Publishable): ConfigScope;
|
|
15
|
+
/**
|
|
16
|
+
* What a child may change on a row. Unset is "fields" because that is how the
|
|
17
|
+
* legacy merge behaves: the tenant's values win.
|
|
18
|
+
*/
|
|
19
|
+
export declare function effectiveOverride(row: Publishable): ConfigOverride;
|
|
20
|
+
export declare const SECRET_KEY: RegExp;
|
|
21
|
+
type Layer = ConfigRows;
|
|
22
|
+
/**
|
|
23
|
+
* Merges the config of a parent chain with the tenant's own, with no I/O.
|
|
24
|
+
*
|
|
25
|
+
* `chain` is the ancestors' rows **nearest first** (the same order as
|
|
26
|
+
* `resolveTenantChain`); `tenant` is the tenant's own rows. Rules
|
|
27
|
+
* (docs/design/tenant-config-inheritance.md, 3.3):
|
|
28
|
+
* - rows merge by a stable key and the nearest layer wins, limited by the
|
|
29
|
+
* `override` of the layer above;
|
|
30
|
+
* - hooks and actions add up: an ancestor's shared rows appear in addition to
|
|
31
|
+
* the tenant's own;
|
|
32
|
+
* - `local` rows of an ancestor are not visible; `platform` rows are merged
|
|
33
|
+
* but listed in `hidden`.
|
|
34
|
+
*
|
|
35
|
+
* `enforce` does not affect the merged result yet; it constrains edits and
|
|
36
|
+
* deletes, which come with the management API changes.
|
|
37
|
+
*/
|
|
38
|
+
export declare function mergeConfig(chain: Layer[], tenant: Layer): ResolvedConfig;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DataAdapters } from "authhero";
|
|
2
|
+
import { ConfigRows } from "./types";
|
|
3
|
+
/** Reads every config entity of one tenant as plain rows. */
|
|
4
|
+
export declare function readConfigRows(adapters: DataAdapters, tenantId: string): Promise<ConfigRows>;
|
|
5
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DataAdapters } from "authhero";
|
|
2
|
+
/**
|
|
3
|
+
* Options for config inheritance shadow mode. Shadow mode compares the parent
|
|
4
|
+
* chain resolver with read-time inheritance and logs differences; it never
|
|
5
|
+
* changes what a request sees.
|
|
6
|
+
*/
|
|
7
|
+
export interface InheritanceShadowOptions {
|
|
8
|
+
/** Fraction of reads (0..1) that may start a comparison. @default 1 */
|
|
9
|
+
sample?: number;
|
|
10
|
+
/** Minimum time between comparisons of the same tenant. @default 60000 */
|
|
11
|
+
intervalMs?: number;
|
|
12
|
+
/** Also log differences that are expected (inherited rows the tenant lacks). @default false */
|
|
13
|
+
includeExpected?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ShadowReporter {
|
|
16
|
+
/** Starts a comparison for `tenantId` in the background, if due. */
|
|
17
|
+
schedule(tenantId: string, legacyControlPlane: string | undefined): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function createShadowReporter(adapters: DataAdapters, options: InheritanceShadowOptions): ShadowReporter;
|
|
20
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +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,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC1E;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,wBAAwB,GAChC,cAAc,CAiDhB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DataAdapters } from "authhero";
|
|
2
|
+
import { ConfigEntity, ConfigRows } from "./types";
|
|
3
|
+
export interface ShadowDiff {
|
|
4
|
+
entity: ConfigEntity;
|
|
5
|
+
key: string;
|
|
6
|
+
kind: "missing" | "extra" | "changed";
|
|
7
|
+
/** Top-level fields that differ (`changed` only). Values are never logged. */
|
|
8
|
+
fields: string[];
|
|
9
|
+
/**
|
|
10
|
+
* The new model materialises inherited rows into the tenant, where
|
|
11
|
+
* read-time inheritance only overlays rows the tenant already has. A row
|
|
12
|
+
* that is `extra` for that reason is expected and not a bug.
|
|
13
|
+
*/
|
|
14
|
+
expected: boolean;
|
|
15
|
+
legacy_hash?: string;
|
|
16
|
+
new_hash?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function sha256(input: string): Promise<string>;
|
|
19
|
+
export declare function diffConfig(legacy: ConfigRows, next: ConfigRows): Promise<ShadowDiff[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Computes the new resolver's result and the legacy result for a tenant and
|
|
22
|
+
* returns their differences. Reads only; the resolver result is never used.
|
|
23
|
+
*/
|
|
24
|
+
export declare function compareShadow(params: {
|
|
25
|
+
adapters: DataAdapters;
|
|
26
|
+
tenantId: string;
|
|
27
|
+
legacyControlPlane?: string;
|
|
28
|
+
maxDepth?: number;
|
|
29
|
+
}): Promise<ShadowDiff[]>;
|
|
30
|
+
//# sourceMappingURL=shadow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow.d.ts","sourceRoot":"","sources":["../../../src/inheritance/shadow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK7C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,YAAY,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACtC,8EAA8E;IAC9E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAgBD,wBAAsB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS3D;AA2FD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,UAAU,EAAE,CAAC,CA+CvB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA0BxB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Action, Branding, Connection, EmailProvider, Hook, HookCode, PromptSetting, ResourceServer } from "authhero";
|
|
2
|
+
/** Plain config rows for one tenant. Singletons are `null` when unset. */
|
|
3
|
+
export interface ConfigRows {
|
|
4
|
+
connections: Connection[];
|
|
5
|
+
resourceServers: ResourceServer[];
|
|
6
|
+
hooks: Hook[];
|
|
7
|
+
/** Code referenced by `code_id` of the code hooks in `hooks`. */
|
|
8
|
+
hookCode: HookCode[];
|
|
9
|
+
actions: Action[];
|
|
10
|
+
emailProvider: EmailProvider | null;
|
|
11
|
+
branding: Branding | null;
|
|
12
|
+
promptSettings: PromptSetting | null;
|
|
13
|
+
}
|
|
14
|
+
export declare const emptyConfigRows: () => ConfigRows;
|
|
15
|
+
export type ConfigEntity = "connection" | "resourceServer" | "hook" | "action" | "emailProvider" | "branding" | "promptSettings";
|
|
16
|
+
/** Result of merging a parent chain into one tenant's config. */
|
|
17
|
+
export interface ResolvedConfig extends ConfigRows {
|
|
18
|
+
/**
|
|
19
|
+
* Keys (`<entity>:<key>`) of rows that came from a `platform`-scoped
|
|
20
|
+
* ancestor row: merged so they can run, but hidden from the tenant.
|
|
21
|
+
*/
|
|
22
|
+
hidden: string[];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,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,5 +1,8 @@
|
|
|
1
1
|
import { init, AuthHeroConfig, DataAdapters } from "authhero";
|
|
2
|
+
import type { SyncConfigFn, TenantOperationExecutor } from "./operations";
|
|
3
|
+
import { type RolloutDeps } from "./rollouts";
|
|
2
4
|
import type { ControlPlaneResolver } from "./middleware";
|
|
5
|
+
import type { InheritanceShadowOptions } from "./inheritance";
|
|
3
6
|
/**
|
|
4
7
|
* Control plane configuration for multi-tenancy.
|
|
5
8
|
*/
|
|
@@ -53,6 +56,28 @@ export interface MultiTenantConfig extends Omit<AuthHeroConfig, "entityHooks" |
|
|
|
53
56
|
* ```
|
|
54
57
|
*/
|
|
55
58
|
resolveControlPlane?: ControlPlaneResolver;
|
|
59
|
+
/**
|
|
60
|
+
* Shadow mode for config inheritance: compares the parent chain resolver
|
|
61
|
+
* with read-time inheritance in the background and logs differences as log
|
|
62
|
+
* type `cfgdiff`, queryable per tenant. Never affects a response.
|
|
63
|
+
* `true` uses the defaults.
|
|
64
|
+
*
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
inheritanceShadow?: boolean | InheritanceShadowOptions;
|
|
68
|
+
/**
|
|
69
|
+
* How the `sync-defaults` tenant operation reaches a tenant's database. The
|
|
70
|
+
* default syncs tenants that share the control plane's database in-process
|
|
71
|
+
* and refuses tenants with their own worker and database; pass a transport
|
|
72
|
+
* (for example a dispatch push to the tenant worker) to reach those.
|
|
73
|
+
*/
|
|
74
|
+
syncDefaults?: SyncConfigFn;
|
|
75
|
+
/**
|
|
76
|
+
* Starts the per-tenant operations of a fleet rollout. Defaults to the same
|
|
77
|
+
* inline executor as `sync-defaults` requests; Workflows deployments pass
|
|
78
|
+
* `createCloudflareWorkflowsExecutor(...)` so waves run durably.
|
|
79
|
+
*/
|
|
80
|
+
rolloutExecutor?: TenantOperationExecutor;
|
|
56
81
|
/**
|
|
57
82
|
* Control which entities to sync from control plane to child tenants.
|
|
58
83
|
* Set to `false` to disable all syncing.
|
|
@@ -102,6 +127,19 @@ export interface MultiTenantResult {
|
|
|
102
127
|
app: ReturnType<typeof init>["app"];
|
|
103
128
|
/** The control plane tenant ID */
|
|
104
129
|
controlPlaneTenantId: string;
|
|
130
|
+
/**
|
|
131
|
+
* What a scheduled handler needs to keep fleet rollouts moving, present when
|
|
132
|
+
* the control plane carries the rollouts and tenant operations adapters:
|
|
133
|
+
*
|
|
134
|
+
* ```typescript
|
|
135
|
+
* async scheduled(_event, env) {
|
|
136
|
+
* if (!rollouts) return;
|
|
137
|
+
* await reconcileConfigDrift(rollouts); // catches lost triggers
|
|
138
|
+
* await advanceRollouts(rollouts); // starts the next wave
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
rollouts?: RolloutDeps;
|
|
105
143
|
}
|
|
106
144
|
/**
|
|
107
145
|
* 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,EAGb,MAAM,UAAU,CAAC;AAUlB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,cAAc,EAEd,YAAY,EAGb,MAAM,UAAU,CAAC;AAUlB,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AASpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAG9D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAC7C,cAAc,EACd,aAAa,GAAG,yBAAyB,CAC1C;IACC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAEl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@ -0,0 +1,36 @@
|
|
|
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. @default 30000
|
|
30
|
+
*/
|
|
31
|
+
ttlMs?: number;
|
|
32
|
+
/** Upper bound on remembered tenants. @default 1000 */
|
|
33
|
+
maxEntries?: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function createConfigSyncResolver(options: ConfigSyncResolverOptions): ConfigSyncResolver;
|
|
36
|
+
//# 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;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GACjC,kBAAkB,CAwCpB"}
|
|
@@ -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;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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B,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,4 +1,19 @@
|
|
|
1
|
-
import { DataAdapters, Client } from "authhero";
|
|
1
|
+
import { DataAdapters, Connection, Client, ResourceServer, ResourceServerScope } from "authhero";
|
|
2
|
+
import { InheritanceShadowOptions } from "../inheritance/report";
|
|
3
|
+
import { ConfigSyncResolver } from "./config-sync-mode";
|
|
4
|
+
/**
|
|
5
|
+
* Merges a connection with control plane fallback options.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mergeConnectionWithFallback(connection: Connection, controlPlaneConnections: Connection[]): Connection;
|
|
8
|
+
/**
|
|
9
|
+
* Merges resource server scopes with control plane fallback.
|
|
10
|
+
* Tenant-specific scopes override control plane scopes with the same value.
|
|
11
|
+
*/
|
|
12
|
+
export declare function mergeResourceServerScopes(tenantScopes: ResourceServerScope[] | undefined, controlPlaneScopes: ResourceServerScope[] | undefined): ResourceServerScope[];
|
|
13
|
+
/**
|
|
14
|
+
* Merges a resource server with control plane fallback scopes.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mergeResourceServerWithFallback(resourceServer: ResourceServer, controlPlaneResourceServer: ResourceServer | null): ResourceServer;
|
|
2
17
|
/**
|
|
3
18
|
* Merges a client with control plane fallback URLs.
|
|
4
19
|
*
|
|
@@ -16,7 +31,7 @@ export declare function mergeClientWithFallback(client: Client, controlPlaneClie
|
|
|
16
31
|
* Resolved inheritance target for a single tenant. `undefined` means the
|
|
17
32
|
* tenant opts out of inheritance entirely.
|
|
18
33
|
*/
|
|
19
|
-
type ResolvedControlPlane = {
|
|
34
|
+
export type ResolvedControlPlane = {
|
|
20
35
|
tenantId: string;
|
|
21
36
|
clientId?: string;
|
|
22
37
|
} | undefined;
|
|
@@ -31,6 +46,17 @@ type ResolvedControlPlane = {
|
|
|
31
46
|
export type ControlPlaneResolver = (params: {
|
|
32
47
|
tenant_id: string;
|
|
33
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>;
|
|
34
60
|
/**
|
|
35
61
|
* Wraps data adapters with is_system-gated resource server scope inheritance
|
|
36
62
|
* from a control plane tenant.
|
|
@@ -75,6 +101,22 @@ export interface RuntimeFallbackConfig {
|
|
|
75
101
|
* control plane id.
|
|
76
102
|
*/
|
|
77
103
|
resolveControlPlane?: ControlPlaneResolver;
|
|
104
|
+
/**
|
|
105
|
+
* Shadow mode for config inheritance. When set, reads also start a
|
|
106
|
+
* background comparison of the parent chain resolver against the result of
|
|
107
|
+
* this adapter and log differences with log type `cfgdiff`. The comparison
|
|
108
|
+
* never changes what a request sees. `true` uses the defaults.
|
|
109
|
+
*
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
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;
|
|
78
120
|
}
|
|
79
121
|
/**
|
|
80
122
|
* Creates a data adapter wrapper that provides runtime settings fallback from a control plane tenant.
|
|
@@ -112,6 +154,13 @@ export interface RuntimeFallbackConfig {
|
|
|
112
154
|
* ```
|
|
113
155
|
*/
|
|
114
156
|
export declare function createRuntimeFallbackAdapter(baseAdapters: DataAdapters, config: RuntimeFallbackConfig): DataAdapters;
|
|
157
|
+
/**
|
|
158
|
+
* Returns true when a hook is marked as inheritable by the control plane.
|
|
159
|
+
* Inheritable hooks surface on every sub-tenant's `hooks.list` so a single
|
|
160
|
+
* control-plane row drives behaviour fleet-wide. Reads `metadata.inheritable`
|
|
161
|
+
* on any hook variant (web/form/template/code).
|
|
162
|
+
*/
|
|
163
|
+
export declare function isInheritableHook(hook: unknown): boolean;
|
|
115
164
|
/**
|
|
116
165
|
* Helper function to wrap data adapters with runtime fallback from control plane.
|
|
117
166
|
*
|
|
@@ -132,5 +181,4 @@ export declare function createRuntimeFallbackAdapter(baseAdapters: DataAdapters,
|
|
|
132
181
|
* ```
|
|
133
182
|
*/
|
|
134
183
|
export declare function withRuntimeFallback(baseAdapters: DataAdapters, config: RuntimeFallbackConfig): DataAdapters;
|
|
135
|
-
export {};
|
|
136
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,
|
|
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,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CAAC,EAAE,MAAM,CAAC;IAE9B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;;;;;;OAWG;IACH,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;IAE3C;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,wBAAwB,CAAC;IAEvD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAC;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"}
|
|
@@ -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,8 @@ 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";
|
|
8
10
|
export { runRecordedTenantOperation } from "./record-provision";
|
|
9
11
|
//# 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,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,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,55 @@
|
|
|
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
|
+
}
|
|
20
|
+
/** Syncs one tenant and returns what happened (or, for a dry run, what would). */
|
|
21
|
+
export type SyncConfigFn = (tenantId: string, options: SyncConfigOptions) => Promise<ApplyResolvedBlockResult>;
|
|
22
|
+
/** Reads the operation's `input` (fixed at creation, never secrets). */
|
|
23
|
+
export declare function syncOptionsOf(operation: Pick<TenantOperation, "input">): SyncConfigOptions;
|
|
24
|
+
/** Every per-entity error message the sync reported. */
|
|
25
|
+
export declare function syncErrors(result: ApplyResolvedBlockResult): string[];
|
|
26
|
+
/**
|
|
27
|
+
* The JSON-serialisable outcome stored in the operation's `result`: the status,
|
|
28
|
+
* hash, per-entity counts and the changed `entity:key` list. Never row content
|
|
29
|
+
* or secrets.
|
|
30
|
+
*/
|
|
31
|
+
export declare function summarizeSyncResult(result: ApplyResolvedBlockResult, options: SyncConfigOptions): Record<string, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* The step both executors run: sync, record the outcome on the operation row,
|
|
34
|
+
* and fail the step when any row reported an error. The result is written
|
|
35
|
+
* before the failure is raised so a failed run still shows what it did.
|
|
36
|
+
*/
|
|
37
|
+
export declare function runSyncDefaultsStep(params: {
|
|
38
|
+
operation: Pick<TenantOperation, "id" | "tenant_id" | "input">;
|
|
39
|
+
syncConfig: SyncConfigFn;
|
|
40
|
+
recorder: Pick<OperationRecorder, "setResult">;
|
|
41
|
+
}): Promise<Record<string, unknown>>;
|
|
42
|
+
/**
|
|
43
|
+
* Sync for tenants whose database is the control plane's own (shared
|
|
44
|
+
* deployments). Reads the chain from, and applies the block to, `adapters`,
|
|
45
|
+
* which should be the layer that returns secrets as stored (ciphertext) so they
|
|
46
|
+
* are copied without being decrypted. A tenant with its own worker and database
|
|
47
|
+
* (`deployment_type: "wfp"`) is not reachable this way: use a dispatch
|
|
48
|
+
* transport.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createInProcessSyncConfig(adapters: DataAdapters, config: {
|
|
51
|
+
controlPlaneTenantId: string;
|
|
52
|
+
resolveControlPlane?: ControlPlaneResolver;
|
|
53
|
+
maxDepth?: number;
|
|
54
|
+
}): SyncConfigFn;
|
|
55
|
+
//# 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;CAChB;AAED,kFAAkF;AAClF,MAAM,MAAM,YAAY,GAAG,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,iBAAiB,KACvB,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAEvC,wEAAwE;AACxE,wBAAgB,aAAa,CAC3B,SAAS,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,GACxC,iBAAiB,CAGnB;AAED,wDAAwD;AACxD,wBAAgB,UAAU,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,EAAE,CAErE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,wBAAwB,EAChC,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmBzB;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE;IAChD,SAAS,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC,CAAC;IAC/D,UAAU,EAAE,YAAY,CAAC;IACzB,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;CAChD,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqBnC;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE;IACN,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GACA,YAAY,CAwBd"}
|
|
@@ -34,6 +34,8 @@ export interface EnqueueTenantOperationParams {
|
|
|
34
34
|
initiated_by?: string;
|
|
35
35
|
target_worker_version?: string;
|
|
36
36
|
target_database_version?: string;
|
|
37
|
+
/** Kind-specific parameters, fixed at creation. Never contains secrets. */
|
|
38
|
+
input?: Record<string, unknown>;
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* Executes an already-persisted operation row. Row-first contract: the
|