@jigx/core-sdk 1.1.0 → 1.2.0-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action/ja.generate-pdf.d.ts +17 -1
- package/dist/action/ja.generate-pdf.d.ts.map +1 -1
- package/dist/action/ja.generate-pdf.js +4 -1
- package/dist/action/ja.in-background.d.ts +3 -2
- package/dist/action/ja.in-background.d.ts.map +1 -1
- package/dist/action/ja.in-background.js +1 -1
- package/dist/assets/example-extraction-cache.json +3 -3
- package/dist/assets/extracted-core-sdk-examples.yaml +18 -0
- package/dist/assets/extracted-core-sdk-types.yaml +58 -0
- package/dist/assets/type-extraction-cache.json +3 -3
- package/docs/array-fields.md +371 -0
- package/docs/conditional-logic.md +178 -0
- package/docs/convention-naming.md +102 -0
- package/docs/date-field.md +92 -0
- package/docs/dropdown-fields.md +879 -0
- package/docs/field-state.md +131 -0
- package/docs/field-types-overview.md +132 -0
- package/docs/formatting.md +421 -0
- package/docs/icons.md +142 -0
- package/docs/index.md +23 -0
- package/docs/jsonata-expressions.md +200 -0
- package/docs/media-fields.md +107 -0
- package/docs/overview.md +467 -0
- package/docs/pattern-build-deploy.md +91 -0
- package/docs/pattern-datasources.md +459 -0
- package/docs/pattern-forms.md +528 -0
- package/docs/pattern-global-actions.md +92 -0
- package/docs/pattern-javascript-functions.md +452 -0
- package/docs/pattern-navigation.md +304 -0
- package/docs/pattern-pdf-generation.md +391 -0
- package/docs/pattern-rest-acumatica.md +660 -0
- package/docs/pattern-sync-progress.md +96 -0
- package/docs/pattern-sync.md +653 -0
- package/docs/pattern-tabs-form.md +293 -0
- package/docs/recipe-index.md +64 -0
- package/docs/runtime-variables.md +127 -0
- package/docs/sections.md +81 -0
- package/docs/validation-patterns.md +150 -0
- package/package.json +3 -2
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
## Basic Validation
|
|
2
|
+
|
|
3
|
+
```typescript
|
|
4
|
+
const age = step.addNumber({
|
|
5
|
+
name: 'age',
|
|
6
|
+
label: 'Age',
|
|
7
|
+
})
|
|
8
|
+
age.with({
|
|
9
|
+
errorText: new JsonataBuilder('$age < 18 ? "Must be 18 or older" : null', {
|
|
10
|
+
age: age.state.value,
|
|
11
|
+
}),
|
|
12
|
+
})
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Password Matching
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
const password = step.addText({ name: 'password', label: 'Password' })
|
|
19
|
+
const confirm = step.addText({
|
|
20
|
+
name: 'confirm-password',
|
|
21
|
+
label: 'Confirm Password',
|
|
22
|
+
})
|
|
23
|
+
confirm.with({
|
|
24
|
+
errorText: new JsonataBuilder('$confirm = $password ? null : "Passwords must match"', {
|
|
25
|
+
password: password.state.value,
|
|
26
|
+
confirm: confirm.state.value,
|
|
27
|
+
}),
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Conditional Validation
|
|
32
|
+
|
|
33
|
+
Validate based on other field values:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
const country = step.addDropdown({
|
|
37
|
+
name: 'country',
|
|
38
|
+
label: 'Country',
|
|
39
|
+
data: [
|
|
40
|
+
{ label: 'USA', value: 'usa' },
|
|
41
|
+
{ label: 'Canada', value: 'canada' },
|
|
42
|
+
],
|
|
43
|
+
})
|
|
44
|
+
// Different validation per country
|
|
45
|
+
const zipCode = step.addText({
|
|
46
|
+
name: 'zip',
|
|
47
|
+
label: 'ZIP/Postal Code',
|
|
48
|
+
})
|
|
49
|
+
zipCode.with({
|
|
50
|
+
errorText: new JsonataBuilder(
|
|
51
|
+
`
|
|
52
|
+
$country = "usa" and $length($zip) != 5 ? "US ZIP must be 5 digits" :
|
|
53
|
+
$country = "canada" and $length($zip) != 6 ? "Canadian postal code must be 6 characters" :
|
|
54
|
+
null
|
|
55
|
+
`,
|
|
56
|
+
{
|
|
57
|
+
country: country.state.value,
|
|
58
|
+
zip: zipCode.state.value,
|
|
59
|
+
},
|
|
60
|
+
),
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Range Validation
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const quantity = step.addNumber({
|
|
68
|
+
name: 'quantity',
|
|
69
|
+
label: 'Quantity',
|
|
70
|
+
})
|
|
71
|
+
quantity.with({
|
|
72
|
+
errorText: new JsonataBuilder(
|
|
73
|
+
`
|
|
74
|
+
$qty = null ? null :
|
|
75
|
+
$qty < 1 ? "Minimum quantity is 1" :
|
|
76
|
+
$qty > 100 ? "Maximum quantity is 100" :
|
|
77
|
+
null
|
|
78
|
+
`,
|
|
79
|
+
{ qty: quantity.state.value },
|
|
80
|
+
),
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Format Validation
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
const phone = step.addText({
|
|
88
|
+
name: 'phone',
|
|
89
|
+
label: 'Phone',
|
|
90
|
+
})
|
|
91
|
+
phone.with({
|
|
92
|
+
errorText: new JsonataBuilder(
|
|
93
|
+
`
|
|
94
|
+
$phone = null or $phone = "" ? null :
|
|
95
|
+
$length($phone) < 10 ? "Phone must be at least 10 digits" :
|
|
96
|
+
null
|
|
97
|
+
`,
|
|
98
|
+
{ phone: phone.state.value },
|
|
99
|
+
),
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Validation Expression Pattern
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
<condition> ? "<error message>" : null
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Multiple conditions:**
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
<check1> ? "<error1>" :
|
|
113
|
+
<check2> ? "<error2>" :
|
|
114
|
+
<check3> ? "<error3>" :
|
|
115
|
+
null
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Cross-Step Validation
|
|
119
|
+
|
|
120
|
+
Validate against data from other steps:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const step1 = form.addStep({ instanceId: 'dates', icon: 'calendar' }, (step) => {
|
|
124
|
+
step.addDate({ name: 'start-date', label: 'Start Date' })
|
|
125
|
+
})
|
|
126
|
+
form.addStep({ instanceId: 'end', title: 'End Date', icon: 'calendar' }, (step) => {
|
|
127
|
+
const endDate = step.addDate({
|
|
128
|
+
name: 'end-date',
|
|
129
|
+
label: 'End Date',
|
|
130
|
+
})
|
|
131
|
+
endDate.with({
|
|
132
|
+
errorText: new JsonataBuilder(
|
|
133
|
+
'$end < $start ? "End date must be after start date" : null',
|
|
134
|
+
{
|
|
135
|
+
start: step1.data.getFieldData('start-date'),
|
|
136
|
+
end: endDate.state.value,
|
|
137
|
+
},
|
|
138
|
+
),
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Useful JSONata Functions
|
|
144
|
+
|
|
145
|
+
| Function | Purpose | Example |
|
|
146
|
+
| --- | --- | --- |
|
|
147
|
+
| `$length(str)` | String length | `$length($phone) < 10` |
|
|
148
|
+
| `$contains(str, sub)` | Contains substring | `$contains($email, "@")` |
|
|
149
|
+
| `$match(str, regex)` | Regex match | `$match($code, /^[A-Z]{3}$/)` |
|
|
150
|
+
| `$number(str)` | Convert to number | `$number($age) >= 18` |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jigx/core-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-rc",
|
|
4
4
|
"description": "Jigx Software Development Kit - SDK for building Jigx applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"files": [
|
|
28
|
-
"dist"
|
|
28
|
+
"dist",
|
|
29
|
+
"docs"
|
|
29
30
|
],
|
|
30
31
|
"keywords": [
|
|
31
32
|
"jigx",
|