n8n 1.84.1 → 1.85.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/dist/auth/auth.service.d.ts +4 -1
- package/dist/auth/auth.service.js +15 -12
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/commands/base-command.d.ts +3 -0
- package/dist/commands/base-command.js +8 -0
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/community-node.d.ts +38 -0
- package/dist/commands/community-node.js +129 -0
- package/dist/commands/community-node.js.map +1 -0
- package/dist/commands/import/workflow.js +6 -10
- package/dist/commands/import/workflow.js.map +1 -1
- package/dist/commands/license/clear.js +1 -1
- package/dist/commands/start.js +1 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/webhook.js +1 -0
- package/dist/commands/webhook.js.map +1 -1
- package/dist/commands/worker.js +1 -0
- package/dist/commands/worker.js.map +1 -1
- package/dist/config/index.d.ts +0 -4
- package/dist/config/schema.d.ts +0 -14
- package/dist/config/schema.js +0 -14
- package/dist/config/schema.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/controllers/users.controller.js +7 -8
- package/dist/controllers/users.controller.js.map +1 -1
- package/dist/databases/dsl/column.js +1 -1
- package/dist/databases/dsl/column.js.map +1 -1
- package/dist/databases/entities/index.d.ts +6 -0
- package/dist/databases/entities/index.js +6 -0
- package/dist/databases/entities/index.js.map +1 -1
- package/dist/databases/migrations/common/1739549398681-CreateAnalyticsTables.js +1 -1
- package/dist/databases/migrations/common/1739549398681-CreateAnalyticsTables.js.map +1 -1
- package/dist/databases/migrations/common/1741167584277-RenameAnalyticsToInsights.d.ts +4 -0
- package/dist/databases/migrations/common/1741167584277-RenameAnalyticsToInsights.js +82 -0
- package/dist/databases/migrations/common/1741167584277-RenameAnalyticsToInsights.js.map +1 -0
- package/dist/databases/migrations/mysqldb/index.js +2 -0
- package/dist/databases/migrations/mysqldb/index.js.map +1 -1
- package/dist/databases/migrations/postgresdb/index.js +2 -0
- package/dist/databases/migrations/postgresdb/index.js.map +1 -1
- package/dist/databases/migrations/sqlite/index.js +2 -0
- package/dist/databases/migrations/sqlite/index.js.map +1 -1
- package/dist/databases/repositories/workflow.repository.js +5 -3
- package/dist/databases/repositories/workflow.repository.js.map +1 -1
- package/dist/decorators/module.d.ts +12 -0
- package/dist/decorators/module.js +31 -0
- package/dist/decorators/module.js.map +1 -0
- package/dist/environments.ee/source-control/constants.d.ts +1 -0
- package/dist/environments.ee/source-control/constants.js +2 -1
- package/dist/environments.ee/source-control/constants.js.map +1 -1
- package/dist/environments.ee/source-control/source-control-export.service.ee.d.ts +4 -1
- package/dist/environments.ee/source-control/source-control-export.service.ee.js +61 -2
- package/dist/environments.ee/source-control/source-control-export.service.ee.js.map +1 -1
- package/dist/environments.ee/source-control/source-control-helper.ee.d.ts +1 -0
- package/dist/environments.ee/source-control/source-control-helper.ee.js +4 -0
- package/dist/environments.ee/source-control/source-control-helper.ee.js.map +1 -1
- package/dist/environments.ee/source-control/source-control-import.service.ee.d.ts +14 -1
- package/dist/environments.ee/source-control/source-control-import.service.ee.js +105 -3
- package/dist/environments.ee/source-control/source-control-import.service.ee.js.map +1 -1
- package/dist/environments.ee/source-control/source-control.controller.ee.d.ts +6 -3
- package/dist/environments.ee/source-control/source-control.service.ee.d.ts +12 -3
- package/dist/environments.ee/source-control/source-control.service.ee.js +97 -5
- package/dist/environments.ee/source-control/source-control.service.ee.js.map +1 -1
- package/dist/environments.ee/source-control/types/exportable-folders.d.ts +8 -0
- package/dist/environments.ee/source-control/types/exportable-folders.js +3 -0
- package/dist/environments.ee/source-control/types/exportable-folders.js.map +1 -0
- package/dist/environments.ee/source-control/types/exportable-workflow.d.ts +1 -0
- package/dist/environments.ee/source-control/types/source-control-workflow-version-id.d.ts +1 -0
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js +1 -1
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js.map +1 -1
- package/dist/execution-lifecycle/execution-lifecycle-hooks.js +4 -0
- package/dist/execution-lifecycle/execution-lifecycle-hooks.js.map +1 -1
- package/dist/interfaces.d.ts +7 -3
- package/dist/interfaces.js.map +1 -1
- package/dist/license.d.ts +1 -0
- package/dist/license.js +3 -0
- package/dist/license.js.map +1 -1
- package/dist/load-nodes-and-credentials.js +9 -4
- package/dist/load-nodes-and-credentials.js.map +1 -1
- package/dist/modules/insights/entities/insights-by-period.d.ts +15 -0
- package/dist/modules/insights/entities/insights-by-period.js +65 -0
- package/dist/modules/insights/entities/insights-by-period.js.map +1 -0
- package/dist/modules/insights/entities/insights-metadata.d.ts +8 -0
- package/dist/modules/insights/entities/insights-metadata.js +40 -0
- package/dist/modules/insights/entities/insights-metadata.js.map +1 -0
- package/dist/modules/insights/entities/insights-raw.d.ts +13 -0
- package/dist/modules/insights/entities/insights-raw.js +63 -0
- package/dist/modules/insights/entities/insights-raw.js.map +1 -0
- package/dist/modules/insights/entities/insights-shared.d.ts +19 -0
- package/dist/modules/insights/entities/insights-shared.js +34 -0
- package/dist/modules/insights/entities/insights-shared.js.map +1 -0
- package/dist/modules/insights/insights.config.d.ts +4 -0
- package/dist/modules/insights/insights.config.js +32 -0
- package/dist/modules/insights/insights.config.js.map +1 -0
- package/dist/modules/insights/insights.controller.d.ts +7 -0
- package/dist/modules/insights/insights.controller.js +35 -0
- package/dist/modules/insights/insights.controller.js.map +1 -0
- package/dist/modules/insights/insights.module.d.ts +12 -0
- package/dist/modules/insights/insights.module.js +40 -0
- package/dist/modules/insights/insights.module.js.map +1 -0
- package/dist/modules/insights/insights.service.d.ts +20 -0
- package/dist/modules/insights/insights.service.js +210 -0
- package/dist/modules/insights/insights.service.js.map +1 -0
- package/dist/modules/insights/repositories/insights-by-period.repository.d.ts +21 -0
- package/dist/modules/insights/repositories/insights-by-period.repository.js +179 -0
- package/dist/modules/insights/repositories/insights-by-period.repository.js.map +1 -0
- package/dist/modules/insights/repositories/insights-metadata.repository.d.ts +5 -0
- package/dist/modules/insights/repositories/insights-metadata.repository.js +26 -0
- package/dist/modules/insights/repositories/insights-metadata.repository.js.map +1 -0
- package/dist/modules/insights/repositories/insights-raw.repository.d.ts +6 -0
- package/dist/modules/insights/repositories/insights-raw.repository.js +34 -0
- package/dist/modules/insights/repositories/insights-raw.repository.js.map +1 -0
- package/dist/modules/modules.config.d.ts +10 -0
- package/dist/modules/modules.config.js +39 -0
- package/dist/modules/modules.config.js.map +1 -0
- package/dist/node-types.d.ts +1 -3
- package/dist/node-types.js +3 -10
- package/dist/node-types.js.map +1 -1
- package/dist/permissions.ee/global-roles.js +1 -0
- package/dist/permissions.ee/global-roles.js.map +1 -1
- package/dist/server.js +16 -3
- package/dist/server.js.map +1 -1
- package/dist/services/folder.service.js +3 -1
- package/dist/services/folder.service.js.map +1 -1
- package/dist/services/frontend.service.js +2 -2
- package/dist/services/frontend.service.js.map +1 -1
- package/dist/timezones.json +1 -1
- package/dist/utils/sql.d.ts +1 -0
- package/dist/utils/sql.js +13 -0
- package/dist/utils/sql.js.map +1 -0
- package/dist/workflows/workflow.service.d.ts +4 -2
- package/dist/workflows/workflow.service.js +16 -5
- package/dist/workflows/workflow.service.js.map +1 -1
- package/dist/workflows/workflows.controller.js +2 -2
- package/dist/workflows/workflows.controller.js.map +1 -1
- package/package.json +10 -10
- package/templates/form-trigger-completion.handlebars +25 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { InsightsSummary } from '@n8n/api-types';
|
|
2
|
+
import type { ExecutionLifecycleHooks } from 'n8n-core';
|
|
3
|
+
import { type IRun } from 'n8n-workflow';
|
|
4
|
+
import { SharedWorkflowRepository } from '../../databases/repositories/shared-workflow.repository';
|
|
5
|
+
import { InsightsByPeriodRepository } from './repositories/insights-by-period.repository';
|
|
6
|
+
import { InsightsRawRepository } from './repositories/insights-raw.repository';
|
|
7
|
+
export declare class InsightsService {
|
|
8
|
+
private readonly sharedWorkflowRepository;
|
|
9
|
+
private readonly insightsByPeriodRepository;
|
|
10
|
+
private readonly insightsRawRepository;
|
|
11
|
+
private compactInsightsTimer;
|
|
12
|
+
constructor(sharedWorkflowRepository: SharedWorkflowRepository, insightsByPeriodRepository: InsightsByPeriodRepository, insightsRawRepository: InsightsRawRepository);
|
|
13
|
+
initializeCompaction(): void;
|
|
14
|
+
shutdown(): void;
|
|
15
|
+
workflowExecuteAfterHandler(ctx: ExecutionLifecycleHooks, fullRunData: IRun): Promise<void>;
|
|
16
|
+
compactInsights(): Promise<void>;
|
|
17
|
+
compactRawToHour(): Promise<number>;
|
|
18
|
+
compactHourToDay(): Promise<number>;
|
|
19
|
+
getInsightsSummary(): Promise<InsightsSummary>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.InsightsService = void 0;
|
|
13
|
+
const di_1 = require("@n8n/di");
|
|
14
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
15
|
+
const shared_workflow_1 = require("../../databases/entities/shared-workflow");
|
|
16
|
+
const shared_workflow_repository_1 = require("../../databases/repositories/shared-workflow.repository");
|
|
17
|
+
const on_shutdown_1 = require("../../decorators/on-shutdown");
|
|
18
|
+
const insights_metadata_1 = require("../../modules/insights/entities/insights-metadata");
|
|
19
|
+
const insights_raw_1 = require("../../modules/insights/entities/insights-raw");
|
|
20
|
+
const insights_shared_1 = require("./entities/insights-shared");
|
|
21
|
+
const insights_config_1 = require("./insights.config");
|
|
22
|
+
const insights_by_period_repository_1 = require("./repositories/insights-by-period.repository");
|
|
23
|
+
const insights_raw_repository_1 = require("./repositories/insights-raw.repository");
|
|
24
|
+
const config = di_1.Container.get(insights_config_1.InsightsConfig);
|
|
25
|
+
const shouldSkipStatus = {
|
|
26
|
+
success: false,
|
|
27
|
+
crashed: false,
|
|
28
|
+
error: false,
|
|
29
|
+
canceled: true,
|
|
30
|
+
new: true,
|
|
31
|
+
running: true,
|
|
32
|
+
unknown: true,
|
|
33
|
+
waiting: true,
|
|
34
|
+
};
|
|
35
|
+
const shouldSkipMode = {
|
|
36
|
+
cli: false,
|
|
37
|
+
error: false,
|
|
38
|
+
integrated: false,
|
|
39
|
+
retry: false,
|
|
40
|
+
trigger: false,
|
|
41
|
+
webhook: false,
|
|
42
|
+
evaluation: false,
|
|
43
|
+
internal: true,
|
|
44
|
+
manual: true,
|
|
45
|
+
};
|
|
46
|
+
let InsightsService = class InsightsService {
|
|
47
|
+
constructor(sharedWorkflowRepository, insightsByPeriodRepository, insightsRawRepository) {
|
|
48
|
+
this.sharedWorkflowRepository = sharedWorkflowRepository;
|
|
49
|
+
this.insightsByPeriodRepository = insightsByPeriodRepository;
|
|
50
|
+
this.insightsRawRepository = insightsRawRepository;
|
|
51
|
+
this.initializeCompaction();
|
|
52
|
+
}
|
|
53
|
+
initializeCompaction() {
|
|
54
|
+
if (this.compactInsightsTimer !== undefined) {
|
|
55
|
+
clearInterval(this.compactInsightsTimer);
|
|
56
|
+
}
|
|
57
|
+
const intervalMilliseconds = config.compactionIntervalMinutes * 60 * 1000;
|
|
58
|
+
this.compactInsightsTimer = setInterval(async () => await this.compactInsights(), intervalMilliseconds);
|
|
59
|
+
}
|
|
60
|
+
shutdown() {
|
|
61
|
+
if (this.compactInsightsTimer !== undefined) {
|
|
62
|
+
clearInterval(this.compactInsightsTimer);
|
|
63
|
+
this.compactInsightsTimer = undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async workflowExecuteAfterHandler(ctx, fullRunData) {
|
|
67
|
+
if (shouldSkipStatus[fullRunData.status] || shouldSkipMode[fullRunData.mode]) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const status = fullRunData.status === 'success' ? 'success' : 'failure';
|
|
71
|
+
await this.sharedWorkflowRepository.manager.transaction(async (trx) => {
|
|
72
|
+
const sharedWorkflow = await trx.findOne(shared_workflow_1.SharedWorkflow, {
|
|
73
|
+
where: { workflowId: ctx.workflowData.id, role: 'workflow:owner' },
|
|
74
|
+
relations: { project: true },
|
|
75
|
+
});
|
|
76
|
+
if (!sharedWorkflow) {
|
|
77
|
+
throw new n8n_workflow_1.UnexpectedError(`Could not find an owner for the workflow with the name '${ctx.workflowData.name}' and the id '${ctx.workflowData.id}'`);
|
|
78
|
+
}
|
|
79
|
+
await trx.upsert(insights_metadata_1.InsightsMetadata, {
|
|
80
|
+
workflowId: ctx.workflowData.id,
|
|
81
|
+
workflowName: ctx.workflowData.name,
|
|
82
|
+
projectId: sharedWorkflow.projectId,
|
|
83
|
+
projectName: sharedWorkflow.project.name,
|
|
84
|
+
}, ['workflowId']);
|
|
85
|
+
const metadata = await trx.findOneBy(insights_metadata_1.InsightsMetadata, {
|
|
86
|
+
workflowId: ctx.workflowData.id,
|
|
87
|
+
});
|
|
88
|
+
if (!metadata) {
|
|
89
|
+
throw new n8n_workflow_1.UnexpectedError(`Could not find metadata for the workflow with the id '${ctx.workflowData.id}'`);
|
|
90
|
+
}
|
|
91
|
+
{
|
|
92
|
+
const event = new insights_raw_1.InsightsRaw();
|
|
93
|
+
event.metaId = metadata.metaId;
|
|
94
|
+
event.type = status;
|
|
95
|
+
event.value = 1;
|
|
96
|
+
await trx.insert(insights_raw_1.InsightsRaw, event);
|
|
97
|
+
}
|
|
98
|
+
if (fullRunData.stoppedAt) {
|
|
99
|
+
const value = fullRunData.stoppedAt.getTime() - fullRunData.startedAt.getTime();
|
|
100
|
+
const event = new insights_raw_1.InsightsRaw();
|
|
101
|
+
event.metaId = metadata.metaId;
|
|
102
|
+
event.type = 'runtime_ms';
|
|
103
|
+
event.value = value;
|
|
104
|
+
await trx.insert(insights_raw_1.InsightsRaw, event);
|
|
105
|
+
}
|
|
106
|
+
if (status === 'success' && ctx.workflowData.settings?.timeSavedPerExecution) {
|
|
107
|
+
const event = new insights_raw_1.InsightsRaw();
|
|
108
|
+
event.metaId = metadata.metaId;
|
|
109
|
+
event.type = 'time_saved_min';
|
|
110
|
+
event.value = ctx.workflowData.settings.timeSavedPerExecution;
|
|
111
|
+
await trx.insert(insights_raw_1.InsightsRaw, event);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
async compactInsights() {
|
|
116
|
+
let numberOfCompactedRawData;
|
|
117
|
+
do {
|
|
118
|
+
numberOfCompactedRawData = await this.compactRawToHour();
|
|
119
|
+
} while (numberOfCompactedRawData > 0);
|
|
120
|
+
let numberOfCompactedHourData;
|
|
121
|
+
do {
|
|
122
|
+
numberOfCompactedHourData = await this.compactHourToDay();
|
|
123
|
+
} while (numberOfCompactedHourData > 0);
|
|
124
|
+
}
|
|
125
|
+
async compactRawToHour() {
|
|
126
|
+
const batchQuery = this.insightsRawRepository.getRawInsightsBatchQuery(config.compactionBatchSize);
|
|
127
|
+
return await this.insightsByPeriodRepository.compactSourceDataIntoInsightPeriod({
|
|
128
|
+
sourceBatchQuery: batchQuery.getSql(),
|
|
129
|
+
sourceTableName: this.insightsRawRepository.metadata.tableName,
|
|
130
|
+
periodUnit: 'hour',
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async compactHourToDay() {
|
|
134
|
+
const batchQuery = this.insightsByPeriodRepository.getPeriodInsightsBatchQuery('hour', config.compactionBatchSize);
|
|
135
|
+
return await this.insightsByPeriodRepository.compactSourceDataIntoInsightPeriod({
|
|
136
|
+
sourceBatchQuery: batchQuery.getSql(),
|
|
137
|
+
periodUnit: 'day',
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async getInsightsSummary() {
|
|
141
|
+
const rows = await this.insightsByPeriodRepository.getPreviousAndCurrentPeriodTypeAggregates();
|
|
142
|
+
const data = {
|
|
143
|
+
current: { byType: {} },
|
|
144
|
+
previous: { byType: {} },
|
|
145
|
+
};
|
|
146
|
+
rows.forEach((row) => {
|
|
147
|
+
const { period, type, total_value } = row;
|
|
148
|
+
if (!data[period])
|
|
149
|
+
return;
|
|
150
|
+
data[period].byType[insights_shared_1.NumberToType[type]] = total_value ? Number(total_value) : 0;
|
|
151
|
+
});
|
|
152
|
+
const getValueByType = (period, type) => data[period]?.byType[type] ?? 0;
|
|
153
|
+
const currentSuccesses = getValueByType('current', 'success');
|
|
154
|
+
const currentFailures = getValueByType('current', 'failure');
|
|
155
|
+
const previousSuccesses = getValueByType('previous', 'success');
|
|
156
|
+
const previousFailures = getValueByType('previous', 'failure');
|
|
157
|
+
const currentTotal = currentSuccesses + currentFailures;
|
|
158
|
+
const previousTotal = previousSuccesses + previousFailures;
|
|
159
|
+
const currentFailureRate = currentTotal > 0 ? Math.round((currentFailures / currentTotal) * 100) / 100 : 0;
|
|
160
|
+
const previousFailureRate = previousTotal > 0 ? Math.round((previousFailures / previousTotal) * 100) / 100 : 0;
|
|
161
|
+
const currentTotalRuntime = getValueByType('current', 'runtime_ms') ?? 0;
|
|
162
|
+
const previousTotalRuntime = getValueByType('previous', 'runtime_ms') ?? 0;
|
|
163
|
+
const currentAvgRuntime = currentTotal > 0 ? Math.round((currentTotalRuntime / currentTotal) * 100) / 100 : 0;
|
|
164
|
+
const previousAvgRuntime = previousTotal > 0 ? Math.round((previousTotalRuntime / previousTotal) * 100) / 100 : 0;
|
|
165
|
+
const currentTimeSaved = getValueByType('current', 'time_saved_min');
|
|
166
|
+
const previousTimeSaved = getValueByType('previous', 'time_saved_min');
|
|
167
|
+
const result = {
|
|
168
|
+
averageRunTime: {
|
|
169
|
+
value: currentAvgRuntime,
|
|
170
|
+
unit: 'time',
|
|
171
|
+
deviation: currentAvgRuntime - previousAvgRuntime,
|
|
172
|
+
},
|
|
173
|
+
failed: {
|
|
174
|
+
value: currentFailures,
|
|
175
|
+
unit: 'count',
|
|
176
|
+
deviation: currentFailures - previousFailures,
|
|
177
|
+
},
|
|
178
|
+
failureRate: {
|
|
179
|
+
value: currentFailureRate,
|
|
180
|
+
unit: 'ratio',
|
|
181
|
+
deviation: currentFailureRate - previousFailureRate,
|
|
182
|
+
},
|
|
183
|
+
timeSaved: {
|
|
184
|
+
value: currentTimeSaved,
|
|
185
|
+
unit: 'time',
|
|
186
|
+
deviation: currentTimeSaved - previousTimeSaved,
|
|
187
|
+
},
|
|
188
|
+
total: {
|
|
189
|
+
value: currentTotal,
|
|
190
|
+
unit: 'count',
|
|
191
|
+
deviation: currentTotal - previousTotal,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
exports.InsightsService = InsightsService;
|
|
198
|
+
__decorate([
|
|
199
|
+
(0, on_shutdown_1.OnShutdown)(),
|
|
200
|
+
__metadata("design:type", Function),
|
|
201
|
+
__metadata("design:paramtypes", []),
|
|
202
|
+
__metadata("design:returntype", void 0)
|
|
203
|
+
], InsightsService.prototype, "shutdown", null);
|
|
204
|
+
exports.InsightsService = InsightsService = __decorate([
|
|
205
|
+
(0, di_1.Service)(),
|
|
206
|
+
__metadata("design:paramtypes", [shared_workflow_repository_1.SharedWorkflowRepository,
|
|
207
|
+
insights_by_period_repository_1.InsightsByPeriodRepository,
|
|
208
|
+
insights_raw_repository_1.InsightsRawRepository])
|
|
209
|
+
], InsightsService);
|
|
210
|
+
//# sourceMappingURL=insights.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insights.service.js","sourceRoot":"","sources":["../../../src/modules/insights/insights.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gCAA6C;AAE7C,+CAKsB;AAEtB,0EAAsE;AACtE,oGAA+F;AAC/F,0DAAsD;AACtD,qFAAiF;AACjF,2EAAuE;AAGvE,gEAA0D;AAC1D,uDAAmD;AACnD,gGAA0F;AAC1F,oFAA+E;AAE/E,MAAM,MAAM,GAAG,cAAS,CAAC,GAAG,CAAC,gCAAc,CAAC,CAAC;AAE7C,MAAM,gBAAgB,GAAqC;IAC1D,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,KAAK;IAEZ,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,IAAI;IACT,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;CACb,CAAC;AAEF,MAAM,cAAc,GAAyC;IAC5D,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE,KAAK;IACjB,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,KAAK;IAEjB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,IAAI;CACZ,CAAC;AAGK,IAAM,eAAe,GAArB,MAAM,eAAe;IAG3B,YACkB,wBAAkD,EAClD,0BAAsD,EACtD,qBAA4C;QAF5C,6BAAwB,GAAxB,wBAAwB,CAA0B;QAClD,+BAA0B,GAA1B,0BAA0B,CAA4B;QACtD,0BAAqB,GAArB,qBAAqB,CAAuB;QAE7D,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC7B,CAAC;IAED,oBAAoB;QACnB,IAAI,IAAI,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;YAC7C,aAAa,CAAC,IAAI,CAAC,oBAAoB,CAAC,C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,SAAS,EAAE,iBAAiB,GAAG,kBAAkB;aACjD;YACD,MAAM,EAAE;gBACP,KAAK,EAAE,eAAe;gBACtB,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,eAAe,GAAG,gBAAgB;aAC7C;YACD,WAAW,EAAE;gBACZ,KAAK,EAAE,kBAAkB;gBACzB,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,kBAAkB,GAAG,mBAAmB;aACnD;YACD,SAAS,EAAE;gBACV,KAAK,EAAE,gBAAgB;gBACvB,IAAI,EAAE,MAAM;gBACZ,SAAS,EAAE,gBAAgB,GAAG,iBAAiB;aAC/C;YACD,KAAK,EAAE;gBACN,KAAK,EAAE,YAAY;gBACnB,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,YAAY,GAAG,aAAa;aACvC;SACD,CAAC;QAEF,OAAO,MAAM,CAAC;IACf,CAAC;CACD,CAAA;AAhOY,0CAAe;AAuB3B;IADC,IAAA,wBAAU,GAAE;;;;+CAMZ;0BA5BW,eAAe;IAD3B,IAAA,YAAO,GAAE;qCAKmC,qDAAwB;QACtB,0DAA0B;QAC/B,+CAAqB;GANlD,eAAe,CAgO3B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataSource, Repository } from '@n8n/typeorm';
|
|
2
|
+
import { InsightsByPeriod } from '../entities/insights-by-period';
|
|
3
|
+
import type { PeriodUnit } from '../entities/insights-shared';
|
|
4
|
+
export declare class InsightsByPeriodRepository extends Repository<InsightsByPeriod> {
|
|
5
|
+
constructor(dataSource: DataSource);
|
|
6
|
+
private escapeField;
|
|
7
|
+
private getPeriodFilterExpr;
|
|
8
|
+
private getPeriodStartExpr;
|
|
9
|
+
getPeriodInsightsBatchQuery(periodUnit: PeriodUnit, compactionBatchSize: number): import("@n8n/typeorm").SelectQueryBuilder<InsightsByPeriod>;
|
|
10
|
+
getAggregationQuery(periodUnit: PeriodUnit): import("@n8n/typeorm").SelectQueryBuilder<import("@n8n/typeorm").ObjectLiteral>;
|
|
11
|
+
compactSourceDataIntoInsightPeriod({ sourceBatchQuery, sourceTableName, periodUnit, }: {
|
|
12
|
+
sourceBatchQuery: string;
|
|
13
|
+
sourceTableName?: string;
|
|
14
|
+
periodUnit: PeriodUnit;
|
|
15
|
+
}): Promise<number>;
|
|
16
|
+
getPreviousAndCurrentPeriodTypeAggregates(): Promise<Array<{
|
|
17
|
+
period: 'previous' | 'current';
|
|
18
|
+
type: 0 | 1 | 2 | 3;
|
|
19
|
+
total_value: string | number;
|
|
20
|
+
}>>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.InsightsByPeriodRepository = void 0;
|
|
13
|
+
const config_1 = require("@n8n/config");
|
|
14
|
+
const di_1 = require("@n8n/di");
|
|
15
|
+
const typeorm_1 = require("@n8n/typeorm");
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
const sql_1 = require("../../../utils/sql");
|
|
18
|
+
const insights_by_period_1 = require("../entities/insights-by-period");
|
|
19
|
+
const insights_shared_1 = require("../entities/insights-shared");
|
|
20
|
+
const dbType = di_1.Container.get(config_1.GlobalConfig).database.type;
|
|
21
|
+
const summaryParser = zod_1.z
|
|
22
|
+
.object({
|
|
23
|
+
period: zod_1.z.enum(['previous', 'current']),
|
|
24
|
+
type: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1), zod_1.z.literal(2), zod_1.z.literal(3)]),
|
|
25
|
+
total_value: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
|
|
26
|
+
})
|
|
27
|
+
.array();
|
|
28
|
+
let InsightsByPeriodRepository = class InsightsByPeriodRepository extends typeorm_1.Repository {
|
|
29
|
+
constructor(dataSource) {
|
|
30
|
+
super(insights_by_period_1.InsightsByPeriod, dataSource.manager);
|
|
31
|
+
}
|
|
32
|
+
escapeField(fieldName) {
|
|
33
|
+
return this.manager.connection.driver.escape(fieldName);
|
|
34
|
+
}
|
|
35
|
+
getPeriodFilterExpr(periodUnit) {
|
|
36
|
+
const daysAgo = periodUnit === 'day' ? 90 : 180;
|
|
37
|
+
let periodStartExpr = `date('now', '-${daysAgo} days')`;
|
|
38
|
+
if (dbType === 'postgresdb') {
|
|
39
|
+
periodStartExpr = `CURRENT_DATE - INTERVAL '${daysAgo} day'`;
|
|
40
|
+
}
|
|
41
|
+
else if (dbType === 'mysqldb' || dbType === 'mariadb') {
|
|
42
|
+
periodStartExpr = `DATE_SUB(CURRENT_DATE, INTERVAL ${daysAgo} DAY)`;
|
|
43
|
+
}
|
|
44
|
+
return periodStartExpr;
|
|
45
|
+
}
|
|
46
|
+
getPeriodStartExpr(periodUnit) {
|
|
47
|
+
let periodStartExpr = `strftime('%Y-%m-%d ${periodUnit === 'hour' ? '%H' : '00'}:00:00.000', periodStart)`;
|
|
48
|
+
if (dbType === 'mysqldb' || dbType === 'mariadb') {
|
|
49
|
+
periodStartExpr =
|
|
50
|
+
periodUnit === 'hour'
|
|
51
|
+
? "DATE_FORMAT(periodStart, '%Y-%m-%d %H:00:00')"
|
|
52
|
+
: "DATE_FORMAT(periodStart, '%Y-%m-%d 00:00:00')";
|
|
53
|
+
}
|
|
54
|
+
else if (dbType === 'postgresdb') {
|
|
55
|
+
periodStartExpr = `DATE_TRUNC('${periodUnit}', ${this.escapeField('periodStart')})`;
|
|
56
|
+
}
|
|
57
|
+
return periodStartExpr;
|
|
58
|
+
}
|
|
59
|
+
getPeriodInsightsBatchQuery(periodUnit, compactionBatchSize) {
|
|
60
|
+
const batchQuery = this.createQueryBuilder()
|
|
61
|
+
.select(['id', 'metaId', 'type', 'periodStart', 'value'].map((fieldName) => this.escapeField(fieldName)))
|
|
62
|
+
.where(`${this.escapeField('periodUnit')} = ${insights_shared_1.PeriodUnitToNumber[periodUnit]}`)
|
|
63
|
+
.andWhere(`${this.escapeField('periodStart')} < ${this.getPeriodFilterExpr('day')}`)
|
|
64
|
+
.orderBy(this.escapeField('periodStart'), 'ASC')
|
|
65
|
+
.limit(compactionBatchSize);
|
|
66
|
+
return batchQuery;
|
|
67
|
+
}
|
|
68
|
+
getAggregationQuery(periodUnit) {
|
|
69
|
+
const periodStartExpr = this.getPeriodStartExpr(periodUnit);
|
|
70
|
+
const aggregationQuery = this.manager
|
|
71
|
+
.createQueryBuilder()
|
|
72
|
+
.select(this.escapeField('metaId'))
|
|
73
|
+
.addSelect(this.escapeField('type'))
|
|
74
|
+
.addSelect(insights_shared_1.PeriodUnitToNumber[periodUnit].toString(), 'periodUnit')
|
|
75
|
+
.addSelect(periodStartExpr, 'periodStart')
|
|
76
|
+
.addSelect(`SUM(${this.escapeField('value')})`, 'value')
|
|
77
|
+
.from('rows_to_compact', 'rtc')
|
|
78
|
+
.groupBy(this.escapeField('metaId'))
|
|
79
|
+
.addGroupBy(this.escapeField('type'))
|
|
80
|
+
.addGroupBy(periodStartExpr);
|
|
81
|
+
return aggregationQuery;
|
|
82
|
+
}
|
|
83
|
+
async compactSourceDataIntoInsightPeriod({ sourceBatchQuery, sourceTableName = this.metadata.tableName, periodUnit, }) {
|
|
84
|
+
const getBatchAndStoreInTemporaryTable = (0, sql_1.sql) `
|
|
85
|
+
CREATE TEMPORARY TABLE rows_to_compact AS
|
|
86
|
+
${sourceBatchQuery};
|
|
87
|
+
`;
|
|
88
|
+
const countBatch = (0, sql_1.sql) `
|
|
89
|
+
SELECT COUNT(*) ${this.escapeField('rowsInBatch')} FROM rows_to_compact;
|
|
90
|
+
`;
|
|
91
|
+
const targetColumnNamesStr = ['metaId', 'type', 'periodUnit', 'periodStart']
|
|
92
|
+
.map((param) => this.escapeField(param))
|
|
93
|
+
.join(', ');
|
|
94
|
+
const targetColumnNamesWithValue = `${targetColumnNamesStr}, value`;
|
|
95
|
+
const aggregationQuery = this.getAggregationQuery(periodUnit);
|
|
96
|
+
const insertQueryBase = (0, sql_1.sql) `
|
|
97
|
+
INSERT INTO ${this.metadata.tableName}
|
|
98
|
+
(${targetColumnNamesWithValue})
|
|
99
|
+
${aggregationQuery.getSql()}
|
|
100
|
+
`;
|
|
101
|
+
let deduplicateQuery;
|
|
102
|
+
if (dbType === 'mysqldb' || dbType === 'mariadb') {
|
|
103
|
+
deduplicateQuery = (0, sql_1.sql) `
|
|
104
|
+
ON DUPLICATE KEY UPDATE value = value + VALUES(value)`;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
deduplicateQuery = (0, sql_1.sql) `
|
|
108
|
+
ON CONFLICT(${targetColumnNamesStr})
|
|
109
|
+
DO UPDATE SET value = ${this.metadata.tableName}.value + excluded.value
|
|
110
|
+
RETURNING *`;
|
|
111
|
+
}
|
|
112
|
+
const upsertEvents = (0, sql_1.sql) `
|
|
113
|
+
${insertQueryBase}
|
|
114
|
+
${deduplicateQuery}
|
|
115
|
+
`;
|
|
116
|
+
const deleteBatch = (0, sql_1.sql) `
|
|
117
|
+
DELETE FROM ${sourceTableName}
|
|
118
|
+
WHERE id IN (SELECT id FROM rows_to_compact);
|
|
119
|
+
`;
|
|
120
|
+
const dropTemporaryTable = (0, sql_1.sql) `
|
|
121
|
+
DROP TABLE rows_to_compact;
|
|
122
|
+
`;
|
|
123
|
+
const result = await this.manager.transaction(async (trx) => {
|
|
124
|
+
await trx.query(getBatchAndStoreInTemporaryTable);
|
|
125
|
+
await trx.query(upsertEvents);
|
|
126
|
+
const rowsInBatch = await trx.query(countBatch);
|
|
127
|
+
await trx.query(deleteBatch);
|
|
128
|
+
await trx.query(dropTemporaryTable);
|
|
129
|
+
return Number(rowsInBatch[0].rowsInBatch);
|
|
130
|
+
});
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
async getPreviousAndCurrentPeriodTypeAggregates() {
|
|
134
|
+
const cte = dbType === 'sqlite'
|
|
135
|
+
? (0, sql_1.sql) `
|
|
136
|
+
SELECT
|
|
137
|
+
datetime('now', '-7 days') AS current_start,
|
|
138
|
+
datetime('now') AS current_end,
|
|
139
|
+
datetime('now', '-14 days') AS previous_start
|
|
140
|
+
`
|
|
141
|
+
: dbType === 'postgresdb'
|
|
142
|
+
? (0, sql_1.sql) `
|
|
143
|
+
SELECT
|
|
144
|
+
(CURRENT_DATE - INTERVAL '7 days')::timestamptz AS current_start,
|
|
145
|
+
CURRENT_DATE::timestamptz AS current_end,
|
|
146
|
+
(CURRENT_DATE - INTERVAL '14 days')::timestamptz AS previous_start
|
|
147
|
+
`
|
|
148
|
+
: (0, sql_1.sql) `
|
|
149
|
+
SELECT
|
|
150
|
+
DATE_SUB(CURDATE(), INTERVAL 7 DAY) AS current_start,
|
|
151
|
+
CURDATE() AS current_end,
|
|
152
|
+
DATE_SUB(CURDATE(), INTERVAL 14 DAY) AS previous_start
|
|
153
|
+
`;
|
|
154
|
+
const rawRows = await this.createQueryBuilder('insights')
|
|
155
|
+
.addCommonTableExpression(cte, 'date_ranges')
|
|
156
|
+
.select((0, sql_1.sql) `
|
|
157
|
+
CASE
|
|
158
|
+
WHEN insights.periodStart >= date_ranges.current_start AND insights.periodStart <= date_ranges.current_end
|
|
159
|
+
THEN 'current'
|
|
160
|
+
ELSE 'previous'
|
|
161
|
+
END
|
|
162
|
+
`, 'period')
|
|
163
|
+
.addSelect('insights.type', 'type')
|
|
164
|
+
.addSelect('SUM(value)', 'total_value')
|
|
165
|
+
.innerJoin('date_ranges', 'date_ranges', '1=1')
|
|
166
|
+
.where('insights.periodStart >= date_ranges.previous_start')
|
|
167
|
+
.andWhere('insights.periodStart <= date_ranges.current_end')
|
|
168
|
+
.groupBy('period')
|
|
169
|
+
.addGroupBy('insights.type')
|
|
170
|
+
.getRawMany();
|
|
171
|
+
return summaryParser.parse(rawRows);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
exports.InsightsByPeriodRepository = InsightsByPeriodRepository;
|
|
175
|
+
exports.InsightsByPeriodRepository = InsightsByPeriodRepository = __decorate([
|
|
176
|
+
(0, di_1.Service)(),
|
|
177
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
178
|
+
], InsightsByPeriodRepository);
|
|
179
|
+
//# sourceMappingURL=insights-by-period.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insights-by-period.repository.js","sourceRoot":"","sources":["../../../../src/modules/insights/repositories/insights-by-period.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA2C;AAC3C,gCAA6C;AAC7C,0CAAsD;AACtD,6BAAwB;AAExB,qCAAkC;AAElC,uEAAkE;AAElE,iEAAiE;AAEjE,MAAM,MAAM,GAAG,cAAS,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAEzD,MAAM,aAAa,GAAG,OAAC;KACrB,MAAM,CAAC;IACP,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACvC,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,C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G,EAAA;;;;;;MAMD,EACF,QAAQ,CACR;aACA,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC;aAClC,SAAS,CAAC,YAAY,EAAE,aAAa,CAAC;aAEtC,SAAS,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,CAAC;aAE9C,KAAK,CAAC,oDAAoD,CAAC;aAC3D,QAAQ,CAAC,iDAAiD,CAAC;aAE3D,OAAO,CAAC,QAAQ,CAAC;aACjB,UAAU,CAAC,eAAe,CAAC;aAC3B,UAAU,EAAE,CAAC;QAEf,OAAO,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACD,CAAA;AA9MY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,YAAO,GAAE;qCAEe,oBAAU;GADtB,0BAA0B,CA8MtC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.InsightsMetadataRepository = void 0;
|
|
13
|
+
const di_1 = require("@n8n/di");
|
|
14
|
+
const typeorm_1 = require("@n8n/typeorm");
|
|
15
|
+
const insights_metadata_1 = require("../entities/insights-metadata");
|
|
16
|
+
let InsightsMetadataRepository = class InsightsMetadataRepository extends typeorm_1.Repository {
|
|
17
|
+
constructor(dataSource) {
|
|
18
|
+
super(insights_metadata_1.InsightsMetadata, dataSource.manager);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.InsightsMetadataRepository = InsightsMetadataRepository;
|
|
22
|
+
exports.InsightsMetadataRepository = InsightsMetadataRepository = __decorate([
|
|
23
|
+
(0, di_1.Service)(),
|
|
24
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
25
|
+
], InsightsMetadataRepository);
|
|
26
|
+
//# sourceMappingURL=insights-metadata.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insights-metadata.repository.js","sourceRoot":"","sources":["../../../../src/modules/insights/repositories/insights-metadata.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gCAAkC;AAClC,0CAAsD;AAEtD,qEAAiE;AAG1D,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,oBAA4B;IAC3E,YAAY,UAAsB;QACjC,KAAK,CAAC,oCAAgB,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACD,CAAA;AAJY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,YAAO,GAAE;qCAEe,oBAAU;GADtB,0BAA0B,CAItC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DataSource, Repository } from '@n8n/typeorm';
|
|
2
|
+
import { InsightsRaw } from '../entities/insights-raw';
|
|
3
|
+
export declare class InsightsRawRepository extends Repository<InsightsRaw> {
|
|
4
|
+
constructor(dataSource: DataSource);
|
|
5
|
+
getRawInsightsBatchQuery(compactionBatchSize: number): import("@n8n/typeorm").SelectQueryBuilder<InsightsRaw>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.InsightsRawRepository = void 0;
|
|
13
|
+
const di_1 = require("@n8n/di");
|
|
14
|
+
const typeorm_1 = require("@n8n/typeorm");
|
|
15
|
+
const insights_raw_1 = require("../entities/insights-raw");
|
|
16
|
+
let InsightsRawRepository = class InsightsRawRepository extends typeorm_1.Repository {
|
|
17
|
+
constructor(dataSource) {
|
|
18
|
+
super(insights_raw_1.InsightsRaw, dataSource.manager);
|
|
19
|
+
}
|
|
20
|
+
getRawInsightsBatchQuery(compactionBatchSize) {
|
|
21
|
+
const batchQuery = this.createQueryBuilder()
|
|
22
|
+
.select(['id', 'metaId', 'type', 'value'].map((fieldName) => this.manager.connection.driver.escape(fieldName)))
|
|
23
|
+
.addSelect('timestamp', 'periodStart')
|
|
24
|
+
.orderBy('timestamp', 'ASC')
|
|
25
|
+
.limit(compactionBatchSize);
|
|
26
|
+
return batchQuery;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.InsightsRawRepository = InsightsRawRepository;
|
|
30
|
+
exports.InsightsRawRepository = InsightsRawRepository = __decorate([
|
|
31
|
+
(0, di_1.Service)(),
|
|
32
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
33
|
+
], InsightsRawRepository);
|
|
34
|
+
//# sourceMappingURL=insights-raw.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insights-raw.repository.js","sourceRoot":"","sources":["../../../../src/modules/insights/repositories/insights-raw.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gCAAkC;AAClC,0CAAsD;AAEtD,2DAAuD;AAGhD,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,oBAAuB;IACjE,YAAY,UAAsB;QACjC,KAAK,CAAC,0BAAW,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,wBAAwB,CAAC,mBAA2B;QAEnD,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,EAAE;aAC1C,MAAM,CACN,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CACnD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAChD,CACD;aACA,SAAS,CAAC,WAAW,EAAE,aAAa,CAAC;aACrC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC;aAC3B,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC7B,OAAO,UAAU,CAAC;IACnB,CAAC;CACD,CAAA;AAlBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,YAAO,GAAE;qCAEe,oBAAU;GADtB,qBAAqB,CAkBjC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommaSeperatedStringArray } from '@n8n/config';
|
|
2
|
+
declare const moduleNames: readonly ["insights"];
|
|
3
|
+
type ModuleName = (typeof moduleNames)[number];
|
|
4
|
+
declare class Modules extends CommaSeperatedStringArray<ModuleName> {
|
|
5
|
+
constructor(str: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class ModulesConfig {
|
|
8
|
+
modules: Modules;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ModulesConfig = void 0;
|
|
13
|
+
const config_1 = require("@n8n/config");
|
|
14
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
15
|
+
const moduleNames = ['insights'];
|
|
16
|
+
class Modules extends config_1.CommaSeperatedStringArray {
|
|
17
|
+
constructor(str) {
|
|
18
|
+
super(str);
|
|
19
|
+
for (const moduleName of this) {
|
|
20
|
+
if (!moduleNames.includes(moduleName)) {
|
|
21
|
+
throw new n8n_workflow_1.UnexpectedError(`Unknown module name ${moduleName}`, { level: 'fatal' });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
let ModulesConfig = class ModulesConfig {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.modules = [];
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.ModulesConfig = ModulesConfig;
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, config_1.Env)('N8N_ENABLED_MODULES'),
|
|
34
|
+
__metadata("design:type", Modules)
|
|
35
|
+
], ModulesConfig.prototype, "modules", void 0);
|
|
36
|
+
exports.ModulesConfig = ModulesConfig = __decorate([
|
|
37
|
+
config_1.Config
|
|
38
|
+
], ModulesConfig);
|
|
39
|
+
//# sourceMappingURL=modules.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.config.js","sourceRoot":"","sources":["../../src/modules/modules.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAqE;AACrE,+CAA+C;AAE/C,MAAM,WAAW,GAAG,CAAC,UAAU,CAAU,CAAC;AAG1C,MAAM,OAAQ,SAAQ,kCAAqC;IAC1D,YAAY,GAAW;QACtB,KAAK,CAAC,GAAG,CAAC,CAAC;QAEX,KAAK,MAAM,UAAU,IAAI,IAAI,EAAE,CAAC;YAC/B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBACvC,MAAM,IAAI,8BAAe,CAAC,uBAAuB,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;YACpF,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;IAAnB;QAGN,YAAO,GAAY,EAAE,CAAC;IACvB,CAAC;CAAA,CAAA;AAJY,sCAAa;AAGzB;IADC,IAAA,YAAG,EAAC,qBAAqB,CAAC;8BAClB,OAAO;8CAAM;wBAHV,aAAa;IADzB,eAAM;GACM,aAAa,CAIzB"}
|
package/dist/node-types.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { GlobalConfig } from '@n8n/config';
|
|
2
1
|
import type { NeededNodeType } from '@n8n/task-runner';
|
|
3
2
|
import type { INodeType, INodeTypeDescription, INodeTypes, IVersionedNodeType } from 'n8n-workflow';
|
|
4
3
|
import { LoadNodesAndCredentials } from './load-nodes-and-credentials';
|
|
5
4
|
export declare class NodeTypes implements INodeTypes {
|
|
6
|
-
private readonly globalConfig;
|
|
7
5
|
private readonly loadNodesAndCredentials;
|
|
8
|
-
constructor(
|
|
6
|
+
constructor(loadNodesAndCredentials: LoadNodesAndCredentials);
|
|
9
7
|
getWithSourcePath(nodeTypeName: string, version: number): {
|
|
10
8
|
description: INodeTypeDescription;
|
|
11
9
|
} & {
|