@cosmicdrift/kumiko-renderer-puppeteer-client 0.391.0 → 0.392.0

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.
Files changed (2) hide show
  1. package/README.md +30 -32
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,26 +1,24 @@
1
1
  # renderer-puppeteer-client
2
2
 
3
- Plugin für `renderer-foundation`. Rendert `kind=["document-pdf", "image-snapshot"]`-Requests via HTTP-Call gegen `puppeteer-service` (separate app in `apps/puppeteer-service` of this repository).
3
+ Plugin for `renderer-foundation`. Renders `kind=["document-pdf", "image-snapshot"]` requests via an HTTP call to `puppeteer-service` (separate app in `apps/puppeteer-service` in this repository).
4
4
 
5
- **Plan-Doc:** [`renderer-foundation.md`](https://github.com/CosmicDriftGameStudio/kumiko-platform/blob/main/docs/plans/features/renderer-foundation.md) Schritte 4–7.
6
-
7
- ## Architektur
5
+ ## Architecture
8
6
 
9
7
  ```
10
- Caller (z.B. Solon NKA-PDF-Generator)
8
+ Caller (e.g. Solon NKA-PDF-Generator)
11
9
  │
12
10
  │ const renderer = foundation.createRendererForTenant({ tenantId, kind: "document-pdf" })
13
11
  │ await renderer.render({ kind: "document-pdf", payload: { content: "<html>…" } }, ctx)
14
12
  ▼
15
- renderer-puppeteer-client (DIESES Package)
13
+ renderer-puppeteer-client (THIS package)
16
14
  │
17
15
  │ POST {PUPPETEER_SERVICE_URL}/render
18
16
  │ Authorization: Bearer {PUPPETEER_AUTH_TOKEN}
19
17
  │ Retry: 5xx + network-error (exponential backoff)
20
18
  ▼
21
- puppeteer-service (separate App, K8s-Deployment)
19
+ puppeteer-service (separate app, K8s deployment)
22
20
  │
23
- │ Launches Puppeteer-Browser, rendert HTML
21
+ │ Launches Puppeteer browser, renders HTML
24
22
  ▼
25
23
  {kind: "document-pdf", pdfBytes, ...}
26
24
  ```
@@ -34,7 +32,7 @@ import { createRendererFoundationFeature } from "@cosmicdrift/kumiko-bundled-fea
34
32
  const features = [
35
33
  createRendererFoundationFeature(),
36
34
  createRendererPuppeteerClientFeature(),
37
- // weitere renderer-Plugins (renderer-mail-html, …)
35
+ // additional renderer plugins (renderer-mail-html, …)
38
36
  ];
39
37
 
40
38
  // In createKumikoApp's extraContext:
@@ -43,31 +41,31 @@ extraContext: ({ db, registry }) => ({
43
41
  });
44
42
  ```
45
43
 
46
- ## Konfiguration (env-vars)
44
+ ## Configuration (env vars)
47
45
 
48
- App-wide, gesetzt via K8s-Secret + ConfigMap:
46
+ App-wide, set via K8s Secret + ConfigMap:
49
47
 
50
- | Var | Default | Beschreibung |
48
+ | Var | Default | Description |
51
49
  |---|---|---|
52
- | `PUPPETEER_SERVICE_URL` | `http://puppeteer-service:3000` | Cluster-internal URL des Services |
53
- | `PUPPETEER_AUTH_TOKEN` | **required** | Shared Secret (>=16 chars, matched zum Service) |
54
- | `PUPPETEER_CLIENT_TIMEOUT_MS` | `60000` | Per-Request Timeout (Client-Side) |
55
- | `PUPPETEER_CLIENT_MAX_RETRIES` | `3` | Anzahl Retries bei 5xx/network-Error |
50
+ | `PUPPETEER_SERVICE_URL` | `http://puppeteer-service:3000` | Internal cluster URL of the service |
51
+ | `PUPPETEER_AUTH_TOKEN` | **required** | Shared secret (>=16 chars, matching the service) |
52
+ | `PUPPETEER_CLIENT_TIMEOUT_MS` | `60000` | Per-request timeout (client side) |
53
+ | `PUPPETEER_CLIENT_MAX_RETRIES` | `3` | Number of retries for 5xx/network errors |
56
54
 
57
- **Pro Tenant?** Aktuell **nicht** — alle Tenants nutzen den gleichen Service. Per-tenant-overrides via config-Bundle kommen, wenn der Bedarf real ist (z.B. dedicated puppeteer-pool für Enterprise-Tenants).
55
+ **Per tenant?** Currently **no**. All tenants use the same service. Per-tenant overrides via a config bundle will be added when there is a real need, for example a dedicated Puppeteer pool for enterprise tenants.
58
56
 
59
- ## Retry-Strategie
57
+ ## Retry strategy
60
58
 
61
- | Response | Aktion |
59
+ | Response | Action |
62
60
  |---|---|
63
- | `2xx` | Success — bytes returnen |
64
- | `4xx` (Validation, Auth, 413) | **KEIN Retry** — RendererError("invalid_payload") sofort |
65
- | `5xx` (Render-Error, Service-Crash) | Retry mit exponential backoff (200ms × 2^attempt) + ±50% jitter |
66
- | Network-error (ECONNREFUSED, timeout) | Retry wie 5xx |
61
+ | `2xx` | Success, return bytes |
62
+ | `4xx` (validation, auth, 413) | **NO retry**. Return `RendererError("invalid_payload")` immediately |
63
+ | `5xx` (render error, service crash) | Retry with exponential backoff (200ms × 2^attempt) + ±50% jitter |
64
+ | Network-error (ECONNREFUSED, timeout) | Retry as for 5xx |
67
65
 
68
- Nach `PUPPETEER_CLIENT_MAX_RETRIES`-Exhaustion: `RendererError("other")` mit Original-Error-Message.
66
+ After `PUPPETEER_CLIENT_MAX_RETRIES` is exhausted: `RendererError("other")` with the original error message.
69
67
 
70
- ## Caller-Pattern
68
+ ## Caller pattern
71
69
 
72
70
  ```typescript
73
71
  import { requireRendererFoundation } from "@cosmicdrift/kumiko-bundled-features/renderer-foundation";
@@ -86,17 +84,17 @@ async function generatePdf(ctx, tenantId, htmlContent) {
86
84
  );
87
85
 
88
86
  if (result.kind !== "document-pdf") throw new Error("unexpected kind");
89
- return result.pdfBytes; // → S3-upload oder direkt zum Caller
87
+ return result.pdfBytes; // → S3 upload or directly to the caller
90
88
  }
91
89
  ```
92
90
 
93
91
  ## Tests
94
92
 
95
- - **15 Unit-Tests** (Config + HTTP-Client + Render + Contract) — kein echter Network-Call, fetch-mock via `vi.stubGlobal`.
96
- - **Kein Integration-Test mit echtem Service** — der Service-Stack braucht puppeteer-service running auf einer URL, das ist E2E-Setup (Schritt 7). Hier nur Unit-Coverage des HTTP-Layers.
93
+ - **15 unit tests** (config + HTTP client + render + contract). No actual network call, fetch mocked via `vi.stubGlobal`.
94
+ - **No integration test with a real service**. The service stack requires puppeteer-service to be running at a URL, which is an E2E setup (step 7). Here, only unit coverage of the HTTP layer.
97
95
 
98
- ## Out-of-Scope
96
+ ## Out of scope
99
97
 
100
- - HTML-Sanitization — Caller liefert trusted HTML (kommt aus template-resolver mit tenant-scoping)
101
- - File-Storage — Response ist immer inline bytes, Caller persistiert in S3 wenn nötig
102
- - Tenant-Specific-URLs — derzeit app-wide, später via config-Bundle möglich
98
+ - HTML sanitization: the caller provides trusted HTML (from template-resolver with tenant scoping)
99
+ - File storage: the response always contains inline bytes, and the caller persists them to S3 if necessary
100
+ - Tenant-specific URLs: currently app-wide, possibly via a config bundle later
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-renderer-puppeteer-client",
3
- "version": "0.391.0",
3
+ "version": "0.392.0",
4
4
  "description": "Renderer-Foundation plugin: HTTP client for puppeteer-service (PDF + image snapshot via remote browser).",
5
5
  "license": "MIT",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -19,13 +19,13 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@cosmicdrift/kumiko-bundled-features": "0.391.0",
23
- "@cosmicdrift/kumiko-framework": "0.391.0",
24
- "@cosmicdrift/kumiko-renderer-mail-html": "0.391.0",
25
- "@cosmicdrift/kumiko-types": "0.391.0"
22
+ "@cosmicdrift/kumiko-bundled-features": "0.392.0",
23
+ "@cosmicdrift/kumiko-framework": "0.392.0",
24
+ "@cosmicdrift/kumiko-renderer-mail-html": "0.392.0",
25
+ "@cosmicdrift/kumiko-types": "0.392.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@cosmicdrift/kumiko-testing": "0.391.0"
28
+ "@cosmicdrift/kumiko-testing": "0.392.0"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",