@hubspot/project-parsing-lib 0.11.0 → 0.11.1

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/README.md CHANGED
@@ -1,38 +1,7 @@
1
- # project-translation-layer
1
+ # @hubspot/project-parsing-lib
2
2
 
3
- ## Description
4
- This project is a translation layer that can be used to translate a project to its immediate representation prior to being uploaded
5
- to the project v2 service.
3
+ A parsing library for converting HubSpot project directory structures to their intermediate representation (IR).
6
4
 
7
- ## Flow Chart
5
+ ## Description
8
6
 
9
- ```mermaid
10
- sequenceDiagram
11
- autonumber
12
-
13
- actor dev as External Developer
14
- participant cli as HS CLI
15
- participant ppl as Project Parsing Library
16
- participant pv3 as Projects v3
17
-
18
- dev ->> cli: Developer runs `hs project upload`
19
- cli ->> cli: Loads project config
20
- cli ->> ppl: CLI calls `translate` function with the values required from the project config
21
- ppl ->> ppl: Walks the project directory looking for the hsmeta files
22
- loop For each hsmeta file
23
- ppl ->> ppl: Checks if file is valid JSON
24
- ppl ->> ppl: Checks if the file is in a valid location
25
- ppl ->> ppl: Generates the IR
26
- end
27
- ppl ->> pv3: Fetch the schemas used to validate the generated IR
28
- loop For each hsmeta file
29
- ppl ->> ppl: Validate the IR config block against the schema
30
- end
31
- alt Validation successful for all schemas
32
- ppl ->> cli: Pass the IR back to the CLI
33
- cli ->> cli: Zip the project contents
34
- cli ->> pv3: Upload the project and the IR
35
- else Validation failed for 1+ schema(s)
36
- ppl ->> cli: Log the error and exit the upload
37
- end
38
- ```
7
+ This library provides functionality to parse HubSpot project structures and convert them into an intermediate representation that can be uploaded to HubSpot. It walks through project directories, locates `.hsmeta.json` files, validates them, and generates the IR needed for project uploads.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/project-parsing-lib",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Parsing library for converting projects directory structures to their intermediate representation",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -6,7 +6,7 @@ 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
@@ -21,7 +21,7 @@ export class TranslationError extends Error {
21
21
  this.errors = transformations.map((transformation, index) => compileTranslationErrors(transformation, errors[index]));
22
22
  }
23
23
  // Returns a formatted string for all the errors in all the files
24
- toString() {
24
+ toString(includeMessage = true) {
25
25
  const listOfErrors = this.errors.map(({ file, errors }) => {
26
26
  if (errors.length === 0) {
27
27
  return null;
@@ -30,9 +30,11 @@ export class TranslationError extends Error {
30
30
  const relativePath = path.relative(projectRoot, path.join(this.translationContext.projectSourceDir, file));
31
31
  return errorMessages.validation.errorWithFileHeader(relativePath, errors);
32
32
  });
33
- return `${this.message}:${listOfErrors
34
- .filter(error => error !== null)
35
- .join('')}`;
33
+ const errorString = listOfErrors.filter(error => error !== null).join('');
34
+ if (includeMessage) {
35
+ return `${this.message}:${errorString}`;
36
+ }
37
+ return errorString.trimStart();
36
38
  }
37
39
  }
38
40
  function generateDotNotationPath(error) {