@purveyors/sdk 0.0.0 → 0.2.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/dist/index.js ADDED
@@ -0,0 +1,54 @@
1
+ // src/client.ts
2
+ import createClient from "openapi-fetch";
3
+ function createParchmentClient(options) {
4
+ const { baseUrl, token, fetch: fetchImpl } = options;
5
+ const client = createClient({
6
+ baseUrl,
7
+ fetch: fetchImpl,
8
+ headers: token ? { Authorization: `Bearer ${token}` } : void 0
9
+ });
10
+ return {
11
+ /** The underlying typed openapi-fetch client for direct path access. */
12
+ raw: client,
13
+ /** Liveness and service identity. */
14
+ health: () => client.GET("/health"),
15
+ /** Resolved principal and entitlements for the caller. */
16
+ me: () => client.GET("/v1/me"),
17
+ catalog: {
18
+ /** Catalog capabilities and visibility for the caller. */
19
+ access: () => client.GET("/v1/catalog/access"),
20
+ /** List public catalog coffees (paginated). */
21
+ list: (query) => client.GET("/v1/catalog", { params: { query } }),
22
+ /** Aggregate proof-coverage over the public catalog. */
23
+ proofCoverage: () => client.GET("/v1/catalog/proof-coverage"),
24
+ /** Find catalog coffees similar to a target coffee. */
25
+ similar: (id, query) => client.GET("/v1/catalog/{id}/similar", {
26
+ params: { path: { id }, query }
27
+ })
28
+ },
29
+ priceIndex: {
30
+ /** Parchment Price Index (aggregate snapshots). */
31
+ list: (query) => client.GET("/v1/price-index", { params: { query } })
32
+ },
33
+ procurement: {
34
+ briefs: {
35
+ /** List the caller's saved sourcing briefs. */
36
+ list: () => client.GET("/v1/procurement/briefs"),
37
+ /** Create a saved sourcing brief. */
38
+ create: (body) => client.POST("/v1/procurement/briefs", { body }),
39
+ /** Fetch one of the caller's sourcing briefs by id. */
40
+ get: (id) => client.GET("/v1/procurement/briefs/{id}", {
41
+ params: { path: { id } }
42
+ }),
43
+ /** Run a saved brief against the catalog (paginated matches). */
44
+ matches: (id, query) => client.GET("/v1/procurement/briefs/{id}/matches", {
45
+ params: { path: { id }, query }
46
+ })
47
+ }
48
+ }
49
+ };
50
+ }
51
+ export {
52
+ createParchmentClient
53
+ };
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import createClient, { type ClientOptions } from \"openapi-fetch\";\nimport type { components, paths } from \"./schema\";\n\nexport interface ParchmentClientOptions {\n /** Base URL of the Parchment API, e.g. https://api.purveyors.io */\n baseUrl: string;\n /**\n * Optional bearer token (a Supabase JWT or, later, an API key). Sent as\n * `Authorization: Bearer <token>`. Auth is resolved server-side against the\n * unified principal model; the SDK only forwards the credential.\n */\n token?: string;\n /** Override the fetch implementation (useful for tests or custom runtimes). */\n fetch?: ClientOptions[\"fetch\"];\n}\n\n/** Query parameters for {@link ParchmentClient.catalog.list}. */\nexport type CatalogListQuery = NonNullable<\n paths[\"/v1/catalog\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.similar}. */\nexport type CatalogSimilarQuery = NonNullable<\n paths[\"/v1/catalog/{id}/similar\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.priceIndex.list}. */\nexport type PriceIndexQuery = NonNullable<\n paths[\"/v1/price-index\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.procurement.briefs.matches}. */\nexport type BriefMatchesQuery = NonNullable<\n paths[\"/v1/procurement/briefs/{id}/matches\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Request body for {@link ParchmentClient.procurement.briefs.create}. */\nexport type SourcingBriefCreateRequest =\n components[\"schemas\"][\"SourcingBriefCreateRequest\"];\n\n/**\n * Create a typed Parchment API client.\n *\n * The generated core (openapi-fetch over the generated `paths` types) is the\n * contract truth; the named helpers below are the hand-maintained ergonomic\n * layer and grow as endpoints land. `raw` always exposes the underlying typed\n * client for direct path access to anything not yet wrapped.\n */\nexport function createParchmentClient(options: ParchmentClientOptions) {\n const { baseUrl, token, fetch: fetchImpl } = options;\n\n const client = createClient<paths>({\n baseUrl,\n fetch: fetchImpl,\n headers: token ? { Authorization: `Bearer ${token}` } : undefined,\n });\n\n return {\n /** The underlying typed openapi-fetch client for direct path access. */\n raw: client,\n /** Liveness and service identity. */\n health: () => client.GET(\"/health\"),\n /** Resolved principal and entitlements for the caller. */\n me: () => client.GET(\"/v1/me\"),\n catalog: {\n /** Catalog capabilities and visibility for the caller. */\n access: () => client.GET(\"/v1/catalog/access\"),\n /** List public catalog coffees (paginated). */\n list: (query?: CatalogListQuery) =>\n client.GET(\"/v1/catalog\", { params: { query } }),\n /** Aggregate proof-coverage over the public catalog. */\n proofCoverage: () => client.GET(\"/v1/catalog/proof-coverage\"),\n /** Find catalog coffees similar to a target coffee. */\n similar: (id: string, query?: CatalogSimilarQuery) =>\n client.GET(\"/v1/catalog/{id}/similar\", {\n params: { path: { id }, query },\n }),\n },\n priceIndex: {\n /** Parchment Price Index (aggregate snapshots). */\n list: (query?: PriceIndexQuery) =>\n client.GET(\"/v1/price-index\", { params: { query } }),\n },\n procurement: {\n briefs: {\n /** List the caller's saved sourcing briefs. */\n list: () => client.GET(\"/v1/procurement/briefs\"),\n /** Create a saved sourcing brief. */\n create: (body: SourcingBriefCreateRequest) =>\n client.POST(\"/v1/procurement/briefs\", { body }),\n /** Fetch one of the caller's sourcing briefs by id. */\n get: (id: string) =>\n client.GET(\"/v1/procurement/briefs/{id}\", {\n params: { path: { id } },\n }),\n /** Run a saved brief against the catalog (paginated matches). */\n matches: (id: string, query?: BriefMatchesQuery) =>\n client.GET(\"/v1/procurement/briefs/{id}/matches\", {\n params: { path: { id }, query },\n }),\n },\n },\n };\n}\n\nexport type ParchmentClient = ReturnType<typeof createParchmentClient>;\n"],"mappings":";AAAA,OAAO,kBAA0C;AA4C1C,SAAS,sBAAsB,SAAiC;AACrE,QAAM,EAAE,SAAS,OAAO,OAAO,UAAU,IAAI;AAE7C,QAAM,SAAS,aAAoB;AAAA,IACjC;AAAA,IACA,OA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
3
- "version": "0.0.0",
3
+ "version": "0.2.0",
4
4
  "description": "Typed client for the Purveyors Parchment API, generated from its OpenAPI spec.",
5
5
  "license": "MIT",
6
6
  "type": "module",