@common-stack/client-react 1.0.1-alpha.0 → 1.0.1-alpha.2

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 (144) hide show
  1. package/lib/connector/base-connector.js +3 -10
  2. package/lib/connector/base-connector.js.map +1 -1
  3. package/lib/connector/connector.d.ts +0 -1
  4. package/lib/connector/connector.js +3 -8
  5. package/lib/connector/connector.js.map +1 -1
  6. package/lib/connector/connector.native.d.ts +0 -1
  7. package/lib/connector/connector.native.js +3 -9
  8. package/lib/connector/connector.native.js.map +1 -1
  9. package/lib/index.js +1 -11
  10. package/lib/index.js.map +1 -1
  11. package/lib/index.native.js +1 -11
  12. package/lib/index.native.js.map +1 -1
  13. package/lib/interfaces/menu.js +2 -3
  14. package/lib/interfaces/menu.js.map +1 -1
  15. package/lib/inversify/InversifyContext.js +4 -6
  16. package/lib/inversify/InversifyContext.js.map +1 -1
  17. package/lib/plugin-area/base-plugin-area.js +4 -10
  18. package/lib/plugin-area/base-plugin-area.js.map +1 -1
  19. package/lib/plugin-area/index.js +2 -6
  20. package/lib/plugin-area/index.js.map +1 -1
  21. package/lib/plugin-area/index.native.js +2 -7
  22. package/lib/plugin-area/index.native.js.map +1 -1
  23. package/lib/plugin-area/plugin-api.js +6 -9
  24. package/lib/plugin-area/plugin-api.js.map +1 -1
  25. package/lib/plugin-area/plugin-context.js +2 -18
  26. package/lib/plugin-area/plugin-context.js.map +1 -1
  27. package/lib/route/get-routes.js +3 -6
  28. package/lib/route/get-routes.js.map +1 -1
  29. package/lib/route/old/get-menus.js +2 -4
  30. package/lib/route/old/get-menus.js.map +1 -1
  31. package/lib/route/old/render.js +2 -5
  32. package/lib/route/old/render.js.map +1 -1
  33. package/lib/route/react-navigation/get-navigation-utils.js +3 -7
  34. package/lib/route/react-navigation/get-navigation-utils.js.map +1 -1
  35. package/lib/route/react-navigation/react-navigation-render.js +6 -10
  36. package/lib/route/react-navigation/react-navigation-render.js.map +1 -1
  37. package/lib/route/react-navigation/root-navigation.js +3 -5
  38. package/lib/route/react-navigation/root-navigation.js.map +1 -1
  39. package/lib/route/react-navigation/types.js +1 -2
  40. package/lib/route/react-navigation/types.js.map +1 -1
  41. package/lib/route/render-routes.js +2 -60
  42. package/lib/route/render-routes.js.map +1 -1
  43. package/lib/route/render-routes.native.js +2 -60
  44. package/lib/route/render-routes.native.js.map +1 -1
  45. package/lib/route/root-navigation.js +3 -5
  46. package/lib/route/root-navigation.js.map +1 -1
  47. package/lib/route-based-plugin-area/plugin-api.js +6 -9
  48. package/lib/route-based-plugin-area/plugin-api.js.map +1 -1
  49. package/lib/route-based-plugin-area/plugin-context.js +2 -18
  50. package/lib/route-based-plugin-area/plugin-context.js.map +1 -1
  51. package/lib/route-based-plugin-area/route-based-plugin-area.js +4 -10
  52. package/lib/route-based-plugin-area/route-based-plugin-area.js.map +1 -1
  53. package/lib/router-factory/index.js +3 -7
  54. package/lib/router-factory/index.js.map +1 -1
  55. package/lib/router-factory/index.native.js +3 -7
  56. package/lib/router-factory/index.native.js.map +1 -1
  57. package/lib/utils/before-ssr.js +2 -4
  58. package/lib/utils/before-ssr.js.map +1 -1
  59. package/lib/utils/combine.js +1 -3
  60. package/lib/utils/combine.js.map +1 -1
  61. package/lib/utils/hydrate.js +2 -4
  62. package/lib/utils/hydrate.js.map +1 -1
  63. package/lib/utils/sort-keys.js +2 -4
  64. package/lib/utils/sort-keys.js.map +1 -1
  65. package/lib/utils/utils.js +2 -3
  66. package/lib/utils/utils.js.map +1 -1
  67. package/package.json +6 -5
  68. package/lib/__tests__/fill-register-test.js +0 -45
  69. package/lib/__tests__/fill-register-test.js.map +0 -1
  70. package/lib/__tests__/helpers/sample-menu.js +0 -75
  71. package/lib/__tests__/helpers/sample-menu.js.map +0 -1
  72. package/lib/__tests__/integrated-routes.test.js +0 -59
  73. package/lib/__tests__/integrated-routes.test.js.map +0 -1
  74. package/lib/__tests__/router-render.test.js +0 -50
  75. package/lib/__tests__/router-render.test.js.map +0 -1
  76. package/lib/connector/connector.test.js +0 -11
  77. package/lib/connector/connector.test.js.map +0 -1
  78. package/lib/connector/index.js +0 -2
  79. package/lib/connector/index.js.map +0 -1
  80. package/lib/interfaces/extended-feature.js +0 -2
  81. package/lib/interfaces/extended-feature.js.map +0 -1
  82. package/lib/interfaces/feature.js +0 -2
  83. package/lib/interfaces/feature.js.map +0 -1
  84. package/lib/interfaces/index.js +0 -6
  85. package/lib/interfaces/index.js.map +0 -1
  86. package/lib/interfaces/new-router.js +0 -2
  87. package/lib/interfaces/new-router.js.map +0 -1
  88. package/lib/interfaces/router.js +0 -2
  89. package/lib/interfaces/router.js.map +0 -1
  90. package/lib/inversify/index.js +0 -2
  91. package/lib/inversify/index.js.map +0 -1
  92. package/lib/plugin-area/__tests__/higher-order-component-util.test.js +0 -39
  93. package/lib/plugin-area/__tests__/higher-order-component-util.test.js.map +0 -1
  94. package/lib/plugin-area/__tests__/plugin-api.test.js +0 -52
  95. package/lib/plugin-area/__tests__/plugin-api.test.js.map +0 -1
  96. package/lib/plugin-area/higher-order-component-util.js +0 -19
  97. package/lib/plugin-area/higher-order-component-util.js.map +0 -1
  98. package/lib/route/__tests__/admin-new-routes.test.js +0 -145
  99. package/lib/route/__tests__/admin-new-routes.test.js.map +0 -1
  100. package/lib/route/__tests__/config-routes.test.d.ts +0 -0
  101. package/lib/route/__tests__/config-routes.test.js +0 -326
  102. package/lib/route/__tests__/config-routes.test.js.map +0 -1
  103. package/lib/route/__tests__/getFlatMenus.test.js +0 -94
  104. package/lib/route/__tests__/getFlatMenus.test.js.map +0 -1
  105. package/lib/route/__tests__/render-routes-config.test.js +0 -57
  106. package/lib/route/__tests__/render-routes-config.test.js.map +0 -1
  107. package/lib/route/__tests__/route-type.test.js +0 -8
  108. package/lib/route/__tests__/route-type.test.js.map +0 -1
  109. package/lib/route/get-routes.test.js +0 -184
  110. package/lib/route/get-routes.test.js.map +0 -1
  111. package/lib/route/index.js +0 -3
  112. package/lib/route/index.js.map +0 -1
  113. package/lib/route/index.native.js +0 -2
  114. package/lib/route/index.native.js.map +0 -1
  115. package/lib/route/old/__tests__/config-sidebar-menu.test.js +0 -200
  116. package/lib/route/old/__tests__/config-sidebar-menu.test.js.map +0 -1
  117. package/lib/route/old/get-routes-notused.js +0 -63
  118. package/lib/route/old/get-routes-notused.js.map +0 -1
  119. package/lib/route/react-navigation/get-navigation-utils.test.js +0 -180
  120. package/lib/route/react-navigation/get-navigation-utils.test.js.map +0 -1
  121. package/lib/route/react-navigation/index.js +0 -3
  122. package/lib/route/react-navigation/index.js.map +0 -1
  123. package/lib/route/react-navigation/react-native.sample.test.js +0 -13
  124. package/lib/route/react-navigation/react-native.sample.test.js.map +0 -1
  125. package/lib/route/react-navigation/react-native.sample1.test.js +0 -30
  126. package/lib/route/react-navigation/react-native.sample1.test.js.map +0 -1
  127. package/lib/route/react-navigation/react-navigation-render.test.js +0 -139
  128. package/lib/route/react-navigation/react-navigation-render.test.js.map +0 -1
  129. package/lib/route/react-navigation/routes.js +0 -2
  130. package/lib/route/react-navigation/routes.js.map +0 -1
  131. package/lib/route/render-routes.test.js +0 -248
  132. package/lib/route/render-routes.test.js.map +0 -1
  133. package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.js +0 -39
  134. package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.js.map +0 -1
  135. package/lib/route-based-plugin-area/__tests__/plugin-api.test.js +0 -52
  136. package/lib/route-based-plugin-area/__tests__/plugin-api.test.js.map +0 -1
  137. package/lib/route-based-plugin-area/higher-order-component-util.js +0 -19
  138. package/lib/route-based-plugin-area/higher-order-component-util.js.map +0 -1
  139. package/lib/route-based-plugin-area/index.js +0 -3
  140. package/lib/route-based-plugin-area/index.js.map +0 -1
  141. package/lib/utils/index.js +0 -6
  142. package/lib/utils/index.js.map +0 -1
  143. package/lib/utils/sort-keys.test.js +0 -31
  144. package/lib/utils/sort-keys.test.js.map +0 -1
