@resolveio/server-lib 22.2.4 → 22.2.5

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.
@@ -0,0 +1,2 @@
1
+ import { MethodManager } from '../managers/method.manager';
2
+ export declare function loadAppSettingsMethods(methodManager: MethodManager): void;
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.loadAppSettingsMethods = loadAppSettingsMethods;
51
+ var simpl_schema_1 = require("simpl-schema");
52
+ var app_setting_collection_1 = require("../collections/app-setting.collection");
53
+ var common_1 = require("../util/common");
54
+ function loadAppSettingsMethods(methodManager) {
55
+ methodManager.methods({
56
+ appSettingsUpsert: {
57
+ check: new simpl_schema_1.default({
58
+ settings: {
59
+ type: Object,
60
+ blackbox: true
61
+ }
62
+ }),
63
+ function: function (settings) {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ var update, idSetting, existing, now, newIdSetting, insertDoc;
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0:
69
+ update = {
70
+ updatedAt: new Date()
71
+ };
72
+ if (settings.company_name !== undefined) {
73
+ update.company_name = normalizeOptionalString(settings.company_name);
74
+ }
75
+ if (settings.timezone !== undefined) {
76
+ update.timezone = normalizeOptionalString(settings.timezone);
77
+ }
78
+ if (settings.currency !== undefined) {
79
+ update.currency = normalizeOptionalString(settings.currency);
80
+ }
81
+ if (settings.invoice_prefix !== undefined) {
82
+ update.invoice_prefix = normalizeOptionalString(settings.invoice_prefix);
83
+ }
84
+ if (settings.support_email !== undefined) {
85
+ update.support_email = normalizeOptionalString(settings.support_email);
86
+ }
87
+ if (settings.support_phone !== undefined) {
88
+ update.support_phone = normalizeOptionalString(settings.support_phone);
89
+ }
90
+ if (settings.support_address !== undefined) {
91
+ update.support_address = normalizeOptionalString(settings.support_address);
92
+ }
93
+ if (settings.notes !== undefined) {
94
+ update.notes = normalizeOptionalString(settings.notes);
95
+ }
96
+ if (settings.enable_ai !== undefined) {
97
+ update.enable_ai = !!settings.enable_ai;
98
+ }
99
+ if (settings.enable_auto_fix !== undefined) {
100
+ update.enable_auto_fix = !!settings.enable_auto_fix;
101
+ }
102
+ if (settings.enable_slow_query_optimizer !== undefined) {
103
+ update.enable_slow_query_optimizer = !!settings.enable_slow_query_optimizer;
104
+ }
105
+ if (settings.custom_settings !== undefined) {
106
+ update.custom_settings = normalizeCustomSettings(settings.custom_settings);
107
+ }
108
+ if (settings.is_active !== undefined) {
109
+ update.is_active = settings.is_active;
110
+ }
111
+ idSetting = normalizeOptionalString(settings.id_app_setting);
112
+ if (!idSetting) return [3 /*break*/, 2];
113
+ return [4 /*yield*/, app_setting_collection_1.AppSettings.updateOne({ _id: idSetting }, { $set: update })];
114
+ case 1:
115
+ _a.sent();
116
+ return [2 /*return*/, { id_app_setting: idSetting }];
117
+ case 2: return [4 /*yield*/, app_setting_collection_1.AppSettings.findOne({}, { sort: { createdAt: -1 } })];
118
+ case 3:
119
+ existing = _a.sent();
120
+ if (!(existing && existing._id)) return [3 /*break*/, 5];
121
+ return [4 /*yield*/, app_setting_collection_1.AppSettings.updateOne({ _id: existing._id }, { $set: update })];
122
+ case 4:
123
+ _a.sent();
124
+ return [2 /*return*/, { id_app_setting: existing._id }];
125
+ case 5:
126
+ now = new Date();
127
+ newIdSetting = (0, common_1.objectIdHexString)();
128
+ insertDoc = {
129
+ _id: newIdSetting,
130
+ __v: 0,
131
+ company_name: update.company_name || 'New Company',
132
+ timezone: update.timezone,
133
+ currency: update.currency,
134
+ invoice_prefix: update.invoice_prefix,
135
+ support_email: update.support_email,
136
+ support_phone: update.support_phone,
137
+ support_address: update.support_address,
138
+ notes: update.notes,
139
+ enable_ai: update.enable_ai !== undefined ? update.enable_ai : false,
140
+ enable_auto_fix: update.enable_auto_fix !== undefined ? update.enable_auto_fix : true,
141
+ enable_slow_query_optimizer: update.enable_slow_query_optimizer !== undefined ? update.enable_slow_query_optimizer : true,
142
+ custom_settings: update.custom_settings,
143
+ is_active: update.is_active !== undefined ? update.is_active : true,
144
+ createdAt: now,
145
+ updatedAt: now
146
+ };
147
+ return [4 /*yield*/, app_setting_collection_1.AppSettings.insertOne(insertDoc)];
148
+ case 6:
149
+ _a.sent();
150
+ return [2 /*return*/, { id_app_setting: newIdSetting }];
151
+ }
152
+ });
153
+ });
154
+ }
155
+ }
156
+ });
157
+ }
158
+ function normalizeOptionalString(value) {
159
+ var raw = typeof value === 'string' ? value.trim() : '';
160
+ return raw || undefined;
161
+ }
162
+ function normalizeCustomSettings(value) {
163
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
164
+ return {};
165
+ }
166
+ return __assign({}, value);
167
+ }
168
+
169
+ //# sourceMappingURL=app-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/methods/app-settings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,wDA6FC;AAnGD,6CAAwC;AACxC,gFAAoE;AAGpE,yCAAmD;AAEnD,SAAgB,sBAAsB,CAAC,aAA4B;IAClE,aAAa,CAAC,OAAO,CAAC;QACrB,iBAAiB,EAAE;YAClB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,QAAQ,EAAE;oBACT,IAAI,EAAE,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AAC,CAAC,CAAC,IAAI;oCACnE,SAAS,EAAE,GAAG;oCACd,SAAS,EAAE,GAAG;iCACd,CAAC;gCAEF,qBAAM,oCAAW,CAAC,SAAS,CAAC,SAA4B,CAAC,EAAA;;gCAAzD,SAAyD,CAAC;gCAC1D,sBAAO,EAAE,cAAc,EAAE,YAAY,EAAE,EAAC;;;;aACxC;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAU;IAC1C,IAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,OAAO,GAAG,IAAI,SAAS,CAAC;AACzB,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAU;IAC1C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjE,OAAO,EAAE,CAAC;IACX,CAAC;IACD,oBACI,KAAK,EACP;AACH,CAAC","file":"app-settings.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { AppSettings } from '../collections/app-setting.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { AppSettingModel } from '../models/app-setting.model';\nimport { objectIdHexString } from '../util/common';\n\nexport function loadAppSettingsMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tappSettingsUpsert: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tsettings: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(settings: any) {\n\t\t\t\tconst update: Partial<AppSettingModel> & { updatedAt: Date } = {\n\t\t\t\t\tupdatedAt: new Date()\n\t\t\t\t};\n\n\t\t\t\tif (settings.company_name !== undefined) {\n\t\t\t\t\tupdate.company_name = normalizeOptionalString(settings.company_name);\n\t\t\t\t}\n\t\t\t\tif (settings.timezone !== undefined) {\n\t\t\t\t\tupdate.timezone = normalizeOptionalString(settings.timezone);\n\t\t\t\t}\n\t\t\t\tif (settings.currency !== undefined) {\n\t\t\t\t\tupdate.currency = normalizeOptionalString(settings.currency);\n\t\t\t\t}\n\t\t\t\tif (settings.invoice_prefix !== undefined) {\n\t\t\t\t\tupdate.invoice_prefix = normalizeOptionalString(settings.invoice_prefix);\n\t\t\t\t}\n\t\t\t\tif (settings.support_email !== undefined) {\n\t\t\t\t\tupdate.support_email = normalizeOptionalString(settings.support_email);\n\t\t\t\t}\n\t\t\t\tif (settings.support_phone !== undefined) {\n\t\t\t\t\tupdate.support_phone = normalizeOptionalString(settings.support_phone);\n\t\t\t\t}\n\t\t\t\tif (settings.support_address !== undefined) {\n\t\t\t\t\tupdate.support_address = normalizeOptionalString(settings.support_address);\n\t\t\t\t}\n\t\t\t\tif (settings.notes !== undefined) {\n\t\t\t\t\tupdate.notes = normalizeOptionalString(settings.notes);\n\t\t\t\t}\n\t\t\t\tif (settings.enable_ai !== undefined) {\n\t\t\t\t\tupdate.enable_ai = !!settings.enable_ai;\n\t\t\t\t}\n\t\t\t\tif (settings.enable_auto_fix !== undefined) {\n\t\t\t\t\tupdate.enable_auto_fix = !!settings.enable_auto_fix;\n\t\t\t\t}\n\t\t\t\tif (settings.enable_slow_query_optimizer !== undefined) {\n\t\t\t\t\tupdate.enable_slow_query_optimizer = !!settings.enable_slow_query_optimizer;\n\t\t\t\t}\n\t\t\t\tif (settings.custom_settings !== undefined) {\n\t\t\t\t\tupdate.custom_settings = normalizeCustomSettings(settings.custom_settings);\n\t\t\t\t}\n\t\t\t\tif (settings.is_active !== undefined) {\n\t\t\t\t\tupdate.is_active = settings.is_active;\n\t\t\t\t}\n\n\t\t\t\tconst idSetting = normalizeOptionalString(settings.id_app_setting);\n\t\t\t\tif (idSetting) {\n\t\t\t\t\tawait AppSettings.updateOne({ _id: idSetting }, { $set: update });\n\t\t\t\t\treturn { id_app_setting: idSetting };\n\t\t\t\t}\n\n\t\t\t\tconst existing = await AppSettings.findOne({}, { sort: { createdAt: -1 } });\n\t\t\t\tif (existing && existing._id) {\n\t\t\t\t\tawait AppSettings.updateOne({ _id: existing._id }, { $set: update });\n\t\t\t\t\treturn { id_app_setting: existing._id };\n\t\t\t\t}\n\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst newIdSetting = objectIdHexString();\n\t\t\t\tconst insertDoc: Partial<AppSettingModel> = {\n\t\t\t\t\t_id: newIdSetting,\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tcompany_name: update.company_name || 'New Company',\n\t\t\t\t\ttimezone: update.timezone,\n\t\t\t\t\tcurrency: update.currency,\n\t\t\t\t\tinvoice_prefix: update.invoice_prefix,\n\t\t\t\t\tsupport_email: update.support_email,\n\t\t\t\t\tsupport_phone: update.support_phone,\n\t\t\t\t\tsupport_address: update.support_address,\n\t\t\t\t\tnotes: update.notes,\n\t\t\t\t\tenable_ai: update.enable_ai !== undefined ? update.enable_ai : false,\n\t\t\t\t\tenable_auto_fix: update.enable_auto_fix !== undefined ? update.enable_auto_fix : true,\n\t\t\t\t\tenable_slow_query_optimizer: update.enable_slow_query_optimizer !== undefined ? update.enable_slow_query_optimizer : true,\n\t\t\t\t\tcustom_settings: update.custom_settings,\n\t\t\t\t\tis_active: update.is_active !== undefined ? update.is_active : true,\n\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\tupdatedAt: now\n\t\t\t\t};\n\n\t\t\t\tawait AppSettings.insertOne(insertDoc as AppSettingModel);\n\t\t\t\treturn { id_app_setting: newIdSetting };\n\t\t\t}\n\t\t}\n\t});\n}\n\nfunction normalizeOptionalString(value: any): string | undefined {\n\tconst raw = typeof value === 'string' ? value.trim() : '';\n\treturn raw || undefined;\n}\n\nfunction normalizeCustomSettings(value: any): Record<string, any> {\n\tif (!value || typeof value !== 'object' || Array.isArray(value)) {\n\t\treturn {};\n\t}\n\treturn {\n\t\t...value\n\t};\n}\n"]}
package/methods.ts CHANGED
@@ -48,6 +48,9 @@ export function SERVER_METHODS(resolveioServer) {
48
48
  aiTerminalUploadFile: (id_conversation: string, file_name: string, content_base64: string, size: number, content_type?: string, cb?: Function): Promise<any> => {
49
49
  return resolveioServer.call('aiTerminalUploadFile', id_conversation, file_name, content_base64, size, content_type, cb);
50
50
  },
51
+ appSettingsUpsert: (settings: any, cb?: Function): Promise<any> => {
52
+ return resolveioServer.call('appSettingsUpsert', settings, cb);
53
+ },
51
54
  collectionListAll: (cb?: Function): Promise<any> => {
52
55
  return resolveioServer.call('collectionListAll', cb);
53
56
  },
@@ -0,0 +1,16 @@
1
+ import { CollectionDocument } from './collection-document.model';
2
+ export interface AppSettingModel extends CollectionDocument {
3
+ company_name?: string;
4
+ timezone?: string;
5
+ currency?: string;
6
+ invoice_prefix?: string;
7
+ support_email?: string;
8
+ support_phone?: string;
9
+ support_address?: string;
10
+ notes?: string;
11
+ enable_ai?: boolean;
12
+ enable_auto_fix?: boolean;
13
+ enable_slow_query_optimizer?: boolean;
14
+ custom_settings?: Record<string, any>;
15
+ is_active?: boolean;
16
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+
4
+ //# sourceMappingURL=app-setting.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/models/app-setting.model.ts"],"names":[],"mappings":"","file":"app-setting.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface AppSettingModel extends CollectionDocument {\n\tcompany_name?: string;\n\ttimezone?: string;\n\tcurrency?: string;\n\tinvoice_prefix?: string;\n\tsupport_email?: string;\n\tsupport_phone?: string;\n\tsupport_address?: string;\n\tnotes?: string;\n\tenable_ai?: boolean;\n\tenable_auto_fix?: boolean;\n\tenable_slow_query_optimizer?: boolean;\n\tcustom_settings?: Record<string, any>;\n\tis_active?: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "22.2.4",
3
+ "version": "22.2.5",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
package/public_api.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './collections/app-status.collection';
2
+ export * from './collections/app-setting.collection';
2
3
  export * from './collections/ai-terminal-issue-report.collection';
3
4
  export * from './collections/ai-terminal-conversation.collection';
4
5
  export * from './collections/ai-terminal-message.collection';
@@ -29,6 +30,7 @@ export * from './collections/user-guide.collection';
29
30
  export * from './collections/user.collection';
30
31
  export * from './managers/mongo.manager';
31
32
  export * from './models/app-status.model';
33
+ export * from './models/app-setting.model';
32
34
  export * from './models/ai-terminal-issue-report.model';
33
35
  export * from './models/ai-terminal-conversation.model';
34
36
  export * from './models/ai-terminal-message.model';
package/public_api.js CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./collections/app-status.collection"), exports);
18
+ __exportStar(require("./collections/app-setting.collection"), exports);
18
19
  __exportStar(require("./collections/ai-terminal-issue-report.collection"), exports);
19
20
  __exportStar(require("./collections/ai-terminal-conversation.collection"), exports);
20
21
  __exportStar(require("./collections/ai-terminal-message.collection"), exports);
@@ -45,6 +46,7 @@ __exportStar(require("./collections/user-guide.collection"), exports);
45
46
  __exportStar(require("./collections/user.collection"), exports);
46
47
  __exportStar(require("./managers/mongo.manager"), exports);
47
48
  __exportStar(require("./models/app-status.model"), exports);
49
+ __exportStar(require("./models/app-setting.model"), exports);
48
50
  __exportStar(require("./models/ai-terminal-issue-report.model"), exports);
49
51
  __exportStar(require("./models/ai-terminal-conversation.model"), exports);
50
52
  __exportStar(require("./models/ai-terminal-message.model"), exports);
package/public_api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/public_api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAoD;AACpD,oFAAkE;AAClE,oFAAkE;AAClE,+EAA6D;AAC7D,mEAAiD;AACjD,iFAA+D;AAC/D,gFAA8D;AAC9D,4EAA0D;AAC1D,oEAAkD;AAClD,yEAAuD;AACvD,0EAAwD;AACxD,gEAA8C;AAC9C,uEAAqD;AACrD,gEAA8C;AAC9C,8EAA4D;AAC5D,4EAA0D;AAC1D,+DAA6C;AAC7C,2EAAyD;AACzD,uEAAqD;AACrD,4EAA0D;AAC1D,0EAAwD;AACxD,yEAAuD;AACvD,wEAAsD;AACtD,+EAA6D;AAC7D,kFAAgE;AAChE,iFAA+D;AAC/D,sEAAoD;AACpD,sEAAoD;AACpD,gEAA8C;AAC9C,2DAAyC;AACzC,4DAA0C;AAC1C,0EAAwD;AACxD,0EAAwD;AACxD,qEAAmD;AACnD,yEAAuD;AACvD,qEAAmD;AACnD,sEAAoD;AACpD,yDAAuC;AACvC,uEAAqD;AACrD,kEAAgD;AAChD,0DAAwC;AACxC,wDAAsC;AACtC,+DAA6C;AAC7C,gEAA8C;AAC9C,sDAAoC;AACpC,6DAA2C;AAC3C,sDAAoC;AACpC,oEAAkD;AAClD,kEAAgD;AAChD,qDAAmC;AACnC,iEAA+C;AAC/C,iEAA+C;AAC/C,wDAAsC;AACtC,6DAA2C;AAC3C,gEAA8C;AAC9C,+DAA6C;AAC7C,8DAA4C;AAC5C,qEAAmD;AACnD,4DAA0C;AAC1C,4DAA0C;AAC1C,wEAAsD;AACtD,uEAAqD;AACrD,gEAA8C;AAC9C,mEAAiD;AACjD,gEAA8C;AAC9C,8DAA4C;AAC5C,gEAA8C;AAC9C,4DAA0C;AAC1C,4DAA0C;AAC1C,sDAAoC;AACpC,yEAAuD;AACvD,0EAAwD;AACxD,yDAAuC;AACvC,2DAAyC;AACzC,0DAAwC;AACxC,gDAA8B;AAC9B,mDAAiC","file":"public_api.js","sourcesContent":["export * from './collections/app-status.collection';\nexport * from './collections/ai-terminal-issue-report.collection';\nexport * from './collections/ai-terminal-conversation.collection';\nexport * from './collections/ai-terminal-message.collection';\nexport * from './collections/counter.collection';\nexport * from './collections/customer-notification.collection';\nexport * from './collections/communication-metric.collection';\nexport * from './collections/cron-job-history.collection';\nexport * from './collections/cron-job.collection';\nexport * from './collections/email-history.collection';\nexport * from './collections/email-verified.collection';\nexport * from './collections/file.collection';\nexport * from './collections/flag-update.collection';\nexport * from './collections/flag.collection';\nexport * from './collections/log-method-latency.collection';\nexport * from './collections/log-subscription.collection';\nexport * from './collections/log.collection';\nexport * from './collections/logged-in-users.collection';\nexport * from './collections/monitor-cpu.collection';\nexport * from './collections/monitor-function.collection';\nexport * from './collections/monitor-memory.collection';\nexport * from './collections/monitor-mongo.collection';\nexport * from './collections/notification.collection';\nexport * from './collections/openai-usage-ledger.collection';\nexport * from './collections/report-builder-library.collection';\nexport * from './collections/report-builder-report.collection';\nexport * from './collections/user-group.collection';\nexport * from './collections/user-guide.collection';\nexport * from './collections/user.collection';\nexport * from './managers/mongo.manager';\nexport * from './models/app-status.model';\nexport * from './models/ai-terminal-issue-report.model';\nexport * from './models/ai-terminal-conversation.model';\nexport * from './models/ai-terminal-message.model';\nexport * from './models/billing-logged-in-users.model';\nexport * from './models/collection-document.model';\nexport * from './models/communication-metric.model';\nexport * from './models/counter.model';\nexport * from './models/customer-notification.model';\nexport * from './models/cron-job-history.model';\nexport * from './models/cron-job.model';\nexport * from './models/dialog.model';\nexport * from './models/email-history.model';\nexport * from './models/email-verified.model';\nexport * from './models/file.model';\nexport * from './models/flag-update.model';\nexport * from './models/flag.model';\nexport * from './models/log-method-latency.model';\nexport * from './models/log-subscription.model';\nexport * from './models/log.model';\nexport * from './models/logged-in-users.model';\nexport * from './models/method-response.model';\nexport * from './models/method.model';\nexport * from './models/monitor-cpu.model';\nexport * from './models/monitor-memory.model';\nexport * from './models/monitor-mongo.model';\nexport * from './models/notification.model';\nexport * from './models/openai-usage-ledger.model';\nexport * from './models/pagination.model';\nexport * from './models/permission.model';\nexport * from './models/report-builder-library.model';\nexport * from './models/report-builder-report.model';\nexport * from './models/report-builder.model';\nexport * from './models/select-data-label.model';\nexport * from './models/server-message.model';\nexport * from './models/subscription.model';\nexport * from './models/support-ticket.model';\nexport * from './models/user-group.model';\nexport * from './models/user-guide.model';\nexport * from './models/user.model';\nexport * from './managers/openai-usage-ledger.manager';\nexport * from './managers/communication-metric.manager';\nexport * from './resolveio-server-app';\nexport * from './services/openai-client';\nexport * from './services/codex-client';\nexport * from './util/common';\nexport * from './util/tokenizer';\n"]}
1
+ {"version":3,"sources":["../../src/public_api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAoD;AACpD,uEAAqD;AACrD,oFAAkE;AAClE,oFAAkE;AAClE,+EAA6D;AAC7D,mEAAiD;AACjD,iFAA+D;AAC/D,gFAA8D;AAC9D,4EAA0D;AAC1D,oEAAkD;AAClD,yEAAuD;AACvD,0EAAwD;AACxD,gEAA8C;AAC9C,uEAAqD;AACrD,gEAA8C;AAC9C,8EAA4D;AAC5D,4EAA0D;AAC1D,+DAA6C;AAC7C,2EAAyD;AACzD,uEAAqD;AACrD,4EAA0D;AAC1D,0EAAwD;AACxD,yEAAuD;AACvD,wEAAsD;AACtD,+EAA6D;AAC7D,kFAAgE;AAChE,iFAA+D;AAC/D,sEAAoD;AACpD,sEAAoD;AACpD,gEAA8C;AAC9C,2DAAyC;AACzC,4DAA0C;AAC1C,6DAA2C;AAC3C,0EAAwD;AACxD,0EAAwD;AACxD,qEAAmD;AACnD,yEAAuD;AACvD,qEAAmD;AACnD,sEAAoD;AACpD,yDAAuC;AACvC,uEAAqD;AACrD,kEAAgD;AAChD,0DAAwC;AACxC,wDAAsC;AACtC,+DAA6C;AAC7C,gEAA8C;AAC9C,sDAAoC;AACpC,6DAA2C;AAC3C,sDAAoC;AACpC,oEAAkD;AAClD,kEAAgD;AAChD,qDAAmC;AACnC,iEAA+C;AAC/C,iEAA+C;AAC/C,wDAAsC;AACtC,6DAA2C;AAC3C,gEAA8C;AAC9C,+DAA6C;AAC7C,8DAA4C;AAC5C,qEAAmD;AACnD,4DAA0C;AAC1C,4DAA0C;AAC1C,wEAAsD;AACtD,uEAAqD;AACrD,gEAA8C;AAC9C,mEAAiD;AACjD,gEAA8C;AAC9C,8DAA4C;AAC5C,gEAA8C;AAC9C,4DAA0C;AAC1C,4DAA0C;AAC1C,sDAAoC;AACpC,yEAAuD;AACvD,0EAAwD;AACxD,yDAAuC;AACvC,2DAAyC;AACzC,0DAAwC;AACxC,gDAA8B;AAC9B,mDAAiC","file":"public_api.js","sourcesContent":["export * from './collections/app-status.collection';\nexport * from './collections/app-setting.collection';\nexport * from './collections/ai-terminal-issue-report.collection';\nexport * from './collections/ai-terminal-conversation.collection';\nexport * from './collections/ai-terminal-message.collection';\nexport * from './collections/counter.collection';\nexport * from './collections/customer-notification.collection';\nexport * from './collections/communication-metric.collection';\nexport * from './collections/cron-job-history.collection';\nexport * from './collections/cron-job.collection';\nexport * from './collections/email-history.collection';\nexport * from './collections/email-verified.collection';\nexport * from './collections/file.collection';\nexport * from './collections/flag-update.collection';\nexport * from './collections/flag.collection';\nexport * from './collections/log-method-latency.collection';\nexport * from './collections/log-subscription.collection';\nexport * from './collections/log.collection';\nexport * from './collections/logged-in-users.collection';\nexport * from './collections/monitor-cpu.collection';\nexport * from './collections/monitor-function.collection';\nexport * from './collections/monitor-memory.collection';\nexport * from './collections/monitor-mongo.collection';\nexport * from './collections/notification.collection';\nexport * from './collections/openai-usage-ledger.collection';\nexport * from './collections/report-builder-library.collection';\nexport * from './collections/report-builder-report.collection';\nexport * from './collections/user-group.collection';\nexport * from './collections/user-guide.collection';\nexport * from './collections/user.collection';\nexport * from './managers/mongo.manager';\nexport * from './models/app-status.model';\nexport * from './models/app-setting.model';\nexport * from './models/ai-terminal-issue-report.model';\nexport * from './models/ai-terminal-conversation.model';\nexport * from './models/ai-terminal-message.model';\nexport * from './models/billing-logged-in-users.model';\nexport * from './models/collection-document.model';\nexport * from './models/communication-metric.model';\nexport * from './models/counter.model';\nexport * from './models/customer-notification.model';\nexport * from './models/cron-job-history.model';\nexport * from './models/cron-job.model';\nexport * from './models/dialog.model';\nexport * from './models/email-history.model';\nexport * from './models/email-verified.model';\nexport * from './models/file.model';\nexport * from './models/flag-update.model';\nexport * from './models/flag.model';\nexport * from './models/log-method-latency.model';\nexport * from './models/log-subscription.model';\nexport * from './models/log.model';\nexport * from './models/logged-in-users.model';\nexport * from './models/method-response.model';\nexport * from './models/method.model';\nexport * from './models/monitor-cpu.model';\nexport * from './models/monitor-memory.model';\nexport * from './models/monitor-mongo.model';\nexport * from './models/notification.model';\nexport * from './models/openai-usage-ledger.model';\nexport * from './models/pagination.model';\nexport * from './models/permission.model';\nexport * from './models/report-builder-library.model';\nexport * from './models/report-builder-report.model';\nexport * from './models/report-builder.model';\nexport * from './models/select-data-label.model';\nexport * from './models/server-message.model';\nexport * from './models/subscription.model';\nexport * from './models/support-ticket.model';\nexport * from './models/user-group.model';\nexport * from './models/user-guide.model';\nexport * from './models/user.model';\nexport * from './managers/openai-usage-ledger.manager';\nexport * from './managers/communication-metric.manager';\nexport * from './resolveio-server-app';\nexport * from './services/openai-client';\nexport * from './services/codex-client';\nexport * from './util/common';\nexport * from './util/tokenizer';\n"]}
@@ -0,0 +1,2 @@
1
+ import { SubscriptionManager } from '../managers/subscription.manager';
2
+ export declare function loadAppSettingsPublications(subscriptionManager: SubscriptionManager): void;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadAppSettingsPublications = loadAppSettingsPublications;
4
+ var simpl_schema_1 = require("simpl-schema");
5
+ var app_setting_collection_1 = require("../collections/app-setting.collection");
6
+ function loadAppSettingsPublications(subscriptionManager) {
7
+ subscriptionManager.publications({
8
+ appSettings: {
9
+ function: function () {
10
+ return app_setting_collection_1.AppSettings.find({}, { sort: { company_name: 1 } });
11
+ },
12
+ collections: ['app-settings']
13
+ },
14
+ appSettingById: {
15
+ check: new simpl_schema_1.default({
16
+ id_app_setting: {
17
+ type: String
18
+ }
19
+ }),
20
+ function: function (id_app_setting) {
21
+ return app_setting_collection_1.AppSettings.findById(id_app_setting);
22
+ },
23
+ collections: ['app-settings']
24
+ }
25
+ });
26
+ }
27
+
28
+ //# sourceMappingURL=app-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/publications/app-settings.ts"],"names":[],"mappings":";;AAIA,kEAoBC;AAxBD,6CAAwC;AACxC,gFAAoE;AAGpE,SAAgB,2BAA2B,CAAC,mBAAwC;IACnF,mBAAmB,CAAC,YAAY,CAAC;QAChC,WAAW,EAAE;YACZ,QAAQ,EAAE;gBACT,OAAO,oCAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,WAAW,EAAE,CAAC,cAAc,CAAC;SAC7B;QACD,cAAc,EAAE;YACf,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,cAAc,EAAE;oBACf,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,cAAsB;gBACxC,OAAO,oCAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;YAC7C,CAAC;YACD,WAAW,EAAE,CAAC,cAAc,CAAC;SAC7B;KACD,CAAC,CAAC;AACJ,CAAC","file":"app-settings.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { AppSettings } from '../collections/app-setting.collection';\nimport { SubscriptionManager } from '../managers/subscription.manager';\n\nexport function loadAppSettingsPublications(subscriptionManager: SubscriptionManager) {\n\tsubscriptionManager.publications({\n\t\tappSettings: {\n\t\t\tfunction: function() {\n\t\t\t\treturn AppSettings.find({}, { sort: { company_name: 1 } });\n\t\t\t},\n\t\t\tcollections: ['app-settings']\n\t\t},\n\t\tappSettingById: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_app_setting: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(id_app_setting: string) {\n\t\t\t\treturn AppSettings.findById(id_app_setting);\n\t\t\t},\n\t\t\tcollections: ['app-settings']\n\t\t}\n\t});\n}\n"]}
package/publications.ts CHANGED
@@ -8,6 +8,12 @@ export function SERVER_PUBLICATIONS(resolveioServer) {
8
8
  aiTerminalMessages: (id_conversation: string, limit?: number) => {
9
9
  return <Observable<any>> resolveioServer.subscribe('aiTerminalMessages', id_conversation, limit);
10
10
  },
11
+ appSettingById: (id_app_setting: string) => {
12
+ return <Observable<any>> resolveioServer.subscribe('appSettingById', id_app_setting);
13
+ },
14
+ appSettings: () => {
15
+ return <Observable<any>> resolveioServer.subscribe('appSettings');
16
+ },
11
17
  appstatus: () => {
12
18
  return <Observable<any>> resolveioServer.subscribe('appstatus');
13
19
  },