@jay-framework/wix-stores-v1 0.24.2 → 0.24.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/dist/index.d.ts CHANGED
@@ -902,19 +902,4 @@ declare const categoryPage: _jay_framework_fullstack_component.JayStackComponent
902
902
 
903
903
  declare const init: _jay_framework_fullstack_component.JayInit<WixStoresV1InitData>;
904
904
 
905
- /**
906
- * Setup handler for wix-stores-v1 plugin.
907
- * Validates that the Wix Stores app is installed by querying products.
908
- */
909
- interface PluginSetupContext {
910
- configDir: string;
911
- projectRoot: string;
912
- initError?: Error;
913
- }
914
- interface PluginSetupResult {
915
- status: 'configured' | 'needs-config' | 'error';
916
- message?: string;
917
- }
918
- declare function setupWixStoresV1(ctx: PluginSetupContext): Promise<PluginSetupResult>;
919
-
920
- export { type CollectionPageParams, type CollectionViewState, type GetProductBySlugInput, type PriceAggregationData, type PriceRangeBucket, type ProductPageParams, type ProductSearchFilters, type ProductSortField, type SearchProductsInput, type SearchProductsOutput, type V1Collection, WIX_STORES_V1_CONTEXT, WIX_STORES_V1_SERVICE_MARKER, type WixStoresV1Context, type WixStoresV1InitData, type WixStoresV1Service, categoryList, categoryPage, collectionList, collectionPage, getCollections, getProductBySlug, init, productPage, productSearch, provideWixStoresV1Service, searchProducts, setupWixStoresV1 };
905
+ export { type CollectionPageParams, type CollectionViewState, type GetProductBySlugInput, type PriceAggregationData, type PriceRangeBucket, type ProductPageParams, type ProductSearchFilters, type ProductSortField, type SearchProductsInput, type SearchProductsOutput, type V1Collection, WIX_STORES_V1_CONTEXT, WIX_STORES_V1_SERVICE_MARKER, type WixStoresV1Context, type WixStoresV1InitData, type WixStoresV1Service, categoryList, categoryPage, collectionList, collectionPage, getCollections, getProductBySlug, init, productPage, productSearch, provideWixStoresV1Service, searchProducts };
package/dist/index.js CHANGED
@@ -1,48 +1,10 @@
1
1
  import { WIX_CART_CONTEXT, WIX_CART_SERVICE, cartIndicator, cartPage, provideWixCartContext, provideWixCartService } from "@jay-framework/wix-cart";
2
- import { createJayService, makeJayQuery, ActionError, makeJayStackComponent, RenderPipeline, makeJayInit } from "@jay-framework/fullstack-component";
3
- import { registerService, getService } from "@jay-framework/stack-server-runtime";
2
+ import { W as WIX_STORES_V1_SERVICE_MARKER, q as queryProducts, p as provideWixStoresV1Service } from "./query-products-CXhRabj0.js";
4
3
  import { createJayContext } from "@jay-framework/runtime";
5
4
  import "@jay-framework/component";
6
5
  import { wixFetch, WIX_CLIENT_SERVICE } from "@jay-framework/wix-server-client";
