@productcraft/core 0.0.5 → 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/README.md +1 -1
- package/dist/index.cjs +7 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Shared transport + auth primitives for the ProductCraft Node.js SDKs.
|
|
4
4
|
|
|
5
|
-
You **don't install this directly**. It's a runtime dependency of every product SDK (`@productcraft/
|
|
5
|
+
You **don't install this directly**. It's a runtime dependency of every product SDK (`@productcraft/auth`, `@productcraft/mail`, `@productcraft/waitlist`, `@productcraft/social`, `@productcraft/platform-auth`) plus the `productcraft` umbrella. Installing one of those pulls `@productcraft/core` along automatically.
|
|
6
6
|
|
|
7
7
|
## What it provides
|
|
8
8
|
|
package/dist/index.cjs
CHANGED
|
@@ -8,15 +8,14 @@ var createClient__default = /*#__PURE__*/_interopDefault(createClient);
|
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
var PC_BASE_URL = {
|
|
11
|
-
// platformAuth
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// social.productcraft.co. Old hosts stay live as aliases.
|
|
11
|
+
// platformAuth is the platform identity layer (workspaces, PATs);
|
|
12
|
+
// it vacated api.auth so the customer-facing Auth product could
|
|
13
|
+
// take that host.
|
|
15
14
|
platformAuth: "https://api.platform-auth.productcraft.co",
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
auth: "https://api.auth.productcraft.co",
|
|
16
|
+
mail: "https://api.mail.productcraft.co",
|
|
17
|
+
waitlist: "https://api.waitlist.productcraft.co",
|
|
18
|
+
social: "https://social.productcraft.co"
|
|
20
19
|
};
|
|
21
20
|
function authMiddleware(auth) {
|
|
22
21
|
return {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["createClient"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["createClient"],"mappings":";;;;;;;;;AAgDO,IAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA,EAIzB,YAAA,EAAc,2CAAA;AAAA,EACd,IAAA,EAAM,kCAAA;AAAA,EACN,IAAA,EAAM,kCAAA;AAAA,EACN,QAAA,EAAU,sCAAA;AAAA,EACV,MAAA,EAAQ;AACV;AAMO,SAAS,eAAe,IAAA,EAAsC;AACnE,EAAA,OAAO;AAAA,IACL,MAAM,SAAA,CAAU,EAAE,OAAA,EAAQ,EAAG;AAC3B,MAAA,IAAI,CAAC,MAAM,OAAO,MAAA;AAClB,MAAA,QAAQ,KAAK,IAAA;AAAM,QACjB,KAAK,QAAA;AACH,UAAA,OAAA,CAAQ,QAAQ,GAAA,CAAI,eAAA,EAAiB,CAAA,OAAA,EAAU,IAAA,CAAK,GAAG,CAAA,CAAE,CAAA;AACzD,UAAA;AAAA,QACF,KAAK,QAAA;AACH,UAAA,OAAA,CAAQ,QAAQ,GAAA,CAAI,eAAA,EAAiB,CAAA,OAAA,EAAU,IAAA,CAAK,KAAK,CAAA,CAAE,CAAA;AAC3D,UAAA;AAAA,QACF,KAAK,QAAA;AACH,UAAA,OAAA,CAAQ,QAAQ,GAAA,CAAI,QAAA,EAAU,CAAA,WAAA,EAAc,IAAA,CAAK,KAAK,CAAA,CAAE,CAAA;AACxD,UAAA;AAAA;AAEJ,MAAA,OAAO,OAAA;AAAA,IACT;AAAA,GACF;AACF;AAQO,SAAS,UAAA,CACd,cAAA,EACA,MAAA,GAAyB,EAAC,EACV;AAChB,EAAA,MAAM,SAASA,6BAAA,CAAqB;AAAA,IAClC,OAAA,EAAS,OAAO,OAAA,IAAW,cAAA;AAAA,IAC3B,OAAO,MAAA,CAAO;AAAA,GACf,CAAA;AACD,EAAA,MAAA,CAAO,GAAA,CAAI,cAAA,CAAe,MAAA,CAAO,IAAI,CAAC,CAAA;AACtC,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["/**\n * Shared transport + auth plumbing used by every surface client.\n *\n * Each surface package (`@productcraft/auth`, `@productcraft/mail`,\n * ...) defines a thin class around `openapi-fetch` plus the generated\n * `paths` types from its own `_generated.d.ts`. The class delegates\n * wire I/O to `openapi-fetch`, but exposes a Stripe-style ergonomic\n * surface where callers reach for `pc.mail.messages.send(...)` rather\n * than the underlying `client.POST(\"/v1/...\")` shape.\n *\n * v0 ships only the underlying `client` (named `client` on each\n * surface) — every endpoint is reachable through it. Ergonomic\n * resource surfaces land in v0.1+ as we hand-roll them.\n */\n\nimport createClient, { type Client, type Middleware } from \"openapi-fetch\";\n\n/**\n * The auth credential the SDK presents to ProductCraft APIs.\n *\n * - `apiKey` — Platform API Key (`pcft_live_*`). Server-side only;\n * never embed in a shipped browser bundle.\n * - `bearer` — pre-resolved JWT (e.g. an Auth app-scoped EndUser\n * token your backend minted and shipped to the device).\n * - `cookie` — captured `auth_token` cookie value. Mostly useful in\n * dev / E2E tests where you've already signed in.\n */\nexport type PCAuth =\n | { type: \"apiKey\"; key: string }\n | { type: \"bearer\"; token: string }\n | { type: \"cookie\"; value: string };\n\nexport interface PCClientConfig {\n auth?: PCAuth;\n /** Override the prod base URL — useful for dev / staging. */\n baseUrl?: string;\n /** Custom fetch (e.g. node-fetch with retries, undici, ...). */\n fetch?: typeof fetch;\n}\n\n/**\n * Default prod base URL per surface.\n *\n * Keys use the rebranded product names (Auth, Mail, Waitlist, Social)\n * matching the package + class names since the 2026-07 SDK rename.\n * Prior releases (`@productcraft/heimdall` 0.x etc.) exposed the same\n * hosts under the old keys (heimdall/envoi/rally/agora).\n */\nexport const PC_BASE_URL = {\n // platformAuth is the platform identity layer (workspaces, PATs);\n // it vacated api.auth so the customer-facing Auth product could\n // take that host.\n platformAuth: \"https://api.platform-auth.productcraft.co\",\n auth: \"https://api.auth.productcraft.co\",\n mail: \"https://api.mail.productcraft.co\",\n waitlist: \"https://api.waitlist.productcraft.co\",\n social: \"https://social.productcraft.co\",\n} as const;\n\n/**\n * Build an `openapi-fetch` middleware that adds the configured auth\n * credential as a header on every outbound request.\n */\nexport function authMiddleware(auth: PCAuth | undefined): Middleware {\n return {\n async onRequest({ request }) {\n if (!auth) return undefined;\n switch (auth.type) {\n case \"apiKey\":\n request.headers.set(\"Authorization\", `Bearer ${auth.key}`);\n break;\n case \"bearer\":\n request.headers.set(\"Authorization\", `Bearer ${auth.token}`);\n break;\n case \"cookie\":\n request.headers.set(\"Cookie\", `auth_token=${auth.value}`);\n break;\n }\n return request;\n },\n };\n}\n\n/**\n * Construct an `openapi-fetch` client for a surface. Each surface\n * package calls this with its own generated `paths` type and default\n * base URL. The returned client is the v0 surface — every endpoint is\n * reachable through `client.GET(...)`, `client.POST(...)`, etc.\n */\nexport function makeClient<TPaths extends object>(\n defaultBaseUrl: string,\n config: PCClientConfig = {},\n): Client<TPaths> {\n const client = createClient<TPaths>({\n baseUrl: config.baseUrl ?? defaultBaseUrl,\n fetch: config.fetch,\n });\n client.use(authMiddleware(config.auth));\n return client;\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -3,11 +3,11 @@ import { Middleware, Client } from 'openapi-fetch';
|
|
|
3
3
|
/**
|
|
4
4
|
* Shared transport + auth plumbing used by every surface client.
|
|
5
5
|
*
|
|
6
|
-
* Each surface package (`@productcraft/
|
|
6
|
+
* Each surface package (`@productcraft/auth`, `@productcraft/mail`,
|
|
7
7
|
* ...) defines a thin class around `openapi-fetch` plus the generated
|
|
8
8
|
* `paths` types from its own `_generated.d.ts`. The class delegates
|
|
9
9
|
* wire I/O to `openapi-fetch`, but exposes a Stripe-style ergonomic
|
|
10
|
-
* surface where callers reach for `pc.
|
|
10
|
+
* surface where callers reach for `pc.mail.messages.send(...)` rather
|
|
11
11
|
* than the underlying `client.POST("/v1/...")` shape.
|
|
12
12
|
*
|
|
13
13
|
* v0 ships only the underlying `client` (named `client` on each
|
|
@@ -20,7 +20,7 @@ import { Middleware, Client } from 'openapi-fetch';
|
|
|
20
20
|
*
|
|
21
21
|
* - `apiKey` — Platform API Key (`pcft_live_*`). Server-side only;
|
|
22
22
|
* never embed in a shipped browser bundle.
|
|
23
|
-
* - `bearer` — pre-resolved JWT (e.g.
|
|
23
|
+
* - `bearer` — pre-resolved JWT (e.g. an Auth app-scoped EndUser
|
|
24
24
|
* token your backend minted and shipped to the device).
|
|
25
25
|
* - `cookie` — captured `auth_token` cookie value. Mostly useful in
|
|
26
26
|
* dev / E2E tests where you've already signed in.
|
|
@@ -45,18 +45,17 @@ interface PCClientConfig {
|
|
|
45
45
|
/**
|
|
46
46
|
* Default prod base URL per surface.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* the v1.0.0 public-API rename, so this stays a non-breaking retarget.
|
|
48
|
+
* Keys use the rebranded product names (Auth, Mail, Waitlist, Social)
|
|
49
|
+
* matching the package + class names since the 2026-07 SDK rename.
|
|
50
|
+
* Prior releases (`@productcraft/heimdall` 0.x etc.) exposed the same
|
|
51
|
+
* hosts under the old keys (heimdall/envoi/rally/agora).
|
|
53
52
|
*/
|
|
54
53
|
declare const PC_BASE_URL: {
|
|
55
54
|
readonly platformAuth: "https://api.platform-auth.productcraft.co";
|
|
56
|
-
readonly
|
|
57
|
-
readonly
|
|
58
|
-
readonly
|
|
59
|
-
readonly
|
|
55
|
+
readonly auth: "https://api.auth.productcraft.co";
|
|
56
|
+
readonly mail: "https://api.mail.productcraft.co";
|
|
57
|
+
readonly waitlist: "https://api.waitlist.productcraft.co";
|
|
58
|
+
readonly social: "https://social.productcraft.co";
|
|
60
59
|
};
|
|
61
60
|
/**
|
|
62
61
|
* Build an `openapi-fetch` middleware that adds the configured auth
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import { Middleware, Client } from 'openapi-fetch';
|
|
|
3
3
|
/**
|
|
4
4
|
* Shared transport + auth plumbing used by every surface client.
|
|
5
5
|
*
|
|
6
|
-
* Each surface package (`@productcraft/
|
|
6
|
+
* Each surface package (`@productcraft/auth`, `@productcraft/mail`,
|
|
7
7
|
* ...) defines a thin class around `openapi-fetch` plus the generated
|
|
8
8
|
* `paths` types from its own `_generated.d.ts`. The class delegates
|
|
9
9
|
* wire I/O to `openapi-fetch`, but exposes a Stripe-style ergonomic
|
|
10
|
-
* surface where callers reach for `pc.
|
|
10
|
+
* surface where callers reach for `pc.mail.messages.send(...)` rather
|
|
11
11
|
* than the underlying `client.POST("/v1/...")` shape.
|
|
12
12
|
*
|
|
13
13
|
* v0 ships only the underlying `client` (named `client` on each
|
|
@@ -20,7 +20,7 @@ import { Middleware, Client } from 'openapi-fetch';
|
|
|
20
20
|
*
|
|
21
21
|
* - `apiKey` — Platform API Key (`pcft_live_*`). Server-side only;
|
|
22
22
|
* never embed in a shipped browser bundle.
|
|
23
|
-
* - `bearer` — pre-resolved JWT (e.g.
|
|
23
|
+
* - `bearer` — pre-resolved JWT (e.g. an Auth app-scoped EndUser
|
|
24
24
|
* token your backend minted and shipped to the device).
|
|
25
25
|
* - `cookie` — captured `auth_token` cookie value. Mostly useful in
|
|
26
26
|
* dev / E2E tests where you've already signed in.
|
|
@@ -45,18 +45,17 @@ interface PCClientConfig {
|
|
|
45
45
|
/**
|
|
46
46
|
* Default prod base URL per surface.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* the v1.0.0 public-API rename, so this stays a non-breaking retarget.
|
|
48
|
+
* Keys use the rebranded product names (Auth, Mail, Waitlist, Social)
|
|
49
|
+
* matching the package + class names since the 2026-07 SDK rename.
|
|
50
|
+
* Prior releases (`@productcraft/heimdall` 0.x etc.) exposed the same
|
|
51
|
+
* hosts under the old keys (heimdall/envoi/rally/agora).
|
|
53
52
|
*/
|
|
54
53
|
declare const PC_BASE_URL: {
|
|
55
54
|
readonly platformAuth: "https://api.platform-auth.productcraft.co";
|
|
56
|
-
readonly
|
|
57
|
-
readonly
|
|
58
|
-
readonly
|
|
59
|
-
readonly
|
|
55
|
+
readonly auth: "https://api.auth.productcraft.co";
|
|
56
|
+
readonly mail: "https://api.mail.productcraft.co";
|
|
57
|
+
readonly waitlist: "https://api.waitlist.productcraft.co";
|
|
58
|
+
readonly social: "https://social.productcraft.co";
|
|
60
59
|
};
|
|
61
60
|
/**
|
|
62
61
|
* Build an `openapi-fetch` middleware that adds the configured auth
|
package/dist/index.js
CHANGED
|
@@ -2,15 +2,14 @@ import createClient from 'openapi-fetch';
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
var PC_BASE_URL = {
|
|
5
|
-
// platformAuth
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// social.productcraft.co. Old hosts stay live as aliases.
|
|
5
|
+
// platformAuth is the platform identity layer (workspaces, PATs);
|
|
6
|
+
// it vacated api.auth so the customer-facing Auth product could
|
|
7
|
+
// take that host.
|
|
9
8
|
platformAuth: "https://api.platform-auth.productcraft.co",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
auth: "https://api.auth.productcraft.co",
|
|
10
|
+
mail: "https://api.mail.productcraft.co",
|
|
11
|
+
waitlist: "https://api.waitlist.productcraft.co",
|
|
12
|
+
social: "https://social.productcraft.co"
|
|
14
13
|
};
|
|
15
14
|
function authMiddleware(auth) {
|
|
16
15
|
return {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAgDO,IAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA,EAIzB,YAAA,EAAc,2CAAA;AAAA,EACd,IAAA,EAAM,kCAAA;AAAA,EACN,IAAA,EAAM,kCAAA;AAAA,EACN,QAAA,EAAU,sCAAA;AAAA,EACV,MAAA,EAAQ;AACV;AAMO,SAAS,eAAe,IAAA,EAAsC;AACnE,EAAA,OAAO;AAAA,IACL,MAAM,SAAA,CAAU,EAAE,OAAA,EAAQ,EAAG;AAC3B,MAAA,IAAI,CAAC,MAAM,OAAO,MAAA;AAClB,MAAA,QAAQ,KAAK,IAAA;AAAM,QACjB,KAAK,QAAA;AACH,UAAA,OAAA,CAAQ,QAAQ,GAAA,CAAI,eAAA,EAAiB,CAAA,OAAA,EAAU,IAAA,CAAK,GAAG,CAAA,CAAE,CAAA;AACzD,UAAA;AAAA,QACF,KAAK,QAAA;AACH,UAAA,OAAA,CAAQ,QAAQ,GAAA,CAAI,eAAA,EAAiB,CAAA,OAAA,EAAU,IAAA,CAAK,KAAK,CAAA,CAAE,CAAA;AAC3D,UAAA;AAAA,QACF,KAAK,QAAA;AACH,UAAA,OAAA,CAAQ,QAAQ,GAAA,CAAI,QAAA,EAAU,CAAA,WAAA,EAAc,IAAA,CAAK,KAAK,CAAA,CAAE,CAAA;AACxD,UAAA;AAAA;AAEJ,MAAA,OAAO,OAAA;AAAA,IACT;AAAA,GACF;AACF;AAQO,SAAS,UAAA,CACd,cAAA,EACA,MAAA,GAAyB,EAAC,EACV;AAChB,EAAA,MAAM,SAAS,YAAA,CAAqB;AAAA,IAClC,OAAA,EAAS,OAAO,OAAA,IAAW,cAAA;AAAA,IAC3B,OAAO,MAAA,CAAO;AAAA,GACf,CAAA;AACD,EAAA,MAAA,CAAO,GAAA,CAAI,cAAA,CAAe,MAAA,CAAO,IAAI,CAAC,CAAA;AACtC,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["/**\n * Shared transport + auth plumbing used by every surface client.\n *\n * Each surface package (`@productcraft/auth`, `@productcraft/mail`,\n * ...) defines a thin class around `openapi-fetch` plus the generated\n * `paths` types from its own `_generated.d.ts`. The class delegates\n * wire I/O to `openapi-fetch`, but exposes a Stripe-style ergonomic\n * surface where callers reach for `pc.mail.messages.send(...)` rather\n * than the underlying `client.POST(\"/v1/...\")` shape.\n *\n * v0 ships only the underlying `client` (named `client` on each\n * surface) — every endpoint is reachable through it. Ergonomic\n * resource surfaces land in v0.1+ as we hand-roll them.\n */\n\nimport createClient, { type Client, type Middleware } from \"openapi-fetch\";\n\n/**\n * The auth credential the SDK presents to ProductCraft APIs.\n *\n * - `apiKey` — Platform API Key (`pcft_live_*`). Server-side only;\n * never embed in a shipped browser bundle.\n * - `bearer` — pre-resolved JWT (e.g. an Auth app-scoped EndUser\n * token your backend minted and shipped to the device).\n * - `cookie` — captured `auth_token` cookie value. Mostly useful in\n * dev / E2E tests where you've already signed in.\n */\nexport type PCAuth =\n | { type: \"apiKey\"; key: string }\n | { type: \"bearer\"; token: string }\n | { type: \"cookie\"; value: string };\n\nexport interface PCClientConfig {\n auth?: PCAuth;\n /** Override the prod base URL — useful for dev / staging. */\n baseUrl?: string;\n /** Custom fetch (e.g. node-fetch with retries, undici, ...). */\n fetch?: typeof fetch;\n}\n\n/**\n * Default prod base URL per surface.\n *\n * Keys use the rebranded product names (Auth, Mail, Waitlist, Social)\n * matching the package + class names since the 2026-07 SDK rename.\n * Prior releases (`@productcraft/heimdall` 0.x etc.) exposed the same\n * hosts under the old keys (heimdall/envoi/rally/agora).\n */\nexport const PC_BASE_URL = {\n // platformAuth is the platform identity layer (workspaces, PATs);\n // it vacated api.auth so the customer-facing Auth product could\n // take that host.\n platformAuth: \"https://api.platform-auth.productcraft.co\",\n auth: \"https://api.auth.productcraft.co\",\n mail: \"https://api.mail.productcraft.co\",\n waitlist: \"https://api.waitlist.productcraft.co\",\n social: \"https://social.productcraft.co\",\n} as const;\n\n/**\n * Build an `openapi-fetch` middleware that adds the configured auth\n * credential as a header on every outbound request.\n */\nexport function authMiddleware(auth: PCAuth | undefined): Middleware {\n return {\n async onRequest({ request }) {\n if (!auth) return undefined;\n switch (auth.type) {\n case \"apiKey\":\n request.headers.set(\"Authorization\", `Bearer ${auth.key}`);\n break;\n case \"bearer\":\n request.headers.set(\"Authorization\", `Bearer ${auth.token}`);\n break;\n case \"cookie\":\n request.headers.set(\"Cookie\", `auth_token=${auth.value}`);\n break;\n }\n return request;\n },\n };\n}\n\n/**\n * Construct an `openapi-fetch` client for a surface. Each surface\n * package calls this with its own generated `paths` type and default\n * base URL. The returned client is the v0 surface — every endpoint is\n * reachable through `client.GET(...)`, `client.POST(...)`, etc.\n */\nexport function makeClient<TPaths extends object>(\n defaultBaseUrl: string,\n config: PCClientConfig = {},\n): Client<TPaths> {\n const client = createClient<TPaths>({\n baseUrl: config.baseUrl ?? defaultBaseUrl,\n fetch: config.fetch,\n });\n client.use(authMiddleware(config.auth));\n return client;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@productcraft/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Shared transport, auth, and config primitives for the ProductCraft SDKs. Depended on by every per-surface package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -34,8 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/clauderanelagh/productcraft-node/tree/main/packages/core",
|
|
36
36
|
"publishConfig": {
|
|
37
|
-
"access": "public"
|
|
38
|
-
"provenance": true
|
|
37
|
+
"access": "public"
|
|
39
38
|
},
|
|
40
39
|
"dependencies": {
|
|
41
40
|
"openapi-fetch": "^0.13.0"
|