@mastra/auth-studio 1.3.4 → 1.3.5-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/_types/@internal_auth/dist/_types/@internal_core/dist/base/index.d.ts +1 -1
- package/dist/_types/@internal_auth/dist/_types/@internal_core/dist/index-Biaf3BmX.d.ts +319 -0
- package/dist/_types/@internal_auth/dist/ee/interfaces/permissions.generated.d.ts +220 -220
- package/dist/index.cjs +89 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -5
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
- package/CHANGELOG.md +0 -240
- package/dist/_types/@internal_auth/dist/_types/@internal_core/dist/index-S1lgaKO7.d.ts +0 -218
package/dist/index.js
CHANGED
|
@@ -21,6 +21,46 @@ function getRequestHeader(request, name) {
|
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region ../../packages/_internal-core/dist/logger/index.js
|
|
24
|
+
/**
|
|
25
|
+
* Export a tracked exception through the adapter sink, mirroring the
|
|
26
|
+
* DualLogger dual-write shape (`errorId`/`domain`/`category`/`details`/`cause`
|
|
27
|
+
* when present on a MastraError-like value). Never throws into the caller.
|
|
28
|
+
*/
|
|
29
|
+
function exportTrackedException(ctx, error, metadata) {
|
|
30
|
+
if (!ctx?.options.export) return;
|
|
31
|
+
try {
|
|
32
|
+
const mastraError = error;
|
|
33
|
+
ctx.getLogSink()?.error(error.message, {
|
|
34
|
+
...mastraError.id !== void 0 ? { errorId: mastraError.id } : {},
|
|
35
|
+
...mastraError.domain !== void 0 ? { domain: mastraError.domain } : {},
|
|
36
|
+
...mastraError.category !== void 0 ? { category: mastraError.category } : {},
|
|
37
|
+
...mastraError.details !== void 0 ? { details: mastraError.details } : {},
|
|
38
|
+
...error.cause instanceof Error ? { cause: error.cause.message } : {},
|
|
39
|
+
...metadata
|
|
40
|
+
});
|
|
41
|
+
} catch {}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Adapt IMastraLogger's variadic args into the structured `data` payload of
|
|
45
|
+
* an exported log record. Extracts the first plain object as data,
|
|
46
|
+
* serializes an Error arg, and collects remaining primitives under `args`
|
|
47
|
+
* so the derived record preserves all context from the native call.
|
|
48
|
+
*/
|
|
49
|
+
function buildLogRecordData(args) {
|
|
50
|
+
const objectData = args.find((arg) => arg !== null && typeof arg === "object" && !Array.isArray(arg) && !(arg instanceof Error));
|
|
51
|
+
const errorArg = args.find((arg) => arg instanceof Error);
|
|
52
|
+
const extraArgs = args.filter((arg) => arg !== objectData && arg !== errorArg);
|
|
53
|
+
if (!objectData && !errorArg && extraArgs.length === 0) return void 0;
|
|
54
|
+
return {
|
|
55
|
+
...objectData ?? {},
|
|
56
|
+
...errorArg ? { error: {
|
|
57
|
+
name: errorArg.name,
|
|
58
|
+
message: errorArg.message,
|
|
59
|
+
stack: errorArg.stack
|
|
60
|
+
} } : {},
|
|
61
|
+
...extraArgs.length > 0 ? { args: extraArgs } : {}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
24
64
|
const RegisteredLogger = {
|
|
25
65
|
AGENT: "AGENT",
|
|
26
66
|
OBSERVABILITY: "OBSERVABILITY",
|
|
@@ -107,19 +147,56 @@ var MastraLogger = class {
|
|
|
107
147
|
var ConsoleLogger = class ConsoleLogger extends MastraLogger {
|
|
108
148
|
component;
|
|
109
149
|
filter;
|
|
150
|
+
#adapterContext;
|
|
110
151
|
constructor(options = {}) {
|
|
111
152
|
super(options);
|
|
112
153
|
this.component = options.component;
|
|
113
154
|
this.filter = options.filter;
|
|
114
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Adapter hook (see `AdaptableLogger`): enables native trace correlation
|
|
158
|
+
* (trace_id/span_id appended to console output) and observability export
|
|
159
|
+
* derived from the same record. Called by Mastra during setup.
|
|
160
|
+
*/
|
|
161
|
+
__attachObservability(ctx) {
|
|
162
|
+
this.#adapterContext = ctx;
|
|
163
|
+
}
|
|
115
164
|
child(componentOrBindings) {
|
|
116
165
|
const component = typeof componentOrBindings === "string" ? componentOrBindings : componentOrBindings?.component ?? this.component;
|
|
117
|
-
|
|
166
|
+
const child = new ConsoleLogger({
|
|
118
167
|
name: this.name,
|
|
119
168
|
level: this.level,
|
|
120
169
|
component,
|
|
121
170
|
filter: this.filter
|
|
122
171
|
});
|
|
172
|
+
if (this.#adapterContext) child.__attachObservability(this.#adapterContext);
|
|
173
|
+
return child;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Native-record correlation: when a span is active, append the trace
|
|
177
|
+
* fields object to the console args so every destination sees them.
|
|
178
|
+
*/
|
|
179
|
+
#correlate(args) {
|
|
180
|
+
const ctx = this.#adapterContext;
|
|
181
|
+
if (!ctx?.options.correlation) return args;
|
|
182
|
+
try {
|
|
183
|
+
const fields = ctx.resolveTraceFields();
|
|
184
|
+
return fields ? [...args, fields] : args;
|
|
185
|
+
} catch {
|
|
186
|
+
return args;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Export the record derived from the same native call to observability.
|
|
191
|
+
* Mirrors DualLogger semantics: export is independent of the console
|
|
192
|
+
* level filter, and never throws into the caller.
|
|
193
|
+
*/
|
|
194
|
+
#export(level, message, args) {
|
|
195
|
+
const ctx = this.#adapterContext;
|
|
196
|
+
if (!ctx?.options.export) return;
|
|
197
|
+
try {
|
|
198
|
+
ctx.getLogSink()?.[level](message, buildLogRecordData(args));
|
|
199
|
+
} catch {}
|
|
123
200
|
}
|
|
124
201
|
shouldLog(level, message, args) {
|
|
125
202
|
if (!this.filter) return true;
|
|
@@ -139,16 +216,23 @@ var ConsoleLogger = class ConsoleLogger extends MastraLogger {
|
|
|
139
216
|
return this.component ? `[${this.component}] ` : "";
|
|
140
217
|
}
|
|
141
218
|
debug(message, ...args) {
|
|
142
|
-
if (this.level === LogLevel.DEBUG && this.shouldLog(LogLevel.DEBUG, message, args)) console.info(`${this.prefix()}${message}`, ...args);
|
|
219
|
+
if (this.level === LogLevel.DEBUG && this.shouldLog(LogLevel.DEBUG, message, args)) console.info(`${this.prefix()}${message}`, ...this.#correlate(args));
|
|
220
|
+
this.#export("debug", message, args);
|
|
143
221
|
}
|
|
144
222
|
info(message, ...args) {
|
|
145
|
-
if ((this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.INFO, message, args)) console.info(`${this.prefix()}${message}`, ...args);
|
|
223
|
+
if ((this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.INFO, message, args)) console.info(`${this.prefix()}${message}`, ...this.#correlate(args));
|
|
224
|
+
this.#export("info", message, args);
|
|
146
225
|
}
|
|
147
226
|
warn(message, ...args) {
|
|
148
|
-
if ((this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.WARN, message, args)) console.warn(`${this.prefix()}${message}`, ...args);
|
|
227
|
+
if ((this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.WARN, message, args)) console.warn(`${this.prefix()}${message}`, ...this.#correlate(args));
|
|
228
|
+
this.#export("warn", message, args);
|
|
149
229
|
}
|
|
150
230
|
error(message, ...args) {
|
|
151
|
-
if ((this.level === LogLevel.ERROR || this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.ERROR, message, args)) console.error(`${this.prefix()}${message}`, ...args);
|
|
231
|
+
if ((this.level === LogLevel.ERROR || this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.ERROR, message, args)) console.error(`${this.prefix()}${message}`, ...this.#correlate(args));
|
|
232
|
+
this.#export("error", message, args);
|
|
233
|
+
}
|
|
234
|
+
trackException(error, metadata) {
|
|
235
|
+
exportTrackedException(this.#adapterContext, error, metadata);
|
|
152
236
|
}
|
|
153
237
|
async listLogs(_transportId, _params) {
|
|
154
238
|
return {
|