@searchspring/snap-client 0.27.5 → 0.27.8
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 +19 -0
- package/dist/cjs/Client/Client.d.ts +2 -2
- package/dist/cjs/Client/Client.d.ts.map +1 -1
- package/dist/cjs/Client/Client.js +21 -3
- package/dist/cjs/Client/apis/Hybrid.d.ts +1 -0
- package/dist/cjs/Client/apis/Hybrid.d.ts.map +1 -1
- package/dist/cjs/Client/apis/Hybrid.js +15 -0
- package/dist/cjs/Client/apis/Recommend.d.ts +2 -73
- package/dist/cjs/Client/apis/Recommend.d.ts.map +1 -1
- package/dist/cjs/Client/apis/Recommend.js +69 -42
- package/dist/cjs/Client/apis/Suggest.d.ts +1 -37
- package/dist/cjs/Client/apis/Suggest.d.ts.map +1 -1
- package/dist/cjs/Client/transforms/suggestResponse.d.ts +1 -1
- package/dist/cjs/Client/transforms/suggestResponse.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/types.d.ts +101 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/Client/Client.d.ts +2 -2
- package/dist/esm/Client/Client.d.ts.map +1 -1
- package/dist/esm/Client/Client.js +14 -1
- package/dist/esm/Client/apis/Hybrid.d.ts +1 -0
- package/dist/esm/Client/apis/Hybrid.d.ts.map +1 -1
- package/dist/esm/Client/apis/Hybrid.js +5 -0
- package/dist/esm/Client/apis/Recommend.d.ts +2 -73
- package/dist/esm/Client/apis/Recommend.d.ts.map +1 -1
- package/dist/esm/Client/apis/Recommend.js +68 -38
- package/dist/esm/Client/apis/Suggest.d.ts +1 -37
- package/dist/esm/Client/apis/Suggest.d.ts.map +1 -1
- package/dist/esm/Client/transforms/suggestResponse.d.ts +1 -1
- package/dist/esm/Client/transforms/suggestResponse.d.ts.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/types.d.ts +101 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -67,6 +67,10 @@ export type ClientConfig = {
|
|
|
67
67
|
api?: SnapApiConfig;
|
|
68
68
|
cache?: CacheConfig;
|
|
69
69
|
};
|
|
70
|
+
finder?: {
|
|
71
|
+
api?: SnapApiConfig;
|
|
72
|
+
cache?: CacheConfig;
|
|
73
|
+
};
|
|
70
74
|
recommend?: {
|
|
71
75
|
api?: SnapApiConfig;
|
|
72
76
|
cache?: CacheConfig;
|
|
@@ -234,6 +238,21 @@ const results = await client.trending({
|
|
|
234
238
|
});
|
|
235
239
|
```
|
|
236
240
|
|
|
241
|
+
## `finder` method
|
|
242
|
+
Makes a request to the Searchspring finder API and returns a promise.
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
const client = new Client(globals, clientConfig);
|
|
246
|
+
const [meta, results] = await client.finder({
|
|
247
|
+
filters: [{
|
|
248
|
+
type: "value",
|
|
249
|
+
field: "color",
|
|
250
|
+
background: false,
|
|
251
|
+
value: "red",
|
|
252
|
+
}]
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
237
256
|
## `recommend` method
|
|
238
257
|
Makes a request to the Searchspring Recommend API and returns a promise.
|
|
239
258
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { TrendingRequestModel, TrendingResponseModel, RecommendCombinedRequestModel, RecommendCombinedResponseModel } from '
|
|
2
|
-
import type { ClientGlobals, ClientConfig } from '../types';
|
|
1
|
+
import type { ClientGlobals, ClientConfig, TrendingRequestModel, TrendingResponseModel, RecommendCombinedRequestModel, RecommendCombinedResponseModel } from '../types';
|
|
3
2
|
import type { MetaRequestModel, MetaResponseModel, SearchRequestModel, SearchResponseModel, AutocompleteRequestModel, AutocompleteResponseModel } from '@searchspring/snapi-types';
|
|
4
3
|
export declare class Client {
|
|
5
4
|
private globals;
|
|
@@ -9,6 +8,7 @@ export declare class Client {
|
|
|
9
8
|
meta(params?: MetaRequestModel): Promise<MetaResponseModel>;
|
|
10
9
|
autocomplete(params?: AutocompleteRequestModel): Promise<[MetaResponseModel, AutocompleteResponseModel]>;
|
|
11
10
|
search(params?: SearchRequestModel): Promise<[MetaResponseModel, SearchResponseModel]>;
|
|
11
|
+
finder(params?: SearchRequestModel): Promise<[MetaResponseModel, SearchResponseModel]>;
|
|
12
12
|
trending(params: Partial<TrendingRequestModel>): Promise<TrendingResponseModel>;
|
|
13
13
|
recommend(params: RecommendCombinedRequestModel): Promise<RecommendCombinedResponseModel>;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/Client/Client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/Client/Client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EAGrB,6BAA6B,EAC7B,8BAA8B,EAC9B,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EACX,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,MAAM,2BAA2B,CAAC;AAqCnC,qBAAa,MAAM;IAClB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAOhB;gBAEU,OAAO,EAAE,aAAa,EAAE,MAAM,GAAE,YAAiB;IAgDvD,IAAI,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAO3D,YAAY,CAAC,MAAM,GAAE,wBAA6B,GAAG,OAAO,CAAC,CAAC,iBAAiB,EAAE,yBAAyB,CAAC,CAAC;IAU5G,MAAM,CAAC,MAAM,GAAE,kBAAuB,GAAG,OAAO,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;IAM1F,MAAM,CAAC,MAAM,GAAE,kBAAuB,GAAG,OAAO,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;IAM1F,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAM/E,SAAS,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,8BAA8B,CAAC;CAgC/F"}
|
|
@@ -85,6 +85,11 @@ var defaultConfig = {
|
|
|
85
85
|
// origin: 'https://snapi.kube.searchspring.io',
|
|
86
86
|
},
|
|
87
87
|
},
|
|
88
|
+
finder: {
|
|
89
|
+
api: {
|
|
90
|
+
// origin: 'https://snapi.kube.searchspring.io',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
88
93
|
suggest: {
|
|
89
94
|
api: {
|
|
90
95
|
// origin: 'https://snapi.kube.searchspring.io',
|
|
@@ -94,7 +99,7 @@ var defaultConfig = {
|
|
|
94
99
|
var Client = /** @class */ (function () {
|
|
95
100
|
function Client(globals, config) {
|
|
96
101
|
if (config === void 0) { config = {}; }
|
|
97
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
102
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
98
103
|
if (!(globals === null || globals === void 0 ? void 0 : globals.siteId)) {
|
|
99
104
|
throw 'no siteId specified!';
|
|
100
105
|
}
|
|
@@ -117,9 +122,13 @@ var Client = /** @class */ (function () {
|
|
|
117
122
|
origin: (_l = (_k = this.config.search) === null || _k === void 0 ? void 0 : _k.api) === null || _l === void 0 ? void 0 : _l.origin,
|
|
118
123
|
cache: (_m = this.config.search) === null || _m === void 0 ? void 0 : _m.cache,
|
|
119
124
|
})),
|
|
125
|
+
finder: new apis_1.HybridAPI(new apis_1.ApiConfiguration({
|
|
126
|
+
origin: (_p = (_o = this.config.finder) === null || _o === void 0 ? void 0 : _o.api) === null || _p === void 0 ? void 0 : _p.origin,
|
|
127
|
+
cache: (_q = this.config.finder) === null || _q === void 0 ? void 0 : _q.cache,
|
|
128
|
+
})),
|
|
120
129
|
suggest: new apis_1.SuggestAPI(new apis_1.ApiConfiguration({
|
|
121
|
-
origin: (
|
|
122
|
-
cache: (
|
|
130
|
+
origin: (_s = (_r = this.config.suggest) === null || _r === void 0 ? void 0 : _r.api) === null || _s === void 0 ? void 0 : _s.origin,
|
|
131
|
+
cache: (_t = this.config.suggest) === null || _t === void 0 ? void 0 : _t.cache,
|
|
123
132
|
})),
|
|
124
133
|
};
|
|
125
134
|
}
|
|
@@ -155,6 +164,15 @@ var Client = /** @class */ (function () {
|
|
|
155
164
|
});
|
|
156
165
|
});
|
|
157
166
|
};
|
|
167
|
+
Client.prototype.finder = function (params) {
|
|
168
|
+
if (params === void 0) { params = {}; }
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
params = (0, deepmerge_1.default)(this.globals, params);
|
|
172
|
+
return [2 /*return*/, Promise.all([this.meta({ siteId: params.siteId || '' }), this.requesters.finder.getFinder(params)])];
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
};
|
|
158
176
|
Client.prototype.trending = function (params) {
|
|
159
177
|
return __awaiter(this, void 0, void 0, function () {
|
|
160
178
|
return __generator(this, function (_a) {
|
|
@@ -5,6 +5,7 @@ export declare class HybridAPI extends API {
|
|
|
5
5
|
constructor(configuration: ApiConfiguration);
|
|
6
6
|
getMeta(requestParameters: MetaRequestModel): Promise<MetaResponseModel>;
|
|
7
7
|
getSearch(requestParameters: SearchRequestModel): Promise<SearchResponseModel>;
|
|
8
|
+
getFinder(requestParameters: SearchRequestModel): Promise<SearchResponseModel>;
|
|
8
9
|
getAutocomplete(requestParameters: AutocompleteRequestModel): Promise<AutocompleteResponseModel>;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=Hybrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hybrid.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Hybrid.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"Hybrid.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Hybrid.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,GAAG,EAAyB,gBAAgB,EAAE,MAAM,GAAG,CAAC;AAIjE,qBAAa,SAAU,SAAQ,GAAG;IACjC,OAAO,CAAC,UAAU,CAGhB;gBAEU,aAAa,EAAE,gBAAgB;IASrC,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKxE,SAAS,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQ9E,SAAS,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQ9E,eAAe,CAAC,iBAAiB,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAoCtG"}
|
|
@@ -99,6 +99,21 @@ var HybridAPI = /** @class */ (function (_super) {
|
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
};
|
|
102
|
+
HybridAPI.prototype.getFinder = function (requestParameters) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
var legacyRequestParameters, legacyData;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
legacyRequestParameters = (0, transforms_1.transformSearchRequest)(requestParameters);
|
|
109
|
+
return [4 /*yield*/, this.requesters.legacy.getFinder(legacyRequestParameters)];
|
|
110
|
+
case 1:
|
|
111
|
+
legacyData = _a.sent();
|
|
112
|
+
return [2 /*return*/, (0, transforms_1.transformSearchResponse)(legacyData, requestParameters)];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
102
117
|
HybridAPI.prototype.getAutocomplete = function (requestParameters) {
|
|
103
118
|
return __awaiter(this, void 0, void 0, function () {
|
|
104
119
|
var legacyRequestParameters, suggestParams, suggestResults, transformedSuggestResults, q, queryParameters, legacyResults, searchResults;
|
|
@@ -1,82 +1,11 @@
|
|
|
1
1
|
import { API, ApiConfiguration } from './Abstract';
|
|
2
|
-
import {
|
|
3
|
-
export declare type RecommendRequestModel = {
|
|
4
|
-
tags: string[];
|
|
5
|
-
siteId: string;
|
|
6
|
-
product?: string;
|
|
7
|
-
shopper?: string;
|
|
8
|
-
categories?: string[];
|
|
9
|
-
cart?: string[];
|
|
10
|
-
lastViewed?: string[];
|
|
11
|
-
test?: boolean;
|
|
12
|
-
batched?: boolean;
|
|
13
|
-
limits?: number | number[];
|
|
14
|
-
};
|
|
15
|
-
export declare type RecommendResponseModel = {
|
|
16
|
-
profile: {
|
|
17
|
-
tag: string;
|
|
18
|
-
};
|
|
19
|
-
results: SearchResponseModelResult[];
|
|
20
|
-
}[];
|
|
21
|
-
export declare type ProfileRequestModel = {
|
|
22
|
-
siteId: string;
|
|
23
|
-
tag: string;
|
|
24
|
-
branch?: string;
|
|
25
|
-
};
|
|
26
|
-
export declare type ProfileResponseModel = {
|
|
27
|
-
profile: {
|
|
28
|
-
tag: string;
|
|
29
|
-
placement: string;
|
|
30
|
-
display: {
|
|
31
|
-
threshold: number;
|
|
32
|
-
template: {
|
|
33
|
-
name: string;
|
|
34
|
-
uuid: string;
|
|
35
|
-
markup?: string;
|
|
36
|
-
styles?: string;
|
|
37
|
-
component?: string;
|
|
38
|
-
branch?: string;
|
|
39
|
-
group?: string;
|
|
40
|
-
};
|
|
41
|
-
templateParameters: {
|
|
42
|
-
[any: string]: unknown;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export declare type RecommendCombinedRequestModel = {
|
|
48
|
-
tag: string;
|
|
49
|
-
siteId: string;
|
|
50
|
-
product?: string;
|
|
51
|
-
shopper?: string;
|
|
52
|
-
categories?: string[];
|
|
53
|
-
cart?: string[];
|
|
54
|
-
lastViewed?: string[];
|
|
55
|
-
test?: boolean;
|
|
56
|
-
branch?: string;
|
|
57
|
-
};
|
|
58
|
-
declare class Deferred {
|
|
59
|
-
promise: Promise<any>;
|
|
60
|
-
resolve: any;
|
|
61
|
-
reject: any;
|
|
62
|
-
constructor();
|
|
63
|
-
}
|
|
64
|
-
export declare type RecommendCombinedResponseModel = ProfileResponseModel & {
|
|
65
|
-
results: SearchResponseModelResult[];
|
|
66
|
-
};
|
|
2
|
+
import { ProfileRequestModel, ProfileResponseModel, RecommendRequestModel, RecommendResponseModel } from '../../types';
|
|
67
3
|
export declare class RecommendAPI extends API {
|
|
68
|
-
batches
|
|
69
|
-
[key: string]: {
|
|
70
|
-
timeout: number;
|
|
71
|
-
request: any;
|
|
72
|
-
deferreds?: Deferred[];
|
|
73
|
-
};
|
|
74
|
-
};
|
|
4
|
+
private batches;
|
|
75
5
|
constructor(config: ApiConfiguration);
|
|
76
6
|
getProfile(queryParameters: ProfileRequestModel): Promise<ProfileResponseModel>;
|
|
77
7
|
batchRecommendations(parameters: RecommendRequestModel): Promise<RecommendResponseModel>;
|
|
78
8
|
getRecommendations(queryParameters: RecommendRequestModel): Promise<RecommendResponseModel>;
|
|
79
9
|
postRecommendations(requestParameters: RecommendRequestModel): Promise<RecommendResponseModel>;
|
|
80
10
|
}
|
|
81
|
-
export {};
|
|
82
11
|
//# sourceMappingURL=Recommend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Recommend.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Recommend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Recommend.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Recommend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;AAIhE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAgBvH,qBAAa,YAAa,SAAQ,GAAG;IACpC,OAAO,CAAC,OAAO,CAOb;gBAEU,MAAM,EAAE,gBAAgB;IAK9B,UAAU,CAAC,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgB/E,oBAAoB,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAgFxF,kBAAkB,CAAC,eAAe,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAmB3F,mBAAmB,CAAC,iBAAiB,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAmBpG"}
|
|
@@ -118,76 +118,84 @@ var RecommendAPI = /** @class */ (function (_super) {
|
|
|
118
118
|
RecommendAPI.prototype.batchRecommendations = function (parameters) {
|
|
119
119
|
var _a;
|
|
120
120
|
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
-
var tags, limits, categories, otherParams,
|
|
121
|
+
var tags, limits, categories, otherParams, getKey, key, batch, deferred;
|
|
122
122
|
var _this = this;
|
|
123
123
|
return __generator(this, function (_b) {
|
|
124
124
|
tags = parameters.tags, limits = parameters.limits, categories = parameters.categories, otherParams = __rest(parameters, ["tags", "limits", "categories"]);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
key = otherParams.siteId;
|
|
125
|
+
getKey = function (parameters) {
|
|
126
|
+
var key = (0, hashParams_1.hashParams)(parameters);
|
|
127
|
+
if ('batched' in parameters) {
|
|
128
|
+
if (parameters.batched) {
|
|
129
|
+
key = parameters.siteId;
|
|
130
|
+
}
|
|
132
131
|
}
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
return key;
|
|
133
|
+
};
|
|
134
|
+
key = getKey(otherParams);
|
|
135
|
+
batch = (this.batches[key] = this.batches[key] || { timeout: null, request: { tags: [], limits: [] }, requests: [], deferreds: [] });
|
|
137
136
|
deferred = new Deferred();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
paramBatch.request.limits = paramBatch.request.limits.concat(limits);
|
|
148
|
-
paramBatch.request = __assign(__assign({}, paramBatch.request), otherParams);
|
|
149
|
-
(_a = paramBatch.deferreds) === null || _a === void 0 ? void 0 : _a.push(deferred);
|
|
150
|
-
window.clearTimeout(paramBatch.timeout);
|
|
151
|
-
paramBatch.timeout = window.setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
152
|
-
var requestMethod, response_1, err_1;
|
|
137
|
+
// add each request to the list
|
|
138
|
+
batch.requests.push(__assign({}, parameters));
|
|
139
|
+
(_a = batch.deferreds) === null || _a === void 0 ? void 0 : _a.push(deferred);
|
|
140
|
+
// wait for all of the requests to come in
|
|
141
|
+
window.clearTimeout(batch.timeout);
|
|
142
|
+
batch.timeout = window.setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
143
|
+
var batchedRequests, response_1, err_1;
|
|
153
144
|
var _a, _b;
|
|
154
145
|
return __generator(this, function (_c) {
|
|
155
146
|
switch (_c.label) {
|
|
156
147
|
case 0:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
148
|
+
// delete the batch so a new one can take its place
|
|
149
|
+
delete this.batches[key];
|
|
150
|
+
batchedRequests = batch.requests.sort(sortRequests);
|
|
151
|
+
// now that the requests are in proper order, map through them
|
|
152
|
+
// and build out the batches
|
|
153
|
+
batchedRequests.map(function (request) {
|
|
154
|
+
var tags = request.tags, limits = request.limits, categories = request.categories, otherParams = __rest(request, ["tags", "limits", "categories"]);
|
|
155
|
+
if (!limits)
|
|
156
|
+
limits = 20;
|
|
157
|
+
var tag = (tags || [])[0];
|
|
158
|
+
delete otherParams.batched; // remove from request parameters
|
|
159
|
+
delete otherParams.order; // remove from request parameters
|
|
160
|
+
batch.request.tags.push(tag);
|
|
161
|
+
if (categories) {
|
|
162
|
+
if (!batch.request.categories) {
|
|
163
|
+
batch.request.categories = categories;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
batch.request.categories = batch.request.categories.concat(categories);
|
|
167
|
+
}
|
|
163
168
|
}
|
|
164
|
-
|
|
169
|
+
batch.request.limits = batch.request.limits.concat(limits);
|
|
170
|
+
batch.request = __assign(__assign({}, batch.request), otherParams);
|
|
171
|
+
});
|
|
165
172
|
_c.label = 1;
|
|
166
173
|
case 1:
|
|
167
174
|
_c.trys.push([1, 6, , 7]);
|
|
168
|
-
if (!((0, snap_toolbox_1.charsParams)(
|
|
169
|
-
|
|
175
|
+
if (!((0, snap_toolbox_1.charsParams)(batch.request) > 1024)) return [3 /*break*/, 3];
|
|
176
|
+
if (batch.request['product']) {
|
|
177
|
+
batch.request['product'] = batch.request['product'].toString();
|
|
178
|
+
}
|
|
179
|
+
return [4 /*yield*/, this.postRecommendations(batch.request)];
|
|
170
180
|
case 2:
|
|
171
181
|
response_1 = _c.sent();
|
|
172
182
|
return [3 /*break*/, 5];
|
|
173
|
-
case 3: return [4 /*yield*/, this.getRecommendations(
|
|
183
|
+
case 3: return [4 /*yield*/, this.getRecommendations(batch.request)];
|
|
174
184
|
case 4:
|
|
175
185
|
response_1 = _c.sent();
|
|
176
186
|
_c.label = 5;
|
|
177
187
|
case 5:
|
|
178
|
-
(_a =
|
|
188
|
+
(_a = batch.deferreds) === null || _a === void 0 ? void 0 : _a.forEach(function (def, index) {
|
|
179
189
|
def.resolve([response_1[index]]);
|
|
180
190
|
});
|
|
181
191
|
return [3 /*break*/, 7];
|
|
182
192
|
case 6:
|
|
183
193
|
err_1 = _c.sent();
|
|
184
|
-
(_b =
|
|
194
|
+
(_b = batch.deferreds) === null || _b === void 0 ? void 0 : _b.forEach(function (def) {
|
|
185
195
|
def.reject(err_1);
|
|
186
196
|
});
|
|
187
197
|
return [3 /*break*/, 7];
|
|
188
|
-
case 7:
|
|
189
|
-
delete this.batches[key];
|
|
190
|
-
return [2 /*return*/];
|
|
198
|
+
case 7: return [2 /*return*/];
|
|
191
199
|
}
|
|
192
200
|
});
|
|
193
201
|
}); }, BATCH_TIMEOUT);
|
|
@@ -243,3 +251,22 @@ var RecommendAPI = /** @class */ (function (_super) {
|
|
|
243
251
|
return RecommendAPI;
|
|
244
252
|
}(Abstract_1.API));
|
|
245
253
|
exports.RecommendAPI = RecommendAPI;
|
|
254
|
+
function sortRequests(a, b) {
|
|
255
|
+
// undefined order goes last
|
|
256
|
+
if (a.order == undefined && b.order == undefined) {
|
|
257
|
+
return 0;
|
|
258
|
+
}
|
|
259
|
+
if (a.order == undefined && b.order != undefined) {
|
|
260
|
+
return 1;
|
|
261
|
+
}
|
|
262
|
+
if (b.order == undefined && a.order != undefined) {
|
|
263
|
+
return -1;
|
|
264
|
+
}
|
|
265
|
+
if (a.order < b.order) {
|
|
266
|
+
return -1;
|
|
267
|
+
}
|
|
268
|
+
if (a.order > b.order) {
|
|
269
|
+
return 1;
|
|
270
|
+
}
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
@@ -1,41 +1,5 @@
|
|
|
1
1
|
import { API } from './Abstract';
|
|
2
|
-
|
|
3
|
-
siteId: string;
|
|
4
|
-
query: string;
|
|
5
|
-
language?: string;
|
|
6
|
-
suggestionCount?: number;
|
|
7
|
-
productCount?: number;
|
|
8
|
-
disableSpellCorrect?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare type SuggestResponseModelSuggestion = {
|
|
11
|
-
text: string;
|
|
12
|
-
type?: string;
|
|
13
|
-
source?: string;
|
|
14
|
-
popularity?: number;
|
|
15
|
-
completed?: {
|
|
16
|
-
token: string;
|
|
17
|
-
query: string;
|
|
18
|
-
type: string;
|
|
19
|
-
}[];
|
|
20
|
-
};
|
|
21
|
-
export declare type SuggestResponseModel = {
|
|
22
|
-
query: string;
|
|
23
|
-
'corrected-query'?: string;
|
|
24
|
-
suggested?: SuggestResponseModelSuggestion;
|
|
25
|
-
alternatives?: SuggestResponseModelSuggestion[];
|
|
26
|
-
};
|
|
27
|
-
export declare type TrendingRequestModel = {
|
|
28
|
-
siteId: string;
|
|
29
|
-
limit?: number;
|
|
30
|
-
};
|
|
31
|
-
export declare type TrendingResponseModel = {
|
|
32
|
-
trending: {
|
|
33
|
-
queries: {
|
|
34
|
-
popularity: number;
|
|
35
|
-
searchQuery: string;
|
|
36
|
-
}[];
|
|
37
|
-
};
|
|
38
|
-
};
|
|
2
|
+
import { SuggestRequestModel, SuggestResponseModel, TrendingRequestModel, TrendingResponseModel } from '../../types';
|
|
39
3
|
export declare class SuggestAPI extends API {
|
|
40
4
|
getSuggest(queryParameters: SuggestRequestModel): Promise<SuggestResponseModel>;
|
|
41
5
|
postSuggest(requestParameters: SuggestRequestModel): Promise<SuggestResponseModel>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Suggest.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAe,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Suggest.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAe,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAkC,oBAAoB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAErJ,qBAAa,UAAW,SAAQ,GAAG;IAC5B,UAAU,CAAC,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgB/E,WAAW,CAAC,iBAAiB,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiBlF,WAAW,CAAC,eAAe,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgBlF,YAAY,CAAC,iBAAiB,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAgB3F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SuggestResponseModel } from '
|
|
1
|
+
import { SuggestResponseModel } from '../../types';
|
|
2
2
|
export declare function transformSuggestResponse(response: SuggestResponseModel): any;
|
|
3
3
|
export declare namespace transformSuggestResponse {
|
|
4
4
|
var query: (response: SuggestResponseModel) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestResponse.d.ts","sourceRoot":"","sources":["../../../../src/Client/transforms/suggestResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"suggestResponse.d.ts","sourceRoot":"","sources":["../../../../src/Client/transforms/suggestResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,GAAG,CAO5E;yBAPe,wBAAwB"}
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SearchResponseModelResult } from '@searchspring/snapi-types';
|
|
1
2
|
export declare type ClientConfig = {
|
|
2
3
|
meta?: {
|
|
3
4
|
api?: SnapApiConfig;
|
|
@@ -11,6 +12,10 @@ export declare type ClientConfig = {
|
|
|
11
12
|
api?: SnapApiConfig;
|
|
12
13
|
cache?: CacheConfig;
|
|
13
14
|
};
|
|
15
|
+
finder?: {
|
|
16
|
+
api?: SnapApiConfig;
|
|
17
|
+
cache?: CacheConfig;
|
|
18
|
+
};
|
|
14
19
|
recommend?: {
|
|
15
20
|
api?: SnapApiConfig;
|
|
16
21
|
cache?: CacheConfig;
|
|
@@ -45,4 +50,100 @@ export declare type ClientGlobals = {
|
|
|
45
50
|
siteId: string;
|
|
46
51
|
[configurationPath: string]: any;
|
|
47
52
|
};
|
|
53
|
+
export declare type SuggestRequestModel = {
|
|
54
|
+
siteId: string;
|
|
55
|
+
query: string;
|
|
56
|
+
language?: string;
|
|
57
|
+
suggestionCount?: number;
|
|
58
|
+
productCount?: number;
|
|
59
|
+
disableSpellCorrect?: boolean;
|
|
60
|
+
};
|
|
61
|
+
export declare type SuggestResponseModelSuggestion = {
|
|
62
|
+
text: string;
|
|
63
|
+
type?: string;
|
|
64
|
+
source?: string;
|
|
65
|
+
popularity?: number;
|
|
66
|
+
completed?: {
|
|
67
|
+
token: string;
|
|
68
|
+
query: string;
|
|
69
|
+
type: string;
|
|
70
|
+
}[];
|
|
71
|
+
};
|
|
72
|
+
export declare type SuggestResponseModel = {
|
|
73
|
+
query: string;
|
|
74
|
+
'corrected-query'?: string;
|
|
75
|
+
suggested?: SuggestResponseModelSuggestion;
|
|
76
|
+
alternatives?: SuggestResponseModelSuggestion[];
|
|
77
|
+
};
|
|
78
|
+
export declare type TrendingRequestModel = {
|
|
79
|
+
siteId: string;
|
|
80
|
+
limit?: number;
|
|
81
|
+
};
|
|
82
|
+
export declare type TrendingResponseModel = {
|
|
83
|
+
trending: {
|
|
84
|
+
queries: {
|
|
85
|
+
popularity: number;
|
|
86
|
+
searchQuery: string;
|
|
87
|
+
}[];
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export declare type RecommendRequestModel = {
|
|
91
|
+
tags: string[];
|
|
92
|
+
siteId: string;
|
|
93
|
+
product?: string;
|
|
94
|
+
shopper?: string;
|
|
95
|
+
categories?: string[];
|
|
96
|
+
cart?: string[];
|
|
97
|
+
lastViewed?: string[];
|
|
98
|
+
test?: boolean;
|
|
99
|
+
batched?: boolean;
|
|
100
|
+
limits?: number | number[];
|
|
101
|
+
order?: number;
|
|
102
|
+
};
|
|
103
|
+
export declare type RecommendResponseModel = {
|
|
104
|
+
profile: {
|
|
105
|
+
tag: string;
|
|
106
|
+
};
|
|
107
|
+
results: SearchResponseModelResult[];
|
|
108
|
+
}[];
|
|
109
|
+
export declare type ProfileRequestModel = {
|
|
110
|
+
siteId: string;
|
|
111
|
+
tag: string;
|
|
112
|
+
branch?: string;
|
|
113
|
+
};
|
|
114
|
+
export declare type ProfileResponseModel = {
|
|
115
|
+
profile: {
|
|
116
|
+
tag: string;
|
|
117
|
+
placement: string;
|
|
118
|
+
display: {
|
|
119
|
+
threshold: number;
|
|
120
|
+
template: {
|
|
121
|
+
name: string;
|
|
122
|
+
uuid: string;
|
|
123
|
+
markup?: string;
|
|
124
|
+
styles?: string;
|
|
125
|
+
component?: string;
|
|
126
|
+
branch?: string;
|
|
127
|
+
group?: string;
|
|
128
|
+
};
|
|
129
|
+
templateParameters: {
|
|
130
|
+
[any: string]: unknown;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export declare type RecommendCombinedRequestModel = {
|
|
136
|
+
tag: string;
|
|
137
|
+
siteId: string;
|
|
138
|
+
product?: string;
|
|
139
|
+
shopper?: string;
|
|
140
|
+
categories?: string[];
|
|
141
|
+
cart?: string[];
|
|
142
|
+
lastViewed?: string[];
|
|
143
|
+
test?: boolean;
|
|
144
|
+
branch?: string;
|
|
145
|
+
};
|
|
146
|
+
export declare type RecommendCombinedResponseModel = ProfileResponseModel & {
|
|
147
|
+
results: SearchResponseModelResult[];
|
|
148
|
+
};
|
|
48
149
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/cjs/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY,GAAG;IAC1B,IAAI,CAAC,EAAE;QACN,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;IACF,MAAM,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;IACF,YAAY,CAAC,EAAE;QACd,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;IACF,SAAS,CAAC,EAAE;QACX,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;IACF,OAAO,CAAC,EAAE;QACT,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;CACF,CAAC;AAEF,oBAAY,WAAW,GAAG,OAAO,CAAC,kBAAkB,C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AAA;CAAE,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { TrendingRequestModel, TrendingResponseModel, RecommendCombinedRequestModel, RecommendCombinedResponseModel } from '
|
|
2
|
-
import type { ClientGlobals, ClientConfig } from '../types';
|
|
1
|
+
import type { ClientGlobals, ClientConfig, TrendingRequestModel, TrendingResponseModel, RecommendCombinedRequestModel, RecommendCombinedResponseModel } from '../types';
|
|
3
2
|
import type { MetaRequestModel, MetaResponseModel, SearchRequestModel, SearchResponseModel, AutocompleteRequestModel, AutocompleteResponseModel } from '@searchspring/snapi-types';
|
|
4
3
|
export declare class Client {
|
|
5
4
|
private globals;
|
|
@@ -9,6 +8,7 @@ export declare class Client {
|
|
|
9
8
|
meta(params?: MetaRequestModel): Promise<MetaResponseModel>;
|
|
10
9
|
autocomplete(params?: AutocompleteRequestModel): Promise<[MetaResponseModel, AutocompleteResponseModel]>;
|
|
11
10
|
search(params?: SearchRequestModel): Promise<[MetaResponseModel, SearchResponseModel]>;
|
|
11
|
+
finder(params?: SearchRequestModel): Promise<[MetaResponseModel, SearchResponseModel]>;
|
|
12
12
|
trending(params: Partial<TrendingRequestModel>): Promise<TrendingResponseModel>;
|
|
13
13
|
recommend(params: RecommendCombinedRequestModel): Promise<RecommendCombinedResponseModel>;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/Client/Client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/Client/Client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EAGrB,6BAA6B,EAC7B,8BAA8B,EAC9B,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EACX,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,MAAM,2BAA2B,CAAC;AAqCnC,qBAAa,MAAM;IAClB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAOhB;gBAEU,OAAO,EAAE,aAAa,EAAE,MAAM,GAAE,YAAiB;IAgDvD,IAAI,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAO3D,YAAY,CAAC,MAAM,GAAE,wBAA6B,GAAG,OAAO,CAAC,CAAC,iBAAiB,EAAE,yBAAyB,CAAC,CAAC;IAU5G,MAAM,CAAC,MAAM,GAAE,kBAAuB,GAAG,OAAO,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;IAM1F,MAAM,CAAC,MAAM,GAAE,kBAAuB,GAAG,OAAO,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;IAM1F,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAM/E,SAAS,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,8BAA8B,CAAC;CAgC/F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HybridAPI, SuggestAPI, RecommendAPI, ApiConfiguration
|
|
1
|
+
import { HybridAPI, SuggestAPI, RecommendAPI, ApiConfiguration } from './apis';
|
|
2
2
|
import deepmerge from 'deepmerge';
|
|
3
3
|
const defaultConfig = {
|
|
4
4
|
meta: {
|
|
@@ -21,6 +21,11 @@ const defaultConfig = {
|
|
|
21
21
|
// origin: 'https://snapi.kube.searchspring.io',
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
|
+
finder: {
|
|
25
|
+
api: {
|
|
26
|
+
// origin: 'https://snapi.kube.searchspring.io',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
24
29
|
suggest: {
|
|
25
30
|
api: {
|
|
26
31
|
// origin: 'https://snapi.kube.searchspring.io',
|
|
@@ -51,6 +56,10 @@ export class Client {
|
|
|
51
56
|
origin: this.config.search?.api?.origin,
|
|
52
57
|
cache: this.config.search?.cache,
|
|
53
58
|
})),
|
|
59
|
+
finder: new HybridAPI(new ApiConfiguration({
|
|
60
|
+
origin: this.config.finder?.api?.origin,
|
|
61
|
+
cache: this.config.finder?.cache,
|
|
62
|
+
})),
|
|
54
63
|
suggest: new SuggestAPI(new ApiConfiguration({
|
|
55
64
|
origin: this.config.suggest?.api?.origin,
|
|
56
65
|
cache: this.config.suggest?.cache,
|
|
@@ -73,6 +82,10 @@ export class Client {
|
|
|
73
82
|
params = deepmerge(this.globals, params);
|
|
74
83
|
return Promise.all([this.meta({ siteId: params.siteId || '' }), this.requesters.search.getSearch(params)]);
|
|
75
84
|
}
|
|
85
|
+
async finder(params = {}) {
|
|
86
|
+
params = deepmerge(this.globals, params);
|
|
87
|
+
return Promise.all([this.meta({ siteId: params.siteId || '' }), this.requesters.finder.getFinder(params)]);
|
|
88
|
+
}
|
|
76
89
|
async trending(params) {
|
|
77
90
|
params = deepmerge({ siteId: this.globals.siteId }, params || {});
|
|
78
91
|
return this.requesters.suggest.getTrending(params);
|
|
@@ -5,6 +5,7 @@ export declare class HybridAPI extends API {
|
|
|
5
5
|
constructor(configuration: ApiConfiguration);
|
|
6
6
|
getMeta(requestParameters: MetaRequestModel): Promise<MetaResponseModel>;
|
|
7
7
|
getSearch(requestParameters: SearchRequestModel): Promise<SearchResponseModel>;
|
|
8
|
+
getFinder(requestParameters: SearchRequestModel): Promise<SearchResponseModel>;
|
|
8
9
|
getAutocomplete(requestParameters: AutocompleteRequestModel): Promise<AutocompleteResponseModel>;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=Hybrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hybrid.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Hybrid.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"Hybrid.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Hybrid.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,GAAG,EAAyB,gBAAgB,EAAE,MAAM,GAAG,CAAC;AAIjE,qBAAa,SAAU,SAAQ,GAAG;IACjC,OAAO,CAAC,UAAU,CAGhB;gBAEU,aAAa,EAAE,gBAAgB;IASrC,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKxE,SAAS,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQ9E,SAAS,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQ9E,eAAe,CAAC,iBAAiB,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAoCtG"}
|
|
@@ -17,6 +17,11 @@ export class HybridAPI extends API {
|
|
|
17
17
|
const legacyData = await this.requesters.legacy.getSearch(legacyRequestParameters);
|
|
18
18
|
return transformSearchResponse(legacyData, requestParameters);
|
|
19
19
|
}
|
|
20
|
+
async getFinder(requestParameters) {
|
|
21
|
+
const legacyRequestParameters = transformSearchRequest(requestParameters);
|
|
22
|
+
const legacyData = await this.requesters.legacy.getFinder(legacyRequestParameters);
|
|
23
|
+
return transformSearchResponse(legacyData, requestParameters);
|
|
24
|
+
}
|
|
20
25
|
async getAutocomplete(requestParameters) {
|
|
21
26
|
const legacyRequestParameters = transformSearchRequest(requestParameters);
|
|
22
27
|
const suggestParams = {
|
|
@@ -1,82 +1,11 @@
|
|
|
1
1
|
import { API, ApiConfiguration } from './Abstract';
|
|
2
|
-
import {
|
|
3
|
-
export declare type RecommendRequestModel = {
|
|
4
|
-
tags: string[];
|
|
5
|
-
siteId: string;
|
|
6
|
-
product?: string;
|
|
7
|
-
shopper?: string;
|
|
8
|
-
categories?: string[];
|
|
9
|
-
cart?: string[];
|
|
10
|
-
lastViewed?: string[];
|
|
11
|
-
test?: boolean;
|
|
12
|
-
batched?: boolean;
|
|
13
|
-
limits?: number | number[];
|
|
14
|
-
};
|
|
15
|
-
export declare type RecommendResponseModel = {
|
|
16
|
-
profile: {
|
|
17
|
-
tag: string;
|
|
18
|
-
};
|
|
19
|
-
results: SearchResponseModelResult[];
|
|
20
|
-
}[];
|
|
21
|
-
export declare type ProfileRequestModel = {
|
|
22
|
-
siteId: string;
|
|
23
|
-
tag: string;
|
|
24
|
-
branch?: string;
|
|
25
|
-
};
|
|
26
|
-
export declare type ProfileResponseModel = {
|
|
27
|
-
profile: {
|
|
28
|
-
tag: string;
|
|
29
|
-
placement: string;
|
|
30
|
-
display: {
|
|
31
|
-
threshold: number;
|
|
32
|
-
template: {
|
|
33
|
-
name: string;
|
|
34
|
-
uuid: string;
|
|
35
|
-
markup?: string;
|
|
36
|
-
styles?: string;
|
|
37
|
-
component?: string;
|
|
38
|
-
branch?: string;
|
|
39
|
-
group?: string;
|
|
40
|
-
};
|
|
41
|
-
templateParameters: {
|
|
42
|
-
[any: string]: unknown;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export declare type RecommendCombinedRequestModel = {
|
|
48
|
-
tag: string;
|
|
49
|
-
siteId: string;
|
|
50
|
-
product?: string;
|
|
51
|
-
shopper?: string;
|
|
52
|
-
categories?: string[];
|
|
53
|
-
cart?: string[];
|
|
54
|
-
lastViewed?: string[];
|
|
55
|
-
test?: boolean;
|
|
56
|
-
branch?: string;
|
|
57
|
-
};
|
|
58
|
-
declare class Deferred {
|
|
59
|
-
promise: Promise<any>;
|
|
60
|
-
resolve: any;
|
|
61
|
-
reject: any;
|
|
62
|
-
constructor();
|
|
63
|
-
}
|
|
64
|
-
export declare type RecommendCombinedResponseModel = ProfileResponseModel & {
|
|
65
|
-
results: SearchResponseModelResult[];
|
|
66
|
-
};
|
|
2
|
+
import { ProfileRequestModel, ProfileResponseModel, RecommendRequestModel, RecommendResponseModel } from '../../types';
|
|
67
3
|
export declare class RecommendAPI extends API {
|
|
68
|
-
batches
|
|
69
|
-
[key: string]: {
|
|
70
|
-
timeout: number;
|
|
71
|
-
request: any;
|
|
72
|
-
deferreds?: Deferred[];
|
|
73
|
-
};
|
|
74
|
-
};
|
|
4
|
+
private batches;
|
|
75
5
|
constructor(config: ApiConfiguration);
|
|
76
6
|
getProfile(queryParameters: ProfileRequestModel): Promise<ProfileResponseModel>;
|
|
77
7
|
batchRecommendations(parameters: RecommendRequestModel): Promise<RecommendResponseModel>;
|
|
78
8
|
getRecommendations(queryParameters: RecommendRequestModel): Promise<RecommendResponseModel>;
|
|
79
9
|
postRecommendations(requestParameters: RecommendRequestModel): Promise<RecommendResponseModel>;
|
|
80
10
|
}
|
|
81
|
-
export {};
|
|
82
11
|
//# sourceMappingURL=Recommend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Recommend.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Recommend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Recommend.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Recommend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;AAIhE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAgBvH,qBAAa,YAAa,SAAQ,GAAG;IACpC,OAAO,CAAC,OAAO,CAOb;gBAEU,MAAM,EAAE,gBAAgB;IAK9B,UAAU,CAAC,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgB/E,oBAAoB,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAgFxF,kBAAkB,CAAC,eAAe,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAmB3F,mBAAmB,CAAC,iBAAiB,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAmBpG"}
|
|
@@ -27,59 +27,70 @@ export class RecommendAPI extends API {
|
|
|
27
27
|
}
|
|
28
28
|
async batchRecommendations(parameters) {
|
|
29
29
|
let { tags, limits, categories, ...otherParams } = parameters;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
key = otherParams.siteId;
|
|
30
|
+
const getKey = (parameters) => {
|
|
31
|
+
let key = hashParams(parameters);
|
|
32
|
+
if ('batched' in parameters) {
|
|
33
|
+
if (parameters.batched) {
|
|
34
|
+
key = parameters.siteId;
|
|
35
|
+
}
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const
|
|
37
|
+
return key;
|
|
38
|
+
};
|
|
39
|
+
// set up batch keys and deferred promises
|
|
40
|
+
const key = getKey(otherParams);
|
|
41
|
+
const batch = (this.batches[key] = this.batches[key] || { timeout: null, request: { tags: [], limits: [] }, requests: [], deferreds: [] });
|
|
42
42
|
const deferred = new Deferred();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
// add each request to the list
|
|
44
|
+
batch.requests.push({ ...parameters });
|
|
45
|
+
batch.deferreds?.push(deferred);
|
|
46
|
+
// wait for all of the requests to come in
|
|
47
|
+
window.clearTimeout(batch.timeout);
|
|
48
|
+
batch.timeout = window.setTimeout(async () => {
|
|
49
|
+
// delete the batch so a new one can take its place
|
|
50
|
+
delete this.batches[key];
|
|
51
|
+
// reorder the requests by order value in context.
|
|
52
|
+
const batchedRequests = batch.requests.sort(sortRequests);
|
|
53
|
+
// now that the requests are in proper order, map through them
|
|
54
|
+
// and build out the batches
|
|
55
|
+
batchedRequests.map((request) => {
|
|
56
|
+
let { tags, limits, categories, ...otherParams } = request;
|
|
57
|
+
if (!limits)
|
|
58
|
+
limits = 20;
|
|
59
|
+
const [tag] = tags || [];
|
|
60
|
+
delete otherParams.batched; // remove from request parameters
|
|
61
|
+
delete otherParams.order; // remove from request parameters
|
|
62
|
+
batch.request.tags.push(tag);
|
|
63
|
+
if (categories) {
|
|
64
|
+
if (!batch.request.categories) {
|
|
65
|
+
batch.request.categories = categories;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
batch.request.categories = batch.request.categories.concat(categories);
|
|
69
|
+
}
|
|
63
70
|
}
|
|
64
|
-
|
|
71
|
+
batch.request.limits = batch.request.limits.concat(limits);
|
|
72
|
+
batch.request = { ...batch.request, ...otherParams };
|
|
73
|
+
});
|
|
65
74
|
try {
|
|
66
75
|
let response;
|
|
67
|
-
if (charsParams(
|
|
68
|
-
|
|
76
|
+
if (charsParams(batch.request) > 1024) {
|
|
77
|
+
if (batch.request['product']) {
|
|
78
|
+
batch.request['product'] = batch.request['product'].toString();
|
|
79
|
+
}
|
|
80
|
+
response = await this.postRecommendations(batch.request);
|
|
69
81
|
}
|
|
70
82
|
else {
|
|
71
|
-
response = await this.getRecommendations(
|
|
83
|
+
response = await this.getRecommendations(batch.request);
|
|
72
84
|
}
|
|
73
|
-
|
|
85
|
+
batch.deferreds?.forEach((def, index) => {
|
|
74
86
|
def.resolve([response[index]]);
|
|
75
87
|
});
|
|
76
88
|
}
|
|
77
89
|
catch (err) {
|
|
78
|
-
|
|
90
|
+
batch.deferreds?.forEach((def) => {
|
|
79
91
|
def.reject(err);
|
|
80
92
|
});
|
|
81
93
|
}
|
|
82
|
-
delete this.batches[key];
|
|
83
94
|
}, BATCH_TIMEOUT);
|
|
84
95
|
return deferred.promise;
|
|
85
96
|
}
|
|
@@ -109,3 +120,22 @@ export class RecommendAPI extends API {
|
|
|
109
120
|
return response;
|
|
110
121
|
}
|
|
111
122
|
}
|
|
123
|
+
function sortRequests(a, b) {
|
|
124
|
+
// undefined order goes last
|
|
125
|
+
if (a.order == undefined && b.order == undefined) {
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
if (a.order == undefined && b.order != undefined) {
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
if (b.order == undefined && a.order != undefined) {
|
|
132
|
+
return -1;
|
|
133
|
+
}
|
|
134
|
+
if (a.order < b.order) {
|
|
135
|
+
return -1;
|
|
136
|
+
}
|
|
137
|
+
if (a.order > b.order) {
|
|
138
|
+
return 1;
|
|
139
|
+
}
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
@@ -1,41 +1,5 @@
|
|
|
1
1
|
import { API } from './Abstract';
|
|
2
|
-
|
|
3
|
-
siteId: string;
|
|
4
|
-
query: string;
|
|
5
|
-
language?: string;
|
|
6
|
-
suggestionCount?: number;
|
|
7
|
-
productCount?: number;
|
|
8
|
-
disableSpellCorrect?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare type SuggestResponseModelSuggestion = {
|
|
11
|
-
text: string;
|
|
12
|
-
type?: string;
|
|
13
|
-
source?: string;
|
|
14
|
-
popularity?: number;
|
|
15
|
-
completed?: {
|
|
16
|
-
token: string;
|
|
17
|
-
query: string;
|
|
18
|
-
type: string;
|
|
19
|
-
}[];
|
|
20
|
-
};
|
|
21
|
-
export declare type SuggestResponseModel = {
|
|
22
|
-
query: string;
|
|
23
|
-
'corrected-query'?: string;
|
|
24
|
-
suggested?: SuggestResponseModelSuggestion;
|
|
25
|
-
alternatives?: SuggestResponseModelSuggestion[];
|
|
26
|
-
};
|
|
27
|
-
export declare type TrendingRequestModel = {
|
|
28
|
-
siteId: string;
|
|
29
|
-
limit?: number;
|
|
30
|
-
};
|
|
31
|
-
export declare type TrendingResponseModel = {
|
|
32
|
-
trending: {
|
|
33
|
-
queries: {
|
|
34
|
-
popularity: number;
|
|
35
|
-
searchQuery: string;
|
|
36
|
-
}[];
|
|
37
|
-
};
|
|
38
|
-
};
|
|
2
|
+
import { SuggestRequestModel, SuggestResponseModel, TrendingRequestModel, TrendingResponseModel } from '../../types';
|
|
39
3
|
export declare class SuggestAPI extends API {
|
|
40
4
|
getSuggest(queryParameters: SuggestRequestModel): Promise<SuggestResponseModel>;
|
|
41
5
|
postSuggest(requestParameters: SuggestRequestModel): Promise<SuggestResponseModel>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Suggest.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAe,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Suggest.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAe,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAkC,oBAAoB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAErJ,qBAAa,UAAW,SAAQ,GAAG;IAC5B,UAAU,CAAC,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgB/E,WAAW,CAAC,iBAAiB,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiBlF,WAAW,CAAC,eAAe,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgBlF,YAAY,CAAC,iBAAiB,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAgB3F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SuggestResponseModel } from '
|
|
1
|
+
import { SuggestResponseModel } from '../../types';
|
|
2
2
|
export declare function transformSuggestResponse(response: SuggestResponseModel): any;
|
|
3
3
|
export declare namespace transformSuggestResponse {
|
|
4
4
|
var query: (response: SuggestResponseModel) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestResponse.d.ts","sourceRoot":"","sources":["../../../../src/Client/transforms/suggestResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"suggestResponse.d.ts","sourceRoot":"","sources":["../../../../src/Client/transforms/suggestResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,GAAG,CAO5E;yBAPe,wBAAwB"}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SearchResponseModelResult } from '@searchspring/snapi-types';
|
|
1
2
|
export declare type ClientConfig = {
|
|
2
3
|
meta?: {
|
|
3
4
|
api?: SnapApiConfig;
|
|
@@ -11,6 +12,10 @@ export declare type ClientConfig = {
|
|
|
11
12
|
api?: SnapApiConfig;
|
|
12
13
|
cache?: CacheConfig;
|
|
13
14
|
};
|
|
15
|
+
finder?: {
|
|
16
|
+
api?: SnapApiConfig;
|
|
17
|
+
cache?: CacheConfig;
|
|
18
|
+
};
|
|
14
19
|
recommend?: {
|
|
15
20
|
api?: SnapApiConfig;
|
|
16
21
|
cache?: CacheConfig;
|
|
@@ -45,4 +50,100 @@ export declare type ClientGlobals = {
|
|
|
45
50
|
siteId: string;
|
|
46
51
|
[configurationPath: string]: any;
|
|
47
52
|
};
|
|
53
|
+
export declare type SuggestRequestModel = {
|
|
54
|
+
siteId: string;
|
|
55
|
+
query: string;
|
|
56
|
+
language?: string;
|
|
57
|
+
suggestionCount?: number;
|
|
58
|
+
productCount?: number;
|
|
59
|
+
disableSpellCorrect?: boolean;
|
|
60
|
+
};
|
|
61
|
+
export declare type SuggestResponseModelSuggestion = {
|
|
62
|
+
text: string;
|
|
63
|
+
type?: string;
|
|
64
|
+
source?: string;
|
|
65
|
+
popularity?: number;
|
|
66
|
+
completed?: {
|
|
67
|
+
token: string;
|
|
68
|
+
query: string;
|
|
69
|
+
type: string;
|
|
70
|
+
}[];
|
|
71
|
+
};
|
|
72
|
+
export declare type SuggestResponseModel = {
|
|
73
|
+
query: string;
|
|
74
|
+
'corrected-query'?: string;
|
|
75
|
+
suggested?: SuggestResponseModelSuggestion;
|
|
76
|
+
alternatives?: SuggestResponseModelSuggestion[];
|
|
77
|
+
};
|
|
78
|
+
export declare type TrendingRequestModel = {
|
|
79
|
+
siteId: string;
|
|
80
|
+
limit?: number;
|
|
81
|
+
};
|
|
82
|
+
export declare type TrendingResponseModel = {
|
|
83
|
+
trending: {
|
|
84
|
+
queries: {
|
|
85
|
+
popularity: number;
|
|
86
|
+
searchQuery: string;
|
|
87
|
+
}[];
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export declare type RecommendRequestModel = {
|
|
91
|
+
tags: string[];
|
|
92
|
+
siteId: string;
|
|
93
|
+
product?: string;
|
|
94
|
+
shopper?: string;
|
|
95
|
+
categories?: string[];
|
|
96
|
+
cart?: string[];
|
|
97
|
+
lastViewed?: string[];
|
|
98
|
+
test?: boolean;
|
|
99
|
+
batched?: boolean;
|
|
100
|
+
limits?: number | number[];
|
|
101
|
+
order?: number;
|
|
102
|
+
};
|
|
103
|
+
export declare type RecommendResponseModel = {
|
|
104
|
+
profile: {
|
|
105
|
+
tag: string;
|
|
106
|
+
};
|
|
107
|
+
results: SearchResponseModelResult[];
|
|
108
|
+
}[];
|
|
109
|
+
export declare type ProfileRequestModel = {
|
|
110
|
+
siteId: string;
|
|
111
|
+
tag: string;
|
|
112
|
+
branch?: string;
|
|
113
|
+
};
|
|
114
|
+
export declare type ProfileResponseModel = {
|
|
115
|
+
profile: {
|
|
116
|
+
tag: string;
|
|
117
|
+
placement: string;
|
|
118
|
+
display: {
|
|
119
|
+
threshold: number;
|
|
120
|
+
template: {
|
|
121
|
+
name: string;
|
|
122
|
+
uuid: string;
|
|
123
|
+
markup?: string;
|
|
124
|
+
styles?: string;
|
|
125
|
+
component?: string;
|
|
126
|
+
branch?: string;
|
|
127
|
+
group?: string;
|
|
128
|
+
};
|
|
129
|
+
templateParameters: {
|
|
130
|
+
[any: string]: unknown;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export declare type RecommendCombinedRequestModel = {
|
|
136
|
+
tag: string;
|
|
137
|
+
siteId: string;
|
|
138
|
+
product?: string;
|
|
139
|
+
shopper?: string;
|
|
140
|
+
categories?: string[];
|
|
141
|
+
cart?: string[];
|
|
142
|
+
lastViewed?: string[];
|
|
143
|
+
test?: boolean;
|
|
144
|
+
branch?: string;
|
|
145
|
+
};
|
|
146
|
+
export declare type RecommendCombinedResponseModel = ProfileResponseModel & {
|
|
147
|
+
results: SearchResponseModelResult[];
|
|
148
|
+
};
|
|
48
149
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY,GAAG;IAC1B,IAAI,CAAC,EAAE;QACN,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;IACF,MAAM,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;IACF,YAAY,CAAC,EAAE;QACd,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;IACF,SAAS,CAAC,EAAE;QACX,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;IACF,OAAO,CAAC,EAAE;QACT,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,WAAW,CAAC;KACpB,CAAC;CACF,CAAC;AAEF,oBAAY,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEtD,oBAAY,kBAAkB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAE,CAAC;CACtC,CAAC;AACF,oBAAY,UAAU,GAAG;IACxB,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC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S,EAAE,MAAM,CAAC;YAClB,QAAQ,EAAE;gBACT,IAAI,EAAE,MAAM,CAAC;gBACb,IAAI,EAAE,MAAM,CAAC;gBACb,MAAM,CAAC,EAAE,MAAM,CAAC;gBAChB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAChB,SAAS,CAAC,EAAE,MAAM,CAAC;gBACnB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAChB,KAAK,CAAC,EAAE,MAAM,CAAC;aACf,CAAC;YACF,kBAAkB,EAAE;gBACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;aACvB,CAAC;SACF,CAAC;KACF,CAAC;CACF,CAAC;AAEF,oBAAY,6BAA6B,GAAG;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,8BAA8B,GAAG,oBAAoB,GAAG;IAAE,OAAO,EAAE,yBAAyB,EAAE,CAAA;CAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@searchspring/snap-client",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.8",
|
|
4
4
|
"description": "Snap Client",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"test:watch": "jest --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@searchspring/snap-toolbox": "^0.27.
|
|
24
|
-
"deepmerge": "
|
|
23
|
+
"@searchspring/snap-toolbox": "^0.27.8",
|
|
24
|
+
"deepmerge": "4.2.2"
|
|
25
25
|
},
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"files": [
|
|
28
28
|
"dist/**/*"
|
|
29
29
|
],
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "cfbe6d18899fb4944ec397e2419d8409d4ab0065"
|
|
31
31
|
}
|