@onereach/idw-init-account-resources 0.19.2 → 0.19.3
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/assets/db_migrations/20250103134909-create-idw-graph.js +41 -15
- package/dist/assets/db_migrations/20250103134909-create-idw-graph.js.map +1 -1
- package/dist/assets/db_migrations/20250623160622-add_skill_info_to_feedback_table.js +1 -1
- package/dist/assets/db_migrations/20250623160622-add_skill_info_to_feedback_table.js.map +1 -1
- package/dist/assets/db_migrations/20250624113914-move-info-from-orbes-to-rdb.js +77 -37
- package/dist/assets/db_migrations/20250624113914-move-info-from-orbes-to-rdb.js.map +1 -1
- package/dist/assets/db_migrations/20250801134909-create-MCP-graphs.js +50 -14
- package/dist/assets/db_migrations/20250801134909-create-MCP-graphs.js.map +1 -1
- package/dist/assets/db_migrations/20250818113914-add-mcp-url.js +43 -17
- package/dist/assets/db_migrations/20250818113914-add-mcp-url.js.map +1 -1
- package/dist/assets/db_migrations/20251014120039-add-domain-image.js +4 -2
- package/dist/assets/db_migrations/20251014120039-add-domain-image.js.map +1 -1
- package/dist/assets/db_migrations/20251110102751-move-account-settings-to-kv-settings.js +2 -1
- package/dist/assets/db_migrations/20251110102751-move-account-settings-to-kv-settings.js.map +1 -1
- package/dist/assets/db_migrations/20251117171755-sync-graph.js +32 -8
- package/dist/assets/db_migrations/20251117171755-sync-graph.js.map +1 -1
- package/dist/assets/db_migrations/20251124123410-create-collect-information-skill-tables.js +1 -1
- package/dist/assets/db_migrations/20251124123410-create-collect-information-skill-tables.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/db_migrations/20250103134909-create-idw-graph.ts +49 -15
- package/src/assets/db_migrations/20250623160622-add_skill_info_to_feedback_table.ts +3 -3
- package/src/assets/db_migrations/20250624113914-move-info-from-orbes-to-rdb.ts +90 -45
- package/src/assets/db_migrations/20250801134909-create-MCP-graphs.ts +56 -20
- package/src/assets/db_migrations/20250818113914-add-mcp-url.ts +46 -16
- package/src/assets/db_migrations/20251014120039-add-domain-image.ts +5 -1
- package/src/assets/db_migrations/20251110102751-move-account-settings-to-kv-settings.ts +3 -1
- package/src/assets/db_migrations/20251117171755-sync-graph.ts +39 -11
- package/src/assets/db_migrations/20251124123410-create-collect-information-skill-tables.ts +4 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
WARN Issue while reading "/builds/onereach/platform/idw/idw-template/.npmrc". Failed to replace env in config: ${OR_NPM_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @onereach/idw-init-account-resources@0.19.
|
|
3
|
+
> @onereach/idw-init-account-resources@0.19.2 build /builds/onereach/platform/idw/idw-template/packages/level-system/idw-init-account-resources
|
|
4
4
|
> rimraf dist && tsc -b && mkdir dist/assets/skills/documentation && cp -r src/assets/skills/documentation/* dist/assets/skills/documentation
|
|
5
5
|
|
package/CHANGELOG.md
CHANGED
|
@@ -40,25 +40,51 @@ var graph_1 = require("@or-sdk/graph");
|
|
|
40
40
|
module.exports = {
|
|
41
41
|
up: function (queryInterface) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var graphApi, graphs,
|
|
44
|
-
return __generator(this, function (
|
|
45
|
-
switch (
|
|
43
|
+
var _a, discoveryUrl, _orToken, response, services, graphService, graphUrl, graphApi, graphName_1, graphs, idwGraph, error_1;
|
|
44
|
+
return __generator(this, function (_b) {
|
|
45
|
+
switch (_b.label) {
|
|
46
46
|
case 0:
|
|
47
|
+
_a = queryInterface.context, discoveryUrl = _a.discoveryUrl, _orToken = _a._orToken;
|
|
48
|
+
_b.label = 1;
|
|
49
|
+
case 1:
|
|
50
|
+
_b.trys.push([1, 7, , 8]);
|
|
51
|
+
return [4, fetch("".concat(discoveryUrl, "/api/v2/services"))];
|
|
52
|
+
case 2:
|
|
53
|
+
response = _b.sent();
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
throw new Error("Failed to fetch services: ".concat(response.statusText));
|
|
56
|
+
}
|
|
57
|
+
return [4, response.json()];
|
|
58
|
+
case 3:
|
|
59
|
+
services = (_b.sent()).services;
|
|
60
|
+
graphService = services.find(function (service) { return service.serviceKey === 'graphs-api'; });
|
|
61
|
+
if (!graphService) {
|
|
62
|
+
throw new Error('Service \'graphs-api\' not found in discovery services.');
|
|
63
|
+
}
|
|
64
|
+
graphUrl = graphService.url;
|
|
47
65
|
graphApi = new graph_1.Graphs({
|
|
48
|
-
graphUrl:
|
|
49
|
-
token:
|
|
66
|
+
graphUrl: graphUrl,
|
|
67
|
+
token: _orToken,
|
|
50
68
|
});
|
|
69
|
+
graphName_1 = 'idw';
|
|
51
70
|
return [4, graphApi.listGraphs()];
|
|
52
|
-
case
|
|
53
|
-
graphs =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return [4, graphApi.createGraph({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
case 4:
|
|
72
|
+
graphs = _b.sent();
|
|
73
|
+
idwGraph = graphs.items.find(function (graph) { return graph.name === graphName_1; });
|
|
74
|
+
if (!!idwGraph) return [3, 6];
|
|
75
|
+
console.log("".concat(graphName_1, " not found. Start creating graph..."));
|
|
76
|
+
return [4, graphApi.createGraph({
|
|
77
|
+
name: graphName_1,
|
|
78
|
+
})];
|
|
79
|
+
case 5:
|
|
80
|
+
_b.sent();
|
|
81
|
+
_b.label = 6;
|
|
82
|
+
case 6: return [3, 8];
|
|
83
|
+
case 7:
|
|
84
|
+
error_1 = _b.sent();
|
|
85
|
+
console.error('Migration failed with detailed error:', error_1.message);
|
|
86
|
+
throw error_1;
|
|
87
|
+
case 8: return [2];
|
|
62
88
|
}
|
|
63
89
|
});
|
|
64
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250103134909-create-idw-graph.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250103134909-create-idw-graph.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"20250103134909-create-idw-graph.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250103134909-create-idw-graph.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,uCAA8C;AAQ9C,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAA+G;;;;;;wBAChH,KAA6B,cAAc,CAAC,OAAO,EAAjD,YAAY,kBAAA,EAAE,QAAQ,cAAA,CAA4B;;;;wBAGvC,WAAM,KAAK,CAAC,UAAG,YAAY,qBAAkB,CAAC,EAAA;;wBAAzD,QAAQ,GAAG,SAA8C;wBAE/D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;4BAEjB,MAAM,IAAI,KAAK,CAAC,oCAA6B,QAAQ,CAAC,UAAU,CAAE,CAAC,CAAC;wBACtE,CAAC;wBAEoB,WAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAAlC,QAAQ,GAAK,CAAA,SAAqB,CAAA,SAA1B;wBACV,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAC,OAAyB,IAAK,OAAA,OAAO,CAAC,UAAU,KAAK,YAAY,EAAnC,CAAmC,CAAC,CAAC;wBAEvG,IAAI,CAAC,YAAY,EAAE,CAAC;4BAElB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;wBAC7E,CAAC;wBAEK,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC;wBAE5B,QAAQ,GAAG,IAAI,cAAM,CAAC;4BAC1B,QAAQ,UAAA;4BACR,KAAK,EAAE,QAAQ;yBAChB,CAAC,CAAC;wBAEG,cAAY,KAAK,CAAC;wBAET,WAAM,QAAQ,CAAC,UAAU,EAAE,EAAA;;wBAApC,MAAM,GAAG,SAA2B;wBACpC,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,UAAC,KAAY,IAAK,OAAA,KAAK,CAAC,IAAI,KAAK,WAAS,EAAxB,CAAwB,CAAC,CAAC;6BAE3E,CAAC,QAAQ,EAAT,cAAS;wBAEX,OAAO,CAAC,GAAG,CAAC,UAAG,WAAS,wCAAqC,CAAC,CAAC;wBAE/D,WAAM,QAAQ,CAAC,WAAW,CAAC;gCACzB,IAAI,EAAE,WAAS;6BAChB,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;wBAIL,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAG,OAAe,CAAC,OAAO,CAAC,CAAC;wBAEjF,MAAM,OAAK,CAAC;;;;;KAEf;IAEK,IAAI;;;;;;KAOT;CACF,CAAC"}
|
|
@@ -41,7 +41,7 @@ module.exports = {
|
|
|
41
41
|
return __awaiter(this, void 0, void 0, function () {
|
|
42
42
|
return __generator(this, function (_a) {
|
|
43
43
|
switch (_a.label) {
|
|
44
|
-
case 0: return [4, queryInterface.context.sequelize.query("\n ALTER TABLE feedback\n ADD COLUMN skill_rate text,\n ADD COLUMN skill_name text,\n ADD COLUMN skill_feedback text;\n ")];
|
|
44
|
+
case 0: return [4, queryInterface.context.sequelize.query("\n ALTER TABLE feedback\n ADD COLUMN IF NOT EXISTS skill_rate text,\n ADD COLUMN IF NOT EXISTS skill_name text,\n ADD COLUMN IF NOT EXISTS skill_feedback text;\n ")];
|
|
45
45
|
case 1:
|
|
46
46
|
_a.sent();
|
|
47
47
|
return [2];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250623160622-add_skill_info_to_feedback_table.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250623160622-add_skill_info_to_feedback_table.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIb,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAAwE;;;;4BAC/E,WAAM,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"20250623160622-add_skill_info_to_feedback_table.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250623160622-add_skill_info_to_feedback_table.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIb,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAAwE;;;;4BAC/E,WAAM,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,2LAK5C,CAAC,EAAA;;wBALF,SAKE,CAAC;;;;;KACJ;IAEK,IAAI,YAAC,cAAwE;;;;4BACjF,WAAM,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,mKAK5C,CAAC,EAAA;;wBALF,SAKE,CAAC;;;;;KACJ;CACF,CAAC"}
|
|
@@ -50,26 +50,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
module.exports = {
|
|
51
51
|
up: function (queryInterface) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
var services, sdkApiUrl, idwApiUrl, accountId,
|
|
54
|
-
return __generator(this, function (
|
|
55
|
-
switch (
|
|
56
|
-
case 0:
|
|
53
|
+
var _a, discoveryUrl, _orToken, response, services, sdkService, idwService, sdkApiUrl, idwApiUrl, authResponse, accountId, userResponse, _b, name_1, description, role, avatar, newValue, storageGetUrl, storageGetResponse, existingSettings, storageData, updateResponse, error_1;
|
|
54
|
+
return __generator(this, function (_c) {
|
|
55
|
+
switch (_c.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
_a = queryInterface.context, discoveryUrl = _a.discoveryUrl, _orToken = _a._orToken;
|
|
58
|
+
_c.label = 1;
|
|
57
59
|
case 1:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
idwApiUrl = services.find(function (service) { return service.serviceKey === 'idw-api'; }).url;
|
|
61
|
-
return [4, fetch("".concat(sdkApiUrl, "/auth/token"), {
|
|
62
|
-
headers: {
|
|
63
|
-
Authorization: queryInterface.context._orToken,
|
|
64
|
-
},
|
|
65
|
-
}).then(function (res) { return res.json(); })];
|
|
60
|
+
_c.trys.push([1, 12, , 13]);
|
|
61
|
+
return [4, fetch("".concat(discoveryUrl, "/api/v2/services"))];
|
|
66
62
|
case 2:
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
response = _c.sent();
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw new Error("Failed to fetch services: ".concat(response.statusText));
|
|
66
|
+
}
|
|
67
|
+
return [4, response.json()];
|
|
69
68
|
case 3:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
services = (_c.sent()).services;
|
|
70
|
+
sdkService = services.find(function (service) { return service.serviceKey === 'sdk-api'; });
|
|
71
|
+
idwService = services.find(function (service) { return service.serviceKey === 'idw-api'; });
|
|
72
|
+
if (!sdkService || !idwService) {
|
|
73
|
+
throw new Error("Required services missing: sdk-api (".concat(!!sdkService, "), idw-api (").concat(!!idwService, ")"));
|
|
74
|
+
}
|
|
75
|
+
sdkApiUrl = sdkService.url;
|
|
76
|
+
idwApiUrl = idwService.url;
|
|
77
|
+
return [4, fetch("".concat(sdkApiUrl, "/auth/token"), {
|
|
78
|
+
headers: { Authorization: _orToken },
|
|
79
|
+
})];
|
|
80
|
+
case 4:
|
|
81
|
+
authResponse = _c.sent();
|
|
82
|
+
if (!authResponse.ok) {
|
|
83
|
+
throw new Error('Failed to fetch auth token info');
|
|
84
|
+
}
|
|
85
|
+
return [4, authResponse.json()];
|
|
86
|
+
case 5:
|
|
87
|
+
accountId = (_c.sent()).accountId;
|
|
88
|
+
return [4, fetch("".concat(idwApiUrl, "/user/info?accountId=").concat(accountId))];
|
|
89
|
+
case 6:
|
|
90
|
+
userResponse = _c.sent();
|
|
91
|
+
if (!userResponse.ok) {
|
|
92
|
+
throw new Error('Failed to fetch user info');
|
|
93
|
+
}
|
|
94
|
+
return [4, userResponse.json()];
|
|
95
|
+
case 7:
|
|
96
|
+
_b = _c.sent(), name_1 = _b.name, description = _b.description, role = _b.role, avatar = _b.avatar;
|
|
97
|
+
newValue = {
|
|
98
|
+
name: name_1 || '',
|
|
73
99
|
description: description || '',
|
|
74
100
|
role: role || '',
|
|
75
101
|
avatar: avatar || '',
|
|
@@ -79,26 +105,40 @@ module.exports = {
|
|
|
79
105
|
logo: '',
|
|
80
106
|
},
|
|
81
107
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
existingSettings =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
storageGetUrl = "".concat(sdkApiUrl, "/storage/idw-settings/all?exists=false");
|
|
109
|
+
return [4, fetch(storageGetUrl, {
|
|
110
|
+
headers: { Authorization: _orToken },
|
|
111
|
+
})];
|
|
112
|
+
case 8:
|
|
113
|
+
storageGetResponse = _c.sent();
|
|
114
|
+
existingSettings = {};
|
|
115
|
+
if (!storageGetResponse.ok) return [3, 10];
|
|
116
|
+
return [4, storageGetResponse.json()];
|
|
117
|
+
case 9:
|
|
118
|
+
storageData = _c.sent();
|
|
119
|
+
existingSettings = storageData.value || {};
|
|
120
|
+
_c.label = 10;
|
|
121
|
+
case 10: return [4, fetch("".concat(sdkApiUrl, "/storage/idw-settings/all"), {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
headers: {
|
|
124
|
+
Authorization: _orToken,
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify({
|
|
128
|
+
value: __assign(__assign({}, newValue), existingSettings),
|
|
129
|
+
}),
|
|
130
|
+
})];
|
|
131
|
+
case 11:
|
|
132
|
+
updateResponse = _c.sent();
|
|
133
|
+
if (!updateResponse.ok) {
|
|
134
|
+
throw new Error("Failed to update settings: ".concat(updateResponse.statusText));
|
|
135
|
+
}
|
|
136
|
+
return [3, 13];
|
|
137
|
+
case 12:
|
|
138
|
+
error_1 = _c.sent();
|
|
139
|
+
console.error('Migration failed with detailed error:', error_1.message);
|
|
140
|
+
throw error_1;
|
|
141
|
+
case 13: return [2];
|
|
102
142
|
}
|
|
103
143
|
});
|
|
104
144
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250624113914-move-info-from-orbes-to-rdb.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250624113914-move-info-from-orbes-to-rdb.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASb,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAA+G
|
|
1
|
+
{"version":3,"file":"20250624113914-move-info-from-orbes-to-rdb.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250624113914-move-info-from-orbes-to-rdb.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASb,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAA+G;;;;;;wBAChH,KAA6B,cAAc,CAAC,OAAO,EAAjD,YAAY,kBAAA,EAAE,QAAQ,cAAA,CAA4B;;;;wBAGvC,WAAM,KAAK,CAAC,UAAG,YAAY,qBAAkB,CAAC,EAAA;;wBAAzD,QAAQ,GAAG,SAA8C;wBAE/D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;4BAEjB,MAAM,IAAI,KAAK,CAAC,oCAA6B,QAAQ,CAAC,UAAU,CAAE,CAAC,CAAC;wBACtE,CAAC;wBAEoB,WAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAAlC,QAAQ,GAAK,CA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AAC;;;;;KAEf;IAEK,IAAI;;;;;;KAOT;CACF,CAAC"}
|
|
@@ -40,25 +40,61 @@ var graph_1 = require("@or-sdk/graph");
|
|
|
40
40
|
module.exports = {
|
|
41
41
|
up: function (queryInterface) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var services, graphUrl, graphApi,
|
|
44
|
-
return __generator(this, function (
|
|
45
|
-
switch (
|
|
46
|
-
case 0:
|
|
43
|
+
var _a, discoveryUrl, _orToken, response, services, graphService, graphUrl, graphApi, graphName_1, nodes, queryStr, graphs, entitiesGraph, error_1;
|
|
44
|
+
return __generator(this, function (_b) {
|
|
45
|
+
switch (_b.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
_a = queryInterface.context, discoveryUrl = _a.discoveryUrl, _orToken = _a._orToken;
|
|
48
|
+
_b.label = 1;
|
|
47
49
|
case 1:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
_b.trys.push([1, 8, , 9]);
|
|
51
|
+
return [4, fetch("".concat(discoveryUrl, "/api/v2/services"))];
|
|
52
|
+
case 2:
|
|
53
|
+
response = _b.sent();
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
throw new Error("Failed to fetch services: ".concat(response.statusText));
|
|
56
|
+
}
|
|
57
|
+
return [4, response.json()];
|
|
58
|
+
case 3:
|
|
59
|
+
services = (_b.sent()).services;
|
|
60
|
+
graphService = services.find(function (service) { return service.serviceKey === 'graphs-api'; });
|
|
61
|
+
if (!graphService) {
|
|
62
|
+
throw new Error('Service \'graphs-api\' not found in discovery services.');
|
|
63
|
+
}
|
|
64
|
+
graphUrl = graphService.url;
|
|
50
65
|
graphApi = new graph_1.Graphs({
|
|
51
66
|
graphUrl: graphUrl,
|
|
52
|
-
token:
|
|
67
|
+
token: _orToken,
|
|
53
68
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
graphName_1 = 'idw_entities';
|
|
70
|
+
nodes = ['Skill', 'Knowledge', 'GPT', 'Eval', 'Custom', 'Bing'];
|
|
71
|
+
queryStr = nodes
|
|
72
|
+
.map(function (name, index) { return "MERGE (n_".concat(index, ": MCP_Datasource {name: \"").concat(name, "\"})"); })
|
|
73
|
+
.join('\n');
|
|
74
|
+
return [4, graphApi.listGraphs()];
|
|
75
|
+
case 4:
|
|
76
|
+
graphs = _b.sent();
|
|
77
|
+
entitiesGraph = graphs.items.find(function (graph) { return graph.name === graphName_1; });
|
|
78
|
+
if (!!entitiesGraph) return [3, 6];
|
|
79
|
+
console.log("".concat(graphName_1, " not found. Start creating graph..."));
|
|
80
|
+
return [4, graphApi.createGraph({
|
|
81
|
+
name: graphName_1,
|
|
58
82
|
})];
|
|
59
|
-
case
|
|
60
|
-
|
|
61
|
-
|
|
83
|
+
case 5:
|
|
84
|
+
_b.sent();
|
|
85
|
+
_b.label = 6;
|
|
86
|
+
case 6: return [4, graphApi.query({
|
|
87
|
+
query: queryStr,
|
|
88
|
+
graph: graphName_1,
|
|
89
|
+
})];
|
|
90
|
+
case 7:
|
|
91
|
+
_b.sent();
|
|
92
|
+
return [3, 9];
|
|
93
|
+
case 8:
|
|
94
|
+
error_1 = _b.sent();
|
|
95
|
+
console.error('Migration failed with detailed error:', error_1.message);
|
|
96
|
+
throw error_1;
|
|
97
|
+
case 9: return [2];
|
|
62
98
|
}
|
|
63
99
|
});
|
|
64
100
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250801134909-create-MCP-graphs.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250801134909-create-MCP-graphs.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"20250801134909-create-MCP-graphs.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250801134909-create-MCP-graphs.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,GAAG,SAA2B;wBACpC,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,UAAC,KAAY,IAAK,OAAA,KAAK,CAAC,IAAI,KAAK,WAAS,EAAxB,CAAwB,CAAC,CAAC;6BAEhF,CAAC,aAAa,EAAd,cAAc;wBAEhB,OAAO,CAAC,GAAG,CAAC,UAAG,WAAS,wCAAqC,CAAC,CAAC;wBAE/D,WAAM,QAAQ,CAAC,WAAW,CAAC;gCACzB,IAAI,EAAE,WAAS;6BAChB,CAAC,EAAA;;wBAFF,SAEE,CAAC;;4BAGL,WAAM,QAAQ,CAAC,KAAK,CAAC;4BACnB,KAAK,EAAE,QAAQ;4BACf,KAAK,EAAE,WAAS;yBACjB,CAAC,EAAA;;wBAHF,SAGE,CAAC;;;;wBAGH,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAG,OAAe,CAAC,OAAO,CAAC,CAAC;wBAEjF,MAAM,OAAK,CAAC;;;;;KAEf;IAEK,IAAI;;;;;;KAOT;CACF,CAAC"}
|
|
@@ -39,26 +39,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
module.exports = {
|
|
40
40
|
up: function (queryInterface) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
-
var services, sdkApiUrl,
|
|
43
|
-
return __generator(this, function (
|
|
44
|
-
switch (
|
|
45
|
-
case 0:
|
|
42
|
+
var _a, discoveryUrl, _orToken, sequelize, response, services, sdkService, mcpService, sdkApiUrl, mcpApiUrl, authResponse, accountId, accPart, mcpDomain, error_1;
|
|
43
|
+
return __generator(this, function (_b) {
|
|
44
|
+
switch (_b.label) {
|
|
45
|
+
case 0:
|
|
46
|
+
_a = queryInterface.context, discoveryUrl = _a.discoveryUrl, _orToken = _a._orToken, sequelize = _a.sequelize;
|
|
47
|
+
_b.label = 1;
|
|
46
48
|
case 1:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
mcpAPi = services.find(function (service) { return service.serviceKey === 'mcp-api'; }).url;
|
|
50
|
-
return [4, fetch("".concat(sdkApiUrl, "/auth/token"), {
|
|
51
|
-
headers: {
|
|
52
|
-
Authorization: queryInterface.context._orToken,
|
|
53
|
-
},
|
|
54
|
-
}).then(function (res) { return res.json(); })];
|
|
49
|
+
_b.trys.push([1, 7, , 8]);
|
|
50
|
+
return [4, fetch("".concat(discoveryUrl, "/api/v2/services"))];
|
|
55
51
|
case 2:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
response = _b.sent();
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
throw new Error("Failed to fetch services: ".concat(response.statusText));
|
|
55
|
+
}
|
|
56
|
+
return [4, response.json()];
|
|
59
57
|
case 3:
|
|
60
|
-
|
|
61
|
-
return
|
|
58
|
+
services = (_b.sent()).services;
|
|
59
|
+
sdkService = services.find(function (service) { return service.serviceKey === 'sdk-api'; });
|
|
60
|
+
mcpService = services.find(function (service) { return service.serviceKey === 'mcp-api'; });
|
|
61
|
+
if (!sdkService || !mcpService) {
|
|
62
|
+
throw new Error("Required services missing: sdk-api (".concat(!!sdkService, "), mcp-api (").concat(!!mcpService, ")"));
|
|
63
|
+
}
|
|
64
|
+
sdkApiUrl = sdkService.url;
|
|
65
|
+
mcpApiUrl = mcpService.url;
|
|
66
|
+
return [4, fetch("".concat(sdkApiUrl, "/auth/token"), {
|
|
67
|
+
headers: { Authorization: _orToken },
|
|
68
|
+
})];
|
|
69
|
+
case 4:
|
|
70
|
+
authResponse = _b.sent();
|
|
71
|
+
if (!authResponse.ok) {
|
|
72
|
+
throw new Error('Failed to fetch auth token info');
|
|
73
|
+
}
|
|
74
|
+
return [4, authResponse.json()];
|
|
75
|
+
case 5:
|
|
76
|
+
accountId = (_b.sent()).accountId;
|
|
77
|
+
accPart = accountId.split('-')[0];
|
|
78
|
+
mcpDomain = mcpApiUrl.replace(/^https?:\/\//, '');
|
|
79
|
+
return [4, sequelize.query("\n ALTER TABLE datasources \n ADD COLUMN IF NOT EXISTS mcp_url varchar;\n\n UPDATE datasources \n SET mcp_url = 'https://".concat(accPart, "-' || slug || '.").concat(mcpDomain, "/mcp'\n WHERE is_default = true;\n "))];
|
|
80
|
+
case 6:
|
|
81
|
+
_b.sent();
|
|
82
|
+
return [3, 8];
|
|
83
|
+
case 7:
|
|
84
|
+
error_1 = _b.sent();
|
|
85
|
+
console.error('Migration failed with detailed error:', error_1.message);
|
|
86
|
+
throw error_1;
|
|
87
|
+
case 8: return [2];
|
|
62
88
|
}
|
|
63
89
|
});
|
|
64
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250818113914-add-mcp-url.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250818113914-add-mcp-url.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASb,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAA+G
|
|
1
|
+
{"version":3,"file":"20250818113914-add-mcp-url.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20250818113914-add-mcp-url.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASb,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAA+G;;;;;;wBAChH,KAAwC,cAAc,CAAC,OAAO,EAA5D,YAAY,kBAAA,EAAE,QAAQ,cAAA,EAAE,SAAS,eAAA,CAA4B;;;;wBAGlD,WAAM,KAAK,CAAC,UAAG,YAAY,qBAAkB,CAAC,EAAA;;wBAAzD,QAAQ,GAAG,SAA8C;wBAE/D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;4BAEjB,MAAM,IAAI,KAAK,CAAC,oCAA6B,QAAQ,CAAC,UAAU,CAAE,CAAC,CAAC;wBACtE,CAAC;wBAEoB,WAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAAlC,QAAQ,GAAK,CAA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BAEjF,MAAM,OAAK,CAAC;;;;;KAEf;IAEK,IAAI;;;;;;KAOT;CACF,CAAC"}
|
|
@@ -59,8 +59,10 @@ module.exports = {
|
|
|
59
59
|
return [4, idwCoreSequelize.query("\n SELECT __id FROM domain;\n ")];
|
|
60
60
|
case 3:
|
|
61
61
|
results = (_a.sent())[0];
|
|
62
|
-
if (!results.length)
|
|
63
|
-
|
|
62
|
+
if (!results.length) {
|
|
63
|
+
console.warn('No domains found');
|
|
64
|
+
return [2];
|
|
65
|
+
}
|
|
64
66
|
cases = results
|
|
65
67
|
.map(function (item, index) {
|
|
66
68
|
return "WHEN '".concat(item.__id, "' THEN '/domains/img-").concat(index, ".png'");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20251014120039-add-domain-image.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20251014120039-add-domain-image.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMb,qDAA6D;AAG7D,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAAoE;;;;;;wBACrE,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC;wBACxC,YAAY,GAAG,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC;wBAEnD,IAAI,GAAG,IAAI,uBAAU,CAAC;4BAC1B,KAAK,OAAA;4BACL,YAAY,cAAA;yBACb,CAAC,CAAC;wBACsB,WAAM,IAAI,CAAC,YAAY,CAAC,oBAAO,CAAC,QAAQ,CAAC,EAAA;;wBAA5D,gBAAgB,GAAG,SAAyC;wBAGlE,WAAM,gBAAgB,CAAC,KAAK,CAAC,4HAG5B,CAAC,EAAA;;wBAHF,SAGE,CAAC;wBAEgB,WAAM,gBAAgB,CAAC,KAAK,CAAC,wCAE/C,CAAC,EAAA;;wBAFK,OAAO,GAAI,CAAC,SAEjB,CAAoC,GAFxB;wBAId,IAAI,CAAC,OAAO,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"20251014120039-add-domain-image.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20251014120039-add-domain-image.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMb,qDAA6D;AAG7D,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAAoE;;;;;;wBACrE,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC;wBACxC,YAAY,GAAG,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC;wBAEnD,IAAI,GAAG,IAAI,uBAAU,CAAC;4BAC1B,KAAK,OAAA;4BACL,YAAY,cAAA;yBACb,CAAC,CAAC;wBACsB,WAAM,IAAI,CAAC,YAAY,CAAC,oBAAO,CAAC,QAAQ,CAAC,EAAA;;wBAA5D,gBAAgB,GAAG,SAAyC;wBAGlE,WAAM,gBAAgB,CAAC,KAAK,CAAC,4HAG5B,CAAC,EAAA;;wBAHF,SAGE,CAAC;wBAEgB,WAAM,gBAAgB,CAAC,KAAK,CAAC,wCAE/C,CAAC,EAAA;;wBAFK,OAAO,GAAI,CAAC,SAEjB,CAAoC,GAFxB;wBAId,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;4BACpB,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;4BAEjC,WAAO;wBACT,CAAC;wBAEK,KAAK,GAAG,OAAO;6BAClB,GAAG,CAAC,UAAC,IAAI,EAAE,KAAK;4BACf,OAAA,gBAAS,IAAI,CAAC,IAAI,kCAAwB,KAAK,UAAO;wBAAtD,CAAsD,CACvD;6BACA,IAAI,CAAC,QAAQ,CAAC,CAAC;wBAEZ,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAA,IAAI,IAAI,OAAA,WAAI,IAAI,CAAC,IAAI,MAAG,EAAhB,CAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAEvD,KAAK,GAAG,sEAGR,KAAK,+CAEQ,GAAG,aACrB,CAAC;wBAEF,WAAM,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAA;;wBAAnC,SAAmC,CAAC;;;;;KACrC;CACF,CAAC"}
|
|
@@ -72,7 +72,8 @@ module.exports = {
|
|
|
72
72
|
case 2:
|
|
73
73
|
settings = _d.sent();
|
|
74
74
|
if (!settings.value) {
|
|
75
|
-
|
|
75
|
+
console.warn('Settings not found');
|
|
76
|
+
return [2];
|
|
76
77
|
}
|
|
77
78
|
newSettings = __assign(__assign({}, settings.value), { allowSignup: allowSignup, isPrivate: isPrivate });
|
|
78
79
|
return [4, keyValueStorage.setValueByKey('idw-settings', 'all', newSettings)];
|
package/dist/assets/db_migrations/20251110102751-move-account-settings-to-kv-settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20251110102751-move-account-settings-to-kv-settings.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20251110102751-move-account-settings-to-kv-settings.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,6DAA2D;AAC3D,+DAA4D;AAI5D,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAAgH;;;;;;wBACjH,eAAe,GAAG,IAAI,kCAAe,CAAC;4BAC1C,YAAY,EAAE,cAAc,CAAC,OAAO,CAAC,YAAY;4BACjD,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ;yBACvC,CAAC,CAAC;wBAEG,eAAe,GAAG,IAAI,mCAAe,CAAC;4BAC1C,YAAY,EAAE,cAAc,CAAC,OAAO,CAAC,YAAY;4BACjD,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ;yBACvC,CAAC,CAAC;wBAGY,WAAM,eAAe,CAAC,cAAc,EAAE,EAAA;;wBAA/C,MAAM,GAAG,SAAsC;wBAC/C,KAA6C,MAAM,CAAC,GAAG,IAAI,EAAE,EAA3D,mBAAmB,EAAnB,WAAW,mBAAG,KAAK,KAAA,EAAE,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA,CAAsB;wBAGnD,WAAM,eAAe,CAAC,aAAa,CAAC,cAAc,EAAE,KAAK,CAAC,EAAA;;wBAArE,QAAQ,GAAG,SAA0D;wBAE3E,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"20251110102751-move-account-settings-to-kv-settings.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20251110102751-move-account-settings-to-kv-settings.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,6DAA2D;AAC3D,+DAA4D;AAI5D,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAAgH;;;;;;wBACjH,eAAe,GAAG,IAAI,kCAAe,CAAC;4BAC1C,YAAY,EAAE,cAAc,CAAC,OAAO,CAAC,YAAY;4BACjD,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ;yBACvC,CAAC,CAAC;wBAEG,eAAe,GAAG,IAAI,mCAAe,CAAC;4BAC1C,YAAY,EAAE,cAAc,CAAC,OAAO,CAAC,YAAY;4BACjD,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ;yBACvC,CAAC,CAAC;wBAGY,WAAM,eAAe,CAAC,cAAc,EAAE,EAAA;;wBAA/C,MAAM,GAAG,SAAsC;wBAC/C,KAA6C,MAAM,CAAC,GAAG,IAAI,EAAE,EAA3D,mBAAmB,EAAnB,WAAW,mBAAG,KAAK,KAAA,EAAE,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA,CAAsB;wBAGnD,WAAM,eAAe,CAAC,aAAa,CAAC,cAAc,EAAE,KAAK,CAAC,EAAA;;wBAArE,QAAQ,GAAG,SAA0D;wBAE3E,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;4BACpB,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;4BAGnC,WAAO;wBACT,CAAC;wBAGK,WAAW,yBACZ,QAAQ,CAAC,KAAK,KACjB,WAAW,aAAA,EACX,SAAS,WAAA,GACV,CAAC;wBAEF,WAAM,eAAe,CAAC,aAAa,CAAC,cAAc,EAAE,KAAK,EAAE,WAAW,CAAC,EAAA;;wBAAvE,SAAuE,CAAC;;;;;KACzE;CACF,CAAC"}
|
|
@@ -40,18 +40,41 @@ var idw_1 = require("@or-sdk/idw");
|
|
|
40
40
|
module.exports = {
|
|
41
41
|
up: function (queryInterface) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var idwApiV2;
|
|
44
|
-
return __generator(this, function (
|
|
45
|
-
switch (
|
|
43
|
+
var _a, discoveryUrl, _orToken, response, services, idwService, idwApiUrl, idwApiV2, error_1;
|
|
44
|
+
return __generator(this, function (_b) {
|
|
45
|
+
switch (_b.label) {
|
|
46
46
|
case 0:
|
|
47
|
+
_a = queryInterface.context, discoveryUrl = _a.discoveryUrl, _orToken = _a._orToken;
|
|
48
|
+
_b.label = 1;
|
|
49
|
+
case 1:
|
|
50
|
+
_b.trys.push([1, 5, , 6]);
|
|
51
|
+
return [4, fetch("".concat(discoveryUrl, "/api/v2/services"))];
|
|
52
|
+
case 2:
|
|
53
|
+
response = _b.sent();
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
throw new Error("Failed to fetch services: ".concat(response.statusText));
|
|
56
|
+
}
|
|
57
|
+
return [4, response.json()];
|
|
58
|
+
case 3:
|
|
59
|
+
services = (_b.sent()).services;
|
|
60
|
+
idwService = services.find(function (s) { return s.serviceKey === 'idw-api'; });
|
|
61
|
+
if (!idwService) {
|
|
62
|
+
throw new Error('Service \'idw-api\' not found in discovery services.');
|
|
63
|
+
}
|
|
64
|
+
idwApiUrl = idwService.url;
|
|
47
65
|
idwApiV2 = new idw_1.IdwApiV2({
|
|
48
|
-
idwApiUrl:
|
|
49
|
-
token:
|
|
66
|
+
idwApiUrl: idwApiUrl,
|
|
67
|
+
token: _orToken,
|
|
50
68
|
});
|
|
51
69
|
return [4, idwApiV2.syncGraph()];
|
|
52
|
-
case
|
|
53
|
-
|
|
54
|
-
return [
|
|
70
|
+
case 4:
|
|
71
|
+
_b.sent();
|
|
72
|
+
return [3, 6];
|
|
73
|
+
case 5:
|
|
74
|
+
error_1 = _b.sent();
|
|
75
|
+
console.error('Migration failed with detailed error:', error_1.message);
|
|
76
|
+
throw error_1;
|
|
77
|
+
case 6: return [2];
|
|
55
78
|
}
|
|
56
79
|
});
|
|
57
80
|
});
|
|
@@ -59,6 +82,7 @@ module.exports = {
|
|
|
59
82
|
down: function () {
|
|
60
83
|
return __awaiter(this, void 0, void 0, function () {
|
|
61
84
|
return __generator(this, function (_a) {
|
|
85
|
+
console.info('Down migration: No action taken (Graph sync is non-revertible).');
|
|
62
86
|
return [2];
|
|
63
87
|
});
|
|
64
88
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20251117171755-sync-graph.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20251117171755-sync-graph.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,mCAAuC;
|
|
1
|
+
{"version":3,"file":"20251117171755-sync-graph.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20251117171755-sync-graph.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,mCAAuC;AASvC,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAA+G;;;;;;wBAChH,KAA6B,cAAc,CAAC,OAAO,EAAjD,YAAY,kBAAA,EAAE,QAAQ,cAAA,CAA4B;;;;wBAGvC,WAAM,KAAK,CAAC,UAAG,YAAY,qBAAkB,CAAC,EAAA;;wBAAzD,QAAQ,GAAG,SAA8C;wBAE/D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;4BAEjB,MAAM,IAAI,KAAK,CAAC,oCAA6B,QAAQ,CAAC,UAAU,CAAE,CAAC,CAAC;wBACtE,CAAC;wBAEoB,WAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAAlC,QAAQ,GAAK,CAAA,SAAqB,CAAA,SAA1B;wBAEV,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAC,CAAmB,IAAK,OAAA,CAAC,CAAC,UAAU,KAAK,SAAS,EAA1B,CAA0B,CAAC,CAAC;wBAEtF,IAAI,CAAC,UAAU,EAAE,CAAC;4BAEhB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;wBAC1E,CAAC;wBAEK,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC;wBAE3B,QAAQ,GAAG,IAAI,cAAQ,CAAC;4BAC5B,SAAS,EAAE,SAAS;4BACpB,KAAK,EAAE,QAAQ;yBAChB,CAAC,CAAC;wBAEH,WAAM,QAAQ,CAAC,SAAS,EAAE,EAAA;;wBAA1B,SAA0B,CAAC;;;;wBAG3B,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAG,OAAe,CAAC,OAAO,CAAC,CAAC;wBAEjF,MAAM,OAAK,CAAC;;;;;KAEf;IAEK,IAAI;;;gBAER,OAAO,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAC;;;;KAOjF;CACF,CAAC"}
|
|
@@ -53,7 +53,7 @@ module.exports = {
|
|
|
53
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
54
|
return __generator(this, function (_a) {
|
|
55
55
|
switch (_a.label) {
|
|
56
|
-
case 0: return [4, queryInterface.context.sequelize.query("\n drop table surveys.form_submissions;\n drop table surveys.form_responses;\n drop table surveys.forms;\n drop schema surveys cascade;\n ")];
|
|
56
|
+
case 0: return [4, queryInterface.context.sequelize.query("\n drop table if exists surveys.form_submissions;\n drop table if exists surveys.form_responses;\n drop table if exists surveys.forms;\n drop schema if exists surveys cascade;\n ")];
|
|
57
57
|
case 1:
|
|
58
58
|
_a.sent();
|
|
59
59
|
return [2];
|
package/dist/assets/db_migrations/20251124123410-create-collect-information-skill-tables.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20251124123410-create-collect-information-skill-tables.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20251124123410-create-collect-information-skill-tables.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIb,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAAoE;;;;4BAC3E,WAAM,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,u0CAyC5C,CAAC,EAAA;;wBAzCF,SAyCE,CAAC;;;;;KAOJ;IAEK,IAAI,YAAC,cAAoE;;;;4BAC7E,WAAM,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"20251124123410-create-collect-information-skill-tables.js","sourceRoot":"","sources":["../../../src/assets/db_migrations/20251124123410-create-collect-information-skill-tables.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIb,MAAM,CAAC,OAAO,GAAG;IACT,EAAE,YAAC,cAAoE;;;;4BAC3E,WAAM,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,u0CAyC5C,CAAC,EAAA;;wBAzCF,SAyCE,CAAC;;;;;KAOJ;IAEK,IAAI,YAAC,cAAoE;;;;4BAC7E,WAAM,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,6MAK1C,CAAC,EAAA;;wBALJ,SAKI,CAAC;;;;;KAON;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,58 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
import { Graph, Graphs } from '@or-sdk/graph';
|
|
2
3
|
import { QueryInterface, Sequelize } from 'sequelize';
|
|
3
|
-
|
|
4
|
+
type DiscovyreService = {
|
|
5
|
+
serviceKey: string;
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
4
8
|
|
|
5
9
|
/** @type {import('sequelize-cli').Migration} */
|
|
6
10
|
module.exports = {
|
|
7
11
|
async up(queryInterface: QueryInterface & { context: { sequelize: Sequelize; _orToken: string; discoveryUrl: string;}; }) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
const { discoveryUrl, _orToken } = queryInterface.context;
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(`${discoveryUrl}/api/v2/services`);
|
|
16
|
+
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
|
|
19
|
+
throw new Error(`Failed to fetch services: ${response.statusText}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { services } = await response.json();
|
|
23
|
+
const graphService = services.find((service: DiscovyreService) => service.serviceKey === 'graphs-api');
|
|
24
|
+
|
|
25
|
+
if (!graphService) {
|
|
26
|
+
|
|
27
|
+
throw new Error('Service \'graphs-api\' not found in discovery services.');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const graphUrl = graphService.url;
|
|
31
|
+
|
|
32
|
+
const graphApi = new Graphs({
|
|
33
|
+
graphUrl,
|
|
34
|
+
token: _orToken,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const graphName = 'idw';
|
|
38
|
+
|
|
39
|
+
const graphs = await graphApi.listGraphs();
|
|
40
|
+
const idwGraph = graphs.items.find((graph: Graph) => graph.name === graphName);
|
|
41
|
+
|
|
42
|
+
if (!idwGraph) {
|
|
43
|
+
// eslint-disable-next-line no-console
|
|
44
|
+
console.log(`${graphName} not found. Start creating graph...`);
|
|
45
|
+
|
|
46
|
+
await graphApi.createGraph({
|
|
47
|
+
name: graphName,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('Migration failed with detailed error:', (error as Error).message);
|
|
53
|
+
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
22
56
|
},
|
|
23
57
|
|
|
24
58
|
async down() {
|
|
@@ -6,9 +6,9 @@ module.exports = {
|
|
|
6
6
|
async up(queryInterface: QueryInterface & { context: { sequelize: Sequelize; }; }) {
|
|
7
7
|
await queryInterface.context.sequelize.query(`
|
|
8
8
|
ALTER TABLE feedback
|
|
9
|
-
ADD COLUMN skill_rate text,
|
|
10
|
-
ADD COLUMN skill_name text,
|
|
11
|
-
ADD COLUMN skill_feedback text;
|
|
9
|
+
ADD COLUMN IF NOT EXISTS skill_rate text,
|
|
10
|
+
ADD COLUMN IF NOT EXISTS skill_name text,
|
|
11
|
+
ADD COLUMN IF NOT EXISTS skill_feedback text;
|
|
12
12
|
`);
|
|
13
13
|
},
|
|
14
14
|
|
|
@@ -9,52 +9,97 @@ type DiscovyreService = {
|
|
|
9
9
|
/** @type {import('sequelize-cli').Migration} */
|
|
10
10
|
module.exports = {
|
|
11
11
|
async up(queryInterface: QueryInterface & { context: { sequelize: Sequelize; _orToken: string; discoveryUrl: string;}; }) {
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
12
|
+
const { discoveryUrl, _orToken } = queryInterface.context;
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(`${discoveryUrl}/api/v2/services`);
|
|
16
|
+
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
|
|
19
|
+
throw new Error(`Failed to fetch services: ${response.statusText}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { services } = await response.json();
|
|
23
|
+
|
|
24
|
+
const sdkService = services.find((service: DiscovyreService) => service.serviceKey === 'sdk-api');
|
|
25
|
+
const idwService = services.find((service: DiscovyreService) => service.serviceKey === 'idw-api');
|
|
26
|
+
|
|
27
|
+
if (!sdkService || !idwService) {
|
|
28
|
+
|
|
29
|
+
throw new Error(`Required services missing: sdk-api (${!!sdkService}), idw-api (${!!idwService})`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const sdkApiUrl = sdkService.url;
|
|
33
|
+
const idwApiUrl = idwService.url;
|
|
34
|
+
|
|
35
|
+
const authResponse = await fetch(`${sdkApiUrl}/auth/token`, {
|
|
36
|
+
headers: { Authorization: _orToken },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!authResponse.ok) {
|
|
40
|
+
|
|
41
|
+
throw new Error('Failed to fetch auth token info');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const { accountId } = await authResponse.json();
|
|
45
|
+
|
|
46
|
+
const userResponse = await fetch(`${idwApiUrl}/user/info?accountId=${accountId}`);
|
|
47
|
+
|
|
48
|
+
if (!userResponse.ok) {
|
|
49
|
+
|
|
50
|
+
throw new Error('Failed to fetch user info');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { name, description, role, avatar } = await userResponse.json();
|
|
54
|
+
|
|
55
|
+
const newValue = {
|
|
56
|
+
name: name || '',
|
|
57
|
+
description: description || '',
|
|
58
|
+
role: role || '',
|
|
59
|
+
avatar: avatar || '',
|
|
60
|
+
signup: {
|
|
61
|
+
header: '',
|
|
62
|
+
description: '',
|
|
63
|
+
logo: '',
|
|
55
64
|
},
|
|
56
|
-
}
|
|
57
|
-
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const storageGetUrl = `${sdkApiUrl}/storage/idw-settings/all?exists=false`;
|
|
68
|
+
const storageGetResponse = await fetch(storageGetUrl, {
|
|
69
|
+
headers: { Authorization: _orToken },
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
let existingSettings = {};
|
|
73
|
+
|
|
74
|
+
if (storageGetResponse.ok) {
|
|
75
|
+
const storageData = await storageGetResponse.json();
|
|
76
|
+
|
|
77
|
+
existingSettings = storageData.value || {};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const updateResponse = await fetch(`${sdkApiUrl}/storage/idw-settings/all`, {
|
|
81
|
+
method: 'POST',
|
|
82
|
+
headers: {
|
|
83
|
+
Authorization: _orToken,
|
|
84
|
+
'Content-Type': 'application/json',
|
|
85
|
+
},
|
|
86
|
+
body: JSON.stringify({
|
|
87
|
+
value: {
|
|
88
|
+
...newValue,
|
|
89
|
+
...existingSettings,
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
if (!updateResponse.ok) {
|
|
95
|
+
|
|
96
|
+
throw new Error(`Failed to update settings: ${updateResponse.statusText}`);
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error('Migration failed with detailed error:', (error as Error).message);
|
|
100
|
+
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
58
103
|
},
|
|
59
104
|
|
|
60
105
|
async down() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
import { Graph, Graphs } from '@or-sdk/graph';
|
|
2
3
|
import { QueryInterface, Sequelize } from 'sequelize';
|
|
3
|
-
import { Graphs } from '@or-sdk/graph';
|
|
4
4
|
type DiscovyreService = {
|
|
5
5
|
serviceKey: string;
|
|
6
6
|
url: string;
|
|
@@ -9,25 +9,61 @@ type DiscovyreService = {
|
|
|
9
9
|
/** @type {import('sequelize-cli').Migration} */
|
|
10
10
|
module.exports = {
|
|
11
11
|
async up(queryInterface: QueryInterface & { context: { sequelize: Sequelize; _orToken: string; discoveryUrl: string;}; }) {
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
const { discoveryUrl, _orToken } = queryInterface.context;
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(`${discoveryUrl}/api/v2/services`);
|
|
16
|
+
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
|
|
19
|
+
throw new Error(`Failed to fetch services: ${response.statusText}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { services } = await response.json();
|
|
23
|
+
|
|
24
|
+
const graphService = services.find((service: DiscovyreService) => service.serviceKey === 'graphs-api');
|
|
25
|
+
|
|
26
|
+
if (!graphService) {
|
|
27
|
+
|
|
28
|
+
throw new Error('Service \'graphs-api\' not found in discovery services.');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const graphUrl = graphService.url;
|
|
32
|
+
|
|
33
|
+
const graphApi = new Graphs({
|
|
34
|
+
graphUrl,
|
|
35
|
+
token: _orToken,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const graphName = 'idw_entities';
|
|
39
|
+
const nodes = ['Skill', 'Knowledge', 'GPT', 'Eval', 'Custom', 'Bing'];
|
|
40
|
+
const queryStr = nodes
|
|
41
|
+
.map((name, index) => `MERGE (n_${index}: MCP_Datasource {name: "${name}"})`)
|
|
42
|
+
.join('\n');
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const graphs = await graphApi.listGraphs();
|
|
46
|
+
const entitiesGraph = graphs.items.find((graph: Graph) => graph.name === graphName);
|
|
47
|
+
|
|
48
|
+
if (!entitiesGraph) {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log(`${graphName} not found. Start creating graph...`);
|
|
51
|
+
|
|
52
|
+
await graphApi.createGraph({
|
|
53
|
+
name: graphName,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await graphApi.query({
|
|
58
|
+
query: queryStr,
|
|
59
|
+
graph: graphName,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error('Migration failed with detailed error:', (error as Error).message);
|
|
64
|
+
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
31
67
|
},
|
|
32
68
|
|
|
33
69
|
async down() {
|
|
@@ -9,27 +9,57 @@ type DiscovyreService = {
|
|
|
9
9
|
/** @type {import('sequelize-cli').Migration} */
|
|
10
10
|
module.exports = {
|
|
11
11
|
async up(queryInterface: QueryInterface & { context: { sequelize: Sequelize; _orToken: string; discoveryUrl: string;}; }) {
|
|
12
|
-
const {
|
|
13
|
-
await fetch(`${queryInterface.context.discoveryUrl}/api/v2/services`).then(res => res.json());
|
|
12
|
+
const { discoveryUrl, _orToken, sequelize } = queryInterface.context;
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(`${discoveryUrl}/api/v2/services`);
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
headers: {
|
|
20
|
-
Authorization: queryInterface.context._orToken,
|
|
21
|
-
},
|
|
22
|
-
}).then(res => res.json());
|
|
17
|
+
if (!response.ok) {
|
|
23
18
|
|
|
19
|
+
throw new Error(`Failed to fetch services: ${response.statusText}`);
|
|
20
|
+
}
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
const { services } = await response.json();
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
const sdkService = services.find((service: DiscovyreService) => service.serviceKey === 'sdk-api');
|
|
25
|
+
const mcpService = services.find((service: DiscovyreService) => service.serviceKey === 'mcp-api');
|
|
26
|
+
|
|
27
|
+
if (!sdkService || !mcpService) {
|
|
28
|
+
|
|
29
|
+
throw new Error(`Required services missing: sdk-api (${!!sdkService}), mcp-api (${!!mcpService})`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const sdkApiUrl = sdkService.url;
|
|
33
|
+
const mcpApiUrl = mcpService.url;
|
|
34
|
+
|
|
35
|
+
const authResponse = await fetch(`${sdkApiUrl}/auth/token`, {
|
|
36
|
+
headers: { Authorization: _orToken },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!authResponse.ok) {
|
|
40
|
+
|
|
41
|
+
throw new Error('Failed to fetch auth token info');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const { accountId } = await authResponse.json();
|
|
45
|
+
|
|
46
|
+
const accPart = accountId.split('-')[0];
|
|
47
|
+
const mcpDomain = mcpApiUrl.replace(/^https?:\/\//, '');
|
|
48
|
+
|
|
49
|
+
await sequelize.query(`
|
|
50
|
+
ALTER TABLE datasources
|
|
51
|
+
ADD COLUMN IF NOT EXISTS mcp_url varchar;
|
|
52
|
+
|
|
53
|
+
UPDATE datasources
|
|
54
|
+
SET mcp_url = 'https://${accPart}-' || slug || '.${mcpDomain}/mcp'
|
|
55
|
+
WHERE is_default = true;
|
|
56
|
+
`);
|
|
57
|
+
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error('Migration failed with detailed error:', (error as Error).message);
|
|
60
|
+
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
33
63
|
},
|
|
34
64
|
|
|
35
65
|
async down() {
|
|
@@ -28,7 +28,11 @@ module.exports = {
|
|
|
28
28
|
SELECT __id FROM domain;
|
|
29
29
|
`)) as unknown as [{ __id: string }[]];
|
|
30
30
|
|
|
31
|
-
if (!results.length)
|
|
31
|
+
if (!results.length) {
|
|
32
|
+
console.warn('No domains found');
|
|
33
|
+
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
32
36
|
|
|
33
37
|
const cases = results
|
|
34
38
|
.map((item, index) =>
|
|
@@ -25,8 +25,10 @@ module.exports = {
|
|
|
25
25
|
const settings = await keyValueStorage.getValueByKey('idw-settings', 'all');
|
|
26
26
|
|
|
27
27
|
if (!settings.value) {
|
|
28
|
+
console.warn('Settings not found');
|
|
29
|
+
|
|
28
30
|
// prevent ide errors
|
|
29
|
-
return
|
|
31
|
+
return;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
// merge old and new settings
|
|
@@ -3,24 +3,52 @@
|
|
|
3
3
|
import { IdwApiV2 } from '@or-sdk/idw';
|
|
4
4
|
import { QueryInterface, Sequelize } from 'sequelize';
|
|
5
5
|
|
|
6
|
+
type DiscovyreService = {
|
|
7
|
+
serviceKey: string;
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
6
10
|
|
|
7
11
|
/** @type {import('sequelize-cli').Migration} */
|
|
8
12
|
module.exports = {
|
|
9
13
|
async up(queryInterface: QueryInterface & { context: { sequelize: Sequelize; _orToken: string; discoveryUrl: string;}; }) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const { discoveryUrl, _orToken } = queryInterface.context;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const response = await fetch(`${discoveryUrl}/api/v2/services`);
|
|
18
|
+
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
|
|
21
|
+
throw new Error(`Failed to fetch services: ${response.statusText}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { services } = await response.json();
|
|
25
|
+
|
|
26
|
+
const idwService = services.find((s: DiscovyreService) => s.serviceKey === 'idw-api');
|
|
27
|
+
|
|
28
|
+
if (!idwService) {
|
|
29
|
+
|
|
30
|
+
throw new Error('Service \'idw-api\' not found in discovery services.');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const idwApiUrl = idwService.url;
|
|
34
|
+
|
|
35
|
+
const idwApiV2 = new IdwApiV2({
|
|
36
|
+
idwApiUrl: idwApiUrl,
|
|
37
|
+
token: _orToken,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
await idwApiV2.syncGraph();
|
|
41
|
+
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('Migration failed with detailed error:', (error as Error).message);
|
|
44
|
+
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
21
47
|
},
|
|
22
48
|
|
|
23
49
|
async down() {
|
|
50
|
+
/* eslint-disable-next-line */
|
|
51
|
+
console.info('Down migration: No action taken (Graph sync is non-revertible).');
|
|
24
52
|
/**
|
|
25
53
|
* Add reverting commands here.
|
|
26
54
|
*
|
|
@@ -56,10 +56,10 @@ PRIMARY KEY (submission_id));
|
|
|
56
56
|
|
|
57
57
|
async down(queryInterface: QueryInterface & {context: {sequelize: Sequelize;};}) {
|
|
58
58
|
await queryInterface.context.sequelize.query(`
|
|
59
|
-
drop table surveys.form_submissions;
|
|
60
|
-
drop table surveys.form_responses;
|
|
61
|
-
drop table surveys.forms;
|
|
62
|
-
drop schema surveys cascade;
|
|
59
|
+
drop table if exists surveys.form_submissions;
|
|
60
|
+
drop table if exists surveys.form_responses;
|
|
61
|
+
drop table if exists surveys.forms;
|
|
62
|
+
drop schema if exists surveys cascade;
|
|
63
63
|
`);
|
|
64
64
|
/**
|
|
65
65
|
* Add reverting commands here.
|