@hubspot/project-parsing-lib 0.2.2-beta.0 → 0.2.2-experimental.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.
Files changed (65) hide show
  1. package/README.md +4 -35
  2. package/package.json +128 -22
  3. package/src/exports/constants.d.ts +1 -0
  4. package/src/exports/constants.js +1 -0
  5. package/src/exports/lang.d.ts +1 -0
  6. package/src/exports/lang.js +1 -0
  7. package/src/exports/migrate.d.ts +1 -0
  8. package/src/exports/migrate.js +1 -0
  9. package/src/exports/profiles.d.ts +3 -0
  10. package/src/exports/profiles.js +2 -0
  11. package/src/exports/projects.d.ts +4 -0
  12. package/src/exports/projects.js +3 -0
  13. package/src/exports/schema.d.ts +2 -0
  14. package/src/exports/schema.js +1 -0
  15. package/src/exports/themes.d.ts +2 -0
  16. package/src/exports/themes.js +1 -0
  17. package/src/exports/transform.d.ts +2 -0
  18. package/src/exports/transform.js +1 -0
  19. package/src/exports/translate.d.ts +3 -0
  20. package/src/exports/translate.js +2 -0
  21. package/src/exports/uid.d.ts +1 -0
  22. package/src/exports/uid.js +1 -0
  23. package/src/exports/validation.d.ts +3 -0
  24. package/src/exports/validation.js +2 -0
  25. package/src/exports/workspaces.d.ts +2 -0
  26. package/src/exports/workspaces.js +1 -0
  27. package/src/lang/copy.d.ts +8 -1
  28. package/src/lang/copy.js +29 -32
  29. package/src/lib/constants.d.ts +55 -29
  30. package/src/lib/constants.js +169 -126
  31. package/src/lib/errors.d.ts +3 -3
  32. package/src/lib/errors.js +25 -33
  33. package/src/lib/files.d.ts +3 -3
  34. package/src/lib/files.js +46 -42
  35. package/src/lib/localDev.d.ts +4 -0
  36. package/src/lib/localDev.js +72 -0
  37. package/src/lib/migrate.d.ts +1 -0
  38. package/src/lib/migrate.js +43 -45
  39. package/src/lib/migrateThemes.d.ts +25 -0
  40. package/src/lib/migrateThemes.js +120 -0
  41. package/src/lib/minimalArboristTree.d.ts +118 -0
  42. package/src/lib/minimalArboristTree.js +32 -0
  43. package/src/lib/platformVersion.d.ts +3 -0
  44. package/src/lib/platformVersion.js +16 -0
  45. package/src/lib/profiles.d.ts +6 -1
  46. package/src/lib/profiles.js +95 -40
  47. package/src/lib/project.js +22 -17
  48. package/src/lib/schemas.d.ts +2 -2
  49. package/src/lib/schemas.js +11 -11
  50. package/src/lib/transform.d.ts +4 -2
  51. package/src/lib/transform.js +100 -53
  52. package/src/lib/translate.d.ts +3 -0
  53. package/src/lib/translate.js +62 -0
  54. package/src/lib/types.d.ts +30 -6
  55. package/src/lib/types.js +1 -2
  56. package/src/lib/uid.d.ts +2 -0
  57. package/src/lib/uid.js +14 -9
  58. package/src/lib/utils.d.ts +3 -0
  59. package/src/lib/utils.js +16 -0
  60. package/src/lib/validation.d.ts +4 -4
  61. package/src/lib/validation.js +61 -53
  62. package/src/lib/workspaces.d.ts +113 -0
  63. package/src/lib/workspaces.js +403 -0
  64. package/src/index.d.ts +0 -18
  65. package/src/index.js +0 -87
