@productcraft/core 0.0.1
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 +49 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +66 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createClient = require('openapi-fetch');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var createClient__default = /*#__PURE__*/_interopDefault(createClient);
|
|
8
|
+
|
|
9
|
+
// src/index.ts
|
|
10
|
+
var PC_BASE_URL = {
|
|
11
|
+
platformAuth: "https://api.auth.productcraft.co",
|
|
12
|
+
heimdall: "https://api.heimdall.productcraft.co",
|
|
13
|
+
envoi: "https://api.mail.productcraft.co",
|
|
14
|
+
rally: "https://api.rally.productcraft.co",
|
|
15
|
+
agora: "https://agora.productcraft.co"
|
|
16
|
+
};
|
|
17
|
+
function authMiddleware(auth) {
|
|
18
|
+
return {
|
|
19
|
+
async onRequest({ request }) {
|
|
20
|
+
if (!auth) return void 0;
|
|
21
|
+
switch (auth.type) {
|
|
22
|
+
case "apiKey":
|
|
23
|
+
request.headers.set("Authorization", `Bearer ${auth.key}`);
|
|
24
|
+
break;
|
|
25
|
+
case "bearer":
|
|
26
|
+
request.headers.set("Authorization", `Bearer ${auth.token}`);
|
|
27
|
+
break;
|
|
28
|
+
case "cookie":
|
|
29
|
+
request.headers.set("Cookie", `auth_token=${auth.value}`);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
return request;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function makeClient(defaultBaseUrl, config = {}) {
|
|
37
|
+
const client = createClient__default.default({
|
|
38
|
+
baseUrl: config.baseUrl ?? defaultBaseUrl,
|
|
39
|
+
fetch: config.fetch
|
|
40
|
+
});
|
|
41
|
+
client.use(authMiddleware(config.auth));
|
|
42
|
+
return client;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.PC_BASE_URL = PC_BASE_URL;
|
|
46
|
+
exports.authMiddleware = authMiddleware;
|
|
47
|
+
exports.makeClient = makeClient;
|
|
48
|
+
//# sourceMappingURL=index.cjs.map
|
|
49
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["createClient"],"mappings":";;;;;;;;;AAyCO,IAAM,WAAA,GAAc;AAAA,EACzB,YAAA,EAAc,kCAAA;AAAA,EACd,QAAA,EAAU,sCAAA;AAAA,EACV,KAAA,EAAO,kCAAA;AAAA,EACP,KAAA,EAAO,mCAAA;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/** Default prod base URL per surface. */\nexport const PC_BASE_URL = {\n platformAuth: \"https://api.auth.productcraft.co\",\n heimdall: \"https://api.heimdall.productcraft.co\",\n envoi: \"https://api.mail.productcraft.co\",\n rally: \"https://api.rally.productcraft.co\",\n agora: \"https://agora.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
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Middleware, Client } from 'openapi-fetch';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared transport + auth plumbing used by every surface client.
|
|
5
|
+
*
|
|
6
|
+
* Each surface package (`@productcraft/heimdall`, `@productcraft/envoi`,
|
|
7
|
+
* ...) defines a thin class around `openapi-fetch` plus the generated
|
|
8
|
+
* `paths` types from its own `_generated.d.ts`. The class delegates
|
|
9
|
+
* wire I/O to `openapi-fetch`, but exposes a Stripe-style ergonomic
|
|
10
|
+
* surface where callers reach for `pc.envoi.messages.send(...)` rather
|
|
11
|
+
* than the underlying `client.POST("/v1/...")` shape.
|
|
12
|
+
*
|
|
13
|
+
* v0 ships only the underlying `client` (named `client` on each
|
|
14
|
+
* surface) — every endpoint is reachable through it. Ergonomic
|
|
15
|
+
* resource surfaces land in v0.1+ as we hand-roll them.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The auth credential the SDK presents to ProductCraft APIs.
|
|
20
|
+
*
|
|
21
|
+
* - `apiKey` — Platform API Key (`pcft_live_*`). Server-side only;
|
|
22
|
+
* never embed in a shipped browser bundle.
|
|
23
|
+
* - `bearer` — pre-resolved JWT (e.g. a Heimdall app-scoped EndUser
|
|
24
|
+
* token your backend minted and shipped to the device).
|
|
25
|
+
* - `cookie` — captured `auth_token` cookie value. Mostly useful in
|
|
26
|
+
* dev / E2E tests where you've already signed in.
|
|
27
|
+
*/
|
|
28
|
+
type PCAuth = {
|
|
29
|
+
type: "apiKey";
|
|
30
|
+
key: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: "bearer";
|
|
33
|
+
token: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "cookie";
|
|
36
|
+
value: string;
|
|
37
|
+
};
|
|
38
|
+
interface PCClientConfig {
|
|
39
|
+
auth?: PCAuth;
|
|
40
|
+
/** Override the prod base URL — useful for dev / staging. */
|
|
41
|
+
baseUrl?: string;
|
|
42
|
+
/** Custom fetch (e.g. node-fetch with retries, undici, ...). */
|
|
43
|
+
fetch?: typeof fetch;
|
|
44
|
+
}
|
|
45
|
+
/** Default prod base URL per surface. */
|
|
46
|
+
declare const PC_BASE_URL: {
|
|
47
|
+
readonly platformAuth: "https://api.auth.productcraft.co";
|
|
48
|
+
readonly heimdall: "https://api.heimdall.productcraft.co";
|
|
49
|
+
readonly envoi: "https://api.mail.productcraft.co";
|
|
50
|
+
readonly rally: "https://api.rally.productcraft.co";
|
|
51
|
+
readonly agora: "https://agora.productcraft.co";
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Build an `openapi-fetch` middleware that adds the configured auth
|
|
55
|
+
* credential as a header on every outbound request.
|
|
56
|
+
*/
|
|
57
|
+
declare function authMiddleware(auth: PCAuth | undefined): Middleware;
|
|
58
|
+
/**
|
|
59
|
+
* Construct an `openapi-fetch` client for a surface. Each surface
|
|
60
|
+
* package calls this with its own generated `paths` type and default
|
|
61
|
+
* base URL. The returned client is the v0 surface — every endpoint is
|
|
62
|
+
* reachable through `client.GET(...)`, `client.POST(...)`, etc.
|
|
63
|
+
*/
|
|
64
|
+
declare function makeClient<TPaths extends object>(defaultBaseUrl: string, config?: PCClientConfig): Client<TPaths>;
|
|
65
|
+
|
|
66
|
+
export { type PCAuth, type PCClientConfig, PC_BASE_URL, authMiddleware, makeClient };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Middleware, Client } from 'openapi-fetch';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared transport + auth plumbing used by every surface client.
|
|
5
|
+
*
|
|
6
|
+
* Each surface package (`@productcraft/heimdall`, `@productcraft/envoi`,
|
|
7
|
+
* ...) defines a thin class around `openapi-fetch` plus the generated
|
|
8
|
+
* `paths` types from its own `_generated.d.ts`. The class delegates
|
|
9
|
+
* wire I/O to `openapi-fetch`, but exposes a Stripe-style ergonomic
|
|
10
|
+
* surface where callers reach for `pc.envoi.messages.send(...)` rather
|
|
11
|
+
* than the underlying `client.POST("/v1/...")` shape.
|
|
12
|
+
*
|
|
13
|
+
* v0 ships only the underlying `client` (named `client` on each
|
|
14
|
+
* surface) — every endpoint is reachable through it. Ergonomic
|
|
15
|
+
* resource surfaces land in v0.1+ as we hand-roll them.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The auth credential the SDK presents to ProductCraft APIs.
|
|
20
|
+
*
|
|
21
|
+
* - `apiKey` — Platform API Key (`pcft_live_*`). Server-side only;
|
|
22
|
+
* never embed in a shipped browser bundle.
|
|
23
|
+
* - `bearer` — pre-resolved JWT (e.g. a Heimdall app-scoped EndUser
|
|
24
|
+
* token your backend minted and shipped to the device).
|
|
25
|
+
* - `cookie` — captured `auth_token` cookie value. Mostly useful in
|
|
26
|
+
* dev / E2E tests where you've already signed in.
|
|
27
|
+
*/
|
|
28
|
+
type PCAuth = {
|
|
29
|
+
type: "apiKey";
|
|
30
|
+
key: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: "bearer";
|
|
33
|
+
token: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "cookie";
|
|
36
|
+
value: string;
|
|
37
|
+
};
|
|
38
|
+
interface PCClientConfig {
|
|
39
|
+
auth?: PCAuth;
|
|
40
|
+
/** Override the prod base URL — useful for dev / staging. */
|
|
41
|
+
baseUrl?: string;
|
|
42
|
+
/** Custom fetch (e.g. node-fetch with retries, undici, ...). */
|
|
43
|
+
fetch?: typeof fetch;
|
|
44
|
+
}
|
|
45
|
+
/** Default prod base URL per surface. */
|
|
46
|
+
declare const PC_BASE_URL: {
|
|
47
|
+
readonly platformAuth: "https://api.auth.productcraft.co";
|
|
48
|
+
readonly heimdall: "https://api.heimdall.productcraft.co";
|
|
49
|
+
readonly envoi: "https://api.mail.productcraft.co";
|
|
50
|
+
readonly rally: "https://api.rally.productcraft.co";
|
|
51
|
+
readonly agora: "https://agora.productcraft.co";
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Build an `openapi-fetch` middleware that adds the configured auth
|
|
55
|
+
* credential as a header on every outbound request.
|
|
56
|
+
*/
|
|
57
|
+
declare function authMiddleware(auth: PCAuth | undefined): Middleware;
|
|
58
|
+
/**
|
|
59
|
+
* Construct an `openapi-fetch` client for a surface. Each surface
|
|
60
|
+
* package calls this with its own generated `paths` type and default
|
|
61
|
+
* base URL. The returned client is the v0 surface — every endpoint is
|
|
62
|
+
* reachable through `client.GET(...)`, `client.POST(...)`, etc.
|
|
63
|
+
*/
|
|
64
|
+
declare function makeClient<TPaths extends object>(defaultBaseUrl: string, config?: PCClientConfig): Client<TPaths>;
|
|
65
|
+
|
|
66
|
+
export { type PCAuth, type PCClientConfig, PC_BASE_URL, authMiddleware, makeClient };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import createClient from 'openapi-fetch';
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
var PC_BASE_URL = {
|
|
5
|
+
platformAuth: "https://api.auth.productcraft.co",
|
|
6
|
+
heimdall: "https://api.heimdall.productcraft.co",
|
|
7
|
+
envoi: "https://api.mail.productcraft.co",
|
|
8
|
+
rally: "https://api.rally.productcraft.co",
|
|
9
|
+
agora: "https://agora.productcraft.co"
|
|
10
|
+
};
|
|
11
|
+
function authMiddleware(auth) {
|
|
12
|
+
return {
|
|
13
|
+
async onRequest({ request }) {
|
|
14
|
+
if (!auth) return void 0;
|
|
15
|
+
switch (auth.type) {
|
|
16
|
+
case "apiKey":
|
|
17
|
+
request.headers.set("Authorization", `Bearer ${auth.key}`);
|
|
18
|
+
break;
|
|
19
|
+
case "bearer":
|
|
20
|
+
request.headers.set("Authorization", `Bearer ${auth.token}`);
|
|
21
|
+
break;
|
|
22
|
+
case "cookie":
|
|
23
|
+
request.headers.set("Cookie", `auth_token=${auth.value}`);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
return request;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function makeClient(defaultBaseUrl, config = {}) {
|
|
31
|
+
const client = createClient({
|
|
32
|
+
baseUrl: config.baseUrl ?? defaultBaseUrl,
|
|
33
|
+
fetch: config.fetch
|
|
34
|
+
});
|
|
35
|
+
client.use(authMiddleware(config.auth));
|
|
36
|
+
return client;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { PC_BASE_URL, authMiddleware, makeClient };
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAyCO,IAAM,WAAA,GAAc;AAAA,EACzB,YAAA,EAAc,kCAAA;AAAA,EACd,QAAA,EAAU,sCAAA;AAAA,EACV,KAAA,EAAO,kCAAA;AAAA,EACP,KAAA,EAAO,mCAAA;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/** Default prod base URL per surface. */\nexport const PC_BASE_URL = {\n platformAuth: \"https://api.auth.productcraft.co\",\n heimdall: \"https://api.heimdall.productcraft.co\",\n envoi: \"https://api.mail.productcraft.co\",\n rally: \"https://api.rally.productcraft.co\",\n agora: \"https://agora.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
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@productcraft/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Shared transport, auth, and config primitives for the ProductCraft SDKs. Depended on by every per-surface package.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/**",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"productcraft",
|
|
29
|
+
"sdk"
|
|
30
|
+
],
|
|
31
|
+
"author": "ProductCraft",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/clauderanelagh/productcraft-node.git",
|
|
36
|
+
"directory": "packages/core"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/clauderanelagh/productcraft-node/tree/main/packages/core",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"openapi-fetch": "^0.13.0"
|
|
44
|
+
}
|
|
45
|
+
}
|