@aws-amplify/core 6.1.1-unstable.7ddca1b.0 → 6.1.1-unstable.82e1bd3.0

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.
Files changed (26) hide show
  1. package/dist/cjs/Platform/version.js +1 -1
  2. package/dist/cjs/Platform/version.js.map +1 -1
  3. package/dist/cjs/providers/pinpoint/apis/updateEndpoint.js +17 -5
  4. package/dist/cjs/providers/pinpoint/apis/updateEndpoint.js.map +1 -1
  5. package/dist/cjs/providers/pinpoint/utils/createEndpointId.js +33 -0
  6. package/dist/cjs/providers/pinpoint/utils/createEndpointId.js.map +1 -0
  7. package/dist/cjs/providers/pinpoint/utils/index.js +3 -1
  8. package/dist/cjs/providers/pinpoint/utils/index.js.map +1 -1
  9. package/dist/esm/Platform/version.d.ts +1 -1
  10. package/dist/esm/Platform/version.mjs +1 -1
  11. package/dist/esm/Platform/version.mjs.map +1 -1
  12. package/dist/esm/providers/pinpoint/apis/updateEndpoint.mjs +17 -5
  13. package/dist/esm/providers/pinpoint/apis/updateEndpoint.mjs.map +1 -1
  14. package/dist/esm/providers/pinpoint/index.mjs +1 -0
  15. package/dist/esm/providers/pinpoint/index.mjs.map +1 -1
  16. package/dist/esm/providers/pinpoint/utils/createEndpointId.d.ts +13 -0
  17. package/dist/esm/providers/pinpoint/utils/createEndpointId.mjs +30 -0
  18. package/dist/esm/providers/pinpoint/utils/createEndpointId.mjs.map +1 -0
  19. package/dist/esm/providers/pinpoint/utils/index.d.ts +1 -0
  20. package/dist/esm/providers/pinpoint/utils/index.mjs +1 -0
  21. package/dist/esm/providers/pinpoint/utils/index.mjs.map +1 -1
  22. package/package.json +3 -3
  23. package/src/Platform/version.ts +1 -1
  24. package/src/providers/pinpoint/apis/updateEndpoint.ts +19 -5
  25. package/src/providers/pinpoint/utils/createEndpointId.ts +39 -0
  26. package/src/providers/pinpoint/utils/index.ts +1 -0
@@ -3,5 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.version = void 0;
5
5
  // generated by genversion
6
- exports.version = '6.2.1-unstable.7ddca1b.0+7ddca1b';
6
+ exports.version = '6.2.1-unstable.82e1bd3.0+82e1bd3';
7
7
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.2.1-unstable.7ddca1b.0+7ddca1b';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,kCAAkC;;"}
1
+ {"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.2.1-unstable.82e1bd3.0+82e1bd3';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,kCAAkC;;"}
@@ -8,6 +8,7 @@ const amplifyUuid_1 = require("../../../utils/amplifyUuid");
8
8
  const getClientInfo_1 = require("../../../utils/getClientInfo");
9
9
  const pinpoint_1 = require("../../../awsClients/pinpoint");
10
10
  const cacheEndpointId_1 = require("../utils/cacheEndpointId");
11
+ const createEndpointId_1 = require("../utils/createEndpointId");
11
12
  const getEndpointId_1 = require("../utils/getEndpointId");