7
- const WIX_STORES_V1_SERVICE_MARKER = createJayService("Wix Store V1 Service");
8
- function provideWixStoresV1Service(wixClient) {
9
- const service = { wixClient };
10
- registerService(WIX_STORES_V1_SERVICE_MARKER, service);
11
- return service;
12
- }
13
- function normalizeProduct(product) {
14
- const p = { ...product };
15
- const raw = product;
16
- if (raw.id && !p._id) {
17
- p._id = raw.id;
18
- }
19
- return p;
20
- }
21
- async function queryProducts(client, request) {
22
- const query = {};
23
- if (request?.filter) query.filter = JSON.stringify(request.filter);
24
- if (request?.sort) {
25
- const v1Sort = request.sort.map((s) => ({
26
- [s.fieldName]: (s.order || "ASC").toLowerCase()
27
- }));
28
- query.sort = JSON.stringify(v1Sort);
29
- }
30
- if (request?.paging) query.paging = request.paging;
31
- const result = await wixFetch(client, "/stores/v1/products/query", {
32
- method: "POST",
33
- body: {
34
- query,
35
- includeVariants: request?.includeVariants ?? true,
36
- includeMerchantSpecificData: request?.includeMerchantSpecificData ?? true
37
- }
38
- });
39
- if (result.products) {
40
- result.products = result.products.map(
41
- (p) => normalizeProduct(p)
42
- );
43
- }
44
- return result;
45
- }
6
+ import { makeJayQuery, ActionError, makeJayStackComponent, RenderPipeline, makeJayInit } from "@jay-framework/fullstack-component";
7
+ import { getService } from "@jay-framework/stack-server-runtime";
46
8
  function normalizeCollection(col) {
47
9
  const c = { ...col };
48
10
  if (col.id && !c._id) {
@@ -921,37 +883,6 @@ const init = makeJayInit().withServer(async () => {
921
883
  enableClientSearch: true
922
884
  };
923
885
  });
924
- async function setupWixStoresV1(ctx) {
925
- if (ctx.initError) {
926
- return {
927
- status: "error",
928
- message: `Service init failed (is wix-server-client configured?). ${ctx.initError.message}`
929
- };
930
- }
931
- let service;
932
- try {
933
- service = getService(WIX_STORES_V1_SERVICE_MARKER);
934
- } catch {
935
- return {
936
- status: "error",
937
- message: "WixStoresV1Service not available. Run setup for wix-server-client first."
938
- };
939
- }
940
- try {
941
- await queryProducts(service.wixClient, { paging: { limit: 1 } });
942
- } catch (e) {
943
- const msg = e.message || "";
944
- const hint = msg.includes("404") || msg.includes("not found") ? "Wix Stores may not be installed on this site" : msg.includes("403") || msg.includes("permission") ? "API key may lack Wix Stores permissions" : "This package requires the Stores Catalog V1 API — if using Catalog V3, use @jay-framework/wix-stores instead";
945
- return {
946
- status: "error",
947
- message: `Wix Stores V1 API check failed: ${hint}. (${msg})`
948
- };
949
- }
950
- return {
951
- status: "configured",
952
- message: "Wix Stores V1 connected"
953
- };
954
- }
955
886
  export {
956
887
  WIX_CART_CONTEXT,
957
888
  WIX_CART_SERVICE,
@@ -971,6 +902,5 @@ export {
971
902
  provideWixCartContext,
972
903
  provideWixCartService,
973
904
  provideWixStoresV1Service,
974
- searchProducts,
975
- setupWixStoresV1
905
+ searchProducts
976
906
  };
@@ -0,0 +1,47 @@
1
+ import { createJayService } from "@jay-framework/fullstack-component";
2
+ import { registerService } from "@jay-framework/stack-server-runtime";
3
+ import { wixFetch } from "@jay-framework/wix-server-client";
4
+ const WIX_STORES_V1_SERVICE_MARKER = createJayService("Wix Store V1 Service");
5
+ function provideWixStoresV1Service(wixClient) {
6
+ const service = { wixClient };
7
+ registerService(WIX_STORES_V1_SERVICE_MARKER, service);
8
+ return service;
9
+ }
10
+ function normalizeProduct(product) {
11
+ const p = { ...product };
12
+ const raw = product;
13
+ if (raw.id && !p._id) {
14
+ p._id = raw.id;
15
+ }
16
+ return p;
17
+ }
18
+ async function queryProducts(client, request) {
19
+ const query = {};
20
+ if (request?.filter) query.filter = JSON.stringify(request.filter);
21
+ if (request?.sort) {
22
+ const v1Sort = request.sort.map((s) => ({
23
+ [s.fieldName]: (s.order || "ASC").toLowerCase()
24
+ }));
25
+ query.sort = JSON.stringify(v1Sort);
26
+ }
27
+ if (request?.paging) query.paging = request.paging;
28
+ const result = await wixFetch(client, "/stores/v1/products/query", {
29
+ method: "POST",
30
+ body: {
31
+ query,
32
+ includeVariants: request?.includeVariants ?? true,
33
+ includeMerchantSpecificData: request?.includeMerchantSpecificData ?? true
34
+ }
35
+ });
36
+ if (result.products) {
37
+ result.products = result.products.map(
38
+ (p) => normalizeProduct(p)
39
+ );
40
+ }
41
+ return result;
42
+ }
43
+ export {
44
+ WIX_STORES_V1_SERVICE_MARKER as W,
45
+ provideWixStoresV1Service as p,
46
+ queryProducts as q
47
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Setup handler for wix-stores-v1 plugin.
3
+ * Validates that the Wix Stores app is installed by querying products.
4
+ */
5
+ interface PluginSetupContext {
6
+ configDir: string;
7
+ projectRoot: string;
8
+ initError?: Error;
9
+ }
10
+ interface PluginSetupResult {
11
+ status: 'configured' | 'needs-config' | 'error';
12
+ message?: string;
13
+ }
14
+ declare function setupWixStoresV1(ctx: PluginSetupContext): Promise<PluginSetupResult>;
15
+
16
+ export { setupWixStoresV1 };
package/dist/tools.js ADDED
@@ -0,0 +1,37 @@
1
+ import { getService } from "@jay-framework/stack-server-runtime";
2
+ import { W as WIX_STORES_V1_SERVICE_MARKER, q as queryProducts } from "./query-products-CXhRabj0.js";
3
+ import "@jay-framework/wix-server-client";
4
+ async function setupWixStoresV1(ctx) {
5
+ if (ctx.initError) {
6
+ return {
7
+ status: "error",
8
+ message: `Service init failed (is wix-server-client configured?). ${ctx.initError.message}`
9
+ };
10
+ }
11
+ let service;
12
+ try {
13
+ service = getService(WIX_STORES_V1_SERVICE_MARKER);
14
+ } catch {
15
+ return {
16
+ status: "error",
17
+ message: "WixStoresV1Service not available. Run setup for wix-server-client first."
18
+ };
19
+ }
20
+ try {
21
+ await queryProducts(service.wixClient, { paging: { limit: 1 } });
22
+ } catch (e) {
23
+ const msg = e.message || "";
24
+ const hint = msg.includes("404") || msg.includes("not found") ? "Wix Stores may not be installed on this site" : msg.includes("403") || msg.includes("permission") ? "API key may lack Wix Stores permissions" : "This package requires the Stores Catalog V1 API — if using Catalog V3, use @jay-framework/wix-stores instead";
25
+ return {
26
+ status: "error",
27
+ message: `Wix Stores V1 API check failed: ${hint}. (${msg})`
28
+ };
29
+ }
30
+ return {
31
+ status: "configured",
32
+ message: "Wix Stores V1 connected"
33
+ };
34
+ }
35
+ export {
36
+ setupWixStoresV1
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/wix-stores-v1",
3
- "version": "0.24.2",
3
+ "version": "0.24.3",
4
4
  "type": "module",
5
5
  "description": "Wix Stores Catalog V1 API client for Jay Framework",
6
6
  "license": "Apache-2.0",
@@ -12,6 +12,7 @@
12
12
  "exports": {
13
13
  ".": "./dist/index.js",
14
14
  "./client": "./dist/index.client.js",
15
+ "./tools": "./dist/tools.js",
15
16
  "./plugin.yaml": "./plugin.yaml",
16
17
  "./product-page.jay-contract": "./dist/contracts/product-page.jay-contract",
17
18
  "./product-search.jay-contract": "./dist/contracts/product-search.jay-contract",
@@ -28,32 +29,32 @@
28
29
  "build:client": "vite build",
29
30
  "build:server": "vite build --ssr",
30
31
  "build:copy-contract": "mkdir -p dist/contracts && cp lib/contracts/*.jay-contract* dist/contracts/ && mkdir -p dist/actions && cp lib/actions/*.jay-action dist/actions/",
31
- "build:types": "tsup lib/index.ts --dts-only --format esm",
32
+ "build:types": "tsup lib/index.ts lib/tools.ts --dts-only --format esm",
32
33
  "build:check-types": "tsc",
33
34
  "clean": "rimraf dist",
34
35
  "confirm": "npm run clean && npm run build && npm run test",
35
36
  "test": ":"
36
37
  },
37
38
  "dependencies": {
38
- "@jay-framework/component": "^0.24.2",
39
- "@jay-framework/fullstack-component": "^0.24.2",
40
- "@jay-framework/reactive": "^0.24.2",
41
- "@jay-framework/runtime": "^0.24.2",
42
- "@jay-framework/secure": "^0.24.2",
43
- "@jay-framework/stack-client-runtime": "^0.24.2",
44
- "@jay-framework/stack-server-runtime": "^0.24.2",
45
- "@jay-framework/wix-cart": "^0.24.2",
46
- "@jay-framework/wix-server-client": "^0.24.2",
47
- "@jay-framework/wix-utils": "^0.24.2",
39
+ "@jay-framework/component": "^0.24.3",
40
+ "@jay-framework/fullstack-component": "^0.24.3",
41
+ "@jay-framework/reactive": "^0.24.3",
42
+ "@jay-framework/runtime": "^0.24.3",
43
+ "@jay-framework/secure": "^0.24.3",
44
+ "@jay-framework/stack-client-runtime": "^0.24.3",
45
+ "@jay-framework/stack-server-runtime": "^0.24.3",
46
+ "@jay-framework/wix-cart": "^0.24.3",
47
+ "@jay-framework/wix-server-client": "^0.24.3",
48
+ "@jay-framework/wix-utils": "^0.24.3",
48
49
  "@wix/sdk": "^1.21.5"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@babel/core": "^7.23.7",
52
53
  "@babel/preset-env": "^7.23.8",
53
54
  "@babel/preset-typescript": "^7.23.3",
54
- "@jay-framework/compiler-jay-stack": "^0.24.2",
55
- "@jay-framework/jay-cli": "^0.24.2",
56
- "@jay-framework/vite-plugin": "^0.24.2",
55
+ "@jay-framework/compiler-jay-stack": "^0.24.3",
56
+ "@jay-framework/jay-cli": "^0.24.3",
57
+ "@jay-framework/vite-plugin": "^0.24.3",
57
58
  "nodemon": "^3.0.3",
58
59
  "rimraf": "^5.0.5",
59
60
  "tslib": "^2.6.2",