@hubspot/project-parsing-lib 0.10.3 → 0.11.0-beta.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.
Files changed (50) hide show
  1. package/package.json +48 -11
  2. package/src/exports/constants.d.ts +1 -0
  3. package/src/exports/constants.js +1 -0
  4. package/src/exports/migrate.d.ts +1 -0
  5. package/src/exports/migrate.js +1 -0
  6. package/src/exports/profiles.d.ts +3 -0
  7. package/src/exports/profiles.js +2 -0
  8. package/src/exports/projects.d.ts +3 -0
  9. package/src/exports/projects.js +2 -0
  10. package/src/exports/schema.d.ts +2 -0
  11. package/src/exports/schema.js +1 -0
  12. package/src/exports/themes.d.ts +2 -0
  13. package/src/exports/themes.js +1 -0
  14. package/src/exports/transform.d.ts +2 -0
  15. package/src/exports/transform.js +1 -0
  16. package/src/exports/translate.d.ts +3 -0
  17. package/src/exports/translate.js +2 -0
  18. package/src/exports/uid.d.ts +1 -0
  19. package/src/exports/uid.js +1 -0
  20. package/src/lang/copy.d.ts +1 -1
  21. package/src/lang/copy.js +21 -31
  22. package/src/lib/constants.d.ts +38 -38
  23. package/src/lib/constants.js +120 -153
  24. package/src/lib/errors.d.ts +2 -2
  25. package/src/lib/errors.js +19 -29
  26. package/src/lib/files.d.ts +1 -1
  27. package/src/lib/files.js +36 -47
  28. package/src/lib/localDev.d.ts +1 -1
  29. package/src/lib/localDev.js +8 -16
  30. package/src/lib/migrate.js +34 -40
  31. package/src/lib/migrateThemes.d.ts +3 -4
  32. package/src/lib/migrateThemes.js +31 -38
  33. package/src/lib/profiles.d.ts +1 -1
  34. package/src/lib/profiles.js +12 -20
  35. package/src/lib/project.js +11 -17
  36. package/src/lib/schemas.d.ts +2 -2
  37. package/src/lib/schemas.js +8 -11
  38. package/src/lib/transform.d.ts +1 -1
  39. package/src/lib/transform.js +50 -64
  40. package/src/lib/translate.d.ts +3 -0
  41. package/src/lib/translate.js +52 -0
  42. package/src/lib/types.d.ts +1 -1
  43. package/src/lib/types.js +1 -2
  44. package/src/lib/uid.js +9 -14
  45. package/src/lib/utils.d.ts +1 -1
  46. package/src/lib/utils.js +7 -14
  47. package/src/lib/validation.d.ts +3 -3
  48. package/src/lib/validation.js +46 -46
  49. package/src/index.d.ts +0 -19
  50. package/src/index.js +0 -94
