@riboseinc/paneron-registry-kit 2.0.0-dev9 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/common.d.ts +1 -1
  2. package/common.js +1 -1
  3. package/common.js.map +1 -1
  4. package/index.d.ts +3 -3
  5. package/index.js +3 -3
  6. package/index.js.map +1 -1
  7. package/package.json +26 -19
  8. package/types/cr.d.ts +216 -0
  9. package/types/cr.js +175 -0
  10. package/types/cr.js.map +1 -0
  11. package/types/index.d.ts +1 -0
  12. package/types/index.js +19 -0
  13. package/types/index.js.map +1 -1
  14. package/types/item.d.ts +13 -3
  15. package/types/item.js +11 -1
  16. package/types/item.js.map +1 -1
  17. package/types/proposal.d.ts +31 -14
  18. package/types/proposal.js +1 -1
  19. package/types/proposal.js.map +1 -1
  20. package/types/register.d.ts +6 -5
  21. package/types/register.js +19 -1
  22. package/types/register.js.map +1 -1
  23. package/types/registry.d.ts +8 -3
  24. package/types/registry.js +8 -1
  25. package/types/registry.js.map +1 -1
  26. package/types/stakeholder.d.ts +40 -16
  27. package/types/stakeholder.js +47 -3
  28. package/types/stakeholder.js.map +1 -1
  29. package/types/views.d.ts +98 -24
  30. package/types/views.js.map +1 -1
  31. package/views/AnnotatedChange.d.ts +7 -0
  32. package/views/AnnotatedChange.js +91 -0
  33. package/views/AnnotatedChange.js.map +1 -0
  34. package/views/BrowserCtx.d.ts +66 -2
  35. package/views/BrowserCtx.js +13 -2
  36. package/views/BrowserCtx.js.map +1 -1
  37. package/views/FilterCriteria/CRITERIA_CONFIGURATION.d.ts +13 -1
  38. package/views/FilterCriteria/CRITERIA_CONFIGURATION.js +178 -85
  39. package/views/FilterCriteria/CRITERIA_CONFIGURATION.js.map +1 -1
  40. package/views/FilterCriteria/criteriaGroupToQueryExpression.d.ts +4 -0
  41. package/views/FilterCriteria/criteriaGroupToQueryExpression.js +10 -3
  42. package/views/FilterCriteria/criteriaGroupToQueryExpression.js.map +1 -1
  43. package/views/FilterCriteria/criteriaGroupToSummary.js +7 -7
  44. package/views/FilterCriteria/criteriaGroupToSummary.js.map +1 -1
  45. package/views/FilterCriteria/criteriaToNodes.d.ts +9 -0
  46. package/views/FilterCriteria/criteriaToNodes.js +42 -28
  47. package/views/FilterCriteria/criteriaToNodes.js.map +1 -1
  48. package/views/FilterCriteria/index.d.ts +1 -0
  49. package/views/FilterCriteria/index.js +29 -21
  50. package/views/FilterCriteria/index.js.map +1 -1
  51. package/views/FilterCriteria/models.d.ts +29 -2
  52. package/views/FilterCriteria/models.js +17 -10
  53. package/views/FilterCriteria/models.js.map +1 -1
  54. package/views/FilterCriteria/mutateGroup.d.ts +4 -1
  55. package/views/FilterCriteria/mutateGroup.js +4 -3
  56. package/views/FilterCriteria/mutateGroup.js.map +1 -1
  57. package/views/GenericRelatedItemView.d.ts +1 -1
  58. package/views/GenericRelatedItemView.js +142 -102
  59. package/views/GenericRelatedItemView.js.map +1 -1
  60. package/views/RegisterStakeholder.d.ts +9 -0
  61. package/views/RegisterStakeholder.js +40 -0
  62. package/views/RegisterStakeholder.js.map +1 -0
  63. package/views/RegisterVersion.d.ts +9 -0
  64. package/views/RegisterVersion.js +41 -0
  65. package/views/RegisterVersion.js.map +1 -0
  66. package/views/SearchQuery.d.ts +13 -0
  67. package/views/SearchQuery.js +137 -0
  68. package/views/SearchQuery.js.map +1 -0
  69. package/views/change-request/ChangeRequestContext.d.ts +20 -0
  70. package/views/change-request/ChangeRequestContext.js +56 -0
  71. package/views/change-request/ChangeRequestContext.js.map +1 -0
  72. package/views/change-request/Proposals.d.ts +21 -0
  73. package/views/change-request/Proposals.js +331 -0
  74. package/views/change-request/Proposals.js.map +1 -0
  75. package/views/change-request/objectChangeset.d.ts +31 -0
  76. package/views/change-request/objectChangeset.js +229 -0
  77. package/views/change-request/objectChangeset.js.map +1 -0
  78. package/views/detail/ChangeRequest/Proposal.d.ts +0 -0
  79. package/views/detail/ChangeRequest/Proposal.js +142 -0
  80. package/views/detail/ChangeRequest/Proposal.js.map +1 -0
  81. package/views/detail/ChangeRequest/index.d.ts +13 -0
  82. package/views/detail/ChangeRequest/index.js +207 -0
  83. package/views/detail/ChangeRequest/index.js.map +1 -0
  84. package/views/detail/ChangeRequest/transitions.d.ts +28 -0
  85. package/views/detail/ChangeRequest/transitions.js +530 -0
  86. package/views/detail/ChangeRequest/transitions.js.map +1 -0
  87. package/views/detail/CustomView/index.d.ts +13 -0
  88. package/views/detail/CustomView/index.js +68 -0
  89. package/views/detail/CustomView/index.js.map +1 -0
  90. package/views/detail/RegisterHome/index.d.ts +5 -0
  91. package/views/detail/RegisterHome/index.js +128 -0
  92. package/views/detail/RegisterHome/index.js.map +1 -0
  93. package/views/detail/RegisterItem/RelatedItems.d.ts +13 -0
  94. package/views/detail/RegisterItem/RelatedItems.js +61 -0
  95. package/views/detail/RegisterItem/RelatedItems.js.map +1 -0
  96. package/views/detail/RegisterItem/SupersedingItemMenu.d.ts +13 -0
  97. package/views/detail/RegisterItem/SupersedingItemMenu.js +56 -0
  98. package/views/detail/RegisterItem/SupersedingItemMenu.js.map +1 -0
  99. package/views/detail/RegisterItem/index.d.ts +13 -0
  100. package/views/detail/RegisterItem/index.js +356 -0
  101. package/views/detail/RegisterItem/index.js.map +1 -0
  102. package/views/detail/RegisterMeta/RegisterMetaForm.d.ts +10 -0
  103. package/views/detail/RegisterMeta/RegisterMetaForm.js +331 -0
  104. package/views/detail/RegisterMeta/RegisterMetaForm.js.map +1 -0
  105. package/views/detail/RegisterMeta/index.d.ts +10 -0
  106. package/views/detail/RegisterMeta/index.js +111 -0
  107. package/views/detail/RegisterMeta/index.js.map +1 -0
  108. package/views/detail/index.d.ts +1 -0
  109. package/views/detail/index.js +24 -0
  110. package/views/detail/index.js.map +1 -0
  111. package/views/diffing/InlineDiff.d.ts +12 -0
  112. package/views/diffing/InlineDiff.js +58 -0
  113. package/views/diffing/InlineDiff.js.map +1 -0
  114. package/views/diffing/StructuredDiff.d.ts +11 -0
  115. package/views/diffing/StructuredDiff.js +65 -0
  116. package/views/diffing/StructuredDiff.js.map +1 -0
  117. package/views/hooks/useCustomView.d.ts +3 -0
  118. package/views/hooks/useCustomView.js +24 -0
  119. package/views/hooks/useCustomView.js.map +1 -0
  120. package/views/hooks/useItemClassConfig.d.ts +3 -0
  121. package/views/hooks/useItemClassConfig.js +24 -0
  122. package/views/hooks/useItemClassConfig.js.map +1 -0
  123. package/views/hooks/useItemRef.d.ts +3 -0
  124. package/views/hooks/useItemRef.js +39 -0
  125. package/views/hooks/useItemRef.js.map +1 -0
  126. package/views/hooks/useSingleRegisterItemData.d.ts +3 -0
  127. package/views/hooks/useSingleRegisterItemData.js +32 -0
  128. package/views/hooks/useSingleRegisterItemData.js.map +1 -0
  129. package/views/index.d.ts +2 -2
  130. package/views/index.js +161 -130
  131. package/views/index.js.map +1 -1
  132. package/views/itemPathUtils.d.ts +45 -2
  133. package/views/itemPathUtils.js +101 -14
  134. package/views/itemPathUtils.js.map +1 -1
  135. package/views/itemQueryUtils.d.ts +11 -0
  136. package/views/itemQueryUtils.js +48 -0
  137. package/views/itemQueryUtils.js.map +1 -0
  138. package/views/protocolRegistry.d.ts +12 -0
  139. package/views/protocolRegistry.js +42 -0
  140. package/views/protocolRegistry.js.map +1 -0
  141. package/views/sidebar/Browse/index.d.ts +11 -0
  142. package/views/sidebar/Browse/index.js +453 -0
  143. package/views/sidebar/Browse/index.js.map +1 -0
  144. package/views/sidebar/Export/index.d.ts +5 -0
  145. package/views/sidebar/Export/index.js +94 -0
  146. package/views/sidebar/Export/index.js.map +1 -0
  147. package/views/sidebar/ListItem.d.ts +10 -0
  148. package/views/sidebar/ListItem.js +43 -0
  149. package/views/sidebar/ListItem.js.map +1 -0
  150. package/views/sidebar/Registration/index.d.ts +5 -0
  151. package/views/sidebar/Registration/index.js +163 -0
  152. package/views/sidebar/Registration/index.js.map +1 -0
  153. package/views/sidebar/Search/index.d.ts +18 -0
  154. package/views/sidebar/Search/index.js +177 -0
  155. package/views/sidebar/Search/index.js.map +1 -0
  156. package/views/sidebar/index.d.ts +6 -0
  157. package/views/sidebar/index.js +104 -0
  158. package/views/sidebar/index.js.map +1 -0
  159. package/views/util.d.ts +29 -5
  160. package/views/util.js +92 -6
  161. package/views/util.js.map +1 -1
  162. package/views/ChangeRequest.d.ts +0 -12
  163. package/views/ChangeRequest.js +0 -689
  164. package/views/ChangeRequest.js.map +0 -1
  165. package/views/ItemBrowser.d.ts +0 -12
  166. package/views/ItemBrowser.js +0 -258
  167. package/views/ItemBrowser.js.map +0 -1
  168. package/views/ItemDetails.d.ts +0 -14
  169. package/views/ItemDetails.js +0 -128
  170. package/views/ItemDetails.js.map +0 -1
  171. package/views/MainView.d.ts +0 -8
  172. package/views/MainView.js +0 -34
  173. package/views/MainView.js.map +0 -1
  174. package/views/RegisterInformation.d.ts +0 -7
  175. package/views/RegisterInformation.js +0 -264
  176. package/views/RegisterInformation.js.map +0 -1
  177. package/views/RegisterItemGrid.d.ts +0 -25
  178. package/views/RegisterItemGrid.js +0 -276
  179. package/views/RegisterItemGrid.js.map +0 -1
