@rootreeweb/netsuite-bundles 0.0.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.
- package/CHANGELOG.md +7 -0
- package/configs/tsconfig.base.json +10 -0
- package/configs/tsconfig.build.json +9 -0
- package/dist/build.d.ts +16 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +57 -0
- package/dist/build.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/rollup.d.ts +24 -0
- package/dist/rollup.d.ts.map +1 -0
- package/dist/rollup.js +86 -0
- package/dist/rollup.js.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +25 -0
- package/dist/utils.js.map +1 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface BuildOptions {
|
|
2
|
+
projectDir: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Orchestrates the full build process for a NetSuite bundle:
|
|
6
|
+
*
|
|
7
|
+
* 1. Cleans the target build directory (dist).
|
|
8
|
+
* 2. Compiles scripts using Rollup.
|
|
9
|
+
* 3. Copies bundle metadata and static configurations to the build directory.
|
|
10
|
+
*
|
|
11
|
+
* @param {BuildOptions} options - Options containing the project's root
|
|
12
|
+
* directory.
|
|
13
|
+
*/
|
|
14
|
+
export declare function runBuild({ projectDir }: BuildOptions): void;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAIA,UAAU,YAAY;IACrB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,EAAE,UAAU,EAAE,EAAE,YAAY,GAAG,IAAI,CA6C3D"}
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, rmSync } from "fs";
|
|
3
|
+
import { resolve } from "path";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Orchestrates the full build process for a NetSuite bundle:
|
|
7
|
+
*
|
|
8
|
+
* 1. Cleans the target build directory (dist).
|
|
9
|
+
* 2. Compiles scripts using Rollup.
|
|
10
|
+
* 3. Copies bundle metadata and static configurations to the build directory.
|
|
11
|
+
*
|
|
12
|
+
* @param {BuildOptions} options - Options containing the project's root
|
|
13
|
+
* directory.
|
|
14
|
+
*/
|
|
15
|
+
export function runBuild({ projectDir }) {
|
|
16
|
+
console.log("Cleaning dist folder...");
|
|
17
|
+
const distPath = resolve(projectDir, "dist");
|
|
18
|
+
if (existsSync(distPath)) {
|
|
19
|
+
rmSync(distPath, { recursive: true, force: true });
|
|
20
|
+
}
|
|
21
|
+
console.log("Building TypeScript files with Rollup...");
|
|
22
|
+
try {
|
|
23
|
+
execSync("yarn rollup -c", { stdio: "inherit", cwd: projectDir });
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.error("Rollup compilation failed!");
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
console.log("Copying project configurations to dist...");
|
|
29
|
+
const targets = [
|
|
30
|
+
"manifest.xml",
|
|
31
|
+
"deploy.xml",
|
|
32
|
+
"Objects",
|
|
33
|
+
"AccountConfiguration",
|
|
34
|
+
"Translations",
|
|
35
|
+
"FileCabinet",
|
|
36
|
+
];
|
|
37
|
+
for (const target of targets) {
|
|
38
|
+
const srcPath = resolve(projectDir, target);
|
|
39
|
+
const destPath = resolve(distPath, target);
|
|
40
|
+
if (existsSync(srcPath)) {
|
|
41
|
+
// Create dest parent folder if needed
|
|
42
|
+
if (!existsSync(distPath)) {
|
|
43
|
+
mkdirSync(distPath, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
cpSync(srcPath, destPath, { recursive: true });
|
|
47
|
+
console.log(`- Copied: ${target}`);
|
|
48
|
+
} catch (copyErr) {
|
|
49
|
+
const errMsg =
|
|
50
|
+
copyErr instanceof Error ? copyErr.message : String(copyErr);
|
|
51
|
+
console.error(`- Failed to copy ${target}: ${errMsg}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
console.log("Build completed successfully!");
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAM/B;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAE,UAAU,EAAgB;IACpD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IACxD,IAAI,CAAC;QACJ,QAAQ,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,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\nimport { existsSync, rmSync, mkdirSync, cpSync } from \"fs\";\nimport { resolve } from \"path\";\n\ninterface BuildOptions {\n\tprojectDir: string;\n}\n\n/**\n * Orchestrates the full build process for a NetSuite bundle:\n * 1. Cleans the target build directory (dist).\n * 2. Compiles scripts using Rollup.\n * 3. Copies bundle metadata and static configurations to the build directory.\n *\n * @param {BuildOptions} options - Options containing the project's root directory.\n */\nexport function runBuild({ projectDir }: BuildOptions): void {\n\tconsole.log(\"Cleaning dist folder...\");\n\tconst distPath = resolve(projectDir, \"dist\");\n\tif (existsSync(distPath)) {\n\t\trmSync(distPath, { recursive: true, force: true });\n\t}\n\n\tconsole.log(\"Building TypeScript files with Rollup...\");\n\ttry {\n\t\texecSync(\"yarn rollup -c\", { stdio: \"inherit\", cwd: projectDir });\n\t} catch (err: unknown) {\n\t\tconsole.error(\"Rollup compilation failed!\");\n\t\tthrow err;\n\t}\n\n\tconsole.log(\"Copying project configurations to dist...\");\n\tconst targets = [\n\t\t\"manifest.xml\",\n\t\t\"deploy.xml\",\n\t\t\"Objects\",\n\t\t\"AccountConfiguration\",\n\t\t\"Translations\",\n\t\t\"FileCabinet\",\n\t];\n\n\tfor (const target of targets) {\n\t\tconst srcPath = resolve(projectDir, target);\n\t\tconst destPath = resolve(distPath, target);\n\n\t\tif (existsSync(srcPath)) {\n\t\t\t// Create dest parent folder if needed\n\t\t\tif (!existsSync(distPath)) {\n\t\t\t\tmkdirSync(distPath, { recursive: true });\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tcpSync(srcPath, destPath, { recursive: true });\n\t\t\t\tconsole.log(`- Copied: ${target}`);\n\t\t\t} catch (copyErr: unknown) {\n\t\t\t\tconst errMsg = copyErr instanceof Error ? copyErr.message : String(copyErr);\n\t\t\t\tconsole.error(`- Failed to copy ${target}: ${errMsg}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tconsole.log(\"Build completed successfully!\");\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as LogModule from "N/log.js";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
function define(
|
|
5
|
+
dependencies: string[],
|
|
6
|
+
factory: (...args: any[]) => any,
|
|
7
|
+
): void;
|
|
8
|
+
const log: typeof LogModule;
|
|
9
|
+
}
|
|
10
|
+
export * from "./rollup.js";
|
|
11
|
+
export * from "./build.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,UAAU,CAAC;AAE3C,OAAO,CAAC,MAAM,CAAC;IAEd,SAAS,MAAM,CACd,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAC9B,IAAI,CAAC;IAER,MAAM,GAAG,EAAE,OAAO,SAAS,CAAC;CAC5B;AAED,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC","sourcesContent":["import type * as LogModule from \"N/log.js\";\n\ndeclare global {\n\t/* eslint-disable @typescript-eslint/no-explicit-any */\n\tfunction define(\n\t\tdependencies: string[],\n\t\tfactory: (...args: any[]) => any,\n\t): void;\n\n\tconst log: typeof LogModule;\n}\n\nexport * from \"./rollup.js\";\nexport * from \"./build.js\";\n"]}
|
package/dist/rollup.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface RollupConfigOptions {
|
|
2
|
+
projectDir: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Recursively find entry files in src, excluding helpers, declarations,
|
|
6
|
+
* backups, and hidden folders.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} dir - The directory to search inside.
|
|
9
|
+
* @returns {string[]} The list of resolved file paths.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getEntryFiles(dir: string): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Dynamically creates a Rollup configuration array for all scripts inside a
|
|
14
|
+
* NetSuite bundle's src directory.
|
|
15
|
+
*
|
|
16
|
+
* @param {RollupConfigOptions} options - Options containing the absolute path
|
|
17
|
+
* to the project's root directory.
|
|
18
|
+
* @returns {any[]} The array of Rollup configuration objects.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createRollupConfig({
|
|
21
|
+
projectDir,
|
|
22
|
+
}: RollupConfigOptions): any[];
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=rollup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAQA,UAAU,mBAAmB;IAC5B,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAmCnD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,UAAU,EAAE,EAAE,mBAAmB,GAAG,GAAG,EAAE,CA4B7E"}
|
package/dist/rollup.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { readdirSync, statSync } from "fs";
|
|
2
|
+
import { extname, relative, resolve } from "path";
|
|
3
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
4
|
+
import typescriptPlugin from "@rollup/plugin-typescript";
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
const typescript = typescriptPlugin;
|
|
8
|
+
/**
|
|
9
|
+
* Recursively find entry files in src, excluding helpers, declarations,
|
|
10
|
+
* backups, and hidden folders.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} dir - The directory to search inside.
|
|
13
|
+
* @returns {string[]} The list of resolved file paths.
|
|
14
|
+
*/
|
|
15
|
+
export function getEntryFiles(dir) {
|
|
16
|
+
let results = [];
|
|
17
|
+
let list;
|
|
18
|
+
try {
|
|
19
|
+
list = readdirSync(dir);
|
|
20
|
+
} catch (_e) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
for (const file of list) {
|
|
24
|
+
const filePath = resolve(dir, file);
|
|
25
|
+
const stat = statSync(filePath);
|
|
26
|
+
if (stat && stat.isDirectory()) {
|
|
27
|
+
// Exclude helper/configuration directories and hidden folders from scanning direct entries
|
|
28
|
+
if (
|
|
29
|
+
!file.startsWith(".") &&
|
|
30
|
+
file !== "node_modules" &&
|
|
31
|
+
file !== "AccountConfiguration" &&
|
|
32
|
+
file !== "Translations" &&
|
|
33
|
+
file !== "Objects" &&
|
|
34
|
+
file !== "FileCabinet"
|
|
35
|
+
) {
|
|
36
|
+
results = results.concat(getEntryFiles(filePath));
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
const ext = extname(file);
|
|
40
|
+
if (
|
|
41
|
+
(ext === ".ts" || ext === ".js") &&
|
|
42
|
+
!file.endsWith(".d.ts") &&
|
|
43
|
+
!file.includes("-backup")
|
|
44
|
+
) {
|
|
45
|
+
results.push(filePath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return results;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Dynamically creates a Rollup configuration array for all scripts inside a
|
|
53
|
+
* NetSuite bundle's src directory.
|
|
54
|
+
*
|
|
55
|
+
* @param {RollupConfigOptions} options - Options containing the absolute path
|
|
56
|
+
* to the project's root directory.
|
|
57
|
+
* @returns {any[]} The array of Rollup configuration objects.
|
|
58
|
+
*/
|
|
59
|
+
export function createRollupConfig({ projectDir }) {
|
|
60
|
+
const entryFiles = getEntryFiles(resolve(projectDir, "src"));
|
|
61
|
+
return entryFiles.map((entry) => {
|
|
62
|
+
const relativePath = relative(resolve(projectDir, "src"), entry);
|
|
63
|
+
const outputRelativePath = relativePath.replace(/\.[jt]s$/, ".js");
|
|
64
|
+
return {
|
|
65
|
+
input: entry,
|
|
66
|
+
output: {
|
|
67
|
+
file: resolve(
|
|
68
|
+
projectDir,
|
|
69
|
+
"dist",
|
|
70
|
+
"FileCabinet",
|
|
71
|
+
"SuiteScripts",
|
|
72
|
+
outputRelativePath,
|
|
73
|
+
),
|
|
74
|
+
format: "es", // Standalone ESM modules
|
|
75
|
+
},
|
|
76
|
+
external: (id) => id.startsWith("N/"),
|
|
77
|
+
plugins: [
|
|
78
|
+
nodeResolve(),
|
|
79
|
+
typescript({
|
|
80
|
+
tsconfig: resolve(projectDir, "configs", "tsconfig.build.json"),
|
|
81
|
+
}),
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=rollup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,8DAA8D;AAC9D,MAAM,UAAU,GAAG,gBAAqD,CAAC;AAMzE;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACxC,IAAI,OAAO,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAc,CAAC;IACnB,IAAI,CAAC;QACJ,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QAC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AK,CAAC,CAAC;QACjE,MAAM,kBAAkB,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAEnE,OAAO;YACN,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE;gBACP,IAAI,EAAE,OAAO,CACZ,UAAU,EACV,MAAM,EACN,aAAa,EACb,cAAc,EACd,kBAAkB,CAClB;gBACD,MAAM,EAAE,IAAI,EAAE,yBAAyB;aACvC;YACD,QAAQ,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YAC7C,OAAO,EAAE;gBACR,WAAW,EAAE;gBACb,UAAU,CAAC;oBACV,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,SAAS,EAAE,qBAAqB,CAAC;iBAC/D,CAAC;aACF;SACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { readdirSync, statSync } from \"fs\";\nimport { extname, relative, resolve } from \"path\";\nimport typescriptPlugin from \"@rollup/plugin-typescript\";\nimport { nodeResolve } from \"@rollup/plugin-node-resolve\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst typescript = typescriptPlugin as unknown as (options?: any) => any;\n\ninterface RollupConfigOptions {\n\tprojectDir: string;\n}\n\n/**\n * Recursively find entry files in src, excluding helpers, declarations,\n * backups, and hidden folders.\n *\n * @param {string} dir - The directory to search inside.\n * @returns {string[]} The list of resolved file paths.\n */\nexport function getEntryFiles(dir: string): string[] {\n\tlet results: string[] = [];\n\tlet list: string[];\n\ttry {\n\t\tlist = readdirSync(dir);\n\t} catch (_e) {\n\t\treturn [];\n\t}\n\tfor (const file of list) {\n\t\tconst filePath = resolve(dir, file);\n\t\tconst stat = statSync(filePath);\n\t\tif (stat && stat.isDirectory()) {\n\t\t\t// Exclude helper/configuration directories and hidden folders from scanning direct entries\n\t\t\tif (\n\t\t\t\t!file.startsWith(\".\") &&\n\t\t\t\tfile !== \"node_modules\" &&\n\t\t\t\tfile !== \"AccountConfiguration\" &&\n\t\t\t\tfile !== \"Translations\" &&\n\t\t\t\tfile !== \"Objects\" &&\n\t\t\t\tfile !== \"FileCabinet\"\n\t\t\t) {\n\t\t\t\tresults = results.concat(getEntryFiles(filePath));\n\t\t\t}\n\t\t} else {\n\t\t\tconst ext = extname(file);\n\t\t\tif (\n\t\t\t\t(ext === \".ts\" || ext === \".js\") &&\n\t\t\t\t!file.endsWith(\".d.ts\") &&\n\t\t\t\t!file.includes(\"-backup\")\n\t\t\t) {\n\t\t\t\tresults.push(filePath);\n\t\t\t}\n\t\t}\n\t}\n\treturn results;\n}\n\n/**\n * Dynamically creates a Rollup configuration array for all scripts inside a NetSuite bundle's src directory.\n *\n * @param {RollupConfigOptions} options - Options containing the absolute path to the project's root directory.\n * @returns {any[]} The array of Rollup configuration objects.\n */\nexport function createRollupConfig({ projectDir }: RollupConfigOptions): any[] {\n\tconst entryFiles = getEntryFiles(resolve(projectDir, \"src\"));\n\n\treturn entryFiles.map((entry) => {\n\t\tconst relativePath = relative(resolve(projectDir, \"src\"), entry);\n\t\tconst outputRelativePath = relativePath.replace(/\\.[jt]s$/, \".js\");\n\n\t\treturn {\n\t\t\tinput: entry,\n\t\t\toutput: {\n\t\t\t\tfile: resolve(\n\t\t\t\t\tprojectDir,\n\t\t\t\t\t\"dist\",\n\t\t\t\t\t\"FileCabinet\",\n\t\t\t\t\t\"SuiteScripts\",\n\t\t\t\t\toutputRelativePath,\n\t\t\t\t),\n\t\t\t\tformat: \"es\", // Standalone ESM modules\n\t\t\t},\n\t\t\texternal: (id: string) => id.startsWith(\"N/\"),\n\t\t\tplugins: [\n\t\t\t\tnodeResolve(),\n\t\t\t\ttypescript({\n\t\t\t\t\ttsconfig: resolve(projectDir, \"configs\", \"tsconfig.build.json\"),\n\t\t\t\t}),\n\t\t\t],\n\t\t};\n\t});\n}\n"]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface UTMData {
|
|
2
|
+
utmSource?: string;
|
|
3
|
+
utmMedium?: string;
|
|
4
|
+
utmCampaign?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface RawPayloadData {
|
|
7
|
+
utm_source?: string;
|
|
8
|
+
utmSource?: string;
|
|
9
|
+
utm_medium?: string;
|
|
10
|
+
utmMedium?: string;
|
|
11
|
+
utm_campaign?: string;
|
|
12
|
+
utmCampaign?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface LeadRecordData {
|
|
15
|
+
id: string | number;
|
|
16
|
+
firstName?: string;
|
|
17
|
+
lastName?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
phone?: string;
|
|
20
|
+
company?: string;
|
|
21
|
+
language?: string;
|
|
22
|
+
inquiryReason?: string;
|
|
23
|
+
interestedIn?: string;
|
|
24
|
+
comments?: string;
|
|
25
|
+
leadSource?: string;
|
|
26
|
+
utmSource?: string;
|
|
27
|
+
utmMedium?: string;
|
|
28
|
+
utmCampaign?: string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface UTMData {\n\tutmSource?: string;\n\tutmMedium?: string;\n\tutmCampaign?: string;\n}\n\nexport interface RawPayloadData {\n\tutm_source?: string;\n\tutmSource?: string;\n\tutm_medium?: string;\n\tutmMedium?: string;\n\tutm_campaign?: string;\n\tutmCampaign?: string;\n}\n\nexport interface LeadRecordData {\n\tid: string | number;\n\tfirstName?: string;\n\tlastName?: string;\n\temail?: string;\n\tphone?: string;\n\tcompany?: string;\n\tlanguage?: string;\n\tinquiryReason?: string;\n\tinterestedIn?: string;\n\tcomments?: string;\n\tleadSource?: string;\n\tutmSource?: string;\n\tutmMedium?: string;\n\tutmCampaign?: string;\n}\n"]}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines the Lead Source value based on UTM source or pre-resolved value.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} leadSource - The current lead source if already set.
|
|
5
|
+
* @param {string} utmSource - The UTM source parameter.
|
|
6
|
+
* @returns {string} The resolved lead source.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLeadSourceText(
|
|
9
|
+
leadSource: string,
|
|
10
|
+
utmSource: string,
|
|
11
|
+
): string;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAgB/E"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines the Lead Source value based on UTM source or pre-resolved value.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} leadSource - The current lead source if already set.
|
|
5
|
+
* @param {string} utmSource - The UTM source parameter.
|
|
6
|
+
* @returns {string} The resolved lead source.
|
|
7
|
+
*/
|
|
8
|
+
export function getLeadSourceText(leadSource, utmSource) {
|
|
9
|
+
if (leadSource) {
|
|
10
|
+
return leadSource;
|
|
11
|
+
}
|
|
12
|
+
const utmMap = new Map([
|
|
13
|
+
["facebook", "Social Media"],
|
|
14
|
+
["google", "Search Engine"],
|
|
15
|
+
["linkedin", "Social Media"],
|
|
16
|
+
["newsletter", "Email Campaign"],
|
|
17
|
+
]);
|
|
18
|
+
const utmKey = (utmSource || "").toLowerCase();
|
|
19
|
+
const mappedValue = utmMap.get(utmKey);
|
|
20
|
+
if (mappedValue) {
|
|
21
|
+
return mappedValue;
|
|
22
|
+
}
|
|
23
|
+
return "Web";
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB,EAAE,SAAiB;IACtE,IAAI,UAAU,EAAE,CAAC;QAChB,OAAO,UAAU,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAiB;QACtC,CAAC,UAAU,EAAE,cAAc,CAAC;QAC5B,CAAC,QAAQ,EAAE,eAAe,CAAC;QAC3B,CAAC,UAAU,EAAE,cAAc,CAAC;QAC5B,CAAC,YAAY,EAAE,gBAAgB,CAAC;KAChC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/C,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,WAAW,EAAE,CAAC;QACjB,OAAO,WAAW,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/**\n * Determines the Lead Source value based on UTM source or pre-resolved value.\n *\n * @param {string} leadSource - The current lead source if already set.\n * @param {string} utmSource - The UTM source parameter.\n * @returns {string} The resolved lead source.\n */\nexport function getLeadSourceText(leadSource: string, utmSource: string): string {\n\tif (leadSource) {\n\t\treturn leadSource;\n\t}\n\tconst utmMap = new Map<string, string>([\n\t\t[\"facebook\", \"Social Media\"],\n\t\t[\"google\", \"Search Engine\"],\n\t\t[\"linkedin\", \"Social Media\"],\n\t\t[\"newsletter\", \"Email Campaign\"]\n\t]);\n\tconst utmKey = (utmSource || \"\").toLowerCase();\n\tconst mappedValue = utmMap.get(utmKey);\n\tif (mappedValue) {\n\t\treturn mappedValue;\n\t}\n\treturn \"Web\";\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rootreeweb/netsuite-bundles",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Shared configurations, build tools, and globals for NetSuite bundles",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"repository": "github:rootreeweb/meta-tools",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./configs/*": "./configs/*"
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22.0.0"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"format": "prettier . --cache --write",
|
|
23
|
+
"lint": "eslint --fix --cache",
|
|
24
|
+
"check": "tsc --noEmit",
|
|
25
|
+
"clean": "del-cli ./dist"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"configs/**/*",
|
|
29
|
+
"dist/**/*"
|
|
30
|
+
],
|
|
31
|
+
"keywords": [
|
|
32
|
+
"netsuite",
|
|
33
|
+
"bundles",
|
|
34
|
+
"suitebundle",
|
|
35
|
+
"suiteapp",
|
|
36
|
+
"suitescript"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
40
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
41
|
+
"rollup": "^4.63.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@hitc/netsuite-types": "^2026.2.1",
|
|
45
|
+
"@rootreeweb/linting": "^5.1.4",
|
|
46
|
+
"del-cli": "^7.0.0",
|
|
47
|
+
"eslint": "^10.9.1",
|
|
48
|
+
"prettier": "~3.8.5",
|
|
49
|
+
"typescript": "^6.0.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@hitc/netsuite-types": "*",
|
|
53
|
+
"typescript": "^6.0.0"
|
|
54
|
+
}
|
|
55
|
+
}
|