@purveyors/sdk 0.3.0 → 0.5.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 CHANGED
@@ -14,6 +14,20 @@ function createParchmentClient(options) {
14
14
  health: () => client.GET("/health"),
15
15
  /** Resolved principal and entitlements for the caller. */
16
16
  me: () => client.GET("/v1/me"),
17
+ apiKeys: {
18
+ /** List API keys owned by the authenticated session user. */
19
+ list: () => client.GET("/v1/api-keys"),
20
+ /** Create an API key. The raw secret is returned only once. */
21
+ create: (body) => client.POST("/v1/api-keys", { body }),
22
+ /** Revoke an API key owned by the authenticated session user. */
23
+ revoke: (id) => client.DELETE("/v1/api-keys/{id}", {
24
+ params: { path: { id } }
25
+ }),
26
+ /** Rotate an API key and return the replacement secret once. */
27
+ rotate: (id) => client.POST("/v1/api-keys/{id}/rotate", {
28
+ params: { path: { id } }
29
+ })
30
+ },
17
31
  catalog: {
18
32
  /** Catalog capabilities and visibility for the caller. */
19
33
  access: () => client.GET("/v1/catalog/access"),
@@ -31,6 +45,28 @@ function createParchmentClient(options) {
31
45
  }),
32
46
  /** Live catalog price context by origin. */
33
47
  originPriceStats: (query) => client.GET("/v1/catalog/origin-price-stats", { params: { query } }),
48
+ /** Aggregate stats over the caller-visible catalog. */
49
+ stats: (query) => client.GET("/v1/catalog/stats", { params: { query } }),
50
+ /** Rank caller-visible catalog coffees by deterministic objectives. */
51
+ rank: (query, headers) => client.GET("/v1/catalog/rank", {
52
+ params: { query, header: headers }
53
+ }),
54
+ /** Rank premium catalog candidates by Purveyor Score. */
55
+ rankPremium: (query, headers) => client.GET("/v1/catalog/rank-premium", {
56
+ params: { query, header: headers }
57
+ }),
58
+ /** List supplier aggregates over caller-visible catalog coffees. */
59
+ suppliers: (query, headers) => client.GET("/v1/catalog/suppliers", {
60
+ params: { query, header: headers }
61
+ }),
62
+ /** Return aggregate detail for a supplier query. */
63
+ supplierDetail: (query, headers) => client.GET("/v1/catalog/suppliers/detail", {
64
+ params: { query, header: headers }
65
+ }),
66
+ /** Rank suppliers by catalog score and availability. */
67
+ supplierRank: (query, headers) => client.GET("/v1/catalog/suppliers/rank", {
68
+ params: { query, header: headers }
69
+ }),
34
70
  /** Aggregate proof-coverage over the public catalog. */
35
71
  proofCoverage: () => client.GET("/v1/catalog/proof-coverage"),
36
72
  /** Find catalog coffees similar to a target coffee. */
@@ -57,6 +93,101 @@ function createParchmentClient(options) {
57
93
  params: { path: { id }, query }
58
94
  })
59
95
  }
