@productcraft/core 0.0.3 → 0.0.5
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/dist/index.cjs +8 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8,11 +8,15 @@ var createClient__default = /*#__PURE__*/_interopDefault(createClient);
|
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
var PC_BASE_URL = {
|
|
11
|
-
platformAuth
|
|
12
|
-
|
|
11
|
+
// platformAuth moved api.auth → api.platform-auth (the platform
|
|
12
|
+
// identity layer vacated api.auth so the customer-facing Auth product
|
|
13
|
+
// could take it). heimdall (the Auth product) → api.auth; agora →
|
|
14
|
+
// social.productcraft.co. Old hosts stay live as aliases.
|
|
15
|
+
platformAuth: "https://api.platform-auth.productcraft.co",
|
|
16
|
+
heimdall: "https://api.auth.productcraft.co",
|
|
13
17
|
envoi: "https://api.mail.productcraft.co",
|
|
14
|
-
rally: "https://api.
|
|
15
|
-
agora: "https://
|
|
18
|
+
rally: "https://api.waitlist.productcraft.co",
|
|
19
|
+
agora: "https://social.productcraft.co"
|
|
16
20
|
};
|
|
17
21
|
function authMiddleware(auth) {
|
|
18
22
|
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":";;;;;;;;;AAiDO,IAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,YAAA,EAAc,2CAAA;AAAA,EACd,QAAA,EAAU,kCAAA;AAAA,EACV,KAAA,EAAO,kCAAA;AAAA,EACP,KAAA,EAAO,sCAAA;AAAA,EACP,KAAA,EAAO;AACT;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/heimdall`, `@productcraft/envoi`,\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.envoi.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. a Heimdall 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 * Pointed at the renamed services (Rally→Waitlist, Agora→Feed,\n * Heimdall→users) so the SDK targets the canonical new domains and the\n * old aliases (api.rally, agora.*, api.heimdall) can eventually retire.\n * The surface KEYS (rally/agora/heimdall) are intentionally kept until\n * the v1.0.0 public-API rename, so this stays a non-breaking retarget.\n */\nexport const PC_BASE_URL = {\n // platformAuth moved api.auth → api.platform-auth (the platform\n // identity layer vacated api.auth so the customer-facing Auth product\n // could take it). heimdall (the Auth product) → api.auth; agora →\n // social.productcraft.co. Old hosts stay live as aliases.\n platformAuth: \"https://api.platform-auth.productcraft.co\",\n heimdall: \"https://api.auth.productcraft.co\",\n envoi: \"https://api.mail.productcraft.co\",\n rally: \"https://api.waitlist.productcraft.co\",\n agora: \"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
|
@@ -42,13 +42,21 @@ interface PCClientConfig {
|
|
|
42
42
|
/** Custom fetch (e.g. node-fetch with retries, undici, ...). */
|
|
43
43
|
fetch?: typeof fetch;
|
|
44
44
|
}
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Default prod base URL per surface.
|
|
47
|
+
*
|
|
48
|
+
* Pointed at the renamed services (Rally→Waitlist, Agora→Feed,
|
|
49
|
+
* Heimdall→users) so the SDK targets the canonical new domains and the
|
|
50
|
+
* old aliases (api.rally, agora.*, api.heimdall) can eventually retire.
|
|
51
|
+
* The surface KEYS (rally/agora/heimdall) are intentionally kept until
|
|
52
|
+
* the v1.0.0 public-API rename, so this stays a non-breaking retarget.
|
|
53
|
+
*/
|
|
46
54
|
declare const PC_BASE_URL: {
|
|
47
|
-
readonly platformAuth: "https://api.auth.productcraft.co";
|
|
48
|
-
readonly heimdall: "https://api.
|
|
55
|
+
readonly platformAuth: "https://api.platform-auth.productcraft.co";
|
|
56
|
+
readonly heimdall: "https://api.auth.productcraft.co";
|
|
49
57
|
readonly envoi: "https://api.mail.productcraft.co";
|
|
50
|
-
readonly rally: "https://api.
|
|
51
|
-
readonly agora: "https://
|
|
58
|
+
readonly rally: "https://api.waitlist.productcraft.co";
|
|
59
|
+
readonly agora: "https://social.productcraft.co";
|
|
52
60
|
};
|
|
53
61
|
/**
|
|
54
62
|
* Build an `openapi-fetch` middleware that adds the configured auth
|
package/dist/index.d.ts
CHANGED
|
@@ -42,13 +42,21 @@ interface PCClientConfig {
|
|
|
42
42
|
/** Custom fetch (e.g. node-fetch with retries, undici, ...). */
|
|
43
43
|
fetch?: typeof fetch;
|
|
44
44
|
}
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Default prod base URL per surface.
|
|
47
|
+
*
|
|
48
|
+
* Pointed at the renamed services (Rally→Waitlist, Agora→Feed,
|
|
49
|
+
* Heimdall→users) so the SDK targets the canonical new domains and the
|
|
50
|
+
* old aliases (api.rally, agora.*, api.heimdall) can eventually retire.
|
|
51
|
+
* The surface KEYS (rally/agora/heimdall) are intentionally kept until
|
|
52
|
+
* the v1.0.0 public-API rename, so this stays a non-breaking retarget.
|
|
53
|
+
*/
|
|
46
54
|
declare const PC_BASE_URL: {
|
|
47
|
-
readonly platformAuth: "https://api.auth.productcraft.co";
|
|
48
|
-
readonly heimdall: "https://api.
|
|
55
|
+
readonly platformAuth: "https://api.platform-auth.productcraft.co";
|
|
56
|
+
readonly heimdall: "https://api.auth.productcraft.co";
|
|
49
57
|
readonly envoi: "https://api.mail.productcraft.co";
|
|
50
|
-
readonly rally: "https://api.
|
|
51
|
-
readonly agora: "https://
|
|
58
|
+
readonly rally: "https://api.waitlist.productcraft.co";
|
|
59
|
+
readonly agora: "https://social.productcraft.co";
|
|
52
60
|
};
|
|
53
61
|
/**
|
|
54
62
|
* Build an `openapi-fetch` middleware that adds the configured auth
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,15 @@ import createClient from 'openapi-fetch';
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
var PC_BASE_URL = {
|
|
5
|
-
platformAuth
|
|
6
|
-
|
|
5
|
+
// platformAuth moved api.auth → api.platform-auth (the platform
|
|
6
|
+
// identity layer vacated api.auth so the customer-facing Auth product
|
|
7
|
+
// could take it). heimdall (the Auth product) → api.auth; agora →
|
|
8
|
+
// social.productcraft.co. Old hosts stay live as aliases.
|
|
9
|
+
platformAuth: "https://api.platform-auth.productcraft.co",
|
|
10
|
+
heimdall: "https://api.auth.productcraft.co",
|
|
7
11
|
envoi: "https://api.mail.productcraft.co",
|
|
8
|
-
rally: "https://api.
|
|
9
|
-
agora: "https://
|
|
12
|
+
rally: "https://api.waitlist.productcraft.co",
|
|
13
|
+
agora: "https://social.productcraft.co"
|
|
10
14
|
};
|
|
11
15
|
function authMiddleware(auth) {
|
|
12
16
|
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":";;;AAiDO,IAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,YAAA,EAAc,2CAAA;AAAA,EACd,QAAA,EAAU,kCAAA;AAAA,EACV,KAAA,EAAO,kCAAA;AAAA,EACP,KAAA,EAAO,sCAAA;AAAA,EACP,KAAA,EAAO;AACT;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/heimdall`, `@productcraft/envoi`,\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.envoi.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. a Heimdall 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 * Pointed at the renamed services (Rally→Waitlist, Agora→Feed,\n * Heimdall→users) so the SDK targets the canonical new domains and the\n * old aliases (api.rally, agora.*, api.heimdall) can eventually retire.\n * The surface KEYS (rally/agora/heimdall) are intentionally kept until\n * the v1.0.0 public-API rename, so this stays a non-breaking retarget.\n */\nexport const PC_BASE_URL = {\n // platformAuth moved api.auth → api.platform-auth (the platform\n // identity layer vacated api.auth so the customer-facing Auth product\n // could take it). heimdall (the Auth product) → api.auth; agora →\n // social.productcraft.co. Old hosts stay live as aliases.\n platformAuth: \"https://api.platform-auth.productcraft.co\",\n heimdall: \"https://api.auth.productcraft.co\",\n envoi: \"https://api.mail.productcraft.co\",\n rally: \"https://api.waitlist.productcraft.co\",\n agora: \"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