authhero 0.291.0 → 0.291.2
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/authhero.cjs +34 -34
- package/dist/authhero.d.ts +111 -0
- package/dist/authhero.mjs +1372 -1296
- package/dist/stats.html +1 -1
- package/package.json +3 -3
package/dist/authhero.d.ts
CHANGED
|
@@ -18041,6 +18041,117 @@ export declare function parseUserId(user_id: string): {
|
|
|
18041
18041
|
connection: string;
|
|
18042
18042
|
id: string;
|
|
18043
18043
|
};
|
|
18044
|
+
/**
|
|
18045
|
+
* Configuration for a secondary adapter in passthrough mode.
|
|
18046
|
+
*/
|
|
18047
|
+
export interface SecondaryAdapterConfig<T> {
|
|
18048
|
+
/**
|
|
18049
|
+
* The secondary adapter to sync writes to.
|
|
18050
|
+
* Can be a partial implementation - only implemented methods will be called.
|
|
18051
|
+
*/
|
|
18052
|
+
adapter: Partial<T>;
|
|
18053
|
+
/**
|
|
18054
|
+
* If true, wait for the secondary write to complete before returning.
|
|
18055
|
+
* Default: false (fire-and-forget)
|
|
18056
|
+
*/
|
|
18057
|
+
blocking?: boolean;
|
|
18058
|
+
/**
|
|
18059
|
+
* Called when a secondary write fails.
|
|
18060
|
+
* @param error - The error that occurred
|
|
18061
|
+
* @param method - The method name that failed
|
|
18062
|
+
* @param args - The arguments passed to the method
|
|
18063
|
+
*/
|
|
18064
|
+
onError?: (error: Error, method: string, args: unknown[]) => void;
|
|
18065
|
+
}
|
|
18066
|
+
/**
|
|
18067
|
+
* Configuration for creating a passthrough adapter that syncs writes to multiple destinations.
|
|
18068
|
+
*
|
|
18069
|
+
* @template T - The adapter interface type (e.g., LogsDataAdapter, UsersDataAdapter)
|
|
18070
|
+
*/
|
|
18071
|
+
export interface PassthroughConfig<T> {
|
|
18072
|
+
/**
|
|
18073
|
+
* Primary adapter - all reads come from here, writes go here first.
|
|
18074
|
+
*/
|
|
18075
|
+
primary: T;
|
|
18076
|
+
/**
|
|
18077
|
+
* Secondary adapters to sync writes to.
|
|
18078
|
+
*/
|
|
18079
|
+
secondaries: SecondaryAdapterConfig<T>[];
|
|
18080
|
+
/**
|
|
18081
|
+
* Methods that should be synced to secondaries.
|
|
18082
|
+
* Default: ["create", "update", "remove", "delete", "set"]
|
|
18083
|
+
*/
|
|
18084
|
+
syncMethods?: string[];
|
|
18085
|
+
}
|
|
18086
|
+
/**
|
|
18087
|
+
* Creates a passthrough adapter that syncs write operations to multiple destinations.
|
|
18088
|
+
*
|
|
18089
|
+
* Reads always come from the primary adapter.
|
|
18090
|
+
* Writes go to the primary first, then are synced to all secondaries.
|
|
18091
|
+
*
|
|
18092
|
+
* @example Logs adapter with database primary and Analytics Engine secondary
|
|
18093
|
+
* ```typescript
|
|
18094
|
+
* import { createPassthroughAdapter } from "@authhero/adapter-interfaces";
|
|
18095
|
+
*
|
|
18096
|
+
* const logsAdapter = createPassthroughAdapter({
|
|
18097
|
+
* primary: databaseLogsAdapter,
|
|
18098
|
+
* secondaries: [
|
|
18099
|
+
* {
|
|
18100
|
+
* adapter: analyticsEngineAdapter,
|
|
18101
|
+
* onError: (err) => console.error("Analytics sync failed:", err),
|
|
18102
|
+
* },
|
|
18103
|
+
* ],
|
|
18104
|
+
* });
|
|
18105
|
+
* ```
|
|
18106
|
+
*
|
|
18107
|
+
* @example Cache adapter with multiple backends
|
|
18108
|
+
* ```typescript
|
|
18109
|
+
* const cacheAdapter = createPassthroughAdapter({
|
|
18110
|
+
* primary: redisCacheAdapter,
|
|
18111
|
+
* secondaries: [
|
|
18112
|
+
* { adapter: memcachedAdapter, blocking: true },
|
|
18113
|
+
* { adapter: localCacheAdapter },
|
|
18114
|
+
* ],
|
|
18115
|
+
* syncMethods: ["set", "delete"],
|
|
18116
|
+
* });
|
|
18117
|
+
* ```
|
|
18118
|
+
*
|
|
18119
|
+
* @example Users adapter with search index sync
|
|
18120
|
+
* ```typescript
|
|
18121
|
+
* const usersAdapter = createPassthroughAdapter({
|
|
18122
|
+
* primary: databaseUsersAdapter,
|
|
18123
|
+
* secondaries: [
|
|
18124
|
+
* {
|
|
18125
|
+
* adapter: elasticsearchAdapter,
|
|
18126
|
+
* blocking: true, // Wait for search index to update
|
|
18127
|
+
* },
|
|
18128
|
+
* ],
|
|
18129
|
+
* });
|
|
18130
|
+
* ```
|
|
18131
|
+
*/
|
|
18132
|
+
export declare function createPassthroughAdapter<T extends object>(config: PassthroughConfig<T>): T;
|
|
18133
|
+
/**
|
|
18134
|
+
* Creates a write-only adapter that only implements specific methods.
|
|
18135
|
+
* Useful for creating secondary adapters that only need to handle synced writes.
|
|
18136
|
+
*
|
|
18137
|
+
* @example
|
|
18138
|
+
* ```typescript
|
|
18139
|
+
* const webhookNotifier = createWriteOnlyAdapter<LogsDataAdapter>({
|
|
18140
|
+
* create: async (tenantId, log) => {
|
|
18141
|
+
* await fetch("https://webhook.example.com/logs", {
|
|
18142
|
+
* method: "POST",
|
|
18143
|
+
* body: JSON.stringify({ tenantId, log }),
|
|
18144
|
+
* });
|
|
18145
|
+
* },
|
|
18146
|
+
* });
|
|
18147
|
+
*
|
|
18148
|
+
* const logsAdapter = createPassthroughAdapter({
|
|
18149
|
+
* primary: databaseLogsAdapter,
|
|
18150
|
+
* secondaries: [{ adapter: webhookNotifier }],
|
|
18151
|
+
* });
|
|
18152
|
+
* ```
|
|
18153
|
+
*/
|
|
18154
|
+
export declare function createWriteOnlyAdapter<T>(implementation: Partial<T>): Partial<T>;
|
|
18044
18155
|
export interface CacheItem<T = any> {
|
|
18045
18156
|
value: T;
|
|
18046
18157
|
expiresAt?: Date;
|