@things-factory/integration-base 10.0.0-beta.1 → 10.0.0-beta.108
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-server/controllers/scenario-controller.js +8 -6
- package/dist-server/controllers/scenario-controller.js.map +1 -1
- package/dist-server/engine/connection-manager.d.ts +19 -0
- package/dist-server/engine/connection-manager.js +148 -16
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/connector/headless-connector.d.ts +12 -0
- package/dist-server/engine/connector/headless-connector.js +74 -31
- package/dist-server/engine/connector/headless-connector.js.map +1 -1
- package/dist-server/engine/connector/operato-connector.js +17 -6
- package/dist-server/engine/connector/operato-connector.js.map +1 -1
- package/dist-server/engine/connector/socket-server.js +12 -2
- package/dist-server/engine/connector/socket-server.js.map +1 -1
- package/dist-server/engine/evaluate-template.d.ts +22 -3
- package/dist-server/engine/evaluate-template.js +43 -4
- package/dist-server/engine/evaluate-template.js.map +1 -1
- package/dist-server/engine/task/script.js +25 -17
- package/dist-server/engine/task/script.js.map +1 -1
- package/dist-server/engine/task/socket-listener.js +29 -9
- package/dist-server/engine/task/socket-listener.js.map +1 -1
- package/dist-server/engine/task/utils/headless-request-with-recovery.js +29 -26
- package/dist-server/engine/task/utils/headless-request-with-recovery.js.map +1 -1
- package/dist-server/engine/types.d.ts +32 -0
- package/dist-server/engine/types.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.d.ts +3 -0
- package/dist-server/service/connection/connection-mutation.js +25 -26
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.js +11 -3
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +13 -6
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.d.ts +4 -1
- package/dist-server/service/connection/connection-type.js +21 -0
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/connection/connection.d.ts +80 -2
- package/dist-server/service/connection/connection.js +59 -15
- package/dist-server/service/connection/connection.js.map +1 -1
- package/dist-server/service/domain-attribute/domain-attribute-query.d.ts +17 -0
- package/dist-server/service/domain-attribute/domain-attribute-query.js +76 -0
- package/dist-server/service/domain-attribute/domain-attribute-query.js.map +1 -0
- package/dist-server/service/domain-attribute/domain-attribute-type.d.ts +15 -0
- package/dist-server/service/domain-attribute/domain-attribute-type.js +46 -0
- package/dist-server/service/domain-attribute/domain-attribute-type.js.map +1 -0
- package/dist-server/service/domain-attribute/index.d.ts +3 -0
- package/dist-server/service/domain-attribute/index.js +8 -0
- package/dist-server/service/domain-attribute/index.js.map +1 -0
- package/dist-server/service/index.d.ts +1 -1
- package/dist-server/service/index.js +3 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/scenario/scenario-mutation.js +10 -0
- package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
- package/dist-server/service/scenario/scenario-query.d.ts +3 -3
- package/dist-server/service/scenario/scenario-query.js +18 -11
- package/dist-server/service/scenario/scenario-query.js.map +1 -1
- package/dist-server/service/scenario-instance/index.d.ts +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js +4 -4
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-type.js +79 -0
- package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
- package/dist-server/service/scenario-queue/scenario-queue-subscription.js +2 -2
- package/dist-server/service/scenario-queue/scenario-queue-subscription.js.map +1 -1
- package/dist-server/service/state-register/data-resolver.js +2 -2
- package/dist-server/service/state-register/data-resolver.js.map +1 -1
- package/dist-server/service/step/step-mutation.js +15 -0
- package/dist-server/service/step/step-mutation.js.map +1 -1
- package/dist-server/service/step/step-query.js +11 -2
- package/dist-server/service/step/step-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/domain-inheritance.d.ts +29 -0
- package/dist-server/utils/domain-inheritance.js +98 -0
- package/dist-server/utils/domain-inheritance.js.map +1 -0
- package/package.json +10 -10
|
@@ -9,6 +9,38 @@ export interface Connector {
|
|
|
9
9
|
taskPrefixes?: string[];
|
|
10
10
|
description?: string;
|
|
11
11
|
help?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 외부 세션 (로그인 상태) 을 보유한 connector 인지 여부.
|
|
14
|
+
* true 이면 ConnectionManager.withSession 이 connection name 단위 mutex 로
|
|
15
|
+
* 동시 acquireSessionPage 호출을 직렬화 — 같은 외부 계정의 중복 로그인 충돌 방지.
|
|
16
|
+
*
|
|
17
|
+
* 기본값 false (stateless 또는 자체 세션 관리). HeadlessConnector 등 로그인 세션
|
|
18
|
+
* 기반 connector 가 true 로 선언.
|
|
19
|
+
*/
|
|
20
|
+
sessionExclusive?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 이 connector 의 자연스러운 inheritance default — 자식 도메인이 부모의 Connection
|
|
23
|
+
* 정의를 inherit 할 때 어떻게 동작하는 게 자연인지를 connector 작성자가 선언.
|
|
24
|
+
*
|
|
25
|
+
* 값은 string literal 'isolate' | 'share' — runtime 호환을 위해 string 으로
|
|
26
|
+
* 비교 (Connection.inheritanceMode column 의 값과 직접 비교 가능하도록).
|
|
27
|
+
*
|
|
28
|
+
* **결정 가이드** (connector 작성자용):
|
|
29
|
+
* 1. 외부 자원이 도메인(테넌트)별로 다른 identity·자격증명·세션이 필요한가?
|
|
30
|
+
* - 예 (stateful + per-tenant: 로그인 connector, 테넌트별 DB pool) → 'isolate'
|
|
31
|
+
* - 아니오 (공용 자원: 단일 브로커·서버 / stateless API) → 'share'
|
|
32
|
+
*
|
|
33
|
+
* 2. 자식 도메인이 부모의 cookies·세션·params 를 그대로 봐도 되는가?
|
|
34
|
+
* - 안 됨 (자료 격리·자격증명 격리 필요) → 'isolate'
|
|
35
|
+
* - 됨 (모두 같은 자원 공유) → 'share'
|
|
36
|
+
*
|
|
37
|
+
* 3. 명시 안 하면 framework 가 ISOLATE 폴백 (격리 우선). 자원 효율이 중요한
|
|
38
|
+
* connector 작성자는 'share' 를 명시 선언.
|
|
39
|
+
*
|
|
40
|
+
* Connection.inheritanceMode 가 명시되면 그것이 우선. 운영자가 특수 케이스를
|
|
41
|
+
* 위해 connector default 를 override 할 수 있음.
|
|
42
|
+
*/
|
|
43
|
+
inheritanceMode?: 'isolate' | 'share';
|
|
12
44
|
}
|
|
13
45
|
export type Context = {
|
|
14
46
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../server/engine/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Connection, PropertySpec, ScenarioInstance, ScenarioInstanceStatus, Step } from '../service'\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nexport interface Connector {\n ready(connections: Connection[]): Promise<any>\n connect(connection: Connection): Promise<any>\n disconnect(connection: Connection): Promise<any>\n parameterSpec: PropertySpec[]\n taskPrefixes?: string[]\n description?: string\n help?: string\n}\n\nexport type Context = {\n /**\n * Represents the domain context.\n */\n domain: Domain\n\n /**\n * User information.\n */\n user: User\n\n /**\n * Language code, for example 'en', 'ko'.\n */\n lng: string\n\n /**\n * Flag to indicate if the IP is unsafe, can be undefined.\n */\n unsafeIP: boolean | undefined\n\n /**\n * List of prohibited privileges, can be undefined.\n */\n prohibitedPrivileges: { category: string; privilege: string }[] | undefined\n\n /**\n * Logger for logging purposes.\n */\n logger: any\n\n /**\n * Function to publish events or messages.\n */\n publish: Function\n\n /**\n * Function to load resources or data.\n */\n load: Function\n\n /**\n * Current status of the scenario instance.\n */\n state: ScenarioInstanceStatus\n\n /**\n * General data storage object.\n */\n data: any\n\n /**\n * Variables related to the context.\n */\n variables: Object\n\n /**\n * Local GraphQL client object.\n */\n client: any /* graphql local client */\n\n /**\n * Root object, can be used for various purposes.\n */\n root?: ScenarioInstance\n\n /**\n * Array of function closures.\n */\n closures: Function[]\n\n /**\n * Function to check the state.\n */\n checkState: Function\n\n /**\n * MQTT subscriber context object.\n */\n __mqtt_subscriber?: any\n\n /**\n * socket listener context object.\n */\n __socket_listener?: any\n\n /**\n * csv readline context object.\n */\n __csv_resources?: any\n}\n\nexport type TaskHandler = (\n step: Step,\n context: Context\n) => Promise<{\n next?: string\n state?: ScenarioInstanceStatus\n data?: any\n}>\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../server/engine/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Connection, PropertySpec, ScenarioInstance, ScenarioInstanceStatus, Step } from '../service'\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nexport interface Connector {\n ready(connections: Connection[]): Promise<any>\n connect(connection: Connection): Promise<any>\n disconnect(connection: Connection): Promise<any>\n parameterSpec: PropertySpec[]\n taskPrefixes?: string[]\n description?: string\n help?: string\n /**\n * 외부 세션 (로그인 상태) 을 보유한 connector 인지 여부.\n * true 이면 ConnectionManager.withSession 이 connection name 단위 mutex 로\n * 동시 acquireSessionPage 호출을 직렬화 — 같은 외부 계정의 중복 로그인 충돌 방지.\n *\n * 기본값 false (stateless 또는 자체 세션 관리). HeadlessConnector 등 로그인 세션\n * 기반 connector 가 true 로 선언.\n */\n sessionExclusive?: boolean\n\n /**\n * 이 connector 의 자연스러운 inheritance default — 자식 도메인이 부모의 Connection\n * 정의를 inherit 할 때 어떻게 동작하는 게 자연인지를 connector 작성자가 선언.\n *\n * 값은 string literal 'isolate' | 'share' — runtime 호환을 위해 string 으로\n * 비교 (Connection.inheritanceMode column 의 값과 직접 비교 가능하도록).\n *\n * **결정 가이드** (connector 작성자용):\n * 1. 외부 자원이 도메인(테넌트)별로 다른 identity·자격증명·세션이 필요한가?\n * - 예 (stateful + per-tenant: 로그인 connector, 테넌트별 DB pool) → 'isolate'\n * - 아니오 (공용 자원: 단일 브로커·서버 / stateless API) → 'share'\n *\n * 2. 자식 도메인이 부모의 cookies·세션·params 를 그대로 봐도 되는가?\n * - 안 됨 (자료 격리·자격증명 격리 필요) → 'isolate'\n * - 됨 (모두 같은 자원 공유) → 'share'\n *\n * 3. 명시 안 하면 framework 가 ISOLATE 폴백 (격리 우선). 자원 효율이 중요한\n * connector 작성자는 'share' 를 명시 선언.\n *\n * Connection.inheritanceMode 가 명시되면 그것이 우선. 운영자가 특수 케이스를\n * 위해 connector default 를 override 할 수 있음.\n */\n inheritanceMode?: 'isolate' | 'share'\n}\n\nexport type Context = {\n /**\n * Represents the domain context.\n */\n domain: Domain\n\n /**\n * User information.\n */\n user: User\n\n /**\n * Language code, for example 'en', 'ko'.\n */\n lng: string\n\n /**\n * Flag to indicate if the IP is unsafe, can be undefined.\n */\n unsafeIP: boolean | undefined\n\n /**\n * List of prohibited privileges, can be undefined.\n */\n prohibitedPrivileges: { category: string; privilege: string }[] | undefined\n\n /**\n * Logger for logging purposes.\n */\n logger: any\n\n /**\n * Function to publish events or messages.\n */\n publish: Function\n\n /**\n * Function to load resources or data.\n */\n load: Function\n\n /**\n * Current status of the scenario instance.\n */\n state: ScenarioInstanceStatus\n\n /**\n * General data storage object.\n */\n data: any\n\n /**\n * Variables related to the context.\n */\n variables: Object\n\n /**\n * Local GraphQL client object.\n */\n client: any /* graphql local client */\n\n /**\n * Root object, can be used for various purposes.\n */\n root?: ScenarioInstance\n\n /**\n * Array of function closures.\n */\n closures: Function[]\n\n /**\n * Function to check the state.\n */\n checkState: Function\n\n /**\n * MQTT subscriber context object.\n */\n __mqtt_subscriber?: any\n\n /**\n * socket listener context object.\n */\n __socket_listener?: any\n\n /**\n * csv readline context object.\n */\n __csv_resources?: any\n}\n\nexport type TaskHandler = (\n step: Step,\n context: Context\n) => Promise<{\n next?: string\n state?: ScenarioInstanceStatus\n data?: any\n}>\n"]}
|
|
@@ -20,6 +20,7 @@ export declare class ConnectionMutation {
|
|
|
20
20
|
endpoint: string;
|
|
21
21
|
active: boolean;
|
|
22
22
|
onDemand: boolean;
|
|
23
|
+
inheritanceMode?: import("./connection").ConnectionInheritanceMode;
|
|
23
24
|
params: {
|
|
24
25
|
[key: string]: any;
|
|
25
26
|
};
|
|
@@ -29,6 +30,8 @@ export declare class ConnectionMutation {
|
|
|
29
30
|
creatorId: string;
|
|
30
31
|
updater: import("@things-factory/auth-base").User;
|
|
31
32
|
updaterId: string;
|
|
33
|
+
__inheritedFrom?: string;
|
|
34
|
+
__sharedFrom?: string;
|
|
32
35
|
}>;
|
|
33
36
|
importConnections(connections: Connection[], context: ResolverContext): Promise<boolean>;
|
|
34
37
|
}
|
|
@@ -8,6 +8,7 @@ const shell_1 = require("@things-factory/shell");
|
|
|
8
8
|
const connection_manager_1 = require("../../engine/connection-manager");
|
|
9
9
|
const connection_1 = require("./connection");
|
|
10
10
|
const connection_type_1 = require("./connection-type");
|
|
11
|
+
const domain_inheritance_1 = require("../../utils/domain-inheritance");
|
|
11
12
|
let ConnectionMutation = class ConnectionMutation {
|
|
12
13
|
async createConnection(connection, context) {
|
|
13
14
|
const { domain, user, tx } = context.state;
|
|
@@ -78,20 +79,19 @@ let ConnectionMutation = class ConnectionMutation {
|
|
|
78
79
|
async connectConnection(name, context) {
|
|
79
80
|
const { domain } = context.state;
|
|
80
81
|
var repository = (0, shell_1.getRepository)(connection_1.Connection);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
// ancestor 도메인을 closest-first 로 순회하여 first hit 사용
|
|
83
|
+
const domainIds = await (0, domain_inheritance_1.getDomainIdsWithAncestors)(domain);
|
|
84
|
+
var connection = null;
|
|
85
|
+
for (const did of domainIds) {
|
|
86
|
+
connection = await repository.findOne({
|
|
87
|
+
where: { domain: { id: did }, name },
|
|
88
|
+
relations: ['domain', 'edge']
|
|
89
|
+
});
|
|
90
|
+
if (connection)
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
85
93
|
if (!connection) {
|
|
86
|
-
|
|
87
|
-
connection = await repository.findOne({
|
|
88
|
-
where: { domain: { id: domain.parentId }, name },
|
|
89
|
-
relations: ['domain', 'edge']
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
if (!connection) {
|
|
93
|
-
throw new Error(`Connection with name '${name}' not found`);
|
|
94
|
-
}
|
|
94
|
+
throw new Error(`Connection with name '${name}' not found`);
|
|
95
95
|
}
|
|
96
96
|
/* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */
|
|
97
97
|
if (connection.domain.id !== domain.id) {
|
|
@@ -113,20 +113,19 @@ let ConnectionMutation = class ConnectionMutation {
|
|
|
113
113
|
async disconnectConnection(name, context) {
|
|
114
114
|
const { domain } = context.state;
|
|
115
115
|
var repository = (0, shell_1.getRepository)(connection_1.Connection);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
// ancestor 도메인을 closest-first 로 순회하여 first hit 사용
|
|
117
|
+
const domainIds = await (0, domain_inheritance_1.getDomainIdsWithAncestors)(domain);
|
|
118
|
+
var connection = null;
|
|
119
|
+
for (const did of domainIds) {
|
|
120
|
+
connection = await repository.findOne({
|
|
121
|
+
where: { domain: { id: did }, name },
|
|
122
|
+
relations: ['domain', 'edge']
|
|
123
|
+
});
|
|
124
|
+
if (connection)
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
120
127
|
if (!connection) {
|
|
121
|
-
|
|
122
|
-
connection = await repository.findOne({
|
|
123
|
-
where: { domain: { id: domain.parentId }, name },
|
|
124
|
-
relations: ['domain', 'edge']
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
if (!connection) {
|
|
128
|
-
throw new Error(`Connection with name '${name}' not found`);
|
|
129
|
-
}
|
|
128
|
+
throw new Error(`Connection with name '${name}' not found`);
|
|
130
129
|
}
|
|
131
130
|
/* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */
|
|
132
131
|
/* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-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U,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,kBAAkB,CA8Q9B","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionStatus } from './connection'\nimport { ConnectionPatch, NewConnection } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionMutation {\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'Creates a new connection.' })\n async createConnection(\n @Arg('connection') connection: NewConnection,\n @Ctx() context: ResolverContext\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Connection).save({\n ...connection,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'Updates an existing connection.' })\n async updateConnection(\n @Arg('name') name: string,\n @Arg('patch') patch: ConnectionPatch,\n @Ctx() context: ResolverContext\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Connection)\n const connection = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => [Connection], { description: 'Updates multiple connections at once.' })\n async updateMultipleConnection(\n @Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Connection[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const connectionRepo = tx.getRepository(Connection)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await connectionRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const connection = await connectionRepo.findOneBy({ id: newRecord.id })\n\n const result = await connectionRepo.save({\n ...connection,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Boolean, { description: 'Deletes a single connection by its name.' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain: { id: domain.id }, name })\n return true\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Boolean, { description: 'Deletes multiple connections by their names.' })\n async deleteConnections(\n @Arg('names', type => [String]) names: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'Establishes a live connection to a configured endpoint.' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n if (!connection) {\n if (domain.parentId) {\n connection = await repository.findOne({\n where: { domain: { id: domain.parentId }, name },\n relations: ['domain', 'edge']\n })\n }\n\n if (!connection) {\n throw new Error(`Connection with name '${name}' not found`)\n }\n }\n\n /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */\n if (connection.domain.id !== domain.id) {\n connection.domain = domain\n await connection.connect()\n /* on-demand 연결인 경우에 connection을 저장하지 말아야 한다. */\n } else {\n await connection.connect()\n await repository.save(connection)\n }\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'Terminates a live connection.' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n if (!connection) {\n if (domain.parentId) {\n connection = await repository.findOne({\n where: { domain: { id: domain.parentId }, name },\n relations: ['domain', 'edge']\n })\n }\n\n if (!connection) {\n throw new Error(`Connection with name '${name}' not found`)\n }\n }\n\n /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */\n\n /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */\n if (connection.domain.id !== domain.id) {\n connection.domain = domain\n await connection.disconnect()\n\n /* on-demand 연결인 경우에 connection을 저장하지 말아야 한다. */\n } else {\n await connection.disconnect()\n await repository.save(connection)\n }\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n }\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Boolean, {\n description: 'Imports multiple connections. Can overwrite existing connections if IDs or names match.'\n })\n async importConnections(\n @Arg('connections', type => [ConnectionPatch]) connections: Connection[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Connection)\n\n await Promise.all(\n connections.map(async (connection: Connection) => {\n const { id, name } = connection\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Connection with id '${id}:${name}' is already taken by another domain`\n }\n\n const sameName = await repository.findOneBy({ domain: { id: domain.id }, name })\n if (sameName && sameName.id != id) {\n throw `Connection with name '${name}' is already taken by another connection`\n }\n\n await repository.save({\n ...sameId,\n ...connection,\n domain,\n updater: user\n })\n\n return\n }\n }\n\n await repository.save({\n ...connection,\n domain,\n updater: user,\n creator: user\n })\n })\n )\n\n return true\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,wEAAmE;AACnE,6CAA2D;AAC3D,uDAAkE;AAClE,uEAA0E;AAGnE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAMvB,AAAN,KAAK,CAAC,gBAAgB,CACD,UAAyB,EACrC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,uBAAU,CAAC,CAAC,IAAI,CAAC;YAC7C,GAAG,UAAU;YACb,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;IACJ,CAAC;IAOK,AAAN,KAAK,CAAC,gBAAgB,CACP,IAAY,EACX,KAAsB,EAC7B,OAAwB;QAE/B,MAAM,EAA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M,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAuC3D;AASK;IAPL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EACR,6GAA6G,CAC9G;IACA,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE;QAC5B,WAAW,EAAE,yFAAyF;KACvG,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,iCAAe,CAAC,CAAC,CAAA;IAC7C,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DA4CP;6BAzQU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,kBAAkB,CA0Q9B","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionStatus } from './connection'\nimport { ConnectionPatch, NewConnection } from './connection-type'\nimport { getDomainIdsWithAncestors } from '../../utils/domain-inheritance'\n\n@Resolver(Connection)\nexport class ConnectionMutation {\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'Creates a new connection.' })\n async createConnection(\n @Arg('connection') connection: NewConnection,\n @Ctx() context: ResolverContext\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Connection).save({\n ...connection,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'Updates an existing connection.' })\n async updateConnection(\n @Arg('name') name: string,\n @Arg('patch') patch: ConnectionPatch,\n @Ctx() context: ResolverContext\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Connection)\n const connection = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => [Connection], { description: 'Updates multiple connections at once.' })\n async updateMultipleConnection(\n @Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Connection[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const connectionRepo = tx.getRepository(Connection)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await connectionRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const connection = await connectionRepo.findOneBy({ id: newRecord.id })\n\n const result = await connectionRepo.save({\n ...connection,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Boolean, { description: 'Deletes a single connection by its name.' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain: { id: domain.id }, name })\n return true\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Boolean, { description: 'Deletes multiple connections by their names.' })\n async deleteConnections(\n @Arg('names', type => [String]) names: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'Establishes a live connection to a configured endpoint.' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n\n // ancestor 도메인을 closest-first 로 순회하여 first hit 사용\n const domainIds = await getDomainIdsWithAncestors(domain)\n var connection: Connection | null = null\n for (const did of domainIds) {\n connection = await repository.findOne({\n where: { domain: { id: did }, name },\n relations: ['domain', 'edge']\n })\n if (connection) break\n }\n\n if (!connection) {\n throw new Error(`Connection with name '${name}' not found`)\n }\n\n /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */\n if (connection.domain.id !== domain.id) {\n connection.domain = domain\n await connection.connect()\n /* on-demand 연결인 경우에 connection을 저장하지 말아야 한다. */\n } else {\n await connection.connect()\n await repository.save(connection)\n }\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'Terminates a live connection.' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n\n // ancestor 도메인을 closest-first 로 순회하여 first hit 사용\n const domainIds = await getDomainIdsWithAncestors(domain)\n var connection: Connection | null = null\n for (const did of domainIds) {\n connection = await repository.findOne({\n where: { domain: { id: did }, name },\n relations: ['domain', 'edge']\n })\n if (connection) break\n }\n\n if (!connection) {\n throw new Error(`Connection with name '${name}' not found`)\n }\n\n /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */\n\n /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */\n if (connection.domain.id !== domain.id) {\n connection.domain = domain\n await connection.disconnect()\n\n /* on-demand 연결인 경우에 connection을 저장하지 말아야 한다. */\n } else {\n await connection.disconnect()\n await repository.save(connection)\n }\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n }\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Boolean, {\n description: 'Imports multiple connections. Can overwrite existing connections if IDs or names match.'\n })\n async importConnections(\n @Arg('connections', type => [ConnectionPatch]) connections: Connection[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Connection)\n\n await Promise.all(\n connections.map(async (connection: Connection) => {\n const { id, name } = connection\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Connection with id '${id}:${name}' is already taken by another domain`\n }\n\n const sameName = await repository.findOneBy({ domain: { id: domain.id }, name })\n if (sameName && sameName.id != id) {\n throw `Connection with name '${name}' is already taken by another connection`\n }\n\n await repository.save({\n ...sameId,\n ...connection,\n domain,\n updater: user\n })\n\n return\n }\n }\n\n await repository.save({\n ...connection,\n domain,\n updater: user,\n creator: user\n })\n })\n )\n\n return true\n }\n}\n"]}
|
|
@@ -3,21 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ConnectionQuery = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
6
7
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
7
8
|
const shell_1 = require("@things-factory/shell");
|
|
8
9
|
const connection_manager_1 = require("../../engine/connection-manager");
|
|
9
10
|
const connection_1 = require("./connection");
|
|
10
11
|
const connection_type_1 = require("./connection-type");
|
|
12
|
+
const domain_inheritance_1 = require("../../utils/domain-inheritance");
|
|
11
13
|
/**
|
|
12
14
|
* @description Provides GraphQL resolvers for the Connection entity.
|
|
13
15
|
*/
|
|
14
16
|
let ConnectionQuery = class ConnectionQuery {
|
|
15
17
|
async connection(name, context) {
|
|
16
18
|
const { domain } = context.state;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const domainIds = await (0, domain_inheritance_1.getDomainIdsWithAncestors)(domain);
|
|
20
|
+
// 동일 name 이 여러 ancestor 도메인에 존재할 수 있음 → closest-first 우선 선택.
|
|
21
|
+
const connections = await (0, shell_1.getRepository)(connection_1.Connection).find({
|
|
22
|
+
where: { domain: { id: (0, typeorm_1.In)(domainIds) }, name },
|
|
19
23
|
relations: ['domain']
|
|
20
24
|
});
|
|
25
|
+
var connection = connections.sort((a, b) => domainIds.indexOf(a.domainId) - domainIds.indexOf(b.domainId))[0];
|
|
21
26
|
return {
|
|
22
27
|
...connection,
|
|
23
28
|
state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
|
|
@@ -27,13 +32,16 @@ let ConnectionQuery = class ConnectionQuery {
|
|
|
27
32
|
}
|
|
28
33
|
async connections(params, context) {
|
|
29
34
|
const { domain } = context.state;
|
|
35
|
+
const domainIds = await (0, domain_inheritance_1.getDomainIdsWithAncestors)(domain);
|
|
30
36
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
31
37
|
repository: (0, shell_1.getRepository)(connection_1.Connection),
|
|
32
38
|
params,
|
|
33
|
-
|
|
39
|
+
// 도메인 필터링은 ancestor 기반으로 직접 적용 (shell helper 는 single-parent 만 지원)
|
|
40
|
+
domain: undefined,
|
|
34
41
|
alias: 'connection',
|
|
35
42
|
searchables: ['name', 'description', 'type', 'endpoint']
|
|
36
43
|
});
|
|
44
|
+
queryBuilder.andWhere(`connection.domain IN (:...ancestorDomainIds)`, { ancestorDomainIds: domainIds });
|
|
37
45
|
const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount();
|
|
38
46
|
items.forEach(connection => {
|
|
39
47
|
connection['state'] = connection_manager_1.ConnectionManager.getConnectionInstance(connection)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;
|
|
1
|
+
{"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qCAA4B;AAE5B,yDAA2D;AAC3D,iDAAuG;AAEvG,wEAAmE;AACnE,6CAA2D;AAC3D,uDAAmE;AACnE,uEAA0E;AAE1E;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAKpB,AAAN,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAwB;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,SAAS,GAAG,MAAM,IAAA,8CAAyB,EAAC,MAAM,CAAC,CAAA;QAEzD,6DAA6D;QAC7D,MAAM,WAAW,GAAG,MAAM,IAAA,qBAAa,EAAC,uBAAU,CAAC,CAAC,IAAI,CAAC;YACvD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE;YAC9C,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;QAEF,IAAI,UAAU,GAAG,WAAW,CAAC,IAAI,CAC/B,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO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AAI,GAAE,CAAA;;6CAAa,uBAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,uBAAU;;8CAE3C;0BA7FU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,eAAe,CA8F3B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionStatus } from './connection'\nimport { ConnectionList, ConnectionState } from './connection-type'\nimport { getDomainIdsWithAncestors } from '../../utils/domain-inheritance'\n\n/**\n * @description Provides GraphQL resolvers for the Connection entity.\n */\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Connection, {\n description: 'Fetches a single connection by its name, including its current state.'\n })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n const domainIds = await getDomainIdsWithAncestors(domain)\n\n // 동일 name 이 여러 ancestor 도메인에 존재할 수 있음 → closest-first 우선 선택.\n const connections = await getRepository(Connection).find({\n where: { domain: { id: In(domainIds) }, name },\n relations: ['domain']\n })\n\n var connection = connections.sort(\n (a, b) => domainIds.indexOf(a.domainId) - domainIds.indexOf(b.domainId)\n )[0]\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionList, {\n description: 'Fetches a paginated list of connections, including their current states.'\n })\n async connections(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ConnectionList> {\n const { domain } = context.state\n const domainIds = await getDomainIdsWithAncestors(domain)\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Connection),\n params,\n // 도메인 필터링은 ancestor 기반으로 직접 적용 (shell helper 는 single-parent 만 지원)\n domain: undefined,\n alias: 'connection',\n searchables: ['name', 'description', 'type', 'endpoint']\n })\n\n queryBuilder.andWhere(`connection.domain IN (:...ancestorDomainIds)`, { ancestorDomainIds: domainIds })\n\n const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount()\n\n items.forEach(connection => {\n connection['state'] = ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionState, { description: 'Fetches the current state of a single connection by its name.' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)\n\n return {\n ...connection,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async edge(@Root() connection: Connection) {\n return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return (\n connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))\n )\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))\n }\n}\n"]}
|
|
@@ -4,10 +4,12 @@ exports.ConnectionSubscription = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const graphql_yoga_1 = require("graphql-yoga");
|
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const typeorm_1 = require("typeorm");
|
|
7
8
|
const shell_1 = require("@things-factory/shell");
|
|
8
9
|
const connection_manager_1 = require("../../engine/connection-manager");
|
|
9
10
|
const connection_1 = require("./connection");
|
|
10
11
|
const connection_type_1 = require("./connection-type");
|
|
12
|
+
const domain_inheritance_1 = require("../../utils/domain-inheritance");
|
|
11
13
|
const debug = require('debug')('things-factory:integration:connection-subscription');
|
|
12
14
|
let ConnectionSubscription = class ConnectionSubscription {
|
|
13
15
|
connectionState(payload, name) {
|
|
@@ -21,7 +23,7 @@ exports.ConnectionSubscription = ConnectionSubscription;
|
|
|
21
23
|
tslib_1.__decorate([
|
|
22
24
|
(0, type_graphql_1.Subscription)({
|
|
23
25
|
description: 'Subscribes to the state changes of connections.',
|
|
24
|
-
subscribe: ({ args, context, info }) => {
|
|
26
|
+
subscribe: async ({ args, context, info }) => {
|
|
25
27
|
const { domain, user } = context.state;
|
|
26
28
|
const { name } = args;
|
|
27
29
|
const subdomain = domain?.subdomain;
|
|
@@ -29,11 +31,15 @@ tslib_1.__decorate([
|
|
|
29
31
|
if (!domain) {
|
|
30
32
|
throw new Error('domain required.');
|
|
31
33
|
}
|
|
32
|
-
if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {
|
|
34
|
+
if (!user.domains?.find(d => d.subdomain === subdomain) && !(await process.superUserGranted(domain, user))) {
|
|
33
35
|
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
|
|
34
36
|
}
|
|
37
|
+
// ancestor 도메인 ids 를 한 번만 계산하여 재사용 (subscribe 는 sync 라 lazy memoize)
|
|
38
|
+
let ancestorIdsPromise = null;
|
|
39
|
+
const resolveAncestorIds = () => (ancestorIdsPromise ||= (0, domain_inheritance_1.getDomainIdsWithAncestors)(domain));
|
|
35
40
|
process.nextTick(async () => {
|
|
36
|
-
|
|
41
|
+
const domainIds = await resolveAncestorIds();
|
|
42
|
+
var where = { domain: { id: (0, typeorm_1.In)(domainIds) } };
|
|
37
43
|
if (name) {
|
|
38
44
|
where['name'] = name;
|
|
39
45
|
}
|
|
@@ -56,7 +62,8 @@ tslib_1.__decorate([
|
|
|
56
62
|
});
|
|
57
63
|
return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('connection-state'), (0, graphql_yoga_1.filter)(async (payload) => {
|
|
58
64
|
const { domain: pdomain, name: pname } = payload.connectionState;
|
|
59
|
-
|
|
65
|
+
const domainIds = await resolveAncestorIds();
|
|
66
|
+
return (!name || name === pname) && domainIds.includes(pdomain?.id);
|
|
60
67
|
}));
|
|
61
68
|
}
|
|
62
69
|
}),
|
|
@@ -69,7 +76,7 @@ tslib_1.__decorate([
|
|
|
69
76
|
tslib_1.__decorate([
|
|
70
77
|
(0, type_graphql_1.Subscription)({
|
|
71
78
|
description: 'Subscribes to log messages from connections.',
|
|
72
|
-
subscribe: ({ args, context, info }) => {
|
|
79
|
+
subscribe: async ({ args, context, info }) => {
|
|
73
80
|
const { domain, user } = context.state;
|
|
74
81
|
const { level } = args;
|
|
75
82
|
const subdomain = domain?.subdomain;
|
|
@@ -77,7 +84,7 @@ tslib_1.__decorate([
|
|
|
77
84
|
if (!domain) {
|
|
78
85
|
throw new Error('domain required');
|
|
79
86
|
}
|
|
80
|
-
if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {
|
|
87
|
+
if (!user.domains?.find(d => d.subdomain === subdomain) && !(await process.superUserGranted(domain, user))) {
|
|
81
88
|
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
|
|
82
89
|
}
|
|
83
90
|
return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('connection-log'), (0, graphql_yoga_1.filter)(async (payload) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAAgE;
|
|
1
|
+
{"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAAgE;AAChE,qCAA4B;AAE5B,iDAAkE;AAElE,wEAAmE;AACnE,6CAA2D;AAC3D,uDAAmD;AACnD,uEAA0E;AAE1E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAG7E,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IA2DjC,eAAe,CACL,OAA6C,EACpB,IAAY;QAE7C,OAAO,OAAO,CAAC,eAAe,CAAA;IAChC,CAAC;IAwCD,aAAa,CAAS,OAAqB,EAAoC,KAAa;QAC1F,OAAO,OAAO,CAAC,GAAG,CAAA;IACpB,CAAC;CACF,CAAA;AA3GY,wDAAsB;AA2DjC;IA1DC,IAAA,2BAAY,EAAC;QACZ,WAAW,EAAE,iDAAiD;QAC9D,SAAS,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YAC3C,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YACtC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;YACrB,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAA;YAEnC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;YACrC,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAA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AAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;gBAC3G,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;YACjF,CAAC;YAED,OAAO,IAAA,mBAAI,EACT,cAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAClC,IAAA,qBAAM,EAAC,KAAK,EAAE,OAAqB,EAAE,EAAE;gBACrC,gCAAgC;gBAChC,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAA;gBACnD,qCAAqC;gBAErC,0CAA0C;gBAC1C,iBAAiB;gBACjB,IAAI;gBAEJ,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;oBAC9B,OAAO,KAAK,CAAA;gBACd,CAAC;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CACH,CAAA;QACH,CAAC;KACF,CAAC;IACa,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAyB,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;4CAAiB,WAAG;2DAEjG;iCA1GU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,sBAAsB,CA2GlC","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\nimport { Arg, Resolver, Root, Subscription } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository, Log, pubsub } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionStatus } from './connection'\nimport { ConnectionState } from './connection-type'\nimport { getDomainIdsWithAncestors } from '../../utils/domain-inheritance'\n\nconst debug = require('debug')('things-factory:integration:connection-subscription')\n\n@Resolver(Connection)\nexport class ConnectionSubscription {\n @Subscription({\n description: 'Subscribes to the state changes of connections.',\n subscribe: async ({ args, context, info }) => {\n const { domain, user } = context.state\n const { name } = args\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n if (!domain) {\n throw new Error('domain required.')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !(await process.superUserGranted(domain, user))) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n // ancestor 도메인 ids 를 한 번만 계산하여 재사용 (subscribe 는 sync 라 lazy memoize)\n let ancestorIdsPromise: Promise<string[]> | null = null\n const resolveAncestorIds = () =>\n (ancestorIdsPromise ||= getDomainIdsWithAncestors(domain))\n\n process.nextTick(async () => {\n const domainIds = await resolveAncestorIds()\n var where: any = { domain: { id: In(domainIds) } }\n if (name) {\n where['name'] = name\n }\n\n var connections = await getRepository(Connection).find({\n where,\n relations: ['domain', 'edge']\n })\n\n connections.forEach(connection => {\n pubsub.publish('connection-state', {\n connectionState: {\n ...connection,\n domain /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED,\n timestamp: new Date()\n }\n })\n })\n })\n\n return pipe(\n pubsub.subscribe('connection-state'),\n filter(async (payload: { connectionState: ConnectionState }) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n const domainIds = await resolveAncestorIds()\n\n return (!name || name === pname) && domainIds.includes(pdomain?.id)\n })\n )\n }\n })\n connectionState(\n @Root() payload: { connectionState: ConnectionState },\n @Arg('name', { nullable: true }) name: string\n ): ConnectionState {\n return payload.connectionState\n }\n\n @Subscription({\n description: 'Subscribes to log messages from connections.',\n subscribe: async ({ args, context, info }) => {\n const { domain, user } = context.state\n const { level } = args\n\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !(await process.superUserGranted(domain, user))) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return pipe(\n pubsub.subscribe('connection-log'),\n filter(async (payload: { log: Log }) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.log\n // const { domain: pdomain } = source\n\n // if (subdomain !== pdomain?.subdomain) {\n // return false\n // }\n\n if (level && level !== plevel) {\n return false\n }\n\n return true\n })\n )\n }\n })\n connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {\n return payload.log\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Appliance } from '@things-factory/auth-base';
|
|
2
2
|
import { Domain } from '@things-factory/shell';
|
|
3
3
|
import { Connection } from './connection';
|
|
4
|
-
import { ConnectionStatus } from './connection';
|
|
4
|
+
import { ConnectionInheritanceMode, ConnectionStatus } from './connection';
|
|
5
5
|
/**
|
|
6
6
|
* Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로
|
|
7
7
|
* 추후, 타입 일치를 통해서 제거할 예정임.
|
|
@@ -19,6 +19,7 @@ export declare class ConnectionState {
|
|
|
19
19
|
description?: string;
|
|
20
20
|
type?: string;
|
|
21
21
|
onDemand?: boolean;
|
|
22
|
+
inheritanceMode?: ConnectionInheritanceMode;
|
|
22
23
|
edge?: Appliance;
|
|
23
24
|
state?: ConnectionStatus;
|
|
24
25
|
timestamp?: Date;
|
|
@@ -28,6 +29,7 @@ export declare class NewConnection {
|
|
|
28
29
|
description?: string;
|
|
29
30
|
type?: string;
|
|
30
31
|
onDemand: boolean;
|
|
32
|
+
inheritanceMode?: ConnectionInheritanceMode;
|
|
31
33
|
edge?: Appliance;
|
|
32
34
|
endpoint?: string;
|
|
33
35
|
active?: boolean;
|
|
@@ -41,6 +43,7 @@ export declare class ConnectionPatch {
|
|
|
41
43
|
description?: string;
|
|
42
44
|
type?: string;
|
|
43
45
|
onDemand: boolean;
|
|
46
|
+
inheritanceMode?: ConnectionInheritanceMode;
|
|
44
47
|
edge?: Appliance;
|
|
45
48
|
endpoint?: string;
|
|
46
49
|
active?: boolean;
|
|
@@ -37,6 +37,13 @@ tslib_1.__decorate([
|
|
|
37
37
|
}),
|
|
38
38
|
tslib_1.__metadata("design:type", Boolean)
|
|
39
39
|
], ConnectionState.prototype, "onDemand", void 0);
|
|
40
|
+
tslib_1.__decorate([
|
|
41
|
+
(0, type_graphql_1.Field)(type => connection_2.ConnectionInheritanceMode, {
|
|
42
|
+
nullable: true,
|
|
43
|
+
description: 'Inheritance mode for child domains. ISOLATE = per-child instance. SHARE = shared parent instance. null = use connector default (falls back to ISOLATE).'
|
|
44
|
+
}),
|
|
45
|
+
tslib_1.__metadata("design:type", String)
|
|
46
|
+
], ConnectionState.prototype, "inheritanceMode", void 0);
|
|
40
47
|
tslib_1.__decorate([
|
|
41
48
|
(0, type_graphql_1.Field)(type => auth_base_1.Appliance, { nullable: true, description: 'The edge appliance associated with the connection.' }),
|
|
42
49
|
tslib_1.__metadata("design:type", auth_base_1.Appliance)
|
|
@@ -74,6 +81,13 @@ tslib_1.__decorate([
|
|
|
74
81
|
}),
|
|
75
82
|
tslib_1.__metadata("design:type", Boolean)
|
|
76
83
|
], NewConnection.prototype, "onDemand", void 0);
|
|
84
|
+
tslib_1.__decorate([
|
|
85
|
+
(0, type_graphql_1.Field)(type => connection_2.ConnectionInheritanceMode, {
|
|
86
|
+
nullable: true,
|
|
87
|
+
description: 'Inheritance mode for child domains. ISOLATE = per-child instance. SHARE = shared parent instance. null = use connector default.'
|
|
88
|
+
}),
|
|
89
|
+
tslib_1.__metadata("design:type", String)
|
|
90
|
+
], NewConnection.prototype, "inheritanceMode", void 0);
|
|
77
91
|
tslib_1.__decorate([
|
|
78
92
|
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'Reference to the edge appliance for the new connection.' }),
|
|
79
93
|
tslib_1.__metadata("design:type", auth_base_1.Appliance)
|
|
@@ -122,6 +136,13 @@ tslib_1.__decorate([
|
|
|
122
136
|
}),
|
|
123
137
|
tslib_1.__metadata("design:type", Boolean)
|
|
124
138
|
], ConnectionPatch.prototype, "onDemand", void 0);
|
|
139
|
+
tslib_1.__decorate([
|
|
140
|
+
(0, type_graphql_1.Field)(type => connection_2.ConnectionInheritanceMode, {
|
|
141
|
+
nullable: true,
|
|
142
|
+
description: 'Inheritance mode for child domains. ISOLATE = per-child instance. SHARE = shared parent instance. null = use connector default.'
|
|
143
|
+
}),
|
|
144
|
+
tslib_1.__metadata("design:type", String)
|
|
145
|
+
], ConnectionPatch.prototype, "inheritanceMode", void 0);
|
|
125
146
|
tslib_1.__decorate([
|
|
126
147
|
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'The new edge appliance for the connection.' }),
|
|
127
148
|
tslib_1.__metadata("design:type", auth_base_1.Appliance)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yDAAqD;AACrD,iDAAuE;AAEvE,6CAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yDAAqD;AACrD,iDAAuE;AAEvE,6CAAyC;AACzC,6CAA0E;AAYnE,IAAM,eAAe,GAArB,MAAM,eAAe;CAoC3B,CAAA;AApCY,0CAAe;AAE1B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;sCAC/D,cAAM;+CAAA;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;;2CACxE;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;;6CACzD;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QA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,WAAW,EAAE,+BAA+B,EAAE,CAAC;;6CAC3D;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;;6CAC3D;yBALF,cAAc;IAD1B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;GACnD,cAAc,CAM1B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Appliance } from '@things-factory/auth-base'\nimport { Domain, ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Connection } from './connection'\nimport { ConnectionInheritanceMode, ConnectionStatus } from './connection'\n\n/**\n * Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로\n * 추후, 타입 일치를 통해서 제거할 예정임.\n *\n */\nexport interface InputConnection extends Connection {\n params: { [key: string]: any }\n}\n\n@ObjectType({ description: 'Represents the state of a connection at a point in time.' })\nexport class ConnectionState {\n @Field(type => Domain, { description: 'The domain of the connection.' })\n domain?: Domain\n\n @Field({ nullable: true, description: 'The unique identifier of the connection.' })\n id?: string\n\n @Field({ nullable: true, description: 'The name of the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The description of the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the connection.' })\n type?: string\n\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand?: boolean\n\n @Field(type => ConnectionInheritanceMode, {\n nullable: true,\n description: 'Inheritance mode for child domains. ISOLATE = per-child instance. SHARE = shared parent instance. null = use connector default (falls back to ISOLATE).'\n })\n inheritanceMode?: ConnectionInheritanceMode\n\n @Field(type => Appliance, { nullable: true, description: 'The edge appliance associated with the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The current status of the connection.' })\n state?: ConnectionStatus\n\n @Field({ nullable: true, description: 'The timestamp when this state was recorded.' })\n timestamp?: Date\n}\n\n@InputType({ description: 'Input for creating a new connection.' })\nexport class NewConnection {\n @Field({ description: 'The name for the new connection.' })\n name: string\n\n @Field({ nullable: true, description: 'A detailed description for the new connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the new connection (e.g., tcp, http, mqtt).' })\n type?: string\n\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand: boolean\n\n @Field(type => ConnectionInheritanceMode, {\n nullable: true,\n description: 'Inheritance mode for child domains. ISOLATE = per-child instance. SHARE = shared parent instance. null = use connector default.'\n })\n inheritanceMode?: ConnectionInheritanceMode\n\n @Field(type => ObjectRef, { nullable: true, description: 'Reference to the edge appliance for the new connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The endpoint URL or address for the new connection.' })\n endpoint?: string\n\n @Field({\n nullable: true,\n description: 'Whether to automatically connect when the application starts'\n })\n active?: boolean\n\n @Field(type => ScalarObject, { nullable: true, description: 'A key-value map of parameters for the new connection.' })\n params?: { [key: string]: any }\n}\n\n@InputType({ description: 'Input for updating (patching) an existing connection.' })\nexport class ConnectionPatch {\n @Field(type => ID, { nullable: true, description: 'The unique identifier of the connection to update.' })\n id: string\n\n @Field({ nullable: true, description: 'The new name for the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The new description for the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The new type for the connection.' })\n type?: string\n\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand: boolean\n\n @Field(type => ConnectionInheritanceMode, {\n nullable: true,\n description: 'Inheritance mode for child domains. ISOLATE = per-child instance. SHARE = shared parent instance. null = use connector default.'\n })\n inheritanceMode?: ConnectionInheritanceMode\n\n @Field(type => ObjectRef, { nullable: true, description: 'The new edge appliance for the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The new endpoint for the connection.' })\n endpoint?: string\n\n @Field({\n nullable: true,\n description: 'Whether to automatically connect when the application starts'\n })\n active?: boolean\n\n @Field(type => ScalarObject, { nullable: true, description: 'The new parameters for the connection.' })\n params?: { [key: string]: any }\n\n @Field({\n nullable: true,\n description: 'A flag indicating whether the connection is being created, updated, or deleted.'\n })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A paginated list of connections.' })\nexport class ConnectionList {\n @Field(type => [Connection], { description: 'The list of connection items.' })\n items: Connection[]\n\n @Field(type => Int, { description: 'The total number of connections.' })\n total: number\n}\n"]}
|