package/package.json CHANGED
@@ -1,29 +1,66 @@
1
1
  {
2
2
  "name": "@hubspot/project-parsing-lib",
3
- "version": "0.10.3",
3
+ "version": "0.11.0-beta.1",
4
4
  "description": "Parsing library for converting projects directory structures to their intermediate representation",
5
5
  "license": "Apache-2.0",
6
- "main": "src/index.js",
6
+ "type": "module",
7
+ "exports": {
8
+ "./constants": {
9
+ "import": "./src/exports/constants.js",
10
+ "types": "./src/exports/constants.d.ts"
11
+ },
12
+ "./migrate": {
13
+ "import": "./src/exports/migrate.js",
14
+ "types": "./src/exports/migrate.d.ts"
15
+ },
16
+ "./profiles": {
17
+ "import": "./src/exports/profiles.js",
18
+ "types": "./src/exports/profiles.d.ts"
19
+ },
20
+ "./projects": {
21
+ "import": "./src/exports/projects.js",
22
+ "types": "./src/exports/projects.d.ts"
23
+ },
24
+ "./schema": {
25
+ "import": "./src/exports/schema.js",
26
+ "types": "./src/exports/schema.d.ts"
27
+ },
28
+ "./themes": {
29
+ "import": "./src/exports/themes.js",
30
+ "types": "./src/exports/themes.d.ts"
31
+ },
32
+ "./transform": {
33
+ "import": "./src/exports/transform.js",
34
+ "types": "./src/exports/transform.d.ts"
35
+ },
36
+ "./translate": {
37
+ "import": "./src/exports/translate.js",
38
+ "types": "./src/exports/translate.d.ts"
39
+ },
40
+ "./uid": {
41
+ "import": "./src/exports/uid.js",
42
+ "types": "./src/exports/uid.d.ts"
43
+ }
44
+ },
7
45
  "devDependencies": {
8
- "@hubspot/npm-scripts": "0.0.4",
46
+ "@hubspot/npm-scripts": "0.0.6",
9
47
  "@inquirer/prompts": "^7.1.0",
10
- "@types/jest": "^29.5.14",
48
+ "@types/node": "^24.9.0",
11
49
  "@types/semver": "^7.5.8",
12
50
  "@typescript-eslint/eslint-plugin": "^8.11.0",
13
51
  "@typescript-eslint/parser": "^8.11.0",
14
- "eslint": "^8.56.0",
52
+ "eslint": "^9.38.0",
15
53
  "eslint-plugin-import": "^2.31.0",
16
54
  "husky": "^9.1.7",
17
- "jest": "^29.5.0",
18
55
  "lint-staged": "^10.5.4",
19
- "prettier": "^1.19.1",
56
+ "prettier": "^3.3.0",
20
57
  "semver": "^7.6.3",
21
- "ts-jest": "^29.2.5",
22
58
  "tsx": "^4.20.5",
23
- "typescript": "^5.6.2"
59
+ "typescript": "^5.6.2",
60
+ "vitest": "^2.1.9"
24
61
  },
25
62
  "dependencies": {
26
- "@hubspot/local-dev-lib": "4.0.0",
63
+ "@hubspot/local-dev-lib": "4.0.4",
27
64
  "ajv": "8.17.1",
28
65
  "ajv-formats": "3.0.1"
29
66
  },
@@ -34,7 +71,7 @@
34
71
  "local-dev": "yarn build && cd dist && yarn link && cd .. && tsc --watch --rootDir . --outdir dist",
35
72
  "local-link": "hubspot-linking",
36
73
  "prettier:write": "prettier ./src/** --write",
37
- "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ./node_modules/.bin/jest",
74
+ "test": "vitest run",
38
75
  "release": "tsx ./scripts/release.ts release",
39
76
  "acceptance-test": "yarn --cwd=./acceptance-tests test"
40
77
  },