@@ -1,75 +0,0 @@
1
- export const menuData = [
2
- {
3
- name: 'dashboard',
4
- icon: 'dashboard',
5
- path: 'dashboard',
6
- children: [
7
- { name: 'analysis', path: 'analysis' },
8
- { name: 'monitor', path: 'monitor' },
9
- { name: 'workplace' },
10
- ],
11
- },
12
- {
13
- name: 'form',
14
- icon: 'form',
15
- path: 'form',
16
- children: [
17
- { name: 'basic-form', path: 'basic-form' },
18
- { name: 'step-form', path: 'step-form' },
19
- { name: 'admin', authority: 'admin' },
20
- ],
21
- }, {
22
- name: 'table',
23
- icon: 'table',
24
- path: 'list',
25
- children: [
26
- { name: 'table-list', path: 'table-list' },
27
- { name: 'basic-list', path: 'basic-list' },
28
- { name: 'card-list', path: 'card-list' },
29
- {
30
- name: 'search',
31
- children: [
32
- { name: 'articles', path: 'articles' },
33
- { name: 'projects', path: 'projects' },
34
- { name: 'applications', path: 'applications' },
35
- ],
36
- },
37
- ],
38
- }, {
39
- name: 'profile',
40
- icon: 'profile',
41
- path: 'profile',
42
- children: [
43
- { name: 'basic' },
44
- { name: 'advanced', authority: 'admin' },
45
- ],
46
- }, {
47
- name: 'check-circle-o',
48
- path: 'result',
49
- children: [
50
- { name: 'success', path: 'success' },
51
- { name: 'fail', path: 'fail' },
52
- ],
53
- }, {
54
- name: 'warning',
55
- path: 'exception',
56
- children: [
57
- { name: '403', path: '403' },
58
- { name: '404', path: '404' },
59
- { name: '500', path: '500' },
60
- { name: 'trigger', path: 'trigger', hideInMenu: true },
61
- ],
62
- },
63
- {
64
- name: 'user',
65
- icon: 'user',
66
- path: 'user',
67
- authority: 'guest',
68
- children: [
69
- { name: 'login', path: 'login' },
70
- { name: 'register', path: 'register' },
71
- { name: 'register-result', path: 'register-result' },
72
- ],
73
- },
74
- ];
75
- //# sourceMappingURL=sample-menu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sample-menu.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/sample-menu.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB;QACI,IA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AE,SAAS,EAAE,OAAO,EAAE;SAC3C;KACJ,EAAE;QACC,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE;YACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACpC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;SACjC;KACJ,EAAE;QACC,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE;YACN,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;YAC5B,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;YAC5B,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;YAC5B,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE;SACzD;KACJ;IACD;QACI,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;YAChC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;YACtC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE;SACvD;KACJ;CACJ,CAAC"}
@@ -1,59 +0,0 @@
1
- import * as React from 'react';
2
- import * as ReactDOMServer from 'react-dom/server';
3
- import StaticRouter from 'react-router/StaticRouter';
4
- import { renderRoutes, matchRoutes } from 'react-router-config';
5
- import { Feature } from '../connector';
6
- import { ConsoleLogger } from '@cdm-logger/server';
7
- const logger = ConsoleLogger.create('test', { level: 'trace' });
8
- import 'jest';
9
- describe('integration', () => {
10
- it('generates the same matches in renderRoutes and matchRoutes', () => {
11
- const rendered = [];
12
- const Comp = ({ match, route: { routes } }) => (rendered.push(match), renderRoutes(routes));
13
- const genRoutes = [
14
- {
15
- ['/ghost']: { component: Comp },
16
- ['/pepper']: { component: Comp, exact: false },
17
- ['/pepper/:type']: { component: Comp, exact: false },
18
- ['/pepper/:type/scoville']: { component: Comp, exact: false },
19
- },
20
- ];
21
- const result = [
22
- {
23
- path: '/ghost',
24
- component: Comp,
25
- },
26
- {
27
- path: '/pepper',
28
- component: Comp,
29
- exact: false,
30
- routes: [
31
- {
32
- path: '/pepper/:type',
33
- component: Comp,
34
- exact: false,
35
- routes: [
36
- {
37
- path: '/pepper/:type/scoville',
38
- component: Comp,
39
- exact: false,
40
- },
41
- ],
42
- },
43
- ],
44
- },
45
- ];
46
- const connector = new Feature({ routeConfig: genRoutes });
47
- const connectorRoutes = connector.getConfiguredRoutes();
48
- expect(connectorRoutes).toMatchObject(result);
49
- const pathname = '/pepper/jalepeno';
50
- const branch = matchRoutes(connectorRoutes, pathname);
51
- ReactDOMServer.renderToString(React.createElement(StaticRouter, { location: pathname, context: {} }, renderRoutes(connectorRoutes)));
52
- expect(branch).toMatchSnapshot();
53
- expect(branch.length).toEqual(2);
54
- expect(rendered.length).toEqual(2);
55
- expect(branch[0].match).toEqual(rendered[0]);
56
- expect(branch[1].match).toEqual(rendered[1]);
57
- });
58
- });
59
- //# sourceMappingURL=integrated-routes.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integrated-routes.test.js","sourceRoot":"","sources":["../../src/__tests__/integrated-routes.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,YAAY,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAA0B,MAAM,oBAAoB,CA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MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;QAC1D,MAAM,eAAe,GAAG,SAAS,CAAC,mBAAmB,EAAE,CAAC;QACxD,MAAM,CAAC,eAAe,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,kBAAkB,CAAC;QACpC,MAAM,MAAM,GAAG,WAAW,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QACtD,cAAc,CAAC,cAAc,CACzB,oBAAC,YAAY,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,IACxC,YAAY,CAAC,eAAe,CAAC,CACnB,CAClB,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;QACjC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
@@ -1,50 +0,0 @@
1
- import * as React from 'react';
2
- import * as ReactDOMServer from 'react-dom/server';
3
- import Router from 'react-router';
4
- import { renderRoutes } from 'react-router-config';
5
- import { Feature } from '../connector';
6
- import { ConsoleLogger } from '@cdm-logger/server';
7
- import 'jest';
8
- export const logger = ConsoleLogger.create('test', { level: 'trace' });
9
- const { StaticRouter } = Router;
10
- describe('renderRoutes', () => {
11
- let renderedRoutes;
12
- let renderedExtraProps;
13
- const Comp = ({ route, route: { routes }, ...extraProps }) => (renderedRoutes.push(route),
14
- renderedExtraProps.push(extraProps),
15
- renderRoutes(routes));
16
- beforeEach(() => {
17
- renderedRoutes = [];
18
- renderedExtraProps = [];
19
- });
20
- it('renders pathless routes', () => {
21
- const routeToMatch = {
22
- component: Comp,
23
- };
24
- const genRoutes = [
25
- {
26
- ['super']: { component: Comp },
27
- },
28
- ];
29
- const routes = [routeToMatch];
30
- const connector = new Feature({ routeConfig: genRoutes });
31
- ReactDOMServer.renderToString(React.createElement(StaticRouter, { location: "/path", context: {} }, renderRoutes(routes)));
32
- expect(renderedRoutes.length).toEqual(1);
33
- expect(renderedRoutes[0]).toEqual(routeToMatch);
34
- });
35
- // it('passes extraProps to the component rendered by a pathless route', () => {
36
- // const routeToMatch = {
37
- // component: Comp,
38
- // };
39
- // const routes = [routeToMatch];
40
- // const extraProps = { anExtraProp: 'anExtraPropValue' };
41
- // ReactDOMServer.renderToString(
42
- // <StaticRouter location="/path" context={{}}>
43
- // {renderRoutes(routes, extraProps)}
44
- // </StaticRouter>,
45
- // );
46
- // expect(renderedExtraProps.length).toEqual(1);
47
- // expect(renderedExtraProps[0].anExtraProp).toEqual('anExtraPropValue');
48
- // });
49
- });
50
- //# sourceMappingURL=router-render.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router-render.test.js","sourceRoot":"","sources":["../../src/__tests__/router-render.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,YAAY,EAAe,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAA0B,MAAM,oBAAoB,CAAC;AAE3E,OAAO,MAAM,CAAC;AAEd,MAAM,CAAC,MAAM,MAAM,GAAsB,aAAa,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;IAClD,CAAC,CAAC,CAAC;IAEH,gFAAgF;IAChF,6BAA6B;IAC7B,2BAA2B;IAC3B,SAAS;IACT,qCAAqC;IACrC,8DAA8D;IAE9D,qCAAqC;IACrC,uDAAuD;IACvD,iDAAiD;IACjD,2BAA2B;IAC3B,SAAS;IACT,oDAAoD;IACpD,6EAA6E;IAC7E,MAAM;AACR,CAAC,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- import { Feature } from './connector';
3
- import { Route } from 'react-router-dom';
4
- import 'jest';
5
- describe('Test Feature', () => {
6
- it('test Connector with router', () => {
7
- const feature = new Feature({ route: React.createElement(Route, { exact: true, path: "/", component: () => React.createElement("div", null, "test") }) });
8
- console.log(feature);
9
- });
10
- });
11
- //# sourceMappingURL=connector.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connector.test.js","sourceRoot":"","sources":["../../src/connector/connector.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,MAAM,CAAC;AAEd,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAE1B,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAClC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE,oBAAC,KAAK,IAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAC,GAAG,EAAC,SAAS,EAAE,GAAG,EAAE,CAAC,wCAAe,GAAI,EAAE,CAAC,CAAC;QAC1G,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './connector';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connector/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=extended-feature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extended-feature.js","sourceRoot":"","sources":["../../src/interfaces/extended-feature.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=feature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"feature.js","sourceRoot":"","sources":["../../src/interfaces/feature.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- export * from './router';
2
- export * from './extended-feature';
3
- export * from './menu';
4
- export * from './new-router';
5
- export * from './feature';
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=new-router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-router.js","sourceRoot":"","sources":["../../src/interfaces/new-router.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/interfaces/router.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export * from './InversifyContext';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/inversify/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -1,39 +0,0 @@
1
- import React, { Component } from 'react';
2
- import { createHigherOrderComponent } from '../higher-order-component-util';
3
- describe('createHigherOrderComponent', () => {
4
- it('should use default name for anonymous function', () => {
5
- const TestComponent = createHigherOrderComponent((OriginalComponent) => OriginalComponent, 'withTest')(() => React.createElement("div", null));
6
- expect(TestComponent.displayName).toBe('WithTest(Component');
7
- });
8
- it('should use camel case starting with upper for wrapper prefix ', () => {
9
- const TestComponent = createHigherOrderComponent((OriginalComponent) => OriginalComponent, 'with-one-two_threeFOUR')(() => React.createElement("div", null));
10
- expect(TestComponent.displayName).toBe('WithOneTwoThreeFour(Component)');
11
- });
12
- it('should use function name', () => {
13
- function SomeComponent() {
14
- return React.createElement("div", null);
15
- }
16
- const TestComponent = createHigherOrderComponent((OriginalComponent) => OriginalComponent, 'withTest')(SomeComponent);
17
- expect(TestComponent.displayName).toBe('WithTest(SomeComponent)');
18
- });
19
- it('should use component class name', () => {
20
- class SomeAnotherComponent extends Component {
21
- render() {
22
- return React.createElement("div", null);
23
- }
24
- }
25
- const TestComponent = createHigherOrderComponent((OriginalComponent) => OriginalComponent, 'withTest')(SomeAnotherComponent);
26
- expect(TestComponent.displayName).toBe('WithTest(SomeAnotherComponent)');
27
- });
28
- it('should use displayName property', () => {
29
- class SomeYetAnotherComponent extends Component {
30
- render() {
31
- return React.createElement("div", null);
32
- }
33
- }
34
- SomeYetAnotherComponent.displayName = 'CustomDisplayName';
35
- const TestComponent = createHigherOrderComponent((OriginalComponent) => OriginalComponent, 'withTest')(SomeYetAnotherComponent);
36
- expect(TestComponent.displayName).toBe('WithTest(CustomDisplayName)');
37
- });
38
- });
39
- //# sourceMappingURL=higher-order-component-util.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"higher-order-component-util.test.js","sourceRoot":"","sources":["../../../src/plugin-area/__tests__/higher-order-component-util.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E,QAAQ,CAAC,4BAA4B,EAAE,GAAG,E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AI,CACvC,gCAAgC,CAChC,CAAC;IACH,CAAC,CAAE,CAAC;IAEJ,EAAE,CAAE,iCAAiC,EAAE,GAAG,EAAE;QAC3C,MAAM,uBAAwB,SAAQ,SAAS;YAC9C,MAAM;gBACL,OAAO,gCAAO,CAAC;YAChB,CAAC;SACD;QACA,uBAA+B,CAAC,WAAW,GAAG,mBAAmB,CAAC;QACnE,MAAM,aAAa,GAAG,0BAA0B,CAC/C,CAAE,iBAAiB,EAAG,EAAE,CAAC,iBAAiB,EAC1C,UAAU,CACV,CAAE,uBAAuB,CAAE,CAAC;QAE7B,MAAM,CAAE,aAAa,CAAC,WAAW,CAAE,CAAC,IAAI,CACvC,6BAA6B,CAC7B,CAAC;IACH,CAAC,CAAE,CAAC;AACL,CAAC,CAAC,CAAA"}
@@ -1,52 +0,0 @@
1
- import { registerPlugin, unregisterPlugin, getPlugin, getPlugins } from '../plugin-api';
2
- describe('registerPlugin', () => {
3
- afterEach(() => {
4
- getPlugins().forEach((plugin) => {
5
- unregisterPlugin(plugin.name);
6
- });
7
- });
8
- it('successfully registers a plugin', () => {
9
- const name = 'plugin';
10
- const icon = 'smiley';
11
- const Component = () => 'plugin content';
12
- registerPlugin(name, {
13
- render: Component,
14
- icon,
15
- });
16
- expect(getPlugin(name)).toEqual({
17
- name,
18
- render: Component,
19
- icon,
20
- });
21
- });
22
- it('fails to register a plugin without a settings object', () => {
23
- registerPlugin();
24
- expect(console).toThrowError('No settings object provided!');
25
- });
26
- it('fails to register a plugin with special character in the name', () => {
27
- registerPlugin('plugin/with/special/characters', {
28
- render: () => { },
29
- });
30
- expect(console).toThrowError('Plugin names must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
31
- });
32
- it('fails to register a plugin with a non-string name', () => {
33
- registerPlugin({}, {
34
- render: () => { },
35
- });
36
- expect(console).toThrowError('Plugin names must be strings.');
37
- });
38
- it('fails to register a plugin without a render function', () => {
39
- registerPlugin('another-plugin', {});
40
- expect(console).toThrowError('The "render" property must be specified and must be a valid function.');
41
- });
42
- it('fails to register a plugin that was already been registered', () => {
43
- registerPlugin('plugin', {
44
- render: () => 'plugin content',
45
- });
46
- registerPlugin('plugin', {
47
- render: () => 'plugin content',
48
- });
49
- expect(console).toThrowError('Plugin "plugin" is already registered.');
50
- });
51
- });
52
- //# sourceMappingURL=plugin-api.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-api.test.js","sourceRoot":"","sources":["../../../src/plugin-area/__tests__/plugin-api.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGvF,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5B,SAAS,CAAC,GAAG,EAAE;QACX,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC5B,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACvC,MAAM,IAAI,GAAG,QAAQ,CAAC;QACtB,MAAM,IAAI,GAAG,QAAQ,CAAC;QACtB,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC;QAEzC,cAAc,CAAC,IAAI,EAAE;YACjB,MAAM,EAAE,SAAS;YACjB,IAAI;SACP,CAAC,CAAC;QAEH,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;YAC5B,IAAI;YACJ,MAAM,EAAE,SAAS;YACjB,IAAI;SACP,CAAC,CAAA;IACN,CAAC,CAAC,CAAC;IAEN,EAAE,CAAE,sDAAsD,EAAE,GAAG,EAAE;QAC1D,cAAe,EAAE,CAAC;QACxB,MAAM,CAAE,OAAO,CAAE,CAAC,YAAY,CAAE,8BAA8B,CAAE,CAAC;IAClE,CAAC,CAAE,CAAC;IAEJ,EAAE,CAAE,+DAA+D,EAAE,GAAG,EAAE;QACzE,cAAc,CAAE,gCAAgC,EAAE;YACjD,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;SAChB,CAAE,CAAC;QACJ,MAAM,CAAE,OAAO,CAAE,CAAC,YAAY,CAC7B,4HAA4H,CAC5H,CAAC;IACH,CAAC,CAAE,CAAC;IAEJ,EAAE,CAAE,mDAAmD,EAAE,GAAG,EAAE;QAC7D,cAAc,CACb,EAAE,EACF;YACC,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;SAChB,CACD,CAAC;QACF,MAAM,CAAE,OAAO,CAAE,CAAC,YAAY,CAAE,+BAA+B,CAAE,CAAC;IACnE,CAAC,CAAE,CAAC;IAEJ,EAAE,CAAE,sDAAsD,EAAE,GAAG,EAAE;QAChE,cAAc,CAAE,gBAAgB,EAAE,EAAE,CAAE,CAAC;QACvC,MAAM,CAAE,OAAO,CAAE,CAAC,YAAY,CAC7B,uEAAuE,CACvE,CAAC;IACH,CAAC,CAAE,CAAC;IAEJ,EAAE,CAAE,6DAA6D,EAAE,GAAG,EAAE;QACvE,cAAc,CAAE,QAAQ,EAAE;YACzB,MAAM,EAAE,GAAG,EAAE,CAAC,gBAAgB;SAC9B,CAAE,CAAC;QACJ,cAAc,CAAE,QAAQ,EAAE;YACzB,MAAM,EAAE,GAAG,EAAE,CAAC,gBAAgB;SAC9B,CAAE,CAAC;QACJ,MAAM,CAAE,OAAO,CAAE,CAAC,YAAY,CAC7B,wCAAwC,CACxC,CAAC;IACH,CAAC,CAAE,CAAC;AACL,CAAC,CAAC,CAAA"}
@@ -1,19 +0,0 @@
1
- import { camelCase, upperFirst } from 'lodash-es';
2
- /**
3
- * Given a function mapping a component to an enhanced component and modifier
4
- * name, returns the enhanced component augmented with a generated displayName.
5
- *
6
- * @param mapComponentToEnhancedComponent Function mapping component to enhanced component.
7
- * @param modifierName Seed name from which to generated display name.
8
- *
9
- * @return Component class with generated display name assigned.
10
- */
11
- export function createHigherOrderComponent(mapComponentToEnhancedComponent, modifierName) {
12
- return (OriginalComponent) => {
13
- const EnhancedComponent = mapComponentToEnhancedComponent(OriginalComponent);
14
- const { displayName = OriginalComponent.name || 'Component', } = OriginalComponent;
15
- EnhancedComponent.displayName = `${upperFirst(camelCase(modifierName))}(${displayName})`;
16
- return EnhancedComponent;
17
- };
18
- }
19
- //# sourceMappingURL=higher-order-component-util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"higher-order-component-util.js","sourceRoot":"","sources":["../../src/plugin-area/higher-order-component-util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACtC,+BAA+B,EAC/B,YAAY;IAEZ,OAAO,CAAE,iBAAiB,EAAG,EAAE;QAC3B,MAAM,iBAAiB,GAAG,+BAA+B,CACrD,iBAAiB,CACpB,CAAC;QACF,MAAM,EACF,WAAW,GAAG,iBAAiB,CAAC,IAAI,IAAI,WAAW,GACtD,GAAG,iBAAiB,CAAC;QACtB,iBAAiB,CAAC,WAAW,GAAG,GAAI,UAAU,CAC1C,SAAS,CAAC,YAAY,CAAC,CAC1B,IAAI,WAAW,GAAG,CAAC;QAEpB,OAAO,iBAAiB,CAAC;IAC7B,CAAC,CAAA;AACL,CAAC"}
@@ -1,145 +0,0 @@
1
- import * as React from 'react';
2
- import { getRoutes } from '../get-routes';
3
- const sortKeys = require('sort-keys');
4
- import { renderRoutes2 as renderRoutes } from '../render-routes';
5
- import 'jest';
6
- function MyComponent(props) {
7
- return React.createElement("div", null,
8
- "MyComponent ",
9
- JSON.stringify(props));
10
- }
11
- const routerConfig1 = {
12
- ['/']: {
13
- exact: false,
14
- component: MyComponent
15
- },
16
- ['//']: {
17
- exact: true,
18
- component: MyComponent
19
- },
20
- ['//a']: {
21
- component: MyComponent,
22
- },
23
- ['/a/1']: {
24
- component: MyComponent,
25
- },
26
- ['/a/:b']: {
27
- component: MyComponent,
28
- },
29
- ['/a/:b/1']: {
30
- component: MyComponent,
31
- },
32
- ['/a/:b/c']: {
33
- exact: true,
34
- component: MyComponent,
35
- },
36
- ['/a/:b/c/1']: {
37
- component: MyComponent,
38
- },
39
- ['/a/:c/1']: {
40
- component: MyComponent,
41
- },
42
- ['/a/2']: {
43
- component: MyComponent,
44
- },
45
- ['/a/2/1']: {
46
- component: MyComponent,
47
- },
48
- ['/ab/2/1']: {
49
- component: MyComponent,
50
- },
51
- ['/b/1']: {
52
- component: MyComponent,
53
- },
54
- ['/b/login/register']: {
55
- component: MyComponent,
56
- },
57
- };
58
- const routerConfig = {
59
- ["/login"]: { exact: true, component: MyComponent },
60
- ["/callback"]: { exact: true, component: MyComponent },
61
- ["/:orgName/usermenu/logout"]: { exact: true, component: MyComponent },
62
- ["/:orgName/usermenu/profile"]: { exact: true, component: MyComponent },
63
- ["/authenticate-popup"]: { exact: true, component: MyComponent },
64
- ["/reset-password"]: { exact: true, component: MyComponent },
65
- ["/:orgName/usermenu/account/"]: { exact: false, component: MyComponent },
66
- ["/:orgName/usermenu/billing"]: { exact: false, component: MyComponent },
67
- ["/"]: { exact: true, component: MyComponent },
68
- ["/:orgName/usermenu/account"]: { exact: false, component: MyComponent },
69
- ["/:orgName/usermenu/account-settings"]: { exact: true, component: MyComponent },
70
- ["/:orgName/teams/view/:teamName"]: { exact: false, component: MyComponent },
71
- ["/:orgName/teams"]: { exact: true, component: MyComponent },
72
- ["/:orgName/invitation"]: { exact: true, component: MyComponent },
73
- ["/:orgName/usermenu/organizations"]: { exact: true, component: MyComponent },
74
- ["/:orgName/usermenu/switch-organization"]: { exact: true, component: MyComponent },
75
- ["/:orgName/pref"]: { exact: false, component: MyComponent },
76
- ["/:orgName/members"]: { exact: false, component: MyComponent },
77
- ["/:orgName/dashboard"]: { exact: true, component: MyComponent },
78
- ["/:orgName/registries"]: { exact: true, component: MyComponent },
79
- ["/:orgName/create-workspace"]: { exact: true, component: MyComponent },
80
- ["/:orgName/workspace/:id/details"]: { exact: true, component: MyComponent },
81
- ["/:orgName/workspace/:id/editor"]: { exact: true, component: MyComponent },
82
- ["/:orgName/workspace/:id"]: { exact: true, component: undefined },
83
- ["/:orgName/repository"]: { exact: true, component: MyComponent },
84
- ["/:orgName/artifact"]: { exact: false, component: MyComponent },
85
- ["/:orgName"]: { exact: false, component: MyComponent },
86
- };
87
- const compare = ((a, b) => {
88
- const aStr = String(a).toLowerCase();
89
- const bStr = String(b).toLowerCase();
90
- // Alphanumeric elements always come before non-alphanumeric elements
91
- const aIsAlphanumeric = notStartWithColon(aStr);
92
- const bIsAlphanumeric = notStartWithColon(bStr);
93
- console.log('aIsAlphanumeric, bIsAlphanumeric', aIsAlphanumeric, bIsAlphanumeric);
94
- if (aIsAlphanumeric && !bIsAlphanumeric) {
95
- return -1;
96
- }
97
- else if (bIsAlphanumeric && !aIsAlphanumeric) {
98
- return 1;
99
- }
100
- // Numerical elements always come before alphabetic elements
101
- const aNum = Number(a);
102
- const bNum = Number(b);
103
- // If both are numerical, sort in the usual fashion (smaller goes first)
104
- if (aNum && bNum) {
105
- return aNum - bNum;
106
- // If a is numerical but b isn't, put a first.
107
- }
108
- else if (aNum) {
109
- return -1;
110
- // If b is numerical but a isn't, put b first.
111
- }
112
- else if (bNum) {
113
- return 1;
114
- }
115
- // In all other cases, default to usual sort order.
116
- return aStr.localeCompare(bStr);
117
- });
118
- function notStartWithColon(str) {
119
- return !str.match(/^\/:.*/);
120
- }
121
- describe('new getRoutes utility with basic routes', () => {
122
- xtest('with /a', async () => {
123
- const result = {
124
- // component: any,
125
- routes: [{
126
- path: '/a', routes: [{ path: '/a/1', exact: true },
127
- { path: '/a/:b/1', exact: true },
128
- { path: '/a/2', routes: [{ 'exact': true, 'path': '/a/2/1' }] },
129
- { path: '/ab/2/1', exact: true }],
130
- }],
131
- };
132
- const routes1 = getRoutes('/', sortKeys(routerConfig1));
133
- // const routes = getRoutes(/^\/.*/, sortKeys(routerConfig, { compare }));
134
- expect(routes1).toMatchSnapshot();
135
- // expect(routes).toMatchSnapshot();
136
- });
137
- test('with org', async () => {
138
- const routes1 = getRoutes('/', sortKeys(routerConfig1));
139
- const renderedRoutes = renderRoutes({
140
- routes: routes1,
141
- });
142
- expect(renderedRoutes).toMatchSnapshot();
143
- });
144
- });
145
- //# sourceMappingURL=admin-new-routes.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"admin-new-routes.test.js","sourceRoot":"","sources":["../../../src/route/__tests__/admin-new-routes.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACtC,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,MAAM,CAAC;AAEd,SAAS,WAAW,CAAC,KAAK;IACtB,OAAO;;QAAkB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAO,CAAC;AAC1D,CAAC;AAED,MAAM,aAAa,GAAG;IAClB,CAAC,GAAG,CAAC,EAAE;QACH,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,WAAW;KACzB;IACD,CAAC,IAAI,CAAC,EAAE;QACJ,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,WAAW;KACzB;IACD,CAAC,KAAK,CAAC,EAAE;QACL,SAAS,EAAE,WAAW;KACzB;IACD,CAAC,MAAM,CAAC,EAAE;QACN,SAAS,EAAE,WAAW;KACzB;IACD,CAAC,OAAO,CAAC,EAAE;QACP,SAAS,EAAE,WAAW;KACzB;IACD,CAAC,SAAS,CAAC,EAAE;QACT,SAAS,EAAE,WAAW;KACzB;IACD,CAAC,SAAS,CAAC,EAAE;QACT,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,WAAW;KACzB;IACD,CAAC,WAAW,CAAC,EAAE;QACX,SAAS,E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