@hubspot/project-parsing-lib 0.2.2 → 0.3.0-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 (66) hide show
  1. package/README.md +9 -35
  2. package/package.json +135 -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 +5 -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 +4 -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 +19 -3
  28. package/src/lang/copy.js +40 -34
  29. package/src/lib/constants.d.ts +57 -29
  30. package/src/lib/constants.js +173 -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 +13 -7
  34. package/src/lib/files.js +56 -49
  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 +8 -0
  44. package/src/lib/platformVersion.js +74 -0
  45. package/src/lib/profiles.d.ts +6 -1
  46. package/src/lib/profiles.js +98 -40
  47. package/src/lib/project.d.ts +6 -0
  48. package/src/lib/project.js +73 -17
  49. package/src/lib/schemas.d.ts +2 -2
  50. package/src/lib/schemas.js +11 -11
  51. package/src/lib/transform.d.ts +4 -2
  52. package/src/lib/transform.js +109 -59
  53. package/src/lib/translate.d.ts +11 -0
  54. package/src/lib/translate.js +65 -0
  55. package/src/lib/types.d.ts +43 -6
  56. package/src/lib/types.js +1 -2
  57. package/src/lib/uid.d.ts +2 -0
  58. package/src/lib/uid.js +14 -9
  59. package/src/lib/utils.d.ts +3 -0
  60. package/src/lib/utils.js +16 -0
  61. package/src/lib/validation.d.ts +4 -4
  62. package/src/lib/validation.js +66 -53
  63. package/src/lib/workspaces.d.ts +113 -0
  64. package/src/lib/workspaces.js +403 -0
  65. package/src/index.d.ts +0 -18
  66. package/src/index.js +0 -87
@@ -1,191 +1,238 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
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);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.allowedSubComponentDirectories = exports.allowedComponentDirectories = exports.ProjectStructure = exports.allowedThemeSubComponentsDirs = exports.allowedAppSubComponentsDirs = exports.packageLockJson = exports.packageJson = exports.hsProjectJsonFilename = exports.profileFilePrefix = exports.metafileExtension = exports.internalTypeToUserFacing = exports.userFacingToInternalType = exports.Components = exports.AutoGeneratedComponentTypes = exports.AppFunctionsPackageKey = exports.WorkflowActionsKey = exports.WebhooksKey = exports.VideoConferencingKey = exports.TimelineEventsKey = exports.MediaBridgeKey = exports.MarketingEventsKey = exports.SettingsKey = exports.SCIMKey = exports.CardsKey = exports.CallingKey = exports.AppObjectAssociationKey = exports.AppObjectKey = exports.AppFunctionsKey = exports.ThemeKey = exports.AppKey = void 0;
1
+ // Previously supported Project Platform Versions
2
+ export const DEPRECATED_PLATFORM_VERSIONS = {
3
+ v2025_1: '2025.1',
4
+ };
5
+ // Supported Project Platform Versions
6
+ export const PLATFORM_VERSIONS = {
7
+ v2023_2: '2023.2',
8
+ v2025_2: '2025.2',
9
+ v2026_03_BETA: '2026.03-beta',
10
+ v2026_03: '2026.03',
11
+ v2026_09_BETA: '2026.09-beta',
12
+ UNSTABLE: 'unstable',
13
+ };
37
14
  // Top Level Component types
38
- const path = __importStar(require("path"));
15
+ import * as path from 'path';
39
16
  // Component types
40
- exports.AppKey = 'app';
41
- exports.ThemeKey = 'theme';
17
+ export const APP_KEY = 'app';
18
+ export const THEME_KEY = 'theme';
19
+ export const CMS_ASSETS_KEY = 'cms-assets';
42
20
  // Sub-Component types
