@contember/engine-server 1.1.1 → 1.2.0-alpha.10
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/src/MasterContainer.d.ts +27 -25
- package/dist/src/MasterContainer.d.ts.map +1 -1
- package/dist/src/MasterContainer.js +54 -80
- package/dist/src/MasterContainer.js.map +1 -1
- package/dist/src/bootstrap/Initializer.d.ts +3 -3
- package/dist/src/bootstrap/Initializer.d.ts.map +1 -1
- package/dist/src/bootstrap/Initializer.js +15 -8
- package/dist/src/bootstrap/Initializer.js.map +1 -1
- package/dist/src/config/config.d.ts +5 -4
- package/dist/src/config/config.d.ts.map +1 -1
- package/dist/src/config/config.js +2 -2
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/configSchema.d.ts +45 -11
- package/dist/src/config/configSchema.d.ts.map +1 -1
- package/dist/src/config/configSchema.js +20 -18
- package/dist/src/config/configSchema.js.map +1 -1
- package/dist/src/config/configTemplate.d.ts.map +1 -1
- package/dist/src/config/configTemplate.js +23 -0
- package/dist/src/config/configTemplate.js.map +1 -1
- package/dist/src/index.d.ts +9 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/project/ProjectContainer.js +1 -1
- package/dist/src/project/ProjectContainer.js.map +1 -1
- package/dist/src/project/ProjectContainerResolver.d.ts +6 -3
- package/dist/src/project/ProjectContainerResolver.d.ts.map +1 -1
- package/dist/src/project/ProjectContainerResolver.js +4 -16
- package/dist/src/project/ProjectContainerResolver.js.map +1 -1
- package/dist/src/projectGroup/ProjectGroupContainer.d.ts +2 -1
- package/dist/src/projectGroup/ProjectGroupContainer.d.ts.map +1 -1
- package/dist/src/projectGroup/ProjectGroupContainer.js +8 -4
- package/dist/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/src/projectGroup/ProjectGroupResolver.d.ts +7 -0
- package/dist/src/projectGroup/ProjectGroupResolver.d.ts.map +1 -0
- package/dist/src/projectGroup/ProjectGroupResolver.js +13 -0
- package/dist/src/projectGroup/ProjectGroupResolver.js.map +1 -0
- package/dist/src/start.js +15 -112
- package/dist/src/start.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/index.d.ts +0 -4
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +0 -4
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/sentry.d.ts +1 -1
- package/dist/src/utils/sentry.d.ts.map +1 -1
- package/dist/src/utils/sentry.js +1 -1
- package/dist/src/utils/sentry.js.map +1 -1
- package/dist/src/utils/serverStartup.d.ts +31 -0
- package/dist/src/utils/serverStartup.d.ts.map +1 -0
- package/dist/src/utils/serverStartup.js +42 -0
- package/dist/src/utils/serverStartup.js.map +1 -0
- package/dist/src/utils/serverTermination.d.ts +12 -0
- package/dist/src/utils/serverTermination.d.ts.map +1 -0
- package/dist/src/utils/serverTermination.js +26 -0
- package/dist/src/utils/serverTermination.js.map +1 -0
- package/dist/tests/e2e/acl-condition-variable.test.d.ts +2 -0
- package/dist/tests/e2e/acl-condition-variable.test.d.ts.map +1 -0
- package/dist/tests/e2e/acl-condition-variable.test.js +77 -0
- package/dist/tests/e2e/acl-condition-variable.test.js.map +1 -0
- package/dist/tests/e2e/assume-identity.test.d.ts +2 -0
- package/dist/tests/e2e/assume-identity.test.d.ts.map +1 -0
- package/dist/tests/e2e/assume-identity.test.js +109 -0
- package/dist/tests/e2e/assume-identity.test.js.map +1 -0
- package/dist/tests/e2e/assume-membership.test.d.ts +2 -0
- package/dist/tests/e2e/assume-membership.test.d.ts.map +1 -0
- package/dist/tests/e2e/assume-membership.test.js +58 -0
- package/dist/tests/e2e/assume-membership.test.js.map +1 -0
- package/dist/tests/e2e/content-api-basic.test.d.ts +2 -0
- package/dist/tests/e2e/content-api-basic.test.d.ts.map +1 -0
- package/dist/tests/e2e/content-api-basic.test.js +50 -0
- package/dist/tests/e2e/content-api-basic.test.js.map +1 -0
- package/dist/tests/e2e/content-invalid-schema.test.d.ts +2 -0
- package/dist/tests/e2e/content-invalid-schema.test.d.ts.map +1 -0
- package/dist/tests/e2e/content-invalid-schema.test.js +29 -0
- package/dist/tests/e2e/content-invalid-schema.test.js.map +1 -0
- package/dist/tests/e2e/homepage.test.d.ts +2 -0
- package/dist/tests/e2e/homepage.test.d.ts.map +1 -0
- package/dist/tests/e2e/homepage.test.js +15 -0
- package/dist/tests/e2e/homepage.test.js.map +1 -0
- package/dist/tests/e2e/tenant-member-access.test.d.ts +2 -0
- package/dist/tests/e2e/tenant-member-access.test.d.ts.map +1 -0
- package/dist/tests/e2e/tenant-member-access.test.js +43 -0
- package/dist/tests/e2e/tenant-member-access.test.js.map +1 -0
- package/dist/tests/e2e/x-contember-ref.test.d.ts +2 -0
- package/dist/tests/e2e/x-contember-ref.test.d.ts.map +1 -0
- package/dist/tests/e2e/x-contember-ref.test.js +63 -0
- package/dist/tests/e2e/x-contember-ref.test.js.map +1 -0
- package/dist/tests/src/requests.d.ts +5 -0
- package/dist/tests/src/requests.d.ts.map +1 -0
- package/dist/tests/src/requests.js +68 -0
- package/dist/tests/src/requests.js.map +1 -0
- package/dist/tests/src/tester.d.ts +19 -0
- package/dist/tests/src/tester.d.ts.map +1 -0
- package/dist/tests/src/tester.js +99 -0
- package/dist/tests/src/tester.js.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/esbuild.js +7 -14
- package/package.json +23 -23
- package/src/MasterContainer.ts +94 -110
- package/src/bootstrap/Initializer.ts +16 -8
- package/src/config/config.ts +7 -5
- package/src/config/configSchema.ts +30 -33
- package/src/config/configTemplate.ts +23 -0
- package/src/index.ts +15 -2
- package/src/project/ProjectContainer.ts +1 -1
- package/src/project/ProjectContainerResolver.ts +4 -17
- package/src/projectGroup/ProjectGroupContainer.ts +12 -3
- package/src/projectGroup/ProjectGroupResolver.ts +12 -0
- package/src/start.ts +18 -127
- package/src/utils/index.ts +0 -4
- package/src/utils/sentry.ts +1 -1
- package/src/utils/serverStartup.ts +42 -0
- package/src/utils/serverTermination.ts +20 -0
- package/tests/e2e/acl-condition-variable.test.ts +74 -0
- package/tests/e2e/assume-identity.test.ts +127 -0
- package/tests/e2e/assume-membership.test.ts +64 -0
- package/tests/e2e/content-api-basic.test.ts +51 -0
- package/tests/e2e/content-invalid-schema.test.ts +31 -0
- package/tests/e2e/homepage.test.ts +10 -0
- package/tests/e2e/tenant-member-access.test.ts +51 -0
- package/tests/e2e/x-contember-ref.test.ts +71 -0
- package/tests/src/requests.ts +81 -0
- package/tests/src/tester.ts +118 -0
- package/alpine.dockerfile +0 -30
- package/debian.dockerfile +0 -27
- package/dist/src/http/CollectHttpMetricsMiddelware.d.ts +0 -5
- package/dist/src/http/CollectHttpMetricsMiddelware.d.ts.map +0 -1
- package/dist/src/http/CollectHttpMetricsMiddelware.js +0 -36
- package/dist/src/http/CollectHttpMetricsMiddelware.js.map +0 -1
- package/dist/src/http/ShowMetricsMiddleware.d.ts +0 -4
- package/dist/src/http/ShowMetricsMiddleware.d.ts.map +0 -1
- package/dist/src/http/ShowMetricsMiddleware.js +0 -20
- package/dist/src/http/ShowMetricsMiddleware.js.map +0 -1
- package/dist/src/http/index.d.ts +0 -3
- package/dist/src/http/index.d.ts.map +0 -1
- package/dist/src/http/index.js +0 -19
- package/dist/src/http/index.js.map +0 -1
- package/dist/src/projectGroup/ProjectGroupContainerResolver.d.ts +0 -12
- package/dist/src/projectGroup/ProjectGroupContainerResolver.d.ts.map +0 -1
- package/dist/src/projectGroup/ProjectGroupContainerResolver.js +0 -36
- package/dist/src/projectGroup/ProjectGroupContainerResolver.js.map +0 -1
- package/dist/src/utils/cluster.d.ts +0 -9
- package/dist/src/utils/cluster.d.ts.map +0 -1
- package/dist/src/utils/cluster.js +0 -47
- package/dist/src/utils/cluster.js.map +0 -1
- package/dist/src/utils/dbMetrics.d.ts +0 -16
- package/dist/src/utils/dbMetrics.d.ts.map +0 -1
- package/dist/src/utils/dbMetrics.js +0 -98
- package/dist/src/utils/dbMetrics.js.map +0 -1
- package/dist/src/utils/timeout.d.ts +0 -2
- package/dist/src/utils/timeout.d.ts.map +0 -1
- package/dist/src/utils/timeout.js +0 -8
- package/dist/src/utils/timeout.js.map +0 -1
- package/dist/src/utils/tuple.d.ts +0 -2
- package/dist/src/utils/tuple.d.ts.map +0 -1
- package/dist/src/utils/tuple.js +0 -6
- package/dist/src/utils/tuple.js.map +0 -1
- package/dist/tests/e2e/http.test.d.ts +0 -2
- package/dist/tests/e2e/http.test.d.ts.map +0 -1
- package/dist/tests/e2e/http.test.js +0 -275
- package/dist/tests/e2e/http.test.js.map +0 -1
- package/jasmine.json +0 -7
- package/src/http/CollectHttpMetricsMiddelware.ts +0 -32
- package/src/http/ShowMetricsMiddleware.ts +0 -12
- package/src/http/index.ts +0 -2
- package/src/projectGroup/ProjectGroupContainerResolver.ts +0 -47
- package/src/utils/cluster.ts +0 -40
- package/src/utils/dbMetrics.ts +0 -111
- package/src/utils/timeout.ts +0 -4
- package/src/utils/tuple.ts +0 -1
- package/tests/e2e/http.test.ts +0 -303
- package/tslint.json +0 -14
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../../src/utils/cluster.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,uCAAmC;AAE5B,MAAM,qBAAqB,GAAG,CAAC,aAAsB,EAAE,EAAE,CAC/D,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAA;AADtG,QAAA,qBAAqB,yBACiF;AAEnH,IAAY,WAIX;AAJD,WAAY,WAAW;IACtB,yDAAU,CAAA;IACV,+DAAa,CAAA;IACb,+DAAa,CAAA;AACd,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAED,MAAM,kBAAkB,GAAG,oBAAoB,CAAA;AAExC,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE;IAClD,IAAI,EAAE,GAAG,KAAK,CAAA;IACd,OAAO,OAAO,CAAC,IAAI,CAAC;QACnB,IAAI,OAAO,CAAC,KAAK,EAAC,OAAO,EAAC,EAAE;YAC3B,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,OAAY,EAAE,EAAE;gBACrC,IAAI,MAAM,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,EAAE;oBAC7D,EAAE,GAAG,IAAI,CAAA;oBACT,OAAO,CAAC,IAAI,CAAC,CAAA;oBACb,iBAAO,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;iBAC3C;YACF,CAAC,CAAA;YACD,MAAM,iBAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;QACtC,CAAC,CAAC;QACF,IAAA,iBAAO,EAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAC5B,IAAI,CAAC,EAAE,EAAE;gBACR,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;aACzC;YACD,OAAO,IAAI,CAAA;QACZ,CAAC,CAAC;KACF,CAAC,CAAA;AACH,CAAC,CAAA;AApBY,QAAA,aAAa,iBAoBzB;AAEM,MAAM,mBAAmB,GAAG,GAAG,EAAE;;IACvC,OAAA,MAAA,OAAO,CAAC,IAAI,wDAAG;QACd,IAAI,EAAE,kBAAkB;KACxB,CAAC,CAAA;CAAA,CAAA;AAHU,QAAA,mBAAmB,uBAG7B"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import prom from 'prom-client';
|
|
2
|
-
import { Connection } from '@contember/database';
|
|
3
|
-
declare const labelNames: ("contember_project" | "contember_module" | "contember_project_group")[];
|
|
4
|
-
declare type LabelNames = typeof labelNames[number];
|
|
5
|
-
declare type Labels = {
|
|
6
|
-
[K in LabelNames]: string;
|
|
7
|
-
};
|
|
8
|
-
declare type DatabaseMetricsEntry = {
|
|
9
|
-
connection: Connection.PoolStatusProvider & Connection.Queryable;
|
|
10
|
-
labels: Labels;
|
|
11
|
-
};
|
|
12
|
-
declare type Unregistrar = () => void;
|
|
13
|
-
declare type DatabaseMetricsRegistrar = (entry: DatabaseMetricsEntry) => Unregistrar;
|
|
14
|
-
export declare const createDbMetricsRegistrar: (registry: prom.Registry) => DatabaseMetricsRegistrar;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=dbMetrics.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dbMetrics.d.ts","sourceRoot":"","sources":["../../../src/utils/dbMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAgB,MAAM,qBAAqB,CAAA;AAE9D,QAAA,MAAM,UAAU,0EAAkG,CAAA;AAClH,aAAK,UAAU,GAAG,OAAO,UAAU,CAAC,MAAM,CAAC,CAAA;AAC3C,aAAK,MAAM,GAAG;KAAG,CAAC,IAAI,UAAU,GAAG,MAAM;CAAE,CAAA;AAC3C,aAAK,oBAAoB,GAAG;IAC3B,UAAU,EAAE,UAAU,CAAC,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAA;IAChE,MAAM,EAAE,MAAM,CAAA;CACd,CAAA;AACD,aAAK,WAAW,GAAG,MAAM,IAAI,CAAA;AAC7B,aAAK,wBAAwB,GAAG,CAAC,KAAK,EAAE,oBAAoB,KAAK,WAAW,CAAA;AAE5E,eAAO,MAAM,wBAAwB,aAAc,KAAK,QAAQ,KAAG,wBAkBlE,CAAA"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createDbMetricsRegistrar = void 0;
|
|
7
|
-
const prom_client_1 = __importDefault(require("prom-client"));
|
|
8
|
-
const database_1 = require("@contember/database");
|
|
9
|
-
const labelNames = ['contember_project', 'contember_module', 'contember_project_group'];
|
|
10
|
-
const createDbMetricsRegistrar = (registry) => {
|
|
11
|
-
const dbPoolCollectorInner = createSingleDbPoolMetricsCollector(registry);
|
|
12
|
-
const entries = new Set();
|
|
13
|
-
const collector = () => {
|
|
14
|
-
for (const entry of entries) {
|
|
15
|
-
dbPoolCollectorInner(entry.connection, entry.labels);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
registry.registerCollector(collector);
|
|
19
|
-
const sqlMetricsRegistrar = createSqlMetricsRegistrar(registry);
|
|
20
|
-
return entry => {
|
|
21
|
-
entries.add(entry);
|
|
22
|
-
const sqlMetricsUnregistrar = sqlMetricsRegistrar(entry.connection, entry.labels);
|
|
23
|
-
return () => {
|
|
24
|
-
entries.delete(entry);
|
|
25
|
-
sqlMetricsUnregistrar();
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
exports.createDbMetricsRegistrar = createDbMetricsRegistrar;
|
|
30
|
-
const createSingleDbPoolMetricsCollector = (registry) => {
|
|
31
|
-
const totalCount = new prom_client_1.default.Gauge({
|
|
32
|
-
registers: [registry],
|
|
33
|
-
name: `contember_db_pool_total_count`,
|
|
34
|
-
help: 'The total number of clients existing within the pool by contember_module (tenant or content; system is not used since it uses the same connection) and contember_project for contember_module=content.',
|
|
35
|
-
labelNames,
|
|
36
|
-
});
|
|
37
|
-
const idleCount = new prom_client_1.default.Gauge({
|
|
38
|
-
registers: [registry],
|
|
39
|
-
name: `contember_db_pool_idle_count`,
|
|
40
|
-
help: 'The number of clients which are not checked out but are currently idle in the pool by contember_module (tenant or content; system is not used since it uses the same connection) and contember_project for contember_module=content.',
|
|
41
|
-
labelNames,
|
|
42
|
-
});
|
|
43
|
-
const waitingCount = new prom_client_1.default.Gauge({
|
|
44
|
-
registers: [registry],
|
|
45
|
-
name: `contember_db_pool_waiting_count`,
|
|
46
|
-
help: 'The number of queued requests waiting on a client when all clients are checked out. It can be helpful to monitor this number to see if you need to adjust the size of the pool by contember_module (tenant or content; system is not used since it uses the same connection) and contember_project for contember_module=content.',
|
|
47
|
-
labelNames,
|
|
48
|
-
});
|
|
49
|
-
const maxCount = new prom_client_1.default.Gauge({
|
|
50
|
-
registers: [registry],
|
|
51
|
-
name: `contember_db_pool_max_count`,
|
|
52
|
-
help: 'Maximum number of clients the pool should contain by contember_module (tenant or content; system is not used since it uses the same connection) and contember_project for contember_module=content.',
|
|
53
|
-
labelNames,
|
|
54
|
-
});
|
|
55
|
-
return (db, labels) => {
|
|
56
|
-
const poolInfo = db.getPoolStatus();
|
|
57
|
-
totalCount.set(labels, poolInfo.totalCount);
|
|
58
|
-
idleCount.set(labels, poolInfo.idleCount);
|
|
59
|
-
waitingCount.set(labels, poolInfo.waitingCount);
|
|
60
|
-
maxCount.set(labels, poolInfo.maxCount);
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const createSqlMetricsRegistrar = (registry) => {
|
|
64
|
-
const sqlDuration = new prom_client_1.default.Histogram({
|
|
65
|
-
name: 'contember_sql_duration_ms',
|
|
66
|
-
help: 'Executed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or "unknown" for unknown project)',
|
|
67
|
-
registers: [registry],
|
|
68
|
-
labelNames,
|
|
69
|
-
buckets: [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000],
|
|
70
|
-
});
|
|
71
|
-
const sqlErrorRate = new prom_client_1.default.Counter({
|
|
72
|
-
name: 'contember_sql_error_count',
|
|
73
|
-
help: 'Failed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or "unknown" for unknown project)',
|
|
74
|
-
labelNames,
|
|
75
|
-
registers: [registry],
|
|
76
|
-
});
|
|
77
|
-
return (connection, labels) => {
|
|
78
|
-
const queryEndCallback = ({ meta }, { timing }) => {
|
|
79
|
-
sqlDuration.observe({
|
|
80
|
-
...labels,
|
|
81
|
-
contember_module: meta.module || labels.contember_module,
|
|
82
|
-
}, timing ? timing.selfDuration / 1000 : 0);
|
|
83
|
-
};
|
|
84
|
-
const queryErrorCallback = ({ meta }) => {
|
|
85
|
-
sqlErrorRate.inc({
|
|
86
|
-
...labels,
|
|
87
|
-
contember_module: meta.module || labels.contember_module,
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
connection.eventManager.on(database_1.EventManager.Event.queryEnd, queryEndCallback);
|
|
91
|
-
connection.eventManager.on(database_1.EventManager.Event.queryError, queryErrorCallback);
|
|
92
|
-
return () => {
|
|
93
|
-
connection.eventManager.removeListener(database_1.EventManager.Event.queryEnd, queryEndCallback);
|
|
94
|
-
connection.eventManager.removeListener(database_1.EventManager.Event.queryError, queryErrorCallback);
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
//# sourceMappingURL=dbMetrics.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dbMetrics.js","sourceRoot":"","sources":["../../../src/utils/dbMetrics.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA8B;AAC9B,kDAA8D;AAE9D,MAAM,UAAU,GAAG,CAAC,mBAA4B,EAAE,kBAA2B,EAAE,yBAAkC,CAAC,CAAA;AAU3G,MAAM,wBAAwB,GAAG,CAAC,QAAuB,EAA4B,EAAE;IAC7F,MAAM,oBAAoB,GAAG,kCAAkC,CAAC,QAAQ,CAAC,CAAA;IACzE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAA;IAC/C,MAAM,SAAS,GAAG,GAAG,EAAE;QACtB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YAC5B,oBAAoB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;SACpD;IACF,CAAC,CAAA;IACD,QAAQ,C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CAAC,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CACvC,CAAA;QACF,CAAC,CAAA;QACD,MAAM,kBAAkB,GAA8D,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;YAClG,YAAY,CAAC,GAAG,CAAC;gBAChB,GAAG,MAAM;gBACT,gBAAgB,EAAE,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,gBAAgB;aACxD,CAAC,CAAA;QACH,CAAC,CAAA;QACD,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,uBAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;QACzE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,uBAAY,CAAC,KAAK,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAA;QAC7E,OAAO,GAAG,EAAE;YACX,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,uBAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;YACrF,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,uBAAY,CAAC,KAAK,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAA;QAC1F,CAAC,CAAA;IACF,CAAC,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../../src/utils/timeout.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,OAAQ,MAAM,qBAG/B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../../src/utils/timeout.ts"],"names":[],"mappings":";;;AAAO,MAAM,OAAO,GAAG,CAAC,EAAU,EAAE,EAAE,CACrC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;IACrB,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AACxB,CAAC,CAAC,CAAA;AAHU,QAAA,OAAO,WAGjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../../../src/utils/tuple.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,wCAA4C,CAAA"}
|
package/dist/src/utils/tuple.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../../src/utils/tuple.ts"],"names":[],"mappings":";;;AAAO,MAAM,KAAK,GAAG,CAAsB,GAAG,IAAO,EAAE,EAAE,CAAC,IAAI,CAAA;AAAjD,QAAA,KAAK,SAA4C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.test.d.ts","sourceRoot":"","sources":["../../../tests/e2e/http.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const supertest_1 = __importDefault(require("supertest"));
|
|
30
|
-
const nodeAssert = __importStar(require("assert"));
|
|
31
|
-
const vitest_1 = require("vitest");
|
|
32
|
-
const schema_migrations_1 = require("@contember/schema-migrations");
|
|
33
|
-
const engine_api_tester_1 = require("@contember/engine-api-tester");
|
|
34
|
-
const rootToken = String(process.env.CONTEMBER_ROOT_TOKEN);
|
|
35
|
-
const loginToken = String(process.env.CONTEMBER_LOGIN_TOKEN);
|
|
36
|
-
const apiUrl = String(process.env.CONTEMBER_API_URL);
|
|
37
|
-
let projectSlug = '';
|
|
38
|
-
// Used to allow prettier formatting of GraphQL queries
|
|
39
|
-
const gql = (strings) => {
|
|
40
|
-
nodeAssert.strictEqual(strings.length, 1);
|
|
41
|
-
return strings[0];
|
|
42
|
-
};
|
|
43
|
-
const executeGraphql = (query, options = {}) => {
|
|
44
|
-
return (0, supertest_1.default)(apiUrl)
|
|
45
|
-
.post(options.path || `/content/${projectSlug}/live`)
|
|
46
|
-
.set('Authorization', 'Bearer ' + (options.authorizationToken || rootToken))
|
|
47
|
-
.send({
|
|
48
|
-
query,
|
|
49
|
-
variables: options.variables || {},
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
const signIn = async (email, password) => {
|
|
53
|
-
const response2 = await executeGraphql(gql `
|
|
54
|
-
mutation ($email: String!, $password: String!) {
|
|
55
|
-
signIn(email: $email, password: $password) {
|
|
56
|
-
ok
|
|
57
|
-
result {
|
|
58
|
-
token
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`, {
|
|
63
|
-
variables: { email, password },
|
|
64
|
-
authorizationToken: loginToken,
|
|
65
|
-
path: '/tenant',
|
|
66
|
-
});
|
|
67
|
-
return response2.body.data.signIn.result.token;
|
|
68
|
-
};
|
|
69
|
-
(0, vitest_1.beforeAll)(async () => {
|
|
70
|
-
projectSlug = 'test' + Date.now();
|
|
71
|
-
const result = await executeGraphql(`
|
|
72
|
-
mutation($projectSlug: String!, $config: Json!) {
|
|
73
|
-
createProject(projectSlug: $projectSlug, config: $config) {
|
|
74
|
-
ok
|
|
75
|
-
error { code }
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
`, {
|
|
79
|
-
path: '/tenant',
|
|
80
|
-
variables: {
|
|
81
|
-
projectSlug: projectSlug,
|
|
82
|
-
config: {},
|
|
83
|
-
},
|
|
84
|
-
})
|
|
85
|
-
.expect(response => {
|
|
86
|
-
vitest_1.assert.isOk(response.body);
|
|
87
|
-
vitest_1.assert.isOk(response.body.data);
|
|
88
|
-
vitest_1.assert.isOk(response.body.data.createProject);
|
|
89
|
-
if (!response.body.data.createProject.ok) {
|
|
90
|
-
vitest_1.assert.equal(response.body.data.createProject.error.code, 'ALREADY_EXISTS');
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
.expect(200);
|
|
94
|
-
if (!result.body.data.createProject.ok) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const migrationFilesManager = new schema_migrations_1.MigrationsResolver(schema_migrations_1.MigrationFilesManager.createForProject((0, engine_api_tester_1.getExampleProjectDirectory)(), 'sample'));
|
|
98
|
-
const migrations = await migrationFilesManager.getMigrations();
|
|
99
|
-
vitest_1.assert.isAtLeast(migrations.length, 2);
|
|
100
|
-
await executeGraphql(`
|
|
101
|
-
mutation($migrations: [Migration!]!) {
|
|
102
|
-
migrate(migrations: $migrations) {
|
|
103
|
-
ok
|
|
104
|
-
error { code }
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
`, {
|
|
108
|
-
path: '/system/' + projectSlug,
|
|
109
|
-
variables: {
|
|
110
|
-
migrations,
|
|
111
|
-
},
|
|
112
|
-
})
|
|
113
|
-
.expect(response => {
|
|
114
|
-
vitest_1.assert.deepStrictEqual(response.body.data, {
|
|
115
|
-
migrate: {
|
|
116
|
-
error: null,
|
|
117
|
-
ok: true,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
(0, vitest_1.test)('show homepage', async () => {
|
|
123
|
-
await (0, supertest_1.default)(apiUrl)
|
|
124
|
-
.get('/')
|
|
125
|
-
.expect(200)
|
|
126
|
-
.expect('App is running');
|
|
127
|
-
});
|
|
128
|
-
(0, vitest_1.test)('Content API: create & read tag', async () => {
|
|
129
|
-
await executeGraphql(gql `
|
|
130
|
-
mutation {
|
|
131
|
-
createTag(data: { label: "graphql" }) {
|
|
132
|
-
ok
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
`)
|
|
136
|
-
.expect(response => {
|
|
137
|
-
vitest_1.assert.deepStrictEqual(response.body.data, {
|
|
138
|
-
createTag: {
|
|
139
|
-
ok: true,
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
})
|
|
143
|
-
.expect(200);
|
|
144
|
-
await executeGraphql(gql `
|
|
145
|
-
query {
|
|
146
|
-
listTag(filter: { label: { eq: "graphql" } }) {
|
|
147
|
-
label
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
`)
|
|
151
|
-
.expect(response => {
|
|
152
|
-
vitest_1.assert.deepStrictEqual(response.body.data, {
|
|
153
|
-
listTag: [
|
|
154
|
-
{
|
|
155
|
-
label: 'graphql',
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
});
|
|
159
|
-
})
|
|
160
|
-
.expect(200);
|
|
161
|
-
});
|
|
162
|
-
(0, vitest_1.test)('Content API: X-Contember-Ref header', async () => {
|
|
163
|
-
await executeGraphql(gql `
|
|
164
|
-
mutation {
|
|
165
|
-
createTag(data: { label: "typescript" }) {
|
|
166
|
-
ok
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
`).expect(200);
|
|
170
|
-
const response = await executeGraphql(gql `
|
|
171
|
-
query {
|
|
172
|
-
listTag(filter: { label: { eq: "typescript" } }) {
|
|
173
|
-
label
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
`)
|
|
177
|
-
.set('X-Contember-Ref', 'None')
|
|
178
|
-
.expect(response => {
|
|
179
|
-
vitest_1.assert.deepStrictEqual(response.body.data, {
|
|
180
|
-
listTag: [
|
|
181
|
-
{
|
|
182
|
-
label: 'typescript',
|
|
183
|
-
},
|
|
184
|
-
],
|
|
185
|
-
});
|
|
186
|
-
})
|
|
187
|
-
.expect(200);
|
|
188
|
-
const eventKey = response.get('X-Contember-Ref');
|
|
189
|
-
await executeGraphql(gql `
|
|
190
|
-
query {
|
|
191
|
-
listTag {
|
|
192
|
-
label
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
`)
|
|
196
|
-
.set('X-Contember-Ref', eventKey)
|
|
197
|
-
.expect(304);
|
|
198
|
-
// ignored for mutation
|
|
199
|
-
await executeGraphql(gql `
|
|
200
|
-
mutation {
|
|
201
|
-
createTag(data: { label: "typescript" }) {
|
|
202
|
-
ok
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
`)
|
|
206
|
-
.set('X-Contember-Ref', eventKey)
|
|
207
|
-
.expect(200);
|
|
208
|
-
});
|
|
209
|
-
(0, vitest_1.test)('Content API: invalid schema error', async () => {
|
|
210
|
-
await executeGraphql(gql `
|
|
211
|
-
mutation {
|
|
212
|
-
createFoo(data: { label: "graphql" }) {
|
|
213
|
-
ok
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
`)
|
|
217
|
-
.expect(400)
|
|
218
|
-
.expect(response => {
|
|
219
|
-
vitest_1.assert.deepStrictEqual(response.body.errors[0].message, 'Cannot query field "createFoo" on type "Mutation". Did you mean "createPost" or "createTag"?');
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
(0, vitest_1.test)('Tenant API: sign up, add to a project and check project access', async () => {
|
|
223
|
-
const email = `john+${Date.now()}@doe.com`;
|
|
224
|
-
const signUpResponse = await executeGraphql(gql `
|
|
225
|
-
mutation($email: String!) {
|
|
226
|
-
signUp(email: $email, password: "123456") {
|
|
227
|
-
ok
|
|
228
|
-
result {
|
|
229
|
-
person {
|
|
230
|
-
identity {
|
|
231
|
-
id
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
`, {
|
|
238
|
-
path: '/tenant',
|
|
239
|
-
variables: { email },
|
|
240
|
-
}).expect(200);
|
|
241
|
-
const identityId = signUpResponse.body.data.signUp.result.person.identity.id;
|
|
242
|
-
const authKey = await signIn(email, '123456');
|
|
243
|
-
await executeGraphql(gql `
|
|
244
|
-
query {
|
|
245
|
-
listTag {
|
|
246
|
-
id
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
`, { authorizationToken: authKey })
|
|
250
|
-
.expect(404)
|
|
251
|
-
.expect({ errors: [{ message: `Project ${projectSlug} NOT found`, code: 404 }] });
|
|
252
|
-
await executeGraphql(gql `
|
|
253
|
-
mutation ($identity: String!, $projectSlug: String!) {
|
|
254
|
-
addProjectMember(identityId: $identity, projectSlug: $projectSlug, memberships: [{ role: "admin", variables: [] }]) {
|
|
255
|
-
ok
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
`, { path: '/tenant', variables: { identity: identityId, projectSlug } })
|
|
259
|
-
.expect(200)
|
|
260
|
-
.expect(response => {
|
|
261
|
-
vitest_1.assert.deepStrictEqual(response.body.data, { addProjectMember: { ok: true } });
|
|
262
|
-
});
|
|
263
|
-
await executeGraphql(gql `
|
|
264
|
-
query {
|
|
265
|
-
listAuthor {
|
|
266
|
-
id
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
`, { authorizationToken: authKey })
|
|
270
|
-
.expect(response => {
|
|
271
|
-
vitest_1.assert.deepStrictEqual(response.body.data, { listAuthor: [] });
|
|
272
|
-
})
|
|
273
|
-
.expect(200);
|
|
274
|
-
});
|
|
275
|
-
//# sourceMappingURL=http.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.test.js","sourceRoot":"","sources":["../../../tests/e2e/http.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAiC;AACjC,mDAAoC;AACpC,mCAAgD;AAChD,oEAAwF;AACxF,oEAAyE;AAGzE,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAC1D,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;AAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;AACpD,IAAI,WAAW,GAAG,EAAE,CAAA;AAEpB,uDAAuD;AACvD,MAAM,GAAG,GAAG,CAAC,OAA6B,EAAE,EAAE;IAC7C,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACzC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;AAClB,CAAC,CAAA;AAGD,MAAM,cAAc,GAAG,CACtB,KAAa,EACb,UAA2F,EAAE,EAC5F,EAAE;IACH,OAAO,IAAA,mBAAS,EAAC,MAAM,CAAC;SACtB,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,YAAY,WAAW,OAAO,CAAC;SACpD,GAAG,CAAC,eAAe,EAAE,SAAS,GAAG,CAAC,OAAO,CAAC,kBAAkB,IAAI,SAAS,CAAC,CAAC;SAC3E,IAAI,CAAC;QACL,KAAK;QACL,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;KAClC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAA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,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;IAC/E,CAAC,CAAC,CAAA;IAEH,MAAM,cAAc,CACnB,GAAG,CAAA;;;;;;GAMF,EACD,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAC/B;SACC,MAAM,CAAC,QAAQ,CAAC,EAAE;QAClB,eAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAA;IAC/D,CAAC,CAAC;SACD,MAAM,CAAC,GAAG,CAAC,CAAA;AACd,CAAC,CAAC,CAAA"}
|
package/jasmine.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { KoaMiddleware, ModuleInfoMiddlewareState, ProjectInfoMiddlewareState } from '@contember/engine-http'
|
|
2
|
-
import prom from 'prom-client'
|
|
3
|
-
import { GraphQLKoaState } from '@contember/engine-http'
|
|
4
|
-
|
|
5
|
-
export const createColllectHttpMetricsMiddleware = (
|
|
6
|
-
registry: prom.Registry,
|
|
7
|
-
): KoaMiddleware<Partial<ProjectInfoMiddlewareState & ModuleInfoMiddlewareState & GraphQLKoaState>> => {
|
|
8
|
-
const requestSummary = new prom.Histogram({
|
|
9
|
-
name: 'contember_http_duration_seconds',
|
|
10
|
-
help: 'Incoming HTTP requests statistics by http_method (OPTIONS requests are ignored), http_code, contember_project (or "unknown" for undefined project), contember_project_group (or "unknown" for undefined project group), contember_module (system, tenant, content, unknown) and graphql_operation (query, mutation, unknown)',
|
|
11
|
-
registers: [registry],
|
|
12
|
-
labelNames: ['http_method', 'http_code', 'contember_project', 'contember_project_group', 'contember_module', 'graphql_operation'],
|
|
13
|
-
buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
return async (ctx, next) => {
|
|
17
|
-
const end = ctx.method === 'OPTIONS' ? () => null : requestSummary.startTimer()
|
|
18
|
-
try {
|
|
19
|
-
await next()
|
|
20
|
-
} finally {
|
|
21
|
-
const labels = {
|
|
22
|
-
http_method: ctx.method,
|
|
23
|
-
http_code: ctx.status,
|
|
24
|
-
contember_project: ctx.state.project || 'unknown',
|
|
25
|
-
contember_project_group: ctx.state.projectGroup || 'unknown',
|
|
26
|
-
contember_module: ctx.state.module || 'unknown',
|
|
27
|
-
graphql_operation: ctx.state.graphql?.operationName || 'unknown',
|
|
28
|
-
}
|
|
29
|
-
end(labels)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { KoaMiddleware, route } from '@contember/engine-http'
|
|
2
|
-
import prom from 'prom-client'
|
|
3
|
-
|
|
4
|
-
export const createShowMetricsMiddleware = (registry: prom.Registry): KoaMiddleware<any> => {
|
|
5
|
-
return route('/metrics', async ctx => {
|
|
6
|
-
if (registry instanceof prom.AggregatorRegistry) {
|
|
7
|
-
ctx.body = await registry.clusterMetrics()
|
|
8
|
-
} else {
|
|
9
|
-
ctx.body = registry.metrics()
|
|
10
|
-
}
|
|
11
|
-
})
|
|
12
|
-
}
|
package/src/http/index.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { TenantConfigResolver } from '../config/tenantConfigResolver'
|
|
2
|
-
import {
|
|
3
|
-
ProjectGroupContainer,
|
|
4
|
-
ProjectGroupContainerResolver as ProjectGroupContainerResolverInterface,
|
|
5
|
-
} from '@contember/engine-http'
|
|
6
|
-
import { ProjectGroupContainerFactory } from './ProjectGroupContainer'
|
|
7
|
-
import { PromiseMap } from '@contember/engine-common'
|
|
8
|
-
import { isDeepStrictEqual } from 'util'
|
|
9
|
-
|
|
10
|
-
interface ContainerWithMeta {
|
|
11
|
-
container: ProjectGroupContainer
|
|
12
|
-
cleanups: (() => void)[]
|
|
13
|
-
inputConfig: any
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class ProjectGroupContainerResolver implements ProjectGroupContainerResolverInterface {
|
|
17
|
-
private containers = new PromiseMap<string | undefined, ContainerWithMeta>()
|
|
18
|
-
|
|
19
|
-
public readonly onCreate: ((container: ProjectGroupContainer, slug: string | undefined) => void | (() => void))[] = []
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
private readonly configResolver: TenantConfigResolver,
|
|
23
|
-
private readonly containerFactory: ProjectGroupContainerFactory,
|
|
24
|
-
) {}
|
|
25
|
-
|
|
26
|
-
public async getProjectGroupContainer(slug: string | undefined, config: any = {}): Promise<ProjectGroupContainer> {
|
|
27
|
-
const existing = this.containers.get(slug)
|
|
28
|
-
if (existing) {
|
|
29
|
-
const existingAwaited = await existing
|
|
30
|
-
if (isDeepStrictEqual(config, existingAwaited.inputConfig)) {
|
|
31
|
-
return existingAwaited.container
|
|
32
|
-
}
|
|
33
|
-
existingAwaited.cleanups.forEach(it => it())
|
|
34
|
-
this.containers.delete(slug)
|
|
35
|
-
}
|
|
36
|
-
return (await this.containers.fetch(slug, async slug => {
|
|
37
|
-
const container = this.containerFactory.create({
|
|
38
|
-
config: this.configResolver(slug, config),
|
|
39
|
-
slug,
|
|
40
|
-
})
|
|
41
|
-
const cleanups = this.onCreate.map(it => it(container, slug) || (() => null))
|
|
42
|
-
// eslint-disable-next-line no-console
|
|
43
|
-
await container.tenantContainer.migrationsRunner.run(console.log)
|
|
44
|
-
return { container, inputConfig: config, cleanups }
|
|
45
|
-
})).container
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/utils/cluster.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import cluster from 'cluster'
|
|
2
|
-
import { timeout } from './timeout'
|
|
3
|
-
|
|
4
|
-
export const getClusterProcessType = (isClusterMode: boolean) =>
|
|
5
|
-
!isClusterMode ? ProcessType.singleNode : cluster.isMaster ? ProcessType.clusterMaster : ProcessType.clusterWorker
|
|
6
|
-
|
|
7
|
-
export enum ProcessType {
|
|
8
|
-
singleNode,
|
|
9
|
-
clusterMaster,
|
|
10
|
-
clusterWorker,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const MSG_WORKER_STARTED = 'msg_worker_started'
|
|
14
|
-
|
|
15
|
-
export const waitForWorker = (timeoutMs: number) => {
|
|
16
|
-
let ok = false
|
|
17
|
-
return Promise.race([
|
|
18
|
-
new Promise(async resolve => {
|
|
19
|
-
const listener = ({}, message: any) => {
|
|
20
|
-
if ('type' in message && message.type === MSG_WORKER_STARTED) {
|
|
21
|
-
ok = true
|
|
22
|
-
resolve(null)
|
|
23
|
-
cluster.removeListener('message', listener)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
await cluster.on('message', listener)
|
|
27
|
-
}),
|
|
28
|
-
timeout(timeoutMs).then(() => {
|
|
29
|
-
if (!ok) {
|
|
30
|
-
throw new Error('Worker start timed out')
|
|
31
|
-
}
|
|
32
|
-
return true
|
|
33
|
-
}),
|
|
34
|
-
])
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const notifyWorkerStarted = () =>
|
|
38
|
-
process.send?.({
|
|
39
|
-
type: MSG_WORKER_STARTED,
|
|
40
|
-
})
|