@edx/frontend-platform 3.6.0 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/analytics/MockAnalyticsService.js +6 -19
  2. package/analytics/MockAnalyticsService.js.map +1 -1
  3. package/analytics/SegmentAnalyticsService.js +53 -57
  4. package/analytics/SegmentAnalyticsService.js.map +1 -1
  5. package/analytics/index.js.map +1 -1
  6. package/analytics/interface.js +9 -9
  7. package/analytics/interface.js.map +1 -1
  8. package/auth/AxiosCsrfTokenService.js +36 -58
  9. package/auth/AxiosCsrfTokenService.js.map +1 -1
  10. package/auth/AxiosJwtAuthService.js +105 -150
  11. package/auth/AxiosJwtAuthService.js.map +1 -1
  12. package/auth/AxiosJwtTokenService.js +101 -148
  13. package/auth/AxiosJwtTokenService.js.map +1 -1
  14. package/auth/LocalForageCache.js +89 -108
  15. package/auth/LocalForageCache.js.map +1 -1
  16. package/auth/MockAuthService.js +10 -35
  17. package/auth/MockAuthService.js.map +1 -1
  18. package/auth/index.js.map +1 -1
  19. package/auth/interceptors/createCsrfTokenProviderInterceptor.js +35 -50
  20. package/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -1
  21. package/auth/interceptors/createJwtTokenProviderInterceptor.js +33 -47
  22. package/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -1
  23. package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +15 -27
  24. package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -1
  25. package/auth/interceptors/createRetryInterceptor.js +75 -105
  26. package/auth/interceptors/createRetryInterceptor.js.map +1 -1
  27. package/auth/interface.js +41 -58
  28. package/auth/interface.js.map +1 -1
  29. package/auth/utils.js +22 -40
  30. package/auth/utils.js.map +1 -1
  31. package/config.js +6 -7
  32. package/config.js.map +1 -1
  33. package/constants.js +8 -8
  34. package/constants.js.map +1 -1
  35. package/i18n/countries.js +9 -15
  36. package/i18n/countries.js.map +1 -1
  37. package/i18n/index.js +1 -0
  38. package/i18n/index.js.map +1 -1
  39. package/i18n/injectIntlWithShim.js +4 -28
  40. package/i18n/injectIntlWithShim.js.map +1 -1
  41. package/i18n/languages.js +11 -17
  42. package/i18n/languages.js.map +1 -1
  43. package/i18n/lib.js +64 -56
  44. package/i18n/lib.js.map +1 -1
  45. package/i18n/scripts/transifex-utils.js +5 -20
  46. package/i18n/scripts/transifex-utils.js.map +1 -1
  47. package/index.js.map +1 -1
  48. package/initialize.js +176 -228
  49. package/initialize.js.map +1 -1
  50. package/logging/MockLoggingService.js +5 -9
  51. package/logging/MockLoggingService.js.map +1 -1
  52. package/logging/NewRelicLoggingService.js +9 -33
  53. package/logging/NewRelicLoggingService.js.map +1 -1
  54. package/logging/index.js.map +1 -1
  55. package/logging/interface.js +7 -6
  56. package/logging/interface.js.map +1 -1
  57. package/package.json +4 -4
  58. package/pubSub.js +4 -3
  59. package/pubSub.js.map +1 -1
  60. package/react/AppContext.js +1 -1
  61. package/react/AppContext.js.map +1 -1
  62. package/react/AppProvider.js +13 -23
  63. package/react/AppProvider.js.map +1 -1
  64. package/react/AuthenticatedPageRoute.js +5 -13
  65. package/react/AuthenticatedPageRoute.js.map +1 -1
  66. package/react/ErrorBoundary.js +4 -21
  67. package/react/ErrorBoundary.js.map +1 -1
  68. package/react/ErrorPage.js +7 -17
  69. package/react/ErrorPage.js.map +1 -1
  70. package/react/LoginRedirect.js +1 -1
  71. package/react/LoginRedirect.js.map +1 -1
  72. package/react/OptionalReduxProvider.js +2 -4
  73. package/react/OptionalReduxProvider.js.map +1 -1
  74. package/react/PageRoute.js +3 -3
  75. package/react/PageRoute.js.map +1 -1
  76. package/react/hooks.js +2 -6
  77. package/react/hooks.js.map +1 -1
  78. package/react/index.js +1 -0
  79. package/react/index.js.map +1 -1
  80. package/testing/index.js +1 -0
  81. package/testing/index.js.map +1 -1
  82. package/testing/initializeMockApp.js +11 -11
  83. package/testing/initializeMockApp.js.map +1 -1
  84. package/testing/mockMessages.js.map +1 -1
  85. package/utils.js +15 -24
  86. package/utils.js.map +1 -1
