@oneuptime/common 7.0.4358 ā 7.0.4395
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/Models/AnalyticsModels/AnalyticsBaseModel/AnalyticsBaseModel.ts +0 -7
- package/Models/AnalyticsModels/AnalyticsBaseModel/CommonModel.ts +0 -13
- package/Models/AnalyticsModels/ExceptionInstance.ts +2 -2
- package/Models/DatabaseModels/Monitor.ts +1 -1
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleSchedule.ts +2 -2
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleTeam.ts +2 -2
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleUser.ts +2 -2
- package/Models/DatabaseModels/OnCallDutyPolicyTimeLog.ts +2 -2
- package/Models/DatabaseModels/Probe.ts +7 -1
- package/Models/DatabaseModels/ServiceCatalog.ts +2 -2
- package/Models/DatabaseModels/ServiceCopilotCodeRepository.ts +2 -2
- package/Server/Middleware/ProjectAuthorization.ts +11 -3
- package/Server/Services/OpenTelemetryIngestService.ts +13 -9
- package/Server/Utils/AnalyticsDatabase/Statement.ts +0 -1
- package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +28 -81
- package/Server/Utils/OpenAPI.ts +605 -16
- package/Server/Utils/StartServer.ts +2 -2
- package/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.ts +0 -49
- package/Types/AnalyticsDatabase/TableColumn.ts +0 -26
- package/Types/AnalyticsDatabase/TableColumnType.ts +2 -1
- package/Types/Database/TableColumnType.ts +3 -0
- package/Types/GenericFunction.ts +1 -1
- package/Types/GenericObject.ts +1 -1
- package/Types/Object.ts +1 -1
- package/UI/esbuild-config.js +214 -0
- package/Utils/Schema/AnalyticsModelSchema.ts +741 -0
- package/Utils/Schema/BaseSchema.ts +450 -0
- package/Utils/Schema/ModelSchema.ts +227 -460
- package/build/dist/Models/AnalyticsModels/AnalyticsBaseModel/AnalyticsBaseModel.js +0 -6
- package/build/dist/Models/AnalyticsModels/AnalyticsBaseModel/AnalyticsBaseModel.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/AnalyticsBaseModel/CommonModel.js +0 -9
- package/build/dist/Models/AnalyticsModels/AnalyticsBaseModel/CommonModel.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/ExceptionInstance.js +2 -2
- package/build/dist/Models/AnalyticsModels/ExceptionInstance.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Monitor.js +1 -1
- package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleSchedule.js +2 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleSchedule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleTeam.js +2 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleTeam.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleUser.js +2 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleUser.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js +2 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Probe.js +7 -1
- package/build/dist/Models/DatabaseModels/Probe.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ServiceCatalog.js +2 -2
- package/build/dist/Models/DatabaseModels/ServiceCatalog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ServiceCopilotCodeRepository.js +2 -2
- package/build/dist/Models/DatabaseModels/ServiceCopilotCodeRepository.js.map +1 -1
- package/build/dist/Server/Middleware/ProjectAuthorization.js +7 -3
- package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
- package/build/dist/Server/Services/OpenTelemetryIngestService.js +8 -4
- package/build/dist/Server/Services/OpenTelemetryIngestService.js.map +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js +0 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js.map +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +15 -55
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
- package/build/dist/Server/Utils/OpenAPI.js +467 -12
- package/build/dist/Server/Utils/OpenAPI.js.map +1 -1
- package/build/dist/Server/Utils/StartServer.js +2 -2
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js +0 -43
- package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js.map +1 -1
- package/build/dist/Types/AnalyticsDatabase/TableColumn.js +0 -19
- package/build/dist/Types/AnalyticsDatabase/TableColumn.js.map +1 -1
- package/build/dist/Types/AnalyticsDatabase/TableColumnType.js +2 -1
- package/build/dist/Types/AnalyticsDatabase/TableColumnType.js.map +1 -1
- package/build/dist/Types/Database/TableColumnType.js +3 -0
- package/build/dist/Types/Database/TableColumnType.js.map +1 -1
- package/build/dist/Utils/Schema/AnalyticsModelSchema.js +619 -0
- package/build/dist/Utils/Schema/AnalyticsModelSchema.js.map +1 -0
- package/build/dist/Utils/Schema/BaseSchema.js +295 -0
- package/build/dist/Utils/Schema/BaseSchema.js.map +1 -0
- package/build/dist/Utils/Schema/ModelSchema.js +207 -390
- package/build/dist/Utils/Schema/ModelSchema.js.map +1 -1
- package/package.json +3 -1
- package/Models/AnalyticsModels/AnalyticsBaseModel/NestedModel.ts +0 -8
- package/Models/AnalyticsModels/NestedModels/KeyValueNestedModel.ts +0 -59
- package/build/dist/Models/AnalyticsModels/AnalyticsBaseModel/NestedModel.js +0 -7
- package/build/dist/Models/AnalyticsModels/AnalyticsBaseModel/NestedModel.js.map +0 -1
- package/build/dist/Models/AnalyticsModels/NestedModels/KeyValueNestedModel.js +0 -51
- package/build/dist/Models/AnalyticsModels/NestedModels/KeyValueNestedModel.js.map +0 -1
|
@@ -198,9 +198,9 @@ const init: InitFunction = async (
|
|
|
198
198
|
app.use(`/${appName}`, ExpressStatic("/usr/src/app/public"));
|
|
199
199
|
|
|
200
200
|
app.get(
|
|
201
|
-
`/${appName}/dist/
|
|
201
|
+
`/${appName}/dist/Index.js`,
|
|
202
202
|
(_req: ExpressRequest, res: ExpressResponse) => {
|
|
203
|
-
res.sendFile("/usr/src/app/public/dist/
|
|
203
|
+
res.sendFile("/usr/src/app/public/dist/Index.js");
|
|
204
204
|
},
|
|
205
205
|
);
|
|
206
206
|
|
|
@@ -8,7 +8,6 @@ import StatementGenerator from "../../../../Server/Utils/AnalyticsDatabase/State
|
|
|
8
8
|
import logger from "../../../../Server/Utils/Logger";
|
|
9
9
|
import "../../TestingUtils/Init";
|
|
10
10
|
import AnalyticsBaseModel from "../../../../Models/AnalyticsModels/AnalyticsBaseModel/AnalyticsBaseModel";
|
|
11
|
-
import NestedModel from "../../../../Models/AnalyticsModels/AnalyticsBaseModel/NestedModel";
|
|
12
11
|
import Route from "../../../../Types/API/Route";
|
|
13
12
|
import AnalyticsTableEngine from "../../../../Types/AnalyticsDatabase/AnalyticsTableEngine";
|
|
14
13
|
import AnalyticsTableColumn from "../../../../Types/AnalyticsDatabase/TableColumn";
|
|
@@ -238,54 +237,6 @@ describe("StatementGenerator", () => {
|
|
|
238
237
|
);
|
|
239
238
|
});
|
|
240
239
|
|
|
241
|
-
test("should support nested models", () => {
|
|
242
|
-
class TestNestedModel extends NestedModel {
|
|
243
|
-
public constructor() {
|
|
244
|
-
super({
|
|
245
|
-
tableColumns: [
|
|
246
|
-
new AnalyticsTableColumn({
|
|
247
|
-
key: "nested_column_1",
|
|
248
|
-
title: "<title>",
|
|
249
|
-
description: "<description>",
|
|
250
|
-
required: true,
|
|
251
|
-
type: TableColumnType.Text,
|
|
252
|
-
}),
|
|
253
|
-
new AnalyticsTableColumn({
|
|
254
|
-
key: "nested_column_2",
|
|
255
|
-
title: "<title>",
|
|
256
|
-
description: "<description>",
|
|
257
|
-
required: false,
|
|
258
|
-
type: TableColumnType.Number,
|
|
259
|
-
}),
|
|
260
|
-
],
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const statement: Statement = generator.toColumnsCreateStatement([
|
|
266
|
-
new AnalyticsTableColumn({
|
|
267
|
-
key: "column_1",
|
|
268
|
-
title: "<title>",
|
|
269
|
-
description: "<description>",
|
|
270
|
-
required: true,
|
|
271
|
-
type: TableColumnType.Text,
|
|
272
|
-
}),
|
|
273
|
-
new AnalyticsTableColumn({
|
|
274
|
-
key: "column_2",
|
|
275
|
-
title: "<title>",
|
|
276
|
-
description: "<description>",
|
|
277
|
-
required: false,
|
|
278
|
-
type: TableColumnType.NestedModel,
|
|
279
|
-
nestedModelType: TestNestedModel,
|
|
280
|
-
}),
|
|
281
|
-
]);
|
|
282
|
-
|
|
283
|
-
expectStatement(
|
|
284
|
-
statement,
|
|
285
|
-
SQL`column_1 String, column_2 Nullable(Nested) (nested_column_1 String, nested_column_2 Nullable(Int32))`,
|
|
286
|
-
);
|
|
287
|
-
});
|
|
288
|
-
|
|
289
240
|
test("should not add NULL|NOT NULL to Array types", () => {
|
|
290
241
|
const statement: Statement = generator.toColumnsCreateStatement([
|
|
291
242
|
new AnalyticsTableColumn({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import NestedModel from "../../Models/AnalyticsModels/AnalyticsBaseModel/NestedModel";
|
|
2
1
|
import TableColumnType from "../AnalyticsDatabase/TableColumnType";
|
|
3
2
|
import { ColumnAccessControl } from "../BaseDatabase/AccessControl";
|
|
4
3
|
import ColumnBillingAccessControl from "../BaseDatabase/ColumnBillingAccessControl";
|
|
@@ -104,25 +103,8 @@ export default class AnalyticsTableColumn {
|
|
|
104
103
|
this._accessControl = v;
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
private _nestedModel?: NestedModel | undefined;
|
|
108
|
-
public get nestedModel(): NestedModel | undefined {
|
|
109
|
-
return this._nestedModel;
|
|
110
|
-
}
|
|
111
|
-
public set nestedModel(v: NestedModel | undefined) {
|
|
112
|
-
this._nestedModel = v;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private _nestedModelType?: { new (): NestedModel } | undefined;
|
|
116
|
-
public get nestedModelType(): { new (): NestedModel } | undefined {
|
|
117
|
-
return this._nestedModelType;
|
|
118
|
-
}
|
|
119
|
-
public set nestedModelType(v: { new (): NestedModel } | undefined) {
|
|
120
|
-
this._nestedModelType = v;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
106
|
public constructor(data: {
|
|
124
107
|
key: string;
|
|
125
|
-
nestedModelType?: { new (): NestedModel } | undefined;
|
|
126
108
|
title: string;
|
|
127
109
|
description: string;
|
|
128
110
|
required: boolean;
|
|
@@ -136,10 +118,6 @@ export default class AnalyticsTableColumn {
|
|
|
136
118
|
| (() => Date | string | number | boolean)
|
|
137
119
|
| undefined;
|
|
138
120
|
}) {
|
|
139
|
-
if (data.type === TableColumnType.NestedModel && !data.nestedModelType) {
|
|
140
|
-
throw new Error("NestedModel is required when type is NestedModel");
|
|
141
|
-
}
|
|
142
|
-
|
|
143
121
|
this.accessControl = data.accessControl;
|
|
144
122
|
this.key = data.key;
|
|
145
123
|
this.title = data.title;
|
|
@@ -152,9 +130,5 @@ export default class AnalyticsTableColumn {
|
|
|
152
130
|
this.billingAccessControl = data.billingAccessControl;
|
|
153
131
|
this.allowAccessIfSubscriptionIsUnpaid =
|
|
154
132
|
data.allowAccessIfSubscriptionIsUnpaid || false;
|
|
155
|
-
if (data.nestedModelType) {
|
|
156
|
-
this.nestedModel = new data.nestedModelType();
|
|
157
|
-
this.nestedModelType = data.nestedModelType;
|
|
158
|
-
}
|
|
159
133
|
}
|
|
160
134
|
}
|
|
@@ -4,13 +4,14 @@ enum ColumnType {
|
|
|
4
4
|
Boolean = "Boolean",
|
|
5
5
|
Number = "Number",
|
|
6
6
|
Text = "Text",
|
|
7
|
-
NestedModel = "Nested Model",
|
|
8
7
|
JSON = "JSON",
|
|
9
8
|
JSONArray = "JSON Array",
|
|
10
9
|
Decimal = "Decimal",
|
|
11
10
|
ArrayNumber = "Array of Numbers",
|
|
12
11
|
ArrayText = "Array of Text",
|
|
13
12
|
LongNumber = "Long Number",
|
|
13
|
+
IP = "IP",
|
|
14
|
+
Port = "Port",
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export default ColumnType;
|
|
@@ -14,6 +14,7 @@ enum ColumnType {
|
|
|
14
14
|
ShortURL = "Short URL",
|
|
15
15
|
Markdown = "Markdown",
|
|
16
16
|
Domain = "Domain",
|
|
17
|
+
MonitorSteps = "Monitor Steps",
|
|
17
18
|
LongURL = "URL",
|
|
18
19
|
ShortText = "Text",
|
|
19
20
|
OTP = "One Time Password",
|
|
@@ -38,6 +39,8 @@ enum ColumnType {
|
|
|
38
39
|
CustomFieldType = "Custom Field Type",
|
|
39
40
|
MonitorType = "Monitor Type",
|
|
40
41
|
WorkflowStatus = "Workflow Status",
|
|
42
|
+
IP = "IP",
|
|
43
|
+
Port = "Port",
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export default ColumnType;
|
package/Types/GenericFunction.ts
CHANGED
package/Types/GenericObject.ts
CHANGED
package/Types/Object.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-types
|
|
2
2
|
export type GlobalObject = object;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared esbuild configuration factory for OneUptime frontend services
|
|
3
|
+
* This creates consistent build configurations across all services
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const esbuild = require('esbuild');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const dotenv = require('dotenv');
|
|
10
|
+
|
|
11
|
+
// CSS Plugin to handle CSS/SCSS files
|
|
12
|
+
function createCSSPlugin() {
|
|
13
|
+
return {
|
|
14
|
+
name: 'css',
|
|
15
|
+
setup(build) {
|
|
16
|
+
build.onLoad({ filter: /\.s?css$/ }, async (args) => {
|
|
17
|
+
const sass = require('sass');
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
|
|
20
|
+
let contents = fs.readFileSync(args.path, 'utf8');
|
|
21
|
+
|
|
22
|
+
// Compile SCSS to CSS if it's a SCSS file
|
|
23
|
+
if (args.path.endsWith('.scss') || args.path.endsWith('.sass')) {
|
|
24
|
+
try {
|
|
25
|
+
const result = sass.compile(args.path);
|
|
26
|
+
contents = result.css;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(`SCSS compilation error in ${args.path}:`, error);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Return CSS as a string that will be injected into the page
|
|
34
|
+
return {
|
|
35
|
+
contents: `
|
|
36
|
+
const style = document.createElement('style');
|
|
37
|
+
style.textContent = ${JSON.stringify(contents)};
|
|
38
|
+
document.head.appendChild(style);
|
|
39
|
+
`,
|
|
40
|
+
loader: 'js',
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// File loader plugin for assets
|
|
48
|
+
function createFileLoaderPlugin() {
|
|
49
|
+
return {
|
|
50
|
+
name: 'file-loader',
|
|
51
|
+
setup(build) {
|
|
52
|
+
build.onLoad({ filter: /\.(png|jpe?g|gif|svg|woff|woff2|eot|ttf|otf)$/ }, async (args) => {
|
|
53
|
+
const fs = require('fs');
|
|
54
|
+
const path = require('path');
|
|
55
|
+
|
|
56
|
+
const contents = fs.readFileSync(args.path);
|
|
57
|
+
const filename = path.basename(args.path);
|
|
58
|
+
const ext = path.extname(filename);
|
|
59
|
+
|
|
60
|
+
// For development, we'll use data URLs for simplicity
|
|
61
|
+
// In production, you might want to copy files to the output directory
|
|
62
|
+
const mimeTypes = {
|
|
63
|
+
'.png': 'image/png',
|
|
64
|
+
'.jpg': 'image/jpeg',
|
|
65
|
+
'.jpeg': 'image/jpeg',
|
|
66
|
+
'.gif': 'image/gif',
|
|
67
|
+
'.svg': 'image/svg+xml',
|
|
68
|
+
'.woff': 'font/woff',
|
|
69
|
+
'.woff2': 'font/woff2',
|
|
70
|
+
'.eot': 'application/vnd.ms-fontobject',
|
|
71
|
+
'.ttf': 'font/ttf',
|
|
72
|
+
'.otf': 'font/otf',
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const mimeType = mimeTypes[ext.toLowerCase()] || 'application/octet-stream';
|
|
76
|
+
const dataUrl = `data:${mimeType};base64,${contents.toString('base64')}`;
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
contents: `export default ${JSON.stringify(dataUrl)};`,
|
|
80
|
+
loader: 'js',
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Read environment variables from .env file
|
|
88
|
+
function readEnvFile(pathToFile) {
|
|
89
|
+
if (!fs.existsSync(pathToFile)) {
|
|
90
|
+
console.warn(`Environment file not found: ${pathToFile}`);
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const parsed = dotenv.config({ path: pathToFile }).parsed || {};
|
|
95
|
+
const env = {};
|
|
96
|
+
|
|
97
|
+
for (const key in parsed) {
|
|
98
|
+
env[`process.env.${key}`] = JSON.stringify(parsed[key]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return env;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Create esbuild configuration for a service
|
|
106
|
+
* @param {Object} options - Configuration options
|
|
107
|
+
* @param {string} options.serviceName - Name of the service (dashboard, accounts, admin, status-page)
|
|
108
|
+
* @param {string} options.publicPath - Public path for assets
|
|
109
|
+
* @param {string} [options.entryPoint] - Entry point file (defaults to './src/Index.tsx')
|
|
110
|
+
* @param {string} [options.outdir] - Output directory (defaults to './public/dist')
|
|
111
|
+
* @param {Object} [options.additionalDefines] - Additional define variables
|
|
112
|
+
* @param {Array} [options.additionalExternal] - Additional external modules
|
|
113
|
+
* @param {Object} [options.additionalAlias] - Additional aliases
|
|
114
|
+
*/
|
|
115
|
+
function createConfig(options) {
|
|
116
|
+
const {
|
|
117
|
+
serviceName,
|
|
118
|
+
publicPath,
|
|
119
|
+
entryPoint = './src/Index.tsx',
|
|
120
|
+
outdir = './public/dist',
|
|
121
|
+
additionalDefines = {},
|
|
122
|
+
additionalExternal = [],
|
|
123
|
+
additionalAlias = {}
|
|
124
|
+
} = options;
|
|
125
|
+
|
|
126
|
+
const isDev = process.env.NODE_ENV !== 'production';
|
|
127
|
+
const isAnalyze = process.env.analyze === 'true';
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
entryPoints: [entryPoint],
|
|
131
|
+
bundle: true,
|
|
132
|
+
outdir,
|
|
133
|
+
format: 'esm', // Changed from 'iife' to 'esm' to support splitting
|
|
134
|
+
platform: 'browser',
|
|
135
|
+
target: 'es2017',
|
|
136
|
+
sourcemap: isDev ? 'inline' : false,
|
|
137
|
+
minify: false,
|
|
138
|
+
splitting: true, // Now supported with ESM format
|
|
139
|
+
publicPath,
|
|
140
|
+
define: {
|
|
141
|
+
'process.env.NODE_ENV': JSON.stringify(isDev ? 'development' : 'production'),
|
|
142
|
+
...additionalDefines,
|
|
143
|
+
},
|
|
144
|
+
external: ['react-native-sqlite-storage', ...additionalExternal],
|
|
145
|
+
alias: {
|
|
146
|
+
'react': path.resolve('./node_modules/react'),
|
|
147
|
+
...additionalAlias,
|
|
148
|
+
},
|
|
149
|
+
plugins: [createCSSPlugin(), createFileLoaderPlugin()],
|
|
150
|
+
loader: {
|
|
151
|
+
'.tsx': 'tsx',
|
|
152
|
+
'.ts': 'ts',
|
|
153
|
+
'.jsx': 'jsx',
|
|
154
|
+
'.js': 'js',
|
|
155
|
+
'.json': 'json',
|
|
156
|
+
},
|
|
157
|
+
resolveExtensions: ['.tsx', '.ts', '.jsx', '.js', '.json', '.css', '.scss'],
|
|
158
|
+
metafile: isAnalyze,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Build function that handles the build process
|
|
164
|
+
* @param {Object} config - esbuild configuration
|
|
165
|
+
* @param {string} serviceName - Name of the service for logging
|
|
166
|
+
*/
|
|
167
|
+
async function build(config, serviceName) {
|
|
168
|
+
const isAnalyze = process.env.analyze === 'true';
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
const result = await esbuild.build(config);
|
|
172
|
+
|
|
173
|
+
if (isAnalyze && result.metafile) {
|
|
174
|
+
const analyzeText = await esbuild.analyzeMetafile(result.metafile);
|
|
175
|
+
console.log(`\nš Bundle analysis for ${serviceName}:`);
|
|
176
|
+
console.log(analyzeText);
|
|
177
|
+
|
|
178
|
+
// Write metafile for external analysis tools
|
|
179
|
+
const metafilePath = path.join(config.outdir, 'metafile.json');
|
|
180
|
+
fs.writeFileSync(metafilePath, JSON.stringify(result.metafile, null, 2));
|
|
181
|
+
console.log(`š Metafile written to: ${metafilePath}`);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
console.log(`ā
${serviceName} build completed successfully`);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
console.error(`ā ${serviceName} build failed:`, error);
|
|
187
|
+
process.exit(1);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Watch function that handles the watch process
|
|
193
|
+
* @param {Object} config - esbuild configuration
|
|
194
|
+
* @param {string} serviceName - Name of the service for logging
|
|
195
|
+
*/
|
|
196
|
+
async function watch(config, serviceName) {
|
|
197
|
+
try {
|
|
198
|
+
const context = await esbuild.context(config);
|
|
199
|
+
await context.watch();
|
|
200
|
+
console.log(`š Watching ${serviceName} for changes...`);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error(`ā ${serviceName} watch failed:`, error);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
module.exports = {
|
|
208
|
+
createConfig,
|
|
209
|
+
build,
|
|
210
|
+
watch,
|
|
211
|
+
createCSSPlugin,
|
|
212
|
+
createFileLoaderPlugin,
|
|
213
|
+
readEnvFile,
|
|
214
|
+
};
|