@lowdefy/operators-js 5.6.0 → 6.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.
@@ -22,5 +22,5 @@ function _env({ arrayIndices, env, location, params }) {
22
22
  params
23
23
  });
24
24
  }
25
- _env.dynamic = false;
25
+ _env.dynamic = true;
26
26
  export default _env;
@@ -0,0 +1,47 @@
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 { ReservedKeyError, applyArrayIndices, get, type } from '@lowdefy/helpers';
16
+ function _websocket({ arrayIndices, params, websockets }) {
17
+ if (!type.isString(params)) {
18
+ throw new Error(`_websocket accepts a string value.`);
19
+ }
20
+ if (type.isNone(websockets)) {
21
+ return null;
22
+ }
23
+ const splitKey = params.split('.');
24
+ const [websocketId, ...keyParts] = splitKey;
25
+ const channel = websockets[websocketId];
26
+ if (type.isNone(channel)) {
27
+ return null;
28
+ }
29
+ if (splitKey.length === 1) {
30
+ return channel;
31
+ }
32
+ const key = keyParts.reduce((acc, value)=>acc === '' ? value : acc.concat('.', value), '');
33
+ try {
34
+ return get(channel, applyArrayIndices(arrayIndices, key), {
35
+ copy: true,
36
+ default: null
37
+ });
38
+ } catch (error) {
39
+ // A runtime read: the key comes from app data or an author keypath evaluated at render time,
40
+ // and there is no config location to attach in the browser. The reserved rule's job — refusing
41
+ // the read — is already done, so degrade to the miss value rather than crashing the page.
42
+ if (error instanceof ReservedKeyError) return null;
43
+ throw error;
44
+ }
45
+ }
46
+ _websocket.dynamic = true;
47
+ export default _websocket;
@@ -13,14 +13,24 @@
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
+ import { ConfigError } from '@lowdefy/errors';
17
+ import { type } from '@lowdefy/helpers';
16
18
  function _app({ arrayIndices, location, lowdefyApp, params }) {
17
- return getFromObject({
19
+ const value = getFromObject({
18
20
  arrayIndices,
19
21
  location,
20
22
  object: lowdefyApp,
21
23
  operator: '_app',
22
24
  params
23
25
  });
26
+ if (params === 'slug' && type.isNone(value)) {
27
+ throw new ConfigError('`slug` is required on the app but is not set. Declare `slug` in `lowdefy.yaml`.', {
28
+ received: {
29
+ slug: value
30
+ }
31
+ });
32
+ }
33
+ return value;
24
34
  }
25
- _app.dynamic = true;
35
+ _app.dynamic = false;
26
36
  export default _app;
@@ -13,6 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import _and from './operators/shared/and.js';
16
+ import _app from './operators/shared/app.js';
16
17
  import _args from './operators/shared/args.js';
17
18
  import _array from './operators/shared/array.js';
18
19
  import _boolean from './operators/shared/boolean.js';
@@ -51,6 +52,7 @@ import _hash from './operators/server/hash.js';
51
52
  import _env from './operators/build/env.js';
52
53
  export default {
53
54
  _and,
55
+ _app,
54
56
  _args,
55
57
  _array,
56
58
  _base64,
@@ -67,3 +67,4 @@ export { default as _request_details } from './operators/client/request_details.
67
67
  export { default as _request } from './operators/client/request.js';
68
68
  export { default as _theme } from './operators/client/theme.js';
69
69
  export { default as _url_query } from './operators/client/url_query.js';
70
+ export { default as _websocket } from './operators/client/websocket.js';
package/dist/types.js CHANGED
@@ -69,7 +69,8 @@
69
69
  '_type',
70
70
  '_uri',
71
71
  '_url_query',
72
- '_user'
72
+ '_user',
73
+ '_websocket'
73
74
  ],
74
75
  server: [
75
76
  '_and',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/operators-js",
3
- "version": "5.6.0",
3
+ "version": "6.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -43,15 +43,16 @@
43
43
  "dist/*"
44
44
  ],
45
45
  "dependencies": {
46
- "@lowdefy/helpers": "5.6.0",
47
- "@lowdefy/operators": "5.6.0",
46
+ "@lowdefy/errors": "6.0.0",
47
+ "@lowdefy/helpers": "6.0.0",
48
+ "@lowdefy/operators": "6.0.0",
48
49
  "intl-messageformat": "11.2.7"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@jest/globals": "28.1.3",
52
- "@lowdefy/node-utils": "5.6.0",
53
- "@swc/cli": "0.8.0",
54
- "@swc/core": "1.15.18",
53
+ "@lowdefy/node-utils": "6.0.0",
54
+ "@swc/cli": "0.8.1",
55
+ "@swc/core": "1.15.32",
55
56
  "@swc/jest": "0.2.39",
56
57
  "jest": "28.1.3",
57
58
  "jest-environment-jsdom": "28.1.3"