96
+ },
97
+ inventory: {
98
+ /** List the caller's own green-coffee inventory (owner-scoped). */
99
+ list: (query) => client.GET("/v1/inventory", { params: { query } }),
100
+ /**
101
+ * Create an owner inventory lot. Requires a session or an owner-bound API
102
+ * key carrying the exact `inventory:write` scope. Pass `idempotencyKey`
103
+ * to make retries safe: the same key replays the original result, and a
104
+ * concurrent duplicate gets 409 while the first is in flight.
105
+ */
106
+ create: (body, options2) => client.POST("/v1/inventory", {
107
+ body,
108
+ params: options2?.idempotencyKey ? { header: { "idempotency-key": options2.idempotencyKey } } : void 0
109
+ }),
110
+ /**
111
+ * Update one of the caller's own inventory rows. Pass `ifMatch` (the
112
+ * row's `last_updated`) to enable optimistic concurrency (409 on mismatch).
113
+ */
114
+ update: (id, body, options2) => client.PATCH("/v1/inventory/{id}", {
115
+ params: {
116
+ path: { id },
117
+ header: options2?.ifMatch ? { "if-match": options2.ifMatch } : void 0
118
+ },
119
+ body
120
+ }),
121
+ /**
122
+ * Delete one of the caller's own inventory rows. Returns 409 if dependent
123
+ * roast profiles or sales exist (no force-cascade).
124
+ */
125
+ delete: (id) => client.DELETE("/v1/inventory/{id}", { params: { path: { id } } })
126
+ },
127
+ roasts: {
128
+ /** List the caller's own roast profiles (owner-scoped). */
129
+ list: (query) => client.GET("/v1/roasts", { params: { query } }),
130
+ /**
131
+ * Fetch one of the caller's roast profiles by id, optionally with its
132
+ * temperature curve (`includeTemps`) and event markers (`includeEvents`).
133
+ */
134
+ get: (id, query) => client.GET("/v1/roasts/{id}", { params: { path: { id }, query } }),
135
+ /**
136
+ * Create an owner roast profile, optionally with nested temperature/event
137
+ * rows. Requires a session or an owner-bound API key carrying the exact
138
+ * `roast:write` scope. Pass `idempotencyKey` to make retries safe.
139
+ */
140
+ create: (body, options2) => client.POST("/v1/roasts", {
141
+ body,
142
+ params: options2?.idempotencyKey ? { header: { "idempotency-key": options2.idempotencyKey } } : void 0
143
+ }),
144
+ /**
145
+ * Update one of the caller's own roast profiles. Pass `ifMatch` (the
146
+ * row's `last_updated`) to enable optimistic concurrency (409 on mismatch).
147
+ */
148
+ update: (id, body, options2) => client.PATCH("/v1/roasts/{id}", {
149
+ params: {
150
+ path: { id },
151
+ header: options2?.ifMatch ? { "if-match": options2.ifMatch } : void 0
152
+ },
153
+ body
154
+ }),
155
+ /** Delete one of the caller's own roast profiles. */
156
+ delete: (id) => client.DELETE("/v1/roasts/{id}", { params: { path: { id } } }),
157
+ /**
158
+ * Create a roast profile from an Artisan `.alog` file against one of the
159
+ * caller's green-coffee lots, persisting the imported curve, events, and
160
+ * an artisan_import_log entry atomically. Requires a session or an
161
+ * owner-bound API key carrying the exact `roast:write` scope. Pass
162
+ * `idempotencyKey` to make retries safe.
163
+ */
164
+ import: (body, options2) => client.POST("/v1/roasts/imports", {
165
+ body,
166
+ params: options2?.idempotencyKey ? { header: { "idempotency-key": options2.idempotencyKey } } : void 0
167
+ }),
168
+ /**
169
+ * Replace the Artisan import data on one of the caller's existing roasts,
170
+ * re-deriving its curve, events, and computed metrics while preserving the
171
+ * roast's identity. Pass `ifMatch` (the roast's `last_updated`) to enable
172
+ * optimistic concurrency (409 on mismatch).
173
+ */
174
+ replaceArtisanImport: (id, body, options2) => client.PUT("/v1/roasts/{id}/artisan-import", {
175
+ params: {
176
+ path: { id },
177
+ header: options2?.ifMatch ? { "if-match": options2.ifMatch } : void 0
178
+ },
179
+ body
180
+ })
181
+ },
182
+ sales: {
183
+ /** List the caller's own sales (owner-scoped). */
184
+ list: (query) => client.GET("/v1/sales", { params: { query } })
185
+ },
186
+ tasting: {
187
+ /** Fetch supplier notes plus the caller's own latest tasting notes. */
188
+ get: (catalogId, query) => client.GET("/v1/tasting/{catalogId}", {
189
+ params: { path: { catalogId }, query }
190
+ })
60
191
  }
61
192
  };
62
193
  }
