drapcode-developer-sdk 1.0.6 → 1.0.7

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
@@ -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;
@@ -151,7 +151,7 @@ var getAllItems = function (baseurl, headers, collectionName, reqQuery, query) {
151
151
  var conditionString = constants_1.QueryOperation[query.condition];
152
152
  var field = encodeURIComponent(query.field);
153
153
  var value = encodeURIComponent(query.value);
154
- queryParams_1.append("".concat(field, "%3A").concat(conditionString), "".concat(value));
154
+ queryParams_1.append("".concat(field, ":").concat(conditionString), "".concat(value));
155
155
  });
156
156
  url = "".concat(baseurl, "/collection/").concat(collectionName, "/items?").concat(queryParams_1.toString());
157
157
  console.log("Generated URL:", url);
@@ -176,8 +176,9 @@ var createItem = function (baseurl, headers, collectionName, body) { return __aw
176
176
  return __generator(this, function (_a) {
177
177
  switch (_a.label) {
178
178
  case 0:
179
- _a.trys.push([0, 5, , 6]);
179
+ _a.trys.push([0, 4, , 5]);
180
180
  url = "".concat(baseurl, "/collection/").concat(collectionName, "/items");
181
+ console.log("url :>> ", url);
181
182
  return [4 /*yield*/, fetch(url, {
182
183
  method: "POST",
183
184
  headers: headers,
@@ -185,28 +186,33 @@ var createItem = function (baseurl, headers, collectionName, body) { return __aw
185
186
  })];
186
187
  case 1:
187
188
  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:
189
+ console.log("response.status :>> ", response.status);
190
+ if (response.status && response.status === 404) {
191
+ return [2 /*return*/, {
192
+ success: false,
193
+ data: "Collection Not Found",
194
+ error: "",
195
+ message: "",
196
+ }];
197
+ }
198
+ if (!(response.status &&
199
+ (response.status === 200 || response.status === 201))) return [3 /*break*/, 3];
200
+ return [4 /*yield*/, response.json()];
201
+ case 2:
197
202
  result = _a.sent();
203
+ console.log("result :>> ", result);
198
204
  return [2 /*return*/, {
199
- code: result === null || result === void 0 ? void 0 : result.code,
205
+ code: response.status,
200
206
  success: true,
201
- data: result === null || result === void 0 ? void 0 : result.data,
207
+ data: result,
202
208
  error: "",
203
- message: result.message || "",
209
+ message: "",
204
210
  }];
205
- case 4: return [3 /*break*/, 6];
206
- case 5:
211
+ case 3: return [3 /*break*/, 5];
212
+ case 4:
207
213
  error_2 = _a.sent();
208
214
  return [2 /*return*/, createErrorResponse(error_2)];
209
- case 6: return [2 /*return*/];
215
+ case 5: return [2 /*return*/];
210
216
  }
211
217
  });
212
218
  }); };
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.7",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "files": [