@rebuy/rebuy 3.16.2 → 3.16.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.
|
@@ -16,8 +16,9 @@ export type DataSourceResults = {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const buildEngineParams: (input: DataSourceInput, key: string) => Record<string, unknown>;
|
|
18
18
|
/**
|
|
19
|
-
* Evaluates a data source against the live cart: resolves the shop's publishable key,
|
|
20
|
-
* endpoint with the translated params,
|
|
21
|
-
*
|
|
19
|
+
* Evaluates a data source against the live cart: resolves the shop's publishable key, calls the engine
|
|
20
|
+
* endpoint with the translated params (a GET, or a JSON POST once the request line would exceed
|
|
21
|
+
* {@link MAX_REQUEST_LINE_BYTES}), and returns camelCased, id-deduplicated products plus rule metadata.
|
|
22
|
+
* `limit: 0` returns metadata only.
|
|
22
23
|
*/
|
|
23
24
|
export declare const fetchDataSourceResults: (input: DataSourceInput, ctx: ServerContext) => Promise<DataSourceResults>;
|
package/dist/server/index.cjs
CHANGED
|
@@ -3970,20 +3970,19 @@ var reportUnreadableVerdict = (metadata, report) => {
|
|
|
3970
3970
|
report?.({ detail: "rule verdict lacks readable custom.shouldShow", kind: "ruleVerdict" });
|
|
3971
3971
|
};
|
|
3972
3972
|
var dedupeById = (products) => (0, import_es_toolkit6.uniqBy)(products, (product) => product.id);
|
|
3973
|
+
var MAX_REQUEST_LINE_BYTES = 32e3;
|
|
3974
|
+
var requestLineBytes = (path, search) => new TextEncoder().encode(`GET ${path}?${search} HTTP/1.1`).length;
|
|
3973
3975
|
var fetchDataSourceResults = async (input, ctx) => {
|
|
3974
3976
|
const { shop } = await fetchUserConfig({ shop: input.shop }, ctx);
|
|
3975
3977
|
const locale = input.language?.split("-")[0]?.toLowerCase();
|
|
3976
3978
|
const marketParams = shop.markets.enabled ? { ...input.country && { country_code: input.country }, ...locale && { locale } } : {};
|
|
3979
|
+
const path = `/api/v1${input.dataSourcePath}`;
|
|
3980
|
+
const engineParams = { ...buildEngineParams(input, shop.apiKey), ...marketParams };
|
|
3981
|
+
const search = serialize(engineParams);
|
|
3982
|
+
const transport = requestLineBytes(path, search) > MAX_REQUEST_LINE_BYTES ? { body: engineParams, method: "POST" } : { search };
|
|
3977
3983
|
let upstream;
|
|
3978
3984
|
try {
|
|
3979
|
-
upstream = await ctx.fetchUpstream(
|
|
3980
|
-
`/api/v1${input.dataSourcePath}`,
|
|
3981
|
-
{},
|
|
3982
|
-
{
|
|
3983
|
-
host: ctx.host,
|
|
3984
|
-
search: serialize({ ...buildEngineParams(input, shop.apiKey), ...marketParams })
|
|
3985
|
-
}
|
|
3986
|
-
);
|
|
3985
|
+
upstream = await ctx.fetchUpstream(path, {}, { host: ctx.host, ...transport });
|
|
3987
3986
|
} catch (err) {
|
|
3988
3987
|
if (err instanceof UpstreamError && (err.status === 404 || err.status === 410)) {
|
|
3989
3988
|
throw new NotFoundError(`Data source not found: ${input.dataSourcePath}`);
|
package/dist/server/index.mjs
CHANGED
|
@@ -3922,20 +3922,19 @@ var reportUnreadableVerdict = (metadata, report) => {
|
|
|
3922
3922
|
report?.({ detail: "rule verdict lacks readable custom.shouldShow", kind: "ruleVerdict" });
|
|
3923
3923
|
};
|
|
3924
3924
|
var dedupeById = (products) => uniqBy2(products, (product) => product.id);
|
|
3925
|
+
var MAX_REQUEST_LINE_BYTES = 32e3;
|
|
3926
|
+
var requestLineBytes = (path, search) => new TextEncoder().encode(`GET ${path}?${search} HTTP/1.1`).length;
|
|
3925
3927
|
var fetchDataSourceResults = async (input, ctx) => {
|
|
3926
3928
|
const { shop } = await fetchUserConfig({ shop: input.shop }, ctx);
|
|
3927
3929
|
const locale = input.language?.split("-")[0]?.toLowerCase();
|
|
3928
3930
|
const marketParams = shop.markets.enabled ? { ...input.country && { country_code: input.country }, ...locale && { locale } } : {};
|
|
3931
|
+
const path = `/api/v1${input.dataSourcePath}`;
|
|
3932
|
+
const engineParams = { ...buildEngineParams(input, shop.apiKey), ...marketParams };
|
|
3933
|
+
const search = serialize(engineParams);
|
|
3934
|
+
const transport = requestLineBytes(path, search) > MAX_REQUEST_LINE_BYTES ? { body: engineParams, method: "POST" } : { search };
|
|
3929
3935
|
let upstream;
|
|
3930
3936
|
try {
|
|
3931
|
-
upstream = await ctx.fetchUpstream(
|
|
3932
|
-
`/api/v1${input.dataSourcePath}`,
|
|
3933
|
-
{},
|
|
3934
|
-
{
|
|
3935
|
-
host: ctx.host,
|
|
3936
|
-
search: serialize({ ...buildEngineParams(input, shop.apiKey), ...marketParams })
|
|
3937
|
-
}
|
|
3938
|
-
);
|
|
3937
|
+
upstream = await ctx.fetchUpstream(path, {}, { host: ctx.host, ...transport });
|
|
3939
3938
|
} catch (err) {
|
|
3940
3939
|
if (err instanceof UpstreamError && (err.status === 404 || err.status === 410)) {
|
|
3941
3940
|
throw new NotFoundError(`Data source not found: ${input.dataSourcePath}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.16.
|
|
3
|
+
"version": "3.16.3",
|
|
4
4
|
"description": "Shared zod schemas, legacy-to-CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers (rebuy-api, admin-nextjs, rebuy-shopify-extensions)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rebuy, Inc.",
|