@ai-billing/lago 0.0.0 → 0.0.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/dist/index.cjs +113 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +90 -0
- package/dist/index.js.map +1 -0
- package/package.json +19 -20
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
createLagoDestination: () => createLagoDestination
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/destination/lago-destination.ts
|
|
28
|
+
var import_core = require("@ai-billing/core");
|
|
29
|
+
function createLagoDestination(options) {
|
|
30
|
+
const apiUrl = options.apiUrl ?? "https://api.getlago.com";
|
|
31
|
+
return (0, import_core.createDestination)("lago", async (event) => {
|
|
32
|
+
const tags = event.tags;
|
|
33
|
+
const externalCustomerId = tags[options.externalCustomerIdKey] ?? tags.userId ?? tags.externalCustomerId;
|
|
34
|
+
if (!externalCustomerId) {
|
|
35
|
+
console.warn(
|
|
36
|
+
"[ai-billing] Lago: No external_customer_id found in tags. Skipping event."
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const meterCode = typeof options.meterCode === "function" ? options.meterCode(event) : options.meterCode ?? "llm_usage";
|
|
41
|
+
const metadata = options.mapMetadata ? options.mapMetadata(event) : (0, import_core.buildMeterMetadata)(event);
|
|
42
|
+
const properties = {
|
|
43
|
+
cost_nanos: (0, import_core.costToNumber)(event.cost, "nanos"),
|
|
44
|
+
currency: event.cost.currency
|
|
45
|
+
};
|
|
46
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
47
|
+
if (value !== void 0) {
|
|
48
|
+
properties[key] = value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
console.log("[ai-billing] Sending to Lago:", {
|
|
52
|
+
meter_code: meterCode,
|
|
53
|
+
properties,
|
|
54
|
+
transaction_id: event.generationId
|
|
55
|
+
});
|
|
56
|
+
try {
|
|
57
|
+
const response = await fetch(`${apiUrl}/api/v1/events`, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
Authorization: `Bearer ${options.apiKey}`
|
|
62
|
+
},
|
|
63
|
+
body: JSON.stringify({
|
|
64
|
+
event: {
|
|
65
|
+
transaction_id: event.generationId,
|
|
66
|
+
external_customer_id: String(externalCustomerId),
|
|
67
|
+
code: meterCode,
|
|
68
|
+
timestamp: Math.floor(Date.now() / 1e3),
|
|
69
|
+
properties
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
if (response.status === 429) {
|
|
74
|
+
console.error(
|
|
75
|
+
"[ai-billing] LagoDestination Error: Rate limit exceeded."
|
|
76
|
+
);
|
|
77
|
+
} else if (response.status === 422) {
|
|
78
|
+
const body = await response.text();
|
|
79
|
+
console.error(
|
|
80
|
+
"[ai-billing] LagoDestination Error: Invalid parameters supplied to Lago API.",
|
|
81
|
+
body
|
|
82
|
+
);
|
|
83
|
+
} else if (response.status === 401) {
|
|
84
|
+
console.error(
|
|
85
|
+
"[ai-billing] LagoDestination Error: Unauthorized. Check your API key."
|
|
86
|
+
);
|
|
87
|
+
} else if (!response.ok) {
|
|
88
|
+
const body = await response.text();
|
|
89
|
+
console.error(
|
|
90
|
+
`[ai-billing] LagoDestination Error: Unexpected response (${response.status}).`,
|
|
91
|
+
body
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
} catch (err) {
|
|
95
|
+
if (err instanceof TypeError) {
|
|
96
|
+
console.error(
|
|
97
|
+
"[ai-billing] LagoDestination Error: Network error.",
|
|
98
|
+
err.message
|
|
99
|
+
);
|
|
100
|
+
} else {
|
|
101
|
+
console.error(
|
|
102
|
+
"[ai-billing] LagoDestination Error:",
|
|
103
|
+
err.message
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
createLagoDestination
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/destination/lago-destination.ts"],"sourcesContent":["export * from './destination/index.js';\n","import {\n createDestination,\n costToNumber,\n buildMeterMetadata,\n} from '@ai-billing/core';\nimport type {\n BillingEvent,\n DefaultTags,\n Destination,\n MeterMetadata,\n} from '@ai-billing/core';\n\nexport interface LagoDestinationOptions<\n TTags extends DefaultTags = DefaultTags,\n> {\n apiKey: string;\n apiUrl?: string;\n /** Lago billable metric code. Defaults to 'llm_usage'. */\n meterCode?: string | ((event: BillingEvent<TTags>) => string);\n\n /** Custom key to look for in tags for the Lago external customer ID.\n * Defaults to: 'userId' | 'externalCustomerId'\n */\n externalCustomerIdKey?: keyof TTags;\n\n mapMetadata?: (\n event: BillingEvent<TTags>,\n ) => Record<string, string | number | boolean>;\n}\n\nexport function createLagoDestination<TTags extends DefaultTags = DefaultTags>(\n options: LagoDestinationOptions<TTags>,\n): Destination<TTags> {\n const apiUrl = options.apiUrl ?? 'https://api.getlago.com';\n\n return createDestination<TTags>('lago', async event => {\n const tags = event.tags as Record<string, string | number | boolean>;\n\n const externalCustomerId =\n tags[options.externalCustomerIdKey as string] ??\n tags.userId ??\n tags.externalCustomerId;\n\n if (!externalCustomerId) {\n console.warn(\n '[ai-billing] Lago: No external_customer_id found in tags. Skipping event.',\n );\n return;\n }\n\n const meterCode =\n typeof options.meterCode === 'function'\n ? options.meterCode(event)\n : (options.meterCode ?? 'llm_usage');\n\n const metadata: Record<string, string | number | boolean> | MeterMetadata =\n options.mapMetadata\n ? options.mapMetadata(event)\n : buildMeterMetadata(event);\n\n const properties: Record<string, string | number | boolean> = {\n cost_nanos: costToNumber(event.cost!, 'nanos'),\n currency: event.cost!.currency,\n };\n\n for (const [key, value] of Object.entries(metadata)) {\n if (value !== undefined) {\n properties[key] = value as string | number | boolean;\n }\n }\n\n console.log('[ai-billing] Sending to Lago:', {\n meter_code: meterCode,\n properties,\n transaction_id: event.generationId,\n });\n\n try {\n const response = await fetch(`${apiUrl}/api/v1/events`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${options.apiKey}`,\n },\n body: JSON.stringify({\n event: {\n transaction_id: event.generationId,\n external_customer_id: String(externalCustomerId),\n code: meterCode,\n timestamp: Math.floor(Date.now() / 1000),\n properties,\n },\n }),\n });\n\n if (response.status === 429) {\n console.error(\n '[ai-billing] LagoDestination Error: Rate limit exceeded.',\n );\n } else if (response.status === 422) {\n const body = await response.text();\n console.error(\n '[ai-billing] LagoDestination Error: Invalid parameters supplied to Lago API.',\n body,\n );\n } else if (response.status === 401) {\n console.error(\n '[ai-billing] LagoDestination Error: Unauthorized. Check your API key.',\n );\n } else if (!response.ok) {\n const body = await response.text();\n console.error(\n `[ai-billing] LagoDestination Error: Unexpected response (${response.status}).`,\n body,\n );\n }\n } catch (err: unknown) {\n if (err instanceof TypeError) {\n console.error(\n '[ai-billing] LagoDestination Error: Network error.',\n (err as Error).message,\n );\n } else {\n console.error(\n '[ai-billing] LagoDestination Error:',\n (err as Error).message,\n );\n }\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAIO;AA0BA,SAAS,sBACd,SACoB;AACpB,QAAM,SAAS,QAAQ,UAAU;AAEjC,aAAO,+BAAyB,QAAQ,OAAM,UAAS;AACrD,UAAM,OAAO,MAAM;AAEnB,UAAM,qBACJ,KAAK,QAAQ,qBAA+B,KAC5C,KAAK,UACL,KAAK;AAEP,QAAI,CAAC,oBAAoB;AACvB,cAAQ;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,YACJ,OAAO,QAAQ,cAAc,aACzB,QAAQ,UAAU,KAAK,IACtB,QAAQ,aAAa;AAE5B,UAAM,WACJ,QAAQ,cACJ,QAAQ,YAAY,KAAK,QACzB,gCAAmB,KAAK;AAE9B,UAAM,aAAwD;AAAA,MAC5D,gBAAY,0BAAa,MAAM,MAAO,OAAO;AAAA,MAC7C,UAAU,MAAM,KAAM;AAAA,IACxB;AAEA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,GAAG;AACnD,UAAI,UAAU,QAAW;AACvB,mBAAW,GAAG,IAAI;AAAA,MACpB;AAAA,IACF;AAEA,YAAQ,IAAI,iCAAiC;AAAA,MAC3C,YAAY;AAAA,MACZ;AAAA,MACA,gBAAgB,MAAM;AAAA,IACxB,CAAC;AAED,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,GAAG,MAAM,kBAAkB;AAAA,QACtD,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,eAAe,UAAU,QAAQ,MAAM;AAAA,QACzC;AAAA,QACA,MAAM,KAAK,UAAU;AAAA,UACnB,OAAO;AAAA,YACL,gBAAgB,MAAM;AAAA,YACtB,sBAAsB,OAAO,kBAAkB;AAAA,YAC/C,MAAM;AAAA,YACN,WAAW,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;AAAA,YACvC;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAED,UAAI,SAAS,WAAW,KAAK;AAC3B,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW,KAAK;AAClC,cAAM,OAAO,MAAM,SAAS,KAAK;AACjC,gBAAQ;AAAA,UACN;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW,KAAK;AAClC,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF,WAAW,CAAC,SAAS,IAAI;AACvB,cAAM,OAAO,MAAM,SAAS,KAAK;AACjC,gBAAQ;AAAA,UACN,4DAA4D,SAAS,MAAM;AAAA,UAC3E;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,KAAc;AACrB,UAAI,eAAe,WAAW;AAC5B,gBAAQ;AAAA,UACN;AAAA,UACC,IAAc;AAAA,QACjB;AAAA,MACF,OAAO;AACL,gBAAQ;AAAA,UACN;AAAA,UACC,IAAc;AAAA,QACjB;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DefaultTags, BillingEvent, Destination } from '@ai-billing/core';
|
|
2
|
+
|
|
3
|
+
interface LagoDestinationOptions<TTags extends DefaultTags = DefaultTags> {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
apiUrl?: string;
|
|
6
|
+
/** Lago billable metric code. Defaults to 'llm_usage'. */
|
|
7
|
+
meterCode?: string | ((event: BillingEvent<TTags>) => string);
|
|
8
|
+
/** Custom key to look for in tags for the Lago external customer ID.
|
|
9
|
+
* Defaults to: 'userId' | 'externalCustomerId'
|
|
10
|
+
*/
|
|
11
|
+
externalCustomerIdKey?: keyof TTags;
|
|
12
|
+
mapMetadata?: (event: BillingEvent<TTags>) => Record<string, string | number | boolean>;
|
|
13
|
+
}
|
|
14
|
+
declare function createLagoDestination<TTags extends DefaultTags = DefaultTags>(options: LagoDestinationOptions<TTags>): Destination<TTags>;
|
|
15
|
+
|
|
16
|
+
export { type LagoDestinationOptions, createLagoDestination };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DefaultTags, BillingEvent, Destination } from '@ai-billing/core';
|
|
2
|
+
|
|
3
|
+
interface LagoDestinationOptions<TTags extends DefaultTags = DefaultTags> {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
apiUrl?: string;
|
|
6
|
+
/** Lago billable metric code. Defaults to 'llm_usage'. */
|
|
7
|
+
meterCode?: string | ((event: BillingEvent<TTags>) => string);
|
|
8
|
+
/** Custom key to look for in tags for the Lago external customer ID.
|
|
9
|
+
* Defaults to: 'userId' | 'externalCustomerId'
|
|
10
|
+
*/
|
|
11
|
+
externalCustomerIdKey?: keyof TTags;
|
|
12
|
+
mapMetadata?: (event: BillingEvent<TTags>) => Record<string, string | number | boolean>;
|
|
13
|
+
}
|
|
14
|
+
declare function createLagoDestination<TTags extends DefaultTags = DefaultTags>(options: LagoDestinationOptions<TTags>): Destination<TTags>;
|
|
15
|
+
|
|
16
|
+
export { type LagoDestinationOptions, createLagoDestination };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/destination/lago-destination.ts
|
|
2
|
+
import {
|
|
3
|
+
createDestination,
|
|
4
|
+
costToNumber,
|
|
5
|
+
buildMeterMetadata
|
|
6
|
+
} from "@ai-billing/core";
|
|
7
|
+
function createLagoDestination(options) {
|
|
8
|
+
const apiUrl = options.apiUrl ?? "https://api.getlago.com";
|
|
9
|
+
return createDestination("lago", async (event) => {
|
|
10
|
+
const tags = event.tags;
|
|
11
|
+
const externalCustomerId = tags[options.externalCustomerIdKey] ?? tags.userId ?? tags.externalCustomerId;
|
|
12
|
+
if (!externalCustomerId) {
|
|
13
|
+
console.warn(
|
|
14
|
+
"[ai-billing] Lago: No external_customer_id found in tags. Skipping event."
|
|
15
|
+
);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const meterCode = typeof options.meterCode === "function" ? options.meterCode(event) : options.meterCode ?? "llm_usage";
|
|
19
|
+
const metadata = options.mapMetadata ? options.mapMetadata(event) : buildMeterMetadata(event);
|
|
20
|
+
const properties = {
|
|
21
|
+
cost_nanos: costToNumber(event.cost, "nanos"),
|
|
22
|
+
currency: event.cost.currency
|
|
23
|
+
};
|
|
24
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
25
|
+
if (value !== void 0) {
|
|
26
|
+
properties[key] = value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
console.log("[ai-billing] Sending to Lago:", {
|
|
30
|
+
meter_code: meterCode,
|
|
31
|
+
properties,
|
|
32
|
+
transaction_id: event.generationId
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
const response = await fetch(`${apiUrl}/api/v1/events`, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
headers: {
|
|
38
|
+
"Content-Type": "application/json",
|
|
39
|
+
Authorization: `Bearer ${options.apiKey}`
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
event: {
|
|
43
|
+
transaction_id: event.generationId,
|
|
44
|
+
external_customer_id: String(externalCustomerId),
|
|
45
|
+
code: meterCode,
|
|
46
|
+
timestamp: Math.floor(Date.now() / 1e3),
|
|
47
|
+
properties
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
if (response.status === 429) {
|
|
52
|
+
console.error(
|
|
53
|
+
"[ai-billing] LagoDestination Error: Rate limit exceeded."
|
|
54
|
+
);
|
|
55
|
+
} else if (response.status === 422) {
|
|
56
|
+
const body = await response.text();
|
|
57
|
+
console.error(
|
|
58
|
+
"[ai-billing] LagoDestination Error: Invalid parameters supplied to Lago API.",
|
|
59
|
+
body
|
|
60
|
+
);
|
|
61
|
+
} else if (response.status === 401) {
|
|
62
|
+
console.error(
|
|
63
|
+
"[ai-billing] LagoDestination Error: Unauthorized. Check your API key."
|
|
64
|
+
);
|
|
65
|
+
} else if (!response.ok) {
|
|
66
|
+
const body = await response.text();
|
|
67
|
+
console.error(
|
|
68
|
+
`[ai-billing] LagoDestination Error: Unexpected response (${response.status}).`,
|
|
69
|
+
body
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
if (err instanceof TypeError) {
|
|
74
|
+
console.error(
|
|
75
|
+
"[ai-billing] LagoDestination Error: Network error.",
|
|
76
|
+
err.message
|
|
77
|
+
);
|
|
78
|
+
} else {
|
|
79
|
+
console.error(
|
|
80
|
+
"[ai-billing] LagoDestination Error:",
|
|
81
|
+
err.message
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
createLagoDestination
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/destination/lago-destination.ts"],"sourcesContent":["import {\n createDestination,\n costToNumber,\n buildMeterMetadata,\n} from '@ai-billing/core';\nimport type {\n BillingEvent,\n DefaultTags,\n Destination,\n MeterMetadata,\n} from '@ai-billing/core';\n\nexport interface LagoDestinationOptions<\n TTags extends DefaultTags = DefaultTags,\n> {\n apiKey: string;\n apiUrl?: string;\n /** Lago billable metric code. Defaults to 'llm_usage'. */\n meterCode?: string | ((event: BillingEvent<TTags>) => string);\n\n /** Custom key to look for in tags for the Lago external customer ID.\n * Defaults to: 'userId' | 'externalCustomerId'\n */\n externalCustomerIdKey?: keyof TTags;\n\n mapMetadata?: (\n event: BillingEvent<TTags>,\n ) => Record<string, string | number | boolean>;\n}\n\nexport function createLagoDestination<TTags extends DefaultTags = DefaultTags>(\n options: LagoDestinationOptions<TTags>,\n): Destination<TTags> {\n const apiUrl = options.apiUrl ?? 'https://api.getlago.com';\n\n return createDestination<TTags>('lago', async event => {\n const tags = event.tags as Record<string, string | number | boolean>;\n\n const externalCustomerId =\n tags[options.externalCustomerIdKey as string] ??\n tags.userId ??\n tags.externalCustomerId;\n\n if (!externalCustomerId) {\n console.warn(\n '[ai-billing] Lago: No external_customer_id found in tags. Skipping event.',\n );\n return;\n }\n\n const meterCode =\n typeof options.meterCode === 'function'\n ? options.meterCode(event)\n : (options.meterCode ?? 'llm_usage');\n\n const metadata: Record<string, string | number | boolean> | MeterMetadata =\n options.mapMetadata\n ? options.mapMetadata(event)\n : buildMeterMetadata(event);\n\n const properties: Record<string, string | number | boolean> = {\n cost_nanos: costToNumber(event.cost!, 'nanos'),\n currency: event.cost!.currency,\n };\n\n for (const [key, value] of Object.entries(metadata)) {\n if (value !== undefined) {\n properties[key] = value as string | number | boolean;\n }\n }\n\n console.log('[ai-billing] Sending to Lago:', {\n meter_code: meterCode,\n properties,\n transaction_id: event.generationId,\n });\n\n try {\n const response = await fetch(`${apiUrl}/api/v1/events`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${options.apiKey}`,\n },\n body: JSON.stringify({\n event: {\n transaction_id: event.generationId,\n external_customer_id: String(externalCustomerId),\n code: meterCode,\n timestamp: Math.floor(Date.now() / 1000),\n properties,\n },\n }),\n });\n\n if (response.status === 429) {\n console.error(\n '[ai-billing] LagoDestination Error: Rate limit exceeded.',\n );\n } else if (response.status === 422) {\n const body = await response.text();\n console.error(\n '[ai-billing] LagoDestination Error: Invalid parameters supplied to Lago API.',\n body,\n );\n } else if (response.status === 401) {\n console.error(\n '[ai-billing] LagoDestination Error: Unauthorized. Check your API key.',\n );\n } else if (!response.ok) {\n const body = await response.text();\n console.error(\n `[ai-billing] LagoDestination Error: Unexpected response (${response.status}).`,\n body,\n );\n }\n } catch (err: unknown) {\n if (err instanceof TypeError) {\n console.error(\n '[ai-billing] LagoDestination Error: Network error.',\n (err as Error).message,\n );\n } else {\n console.error(\n '[ai-billing] LagoDestination Error:',\n (err as Error).message,\n );\n }\n }\n });\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0BA,SAAS,sBACd,SACoB;AACpB,QAAM,SAAS,QAAQ,UAAU;AAEjC,SAAO,kBAAyB,QAAQ,OAAM,UAAS;AACrD,UAAM,OAAO,MAAM;AAEnB,UAAM,qBACJ,KAAK,QAAQ,qBAA+B,KAC5C,KAAK,UACL,KAAK;AAEP,QAAI,CAAC,oBAAoB;AACvB,cAAQ;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,YACJ,OAAO,QAAQ,cAAc,aACzB,QAAQ,UAAU,KAAK,IACtB,QAAQ,aAAa;AAE5B,UAAM,WACJ,QAAQ,cACJ,QAAQ,YAAY,KAAK,IACzB,mBAAmB,KAAK;AAE9B,UAAM,aAAwD;AAAA,MAC5D,YAAY,aAAa,MAAM,MAAO,OAAO;AAAA,MAC7C,UAAU,MAAM,KAAM;AAAA,IACxB;AAEA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,GAAG;AACnD,UAAI,UAAU,QAAW;AACvB,mBAAW,GAAG,IAAI;AAAA,MACpB;AAAA,IACF;AAEA,YAAQ,IAAI,iCAAiC;AAAA,MAC3C,YAAY;AAAA,MACZ;AAAA,MACA,gBAAgB,MAAM;AAAA,IACxB,CAAC;AAED,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,GAAG,MAAM,kBAAkB;AAAA,QACtD,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,eAAe,UAAU,QAAQ,MAAM;AAAA,QACzC;AAAA,QACA,MAAM,KAAK,UAAU;AAAA,UACnB,OAAO;AAAA,YACL,gBAAgB,MAAM;AAAA,YACtB,sBAAsB,OAAO,kBAAkB;AAAA,YAC/C,MAAM;AAAA,YACN,WAAW,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;AAAA,YACvC;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAED,UAAI,SAAS,WAAW,KAAK;AAC3B,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW,KAAK;AAClC,cAAM,OAAO,MAAM,SAAS,KAAK;AACjC,gBAAQ;AAAA,UACN;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW,KAAK;AAClC,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF,WAAW,CAAC,SAAS,IAAI;AACvB,cAAM,OAAO,MAAM,SAAS,KAAK;AACjC,gBAAQ;AAAA,UACN,4DAA4D,SAAS,MAAM;AAAA,UAC3E;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,KAAc;AACrB,UAAI,eAAe,WAAW;AAC5B,gBAAQ;AAAA,UACN;AAAA,UACC,IAAc;AAAA,QACjB;AAAA,MACF,OAAO;AACL,gBAAQ;AAAA,UACN;AAAA,UACC,IAAc;AAAA,QACjB;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-billing/lago",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -23,34 +23,33 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
|
-
"access": "public"
|
|
26
|
+
"access": "public",
|
|
27
|
+
"provenance": true
|
|
27
28
|
},
|
|
28
29
|
"files": [
|
|
29
30
|
"dist"
|
|
30
31
|
],
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "tsup",
|
|
33
|
-
"check-types": "tsc --noEmit",
|
|
34
|
-
"lint": "oxlint",
|
|
35
|
-
"dev": "tsup --watch",
|
|
36
|
-
"test": "vitest run",
|
|
37
|
-
"test:watch": "vitest",
|
|
38
|
-
"test:coverage": "vitest run --coverage",
|
|
39
|
-
"prepack": "node -e \"require('fs').copyFileSync('../../LICENSE', 'LICENSE')\"",
|
|
40
|
-
"postpack": "node -e \"require('fs').rmSync('LICENSE', { force: true })\""
|
|
41
|
-
},
|
|
42
32
|
"dependencies": {},
|
|
43
33
|
"devDependencies": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"@
|
|
34
|
+
"tsup": "^8.5.1",
|
|
35
|
+
"typescript": "5.9.2",
|
|
36
|
+
"vitest": "4.1.1",
|
|
37
|
+
"@edge-runtime/vm": "^5.0.0",
|
|
38
|
+
"@ai-billing/typescript-config": "0.0.1"
|
|
49
39
|
},
|
|
50
40
|
"peerDependencies": {
|
|
51
|
-
"@ai-billing/core": "
|
|
41
|
+
"@ai-billing/core": "0.0.4"
|
|
52
42
|
},
|
|
53
43
|
"engines": {
|
|
54
44
|
"node": ">=20.0.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"check-types": "tsc --noEmit",
|
|
49
|
+
"lint": "oxlint",
|
|
50
|
+
"dev": "tsup --watch",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:watch": "vitest",
|
|
53
|
+
"test:coverage": "vitest run --coverage"
|
|
55
54
|
}
|
|
56
|
-
}
|
|
55
|
+
}
|