12
13
  /**
13
14
  * @internal
@@ -15,7 +16,9 @@ const getEndpointId_1 = require("../utils/getEndpointId");
15
16
  const updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {
16
17
  const endpointId = await (0, getEndpointId_1.getEndpointId)(appId, category);
17
18
  // only generate a new endpoint id if one was not found in cache
18
- const createdEndpointId = !endpointId ? (0, amplifyUuid_1.amplifyUuid)() : undefined;
19
+ const createdEndpointId = !endpointId
20
+ ? (0, createEndpointId_1.createEndpointId)(appId, category)
21
+ : undefined;
19
22
  const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};
20
23
  const clientInfo = (0, getClientInfo_1.getClientInfo)();
21
24
  const mergedDemographic = {
@@ -68,10 +71,19 @@ const updateEndpoint = async ({ address, appId, category, channelType, credentia
68
71
  },
69
72
  },
70
73
  };
71
- await (0, pinpoint_1.updateEndpoint)({ credentials, region, userAgentValue }, input);
72
- // if we had to create an endpoint id, we need to now cache it
73
- if (createdEndpointId) {
74
- return (0, cacheEndpointId_1.cacheEndpointId)(appId, category, createdEndpointId);
74
+ try {
75
+ await (0, pinpoint_1.updateEndpoint)({ credentials, region, userAgentValue }, input);
76
+ // if we had to create an endpoint id, we need to now cache it
77
+ if (createdEndpointId) {
78
+ await (0, cacheEndpointId_1.cacheEndpointId)(appId, category, createdEndpointId);
79
+ }
80
+ }
81
+ finally {
82
+ // at this point, we completely reset the behavior so even if the update was unsuccessful
83
+ // we can just start over with a newly created endpoint id
84
+ if (createdEndpointId) {
85
+ (0, createEndpointId_1.clearCreatedEndpointId)(appId, category);
86
+ }
75
87
  }
76
88
  };
77
89
  exports.updateEndpoint = updateEndpoint;
@@ -1 +1 @@
1
- {"version":3,"file":"updateEndpoint.js","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.updateEndpoint = void 0;\nconst amplifyUuid_1 = require(\"../../../utils/amplifyUuid\");\nconst getClientInfo_1 = require(\"../../../utils/getClientInfo\");\nconst pinpoint_1 = require(\"../../../awsClients/pinpoint\");\nconst cacheEndpointId_1 = require(\"../utils/cacheEndpointId\");\nconst getEndpointId_1 = require(\"../utils/getEndpointId\");\n/**\n * @internal\n */\nconst updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {\n const endpointId = await (0, getEndpointId_1.getEndpointId)(appId, category);\n // only generate a new endpoint id if one was not found in cache\n const createdEndpointId = !endpointId ? (0, amplifyUuid_1.amplifyUuid)() : undefined;\n const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};\n const clientInfo = (0, getClientInfo_1.getClientInfo)();\n const mergedDemographic = {\n appVersion: clientInfo.appVersion,\n make: clientInfo.make,\n model: clientInfo.model,\n modelVersion: clientInfo.version,\n platform: clientInfo.platform,\n ...demographic,\n };\n const shouldAddAttributes = email || customProperties || name || plan;\n const attributes = {\n ...(email && { email: [email] }),\n ...(name && { name: [name] }),\n ...(plan && { plan: [plan] }),\n ...customProperties,\n };\n const input = {\n ApplicationId: appId,\n EndpointId: endpointId ?? createdEndpointId,\n EndpointRequest: {\n RequestId: (0, amplifyUuid_1.amplifyUuid)(),\n EffectiveDate: new Date().toISOString(),\n ChannelType: channelType,\n Address: address,\n Attributes: shouldAddAttributes ? attributes : undefined,\n Demographic: {\n AppVersion: mergedDemographic.appVersion,\n Locale: mergedDemographic.locale,\n Make: mergedDemographic.make,\n Model: mergedDemographic.model,\n ModelVersion: mergedDemographic.modelVersion,\n Platform: mergedDemographic.platform,\n PlatformVersion: mergedDemographic.platformVersion,\n Timezone: mergedDemographic.timezone,\n },\n Location: {\n City: location?.city,\n Country: location?.country,\n Latitude: location?.latitude,\n Longitude: location?.longitude,\n PostalCode: location?.postalCode,\n Region: location?.region,\n },\n Metrics: metrics,\n OptOut: optOut,\n User: {\n UserId: userId ?? identityId,\n UserAttributes: userAttributes,\n },\n },\n };\n await (0, pinpoint_1.updateEndpoint)({ credentials, region, userAgentValue }, input);\n // if we had to create an endpoint id, we need to now cache it\n if (createdEndpointId) {\n return (0, cacheEndpointId_1.cacheEndpointId)(appId, category, createdEndpointId);\n }\n};\nexports.updateEndpoint = updateEndpoint;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC,MAAM,aAAa,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC5D,MAAM,eAAe,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAChE,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC3D,MAAM,iBAAiB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC9D,MAAM,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC1D;AACA;AACA;AACA,MAAM,cAAc,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,GAAG,KAAK;AAC3K,IAAI,MAAM,UAAU,GAAG,MAAM,IAAI,eAAe,CAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACjF;AACA,IAAI,MAAM,iBAAiB,GAAG,CAAC,UAAU,GAAG,IAAI,aAAa,CAAC,WAAW,GAAG,GAAG,SAAS,CAAC;AACzF,IAAI,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,GAAG,WAAW,IAAI,EAAE,CAAC;AACvG,IAAI,MAAM,UAAU,GAAG,IAA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AC,IAAI;AAC5C,gBAAgB,KAAK,EAAE,iBAAiB,CAAC,KAAK;AAC9C,gBAAgB,YAAY,EAAE,iBAAiB,CAAC,YAAY;AAC5D,gBAAgB,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;AACpD,gBAAgB,eAAe,EAAE,iBAAiB,CAAC,eAAe;AAClE,gBAAgB,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;AACpD,aAAa;AACb,YAAY,QAAQ,EAAE;AACtB,gBAAgB,IAAI,EAAE,QAAQ,EAAE,IAAI;AACpC,gBAAgB,OAAO,EAAE,QAAQ,EAAE,OAAO;AAC1C,gBAAgB,QAAQ,EAAE,QAAQ,EAAE,QAAQ;AAC5C,gBAAgB,SAAS,EAAE,QAAQ,EAAE,SAAS;AAC9C,gBAAgB,UAAU,EAAE,QAAQ,EAAE,UAAU;AAChD,gBAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM;AACxC,aAAa;AACb,YAAY,OAAO,EAAE,OAAO;AAC5B,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,IAAI,EAAE;AAClB,gBAAgB,MAAM,EAAE,MAAM,IAAI,UAAU;AAC5C,gBAAgB,cAAc,EAAE,cAAc;AAC9C,aAAa;AACb,SAAS;AACT,KAAK,CAAC;AACN,IAAI,MAAM,IAAI,UAAU,CAAC,cAAc,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,KAAK,CAAC,CAAC;AACzF;AACA,IAAI,IAAI,iBAAiB,EAAE;AAC3B,QAAQ,OAAO,IAAI,iBAAiB,CAAC,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AAC1F,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,cAAc,GAAG,cAAc;;"}
1
+ {"version":3,"file":"updateEndpoint.js","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.updateEndpoint = void 0;\nconst amplifyUuid_1 = require(\"../../../utils/amplifyUuid\");\nconst getClientInfo_1 = require(\"../../../utils/getClientInfo\");\nconst pinpoint_1 = require(\"../../../awsClients/pinpoint\");\nconst cacheEndpointId_1 = require(\"../utils/cacheEndpointId\");\nconst createEndpointId_1 = require(\"../utils/createEndpointId\");\nconst getEndpointId_1 = require(\"../utils/getEndpointId\");\n/**\n * @internal\n */\nconst updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {\n const endpointId = await (0, getEndpointId_1.getEndpointId)(appId, category);\n // only generate a new endpoint id if one was not found in cache\n const createdEndpointId = !endpointId\n ? (0, createEndpointId_1.createEndpointId)(appId, category)\n : undefined;\n const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};\n const clientInfo = (0, getClientInfo_1.getClientInfo)();\n const mergedDemographic = {\n appVersion: clientInfo.appVersion,\n make: clientInfo.make,\n model: clientInfo.model,\n modelVersion: clientInfo.version,\n platform: clientInfo.platform,\n ...demographic,\n };\n const shouldAddAttributes = email || customProperties || name || plan;\n const attributes = {\n ...(email && { email: [email] }),\n ...(name && { name: [name] }),\n ...(plan && { plan: [plan] }),\n ...customProperties,\n };\n const input = {\n ApplicationId: appId,\n EndpointId: endpointId ?? createdEndpointId,\n EndpointRequest: {\n RequestId: (0, amplifyUuid_1.amplifyUuid)(),\n EffectiveDate: new Date().toISOString(),\n ChannelType: channelType,\n Address: address,\n Attributes: shouldAddAttributes ? attributes : undefined,\n Demographic: {\n AppVersion: mergedDemographic.appVersion,\n Locale: mergedDemographic.locale,\n Make: mergedDemographic.make,\n Model: mergedDemographic.model,\n ModelVersion: mergedDemographic.modelVersion,\n Platform: mergedDemographic.platform,\n PlatformVersion: mergedDemographic.platformVersion,\n Timezone: mergedDemographic.timezone,\n },\n Location: {\n City: location?.city,\n Country: location?.country,\n Latitude: location?.latitude,\n Longitude: location?.longitude,\n PostalCode: location?.postalCode,\n Region: location?.region,\n },\n Metrics: metrics,\n OptOut: optOut,\n User: {\n UserId: userId ?? identityId,\n UserAttributes: userAttributes,\n },\n },\n };\n try {\n await (0, pinpoint_1.updateEndpoint)({ credentials, region, userAgentValue }, input);\n // if we had to create an endpoint id, we need to now cache it\n if (createdEndpointId) {\n await (0, cacheEndpointId_1.cacheEndpointId)(appId, category, createdEndpointId);\n }\n }\n finally {\n // at this point, we completely reset the behavior so even if the update was unsuccessful\n // we can just start over with a newly created endpoint id\n if (createdEndpointId) {\n (0, createEndpointId_1.clearCreatedEndpointId)(appId, category);\n }\n }\n};\nexports.updateEndpoint = updateEndpoint;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC,MAAM,aAAa,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC5D,MAAM,eAAe,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAChE,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC3D,MAAM,iBAAiB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAChE,MAAM,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC1D;AACA;AACA;AACA,MAAM,cAAc,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,GAAG,KAAK;AAC3K,IAAI,MAAM,UAAU,GAAG,MAAM,IAAI,e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EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,KAAK,CAAC,CAAC;AAC7F;AACA,QAAQ,IAAI,iBAAiB,EAAE;AAC/B,YAAY,MAAM,CAAC,CAAC,EAAE,iBAAiB,CAAC,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AAC7F,SAAS;AACT,KAAK;AACL,YAAY;AACZ;AACA;AACA,QAAQ,IAAI,iBAAiB,EAAE;AAC/B,YAAY,IAAI,kBAAkB,CAAC,sBAAsB,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC5E,SAAS;AACT,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,cAAc,GAAG,cAAc;;"}
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.clearCreatedEndpointId = exports.createEndpointId = void 0;
7
+ const amplifyUuid_1 = require("../../../utils/amplifyUuid");
8
+ const getCacheKey_1 = require("./getCacheKey");
9
+ const createdEndpointIds = {};
10
+ /**
11
+ * Creates an endpoint id and guarantees multiple creations for a category returns the same uuid.
12
+ *
13
+ * @internal
14
+ */
15
+ const createEndpointId = (appId, category) => {
16
+ const cacheKey = (0, getCacheKey_1.getCacheKey)(appId, category);
17
+ if (!createdEndpointIds[cacheKey]) {
18
+ createdEndpointIds[cacheKey] = (0, amplifyUuid_1.amplifyUuid)();
19
+ }
20
+ return createdEndpointIds[cacheKey];
21
+ };
22
+ exports.createEndpointId = createEndpointId;
23
+ /**
24
+ * Clears a created endpoint id for a category.
25
+ *
26
+ * @internal
27
+ */
28
+ const clearCreatedEndpointId = (appId, category) => {
29
+ const cacheKey = (0, getCacheKey_1.getCacheKey)(appId, category);
30
+ delete createdEndpointIds[cacheKey];
31
+ };
32
+ exports.clearCreatedEndpointId = clearCreatedEndpointId;
33
+ //# sourceMappingURL=createEndpointId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createEndpointId.js","sources":["../../../../../src/providers/pinpoint/utils/createEndpointId.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.clearCreatedEndpointId = exports.createEndpointId = void 0;\nconst amplifyUuid_1 = require(\"../../../utils/amplifyUuid\");\nconst getCacheKey_1 = require(\"./getCacheKey\");\nconst createdEndpointIds = {};\n/**\n * Creates an endpoint id and guarantees multiple creations for a category returns the same uuid.\n *\n * @internal\n */\nconst createEndpointId = (appId, category) => {\n const cacheKey = (0, getCacheKey_1.getCacheKey)(appId, category);\n if (!createdEndpointIds[cacheKey]) {\n createdEndpointIds[cacheKey] = (0, amplifyUuid_1.amplifyUuid)();\n }\n return createdEndpointIds[cacheKey];\n};\nexports.createEndpointId = createEndpointId;\n/**\n * Clears a created endpoint id for a category.\n *\n * @internal\n */\nconst clearCreatedEndpointId = (appId, category) => {\n const cacheKey = (0, getCacheKey_1.getCacheKey)(appId, category);\n delete createdEndpointIds[cacheKey];\n};\nexports.clearCreatedEndpointId = clearCreatedEndpointId;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AACnE,MAAM,aAAa,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC5D,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC/C,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B;AACA;AACA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK;AAC9C,IAAI,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACrE,IAAI,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE;AACvC,QAAQ,kBAAkB,CAAC,QAAQ,CAAC,GAAG,IAAI,aAAa,CAAC,WAAW,GAAG,CAAC;AACxE,KAAK;AACL,IAAI,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC;AACF,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C;AACA;AACA;AACA;AACA;AACA,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK;AACpD,IAAI,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACrE,IAAI,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC;AACF,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
@@ -3,9 +3,11 @@
3
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveEndpointId = exports.getEndpointId = exports.getCacheKey = exports.cacheEndpointId = void 0;
6
+ exports.resolveEndpointId = exports.getEndpointId = exports.getCacheKey = exports.createEndpointId = exports.cacheEndpointId = void 0;
7
7
  var cacheEndpointId_1 = require("./cacheEndpointId");
8
8
  Object.defineProperty(exports, "cacheEndpointId", { enumerable: true, get: function () { return cacheEndpointId_1.cacheEndpointId; } });
9
+ var createEndpointId_1 = require("./createEndpointId");
10
+ Object.defineProperty(exports, "createEndpointId", { enumerable: true, get: function () { return createEndpointId_1.createEndpointId; } });
9
11
  var getCacheKey_1 = require("./getCacheKey");
10
12
  Object.defineProperty(exports, "getCacheKey", { enumerable: true, get: function () { return getCacheKey_1.getCacheKey; } });
11
13
  var getEndpointId_1 = require("./getEndpointId");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/providers/pinpoint/utils/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveEndpointId = exports.getEndpointId = exports.getCacheKey = exports.cacheEndpointId = void 0;\nvar cacheEndpointId_1 = require(\"./cacheEndpointId\");\nObject.defineProperty(exports, \"cacheEndpointId\", { enumerable: true, get: function () { return cacheEndpointId_1.cacheEndpointId; } });\nvar getCacheKey_1 = require(\"./getCacheKey\");\nObject.defineProperty(exports, \"getCacheKey\", { enumerable: true, get: function () { return getCacheKey_1.getCacheKey; } });\nvar getEndpointId_1 = require(\"./getEndpointId\");\nObject.defineProperty(exports, \"getEndpointId\", { enumerable: true, get: function () { return getEndpointId_1.getEndpointId; } });\nvar resolveEndpointId_1 = require(\"./resolveEndpointId\");\nObject.defineProperty(exports, \"resolveEndpointId\", { enumerable: true, get: function () { return resolveEndpointId_1.resolveEndpointId; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AAC3G,IAAI,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACrD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,iBAAiB,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC;AACxI,IAAI,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC7C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5H,IAAI,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACjD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,eAAe,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;AAClI,IAAI,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACzD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mBAAmB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/providers/pinpoint/utils/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveEndpointId = exports.getEndpointId = exports.getCacheKey = exports.createEndpointId = exports.cacheEndpointId = void 0;\nvar cacheEndpointId_1 = require(\"./cacheEndpointId\");\nObject.defineProperty(exports, \"cacheEndpointId\", { enumerable: true, get: function () { return cacheEndpointId_1.cacheEndpointId; } });\nvar createEndpointId_1 = require(\"./createEndpointId\");\nObject.defineProperty(exports, \"createEndpointId\", { enumerable: true, get: function () { return createEndpointId_1.createEndpointId; } });\nvar getCacheKey_1 = require(\"./getCacheKey\");\nObject.defineProperty(exports, \"getCacheKey\", { enumerable: true, get: function () { return getCacheKey_1.getCacheKey; } });\nvar getEndpointId_1 = require(\"./getEndpointId\");\nObject.defineProperty(exports, \"getEndpointId\", { enumerable: true, get: function () { return getEndpointId_1.getEndpointId; } });\nvar resolveEndpointId_1 = require(\"./resolveEndpointId\");\nObject.defineProperty(exports, \"resolveEndpointId\", { enumerable: true, get: function () { return resolveEndpointId_1.resolveEndpointId; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACtI,IAAI,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACrD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,iBAAiB,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC;AACxI,IAAI,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACvD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3I,IAAI,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC7C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5H,IAAI,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACjD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,eAAe,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;AAClI,IAAI,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACzD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mBAAmB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC;;"}
@@ -1 +1 @@
1
- export declare const version = "6.2.1-unstable.7ddca1b.0+7ddca1b";
1
+ export declare const version = "6.2.1-unstable.82e1bd3.0+82e1bd3";
@@ -1,5 +1,5 @@
1
1
  // generated by genversion
2
- const version = '6.2.1-unstable.7ddca1b.0+7ddca1b';
2
+ const version = '6.2.1-unstable.82e1bd3.0+82e1bd3';
3
3
 
4
4
  export { version };
5
5
  //# sourceMappingURL=version.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.2.1-unstable.7ddca1b.0+7ddca1b';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
1
+ {"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.2.1-unstable.82e1bd3.0+82e1bd3';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
@@ -7,6 +7,7 @@ import '../../../awsClients/pinpoint/base.mjs';
7
7
  import '../../../awsClients/pinpoint/errorHelpers.mjs';
8
8
  import { updateEndpoint as updateEndpoint$1 } from '../../../awsClients/pinpoint/updateEndpoint.mjs';
9
9
  import { cacheEndpointId } from '../utils/cacheEndpointId.mjs';
10
+ import { createEndpointId, clearCreatedEndpointId } from '../utils/createEndpointId.mjs';
10
11
  import { getEndpointId } from '../utils/getEndpointId.mjs';
11
12
 
12
13
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -17,7 +18,9 @@ import { getEndpointId } from '../utils/getEndpointId.mjs';
17
18
  const updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {
18
19
  const endpointId = await getEndpointId(appId, category);
19
20
  // only generate a new endpoint id if one was not found in cache
20
- const createdEndpointId = !endpointId ? amplifyUuid() : undefined;
21
+ const createdEndpointId = !endpointId
22
+ ? createEndpointId(appId, category)
23
+ : undefined;
21
24
  const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};
22
25
  const clientInfo = getClientInfo();
23
26
  const mergedDemographic = {
@@ -70,10 +73,19 @@ const updateEndpoint = async ({ address, appId, category, channelType, credentia
70
73
  },
71
74
  },
72
75
  };
73
- await updateEndpoint$1({ credentials, region, userAgentValue }, input);
74
- // if we had to create an endpoint id, we need to now cache it
75
- if (createdEndpointId) {
76
- return cacheEndpointId(appId, category, createdEndpointId);
76
+ try {
77
+ await updateEndpoint$1({ credentials, region, userAgentValue }, input);
78
+ // if we had to create an endpoint id, we need to now cache it
79
+ if (createdEndpointId) {
80
+ await cacheEndpointId(appId, category, createdEndpointId);
81
+ }
82
+ }
83
+ finally {
84
+ // at this point, we completely reset the behavior so even if the update was unsuccessful
85
+ // we can just start over with a newly created endpoint id
86
+ if (createdEndpointId) {
87
+ clearCreatedEndpointId(appId, category);
88
+ }
77
89
  }
78
90
  };
79
91
 
@@ -1 +1 @@
1
- {"version":3,"file":"updateEndpoint.mjs","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { amplifyUuid } from '../../../utils/amplifyUuid';\nimport { getClientInfo } from '../../../utils/getClientInfo';\nimport { updateEndpoint as clientUpdateEndpoint, } from '../../../awsClients/pinpoint';\nimport { cacheEndpointId } from '../utils/cacheEndpointId';\nimport { getEndpointId } from '../utils/getEndpointId';\n/**\n * @internal\n */\nexport const updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {\n const endpointId = await getEndpointId(appId, category);\n // only generate a new endpoint id if one was not found in cache\n const createdEndpointId = !endpointId ? amplifyUuid() : undefined;\n const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};\n const clientInfo = getClientInfo();\n const mergedDemographic = {\n appVersion: clientInfo.appVersion,\n make: clientInfo.make,\n model: clientInfo.model,\n modelVersion: clientInfo.version,\n platform: clientInfo.platform,\n ...demographic,\n };\n const shouldAddAttributes = email || customProperties || name || plan;\n const attributes = {\n ...(email && { email: [email] }),\n ...(name && { name: [name] }),\n ...(plan && { plan: [plan] }),\n ...customProperties,\n };\n const input = {\n ApplicationId: appId,\n EndpointId: endpointId ?? createdEndpointId,\n EndpointRequest: {\n RequestId: amplifyUuid(),\n EffectiveDate: new Date().toISOString(),\n ChannelType: channelType,\n Address: address,\n Attributes: shouldAddAttributes ? attributes : undefined,\n Demographic: {\n AppVersion: mergedDemographic.appVersion,\n Locale: mergedDemographic.locale,\n Make: mergedDemographic.make,\n Model: mergedDemographic.model,\n ModelVersion: mergedDemographic.modelVersion,\n Platform: mergedDemographic.platform,\n PlatformVersion: mergedDemographic.platformVersion,\n Timezone: mergedDemographic.timezone,\n },\n Location: {\n City: location?.city,\n Country: location?.country,\n Latitude: location?.latitude,\n Longitude: location?.longitude,\n PostalCode: location?.postalCode,\n Region: location?.region,\n },\n Metrics: metrics,\n OptOut: optOut,\n User: {\n UserId: userId ?? identityId,\n UserAttributes: userAttributes,\n },\n },\n };\n await clientUpdateEndpoint({ credentials, region, userAgentValue }, input);\n // if we had to create an endpoint id, we need to now cache it\n if (createdEndpointId) {\n return cacheEndpointId(appId, category, createdEndpointId);\n }\n};\n"],"names":["clientUpdateEndpoint"],"mappings":";;;;;;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACY,MAAC,cAAc,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AACb,SAAS;AACT,KAAK,CAAC;AACN,IAAI,MAAMA,gBAAoB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,KAAK,CAAC,CAAC;AAC/E;AACA,IAAI,IAAI,iBAAiB,EAAE;AAC3B,QAAQ,OAAO,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AACnE,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"updateEndpoint.mjs","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { amplifyUuid } from '../../../utils/amplifyUuid';\nimport { getClientInfo } from '../../../utils/getClientInfo';\nimport { updateEndpoint as clientUpdateEndpoint, } from '../../../awsClients/pinpoint';\nimport { cacheEndpointId } from '../utils/cacheEndpointId';\nimport { clearCreatedEndpointId, createEndpointId, } from '../utils/createEndpointId';\nimport { getEndpointId } from '../utils/getEndpointId';\n/**\n * @internal\n */\nexport const updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {\n const endpointId = await getEndpointId(appId, category);\n // only generate a new endpoint id if one was not found in cache\n const createdEndpointId = !endpointId\n ? createEndpointId(appId, category)\n : undefined;\n const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};\n const clientInfo = getClientInfo();\n const mergedDemographic = {\n appVersion: clientInfo.appVersion,\n make: clientInfo.make,\n model: clientInfo.model,\n modelVersion: clientInfo.version,\n platform: clientInfo.platform,\n ...demographic,\n };\n const shouldAddAttributes = email || customProperties || name || plan;\n const attributes = {\n ...(email && { email: [email] }),\n ...(name && { name: [name] }),\n ...(plan && { plan: [plan] }),\n ...customProperties,\n };\n const input = {\n ApplicationId: appId,\n EndpointId: endpointId ?? createdEndpointId,\n EndpointRequest: {\n RequestId: amplifyUuid(),\n EffectiveDate: new Date().toISOString(),\n ChannelType: channelType,\n Address: address,\n Attributes: shouldAddAttributes ? attributes : undefined,\n Demographic: {\n AppVersion: mergedDemographic.appVersion,\n Locale: mergedDemographic.locale,\n Make: mergedDemographic.make,\n Model: mergedDemographic.model,\n ModelVersion: mergedDemographic.modelVersion,\n Platform: mergedDemographic.platform,\n PlatformVersion: mergedDemographic.platformVersion,\n Timezone: mergedDemographic.timezone,\n },\n Location: {\n City: location?.city,\n Country: location?.country,\n Latitude: location?.latitude,\n Longitude: location?.longitude,\n PostalCode: location?.postalCode,\n Region: location?.region,\n },\n Metrics: metrics,\n OptOut: optOut,\n User: {\n UserId: userId ?? identityId,\n UserAttributes: userAttributes,\n },\n },\n };\n try {\n await clientUpdateEndpoint({ credentials, region, userAgentValue }, input);\n // if we had to create an endpoint id, we need to now cache it\n if (createdEndpointId) {\n await cacheEndpointId(appId, category, createdEndpointId);\n }\n }\n finally {\n // at this point, we completely reset the behavior so even if the update was unsuccessful\n // we can just start over with a newly created endpoint id\n if (createdEndpointId) {\n clearCreatedEndpointId(appId, category);\n }\n }\n};\n"],"names":["clientUpdateEndpoint"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACY,MAAC,cAAc,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,GAAG,KAAK;AAClL,IAAI,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC5D;AACA,IAAI,MAAM,iBAAiB,GAAG,CAAC,UAAU;AACzC,UAAU,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC;AAC3C,UAAU,SAAS,CAAC;AACpB,IAAI,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAA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 +3,6 @@ export { record } from './apis/record.mjs';
3
3
  export { flushEvents } from './apis/flushEvents.mjs';
4
4
  export { UpdateEndpointException } from './types/errors.mjs';
5
5
  import '../../Cache/index.mjs';
6
+ import 'uuid';
6
7
  export { resolveEndpointId } from './utils/resolveEndpointId.mjs';
7
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,13 @@
1
+ import { SupportedCategory } from '../types';
2
+ /**
3
+ * Creates an endpoint id and guarantees multiple creations for a category returns the same uuid.
4
+ *
5
+ * @internal
6
+ */
7
+ export declare const createEndpointId: (appId: string, category: SupportedCategory) => string;
8
+ /**
9
+ * Clears a created endpoint id for a category.
10
+ *
11
+ * @internal
12
+ */
13
+ export declare const clearCreatedEndpointId: (appId: string, category: SupportedCategory) => void;
@@ -0,0 +1,30 @@
1
+ import { amplifyUuid } from '../../../utils/amplifyUuid/index.mjs';
2
+ import { getCacheKey } from './getCacheKey.mjs';
3
+
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const createdEndpointIds = {};
7
+ /**
8
+ * Creates an endpoint id and guarantees multiple creations for a category returns the same uuid.
9
+ *
10
+ * @internal
11
+ */
12
+ const createEndpointId = (appId, category) => {
13
+ const cacheKey = getCacheKey(appId, category);
14
+ if (!createdEndpointIds[cacheKey]) {
15
+ createdEndpointIds[cacheKey] = amplifyUuid();
16
+ }
17
+ return createdEndpointIds[cacheKey];
18
+ };
19
+ /**
20
+ * Clears a created endpoint id for a category.
21
+ *
22
+ * @internal
23
+ */
24
+ const clearCreatedEndpointId = (appId, category) => {
25
+ const cacheKey = getCacheKey(appId, category);
26
+ delete createdEndpointIds[cacheKey];
27
+ };
28
+
29
+ export { clearCreatedEndpointId, createEndpointId };
30
+ //# sourceMappingURL=createEndpointId.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createEndpointId.mjs","sources":["../../../../../src/providers/pinpoint/utils/createEndpointId.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { amplifyUuid } from '../../../utils/amplifyUuid';\nimport { getCacheKey } from './getCacheKey';\nconst createdEndpointIds = {};\n/**\n * Creates an endpoint id and guarantees multiple creations for a category returns the same uuid.\n *\n * @internal\n */\nexport const createEndpointId = (appId, category) => {\n const cacheKey = getCacheKey(appId, category);\n if (!createdEndpointIds[cacheKey]) {\n createdEndpointIds[cacheKey] = amplifyUuid();\n }\n return createdEndpointIds[cacheKey];\n};\n/**\n * Clears a created endpoint id for a category.\n *\n * @internal\n */\nexport const clearCreatedEndpointId = (appId, category) => {\n const cacheKey = getCacheKey(appId, category);\n delete createdEndpointIds[cacheKey];\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B;AACA;AACA;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK;AACrD,IAAI,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAClD,IAAI,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE;AACvC,QAAQ,kBAAkB,CAAC,QAAQ,CAAC,GAAG,WAAW,EAAE,CAAC;AACrD,KAAK;AACL,IAAI,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACxC,EAAE;AACF;AACA;AACA;AACA;AACA;AACY,MAAC,sBAAsB,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK;AAC3D,IAAI,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAClD,IAAI,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACxC;;;;"}
@@ -1,4 +1,5 @@
1
1
  export { cacheEndpointId } from './cacheEndpointId';
2
+ export { createEndpointId } from './createEndpointId';
2
3
  export { getCacheKey } from './getCacheKey';
3
4
  export { getEndpointId } from './getEndpointId';
4
5
  export { resolveEndpointId } from './resolveEndpointId';
@@ -1,4 +1,5 @@
1
1
  export { cacheEndpointId } from './cacheEndpointId.mjs';
2
+ export { createEndpointId } from './createEndpointId.mjs';
2
3
  export { getCacheKey } from './getCacheKey.mjs';
3
4
  export { getEndpointId } from './getEndpointId.mjs';
4
5
  export { resolveEndpointId } from './resolveEndpointId.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/core",
3
- "version": "6.1.1-unstable.7ddca1b.0+7ddca1b",
3
+ "version": "6.1.1-unstable.82e1bd3.0+82e1bd3",
4
4
  "description": "Core category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -60,7 +60,7 @@
60
60
  "uuid": "^9.0.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@aws-amplify/react-native": "1.0.29-unstable.7ddca1b.0+7ddca1b",
63
+ "@aws-amplify/react-native": "1.0.29-unstable.82e1bd3.0+82e1bd3",
64
64
  "@types/js-cookie": "3.0.2",
65
65
  "genversion": "^2.2.0",
66
66
  "typescript": "5.0.2"
@@ -192,5 +192,5 @@
192
192
  ]
193
193
  }
194
194
  },
