@resolveio/server-lib 1.0.0-rc1 → 1.0.0-rc11

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.
Files changed (157) hide show
  1. package/collections/active-subscription.collection.d.ts +8 -0
  2. package/collections/active-subscription.collection.js +68 -1
  3. package/collections/app-status.collection.d.ts +8 -0
  4. package/collections/app-status.collection.js +43 -1
  5. package/collections/app-version.collection.d.ts +8 -0
  6. package/collections/app-version.collection.js +56 -1
  7. package/collections/counter.collection.d.ts +10 -0
  8. package/collections/counter.collection.js +73 -1
  9. package/collections/cron-job-history.collection.d.ts +8 -0
  10. package/collections/cron-job-history.collection.js +86 -1
  11. package/collections/cron-job.collection.d.ts +8 -0
  12. package/collections/cron-job.collection.js +89 -1
  13. package/collections/file.collection.d.ts +10 -0
  14. package/collections/file.collection.js +73 -1
  15. package/collections/flag.collection.d.ts +8 -0
  16. package/collections/flag.collection.js +47 -1
  17. package/collections/log.collection.d.ts +8 -0
  18. package/collections/log.collection.js +64 -1
  19. package/collections/logged-in-users.collection.d.ts +8 -0
  20. package/collections/logged-in-users.collection.js +70 -1
  21. package/collections/method-call.collection.d.ts +7 -0
  22. package/collections/method-call.collection.js +44 -1
  23. package/collections/method-response.collection.d.ts +7 -0
  24. package/collections/method-response.collection.js +48 -1
  25. package/collections/queue-flag.collection.d.ts +8 -0
  26. package/collections/queue-flag.collection.js +41 -1
  27. package/collections/queue-method.collection.d.ts +8 -0
  28. package/collections/queue-method.collection.js +116 -1
  29. package/collections/queue-response.collection.d.ts +8 -0
  30. package/collections/queue-response.collection.js +78 -1
  31. package/collections/support-ticket.collection.d.ts +8 -0
  32. package/collections/support-ticket.collection.js +146 -1
  33. package/collections/user.collection.d.ts +9 -0
  34. package/collections/user.collection.js +108 -1
  35. package/cron/cron.d.ts +6 -0
  36. package/cron/cron.js +160 -1
  37. package/fixtures/cron-jobs.d.ts +2 -0
  38. package/fixtures/cron-jobs.js +72 -1
  39. package/fixtures/init.d.ts +2 -0
  40. package/fixtures/init.js +73 -1
  41. package/http/auth.d.ts +3 -0
  42. package/http/auth.js +472 -1
  43. package/http/health.d.ts +2 -0
  44. package/http/health.js +8 -1
  45. package/index.d.ts +14 -0
  46. package/index.js +120 -1
  47. package/managers/cron.manager.d.ts +17 -0
  48. package/managers/cron.manager.js +193 -1
  49. package/managers/method.manager.d.ts +27 -0
  50. package/managers/method.manager.js +513 -1
  51. package/managers/queue-method.manager.d.ts +14 -0
  52. package/managers/queue-method.manager.js +239 -1
  53. package/managers/subscription.manager.d.ts +27 -0
  54. package/managers/subscription.manager.js +700 -1
  55. package/managers/support.manager.d.ts +18 -0
  56. package/managers/support.manager.js +208 -1
  57. package/methods/accounts.d.ts +3 -0
  58. package/methods/accounts.js +253 -1
  59. package/methods/aws.d.ts +3 -0
  60. package/methods/aws.js +323 -1
  61. package/methods/cloudconvert.d.ts +3 -0
  62. package/methods/cloudconvert.js +37 -1
  63. package/methods/collections.d.ts +3 -0
  64. package/methods/collections.js +738 -1
  65. package/methods/counters.d.ts +3 -0
  66. package/methods/counters.js +404 -1
  67. package/methods/cron-jobs.d.ts +3 -0
  68. package/methods/cron-jobs.js +63 -1
  69. package/methods/flags.d.ts +3 -0
  70. package/methods/flags.js +6 -1
  71. package/methods/logs.d.ts +3 -0
  72. package/methods/logs.js +29 -1
  73. package/methods/pdf.d.ts +3 -0
  74. package/methods/pdf.js +303 -1
  75. package/models/active-subscription.model.d.ts +14 -0
  76. package/models/active-subscription.model.js +2 -1
  77. package/models/app-status.model.d.ts +5 -0
  78. package/models/app-status.model.js +2 -1
  79. package/models/app-version.model.d.ts +5 -0
  80. package/models/app-version.model.js +2 -1
  81. package/models/collection-document.model.d.ts +7 -0
  82. package/models/collection-document.model.js +2 -1
  83. package/models/counter.model.d.ts +6 -0
  84. package/models/counter.model.js +2 -1
  85. package/models/cron-job-history.model.d.ts +13 -0
  86. package/models/cron-job-history.model.js +2 -1
  87. package/models/cron-job.model.d.ts +14 -0
  88. package/models/cron-job.model.js +2 -1
  89. package/models/dialog.model.d.ts +24 -0
  90. package/models/dialog.model.js +2 -1
  91. package/models/file.model.d.ts +10 -0
  92. package/models/file.model.js +2 -1
  93. package/models/flag.model.d.ts +6 -0
  94. package/models/flag.model.js +2 -1
  95. package/models/log.model.d.ts +12 -0
  96. package/models/log.model.js +2 -1
  97. package/models/logged-in-users.model.d.ts +10 -0
  98. package/models/logged-in-users.model.js +2 -1
  99. package/models/method-call.model.d.ts +8 -0
  100. package/models/method-call.model.js +2 -1
  101. package/models/method-response.model.d.ts +9 -0
  102. package/models/method-response.model.js +2 -1
  103. package/models/method.model.d.ts +11 -0
  104. package/models/method.model.js +2 -1
  105. package/models/pagination.model.d.ts +12 -0
  106. package/models/pagination.model.js +20 -1
  107. package/models/permission.model.d.ts +13 -0
  108. package/models/permission.model.js +2 -1
  109. package/models/queue-method.model.d.ts +10 -0
  110. package/models/queue-method.model.js +2 -1
  111. package/models/queue-response.model.d.ts +11 -0
  112. package/models/queue-response.model.js +2 -1
  113. package/models/select-data-label.model.d.ts +10 -0
  114. package/models/select-data-label.model.js +2 -1
  115. package/models/server-response.model.d.ts +6 -0
  116. package/models/server-response.model.js +2 -1
  117. package/models/subscription.model.d.ts +31 -0
  118. package/models/subscription.model.js +2 -1
  119. package/models/support-method.model.d.ts +10 -0
  120. package/models/support-method.model.js +2 -1
  121. package/models/support-ticket.model.d.ts +40 -0
  122. package/models/support-ticket.model.js +2 -1
  123. package/models/user.model.d.ts +15 -0
  124. package/models/user.model.js +2 -1
  125. package/package.json +4 -1
  126. package/publications/app-status.d.ts +3 -0
  127. package/publications/app-status.js +14 -1
  128. package/publications/app-version.d.ts +3 -0
  129. package/publications/app-version.js +14 -1
  130. package/publications/cron-jobs.d.ts +3 -0
  131. package/publications/cron-jobs.js +14 -1
  132. package/publications/files.d.ts +3 -0
  133. package/publications/files.js +71 -1
  134. package/publications/flags.d.ts +3 -0
  135. package/publications/flags.js +23 -1
  136. package/publications/logs.d.ts +3 -0
  137. package/publications/logs.js +26 -1
  138. package/publications/method-calls.d.ts +3 -0
  139. package/publications/method-calls.js +14 -1
  140. package/publications/method-responses.d.ts +3 -0
  141. package/publications/method-responses.js +14 -1
  142. package/publications/super-admin.d.ts +3 -0
  143. package/publications/super-admin.js +21 -1
  144. package/publications/support-tickets.d.ts +2 -0
  145. package/publications/support-tickets.js +118 -1
  146. package/server-app.d.ts +33 -0
  147. package/server-app.js +640 -1
  148. package/support-methods/aws.d.ts +3 -0
  149. package/support-methods/aws.js +276 -1
  150. package/support-methods/collections.d.ts +3 -0
  151. package/support-methods/collections.js +471 -1
  152. package/support-methods/counters.d.ts +3 -0
  153. package/support-methods/counters.js +189 -1
  154. package/support-methods/support.d.ts +3 -0
  155. package/support-methods/support.js +19 -1
  156. package/util/common.d.ts +15 -0
  157. package/util/common.js +334 -1
