@things-factory/integration-msgraph 9.0.20 → 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/connector/msgraph-connector.d.ts +1 -0
- package/dist-server/engine/connector/msgraph-connector.js +8 -10
- package/dist-server/engine/connector/msgraph-connector.js.map +1 -1
- package/dist-server/engine/task/msgraph-get.js +1 -1
- package/dist-server/engine/task/msgraph-get.js.map +1 -1
- package/dist-server/engine/task/msgraph-post.js +1 -1
- package/dist-server/engine/task/msgraph-post.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/translations/en.json +1 -1
- package/translations/ja.json +1 -1
- package/translations/ko.json +1 -1
- package/translations/ms.json +1 -1
- package/translations/zh.json +1 -1
|
@@ -13,8 +13,8 @@ class MsGraphConnector {
|
|
|
13
13
|
integration_base_1.ConnectionManager.logger.info('msgraph-connector connections are ready');
|
|
14
14
|
}
|
|
15
15
|
async connect(connection) {
|
|
16
|
-
var { endpoint: uri = 'https://graph.microsoft.com/v1.0', params: { clientId, clientSecret, tenantId
|
|
17
|
-
if (!clientId || !clientSecret || !tenantId
|
|
16
|
+
var { endpoint: uri = 'https://graph.microsoft.com/v1.0', params: { clientId, clientSecret, tenantId } } = connection;
|
|
17
|
+
if (!clientId || !clientSecret || !tenantId) {
|
|
18
18
|
throw new Error('Connection parameters should not be undefined');
|
|
19
19
|
}
|
|
20
20
|
const credential = new azure.ClientSecretCredential(tenantId, clientId, clientSecret);
|
|
@@ -39,22 +39,20 @@ class MsGraphConnector {
|
|
|
39
39
|
{
|
|
40
40
|
type: 'string',
|
|
41
41
|
name: 'clientId',
|
|
42
|
-
label: 'client-id'
|
|
42
|
+
label: 'client-id',
|
|
43
|
+
useDomainAttribute: true
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
46
|
type: 'string',
|
|
46
47
|
name: 'clientSecret',
|
|
47
|
-
label: 'client-secret'
|
|
48
|
+
label: 'client-secret',
|
|
49
|
+
useDomainAttribute: true
|
|
48
50
|
},
|
|
49
51
|
{
|
|
50
52
|
type: 'string',
|
|
51
53
|
name: 'tenantId',
|
|
52
|
-
label: 'tenant-id'
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
type: 'string',
|
|
56
|
-
name: 'authTenantId',
|
|
57
|
-
label: 'auth-tenant-id'
|
|
54
|
+
label: 'tenant-id',
|
|
55
|
+
useDomainAttribute: true
|
|
58
56
|
}
|
|
59
57
|
];
|
|
60
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msgraph-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/msgraph-connector.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,gCAA6B;AAE7B,uEAA+E;AAE/E,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AACxC,MAAM,KAAK,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAA;AAC1D,MAAM,aAAa,GAAG,OAAO,CAAC,uEAAuE,CAAC,CAAA;AAEtG,MAAa,gBAAgB;IAC3B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAEjE,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAA;IAC1E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAU;QACtB,IAAI,EACF,QAAQ,EAAE,GAAG,GAAG,kCAAkC,EAClD,MAAM,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"msgraph-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/msgraph-connector.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,gCAA6B;AAE7B,uEAA+E;AAE/E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AAC,QAAQ,gBAAgB,CACvF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAU;QACzB,MAAM,MAAM,GAAG,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QAClE,wCAAwC;QACxC,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACnG,CAAC;IAED,IAAI,aAAa;QACf,2FAA2F;QAC3F,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;gBAClB,kBAAkB,EAAE,IAAI;aACzB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,eAAe;gBACtB,kBAAkB,EAAE,IAAI;aACzB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;gBAClB,kBAAkB,EAAE,IAAI;aACzB;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,qBAAqB,CAAA;IAC9B,CAAC;CACF;AAxED,4CAwEC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAA","sourcesContent":["/* fetch polyfil */\nimport 'cross-fetch/polyfill'\n\nimport { ConnectionManager, Connector } from '@things-factory/integration-base'\n\nconst azure = require('@azure/identity')\nconst graph = require('@microsoft/microsoft-graph-client')\nconst authProviders = require('@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials')\n\nexport class MsGraphConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('msgraph-connector connections are ready')\n }\n\n async connect(connection) {\n var {\n endpoint: uri = 'https://graph.microsoft.com/v1.0',\n params: { clientId, clientSecret, tenantId }\n } = connection\n\n if (!clientId || !clientSecret || !tenantId) {\n throw new Error('Connection parameters should not be undefined')\n }\n\n const credential = new azure.ClientSecretCredential(tenantId, clientId, clientSecret)\n const authProvider = new authProviders.TokenCredentialAuthenticationProvider(credential, {\n scopes: ['https://graph.microsoft.com/.default']\n })\n\n const client = graph.Client.initWithMiddleware({\n authProvider: authProvider\n })\n\n ConnectionManager.addConnectionInstance(connection, client)\n\n ConnectionManager.logger.info(\n `msgraph-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n }\n\n async disconnect(connection) {\n const client = ConnectionManager.getConnectionInstance(connection)\n // TODO implement how to stop connection\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`msgraph-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n /* To get proper settings, refer https://developer.microsoft.com/en-us/graph/quick-start */\n return [\n {\n type: 'string',\n name: 'clientId',\n label: 'client-id',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'clientSecret',\n label: 'client-secret',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'tenantId',\n label: 'tenant-id',\n useDomainAttribute: true\n }\n ]\n }\n\n get taskPrefixes() {\n return ['msgraph']\n }\n\n get description() {\n return 'Graph API Connector'\n }\n}\n\nConnectionManager.registerConnector('msgraph-connector', new MsGraphConnector())\n"]}
|
|
@@ -6,7 +6,7 @@ async function MsGraphGet(step, context) {
|
|
|
6
6
|
var { connection: connectionName, params: stepOptions } = step;
|
|
7
7
|
var { path, select, filter, skip = 0, top = 30, orderby } = stepOptions || {};
|
|
8
8
|
var { domain, data, variables } = context;
|
|
9
|
-
var client = integration_base_2.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
9
|
+
var client = await integration_base_2.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
10
10
|
select ||= '';
|
|
11
11
|
orderby ||= '';
|
|
12
12
|
filter ||= '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msgraph-get.js","sourceRoot":"","sources":["../../../server/engine/task/msgraph-get.ts"],"names":[],"mappings":";;AAAA,uEAA+D;AAC/D,uEAAoE;AAEpE,KAAK,UAAU,UAAU,CAAC,IAAI,EAAE,OAAO;IACrC,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9D,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,WAAW,IAAI,EAAE,CAAA;IAC7E,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAEzC,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"msgraph-get.js","sourceRoot":"","sources":["../../../server/engine/task/msgraph-get.ts"],"names":[],"mappings":";;AAAA,uEAA+D;AAC/D,uEAAoE;AAEpE,KAAK,UAAU,UAAU,CAAC,IAAI,EAAE,OAAO;IACrC,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9D,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,WAAW,IAAI,EAAE,CAAA;IAC7E,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAEzC,IAAI,MAAM,GAAG,MAAM,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAExF,MAAM,KAAK,EAAE,CAAA;IACb,OAAO,KA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,EAAE,SAAS;KACjB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,QAAQ;KAChB;CACF,CAAA;AACD,UAAU,CAAC,IAAI,GAAG,8BAA8B,CAAA;AAEhD,+BAAY,CAAC,mBAAmB,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '@things-factory/integration-base'\nimport { ConnectionManager } from '@things-factory/integration-base'\n\nasync function MsGraphGet(step, context) {\n var { connection: connectionName, params: stepOptions } = step\n var { path, select, filter, skip = 0, top = 30, orderby } = stepOptions || {}\n var { domain, data, variables } = context\n\n var client = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n select ||= ''\n orderby ||= ''\n filter ||= ''\n\n try {\n var result = client?.api(path)\n select && (result = result.select(select.split(',')))\n filter && (result = result.filter(filter))\n skip && (result = result.skip(skip))\n top && (result = result.top(top))\n orderby && (result = result.orderby(orderby))\n result = await result.get()\n\n return {\n data: result\n }\n } catch (err) {\n console.error(err)\n throw err\n }\n}\n\nMsGraphGet.parameterSpec = [\n {\n type: 'string',\n name: 'path',\n label: 'path'\n },\n {\n type: 'string',\n name: 'select',\n label: 'select'\n },\n {\n type: 'number',\n name: 'skip',\n label: 'skip'\n },\n {\n type: 'number',\n name: 'top',\n label: 'top'\n },\n {\n type: 'string',\n name: 'orderby',\n label: 'orderby'\n },\n {\n type: 'string',\n name: 'filter',\n label: 'filter'\n }\n]\nMsGraphGet.help = 'integration/task/msgraph-get'\n\nTaskRegistry.registerTaskHandler('msgraph-get', MsGraphGet)\n"]}
|
|
@@ -7,7 +7,7 @@ async function MsGraphPost(step, context) {
|
|
|
7
7
|
var { connection: connectionName, params: stepOptions } = step;
|
|
8
8
|
var { path, body } = stepOptions || {};
|
|
9
9
|
var { domain, data, variables } = context;
|
|
10
|
-
var client = integration_base_2.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
10
|
+
var client = await integration_base_2.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
11
11
|
body = (0, utils_1.access)(body, data);
|
|
12
12
|
const result = await client?.api(path).post(body);
|
|
13
13
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msgraph-post.js","sourceRoot":"","sources":["../../../server/engine/task/msgraph-post.ts"],"names":[],"mappings":";;AAAA,uEAA+D;AAC/D,uEAAoE;AACpE,iDAA8C;AAE9C,KAAK,UAAU,WAAW,CAAC,IAAI,EAAE,OAAO;IACtC,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,WAAW,IAAI,EAAE,CAAA;IACtC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAEzC,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"msgraph-post.js","sourceRoot":"","sources":["../../../server/engine/task/msgraph-post.ts"],"names":[],"mappings":";;AAAA,uEAA+D;AAC/D,uEAAoE;AACpE,iDAA8C;AAE9C,KAAK,UAAU,WAAW,CAAC,IAAI,EAAE,OAAO;IACtC,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,WAAW,IAAI,EAAE,CAAA;IACtC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAEzC,IAAI,MAAM,GAAG,MAAM,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACxF,IAAI,GAAG,IAAA,cAAM,EAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAEzB,MAAM,MAAM,GAAG,MAAM,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEjD,OAAO;QACL,IAAI,EAAE,MAAM;KACb,CAAA;AACH,CAAC;AAED,WAAW,CAAC,aAAa,GAAG;IAC1B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;KACd;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;KACd;CACF,CAAA;AACD,WAAW,CAAC,IAAI,GAAG,+BAA+B,CAAA;AAElD,+BAAY,CAAC,mBAAmB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '@things-factory/integration-base'\nimport { ConnectionManager } from '@things-factory/integration-base'\nimport { access } from '@things-factory/utils'\n\nasync function MsGraphPost(step, context) {\n var { connection: connectionName, params: stepOptions } = step\n var { path, body } = stepOptions || {}\n var { domain, data, variables } = context\n\n var client = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n body = access(body, data)\n\n const result = await client?.api(path).post(body)\n\n return {\n data: result\n }\n}\n\nMsGraphPost.parameterSpec = [\n {\n type: 'string',\n name: 'path',\n label: 'path'\n },\n {\n type: 'string',\n name: 'body',\n label: 'body'\n }\n]\nMsGraphPost.help = 'integration/task/msgraph-post'\n\nTaskRegistry.registerTaskHandler('msgraph-post', MsGraphPost)\n"]}
|