@things-factory/integration-base 9.0.24 → 9.0.25
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/engine/connection-manager.d.ts +13 -1
- package/dist-server/engine/connection-manager.js +99 -3
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/task/database-query.js +1 -1
- package/dist-server/engine/task/database-query.js.map +1 -1
- package/dist-server/engine/task/echo-receive.js +1 -1
- package/dist-server/engine/task/echo-receive.js.map +1 -1
- package/dist-server/engine/task/echo-send.js +1 -1
- package/dist-server/engine/task/echo-send.js.map +1 -1
- package/dist-server/engine/task/graphql-mutate.js +1 -1
- package/dist-server/engine/task/graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/graphql-query.js +1 -1
- package/dist-server/engine/task/graphql-query.js.map +1 -1
- package/dist-server/engine/task/headless-post.js +1 -1
- package/dist-server/engine/task/headless-post.js.map +1 -1
- package/dist-server/engine/task/headless-scrap.js +1 -1
- package/dist-server/engine/task/headless-scrap.js.map +1 -1
- package/dist-server/engine/task/http-get.js +1 -1
- package/dist-server/engine/task/http-get.js.map +1 -1
- package/dist-server/engine/task/http-post.js +1 -1
- package/dist-server/engine/task/http-post.js.map +1 -1
- package/dist-server/engine/task/mqtt-publish.js +1 -1
- package/dist-server/engine/task/mqtt-publish.js.map +1 -1
- package/dist-server/engine/task/mqtt-subscribe.js +1 -1
- package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
- package/dist-server/engine/task/mssql-procedure.js +1 -1
- package/dist-server/engine/task/mssql-procedure.js.map +1 -1
- package/dist-server/engine/task/oracle-procedure.js +1 -1
- package/dist-server/engine/task/oracle-procedure.js.map +1 -1
- package/dist-server/engine/task/pyrun-execute.js +1 -1
- package/dist-server/engine/task/pyrun-execute.js.map +1 -1
- package/dist-server/engine/task/socket-listener.js +1 -1
- package/dist-server/engine/task/socket-listener.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.d.ts +1 -0
- package/dist-server/service/connection/connection-mutation.js +43 -4
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +1 -0
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.d.ts +4 -0
- package/dist-server/service/connection/connection-type.js +32 -1
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/connection/connection.d.ts +5 -1
- package/dist-server/service/connection/connection.js +9 -1
- package/dist-server/service/connection/connection.js.map +1 -1
- package/dist-server/service/scenario/scenario-mutation.js +1 -1
- package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
- package/dist-server/service/scenario/scenario-type.js +4 -1
- package/dist-server/service/scenario/scenario-type.js.map +1 -1
- package/dist-server/service/scenario/scenario.js +1 -1
- package/dist-server/service/scenario/scenario.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mqtt-subscribe.js","sourceRoot":"","sources":["../../../server/engine/task/mqtt-subscribe.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;;AAEH,0DAAkD;AAClD,oEAA4D;AAI5D,SAAS,iBAAiB,CAAC,IAAI,EAAE,MAAM;IACrC,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;YAC7C,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;QACxB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;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AM,EAAE;gBACxC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;aACnC;SACF;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,KAAK;QACX,QAAQ,EAAE;YACR,OAAO,EAAE;gBACP,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;gBACjC,EAAE,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE;gBACzC,EAAE,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,EAAE;gBAC1C,EAAE,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE;aAC1C;SACF;KACF;CACF,CAAA;AAED,aAAa,CAAC,IAAI,GAAG,iCAAiC,CAAA;AAEtD,sCAAsC;AACtC,+BAAY,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA","sourcesContent":["/**\n * MQTT Subscribe Task\n * ====================\n *\n * Pull-Based Message Consumption on MQTT:\n * ---------------------------------------\n * While MQTT is inherently a push-based protocol, this task implements a controlled,\n * pull-style message consumption model. A message is only processed when the task is\n * explicitly invoked (i.e., the consumer actively pulls one message at a time).\n * This enables fine-grained control over message flow and avoids unintended buffering.\n *\n * Overview:\n * ---------\n * This task connects to a specified MQTT broker and subscribes to a given topic.\n * It waits for a single message to arrive, resolves the result, and then removes\n * its internal message handler. It is designed to be reentrant — each execution\n * of this task handles exactly one message.\n *\n * This model is useful for applications where message processing must happen\n * sequentially or be synchronized with external state (e.g., workflows or state machines).\n *\n * Key Features:\n * -------------\n * - One-message-per-invocation: each task call resolves with a single message.\n * - Stateless message flow: the system does not queue or buffer messages locally.\n * - Supports automatic re-subscription on reconnect, improving robustness in unstable networks.\n * - Uses broker-level guarantees (QoS, retain) for durability and delivery control.\n * - Supports multiple data formats (JSON, plain text) and adjustable QoS levels.\n *\n * MQTT Reconnection Handling:\n * ---------------------------\n * The task listens for 'connect' events on the MQTT client. When the client reconnects\n * (e.g., after a dropped network), it automatically re-subscribes to all previously\n * tracked topics. This ensures consistent behavior even in long-running systems or\n * unstable network environments.\n *\n * If a disconnect occurs while a task is waiting for a message, the Promise remains\n * pending until a message is received after reconnection, or until manually cleaned up\n * via the task closure mechanism.\n *\n * How It Works:\n * -------------\n * 1. Retrieve an MQTT client using a named connection.\n * 2. Subscribe to the specified topic (only once per topic per workflow).\n * 3. Register a one-time message handler for the topic.\n * 4. When a message is received:\n * - It is parsed into the requested data format.\n * - The task resolves with the parsed message.\n * - The handler is immediately removed.\n * 5. Re-subscribe to all topics upon reconnect.\n * 6. Clean up all resources (subscription, handler, resolver) on task termination.\n *\n * Assumptions:\n * ------------\n * - Broker reliability is enforced via QoS ≥ 1 and/or retained messages.\n * - Message loss may occur if a message arrives before re-invocation, unless the broker retains it.\n * - The task caller is responsible for repeated invocations to consume additional messages.\n * - MQTT clients are externally managed and assumed to reconnect automatically.\n *\n * Parameters:\n * -----------\n * - topic (string): MQTT topic to subscribe to.\n * - dataFormat ('json' | 'text'): Describes how to parse the incoming message payload.\n * - qos (0 | 1 | 2): Quality of Service level for the subscription (default: 1).\n *\n * Returns:\n * --------\n * - A Promise that resolves with the first received message:\n * { data: any }\n * - If the task is terminated before receiving a message:\n * { data: null, terminated: true }\n *\n * Example:\n * --------\n * await MqttSubscribe({\n * connection: 'my-mqtt',\n * params: {\n * topic: 'sensor/temperature',\n * dataFormat: 'json',\n * qos: 1\n * },\n * name: 'readTemperature'\n * }, context)\n */\n\nimport { TaskRegistry } from '../task-registry.js'\nimport { ConnectionManager } from '../connection-manager.js'\nimport { InputStep } from '../../service/step/step-type.js'\nimport { Context } from '../types.js'\n\nfunction convertDataFormat(data, format) {\n if (format === 'json') {\n try {\n return JSON.parse(data)\n } catch (e) {\n console.error('JSON parse error:', e.message)\n return data.toString()\n }\n } else {\n return data.toString()\n }\n}\n\ninterface MqttContext extends Context {\n __mqtt_handlers?: Map<string, () => void>\n __mqtt_resolvers?: Map<string, (result: any) => void>\n __mqtt_subscriptions?: Set<string>\n __mqtt_event_hooked?: boolean\n}\n\nasync function MqttSubscribe(step: InputStep, context: MqttContext) {\n const {\n connection: connectionName,\n params: { topic, dataFormat, qos = 1 },\n name: stepName\n } = step\n\n const { domain, logger, closures } = context\n const { client } = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!client) throw new Error(`connection not found: ${connectionName}`)\n if (!topic) throw new Error(`Missing topic for connection: ${connectionName}`)\n\n const subscriberId = `${domain}_${connectionName}_${topic}_${stepName}`\n\n context.__mqtt_subscriptions ??= new Set()\n context.__mqtt_resolvers ??= new Map()\n context.__mqtt_handlers ??= new Map()\n\n // Setup MQTT client reconnect/resubscribe handlers only once\n if (!context.__mqtt_event_hooked) {\n client.on('connect', async () => {\n logger.info('[MQTT] Reconnected. Resubscribing to topics...')\n for (const t of context.__mqtt_subscriptions) {\n try {\n await client.subscribe(t, { qos })\n logger.info(`[MQTT] Resubscribed to topic: ${t}`)\n } catch (e) {\n logger.error(`[MQTT] Failed to resubscribe to topic ${t}: ${e.message}`)\n }\n }\n })\n\n client.on('offline', () => {\n logger.warn('[MQTT] Client offline')\n })\n\n client.on('close', () => {\n logger.warn('[MQTT] Connection closed')\n })\n\n client.on('error', err => {\n logger.error(`[MQTT] Error: ${err.message}`)\n })\n\n context.__mqtt_event_hooked = true\n }\n\n // Subscribe if not already done\n if (!context.__mqtt_subscriptions.has(topic)) {\n await client.subscribe(topic, { qos: Number(qos) })\n context.__mqtt_subscriptions.add(topic)\n logger.info(`Subscribed to topic: ${topic} (QoS: ${qos})`)\n }\n\n // Remove previous handler for this step\n if (context.__mqtt_handlers.has(subscriberId)) {\n const removeHandler = context.__mqtt_handlers.get(subscriberId)\n removeHandler?.()\n context.__mqtt_handlers.delete(subscriberId)\n }\n\n return new Promise(resolve => {\n context.__mqtt_resolvers.set(subscriberId, resolve)\n\n const messageHandler = (messageTopic, message) => {\n if (messageTopic !== topic) return\n\n const converted = convertDataFormat(message, dataFormat)\n const resolver = context.__mqtt_resolvers.get(subscriberId)\n\n if (resolver) {\n context.__mqtt_resolvers.delete(subscriberId)\n resolver({ data: converted })\n client.removeListener('message', messageHandler)\n context.__mqtt_handlers.delete(subscriberId)\n }\n }\n\n client.on('message', messageHandler)\n context.__mqtt_handlers.set(subscriberId, () => {\n client.removeListener('message', messageHandler)\n })\n\n closures.push(async () => {\n try {\n if (context.__mqtt_subscriptions?.has(topic)) {\n await client.unsubscribe(topic)\n context.__mqtt_subscriptions.delete(topic)\n logger.info(`Unsubscribed from topic: ${topic}`)\n }\n\n if (context.__mqtt_handlers?.has(subscriberId)) {\n const remove = context.__mqtt_handlers.get(subscriberId)\n remove?.()\n context.__mqtt_handlers.delete(subscriberId)\n }\n\n if (context.__mqtt_resolvers?.has(subscriberId)) {\n const resolver = context.__mqtt_resolvers.get(subscriberId)\n resolver?.({ data: null, terminated: true })\n context.__mqtt_resolvers.delete(subscriberId)\n }\n } catch (e) {\n logger.error(`MQTT cleanup error: ${e.message}`)\n }\n })\n\n logger.info(`Waiting for MQTT message on topic: ${topic}`)\n })\n}\n\n// Task parameter definitions for UI or DSL support\nMqttSubscribe.parameterSpec = [\n {\n type: 'string',\n name: 'topic',\n label: 'topic'\n },\n {\n type: 'select',\n label: 'data-format',\n name: 'dataFormat',\n property: {\n options: [\n { display: '', value: undefined },\n { display: 'Plain Text', value: 'text' },\n { display: 'JSON', value: 'json' }\n ]\n }\n },\n {\n type: 'select',\n label: 'QoS',\n name: 'qos',\n property: {\n options: [\n { display: '', value: undefined },\n { display: '0 (at most once)', value: 0 },\n { display: '1 (at least once)', value: 1 },\n { display: '2 (exactly once)', value: 2 }\n ]\n }\n }\n]\n\nMqttSubscribe.help = 'integration/task/mqtt-subscribe'\n\n// Register task with runtime registry\nTaskRegistry.registerTaskHandler('mqtt-subscribe', MqttSubscribe)\n"]}
|
1
|
+
{"version":3,"file":"mqtt-subscribe.js","sourceRoot":"","sources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task\n * ====================\n *\n * Pull-Based Message Consumption on MQTT:\n * ---------------------------------------\n * While MQTT is inherently a push-based protocol, this task implements a controlled,\n * pull-style message consumption model. A message is only processed when the task is\n * explicitly invoked (i.e., the consumer actively pulls one message at a time).\n * This enables fine-grained control over message flow and avoids unintended buffering.\n *\n * Overview:\n * ---------\n * This task connects to a specified MQTT broker and subscribes to a given topic.\n * It waits for a single message to arrive, resolves the result, and then removes\n * its internal message handler. It is designed to be reentrant — each execution\n * of this task handles exactly one message.\n *\n * This model is useful for applications where message processing must happen\n * sequentially or be synchronized with external state (e.g., workflows or state machines).\n *\n * Key Features:\n * -------------\n * - One-message-per-invocation: each task call resolves with a single message.\n * - Stateless message flow: the system does not queue or buffer messages locally.\n * - Supports automatic re-subscription on reconnect, improving robustness in unstable networks.\n * - Uses broker-level guarantees (QoS, retain) for durability and delivery control.\n * - Supports multiple data formats (JSON, plain text) and adjustable QoS levels.\n *\n * MQTT Reconnection Handling:\n * ---------------------------\n * The task listens for 'connect' events on the MQTT client. When the client reconnects\n * (e.g., after a dropped network), it automatically re-subscribes to all previously\n * tracked topics. This ensures consistent behavior even in long-running systems or\n * unstable network environments.\n *\n * If a disconnect occurs while a task is waiting for a message, the Promise remains\n * pending until a message is received after reconnection, or until manually cleaned up\n * via the task closure mechanism.\n *\n * How It Works:\n * -------------\n * 1. Retrieve an MQTT client using a named connection.\n * 2. Subscribe to the specified topic (only once per topic per workflow).\n * 3. Register a one-time message handler for the topic.\n * 4. When a message is received:\n * - It is parsed into the requested data format.\n * - The task resolves with the parsed message.\n * - The handler is immediately removed.\n * 5. Re-subscribe to all topics upon reconnect.\n * 6. Clean up all resources (subscription, handler, resolver) on task termination.\n *\n * Assumptions:\n * ------------\n * - Broker reliability is enforced via QoS ≥ 1 and/or retained messages.\n * - Message loss may occur if a message arrives before re-invocation, unless the broker retains it.\n * - The task caller is responsible for repeated invocations to consume additional messages.\n * - MQTT clients are externally managed and assumed to reconnect automatically.\n *\n * Parameters:\n * -----------\n * - topic (string): MQTT topic to subscribe to.\n * - dataFormat ('json' | 'text'): Describes how to parse the incoming message payload.\n * - qos (0 | 1 | 2): Quality of Service level for the subscription (default: 1).\n *\n * Returns:\n * --------\n * - A Promise that resolves with the first received message:\n * { data: any }\n * - If the task is terminated before receiving a message:\n * { data: null, terminated: true }\n *\n * Example:\n * --------\n * await MqttSubscribe({\n * connection: 'my-mqtt',\n * params: {\n * topic: 'sensor/temperature',\n * dataFormat: 'json',\n * qos: 1\n * },\n * name: 'readTemperature'\n * }, context)\n */\n\nimport { TaskRegistry } from '../task-registry.js'\nimport { ConnectionManager } from '../connection-manager.js'\nimport { InputStep } from '../../service/step/step-type.js'\nimport { Context } from '../types.js'\n\nfunction convertDataFormat(data, format) {\n if (format === 'json') {\n try {\n return JSON.parse(data)\n } catch (e) {\n console.error('JSON parse error:', e.message)\n return data.toString()\n }\n } else {\n return data.toString()\n }\n}\n\ninterface MqttContext extends Context {\n __mqtt_handlers?: Map<string, () => void>\n __mqtt_resolvers?: Map<string, (result: any) => void>\n __mqtt_subscriptions?: Set<string>\n __mqtt_event_hooked?: boolean\n}\n\nasync function MqttSubscribe(step: InputStep, context: MqttContext) {\n const {\n connection: connectionName,\n params: { topic, dataFormat, qos = 1 },\n name: stepName\n } = step\n\n const { domain, logger, closures } = context\n const { client } = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!client) throw new Error(`connection not found: ${connectionName}`)\n if (!topic) throw new Error(`Missing topic for connection: ${connectionName}`)\n\n const subscriberId = `${domain}_${connectionName}_${topic}_${stepName}`\n\n context.__mqtt_subscriptions ??= new Set()\n context.__mqtt_resolvers ??= new Map()\n context.__mqtt_handlers ??= new Map()\n\n // Setup MQTT client reconnect/resubscribe handlers only once\n if (!context.__mqtt_event_hooked) {\n client.on('connect', async () => {\n logger.info('[MQTT] Reconnected. Resubscribing to topics...')\n for (const t of context.__mqtt_subscriptions) {\n try {\n await client.subscribe(t, { qos })\n logger.info(`[MQTT] Resubscribed to topic: ${t}`)\n } catch (e) {\n logger.error(`[MQTT] Failed to resubscribe to topic ${t}: ${e.message}`)\n }\n }\n })\n\n client.on('offline', () => {\n logger.warn('[MQTT] Client offline')\n })\n\n client.on('close', () => {\n logger.warn('[MQTT] Connection closed')\n })\n\n client.on('error', err => {\n logger.error(`[MQTT] Error: ${err.message}`)\n })\n\n context.__mqtt_event_hooked = true\n }\n\n // Subscribe if not already done\n if (!context.__mqtt_subscriptions.has(topic)) {\n await client.subscribe(topic, { qos: Number(qos) })\n context.__mqtt_subscriptions.add(topic)\n logger.info(`Subscribed to topic: ${topic} (QoS: ${qos})`)\n }\n\n // Remove previous handler for this step\n if (context.__mqtt_handlers.has(subscriberId)) {\n const removeHandler = context.__mqtt_handlers.get(subscriberId)\n removeHandler?.()\n context.__mqtt_handlers.delete(subscriberId)\n }\n\n return new Promise(resolve => {\n context.__mqtt_resolvers.set(subscriberId, resolve)\n\n const messageHandler = (messageTopic, message) => {\n if (messageTopic !== topic) return\n\n const converted = convertDataFormat(message, dataFormat)\n const resolver = context.__mqtt_resolvers.get(subscriberId)\n\n if (resolver) {\n context.__mqtt_resolvers.delete(subscriberId)\n resolver({ data: converted })\n client.removeListener('message', messageHandler)\n context.__mqtt_handlers.delete(subscriberId)\n }\n }\n\n client.on('message', messageHandler)\n context.__mqtt_handlers.set(subscriberId, () => {\n client.removeListener('message', messageHandler)\n })\n\n closures.push(async () => {\n try {\n if (context.__mqtt_subscriptions?.has(topic)) {\n await client.unsubscribe(topic)\n context.__mqtt_subscriptions.delete(topic)\n logger.info(`Unsubscribed from topic: ${topic}`)\n }\n\n if (context.__mqtt_handlers?.has(subscriberId)) {\n const remove = context.__mqtt_handlers.get(subscriberId)\n remove?.()\n context.__mqtt_handlers.delete(subscriberId)\n }\n\n if (context.__mqtt_resolvers?.has(subscriberId)) {\n const resolver = context.__mqtt_resolvers.get(subscriberId)\n resolver?.({ data: null, terminated: true })\n context.__mqtt_resolvers.delete(subscriberId)\n }\n } catch (e) {\n logger.error(`MQTT cleanup error: ${e.message}`)\n }\n })\n\n logger.info(`Waiting for MQTT message on topic: ${topic}`)\n })\n}\n\n// Task parameter definitions for UI or DSL support\nMqttSubscribe.parameterSpec = [\n {\n type: 'string',\n name: 'topic',\n label: 'topic'\n },\n {\n type: 'select',\n label: 'data-format',\n name: 'dataFormat',\n property: {\n options: [\n { display: '', value: undefined },\n { display: 'Plain Text', value: 'text' },\n { display: 'JSON', value: 'json' }\n ]\n }\n },\n {\n type: 'select',\n label: 'QoS',\n name: 'qos',\n property: {\n options: [\n { display: '', value: undefined },\n { display: '0 (at most once)', value: 0 },\n { display: '1 (at least once)', value: 1 },\n { display: '2 (exactly once)', value: 2 }\n ]\n }\n }\n]\n\nMqttSubscribe.help = 'integration/task/mqtt-subscribe'\n\n// Register task with runtime registry\nTaskRegistry.registerTaskHandler('mqtt-subscribe', MqttSubscribe)\n"]}
|
@@ -34,7 +34,7 @@ async function MssqlProcedure(step, context) {
|
|
34
34
|
var { domain, user, data, variables, lng } = context;
|
35
35
|
var { connection: connectionName, params } = step;
|
36
36
|
var { code = '', procedure = '', parameters = [] } = params.parameters;
|
37
|
-
var dbconnection = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
37
|
+
var dbconnection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
38
38
|
if (!code) {
|
39
39
|
throw 'procedure code not defined';
|
40
40
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mssql-procedure.js","sourceRoot":"","sources":["../../../server/engine/task/mssql-procedure.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAC5C,iDAA8C;AAC9C,8DAAyD;AACzD,oDAA+C;AAG/C,eAAY;AAEZ,IAAI,CAAC;IACH,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAC9B,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,C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AC7B,CAAC;YAED,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAE,CAAC,CAAA;IAER,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAA;IAEzE,OAAO;QACL,IAAI,EAAE,MAAM;KACb,CAAA;AACH,CAAC;AAED,cAAc,CAAC,aAAa,GAAG;IAC7B;QACE,IAAI,EAAE,sBAAsB;QAC5B,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE;YACR,MAAM,EAAE,OAAO;SAChB;KACF;CACF,CAAA;AAED,cAAc,CAAC,IAAI,GAAG,kCAAkC,CAAA;AAExD,4BAAY,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAA","sourcesContent":["import { logger } from '@things-factory/env'\nimport { access } from '@things-factory/utils'\nimport { ConnectionManager } from '../connection-manager'\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\nimport 'ses'\n\ntry {\n var mssql = require('mssql')\n} catch (err) {\n logger.error('mssql module loading failed', err)\n}\n\ntype ProcedureParameterType = {\n name: string\n dir: string\n type: string\n val?: any\n accessor?: string\n maxSize?: number\n}\n\ntype ValueType = {\n code?: string\n procedure?: string\n parameters?: ProcedureParameterType[]\n}\n\nconst DIR = {\n In: 'in',\n Out: 'out',\n Inout: 'inout' /* 초기값이 있는 out 파라미터 */\n}\n\nconst NUMBER_TYPES = [\n 'TINYINT',\n 'SMALLINT',\n 'INT',\n 'BIGINT',\n 'FLOAT',\n 'READ',\n 'DECIMAL',\n 'NUMERIC',\n 'MONEY',\n 'SMALLMONEY'\n]\n\nconst DATE_TYPES = ['DATE', 'TIME', 'DATETIME', 'SMALLDATETIME', 'DATETIME2']\nconst PARAMETERIZED_STRINGS = ['NCHAR', 'NVARCHAR', 'NTEXT', 'DECIMAL', 'NUMERIC']\n\nasync function MssqlProcedure(step: InputStep, context: Context) {\n var { domain, user, data, variables, lng } = context\n var { connection: connectionName, params } = step\n\n var { code = '', procedure = '', parameters = [] } = params.parameters as ValueType\n\n var dbconnection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n if (!code) {\n throw 'procedure code not defined'\n }\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalCode\n try {\n evalCode = compartment.evaluate('`' + code + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate code: ${err.message}`)\n }\n\n code = evalCode\n\n const procedureParameters =\n parameters &&\n parameters.reduce((sum, { name, val, dir, type, accessor, maxSize }) => {\n sum[name] = {\n dir: DIR[dir],\n type\n }\n\n const calculated = accessor ? access(accessor, data) || val : val\n\n if (calculated !== undefined) {\n sum[name].val = NUMBER_TYPES.includes(type)\n ? Number(calculated)\n : DATE_TYPES.includes(type)\n ? new Date(calculated)\n : String(calculated)\n }\n\n if ((dir == DIR.In || dir == DIR.Inout) && maxSize > 0 && type == 'String') {\n sum[name].type = mssql?.VarChar(maxSize)\n sum[name].maxSize = maxSize\n }\n\n return sum\n }, {})\n\n const result = await dbconnection.execute(procedure, procedureParameters)\n\n return {\n data: result\n }\n}\n\nMssqlProcedure.parameterSpec = [\n {\n type: 'procedure-parameters',\n name: 'parameters',\n label: '',\n property: {\n dbtype: 'mssql'\n }\n }\n]\n\nMssqlProcedure.help = 'integration/task/mssql-procedure'\n\nTaskRegistry.registerTaskHandler('mssql-procedure', MssqlProcedure)\n"]}
|
@@ -29,7 +29,7 @@ async function OracleProcedure(step, context) {
|
|
29
29
|
var { domain, user, data, variables, lng } = context;
|
30
30
|
var { connection: connectionName, params } = step;
|
31
31
|
var { code = '', parameters = [] } = params.parameters;
|
32
|
-
var dbconnection = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
32
|
+
var dbconnection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
33
33
|
if (!code) {
|
34
34
|
throw 'procedure code not defined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CAAC,CAAC,UAAU,CAAA;YACtB,CAAC;YAED,IAAI,OAAO,EAAE,CAAC;gBACZ,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,GAAG,OAAO,CAAA;YAC7B,CAAC;YAED,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAE,CAAC,CAAA;IAER,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAA;IAEpE,OAAO;QACL,IAAI,EAAE,MAAM;KACb,CAAA;AACH,CAAC;AAED,eAAe,CAAC,aAAa,GAAG;IAC9B;QACE,IAAI,EAAE,sBAAsB;QAC5B,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE;YACR,MAAM,EAAE,QAAQ;SACjB;KACF;CACF,CAAA;AAED,eAAe,CAAC,IAAI,GAAG,mCAAmC,CAAA;AAE1D,4BAAY,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAA","sourcesContent":["import { logger } from '@things-factory/env'\nimport { access } from '@things-factory/utils'\nimport { ConnectionManager } from '../connection-manager'\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\nimport 'ses'\n\ntry {\n var oracledb = require('oracledb')\n} catch (err) {\n logger.error('oracledb module loading failed', err)\n}\n\ntype ProcedureParameterType = {\n name: string\n dir: string\n type: string\n val?: any\n accessor?: string\n maxSize?: number\n}\n\ntype ValueType = {\n code?: string\n procedure?: string\n parameters?: ProcedureParameterType[]\n}\n\nconst TYPES = {\n Number: oracledb?.NUMBER,\n String: oracledb?.STRING,\n Date: oracledb?.DATE,\n Buffer: oracledb?.BUFFER,\n Blob: oracledb?.BLOB,\n Clob: oracledb?.CLOB,\n Cursor: oracledb?.CURSOR\n}\n\nconst DIR = {\n In: oracledb?.BIND_IN,\n Inout: oracledb?.BIND_INOUT,\n Out: oracledb?.BIND_OUT\n}\n\nasync function OracleProcedure(step: InputStep, context: Context) {\n var { domain, user, data, variables, lng } = context\n var { connection: connectionName, params } = step\n\n var { code = '', parameters = [] } = params.parameters as ValueType\n\n var dbconnection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n if (!code) {\n throw 'procedure code not defined'\n }\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalCode\n try {\n evalCode = compartment.evaluate('`' + code + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate code: ${err.message}`)\n }\n\n code = evalCode\n\n const procedureParameters =\n parameters &&\n parameters.reduce((sum, { name, val, dir, type, accessor, maxSize }) => {\n sum[name] = {\n dir: DIR[dir],\n type: TYPES[type]\n }\n\n const calculated = accessor ? access(accessor, data) || val : val\n\n if (calculated !== undefined) {\n sum[name].val =\n type === 'Date'\n ? new Date(calculated)\n : type == 'Number'\n ? Number(calculated)\n : type == 'String'\n ? String(calculated)\n : calculated\n }\n\n if (maxSize) {\n sum[name].maxSize = maxSize\n }\n\n return sum\n }, {})\n\n const result = await dbconnection.execute(code, procedureParameters)\n\n return {\n data: result\n }\n}\n\nOracleProcedure.parameterSpec = [\n {\n type: 'procedure-parameters',\n name: 'parameters',\n label: '',\n property: {\n dbtype: 'oracle'\n }\n }\n]\n\nOracleProcedure.help = 'integration/task/oracle-procedure'\n\nTaskRegistry.registerTaskHandler('oracle-procedure', OracleProcedure)\n"]}
|
@@ -4,7 +4,7 @@ const task_registry_1 = require("../task-registry");
|
|
4
4
|
const connection_manager_1 = require("../connection-manager");
|
5
5
|
async function PyrunExecute(step, { logger, data, domain }) {
|
6
6
|
const { connection: connectionName, params } = step;
|
7
|
-
const pyrun = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
7
|
+
const pyrun = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
8
8
|
if (!pyrun)
|
9
9
|
throw Error(`pyrun connection not found: ${connectionName}`);
|
10
10
|
const module = params.module;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pyrun-execute.js","sourceRoot":"","sources":["../../../server/engine/task/pyrun-execute.ts"],"names":[],"mappings":";;AAAA,oDAA+C;AAC/C,8DAAyD;AAIzD,KAAK,UAAU,YAAY,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IACnE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAEnD,MAAM,KAAK,GAAG,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"pyrun-execute.js","sourceRoot":"","sources":["../../../server/engine/task/pyrun-execute.ts"],"names":[],"mappings":";;AAAA,oDAA+C;AAC/C,8DAAyD;AAIzD,KAAK,UAAU,YAAY,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IACnE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAEnD,MAAM,KAAK,GAAG,MAAM,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACzF,IAAI,CAAC,KAAK;QAAE,MAAM,KAAK,CAAC,+BAA+B,cAAc,EAAE,CAAC,CAAA;IAExE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAA;IAEhC,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,QAAQ,YAAY,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAA;IACrE,MAAM,OAAO,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAS,CAAA;IAC7D,IAAI,KAAK,CAAC,KAAK;QAAE,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,CAAC,KAAK,EAAE,CAAA;IAEnE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAA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TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function PyrunExecute(step: InputStep, { logger, data, domain }) {\n const { connection: connectionName, params } = step\n\n const pyrun = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!pyrun) throw Error(`pyrun connection not found: ${connectionName}`)\n\n const module = params.module\n const input = params.input || {}\n\n const url = `${pyrun.endpoint}/api/run/${encodeURIComponent(module)}`\n const headers = { 'Content-Type': 'application/json' } as any\n if (pyrun.token) headers['Authorization'] = `Bearer ${pyrun.token}`\n\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify({ input })\n })\n\n if (!response.ok) {\n const error = await response.text()\n throw new Error(`pyrun-execute failed: ${response.status} ${error}`)\n }\n\n const { result, exit_code, stderr, stdout, duration } = await response.json()\n\n if (stdout) {\n logger.info(`pyrun-execute stdout: ${stdout}`)\n }\n\n if (stderr) {\n logger.error(`pyrun-execute stderr: ${stderr}`)\n }\n\n if (exit_code !== 0) {\n throw new Error(`pyrun-execute failed: ${exit_code}`)\n }\n\n return { data: result }\n}\n\nPyrunExecute.parameterSpec = [\n { type: 'string', name: 'module', label: 'module', required: true },\n { type: 'key-values', name: 'input', label: 'input-params', required: false }\n]\nPyrunExecute.help = 'integration/task/pyrun-execute'\n\nTaskRegistry.registerTaskHandler('pyrun-execute', PyrunExecute)\n"]}
|
@@ -26,7 +26,7 @@ async function SocketListener(step, context) {
|
|
26
26
|
context.__socket_listener = {};
|
27
27
|
}
|
28
28
|
// get socket information from connection
|
29
|
-
var connection = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
29
|
+
var connection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
30
30
|
if (!connection) {
|
31
31
|
throw new Error(`connector '${connectionName}' is not established.`);
|
32
32
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"socket-listener.js","sourceRoot":"","sources":["../../../server/engine/task/socket-listener.ts"],"names":[],"mappings":";;AAAA,iDAA6C;AAC7C,oDAA+C;AAC/C,8DAAyD;AAIzD,SAAS,iBAAiB,CAAC,IAAI,EAAE,MAAM;IACrC,IAAI,CAAC;QACH,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;aAAM,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,IAAe,EAAE,OAAgB;IAC7D,qBAAqB;IACrB,MAAM,EACJ,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,EAAE,UAAU,GAAG,MAAM,EAAE,EAC/B,IAAI,EACL,GAAG,IAAI,CAAA;IAER,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAA;IAC/D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAO,CAAC,iBAAiB,GAAG,EAAE,CAAA;IAChC,CAAC;IAED,yCAAyC;IACzC,IAAI,UAAU,GAAG,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"socket-listener.js","sourceRoot":"","sources":["../../../server/engine/task/socket-listener.ts"],"names":[],"mappings":";;AAAA,iDAA6C;AAC7C,oDAA+C;AAC/C,8DAAyD;AAIzD,SAAS,iBAAiB,CAAC,IAAI,EAAE,MAAM;IACrC,IAAI,CAAC;QACH,IAAI,MAAM,IAAI,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,aAAK,EAAC,GAAG,CAAC,CAAA;gBAClB,CAAC;gBACD,IAAI,OAAO,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAA;gBAC9B,OAAO;oBACL,OAAO;iBACR,CAAA;YACH,CAAC,CAAA;YAED,MAAM,UAAU,CAAC,WAAW,CAAC,uBAAuB,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;gBACpE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;gBAC/B,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC,CAAC,CAAA;YAClE,CAAC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;IAED,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAA;IAEzD,OAAO;QACL,IAAI,EAAE,OAAO;KACd,CAAA;AACH,CAAC;AAED,cAAc,CAAC,aAAa,GAAG;IAC7B;QACE,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE;YACR,OAAO,EAAE;gBACP;oBACE,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,KAAK;iBACb;gBACD;oBACE,OAAO,EAAE,MAAM;oBACf,KAAK,EAAE,MAAM;iBACd;gBACD;oBACE,OAAO,EAAE,QAAQ;oBACjB,KAAK,EAAE,QAAQ;iBAChB;aACF;SACF;KACF;CACF,CAAA;AACD,4BAAY,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAA","sourcesContent":["import { sleep } from '@things-factory/utils'\nimport { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nfunction convertDataFormat(data, format) {\n try {\n if (format == 'json') {\n return JSON.parse(data)\n } else if (format == 'csv') {\n return data.split(',')\n }\n } catch (e) {\n return data.toString()\n }\n\n return data\n}\n\nasync function SocketListener(step: InputStep, context: Context) {\n //get connection data\n const {\n connection: connectionName,\n params: { dataFormat = 'JSON' },\n name\n } = step\n\n const { domain, logger, closures, __socket_listener } = context\n logger.info('\\r\\n')\n if (!__socket_listener) {\n context.__socket_listener = {}\n }\n\n // get socket information from connection\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!connection) {\n throw new Error(`connector '${connectionName}' is not established.`)\n }\n\n /*\n * 1. listner list에서 listner를 찾는다. 없으면, 생성한다.\n */\n if (!context.__socket_listener[name]) {\n try {\n var MESSAGES = []\n context.__socket_listener[name] = async () => {\n while (MESSAGES.length == 0) {\n await sleep(100)\n }\n var message = MESSAGES.shift()\n return {\n message\n }\n }\n\n await connection.addListener('socket-message-arrive', async message => {\n logger.info(message.toString())\n MESSAGES.push(convertDataFormat(message.toString(), dataFormat))\n })\n } catch (e) {\n logger.error(e)\n }\n }\n\n var { message } = await context.__socket_listener[name]()\n\n return {\n data: message\n }\n}\n\nSocketListener.parameterSpec = [\n {\n type: 'select',\n label: 'data-format',\n name: 'dataFormat',\n property: {\n options: [\n {\n display: 'CSV',\n value: 'csv'\n },\n {\n display: 'JSON',\n value: 'json'\n },\n {\n display: 'String',\n value: 'string'\n }\n ]\n }\n }\n]\nTaskRegistry.registerTaskHandler('socket-listener', SocketListener)\n"]}
|
@@ -82,8 +82,27 @@ let ConnectionMutation = class ConnectionMutation {
|
|
82
82
|
where: { domain: { id: domain.id }, name },
|
83
83
|
relations: ['domain', 'edge']
|
84
84
|
});
|
85
|
-
|
86
|
-
|
85
|
+
if (!connection) {
|
86
|
+
if (domain.parentId) {
|
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
|
+
}
|
95
|
+
}
|
96
|
+
/* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */
|
97
|
+
if (connection.domain.id !== domain.id) {
|
98
|
+
connection.domain = domain;
|
99
|
+
await connection.connect();
|
100
|
+
/* on-demand 연결인 경우에 connection을 저장하지 말아야 한다. */
|
101
|
+
}
|
102
|
+
else {
|
103
|
+
await connection.connect();
|
104
|
+
await repository.save(connection);
|
105
|
+
}
|
87
106
|
return {
|
88
107
|
...connection,
|
89
108
|
state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
|
@@ -98,8 +117,28 @@ let ConnectionMutation = class ConnectionMutation {
|
|
98
117
|
where: { domain: { id: domain.id }, name },
|
99
118
|
relations: ['domain', 'edge']
|
100
119
|
});
|
101
|
-
|
102
|
-
|
120
|
+
if (!connection) {
|
121
|
+
if (domain.parentId) {
|
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
|
+
}
|
130
|
+
}
|
131
|
+
/* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */
|
132
|
+
/* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */
|
133
|
+
if (connection.domain.id !== domain.id) {
|
134
|
+
connection.domain = domain;
|
135
|
+
await connection.disconnect();
|
136
|
+
/* on-demand 연결인 경우에 connection을 저장하지 말아야 한다. */
|
137
|
+
}
|
138
|
+
else {
|
139
|
+
await connection.disconnect();
|
140
|
+
await repository.save(connection);
|
141
|
+
}
|
103
142
|
return {
|
104
143
|
...connection,
|
105
144
|
state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connection-mutation.js","sourceRoot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ourcesContent":["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 await connection.connect()\n await repository.save(connection)\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 await connection.disconnect()\n await repository.save(connection)\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,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AAC;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"]}
|
@@ -45,6 +45,7 @@ tslib_1.__decorate([
|
|
45
45
|
shell_1.pubsub.publish('connection-state', {
|
46
46
|
connectionState: {
|
47
47
|
...connection,
|
48
|
+
domain /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */,
|
48
49
|
state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
|
49
50
|
? connection_1.ConnectionStatus.CONNECTED
|
50
51
|
: connection_1.ConnectionStatus.DISCONNECTED,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAAgE;AAEhE,iDAAkE;AAElE,wEAAmE;AACnE,6CAA2D;AAC3D,uDAAmD;AAEnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAG7E,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;
|
1
|
+
{"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;A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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;iCAnGU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,sBAAsB,CAoGlC","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\nimport { Arg, Resolver, Root, Subscription } from 'type-graphql'\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'\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: ({ 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) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n process.nextTick(async () => {\n var where = { domain: { id: domain.id } }\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\n return (!name || name === pname) && subdomain === pdomain?.subdomain\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: ({ 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) && !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"]}
|
@@ -18,6 +18,7 @@ export declare class ConnectionState {
|
|
18
18
|
name?: string;
|
19
19
|
description?: string;
|
20
20
|
type?: string;
|
21
|
+
onDemand?: boolean;
|
21
22
|
edge?: Appliance;
|
22
23
|
state?: ConnectionStatus;
|
23
24
|
timestamp?: Date;
|
@@ -26,8 +27,10 @@ export declare class NewConnection {
|
|
26
27
|
name: string;
|
27
28
|
description?: string;
|
28
29
|
type?: string;
|
30
|
+
onDemand: boolean;
|
29
31
|
edge?: Appliance;
|
30
32
|
endpoint?: string;
|
33
|
+
active?: boolean;
|
31
34
|
params?: {
|
32
35
|
[key: string]: any;
|
33
36
|
};
|
@@ -37,6 +40,7 @@ export declare class ConnectionPatch {
|
|
37
40
|
name?: string;
|
38
41
|
description?: string;
|
39
42
|
type?: string;
|
43
|
+
onDemand: boolean;
|
40
44
|
edge?: Appliance;
|
41
45
|
endpoint?: string;
|
42
46
|
active?: boolean;
|
@@ -30,6 +30,13 @@ tslib_1.__decorate([
|
|
30
30
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The type of the connection.' }),
|
31
31
|
tslib_1.__metadata("design:type", String)
|
32
32
|
], ConnectionState.prototype, "type", void 0);
|
33
|
+
tslib_1.__decorate([
|
34
|
+
(0, type_graphql_1.Field)({
|
35
|
+
nullable: true,
|
36
|
+
description: 'When true, connection is created on-demand when needed and cleaned up after use.'
|
37
|
+
}),
|
38
|
+
tslib_1.__metadata("design:type", Boolean)
|
39
|
+
], ConnectionState.prototype, "onDemand", void 0);
|
33
40
|
tslib_1.__decorate([
|
34
41
|
(0, type_graphql_1.Field)(type => auth_base_1.Appliance, { nullable: true, description: 'The edge appliance associated with the connection.' }),
|
35
42
|
tslib_1.__metadata("design:type", auth_base_1.Appliance)
|
@@ -60,6 +67,13 @@ tslib_1.__decorate([
|
|
60
67
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The type of the new connection (e.g., tcp, http, mqtt).' }),
|
61
68
|
tslib_1.__metadata("design:type", String)
|
62
69
|
], NewConnection.prototype, "type", void 0);
|
70
|
+
tslib_1.__decorate([
|
71
|
+
(0, type_graphql_1.Field)({
|
72
|
+
nullable: true,
|
73
|
+
description: 'When true, connection is created on-demand when needed and cleaned up after use.'
|
74
|
+
}),
|
75
|
+
tslib_1.__metadata("design:type", Boolean)
|
76
|
+
], NewConnection.prototype, "onDemand", void 0);
|
63
77
|
tslib_1.__decorate([
|
64
78
|
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'Reference to the edge appliance for the new connection.' }),
|
65
79
|
tslib_1.__metadata("design:type", auth_base_1.Appliance)
|
@@ -68,6 +82,13 @@ tslib_1.__decorate([
|
|
68
82
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The endpoint URL or address for the new connection.' }),
|
69
83
|
tslib_1.__metadata("design:type", String)
|
70
84
|
], NewConnection.prototype, "endpoint", void 0);
|
85
|
+
tslib_1.__decorate([
|
86
|
+
(0, type_graphql_1.Field)({
|
87
|
+
nullable: true,
|
88
|
+
description: 'Whether to automatically connect when the application starts'
|
89
|
+
}),
|
90
|
+
tslib_1.__metadata("design:type", Boolean)
|
91
|
+
], NewConnection.prototype, "active", void 0);
|
71
92
|
tslib_1.__decorate([
|
72
93
|
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'A key-value map of parameters for the new connection.' }),
|
73
94
|
tslib_1.__metadata("design:type", Object)
|
@@ -94,6 +115,13 @@ tslib_1.__decorate([
|
|
94
115
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The new type for the connection.' }),
|
95
116
|
tslib_1.__metadata("design:type", String)
|
96
117
|
], ConnectionPatch.prototype, "type", void 0);
|
118
|
+
tslib_1.__decorate([
|
119
|
+
(0, type_graphql_1.Field)({
|
120
|
+
nullable: true,
|
121
|
+
description: 'When true, connection is created on-demand when needed and cleaned up after use.'
|
122
|
+
}),
|
123
|
+
tslib_1.__metadata("design:type", Boolean)
|
124
|
+
], ConnectionPatch.prototype, "onDemand", void 0);
|
97
125
|
tslib_1.__decorate([
|
98
126
|
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'The new edge appliance for the connection.' }),
|
99
127
|
tslib_1.__metadata("design:type", auth_base_1.Appliance)
|
@@ -103,7 +131,10 @@ tslib_1.__decorate([
|
|
103
131
|
tslib_1.__metadata("design:type", String)
|
104
132
|
], ConnectionPatch.prototype, "endpoint", void 0);
|
105
133
|
tslib_1.__decorate([
|
106
|
-
(0, type_graphql_1.Field)({
|
134
|
+
(0, type_graphql_1.Field)({
|
135
|
+
nullable: true,
|
136
|
+
description: 'Whether to automatically connect when the application starts'
|
137
|
+
}),
|
107
138
|
tslib_1.__metadata("design:type", Boolean)
|
108
139
|
], ConnectionPatch.prototype, "active", void 0);
|
109
140
|
tslib_1.__decorate([
|
@@ -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,6CAA+C;AAYxC,IAAM,eAAe,GAArB,MAAM,eAAe;
|
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,6CAA+C;AAYxC,IAAM,eAAe,GAArB,MAAM,eAAe;CA8B3B,CAAA;AA9BY,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,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;;oDACzD;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;;6CACzD;AAMb;IAJC,IAAA,oBAAK,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,kFAAkF;KAChG,CAAC;;iDACgB;AAGlB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,qBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oDAAoD,EAAE,CAAC;sCACzG,qBAAS;6CAAA;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;;8CACxD;AAGxB;IADC,IAAA,o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AC;;+CACa;0BAtCJ,eAAe;IAD3B,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;GACvE,eAAe,CAuC3B;AAGM,IAAM,cAAc,GAApB,MAAM,cAAc;CAM1B,CAAA;AANY,wCAAc;AAEzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,uBAAU,CAAC,EAAE,EAAE,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 { 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 => 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 => 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 => 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"]}
|
@@ -42,9 +42,13 @@ export declare class Connection {
|
|
42
42
|
*/
|
43
43
|
endpoint: string;
|
44
44
|
/**
|
45
|
-
*
|
45
|
+
* Whether to automatically connect when the application starts
|
46
46
|
*/
|
47
47
|
active: boolean;
|
48
|
+
/**
|
49
|
+
* Indicates whether the connection should be created on-demand when needed.
|
50
|
+
*/
|
51
|
+
onDemand: boolean;
|
48
52
|
/**
|
49
53
|
* The status of the connection, using the ConnectionStatus type.
|
50
54
|
*/
|
@@ -149,10 +149,18 @@ tslib_1.__decorate([
|
|
149
149
|
(0, typeorm_1.Column)({ nullable: true }),
|
150
150
|
(0, type_graphql_1.Field)({
|
151
151
|
nullable: true,
|
152
|
-
description: '
|
152
|
+
description: 'Whether to automatically connect when the application starts'
|
153
153
|
}),
|
154
154
|
tslib_1.__metadata("design:type", Boolean)
|
155
155
|
], Connection.prototype, "active", void 0);
|
156
|
+
tslib_1.__decorate([
|
157
|
+
(0, typeorm_1.Column)({ default: false }),
|
158
|
+
(0, type_graphql_1.Field)({
|
159
|
+
nullable: true,
|
160
|
+
description: 'When true, connection is created on-demand when needed and cleaned up after use.'
|
161
|
+
}),
|
162
|
+
tslib_1.__metadata("design:type", Boolean)
|
163
|
+
], Connection.prototype, "onDemand", void 0);
|
156
164
|
tslib_1.__decorate([
|
157
165
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The current status of the connection (e.g., CONNECTED, DISCONNECTED).' }),
|
158
166
|
tslib_1.__metadata("design:type", String)
|