@aws-amplify/core 6.0.18-unstable.b758843.0 → 6.0.18

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.
@@ -71,7 +71,7 @@ class I18n {
71
71
  * @static
72
72
  * @method
73
73
  * Add vocabularies for one language
74
- * @param {String} langurage - Language of the dictionary
74
+ * @param {String} language - Language of the dictionary
75
75
  * @param {Object} vocabularies - Object that has key-value as dictionary entry
76
76
  */
77
77
  static putVocabulariesForLanguage(language, vocabularies) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/I18n/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.I18n = void 0;\nconst Logger_1 = require(\"../Logger\");\nconst I18n_1 = require(\"./I18n\");\nconst errorHelpers_1 = require(\"./errorHelpers\");\nconst logger = new Logger_1.ConsoleLogger('I18n');\nlet _config = { language: null };\nlet _i18n = null;\n/**\n * Export I18n APIs\n */\nclass I18n {\n /**\n * @static\n * @method\n * Configure I18n part\n * @param {Object} config - Configuration of the I18n\n */\n static configure(config) {\n logger.debug('configure I18n');\n if (!config) {\n return _config;\n }\n _config = Object.assign({}, _config, config.I18n || config);\n I18n.createInstance();\n return _config;\n }\n static getModuleName() {\n return 'I18n';\n }\n /**\n * @static\n * @method\n * Create an instance of I18n for the library\n */\n static createInstance() {\n logger.debug('create I18n instance');\n if (_i18n) {\n return;\n }\n _i18n = new I18n_1.I18n();\n }\n /**\n * @static @method\n * Explicitly setting language\n * @param {String} lang\n */\n static setLanguage(lang) {\n I18n.checkConfig();\n (0, errorHelpers_1.assert)(!!_i18n, errorHelpers_1.I18nErrorCode.NotConfigured);\n _i18n.setLanguage(lang);\n }\n /**\n * @static @method\n * Get value\n * @param {String} key\n * @param {String} defVal - Default value\n */\n static get(key, defVal) {\n if (!I18n.checkConfig()) {\n return typeof defVal === 'undefined' ? key : defVal;\n }\n (0, errorHelpers_1.assert)(!!_i18n, errorHelpers_1.I18nErrorCode.NotConfigured);\n return _i18n.get(key, defVal);\n }\n /**\n * @static\n * @method\n * Add vocabularies for one language\n * @param {String} langurage - Language of the dictionary\n * @param {Object} vocabularies - Object that has key-value as dictionary entry\n */\n static putVocabulariesForLanguage(language, vocabularies) {\n I18n.checkConfig();\n (0, errorHelpers_1.assert)(!!_i18n, errorHelpers_1.I18nErrorCode.NotConfigured);\n _i18n.putVocabulariesForLanguage(language, vocabularies);\n }\n /**\n * @static\n * @method\n * Add vocabularies for one language\n * @param {Object} vocabularies - Object that has language as key,\n * vocabularies of each language as value\n */\n static putVocabularies(vocabularies) {\n I18n.checkConfig();\n (0, errorHelpers_1.assert)(!!_i18n, errorHelpers_1.I18nErrorCode.NotConfigured);\n _i18n.putVocabularies(vocabularies);\n }\n static checkConfig() {\n if (!_i18n) {\n I18n.createInstance();\n }\n return true;\n }\n}\nexports.I18n = I18n;\n// Create an instance of I18n in the static class\nI18n.createInstance();\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AACtB,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACjD,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAClD,IAAI,OAAO,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACjC,IAAI,KAAK,GAAG,IAAI,CAAC;AACjB;AACA;AACA;AACA,MAAM,IAAI,CAAC;AACX;AACA;AACA;AACA;AAC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IAAI,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;AACxF,QAAQ,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACtC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,0BAA0B,CAAC,QAAQ,EAAE,YAAY,EAAE;AAC9D,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;AAC3B,QAAQ,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;AACxF,QAAQ,KAAK,CAAC,0BAA0B,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AACjE,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,eAAe,CAAC,YAAY,EAAE;AACzC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;AAC3B,QAAQ,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;AACxF,QAAQ,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAC5C,KAAK;AACL,IAAI,OAAO,WAAW,GAAG;AACzB,QAAQ,IAAI,CAAC,KAAK,EAAE;AACpB,YAAY,IAAI,CAAC,cAAc,EAAE,CAAC;AAClC,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;AACpB;AACA,IAAI,CAAC,cAAc,EAAE;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/I18n/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.I18n = void 0;\nconst Logger_1 = require(\"../Logger\");\nconst I18n_1 = require(\"./I18n\");\nconst errorHelpers_1 = require(\"./errorHelpers\");\nconst logger = new Logger_1.ConsoleLogger('I18n');\nlet _config = { language: null };\nlet _i18n = null;\n/**\n * Export I18n APIs\n */\nclass I18n {\n /**\n * @static\n * @method\n * Configure I18n part\n * @param {Object} config - Configuration of the I18n\n */\n static configure(config) {\n logger.debug('configure I18n');\n if (!config) {\n return _config;\n }\n _config = Object.assign({}, _config, config.I18n || config);\n I18n.createInstance();\n return _config;\n }\n static getModuleName() {\n return 'I18n';\n }\n /**\n * @static\n * @method\n * Create an instance of I18n for the library\n */\n static createInstance() {\n logger.debug('create I18n instance');\n if (_i18n) {\n return;\n }\n _i18n = new I18n_1.I18n();\n }\n /**\n * @static @method\n * Explicitly setting language\n * @param {String} lang\n */\n static setLanguage(lang) {\n I18n.checkConfig();\n (0, errorHelpers_1.assert)(!!_i18n, errorHelpers_1.I18nErrorCode.NotConfigured);\n _i18n.setLanguage(lang);\n }\n /**\n * @static @method\n * Get value\n * @param {String} key\n * @param {String} defVal - Default value\n */\n static get(key, defVal) {\n if (!I18n.checkConfig()) {\n return typeof defVal === 'undefined' ? key : defVal;\n }\n (0, errorHelpers_1.assert)(!!_i18n, errorHelpers_1.I18nErrorCode.NotConfigured);\n return _i18n.get(key, defVal);\n }\n /**\n * @static\n * @method\n * Add vocabularies for one language\n * @param {String} language - Language of the dictionary\n * @param {Object} vocabularies - Object that has key-value as dictionary entry\n */\n static putVocabulariesForLanguage(language, vocabularies) {\n I18n.checkConfig();\n (0, errorHelpers_1.assert)(!!_i18n, errorHelpers_1.I18nErrorCode.NotConfigured);\n _i18n.putVocabulariesForLanguage(language, vocabularies);\n }\n /**\n * @static\n * @method\n * Add vocabularies for one language\n * @param {Object} vocabularies - Object that has language as key,\n * vocabularies of each language as value\n */\n static putVocabularies(vocabularies) {\n I18n.checkConfig();\n (0, errorHelpers_1.assert)(!!_i18n, errorHelpers_1.I18nErrorCode.NotConfigured);\n _i18n.putVocabularies(vocabularies);\n }\n static checkConfig() {\n if (!_i18n) {\n I18n.createInstance();\n }\n return true;\n }\n}\nexports.I18n = I18n;\n// Create an instance of I18n in the static class\nI18n.createInstance();\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AACtB,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACjD,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAClD,IAAI,OAAO,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACjC,IAAI,KAAK,GAAG,IAAI,CAAC;AACjB;AACA;AACA;AACA,MAAM,IAAI,CAAC;AACX;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,SAAS,CAAC,MAAM,EAAE;AAC7B,QAAQ,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACvC,QAAQ,IAAI,CAAC,MAAM,EAAE;AACrB,YAAY,OAAO,OAAO,CAAC;AAC3B,SAAS;AACT,QAAQ,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC;AACpE,QAAQ,IAAI,CAAC,cAAc,EAAE,CAAC;AAC9B,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,OAAO,aAAa,GAAG;AAC3B,QAAQ,OAAO,MAAM,CAAC;AACtB,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,cAAc,GAA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;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,eAAe,CAAC,YAAY,EAAE;AACzC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;AAC3B,QAAQ,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;AACxF,QAAQ,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAC5C,KAAK;AACL,IAAI,OAAO,WAAW,GAAG;AACzB,QAAQ,IAAI,CAAC,KAAK,EAAE;AACpB,YAAY,IAAI,CAAC,cAAc,EAAE,CAAC;AAClC,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;AACpB;AACA,IAAI,CAAC,cAAc,EAAE;;"}
@@ -3,5 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.version = void 0;
5
5
  // generated by genversion
6
- exports.version = '6.0.18-unstable.b758843.0+b758843';
6
+ exports.version = '6.0.18';
7
7
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.0.18-unstable.b758843.0+b758843';\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,mCAAmC;;"}
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.0.18';\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,QAAQ;;"}
@@ -39,8 +39,8 @@ class ServiceWorkerClass {
39
39
  * Make sure the service-worker.js is part of the build
40
40
  * for example with Angular, modify the angular-cli.json file
41
41
  * and add to "assets" array "service-worker.js"
42
- * @param {string} - (optional) Service worker file. Defaults to "/service-worker.js"
43
- * @param {string} - (optional) The service worker scope. Defaults to "/"
42
+ * @param {string} filePath Service worker file. Defaults to "/service-worker.js"
43
+ * @param {string} scope The service worker scope. Defaults to "/"
44
44
  * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
45
45
  * @returns {Promise}
46
46
  * - resolve(ServiceWorkerRegistration)
@@ -155,7 +155,7 @@ class ServiceWorkerClass {
155
155
  * Send a message to the service worker. The service worker needs
156
156
  * to implement `self.addEventListener('message') to handle the
157
157
  * message. This ***currently*** does not work in Safari or IE.
158
- * @param {object | string} - An arbitrary JSON object or string message to send to the service worker
158
+ * @param {object | string} message An arbitrary JSON object or string message to send to the service worker
159
159
  * - see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable
160
160
  * @returns {Promise}
161
161
  **/
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceWorker.js","sources":["../../../src/ServiceWorker/ServiceWorker.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.ServiceWorkerClass = void 0;\nconst Logger_1 = require(\"../Logger\");\nconst utils_1 = require(\"../utils\");\nconst errors_1 = require(\"../errors\");\nconst pinpoint_1 = require(\"../providers/pinpoint\");\nconst singleton_1 = require(\"../singleton\");\nconst errorHelpers_1 = require(\"./errorHelpers\");\n/**\n * Provides a means to registering a service worker in the browser\n * and communicating with it via postMessage events.\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/\n *\n * postMessage events are currently not supported in all browsers. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API\n *\n * At the minmum this class will register the service worker and listen\n * and attempt to dispatch messages on state change and record analytics\n * events based on the service worker lifecycle.\n */\nclass ServiceWorkerClass {\n constructor() {\n // The AWS Amplify logger\n this._logger = new Logger_1.ConsoleLogger('ServiceWorker');\n }\n /**\n * Get the currently active service worker\n */\n get serviceWorker() {\n (0, errorHelpers_1.assert)(this._serviceWorker !== undefined, errorHelpers_1.ServiceWorkerErrorCode.UndefinedInstance);\n return this._serviceWorker;\n }\n /**\n * Register the service-worker.js file in the browser\n * Make sure the service-worker.js is part of the build\n * for example with Angular, modify the angular-cli.json file\n * and add to \"assets\" array \"service-worker.js\"\n * @param {string} - (optional) Service worker file. Defaults to \"/service-worker.js\"\n * @param {string} - (optional) The service worker scope. Defaults to \"/\"\n * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n * @returns {Promise}\n *\t- resolve(ServiceWorkerRegistration)\n *\t- reject(Error)\n **/\n register(filePath = '/service-worker.js', scope = '/') {\n this._logger.debug(`registering ${filePath}`);\n this._logger.debug(`registering service worker with scope ${scope}`);\n return new Promise((resolve, reject) => {\n if (navigator && 'serviceWorker' in navigator) {\n navigator.serviceWorker\n .register(filePath, {\n scope,\n })\n .then(registration => {\n if (registration.installing) {\n this._serviceWorker = registration.installing;\n }\n else if (registration.waiting) {\n this._serviceWorker = registration.waiting;\n }\n else if (registration.active) {\n this._serviceWorker = registration.active;\n }\n this._registration = registration;\n this._setupListeners();\n this._logger.debug(`Service Worker Registration Success: ${registration}`);\n resolve(registration);\n })\n .catch(error => {\n this._logger.debug(`Service Worker Registration Failed ${error}`);\n reject(new errors_1.AmplifyError({\n name: errorHelpers_1.ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n underlyingError: error,\n }));\n });\n }\n else {\n reject(new errors_1.AmplifyError({\n name: errorHelpers_1.ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Enable web push notifications. If not subscribed, a new subscription will\n * be created and registered.\n * \tTest Push Server: https://web-push-codelab.glitch.me/\n * \tPush Server Libraries: https://github.com/web-push-libs/\n * \tAPI Doc: https://developers.google.com/web/fundamentals/codelabs/push-notifications/\n * @param publicKey\n * @returns {Promise}\n * \t- resolve(PushSubscription)\n * - reject(Error)\n */\n enablePush(publicKey) {\n (0, errorHelpers_1.assert)(this._registration !== undefined, errorHelpers_1.ServiceWorkerErrorCode.UndefinedRegistration);\n this._publicKey = publicKey;\n return new Promise((resolve, reject) => {\n if ((0, utils_1.isBrowser)()) {\n (0, errorHelpers_1.assert)(this._registration !== undefined, errorHelpers_1.ServiceWorkerErrorCode.UndefinedRegistration);\n this._registration.pushManager.getSubscription().then(subscription => {\n if (subscription) {\n this._subscription = subscription;\n this._logger.debug(`User is subscribed to push: ${JSON.stringify(subscription)}`);\n resolve(subscription);\n }\n else {\n this._logger.debug(`User is NOT subscribed to push`);\n return this._registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: this._urlB64ToUint8Array(publicKey),\n })\n .then(pushManagerSubscription => {\n this._subscription = pushManagerSubscription;\n this._logger.debug(`User subscribed: ${JSON.stringify(pushManagerSubscription)}`);\n resolve(pushManagerSubscription);\n })\n .catch(error => {\n this._logger.error(error);\n });\n }\n });\n }\n else {\n reject(new errors_1.AmplifyError({\n name: errorHelpers_1.ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Convert a base64 encoded string to a Uint8 array for the push server key\n * @param base64String\n */\n _urlB64ToUint8Array(base64String) {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding)\n .replace(/-/g, '+')\n .replace(/_/g, '/');\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n }\n /**\n * Send a message to the service worker. The service worker needs\n * to implement `self.addEventListener('message') to handle the\n * message. This ***currently*** does not work in Safari or IE.\n * @param {object | string} - An arbitrary JSON object or string message to send to the service worker\n *\t- see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable\n * @returns {Promise}\n **/\n send(message) {\n if (this._serviceWorker) {\n this._serviceWorker.postMessage(typeof message === 'object' ? JSON.stringify(message) : message);\n }\n }\n /**\n * Listen for service worker state change and message events\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state\n **/\n _setupListeners() {\n this.serviceWorker.addEventListener('statechange', async () => {\n const currentState = this.serviceWorker.state;\n this._logger.debug(`ServiceWorker statechange: ${currentState}`);\n const { appId, region, bufferSize, flushInterval, flushSize, resendLimit, } = singleton_1.Amplify.getConfig().Analytics?.Pinpoint ?? {};\n const { credentials } = await (0, singleton_1.fetchAuthSession)();\n if (appId && region && credentials) {\n // Pinpoint is configured, record an event\n (0, pinpoint_1.record)({\n appId,\n region,\n category: 'Core',\n credentials,\n bufferSize,\n flushInterval,\n flushSize,\n resendLimit,\n event: {\n name: 'ServiceWorker',\n attributes: {\n state: currentState,\n },\n },\n });\n }\n });\n this.serviceWorker.addEventListener('message', event => {\n this._logger.debug(`ServiceWorker message event: ${event}`);\n });\n }\n}\nexports.ServiceWorkerClass = ServiceWorkerClass;\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,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAA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ACzB,oBAAoB,MAAM;AAC1B,oBAAoB,QAAQ,EAAE,MAAM;AACpC,oBAAoB,WAAW;AAC/B,oBAAoB,UAAU;AAC9B,oBAAoB,aAAa;AACjC,oBAAoB,SAAS;AAC7B,oBAAoB,WAAW;AAC/B,oBAAoB,KAAK,EAAE;AAC3B,wBAAwB,IAAI,EAAE,eAAe;AAC7C,wBAAwB,UAAU,EAAE;AACpC,4BAA4B,KAAK,EAAE,YAAY;AAC/C,yBAAyB;AACzB,qBAAqB;AACrB,iBAAiB,CAAC,CAAC;AACnB,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,IAAI;AAChE,YAAY,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACxE,SAAS,CAAC,CAAC;AACX,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
1
+ {"version":3,"file":"ServiceWorker.js","sources":["../../../src/ServiceWorker/ServiceWorker.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.ServiceWorkerClass = void 0;\nconst Logger_1 = require(\"../Logger\");\nconst utils_1 = require(\"../utils\");\nconst errors_1 = require(\"../errors\");\nconst pinpoint_1 = require(\"../providers/pinpoint\");\nconst singleton_1 = require(\"../singleton\");\nconst errorHelpers_1 = require(\"./errorHelpers\");\n/**\n * Provides a means to registering a service worker in the browser\n * and communicating with it via postMessage events.\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/\n *\n * postMessage events are currently not supported in all browsers. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API\n *\n * At the minmum this class will register the service worker and listen\n * and attempt to dispatch messages on state change and record analytics\n * events based on the service worker lifecycle.\n */\nclass ServiceWorkerClass {\n constructor() {\n // The AWS Amplify logger\n this._logger = new Logger_1.ConsoleLogger('ServiceWorker');\n }\n /**\n * Get the currently active service worker\n */\n get serviceWorker() {\n (0, errorHelpers_1.assert)(this._serviceWorker !== undefined, errorHelpers_1.ServiceWorkerErrorCode.UndefinedInstance);\n return this._serviceWorker;\n }\n /**\n * Register the service-worker.js file in the browser\n * Make sure the service-worker.js is part of the build\n * for example with Angular, modify the angular-cli.json file\n * and add to \"assets\" array \"service-worker.js\"\n * @param {string} filePath Service worker file. Defaults to \"/service-worker.js\"\n * @param {string} scope The service worker scope. Defaults to \"/\"\n * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n * @returns {Promise}\n *\t- resolve(ServiceWorkerRegistration)\n *\t- reject(Error)\n **/\n register(filePath = '/service-worker.js', scope = '/') {\n this._logger.debug(`registering ${filePath}`);\n this._logger.debug(`registering service worker with scope ${scope}`);\n return new Promise((resolve, reject) => {\n if (navigator && 'serviceWorker' in navigator) {\n navigator.serviceWorker\n .register(filePath, {\n scope,\n })\n .then(registration => {\n if (registration.installing) {\n this._serviceWorker = registration.installing;\n }\n else if (registration.waiting) {\n this._serviceWorker = registration.waiting;\n }\n else if (registration.active) {\n this._serviceWorker = registration.active;\n }\n this._registration = registration;\n this._setupListeners();\n this._logger.debug(`Service Worker Registration Success: ${registration}`);\n resolve(registration);\n })\n .catch(error => {\n this._logger.debug(`Service Worker Registration Failed ${error}`);\n reject(new errors_1.AmplifyError({\n name: errorHelpers_1.ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n underlyingError: error,\n }));\n });\n }\n else {\n reject(new errors_1.AmplifyError({\n name: errorHelpers_1.ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Enable web push notifications. If not subscribed, a new subscription will\n * be created and registered.\n * \tTest Push Server: https://web-push-codelab.glitch.me/\n * \tPush Server Libraries: https://github.com/web-push-libs/\n * \tAPI Doc: https://developers.google.com/web/fundamentals/codelabs/push-notifications/\n * @param publicKey\n * @returns {Promise}\n * \t- resolve(PushSubscription)\n * - reject(Error)\n */\n enablePush(publicKey) {\n (0, errorHelpers_1.assert)(this._registration !== undefined, errorHelpers_1.ServiceWorkerErrorCode.UndefinedRegistration);\n this._publicKey = publicKey;\n return new Promise((resolve, reject) => {\n if ((0, utils_1.isBrowser)()) {\n (0, errorHelpers_1.assert)(this._registration !== undefined, errorHelpers_1.ServiceWorkerErrorCode.UndefinedRegistration);\n this._registration.pushManager.getSubscription().then(subscription => {\n if (subscription) {\n this._subscription = subscription;\n this._logger.debug(`User is subscribed to push: ${JSON.stringify(subscription)}`);\n resolve(subscription);\n }\n else {\n this._logger.debug(`User is NOT subscribed to push`);\n return this._registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: this._urlB64ToUint8Array(publicKey),\n })\n .then(pushManagerSubscription => {\n this._subscription = pushManagerSubscription;\n this._logger.debug(`User subscribed: ${JSON.stringify(pushManagerSubscription)}`);\n resolve(pushManagerSubscription);\n })\n .catch(error => {\n this._logger.error(error);\n });\n }\n });\n }\n else {\n reject(new errors_1.AmplifyError({\n name: errorHelpers_1.ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Convert a base64 encoded string to a Uint8 array for the push server key\n * @param base64String\n */\n _urlB64ToUint8Array(base64String) {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding)\n .replace(/-/g, '+')\n .replace(/_/g, '/');\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n }\n /**\n * Send a message to the service worker. The service worker needs\n * to implement `self.addEventListener('message') to handle the\n * message. This ***currently*** does not work in Safari or IE.\n * @param {object | string} message An arbitrary JSON object or string message to send to the service worker\n *\t- see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable\n * @returns {Promise}\n **/\n send(message) {\n if (this._serviceWorker) {\n this._serviceWorker.postMessage(typeof message === 'object' ? JSON.stringify(message) : message);\n }\n }\n /**\n * Listen for service worker state change and message events\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state\n **/\n _setupListeners() {\n this.serviceWorker.addEventListener('statechange', async () => {\n const currentState = this.serviceWorker.state;\n this._logger.debug(`ServiceWorker statechange: ${currentState}`);\n const { appId, region, bufferSize, flushInterval, flushSize, resendLimit, } = singleton_1.Amplify.getConfig().Analytics?.Pinpoint ?? {};\n const { credentials } = await (0, singleton_1.fetchAuthSession)();\n if (appId && region && credentials) {\n // Pinpoint is configured, record an event\n (0, pinpoint_1.record)({\n appId,\n region,\n category: 'Core',\n credentials,\n bufferSize,\n flushInterval,\n flushSize,\n resendLimit,\n event: {\n name: 'ServiceWorker',\n attributes: {\n state: currentState,\n },\n },\n });\n }\n });\n this.serviceWorker.addEventListener('message', event => {\n this._logger.debug(`ServiceWorker message event: ${event}`);\n });\n }\n}\nexports.ServiceWorkerClass = ServiceWorkerClass;\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,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACtC,MAAM,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACpD,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACjD;AACA;AACA;AACA;AACA;AACA;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BAA4B,KAAK,EAAE,YAAY;AAC/C,yBAAyB;AACzB,qBAAqB;AACrB,iBAAiB,CAAC,CAAC;AACnB,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,IAAI;AAChE,YAAY,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACxE,SAAS,CAAC,CAAC;AACX,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
@@ -34,7 +34,7 @@ export declare class I18n {
34
34
  * @static
35
35
  * @method
36
36
  * Add vocabularies for one language
37
- * @param {String} langurage - Language of the dictionary
37
+ * @param {String} language - Language of the dictionary
38
38
  * @param {Object} vocabularies - Object that has key-value as dictionary entry
39
39
  */
40
40
  static putVocabulariesForLanguage(language: string, vocabularies: Record<string, string>): void;
@@ -68,7 +68,7 @@ class I18n {
68
68
  * @static
69
69
  * @method
70
70
  * Add vocabularies for one language
71
- * @param {String} langurage - Language of the dictionary
71
+ * @param {String} language - Language of the dictionary
72
72
  * @param {Object} vocabularies - Object that has key-value as dictionary entry
73
73
  */
74
74
  static putVocabulariesForLanguage(language, vocabularies) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../src/I18n/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../Logger';\nimport { I18n as I18nClass } from './I18n';\nimport { I18nErrorCode, assert } from './errorHelpers';\nconst logger = new ConsoleLogger('I18n');\nlet _config = { language: null };\nlet _i18n = null;\n/**\n * Export I18n APIs\n */\nexport class I18n {\n /**\n * @static\n * @method\n * Configure I18n part\n * @param {Object} config - Configuration of the I18n\n */\n static configure(config) {\n logger.debug('configure I18n');\n if (!config) {\n return _config;\n }\n _config = Object.assign({}, _config, config.I18n || config);\n I18n.createInstance();\n return _config;\n }\n static getModuleName() {\n return 'I18n';\n }\n /**\n * @static\n * @method\n * Create an instance of I18n for the library\n */\n static createInstance() {\n logger.debug('create I18n instance');\n if (_i18n) {\n return;\n }\n _i18n = new I18nClass();\n }\n /**\n * @static @method\n * Explicitly setting language\n * @param {String} lang\n */\n static setLanguage(lang) {\n I18n.checkConfig();\n assert(!!_i18n, I18nErrorCode.NotConfigured);\n _i18n.setLanguage(lang);\n }\n /**\n * @static @method\n * Get value\n * @param {String} key\n * @param {String} defVal - Default value\n */\n static get(key, defVal) {\n if (!I18n.checkConfig()) {\n return typeof defVal === 'undefined' ? key : defVal;\n }\n assert(!!_i18n, I18nErrorCode.NotConfigured);\n return _i18n.get(key, defVal);\n }\n /**\n * @static\n * @method\n * Add vocabularies for one language\n * @param {String} langurage - Language of the dictionary\n * @param {Object} vocabularies - Object that has key-value as dictionary entry\n */\n static putVocabulariesForLanguage(language, vocabularies) {\n I18n.checkConfig();\n assert(!!_i18n, I18nErrorCode.NotConfigured);\n _i18n.putVocabulariesForLanguage(language, vocabularies);\n }\n /**\n * @static\n * @method\n * Add vocabularies for one language\n * @param {Object} vocabularies - Object that has language as key,\n * vocabularies of each language as value\n */\n static putVocabularies(vocabularies) {\n I18n.checkConfig();\n assert(!!_i18n, I18nErrorCode.NotConfigured);\n _i18n.putVocabularies(vocabularies);\n }\n static checkConfig() {\n if (!_i18n) {\n I18n.createInstance();\n }\n return true;\n }\n}\n// Create an instance of I18n in the static class\nI18n.createInstance();\n"],"names":["I18nClass"],"mappings":";;;;AAAA;AACA;AAIA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;AACzC,IAAI,OAAO,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACjC,IAAI,KAAK,GAAG,IAAI,CAAC;AACjB;AACA;AACA;AACO,MAAM,IAAI,CAAC;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,SA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ACrD,QAAQ,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACtC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,0BAA0B,CAAC,QAAQ,EAAE,YAAY,EAAE;AAC9D,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;AAC3B,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;AACrD,QAAQ,KAAK,CAAC,0BAA0B,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AACjE,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,eAAe,CAAC,YAAY,EAAE;AACzC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;AAC3B,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;AACrD,QAAQ,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAC5C,KAAK;AACL,IAAI,OAAO,WAAW,GAAG;AACzB,QAAQ,IAAI,CAAC,KAAK,EAAE;AACpB,YAAY,IAAI,CAAC,cAAc,EAAE,CAAC;AAClC,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,CAAC;AACD;AACA,IAAI,CAAC,cAAc,EAAE;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/I18n/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../Logger';\nimport { I18n as I18nClass } from './I18n';\nimport { I18nErrorCode, assert } from './errorHelpers';\nconst logger = new ConsoleLogger('I18n');\nlet _config = { language: null };\nlet _i18n = null;\n/**\n * Export I18n APIs\n */\nexport class I18n {\n /**\n * @static\n * @method\n * Configure I18n part\n * @param {Object} config - Configuration of the I18n\n */\n static configure(config) {\n logger.debug('configure I18n');\n if (!config) {\n return _config;\n }\n _config = Object.assign({}, _config, config.I18n || config);\n I18n.createInstance();\n return _config;\n }\n static getModuleName() {\n return 'I18n';\n }\n /**\n * @static\n * @method\n * Create an instance of I18n for the library\n */\n static createInstance() {\n logger.debug('create I18n instance');\n if (_i18n) {\n return;\n }\n _i18n = new I18nClass();\n }\n /**\n * @static @method\n * Explicitly setting language\n * @param {String} lang\n */\n static setLanguage(lang) {\n I18n.checkConfig();\n assert(!!_i18n, I18nErrorCode.NotConfigured);\n _i18n.setLanguage(lang);\n }\n /**\n * @static @method\n * Get value\n * @param {String} key\n * @param {String} defVal - Default value\n */\n static get(key, defVal) {\n if (!I18n.checkConfig()) {\n return typeof defVal === 'undefined' ? key : defVal;\n }\n assert(!!_i18n, I18nErrorCode.NotConfigured);\n return _i18n.get(key, defVal);\n }\n /**\n * @static\n * @method\n * Add vocabularies for one language\n * @param {String} language - Language of the dictionary\n * @param {Object} vocabularies - Object that has key-value as dictionary entry\n */\n static putVocabulariesForLanguage(language, vocabularies) {\n I18n.checkConfig();\n assert(!!_i18n, I18nErrorCode.NotConfigured);\n _i18n.putVocabulariesForLanguage(language, vocabularies);\n }\n /**\n * @static\n * @method\n * Add vocabularies for one language\n * @param {Object} vocabularies - Object that has language as key,\n * vocabularies of each language as value\n */\n static putVocabularies(vocabularies) {\n I18n.checkConfig();\n assert(!!_i18n, I18nErrorCode.NotConfigured);\n _i18n.putVocabularies(vocabularies);\n }\n static checkConfig() {\n if (!_i18n) {\n I18n.createInstance();\n }\n return true;\n }\n}\n// Create an instance of I18n in the static class\nI18n.createInstance();\n"],"names":["I18nClass"],"mappings":";;;;AAAA;AACA;AAIA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;AACzC,IAAI,OAAO,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACjC,IAAI,KAAK,GAAG,IAAI,CAAC;AACjB;AACA;AACA;AACO,MAAM,IAAI,CAAC;AAClB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,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;AACrD,QAAQ,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACtC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,0BAA0B,CAAC,QAAQ,EAAE,YAAY,EAAE;AAC9D,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;AAC3B,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;AACrD,QAAQ,KAAK,CAAC,0BAA0B,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AACjE,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,eAAe,CAAC,YAAY,EAAE;AACzC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;AAC3B,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;AACrD,QAAQ,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAC5C,KAAK;AACL,IAAI,OAAO,WAAW,GAAG;AACzB,QAAQ,IAAI,CAAC,KAAK,EAAE;AACpB,YAAY,IAAI,CAAC,cAAc,EAAE,CAAC;AAClC,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,CAAC;AACD;AACA,IAAI,CAAC,cAAc,EAAE;;;;"}
@@ -1 +1 @@
1
- export declare const version = "6.0.18-unstable.b758843.0+b758843";
1
+ export declare const version = "6.0.18";
@@ -1,5 +1,5 @@
1
1
  // generated by genversion
2
- const version = '6.0.18-unstable.b758843.0+b758843';
2
+ const version = '6.0.18';
3
3
 
4
4
  export { version };
5
5
  //# sourceMappingURL=version.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.0.18-unstable.b758843.0+b758843';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
1
+ {"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.0.18';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
@@ -25,8 +25,8 @@ export declare class ServiceWorkerClass {
25
25
  * Make sure the service-worker.js is part of the build
26
26
  * for example with Angular, modify the angular-cli.json file
27
27
  * and add to "assets" array "service-worker.js"
28
- * @param {string} - (optional) Service worker file. Defaults to "/service-worker.js"
29
- * @param {string} - (optional) The service worker scope. Defaults to "/"
28
+ * @param {string} filePath Service worker file. Defaults to "/service-worker.js"
29
+ * @param {string} scope The service worker scope. Defaults to "/"
30
30
  * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
31
31
  * @returns {Promise}
32
32
  * - resolve(ServiceWorkerRegistration)
@@ -54,7 +54,7 @@ export declare class ServiceWorkerClass {
54
54
  * Send a message to the service worker. The service worker needs
55
55
  * to implement `self.addEventListener('message') to handle the
56
56
  * message. This ***currently*** does not work in Safari or IE.
57
- * @param {object | string} - An arbitrary JSON object or string message to send to the service worker
57
+ * @param {object | string} message An arbitrary JSON object or string message to send to the service worker
58
58
  * - see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable
59
59
  * @returns {Promise}
60
60
  **/
@@ -49,8 +49,8 @@ class ServiceWorkerClass {
49
49
  * Make sure the service-worker.js is part of the build
50
50
  * for example with Angular, modify the angular-cli.json file
51
51
  * and add to "assets" array "service-worker.js"
52
- * @param {string} - (optional) Service worker file. Defaults to "/service-worker.js"
53
- * @param {string} - (optional) The service worker scope. Defaults to "/"
52
+ * @param {string} filePath Service worker file. Defaults to "/service-worker.js"
53
+ * @param {string} scope The service worker scope. Defaults to "/"
54
54
  * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
55
55
  * @returns {Promise}
56
56
  * - resolve(ServiceWorkerRegistration)
@@ -165,7 +165,7 @@ class ServiceWorkerClass {
165
165
  * Send a message to the service worker. The service worker needs
166
166
  * to implement `self.addEventListener('message') to handle the
167
167
  * message. This ***currently*** does not work in Safari or IE.
168
- * @param {object | string} - An arbitrary JSON object or string message to send to the service worker
168
+ * @param {object | string} message An arbitrary JSON object or string message to send to the service worker
169
169
  * - see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable
170
170
  * @returns {Promise}
171
171
  **/
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceWorker.mjs","sources":["../../../src/ServiceWorker/ServiceWorker.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../Logger';\nimport { isBrowser } from '../utils';\nimport { AmplifyError } from '../errors';\nimport { record } from '../providers/pinpoint';\nimport { Amplify, fetchAuthSession } from '../singleton';\nimport { ServiceWorkerErrorCode, assert } from './errorHelpers';\n/**\n * Provides a means to registering a service worker in the browser\n * and communicating with it via postMessage events.\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/\n *\n * postMessage events are currently not supported in all browsers. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API\n *\n * At the minmum this class will register the service worker and listen\n * and attempt to dispatch messages on state change and record analytics\n * events based on the service worker lifecycle.\n */\nexport class ServiceWorkerClass {\n constructor() {\n // The AWS Amplify logger\n this._logger = new ConsoleLogger('ServiceWorker');\n }\n /**\n * Get the currently active service worker\n */\n get serviceWorker() {\n assert(this._serviceWorker !== undefined, ServiceWorkerErrorCode.UndefinedInstance);\n return this._serviceWorker;\n }\n /**\n * Register the service-worker.js file in the browser\n * Make sure the service-worker.js is part of the build\n * for example with Angular, modify the angular-cli.json file\n * and add to \"assets\" array \"service-worker.js\"\n * @param {string} - (optional) Service worker file. Defaults to \"/service-worker.js\"\n * @param {string} - (optional) The service worker scope. Defaults to \"/\"\n * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n * @returns {Promise}\n *\t- resolve(ServiceWorkerRegistration)\n *\t- reject(Error)\n **/\n register(filePath = '/service-worker.js', scope = '/') {\n this._logger.debug(`registering ${filePath}`);\n this._logger.debug(`registering service worker with scope ${scope}`);\n return new Promise((resolve, reject) => {\n if (navigator && 'serviceWorker' in navigator) {\n navigator.serviceWorker\n .register(filePath, {\n scope,\n })\n .then(registration => {\n if (registration.installing) {\n this._serviceWorker = registration.installing;\n }\n else if (registration.waiting) {\n this._serviceWorker = registration.waiting;\n }\n else if (registration.active) {\n this._serviceWorker = registration.active;\n }\n this._registration = registration;\n this._setupListeners();\n this._logger.debug(`Service Worker Registration Success: ${registration}`);\n resolve(registration);\n })\n .catch(error => {\n this._logger.debug(`Service Worker Registration Failed ${error}`);\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n underlyingError: error,\n }));\n });\n }\n else {\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Enable web push notifications. If not subscribed, a new subscription will\n * be created and registered.\n * \tTest Push Server: https://web-push-codelab.glitch.me/\n * \tPush Server Libraries: https://github.com/web-push-libs/\n * \tAPI Doc: https://developers.google.com/web/fundamentals/codelabs/push-notifications/\n * @param publicKey\n * @returns {Promise}\n * \t- resolve(PushSubscription)\n * - reject(Error)\n */\n enablePush(publicKey) {\n assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);\n this._publicKey = publicKey;\n return new Promise((resolve, reject) => {\n if (isBrowser()) {\n assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);\n this._registration.pushManager.getSubscription().then(subscription => {\n if (subscription) {\n this._subscription = subscription;\n this._logger.debug(`User is subscribed to push: ${JSON.stringify(subscription)}`);\n resolve(subscription);\n }\n else {\n this._logger.debug(`User is NOT subscribed to push`);\n return this._registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: this._urlB64ToUint8Array(publicKey),\n })\n .then(pushManagerSubscription => {\n this._subscription = pushManagerSubscription;\n this._logger.debug(`User subscribed: ${JSON.stringify(pushManagerSubscription)}`);\n resolve(pushManagerSubscription);\n })\n .catch(error => {\n this._logger.error(error);\n });\n }\n });\n }\n else {\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Convert a base64 encoded string to a Uint8 array for the push server key\n * @param base64String\n */\n _urlB64ToUint8Array(base64String) {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding)\n .replace(/-/g, '+')\n .replace(/_/g, '/');\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n }\n /**\n * Send a message to the service worker. The service worker needs\n * to implement `self.addEventListener('message') to handle the\n * message. This ***currently*** does not work in Safari or IE.\n * @param {object | string} - An arbitrary JSON object or string message to send to the service worker\n *\t- see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable\n * @returns {Promise}\n **/\n send(message) {\n if (this._serviceWorker) {\n this._serviceWorker.postMessage(typeof message === 'object' ? JSON.stringify(message) : message);\n }\n }\n /**\n * Listen for service worker state change and message events\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state\n **/\n _setupListeners() {\n this.serviceWorker.addEventListener('statechange', async () => {\n const currentState = this.serviceWorker.state;\n this._logger.debug(`ServiceWorker statechange: ${currentState}`);\n const { appId, region, bufferSize, flushInterval, flushSize, resendLimit, } = Amplify.getConfig().Analytics?.Pinpoint ?? {};\n const { credentials } = await fetchAuthSession();\n if (appId && region && credentials) {\n // Pinpoint is configured, record an event\n record({\n appId,\n region,\n category: 'Core',\n credentials,\n bufferSize,\n flushInterval,\n flushSize,\n resendLimit,\n event: {\n name: 'ServiceWorker',\n attributes: {\n state: currentState,\n },\n },\n });\n }\n });\n this.serviceWorker.addEventListener('message', event => {\n this._logger.debug(`ServiceWorker message event: ${event}`);\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kBAAkB,CAAC;AAChC,IAAI,WAAW,GAAG;AAClB;AACA,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,eAAe,CAAC,CAAC;AAC1D,KAAK;AACL;AACA;AACA;AACA,IAAI,IAAI,aAAa,GAAG;AACxB,QAAQ,MAAM,CAAC,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;AAC5F,QAAQ,OAAO,IAAI,CAAC,cAAc,CAAC;AACnC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,QAAQ,CAAC,QAAQ,GAAG,oBAAoB,EAAE,KAAK,GAAG,GAAG,EAAE;AAC3D,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AACtD,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAC7E,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,IAAI,SAAS,IAAI,eAAe,IAAI,SAAS,EAAE;AAC3D,gBAAgB,SAAS,CAAC,aAAa;AACvC,qBAAqB,QAAQ,CAAC,QAAQ,EAAE;AACxC,oBAAoB,KAAK;AACzB,iBAAiB,CAAC;AAClB,qBAAqB,IAAI,CAAC,YAAY,IAAI;AAC1C,oBAAoB,IAAI,YAAY,CAAC,UAAU,EAAE;AACjD,wBAAwB,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC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nB,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,IAAI;AAChE,YAAY,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACxE,SAAS,CAAC,CAAC;AACX,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"ServiceWorker.mjs","sources":["../../../src/ServiceWorker/ServiceWorker.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../Logger';\nimport { isBrowser } from '../utils';\nimport { AmplifyError } from '../errors';\nimport { record } from '../providers/pinpoint';\nimport { Amplify, fetchAuthSession } from '../singleton';\nimport { ServiceWorkerErrorCode, assert } from './errorHelpers';\n/**\n * Provides a means to registering a service worker in the browser\n * and communicating with it via postMessage events.\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/\n *\n * postMessage events are currently not supported in all browsers. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API\n *\n * At the minmum this class will register the service worker and listen\n * and attempt to dispatch messages on state change and record analytics\n * events based on the service worker lifecycle.\n */\nexport class ServiceWorkerClass {\n constructor() {\n // The AWS Amplify logger\n this._logger = new ConsoleLogger('ServiceWorker');\n }\n /**\n * Get the currently active service worker\n */\n get serviceWorker() {\n assert(this._serviceWorker !== undefined, ServiceWorkerErrorCode.UndefinedInstance);\n return this._serviceWorker;\n }\n /**\n * Register the service-worker.js file in the browser\n * Make sure the service-worker.js is part of the build\n * for example with Angular, modify the angular-cli.json file\n * and add to \"assets\" array \"service-worker.js\"\n * @param {string} filePath Service worker file. Defaults to \"/service-worker.js\"\n * @param {string} scope The service worker scope. Defaults to \"/\"\n * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n * @returns {Promise}\n *\t- resolve(ServiceWorkerRegistration)\n *\t- reject(Error)\n **/\n register(filePath = '/service-worker.js', scope = '/') {\n this._logger.debug(`registering ${filePath}`);\n this._logger.debug(`registering service worker with scope ${scope}`);\n return new Promise((resolve, reject) => {\n if (navigator && 'serviceWorker' in navigator) {\n navigator.serviceWorker\n .register(filePath, {\n scope,\n })\n .then(registration => {\n if (registration.installing) {\n this._serviceWorker = registration.installing;\n }\n else if (registration.waiting) {\n this._serviceWorker = registration.waiting;\n }\n else if (registration.active) {\n this._serviceWorker = registration.active;\n }\n this._registration = registration;\n this._setupListeners();\n this._logger.debug(`Service Worker Registration Success: ${registration}`);\n resolve(registration);\n })\n .catch(error => {\n this._logger.debug(`Service Worker Registration Failed ${error}`);\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n underlyingError: error,\n }));\n });\n }\n else {\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Enable web push notifications. If not subscribed, a new subscription will\n * be created and registered.\n * \tTest Push Server: https://web-push-codelab.glitch.me/\n * \tPush Server Libraries: https://github.com/web-push-libs/\n * \tAPI Doc: https://developers.google.com/web/fundamentals/codelabs/push-notifications/\n * @param publicKey\n * @returns {Promise}\n * \t- resolve(PushSubscription)\n * - reject(Error)\n */\n enablePush(publicKey) {\n assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);\n this._publicKey = publicKey;\n return new Promise((resolve, reject) => {\n if (isBrowser()) {\n assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);\n this._registration.pushManager.getSubscription().then(subscription => {\n if (subscription) {\n this._subscription = subscription;\n this._logger.debug(`User is subscribed to push: ${JSON.stringify(subscription)}`);\n resolve(subscription);\n }\n else {\n this._logger.debug(`User is NOT subscribed to push`);\n return this._registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: this._urlB64ToUint8Array(publicKey),\n })\n .then(pushManagerSubscription => {\n this._subscription = pushManagerSubscription;\n this._logger.debug(`User subscribed: ${JSON.stringify(pushManagerSubscription)}`);\n resolve(pushManagerSubscription);\n })\n .catch(error => {\n this._logger.error(error);\n });\n }\n });\n }\n else {\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Convert a base64 encoded string to a Uint8 array for the push server key\n * @param base64String\n */\n _urlB64ToUint8Array(base64String) {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding)\n .replace(/-/g, '+')\n .replace(/_/g, '/');\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n }\n /**\n * Send a message to the service worker. The service worker needs\n * to implement `self.addEventListener('message') to handle the\n * message. This ***currently*** does not work in Safari or IE.\n * @param {object | string} message An arbitrary JSON object or string message to send to the service worker\n *\t- see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable\n * @returns {Promise}\n **/\n send(message) {\n if (this._serviceWorker) {\n this._serviceWorker.postMessage(typeof message === 'object' ? JSON.stringify(message) : message);\n }\n }\n /**\n * Listen for service worker state change and message events\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state\n **/\n _setupListeners() {\n this.serviceWorker.addEventListener('statechange', async () => {\n const currentState = this.serviceWorker.state;\n this._logger.debug(`ServiceWorker statechange: ${currentState}`);\n const { appId, region, bufferSize, flushInterval, flushSize, resendLimit, } = Amplify.getConfig().Analytics?.Pinpoint ?? {};\n const { credentials } = await fetchAuthSession();\n if (appId && region && credentials) {\n // Pinpoint is configured, record an event\n record({\n appId,\n region,\n category: 'Core',\n credentials,\n bufferSize,\n flushInterval,\n flushSize,\n resendLimit,\n event: {\n name: 'ServiceWorker',\n attributes: {\n state: currentState,\n },\n },\n });\n }\n });\n this.serviceWorker.addEventListener('message', event => {\n this._logger.debug(`Serv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AAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,IAAI;AAChE,YAAY,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACxE,SAAS,CAAC,CAAC;AACX,KAAK;AACL;;;;"}
@@ -7,7 +7,7 @@ export { amplifyUuid } from './utils/amplifyUuid';
7
7
  export { AmplifyUrl, AmplifyUrlSearchParams } from './utils/amplifyUrl';
8
8
  export { decodeJWT, assertTokenProviderConfig, assertIdentityPoolIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
9
9
  export { isTokenExpired } from './singleton/Auth';
10
- export { AssociationBelongsTo, AssociationHasMany, AssociationHasOne, DocumentType, GraphQLAuthMode, ModelFieldType, ModelIntrospectionSchema, SchemaModel, SchemaModels, ModelAttribute, SecondaryIndexAttribute, GraphQLProviderConfig, } from './singleton/API/types';
10
+ export { AssociationBelongsTo, AssociationHasMany, AssociationHasOne, DocumentType, GraphQLAuthMode, ModelFieldType, NonModelFieldType, ModelIntrospectionSchema, SchemaModel, SchemaModels, SchemaNonModel, SchemaNonModels, CustomOperations, CustomOperation, CustomOperationArguments, CustomOperationArgument, ModelAttribute, SecondaryIndexAttribute, GraphQLProviderConfig, } from './singleton/API/types';
11
11
  export { Signer } from './Signer';
12
12
  export { JWT, StrictUnion, CognitoIdentityPoolConfig, JwtPayload, AuthStandardAttributeKey, AuthVerifiableAttributeKey, AWSCredentials, } from './singleton/Auth/types';
13
13
  export { haveCredentialsChanged } from './utils/haveCredentialsChanged';
@@ -85,6 +85,8 @@ export interface ModelIntrospectionSchema {
85
85
  models: SchemaModels;
86
86
  nonModels: SchemaNonModels;
87
87
  enums: SchemaEnums;
88
+ queries?: CustomOperations;
89
+ mutations?: CustomOperations;
88
90
  }
89
91
  /**
90
92
  * Top-level Entities on a Schema
@@ -92,6 +94,7 @@ export interface ModelIntrospectionSchema {
92
94
  export type SchemaModels = Record<string, SchemaModel>;
93
95
  export type SchemaNonModels = Record<string, SchemaNonModel>;
94
96
  export type SchemaEnums = Record<string, SchemaEnum>;
97
+ export type CustomOperations = Record<string, CustomOperation>;
95
98
  export interface SchemaModel {
96
99
  name: string;
97
100
  attributes?: ModelAttribute[];
@@ -120,6 +123,21 @@ export interface SecondaryIndexAttribute {
120
123
  fields: string[];
121
124
  };
122
125
  }
126
+ export interface CustomOperation {
127
+ name: string;
128
+ type: FieldType;
129
+ isArray: boolean;
130
+ isRequired: boolean;
131
+ arguments: CustomOperationArguments;
132
+ }
133
+ export type CustomOperationArguments = Record<string, CustomOperationArgument>;
134
+ export interface CustomOperationArgument {
135
+ name: string;
136
+ type: FieldType;
137
+ isArray: boolean;
138
+ isRequired: boolean;
139
+ isArrayNullable?: boolean;
140
+ }
123
141
  /**
124
142
  * Field Definition
125
143
  */
@@ -137,11 +155,12 @@ export interface Field {
137
155
  export interface ModelFieldType {
138
156
  model: string;
139
157
  }
158
+ export interface NonModelFieldType {
159
+ nonModel: string;
160
+ }
140
161
  export type FieldType = 'ID' | 'String' | 'Int' | 'Float' | 'AWSDate' | 'AWSTime' | 'AWSDateTime' | 'AWSTimestamp' | 'AWSEmail' | 'AWSURL' | 'AWSIPAddress' | 'Boolean' | 'AWSJSON' | 'AWSPhone' | {
141
162
  enum: string;
142
- } | ModelFieldType | {
143
- nonModel: string;
144
- };
163
+ } | ModelFieldType | NonModelFieldType;
145
164
  export type FieldAttribute = ModelAttribute;
146
165
  /**
147
166
  * Field-level Relationship Definitions
@@ -6,6 +6,9 @@ import { PredictionsConfig } from './Predictions/types';
6
6
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
7
7
  import { NotificationsConfig } from './Notifications/types';
8
8
  import { InteractionsConfig } from './Interactions/types';
9
+ /**
10
+ * Compatibility type representing the Amplify Gen 1 configuration file schema. This type should not be used directly.
11
+ */
9
12
  export interface LegacyConfig {
10
13
  /**
11
14
  * @deprecated The field should not be used.
@@ -15,6 +18,9 @@ export interface LegacyConfig {
15
18
  export type AtLeastOne<T, U = {
16
19
  [K in keyof T]: Pick<T, K>;
17
20
  }> = Partial<T> & U[keyof U];
21
+ /**
22
+ * Amplify library configuration type. Used to specify back-end resource configuration across the library.
23
+ */
18
24
  export interface ResourcesConfig {
19
25
  API?: APIConfig;
20
26
  Analytics?: AnalyticsConfig;
@@ -25,6 +31,9 @@ export interface ResourcesConfig {
25
31
  Storage?: StorageConfig;
26
32
  Geo?: GeoConfig;
27
33
  }
34
+ /**
35
+ * Amplify library options type. Used to customize library behavior.
36
+ */
28
37
  export interface LibraryOptions {
29
38
  API?: LibraryAPIOptions;
30
39
  Auth?: LibraryAuthOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/core",
3
- "version": "6.0.18-unstable.b758843.0+b758843",
3
+ "version": "6.0.18",
4
4
  "description": "Core category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -60,7 +60,7 @@
60
60
  "uuid": "^9.0.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@aws-amplify/react-native": "1.0.18-unstable.b758843.0+b758843",
63
+ "@aws-amplify/react-native": "1.0.18",
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": "b758843635c9abeb6348723e48852c3a58af569e"
195
+ "gitHead": "27ee4e14d5ba091a827ca49e9e04f15e26bb1445"
196
196
  }
package/src/I18n/index.ts CHANGED
@@ -83,7 +83,7 @@ export class I18n {
83
83
  * @static
84
84
  * @method
85
85
  * Add vocabularies for one language
86
- * @param {String} langurage - Language of the dictionary
86
+ * @param {String} language - Language of the dictionary
87
87
  * @param {Object} vocabularies - Object that has key-value as dictionary entry
88
88
  */
89
89
  static putVocabulariesForLanguage(
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '6.0.18-unstable.b758843.0+b758843';
2
+ export const version = '6.0.18';
@@ -55,8 +55,8 @@ export class ServiceWorkerClass {
55
55
  * Make sure the service-worker.js is part of the build
56
56
  * for example with Angular, modify the angular-cli.json file
57
57
  * and add to "assets" array "service-worker.js"
58
- * @param {string} - (optional) Service worker file. Defaults to "/service-worker.js"
59
- * @param {string} - (optional) The service worker scope. Defaults to "/"
58
+ * @param {string} filePath Service worker file. Defaults to "/service-worker.js"
59
+ * @param {string} scope The service worker scope. Defaults to "/"
60
60
  * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
61
61
  * @returns {Promise}
62
62
  * - resolve(ServiceWorkerRegistration)
@@ -195,7 +195,7 @@ export class ServiceWorkerClass {
195
195
  * Send a message to the service worker. The service worker needs
196
196
  * to implement `self.addEventListener('message') to handle the
197
197
  * message. This ***currently*** does not work in Safari or IE.
198
- * @param {object | string} - An arbitrary JSON object or string message to send to the service worker
198
+ * @param {object | string} message An arbitrary JSON object or string message to send to the service worker
199
199
  * - see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable
200
200
  * @returns {Promise}
201
201
  **/
@@ -40,9 +40,16 @@ export {
40
40
  DocumentType,
41
41
  GraphQLAuthMode,
42
42
  ModelFieldType,
43
+ NonModelFieldType,
43
44
  ModelIntrospectionSchema,
44
45
  SchemaModel,
45
46
  SchemaModels,
47
+ SchemaNonModel,
48
+ SchemaNonModels,
49
+ CustomOperations,
50
+ CustomOperation,
51
+ CustomOperationArguments,
52
+ CustomOperationArgument,
46
53
  ModelAttribute,
47
54
  SecondaryIndexAttribute,
48
55
  GraphQLProviderConfig,
@@ -106,6 +106,8 @@ export interface ModelIntrospectionSchema {
106
106
  models: SchemaModels;
107
107
  nonModels: SchemaNonModels;
108
108
  enums: SchemaEnums;
109
+ queries?: CustomOperations;
110
+ mutations?: CustomOperations;
109
111
  }
110
112
 
111
113
  /**
@@ -114,6 +116,7 @@ export interface ModelIntrospectionSchema {
114
116
  export type SchemaModels = Record<string, SchemaModel>;
115
117
  export type SchemaNonModels = Record<string, SchemaNonModel>;
116
118
  export type SchemaEnums = Record<string, SchemaEnum>;
119
+ export type CustomOperations = Record<string, CustomOperation>;
117
120
 
118
121
  export interface SchemaModel {
119
122
  name: string;
@@ -146,6 +149,24 @@ export interface SecondaryIndexAttribute {
146
149
  };
147
150
  }
148
151
 
152
+ export interface CustomOperation {
153
+ name: string;
154
+ type: FieldType;
155
+ isArray: boolean;
156
+ isRequired: boolean;
157
+ arguments: CustomOperationArguments;
158
+ }
159
+
160
+ export type CustomOperationArguments = Record<string, CustomOperationArgument>;
161
+
162
+ export interface CustomOperationArgument {
163
+ name: string;
164
+ type: FieldType;
165
+ isArray: boolean;
166
+ isRequired: boolean;
167
+ isArrayNullable?: boolean;
168
+ }
169
+
149
170
  /**
150
171
  * Field Definition
151
172
  */
@@ -164,6 +185,9 @@ export interface Field {
164
185
  export interface ModelFieldType {
165
186
  model: string;
166
187
  }
188
+ export interface NonModelFieldType {
189
+ nonModel: string;
190
+ }
167
191
 
168
192
  export type FieldType =
169
193
  | 'ID'
@@ -182,7 +206,7 @@ export type FieldType =
182
206
  | 'AWSPhone'
183
207
  | { enum: string }
184
208
  | ModelFieldType
185
- | { nonModel: string };
209
+ | NonModelFieldType;
186
210
  export type FieldAttribute = ModelAttribute;
187
211
 
188
212
  /**
@@ -26,6 +26,9 @@ import {
26
26
  import { NotificationsConfig } from './Notifications/types';
27
27
  import { InteractionsConfig } from './Interactions/types';
28
28
 
29
+ /**
30
+ * Compatibility type representing the Amplify Gen 1 configuration file schema. This type should not be used directly.
31
+ */
29
32
  export interface LegacyConfig {
30
33
  /**
31
34
  * @deprecated The field should not be used.
@@ -36,6 +39,9 @@ export interface LegacyConfig {
36
39
  export type AtLeastOne<T, U = { [K in keyof T]: Pick<T, K> }> = Partial<T> &
37
40
  U[keyof U];
38
41
 
42
+ /**
43
+ * Amplify library configuration type. Used to specify back-end resource configuration across the library.
44
+ */
39
45
  export interface ResourcesConfig {
40
46
  API?: APIConfig;
41
47
  Analytics?: AnalyticsConfig;
@@ -47,6 +53,9 @@ export interface ResourcesConfig {
47
53
  Geo?: GeoConfig;
48
54
  }
49
55
 
56
+ /**
57
+ * Amplify library options type. Used to customize library behavior.
58
+ */
50
59
  export interface LibraryOptions {
51
60
  API?: LibraryAPIOptions;
52
61
  Auth?: LibraryAuthOptions;