@selvajs/server 1.3.0 → 1.3.2

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 CHANGED
@@ -26,17 +26,23 @@ pnpm add @selvajs/server
26
26
  **There is no root export.** Import from a subpath — `import … from '@selvajs/server'` fails to
27
27
  resolve, on purpose, so it stays visible which slice a consumer depends on.
28
28
 
29
- | Export | Contents |
30
- | ----------------------------- | ------------------------------------------------------------------------------- |
31
- | `@selvajs/server/compute` | Compute limits, rate limiting, idempotency, SSRF guard, remote-definition fetch |
32
- | `@selvajs/server/definitions` | Definition service, compute-schema extraction, render loader |
33
- | `@selvajs/server/providers` | Env-driven provider selection over a caller-supplied registry |
34
- | `@selvajs/server/tokens` | HMAC codec for capability-URL tokens (share links, invites) |
35
- | `@selvajs/server/errors` | Sentry-backed `IErrorReporter` |
36
- | `@selvajs/server/logging` | pino-backed `ILogger` + request-id correlation |
37
- | `@selvajs/server/http` | Security headers, body-size and redirect guards, route classification |
38
- | `@selvajs/server/access` | Builds the input platform's project access rules consume |
39
- | `@selvajs/server/ops` | Channel-aware semver comparison |
29
+ | Export | Contents |
30
+ | ------------------------------- | ------------------------------------------------------------------------------- |
31
+ | `@selvajs/server/compute` | Compute limits, rate limiting, idempotency, SSRF guard, remote-definition fetch |
32
+ | `@selvajs/server/definitions` | Definition service, compute-schema extraction, render loader |
33
+ | `@selvajs/server/providers` | Env-driven provider selection over a caller-supplied registry |
34
+ | `@selvajs/server/tokens` | HMAC codec for capability-URL tokens (share links, invites) |
35
+ | `@selvajs/server/errors` | Sentry-backed `IErrorReporter` |
36
+ | `@selvajs/server/logging` | pino-backed `ILogger` + request-id correlation |
37
+ | `@selvajs/server/http` | Security headers, body-size and redirect guards, route classification |
38
+ | `@selvajs/server/access` | Builds the input platform's project access rules consume |
39
+ | `@selvajs/server/ops` | Channel-aware semver comparison |
40
+ | `@selvajs/server/api` | Transport-free API core: handler contract, injected deps, error envelope |
41
+ | `@selvajs/server/handlers` | The API handlers: business logic behind each endpoint, bound via `runHandler` |
42
+ | `@selvajs/server/projects` | Project writes whose rules two routes must agree on |
43
+ | `@selvajs/server/organizations` | Org-level domain services spanning more than one provider |
44
+ | `@selvajs/server/notifications` | `SmtpNotificationProvider`, SMTP config, invite delivery |
45
+ | `@selvajs/server/testing` | Test harness for the transport-free API handlers |
40
46
 
41
47
  Requires a `@selvajs/platform` provider (e.g. `@selvajs/local-provider` or
42
48
  `@selvajs/supabase-provider`) for data/storage/auth.
@@ -4,7 +4,7 @@
4
4
  * Handlers used to reach module-global getters (`getProjectProvider()`,
5
5
  * `getDefinitionService()`, …) from the Selva app's composition root — 77 call
6
6
  * sites across the v1 routes. That welded them to one app's boot: a second app
7
- * on a different provider set (parafa, on Supabase) could not call them at all.
7
+ * on a different provider set could not call them at all.
8
8
  *
9
9
  * Most fields are sub-stores of `IDataProvider`, so a host that already built a
10
10
  * `SelvaConfig` gets them via `depsFromConfig`. `services` stays host-defined:
package/dist/api/deps.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Handlers used to reach module-global getters (`getProjectProvider()`,
5
5
  * `getDefinitionService()`, …) from the Selva app's composition root — 77 call
6
6
  * sites across the v1 routes. That welded them to one app's boot: a second app
7
- * on a different provider set (parafa, on Supabase) could not call them at all.
7
+ * on a different provider set could not call them at all.
8
8
  *
9
9
  * Most fields are sub-stores of `IDataProvider`, so a host that already built a
10
10
  * `SelvaConfig` gets them via `depsFromConfig`. `services` stays host-defined:
@@ -32,6 +32,10 @@ export declare function resolveRequestId(headers: Headers, generate?: () => stri
32
32
  * `[object Object]` and destroy the only record of the failure. Errors keep
33
33
  * their stack; anything else is JSON-serialized, with `String()` as the last
34
34
  * resort for cycles and exotic values.
35
+ *
36
+ * A `code` / `statusCode` carried on the error (ComputeError, ProviderError,
37
+ * Node's ECONNREFUSED-style errors) is appended as a `[code=… status=…]` tag —
38
+ * it classifies the failure and stacks alone don't show it.
35
39
  */
36
40
  export declare function renderThrown(error: unknown): string;
37
41
  //# sourceMappingURL=requestId.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestId.d.ts","sourceRoot":"","sources":["../../src/logging/requestId.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAahD,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAI/E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,GAAE,MAAM,MAAiB,GAAG,MAAM,CAE5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOnD"}
1
+ {"version":3,"file":"requestId.d.ts","sourceRoot":"","sources":["../../src/logging/requestId.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAahD,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAI/E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,GAAE,MAAM,MAAiB,GAAG,MAAM,CAE5F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAenD"}
@@ -48,10 +48,23 @@ export function resolveRequestId(headers, generate = randomId) {
48
48
  * `[object Object]` and destroy the only record of the failure. Errors keep
49
49
  * their stack; anything else is JSON-serialized, with `String()` as the last
50
50
  * resort for cycles and exotic values.
51
+ *
52
+ * A `code` / `statusCode` carried on the error (ComputeError, ProviderError,
53
+ * Node's ECONNREFUSED-style errors) is appended as a `[code=… status=…]` tag —
54
+ * it classifies the failure and stacks alone don't show it.
51
55
  */
52
56
  export function renderThrown(error) {
53
- if (error instanceof Error)
54
- return error.stack ?? error.message;
57
+ if (error instanceof Error) {
58
+ const base = error.stack ?? error.message;
59
+ const code = error.code;
60
+ const statusCode = error.statusCode;
61
+ const tags = [];
62
+ if (typeof code === 'string' || typeof code === 'number')
63
+ tags.push(`code=${code}`);
64
+ if (typeof statusCode === 'number')
65
+ tags.push(`status=${statusCode}`);
66
+ return tags.length > 0 ? `${base} [${tags.join(' ')}]` : base;
67
+ }
55
68
  try {
56
69
  return JSON.stringify(error) ?? String(error);
57
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"requestId.js","sourceRoot":"","sources":["../../src/logging/requestId.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,kFAAkF;AAClF,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEhD,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAEpD,oFAAoF;AACpF,MAAM,UAAU,iBAAiB,CAAC,GAA8B;IAC/D,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;IACzF,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB,EAAE,WAAyB,QAAQ;IACnF,OAAO,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC;AACxE,CAAC;AAED;;;;;;;;GAQG;AACH,M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AU,CAAC,MAAM,CAAC;IAChD,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,UAAU,KAAK,UAAU;QAAE,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC;IACnE,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AACpF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selvajs/server",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Transport-agnostic server building blocks for apps built on the Selva engine (limits, rate limiting, SSRF guard, remote-definition fetch, definition service + render loader); the solve core lives in @selvajs/solve/server",
5
5
  "license": "MIT",
6
6
  "author": "VektorNode",
@@ -110,10 +110,10 @@
110
110
  ],
111
111
  "dependencies": {
112
112
  "zod": "^4.3.6",
113
- "@selvajs/compute": "^4.0.2",
114
- "@selvajs/notifications": "^0.2.0",
115
- "@selvajs/platform": "^0.20.0",
116
- "@selvajs/schemas": "^5.0.1"
113
+ "@selvajs/compute": "^4.1.1",
114
+ "@selvajs/notifications": "^0.2.1",
115
+ "@selvajs/platform": "^0.20.1",
116
+ "@selvajs/schemas": "^5.0.2"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "@sentry/node": ">=8",
@@ -132,13 +132,13 @@
132
132
  }
133
133
  },
134
134
  "devDependencies": {
135
- "@types/node": "^26.2.0",
135
+ "@types/node": "^26.4.0",
136
136
  "@types/nodemailer": "^8.0.1",
137
- "nodemailer": "^9.0.5",
137
+ "nodemailer": "^9.0.6",
138
138
  "typescript": "~6.0.3",
139
- "vitest": "^4.1.10",
139
+ "vitest": "^4.1.11",
140
140
  "@selvajs/config": "0.0.4",
141
- "@selvajs/local-provider": "0.15.2"
141
+ "@selvajs/local-provider": "0.15.3"
142
142
  },
143
143
  "scripts": {
144
144
  "build": "tsc",