@hubspot/local-dev-lib 0.0.3 → 0.0.4

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 (141) hide show
  1. package/config/CLIConfiguration.d.ts +6 -6
  2. package/config/CLIConfiguration.js +11 -11
  3. package/config/configFile.js +1 -2
  4. package/constants/extensions.d.ts +1 -0
  5. package/constants/extensions.js +2 -1
  6. package/errors/fileSystemErrors.d.ts +7 -1
  7. package/errors/fileSystemErrors.js +1 -2
  8. package/errors/standardErrors.d.ts +14 -4
  9. package/errors/standardErrors.js +38 -34
  10. package/{src/http → http}/requestOptions.js +1 -1
  11. package/lib/archive.js +2 -4
  12. package/lib/path.d.ts +0 -3
  13. package/lib/path.js +2 -19
  14. package/package.json +8 -8
  15. package/types/Config.d.ts +1 -1
  16. package/types/Error.d.ts +6 -13
  17. package/utils/git.d.ts +2 -1
  18. package/utils/git.js +4 -68
  19. package/utils/lang.d.ts +5 -0
  20. package/utils/lang.js +30 -5
  21. package/errors/cmsFieldsJsErrors.d.ts +0 -9
  22. package/errors/cmsFieldsJsErrors.js +0 -31
  23. package/index.d.ts +0 -2
  24. package/index.js +0 -5
  25. package/src/config/CLIConfiguration.d.ts +0 -55
  26. package/src/config/CLIConfiguration.js +0 -392
  27. package/src/config/configFile.d.ts +0 -21
  28. package/src/config/configFile.js +0 -109
  29. package/src/config/configUtils.d.ts +0 -24
  30. package/src/config/configUtils.js +0 -85
  31. package/src/config/environment.d.ts +0 -3
  32. package/src/config/environment.js +0 -64
  33. package/src/constants/auth.d.ts +0 -24
  34. package/src/constants/auth.js +0 -31
  35. package/src/constants/config.d.ts +0 -8
  36. package/src/constants/config.js +0 -12
  37. package/src/constants/environments.d.ts +0 -13
  38. package/src/constants/environments.js +0 -16
  39. package/src/constants/extensions.d.ts +0 -2
  40. package/src/constants/extensions.js +0 -23
  41. package/src/constants/index.d.ts +0 -16
  42. package/src/constants/index.js +0 -12
  43. package/src/errors/HubSpotAuthError.d.ts +0 -3
  44. package/src/errors/HubSpotAuthError.js +0 -6
  45. package/src/errors/cmsFieldsJsErrors.d.ts +0 -9
  46. package/src/errors/cmsFieldsJsErrors.js +0 -31
  47. package/src/errors/fileSystemErrors.d.ts +0 -8
  48. package/src/errors/fileSystemErrors.js +0 -28
  49. package/src/errors/standardErrors.d.ts +0 -19
  50. package/src/errors/standardErrors.js +0 -67
  51. package/src/index.d.ts +0 -2
  52. package/src/index.js +0 -5
  53. package/src/lib/archive.d.ts +0 -7
  54. package/src/lib/archive.js +0 -111
  55. package/src/lib/modules.d.ts +0 -28
  56. package/src/lib/modules.js +0 -174
  57. package/src/lib/path.d.ts +0 -10
  58. package/src/lib/path.js +0 -84
  59. package/src/types/Accounts.d.ts +0 -50
  60. package/src/types/Accounts.js +0 -2
  61. package/src/types/CLIOptions.d.ts +0 -3
  62. package/src/types/CLIOptions.js +0 -2
  63. package/src/types/Config.d.ts +0 -10
  64. package/src/types/Config.js +0 -2
  65. package/src/types/Error.d.ts +0 -31
  66. package/src/types/Error.js +0 -2
  67. package/src/types/LogCallbacks.d.ts +0 -6
  68. package/src/types/LogCallbacks.js +0 -2
  69. package/src/types/Utils.d.ts +0 -1
  70. package/src/types/Utils.js +0 -2
  71. package/src/utils/encoding.d.ts +0 -1
  72. package/src/utils/encoding.js +0 -11
  73. package/src/utils/environment.d.ts +0 -1
  74. package/src/utils/environment.js +0 -16
  75. package/src/utils/escapeRegExp.d.ts +0 -1
  76. package/src/utils/escapeRegExp.js +0 -7
  77. package/src/utils/files.d.ts +0 -3
  78. package/src/utils/files.js +0 -35
  79. package/src/utils/fs/read.d.ts +0 -4
  80. package/src/utils/fs/read.js +0 -55
  81. package/src/utils/fs/walk.d.ts +0 -2
  82. package/src/utils/fs/walk.js +0 -44
  83. package/src/utils/git.d.ts +0 -4
  84. package/src/utils/git.js +0 -40
  85. package/src/utils/handleFieldsJS.d.ts +0 -35
  86. package/src/utils/handleFieldsJS.js +0 -158
  87. package/src/utils/interpolation.d.ts +0 -5
  88. package/src/utils/interpolation.js +0 -31
  89. package/src/utils/lang.d.ts +0 -8
  90. package/src/utils/lang.js +0 -83
  91. package/src/utils/logger.d.ts +0 -10
  92. package/src/utils/logger.js +0 -22
  93. package/src/utils/text.d.ts +0 -1
  94. package/src/utils/text.js +0 -16
  95. package/src/utils/urls.d.ts +0 -2
  96. package/src/utils/urls.js +0 -20
  97. package/utils/encoding.d.ts +0 -1
  98. package/utils/encoding.js +0 -11
  99. package/utils/environment.d.ts +0 -1
  100. package/utils/environment.js +0 -16
  101. package/utils/interpolation.d.ts +0 -5
  102. package/utils/interpolation.js +0 -31
  103. package/utils/text.d.ts +0 -1
  104. package/utils/text.js +0 -16
  105. /package/{src/constants → constants}/files.d.ts +0 -0
  106. /package/{src/constants → constants}/files.js +0 -0
  107. /package/{src/constants → constants}/github.d.ts +0 -0
  108. /package/{src/constants → constants}/github.js +0 -0
  109. /package/{src/http → http}/requestOptions.d.ts +0 -0
  110. /package/{src/lib → lib}/cms/handleFieldsJS.d.ts +0 -0
  111. /package/{src/lib → lib}/cms/handleFieldsJS.js +0 -0
  112. /package/{src/lib → lib}/cms/index.d.ts +0 -0
  113. /package/{src/lib → lib}/cms/index.js +0 -0
  114. /package/{src/lib → lib}/cms/modules.d.ts +0 -0
  115. /package/{src/lib → lib}/cms/modules.js +0 -0
  116. /package/{src/lib → lib}/cms/themes.d.ts +0 -0
  117. /package/{src/lib → lib}/cms/themes.js +0 -0
  118. /package/{src/lib → lib}/environment.d.ts +0 -0
  119. /package/{src/lib → lib}/environment.js +0 -0
  120. /package/{src/lib → lib}/fs.d.ts +0 -0
  121. /package/{src/lib → lib}/fs.js +0 -0
  122. /package/{src/lib → lib}/github.d.ts +0 -0
  123. /package/{src/lib → lib}/github.js +0 -0
  124. /package/{src/lib → lib}/gitignore.d.ts +0 -0
  125. /package/{src/lib → lib}/gitignore.js +0 -0
  126. /package/{src/lib → lib}/index.d.ts +0 -0
  127. /package/{src/lib → lib}/index.js +0 -0
  128. /package/{src/lib → lib}/text.d.ts +0 -0
  129. /package/{src/lib → lib}/text.js +0 -0
  130. /package/{src/lib → lib}/urls.d.ts +0 -0
  131. /package/{src/lib → lib}/urls.js +0 -0
  132. /package/{src/types → types}/Files.d.ts +0 -0
  133. /package/{src/types → types}/Files.js +0 -0
  134. /package/{src/types → types}/Github.d.ts +0 -0
  135. /package/{src/types → types}/Github.js +0 -0
  136. /package/{src/types → types}/Modules.d.ts +0 -0
  137. /package/{src/types → types}/Modules.js +0 -0
  138. /package/{src/utils → utils}/fieldsJS.d.ts +0 -0
  139. /package/{src/utils → utils}/fieldsJS.js +0 -0
  140. /package/{src/utils → utils}/modules.d.ts +0 -0
  141. /package/{src/utils → utils}/modules.js +0 -0
