@hubspot/project-parsing-lib 0.0.2-experimental.0 → 0.0.4-beta.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/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@hubspot/project-parsing-lib",
3
- "version": "0.0.2-experimental.0",
3
+ "version": "0.0.4-beta.0",
4
4
  "description": "Parsing library for converting projects directory structures to their intermediate representation",
5
5
  "license": "Apache-2.0",
6
6
  "main": "src/index.js",
7
7
  "devDependencies": {
8
+ "@hubspot/local-dev-lib": "^3.1.0",
8
9
  "@inquirer/prompts": "^7.1.0",
9
10
  "@types/jest": "^29.5.14",
10
11
  "@types/semver": "^7.5.8",
@@ -22,9 +23,11 @@
22
23
  "typescript": "^5.6.2"
23
24
  },
24
25
  "dependencies": {
25
- "@hubspot/local-dev-lib": "3.1.0",
26
- "ajv": "^8.17.1",
27
- "ajv-draft-04": "^1.0.0"
26
+ "ajv": "8.17.1",
27
+ "ajv-draft-04": "1.0.0"
28
+ },
29
+ "peerDependencies": {
30
+ "@hubspot/local-dev-lib": "^3.1.0"
28
31
  },
29
32
  "scripts": {
30
33
  "build": "ts-node ./scripts/build.ts",
@@ -15,6 +15,7 @@ interface ComponentMetadata {
15
15
  parentComponent?: string;
16
16
  }
17
17
  export declare const Components: Record<string, ComponentMetadata>;
18
+ export declare const externalTypeToInternalType: Record<string, string>;
18
19
  export declare const metafileExtension = "-hsmeta.json";
19
20
  export declare const allowedAppSubComponentsDirs: string[];
20
21
  export declare const allowedThemeSubComponentsDirs: string[];
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.allowedSubComponentDirectories = exports.allowedComponentDirectories = exports.ProjectStructure = exports.allowedThemeSubComponentsDirs = exports.allowedAppSubComponentsDirs = exports.metafileExtension = exports.Components = exports.WorkflowActionsKey = exports.WebhooksKey = exports.VideoConferencingKey = exports.TimelineEventsKey = exports.MediaBridgeKey = exports.MarketingEventsKey = exports.FunctionsKey = exports.CardsKey = exports.CallingKey = exports.ThemeKey = exports.AppKey = void 0;
26
+ exports.allowedSubComponentDirectories = exports.allowedComponentDirectories = exports.ProjectStructure = exports.allowedThemeSubComponentsDirs = exports.allowedAppSubComponentsDirs = exports.metafileExtension = exports.externalTypeToInternalType = exports.Components = exports.WorkflowActionsKey = exports.WebhooksKey = exports.VideoConferencingKey = exports.TimelineEventsKey = exports.MediaBridgeKey = exports.MarketingEventsKey = exports.FunctionsKey = exports.CardsKey = exports.CallingKey = exports.ThemeKey = exports.AppKey = void 0;
27
27
  // Top Level Component types
28
28
  const path = __importStar(require("path"));
29
29
  // Component types
@@ -85,6 +85,9 @@ exports.Components = {
85
85
  parentComponent: exports.AppKey,
86
86
  },
87
87
  };
88
+ exports.externalTypeToInternalType = {
89
+ [exports.AppKey]: 'application',
90
+ };
88
91
  exports.metafileExtension = '-hsmeta.json';
89
92
  function getSubComponentDirsForParentType(parentComponent) {
90
93
  return Object.values(exports.Components).reduce((acc, item) => {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getIntermediateRepresentationSchema = getIntermediateRepresentationSchema;
4
4
  const http_1 = require("@hubspot/local-dev-lib/http");
5
+ const index_1 = require("@hubspot/local-dev-lib/errors/index");
5
6
  async function getIntermediateRepresentationSchema(translationContext) {
6
7
  try {
7
8
  const { accountId } = translationContext;
@@ -12,6 +13,9 @@ async function getIntermediateRepresentationSchema(translationContext) {
12
13
  return data;
13
14
  }
14
15
  catch (e) {
16
+ if ((0, index_1.isHubSpotHttpError)(e)) {
17
+ throw e;
18
+ }
15
19
  throw new Error('Failed to fetch schemas', { cause: e });
16
20
  }
17
21
  }
@@ -14,6 +14,9 @@ function calculateComponentDeps(fileValidationResult, parentComponents) {
14
14
  : {}),
15
15
  };
16
16
  }
17
+ function mapToInternalType(type) {
18
+ return (constants_1.externalTypeToInternalType[type] || type || '').toUpperCase();
19
+ }
17
20
  function transform(fileParseResults) {
18
21
  const parentTypes = Object.keys(constants_1.ProjectStructure);
19
22
  // Compute the parent components, so we can add them as dependencies to the child components
@@ -28,12 +31,12 @@ function transform(fileParseResults) {
28
31
  currentFile.errors?.push(`File content is missing for ${currentFile.file}`);
29
32
  return { intermediateRepresentation: null, fileParseResult: currentFile };
30
33
  }
31
- const { config, uid } = currentFile.content;
34
+ const { config, uid, type } = currentFile.content;
32
35
  return {
33
36
  intermediateRepresentation: {
34
37
  uid,
35
38
  config,
36
- componentType: currentFile.content?.type.toUpperCase() || '',
39
+ componentType: mapToInternalType(type),
37
40
  componentDeps: calculateComponentDeps(currentFile, parentComponents),
38
41
  files: {},
39
42
  },