@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,46 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const jsonConfigSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
title: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
},
|
|
9
|
+
slug: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
unique: true,
|
|
13
|
+
index: true,
|
|
14
|
+
},
|
|
15
|
+
alias: {
|
|
16
|
+
type: String,
|
|
17
|
+
unique: true,
|
|
18
|
+
sparse: true,
|
|
19
|
+
index: true,
|
|
20
|
+
},
|
|
21
|
+
publicEnabled: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false,
|
|
24
|
+
},
|
|
25
|
+
cacheTtlSeconds: {
|
|
26
|
+
type: Number,
|
|
27
|
+
default: 0,
|
|
28
|
+
},
|
|
29
|
+
jsonRaw: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
jsonHash: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: null,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
timestamps: true,
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// jsonConfigSchema.index({ slug: 1 }); // Removed duplicate index
|
|
44
|
+
// jsonConfigSchema.index({ alias: 1 }); // Removed duplicate index
|
|
45
|
+
|
|
46
|
+
module.exports = mongoose.model('JsonConfig', jsonConfigSchema);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const notificationSchema = new mongoose.Schema({
|
|
4
|
+
userId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'User',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
type: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
enum: ['info', 'success', 'warning', 'error']
|
|
14
|
+
},
|
|
15
|
+
title: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
message: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
read: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false
|
|
26
|
+
},
|
|
27
|
+
metadata: {
|
|
28
|
+
type: mongoose.Schema.Types.Mixed,
|
|
29
|
+
default: {}
|
|
30
|
+
},
|
|
31
|
+
channel: {
|
|
32
|
+
type: String,
|
|
33
|
+
enum: ['in_app', 'email', 'both'],
|
|
34
|
+
default: 'in_app'
|
|
35
|
+
},
|
|
36
|
+
emailStatus: {
|
|
37
|
+
type: String,
|
|
38
|
+
enum: ['pending', 'sent', 'failed', 'skipped'],
|
|
39
|
+
default: 'skipped'
|
|
40
|
+
},
|
|
41
|
+
emailSentAt: {
|
|
42
|
+
type: Date
|
|
43
|
+
},
|
|
44
|
+
sentByAdminId: {
|
|
45
|
+
type: String
|
|
46
|
+
},
|
|
47
|
+
broadcastId: {
|
|
48
|
+
type: String,
|
|
49
|
+
index: true
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
timestamps: true
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
notificationSchema.index({ userId: 1, read: 1 });
|
|
56
|
+
notificationSchema.index({ createdAt: -1 });
|
|
57
|
+
notificationSchema.index({ sentByAdminId: 1, createdAt: -1 });
|
|
58
|
+
notificationSchema.index({ channel: 1, emailStatus: 1 });
|
|
59
|
+
|
|
60
|
+
module.exports = mongoose.model('Notification', notificationSchema);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const organizationSchema = new mongoose.Schema({
|
|
4
|
+
name: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
trim: true
|
|
8
|
+
},
|
|
9
|
+
slug: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
unique: true,
|
|
13
|
+
lowercase: true,
|
|
14
|
+
trim: true
|
|
15
|
+
},
|
|
16
|
+
ownerUserId: {
|
|
17
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
18
|
+
ref: 'User',
|
|
19
|
+
required: true,
|
|
20
|
+
index: true
|
|
21
|
+
},
|
|
22
|
+
billingOwnerUserId: {
|
|
23
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
24
|
+
ref: 'User'
|
|
25
|
+
},
|
|
26
|
+
description: {
|
|
27
|
+
type: String,
|
|
28
|
+
trim: true
|
|
29
|
+
},
|
|
30
|
+
allowPublicJoin: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
status: {
|
|
35
|
+
type: String,
|
|
36
|
+
enum: ['active', 'disabled'],
|
|
37
|
+
default: 'active'
|
|
38
|
+
},
|
|
39
|
+
settings: {
|
|
40
|
+
type: mongoose.Schema.Types.Mixed,
|
|
41
|
+
default: {}
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
timestamps: true
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// organizationSchema.index({ slug: 1 }, { unique: true }); // Removed duplicate index
|
|
48
|
+
organizationSchema.index({ ownerUserId: 1, createdAt: -1 });
|
|
49
|
+
organizationSchema.index({ status: 1 });
|
|
50
|
+
|
|
51
|
+
organizationSchema.methods.toJSON = function() {
|
|
52
|
+
const obj = this.toObject();
|
|
53
|
+
delete obj.__v;
|
|
54
|
+
return obj;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
module.exports = mongoose.model('Organization', organizationSchema);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const organizationMemberSchema = new mongoose.Schema({
|
|
4
|
+
orgId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Organization',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
userId: {
|
|
11
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
+
ref: 'User',
|
|
13
|
+
required: true,
|
|
14
|
+
index: true
|
|
15
|
+
},
|
|
16
|
+
role: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: 'member'
|
|
19
|
+
},
|
|
20
|
+
status: {
|
|
21
|
+
type: String,
|
|
22
|
+
enum: ['active', 'removed'],
|
|
23
|
+
default: 'active'
|
|
24
|
+
},
|
|
25
|
+
addedByUserId: {
|
|
26
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
27
|
+
ref: 'User'
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
timestamps: true
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
organizationMemberSchema.index({ orgId: 1, userId: 1 }, { unique: true });
|
|
34
|
+
organizationMemberSchema.index({ userId: 1, status: 1, createdAt: -1 });
|
|
35
|
+
organizationMemberSchema.index({ orgId: 1, status: 1, role: 1 });
|
|
36
|
+
|
|
37
|
+
organizationMemberSchema.methods.toJSON = function() {
|
|
38
|
+
const obj = this.toObject();
|
|
39
|
+
delete obj.__v;
|
|
40
|
+
return obj;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
module.exports = mongoose.model('OrganizationMember', organizationMemberSchema);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const stripeCatalogItemSchema = new mongoose.Schema({
|
|
4
|
+
stripeProductId: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
index: true
|
|
8
|
+
},
|
|
9
|
+
stripePriceId: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
unique: true,
|
|
13
|
+
index: true
|
|
14
|
+
},
|
|
15
|
+
planKey: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
trim: true,
|
|
19
|
+
index: true
|
|
20
|
+
},
|
|
21
|
+
displayName: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true,
|
|
24
|
+
trim: true
|
|
25
|
+
},
|
|
26
|
+
description: {
|
|
27
|
+
type: String,
|
|
28
|
+
trim: true,
|
|
29
|
+
default: ''
|
|
30
|
+
},
|
|
31
|
+
billingType: {
|
|
32
|
+
type: String,
|
|
33
|
+
enum: ['subscription', 'one_time'],
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
36
|
+
currency: {
|
|
37
|
+
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
lowercase: true,
|
|
40
|
+
default: 'usd'
|
|
41
|
+
},
|
|
42
|
+
unitAmount: {
|
|
43
|
+
type: Number,
|
|
44
|
+
required: true
|
|
45
|
+
},
|
|
46
|
+
interval: {
|
|
47
|
+
type: String,
|
|
48
|
+
enum: ['month', 'year', 'week', 'day', null],
|
|
49
|
+
default: null
|
|
50
|
+
},
|
|
51
|
+
intervalCount: {
|
|
52
|
+
type: Number,
|
|
53
|
+
default: 1
|
|
54
|
+
},
|
|
55
|
+
active: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: true,
|
|
58
|
+
index: true
|
|
59
|
+
},
|
|
60
|
+
metadata: {
|
|
61
|
+
type: mongoose.Schema.Types.Mixed,
|
|
62
|
+
default: {}
|
|
63
|
+
},
|
|
64
|
+
createdByAdminId: {
|
|
65
|
+
type: String
|
|
66
|
+
},
|
|
67
|
+
updatedByAdminId: {
|
|
68
|
+
type: String
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
timestamps: true
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
stripeCatalogItemSchema.index({ planKey: 1, active: 1 });
|
|
75
|
+
stripeCatalogItemSchema.index({ stripeProductId: 1, active: 1 });
|
|
76
|
+
|
|
77
|
+
module.exports = mongoose.model('StripeCatalogItem', stripeCatalogItemSchema);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const stripeWebhookEventSchema = new mongoose.Schema({
|
|
4
|
+
stripeEventId: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
unique: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
eventType: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
index: true
|
|
14
|
+
},
|
|
15
|
+
data: {
|
|
16
|
+
type: Object,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
previousAttributes: {
|
|
20
|
+
type: Object
|
|
21
|
+
},
|
|
22
|
+
api_version: {
|
|
23
|
+
type: String
|
|
24
|
+
},
|
|
25
|
+
request: {
|
|
26
|
+
type: Object
|
|
27
|
+
},
|
|
28
|
+
status: {
|
|
29
|
+
type: String,
|
|
30
|
+
enum: ['received', 'processed', 'failed', 'skipped'],
|
|
31
|
+
default: 'received',
|
|
32
|
+
index: true
|
|
33
|
+
},
|
|
34
|
+
processingErrors: [{
|
|
35
|
+
message: String,
|
|
36
|
+
timestamp: Date
|
|
37
|
+
}],
|
|
38
|
+
retryCount: {
|
|
39
|
+
type: Number,
|
|
40
|
+
default: 0
|
|
41
|
+
},
|
|
42
|
+
receivedAt: {
|
|
43
|
+
type: Date,
|
|
44
|
+
default: Date.now,
|
|
45
|
+
index: true
|
|
46
|
+
},
|
|
47
|
+
processedAt: {
|
|
48
|
+
type: Date
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
timestamps: true
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
stripeWebhookEventSchema.index({ status: 1, receivedAt: 1 });
|
|
55
|
+
stripeWebhookEventSchema.index({ eventType: 1, createdAt: -1 });
|
|
56
|
+
|
|
57
|
+
module.exports = mongoose.model('StripeWebhookEvent', stripeWebhookEventSchema);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const bcrypt = require('bcryptjs');
|
|
3
|
+
|
|
4
|
+
const userSchema = new mongoose.Schema({
|
|
5
|
+
email: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
unique: true,
|
|
9
|
+
lowercase: true,
|
|
10
|
+
trim: true,
|
|
11
|
+
index: true
|
|
12
|
+
},
|
|
13
|
+
clerkUserId: {
|
|
14
|
+
type: String,
|
|
15
|
+
index: true,
|
|
16
|
+
sparse: true
|
|
17
|
+
},
|
|
18
|
+
passwordHash: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: function () {
|
|
21
|
+
return !this.clerkUserId;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
name: {
|
|
25
|
+
type: String,
|
|
26
|
+
trim: true
|
|
27
|
+
},
|
|
28
|
+
subscriptionStatus: {
|
|
29
|
+
type: String,
|
|
30
|
+
enum: ['none', 'active', 'cancelled', 'past_due', 'incomplete', 'incomplete_expired', 'trialing', 'unpaid'],
|
|
31
|
+
default: 'none'
|
|
32
|
+
},
|
|
33
|
+
stripeCustomerId: {
|
|
34
|
+
type: String,
|
|
35
|
+
sparse: true
|
|
36
|
+
},
|
|
37
|
+
stripeSubscriptionId: {
|
|
38
|
+
type: String,
|
|
39
|
+
sparse: true
|
|
40
|
+
},
|
|
41
|
+
currentPlan: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: 'free',
|
|
44
|
+
trim: true
|
|
45
|
+
},
|
|
46
|
+
settings: {
|
|
47
|
+
type: mongoose.Schema.Types.Mixed,
|
|
48
|
+
default: {}
|
|
49
|
+
},
|
|
50
|
+
passwordResetToken: {
|
|
51
|
+
type: String,
|
|
52
|
+
sparse: true
|
|
53
|
+
},
|
|
54
|
+
passwordResetExpiry: {
|
|
55
|
+
type: Date
|
|
56
|
+
},
|
|
57
|
+
role: {
|
|
58
|
+
type: String,
|
|
59
|
+
enum: ['user', 'admin'],
|
|
60
|
+
default: 'user'
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
timestamps: true
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// userSchema.index({ email: 1 }); // Removed duplicate index
|
|
67
|
+
|
|
68
|
+
// Hash password before saving
|
|
69
|
+
userSchema.pre('save', async function(next) {
|
|
70
|
+
if (!this.isModified('passwordHash')) return next();
|
|
71
|
+
this.passwordHash = await bcrypt.hash(this.passwordHash, 10);
|
|
72
|
+
next();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Method to compare password
|
|
76
|
+
userSchema.methods.comparePassword = async function(candidatePassword) {
|
|
77
|
+
if (!this.passwordHash) return false;
|
|
78
|
+
return bcrypt.compare(candidatePassword, this.passwordHash);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Clean up response
|
|
82
|
+
userSchema.methods.toJSON = function() {
|
|
83
|
+
const obj = this.toObject();
|
|
84
|
+
delete obj.passwordHash;
|
|
85
|
+
delete obj.__v;
|
|
86
|
+
return obj;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
module.exports = mongoose.model('User', userSchema);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const virtualEjsFileSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
path: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
unique: true,
|
|
9
|
+
index: true,
|
|
10
|
+
},
|
|
11
|
+
enabled: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: true,
|
|
14
|
+
index: true,
|
|
15
|
+
},
|
|
16
|
+
content: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: '',
|
|
19
|
+
},
|
|
20
|
+
source: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: 'manual',
|
|
23
|
+
enum: ['filesystem_snapshot', 'manual', 'llm', 'rollback'],
|
|
24
|
+
index: true,
|
|
25
|
+
},
|
|
26
|
+
baseSha: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: null,
|
|
29
|
+
},
|
|
30
|
+
inferred: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false,
|
|
33
|
+
index: true,
|
|
34
|
+
},
|
|
35
|
+
integrated: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false,
|
|
38
|
+
index: true,
|
|
39
|
+
},
|
|
40
|
+
renderCount: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 0,
|
|
43
|
+
},
|
|
44
|
+
lastRenderedAt: {
|
|
45
|
+
type: Date,
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
48
|
+
lastSeenAt: {
|
|
49
|
+
type: Date,
|
|
50
|
+
default: null,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{ timestamps: true },
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// virtualEjsFileSchema.index({ path: 1 }); // Removed duplicate index
|
|
57
|
+
virtualEjsFileSchema.index({ inferred: 1, integrated: 1 });
|
|
58
|
+
virtualEjsFileSchema.index({ enabled: 1, updatedAt: -1 });
|
|
59
|
+
|
|
60
|
+
module.exports = mongoose.model('VirtualEjsFile', virtualEjsFileSchema);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const virtualEjsFileVersionSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
fileId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
ref: 'VirtualEjsFile',
|
|
8
|
+
required: true,
|
|
9
|
+
index: true,
|
|
10
|
+
},
|
|
11
|
+
path: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
index: true,
|
|
15
|
+
},
|
|
16
|
+
content: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: '',
|
|
19
|
+
},
|
|
20
|
+
source: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: 'manual',
|
|
23
|
+
enum: ['filesystem_snapshot', 'manual', 'llm', 'rollback'],
|
|
24
|
+
index: true,
|
|
25
|
+
},
|
|
26
|
+
description: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: '',
|
|
29
|
+
},
|
|
30
|
+
groupId: {
|
|
31
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
32
|
+
ref: 'VirtualEjsGroupChange',
|
|
33
|
+
default: null,
|
|
34
|
+
index: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{ timestamps: true },
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
virtualEjsFileVersionSchema.index({ fileId: 1, createdAt: -1 });
|
|
41
|
+
virtualEjsFileVersionSchema.index({ path: 1, createdAt: -1 });
|
|
42
|
+
|
|
43
|
+
module.exports = mongoose.model('VirtualEjsFileVersion', virtualEjsFileVersionSchema);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const virtualEjsGroupChangeSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
title: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: '',
|
|
8
|
+
},
|
|
9
|
+
summary: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: '',
|
|
12
|
+
},
|
|
13
|
+
filePaths: {
|
|
14
|
+
type: [String],
|
|
15
|
+
default: [],
|
|
16
|
+
},
|
|
17
|
+
versionIds: {
|
|
18
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
19
|
+
ref: 'VirtualEjsFileVersion',
|
|
20
|
+
default: [],
|
|
21
|
+
},
|
|
22
|
+
createdBy: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: null,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{ timestamps: true },
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
virtualEjsGroupChangeSchema.index({ createdAt: -1 });
|
|
31
|
+
|
|
32
|
+
module.exports = mongoose.model('VirtualEjsGroupChange', virtualEjsGroupChangeSchema);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const waitingListSchema = new mongoose.Schema({
|
|
4
|
+
email: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
unique: true,
|
|
8
|
+
lowercase: true,
|
|
9
|
+
trim: true,
|
|
10
|
+
index: true
|
|
11
|
+
},
|
|
12
|
+
type: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
default: 'both'
|
|
16
|
+
},
|
|
17
|
+
status: {
|
|
18
|
+
type: String,
|
|
19
|
+
enum: ['active', 'subscribed', 'launched'],
|
|
20
|
+
default: 'active'
|
|
21
|
+
},
|
|
22
|
+
referralSource: {
|
|
23
|
+
type: String,
|
|
24
|
+
trim: true
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
timestamps: true
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// waitingListSchema.index({ email: 1 }); // Removed duplicate index
|
|
31
|
+
waitingListSchema.index({ type: 1 });
|
|
32
|
+
waitingListSchema.index({ status: 1 });
|
|
33
|
+
|
|
34
|
+
// Clean up response
|
|
35
|
+
waitingListSchema.methods.toJSON = function() {
|
|
36
|
+
const obj = this.toObject();
|
|
37
|
+
delete obj.__v;
|
|
38
|
+
return obj;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
module.exports = mongoose.model('WaitingList', waitingListSchema);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const webhookSchema = new mongoose.Schema({
|
|
4
|
+
name: {
|
|
5
|
+
type: String,
|
|
6
|
+
trim: true,
|
|
7
|
+
index: true,
|
|
8
|
+
default: () => `Webhook-${require('crypto').randomBytes(4).toString('hex')}`
|
|
9
|
+
},
|
|
10
|
+
targetUrl: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
trim: true
|
|
14
|
+
},
|
|
15
|
+
secret: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
default: () => require('crypto').randomBytes(32).toString('hex')
|
|
19
|
+
},
|
|
20
|
+
events: [{
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
enum: [
|
|
24
|
+
'user.login',
|
|
25
|
+
'user.registered',
|
|
26
|
+
'organization.updated',
|
|
27
|
+
'member.added',
|
|
28
|
+
'form.submitted',
|
|
29
|
+
'audit.event'
|
|
30
|
+
]
|
|
31
|
+
}],
|
|
32
|
+
organizationId: {
|
|
33
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
34
|
+
ref: 'Organization',
|
|
35
|
+
required: false,
|
|
36
|
+
index: true
|
|
37
|
+
},
|
|
38
|
+
status: {
|
|
39
|
+
type: String,
|
|
40
|
+
enum: ['active', 'paused', 'failed'],
|
|
41
|
+
default: 'active'
|
|
42
|
+
},
|
|
43
|
+
timeout: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: 5000, // 5 seconds default
|
|
46
|
+
min: 1000,
|
|
47
|
+
max: 30000 // 30 seconds max
|
|
48
|
+
},
|
|
49
|
+
isAsync: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false
|
|
52
|
+
},
|
|
53
|
+
metadata: {
|
|
54
|
+
type: mongoose.Schema.Types.Mixed,
|
|
55
|
+
default: {}
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
timestamps: true
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
webhookSchema.index({ name: 1, organizationId: 1 }, { unique: true });
|
|
62
|
+
|
|
63
|
+
module.exports = mongoose.model('Webhook', webhookSchema);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const workflowSchema = new mongoose.Schema({
|
|
4
|
+
name: { type: String, required: true },
|
|
5
|
+
status: { type: String, enum: ['active', 'inactive'], default: 'inactive' },
|
|
6
|
+
organizationId: { type: mongoose.Schema.Types.ObjectId, ref: 'Organization', index: true },
|
|
7
|
+
entrypoint: {
|
|
8
|
+
type: { type: String, default: 'webhook' },
|
|
9
|
+
allowedMethods: { type: [String], default: ['POST', 'GET'] },
|
|
10
|
+
auth: {
|
|
11
|
+
type: { type: String, enum: ['none', 'header', 'bearer'], default: 'none' },
|
|
12
|
+
headerName: String,
|
|
13
|
+
headerValue: String
|
|
14
|
+
},
|
|
15
|
+
awaitResponse: { type: Boolean, default: false }
|
|
16
|
+
},
|
|
17
|
+
testDataset: {
|
|
18
|
+
method: { type: String, default: 'POST' },
|
|
19
|
+
body: { type: Object, default: {} },
|
|
20
|
+
query: { type: Object, default: {} },
|
|
21
|
+
headers: { type: Object, default: {} }
|
|
22
|
+
},
|
|
23
|
+
webhookSlug: { type: String, unique: true, sparse: true },
|
|
24
|
+
nodes: { type: Array, default: [] },
|
|
25
|
+
createdAt: { type: Date, default: Date.now },
|
|
26
|
+
updatedAt: { type: Date, default: Date.now }
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
module.exports = mongoose.model('Workflow', workflowSchema);
|