package/dist/index.js.map CHANGED
@@ -1 +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.facets}. */\nexport type CatalogFacetsQuery = NonNullable<\n paths[\"/v1/catalog/facets\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/**\n * Optional headers for {@link ParchmentClient.catalog.list}, notably the\n * RFC 7240 `Prefer: handling=lenient|strict` override (PADR-0013 §7). Sending\n * `handling=lenient` opts a strict caller (API key or bearer-session JWT) back\n * into strip-with-notice degradation instead of a 401/403 hard-deny.\n */\nexport type CatalogListHeaders = NonNullable<\n paths[\"/v1/catalog\"][\"get\"][\"parameters\"][\"header\"]\n>;\n/** Optional headers for {@link ParchmentClient.catalog.facets}; see {@link CatalogListHeaders}. */\nexport type CatalogFacetsHeaders = NonNullable<\n paths[\"/v1/catalog/facets\"][\"get\"][\"parameters\"][\"header\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.originPriceStats}. */\nexport type CatalogOriginPriceStatsQuery = NonNullable<\n paths[\"/v1/catalog/origin-price-stats\"][\"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 /**\n * List public catalog coffees (paginated). Pass `headers` to send the\n * `Prefer: handling=lenient|strict` override (see {@link CatalogListHeaders}).\n */\n list: (query?: CatalogListQuery, headers?: CatalogListHeaders) =>\n client.GET(\"/v1/catalog\", { params: { query, header: headers } }),\n /**\n * Catalog filter metadata and counted facets. Pass `headers` to send the\n * `Prefer: handling=lenient|strict` override (see {@link CatalogFacetsHeaders}).\n */\n facets: (query?: CatalogFacetsQuery, headers?: CatalogFacetsHeaders) =>\n client.GET(\"/v1/catalog/facets\", {\n params: { query, header: headers },\n }),\n /** Live catalog price context by origin. */\n originPriceStats: (query?: CatalogOriginPriceStatsQuery) =>\n client.GET(\"/v1/catalog/origin-price-stats\", { 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;AAiE1C,SAAS,sBAAsB,SAAiC;AACrE,QAAM,EAAE,SAAS,OAAO,OAAO,UAAU,IAAI;AAE7C,QAAM,SAAS,aAAoB;AAAA,IACjC;AAAA,IACA,OAAO;AAAA,IACP,SAAS,QAAQ,EAAE,eAAe,UAAU,KAAK,GAAG,IAAI;AAAA,EAC1D,CAAC;AAED,SAAO;AAAA;AAAA,IAEL,KAAK;AAA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,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM;AAAA,QAChC,CAAC;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
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.facets}. */\nexport type CatalogFacetsQuery = NonNullable<\n paths[\"/v1/catalog/facets\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/**\n * Optional headers for {@link ParchmentClient.catalog.list}, notably the\n * RFC 7240 `Prefer: handling=lenient|strict` override (PADR-0013 §7). Sending\n * `handling=lenient` opts a strict caller (API key or bearer-session JWT) back\n * into strip-with-notice degradation instead of a 401/403 hard-deny.\n */\nexport type CatalogListHeaders = NonNullable<\n paths[\"/v1/catalog\"][\"get\"][\"parameters\"][\"header\"]\n>;\n/** Optional headers for {@link ParchmentClient.catalog.facets}; see {@link CatalogListHeaders}. */\nexport type CatalogFacetsHeaders = NonNullable<\n paths[\"/v1/catalog/facets\"][\"get\"][\"parameters\"][\"header\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.originPriceStats}. */\nexport type CatalogOriginPriceStatsQuery = NonNullable<\n paths[\"/v1/catalog/origin-price-stats\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.stats}. */\nexport type CatalogStatsQuery = NonNullable<\n paths[\"/v1/catalog/stats\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.rank}. */\nexport type CatalogRankQuery = NonNullable<\n paths[\"/v1/catalog/rank\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.rankPremium}. */\nexport type CatalogRankPremiumQuery = NonNullable<\n paths[\"/v1/catalog/rank-premium\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.suppliers}. */\nexport type CatalogSuppliersQuery = NonNullable<\n paths[\"/v1/catalog/suppliers\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.supplierDetail}. */\nexport type CatalogSupplierDetailQuery = NonNullable<\n paths[\"/v1/catalog/suppliers/detail\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.supplierRank}. */\nexport type CatalogSupplierRankQuery = NonNullable<\n paths[\"/v1/catalog/suppliers/rank\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Optional headers for ranking endpoints; see {@link CatalogListHeaders}. */\nexport type CatalogRankHeaders = NonNullable<\n paths[\"/v1/catalog/rank\"][\"get\"][\"parameters\"][\"header\"]\n>;\n/** Optional headers for premium ranking endpoints; see {@link CatalogListHeaders}. */\nexport type CatalogRankPremiumHeaders = NonNullable<\n paths[\"/v1/catalog/rank-premium\"][\"get\"][\"parameters\"][\"header\"]\n>;\n/** Optional headers for supplier aggregate endpoints; see {@link CatalogListHeaders}. */\nexport type CatalogSupplierHeaders = NonNullable<\n paths[\"/v1/catalog/suppliers\"][\"get\"][\"parameters\"][\"header\"]\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/** Query parameters for {@link ParchmentClient.inventory.list}. */\nexport type InventoryListQuery = NonNullable<\n paths[\"/v1/inventory\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Request body for {@link ParchmentClient.inventory.create}. */\nexport type InventoryCreateRequest = NonNullable<\n paths[\"/v1/inventory\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n/** Request body for {@link ParchmentClient.inventory.update}. */\nexport type InventoryUpdateRequest = NonNullable<\n paths[\"/v1/inventory/{id}\"][\"patch\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n/** Query parameters for {@link ParchmentClient.roasts.list}. */\nexport type RoastListQuery = NonNullable<\n paths[\"/v1/roasts\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.roasts.get}. */\nexport type RoastGetQuery = NonNullable<\n paths[\"/v1/roasts/{id}\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Request body for {@link ParchmentClient.roasts.create}. */\nexport type RoastCreateRequest = NonNullable<\n paths[\"/v1/roasts\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n/** Request body for {@link ParchmentClient.roasts.update}. */\nexport type RoastUpdateRequest = NonNullable<\n paths[\"/v1/roasts/{id}\"][\"patch\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n/** Request body for {@link ParchmentClient.roasts.import}. */\nexport type RoastImportRequest = NonNullable<\n paths[\"/v1/roasts/imports\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n/** Request body for {@link ParchmentClient.roasts.replaceArtisanImport}. */\nexport type RoastArtisanImportReplaceRequest = NonNullable<\n paths[\"/v1/roasts/{id}/artisan-import\"][\"put\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n/** Query parameters for {@link ParchmentClient.sales.list}. */\nexport type SalesListQuery = NonNullable<\n paths[\"/v1/sales\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.tasting.get}. */\nexport type TastingGetQuery = NonNullable<\n paths[\"/v1/tasting/{catalogId}\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Request body for {@link ParchmentClient.apiKeys.create}. */\nexport type ApiKeyCreateRequest = NonNullable<\n paths[\"/v1/api-keys\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\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 apiKeys: {\n /** List API keys owned by the authenticated session user. */\n list: () => client.GET(\"/v1/api-keys\"),\n /** Create an API key. The raw secret is returned only once. */\n create: (body: ApiKeyCreateRequest) =>\n client.POST(\"/v1/api-keys\", { body }),\n /** Revoke an API key owned by the authenticated session user. */\n revoke: (id: string) =>\n client.DELETE(\"/v1/api-keys/{id}\", {\n params: { path: { id } },\n }),\n /** Rotate an API key and return the replacement secret once. */\n rotate: (id: string) =>\n client.POST(\"/v1/api-keys/{id}/rotate\", {\n params: { path: { id } },\n }),\n },\n catalog: {\n /** Catalog capabilities and visibility for the caller. */\n access: () => client.GET(\"/v1/catalog/access\"),\n /**\n * List public catalog coffees (paginated). Pass `headers` to send the\n * `Prefer: handling=lenient|strict` override (see {@link CatalogListHeaders}).\n */\n list: (query?: CatalogListQuery, headers?: CatalogListHeaders) =>\n client.GET(\"/v1/catalog\", { params: { query, header: headers } }),\n /**\n * Catalog filter metadata and counted facets. Pass `headers` to send the\n * `Prefer: handling=lenient|strict` override (see {@link CatalogFacetsHeaders}).\n */\n facets: (query?: CatalogFacetsQuery, headers?: CatalogFacetsHeaders) =>\n client.GET(\"/v1/catalog/facets\", {\n params: { query, header: headers },\n }),\n /** Live catalog price context by origin. */\n originPriceStats: (query?: CatalogOriginPriceStatsQuery) =>\n client.GET(\"/v1/catalog/origin-price-stats\", { params: { query } }),\n /** Aggregate stats over the caller-visible catalog. */\n stats: (query?: CatalogStatsQuery) =>\n client.GET(\"/v1/catalog/stats\", { params: { query } }),\n /** Rank caller-visible catalog coffees by deterministic objectives. */\n rank: (query?: CatalogRankQuery, headers?: CatalogRankHeaders) =>\n client.GET(\"/v1/catalog/rank\", {\n params: { query, header: headers },\n }),\n /** Rank premium catalog candidates by Purveyor Score. */\n rankPremium: (\n query?: CatalogRankPremiumQuery,\n headers?: CatalogRankPremiumHeaders,\n ) =>\n client.GET(\"/v1/catalog/rank-premium\", {\n params: { query, header: headers },\n }),\n /** List supplier aggregates over caller-visible catalog coffees. */\n suppliers: (\n query?: CatalogSuppliersQuery,\n headers?: CatalogSupplierHeaders,\n ) =>\n client.GET(\"/v1/catalog/suppliers\", {\n params: { query, header: headers },\n }),\n /** Return aggregate detail for a supplier query. */\n supplierDetail: (\n query: CatalogSupplierDetailQuery,\n headers?: CatalogSupplierHeaders,\n ) =>\n client.GET(\"/v1/catalog/suppliers/detail\", {\n params: { query, header: headers },\n }),\n /** Rank suppliers by catalog score and availability. */\n supplierRank: (\n query?: CatalogSupplierRankQuery,\n headers?: CatalogSupplierHeaders,\n ) =>\n client.GET(\"/v1/catalog/suppliers/rank\", {\n params: { query, header: headers },\n }),\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 inventory: {\n /** List the caller's own green-coffee inventory (owner-scoped). */\n list: (query?: InventoryListQuery) =>\n client.GET(\"/v1/inventory\", { params: { query } }),\n /**\n * Create an owner inventory lot. Requires a session or an owner-bound API\n * key carrying the exact `inventory:write` scope. Pass `idempotencyKey`\n * to make retries safe: the same key replays the original result, and a\n * concurrent duplicate gets 409 while the first is in flight.\n */\n create: (\n body: InventoryCreateRequest,\n options?: { idempotencyKey?: string },\n ) =>\n client.POST(\"/v1/inventory\", {\n body,\n params: options?.idempotencyKey\n ? { header: { \"idempotency-key\": options.idempotencyKey } }\n : undefined,\n }),\n /**\n * Update one of the caller's own inventory rows. Pass `ifMatch` (the\n * row's `last_updated`) to enable optimistic concurrency (409 on mismatch).\n */\n update: (\n id: number,\n body: InventoryUpdateRequest,\n options?: { ifMatch?: string },\n ) =>\n client.PATCH(\"/v1/inventory/{id}\", {\n params: {\n path: { id },\n header: options?.ifMatch\n ? { \"if-match\": options.ifMatch }\n : undefined,\n },\n body,\n }),\n /**\n * Delete one of the caller's own inventory rows. Returns 409 if dependent\n * roast profiles or sales exist (no force-cascade).\n */\n delete: (id: number) =>\n client.DELETE(\"/v1/inventory/{id}\", { params: { path: { id } } }),\n },\n roasts: {\n /** List the caller's own roast profiles (owner-scoped). */\n list: (query?: RoastListQuery) =>\n client.GET(\"/v1/roasts\", { params: { query } }),\n /**\n * Fetch one of the caller's roast profiles by id, optionally with its\n * temperature curve (`includeTemps`) and event markers (`includeEvents`).\n */\n get: (id: string, query?: RoastGetQuery) =>\n client.GET(\"/v1/roasts/{id}\", { params: { path: { id }, query } }),\n /**\n * Create an owner roast profile, optionally with nested temperature/event\n * rows. Requires a session or an owner-bound API key carrying the exact\n * `roast:write` scope. Pass `idempotencyKey` to make retries safe.\n */\n create: (\n body: RoastCreateRequest,\n options?: { idempotencyKey?: string },\n ) =>\n client.POST(\"/v1/roasts\", {\n body,\n params: options?.idempotencyKey\n ? { header: { \"idempotency-key\": options.idempotencyKey } }\n : undefined,\n }),\n /**\n * Update one of the caller's own roast profiles. Pass `ifMatch` (the\n * row's `last_updated`) to enable optimistic concurrency (409 on mismatch).\n */\n update: (\n id: number,\n body: RoastUpdateRequest,\n options?: { ifMatch?: string },\n ) =>\n client.PATCH(\"/v1/roasts/{id}\", {\n params: {\n path: { id },\n header: options?.ifMatch\n ? { \"if-match\": options.ifMatch }\n : undefined,\n },\n body,\n }),\n /** Delete one of the caller's own roast profiles. */\n delete: (id: number) =>\n client.DELETE(\"/v1/roasts/{id}\", { params: { path: { id } } }),\n /**\n * Create a roast profile from an Artisan `.alog` file against one of the\n * caller's green-coffee lots, persisting the imported curve, events, and\n * an artisan_import_log entry atomically. Requires a session or an\n * owner-bound API key carrying the exact `roast:write` scope. Pass\n * `idempotencyKey` to make retries safe.\n */\n import: (\n body: RoastImportRequest,\n options?: { idempotencyKey?: string },\n ) =>\n client.POST(\"/v1/roasts/imports\", {\n body,\n params: options?.idempotencyKey\n ? { header: { \"idempotency-key\": options.idempotencyKey } }\n : undefined,\n }),\n /**\n * Replace the Artisan import data on one of the caller's existing roasts,\n * re-deriving its curve, events, and computed metrics while preserving the\n * roast's identity. Pass `ifMatch` (the roast's `last_updated`) to enable\n * optimistic concurrency (409 on mismatch).\n */\n replaceArtisanImport: (\n id: number,\n body: RoastArtisanImportReplaceRequest,\n options?: { ifMatch?: string },\n ) =>\n client.PUT(\"/v1/roasts/{id}/artisan-import\", {\n params: {\n path: { id },\n header: options?.ifMatch\n ? { \"if-match\": options.ifMatch }\n : undefined,\n },\n body,\n }),\n },\n sales: {\n /** List the caller's own sales (owner-scoped). */\n list: (query?: SalesListQuery) =>\n client.GET(\"/v1/sales\", { params: { query } }),\n },\n tasting: {\n /** Fetch supplier notes plus the caller's own latest tasting notes. */\n get: (catalogId: string, query?: TastingGetQuery) =>\n client.GET(\"/v1/tasting/{catalogId}\", {\n params: { path: { catalogId }, query },\n }),\n },\n };\n}\n\nexport type ParchmentClient = ReturnType<typeof createParchmentClient>;\n"],"mappings":";AAAA,OAAO,kBAA0C;AAqJ1C,SAAS,sBAAsB,SAAiC;AACrE,QAAM,EAAE,SAAS,OAAO,OAAO,UAAU,IAAI;AAE7C,QAAM,SAAS,aAAoB;AAAA,IACjC;AAAA,IACA,OAAO;AAAA,IACP,SAAS,QAAQ,EAAE,eAAe,UAAU,KAAK,GAAG,IAAI;AAAA,EAC1D,CAAC;AAED,SAAO;AAAA;AAAA,IAEL,KAAK;AAAA;AAAA,IAEL,QAAQ,MAAM,OAAO,IAAI,SAAS;AAAA;AAAA,IAElC,IAAI,MAAM,OAAO,IAAI,QAAQ;AAAA,IAC7B,SAAS;AAAA;AAAA,MAEP,MAAM,MAAM,OAAO,IAAI,cAAc;AAAA;AAAA,MAErC,QAAQ,CAAC,SACP,OAAO,KAA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AG,EAAE,EAAE,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQ/D,QAAQ,CACN,MACAA,aAEA,OAAO,KAAK,sBAAsB;AAAA,QAChC;AAAA,QACA,QAAQA,UAAS,iBACb,EAAE,QAAQ,EAAE,mBAAmBA,SAAQ,eAAe,EAAE,IACxD;AAAA,MACN,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOH,sBAAsB,CACpB,IACA,MACAA,aAEA,OAAO,IAAI,kCAAkC;AAAA,QAC3C,QAAQ;AAAA,UACN,MAAM,EAAE,GAAG;AAAA,UACX,QAAQA,UAAS,UACb,EAAE,YAAYA,SAAQ,QAAQ,IAC9B;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACL;AAAA,IACA,OAAO;AAAA;AAAA,MAEL,MAAM,CAAC,UACL,OAAO,IAAI,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAAA,IACjD;AAAA,IACA,SAAS;AAAA;AAAA,MAEP,KAAK,CAAC,WAAmB,UACvB,OAAO,IAAI,2BAA2B;AAAA,QACpC,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM;AAAA,MACvC,CAAC;AAAA,IACL;AAAA,EACF;AACF;","names":["options"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purveyors/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Typed client for the Purveyors Parchment API, generated from its OpenAPI spec.",
5
5
  "license": "MIT",
6
6
  "type": "module",