From 35f0bc03fdc703dfcfdae9dad30cdad70030462b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:57:45 -0500 Subject: [PATCH] new configuration for dataconnect request in internal api harness --- internal-api-harness/src/api/krowSDK.js | 83 ++++++++++++++++++++++++- internal-api-harness/src/firebase.js | 3 + 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/internal-api-harness/src/api/krowSDK.js b/internal-api-harness/src/api/krowSDK.js index 7f72449e..4ab64798 100644 --- a/internal-api-harness/src/api/krowSDK.js +++ b/internal-api-harness/src/api/krowSDK.js @@ -1,7 +1,9 @@ import apiClient from './client'; -import { auth } from '../firebase'; +import { auth, dataConnect } from '../firebase'; import { signOut } from 'firebase/auth'; +import * as dcSdk from '@dataconnect/generated'; // listEvents, createEvent, etc. + // --- Auth Module --- const authModule = { /** @@ -96,7 +98,7 @@ const coreIntegrationsModule = { // --- Entities Module --- // Based on docs/07-reference-base44-api-export.md -const entityNames = [ +/*const entityNames = [ "User", "Event", "Staff", "Vendor", "VendorRate", "Invoice", "Business", "Certification", "Team", "Conversation", "Message", "ActivityLog", "Enterprise", "Sector", "Partner", "Order", "Shift" @@ -134,6 +136,83 @@ entityNames.forEach(entityName => { 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) => { ... } }), + }; }); diff --git a/internal-api-harness/src/firebase.js b/internal-api-harness/src/firebase.js index fc4f44e1..3455c48f 100644 --- a/internal-api-harness/src/firebase.js +++ b/internal-api-harness/src/firebase.js @@ -1,6 +1,8 @@ // Import the functions you need from the SDKs you need import { initializeApp } from "firebase/app"; import { getAuth } from "firebase/auth"; +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig } from '@dataconnect/generated'; // Your web app's Firebase configuration const firebaseConfig = { @@ -14,4 +16,5 @@ const firebaseConfig = { // Initialize Firebase const app = initializeApp(firebaseConfig); +export const dataConnect = getDataConnect(app, connectorConfig); export const auth = getAuth(app); \ No newline at end of file