@komaci/esm-generator 240.1.3 → 242.1.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.
- package/build/__tests__/adgAstGeneration.spec.d.ts +2 -0
- package/build/__tests__/adgAstGeneration.spec.js +31 -0
- package/build/__tests__/compositionAstGeneration.spec.d.ts +2 -0
- package/build/__tests__/compositionAstGeneration.spec.js +394 -0
- package/build/__tests__/fixtures-combined-files/exclude-partial-classProps-indirect-importRef-getter/actual.js +5 -1
- package/build/__tests__/fixtures-combined-files/include-all-indirect-importRef-getter-complex/actual.js +5 -1
- package/build/__tests__/fixtures-combined-files/include-class-prop-indirect-importRef-getter/actual.js +5 -1
- package/build/__tests__/fixtures-script-files/imports/actual.js +5 -1
- package/build/__tests__/fixtures-script-files/imports-namespaced/actual.js +5 -1
- package/build/__tests__/fixtures-script-files/wire-imports/actual.js +5 -1
- package/build/__tests__/functionAstGeneration.spec.d.ts +2 -0
- package/build/__tests__/functionAstGeneration.spec.js +412 -0
- package/build/__tests__/general-komaci-docs/import-types/source.js +5 -1
- package/build/__tests__/general-komaci-docs/template-component/source.js +3 -3
- package/build/__tests__/genericAstGeneration.spec.d.ts +2 -0
- package/build/__tests__/genericAstGeneration.spec.js +586 -0
- package/build/__tests__/index.spec.js +13 -9
- package/build/__tests__/komaci-ast-unit.spec.js +240 -448
- package/build/__tests__/komaci-bundle-module.fixtures.spec.js +1 -0
- package/build/__tests__/komaci-script-module.fixtures.spec.js +5 -1
- package/build/__tests__/komaci-template-module.fixtures.spec.js +2 -1
- package/build/componentAstProcessing.d.ts +34 -0
- package/build/componentAstProcessing.js +105 -0
- package/build/compositionAstGeneration.d.ts +76 -0
- package/build/compositionAstGeneration.js +299 -0
- package/build/functionAstGeneration.d.ts +81 -0
- package/build/functionAstGeneration.js +337 -0
- package/build/genericAstGeneration.d.ts +107 -0
- package/build/genericAstGeneration.js +600 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +85 -88
- package/build/types.d.ts +13 -2
- package/build/types.js +69 -1
- package/package.json +4 -4
- package/build/__tests__/modGenScript.spec.d.ts +0 -2
- package/build/__tests__/modGenScript.spec.js +0 -110
- package/build/__tests__/modGenTemplate.spec.d.ts +0 -2
- package/build/__tests__/modGenTemplate.spec.js +0 -196
- package/build/__tests__/shared.spec.d.ts +0 -2
- package/build/__tests__/shared.spec.js +0 -62
- package/build/__tests__/templateStrings.spec.d.ts +0 -2
- package/build/__tests__/templateStrings.spec.js +0 -130
- package/build/modGenScript.d.ts +0 -38
- package/build/modGenScript.js +0 -1027
- package/build/modGenTemplate.d.ts +0 -37
- package/build/modGenTemplate.js +0 -402
- package/build/shared.d.ts +0 -170
- package/build/shared.js +0 -588
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const common_shared_1 = require("@komaci/common-shared");
|
|
10
|
+
const types_1 = require("@babel/types");
|
|
11
|
+
const functionAstGeneration_1 = require("../functionAstGeneration");
|
|
12
|
+
const generator_1 = __importDefault(require("@babel/generator"));
|
|
13
|
+
const badImportRef_1 = require("./fixtures-source-code/badImportRef");
|
|
14
|
+
describe('hoistLocalFunction', () => {
|
|
15
|
+
const baseFilesPath = (0, path_1.join)(__dirname, 'general-komaci-docs/assorted-template-strings');
|
|
16
|
+
const src = (0, fs_1.readFileSync)((0, path_1.join)(baseFilesPath, 'source.js'), {
|
|
17
|
+
encoding: 'utf-8',
|
|
18
|
+
});
|
|
19
|
+
const ast = (0, common_shared_1.generateAstFromSrcCode)(src);
|
|
20
|
+
const { templateStrings } = (0, common_shared_1.getPropertyMetadataFromAst)(ast);
|
|
21
|
+
const firstTemplateStringFunc = {
|
|
22
|
+
generatedName: 't0',
|
|
23
|
+
type: common_shared_1.FunctionTypes.TEMPLATE_STRING,
|
|
24
|
+
componentAstNode: templateStrings[0],
|
|
25
|
+
requiredProperties: [],
|
|
26
|
+
};
|
|
27
|
+
const secondTemplateStringFunc = {
|
|
28
|
+
generatedName: 't1',
|
|
29
|
+
type: common_shared_1.FunctionTypes.TEMPLATE_STRING,
|
|
30
|
+
componentAstNode: templateStrings[1],
|
|
31
|
+
requiredProperties: [],
|
|
32
|
+
};
|
|
33
|
+
const imports = new Map();
|
|
34
|
+
imports.set('gql', {
|
|
35
|
+
generatorAlias: 'i1',
|
|
36
|
+
resourceName: 'lightning/graphql',
|
|
37
|
+
isFromInternalNamespace: true,
|
|
38
|
+
isFromSupportedLibrary: true,
|
|
39
|
+
name: 'gql',
|
|
40
|
+
komaciDocImportRef: '1/names/0',
|
|
41
|
+
usedInPriming: true,
|
|
42
|
+
staticallyAnalyzable: false,
|
|
43
|
+
});
|
|
44
|
+
imports.set('sneaky', {
|
|
45
|
+
generatorAlias: 'i2',
|
|
46
|
+
resourceName: 'snoop',
|
|
47
|
+
isFromInternalNamespace: true,
|
|
48
|
+
isFromSupportedLibrary: true,
|
|
49
|
+
name: 'sneaky',
|
|
50
|
+
komaciDocImportRef: '2/names/0',
|
|
51
|
+
usedInPriming: true,
|
|
52
|
+
staticallyAnalyzable: false,
|
|
53
|
+
});
|
|
54
|
+
const hoistedFirstFunc = (0, functionAstGeneration_1.hoistLocalFunction)(firstTemplateStringFunc, imports);
|
|
55
|
+
const hoistedSecondFunc = (0, functionAstGeneration_1.hoistLocalFunction)(secondTemplateStringFunc, imports);
|
|
56
|
+
it('can compose a template string for a public api prop', () => {
|
|
57
|
+
expect(hoistedFirstFunc).not.toBeUndefined();
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
59
|
+
expect(hoistedFirstFunc.type).toBe('FunctionDeclaration');
|
|
60
|
+
expect(hoistedFirstFunc.id.name).toBe('t0');
|
|
61
|
+
expect(hoistedFirstFunc.body.body).toHaveLength(1);
|
|
62
|
+
expect(hoistedFirstFunc.body.body[0].type).toBe('ReturnStatement');
|
|
63
|
+
expect(hoistedFirstFunc.body.body[0]
|
|
64
|
+
.argument?.type).toBe('TemplateLiteral');
|
|
65
|
+
expect(hoistedFirstFunc.body
|
|
66
|
+
.body[0].argument.expressions).toHaveLength(2);
|
|
67
|
+
expect(hoistedFirstFunc.body
|
|
68
|
+
.body[0].argument.expressions[0].type).toBe('MemberExpression');
|
|
69
|
+
expect(hoistedFirstFunc.body
|
|
70
|
+
.body[0].argument.expressions[0].object.name).toBe('props');
|
|
71
|
+
expect(hoistedFirstFunc.body
|
|
72
|
+
.body[0].argument.expressions[0].property.name).toBe('basicInit');
|
|
73
|
+
expect(hoistedFirstFunc.body
|
|
74
|
+
.body[0].argument.expressions[1].type).toBe('Identifier');
|
|
75
|
+
expect(hoistedFirstFunc.body
|
|
76
|
+
.body[0].argument.expressions[1].name).toBe('i2');
|
|
77
|
+
});
|
|
78
|
+
it('can compose a template string for an internal prop', () => {
|
|
79
|
+
expect(hoistedSecondFunc).not.toBeUndefined();
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
81
|
+
expect(hoistedSecondFunc.type).toBe('FunctionDeclaration');
|
|
82
|
+
expect(hoistedSecondFunc.id.name).toBe('t1');
|
|
83
|
+
expect(hoistedSecondFunc.body.body).toHaveLength(1);
|
|
84
|
+
expect(hoistedSecondFunc.body.body[0].type).toBe('ReturnStatement');
|
|
85
|
+
expect(hoistedSecondFunc.body.body[0]
|
|
86
|
+
.argument?.type).toBe('TaggedTemplateExpression');
|
|
87
|
+
expect(hoistedSecondFunc.body
|
|
88
|
+
.body[0].argument.quasi.expressions).toHaveLength(1);
|
|
89
|
+
expect(hoistedSecondFunc.body
|
|
90
|
+
.body[0].argument.tag.name).toBe('i1');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
describe('sanitizeFunction', () => {
|
|
94
|
+
const ast = (0, common_shared_1.generateAstFromSrcCode)(badImportRef_1.sourceClass);
|
|
95
|
+
const { getters } = (0, common_shared_1.getPropertyMetadataFromAst)(ast);
|
|
96
|
+
const imports = new Map();
|
|
97
|
+
imports.set('test', {
|
|
98
|
+
name: 'test',
|
|
99
|
+
resourceName: 'force/shared',
|
|
100
|
+
staticallyAnalyzable: false,
|
|
101
|
+
usedInPriming: true,
|
|
102
|
+
isFromInternalNamespace: true,
|
|
103
|
+
isFromSupportedLibrary: true,
|
|
104
|
+
generatorAlias: 'i0',
|
|
105
|
+
komaciDocImportRef: '0/names/0',
|
|
106
|
+
});
|
|
107
|
+
imports.set('bad', {
|
|
108
|
+
name: 'test',
|
|
109
|
+
resourceName: 'invalid/import',
|
|
110
|
+
isFromInternalNamespace: true,
|
|
111
|
+
isFromSupportedLibrary: false,
|
|
112
|
+
staticallyAnalyzable: false,
|
|
113
|
+
usedInPriming: true,
|
|
114
|
+
generatorAlias: 'i1',
|
|
115
|
+
komaciDocImportRef: '1/names/0',
|
|
116
|
+
});
|
|
117
|
+
it('should be able to clean up and hoist a function with valid import references', () => {
|
|
118
|
+
(0, functionAstGeneration_1.sanitizeFunction)(getters[0], imports);
|
|
119
|
+
const hoisted = (0, types_1.functionDeclaration)((0, types_1.identifier)('g0'), [(0, types_1.identifier)('props')], // make 'props' an input parameter to the hoisted getter
|
|
120
|
+
getters[0].node.body);
|
|
121
|
+
const generatedFunction = (0, generator_1.default)((0, types_1.file)((0, types_1.program)([hoisted])));
|
|
122
|
+
expect(generatedFunction.code).toBe(badImportRef_1.expectedGoodHoist);
|
|
123
|
+
});
|
|
124
|
+
it('should throw an error if we try to reference a bad input', () => {
|
|
125
|
+
expect(() => (0, functionAstGeneration_1.sanitizeFunction)(getters[1], imports)).toThrowError(new Error(`${common_shared_1.ERROR_PREFIX}: 'bad' does not map to valid import`));
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
describe('adgToExpression', () => {
|
|
129
|
+
it('returns valid adg function from komaci doc', () => {
|
|
130
|
+
const komaciDoc = {
|
|
131
|
+
adgs: [
|
|
132
|
+
{
|
|
133
|
+
properties: {
|
|
134
|
+
getter0: {
|
|
135
|
+
isPublic: false,
|
|
136
|
+
input: { type: 'ImportReference', value: '0/names/0' },
|
|
137
|
+
},
|
|
138
|
+
prop1: {
|
|
139
|
+
isPublic: true,
|
|
140
|
+
initial: {
|
|
141
|
+
type: 'ImportReference',
|
|
142
|
+
value: '0/names/0',
|
|
143
|
+
namespacedMember: 'p1',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
prop2: {
|
|
147
|
+
isPublic: true,
|
|
148
|
+
initial: {
|
|
149
|
+
type: 'ImportReference',
|
|
150
|
+
value: '1/names/0',
|
|
151
|
+
namespacedMember: 'p2',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
record1: {
|
|
155
|
+
isPublic: false,
|
|
156
|
+
input: { type: 'FunctionReference', value: 0 },
|
|
157
|
+
},
|
|
158
|
+
record2: {
|
|
159
|
+
isPublic: false,
|
|
160
|
+
input: { type: 'FunctionReference', value: 1 },
|
|
161
|
+
},
|
|
162
|
+
record3: {
|
|
163
|
+
isPublic: false,
|
|
164
|
+
input: { type: 'FunctionReference', value: 2 },
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
functions: [
|
|
168
|
+
{
|
|
169
|
+
type: 'WireFunction',
|
|
170
|
+
reference: { type: 'ImportReference', value: '2/names/0' },
|
|
171
|
+
input: [
|
|
172
|
+
{
|
|
173
|
+
type: 'ObjectValue',
|
|
174
|
+
value: {
|
|
175
|
+
recordId: {
|
|
176
|
+
type: 'PropertyReference',
|
|
177
|
+
value: 'prop1',
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
location: {
|
|
183
|
+
startLine: 19,
|
|
184
|
+
startColumn: 5,
|
|
185
|
+
endLine: 19,
|
|
186
|
+
endColumn: 45,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
type: 'WireFunction',
|
|
191
|
+
reference: { type: 'ImportReference', value: '2/names/0' },
|
|
192
|
+
input: [
|
|
193
|
+
{
|
|
194
|
+
type: 'ObjectValue',
|
|
195
|
+
value: {
|
|
196
|
+
recordId: {
|
|
197
|
+
type: 'PropertyReference',
|
|
198
|
+
value: 'getter0',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
location: {
|
|
204
|
+
startLine: 23,
|
|
205
|
+
startColumn: 5,
|
|
206
|
+
endLine: 23,
|
|
207
|
+
endColumn: 47,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
type: 'WireFunction',
|
|
212
|
+
reference: { type: 'ImportReference', value: '2/names/0' },
|
|
213
|
+
input: [
|
|
214
|
+
{
|
|
215
|
+
type: 'ObjectValue',
|
|
216
|
+
value: {
|
|
217
|
+
recordId: {
|
|
218
|
+
type: 'PropertyReference',
|
|
219
|
+
value: 'prop2',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
location: {
|
|
225
|
+
startLine: 27,
|
|
226
|
+
startColumn: 5,
|
|
227
|
+
endLine: 27,
|
|
228
|
+
endColumn: 45,
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
imports: [
|
|
235
|
+
{ resourceName: 'force/shared', names: ['*'] },
|
|
236
|
+
{ resourceName: 'laf/transformWire', names: ['*'] },
|
|
237
|
+
{ resourceName: 'lightning/uiRecordApi', names: ['getRecord'] },
|
|
238
|
+
],
|
|
239
|
+
exports: { default: { type: 'AdgReference', value: 0 } },
|
|
240
|
+
};
|
|
241
|
+
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
242
|
+
(0, common_shared_1.initializeImportMetdataFromKomaciDocument)(komaciDoc, moduleMetadata);
|
|
243
|
+
(0, common_shared_1.initalizeAdgMetadata)(0, komaciDoc, moduleMetadata, false, false);
|
|
244
|
+
const adgMetadata = moduleMetadata.adgs.get(0);
|
|
245
|
+
const result = (0, functionAstGeneration_1.adgToExpression)(adgMetadata, moduleMetadata);
|
|
246
|
+
expect(result).not.toBeUndefined();
|
|
247
|
+
expect(result.arguments).toHaveLength(5);
|
|
248
|
+
expect(result.arguments[0].type).toBe('Identifier');
|
|
249
|
+
expect(result.arguments[0].name).toBe('undefined');
|
|
250
|
+
expect(result.arguments[1].type).toBe('ObjectExpression');
|
|
251
|
+
expect(result.arguments[2].type).toBe('ArrayExpression');
|
|
252
|
+
expect(result.arguments[2].elements).toHaveLength(3);
|
|
253
|
+
expect(result.arguments[3].type).toBe('Identifier');
|
|
254
|
+
expect(result.arguments[3].name).toBe('comp1');
|
|
255
|
+
expect(result.arguments[4].type).toBe('ArrayExpression');
|
|
256
|
+
});
|
|
257
|
+
it('returns valid adg function from komaci doc with local parent', () => {
|
|
258
|
+
const komaciDoc = {
|
|
259
|
+
adgs: [
|
|
260
|
+
{
|
|
261
|
+
properties: {
|
|
262
|
+
parentProp: {
|
|
263
|
+
isPublic: true,
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
parentClass: {
|
|
269
|
+
type: 'AdgReference',
|
|
270
|
+
value: 0,
|
|
271
|
+
},
|
|
272
|
+
properties: {
|
|
273
|
+
testProp: {
|
|
274
|
+
isPublic: false,
|
|
275
|
+
input: {
|
|
276
|
+
type: 'FunctionReference',
|
|
277
|
+
value: 0,
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
functions: [
|
|
282
|
+
{
|
|
283
|
+
type: 'WireFunction',
|
|
284
|
+
reference: {
|
|
285
|
+
type: 'ImportReference',
|
|
286
|
+
value: '0/names/0',
|
|
287
|
+
},
|
|
288
|
+
input: [
|
|
289
|
+
{
|
|
290
|
+
type: 'ObjectValue',
|
|
291
|
+
value: {
|
|
292
|
+
id: {
|
|
293
|
+
type: 'PropertyReference',
|
|
294
|
+
value: 'parentProp',
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
},
|
|
302
|
+
],
|
|
303
|
+
imports: [
|
|
304
|
+
{
|
|
305
|
+
resourceName: 'lightning/uiRecordApi',
|
|
306
|
+
names: ['getRecord'],
|
|
307
|
+
},
|
|
308
|
+
],
|
|
309
|
+
exports: {
|
|
310
|
+
Foo: {
|
|
311
|
+
type: 'AdgReference',
|
|
312
|
+
value: 0,
|
|
313
|
+
},
|
|
314
|
+
default: {
|
|
315
|
+
type: 'AdgReference',
|
|
316
|
+
value: 1,
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
321
|
+
(0, common_shared_1.initializeImportMetdataFromKomaciDocument)(komaciDoc, moduleMetadata);
|
|
322
|
+
(0, common_shared_1.initalizeAdgMetadata)(1, komaciDoc, moduleMetadata, false, false);
|
|
323
|
+
const adgMetadata = moduleMetadata.adgs.get(1);
|
|
324
|
+
const result = (0, functionAstGeneration_1.adgToExpression)(adgMetadata, moduleMetadata);
|
|
325
|
+
expect(result).not.toBeUndefined();
|
|
326
|
+
expect(result).not.toBeUndefined();
|
|
327
|
+
expect(result.arguments).toHaveLength(5);
|
|
328
|
+
expect(result.arguments[0].type).toBe('CallExpression');
|
|
329
|
+
expect(result.arguments[0].callee.name).toBe('adg0');
|
|
330
|
+
expect(result.arguments[1].type).toBe('ObjectExpression');
|
|
331
|
+
expect(result.arguments[2].type).toBe('ArrayExpression');
|
|
332
|
+
expect(result.arguments[2].elements).toHaveLength(1);
|
|
333
|
+
expect(result.arguments[3].type).toBe('Identifier');
|
|
334
|
+
expect(result.arguments[3].name).toBe('comp1');
|
|
335
|
+
expect(result.arguments[4].type).toBe('ArrayExpression');
|
|
336
|
+
});
|
|
337
|
+
it('returns valid adg function from komaci doc with import parent', () => {
|
|
338
|
+
const komaciDoc = {
|
|
339
|
+
adgs: [
|
|
340
|
+
{
|
|
341
|
+
properties: {
|
|
342
|
+
getterProp: {
|
|
343
|
+
isPublic: false,
|
|
344
|
+
input: {
|
|
345
|
+
type: 'ImportReference',
|
|
346
|
+
value: '0/names/0',
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
parentClass: {
|
|
351
|
+
type: 'ImportReference',
|
|
352
|
+
value: '1/names/0',
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
imports: [
|
|
357
|
+
{
|
|
358
|
+
resourceName: 'force/shared',
|
|
359
|
+
names: ['default'],
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
resourceName: '@salesforce/komaci/force__shared__shared.js',
|
|
363
|
+
names: ['default'],
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
exports: {
|
|
367
|
+
default: {
|
|
368
|
+
type: 'AdgReference',
|
|
369
|
+
value: 0,
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
374
|
+
(0, common_shared_1.initializeImportMetdataFromKomaciDocument)(komaciDoc, moduleMetadata);
|
|
375
|
+
(0, common_shared_1.initalizeAdgMetadata)(0, komaciDoc, moduleMetadata, false, false);
|
|
376
|
+
const adgMetadata = moduleMetadata.adgs.get(0);
|
|
377
|
+
const result = (0, functionAstGeneration_1.adgToExpression)(adgMetadata, moduleMetadata);
|
|
378
|
+
expect(result).not.toBeUndefined();
|
|
379
|
+
expect(result.arguments).toHaveLength(5);
|
|
380
|
+
expect(result.arguments[0].type).toBe('CallExpression');
|
|
381
|
+
expect(result.arguments[0].callee.name).toBe('i1');
|
|
382
|
+
expect(result.arguments[1].type).toBe('ObjectExpression');
|
|
383
|
+
expect(result.arguments[2].type).toBe('ArrayExpression');
|
|
384
|
+
expect(result.arguments[2].elements).toHaveLength(0);
|
|
385
|
+
expect(result.arguments[3].type).toBe('Identifier');
|
|
386
|
+
expect(result.arguments[3].name).toBe('comp1');
|
|
387
|
+
expect(result.arguments[4].type).toBe('ArrayExpression');
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
describe('produceErrorAdgFunction', () => {
|
|
391
|
+
it('should produce a resolvable module with an adg with only one node that shows what the error was', () => {
|
|
392
|
+
const expected = `export default function (fct, ctx) {
|
|
393
|
+
const {
|
|
394
|
+
adg
|
|
395
|
+
} = fct;
|
|
396
|
+
return adg(undefined, {}, [{
|
|
397
|
+
t: "ErrorFunction",
|
|
398
|
+
c: {
|
|
399
|
+
"error": "something bad happened",
|
|
400
|
+
"stack": "full stack normally"
|
|
401
|
+
}
|
|
402
|
+
}], (fct, ctx) => {
|
|
403
|
+
return [];
|
|
404
|
+
}, []);
|
|
405
|
+
}`;
|
|
406
|
+
const testError = new Error('something bad happened');
|
|
407
|
+
testError.stack = 'full stack normally';
|
|
408
|
+
const res = (0, functionAstGeneration_1.produceErrorAdgFunction)((0, common_shared_1.initModuleMetadataObject)(), testError);
|
|
409
|
+
expect((0, generator_1.default)((0, types_1.file)(res)).code).toBe(expected);
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
//# sourceMappingURL=functionAstGeneration.spec.js.map
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const shared_1 = require("force/shared");
|
|
13
|
-
const
|
|
13
|
+
const uiRecordApi_1 = require("lightning/uiRecordApi");
|
|
14
14
|
const crazycool_1 = __importDefault(require("@salesforce/label/crazycool"));
|
|
15
15
|
const lightning_1 = require("lightning");
|
|
16
16
|
const import_1 = __importDefault(require("bad/import"));
|
|
@@ -25,10 +25,10 @@ __decorate([
|
|
|
25
25
|
lightning_1.api
|
|
26
26
|
], Component.prototype, "recordId", void 0);
|
|
27
27
|
__decorate([
|
|
28
|
-
(0, lightning_1.wire)(
|
|
28
|
+
(0, lightning_1.wire)(uiRecordApi_1.getRecord, { id: '$contractId' })
|
|
29
29
|
], Component.prototype, "contract", void 0);
|
|
30
30
|
__decorate([
|
|
31
|
-
(0, lightning_1.wire)(
|
|
31
|
+
(0, lightning_1.wire)(uiRecordApi_1.getRecord, { id: '$malicious' })
|
|
32
32
|
], Component.prototype, "account", void 0);
|
|
33
33
|
exports.default = Component;
|
|
34
34
|
//# sourceMappingURL=source.js.map
|