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>,
|
feat: JSON Form widget (#8472)
* initial layout
* updated parser to support nested array
* array field rendering
* changes
* ts fix
* minor revert FormWidget
* modified schema structure
* select and switch fields
* added checkbox field
* added RadioGroupField
* partial DateField and defaults, typing refactoring
* added label and field type change
* minor ts changes
* changes
* modified widget/utils for nested panelConfig, modified schema to object approach
* array/object label support
* hide field configuration when children not present
* added tooltip
* field visibility option
* disabled state
* upgraded tslib, form initial values
* custom field configuration - add/hide/edit
* field configuration - label change
* return input when field configuration reaches max depth
* minor changes
* form - scroll, fixedfooter, enitity defn and other minior changes
* form title
* unregister on unmount
* fixes
* zero state
* fix field padding
* patched updating form values, removed linting warnings
* configured action buttons
* minor fix
* minor change
* property pane - sort fields in field configuration
* refactor include all properties
* checkbox properties
* date properties
* refactor typings and radio group properties
* switch, multselect, select, array, object properties
* minor changes
* default value
* ts fixes
* checkbox field properties implementation
* date field prop implementation
* switch field
* select field and fix deep nested meta properties
* multiselect implementation
* minor change
* input field implementation
* fix position jump on field type change
* initial accordian
* field state property and auto-complete of JSONFormComputeControl
* merge fixes
* renamed FormBuilder to JSONForm
* source data validation minor change
* custom field default value fix
* Editable keys for custom field
* minor fixes
* replaced useFieldArray with custom logic, added widget icon
* array and object accordian with border/background styling
* minor change
* disabled states for array and objects
* default value minor fix
* form level styles
* modified logic for isDisabled for array and object, added disabledWhenInvalid, exposed isValid to fieldState for text input, removed useDisableChildren
* added isValid for all field types
* fixed reset to default values
* debounce form values update
* minor change
* minor change
* fix crash - source data change multi-select to array, fix crash - change of options
* fix positioning
* detect date type in source data
* fix crash - when object is passed to regex input field
* fixed default sourceData path for fields
* accodion keep children mounted on collapse
* jest test for schemaParser
* widget/helper and useRegisterFieldInvalid test
* tests for property config helper and generatePanelPropertyConfig
* fix input field validation not appearing
* fix date field type detection
* rename data -> formData
* handle null/undefined field value change in sourceData
* added null/undefined as valid values for defaultValue text field
* auto detect email field
* set formData default value on initial load
* switch field inline positioning
* field margin fix for row direction
* select full width
* fiex date field default value - out of range
* fix any field type to array
* array default value logic change
* base cypress test changes
* initial json form render cy test
* key sanitization
* fix fieldState update logic
* required design, object/array background color, accordion changes, fix - add new custom field
* minor change
* cypress tests
* fix date formatted value, field state cypress test
* cypress - field properties test and fixes
* rename test file
* fix accessort change to blank value, cypress tests
* fix array field default value for modified accessor
* minor fix
* added animate loading
* fix empty state, add new custom field
* test data fix
* fix warnings
* fix timePrecision visibility
* button styling
* ported input v2
* fix jest tests
* fix cypress tests
* perf changes
* perf improvement
* added comments
* multiselect changes
* input field perf refactor
* array field, object field refactor performance
* checkbox field refactor
* refectored date, radio, select and switch
* fixes
* test fixes
* fixes
* minor fix
* rename field renderer
* remove tracked fieldRenderer field
* cypress test fixes
* cypress changes
* array default value fixes
* arrayfield passedDefaultValue
* auto enabled JS mode for few properties, reverted swith and date property controls
* cypress changes
* added widget sniping mode and fixed object passedDefaultValue
* multiselect v2
* select v2
* fix jest tests
* test fixes
* field limit
* rename field type dropdown texts
* field type changes fixes
* jest fixes
* loading state submit button
* default source data for new widget
* modify limit message
* multiseelct default value changes and cypress fix
* select default value
* keep default value intact on field type change
* TextTable cypress text fix
* review changes
* fixed footer changes
* collapse styles section by default
* fixed footer changes
* form modes
* custom field key rentention
* fixed footer fix in view mode
* non ascii characters
* fix meta merge in dataTreeWidget
* minor fixes
* rename useRegisterFieldInvalid.ts -> useRegisterFieldValidity.ts
* modified dependency injection into evaluated values
* refactored fixedfooter logic
* minor change
* accessor update
* minor change
* fixes
* QA fixes date field, scroll content
* fix phone number field, removed visiblity option from array item
* fix sourceData autocomplete
* reset logic
* fix multiselect reset
* form values hydration on widget drag
* code review changes
* reverted order of merge dataTreeWidget
* fixes
* added button titles, fixed hydration issue
* default value fixes
* upgraded react hook form, modified array-level/field-level default value logic
* fixed select validation
* added icon entity explorer, modified icon align control
* modify accessor validation for mongo db _id
* update email field regex
* review changes
* explicitly handle empty source data validation
2022-03-24 07:13:25 +00:00
|
|
|
propertyPath: string,
|
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",
|
|
|
|
|
};
|