@lowdefy/operators-js 4.7.2 → 5.0.0

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.
@@ -13,12 +13,18 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { getFromObject } from '@lowdefy/operators';
16
+ function getDarkModePreference(window) {
17
+ return window.localStorage?.getItem('lowdefy_darkMode') ?? 'system';
18
+ }
19
+ function getDarkMode(window) {
20
+ return window.__lowdefy_isDark ?? false;
21
+ }
16
22
  const breakpoints = {
17
- xs: 576,
23
+ xs: 640,
18
24
  sm: 768,
19
- md: 992,
20
- lg: 1200,
21
- xl: 1600
25
+ md: 1024,
26
+ lg: 1280,
27
+ xl: 1536
22
28
  };
23
29
  function _media({ arrayIndices, location, params, globals }) {
24
30
  const { window } = globals;
@@ -43,13 +49,15 @@ function _media({ arrayIndices, location, params, globals }) {
43
49
  size = 'xl';
44
50
  break;
45
51
  default:
46
- size = 'xxl';
52
+ size = '2xl';
47
53
  break;
48
54
  }
49
55
  const media = {
50
56
  size,
51
57
  width: window.innerWidth,
52
- height: window.innerHeight
58
+ height: window.innerHeight,
59
+ darkMode: getDarkMode(window),
60
+ darkModePreference: getDarkModePreference(window)
53
61
  };
54
62
  return getFromObject({
55
63
  arrayIndices,
@@ -21,7 +21,9 @@
21
21
  enum: [
22
22
  'size',
23
23
  'width',
24
- 'height'
24
+ 'height',
25
+ 'darkMode',
26
+ 'darkModePreference'
25
27
  ],
26
28
  description: 'Media property to return.'
27
29
  },
@@ -40,7 +42,9 @@
40
42
  enum: [
41
43
  'size',
42
44
  'width',
43
- 'height'
45
+ 'height',
46
+ 'darkMode',
47
+ 'darkModePreference'
44
48
  ],
45
49
  description: 'Media property to return.'
46
50
  },
@@ -12,15 +12,38 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import { getFromArray } from '@lowdefy/operators';
16
- function _menu({ params, menus, location }) {
17
- return getFromArray({
15
+ */ import { getFromArray, getFromObject } from '@lowdefy/operators';
16
+ import { type } from '@lowdefy/helpers';
17
+ function _menu({ params, arrayIndices, menus, location }) {
18
+ // Support dot-path access: _menu: menuId.path.into.links
19
+ if (type.isString(params) && params.includes('.')) {
20
+ const dotIndex = params.indexOf('.');
21
+ const menuId = params.slice(0, dotIndex);
22
+ const path = params.slice(dotIndex + 1);
23
+ const menu = menus.find((item)=>item.menuId === menuId);
24
+ if (!menu) return undefined;
25
+ const links = menu.links ?? [];
26
+ return getFromObject({
27
+ params: path,
28
+ object: links,
29
+ arrayIndices,
30
+ operator: '_menu',
31
+ location
32
+ });
33
+ }
34
+ const result = getFromArray({
18
35
  params,
19
36
  array: menus,
20
37
  key: 'menuId',
21
38
  operator: '_menu',
22
39
  location
23
40
  });
41
+ // When selecting a single menu, return its links array directly.
42
+ // _menu: true and { all: true } return the full menus array (result is an array).
43
+ if (result && !Array.isArray(result)) {
44
+ return result.links ?? [];
45
+ }
46
+ return result;
24
47
  }
25
48
  _menu.dynamic = true;
26
49
  export default _menu;
@@ -0,0 +1,26 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { getFromObject } from '@lowdefy/operators';
16
+ function _theme({ arrayIndices, location, theme, params }) {
17
+ return getFromObject({
18
+ arrayIndices,
19
+ location,
20
+ object: theme?._resolvedAntdToken ?? theme?.antd?.token ?? {},
21
+ operator: '_theme',
22
+ params
23
+ });
24
+ }
25
+ _theme.dynamic = true;
26
+ export default _theme;
@@ -38,16 +38,13 @@ const prep = (args)=>{
38
38
  return args;
39
39
  };
40
40
  const meta = {
41
- // Methods that use prep (default to current date when null) are marked dynamic
42
- // to prevent build-time evaluation freezing the date
43
41
  getDate: {
44
42
  singleArg: true,
45
43
  prep,
46
44
  validTypes: [
47
45
  'date',
48
46
  'null'
49
- ],
50
- dynamic: true
47
+ ]
51
48
  },
52
49
  getDay: {
53
50
  singleArg: true,
@@ -55,8 +52,7 @@ const meta = {
55
52
  validTypes: [
56
53
  'date',
57
54
  'null'
58
- ],
59
- dynamic: true
55
+ ]
60
56
  },
61
57
  getFullYear: {
62
58
  singleArg: true,
@@ -64,8 +60,7 @@ const meta = {
64
60
  validTypes: [
65
61
  'date',
66
62
  'null'
67
- ],
68
- dynamic: true
63
+ ]
69
64
  },
70
65
  getHours: {
71
66
  singleArg: true,
@@ -73,8 +68,7 @@ const meta = {
73
68
  validTypes: [
74
69
  'date',
75
70
  'null'
76
- ],
77
- dynamic: true
71
+ ]
78
72
  },
79
73
  getMilliseconds: {
80
74
  singleArg: true,
@@ -82,8 +76,7 @@ const meta = {
82
76
  validTypes: [
83
77
  'date',
84
78
  'null'
85
- ],
86
- dynamic: true
79
+ ]
87
80
  },
88
81
  getMinutes: {
89
82
  singleArg: true,
@@ -91,8 +84,7 @@ const meta = {
91
84
  validTypes: [
92
85
  'date',
93
86
  'null'
94
- ],
95
- dynamic: true
87
+ ]
96
88
  },
97
89
  getMonth: {
98
90
  singleArg: true,
@@ -100,8 +92,7 @@ const meta = {
100
92
  validTypes: [
101
93
  'date',
102
94
  'null'
103
- ],
104
- dynamic: true
95
+ ]
105
96
  },
106
97
  getSeconds: {
107
98
  singleArg: true,
@@ -109,8 +100,7 @@ const meta = {
109
100
  validTypes: [
110
101
  'date',
111
102
  'null'
112
- ],
113
- dynamic: true
103
+ ]
114
104
  },
115
105
  getTime: {
116
106
  singleArg: true,
@@ -118,8 +108,7 @@ const meta = {
118
108
  validTypes: [
119
109
  'date',
120
110
  'null'
121
- ],
122
- dynamic: true
111
+ ]
123
112
  },
124
113
  getTimezoneOffset: {
125
114
  singleArg: true,
@@ -127,8 +116,7 @@ const meta = {
127
116
  validTypes: [
128
117
  'date',
129
118
  'null'
130
- ],
131
- dynamic: true
119
+ ]
132
120
  },
133
121
  getUTCDate: {
134
122
  singleArg: true,
@@ -136,8 +124,7 @@ const meta = {
136
124
  validTypes: [
137
125
  'date',
138
126
  'null'
139
- ],
140
- dynamic: true
127
+ ]
141
128
  },
142
129
  getUTCDay: {
143
130
  singleArg: true,
@@ -145,8 +132,7 @@ const meta = {
145
132
  validTypes: [
146
133
  'date',
147
134
  'null'
148
- ],
149
- dynamic: true
135
+ ]
150
136
  },
151
137
  getUTCFullYear: {
152
138
  singleArg: true,
@@ -154,8 +140,7 @@ const meta = {
154
140
  validTypes: [
155
141
  'date',
156
142
  'null'
157
- ],
158
- dynamic: true
143
+ ]
159
144
  },
160
145
  getUTCHours: {
161
146
  singleArg: true,
@@ -163,8 +148,7 @@ const meta = {
163
148
  validTypes: [
164
149
  'date',
165
150
  'null'
166
- ],
167
- dynamic: true
151
+ ]
168
152
  },
169
153
  getUTCMilliseconds: {
170
154
  singleArg: true,
@@ -172,8 +156,7 @@ const meta = {
172
156
  validTypes: [
173
157
  'date',
174
158
  'null'
175
- ],
176
- dynamic: true
159
+ ]
177
160
  },
178
161
  getUTCMinutes: {
179
162
  singleArg: true,
@@ -181,8 +164,7 @@ const meta = {
181
164
  validTypes: [
182
165
  'date',
183
166
  'null'
184
- ],
185
- dynamic: true
167
+ ]
186
168
  },
187
169
  getUTCMonth: {
188
170
  singleArg: true,
@@ -190,8 +172,7 @@ const meta = {
190
172
  validTypes: [
191
173
  'date',
192
174
  'null'
193
- ],
194
- dynamic: true
175
+ ]
195
176
  },
196
177
  getUTCSeconds: {
197
178
  singleArg: true,
@@ -199,12 +180,10 @@ const meta = {
199
180
  validTypes: [
200
181
  'date',
201
182
  'null'
202
- ],
203
- dynamic: true
183
+ ]
204
184
  },
205
185
  now: {
206
- noArgs: true,
207
- dynamic: true
186
+ noArgs: true
208
187
  },
209
188
  parse: {
210
189
  singleArg: true,
@@ -212,8 +191,7 @@ const meta = {
212
191
  validTypes: [
213
192
  'string',
214
193
  'null'
215
- ],
216
- dynamic: true
194
+ ]
217
195
  },
218
196
  setDate: {
219
197
  namedArgs: [
@@ -371,8 +349,7 @@ const meta = {
371
349
  validTypes: [
372
350
  'date',
373
351
  'null'
374
- ],
375
- dynamic: true
352
+ ]
376
353
  },
377
354
  toISOString: {
378
355
  singleArg: true,
@@ -380,8 +357,7 @@ const meta = {
380
357
  validTypes: [
381
358
  'date',
382
359
  'null'
383
- ],
384
- dynamic: true
360
+ ]
385
361
  },
386
362
  toJSON: {
387
363
  singleArg: true,
@@ -389,8 +365,7 @@ const meta = {
389
365
  validTypes: [
390
366
  'date',
391
367
  'null'
392
- ],
393
- dynamic: true
368
+ ]
394
369
  },
395
370
  toString: {
396
371
  singleArg: true,
@@ -398,8 +373,7 @@ const meta = {
398
373
  validTypes: [
399
374
  'date',
400
375
  'null'
401
- ],
402
- dynamic: true
376
+ ]
403
377
  },
404
378
  toTimeString: {
405
379
  singleArg: true,
@@ -407,8 +381,7 @@ const meta = {
407
381
  validTypes: [
408
382
  'date',
409
383
  'null'
410
- ],
411
- dynamic: true
384
+ ]
412
385
  },
413
386
  toUTCString: {
414
387
  singleArg: true,
@@ -416,8 +389,7 @@ const meta = {
416
389
  validTypes: [
417
390
  'date',
418
391
  'null'
419
- ],
420
- dynamic: true
392
+ ]
421
393
  },
422
394
  UTC: {
423
395
  namedArgs: [
@@ -446,7 +418,8 @@ const meta = {
446
418
  singleArg: true,
447
419
  validTypes: [
448
420
  'number',
449
- 'string'
421
+ 'string',
422
+ 'date'
450
423
  ]
451
424
  }
452
425
  };
@@ -475,6 +448,5 @@ function _date({ params, location, methodName }) {
475
448
  instanceType: 'date'
476
449
  });
477
450
  }
478
- _date.dynamic = false;
479
- _date.meta = meta;
451
+ _date.dynamic = true;
480
452
  export default _date;
@@ -91,5 +91,5 @@ function intl({ params, location, methodName }) {
91
91
  params
92
92
  });
93
93
  }
94
- intl.dynamic = false;
94
+ intl.dynamic = true;
95
95
  export default intl;
@@ -172,6 +172,16 @@ const meta = {
172
172
  'array'
173
173
  ]
174
174
  },
175
+ mod: {
176
+ namedArgs: [
177
+ 'dividend',
178
+ 'divisor'
179
+ ],
180
+ validTypes: [
181
+ 'object',
182
+ 'array'
183
+ ]
184
+ },
175
185
  pow: {
176
186
  namedArgs: [
177
187
  'base',
@@ -259,9 +269,11 @@ const meta = {
259
269
  property: true
260
270
  }
261
271
  };
272
+ const functions = Object.create(Math);
273
+ functions.mod = (a, b)=>a % b;
262
274
  function _math({ params, location, methodName }) {
263
275
  return runClass({
264
- functions: Math,
276
+ functions,
265
277
  location,
266
278
  meta,
267
279
  methodName,
@@ -94,7 +94,8 @@ const meta = {
94
94
  validTypes: [
95
95
  'array',
96
96
  'object'
97
- ]
97
+ ],
98
+ dynamic: true
98
99
  },
99
100
  toPrecision: {
100
101
  namedArgs: [
@@ -144,4 +145,5 @@ function _number({ params, location, methodName }) {
144
145
  });
145
146
  }
146
147
  _number.dynamic = false;
148
+ _number.meta = meta;
147
149
  export default _number;
@@ -61,4 +61,5 @@ export { default as _media } from './operators/client/media.js';
61
61
  export { default as _menu } from './operators/client/menu.js';
62
62
  export { default as _request_details } from './operators/client/request_details.js';
63
63
  export { default as _request } from './operators/client/request.js';
64
+ export { default as _theme } from './operators/client/theme.js';
64
65
  export { default as _url_query } from './operators/client/url_query.js';
package/dist/types.js CHANGED
@@ -12,11 +12,104 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import * as client from './operatorsClient.js';
16
- import * as server from './operatorsServer.js';
17
- export default {
15
+ */ export default {
18
16
  operators: {
19
- client: Object.keys(client),
20
- server: Object.keys(server)
17
+ client: [
18
+ '_actions',
19
+ '_and',
20
+ '_api',
21
+ '_args',
22
+ '_array',
23
+ '_base64',
24
+ '_date',
25
+ '_divide',
26
+ '_eq',
27
+ '_event',
28
+ '_event_log',
29
+ '_function',
30
+ '_get',
31
+ '_global',
32
+ '_gt',
33
+ '_gte',
34
+ '_if',
35
+ '_if_none',
36
+ '_index',
37
+ '_input',
38
+ '_intl',
39
+ '_js',
40
+ '_json',
41
+ '_location',
42
+ '_log',
43
+ '_lt',
44
+ '_lte',
45
+ '_math',
46
+ '_media',
47
+ '_menu',
48
+ '_ne',
49
+ '_not',
50
+ '_number',
51
+ '_object',
52
+ '_operator',
53
+ '_or',
54
+ '_product',
55
+ '_random',
56
+ '_regex',
57
+ '_request',
58
+ '_request_details',
59
+ '_state',
60
+ '_string',
61
+ '_subtract',
62
+ '_sum',
63
+ '_switch',
64
+ '_theme',
65
+ '_type',
66
+ '_uri',
67
+ '_url_query',
68
+ '_user'
69
+ ],
70
+ server: [
71
+ '_and',
72
+ '_args',
73
+ '_array',
74
+ '_base64',
75
+ '_date',
76
+ '_divide',
77
+ '_eq',
78
+ '_function',
79
+ '_get',
80
+ '_gt',
81
+ '_gte',
82
+ '_hash',
83
+ '_if',
84
+ '_if_none',
85
+ '_intl',
86
+ '_item',
87
+ '_js',
88
+ '_json',
89
+ '_log',
90
+ '_lt',
91
+ '_lte',
92
+ '_math',
93
+ '_ne',
94
+ '_not',
95
+ '_number',
96
+ '_object',
97
+ '_operator',
98
+ '_or',
99
+ '_payload',
100
+ '_product',
101
+ '_random',
102
+ '_regex',
103
+ '_secret',
104
+ '_state',
105
+ '_step',
106
+ '_string',
107
+ '_subtract',
108
+ '_sum',
109
+ '_switch',
110
+ '_type',
111
+ '_uri',
112
+ '_user'
113
+ ]
21
114
  }
22
115
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/operators-js",
3
- "version": "4.7.2",
3
+ "version": "5.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -43,14 +43,15 @@
43
43
  "dist/*"
44
44
  ],
45
45
  "dependencies": {
46
- "@lowdefy/helpers": "4.7.2",
47
- "@lowdefy/operators": "4.7.2"
46
+ "@lowdefy/helpers": "5.0.0",
47
+ "@lowdefy/operators": "5.0.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@jest/globals": "28.1.3",
51
- "@swc/cli": "0.1.63",
52
- "@swc/core": "1.3.99",
53
- "@swc/jest": "0.2.29",
51
+ "@lowdefy/node-utils": "5.0.0",
52
+ "@swc/cli": "0.8.0",
53
+ "@swc/core": "1.15.18",
54
+ "@swc/jest": "0.2.39",
54
55
  "jest": "28.1.3",
55
56
  "jest-environment-jsdom": "28.1.3"
56
57
  },
@@ -58,7 +59,7 @@
58
59
  "access": "public"
59
60
  },
60
61
  "scripts": {
61
- "build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
62
+ "build": "swc src --out-dir dist --config-file ../../../../.swcrc --cli-config-file ../../../../.swc-cli.json --copy-files",
62
63
  "clean": "rm -rf dist",
63
64
  "test": "TZ=UTC node --experimental-vm-modules node_modules/jest/bin/jest.js"
64
65
  }