@pikku/kysely 0.13.34 → 0.13.35

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/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## 0.13.35
2
+
3
+ ### Patch Changes
4
+
5
+ - 15c4968: The default runtime path no longer needs `node:*`, `Buffer` or an unguarded `process`, so it loads on edge runtimes (Web APIs only).
6
+
7
+ **Breaking:** `FileScenarioRunStore`, `scenarioArtifactContentType` and `scenarioRunSummary` leave the `@pikku/core/services` barrel because they use `node:fs`. Import them from `@pikku/core/services/file-scenario-run-store`. Pre-0.13 breaking changes still ship as a patch.
8
+
9
+ **Breaking:** the HMAC helpers in `@pikku/core/hmac` run on Web Crypto, which is async. `hmacSha256Hex`, `hmacDigest`, `verifyHmacSignature` and `verifyPublicKeySignature` now return a Promise; `timingSafeStringEqual` stays synchronous. `WebhookService.sign` and `WebhookService.verify` return a Promise, and so does `verifySlackSignature` in `@pikku/gateway-slack`: `await` them. A function-style `verify` on a webhook source may return a Promise as well. `verifyPublicKeySignature` accepts RSA and EC (P-256, P-384, P-521) PEM keys; Ed25519 and RSA-PSS keys verify as false.
10
+
11
+ `isProduction()` (and the `PIKKU_MODEL_ALIASES` and `PIKKU_ENV` reads) now ask the registered singleton services' `variables` service first, then `process.env` when `process` exists. With neither, `isProduction()` is true, so an edge deployment never exposes error details by accident. `LocalVariablesService` resolves its `process.env` default when constructed and falls back to an empty store without `process`.
12
+
13
+ Workflow invocation ids use a built-in SHA-1 and stay byte-identical. `@pikku/kysely` and the Cloudflare hibernation server use `globalThis.crypto.randomUUID()` and no `Buffer`; `@pikku/kysely` is marked `sideEffects: false`. `@pikku/ai-deepinfra` reads `DEEPINFRA_API_KEY` only when `process` exists and decodes base64 audio without `Buffer`.
14
+
15
+ Runtime tiers. A package declares where it can run in `package.json`: `"pikku": { "runtime": "edge" | "serverless" | "server" }`, with optional per-subpath overrides (`"exports": { "./dev": "server" }`). `server` is the default. `@pikku/core` and the default services are `edge` (core's Node-only subpaths are `server`), `@pikku/better-auth`, `@pikku/addon-admin` and `@pikku/cloudflare` are `serverless` (better-auth statically imports `node:crypto` scrypt), and `@pikku/addon-console` is `server` and must never land in a deployed unit.
16
+
17
+ `pikku deploy` now verifies each deployed unit before bundling it. The unit is bundled with esbuild (neutral platform, `workerd`/`worker`/`browser` conditions) under its tier's profile, ahead of the adapter's aliases and stubs so they cannot hide anything, and the build fails when the bundle holds a package declared above the unit's tier or a Node built-in the runtime does not provide. The error names the unit, package, import chain and the fix. A built-in the provider stubs is a warning. On an edge unit, a bundled `InMemory*` class also fails the build. The unit's tier is its `runtime`, else the project's own `pikku.runtime`, else the provider default (`serverless` on Cloudflare). Packages that declare nothing are judged by their imports only.
18
+
19
+ `ProviderAdapter.getRuntimeProfile(tier?)` returns the compat date, compat flags, the built-ins the runtime provides (keyed by compat date), the stubbed ones and the externals. The Cloudflare adapter derives `wrangler.toml`, the upload metadata and the bundle externals from it; `node:os` and `node:fs` are not provided before compat date 2025-09-15. The default is `nodejs_compat_v2` with compat date 2024-12-18, which is what `wrangler.toml` and Fabric's live workers already use, so Fabric deploys see no runtime change. Only the direct-API upload in `@pikku/deploy-cloudflare` (`createWorker`, used by its own `deploy()`) moves: it sent `nodejs_compat` with 2024-01-01 before. A newer date or flag is opt-in through the adapter option `new CloudflareProviderAdapter({ compatDate })` or `getCloudflareRuntimeProfile(tier, compatDate)`. From 2025-08-15 `node:http` and `node:https` exist, and from 2025-09-15 `node:os`, `node:fs` (stubbed by the build regardless) and `node:perf_hooks`; the verifier's allowed built-ins follow the effective date. A newer date changes the runtime of every worker deployed with it.
20
+
21
+ `declareScopes(['pikku:console'])` (from `@pikku/core/scope`) declares scopes by id without wiring anything. `wireAddon({ scopes })` only requires a scope of an addon's functions; the tree arrives with the addon's metadata, so a role granting `pikku:console` used to fail PKU124 unless the addon was wired, and a wired `@pikku/addon-console` lands in every unit carrying the `/rpc` catch-all. An app that grants the scope without the console now calls `declareScopes` and no longer needs the scaffold or the addon. When the addon is wired its tree and descriptions win and the bare id adds nothing.
22
+
23
+ More packages declare a tier after bundling each with the edge profile. `edge`: `@pikku/addon-graph`, `@pikku/pino`, `@pikku/jose`, `@pikku/ai-vercel`, `@pikku/ai-voice`. `serverless`: `@pikku/kysely-postgres` (postgres.js needs `node:buffer`, `stream`, `events`), `@pikku/backblaze` (`copyFile` reads a local file, which the build stubs), `@pikku/gateway-slack` (`@slack/web-api` imports `node:os` and `zlib`). `server`: `@pikku/schedule` (`cron` imports `child_process`), `@pikku/aws-services` (the AWS SDK's Node handler needs `node:http2`), `@pikku/browser` (puppeteer), and `@pikku/modelcontextprotocol` except its `./fetch` subpath, which is `edge`.
24
+
25
+ `@pikku/addon-graph` no longer needs `node:crypto` or `Buffer`: the Crypto function hashes and HMACs on Web Crypto (MD5 is built in, since Web Crypto has none) and encodes with `TextEncoder`/`atob`/`btoa`, with output unchanged.
26
+
27
+ - Updated dependencies [6f11bb5]
28
+ - Updated dependencies [0c67e33]
29
+ - Updated dependencies [15c4968]
30
+ - Updated dependencies [d75a23d]
31
+ - Updated dependencies [9b12c8a]
32
+ - @pikku/core@0.12.138
33
+
1
34
  ## 0.13.34
2
35
 
3
36
  ### Patch Changes
@@ -39,4 +39,7 @@ if (process.argv.length !== 4) {
39
39
  process.exit(1);
40
40
  }
41
41
  const [, , output, input] = process.argv;
42
- main(output, input);
42
+ main(output, input).catch((err) => {
43
+ console.error(err);
44
+ process.exit(1);
45
+ });
@@ -12,8 +12,22 @@ import { DEFAULT_KEY_ID } from '@pikku/core/classification';
12
12
  */
13
13
  export { DEFAULT_KEY_ID };
14
14
  const ENVELOPE_PREFIX = 'pikku1';
15
- const encodePart = (value) => Buffer.from(value, 'utf8').toString('base64url');
16
- const decodePart = (value) => Buffer.from(value, 'base64url').toString('utf8');
15
+ /** base64url of the UTF-8 bytes, unpadded: `Buffer`-free, so it runs on edge runtimes. */
16
+ const encodePart = (value) => {
17
+ let binary = '';
18
+ for (const byte of new TextEncoder().encode(value)) {
19
+ binary += String.fromCharCode(byte);
20
+ }
21
+ return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
22
+ };
23
+ const decodePart = (value) => {
24
+ const base64 = value.replace(/-/g, '+').replace(/_/g, '/');
25
+ const binary = atob(base64 + '='.repeat((4 - (base64.length % 4)) % 4));
26
+ const bytes = new Uint8Array(binary.length);
27
+ for (let i = 0; i < binary.length; i++)
28
+ bytes[i] = binary.charCodeAt(i);
29
+ return new TextDecoder().decode(bytes);
30
+ };
17
31
  const serializeEnvelope = (envelope) => [
18
32
  ENVELOPE_PREFIX,
19
33
  encodePart(envelope.keyId),
@@ -54,7 +54,10 @@ export class KyselyDeploymentService {
54
54
  .execute();
55
55
  }
56
56
  });
57
- this.heartbeatTimer = setInterval(() => this.sendHeartbeat(), this.heartbeatInterval);
57
+ this.heartbeatTimer = setInterval(() => {
58
+ // sendHeartbeat catches its own errors; it retries on the next tick
59
+ void this.sendHeartbeat();
60
+ }, this.heartbeatInterval);
58
61
  }
