@ram_28/kf-ai-sdk 1.0.20 → 1.0.21

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.
Files changed (50) hide show
  1. package/dist/api/client.d.ts.map +1 -1
  2. package/dist/api/datetime.d.ts +59 -10
  3. package/dist/api/datetime.d.ts.map +1 -1
  4. package/dist/api/index.d.ts +3 -2
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/api.cjs +1 -1
  7. package/dist/api.d.ts +1 -1
  8. package/dist/api.d.ts.map +1 -1
  9. package/dist/api.mjs +43 -21
  10. package/dist/api.types.d.ts +2 -1
  11. package/dist/api.types.d.ts.map +1 -1
  12. package/dist/auth/AuthProvider.d.ts.map +1 -1
  13. package/dist/auth.cjs +1 -1
  14. package/dist/auth.mjs +34 -34
  15. package/dist/base-types.d.ts +1 -1
  16. package/dist/base-types.d.ts.map +1 -1
  17. package/dist/client-BIkaIr2y.js +217 -0
  18. package/dist/client-DxjRcEtN.cjs +1 -0
  19. package/dist/components/hooks/useForm/apiClient.d.ts +45 -4
  20. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  21. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  22. package/dist/form.cjs +1 -1
  23. package/dist/form.mjs +736 -761
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/kanban.cjs +1 -1
  27. package/dist/kanban.mjs +1 -1
  28. package/dist/{metadata-0lZAfuTP.cjs → metadata-Bz8zJqC1.cjs} +1 -1
  29. package/dist/{metadata-B88D_pVS.js → metadata-VbQzyD2C.js} +1 -1
  30. package/dist/table.cjs +1 -1
  31. package/dist/table.mjs +1 -1
  32. package/dist/types/base-fields.d.ts +71 -17
  33. package/dist/types/base-fields.d.ts.map +1 -1
  34. package/dist/types/common.d.ts +0 -12
  35. package/dist/types/common.d.ts.map +1 -1
  36. package/package.json +1 -1
  37. package/sdk/api/client.ts +3 -41
  38. package/sdk/api/datetime.ts +98 -14
  39. package/sdk/api/index.ts +12 -6
  40. package/sdk/api.ts +6 -3
  41. package/sdk/api.types.ts +3 -4
  42. package/sdk/auth/AuthProvider.tsx +22 -24
  43. package/sdk/base-types.ts +2 -0
  44. package/sdk/components/hooks/useForm/apiClient.ts +118 -4
  45. package/sdk/components/hooks/useForm/useForm.ts +70 -58
  46. package/sdk/index.ts +3 -0
  47. package/sdk/types/base-fields.ts +71 -17
  48. package/sdk/types/common.ts +2 -13
  49. package/dist/client-DgtkT50N.cjs +0 -1
  50. package/dist/client-V-WzUb8H.js +0 -237
