@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.cjs
CHANGED
|
@@ -1082,6 +1082,35 @@ var AuthModule = class {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
};
|
|
1084
1084
|
|
|
1085
|
+
// src/utils/sort.ts
|
|
1086
|
+
function normalizeSort(sort) {
|
|
1087
|
+
if (!sort) return void 0;
|
|
1088
|
+
if (typeof sort === "string") {
|
|
1089
|
+
return sort;
|
|
1090
|
+
}
|
|
1091
|
+
if (Array.isArray(sort)) {
|
|
1092
|
+
if (sort.length === 0) return void 0;
|
|
1093
|
+
if (typeof sort[0] === "object" && "column" in sort[0]) {
|
|
1094
|
+
return sort.map((s) => `${s.column}:${s.order.toLowerCase()}`).join(",");
|
|
1095
|
+
}
|
|
1096
|
+
return sort.map((s) => {
|
|
1097
|
+
if (s.startsWith("-")) {
|
|
1098
|
+
return `${s.substring(1)}:desc`;
|
|
1099
|
+
}
|
|
1100
|
+
if (s.includes(":")) {
|
|
1101
|
+
return s;
|
|
1102
|
+
}
|
|
1103
|
+
return `${s}:asc`;
|
|
1104
|
+
}).join(",");
|
|
1105
|
+
}
|
|
1106
|
+
if (typeof sort === "object") {
|
|
1107
|
+
const entries = Object.entries(sort);
|
|
1108
|
+
if (entries.length === 0) return void 0;
|
|
1109
|
+
return entries.map(([field, direction]) => `${field}:${direction.toLowerCase()}`).join(",");
|
|
1110
|
+
}
|
|
1111
|
+
return void 0;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1085
1114
|
// src/modules/items.ts
|
|
1086
1115
|
var QueryBuilder = class {
|
|
1087
1116
|
collection;
|
|
@@ -1389,8 +1418,12 @@ var ItemsModule = class {
|
|
|
1389
1418
|
* ```
|
|
1390
1419
|
*/
|
|
1391
1420
|
async find(params) {
|
|
1421
|
+
const normalizedParams = params ? {
|
|
1422
|
+
...params,
|
|
1423
|
+
sort: normalizeSort(params.sort)
|
|
1424
|
+
} : void 0;
|
|
1392
1425
|
return this.client.get(`/items/${this.collection}`, {
|
|
1393
|
-
params
|
|
1426
|
+
params: normalizedParams
|
|
1394
1427
|
});
|
|
1395
1428
|
}
|
|
1396
1429
|
/**
|
|
@@ -1806,8 +1839,12 @@ var FilesModule = class {
|
|
|
1806
1839
|
* ```
|
|
1807
1840
|
*/
|
|
1808
1841
|
async find(params) {
|
|
1842
|
+
const normalizedParams = params ? {
|
|
1843
|
+
...params,
|
|
1844
|
+
sort: normalizeSort(params.sort)
|
|
1845
|
+
} : void 0;
|
|
1809
1846
|
return this.client.get("/files", {
|
|
1810
|
-
params
|
|
1847
|
+
params: normalizedParams
|
|
1811
1848
|
});
|
|
1812
1849
|
}
|
|
1813
1850
|
/**
|
|
@@ -1995,7 +2032,11 @@ var SchemasModule = class {
|
|
|
1995
2032
|
* ```
|
|
1996
2033
|
*/
|
|
1997
2034
|
async find(params) {
|
|
1998
|
-
|
|
2035
|
+
const normalizedParams = params ? {
|
|
2036
|
+
...params,
|
|
2037
|
+
sort: normalizeSort(params.sort)
|
|
2038
|
+
} : void 0;
|
|
2039
|
+
return this.client.get("/schemas", { params: normalizedParams });
|
|
1999
2040
|
}
|
|
2000
2041
|
/**
|
|
2001
2042
|
* Get schema for a specific collection
|