@jigx/core-sdk 1.2.0-next.38 → 1.2.0-next.39
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/assets/example-extraction-cache.json +3 -3
- package/dist/assets/extracted-core-sdk-examples.yaml +6 -0
- package/docs/index.md +1 -0
- package/docs/pattern-javascript-functions.md +1 -1
- package/docs/pattern-sync.md +5 -10
- package/docs/recipe-index.md +1 -0
- package/docs/runtime-variables.md +67 -0
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "2.0.0",
|
|
3
|
-
"sourceHash": "
|
|
4
|
-
"timestamp":
|
|
3
|
+
"sourceHash": "1e5b057da2c4ec4925389e6567e28bc2",
|
|
4
|
+
"timestamp": 1794346307118,
|
|
5
5
|
"stats": {
|
|
6
6
|
"inputFiles": 439,
|
|
7
|
-
"extractionTimeMs":
|
|
7
|
+
"extractionTimeMs": 566
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -2916,6 +2916,12 @@
|
|
|
2916
2916
|
screen.addWidget
|
|
2917
2917
|
.value({ name: 'dow-widget' })
|
|
2918
2918
|
.value('=$dayOfWeek(@ctx.jig.inputs.selectedDate)') // Day of week (0-6)
|
|
2919
|
+
screen.addWidget
|
|
2920
|
+
.value({ name: 'local-time-widget' })
|
|
2921
|
+
.value('=$utcToTimezone(@ctx.jig.inputs.selectedDate, "local", "HH:mm")') // UTC instant to local text
|
|
2922
|
+
screen.addWidget
|
|
2923
|
+
.value({ name: 'utc-instant-widget' })
|
|
2924
|
+
.value('=$timezoneToUtc(@ctx.jig.inputs.localDate, "Europe/Prague")') // Local text to UTC instant
|
|
2919
2925
|
- id: dynamic-screen-selection-example
|
|
2920
2926
|
name: Dynamic Screen Selection
|
|
2921
2927
|
category: logic and expressions
|
package/docs/index.md
CHANGED
|
@@ -19,6 +19,7 @@ and TSDoc ship in `dist/**/*.d.ts`; runnable examples ship in
|
|
|
19
19
|
| Define reusable actions | [Global actions](./pattern-global-actions.md) |
|
|
20
20
|
| Show sync progress | [Sync progress](./pattern-sync-progress.md) |
|
|
21
21
|
| Extend expressions with JavaScript | [JavaScript functions](./pattern-javascript-functions.md) |
|
|
22
|
+
| Convert dates between UTC and local time | [Timezone functions](./runtime-variables.md#timezone) |
|
|
22
23
|
| Generate and share PDFs | [PDF generation](./pattern-pdf-generation.md) |
|
|
23
24
|
| Build and deploy | [Build/deploy](./pattern-build-deploy.md) |
|
|
24
25
|
|
|
@@ -10,7 +10,7 @@ Reach for this whenever JSONata becomes awkward or unreadable. Typical categorie
|
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| **HTML/text template building** | PDF generation, email body composition, report rendering |
|
|
12
12
|
| **Non-trivial math** | Pricing tiers, tax/discount rules, amortization, unit conversions |
|
|
13
|
-
| **Date/time beyond `$fromMillis`** | Business-day arithmetic,
|
|
13
|
+
| **Date/time beyond `$fromMillis`** | Business-day arithmetic, date-range diffs. For timezone conversion use [`$utcToTimezone` / `$timezoneToUtc`](./runtime-variables.md#timezone) |
|
|
14
14
|
| **Data shaping** | Group-by, pivot, multi-level aggregation, CSV/TSV export |
|
|
15
15
|
| **Validation logic** | Complex multi-field checks, regex-heavy rules, checksum/Luhn |
|
|
16
16
|
| **String parsing and formatting** | Phone normalization, address parsing, slugify, abbreviation |
|
package/docs/pattern-sync.md
CHANGED
|
@@ -441,7 +441,7 @@ Acumatica exposes two API styles. Use REST endpoints where possible — the resp
|
|
|
441
441
|
| Response format | Nested JSON with `.value` wrappers | Flat fields |
|
|
442
442
|
| Records location | Top-level array (`@ctx.response.body`) | Under `value` array (`@ctx.response.body.value`) |
|
|
443
443
|
| outputTransform | Simple — add `id` + `Remote` | Complex — reshape flat → nested with `.value` wrappers |
|
|
444
|
-
| Date handling | ISO format with timezone | Needs timezone conversion (
|
|
444
|
+
| Date handling | ISO format with timezone | Needs timezone conversion (zone name from config) |
|
|
445
445
|
| Counting for continuation | `$count(@ctx.output.data)` | `$count(@ctx.output.data)` (after transform) |
|
|
446
446
|
|
|
447
447
|
For non-Acumatica systems, the same patterns apply — just adapt the URL, auth, response format, and outputTransform to match the API.
|
|
@@ -634,21 +634,16 @@ record so the next sync can compute a new local max. Preserve the same
|
|
|
634
634
|
|
|
635
635
|
## Acumatica-specific: OData timezone handling
|
|
636
636
|
|
|
637
|
-
OData responses from Acumatica use a different datetime format than REST. A timezone conversion
|
|
637
|
+
OData responses from Acumatica use a different datetime format than REST. A timezone conversion is needed in the outputTransform. The outputTransform must start with `=` and the function must set `useLocalCall: true` ([availability](./runtime-variables.md#where-they-are-available)):
|
|
638
638
|
|
|
639
639
|
```jsonata
|
|
640
|
-
$
|
|
641
|
-
$tzSign := $substring($tz, 0, 1) = "-" ? -1 : 1;
|
|
642
|
-
$tzH := $number($substring($tz, 1, 2));
|
|
643
|
-
$tzM := $number($substring($tz, 4, 2));
|
|
644
|
-
$tzOffsetMs := $tzSign * ($tzH * 60 + $tzM) * 60 * 1000;
|
|
645
|
-
$pic := "[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001]";
|
|
640
|
+
$zone := "Europe/Prague";
|
|
646
641
|
$fmtDT := function($d) {
|
|
647
|
-
$d ? $
|
|
642
|
+
$d ? $utcToTimezone($d & "Z", $zone, "YYYY-MM-DDTHH:mm:ss.SSSZ") : undefined
|
|
648
643
|
};
|
|
649
644
|
```
|
|
650
645
|
|
|
651
|
-
Ideally, store the
|
|
646
|
+
Use an IANA zone name, not a fixed offset, so the offset is correct on both sides of a DST change. Ideally, store the zone name in the config table and fetch it via a query in the function, rather than hardcoding.
|
|
652
647
|
|
|
653
648
|
## Error handlers for GET functions
|
|
654
649
|
|
package/docs/recipe-index.md
CHANGED
|
@@ -20,6 +20,7 @@ Reference implementation: `workspace/acumatica-apps/create-customer/`
|
|
|
20
20
|
| [pattern-sync.md](pattern-sync.md) | Initial sync, continuation, diff sync, sync scopes, OData vs REST |
|
|
21
21
|
| [pattern-sync-progress.md](pattern-sync-progress.md) | Sync progress bar UI ideas — weights, step text, show/hide, cards |
|
|
22
22
|
| [pattern-javascript-functions.md](pattern-javascript-functions.md) | `app.script()` — extend JSONata with custom JS functions (math, formatting, HTML templates, validation, transformation) |
|
|
23
|
+
| [runtime-variables.md](runtime-variables.md#timezone) | Runtime variables; `$utcToTimezone` / `$timezoneToUtc` — UTC instant to local text and back, DST-correct, where they are available |
|
|
23
24
|
| [pattern-pdf-generation.md](pattern-pdf-generation.md) | `generate-pdf` action + `app.script()` + `jig.document` screen — generate, persist, preview, share PDFs |
|
|
24
25
|
| [pattern-build-deploy.md](pattern-build-deploy.md) | Build order, typecheck, JSON/YAML generation, deploy script, Jigx API |
|
|
25
26
|
|
|
@@ -37,6 +37,73 @@ import { Auth, System, JsonataBuilder } from '@jigx/expert-sdk'
|
|
|
37
37
|
| `System.timezone.name` | string | Timezone name (e.g., 'America/New_York') |
|
|
38
38
|
| `System.timezone.offset` | string | UTC offset as `±HHMM` (e.g., '+0200'), for today only. Mobile reads it again each time the app becomes active. Web reads it once per page load, so an open page keeps the old offset across a DST change. |
|
|
39
39
|
|
|
40
|
+
`$utcToTimezone` and `$timezoneToUtc` are runtime Expression functions. They convert between a UTC instant and local wall-clock text, with the correct DST offset for the date of the value.
|
|
41
|
+
|
|
42
|
+
These notes track [Mobile #7696](https://github.com/jigx-com/jigx/pull/7696). Confirm that the target app build includes it.
|
|
43
|
+
|
|
44
|
+
#### Conversion functions
|
|
45
|
+
|
|
46
|
+
| Function | Input | Output |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `$utcToTimezone(value, zone?, format?)` | ISO 8601 string with `Z` or an offset, or epoch millis | Text in `zone`. Without `format`: ISO 8601 with offset |
|
|
49
|
+
| `$timezoneToUtc(wallClock, zone?)` | ISO 8601 string with no offset (`2026-07-15T08:00:00`, `2026-07-15`). Date-only means midnight in `zone` | UTC ISO 8601 string |
|
|
50
|
+
|
|
51
|
+
- `zone`: IANA name (`Europe/Prague`), `'UTC'`, or `'local'` (device zone). Default: `'local'`.
|
|
52
|
+
- `format`: moment tokens (`HH:mm`, `YYYY-MM-DD`), not `$fromMillis` picture strings.
|
|
53
|
+
- Null or undefined input returns `undefined`.
|
|
54
|
+
- Invalid input does not throw. The function logs a warning and returns the input unchanged. A value with no offset passed to `$utcToTimezone` is invalid, and so is a value with an offset passed to `$timezoneToUtc`.
|
|
55
|
+
|
|
56
|
+
#### Conversion examples
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
// UTC instant -> local text for an external system
|
|
60
|
+
screen.addWidget
|
|
61
|
+
.value({ name: 'departed-local' })
|
|
62
|
+
.value('=$utcToTimezone(@ctx.jig.inputs.departedAt, "local", "YYYY-MM-DDTHH:mm:ss")')
|
|
63
|
+
|
|
64
|
+
// Local calendar day. $now() is UTC, so it can be a different day
|
|
65
|
+
screen.addWidget
|
|
66
|
+
.value({ name: 'local-today' })
|
|
67
|
+
.value('=$utcToTimezone($now(), "local", "YYYY-MM-DD")')
|
|
68
|
+
|
|
69
|
+
// Time at a site, not on the device
|
|
70
|
+
screen.addWidget
|
|
71
|
+
.value({ name: 'site-time' })
|
|
72
|
+
.value('=$utcToTimezone(@ctx.jig.inputs.arrivalAt, @ctx.jig.inputs.siteZone, "HH:mm")')
|
|
73
|
+
|
|
74
|
+
// Local wall-clock text -> UTC instant
|
|
75
|
+
screen.addWidget
|
|
76
|
+
.value({ name: 'shift-start-utc' })
|
|
77
|
+
.value('=$timezoneToUtc(@ctx.jig.inputs.shiftStartLocal, @ctx.jig.inputs.siteZone)')
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Which zone
|
|
81
|
+
|
|
82
|
+
| Value | Zone |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| A moment in time (created, submitted) | `'local'` |
|
|
85
|
+
| A calendar date (transaction date, period) | `'local'` |
|
|
86
|
+
| A time of day at a site (shift start, appointment) | IANA name of the site, from configuration |
|
|
87
|
+
|
|
88
|
+
#### When not to use them
|
|
89
|
+
|
|
90
|
+
| Goal | Use |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| Show a date to the user | Date `format` with `timezone`. It does not change the stored value |
|
|
93
|
+
| Compare or calculate with dates | `$toMillis` / `$millis()` |
|
|
94
|
+
| Business-day arithmetic | [JavaScript functions](./pattern-javascript-functions.md) |
|
|
95
|
+
|
|
96
|
+
Do not calculate local time from `@ctx.system.timezone.offset`. It is the offset for today, so a date in the other DST season is one hour wrong.
|
|
97
|
+
|
|
98
|
+
#### Where they are available
|
|
99
|
+
|
|
100
|
+
| Location | Available |
|
|
101
|
+
| --- | --- |
|
|
102
|
+
| Expressions with a leading `=` on device | Yes |
|
|
103
|
+
| `outputTransform` with a leading `=` and `useLocalCall: true` | Yes |
|
|
104
|
+
| `outputTransform` with no leading `=` (legacy) | No. It evaluates with stock JSONata |
|
|
105
|
+
| `outputTransform` of a remote function (no `useLocalCall`) | Not confirmed. It does not run on the device, so do not use them there |
|
|
106
|
+
|
|
40
107
|
## User Variables (Auth.user)
|
|
41
108
|
|
|
42
109
|
| Variable | Type | Description |
|