@taruvi/refine-providers 1.1.7 → 1.1.8
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 +98 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -22
- package/dist/index.d.ts +35 -22
- package/dist/index.js +99 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -482,83 +482,11 @@ function storageDataProvider(client) {
|
|
|
482
482
|
updateMany: void 0
|
|
483
483
|
};
|
|
484
484
|
}
|
|
485
|
-
function functionsDataProvider(client) {
|
|
486
|
-
const config = client.getConfig();
|
|
487
|
-
const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
|
|
488
|
-
const functions = new sdk.Functions(client);
|
|
489
|
-
return {
|
|
490
|
-
/**
|
|
491
|
-
* Execute an edge function.
|
|
492
|
-
*
|
|
493
|
-
* @param resource - The function slug to execute
|
|
494
|
-
* @param variables - Parameters to pass to the function
|
|
495
|
-
* @param meta.async - Whether to execute asynchronously (default: false)
|
|
496
|
-
*/
|
|
497
|
-
create: async ({
|
|
498
|
-
resource,
|
|
499
|
-
variables,
|
|
500
|
-
meta
|
|
501
|
-
}) => {
|
|
502
|
-
const functionMeta = meta;
|
|
503
|
-
const response = await functions.execute(resource, {
|
|
504
|
-
async: functionMeta?.async ?? false,
|
|
505
|
-
params: variables
|
|
506
|
-
});
|
|
507
|
-
return { data: response.data };
|
|
508
|
-
},
|
|
509
|
-
getApiUrl: () => baseApiUrl,
|
|
510
|
-
// Edge functions don't support custom method - use create() instead
|
|
511
|
-
custom: async () => {
|
|
512
|
-
throw new Error(
|
|
513
|
-
"custom is not supported for edge functions. Use useCreate to execute functions."
|
|
514
|
-
);
|
|
515
|
-
},
|
|
516
|
-
// Edge functions don't support other CRUD operations
|
|
517
|
-
getList: async () => {
|
|
518
|
-
throw new Error(
|
|
519
|
-
"getList is not supported for edge functions. Use useCreate to execute functions."
|
|
520
|
-
);
|
|
521
|
-
},
|
|
522
|
-
getOne: async () => {
|
|
523
|
-
throw new Error(
|
|
524
|
-
"getOne is not supported for edge functions. Use useCreate to execute functions."
|
|
525
|
-
);
|
|
526
|
-
},
|
|
527
|
-
getMany: async () => {
|
|
528
|
-
throw new Error(
|
|
529
|
-
"getMany is not supported for edge functions. Use useCreate to execute functions."
|
|
530
|
-
);
|
|
531
|
-
},
|
|
532
|
-
createMany: async () => {
|
|
533
|
-
throw new Error(
|
|
534
|
-
"createMany is not supported for edge functions. Use useCreate to execute functions."
|
|
535
|
-
);
|
|
536
|
-
},
|
|
537
|
-
update: async () => {
|
|
538
|
-
throw new Error(
|
|
539
|
-
"update is not supported for edge functions. Use useCreate to execute functions."
|
|
540
|
-
);
|
|
541
|
-
},
|
|
542
|
-
updateMany: async () => {
|
|
543
|
-
throw new Error(
|
|
544
|
-
"updateMany is not supported for edge functions. Use useCreate to execute functions."
|
|
545
|
-
);
|
|
546
|
-
},
|
|
547
|
-
deleteOne: async () => {
|
|
548
|
-
throw new Error(
|
|
549
|
-
"deleteOne is not supported for edge functions. Use useCreate to execute functions."
|
|
550
|
-
);
|
|
551
|
-
},
|
|
552
|
-
deleteMany: async () => {
|
|
553
|
-
throw new Error(
|
|
554
|
-
"deleteMany is not supported for edge functions. Use useCreate to execute functions."
|
|
555
|
-
);
|
|
556
|
-
}
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
485
|
function appDataProvider(client) {
|
|
560
486
|
const config = client.getConfig();
|
|
561
487
|
const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
|
|
488
|
+
const functions = new sdk.Functions(client);
|
|
489
|
+
const analytics = new sdk.Analytics(client);
|
|
562
490
|
return {
|
|
563
491
|
getList: async (params) => {
|
|
564
492
|
const { resource } = params;
|
|
@@ -572,7 +500,6 @@ function appDataProvider(client) {
|
|
|
572
500
|
}
|
|
573
501
|
throw new Error(`Unknown app resource: ${resource}. Supported resources: roles`);
|
|
574
502
|
},
|
|
575
|
-
getApiUrl: () => baseApiUrl,
|
|
576
503
|
getOne: async (params) => {
|
|
577
504
|
const { resource } = params;
|
|
578
505
|
if (resource === "settings") {
|
|
@@ -584,12 +511,32 @@ function appDataProvider(client) {
|
|
|
584
511
|
}
|
|
585
512
|
throw new Error(`Unknown app resource for getOne: ${resource}. Supported resources: settings`);
|
|
586
513
|
},
|
|
587
|
-
|
|
514
|
+
custom: async (params) => {
|
|
515
|
+
const { url: slug, payload, meta } = params;
|
|
516
|
+
const customMeta = meta;
|
|
517
|
+
if (customMeta?.kind === "function") {
|
|
518
|
+
const response = await functions.execute(slug, {
|
|
519
|
+
async: customMeta.async ?? false,
|
|
520
|
+
params: payload ?? {}
|
|
521
|
+
});
|
|
522
|
+
return { data: response.data };
|
|
523
|
+
}
|
|
524
|
+
if (customMeta?.kind === "analytics") {
|
|
525
|
+
const response = await analytics.execute(slug, {
|
|
526
|
+
params: payload ?? {}
|
|
527
|
+
});
|
|
528
|
+
return { data: response.data };
|
|
529
|
+
}
|
|
530
|
+
throw new Error(
|
|
531
|
+
'Specify meta.kind as "function" or "analytics" for custom operations on the app provider.'
|
|
532
|
+
);
|
|
533
|
+
},
|
|
534
|
+
getApiUrl: () => baseApiUrl,
|
|
588
535
|
getMany: async () => {
|
|
589
536
|
throw new Error("getMany is not supported for app resources");
|
|
590
537
|
},
|
|
591
538
|
create: async () => {
|
|
592
|
-
throw new Error("create is not supported for app resources");
|
|
539
|
+
throw new Error("create is not supported for app resources. Use useCustom with meta.kind");
|
|
593
540
|
},
|
|
594
541
|
createMany: async () => {
|
|
595
542
|
throw new Error("createMany is not supported for app resources");
|
|
@@ -605,9 +552,6 @@ function appDataProvider(client) {
|
|
|
605
552
|
},
|
|
606
553
|
deleteMany: async () => {
|
|
607
554
|
throw new Error("deleteMany is not supported for app resources");
|
|
608
|
-
},
|
|
609
|
-
custom: async () => {
|
|
610
|
-
throw new Error("custom is not supported for app resources");
|
|
611
555
|
}
|
|
612
556
|
};
|
|
613
557
|
}
|
|
@@ -747,6 +691,80 @@ function userDataProvider(client) {
|
|
|
747
691
|
}
|
|
748
692
|
};
|
|
749
693
|
}
|
|
694
|
+
function functionsDataProvider(client) {
|
|
695
|
+
const config = client.getConfig();
|
|
696
|
+
const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
|
|
697
|
+
const functions = new sdk.Functions(client);
|
|
698
|
+
return {
|
|
699
|
+
/**
|
|
700
|
+
* Execute an edge function.
|
|
701
|
+
*
|
|
702
|
+
* @param resource - The function slug to execute
|
|
703
|
+
* @param variables - Parameters to pass to the function
|
|
704
|
+
* @param meta.async - Whether to execute asynchronously (default: false)
|
|
705
|
+
*/
|
|
706
|
+
create: async ({
|
|
707
|
+
resource,
|
|
708
|
+
variables,
|
|
709
|
+
meta
|
|
710
|
+
}) => {
|
|
711
|
+
const functionMeta = meta;
|
|
712
|
+
const response = await functions.execute(resource, {
|
|
713
|
+
async: functionMeta?.async ?? false,
|
|
714
|
+
params: variables
|
|
715
|
+
});
|
|
716
|
+
return { data: response.data };
|
|
717
|
+
},
|
|
718
|
+
getApiUrl: () => baseApiUrl,
|
|
719
|
+
// Edge functions don't support custom method - use create() instead
|
|
720
|
+
custom: async () => {
|
|
721
|
+
throw new Error(
|
|
722
|
+
"custom is not supported for edge functions. Use useCreate to execute functions."
|
|
723
|
+
);
|
|
724
|
+
},
|
|
725
|
+
// Edge functions don't support other CRUD operations
|
|
726
|
+
getList: async () => {
|
|
727
|
+
throw new Error(
|
|
728
|
+
"getList is not supported for edge functions. Use useCreate to execute functions."
|
|
729
|
+
);
|
|
730
|
+
},
|
|
731
|
+
getOne: async () => {
|
|
732
|
+
throw new Error(
|
|
733
|
+
"getOne is not supported for edge functions. Use useCreate to execute functions."
|
|
734
|
+
);
|
|
735
|
+
},
|
|
736
|
+
getMany: async () => {
|
|
737
|
+
throw new Error(
|
|
738
|
+
"getMany is not supported for edge functions. Use useCreate to execute functions."
|
|
739
|
+
);
|
|
740
|
+
},
|
|
741
|
+
createMany: async () => {
|
|
742
|
+
throw new Error(
|
|
743
|
+
"createMany is not supported for edge functions. Use useCreate to execute functions."
|
|
744
|
+
);
|
|
745
|
+
},
|
|
746
|
+
update: async () => {
|
|
747
|
+
throw new Error(
|
|
748
|
+
"update is not supported for edge functions. Use useCreate to execute functions."
|
|
749
|
+
);
|
|
750
|
+
},
|
|
751
|
+
updateMany: async () => {
|
|
752
|
+
throw new Error(
|
|
753
|
+
"updateMany is not supported for edge functions. Use useCreate to execute functions."
|
|
754
|
+
);
|
|
755
|
+
},
|
|
756
|
+
deleteOne: async () => {
|
|
757
|
+
throw new Error(
|
|
758
|
+
"deleteOne is not supported for edge functions. Use useCreate to execute functions."
|
|
759
|
+
);
|
|
760
|
+
},
|
|
761
|
+
deleteMany: async () => {
|
|
762
|
+
throw new Error(
|
|
763
|
+
"deleteMany is not supported for edge functions. Use useCreate to execute functions."
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
}
|
|
750
768
|
function analyticsDataProvider(client) {
|
|
751
769
|
const config = client.getConfig();
|
|
752
770
|
const baseApiUrl = `${config.baseUrl}/api/apps/${config.appSlug}`;
|