@peopl-health/nexus 4.4.4 → 4.4.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.
|
@@ -3,6 +3,7 @@ const EventEmitter = require('events');
|
|
|
3
3
|
const { airtable } = require('../config/airtableConfig');
|
|
4
4
|
const llmConfigModule = require('../config/llmConfig');
|
|
5
5
|
const { connect } = require('../config/mongoConfig');
|
|
6
|
+
const { setMetaConfig } = require('../config/metaConfig');
|
|
6
7
|
|
|
7
8
|
const { logger } = require('../utils/logger');
|
|
8
9
|
|
|
@@ -101,7 +102,7 @@ class NexusMessaging {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
async initialize(options = {}) {
|
|
104
|
-
const { provider, providerConfig, mongoUri, messageStorage, llm, llmConfig } = options;
|
|
105
|
+
const { provider, providerConfig, mongoUri, messageStorage, llm, llmConfig, meta } = options;
|
|
105
106
|
|
|
106
107
|
if (mongoUri || process.env.MONGODB_URI) {
|
|
107
108
|
await this.initializeMongoDB(mongoUri);
|
|
@@ -112,6 +113,9 @@ class NexusMessaging {
|
|
|
112
113
|
if (llm && llmConfig) {
|
|
113
114
|
this.initializeLLM(llm, llmConfig);
|
|
114
115
|
}
|
|
116
|
+
if (meta) {
|
|
117
|
+
setMetaConfig(meta);
|
|
118
|
+
}
|
|
115
119
|
if (messageStorage) {
|
|
116
120
|
this.setMessageStorage(messageStorage);
|
|
117
121
|
}
|
|
@@ -5,16 +5,8 @@ const { getMetaConfig } = require('../config/metaConfig');
|
|
|
5
5
|
const { logger } = require('../utils/logger');
|
|
6
6
|
const { jsonStringifyWithUnicodeEscapes } = require('../utils/jsonUtils');
|
|
7
7
|
|
|
8
|
-
const requireConfig = () => {
|
|
9
|
-
const config = getMetaConfig();
|
|
10
|
-
if (!config.accessToken || !config.wabaId) {
|
|
11
|
-
throw new Error('Meta API not configured. Call setMetaConfig() first with accessToken and wabaId.');
|
|
12
|
-
}
|
|
13
|
-
return config;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
8
|
const getApiUrl = (path) => {
|
|
17
|
-
const config =
|
|
9
|
+
const config = getMetaConfig();
|
|
18
10
|
return `https://graph.facebook.com/${config.apiVersion}/${path}`;
|
|
19
11
|
};
|
|
20
12
|
|
|
@@ -27,7 +19,7 @@ const errorResult = (error) => ({
|
|
|
27
19
|
});
|
|
28
20
|
|
|
29
21
|
async function createFlowInMeta(flowJSON, name, category = 'OTHER') {
|
|
30
|
-
const config =
|
|
22
|
+
const config = getMetaConfig();
|
|
31
23
|
const categories = Array.isArray(category) ? category : [category];
|
|
32
24
|
|
|
33
25
|
logger.info('[createFlowInMeta] Creating', { name, categories });
|
|
@@ -58,7 +50,7 @@ async function createFlowInMeta(flowJSON, name, category = 'OTHER') {
|
|
|
58
50
|
}
|
|
59
51
|
|
|
60
52
|
async function setFlowEndpoint(flowId, endpointUri, applicationId) {
|
|
61
|
-
const config =
|
|
53
|
+
const config = getMetaConfig();
|
|
62
54
|
|
|
63
55
|
try {
|
|
64
56
|
const response = await axios.post(getApiUrl(flowId), {
|
|
@@ -78,7 +70,7 @@ async function setFlowEndpoint(flowId, endpointUri, applicationId) {
|
|
|
78
70
|
}
|
|
79
71
|
|
|
80
72
|
async function getFlowFromMeta(flowId) {
|
|
81
|
-
const config =
|
|
73
|
+
const config = getMetaConfig();
|
|
82
74
|
|
|
83
75
|
try {
|
|
84
76
|
const response = await axios.get(getApiUrl(flowId), {
|
|
@@ -101,7 +93,7 @@ async function getFlowFromMeta(flowId) {
|
|
|
101
93
|
}
|
|
102
94
|
|
|
103
95
|
async function publishFlowInMeta(flowId) {
|
|
104
|
-
const config =
|
|
96
|
+
const config = getMetaConfig();
|
|
105
97
|
|
|
106
98
|
try {
|
|
107
99
|
const current = await getFlowFromMeta(flowId);
|