Fixed minor bugs in app creator bodies and action names + added auto addition of headers

This commit is contained in:
frikky
2022-07-14 01:16:27 +02:00
parent 76bfff84da
commit 16e7bfcb58
11 changed files with 340 additions and 269 deletions
+4
View File
@@ -2109,6 +2109,9 @@ class AppBase:
error = True error = True
error_msg = e error_msg = e
if "fmt" in error_msg and "liquid_date" in error_msg:
return template
self.logger.info("Done in liquid") self.logger.info("Done in liquid")
if error == True: if error == True:
self.action_result["status"] = "FAILURE" self.action_result["status"] = "FAILURE"
@@ -2117,6 +2120,7 @@ class AppBase:
"reason": f"Failed to parse LiquidPy: {error_msg}", "reason": f"Failed to parse LiquidPy: {error_msg}",
"input": template, "input": template,
} }
try: try:
self.action_result["result"] = json.dumps(data) self.action_result["result"] = json.dumps(data)
except Exception as e: except Exception as e:
+1 -1
View File
@@ -2,7 +2,7 @@
### DEFAULT ### DEFAULT
NAME=shuffle-app_sdk NAME=shuffle-app_sdk
VERSION=1.0.4 VERSION=1.0.5
docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force
docker build . -f Dockerfile -t frikky/shuffle:app_sdk -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION -t ghcr.io/frikky/$NAME:nightly docker build . -f Dockerfile -t frikky/shuffle:app_sdk -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION -t ghcr.io/frikky/$NAME:nightly
+1 -1
View File
@@ -1,7 +1,7 @@
urllib3==1.26.5 urllib3==1.26.5
requests==2.25.1 requests==2.25.1
MarkupSafe==2.0.1 MarkupSafe==2.0.1
liquidpy==0.7.3 liquidpy==0.7.5
flask[async]==2.0.2 flask[async]==2.0.2
waitress==2.1.0 waitress==2.1.0
#flask==1.1.2 #flask==1.1.2
+1 -1
View File
@@ -559,7 +559,7 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
} }
//log.Printf("BASE LENGTH: %d", len(workflowExecution.Results)) //log.Printf("BASE LENGTH: %d", len(workflowExecution.Results))
workflowExecution, dbSave, err := shuffle.ParsedExecutionResult(ctx, *workflowExecution, actionResult, false) workflowExecution, dbSave, err := shuffle.ParsedExecutionResult(ctx, *workflowExecution, actionResult, false, 4)
if err != nil { if err != nil {
b, suberr := json.Marshal(actionResult) b, suberr := json.Marshal(actionResult)
if suberr != nil { if suberr != nil {
@@ -1599,16 +1599,11 @@ const Framework = (props) => {
</div> </div>
<div style={{marginTop: 10}}> <div style={{marginTop: 10}}>
{selectionOpen ? {selectionOpen ?
isCloud && defaultSearch !== undefined && defaultSearch.length > 0 ?
<WorkflowSearch <WorkflowSearch
defaultSearch={defaultSearch} defaultSearch={defaultSearch}
newSelectedApp={newSelectedApp} newSelectedApp={newSelectedApp}
setNewSelectedApp={setNewSelectedApp} setNewSelectedApp={setNewSelectedApp}
/> />
:
<div>
Coming soon. <a style={{ textDecoration: "none", color: "#f85a3e" }} href="https://shuffler.io/register" target="_blank">Register for Shuffle cloud</a> to try an early version now.
</div>
: null} : null}
</div> </div>
</Paper> </Paper>
+82 -67
View File
@@ -5,6 +5,7 @@ import { useTheme } from '@material-ui/core/styles';
import {Link} from 'react-router-dom'; import {Link} from 'react-router-dom';
import { Search as SearchIcon, CloudQueue as CloudQueueIcon, Code as CodeIcon } from '@material-ui/icons'; import { Search as SearchIcon, CloudQueue as CloudQueueIcon, Code as CodeIcon } from '@material-ui/icons';
import aa from 'search-insights'
import algoliasearch from 'algoliasearch/lite'; import algoliasearch from 'algoliasearch/lite';
import { InstantSearch, Configure, connectSearchBox, connectHits } from 'react-instantsearch-dom'; import { InstantSearch, Configure, connectSearchBox, connectHits } from 'react-instantsearch-dom';
@@ -13,13 +14,20 @@ import {
Grid, Grid,
Paper, Paper,
TextField, TextField,
Avatar,
ButtonBase, ButtonBase,
InputAdornment, InputAdornment,
Typography, Typography,
Button, Button,
Tooltip Tooltip,
List,
ListItem,
ListItemAvatar,
ListItemText,
} from '@material-ui/core'; } from '@material-ui/core';
import {Close as CloseIcon, Folder as FolderIcon, Polymer as PolymerIcon, LibraryBooks as LibraryBooksIcon} from '@material-ui/icons'
const searchClient = algoliasearch("JNSS5CFDZZ", "db08e40265e2941b9a7d8f644b6e5240") const searchClient = algoliasearch("JNSS5CFDZZ", "db08e40265e2941b9a7d8f644b6e5240")
const DocsGrid = props => { const DocsGrid = props => {
const { maxRows, showName, showSuggestion, isMobile, globalUrl, parsedXs } = props const { maxRows, showName, showSuggestion, isMobile, globalUrl, parsedXs } = props
@@ -139,92 +147,99 @@ const DocsGrid = props => {
//} //}
return ( return (
<Grid container spacing={2}> <List>
{hits.map((data, index) => { {hits.map((data, index) => {
workflowDelay += 50 workflowDelay += 50
const paperStyle = { const innerlistitemStyle = {
backgroundColor: index === mouseHoverIndex ? "rgba(255,255,255,0.8)" : theme.palette.inputColor, width: "100%",
color: index === mouseHoverIndex ? theme.palette.inputColor : "rgba(255,255,255,0.8)", overflowX: "hidden",
border: `1px solid ${innerColor}`, overflowY: "hidden",
padding: 15, borderBottom: "1px solid rgba(255,255,255,0.4)",
backgroundColor: mouseHoverIndex === index ? "#1f2023" : "inherit",
cursor: "pointer", cursor: "pointer",
position: "relative", marginLeft: 5,
minHeight: 116, marginRight: 5,
maxHeight: 75,
minHeight: 75,
maxWidth: 420,
minWidth: "100%",
} }
if (counted === 12/xs*rowHandler) { //if (counted === 12/xs*rowHandler) {
return null // return null
} //}
console.log("DATA: ", data)
counted += 1 counted += 1
var parsedname = "" var name = data.name === undefined ?
for (var key = 0; key < data.name.length; key++) { data.filename.charAt(0).toUpperCase() + data.filename.slice(1).replaceAll("_", " ") + " - " + data.title :
var character = data.name.charAt(key) (data.name.charAt(0).toUpperCase()+data.name.slice(1)).replaceAll("_", " ")
if (character === character.toUpperCase()) {
//console.log(data.name[key], data.name[key+1]) if (name.length > 100) {
if (data.name.charAt(key+1) !== undefined && data.name.charAt(key+1) === data.name.charAt(key+1).toUpperCase()) { name = name.slice(0, 100)+"..."
} else {
parsedname += " "
}
} }
parsedname += character const secondaryText = data.data !== undefined ? data.data.slice(0, 100)+"..." : ""
} const baseImage = <PolymerIcon />
const avatar = data.image_url === undefined ?
baseImage
:
<Avatar
src={data.image_url}
variant="rounded"
/>
parsedname = (parsedname.charAt(0).toUpperCase()+parsedname.substring(1)).replaceAll("_", " ") var parsedUrl = data.urlpath !== undefined ? data.urlpath : ""
parsedUrl += `?queryID=${data.__queryID}`
return ( return (
<Zoom key={index} in={true} style={{ transitionDelay: `${workflowDelay}ms` }}> <Zoom key={index} in={true} style={{ transitionDelay: `${workflowDelay}ms` }}>
<Grid item xs={xs} key={index}> <Link key={data.objectID} to={parsedUrl} style={{textDecoration: "none", color: "white",}} onClick={(event) => {
<Link to={`/docs/${data.objectID}?queryID=${data.__queryID}`} style={{textDecoration: "none", color: "#f85a3e"}}> aa('init', {
<Paper elevation={0} style={paperStyle} onMouseOver={() => { appId: searchClient.appId,
setMouseHoverIndex(index) apiKey: searchClient.transporter.queryParameters["x-algolia-api-key"]
/*
ReactGA.event({
category: "app_grid_view",
action: `search_bar_click`,
label: "",
})
*/
}} onMouseOut={() => {
setMouseHoverIndex(-1)
}} onClick={() => {
ReactGA.event({
category: "docs_grid_view",
action: `docs_${parsedname}_${data.id}_click`,
label: "",
}) })
const timestamp = new Date().getTime()
aa('sendEvents', [
{
eventType: 'click',
eventName: 'Product Clicked Appgrid',
index: 'documentation',
objectIDs: [data.objectID],
timestamp: timestamp,
queryID: data.__queryID,
positions: [data.__position],
}
])
console.log("CLICK")
}}> }}>
<ButtonBase style={{padding: 5, borderRadius: 3, minHeight: 100, minWidth: 100,}}> <ListItem key={data.objectID} style={innerlistitemStyle} onMouseOver={() => {
<img alt={data.name} src={data.image_url} style={{width: "100%", maxWidth: 100, minWidth: 100, minHeight: 100, maxHeight: 100, display: "block", margin: "0 auto"}} /> setMouseHoverIndex(index)
</ButtonBase> }}>
<div/> <ListItemAvatar>
{index === mouseHoverIndex || showName === true ? {avatar}
parsedname </ListItemAvatar>
: <ListItemText
null primary={name}
} secondary={secondaryText}
{data.generated ? />
<Tooltip title={"Created with App editor"} style={{marginTop: "28px", width: "100%"}} aria-label={data.name}> {/*
{data.invalid ? <ListItemSecondaryAction>
<CloudQueueIcon style={{position: "absolute", top: 1, left: 3, height: 16, width: 16, color: theme.palette.primary.main }}/> <IconButton edge="end" aria-label="delete">
: <DeleteIcon />
<CloudQueueIcon style={{position: "absolute", top: 1, left: 3, height: 16, width: 16, color: "rgba(255,255,255,0.95)",}}/> </IconButton>
} </ListItemSecondaryAction>
</Tooltip> */}
: </ListItem>
<Tooltip title={"Created with python (custom app)"} style={{marginTop: "28px", width: "100%"}} aria-label={data.name}>
<CodeIcon style={{position: "absolute", top: 1, left: 3, height: 16, width: 16, color: "rgba(255,255,255,0.95)",}}/>
</Tooltip>
}
</Paper>
</Link> </Link>
</Grid>
</Zoom> </Zoom>
) )
})} })}
</Grid> </List>
) )
} }
+30
View File
@@ -1295,6 +1295,19 @@ const ParsedAction = (props) => {
if (data.name === "url" && data.value !== undefined && data.value !== null && data.value.length === 0) { if (data.name === "url" && data.value !== undefined && data.value !== null && data.value.length === 0) {
data.value = data.example; data.value = data.example;
} }
if (data.value.length === 0) {
if (data.name.toLowerCase() === "headers") {
data.value = data.example
}
}
/*
if (data.name !== "queries" && data.name !== "key" && data.name !== "value" ) {
data.value = data.example
}
}
*/
} }
if (data.name.startsWith("${") && data.name.endsWith("}")) { if (data.name.startsWith("${") && data.name.endsWith("}")) {
@@ -3269,13 +3282,30 @@ const ParsedAction = (props) => {
for (var line in descSplit) { for (var line in descSplit) {
if (descSplit[line].includes("http") && descSplit[line].includes("://")) { if (descSplit[line].includes("http") && descSplit[line].includes("://")) {
const urlsplit = descSplit[line].split("/") const urlsplit = descSplit[line].split("/")
try {
extraUrl = "/"+urlsplit.slice(3, urlsplit.length).join("/")
} catch (e) {
console.log("Failed - running with -1")
extraUrl = "/"+urlsplit.slice(3, urlsplit.length-1).join("/") extraUrl = "/"+urlsplit.slice(3, urlsplit.length-1).join("/")
}
console.log("NO BASEURL TOO!! Why missing last one in certain scenarios (sevco)?", extraUrl, urlsplit, descSplit[line])
break break
} }
} }
if (extraUrl.length > 0) { if (extraUrl.length > 0) {
if (extraUrl.includes(" ")) {
extraUrl = extraUrl.split(" ")[0]
}
if (extraUrl.includes("#")) {
extraUrl = extraUrl.split("#")[0]
}
extraDescription = `${method} ${extraUrl}` extraDescription = `${method} ${extraUrl}`
} else {
console.log("No url found. Check again :)")
} }
} }
@@ -41,6 +41,7 @@ import { padding, textAlign } from '@mui/system';
const liquidFilters = [ const liquidFilters = [
{"name": "Size", "value": "size", "example": ""}, {"name": "Size", "value": "size", "example": ""},
{"name": "Date", "value": `date: "%Y%M%d"`, "example": `{{ "now" | date: "%s" }}`}, {"name": "Date", "value": `date: "%Y%M%d"`, "example": `{{ "now" | date: "%s" }}`},
{"name": "Escape String", "value": `{{ \"\"\"'string with weird'" quotes\"\"\" | escape_string }}`, "example": ``},
] ]
const mathFilters = [ const mathFilters = [
@@ -50,7 +51,7 @@ const mathFilters = [
const pythonFilters = [ const pythonFilters = [
{"name": "Hello World", "value": `{% python %}\nprint("hello world")\n{% endpython %}`, "example": ``}, {"name": "Hello World", "value": `{% python %}\nprint("hello world")\n{% endpython %}`, "example": ``},
{"name": "Handle JSON", "value": `{% python %}\nimport json\njsondata = json.loads("""$nodename""")\n{% endpython %}`, "example": ``}, {"name": "Handle JSON", "value": `{% python %}\nimport json\njsondata = json.loads(r"""$nodename""")\n{% endpython %}`, "example": ``},
] ]
const CodeEditor = (props) => { const CodeEditor = (props) => {
@@ -348,7 +349,7 @@ const CodeEditor = (props) => {
return return
} }
if (!item.value.includes("{%")) { if (!item.value.includes("{%") && !item.value.includes("{{")) {
setlocalcodedata(localcodedata+" | "+item.value+" }}") setlocalcodedata(localcodedata+" | "+item.value+" }}")
} else { } else {
setlocalcodedata(localcodedata+item.value) setlocalcodedata(localcodedata+item.value)
@@ -582,7 +583,7 @@ const CodeEditor = (props) => {
}} }}
/> />
</span> </span>
{editorPopupOpen ? {/*editorPopupOpen ?
<Paper <Paper
style={{ style={{
margin: 10, margin: 10,
@@ -617,13 +618,12 @@ const CodeEditor = (props) => {
}} }}
> >
{data.substring(0, 25)} {data.substring(0, 25)}
{/* {Object.keys(data.example).forEach(key => key)} */}
</button> </button>
</div> </div>
) )
})} })}
</Paper> </Paper>
: null} : null*/}
<div <div
style={{ style={{
+13 -5
View File
@@ -1120,6 +1120,9 @@ const AngularWorkflow = (defaultprops) => {
} }
curworkflowTrigger.position = cyelements[key].position(); curworkflowTrigger.position = cyelements[key].position();
if (curworkflowTrigger.canConnect === false) {
continue
}
newTriggers.push(curworkflowTrigger); newTriggers.push(curworkflowTrigger);
} else if (type === "COMMENT") { } else if (type === "COMMENT") {
@@ -11452,9 +11455,9 @@ const AngularWorkflow = (defaultprops) => {
</Tooltip> </Tooltip>
</div> </div>
</div> </div>
); );
const executionPaperStyle = { const executionPaperStyle = {
minWidth: "95%", minWidth: "95%",
maxWidth: "95%", maxWidth: "95%",
marginTop: "5px", marginTop: "5px",
@@ -11466,9 +11469,9 @@ const executionPaperStyle = {
display: "flex", display: "flex",
minHeight: 40, minHeight: 40,
maxHeight: 40, maxHeight: 40,
}; };
const parsedExecutionArgument = () => { const parsedExecutionArgument = () => {
var showResult = executionData.execution_argument.trim(); var showResult = executionData.execution_argument.trim();
const validate = validateJson(showResult); const validate = validateJson(showResult);
@@ -12175,7 +12178,12 @@ const parsedExecutionArgument = () => {
executionData.execution_argument, executionData.execution_argument,
executionData.start, executionData.start,
lastSaved lastSaved
); )
if (executionText === undefined || executionText === null || executionText.length === 0) {
setExecutionText(executionData.execution_argument)
}
setExecutionModalOpen(false); setExecutionModalOpen(false);
}} }}
> >
+10
View File
@@ -1814,6 +1814,10 @@ const AppCreator = (defaultprops) => {
for (var querykey in item.queries) { for (var querykey in item.queries) {
const queryitem = item.queries[querykey]; const queryitem = item.queries[querykey];
if (queryitem === undefined || queryitem === null || queryitem.name === undefined || queryitem.name === null) {
continue
}
// A fix for duplicate items // A fix for duplicate items
if (querynames.includes(queryitem.name.toLowerCase())) { if (querynames.includes(queryitem.name.toLowerCase())) {
continue continue
@@ -1967,11 +1971,16 @@ const AppCreator = (defaultprops) => {
} }
} }
const methodname = item.method.toLowerCase()
if (methodname === "post" || methodname === "put" || methodname === "patch") {
if ( if (
item.body !== undefined && item.body !== undefined &&
item.body !== null && item.body !== null &&
item.body.length > 0 item.body.length > 0
) { ) {
console.log("GOT BODY: ", item.url, item.method)
//var pathjoin = item.url+"_"+item.method.toLowerCase()
const required = false; const required = false;
newitem = { newitem = {
in: "body", in: "body",
@@ -2031,6 +2040,7 @@ const AppCreator = (defaultprops) => {
} else { } else {
//console.log("Nothing to append?") //console.log("Nothing to append?")
} }
}
// https://swagger.io/docs/specification/describing-request-body/file-upload/ // https://swagger.io/docs/specification/describing-request-body/file-upload/
if ( if (
+18 -9
View File
@@ -8,7 +8,6 @@ import SecurityFramework from '../components/SecurityFramework.jsx';
import { ShepherdTour, ShepherdTourContext } from 'react-shepherd' import { ShepherdTour, ShepherdTourContext } from 'react-shepherd'
import { isMobile } from "react-device-detect" import { isMobile } from "react-device-detect"
import { import {
Badge, Badge,
Avatar, Avatar,
@@ -88,6 +87,7 @@ import { useAlert } from "react-alert";
import ChipInput from "material-ui-chip-input"; import ChipInput from "material-ui-chip-input";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
const inputColor = "#383B40"; const inputColor = "#383B40";
const surfaceColor = "#27292D"; const surfaceColor = "#27292D";
const svgSize = 24; const svgSize = 24;
@@ -133,8 +133,8 @@ export const GetIconInfo = (action) => {
const iconList = [ const iconList = [
{ key: "cache_add", values: ["set_cache"] }, { key: "cache_add", values: ["set_cache"] },
{ key: "cache_get", values: ["get_cache"] }, { key: "cache_get", values: ["get_cache"] },
{ key: "filter", values: ["filter", "route", "router"] }, { key: "filter", values: ["filter"] },
{ key: "merge", values: ["join", "merge"] }, { key: "merge", values: ["join", "merge", "route", "router"] },
{ {
key: "search", key: "search",
values: ["search", "find", "locate", "index", "analyze", "anal", "match", "check cache", "check", "verify", "validate"], values: ["search", "find", "locate", "index", "analyze", "anal", "match", "check cache", "check", "verify", "validate"],
@@ -412,6 +412,7 @@ export const validateJson = (showResult) => {
jsonvalid = false jsonvalid = false
} }
} catch (e) { } catch (e) {
console.log("Bug1: ", e)
showResult = showResult.split("'").join('"'); showResult = showResult.split("'").join('"');
try { try {
@@ -419,14 +420,17 @@ export const validateJson = (showResult) => {
jsonvalid = false; jsonvalid = false;
} }
} catch (e) { } catch (e) {
console.log("Bug2: ", e)
jsonvalid = false; jsonvalid = false;
} }
} }
var result = showResult; var result = showResult;
try { try {
result = jsonvalid ? JSON.parse(showResult) : showResult; result = jsonvalid ? JSON.parse(showResult, {"storeAsString": true}) : showResult;
} catch (e) { } catch (e) {
console.log("Bug3: ", e)
////console.log("Failed parsing JSON even though its valid: ", e) ////console.log("Failed parsing JSON even though its valid: ", e)
jsonvalid = false; jsonvalid = false;
} }
@@ -444,6 +448,7 @@ export const validateJson = (showResult) => {
result = JSON.parse(newstr) result = JSON.parse(newstr)
jsonvalid = true jsonvalid = true
} catch (e) { } catch (e) {
console.log("Bug4: ", e)
//console.log("Failed parsing JSON even though its valid (2): ", e) //console.log("Failed parsing JSON even though its valid (2): ", e)
jsonvalid = false jsonvalid = false
@@ -477,7 +482,6 @@ export const validateJson = (showResult) => {
} }
} }
//console.log("VALID: ", jsonvalid, result, typeof result)
return { return {
valid: jsonvalid, valid: jsonvalid,
result: result, result: result,
@@ -1116,10 +1120,15 @@ const Workflows = (props) => {
justifyContent: "space-between", justifyContent: "space-between",
}; };
const exportAllWorkflows = () => { const exportAllWorkflows = (allWorkflows) => {
for (var key in workflows) { for (var i = 0; i < allWorkflows.length; i++) {
exportWorkflow(workflows[key], false); setTimeout(() => {
console.log(workflows[i].name)
exportWorkflow(workflows[i], false)
}, i * 200);
} }
alert.info(`exporting and keeping original for all ${workflows.length} workflows`);
}; };
const deduplicateIds = (data) => { const deduplicateIds = (data) => {
@@ -2811,7 +2820,7 @@ const Workflows = (props) => {
style={{}} style={{}}
variant="text" variant="text"
onClick={() => { onClick={() => {
exportAllWorkflows(); exportAllWorkflows(workflows);
}} }}
> >
<GetAppIcon /> <GetAppIcon />