@@ -1,35 +0,0 @@
1
- export declare class FieldsJs {
2
- projectDir: string;
3
- filePath: string;
4
- rootWriteDir: string;
5
- rejected: boolean;
6
- fieldOptions: string;
7
- outputPath?: string;
8
- constructor(projectDir: string, filePath: string, rootWriteDir?: string, fieldOptions?: string);
9
- init(): Promise<this>;
10
- convertFieldsJs(writeDir: string): Promise<string | void>;
11
- /**
12
- * If there has been a fields.json written to the output path, then copy it from the output
13
- * directory to the project directory, respecting the path within the output directory.
14
- * Ex: path/to/tmp/example.module/fields.json => path/to/project/example.module/fields.output.json
15
- */
16
- saveOutput(): void;
17
- /**
18
- * Resolves the relative path to the fields.js within the project directory and returns
19
- * directory name to write to in rootWriteDir directory.
20
- *
21
- * Ex: If rootWriteDir = 'path/to/temp', filePath = 'projectRoot/sample.module/fields.js'. Then getWriteDir() => path/to/temp/sample.module
22
- */
23
- getWriteDir(): string;
24
- getOutputPathPromise(): Promise<string | void>;
25
- }
26
- type FieldsArray<T> = Array<T | FieldsArray<T>>;
27
- export declare function fieldsArrayToJson<T>(fields: FieldsArray<T>): string;
28
- /**
29
- * Determines if file is a convertable fields.js file i.e., if it is called
30
- * 'fields.js' and in a root or in a module folder, and if convertFields flag is true.
31
- */
32
- export declare function isConvertableFieldJs(rootDir: string, filePath: string, convertFields?: boolean): boolean;
33
- export declare function createTmpDirSync(prefix: string): string;
34
- export declare function cleanupTmpDirSync(tmpDir: string): void;
35
- export {};
@@ -1,158 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cleanupTmpDirSync = exports.createTmpDirSync = exports.isConvertableFieldJs = exports.fieldsArrayToJson = exports.FieldsJs = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const os_1 = __importDefault(require("os"));
9
- const path_1 = __importDefault(require("path"));
10
- const child_process_1 = require("child_process");
11
- const escapeRegExp_1 = require("./escapeRegExp");
12
- const modules_1 = require("../lib/modules");
13
- const logger_1 = require("./logger");
14
- const standardErrors_1 = require("../errors/standardErrors");
15
- const i18nKey = 'utils.handleFieldsJs';
16
- class FieldsJs {
17
- projectDir;
18
- filePath;
19
- rootWriteDir;
20
- rejected;
21
- fieldOptions;
22
- outputPath;
23
- constructor(projectDir, filePath, rootWriteDir, fieldOptions = '') {
24
- this.projectDir = projectDir;
25
- this.filePath = filePath;
26
- this.fieldOptions = fieldOptions;
27
- this.rejected = false;
28
- // Create tmpDir if no writeDir is given.
29
- this.rootWriteDir =
30
- rootWriteDir === undefined
31
- ? createTmpDirSync('hubspot-temp-fieldsjs-output-')
32
- : rootWriteDir;
33
- }
34
- async init() {
35
- const outputPath = await this.getOutputPathPromise();
36
- this.outputPath = this.rejected ? undefined : outputPath;
37
- return this;
38
- }
39
- // Converts a fields.js file into a fields.json file, writes, and returns of fields.json
40
- convertFieldsJs(writeDir) {
41
- const filePath = this.filePath;
42
- const dirName = path_1.default.dirname(filePath);
43
- return new Promise((resolve, reject) => {
44
- const convertFieldsProcess = (0, child_process_1.fork)(path_1.default.join(__dirname, './processFieldsJs.js'), [], {
45
- cwd: dirName,
46
- env: {
47
- dirName,
48
- fieldOptions: this.fieldOptions,
49
- filePath,
50
- writeDir,
51
- },
52
- });
53
- (0, logger_1.debug)(`${i18nKey}.convertFieldsJs.creating`, {
54
- pid: convertFieldsProcess.pid || '',
55
- });
56
- convertFieldsProcess.on('message', function (message) {
57
- if (message.action === 'ERROR') {
58
- reject(message.message);
59
- }
60
- else if (message.action === 'COMPLETE') {
61
- resolve(message.finalPath);
62
- }
63
- });
64
- convertFieldsProcess.on('close', () => {
65
- (0, logger_1.debug)(`${i18nKey}.convertFieldsJs.terminating`, {
66
- pid: convertFieldsProcess.pid || '',
67
- });
68
- });
69
- }).catch((e) => {
70
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.convertFieldsJs`, { filePath }, e);
71
- });
72
- }
73
- /**
74
- * If there has been a fields.json written to the output path, then copy it from the output
75
- * directory to the project directory, respecting the path within the output directory.
76
- * Ex: path/to/tmp/example.module/fields.json => path/to/project/example.module/fields.output.json
77
- */
78
- saveOutput() {
79
- if (!this.outputPath || !fs_extra_1.default.existsSync(this.outputPath)) {
80
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.saveOutput`, { path: this.filePath });
81
- }
82
- const relativePath = path_1.default.relative(this.rootWriteDir, path_1.default.dirname(this.outputPath));
83
- const savePath = path_1.default.join(this.projectDir, relativePath, 'fields.output.json');
84
- try {
85
- fs_extra_1.default.copyFileSync(this.outputPath, savePath);
86
- }
87
- catch (err) {
88
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.saveOutput`, { path: savePath }, err);
89
- }
90
- }
91
- /**
92
- * Resolves the relative path to the fields.js within the project directory and returns
93
- * directory name to write to in rootWriteDir directory.
94
- *
95
- * Ex: If rootWriteDir = 'path/to/temp', filePath = 'projectRoot/sample.module/fields.js'. Then getWriteDir() => path/to/temp/sample.module
96
- */
97
- getWriteDir() {
98
- const projectDirRegex = new RegExp(`^${(0, escapeRegExp_1.escapeRegExp)(this.projectDir)}`);
99
- const relativePath = this.filePath.replace(projectDirRegex, '');
100
- return path_1.default.dirname(path_1.default.join(this.rootWriteDir, relativePath));
101
- }
102
- getOutputPathPromise() {
103
- const writeDir = this.getWriteDir();
104
- return this.convertFieldsJs(writeDir).then(outputPath => outputPath);
105
- }
106
- }
107
- exports.FieldsJs = FieldsJs;
108
- /*
109
- * Polyfill for `Array.flat(Infinity)` since the `flat` is only available for Node v11+
110
- * https://stackoverflow.com/a/15030117
111
- */
112
- function flattenArray(arr) {
113
- return arr.reduce((flat, toFlatten) => {
114
- return flat.concat(Array.isArray(toFlatten) ? flattenArray(toFlatten) : toFlatten);
115
- }, []);
116
- }
117
- //Transform fields array to JSON
118
- function fieldsArrayToJson(fields) {
119
- const flattened = flattenArray(fields);
120
- return JSON.stringify(flattened, null, 2);
121
- }
122
- exports.fieldsArrayToJson = fieldsArrayToJson;
123
- /**
124
- * Determines if file is a convertable fields.js file i.e., if it is called
125
- * 'fields.js' and in a root or in a module folder, and if convertFields flag is true.
126
- */
127
- function isConvertableFieldJs(rootDir, filePath, convertFields = false) {
128
- const allowedFieldsNames = ['fields.js', 'fields.mjs', 'fields.cjs'];
129
- const regex = new RegExp(`^${(0, escapeRegExp_1.escapeRegExp)(rootDir)}`);
130
- const relativePath = path_1.default.dirname(filePath.replace(regex, ''));
131
- const baseName = path_1.default.basename(filePath);
132
- const inModuleFolder = (0, modules_1.isModuleFolderChild)({ path: filePath, isLocal: true });
133
- return !!(convertFields &&
134
- allowedFieldsNames.includes(baseName) &&
135
- (inModuleFolder || relativePath == '/'));
136
- }
137
- exports.isConvertableFieldJs = isConvertableFieldJs;
138
- // Try creating tempdir
139
- function createTmpDirSync(prefix) {
140
- let tmpDir;
141
- try {
142
- tmpDir = fs_extra_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), prefix));
143
- }
144
- catch (err) {
145
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.createTmpDirSync`, {}, err);
146
- }
147
- return tmpDir;
148
- }
149
- exports.createTmpDirSync = createTmpDirSync;
150
- // Try cleaning up resources from os's tempdir
151
- function cleanupTmpDirSync(tmpDir) {
152
- fs_extra_1.default.rm(tmpDir, { recursive: true }, err => {
153
- if (err) {
154
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.cleanupTmpDirSync`, {}, err);
155
- }
156
- });
157
- }
158
- exports.cleanupTmpDirSync = cleanupTmpDirSync;
@@ -1,5 +0,0 @@
1
- type InterpolationData = {
2
- [identifier: string]: string | number;
3
- };
4
- export declare function interpolate(stringValue: string, interpolationData: InterpolationData): string;
5
- export {};
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.interpolate = void 0;
4
- const delimiters = {
5
- interpolation: {
6
- start: '{{',
7
- end: '}}',
8
- },
9
- };
10
- function generateReplaceFn(matchedText, startIndex, replacementString) {
11
- return function (currentStringValue) {
12
- return `${currentStringValue.slice(0, startIndex)}${replacementString || ''}${currentStringValue.slice(startIndex + matchedText.length)}`;
13
- };
14
- }
15
- function interpolate(stringValue, interpolationData) {
16
- const interpolationIdentifierRegEx = new RegExp(`${delimiters.interpolation.start}(.*?)${delimiters.interpolation.end}`, 'g');
17
- const replaceQueue = [];
18
- let match;
19
- // while & reduce necessary because RegExp.exec is stateful and only runs
20
- // from beginning to end of string
21
- while ((match = interpolationIdentifierRegEx.exec(stringValue)) != null) {
22
- const { 0: matchedText, 1: rawIdentifier, index } = match;
23
- const identifier = rawIdentifier.trim();
24
- if (identifier) {
25
- replaceQueue.unshift(generateReplaceFn(matchedText, index, interpolationData[identifier]));
26
- }
27
- }
28
- const compiledString = replaceQueue.reduce((currentValue, replaceFn) => replaceFn(currentValue), stringValue);
29
- return compiledString;
30
- }
31
- exports.interpolate = interpolate;
@@ -1,8 +0,0 @@
1
- type InterpolationData = {
2
- [identifier: string]: string | number;
3
- };
4
- export declare function interpolate(stringValue: string, interpolationData: InterpolationData): string;
5
- export declare function i18n(lookupDotNotation: string, options?: {
6
- [identifier: string]: string | number;
7
- }): string;
8
- export {};
package/src/utils/lang.js DELETED
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.i18n = exports.interpolate = void 0;
4
- const path_1 = require("path");
5
- const fs_extra_1 = require("fs-extra");
6
- const js_yaml_1 = require("js-yaml");
7
- const MISSING_LANGUAGE_DATA_PREFIX = '[Missing language data]';
8
- let locale = '';
9
- let languageObj;
10
- function loadLanguageFromYaml() {
11
- if (languageObj)
12
- return;
13
- try {
14
- const nodeLocale = Intl.DateTimeFormat()
15
- .resolvedOptions()
16
- .locale.split('-')[0];
17
- const languageFilePath = (0, path_1.join)(__dirname, `../lang/${nodeLocale}.lyaml`);
18
- const languageFileExists = (0, fs_extra_1.existsSync)(languageFilePath);
19
- // Fall back to using the default language file
20
- locale = languageFileExists ? nodeLocale : 'en';
21
- languageObj = (0, js_yaml_1.load)((0, fs_extra_1.readFileSync)((0, path_1.join)(__dirname, `../lang/${locale}.lyaml`), 'utf8'));
22
- }
23
- catch (e) {
24
- throw new Error(`Error loading language data: ${e}`);
25
- }
26
- }
27
- function getTextValue(lookupDotNotation) {
28
- const lookupProps = [locale, ...lookupDotNotation.split('.')];
29
- const missingTextData = `${MISSING_LANGUAGE_DATA_PREFIX}: ${lookupProps.join('.')}`;
30
- let textValue = languageObj;
31
- let previouslyCheckedProp = lookupProps[0];
32
- lookupProps.forEach(prop => {
33
- previouslyCheckedProp = prop;
34
- if (typeof textValue === 'object') {
35
- textValue = textValue[prop];
36
- }
37
- else {
38
- console.debug(`Unable to access language property: ${lookupProps.join('.')}. Failed to access prop "${previouslyCheckedProp}".`);
39
- }
40
- });
41
- if (typeof textValue !== 'string') {
42
- return missingTextData;
43
- }
44
- return textValue;
45
- }
46
- const delimiters = {
47
- interpolation: {
48
- start: '{{',
49
- end: '}}',
50
- },
51
- };
52
- function generateReplaceFn(matchedText, startIndex, replacementString) {
53
- return function (currentStringValue) {
54
- return `${currentStringValue.slice(0, startIndex)}${replacementString || ''}${currentStringValue.slice(startIndex + matchedText.length)}`;
55
- };
56
- }
57
- function interpolate(stringValue, interpolationData) {
58
- const interpolationIdentifierRegEx = new RegExp(`${delimiters.interpolation.start}(.*?)${delimiters.interpolation.end}`, 'g');
59
- const replaceQueue = [];
60
- let match;
61
- // while & reduce necessary because RegExp.exec is stateful and only runs
62
- // from beginning to end of string
63
- while ((match = interpolationIdentifierRegEx.exec(stringValue)) != null) {
64
- const { 0: matchedText, 1: rawIdentifier, index } = match;
65
- const identifier = rawIdentifier.trim();
66
- if (identifier) {
67
- replaceQueue.unshift(generateReplaceFn(matchedText, index, interpolationData[identifier]));
68
- }
69
- }
70
- const compiledString = replaceQueue.reduce((currentValue, replaceFn) => replaceFn(currentValue), stringValue);
71
- return compiledString;
72
- }
73
- exports.interpolate = interpolate;
74
- function i18n(lookupDotNotation, options = {}) {
75
- if (typeof lookupDotNotation !== 'string') {
76
- throw new Error(`i18n must be passed a string value for lookupDotNotation, received ${typeof lookupDotNotation}`);
77
- }
78
- const textValue = getTextValue(lookupDotNotation);
79
- const shouldInterpolate = !textValue.startsWith(MISSING_LANGUAGE_DATA_PREFIX);
80
- return shouldInterpolate ? interpolate(textValue, options) : textValue;
81
- }
82
- exports.i18n = i18n;
83
- loadLanguageFromYaml();
@@ -1,10 +0,0 @@
1
- import { LogCallbacks } from '../types/LogCallbacks';
2
- export declare function log<T extends string>(key: T, callbacks?: LogCallbacks<T>, debugKey?: string, debugInterpolation?: {
3
- [key: string]: string | number;
4
- }): void;
5
- export declare function makeTypedLogger<T extends readonly string[]>(callbacks?: LogCallbacks<T[number]>, debugKey?: string): (key: T[number], debugInterpolation?: {
6
- [key: string]: string | number;
7
- } | undefined) => void;
8
- export declare function debug(identifier: string, interpolation?: {
9
- [key: string]: string | number;
10
- }): void;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.debug = exports.makeTypedLogger = exports.log = void 0;
4
- const lang_1 = require("./lang");
5
- function log(key, callbacks, debugKey, debugInterpolation) {
6
- if (callbacks && callbacks[key]) {
7
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8
- callbacks[key]();
9
- }
10
- else if (debugKey) {
11
- debug(debugKey, debugInterpolation);
12
- }
13
- }
14
- exports.log = log;
15
- function makeTypedLogger(callbacks, debugKey) {
16
- return (key, debugInterpolation) => log(key, callbacks, `${debugKey}.${key}`, debugInterpolation);
17
- }
18
- exports.makeTypedLogger = makeTypedLogger;
19
- function debug(identifier, interpolation) {
20
- console.debug((0, lang_1.i18n)(`debug.${identifier}`, interpolation));
21
- }
22
- exports.debug = debug;
@@ -1 +0,0 @@
1
- export declare function commaSeparatedValues(arr: Array<string>, conjunction?: string, ifempty?: string): string;
package/src/utils/text.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.commaSeparatedValues = void 0;
4
- function commaSeparatedValues(arr, conjunction = 'and', ifempty = '') {
5
- const l = arr.length;
6
- if (!l)
7
- return ifempty;
8
- if (l < 2)
9
- return arr[0];
10
- if (l < 3)
11
- return arr.join(` ${conjunction} `);
12
- arr = arr.slice();
13
- arr[l - 1] = `${conjunction} ${arr[l - 1]}`;
14
- return arr.join(', ');
15
- }
16
- exports.commaSeparatedValues = commaSeparatedValues;
@@ -1,2 +0,0 @@
1
- export declare const getHubSpotWebsiteOrigin: (env: string) => string;
2
- export declare function getHubSpotApiOrigin(env?: string, useLocalHost?: boolean): string;
package/src/utils/urls.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getHubSpotApiOrigin = exports.getHubSpotWebsiteOrigin = void 0;
4
- const environments_1 = require("../constants/environments");
5
- function getEnvUrlString(env) {
6
- if (typeof env !== 'string') {
7
- return '';
8
- }
9
- return env.toLowerCase() === environments_1.ENVIRONMENTS.QA ? environments_1.ENVIRONMENTS.QA : '';
10
- }
11
- const getHubSpotWebsiteOrigin = (env) => `https://app.hubspot${getEnvUrlString(env)}.com`;
12
- exports.getHubSpotWebsiteOrigin = getHubSpotWebsiteOrigin;
13
- function getHubSpotApiOrigin(env, useLocalHost) {
14
- let domain = process.env.HUBAPI_DOMAIN_OVERRIDE;
15
- if (!domain || typeof domain !== 'string') {
16
- domain = `${useLocalHost ? 'local' : 'api'}.hubapi${getEnvUrlString(env)}`;
17
- }
18
- return `https://${domain}.com`;
19
- }
20
- exports.getHubSpotApiOrigin = getHubSpotApiOrigin;
@@ -1 +0,0 @@
1
- export declare function base64EncodeString(valueToEncode: string): string;
package/utils/encoding.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.base64EncodeString = void 0;
4
- function base64EncodeString(valueToEncode) {
5
- if (typeof valueToEncode !== 'string') {
6
- return valueToEncode;
7
- }
8
- const stringBuffer = Buffer.from(valueToEncode);
9
- return encodeURIComponent(stringBuffer.toString('base64'));
10
- }
11
- exports.base64EncodeString = base64EncodeString;
@@ -1 +0,0 @@
1
- export declare function getValidEnv(env: string, maskedProductionValue?: string): string;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getValidEnv = void 0;
4
- const environments_1 = require("../constants/environments");
5
- function getValidEnv(env, maskedProductionValue) {
6
- const prodValue = maskedProductionValue
7
- ? maskedProductionValue
8
- : environments_1.ENVIRONMENTS.PROD;
9
- const returnVal = typeof env &&
10
- typeof env === 'string' &&
11
- env.toLowerCase() === environments_1.ENVIRONMENTS.QA
12
- ? environments_1.ENVIRONMENTS.QA
13
- : prodValue;
14
- return returnVal;
15
- }
16
- exports.getValidEnv = getValidEnv;
@@ -1,5 +0,0 @@
1
- type InterpolationData = {
2
- [identifier: string]: string | number;
3
- };
4
- export declare function interpolate(stringValue: string, interpolationData: InterpolationData): string;
5
- export {};
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.interpolate = void 0;
4
- const delimiters = {
5
- interpolation: {
6
- start: '{{',
7
- end: '}}',
8
- },
9
- };
10
- function generateReplaceFn(matchedText, startIndex, replacementString) {
11
- return function (currentStringValue) {
12
- return `${currentStringValue.slice(0, startIndex)}${replacementString || ''}${currentStringValue.slice(startIndex + matchedText.length)}`;
13
- };
14
- }
15
- function interpolate(stringValue, interpolationData) {
16
- const interpolationIdentifierRegEx = new RegExp(`${delimiters.interpolation.start}(.*?)${delimiters.interpolation.end}`, 'g');
17
- const replaceQueue = [];
18
- let match;
19
- // while & reduce necessary because RegExp.exec is stateful and only runs
20
- // from beginning to end of string
21
- while ((match = interpolationIdentifierRegEx.exec(stringValue)) != null) {
22
- const { 0: matchedText, 1: rawIdentifier, index } = match;
23
- const identifier = rawIdentifier.trim();
24
- if (identifier) {
25
- replaceQueue.unshift(generateReplaceFn(matchedText, index, interpolationData[identifier]));
26
- }
27
- }
28
- const compiledString = replaceQueue.reduce((currentValue, replaceFn) => replaceFn(currentValue), stringValue);
29
- return compiledString;
30
- }
31
- exports.interpolate = interpolate;
package/utils/text.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function commaSeparatedValues(arr: Array<string>, conjunction?: string, ifempty?: string): string;
package/utils/text.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.commaSeparatedValues = void 0;
4
- function commaSeparatedValues(arr, conjunction = 'and', ifempty = '') {
5
- const l = arr.length;
6
- if (!l)
7
- return ifempty;
8
- if (l < 2)
9
- return arr[0];
10
- if (l < 3)
11
- return arr.join(` ${conjunction} `);
12
- arr = arr.slice();
13
- arr[l - 1] = `${conjunction} ${arr[l - 1]}`;
14
- return arr.join(', ');
15
- }
16
- exports.commaSeparatedValues = commaSeparatedValues;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes