@searchspring/snap-client 0.20.0

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.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/cjs/Client/Client.d.ts +15 -0
  4. package/dist/cjs/Client/Client.d.ts.map +1 -0
  5. package/dist/cjs/Client/Client.js +198 -0
  6. package/dist/cjs/Client/NetworkCache/NetworkCache.d.ts +10 -0
  7. package/dist/cjs/Client/NetworkCache/NetworkCache.d.ts.map +1 -0
  8. package/dist/cjs/Client/NetworkCache/NetworkCache.js +104 -0
  9. package/dist/cjs/Client/apis/Abstract.d.ts +49 -0
  10. package/dist/cjs/Client/apis/Abstract.d.ts.map +1 -0
  11. package/dist/cjs/Client/apis/Abstract.js +209 -0
  12. package/dist/cjs/Client/apis/Hybrid.d.ts +10 -0
  13. package/dist/cjs/Client/apis/Hybrid.d.ts.map +1 -0
  14. package/dist/cjs/Client/apis/Hybrid.js +137 -0
  15. package/dist/cjs/Client/apis/Legacy.d.ts +11 -0
  16. package/dist/cjs/Client/apis/Legacy.d.ts.map +1 -0
  17. package/dist/cjs/Client/apis/Legacy.js +147 -0
  18. package/dist/cjs/Client/apis/Recommend.d.ts +81 -0
  19. package/dist/cjs/Client/apis/Recommend.d.ts.map +1 -0
  20. package/dist/cjs/Client/apis/Recommend.js +222 -0
  21. package/dist/cjs/Client/apis/Snap.d.ts +8 -0
  22. package/dist/cjs/Client/apis/Snap.d.ts.map +1 -0
  23. package/dist/cjs/Client/apis/Snap.js +126 -0
  24. package/dist/cjs/Client/apis/Suggest.d.ts +45 -0
  25. package/dist/cjs/Client/apis/Suggest.d.ts.map +1 -0
  26. package/dist/cjs/Client/apis/Suggest.js +145 -0
  27. package/dist/cjs/Client/apis/index.d.ts +7 -0
  28. package/dist/cjs/Client/apis/index.d.ts.map +1 -0
  29. package/dist/cjs/Client/apis/index.js +18 -0
  30. package/dist/cjs/Client/transforms/index.d.ts +4 -0
  31. package/dist/cjs/Client/transforms/index.d.ts.map +1 -0
  32. package/dist/cjs/Client/transforms/index.js +15 -0
  33. package/dist/cjs/Client/transforms/searchRequest.d.ts +47 -0
  34. package/dist/cjs/Client/transforms/searchRequest.d.ts.map +1 -0
  35. package/dist/cjs/Client/transforms/searchRequest.js +151 -0
  36. package/dist/cjs/Client/transforms/searchResponse.d.ts +31 -0
  37. package/dist/cjs/Client/transforms/searchResponse.d.ts.map +1 -0
  38. package/dist/cjs/Client/transforms/searchResponse.js +246 -0
  39. package/dist/cjs/Client/transforms/suggestResponse.d.ts +29 -0
  40. package/dist/cjs/Client/transforms/suggestResponse.d.ts.map +1 -0
  41. package/dist/cjs/Client/transforms/suggestResponse.js +53 -0
  42. package/dist/cjs/Client/utils/charsParams.d.ts +3 -0
  43. package/dist/cjs/Client/utils/charsParams.d.ts.map +1 -0
  44. package/dist/cjs/Client/utils/charsParams.js +23 -0
  45. package/dist/cjs/Client/utils/fibonacci.d.ts +2 -0
  46. package/dist/cjs/Client/utils/fibonacci.d.ts.map +1 -0
  47. package/dist/cjs/Client/utils/fibonacci.js +14 -0
  48. package/dist/cjs/Client/utils/hashParams.d.ts +3 -0
  49. package/dist/cjs/Client/utils/hashParams.d.ts.map +1 -0
  50. package/dist/cjs/Client/utils/hashParams.js +10 -0
  51. package/dist/cjs/Client/utils/htmlUnescape.d.ts +2 -0
  52. package/dist/cjs/Client/utils/htmlUnescape.d.ts.map +1 -0
  53. package/dist/cjs/Client/utils/htmlUnescape.js +12 -0
  54. package/dist/cjs/Client/utils/index.d.ts +2 -0
  55. package/dist/cjs/Client/utils/index.d.ts.map +1 -0
  56. package/dist/cjs/Client/utils/index.js +13 -0
  57. package/dist/cjs/Client/utils/mergeParams.d.ts +2 -0
  58. package/dist/cjs/Client/utils/mergeParams.d.ts.map +1 -0
  59. package/dist/cjs/Client/utils/mergeParams.js +18 -0
  60. package/dist/cjs/index.d.ts +3 -0
  61. package/dist/cjs/index.d.ts.map +1 -0
  62. package/dist/cjs/index.js +13 -0
  63. package/dist/cjs/types.d.ts +45 -0
  64. package/dist/cjs/types.d.ts.map +1 -0
  65. package/dist/cjs/types.js +2 -0
  66. package/dist/esm/Client/Client.d.ts +15 -0
  67. package/dist/esm/Client/Client.d.ts.map +1 -0
  68. package/dist/esm/Client/Client.js +108 -0
  69. package/dist/esm/Client/NetworkCache/NetworkCache.d.ts +10 -0
  70. package/dist/esm/Client/NetworkCache/NetworkCache.d.ts.map +1 -0
  71. package/dist/esm/Client/NetworkCache/NetworkCache.js +89 -0
  72. package/dist/esm/Client/apis/Abstract.d.ts +49 -0
  73. package/dist/esm/Client/apis/Abstract.d.ts.map +1 -0
  74. package/dist/esm/Client/apis/Abstract.js +119 -0
  75. package/dist/esm/Client/apis/Hybrid.d.ts +10 -0
  76. package/dist/esm/Client/apis/Hybrid.d.ts.map +1 -0
  77. package/dist/esm/Client/apis/Hybrid.js +49 -0
  78. package/dist/esm/Client/apis/Legacy.d.ts +11 -0
  79. package/dist/esm/Client/apis/Legacy.d.ts.map +1 -0
  80. package/dist/esm/Client/apis/Legacy.js +44 -0
  81. package/dist/esm/Client/apis/Recommend.d.ts +81 -0
  82. package/dist/esm/Client/apis/Recommend.d.ts.map +1 -0
  83. package/dist/esm/Client/apis/Recommend.js +91 -0
  84. package/dist/esm/Client/apis/Snap.d.ts +8 -0
  85. package/dist/esm/Client/apis/Snap.d.ts.map +1 -0
  86. package/dist/esm/Client/apis/Snap.js +36 -0
  87. package/dist/esm/Client/apis/Suggest.d.ts +45 -0
  88. package/dist/esm/Client/apis/Suggest.d.ts.map +1 -0
  89. package/dist/esm/Client/apis/Suggest.js +45 -0
  90. package/dist/esm/Client/apis/index.d.ts +7 -0
  91. package/dist/esm/Client/apis/index.d.ts.map +1 -0
  92. package/dist/esm/Client/apis/index.js +6 -0
  93. package/dist/esm/Client/transforms/index.d.ts +4 -0
  94. package/dist/esm/Client/transforms/index.d.ts.map +1 -0
  95. package/dist/esm/Client/transforms/index.js +3 -0
  96. package/dist/esm/Client/transforms/searchRequest.d.ts +47 -0
  97. package/dist/esm/Client/transforms/searchRequest.d.ts.map +1 -0
  98. package/dist/esm/Client/transforms/searchRequest.js +133 -0
  99. package/dist/esm/Client/transforms/searchResponse.d.ts +31 -0
  100. package/dist/esm/Client/transforms/searchResponse.d.ts.map +1 -0
  101. package/dist/esm/Client/transforms/searchResponse.js +249 -0
  102. package/dist/esm/Client/transforms/suggestResponse.d.ts +29 -0
  103. package/dist/esm/Client/transforms/suggestResponse.d.ts.map +1 -0
  104. package/dist/esm/Client/transforms/suggestResponse.js +42 -0
  105. package/dist/esm/Client/utils/charsParams.d.ts +3 -0
  106. package/dist/esm/Client/utils/charsParams.d.ts.map +1 -0
  107. package/dist/esm/Client/utils/charsParams.js +19 -0
  108. package/dist/esm/Client/utils/fibonacci.d.ts +2 -0
  109. package/dist/esm/Client/utils/fibonacci.d.ts.map +1 -0
  110. package/dist/esm/Client/utils/fibonacci.js +10 -0
  111. package/dist/esm/Client/utils/hashParams.d.ts +3 -0
  112. package/dist/esm/Client/utils/hashParams.d.ts.map +1 -0
  113. package/dist/esm/Client/utils/hashParams.js +6 -0
  114. package/dist/esm/Client/utils/htmlUnescape.d.ts +2 -0
  115. package/dist/esm/Client/utils/htmlUnescape.d.ts.map +1 -0
  116. package/dist/esm/Client/utils/htmlUnescape.js +8 -0
  117. package/dist/esm/Client/utils/index.d.ts +2 -0
  118. package/dist/esm/Client/utils/index.d.ts.map +1 -0
  119. package/dist/esm/Client/utils/index.js +1 -0
  120. package/dist/esm/Client/utils/mergeParams.d.ts +2 -0
  121. package/dist/esm/Client/utils/mergeParams.d.ts.map +1 -0
  122. package/dist/esm/Client/utils/mergeParams.js +10 -0
  123. package/dist/esm/index.d.ts +3 -0
  124. package/dist/esm/index.d.ts.map +1 -0
  125. package/dist/esm/index.js +1 -0
  126. package/dist/esm/types.d.ts +45 -0
  127. package/dist/esm/types.d.ts.map +1 -0
  128. package/dist/esm/types.js +1 -0
  129. package/package.json +27 -0
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __generator = (this && this.__generator) || function (thisArg, body) {
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
+ function verb(n) { return function (v) { return step([n, v]); }; }
41
+ function step(op) {
42
+ if (f) throw new TypeError("Generator is already executing.");
43
+ while (_) try {
44
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
+ if (y = 0, t) op = [op[0] & 2, t.value];
46
+ switch (op[0]) {
47
+ case 0: case 1: t = op; break;
48
+ case 4: _.label++; return { value: op[1], done: false };
49
+ case 5: _.label++; y = op[1]; op = [0]; continue;
50
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
+ default:
52
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
+ if (t[2]) _.ops.pop();
57
+ _.trys.pop(); continue;
58
+ }
59
+ op = body.call(thisArg, _);
60
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
+ }
63
+ };
64
+ var __rest = (this && this.__rest) || function (s, e) {
65
+ var t = {};
66
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
67
+ t[p] = s[p];
68
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
69
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
71
+ t[p[i]] = s[p[i]];
72
+ }
73
+ return t;
74
+ };
75
+ Object.defineProperty(exports, "__esModule", { value: true });
76
+ exports.RecommendAPI = void 0;
77
+ var Abstract_1 = require("./Abstract");
78
+ var hashParams_1 = require("../utils/hashParams");
79
+ var charsParams_1 = require("../utils/charsParams");
80
+ var Deferred = /** @class */ (function () {
81
+ function Deferred() {
82
+ var _this = this;
83
+ this.promise = new Promise(function (resolve, reject) {
84
+ _this.reject = reject;
85
+ _this.resolve = resolve;
86
+ });
87
+ }
88
+ return Deferred;
89
+ }());
90
+ var BATCH_TIMEOUT = 150;
91
+ var RecommendAPI = /** @class */ (function (_super) {
92
+ __extends(RecommendAPI, _super);
93
+ function RecommendAPI(config) {
94
+ var _this = _super.call(this, config) || this;
95
+ _this.batches = {};
96
+ return _this;
97
+ }
98
+ RecommendAPI.prototype.getProfile = function (queryParameters) {
99
+ return __awaiter(this, void 0, void 0, function () {
100
+ var headerParameters, response;
101
+ return __generator(this, function (_a) {
102
+ switch (_a.label) {
103
+ case 0:
104
+ headerParameters = {};
105
+ return [4 /*yield*/, this.request({
106
+ path: '/api/personalized-recommendations/profile.json',
107
+ method: 'GET',
108
+ headers: headerParameters,
109
+ query: queryParameters,
110
+ }, '/api/personalized-recommendations/profile.json' + JSON.stringify(queryParameters))];
111
+ case 1:
112
+ response = _a.sent();
113
+ return [2 /*return*/, response];
114
+ }
115
+ });
116
+ });
117
+ };
118
+ RecommendAPI.prototype.batchRecommendations = function (parameters) {
119
+ return __awaiter(this, void 0, void 0, function () {
120
+ var tags, otherParams, tag, key, paramBatch, deferred;
121
+ var _this = this;
122
+ return __generator(this, function (_a) {
123
+ tags = parameters.tags, otherParams = __rest(parameters, ["tags"]);
124
+ tag = (tags || [])[0];
125
+ if (!tag)
126
+ return [2 /*return*/];
127
+ key = (0, hashParams_1.hashParams)(otherParams);
128
+ if ('batched' in otherParams) {
129
+ if (otherParams.batched) {
130
+ key = otherParams.siteId;
131
+ }
132
+ delete otherParams.batched; // remove from request parameters
133
+ }
134
+ this.batches[key] = this.batches[key] || { timeout: null, request: __assign({ tags: [] }, otherParams), deferreds: [] };
135
+ paramBatch = this.batches[key];
136
+ deferred = new Deferred();
137
+ paramBatch.request.tags.push(tag);
138
+ paramBatch.deferreds.push(deferred);
139
+ window.clearTimeout(paramBatch.timeout);
140
+ paramBatch.timeout = window.setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
141
+ var requestMethod, response_1, err_1;
142
+ return __generator(this, function (_a) {
143
+ switch (_a.label) {
144
+ case 0:
145
+ requestMethod = 'getRecommendations';
146
+ if ((0, charsParams_1.charsParams)(paramBatch.request) > 1024) {
147
+ requestMethod = 'postRecommendations';
148
+ }
149
+ _a.label = 1;
150
+ case 1:
151
+ _a.trys.push([1, 3, , 4]);
152
+ return [4 /*yield*/, this[requestMethod](paramBatch.request)];
153
+ case 2:
154
+ response_1 = _a.sent();
155
+ paramBatch.deferreds.forEach(function (def, index) {
156
+ def.resolve([response_1[index]]);
157
+ });
158
+ return [3 /*break*/, 4];
159
+ case 3:
160
+ err_1 = _a.sent();
161
+ paramBatch.deferreds.forEach(function (def) {
162
+ def.reject(err_1);
163
+ });
164
+ return [3 /*break*/, 4];
165
+ case 4:
166
+ delete this.batches[key];
167
+ return [2 /*return*/];
168
+ }
169
+ });
170
+ }); }, BATCH_TIMEOUT);
171
+ return [2 /*return*/, deferred.promise];
172
+ });
173
+ });
174
+ };
175
+ RecommendAPI.prototype.getRecommendations = function (queryParameters) {
176
+ return __awaiter(this, void 0, void 0, function () {
177
+ var headerParameters, siteId, path, response;
178
+ return __generator(this, function (_a) {
179
+ switch (_a.label) {
180
+ case 0:
181
+ headerParameters = {};
182
+ siteId = queryParameters.siteId;
183
+ path = "/boost/".concat(siteId, "/recommend");
184
+ return [4 /*yield*/, this.request({
185
+ path: path,
186
+ method: 'GET',
187
+ headers: headerParameters,
188
+ query: queryParameters,
189
+ }, path + JSON.stringify(queryParameters))];
190
+ case 1:
191
+ response = _a.sent();
192
+ return [2 /*return*/, response];
193
+ }
194
+ });
195
+ });
196
+ };
197
+ RecommendAPI.prototype.postRecommendations = function (requestParameters) {
198
+ return __awaiter(this, void 0, void 0, function () {
199
+ var headerParameters, siteId, path, response;
200
+ return __generator(this, function (_a) {
201
+ switch (_a.label) {
202
+ case 0:
203
+ headerParameters = {};
204
+ headerParameters['Content-Type'] = 'application/json';
205
+ siteId = requestParameters.siteId;
206
+ path = "/boost/".concat(siteId, "/recommend");
207
+ return [4 /*yield*/, this.request({
208
+ path: path,
209
+ method: 'POST',
210
+ headers: headerParameters,
211
+ body: requestParameters,
212
+ }, path + JSON.stringify(requestParameters))];
213
+ case 1:
214
+ response = _a.sent();
215
+ return [2 /*return*/, response];
216
+ }
217
+ });
218
+ });
219
+ };
220
+ return RecommendAPI;
221
+ }(Abstract_1.API));
222
+ exports.RecommendAPI = RecommendAPI;
@@ -0,0 +1,8 @@
1
+ import { AutocompleteRequestModel, AutocompleteResponseModel, MetaRequestModel, MetaResponseModel, SearchRequestModel, SearchResponseModel } from '@searchspring/snapi-types';
2
+ import { API } from '.';
3
+ export declare class SnapAPI extends API {
4
+ postMeta(requestParameters: MetaRequestModel): Promise<MetaResponseModel>;
5
+ postSearch(requestParameters: SearchRequestModel): Promise<SearchResponseModel>;
6
+ postAutocomplete(requestParameters: AutocompleteRequestModel): Promise<AutocompleteResponseModel>;
7
+ }
8
+ //# sourceMappingURL=Snap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Snap.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/Snap.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,EAAe,MAAM,GAAG,CAAC;AAErC,qBAAa,OAAQ,SAAQ,GAAG;IACzB,QAAQ,CAAC,iBAAiB,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiBzE,UAAU,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAiB/E,gBAAgB,CAAC,iBAAiB,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAgBvG"}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.SnapAPI = void 0;
55
+ var _1 = require(".");
56
+ var SnapAPI = /** @class */ (function (_super) {
57
+ __extends(SnapAPI, _super);
58
+ function SnapAPI() {
59
+ return _super !== null && _super.apply(this, arguments) || this;
60
+ }
61
+ SnapAPI.prototype.postMeta = function (requestParameters) {
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var headerParameters, response;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0:
67
+ headerParameters = {};
68
+ headerParameters['Content-Type'] = 'application/json';
69
+ return [4 /*yield*/, this.request({
70
+ path: '/api/v1/meta',
71
+ method: 'POST',
72
+ headers: headerParameters,
73
+ body: requestParameters,
74
+ }, '/api/v1/meta' + JSON.stringify(requestParameters))];
75
+ case 1:
76
+ response = _a.sent();
77
+ return [2 /*return*/, response];
78
+ }
79
+ });
80
+ });
81
+ };
82
+ SnapAPI.prototype.postSearch = function (requestParameters) {
83
+ return __awaiter(this, void 0, void 0, function () {
84
+ var headerParameters, response;
85
+ return __generator(this, function (_a) {
86
+ switch (_a.label) {
87
+ case 0:
88
+ headerParameters = {};
89
+ headerParameters['Content-Type'] = 'application/json';
90
+ return [4 /*yield*/, this.request({
91
+ path: '/api/v1/search',
92
+ method: 'POST',
93
+ headers: headerParameters,
94
+ body: requestParameters,
95
+ }, '/api/v1/search' + JSON.stringify(requestParameters))];
96
+ case 1:
97
+ response = _a.sent();
98
+ return [2 /*return*/, response];
99
+ }
100
+ });
101
+ });
102
+ };
103
+ SnapAPI.prototype.postAutocomplete = function (requestParameters) {
104
+ return __awaiter(this, void 0, void 0, function () {
105
+ var headerParameters, response;
106
+ return __generator(this, function (_a) {
107
+ switch (_a.label) {
108
+ case 0:
109
+ headerParameters = {};
110
+ headerParameters['Content-Type'] = 'application/json';
111
+ return [4 /*yield*/, this.request({
112
+ path: '/api/v1/autocomplete',
113
+ method: 'POST',
114
+ headers: headerParameters,
115
+ body: requestParameters,
116
+ }, '/api/v1/autocomplete' + JSON.stringify(requestParameters))];
117
+ case 1:
118
+ response = _a.sent();
119
+ return [2 /*return*/, response];
120
+ }
121
+ });
122
+ });
123
+ };
124
+ return SnapAPI;
125
+ }(_1.API));
126
+ exports.SnapAPI = SnapAPI;
@@ -0,0 +1,45 @@
1
+ import { API } from './Abstract';
2
+ export declare type SuggestRequestModel = {
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
+ };
39
+ export declare class SuggestAPI extends API {
40
+ getSuggest(queryParameters: SuggestRequestModel): Promise<SuggestResponseModel>;
41
+ postSuggest(requestParameters: SuggestRequestModel): Promise<SuggestResponseModel>;
42
+ getTrending(queryParameters: TrendingRequestModel): Promise<TrendingResponseModel>;
43
+ postTrending(requestParameters: TrendingRequestModel): Promise<TrendingResponseModel>;
44
+ }
45
+ //# sourceMappingURL=Suggest.d.ts.map
@@ -0,0 +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;AAE9C,oBAAY,mBAAmB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,oBAAY,8BAA8B,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;CACJ,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,8BAA8B,CAAC;IAC3C,YAAY,CAAC,EAAE,8BAA8B,EAAE,CAAC;CAChD,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,qBAAqB,GAAG;IACnC,QAAQ,EAAE;QACT,OAAO,EAAE;YACR,UAAU,EAAE,MAAM,CAAC;YACnB,WAAW,EAAE,MAAM,CAAC;SACpB,EAAE,CAAC;KACJ,CAAC;CACF,CAAC;AAEF,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"}
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.SuggestAPI = void 0;
55
+ var Abstract_1 = require("./Abstract");
56
+ var SuggestAPI = /** @class */ (function (_super) {
57
+ __extends(SuggestAPI, _super);
58
+ function SuggestAPI() {
59
+ return _super !== null && _super.apply(this, arguments) || this;
60
+ }
61
+ SuggestAPI.prototype.getSuggest = function (queryParameters) {
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var headerParameters, response;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0:
67
+ headerParameters = {};
68
+ return [4 /*yield*/, this.request({
69
+ path: '/api/suggest/query',
70
+ method: 'GET',
71
+ headers: headerParameters,
72
+ query: queryParameters,
73
+ }, '/api/suggest/query' + JSON.stringify(queryParameters))];
74
+ case 1:
75
+ response = _a.sent();
76
+ return [2 /*return*/, response];
77
+ }
78
+ });
79
+ });
80
+ };
81
+ SuggestAPI.prototype.postSuggest = function (requestParameters) {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var headerParameters, response;
84
+ return __generator(this, function (_a) {
85
+ switch (_a.label) {
86
+ case 0:
87
+ headerParameters = {};
88
+ headerParameters['Content-Type'] = 'application/json';
89
+ return [4 /*yield*/, this.request({
90
+ path: '/api/suggest/query',
91
+ method: 'POST',
92
+ headers: headerParameters,
93
+ body: requestParameters,
94
+ }, '/api/suggest/query' + JSON.stringify(requestParameters))];
95
+ case 1:
96
+ response = _a.sent();
97
+ return [2 /*return*/, response];
98
+ }
99
+ });
100
+ });
101
+ };
102
+ SuggestAPI.prototype.getTrending = function (queryParameters) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ var headerParameters, response;
105
+ return __generator(this, function (_a) {
106
+ switch (_a.label) {
107
+ case 0:
108
+ headerParameters = {};
109
+ return [4 /*yield*/, this.request({
110
+ path: '/api/suggest/trending',
111
+ method: 'GET',
112
+ headers: headerParameters,
113
+ query: queryParameters,
114
+ }, '/api/suggest/trending' + JSON.stringify(queryParameters))];
115
+ case 1:
116
+ response = _a.sent();
117
+ return [2 /*return*/, response];
118
+ }
119
+ });
120
+ });
121
+ };
122
+ SuggestAPI.prototype.postTrending = function (requestParameters) {
123
+ return __awaiter(this, void 0, void 0, function () {
124
+ var headerParameters, response;
125
+ return __generator(this, function (_a) {
126
+ switch (_a.label) {
127
+ case 0:
128
+ headerParameters = {};
129
+ headerParameters['Content-Type'] = 'application/json';
130
+ return [4 /*yield*/, this.request({
131
+ path: '/api/suggest/trending',
132
+ method: 'POST',
133
+ headers: headerParameters,
134
+ body: requestParameters,
135
+ }, '/api/suggest/trending' + JSON.stringify(requestParameters))];
136
+ case 1:
137
+ response = _a.sent();
138
+ return [2 /*return*/, response];
139
+ }
140
+ });
141
+ });
142
+ };
143
+ return SuggestAPI;
144
+ }(Abstract_1.API));
145
+ exports.SuggestAPI = SuggestAPI;
@@ -0,0 +1,7 @@
1
+ export * from './Abstract';
2
+ export * from './Legacy';
3
+ export * from './Recommend';
4
+ export * from './Snap';
5
+ export * from './Suggest';
6
+ export * from './Hybrid';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Client/apis/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Abstract"), exports);
14
+ __exportStar(require("./Legacy"), exports);
15
+ __exportStar(require("./Recommend"), exports);
16
+ __exportStar(require("./Snap"), exports);
17
+ __exportStar(require("./Suggest"), exports);
18
+ __exportStar(require("./Hybrid"), exports);
@@ -0,0 +1,4 @@
1
+ export * from './searchRequest';
2
+ export * from './searchResponse';
3
+ export * from './suggestResponse';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Client/transforms/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./searchRequest"), exports);
14
+ __exportStar(require("./searchResponse"), exports);
15
+ __exportStar(require("./suggestResponse"), exports);
@@ -0,0 +1,47 @@
1
+ import { SearchRequestModel } from '@searchspring/snapi-types';
2
+ export declare function transformSearchRequest(request: SearchRequestModel): any;
3
+ export declare namespace transformSearchRequest {
4
+ var sorts: (request?: SearchRequestModel) => import("@searchspring/snapi-types").SearchRequestModelSorts;
5
+ var search: (request?: SearchRequestModel) => {
6
+ q?: string;
7
+ rq?: string;
8
+ originalQuery?: string;
9
+ redirectResponse?: string;
10
+ };
11
+ var filters: (request?: SearchRequestModel) => {};
12
+ var merchandising: (request?: SearchRequestModel) => {
13
+ disableMerchandising: boolean;
14
+ } | {
15
+ disableMerchandising?: undefined;
16
+ };
17
+ var pagination: (request?: SearchRequestModel) => {
18
+ page?: number;
19
+ resultsPerPage?: number;
20
+ };
21
+ var siteId: (request?: SearchRequestModel) => {
22
+ siteId: string;
23
+ } | {
24
+ siteId?: undefined;
25
+ };
26
+ var facets: (request?: SearchRequestModel) => {
27
+ includedFacets: string[];
28
+ excludedFacets?: undefined;
29
+ } | {
30
+ excludedFacets: string[];
31
+ includedFacets?: undefined;
32
+ } | {
33
+ includedFacets?: undefined;
34
+ excludedFacets?: undefined;
35
+ };
36
+ var tracking: (request?: SearchRequestModel) => {
37
+ userId?: string;
38
+ domain?: string;
39
+ };
40
+ var personalization: (request?: SearchRequestModel) => {
41
+ skipPersonalization?: boolean;
42
+ cart?: string;
43
+ shopper?: string;
44
+ lastViewed?: string;
45
+ };
46
+ }
47
+ //# sourceMappingURL=searchRequest.d.ts.map