new configuration for dataconnect request in internal api harness
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
import apiClient from './client';
|
import apiClient from './client';
|
||||||
import { auth } from '../firebase';
|
import { auth, dataConnect } from '../firebase';
|
||||||
import { signOut } from 'firebase/auth';
|
import { signOut } from 'firebase/auth';
|
||||||
|
|
||||||
|
import * as dcSdk from '@dataconnect/generated'; // listEvents, createEvent, etc.
|
||||||
|
|
||||||
// --- Auth Module ---
|
// --- Auth Module ---
|
||||||
const authModule = {
|
const authModule = {
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +98,7 @@ const coreIntegrationsModule = {
|
|||||||
|
|
||||||
// --- Entities Module ---
|
// --- Entities Module ---
|
||||||
// Based on docs/07-reference-base44-api-export.md
|
// Based on docs/07-reference-base44-api-export.md
|
||||||
const entityNames = [
|
/*const entityNames = [
|
||||||
"User", "Event", "Staff", "Vendor", "VendorRate", "Invoice", "Business",
|
"User", "Event", "Staff", "Vendor", "VendorRate", "Invoice", "Business",
|
||||||
"Certification", "Team", "Conversation", "Message", "ActivityLog",
|
"Certification", "Team", "Conversation", "Message", "ActivityLog",
|
||||||
"Enterprise", "Sector", "Partner", "Order", "Shift"
|
"Enterprise", "Sector", "Partner", "Order", "Shift"
|
||||||
@@ -134,6 +136,83 @@ entityNames.forEach(entityName => {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
});*/
|
||||||
|
|
||||||
|
const dataconnectEntityConfig = {
|
||||||
|
Event: {
|
||||||
|
list: 'listEvents',
|
||||||
|
create: 'createEvent',
|
||||||
|
// get: 'getEvent',
|
||||||
|
// update: 'updateEvent',
|
||||||
|
// delete: 'deleteEvent',
|
||||||
|
// filter: 'filterEvents',
|
||||||
|
},
|
||||||
|
|
||||||
|
// Staff: {
|
||||||
|
// list: 'listStaff',
|
||||||
|
// create: 'createStaff',
|
||||||
|
// ...
|
||||||
|
// },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper for methods not implemented
|
||||||
|
const notImplemented = (entityName, method) => async () => {
|
||||||
|
throw new Error(`${entityName}.${method} is not implemented yet for Data Connect`);
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- Entities Module ( Data Connect, without REST Base44) ---
|
||||||
|
const entitiesModule = {};
|
||||||
|
|
||||||
|
Object.entries(dataconnectEntityConfig).forEach(([entityName, ops]) => {
|
||||||
|
entitiesModule[entityName] = {
|
||||||
|
|
||||||
|
get: notImplemented(entityName, 'get'),
|
||||||
|
update: notImplemented(entityName, 'update'),
|
||||||
|
delete: notImplemented(entityName, 'delete'),
|
||||||
|
filter: notImplemented(entityName, 'filter'),
|
||||||
|
list: notImplemented(entityName, 'list'),
|
||||||
|
create: notImplemented(entityName, 'create'),
|
||||||
|
|
||||||
|
// list
|
||||||
|
...(ops.list && {
|
||||||
|
list: async (params) => {
|
||||||
|
const fn = dcSdk[ops.list];
|
||||||
|
if (typeof fn !== 'function') {
|
||||||
|
throw new Error(
|
||||||
|
`Data Connect operation "${ops.list}" not found for entity "${entityName}".`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fn(dataConnect);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
// create
|
||||||
|
...(ops.create && {
|
||||||
|
create: async (params) => {
|
||||||
|
const fn = dcSdk[ops.create];
|
||||||
|
if (typeof fn !== 'function') {
|
||||||
|
throw new Error(
|
||||||
|
`Data Connect operation "${ops.create}" not found for entity "${entityName}".`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = params ?? {};
|
||||||
|
if (!data) {
|
||||||
|
throw new Error(
|
||||||
|
`${entityName}.create expects a payload like { data: { ...fields } }`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fn(dataConnect, data);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
// ...(ops.get && { get: async (params) => { ... } }),
|
||||||
|
// ...(ops.update && { update: async (params) => { ... } }),
|
||||||
|
// ...(ops.delete && { delete: async (params) => { ... } }),
|
||||||
|
// ...(ops.filter && { filter: async (params) => { ... } }),
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// Import the functions you need from the SDKs you need
|
// Import the functions you need from the SDKs you need
|
||||||
import { initializeApp } from "firebase/app";
|
import { initializeApp } from "firebase/app";
|
||||||
import { getAuth } from "firebase/auth";
|
import { getAuth } from "firebase/auth";
|
||||||
|
import { getDataConnect } from 'firebase/data-connect';
|
||||||
|
import { connectorConfig } from '@dataconnect/generated';
|
||||||
|
|
||||||
// Your web app's Firebase configuration
|
// Your web app's Firebase configuration
|
||||||
const firebaseConfig = {
|
const firebaseConfig = {
|
||||||
@@ -14,4 +16,5 @@ const firebaseConfig = {
|
|||||||
|
|
||||||
// Initialize Firebase
|
// Initialize Firebase
|
||||||
const app = initializeApp(firebaseConfig);
|
const app = initializeApp(firebaseConfig);
|
||||||
|
export const dataConnect = getDataConnect(app, connectorConfig);
|
||||||
export const auth = getAuth(app);
|
export const auth = getAuth(app);
|
||||||
Reference in New Issue
Block a user