2021-03-30 05:29:03 +00:00
|
|
|
import { EXECUTION_PARAM_KEY } from "constants/AppsmithActionConstants/ActionConstants";
|
2021-07-26 05:50:46 +00:00
|
|
|
import { ValidationConfig } from "./PropertyControlConstants";
|
2020-03-31 03:21:35 +00:00
|
|
|
|
2021-04-21 14:34:25 +00:00
|
|
|
// Always add a validator function in ./worker/validation for these types
|
2021-07-26 05:50:46 +00:00
|
|
|
export enum ValidationTypes {
|
2021-04-21 14:34:25 +00:00
|
|
|
TEXT = "TEXT",
|
|
|
|
|
REGEX = "REGEX",
|
|
|
|
|
NUMBER = "NUMBER",
|
|
|
|
|
BOOLEAN = "BOOLEAN",
|
|
|
|
|
OBJECT = "OBJECT",
|
|
|
|
|
ARRAY = "ARRAY",
|
2021-07-26 05:50:46 +00:00
|
|
|
OBJECT_ARRAY = "OBJECT_ARRAY",
|
2021-09-17 09:08:35 +00:00
|
|
|
NESTED_OBJECT_ARRAY = "NESTED_OBJECT_ARRAY",
|
2021-04-21 14:34:25 +00:00
|
|
|
DATE_ISO_STRING = "DATE_ISO_STRING",
|
2021-07-26 05:50:46 +00:00
|
|
|
IMAGE_URL = "IMAGE_URL",
|
|
|
|
|
FUNCTION = "FUNCTION",
|
2021-07-28 06:01:09 +00:00
|
|
|
SAFE_URL = "SAFE_URL",
|
2021-12-09 06:15:59 +00:00
|
|
|
TABLE_PROPERTY = "TABLE_PROPERTY",
|
2021-04-21 14:34:25 +00:00
|
|
|
}
|
2019-11-22 13:12:39 +00:00
|
|
|
|
|
|
|
|
export type ValidationResponse = {
|
|
|
|
|
isValid: boolean;
|
|
|
|
|
parsed: any;
|
2021-09-29 12:03:11 +00:00
|
|
|
messages?: string[];
|
2020-06-05 16:20:23 +00:00
|
|
|
transformed?: any;
|
2019-11-19 12:44:58 +00:00
|
|
|
};
|
|
|
|
|
|
2020-04-20 05:42:46 +00:00
|
|
|
export type Validator = (
|
2021-07-26 05:50:46 +00:00
|
|
|
config: ValidationConfig,
|
|
|
|
|
value: unknown,
|
2022-02-03 09:57:08 +00:00
|
|
|
props: Record<string, unknown>,
|
2020-04-20 05:42:46 +00:00
|
|
|
) => ValidationResponse;
|
2020-08-17 05:03:15 +00:00
|
|
|
|
2021-02-23 12:35:09 +00:00
|
|
|
export const ISO_DATE_FORMAT = "YYYY-MM-DDTHH:mm:ss.sssZ";
|
2020-11-23 09:27:00 +00:00
|
|
|
|
2020-12-14 18:48:13 +00:00
|
|
|
export const JAVASCRIPT_KEYWORDS = {
|
2022-02-02 15:35:42 +00:00
|
|
|
Array: "Array",
|
2020-11-23 09:27:00 +00:00
|
|
|
await: "await",
|
2022-02-02 15:35:42 +00:00
|
|
|
Boolean: "Boolean",
|
2020-11-23 09:27:00 +00:00
|
|
|
break: "break",
|
|
|
|
|
case: "case",
|
|
|
|
|
catch: "catch",
|
|
|
|
|
class: "class",
|
|
|
|
|
const: "const",
|
|
|
|
|
continue: "continue",
|
2022-02-02 15:35:42 +00:00
|
|
|
Date: "Date",
|
2020-11-23 09:27:00 +00:00
|
|
|
debugger: "debugger",
|
|
|
|
|
default: "default",
|
|
|
|
|
delete: "delete",
|
|
|
|
|
do: "do",
|
|
|
|
|
else: "else",
|
|
|
|
|
enum: "enum",
|
2022-02-02 15:35:42 +00:00
|
|
|
eval: "eval",
|
2020-11-23 09:27:00 +00:00
|
|
|
export: "export",
|
|
|
|
|
extends: "extends",
|
|
|
|
|
false: "false",
|
|
|
|
|
finally: "finally",
|
|
|
|
|
for: "for",
|
|
|
|
|
function: "function",
|
2022-02-02 15:35:42 +00:00
|
|
|
Function: "Function",
|
|
|
|
|
hasOwnProperty: "hasOwnProperty",
|
2020-11-23 09:27:00 +00:00
|
|
|
if: "if",
|
|
|
|
|
implements: "implements",
|
|
|
|
|
import: "import",
|
|
|
|
|
in: "in",
|
2022-02-02 15:35:42 +00:00
|
|
|
Infinity: "Infinity",
|
2020-11-23 09:27:00 +00:00
|
|
|
instanceof: "instanceof",
|
|
|
|
|
interface: "interface",
|
2022-02-02 15:35:42 +00:00
|
|
|
isFinite: "isFinite",
|
|
|
|
|
isNaN: "isNaN",
|
|
|
|
|
isPrototypeOf: "isPrototypeOf",
|
|
|
|
|
JSON: "JSON",
|
|
|
|
|
length: "length",
|
2020-11-23 09:27:00 +00:00
|
|
|
let: "let",
|
2022-02-02 15:35:42 +00:00
|
|
|
Math: "Math",
|
|
|
|
|
name: "name",
|
|
|
|
|
NaN: "NaN",
|
2020-11-23 09:27:00 +00:00
|
|
|
new: "new",
|
|
|
|
|
null: "null",
|
2022-02-02 15:35:42 +00:00
|
|
|
Number: "Number",
|
|
|
|
|
Object: "Object",
|
2020-11-23 09:27:00 +00:00
|
|
|
package: "package",
|
|
|
|
|
private: "private",
|
|
|
|
|
protected: "protected",
|
|
|
|
|
public: "public",
|
|
|
|
|
return: "return",
|
|
|
|
|
static: "static",
|
2022-02-02 15:35:42 +00:00
|
|
|
String: "String",
|
2020-11-23 09:27:00 +00:00
|
|
|
super: "super",
|
|
|
|
|
switch: "switch",
|
|
|
|
|
this: "this",
|
|
|
|
|
throw: "throw",
|
2022-02-02 15:35:42 +00:00
|
|
|
toString: "toString",
|
|
|
|
|
true: "true",
|
2020-11-23 09:27:00 +00:00
|
|
|
try: "try",
|
|
|
|
|
typeof: "typeof",
|
2022-02-02 15:35:42 +00:00
|
|
|
undefined: "undefined",
|
|
|
|
|
valueOf: "valueOf",
|
2020-11-23 09:27:00 +00:00
|
|
|
var: "var",
|
|
|
|
|
void: "void",
|
|
|
|
|
while: "while",
|
|
|
|
|
with: "with",
|
|
|
|
|
yield: "yield",
|
|
|
|
|
};
|
2020-12-14 18:48:13 +00:00
|
|
|
|
|
|
|
|
export const DATA_TREE_KEYWORDS = {
|
|
|
|
|
actionPaths: "actionPaths",
|
|
|
|
|
appsmith: "appsmith",
|
|
|
|
|
pageList: "pageList",
|
|
|
|
|
[EXECUTION_PARAM_KEY]: EXECUTION_PARAM_KEY,
|
|
|
|
|
};
|
2021-10-04 12:49:58 +00:00
|
|
|
|
|
|
|
|
export const WINDOW_OBJECT_PROPERTIES = {
|
|
|
|
|
closed: "closed",
|
|
|
|
|
console: "console",
|
|
|
|
|
defaultStatus: "defaultStatus",
|
|
|
|
|
document: "document",
|
|
|
|
|
frameElement: "frameElement",
|
|
|
|
|
frames: "frames",
|
|
|
|
|
history: "history",
|
|
|
|
|
innerHeight: "innerHeight",
|
|
|
|
|
innerWidth: "innerWidth",
|
|
|
|
|
length: "length",
|
|
|
|
|
localStorage: "localStorage",
|
|
|
|
|
location: "location",
|
|
|
|
|
name: "name",
|
|
|
|
|
navigator: "navigator",
|
|
|
|
|
opener: "opener",
|
|
|
|
|
outerHeight: "outerHeight",
|
|
|
|
|
outerWidth: "outerWidth",
|
|
|
|
|
pageXOffset: "pageXOffset",
|
|
|
|
|
pageYOffset: "pageYOffset",
|
|
|
|
|
parent: "parent",
|
|
|
|
|
screen: "screen",
|
|
|
|
|
screenLeft: "screenLeft",
|
|
|
|
|
screenTop: "screenTop",
|
|
|
|
|
screenY: "screenY",
|
|
|
|
|
scrollX: "scrollX",
|
|
|
|
|
scrollY: "scrollY",
|
|
|
|
|
self: "self",
|
|
|
|
|
status: "status",
|
|
|
|
|
top: "top",
|
2021-11-10 07:11:23 +00:00
|
|
|
evaluationVersion: "evaluationVersion",
|
2021-10-04 12:49:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const WINDOW_OBJECT_METHODS = {
|
|
|
|
|
alert: "alert",
|
|
|
|
|
atob: "atob",
|
|
|
|
|
blur: "blur",
|
|
|
|
|
btoa: "btoa",
|
|
|
|
|
clearInterval: "clearInterval",
|
|
|
|
|
clearTimeout: "clearTimeout",
|
|
|
|
|
close: "close",
|
|
|
|
|
confirm: "confirm",
|
|
|
|
|
focus: "focus",
|
|
|
|
|
getComputedStyle: "getComputedStyle",
|
|
|
|
|
getSelection: "getSelection",
|
|
|
|
|
matchMedia: "matchMedia",
|
|
|
|
|
moveBy: "moveBy",
|
|
|
|
|
moveTo: "moveTo",
|
|
|
|
|
open: "open",
|
|
|
|
|
print: "print",
|
|
|
|
|
prompt: "prompt",
|
|
|
|
|
requestAnimationFrame: "requestAnimationFrame",
|
|
|
|
|
resizeBy: "resizeBy",
|
|
|
|
|
resizeTo: "resizeTo",
|
|
|
|
|
scroll: "scroll",
|
|
|
|
|
scrollBy: "scrollBy",
|
|
|
|
|
scrollTo: "scrollBy",
|
|
|
|
|
setInterval: "setInterval",
|
|
|
|
|
setTimeout: "setTimeout",
|
|
|
|
|
stop: "stop",
|
|
|
|
|
};
|