@@ -0,0 +1,403 @@
1
+ import fs from 'fs';
2
+ import fsPromises from 'fs/promises';
3
+ import path from 'path';
4
+ import os from 'os';
5
+ import { fileURLToPath } from 'node:url';
6
+ import mapWorkspaces from '@npmcli/map-workspaces';
7
+ import packlist from 'npm-packlist';
8
+ import { logger } from '@hubspot/local-dev-lib/logger';
9
+ import { walk } from '@hubspot/local-dev-lib/fs';
10
+ import { createMinimalTree } from './minimalArboristTree.js';
11
+ /**
12
+ * Error thrown when a workspace directory cannot be resolved
13
+ */
14
+ export class WorkspaceResolutionError extends Error {
15
+ workspaceDir;
16
+ sourcePackageJson;
17
+ constructor(workspaceDir, sourcePackageJson, cause) {
18
+ super(`Failed to resolve workspace directory "${workspaceDir}" declared in ${sourcePackageJson}${cause ? `: ${cause.message}` : ''}`);
19
+ this.workspaceDir = workspaceDir;
20
+ this.sourcePackageJson = sourcePackageJson;
21
+ this.name = 'WorkspaceResolutionError';
22
+ if (cause) {
23
+ this.cause = cause;
24
+ }
25
+ }
26
+ }
27
+ /**
28
+ * Error thrown when a file: dependency cannot be resolved
29
+ */
30
+ export class FileDependencyResolutionError extends Error {
31
+ packageName;
32
+ dependencyPath;
33
+ sourcePackageJson;
34
+ constructor(packageName, dependencyPath, sourcePackageJson, cause) {
35
+ super(`Failed to resolve file: dependency "${packageName}" at path "${dependencyPath}" declared in ${sourcePackageJson}${cause ? `: ${cause.message}` : ''}`);
36
+ this.packageName = packageName;
37
+ this.dependencyPath = dependencyPath;
38
+ this.sourcePackageJson = sourcePackageJson;
39
+ this.name = 'FileDependencyResolutionError';
40
+ if (cause) {
41
+ this.cause = cause;
42
+ }
43
+ }
44
+ }
45
+ /**
46
+ * Error thrown when a `workspace:` protocol dependency does not match any known
47
+ * workspace member. npm itself does not support the `workspace:` protocol —
48
+ * only pnpm and yarn berry do — so the install fails with a confusing message
49
+ * server-side. Surface a clearer error up front.
50
+ */
51
+ export class OrphanWorkspaceProtocolError extends Error {
52
+ packageName;
53
+ sourcePackageJson;
54
+ constructor(packageName, sourcePackageJson) {
55
+ super(`Found \`workspace:\` protocol dependency "${packageName}" in ${sourcePackageJson} but no workspace member is named "${packageName}". ` +
56
+ `The \`workspace:\` protocol requires a matching workspace member declared under "workspaces" in a parent package.json. ` +
57
+ `If you're migrating from pnpm or yarn berry, replace with \`file:./<relative-path>\` or \`link:./<relative-path>\`, or add the package under "workspaces".`);
58
+ this.packageName = packageName;
59
+ this.sourcePackageJson = sourcePackageJson;
60
+ this.name = 'OrphanWorkspaceProtocolError';
61
+ }
62
+ }
63
+ const TARBALL_EXTENSIONS = ['.tgz', '.tar.gz', '.tar'];
64
+ function hasTarballExtension(p) {
65
+ const lower = p.toLowerCase();
66
+ return TARBALL_EXTENSIONS.some(ext => lower.endsWith(ext));
67
+ }
68
+ /**
69
+ * Expands tilde (~) in paths to the user's home directory
70
+ */
71
+ function expandTildePath(filePath) {
72
+ return filePath.startsWith('~')
73
+ ? path.join(os.homedir(), filePath.slice(1))
74
+ : filePath;
75
+ }
76
+ /**
77
+ * Parses a `file:` or `link:` dependency spec into its protocol and raw path.
78
+ * Handles all npm-supported shapes:
79
+ * - file:./relative/path
80
+ * - file:relative/path (no leading slash/dot)
81
+ * - file:/absolute/path
82
+ * - file://./relative — npm-style file URL with relative path
83
+ * - file:///absolute — file URL with absolute path
84
+ * - link:./relative/path (symlink semantics for directories only)
85
+ */
86
+ export function parseLocalSpec(spec) {
87
+ const match = /^(file|link):(.*)$/.exec(spec);
88
+ if (!match) {
89
+ return null;
90
+ }
91
+ const protocol = match[1];
92
+ let rawPath = match[2];
93
+ if (rawPath.startsWith('//')) {
94
+ try {
95
+ rawPath = fileURLToPath(`file:${rawPath}`);
96
+ }
97
+ catch {
98
+ return { protocol, rawPath };
99
+ }
100
+ }
101
+ return { protocol, rawPath };
102
+ }
103
+ /**
104
+ * Finds and parses all package.json files in a directory.
105
+ * This is the single entry point for discovering package.json files and parsing their contents.
106
+ */
107
+ export async function findAndParsePackageJsonFiles(srcDir) {
108
+ const allFiles = await walk(srcDir, ['node_modules']);
109
+ const packageJsonPaths = allFiles.filter(file => path.basename(file) === 'package.json');
110
+ return packageJsonPaths.map(filePath => {
111
+ try {
112
+ return {
113
+ path: filePath,
114
+ dir: path.dirname(filePath),
115
+ content: JSON.parse(fs.readFileSync(filePath, 'utf8')),
116
+ };
117
+ }
118
+ catch (e) {
119
+ logger.debug(`Failed to parse package.json at ${filePath}: ${e}`);
120
+ return {
121
+ path: filePath,
122
+ dir: path.dirname(filePath),
123
+ content: null,
124
+ };
125
+ }
126
+ });
127
+ }
128
+ /**
129
+ * Extracts workspace patterns from parsed package.json content
130
+ */
131
+ function extractWorkspaceGlobs(packageJson) {
132
+ const workspaces = packageJson.workspaces;
133
+ if (!workspaces) {
134
+ return [];
135
+ }
136
+ if (Array.isArray(workspaces)) {
137
+ return workspaces;
138
+ }
139
+ if (workspaces.packages && Array.isArray(workspaces.packages)) {
140
+ return workspaces.packages;
141
+ }
142
+ return [];
143
+ }
144
+ /**
145
+ * Resolves workspace glob patterns to actual directories.
146
+ *
147
+ * Uses @npmcli/map-workspaces (npm's reference impl) so that negation patterns
148
+ * like `["packages/*", "!packages/excluded"]` are honored — a hand-rolled
149
+ * per-pattern glob() silently accepted negations without actually excluding.
150
+ */
151
+ export async function resolveWorkspaceDirectories(baseDir, workspaceGlobs) {
152
+ if (workspaceGlobs.length === 0) {
153
+ return [];
154
+ }
155
+ const expandedGlobs = workspaceGlobs.map(expandTildePath);
156
+ let workspaceMap;
157
+ try {
158
+ workspaceMap = await mapWorkspaces({
159
+ pkg: { workspaces: expandedGlobs },
160
+ cwd: baseDir,
161
+ });
162
+ }
163
+ catch (e) {
164
+ logger.debug(`Failed to resolve workspace patterns in ${baseDir} via map-workspaces: ${e}`);
165
+ return [];
166
+ }
167
+ const resolved = new Set();
168
+ for (const dir of workspaceMap.values()) {
169
+ try {
170
+ const stats = await fsPromises.stat(dir);
171
+ if (!stats.isDirectory()) {
172
+ continue;
173
+ }
174
+ const packageJsonPath = path.join(dir, 'package.json');
175
+ try {
176
+ await fsPromises.access(packageJsonPath, fs.constants.F_OK);
177
+ resolved.add(dir);
178
+ }
179
+ catch {
180
+ // Directory exists but doesn't contain package.json — skip silently.
181
+ }
182
+ }
183
+ catch (e) {
184
+ logger.warn(`Cannot access directory ${dir}: ${e}`);
185
+ }
186
+ }
187
+ return Array.from(resolved);
188
+ }
189
+ /**
190
+ * Collects all workspace directories that need to be uploaded.
191
+ * Handles edge cases like circular references, symlinks, and overlapping paths.
192
+ * Returns mappings that track which package.json defined each workspace.
193
+ */
194
+ export async function collectWorkspaceDirectories(parsedPackageJsons) {
195
+ const workspaceMappings = [];
196
+ // Track (sourcePackageJsonPath, workspaceDir) pairs to avoid duplicates within
197
+ // the same source, while still allowing the same workspace dir to appear in
198
+ // mappings from multiple different package.json files. Both keys use realpath
199
+ // form so case-only differences on case-insensitive filesystems collapse.
200
+ const visited = new Set();
201
+ for (const parsed of parsedPackageJsons) {
202
+ if (!parsed.content) {
203
+ continue;
204
+ }
205
+ const workspaceGlobs = extractWorkspaceGlobs(parsed.content);
206
+ if (workspaceGlobs.length === 0) {
207
+ continue;
208
+ }
209
+ logger.debug(`Found workspaces in ${parsed.path}: ${workspaceGlobs.join(', ')}`);
210
+ const resolved = await resolveWorkspaceDirectories(parsed.dir, workspaceGlobs);
211
+ let sourceRealPath;
212
+ try {
213
+ sourceRealPath = await fsPromises.realpath(parsed.path);
214
+ }
215
+ catch {
216
+ sourceRealPath = parsed.path;
217
+ }
218
+ for (const dir of resolved) {
219
+ let realDir;
220
+ try {
221
+ realDir = await fsPromises.realpath(dir);
222
+ }
223
+ catch (e) {
224
+ throw new WorkspaceResolutionError(dir, parsed.path, e instanceof Error ? e : undefined);
225
+ }
226
+ const pairKey = `${sourceRealPath}::${realDir}`;
227
+ if (visited.has(pairKey)) {
228
+ logger.debug(`Skipping duplicate workspace mapping: ${realDir} from ${parsed.path}`);
229
+ continue;
230
+ }
231
+ visited.add(pairKey);
232
+ workspaceMappings.push({
233
+ workspaceDir: realDir,
234
+ sourcePackageJsonPath: parsed.path,
235
+ });
236
+ logger.debug(`Resolved workspace: ${realDir}`);
237
+ }
238
+ }
239
+ return workspaceMappings;
240
+ }
241
+ /**
242
+ * Extracts file: and link: dependencies from parsed package.json content.
243
+ * Only scans production dependencies since devDependencies and optionalDependencies
244
+ * are not needed for the build pipeline.
245
+ */
246
+ function extractFileDependencies(packageJson) {
247
+ const fileDeps = [];
248
+ const deps = packageJson.dependencies;
249
+ if (!deps) {
250
+ return fileDeps;
251
+ }
252
+ for (const [packageName, version] of Object.entries(deps)) {
253
+ if (typeof version !== 'string') {
254
+ continue;
255
+ }
256
+ const parsed = parseLocalSpec(version);
257
+ if (parsed) {
258
+ fileDeps.push({
259
+ packageName,
260
+ protocol: parsed.protocol,
261
+ rawPath: parsed.rawPath,
262
+ });
263
+ }
264
+ }
265
+ return fileDeps;
266
+ }
267
+ /**
268
+ * Collects all `file:` and `link:` dependencies that need to be uploaded.
269
+ * Returns mappings that track the package name, resolved path, source
270
+ * package.json, kind (directory vs tarball) and protocol (file vs link).
271
+ */
272
+ export async function collectFileDependencies(parsedPackageJsons) {
273
+ const fileDependencyMappings = [];
274
+ const visited = new Set();
275
+ for (const parsed of parsedPackageJsons) {
276
+ if (!parsed.content) {
277
+ continue;
278
+ }
279
+ const fileDeps = extractFileDependencies(parsed.content);
280
+ if (fileDeps.length === 0) {
281
+ continue;
282
+ }
283
+ logger.debug(`Found file:/link: dependencies in ${parsed.path}: ${fileDeps.map(d => d.packageName).join(', ')}`);
284
+ for (const { packageName, protocol, rawPath } of fileDeps) {
285
+ const expandedPath = expandTildePath(rawPath);
286
+ const absolutePath = path.resolve(parsed.dir, expandedPath);
287
+ const looksLikeTarball = hasTarballExtension(absolutePath);
288
+ if (looksLikeTarball && protocol === 'link') {
289
+ throw new FileDependencyResolutionError(packageName, absolutePath, parsed.path, new Error('`link:` protocol is for directories (symlink semantics); use `file:` for tarballs'));
290
+ }
291
+ let realPath;
292
+ try {
293
+ realPath = await fsPromises.realpath(absolutePath);
294
+ }
295
+ catch (e) {
296
+ throw new FileDependencyResolutionError(packageName, absolutePath, parsed.path, e instanceof Error ? e : undefined);
297
+ }
298
+ let stats;
299
+ try {
300
+ stats = await fsPromises.stat(realPath);
301
+ }
302
+ catch (e) {
303
+ throw new FileDependencyResolutionError(packageName, realPath, parsed.path, e instanceof Error ? e : undefined);
304
+ }
305
+ let kind;
306
+ if (looksLikeTarball) {
307
+ if (!stats.isFile()) {
308
+ throw new FileDependencyResolutionError(packageName, realPath, parsed.path, new Error('Tarball path is not a regular file'));
309
+ }
310
+ kind = 'tarball';
311
+ }
312
+ else if (stats.isDirectory()) {
313
+ const depPackageJsonPath = path.join(realPath, 'package.json');
314
+ try {
315
+ await fsPromises.access(depPackageJsonPath, fs.constants.F_OK);
316
+ }
317
+ catch {
318
+ throw new FileDependencyResolutionError(packageName, realPath, parsed.path, new Error('Directory does not contain package.json'));
319
+ }
320
+ kind = 'directory';
321
+ }
322
+ else {
323
+ throw new FileDependencyResolutionError(packageName, realPath, parsed.path, new Error('Path is not a directory'));
324
+ }
325
+ if (visited.has(realPath)) {
326
+ logger.debug(`Skipping already visited file: dependency: ${realPath}`);
327
+ continue;
328
+ }
329
+ visited.add(realPath);
330
+ fileDependencyMappings.push({
331
+ packageName,
332
+ localPath: realPath,
333
+ sourcePackageJsonPath: parsed.path,
334
+ kind,
335
+ protocol,
336
+ });
337
+ logger.debug(`Resolved ${protocol}: dependency ${packageName} (${kind}): ${realPath}`);
338
+ }
339
+ }
340
+ return fileDependencyMappings;
341
+ }
342
+ /**
343
+ * Validates that every `workspace:` protocol dependency in the parsed package
344
+ * trees matches a known workspace member. Throws OrphanWorkspaceProtocolError
345
+ * for the first orphan found.
346
+ *
347
+ * npm itself does not implement the `workspace:` protocol; only pnpm and yarn
348
+ * berry do. If a project uses `workspace:*` without a matching member declared
349
+ * under `workspaces`, the install fails server-side with a confusing message —
350
+ * fail fast with a clearer one.
351
+ */
352
+ export function validateWorkspaceProtocolDependencies(parsedPackageJsons, workspaceMappings) {
353
+ const workspacePackageNames = new Set();
354
+ const workspaceDirs = new Set(workspaceMappings.map(m => m.workspaceDir));
355
+ for (const parsed of parsedPackageJsons) {
356
+ if (!parsed.content?.name) {
357
+ continue;
358
+ }
359
+ let realDir;
360
+ try {
361
+ realDir = fs.realpathSync(parsed.dir);
362
+ }
363
+ catch {
364
+ continue;
365
+ }
366
+ if (workspaceDirs.has(realDir)) {
367
+ workspacePackageNames.add(parsed.content.name);
368
+ }
369
+ }
370
+ for (const parsed of parsedPackageJsons) {
371
+ const deps = parsed.content?.dependencies;
372
+ if (!deps) {
373
+ continue;
374
+ }
375
+ for (const [packageName, version] of Object.entries(deps)) {
376
+ if (typeof version !== 'string' || !version.startsWith('workspace:')) {
377
+ continue;
378
+ }
379
+ if (!workspacePackageNames.has(packageName)) {
380
+ throw new OrphanWorkspaceProtocolError(packageName, parsed.path);
381
+ }
382
+ }
383
+ }
384
+ }
385
+ /**
386
+ * Returns the set of files that npm would include when publishing a package.
387
+ * Uses npm-packlist which respects the "files" field in package.json,
388
+ * .npmignore, and .gitignore rules.
389
+ *
390
+ * @throws Error if packlist fails to generate the file list
391
+ */
392
+ export async function getPackableFiles(dir) {
393
+ try {
394
+ const tree = createMinimalTree(dir);
395
+ const files = await packlist(tree);
396
+ return new Set(files);
397
+ }
398
+ catch (e) {
399
+ const errorMessage = `Failed to get packlist for ${dir}: ${e instanceof Error ? e.message : String(e)}`;
400
+ logger.error(errorMessage);
401
+ throw new Error(errorMessage, { cause: e });
402
+ }
403
+ }
package/src/index.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import { IntermediateRepresentation, IntermediateRepresentationNode, IntermediateRepresentationLocalDev, TranslationContext, TranslationOptions, IntermediateRepresentationNodeLocalDev } from './lib/types';
2
- import { ValidateFunction, AnySchema, ErrorObject } from 'ajv/dist/2020';
3
- export declare function translate(translationContext: TranslationContext, translationOptions?: TranslationOptions): Promise<IntermediateRepresentation>;
4
- export declare function translateForLocalDev(translationContext: TranslationContext, translationOptions?: Pick<TranslationOptions, 'profile'>): Promise<IntermediateRepresentationLocalDev>;
5
- export { isTranslationError } from './lib/errors';
6
- export { IntermediateRepresentation, IntermediateRepresentationNode, IntermediateRepresentationLocalDev, IntermediateRepresentationNodeLocalDev, TranslationContext, };
7
- export { getHsProfileFilename } from './lib/profiles';
8
- export { loadHsProfileFile, getAllHsProfiles, projectContainsHsMetaFiles, } from './lib/files';
9
- export { migrate } from './lib/migrate';
10
- export { validateUid } from './lib/uid';
11
- export { mapToUserFriendlyName, mapToInternalType } from './lib/transform';
12
- export { getIntermediateRepresentationSchema } from './lib/schemas';
13
- export { createAjvInstance } from './lib/validation';
14
- export { ValidateFunction, AnySchema, ErrorObject };
15
- export { metafileExtension, hsProjectJsonFilename } from './lib/constants';
16
- export { Components } from './lib/types';
17
- export { AjvErrorKeyword } from './lib/errors';
18
- export { getInvalidJsonError, getMissingTypeError, getMissingConfigError, getMissingAccountIdError, getMissingRequiredFieldError, getFailedToFetchSchemasError, getUnsupportedTypeError, } from './lang/copy';
package/src/index.js DELETED
@@ -1,87 +0,0 @@
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
- exports.getUnsupportedTypeError = exports.getFailedToFetchSchemasError = exports.getMissingRequiredFieldError = exports.getMissingAccountIdError = exports.getMissingConfigError = exports.getMissingTypeError = exports.getInvalidJsonError = exports.AjvErrorKeyword = exports.hsProjectJsonFilename = exports.metafileExtension = exports.createAjvInstance = exports.getIntermediateRepresentationSchema = exports.mapToInternalType = exports.mapToUserFriendlyName = exports.validateUid = exports.migrate = exports.projectContainsHsMetaFiles = exports.getAllHsProfiles = exports.loadHsProfileFile = exports.getHsProfileFilename = exports.isTranslationError = void 0;
7
- exports.translate = translate;
8
- exports.translateForLocalDev = translateForLocalDev;
9
- const files_1 = require("./lib/files");
10
- const validation_1 = require("./lib/validation");
11
- const transform_1 = require("./lib/transform");
12
- const copy_1 = require("./lang/copy");
13
- const path_1 = __importDefault(require("path"));
14
- const defaultOptions = {
15
- skipValidation: false,
16
- };
17
- async function translate(translationContext, translationOptions = defaultOptions) {
18
- const { skipValidation } = translationOptions;
19
- const metafileContents = await (0, files_1.loadHsMetaFiles)(translationContext);
20
- if (metafileContents.length === 0) {
21
- throw new Error(copy_1.errorMessages.project.noHsMetaFiles);
22
- }
23
- let hsProfileContents;
24
- if (translationOptions.profile) {
25
- hsProfileContents = (0, files_1.loadHsProfileFile)(translationContext.projectSourceDir, translationOptions.profile);
26
- }
27
- const transformation = (0, transform_1.transform)(metafileContents, translationContext, hsProfileContents);
28
- const intermediateRepresentation = (0, transform_1.getIntermediateRepresentation)(transformation, skipValidation);
29
- // Remove once extensions and serverless functions are supported
30
- if (!skipValidation) {
31
- await (0, validation_1.validateIntermediateRepresentation)(intermediateRepresentation, transformation, translationContext);
32
- }
33
- return intermediateRepresentation;
34
- }
35
- async function translateForLocalDev(translationContext, translationOptions) {
36
- const IR = await translate(translationContext, {
37
- skipValidation: true,
38
- profile: translationOptions?.profile,
39
- });
40
- const localDevIr = {
41
- intermediateNodesIndexedByUid: {},
42
- };
43
- Object.entries(IR.intermediateNodesIndexedByUid).forEach(([uid, node]) => {
44
- const component = IR.intermediateNodesIndexedByUid[uid];
45
- const componentConfigPath = path_1.default.join(translationContext.projectSourceDir, component.metaFilePath);
46
- localDevIr.intermediateNodesIndexedByUid[uid] = {
47
- ...node,
48
- localDev: {
49
- componentRoot: path_1.default.dirname(componentConfigPath),
50
- componentConfigPath,
51
- },
52
- };
53
- });
54
- return localDevIr;
55
- }
56
- var errors_1 = require("./lib/errors");
57
- Object.defineProperty(exports, "isTranslationError", { enumerable: true, get: function () { return errors_1.isTranslationError; } });
58
- var profiles_1 = require("./lib/profiles");
59
- Object.defineProperty(exports, "getHsProfileFilename", { enumerable: true, get: function () { return profiles_1.getHsProfileFilename; } });
60
- var files_2 = require("./lib/files");
61
- Object.defineProperty(exports, "loadHsProfileFile", { enumerable: true, get: function () { return files_2.loadHsProfileFile; } });
62
- Object.defineProperty(exports, "getAllHsProfiles", { enumerable: true, get: function () { return files_2.getAllHsProfiles; } });
63
- Object.defineProperty(exports, "projectContainsHsMetaFiles", { enumerable: true, get: function () { return files_2.projectContainsHsMetaFiles; } });
64
- var migrate_1 = require("./lib/migrate");
65
- Object.defineProperty(exports, "migrate", { enumerable: true, get: function () { return migrate_1.migrate; } });
66
- var uid_1 = require("./lib/uid");
67
- Object.defineProperty(exports, "validateUid", { enumerable: true, get: function () { return uid_1.validateUid; } });
68
- var transform_2 = require("./lib/transform");
69
- Object.defineProperty(exports, "mapToUserFriendlyName", { enumerable: true, get: function () { return transform_2.mapToUserFriendlyName; } });
70
- Object.defineProperty(exports, "mapToInternalType", { enumerable: true, get: function () { return transform_2.mapToInternalType; } });
71
- var schemas_1 = require("./lib/schemas");
72
- Object.defineProperty(exports, "getIntermediateRepresentationSchema", { enumerable: true, get: function () { return schemas_1.getIntermediateRepresentationSchema; } });
73
- var validation_2 = require("./lib/validation");
74
- Object.defineProperty(exports, "createAjvInstance", { enumerable: true, get: function () { return validation_2.createAjvInstance; } });
75
- var constants_1 = require("./lib/constants");
76
- Object.defineProperty(exports, "metafileExtension", { enumerable: true, get: function () { return constants_1.metafileExtension; } });
77
- Object.defineProperty(exports, "hsProjectJsonFilename", { enumerable: true, get: function () { return constants_1.hsProjectJsonFilename; } });
78
- var errors_2 = require("./lib/errors");
79
- Object.defineProperty(exports, "AjvErrorKeyword", { enumerable: true, get: function () { return errors_2.AjvErrorKeyword; } });
80
- var copy_2 = require("./lang/copy");
81
- Object.defineProperty(exports, "getInvalidJsonError", { enumerable: true, get: function () { return copy_2.getInvalidJsonError; } });
82
- Object.defineProperty(exports, "getMissingTypeError", { enumerable: true, get: function () { return copy_2.getMissingTypeError; } });
83
- Object.defineProperty(exports, "getMissingConfigError", { enumerable: true, get: function () { return copy_2.getMissingConfigError; } });
84
- Object.defineProperty(exports, "getMissingAccountIdError", { enumerable: true, get: function () { return copy_2.getMissingAccountIdError; } });
85
- Object.defineProperty(exports, "getMissingRequiredFieldError", { enumerable: true, get: function () { return copy_2.getMissingRequiredFieldError; } });
86
- Object.defineProperty(exports, "getFailedToFetchSchemasError", { enumerable: true, get: function () { return copy_2.getFailedToFetchSchemasError; } });
87
- Object.defineProperty(exports, "getUnsupportedTypeError", { enumerable: true, get: function () { return copy_2.getUnsupportedTypeError; } });