@@ -1,15 +1,16 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import { configure as configureAnalytics, MockAnalyticsService } from '../analytics';
8
8
  import { configure as configureI18n } from '../i18n';
9
9
  import { configure as configureLogging, MockLoggingService } from '../logging';
10
10
  import { configure as configureAuth, MockAuthService } from '../auth';
11
11
  import { getConfig } from '../config';
12
12
  import mockMessages from './mockMessages';
13
+
13
14
  /**
14
15
  * Initializes a mock application for component testing. The mock application includes
15
16
  * mock analytics, auth, and logging services, and the real i18n service.
@@ -48,14 +49,12 @@ import mockMessages from './mockMessages';
48
49
  * authenticated user. This is passed directly to MockAuthService.
49
50
  * @memberof module:Testing
50
51
  */
51
-
52
52
  export default function initializeMockApp() {
53
53
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
54
- _ref$messages = _ref.messages,
55
- messages = _ref$messages === void 0 ? mockMessages : _ref$messages,
56
- _ref$authenticatedUse = _ref.authenticatedUser,
57
- authenticatedUser = _ref$authenticatedUse === void 0 ? null : _ref$authenticatedUse;
58
-
54
+ _ref$messages = _ref.messages,
55
+ messages = _ref$messages === void 0 ? mockMessages : _ref$messages,
56
+ _ref$authenticatedUse = _ref.authenticatedUser,
57
+ authenticatedUser = _ref$authenticatedUse === void 0 ? null : _ref$authenticatedUse;
59
58
  var loggingService = configureLogging(MockLoggingService, {
60
59
  config: getConfig()
61
60
  });
@@ -69,8 +68,9 @@ export default function initializeMockApp() {
69
68
  config: getConfig(),
70
69
  httpClient: authService.getAuthenticatedHttpClient(),
71
70
  loggingService: loggingService
72
- }); // The i18n service configure function has no return value, since there isn't a service class.
71
+ });
73
72
 
