@hubspot/project-parsing-lib 0.10.3 → 0.11.0-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 +48 -11
- package/src/exports/constants.d.ts +1 -0
- package/src/exports/constants.js +1 -0
- package/src/exports/migrate.d.ts +1 -0
- package/src/exports/migrate.js +1 -0
- package/src/exports/profiles.d.ts +3 -0
- package/src/exports/profiles.js +2 -0
- package/src/exports/projects.d.ts +3 -0
- package/src/exports/projects.js +2 -0
- package/src/exports/schema.d.ts +2 -0
- package/src/exports/schema.js +1 -0
- package/src/exports/themes.d.ts +2 -0
- package/src/exports/themes.js +1 -0
- package/src/exports/transform.d.ts +2 -0
- package/src/exports/transform.js +1 -0
- package/src/exports/translate.d.ts +3 -0
- package/src/exports/translate.js +2 -0
- package/src/exports/uid.d.ts +1 -0
- package/src/exports/uid.js +1 -0
- package/src/lang/copy.d.ts +1 -1
- package/src/lang/copy.js +21 -31
- package/src/lib/constants.d.ts +38 -38
- package/src/lib/constants.js +120 -153
- package/src/lib/errors.d.ts +2 -2
- package/src/lib/errors.js +19 -29
- package/src/lib/files.d.ts +1 -1
- package/src/lib/files.js +36 -47
- package/src/lib/localDev.d.ts +1 -1
- package/src/lib/localDev.js +8 -16
- package/src/lib/migrate.js +34 -40
- package/src/lib/migrateThemes.d.ts +3 -4
- package/src/lib/migrateThemes.js +31 -38
- package/src/lib/profiles.d.ts +1 -1
- package/src/lib/profiles.js +12 -20
- package/src/lib/project.js +11 -17
- package/src/lib/schemas.d.ts +2 -2
- package/src/lib/schemas.js +8 -11
- package/src/lib/transform.d.ts +1 -1
- package/src/lib/transform.js +50 -64
- package/src/lib/translate.d.ts +3 -0
- package/src/lib/translate.js +52 -0
- package/src/lib/types.d.ts +1 -1
- package/src/lib/types.js +1 -2
- package/src/lib/uid.js +9 -14
- package/src/lib/utils.d.ts +1 -1
- package/src/lib/utils.js +7 -14
- package/src/lib/validation.d.ts +3 -3
- package/src/lib/validation.js +46 -46
- package/src/index.d.ts +0 -19
- 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.
|
|
3
|
+
"version": "0.11.0-beta.0",
|
|
4
4
|
"description": "Parsing library for converting projects directory structures to their intermediate representation",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"
|
|
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.
|
|
46
|
+
"@hubspot/npm-scripts": "0.0.6",
|
|
9
47
|
"@inquirer/prompts": "^7.1.0",
|
|
10
|
-
"@types/
|
|
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": "^
|
|
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": "^
|
|
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.
|
|
63
|
+
"@hubspot/local-dev-lib": "4.0.3",
|
|
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": "
|
|
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 @@
|
|
|
1
|
+
export { getIntermediateRepresentationSchema } from '../lib/schemas.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { migrateThemes, getProjectThemeDetails } from '../lib/migrateThemes.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 @@
|
|
|
1
|
+
export { validateUid, coerceToValidUid } from '../lib/uid.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { validateUid, coerceToValidUid } from '../lib/uid.js';
|
package/src/lang/copy.d.ts
CHANGED
package/src/lang/copy.js
CHANGED
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 '${
|
|
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. ${
|
|
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: ${
|
|
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
|
|
42
|
+
export function getInvalidJsonError() {
|
|
43
|
+
return errorMessages.validation.invalidJson;
|
|
54
44
|
}
|
|
55
|
-
function getMissingTypeError() {
|
|
56
|
-
return
|
|
45
|
+
export function getMissingTypeError() {
|
|
46
|
+
return errorMessages.validation.missingType;
|
|
57
47
|
}
|
|
58
|
-
function getMissingConfigError() {
|
|
59
|
-
return
|
|
48
|
+
export function getMissingConfigError() {
|
|
49
|
+
return errorMessages.validation.missingConfig;
|
|
60
50
|
}
|
|
61
|
-
function getMissingAccountIdError() {
|
|
62
|
-
return
|
|
51
|
+
export function getMissingAccountIdError() {
|
|
52
|
+
return errorMessages.api.accountIdIsRequiredToFetchSchemas;
|
|
63
53
|
}
|
|
64
|
-
function getMissingRequiredFieldError(field) {
|
|
65
|
-
return
|
|
54
|
+
export function getMissingRequiredFieldError(field) {
|
|
55
|
+
return errorMessages.validation.missingRequiredField(field);
|
|
66
56
|
}
|
|
67
|
-
function getFailedToFetchSchemasError() {
|
|
68
|
-
return
|
|
57
|
+
export function getFailedToFetchSchemasError() {
|
|
58
|
+
return errorMessages.api.failedToFetchSchemas;
|
|
69
59
|
}
|
|
70
|
-
function getUnsupportedTypeError(type) {
|
|
71
|
-
return
|
|
60
|
+
export function getUnsupportedTypeError(type) {
|
|
61
|
+
return errorMessages.validation.unsupportedType(type);
|
|
72
62
|
}
|
|
73
|
-
|
|
63
|
+
export const logMessages = {
|
|
74
64
|
files: {
|
|
75
65
|
skippingPath: (path) => `Skipping ${path} as it is not in a valid directory`,
|
|
76
66
|
},
|
package/src/lib/constants.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Components as ComponentsTopLevel } from './types';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
17
|
-
export declare const
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const
|
|
23
|
-
export declare const
|
|
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
|
|
35
|
-
export declare const
|
|
36
|
-
export declare const
|
|
37
|
-
export declare const
|
|
38
|
-
export declare const
|
|
39
|
-
export declare const
|
|
40
|
-
export declare const
|
|
41
|
-
export declare const
|
|
42
|
-
export declare const
|
|
43
|
-
export declare const
|
|
44
|
-
export declare const
|
|
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
|
|
50
|
-
export declare const
|
|
51
|
-
export declare const
|
|
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
|
|
57
|
+
export declare const ALLOWED_TOP_LEVEL_FIELDS: Set<keyof ComponentsTopLevel>;
|