react-shopwave-connect 0.4.3 → 0.4.4
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 +6 -4
- package/dist/core/index.cjs +484 -424
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +56 -2
- package/dist/core/index.d.ts +56 -2
- package/dist/core/index.js +481 -425
- package/dist/core/index.js.map +1 -1
- package/dist/hooks/index.cjs +159 -145
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +19 -0
- package/dist/hooks/index.d.ts +19 -0
- package/dist/hooks/index.js +159 -145
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +484 -424
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -2
- package/dist/index.d.ts +56 -2
- package/dist/index.js +481 -425
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +75 -57
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +21 -4
- package/dist/next/index.d.ts +21 -4
- package/dist/next/index.js +75 -58
- package/dist/next/index.js.map +1 -1
- package/dist/server/index.cjs +75 -57
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +26 -5
- package/dist/server/index.d.ts +26 -5
- package/dist/server/index.js +75 -58
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -676,6 +676,9 @@ declare function fetchEntityById<K extends EntityKind>(kind: K, id: EntityId, pa
|
|
|
676
676
|
* read) so an edited price is sent as a new instance. As a safeguard, a new
|
|
677
677
|
* product (no `id`, e.g. a duplicate) never sends instance ids: an id copied from
|
|
678
678
|
* another product would otherwise point the save at that product's instances.
|
|
679
|
+
*
|
|
680
|
+
* `images` is sent as file names ({@link toStoredProductImages}), so the URLs a
|
|
681
|
+
* read returns can be passed straight back; leaving `images` out keeps them.
|
|
679
682
|
*/
|
|
680
683
|
declare const saveProduct: (product: ProductSaveInput, options?: RequestOptions) => Promise<Saved<Product>>;
|
|
681
684
|
declare const deleteProduct: (id: EntityId, options?: RequestOptions) => Promise<void>;
|
|
@@ -844,20 +847,40 @@ declare const SHOPWAVE_RESOURCES: Readonly<Record<ResourceKind, ResourceDefiniti
|
|
|
844
847
|
type UploadKind = "merchant" | "merchantFeature" | "product" | "user" | "applicationLogo" | "applicationImages";
|
|
845
848
|
/** `UploadKind` → the API's `contentType` value. */
|
|
846
849
|
declare const UPLOAD_KINDS: Readonly<Record<UploadKind, string>>;
|
|
850
|
+
/**
|
|
851
|
+
* The role an image plays, sent to Shopwave as the uploader's `prefix` header.
|
|
852
|
+
* The uploader names the file `<prefix>_<hash>.<ext>`, so the role travels with
|
|
853
|
+
* the file wherever a record stores it (a product's `images`). Live, merchant
|
|
854
|
+
* 5644, 4 Nov 2026: all four values answered 201.
|
|
855
|
+
* - `product`: a product gallery image;
|
|
856
|
+
* - `product_thumbnail`: the product's lead image, shown in lists;
|
|
857
|
+
* - `variant` / `variant_thumbnail`: a variant's own image and its lead image
|
|
858
|
+
* (used by the Connect integrations).
|
|
859
|
+
*
|
|
860
|
+
* Values are the ones Connect's `uploadFileToShopwave` sends.
|
|
861
|
+
*/
|
|
862
|
+
type UploadPrefix = "product" | "product_thumbnail" | "variant" | "variant_thumbnail";
|
|
863
|
+
/** Every `UploadPrefix`, longest first so a name check never takes `product` for `product_thumbnail`. */
|
|
864
|
+
declare const UPLOAD_PREFIXES: ReadonlyArray<UploadPrefix>;
|
|
847
865
|
/** How uploads are addressed (app route and Shopwave uploader). */
|
|
848
866
|
declare const SHOPWAVE_UPLOAD: Readonly<{
|
|
849
|
-
/** App route: `POST /api/<route>` (multipart `file` + `kind`). */
|
|
867
|
+
/** App route: `POST /api/<route>` (multipart `file` + `kind`, optional `prefix`). */
|
|
850
868
|
route: "upload";
|
|
851
869
|
/** Shopwave path: `PUT {apiUrl}/uploader` (multipart `file`). */
|
|
852
870
|
upstream: "uploader";
|
|
853
871
|
/** Header that carries the upload kind upstream. */
|
|
854
872
|
kindHeader: "contentType";
|
|
873
|
+
/** Header that carries the image role upstream (see `UploadPrefix`). */
|
|
874
|
+
prefixHeader: "prefix";
|
|
855
875
|
/** Multipart field name for the file, on both sides. */
|
|
856
876
|
fileField: "file";
|
|
857
877
|
/** Multipart field name for the kind in the app request. */
|
|
858
878
|
kindField: "kind";
|
|
879
|
+
/** Multipart field name for the image role in the app request. */
|
|
880
|
+
prefixField: "prefix";
|
|
859
881
|
}>;
|
|
860
882
|
declare function isUploadKind(value: unknown): value is UploadKind;
|
|
883
|
+
declare function isUploadPrefix(value: unknown): value is UploadPrefix;
|
|
861
884
|
/**
|
|
862
885
|
* Read-only lists that aren't records: the merchant's distinct tags.
|
|
863
886
|
*
|
|
@@ -933,6 +956,12 @@ declare function fitImageToSize(file: Blob, width: number, height: number, optio
|
|
|
933
956
|
interface UploadImageParams {
|
|
934
957
|
/** What the image is for (sent to Shopwave as the uploader's `contentType`). */
|
|
935
958
|
kind: UploadKind;
|
|
959
|
+
/**
|
|
960
|
+
* The image's role (sent to Shopwave as the uploader's `prefix` header), e.g.
|
|
961
|
+
* `product_thumbnail` for a product's lead image. Leave it out for images
|
|
962
|
+
* without a role (merchant logos).
|
|
963
|
+
*/
|
|
964
|
+
prefix?: UploadPrefix;
|
|
936
965
|
/** File name to send when `file` is a Blob without one. Defaults to `File.name`, else `"upload"`. */
|
|
937
966
|
fileName?: string;
|
|
938
967
|
}
|
|
@@ -1224,5 +1253,30 @@ interface UserResponse {
|
|
|
1224
1253
|
/** Reads the logged-in user, or `null` when the API returns none. */
|
|
1225
1254
|
declare function fetchUser(options?: RequestOptions): Promise<User | null>;
|
|
1226
1255
|
//#endregion
|
|
1227
|
-
|
|
1256
|
+
//#region src/core/productImages.d.ts
|
|
1257
|
+
/**
|
|
1258
|
+
* Product images, as the live API stores them (merchant 5644, 4 Nov 2026):
|
|
1259
|
+
* - A product's `images` is a list. **Reads return full URLs**
|
|
1260
|
+
* (`http://static.merchantstack.com/images/merchant/<id>/product/<file>`);
|
|
1261
|
+
* **writes take the uploader's file names** ({@link toStoredProductImages};
|
|
1262
|
+
* `saveProduct` does this for you).
|
|
1263
|
+
* - The uploader takes one file per request. With a `prefix` (see
|
|
1264
|
+
* `UploadPrefix`) it names the file `<prefix>_<hash>.<ext>`
|
|
1265
|
+
* (`product_thumbnail_1bdd…41090b.png`); without one, `<hash>.<ext>`. So an
|
|
1266
|
+
* image's role can be read back from its name ({@link productImageRole}).
|
|
1267
|
+
*/
|
|
1268
|
+
/**
|
|
1269
|
+
* The role in an image's file name or URL, from the uploader's `prefix`:
|
|
1270
|
+
* `"…/product_thumbnail_1bdd.png"` → `"product_thumbnail"`. `null` for a name
|
|
1271
|
+
* without one (images uploaded without a prefix, e.g. before prefixes existed).
|
|
1272
|
+
*/
|
|
1273
|
+
declare function productImageRole(value: unknown): UploadPrefix | null;
|
|
1274
|
+
/**
|
|
1275
|
+
* A product's `images` as the API takes them on a save: file names, not the
|
|
1276
|
+
* URLs a read returns. Non-strings, blanks and duplicates are dropped; the
|
|
1277
|
+
* order is kept.
|
|
1278
|
+
*/
|
|
1279
|
+
declare function toStoredProductImages(images: unknown): string[];
|
|
1280
|
+
//#endregion
|
|
1281
|
+
export { Basket, BasketFilters, BasketItem, BasketPagination, BasketReportRow, BasketSummary, Category, CategoryResponse, CombineBasketRowsParams, Consumer, ConsumerResponse, CropRect, DEFAULT_BASKET_FILTERS, DEFAULT_PAGINATION, DeletableEntityKind, Employee, EmployeeResponse, EntityDefinition, EntityId, EntityInput, EntityKind, EntityTypes, ErrorMessage, Extras, FetchByIdParams, FetchCategoriesParams, FetchEmployeesParams, FetchProductsParams, FetchPromotionsParams, FetchStoresParams, FitImageOptions, ImageSize, LookupDefinition, LookupKind, MERCHANT_COLOUR_KEYS, MERCHANT_FIELD_MAX_LENGTH, MERCHANT_IMAGE_SLOTS, MERCHANT_IMAGE_SLOT_KEYS, MERCHANT_LINK_KEYS, MERCHANT_LINK_PATHS, MERCHANT_OBJECT_FIELDS, MERCHANT_READ_ONLY_FIELDS, Merchant, MerchantColourKey, MerchantColourSet, MerchantColours, MerchantImageIds, MerchantImageSlot, MerchantImageSlotDefinition, MerchantLinkKey, MerchantLinks, MerchantPatch, MerchantResponse, MessageInfo, ParsedBasket, Product, ProductInstance, ProductInstanceInput, ProductInstances, ProductResponse, ProductSaveInput, Promotion, PromotionResponse, PromotionRuleSet, ReportData, ReportKey, ReportQuery, ReportQueryMap, ReportResponse, RepricedInstance, RequestOptions, ResourceDefinition, ResourceKind, SHOPWAVE_ENTITIES, SHOPWAVE_IMAGE_BASE_URL, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, SHOPWAVE_UPLOAD, Saved, SessionStatus, ShopwaveApiError, ShopwaveErrorMap, Store, StoreResponse, SubmitEntityArgs, SubmitEntityResponse, SuccessMessage, UPLOAD_KINDS, UPLOAD_PREFIXES, UpdateMerchantOptions, UploadImageParams, UploadKind, UploadMerchantImageOptions, UploadPrefix, UploadedImage, User, UserEmployee, UserResponse, WritableEntityKind, apiDelete, apiGet, apiRequest, apiResponse, apiSend, assertNoApiErrors, authorizationFor, buildBasketReportQuery, buildConsumerMap, collectConsumerIds, collectProductIds, combineBasketRows, computeBasketSummary, coverCrop, deleteCategory, deleteEmployee, deleteEntity, deleteEntityById, deleteProduct, deletePromotion, deleteStore, fetchCategories, fetchCategory, fetchConsumer, fetchConsumers, fetchEmployee, fetchEmployees, fetchEntityById, fetchMerchant, fetchProduct, fetchProductInstanceTags, fetchProductTags, fetchProducts, fetchProductsMap, fetchPromotion, fetchPromotions, fetchReport, fetchSession, fetchStore, fetchStores, fetchUser, findRepricedInstances, fitImageToSize, formatDateForQuery, getApiErrorMap, getApiErrors, getImageUrl, getMerchantImage, getMerchantImageUrl, imageFileName, isSameInstancePrice, isUploadKind, isUploadPrefix, loginPath, logout, logoutPath, merchantLinksFromForm, merchantLinksToForm, normalizeMerchantLinks, normalizeTagList, parseBasketReportData, productImageRole, readImageSize, rolesById, saveCategory, saveEmployee, saveEntities, saveEntity, saveProduct, savePromotion, saveStore, setMerchantImage, submitEntity, toProductInstancesForSave, toShopwaveApiError, toStoredImageIds, toStoredProductImages, updateMerchant, uploadImage, uploadMerchantImage, validateMerchant, withToken };
|
|
1228
1282
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/core/index.d.ts
CHANGED
|
@@ -676,6 +676,9 @@ declare function fetchEntityById<K extends EntityKind>(kind: K, id: EntityId, pa
|
|
|
676
676
|
* read) so an edited price is sent as a new instance. As a safeguard, a new
|
|
677
677
|
* product (no `id`, e.g. a duplicate) never sends instance ids: an id copied from
|
|
678
678
|
* another product would otherwise point the save at that product's instances.
|
|
679
|
+
*
|
|
680
|
+
* `images` is sent as file names ({@link toStoredProductImages}), so the URLs a
|
|
681
|
+
* read returns can be passed straight back; leaving `images` out keeps them.
|
|
679
682
|
*/
|
|
680
683
|
declare const saveProduct: (product: ProductSaveInput, options?: RequestOptions) => Promise<Saved<Product>>;
|
|
681
684
|
declare const deleteProduct: (id: EntityId, options?: RequestOptions) => Promise<void>;
|
|
@@ -844,20 +847,40 @@ declare const SHOPWAVE_RESOURCES: Readonly<Record<ResourceKind, ResourceDefiniti
|
|
|
844
847
|
type UploadKind = "merchant" | "merchantFeature" | "product" | "user" | "applicationLogo" | "applicationImages";
|
|
845
848
|
/** `UploadKind` → the API's `contentType` value. */
|
|
846
849
|
declare const UPLOAD_KINDS: Readonly<Record<UploadKind, string>>;
|
|
850
|
+
/**
|
|
851
|
+
* The role an image plays, sent to Shopwave as the uploader's `prefix` header.
|
|
852
|
+
* The uploader names the file `<prefix>_<hash>.<ext>`, so the role travels with
|
|
853
|
+
* the file wherever a record stores it (a product's `images`). Live, merchant
|
|
854
|
+
* 5644, 4 Nov 2026: all four values answered 201.
|
|
855
|
+
* - `product`: a product gallery image;
|
|
856
|
+
* - `product_thumbnail`: the product's lead image, shown in lists;
|
|
857
|
+
* - `variant` / `variant_thumbnail`: a variant's own image and its lead image
|
|
858
|
+
* (used by the Connect integrations).
|
|
859
|
+
*
|
|
860
|
+
* Values are the ones Connect's `uploadFileToShopwave` sends.
|
|
861
|
+
*/
|
|
862
|
+
type UploadPrefix = "product" | "product_thumbnail" | "variant" | "variant_thumbnail";
|
|
863
|
+
/** Every `UploadPrefix`, longest first so a name check never takes `product` for `product_thumbnail`. */
|
|
864
|
+
declare const UPLOAD_PREFIXES: ReadonlyArray<UploadPrefix>;
|
|
847
865
|
/** How uploads are addressed (app route and Shopwave uploader). */
|
|
848
866
|
declare const SHOPWAVE_UPLOAD: Readonly<{
|
|
849
|
-
/** App route: `POST /api/<route>` (multipart `file` + `kind`). */
|
|
867
|
+
/** App route: `POST /api/<route>` (multipart `file` + `kind`, optional `prefix`). */
|
|
850
868
|
route: "upload";
|
|
851
869
|
/** Shopwave path: `PUT {apiUrl}/uploader` (multipart `file`). */
|
|
852
870
|
upstream: "uploader";
|
|
853
871
|
/** Header that carries the upload kind upstream. */
|
|
854
872
|
kindHeader: "contentType";
|
|
873
|
+
/** Header that carries the image role upstream (see `UploadPrefix`). */
|
|
874
|
+
prefixHeader: "prefix";
|
|
855
875
|
/** Multipart field name for the file, on both sides. */
|
|
856
876
|
fileField: "file";
|
|
857
877
|
/** Multipart field name for the kind in the app request. */
|
|
858
878
|
kindField: "kind";
|
|
879
|
+
/** Multipart field name for the image role in the app request. */
|
|
880
|
+
prefixField: "prefix";
|
|
859
881
|
}>;
|
|
860
882
|
declare function isUploadKind(value: unknown): value is UploadKind;
|
|
883
|
+
declare function isUploadPrefix(value: unknown): value is UploadPrefix;
|
|
861
884
|
/**
|
|
862
885
|
* Read-only lists that aren't records: the merchant's distinct tags.
|
|
863
886
|
*
|
|
@@ -933,6 +956,12 @@ declare function fitImageToSize(file: Blob, width: number, height: number, optio
|
|
|
933
956
|
interface UploadImageParams {
|
|
934
957
|
/** What the image is for (sent to Shopwave as the uploader's `contentType`). */
|
|
935
958
|
kind: UploadKind;
|
|
959
|
+
/**
|
|
960
|
+
* The image's role (sent to Shopwave as the uploader's `prefix` header), e.g.
|
|
961
|
+
* `product_thumbnail` for a product's lead image. Leave it out for images
|
|
962
|
+
* without a role (merchant logos).
|
|
963
|
+
*/
|
|
964
|
+
prefix?: UploadPrefix;
|
|
936
965
|
/** File name to send when `file` is a Blob without one. Defaults to `File.name`, else `"upload"`. */
|
|
937
966
|
fileName?: string;
|
|
938
967
|
}
|
|
@@ -1224,5 +1253,30 @@ interface UserResponse {
|
|
|
1224
1253
|
/** Reads the logged-in user, or `null` when the API returns none. */
|
|
1225
1254
|
declare function fetchUser(options?: RequestOptions): Promise<User | null>;
|
|
1226
1255
|
//#endregion
|
|
1227
|
-
|
|
1256
|
+
//#region src/core/productImages.d.ts
|
|
1257
|
+
/**
|
|
1258
|
+
* Product images, as the live API stores them (merchant 5644, 4 Nov 2026):
|
|
1259
|
+
* - A product's `images` is a list. **Reads return full URLs**
|
|
1260
|
+
* (`http://static.merchantstack.com/images/merchant/<id>/product/<file>`);
|
|
1261
|
+
* **writes take the uploader's file names** ({@link toStoredProductImages};
|
|
1262
|
+
* `saveProduct` does this for you).
|
|
1263
|
+
* - The uploader takes one file per request. With a `prefix` (see
|
|
1264
|
+
* `UploadPrefix`) it names the file `<prefix>_<hash>.<ext>`
|
|
1265
|
+
* (`product_thumbnail_1bdd…41090b.png`); without one, `<hash>.<ext>`. So an
|
|
1266
|
+
* image's role can be read back from its name ({@link productImageRole}).
|
|
1267
|
+
*/
|
|
1268
|
+
/**
|
|
1269
|
+
* The role in an image's file name or URL, from the uploader's `prefix`:
|
|
1270
|
+
* `"…/product_thumbnail_1bdd.png"` → `"product_thumbnail"`. `null` for a name
|
|
1271
|
+
* without one (images uploaded without a prefix, e.g. before prefixes existed).
|
|
1272
|
+
*/
|
|
1273
|
+
declare function productImageRole(value: unknown): UploadPrefix | null;
|
|
1274
|
+
/**
|
|
1275
|
+
* A product's `images` as the API takes them on a save: file names, not the
|
|
1276
|
+
* URLs a read returns. Non-strings, blanks and duplicates are dropped; the
|
|
1277
|
+
* order is kept.
|
|
1278
|
+
*/
|
|
1279
|
+
declare function toStoredProductImages(images: unknown): string[];
|
|
1280
|
+
//#endregion
|
|
1281
|
+
export { Basket, BasketFilters, BasketItem, BasketPagination, BasketReportRow, BasketSummary, Category, CategoryResponse, CombineBasketRowsParams, Consumer, ConsumerResponse, CropRect, DEFAULT_BASKET_FILTERS, DEFAULT_PAGINATION, DeletableEntityKind, Employee, EmployeeResponse, EntityDefinition, EntityId, EntityInput, EntityKind, EntityTypes, ErrorMessage, Extras, FetchByIdParams, FetchCategoriesParams, FetchEmployeesParams, FetchProductsParams, FetchPromotionsParams, FetchStoresParams, FitImageOptions, ImageSize, LookupDefinition, LookupKind, MERCHANT_COLOUR_KEYS, MERCHANT_FIELD_MAX_LENGTH, MERCHANT_IMAGE_SLOTS, MERCHANT_IMAGE_SLOT_KEYS, MERCHANT_LINK_KEYS, MERCHANT_LINK_PATHS, MERCHANT_OBJECT_FIELDS, MERCHANT_READ_ONLY_FIELDS, Merchant, MerchantColourKey, MerchantColourSet, MerchantColours, MerchantImageIds, MerchantImageSlot, MerchantImageSlotDefinition, MerchantLinkKey, MerchantLinks, MerchantPatch, MerchantResponse, MessageInfo, ParsedBasket, Product, ProductInstance, ProductInstanceInput, ProductInstances, ProductResponse, ProductSaveInput, Promotion, PromotionResponse, PromotionRuleSet, ReportData, ReportKey, ReportQuery, ReportQueryMap, ReportResponse, RepricedInstance, RequestOptions, ResourceDefinition, ResourceKind, SHOPWAVE_ENTITIES, SHOPWAVE_IMAGE_BASE_URL, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, SHOPWAVE_UPLOAD, Saved, SessionStatus, ShopwaveApiError, ShopwaveErrorMap, Store, StoreResponse, SubmitEntityArgs, SubmitEntityResponse, SuccessMessage, UPLOAD_KINDS, UPLOAD_PREFIXES, UpdateMerchantOptions, UploadImageParams, UploadKind, UploadMerchantImageOptions, UploadPrefix, UploadedImage, User, UserEmployee, UserResponse, WritableEntityKind, apiDelete, apiGet, apiRequest, apiResponse, apiSend, assertNoApiErrors, authorizationFor, buildBasketReportQuery, buildConsumerMap, collectConsumerIds, collectProductIds, combineBasketRows, computeBasketSummary, coverCrop, deleteCategory, deleteEmployee, deleteEntity, deleteEntityById, deleteProduct, deletePromotion, deleteStore, fetchCategories, fetchCategory, fetchConsumer, fetchConsumers, fetchEmployee, fetchEmployees, fetchEntityById, fetchMerchant, fetchProduct, fetchProductInstanceTags, fetchProductTags, fetchProducts, fetchProductsMap, fetchPromotion, fetchPromotions, fetchReport, fetchSession, fetchStore, fetchStores, fetchUser, findRepricedInstances, fitImageToSize, formatDateForQuery, getApiErrorMap, getApiErrors, getImageUrl, getMerchantImage, getMerchantImageUrl, imageFileName, isSameInstancePrice, isUploadKind, isUploadPrefix, loginPath, logout, logoutPath, merchantLinksFromForm, merchantLinksToForm, normalizeMerchantLinks, normalizeTagList, parseBasketReportData, productImageRole, readImageSize, rolesById, saveCategory, saveEmployee, saveEntities, saveEntity, saveProduct, savePromotion, saveStore, setMerchantImage, submitEntity, toProductInstancesForSave, toShopwaveApiError, toStoredImageIds, toStoredProductImages, updateMerchant, uploadImage, uploadMerchantImage, validateMerchant, withToken };
|
|
1228
1282
|
//# sourceMappingURL=index.d.ts.map
|