@kapeta/local-cluster-service 0.33.1 → 0.33.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/CHANGELOG.md +14 -0
- package/dist/cjs/src/proxy/types/web.js +1 -1
- package/dist/cjs/src/serviceManager.d.ts +1 -0
- package/dist/cjs/src/serviceManager.js +6 -6
- package/dist/cjs/src/utils/BlockInstanceRunner.d.ts +1 -0
- package/dist/cjs/src/utils/BlockInstanceRunner.js +11 -4
- package/dist/esm/src/proxy/types/web.js +1 -1
- package/dist/esm/src/serviceManager.d.ts +1 -0
- package/dist/esm/src/serviceManager.js +6 -6
- package/dist/esm/src/utils/BlockInstanceRunner.d.ts +1 -0
- package/dist/esm/src/utils/BlockInstanceRunner.js +11 -4
- package/package.json +2 -2
- package/src/proxy/types/web.ts +1 -1
- package/src/serviceManager.ts +6 -5
- package/src/utils/BlockInstanceRunner.ts +11 -4
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [0.33.3](https://github.com/kapetacom/local-cluster-service/compare/v0.33.2...v0.33.3) (2024-01-02)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Be consistent when mapping web + rest to http ([#109](https://github.com/kapetacom/local-cluster-service/issues/109)) ([9fde7d6](https://github.com/kapetacom/local-cluster-service/commit/9fde7d6ca4efa76888c25e2b7ad05f452d6c38db))
|
7
|
+
|
8
|
+
## [0.33.2](https://github.com/kapetacom/local-cluster-service/compare/v0.33.1...v0.33.2) (2023-12-30)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* Bump registry utils to fix broken installs ([7e6b04f](https://github.com/kapetacom/local-cluster-service/commit/7e6b04f7ae11de122f747d564abaa2f910e7ef32))
|
14
|
+
|
1
15
|
## [0.33.1](https://github.com/kapetacom/local-cluster-service/compare/v0.33.0...v0.33.1) (2023-12-30)
|
2
16
|
|
3
17
|
|
@@ -25,7 +25,7 @@ function proxyHttpRequest(req, res, opts) {
|
|
25
25
|
if (opts.consumerPath.startsWith(sourceBasePath)) {
|
26
26
|
path = path.replace(sourceBasePath, targetBasePath);
|
27
27
|
}
|
28
|
-
console.log('Proxy request to provider: %s => %s%s [
|
28
|
+
console.log('Proxy request to provider: %s => %s%s [http]', opts.consumerPath, opts.address, path);
|
29
29
|
const reqOpts = {
|
30
30
|
method: req.method,
|
31
31
|
url: opts.address + path,
|
@@ -7,13 +7,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
8
8
|
};
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
-
exports.serviceManager = exports.HTTP_PORTS = exports.DEFAULT_PORT_TYPE = void 0;
|
10
|
+
exports.serviceManager = exports.HTTP_PORTS = exports.DEFAULT_PORT_TYPE = exports.HTTP_PORT_TYPE = void 0;
|
11
11
|
const lodash_1 = __importDefault(require("lodash"));
|
12
12
|
const clusterService_1 = require("./clusterService");
|
13
13
|
const storageService_1 = require("./storageService");
|
14
14
|
const nodejs_utils_1 = require("@kapeta/nodejs-utils");
|
15
|
-
|
16
|
-
exports.
|
15
|
+
const BlockInstanceRunner_1 = require("./utils/BlockInstanceRunner");
|
16
|
+
exports.HTTP_PORT_TYPE = 'http';
|
17
|
+
exports.DEFAULT_PORT_TYPE = exports.HTTP_PORT_TYPE;
|
18
|
+
exports.HTTP_PORTS = [exports.HTTP_PORT_TYPE, 'web', 'rest'];
|
17
19
|
class ServiceManager {
|
18
20
|
_systems;
|
19
21
|
constructor() {
|
@@ -65,9 +67,7 @@ class ServiceManager {
|
|
65
67
|
if (!portType) {
|
66
68
|
portType = exports.DEFAULT_PORT_TYPE;
|
67
69
|
}
|
68
|
-
|
69
|
-
portType = 'http';
|
70
|
-
}
|
70
|
+
portType = (0, BlockInstanceRunner_1.resolvePortType)(portType);
|
71
71
|
const service = this._ensureService(systemId, blockInstanceId);
|
72
72
|
if (!service[portType]) {
|
73
73
|
const port = await clusterService_1.clusterService.getNextAvailablePort();
|
@@ -5,6 +5,7 @@
|
|
5
5
|
import { DefinitionInfo } from '@kapeta/local-cluster-config';
|
6
6
|
import { KapetaURI } from '@kapeta/nodejs-utils';
|
7
7
|
import { AnyMap, BlockProcessParams, ProcessInfo, StringMap } from '../types';
|
8
|
+
export declare function resolvePortType(portType: string): string;
|
8
9
|
export declare class BlockInstanceRunner {
|
9
10
|
private readonly _systemId;
|
10
11
|
constructor(systemId: string);
|
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
8
8
|
};
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
-
exports.BlockInstanceRunner = void 0;
|
10
|
+
exports.BlockInstanceRunner = exports.resolvePortType = void 0;
|
11
11
|
const node_fs_1 = __importDefault(require("node:fs"));
|
12
12
|
const local_cluster_config_1 = __importDefault(require("@kapeta/local-cluster-config"));
|
13
13
|
const utils_1 = require("./utils");
|
@@ -39,17 +39,24 @@ async function getProvider(uri) {
|
|
39
39
|
return (0, nodejs_utils_1.parseKapetaUri)(ref).id === uri.id;
|
40
40
|
});
|
41
41
|
}
|
42
|
+
function resolvePortType(portType) {
|
43
|
+
if (serviceManager_1.HTTP_PORTS.includes(portType)) {
|
44
|
+
return serviceManager_1.HTTP_PORT_TYPE;
|
45
|
+
}
|
46
|
+
return portType;
|
47
|
+
}
|
48
|
+
exports.resolvePortType = resolvePortType;
|
42
49
|
function getProviderPorts(assetVersion, providerVersion) {
|
43
50
|
const out = assetVersion.definition?.spec?.providers
|
44
51
|
?.map((provider) => {
|
45
|
-
return provider.spec?.port?.type;
|
52
|
+
return resolvePortType(provider.spec?.port?.type);
|
46
53
|
})
|
47
54
|
.filter((t) => !!t) ?? [];
|
48
55
|
if (out.length === 0) {
|
49
56
|
if (providerVersion.definition.spec?.defaultPort?.type) {
|
50
|
-
return [providerVersion.definition.spec?.defaultPort?.type];
|
57
|
+
return [resolvePortType(providerVersion.definition.spec?.defaultPort?.type)];
|
51
58
|
}
|
52
|
-
return [serviceManager_1.DEFAULT_PORT_TYPE];
|
59
|
+
return [resolvePortType(serviceManager_1.DEFAULT_PORT_TYPE)];
|
53
60
|
}
|
54
61
|
// Duplicated port types are not allowed
|
55
62
|
return Array.from(new Set(out));
|
@@ -25,7 +25,7 @@ function proxyHttpRequest(req, res, opts) {
|
|
25
25
|
if (opts.consumerPath.startsWith(sourceBasePath)) {
|
26
26
|
path = path.replace(sourceBasePath, targetBasePath);
|
27
27
|
}
|
28
|
-
console.log('Proxy request to provider: %s => %s%s [
|
28
|
+
console.log('Proxy request to provider: %s => %s%s [http]', opts.consumerPath, opts.address, path);
|
29
29
|
const reqOpts = {
|
30
30
|
method: req.method,
|
31
31
|
url: opts.address + path,
|
@@ -7,13 +7,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
8
8
|
};
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
-
exports.serviceManager = exports.HTTP_PORTS = exports.DEFAULT_PORT_TYPE = void 0;
|
10
|
+
exports.serviceManager = exports.HTTP_PORTS = exports.DEFAULT_PORT_TYPE = exports.HTTP_PORT_TYPE = void 0;
|
11
11
|
const lodash_1 = __importDefault(require("lodash"));
|
12
12
|
const clusterService_1 = require("./clusterService");
|
13
13
|
const storageService_1 = require("./storageService");
|
14
14
|
const nodejs_utils_1 = require("@kapeta/nodejs-utils");
|
15
|
-
|
16
|
-
exports.
|
15
|
+
const BlockInstanceRunner_1 = require("./utils/BlockInstanceRunner");
|
16
|
+
exports.HTTP_PORT_TYPE = 'http';
|
17
|
+
exports.DEFAULT_PORT_TYPE = exports.HTTP_PORT_TYPE;
|
18
|
+
exports.HTTP_PORTS = [exports.HTTP_PORT_TYPE, 'web', 'rest'];
|
17
19
|
class ServiceManager {
|
18
20
|
_systems;
|
19
21
|
constructor() {
|
@@ -65,9 +67,7 @@ class ServiceManager {
|
|
65
67
|
if (!portType) {
|
66
68
|
portType = exports.DEFAULT_PORT_TYPE;
|
67
69
|
}
|
68
|
-
|
69
|
-
portType = 'http';
|
70
|
-
}
|
70
|
+
portType = (0, BlockInstanceRunner_1.resolvePortType)(portType);
|
71
71
|
const service = this._ensureService(systemId, blockInstanceId);
|
72
72
|
if (!service[portType]) {
|
73
73
|
const port = await clusterService_1.clusterService.getNextAvailablePort();
|
@@ -5,6 +5,7 @@
|
|
5
5
|
import { DefinitionInfo } from '@kapeta/local-cluster-config';
|
6
6
|
import { KapetaURI } from '@kapeta/nodejs-utils';
|
7
7
|
import { AnyMap, BlockProcessParams, ProcessInfo, StringMap } from '../types';
|
8
|
+
export declare function resolvePortType(portType: string): string;
|
8
9
|
export declare class BlockInstanceRunner {
|
9
10
|
private readonly _systemId;
|
10
11
|
constructor(systemId: string);
|
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
8
8
|
};
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
-
exports.BlockInstanceRunner = void 0;
|
10
|
+
exports.BlockInstanceRunner = exports.resolvePortType = void 0;
|
11
11
|
const node_fs_1 = __importDefault(require("node:fs"));
|
12
12
|
const local_cluster_config_1 = __importDefault(require("@kapeta/local-cluster-config"));
|
13
13
|
const utils_1 = require("./utils");
|
@@ -39,17 +39,24 @@ async function getProvider(uri) {
|
|
39
39
|
return (0, nodejs_utils_1.parseKapetaUri)(ref).id === uri.id;
|
40
40
|
});
|
41
41
|
}
|
42
|
+
function resolvePortType(portType) {
|
43
|
+
if (serviceManager_1.HTTP_PORTS.includes(portType)) {
|
44
|
+
return serviceManager_1.HTTP_PORT_TYPE;
|
45
|
+
}
|
46
|
+
return portType;
|
47
|
+
}
|
48
|
+
exports.resolvePortType = resolvePortType;
|
42
49
|
function getProviderPorts(assetVersion, providerVersion) {
|
43
50
|
const out = assetVersion.definition?.spec?.providers
|
44
51
|
?.map((provider) => {
|
45
|
-
return provider.spec?.port?.type;
|
52
|
+
return resolvePortType(provider.spec?.port?.type);
|
46
53
|
})
|
47
54
|
.filter((t) => !!t) ?? [];
|
48
55
|
if (out.length === 0) {
|
49
56
|
if (providerVersion.definition.spec?.defaultPort?.type) {
|
50
|
-
return [providerVersion.definition.spec?.defaultPort?.type];
|
57
|
+
return [resolvePortType(providerVersion.definition.spec?.defaultPort?.type)];
|
51
58
|
}
|
52
|
-
return [serviceManager_1.DEFAULT_PORT_TYPE];
|
59
|
+
return [resolvePortType(serviceManager_1.DEFAULT_PORT_TYPE)];
|
53
60
|
}
|
54
61
|
// Duplicated port types are not allowed
|
55
62
|
return Array.from(new Set(out));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@kapeta/local-cluster-service",
|
3
|
-
"version": "0.33.
|
3
|
+
"version": "0.33.3",
|
4
4
|
"description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
|
5
5
|
"type": "commonjs",
|
6
6
|
"exports": {
|
@@ -51,7 +51,7 @@
|
|
51
51
|
"@kapeta/local-cluster-config": ">= 0.3.0 <2",
|
52
52
|
"@kapeta/nodejs-api-client": ">=0.1.3 <2",
|
53
53
|
"@kapeta/nodejs-process": "<2",
|
54
|
-
"@kapeta/nodejs-registry-utils": "<2",
|
54
|
+
"@kapeta/nodejs-registry-utils": ">=0.8.4 <2",
|
55
55
|
"@kapeta/nodejs-utils": "<2",
|
56
56
|
"@kapeta/schemas": "<2",
|
57
57
|
"@kapeta/sdk-config": "<2",
|
package/src/proxy/types/web.ts
CHANGED
@@ -27,7 +27,7 @@ export function proxyHttpRequest(req: StringBodyRequest, res: Response, opts: Pr
|
|
27
27
|
path = path.replace(sourceBasePath, targetBasePath);
|
28
28
|
}
|
29
29
|
|
30
|
-
console.log('Proxy request to provider: %s => %s%s [
|
30
|
+
console.log('Proxy request to provider: %s => %s%s [http]', opts.consumerPath, opts.address, path);
|
31
31
|
|
32
32
|
const reqOpts: SimpleRequest = {
|
33
33
|
method: req.method,
|
package/src/serviceManager.ts
CHANGED
@@ -8,10 +8,13 @@ import { clusterService } from './clusterService';
|
|
8
8
|
import { storageService } from './storageService';
|
9
9
|
import { EnvironmentType } from './types';
|
10
10
|
import { normalizeKapetaUri } from '@kapeta/nodejs-utils';
|
11
|
+
import { resolvePortType } from './utils/BlockInstanceRunner';
|
11
12
|
|
12
|
-
export const
|
13
|
+
export const HTTP_PORT_TYPE = 'http';
|
13
14
|
|
14
|
-
export const
|
15
|
+
export const DEFAULT_PORT_TYPE = HTTP_PORT_TYPE;
|
16
|
+
|
17
|
+
export const HTTP_PORTS = [HTTP_PORT_TYPE, 'web', 'rest'];
|
15
18
|
|
16
19
|
class ServiceManager {
|
17
20
|
private _systems: any;
|
@@ -75,9 +78,7 @@ class ServiceManager {
|
|
75
78
|
portType = DEFAULT_PORT_TYPE;
|
76
79
|
}
|
77
80
|
|
78
|
-
|
79
|
-
portType = 'http';
|
80
|
-
}
|
81
|
+
portType = resolvePortType(portType);
|
81
82
|
|
82
83
|
const service = this._ensureService(systemId, blockInstanceId);
|
83
84
|
|
@@ -7,7 +7,7 @@ import FS from 'node:fs';
|
|
7
7
|
import ClusterConfig, { DefinitionInfo } from '@kapeta/local-cluster-config';
|
8
8
|
import { getBindHost, getBlockInstanceContainerName, readYML } from './utils';
|
9
9
|
import { KapetaURI, parseKapetaUri, normalizeKapetaUri } from '@kapeta/nodejs-utils';
|
10
|
-
import { DEFAULT_PORT_TYPE, serviceManager } from '../serviceManager';
|
10
|
+
import { DEFAULT_PORT_TYPE, HTTP_PORT_TYPE, HTTP_PORTS, serviceManager } from '../serviceManager';
|
11
11
|
import {
|
12
12
|
COMPOSE_LABEL_PROJECT,
|
13
13
|
COMPOSE_LABEL_SERVICE,
|
@@ -45,19 +45,26 @@ async function getProvider(uri: KapetaURI) {
|
|
45
45
|
});
|
46
46
|
}
|
47
47
|
|
48
|
+
export function resolvePortType(portType: string) {
|
49
|
+
if (HTTP_PORTS.includes(portType)) {
|
50
|
+
return HTTP_PORT_TYPE;
|
51
|
+
}
|
52
|
+
return portType;
|
53
|
+
}
|
54
|
+
|
48
55
|
function getProviderPorts(assetVersion: DefinitionInfo, providerVersion: DefinitionInfo): string[] {
|
49
56
|
const out =
|
50
57
|
assetVersion.definition?.spec?.providers
|
51
58
|
?.map((provider: any) => {
|
52
|
-
return provider.spec?.port?.type;
|
59
|
+
return resolvePortType(provider.spec?.port?.type);
|
53
60
|
})
|
54
61
|
.filter((t: any) => !!t) ?? [];
|
55
62
|
|
56
63
|
if (out.length === 0) {
|
57
64
|
if (providerVersion.definition.spec?.defaultPort?.type) {
|
58
|
-
return [providerVersion.definition.spec?.defaultPort?.type];
|
65
|
+
return [resolvePortType(providerVersion.definition.spec?.defaultPort?.type)];
|
59
66
|
}
|
60
|
-
return [DEFAULT_PORT_TYPE];
|
67
|
+
return [resolvePortType(DEFAULT_PORT_TYPE)];
|
61
68
|
}
|
62
69
|
// Duplicated port types are not allowed
|
63
70
|
return Array.from(new Set<string>(out));
|