@getlupa/vue 0.25.3 → 0.25.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.
@@ -5796,6 +5796,16 @@ const relatedQueries = (queryKey, query, environment, customBaseUrl, customParam
5796
5796
  const errors = yield res.json();
5797
5797
  return { success: false, errors };
5798
5798
  });
5799
+ const relatedQueriesCustom = (query, options) => __async(null, null, function* () {
5800
+ var _a25;
5801
+ const res = yield fetch(options.customUrl, Object.assign(Object.assign({}, customRequestConfig({ customHeaders: options.customHeaders })), { body: JSON.stringify(Object.assign({ publicQuery: query }, (_a25 = options.customPayload) !== null && _a25 !== void 0 ? _a25 : {})) }));
5802
+ if (res.status < 400) {
5803
+ const data = yield res.json();
5804
+ return Object.assign(Object.assign({}, data), { success: true });
5805
+ }
5806
+ const errors = yield res.json();
5807
+ return { success: false, errors };
5808
+ });
5799
5809
  const queryByIds = (queryKey, ids, environment, customBaseUrl, customParams) => __async(null, null, function* () {
5800
5810
  const idParam = ids.map((id) => `ids=${id}`).join("&");
5801
5811
  const endpoint = `${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}/ids?${idParam}`;
@@ -6018,6 +6028,10 @@ const LupaSearchSdk = {
6018
6028
  return transformSearchQueryRefinersResult(result2, options);
6019
6029
  }),
6020
6030
  queryRelated: (queryKey, publicQuery, options = null) => __async(null, null, function* () {
6031
+ if (options === null || options === void 0 ? void 0 : options.customUrl) {
6032
+ const result3 = yield relatedQueriesCustom(publicQuery, options);
6033
+ return transformRelatedQueries(result3, options);
6034
+ }
6021
6035
  const result2 = yield relatedQueries(queryKey, publicQuery, (options === null || options === void 0 ? void 0 : options.environment) || "production", options === null || options === void 0 ? void 0 : options.customBaseUrl, options === null || options === void 0 ? void 0 : options.customParams);
6022
6036
  return transformRelatedQueries(result2, options);
6023
6037
  }),
@@ -32622,23 +32636,20 @@ const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
32622
32636
  return;
32623
32637
  }
