n8n 2.17.3 → 2.18.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/active-workflow-manager.d.ts +3 -1
- package/dist/active-workflow-manager.js +7 -4
- package/dist/active-workflow-manager.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/commands/start.js +5 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/webhook.js +7 -1
- package/dist/commands/webhook.js.map +1 -1
- package/dist/commands/worker.js +7 -1
- package/dist/commands/worker.js.map +1 -1
- package/dist/controllers/mfa.controller.d.ts +3 -1
- package/dist/controllers/mfa.controller.js +9 -2
- package/dist/controllers/mfa.controller.js.map +1 -1
- package/dist/controllers/security-settings.controller.d.ts +4 -1
- package/dist/controllers/security-settings.controller.js +10 -2
- package/dist/controllers/security-settings.controller.js.map +1 -1
- package/dist/credentials/credentials.controller.js +8 -11
- package/dist/credentials/credentials.controller.js.map +1 -1
- package/dist/credentials/credentials.service.d.ts +3 -0
- package/dist/credentials/credentials.service.js +39 -0
- package/dist/credentials/credentials.service.js.map +1 -1
- package/dist/errors/credential-not-found.error.d.ts +1 -1
- package/dist/errors/credential-not-found.error.js +3 -1
- package/dist/errors/credential-not-found.error.js.map +1 -1
- package/dist/errors/response-errors/workflow-activation-bad-request.error.d.ts +13 -0
- package/dist/errors/response-errors/workflow-activation-bad-request.error.js +13 -0
- package/dist/errors/response-errors/workflow-activation-bad-request.error.js.map +1 -0
- package/dist/errors/response-errors/workflow-validation.error.d.ts +2 -2
- package/dist/errors/response-errors/workflow-validation.error.js +2 -2
- package/dist/errors/response-errors/workflow-validation.error.js.map +1 -1
- package/dist/eventbus/event-message-classes/index.d.ts +2 -2
- package/dist/eventbus/event-message-classes/index.js +1 -0
- package/dist/eventbus/event-message-classes/index.js.map +1 -1
- package/dist/events/maps/relay.event-map.d.ts +19 -1
- package/dist/events/relays/log-streaming.event-relay.d.ts +1 -0
- package/dist/events/relays/log-streaming.event-relay.js +7 -0
- package/dist/events/relays/log-streaming.event-relay.js.map +1 -1
- package/dist/events/relays/telemetry.event-relay.d.ts +2 -0
- package/dist/events/relays/telemetry.event-relay.js +23 -2
- package/dist/events/relays/telemetry.event-relay.js.map +1 -1
- package/dist/instance-settings-loader/instance-bootstrapping.error.d.ts +3 -0
- package/dist/instance-settings-loader/instance-bootstrapping.error.js +8 -0
- package/dist/instance-settings-loader/instance-bootstrapping.error.js.map +1 -0
- package/dist/instance-settings-loader/instance-settings-loader.service.d.ts +5 -1
- package/dist/instance-settings-loader/instance-settings-loader.service.js +10 -2
- package/dist/instance-settings-loader/instance-settings-loader.service.js.map +1 -1
- package/dist/instance-settings-loader/loaders/oidc.instance-settings-loader.d.ts +13 -0
- package/dist/instance-settings-loader/loaders/oidc.instance-settings-loader.js +116 -0
- package/dist/instance-settings-loader/loaders/oidc.instance-settings-loader.js.map +1 -0
- package/dist/instance-settings-loader/loaders/owner.instance-settings-loader.js +4 -6
- package/dist/instance-settings-loader/loaders/owner.instance-settings-loader.js.map +1 -1
- package/dist/instance-settings-loader/loaders/security-policy.instance-settings-loader.d.ts +12 -0
- package/dist/instance-settings-loader/loaders/security-policy.instance-settings-loader.js +48 -0
- package/dist/instance-settings-loader/loaders/security-policy.instance-settings-loader.js.map +1 -0
- package/dist/metrics/prometheus-metrics.service.d.ts +2 -0
- package/dist/metrics/prometheus-metrics.service.js +61 -0
- package/dist/metrics/prometheus-metrics.service.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub-extractor.d.ts +2 -2
- package/dist/modules/community-packages/community-node-types.service.d.ts +1 -1
- package/dist/modules/community-packages/community-node-types.service.js +4 -1
- package/dist/modules/community-packages/community-node-types.service.js.map +1 -1
- package/dist/modules/community-packages/community-packages.config.d.ts +1 -0
- package/dist/modules/community-packages/community-packages.config.js +5 -0
- package/dist/modules/community-packages/community-packages.config.js.map +1 -1
- package/dist/modules/community-packages/community-packages.lifecycle.service.d.ts +4 -1
- package/dist/modules/community-packages/community-packages.lifecycle.service.js +42 -22
- package/dist/modules/community-packages/community-packages.lifecycle.service.js.map +1 -1
- package/dist/modules/community-packages/community-packages.service.d.ts +2 -1
- package/dist/modules/community-packages/community-packages.service.js +25 -19
- package/dist/modules/community-packages/community-packages.service.js.map +1 -1
- package/dist/modules/community-packages/npm-utils.d.ts +10 -2
- package/dist/modules/community-packages/npm-utils.js +63 -26
- package/dist/modules/community-packages/npm-utils.js.map +1 -1
- package/dist/modules/data-table/data-table.service.d.ts +3 -1
- package/dist/modules/data-table/data-table.service.js +10 -2
- package/dist/modules/data-table/data-table.service.js.map +1 -1
- package/dist/modules/encryption-key-manager/encryption-key-manager.module.d.ts +4 -0
- package/dist/modules/encryption-key-manager/encryption-key-manager.module.js +53 -0
- package/dist/modules/encryption-key-manager/encryption-key-manager.module.js.map +1 -0
- package/dist/modules/encryption-key-manager/key-manager.service.d.ts +19 -0
- package/dist/modules/encryption-key-manager/key-manager.service.js +75 -0
- package/dist/modules/encryption-key-manager/key-manager.service.js.map +1 -0
- package/dist/modules/external-secrets.ee/providers/azure-key-vault/azure-key-vault.d.ts +1 -1
- package/dist/modules/external-secrets.ee/providers/azure-key-vault/azure-key-vault.js +27 -9
- package/dist/modules/external-secrets.ee/providers/azure-key-vault/azure-key-vault.js.map +1 -1
- package/dist/modules/favorites/database/entities/user-favorite.entity.d.ts +9 -0
- package/dist/modules/favorites/database/entities/user-favorite.entity.js +43 -0
- package/dist/modules/favorites/database/entities/user-favorite.entity.js.map +1 -0
- package/dist/modules/favorites/database/repositories/user-favorite.repository.d.ts +9 -0
- package/dist/modules/favorites/database/repositories/user-favorite.repository.js +40 -0
- package/dist/modules/favorites/database/repositories/user-favorite.repository.js.map +1 -0
- package/dist/modules/favorites/dto/add-favorite.dto.d.ts +11 -0
- package/dist/modules/favorites/dto/add-favorite.dto.js +12 -0
- package/dist/modules/favorites/dto/add-favorite.dto.js.map +1 -0
- package/dist/modules/favorites/favorites.controller.d.ts +13 -0
- package/dist/modules/favorites/favorites.controller.js +68 -0
- package/dist/modules/favorites/favorites.controller.js.map +1 -0
- package/dist/modules/favorites/favorites.event-relay.d.ts +9 -0
- package/dist/modules/favorites/favorites.event-relay.js +40 -0
- package/dist/modules/favorites/favorites.event-relay.js.map +1 -0
- package/dist/modules/favorites/favorites.module.d.ts +5 -0
- package/dist/modules/favorites/favorites.module.js +60 -0
- package/dist/modules/favorites/favorites.module.js.map +1 -0
- package/dist/modules/favorites/favorites.service.d.ts +23 -0
- package/dist/modules/favorites/favorites.service.js +176 -0
- package/dist/modules/favorites/favorites.service.js.map +1 -0
- package/dist/modules/insights/database/entities/insights-shared.d.ts +1 -1
- package/dist/modules/instance-ai/filesystem/local-gateway-registry.d.ts +1 -0
- package/dist/modules/instance-ai/filesystem/local-gateway-registry.js +5 -0
- package/dist/modules/instance-ai/filesystem/local-gateway-registry.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-settings.service.d.ts +6 -2
- package/dist/modules/instance-ai/instance-ai-settings.service.js +36 -10
- package/dist/modules/instance-ai/instance-ai-settings.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-test.controller.d.ts +26 -0
- package/dist/modules/instance-ai/instance-ai-test.controller.js +102 -0
- package/dist/modules/instance-ai/instance-ai-test.controller.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai.adapter.service.js +17 -11
- package/dist/modules/instance-ai/instance-ai.adapter.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.controller.d.ts +8 -6
- package/dist/modules/instance-ai/instance-ai.controller.js +45 -22
- package/dist/modules/instance-ai/instance-ai.controller.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.module.d.ts +1 -0
- package/dist/modules/instance-ai/instance-ai.module.js +6 -0
- package/dist/modules/instance-ai/instance-ai.module.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.service.d.ts +9 -0
- package/dist/modules/instance-ai/instance-ai.service.js +81 -4
- package/dist/modules/instance-ai/instance-ai.service.js.map +1 -1
- package/dist/modules/instance-ai/trace-replay-state.d.ts +19 -0
- package/dist/modules/instance-ai/trace-replay-state.js +105 -0
- package/dist/modules/instance-ai/trace-replay-state.js.map +1 -0
- package/dist/modules/instance-registry/instance-registry.controller.d.ts +7 -0
- package/dist/modules/instance-registry/instance-registry.controller.js +39 -0
- package/dist/modules/instance-registry/instance-registry.controller.js.map +1 -0
- package/dist/modules/instance-registry/instance-registry.module.d.ts +1 -0
- package/dist/modules/instance-registry/instance-registry.module.js +60 -3
- package/dist/modules/instance-registry/instance-registry.module.js.map +1 -1
- package/dist/modules/instance-registry/instance-registry.service.d.ts +26 -0
- package/dist/modules/instance-registry/instance-registry.service.js +158 -0
- package/dist/modules/instance-registry/instance-registry.service.js.map +1 -0
- package/dist/modules/instance-registry/stale-member-cleanup.service.d.ts +16 -0
- package/dist/modules/instance-registry/stale-member-cleanup.service.js +81 -0
- package/dist/modules/instance-registry/stale-member-cleanup.service.js.map +1 -0
- package/dist/modules/instance-registry/storage/lua-scripts.d.ts +2 -2
- package/dist/modules/instance-registry/storage/lua-scripts.js +23 -9
- package/dist/modules/instance-registry/storage/lua-scripts.js.map +1 -1
- package/dist/modules/instance-registry/storage/redis-instance-storage.js +12 -12
- package/dist/modules/instance-registry/storage/redis-instance-storage.js.map +1 -1
- package/dist/modules/mcp/mcp-oauth-service.js +15 -8
- package/dist/modules/mcp/mcp-oauth-service.js.map +1 -1
- package/dist/modules/mcp/mcp.service.js +1 -1
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/tools/publish-workflow.tool.js +1 -0
- package/dist/modules/mcp/tools/publish-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/unpublish-workflow.tool.js +3 -1
- package/dist/modules/mcp/tools/unpublish-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.d.ts +2 -1
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js +49 -5
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js +10 -3
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js +7 -0
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-validation.utils.d.ts +1 -0
- package/dist/modules/mcp/tools/workflow-validation.utils.js +9 -0
- package/dist/modules/mcp/tools/workflow-validation.utils.js.map +1 -1
- package/dist/modules/otel/handlers/workflow-start.handler.js +1 -0
- package/dist/modules/otel/handlers/workflow-start.handler.js.map +1 -1
- package/dist/modules/otel/otel.constants.d.ts +1 -0
- package/dist/modules/otel/otel.constants.js +1 -0
- package/dist/modules/otel/otel.constants.js.map +1 -1
- package/dist/modules/provisioning.ee/provisioning.controller.ee.d.ts +3 -1
- package/dist/modules/provisioning.ee/provisioning.controller.ee.js +9 -2
- package/dist/modules/provisioning.ee/provisioning.controller.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-git.service.ee.d.ts +4 -1
- package/dist/modules/source-control.ee/source-control-git.service.ee.js +38 -5
- package/dist/modules/source-control.ee/source-control-git.service.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-import.service.ee.js +56 -34
- package/dist/modules/source-control.ee/source-control-import.service.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-status.service.ee.d.ts +1 -0
- package/dist/modules/source-control.ee/source-control-status.service.ee.js +55 -5
- package/dist/modules/source-control.ee/source-control-status.service.ee.js.map +1 -1
- package/dist/modules/sso-oidc/oidc.controller.ee.d.ts +3 -1
- package/dist/modules/sso-oidc/oidc.controller.ee.js +8 -2
- package/dist/modules/sso-oidc/oidc.controller.ee.js.map +1 -1
- package/dist/modules/token-exchange/controllers/embed-auth.controller.js +26 -13
- package/dist/modules/token-exchange/controllers/embed-auth.controller.js.map +1 -1
- package/dist/modules/token-exchange/controllers/token-exchange.controller.js +10 -4
- package/dist/modules/token-exchange/controllers/token-exchange.controller.js.map +1 -1
- package/dist/modules/token-exchange/services/identity-resolution.service.js +7 -6
- package/dist/modules/token-exchange/services/identity-resolution.service.js.map +1 -1
- package/dist/modules/token-exchange/services/token-exchange.service.js +11 -12
- package/dist/modules/token-exchange/services/token-exchange.service.js.map +1 -1
- package/dist/modules/token-exchange/token-exchange.errors.d.ts +11 -0
- package/dist/modules/token-exchange/token-exchange.errors.js +20 -0
- package/dist/modules/token-exchange/token-exchange.errors.js.map +1 -0
- package/dist/modules/token-exchange/token-exchange.schemas.d.ts +6 -6
- package/dist/modules/token-exchange/token-exchange.types.d.ts +15 -0
- package/dist/modules/token-exchange/token-exchange.types.js +15 -1
- package/dist/modules/token-exchange/token-exchange.types.js.map +1 -1
- package/dist/public-api/types.d.ts +8 -2
- package/dist/public-api/v1/handlers/community-packages/community-packages.handler.d.ts +1 -0
- package/dist/public-api/v1/handlers/community-packages/community-packages.handler.js +2 -1
- package/dist/public-api/v1/handlers/community-packages/community-packages.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/credentials/credentials.handler.d.ts +20 -1
- package/dist/public-api/v1/handlers/credentials/credentials.handler.js +55 -27
- package/dist/public-api/v1/handlers/credentials/credentials.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/credentials/credentials.mapper.d.ts +6 -0
- package/dist/public-api/v1/handlers/credentials/credentials.mapper.js +19 -0
- package/dist/public-api/v1/handlers/credentials/credentials.mapper.js.map +1 -0
- package/dist/public-api/v1/handlers/credentials/credentials.service.d.ts +3 -2
- package/dist/public-api/v1/handlers/credentials/credentials.service.js +2 -6
- package/dist/public-api/v1/handlers/credentials/credentials.service.js.map +1 -1
- package/dist/public-api/v1/handlers/data-tables/data-tables.handler.js +23 -41
- package/dist/public-api/v1/handlers/data-tables/data-tables.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/data-tables/data-tables.service.d.ts +5 -0
- package/dist/public-api/v1/handlers/data-tables/data-tables.service.js +57 -0
- package/dist/public-api/v1/handlers/data-tables/data-tables.service.js.map +1 -0
- package/dist/public-api/v1/handlers/workflows/workflows.handler.js +8 -2
- package/dist/public-api/v1/handlers/workflows/workflows.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/workflows/workflows.service.js +1 -0
- package/dist/public-api/v1/handlers/workflows/workflows.service.js.map +1 -1
- package/dist/public-api/v1/openapi.yml +102 -11
- package/dist/scaling/pubsub/pubsub.event-map.d.ts +2 -0
- package/dist/services/dynamic-node-parameters.service.d.ts +4 -1
- package/dist/services/dynamic-node-parameters.service.js +29 -14
- package/dist/services/dynamic-node-parameters.service.js.map +1 -1
- package/dist/services/folder.service.d.ts +3 -1
- package/dist/services/folder.service.js +8 -4
- package/dist/services/folder.service.js.map +1 -1
- package/dist/services/frontend.service.js +1 -0
- package/dist/services/frontend.service.js.map +1 -1
- package/dist/services/jwt.service.d.ts +13 -1
- package/dist/services/jwt.service.js +21 -1
- package/dist/services/jwt.service.js.map +1 -1
- package/dist/services/project.service.ee.js +3 -1
- package/dist/services/project.service.ee.js.map +1 -1
- package/dist/wait-tracker.d.ts +2 -6
- package/dist/wait-tracker.js +63 -94
- package/dist/wait-tracker.js.map +1 -1
- package/dist/workflows/utils.d.ts +2 -0
- package/dist/workflows/utils.js +18 -0
- package/dist/workflows/utils.js.map +1 -0
- package/dist/workflows/workflow-creation.service.d.ts +2 -0
- package/dist/workflows/workflow-creation.service.js +2 -1
- package/dist/workflows/workflow-creation.service.js.map +1 -1
- package/dist/workflows/workflow.service.d.ts +5 -2
- package/dist/workflows/workflow.service.js +26 -11
- package/dist/workflows/workflow.service.js.map +1 -1
- package/package.json +24 -24
- package/dist/services/db-clock.service.d.ts +0 -10
- package/dist/services/db-clock.service.js +0 -48
- package/dist/services/db-clock.service.js.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
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.UserFavorite = void 0;
|
|
13
|
+
const db_1 = require("@n8n/db");
|
|
14
|
+
const typeorm_1 = require("@n8n/typeorm");
|
|
15
|
+
let UserFavorite = class UserFavorite {
|
|
16
|
+
};
|
|
17
|
+
exports.UserFavorite = UserFavorite;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], UserFavorite.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.ManyToOne)(() => db_1.User, { onDelete: 'CASCADE' }),
|
|
24
|
+
__metadata("design:type", db_1.User)
|
|
25
|
+
], UserFavorite.prototype, "user", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ type: String }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], UserFavorite.prototype, "userId", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ type: String }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], UserFavorite.prototype, "resourceId", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ type: String }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], UserFavorite.prototype, "resourceType", void 0);
|
|
38
|
+
exports.UserFavorite = UserFavorite = __decorate([
|
|
39
|
+
(0, typeorm_1.Entity)('user_favorites'),
|
|
40
|
+
(0, typeorm_1.Unique)(['userId', 'resourceId', 'resourceType']),
|
|
41
|
+
(0, typeorm_1.Index)(['userId'])
|
|
42
|
+
], UserFavorite);
|
|
43
|
+
//# sourceMappingURL=user-favorite.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-favorite.entity.js","sourceRoot":"","sources":["../../../../../src/modules/favorites/database/entities/user-favorite.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gCAA+B;AAC/B,0CAAgG;AAKzF,IAAM,YAAY,GAAlB,MAAM,YAAY;CAexB,CAAA;AAfY,oCAAY;AAExB;IADC,IAAA,gCAAsB,GAAE;;wCACd;AAGX;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,SAAI,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;8BACzC,SAAI;0CAAC;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACV;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACN;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDACU;uBAdvB,YAAY;IAHxB,IAAA,gBAAM,EAAC,gBAAgB,CAAC;IACxB,IAAA,gBAAM,EAAC,CAAC,QAAQ,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;IAChD,IAAA,eAAK,EAAC,CAAC,QAAQ,CAAC,CAAC;GACL,YAAY,CAexB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FavoriteResourceType } from '@n8n/api-types';
|
|
2
|
+
import { DataSource, Repository } from '@n8n/typeorm';
|
|
3
|
+
import { UserFavorite } from '../entities/user-favorite.entity';
|
|
4
|
+
export declare class UserFavoriteRepository extends Repository<UserFavorite> {
|
|
5
|
+
constructor(dataSource: DataSource);
|
|
6
|
+
findByUser(userId: string): Promise<UserFavorite[]>;
|
|
7
|
+
deleteByResourceId(resourceId: string, resourceType: FavoriteResourceType): Promise<void>;
|
|
8
|
+
deleteByResourceIds(resourceIds: string[], resourceType: FavoriteResourceType): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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.UserFavoriteRepository = void 0;
|
|
13
|
+
const di_1 = require("@n8n/di");
|
|
14
|
+
const typeorm_1 = require("@n8n/typeorm");
|
|
15
|
+
const user_favorite_entity_1 = require("../entities/user-favorite.entity");
|
|
16
|
+
let UserFavoriteRepository = class UserFavoriteRepository extends typeorm_1.Repository {
|
|
17
|
+
constructor(dataSource) {
|
|
18
|
+
super(user_favorite_entity_1.UserFavorite, dataSource.manager);
|
|
19
|
+
}
|
|
20
|
+
async findByUser(userId) {
|
|
21
|
+
return await this.find({
|
|
22
|
+
where: { userId },
|
|
23
|
+
order: { id: 'DESC' },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async deleteByResourceId(resourceId, resourceType) {
|
|
27
|
+
await this.delete({ resourceId, resourceType });
|
|
28
|
+
}
|
|
29
|
+
async deleteByResourceIds(resourceIds, resourceType) {
|
|
30
|
+
if (resourceIds.length === 0)
|
|
31
|
+
return;
|
|
32
|
+
await this.delete({ resourceId: (0, typeorm_1.In)(resourceIds), resourceType });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.UserFavoriteRepository = UserFavoriteRepository;
|
|
36
|
+
exports.UserFavoriteRepository = UserFavoriteRepository = __decorate([
|
|
37
|
+
(0, di_1.Service)(),
|
|
38
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
39
|
+
], UserFavoriteRepository);
|
|
40
|
+
//# sourceMappingURL=user-favorite.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-favorite.repository.js","sourceRoot":"","sources":["../../../../../src/modules/favorites/database/repositories/user-favorite.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gCAAkC;AAClC,0CAA0D;AAE1D,2EAAgE;AAGzD,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,oBAAwB;IACnE,YAAY,UAAsB;QACjC,KAAK,CAAC,mCAAY,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAc;QAC9B,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC;YACtB,KAAK,EAAE,EAAE,MAAM,EAAE;YACjB,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;SACrB,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,UAAkB,EAAE,YAAkC;QAC9E,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,mBAAmB,CACxB,WAAqB,EACrB,YAAkC;QAElC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACrC,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,IAAA,YAAE,EAAC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;IAClE,CAAC;CACD,CAAA;AAvBY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,YAAO,GAAE;qCAEe,oBAAU;GADtB,sBAAsB,CAuBlC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const AddFavoriteDto_base: import("@n8n/api-types").ZodClass<{
|
|
3
|
+
resourceId: string;
|
|
4
|
+
resourceType: "project" | "workflow" | "folder" | "dataTable";
|
|
5
|
+
}, {
|
|
6
|
+
resourceId: z.ZodString;
|
|
7
|
+
resourceType: z.ZodEnum<["workflow", "project", "dataTable", "folder"]>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare class AddFavoriteDto extends AddFavoriteDto_base {
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddFavoriteDto = void 0;
|
|
4
|
+
const api_types_1 = require("@n8n/api-types");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
class AddFavoriteDto extends api_types_1.Z.class({
|
|
7
|
+
resourceId: zod_1.z.string(),
|
|
8
|
+
resourceType: zod_1.z.enum(api_types_1.FAVORITE_RESOURCE_TYPES),
|
|
9
|
+
}) {
|
|
10
|
+
}
|
|
11
|
+
exports.AddFavoriteDto = AddFavoriteDto;
|
|
12
|
+
//# sourceMappingURL=add-favorite.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-favorite.dto.js","sourceRoot":"","sources":["../../../../src/modules/favorites/dto/add-favorite.dto.ts"],"names":[],"mappings":";;;AAAA,8CAA4D;AAC5D,6BAAwB;AAExB,MAAa,cAAe,SAAQ,aAAC,CAAC,KAAK,CAAC;IAC3C,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;IACtB,YAAY,EAAE,OAAC,CAAC,IAAI,CAAC,mCAAuB,CAAC;CAC7C,CAAC;CAAG;AAHL,wCAGK"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AuthenticatedRequest } from '@n8n/db';
|
|
2
|
+
import { FavoritesService } from './favorites.service';
|
|
3
|
+
import { AddFavoriteDto } from './dto/add-favorite.dto';
|
|
4
|
+
export declare class FavoritesController {
|
|
5
|
+
private readonly favoritesService;
|
|
6
|
+
constructor(favoritesService: FavoritesService);
|
|
7
|
+
getFavorites(req: AuthenticatedRequest): Promise<(import("./database/entities/user-favorite.entity").UserFavorite & {
|
|
8
|
+
resourceName: string;
|
|
9
|
+
resourceProjectId?: string;
|
|
10
|
+
})[]>;
|
|
11
|
+
addFavorite(req: AuthenticatedRequest, _res: unknown, body: AddFavoriteDto): Promise<import("./database/entities/user-favorite.entity").UserFavorite>;
|
|
12
|
+
removeFavorite(req: AuthenticatedRequest, _res: unknown, resourceId: string, resourceType: string): Promise<boolean>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FavoritesController = void 0;
|
|
16
|
+
const decorators_1 = require("@n8n/decorators");
|
|
17
|
+
const api_types_1 = require("@n8n/api-types");
|
|
18
|
+
const bad_request_error_1 = require("../../errors/response-errors/bad-request.error");
|
|
19
|
+
const favorites_service_1 = require("./favorites.service");
|
|
20
|
+
const add_favorite_dto_1 = require("./dto/add-favorite.dto");
|
|
21
|
+
function isFavoriteResourceType(value) {
|
|
22
|
+
return api_types_1.FAVORITE_RESOURCE_TYPES.includes(value);
|
|
23
|
+
}
|
|
24
|
+
let FavoritesController = class FavoritesController {
|
|
25
|
+
constructor(favoritesService) {
|
|
26
|
+
this.favoritesService = favoritesService;
|
|
27
|
+
}
|
|
28
|
+
async getFavorites(req) {
|
|
29
|
+
return await this.favoritesService.getEnrichedFavorites(req.user.id);
|
|
30
|
+
}
|
|
31
|
+
async addFavorite(req, _res, body) {
|
|
32
|
+
return await this.favoritesService.addFavorite(req.user.id, body.resourceId, body.resourceType);
|
|
33
|
+
}
|
|
34
|
+
async removeFavorite(req, _res, resourceId, resourceType) {
|
|
35
|
+
if (!isFavoriteResourceType(resourceType)) {
|
|
36
|
+
throw new bad_request_error_1.BadRequestError(`Invalid resourceType: ${resourceType}`);
|
|
37
|
+
}
|
|
38
|
+
await this.favoritesService.removeFavorite(req.user.id, resourceId, resourceType);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.FavoritesController = FavoritesController;
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, decorators_1.Get)('/'),
|
|
45
|
+
__metadata("design:type", Function),
|
|
46
|
+
__metadata("design:paramtypes", [Object]),
|
|
47
|
+
__metadata("design:returntype", Promise)
|
|
48
|
+
], FavoritesController.prototype, "getFavorites", null);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, decorators_1.Post)('/'),
|
|
51
|
+
__param(2, decorators_1.Body),
|
|
52
|
+
__metadata("design:type", Function),
|
|
53
|
+
__metadata("design:paramtypes", [Object, Object, add_favorite_dto_1.AddFavoriteDto]),
|
|
54
|
+
__metadata("design:returntype", Promise)
|
|
55
|
+
], FavoritesController.prototype, "addFavorite", null);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, decorators_1.Delete)('/:resourceType/:resourceId'),
|
|
58
|
+
__param(2, (0, decorators_1.Param)('resourceId')),
|
|
59
|
+
__param(3, (0, decorators_1.Param)('resourceType')),
|
|
60
|
+
__metadata("design:type", Function),
|
|
61
|
+
__metadata("design:paramtypes", [Object, Object, String, String]),
|
|
62
|
+
__metadata("design:returntype", Promise)
|
|
63
|
+
], FavoritesController.prototype, "removeFavorite", null);
|
|
64
|
+
exports.FavoritesController = FavoritesController = __decorate([
|
|
65
|
+
(0, decorators_1.RestController)('/favorites'),
|
|
66
|
+
__metadata("design:paramtypes", [favorites_service_1.FavoritesService])
|
|
67
|
+
], FavoritesController);
|
|
68
|
+
//# sourceMappingURL=favorites.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"favorites.controller.js","sourceRoot":"","sources":["../../../src/modules/favorites/favorites.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,gDAAiF;AACjF,8CAAoF;AAEpF,kFAA6E;AAE7E,2DAAuD;AACvD,6DAAwD;AAExD,SAAS,sBAAsB,CAAC,KAAa;IAC5C,OAAQ,mCAA6C,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAGM,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC/B,YAA6B,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAG7D,A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relay';
|
|
2
|
+
import { EventService } from '../../events/event.service';
|
|
3
|
+
import { FavoritesService } from './favorites.service';
|
|
4
|
+
export declare class FavoritesEventRelay extends EventRelay {
|
|
5
|
+
readonly eventService: EventService;
|
|
6
|
+
private readonly favoritesService;
|
|
7
|
+
constructor(eventService: EventService, favoritesService: FavoritesService);
|
|
8
|
+
init(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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.FavoritesEventRelay = void 0;
|
|
13
|
+
const di_1 = require("@n8n/di");
|
|
14
|
+
const event_relay_1 = require("../../events/relays/event-relay");
|
|
15
|
+
const event_service_1 = require("../../events/event.service");
|
|
16
|
+
const favorites_service_1 = require("./favorites.service");
|
|
17
|
+
let FavoritesEventRelay = class FavoritesEventRelay extends event_relay_1.EventRelay {
|
|
18
|
+
constructor(eventService, favoritesService) {
|
|
19
|
+
super(eventService);
|
|
20
|
+
this.eventService = eventService;
|
|
21
|
+
this.favoritesService = favoritesService;
|
|
22
|
+
}
|
|
23
|
+
init() {
|
|
24
|
+
this.setupListeners({
|
|
25
|
+
'workflow-deleted': async ({ workflowId }) => await this.favoritesService.deleteByResource(workflowId, 'workflow'),
|
|
26
|
+
'data-table-deleted': async ({ dataTableId }) => await this.favoritesService.deleteByResource(dataTableId, 'dataTable'),
|
|
27
|
+
'folder-deleted': async ({ folderId }) => await this.favoritesService.deleteByResource(folderId, 'folder'),
|
|
28
|
+
'team-project-deleted': async ({ projectId }) => {
|
|
29
|
+
await this.favoritesService.deleteByResource(projectId, 'project');
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.FavoritesEventRelay = FavoritesEventRelay;
|
|
35
|
+
exports.FavoritesEventRelay = FavoritesEventRelay = __decorate([
|
|
36
|
+
(0, di_1.Service)(),
|
|
37
|
+
__metadata("design:paramtypes", [event_service_1.EventService,
|
|
38
|
+
favorites_service_1.FavoritesService])
|
|
39
|
+
], FavoritesEventRelay);
|
|
40
|
+
//# sourceMappingURL=favorites.event-relay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"favorites.event-relay.js","sourceRoot":"","sources":["../../../src/modules/favorites/favorites.event-relay.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gCAAkC;AAElC,6DAAyD;AACzD,0DAAsD;AAEtD,2DAAuD;AAGhD,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,wBAAU;IAClD,YACU,YAA0B,EAClB,gBAAkC;QAEnD,KAAK,CAAC,YAAY,CAAC,CAAC;QAHX,iBAAY,GAAZ,YAAY,CAAc;QAClB,qBAAgB,GAAhB,gBAAgB,CAAkB;IAGpD,CAAC;IAED,IAAI;QACH,IAAI,CAAC,cAAc,CAAC;YACnB,kBAAkB,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAC5C,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC;YACrE,oBAAoB,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAC/C,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC;YACvE,gBAAgB,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CACxC,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC;YACjE,sBAAsB,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;gBAC/C,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACpE,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;CACD,CAAA;AArBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,YAAO,GAAE;qCAGe,4BAAY;QACA,oCAAgB;GAHxC,mBAAmB,CAqB/B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.FavoritesModule = void 0;
|
|
43
|
+
const decorators_1 = require("@n8n/decorators");
|
|
44
|
+
const di_1 = require("@n8n/di");
|
|
45
|
+
let FavoritesModule = class FavoritesModule {
|
|
46
|
+
async init() {
|
|
47
|
+
await Promise.resolve().then(() => __importStar(require('./favorites.controller')));
|
|
48
|
+
const { FavoritesEventRelay } = await Promise.resolve().then(() => __importStar(require('./favorites.event-relay')));
|
|
49
|
+
di_1.Container.get(FavoritesEventRelay).init();
|
|
50
|
+
}
|
|
51
|
+
async entities() {
|
|
52
|
+
const { UserFavorite } = await Promise.resolve().then(() => __importStar(require('./database/entities/user-favorite.entity')));
|
|
53
|
+
return [UserFavorite];
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.FavoritesModule = FavoritesModule;
|
|
57
|
+
exports.FavoritesModule = FavoritesModule = __decorate([
|
|
58
|
+
(0, decorators_1.BackendModule)({ name: 'favorites', instanceTypes: ['main'] })
|
|
59
|
+
], FavoritesModule);
|
|
60
|
+
//# sourceMappingURL=favorites.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"favorites.module.js","sourceRoot":"","sources":["../../../src/modules/favorites/favorites.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAAgD;AAChD,gCAAoC;AAG7B,IAAM,eAAe,GAArB,MAAM,eAAe;IAC3B,KAAK,CAAC,IAAI;QACT,wDAAa,wBAAwB,GAAC,CAAC;QAEvC,MAAM,EAAE,mBAAmB,EAAE,GAAG,wDAAa,yBAAyB,GAAC,CAAC;QACxE,cAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,QAAQ;QACb,MAAM,EAAE,YAAY,EAAE,GAAG,wDAAa,0CAA0C,GAAC,CAAC;QAClF,OAAO,CAAC,YAAY,CAAU,CAAC;IAChC,CAAC;CACD,CAAA;AAZY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,0BAAa,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;GACjD,eAAe,CAY3B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FolderRepository, ProjectRepository, SharedWorkflowRepository, WorkflowRepository } from '@n8n/db';
|
|
2
|
+
import { UserFavoriteRepository } from './database/repositories/user-favorite.repository';
|
|
3
|
+
import { DataTableRepository } from '../../modules/data-table/data-table.repository';
|
|
4
|
+
import type { FavoriteResourceType } from '@n8n/api-types';
|
|
5
|
+
export declare class FavoritesService {
|
|
6
|
+
private readonly userFavoriteRepository;
|
|
7
|
+
private readonly workflowRepository;
|
|
8
|
+
private readonly projectRepository;
|
|
9
|
+
private readonly sharedWorkflowRepository;
|
|
10
|
+
private readonly dataTableRepository;
|
|
11
|
+
private readonly folderRepository;
|
|
12
|
+
private readonly MAX_FAVORITES;
|
|
13
|
+
constructor(userFavoriteRepository: UserFavoriteRepository, workflowRepository: WorkflowRepository, projectRepository: ProjectRepository, sharedWorkflowRepository: SharedWorkflowRepository, dataTableRepository: DataTableRepository, folderRepository: FolderRepository);
|
|
14
|
+
getEnrichedFavorites(userId: string): Promise<(import("./database/entities/user-favorite.entity").UserFavorite & {
|
|
15
|
+
resourceName: string;
|
|
16
|
+
resourceProjectId?: string;
|
|
17
|
+
})[]>;
|
|
18
|
+
addFavorite(userId: string, resourceId: string, resourceType: FavoriteResourceType): Promise<import("./database/entities/user-favorite.entity").UserFavorite>;
|
|
19
|
+
private assertResourceExists;
|
|
20
|
+
removeFavorite(userId: string, resourceId: string, resourceType: FavoriteResourceType): Promise<void>;
|
|
21
|
+
deleteByResource(resourceId: string, resourceType: FavoriteResourceType): Promise<void>;
|
|
22
|
+
deleteByResourceIds(resourceIds: string[], resourceType: FavoriteResourceType): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
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.FavoritesService = void 0;
|
|
13
|
+
const di_1 = require("@n8n/di");
|
|
14
|
+
const db_1 = require("@n8n/db");
|
|
15
|
+
const typeorm_1 = require("@n8n/typeorm");
|
|
16
|
+
const user_favorite_repository_1 = require("./database/repositories/user-favorite.repository");
|
|
17
|
+
const bad_request_error_1 = require("../../errors/response-errors/bad-request.error");
|
|
18
|
+
const not_found_error_1 = require("../../errors/response-errors/not-found.error");
|
|
19
|
+
const data_table_repository_1 = require("../../modules/data-table/data-table.repository");
|
|
20
|
+
let FavoritesService = class FavoritesService {
|
|
21
|
+
constructor(userFavoriteRepository, workflowRepository, projectRepository, sharedWorkflowRepository, dataTableRepository, folderRepository) {
|
|
22
|
+
this.userFavoriteRepository = userFavoriteRepository;
|
|
23
|
+
this.workflowRepository = workflowRepository;
|
|
24
|
+
this.projectRepository = projectRepository;
|
|
25
|
+
this.sharedWorkflowRepository = sharedWorkflowRepository;
|
|
26
|
+
this.dataTableRepository = dataTableRepository;
|
|
27
|
+
this.folderRepository = folderRepository;
|
|
28
|
+
this.MAX_FAVORITES = 200;
|
|
29
|
+
}
|
|
30
|
+
async getEnrichedFavorites(userId) {
|
|
31
|
+
const favorites = await this.userFavoriteRepository.findByUser(userId);
|
|
32
|
+
if (favorites.length === 0)
|
|
33
|
+
return [];
|
|
34
|
+
const workflowIds = favorites
|
|
35
|
+
.filter((f) => f.resourceType === 'workflow')
|
|
36
|
+
.map((f) => f.resourceId);
|
|
37
|
+
const dataTableIds = favorites
|
|
38
|
+
.filter((f) => f.resourceType === 'dataTable')
|
|
39
|
+
.map((f) => f.resourceId);
|
|
40
|
+
const folderIds = favorites.filter((f) => f.resourceType === 'folder').map((f) => f.resourceId);
|
|
41
|
+
const accessibleProjects = await this.projectRepository.getAccessibleProjects(userId);
|
|
42
|
+
const accessibleProjectIds = new Set(accessibleProjects.map((p) => p.id));
|
|
43
|
+
const projectNameMap = new Map(accessibleProjects.map((p) => [p.id, p.name ?? '']));
|
|
44
|
+
const [workflows, sharedWorkflows, dataTables, folders] = await Promise.all([
|
|
45
|
+
workflowIds.length > 0 && accessibleProjectIds.size > 0
|
|
46
|
+
? this.workflowRepository.findByIds(workflowIds, { fields: ['id', 'name'] })
|
|
47
|
+
: [],
|
|
48
|
+
workflowIds.length > 0 && accessibleProjectIds.size > 0
|
|
49
|
+
? this.sharedWorkflowRepository.find({
|
|
50
|
+
select: { workflowId: true },
|
|
51
|
+
where: { workflowId: (0, typeorm_1.In)(workflowIds), projectId: (0, typeorm_1.In)([...accessibleProjectIds]) },
|
|
52
|
+
})
|
|
53
|
+
: [],
|
|
54
|
+
dataTableIds.length > 0
|
|
55
|
+
? this.dataTableRepository.find({ where: { id: (0, typeorm_1.In)(dataTableIds) } })
|
|
56
|
+
: [],
|
|
57
|
+
folderIds.length > 0
|
|
58
|
+
? this.folderRepository.find({
|
|
59
|
+
where: { id: (0, typeorm_1.In)(folderIds) },
|
|
60
|
+
relations: { homeProject: true },
|
|
61
|
+
})
|
|
62
|
+
: [],
|
|
63
|
+
]);
|
|
64
|
+
const workflowNameMap = new Map();
|
|
65
|
+
if (workflowIds.length > 0 && accessibleProjectIds.size > 0) {
|
|
66
|
+
const wfMap = new Map(workflows.map((wf) => [wf.id, wf.name]));
|
|
67
|
+
const accessibleWfIds = new Set(sharedWorkflows.map((sw) => sw.workflowId));
|
|
68
|
+
for (const id of workflowIds) {
|
|
69
|
+
const name = wfMap.get(id);
|
|
70
|
+
if (accessibleWfIds.has(id) && name !== undefined) {
|
|
71
|
+
workflowNameMap.set(id, name);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const dataTableMetaMap = new Map();
|
|
76
|
+
for (const dt of dataTables) {
|
|
77
|
+
if (accessibleProjectIds.has(dt.projectId)) {
|
|
78
|
+
dataTableMetaMap.set(dt.id, { name: dt.name, projectId: dt.projectId });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const folderMetaMap = new Map();
|
|
82
|
+
for (const folder of folders) {
|
|
83
|
+
const projectId = folder.homeProject?.id;
|
|
84
|
+
if (projectId && accessibleProjectIds.has(projectId)) {
|
|
85
|
+
folderMetaMap.set(folder.id, { name: folder.name, projectId });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const enriched = [];
|
|
89
|
+
for (const fav of favorites) {
|
|
90
|
+
if (fav.resourceType === 'workflow') {
|
|
91
|
+
const name = workflowNameMap.get(fav.resourceId);
|
|
92
|
+
if (name !== undefined)
|
|
93
|
+
enriched.push({ ...fav, resourceName: name });
|
|
94
|
+
}
|
|
95
|
+
else if (fav.resourceType === 'project') {
|
|
96
|
+
const name = projectNameMap.get(fav.resourceId);
|
|
97
|
+
if (name !== undefined) {
|
|
98
|
+
enriched.push({ ...fav, resourceName: name });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (fav.resourceType === 'dataTable') {
|
|
102
|
+
const meta = dataTableMetaMap.get(fav.resourceId);
|
|
103
|
+
if (meta !== undefined) {
|
|
104
|
+
enriched.push({ ...fav, resourceName: meta.name, resourceProjectId: meta.projectId });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (fav.resourceType === 'folder') {
|
|
108
|
+
const meta = folderMetaMap.get(fav.resourceId);
|
|
109
|
+
if (meta !== undefined) {
|
|
110
|
+
enriched.push({ ...fav, resourceName: meta.name, resourceProjectId: meta.projectId });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return enriched;
|
|
115
|
+
}
|
|
116
|
+
async addFavorite(userId, resourceId, resourceType) {
|
|
117
|
+
const existing = await this.userFavoriteRepository.findOne({
|
|
118
|
+
where: { userId, resourceId, resourceType },
|
|
119
|
+
});
|
|
120
|
+
if (existing)
|
|
121
|
+
return existing;
|
|
122
|
+
await this.assertResourceExists(resourceId, resourceType);
|
|
123
|
+
const count = await this.userFavoriteRepository.count({ where: { userId } });
|
|
124
|
+
if (count >= this.MAX_FAVORITES) {
|
|
125
|
+
throw new bad_request_error_1.BadRequestError(`Favorites limit of ${this.MAX_FAVORITES} reached`);
|
|
126
|
+
}
|
|
127
|
+
const favorite = this.userFavoriteRepository.create({ userId, resourceId, resourceType });
|
|
128
|
+
return await this.userFavoriteRepository.save(favorite);
|
|
129
|
+
}
|
|
130
|
+
async assertResourceExists(resourceId, resourceType) {
|
|
131
|
+
let exists;
|
|
132
|
+
switch (resourceType) {
|
|
133
|
+
case 'workflow':
|
|
134
|
+
exists = await this.workflowRepository.existsBy({ id: resourceId });
|
|
135
|
+
break;
|
|
136
|
+
case 'project':
|
|
137
|
+
exists = await this.projectRepository.existsBy({ id: resourceId });
|
|
138
|
+
break;
|
|
139
|
+
case 'dataTable':
|
|
140
|
+
exists = await this.dataTableRepository.existsBy({ id: resourceId });
|
|
141
|
+
break;
|
|
142
|
+
case 'folder':
|
|
143
|
+
exists = await this.folderRepository.existsBy({ id: resourceId });
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
if (!exists) {
|
|
147
|
+
throw new not_found_error_1.NotFoundError(`${resourceType} with id "${resourceId}" not found`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async removeFavorite(userId, resourceId, resourceType) {
|
|
151
|
+
const favorite = await this.userFavoriteRepository.findOne({
|
|
152
|
+
where: { userId, resourceId, resourceType },
|
|
153
|
+
});
|
|
154
|
+
if (!favorite) {
|
|
155
|
+
throw new not_found_error_1.NotFoundError('Favorite not found');
|
|
156
|
+
}
|
|
157
|
+
await this.userFavoriteRepository.remove(favorite);
|
|
158
|
+
}
|
|
159
|
+
async deleteByResource(resourceId, resourceType) {
|
|
160
|
+
await this.userFavoriteRepository.deleteByResourceId(resourceId, resourceType);
|
|
161
|
+
}
|
|
162
|
+
async deleteByResourceIds(resourceIds, resourceType) {
|
|
163
|
+
await this.userFavoriteRepository.deleteByResourceIds(resourceIds, resourceType);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
exports.FavoritesService = FavoritesService;
|
|
167
|
+
exports.FavoritesService = FavoritesService = __decorate([
|
|
168
|
+
(0, di_1.Service)(),
|
|
169
|
+
__metadata("design:paramtypes", [user_favorite_repository_1.UserFavoriteRepository,
|
|
170
|
+
db_1.WorkflowRepository,
|
|
171
|
+
db_1.ProjectRepository,
|
|
172
|
+
db_1.SharedWorkflowRepository,
|
|
173
|
+
data_table_repository_1.DataTableRepository,
|
|
174
|
+
db_1.FolderRepository])
|
|
175
|
+
], FavoritesService);
|
|
176
|
+
//# sourceMappingURL=favorites.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"favorites.service.js","sourceRoot":"","sources":["../../../src/modules/favorites/favorites.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gCAAkC;AAClC,gCAKiB;AACjB,0CAAkC;AAElC,+FAA0F;AAE1F,kFAA6E;AAC7E,8EAAyE;AACzE,sFAAiF;AAK1E,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAE5B,YACkB,sBAA8C,EAC9C,kBAAsC,EACtC,iBAAoC,EACpC,wBAAkD,EAClD,mBAAwC,EACxC,gBAAkC;QALlC,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,6BAAwB,GAAxB,wBAAwB,CAA0B;QAClD,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAPnC,kBAAa,GAAG,GAAG,CAAC;IAQlC,CAAC;IAEJ,KAAK,CAAC,oBAAoB,CAAC,MAAc;QACxC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,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IAClF,CAAC;CACD,CAAA;AAhLY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,YAAO,GAAE;qCAIiC,iDAAsB;QAC1B,uBAAkB;QACnB,sBAAiB;QACV,6BAAwB;QAC7B,2CAAmB;QACtB,qBAAgB;GARxC,gBAAgB,CAgL5B"}
|
|
@@ -15,5 +15,5 @@ export declare const TypeToNumber: {
|
|
|
15
15
|
};
|
|
16
16
|
export type TypeUnit = keyof typeof TypeToNumber;
|
|
17
17
|
export type TypeUnitNumber = (typeof TypeToNumber)[TypeUnit];
|
|
18
|
-
export declare const NumberToType: Record<TypeUnitNumber, "success" | "
|
|
18
|
+
export declare const NumberToType: Record<TypeUnitNumber, "success" | "failure" | "time_saved_min" | "runtime_ms">;
|
|
19
19
|
export declare function isValidTypeNumber(value: number): value is TypeUnitNumber;
|
|
@@ -123,6 +123,11 @@ class LocalGatewayRegistry {
|
|
|
123
123
|
clearTimeout(state.disconnectTimer);
|
|
124
124
|
state.disconnectTimer = null;
|
|
125
125
|
}
|
|
126
|
+
getConnectedUserIds() {
|
|
127
|
+
return [...this.userGateways.entries()]
|
|
128
|
+
.filter(([, state]) => state.gateway.getStatus().connected)
|
|
129
|
+
.map(([userId]) => userId);
|
|
130
|
+
}
|
|
126
131
|
disconnectAll() {
|
|
127
132
|
for (const state of this.userGateways.values()) {
|
|
128
133
|
if (state.disconnectTimer)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-gateway-registry.js","sourceRoot":"","sources":["../../../../src/modules/instance-ai/filesystem/local-gateway-registry.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAQhC,mDAA+C;AAU/C,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,YAAY,GAAG,OAAO,CAAC;AAC7B,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAO3C,MAAa,oBAAoB;IAAjC;QACkB,iBAAY,GAAG,IAAI,GAAG,EAA4B,CAAC;QAGnD,mBAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"local-gateway-registry.js","sourceRoot":"","sources":["../../../../src/modules/instance-ai/filesystem/local-gateway-registry.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAQhC,mDAA+C;AAU/C,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,YAAY,GAAG,OAAO,CAAC;AAC7B,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAO3C,MAAa,oBAAoB;IAAjC;QACkB,iBAAY,GAAG,IAAI,GAAG,EAA4B,CAAC;QAGnD,mBAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IAuL7D,CAAC;IApLQ,iBAAiB,CAAC,MAAc;QACvC,IAAI,GAAW,CAAC;QAChB,GAAG,CAAC;YACH,GAAG,GAAG,GAAG,MAAM,IAAI,IAAA,eAAM,EAAC,EAAE,CAAC,EAAE,CAAC;QACjC,CAAC,QAAQ,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACvC,OAAO,GAAG,CAAC;IACZ,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE;gBAC7B,OAAO,EAAE,IAAI,4BAAY,EAAE;gBAC3B,YAAY,EAAE,IAAI;gBAClB,gBAAgB,EAAE,IAAI;gBACtB,eAAe,EAAE,IAAI;gBACrB,cAAc,EAAE,CAAC;aACjB,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;IACvC,CAAC;IAGD,kBAAkB,CAAC,GAAW;QAC7B,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAG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