43
- exports.AppFunctionsKey = 'app-function';
44
- exports.AppObjectKey = 'app-object';
45
- exports.AppObjectAssociationKey = 'app-object-association';
46
- exports.CallingKey = 'calling';
47
- exports.CardsKey = 'card';
48
- exports.SCIMKey = 'scim';
49
- exports.SettingsKey = 'settings';
50
- exports.MarketingEventsKey = 'marketing-event';
51
- exports.MediaBridgeKey = 'media-bridge';
52
- exports.TimelineEventsKey = 'timeline-event';
53
- exports.VideoConferencingKey = 'video-conferencing';
54
- exports.WebhooksKey = 'webhooks';
55
- exports.WorkflowActionsKey = 'workflow-action';
21
+ export const APP_EVENTS_KEY = 'app-event';
22
+ export const APP_FUNCTIONS_KEY = 'app-function';
23
+ export const PAGE_KEY = 'page';
24
+ export const PAGES_KEY = 'pages';
25
+ export const APP_OBJECT_KEY = 'app-object';
26
+ export const APP_OBJECT_ASSOCIATION_KEY = 'app-object-association';
27
+ export const CALLING_KEY = 'calling';
28
+ export const CARDS_KEY = 'card';
29
+ export const SCIM_KEY = 'scim';
30
+ export const MARKETING_EVENTS_KEY = 'marketing-event';
31
+ export const MCP_SERVER_KEY = 'mcp-server';
32
+ export const MEDIA_BRIDGE_KEY = 'media-bridge';
33
+ export const SETTINGS_KEY = 'settings';
34
+ export const TELEMETRY_KEY = 'telemetry';
35
+ export const VIDEO_CONFERENCING_KEY = 'video-conferencing';
36
+ export const WEBHOOKS_KEY = 'webhooks';
37
+ export const WEBHOOKS_JOURNAL_KEY = 'webhooks-journal';
38
+ export const WORKFLOW_ACTIONS_KEY = 'workflow-action';
39
+ export const ACTIONS_KEY = 'crm-bulk-action';
56
40
  // Auto-generated component types
