@intranefr/superbackend 1.4.3
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/.commiat +4 -0
- package/.env.example +47 -0
- package/README.md +110 -0
- package/index.js +94 -0
- package/package.json +67 -0
- package/public/css/styles.css +139 -0
- package/public/js/animations.js +41 -0
- package/sdk/error-tracking/browser/package.json +16 -0
- package/sdk/error-tracking/browser/src/core.js +270 -0
- package/sdk/error-tracking/browser/src/embed.js +18 -0
- package/sdk/error-tracking/browser/src/index.js +1 -0
- package/server.js +5 -0
- package/src/admin/endpointRegistry.js +300 -0
- package/src/controllers/admin.controller.js +321 -0
- package/src/controllers/adminAssets.controller.js +530 -0
- package/src/controllers/adminAssetsStorage.controller.js +260 -0
- package/src/controllers/adminEjsVirtual.controller.js +354 -0
- package/src/controllers/adminFeatureFlags.controller.js +155 -0
- package/src/controllers/adminHeadless.controller.js +1071 -0
- package/src/controllers/adminI18n.controller.js +604 -0
- package/src/controllers/adminJsonConfigs.controller.js +97 -0
- package/src/controllers/adminLlm.controller.js +273 -0
- package/src/controllers/adminMigration.controller.js +257 -0
- package/src/controllers/adminSeoConfig.controller.js +515 -0
- package/src/controllers/adminStats.controller.js +121 -0
- package/src/controllers/adminUploadNamespaces.controller.js +208 -0
- package/src/controllers/assets.controller.js +248 -0
- package/src/controllers/auth.controller.js +93 -0
- package/src/controllers/billing.controller.js +223 -0
- package/src/controllers/featureFlags.controller.js +35 -0
- package/src/controllers/forms.controller.js +217 -0
- package/src/controllers/globalSettings.controller.js +252 -0
- package/src/controllers/headlessCrud.controller.js +126 -0
- package/src/controllers/i18n.controller.js +12 -0
- package/src/controllers/invite.controller.js +249 -0
- package/src/controllers/jsonConfigs.controller.js +19 -0
- package/src/controllers/metrics.controller.js +149 -0
- package/src/controllers/notificationAdmin.controller.js +264 -0
- package/src/controllers/notifications.controller.js +131 -0
- package/src/controllers/org.controller.js +357 -0
- package/src/controllers/orgAdmin.controller.js +491 -0
- package/src/controllers/stripeAdmin.controller.js +410 -0
- package/src/controllers/user.controller.js +361 -0
- package/src/controllers/userAdmin.controller.js +277 -0
- package/src/controllers/waitingList.controller.js +167 -0
- package/src/controllers/webhook.controller.js +200 -0
- package/src/middleware/auth.js +66 -0
- package/src/middleware/errorCapture.js +170 -0
- package/src/middleware/headlessApiTokenAuth.js +57 -0
- package/src/middleware/org.js +108 -0
- package/src/middleware.js +901 -0
- package/src/models/ActionEvent.js +31 -0
- package/src/models/ActivityLog.js +41 -0
- package/src/models/Asset.js +84 -0
- package/src/models/AuditEvent.js +93 -0
- package/src/models/EmailLog.js +28 -0
- package/src/models/ErrorAggregate.js +72 -0
- package/src/models/FormSubmission.js +41 -0
- package/src/models/GlobalSetting.js +38 -0
- package/src/models/HeadlessApiToken.js +24 -0
- package/src/models/HeadlessModelDefinition.js +41 -0
- package/src/models/I18nEntry.js +77 -0
- package/src/models/I18nLocale.js +33 -0
- package/src/models/Invite.js +70 -0
- package/src/models/JsonConfig.js +46 -0
- package/src/models/Notification.js +60 -0
- package/src/models/Organization.js +57 -0
- package/src/models/OrganizationMember.js +43 -0
- package/src/models/StripeCatalogItem.js +77 -0
- package/src/models/StripeWebhookEvent.js +57 -0
- package/src/models/User.js +89 -0
- package/src/models/VirtualEjsFile.js +60 -0
- package/src/models/VirtualEjsFileVersion.js +43 -0
- package/src/models/VirtualEjsGroupChange.js +32 -0
- package/src/models/WaitingList.js +41 -0
- package/src/models/Webhook.js +63 -0
- package/src/models/Workflow.js +29 -0
- package/src/models/WorkflowExecution.js +12 -0
- package/src/routes/admin.routes.js +26 -0
- package/src/routes/adminAssets.routes.js +28 -0
- package/src/routes/adminAssetsStorage.routes.js +13 -0
- package/src/routes/adminAudit.routes.js +196 -0
- package/src/routes/adminEjsVirtual.routes.js +17 -0
- package/src/routes/adminErrors.routes.js +164 -0
- package/src/routes/adminFeatureFlags.routes.js +12 -0
- package/src/routes/adminHeadless.routes.js +38 -0
- package/src/routes/adminI18n.routes.js +22 -0
- package/src/routes/adminJsonConfigs.routes.js +15 -0
- package/src/routes/adminLlm.routes.js +12 -0
- package/src/routes/adminMigration.routes.js +81 -0
- package/src/routes/adminSeoConfig.routes.js +20 -0
- package/src/routes/adminUploadNamespaces.routes.js +13 -0
- package/src/routes/assets.routes.js +21 -0
- package/src/routes/auth.routes.js +12 -0
- package/src/routes/billing.routes.js +11 -0
- package/src/routes/errorTracking.routes.js +31 -0
- package/src/routes/featureFlags.routes.js +9 -0
- package/src/routes/forms.routes.js +9 -0
- package/src/routes/formsAdmin.routes.js +13 -0
- package/src/routes/globalSettings.routes.js +18 -0
- package/src/routes/headless.routes.js +15 -0
- package/src/routes/i18n.routes.js +8 -0
- package/src/routes/invite.routes.js +9 -0
- package/src/routes/jsonConfigs.routes.js +8 -0
- package/src/routes/log.routes.js +111 -0
- package/src/routes/metrics.routes.js +9 -0
- package/src/routes/notificationAdmin.routes.js +15 -0
- package/src/routes/notifications.routes.js +12 -0
- package/src/routes/org.routes.js +31 -0
- package/src/routes/orgAdmin.routes.js +20 -0
- package/src/routes/publicAssets.routes.js +7 -0
- package/src/routes/stripeAdmin.routes.js +20 -0
- package/src/routes/user.routes.js +22 -0
- package/src/routes/userAdmin.routes.js +15 -0
- package/src/routes/waitingList.routes.js +13 -0
- package/src/routes/waitingListAdmin.routes.js +9 -0
- package/src/routes/webhook.routes.js +32 -0
- package/src/routes/workflowWebhook.routes.js +54 -0
- package/src/routes/workflows.routes.js +110 -0
- package/src/services/assets.service.js +110 -0
- package/src/services/audit.service.js +62 -0
- package/src/services/auditLogger.js +165 -0
- package/src/services/ejsVirtual.service.js +614 -0
- package/src/services/email.service.js +351 -0
- package/src/services/errorLogger.js +221 -0
- package/src/services/featureFlags.service.js +202 -0
- package/src/services/forms.service.js +214 -0
- package/src/services/globalSettings.service.js +49 -0
- package/src/services/headlessApiTokens.service.js +158 -0
- package/src/services/headlessCrypto.service.js +31 -0
- package/src/services/headlessModels.service.js +356 -0
- package/src/services/i18n.service.js +314 -0
- package/src/services/i18nInferredKeys.service.js +337 -0
- package/src/services/jsonConfigs.service.js +392 -0
- package/src/services/llm.service.js +749 -0
- package/src/services/migration.service.js +581 -0
- package/src/services/migrationAssets/fsLocal.js +58 -0
- package/src/services/migrationAssets/index.js +134 -0
- package/src/services/migrationAssets/s3.js +75 -0
- package/src/services/migrationAssets/sftp.js +92 -0
- package/src/services/notification.service.js +212 -0
- package/src/services/objectStorage.service.js +514 -0
- package/src/services/seoConfig.service.js +402 -0
- package/src/services/storage.js +150 -0
- package/src/services/stripe.service.js +185 -0
- package/src/services/stripeHelper.service.js +264 -0
- package/src/services/uploadNamespaces.service.js +326 -0
- package/src/services/webhook.service.js +157 -0
- package/src/services/workflow.service.js +271 -0
- package/src/utils/asyncHandler.js +5 -0
- package/src/utils/encryption.js +80 -0
- package/src/utils/jwt.js +40 -0
- package/src/utils/orgRoles.js +156 -0
- package/src/utils/validation.js +26 -0
- package/src/utils/webhookRetry.js +93 -0
- package/views/admin-assets.ejs +444 -0
- package/views/admin-audit.ejs +283 -0
- package/views/admin-coolify-deploy.ejs +207 -0
- package/views/admin-dashboard-home.ejs +291 -0
- package/views/admin-dashboard.ejs +397 -0
- package/views/admin-ejs-virtual.ejs +280 -0
- package/views/admin-errors.ejs +368 -0
- package/views/admin-feature-flags.ejs +390 -0
- package/views/admin-forms.ejs +526 -0
- package/views/admin-global-settings.ejs +436 -0
- package/views/admin-headless.ejs +2020 -0
- package/views/admin-i18n-locales.ejs +221 -0
- package/views/admin-i18n.ejs +728 -0
- package/views/admin-json-configs.ejs +410 -0
- package/views/admin-llm.ejs +884 -0
- package/views/admin-metrics.ejs +274 -0
- package/views/admin-migration.ejs +814 -0
- package/views/admin-notifications.ejs +430 -0
- package/views/admin-organizations.ejs +984 -0
- package/views/admin-seo-config.ejs +673 -0
- package/views/admin-stripe-pricing.ejs +558 -0
- package/views/admin-test.ejs +342 -0
- package/views/admin-users.ejs +452 -0
- package/views/admin-waiting-list.ejs +547 -0
- package/views/admin-webhooks.ejs +329 -0
- package/views/admin-workflows.ejs +310 -0
- package/views/partials/admin-assets-script.ejs +2022 -0
- package/views/partials/admin-test-sidebar.ejs +14 -0
- package/views/partials/dashboard/nav-items.ejs +66 -0
- package/views/partials/dashboard/palette.ejs +63 -0
- package/views/partials/dashboard/sidebar.ejs +21 -0
- package/views/partials/dashboard/tab-bar.ejs +26 -0
- package/views/partials/footer.ejs +3 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const actionEventSchema = new mongoose.Schema({
|
|
4
|
+
action: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
index: true,
|
|
8
|
+
},
|
|
9
|
+
actorType: {
|
|
10
|
+
type: String,
|
|
11
|
+
enum: ['user', 'anonymous', 'system'],
|
|
12
|
+
required: true,
|
|
13
|
+
index: true,
|
|
14
|
+
},
|
|
15
|
+
actorId: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
index: true,
|
|
19
|
+
},
|
|
20
|
+
meta: {
|
|
21
|
+
type: mongoose.Schema.Types.Mixed,
|
|
22
|
+
default: null,
|
|
23
|
+
},
|
|
24
|
+
}, {
|
|
25
|
+
timestamps: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// actionEventSchema.index({ action: 1, createdAt: -1 }); // Removed duplicate index
|
|
29
|
+
actionEventSchema.index({ actorType: 1, actorId: 1, createdAt: -1 });
|
|
30
|
+
|
|
31
|
+
module.exports = mongoose.model('ActionEvent', actionEventSchema);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const activityLogSchema = new mongoose.Schema({
|
|
4
|
+
userId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'User',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
action: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
category: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
enum: ['auth', 'billing', 'content', 'settings', 'admin', 'other']
|
|
18
|
+
},
|
|
19
|
+
description: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
ipAddress: {
|
|
24
|
+
type: String
|
|
25
|
+
},
|
|
26
|
+
userAgent: {
|
|
27
|
+
type: String
|
|
28
|
+
},
|
|
29
|
+
metadata: {
|
|
30
|
+
type: mongoose.Schema.Types.Mixed,
|
|
31
|
+
default: {}
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
timestamps: true
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
activityLogSchema.index({ userId: 1, createdAt: -1 });
|
|
38
|
+
activityLogSchema.index({ category: 1 });
|
|
39
|
+
activityLogSchema.index({ action: 1 });
|
|
40
|
+
|
|
41
|
+
module.exports = mongoose.model('ActivityLog', activityLogSchema);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const assetSchema = new mongoose.Schema({
|
|
4
|
+
key: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
unique: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
provider: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
enum: ['s3', 'fs'],
|
|
14
|
+
default: 'fs'
|
|
15
|
+
},
|
|
16
|
+
bucket: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
default: 'fs'
|
|
20
|
+
},
|
|
21
|
+
originalName: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
contentType: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
sizeBytes: {
|
|
30
|
+
type: Number,
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
visibility: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
enum: ['public', 'private'],
|
|
37
|
+
default: 'private'
|
|
38
|
+
},
|
|
39
|
+
namespace: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: true,
|
|
42
|
+
default: 'default',
|
|
43
|
+
index: true,
|
|
44
|
+
},
|
|
45
|
+
visibilityEnforced: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
required: true,
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
50
|
+
tags: {
|
|
51
|
+
type: [String],
|
|
52
|
+
required: true,
|
|
53
|
+
default: [],
|
|
54
|
+
index: true,
|
|
55
|
+
},
|
|
56
|
+
ownerUserId: {
|
|
57
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
58
|
+
ref: 'User',
|
|
59
|
+
index: true,
|
|
60
|
+
default: null
|
|
61
|
+
},
|
|
62
|
+
orgId: {
|
|
63
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
64
|
+
ref: 'Organization',
|
|
65
|
+
index: true,
|
|
66
|
+
default: null
|
|
67
|
+
},
|
|
68
|
+
status: {
|
|
69
|
+
type: String,
|
|
70
|
+
required: true,
|
|
71
|
+
enum: ['uploaded', 'deleted'],
|
|
72
|
+
default: 'uploaded'
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
timestamps: true
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
assetSchema.index({ ownerUserId: 1, createdAt: -1 });
|
|
79
|
+
assetSchema.index({ visibility: 1, status: 1 });
|
|
80
|
+
assetSchema.index({ orgId: 1, createdAt: -1 });
|
|
81
|
+
assetSchema.index({ namespace: 1, createdAt: -1 });
|
|
82
|
+
assetSchema.index({ tags: 1, createdAt: -1 });
|
|
83
|
+
|
|
84
|
+
module.exports = mongoose.model('Asset', assetSchema);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const auditEventSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
actorType: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
enum: ['admin', 'admin_basic', 'user', 'system', 'anonymous'],
|
|
9
|
+
},
|
|
10
|
+
actorUserId: {
|
|
11
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
+
ref: 'User',
|
|
13
|
+
default: null,
|
|
14
|
+
index: true,
|
|
15
|
+
},
|
|
16
|
+
actorRole: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: null,
|
|
19
|
+
},
|
|
20
|
+
actorId: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: null,
|
|
23
|
+
},
|
|
24
|
+
action: {
|
|
25
|
+
type: String,
|
|
26
|
+
required: true,
|
|
27
|
+
index: true,
|
|
28
|
+
},
|
|
29
|
+
entityType: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: false,
|
|
32
|
+
index: true,
|
|
33
|
+
},
|
|
34
|
+
entityId: {
|
|
35
|
+
type: String,
|
|
36
|
+
required: false,
|
|
37
|
+
default: null,
|
|
38
|
+
index: true,
|
|
39
|
+
},
|
|
40
|
+
before: {
|
|
41
|
+
type: mongoose.Schema.Types.Mixed,
|
|
42
|
+
default: null,
|
|
43
|
+
},
|
|
44
|
+
after: {
|
|
45
|
+
type: mongoose.Schema.Types.Mixed,
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
48
|
+
meta: {
|
|
49
|
+
type: mongoose.Schema.Types.Mixed,
|
|
50
|
+
default: null,
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
outcome: {
|
|
54
|
+
type: String,
|
|
55
|
+
enum: ['success', 'failure'],
|
|
56
|
+
default: 'success',
|
|
57
|
+
index: true,
|
|
58
|
+
},
|
|
59
|
+
context: {
|
|
60
|
+
ip: String,
|
|
61
|
+
userAgent: String,
|
|
62
|
+
requestId: String,
|
|
63
|
+
path: String,
|
|
64
|
+
method: String,
|
|
65
|
+
},
|
|
66
|
+
targetType: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: null,
|
|
69
|
+
index: true,
|
|
70
|
+
},
|
|
71
|
+
targetId: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: null,
|
|
74
|
+
index: true,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{ timestamps: true },
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
auditEventSchema.index({ action: 1, createdAt: -1 });
|
|
81
|
+
auditEventSchema.index({ entityType: 1, entityId: 1, createdAt: -1 });
|
|
82
|
+
auditEventSchema.index({ outcome: 1, createdAt: -1 });
|
|
83
|
+
auditEventSchema.index({ targetType: 1, targetId: 1, createdAt: -1 });
|
|
84
|
+
|
|
85
|
+
auditEventSchema.set('toJSON', {
|
|
86
|
+
transform: (doc, ret) => {
|
|
87
|
+
ret.id = ret._id;
|
|
88
|
+
delete ret.__v;
|
|
89
|
+
return ret;
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
module.exports = mongoose.model('AuditEvent', auditEventSchema);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const emailLogSchema = new mongoose.Schema({
|
|
4
|
+
userId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'User',
|
|
7
|
+
index: true
|
|
8
|
+
},
|
|
9
|
+
to: [String],
|
|
10
|
+
subject: String,
|
|
11
|
+
type: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: 'other',
|
|
14
|
+
index: true
|
|
15
|
+
},
|
|
16
|
+
providerId: String,
|
|
17
|
+
status: {
|
|
18
|
+
type: String,
|
|
19
|
+
enum: ['sent', 'failed'],
|
|
20
|
+
default: 'sent'
|
|
21
|
+
},
|
|
22
|
+
error: String,
|
|
23
|
+
metadata: mongoose.Schema.Types.Mixed
|
|
24
|
+
}, {
|
|
25
|
+
timestamps: true
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
module.exports = mongoose.model('EmailLog', emailLogSchema);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const errorSampleSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
at: { type: Date, default: Date.now },
|
|
6
|
+
message: { type: String, maxlength: 2000 },
|
|
7
|
+
stack: { type: String, maxlength: 5000 },
|
|
8
|
+
actor: {
|
|
9
|
+
userId: { type: String },
|
|
10
|
+
role: String,
|
|
11
|
+
ip: String,
|
|
12
|
+
userAgent: String,
|
|
13
|
+
},
|
|
14
|
+
request: {
|
|
15
|
+
method: String,
|
|
16
|
+
path: String,
|
|
17
|
+
statusCode: Number,
|
|
18
|
+
requestId: String,
|
|
19
|
+
},
|
|
20
|
+
runtime: {
|
|
21
|
+
url: String,
|
|
22
|
+
referrer: String,
|
|
23
|
+
viewport: String,
|
|
24
|
+
locale: String,
|
|
25
|
+
appVersion: String,
|
|
26
|
+
nodeVersion: String,
|
|
27
|
+
hostname: String,
|
|
28
|
+
},
|
|
29
|
+
extra: { type: mongoose.Schema.Types.Mixed },
|
|
30
|
+
},
|
|
31
|
+
{ _id: false },
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const errorAggregateSchema = new mongoose.Schema(
|
|
35
|
+
{
|
|
36
|
+
fingerprint: { type: String, required: true, unique: true, index: true },
|
|
37
|
+
source: { type: String, enum: ['frontend', 'backend'], required: true, index: true },
|
|
38
|
+
severity: { type: String, enum: ['fatal', 'error', 'warn', 'info'], default: 'error', index: true },
|
|
39
|
+
errorName: { type: String, index: true },
|
|
40
|
+
errorCode: String,
|
|
41
|
+
messageTemplate: { type: String, maxlength: 500 },
|
|
42
|
+
topFrame: String,
|
|
43
|
+
httpStatusBucket: String,
|
|
44
|
+
countTotal: { type: Number, default: 0 },
|
|
45
|
+
countsByDay: { type: Map, of: Number, default: {} },
|
|
46
|
+
firstSeenAt: { type: Date, default: Date.now },
|
|
47
|
+
lastSeenAt: { type: Date, default: Date.now, index: true },
|
|
48
|
+
samples: {
|
|
49
|
+
type: [errorSampleSchema],
|
|
50
|
+
default: [],
|
|
51
|
+
validate: [arr => arr.length <= 20, 'samples cannot exceed 20'],
|
|
52
|
+
},
|
|
53
|
+
status: { type: String, enum: ['open', 'ignored', 'resolved'], default: 'open', index: true },
|
|
54
|
+
resolvedAt: Date,
|
|
55
|
+
},
|
|
56
|
+
{ timestamps: true },
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
errorAggregateSchema.index({ source: 1, lastSeenAt: -1 });
|
|
60
|
+
errorAggregateSchema.index({ countTotal: -1 });
|
|
61
|
+
errorAggregateSchema.index({ status: 1, lastSeenAt: -1 });
|
|
62
|
+
|
|
63
|
+
errorAggregateSchema.set('toJSON', {
|
|
64
|
+
transform: (doc, ret) => {
|
|
65
|
+
ret.id = ret._id;
|
|
66
|
+
delete ret._id;
|
|
67
|
+
delete ret.__v;
|
|
68
|
+
return ret;
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
module.exports = mongoose.model('ErrorAggregate', errorAggregateSchema);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const formSubmissionSchema = new mongoose.Schema({
|
|
4
|
+
formKey: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
index: true,
|
|
8
|
+
},
|
|
9
|
+
actorType: {
|
|
10
|
+
type: String,
|
|
11
|
+
enum: ['user', 'anonymous', 'system'],
|
|
12
|
+
required: true,
|
|
13
|
+
index: true,
|
|
14
|
+
},
|
|
15
|
+
actorId: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
index: true,
|
|
19
|
+
},
|
|
20
|
+
userId: {
|
|
21
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
+
ref: 'User',
|
|
23
|
+
default: null,
|
|
24
|
+
index: true,
|
|
25
|
+
},
|
|
26
|
+
fields: {
|
|
27
|
+
type: mongoose.Schema.Types.Mixed,
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
meta: {
|
|
31
|
+
type: mongoose.Schema.Types.Mixed,
|
|
32
|
+
default: null,
|
|
33
|
+
},
|
|
34
|
+
}, {
|
|
35
|
+
timestamps: true,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
formSubmissionSchema.index({ formKey: 1, createdAt: -1 });
|
|
39
|
+
formSubmissionSchema.index({ actorType: 1, actorId: 1, createdAt: -1 });
|
|
40
|
+
|
|
41
|
+
module.exports = mongoose.model('FormSubmission', formSubmissionSchema);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const globalSettingSchema = new mongoose.Schema({
|
|
4
|
+
key: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
unique: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
value: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
type: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
enum: ['string', 'html', 'boolean', 'json', 'number', 'encrypted'],
|
|
18
|
+
default: 'string'
|
|
19
|
+
},
|
|
20
|
+
description: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
templateVariables: {
|
|
25
|
+
type: [String],
|
|
26
|
+
default: []
|
|
27
|
+
},
|
|
28
|
+
public: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
timestamps: true
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// globalSettingSchema.index({ key: 1 }); // Removed duplicate index
|
|
37
|
+
|
|
38
|
+
module.exports = mongoose.model('GlobalSetting', globalSettingSchema);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const tokenPermissionSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
modelCode: { type: String, required: true },
|
|
6
|
+
operations: { type: [String], default: [] },
|
|
7
|
+
},
|
|
8
|
+
{ _id: false },
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const headlessApiTokenSchema = new mongoose.Schema(
|
|
12
|
+
{
|
|
13
|
+
name: { type: String, required: true },
|
|
14
|
+
tokenHash: { type: String, required: true, unique: true, index: true },
|
|
15
|
+
permissions: { type: [tokenPermissionSchema], default: [] },
|
|
16
|
+
expiresAt: { type: Date, default: null, index: true },
|
|
17
|
+
isActive: { type: Boolean, default: true, index: true },
|
|
18
|
+
lastUsedAt: { type: Date, default: null },
|
|
19
|
+
},
|
|
20
|
+
{ timestamps: true, collection: 'headless_api_tokens' },
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
module.exports = mongoose.models.HeadlessApiToken ||
|
|
24
|
+
mongoose.model('HeadlessApiToken', headlessApiTokenSchema);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const headlessFieldSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
name: { type: String, required: true },
|
|
6
|
+
type: { type: String, required: true },
|
|
7
|
+
required: { type: Boolean, default: false },
|
|
8
|
+
unique: { type: Boolean, default: false },
|
|
9
|
+
default: { type: mongoose.Schema.Types.Mixed, default: undefined },
|
|
10
|
+
validation: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
11
|
+
refModelCode: { type: String, default: null },
|
|
12
|
+
},
|
|
13
|
+
{ _id: false },
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const headlessIndexSchema = new mongoose.Schema(
|
|
17
|
+
{
|
|
18
|
+
fields: { type: mongoose.Schema.Types.Mixed, required: true },
|
|
19
|
+
options: { type: mongoose.Schema.Types.Mixed, default: {} },
|
|
20
|
+
},
|
|
21
|
+
{ _id: false },
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const headlessModelDefinitionSchema = new mongoose.Schema(
|
|
25
|
+
{
|
|
26
|
+
codeIdentifier: { type: String, required: true, unique: true, index: true },
|
|
27
|
+
displayName: { type: String, required: true },
|
|
28
|
+
description: { type: String, default: '' },
|
|
29
|
+
fields: { type: [headlessFieldSchema], default: [] },
|
|
30
|
+
indexes: { type: [headlessIndexSchema], default: [] },
|
|
31
|
+
isActive: { type: Boolean, default: true, index: true },
|
|
32
|
+
version: { type: Number, default: 1 },
|
|
33
|
+
fieldsHash: { type: String, default: null },
|
|
34
|
+
previousFields: { type: [headlessFieldSchema], default: [] },
|
|
35
|
+
previousIndexes: { type: [headlessIndexSchema], default: [] },
|
|
36
|
+
},
|
|
37
|
+
{ timestamps: true, collection: 'headless_model_definitions' },
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
module.exports = mongoose.models.HeadlessModelDefinition ||
|
|
41
|
+
mongoose.model('HeadlessModelDefinition', headlessModelDefinitionSchema);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const i18nEntrySchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
key: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
index: true,
|
|
9
|
+
trim: true,
|
|
10
|
+
},
|
|
11
|
+
locale: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
index: true,
|
|
15
|
+
trim: true,
|
|
16
|
+
},
|
|
17
|
+
value: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true,
|
|
20
|
+
default: '',
|
|
21
|
+
},
|
|
22
|
+
valueFormat: {
|
|
23
|
+
type: String,
|
|
24
|
+
enum: ['text', 'html'],
|
|
25
|
+
default: 'text',
|
|
26
|
+
},
|
|
27
|
+
source: {
|
|
28
|
+
type: String,
|
|
29
|
+
enum: ['seed', 'admin', 'ai'],
|
|
30
|
+
default: 'admin',
|
|
31
|
+
},
|
|
32
|
+
seeded: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false,
|
|
35
|
+
},
|
|
36
|
+
seedHash: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: null,
|
|
39
|
+
},
|
|
40
|
+
seedVersion: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: null,
|
|
43
|
+
},
|
|
44
|
+
edited: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
editedAt: {
|
|
49
|
+
type: Date,
|
|
50
|
+
default: null,
|
|
51
|
+
},
|
|
52
|
+
editedBy: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: null,
|
|
55
|
+
},
|
|
56
|
+
lastAiProvider: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: null,
|
|
59
|
+
},
|
|
60
|
+
lastAiModel: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: null,
|
|
63
|
+
},
|
|
64
|
+
lastAiPromptHash: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: null,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{ timestamps: true },
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
i18nEntrySchema.index({ key: 1, locale: 1 }, { unique: true });
|
|
73
|
+
// i18nEntrySchema.index({ locale: 1, key: 1 }); // Removed duplicate index
|
|
74
|
+
i18nEntrySchema.index({ edited: 1 });
|
|
75
|
+
i18nEntrySchema.index({ seeded: 1 });
|
|
76
|
+
|
|
77
|
+
module.exports = mongoose.model('I18nEntry', i18nEntrySchema);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const i18nLocaleSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
code: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
unique: true,
|
|
9
|
+
index: true,
|
|
10
|
+
trim: true,
|
|
11
|
+
},
|
|
12
|
+
name: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
trim: true,
|
|
16
|
+
},
|
|
17
|
+
enabled: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: true,
|
|
20
|
+
},
|
|
21
|
+
isDefault: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{ timestamps: true },
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// i18nLocaleSchema.index({ code: 1 }); // Removed duplicate index
|
|
30
|
+
i18nLocaleSchema.index({ enabled: 1 });
|
|
31
|
+
i18nLocaleSchema.index({ isDefault: 1 });
|
|
32
|
+
|
|
33
|
+
module.exports = mongoose.model('I18nLocale', i18nLocaleSchema);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
|
|
4
|
+
const inviteSchema = new mongoose.Schema({
|
|
5
|
+
email: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
lowercase: true,
|
|
9
|
+
trim: true,
|
|
10
|
+
index: true
|
|
11
|
+
},
|
|
12
|
+
tokenHash: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
unique: true
|
|
16
|
+
},
|
|
17
|
+
expiresAt: {
|
|
18
|
+
type: Date,
|
|
19
|
+
required: true,
|
|
20
|
+
index: true
|
|
21
|
+
},
|
|
22
|
+
status: {
|
|
23
|
+
type: String,
|
|
24
|
+
enum: ['pending', 'accepted', 'revoked', 'expired'],
|
|
25
|
+
default: 'pending'
|
|
26
|
+
},
|
|
27
|
+
createdByUserId: {
|
|
28
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
29
|
+
ref: 'User',
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
orgId: {
|
|
33
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
34
|
+
ref: 'Organization',
|
|
35
|
+
required: true,
|
|
36
|
+
index: true
|
|
37
|
+
},
|
|
38
|
+
role: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: 'member'
|
|
41
|
+
},
|
|
42
|
+
metadata: {
|
|
43
|
+
type: mongoose.Schema.Types.Mixed,
|
|
44
|
+
default: {}
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
timestamps: true
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
inviteSchema.index({ email: 1, status: 1 });
|
|
51
|
+
inviteSchema.index({ orgId: 1, status: 1 });
|
|
52
|
+
|
|
53
|
+
inviteSchema.statics.generateToken = function() {
|
|
54
|
+
const token = 'inv_' + crypto.randomBytes(24).toString('hex');
|
|
55
|
+
const tokenHash = crypto.createHash('sha256').update(token).digest('hex');
|
|
56
|
+
return { token, tokenHash };
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
inviteSchema.statics.hashToken = function(token) {
|
|
60
|
+
return crypto.createHash('sha256').update(token).digest('hex');
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
inviteSchema.methods.toJSON = function() {
|
|
64
|
+
const obj = this.toObject();
|
|
65
|
+
delete obj.__v;
|
|
66
|
+
delete obj.tokenHash;
|
|
67
|
+
return obj;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
module.exports = mongoose.model('Invite', inviteSchema);
|