@@ -1 +0,0 @@
1
- "use strict";let o={baseUrl:"",headers:{"Content-Type":"application/json"}};function u(e){o.baseUrl=e}function h(e){o.headers={...o.headers,...e}}function d(){return{...o.headers}}function l(){return o.baseUrl||""}function i(e){if(e==null)return e;if(Array.isArray(e))return e.map(s=>i(s));if(typeof e=="object"){if("$__dt__"in e)return new Date(e.$__dt__*1e3);if("$__d__"in e)return new Date(e.$__d__);const s={};for(const[n,t]of Object.entries(e))s[n]=i(t);return s}return e}function w(e){const s=o.baseUrl,n=o.headers;return{async get(t){const r=await fetch(`${s}/api/app/${e}/${t}/read`,{method:"GET",headers:n});if(!r.ok)throw new Error(`Failed to get ${e} ${t}: ${r.statusText}`);const a=await r.json();return i(a.Data)},async create(t){const r=await fetch(`${s}/api/app/${e}/create`,{method:"POST",headers:n,body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create ${e}: ${r.statusText}`);return r.json()},async update(t,r){const a=await fetch(`${s}/api/app/${e}/${t}/update`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to update ${e} ${t}: ${a.statusText}`);return a.json()},async delete(t){const r=await fetch(`${s}/api/app/${e}/${t}/delete`,{method:"DELETE",headers:n});if(!r.ok)throw new Error(`Failed to delete ${e} ${t}: ${r.statusText}`);return r.json()},async list(t){const r={Type:"List",...t},a=await fetch(`${s}/api/app/${e}/list`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to list ${e}: ${a.statusText}`);return{Data:(await a.json()).Data.map(f=>i(f))}},async count(t){var p,$;const r={Type:"Metric",GroupBy:[],Metric:[{Field:"_id",Type:"Count"}],...(t==null?void 0:t.Filter)&&{Filter:t.Filter}},a=await fetch(`${s}/api/app/${e}/metric`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to count ${e}: ${a.statusText}`);return{Count:(($=(p=(await a.json()).Data)==null?void 0:p[0])==null?void 0:$.count__id)??0}},async draft(t){const r=await fetch(`${s}/api/app/${e}/draft`,{method:"POST",headers:n,body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create draft for ${e}: ${r.statusText}`);return r.json()},async draftUpdate(t,r){const a=await fetch(`${s}/api/app/${e}/${t}/draft`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to update draft for ${e} ${t}: ${a.statusText}`);return a.json()},async draftPatch(t,r){const a=await fetch(`${s}/api/app/${e}/${t}/draft`,{method:"PATCH",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to patch draft for ${e} ${t}: ${a.statusText}`);return a.json()},async draftInteraction(t){const r=await fetch(`${s}/api/app/${e}/draft`,{method:"PATCH",headers:n,body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create interactive draft for ${e}: ${r.statusText}`);const a=await r.json();return{...a.Data,_id:a.Data._id}},async metric(t){const r={Type:"Metric",...t},a=await fetch(`${s}/api/app/${e}/metric`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to get metrics for ${e}: ${a.statusText}`);return a.json()},async pivot(t){const r={Type:"Pivot",...t},a=await fetch(`${s}/api/app/${e}/pivot`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to get pivot data for ${e}: ${a.statusText}`);return a.json()},async fields(){const t=await fetch(`${s}/api/app/${e}/fields`,{method:"GET",headers:n});if(!t.ok)throw new Error(`Failed to get fields for ${e}: ${t.statusText}`);return t.json()},async fetchField(t,r){const a=await fetch(`${s}/api/app/${e}/${t}/field/${r}/fetch`,{method:"GET",headers:n});if(!a.ok)throw new Error(`Failed to fetch field ${r} for ${e}: ${a.statusText}`);return(await a.json()).Data}}}exports.api=w;exports.getApiBaseUrl=l;exports.getDefaultHeaders=d;exports.setApiBaseUrl=u;exports.setDefaultHeaders=h;
@@ -1,237 +0,0 @@
1
- let o = {
2
- baseUrl: "",
3
- headers: {
4
- "Content-Type": "application/json"
5
- }
6
- };
7
- function u(e) {
8
- o.baseUrl = e;
9
- }
10
- function h(e) {
11
- o.headers = { ...o.headers, ...e };
12
- }
13
- function d() {
14
- return { ...o.headers };
15
- }
16
- function w() {
17
- return o.baseUrl || "";
18
- }
19
- function i(e) {
20
- if (e == null)
21
- return e;
22
- if (Array.isArray(e))
23
- return e.map((s) => i(s));
24
- if (typeof e == "object") {
25
- if ("$__dt__" in e)
26
- return new Date(e.$__dt__ * 1e3);
27
- if ("$__d__" in e)
28
- return new Date(e.$__d__);
29
- const s = {};
30
- for (const [n, t] of Object.entries(e))
31
- s[n] = i(t);
32
- return s;
33
- }
34
- return e;
35
- }
36
- function y(e) {
37
- const s = o.baseUrl, n = o.headers;
38
- return {
39
- async get(t) {
40
- const r = await fetch(`${s}/api/app/${e}/${t}/read`, {
41
- method: "GET",
42
- headers: n
43
- });
44
- if (!r.ok)
45
- throw new Error(`Failed to get ${e} ${t}: ${r.statusText}`);
46
- const a = await r.json();
47
- return i(a.Data);
48
- },
49
- async create(t) {
50
- const r = await fetch(`${s}/api/app/${e}/create`, {
51
- method: "POST",
52
- headers: n,
53
- body: JSON.stringify(t)
54
- });
55
- if (!r.ok)
56
- throw new Error(`Failed to create ${e}: ${r.statusText}`);
57
- return r.json();
58
- },
59
- async update(t, r) {
60
- const a = await fetch(`${s}/api/app/${e}/${t}/update`, {
61
- method: "POST",
62
- headers: n,
63
- body: JSON.stringify(r)
64
- });
65
- if (!a.ok)
66
- throw new Error(
67
- `Failed to update ${e} ${t}: ${a.statusText}`
68
- );
69
- return a.json();
70
- },
71
- async delete(t) {
72
- const r = await fetch(`${s}/api/app/${e}/${t}/delete`, {
73
- method: "DELETE",
74
- headers: n
75
- });
76
- if (!r.ok)
77
- throw new Error(
78
- `Failed to delete ${e} ${t}: ${r.statusText}`
79
- );
80
- return r.json();
81
- },
82
- async list(t) {
83
- const r = {
84
- Type: "List",
85
- ...t
86
- }, a = await fetch(`${s}/api/app/${e}/list`, {
87
- method: "POST",
88
- headers: n,
89
- body: JSON.stringify(r)
90
- });
91
- if (!a.ok)
92
- throw new Error(`Failed to list ${e}: ${a.statusText}`);
93
- return {
94
- Data: (await a.json()).Data.map((f) => i(f))
95
- };
96
- },
97
- async count(t) {
98
- var p, $;
99
- const r = {
100
- Type: "Metric",
101
- GroupBy: [],
102
- Metric: [{ Field: "_id", Type: "Count" }],
103
- ...(t == null ? void 0 : t.Filter) && { Filter: t.Filter }
104
- }, a = await fetch(`${s}/api/app/${e}/metric`, {
105
- method: "POST",
106
- headers: n,
107
- body: JSON.stringify(r)
108
- });
109
- if (!a.ok)
110
- throw new Error(`Failed to count ${e}: ${a.statusText}`);
111
- return { Count: (($ = (p = (await a.json()).Data) == null ? void 0 : p[0]) == null ? void 0 : $.count__id) ?? 0 };
112
- },
113
- // ============================================================
114
- // DRAFT/INTERACTIVE OPERATIONS
115
- // ============================================================
116
- async draft(t) {
117
- const r = await fetch(`${s}/api/app/${e}/draft`, {
118
- method: "POST",
119
- headers: n,
120
- body: JSON.stringify(t)
121
- });
122
- if (!r.ok)
123
- throw new Error(
124
- `Failed to create draft for ${e}: ${r.statusText}`
125
- );
126
- return r.json();
127
- },
128
- async draftUpdate(t, r) {
129
- const a = await fetch(`${s}/api/app/${e}/${t}/draft`, {
130
- method: "POST",
131
- headers: n,
132
- body: JSON.stringify(r)
133
- });
134
- if (!a.ok)
135
- throw new Error(
136
- `Failed to update draft for ${e} ${t}: ${a.statusText}`
137
- );
138
- return a.json();
139
- },
140
- async draftPatch(t, r) {
141
- const a = await fetch(`${s}/api/app/${e}/${t}/draft`, {
142
- method: "PATCH",
143
- headers: n,
144
- body: JSON.stringify(r)
145
- });
146
- if (!a.ok)
147
- throw new Error(
148
- `Failed to patch draft for ${e} ${t}: ${a.statusText}`
149
- );
150
- return a.json();
151
- },
152
- async draftInteraction(t) {
153
- const r = await fetch(`${s}/api/app/${e}/draft`, {
154
- method: "PATCH",
155
- headers: n,
156
- body: JSON.stringify(t)
157
- });
158
- if (!r.ok)
159
- throw new Error(
160
- `Failed to create interactive draft for ${e}: ${r.statusText}`
161
- );
162
- const a = await r.json();
163
- return {
164
- ...a.Data,
165
- _id: a.Data._id
166
- };
167
- },
168
- // ============================================================
169
- // QUERY OPERATIONS
170
- // ============================================================
171
- async metric(t) {
172
- const r = {
173
- Type: "Metric",
174
- ...t
175
- }, a = await fetch(`${s}/api/app/${e}/metric`, {
176
- method: "POST",
177
- headers: n,
178
- body: JSON.stringify(r)
179
- });
180
- if (!a.ok)
181
- throw new Error(
182
- `Failed to get metrics for ${e}: ${a.statusText}`
183
- );
184
- return a.json();
185
- },
186
- async pivot(t) {
187
- const r = {
188
- Type: "Pivot",
189
- ...t
190
- }, a = await fetch(`${s}/api/app/${e}/pivot`, {
191
- method: "POST",
192
- headers: n,
193
- body: JSON.stringify(r)
194
- });
195
- if (!a.ok)
196
- throw new Error(
197
- `Failed to get pivot data for ${e}: ${a.statusText}`
198
- );
199
- return a.json();
200
- },
201
- // ============================================================
202
- // METADATA OPERATIONS
203
- // ============================================================
204
- async fields() {
205
- const t = await fetch(`${s}/api/app/${e}/fields`, {
206
- method: "GET",
207
- headers: n
208
- });
209
- if (!t.ok)
210
- throw new Error(
211
- `Failed to get fields for ${e}: ${t.statusText}`
212
- );
213
- return t.json();
214
- },
215
- async fetchField(t, r) {
216
- const a = await fetch(
217
- `${s}/api/app/${e}/${t}/field/${r}/fetch`,
218
- {
219
- method: "GET",
220
- headers: n
221
- }
222
- );
223
- if (!a.ok)
224
- throw new Error(
225
- `Failed to fetch field ${r} for ${e}: ${a.statusText}`
226
- );
227
- return (await a.json()).Data;
228
- }
229
- };
230
- }
231
- export {
232
- y as a,
233
- h as b,
234
- w as c,
235
- d as g,
236
- u as s
237
- };