@productcraft/waitlist 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ProductCraft
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # @productcraft/waitlist
2
+
3
+ Typed Node.js SDK for [ProductCraft Waitlist](https://productcraft.co) — waitlist management: public-form signups, variants for A/B/n landing pages, referrals, position + leaderboard, approval workflow with invite-to-app, signed outbound webhooks, CSV export.
4
+
5
+ ```bash
6
+ npm install @productcraft/waitlist
7
+ ```
8
+
9
+ The waitlist-entries endpoint can be called unauthenticated from a marketing-site form. Every other endpoint (admin, approval, analytics, exports, webhooks) requires a PlatformUser cookie or a workspace-scoped PAK (`pcft_live_…`).
10
+
11
+ ## Quick start — accept a signup from a public form
12
+
13
+ ```ts
14
+ import { Waitlist } from "@productcraft/waitlist";
15
+
16
+ // No auth — public surface
17
+ const waitlist = new Waitlist();
18
+
19
+ const { data, error } = await waitlist.client.POST(
20
+ "/v1/waitlists/{workspace_slug}/{waitlist_slug}/entries",
21
+ {
22
+ params: { path: { workspace_slug: "acme", waitlist_slug: "early-access" } },
23
+ body: {
24
+ email: "alice@example.com",
25
+ name: "Alice",
26
+ referrer: "twitter",
27
+ referral_code: "ada-123", // optional — bumps the referrer's position
28
+ metadata: { plan_interest: "pro" },
29
+ },
30
+ },
31
+ );
32
+ ```
33
+
34
+ The response includes the entry's id + assigned position. Round-trip the `id` into your "thanks" page so the visitor can share their own referral link.
35
+
36
+ If the waitlist has `settings.recaptcha_site_key` set, also pass a `recaptcha_token` from your client side.
37
+
38
+ ## Quick start — workspace-admin (authenticated)
39
+
40
+ ```ts
41
+ import { Waitlist } from "@productcraft/waitlist";
42
+
43
+ const waitlist = new Waitlist({
44
+ auth: { type: "apiKey", key: process.env.PCFT_KEY! },
45
+ });
46
+
47
+ // Create a waitlist — body uses `display_name`, not `name`.
48
+ const { data } = await waitlist.client.POST(
49
+ "/v1/workspaces/{workspace_id}/waitlists",
50
+ {
51
+ params: { path: { workspace_id: "<workspace-uuid>" } },
52
+ body: { display_name: "Early Access", slug: "early-access" },
53
+ },
54
+ );
55
+ ```
56
+
57
+ `{workspace_id}` is the workspace UUID returned by `@productcraft/platform-auth`'s introspect endpoint.
58
+
59
+ ## Configuration
60
+
61
+ ```ts
62
+ new Waitlist({
63
+ // Optional: required for workspace-admin calls. Public submit works without auth.
64
+ auth: { type: "apiKey", key: "pcft_live_..." }
65
+ | { type: "bearer", token: "eyJ..." }
66
+ | { type: "cookie", value: "auth_token=..." },
67
+ baseUrl: "https://api.waitlist.example.test", // optional override
68
+ fetch: customFetch, // optional
69
+ });
70
+ ```
71
+
72
+ ## Common operations
73
+
74
+ ### Public surface
75
+
76
+ ```ts
77
+ // Read the waitlist's public metadata (name, position-window, active variant, ...)
78
+ await waitlist.client.GET(
79
+ "/v1/waitlists/{workspace_slug}/{waitlist_slug}",
80
+ { params: { ... } },
81
+ );
82
+
83
+ // Read the public leaderboard (when enabled per-waitlist)
84
+ await waitlist.client.GET(
85
+ "/v1/waitlists/{workspace_slug}/{waitlist_slug}/leaderboard",
86
+ { params: { ... } },
87
+ );
88
+ ```
89
+
90
+ ### Entries (workspace-admin)
91
+
92
+ ```ts
93
+ // List entries
94
+ await waitlist.client.GET(
95
+ "/v1/workspaces/{workspace_id}/waitlists/{waitlist_id}/entries",
96
+ { params: { path: { workspace_id, waitlist_id }, query: { limit: 50 } } },
97
+ );
98
+
99
+ // Count
100
+ await waitlist.client.GET(
101
+ "/v1/workspaces/{workspace_id}/waitlists/{waitlist_id}/entries/count",
102
+ { ... },
103
+ );
104
+
105
+ // Approve / reject in bulk
106
+ await waitlist.client.POST(
107
+ "/v1/workspaces/{workspace_id}/waitlists/{waitlist_id}/entries/bulk",
108
+ { params: { ... }, body: { ids: [...], action: "approve" } },
109
+ );
110
+
111
+ // Send an invite (e.g. into an Auth app)
112
+ await waitlist.client.POST(
113
+ "/v1/workspaces/{workspace_id}/waitlists/{waitlist_id}/entries/{entry_id}/invite-to-app",
114
+ { params: { ... }, body: { /* app + role + invite_template */ } },
115
+ );
116
+
117
+ // Export to CSV
118
+ await waitlist.client.GET(
119
+ "/v1/workspaces/{workspace_id}/waitlists/{waitlist_id}/entries/export.csv",
120
+ { ... },
121
+ );
122
+ ```
123
+
124
+ ### Variants (A/B/n landing pages)
125
+
126
+ Variants split two ways: `kind: "ab"` for split-traffic A/B/n tests, or `kind: "locale"` for per-locale copy switching. Pick one; the body shape is `{ kind, slug, locale? }`.
127
+
128
+ ```ts
129
+ // A/B variant
130
+ await waitlist.client.POST(
131
+ "/v1/workspaces/{workspace_id}/waitlists/{waitlist_id}/variants",
132
+ {
133
+ params: { ... },
134
+ body: { kind: "ab", slug: "headline-b" },
135
+ },
136
+ );
137
+
138
+ // Locale variant
139
+ await waitlist.client.POST(
140
+ "/v1/workspaces/{workspace_id}/waitlists/{waitlist_id}/variants",
141
+ {
142
+ params: { ... },
143
+ body: { kind: "locale", slug: "pt-br", locale: "pt-BR" },
144
+ },
145
+ );
146
+ ```
147
+
148
+ Front-end picks up the active variant from `GET /v1/waitlists/:workspace_slug/:waitlist_slug` and round-trips its id back in the entry submission via the `variant_id` field — Waitlist computes per-variant conversion without a separate impressions table.
149
+
150
+ ### Analytics
151
+
152
+ ```ts
153
+ // Conversion + per-variant counts
154
+ await waitlist.client.GET(
155
+ "/v1/workspaces/{workspace_id}/waitlists/{waitlist_id}/analytics",
156
+ { ... },
157
+ );
158
+
159
+ // Timeseries — `since` is an ISO-8601 timestamp. There are no
160
+ // `bucket` / `lookback` query params.
161
+ await waitlist.client.GET(
162
+ "/v1/workspaces/{workspace_id}/waitlists/{waitlist_id}/analytics/timeline",
163
+ {
164
+ params: {
165
+ path: { ... },
166
+ query: { since: "2026-05-01T00:00:00Z" },
167
+ },
168
+ },
169
+ );
170
+ ```
171
+
172
+ ### Webhooks
173
+
174
+ ```ts
175
+ // Subscribe to entry.created / entry.approved / entry.rejected
176
+ await waitlist.client.POST(
177
+ "/v1/workspaces/{workspace_id}/webhooks",
178
+ { params: { ... }, body: { url: "https://yourapp.com/hooks/waitlist", events: ["entry.created"] } },
179
+ );
180
+
181
+ // Rotate the signing secret without disabling the webhook
182
+ await waitlist.client.POST(
183
+ "/v1/workspaces/{workspace_id}/webhooks/{id}/rotate-secret",
184
+ { ... },
185
+ );
186
+
187
+ // Replay a delivery from history
188
+ await waitlist.client.GET(
189
+ "/v1/workspaces/{workspace_id}/webhooks/{id}/deliveries",
190
+ { ... },
191
+ );
192
+ ```
193
+
194
+ ## How this SDK is built
195
+
196
+ Generated from the live OpenAPI spec at `https://api.waitlist.productcraft.co/docs-json` via [`openapi-typescript`](https://openapi-ts.dev/) + [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/). The nightly `spec-refresh` workflow opens a PR whenever the spec changes.
197
+
198
+ ## License
199
+
200
+ [MIT](https://github.com/clauderanelagh/productcraft-node/blob/main/LICENSE).
package/dist/index.cjs ADDED
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var core = require('@productcraft/core');
4
+
5
+ // src/index.ts
6
+ var Waitlist = class {
7
+ /** The underlying typed client. v0 surface — every endpoint reachable. */
8
+ client;
9
+ constructor(config = {}) {
10
+ this.client = core.makeClient(core.PC_BASE_URL.waitlist, config);
11
+ }
12
+ };
13
+
14
+ exports.Waitlist = Waitlist;
15
+ //# sourceMappingURL=index.cjs.map
16
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["makeClient","PC_BASE_URL"],"mappings":";;;;;AASO,IAAM,WAAN,MAAe;AAAA;AAAA,EAEJ,MAAA;AAAA,EAEhB,WAAA,CAAY,MAAA,GAAyB,EAAC,EAAG;AACvC,IAAA,IAAA,CAAK,MAAA,GAASA,eAAA,CAAkBC,gBAAA,CAAY,QAAA,EAAU,MAAM,CAAA;AAAA,EAC9D;AACF","file":"index.cjs","sourcesContent":["import type { paths } from \"./_generated.js\";\nimport { makeClient, PC_BASE_URL, type PCClientConfig } from \"@productcraft/core\";\n\n/**\n * Waitlist — typed `openapi-fetch` client for every endpoint in\n * `Specs/waitlist.json`. Reach for `client.GET(\"/v1/...\")` or\n * `client.POST(...)`; request / response types come from the\n * generated `paths` interface.\n */\nexport class Waitlist {\n /** The underlying typed client. v0 surface — every endpoint reachable. */\n public readonly client: ReturnType<typeof makeClient<paths>>;\n\n constructor(config: PCClientConfig = {}) {\n this.client = makeClient<paths>(PC_BASE_URL.waitlist, config);\n }\n}\n\nexport type { paths } from \"./_generated.js\";\n"]}