@mindful-web/marko-web-omeda-identity-x 1.68.6 → 1.69.3
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-omeda-identity-x$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-omeda-identity-x$1.69.3/components/identify.marko",
|
|
6
6
|
marko_component = require("./identify.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_getCookieId = require("@mindful-web/marko-web-omeda-identity-x/utils/get-cookie-id"),
|
|
@@ -51,7 +51,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
51
51
|
}, marko_component);
|
|
52
52
|
|
|
53
53
|
marko_template.meta = {
|
|
54
|
-
id: "/@mindful-web/marko-web-omeda-identity-x$1.
|
|
54
|
+
id: "/@mindful-web/marko-web-omeda-identity-x$1.69.3/components/identify.marko",
|
|
55
55
|
component: "./identify.marko",
|
|
56
56
|
tags: [
|
|
57
57
|
"@mindful-web/marko-web-identity-x/components/identify.marko",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const { get } = require('@mindful-web/object-path');
|
|
2
|
+
const gql = require('graphql-tag');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the first encryped id found (if any) for the supplied email address
|
|
6
|
+
* @param {object} args
|
|
7
|
+
* @param {import("apollo-client").ApolloClient} args.client The Omeda GraphQL client instance
|
|
8
|
+
* @param {string} args.emailAddress The email address to look up
|
|
9
|
+
* @param {number} [args.productId] The Omeda productId to filter the results by
|
|
10
|
+
* @returns {Promise<string?>}
|
|
11
|
+
*/
|
|
12
|
+
module.exports = async ({ client, emailAddress }) => {
|
|
13
|
+
const query = gql`
|
|
14
|
+
query CustomersByEmailAddress($emailAddress: String!) {
|
|
15
|
+
customersByEmailAddress(input: {
|
|
16
|
+
emailAddress: $emailAddress
|
|
17
|
+
}) { encryptedCustomerId }
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const variables = { emailAddress };
|
|
21
|
+
const { data } = await client.query({ query, variables });
|
|
22
|
+
return get(data, 'customersByEmailAddress.0.encryptedCustomerId');
|
|
23
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { get, getAsArray } = require('@mindful-web/object-path');
|
|
2
|
+
const getEncryptedIdFromEmail = require('./get-encrypted-id-from-email');
|
|
3
|
+
|
|
4
|
+
module.exports = async ({ req, payload }) => {
|
|
5
|
+
const omeda = req.app.locals.site.getAsObject('omeda');
|
|
6
|
+
const { user } = payload;
|
|
7
|
+
const found = getAsArray(user, 'externalIds')
|
|
8
|
+
.find(({ identifier, namespace }) => identifier.type === 'encrypted'
|
|
9
|
+
&& namespace.provider === 'omeda'
|
|
10
|
+
&& namespace.tenant === omeda.brandKey);
|
|
11
|
+
if (found) return get(found, 'identifier.value');
|
|
12
|
+
// If no external user found attept to retrieve the user's encrypted customer id directly
|
|
13
|
+
return getEncryptedIdFromEmail({
|
|
14
|
+
client: req.$omedaGraphQLClient,
|
|
15
|
+
emailAddress: payload.user.email,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const { getAsArray } = require('@mindful-web/object-path');
|
|
2
|
+
const getOmedaCustomerRecord = require('./get-omeda-customer-record');
|
|
3
|
+
const getEncryptedOmedaId = require('./get-encrypted-omeda-id');
|
|
4
|
+
|
|
5
|
+
module.exports = async ({ req, payload }) => {
|
|
6
|
+
const userDemoIds = new Set();
|
|
7
|
+
const userDeploymentIds = new Set();
|
|
8
|
+
const userProductIds = new Set();
|
|
9
|
+
|
|
10
|
+
const encryptedCustomerId = await getEncryptedOmedaId({ req, payload });
|
|
11
|
+
const omedaCustomer = encryptedCustomerId ? await getOmedaCustomerRecord({
|
|
12
|
+
omedaGraphQLClient: req.$omedaGraphQLClient,
|
|
13
|
+
encryptedCustomerId,
|
|
14
|
+
}) : {};
|
|
15
|
+
|
|
16
|
+
getAsArray(omedaCustomer, 'subscriptions')
|
|
17
|
+
.forEach(({ product }) => userProductIds.add(product.id));
|
|
18
|
+
getAsArray(omedaCustomer, 'demographics')
|
|
19
|
+
.forEach(({ demographic }) => userDemoIds.add(demographic.id));
|
|
20
|
+
getAsArray(omedaCustomer, 'primaryEmailAddress.optInStatus')
|
|
21
|
+
.forEach(({ deploymentTypeId }) => userDeploymentIds.add(deploymentTypeId));
|
|
22
|
+
|
|
23
|
+
return { userDemoIds, userDeploymentIds, userProductIds };
|
|
24
|
+
};
|
package/omeda-data/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const getAnsweredQuestionMap = require('./get-answered-question-map');
|
|
2
|
+
const getEncryptedIdFromEmail = require('./get-encrypted-id-from-email');
|
|
3
|
+
const getEncryptedOmedaId = require('./get-encrypted-omeda-id');
|
|
2
4
|
const getOmedaCustomerRecord = require('./get-omeda-customer-record');
|
|
3
5
|
const getOmedaLinkedFields = require('./get-omeda-linked-fields');
|
|
6
|
+
const getOmedaSubscriptionIds = require('./get-omeda-subscription-ids');
|
|
4
7
|
const setOmedaData = require('./set-omeda-data');
|
|
5
8
|
const setOmedaDemographics = require('./set-omeda-demographics');
|
|
6
9
|
const setOmedaDeploymentTypes = require('./set-omeda-deployment-types');
|
|
@@ -9,8 +12,11 @@ const updateIdentityX = require('./update-identity-x');
|
|
|
9
12
|
|
|
10
13
|
module.exports = {
|
|
11
14
|
getAnsweredQuestionMap,
|
|
15
|
+
getEncryptedIdFromEmail,
|
|
16
|
+
getEncryptedOmedaId,
|
|
12
17
|
getOmedaCustomerRecord,
|
|
13
18
|
getOmedaLinkedFields,
|
|
19
|
+
getOmedaSubscriptionIds,
|
|
14
20
|
setOmedaData,
|
|
15
21
|
setOmedaDemographics,
|
|
16
22
|
setOmedaDeploymentTypes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindful-web/marko-web-omeda-identity-x",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.69.3",
|
|
4
4
|
"description": "Marko Omeda+IdentityX integration tools",
|
|
5
5
|
"repository": "https://github.com/parameter1/mindful-web/tree/main/packages/marko-web-omeda-identity-x",
|
|
6
6
|
"author": "Josh Worden <josh@parameter1.com>",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "d0d959088f4282c94c3ccce18abcc1618db5fb90"
|
|
33
33
|
}
|