@komaci/common-shared 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.
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPropertyFromImport = exports.isPropertyAWire = exports.updatePropertyUsage = exports.updatePropertyMetadataFromTemplateDoc = exports.updatePropertiesForComposition = exports.collectPropertyMetadataFromScriptDoc = exports.traverseParentAdgs = exports.traverseInput = exports.initializePropertiesMap = exports.stripChildReferenceFromValue = exports.isImportValid = exports.isAFunctionOfType = exports.isFunctionReference = exports.isSrcABinding = exports.isSrcPrimitiveValue = exports.isCompositionAnImage = exports.isCompositionAComposedAdg = exports.isCompositionAnIteration = void 0;
3
+ exports.importToComponentId = exports.isPropertyFromImport = exports.updatePropertyUsage = exports.updatePropertiesForComposition = exports.traverseComposition = exports.doesAdgExist = exports.traverseParentAdgs = exports.traverseInput = exports.processFreestandingFunctions = exports.initializePropertiesMap = exports.stripChildReferenceFromValue = exports.isImportValid = exports.isAFunctionOfType = exports.isValueProperty = exports.isFunctionReference = exports.isSrcABinding = exports.isSrcPrimitiveValue = exports.isCompositionAnImage = exports.isCompositionAComposedAdg = exports.isCompositionAContainer = exports.isCompositionASlot = exports.isCompositionAnIteration = void 0;
4
4
  const types_1 = require("./types");
5
+ const moduleMetadata_1 = require("./moduleMetadata");
5
6
  /**
6
7
  * Check if the composition is an Iteration
7
8
  * @param composition composition obj to check
@@ -11,6 +12,24 @@ function isCompositionAnIteration(composition) {
11
12
  return composition?.type === 'Iteration';
12
13
  }
13
14
  exports.isCompositionAnIteration = isCompositionAnIteration;
15
+ /**
16
+ * Check if the composition is a Slot
17
+ * @param composition composition obj to check
18
+ * @returns if composition is a Slot
19
+ */
20
+ function isCompositionASlot(composition) {
21
+ return composition?.type === 'Slot';
22
+ }
23
+ exports.isCompositionASlot = isCompositionASlot;
24
+ /**
25
+ * Check if the composition is an Iteration
26
+ * @param composition composition obj to check
27
+ * @returns if composition is an Iteration
28
+ */
29
+ function isCompositionAContainer(composition) {
30
+ return composition?.type === 'Container';
31
+ }
32
+ exports.isCompositionAContainer = isCompositionAContainer;
14
33
  /**
15
34
  * Check if the composition is a ComposedAdg
16
35
  * @param composition composition obj to check
@@ -56,6 +75,15 @@ function isFunctionReference(node) {
56
75
  return node?.type === 'FunctionReference';
57
76
  }
58
77
  exports.isFunctionReference = isFunctionReference;
78
+ /**
79
+ * Check if input is a property reference
80
+ * @param node input to check
81
+ * @returns if it is a property reference
82
+ */
83
+ function isValueProperty(node) {
84
+ return node?.type === 'PropertyReference';
85
+ }
86
+ exports.isValueProperty = isValueProperty;
59
87
  /**
60
88
  * Confirm if a function object is of a specfic type
61
89
  * @param type The type to validate against
@@ -104,78 +132,142 @@ exports.stripChildReferenceFromValue = stripChildReferenceFromValue;
104
132
  *
105
133
  * @param component The component ADG to process
106
134
  * @param doc The full komaci doc we are looking in
135
+ * @param moduleMetadata Data structure of metadata about the component we are analyzing
107
136
  * @returns The inflated properties map
108
137
  */
