@ozdao/prometheus-framework 0.1.34 → 0.1.36
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth.server.js +6 -6
- package/dist/auth.server.mjs +6 -6
- package/dist/community.server.js +21 -52
- package/dist/community.server.mjs +21 -52
- package/dist/events.server.js +27 -61
- package/dist/events.server.mjs +27 -61
- package/dist/metadata.schema-4f856191.js +85 -0
- package/dist/metadata.schema-7f36e829.mjs +86 -0
- package/package.json +1 -1
- package/src/modules/auth/routes/auth.routes.js +9 -6
- package/src/modules/community/controllers/blog.new.controller.js +290 -0
- package/src/modules/community/models/blogpost.model.js +18 -44
- package/src/modules/community/routes/blog.routes.js +10 -6
- package/src/modules/events/controllers/events.controller.js +2 -1
- package/src/modules/events/middlewares/server/verifyEvent.js +2 -0
- package/src/modules/events/models/event.model.js +25 -50
- package/src/modules/events/routes/events.routes.js +9 -6
- package/src/modules/globals/models/common.schema.js +3 -7
- package/src/modules/globals/models/engagement.schema.js +28 -6
- package/src/modules/globals/models/metadata.schema.js +7 -6
- package/src/modules/globals/models/ownership.schema.js +9 -8
- package/src/modules/events/models/event.new.model.js +0 -76
package/dist/auth.server.js
CHANGED
@@ -410,16 +410,16 @@ var invites_routes = function(app, db) {
|
|
410
410
|
const controllerFactory$1 = auth_controller;
|
411
411
|
const controllerFactoryTwofa = twofa_controller;
|
412
412
|
const middlewareFactory$1 = index.server;
|
413
|
-
var auth_routes = function(app, db) {
|
413
|
+
var auth_routes = function(app, db, origins) {
|
414
414
|
const controller = controllerFactory$1(db);
|
415
415
|
const controllerTwofa = controllerFactoryTwofa();
|
416
416
|
const { verifySignUp, verifyUser } = middlewareFactory$1(db);
|
417
417
|
app.use(function(req, res, next) {
|
418
|
-
|
419
|
-
|
420
|
-
"Access-Control-Allow-Origin",
|
421
|
-
|
422
|
-
);
|
418
|
+
const origin = req.headers.origin;
|
419
|
+
if (origins.includes(origin)) {
|
420
|
+
res.setHeader("Access-Control-Allow-Origin", origin);
|
421
|
+
}
|
422
|
+
res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
|
423
423
|
next();
|
424
424
|
});
|
425
425
|
app.post(
|
package/dist/auth.server.mjs
CHANGED
@@ -409,16 +409,16 @@ var invites_routes = function(app, db) {
|
|
409
409
|
const controllerFactory$1 = auth_controller;
|
410
410
|
const controllerFactoryTwofa = twofa_controller;
|
411
411
|
const middlewareFactory$1 = server;
|
412
|
-
var auth_routes = function(app, db) {
|
412
|
+
var auth_routes = function(app, db, origins) {
|
413
413
|
const controller = controllerFactory$1(db);
|
414
414
|
const controllerTwofa = controllerFactoryTwofa();
|
415
415
|
const { verifySignUp, verifyUser } = middlewareFactory$1(db);
|
416
416
|
app.use(function(req, res, next) {
|
417
|
-
|
418
|
-
|
419
|
-
"Access-Control-Allow-Origin",
|
420
|
-
|
421
|
-
);
|
417
|
+
const origin = req.headers.origin;
|
418
|
+
if (origins.includes(origin)) {
|
419
|
+
res.setHeader("Access-Control-Allow-Origin", origin);
|
420
|
+
}
|
421
|
+
res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
|
422
422
|
next();
|
423
423
|
});
|
424
424
|
app.post(
|
package/dist/community.server.js
CHANGED
@@ -3,6 +3,7 @@ const _commonjsHelpers = require("./_commonjsHelpers-3b53548e.js");
|
|
3
3
|
require("uuid");
|
4
4
|
const require$$0 = require("mongoose");
|
5
5
|
const index = require("./index-21dfdbd9.js");
|
6
|
+
const metadata_schema = require("./metadata.schema-4f856191.js");
|
6
7
|
require("jsonwebtoken");
|
7
8
|
require("mongodb");
|
8
9
|
async function getBlockedMembers$1(Membership, userId) {
|
@@ -486,16 +487,16 @@ var server = middlewareIndexFactory;
|
|
486
487
|
const controllerFactory$2 = blog_controller;
|
487
488
|
const middlewareFactoryGlobal = index.server;
|
488
489
|
const middlewareFactoryCommunity = server;
|
489
|
-
var blog_routes = function(app, db) {
|
490
|
+
var blog_routes = function(app, db, origins) {
|
490
491
|
const controller = controllerFactory$2(db);
|
491
492
|
middlewareFactoryGlobal(db);
|
492
493
|
const { verifyBlogpost: verifyBlogpost2 } = middlewareFactoryCommunity(db);
|
493
494
|
app.use(function(req, res, next) {
|
494
|
-
|
495
|
-
|
496
|
-
"Access-Control-Allow-Origin",
|
497
|
-
|
498
|
-
);
|
495
|
+
const origin = req.headers.origin;
|
496
|
+
if (origins.includes(origin)) {
|
497
|
+
res.setHeader("Access-Control-Allow-Origin", origin);
|
498
|
+
}
|
499
|
+
res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
|
499
500
|
next();
|
500
501
|
});
|
501
502
|
app.get(
|
@@ -579,54 +580,18 @@ var reactions_routes = function(app, db) {
|
|
579
580
|
controller.delete
|
580
581
|
);
|
581
582
|
};
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
status: {
|
583
|
+
const applyCommonSchema = metadata_schema.common_schema;
|
584
|
+
const applyEngagementSchema = metadata_schema.engagement_schema;
|
585
|
+
const applyOwnershipSchema = metadata_schema.ownership_schema;
|
586
|
+
const applyMetadataSchema = metadata_schema.metadata_schema;
|
587
|
+
var blogpost_model = (db) => {
|
588
|
+
const BlogpostSchema = new db.mongoose.Schema({
|
589
|
+
name: {
|
590
590
|
type: String,
|
591
|
-
enum: ["draft", "published", "removed"],
|
592
|
-
default: "draft",
|
593
591
|
required: true
|
594
592
|
},
|
595
|
-
|
596
|
-
type:
|
597
|
-
type: String,
|
598
|
-
required: true
|
599
|
-
},
|
600
|
-
target: {
|
601
|
-
type: mongoose.Schema.Types.ObjectId,
|
602
|
-
ref: function(value) {
|
603
|
-
if (this.owner.type === "user")
|
604
|
-
return "User";
|
605
|
-
if (this.owner.type === "organization")
|
606
|
-
return "Organization";
|
607
|
-
},
|
608
|
-
required: true
|
609
|
-
}
|
610
|
-
},
|
611
|
-
creator: {
|
612
|
-
hidden: {
|
613
|
-
type: Boolean,
|
614
|
-
required: true
|
615
|
-
},
|
616
|
-
type: {
|
617
|
-
type: String,
|
618
|
-
required: true
|
619
|
-
},
|
620
|
-
target: {
|
621
|
-
type: mongoose.Schema.Types.ObjectId,
|
622
|
-
ref: function(value) {
|
623
|
-
if (this.owner.type === "user")
|
624
|
-
return "User";
|
625
|
-
if (this.owner.type === "organization")
|
626
|
-
return "Organization";
|
627
|
-
},
|
628
|
-
required: true
|
629
|
-
}
|
593
|
+
content: {
|
594
|
+
type: Array
|
630
595
|
}
|
631
596
|
}, {
|
632
597
|
timestamps: {
|
@@ -635,7 +600,11 @@ var blogpost_model = (mongoose) => {
|
|
635
600
|
}, {
|
636
601
|
strict: false
|
637
602
|
});
|
638
|
-
|
603
|
+
applyCommonSchema(BlogpostSchema);
|
604
|
+
applyEngagementSchema(BlogpostSchema, db);
|
605
|
+
applyOwnershipSchema(BlogpostSchema, db);
|
606
|
+
applyMetadataSchema(BlogpostSchema);
|
607
|
+
const Blogpost = db.mongoose.model("Blogpost", BlogpostSchema);
|
639
608
|
return Blogpost;
|
640
609
|
};
|
641
610
|
var comment_model = (mongoose) => {
|
@@ -2,6 +2,7 @@ import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-83b1d755.mjs";
|
|
2
2
|
import "uuid";
|
3
3
|
import require$$0 from "mongoose";
|
4
4
|
import { s as server$1 } from "./index-fa8d5df4.mjs";
|
5
|
+
import { c as common_schema, e as engagement_schema, o as ownership_schema, m as metadata_schema } from "./metadata.schema-7f36e829.mjs";
|
5
6
|
import "jsonwebtoken";
|
6
7
|
import "mongodb";
|
7
8
|
async function getBlockedMembers$1(Membership, userId) {
|
@@ -485,16 +486,16 @@ var server = middlewareIndexFactory;
|
|
485
486
|
const controllerFactory$2 = blog_controller;
|
486
487
|
const middlewareFactoryGlobal = server$1;
|
487
488
|
const middlewareFactoryCommunity = server;
|
488
|
-
var blog_routes = function(app, db) {
|
489
|
+
var blog_routes = function(app, db, origins) {
|
489
490
|
const controller = controllerFactory$2(db);
|
490
491
|
middlewareFactoryGlobal(db);
|
491
492
|
const { verifyBlogpost: verifyBlogpost2 } = middlewareFactoryCommunity(db);
|
492
493
|
app.use(function(req, res, next) {
|
493
|
-
|
494
|
-
|
495
|
-
"Access-Control-Allow-Origin",
|
496
|
-
|
497
|
-
);
|
494
|
+
const origin = req.headers.origin;
|
495
|
+
if (origins.includes(origin)) {
|
496
|
+
res.setHeader("Access-Control-Allow-Origin", origin);
|
497
|
+
}
|
498
|
+
res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
|
498
499
|
next();
|
499
500
|
});
|
500
501
|
app.get(
|
@@ -578,54 +579,18 @@ var reactions_routes = function(app, db) {
|
|
578
579
|
controller.delete
|
579
580
|
);
|
580
581
|
};
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
status: {
|
582
|
+
const applyCommonSchema = common_schema;
|
583
|
+
const applyEngagementSchema = engagement_schema;
|
584
|
+
const applyOwnershipSchema = ownership_schema;
|
585
|
+
const applyMetadataSchema = metadata_schema;
|
586
|
+
var blogpost_model = (db) => {
|
587
|
+
const BlogpostSchema = new db.mongoose.Schema({
|
588
|
+
name: {
|
589
589
|
type: String,
|
590
|
-
enum: ["draft", "published", "removed"],
|
591
|
-
default: "draft",
|
592
590
|
required: true
|
593
591
|
},
|
594
|
-
|
595
|
-
type:
|
596
|
-
type: String,
|
597
|
-
required: true
|
598
|
-
},
|
599
|
-
target: {
|
600
|
-
type: mongoose.Schema.Types.ObjectId,
|
601
|
-
ref: function(value) {
|
602
|
-
if (this.owner.type === "user")
|
603
|
-
return "User";
|
604
|
-
if (this.owner.type === "organization")
|
605
|
-
return "Organization";
|
606
|
-
},
|
607
|
-
required: true
|
608
|
-
}
|
609
|
-
},
|
610
|
-
creator: {
|
611
|
-
hidden: {
|
612
|
-
type: Boolean,
|
613
|
-
required: true
|
614
|
-
},
|
615
|
-
type: {
|
616
|
-
type: String,
|
617
|
-
required: true
|
618
|
-
},
|
619
|
-
target: {
|
620
|
-
type: mongoose.Schema.Types.ObjectId,
|
621
|
-
ref: function(value) {
|
622
|
-
if (this.owner.type === "user")
|
623
|
-
return "User";
|
624
|
-
if (this.owner.type === "organization")
|
625
|
-
return "Organization";
|
626
|
-
},
|
627
|
-
required: true
|
628
|
-
}
|
592
|
+
content: {
|
593
|
+
type: Array
|
629
594
|
}
|
630
595
|
}, {
|
631
596
|
timestamps: {
|
@@ -634,7 +599,11 @@ var blogpost_model = (mongoose) => {
|
|
634
599
|
}, {
|
635
600
|
strict: false
|
636
601
|
});
|
637
|
-
|
602
|
+
applyCommonSchema(BlogpostSchema);
|
603
|
+
applyEngagementSchema(BlogpostSchema, db);
|
604
|
+
applyOwnershipSchema(BlogpostSchema, db);
|
605
|
+
applyMetadataSchema(BlogpostSchema);
|
606
|
+
const Blogpost = db.mongoose.model("Blogpost", BlogpostSchema);
|
638
607
|
return Blogpost;
|
639
608
|
};
|
640
609
|
var comment_model = (mongoose) => {
|
package/dist/events.server.js
CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const _commonjsHelpers = require("./_commonjsHelpers-3b53548e.js");
|
4
4
|
const require$$0 = require("mongoose");
|
5
5
|
const index = require("./index-21dfdbd9.js");
|
6
|
+
const metadata_schema = require("./metadata.schema-4f856191.js");
|
6
7
|
require("jsonwebtoken");
|
7
8
|
require("mongodb");
|
8
9
|
const ObjectId$1 = require$$0.Types.ObjectId;
|
@@ -383,8 +384,7 @@ const middlewareFactory = (db) => {
|
|
383
384
|
}
|
384
385
|
};
|
385
386
|
const create = async (req, res) => {
|
386
|
-
|
387
|
-
delete req.body._id;
|
387
|
+
delete req.body._id;
|
388
388
|
try {
|
389
389
|
req.body.url = createFriendlyURL(req.body.name);
|
390
390
|
const event = await Event.create(req.body);
|
@@ -493,16 +493,16 @@ var server = middlewareIndexFactory;
|
|
493
493
|
const controllerFactory$2 = events_controller;
|
494
494
|
const middlewareFactoryGlobal = index.server;
|
495
495
|
const middlewareFactoryEvents = server;
|
496
|
-
var events_routes = function(app, db) {
|
496
|
+
var events_routes = function(app, db, origins) {
|
497
497
|
const controller = controllerFactory$2(db);
|
498
498
|
middlewareFactoryGlobal(db);
|
499
499
|
const { verifyEvent: verifyEvent2 } = middlewareFactoryEvents(db);
|
500
500
|
app.use(function(req, res, next) {
|
501
|
-
|
502
|
-
|
503
|
-
"Access-Control-Allow-Origin",
|
504
|
-
|
505
|
-
);
|
501
|
+
const origin = req.headers.origin;
|
502
|
+
if (origins.includes(origin)) {
|
503
|
+
res.setHeader("Access-Control-Allow-Origin", origin);
|
504
|
+
}
|
505
|
+
res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
|
506
506
|
next();
|
507
507
|
});
|
508
508
|
app.get(
|
@@ -634,12 +634,12 @@ var tickets_routes = function(app, db, origins) {
|
|
634
634
|
);
|
635
635
|
};
|
636
636
|
const tickets_routes$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(tickets_routes);
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
637
|
+
const applyCommonSchema = metadata_schema.common_schema;
|
638
|
+
const applyEngagementSchema = metadata_schema.engagement_schema;
|
639
|
+
const applyOwnershipSchema = metadata_schema.ownership_schema;
|
640
|
+
const applyMetadataSchema = metadata_schema.metadata_schema;
|
641
|
+
var event_model = (db) => {
|
642
|
+
const EventSchema = new db.mongoose.Schema({
|
643
643
|
cover: {
|
644
644
|
type: String
|
645
645
|
},
|
@@ -647,12 +647,6 @@ var event_model = (mongoose) => {
|
|
647
647
|
type: String,
|
648
648
|
required: true
|
649
649
|
},
|
650
|
-
status: {
|
651
|
-
type: String,
|
652
|
-
enum: ["draft", "published", "removed"],
|
653
|
-
default: "draft",
|
654
|
-
required: true
|
655
|
-
},
|
656
650
|
description: {
|
657
651
|
type: String,
|
658
652
|
required: true
|
@@ -668,53 +662,25 @@ var event_model = (mongoose) => {
|
|
668
662
|
end: {
|
669
663
|
type: Date
|
670
664
|
}
|
671
|
-
},
|
672
|
-
tags: [{
|
673
|
-
type: String
|
674
|
-
}],
|
675
|
-
owner: {
|
676
|
-
type: {
|
677
|
-
type: String,
|
678
|
-
required: true
|
679
|
-
},
|
680
|
-
target: {
|
681
|
-
type: mongoose.Schema.Types.ObjectId,
|
682
|
-
ref: function(value) {
|
683
|
-
if (this.owner.type === "user")
|
684
|
-
return "User";
|
685
|
-
if (this.owner.type === "organization")
|
686
|
-
return "Organization";
|
687
|
-
},
|
688
|
-
required: true
|
689
|
-
}
|
690
|
-
},
|
691
|
-
creator: {
|
692
|
-
hidden: {
|
693
|
-
type: Boolean,
|
694
|
-
required: true
|
695
|
-
},
|
696
|
-
type: {
|
697
|
-
type: String,
|
698
|
-
required: true
|
699
|
-
},
|
700
|
-
target: {
|
701
|
-
type: mongoose.Schema.Types.ObjectId,
|
702
|
-
ref: function(value) {
|
703
|
-
if (this.owner.type === "user")
|
704
|
-
return "User";
|
705
|
-
if (this.owner.type === "organization")
|
706
|
-
return "Organization";
|
707
|
-
},
|
708
|
-
required: true
|
709
|
-
}
|
710
665
|
}
|
711
666
|
}, {
|
712
667
|
timestamps: {
|
713
668
|
currentTime: () => Date.now()
|
714
669
|
}
|
715
670
|
});
|
716
|
-
EventSchema.index({
|
717
|
-
|
671
|
+
EventSchema.index({
|
672
|
+
"name": 1,
|
673
|
+
"date.start": 1,
|
674
|
+
"date.end": -1
|
675
|
+
});
|
676
|
+
applyCommonSchema(EventSchema);
|
677
|
+
applyEngagementSchema(EventSchema, db);
|
678
|
+
applyOwnershipSchema(EventSchema, db);
|
679
|
+
applyMetadataSchema(EventSchema);
|
680
|
+
EventSchema.post("aggregate", async function(docs) {
|
681
|
+
console.log(EventSchema);
|
682
|
+
});
|
683
|
+
const Event = db.mongoose.model("Event", EventSchema);
|
718
684
|
return Event;
|
719
685
|
};
|
720
686
|
const event_model$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(event_model);
|
package/dist/events.server.mjs
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-83b1d755.mjs";
|
2
2
|
import require$$0 from "mongoose";
|
3
3
|
import { s as server$1 } from "./index-fa8d5df4.mjs";
|
4
|
+
import { c as common_schema, e as engagement_schema, o as ownership_schema, m as metadata_schema } from "./metadata.schema-7f36e829.mjs";
|
4
5
|
import "jsonwebtoken";
|
5
6
|
import "mongodb";
|
6
7
|
const ObjectId$1 = require$$0.Types.ObjectId;
|
@@ -381,8 +382,7 @@ const middlewareFactory = (db) => {
|
|
381
382
|
}
|
382
383
|
};
|
383
384
|
const create = async (req, res) => {
|
384
|
-
|
385
|
-
delete req.body._id;
|
385
|
+
delete req.body._id;
|
386
386
|
try {
|
387
387
|
req.body.url = createFriendlyURL(req.body.name);
|
388
388
|
const event = await Event.create(req.body);
|
@@ -491,16 +491,16 @@ var server = middlewareIndexFactory;
|
|
491
491
|
const controllerFactory$2 = events_controller;
|
492
492
|
const middlewareFactoryGlobal = server$1;
|
493
493
|
const middlewareFactoryEvents = server;
|
494
|
-
var events_routes = function(app, db) {
|
494
|
+
var events_routes = function(app, db, origins) {
|
495
495
|
const controller = controllerFactory$2(db);
|
496
496
|
middlewareFactoryGlobal(db);
|
497
497
|
const { verifyEvent: verifyEvent2 } = middlewareFactoryEvents(db);
|
498
498
|
app.use(function(req, res, next) {
|
499
|
-
|
500
|
-
|
501
|
-
"Access-Control-Allow-Origin",
|
502
|
-
|
503
|
-
);
|
499
|
+
const origin = req.headers.origin;
|
500
|
+
if (origins.includes(origin)) {
|
501
|
+
res.setHeader("Access-Control-Allow-Origin", origin);
|
502
|
+
}
|
503
|
+
res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
|
504
504
|
next();
|
505
505
|
});
|
506
506
|
app.get(
|
@@ -632,12 +632,12 @@ var tickets_routes = function(app, db, origins) {
|
|
632
632
|
);
|
633
633
|
};
|
634
634
|
const tickets_routes$1 = /* @__PURE__ */ getDefaultExportFromCjs(tickets_routes);
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
635
|
+
const applyCommonSchema = common_schema;
|
636
|
+
const applyEngagementSchema = engagement_schema;
|
637
|
+
const applyOwnershipSchema = ownership_schema;
|
638
|
+
const applyMetadataSchema = metadata_schema;
|
639
|
+
var event_model = (db) => {
|
640
|
+
const EventSchema = new db.mongoose.Schema({
|
641
641
|
cover: {
|
642
642
|
type: String
|
643
643
|
},
|
@@ -645,12 +645,6 @@ var event_model = (mongoose) => {
|
|
645
645
|
type: String,
|
646
646
|
required: true
|
647
647
|
},
|
648
|
-
status: {
|
649
|
-
type: String,
|
650
|
-
enum: ["draft", "published", "removed"],
|
651
|
-
default: "draft",
|
652
|
-
required: true
|
653
|
-
},
|
654
648
|
description: {
|
655
649
|
type: String,
|
656
650
|
required: true
|
@@ -666,53 +660,25 @@ var event_model = (mongoose) => {
|
|
666
660
|
end: {
|
667
661
|
type: Date
|
668
662
|
}
|
669
|
-
},
|
670
|
-
tags: [{
|
671
|
-
type: String
|
672
|
-
}],
|
673
|
-
owner: {
|
674
|
-
type: {
|
675
|
-
type: String,
|
676
|
-
required: true
|
677
|
-
},
|
678
|
-
target: {
|
679
|
-
type: mongoose.Schema.Types.ObjectId,
|
680
|
-
ref: function(value) {
|
681
|
-
if (this.owner.type === "user")
|
682
|
-
return "User";
|
683
|
-
if (this.owner.type === "organization")
|
684
|
-
return "Organization";
|
685
|
-
},
|
686
|
-
required: true
|
687
|
-
}
|
688
|
-
},
|
689
|
-
creator: {
|
690
|
-
hidden: {
|
691
|
-
type: Boolean,
|
692
|
-
required: true
|
693
|
-
},
|
694
|
-
type: {
|
695
|
-
type: String,
|
696
|
-
required: true
|
697
|
-
},
|
698
|
-
target: {
|
699
|
-
type: mongoose.Schema.Types.ObjectId,
|
700
|
-
ref: function(value) {
|
701
|
-
if (this.owner.type === "user")
|
702
|
-
return "User";
|
703
|
-
if (this.owner.type === "organization")
|
704
|
-
return "Organization";
|
705
|
-
},
|
706
|
-
required: true
|
707
|
-
}
|
708
663
|
}
|
709
664
|
}, {
|
710
665
|
timestamps: {
|
711
666
|
currentTime: () => Date.now()
|
712
667
|
}
|
713
668
|
});
|
714
|
-
EventSchema.index({
|
715
|
-
|
669
|
+
EventSchema.index({
|
670
|
+
"name": 1,
|
671
|
+
"date.start": 1,
|
672
|
+
"date.end": -1
|
673
|
+
});
|
674
|
+
applyCommonSchema(EventSchema);
|
675
|
+
applyEngagementSchema(EventSchema, db);
|
676
|
+
applyOwnershipSchema(EventSchema, db);
|
677
|
+
applyMetadataSchema(EventSchema);
|
678
|
+
EventSchema.post("aggregate", async function(docs) {
|
679
|
+
console.log(EventSchema);
|
680
|
+
});
|
681
|
+
const Event = db.mongoose.model("Event", EventSchema);
|
716
682
|
return Event;
|
717
683
|
};
|
718
684
|
const event_model$1 = /* @__PURE__ */ getDefaultExportFromCjs(event_model);
|
@@ -0,0 +1,85 @@
|
|
1
|
+
"use strict";
|
2
|
+
var common_schema = function applyCommonSchema(schema, db) {
|
3
|
+
schema.add({
|
4
|
+
status: {
|
5
|
+
type: String,
|
6
|
+
enum: ["draft", "published", "removed"],
|
7
|
+
default: "draft",
|
8
|
+
required: true
|
9
|
+
}
|
10
|
+
});
|
11
|
+
};
|
12
|
+
var engagement_schema = function applyEngagementSchema(schema, db) {
|
13
|
+
schema.add({
|
14
|
+
views: {
|
15
|
+
type: Number,
|
16
|
+
default: 0
|
17
|
+
}
|
18
|
+
});
|
19
|
+
schema.post("aggregate", async function(docs) {
|
20
|
+
if (docs.length > 0) {
|
21
|
+
console.log("Post-aggregate hook in engagement schena triggered");
|
22
|
+
try {
|
23
|
+
await Promise.all(docs.map(async (doc) => {
|
24
|
+
console.log(doc._id);
|
25
|
+
const updatedViews = await db.event.findOneAndUpdate({ _id: doc._id }, { $inc: { views: 1 } }).exec();
|
26
|
+
}));
|
27
|
+
} catch (error) {
|
28
|
+
console.error("Error updating views:", error);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
});
|
32
|
+
};
|
33
|
+
var ownership_schema = function applyOwnershipSchema(schema, db) {
|
34
|
+
schema.add({
|
35
|
+
owner: {
|
36
|
+
type: {
|
37
|
+
type: String,
|
38
|
+
required: true
|
39
|
+
},
|
40
|
+
target: {
|
41
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
42
|
+
refPath: "owner.type",
|
43
|
+
required: true
|
44
|
+
}
|
45
|
+
},
|
46
|
+
creator: {
|
47
|
+
hidden: {
|
48
|
+
type: Boolean,
|
49
|
+
required: true
|
50
|
+
},
|
51
|
+
type: {
|
52
|
+
type: String,
|
53
|
+
required: true
|
54
|
+
},
|
55
|
+
target: {
|
56
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
57
|
+
refPath: "creator.type",
|
58
|
+
required: true
|
59
|
+
}
|
60
|
+
}
|
61
|
+
});
|
62
|
+
schema.index({
|
63
|
+
"owner.target": 1,
|
64
|
+
"creator.target": 1
|
65
|
+
});
|
66
|
+
};
|
67
|
+
var metadata_schema = function applyMetadataSchema(schema, db) {
|
68
|
+
schema.add({
|
69
|
+
url: {
|
70
|
+
type: String,
|
71
|
+
required: true
|
72
|
+
},
|
73
|
+
tags: [{
|
74
|
+
type: String
|
75
|
+
}]
|
76
|
+
});
|
77
|
+
schema.index({
|
78
|
+
"url": 1,
|
79
|
+
"tags": 1
|
80
|
+
});
|
81
|
+
};
|
82
|
+
exports.common_schema = common_schema;
|
83
|
+
exports.engagement_schema = engagement_schema;
|
84
|
+
exports.metadata_schema = metadata_schema;
|
85
|
+
exports.ownership_schema = ownership_schema;
|