195
- "gitHead": "7ddca1bc9fa9d991259466b2d1e391cede1c206d"
195
+ "gitHead": "82e1bd3878757db605d68b0c1ca4d564281acce7"
196
196
  }
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '6.2.1-unstable.7ddca1b.0+7ddca1b';
2
+ export const version = '6.2.1-unstable.82e1bd3.0+82e1bd3';
@@ -9,6 +9,10 @@ import {
9
9
  } from '../../../awsClients/pinpoint';
10
10
  import { PinpointUpdateEndpointInput } from '../types';
11
11
  import { cacheEndpointId } from '../utils/cacheEndpointId';
12
+ import {
13
+ clearCreatedEndpointId,
14
+ createEndpointId,
15
+ } from '../utils/createEndpointId';
12
16
  import { getEndpointId } from '../utils/getEndpointId';
13
17
 
14
18
  /**
@@ -30,7 +34,9 @@ export const updateEndpoint = async ({
30
34
  }: PinpointUpdateEndpointInput): Promise<void> => {
31
35
  const endpointId = await getEndpointId(appId, category);
32
36
  // only generate a new endpoint id if one was not found in cache
33
- const createdEndpointId = !endpointId ? amplifyUuid() : undefined;
37
+ const createdEndpointId = !endpointId
38
+ ? createEndpointId(appId, category)
39
+ : undefined;
34
40
  const {
35
41
  customProperties,
36
42
  demographic,
@@ -91,9 +97,17 @@ export const updateEndpoint = async ({
91
97
  },
92
98
  },
93
99
  };
94
- await clientUpdateEndpoint({ credentials, region, userAgentValue }, input);
95
- // if we had to create an endpoint id, we need to now cache it
96
- if (createdEndpointId) {
97
- return cacheEndpointId(appId, category, createdEndpointId);
100
+ try {
101
+ await clientUpdateEndpoint({ credentials, region, userAgentValue }, input);
102
+ // if we had to create an endpoint id, we need to now cache it
103
+ if (createdEndpointId) {
104
+ await cacheEndpointId(appId, category, createdEndpointId);
105
+ }
106
+ } finally {
107
+ // at this point, we completely reset the behavior so even if the update was unsuccessful
108
+ // we can just start over with a newly created endpoint id
109
+ if (createdEndpointId) {
110
+ clearCreatedEndpointId(appId, category);
111
+ }
98
112
  }
99
113
  };
@@ -0,0 +1,39 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { amplifyUuid } from '../../../utils/amplifyUuid';
5
+ import { SupportedCategory } from '../types';
6
+
7
+ import { getCacheKey } from './getCacheKey';
8
+
9
+ const createdEndpointIds: Record<string, string> = {};
10
+
11
+ /**
12
+ * Creates an endpoint id and guarantees multiple creations for a category returns the same uuid.
13
+ *
14
+ * @internal
15
+ */
16
+ export const createEndpointId = (
17
+ appId: string,
18
+ category: SupportedCategory,
19
+ ): string => {
20
+ const cacheKey = getCacheKey(appId, category);
21
+ if (!createdEndpointIds[cacheKey]) {
22
+ createdEndpointIds[cacheKey] = amplifyUuid();
23
+ }
24
+
25
+ return createdEndpointIds[cacheKey];
26
+ };
27
+
28
+ /**
29
+ * Clears a created endpoint id for a category.
30
+ *
31
+ * @internal
32
+ */
33
+ export const clearCreatedEndpointId = (
34
+ appId: string,
35
+ category: SupportedCategory,
36
+ ): void => {
37
+ const cacheKey = getCacheKey(appId, category);
38
+ delete createdEndpointIds[cacheKey];
39
+ };
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export { cacheEndpointId } from './cacheEndpointId';
5
+ export { createEndpointId } from './createEndpointId';
5
6
  export { getCacheKey } from './getCacheKey';
6
7
  export { getEndpointId } from './getEndpointId';
7
8
  export { resolveEndpointId } from './resolveEndpointId';