@mindful-web/marko-web-omeda-identity-x 1.69.2 → 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.69.2/components/identify.marko",
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.69.2/components/identify.marko",
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
+ };
@@ -1,4 +1,5 @@
1
1
  const { get, getAsArray } = require('@mindful-web/object-path');
2
+ const getEncryptedIdFromEmail = require('./get-encrypted-id-from-email');
2
3
 
3
4
  module.exports = async ({ req, payload }) => {
4
5
  const omeda = req.app.locals.site.getAsObject('omeda');
@@ -8,7 +9,9 @@ module.exports = async ({ req, payload }) => {
8
9
  && namespace.provider === 'omeda'
9
10
  && namespace.tenant === omeda.brandKey);
10
11
  if (found) return get(found, 'identifier.value');
11
- const rapidIdentity = await req.$idxOmedaRapidIdentify(payload);
12
- return (rapidIdentity && rapidIdentity.encryptedCustomerId)
13
- ? rapidIdentity.encryptedCustomerId : undefined;
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
+ });
14
17
  };
@@ -1,4 +1,5 @@
1
1
  const getAnsweredQuestionMap = require('./get-answered-question-map');
2
+ const getEncryptedIdFromEmail = require('./get-encrypted-id-from-email');
2
3
  const getEncryptedOmedaId = require('./get-encrypted-omeda-id');
3
4
  const getOmedaCustomerRecord = require('./get-omeda-customer-record');
4
5
  const getOmedaLinkedFields = require('./get-omeda-linked-fields');
@@ -11,6 +12,7 @@ const updateIdentityX = require('./update-identity-x');
11
12
 
12
13
  module.exports = {
13
14
  getAnsweredQuestionMap,
15
+ getEncryptedIdFromEmail,
14
16
  getEncryptedOmedaId,
15
17
  getOmedaCustomerRecord,
16
18
  getOmedaLinkedFields,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindful-web/marko-web-omeda-identity-x",
3
- "version": "1.69.2",
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": "fcbd5d1058d6f8b4bd6393316e4013da27ee349a"
32
+ "gitHead": "d0d959088f4282c94c3ccce18abcc1618db5fb90"
33
33
  }