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 +7 -8
- package/build/methods/methods.d.ts +5 -6
- package/build/methods/methods.js +28 -19
- package/package.json +1 -1
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
|
-
|
|
10
|
-
|
|
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:
|
|
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:
|
|
34
|
+
data: string;
|
|
36
35
|
error: string;
|
|
37
|
-
message:
|
|
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:
|
|
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:
|
|
25
|
+
data: string;
|
|
27
26
|
error: string;
|
|
28
|
-
message:
|
|
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;
|
package/build/methods/methods.js
CHANGED
|
@@ -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 =
|
|
153
|
-
var value =
|
|
154
|
-
|
|
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,
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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:
|
|
208
|
+
code: response.status,
|
|
200
209
|
success: true,
|
|
201
|
-
data: result
|
|
210
|
+
data: result,
|
|
202
211
|
error: "",
|
|
203
|
-
message:
|
|
212
|
+
message: "",
|
|
204
213
|
}];
|
|
205
|
-
case
|
|
206
|
-
case
|
|
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
|
|
218
|
+
case 5: return [2 /*return*/];
|
|
210
219
|
}
|
|
211
220
|
});
|
|
212
221
|
}); };
|