@taruvi/refine-providers 1.1.8-beta.0 → 1.1.8-beta.1

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 CHANGED
@@ -8,31 +8,50 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
  var DataLoader__default = /*#__PURE__*/_interopDefault(DataLoader);
9
9
 
10
10
  // src/dataProvider.ts
11
- var REFINE_TO_SDK_OPERATOR = {
12
- eq: "eq",
11
+
12
+ // src/utils.ts
13
+ var REFINE_OPERATOR_MAP = {
14
+ // Equality
15
+ eq: "",
16
+ // exact match (no suffix)
13
17
  ne: "ne",
18
+ // Comparison
14
19
  lt: "lt",
15
20
  gt: "gt",
16
21
  lte: "lte",
17
22
  gte: "gte",
23
+ // String operations (case-sensitive)
18
24
  contains: "contains",
19
- containss: "icontains",
20
- // case-insensitive
25
+ ncontains: "ncontains",
21
26
  startswith: "startswith",
22
- startswiths: "istartswith",
27
+ nstartswith: "nstartswith",
23
28
  endswith: "endswith",
29
+ nendswith: "nendswith",
30
+ // String operations (case-insensitive)
31
+ containss: "icontains",
32
+ ncontainss: "nicontains",
33
+ startswiths: "istartswith",
34
+ nstartswiths: "nistartswith",
24
35
  endswiths: "iendswith",
36
+ nendswiths: "niendswith",
37
+ // Array operations
25
38
  in: "in",
26
39
  nin: "nin",
27
- null: "isnull"
40
+ // Null checks
41
+ null: "null",
42
+ nnull: "nnull",
43
+ // Range
44
+ between: "between",
45
+ nbetween: "nbetween"
28
46
  };
29
- function applyFilters(query, filters) {
30
- if (!filters || filters.length === 0) return query;
31
- let result = query;
47
+ function convertRefineFilters(filters) {
48
+ if (!filters || filters.length === 0) return {};
49
+ const params = {};
32
50
  for (const filter of filters) {
33
51
  if ("operator" in filter && (filter.operator === "and" || filter.operator === "or")) {
34
52
  if (filter.value && Array.isArray(filter.value)) {
35
- result = applyFilters(result, filter.value);
53
+ const nested = convertRefineFilters(filter.value);
54
+ Object.assign(params, nested);
36
55
  }
37
56
  continue;
38
57
  }
@@ -41,22 +60,104 @@ function applyFilters(query, filters) {
41
60
  if (value === void 0 || value === null && operator !== "null") {
42
61
  continue;
43
62
  }
44
- const sdkOperator = REFINE_TO_SDK_OPERATOR[operator];
45
- if (!sdkOperator) {
63
+ const suffix = REFINE_OPERATOR_MAP[operator];
64
+ if (suffix === void 0) {
46
65
  console.warn(`Unknown Refine operator: ${operator}`);
47
66
  continue;
48
67
  }
49
- let sdkValue;
68
+ const paramKey = suffix ? `${field}__${suffix}` : String(field);
50
69
  if (operator === "in" || operator === "nin") {
51
- sdkValue = Array.isArray(value) ? value : [value];
70
+ params[paramKey] = Array.isArray(value) ? value.join(",") : String(value);
71
+ } else if (operator === "between" || operator === "nbetween") {
72
+ params[paramKey] = Array.isArray(value) ? value.join(",") : String(value);
73
+ } else if (operator === "null" || operator === "nnull") {
74
+ params[paramKey] = "true";
75
+ } else {
76
+ params[paramKey] = String(value);
77
+ }
78
+ }
79
+ }
80
+ return params;
81
+ }
82
+ function convertRefineSorters(sorters) {
83
+ if (!sorters || sorters.length === 0) return void 0;
84
+ return sorters.map((sort) => sort.order === "desc" ? `-${sort.field}` : sort.field).join(",");
85
+ }
86
+ function convertRefinePagination(pagination) {
87
+ if (!pagination) return {};
88
+ const { currentPage, pageSize, mode } = pagination;
89
+ if (mode === "off") return {};
90
+ return {
91
+ page: currentPage ?? 1,
92
+ // Default to page 1 if currentPage is undefined
93
+ page_size: pageSize
94
+ };
95
+ }
96
+ function buildRefineQueryParams(options) {
97
+ const { filters, sorters, pagination, meta } = options;
98
+ const params = {
99
+ ...convertRefineFilters(filters),
100
+ ...convertRefinePagination(pagination)
101
+ };
102
+ const ordering = convertRefineSorters(sorters);
103
+ if (ordering) {
104
+ params.ordering = ordering;
105
+ }
106
+ if (meta?.populate) {
107
+ params.populate = Array.isArray(meta.populate) ? meta.populate.join(",") : meta.populate;
108
+ }
109
+ return params;
110
+ }
111
+ function buildQueryString(params) {
112
+ if (!params || Object.keys(params).length === 0) return "";
113
+ const searchParams = new URLSearchParams();
114
+ for (const [key, value] of Object.entries(params)) {
115
+ if (value !== void 0 && value !== null) {
116
+ searchParams.append(key, String(value));
117
+ }
118
+ }
119
+ const queryString = searchParams.toString();
120
+ return queryString ? `?${queryString}` : "";
121
+ }
122
+ function handleError(error) {
123
+ if (error instanceof Error) {
124
+ throw error;
125
+ }
126
+ if (typeof error === "object" && error !== null && "message" in error) {
127
+ throw new Error(String(error.message));
128
+ }
129
+ throw new Error("Unknown error occurred");
130
+ }
131
+
132
+ // src/dataProvider.ts
133
+ function applyFilters(query, filters) {
134
+ if (!filters || filters.length === 0) return query;
135
+ let result = query;
136
+ for (const filter of filters) {
137
+ if ("operator" in filter && (filter.operator === "and" || filter.operator === "or")) {
138
+ if (filter.value && Array.isArray(filter.value)) {
139
+ result = applyFilters(result, filter.value);
140
+ }
141
+ continue;
142
+ }
143
+ if ("field" in filter && filter.field && filter.operator) {
144
+ const { field, operator, value } = filter;
145
+ if (value === void 0 || value === null && operator !== "null") continue;
146
+ const suffix = REFINE_OPERATOR_MAP[operator];
147
+ if (suffix === void 0) {
148
+ console.warn(`Unknown Refine operator: ${operator}`);
149
+ continue;
150
+ }
151
+ const paramKey = suffix ? `${field}__${suffix}` : String(field);
152
+ let paramValue;
153
+ if (operator === "in" || operator === "nin" || operator === "between" || operator === "nbetween") {
154
+ paramValue = Array.isArray(value) ? value.join(",") : String(value);
52
155
  } else if (operator === "null" || operator === "nnull") {
53
- sdkValue = true;
54
- } else if (typeof value === "boolean" || typeof value === "number") {
55
- sdkValue = value;
156
+ paramValue = "true";
56
157
  } else {
57
- sdkValue = String(value);
158
+ paramValue = String(value);
58
159
  }
59
- result = result.filter(String(field), sdkOperator, sdkValue);
160
+ result = result.filter(paramKey, "eq", paramValue);
60
161
  }
61
162
  }
62
163
  return result;
@@ -65,20 +166,15 @@ function applySorters(query, sorters) {
65
166
  if (!sorters || sorters.length === 0) return query;
66
167
  let result = query;
67
168
  for (const sorter of sorters) {
68
- const order = sorter.order === "desc" ? "desc" : "asc";
69
- result = result.sort(sorter.field, order);
169
+ result = result.sort(sorter.field, sorter.order === "desc" ? "desc" : "asc");
70
170
  }
71
171
  return result;
72
172
  }
73
173
  function applyPagination(query, pagination) {
74
174
  if (!pagination || pagination.mode === "off") return query;
75
175
  let result = query;
76
- if (pagination.currentPage) {
77
- result = result.page(pagination.currentPage);
78
- }
79
- if (pagination.pageSize) {
80
- result = result.pageSize(pagination.pageSize);
81
- }
176
+ if (pagination.currentPage) result = result.page(pagination.currentPage);
177
+ if (pagination.pageSize) result = result.pageSize(pagination.pageSize);
82
178
  return result;
83
179
  }
84
180
  function applyPopulate(query, meta) {
@@ -100,7 +196,7 @@ function buildGraphQuery(client, tableName, meta, recordId) {
100
196
  }
101
197
  function dataProvider(client) {
102
198
  const config = client.getConfig();
103
- const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
199
+ const baseApiUrl = `${config.apiUrl}/api/apps/${config.appSlug}`;
104
200
  const getIdColumn = (meta) => meta?.idColumnName ?? "id";
105
201
  const getTableName = (resource, meta) => meta?.tableName ?? resource;
106
202
  return {
@@ -131,9 +227,9 @@ function dataProvider(client) {
131
227
  const data = Array.isArray(response2) ? response2[0] : response2?.data?.[0] ?? response2;
132
228
  return { data };
133
229
  }
134
- let query = new sdk.Database(client).from(tableName);
230
+ let query = new sdk.Database(client).from(tableName).get(String(id));
135
231
  query = applyPopulate(query, taruviMeta);
136
- const response = await query.get(String(id)).execute();
232
+ const response = await query.execute();
137
233
  return { data: response.data };
138
234
  },
139
235
  getMany: async (params) => {
@@ -161,11 +257,11 @@ function dataProvider(client) {
161
257
  const taruviMeta = meta;
162
258
  const tableName = getTableName(resource, taruviMeta);
163
259
  if (isGraphQuery(taruviMeta)) {
164
- const data2 = await new sdk.Graph(client).from(tableName).createEdge(variables).execute();
165
- return { data: data2 };
260
+ const response2 = await new sdk.Graph(client).from(tableName).create(variables).execute();
261
+ return { data: response2.data };
166
262
  }
167
- const data = await new sdk.Database(client).from(tableName).create(variables).execute();
168
- return { data };
263
+ const response = await new sdk.Database(client).from(tableName).create(variables).execute();
264
+ return { data: response.data };
169
265
  },
170
266
  createMany: async (params) => {
171
267
  const { resource, variables, meta } = params;
@@ -173,7 +269,8 @@ function dataProvider(client) {
173
269
  const tableName = getTableName(resource, taruviMeta);
174
270
  const data = await Promise.all(
175
271
  variables.map(async (vars) => {
176
- return new sdk.Database(client).from(tableName).create(vars).execute();
272
+ const response = await new sdk.Database(client).from(tableName).create(vars).execute();
273
+ return response.data;
177
274
  })
178
275
  );
179
276
  return { data };
@@ -183,11 +280,11 @@ function dataProvider(client) {
183
280
  const taruviMeta = meta;
184
281
  const tableName = getTableName(resource, taruviMeta);
185
282
  if (isGraphQuery(taruviMeta)) {
186
- const data2 = await new sdk.Graph(client).from(tableName).updateEdge(String(id), variables).execute();
187
- return { data: data2 };
283
+ const response2 = await new sdk.Graph(client).from(tableName).update(String(id), variables).execute();
284
+ return { data: response2.data };
188
285
  }
189
- const data = await new sdk.Database(client).from(tableName).get(String(id)).update(variables).execute();
190
- return { data };
286
+ const response = await new sdk.Database(client).from(tableName).get(String(id)).update(variables).execute();
287
+ return { data: response.data };
191
288
  },
192
289
  updateMany: async (params) => {
193
290
  const { resource, ids, variables, meta } = params;
@@ -195,7 +292,8 @@ function dataProvider(client) {
195
292
  const tableName = getTableName(resource, taruviMeta);
196
293
  const data = await Promise.all(
197
294
  ids.map(async (id) => {
198
- return new sdk.Database(client).from(tableName).get(String(id)).update(variables).execute();
295
+ const response = await new sdk.Database(client).from(tableName).get(String(id)).update(variables).execute();
296
+ return response.data;
199
297
  })
200
298
  );
201
299
  return { data };
@@ -205,46 +303,51 @@ function dataProvider(client) {
205
303
  const taruviMeta = meta;
206
304
  const tableName = getTableName(resource, taruviMeta);
207
305
  if (isGraphQuery(taruviMeta)) {
208
- const data2 = await new sdk.Graph(client).from(tableName).deleteEdge([String(id)]).execute();
209
- return { data: data2 };
306
+ const response = await new sdk.Graph(client).from(tableName).delete([Number(id)]).execute();
307
+ return { data: response.data };
210
308
  }
211
- const data = await new sdk.Database(client).from(tableName).delete(String(id)).execute();
212
- return { data };
309
+ await new sdk.Database(client).from(tableName).delete(String(id)).execute();
310
+ return { data: { id } };
213
311
  },
214
312
  deleteMany: async (params) => {
215
313
  const { resource, ids, meta } = params;
216
314
  const taruviMeta = meta;
217
315
  const tableName = getTableName(resource, taruviMeta);
218
316
  if (isGraphQuery(taruviMeta)) {
219
- const data2 = await new sdk.Graph(client).from(tableName).deleteEdge(ids.map(String)).execute();
220
- return { data: [data2] };
317
+ const response = await new sdk.Graph(client).from(tableName).delete(ids.map(Number)).execute();
318
+ return { data: [response.data] };
221
319
  }
222
- const data = await Promise.all(
223
- ids.map((id) => new sdk.Database(client).from(tableName).delete(String(id)).execute())
320
+ await Promise.all(
321
+ ids.map(async (id) => {
322
+ await new sdk.Database(client).from(tableName).delete(String(id)).execute();
323
+ })
224
324
  );
225
- return { data };
325
+ return { data: ids.map((id) => ({ id })) };
226
326
  },
227
327
  custom: async (params) => {
228
328
  const { url, method, payload, query } = params;
229
- let fullUrl = `api/apps/${config.appSlug}/datatables/${url}`;
329
+ let endpoint = `api/apps/${config.appSlug}/datatables/${url}`;
230
330
  let data;
231
331
  switch (method.toLowerCase()) {
232
332
  case "get": {
233
333
  if (query && Object.keys(query).length > 0) {
234
334
  const queryString = new URLSearchParams(query).toString();
235
- fullUrl = `${fullUrl}${fullUrl.includes("?") ? "&" : "?"}${queryString}`;
335
+ endpoint = `${endpoint}${endpoint.includes("?") ? "&" : "?"}${queryString}`;
236
336
  }
237
- data = await client.httpClient.get(fullUrl);
337
+ data = await client.httpClient.get(endpoint);
238
338
  break;
239
339
  }
240
340
  case "post":
241
- data = await client.httpClient.post(fullUrl, payload);
341
+ data = await client.httpClient.post(endpoint, payload);
242
342
  break;
243
343
  case "put":
244
- data = await client.httpClient.put(fullUrl, payload);
344
+ data = await client.httpClient.put(endpoint, payload);
345
+ break;
346
+ case "patch":
347
+ data = await client.httpClient.patch(endpoint, payload);
245
348
  break;
246
349
  case "delete":
247
- data = await client.httpClient.delete(fullUrl);
350
+ data = await client.httpClient.delete(endpoint);
248
351
  break;
249
352
  default:
250
353
  throw new Error(`Unsupported HTTP method: ${method}`);
@@ -254,131 +357,9 @@ function dataProvider(client) {
254
357
  getApiUrl: () => baseApiUrl
255
358
  };
256
359
  }
257
-
258
- // src/utils.ts
259
- var REFINE_OPERATOR_MAP = {
260
- // Equality
261
- eq: "",
262
- // exact match (no suffix)
263
- ne: "ne",
264
- // Comparison
265
- lt: "lt",
266
- gt: "gt",
267
- lte: "lte",
268
- gte: "gte",
269
- // String operations (case-sensitive)
270
- contains: "contains",
271
- ncontains: "ncontains",
272
- startswith: "startswith",
273
- nstartswith: "nstartswith",
274
- endswith: "endswith",
275
- nendswith: "nendswith",
276
- // String operations (case-insensitive)
277
- containss: "icontains",
278
- ncontainss: "nicontains",
279
- startswiths: "istartswith",
280
- nstartswiths: "nistartswith",
281
- endswiths: "iendswith",
282
- nendswiths: "niendswith",
283
- // Array operations
284
- in: "in",
285
- nin: "nin",
286
- // Null checks
287
- null: "null",
288
- nnull: "nnull",
289
- // Range
290
- between: "between",
291
- nbetween: "nbetween"
292
- };
293
- function convertRefineFilters(filters) {
294
- if (!filters || filters.length === 0) return {};
295
- const params = {};
296
- for (const filter of filters) {
297
- if ("operator" in filter && (filter.operator === "and" || filter.operator === "or")) {
298
- if (filter.value && Array.isArray(filter.value)) {
299
- const nested = convertRefineFilters(filter.value);
300
- Object.assign(params, nested);
301
- }
302
- continue;
303
- }
304
- if ("field" in filter && filter.field && filter.operator) {
305
- const { field, operator, value } = filter;
306
- if (value === void 0 || value === null && operator !== "null") {
307
- continue;
308
- }
309
- const suffix = REFINE_OPERATOR_MAP[operator];
310
- if (suffix === void 0) {
311
- console.warn(`Unknown Refine operator: ${operator}`);
312
- continue;
313
- }
314
- const paramKey = suffix ? `${field}__${suffix}` : String(field);
315
- if (operator === "in" || operator === "nin") {
316
- params[paramKey] = Array.isArray(value) ? value.join(",") : String(value);
317
- } else if (operator === "between" || operator === "nbetween") {
318
- params[paramKey] = Array.isArray(value) ? value.join(",") : String(value);
319
- } else if (operator === "null" || operator === "nnull") {
320
- params[paramKey] = "true";
321
- } else {
322
- params[paramKey] = String(value);
323
- }
324
- }
325
- }
326
- return params;
327
- }
328
- function convertRefineSorters(sorters) {
329
- if (!sorters || sorters.length === 0) return void 0;
330
- return sorters.map((sort) => sort.order === "desc" ? `-${sort.field}` : sort.field).join(",");
331
- }
332
- function convertRefinePagination(pagination) {
333
- if (!pagination) return {};
334
- const { currentPage, pageSize, mode } = pagination;
335
- if (mode === "off") return {};
336
- return {
337
- page: currentPage ?? 1,
338
- // Default to page 1 if currentPage is undefined
339
- page_size: pageSize
340
- };
341
- }
342
- function buildRefineQueryParams(options) {
343
- const { filters, sorters, pagination, meta } = options;
344
- const params = {
345
- ...convertRefineFilters(filters),
346
- ...convertRefinePagination(pagination)
347
- };
348
- const ordering = convertRefineSorters(sorters);
349
- if (ordering) {
350
- params.ordering = ordering;
351
- }
352
- if (meta?.populate) {
353
- params.populate = Array.isArray(meta.populate) ? meta.populate.join(",") : meta.populate;
354
- }
355
- return params;
356
- }
357
- function buildQueryString(params) {
358
- if (!params || Object.keys(params).length === 0) return "";
359
- const searchParams = new URLSearchParams();
360
- for (const [key, value] of Object.entries(params)) {
361
- if (value !== void 0 && value !== null) {
362
- searchParams.append(key, String(value));
363
- }
364
- }
365
- const queryString = searchParams.toString();
366
- return queryString ? `?${queryString}` : "";
367
- }
368
- function handleError(error) {
369
- if (error instanceof Error) {
370
- throw error;
371
- }
372
- if (typeof error === "object" && error !== null && "message" in error) {
373
- throw new Error(String(error.message));
374
- }
375
- throw new Error("Unknown error occurred");
376
- }
377
-
378
- // src/storageDataProvider.ts
379
360
  function storageDataProvider(client) {
380
361
  const config = client.getConfig();
381
- const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
362
+ const baseApiUrl = `${config.apiUrl}/api/apps/${config.appSlug}`;
382
363
  const getBucketName = (resource, meta) => meta?.bucketName ?? resource;
383
364
  const buildFilters = (params) => {
384
365
  const filters = {
@@ -395,27 +376,15 @@ function storageDataProvider(client) {
395
376
  const taruviMeta = meta;
396
377
  const bucket = getBucketName(resource, taruviMeta);
397
378
  const storageFilters = buildFilters({ filters, sorters, pagination});
398
- const response = await new sdk.Storage(client, {}).from(bucket).filter(storageFilters).execute();
379
+ const response = await new sdk.Storage(client).from(bucket).filter(storageFilters).execute();
399
380
  return { data: response.data, total: response.total };
400
381
  },
401
382
  getOne: async (params) => {
402
383
  const { resource, id: path, meta } = params;
403
384
  const taruviMeta = meta;
404
385
  const bucket = getBucketName(resource, taruviMeta);
405
- const encodedPath = String(path);
406
- const url = `${baseApiUrl}/storage/buckets/${bucket}/objects/${encodedPath}/`;
407
- const headers = {};
408
- const token = client.tokenClient.getToken();
409
- if (token) headers["Authorization"] = `Bearer ${token}`;
410
- if (taruviMeta?.metadata) {
411
- const res2 = await fetch(`${url}?metadata=true`, { headers });
412
- const data = await res2.json();
413
- return { data };
414
- }
415
- const res = await fetch(url, { headers });
416
- const blob = await res.blob();
417
- const blobUrl = URL.createObjectURL(blob);
418
- return { data: blobUrl };
386
+ const data = await new sdk.Storage(client).from(bucket).download(String(path)).execute();
387
+ return { data };
419
388
  },
420
389
  create: async (params) => {
421
390
  const { resource, variables, meta } = params;
@@ -424,25 +393,25 @@ function storageDataProvider(client) {
424
393
  const { files, paths = [], metadatas = [] } = variables;
425
394
  const filePaths = files.map((file, i) => paths[i] || file.name);
426
395
  const fileMetadatas = files.map((_, i) => metadatas[i] || {});
427
- const data = await new sdk.Storage(client, {}).from(bucket).upload({ files, paths: filePaths, metadatas: fileMetadatas }).execute();
428
- return { data };
396
+ const response = await new sdk.Storage(client).from(bucket).upload({ files, paths: filePaths, metadatas: fileMetadatas }).execute();
397
+ const firstUploaded = response.data?.successful?.[0]?.object;
398
+ return { data: firstUploaded ?? response.data };
429
399
  },
430
400
  update: async (params) => {
431
401
  const { resource, id: path, variables, meta } = params;
432
402
  const taruviMeta = meta;
433
403
  const bucket = getBucketName(resource, taruviMeta);
434
- const data = await new sdk.Storage(client, {}).from(bucket).update(String(path), variables).execute();
435
- return { data };
404
+ const response = await new sdk.Storage(client).from(bucket).update(String(path), variables).execute();
405
+ return { data: response.data };
436
406
  },
437
407
  deleteOne: async (params) => {
438
408
  const { resource, id: path, meta } = params;
439
409
  const taruviMeta = meta;
440
410
  const bucket = getBucketName(resource, taruviMeta);
441
- const data = await new sdk.Storage(client, {}).from(bucket).delete([String(path)]).execute();
442
- return { data };
411
+ await new sdk.Storage(client).from(bucket).delete([String(path)]).execute();
412
+ return { data: { id: path } };
443
413
  },
444
414
  getApiUrl: () => baseApiUrl,
445
- // Not applicable for storage - return empty array
446
415
  getMany: async () => ({ data: [] }),
447
416
  createMany: async (params) => {
448
417
  const { resource, variables, meta } = params;
@@ -451,15 +420,16 @@ function storageDataProvider(client) {
451
420
  const { files, paths = [], metadatas = [] } = variables;
452
421
  const filePaths = files.map((file, i) => paths[i] || file.name);
453
422
  const fileMetadatas = files.map((_, i) => metadatas[i] || {});
454
- const data = await new sdk.Storage(client, {}).from(bucket).upload({ files, paths: filePaths, metadatas: fileMetadatas }).execute();
455
- return { data };
423
+ const response = await new sdk.Storage(client).from(bucket).upload({ files, paths: filePaths, metadatas: fileMetadatas }).execute();
424
+ const uploaded = response.data?.successful?.map((s) => s.object) ?? [];
425
+ return { data: uploaded.length > 0 ? uploaded[0] : response.data };
456
426
  },
457
427
  deleteMany: async (params) => {
458
428
  const { resource, ids, meta } = params;
459
429
  const taruviMeta = meta;
460
430
  const bucket = getBucketName(resource, taruviMeta);
461
- const data = await new sdk.Storage(client, {}).from(bucket).delete(ids.map(String)).execute();
462
- return { data: [data] };
431
+ await new sdk.Storage(client).from(bucket).delete(ids.map(String)).execute();
432
+ return { data: ids.map((id) => ({ id })) };
463
433
  },
464
434
  custom: async (params) => {
465
435
  const { url, method, payload, query } = params;
@@ -480,6 +450,9 @@ function storageDataProvider(client) {
480
450
  case "put":
481
451
  data = await client.httpClient.put(fullUrl, payload);
482
452
  break;
453
+ case "patch":
454
+ data = await client.httpClient.patch(fullUrl, payload);
455
+ break;
483
456
  case "delete":
484
457
  data = await client.httpClient.delete(fullUrl);
485
458
  break;
@@ -494,12 +467,12 @@ function storageDataProvider(client) {
494
467
  }
495
468
  function appDataProvider(client) {
496
469
  const config = client.getConfig();
497
- const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
470
+ const baseApiUrl = `${config.apiUrl}/api/apps/${config.appSlug}`;
498
471
  const functions = new sdk.Functions(client);
499
472
  const analytics = new sdk.Analytics(client);
500
473
  return {
501
474
  getList: async (params) => {
502
- const { resource } = params;
475
+ const { resource, meta } = params;
503
476
  if (resource === "roles") {
504
477
  const app = new sdk.App(client);
505
478
  const response = await app.roles().execute();
@@ -508,18 +481,40 @@ function appDataProvider(client) {
508
481
  total: response.total ?? (Array.isArray(response) ? response.length : response.data?.length ?? 0)
509
482
  };
510
483
  }
511
- throw new Error(`Unknown app resource: ${resource}. Supported resources: roles`);
484
+ if (resource === "secrets") {
485
+ const keys = meta?.keys;
486
+ if (!keys || keys.length === 0) {
487
+ throw new Error("secrets resource requires meta.keys array");
488
+ }
489
+ const secrets = new sdk.Secrets(client);
490
+ const response = await secrets.list(keys, {
491
+ app: meta?.app,
492
+ includeMetadata: meta?.includeMetadata
493
+ });
494
+ const raw = response.data || response;
495
+ const data = Array.isArray(raw) ? raw : Object.entries(raw).map(([key, value]) => ({ key, value }));
496
+ return { data, total: data.length };
497
+ }
498
+ throw new Error(`Unknown app resource: ${resource}. Supported resources: roles, secrets`);
512
499
  },
513
500
  getOne: async (params) => {
514
- const { resource } = params;
501
+ const { resource, id, meta } = params;
515
502
  if (resource === "settings") {
516
503
  const app = new sdk.App(client);
517
504
  const response = await app.settings().execute();
518
505
  return {
519
- data: response
506
+ data: response.data
520
507
  };
521
508
  }
522
- throw new Error(`Unknown app resource for getOne: ${resource}. Supported resources: settings`);
509
+ if (resource === "secrets") {
510
+ const secrets = new sdk.Secrets(client);
511
+ const response = await secrets.get(String(id), {
512
+ app: meta?.app,
513
+ tags: meta?.tags
514
+ }).execute();
515
+ return { data: response.data ?? response };
516
+ }
517
+ throw new Error(`Unknown app resource for getOne: ${resource}. Supported resources: settings, secrets`);
523
518
  },
524
519
  custom: async (params) => {
525
520
  const { url: slug, payload, meta } = params;
@@ -608,7 +603,7 @@ function buildUserListFilters(filters, sorters, pagination) {
608
603
  }
609
604
  function userDataProvider(client) {
610
605
  const config = client.getConfig();
611
- const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
606
+ const baseApiUrl = `${config.apiUrl}/api/apps/${config.appSlug}`;
612
607
  return {
613
608
  getList: async (params) => {
614
609
  const { resource, pagination, filters, sorters, meta } = params;
@@ -628,20 +623,41 @@ function userDataProvider(client) {
628
623
  }
629
624
  const user = new sdk.User(client);
630
625
  const response = await user.getUser(username);
631
- const roles = response.roles || [];
626
+ const roles = response.data?.roles || response.roles || [];
632
627
  return {
633
628
  data: roles,
634
629
  total: roles.length
635
630
  };
636
631
  }
637
- throw new Error(`Unknown user resource for getList: ${resource}. Supported: users, roles`);
632
+ if (resource === "apps") {
633
+ const username = meta?.username;
634
+ if (!username) {
635
+ throw new Error("apps resource requires meta.username");
636
+ }
637
+ const user = new sdk.User(client);
638
+ const response = await user.getUserApps(username);
639
+ const apps = response.data || response;
640
+ return {
641
+ data: apps,
642
+ total: Array.isArray(apps) ? apps.length : 0
643
+ };
644
+ }
645
+ throw new Error(`Unknown user resource for getList: ${resource}. Supported: users, roles, apps`);
638
646
  },
639
647
  getOne: async (params) => {
640
648
  const { resource, id } = params;
641
649
  if (resource === "users") {
642
650
  const user = new sdk.User(client);
651
+ if (String(id) === "me") {
652
+ const auth = new sdk.Auth(client);
653
+ const response2 = await auth.getCurrentUser();
654
+ const data = response2 ? response2.data ?? response2 : null;
655
+ return { data };
656
+ }
643
657
  const response = await user.getUser(String(id));
644
- return { data: response };
658
+ return {
659
+ data: response.data
660
+ };
645
661
  }
646
662
  throw new Error(`Unknown user resource for getOne: ${resource}. Supported: users`);
647
663
  },
@@ -653,7 +669,7 @@ function userDataProvider(client) {
653
669
  const userData = variables;
654
670
  const response = await user.createUser(userData);
655
671
  return {
656
- data: response
672
+ data: response.data
657
673
  };
658
674
  }
659
675
  throw new Error(`Unknown user resource for create: ${resource}. Supported resources: users`);
@@ -666,7 +682,7 @@ function userDataProvider(client) {
666
682
  const updateData = variables;
667
683
  const response = await user.updateUser(username, updateData);
668
684
  return {
669
- data: response
685
+ data: response.data
670
686
  };
671
687
  }
672
688
  throw new Error(`Unknown user resource for update: ${resource}. Supported resources: users`);
@@ -703,7 +719,7 @@ function userDataProvider(client) {
703
719
  }
704
720
  function functionsDataProvider(client) {
705
721
  const config = client.getConfig();
706
- const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
722
+ const baseApiUrl = `${config.apiUrl}/api/apps/${config.appSlug}`;
707
723
  const functions = new sdk.Functions(client);
708
724
  return {
709
725
  /**
@@ -777,7 +793,7 @@ function functionsDataProvider(client) {
777
793
  }
778
794
  function analyticsDataProvider(client) {
779
795
  const config = client.getConfig();
780
- const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
796
+ const baseApiUrl = `${config.apiUrl}/api/apps/${config.appSlug}`;
781
797
  const analytics = new sdk.Analytics(client);
782
798
  return {
783
799
  /**
@@ -872,7 +888,7 @@ function authProvider(client) {
872
888
  },
873
889
  logout: async (params = {}) => {
874
890
  const { callbackUrl } = params;
875
- auth.logout(callbackUrl);
891
+ await auth.logout(callbackUrl);
876
892
  return {
877
893
  success: true,
878
894
  redirectTo: callbackUrl || "/login"
@@ -942,14 +958,18 @@ function authProvider(client) {
942
958
  };
943
959
  },
944
960
  getIdentity: async () => {
945
- const user = await auth.getCurrentUser();
946
- if (!user) {
961
+ const response = await auth.getCurrentUser();
962
+ if (!response) {
947
963
  return null;
948
964
  }
949
- return user;
965
+ return response.data ?? response;
950
966
  },
951
967
  getPermissions: async () => {
952
- const user = await auth.getCurrentUser();
968
+ const response = await auth.getCurrentUser();
969
+ if (!response) {
970
+ return null;
971
+ }
972
+ const user = response.data ?? response;
953
973
  if (!user) {
954
974
  return null;
955
975
  }
@@ -969,7 +989,8 @@ function accessControlProvider(client, options) {
969
989
  const { batchDelayMs = 50 } = options ?? {};
970
990
  const permissionLoader = new DataLoader__default.default(
971
991
  async (checks) => {
972
- const user = await auth.getCurrentUser();
992
+ const response = await auth.getCurrentUser();
993
+ const user = response ? response.data ?? response : null;
973
994
  if (!user) {
974
995
  return checks.map(() => ({
975
996
  can: false,