@magemetrics/core 0.11.1 → 0.11.4
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/index.d.ts +590 -288
- package/dist/index.js +27 -10
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { DefaultChatTransport } from 'ai';
|
|
|
13
13
|
var HEADER_CLIENT_VERSION = "X-Client-Version";
|
|
14
14
|
var HEADER_SP_TOKEN = "sp-access-token";
|
|
15
15
|
var HEADER_API_KEY = "X-Api-Key";
|
|
16
|
+
var HEADER_APPLICATION_NAME = "X-Application-Name";
|
|
16
17
|
var ApiError = class extends Error {
|
|
17
18
|
extra;
|
|
18
19
|
response;
|
|
@@ -57,7 +58,7 @@ var addApiKeyHeader = (apiKey) => {
|
|
|
57
58
|
|
|
58
59
|
// package.json
|
|
59
60
|
var package_default = {
|
|
60
|
-
version: "0.11.
|
|
61
|
+
version: "0.11.4"};
|
|
61
62
|
|
|
62
63
|
// src/core/MageMetricsEventEmitter.ts
|
|
63
64
|
var MageMetricsEventEmitter = class {
|
|
@@ -151,7 +152,7 @@ var hashString = (value) => {
|
|
|
151
152
|
return Array.from(hash).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
152
153
|
};
|
|
153
154
|
|
|
154
|
-
// ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.
|
|
155
|
+
// ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.4.1_zod@4.3.6/node_modules/@asteasolutions/zod-to-openapi/dist/index.mjs
|
|
155
156
|
function __rest(s, e) {
|
|
156
157
|
var t = {};
|
|
157
158
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -169,9 +170,11 @@ var ZodTypeKeys = {
|
|
|
169
170
|
ZodBigInt: "bigint",
|
|
170
171
|
ZodBoolean: "boolean",
|
|
171
172
|
ZodDefault: "default",
|
|
173
|
+
ZodPrefault: "prefault",
|
|
172
174
|
ZodTransform: "transform",
|
|
173
175
|
ZodEnum: "enum",
|
|
174
176
|
ZodIntersection: "intersection",
|
|
177
|
+
ZodLazy: "lazy",
|
|
175
178
|
ZodLiteral: "literal",
|
|
176
179
|
ZodNever: "never",
|
|
177
180
|
ZodNull: "null",
|
|
@@ -190,7 +193,8 @@ var ZodTypeKeys = {
|
|
|
190
193
|
ZodDiscriminatedUnion: "union",
|
|
191
194
|
ZodUnknown: "unknown",
|
|
192
195
|
ZodVoid: "void",
|
|
193
|
-
ZodDate: "date"
|
|
196
|
+
ZodDate: "date",
|
|
197
|
+
ZodTemplateLiteral: "template_literal"
|
|
194
198
|
};
|
|
195
199
|
function isZodType(schema, typeNames) {
|
|
196
200
|
const typeNamesArray = Array.isArray(typeNames) ? typeNames : [typeNames];
|
|
@@ -204,7 +208,7 @@ function isZodType(schema, typeNames) {
|
|
|
204
208
|
});
|
|
205
209
|
}
|
|
206
210
|
function isAnyZodType(schema) {
|
|
207
|
-
return "def" in schema;
|
|
211
|
+
return schema && "def" in schema;
|
|
208
212
|
}
|
|
209
213
|
var $ZodRegistry = class {
|
|
210
214
|
constructor() {
|
|
@@ -283,6 +287,7 @@ var Metadata = class {
|
|
|
283
287
|
"ZodOptional",
|
|
284
288
|
"ZodNullable",
|
|
285
289
|
"ZodDefault",
|
|
290
|
+
"ZodPrefault",
|
|
286
291
|
"ZodReadonly",
|
|
287
292
|
"ZodNonOptional"
|
|
288
293
|
]) && isAnyZodType(schema._zod.def.innerType)) {
|
|
@@ -343,7 +348,8 @@ var Metadata = class {
|
|
|
343
348
|
return this.unwrapUntil(schema);
|
|
344
349
|
}
|
|
345
350
|
static getDefaultValue(zodSchema) {
|
|
346
|
-
|
|
351
|
+
var _a;
|
|
352
|
+
const unwrapped = (_a = this.unwrapUntil(zodSchema, "ZodDefault")) !== null && _a !== void 0 ? _a : this.unwrapUntil(zodSchema, "ZodPrefault");
|
|
347
353
|
return unwrapped === null || unwrapped === void 0 ? void 0 : unwrapped._zod.def.defaultValue;
|
|
348
354
|
}
|
|
349
355
|
static unwrapUntil(schema, typeName) {
|
|
@@ -354,6 +360,7 @@ var Metadata = class {
|
|
|
354
360
|
"ZodOptional",
|
|
355
361
|
"ZodNullable",
|
|
356
362
|
"ZodDefault",
|
|
363
|
+
"ZodPrefault",
|
|
357
364
|
"ZodReadonly",
|
|
358
365
|
"ZodNonOptional"
|
|
359
366
|
]) && isAnyZodType(schema._zod.def.innerType)) {
|
|
@@ -416,7 +423,13 @@ function extendZodWithOpenApi(zod) {
|
|
|
416
423
|
param: Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param), param)
|
|
417
424
|
} : void 0);
|
|
418
425
|
const result = new this.constructor(this._def);
|
|
419
|
-
|
|
426
|
+
function setMetadata(schema) {
|
|
427
|
+
Metadata.setMetadataInRegistry(schema, Object.assign(Object.assign({}, Object.keys(_internal).length > 0 ? { _internal } : void 0), resultMetadata));
|
|
428
|
+
}
|
|
429
|
+
setMetadata(result);
|
|
430
|
+
if (isZodType(result, "ZodLazy")) {
|
|
431
|
+
setMetadata(this);
|
|
432
|
+
}
|
|
420
433
|
if (isZodType(result, "ZodObject")) {
|
|
421
434
|
const currentMetadata2 = Metadata.getMetadataFromRegistry(result);
|
|
422
435
|
const originalExtend = result.extend;
|
|
@@ -469,7 +482,7 @@ function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
|
|
|
469
482
|
};
|
|
470
483
|
}
|
|
471
484
|
|
|
472
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
485
|
+
// ../../node_modules/.pnpm/hono@4.12.4/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
473
486
|
new Set(".\\+*[^]$()");
|
|
474
487
|
var createRoute = (routeConfig) => {
|
|
475
488
|
const route = {
|
|
@@ -626,7 +639,7 @@ var ExternalAuthProvider = class {
|
|
|
626
639
|
supabaseClient = null;
|
|
627
640
|
noAuthApiClient = null;
|
|
628
641
|
authApiResponse = null;
|
|
629
|
-
processedJwt = Symbol("initial");
|
|
642
|
+
processedJwt = /* @__PURE__ */ Symbol("initial");
|
|
630
643
|
userId = null;
|
|
631
644
|
events = new MageMetricsEventEmitter();
|
|
632
645
|
constructor(config) {
|
|
@@ -668,7 +681,7 @@ var ExternalAuthProvider = class {
|
|
|
668
681
|
async updateExternalJwt(jwt) {
|
|
669
682
|
if (this.config.externalJwt === jwt) return;
|
|
670
683
|
this.config.externalJwt = jwt;
|
|
671
|
-
this.processedJwt = Symbol("updating");
|
|
684
|
+
this.processedJwt = /* @__PURE__ */ Symbol("updating");
|
|
672
685
|
await this.initialize();
|
|
673
686
|
}
|
|
674
687
|
async logout() {
|
|
@@ -3062,7 +3075,11 @@ var MageMetricsClient = class {
|
|
|
3062
3075
|
}
|
|
3063
3076
|
async getHeaders() {
|
|
3064
3077
|
await this.waitForAuth();
|
|
3065
|
-
|
|
3078
|
+
const headers = await this.authProvider.getHeaders();
|
|
3079
|
+
if (this.config.applicationName) {
|
|
3080
|
+
headers[HEADER_APPLICATION_NAME] = this.config.applicationName;
|
|
3081
|
+
}
|
|
3082
|
+
return headers;
|
|
3066
3083
|
}
|
|
3067
3084
|
async logout() {
|
|
3068
3085
|
await this.authProvider.logout();
|