109
- function initializePropertiesMap(component, doc, properties) {
110
- if (component.properties) {
111
- for (const [name, detail] of Object.entries(component.properties)) {
138
+ function initializePropertiesMap(adgProperties, adgFunctions, adgIndex, doc, moduleMetadata, properties = new Map()) {
139
+ const adgMetadata = moduleMetadata.adgs.get(adgIndex);
140
+ if (adgMetadata && adgProperties) {
141
+ for (const [name, detail] of Object.entries(adgProperties)) {
112
142
  const property = {
113
143
  usedInPriming: false,
114
- type: types_1.PropertyTypes.INTERNAL,
144
+ type: types_1.PropertyTypes.BASE,
145
+ isPublic: false,
146
+ fromAdg: adgIndex,
115
147
  };
116
148
  if (detail.isPublic) {
117
- property.type = types_1.PropertyTypes.PUBLIC;
149
+ property.isPublic = true;
118
150
  }
119
- else if (isAFunctionOfType('WireFunction', detail, component.functions) &&
120
- doc.imports) {
151
+ else if (isAFunctionOfType('WireFunction', detail, adgFunctions)) {
121
152
  //ts rules and this is how types work ig
122
- const functionDetail = component.functions?.[detail.input.value];
153
+ const functionDetail = adgFunctions?.[detail.input.value];
123
154
  if (functionDetail) {
124
- const importIndex = parseInt(functionDetail.reference.value.charAt(0));
125
- const nameIndex = parseInt(functionDetail?.reference.value.charAt(functionDetail?.reference.value.length - 1));
126
- if (isImportValid(importIndex, nameIndex, doc.imports)) {
127
- property.type = types_1.PropertyTypes.WIRE;
128
- property.usedInPriming = true;
129
- property.wire = {
130
- name: doc.imports[importIndex].names[nameIndex],
131
- resourceName: doc.imports[importIndex].resourceName,
132
- komaciDocImportRef: functionDetail.reference.value,
133
- };
155
+ functionDetail.visited = true;
156
+ const wireImport = (0, moduleMetadata_1.reconcileWireReference)(functionDetail, adgMetadata, moduleMetadata);
157
+ property.type = types_1.PropertyTypes.WIRE;
158
+ if (wireImport) {
159
+ const wireFunction = (0, moduleMetadata_1.composeWireFunctionMetadata)(functionDetail, wireImport, moduleMetadata);
160
+ const isFunctionUnsupported = wireFunction.importReference.functionName ===
161
+ types_1.IdKeys.UNRESOLVED_VALUE;
162
+ if (isFunctionUnsupported) {
163
+ adgMetadata.requiredAdgFactoryFunctions.add(types_1.IdKeys.UNRESOLVED_VALUE);
164
+ property.functionIndex =
165
+ types_1.UNSUPPORTED_FUNCTION;
166
+ }
167
+ else {
168
+ const functionsLength = adgMetadata.functions.push(wireFunction);
169
+ property.functionIndex =
170
+ functionsLength - 1;
171
+ }
172
+ }
173
+ else {
174
+ property.functionIndex =
175
+ types_1.UNSUPPORTED_FUNCTION;
134
176
  }
135
177
  }
136
178
  }
137
- if (detail.initial?.type === 'ImportReference' && doc.imports) {
138
- const importIndex = parseInt(detail.initial.value.charAt(0));
139
- const nameIndex = parseInt(detail.initial.value.charAt(detail.initial.value.length - 1));
140
- if (isImportValid(importIndex, nameIndex, doc.imports)) {
141
- property.imports = {
142
- [detail.initial.value]: {
143
- name: doc.imports[importIndex].names[nameIndex],
144
- resourceName: doc.imports[importIndex].resourceName,
145
- komaciDocImportRef: detail.initial.value,
146
- },
147
- };
179
+ if (!adgMetadata.hasSourceFile &&
180
+ detail.input?.type === 'ImportReference' &&
181
+ moduleMetadata.importIndexReference.has(detail.input.value) &&
182
+ moduleMetadata.importsByName.has(
183
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
184
+ moduleMetadata.importIndexReference.get(detail.input.value))) {
185
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
186
+ const importMetadata = moduleMetadata.importsByName.get(
187
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
188
+ moduleMetadata.importIndexReference.get(detail.input.value));
189
+ if (!importMetadata.isFromInternalNamespace ||
190
+ !importMetadata.isFromSupportedLibrary) {
191
+ property.type = types_1.PropertyTypes.GETTER;
192
+ adgMetadata.requiredAdgFactoryFunctions.add(types_1.IdKeys.UNRESOLVED_VALUE);
193
+ property.functionIndex =
194
+ types_1.UNSUPPORTED_FUNCTION;
195
+ }
196
+ else {
197
+ detail.initial = detail.input;
148
198
  }
149
199
  }
150
- else if (detail.initial && doc.imports) {
151
- const imports = {};
152
- let totalImportRefs = 0;
200
+ else if (!adgMetadata.hasSourceFile &&
201
+ detail.input?.type === 'Unresolved') {
202
+ property.type = types_1.PropertyTypes.GETTER;
203
+ adgMetadata.requiredAdgFactoryFunctions.add(types_1.IdKeys.UNRESOLVED_VALUE);
204
+ property.functionIndex =
205
+ types_1.UNSUPPORTED_FUNCTION;
206
+ }
207
+ if (detail.initial?.type === 'ImportReference' &&
208
+ moduleMetadata.importIndexReference.has(detail.initial.value) &&
209
+ moduleMetadata.importsByName.has(
210
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
211
+ moduleMetadata.importIndexReference.get(detail.initial.value))) {
212
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
213
+ const importMetadata = moduleMetadata.importsByName.get(
214
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
215
+ moduleMetadata.importIndexReference.get(detail.initial.value));
216
+ importMetadata.usedInPriming = true;
217
+ property.inital = detail.initial;
218
+ }
219
+ else if (detail.initial) {
153
220
  traverseInput(detail.initial, (potentialImportRef) => {
154
- if (potentialImportRef.type === 'ImportReference') {
155
- totalImportRefs++;
156
- const importIndex = parseInt(potentialImportRef.value.charAt(0));
157
- const nameIndex = parseInt(potentialImportRef.value.charAt(potentialImportRef.value.length - 1));
158
- if (doc.imports &&
159
- isImportValid(importIndex, nameIndex, doc.imports)) {
160
- imports[potentialImportRef.value] = {
161
- name: doc.imports[importIndex].names[nameIndex],
162
- resourceName: doc.imports[importIndex].resourceName,
163
- komaciDocImportRef: potentialImportRef.value,
164
- };
165
- }
221
+ if (potentialImportRef.type === 'ImportReference' &&
222
+ moduleMetadata.importIndexReference.has(potentialImportRef.value) &&
223
+ moduleMetadata.importsByName.has(
224
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
225
+ moduleMetadata.importIndexReference.get(potentialImportRef.value))) {
226
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
227
+ const importMetadata = moduleMetadata.importsByName.get(
228
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
229
+ moduleMetadata.importIndexReference.get(potentialImportRef.value));
230
+ importMetadata.usedInPriming = true;
231
+ }
232
+ else if (potentialImportRef.type === 'Unresolved') {
233
+ adgMetadata.requiredAdgFactoryFunctions.add(types_1.IdKeys.UNRESOLVED_VALUE);
166
234
  }
167
235
  return false;
168
236
  });
169
- if (totalImportRefs !== 0) {
170
- property.imports = imports;
171
- }
237
+ property.inital = detail.initial;
172
238
  }
173
239
  properties.set(name, property);
174
240
  }
241
+ adgMetadata.properties = properties;
175
242
  }
176
243
  return properties;
177
244
  }
178
245
  exports.initializePropertiesMap = initializePropertiesMap;
246
+ /**
247
+ * run over functions not associated with a property and make sure we collect info about the good ones
248
+ * @param functions list of functions for a given adg
249
+ * @param adg metadata about the given adg
250
+ * @param moduleMetadata general module metadata
251
+ */
252
+ function processFreestandingFunctions(functions = [], adg, moduleMetadata) {
253
+ for (let i = 0; i < functions.length; i++) {
254
+ const unprocessedFunction = functions[i];
255
+ if (!unprocessedFunction.visited && unprocessedFunction.type === 'WireFunction') {
256
+ const wireImport = (0, moduleMetadata_1.reconcileWireReference)(unprocessedFunction, adg, moduleMetadata);
257
+ if (wireImport) {
258
+ const wireFunction = (0, moduleMetadata_1.composeWireFunctionMetadata)(unprocessedFunction, wireImport, moduleMetadata);
259
+ const isFunctionUnsupported = wireFunction.importReference.functionName === types_1.IdKeys.UNRESOLVED_VALUE;
260
+ if (isFunctionUnsupported) {
261
+ adg.requiredAdgFactoryFunctions.add(types_1.IdKeys.UNRESOLVED_VALUE);
262
+ }
263
+ else {
264
+ adg.functions.push(wireFunction);
265
+ }
266
+ }
267
+ }
268
+ }
269
+ }
270
+ exports.processFreestandingFunctions = processFreestandingFunctions;
179
271
  /**
180
272
  * Traverse the input of a Function object (as definged in a Komaci Document) generically. When we get to a specific value
181
273
  * in the tree, we run the provided callback. The callback can return `true` if we should stop
@@ -189,6 +281,9 @@ exports.initializePropertiesMap = initializePropertiesMap;
189
281
  */
190
282
  function traverseInput(input, cb, key) {
191
283
  let shouldEarlyExit = false;
284
+ if (!input) {
285
+ return false;
286
+ }
192
287
  if (!Array.isArray(input) &&
193
288
  !(input.type === 'ArrayValue' || input.type === 'ObjectValue')) {
194
289
  shouldEarlyExit = cb(input, key);
@@ -219,51 +314,21 @@ function traverseInput(input, cb, key) {
219
314
  return shouldEarlyExit;
220
315
  }
221
316
  exports.traverseInput = traverseInput;
222
- function traverseParentAdgs(component, doc, cb) {
223
- if (component.parentClass &&
224
- component.parentClass.type === 'AdgReference' &&
225
- doc.adgs?.[component.parentClass.value]) {
226
- traverseParentAdgs(doc.adgs?.[component.parentClass.value], doc, cb);
317
+ function traverseParentAdgs(component, komaciDocIndex, doc, moduleMetadata, cb) {
318
+ if (component) {
319
+ if (component.parentClass &&
320
+ component.parentClass.type === 'AdgReference' &&
321
+ (0, exports.doesAdgExist)(component.parentClass.value, doc)) {
322
+ traverseParentAdgs(doc.adgs?.[component.parentClass.value], component.parentClass.value, doc, moduleMetadata, cb);
323
+ }
324
+ cb(component, komaciDocIndex);
227
325
  }
228
- cb(component);
229
326
  }
230
327
  exports.traverseParentAdgs = traverseParentAdgs;
231
- /**
232
- * Traverse the Komaci Document for a script file and collect property usages.
233
- *
234
- * This function:
235
- * 1. prepares the properties object with initial values
236
- * 2. collects usages of properties from wire functions
237
- * @param doc Komaci Script Doc to traverse
238
- * @returns contextual information about properties
239
- */
240
- function collectPropertyMetadataFromScriptDoc(doc) {
241
- if (doc?.exports?.default?.type === 'AdgReference' &&
242
- doc?.adgs?.[doc.exports?.default?.value]) {
243
- const component = doc.adgs[doc.exports.default.value];
244
- let properties = new Map();
245
- traverseParentAdgs(component, doc, (currentComponent) => {
246
- properties = initializePropertiesMap(currentComponent, doc, properties);
247
- for (const functionDetail of currentComponent.functions || []) {
248
- if (functionDetail.type === 'WireFunction' && functionDetail.input) {
249
- traverseInput(functionDetail.input, (value) => {
250
- if (value.type === 'PropertyReference' &&
251
- properties.has(value.value)) {
252
- const property = properties.get(value.value);
253
- if (property) {
254
- property.usedInPriming = true;
255
- }
256
- }
257
- return false;
258
- });
259
- }
260
- }
261
- });
262
- return properties;
263
- }
264
- return new Map();
265
- }
266
- exports.collectPropertyMetadataFromScriptDoc = collectPropertyMetadataFromScriptDoc;
328
+ const doesAdgExist = (index, doc) => {
329
+ return doc.adgs?.[index] !== undefined;
330
+ };
331
+ exports.doesAdgExist = doesAdgExist;
267
332
  /**
268
333
  * Helper to clean up a potential property, see if it exists and update if it does
269
334
  * @param value potential property. could be in the form of record/data/whatever
@@ -279,62 +344,77 @@ function updatePropertyIfExists(value, properties, key) {
279
344
  [key]: true,
280
345
  });
281
346
  }
347
+ return cleanedUpValue;
282
348
  }
349
+ /**
350
+ * Traverse through a composition looking for something
351
+ * @param composition the composition to look at
352
+ * @param cb the function to run on every new composition. returning true here will end traversal for that subtree
353
+ */
354
+ function traverseComposition(composition, cb, iteratorContext = []) {
355
+ const found = cb(composition, iteratorContext);
356
+ if (!found && composition && composition.compositions) {
357
+ for (const value of composition.compositions) {
358
+ if (isCompositionAnIteration(composition)) {
359
+ iteratorContext.unshift(composition.iterator);
360
+ }
361
+ traverseComposition(value, cb, iteratorContext);
362
+ if (isCompositionAnIteration(composition)) {
363
+ iteratorContext.shift();
364
+ }
365
+ }
366
+ }
367
+ }
368
+ exports.traverseComposition = traverseComposition;
283
369
  /**
284
370
  * Recursively probe a composition and it's children for usages of properties.
285
371
  * @param composition Current composition
286
372
  * @param properties The map of properties to update
287
373
  */
288
- function updatePropertiesForComposition(composition, properties) {
374
+ function updatePropertiesForComposition(composition, properties, propertiesUsedInTemplate, iterationContext) {
289
375
  if (composition && composition.key) {
290
376
  const container = composition;
291
377
  if (container.key && container.key.type === 'Binding') {
292
- updatePropertyIfExists(container.key.value, properties, 'usedInPriming');
378
+ const prop = updatePropertyIfExists(container.key.value, properties, 'usedInPriming');
379
+ if (!iterationContext.includes(prop)) {
380
+ propertiesUsedInTemplate.add(prop);
381
+ }
293
382
  }
294
383
  }
295
384
  if (composition && composition.isActive) {
296
- updatePropertyIfExists(composition.isActive.input.value, properties, 'usedInPriming');
385
+ const prop = updatePropertyIfExists(composition.isActive.input.value, properties, 'usedInPriming');
386
+ if (!iterationContext.includes(prop)) {
387
+ propertiesUsedInTemplate.add(prop);
388
+ }
297
389
  }
298
390
  if (isCompositionAnIteration(composition)) {
299
- updatePropertyIfExists(composition.input.value, properties, 'usedInPriming');
391
+ const prop = updatePropertyIfExists(composition.input.value, properties, 'usedInPriming');
392
+ if (!iterationContext.includes(prop)) {
393
+ propertiesUsedInTemplate.add(prop);
394
+ }
300
395
  }
301
396
  if (isCompositionAComposedAdg(composition) && composition.properties) {
302
397
  for (const property of Object.values(composition.properties || {})) {
303
398
  if (property.type === 'Binding') {
304
- updatePropertyIfExists(property.value, properties, 'usedInPriming');
399
+ const prop = updatePropertyIfExists(property.value, properties, 'usedInPriming');
400
+ if (!iterationContext.includes(prop)) {
401
+ propertiesUsedInTemplate.add(prop);
402
+ }
305
403
  }
306
404
  }
307
- if (composition.input.type === 'Binding') {
308
- updatePropertyIfExists(composition.input.value, properties, 'usedInPriming');
309
- }
310
405
  }
311
406
  if (isCompositionAnImage(composition)) {
312
407
  // if img.src is a Binding, then let's update the property to note it is used in Priming
313
408
  if (isSrcABinding(composition.src)) {
314
409
  const binding = composition.src;
315
- updatePropertyIfExists(binding.value, properties, 'usedInPriming');
316
- }
317
- }
318
- if (composition && composition.compositions) {
319
- for (const value of composition.compositions) {
320
- updatePropertiesForComposition(value, properties);
410
+ const prop = updatePropertyIfExists(binding.value, properties, 'usedInPriming');
411
+ if (!iterationContext.includes(prop)) {
412
+ propertiesUsedInTemplate.add(prop);
413
+ }
321
414
  }
322
415
  }
323
416
  }
324
417
  exports.updatePropertiesForComposition = updatePropertiesForComposition;
325
- /**
326
- * Collect usages of properties from compositions in a Komaci Template Document
327
- * @param doc Komaci Document
328
- * @param properties The current map of properties, this is just updating them.
329
- */
330
- function updatePropertyMetadataFromTemplateDoc(doc, properties) {
331
- if (doc?.exports?.default?.type === 'CompositionReference' &&
332
- doc.compositions?.[doc.exports.default.value]) {
333
- const composition = doc.compositions[doc.exports.default.value];
334
- updatePropertiesForComposition(composition, properties);
335
- }
336
- }
337
- exports.updatePropertyMetadataFromTemplateDoc = updatePropertyMetadataFromTemplateDoc;
338
418
  /**
339
419
  * Updates used properties to record whether they were used in Priming.
340
420
  * @param prop the name of the getter under consideration
@@ -355,12 +435,35 @@ function updatePropertyUsage(prop, identifiers, properties, type) {
355
435
  });
356
436
  }
357
437
  exports.updatePropertyUsage = updatePropertyUsage;
358
- function isPropertyAWire(property) {
359
- return property.type === types_1.PropertyTypes.WIRE;
360
- }
361
- exports.isPropertyAWire = isPropertyAWire;
362
438
  function isPropertyFromImport(property) {
363
439
  return property.imports !== undefined;
364
440
  }
365
441
  exports.isPropertyFromImport = isPropertyFromImport;
442
+ /**
443
+ * Convers an import in a Komaci template doc to a component identifier.
444
+ * Example:
445
+ * From: @salesforce/komaci/c__child1__child1.js
446
+ * To: c-child1
447
+ * @param {string} resourceName the import path
448
+ * @returns {string} a string representing the component id generated from the import resource name
449
+ */
450
+ function importToComponentId(resourceName) {
451
+ // First split by '/' and confirm expected # segments.
452
+ let segments = resourceName.split('/');
453
+ if (segments.length !== 3) {
454
+ throw new Error(types_1.ERROR_PREFIX + 'komaciDoc contains invalid import');
455
+ }
456
+ // Now split last segment by '__' and confirm expected # segments.
457
+ segments = segments[2].split('__');
458
+ if (segments.length !== 3) {
459
+ throw new Error(types_1.ERROR_PREFIX + 'komaciDoc contains invalid import');
460
+ }
461
+ const namespace = segments[0];
462
+ // name converted from camel case to kebab case.
463
+ const name = segments[1]
464
+ .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2')
465
+ .toLowerCase();
466
+ return `${namespace}-${name}`;
467
+ }
468
+ exports.importToComponentId = importToComponentId;
366
469
  //# sourceMappingURL=komaciDocumentIntrospection.js.map
@@ -0,0 +1,160 @@
1
+ import { FunctionType, KomaciDocument } from '@komaci/types';
2
+ import * as t from '@babel/types';
3
+ import { AdgMetadata, ImportDetail, ImportMetadata, ModuleMetadata, PrimingAdapterDefinition, WireFunctionMetadata } from './types';
4
+ /** not all imports are consumed in a statically analyzable way. when we add their metadata, we use this to ack that the komaciDocImportRef for this import is nil */
5
+ export declare const NO_KOMACI_DOC_REF = "nil";
6
+ /**
7
+ * establish a base object for module metadata
8
+ * @returns A structured object for module metadata
9
+ */
10
+ export declare const initModuleMetadataObject: () => ModuleMetadata;
11
+ /**
12
+ * establish an empty object for adg metadata
13
+ * @param defaultGeneratedName a generated name for this object
14
+ * @returns an empty metadata object
15
+ */
16
+ export declare const initAdgMetadataObject: (defaultGeneratedName: string) => AdgMetadata;
17
+ /**
18
+ * Process import references from komaci document
19
+ * @param doc the KomaciDocument itself
20
+ * @param moduleMetadata data structure representing metadata about the module we are working on
21
+ */
22
+ export declare const initializeImportMetdataFromKomaciDocument: (doc: KomaciDocument, moduleMetadata: ModuleMetadata, fromTemplate?: boolean) => void;
23
+ /**
24
+ * Update module metadata with information about the given import.
25
+ * @param name import name
26
+ * @param resourceName import path
27
+ * @param isSupported if it's from a valid namespace
28
+ * @param komaciDocImportRef reference index in komaci document
29
+ * @param moduleMetadata the metadata object
30
+ *
31
+ * @return the import metadata object in case anything needs to be modified
32
+ */
33
+ export declare const composeImportMetadata: (name: string, resourceName: string, isSupported: boolean, komaciDocImportRef: string, moduleMetadata: ModuleMetadata, importAlias?: string) => ImportMetadata;
34
+ /**
35
+ * collect all the imports for a given ast and then execute a callback with information about the import
36
+ * @param ast The babel ast
37
+ * @param cb function to call for acting on import information
38
+ */
39
+ export declare const traverseAstImports: (ast: t.File, cb: (lookupName: string, referencedName: string, resourceName: string, originalImportName?: string) => void) => void;
40
+ /**
41
+ * given the name of a resource see if we have information about it. if we don't compose the base object for later reference.
42
+ * @param resourceName The import path
43
+ * @param moduleMetadata Metadata about this module
44
+ * @returns The namespace metadata object
45
+ */
46
+ export declare const reconcileNamespace: (resourceName: string, moduleMetadata: ModuleMetadata) => ImportDetail;
47
+ /**
48
+ * When looking for an import if it it doesn't exist and we'd have
49
+ * to just make it anyway this function will do that for you
50
+ *
51
+ * @param name identifier of import you're looking for
52
+ * @param importPath resource path for the import
53
+ * @param moduleMetadata module metadata instance
54
+ * @returns The import metadata for this import (as much as we know)
55
+ */
56
+ export declare const reconcileImport: (name: string, importPath: string, moduleMetadata: ModuleMetadata) => ImportMetadata;
57
+ /**
58
+ * add a new import that is only found in the ast. sometimes imports are not statically analyzable but we still want to collect info on them so we do this.
59
+ * @param referencedName the name used to reference this import in code
60
+ * @param namespace the metadata about the import namespace
61
+ * @param moduleMetadata the metadata about the module
62
+ * @param originalImportName (optional) the original name of the import that has been aliases. undefined if no alias.
63
+ */
64
+ export declare const addNewImportFromAst: (referencedName: string, namespace: ImportDetail, moduleMetadata: ModuleMetadata, originalImportName?: string) => void;
65
+ /**
66
+ * Komaci Documents don't keep track of import aliases but sometimes they're referenced in code so we want to makes sure we have them.
67
+ * @param lookupName the name used as the holdover key tor eference this import
68
+ * @param referencedName the name used to reference this import in code
69
+ * @param namespace the import namespace metadata
70
+ * @param moduleMetadata metadata about this module
71
+ * @param originalImportName (optional) the original name of the import that has been aliases. undefined if no alias.
72
+ */
73
+ export declare const updateAliasForImport: (lookupName: string, referencedName: string, namespace: ImportDetail, moduleMetadata: ModuleMetadata, originalImportName?: string) => void;
74
+ /**
75
+ * pull all needful import metadata we can from the ast
76
+ * for the most part, we can grab data from the komaci document for imports but sometimes
77
+ * imports are consumed in non statically analyzable ways like inside of a getter or template string
78
+ * so we need to collect that info seperately
79
+ *
80
+ * also, the Komaci Document doesn't maintain the local alias for default or namespaced imports. so if we
81
+ * have previously collected information about one of these imports from the Komaci Document then we want
82
+ * to make sure the alias is consumed and the maps properly represent the way the import is consumed.
83
+ *
84
+ * @param moduleMetadata metadata data structure to modify
85
+ * @param ast ast for the given component
86
+ */
87
+ export declare const collectImportMetadataFromAst: (ast: t.File, moduleMetadata: ModuleMetadata) => void;
88
+ /**
89
+ * From a given adg, collect as much metadata as possible ONLY from the komaci document
90
+ *
91
+ * This would include:
92
+ * - property initialization (any info we can collect ONLY from the komaci document)
93
+ * - function initialization
94
+ * - default generation name setup
95
+ * @param docAdgIndex the index of the adg in the KomaciDocument
96
+ * @param doc the KomaciDocument itself
97
+ * @param moduleMetadata data structure representing metadata about the module we are working on
98
+ */
99
+ export declare const initalizeAdgMetadata: (docAdgIndex: number, doc: KomaciDocument, moduleMetadata: ModuleMetadata, hasSourceFile: boolean, isBundle?: boolean) => void;
100
+ /**
101
+ * Update exports key in module metadata mapping the export name to associated adg object
102
+ * @param doc the KomaciDocument itself
103
+ * @param moduleMetadata data structure representing metadata about the module we are working on
104
+ */
105
+ export declare const mapExportNamesToAdgs: (exports: KomaciDocument['exports'], moduleMetadata: ModuleMetadata) => void;
106
+ /**
107
+ * Walk the compositions to see what props are being used, add this information to the adg metadata
108
+ * @param doc the template KomaciDocument
109
+ * @param adgIndex the index of the default adg
110
+ * @param moduleMetadata data structure representing metadata about the module we are working on
111
+ */
112
+ export declare const addTemplateUsageForDefaultAdg: (doc: KomaciDocument, adgIndex: number, moduleMetadata: ModuleMetadata) => void;
113
+ /**
114
+ * Collect functional metadata for a wire this includes
115
+ * - wire function details (name, batch / reducer if priming function)
116
+ * - input
117
+ * - required properties
118
+ *
119
+ * all bundled up into one readily available package for later composition
120
+ *
121
+ * @param functionDetails
122
+ * @param wireImport
123
+ * @param moduleMetadata
124
+ * @returns
125
+ */
126
+ export declare const composeWireFunctionMetadata: (functionDetails: FunctionType, wireImport: ImportMetadata, moduleMetadata: ModuleMetadata) => WireFunctionMetadata;
127
+ /**
128
+ * A Wire Function can only have one valid type of reference, an import. if we see an import we should collect the info for that
129
+ * otherwise, we should mark the reference as unresolved and make sure we are accounting for it in factory functions
130
+ * @param func The details about a function from the komaci doc
131
+ * @param adg metadata about the adg this function is in
132
+ * @param moduleMetadata general module metadata (imports mostly)
133
+ * @returns import metadata if this wire references a valid one, undefined otherwise
134
+ */
135
+ export declare const reconcileWireReference: (func: FunctionType, adg: AdgMetadata, moduleMetadata: ModuleMetadata) => ImportMetadata | undefined;
136
+ /**
137
+ * Some wires have associated priming adapters. if we do have one of those then we want to use it instead of the
138
+ * original wire adapter referenced in the komaci document. as part of this we have to make sure the new imports
139
+ * are made and appropriately referenced inside module metadata
140
+ *
141
+ * @param functionMetadata Details about a wire function
142
+ * @param primingAdapterDef Details about the priming adapter associated for this wire
143
+ * @param moduleMetadata Instance of module metadata data structure
144
+ */
145
+ export declare const reconcilePrimingAdapater: (functionMetadata: WireFunctionMetadata, primingAdapterDef: PrimingAdapterDefinition, moduleMetadata: ModuleMetadata) => void;
146
+ export declare function isImportInvalid(importMetadata: ImportMetadata): boolean;
147
+ /**
148
+ * in specific cases, mainly template only compositions, we may not have a default adg already but need one to compose the resolvable module.
149
+ * @param currentDefaultAdgIndex The current index of the default adg if it exists
150
+ * @param moduleMetadata metadata about the module
151
+ * @returns the index of the default adg
152
+ */
153
+ export declare function reconcileDefaultAdg(currentDefaultAdgIndex: number | undefined, moduleMetadata: ModuleMetadata): number;
154
+ /**
155
+ * If we process a template and see it has some props we don't know about we can uplift them to the adgs props using this.
156
+ * this is only currently used for template only bundles
157
+ * @param adg The metadata object for a given adg
158
+ */
159
+ export declare function upliftFakePropsFromTemplate(adg: AdgMetadata): void;
160
+ //# sourceMappingURL=moduleMetadata.d.ts.map