mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
multiservice rowy run
This commit is contained in:
@@ -174,7 +174,7 @@ export default function Step1RowyRun({
|
||||
}
|
||||
|
||||
export const checkRowyRun = async (
|
||||
rowyRunUrl: string,
|
||||
serviceUrl: string,
|
||||
signal?: AbortSignal
|
||||
) => {
|
||||
const result = {
|
||||
@@ -184,7 +184,7 @@ export const checkRowyRun = async (
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await rowyRun({ rowyRunUrl, route: runRoutes.version, signal });
|
||||
const res = await rowyRun({ serviceUrl, route: runRoutes.version, signal });
|
||||
if (!res.version) return result;
|
||||
|
||||
result.isValidRowyRunUrl = true;
|
||||
|
||||
@@ -150,12 +150,12 @@ export default function Step2ServiceAccount({
|
||||
}
|
||||
|
||||
export const checkServiceAccount = async (
|
||||
rowyRunUrl: string,
|
||||
serviceUrl: string,
|
||||
signal?: AbortSignal
|
||||
) => {
|
||||
try {
|
||||
const res = await rowyRun({
|
||||
rowyRunUrl,
|
||||
serviceUrl,
|
||||
route: runRoutes.serviceAccountAccess,
|
||||
signal,
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ export default function Step3ProjectOwner({
|
||||
|
||||
const [email, setEmail] = useState("");
|
||||
useEffect(() => {
|
||||
rowyRun({ rowyRunUrl, route: runRoutes.projectOwner })
|
||||
rowyRun({ serviceUrl: rowyRunUrl, route: runRoutes.projectOwner })
|
||||
.then((data) => setEmail(data.email))
|
||||
.catch((e: any) => {
|
||||
console.error(e);
|
||||
@@ -44,7 +44,7 @@ export default function Step3ProjectOwner({
|
||||
const authToken = await getAuthToken();
|
||||
const res = await rowyRun({
|
||||
route: runRoutes.setOwnerRoles,
|
||||
rowyRunUrl,
|
||||
serviceUrl: rowyRunUrl,
|
||||
authToken,
|
||||
});
|
||||
|
||||
@@ -186,7 +186,7 @@ export const checkProjectOwner = async (
|
||||
|
||||
try {
|
||||
const res = await rowyRun({
|
||||
rowyRunUrl,
|
||||
serviceUrl: rowyRunUrl,
|
||||
route: runRoutes.projectOwner,
|
||||
signal,
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ export default function Step4Rules({
|
||||
getAuthToken(true)
|
||||
.then((authToken) =>
|
||||
rowyRun({
|
||||
rowyRunUrl,
|
||||
serviceUrl: rowyRunUrl,
|
||||
route: runRoutes.firestoreRules,
|
||||
authToken,
|
||||
})
|
||||
@@ -99,7 +99,7 @@ export default function Step4Rules({
|
||||
if (!authToken) throw new Error("Failed to generate auth token");
|
||||
|
||||
const res = await rowyRun({
|
||||
rowyRunUrl,
|
||||
serviceUrl: rowyRunUrl,
|
||||
route: runRoutes.setFirestoreRules,
|
||||
authToken,
|
||||
body: { ruleset: newRules },
|
||||
@@ -275,7 +275,7 @@ export const checkRules = async (
|
||||
|
||||
try {
|
||||
const res = await rowyRun({
|
||||
rowyRunUrl,
|
||||
serviceUrl: rowyRunUrl,
|
||||
route: runRoutes.firestoreRules,
|
||||
authToken,
|
||||
signal,
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function Step5Migrate({
|
||||
|
||||
const res = await rowyRun({
|
||||
route: runRoutes.migrateFT2Rowy,
|
||||
rowyRunUrl,
|
||||
serviceUrl: rowyRunUrl,
|
||||
authToken,
|
||||
});
|
||||
if (!res.success) throw new Error(res.message);
|
||||
@@ -100,7 +100,7 @@ export const checkMigrate = async (
|
||||
|
||||
try {
|
||||
const res = await rowyRun({
|
||||
rowyRunUrl,
|
||||
serviceUrl: rowyRunUrl,
|
||||
route: runRoutes.checkFT2Rowy,
|
||||
authToken,
|
||||
signal,
|
||||
|
||||
@@ -34,6 +34,10 @@ export type Table = {
|
||||
auditFieldUpdatedBy?: string;
|
||||
};
|
||||
|
||||
interface IRowyRun
|
||||
extends Omit<IRowyRunRequestProps, "serviceUrl" | "authToken"> {
|
||||
service?: "hooks" | "builder";
|
||||
}
|
||||
export interface IProjectContext {
|
||||
settings: {
|
||||
rowyRunUrl?: string;
|
||||
@@ -89,9 +93,7 @@ export interface IProjectContext {
|
||||
// A ref ot the import wizard. Prevents unnecessary re-renders
|
||||
importWizardRef: React.MutableRefObject<ImportWizardRef | undefined>;
|
||||
|
||||
rowyRun: <T = any>(
|
||||
args: Omit<IRowyRunRequestProps, "rowyRunUrl" | "authToken">
|
||||
) => Promise<T>;
|
||||
rowyRun: <T = any>(args: IRowyRun) => Promise<T>;
|
||||
}
|
||||
|
||||
const ProjectContext = React.createContext<Partial<IProjectContext>>({});
|
||||
@@ -272,15 +274,20 @@ export const ProjectContextProvider: React.FC = ({ children }) => {
|
||||
};
|
||||
// rowyRun access
|
||||
const _rowyRun: IProjectContext["rowyRun"] = async (args) => {
|
||||
const { service, ...rest } = args;
|
||||
const authToken = await getAuthToken();
|
||||
if (settings.doc.rowyRunUrl)
|
||||
const serviceUrl = service
|
||||
? settings.doc.services[service]
|
||||
: settings.doc.rowyRunUrl;
|
||||
|
||||
if (serviceUrl) {
|
||||
return rowyRun({
|
||||
rowyRunUrl: settings.doc.rowyRunUrl,
|
||||
serviceUrl,
|
||||
authToken,
|
||||
...args,
|
||||
...rest,
|
||||
});
|
||||
else {
|
||||
enqueueSnackbar(`Rowy Run is not set up`, {
|
||||
} else {
|
||||
enqueueSnackbar(`Rowy Run${service ? ` ${service}` : ""} is not set up`, {
|
||||
variant: "error",
|
||||
action: (
|
||||
<Button
|
||||
|
||||
@@ -289,7 +289,13 @@ const useTableData = () => {
|
||||
: [];
|
||||
|
||||
const { path } = tableState;
|
||||
const newId = generateSmallerId(rows[0]?.id ?? "zzzzzzzzzzzzzzzzzzzz");
|
||||
let rowIndex = 0;
|
||||
let seedId = rows[rowIndex]?.id ?? "zzzzzzzzzzzzzzzzzzzz";
|
||||
while (seedId.split("").every((char) => char === "0")) {
|
||||
rowIndex += 1;
|
||||
seedId = rows[rowIndex].id;
|
||||
}
|
||||
const newId = generateSmallerId(seedId);
|
||||
|
||||
if (missingRequiredFields.length === 0) {
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { RunRoute } from "@src/constants/runRoutes";
|
||||
|
||||
export interface IRowyRunRequestProps {
|
||||
rowyRunUrl: string;
|
||||
serviceUrl: string;
|
||||
authToken?: string;
|
||||
route: RunRoute;
|
||||
body?: any;
|
||||
@@ -12,7 +12,7 @@ export interface IRowyRunRequestProps {
|
||||
}
|
||||
|
||||
export const rowyRun = async ({
|
||||
rowyRunUrl,
|
||||
serviceUrl,
|
||||
authToken,
|
||||
route,
|
||||
body,
|
||||
@@ -22,7 +22,7 @@ export const rowyRun = async ({
|
||||
signal,
|
||||
}: IRowyRunRequestProps) => {
|
||||
const { method, path } = route;
|
||||
let url = (localhost ? "http://localhost:8080" : rowyRunUrl) + path;
|
||||
let url = (localhost ? "http://localhost:8080" : serviceUrl) + path;
|
||||
if (params && params.length > 0) url = url + "/" + params.join("/");
|
||||
const response = await fetch(url, {
|
||||
method: method,
|
||||
|
||||
Reference in New Issue
Block a user