@aws-amplify/core 6.4.5-unstable.5c3f17a.0 → 6.4.6-events.538dd9f.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.
- package/dist/cjs/Cache/StorageCacheCommon.js +2 -1
- package/dist/cjs/Cache/StorageCacheCommon.js.map +1 -1
- package/dist/cjs/Platform/version.js +1 -1
- package/dist/cjs/Platform/version.js.map +1 -1
- package/dist/cjs/parseAmplifyOutputs.js +21 -0
- package/dist/cjs/parseAmplifyOutputs.js.map +1 -1
- package/dist/esm/Cache/StorageCacheCommon.mjs +2 -1
- package/dist/esm/Cache/StorageCacheCommon.mjs.map +1 -1
- package/dist/esm/Platform/version.d.ts +1 -1
- package/dist/esm/Platform/version.mjs +1 -1
- package/dist/esm/Platform/version.mjs.map +1 -1
- package/dist/esm/parseAmplifyOutputs.mjs +21 -0
- package/dist/esm/parseAmplifyOutputs.mjs.map +1 -1
- package/dist/esm/singleton/API/types.d.ts +34 -1
- package/dist/esm/singleton/AmplifyOutputs/types.d.ts +10 -0
- package/package.json +3 -3
- package/src/Cache/StorageCacheCommon.ts +2 -1
- package/src/Platform/version.ts +1 -1
- package/src/parseAmplifyOutputs.ts +32 -1
- package/src/singleton/API/types.ts +38 -1
- package/src/singleton/AmplifyOutputs/types.ts +12 -0
|
@@ -458,7 +458,8 @@ class StorageCacheCommon {
|
|
|
458
458
|
try {
|
|
459
459
|
const keys = await this.getAllKeys();
|
|
460
460
|
for (const key of keys) {
|
|
461
|
-
|
|
461
|
+
const prefixedKey = `${this.config.keyPrefix}${key}`;
|
|
462
|
+
await this.getStorage().removeItem(prefixedKey);
|
|
462
463
|
}
|
|
463
464
|
}
|
|
464
465
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageCacheCommon.js","sources":["../../../src/Cache/StorageCacheCommon.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.StorageCacheCommon = void 0;\nconst Logger_1 = require(\"../Logger\");\nconst constants_1 = require(\"./constants\");\nconst utils_1 = require(\"./utils\");\nconst errorHelpers_1 = require(\"./utils/errorHelpers\");\nconst logger = new Logger_1.ConsoleLogger('StorageCache');\n/**\n * Initialization of the cache\n *\n */\nclass StorageCacheCommon {\n /**\n * Initialize the cache\n *\n * @param config - Custom configuration for this instance.\n */\n constructor({ config, keyValueStorage, }) {\n this.config = {\n ...constants_1.defaultConfig,\n ...config,\n };\n this.keyValueStorage = keyValueStorage;\n this.sanitizeConfig();\n }\n getModuleName() {\n return 'Cache';\n }\n /**\n * Set custom configuration for the cache instance.\n *\n * @param config - customized configuration (without keyPrefix, which can't be changed)\n *\n * @return - the current configuration\n */\n configure(config) {\n if (config) {\n if (config.keyPrefix) {\n logger.warn('keyPrefix can not be re-configured on an existing Cache instance.');\n }\n this.config = {\n ...this.config,\n ...config,\n };\n }\n this.sanitizeConfig();\n return this.config;\n }\n /**\n * return the current size of the cache\n * @return {Promise}\n */\n async getCurrentCacheSize() {\n let size = await this.getStorage().getItem((0, utils_1.getCurrentSizeKey)(this.config.keyPrefix));\n if (!size) {\n await this.getStorage().setItem((0, utils_1.getCurrentSizeKey)(this.config.keyPrefix), '0');\n size = '0';\n }\n return Number(size);\n }\n /**\n * Set item into cache. You can put number, string, boolean or object.\n * The cache will first check whether has the same key.\n * If it has, it will delete the old item and then put the new item in\n * The cache will pop out items if it is full\n * You can specify the cache item options. The cache will abort and output a warning:\n * If the key is invalid\n * If the size of the item exceeds itemMaxSize.\n * If the value is undefined\n * If incorrect cache item configuration\n * If error happened with browser storage\n *\n * @param {String} key - the key of the item\n * @param {Object} value - the value of the item\n * @param {Object} [options] - optional, the specified meta-data\n *\n * @return {Promise}\n */\n async setItem(key, value, options) {\n logger.debug(`Set item: key is ${key}, value is ${value} with options: ${options}`);\n if (!key || key === constants_1.currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${constants_1.currentSizeKey}'`);\n return;\n }\n if (typeof value === 'undefined') {\n logger.warn(`The value of item should not be undefined!`);\n return;\n }\n const cacheItemOptions = {\n priority: options?.priority !== undefined\n ? options.priority\n : this.config.defaultPriority,\n expires: options?.expires !== undefined\n ? options.expires\n : this.config.defaultTTL + (0, utils_1.getCurrentTime)(),\n };\n if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {\n logger.warn(`Invalid parameter: priority due to out or range. It should be within 1 and 5.`);\n return;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n const item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);\n // check whether this item is too big;\n if (item.byteSize > this.config.itemMaxSize) {\n logger.warn(`Item with key: ${key} you are trying to put into is too big!`);\n return;\n }\n try {\n // first look into the storage, if it exists, delete it.\n const val = await this.getStorage().getItem(prefixedKey);\n if (val) {\n await this.removeCacheItem(prefixedKey, JSON.parse(val).byteSize);\n }\n // check whether the cache is full\n if (await this.isCacheFull(item.byteSize)) {\n const validKeys = await this.clearInvalidAndGetRemainingKeys();\n if (await this.isCacheFull(item.byteSize)) {\n const sizeToPop = await this.sizeToPop(item.byteSize);\n await this.popOutItems(validKeys, sizeToPop);\n }\n }\n // put item in the cache\n return this.setCacheItem(prefixedKey, item);\n }\n catch (e) {\n logger.warn(`setItem failed! ${e}`);\n }\n }\n /**\n * Get item from cache. It will return null if item doesn’t exist or it has been expired.\n * If you specified callback function in the options,\n * then the function will be executed if no such item in the cache\n * and finally put the return value into cache.\n * Please make sure the callback function will return the value you want to put into the cache.\n * The cache will abort output a warning:\n * If the key is invalid\n * If error happened with AsyncStorage\n *\n * @param {String} key - the key of the item\n * @param {Object} [options] - the options of callback function\n *\n * @return {Promise} - return a promise resolves to be the value of the item\n */\n async getItem(key, options) {\n logger.debug(`Get item: key is ${key} with options ${options}`);\n let cached;\n if (!key || key === constants_1.currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${constants_1.currentSizeKey}'`);\n return null;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n try {\n cached = await this.getStorage().getItem(prefixedKey);\n if (cached != null) {\n if (await this.isExpired(prefixedKey)) {\n // if expired, remove that item and return null\n await this.removeCacheItem(prefixedKey, JSON.parse(cached).byteSize);\n }\n else {\n // if not expired, update its visitedTime and return the value\n const item = await this.updateVisitedTime(JSON.parse(cached), prefixedKey);\n return item.data;\n }\n }\n if (options?.callback) {\n const val = options.callback();\n if (val !== null) {\n await this.setItem(key, val, options);\n }\n return val;\n }\n return null;\n }\n catch (e) {\n logger.warn(`getItem failed! ${e}`);\n return null;\n }\n }\n /**\n * remove item from the cache\n * The cache will abort output a warning:\n * If error happened with AsyncStorage\n * @param {String} key - the key of the item\n * @return {Promise}\n */\n async removeItem(key) {\n logger.debug(`Remove item: key is ${key}`);\n if (!key || key === constants_1.currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${constants_1.currentSizeKey}'`);\n return;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n try {\n const val = await this.getStorage().getItem(prefixedKey);\n if (val) {\n await this.removeCacheItem(prefixedKey, JSON.parse(val).byteSize);\n }\n }\n catch (e) {\n logger.warn(`removeItem failed! ${e}`);\n }\n }\n /**\n * Return all the keys owned by this cache.\n * Will return an empty array if error occurred.\n *\n * @return {Promise}\n */\n async getAllKeys() {\n try {\n return await this.getAllCacheKeys();\n }\n catch (e) {\n logger.warn(`getAllkeys failed! ${e}`);\n return [];\n }\n }\n getStorage() {\n return this.keyValueStorage;\n }\n /**\n * check whether item is expired\n *\n * @param key - the key of the item\n *\n * @return true if the item is expired.\n */\n async isExpired(key) {\n const text = await this.getStorage().getItem(key);\n (0, errorHelpers_1.assert)(text !== null, errorHelpers_1.CacheErrorCode.NoCacheItem, `Key: ${key}`);\n const item = JSON.parse(text);\n if ((0, utils_1.getCurrentTime)() >= item.expires) {\n return true;\n }\n return false;\n }\n /**\n * delete item from cache\n *\n * @param prefixedKey - the key of the item\n * @param size - optional, the byte size of the item\n */\n async removeCacheItem(prefixedKey, size) {\n const item = await this.getStorage().getItem(prefixedKey);\n (0, errorHelpers_1.assert)(item !== null, errorHelpers_1.CacheErrorCode.NoCacheItem, `Key: ${prefixedKey}`);\n const itemSize = size ?? JSON.parse(item).byteSize;\n // first try to update the current size of the cache\n await this.decreaseCurrentSizeInBytes(itemSize);\n // try to remove the item from cache\n try {\n await this.getStorage().removeItem(prefixedKey);\n }\n catch (removeItemError) {\n // if some error happened, we need to rollback the current size\n await this.increaseCurrentSizeInBytes(itemSize);\n logger.error(`Failed to remove item: ${removeItemError}`);\n }\n }\n /**\n * produce a JSON object with meta-data and data value\n * @param value - the value of the item\n * @param options - optional, the specified meta-data\n *\n * @return - the item which has the meta-data and the value\n */\n fillCacheItem(key, value, options) {\n const item = {\n key,\n data: value,\n timestamp: (0, utils_1.getCurrentTime)(),\n visitedTime: (0, utils_1.getCurrentTime)(),\n priority: options.priority ?? 0,\n expires: options.expires ?? 0,\n type: typeof value,\n byteSize: 0,\n };\n // calculate byte size\n item.byteSize = (0, utils_1.getByteLength)(JSON.stringify(item));\n // re-calculate using cache item with updated byteSize property\n item.byteSize = (0, utils_1.getByteLength)(JSON.stringify(item));\n return item;\n }\n sanitizeConfig() {\n if (this.config.itemMaxSize > this.config.capacityInBytes) {\n logger.error('Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default.');\n this.config.itemMaxSize = constants_1.defaultConfig.itemMaxSize;\n }\n if (this.config.defaultPriority > 5 || this.config.defaultPriority < 1) {\n logger.error('Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default.');\n this.config.defaultPriority = constants_1.defaultConfig.defaultPriority;\n }\n if (Number(this.config.warningThreshold) > 1 ||\n Number(this.config.warningThreshold) < 0) {\n logger.error('Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default.');\n this.config.warningThreshold = constants_1.defaultConfig.warningThreshold;\n }\n // Set 5MB limit\n const cacheLimit = 5 * 1024 * 1024;\n if (this.config.capacityInBytes > cacheLimit) {\n logger.error('Cache Capacity should be less than 5MB. Setting back to default. Setting back to default.');\n this.config.capacityInBytes = constants_1.defaultConfig.capacityInBytes;\n }\n }\n /**\n * increase current size of the cache\n *\n * @param amount - the amount of the cache szie which need to be increased\n */\n async increaseCurrentSizeInBytes(amount) {\n const size = await this.getCurrentCacheSize();\n await this.getStorage().setItem((0, utils_1.getCurrentSizeKey)(this.config.keyPrefix), (size + amount).toString());\n }\n /**\n * decrease current size of the cache\n *\n * @param amount - the amount of the cache size which needs to be decreased\n */\n async decreaseCurrentSizeInBytes(amount) {\n const size = await this.getCurrentCacheSize();\n await this.getStorage().setItem((0, utils_1.getCurrentSizeKey)(this.config.keyPrefix), (size - amount).toString());\n }\n /**\n * update the visited time if item has been visited\n *\n * @param item - the item which need to be updated\n * @param prefixedKey - the key of the item\n *\n * @return the updated item\n */\n async updateVisitedTime(item, prefixedKey) {\n item.visitedTime = (0, utils_1.getCurrentTime)();\n await this.getStorage().setItem(prefixedKey, JSON.stringify(item));\n return item;\n }\n /**\n * put item into cache\n *\n * @param prefixedKey - the key of the item\n * @param itemData - the value of the item\n * @param itemSizeInBytes - the byte size of the item\n */\n async setCacheItem(prefixedKey, item) {\n // first try to update the current size of the cache.\n await this.increaseCurrentSizeInBytes(item.byteSize);\n // try to add the item into cache\n try {\n await this.getStorage().setItem(prefixedKey, JSON.stringify(item));\n }\n catch (setItemErr) {\n // if some error happened, we need to rollback the current size\n await this.decreaseCurrentSizeInBytes(item.byteSize);\n logger.error(`Failed to set item ${setItemErr}`);\n }\n }\n /**\n * total space needed when poping out items\n *\n * @param itemSize\n *\n * @return total space needed\n */\n async sizeToPop(itemSize) {\n const cur = await this.getCurrentCacheSize();\n const spaceItemNeed = cur + itemSize - this.config.capacityInBytes;\n const cacheThresholdSpace = (1 - this.config.warningThreshold) * this.config.capacityInBytes;\n return spaceItemNeed > cacheThresholdSpace\n ? spaceItemNeed\n : cacheThresholdSpace;\n }\n /**\n * see whether cache is full\n *\n * @param itemSize\n *\n * @return true if cache is full\n */\n async isCacheFull(itemSize) {\n const cur = await this.getCurrentCacheSize();\n return itemSize + cur > this.config.capacityInBytes;\n }\n /**\n * get all the items we have, sort them by their priority,\n * if priority is same, sort them by their last visited time\n * pop out items from the low priority (5 is the lowest)\n * @private\n * @param keys - all the keys in this cache\n * @param sizeToPop - the total size of the items which needed to be poped out\n */\n async popOutItems(keys, sizeToPop) {\n const items = [];\n let remainedSize = sizeToPop;\n for (const key of keys) {\n const val = await this.getStorage().getItem(key);\n if (val != null) {\n const item = JSON.parse(val);\n items.push(item);\n }\n }\n // first compare priority\n // then compare visited time\n items.sort((a, b) => {\n if (a.priority > b.priority) {\n return -1;\n }\n else if (a.priority < b.priority) {\n return 1;\n }\n else {\n if (a.visitedTime < b.visitedTime) {\n return -1;\n }\n else\n return 1;\n }\n });\n for (const item of items) {\n // pop out items until we have enough room for new item\n await this.removeCacheItem(item.key, item.byteSize);\n remainedSize -= item.byteSize;\n if (remainedSize <= 0) {\n return;\n }\n }\n }\n /**\n * Scan the storage and combine the following operations for efficiency\n * 1. Clear out all expired keys owned by this cache, not including the size key.\n * 2. Return the remaining keys.\n *\n * @return The remaining valid keys\n */\n async clearInvalidAndGetRemainingKeys() {\n const remainingKeys = [];\n const keys = await this.getAllCacheKeys({\n omitSizeKey: true,\n });\n for (const key of keys) {\n if (await this.isExpired(key)) {\n await this.removeCacheItem(key);\n }\n else {\n remainingKeys.push(key);\n }\n }\n return remainingKeys;\n }\n /**\n * clear the entire cache\n * The cache will abort and output a warning if error occurs\n * @return {Promise}\n */\n async clear() {\n logger.debug(`Clear Cache`);\n try {\n const keys = await this.getAllKeys();\n for (const key of keys) {\n await this.getStorage().removeItem(key);\n }\n }\n catch (e) {\n logger.warn(`clear failed! ${e}`);\n }\n }\n}\nexports.StorageCacheCommon = StorageCacheCommon;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM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;AACT,QAAQ,OAAO,aAAa,CAAC;AAC7B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AACpC,QAAQ,IAAI;AACZ,YAAY,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;AACjD,YAAY,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AACpC,gBAAgB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACxD,aAAa;AACb,SAAS;AACT,QAAQ,OAAO,CAAC,EAAE;AAClB,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,SAAS;AACT,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
1
|
+
{"version":3,"file":"StorageCacheCommon.js","sources":["../../../src/Cache/StorageCacheCommon.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.StorageCacheCommon = void 0;\nconst Logger_1 = require(\"../Logger\");\nconst constants_1 = require(\"./constants\");\nconst utils_1 = require(\"./utils\");\nconst errorHelpers_1 = require(\"./utils/errorHelpers\");\nconst logger = new Logger_1.ConsoleLogger('StorageCache');\n/**\n * Initialization of the cache\n *\n */\nclass StorageCacheCommon {\n /**\n * Initialize the cache\n *\n * @param config - Custom configuration for this instance.\n */\n constructor({ config, keyValueStorage, }) {\n this.config = {\n ...constants_1.defaultConfig,\n ...config,\n };\n this.keyValueStorage = keyValueStorage;\n this.sanitizeConfig();\n }\n getModuleName() {\n return 'Cache';\n }\n /**\n * Set custom configuration for the cache instance.\n *\n * @param config - customized configuration (without keyPrefix, which can't be changed)\n *\n * @return - the current configuration\n */\n configure(config) {\n if (config) {\n if (config.keyPrefix) {\n logger.warn('keyPrefix can not be re-configured on an existing Cache instance.');\n }\n this.config = {\n ...this.config,\n ...config,\n };\n }\n this.sanitizeConfig();\n return this.config;\n }\n /**\n * return the current size of the cache\n * @return {Promise}\n */\n async getCurrentCacheSize() {\n let size = await this.getStorage().getItem((0, utils_1.getCurrentSizeKey)(this.config.keyPrefix));\n if (!size) {\n await this.getStorage().setItem((0, utils_1.getCurrentSizeKey)(this.config.keyPrefix), '0');\n size = '0';\n }\n return Number(size);\n }\n /**\n * Set item into cache. You can put number, string, boolean or object.\n * The cache will first check whether has the same key.\n * If it has, it will delete the old item and then put the new item in\n * The cache will pop out items if it is full\n * You can specify the cache item options. The cache will abort and output a warning:\n * If the key is invalid\n * If the size of the item exceeds itemMaxSize.\n * If the value is undefined\n * If incorrect cache item configuration\n * If error happened with browser storage\n *\n * @param {String} key - the key of the item\n * @param {Object} value - the value of the item\n * @param {Object} [options] - optional, the specified meta-data\n *\n * @return {Promise}\n */\n async setItem(key, value, options) {\n logger.debug(`Set item: key is ${key}, value is ${value} with options: ${options}`);\n if (!key || key === constants_1.currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${constants_1.currentSizeKey}'`);\n return;\n }\n if (typeof value === 'undefined') {\n logger.warn(`The value of item should not be undefined!`);\n return;\n }\n const cacheItemOptions = {\n priority: options?.priority !== undefined\n ? options.priority\n : this.config.defaultPriority,\n expires: options?.expires !== undefined\n ? options.expires\n : this.config.defaultTTL + (0, utils_1.getCurrentTime)(),\n };\n if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {\n logger.warn(`Invalid parameter: priority due to out or range. It should be within 1 and 5.`);\n return;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n const item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);\n // check whether this item is too big;\n if (item.byteSize > this.config.itemMaxSize) {\n logger.warn(`Item with key: ${key} you are trying to put into is too big!`);\n return;\n }\n try {\n // first look into the storage, if it exists, delete it.\n const val = await this.getStorage().getItem(prefixedKey);\n if (val) {\n await this.removeCacheItem(prefixedKey, JSON.parse(val).byteSize);\n }\n // check whether the cache is full\n if (await this.isCacheFull(item.byteSize)) {\n const validKeys = await this.clearInvalidAndGetRemainingKeys();\n if (await this.isCacheFull(item.byteSize)) {\n const sizeToPop = await this.sizeToPop(item.byteSize);\n await this.popOutItems(validKeys, sizeToPop);\n }\n }\n // put item in the cache\n return this.setCacheItem(prefixedKey, item);\n }\n catch (e) {\n logger.warn(`setItem failed! ${e}`);\n }\n }\n /**\n * Get item from cache. It will return null if item doesn’t exist or it has been expired.\n * If you specified callback function in the options,\n * then the function will be executed if no such item in the cache\n * and finally put the return value into cache.\n * Please make sure the callback function will return the value you want to put into the cache.\n * The cache will abort output a warning:\n * If the key is invalid\n * If error happened with AsyncStorage\n *\n * @param {String} key - the key of the item\n * @param {Object} [options] - the options of callback function\n *\n * @return {Promise} - return a promise resolves to be the value of the item\n */\n async getItem(key, options) {\n logger.debug(`Get item: key is ${key} with options ${options}`);\n let cached;\n if (!key || key === constants_1.currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${constants_1.currentSizeKey}'`);\n return null;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n try {\n cached = await this.getStorage().getItem(prefixedKey);\n if (cached != null) {\n if (await this.isExpired(prefixedKey)) {\n // if expired, remove that item and return null\n await this.removeCacheItem(prefixedKey, JSON.parse(cached).byteSize);\n }\n else {\n // if not expired, update its visitedTime and return the value\n const item = await this.updateVisitedTime(JSON.parse(cached), prefixedKey);\n return item.data;\n }\n }\n if (options?.callback) {\n const val = options.callback();\n if (val !== null) {\n await this.setItem(key, val, options);\n }\n return val;\n }\n return null;\n }\n catch (e) {\n logger.warn(`getItem failed! ${e}`);\n return null;\n }\n }\n /**\n * remove item from the cache\n * The cache will abort output a warning:\n * If error happened with AsyncStorage\n * @param {String} key - the key of the item\n * @return {Promise}\n */\n async removeItem(key) {\n logger.debug(`Remove item: key is ${key}`);\n if (!key || key === constants_1.currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${constants_1.currentSizeKey}'`);\n return;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n try {\n const val = await this.getStorage().getItem(prefixedKey);\n if (val) {\n await this.removeCacheItem(prefixedKey, JSON.parse(val).byteSize);\n }\n }\n catch (e) {\n logger.warn(`removeItem failed! ${e}`);\n }\n }\n /**\n * Return all the keys owned by this cache.\n * Will return an empty array if error occurred.\n *\n * @return {Promise}\n */\n async getAllKeys() {\n try {\n return await this.getAllCacheKeys();\n }\n catch (e) {\n logger.warn(`getAllkeys failed! ${e}`);\n return [];\n }\n }\n getStorage() {\n return this.keyValueStorage;\n }\n /**\n * check whether item is expired\n *\n * @param key - the key of the item\n *\n * @return true if the item is expired.\n */\n async isExpired(key) {\n const text = await this.getStorage().getItem(key);\n (0, errorHelpers_1.assert)(text !== null, errorHelpers_1.CacheErrorCode.NoCacheItem, `Key: ${key}`);\n const item = JSON.parse(text);\n if ((0, utils_1.getCurrentTime)() >= item.expires) {\n return true;\n }\n return false;\n }\n /**\n * delete item from cache\n *\n * @param prefixedKey - the key of the item\n * @param size - optional, the byte size of the item\n */\n async removeCacheItem(prefixedKey, size) {\n const item = await this.getStorage().getItem(prefixedKey);\n (0, errorHelpers_1.assert)(item !== null, errorHelpers_1.CacheErrorCode.NoCacheItem, `Key: ${prefixedKey}`);\n const itemSize = size ?? JSON.parse(item).byteSize;\n // first try to update the current size of the cache\n await this.decreaseCurrentSizeInBytes(itemSize);\n // try to remove the item from cache\n try {\n await this.getStorage().removeItem(prefixedKey);\n }\n catch (removeItemError) {\n // if some error happened, we need to rollback the current size\n await this.increaseCurrentSizeInBytes(itemSize);\n logger.error(`Failed to remove item: ${removeItemError}`);\n }\n }\n /**\n * produce a JSON object with meta-data and data value\n * @param value - the value of the item\n * @param options - optional, the specified meta-data\n *\n * @return - the item which has the meta-data and the value\n */\n fillCacheItem(key, value, options) {\n const item = {\n key,\n data: value,\n timestamp: (0, utils_1.getCurrentTime)(),\n visitedTime: (0, utils_1.getCurrentTime)(),\n priority: options.priority ?? 0,\n expires: options.expires ?? 0,\n type: typeof value,\n byteSize: 0,\n };\n // calculate byte size\n item.byteSize = (0, utils_1.getByteLength)(JSON.stringify(item));\n // re-calculate using cache item with updated byteSize property\n item.byteSize = (0, utils_1.getByteLength)(JSON.stringify(item));\n return item;\n }\n sanitizeConfig() {\n if (this.config.itemMaxSize > this.config.capacityInBytes) {\n logger.error('Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default.');\n this.config.itemMaxSize = constants_1.defaultConfig.itemMaxSize;\n }\n if (this.config.defaultPriority > 5 || this.config.defaultPriority < 1) {\n logger.error('Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default.');\n this.config.defaultPriority = constants_1.defaultConfig.defaultPriority;\n }\n if (Number(this.config.warningThreshold) > 1 ||\n Number(this.config.warningThreshold) < 0) {\n logger.error('Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default.');\n this.config.warningThreshold = constants_1.defaultConfig.warningThreshold;\n }\n // Set 5MB limit\n const cacheLimit = 5 * 1024 * 1024;\n if (this.config.capacityInBytes > cacheLimit) {\n logger.error('Cache Capacity should be less than 5MB. Setting back to default. Setting back to default.');\n this.config.capacityInBytes = constants_1.defaultConfig.capacityInBytes;\n }\n }\n /**\n * increase current size of the cache\n *\n * @param amount - the amount of the cache szie which need to be increased\n */\n async increaseCurrentSizeInBytes(amount) {\n const size = await this.getCurrentCacheSize();\n await this.getStorage().setItem((0, utils_1.getCurrentSizeKey)(this.config.keyPrefix), (size + amount).toString());\n }\n /**\n * decrease current size of the cache\n *\n * @param amount - the amount of the cache size which needs to be decreased\n */\n async decreaseCurrentSizeInBytes(amount) {\n const size = await this.getCurrentCacheSize();\n await this.getStorage().setItem((0, utils_1.getCurrentSizeKey)(this.config.keyPrefix), (size - amount).toString());\n }\n /**\n * update the visited time if item has been visited\n *\n * @param item - the item which need to be updated\n * @param prefixedKey - the key of the item\n *\n * @return the updated item\n */\n async updateVisitedTime(item, prefixedKey) {\n item.visitedTime = (0, utils_1.getCurrentTime)();\n await this.getStorage().setItem(prefixedKey, JSON.stringify(item));\n return item;\n }\n /**\n * put item into cache\n *\n * @param prefixedKey - the key of the item\n * @param itemData - the value of the item\n * @param itemSizeInBytes - the byte size of the item\n */\n async setCacheItem(prefixedKey, item) {\n // first try to update the current size of the cache.\n await this.increaseCurrentSizeInBytes(item.byteSize);\n // try to add the item into cache\n try {\n await this.getStorage().setItem(prefixedKey, JSON.stringify(item));\n }\n catch (setItemErr) {\n // if some error happened, we need to rollback the current size\n await this.decreaseCurrentSizeInBytes(item.byteSize);\n logger.error(`Failed to set item ${setItemErr}`);\n }\n }\n /**\n * total space needed when poping out items\n *\n * @param itemSize\n *\n * @return total space needed\n */\n async sizeToPop(itemSize) {\n const cur = await this.getCurrentCacheSize();\n const spaceItemNeed = cur + itemSize - this.config.capacityInBytes;\n const cacheThresholdSpace = (1 - this.config.warningThreshold) * this.config.capacityInBytes;\n return spaceItemNeed > cacheThresholdSpace\n ? spaceItemNeed\n : cacheThresholdSpace;\n }\n /**\n * see whether cache is full\n *\n * @param itemSize\n *\n * @return true if cache is full\n */\n async isCacheFull(itemSize) {\n const cur = await this.getCurrentCacheSize();\n return itemSize + cur > this.config.capacityInBytes;\n }\n /**\n * get all the items we have, sort them by their priority,\n * if priority is same, sort them by their last visited time\n * pop out items from the low priority (5 is the lowest)\n * @private\n * @param keys - all the keys in this cache\n * @param sizeToPop - the total size of the items which needed to be poped out\n */\n async popOutItems(keys, sizeToPop) {\n const items = [];\n let remainedSize = sizeToPop;\n for (const key of keys) {\n const val = await this.getStorage().getItem(key);\n if (val != null) {\n const item = JSON.parse(val);\n items.push(item);\n }\n }\n // first compare priority\n // then compare visited time\n items.sort((a, b) => {\n if (a.priority > b.priority) {\n return -1;\n }\n else if (a.priority < b.priority) {\n return 1;\n }\n else {\n if (a.visitedTime < b.visitedTime) {\n return -1;\n }\n else\n return 1;\n }\n });\n for (const item of items) {\n // pop out items until we have enough room for new item\n await this.removeCacheItem(item.key, item.byteSize);\n remainedSize -= item.byteSize;\n if (remainedSize <= 0) {\n return;\n }\n }\n }\n /**\n * Scan the storage and combine the following operations for efficiency\n * 1. Clear out all expired keys owned by this cache, not including the size key.\n * 2. Return the remaining keys.\n *\n * @return The remaining valid keys\n */\n async clearInvalidAndGetRemainingKeys() {\n const remainingKeys = [];\n const keys = await this.getAllCacheKeys({\n omitSizeKey: true,\n });\n for (const key of keys) {\n if (await this.isExpired(key)) {\n await this.removeCacheItem(key);\n }\n else {\n remainingKeys.push(key);\n }\n }\n return remainingKeys;\n }\n /**\n * clear the entire cache\n * The cache will abort and output a warning if error occurs\n * @return {Promise}\n */\n async clear() {\n logger.debug(`Clear Cache`);\n try {\n const keys = await this.getAllKeys();\n for (const key of keys) {\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n await this.getStorage().removeItem(prefixedKey);\n }\n }\n catch (e) {\n logger.warn(`clear failed! ${e}`);\n }\n }\n}\nexports.StorageCacheCommon = StorageCacheCommon;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACtC,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACvD,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;AAC1D;AACA;AACA;AACA;AACA,MAAM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U,CAAC,WAAW,CAAC,CAAC;AAChE,aAAa;AACb,SAAS;AACT,QAAQ,OAAO,CAAC,EAAE;AAClB,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,SAAS;AACT,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -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.6.
|
|
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.6.6-events.538dd9f.0+538dd9f';\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,gCAAgC;;"}
|
|
@@ -131,6 +131,21 @@ function parseData(amplifyOutputsDataProperties) {
|
|
|
131
131
|
GraphQL,
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
+
function parseCustom(amplifyOutputsCustomProperties) {
|
|
135
|
+
if (!amplifyOutputsCustomProperties?.events) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const { url, aws_region, api_key, default_authorization_type } = amplifyOutputsCustomProperties.events;
|
|
139
|
+
const Events = {
|
|
140
|
+
endpoint: url,
|
|
141
|
+
defaultAuthMode: getGraphQLAuthMode(default_authorization_type),
|
|
142
|
+
region: aws_region,
|
|
143
|
+
apiKey: api_key,
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
Events,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
134
149
|
function parseNotifications(amplifyOutputsNotificationsProperties) {
|
|
135
150
|
if (!amplifyOutputsNotificationsProperties) {
|
|
136
151
|
return undefined;
|
|
@@ -178,6 +193,12 @@ function parseAmplifyOutputs(amplifyOutputs) {
|
|
|
178
193
|
if (amplifyOutputs.data) {
|
|
179
194
|
resourcesConfig.API = parseData(amplifyOutputs.data);
|
|
180
195
|
}
|
|
196
|
+
if (amplifyOutputs.custom) {
|
|
197
|
+
const customConfig = parseCustom(amplifyOutputs.custom);
|
|
198
|
+
if (customConfig && 'Events' in customConfig) {
|
|
199
|
+
resourcesConfig.API = { ...resourcesConfig.API, ...customConfig };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
181
202
|
if (amplifyOutputs.notifications) {
|
|
182
203
|
resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);
|
|
183
204
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseAmplifyOutputs.js","sources":["../../src/parseAmplifyOutputs.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.parseAmplifyOutputs = exports.parseAnalytics = exports.isAmplifyOutputs = void 0;\nfunction isAmplifyOutputs(config) {\n // version format initially will be '1' but is expected to be something like x.y where x is major and y minor version\n const { version } = config;\n if (!version) {\n return false;\n }\n return version.startsWith('1');\n}\nexports.isAmplifyOutputs = isAmplifyOutputs;\nfunction parseStorage(amplifyOutputsStorageProperties) {\n if (!amplifyOutputsStorageProperties) {\n return undefined;\n }\n const { bucket_name, aws_region, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\n },\n };\n}\nfunction parseAuth(amplifyOutputsAuthProperties) {\n if (!amplifyOutputsAuthProperties) {\n return undefined;\n }\n const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, } = amplifyOutputsAuthProperties;\n const authConfig = {\n Cognito: {\n userPoolId: user_pool_id,\n userPoolClientId: user_pool_client_id,\n },\n };\n if (identity_pool_id) {\n authConfig.Cognito = {\n ...authConfig.Cognito,\n identityPoolId: identity_pool_id,\n };\n }\n if (password_policy) {\n authConfig.Cognito.passwordFormat = {\n requireLowercase: password_policy.require_lowercase,\n requireNumbers: password_policy.require_numbers,\n requireUppercase: password_policy.require_uppercase,\n requireSpecialCharacters: password_policy.require_symbols,\n minLength: password_policy.min_length ?? 6,\n };\n }\n if (mfa_configuration) {\n authConfig.Cognito.mfa = {\n status: getMfaStatus(mfa_configuration),\n smsEnabled: mfa_methods?.includes('SMS'),\n totpEnabled: mfa_methods?.includes('TOTP'),\n };\n }\n if (unauthenticated_identities_enabled) {\n authConfig.Cognito.allowGuestAccess = unauthenticated_identities_enabled;\n }\n if (oauth) {\n authConfig.Cognito.loginWith = {\n oauth: {\n domain: oauth.domain,\n redirectSignIn: oauth.redirect_sign_in_uri,\n redirectSignOut: oauth.redirect_sign_out_uri,\n responseType: oauth.response_type === 'token' ? 'token' : 'code',\n scopes: oauth.scopes,\n providers: getOAuthProviders(oauth.identity_providers),\n },\n };\n }\n if (username_attributes) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\n };\n }\n if (standard_required_attributes) {\n authConfig.Cognito.userAttributes = standard_required_attributes.reduce((acc, curr) => ({ ...acc, [curr]: { required: true } }), {});\n }\n return authConfig;\n}\nfunction parseAnalytics(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties?.amazon_pinpoint) {\n return undefined;\n }\n const { amazon_pinpoint } = amplifyOutputsAnalyticsProperties;\n return {\n Pinpoint: {\n appId: amazon_pinpoint.app_id,\n region: amazon_pinpoint.aws_region,\n },\n };\n}\nexports.parseAnalytics = parseAnalytics;\nfunction parseGeo(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties) {\n return undefined;\n }\n const { aws_region, geofence_collections, maps, search_indices } = amplifyOutputsAnalyticsProperties;\n return {\n LocationService: {\n region: aws_region,\n searchIndices: search_indices,\n geofenceCollections: geofence_collections,\n maps,\n },\n };\n}\nfunction parseData(amplifyOutputsDataProperties) {\n if (!amplifyOutputsDataProperties) {\n return undefined;\n }\n const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;\n const GraphQL = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n modelIntrospection: model_introspection,\n };\n return {\n GraphQL,\n };\n}\nfunction parseNotifications(amplifyOutputsNotificationsProperties) {\n if (!amplifyOutputsNotificationsProperties) {\n return undefined;\n }\n const { aws_region, channels, amazon_pinpoint_app_id } = amplifyOutputsNotificationsProperties;\n const hasInAppMessaging = channels.includes('IN_APP_MESSAGING');\n const hasPushNotification = channels.includes('APNS') || channels.includes('FCM');\n if (!(hasInAppMessaging || hasPushNotification)) {\n return undefined;\n }\n // At this point, we know the Amplify outputs contains at least one supported channel\n const notificationsConfig = {};\n if (hasInAppMessaging) {\n notificationsConfig.InAppMessaging = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n if (hasPushNotification) {\n notificationsConfig.PushNotification = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n return notificationsConfig;\n}\nfunction parseAmplifyOutputs(amplifyOutputs) {\n const resourcesConfig = {};\n if (amplifyOutputs.storage) {\n resourcesConfig.Storage = parseStorage(amplifyOutputs.storage);\n }\n if (amplifyOutputs.auth) {\n resourcesConfig.Auth = parseAuth(amplifyOutputs.auth);\n }\n if (amplifyOutputs.analytics) {\n resourcesConfig.Analytics = parseAnalytics(amplifyOutputs.analytics);\n }\n if (amplifyOutputs.geo) {\n resourcesConfig.Geo = parseGeo(amplifyOutputs.geo);\n }\n if (amplifyOutputs.data) {\n resourcesConfig.API = parseData(amplifyOutputs.data);\n }\n if (amplifyOutputs.notifications) {\n resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);\n }\n return resourcesConfig;\n}\nexports.parseAmplifyOutputs = parseAmplifyOutputs;\nconst authModeNames = {\n AMAZON_COGNITO_USER_POOLS: 'userPool',\n API_KEY: 'apiKey',\n AWS_IAM: 'iam',\n AWS_LAMBDA: 'lambda',\n OPENID_CONNECT: 'oidc',\n};\nfunction getGraphQLAuthMode(authType) {\n return authModeNames[authType];\n}\nconst providerNames = {\n GOOGLE: 'Google',\n LOGIN_WITH_AMAZON: 'Amazon',\n FACEBOOK: 'Facebook',\n SIGN_IN_WITH_APPLE: 'Apple',\n};\nfunction getOAuthProviders(providers = []) {\n return providers.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n };\n });\n return mappedBuckets;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO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D,SAAS,YAAY,CAAC,gBAAgB,EAAE;AACxC,IAAI,IAAI,gBAAgB,KAAK,UAAU;AACvC,QAAQ,OAAO,UAAU,CAAC;AAC1B,IAAI,IAAI,gBAAgB,KAAK,UAAU;AACvC,QAAQ,OAAO,IAAI,CAAC;AACpB,IAAI,OAAO,KAAK,CAAC;AACjB,CAAC;AACD,SAAS,mBAAmB,CAAC,OAAO,EAAE;AACtC,IAAI,MAAM,aAAa,GAAG,EAAE,CAAC;AAC7B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK;AAC/E,QAAQ,IAAI,IAAI,IAAI,aAAa,EAAE;AACnC,YAAY,MAAM,IAAI,KAAK,CAAC,CAAC,+BAA+B,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC5F,SAAS;AACT,QAAQ,aAAa,CAAC,IAAI,CAAC,GAAG;AAC9B,YAAY,UAAU;AACtB,YAAY,MAAM;AAClB,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,aAAa,CAAC;AACzB;;"}
|
|
1
|
+
{"version":3,"file":"parseAmplifyOutputs.js","sources":["../../src/parseAmplifyOutputs.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.parseAmplifyOutputs = exports.parseAnalytics = exports.isAmplifyOutputs = void 0;\nfunction isAmplifyOutputs(config) {\n // version format initially will be '1' but is expected to be something like x.y where x is major and y minor version\n const { version } = config;\n if (!version) {\n return false;\n }\n return version.startsWith('1');\n}\nexports.isAmplifyOutputs = isAmplifyOutputs;\nfunction parseStorage(amplifyOutputsStorageProperties) {\n if (!amplifyOutputsStorageProperties) {\n return undefined;\n }\n const { bucket_name, aws_region, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\n },\n };\n}\nfunction parseAuth(amplifyOutputsAuthProperties) {\n if (!amplifyOutputsAuthProperties) {\n return undefined;\n }\n const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, } = amplifyOutputsAuthProperties;\n const authConfig = {\n Cognito: {\n userPoolId: user_pool_id,\n userPoolClientId: user_pool_client_id,\n },\n };\n if (identity_pool_id) {\n authConfig.Cognito = {\n ...authConfig.Cognito,\n identityPoolId: identity_pool_id,\n };\n }\n if (password_policy) {\n authConfig.Cognito.passwordFormat = {\n requireLowercase: password_policy.require_lowercase,\n requireNumbers: password_policy.require_numbers,\n requireUppercase: password_policy.require_uppercase,\n requireSpecialCharacters: password_policy.require_symbols,\n minLength: password_policy.min_length ?? 6,\n };\n }\n if (mfa_configuration) {\n authConfig.Cognito.mfa = {\n status: getMfaStatus(mfa_configuration),\n smsEnabled: mfa_methods?.includes('SMS'),\n totpEnabled: mfa_methods?.includes('TOTP'),\n };\n }\n if (unauthenticated_identities_enabled) {\n authConfig.Cognito.allowGuestAccess = unauthenticated_identities_enabled;\n }\n if (oauth) {\n authConfig.Cognito.loginWith = {\n oauth: {\n domain: oauth.domain,\n redirectSignIn: oauth.redirect_sign_in_uri,\n redirectSignOut: oauth.redirect_sign_out_uri,\n responseType: oauth.response_type === 'token' ? 'token' : 'code',\n scopes: oauth.scopes,\n providers: getOAuthProviders(oauth.identity_providers),\n },\n };\n }\n if (username_attributes) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\n };\n }\n if (standard_required_attributes) {\n authConfig.Cognito.userAttributes = standard_required_attributes.reduce((acc, curr) => ({ ...acc, [curr]: { required: true } }), {});\n }\n return authConfig;\n}\nfunction parseAnalytics(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties?.amazon_pinpoint) {\n return undefined;\n }\n const { amazon_pinpoint } = amplifyOutputsAnalyticsProperties;\n return {\n Pinpoint: {\n appId: amazon_pinpoint.app_id,\n region: amazon_pinpoint.aws_region,\n },\n };\n}\nexports.parseAnalytics = parseAnalytics;\nfunction parseGeo(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties) {\n return undefined;\n }\n const { aws_region, geofence_collections, maps, search_indices } = amplifyOutputsAnalyticsProperties;\n return {\n LocationService: {\n region: aws_region,\n searchIndices: search_indices,\n geofenceCollections: geofence_collections,\n maps,\n },\n };\n}\nfunction parseData(amplifyOutputsDataProperties) {\n if (!amplifyOutputsDataProperties) {\n return undefined;\n }\n const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;\n const GraphQL = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n modelIntrospection: model_introspection,\n };\n return {\n GraphQL,\n };\n}\nfunction parseCustom(amplifyOutputsCustomProperties) {\n if (!amplifyOutputsCustomProperties?.events) {\n return undefined;\n }\n const { url, aws_region, api_key, default_authorization_type } = amplifyOutputsCustomProperties.events;\n const Events = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n };\n return {\n Events,\n };\n}\nfunction parseNotifications(amplifyOutputsNotificationsProperties) {\n if (!amplifyOutputsNotificationsProperties) {\n return undefined;\n }\n const { aws_region, channels, amazon_pinpoint_app_id } = amplifyOutputsNotificationsProperties;\n const hasInAppMessaging = channels.includes('IN_APP_MESSAGING');\n const hasPushNotification = channels.includes('APNS') || channels.includes('FCM');\n if (!(hasInAppMessaging || hasPushNotification)) {\n return undefined;\n }\n // At this point, we know the Amplify outputs contains at least one supported channel\n const notificationsConfig = {};\n if (hasInAppMessaging) {\n notificationsConfig.InAppMessaging = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n if (hasPushNotification) {\n notificationsConfig.PushNotification = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n return notificationsConfig;\n}\nfunction parseAmplifyOutputs(amplifyOutputs) {\n const resourcesConfig = {};\n if (amplifyOutputs.storage) {\n resourcesConfig.Storage = parseStorage(amplifyOutputs.storage);\n }\n if (amplifyOutputs.auth) {\n resourcesConfig.Auth = parseAuth(amplifyOutputs.auth);\n }\n if (amplifyOutputs.analytics) {\n resourcesConfig.Analytics = parseAnalytics(amplifyOutputs.analytics);\n }\n if (amplifyOutputs.geo) {\n resourcesConfig.Geo = parseGeo(amplifyOutputs.geo);\n }\n if (amplifyOutputs.data) {\n resourcesConfig.API = parseData(amplifyOutputs.data);\n }\n if (amplifyOutputs.custom) {\n const customConfig = parseCustom(amplifyOutputs.custom);\n if (customConfig && 'Events' in customConfig) {\n resourcesConfig.API = { ...resourcesConfig.API, ...customConfig };\n }\n }\n if (amplifyOutputs.notifications) {\n resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);\n }\n return resourcesConfig;\n}\nexports.parseAmplifyOutputs = parseAmplifyOutputs;\nconst authModeNames = {\n AMAZON_COGNITO_USER_POOLS: 'userPool',\n API_KEY: 'apiKey',\n AWS_IAM: 'iam',\n AWS_LAMBDA: 'lambda',\n OPENID_CONNECT: 'oidc',\n};\nfunction getGraphQLAuthMode(authType) {\n return authModeNames[authType];\n}\nconst providerNames = {\n GOOGLE: 'Google',\n LOGIN_WITH_AMAZON: 'Amazon',\n FACEBOOK: 'Facebook',\n SIGN_IN_WITH_APPLE: 'Apple',\n};\nfunction getOAuthProviders(providers = []) {\n return providers.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n };\n });\n return mappedBuckets;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AACzF,SAAS,gBAAgB,CAAC,MAAM,EAAE;AAClC;AACA,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AAC/B,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AACD,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C,SAAS,YAAY,CAAC,+BAA+B,EAAE;AACvD,IAAI,IAAI,CAAC,+BAA+B,EAAE;AAC1C,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,+BAA+B,CAAC;AACjF,IAAI,OAAO;AACX,QAAQ,EAAE,EAAE;AACZ,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,MAAM,EAAE,UAAU;AAC9B,YAAY,OAAO,EAAE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC;AAC5D,SAAS;AACT,KAAK,CAAC;AACN,CAAC;AACD,S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AK,EAAE,EAAE,CAAC,CAAC;AACX,CAAC;AACD,SAAS,YAAY,CAAC,gBAAgB,EAAE;AACxC,IAAI,IAAI,gBAAgB,KAAK,UAAU;AACvC,QAAQ,OAAO,UAAU,CAAC;AAC1B,IAAI,IAAI,gBAAgB,KAAK,UAAU;AACvC,QAAQ,OAAO,IAAI,CAAC;AACpB,IAAI,OAAO,KAAK,CAAC;AACjB,CAAC;AACD,SAAS,mBAAmB,CAAC,OAAO,EAAE;AACtC,IAAI,MAAM,aAAa,GAAG,EAAE,CAAC;AAC7B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK;AAC/E,QAAQ,IAAI,IAAI,IAAI,aAAa,EAAE;AACnC,YAAY,MAAM,IAAI,KAAK,CAAC,CAAC,+BAA+B,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC5F,SAAS;AACT,QAAQ,aAAa,CAAC,IAAI,CAAC,GAAG;AAC9B,YAAY,UAAU;AACtB,YAAY,MAAM;AAClB,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,aAAa,CAAC;AACzB;;"}
|
|
@@ -455,7 +455,8 @@ class StorageCacheCommon {
|
|
|
455
455
|
try {
|
|
456
456
|
const keys = await this.getAllKeys();
|
|
457
457
|
for (const key of keys) {
|
|
458
|
-
|
|
458
|
+
const prefixedKey = `${this.config.keyPrefix}${key}`;
|
|
459
|
+
await this.getStorage().removeItem(prefixedKey);
|
|
459
460
|
}
|
|
460
461
|
}
|
|
461
462
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageCacheCommon.mjs","sources":["../../../src/Cache/StorageCacheCommon.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../Logger';\nimport { currentSizeKey, defaultConfig } from './constants';\nimport { getByteLength, getCurrentSizeKey, getCurrentTime } from './utils';\nimport { CacheErrorCode, assert } from './utils/errorHelpers';\nconst logger = new ConsoleLogger('StorageCache');\n/**\n * Initialization of the cache\n *\n */\nexport class StorageCacheCommon {\n /**\n * Initialize the cache\n *\n * @param config - Custom configuration for this instance.\n */\n constructor({ config, keyValueStorage, }) {\n this.config = {\n ...defaultConfig,\n ...config,\n };\n this.keyValueStorage = keyValueStorage;\n this.sanitizeConfig();\n }\n getModuleName() {\n return 'Cache';\n }\n /**\n * Set custom configuration for the cache instance.\n *\n * @param config - customized configuration (without keyPrefix, which can't be changed)\n *\n * @return - the current configuration\n */\n configure(config) {\n if (config) {\n if (config.keyPrefix) {\n logger.warn('keyPrefix can not be re-configured on an existing Cache instance.');\n }\n this.config = {\n ...this.config,\n ...config,\n };\n }\n this.sanitizeConfig();\n return this.config;\n }\n /**\n * return the current size of the cache\n * @return {Promise}\n */\n async getCurrentCacheSize() {\n let size = await this.getStorage().getItem(getCurrentSizeKey(this.config.keyPrefix));\n if (!size) {\n await this.getStorage().setItem(getCurrentSizeKey(this.config.keyPrefix), '0');\n size = '0';\n }\n return Number(size);\n }\n /**\n * Set item into cache. You can put number, string, boolean or object.\n * The cache will first check whether has the same key.\n * If it has, it will delete the old item and then put the new item in\n * The cache will pop out items if it is full\n * You can specify the cache item options. The cache will abort and output a warning:\n * If the key is invalid\n * If the size of the item exceeds itemMaxSize.\n * If the value is undefined\n * If incorrect cache item configuration\n * If error happened with browser storage\n *\n * @param {String} key - the key of the item\n * @param {Object} value - the value of the item\n * @param {Object} [options] - optional, the specified meta-data\n *\n * @return {Promise}\n */\n async setItem(key, value, options) {\n logger.debug(`Set item: key is ${key}, value is ${value} with options: ${options}`);\n if (!key || key === currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${currentSizeKey}'`);\n return;\n }\n if (typeof value === 'undefined') {\n logger.warn(`The value of item should not be undefined!`);\n return;\n }\n const cacheItemOptions = {\n priority: options?.priority !== undefined\n ? options.priority\n : this.config.defaultPriority,\n expires: options?.expires !== undefined\n ? options.expires\n : this.config.defaultTTL + getCurrentTime(),\n };\n if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {\n logger.warn(`Invalid parameter: priority due to out or range. It should be within 1 and 5.`);\n return;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n const item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);\n // check whether this item is too big;\n if (item.byteSize > this.config.itemMaxSize) {\n logger.warn(`Item with key: ${key} you are trying to put into is too big!`);\n return;\n }\n try {\n // first look into the storage, if it exists, delete it.\n const val = await this.getStorage().getItem(prefixedKey);\n if (val) {\n await this.removeCacheItem(prefixedKey, JSON.parse(val).byteSize);\n }\n // check whether the cache is full\n if (await this.isCacheFull(item.byteSize)) {\n const validKeys = await this.clearInvalidAndGetRemainingKeys();\n if (await this.isCacheFull(item.byteSize)) {\n const sizeToPop = await this.sizeToPop(item.byteSize);\n await this.popOutItems(validKeys, sizeToPop);\n }\n }\n // put item in the cache\n return this.setCacheItem(prefixedKey, item);\n }\n catch (e) {\n logger.warn(`setItem failed! ${e}`);\n }\n }\n /**\n * Get item from cache. It will return null if item doesn’t exist or it has been expired.\n * If you specified callback function in the options,\n * then the function will be executed if no such item in the cache\n * and finally put the return value into cache.\n * Please make sure the callback function will return the value you want to put into the cache.\n * The cache will abort output a warning:\n * If the key is invalid\n * If error happened with AsyncStorage\n *\n * @param {String} key - the key of the item\n * @param {Object} [options] - the options of callback function\n *\n * @return {Promise} - return a promise resolves to be the value of the item\n */\n async getItem(key, options) {\n logger.debug(`Get item: key is ${key} with options ${options}`);\n let cached;\n if (!key || key === currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${currentSizeKey}'`);\n return null;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n try {\n cached = await this.getStorage().getItem(prefixedKey);\n if (cached != null) {\n if (await this.isExpired(prefixedKey)) {\n // if expired, remove that item and return null\n await this.removeCacheItem(prefixedKey, JSON.parse(cached).byteSize);\n }\n else {\n // if not expired, update its visitedTime and return the value\n const item = await this.updateVisitedTime(JSON.parse(cached), prefixedKey);\n return item.data;\n }\n }\n if (options?.callback) {\n const val = options.callback();\n if (val !== null) {\n await this.setItem(key, val, options);\n }\n return val;\n }\n return null;\n }\n catch (e) {\n logger.warn(`getItem failed! ${e}`);\n return null;\n }\n }\n /**\n * remove item from the cache\n * The cache will abort output a warning:\n * If error happened with AsyncStorage\n * @param {String} key - the key of the item\n * @return {Promise}\n */\n async removeItem(key) {\n logger.debug(`Remove item: key is ${key}`);\n if (!key || key === currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${currentSizeKey}'`);\n return;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n try {\n const val = await this.getStorage().getItem(prefixedKey);\n if (val) {\n await this.removeCacheItem(prefixedKey, JSON.parse(val).byteSize);\n }\n }\n catch (e) {\n logger.warn(`removeItem failed! ${e}`);\n }\n }\n /**\n * Return all the keys owned by this cache.\n * Will return an empty array if error occurred.\n *\n * @return {Promise}\n */\n async getAllKeys() {\n try {\n return await this.getAllCacheKeys();\n }\n catch (e) {\n logger.warn(`getAllkeys failed! ${e}`);\n return [];\n }\n }\n getStorage() {\n return this.keyValueStorage;\n }\n /**\n * check whether item is expired\n *\n * @param key - the key of the item\n *\n * @return true if the item is expired.\n */\n async isExpired(key) {\n const text = await this.getStorage().getItem(key);\n assert(text !== null, CacheErrorCode.NoCacheItem, `Key: ${key}`);\n const item = JSON.parse(text);\n if (getCurrentTime() >= item.expires) {\n return true;\n }\n return false;\n }\n /**\n * delete item from cache\n *\n * @param prefixedKey - the key of the item\n * @param size - optional, the byte size of the item\n */\n async removeCacheItem(prefixedKey, size) {\n const item = await this.getStorage().getItem(prefixedKey);\n assert(item !== null, CacheErrorCode.NoCacheItem, `Key: ${prefixedKey}`);\n const itemSize = size ?? JSON.parse(item).byteSize;\n // first try to update the current size of the cache\n await this.decreaseCurrentSizeInBytes(itemSize);\n // try to remove the item from cache\n try {\n await this.getStorage().removeItem(prefixedKey);\n }\n catch (removeItemError) {\n // if some error happened, we need to rollback the current size\n await this.increaseCurrentSizeInBytes(itemSize);\n logger.error(`Failed to remove item: ${removeItemError}`);\n }\n }\n /**\n * produce a JSON object with meta-data and data value\n * @param value - the value of the item\n * @param options - optional, the specified meta-data\n *\n * @return - the item which has the meta-data and the value\n */\n fillCacheItem(key, value, options) {\n const item = {\n key,\n data: value,\n timestamp: getCurrentTime(),\n visitedTime: getCurrentTime(),\n priority: options.priority ?? 0,\n expires: options.expires ?? 0,\n type: typeof value,\n byteSize: 0,\n };\n // calculate byte size\n item.byteSize = getByteLength(JSON.stringify(item));\n // re-calculate using cache item with updated byteSize property\n item.byteSize = getByteLength(JSON.stringify(item));\n return item;\n }\n sanitizeConfig() {\n if (this.config.itemMaxSize > this.config.capacityInBytes) {\n logger.error('Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default.');\n this.config.itemMaxSize = defaultConfig.itemMaxSize;\n }\n if (this.config.defaultPriority > 5 || this.config.defaultPriority < 1) {\n logger.error('Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default.');\n this.config.defaultPriority = defaultConfig.defaultPriority;\n }\n if (Number(this.config.warningThreshold) > 1 ||\n Number(this.config.warningThreshold) < 0) {\n logger.error('Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default.');\n this.config.warningThreshold = defaultConfig.warningThreshold;\n }\n // Set 5MB limit\n const cacheLimit = 5 * 1024 * 1024;\n if (this.config.capacityInBytes > cacheLimit) {\n logger.error('Cache Capacity should be less than 5MB. Setting back to default. Setting back to default.');\n this.config.capacityInBytes = defaultConfig.capacityInBytes;\n }\n }\n /**\n * increase current size of the cache\n *\n * @param amount - the amount of the cache szie which need to be increased\n */\n async increaseCurrentSizeInBytes(amount) {\n const size = await this.getCurrentCacheSize();\n await this.getStorage().setItem(getCurrentSizeKey(this.config.keyPrefix), (size + amount).toString());\n }\n /**\n * decrease current size of the cache\n *\n * @param amount - the amount of the cache size which needs to be decreased\n */\n async decreaseCurrentSizeInBytes(amount) {\n const size = await this.getCurrentCacheSize();\n await this.getStorage().setItem(getCurrentSizeKey(this.config.keyPrefix), (size - amount).toString());\n }\n /**\n * update the visited time if item has been visited\n *\n * @param item - the item which need to be updated\n * @param prefixedKey - the key of the item\n *\n * @return the updated item\n */\n async updateVisitedTime(item, prefixedKey) {\n item.visitedTime = getCurrentTime();\n await this.getStorage().setItem(prefixedKey, JSON.stringify(item));\n return item;\n }\n /**\n * put item into cache\n *\n * @param prefixedKey - the key of the item\n * @param itemData - the value of the item\n * @param itemSizeInBytes - the byte size of the item\n */\n async setCacheItem(prefixedKey, item) {\n // first try to update the current size of the cache.\n await this.increaseCurrentSizeInBytes(item.byteSize);\n // try to add the item into cache\n try {\n await this.getStorage().setItem(prefixedKey, JSON.stringify(item));\n }\n catch (setItemErr) {\n // if some error happened, we need to rollback the current size\n await this.decreaseCurrentSizeInBytes(item.byteSize);\n logger.error(`Failed to set item ${setItemErr}`);\n }\n }\n /**\n * total space needed when poping out items\n *\n * @param itemSize\n *\n * @return total space needed\n */\n async sizeToPop(itemSize) {\n const cur = await this.getCurrentCacheSize();\n const spaceItemNeed = cur + itemSize - this.config.capacityInBytes;\n const cacheThresholdSpace = (1 - this.config.warningThreshold) * this.config.capacityInBytes;\n return spaceItemNeed > cacheThresholdSpace\n ? spaceItemNeed\n : cacheThresholdSpace;\n }\n /**\n * see whether cache is full\n *\n * @param itemSize\n *\n * @return true if cache is full\n */\n async isCacheFull(itemSize) {\n const cur = await this.getCurrentCacheSize();\n return itemSize + cur > this.config.capacityInBytes;\n }\n /**\n * get all the items we have, sort them by their priority,\n * if priority is same, sort them by their last visited time\n * pop out items from the low priority (5 is the lowest)\n * @private\n * @param keys - all the keys in this cache\n * @param sizeToPop - the total size of the items which needed to be poped out\n */\n async popOutItems(keys, sizeToPop) {\n const items = [];\n let remainedSize = sizeToPop;\n for (const key of keys) {\n const val = await this.getStorage().getItem(key);\n if (val != null) {\n const item = JSON.parse(val);\n items.push(item);\n }\n }\n // first compare priority\n // then compare visited time\n items.sort((a, b) => {\n if (a.priority > b.priority) {\n return -1;\n }\n else if (a.priority < b.priority) {\n return 1;\n }\n else {\n if (a.visitedTime < b.visitedTime) {\n return -1;\n }\n else\n return 1;\n }\n });\n for (const item of items) {\n // pop out items until we have enough room for new item\n await this.removeCacheItem(item.key, item.byteSize);\n remainedSize -= item.byteSize;\n if (remainedSize <= 0) {\n return;\n }\n }\n }\n /**\n * Scan the storage and combine the following operations for efficiency\n * 1. Clear out all expired keys owned by this cache, not including the size key.\n * 2. Return the remaining keys.\n *\n * @return The remaining valid keys\n */\n async clearInvalidAndGetRemainingKeys() {\n const remainingKeys = [];\n const keys = await this.getAllCacheKeys({\n omitSizeKey: true,\n });\n for (const key of keys) {\n if (await this.isExpired(key)) {\n await this.removeCacheItem(key);\n }\n else {\n remainingKeys.push(key);\n }\n }\n return remainingKeys;\n }\n /**\n * clear the entire cache\n * The cache will abort and output a warning if error occurs\n * @return {Promise}\n */\n async clear() {\n logger.debug(`Clear Cache`);\n try {\n const keys = await this.getAllKeys();\n for (const key of keys) {\n await this.getStorage().removeItem(key);\n }\n }\n catch (e) {\n logger.warn(`clear failed! ${e}`);\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC;AACjD;AACA;AACA;AACA;AACO,MAAM,kBAAkB,CAAC;AAChC;AACA;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,EAAE;AAC9C,QAAQ,IAAI,CAAC,MAAM,GAAG;AACtB,YAAY,GAAG,aAAa;AAC5B,YAAY,GAAG,MAAM;AACrB,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;AAC/C,QAAQ,IAAI,CAAC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;AAChD,aAAa;AACb,iBAAiB;AACjB,gBAAgB,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,aAAa;AACb,SAAS;AACT,QAAQ,OAAO,aAAa,CAAC;AAC7B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AACpC,QAAQ,IAAI;AACZ,YAAY,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;AACjD,YAAY,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AACpC,gBAAgB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACxD,aAAa;AACb,SAAS;AACT,QAAQ,OAAO,CAAC,EAAE;AAClB,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,SAAS;AACT,KAAK;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"StorageCacheCommon.mjs","sources":["../../../src/Cache/StorageCacheCommon.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../Logger';\nimport { currentSizeKey, defaultConfig } from './constants';\nimport { getByteLength, getCurrentSizeKey, getCurrentTime } from './utils';\nimport { CacheErrorCode, assert } from './utils/errorHelpers';\nconst logger = new ConsoleLogger('StorageCache');\n/**\n * Initialization of the cache\n *\n */\nexport class StorageCacheCommon {\n /**\n * Initialize the cache\n *\n * @param config - Custom configuration for this instance.\n */\n constructor({ config, keyValueStorage, }) {\n this.config = {\n ...defaultConfig,\n ...config,\n };\n this.keyValueStorage = keyValueStorage;\n this.sanitizeConfig();\n }\n getModuleName() {\n return 'Cache';\n }\n /**\n * Set custom configuration for the cache instance.\n *\n * @param config - customized configuration (without keyPrefix, which can't be changed)\n *\n * @return - the current configuration\n */\n configure(config) {\n if (config) {\n if (config.keyPrefix) {\n logger.warn('keyPrefix can not be re-configured on an existing Cache instance.');\n }\n this.config = {\n ...this.config,\n ...config,\n };\n }\n this.sanitizeConfig();\n return this.config;\n }\n /**\n * return the current size of the cache\n * @return {Promise}\n */\n async getCurrentCacheSize() {\n let size = await this.getStorage().getItem(getCurrentSizeKey(this.config.keyPrefix));\n if (!size) {\n await this.getStorage().setItem(getCurrentSizeKey(this.config.keyPrefix), '0');\n size = '0';\n }\n return Number(size);\n }\n /**\n * Set item into cache. You can put number, string, boolean or object.\n * The cache will first check whether has the same key.\n * If it has, it will delete the old item and then put the new item in\n * The cache will pop out items if it is full\n * You can specify the cache item options. The cache will abort and output a warning:\n * If the key is invalid\n * If the size of the item exceeds itemMaxSize.\n * If the value is undefined\n * If incorrect cache item configuration\n * If error happened with browser storage\n *\n * @param {String} key - the key of the item\n * @param {Object} value - the value of the item\n * @param {Object} [options] - optional, the specified meta-data\n *\n * @return {Promise}\n */\n async setItem(key, value, options) {\n logger.debug(`Set item: key is ${key}, value is ${value} with options: ${options}`);\n if (!key || key === currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${currentSizeKey}'`);\n return;\n }\n if (typeof value === 'undefined') {\n logger.warn(`The value of item should not be undefined!`);\n return;\n }\n const cacheItemOptions = {\n priority: options?.priority !== undefined\n ? options.priority\n : this.config.defaultPriority,\n expires: options?.expires !== undefined\n ? options.expires\n : this.config.defaultTTL + getCurrentTime(),\n };\n if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {\n logger.warn(`Invalid parameter: priority due to out or range. It should be within 1 and 5.`);\n return;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n const item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);\n // check whether this item is too big;\n if (item.byteSize > this.config.itemMaxSize) {\n logger.warn(`Item with key: ${key} you are trying to put into is too big!`);\n return;\n }\n try {\n // first look into the storage, if it exists, delete it.\n const val = await this.getStorage().getItem(prefixedKey);\n if (val) {\n await this.removeCacheItem(prefixedKey, JSON.parse(val).byteSize);\n }\n // check whether the cache is full\n if (await this.isCacheFull(item.byteSize)) {\n const validKeys = await this.clearInvalidAndGetRemainingKeys();\n if (await this.isCacheFull(item.byteSize)) {\n const sizeToPop = await this.sizeToPop(item.byteSize);\n await this.popOutItems(validKeys, sizeToPop);\n }\n }\n // put item in the cache\n return this.setCacheItem(prefixedKey, item);\n }\n catch (e) {\n logger.warn(`setItem failed! ${e}`);\n }\n }\n /**\n * Get item from cache. It will return null if item doesn’t exist or it has been expired.\n * If you specified callback function in the options,\n * then the function will be executed if no such item in the cache\n * and finally put the return value into cache.\n * Please make sure the callback function will return the value you want to put into the cache.\n * The cache will abort output a warning:\n * If the key is invalid\n * If error happened with AsyncStorage\n *\n * @param {String} key - the key of the item\n * @param {Object} [options] - the options of callback function\n *\n * @return {Promise} - return a promise resolves to be the value of the item\n */\n async getItem(key, options) {\n logger.debug(`Get item: key is ${key} with options ${options}`);\n let cached;\n if (!key || key === currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${currentSizeKey}'`);\n return null;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n try {\n cached = await this.getStorage().getItem(prefixedKey);\n if (cached != null) {\n if (await this.isExpired(prefixedKey)) {\n // if expired, remove that item and return null\n await this.removeCacheItem(prefixedKey, JSON.parse(cached).byteSize);\n }\n else {\n // if not expired, update its visitedTime and return the value\n const item = await this.updateVisitedTime(JSON.parse(cached), prefixedKey);\n return item.data;\n }\n }\n if (options?.callback) {\n const val = options.callback();\n if (val !== null) {\n await this.setItem(key, val, options);\n }\n return val;\n }\n return null;\n }\n catch (e) {\n logger.warn(`getItem failed! ${e}`);\n return null;\n }\n }\n /**\n * remove item from the cache\n * The cache will abort output a warning:\n * If error happened with AsyncStorage\n * @param {String} key - the key of the item\n * @return {Promise}\n */\n async removeItem(key) {\n logger.debug(`Remove item: key is ${key}`);\n if (!key || key === currentSizeKey) {\n logger.warn(`Invalid key: should not be empty or reserved key: '${currentSizeKey}'`);\n return;\n }\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n try {\n const val = await this.getStorage().getItem(prefixedKey);\n if (val) {\n await this.removeCacheItem(prefixedKey, JSON.parse(val).byteSize);\n }\n }\n catch (e) {\n logger.warn(`removeItem failed! ${e}`);\n }\n }\n /**\n * Return all the keys owned by this cache.\n * Will return an empty array if error occurred.\n *\n * @return {Promise}\n */\n async getAllKeys() {\n try {\n return await this.getAllCacheKeys();\n }\n catch (e) {\n logger.warn(`getAllkeys failed! ${e}`);\n return [];\n }\n }\n getStorage() {\n return this.keyValueStorage;\n }\n /**\n * check whether item is expired\n *\n * @param key - the key of the item\n *\n * @return true if the item is expired.\n */\n async isExpired(key) {\n const text = await this.getStorage().getItem(key);\n assert(text !== null, CacheErrorCode.NoCacheItem, `Key: ${key}`);\n const item = JSON.parse(text);\n if (getCurrentTime() >= item.expires) {\n return true;\n }\n return false;\n }\n /**\n * delete item from cache\n *\n * @param prefixedKey - the key of the item\n * @param size - optional, the byte size of the item\n */\n async removeCacheItem(prefixedKey, size) {\n const item = await this.getStorage().getItem(prefixedKey);\n assert(item !== null, CacheErrorCode.NoCacheItem, `Key: ${prefixedKey}`);\n const itemSize = size ?? JSON.parse(item).byteSize;\n // first try to update the current size of the cache\n await this.decreaseCurrentSizeInBytes(itemSize);\n // try to remove the item from cache\n try {\n await this.getStorage().removeItem(prefixedKey);\n }\n catch (removeItemError) {\n // if some error happened, we need to rollback the current size\n await this.increaseCurrentSizeInBytes(itemSize);\n logger.error(`Failed to remove item: ${removeItemError}`);\n }\n }\n /**\n * produce a JSON object with meta-data and data value\n * @param value - the value of the item\n * @param options - optional, the specified meta-data\n *\n * @return - the item which has the meta-data and the value\n */\n fillCacheItem(key, value, options) {\n const item = {\n key,\n data: value,\n timestamp: getCurrentTime(),\n visitedTime: getCurrentTime(),\n priority: options.priority ?? 0,\n expires: options.expires ?? 0,\n type: typeof value,\n byteSize: 0,\n };\n // calculate byte size\n item.byteSize = getByteLength(JSON.stringify(item));\n // re-calculate using cache item with updated byteSize property\n item.byteSize = getByteLength(JSON.stringify(item));\n return item;\n }\n sanitizeConfig() {\n if (this.config.itemMaxSize > this.config.capacityInBytes) {\n logger.error('Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default.');\n this.config.itemMaxSize = defaultConfig.itemMaxSize;\n }\n if (this.config.defaultPriority > 5 || this.config.defaultPriority < 1) {\n logger.error('Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default.');\n this.config.defaultPriority = defaultConfig.defaultPriority;\n }\n if (Number(this.config.warningThreshold) > 1 ||\n Number(this.config.warningThreshold) < 0) {\n logger.error('Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default.');\n this.config.warningThreshold = defaultConfig.warningThreshold;\n }\n // Set 5MB limit\n const cacheLimit = 5 * 1024 * 1024;\n if (this.config.capacityInBytes > cacheLimit) {\n logger.error('Cache Capacity should be less than 5MB. Setting back to default. Setting back to default.');\n this.config.capacityInBytes = defaultConfig.capacityInBytes;\n }\n }\n /**\n * increase current size of the cache\n *\n * @param amount - the amount of the cache szie which need to be increased\n */\n async increaseCurrentSizeInBytes(amount) {\n const size = await this.getCurrentCacheSize();\n await this.getStorage().setItem(getCurrentSizeKey(this.config.keyPrefix), (size + amount).toString());\n }\n /**\n * decrease current size of the cache\n *\n * @param amount - the amount of the cache size which needs to be decreased\n */\n async decreaseCurrentSizeInBytes(amount) {\n const size = await this.getCurrentCacheSize();\n await this.getStorage().setItem(getCurrentSizeKey(this.config.keyPrefix), (size - amount).toString());\n }\n /**\n * update the visited time if item has been visited\n *\n * @param item - the item which need to be updated\n * @param prefixedKey - the key of the item\n *\n * @return the updated item\n */\n async updateVisitedTime(item, prefixedKey) {\n item.visitedTime = getCurrentTime();\n await this.getStorage().setItem(prefixedKey, JSON.stringify(item));\n return item;\n }\n /**\n * put item into cache\n *\n * @param prefixedKey - the key of the item\n * @param itemData - the value of the item\n * @param itemSizeInBytes - the byte size of the item\n */\n async setCacheItem(prefixedKey, item) {\n // first try to update the current size of the cache.\n await this.increaseCurrentSizeInBytes(item.byteSize);\n // try to add the item into cache\n try {\n await this.getStorage().setItem(prefixedKey, JSON.stringify(item));\n }\n catch (setItemErr) {\n // if some error happened, we need to rollback the current size\n await this.decreaseCurrentSizeInBytes(item.byteSize);\n logger.error(`Failed to set item ${setItemErr}`);\n }\n }\n /**\n * total space needed when poping out items\n *\n * @param itemSize\n *\n * @return total space needed\n */\n async sizeToPop(itemSize) {\n const cur = await this.getCurrentCacheSize();\n const spaceItemNeed = cur + itemSize - this.config.capacityInBytes;\n const cacheThresholdSpace = (1 - this.config.warningThreshold) * this.config.capacityInBytes;\n return spaceItemNeed > cacheThresholdSpace\n ? spaceItemNeed\n : cacheThresholdSpace;\n }\n /**\n * see whether cache is full\n *\n * @param itemSize\n *\n * @return true if cache is full\n */\n async isCacheFull(itemSize) {\n const cur = await this.getCurrentCacheSize();\n return itemSize + cur > this.config.capacityInBytes;\n }\n /**\n * get all the items we have, sort them by their priority,\n * if priority is same, sort them by their last visited time\n * pop out items from the low priority (5 is the lowest)\n * @private\n * @param keys - all the keys in this cache\n * @param sizeToPop - the total size of the items which needed to be poped out\n */\n async popOutItems(keys, sizeToPop) {\n const items = [];\n let remainedSize = sizeToPop;\n for (const key of keys) {\n const val = await this.getStorage().getItem(key);\n if (val != null) {\n const item = JSON.parse(val);\n items.push(item);\n }\n }\n // first compare priority\n // then compare visited time\n items.sort((a, b) => {\n if (a.priority > b.priority) {\n return -1;\n }\n else if (a.priority < b.priority) {\n return 1;\n }\n else {\n if (a.visitedTime < b.visitedTime) {\n return -1;\n }\n else\n return 1;\n }\n });\n for (const item of items) {\n // pop out items until we have enough room for new item\n await this.removeCacheItem(item.key, item.byteSize);\n remainedSize -= item.byteSize;\n if (remainedSize <= 0) {\n return;\n }\n }\n }\n /**\n * Scan the storage and combine the following operations for efficiency\n * 1. Clear out all expired keys owned by this cache, not including the size key.\n * 2. Return the remaining keys.\n *\n * @return The remaining valid keys\n */\n async clearInvalidAndGetRemainingKeys() {\n const remainingKeys = [];\n const keys = await this.getAllCacheKeys({\n omitSizeKey: true,\n });\n for (const key of keys) {\n if (await this.isExpired(key)) {\n await this.removeCacheItem(key);\n }\n else {\n remainingKeys.push(key);\n }\n }\n return remainingKeys;\n }\n /**\n * clear the entire cache\n * The cache will abort and output a warning if error occurs\n * @return {Promise}\n */\n async clear() {\n logger.debug(`Clear Cache`);\n try {\n const keys = await this.getAllKeys();\n for (const key of keys) {\n const prefixedKey = `${this.config.keyPrefix}${key}`;\n await this.getStorage().removeItem(prefixedKey);\n }\n }\n catch (e) {\n logger.warn(`clear failed! ${e}`);\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC;AACjD;AACA;AACA;AACA;AACO,MAAM,kBAAkB,CAAC;AAChC;AACA;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,EAAE;AAC9C,QAAQ,IAAI,CAAC,MAAM,GAAG;AACtB,YAAY,GAAG,aAAa;AAC5B,YAAY,GAAG,MAAM;AACrB,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;AAC/C,QAAQ,IAAI,CAAC,cAAc,EAAE,CAAC;AAC9B,KAAK;AACL,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,MAAM,EAAE;AACtB,QAAQ,IAAI,MAAM,EAAE;AACpB,YAAY,IAAI,MAAM,CAAC,SAAS,EAAE;AAClC,gBAAgB,MAAM,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;AACjG,aAAa;AACb,YAAY,IAAI,CAAC,MAAM,GAAG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AE,CAAC;AACjD,YAAY,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AACpC,gBAAgB,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AACrE,gBAAgB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAChE,aAAa;AACb,SAAS;AACT,QAAQ,OAAO,CAAC,EAAE;AAClB,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,SAAS;AACT,KAAK;AACL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.6.
|
|
1
|
+
export declare const version = "6.6.6-events.538dd9f.0+538dd9f";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.6.
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.6.6-events.538dd9f.0+538dd9f';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
|
|
@@ -125,6 +125,21 @@ function parseData(amplifyOutputsDataProperties) {
|
|
|
125
125
|
GraphQL,
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
+
function parseCustom(amplifyOutputsCustomProperties) {
|
|
129
|
+
if (!amplifyOutputsCustomProperties?.events) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
const { url, aws_region, api_key, default_authorization_type } = amplifyOutputsCustomProperties.events;
|
|
133
|
+
const Events = {
|
|
134
|
+
endpoint: url,
|
|
135
|
+
defaultAuthMode: getGraphQLAuthMode(default_authorization_type),
|
|
136
|
+
region: aws_region,
|
|
137
|
+
apiKey: api_key,
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
Events,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
128
143
|
function parseNotifications(amplifyOutputsNotificationsProperties) {
|
|
129
144
|
if (!amplifyOutputsNotificationsProperties) {
|
|
130
145
|
return undefined;
|
|
@@ -172,6 +187,12 @@ function parseAmplifyOutputs(amplifyOutputs) {
|
|
|
172
187
|
if (amplifyOutputs.data) {
|
|
173
188
|
resourcesConfig.API = parseData(amplifyOutputs.data);
|
|
174
189
|
}
|
|
190
|
+
if (amplifyOutputs.custom) {
|
|
191
|
+
const customConfig = parseCustom(amplifyOutputs.custom);
|
|
192
|
+
if (customConfig && 'Events' in customConfig) {
|
|
193
|
+
resourcesConfig.API = { ...resourcesConfig.API, ...customConfig };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
175
196
|
if (amplifyOutputs.notifications) {
|
|
176
197
|
resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);
|
|
177
198
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseAmplifyOutputs.mjs","sources":["../../src/parseAmplifyOutputs.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isAmplifyOutputs(config) {\n // version format initially will be '1' but is expected to be something like x.y where x is major and y minor version\n const { version } = config;\n if (!version) {\n return false;\n }\n return version.startsWith('1');\n}\nfunction parseStorage(amplifyOutputsStorageProperties) {\n if (!amplifyOutputsStorageProperties) {\n return undefined;\n }\n const { bucket_name, aws_region, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\n },\n };\n}\nfunction parseAuth(amplifyOutputsAuthProperties) {\n if (!amplifyOutputsAuthProperties) {\n return undefined;\n }\n const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, } = amplifyOutputsAuthProperties;\n const authConfig = {\n Cognito: {\n userPoolId: user_pool_id,\n userPoolClientId: user_pool_client_id,\n },\n };\n if (identity_pool_id) {\n authConfig.Cognito = {\n ...authConfig.Cognito,\n identityPoolId: identity_pool_id,\n };\n }\n if (password_policy) {\n authConfig.Cognito.passwordFormat = {\n requireLowercase: password_policy.require_lowercase,\n requireNumbers: password_policy.require_numbers,\n requireUppercase: password_policy.require_uppercase,\n requireSpecialCharacters: password_policy.require_symbols,\n minLength: password_policy.min_length ?? 6,\n };\n }\n if (mfa_configuration) {\n authConfig.Cognito.mfa = {\n status: getMfaStatus(mfa_configuration),\n smsEnabled: mfa_methods?.includes('SMS'),\n totpEnabled: mfa_methods?.includes('TOTP'),\n };\n }\n if (unauthenticated_identities_enabled) {\n authConfig.Cognito.allowGuestAccess = unauthenticated_identities_enabled;\n }\n if (oauth) {\n authConfig.Cognito.loginWith = {\n oauth: {\n domain: oauth.domain,\n redirectSignIn: oauth.redirect_sign_in_uri,\n redirectSignOut: oauth.redirect_sign_out_uri,\n responseType: oauth.response_type === 'token' ? 'token' : 'code',\n scopes: oauth.scopes,\n providers: getOAuthProviders(oauth.identity_providers),\n },\n };\n }\n if (username_attributes) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\n };\n }\n if (standard_required_attributes) {\n authConfig.Cognito.userAttributes = standard_required_attributes.reduce((acc, curr) => ({ ...acc, [curr]: { required: true } }), {});\n }\n return authConfig;\n}\nexport function parseAnalytics(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties?.amazon_pinpoint) {\n return undefined;\n }\n const { amazon_pinpoint } = amplifyOutputsAnalyticsProperties;\n return {\n Pinpoint: {\n appId: amazon_pinpoint.app_id,\n region: amazon_pinpoint.aws_region,\n },\n };\n}\nfunction parseGeo(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties) {\n return undefined;\n }\n const { aws_region, geofence_collections, maps, search_indices } = amplifyOutputsAnalyticsProperties;\n return {\n LocationService: {\n region: aws_region,\n searchIndices: search_indices,\n geofenceCollections: geofence_collections,\n maps,\n },\n };\n}\nfunction parseData(amplifyOutputsDataProperties) {\n if (!amplifyOutputsDataProperties) {\n return undefined;\n }\n const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;\n const GraphQL = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n modelIntrospection: model_introspection,\n };\n return {\n GraphQL,\n };\n}\nfunction parseNotifications(amplifyOutputsNotificationsProperties) {\n if (!amplifyOutputsNotificationsProperties) {\n return undefined;\n }\n const { aws_region, channels, amazon_pinpoint_app_id } = amplifyOutputsNotificationsProperties;\n const hasInAppMessaging = channels.includes('IN_APP_MESSAGING');\n const hasPushNotification = channels.includes('APNS') || channels.includes('FCM');\n if (!(hasInAppMessaging || hasPushNotification)) {\n return undefined;\n }\n // At this point, we know the Amplify outputs contains at least one supported channel\n const notificationsConfig = {};\n if (hasInAppMessaging) {\n notificationsConfig.InAppMessaging = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n if (hasPushNotification) {\n notificationsConfig.PushNotification = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n return notificationsConfig;\n}\nexport function parseAmplifyOutputs(amplifyOutputs) {\n const resourcesConfig = {};\n if (amplifyOutputs.storage) {\n resourcesConfig.Storage = parseStorage(amplifyOutputs.storage);\n }\n if (amplifyOutputs.auth) {\n resourcesConfig.Auth = parseAuth(amplifyOutputs.auth);\n }\n if (amplifyOutputs.analytics) {\n resourcesConfig.Analytics = parseAnalytics(amplifyOutputs.analytics);\n }\n if (amplifyOutputs.geo) {\n resourcesConfig.Geo = parseGeo(amplifyOutputs.geo);\n }\n if (amplifyOutputs.data) {\n resourcesConfig.API = parseData(amplifyOutputs.data);\n }\n if (amplifyOutputs.notifications) {\n resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);\n }\n return resourcesConfig;\n}\nconst authModeNames = {\n AMAZON_COGNITO_USER_POOLS: 'userPool',\n API_KEY: 'apiKey',\n AWS_IAM: 'iam',\n AWS_LAMBDA: 'lambda',\n OPENID_CONNECT: 'oidc',\n};\nfunction getGraphQLAuthMode(authType) {\n return authModeNames[authType];\n}\nconst providerNames = {\n GOOGLE: 'Google',\n LOGIN_WITH_AMAZON: 'Amazon',\n FACEBOOK: 'Facebook',\n SIGN_IN_WITH_APPLE: 'Apple',\n};\nfunction getOAuthProviders(providers = []) {\n return providers.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n };\n });\n return mappedBuckets;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,EAAE;AACzC;AACA,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AAC/B,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AACD,SAAS,YAAY,CAAC,+BAA+B,EAAE;AACvD,IAAI,IAAI,CAAC,+BAA+B,EAAE;AAC1C,QAAQ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I,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC5F,SAAS;AACT,QAAQ,aAAa,CAAC,IAAI,CAAC,GAAG;AAC9B,YAAY,UAAU;AACtB,YAAY,MAAM;AAClB,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,aAAa,CAAC;AACzB;;;;"}
|
|
1
|
+
{"version":3,"file":"parseAmplifyOutputs.mjs","sources":["../../src/parseAmplifyOutputs.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isAmplifyOutputs(config) {\n // version format initially will be '1' but is expected to be something like x.y where x is major and y minor version\n const { version } = config;\n if (!version) {\n return false;\n }\n return version.startsWith('1');\n}\nfunction parseStorage(amplifyOutputsStorageProperties) {\n if (!amplifyOutputsStorageProperties) {\n return undefined;\n }\n const { bucket_name, aws_region, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\n },\n };\n}\nfunction parseAuth(amplifyOutputsAuthProperties) {\n if (!amplifyOutputsAuthProperties) {\n return undefined;\n }\n const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, } = amplifyOutputsAuthProperties;\n const authConfig = {\n Cognito: {\n userPoolId: user_pool_id,\n userPoolClientId: user_pool_client_id,\n },\n };\n if (identity_pool_id) {\n authConfig.Cognito = {\n ...authConfig.Cognito,\n identityPoolId: identity_pool_id,\n };\n }\n if (password_policy) {\n authConfig.Cognito.passwordFormat = {\n requireLowercase: password_policy.require_lowercase,\n requireNumbers: password_policy.require_numbers,\n requireUppercase: password_policy.require_uppercase,\n requireSpecialCharacters: password_policy.require_symbols,\n minLength: password_policy.min_length ?? 6,\n };\n }\n if (mfa_configuration) {\n authConfig.Cognito.mfa = {\n status: getMfaStatus(mfa_configuration),\n smsEnabled: mfa_methods?.includes('SMS'),\n totpEnabled: mfa_methods?.includes('TOTP'),\n };\n }\n if (unauthenticated_identities_enabled) {\n authConfig.Cognito.allowGuestAccess = unauthenticated_identities_enabled;\n }\n if (oauth) {\n authConfig.Cognito.loginWith = {\n oauth: {\n domain: oauth.domain,\n redirectSignIn: oauth.redirect_sign_in_uri,\n redirectSignOut: oauth.redirect_sign_out_uri,\n responseType: oauth.response_type === 'token' ? 'token' : 'code',\n scopes: oauth.scopes,\n providers: getOAuthProviders(oauth.identity_providers),\n },\n };\n }\n if (username_attributes) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\n };\n }\n if (standard_required_attributes) {\n authConfig.Cognito.userAttributes = standard_required_attributes.reduce((acc, curr) => ({ ...acc, [curr]: { required: true } }), {});\n }\n return authConfig;\n}\nexport function parseAnalytics(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties?.amazon_pinpoint) {\n return undefined;\n }\n const { amazon_pinpoint } = amplifyOutputsAnalyticsProperties;\n return {\n Pinpoint: {\n appId: amazon_pinpoint.app_id,\n region: amazon_pinpoint.aws_region,\n },\n };\n}\nfunction parseGeo(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties) {\n return undefined;\n }\n const { aws_region, geofence_collections, maps, search_indices } = amplifyOutputsAnalyticsProperties;\n return {\n LocationService: {\n region: aws_region,\n searchIndices: search_indices,\n geofenceCollections: geofence_collections,\n maps,\n },\n };\n}\nfunction parseData(amplifyOutputsDataProperties) {\n if (!amplifyOutputsDataProperties) {\n return undefined;\n }\n const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;\n const GraphQL = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n modelIntrospection: model_introspection,\n };\n return {\n GraphQL,\n };\n}\nfunction parseCustom(amplifyOutputsCustomProperties) {\n if (!amplifyOutputsCustomProperties?.events) {\n return undefined;\n }\n const { url, aws_region, api_key, default_authorization_type } = amplifyOutputsCustomProperties.events;\n const Events = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n };\n return {\n Events,\n };\n}\nfunction parseNotifications(amplifyOutputsNotificationsProperties) {\n if (!amplifyOutputsNotificationsProperties) {\n return undefined;\n }\n const { aws_region, channels, amazon_pinpoint_app_id } = amplifyOutputsNotificationsProperties;\n const hasInAppMessaging = channels.includes('IN_APP_MESSAGING');\n const hasPushNotification = channels.includes('APNS') || channels.includes('FCM');\n if (!(hasInAppMessaging || hasPushNotification)) {\n return undefined;\n }\n // At this point, we know the Amplify outputs contains at least one supported channel\n const notificationsConfig = {};\n if (hasInAppMessaging) {\n notificationsConfig.InAppMessaging = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n if (hasPushNotification) {\n notificationsConfig.PushNotification = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n return notificationsConfig;\n}\nexport function parseAmplifyOutputs(amplifyOutputs) {\n const resourcesConfig = {};\n if (amplifyOutputs.storage) {\n resourcesConfig.Storage = parseStorage(amplifyOutputs.storage);\n }\n if (amplifyOutputs.auth) {\n resourcesConfig.Auth = parseAuth(amplifyOutputs.auth);\n }\n if (amplifyOutputs.analytics) {\n resourcesConfig.Analytics = parseAnalytics(amplifyOutputs.analytics);\n }\n if (amplifyOutputs.geo) {\n resourcesConfig.Geo = parseGeo(amplifyOutputs.geo);\n }\n if (amplifyOutputs.data) {\n resourcesConfig.API = parseData(amplifyOutputs.data);\n }\n if (amplifyOutputs.custom) {\n const customConfig = parseCustom(amplifyOutputs.custom);\n if (customConfig && 'Events' in customConfig) {\n resourcesConfig.API = { ...resourcesConfig.API, ...customConfig };\n }\n }\n if (amplifyOutputs.notifications) {\n resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);\n }\n return resourcesConfig;\n}\nconst authModeNames = {\n AMAZON_COGNITO_USER_POOLS: 'userPool',\n API_KEY: 'apiKey',\n AWS_IAM: 'iam',\n AWS_LAMBDA: 'lambda',\n OPENID_CONNECT: 'oidc',\n};\nfunction getGraphQLAuthMode(authType) {\n return authModeNames[authType];\n}\nconst providerNames = {\n GOOGLE: 'Google',\n LOGIN_WITH_AMAZON: 'Amazon',\n FACEBOOK: 'Facebook',\n SIGN_IN_WITH_APPLE: 'Apple',\n};\nfunction getOAuthProviders(providers = []) {\n return providers.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n };\n });\n return mappedBuckets;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,EAAE;AACzC;AACA,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AAC/B,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AACD,SAAS,YAAY,CAAC,+BAA+B,EAAE;AACvD,IAAI,IAAI,CAAC,+BAA+B,EAAE;AAC1C,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,M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;AAC1D,QAAQ,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;AACnD,YAAY,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzD,SAAS;AACT,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK,EAAE,EAAE,CAAC,CAAC;AACX,CAAC;AACD,SAAS,YAAY,CAAC,gBAAgB,EAAE;AACxC,IAAI,IAAI,gBAAgB,KAAK,UAAU;AACvC,QAAQ,OAAO,UAAU,CAAC;AAC1B,IAAI,IAAI,gBAAgB,KAAK,UAAU;AACvC,QAAQ,OAAO,IAAI,CAAC;AACpB,IAAI,OAAO,KAAK,CAAC;AACjB,CAAC;AACD,SAAS,mBAAmB,CAAC,OAAO,EAAE;AACtC,IAAI,MAAM,aAAa,GAAG,EAAE,CAAC;AAC7B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK;AAC/E,QAAQ,IAAI,IAAI,IAAI,aAAa,EAAE;AACnC,YAAY,MAAM,IAAI,KAAK,CAAC,CAAC,+BAA+B,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC5F,SAAS;AACT,QAAQ,aAAa,CAAC,IAAI,CAAC,GAAG;AAC9B,YAAY,UAAU;AACtB,YAAY,MAAM;AAClB,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,aAAa,CAAC;AACzB;;;;"}
|
|
@@ -42,6 +42,36 @@ export interface APIGraphQLConfig {
|
|
|
42
42
|
defaultAuthMode: GraphQLAuthMode;
|
|
43
43
|
modelIntrospection?: ModelIntrospectionSchema;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* @experimental
|
|
47
|
+
*/
|
|
48
|
+
export interface APIEventsConfig {
|
|
49
|
+
/**
|
|
50
|
+
* Required GraphQL endpoint, must be a valid URL string.
|
|
51
|
+
*/
|
|
52
|
+
endpoint: string;
|
|
53
|
+
/**
|
|
54
|
+
* Optional region string used to sign the request. Required only if the auth mode is 'iam'.
|
|
55
|
+
*/
|
|
56
|
+
region?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Optional API key string. Required only if the auth mode is 'apiKey'.
|
|
59
|
+
*/
|
|
60
|
+
apiKey?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Custom domain endpoint for GraphQL API.
|
|
63
|
+
*/
|
|
64
|
+
customEndpoint?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Optional region string used to sign the request to `customEndpoint`. Effective only if `customEndpoint` is
|
|
67
|
+
* specified, and the auth mode is 'iam'.
|
|
68
|
+
*/
|
|
69
|
+
customEndpointRegion?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Default auth mode for all the API calls to given service.
|
|
72
|
+
*/
|
|
73
|
+
defaultAuthMode: GraphQLAuthMode;
|
|
74
|
+
}
|
|
45
75
|
export interface APIRestConfig {
|
|
46
76
|
/**
|
|
47
77
|
* Required REST endpoint, must be a valid URL string.
|
|
@@ -67,7 +97,10 @@ export interface RESTProviderConfig {
|
|
|
67
97
|
export interface GraphQLProviderConfig {
|
|
68
98
|
GraphQL: APIGraphQLConfig;
|
|
69
99
|
}
|
|
70
|
-
export
|
|
100
|
+
export interface EventsProviderConfig {
|
|
101
|
+
Events: APIEventsConfig;
|
|
102
|
+
}
|
|
103
|
+
export type APIConfig = AtLeastOne<RESTProviderConfig & GraphQLProviderConfig & EventsProviderConfig>;
|
|
71
104
|
export type GraphQLAuthMode = 'apiKey' | 'oidc' | 'userPool' | 'iam' | 'identityPool' | 'lambda' | 'none';
|
|
72
105
|
/**
|
|
73
106
|
* Type representing a plain JavaScript object that can be serialized to JSON.
|
|
@@ -76,6 +76,15 @@ export interface AmplifyOutputsDataProperties {
|
|
|
76
76
|
api_key?: string;
|
|
77
77
|
conflict_resolution_mode?: string;
|
|
78
78
|
}
|
|
79
|
+
export interface AmplifyOutputsCustomProperties {
|
|
80
|
+
events?: {
|
|
81
|
+
url: string;
|
|
82
|
+
aws_region: string;
|
|
83
|
+
default_authorization_type: string;
|
|
84
|
+
api_key?: string;
|
|
85
|
+
};
|
|
86
|
+
[key: string]: any;
|
|
87
|
+
}
|
|
79
88
|
export interface AmplifyOutputsNotificationsProperties {
|
|
80
89
|
aws_region: string;
|
|
81
90
|
amazon_pinpoint_app_id: string;
|
|
@@ -88,5 +97,6 @@ export interface AmplifyOutputs {
|
|
|
88
97
|
analytics?: AmplifyOutputsAnalyticsProperties;
|
|
89
98
|
geo?: AmplifyOutputsGeoProperties;
|
|
90
99
|
data?: AmplifyOutputsDataProperties;
|
|
100
|
+
custom?: AmplifyOutputsCustomProperties;
|
|
91
101
|
notifications?: AmplifyOutputsNotificationsProperties;
|
|
92
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/core",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.6-events.538dd9f.0+538dd9f",
|
|
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.1.7-
|
|
63
|
+
"@aws-amplify/react-native": "1.1.7-events.538dd9f.0+538dd9f",
|
|
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": "
|
|
195
|
+
"gitHead": "538dd9f6bb75937d4c9e924af7c94edbae98484b"
|
|
196
196
|
}
|
|
@@ -588,7 +588,8 @@ export abstract class StorageCacheCommon {
|
|
|
588
588
|
try {
|
|
589
589
|
const keys = await this.getAllKeys();
|
|
590
590
|
for (const key of keys) {
|
|
591
|
-
|
|
591
|
+
const prefixedKey = `${this.config.keyPrefix}${key}`;
|
|
592
|
+
await this.getStorage().removeItem(prefixedKey);
|
|
592
593
|
}
|
|
593
594
|
} catch (e) {
|
|
594
595
|
logger.warn(`clear failed! ${e}`);
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.6.
|
|
2
|
+
export const version = '6.6.6-events.538dd9f.0+538dd9f';
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
/* eslint-disable camelcase */
|
|
6
6
|
|
|
7
7
|
/* Does not like exhaustive checks */
|
|
8
|
-
/* eslint-disable no-case-declarations */
|
|
9
8
|
|
|
10
9
|
import {
|
|
11
10
|
APIConfig,
|
|
11
|
+
APIEventsConfig,
|
|
12
12
|
APIGraphQLConfig,
|
|
13
13
|
GraphQLAuthMode,
|
|
14
14
|
ModelIntrospectionSchema,
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
AmplifyOutputs,
|
|
23
23
|
AmplifyOutputsAnalyticsProperties,
|
|
24
24
|
AmplifyOutputsAuthProperties,
|
|
25
|
+
AmplifyOutputsCustomProperties,
|
|
25
26
|
AmplifyOutputsDataProperties,
|
|
26
27
|
AmplifyOutputsGeoProperties,
|
|
27
28
|
AmplifyOutputsNotificationsProperties,
|
|
@@ -223,6 +224,28 @@ function parseData(
|
|
|
223
224
|
};
|
|
224
225
|
}
|
|
225
226
|
|
|
227
|
+
function parseCustom(
|
|
228
|
+
amplifyOutputsCustomProperties?: AmplifyOutputsCustomProperties,
|
|
229
|
+
) {
|
|
230
|
+
if (!amplifyOutputsCustomProperties?.events) {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const { url, aws_region, api_key, default_authorization_type } =
|
|
235
|
+
amplifyOutputsCustomProperties.events;
|
|
236
|
+
|
|
237
|
+
const Events: APIEventsConfig = {
|
|
238
|
+
endpoint: url,
|
|
239
|
+
defaultAuthMode: getGraphQLAuthMode(default_authorization_type),
|
|
240
|
+
region: aws_region,
|
|
241
|
+
apiKey: api_key,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
Events,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
226
249
|
function parseNotifications(
|
|
227
250
|
amplifyOutputsNotificationsProperties?: AmplifyOutputsNotificationsProperties,
|
|
228
251
|
): NotificationsConfig | undefined {
|
|
@@ -290,6 +313,14 @@ export function parseAmplifyOutputs(
|
|
|
290
313
|
resourcesConfig.API = parseData(amplifyOutputs.data);
|
|
291
314
|
}
|
|
292
315
|
|
|
316
|
+
if (amplifyOutputs.custom) {
|
|
317
|
+
const customConfig = parseCustom(amplifyOutputs.custom);
|
|
318
|
+
|
|
319
|
+
if (customConfig && 'Events' in customConfig) {
|
|
320
|
+
resourcesConfig.API = { ...resourcesConfig.API, ...customConfig };
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
293
324
|
if (amplifyOutputs.notifications) {
|
|
294
325
|
resourcesConfig.Notifications = parseNotifications(
|
|
295
326
|
amplifyOutputs.notifications,
|
|
@@ -47,6 +47,37 @@ export interface APIGraphQLConfig {
|
|
|
47
47
|
modelIntrospection?: ModelIntrospectionSchema;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @experimental
|
|
52
|
+
*/
|
|
53
|
+
export interface APIEventsConfig {
|
|
54
|
+
/**
|
|
55
|
+
* Required GraphQL endpoint, must be a valid URL string.
|
|
56
|
+
*/
|
|
57
|
+
endpoint: string;
|
|
58
|
+
/**
|
|
59
|
+
* Optional region string used to sign the request. Required only if the auth mode is 'iam'.
|
|
60
|
+
*/
|
|
61
|
+
region?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Optional API key string. Required only if the auth mode is 'apiKey'.
|
|
64
|
+
*/
|
|
65
|
+
apiKey?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Custom domain endpoint for GraphQL API.
|
|
68
|
+
*/
|
|
69
|
+
customEndpoint?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Optional region string used to sign the request to `customEndpoint`. Effective only if `customEndpoint` is
|
|
72
|
+
* specified, and the auth mode is 'iam'.
|
|
73
|
+
*/
|
|
74
|
+
customEndpointRegion?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Default auth mode for all the API calls to given service.
|
|
77
|
+
*/
|
|
78
|
+
defaultAuthMode: GraphQLAuthMode;
|
|
79
|
+
}
|
|
80
|
+
|
|
50
81
|
export interface APIRestConfig {
|
|
51
82
|
/**
|
|
52
83
|
* Required REST endpoint, must be a valid URL string.
|
|
@@ -75,7 +106,13 @@ export interface GraphQLProviderConfig {
|
|
|
75
106
|
GraphQL: APIGraphQLConfig;
|
|
76
107
|
}
|
|
77
108
|
|
|
78
|
-
export
|
|
109
|
+
export interface EventsProviderConfig {
|
|
110
|
+
Events: APIEventsConfig;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type APIConfig = AtLeastOne<
|
|
114
|
+
RESTProviderConfig & GraphQLProviderConfig & EventsProviderConfig
|
|
115
|
+
>;
|
|
79
116
|
|
|
80
117
|
export type GraphQLAuthMode =
|
|
81
118
|
| 'apiKey'
|
|
@@ -94,6 +94,17 @@ export interface AmplifyOutputsDataProperties {
|
|
|
94
94
|
conflict_resolution_mode?: string;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
export interface AmplifyOutputsCustomProperties {
|
|
98
|
+
// @experimental
|
|
99
|
+
events?: {
|
|
100
|
+
url: string;
|
|
101
|
+
aws_region: string;
|
|
102
|
+
default_authorization_type: string;
|
|
103
|
+
api_key?: string;
|
|
104
|
+
};
|
|
105
|
+
[key: string]: any;
|
|
106
|
+
}
|
|
107
|
+
|
|
97
108
|
export interface AmplifyOutputsNotificationsProperties {
|
|
98
109
|
aws_region: string;
|
|
99
110
|
amazon_pinpoint_app_id: string;
|
|
@@ -107,5 +118,6 @@ export interface AmplifyOutputs {
|
|
|
107
118
|
analytics?: AmplifyOutputsAnalyticsProperties;
|
|
108
119
|
geo?: AmplifyOutputsGeoProperties;
|
|
109
120
|
data?: AmplifyOutputsDataProperties;
|
|
121
|
+
custom?: AmplifyOutputsCustomProperties;
|
|
110
122
|
notifications?: AmplifyOutputsNotificationsProperties;
|
|
111
123
|
}
|