@memberjunction/communication-ms-graph 2.5.1
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/MSGraphProvider.d.ts +10 -0
- package/dist/MSGraphProvider.d.ts.map +1 -0
- package/dist/MSGraphProvider.js +72 -0
- package/dist/MSGraphProvider.js.map +1 -0
- package/dist/auth.d.ts +25 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +98 -0
- package/dist/auth.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +28 -0
- package/dist/config.js.map +1 -0
- package/dist/fetch.d.ts +7 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +41 -0
- package/dist/fetch.js.map +1 -0
- package/dist/generic/models.d.ts +5 -0
- package/dist/generic/models.d.ts.map +1 -0
- package/dist/generic/models.js +3 -0
- package/dist/generic/models.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
- package/readme.md +5 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseCommunicationProvider, MessageResult, ProcessedMessage } from "@memberjunction/communication-types";
|
|
2
|
+
/**
|
|
3
|
+
* Implementation of the SendGrid provider for sending and receiving messages
|
|
4
|
+
*/
|
|
5
|
+
export declare class MSGraphProvider extends BaseCommunicationProvider {
|
|
6
|
+
constructor();
|
|
7
|
+
SendSingleMessage(message: ProcessedMessage): Promise<MessageResult>;
|
|
8
|
+
}
|
|
9
|
+
export declare function LoadMSGraphProvider(): void;
|
|
10
|
+
//# sourceMappingURL=MSGraphProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MSGraphProvider.d.ts","sourceRoot":"","sources":["../src/MSGraphProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAKjH;;GAEG;AACH,qBACa,eAAgB,SAAQ,yBAAyB;;IAM7C,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;CA6CpF;AAED,wBAAgB,mBAAmB,SAElC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LoadMSGraphProvider = exports.MSGraphProvider = void 0;
|
|
10
|
+
const communication_types_1 = require("@memberjunction/communication-types");
|
|
11
|
+
const global_1 = require("@memberjunction/global");
|
|
12
|
+
const core_1 = require("@memberjunction/core");
|
|
13
|
+
const auth_1 = require("./auth");
|
|
14
|
+
/**
|
|
15
|
+
* Implementation of the SendGrid provider for sending and receiving messages
|
|
16
|
+
*/
|
|
17
|
+
let MSGraphProvider = class MSGraphProvider extends communication_types_1.BaseCommunicationProvider {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
}
|
|
21
|
+
async SendSingleMessage(message) {
|
|
22
|
+
try {
|
|
23
|
+
if (!message) {
|
|
24
|
+
return {
|
|
25
|
+
Message: message,
|
|
26
|
+
Success: false,
|
|
27
|
+
Error: 'Error: message is null'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const sendMail = {
|
|
31
|
+
message: {
|
|
32
|
+
subject: message.Subject,
|
|
33
|
+
body: {
|
|
34
|
+
contentType: message.ProcessedHTMLBody ? 'HTML' : 'Text',
|
|
35
|
+
content: message.ProcessedHTMLBody || message.ProcessedBody
|
|
36
|
+
},
|
|
37
|
+
toRecipients: [
|
|
38
|
+
{
|
|
39
|
+
emailAddress: {
|
|
40
|
+
address: message.To
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
saveToSentItems: 'false'
|
|
46
|
+
};
|
|
47
|
+
await auth_1.GraphClient.api('/me/sendMail').post(sendMail);
|
|
48
|
+
return {
|
|
49
|
+
Message: message,
|
|
50
|
+
Success: true,
|
|
51
|
+
Error: ''
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (ex) {
|
|
55
|
+
(0, core_1.LogError)(ex);
|
|
56
|
+
return {
|
|
57
|
+
Message: message,
|
|
58
|
+
Success: false,
|
|
59
|
+
Error: ex.message
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.MSGraphProvider = MSGraphProvider;
|
|
65
|
+
exports.MSGraphProvider = MSGraphProvider = __decorate([
|
|
66
|
+
(0, global_1.RegisterClass)(communication_types_1.BaseCommunicationProvider, 'SendGrid')
|
|
67
|
+
], MSGraphProvider);
|
|
68
|
+
function LoadMSGraphProvider() {
|
|
69
|
+
// do nothing, this prevents tree shaking from removing this class
|
|
70
|
+
}
|
|
71
|
+
exports.LoadMSGraphProvider = LoadMSGraphProvider;
|
|
72
|
+
//# sourceMappingURL=MSGraphProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MSGraphProvider.js","sourceRoot":"","sources":["../src/MSGraphProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6EAAiH;AACjH,mDAAuD;AACvD,+CAAgD;AAChD,iCAAqC;AAErC;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eA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DAEC"}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import msal from '@azure/msal-node';
|
|
2
|
+
import { Client } from '@microsoft/microsoft-graph-client';
|
|
3
|
+
export declare const GraphClient: Client;
|
|
4
|
+
/**
|
|
5
|
+
* With client credentials flows permissions need to be granted in the portal by a tenant administrator.
|
|
6
|
+
* The scope is always in the format '<resource>/.default'. For more, visit:
|
|
7
|
+
* https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow
|
|
8
|
+
*/
|
|
9
|
+
export declare const TokenRequest: {
|
|
10
|
+
scopes: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare const ApiConfig: {
|
|
13
|
+
uri: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Acquires token with client credentials.
|
|
17
|
+
* @param {object} tokenRequest
|
|
18
|
+
*/
|
|
19
|
+
export declare function GetToken(tokenRequest: msal.ClientCredentialRequest): Promise<msal.AuthenticationResult | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Calls the endpoint with authorization bearer token.
|
|
22
|
+
* @param {string} endpoint
|
|
23
|
+
*/
|
|
24
|
+
export declare function CallGraphApi<T>(endpoint: string): Promise<T | null>;
|
|
25
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAqC3D,eAAO,MAAM,WAAW,EAAE,MAAkE,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,eAAO,MAAM,SAAS;;CAErB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAGpH;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CASzE"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CallGraphApi = exports.GetToken = exports.ApiConfig = exports.TokenRequest = exports.GraphClient = void 0;
|
|
30
|
+
const identity_1 = require("@azure/identity");
|
|
31
|
+
const Config = __importStar(require("./config"));
|
|
32
|
+
const msal_node_1 = __importDefault(require("@azure/msal-node"));
|
|
33
|
+
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
34
|
+
const azureTokenCredentials_1 = require("@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials");
|
|
35
|
+
/**
|
|
36
|
+
* Configuration object to be passed to MSAL instance on creation.
|
|
37
|
+
* For a full list of MSAL Node configuration parameters, visit:
|
|
38
|
+
* https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/configuration.md
|
|
39
|
+
*/
|
|
40
|
+
const msalConfig = {
|
|
41
|
+
auth: {
|
|
42
|
+
clientId: Config.AZURE_CLIENT_ID,
|
|
43
|
+
authority: Config.AZURE_AAD_ENDPOINT + '/' + Config.AZURE_TENANT_ID,
|
|
44
|
+
clientSecret: Config.AZURE_CLIENT_SECRET,
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Initialize a confidential client application. For more info, visit:
|
|
49
|
+
* https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/initialize-confidential-client-application.md
|
|
50
|
+
*/
|
|
51
|
+
const cca = new msal_node_1.default.ConfidentialClientApplication(msalConfig);
|
|
52
|
+
const credential = new identity_1.ClientSecretCredential(Config.AZURE_TENANT_ID, Config.AZURE_CLIENT_ID, Config.AZURE_CLIENT_SECRET);
|
|
53
|
+
// @microsoft/microsoft-graph-client/authProviders/azureTokenCredentials
|
|
54
|
+
const authProvider = new azureTokenCredentials_1.TokenCredentialAuthenticationProvider(credential, {
|
|
55
|
+
// The client credentials flow requires that you request the
|
|
56
|
+
// /.default scope, and pre-configure your permissions on the
|
|
57
|
+
// app registration in Azure. An administrator must grant consent
|
|
58
|
+
// to those permissions beforehand.
|
|
59
|
+
scopes: ['https://graph.microsoft.com/.default'],
|
|
60
|
+
});
|
|
61
|
+
exports.GraphClient = microsoft_graph_client_1.Client.initWithMiddleware({ authProvider: authProvider });
|
|
62
|
+
/**
|
|
63
|
+
* With client credentials flows permissions need to be granted in the portal by a tenant administrator.
|
|
64
|
+
* The scope is always in the format '<resource>/.default'. For more, visit:
|
|
65
|
+
* https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow
|
|
66
|
+
*/
|
|
67
|
+
exports.TokenRequest = {
|
|
68
|
+
scopes: [Config.AZURE_GRAPH_ENDPOINT + '/.default'],
|
|
69
|
+
};
|
|
70
|
+
exports.ApiConfig = {
|
|
71
|
+
uri: Config.AZURE_GRAPH_ENDPOINT + '/v1.0/users',
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Acquires token with client credentials.
|
|
75
|
+
* @param {object} tokenRequest
|
|
76
|
+
*/
|
|
77
|
+
async function GetToken(tokenRequest) {
|
|
78
|
+
const authResult = await cca.acquireTokenByClientCredential(tokenRequest);
|
|
79
|
+
return authResult;
|
|
80
|
+
}
|
|
81
|
+
exports.GetToken = GetToken;
|
|
82
|
+
/**
|
|
83
|
+
* Calls the endpoint with authorization bearer token.
|
|
84
|
+
* @param {string} endpoint
|
|
85
|
+
*/
|
|
86
|
+
async function CallGraphApi(endpoint) {
|
|
87
|
+
try {
|
|
88
|
+
const response = await exports.GraphClient.api(endpoint).get();
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.log(`Error calling api: ${error}`);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.CallGraphApi = CallGraphApi;
|
|
97
|
+
;
|
|
98
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAyD;AACz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ACD,MAAM,QAAQ,GAAM,MAAM,mBAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AATD,oCASC;AAAA,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const dbHost: string;
|
|
2
|
+
export declare const dbPort: number;
|
|
3
|
+
export declare const dbUsername: string;
|
|
4
|
+
export declare const dbPassword: string;
|
|
5
|
+
export declare const dbDatabase: string;
|
|
6
|
+
export declare const dbInstanceName: string | undefined;
|
|
7
|
+
export declare const dbTrustServerCertificate: boolean | undefined;
|
|
8
|
+
export declare const outputCode: string | undefined;
|
|
9
|
+
export declare const configFile: string;
|
|
10
|
+
export declare const mjCoreSchema: string;
|
|
11
|
+
export declare const graphqlPort: number;
|
|
12
|
+
export declare const AZURE_CLIENT_ID: string;
|
|
13
|
+
export declare const AZURE_AAD_ENDPOINT: string;
|
|
14
|
+
export declare const AZURE_TENANT_ID: string;
|
|
15
|
+
export declare const AZURE_CLIENT_SECRET: string;
|
|
16
|
+
export declare const AZURE_GRAPH_ENDPOINT: string;
|
|
17
|
+
export declare const AZURE_ACCOUNT_EMAIL: string;
|
|
18
|
+
export declare const AZURE_ACCOUNT_ID: string;
|
|
19
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,EAAE,MAAiD,CAAC;AACvE,eAAO,MAAM,MAAM,EAAE,MAA0D,CAAC;AAChF,eAAO,MAAM,UAAU,EAAE,MAAqD,CAAC;AAC/E,eAAO,MAAM,UAAU,EAAE,MAAqD,CAAC;AAC/E,eAAO,MAAM,UAAU,EAAE,MAAqD,CAAC;AAC/E,eAAO,MAAM,cAAc,EAAE,MAAM,GAAG,SAAkD,CAAC;AACzF,eAAO,MAAM,wBAAwB,EAAE,OAAO,GAAG,SAA2D,CAAC;AAC7G,eAAO,MAAM,UAAU,EAAE,MAAM,GAAG,SAA6C,CAAC;AAChF,eAAO,MAAM,UAAU,QAAoC,CAAC;AAC5D,eAAO,MAAM,YAAY,QAAuD,CAAC;AACjF,eAAO,MAAM,WAAW,QAAyD,CAAC;AAGlF,eAAO,MAAM,eAAe,EAAE,MAAyD,CAAC;AACxF,eAAO,MAAM,kBAAkB,EAAE,MAA4D,CAAC;AAC9F,eAAO,MAAM,eAAe,EAAE,MAAyD,CAAC;AACxF,eAAO,MAAM,mBAAmB,EAAE,MAA6D,CAAC;AAChG,eAAO,MAAM,oBAAoB,EAAE,MAA8D,CAAC;AAClG,eAAO,MAAM,mBAAmB,EAAE,MAA6D,CAAC;AAChG,eAAO,MAAM,gBAAgB,EAAE,MAA2D,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AZURE_ACCOUNT_ID = exports.AZURE_ACCOUNT_EMAIL = exports.AZURE_GRAPH_ENDPOINT = exports.AZURE_CLIENT_SECRET = exports.AZURE_TENANT_ID = exports.AZURE_AAD_ENDPOINT = exports.AZURE_CLIENT_ID = exports.graphqlPort = exports.mjCoreSchema = exports.configFile = exports.outputCode = exports.dbTrustServerCertificate = exports.dbInstanceName = exports.dbDatabase = exports.dbPassword = exports.dbUsername = exports.dbPort = exports.dbHost = void 0;
|
|
7
|
+
const env_var_1 = __importDefault(require("env-var"));
|
|
8
|
+
//MJ Related
|
|
9
|
+
exports.dbHost = env_var_1.default.get('DB_HOST').required().asString();
|
|
10
|
+
exports.dbPort = env_var_1.default.get('DB_PORT').default('1433').asPortNumber();
|
|
11
|
+
exports.dbUsername = env_var_1.default.get('DB_USERNAME').required().asString();
|
|
12
|
+
exports.dbPassword = env_var_1.default.get('DB_PASSWORD').required().asString();
|
|
13
|
+
exports.dbDatabase = env_var_1.default.get('DB_DATABASE').required().asString();
|
|
14
|
+
exports.dbInstanceName = env_var_1.default.get('DB_INSTANCE_NAME').asString();
|
|
15
|
+
exports.dbTrustServerCertificate = env_var_1.default.get('DB_TRUST_SERVER_CERTIFICATE').asBool();
|
|
16
|
+
exports.outputCode = env_var_1.default.get('OUTPUT_CODE').asString();
|
|
17
|
+
exports.configFile = env_var_1.default.get('CONFIG_FILE').asString();
|
|
18
|
+
exports.mjCoreSchema = env_var_1.default.get('MJ_CORE_SCHEMA').default('__mj').asString();
|
|
19
|
+
exports.graphqlPort = env_var_1.default.get('GRAPHQL_PORT').default('4000').asPortNumber();
|
|
20
|
+
//Azure Related
|
|
21
|
+
exports.AZURE_CLIENT_ID = env_var_1.default.get('AZURE_CLIENT_ID').required().asString();
|
|
22
|
+
exports.AZURE_AAD_ENDPOINT = env_var_1.default.get('AZURE_AAD_ENDPOINT').required().asString();
|
|
23
|
+
exports.AZURE_TENANT_ID = env_var_1.default.get('AZURE_TENANT_ID').required().asString();
|
|
24
|
+
exports.AZURE_CLIENT_SECRET = env_var_1.default.get('AZURE_CLIENT_SECRET').required().asString();
|
|
25
|
+
exports.AZURE_GRAPH_ENDPOINT = env_var_1.default.get('AZURE_GRAPH_ENDPOINT').required().asString();
|
|
26
|
+
exports.AZURE_ACCOUNT_EMAIL = env_var_1.default.get('AZURE_ACCOUNT_EMAIL').required().asString();
|
|
27
|
+
exports.AZURE_ACCOUNT_ID = env_var_1.default.get('AZURE_ACCOUNT_ID').default("").asString();
|
|
28
|
+
//# sourceMappingURL=config.js.map
|
|
@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C,YAAY,EAAE,CAAC;AAElF,eAAe;AACF,QAAA,eAAe,GAAW,iBAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC3E,QAAA,kBAAkB,GAAW,iBAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACjF,QAAA,eAAe,GAAW,iBAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC3E,QAAA,mBAAmB,GAAW,iBAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACnF,QAAA,oBAAoB,GAAW,iBAAG,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACrF,QAAA,mBAAmB,GAAW,iBAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACnF,QAAA,gBAAgB,GAAW,iBAAG,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC"}
|
package/dist/fetch.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CA4BzF"}
|
package/dist/fetch.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CallApi = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
/**
|
|
9
|
+
* Calls the endpoint with authorization bearer token.
|
|
10
|
+
* @param {string} endpoint
|
|
11
|
+
* @param {string} accessToken
|
|
12
|
+
*/
|
|
13
|
+
async function CallApi(endpoint, accessToken) {
|
|
14
|
+
const options = {
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${accessToken}`
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
const response = await axios_1.default.get(endpoint, options);
|
|
21
|
+
return response.data;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
25
|
+
const axiosError = error;
|
|
26
|
+
if (axiosError.response) {
|
|
27
|
+
console.log(`Error calling api: ${axiosError.response.status} - ${axiosError.response.statusText}`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
console.log(`Error calling api: ${axiosError.message}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log(`Error calling api`);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.CallApi = CallApi;
|
|
40
|
+
;
|
|
41
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0C;AAE1C;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAI,QAAgB,EAAE,WAAmB;IAElE,MAAM,OAAO,GAAG;QACZ,OAAO,EAAE;YACL,aAAa,EAAE,UAAU,WAAW,EAAE;SACzC;KACJ,CAAC;IAEF,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAI,QAAQ,EAAE,OAAO,CAAC,CAAC;QACvD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,EAAE,CAAC;QACX,IAAG,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAC,CAAC;YAC1B,MAAM,UAAU,GAAG,KAAmB,CAAC;YACvC,IAAG,UAAU,CAAC,QAAQ,EAAC,CAAC;gBACpB,OAAO,CAAC,GAAG,CAAC,sBAAsB,UAAU,CAAC,QAAQ,CAAC,MAAM,MAAM,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;YACxG,CAAC;iBACG,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,sBAAsB,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5D,CAAC;QACL,CAAC;aACG,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AA5BD,0BA4BC;AAAA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/generic/models.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,CAAC,CAAA;CACX,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/generic/models.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./MSGraphProvider"), exports);
|
|
18
|
+
__exportStar(require("./auth"), exports);
|
|
19
|
+
__exportStar(require("./generic/models"), exports);
|
|
20
|
+
__exportStar(require("./fetch"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yCAAuB;AACvB,mDAAiC;AACjC,0CAAwB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memberjunction/communication-ms-graph",
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"description": "MemberJunction: Microsoft Graph Provider for the MJ Communication Framework",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "ts-node-dev src/index.ts",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"author": "MemberJunction.com",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"ts-node-dev": "^2.0.0",
|
|
19
|
+
"typescript": "^5.4.5",
|
|
20
|
+
"@types/html-to-text": "^9.0.4",
|
|
21
|
+
"@microsoft/microsoft-graph-types": "^2.40.0"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@azure/identity": "^4.4.1",
|
|
25
|
+
"@azure/msal-node": "^2.13.1",
|
|
26
|
+
"@memberjunction/communication-types": "2.5.1",
|
|
27
|
+
"@memberjunction/ai": "2.5.1",
|
|
28
|
+
"@memberjunction/ai-openai": "2.5.1",
|
|
29
|
+
"@memberjunction/aiengine": "2.5.1",
|
|
30
|
+
"@memberjunction/core": "2.5.1",
|
|
31
|
+
"@memberjunction/core-entities": "2.5.1",
|
|
32
|
+
"@memberjunction/global": "2.5.1",
|
|
33
|
+
"@memberjunction/sqlserver-dataprovider": "2.5.1",
|
|
34
|
+
"@microsoft/microsoft-graph-client": "^3.0.7",
|
|
35
|
+
"html-to-text": "^9.0.5",
|
|
36
|
+
"axios": "^1.7.7",
|
|
37
|
+
"dotenv": "^16.4.5",
|
|
38
|
+
"env-var": "^7.5.0"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# @memberjunction/communication-core
|
|
2
|
+
|
|
3
|
+
The `@memberjunction/communication-core` library provides the fundamental objects that are used for the MemberJunction Communications framework. Other packages within the @memberjunction/communication-* world use this package as a foundation.
|
|
4
|
+
|
|
5
|
+
|