@@ -0,0 +1 @@
1
+ export * from '../lib/constants.js';
@@ -0,0 +1 @@
1
+ export * from '../lib/constants.js';
@@ -0,0 +1 @@
1
+ export { migrate } from '../lib/migrate.js';
@@ -0,0 +1 @@
1
+ export { migrate } from '../lib/migrate.js';
@@ -0,0 +1,3 @@
1
+ export { getAllHsProfiles, loadHsProfileFile } from '../lib/files.js';
2
+ export { getHsProfileFilename, validateProfileVariables, } from '../lib/profiles.js';
3
+ export type { HsProfileFile, HSProfileVariables } from '../lib/types.js';
@@ -0,0 +1,2 @@
1
+ export { getAllHsProfiles, loadHsProfileFile } from '../lib/files.js';
2
+ export { getHsProfileFilename, validateProfileVariables, } from '../lib/profiles.js';
@@ -0,0 +1,3 @@
1
+ export { getProjectMetadata } from '../lib/project.js';
2
+ export { projectContainsHsMetaFiles } from '../lib/files.js';
3
+ export type { ProjectMetadata } from '../lib/project.js';
@@ -0,0 +1,2 @@
1
+ export { getProjectMetadata } from '../lib/project.js';
2
+ export { projectContainsHsMetaFiles } from '../lib/files.js';
@@ -0,0 +1,2 @@
1
+ export { getIntermediateRepresentationSchema } from '../lib/schemas.js';
2
+ export type { AnySchema } from 'ajv';
@@ -0,0 +1 @@
1
+ export { getIntermediateRepresentationSchema } from '../lib/schemas.js';
@@ -0,0 +1,2 @@
1
+ export { migrateThemes, getProjectThemeDetails } from '../lib/migrateThemes.js';
2
+ export type { ThemeDetails, ReactThemeDetails, ProjectThemeDetails, } from '../lib/migrateThemes.js';
@@ -0,0 +1 @@
1
+ export { migrateThemes, getProjectThemeDetails } from '../lib/migrateThemes.js';
@@ -0,0 +1,2 @@
1
+ export { mapToUserFriendlyName, mapToUserFacingType, mapToInternalType, } from '../lib/transform.js';
2
+ export type { Dependencies } from '../lib/types.js';
@@ -0,0 +1 @@
1
+ export { mapToUserFriendlyName, mapToUserFacingType, mapToInternalType, } from '../lib/transform.js';
@@ -0,0 +1,3 @@
1
+ export { translate, translateForLocalDev } from '../lib/translate.js';
2
+ export { isTranslationError, type TranslationError } from '../lib/errors.js';
3
+ export type { IntermediateRepresentation, IntermediateRepresentationLocalDev, IntermediateRepresentationNodeLocalDev, IntermediateRepresentationNode, TranslationContext, TranslationOptions, TranslationOptionsLocalDev, } from '../lib/types.js';
@@ -0,0 +1,2 @@
1
+ export { translate, translateForLocalDev } from '../lib/translate.js';
2
+ export { isTranslationError } from '../lib/errors.js';
@@ -0,0 +1 @@
1
+ export { validateUid, coerceToValidUid } from '../lib/uid.js';
@@ -0,0 +1 @@
1
+ export { validateUid, coerceToValidUid } from '../lib/uid.js';
@@ -1,4 +1,4 @@
1
- import { ComponentMetadata } from '../lib/constants';
1
+ import { ComponentMetadata } from '../lib/constants.js';
2
2
  export declare const errorMessages: {
3
3
  api: {
4
4
  failedToFetchSchemas: string;
package/src/lang/copy.js CHANGED
@@ -1,27 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logMessages = exports.errorMessages = void 0;
4
- exports.getInvalidJsonError = getInvalidJsonError;
5
- exports.getMissingTypeError = getMissingTypeError;
6
- exports.getMissingConfigError = getMissingConfigError;
7
- exports.getMissingAccountIdError = getMissingAccountIdError;
8
- exports.getMissingRequiredFieldError = getMissingRequiredFieldError;
9
- exports.getFailedToFetchSchemasError = getFailedToFetchSchemasError;
10
- exports.getUnsupportedTypeError = getUnsupportedTypeError;
11
- const constants_1 = require("../lib/constants");
12
- const transform_1 = require("../lib/transform");
13
- exports.errorMessages = {
1
+ import { APP_FUNCTIONS_KEY, APP_KEY, Components, PACKAGE_JSON, } from '../lib/constants.js';
2
+ import { mapToUserFacingType } from '../lib/transform.js';
3
+ export const errorMessages = {
14
4
  api: {
15
5
  failedToFetchSchemas: 'Failed to fetch schemas',
16
6
  accountIdIsRequiredToFetchSchemas: 'Account id is required to fetch schemas',
17
7
  },
18
8
  project: {
19
- mustHaveAppComponent: (componentType) => `This '${componentType}' component must be a child of the '${constants_1.AppKey}' component. No *-hsmeta.json files were found with type '${constants_1.AppKey}'`,
9
+ mustHaveAppComponent: (componentType) => `This '${componentType}' component must be a child of the '${APP_KEY}' component. No *-hsmeta.json files were found with type '${APP_KEY}'`,
20
10
  noHsMetaFiles: 'No *-hsmeta.json files found in the current directory. Please make sure you are inside the correct project directory.',
21
11
  failedToTranslateProject: 'Project validation failed',
22
12
  duplicateUid: (uid, files) => `Duplicate uid '${uid}' found in:\n- ${files.join('\n- ')}`,
23
13
  duplicateComponent: (componentType) => `Only one ${componentType} component is allowed`,
24
- noPackageJsonForServerless: (appFunctionsPackageFile) => `${appFunctionsPackageFile} does not exist. ${constants_1.Components[constants_1.AppFunctionsKey].userFriendlyName} requires a ${constants_1.packageJson} file to exist in this location`,
14
+ noPackageJsonForServerless: (appFunctionsPackageFile) => `${appFunctionsPackageFile} does not exist. ${Components[APP_FUNCTIONS_KEY].userFriendlyName} requires a ${PACKAGE_JSON} file to exist in this location`,
25
15
  fileContentMissingFor: (file) => `File content is missing for ${file}`,
26
16
  },
27
17
  profile: {
@@ -39,7 +29,7 @@ exports.errorMessages = {
39
29
  uidTooLong: `'uid' must be 64 characters or less`,
40
30
  missingType: `Missing required field: 'type'`,
41
31
  missingConfig: `Missing required field: 'config'`,
42
- unsupportedType: (type) => `Unsupported type: ${(0, transform_1.mapToUserFacingType)(type)}`,
32
+ unsupportedType: (type) => `Unsupported type: ${mapToUserFacingType(type)}`,
43
33
  errorWithField: (field, error) => `${field}: ${error || 'Unknown error'}`,
44
34
  invalidJson: 'Invalid JSON',
45
35
  unexpectedToplevelFields: (unexpectedFields) => `Unexpected top-level properties found: ${unexpectedFields}`,
@@ -49,28 +39,28 @@ exports.errorMessages = {
49
39
  rootReactThemeNotSupported: 'Migrating themes that live at the root of the project src directory is not supported. Please move the theme to a subdirectory.',
50
40
  },
51
41
  };
52
- function getInvalidJsonError() {
53
- return exports.errorMessages.validation.invalidJson;
42
+ export function getInvalidJsonError() {
43
+ return errorMessages.validation.invalidJson;
54
44
  }
55
- function getMissingTypeError() {
56
- return exports.errorMessages.validation.missingType;
45
+ export function getMissingTypeError() {
46
+ return errorMessages.validation.missingType;
57
47
  }
58
- function getMissingConfigError() {
59
- return exports.errorMessages.validation.missingConfig;
48
+ export function getMissingConfigError() {
49
+ return errorMessages.validation.missingConfig;
60
50
  }
61
- function getMissingAccountIdError() {
62
- return exports.errorMessages.api.accountIdIsRequiredToFetchSchemas;
51
+ export function getMissingAccountIdError() {
52
+ return errorMessages.api.accountIdIsRequiredToFetchSchemas;
63
53
  }
64
- function getMissingRequiredFieldError(field) {
65
- return exports.errorMessages.validation.missingRequiredField(field);
54
+ export function getMissingRequiredFieldError(field) {
55
+ return errorMessages.validation.missingRequiredField(field);
66
56
  }
67
- function getFailedToFetchSchemasError() {
68
- return exports.errorMessages.api.failedToFetchSchemas;
57
+ export function getFailedToFetchSchemasError() {
58
+ return errorMessages.api.failedToFetchSchemas;
69
59
  }
70
- function getUnsupportedTypeError(type) {
71
- return exports.errorMessages.validation.unsupportedType(type);
60
+ export function getUnsupportedTypeError(type) {
61
+ return errorMessages.validation.unsupportedType(type);
72
62
  }
73
- exports.logMessages = {
63
+ export const logMessages = {
74
64
  files: {
75
65
  skippingPath: (path) => `Skipping ${path} as it is not in a valid directory`,
76
66
  },
@@ -1,26 +1,26 @@
1
- import { Components as ComponentsTopLevel } from './types';
2
- export declare const AppKey = "app";
3
- export declare const ThemeKey = "theme";
4
- export declare const CmsAssetsKey = "cms-assets";
5
- export declare const AppEventsKey = "app-event";
6
- export declare const AppFunctionsKey = "app-function";
7
- export declare const PagesKey = "page";
8
- export declare const AppObjectKey = "app-object";
9
- export declare const AppObjectAssociationKey = "app-object-association";
10
- export declare const CallingKey = "calling";
11
- export declare const CardsKey = "card";
12
- export declare const SCIMKey = "scim";
13
- export declare const MarketingEventsKey = "marketing-event";
14
- export declare const MCPRegistryKey = "mcp-registry";
15
- export declare const MediaBridgeKey = "media-bridge";
16
- export declare const SettingsKey = "settings";
17
- export declare const TelemetryKey = "telemetry";
18
- export declare const VideoConferencingKey = "video-conferencing";
19
- export declare const WebhooksKey = "webhooks";
20
- export declare const WebhooksJournalKey = "webhooks-journal";
21
- export declare const WorkflowActionsKey = "workflow-action";
22
- export declare const AppFunctionsPackageKey = "serverless-package";
23
- export declare const AutoGeneratedComponentTypes: string[];
1
+ import { Components as ComponentsTopLevel } from './types.js';
2
+ export declare const APP_KEY = "app";
3
+ export declare const THEME_KEY = "theme";
4
+ export declare const CMS_ASSETS_KEY = "cms-assets";
5
+ export declare const APP_EVENTS_KEY = "app-event";
6
+ export declare const APP_FUNCTIONS_KEY = "app-function";
7
+ export declare const PAGES_KEY = "page";
8
+ export declare const APP_OBJECT_KEY = "app-object";
9
+ export declare const APP_OBJECT_ASSOCIATION_KEY = "app-object-association";
10
+ export declare const CALLING_KEY = "calling";
11
+ export declare const CARDS_KEY = "card";
12
+ export declare const SCIM_KEY = "scim";
13
+ export declare const MARKETING_EVENTS_KEY = "marketing-event";
14
+ export declare const MCP_REGISTRY_KEY = "mcp-registry";
15
+ export declare const MEDIA_BRIDGE_KEY = "media-bridge";
16
+ export declare const SETTINGS_KEY = "settings";
17
+ export declare const TELEMETRY_KEY = "telemetry";
18
+ export declare const VIDEO_CONFERENCING_KEY = "video-conferencing";
19
+ export declare const WEBHOOKS_KEY = "webhooks";
20
+ export declare const WEBHOOKS_JOURNAL_KEY = "webhooks-journal";
21
+ export declare const WORKFLOW_ACTIONS_KEY = "workflow-action";
22
+ export declare const APP_FUNCTIONS_PACKAGE_KEY = "serverless-package";
23
+ export declare const AUTO_GENERATED_COMPONENT_TYPES: string[];
24
24
  export interface ComponentMetadata {
25
25
  dir: string;
26
26
  isToplevel: boolean;
@@ -31,27 +31,27 @@ export interface ComponentMetadata {
31
31
  singularComponent?: boolean;
32
32
  }
33
33
  export declare const Components: Record<string, ComponentMetadata>;
34
- export declare const userFacingToInternalType: Record<string, string>;
35
- export declare const internalTypeToUserFacing: Record<string, string>;
36
- export declare const metafileExtension = "-hsmeta.json";
37
- export declare const profileFilePrefix = "hsprofile";
38
- export declare const hsProjectJsonFilename = "hsproject.json";
39
- export declare const packageJson = "package.json";
40
- export declare const packageLockJson = "package-lock.json";
41
- export declare const allowedAppSubComponentsDirs: string[];
42
- export declare const allowedThemeSubComponentsDirs: string[];
43
- export declare const allowedCmsAssetSubComponentDirs: string[];
44
- export declare const ProjectStructure: {
34
+ export declare const USER_FACING_TO_INTERNAL_TYPE: Record<string, string>;
35
+ export declare const INTERNAL_TYPE_TO_USER_FACING: Record<string, string>;
36
+ export declare const METAFILE_EXTENSION = "-hsmeta.json";
37
+ export declare const PROFILE_FILE_PREFIX = "hsprofile";
38
+ export declare const HS_PROJECT_JSON_FILENAME = "hsproject.json";
39
+ export declare const PACKAGE_JSON = "package.json";
40
+ export declare const PACKAGE_LOCK_JSON = "package-lock.json";
41
+ export declare const ALLOWED_APP_SUB_COMPONENTS_DIRS: string[];
42
+ export declare const ALLOWED_THEME_SUB_COMPONENTS_DIRS: string[];
43
+ export declare const ALLOWED_CMS_ASSET_SUB_COMPONENT_DIRS: string[];
44
+ export declare const PROJECT_STRUCTURE: {
45
45
  readonly app: string[];
46
46
  readonly theme: string[];
47
47
  readonly "cms-assets": string[];
48
48
  };
49
- export declare const allowedComponentDirectories: string[];
50
- export declare const allowedSubComponentDirectories: string[];
51
- export declare const ProfileVariableTypes: {
49
+ export declare const ALLOWED_COMPONENT_DIRECTORIES: string[];
50
+ export declare const ALLOWED_SUB_COMPONENT_DIRECTORIES: string[];
51
+ export declare const PROFILE_VARIABLE_TYPES: {
52
52
  readonly PROFILE_INT: "PROFILE_INT";
53
53
  readonly PROFILE_LONG: "PROFILE_LONG";
54
54
  readonly PROFILE_STRING: "PROFILE_STRING";
55
55
  readonly PROFILE_BOOLEAN: "PROFILE_BOOLEAN";
56
56
  };
57
- export declare const allowedTopLevelFields: Set<keyof ComponentsTopLevel>;
57
+ export declare const ALLOWED_TOP_LEVEL_FIELDS: Set<keyof ComponentsTopLevel>;