krisspy-sdk 0.8.0 → 0.8.2
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.d.mts +33 -4
- package/dist/index.d.ts +33 -4
- package/dist/index.js +115 -65
- package/dist/index.mjs +115 -65
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -939,6 +939,31 @@ declare class KrisspyNotifications {
|
|
|
939
939
|
* Query Builder - Supabase-style fluent API for database queries
|
|
940
940
|
*/
|
|
941
941
|
|
|
942
|
+
/**
|
|
943
|
+
* Thenable builder for mutation operations (update/delete).
|
|
944
|
+
* Supports chaining filters (.eq, .neq, etc.) AFTER .update()/.delete(),
|
|
945
|
+
* and executes the HTTP request lazily on await.
|
|
946
|
+
*/
|
|
947
|
+
declare class MutationFilterBuilder<T = any> implements PromiseLike<MutationResponse<T>> {
|
|
948
|
+
private http;
|
|
949
|
+
private path;
|
|
950
|
+
private method;
|
|
951
|
+
private body;
|
|
952
|
+
private queryParams;
|
|
953
|
+
constructor(http: HttpClient, path: string, method: 'patch' | 'delete', body: Partial<T> | undefined, initialParams: Record<string, string>);
|
|
954
|
+
eq(column: string, value: any): this;
|
|
955
|
+
neq(column: string, value: any): this;
|
|
956
|
+
gt(column: string, value: any): this;
|
|
957
|
+
gte(column: string, value: any): this;
|
|
958
|
+
lt(column: string, value: any): this;
|
|
959
|
+
lte(column: string, value: any): this;
|
|
960
|
+
like(column: string, pattern: string): this;
|
|
961
|
+
ilike(column: string, pattern: string): this;
|
|
962
|
+
in(column: string, values: any[]): this;
|
|
963
|
+
is(column: string, value: null | boolean): this;
|
|
964
|
+
private execute;
|
|
965
|
+
then<TResult1 = MutationResponse<T>, TResult2 = never>(onfulfilled?: ((value: MutationResponse<T>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
966
|
+
}
|
|
942
967
|
declare class QueryBuilder<T = any> {
|
|
943
968
|
private http;
|
|
944
969
|
private backendId;
|
|
@@ -1059,14 +1084,18 @@ declare class QueryBuilder<T = any> {
|
|
|
1059
1084
|
insert(data: Partial<T> | Partial<T>[]): Promise<MutationResponse<T>>;
|
|
1060
1085
|
/**
|
|
1061
1086
|
* Update rows (requires filters)
|
|
1062
|
-
*
|
|
1087
|
+
* Returns a thenable builder - chain filters then await.
|
|
1088
|
+
* @example await krisspy.from('items').update({ price: 899 }).eq('id', 123)
|
|
1089
|
+
* @example await krisspy.from('items').eq('id', 123).update({ price: 899 })
|
|
1063
1090
|
*/
|
|
1064
|
-
update(data: Partial<T>):
|
|
1091
|
+
update(data: Partial<T>): MutationFilterBuilder<T>;
|
|
1065
1092
|
/**
|
|
1066
1093
|
* Delete rows (requires filters)
|
|
1067
|
-
*
|
|
1094
|
+
* Returns a thenable builder - chain filters then await.
|
|
1095
|
+
* @example await krisspy.from('items').delete().eq('id', 123)
|
|
1096
|
+
* @example await krisspy.from('items').eq('id', 123).delete()
|
|
1068
1097
|
*/
|
|
1069
|
-
delete():
|
|
1098
|
+
delete(): MutationFilterBuilder<T>;
|
|
1070
1099
|
/**
|
|
1071
1100
|
* Upsert rows (insert or update on conflict)
|
|
1072
1101
|
* @example .upsert({ id: 1, name: 'iPhone' })
|
package/dist/index.d.ts
CHANGED
|
@@ -939,6 +939,31 @@ declare class KrisspyNotifications {
|
|
|
939
939
|
* Query Builder - Supabase-style fluent API for database queries
|
|
940
940
|
*/
|
|
941
941
|
|
|
942
|
+
/**
|
|
943
|
+
* Thenable builder for mutation operations (update/delete).
|
|
944
|
+
* Supports chaining filters (.eq, .neq, etc.) AFTER .update()/.delete(),
|
|
945
|
+
* and executes the HTTP request lazily on await.
|
|
946
|
+
*/
|
|
947
|
+
declare class MutationFilterBuilder<T = any> implements PromiseLike<MutationResponse<T>> {
|
|
948
|
+
private http;
|
|
949
|
+
private path;
|
|
950
|
+
private method;
|
|
951
|
+
private body;
|
|
952
|
+
private queryParams;
|
|
953
|
+
constructor(http: HttpClient, path: string, method: 'patch' | 'delete', body: Partial<T> | undefined, initialParams: Record<string, string>);
|
|
954
|
+
eq(column: string, value: any): this;
|
|
955
|
+
neq(column: string, value: any): this;
|
|
956
|
+
gt(column: string, value: any): this;
|
|
957
|
+
gte(column: string, value: any): this;
|
|
958
|
+
lt(column: string, value: any): this;
|
|
959
|
+
lte(column: string, value: any): this;
|
|
960
|
+
like(column: string, pattern: string): this;
|
|
961
|
+
ilike(column: string, pattern: string): this;
|
|
962
|
+
in(column: string, values: any[]): this;
|
|
963
|
+
is(column: string, value: null | boolean): this;
|
|
964
|
+
private execute;
|
|
965
|
+
then<TResult1 = MutationResponse<T>, TResult2 = never>(onfulfilled?: ((value: MutationResponse<T>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
966
|
+
}
|
|
942
967
|
declare class QueryBuilder<T = any> {
|
|
943
968
|
private http;
|
|
944
969
|
private backendId;
|
|
@@ -1059,14 +1084,18 @@ declare class QueryBuilder<T = any> {
|
|
|
1059
1084
|
insert(data: Partial<T> | Partial<T>[]): Promise<MutationResponse<T>>;
|
|
1060
1085
|
/**
|
|
1061
1086
|
* Update rows (requires filters)
|
|
1062
|
-
*
|
|
1087
|
+
* Returns a thenable builder - chain filters then await.
|
|
1088
|
+
* @example await krisspy.from('items').update({ price: 899 }).eq('id', 123)
|
|
1089
|
+
* @example await krisspy.from('items').eq('id', 123).update({ price: 899 })
|
|
1063
1090
|
*/
|
|
1064
|
-
update(data: Partial<T>):
|
|
1091
|
+
update(data: Partial<T>): MutationFilterBuilder<T>;
|
|
1065
1092
|
/**
|
|
1066
1093
|
* Delete rows (requires filters)
|
|
1067
|
-
*
|
|
1094
|
+
* Returns a thenable builder - chain filters then await.
|
|
1095
|
+
* @example await krisspy.from('items').delete().eq('id', 123)
|
|
1096
|
+
* @example await krisspy.from('items').eq('id', 123).delete()
|
|
1068
1097
|
*/
|
|
1069
|
-
delete():
|
|
1098
|
+
delete(): MutationFilterBuilder<T>;
|
|
1070
1099
|
/**
|
|
1071
1100
|
* Upsert rows (insert or update on conflict)
|
|
1072
1101
|
* @example .upsert({ id: 1, name: 'iPhone' })
|
package/dist/index.js
CHANGED
|
@@ -1563,6 +1563,75 @@ var KrisspyNotifications = class {
|
|
|
1563
1563
|
};
|
|
1564
1564
|
|
|
1565
1565
|
// src/query-builder.ts
|
|
1566
|
+
var MutationFilterBuilder = class {
|
|
1567
|
+
constructor(http, path, method, body, initialParams) {
|
|
1568
|
+
this.http = http;
|
|
1569
|
+
this.path = path;
|
|
1570
|
+
this.method = method;
|
|
1571
|
+
this.body = body;
|
|
1572
|
+
this.queryParams = __spreadValues({}, initialParams);
|
|
1573
|
+
delete this.queryParams["select"];
|
|
1574
|
+
delete this.queryParams["order"];
|
|
1575
|
+
delete this.queryParams["limit"];
|
|
1576
|
+
delete this.queryParams["offset"];
|
|
1577
|
+
}
|
|
1578
|
+
eq(column, value) {
|
|
1579
|
+
this.queryParams[column] = `eq.${value}`;
|
|
1580
|
+
return this;
|
|
1581
|
+
}
|
|
1582
|
+
neq(column, value) {
|
|
1583
|
+
this.queryParams[column] = `neq.${value}`;
|
|
1584
|
+
return this;
|
|
1585
|
+
}
|
|
1586
|
+
gt(column, value) {
|
|
1587
|
+
this.queryParams[column] = `gt.${value}`;
|
|
1588
|
+
return this;
|
|
1589
|
+
}
|
|
1590
|
+
gte(column, value) {
|
|
1591
|
+
this.queryParams[column] = `gte.${value}`;
|
|
1592
|
+
return this;
|
|
1593
|
+
}
|
|
1594
|
+
lt(column, value) {
|
|
1595
|
+
this.queryParams[column] = `lt.${value}`;
|
|
1596
|
+
return this;
|
|
1597
|
+
}
|
|
1598
|
+
lte(column, value) {
|
|
1599
|
+
this.queryParams[column] = `lte.${value}`;
|
|
1600
|
+
return this;
|
|
1601
|
+
}
|
|
1602
|
+
like(column, pattern) {
|
|
1603
|
+
this.queryParams[column] = `like.${pattern}`;
|
|
1604
|
+
return this;
|
|
1605
|
+
}
|
|
1606
|
+
ilike(column, pattern) {
|
|
1607
|
+
this.queryParams[column] = `ilike.${pattern}`;
|
|
1608
|
+
return this;
|
|
1609
|
+
}
|
|
1610
|
+
in(column, values) {
|
|
1611
|
+
this.queryParams[column] = `in.${values.join(",")}`;
|
|
1612
|
+
return this;
|
|
1613
|
+
}
|
|
1614
|
+
is(column, value) {
|
|
1615
|
+
const strValue = value === null ? "null" : value ? "true" : "false";
|
|
1616
|
+
this.queryParams[column] = `is.${strValue}`;
|
|
1617
|
+
return this;
|
|
1618
|
+
}
|
|
1619
|
+
async execute() {
|
|
1620
|
+
var _a, _b, _c, _d;
|
|
1621
|
+
const response = this.method === "patch" ? await this.http.patch(this.path, this.body, this.queryParams) : await this.http.delete(this.path, this.queryParams);
|
|
1622
|
+
if (response.error) {
|
|
1623
|
+
return { data: null, error: response.error, count: 0 };
|
|
1624
|
+
}
|
|
1625
|
+
return {
|
|
1626
|
+
data: (_b = (_a = response.data) == null ? void 0 : _a.data) != null ? _b : [],
|
|
1627
|
+
error: null,
|
|
1628
|
+
count: (_d = (_c = response.data) == null ? void 0 : _c.count) != null ? _d : 0
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
then(onfulfilled, onrejected) {
|
|
1632
|
+
return this.execute().then(onfulfilled, onrejected);
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1566
1635
|
var QueryBuilder = class {
|
|
1567
1636
|
constructor(http, backendId, tableName, dataMode = "rls") {
|
|
1568
1637
|
this.queryParams = {};
|
|
@@ -1796,47 +1865,33 @@ var QueryBuilder = class {
|
|
|
1796
1865
|
}
|
|
1797
1866
|
/**
|
|
1798
1867
|
* Update rows (requires filters)
|
|
1799
|
-
*
|
|
1868
|
+
* Returns a thenable builder - chain filters then await.
|
|
1869
|
+
* @example await krisspy.from('items').update({ price: 899 }).eq('id', 123)
|
|
1870
|
+
* @example await krisspy.from('items').eq('id', 123).update({ price: 899 })
|
|
1800
1871
|
*/
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
const response = await this.http.patch(path, data, params);
|
|
1810
|
-
if (response.error) {
|
|
1811
|
-
return { data: null, error: response.error, count: 0 };
|
|
1812
|
-
}
|
|
1813
|
-
return {
|
|
1814
|
-
data: (_b = (_a = response.data) == null ? void 0 : _a.data) != null ? _b : [],
|
|
1815
|
-
error: null,
|
|
1816
|
-
count: (_d = (_c = response.data) == null ? void 0 : _c.count) != null ? _d : 0
|
|
1817
|
-
};
|
|
1872
|
+
update(data) {
|
|
1873
|
+
return new MutationFilterBuilder(
|
|
1874
|
+
this.http,
|
|
1875
|
+
this.getBasePath(),
|
|
1876
|
+
"patch",
|
|
1877
|
+
data,
|
|
1878
|
+
this.buildParams()
|
|
1879
|
+
);
|
|
1818
1880
|
}
|
|
1819
1881
|
/**
|
|
1820
1882
|
* Delete rows (requires filters)
|
|
1821
|
-
*
|
|
1883
|
+
* Returns a thenable builder - chain filters then await.
|
|
1884
|
+
* @example await krisspy.from('items').delete().eq('id', 123)
|
|
1885
|
+
* @example await krisspy.from('items').eq('id', 123).delete()
|
|
1822
1886
|
*/
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
const response = await this.http.delete(path, params);
|
|
1832
|
-
if (response.error) {
|
|
1833
|
-
return { data: null, error: response.error, count: 0 };
|
|
1834
|
-
}
|
|
1835
|
-
return {
|
|
1836
|
-
data: (_b = (_a = response.data) == null ? void 0 : _a.data) != null ? _b : [],
|
|
1837
|
-
error: null,
|
|
1838
|
-
count: (_d = (_c = response.data) == null ? void 0 : _c.count) != null ? _d : 0
|
|
1839
|
-
};
|
|
1887
|
+
delete() {
|
|
1888
|
+
return new MutationFilterBuilder(
|
|
1889
|
+
this.http,
|
|
1890
|
+
this.getBasePath(),
|
|
1891
|
+
"delete",
|
|
1892
|
+
void 0,
|
|
1893
|
+
this.buildParams()
|
|
1894
|
+
);
|
|
1840
1895
|
}
|
|
1841
1896
|
/**
|
|
1842
1897
|
* Upsert rows (insert or update on conflict)
|
|
@@ -2104,37 +2159,32 @@ var KrisspyClient = class {
|
|
|
2104
2159
|
get functions() {
|
|
2105
2160
|
return {
|
|
2106
2161
|
invoke: async (functionName, options) => {
|
|
2107
|
-
if (this.functionsUrl) {
|
|
2108
|
-
|
|
2109
|
-
try {
|
|
2110
|
-
const res = await fetch(url, {
|
|
2111
|
-
method: "POST",
|
|
2112
|
-
headers: __spreadValues({
|
|
2113
|
-
"Content-Type": "application/json"
|
|
2114
|
-
}, options == null ? void 0 : options.headers),
|
|
2115
|
-
body: (options == null ? void 0 : options.body) ? JSON.stringify(options.body) : void 0
|
|
2116
|
-
});
|
|
2117
|
-
const contentType = res.headers.get("content-type");
|
|
2118
|
-
let data = null;
|
|
2119
|
-
if (contentType == null ? void 0 : contentType.includes("application/json")) {
|
|
2120
|
-
data = await res.json();
|
|
2121
|
-
} else {
|
|
2122
|
-
data = await res.text();
|
|
2123
|
-
}
|
|
2124
|
-
if (!res.ok) {
|
|
2125
|
-
return { data: null, error: { message: (data == null ? void 0 : data.error) || (data == null ? void 0 : data.message) || `Request failed with status ${res.status}`, status: res.status } };
|
|
2126
|
-
}
|
|
2127
|
-
return { data, error: null };
|
|
2128
|
-
} catch (err) {
|
|
2129
|
-
return { data: null, error: { message: err.message || "Network error", code: "NETWORK_ERROR", status: 0 } };
|
|
2130
|
-
}
|
|
2162
|
+
if (!this.functionsUrl) {
|
|
2163
|
+
return { data: null, error: { message: 'functionsUrl is required. Pass it in createClient({ functionsUrl: "https://your-func-app.azurewebsites.net" })', code: "CONFIG_ERROR", status: 0 } };
|
|
2131
2164
|
}
|
|
2132
|
-
const
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2165
|
+
const url = `${this.functionsUrl}/api/${functionName}`;
|
|
2166
|
+
try {
|
|
2167
|
+
const res = await fetch(url, {
|
|
2168
|
+
method: "POST",
|
|
2169
|
+
headers: __spreadValues({
|
|
2170
|
+
"Content-Type": "application/json"
|
|
2171
|
+
}, options == null ? void 0 : options.headers),
|
|
2172
|
+
body: (options == null ? void 0 : options.body) ? JSON.stringify(options.body) : void 0
|
|
2173
|
+
});
|
|
2174
|
+
const contentType = res.headers.get("content-type");
|
|
2175
|
+
let data = null;
|
|
2176
|
+
if (contentType == null ? void 0 : contentType.includes("application/json")) {
|
|
2177
|
+
data = await res.json();
|
|
2178
|
+
} else {
|
|
2179
|
+
data = await res.text();
|
|
2180
|
+
}
|
|
2181
|
+
if (!res.ok) {
|
|
2182
|
+
return { data: null, error: { message: (data == null ? void 0 : data.error) || (data == null ? void 0 : data.message) || `Request failed with status ${res.status}`, status: res.status } };
|
|
2183
|
+
}
|
|
2184
|
+
return { data, error: null };
|
|
2185
|
+
} catch (err) {
|
|
2186
|
+
return { data: null, error: { message: err.message || "Network error", code: "NETWORK_ERROR", status: 0 } };
|
|
2136
2187
|
}
|
|
2137
|
-
return { data: response.data, error: null };
|
|
2138
2188
|
},
|
|
2139
2189
|
list: async () => {
|
|
2140
2190
|
var _a, _b;
|
package/dist/index.mjs
CHANGED
|
@@ -1528,6 +1528,75 @@ var KrisspyNotifications = class {
|
|
|
1528
1528
|
};
|
|
1529
1529
|
|
|
1530
1530
|
// src/query-builder.ts
|
|
1531
|
+
var MutationFilterBuilder = class {
|
|
1532
|
+
constructor(http, path, method, body, initialParams) {
|
|
1533
|
+
this.http = http;
|
|
1534
|
+
this.path = path;
|
|
1535
|
+
this.method = method;
|
|
1536
|
+
this.body = body;
|
|
1537
|
+
this.queryParams = __spreadValues({}, initialParams);
|
|
1538
|
+
delete this.queryParams["select"];
|
|
1539
|
+
delete this.queryParams["order"];
|
|
1540
|
+
delete this.queryParams["limit"];
|
|
1541
|
+
delete this.queryParams["offset"];
|
|
1542
|
+
}
|
|
1543
|
+
eq(column, value) {
|
|
1544
|
+
this.queryParams[column] = `eq.${value}`;
|
|
1545
|
+
return this;
|
|
1546
|
+
}
|
|
1547
|
+
neq(column, value) {
|
|
1548
|
+
this.queryParams[column] = `neq.${value}`;
|
|
1549
|
+
return this;
|
|
1550
|
+
}
|
|
1551
|
+
gt(column, value) {
|
|
1552
|
+
this.queryParams[column] = `gt.${value}`;
|
|
1553
|
+
return this;
|
|
1554
|
+
}
|
|
1555
|
+
gte(column, value) {
|
|
1556
|
+
this.queryParams[column] = `gte.${value}`;
|
|
1557
|
+
return this;
|
|
1558
|
+
}
|
|
1559
|
+
lt(column, value) {
|
|
1560
|
+
this.queryParams[column] = `lt.${value}`;
|
|
1561
|
+
return this;
|
|
1562
|
+
}
|
|
1563
|
+
lte(column, value) {
|
|
1564
|
+
this.queryParams[column] = `lte.${value}`;
|
|
1565
|
+
return this;
|
|
1566
|
+
}
|
|
1567
|
+
like(column, pattern) {
|
|
1568
|
+
this.queryParams[column] = `like.${pattern}`;
|
|
1569
|
+
return this;
|
|
1570
|
+
}
|
|
1571
|
+
ilike(column, pattern) {
|
|
1572
|
+
this.queryParams[column] = `ilike.${pattern}`;
|
|
1573
|
+
return this;
|
|
1574
|
+
}
|
|
1575
|
+
in(column, values) {
|
|
1576
|
+
this.queryParams[column] = `in.${values.join(",")}`;
|
|
1577
|
+
return this;
|
|
1578
|
+
}
|
|
1579
|
+
is(column, value) {
|
|
1580
|
+
const strValue = value === null ? "null" : value ? "true" : "false";
|
|
1581
|
+
this.queryParams[column] = `is.${strValue}`;
|
|
1582
|
+
return this;
|
|
1583
|
+
}
|
|
1584
|
+
async execute() {
|
|
1585
|
+
var _a, _b, _c, _d;
|
|
1586
|
+
const response = this.method === "patch" ? await this.http.patch(this.path, this.body, this.queryParams) : await this.http.delete(this.path, this.queryParams);
|
|
1587
|
+
if (response.error) {
|
|
1588
|
+
return { data: null, error: response.error, count: 0 };
|
|
1589
|
+
}
|
|
1590
|
+
return {
|
|
1591
|
+
data: (_b = (_a = response.data) == null ? void 0 : _a.data) != null ? _b : [],
|
|
1592
|
+
error: null,
|
|
1593
|
+
count: (_d = (_c = response.data) == null ? void 0 : _c.count) != null ? _d : 0
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
then(onfulfilled, onrejected) {
|
|
1597
|
+
return this.execute().then(onfulfilled, onrejected);
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1531
1600
|
var QueryBuilder = class {
|
|
1532
1601
|
constructor(http, backendId, tableName, dataMode = "rls") {
|
|
1533
1602
|
this.queryParams = {};
|
|
@@ -1761,47 +1830,33 @@ var QueryBuilder = class {
|
|
|
1761
1830
|
}
|
|
1762
1831
|
/**
|
|
1763
1832
|
* Update rows (requires filters)
|
|
1764
|
-
*
|
|
1833
|
+
* Returns a thenable builder - chain filters then await.
|
|
1834
|
+
* @example await krisspy.from('items').update({ price: 899 }).eq('id', 123)
|
|
1835
|
+
* @example await krisspy.from('items').eq('id', 123).update({ price: 899 })
|
|
1765
1836
|
*/
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
const response = await this.http.patch(path, data, params);
|
|
1775
|
-
if (response.error) {
|
|
1776
|
-
return { data: null, error: response.error, count: 0 };
|
|
1777
|
-
}
|
|
1778
|
-
return {
|
|
1779
|
-
data: (_b = (_a = response.data) == null ? void 0 : _a.data) != null ? _b : [],
|
|
1780
|
-
error: null,
|
|
1781
|
-
count: (_d = (_c = response.data) == null ? void 0 : _c.count) != null ? _d : 0
|
|
1782
|
-
};
|
|
1837
|
+
update(data) {
|
|
1838
|
+
return new MutationFilterBuilder(
|
|
1839
|
+
this.http,
|
|
1840
|
+
this.getBasePath(),
|
|
1841
|
+
"patch",
|
|
1842
|
+
data,
|
|
1843
|
+
this.buildParams()
|
|
1844
|
+
);
|
|
1783
1845
|
}
|
|
1784
1846
|
/**
|
|
1785
1847
|
* Delete rows (requires filters)
|
|
1786
|
-
*
|
|
1848
|
+
* Returns a thenable builder - chain filters then await.
|
|
1849
|
+
* @example await krisspy.from('items').delete().eq('id', 123)
|
|
1850
|
+
* @example await krisspy.from('items').eq('id', 123).delete()
|
|
1787
1851
|
*/
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
const response = await this.http.delete(path, params);
|
|
1797
|
-
if (response.error) {
|
|
1798
|
-
return { data: null, error: response.error, count: 0 };
|
|
1799
|
-
}
|
|
1800
|
-
return {
|
|
1801
|
-
data: (_b = (_a = response.data) == null ? void 0 : _a.data) != null ? _b : [],
|
|
1802
|
-
error: null,
|
|
1803
|
-
count: (_d = (_c = response.data) == null ? void 0 : _c.count) != null ? _d : 0
|
|
1804
|
-
};
|
|
1852
|
+
delete() {
|
|
1853
|
+
return new MutationFilterBuilder(
|
|
1854
|
+
this.http,
|
|
1855
|
+
this.getBasePath(),
|
|
1856
|
+
"delete",
|
|
1857
|
+
void 0,
|
|
1858
|
+
this.buildParams()
|
|
1859
|
+
);
|
|
1805
1860
|
}
|
|
1806
1861
|
/**
|
|
1807
1862
|
* Upsert rows (insert or update on conflict)
|
|
@@ -2069,37 +2124,32 @@ var KrisspyClient = class {
|
|
|
2069
2124
|
get functions() {
|
|
2070
2125
|
return {
|
|
2071
2126
|
invoke: async (functionName, options) => {
|
|
2072
|
-
if (this.functionsUrl) {
|
|
2073
|
-
|
|
2074
|
-
try {
|
|
2075
|
-
const res = await fetch(url, {
|
|
2076
|
-
method: "POST",
|
|
2077
|
-
headers: __spreadValues({
|
|
2078
|
-
"Content-Type": "application/json"
|
|
2079
|
-
}, options == null ? void 0 : options.headers),
|
|
2080
|
-
body: (options == null ? void 0 : options.body) ? JSON.stringify(options.body) : void 0
|
|
2081
|
-
});
|
|
2082
|
-
const contentType = res.headers.get("content-type");
|
|
2083
|
-
let data = null;
|
|
2084
|
-
if (contentType == null ? void 0 : contentType.includes("application/json")) {
|
|
2085
|
-
data = await res.json();
|
|
2086
|
-
} else {
|
|
2087
|
-
data = await res.text();
|
|
2088
|
-
}
|
|
2089
|
-
if (!res.ok) {
|
|
2090
|
-
return { data: null, error: { message: (data == null ? void 0 : data.error) || (data == null ? void 0 : data.message) || `Request failed with status ${res.status}`, status: res.status } };
|
|
2091
|
-
}
|
|
2092
|
-
return { data, error: null };
|
|
2093
|
-
} catch (err) {
|
|
2094
|
-
return { data: null, error: { message: err.message || "Network error", code: "NETWORK_ERROR", status: 0 } };
|
|
2095
|
-
}
|
|
2127
|
+
if (!this.functionsUrl) {
|
|
2128
|
+
return { data: null, error: { message: 'functionsUrl is required. Pass it in createClient({ functionsUrl: "https://your-func-app.azurewebsites.net" })', code: "CONFIG_ERROR", status: 0 } };
|
|
2096
2129
|
}
|
|
2097
|
-
const
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2130
|
+
const url = `${this.functionsUrl}/api/${functionName}`;
|
|
2131
|
+
try {
|
|
2132
|
+
const res = await fetch(url, {
|
|
2133
|
+
method: "POST",
|
|
2134
|
+
headers: __spreadValues({
|
|
2135
|
+
"Content-Type": "application/json"
|
|
2136
|
+
}, options == null ? void 0 : options.headers),
|
|
2137
|
+
body: (options == null ? void 0 : options.body) ? JSON.stringify(options.body) : void 0
|
|
2138
|
+
});
|
|
2139
|
+
const contentType = res.headers.get("content-type");
|
|
2140
|
+
let data = null;
|
|
2141
|
+
if (contentType == null ? void 0 : contentType.includes("application/json")) {
|
|
2142
|
+
data = await res.json();
|
|
2143
|
+
} else {
|
|
2144
|
+
data = await res.text();
|
|
2145
|
+
}
|
|
2146
|
+
if (!res.ok) {
|
|
2147
|
+
return { data: null, error: { message: (data == null ? void 0 : data.error) || (data == null ? void 0 : data.message) || `Request failed with status ${res.status}`, status: res.status } };
|
|
2148
|
+
}
|
|
2149
|
+
return { data, error: null };
|
|
2150
|
+
} catch (err) {
|
|
2151
|
+
return { data: null, error: { message: err.message || "Network error", code: "NETWORK_ERROR", status: 0 } };
|
|
2101
2152
|
}
|
|
2102
|
-
return { data: response.data, error: null };
|
|
2103
2153
|
},
|
|
2104
2154
|
list: async () => {
|
|
2105
2155
|
var _a, _b;
|