32624
32638
  LupaSearchSdk.query(props.options.queryKey, query2, props.options.options).then((res) => {
32625
- var _a25, _b25, _c;
32639
+ var _a25, _b25, _c, _d, _e, _f, _g;
32626
32640
  if (res.success) {
32627
32641
  handleResults({ queryKey: props.options.queryKey, results: res });
32628
32642
  searchResultStore.add(requestId, __spreadValues({}, res));
32629
32643
  searchResultStore.setRelatedQueriesApiEnabled((_a25 = res.hasRelatedQueries) != null ? _a25 : false);
32630
32644
  if (res.hasRelatedQueries && Boolean(props.options.relatedQueries)) {
32631
- searchResultStore.queryRelatedQueries(
32632
- props.options.queryKey,
32633
- publicQuery,
32634
- res,
32635
- props.options.options
32636
- );
32645
+ searchResultStore.queryRelatedQueries(props.options.queryKey, publicQuery, res, __spreadProps(__spreadValues({}, (_c = (_b25 = props.options) == null ? void 0 : _b25.options) != null ? _c : {}), {
32646
+ customUrl: ((_e = (_d = props.options) == null ? void 0 : _d.options) == null ? void 0 : _e.customRelatedQueriesUrl) || void 0
32647
+ }));
32637
32648
  }
32638
32649
  if (props.options.splitExpensiveRequests && res.refinementThreshold >= res.total) {
32639
32650
  queryRefiners(requestId, publicQuery);
32640
32651
  }
32641
- } else if ((_c = (_b25 = props.options) == null ? void 0 : _b25.options) == null ? void 0 : _c.onError) {
32652
+ } else if ((_g = (_f = props.options) == null ? void 0 : _f.options) == null ? void 0 : _g.onError) {
32642
32653
  props.options.options.onError(res);
32643
32654
  }
32644
32655
  }).catch((err) => {
@@ -5794,6 +5794,16 @@ const relatedQueries = (queryKey, query, environment, customBaseUrl, customParam
5794
5794
  const errors = yield res.json();
5795
5795
  return { success: false, errors };
5796
5796
  });
5797
+ const relatedQueriesCustom = (query, options) => __async(null, null, function* () {
5798
+ var _a25;
5799
+ const res = yield fetch(options.customUrl, Object.assign(Object.assign({}, customRequestConfig({ customHeaders: options.customHeaders })), { body: JSON.stringify(Object.assign({ publicQuery: query }, (_a25 = options.customPayload) !== null && _a25 !== void 0 ? _a25 : {})) }));
5800
+ if (res.status < 400) {
5801
+ const data = yield res.json();
5802
+ return Object.assign(Object.assign({}, data), { success: true });
5803
+ }
5804
+ const errors = yield res.json();
5805
+ return { success: false, errors };
5806
+ });
5797
5807
  const queryByIds = (queryKey, ids, environment, customBaseUrl, customParams) => __async(null, null, function* () {
5798
5808
  const idParam = ids.map((id) => `ids=${id}`).join("&");
5799
5809
  const endpoint = `${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}/ids?${idParam}`;
@@ -6016,6 +6026,10 @@ const LupaSearchSdk = {
6016
6026
  return transformSearchQueryRefinersResult(result2, options);
6017
6027
  }),
6018
6028
  queryRelated: (queryKey, publicQuery, options = null) => __async(null, null, function* () {
6029
+ if (options === null || options === void 0 ? void 0 : options.customUrl) {
6030
+ const result3 = yield relatedQueriesCustom(publicQuery, options);
6031
+ return transformRelatedQueries(result3, options);
6032
+ }
6019
6033
  const result2 = yield relatedQueries(queryKey, publicQuery, (options === null || options === void 0 ? void 0 : options.environment) || "production", options === null || options === void 0 ? void 0 : options.customBaseUrl, options === null || options === void 0 ? void 0 : options.customParams);
6020
6034
  return transformRelatedQueries(result2, options);
6021
6035
  }),
@@ -32620,23 +32634,20 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
32620
32634
  return;
32621
32635
  }
32622
32636
  LupaSearchSdk.query(props.options.queryKey, query2, props.options.options).then((res) => {
32623
- var _a25, _b25, _c;
32637
+ var _a25, _b25, _c, _d, _e, _f, _g;
32624
32638
  if (res.success) {
32625
32639
  handleResults({ queryKey: props.options.queryKey, results: res });
32626
32640
  searchResultStore.add(requestId, __spreadValues({}, res));
32627
32641
  searchResultStore.setRelatedQueriesApiEnabled((_a25 = res.hasRelatedQueries) != null ? _a25 : false);
32628
32642
  if (res.hasRelatedQueries && Boolean(props.options.relatedQueries)) {
32629
- searchResultStore.queryRelatedQueries(
32630
- props.options.queryKey,
32631
- publicQuery,
32632
- res,
32633
- props.options.options
32634
- );
32643
+ searchResultStore.queryRelatedQueries(props.options.queryKey, publicQuery, res, __spreadProps(__spreadValues({}, (_c = (_b25 = props.options) == null ? void 0 : _b25.options) != null ? _c : {}), {
32644
+ customUrl: ((_e = (_d = props.options) == null ? void 0 : _d.options) == null ? void 0 : _e.customRelatedQueriesUrl) || void 0
32645
+ }));
32635
32646
  }
32636
32647
  if (props.options.splitExpensiveRequests && res.refinementThreshold >= res.total) {
32637
32648
  queryRefiners(requestId, publicQuery);
32638
32649
  }
32639
- } else if ((_c = (_b25 = props.options) == null ? void 0 : _b25.options) == null ? void 0 : _c.onError) {
32650
+ } else if ((_g = (_f = props.options) == null ? void 0 : _f.options) == null ? void 0 : _g.onError) {
32640
32651
  props.options.options.onError(res);
32641
32652
  }
32642
32653
  }).catch((err) => {
@@ -5,6 +5,7 @@ export type SdkOptions = {
5
5
  environment: SdkEnvironment;
6
6
  customBaseUrl?: string;
7
7
  customUrl?: string;
8
+ customRelatedQueriesUrl?: string;
8
9
  customPayload?: Record<string, unknown>;
9
10
  customHeaders?: Record<string, string>;
10
11
  customParams?: Record<string, string | string[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.25.3",
3
+ "version": "0.25.4",
4
4
  "main": "dist/lupaSearch.mjs",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "vue": "^3.0.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@getlupa/client-sdk": "^1.10.2",
26
+ "@getlupa/client-sdk": "^1.11.0",
27
27
  "@pinia/testing": "^1.0.2",
28
28
  "@rollup/plugin-babel": "^6.0.4",
29
29
  "@rollup/plugin-commonjs": "^28.0.6",