73
+ // The i18n service configure function has no return value, since there isn't a service class.
74
74
  configureI18n({
75
75
  config: getConfig(),
76
76
  loggingService: loggingService,
@@ -1 +1 @@
1
- {"version":3,"file":"initializeMockApp.js","names":["configure","configureAnalytics","MockAnalyticsService","configureI18n","configureLogging","MockLoggingService","configureAuth","MockAuthService","getConfig","mockMessages","initializeMockApp","messages","authenticatedUser","loggingService","config","authService","analyticsService","httpClient","getAuthenticatedHttpClient"],"sources":["../../src/testing/initializeMockApp.js"],"sourcesContent":["import { configure as configureAnalytics, MockAnalyticsService } from '../analytics';\nimport { configure as configureI18n } from '../i18n';\nimport { configure as configureLogging, MockLoggingService } from '../logging';\nimport { configure as configureAuth, MockAuthService } from '../auth';\nimport { getConfig } from '../config';\nimport mockMessages from './mockMessages';\n\n/**\n * Initializes a mock application for component testing. The mock application includes\n * mock analytics, auth, and logging services, and the real i18n service.\n *\n * See MockAnalyticsService, MockAuthService, and MockLoggingService for mock implementation\n * details. For the most part, the analytics and logging services just implement their functions\n * with jest.fn() and do nothing else, whereas the MockAuthService actually has some behavior\n * implemented, it just doesn't make any HTTP calls.\n *\n * Note that this mock application is not sufficient for testing the full application lifecycle or\n * initialization callbacks/custom handlers as described in the 'initialize' function's\n * documentation. It exists merely to set up the mock services that components themselves tend to\n * interact with most often. It could be extended to allow for setting up custom handlers fairly\n * easily, as this functionality would be more-or-less identical to what the real initialize\n * function does.\n *\n * Example:\n *\n * ```\n * import { initializeMockApp } from '@edx/frontend-platform/testing';\n * import { logInfo } from '@edx/frontend-platform/logging';\n *\n * describe('initializeMockApp', () => {\n * it('mocks things correctly', () => {\n * const { loggingService } = initializeMockApp();\n * logInfo('test', {});\n * expect(loggingService.logInfo).toHaveBeenCalledWith('test', {});\n * });\n * });\n * ```\n *\n * @param {Object} [options]\n * @param {*} [options.messages] A i18n-compatible messages object, or an array of such objects. If\n * an array is provided, duplicate keys are resolved with the last-one-in winning.\n * @param {UserData|null} [options.authenticatedUser] A UserData object representing the\n * authenticated user. This is passed directly to MockAuthService.\n * @memberof module:Testing\n */\nexport default function initializeMockApp({\n messages = mockMessages,\n authenticatedUser = null,\n} = {}) {\n const loggingService = configureLogging(MockLoggingService, {\n config: getConfig(),\n });\n\n const authService = configureAuth(MockAuthService, {\n config: { ...getConfig(), authenticatedUser },\n loggingService,\n });\n\n const analyticsService = configureAnalytics(MockAnalyticsService, {\n config: getConfig(),\n httpClient: authService.getAuthenticatedHttpClient(),\n loggingService,\n });\n\n // The i18n service configure function has no return value, since there isn't a service class.\n configureI18n({\n config: getConfig(),\n loggingService,\n messages,\n });\n\n return {\n analyticsService,\n authService,\n loggingService,\n };\n}\n"],"mappings":";;;;;;AAAA,SAASA,SAAS,IAAIC,kBAAtB,EAA0CC,oBAA1C,QAAsE,cAAtE;AACA,SAASF,SAAS,IAAIG,aAAtB,QAA2C,SAA3C;AACA,SAASH,SAAS,IAAII,gBAAtB,EAAwCC,kBAAxC,QAAkE,YAAlE;AACA,SAASL,SAAS,IAAIM,aAAtB,EAAqCC,eAArC,QAA4D,SAA5D;AACA,SAASC,SAAT,QAA0B,WAA1B;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,iBAAT,GAGP;EAAA,+EAAJ,EAAI;EAAA,yBAFNC,QAEM;EAAA,IAFNA,QAEM,8BAFKF,YAEL;EAAA,iCADNG,iBACM;EAAA,IADNA,iBACM,sCADc,IACd;;EACN,IAAMC,cAAc,GAAGT,gBAAgB,CAACC,kBAAD,EAAqB;IAC1DS,MAAM,EAAEN,SAAS;EADyC,CAArB,CAAvC;EAIA,IAAMO,WAAW,GAAGT,aAAa,CAACC,eAAD,EAAkB;IACjDO,MAAM,kCAAON,SAAS,EAAhB;MAAoBI,iBAAiB,EAAjBA;IAApB,EAD2C;IAEjDC,cAAc,EAAdA;EAFiD,CAAlB,CAAjC;EAKA,IAAMG,gBAAgB,GAAGf,kBAAkB,CAACC,oBAAD,EAAuB;IAChEY,MAAM,EAAEN,SAAS,EAD+C;IAEhES,UAAU,EAAEF,WAAW,CAACG,0BAAZ,EAFoD;IAGhEL,cAAc,EAAdA;EAHgE,CAAvB,CAA3C,CAVM,CAgBN;;EACAV,aAAa,CAAC;IACZW,MAAM,EAAEN,SAAS,EADL;IAEZK,cAAc,EAAdA,cAFY;IAGZF,QAAQ,EAARA;EAHY,CAAD,CAAb;EAMA,OAAO;IACLK,gBAAgB,EAAhBA,gBADK;IAELD,WAAW,EAAXA,WAFK;IAGLF,cAAc,EAAdA;EAHK,CAAP;AAKD"}
1
+ {"version":3,"file":"initializeMockApp.js","names":["configure","configureAnalytics","MockAnalyticsService","configureI18n","configureLogging","MockLoggingService","configureAuth","MockAuthService","getConfig","mockMessages","initializeMockApp","_ref","arguments","length","undefined","_ref$messages","messages","_ref$authenticatedUse","authenticatedUser","loggingService","config","authService","_objectSpread","analyticsService","httpClient","getAuthenticatedHttpClient"],"sources":["../../src/testing/initializeMockApp.js"],"sourcesContent":["import { configure as configureAnalytics, MockAnalyticsService } from '../analytics';\nimport { configure as configureI18n } from '../i18n';\nimport { configure as configureLogging, MockLoggingService } from '../logging';\nimport { configure as configureAuth, MockAuthService } from '../auth';\nimport { getConfig } from '../config';\nimport mockMessages from './mockMessages';\n\n/**\n * Initializes a mock application for component testing. The mock application includes\n * mock analytics, auth, and logging services, and the real i18n service.\n *\n * See MockAnalyticsService, MockAuthService, and MockLoggingService for mock implementation\n * details. For the most part, the analytics and logging services just implement their functions\n * with jest.fn() and do nothing else, whereas the MockAuthService actually has some behavior\n * implemented, it just doesn't make any HTTP calls.\n *\n * Note that this mock application is not sufficient for testing the full application lifecycle or\n * initialization callbacks/custom handlers as described in the 'initialize' function's\n * documentation. It exists merely to set up the mock services that components themselves tend to\n * interact with most often. It could be extended to allow for setting up custom handlers fairly\n * easily, as this functionality would be more-or-less identical to what the real initialize\n * function does.\n *\n * Example:\n *\n * ```\n * import { initializeMockApp } from '@edx/frontend-platform/testing';\n * import { logInfo } from '@edx/frontend-platform/logging';\n *\n * describe('initializeMockApp', () => {\n * it('mocks things correctly', () => {\n * const { loggingService } = initializeMockApp();\n * logInfo('test', {});\n * expect(loggingService.logInfo).toHaveBeenCalledWith('test', {});\n * });\n * });\n * ```\n *\n * @param {Object} [options]\n * @param {*} [options.messages] A i18n-compatible messages object, or an array of such objects. If\n * an array is provided, duplicate keys are resolved with the last-one-in winning.\n * @param {UserData|null} [options.authenticatedUser] A UserData object representing the\n * authenticated user. This is passed directly to MockAuthService.\n * @memberof module:Testing\n */\nexport default function initializeMockApp({\n messages = mockMessages,\n authenticatedUser = null,\n} = {}) {\n const loggingService = configureLogging(MockLoggingService, {\n config: getConfig(),\n });\n\n const authService = configureAuth(MockAuthService, {\n config: { ...getConfig(), authenticatedUser },\n loggingService,\n });\n\n const analyticsService = configureAnalytics(MockAnalyticsService, {\n config: getConfig(),\n httpClient: authService.getAuthenticatedHttpClient(),\n loggingService,\n });\n\n // The i18n service configure function has no return value, since there isn't a service class.\n configureI18n({\n config: getConfig(),\n loggingService,\n messages,\n });\n\n return {\n analyticsService,\n authService,\n loggingService,\n };\n}\n"],"mappings":";;;;;;AAAA,SAASA,SAAS,IAAIC,kBAAkB,EAAEC,oBAAoB,QAAQ,cAAc;AACpF,SAASF,SAAS,IAAIG,aAAa,QAAQ,SAAS;AACpD,SAASH,SAAS,IAAII,gBAAgB,EAAEC,kBAAkB,QAAQ,YAAY;AAC9E,SAASL,SAAS,IAAIM,aAAa,EAAEC,eAAe,QAAQ,SAAS;AACrE,SAASC,SAAS,QAAQ,WAAW;AACrC,OAAOC,YAAY,MAAM,gBAAgB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,iBAAiBA,CAAA,EAGjC;EAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAJ,CAAC,CAAC;IAAAG,aAAA,GAAAJ,IAAA,CAFJK,QAAQ;IAARA,QAAQ,GAAAD,aAAA,cAAGN,YAAY,GAAAM,aAAA;IAAAE,qBAAA,GAAAN,IAAA,CACvBO,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,IAAI,GAAAA,qBAAA;EAExB,IAAME,cAAc,GAAGf,gBAAgB,CAACC,kBAAkB,EAAE;IAC1De,MAAM,EAAEZ,SAAS;EACnB,CAAC,CAAC;EAEF,IAAMa,WAAW,GAAGf,aAAa,CAACC,eAAe,EAAE;IACjDa,MAAM,EAAAE,aAAA,CAAAA,aAAA,KAAOd,SAAS,EAAE;MAAEU,iBAAiB,EAAjBA;IAAiB,EAAE;IAC7CC,cAAc,EAAdA;EACF,CAAC,CAAC;EAEF,IAAMI,gBAAgB,GAAGtB,kBAAkB,CAACC,oBAAoB,EAAE;IAChEkB,MAAM,EAAEZ,SAAS,EAAE;IACnBgB,UAAU,EAAEH,WAAW,CAACI,0BAA0B,EAAE;IACpDN,cAAc,EAAdA;EACF,CAAC,CAAC;;EAEF;EACAhB,aAAa,CAAC;IACZiB,MAAM,EAAEZ,SAAS,EAAE;IACnBW,cAAc,EAAdA,cAAc;IACdH,QAAQ,EAARA;EACF,CAAC,CAAC;EAEF,OAAO;IACLO,gBAAgB,EAAhBA,gBAAgB;IAChBF,WAAW,EAAXA,WAAW;IACXF,cAAc,EAAdA;EACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"mockMessages.js","names":["messages","ar","fr","ca","he","id","pl","ru","th","uk"],"sources":["../../src/testing/mockMessages.js"],"sourcesContent":["/**\n * An empty messages object suitable for fulfilling the i18n service's contract.\n * @memberof module:Testing\n */\nconst messages = {\n ar: {},\n 'es-419': {},\n fr: {},\n 'zh-cn': {},\n ca: {},\n he: {},\n id: {},\n 'ko-kr': {},\n pl: {},\n 'pt-br': {},\n ru: {},\n th: {},\n uk: {},\n};\n\nexport default messages;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,IAAMA,QAAQ,GAAG;EACfC,EAAE,EAAE,EADW;EAEf,UAAU,EAFK;EAGfC,EAAE,EAAE,EAHW;EAIf,SAAS,EAJM;EAKfC,EAAE,EAAE,EALW;EAMfC,EAAE,EAAE,EANW;EAOfC,EAAE,EAAE,EAPW;EAQf,SAAS,EARM;EASfC,EAAE,EAAE,EATW;EAUf,SAAS,EAVM;EAWfC,EAAE,EAAE,EAXW;EAYfC,EAAE,EAAE,EAZW;EAafC,EAAE,EAAE;AAbW,CAAjB;AAgBA,eAAeT,QAAf"}
1
+ {"version":3,"file":"mockMessages.js","names":["messages","ar","fr","ca","he","id","pl","ru","th","uk"],"sources":["../../src/testing/mockMessages.js"],"sourcesContent":["/**\n * An empty messages object suitable for fulfilling the i18n service's contract.\n * @memberof module:Testing\n */\nconst messages = {\n ar: {},\n 'es-419': {},\n fr: {},\n 'zh-cn': {},\n ca: {},\n he: {},\n id: {},\n 'ko-kr': {},\n pl: {},\n 'pt-br': {},\n ru: {},\n th: {},\n uk: {},\n};\n\nexport default messages;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,IAAMA,QAAQ,GAAG;EACfC,EAAE,EAAE,CAAC,CAAC;EACN,QAAQ,EAAE,CAAC,CAAC;EACZC,EAAE,EAAE,CAAC,CAAC;EACN,OAAO,EAAE,CAAC,CAAC;EACXC,EAAE,EAAE,CAAC,CAAC;EACNC,EAAE,EAAE,CAAC,CAAC;EACNC,EAAE,EAAE,CAAC,CAAC;EACN,OAAO,EAAE,CAAC,CAAC;EACXC,EAAE,EAAE,CAAC,CAAC;EACN,OAAO,EAAE,CAAC,CAAC;EACXC,EAAE,EAAE,CAAC,CAAC;EACNC,EAAE,EAAE,CAAC,CAAC;EACNC,EAAE,EAAE,CAAC;AACP,CAAC;AAED,eAAeT,QAAQ"}
package/utils.js CHANGED
@@ -1,19 +1,13 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
3
4
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
-
5
5
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
-
7
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
-
9
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10
-
11
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
12
-
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
13
9
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
-
15
10
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
16
-
17
11
  /**
18
12
  * #### Import members from **@edx/frontend-platform**
19
13
  *
@@ -21,6 +15,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
21
15
  */
22
16
  import camelCase from 'lodash.camelcase';
23
17
  import snakeCase from 'lodash.snakecase';
18
+
24
19
  /**
25
20
  * This is the underlying function used by camelCaseObject, snakeCaseObject, and convertKeyNames
26
21
  * above.
@@ -51,30 +46,28 @@ import snakeCase from 'lodash.snakecase';
51
46
  * @param {function} modify
52
47
  * @returns {Object}
53
48
  */
54
-
55
49
  export function modifyObjectKeys(object, modify) {
56
50
  // If the passed in object is not an Object, return it.
57
51
  if (object === undefined || object === null || _typeof(object) !== 'object' && !Array.isArray(object)) {
58
52
  return object;
59
53
  }
60
-
61
54
  if (Array.isArray(object)) {
62
55
  return object.map(function (value) {
63
56
  return modifyObjectKeys(value, modify);
64
57
  });
65
- } // Otherwise, process all its keys.
66
-
58
+ }
67
59
 
60
+ // Otherwise, process all its keys.
68
61
  var result = {};
69
62
  Object.entries(object).forEach(function (_ref) {
70
63
  var _ref2 = _slicedToArray(_ref, 2),
71
- key = _ref2[0],
72
- value = _ref2[1];
73
-
64
+ key = _ref2[0],
65
+ value = _ref2[1];
74
66
  result[modify(key)] = modifyObjectKeys(value, modify);
75
67
  });
76
68
  return result;
77
69
  }
70
+
78
71
  /**
79
72
  * Performs a deep conversion to camelCase on all keys in the provided object and its tree of
80
73
  * children. Uses [lodash.camelcase](https://lodash.com/docs/4.17.15#camelCase) on each key. This
@@ -87,10 +80,10 @@ export function modifyObjectKeys(object, modify) {
87
80
  * @param {Array|Object} object
88
81
  * @returns {Array|Object}
89
82
  */
90
-
91
83
  export function camelCaseObject(object) {
92
84
  return modifyObjectKeys(object, camelCase);
93
85
  }
86
+
94
87
  /**
95
88
  * Performs a deep conversion to snake_case on all keys in the provided object and its tree of
96
89
  * children. Uses [lodash.snakecase](https://lodash.com/docs/4.17.15#snakeCase) on each key. This
@@ -103,10 +96,10 @@ export function camelCaseObject(object) {
103
96
  * @param {Array|Object} object
104
97
  * @returns {Array|Object}
105
98
  */
106
-
107
99
  export function snakeCaseObject(object) {
108
100
  return modifyObjectKeys(object, snakeCase);
109
101
  }
102
+
110
103
  /**
111
104
  * Given a map of key-value pairs, performs a deep conversion key names in the specified object
112
105
  * _from_ the key _to_ the value. This is useful for updating names in an API request to the names
@@ -133,14 +126,13 @@ export function snakeCaseObject(object) {
133
126
  * @param {Object} nameMap
134
127
  * @returns {Array|Object}
135
128
  */
136
-
137
129
  export function convertKeyNames(object, nameMap) {
138
130
  var transformer = function transformer(key) {
139
131
  return nameMap[key] === undefined ? key : nameMap[key];
140
132
  };
141
-
142
133
  return modifyObjectKeys(object, transformer);
143
134
  }
135
+
144
136
  /**
145
137
  * *Deprecated*: A method which converts the supplied query string into an object of
146
138
  * key-value pairs and returns it. Defaults to the current query string - should perform like
@@ -150,7 +142,6 @@ export function convertKeyNames(object, nameMap) {
150
142
  * @param {string} [search=global.location.search]
151
143
  * @returns {Object}
152
144
  */
153
-
154
145
  export function getQueryParameters() {
155
146
  var search = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : global.location.search;
156
147
  var keyValueFragments = search.slice(search.indexOf('?') + 1).split('&').filter(function (hash) {
@@ -163,6 +154,7 @@ export function getQueryParameters() {
163
154
  return Object.assign(params, _defineProperty({}, key, decodeURIComponent(value)));
164
155
  }, {});
165
156
  }
157
+
166
158
  /**
167
159
  * This function helps catch a certain class of misconfiguration in which configuration variables
168
160
  * are not properly defined and/or supplied to a consumer that requires them. Any key that exists
@@ -175,7 +167,6 @@ export function getQueryParameters() {
175
167
  * @param {string} requester A human-readable identifier for the code which called this function.
176
168
  * Used when throwing errors to aid in debugging.
177
169
  */
178
-
179
170
  export function ensureDefinedConfig(object, requester) {
180
171
  Object.keys(object).forEach(function (key) {
181
172
  if (object[key] === undefined) {
package/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["camelCase","snakeCase","modifyObjectKeys","object","modify","undefined","Array","isArray","map","value","result","Object","entries","forEach","key","camelCaseObject","snakeCaseObject","convertKeyNames","nameMap","transformer","getQueryParameters","search","global","location","keyValueFragments","slice","indexOf","split","filter","hash","reduce","params","keyValueFragment","assign","decodeURIComponent","ensureDefinedConfig","requester","keys","console","warn"],"sources":["../src/utils.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform**\n *\n * @module Utilities\n */\nimport camelCase from 'lodash.camelcase';\nimport snakeCase from 'lodash.snakecase';\n\n/**\n * This is the underlying function used by camelCaseObject, snakeCaseObject, and convertKeyNames\n * above.\n *\n * Given an object (or array) and a modification function, will perform the function on each key it\n * encounters on the object and its tree of children.\n *\n * The modification function must take a string as an argument and returns a string.\n *\n * Example:\n *\n * ```\n * (key) => {\n * if (key === 'edX') {\n * return 'Open edX';\n * }\n * return key;\n * }\n * ```\n *\n * This function will turn any key that matches 'edX' into 'Open edX'. All other keys will be\n * passed through unmodified.\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Object} object\n * @param {function} modify\n * @returns {Object}\n */\nexport function modifyObjectKeys(object, modify) {\n // If the passed in object is not an Object, return it.\n if (\n object === undefined\n || object === null\n || (typeof object !== 'object' && !Array.isArray(object))\n ) {\n return object;\n }\n\n if (Array.isArray(object)) {\n return object.map(value => modifyObjectKeys(value, modify));\n }\n\n // Otherwise, process all its keys.\n const result = {};\n Object.entries(object).forEach(([key, value]) => {\n result[modify(key)] = modifyObjectKeys(value, modify);\n });\n return result;\n}\n\n/**\n * Performs a deep conversion to camelCase on all keys in the provided object and its tree of\n * children. Uses [lodash.camelcase](https://lodash.com/docs/4.17.15#camelCase) on each key. This\n * is commonly used to convert snake_case keys in models from a backend server into camelCase keys\n * for use in the JavaScript client.\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Array|Object} object\n * @returns {Array|Object}\n */\nexport function camelCaseObject(object) {\n return modifyObjectKeys(object, camelCase);\n}\n\n/**\n * Performs a deep conversion to snake_case on all keys in the provided object and its tree of\n * children. Uses [lodash.snakecase](https://lodash.com/docs/4.17.15#snakeCase) on each key. This\n * is commonly used to convert camelCase keys from the JavaScript app into snake_case keys expected\n * by backend servers.\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Array|Object} object\n * @returns {Array|Object}\n */\nexport function snakeCaseObject(object) {\n return modifyObjectKeys(object, snakeCase);\n}\n\n/**\n * Given a map of key-value pairs, performs a deep conversion key names in the specified object\n * _from_ the key _to_ the value. This is useful for updating names in an API request to the names\n * used throughout a client application if they happen to differ. It can also be used in the\n * reverse - formatting names from the client application to names expected by an API.\n *\n * ```\n * import { convertKeyNames } from '@edx/frontend-base';\n *\n * // This object can be of any shape or depth with subobjects/arrays.\n * const myObject = {\n * myKey: 'my value',\n * }\n *\n * const result = convertKeyNames(myObject, { myKey: 'their_key' });\n *\n * console.log(result) // { their_key: 'my value' }\n * ```\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Array|Object} object\n * @param {Object} nameMap\n * @returns {Array|Object}\n */\nexport function convertKeyNames(object, nameMap) {\n const transformer = key => (nameMap[key] === undefined ? key : nameMap[key]);\n\n return modifyObjectKeys(object, transformer);\n}\n\n/**\n * *Deprecated*: A method which converts the supplied query string into an object of\n * key-value pairs and returns it. Defaults to the current query string - should perform like\n * [window.searchParams](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams)\n *\n * @deprecated\n * @param {string} [search=global.location.search]\n * @returns {Object}\n */\nexport function getQueryParameters(search = global.location.search) {\n const keyValueFragments = search\n .slice(search.indexOf('?') + 1)\n .split('&')\n .filter(hash => hash !== '');\n\n return keyValueFragments.reduce((params, keyValueFragment) => {\n const split = keyValueFragment.indexOf('=');\n const key = keyValueFragment.slice(0, split);\n const value = keyValueFragment.slice(split + 1);\n return Object.assign(params, { [key]: decodeURIComponent(value) });\n }, {});\n}\n\n/**\n * This function helps catch a certain class of misconfiguration in which configuration variables\n * are not properly defined and/or supplied to a consumer that requires them. Any key that exists\n * is still set to \"undefined\" indicates a misconfiguration further up in the application, and\n * should be flagged as an error, and is logged to 'warn'.\n *\n * Keys that are intended to be falsy should be defined using null, 0, false, etc.\n *\n * @param {Object} object\n * @param {string} requester A human-readable identifier for the code which called this function.\n * Used when throwing errors to aid in debugging.\n */\nexport function ensureDefinedConfig(object, requester) {\n Object.keys(object).forEach((key) => {\n if (object[key] === undefined) {\n // eslint-disable-next-line no-console\n console.warn(`Module configuration error: ${key} is required by ${requester}.`);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,kBAAtB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AAEA;AACA;AACA;AACA;AACA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A;;AACA,OAAO,SAAS0B,mBAAT,CAA6BhC,MAA7B,EAAqCiC,SAArC,EAAgD;EACrDzB,MAAM,CAAC0B,IAAP,CAAYlC,MAAZ,EAAoBU,OAApB,CAA4B,UAACC,GAAD,EAAS;IACnC,IAAIX,MAAM,CAACW,GAAD,CAAN,KAAgBT,SAApB,EAA+B;MAC7B;MACAiC,OAAO,CAACC,IAAR,uCAA4CzB,GAA5C,6BAAkEsB,SAAlE;IACD;EACF,CALD;AAMD"}
1
+ {"version":3,"file":"utils.js","names":["camelCase","snakeCase","modifyObjectKeys","object","modify","undefined","_typeof","Array","isArray","map","value","result","Object","entries","forEach","_ref","_ref2","_slicedToArray","key","camelCaseObject","snakeCaseObject","convertKeyNames","nameMap","transformer","getQueryParameters","search","arguments","length","global","location","keyValueFragments","slice","indexOf","split","filter","hash","reduce","params","keyValueFragment","assign","_defineProperty","decodeURIComponent","ensureDefinedConfig","requester","keys","console","warn","concat"],"sources":["../src/utils.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform**\n *\n * @module Utilities\n */\nimport camelCase from 'lodash.camelcase';\nimport snakeCase from 'lodash.snakecase';\n\n/**\n * This is the underlying function used by camelCaseObject, snakeCaseObject, and convertKeyNames\n * above.\n *\n * Given an object (or array) and a modification function, will perform the function on each key it\n * encounters on the object and its tree of children.\n *\n * The modification function must take a string as an argument and returns a string.\n *\n * Example:\n *\n * ```\n * (key) => {\n * if (key === 'edX') {\n * return 'Open edX';\n * }\n * return key;\n * }\n * ```\n *\n * This function will turn any key that matches 'edX' into 'Open edX'. All other keys will be\n * passed through unmodified.\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Object} object\n * @param {function} modify\n * @returns {Object}\n */\nexport function modifyObjectKeys(object, modify) {\n // If the passed in object is not an Object, return it.\n if (\n object === undefined\n || object === null\n || (typeof object !== 'object' && !Array.isArray(object))\n ) {\n return object;\n }\n\n if (Array.isArray(object)) {\n return object.map(value => modifyObjectKeys(value, modify));\n }\n\n // Otherwise, process all its keys.\n const result = {};\n Object.entries(object).forEach(([key, value]) => {\n result[modify(key)] = modifyObjectKeys(value, modify);\n });\n return result;\n}\n\n/**\n * Performs a deep conversion to camelCase on all keys in the provided object and its tree of\n * children. Uses [lodash.camelcase](https://lodash.com/docs/4.17.15#camelCase) on each key. This\n * is commonly used to convert snake_case keys in models from a backend server into camelCase keys\n * for use in the JavaScript client.\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Array|Object} object\n * @returns {Array|Object}\n */\nexport function camelCaseObject(object) {\n return modifyObjectKeys(object, camelCase);\n}\n\n/**\n * Performs a deep conversion to snake_case on all keys in the provided object and its tree of\n * children. Uses [lodash.snakecase](https://lodash.com/docs/4.17.15#snakeCase) on each key. This\n * is commonly used to convert camelCase keys from the JavaScript app into snake_case keys expected\n * by backend servers.\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Array|Object} object\n * @returns {Array|Object}\n */\nexport function snakeCaseObject(object) {\n return modifyObjectKeys(object, snakeCase);\n}\n\n/**\n * Given a map of key-value pairs, performs a deep conversion key names in the specified object\n * _from_ the key _to_ the value. This is useful for updating names in an API request to the names\n * used throughout a client application if they happen to differ. It can also be used in the\n * reverse - formatting names from the client application to names expected by an API.\n *\n * ```\n * import { convertKeyNames } from '@edx/frontend-base';\n *\n * // This object can be of any shape or depth with subobjects/arrays.\n * const myObject = {\n * myKey: 'my value',\n * }\n *\n * const result = convertKeyNames(myObject, { myKey: 'their_key' });\n *\n * console.log(result) // { their_key: 'my value' }\n * ```\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Array|Object} object\n * @param {Object} nameMap\n * @returns {Array|Object}\n */\nexport function convertKeyNames(object, nameMap) {\n const transformer = key => (nameMap[key] === undefined ? key : nameMap[key]);\n\n return modifyObjectKeys(object, transformer);\n}\n\n/**\n * *Deprecated*: A method which converts the supplied query string into an object of\n * key-value pairs and returns it. Defaults to the current query string - should perform like\n * [window.searchParams](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams)\n *\n * @deprecated\n * @param {string} [search=global.location.search]\n * @returns {Object}\n */\nexport function getQueryParameters(search = global.location.search) {\n const keyValueFragments = search\n .slice(search.indexOf('?') + 1)\n .split('&')\n .filter(hash => hash !== '');\n\n return keyValueFragments.reduce((params, keyValueFragment) => {\n const split = keyValueFragment.indexOf('=');\n const key = keyValueFragment.slice(0, split);\n const value = keyValueFragment.slice(split + 1);\n return Object.assign(params, { [key]: decodeURIComponent(value) });\n }, {});\n}\n\n/**\n * This function helps catch a certain class of misconfiguration in which configuration variables\n * are not properly defined and/or supplied to a consumer that requires them. Any key that exists\n * is still set to \"undefined\" indicates a misconfiguration further up in the application, and\n * should be flagged as an error, and is logged to 'warn'.\n *\n * Keys that are intended to be falsy should be defined using null, 0, false, etc.\n *\n * @param {Object} object\n * @param {string} requester A human-readable identifier for the code which called this function.\n * Used when throwing errors to aid in debugging.\n */\nexport function ensureDefinedConfig(object, requester) {\n Object.keys(object).forEach((key) => {\n if (object[key] === undefined) {\n // eslint-disable-next-line no-console\n console.warn(`Module configuration error: ${key} is required by ${requester}.`);\n }\n });\n}\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,kBAAkB;AACxC,OAAOC,SAAS,MAAM,kBAAkB;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACC,MAAM,EAAEC,MAAM,EAAE;EAC/C;EACA,IACED,MAAM,KAAKE,SAAS,IACjBF,MAAM,KAAK,IAAI,IACdG,OAAA,CAAOH,MAAM,MAAK,QAAQ,IAAI,CAACI,KAAK,CAACC,OAAO,CAACL,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