@surfside/ads-core 2.0.15 → 2.0.17
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/lib/cjs/Api.js +18 -11
- package/lib/cjs/Api.js.map +1 -1
- package/lib/cjs/BuildInfo.js +1 -1
- package/lib/cjs/BuildInfo.js.map +1 -1
- package/lib/cjs/helpers/Handlebars.js +130 -39
- package/lib/cjs/helpers/Handlebars.js.map +1 -1
- package/lib/cjs/helpers/RequestBuilder.js +1 -1
- package/lib/cjs/helpers/RequestBuilder.js.map +1 -1
- package/lib/cjs/helpers/response/Clickthrough.js +4 -1
- package/lib/cjs/helpers/response/Clickthrough.js.map +1 -1
- package/lib/cjs/helpers/response/ProductCard.js +5 -2
- package/lib/cjs/helpers/response/ProductCard.js.map +1 -1
- package/lib/cjs/services/Bidder.js.map +1 -1
- package/lib/cjs/services/BotFiltering.js +43 -0
- package/lib/cjs/services/BotFiltering.js.map +1 -0
- package/lib/cjs/services/Configuration.js +21 -11
- package/lib/cjs/services/Configuration.js.map +1 -1
- package/lib/cjs/services/Memo.js +0 -5
- package/lib/cjs/services/Memo.js.map +1 -1
- package/lib/cjs/services/Product.js +28 -6
- package/lib/cjs/services/Product.js.map +1 -1
- package/lib/cjs/services/Recommender.js +11 -10
- package/lib/cjs/services/Recommender.js.map +1 -1
- package/lib/cjs/services/Template.js +2 -2
- package/lib/cjs/services/Template.js.map +1 -1
- package/lib/esm/Api.js +19 -12
- package/lib/esm/Api.js.map +1 -1
- package/lib/esm/BuildInfo.js +1 -1
- package/lib/esm/BuildInfo.js.map +1 -1
- package/lib/esm/helpers/Handlebars.js +122 -36
- package/lib/esm/helpers/Handlebars.js.map +1 -1
- package/lib/esm/helpers/RequestBuilder.js +1 -1
- package/lib/esm/helpers/RequestBuilder.js.map +1 -1
- package/lib/esm/helpers/response/Clickthrough.js +4 -1
- package/lib/esm/helpers/response/Clickthrough.js.map +1 -1
- package/lib/esm/helpers/response/ProductCard.js +5 -2
- package/lib/esm/helpers/response/ProductCard.js.map +1 -1
- package/lib/esm/services/Bidder.js.map +1 -1
- package/lib/esm/services/BotFiltering.js +38 -0
- package/lib/esm/services/BotFiltering.js.map +1 -0
- package/lib/esm/services/Configuration.js +4 -4
- package/lib/esm/services/Configuration.js.map +1 -1
- package/lib/esm/services/Memo.js +0 -5
- package/lib/esm/services/Memo.js.map +1 -1
- package/lib/esm/services/Product.js +26 -5
- package/lib/esm/services/Product.js.map +1 -1
- package/lib/esm/services/Recommender.js +11 -10
- package/lib/esm/services/Recommender.js.map +1 -1
- package/lib/esm/services/Template.js +2 -2
- package/lib/esm/services/Template.js.map +1 -1
- package/lib/types/helpers/Handlebars.d.ts +41 -3
- package/lib/types/models/rtb/BidResponse.d.ts +4 -1
- package/lib/types/services/BotFiltering.d.ts +3 -0
- package/lib/types/services/Product.d.ts +8 -4
- package/lib/types/services/Recommender.d.ts +5 -5
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Ctx } from './Logger';
|
|
2
2
|
import { Err, Ok } from './Result';
|
|
3
|
-
export async function* GenerateTopProducts(logger, productFeed, url, accountId, siteId, locationId) {
|
|
3
|
+
export async function* GenerateTopProducts(logger, productFeed, url, accountId, siteId, locationId, category) {
|
|
4
4
|
const log = Ctx(logger)?.with('GenerateTopProducts').with(accountId).with(siteId).with(locationId);
|
|
5
5
|
log?.info('Generating top products');
|
|
6
|
-
yield* generateProductRecommendation(logger, productFeed, url, accountId, siteId, locationId, undefined, 'top-products');
|
|
6
|
+
yield* generateProductRecommendation(logger, productFeed, url, accountId, siteId, locationId, undefined, 'top-products', category);
|
|
7
7
|
}
|
|
8
|
-
export async function* GenerateForYou(logger, productFeed, url, accountId, siteId, locationId, userId) {
|
|
8
|
+
export async function* GenerateForYou(logger, productFeed, url, accountId, siteId, locationId, userId, category) {
|
|
9
9
|
const log = Ctx(logger)?.with('GenerateForYou').with(accountId).with(siteId).with(locationId).with(userId);
|
|
10
10
|
log?.info('Generating for you');
|
|
11
|
-
yield* generateProductRecommendation(logger, productFeed, url, accountId, siteId, locationId, userId, 'for-you');
|
|
11
|
+
yield* generateProductRecommendation(logger, productFeed, url, accountId, siteId, locationId, userId, 'for-you', category);
|
|
12
12
|
}
|
|
13
|
-
export async function* GeneratePreviousPurchases(logger, productFeed, url, accountId, siteId, locationId, userId) {
|
|
13
|
+
export async function* GeneratePreviousPurchases(logger, productFeed, url, accountId, siteId, locationId, userId, category) {
|
|
14
14
|
const log = Ctx(logger)
|
|
15
15
|
?.with('GeneratePreviousPurchases')
|
|
16
16
|
.with(accountId)
|
|
@@ -18,12 +18,12 @@ export async function* GeneratePreviousPurchases(logger, productFeed, url, accou
|
|
|
18
18
|
.with(locationId)
|
|
19
19
|
.with(userId);
|
|
20
20
|
log?.info('Generating previous purchases');
|
|
21
|
-
yield* generateProductRecommendation(log, productFeed, url, accountId, siteId, locationId, userId, 'buy-again');
|
|
21
|
+
yield* generateProductRecommendation(log, productFeed, url, accountId, siteId, locationId, userId, 'buy-again', category);
|
|
22
22
|
}
|
|
23
|
-
async function* generateProductRecommendation(logger, productFeed, url, accountId, siteId, locationId, userId, type) {
|
|
23
|
+
async function* generateProductRecommendation(logger, productFeed, url, accountId, siteId, locationId, userId, type, category) {
|
|
24
24
|
const log = Ctx(logger)?.with('generateProductRecommendation');
|
|
25
25
|
log?.debug('Generating product recommendation');
|
|
26
|
-
const recommendations = await fetchRecommendations(log, url, accountId, siteId, locationId, userId, type);
|
|
26
|
+
const recommendations = await fetchRecommendations(log, url, accountId, siteId, locationId, userId, type, category);
|
|
27
27
|
if (!recommendations.ok) {
|
|
28
28
|
log?.error(recommendations.error);
|
|
29
29
|
return;
|
|
@@ -31,10 +31,11 @@ async function* generateProductRecommendation(logger, productFeed, url, accountI
|
|
|
31
31
|
yield* generateProduct(log, productFeed, accountId, locationId, recommendations.value);
|
|
32
32
|
log?.debug('out of recommendations');
|
|
33
33
|
}
|
|
34
|
-
const fetchRecommendations = async (logger, url, accountId, siteId, locationId, userId, type) => {
|
|
34
|
+
const fetchRecommendations = async (logger, url, accountId, siteId, locationId, userId, type, category) => {
|
|
35
35
|
const log = Ctx(logger)?.with('fetchRecommendations');
|
|
36
36
|
log?.debug('Fetching recommendations');
|
|
37
|
-
const key = `accountId=${accountId}&siteId=${siteId}&locationId=${locationId}&userId=${userId ?? 'null'}
|
|
37
|
+
const key = `accountId=${accountId}&siteId=${siteId}&locationId=${locationId}&userId=${userId ?? 'null'}` +
|
|
38
|
+
(category !== undefined ? `&category=${category}` : '');
|
|
38
39
|
try {
|
|
39
40
|
const results = await fetch(`${url}/r/${type}?${key}&limit=100`);
|
|
40
41
|
if (results.status !== 200) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Recommender.js","sourceRoot":"src/","sources":["services/Recommender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAgB,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAoB,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,KAAK,SAAU,CAAC,CAAA,mBAAmB,CACtC,MAA2B,EAC3B,WAAiD,EACjD,GAAW,EACX,SAAiB,EACjB,MAAc,EACd,UAAkB;
|
|
1
|
+
{"version":3,"file":"Recommender.js","sourceRoot":"src/","sources":["services/Recommender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAgB,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAoB,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,KAAK,SAAU,CAAC,CAAA,mBAAmB,CACtC,MAA2B,EAC3B,WAAiD,EACjD,GAAW,EACX,SAAiB,EACjB,MAAc,EACd,UAAkB,EAClB,QAAiB;IAEjB,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,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AAC,MAAM,CAAC,CAAC;YAC1C,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YACvC,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;gBACb,MAAM,OAAO,CAAC,KAAK,CAAC;YACxB,CAAC;iBAAM,CAAC;gBACJ,GAAG,EAAE,IAAI,CAAC,oCAAoC,EAAE,MAAM,CAAC,CAAC;YAC5D,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,GAAG,EAAE,IAAI,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAC5C,CAAC;IACL,CAAC;IAED,GAAG,EAAE,IAAI,CAAC,2BAA2B,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC7C;QACI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC1C,CAAC;CACJ"}
|
|
@@ -7,12 +7,12 @@ export const EvaluateHandlebarsProductCardTemplate = (logger, windowInfo, publis
|
|
|
7
7
|
const renderedClickthrough = clickthrough ?? GetValueOrThrow(EvaluateHandlebarsClickthroughTemplate(log, windowInfo, publisher, product));
|
|
8
8
|
log?.debug('Got clickthrough URL', renderedClickthrough);
|
|
9
9
|
return Ok(publisher.templates.productCardTemplate({
|
|
10
|
-
...product,
|
|
11
10
|
product,
|
|
12
11
|
window: windowInfo,
|
|
13
12
|
publisher,
|
|
14
13
|
catalog: product,
|
|
15
|
-
clickthrough: renderedClickthrough
|
|
14
|
+
clickthrough: renderedClickthrough,
|
|
15
|
+
...product
|
|
16
16
|
}));
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Template.js","sourceRoot":"src/","sources":["services/Template.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAgB,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,EAAE,EAAe,MAA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OAAO,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC;YAC9C,OAAO;YACP,MAAM,EAAE,UAAU;YAClB,SAAS;YACT,OAAO,EAAE,OAAO;YAChB,YAAY,EAAE,oBAAoB;YAClC,GAAG,OAAO;SACb,CAAC,CAAC,CAAC;IACR,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,GAAG,CAAC,KAAc,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,MAA2B,EAC9E,UAAyC,EACzC,SAA0C,EAC1C,OAA4B,EACd,EAAE;IAChB,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACxE,GAAG,EAAE,IAAI,CAAC,iDAAiD,EAAE,OAAO,CAAC,CAAC;IACtE,IAAI,CAAC;QACD,OAAO,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,uBAAuB,CAAC;YAClD,OAAO;YACP,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,UAAU;YAClB,SAAS;YACT,GAAG,OAAO;SACb,CAAC,CAAC,CAAC;IACR,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,GAAG,CAAC,KAAc,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type HelperDelegate } from 'handlebars';
|
|
2
|
+
import { type INativeTemplateDelegateWindow } from '../models';
|
|
2
3
|
/**
|
|
3
4
|
* Converts the passed string to a slug with the specified options. By default, the slug is hyphenated and only
|
|
4
5
|
* contains alphanumeric characters. You can pass a different hyphenation regex and a different drop regex to
|
|
@@ -36,6 +37,11 @@ export declare function slug(name: string, options: {
|
|
|
36
37
|
* @returns A lowercase version of the passed string
|
|
37
38
|
*/
|
|
38
39
|
export declare function lower(name: string): string;
|
|
40
|
+
export declare function split(str: string, options: {
|
|
41
|
+
hash: {
|
|
42
|
+
by?: string;
|
|
43
|
+
};
|
|
44
|
+
}): string[];
|
|
39
45
|
export declare function upper(name: string): string;
|
|
40
46
|
/**
|
|
41
47
|
* Returns the path component of the URL at the specified position, 1-indexed
|
|
@@ -44,7 +50,28 @@ export declare function upper(name: string): string;
|
|
|
44
50
|
* @param position The position of the path component to return, 1-indexed
|
|
45
51
|
* @returns The path component at the specified position
|
|
46
52
|
*/
|
|
47
|
-
export declare
|
|
53
|
+
export declare const path: (pathname: string) => (position: number, options: {
|
|
54
|
+
hash: {
|
|
55
|
+
url?: string;
|
|
56
|
+
};
|
|
57
|
+
}) => string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Returns the domain. By default strips out subdomains. Pass a number to increase the depth of the domain. For example
|
|
60
|
+
* if the url is http://shop.mysite.co/ then {{domain}} returns `mysite.co`. `{{domain 3}}` will return
|
|
61
|
+
* `shop.mysite.co` and `{{domain 1}}` returns `co`.
|
|
62
|
+
* @returns The domain
|
|
63
|
+
*/
|
|
64
|
+
export declare const domain: (hostname: string) => (options?: {
|
|
65
|
+
hash: {
|
|
66
|
+
url?: string;
|
|
67
|
+
depth?: number;
|
|
68
|
+
};
|
|
69
|
+
}) => string | undefined;
|
|
70
|
+
export declare function money(value: number | string, options: {
|
|
71
|
+
hash: {
|
|
72
|
+
cents?: boolean;
|
|
73
|
+
};
|
|
74
|
+
}): string;
|
|
48
75
|
/**
|
|
49
76
|
* A general-purpose string replacement tool - meant to behave like the Unix sed tool. Accepts a regex for
|
|
50
77
|
* search, and a replacement string. for example, if the input string is "hello world" and the search is
|
|
@@ -97,7 +124,11 @@ export declare function replace(input: string, search: string, replacement: stri
|
|
|
97
124
|
* @param name The name of the query parameter to return
|
|
98
125
|
* @returns The value of the query parameter, or an empty string if the parameter is not found
|
|
99
126
|
*/
|
|
100
|
-
export declare
|
|
127
|
+
export declare const search: (search: string) => (name: string, options: {
|
|
128
|
+
hash: {
|
|
129
|
+
url?: string;
|
|
130
|
+
};
|
|
131
|
+
}) => string;
|
|
101
132
|
/**
|
|
102
133
|
* Returns the first truthy argument, or an empty string if all arguments are falsy. Returns false for empty strings
|
|
103
134
|
* For example, {{coalesce false (eq "b" "d") c}} will return "c", because false is falsy, "b" is not equal to "d",
|
|
@@ -158,11 +189,18 @@ export declare function and(a: any, b: any): boolean;
|
|
|
158
189
|
* @returns True if the value is in the array, false otherwise
|
|
159
190
|
*/
|
|
160
191
|
export declare function isIn(a: any, b: any[]): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Grabs a variable off of the global window object. {{global "foo" "bar"}} will return `window.foo.bar`.
|
|
194
|
+
* If any part of the path is undefined, this returns undefined with no exceptions
|
|
195
|
+
* @returns The global variable
|
|
196
|
+
*/
|
|
197
|
+
export declare function global(...args: any[]): any;
|
|
161
198
|
/**
|
|
162
199
|
* Returns an array of the passed arguments. Useful with the "in" helper
|
|
163
200
|
* @group TemplateHelpers
|
|
164
201
|
* @returns An array of the passed arguments
|
|
165
202
|
*/
|
|
166
203
|
export declare function array(...args: any[]): any[];
|
|
204
|
+
export declare function brand(options: Handlebars.HelperOptions): string | undefined;
|
|
167
205
|
export type HandlebarsHelpers = Record<string, HelperDelegate>;
|
|
168
|
-
export declare const GetHelpers: () => HandlebarsHelpers;
|
|
206
|
+
export declare const GetHelpers: (windowInfo: INativeTemplateDelegateWindow) => HandlebarsHelpers;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export interface IBidExtensions extends Record<string, any> {
|
|
2
|
+
primaryCategory?: string;
|
|
3
|
+
}
|
|
1
4
|
export interface IBid {
|
|
2
5
|
id: string;
|
|
3
6
|
impid: string;
|
|
@@ -26,7 +29,7 @@ export interface IBid {
|
|
|
26
29
|
wratio?: number;
|
|
27
30
|
hratio?: number;
|
|
28
31
|
exp?: number;
|
|
29
|
-
ext?:
|
|
32
|
+
ext?: IBidExtensions;
|
|
30
33
|
dur?: number;
|
|
31
34
|
mtype?: number;
|
|
32
35
|
slotinpid?: number;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ILogger } from './Logger';
|
|
2
|
+
export declare const FilterBots: <TArgs extends readonly unknown[], TReturn>(logger: ILogger | undefined, userAgent: string, fn: (...args: TArgs) => TReturn, fallback: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
|
|
3
|
+
export declare const FilterBotsAsyncGenerator: <TArgs extends readonly unknown[], TReturn>(logger: ILogger | undefined, userAgent: string, fn: (...args: TArgs) => AsyncGenerator<TReturn>) => (...args: TArgs) => AsyncGenerator<Awaited<TReturn>, void, any>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ICompiledPublisherConfiguration, IProductInformation } from '../models';
|
|
2
2
|
import { type ILogger } from './Logger';
|
|
3
3
|
import { type Result, type AsyncResult } from './Result';
|
|
4
|
-
export type GetSponsoredProductFromNativeIdFn = (nativeId: string) => AsyncGenerator<IProductInformation>;
|
|
5
|
-
export type GetAllSponsoredProductFromNativeIdFn = (nativeId: string) => Promise<Result<IProductInformation[]>>;
|
|
4
|
+
export type GetSponsoredProductFromNativeIdFn = (nativeId: string, categories?: string[]) => AsyncGenerator<IProductInformation>;
|
|
5
|
+
export type GetAllSponsoredProductFromNativeIdFn = (nativeId: string, categories?: string[]) => Promise<Result<IProductInformation[]>>;
|
|
6
6
|
export type GetRecommendedProductFromProductIdFn = (productId: string) => AsyncResult<IProductInformation>;
|
|
7
|
-
export declare const GetAllSponsoredProducts: (logger: ILogger | undefined, url: string, config: ICompiledPublisherConfiguration, accountId: string, locationId: string, nativeId: string) => Promise<Result<IProductInformation[]>>;
|
|
8
|
-
export declare const GetAllSponsoredBrandProducts: (logger: ILogger | undefined, url: string, config: ICompiledPublisherConfiguration, accountId: string, locationId: string, nativeId: string) => Promise<Result<IProductInformation[]>>;
|
|
7
|
+
export declare const GetAllSponsoredProducts: (logger: ILogger | undefined, url: string, config: ICompiledPublisherConfiguration, accountId: string, locationId: string, nativeId: string, categories?: string[]) => Promise<Result<IProductInformation[]>>;
|
|
8
|
+
export declare const GetAllSponsoredBrandProducts: (logger: ILogger | undefined, url: string, config: ICompiledPublisherConfiguration, accountId: string, locationId: string, nativeId: string, categories?: string[]) => Promise<Result<IProductInformation[]>>;
|
|
9
9
|
export declare const GetRecommendedProduct: (logger: ILogger | undefined, url: string, config: ICompiledPublisherConfiguration, accountId: string, locationId: string, productId: string) => AsyncResult<IProductInformation>;
|
|
10
10
|
export declare class NoNativeError extends Error {
|
|
11
11
|
nativeId: string;
|
|
@@ -15,3 +15,7 @@ export declare class MalformedBrandResponseError extends Error {
|
|
|
15
15
|
nativeId: string;
|
|
16
16
|
constructor(nativeId: string);
|
|
17
17
|
}
|
|
18
|
+
export declare class NoProductError extends Error {
|
|
19
|
+
productId: string;
|
|
20
|
+
constructor(productId: string);
|
|
21
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { IProductInformation } from '../models';
|
|
2
2
|
import { type ILogger } from './Logger';
|
|
3
3
|
import type { GetRecommendedProductFromProductIdFn } from './Product';
|
|
4
|
-
export type NonPersonalRecommenderFn = () => AsyncGenerator<IProductInformation>;
|
|
5
|
-
export type PersonalRecommenderFn = (userId: string) => AsyncGenerator<IProductInformation>;
|
|
6
|
-
export declare function GenerateTopProducts(logger: ILogger | undefined, productFeed: GetRecommendedProductFromProductIdFn, url: string, accountId: string, siteId: string, locationId: string): AsyncGenerator<IProductInformation>;
|
|
7
|
-
export declare function GenerateForYou(logger: ILogger | undefined, productFeed: GetRecommendedProductFromProductIdFn, url: string, accountId: string, siteId: string, locationId: string, userId: string): AsyncGenerator<IProductInformation>;
|
|
8
|
-
export declare function GeneratePreviousPurchases(logger: ILogger | undefined, productFeed: GetRecommendedProductFromProductIdFn, url: string, accountId: string, siteId: string, locationId: string, userId: string): AsyncGenerator<IProductInformation>;
|
|
4
|
+
export type NonPersonalRecommenderFn = (category?: string) => AsyncGenerator<IProductInformation>;
|
|
5
|
+
export type PersonalRecommenderFn = (userId: string, category?: string) => AsyncGenerator<IProductInformation>;
|
|
6
|
+
export declare function GenerateTopProducts(logger: ILogger | undefined, productFeed: GetRecommendedProductFromProductIdFn, url: string, accountId: string, siteId: string, locationId: string, category?: string): AsyncGenerator<IProductInformation>;
|
|
7
|
+
export declare function GenerateForYou(logger: ILogger | undefined, productFeed: GetRecommendedProductFromProductIdFn, url: string, accountId: string, siteId: string, locationId: string, userId: string, category?: string): AsyncGenerator<IProductInformation>;
|
|
8
|
+
export declare function GeneratePreviousPurchases(logger: ILogger | undefined, productFeed: GetRecommendedProductFromProductIdFn, url: string, accountId: string, siteId: string, locationId: string, userId: string, category?: string): AsyncGenerator<IProductInformation>;
|
|
9
9
|
export declare class NoRecommendationsError extends Error {
|
|
10
10
|
constructor();
|
|
11
11
|
}
|