@@ -1 +1,146 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var mongoose_1=require("mongoose"),simpl_schema_1=require("simpl-schema"),index_1=require("../index"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},type:{type:String},priority:{type:String},issue:{type:String},support_ticket_number:{type:Number},support_ticket_number_string:{type:String},status:{type:String},client:{type:String},id_client:{type:String},messages:{type:Array},"messages.$":{type:Object},"messages.$.message":{type:String},"messages.$.id_user":{type:String},"messages.$.user":{type:String},"messages.$.date":{type:Date},"messages.$.type":{type:String},date_created:{type:Date},date_created_string:{type:String},id_user_created:{type:String},user_created:{type:String},billable:{type:Boolean},work_logs:{type:Array},"work_logs.$":{type:Object},"work_logs.$.note":{type:String},"work_logs.$.id_user":{type:String},"work_logs.$.user":{type:String},"work_logs.$.date_start":{type:Date},"work_logs.$.date_end":{type:Date,optional:!0},"work_logs.$.time_spent":{type:Number,optional:!0},"work_logs.$.time_spent_string":{type:String,optional:!0},date_investigation:{type:Date,optional:!0},date_closed:{type:Date,optional:!0}},DefaultSchema=new mongoose_1.Schema(schema,{skipVersioning:!0,versionKey:!1,timestamps:!0});exports.SupportTickets=null,index_1.getSupportDB()&&(exports.SupportTickets=index_1.getSupportDB().model("support-tickets",DefaultSchema),exports.SupportTickets.simplschema=new simpl_schema_1.default(schema)),schema._id={type:mongoose_1.Schema.Types.Mixed};var VersionSchema=new mongoose_1.Schema(schema,{skipVersioning:!0,versionKey:!1,timestamps:!0});index_1.getSupportDB()&&(exports.SupportTickets.versionCollection="support-tickets.versions"),exports.SupportTicketVersions=null,index_1.getSupportDB()&&(exports.SupportTicketVersions=index_1.getSupportDB().model(exports.SupportTickets.versionCollection,VersionSchema));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mongoose_1 = require("mongoose");
4
+ var simpl_schema_1 = require("simpl-schema");
5
+ var index_1 = require("../index");
6
+ var schema = {
7
+ _id: {
8
+ type: String,
9
+ optional: true
10
+ },
11
+ __v: {
12
+ type: Number,
13
+ optional: true
14
+ },
15
+ updatedAt: {
16
+ type: Date,
17
+ optional: true
18
+ },
19
+ createdAt: {
20
+ type: Date,
21
+ optional: true
22
+ },
23
+ type: {
24
+ type: String
25
+ },
26
+ priority: {
27
+ type: String
28
+ },
29
+ issue: {
30
+ type: String
31
+ },
32
+ support_ticket_number: {
33
+ type: Number
34
+ },
35
+ support_ticket_number_string: {
36
+ type: String
37
+ },
38
+ status: {
39
+ type: String
40
+ },
41
+ client: {
42
+ type: String
43
+ },
44
+ id_client: {
45
+ type: String
46
+ },
47
+ messages: {
48
+ type: Array
49
+ },
50
+ 'messages.$': {
51
+ type: Object
52
+ },
53
+ 'messages.$.message': {
54
+ type: String
55
+ },
56
+ 'messages.$.id_user': {
57
+ type: String
58
+ },
59
+ 'messages.$.user': {
60
+ type: String
61
+ },
62
+ 'messages.$.date': {
63
+ type: Date
64
+ },
65
+ 'messages.$.type': {
66
+ type: String
67
+ },
68
+ date_created: {
69
+ type: Date
70
+ },
71
+ date_created_string: {
72
+ type: String
73
+ },
74
+ id_user_created: {
75
+ type: String
76
+ },
77
+ user_created: {
78
+ type: String
79
+ },
80
+ billable: {
81
+ type: Boolean
82
+ },
83
+ work_logs: {
84
+ type: Array
85
+ },
86
+ 'work_logs.$': {
87
+ type: Object
88
+ },
89
+ 'work_logs.$.note': {
90
+ type: String
91
+ },
92
+ 'work_logs.$.id_user': {
93
+ type: String
94
+ },
95
+ 'work_logs.$.user': {
96
+ type: String
97
+ },
98
+ 'work_logs.$.date_start': {
99
+ type: Date
100
+ },
101
+ 'work_logs.$.date_end': {
102
+ type: Date,
103
+ optional: true
104
+ },
105
+ 'work_logs.$.time_spent': {
106
+ type: Number,
107
+ optional: true
108
+ },
109
+ 'work_logs.$.time_spent_string': {
110
+ type: String,
111
+ optional: true
112
+ },
113
+ date_investigation: {
114
+ type: Date,
115
+ optional: true,
116
+ },
117
+ date_closed: {
118
+ type: Date,
119
+ optional: true,
120
+ }
121
+ };
122
+ var DefaultSchema = new mongoose_1.Schema(schema, {
123
+ skipVersioning: true,
124
+ versionKey: false,
125
+ timestamps: true
126
+ });
127
+ exports.SupportTickets = null;
128
+ if (index_1.ResolveIOServer.getSupportDB()) {
129
+ exports.SupportTickets = index_1.ResolveIOServer.getSupportDB().model('support-tickets', DefaultSchema);
130
+ exports.SupportTickets['simplschema'] = new simpl_schema_1.default(schema);
131
+ }
132
+ schema._id = {
133
+ type: mongoose_1.Schema.Types.Mixed
134
+ };
135
+ var VersionSchema = new mongoose_1.Schema(schema, {
136
+ skipVersioning: true,
137
+ versionKey: false,
138
+ timestamps: true
139
+ });
140
+ if (index_1.ResolveIOServer.getSupportDB()) {
141
+ exports.SupportTickets['versionCollection'] = 'support-tickets.versions';
142
+ }
143
+ exports.SupportTicketVersions = null;
144
+ if (index_1.ResolveIOServer.getSupportDB()) {
145
+ exports.SupportTicketVersions = index_1.ResolveIOServer.getSupportDB().model(exports.SupportTickets['versionCollection'], VersionSchema);
146
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="passport-local-mongoose" />
2
+ import { Model, PassportLocalDocument, PassportLocalModel } from 'mongoose';
3
+ import { UserModel } from '../models/user.model';
4
+ interface ResolveIOModel extends UserModel, PassportLocalDocument {
5
+ }
6
+ export declare const Users: PassportLocalModel<ResolveIOModel>;
7
+ export declare const UserVersions: Model<ResolveIOModel>;
8
+ export {};
9
+ //# sourceMappingURL=user.collection.d.ts.map
@@ -1 +1,108 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var mongoose_1=require("mongoose"),passportLocalMongoose=require("passport-local-mongoose"),simpl_schema_1=require("simpl-schema"),index_1=require("../index"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},readonly:{type:Boolean,optional:!0},active:{type:Boolean},attempts:{type:Number,optional:!0},last:{type:Date,optional:!0},services:{type:Object,optional:!0},"services.enrollment":{type:String,optional:!0},"services.forgot_password":{type:String,optional:!0},"services.reset_password":{type:String,optional:!0},username:{type:String,optional:!0},email:{type:String,optional:!0},fullname:{type:String},roles:{type:Array},"roles.$":{type:String},phonenumber:{type:String,optional:!0},other:{type:Object,blackbox:!0,optional:!0}},DefaultSchema=new mongoose_1.Schema(schema,{skipVersioning:!0,versionKey:!1,timestamps:!0});DefaultSchema.plugin(passportLocalMongoose,{usernameUnique:!0,limitAttempts:!0,maxAttempts:5,findByUsername:function(e,o){return o.active=!0,e.findOne(o)}}),exports.Users=index_1.getMainDB().model("users",DefaultSchema),exports.Users.simplschema=new simpl_schema_1.default(schema),schema._id={type:mongoose_1.Schema.Types.Mixed};var VersionSchema=new mongoose_1.Schema(schema,{skipVersioning:!0,versionKey:!1,timestamps:!0});exports.Users.versionCollection="users.versions",exports.UserVersions=index_1.getMainDB().model(exports.Users.versionCollection,VersionSchema);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mongoose_1 = require("mongoose");
4
+ var passportLocalMongoose = require("passport-local-mongoose");
5
+ var simpl_schema_1 = require("simpl-schema");
6
+ var index_1 = require("../index");
7
+ var schema = {
8
+ _id: {
9
+ type: String,
10
+ optional: true
11
+ },
12
+ __v: {
13
+ type: Number,
14
+ optional: true
15
+ },
16
+ updatedAt: {
17
+ type: Date,
18
+ optional: true
19
+ },
20
+ createdAt: {
21
+ type: Date,
22
+ optional: true
23
+ },
24
+ readonly: {
25
+ type: Boolean,
26
+ optional: true
27
+ },
28
+ active: {
29
+ type: Boolean
30
+ },
31
+ attempts: {
32
+ type: Number,
33
+ optional: true
34
+ },
35
+ last: {
36
+ type: Date,
37
+ optional: true
38
+ },
39
+ services: {
40
+ type: Object,
41
+ optional: true
42
+ },
43
+ 'services.enrollment': {
44
+ type: String,
45
+ optional: true
46
+ },
47
+ 'services.forgot_password': {
48
+ type: String,
49
+ optional: true
50
+ },
51
+ 'services.reset_password': {
52
+ type: String,
53
+ optional: true
54
+ },
55
+ username: {
56
+ type: String,
57
+ optional: true
58
+ },
59
+ email: {
60
+ type: String,
61
+ optional: true
62
+ },
63
+ fullname: {
64
+ type: String
65
+ },
66
+ roles: {
67
+ type: Array
68
+ },
69
+ 'roles.$': {
70
+ type: String
71
+ },
72
+ phonenumber: {
73
+ type: String,
74
+ optional: true
75
+ },
76
+ other: {
77
+ type: Object,
78
+ blackbox: true,
79
+ optional: true
80
+ }
81
+ };
82
+ var DefaultSchema = new mongoose_1.Schema(schema, {
83
+ skipVersioning: true,
84
+ versionKey: false,
85
+ timestamps: true
86
+ });
87
+ DefaultSchema.plugin(passportLocalMongoose, {
88
+ usernameUnique: true,
89
+ limitAttempts: true,
90
+ maxAttempts: 5,
91
+ findByUsername: function (mongooseModel, queryParameters) {
92
+ // Add additional query parameter - AND condition - active: true
93
+ queryParameters.active = true;
94
+ return mongooseModel.findOne(queryParameters);
95
+ }
96
+ });
97
+ exports.Users = index_1.ResolveIOServer.getMainDB().model('users', DefaultSchema);
98
+ exports.Users['simplschema'] = new simpl_schema_1.default(schema);
99
+ schema._id = {
100
+ type: mongoose_1.Schema.Types.Mixed
101
+ };
102
+ var VersionSchema = new mongoose_1.Schema(schema, {
103
+ skipVersioning: true,
104
+ versionKey: false,
105
+ timestamps: true
106
+ });
107
+ exports.Users['versionCollection'] = 'users.versions';
108
+ exports.UserVersions = index_1.ResolveIOServer.getMainDB().model(exports.Users['versionCollection'], VersionSchema);
package/cron/cron.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ declare let CronJob: any;
2
+ declare function CrontabManager(key: any, tab: any, task: any, options: any): void;
3
+ declare function combineOptions(tab: any, task: any, options: any): {};
4
+ declare function updateTab(key: any, cronstring: any): void;
5
+ declare function updateTask(key: any, task: any): void;
6
+ //# sourceMappingURL=cron.d.ts.map
package/cron/cron.js CHANGED
@@ -1 +1,160 @@
1
- var CronJob=require("cron").CronJob;function CrontabManager(o,t,n,r){this.jobs={},o&&t&&n&&this.add(o,t,n,r)}function combineOptions(o,t,n){var r={};if(r.cronTime=o,r.onTick=t,n instanceof Object)for(var e in n)r[e]=n[e];return r}function updateTab(t,o){try{var n=this.jobs[t].running;if(this.jobs[t].stop(),!("string"==typeof o||o instanceof Date))throw new Error("The cron definition passed was not a string or a Date object! "+t+" was stopped and not updated");this.jobs[t]=new CronJob(o,this.jobs[t]._callbacks[0],this.jobs[t].onComplete,n,this.jobs[t].zone)}catch(o){console.error("error updating tab: "+t+" - "+o.message)}}function updateTask(t,o){try{var n=this.jobs[t].running;if(this.jobs[t].stop(),!(o instanceof Function))return void console.error("can't update with something that is not a function: "+typeof o);this.jobs[t]=new CronJob(this.jobs[t].cronTime.source,o,this.jobs[t].onComplete,n,this.jobs[t].zone)}catch(o){console.error("error updating task: "+t+" - "+o.message)}}CrontabManager.prototype.getJob=function(o){return this.jobs[o]},CrontabManager.prototype.getJobs=function(){return Object.keys(this.jobs)},CrontabManager.prototype.add=function(t,n,o,r){if(("string"==typeof n||n instanceof Date)&&"string"==typeof t&&o instanceof Function){r=combineOptions(n,o,r);try{this.jobs[t]&&(this.deleteJob(t),console.warn(t+" already existed and was deleted from the manager...")),this.jobs[t]=new CronJob(r)}catch(o){console.error("crontab: "+n+" possibly not valid, job "+t+" not started..."+o.message)}}else console.warn("couldn't add: "+t+" improper arguments")},CrontabManager.prototype.update=function(){2===arguments.length?"string"==typeof arguments[1]||arguments[1]instanceof Date?updateTab.call(this,arguments[0],arguments[1]):arguments[1]instanceof Function&&updateTask.call(this,arguments[0],arguments[1]):3===arguments.length?(updateTab.call(this,arguments[0],arguments[1]),updateTask.call(this,arguments[0],arguments[2])):console.error("incorrect number of arguents passed to update.. won't update.. "+arguments[0])},CrontabManager.prototype.deleteJob=function(t){try{this.jobs[t].stop(),delete this.jobs[t]}catch(o){console.error("error in trying to stop job: "+t+": "+o)}},CrontabManager.prototype.start=function(t){try{this.jobs[t].running?console.warn(t+" job already running"):this.jobs[t].start()}catch(o){console.error("couldn't start job: "+t+": "+o)}},CrontabManager.prototype.stop=function(t){try{this.jobs[t].running?this.jobs[t].stop():console.warn(t+" job already stopped")}catch(o){console.error("couldn't stop job: "+t+": "+o)}},CrontabManager.prototype.stopAll=function(){for(var o in this.jobs)try{this.jobs[o].stop()}catch(o){}},CrontabManager.prototype.toString=function(){var o="{\n";for(var t in this.jobs)o+="'"+t+"': "+this.jobs[t].cronTime.source+": "+this.jobs[t]._callbacks[0]+": "+(this.jobs[t].running?"Running":"Stopped");return o+="\n}"},CrontabManager.prototype.listCrons=function(){var o="{\n";for(var t in this.jobs)o+="'"+t+"': "+this.jobs[t].cronTime.source+" status: "+(this.jobs[t].running?"Running":"Stopped")+" \n";return o+="\n}"},CrontabManager.prototype.exists=function(o){return!!this.jobs[o]},module.exports=CrontabManager;
1
+ var CronJob = require('cron').CronJob;
2
+ function CrontabManager(key, tab, task, options) {
3
+ this.jobs = {};
4
+ if (key && tab && task) {
5
+ this.add(key, tab, task, options);
6
+ }
7
+ }
8
+ CrontabManager.prototype.getJob = function (key) {
9
+ return this.jobs[key];
10
+ };
11
+ CrontabManager.prototype.getJobs = function () {
12
+ return Object.keys(this.jobs);
13
+ };
14
+ CrontabManager.prototype.add = function (key, tab, task, options) {
15
+ if ((typeof tab === 'string' || tab instanceof Date) && typeof key === 'string' && task instanceof Function) {
16
+ options = combineOptions(tab, task, options);
17
+ try {
18
+ if (this.jobs[key]) {
19
+ this.deleteJob(key);
20
+ console.warn(key + " already existed and was deleted from the manager...");
21
+ }
22
+ this.jobs[key] = new CronJob(options);
23
+ }
24
+ catch (fooBaredByUser) {
25
+ console.error("crontab: " + tab + " possibly not valid, job " + key + " not started..." + fooBaredByUser.message);
26
+ }
27
+ }
28
+ else {
29
+ console.warn("couldn't add: " + key + " improper arguments");
30
+ }
31
+ };
32
+ CrontabManager.prototype.update = function () {
33
+ if (arguments.length === 2) {
34
+ if (typeof arguments[1] === 'string' || arguments[1] instanceof Date) {
35
+ updateTab.call(this, arguments[0], arguments[1]);
36
+ }
37
+ else if (arguments[1] instanceof Function) {
38
+ updateTask.call(this, arguments[0], arguments[1]);
39
+ }
40
+ }
41
+ else if (arguments.length === 3) {
42
+ updateTab.call(this, arguments[0], arguments[1]);
43
+ updateTask.call(this, arguments[0], arguments[2]);
44
+ }
45
+ else {
46
+ console.error("incorrect number of arguents passed to update.. won't update.. " + arguments[0]);
47
+ }
48
+ };
49
+ CrontabManager.prototype.deleteJob = function (key) {
50
+ try {
51
+ this.jobs[key].stop();
52
+ delete this.jobs[key];
53
+ }
54
+ catch (err) {
55
+ console.error("error in trying to stop job: " + key + ": " + err);
56
+ }
57
+ };
58
+ CrontabManager.prototype.start = function (key) {
59
+ try {
60
+ if (this.jobs[key].running) {
61
+ console.warn(key + " job already running");
62
+ }
63
+ else {
64
+ this.jobs[key].start();
65
+ }
66
+ }
67
+ catch (err) {
68
+ console.error("couldn't start job: " + key + ": " + err);
69
+ }
70
+ };
71
+ CrontabManager.prototype.stop = function (key) {
72
+ try {
73
+ if (!this.jobs[key].running) {
74
+ console.warn(key + " job already stopped");
75
+ }
76
+ else {
77
+ this.jobs[key].stop();
78
+ }
79
+ }
80
+ catch (err) {
81
+ console.error("couldn't stop job: " + key + ": " + err);
82
+ }
83
+ };
84
+ CrontabManager.prototype.stopAll = function () {
85
+ // tslint:disable-next-line:forin
86
+ for (var jobKey in this.jobs) {
87
+ try {
88
+ this.jobs[jobKey].stop();
89
+ }
90
+ catch (err) {
91
+ }
92
+ }
93
+ };
94
+ CrontabManager.prototype.toString = function () {
95
+ var manString = '{\n';
96
+ // tslint:disable-next-line:forin
97
+ for (var jobKey in this.jobs) {
98
+ manString += "'" + jobKey + "': " + this.jobs[jobKey].cronTime.source + ": " + this.jobs[jobKey]._callbacks[0] + ": " + (this.jobs[jobKey].running ? 'Running' : 'Stopped');
99
+ }
100
+ manString += '\n}';
101
+ return manString;
102
+ };
103
+ CrontabManager.prototype.listCrons = function () {
104
+ var manString = '{\n';
105
+ // tslint:disable-next-line:forin
106
+ for (var jobKey in this.jobs) {
107
+ manString += "'" + jobKey + "': " + this.jobs[jobKey].cronTime.source + " status: " + (this.jobs[jobKey].running ? 'Running' : 'Stopped') + " \n";
108
+ }
109
+ manString += '\n}';
110
+ return manString;
111
+ };
112
+ CrontabManager.prototype.exists = function (tabKey) {
113
+ if (this.jobs[tabKey]) {
114
+ return true;
115
+ }
116
+ return false;
117
+ };
118
+ function combineOptions(tab, task, options) {
119
+ var newOpts = {};
120
+ newOpts['cronTime'] = tab;
121
+ newOpts['onTick'] = task;
122
+ if (options instanceof Object) {
123
+ // might overwrite... please be careful.
124
+ // tslint:disable-next-line:forin
125
+ for (var optionKey in options) {
126
+ newOpts[optionKey] = options[optionKey];
127
+ }
128
+ }
129
+ return newOpts;
130
+ }
131
+ function updateTab(key, cronstring) {
132
+ try {
133
+ var running = this.jobs[key].running;
134
+ this.jobs[key].stop();
135
+ if (typeof cronstring === 'string' || cronstring instanceof Date) {
136
+ this.jobs[key] = new CronJob(cronstring, this.jobs[key]._callbacks[0], this.jobs[key].onComplete, running, this.jobs[key].zone);
137
+ }
138
+ else {
139
+ throw new Error("The cron definition passed was not a string or a Date object! " + key + " was stopped and not updated");
140
+ }
141
+ }
142
+ catch (tabErr) {
143
+ console.error("error updating tab: " + key + " - " + tabErr.message);
144
+ }
145
+ }
146
+ function updateTask(key, task) {
147
+ try {
148
+ var running = this.jobs[key].running;
149
+ this.jobs[key].stop();
150
+ if (!(task instanceof Function)) {
151
+ console.error("can't update with something that is not a function: " + typeof (task));
152
+ return;
153
+ }
154
+ this.jobs[key] = new CronJob(this.jobs[key].cronTime.source, task, this.jobs[key].onComplete, running, this.jobs[key].zone);
155
+ }
156
+ catch (tabErr) {
157
+ console.error("error updating task: " + key + " - " + tabErr.message);
158
+ }
159
+ }
160
+ module.exports = CrontabManager;
@@ -0,0 +1,2 @@
1
+ export declare function loadServerCronJobs(): Promise<void>;
2
+ //# sourceMappingURL=cron-jobs.d.ts.map
@@ -1 +1,72 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(i,a,c,u){return new(c||(c=Promise))(function(e,n){function t(e){try{o(u.next(e))}catch(e){n(e)}}function r(e){try{o(u.throw(e))}catch(e){n(e)}}function o(n){n.done?e(n.value):new c(function(e){e(n.value)}).then(t,r)}o((u=u.apply(i,a||[])).next())})},__generator=this&&this.__generator||function(t,r){var o,i,a,e,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return e={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function n(n){return function(e){return function(n){if(o)throw new TypeError("Generator is already executing.");for(;c;)try{if(o=1,i&&(a=2&n[0]?i.return:n[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[2&n[0],a.value]),n[0]){case 0:case 1:a=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,i=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){c.label=n[1];break}if(6===n[0]&&c.label<a[1]){c.label=a[1],a=n;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(n);break}a[2]&&c.ops.pop(),c.trys.pop();continue}n=r.call(t,c)}catch(e){n=[6,e],i=0}finally{o=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,e])}}};Object.defineProperty(exports,"__esModule",{value:!0});var cron_job_collection_1=require("../collections/cron-job.collection"),mongoose_1=require("mongoose");function loadServerCronJobs(){return __awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(e){switch(e.label){case 0:return[4,cron_job_collection_1.CronJobs.find({}).exec()];case 1:return(n=e.sent()).filter(function(e){return"Method Queue"===e.name}).length?[3,3]:[4,cron_job_collection_1.CronJobs.create({_id:mongoose_1.Types.ObjectId().toHexString(),__v:0,name:"Method Queue",reoccuring:!0,time_to_run:"*/5 * * * * *",method_name:"emailUpdatedChemicalRequests",last_run:new Date,next_run:new Date,running:!1})];case 2:e.sent(),e.label=3;case 3:return n.filter(function(e){return e.running&&e.next_run&&e.next_run.getTime()<(new Date).getTime()}).forEach(function(e){cron_job_collection_1.CronJobs.updateOne({_id:e._id},{$set:{running:!1}}).exec()}),[2]}})})}exports.loadServerCronJobs=loadServerCronJobs;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ var cron_job_collection_1 = require("../collections/cron-job.collection");
39
+ var mongoose_1 = require("mongoose");
40
+ function loadServerCronJobs() {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var cronJobs;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0: return [4 /*yield*/, cron_job_collection_1.CronJobs.find({}).exec()];
46
+ case 1:
47
+ cronJobs = _a.sent();
48
+ if (!!cronJobs.filter(function (a) { return a.name === 'Method Queue'; }).length) return [3 /*break*/, 3];
49
+ return [4 /*yield*/, cron_job_collection_1.CronJobs.create({
50
+ _id: mongoose_1.Types.ObjectId().toHexString(),
51
+ __v: 0,
52
+ name: 'Method Queue',
53
+ reoccuring: true,
54
+ time_to_run: '*/5 * * * * *',
55
+ method_name: 'emailUpdatedChemicalRequests',
56
+ last_run: new Date,
57
+ next_run: new Date,
58
+ running: false
59
+ })];
60
+ case 2:
61
+ _a.sent();
62
+ _a.label = 3;
63
+ case 3:
64
+ cronJobs.filter(function (a) { return a.running && a.next_run && a.next_run.getTime() < (new Date()).getTime(); }).forEach(function (cronJob) {
65
+ cron_job_collection_1.CronJobs.updateOne({ _id: cronJob._id }, { $set: { running: false } }).exec();
66
+ });
67
+ return [2 /*return*/];
68
+ }
69
+ });
70
+ });
71
+ }
72
+ exports.loadServerCronJobs = loadServerCronJobs;
@@ -0,0 +1,2 @@
1
+ export declare function loadServerInit(): Promise<void>;
2
+ //# sourceMappingURL=init.d.ts.map
package/fixtures/init.js CHANGED
@@ -1 +1,73 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(i,c,l,s){return new(l||(l=Promise))(function(e,n){function t(e){try{r(s.next(e))}catch(e){n(e)}}function o(e){try{r(s.throw(e))}catch(e){n(e)}}function r(n){n.done?e(n.value):new l(function(e){e(n.value)}).then(t,o)}r((s=s.apply(i,c||[])).next())})},__generator=this&&this.__generator||function(t,o){var r,i,c,e,l={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]};return e={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function n(n){return function(e){return function(n){if(r)throw new TypeError("Generator is already executing.");for(;l;)try{if(r=1,i&&(c=2&n[0]?i.return:n[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,n[1])).done)return c;switch(i=0,c&&(n=[2&n[0],c.value]),n[0]){case 0:case 1:c=n;break;case 4:return l.label++,{value:n[1],done:!1};case 5:l.label++,i=n[1],n=[0];continue;case 7:n=l.ops.pop(),l.trys.pop();continue;default:if(!(c=0<(c=l.trys).length&&c[c.length-1])&&(6===n[0]||2===n[0])){l=0;continue}if(3===n[0]&&(!c||n[1]>c[0]&&n[1]<c[3])){l.label=n[1];break}if(6===n[0]&&l.label<c[1]){l.label=c[1],c=n;break}if(c&&l.label<c[2]){l.label=c[2],l.ops.push(n);break}c[2]&&l.ops.pop(),l.trys.pop();continue}n=o.call(t,l)}catch(e){n=[6,e],i=0}finally{r=c=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,e])}}};Object.defineProperty(exports,"__esModule",{value:!0});var app_version_collection_1=require("../collections/app-version.collection"),logged_in_users_collection_1=require("../collections/logged-in-users.collection"),active_subscription_collection_1=require("../collections/active-subscription.collection"),mongoose_1=require("mongoose");function loadServerInit(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,app_version_collection_1.AppVersions.findOne()];case 1:return e.sent()||app_version_collection_1.AppVersions.create({_id:mongoose_1.Types.ObjectId().toHexString(),version:1}),[4,logged_in_users_collection_1.LoggedInUsers.find({})];case 2:return e.sent().forEach(function(e){logged_in_users_collection_1.LoggedInUsers.deleteOne({_id:e._id}).exec()}),[4,active_subscription_collection_1.ActiveSubscriptions.find({})];case 3:return e.sent().forEach(function(e){active_subscription_collection_1.ActiveSubscriptions.deleteOne({_id:e._id}).exec()}),[2]}})})}exports.loadServerInit=loadServerInit;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ var app_version_collection_1 = require("../collections/app-version.collection");
39
+ var logged_in_users_collection_1 = require("../collections/logged-in-users.collection");
40
+ var active_subscription_collection_1 = require("../collections/active-subscription.collection");
41
+ var mongoose_1 = require("mongoose");
42
+ function loadServerInit() {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var appVersion, loggedInUsers, activeSubs;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, app_version_collection_1.AppVersions.findOne()];
48
+ case 1:
49
+ appVersion = _a.sent();
50
+ if (!appVersion) {
51
+ app_version_collection_1.AppVersions.create({
52
+ _id: mongoose_1.Types.ObjectId().toHexString(),
53
+ version: 1
54
+ });
55
+ }
56
+ return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.find({})];
57
+ case 2:
58
+ loggedInUsers = _a.sent();
59
+ loggedInUsers.forEach(function (loggedInUser) {
60
+ logged_in_users_collection_1.LoggedInUsers.deleteOne({ _id: loggedInUser._id }).exec();
61
+ });
62
+ return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.find({})];
63
+ case 3:
64
+ activeSubs = _a.sent();
65
+ activeSubs.forEach(function (sub) {
66
+ active_subscription_collection_1.ActiveSubscriptions.deleteOne({ _id: sub._id }).exec();
67
+ });
68
+ return [2 /*return*/];
69
+ }
70
+ });
71
+ });
72
+ }
73
+ exports.loadServerInit = loadServerInit;
package/http/auth.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import ResolveIOMainServer from '../server-app';
2
+ export declare function setupAuthRoutes(mainServer: ResolveIOMainServer, app: any, serverConfig: any): void;
3
+ //# sourceMappingURL=auth.d.ts.map