59
62
  async stop() {
60
63
  if (this.heartbeatTimer) {
@@ -1,4 +1,3 @@
1
- import { randomUUID } from 'node:crypto';
2
1
  import { parseJson } from './kysely-json.js';
3
2
  import { requirePikkuSchema } from './schema/index.js';
4
3
  import { virtualUserSchema } from './schema/virtual-user.schema.js';
@@ -49,7 +48,7 @@ export class KyselyVirtualUserRunStore {
49
48
  }
50
49
  async start(run) {
51
50
  await this.init();
52
- const runId = randomUUID();
51
+ const runId = globalThis.crypto.randomUUID();
53
52
  await this.db
54
53
  .insertInto('virtualUserRun')
55
54
  .values({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/kysely",
3
- "version": "0.13.34",
3
+ "version": "0.13.35",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -15,6 +15,7 @@
15
15
  "pikku-kysely-pure": "dist/bin/pikku-kysely-pure.js"
16
16
  },
17
17
  "type": "module",
18
+ "sideEffects": false,
18
19
  "scripts": {
19
20
  "tsc": "tsc",
20
21
  "ncu": "npx npm-check-updates",
@@ -26,7 +27,7 @@
26
27
  "prepublishOnly": "bun run build"
27
28
  },
28
29
  "peerDependencies": {
29
- "@pikku/core": "^0.12.136"
30
+ "@pikku/core": "^0.12.138"
30
31
  },
31
32
  "dependencies": {
32
33
  "kysely": "^0.29.5"