57
- exports.AppFunctionsPackageKey = 'serverless-package';
58
- exports.AutoGeneratedComponentTypes = [exports.AppFunctionsPackageKey];
59
- const TopLevelComponentFields = {
41
+ export const APP_FUNCTIONS_PACKAGE_KEY = 'serverless-package';
42
+ export const AUTO_GENERATED_COMPONENT_TYPES = [APP_FUNCTIONS_PACKAGE_KEY];
43
+ const TOP_LEVEL_COMPONENT_FIELDS = {
60
44
  isToplevel: true,
61
45
  userFriendlyType: 'component',
62
46
  userFriendlyTypePlural: 'components',
63
47
  };
64
- const SubComponentFields = {
48
+ const SUB_COMPONENT_FIELDS = {
65
49
  isToplevel: false,
66
50
  userFriendlyType: 'feature',
67
51
  userFriendlyTypePlural: 'features',
68
52
  };
69
- exports.Components = {
70
- [exports.AppKey]: {
71
- dir: exports.AppKey,
53
+ const PAGE_COMPONENT = {
54
+ dir: 'pages',
55
+ parentComponent: APP_KEY,
56
+ ...SUB_COMPONENT_FIELDS,
57
+ userFriendlyName: 'Page',
58
+ singularComponent: true,
59
+ };
60
+ export const Components = {
61
+ [APP_KEY]: {
62
+ dir: APP_KEY,
72
63
  userFriendlyName: 'App',
73
- ...TopLevelComponentFields,
64
+ ...TOP_LEVEL_COMPONENT_FIELDS,
74
65
  singularComponent: true,
75
66
  },
76
- [exports.AppObjectKey]: {
67
+ [APP_OBJECT_KEY]: {
77
68
  dir: 'app-objects',
78
- parentComponent: exports.AppKey,
79
- ...SubComponentFields,
69
+ parentComponent: APP_KEY,
70
+ ...SUB_COMPONENT_FIELDS,
80
71
  userFriendlyName: 'App Object',
81
72
  },
82
- [exports.AppObjectAssociationKey]: {
73
+ [APP_OBJECT_ASSOCIATION_KEY]: {
83
74
  dir: 'app-object-associations',
84
- parentComponent: exports.AppKey,
85
- ...SubComponentFields,
75
+ parentComponent: APP_KEY,
76
+ ...SUB_COMPONENT_FIELDS,
86
77
  userFriendlyName: 'App Object Association',
87
78
  },
88
- [exports.ThemeKey]: {
89
- dir: exports.ThemeKey,
79
+ [PAGE_KEY]: PAGE_COMPONENT,
80
+ [PAGES_KEY]: PAGE_COMPONENT,
81
+ [THEME_KEY]: {
82
+ dir: THEME_KEY,
90
83
  userFriendlyName: 'Theme',
91
- ...TopLevelComponentFields,
84
+ ...TOP_LEVEL_COMPONENT_FIELDS,
92
85
  },
93
- [exports.CallingKey]: {
94
- dir: exports.CallingKey,
95
- parentComponent: exports.AppKey,
86
+ [CMS_ASSETS_KEY]: {
87
+ dir: CMS_ASSETS_KEY,
88
+ userFriendlyName: 'CMS Asset',
89
+ ...TOP_LEVEL_COMPONENT_FIELDS,
90
+ },
91
+ [CALLING_KEY]: {
92
+ dir: CALLING_KEY,
93
+ parentComponent: APP_KEY,
96
94
  userFriendlyName: 'Calling',
97
- ...SubComponentFields,
95
+ ...SUB_COMPONENT_FIELDS,
98
96
  singularComponent: true,
99
97
  },
100
- [exports.CardsKey]: {
98
+ [CARDS_KEY]: {
101
99
  dir: 'cards',
102
- parentComponent: exports.AppKey,
100
+ parentComponent: APP_KEY,
103
101
  userFriendlyName: 'Card',
104
- ...SubComponentFields,
102
+ ...SUB_COMPONENT_FIELDS,
105
103
  },
106
- [exports.AppFunctionsKey]: {
104
+ [APP_FUNCTIONS_KEY]: {
107
105
  dir: 'functions',
108
- parentComponent: exports.AppKey,
106
+ parentComponent: APP_KEY,
109
107
  userFriendlyName: 'App Function',
110
- ...SubComponentFields,
108
+ ...SUB_COMPONENT_FIELDS,
111
109
  },
112
- [exports.SCIMKey]: {
113
- dir: exports.SCIMKey,
114
- parentComponent: exports.AppKey,
110
+ [SCIM_KEY]: {
111
+ dir: SCIM_KEY,
112
+ parentComponent: APP_KEY,
115
113
  userFriendlyName: 'SCIM',
116
114
  singularComponent: true,
117
- ...SubComponentFields,
115
+ ...SUB_COMPONENT_FIELDS,
118
116
  },
119
- [exports.SettingsKey]: {
117
+ [SETTINGS_KEY]: {
120
118
  dir: 'settings',
121
- parentComponent: exports.AppKey,
119
+ parentComponent: APP_KEY,
122
120
  userFriendlyName: 'Settings Extension',
123
- ...SubComponentFields,
121
+ ...SUB_COMPONENT_FIELDS,
124
122
  singularComponent: true,
125
123
  },
126
- [exports.MarketingEventsKey]: {
124
+ [MARKETING_EVENTS_KEY]: {
127
125
  dir: 'marketing-events',
128
- parentComponent: exports.AppKey,
126
+ parentComponent: APP_KEY,
129
127
  userFriendlyName: 'Marketing Event',
130
- ...SubComponentFields,
128
+ ...SUB_COMPONENT_FIELDS,
131
129
  },
132
- MediaBridgeKey: {
133
- dir: exports.MediaBridgeKey,
134
- parentComponent: exports.AppKey,
130
+ [MEDIA_BRIDGE_KEY]: {
131
+ dir: MEDIA_BRIDGE_KEY,
132
+ parentComponent: APP_KEY,
135
133
  userFriendlyName: 'Media Bridge',
136
- ...SubComponentFields,
134
+ ...SUB_COMPONENT_FIELDS,
137
135
  },
138
- [exports.TimelineEventsKey]: {
139
- dir: 'timeline-events',
140
- parentComponent: exports.AppKey,
141
- userFriendlyName: 'Timeline Event',
142
- ...SubComponentFields,
136
+ [APP_EVENTS_KEY]: {
137
+ dir: 'app-events',
138
+ parentComponent: APP_KEY,
139
+ userFriendlyName: 'App Event',
140
+ ...SUB_COMPONENT_FIELDS,
143
141
  },
144
- [exports.VideoConferencingKey]: {
145
- dir: exports.VideoConferencingKey,
146
- parentComponent: exports.AppKey,
142
+ [VIDEO_CONFERENCING_KEY]: {
143
+ dir: VIDEO_CONFERENCING_KEY,
144
+ parentComponent: APP_KEY,
147
145
  userFriendlyName: 'Video Conferencing',
148
- ...SubComponentFields,
146
+ ...SUB_COMPONENT_FIELDS,
149
147
  },
150
- [exports.WebhooksKey]: {
151
- dir: exports.WebhooksKey,
152
- parentComponent: exports.AppKey,
148
+ [WEBHOOKS_KEY]: {
149
+ dir: WEBHOOKS_KEY,
150
+ parentComponent: APP_KEY,
153
151
  userFriendlyName: 'Webhooks',
154
- ...SubComponentFields,
152
+ ...SUB_COMPONENT_FIELDS,
153
+ singularComponent: true,
154
+ },
155
+ [WEBHOOKS_JOURNAL_KEY]: {
156
+ dir: WEBHOOKS_JOURNAL_KEY,
157
+ parentComponent: APP_KEY,
158
+ userFriendlyName: 'Webhooks Journal',
159
+ ...SUB_COMPONENT_FIELDS,
155
160
  singularComponent: true,
156
161
  },
157
- [exports.WorkflowActionsKey]: {
162
+ [WORKFLOW_ACTIONS_KEY]: {
158
163
  dir: 'workflow-actions',
159
- parentComponent: exports.AppKey,
164
+ parentComponent: APP_KEY,
160
165
  userFriendlyName: 'Workflow Action',
161
- ...SubComponentFields,
166
+ ...SUB_COMPONENT_FIELDS,
167
+ },
168
+ [ACTIONS_KEY]: {
169
+ dir: 'actions',
170
+ parentComponent: APP_KEY,
171
+ userFriendlyName: 'Action',
172
+ ...SUB_COMPONENT_FIELDS,
173
+ },
174
+ [TELEMETRY_KEY]: {
175
+ dir: TELEMETRY_KEY,
176
+ parentComponent: APP_KEY,
177
+ userFriendlyName: 'Telemetry',
178
+ singularComponent: true,
179
+ ...SUB_COMPONENT_FIELDS,
180
+ },
181
+ [MCP_SERVER_KEY]: {
182
+ dir: MCP_SERVER_KEY,
183
+ parentComponent: APP_KEY,
184
+ userFriendlyName: 'MCP Server',
185
+ singularComponent: true,
186
+ ...SUB_COMPONENT_FIELDS,
162
187
  },
163
188
  };
164
- exports.userFacingToInternalType = {
165
- [exports.AppKey]: 'APPLICATION',
166
- [exports.SCIMKey]: 'SCIM_INTEGRATION',
189
+ export const USER_FACING_TO_INTERNAL_TYPE = {
190
+ [APP_KEY]: 'APPLICATION',
191
+ [SCIM_KEY]: 'SCIM_INTEGRATION',
192
+ [TELEMETRY_KEY]: 'TELEMETRY_CONFIG',
193
+ [CMS_ASSETS_KEY]: 'REACT_THEME',
194
+ [PAGES_KEY]: 'PAGE',
167
195
  };
168
- exports.internalTypeToUserFacing = Object.fromEntries(Object.entries(exports.userFacingToInternalType).map(([key, value]) => [value, key]));
169
- exports.metafileExtension = '-hsmeta.json';
170
- exports.profileFilePrefix = 'hsprofile';
171
- exports.hsProjectJsonFilename = 'hsproject.json';
172
- exports.packageJson = 'package.json';
173
- exports.packageLockJson = 'package-lock.json';
196
+ export const INTERNAL_TYPE_TO_USER_FACING = Object.fromEntries(Object.entries(USER_FACING_TO_INTERNAL_TYPE).map(([key, value]) => [
197
+ value,
198
+ key,
199
+ ]));
200
+ export const METAFILE_EXTENSION = '-hsmeta.json';
201
+ export const PROFILE_FILE_PREFIX = 'hsprofile';
202
+ export const HS_PROJECT_JSON_FILENAME = 'hsproject.json';
203
+ export const PACKAGE_JSON = 'package.json';
204
+ export const PACKAGE_LOCK_JSON = 'package-lock.json';
174
205
  function getSubComponentDirsForParentType(parentComponent) {
175
- return Object.values(exports.Components).reduce((acc, item) => {
206
+ return Object.values(Components).reduce((acc, item) => {
176
207
  if (item.parentComponent === parentComponent) {
177
208
  acc.push(item.dir);
178
209
  }
179
210
  return acc;
180
211
  }, []);
181
212
  }
182
- exports.allowedAppSubComponentsDirs = getSubComponentDirsForParentType(exports.AppKey);
183
- exports.allowedThemeSubComponentsDirs = getSubComponentDirsForParentType(exports.ThemeKey);
184
- exports.ProjectStructure = {
185
- [exports.AppKey]: exports.allowedAppSubComponentsDirs,
186
- [exports.ThemeKey]: exports.allowedThemeSubComponentsDirs,
213
+ export const ALLOWED_APP_SUB_COMPONENTS_DIRS = getSubComponentDirsForParentType(APP_KEY);
214
+ export const ALLOWED_THEME_SUB_COMPONENTS_DIRS = getSubComponentDirsForParentType(THEME_KEY);
215
+ export const ALLOWED_CMS_ASSET_SUB_COMPONENT_DIRS = getSubComponentDirsForParentType(CMS_ASSETS_KEY);
216
+ export const PROJECT_STRUCTURE = {
217
+ [APP_KEY]: ALLOWED_APP_SUB_COMPONENTS_DIRS,
218
+ [THEME_KEY]: ALLOWED_THEME_SUB_COMPONENTS_DIRS,
219
+ [CMS_ASSETS_KEY]: ALLOWED_CMS_ASSET_SUB_COMPONENT_DIRS,
187
220
  };
188
- exports.allowedComponentDirectories = Object.keys(exports.ProjectStructure);
189
- exports.allowedSubComponentDirectories = Object.entries(exports.ProjectStructure)
221
+ export const ALLOWED_COMPONENT_DIRECTORIES = Object.keys(PROJECT_STRUCTURE);
222
+ export const ALLOWED_SUB_COMPONENT_DIRECTORIES = Object.entries(PROJECT_STRUCTURE)
190
223
  .map(([key, value]) => value.map((value) => path.join(key, value)))
191
224
  .flat();
225
+ // Profile variable types
226
+ export const PROFILE_VARIABLE_TYPES = {
227
+ PROFILE_INT: 'PROFILE_INT',
228
+ PROFILE_LONG: 'PROFILE_LONG',
229
+ PROFILE_STRING: 'PROFILE_STRING',
230
+ PROFILE_BOOLEAN: 'PROFILE_BOOLEAN',
231
+ };
232
+ export const ALLOWED_TOP_LEVEL_FIELDS = new Set([
233
+ 'uid',
234
+ 'type',
235
+ 'config',
236
+ 'dependencies',
237
+ 'permissions',
238
+ ]);
@@ -1,12 +1,12 @@
1
- import { CompiledError, Transformation, TranslationContext } from './types';
2
- import { ErrorObject } from 'ajv/dist/2020';
1
+ import { CompiledError, Transformation, TranslationContext } from './types.js';
2
+ import type { ErrorObject } from 'ajv';
3
3
  export declare function isTranslationError(error: unknown): error is TranslationError;
4
4
  export declare function compileError(validatedTransformation: Transformation): CompiledError;
5
5
  export declare class TranslationError extends Error {
6
6
  private errors;
7
7
  private translationContext;
8
8
  constructor(message: string, transformations: Transformation[], errors: (ErrorObject[] | null | undefined)[], translationContext: TranslationContext);
9
- toString(): string;
9
+ toString(includeMessage?: boolean): string;
10
10
  }
11
11
  export declare function extractDotNotationValueFromTransformation(dotNotation: string, transformation: Transformation): unknown;
12
12
  export declare const AjvErrorKeyword: {
package/src/lib/errors.js CHANGED
@@ -1,26 +1,17 @@
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.AjvErrorKeyword = exports.TranslationError = void 0;
7
- exports.isTranslationError = isTranslationError;
8
- exports.compileError = compileError;
9
- exports.extractDotNotationValueFromTransformation = extractDotNotationValueFromTransformation;
10
- const copy_1 = require("../lang/copy");
11
- const path_1 = __importDefault(require("path"));
12
- const logger_1 = require("@hubspot/local-dev-lib/logger");
13
- function isTranslationError(error) {
1
+ import { errorMessages } from '../lang/copy.js';
2
+ import path from 'path';
3
+ import { logger } from '@hubspot/local-dev-lib/logger';
4
+ export function isTranslationError(error) {
14
5
  return error instanceof TranslationError;
15
6
  }
16
- function compileError(validatedTransformation) {
7
+ export function compileError(validatedTransformation) {
17
8
  const { fileParseResult } = validatedTransformation;
18
9
  const { errors } = fileParseResult;
19
10
  return {
20
11
  errors,
21
12
  };
22
13
  }
23
- class TranslationError extends Error {
14
+ export class TranslationError extends Error {
24
15
  errors = [];
25
16
  translationContext;
26
17
  constructor(message, transformations, errors, translationContext) {
@@ -30,21 +21,22 @@ class TranslationError extends Error {
30
21
  this.errors = transformations.map((transformation, index) => compileTranslationErrors(transformation, errors[index]));
31
22
  }
32
23
  // Returns a formatted string for all the errors in all the files
33
- toString() {
24
+ toString(includeMessage = true) {
34
25
  const listOfErrors = this.errors.map(({ file, errors }) => {
35
26
  if (errors.length === 0) {
36
27
  return null;
37
28
  }
38
- const projectRoot = path_1.default.dirname(path_1.default.dirname(this.translationContext.projectSourceDir));
39
- const relativePath = path_1.default.relative(projectRoot, path_1.default.join(this.translationContext.projectSourceDir, file));
40
- return copy_1.errorMessages.validation.errorWithFileHeader(relativePath, errors);
29
+ const projectRoot = path.dirname(path.dirname(this.translationContext.projectSourceDir));
30
+ const relativePath = path.relative(projectRoot, path.join(this.translationContext.projectSourceDir, file));
31
+ return errorMessages.validation.errorWithFileHeader(relativePath, errors);
41
32
  });
42
- return `${this.message}:${listOfErrors
43
- .filter(error => error !== null)
44
- .join('')}`;
33
+ const errorString = listOfErrors.filter(error => error !== null).join('');
34
+ if (includeMessage) {
35
+ return `${this.message}:${errorString}`;
36
+ }
37
+ return errorString.trimStart();
45
38
  }
46
39
  }
47
- exports.TranslationError = TranslationError;
48
40
  function generateDotNotationPath(error) {
49
41
  const { instancePath } = error;
50
42
  const errorPath = instancePath
@@ -104,7 +96,7 @@ function preprocessSpecialErrors(schemaErrors, transformation) {
104
96
  }
105
97
  function generateErrorMessage(error, transformation) {
106
98
  const errorPath = generateDotNotationPath(error);
107
- const errorMessage = copy_1.errorMessages.validation.errorWithField(errorPath, error.message);
99
+ const errorMessage = errorMessages.validation.errorWithField(errorPath, error.message);
108
100
  const params = Object.entries(error.params);
109
101
  if (params.length === 0) {
110
102
  return errorMessage;
@@ -113,12 +105,12 @@ function generateErrorMessage(error, transformation) {
113
105
  .filter(([_, value]) => value)
114
106
  .map(([key, value]) => `${key}: ${Array.isArray(value) ? value.join(', ') : value}`);
115
107
  if (isRequiredError(error)) {
116
- return copy_1.errorMessages.validation.missingRequiredField(`${errorPath}.${error.params.missingProperty}`);
108
+ return errorMessages.validation.missingRequiredField(`${errorPath}.${error.params.missingProperty}`);
117
109
  }
118
110
  else if (isTypeError(error)) {
119
111
  const dotNotationPath = generateDotNotationPath(error);
120
112
  const value = extractDotNotationValueFromTransformation(dotNotationPath, transformation);
121
- return copy_1.errorMessages.validation.errorWithField(value !== undefined
113
+ return errorMessages.validation.errorWithField(value !== undefined
122
114
  ? `Value (${value}) in ${dotNotationPath}`
123
115
  : dotNotationPath, error.message);
124
116
  }
@@ -142,7 +134,7 @@ function mergeEnumErrors(cur, next) {
142
134
  },
143
135
  };
144
136
  }
145
- function extractDotNotationValueFromTransformation(dotNotation, transformation) {
137
+ export function extractDotNotationValueFromTransformation(dotNotation, transformation) {
146
138
  try {
147
139
  const parts = dotNotation.split('.');
148
140
  if (!transformation?.fileParseResult?.content || parts.length === 0) {
@@ -169,22 +161,22 @@ function extractDotNotationValueFromTransformation(dotNotation, transformation)
169
161
  return value;
170
162
  }
171
163
  catch (e) {
172
- logger_1.logger.debug('Unable to parse dot notation path to located value', e);
164
+ logger.debug('Unable to parse dot notation path to located value', e);
173
165
  }
174
166
  }
175
167
  function isOneOfError(error) {
176
- return error.keyword === exports.AjvErrorKeyword.OneOf;
168
+ return error.keyword === AjvErrorKeyword.OneOf;
177
169
  }
178
170
  function isRequiredError(error) {
179
- return error.keyword === exports.AjvErrorKeyword.Required;
171
+ return error.keyword === AjvErrorKeyword.Required;
180
172
  }
181
173
  function isEnumError(error) {
182
- return error.keyword === exports.AjvErrorKeyword.Enum;
174
+ return error.keyword === AjvErrorKeyword.Enum;
183
175
  }
184
176
  function isTypeError(error) {
185
- return error.keyword === exports.AjvErrorKeyword.Type;
177
+ return error.keyword === AjvErrorKeyword.Type;
186
178
  }
187
- exports.AjvErrorKeyword = {
179
+ export const AjvErrorKeyword = {
188
180
  AdditionalItems: 'additionalItems',
189
181
  AdditionalProperties: 'additionalProperties',
190
182
  Dependencies: 'dependencies',
@@ -1,13 +1,19 @@
1
- import { FileParseResult, TranslationContext, HsProfileFile } from './types';
2
- type MetaFileLocation = {
1
+ import { FileParseResult, HsProfileFile, TranslationContext } from './types.js';
2
+ export type MetaFileLocation = {
3
3
  file: string;
4
4
  parentDirectory?: string;
5
5
  };
6
6
  export declare function loadHsProfileFile(projectSourceDir: string, profile: string): HsProfileFile;
7
7
  export declare function getAllHsProfiles(projectSourceDir: string): Promise<string[]>;
8
- export declare function loadHsMetaFiles(translationContext: TranslationContext): Promise<FileParseResult[]>;
9
- export declare function locateHsMetaFiles(projectSourceDir: string, options?: {
10
- silent: boolean;
11
- }): Promise<MetaFileLocation[]>;
8
+ export type LoadHsMetaFilesResult = {
9
+ results: FileParseResult[];
10
+ skippedFiles: string[];
11
+ };
12
+ export declare function loadHsMetaFiles(translationContext: TranslationContext): Promise<LoadHsMetaFilesResult>;
13
+ export type LocateHsMetaFilesResult = {
14
+ metaFiles: MetaFileLocation[];
15
+ skippedFiles: string[];
16
+ };
17
+ export declare function locateHsMetaFiles(projectSourceDir: string): Promise<LocateHsMetaFilesResult>;
12
18
  export declare function projectContainsHsMetaFiles(projectSourceDir: string): Promise<boolean>;
13
- export {};
19
+ export declare function convertPathToPosixPath(filepath: string): string;