productcraft 0.0.2 → 0.0.3

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 +107 -0
  2. package/package.json +7 -7
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # productcraft
2
+
3
+ All-in-one Node.js / TypeScript SDK for the [ProductCraft](https://productcraft.co) platform. One install, one auth credential, every surface.
4
+
5
+ ```bash
6
+ npm install productcraft
7
+ ```
8
+
9
+ ## When to use this
10
+
11
+ Install **`productcraft`** when you call more than one ProductCraft API from the same backend (e.g. you mint Heimdall tokens *and* send transactional email through Envoi). It's a thin wrapper that instantiates one of each per-surface client and shares your auth credential across them.
12
+
13
+ Install the **per-product packages** when you only need one:
14
+
15
+ - `@productcraft/heimdall` — customer auth + EndUsers
16
+ - `@productcraft/envoi` — transactional email
17
+ - `@productcraft/rally` — waitlists
18
+ - `@productcraft/agora` — landing pages
19
+ - `@productcraft/platform-auth` — workspace administration
20
+
21
+ The per-product packages are leaner (no bundled deps for the surfaces you don't use).
22
+
23
+ ## Quick start
24
+
25
+ ```ts
26
+ import { ProductCraft } from "productcraft";
27
+
28
+ const pc = new ProductCraft({
29
+ auth: { type: "apiKey", key: process.env.PCFT_KEY! },
30
+ });
31
+
32
+ // Heimdall — sign in an EndUser through the BFF flow
33
+ const consumer = pc.heimdall.consumer("my-app-slug");
34
+ const tokens = await consumer.auth.signin({
35
+ identifier: "alice@example.com",
36
+ password: "...",
37
+ });
38
+
39
+ // Envoi — send a transactional email from the same backend
40
+ await pc.envoi.client.POST(
41
+ "/v1/mailboxes/{mailboxId}/messages/send",
42
+ {
43
+ params: { path: { mailboxId: "mbx_..." } },
44
+ body: {
45
+ to: "alice@example.com",
46
+ from: "hello@yourbrand.com",
47
+ subject: "Welcome",
48
+ html: "<p>Hi!</p>",
49
+ },
50
+ },
51
+ );
52
+
53
+ // Rally — accept a waitlist signup
54
+ await pc.rally.client.POST(
55
+ "/v1/waitlists/{workspaceSlug}/{waitlistSlug}/entries",
56
+ {
57
+ params: { path: { workspaceSlug: "my-workspace", waitlistSlug: "early-access" } },
58
+ body: { email: "alice@example.com" },
59
+ },
60
+ );
61
+ ```
62
+
63
+ ## What gets instantiated
64
+
65
+ ```ts
66
+ class ProductCraft {
67
+ readonly heimdall: Heimdall; // @productcraft/heimdall
68
+ readonly envoi: Envoi; // @productcraft/envoi
69
+ readonly rally: Rally; // @productcraft/rally
70
+ readonly agora: Agora; // @productcraft/agora
71
+ readonly platformAuth: PlatformAuth; // @productcraft/platform-auth
72
+ }
73
+ ```
74
+
75
+ Each is the same class you'd get from installing its per-product package directly — `pc.heimdall` is `new Heimdall(config)`, etc. The classes are re-exported so you can refer to their types: `import type { Heimdall } from "productcraft"`.
76
+
77
+ ## Configuration
78
+
79
+ ```ts
80
+ new ProductCraft({
81
+ // Shared auth credential — applied to every surface
82
+ auth: { type: "apiKey", key: "pcft_live_..." }
83
+ | { type: "bearer", token: "eyJ..." }
84
+ | { type: "cookie", value: "auth_token=..." },
85
+
86
+ // Shared overrides (optional)
87
+ baseUrl: "...", // RARELY useful — surfaces have different base URLs
88
+ fetch: customFetch,
89
+
90
+ // Per-surface overrides — useful for dev / staging
91
+ heimdall: { baseUrl: "https://api.heimdall.example.test" },
92
+ envoi: { baseUrl: "https://api.mail.example.test" },
93
+ rally: { baseUrl: "https://api.rally.example.test" },
94
+ agora: { baseUrl: "https://agora.example.test" },
95
+ platformAuth: { baseUrl: "https://api.auth.example.test" },
96
+ });
97
+ ```
98
+
99
+ A per-surface override is merged over the shared config — you can change just the base URL of one surface (e.g. pointing Heimdall at a staging cluster while Envoi stays on prod) without restating the whole credential.
100
+
101
+ ## How these SDKs are built
102
+
103
+ Every surface is generated from its live OpenAPI spec via [`openapi-typescript`](https://openapi-ts.dev/) (types) + [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/) (runtime). Heimdall additionally has a hand-written ergonomic layer (`consumer(slug).auth.signin(...)`) on top of the generated client; the other surfaces ship the `client` directly for now.
104
+
105
+ ## License
106
+
107
+ [MIT](https://github.com/clauderanelagh/productcraft-node/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "productcraft",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "All-in-one Node.js / TypeScript SDK for the ProductCraft platform — Heimdall, Envoi, Rally, Agora, and Platform-Auth from a single import. Install per-product packages (`@productcraft/heimdall`, ...) if you only need one.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -46,12 +46,12 @@
46
46
  "provenance": true
47
47
  },
48
48
  "dependencies": {
49
- "@productcraft/agora": "^0.0.2",
50
- "@productcraft/core": "^0.0.2",
51
- "@productcraft/envoi": "^0.0.2",
52
- "@productcraft/heimdall": "^0.0.2",
53
- "@productcraft/platform-auth": "^0.0.2",
54
- "@productcraft/rally": "^0.0.2"
49
+ "@productcraft/agora": "^0.0.3",
50
+ "@productcraft/core": "^0.0.3",
51
+ "@productcraft/envoi": "^0.0.3",
52
+ "@productcraft/heimdall": "^0.1.0",
53
+ "@productcraft/platform-auth": "^0.0.3",
54
+ "@productcraft/rally": "^0.0.3"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "tsup",