Comparing version 0.0.8 to 0.0.9
@@ -21,3 +21,3 @@ import { paths } from './api/server'; | ||
} | undefined>; | ||
logGeneration: (body: paths['/api/public/generations']['post']['requestBody']['content']['application/json'], trace?: ReturnType<typeof this.createTrace>, parent?: Promise<{ | ||
logGeneration: (body: WithTypedDates<paths['/api/public/generations']['post']['requestBody']['content']['application/json']>, trace?: ReturnType<typeof this.createTrace>, parent?: Promise<{ | ||
id: string; | ||
@@ -47,3 +47,3 @@ } | undefined>) => Promise<{ | ||
}>; | ||
createSpan: (body: paths['/api/public/spans']['post']['requestBody']['content']['application/json'], trace?: ReturnType<typeof this.createTrace>, parent?: Promise<{ | ||
createSpan: (body: WithTypedDates<paths['/api/public/spans']['post']['requestBody']['content']['application/json']>, trace?: ReturnType<typeof this.createTrace>, parent?: Promise<{ | ||
id: string; | ||
@@ -64,3 +64,3 @@ } | undefined>) => Promise<{ | ||
}>; | ||
createEvent: (body: paths['/api/public/events']['post']['requestBody']['content']['application/json'], trace?: ReturnType<typeof this.createTrace>, parent?: Promise<{ | ||
createEvent: (body: WithTypedDates<paths['/api/public/events']['post']['requestBody']['content']['application/json']>, trace?: ReturnType<typeof this.createTrace>, parent?: Promise<{ | ||
id: string; | ||
@@ -112,1 +112,6 @@ } | undefined>) => Promise<{ | ||
} | ||
type OptionalTypes<T> = T extends null | undefined ? T : never; | ||
type WithTypedDates<T> = { | ||
[P in keyof T]: P extends 'startTime' | 'endTime' | 'timestamp' ? Date | OptionalTypes<T[P]> : T[P]; | ||
}; | ||
export {}; |
@@ -28,7 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const promise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { | ||
var _b, _c; | ||
var _b, _c, _d, _e; | ||
const traceId = trace ? (_b = (yield trace)) === null || _b === void 0 ? void 0 : _b.id : undefined; | ||
const parentId = parent ? (_c = (yield parent)) === null || _c === void 0 ? void 0 : _c.id : undefined; | ||
const res = this.post('/api/public/generations', { | ||
body: Object.assign(Object.assign({}, body), { traceId: traceId !== null && traceId !== void 0 ? traceId : body.traceId, parentObservationId: parentId !== null && parentId !== void 0 ? parentId : body.parentObservationId }), | ||
body: Object.assign(Object.assign({}, body), { startTime: (_d = body.startTime) === null || _d === void 0 ? void 0 : _d.toISOString(), endTime: (_e = body.endTime) === null || _e === void 0 ? void 0 : _e.toISOString(), traceId: traceId !== null && traceId !== void 0 ? traceId : body.traceId, parentObservationId: parentId !== null && parentId !== void 0 ? parentId : body.parentObservationId }), | ||
}).then((res) => { | ||
@@ -51,7 +51,7 @@ if (res.error) { | ||
const promise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { | ||
var _d, _e; | ||
const traceId = trace ? (_d = (yield trace)) === null || _d === void 0 ? void 0 : _d.id : undefined; | ||
const parentId = parent ? (_e = (yield parent)) === null || _e === void 0 ? void 0 : _e.id : undefined; | ||
var _f, _g, _h, _j; | ||
const traceId = trace ? (_f = (yield trace)) === null || _f === void 0 ? void 0 : _f.id : undefined; | ||
const parentId = parent ? (_g = (yield parent)) === null || _g === void 0 ? void 0 : _g.id : undefined; | ||
const res = this.post('/api/public/spans', { | ||
body: Object.assign(Object.assign({}, body), { traceId: traceId !== null && traceId !== void 0 ? traceId : body.traceId, parentObservationId: parentId !== null && parentId !== void 0 ? parentId : body.parentObservationId }), | ||
body: Object.assign(Object.assign({}, body), { startTime: (_h = body.startTime) === null || _h === void 0 ? void 0 : _h.toISOString(), endTime: (_j = body.endTime) === null || _j === void 0 ? void 0 : _j.toISOString(), traceId: traceId !== null && traceId !== void 0 ? traceId : body.traceId, parentObservationId: parentId !== null && parentId !== void 0 ? parentId : body.parentObservationId }), | ||
}).then((res) => { | ||
@@ -74,7 +74,7 @@ if (res.error) { | ||
const promise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { | ||
var _f, _g; | ||
const traceId = trace ? (_f = (yield trace)) === null || _f === void 0 ? void 0 : _f.id : undefined; | ||
const parentId = parent ? (_g = (yield parent)) === null || _g === void 0 ? void 0 : _g.id : undefined; | ||
var _k, _l, _m; | ||
const traceId = trace ? (_k = (yield trace)) === null || _k === void 0 ? void 0 : _k.id : undefined; | ||
const parentId = parent ? (_l = (yield parent)) === null || _l === void 0 ? void 0 : _l.id : undefined; | ||
const res = this.post('/api/public/events', { | ||
body: Object.assign(Object.assign({}, body), { traceId: traceId !== null && traceId !== void 0 ? traceId : body.traceId, parentObservationId: parentId !== null && parentId !== void 0 ? parentId : body.parentObservationId }), | ||
body: Object.assign(Object.assign({}, body), { startTime: (_m = body.startTime) === null || _m === void 0 ? void 0 : _m.toISOString(), traceId: traceId !== null && traceId !== void 0 ? traceId : body.traceId, parentObservationId: parentId !== null && parentId !== void 0 ? parentId : body.parentObservationId }), | ||
}).then((res) => { | ||
@@ -97,5 +97,5 @@ if (res.error) { | ||
const promise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { | ||
var _h, _j; | ||
const traceId = trace ? (_h = (yield trace)) === null || _h === void 0 ? void 0 : _h.id : undefined; | ||
const observationId = observation ? (_j = (yield observation)) === null || _j === void 0 ? void 0 : _j.id : undefined; | ||
var _o, _p; | ||
const traceId = trace ? (_o = (yield trace)) === null || _o === void 0 ? void 0 : _o.id : undefined; | ||
const observationId = observation ? (_p = (yield observation)) === null || _p === void 0 ? void 0 : _p.id : undefined; | ||
const res = this.post('/api/public/scores', { | ||
@@ -102,0 +102,0 @@ body: Object.assign(Object.assign({}, body), { traceId: traceId !== null && traceId !== void 0 ? traceId : body.traceId, observationId: observationId !== null && observationId !== void 0 ? observationId : body.observationId }), |
{ | ||
"name": "langfuse", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"pretty": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json}\"", | ||
"prebuild": "npm run generateAPI && npm run pretty", | ||
"prebuild": "npm i && npm run generateAPI && npm run pretty", | ||
"build": "tsc -p tsconfig.json", | ||
@@ -15,0 +15,0 @@ "prepublishOnly": "npm run build", |
@@ -1,8 +0,17 @@ | ||
# Langfuse | ||
# Langfuse Javascript SDK | ||
[](https://www.npmjs.com/package/posthog-js) | ||
[](https://opensource.org/licenses/MIT) | ||
This is a pre-release version of the langfuse SDK. For production use, please refer to the [Typescript Docs](https://langfuse.com/docs/sdk/typescript). | ||
## Update OpenAPI typing | ||
``` | ||
npm i langfuse | ||
``` | ||
1. Update /src/api/openapi-\*.yaml | ||
## Development | ||
**Update OpenAPI typing** | ||
1. Update `/src/api/openapi-\*.yaml` | ||
2. `npm run generateAPI` | ||
@@ -14,1 +23,5 @@ | ||
2. `npm publish` | ||
## License | ||
MIT |
33397
9
862
27