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