mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-28 16:06:41 +01:00
@@ -61,15 +61,19 @@ function CodeEditor({ type, column, handleChange }: ICodeEditorProps) {
|
||||
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
}`;
|
||||
} else {
|
||||
dynamicValueFn = `const dynamicValueFn: DefaultValue = async ({row,ref,db,storage,auth,logging})=>{
|
||||
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
logging.log("dynamicValueFn started")
|
||||
|
||||
dynamicValueFn = `// Import any NPM package needed
|
||||
// import _ from "lodash";
|
||||
|
||||
const defaultValue: DefaultValue = async ({ row, ref, db, storage, auth, logging }) => {
|
||||
logging.log("dynamicValueFn started");
|
||||
|
||||
// Example: generate random hex color
|
||||
// const color = "#" + Math.floor(Math.random() * 16777215).toString(16);
|
||||
// return color;
|
||||
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
}`;
|
||||
};
|
||||
|
||||
export default defaultValue;
|
||||
`;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,67 +1,69 @@
|
||||
export const RUN_ACTION_TEMPLATE = `const action:Action = async ({row,ref,db,storage,auth,actionParams,user,logging}) => {
|
||||
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
logging.log("action started")
|
||||
|
||||
// Import any NPM package needed
|
||||
// const lodash = require('lodash');
|
||||
|
||||
// Example:
|
||||
/*
|
||||
const authToken = await rowy.secrets.get("service")
|
||||
try {
|
||||
const resp = await fetch('https://example.com/api/v1/users/'+ref.id,{
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': authToken
|
||||
},
|
||||
body: JSON.stringify(row)
|
||||
})
|
||||
return {
|
||||
success: true,
|
||||
message: 'User updated successfully on example service',
|
||||
status: "upto date"
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'User update failed on example service',
|
||||
}
|
||||
}
|
||||
*/
|
||||
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
}`;
|
||||
export const RUN_ACTION_TEMPLATE = `// Import any NPM package needed
|
||||
// import _ from "lodash";
|
||||
|
||||
const action: Action = async ({ row, ref, db, storage, auth, actionParams, user, logging }) => {
|
||||
logging.log("action started");
|
||||
|
||||
export const UNDO_ACTION_TEMPLATE = `const action : Action = async ({row,ref,db,storage,auth,actionParams,user,logging}) => {
|
||||
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
logging.log("action started")
|
||||
|
||||
// Import any NPM package needed
|
||||
// const lodash = require('lodash');
|
||||
|
||||
// Example:
|
||||
/*
|
||||
const authToken = await rowy.secrets.get("service")
|
||||
// Example:
|
||||
const authToken = await rowy.secrets.get("service");
|
||||
try {
|
||||
const resp = await fetch('https://example.com/api/v1/users/'+ref.id,{
|
||||
method: 'DELETE',
|
||||
const resp = await fetch("https://example.com/api/v1/users/" + ref.id, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': authToken
|
||||
"Content-Type": "application/json",
|
||||
Authorization: authToken,
|
||||
},
|
||||
body: JSON.stringify(row)
|
||||
})
|
||||
body: JSON.stringify(row),
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
message: 'User deleted successfully on example service',
|
||||
status: null
|
||||
}
|
||||
message: "User updated successfully on example service",
|
||||
status: "upto date",
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'User delete failed on example service',
|
||||
}
|
||||
message: "User update failed on example service",
|
||||
};
|
||||
}
|
||||
*/
|
||||
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
}`;
|
||||
};
|
||||
|
||||
export default action;
|
||||
`;
|
||||
|
||||
export const UNDO_ACTION_TEMPLATE = `// Import any NPM package needed
|
||||
// import _ from "lodash";
|
||||
|
||||
const action: Action = async ({ row, ref, db, storage, auth, actionParams, user, logging }) => {
|
||||
logging.log("action started");
|
||||
|
||||
/*
|
||||
// Example:
|
||||
const authToken = await rowy.secrets.get("service");
|
||||
try {
|
||||
const resp = await fetch("https://example.com/api/v1/users/" + ref.id, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: authToken,
|
||||
},
|
||||
body: JSON.stringify(row),
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
message: "User deleted successfully on example service",
|
||||
status: null,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
message: "User delete failed on example service",
|
||||
};
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
export default action;
|
||||
`;
|
||||
|
||||
@@ -11,16 +11,19 @@ export const replacer = (data: any) => (m: string, key: string) => {
|
||||
return get(data, objKey, defaultValue);
|
||||
};
|
||||
|
||||
export const baseFunction = `const connectorFn: Connector = async ({query, row, user, logging}) => {
|
||||
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
logging.log("connectorFn started")
|
||||
|
||||
// Import any NPM package needed
|
||||
// const lodash = require('lodash');
|
||||
|
||||
return [];
|
||||
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
};`;
|
||||
export const baseFunction = `// Import any NPM package needed
|
||||
// import _ from "lodash";
|
||||
|
||||
const connector: Connector = async ({ query, row, user, logging }) => {
|
||||
logging.log("connector started");
|
||||
// return [
|
||||
// { id: "a", name: "Apple" },
|
||||
// { id: "b", name: "Banana" },
|
||||
// ];
|
||||
};
|
||||
|
||||
export default connector;
|
||||
`;
|
||||
|
||||
export const getLabel = (config: any, row: TableRow) => {
|
||||
if (!config.labelFormatter) {
|
||||
|
||||
@@ -75,18 +75,19 @@ export default function Settings({
|
||||
${config.script.replace(/utilFns.getSecret/g, "rowy.secrets.get")}
|
||||
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
}`
|
||||
: `const derivative:Derivative = async ({row,ref,db,storage,auth,logging})=>{
|
||||
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
logging.log("derivative started")
|
||||
|
||||
// Import any NPM package needed
|
||||
// const lodash = require('lodash');
|
||||
|
||||
: `// Import any NPM package needed
|
||||
// import _ from "lodash";
|
||||
|
||||
const derivative: Derivative = async ({ row, ref, db, storage, auth, logging }) => {
|
||||
logging.log("derivative started");
|
||||
|
||||
// Example:
|
||||
// const sum = row.a + row.b;
|
||||
// return sum;
|
||||
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
}`;
|
||||
};
|
||||
|
||||
export default derivative;
|
||||
`;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user