@fugood/bricks-ctor 2.25.0-beta.36 → 2.25.0-beta.37

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.
@@ -3,8 +3,9 @@ import { compile } from '../index'
3
3
  const SUBSPACE_ID = 'SUBSPACE_00000000-0000-0000-0000-000000000001'
4
4
  const CANVAS_ID = 'CANVAS_00000000-0000-0000-0000-000000000001'
5
5
  const ANIMATION_ID = 'ANIMATION_00000000-0000-0000-0000-000000000001'
6
+ const DATA_ID = 'PROPERTY_BANK_DATA_NODE_00000000-0000-0000-0000-000000000001'
6
7
 
7
- const makeApp = (animations) => {
8
+ const makeApp = (animations = [], data = []) => {
8
9
  const rootCanvas = {
9
10
  __typename: 'Canvas',
10
11
  id: CANVAS_ID,
@@ -23,7 +24,7 @@ const makeApp = (animations) => {
23
24
  animations,
24
25
  bricks: [],
25
26
  generators: [],
26
- data: [],
27
+ data,
27
28
  dataRouting: [],
28
29
  dataCalculation: [],
29
30
  }
@@ -35,6 +36,13 @@ const makeApp = (animations) => {
35
36
  }
36
37
  }
37
38
 
39
+ const makeData = (remoteUpdate) => ({
40
+ __typename: 'Data',
41
+ id: DATA_ID,
42
+ type: 'string',
43
+ remoteUpdate,
44
+ })
45
+
38
46
  describe('compile animations', () => {
39
47
  test('normalizes mixed legacy spring config', async () => {
40
48
  const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
@@ -113,3 +121,32 @@ describe('compile animations', () => {
113
121
  ).rejects.toThrow(/Invalid animation config type/)
114
122
  })
115
123
  })
124
+
125
+ describe('compile data remote update', () => {
126
+ test.each([
127
+ [undefined, { bank_type: 'none' }],
128
+ [{ type: 'auto' }, { bank_type: 'create', enable_remote_update: true }],
129
+ [
130
+ { type: 'device-specific' },
131
+ {
132
+ bank_type: 'create-device-specific',
133
+ enable_remote_update: true,
134
+ use_remote_id_prefix: true,
135
+ },
136
+ ],
137
+ [
138
+ { type: 'global-data', id: 'GLOBAL_PROP_1' },
139
+ {
140
+ bank_type: 'global',
141
+ enable_remote_update: true,
142
+ global_remote_update_prop: 'GLOBAL_PROP_1',
143
+ },
144
+ ],
145
+ ])('emits bank_type for %p', async (remoteUpdate, expectedRemoteUpdate) => {
146
+ const config = await compile(makeApp([], [makeData(remoteUpdate)]))
147
+
148
+ expect(config.subspace_map[SUBSPACE_ID].property_bank_map[DATA_ID]).toMatchObject(
149
+ expectedRemoteUpdate,
150
+ )
151
+ })
152
+ })
package/compile/index.ts CHANGED
@@ -513,9 +513,10 @@ const compileKind = (kind: Data['kind']) => {
513
513
  }
514
514
 
515
515
  const compileRemoteUpdate = (remoteUpdate: Data['remoteUpdate']) => {
516
- if (!remoteUpdate) return {}
517
- if (remoteUpdate.type === 'auto') return { enable_remote_update: true }
516
+ if (!remoteUpdate) return { bank_type: 'none' }
517
+ if (remoteUpdate.type === 'auto') return { bank_type: 'create', enable_remote_update: true }
518
518
  return {
519
+ bank_type: remoteUpdate.type === 'device-specific' ? 'create-device-specific' : 'global',
519
520
  enable_remote_update: true,
520
521
  ...(remoteUpdate.type === 'device-specific' ? { use_remote_id_prefix: true } : {}),
521
522
  ...(remoteUpdate.type === 'global-data' ? { global_remote_update_prop: remoteUpdate.id } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fugood/bricks-ctor",
3
- "version": "2.25.0-beta.36",
3
+ "version": "2.25.0-beta.37",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "typecheck": "tsc --noEmit",
@@ -25,5 +25,5 @@
25
25
  "peerDependencies": {
26
26
  "oxfmt": "^0.36.0"
27
27
  },
28
- "gitHead": "c53e96e4dfcea862106a3492ea01a6d080d26881"
28
+ "gitHead": "53740bd4fb9ec122c5510d9935fd43878f440eca"
29
29
  }