package/common.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const REGISTER_METADATA_FILENAME = "register.yaml";
1
+ export declare const REGISTER_METADATA_FILENAME = "/register.yaml";
package/common.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.REGISTER_METADATA_FILENAME = void 0;
7
- const REGISTER_METADATA_FILENAME = 'register.yaml';
7
+ const REGISTER_METADATA_FILENAME = '/register.yaml';
8
8
  exports.REGISTER_METADATA_FILENAME = REGISTER_METADATA_FILENAME;
package/common.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CAAC","sourcesContent":["export const REGISTER_METADATA_FILENAME = 'register.yaml';\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC","sourcesContent":["export const REGISTER_METADATA_FILENAME = '/register.yaml';\n"]}
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Extension } from '@riboseinc/paneron-extension-kit/types';
2
- import { ExtensionMakerProps } from '@riboseinc/paneron-extension-kit/types/extension-maker';
3
- import { RegistryViewProps } from './types';
1
+ import type { Extension } from '@riboseinc/paneron-extension-kit/types';
2
+ import type { ExtensionMakerProps } from '@riboseinc/paneron-extension-kit/types/extension-maker';
3
+ import type { RegistryViewProps } from './types';
4
4
  export declare type RegistryExtensionMakerProps = Pick<ExtensionMakerProps, 'name'> & RegistryViewProps;
5
5
  export declare type RegistryExtensionMaker = (opts: RegistryExtensionMakerProps) => Promise<Extension>;
6
6
  export declare const makeRegistryExtension: RegistryExtensionMaker;
package/index.js CHANGED
@@ -13,9 +13,9 @@ var _views = require("./views");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
 
18
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
19
 
