@yrpri/api 9.0.112 → 9.0.113

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yrpri/api",
3
- "version": "9.0.112",
3
+ "version": "9.0.113",
4
4
  "license": "MIT",
5
5
  "author": "Robert Bjarnason & Citizens Foundation",
6
6
  "repository": {
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const Sequelize = require('sequelize');
5
+ const basename = path.basename(__filename);
6
+ const env = process.env.NODE_ENV || 'development';
7
+ // TODO: Replace this with your actual database configuration
8
+ // It might come from a central config file or environment variables
9
+ const config = require(__dirname + '/../../config/config.json')[env]; // Assuming a config file structure
10
+ const db = {};
11
+ let sequelize;
12
+ if (config.use_env_variable) {
13
+ sequelize = new Sequelize(process.env[config.use_env_variable], config);
14
+ }
15
+ else {
16
+ sequelize = new Sequelize(config.database, config.username, config.password, config);
17
+ }
18
+ fs
19
+ .readdirSync(__dirname)
20
+ .filter(file => {
21
+ return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-4) === '.cjs') && file.startsWith('ac_');
22
+ })
23
+ .forEach(file => {
24
+ // Sequelize V6 style model import
25
+ const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
26
+ db[model.name] = model;
27
+ });
28
+ Object.keys(db).forEach(modelName => {
29
+ if (db[modelName].associate) {
30
+ db[modelName].associate(db);
31
+ }
32
+ });
33
+ db.sequelize = sequelize;
34
+ db.Sequelize = Sequelize;
35
+ module.exports = db;
@@ -0,0 +1,2 @@
1
+ export = db;
2
+ declare const db: typeof import("services/models/index.cjs");
@@ -33,6 +33,14 @@ declare module "models/index.cjs" { // Module path relative to baseUrl ("server_
33
33
  type RatingInstance = ModelInstance<YpRatingData>;
34
34
  type UserInstance = ModelInstance<YpUserData>;
35
35
  type VideoInstance = ModelInstance<YpVideoData>;
36
+ type AcActivityInstance = ModelInstance<AcActivityData>;
37
+ type AcBackgroundJobInstance = ModelInstance<AcBackgroundJobData>;
38
+ type AcClientActivityInstance = ModelInstance<AcClientActivityData>;
39
+ type AcDelayedNotificationInstance = ModelInstance<AcDelayedNotificationData>;
40
+ type AcFollowingInstance = ModelInstance<AcFollowingData>;
41
+ type AcMuteInstance = ModelInstance<AcMuteData>;
42
+ type AcNotificationInstance = ModelInstance<AcNotificationData>;
43
+ type AcTranslationCacheInstance = ModelInstance<AcTranslationCacheData>;
36
44
  // Add other specific instance types if new models are included
37
45
 
38
46
  // --- Interface for the Exported DB Object (local to this module declaration) ---
@@ -58,6 +66,16 @@ declare module "models/index.cjs" { // Module path relative to baseUrl ("server_
58
66
  Rating: ModelStatic<RatingInstance>;
59
67
  User: ModelStatic<UserInstance>;
60
68
  Video: ModelStatic<VideoInstance>;
69
+ AcActivity: ModelStatic<AcActivityInstance>;
70
+ AcBackgroundJob: ModelStatic<AcBackgroundJobInstance>;
71
+ AcCampaign: ModelStatic<AcCampaignInstance>;
72
+ AcClientActivity: ModelStatic<AcClientActivityInstance>;
73
+ AcDelayedNotification: ModelStatic<AcDelayedNotificationInstance>;
74
+ AcFollowing: ModelStatic<AcFollowingInstance>;
75
+ AcMute: ModelStatic<AcMuteInstance>;
76
+ AcNotification: ModelStatic<AcNotificationInstance>;
77
+ AcTranslationCache: ModelStatic<AcTranslationCacheInstance>;
78
+
61
79
  // Add other ModelStatic types as new models are included
62
80
  }
63
81