@hubspot/project-parsing-lib 0.0.7-experimental.0 → 0.0.8-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 +1 -1
- package/src/index.d.ts +1 -3
- package/src/index.js +0 -24
- package/src/lib/constants.js +2 -2
- package/src/lib/transform.d.ts +0 -1
- package/src/lib/transform.js +6 -3
- package/src/lib/types.d.ts +1 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/project-parsing-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8-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",
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { IntermediateRepresentation,
|
|
1
|
+
import { IntermediateRepresentation, TranslationContext, TranslationOptions } from './lib/types';
|
|
2
2
|
export declare function translate(translationContext: TranslationContext, translationOptions?: TranslationOptions): Promise<IntermediateRepresentation>;
|
|
3
|
-
export declare function translateForLocalDev(translationContext: TranslationContext): Promise<IntermediateRepresentationLocalDev>;
|
|
4
3
|
export { isTranslationError } from './lib/errors';
|
|
5
|
-
export { IntermediateRepresentation, IntermediateRepresentationNode, IntermediateRepresentationLocalDev, IntermediateRepresentationNodeLocalDev, TranslationContext, };
|
package/src/index.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.isTranslationError = void 0;
|
|
7
4
|
exports.translate = translate;
|
|
8
|
-
exports.translateForLocalDev = translateForLocalDev;
|
|
9
5
|
const files_1 = require("./lib/files");
|
|
10
6
|
const validation_1 = require("./lib/validation");
|
|
11
7
|
const transform_1 = require("./lib/transform");
|
|
12
8
|
const copy_1 = require("./lang/copy");
|
|
13
|
-
const path_1 = __importDefault(require("path"));
|
|
14
9
|
const defaultOptions = {
|
|
15
10
|
skipValidation: false,
|
|
16
11
|
};
|
|
@@ -22,29 +17,10 @@ async function translate(translationContext, translationOptions = defaultOptions
|
|
|
22
17
|
}
|
|
23
18
|
const transformation = (0, transform_1.transform)(metafileContents);
|
|
24
19
|
const intermediateRepresentation = (0, transform_1.getIntermediateRepresentation)(transformation);
|
|
25
|
-
// Remove once extensions and serverless functions are supported
|
|
26
20
|
if (!skipValidation) {
|
|
27
21
|
await (0, validation_1.validateIntermediateRepresentation)(intermediateRepresentation, transformation, translationContext);
|
|
28
22
|
}
|
|
29
23
|
return intermediateRepresentation;
|
|
30
24
|
}
|
|
31
|
-
async function translateForLocalDev(translationContext) {
|
|
32
|
-
const IR = await translate(translationContext, { skipValidation: true });
|
|
33
|
-
const localDevIr = {
|
|
34
|
-
intermediateNodesIndexedByUid: {},
|
|
35
|
-
};
|
|
36
|
-
Object.entries(IR.intermediateNodesIndexedByUid).forEach(([uid, node]) => {
|
|
37
|
-
const component = IR.intermediateNodesIndexedByUid[uid];
|
|
38
|
-
const componentConfigPath = path_1.default.join(translationContext.projectSourceDir, component.metaFilePath);
|
|
39
|
-
localDevIr.intermediateNodesIndexedByUid[uid] = {
|
|
40
|
-
...node,
|
|
41
|
-
localDev: {
|
|
42
|
-
componentRoot: path_1.default.dirname(componentConfigPath),
|
|
43
|
-
componentConfigPath,
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
return localDevIr;
|
|
48
|
-
}
|
|
49
25
|
var errors_1 = require("./lib/errors");
|
|
50
26
|
Object.defineProperty(exports, "isTranslationError", { enumerable: true, get: function () { return errors_1.isTranslationError; } });
|
package/src/lib/constants.js
CHANGED
|
@@ -69,15 +69,15 @@ exports.Components = {
|
|
|
69
69
|
},
|
|
70
70
|
[exports.AppObjectKey]: {
|
|
71
71
|
dir: 'app-objects',
|
|
72
|
-
userFriendlyName: 'App Object',
|
|
73
72
|
parentComponent: exports.AppKey,
|
|
74
73
|
...SubComponentFields,
|
|
74
|
+
userFriendlyName: 'App Object',
|
|
75
75
|
},
|
|
76
76
|
[exports.AppObjectAssociationKey]: {
|
|
77
77
|
dir: 'app-object-associations',
|
|
78
|
-
userFriendlyName: 'App Object Association',
|
|
79
78
|
parentComponent: exports.AppKey,
|
|
80
79
|
...SubComponentFields,
|
|
80
|
+
userFriendlyName: 'App Object Association',
|
|
81
81
|
},
|
|
82
82
|
[exports.ThemeKey]: {
|
|
83
83
|
dir: exports.ThemeKey,
|
package/src/lib/transform.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FileParseResult, IntermediateRepresentation, Transformation } from './types';
|
|
2
|
-
export declare function mapToInternalType(type: string): string;
|
|
3
2
|
export declare function mapToUserFacingType(type: string): string;
|
|
4
3
|
export declare function transform(fileParseResults: FileParseResult[]): Transformation[];
|
|
5
4
|
export declare function getIntermediateRepresentation(transformations: Transformation[]): IntermediateRepresentation;
|
package/src/lib/transform.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapToInternalType = mapToInternalType;
|
|
4
3
|
exports.mapToUserFacingType = mapToUserFacingType;
|
|
5
4
|
exports.transform = transform;
|
|
6
5
|
exports.getIntermediateRepresentation = getIntermediateRepresentation;
|
|
@@ -30,8 +29,9 @@ function mapToInternalType(type) {
|
|
|
30
29
|
return resolvedType.toUpperCase().replace(/-/g, '_');
|
|
31
30
|
}
|
|
32
31
|
function mapToUserFacingType(type) {
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
return (constants_1.internalTypeToUserFacing[type] || type || '')
|
|
33
|
+
.toLowerCase()
|
|
34
|
+
.replace(/_/g, '-');
|
|
35
35
|
}
|
|
36
36
|
function transform(fileParseResults) {
|
|
37
37
|
const parentTypes = Object.keys(constants_1.ProjectStructure);
|
|
@@ -67,6 +67,9 @@ function transform(fileParseResults) {
|
|
|
67
67
|
}
|
|
68
68
|
function getIntermediateRepresentation(transformations) {
|
|
69
69
|
const nodes = transformations.reduce((acc, current) => {
|
|
70
|
+
if (!current.intermediateRepresentation) {
|
|
71
|
+
return acc;
|
|
72
|
+
}
|
|
70
73
|
const { uid } = current.intermediateRepresentation;
|
|
71
74
|
if (acc[uid]) {
|
|
72
75
|
const duplicates = transformations
|
package/src/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ErrorObject } from 'ajv-draft-04';
|
|
2
1
|
export type Dependencies = Record<string, string | string[]>;
|
|
2
|
+
import { ErrorObject } from 'ajv-draft-04';
|
|
3
3
|
export interface Components {
|
|
4
4
|
uid: string;
|
|
5
5
|
type: string;
|
|
@@ -30,17 +30,6 @@ export interface IntermediateRepresentation {
|
|
|
30
30
|
[key: string]: IntermediateRepresentationNode;
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
export interface IntermediateRepresentationNodeLocalDev extends IntermediateRepresentationNode {
|
|
34
|
-
localDev: {
|
|
35
|
-
componentRoot: string;
|
|
36
|
-
componentConfigPath: string;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export interface IntermediateRepresentationLocalDev {
|
|
40
|
-
intermediateNodesIndexedByUid: {
|
|
41
|
-
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
33
|
export type Transformation = {
|
|
45
34
|
intermediateRepresentation?: IntermediateRepresentationNode | null;
|
|
46
35
|
fileParseResult: FileParseResult;
|