20
20
  const makeRegistryExtension = function (opts) {
21
21
  const {
@@ -36,7 +36,7 @@ const makeRegistryExtension = function (opts) {
36
36
  return (0, _paneronExtensionKit.makeExtension)({
37
37
  mainView,
38
38
  name,
39
- requiredHostAppVersion: '1.0.0-alpha19',
39
+ requiredHostAppVersion: '2.0.0',
40
40
  datasetMigrations: {},
41
41
  datasetInitializer: () => Promise.resolve().then(() => _interopRequireWildcard(require('./migrations/initial')))
42
42
  });
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAIjE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,MAAM,CAAC,MAAM,qBAAqB,GAA2B,UAAU,IAAI;IACzE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAEtB,MAAM,QAAQ,GAAoC,KAAK;QACrD,OAAO;YACL,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,CACL,oBAAC,YAAY,IACX,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EACnD,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACH,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,aAAa,CAAC;QACnB,QAAQ;QACR,IAAI;QACJ,sBAAsB,EAAE,eAAe;QACvC,iBAAiB,EAAE,EAAE;QACrB,kBAAkB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC;KACzD,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { makeExtension } from '@riboseinc/paneron-extension-kit';\nimport { Extension } from '@riboseinc/paneron-extension-kit/types';\nimport { ExtensionMakerProps } from '@riboseinc/paneron-extension-kit/types/extension-maker';\nimport { RegistryViewProps } from './types';\nimport { RegistryView } from './views';\n\nexport type RegistryExtensionMakerProps =\n Pick<ExtensionMakerProps, 'name'> & RegistryViewProps\n\nexport type RegistryExtensionMaker =\n (opts: RegistryExtensionMakerProps) => Promise<Extension>;\n\nexport const makeRegistryExtension: RegistryExtensionMaker = function (opts) {\n const { name } = opts;\n\n const mainView: ExtensionMakerProps[\"mainView\"] = async function () {\n return {\n default: () => {\n return (\n <RegistryView\n itemClassConfiguration={opts.itemClassConfiguration}\n subregisters={opts.subregisters}\n />\n );\n },\n };\n };\n\n return makeExtension({\n mainView,\n name,\n requiredHostAppVersion: '1.0.0-alpha19',\n datasetMigrations: {},\n datasetInitializer: () => import('./migrations/initial'),\n });\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAIjE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,MAAM,CAAC,MAAM,qBAAqB,GAA2B,UAAU,IAAI;IACzE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAEtB,MAAM,QAAQ,GAAoC,KAAK;QACrD,OAAO;YACL,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,CACL,oBAAC,YAAY,IACX,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EACnD,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACH,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,aAAa,CAAC;QACnB,QAAQ;QACR,IAAI;QACJ,sBAAsB,EAAE,OAAO;QAC/B,iBAAiB,EAAE,EAAE;QACrB,kBAAkB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC;KACzD,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { makeExtension } from '@riboseinc/paneron-extension-kit';\nimport type { Extension } from '@riboseinc/paneron-extension-kit/types';\nimport type { ExtensionMakerProps } from '@riboseinc/paneron-extension-kit/types/extension-maker';\nimport type { RegistryViewProps } from './types';\nimport { RegistryView } from './views';\n\nexport type RegistryExtensionMakerProps =\n Pick<ExtensionMakerProps, 'name'> & RegistryViewProps\n\nexport type RegistryExtensionMaker =\n (opts: RegistryExtensionMakerProps) => Promise<Extension>;\n\nexport const makeRegistryExtension: RegistryExtensionMaker = function (opts) {\n const { name } = opts;\n\n const mainView: ExtensionMakerProps[\"mainView\"] = async function () {\n return {\n default: () => {\n return (\n <RegistryView\n itemClassConfiguration={opts.itemClassConfiguration}\n subregisters={opts.subregisters}\n />\n );\n },\n };\n };\n\n return makeExtension({\n mainView,\n name,\n requiredHostAppVersion: '2.0.0',\n datasetMigrations: {},\n datasetInitializer: () => import('./migrations/initial'),\n });\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riboseinc/paneron-registry-kit",
3
- "version": "2.0.0-dev9",
3
+ "version": "2.0.0",
4
4
  "main": "index.js",
5
5
  "author": "Ribose Inc. <open.source@ribose.com>",
6
6
  "scripts": {
@@ -14,35 +14,42 @@
14
14
  "**/*.js.map",
15
15
  "**/*.d.ts"
16
16
  ],
17
- "peerDependencies": {
18
- "electron": "^10.1.3"
17
+ "resolutions": {
18
+ "@types/react": "17.0.53"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@babel/cli": "^7.1.5",
22
22
  "@babel/core": "^7.4.0",
23
23
  "@babel/preset-env": "^7.4.2",
24
- "@blueprintjs/core": "^3.42.0",
25
- "@blueprintjs/datetime": "^3.22.0",
26
- "@blueprintjs/icons": "^3.26.0",
27
- "@blueprintjs/popover2": "^0.7.0",
28
- "@blueprintjs/select": "^3.15.9",
29
- "@emotion/core": "^10.0.35",
30
- "@emotion/styled": "^10.0.0",
31
- "@riboseinc/paneron-extension-kit": "2.0.0-dev16",
24
+ "@blueprintjs/core": "~4.17.6",
25
+ "@blueprintjs/datetime": "~4.4.25",
26
+ "@blueprintjs/icons": "~4.14.3",
27
+ "@blueprintjs/popover2": "~1.13.10",
28
+ "@blueprintjs/select": "~4.9.10",
29
+ "@emotion/react": "^11.10.6",
30
+ "@emotion/styled": "^11.10.6",
31
+ "@riboseinc/isogit-lfs": "0.1.6",
32
+ "@riboseinc/paneron-extension-kit": "2.0.0",
32
33
  "@types/js-yaml": "^3.12.5",
33
- "@types/node": "^14.11.2",
34
+ "@types/node": "^16.11.7",
34
35
  "@types/ramda": "^0.27.35",
35
- "@types/react": "^16.9.11",
36
- "@types/react-window": "^1.8.2",
36
+ "@types/react": "17.0.53",
37
+ "@types/react-dom": "^17.0.2",
38
+ "@types/react-helmet": "^6.1.2",
39
+ "@types/react-window": "^1.8.5",
37
40
  "@types/throttle-debounce": "^2.1.0",
38
- "electron": "^10.1.3",
39
- "electron-log": "^4.2.4",
41
+ "date-fns": "^2.22.1",
40
42
  "immutability-helper": "^3.1.1",
41
43
  "js-yaml": "^3.14.0",
42
- "react": "^16.11.0",
43
- "react-window": "^1.8.5",
44
+ "jsondiffpatch": "^0.4.1",
45
+ "react": "^17.0.2",
46
+ "react-dom": "^17.0.2",
47
+ "react-helmet": "^6.1.0",
48
+ "react-visual-diff": "^0.4.3",
49
+ "react-window": "^1.8.8",
50
+ "rough-notation": "^0.5.1",
44
51
  "throttle-debounce": "^2.3.0",
45
- "typescript": "^4.1.3"
52
+ "typescript": "~4.6.0"
46
53
  },
47
54
  "license": "MIT"
48
55
  }
package/types/cr.d.ts ADDED
@@ -0,0 +1,216 @@
1
+ /** Change request types, states and state transitions. */
2
+ import type React from 'react';
3
+ import type { ProposalSet } from './proposal';
4
+ import { type RegisterStakeholder } from './stakeholder';
5
+ export declare function isSubmittedBy(stakeholder: RegisterStakeholder, cr: Base): boolean;
6
+ /** Used in place of enum for convenience. */
7
+ export declare const State: {
8
+ readonly DRAFT: "draft";
9
+ readonly PROPOSED: "proposed";
10
+ readonly SUBMITTED_FOR_CONTROL_BODY_REVIEW: "pending-control-body-review";
11
+ readonly RETURNED_FOR_CLARIFICATION: "returned-for-clarification";
12
+ readonly WITHDRAWN: "withdrawn";
13
+ readonly ACCEPTED: "accepted";
14
+ readonly REJECTED: "rejected";
15
+ readonly APPEALED: "rejection-appealed-to-owner";
16
+ readonly ACCEPTED_ON_APPEAL: "accepted-on-appeal";
17
+ readonly REJECTION_UPHELD_ON_APPEAL: "rejection-upheld-on-appeal";
18
+ readonly APPEAL_WITHDRAWN: "appeal-withdrawn";
19
+ };
20
+ export declare type StateType = typeof State[keyof typeof State];
21
+ export declare function isState(val: string): val is StateType;
22
+ /** A subset of `State` that represents editable states. */
23
+ export declare const EditableState: readonly ["draft", "returned-for-clarification"];
24
+ export declare type EditableStateType = StateType & typeof EditableState[number];
25
+ export declare function isEditableState(state: StateType): state is EditableStateType;
26
+ /**
27
+ * Base change request type.
28
+ *
29
+ * Note that e.g. type Base<typeof State.DRAFT> does not equal to Drafted
30
+ * because Drafted includes additional information (namely, SubmitterInput).
31
+ *
32
+ * If the state of a CR matters, this type should not be used directly
33
+ * and concrete types should be used instead.
34
+ */
35
+ export interface Base<S extends StateType = StateType> {
36
+ id: string;
37
+ state: S;
38
+ /**
39
+ * Used to match against stakeholders declared in register metadata.
40
+ */
41
+ submittingStakeholderGitServerUsername: string;
42
+ items: ProposalSet;
43
+ /**
44
+ * Against to which register version changes were proposed.
45
+ */
46
+ registerVersion: string;
47
+ /**
48
+ * A link to external discussion.
49
+ */
50
+ externalDiscussionURI?: string;
51
+ }
52
+ export declare function isCreatedBy(stakeholder: RegisterStakeholder, cr: Base): boolean;
53
+ export declare function canBeEditedBy(stakeholder: RegisterStakeholder, cr: Base): boolean;
54
+ /**
55
+ * A change request in any state.
56
+ * Contains a superset of all possible properties, but all optional.
57
+ * XXX: ^^^ This is a lie. Should be changed from | to & with Partial<>?
58
+ */
59
+ export declare type SomeCR = Drafted | Proposed | Withdrawn | ReturnedForClarificationByManager | SubmittedForControlBodyReview | ReturnedForClarificationByControlBody | Accepted | Rejected | RejectionUpheld | AcceptedOnAppeal | RejectedWithAppealWithdrawn;
60
+ export declare type Withdrawable = Proposed | SubmittedForControlBodyReview | ReturnedForClarificationByManager | ReturnedForClarificationByControlBody;
61
+ export declare type Proposable = Drafted | ReturnedForClarificationByManager | ReturnedForClarificationByControlBody;
62
+ export declare type SomeEditable = Drafted | ReturnedForClarificationByManager | ReturnedForClarificationByControlBody;
63
+ export declare type Disposed = Withdrawn | Accepted | Rejected | AcceptedOnAppeal | RejectionUpheld;
64
+ export interface Drafted extends SubmitterInput, Base<typeof State.DRAFT> {
65
+ timeStarted: Date;
66
+ timeEdited: Date;
67
+ }
68
+ export declare function isDrafted(cr: Base): cr is Drafted;
69
+ export interface Proposed extends Omit<Drafted, 'state'>, Base<typeof State.PROPOSED> {
70
+ timeProposed: Date;
71
+ }
72
+ export declare function isProposed(cr: Base): cr is Proposed;
73
+ export interface Withdrawn extends Omit<Withdrawable, 'state'>, Base<typeof State.WITHDRAWN> {
74
+ timeDisposed: Date;
75
+ }
76
+ export declare function isWithdrawn(cr: Base): cr is Withdrawn;
77
+ export declare function hadBeenProposed(cr: Base): cr is Base & {
78
+ timeProposed: Date;
79
+ };
80
+ export declare function isDisposed(cr: Base): cr is Base & {
81
+ timeDisposed: Date;
82
+ };
83
+ export interface SubmittedForControlBodyReview extends Omit<Proposed, 'state'>, RegisterManagerInput, Base<typeof State.SUBMITTED_FOR_CONTROL_BODY_REVIEW> {
84
+ }
85
+ export interface ReturnedForClarificationByManager extends Omit<Proposed, 'state'>, RegisterManagerInput, Base<typeof State.RETURNED_FOR_CLARIFICATION> {
86
+ }
87
+ export interface ReturnedForClarificationByControlBody extends Omit<SubmittedForControlBodyReview, 'state'>, ControlBodyInput, Base<typeof State.RETURNED_FOR_CLARIFICATION> {
88
+ }
89
+ export interface Accepted extends Omit<SubmittedForControlBodyReview, 'state'>, ControlBodyInput, Base<typeof State.ACCEPTED> {
90
+ timeDisposed: Date;
91
+ }
92
+ export declare function isAccepted(cr: Base): cr is Accepted;
93
+ export interface Rejected extends Omit<SubmittedForControlBodyReview, 'state'>, ControlBodyInput, Base<typeof State.REJECTED> {
94
+ timeDisposed: Date;
95
+ }
96
+ export interface Appealed extends Omit<Rejected, 'state' | 'timeDisposed'>, AppealRequest, Base<typeof State.APPEALED> {
97
+ timeDisposed: undefined;
98
+ }
99
+ export declare function isAppealed(cr: Base): cr is Appealed;
100
+ export interface RejectionUpheld extends Omit<Appealed, 'state' | 'timeDisposed'>, RegisterOwnerInput, Base<typeof State.REJECTION_UPHELD_ON_APPEAL> {
101
+ timeDisposed: Date;
102
+ }
103
+ export interface AcceptedOnAppeal extends Omit<Appealed, 'state' | 'timeDisposed'>, RegisterOwnerInput, Base<typeof State.ACCEPTED_ON_APPEAL> {
104
+ timeDisposed: Date;
105
+ }
106
+ export declare function isAcceptedOnAppeal(cr: Base): cr is AcceptedOnAppeal;
107
+ export interface RejectedWithAppealWithdrawn extends Omit<Appealed, 'state' | 'timeDisposed'>, Base<typeof State.APPEAL_WITHDRAWN> {
108
+ timeDisposed: Date;
109
+ }
110
+ export interface SubmitterInput {
111
+ justification: string;
112
+ }
113
+ export declare function hasSubmitterInput(val: any): val is SubmitterInput;
114
+ export interface RegisterManagerInput {
115
+ registerManagerNotes: string;
116
+ }
117
+ export declare function hasRegisterManagerInput(val: any): val is RegisterManagerInput;
118
+ export interface ControlBodyInput {
119
+ controlBodyNotes: string;
120
+ controlBodyDecisionEvent: string;
121
+ }
122
+ export declare function hasControlBodyInput(val: any): val is ControlBodyInput;
123
+ export interface AppealRequest {
124
+ appealReason: string;
125
+ }
126
+ export declare function hasAppealRequest(val: any): val is AppealRequest;
127
+ export interface RegisterOwnerInput {
128
+ registerOwnerNotes: string;
129
+ }
130
+ export declare function hasRegisterOwnerInput(val: any): val is RegisterOwnerInput;
131
+ export declare type StateInput = SubmitterInput | RegisterManagerInput | ControlBodyInput | AppealRequest | RegisterOwnerInput;
132
+ /**
133
+ * A function that transitions CR1 to CR2.
134
+ *
135
+ * The function is declared to return the object
136
+ * without the `state` field, it is set
137
+ * by common wrapper function to reduce duplication.
138
+ */
139
+ export declare type Transition<
140
+ /** From CR of this subtype */
141
+ CR1 extends Base,
142
+ /** To CR of this subtype */
143
+ CR2 extends Base,
144
+ /** Using this extra information */
145
+ P extends Record<string, any> | null = null> = (cr: CR1, payload: P) => Omit<CR2, 'state'>;
146
+ /**
147
+ * Describes a transition.
148
+ *
149
+ * @typeParam CR1: Change request source state type
150
+ * @typeParam CR2: Change request target state type
151
+ * @typeParam P: Extra input needed to transition, if any
152
+ */
153
+ export interface TransitionConfig<CR1 extends Base, CR2 extends Base, P extends Record<string, any> | null = null> {
154
+ /**
155
+ * Function that implements the transition.
156
+ * Takes a CR in the original state and returns CR in the new state.
157
+ * Additionally, takes appropriate payload, if any, for the transition
158
+ * (e.g., register manager or control body notes).
159
+ *
160
+ * For function implementor:
161
+ *
162
+ * - Function MUST NOT modify CR in place.
163
+ * - Function should throw if submitted payload does not conform to requirements.
164
+ */
165
+ func: Transition<CR1, CR2, P>;
166
+ targetState: CR2["state"];
167
+ /** Title. Use verb. */
168
+ title: string;
169
+ hint?: string | JSX.Element;
170
+ /** Widget that can be used to view or enter extra input. */
171
+ Widget: P extends null ? null : React.FC<{
172
+ value: P;
173
+ onChange?: (userInput: P) => void;
174
+ }>;
175
+ /**
176
+ * Function that returns true
177
+ * if given stakeholder can perform this transition on given CR.
178
+ */
179
+ canBeTransitionedBy: (stakeholder: RegisterStakeholder, cr: CR1) => boolean;
180
+ }
181
+ /**
182
+ * Source of truth for available transitions.
183
+ * When updating change request business logic,
184
+ * this is the type that should be modified.
185
+ *
186
+ * It will cause compile errors until transition implementation
187
+ * is updated correspondingly.
188
+ */
189
+ export declare type Transitions = {
190
+ [State.DRAFT]: {
191
+ [State.PROPOSED]: TransitionConfig<Drafted, Proposed, SubmitterInput>;
192
+ };
193
+ [State.PROPOSED]: {
194
+ [State.WITHDRAWN]: TransitionConfig<Proposed, Withdrawn>;
195
+ [State.SUBMITTED_FOR_CONTROL_BODY_REVIEW]: TransitionConfig<Proposed, SubmittedForControlBodyReview, RegisterManagerInput>;
196
+ [State.RETURNED_FOR_CLARIFICATION]: TransitionConfig<Proposed, ReturnedForClarificationByManager, RegisterManagerInput>;
197
+ };
198
+ [State.SUBMITTED_FOR_CONTROL_BODY_REVIEW]: {
199
+ [State.WITHDRAWN]: TransitionConfig<SubmittedForControlBodyReview, Withdrawn>;
200
+ [State.RETURNED_FOR_CLARIFICATION]: TransitionConfig<SubmittedForControlBodyReview, ReturnedForClarificationByControlBody, ControlBodyInput>;
201
+ [State.REJECTED]: TransitionConfig<SubmittedForControlBodyReview, Rejected, ControlBodyInput>;
202
+ [State.ACCEPTED]: TransitionConfig<SubmittedForControlBodyReview, Accepted, ControlBodyInput>;
203
+ };
204
+ [State.RETURNED_FOR_CLARIFICATION]: {
205
+ [State.PROPOSED]: TransitionConfig<ReturnedForClarificationByManager | ReturnedForClarificationByControlBody, Proposed, SubmitterInput>;
206
+ [State.WITHDRAWN]: TransitionConfig<ReturnedForClarificationByManager | ReturnedForClarificationByControlBody, Withdrawn>;
207
+ };
208
+ [State.REJECTED]: {
209
+ [State.APPEALED]: TransitionConfig<Rejected, Appealed, AppealRequest>;
210
+ };
211
+ [State.APPEALED]: {
212
+ [State.APPEAL_WITHDRAWN]: TransitionConfig<Appealed, RejectedWithAppealWithdrawn>;
213
+ [State.ACCEPTED_ON_APPEAL]: TransitionConfig<Appealed, AcceptedOnAppeal, RegisterOwnerInput>;
214
+ [State.REJECTION_UPHELD_ON_APPEAL]: TransitionConfig<Appealed, RejectionUpheld, RegisterOwnerInput>;
215
+ };
216
+ };
package/types/cr.js ADDED
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isSubmittedBy = isSubmittedBy;
7
+ exports.isState = isState;
8
+ exports.isEditableState = isEditableState;
9
+ exports.isCreatedBy = isCreatedBy;
10
+ exports.canBeEditedBy = canBeEditedBy;
11
+ exports.isDrafted = isDrafted;
12
+ exports.isProposed = isProposed;
13
+ exports.isWithdrawn = isWithdrawn;
14
+ exports.hadBeenProposed = hadBeenProposed;
15
+ exports.isDisposed = isDisposed;
16
+ exports.isAccepted = isAccepted;
17
+ exports.isAppealed = isAppealed;
18
+ exports.isAcceptedOnAppeal = isAcceptedOnAppeal;
19
+ exports.hasSubmitterInput = hasSubmitterInput;
20
+ exports.hasRegisterManagerInput = hasRegisterManagerInput;
21
+ exports.hasControlBodyInput = hasControlBodyInput;
22
+ exports.hasAppealRequest = hasAppealRequest;
23
+ exports.hasRegisterOwnerInput = hasRegisterOwnerInput;
24
+ exports.EditableState = exports.State = void 0;
25
+
26
+ /** Change request types, states and state transitions. */
27
+ function isSubmittedBy(stakeholder, cr) {
28
+ return (//isSubmitter(stakeholder) &&
29
+ stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername
30
+ );
31
+ } // =====================
32
+ // Change request states
33
+ // =====================
34
+
35
+ /** Used in place of enum for convenience. */
36
+
37
+
38
+ const State = {
39
+ DRAFT: 'draft',
40
+ PROPOSED: 'proposed',
41
+ SUBMITTED_FOR_CONTROL_BODY_REVIEW: 'pending-control-body-review',
42
+ RETURNED_FOR_CLARIFICATION: 'returned-for-clarification',
43
+ WITHDRAWN: 'withdrawn',
44
+ ACCEPTED: 'accepted',
45
+ REJECTED: 'rejected',
46
+ APPEALED: 'rejection-appealed-to-owner',
47
+ ACCEPTED_ON_APPEAL: 'accepted-on-appeal',
48
+ REJECTION_UPHELD_ON_APPEAL: 'rejection-upheld-on-appeal',
49
+ APPEAL_WITHDRAWN: 'appeal-withdrawn'
50
+ };
51
+ exports.State = State;
52
+
53
+ function isState(val) {
54
+ return Object.values(State).indexOf(val) >= 0;
55
+ }
56
+ /** A subset of `State` that represents editable states. */
57
+
58
+
59
+ const EditableState = [State.DRAFT, State.RETURNED_FOR_CLARIFICATION];
60
+ exports.EditableState = EditableState;
61
+
62
+ function isEditableState(state) {
63
+ return EditableState.indexOf(state) >= 0;
64
+ }
65
+
66
+ function isCreatedBy(stakeholder, cr) {
67
+ return stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername;
68
+ }
69
+
70
+ function canBeEditedBy(stakeholder, cr) {
71
+ return isCreatedBy(stakeholder, cr) && isEditableState(cr.state);
72
+ }
73
+
74
+ function isDrafted(cr) {
75
+ return isInState(cr, State.DRAFT);
76
+ }
77
+
78
+ function isProposed(cr) {
79
+ return isInState(cr, State.PROPOSED);
80
+ }
81
+
82
+ function isWithdrawn(cr) {
83
+ return isInState(cr, State.WITHDRAWN);
84
+ }
85
+
86
+ function hadBeenProposed(cr) {
87
+ return cr && cr.hasOwnProperty('timeProposed') && !!cr.timeProposed;
88
+ }
89
+
90
+ function isDisposed(cr) {
91
+ return cr && cr.hasOwnProperty('timeDisposed') && !!cr.timeDisposed; //return [
92
+ // State.WITHDRAWN,
93
+ // State.ACCEPTED,
94
+ // State.REJECTED,
95
+ // State.REJECTION_UPHELD_ON_APPEAL,
96
+ // State.ACCEPTED_ON_APPEAL,
97
+ //].some(s => cr.state === s);
98
+ }
99
+
100
+ function isAccepted(cr) {
101
+ return isInState(cr, State.ACCEPTED);
102
+ }
103
+
104
+ function isAppealed(cr) {
105
+ return isInState(cr, State.APPEALED);
106
+ }
107
+
108
+ function isAcceptedOnAppeal(cr) {
109
+ return isInState(cr, State.ACCEPTED_ON_APPEAL);
110
+ }
111
+
112
+ function hasSubmitterInput(val) {
113
+ return val.hasOwnProperty('justification') && typeof val.justification === 'string';
114
+ }
115
+
116
+ function hasRegisterManagerInput(val) {
117
+ return val.hasOwnProperty('registerManagerNotes') && typeof val.registerManagerNotes === 'string';
118
+ }
119
+
120
+ function hasControlBodyInput(val) {
121
+ return val.hasOwnProperty('controlBodyNotes') && typeof val.controlBodyNotes === 'string' && val.hasOwnProperty('controlBodyDecisionEvent') && typeof val.controlBodyDecisionEvent === 'string';
122
+ }
123
+
124
+ function hasAppealRequest(val) {
125
+ return val.hasOwnProperty('appealReason') && typeof val.appealReason === 'string';
126
+ }
127
+
128
+ function hasRegisterOwnerInput(val) {
129
+ return val.hasOwnProperty('registerOwnerNotes') && typeof val.registerOwnerNotes === 'string';
130
+ }
131
+ /**
132
+ * CR type guard helper.
133
+ * Normally you would not use it directly and instead use
134
+ * more specific is[Type]() helper from this module.
135
+ *
136
+ * Checks CR type using the `state` property.
137
+ * Does not validate other properties.
138
+ *
139
+ * Usage:
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * let someCR;
144
+ * if (isInState<Drafted>(someCR, State.DRAFT)) {
145
+ * // Can assume someCR is Drafted
146
+ * }
147
+ * ```
148
+ *
149
+ * It’ll try to tell you if you mismatch those.
150
+ *
151
+ * @example
152
+ * Will not compile:
153
+ * ```ts
154
+ * let someCR;
155
+ * if (isInState<Drafted>(someCR, State.PROPOSED)) {
156
+ * // Compile error
157
+ * // because State.PROPOSED is not a possible value of Drafted["state"]
158
+ * }
159
+ * ```
160
+ *
161
+ * @example
162
+ * Incorrect usage (do not do this):
163
+ * ```ts
164
+ * let someCR;
165
+ * if (isInState(someCR, State.DRAFT)) {
166
+ * // Can NOT assume someCR is Drafted
167
+ * // The compiler must know the expected concrete CR type
168
+ * }
169
+ * ```
170
+ */
171
+
172
+
173
+ function isInState(cr, s) {
174
+ return cr.state === s;
175
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cr.js","sourceRoot":"","sources":["../../src/types/cr.ts"],"names":[],"mappings":"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","sourcesContent":["/** Change request types, states and state transitions. */\n\nimport type React from 'react';\nimport type { ProposalSet } from './proposal';\nimport { type RegisterStakeholder } from './stakeholder';\n\n\n\nexport function isSubmittedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return (\n //isSubmitter(stakeholder) &&\n stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername);\n}\n\n\n\n// =====================\n// Change request states\n// =====================\n\n/** Used in place of enum for convenience. */\nexport const State = {\n DRAFT: 'draft',\n PROPOSED: 'proposed',\n SUBMITTED_FOR_CONTROL_BODY_REVIEW: 'pending-control-body-review',\n RETURNED_FOR_CLARIFICATION: 'returned-for-clarification',\n WITHDRAWN: 'withdrawn',\n ACCEPTED: 'accepted',\n REJECTED: 'rejected',\n APPEALED: 'rejection-appealed-to-owner',\n ACCEPTED_ON_APPEAL: 'accepted-on-appeal',\n REJECTION_UPHELD_ON_APPEAL: 'rejection-upheld-on-appeal',\n APPEAL_WITHDRAWN: 'appeal-withdrawn',\n} as const;\n\nexport type StateType = typeof State[keyof typeof State];\n\nexport function isState(val: string): val is StateType {\n return Object.values(State).indexOf(val as StateType) >= 0;\n}\n\n/** A subset of `State` that represents editable states. */\nexport const EditableState = [\n State.DRAFT,\n State.RETURNED_FOR_CLARIFICATION,\n] as const;\n\nexport type EditableStateType = StateType & typeof EditableState[number];\n\nexport function isEditableState(state: StateType): state is EditableStateType {\n return EditableState.indexOf(state as EditableStateType) >= 0;\n}\n\n\n\n// ======================\n// Change request classes\n// ======================\n\n/**\n * Base change request type.\n *\n * Note that e.g. type Base<typeof State.DRAFT> does not equal to Drafted\n * because Drafted includes additional information (namely, SubmitterInput).\n *\n * If the state of a CR matters, this type should not be used directly\n * and concrete types should be used instead.\n */\nexport interface Base<S extends StateType = StateType>\n{\n id: string;\n // decision: typeof Decision[keyof typeof Decision]\n // disposition?: typeof Disposition[keyof typeof Disposition]\n state: S;\n\n /**\n * Used to match against stakeholders declared in register metadata.\n */\n submittingStakeholderGitServerUsername: string;\n\n items: ProposalSet;\n\n /**\n * Against to which register version changes were proposed.\n */\n registerVersion: string;\n\n /**\n * A link to external discussion.\n */\n externalDiscussionURI?: string;\n}\n\n\nexport function isCreatedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername;\n}\n\nexport function canBeEditedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return isCreatedBy(stakeholder, cr) && isEditableState(cr.state);\n}\n\n\n/**\n * A change request in any state.\n * Contains a superset of all possible properties, but all optional.\n * XXX: ^^^ This is a lie. Should be changed from | to & with Partial<>?\n */\nexport type SomeCR = \n | Drafted\n | Proposed\n | Withdrawn\n | ReturnedForClarificationByManager\n | SubmittedForControlBodyReview\n | ReturnedForClarificationByControlBody\n | Accepted\n | Rejected\n | RejectionUpheld\n | AcceptedOnAppeal\n | RejectedWithAppealWithdrawn;\n\nexport type Withdrawable =\n | Proposed\n | SubmittedForControlBodyReview\n | ReturnedForClarificationByManager\n | ReturnedForClarificationByControlBody;\n\nexport type Proposable =\n | Drafted\n | ReturnedForClarificationByManager\n | ReturnedForClarificationByControlBody;\n\nexport type SomeEditable =\n | Drafted\n | ReturnedForClarificationByManager\n | ReturnedForClarificationByControlBody;\n\nexport type Disposed =\n | Withdrawn\n | Accepted\n | Rejected\n | AcceptedOnAppeal\n | RejectionUpheld;\n\n\n// More specific change request types.\n// TODO: Refactor to avoid confusiong between current state e.g. Proposed)\n// and type (Proposed, to which all inheriting classes also conform)\n\nexport interface Drafted extends\n SubmitterInput,\n Base<typeof State.DRAFT> { timeStarted: Date, timeEdited: Date }\nexport function isDrafted(cr: Base): cr is Drafted {\n return isInState(cr, State.DRAFT);\n}\n\nexport interface Proposed extends\n Omit<Drafted, 'state'>,\n Base<typeof State.PROPOSED> { timeProposed: Date }\nexport function isProposed(cr: Base): cr is Proposed {\n return isInState(cr, State.PROPOSED);\n}\n\nexport interface Withdrawn extends\n Omit<Withdrawable, 'state'>,\n Base<typeof State.WITHDRAWN> { timeDisposed: Date }\nexport function isWithdrawn(cr: Base): cr is Withdrawn {\n return isInState(cr, State.WITHDRAWN);\n}\n\nexport function hadBeenProposed(cr: Base): cr is Base & { timeProposed: Date } {\n return cr && cr.hasOwnProperty('timeProposed') && !!(cr as Proposed).timeProposed;\n}\nexport function isDisposed(cr: Base): cr is Base & { timeDisposed: Date } {\n return cr && cr.hasOwnProperty('timeDisposed') && !!(cr as Disposed).timeDisposed;\n //return [\n // State.WITHDRAWN,\n // State.ACCEPTED,\n // State.REJECTED,\n // State.REJECTION_UPHELD_ON_APPEAL,\n // State.ACCEPTED_ON_APPEAL,\n //].some(s => cr.state === s);\n}\n\nexport interface SubmittedForControlBodyReview extends\n Omit<Proposed, 'state'>,\n RegisterManagerInput,\n Base<typeof State.SUBMITTED_FOR_CONTROL_BODY_REVIEW> {}\n\nexport interface ReturnedForClarificationByManager extends\n Omit<Proposed, 'state'>,\n RegisterManagerInput,\n Base<typeof State.RETURNED_FOR_CLARIFICATION> {}\n\nexport interface ReturnedForClarificationByControlBody extends\n Omit<SubmittedForControlBodyReview, 'state'>,\n ControlBodyInput,\n Base<typeof State.RETURNED_FOR_CLARIFICATION> {}\n\nexport interface Accepted extends\n Omit<SubmittedForControlBodyReview, 'state'>,\n ControlBodyInput,\n Base<typeof State.ACCEPTED> { timeDisposed: Date }\nexport function isAccepted(cr: Base): cr is Accepted {\n return isInState(cr, State.ACCEPTED);\n}\n\nexport interface Rejected extends\n Omit<SubmittedForControlBodyReview, 'state'>,\n ControlBodyInput,\n Base<typeof State.REJECTED> { timeDisposed: Date }\n\nexport interface Appealed extends\n Omit<Rejected, 'state' | 'timeDisposed'>,\n AppealRequest,\n Base<typeof State.APPEALED> { timeDisposed: undefined }\nexport function isAppealed(cr: Base): cr is Appealed {\n return isInState(cr, State.APPEALED);\n}\n\nexport interface RejectionUpheld extends\n Omit<Appealed, 'state' | 'timeDisposed'>,\n RegisterOwnerInput,\n Base<typeof State.REJECTION_UPHELD_ON_APPEAL> { timeDisposed: Date }\n\nexport interface AcceptedOnAppeal extends\n Omit<Appealed, 'state' | 'timeDisposed'>,\n RegisterOwnerInput,\n Base<typeof State.ACCEPTED_ON_APPEAL> { timeDisposed: Date }\nexport function isAcceptedOnAppeal(cr: Base): cr is AcceptedOnAppeal {\n return isInState(cr, State.ACCEPTED_ON_APPEAL);\n}\n\nexport interface RejectedWithAppealWithdrawn extends\n Omit<Appealed, 'state' | 'timeDisposed'>,\n Base<typeof State.APPEAL_WITHDRAWN> { timeDisposed: Date }\n\n\n\n// Input required when transitioning to different states\n\nexport interface SubmitterInput {\n justification: string;\n}\nexport function hasSubmitterInput(val: any): val is SubmitterInput {\n return val.hasOwnProperty('justification') && typeof val.justification === 'string';\n}\nexport interface RegisterManagerInput {\n registerManagerNotes: string;\n}\nexport function hasRegisterManagerInput(val: any): val is RegisterManagerInput {\n return val.hasOwnProperty('registerManagerNotes') && typeof val.registerManagerNotes === 'string';\n}\nexport interface ControlBodyInput {\n controlBodyNotes: string;\n controlBodyDecisionEvent: string;\n}\nexport function hasControlBodyInput(val: any): val is ControlBodyInput {\n return (\n val.hasOwnProperty('controlBodyNotes') && typeof val.controlBodyNotes === 'string' &&\n val.hasOwnProperty('controlBodyDecisionEvent') && typeof val.controlBodyDecisionEvent === 'string');\n}\nexport interface AppealRequest {\n appealReason: string;\n}\nexport function hasAppealRequest(val: any): val is AppealRequest {\n return val.hasOwnProperty('appealReason') && typeof val.appealReason === 'string';\n}\nexport interface RegisterOwnerInput {\n registerOwnerNotes: string;\n}\nexport function hasRegisterOwnerInput(val: any): val is RegisterOwnerInput {\n return val.hasOwnProperty('registerOwnerNotes') && typeof val.registerOwnerNotes === 'string';\n}\n\nexport type StateInput =\n | SubmitterInput\n | RegisterManagerInput\n | ControlBodyInput\n | AppealRequest\n | RegisterOwnerInput;\n\n\n/** \n * CR type guard helper.\n * Normally you would not use it directly and instead use\n * more specific is[Type]() helper from this module.\n *\n * Checks CR type using the `state` property.\n * Does not validate other properties.\n *\n * Usage:\n *\n * @example\n * ```ts\n * let someCR;\n * if (isInState<Drafted>(someCR, State.DRAFT)) {\n * // Can assume someCR is Drafted\n * }\n * ```\n *\n * It’ll try to tell you if you mismatch those.\n *\n * @example\n * Will not compile:\n * ```ts\n * let someCR;\n * if (isInState<Drafted>(someCR, State.PROPOSED)) {\n * // Compile error\n * // because State.PROPOSED is not a possible value of Drafted[\"state\"]\n * }\n * ```\n *\n * @example\n * Incorrect usage (do not do this):\n * ```ts\n * let someCR;\n * if (isInState(someCR, State.DRAFT)) {\n * // Can NOT assume someCR is Drafted\n * // The compiler must know the expected concrete CR type\n * }\n * ```\n */\nfunction isInState<CR extends Base>(cr: Base, s: CR[\"state\"]): cr is CR {\n return cr.state === s;\n}\n\n\n\n\n// ===========\n// Transitions\n// ===========\n\n/**\n * A function that transitions CR1 to CR2.\n *\n * The function is declared to return the object\n * without the `state` field, it is set\n * by common wrapper function to reduce duplication.\n */\nexport type Transition<\n /** From CR of this subtype */\n CR1 extends Base,\n /** To CR of this subtype */\n CR2 extends Base,\n /** Using this extra information */\n P extends Record<string, any> | null = null,\n> = (cr: CR1, payload: P) => Omit<CR2, 'state'>;\n\n\n/**\n * Describes a transition.\n *\n * @typeParam CR1: Change request source state type\n * @typeParam CR2: Change request target state type\n * @typeParam P: Extra input needed to transition, if any\n */\nexport interface TransitionConfig<CR1 extends Base, CR2 extends Base, P extends Record<string, any> | null = null> {\n /**\n * Function that implements the transition.\n * Takes a CR in the original state and returns CR in the new state.\n * Additionally, takes appropriate payload, if any, for the transition\n * (e.g., register manager or control body notes).\n *\n * For function implementor:\n *\n * - Function MUST NOT modify CR in place.\n * - Function should throw if submitted payload does not conform to requirements.\n */\n func: Transition<CR1, CR2, P>;\n\n targetState: CR2[\"state\"];\n\n /** Title. Use verb. */\n title: string;\n\n hint?: string | JSX.Element;\n\n /** Widget that can be used to view or enter extra input. */\n Widget: P extends null ? null : React.FC<{ value: P, onChange?: (userInput: P) => void }>;\n\n /**\n * Function that returns true\n * if given stakeholder can perform this transition on given CR.\n */\n canBeTransitionedBy: (stakeholder: RegisterStakeholder, cr: CR1) => boolean;\n}\n\n\n// type TransitionSpec = {\n// [S1 in StateType]?: {\n// [S2 in StateType]?: Transition<Base<S1>, Base<S2>, Record<string, any>>\n// }\n// }\n\n\n/**\n * Source of truth for available transitions.\n * When updating change request business logic,\n * this is the type that should be modified.\n *\n * It will cause compile errors until transition implementation\n * is updated correspondingly.\n */\nexport type Transitions = {\n [State.DRAFT]: {\n // [State.DRAFT]:\n // TransitionConfig<Drafted, Drafted, SubmitterInput>;\n [State.PROPOSED]:\n TransitionConfig<Drafted, Proposed, SubmitterInput>;\n };\n [State.PROPOSED]: {\n [State.WITHDRAWN]:\n TransitionConfig<Proposed, Withdrawn>;\n [State.SUBMITTED_FOR_CONTROL_BODY_REVIEW]:\n TransitionConfig<Proposed, SubmittedForControlBodyReview, RegisterManagerInput>;\n [State.RETURNED_FOR_CLARIFICATION]:\n TransitionConfig<Proposed, ReturnedForClarificationByManager, RegisterManagerInput>;\n };\n [State.SUBMITTED_FOR_CONTROL_BODY_REVIEW]: {\n [State.WITHDRAWN]:\n TransitionConfig<SubmittedForControlBodyReview, Withdrawn>;\n [State.RETURNED_FOR_CLARIFICATION]:\n TransitionConfig<SubmittedForControlBodyReview, ReturnedForClarificationByControlBody, ControlBodyInput>;\n [State.REJECTED]:\n TransitionConfig<SubmittedForControlBodyReview, Rejected, ControlBodyInput>;\n [State.ACCEPTED]:\n TransitionConfig<SubmittedForControlBodyReview, Accepted, ControlBodyInput>;\n };\n [State.RETURNED_FOR_CLARIFICATION]: {\n [State.PROPOSED]:\n TransitionConfig<ReturnedForClarificationByManager | ReturnedForClarificationByControlBody, Proposed, SubmitterInput>;\n [State.WITHDRAWN]:\n TransitionConfig<ReturnedForClarificationByManager | ReturnedForClarificationByControlBody, Withdrawn>;\n };\n [State.REJECTED]: {\n [State.APPEALED]:\n TransitionConfig<Rejected, Appealed, AppealRequest>;\n };\n [State.APPEALED]: {\n [State.APPEAL_WITHDRAWN]:\n TransitionConfig<Appealed, RejectedWithAppealWithdrawn>;\n [State.ACCEPTED_ON_APPEAL]:\n TransitionConfig<Appealed, AcceptedOnAppeal, RegisterOwnerInput>;\n [State.REJECTION_UPHELD_ON_APPEAL]:\n TransitionConfig<Appealed, RejectionUpheld, RegisterOwnerInput>;\n };\n}\n"]}
package/types/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './views';
2
2
  export * from './register';
3
+ export * from './registry';
3
4
  export * from './item';
4
5
  export * from './stakeholder';
5
6
  export * from './proposal';
package/types/index.js CHANGED
@@ -8,6 +8,7 @@ var _views = require("./views");
8
8
 
9
9
  Object.keys(_views).forEach(function (key) {
10
10
  if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _views[key]) return;
11
12
  Object.defineProperty(exports, key, {
12
13
  enumerable: true,
13
14
  get: function () {
@@ -20,6 +21,7 @@ var _register = require("./register");
20
21
 
21
22
  Object.keys(_register).forEach(function (key) {
22
23
  if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _register[key]) return;
23
25
  Object.defineProperty(exports, key, {
24
26
  enumerable: true,
25
27
  get: function () {
@@ -28,10 +30,24 @@ Object.keys(_register).forEach(function (key) {
28
30
  });
29
31
  });
30
32
 
33
+ var _registry = require("./registry");
34
+
35
+ Object.keys(_registry).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _registry[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _registry[key];
42
+ }
43
+ });
44
+ });
45
+
31
46
  var _item = require("./item");
32
47
 
33
48
  Object.keys(_item).forEach(function (key) {
34
49
  if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _item[key]) return;
35
51
  Object.defineProperty(exports, key, {
36
52
  enumerable: true,
37
53
  get: function () {
@@ -44,6 +60,7 @@ var _stakeholder = require("./stakeholder");
44
60
 
45
61
  Object.keys(_stakeholder).forEach(function (key) {
46
62
  if (key === "default" || key === "__esModule") return;
63
+ if (key in exports && exports[key] === _stakeholder[key]) return;
47
64
  Object.defineProperty(exports, key, {
48
65
  enumerable: true,
49
66
  get: function () {
@@ -56,6 +73,7 @@ var _proposal = require("./proposal");
56
73
 
57
74
  Object.keys(_proposal).forEach(function (key) {
58
75
  if (key === "default" || key === "__esModule") return;
76
+ if (key in exports && exports[key] === _proposal[key]) return;
59
77
  Object.defineProperty(exports, key, {
60
78
  enumerable: true,
61
79
  get: function () {
@@ -68,6 +86,7 @@ var _util = require("./util");
68
86
 
69
87
  Object.keys(_util).forEach(function (key) {
70
88
  if (key === "default" || key === "__esModule") return;
89
+ if (key in exports && exports[key] === _util[key]) return;
71
90
  Object.defineProperty(exports, key, {
72
91
  enumerable: true,
73
92
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC","sourcesContent":["export * from './views';\nexport * from './register';\nexport * from './item';\nexport * from './stakeholder';\nexport * from './proposal';\nexport * from './util';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC","sourcesContent":["export * from './views';\nexport * from './register';\nexport * from './registry';\nexport * from './item';\nexport * from './stakeholder';\nexport * from './proposal';\nexport * from './util';\n"]}