@tspvivek/baasix-sdk 0.1.0-alpha.2 → 0.1.0-alpha.3
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/dist/index.cjs +44 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -3
- package/dist/index.js.map +1 -1
- package/dist/modules/files.cjs +34 -1
- package/dist/modules/files.cjs.map +1 -1
- package/dist/modules/files.js +34 -1
- package/dist/modules/files.js.map +1 -1
- package/dist/modules/items.cjs +34 -1
- package/dist/modules/items.cjs.map +1 -1
- package/dist/modules/items.js +34 -1
- package/dist/modules/items.js.map +1 -1
- package/dist/modules/schemas.cjs +34 -1
- package/dist/modules/schemas.cjs.map +1 -1
- package/dist/modules/schemas.d.cts +2 -2
- package/dist/modules/schemas.d.ts +2 -2
- package/dist/modules/schemas.js +34 -1
- package/dist/modules/schemas.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1080,6 +1080,35 @@ var AuthModule = class {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
};
|
|
1082
1082
|
|
|
1083
|
+
// src/utils/sort.ts
|
|
1084
|
+
function normalizeSort(sort) {
|
|
1085
|
+
if (!sort) return void 0;
|
|
1086
|
+
if (typeof sort === "string") {
|
|
1087
|
+
return sort;
|
|
1088
|
+
}
|
|
1089
|
+
if (Array.isArray(sort)) {
|
|
1090
|
+
if (sort.length === 0) return void 0;
|
|
1091
|
+
if (typeof sort[0] === "object" && "column" in sort[0]) {
|
|
1092
|
+
return sort.map((s) => `${s.column}:${s.order.toLowerCase()}`).join(",");
|
|
1093
|
+
}
|
|
1094
|
+
return sort.map((s) => {
|
|
1095
|
+
if (s.startsWith("-")) {
|
|
1096
|
+
return `${s.substring(1)}:desc`;
|
|
1097
|
+
}
|
|
1098
|
+
if (s.includes(":")) {
|
|
1099
|
+
return s;
|
|
1100
|
+
}
|
|
1101
|
+
return `${s}:asc`;
|
|
1102
|
+
}).join(",");
|
|
1103
|
+
}
|
|
1104
|
+
if (typeof sort === "object") {
|
|
1105
|
+
const entries = Object.entries(sort);
|
|
1106
|
+
if (entries.length === 0) return void 0;
|
|
1107
|
+
return entries.map(([field, direction]) => `${field}:${direction.toLowerCase()}`).join(",");
|
|
1108
|
+
}
|
|
1109
|
+
return void 0;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1083
1112
|
// src/modules/items.ts
|
|
1084
1113
|
var QueryBuilder = class {
|
|
1085
1114
|
collection;
|
|
@@ -1387,8 +1416,12 @@ var ItemsModule = class {
|
|
|
1387
1416
|
* ```
|
|
1388
1417
|
*/
|
|
1389
1418
|
async find(params) {
|
|
1419
|
+
const normalizedParams = params ? {
|
|
1420
|
+
...params,
|
|
1421
|
+
sort: normalizeSort(params.sort)
|
|
1422
|
+
} : void 0;
|
|
1390
1423
|
return this.client.get(`/items/${this.collection}`, {
|
|
1391
|
-
params
|
|
1424
|
+
params: normalizedParams
|
|
1392
1425
|
});
|
|
1393
1426
|
}
|
|
1394
1427
|
/**
|
|
@@ -1804,8 +1837,12 @@ var FilesModule = class {
|
|
|
1804
1837
|
* ```
|
|
1805
1838
|
*/
|
|
1806
1839
|
async find(params) {
|
|
1840
|
+
const normalizedParams = params ? {
|
|
1841
|
+
...params,
|
|
1842
|
+
sort: normalizeSort(params.sort)
|
|
1843
|
+
} : void 0;
|
|
1807
1844
|
return this.client.get("/files", {
|
|
1808
|
-
params
|
|
1845
|
+
params: normalizedParams
|
|
1809
1846
|
});
|
|
1810
1847
|
}
|
|
1811
1848
|
/**
|
|
@@ -1993,7 +2030,11 @@ var SchemasModule = class {
|
|
|
1993
2030
|
* ```
|
|
1994
2031
|
*/
|
|
1995
2032
|
async find(params) {
|
|
1996
|
-
|
|
2033
|
+
const normalizedParams = params ? {
|
|
2034
|
+
...params,
|
|
2035
|
+
sort: normalizeSort(params.sort)
|
|
2036
|
+
} : void 0;
|
|
2037
|
+
return this.client.get("/schemas", { params: normalizedParams });
|
|
1997
2038
|
}
|
|
1998
2039
|
/**
|
|
1999
2040
|
* Get schema for a specific collection
|