@salesforce/lds-ads-bridge 0.1.0-dev1

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.
@@ -0,0 +1,47 @@
1
+ import resolve from '@rollup/plugin-node-resolve';
2
+ import typescript from '@rollup/plugin-typescript';
3
+
4
+ import * as packageJson from './package.json';
5
+ import { buildBanner, buildFooter, copyrightHeaderPlugin } from '../../scripts/rollup/rollup-utils';
6
+
7
+ const banner = buildBanner(true);
8
+ const footer = buildFooter(packageJson.version);
9
+
10
+ const adsBridge = {
11
+ input: './src/main.ts',
12
+ external: ['@salesforce/lds-adapters-uiapi', '@salesforce/lds-default-luvio'],
13
+ output: {
14
+ file: 'dist/adsBridge.js',
15
+ format: 'esm',
16
+ banner,
17
+ footer,
18
+ paths: {
19
+ '@salesforce/lds-default-luvio': 'force/ldsEngine',
20
+ '@salesforce/lds-adapters-uiapi': 'force/ldsAdaptersUiapi',
21
+ },
22
+ },
23
+ plugins: [
24
+ copyrightHeaderPlugin,
25
+ resolve(),
26
+ typescript({
27
+ declarationDir: 'types',
28
+ }),
29
+ ],
30
+ };
31
+
32
+ const adsBridgeForPerfTest = {
33
+ input: './src/ads-bridge.ts',
34
+ output: {
35
+ file: 'dist/ads-bridge-perf.js',
36
+ format: 'esm',
37
+ },
38
+ plugins: [
39
+ copyrightHeaderPlugin,
40
+ resolve(),
41
+ typescript({
42
+ declaration: false,
43
+ }),
44
+ ],
45
+ };
46
+
47
+ export default [adsBridge, adsBridgeForPerfTest];
@@ -0,0 +1,83 @@
1
+ import { Luvio, InMemoryStore, Environment } from '@luvio/engine';
2
+ import AdsBridge from '../../dist/ads-bridge-perf';
3
+ import { ingestRecord, ingestObjectInfo } from '@salesforce/lds-adapters-uiapi';
4
+
5
+ import mockObjectInfo from './mocks/custom-proto-medium-object-info';
6
+ import mockRecord from './mocks/custom-proto-medium-record';
7
+
8
+ function cloneObjectInfo(data) {
9
+ return JSON.parse(data);
10
+ }
11
+
12
+ function cloneRecord(data) {
13
+ const copy = JSON.parse(data);
14
+ copy.id = `aJ9x00000000001CA0`;
15
+
16
+ Object.keys(copy.fields).forEach((key, index) => {
17
+ const field = copy.fields[key];
18
+ if (field.value && field.value.id) {
19
+ field.value.id = `aJ9x00000000001C0${index}`;
20
+ }
21
+ });
22
+
23
+ return copy;
24
+ }
25
+
26
+ describe('Luvio to ADS bridge', () => {
27
+ benchmark('emitting single record without object info', () => {
28
+ let luvio;
29
+ let adsBridge;
30
+ before(() => {
31
+ const store = new InMemoryStore();
32
+ luvio = new Luvio(new Environment(store, () => new Promise(() => {})));
33
+ adsBridge = new AdsBridge(luvio);
34
+ const time = Date.now();
35
+
36
+ ingestRecord(
37
+ cloneRecord(mockRecord),
38
+ { fullPath: 'record', parent: null },
39
+ luvio,
40
+ store,
41
+ time
42
+ );
43
+
44
+ adsBridge.receiveFromLdsCallback = () => {};
45
+ });
46
+
47
+ run(() => {
48
+ luvio.storeBroadcast();
49
+ });
50
+ });
51
+
52
+ benchmark('emitting single record with object info', () => {
53
+ let luvio;
54
+ let adsBridge;
55
+ before(() => {
56
+ const store = new InMemoryStore();
57
+ luvio = new Luvio(new Environment(store, () => new Promise(() => {})));
58
+ adsBridge = new AdsBridge(luvio);
59
+ const time = Date.now();
60
+
61
+ ingestObjectInfo(
62
+ cloneObjectInfo(mockObjectInfo),
63
+ { fullPath: 'object-info', parent: null },
64
+ luvio,
65
+ store,
66
+ time
67
+ );
68
+ ingestRecord(
69
+ cloneRecord(mockRecord),
70
+ { fullPath: 'record', parent: null },
71
+ luvio,
72
+ store,
73
+ time
74
+ );
75
+
76
+ adsBridge.receiveFromLdsCallback = () => {};
77
+ });
78
+
79
+ run(() => {
80
+ luvio.storeBroadcast();
81
+ });
82
+ });
83
+ });