mcp-creatio 0.4.0 → 0.4.1
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/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +18 -11
- package/dist/cli.js.map +1 -1
- package/dist/creatio/auth/auth.d.ts +2 -0
- package/dist/creatio/auth/auth.d.ts.map +1 -1
- package/dist/creatio/auth/auth.js.map +1 -1
- package/dist/creatio/auth/providers/base-provider.d.ts +1 -0
- package/dist/creatio/auth/providers/base-provider.d.ts.map +1 -1
- package/dist/creatio/auth/providers/base-provider.js +3 -0
- package/dist/creatio/auth/providers/base-provider.js.map +1 -1
- package/dist/creatio/auth/providers/oauth2-code-provider.d.ts +3 -0
- package/dist/creatio/auth/providers/oauth2-code-provider.d.ts.map +1 -1
- package/dist/creatio/auth/providers/oauth2-code-provider.js +30 -24
- package/dist/creatio/auth/providers/oauth2-code-provider.js.map +1 -1
- package/dist/creatio/services/http-client.d.ts.map +1 -1
- package/dist/creatio/services/http-client.js +0 -1
- package/dist/creatio/services/http-client.js.map +1 -1
- package/dist/creatio/services/metadata-store.d.ts +5 -0
- package/dist/creatio/services/metadata-store.d.ts.map +1 -1
- package/dist/creatio/services/metadata-store.js +18 -6
- package/dist/creatio/services/metadata-store.js.map +1 -1
- package/dist/creatio/services/odata-crud-provider.d.ts +2 -0
- package/dist/creatio/services/odata-crud-provider.d.ts.map +1 -1
- package/dist/creatio/services/odata-crud-provider.js +10 -1
- package/dist/creatio/services/odata-crud-provider.js.map +1 -1
- package/dist/server/http/creatio-oauth-handlers.d.ts +0 -1
- package/dist/server/http/creatio-oauth-handlers.d.ts.map +1 -1
- package/dist/server/http/creatio-oauth-handlers.js +30 -23
- package/dist/server/http/creatio-oauth-handlers.js.map +1 -1
- package/dist/server/http/httpServer.d.ts +9 -0
- package/dist/server/http/httpServer.d.ts.map +1 -1
- package/dist/server/http/httpServer.js +34 -11
- package/dist/server/http/httpServer.js.map +1 -1
- package/dist/server/http/mcp-handlers.d.ts.map +1 -1
- package/dist/server/http/mcp-handlers.js +4 -1
- package/dist/server/http/mcp-handlers.js.map +1 -1
- package/dist/server/http/mcp-oauth-handlers.d.ts.map +1 -1
- package/dist/server/http/mcp-oauth-handlers.js +18 -6
- package/dist/server/http/mcp-oauth-handlers.js.map +1 -1
- package/dist/server/http/middleware.d.ts +7 -0
- package/dist/server/http/middleware.d.ts.map +1 -1
- package/dist/server/http/middleware.js +23 -0
- package/dist/server/http/middleware.js.map +1 -1
- package/dist/server/http/rate-limiter.d.ts +24 -0
- package/dist/server/http/rate-limiter.d.ts.map +1 -0
- package/dist/server/http/rate-limiter.js +42 -0
- package/dist/server/http/rate-limiter.js.map +1 -0
- package/dist/server/oauth/oauth-server.d.ts +0 -1
- package/dist/server/oauth/oauth-server.d.ts.map +1 -1
- package/dist/server/oauth/oauth-server.js +11 -21
- package/dist/server/oauth/oauth-server.js.map +1 -1
- package/dist/server/oauth/storage.d.ts +0 -2
- package/dist/server/oauth/storage.d.ts.map +1 -1
- package/dist/server/oauth/storage.js +0 -6
- package/dist/server/oauth/storage.js.map +1 -1
- package/dist/server/oauth/validators.d.ts +6 -0
- package/dist/server/oauth/validators.d.ts.map +1 -1
- package/dist/server/oauth/validators.js +28 -0
- package/dist/server/oauth/validators.js.map +1 -1
- package/dist/services/session-context.d.ts +8 -7
- package/dist/services/session-context.d.ts.map +1 -1
- package/dist/services/session-context.js +7 -27
- package/dist/services/session-context.js.map +1 -1
- package/package.json +12 -3
- package/.dockerignore +0 -12
- package/.editorconfig +0 -14
- package/.eslintrc.cjs +0 -18
- package/.gitattributes +0 -8
- package/.github/workflows/docker-publish.yml +0 -50
- package/.prettierignore +0 -3
- package/.prettierrc +0 -9
- package/.vscode/launch.json +0 -23
- package/.vscode/mcp.json +0 -13
- package/.vscode/settings.json +0 -16
- package/Agent.md +0 -190
- package/Debug.md +0 -32
- package/Dockerfile +0 -23
- package/docs/coding-style.md +0 -30
- package/eslint.config.cjs +0 -95
- package/src/cli.ts +0 -162
- package/src/config-builder.ts +0 -76
- package/src/consts.ts +0 -3
- package/src/creatio/auth/auth-manager.ts +0 -27
- package/src/creatio/auth/auth.ts +0 -31
- package/src/creatio/auth/index.ts +0 -3
- package/src/creatio/auth/providers/base-oauth2-provider.ts +0 -62
- package/src/creatio/auth/providers/base-provider.ts +0 -42
- package/src/creatio/auth/providers/index.ts +0 -4
- package/src/creatio/auth/providers/legacy-provider.ts +0 -70
- package/src/creatio/auth/providers/oauth2-code-provider.ts +0 -252
- package/src/creatio/auth/providers/oauth2-provider.ts +0 -91
- package/src/creatio/auth/providers/type.ts +0 -5
- package/src/creatio/client-config.ts +0 -34
- package/src/creatio/engines/admin-operation/admin-operation-engine.ts +0 -44
- package/src/creatio/engines/configuration/configuration-engine.ts +0 -26
- package/src/creatio/engines/crud/crud-engine.ts +0 -47
- package/src/creatio/engines/engine-manager.ts +0 -157
- package/src/creatio/engines/engine-registry.ts +0 -39
- package/src/creatio/engines/engine.ts +0 -3
- package/src/creatio/engines/feature/feature-engine.ts +0 -20
- package/src/creatio/engines/index.ts +0 -10
- package/src/creatio/engines/process/process-engine.ts +0 -20
- package/src/creatio/engines/sys-settings/sys-settings-engine.ts +0 -41
- package/src/creatio/engines/user/user-engine.ts +0 -20
- package/src/creatio/index.ts +0 -6
- package/src/creatio/provider-context.ts +0 -21
- package/src/creatio/providers/admin-operation-provider.ts +0 -34
- package/src/creatio/providers/configuration-provider.ts +0 -22
- package/src/creatio/providers/crud-provider.ts +0 -45
- package/src/creatio/providers/feature-provider.ts +0 -10
- package/src/creatio/providers/index.ts +0 -7
- package/src/creatio/providers/process-provider.ts +0 -15
- package/src/creatio/providers/sys-settings-provider.ts +0 -63
- package/src/creatio/providers/user-provider.ts +0 -12
- package/src/creatio/services/admin-operation-service-provider.ts +0 -115
- package/src/creatio/services/configuration-service-provider.ts +0 -127
- package/src/creatio/services/creatio-service-context.ts +0 -55
- package/src/creatio/services/feature-service-provider.ts +0 -60
- package/src/creatio/services/http-client.ts +0 -174
- package/src/creatio/services/index.ts +0 -10
- package/src/creatio/services/metadata-store.ts +0 -181
- package/src/creatio/services/odata-crud-provider.ts +0 -210
- package/src/creatio/services/process-service-provider.ts +0 -76
- package/src/creatio/services/sys-settings-service-provider.ts +0 -192
- package/src/creatio/services/user-info-provider.ts +0 -41
- package/src/index.ts +0 -44
- package/src/log.ts +0 -183
- package/src/server/http/creatio-oauth-handlers.ts +0 -146
- package/src/server/http/httpServer.ts +0 -150
- package/src/server/http/index.ts +0 -5
- package/src/server/http/mcp-handlers.ts +0 -92
- package/src/server/http/mcp-oauth-handlers.ts +0 -108
- package/src/server/http/middleware.ts +0 -91
- package/src/server/index.ts +0 -2
- package/src/server/mcp/filters.ts +0 -97
- package/src/server/mcp/index.ts +0 -1
- package/src/server/mcp/prompts-data.ts +0 -1292
- package/src/server/mcp/server.ts +0 -442
- package/src/server/mcp/tools-data.ts +0 -748
- package/src/server/oauth/client-manager.ts +0 -47
- package/src/server/oauth/index.ts +0 -6
- package/src/server/oauth/oauth-server.ts +0 -185
- package/src/server/oauth/storage.ts +0 -106
- package/src/server/oauth/token-manager.ts +0 -80
- package/src/server/oauth/types.ts +0 -55
- package/src/server/oauth/validators.ts +0 -56
- package/src/services/index.ts +0 -2
- package/src/services/session-context.ts +0 -232
- package/src/services/token-refresh-scheduler.ts +0 -68
- package/src/types/index.ts +0 -1
- package/src/types/network.ts +0 -7
- package/src/utils/context.ts +0 -49
- package/src/utils/env.ts +0 -12
- package/src/utils/index.ts +0 -5
- package/src/utils/mcp.ts +0 -8
- package/src/utils/network.ts +0 -65
- package/src/utils/pkce.ts +0 -39
- package/src/version.ts +0 -15
- package/tsconfig.json +0 -28
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import log from '../../log';
|
|
2
|
-
import {
|
|
3
|
-
CrudDeleteParams,
|
|
4
|
-
CrudProvider,
|
|
5
|
-
CrudReadParams,
|
|
6
|
-
CrudUpdateParams,
|
|
7
|
-
CrudWriteParams,
|
|
8
|
-
EntitySchemaDescription,
|
|
9
|
-
} from '../providers';
|
|
10
|
-
|
|
11
|
-
import { CreatioHttpClient } from './http-client';
|
|
12
|
-
import { ODataMetadataStore } from './metadata-store';
|
|
13
|
-
|
|
14
|
-
export class ODataCrudProvider implements CrudProvider {
|
|
15
|
-
private readonly _client: CreatioHttpClient;
|
|
16
|
-
private readonly _metadataStore: ODataMetadataStore;
|
|
17
|
-
|
|
18
|
-
public readonly kind = 'creatio-odata';
|
|
19
|
-
|
|
20
|
-
constructor(client: CreatioHttpClient, metadataStore: ODataMetadataStore) {
|
|
21
|
-
this._client = client;
|
|
22
|
-
this._metadataStore = metadataStore;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private _buildODataQueryParams(
|
|
26
|
-
filter?: string,
|
|
27
|
-
select?: string[],
|
|
28
|
-
top?: number,
|
|
29
|
-
expand?: string[],
|
|
30
|
-
orderBy?: string,
|
|
31
|
-
): string[] {
|
|
32
|
-
const params: string[] = [];
|
|
33
|
-
if (filter) {
|
|
34
|
-
params.push(`$filter=${encodeURIComponent(filter)}`);
|
|
35
|
-
}
|
|
36
|
-
if (select && select.length > 0) {
|
|
37
|
-
params.push(`$select=${encodeURIComponent(select.join(','))}`);
|
|
38
|
-
}
|
|
39
|
-
if (expand && expand.length > 0) {
|
|
40
|
-
params.push(`$expand=${encodeURIComponent(expand.join(','))}`);
|
|
41
|
-
}
|
|
42
|
-
if (orderBy) {
|
|
43
|
-
params.push(`$orderby=${encodeURIComponent(orderBy)}`);
|
|
44
|
-
}
|
|
45
|
-
if (top) {
|
|
46
|
-
params.push(`$top=${top}`);
|
|
47
|
-
}
|
|
48
|
-
return params;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private _buildQueryString(params: string[]): string {
|
|
52
|
-
return params.length ? `?${params.join('&')}` : '';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private _extractODataValue(body: any): any {
|
|
56
|
-
return body && typeof body === 'object' && 'value' in body ? body.value : body;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
private _buildEntityUrl(entity: string): string {
|
|
60
|
-
return `${this._client.odataRoot}/${entity}`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private _formatEntityKey(id: string): string {
|
|
64
|
-
const GUID_PATTERN =
|
|
65
|
-
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
66
|
-
const NUMERIC_PATTERN = /^\d+$/;
|
|
67
|
-
if (NUMERIC_PATTERN.test(id) || GUID_PATTERN.test(id)) {
|
|
68
|
-
return id;
|
|
69
|
-
}
|
|
70
|
-
return `'${id.replace(/'/g, "''")}'`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public listEntitySets(): Promise<string[]> {
|
|
74
|
-
return this._metadataStore.listEntitySets();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public describeEntity(entitySet: string): Promise<EntitySchemaDescription> {
|
|
78
|
-
return this._metadataStore.describeEntity(entitySet);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public async create({ entity, data }: CrudWriteParams) {
|
|
82
|
-
const url = this._buildEntityUrl(entity);
|
|
83
|
-
return this._client.executeWithTiming(
|
|
84
|
-
'create',
|
|
85
|
-
url,
|
|
86
|
-
async () => {
|
|
87
|
-
const headers = await this._client.getJsonHeaders();
|
|
88
|
-
return this._client.fetchWithAuth(url, async () => ({
|
|
89
|
-
method: 'POST',
|
|
90
|
-
headers,
|
|
91
|
-
body: JSON.stringify(data),
|
|
92
|
-
}));
|
|
93
|
-
},
|
|
94
|
-
async (response, duration) => {
|
|
95
|
-
this._client.logSuccess('create', response.status, duration, { entity });
|
|
96
|
-
return response.json().catch(() => ({}));
|
|
97
|
-
},
|
|
98
|
-
async (response, duration) =>
|
|
99
|
-
this._client.handleErrorResponse(
|
|
100
|
-
'create',
|
|
101
|
-
response,
|
|
102
|
-
duration,
|
|
103
|
-
'creatio_create_failed',
|
|
104
|
-
{
|
|
105
|
-
entity,
|
|
106
|
-
url,
|
|
107
|
-
},
|
|
108
|
-
),
|
|
109
|
-
{ entity },
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public async read({ entity, filter, select, top, expand, orderBy }: CrudReadParams) {
|
|
114
|
-
const startTime = Date.now();
|
|
115
|
-
const queryParams = this._buildODataQueryParams(filter, select, top, expand, orderBy);
|
|
116
|
-
const url = this._buildEntityUrl(entity) + this._buildQueryString(queryParams);
|
|
117
|
-
const headers = await this._client.getJsonHeaders();
|
|
118
|
-
try {
|
|
119
|
-
const body = await this._client.fetchJson(url, async () => ({ headers }));
|
|
120
|
-
const result = this._extractODataValue(body);
|
|
121
|
-
const duration = Date.now() - startTime;
|
|
122
|
-
const resultCount = Array.isArray(result) ? result.length : result ? 1 : 0;
|
|
123
|
-
log.info('creatio.crud.read.success', {
|
|
124
|
-
entity,
|
|
125
|
-
filter,
|
|
126
|
-
select: select?.join(','),
|
|
127
|
-
expand: expand?.join(','),
|
|
128
|
-
orderBy,
|
|
129
|
-
top,
|
|
130
|
-
resultCount,
|
|
131
|
-
duration,
|
|
132
|
-
});
|
|
133
|
-
return result;
|
|
134
|
-
} catch (error: any) {
|
|
135
|
-
const duration = Date.now() - startTime;
|
|
136
|
-
log.error('creatio.crud.read.error', {
|
|
137
|
-
entity,
|
|
138
|
-
url,
|
|
139
|
-
error: String(error?.message ?? error),
|
|
140
|
-
duration,
|
|
141
|
-
});
|
|
142
|
-
throw error;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public async update({ entity, id, data }: CrudUpdateParams) {
|
|
147
|
-
const url = `${this._buildEntityUrl(entity)}(${this._formatEntityKey(id)})`;
|
|
148
|
-
return this._client.executeWithTiming(
|
|
149
|
-
'update',
|
|
150
|
-
url,
|
|
151
|
-
async () => {
|
|
152
|
-
const headers = await this._client.getJsonHeaders();
|
|
153
|
-
return this._client.fetchWithAuth(url, async () => ({
|
|
154
|
-
method: 'PATCH',
|
|
155
|
-
headers,
|
|
156
|
-
body: JSON.stringify(data),
|
|
157
|
-
}));
|
|
158
|
-
},
|
|
159
|
-
async (response, duration) => {
|
|
160
|
-
this._client.logSuccess('update', response.status, duration, { entity, id });
|
|
161
|
-
return response.text();
|
|
162
|
-
},
|
|
163
|
-
async (response, duration) =>
|
|
164
|
-
this._client.handleErrorResponse(
|
|
165
|
-
'update',
|
|
166
|
-
response,
|
|
167
|
-
duration,
|
|
168
|
-
'creatio_update_failed',
|
|
169
|
-
{
|
|
170
|
-
entity,
|
|
171
|
-
id,
|
|
172
|
-
url,
|
|
173
|
-
},
|
|
174
|
-
),
|
|
175
|
-
{ entity, id },
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
public async delete({ entity, id }: CrudDeleteParams) {
|
|
180
|
-
const url = `${this._buildEntityUrl(entity)}(${this._formatEntityKey(id)})`;
|
|
181
|
-
return this._client.executeWithTiming(
|
|
182
|
-
'delete',
|
|
183
|
-
url,
|
|
184
|
-
async () => {
|
|
185
|
-
const headers = await this._client.getJsonHeaders();
|
|
186
|
-
return this._client.fetchWithAuth(url, async () => ({
|
|
187
|
-
method: 'DELETE',
|
|
188
|
-
headers,
|
|
189
|
-
}));
|
|
190
|
-
},
|
|
191
|
-
async (response, duration) => {
|
|
192
|
-
this._client.logSuccess('delete', response.status, duration, { entity, id });
|
|
193
|
-
return response.text();
|
|
194
|
-
},
|
|
195
|
-
async (response, duration) =>
|
|
196
|
-
this._client.handleErrorResponse(
|
|
197
|
-
'delete',
|
|
198
|
-
response,
|
|
199
|
-
duration,
|
|
200
|
-
'creatio_delete_failed',
|
|
201
|
-
{
|
|
202
|
-
entity,
|
|
203
|
-
id,
|
|
204
|
-
url,
|
|
205
|
-
},
|
|
206
|
-
),
|
|
207
|
-
{ entity, id },
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { ExecuteProcessParams, ExecuteProcessResult, ProcessProvider } from '../providers';
|
|
2
|
-
|
|
3
|
-
import { CreatioHttpClient } from './http-client';
|
|
4
|
-
|
|
5
|
-
export class ProcessServiceProvider implements ProcessProvider {
|
|
6
|
-
private readonly _client: CreatioHttpClient;
|
|
7
|
-
|
|
8
|
-
public readonly kind = 'creatio-process-service';
|
|
9
|
-
|
|
10
|
-
constructor(client: CreatioHttpClient) {
|
|
11
|
-
this._client = client;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
private _getServiceUrl(): string {
|
|
15
|
-
return `${this._client.normalizedBaseUrl}/0/ServiceModel/ProcessEngineService.svc/RunProcess`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
private _createProcessParameterValues(parameters?: Record<string, any>): Array<{
|
|
19
|
-
name: string;
|
|
20
|
-
value: any;
|
|
21
|
-
}> {
|
|
22
|
-
const parameterValues: Array<{
|
|
23
|
-
name: string;
|
|
24
|
-
value: any;
|
|
25
|
-
}> = [];
|
|
26
|
-
if (!parameters) {
|
|
27
|
-
return parameterValues;
|
|
28
|
-
}
|
|
29
|
-
Object.entries(parameters).forEach(([name, value]) => {
|
|
30
|
-
let encodedValue = value;
|
|
31
|
-
if (value instanceof Date) {
|
|
32
|
-
encodedValue = value.toISOString();
|
|
33
|
-
}
|
|
34
|
-
parameterValues.push({
|
|
35
|
-
name,
|
|
36
|
-
value: encodedValue,
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
return parameterValues;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public async executeProcess({ processName, parameters }: ExecuteProcessParams) {
|
|
43
|
-
const url = this._getServiceUrl();
|
|
44
|
-
return this._client.executeWithTiming(
|
|
45
|
-
'execute-process',
|
|
46
|
-
url,
|
|
47
|
-
async () => {
|
|
48
|
-
const body = {
|
|
49
|
-
schemaName: processName,
|
|
50
|
-
parameterValues: this._createProcessParameterValues(parameters),
|
|
51
|
-
resultParameterNames: [],
|
|
52
|
-
};
|
|
53
|
-
const requestInit = await this._client.createPostRequest(body);
|
|
54
|
-
return this._client.fetchWithAuth(url, async () => requestInit);
|
|
55
|
-
},
|
|
56
|
-
async (response, duration) => {
|
|
57
|
-
this._client.logSuccess('execute-process', response.status, duration, {
|
|
58
|
-
processName,
|
|
59
|
-
});
|
|
60
|
-
return (await response.json()) as ExecuteProcessResult;
|
|
61
|
-
},
|
|
62
|
-
async (response, duration) =>
|
|
63
|
-
this._client.handleErrorResponse(
|
|
64
|
-
'execute-process',
|
|
65
|
-
response,
|
|
66
|
-
duration,
|
|
67
|
-
'creatio_execute_process_failed',
|
|
68
|
-
{
|
|
69
|
-
processName,
|
|
70
|
-
url,
|
|
71
|
-
},
|
|
72
|
-
),
|
|
73
|
-
{ processName },
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
CreateSysSettingRequest,
|
|
5
|
-
CreateSysSettingResult,
|
|
6
|
-
QuerySysSettingsResponse,
|
|
7
|
-
SysSettingDefinition,
|
|
8
|
-
SysSettingDefinitionUpdate,
|
|
9
|
-
SysSettingInsertResponse,
|
|
10
|
-
SysSettingUpdateResponse,
|
|
11
|
-
SysSettingsProvider,
|
|
12
|
-
} from '../providers';
|
|
13
|
-
|
|
14
|
-
import { CreatioHttpClient } from './http-client';
|
|
15
|
-
|
|
16
|
-
export class SysSettingsServiceProvider implements SysSettingsProvider {
|
|
17
|
-
private readonly _client: CreatioHttpClient;
|
|
18
|
-
|
|
19
|
-
public readonly kind = 'creatio-sys-settings-service';
|
|
20
|
-
|
|
21
|
-
constructor(client: CreatioHttpClient) {
|
|
22
|
-
this._client = client;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private _getSetValuesUrl(): string {
|
|
26
|
-
return `${this._client.normalizedBaseUrl}/0/DataService/json/SyncReply/PostSysSettingsValues`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private _getQueryUrl(): string {
|
|
30
|
-
return `${this._client.normalizedBaseUrl}/0/DataService/json/SyncReply/QuerySysSettings`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private _getInsertUrl(): string {
|
|
34
|
-
return `${this._client.normalizedBaseUrl}/0/DataService/json/SyncReply/InsertSysSettingRequest`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private _getUpdateUrl(): string {
|
|
38
|
-
return `${this._client.normalizedBaseUrl}/0/DataService/json/SyncReply/UpdateSysSettingRequest`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private async _insertSetting(
|
|
42
|
-
definition: SysSettingDefinition,
|
|
43
|
-
): Promise<SysSettingInsertResponse> {
|
|
44
|
-
const payload = {
|
|
45
|
-
id: definition.id ?? randomUUID(),
|
|
46
|
-
...definition,
|
|
47
|
-
};
|
|
48
|
-
return this._sendDefinitionRequest(
|
|
49
|
-
'insert-sys-setting',
|
|
50
|
-
this._getInsertUrl(),
|
|
51
|
-
payload,
|
|
52
|
-
(response) => response.json() as Promise<SysSettingInsertResponse>,
|
|
53
|
-
'creatio_insert_sys_setting_failed',
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private async _updateSetting(
|
|
58
|
-
definition: SysSettingDefinitionUpdate,
|
|
59
|
-
): Promise<SysSettingUpdateResponse> {
|
|
60
|
-
const payload = {
|
|
61
|
-
...definition,
|
|
62
|
-
};
|
|
63
|
-
return this._sendDefinitionRequest(
|
|
64
|
-
'update-sys-setting',
|
|
65
|
-
this._getUpdateUrl(),
|
|
66
|
-
payload,
|
|
67
|
-
(response) => response.json() as Promise<SysSettingUpdateResponse>,
|
|
68
|
-
'creatio_update_sys_setting_failed',
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private async _sendDefinitionRequest<T>(
|
|
73
|
-
operation: string,
|
|
74
|
-
url: string,
|
|
75
|
-
payload: Partial<SysSettingDefinition> & { id?: string | undefined },
|
|
76
|
-
parser: (response: Response) => Promise<T>,
|
|
77
|
-
errorPrefix: string,
|
|
78
|
-
): Promise<T> {
|
|
79
|
-
return this._client.executeWithTiming(
|
|
80
|
-
operation,
|
|
81
|
-
url,
|
|
82
|
-
async () => {
|
|
83
|
-
const requestInit = await this._client.createPostRequest(payload);
|
|
84
|
-
return this._client.fetchWithAuth(url, async () => requestInit);
|
|
85
|
-
},
|
|
86
|
-
async (response, duration) => {
|
|
87
|
-
const body = await parser(response);
|
|
88
|
-
this._client.logSuccess(operation, response.status, duration, {
|
|
89
|
-
code: payload.code,
|
|
90
|
-
id: payload.id,
|
|
91
|
-
});
|
|
92
|
-
return body;
|
|
93
|
-
},
|
|
94
|
-
async (response, duration) =>
|
|
95
|
-
this._client.handleErrorResponse(operation, response, duration, errorPrefix, {
|
|
96
|
-
code: payload.code,
|
|
97
|
-
id: payload.id,
|
|
98
|
-
url,
|
|
99
|
-
}),
|
|
100
|
-
{ code: payload.code, id: payload.id },
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public async setValues(sysSettingsValues: Record<string, any>): Promise<any> {
|
|
105
|
-
const url = this._getSetValuesUrl();
|
|
106
|
-
return this._client.executeWithTiming(
|
|
107
|
-
'set-sys-settings-value',
|
|
108
|
-
url,
|
|
109
|
-
async () => {
|
|
110
|
-
const body = {
|
|
111
|
-
isPersonal: false,
|
|
112
|
-
sysSettingsValues,
|
|
113
|
-
};
|
|
114
|
-
const requestInit = await this._client.createPostRequest(body);
|
|
115
|
-
return this._client.fetchWithAuth(url, async () => requestInit);
|
|
116
|
-
},
|
|
117
|
-
async (response, duration) => {
|
|
118
|
-
this._client.logSuccess('set-sys-settings-value', response.status, duration, {
|
|
119
|
-
settingsCount: Object.keys(sysSettingsValues).length,
|
|
120
|
-
});
|
|
121
|
-
return response.text();
|
|
122
|
-
},
|
|
123
|
-
async (response, duration) =>
|
|
124
|
-
this._client.handleErrorResponse(
|
|
125
|
-
'set-sys-settings-value',
|
|
126
|
-
response,
|
|
127
|
-
duration,
|
|
128
|
-
'creatio_set_sys_settings_value_failed',
|
|
129
|
-
{
|
|
130
|
-
settingsCount: Object.keys(sysSettingsValues).length,
|
|
131
|
-
url,
|
|
132
|
-
},
|
|
133
|
-
),
|
|
134
|
-
{ settingsCount: Object.keys(sysSettingsValues).length },
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public async queryValues(sysSettingCodes: string[]): Promise<QuerySysSettingsResponse> {
|
|
139
|
-
if (!sysSettingCodes || sysSettingCodes.length === 0) {
|
|
140
|
-
return { success: true, values: {} };
|
|
141
|
-
}
|
|
142
|
-
const url = this._getQueryUrl();
|
|
143
|
-
return this._client.executeWithTiming(
|
|
144
|
-
'query-sys-settings',
|
|
145
|
-
url,
|
|
146
|
-
async () => {
|
|
147
|
-
const body = {
|
|
148
|
-
sysSettingsNameCollection: sysSettingCodes,
|
|
149
|
-
};
|
|
150
|
-
const requestInit = await this._client.createPostRequest(body);
|
|
151
|
-
return this._client.fetchWithAuth(url, async () => requestInit);
|
|
152
|
-
},
|
|
153
|
-
async (response, duration) => {
|
|
154
|
-
const payload = (await response.json()) as QuerySysSettingsResponse;
|
|
155
|
-
this._client.logSuccess('query-sys-settings', response.status, duration, {
|
|
156
|
-
settingsCount: sysSettingCodes.length,
|
|
157
|
-
});
|
|
158
|
-
return payload;
|
|
159
|
-
},
|
|
160
|
-
async (response, duration) =>
|
|
161
|
-
this._client.handleErrorResponse(
|
|
162
|
-
'query-sys-settings',
|
|
163
|
-
response,
|
|
164
|
-
duration,
|
|
165
|
-
'creatio_query_sys_settings_failed',
|
|
166
|
-
{
|
|
167
|
-
settingsCount: sysSettingCodes.length,
|
|
168
|
-
url,
|
|
169
|
-
},
|
|
170
|
-
),
|
|
171
|
-
{ settingsCount: sysSettingCodes.length },
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
public async createSetting({
|
|
176
|
-
definition,
|
|
177
|
-
initialValue,
|
|
178
|
-
}: CreateSysSettingRequest): Promise<CreateSysSettingResult> {
|
|
179
|
-
const insertResult = await this._insertSetting(definition);
|
|
180
|
-
let setValueResult: any;
|
|
181
|
-
if (initialValue !== undefined) {
|
|
182
|
-
setValueResult = await this.setValues({ [definition.code]: initialValue });
|
|
183
|
-
}
|
|
184
|
-
return { insertResult, setValueResult };
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
public updateDefinition(
|
|
188
|
-
definition: SysSettingDefinitionUpdate,
|
|
189
|
-
): Promise<SysSettingUpdateResponse> {
|
|
190
|
-
return this._updateSetting(definition);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { CurrentUserInfo, UserProvider } from '../providers';
|
|
2
|
-
|
|
3
|
-
import { CreatioHttpClient } from './http-client';
|
|
4
|
-
|
|
5
|
-
export class UserInfoProvider implements UserProvider {
|
|
6
|
-
private readonly _client: CreatioHttpClient;
|
|
7
|
-
|
|
8
|
-
public readonly kind = 'creatio-user-info-service';
|
|
9
|
-
|
|
10
|
-
constructor(client: CreatioHttpClient) {
|
|
11
|
-
this._client = client;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
private _getServiceUrl(): string {
|
|
15
|
-
return `${this._client.normalizedBaseUrl}/0/ServiceModel/UserInfoService.svc/GetCurrentUserInfo`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public async getCurrentUserInfo(): Promise<CurrentUserInfo> {
|
|
19
|
-
const url = this._getServiceUrl();
|
|
20
|
-
return this._client.executeWithTiming(
|
|
21
|
-
'getCurrentUserInfo',
|
|
22
|
-
url,
|
|
23
|
-
async () => {
|
|
24
|
-
const requestInit = await this._client.createPostRequest();
|
|
25
|
-
return this._client.fetchWithAuth(url, async () => requestInit);
|
|
26
|
-
},
|
|
27
|
-
async (response, duration) => {
|
|
28
|
-
this._client.logSuccess('getCurrentUserInfo', response.status, duration);
|
|
29
|
-
const body = await response.json().catch(() => ({}));
|
|
30
|
-
return body as CurrentUserInfo;
|
|
31
|
-
},
|
|
32
|
-
async (response, duration) =>
|
|
33
|
-
this._client.handleErrorResponse(
|
|
34
|
-
'getCurrentUserInfo',
|
|
35
|
-
response,
|
|
36
|
-
duration,
|
|
37
|
-
'creatio_get_current_user_info_failed',
|
|
38
|
-
),
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { getCreatioClientConfig } from './config-builder';
|
|
2
|
-
import { HTTP_MCP_PORT } from './consts';
|
|
3
|
-
import { CreatioEngineManager, CreatioServiceContext } from './creatio';
|
|
4
|
-
import log from './log';
|
|
5
|
-
import { HttpServer, Server } from './server';
|
|
6
|
-
import { envBool } from './utils';
|
|
7
|
-
|
|
8
|
-
let _httpInstance: HttpServer | undefined;
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
log.appStart({ env: { node: process.version, HTTP_MCP_PORT } });
|
|
12
|
-
const cfg = getCreatioClientConfig();
|
|
13
|
-
const provider = new CreatioServiceContext(cfg);
|
|
14
|
-
const engines = new CreatioEngineManager(provider);
|
|
15
|
-
const server = new Server(engines, { readonlyMode: envBool('READONLY_MODE', false) });
|
|
16
|
-
const http = new HttpServer(server);
|
|
17
|
-
_httpInstance = http;
|
|
18
|
-
await http.start(HTTP_MCP_PORT);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let shuttingDown = false;
|
|
22
|
-
|
|
23
|
-
async function shutdown(signal?: string) {
|
|
24
|
-
if (shuttingDown) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
shuttingDown = true;
|
|
28
|
-
try {
|
|
29
|
-
log.appStop({ reason: signal || 'shutdown' });
|
|
30
|
-
await _httpInstance?.stop();
|
|
31
|
-
} catch (err) {
|
|
32
|
-
log.error('shutdown.error', { error: String(err) });
|
|
33
|
-
} finally {
|
|
34
|
-
process.exit(0);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
main().catch((err) => {
|
|
39
|
-
log.error('startup.error', { error: String(err) });
|
|
40
|
-
process.exit(1);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
44
|
-
process.on('SIGTERM', () => shutdown('SIGTERM'));
|