@rasputin-ai/elysia 0.6.2 → 0.7.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.js CHANGED
@@ -16,7 +16,7 @@ import { Elysia } from "elysia";
16
16
 
17
17
  // src/sdk-meta.ts
18
18
  var SDK_NAME = "@rasputin-ai/elysia";
19
- var SDK_VERSION = "0.6.2";
19
+ var SDK_VERSION = "0.7.1";
20
20
 
21
21
  // src/rasputin-init.ts
22
22
  var publicExecution = (runtime) => ({
@@ -24,7 +24,7 @@ var publicExecution = (runtime) => ({
24
24
  const scope = runtime.createScope(metadata);
25
25
  return {
26
26
  run: scope.run,
27
- associateError: scope.associateError,
27
+ observeError: scope.observeError,
28
28
  finish: scope.finish
29
29
  };
30
30
  },
@@ -93,42 +93,51 @@ var finishExecution = (scope, metadata) => {
93
93
  } catch {
94
94
  }
95
95
  };
96
- var rememberExecutionError = (scope, error) => {
96
+ var requestScopes = /* @__PURE__ */ new WeakMap();
97
+ var observeExecutionError = (scope, error) => {
97
98
  try {
98
- scope.associateError(error);
99
+ return scope.observeError(error);
99
100
  } catch {
101
+ return void 0;
100
102
  }
101
103
  };
102
104
  var buildPlugin = (client, execution, recorderEnabled) => {
103
105
  const executionBoundary = ((handler, initialRequest) => {
104
- const scope = execution.createScope({
105
- kind: "http",
106
- request: { method: initialRequest.method }
107
- });
108
- return (request) => scope.run(() => {
106
+ return (request) => {
107
+ const scope = execution.createScope({
108
+ kind: "http",
109
+ request: { method: request.method || initialRequest.method }
110
+ });
109
111
  try {
110
- const response = handler(request);
111
- if (isNativeResponsePromise(response)) {
112
- Promise.prototype.then.call(
113
- response,
114
- (value) => {
115
- finishExecution(scope, { request: { status: value.status } });
116
- },
117
- (error) => {
118
- rememberExecutionError(scope, error);
119
- finishExecution(scope);
120
- }
121
- );
112
+ requestScopes.set(request, scope);
113
+ requestScopes.set(initialRequest, scope);
114
+ } catch {
115
+ }
116
+ return scope.run(() => {
117
+ try {
118
+ const response = handler(request);
119
+ if (isNativeResponsePromise(response)) {
120
+ Promise.prototype.then.call(
121
+ response,
122
+ (value) => {
123
+ finishExecution(scope, { request: { status: value.status } });
124
+ },
125
+ (error) => {
126
+ observeExecutionError(scope, error);
127
+ finishExecution(scope);
128
+ }
129
+ );
130
+ return response;
131
+ }
132
+ finishExecution(scope, { request: { status: response.status } });
122
133
  return response;
134
+ } catch (error) {
135
+ observeExecutionError(scope, error);
136
+ finishExecution(scope);
137
+ throw error;
123
138
  }
124
- finishExecution(scope, { request: { status: response.status } });
125
- return response;
126
- } catch (error) {
127
- rememberExecutionError(scope, error);
128
- finishExecution(scope);
129
- throw error;
130
- }
131
- });
139
+ });
140
+ };
132
141
  });
133
142
  const plugin = new Elysia({ name: "rasputin" }).decorate("rasputin", client);
134
143
  if (recorderEnabled) plugin.wrap(executionBoundary);
@@ -139,7 +148,12 @@ var buildPlugin = (client, execution, recorderEnabled) => {
139
148
  status: toStatus(set.status)
140
149
  };
141
150
  try {
142
- client.captureException(error, { request: requestContext });
151
+ const scope = requestScopes.get(request);
152
+ const observation = scope ? observeExecutionError(scope, error) : void 0;
153
+ client.captureException(error, {
154
+ request: requestContext,
155
+ ...observation ? { observation } : {}
156
+ });
143
157
  } catch {
144
158
  }
145
159
  return;
@@ -165,10 +179,7 @@ function RasputinInit(options, hooks = {}) {
165
179
  installTransportSignalHandlers,
166
180
  sdkVersion: SDK_VERSION,
167
181
  sdkName: SDK_NAME,
168
- resolveRuntimeState: (error, context) => runtime.getErrorState(
169
- error,
170
- context?.request ? { kind: "http", request: context.request } : void 0
171
- )
182
+ resolveObservation: (observation) => runtime.getErrorState(observation)
172
183
  });
173
184
  let uninstallHandlers = () => {
174
185
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rasputin-init.d.ts","sourceRoot":"","sources":["../src/rasputin-init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAMN,KAAK,eAAe,EAGpB,MAAM,mBAAmB,C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,MAAM,MAAM,cAAc,GAAG;IAC5B,8EAA8E;IAC9E,MAAM,EAAE,kBAAkB,CAAC;IAC3B,2EAA2E;IAC3E,MAAM,EAAE,oBAAoB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG;IACrD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC;AAuHF,QAAA,MAAM,WAAW,GAChB,QAAQ,kBAAkB,EAC1B,WAAW,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,EACjD,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiExB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAAC"}
@@ -1,4 +1,4 @@
1
1
  /** Generated by scripts/generate-sdk-meta.ts — do not edit. */
2
2
  export declare const SDK_NAME = "@rasputin-ai/elysia";
3
- export declare const SDK_VERSION = "0.6.2";
3
+ export declare const SDK_VERSION = "0.7.1";
4
4
  //# sourceMappingURL=sdk-meta.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasputin-ai/elysia",
3
- "version": "0.6.2",
3
+ "version": "0.7.1",
4
4
  "description": "Official Rasputin AI SDK for Elysia.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -24,10 +24,10 @@
24
24
  "dist"
25
25
  ],
26
26
  "scripts": {
27
- "build": "bun ../scripts/build-package.ts .",
28
- "prepublishOnly": "npm run build && bun ../scripts/check-lockstep-versions.ts",
27
+ "build": "bun ../../scripts/build-package.ts .",
28
+ "prepublishOnly": "npm run build && bun ../../scripts/check-lockstep-versions.ts",
29
29
  "pack:check": "npm run build && npm pack --dry-run",
30
- "typecheck": "bun ../scripts/build-package.ts ../core && bun ../scripts/build-package.ts ../node && bun ../scripts/generate-sdk-meta.ts . && bunx tsc --noEmit",
30
+ "typecheck": "bun ../../scripts/generate-sdk-meta.ts . && bunx tsc --noEmit",
31
31
  "lint": "biome check .",
32
32
  "test": "bun test"
33
33
  },
@@ -35,8 +35,8 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@rasputin-ai/core": "0.6.2",
39
- "@rasputin-ai/node": "0.6.2"
38
+ "@rasputin-ai/core": "0.7.1",
39
+ "@rasputin-ai/node": "0.7.1"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "elysia": ">=1.4.0 <2"