react-shopwave-connect 0.4.2 → 0.4.3
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 +14 -2
- package/dist/core/index.cjs +104 -44
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +54 -4
- package/dist/core/index.d.ts +54 -4
- package/dist/core/index.js +101 -45
- package/dist/core/index.js.map +1 -1
- package/dist/hooks/index.cjs +129 -44
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +21 -1
- package/dist/hooks/index.d.ts +21 -1
- package/dist/hooks/index.js +128 -45
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +133 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -4
- package/dist/index.d.ts +74 -4
- package/dist/index.js +128 -45
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +24 -0
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +45 -4
- package/dist/next/index.d.ts +45 -4
- package/dist/next/index.js +24 -1
- package/dist/next/index.js.map +1 -1
- package/dist/server/index.cjs +21 -0
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +42 -4
- package/dist/server/index.d.ts +42 -4
- package/dist/server/index.js +21 -1
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/next/index.d.cts
CHANGED
|
@@ -87,8 +87,9 @@ interface ShopwaveOAuthClient {
|
|
|
87
87
|
//#region src/core/entities.d.ts
|
|
88
88
|
/**
|
|
89
89
|
* How each Shopwave entity is addressed, shared by the client functions below
|
|
90
|
-
* and the server route handlers in `react-shopwave-connect/
|
|
91
|
-
*
|
|
90
|
+
* and the server route handlers in `react-shopwave-connect/server` (wrapped with
|
|
91
|
+
* the session by `react-shopwave-connect/next`), so the two halves of the
|
|
92
|
+
* contract can't drift apart.
|
|
92
93
|
*/
|
|
93
94
|
interface EntityDefinition {
|
|
94
95
|
/** App route segment: `/api/<route>` and `/api/<route>/<id>`. */
|
|
@@ -148,7 +149,7 @@ declare const SHOPWAVE_ENTITIES: Readonly<Record<EntityKind, EntityDefinition>>;
|
|
|
148
149
|
*
|
|
149
150
|
* Like `SHOPWAVE_ENTITIES`, this table is shared by the client functions
|
|
150
151
|
* (`fetchMerchant`, `fetchUser`, `uploadImage`, …) and the server route
|
|
151
|
-
* handlers in `react-shopwave-connect/
|
|
152
|
+
* handlers in `react-shopwave-connect/server`, so the two halves of the contract
|
|
152
153
|
* can't drift apart. These aren't in `SHOPWAVE_ENTITIES` because they aren't
|
|
153
154
|
* keyed collections: `GET /merchant` answers `{ merchant: {…} }`, not a map by id.
|
|
154
155
|
*/
|
|
@@ -181,6 +182,35 @@ declare const SHOPWAVE_RESOURCES: Readonly<Record<ResourceKind, ResourceDefiniti
|
|
|
181
182
|
type UploadKind = "merchant" | "merchantFeature" | "product" | "user" | "applicationLogo" | "applicationImages";
|
|
182
183
|
/** `UploadKind` → the API's `contentType` value. */
|
|
183
184
|
declare const UPLOAD_KINDS: Readonly<Record<UploadKind, string>>;
|
|
185
|
+
/**
|
|
186
|
+
* Read-only lists that aren't records: the merchant's distinct tags.
|
|
187
|
+
*
|
|
188
|
+
* Like `SHOPWAVE_RESOURCES`, shared by the client functions
|
|
189
|
+
* (`fetchProductTags`, `fetchProductInstanceTags`) and the server route
|
|
190
|
+
* handlers (`shopwave.lookup(kind)`), so the two halves can't drift apart.
|
|
191
|
+
*
|
|
192
|
+
* - productTags: `GET /product/tags` → `{ tags: string[] }`, every distinct tag
|
|
193
|
+
* on the merchant's products. No parameters. The API reference says
|
|
194
|
+
* "internal SKU tags are excluded", but the live API includes system tags
|
|
195
|
+
* written by imports and syncs (`PID-133`, `VID-137`, `#Hash:…`, `upc-…`;
|
|
196
|
+
* test merchant 5644, 29 Oct 2026). Apps that offer the list as suggestions
|
|
197
|
+
* filter those themselves. Tags of deleted products drop out of the list.
|
|
198
|
+
* - productInstanceTags: `GET /product/instance/tags` → `{ tags: string[] }`,
|
|
199
|
+
* the same for price instances (channels such as "Eat In", "Takeout").
|
|
200
|
+
*
|
|
201
|
+
* The app route for instance tags is `products/instance-tags`, one segment
|
|
202
|
+
* under `products`, so it sits beside `products/[id]` without nesting deeper.
|
|
203
|
+
*/
|
|
204
|
+
interface LookupDefinition {
|
|
205
|
+
/** App route: `/api/<route>`. */
|
|
206
|
+
route: string;
|
|
207
|
+
/** Key of the list in the response (`{ tags: [...] }`). */
|
|
208
|
+
key: string;
|
|
209
|
+
/** Shopwave API path. */
|
|
210
|
+
upstream: string;
|
|
211
|
+
}
|
|
212
|
+
type LookupKind = "productTags" | "productInstanceTags";
|
|
213
|
+
declare const SHOPWAVE_LOOKUPS: Readonly<Record<LookupKind, LookupDefinition>>;
|
|
184
214
|
//#endregion
|
|
185
215
|
//#region src/server/api.d.ts
|
|
186
216
|
/**
|
|
@@ -303,6 +333,14 @@ interface ShopwaveApiHandlers {
|
|
|
303
333
|
passthrough(path: string): {
|
|
304
334
|
GET: RouteHandler;
|
|
305
335
|
};
|
|
336
|
+
/**
|
|
337
|
+
* Handler for a read-only list (see `SHOPWAVE_LOOKUPS`), e.g.
|
|
338
|
+
* `app/api/products/tags/route.ts`: `export const { GET } = shopwave.lookup("productTags")`.
|
|
339
|
+
* Takes no parameters, so the caller's `extras` aren't forwarded.
|
|
340
|
+
*/
|
|
341
|
+
lookup(kind: LookupKind): {
|
|
342
|
+
GET: RouteHandler;
|
|
343
|
+
};
|
|
306
344
|
/** Handlers for a singleton resource: `app/api/merchant/route.ts`, `app/api/user/route.ts`. */
|
|
307
345
|
resource(kind: ResourceKind): ResourceHandlers;
|
|
308
346
|
/** Handler for `app/api/upload/route.ts`. */
|
|
@@ -510,9 +548,12 @@ interface ShopwaveNextApiConfig extends Omit<ShopwaveApiConfig, "getAuthorizatio
|
|
|
510
548
|
* export const { GET } = shopwave.resource("user");
|
|
511
549
|
* // app/api/upload/route.ts
|
|
512
550
|
* export const { POST } = shopwave.upload();
|
|
551
|
+
* // app/api/products/tags/route.ts, app/api/products/instance-tags/route.ts
|
|
552
|
+
* export const { GET } = shopwave.lookup("productTags");
|
|
553
|
+
* export const { GET } = shopwave.lookup("productInstanceTags");
|
|
513
554
|
* ```
|
|
514
555
|
*/
|
|
515
556
|
declare function createShopwaveApi(config: ShopwaveNextApiConfig): ShopwaveApiHandlers;
|
|
516
557
|
//#endregion
|
|
517
|
-
export { AuthContext, type CollectionHandlers, type EntityDefinition, type EntityKind, type ForwardInit, type ItemHandlers, ProtectOptions, type ResourceHandlers, type ResourceKind, type RouteContext, type RouteHandler, SHOPWAVE_ENTITIES, SHOPWAVE_RESOURCES, type SessionStatus, type ShopwaveApiHandlers, ShopwaveAuth, ShopwaveAuthConfig, ShopwaveAuthError, ShopwaveNextApiConfig, ShopwaveSessionConfig, ShopwaveSessionData, type ShopwaveToken, UPLOAD_KINDS, type UploadHandlers, type UploadKind, type UploadOptions, authorizationHeader, createShopwaveApi, createShopwaveAuth, isExpiredTokenResponse, readRequestToken };
|
|
558
|
+
export { AuthContext, type CollectionHandlers, type EntityDefinition, type EntityKind, type ForwardInit, type ItemHandlers, type LookupKind, ProtectOptions, type ResourceHandlers, type ResourceKind, type RouteContext, type RouteHandler, SHOPWAVE_ENTITIES, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, type SessionStatus, type ShopwaveApiHandlers, ShopwaveAuth, ShopwaveAuthConfig, ShopwaveAuthError, ShopwaveNextApiConfig, ShopwaveSessionConfig, ShopwaveSessionData, type ShopwaveToken, UPLOAD_KINDS, type UploadHandlers, type UploadKind, type UploadOptions, authorizationHeader, createShopwaveApi, createShopwaveAuth, isExpiredTokenResponse, readRequestToken };
|
|
518
559
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/next/index.d.ts
CHANGED
|
@@ -87,8 +87,9 @@ interface ShopwaveOAuthClient {
|
|
|
87
87
|
//#region src/core/entities.d.ts
|
|
88
88
|
/**
|
|
89
89
|
* How each Shopwave entity is addressed, shared by the client functions below
|
|
90
|
-
* and the server route handlers in `react-shopwave-connect/
|
|
91
|
-
*
|
|
90
|
+
* and the server route handlers in `react-shopwave-connect/server` (wrapped with
|
|
91
|
+
* the session by `react-shopwave-connect/next`), so the two halves of the
|
|
92
|
+
* contract can't drift apart.
|
|
92
93
|
*/
|
|
93
94
|
interface EntityDefinition {
|
|
94
95
|
/** App route segment: `/api/<route>` and `/api/<route>/<id>`. */
|
|
@@ -148,7 +149,7 @@ declare const SHOPWAVE_ENTITIES: Readonly<Record<EntityKind, EntityDefinition>>;
|
|
|
148
149
|
*
|
|
149
150
|
* Like `SHOPWAVE_ENTITIES`, this table is shared by the client functions
|
|
150
151
|
* (`fetchMerchant`, `fetchUser`, `uploadImage`, …) and the server route
|
|
151
|
-
* handlers in `react-shopwave-connect/
|
|
152
|
+
* handlers in `react-shopwave-connect/server`, so the two halves of the contract
|
|
152
153
|
* can't drift apart. These aren't in `SHOPWAVE_ENTITIES` because they aren't
|
|
153
154
|
* keyed collections: `GET /merchant` answers `{ merchant: {…} }`, not a map by id.
|
|
154
155
|
*/
|
|
@@ -181,6 +182,35 @@ declare const SHOPWAVE_RESOURCES: Readonly<Record<ResourceKind, ResourceDefiniti
|
|
|
181
182
|
type UploadKind = "merchant" | "merchantFeature" | "product" | "user" | "applicationLogo" | "applicationImages";
|
|
182
183
|
/** `UploadKind` → the API's `contentType` value. */
|
|
183
184
|
declare const UPLOAD_KINDS: Readonly<Record<UploadKind, string>>;
|
|
185
|
+
/**
|
|
186
|
+
* Read-only lists that aren't records: the merchant's distinct tags.
|
|
187
|
+
*
|
|
188
|
+
* Like `SHOPWAVE_RESOURCES`, shared by the client functions
|
|
189
|
+
* (`fetchProductTags`, `fetchProductInstanceTags`) and the server route
|
|
190
|
+
* handlers (`shopwave.lookup(kind)`), so the two halves can't drift apart.
|
|
191
|
+
*
|
|
192
|
+
* - productTags: `GET /product/tags` → `{ tags: string[] }`, every distinct tag
|
|
193
|
+
* on the merchant's products. No parameters. The API reference says
|
|
194
|
+
* "internal SKU tags are excluded", but the live API includes system tags
|
|
195
|
+
* written by imports and syncs (`PID-133`, `VID-137`, `#Hash:…`, `upc-…`;
|
|
196
|
+
* test merchant 5644, 29 Oct 2026). Apps that offer the list as suggestions
|
|
197
|
+
* filter those themselves. Tags of deleted products drop out of the list.
|
|
198
|
+
* - productInstanceTags: `GET /product/instance/tags` → `{ tags: string[] }`,
|
|
199
|
+
* the same for price instances (channels such as "Eat In", "Takeout").
|
|
200
|
+
*
|
|
201
|
+
* The app route for instance tags is `products/instance-tags`, one segment
|
|
202
|
+
* under `products`, so it sits beside `products/[id]` without nesting deeper.
|
|
203
|
+
*/
|
|
204
|
+
interface LookupDefinition {
|
|
205
|
+
/** App route: `/api/<route>`. */
|
|
206
|
+
route: string;
|
|
207
|
+
/** Key of the list in the response (`{ tags: [...] }`). */
|
|
208
|
+
key: string;
|
|
209
|
+
/** Shopwave API path. */
|
|
210
|
+
upstream: string;
|
|
211
|
+
}
|
|
212
|
+
type LookupKind = "productTags" | "productInstanceTags";
|
|
213
|
+
declare const SHOPWAVE_LOOKUPS: Readonly<Record<LookupKind, LookupDefinition>>;
|
|
184
214
|
//#endregion
|
|
185
215
|
//#region src/server/api.d.ts
|
|
186
216
|
/**
|
|
@@ -303,6 +333,14 @@ interface ShopwaveApiHandlers {
|
|
|
303
333
|
passthrough(path: string): {
|
|
304
334
|
GET: RouteHandler;
|
|
305
335
|
};
|
|
336
|
+
/**
|
|
337
|
+
* Handler for a read-only list (see `SHOPWAVE_LOOKUPS`), e.g.
|
|
338
|
+
* `app/api/products/tags/route.ts`: `export const { GET } = shopwave.lookup("productTags")`.
|
|
339
|
+
* Takes no parameters, so the caller's `extras` aren't forwarded.
|
|
340
|
+
*/
|
|
341
|
+
lookup(kind: LookupKind): {
|
|
342
|
+
GET: RouteHandler;
|
|
343
|
+
};
|
|
306
344
|
/** Handlers for a singleton resource: `app/api/merchant/route.ts`, `app/api/user/route.ts`. */
|
|
307
345
|
resource(kind: ResourceKind): ResourceHandlers;
|
|
308
346
|
/** Handler for `app/api/upload/route.ts`. */
|
|
@@ -510,9 +548,12 @@ interface ShopwaveNextApiConfig extends Omit<ShopwaveApiConfig, "getAuthorizatio
|
|
|
510
548
|
* export const { GET } = shopwave.resource("user");
|
|
511
549
|
* // app/api/upload/route.ts
|
|
512
550
|
* export const { POST } = shopwave.upload();
|
|
551
|
+
* // app/api/products/tags/route.ts, app/api/products/instance-tags/route.ts
|
|
552
|
+
* export const { GET } = shopwave.lookup("productTags");
|
|
553
|
+
* export const { GET } = shopwave.lookup("productInstanceTags");
|
|
513
554
|
* ```
|
|
514
555
|
*/
|
|
515
556
|
declare function createShopwaveApi(config: ShopwaveNextApiConfig): ShopwaveApiHandlers;
|
|
516
557
|
//#endregion
|
|
517
|
-
export { AuthContext, type CollectionHandlers, type EntityDefinition, type EntityKind, type ForwardInit, type ItemHandlers, ProtectOptions, type ResourceHandlers, type ResourceKind, type RouteContext, type RouteHandler, SHOPWAVE_ENTITIES, SHOPWAVE_RESOURCES, type SessionStatus, type ShopwaveApiHandlers, ShopwaveAuth, ShopwaveAuthConfig, ShopwaveAuthError, ShopwaveNextApiConfig, ShopwaveSessionConfig, ShopwaveSessionData, type ShopwaveToken, UPLOAD_KINDS, type UploadHandlers, type UploadKind, type UploadOptions, authorizationHeader, createShopwaveApi, createShopwaveAuth, isExpiredTokenResponse, readRequestToken };
|
|
558
|
+
export { AuthContext, type CollectionHandlers, type EntityDefinition, type EntityKind, type ForwardInit, type ItemHandlers, type LookupKind, ProtectOptions, type ResourceHandlers, type ResourceKind, type RouteContext, type RouteHandler, SHOPWAVE_ENTITIES, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, type SessionStatus, type ShopwaveApiHandlers, ShopwaveAuth, ShopwaveAuthConfig, ShopwaveAuthError, ShopwaveNextApiConfig, ShopwaveSessionConfig, ShopwaveSessionData, type ShopwaveToken, UPLOAD_KINDS, type UploadHandlers, type UploadKind, type UploadOptions, authorizationHeader, createShopwaveApi, createShopwaveAuth, isExpiredTokenResponse, readRequestToken };
|
|
518
559
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/next/index.js
CHANGED
|
@@ -367,6 +367,18 @@ const SHOPWAVE_UPLOAD = Object.freeze({
|
|
|
367
367
|
function isUploadKind(value) {
|
|
368
368
|
return typeof value === "string" && Object.prototype.hasOwnProperty.call(UPLOAD_KINDS, value);
|
|
369
369
|
}
|
|
370
|
+
const SHOPWAVE_LOOKUPS = Object.freeze({
|
|
371
|
+
productTags: {
|
|
372
|
+
route: "products/tags",
|
|
373
|
+
key: "tags",
|
|
374
|
+
upstream: "product/tags"
|
|
375
|
+
},
|
|
376
|
+
productInstanceTags: {
|
|
377
|
+
route: "products/instance-tags",
|
|
378
|
+
key: "tags",
|
|
379
|
+
upstream: "product/instance/tags"
|
|
380
|
+
}
|
|
381
|
+
});
|
|
370
382
|
|
|
371
383
|
//#endregion
|
|
372
384
|
//#region src/server/api.ts
|
|
@@ -808,6 +820,14 @@ function createShopwaveApiHandlers(config) {
|
|
|
808
820
|
passthrough(path) {
|
|
809
821
|
return { GET: (request) => forward(request, { path }) };
|
|
810
822
|
},
|
|
823
|
+
lookup(kind) {
|
|
824
|
+
const def = SHOPWAVE_LOOKUPS[kind];
|
|
825
|
+
if (!def) throw new Error(`Unknown Shopwave lookup "${kind}"`);
|
|
826
|
+
return { GET: (request) => forward(request, {
|
|
827
|
+
path: def.upstream,
|
|
828
|
+
forwardExtras: false
|
|
829
|
+
}) };
|
|
830
|
+
},
|
|
811
831
|
resource(kind) {
|
|
812
832
|
const def = resourceDef(kind);
|
|
813
833
|
const save = (request) => writeResource(request, def);
|
|
@@ -1150,6 +1170,9 @@ function createShopwaveAuth(config) {
|
|
|
1150
1170
|
* export const { GET } = shopwave.resource("user");
|
|
1151
1171
|
* // app/api/upload/route.ts
|
|
1152
1172
|
* export const { POST } = shopwave.upload();
|
|
1173
|
+
* // app/api/products/tags/route.ts, app/api/products/instance-tags/route.ts
|
|
1174
|
+
* export const { GET } = shopwave.lookup("productTags");
|
|
1175
|
+
* export const { GET } = shopwave.lookup("productInstanceTags");
|
|
1153
1176
|
* ```
|
|
1154
1177
|
*/
|
|
1155
1178
|
function createShopwaveApi(config) {
|
|
@@ -1162,5 +1185,5 @@ function createShopwaveApi(config) {
|
|
|
1162
1185
|
}
|
|
1163
1186
|
|
|
1164
1187
|
//#endregion
|
|
1165
|
-
export { SHOPWAVE_ENTITIES, SHOPWAVE_RESOURCES, ShopwaveAuthError, UPLOAD_KINDS, authorizationHeader, createShopwaveApi, createShopwaveAuth, isExpiredTokenResponse, readRequestToken };
|
|
1188
|
+
export { SHOPWAVE_ENTITIES, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, ShopwaveAuthError, UPLOAD_KINDS, authorizationHeader, createShopwaveApi, createShopwaveAuth, isExpiredTokenResponse, readRequestToken };
|
|
1166
1189
|
//# sourceMappingURL=index.js.map
|