drapcode-developer-sdk 1.0.6 → 1.0.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/build/index.d.ts CHANGED
@@ -6,8 +6,8 @@ export declare class DrapcodeApis {
6
6
  private environment;
7
7
  private API_PATH;
8
8
  constructor(project_seo_name: string, xApiKey?: string, authorization?: string, environment?: string);
9
- private getBaseUrl;
10
- private getHeaders;
9
+ getBaseUrl(): string;
10
+ getHeaders(): Record<string, string>;
11
11
  getAllItems(collectionName: string, reqQuery?: SearchPaginate | any, query?: Query[] | []): Promise<{
12
12
  code: any;
13
13
  success: boolean;
@@ -24,18 +24,17 @@ export declare class DrapcodeApis {
24
24
  totalPages?: undefined;
25
25
  }>;
26
26
  createItem(collectionName: string, body: any): Promise<{
27
+ code: any;
27
28
  success: boolean;
28
- data: string;
29
+ data: any;
29
30
  error: string;
30
31
  message: string;
31
- code?: undefined;
32
32
  } | {
33
- code: any;
34
33
  success: boolean;
35
- data: any;
34
+ data: string;
36
35
  error: string;
37
- message: any;
38
- }>;
36
+ message: string;
37
+ } | undefined>;
39
38
  getItemsWithFilter(collectionName: string, filterUuid: string): Promise<{
40
39
  code: any;
41
40
  success: boolean;
@@ -15,18 +15,17 @@ export declare const getAllItems: (baseurl: string, headers: Record<string, stri
15
15
  totalPages?: undefined;
16
16
  }>;
17
17
  export declare const createItem: (baseurl: string, headers: Record<string, string>, collectionName: string, body: any) => Promise<{
18
+ code: any;
18
19
  success: boolean;
19
- data: string;
20
+ data: any;
20
21
  error: string;
21
22
  message: string;
22
- code?: undefined;
23
23
  } | {
24
- code: any;
25
24
  success: boolean;
26
- data: any;
25
+ data: string;
27
26
  error: string;
28
- message: any;
29
- }>;
27
+ message: string;
28
+ } | undefined>;
30
29
  export declare const getItemsWithFilter: (baseurl: string, headers: Record<string, string>, collectionName: string, filterUuid: string) => Promise<{
31
30
  code: any;
32
31
  success: boolean;
@@ -149,9 +149,12 @@ var getAllItems = function (baseurl, headers, collectionName, reqQuery, query) {
149
149
  }
150
150
  query.map(function (query) {
151
151
  var conditionString = constants_1.QueryOperation[query.condition];
152
- var field = encodeURIComponent(query.field);
153
- var value = encodeURIComponent(query.value);
154
- queryParams_1.append("".concat(field, "%3A").concat(conditionString), "".concat(value));
152
+ var field = "".concat(query.field);
153
+ var value = "".concat(query.value);
154
+ // double encoding the query params(remove after testing)
155
+ // const field = encodeURIComponent(query.field);
156
+ // const value = encodeURIComponent(query.value);
157
+ queryParams_1.append("".concat(field, ":").concat(conditionString), "".concat(value));
155
158
  });
156
159
  url = "".concat(baseurl, "/collection/").concat(collectionName, "/items?").concat(queryParams_1.toString());
157
160
  console.log("Generated URL:", url);
@@ -176,8 +179,9 @@ var createItem = function (baseurl, headers, collectionName, body) { return __aw
176
179
  return __generator(this, function (_a) {
177
180
  switch (_a.label) {
178
181
  case 0:
179
- _a.trys.push([0, 5, , 6]);
182
+ _a.trys.push([0, 4, , 5]);
180
183
  url = "".concat(baseurl, "/collection/").concat(collectionName, "/items");
184
+ console.log("url :>> ", url);
181
185
  return [4 /*yield*/, fetch(url, {
182
186
  method: "POST",
183
187
  headers: headers,
@@ -185,28 +189,33 @@ var createItem = function (baseurl, headers, collectionName, body) { return __aw
185
189
  })];
186
190
  case 1:
187
191
  response = _a.sent();
188
- if (!(response.status && response.status === 404)) return [3 /*break*/, 2];
189
- return [2 /*return*/, {
190
- success: false,
191
- data: "Collection Not Found",
192
- error: "",
193
- message: "",
194
- }];
195
- case 2: return [4 /*yield*/, response.json()];
196
- case 3:
192
+ console.log("response.status :>> ", response.status);
193
+ if (response.status && response.status === 404) {
194
+ return [2 /*return*/, {
195
+ success: false,
196
+ data: "Collection Not Found",
197
+ error: "",
198
+ message: "",
199
+ }];
200
+ }
201
+ if (!(response.status &&
202
+ (response.status === 200 || response.status === 201))) return [3 /*break*/, 3];
203
+ return [4 /*yield*/, response.json()];
204
+ case 2:
197
205
  result = _a.sent();
206
+ console.log("result :>> ", result);
198
207
  return [2 /*return*/, {
199
- code: result === null || result === void 0 ? void 0 : result.code,
208
+ code: response.status,
200
209
  success: true,
201
- data: result === null || result === void 0 ? void 0 : result.data,
210
+ data: result,
202
211
  error: "",
203
- message: result.message || "",
212
+ message: "",
204
213
  }];
205
- case 4: return [3 /*break*/, 6];
206
- case 5:
214
+ case 3: return [3 /*break*/, 5];
215
+ case 4:
207
216
  error_2 = _a.sent();
208
217
  return [2 /*return*/, createErrorResponse(error_2)];
209
- case 6: return [2 /*return*/];
218
+ case 5: return [2 /*return*/];
210
219
  }
211
220
  });
212
221
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-developer-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "files": [