@riboseinc/paneron-registry-kit 2.2.11 → 2.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -4
- package/package.json +2 -2
- package/site-builder/index.d.ts +3 -0
- package/site-builder/index.js +75 -0
- package/site-builder/index.js.map +1 -0
- package/site-builder/jsx-runtime.d.ts +18 -0
- package/site-builder/jsx-runtime.js +107 -0
- package/site-builder/jsx-runtime.js.map +1 -0
- package/site-builder/page.d.ts +6 -0
- package/site-builder/page.js +24 -0
- package/site-builder/page.js.map +1 -0
- package/types/cr.d.ts +5 -1
- package/types/cr.js +6 -2
- package/types/cr.js.map +1 -1
- package/types/util.d.ts +2 -0
- package/types/util.js.map +1 -1
- package/types/views.d.ts +22 -0
- package/types/views.js.map +1 -1
- package/views/BrowserCtx.d.ts +3 -11
- package/views/BrowserCtx.js +1 -0
- package/views/BrowserCtx.js.map +1 -1
- package/views/FilterCriteria/criteriaGroupToQueryExpression.d.ts +1 -1
- package/views/FilterCriteria/criteriaGroupToQueryExpression.js.map +1 -1
- package/views/FilterCriteria/models.d.ts +1 -1
- package/views/FilterCriteria/models.js.map +1 -1
- package/views/GenericRelatedItemView.js +7 -4
- package/views/GenericRelatedItemView.js.map +1 -1
- package/views/SearchQuery.js +25 -14
- package/views/SearchQuery.js.map +1 -1
- package/views/change-request/ChangeProposalContext.d.ts +3 -0
- package/views/change-request/ChangeProposalContext.js +4 -0
- package/views/change-request/ChangeProposalContext.js.map +1 -0
- package/views/change-request/ChangeRequestContext.d.ts +6 -6
- package/views/change-request/ChangeRequestContext.js +2 -2
- package/views/change-request/ChangeRequestContext.js.map +1 -1
- package/views/change-request/State.d.ts +0 -0
- package/views/change-request/State.js +1 -0
- package/views/change-request/State.js.map +1 -0
- package/views/change-request/objectChangeset.d.ts +7 -4
- package/views/change-request/objectChangeset.js +59 -22
- package/views/change-request/objectChangeset.js.map +1 -1
- package/views/detail/RegisterHome/ActiveProposalDetails.d.ts +15 -0
- package/views/detail/RegisterHome/ActiveProposalDetails.js +104 -0
- package/views/detail/RegisterHome/ActiveProposalDetails.js.map +1 -0
- package/views/detail/RegisterHome/Block.d.ts +19 -0
- package/views/detail/RegisterHome/Block.js +49 -0
- package/views/detail/RegisterHome/Block.js.map +1 -0
- package/views/detail/RegisterHome/MetaSummary.js +6 -2
- package/views/detail/RegisterHome/MetaSummary.js.map +1 -1
- package/views/detail/RegisterHome/Proposal.d.ts +1 -11
- package/views/detail/RegisterHome/Proposal.js +113 -45
- package/views/detail/RegisterHome/Proposal.js.map +1 -1
- package/views/detail/RegisterHome/index.js +58 -144
- package/views/detail/RegisterHome/index.js.map +1 -1
- package/views/detail/RegisterItem/index.js +0 -1
- package/views/detail/RegisterItem/index.js.map +1 -1
- package/views/hooks/useCustomView.js +1 -1
- package/views/hooks/useCustomView.js.map +1 -1
- package/views/index.js +4 -2
- package/views/index.js.map +1 -1
- package/views/sidebar/Search/index.js +12 -2
- package/views/sidebar/Search/index.js.map +1 -1
- package/views/util.d.ts +7 -4
- package/views/util.js +39 -11
- package/views/util.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -14,11 +14,9 @@ declare const _default: {
|
|
|
14
14
|
BrowserCtx: React.Context<BrowserCtx>;
|
|
15
15
|
CRITERIA_CONFIGURATION: import("./views/FilterCriteria/models").CriteriaConfiguration;
|
|
16
16
|
GenericRelatedItemView: React.FC<import("./types").GenericRelatedItemViewProps>;
|
|
17
|
-
PropertyDetailView: React.FC<{
|
|
18
|
-
title
|
|
17
|
+
PropertyDetailView: React.FC<import("@blueprintjs/core").IFormGroupProps & {
|
|
18
|
+
title?: React.ReactNode;
|
|
19
19
|
secondaryTitle?: React.ReactNode;
|
|
20
|
-
inline?: boolean | undefined;
|
|
21
|
-
className?: string | undefined;
|
|
22
20
|
}>;
|
|
23
21
|
};
|
|
24
22
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riboseinc/paneron-registry-kit",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.12",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"author": "Ribose Inc. <open.source@ribose.com>",
|
|
6
6
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@blueprintjs/select": "~4.9.10",
|
|
29
29
|
"@emotion/react": "^11.10.6",
|
|
30
30
|
"@emotion/styled": "^11.10.6",
|
|
31
|
-
"@riboseinc/paneron-extension-kit": "2.2.
|
|
31
|
+
"@riboseinc/paneron-extension-kit": "2.2.10",
|
|
32
32
|
"@types/react": "17.0.53",
|
|
33
33
|
"@types/react-dom": "^17.0.2",
|
|
34
34
|
"@types/react-helmet": "^6.1.2",
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _common = require("../common");
|
|
9
|
+
|
|
10
|
+
var _register = require("../types/register");
|
|
11
|
+
|
|
12
|
+
var _page = _interopRequireDefault(require("./page"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
//import type { RegisterItem } from '../types/item';
|
|
17
|
+
//import { REGISTER_ITEM_QUERY } from '../views/itemQueryUtils';
|
|
18
|
+
const exporter = async function* exportPublicSite({
|
|
19
|
+
getObjectData,
|
|
20
|
+
getMapReducedData,
|
|
21
|
+
onProgress
|
|
22
|
+
}) {
|
|
23
|
+
const registerMeta = (await getObjectData({
|
|
24
|
+
objectPaths: [`/${_common.REGISTER_METADATA_FILENAME}`]
|
|
25
|
+
})).data[`/${_common.REGISTER_METADATA_FILENAME}`];
|
|
26
|
+
|
|
27
|
+
if (!(0, _register.isRegisterMetadata)(registerMeta)) {
|
|
28
|
+
throw new Error("Invalid register metadata found");
|
|
29
|
+
} //const itemsByClass: { [clsID: string]: RegisterItem<any> } = await getMapReducedData({
|
|
30
|
+
// chains: {
|
|
31
|
+
// byClass: {
|
|
32
|
+
// mapFunc: PUBLIC_ITEM_MAPPER,
|
|
33
|
+
// reduceFunc: PUBLIC_ITEM_REDUCER,
|
|
34
|
+
// },
|
|
35
|
+
// },
|
|
36
|
+
//});
|
|
37
|
+
//const classIDs = Object.keys(itemsByClass);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
yield {
|
|
41
|
+
'/hello.txt': enc.encode('hello'),
|
|
42
|
+
'/index.html': enc.encode((0, _page.default)({
|
|
43
|
+
title: "Register"
|
|
44
|
+
})),
|
|
45
|
+
'/register-meta.json': enc.encode(JSON.stringify(registerMeta))
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
var _default = exporter;
|
|
50
|
+
exports.default = _default;
|
|
51
|
+
const enc = new TextEncoder(); // const PUBLIC_ITEM_PREDICATE = `
|
|
52
|
+
// (${REGISTER_ITEM_QUERY}) && obj.status === 'valid'
|
|
53
|
+
// `;
|
|
54
|
+
//
|
|
55
|
+
// /** Emits register items keyed by class ID. */
|
|
56
|
+
//const PUBLIC_ITEM_MAPPER = `
|
|
57
|
+
// if (${PUBLIC_ITEM_PREDICATE}) {
|
|
58
|
+
// const pathWithoutSubregister = objPath.replace(/^\/subregisters/, '');
|
|
59
|
+
// const components = pathWithoutSubregister.split('/');
|
|
60
|
+
// const clsID = components[1];
|
|
61
|
+
// emit([clsID, obj]);
|
|
62
|
+
// }
|
|
63
|
+
//`;
|
|
64
|
+
//
|
|
65
|
+
//const PUBLIC_ITEM_REDUCER = `
|
|
66
|
+
// const acc = accumulator ?? {};
|
|
67
|
+
//
|
|
68
|
+
// // value[0] is item class ID
|
|
69
|
+
// acc[value[0]] ??= [];
|
|
70
|
+
//
|
|
71
|
+
// // value[1] is full register item data
|
|
72
|
+
// acc[value[0]].push(value[1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ACH,iDAAiD;AACjD,8BAA8B;AAC9B,mCAAmC;AACnC,4EAA4E;AAC5E,2DAA2D;AAC3D,kCAAkC;AAClC,yBAAyB;AACzB,KAAK;AACL,IAAI;AACJ,EAAE;AACF,+BAA+B;AAC/B,kCAAkC;AAClC,EAAE;AACF,gCAAgC;AAChC,yBAAyB;AACzB,EAAE;AACF,0CAA0C;AAC1C,iCAAiC;AACjC,EAAE;AACF,eAAe;AACf,IAAI","sourcesContent":["import type { BufferDataset } from '@riboseinc/paneron-extension-kit/types/buffers';\nimport type { ExporterConstructor } from '@riboseinc/paneron-extension-kit/types/export-formats';\n//import type { RegisterItem } from '../types/item';\nimport { REGISTER_METADATA_FILENAME } from '../common'; \n//import { REGISTER_ITEM_QUERY } from '../views/itemQueryUtils';\nimport { isRegisterMetadata } from '../types/register';\nimport getHTML from './page';\n\n\nconst exporter: ExporterConstructor = async function * exportPublicSite({\n getObjectData,\n getMapReducedData,\n onProgress,\n}): AsyncGenerator<BufferDataset, void, void> {\n const registerMeta = (await getObjectData({\n objectPaths: [`/${REGISTER_METADATA_FILENAME}`],\n })).data[`/${REGISTER_METADATA_FILENAME}`];\n\n if (!isRegisterMetadata(registerMeta)) {\n throw new Error(\"Invalid register metadata found\");\n }\n\n //const itemsByClass: { [clsID: string]: RegisterItem<any> } = await getMapReducedData({\n // chains: {\n // byClass: {\n // mapFunc: PUBLIC_ITEM_MAPPER,\n // reduceFunc: PUBLIC_ITEM_REDUCER,\n // },\n // },\n //});\n\n //const classIDs = Object.keys(itemsByClass);\n\n yield {\n '/hello.txt': enc.encode('hello'),\n '/index.html': enc.encode(getHTML({ title: \"Register\" })),\n '/register-meta.json': enc.encode(JSON.stringify(registerMeta)),\n };\n};\n\n\nexport default exporter;\n\n\nconst enc = new TextEncoder();\n\n\n// const PUBLIC_ITEM_PREDICATE = `\n// (${REGISTER_ITEM_QUERY}) && obj.status === 'valid'\n// `;\n// \n// /** Emits register items keyed by class ID. */\n//const PUBLIC_ITEM_MAPPER = `\n// if (${PUBLIC_ITEM_PREDICATE}) {\n// const pathWithoutSubregister = objPath.replace(/^\\/subregisters/, '');\n// const components = pathWithoutSubregister.split('/');\n// const clsID = components[1];\n// emit([clsID, obj]);\n// }\n//`;\n//\n//const PUBLIC_ITEM_REDUCER = `\n// const acc = accumulator ?? {};\n//\n// // value[0] is item class ID\n// acc[value[0]] ??= [];\n//\n// // value[1] is full register item data\n// acc[value[0]].push(value[1]);\n//\n// return acc;\n//`;\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare namespace JSX {
|
|
2
|
+
type Element = string;
|
|
3
|
+
interface IntrinsicElements {
|
|
4
|
+
[el: string]: any;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare type AttributeValue = number | string | Date | boolean;
|
|
8
|
+
export interface Children {
|
|
9
|
+
children?: string | string[];
|
|
10
|
+
}
|
|
11
|
+
export interface CustomElementHandler {
|
|
12
|
+
(attributes: Attributes & Children, contents: string[]): string;
|
|
13
|
+
}
|
|
14
|
+
export interface Attributes {
|
|
15
|
+
[key: string]: AttributeValue;
|
|
16
|
+
}
|
|
17
|
+
declare function createElement(name: string | CustomElementHandler, attributes: Attributes & Children | undefined, ...contents: string[]): string;
|
|
18
|
+
export { createElement as jsxs, createElement as jsx };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.jsx = exports.jsxs = createElement;
|
|
7
|
+
const capitalACharCode = 'A'.charCodeAt(0);
|
|
8
|
+
const capitalZCharCode = 'Z'.charCodeAt(0);
|
|
9
|
+
|
|
10
|
+
function isUpper(input, index) {
|
|
11
|
+
const charCode = input.charCodeAt(index);
|
|
12
|
+
return capitalACharCode <= charCode && capitalZCharCode >= charCode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
;
|
|
16
|
+
|
|
17
|
+
function toKebabCase(camelCased) {
|
|
18
|
+
let kebabCased = '';
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < camelCased.length; i++) {
|
|
21
|
+
const prevUpperCased = i > 0 ? isUpper(camelCased, i - 1) : true;
|
|
22
|
+
const currentUpperCased = isUpper(camelCased, i);
|
|
23
|
+
const nextUpperCased = i < camelCased.length - 1 ? isUpper(camelCased, i + 1) : true;
|
|
24
|
+
|
|
25
|
+
if (!prevUpperCased && currentUpperCased || currentUpperCased && !nextUpperCased) {
|
|
26
|
+
kebabCased += '-';
|
|
27
|
+
kebabCased += camelCased[i].toLowerCase();
|
|
28
|
+
} else {
|
|
29
|
+
kebabCased += camelCased[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return kebabCased;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
;
|
|
37
|
+
|
|
38
|
+
function escapeAttrNodeValue(value) {
|
|
39
|
+
return value.replace(/(&)|(")|(\u00A0)/g, (_, amp, quote) => {
|
|
40
|
+
if (amp) {
|
|
41
|
+
return '&';
|
|
42
|
+
} else if (quote) {
|
|
43
|
+
return '"';
|
|
44
|
+
} else {
|
|
45
|
+
return ' ';
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
;
|
|
51
|
+
|
|
52
|
+
function getAttributeStringifier(attributes) {
|
|
53
|
+
return function attributeToString(name) {
|
|
54
|
+
const value = attributes[name];
|
|
55
|
+
const formattedName = toKebabCase(name);
|
|
56
|
+
|
|
57
|
+
const makeAttribute = value => `${formattedName}="${value}"`;
|
|
58
|
+
|
|
59
|
+
if (value instanceof Date) {
|
|
60
|
+
return makeAttribute(value.toISOString());
|
|
61
|
+
} else switch (typeof value) {
|
|
62
|
+
case 'boolean':
|
|
63
|
+
if (value) {
|
|
64
|
+
return formattedName;
|
|
65
|
+
} else {
|
|
66
|
+
return '';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
default:
|
|
70
|
+
return makeAttribute(escapeAttrNodeValue(value.toString()));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
;
|
|
76
|
+
|
|
77
|
+
function attributesToString(attributes) {
|
|
78
|
+
const spaceSeparated = Object.keys(attributes).filter(attribute => attribute !== 'children').map(getAttributeStringifier(attributes)).filter(attribute => attribute.length).join(' ');
|
|
79
|
+
|
|
80
|
+
if (spaceSeparated.trim()) {
|
|
81
|
+
return ` ${spaceSeparated}`;
|
|
82
|
+
} else {
|
|
83
|
+
return '';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
;
|
|
88
|
+
|
|
89
|
+
function contentsToString(contents) {
|
|
90
|
+
var _a;
|
|
91
|
+
|
|
92
|
+
return (_a = contents.map(elements => Array.isArray(elements) ? elements.join('\n') : elements).join('\n')) !== null && _a !== void 0 ? _a : '';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
;
|
|
96
|
+
|
|
97
|
+
function createElement(name, attributes, ...contents) {
|
|
98
|
+
if (typeof name === 'function') {
|
|
99
|
+
return name(attributes !== null && attributes !== void 0 ? attributes : {}, contents);
|
|
100
|
+
} else {
|
|
101
|
+
const tagName = toKebabCase(name);
|
|
102
|
+
const inner1 = contentsToString(contents);
|
|
103
|
+
const inner2 = (attributes === null || attributes === void 0 ? void 0 : attributes.children) ? contentsToString(Array.isArray(attributes.children) ? attributes.children : [attributes.children]) : '';
|
|
104
|
+
const inner = inner1 && inner2 ? `${inner1}\n${inner2}` : inner1 || inner2;
|
|
105
|
+
return `<${tagName}${attributes ? attributesToString(attributes) : ''}>${inner}</${tagName}>`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../../src/site-builder/jsx-runtime.ts"],"names":[],"mappings":"AAqBA,MAAM,gBAAgB,GAAG,GAAG,CAAC,UAAU,CAAC,CAA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C,CAAC,EAAE,IAAI,KAAK,KAAK,OAAO,GAAG,CAAC;KAC/F;AACH,CAAC;AAED,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,aAAa,IAAI,GAAG,EAAE,CAAA","sourcesContent":["export namespace JSX {\n export type Element = string;\n export interface IntrinsicElements {\n [el: string]: any\n }\n}\n\ntype AttributeValue = number | string | Date | boolean;\n\nexport interface Children {\n children?: string | string[];\n}\n\nexport interface CustomElementHandler {\n (attributes: Attributes & Children, contents: string[]): string;\n}\n\nexport interface Attributes {\n [key: string]: AttributeValue;\n}\n\nconst capitalACharCode = 'A'.charCodeAt(0);\nconst capitalZCharCode = 'Z'.charCodeAt(0);\n\nfunction isUpper(input: string, index: number) {\n const charCode = input.charCodeAt(index);\n return capitalACharCode <= charCode && capitalZCharCode >= charCode;\n};\n\nfunction toKebabCase(camelCased: string) {\n let kebabCased = '';\n for (let i = 0; i < camelCased.length; i++) {\n const prevUpperCased = i > 0 ? isUpper(camelCased, i - 1) : true;\n const currentUpperCased = isUpper(camelCased, i);\n const nextUpperCased = i < camelCased.length - 1 ? isUpper(camelCased, i + 1) : true;\n if (!prevUpperCased && currentUpperCased || currentUpperCased && !nextUpperCased) {\n kebabCased += '-';\n kebabCased += camelCased[i].toLowerCase();\n } else {\n kebabCased += camelCased[i];\n }\n }\n return kebabCased;\n};\n\nfunction escapeAttrNodeValue(value: string) {\n return (\n value.replace(/(&)|(\")|(\\u00A0)/g, (_, amp, quote) => {\n if (amp) { return '&'; }\n else if (quote) { return '"'; }\n else { return ' '; }\n })\n );\n};\n\nfunction getAttributeStringifier(attributes: Attributes) {\n return function attributeToString(name: string): string {\n const value = attributes[name];\n const formattedName = toKebabCase(name);\n const makeAttribute = (value: string) => `${formattedName}=\"${value}\"`;\n\n if (value instanceof Date) {\n return makeAttribute(value.toISOString());\n } else switch (typeof value) {\n case 'boolean':\n if (value) {\n return formattedName;\n } else {\n return '';\n }\n default:\n return makeAttribute(escapeAttrNodeValue(value.toString()));\n }\n }\n};\n\nfunction attributesToString(attributes: Attributes) {\n const spaceSeparated = Object.keys(attributes).\n filter(attribute => attribute !== 'children').\n map(getAttributeStringifier(attributes)).\n filter(attribute => attribute.length).\n join(' ');\n if (spaceSeparated.trim()) {\n return ` ${spaceSeparated}`;\n } else {\n return '';\n }\n};\n\nfunction contentsToString(contents: string[]) {\n return contents.\n map(elements => Array.isArray(elements) ? elements.join('\\n') : elements).\n join('\\n') ?? ''\n};\n\nfunction createElement(\n name: string | CustomElementHandler,\n attributes: Attributes & Children | undefined,\n ...contents: string[]\n): string {\n if (typeof name === 'function') {\n return name(attributes ?? {}, contents);\n } else {\n const tagName = toKebabCase(name);\n const inner1 = contentsToString(contents);\n const inner2 = attributes?.children\n ? contentsToString(\n Array.isArray(attributes.children)\n ? attributes.children\n : [attributes.children]\n )\n : '';\n const inner = inner1 && inner2\n ? `${inner1}\\n${inner2}`\n : inner1 || inner2;\n return `<${tagName}${attributes ? attributesToString(attributes) : ''}>${inner}</${tagName}>`;\n }\n}\n\nexport { createElement as jsxs, createElement as jsx }\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = getHTML;
|
|
7
|
+
|
|
8
|
+
var _jsxRuntime = require("./jsx-runtime");
|
|
9
|
+
|
|
10
|
+
function getHTML(meta) {
|
|
11
|
+
return (0, _jsxRuntime.jsxs)("html", {
|
|
12
|
+
children: [(0, _jsxRuntime.jsx)("head", {
|
|
13
|
+
children: (0, _jsxRuntime.jsx)("title", {
|
|
14
|
+
children: meta.title
|
|
15
|
+
})
|
|
16
|
+
}), (0, _jsxRuntime.jsx)("body", {
|
|
17
|
+
children: (0, _jsxRuntime.jsx)("div", {
|
|
18
|
+
children: "test"
|
|
19
|
+
})
|
|
20
|
+
})]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/site-builder/page.tsx"],"names":[],"mappings":";AAQA,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAc;IAC5C,OAAO,2BACL,yBACE,0BAAQ,IAAI,CAAC,KAAK,GAAS,GACtB,EACP,yBACE,iCAAe,GACV,IACF,CAAC;AACV,CAAC;AAAA,CAAC","sourcesContent":["/** @jsxImportSource . */\n\n\ninterface PageMeta {\n title: string\n}\n\n\nexport default function getHTML(meta: PageMeta): string {\n return <html>\n <head>\n <title>{meta.title}</title>\n </head>\n <body>\n <div>test</div>\n </body>\n </html>;\n};\n\n// XXX: Write `getHead()`\n"]}
|
package/types/cr.d.ts
CHANGED
|
@@ -63,7 +63,11 @@ export interface TransitionEntry {
|
|
|
63
63
|
export declare function isCreatedBy(stakeholder: RegisterStakeholder, cr: Base): boolean;
|
|
64
64
|
/** Whether given `cr` can be edited (as in, items changed) by specified stakeholder. */
|
|
65
65
|
export declare function canBeEditedBy(stakeholder: RegisterStakeholder, cr: Base): boolean;
|
|
66
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Whether given `cr` can be deleted by given stakeholder.
|
|
68
|
+
* Unlike editing, deletion is possible only if there are no items
|
|
69
|
+
* and CR was never proposed.
|
|
70
|
+
*/
|
|
67
71
|
export declare function canBeDeletedBy(stakeholder: RegisterStakeholder, cr: Base): boolean;
|
|
68
72
|
/** Proposal structure for single-file proposal import format. */
|
|
69
73
|
export interface ImportableCR {
|
package/types/cr.js
CHANGED
|
@@ -81,11 +81,15 @@ function isCreatedBy(stakeholder, cr) {
|
|
|
81
81
|
function canBeEditedBy(stakeholder, cr) {
|
|
82
82
|
return isCreatedBy(stakeholder, cr) && isEditableState(cr.state);
|
|
83
83
|
}
|
|
84
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Whether given `cr` can be deleted by given stakeholder.
|
|
86
|
+
* Unlike editing, deletion is possible only if there are no items
|
|
87
|
+
* and CR was never proposed.
|
|
88
|
+
*/
|
|
85
89
|
|
|
86
90
|
|
|
87
91
|
function canBeDeletedBy(stakeholder, cr) {
|
|
88
|
-
return isCreatedBy(stakeholder, cr) && isEditableState(cr.state) && Object.keys(cr.items).length < 1;
|
|
92
|
+
return isCreatedBy(stakeholder, cr) && isEditableState(cr.state) && Object.keys(cr.items).length < 1 && !cr.timeProposed;
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
function isImportableCR(val) {
|
package/types/cr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cr.js","sourceRoot":"","sources":["../../src/types/cr.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAS1D,MAAM,UAAU,aAAa,CAAC,WAAgC,EAAE,EAAQ;IACtE,OAAO;IACL,6BAA6B;IAC7B,WAAW,CAAC,iBAAiB,KAAK,EAAE,CAAC,sCAAsC,CAAC,CAAC;AACjF,CAAC;AAID,wBAAwB;AACxB,wBAAwB;AACxB,wBAAwB;AAExB,6CAA6C;AAC7C,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,iCAAiC,EAAE,6BAA6B;IAChE,0BAA0B,EAAE,4BAA4B;IACxD,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,6BAA6B;IACvC,kBAAkB,EAAE,oBAAoB;IACxC,0BAA0B,EAAE,4BAA4B;IACxD,gBAAgB,EAAE,kBAAkB;CAC5B,CAAC;AAIX,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAgB,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,2DAA2D;AAC3D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,CAAC,KAAK;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AAO,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC;AACxB,CAAC","sourcesContent":["/** Change request types, states and state transitions. */\n\nimport type React from 'react';\nimport type { ProposalSet } from './proposal';\nimport { type RegisterStakeholder } from './stakeholder';\nimport type { RegisterItem } from './item';\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 pastTransitions?: TransitionEntry[];\n}\n\n\nexport interface TransitionEntry {\n /** Verb in past tense. */\n label: string;\n\n timestamp: Date;\n fromState: StateType;\n toState: StateType;\n stakeholder: RegisterStakeholder;\n input: StateInput;\n}\n\n\nexport function isCreatedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return stakeholder.gitServerUsername?.trim() !== '' && stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername;\n}\n\n/** Whether given `cr` can be edited (as in, items changed) by specified stakeholder. */\nexport function canBeEditedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return isCreatedBy(stakeholder, cr) && isEditableState(cr.state);\n}\n\n/** Whether given `cr` can be deleted by given stakeholder. */\nexport function canBeDeletedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return isCreatedBy(stakeholder, cr) && isEditableState(cr.state) && Object.keys(cr.items).length < 1;\n}\n\n\n/** Proposal structure for single-file proposal import format. */\nexport interface ImportableCR {\n /** Proposal data. */\n proposalDraft: Drafted,\n /** Register item data for additions & clarifications. */\n itemPayloads: Record<string, RegisterItem<any>>,\n}\nexport function isImportableCR(val: any): val is ImportableCR {\n // TODO: More complete check\n return (\n val.proposalDraft.id\n && isDrafted(val.proposalDraft as Base)\n && Object.keys(val.itemPayloads).length > 0);\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 function isSubmittedForControlBodyReview(cr: Base): cr is SubmittedForControlBodyReview {\n return isInState(cr, State.SUBMITTED_FOR_CONTROL_BODY_REVIEW)\n}\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 function isReturnedForClarification(cr: Base): cr is (ReturnedForClarificationByManager | ReturnedForClarificationByControlBody) {\n return isInState(cr, State.RETURNED_FOR_CLARIFICATION)\n}\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 }\nexport function isRejected(cr: Base): cr is Rejected {\n return isInState(cr, State.REJECTED);\n}\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 }\nexport function isRejectedOnAppeal(cr: Base): cr is RejectionUpheld {\n return isInState(cr, State.REJECTION_UPHELD_ON_APPEAL);\n}\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 }\nexport function isRejectedWithAppealWithdrawn(cr: Base): cr is RejectedWithAppealWithdrawn {\n return isInState(cr, State.APPEAL_WITHDRAWN);\n}\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}\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.WITHDRAWN]:\n TransitionConfig<Proposed, Withdrawn>;\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"]}
|
|
1
|
+
{"version":3,"file":"cr.js","sourceRoot":"","sources":["../../src/types/cr.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAS1D,MAAM,UAAU,aAAa,CAAC,WAAgC,EAAE,EAAQ;IACtE,OAAO;IACL,6BAA6B;IAC7B,WAAW,CAAC,iBAAiB,KAAK,EAAE,CAAC,sCAAsC,CAAC,CAAC;AACjF,CAAC;AAID,wBAAwB;AACxB,wBAAwB;AACxB,wBAAwB;AAExB,6CAA6C;AAC7C,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,iCAAiC,EAAE,6BAA6B;IAChE,0BAA0B,EAAE,4BAA4B;IACxD,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,6BAA6B;IACvC,kBAAkB,EAAE,oBAAoB;IACxC,0BAA0B,EAAE,4BAA4B;IACxD,gBAAgB,EAAE,kBAAkB;CAC5B,CAAC;AAIX,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAgB,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,2DAA2D;AAC3D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,CAAC,KAAK;IACX,KAAK,CAAC,0BAA0B;CACxB,CAAC;AAIX,MAAM,UAAU,eAAe,CAAC,KAAgB;IAC9C,OAAO,aAAa,CAAC,OAAO,CAAC,KAA0B,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;AAyDD,MAAM,UAAU,WAAW,CAAC,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CAAC;AAKD,MAAM,UAAU,6BAA6B,CAAC,EAAQ;IACpD,OAAO,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAC/C,CAAC;AASD,MAAM,UAAU,iBAAiB,CAAC,GAAQ;IACxC,OAAO,GAAG,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ,CAAC;AACtF,CAAC;AAID,MAAM,UAAU,uBAAuB,CAAC,GAAQ;IAC9C,OAAO,GAAG,CAAC,cAAc,CAAC,sBAAsB,CAAC,IAAI,OAAO,GAAG,CAAC,oBAAoB,KAAK,QAAQ,CAAC;AACpG,CAAC;AAID,MAAM,UAAU,mBAAmB,CAAC,GAAQ;IAC1C,OAAO,CACL,GAAG,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,OAAO,GAAG,CAAC,gBAAgB,KAAK,QAAQ;QAClF,GAAG,CAAC,cAAc,CAAC,0BAA0B,CAAC,IAAI,OAAO,GAAG,CAAC,wBAAwB,KAAK,QAAQ,CAAC,CAAC;AACxG,CAAC;AAID,MAAM,UAAU,gBAAgB,CAAC,GAAQ;IACvC,OAAO,GAAG,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,OAAO,GAAG,CAAC,YAAY,KAAK,QAAQ,CAAC;AACpF,CAAC;AAID,MAAM,UAAU,qBAAqB,CAAC,GAAQ;IAC5C,OAAO,GAAG,CAAC,cAAc,CAAC,oBAAoB,CAAC,IAAI,OAAO,GAAG,CAAC,kBAAkB,KAAK,QAAQ,CAAC;AAChG,CAAC;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAS,SAAS,CAAkB,EAAQ,EAAE,CAAc;IAC1D,OAAO,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC;AACxB,CAAC","sourcesContent":["/** Change request types, states and state transitions. */\n\nimport type React from 'react';\nimport type { ProposalSet } from './proposal';\nimport { type RegisterStakeholder } from './stakeholder';\nimport type { RegisterItem } from './item';\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 pastTransitions?: TransitionEntry[];\n}\n\n\nexport interface TransitionEntry {\n /** Verb in past tense. */\n label: string;\n\n timestamp: Date;\n fromState: StateType;\n toState: StateType;\n stakeholder: RegisterStakeholder;\n input: StateInput;\n}\n\n\nexport function isCreatedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return stakeholder.gitServerUsername?.trim() !== '' && stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername;\n}\n\n/** Whether given `cr` can be edited (as in, items changed) by specified stakeholder. */\nexport function canBeEditedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return isCreatedBy(stakeholder, cr) && isEditableState(cr.state);\n}\n\n/**\n * Whether given `cr` can be deleted by given stakeholder.\n * Unlike editing, deletion is possible only if there are no items\n * and CR was never proposed.\n */\nexport function canBeDeletedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return (\n isCreatedBy(stakeholder, cr)\n && isEditableState(cr.state)\n && Object.keys(cr.items).length < 1\n && !((cr as Proposed).timeProposed)\n );\n}\n\n\n/** Proposal structure for single-file proposal import format. */\nexport interface ImportableCR {\n /** Proposal data. */\n proposalDraft: Drafted,\n /** Register item data for additions & clarifications. */\n itemPayloads: Record<string, RegisterItem<any>>,\n}\nexport function isImportableCR(val: any): val is ImportableCR {\n // TODO: More complete check\n return (\n val.proposalDraft.id\n && isDrafted(val.proposalDraft as Base)\n && Object.keys(val.itemPayloads).length > 0);\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 function isSubmittedForControlBodyReview(cr: Base): cr is SubmittedForControlBodyReview {\n return isInState(cr, State.SUBMITTED_FOR_CONTROL_BODY_REVIEW)\n}\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 function isReturnedForClarification(cr: Base): cr is (ReturnedForClarificationByManager | ReturnedForClarificationByControlBody) {\n return isInState(cr, State.RETURNED_FOR_CLARIFICATION)\n}\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 }\nexport function isRejected(cr: Base): cr is Rejected {\n return isInState(cr, State.REJECTED);\n}\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 }\nexport function isRejectedOnAppeal(cr: Base): cr is RejectionUpheld {\n return isInState(cr, State.REJECTION_UPHELD_ON_APPEAL);\n}\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 }\nexport function isRejectedWithAppealWithdrawn(cr: Base): cr is RejectedWithAppealWithdrawn {\n return isInState(cr, State.APPEAL_WITHDRAWN);\n}\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}\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.WITHDRAWN]:\n TransitionConfig<Proposed, Withdrawn>;\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/util.d.ts
CHANGED
package/types/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/types/util.ts"],"names":[],"mappings":"AAAA,YAAY","sourcesContent":["// Utilities\n\nexport interface Locale {\n name: string\n country: string\n languageCode: string // ISO 639-2\n characterEncoding: 'utf-8' // TODO: Support more encodings\n // TODO: citation?: CI_Citation\n}\n\n\nexport interface Citation {\n title: string\n\n seriesIssueID: string | null\n seriesName: string | null\n seriesPage: string | null\n\n edition: string | null\n editionDate: Date | null\n\n otherDetails: string\n\n isbn: string | null\n issn: string | null\n\n
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/types/util.ts"],"names":[],"mappings":"AAAA,YAAY","sourcesContent":["// Utilities\n\nexport interface Locale {\n name: string\n country: string\n languageCode: string // ISO 639-2\n characterEncoding: 'utf-8' // TODO: Support more encodings\n // TODO: citation?: CI_Citation\n}\n\n\nexport interface Citation {\n title: string\n\n seriesIssueID: string | null\n seriesName: string | null\n seriesPage: string | null\n\n edition: string | null\n editionDate: Date | null\n\n otherDetails: string\n\n isbn: string | null\n issn: string | null\n\n alternateTitles?: string[]\n\n uri?: string\n\n //publicationDate: Date\n}\n\n\nexport interface LocalizedAlternative<T> {\n alternative: T\n locale: Locale\n}\n"]}
|
package/types/views.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export interface ExportFormatConfiguration<P extends Payload> {
|
|
|
66
66
|
export interface ItemClassConfiguration<P extends Payload> {
|
|
67
67
|
meta: RegisterItemClass;
|
|
68
68
|
itemCanBeSuperseded?: boolean;
|
|
69
|
+
/** Used to pre-populate item data e.g. when a new item is created. */
|
|
69
70
|
defaults?: RegistryItemPayloadDefaults<P>;
|
|
70
71
|
validatePayload?: (item: P) => Promise<boolean>;
|
|
71
72
|
sanitizePayload?: (item: P) => Promise<P>;
|
|
@@ -88,6 +89,27 @@ export interface RegistryViewProps<Items extends ItemClassConfigurationSet = Rec
|
|
|
88
89
|
* Not very useful since there are also preset searches in the browser now.
|
|
89
90
|
*/
|
|
90
91
|
defaultSearchCriteria?: CriteriaGroup;
|
|
92
|
+
/**
|
|
93
|
+
* Default predicate for matching items
|
|
94
|
+
* using quick search.
|
|
95
|
+
*
|
|
96
|
+
* Must return the search expression as text.
|
|
97
|
+
*
|
|
98
|
+
* Search expression must return a boolean and can access:
|
|
99
|
+
*
|
|
100
|
+
* - `obj`, which *should* be a RegisterItem instance
|
|
101
|
+
* with `obj.data` being its class-specific payload.
|
|
102
|
+
*
|
|
103
|
+
* E.g., if all important item classes in your register
|
|
104
|
+
* specify a `name` field:
|
|
105
|
+
*
|
|
106
|
+
* @example (searchQuery) => `obj.data?.name?.toLowerCase().indexOf("${searchQuery.toLowerCase()}") >= 0`
|
|
107
|
+
*/
|
|
108
|
+
getQuickSearchPredicate?: (quickSearchQuery: string) => string;
|
|
109
|
+
/**
|
|
110
|
+
* Extension-provided additional views that don’t correspond
|
|
111
|
+
* to entities like register item, change request, etc. handled by RegistryKit.
|
|
112
|
+
*/
|
|
91
113
|
customViews?: CustomViewConfiguration[];
|
|
92
114
|
}
|
|
93
115
|
export interface CustomViewConfiguration {
|
package/types/views.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../src/types/views.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { ButtonProps, MenuItemProps } from '@blueprintjs/core';\nimport type { ObjectDatasetRequest, ObjectDatasetResponse, ValueHook } from '@riboseinc/paneron-extension-kit/types';\nimport type { InternalItemReference, Payload, RegisterItem, RegisterItemClass } from './item';\nimport type { CriteriaGroup } from '../views/FilterCriteria/models';\n\n\n// Hooks\n\n/**\n * Mostly a wrapper around useObjectData, but coerces value type\n * (TODO: validate!) and takes into account change request from any\n * wrapping change request context. If a change request is present,\n * will substitute proposed item data unless `ignoreActiveCR` is set.\n *\n * NOTE: Despite the name, returns the entire RegisterItem,\n * not just the `.data` property with item payload.\n */\nexport type RegisterItemDataHook<P extends Payload = Payload> =\n (opts: { itemPaths: string[], ignoreActiveCR?: true }) => ValueHook<Record<string, RegisterItem<P> | null>>;\n\n\n// Extension configuration\n\n// TODO: Obsolete?\n// export interface ExtensionContext {\n// getRelatedItemClassConfiguration: (classID: string) => RelatedItemClassConfiguration\n// useRegisterItemData: RegisterItemDataHook\n// onJump?: () => void\n// }\n\nexport interface RegisterConfiguration\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>> {\n /**\n * Configuration for all items in this register.\n * This includes items in subregisters.\n */\n itemClassConfiguration: Items\n\n /**\n * Default expression used to sort an item.\n * Passed to useFilteredIndex().\n */\n keyExpression?: string\n\n /** Subregister information. */\n subregisters?: Subregisters<Items>\n}\n\nexport type Subregisters\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>> = {\n [subregisterID: string]: {\n title: string\n\n /** Names of item classes that go in this subregister. */\n itemClasses: (keyof Items)[]\n }\n};\n\nexport type ItemClassConfigurationSet = {\n [itemClassID: string]: ItemClassConfiguration<any>\n};\n\n\n\nexport interface ExportFormatConfiguration<P extends Payload> {\n /** The name of the export format. */\n label: string\n\n /**\n * Trailing part of the filename to save export as;\n * must include at least extension (with separator),\n * must not include any path prefix.\n */\n filenameExtension: string\n\n /**\n * The function that takes register item data and some helper functions\n * and is expected to return a blob.\n */\n exportItem: (\n itemData: RegisterItem<P>,\n opts: {\n getObjectData: (opts: ObjectDatasetRequest) => Promise<ObjectDatasetResponse>,\n getBlob: (val: string) => Promise<Uint8Array>,\n logger?: { log: Console[\"log\"], error: Console[\"error\"], debug: Console[\"debug\"] },\n },\n ) => Promise<Uint8Array>\n}\n\n\nexport interface ItemClassConfiguration<P extends Payload/*, F extends Field*/> {\n meta: RegisterItemClass\n\n itemCanBeSuperseded?: boolean\n // If false, items of this class cannot be superseded, only retired.\n // Default is true.\n\n
|
|
1
|
+
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../src/types/views.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { ButtonProps, MenuItemProps } from '@blueprintjs/core';\nimport type { ObjectDatasetRequest, ObjectDatasetResponse, ValueHook } from '@riboseinc/paneron-extension-kit/types';\nimport type { InternalItemReference, Payload, RegisterItem, RegisterItemClass } from './item';\nimport type { CriteriaGroup } from '../views/FilterCriteria/models';\n\n\n// Hooks\n\n/**\n * Mostly a wrapper around useObjectData, but coerces value type\n * (TODO: validate!) and takes into account change request from any\n * wrapping change request context. If a change request is present,\n * will substitute proposed item data unless `ignoreActiveCR` is set.\n *\n * NOTE: Despite the name, returns the entire RegisterItem,\n * not just the `.data` property with item payload.\n */\nexport type RegisterItemDataHook<P extends Payload = Payload> =\n (opts: { itemPaths: string[], ignoreActiveCR?: true }) => ValueHook<Record<string, RegisterItem<P> | null>>;\n\n\n// Extension configuration\n\n// TODO: Obsolete?\n// export interface ExtensionContext {\n// getRelatedItemClassConfiguration: (classID: string) => RelatedItemClassConfiguration\n// useRegisterItemData: RegisterItemDataHook\n// onJump?: () => void\n// }\n\nexport interface RegisterConfiguration\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>> {\n /**\n * Configuration for all items in this register.\n * This includes items in subregisters.\n */\n itemClassConfiguration: Items\n\n /**\n * Default expression used to sort an item.\n * Passed to useFilteredIndex().\n */\n keyExpression?: string\n\n /** Subregister information. */\n subregisters?: Subregisters<Items>\n}\n\nexport type Subregisters\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>> = {\n [subregisterID: string]: {\n title: string\n\n /** Names of item classes that go in this subregister. */\n itemClasses: (keyof Items)[]\n }\n};\n\nexport type ItemClassConfigurationSet = {\n [itemClassID: string]: ItemClassConfiguration<any>\n};\n\n\n\nexport interface ExportFormatConfiguration<P extends Payload> {\n /** The name of the export format. */\n label: string\n\n /**\n * Trailing part of the filename to save export as;\n * must include at least extension (with separator),\n * must not include any path prefix.\n */\n filenameExtension: string\n\n /**\n * The function that takes register item data and some helper functions\n * and is expected to return a blob.\n */\n exportItem: (\n itemData: RegisterItem<P>,\n opts: {\n getObjectData: (opts: ObjectDatasetRequest) => Promise<ObjectDatasetResponse>,\n getBlob: (val: string) => Promise<Uint8Array>,\n logger?: { log: Console[\"log\"], error: Console[\"error\"], debug: Console[\"debug\"] },\n },\n ) => Promise<Uint8Array>\n}\n\n\nexport interface ItemClassConfiguration<P extends Payload/*, F extends Field*/> {\n meta: RegisterItemClass\n\n itemCanBeSuperseded?: boolean\n // If false, items of this class cannot be superseded, only retired.\n // Default is true.\n\n /** Used to pre-populate item data e.g. when a new item is created. */\n defaults?: RegistryItemPayloadDefaults<P>\n\n validatePayload?: (item: P) => Promise<boolean>\n sanitizePayload?: (item: P) => Promise<P>\n\n // XXX: Confirm if obsolete and remove\n itemSorter?: (a: P, b: P) => number\n\n /**\n * Expression used to sort an item of this class.\n * Passed to useFilteredIndex().\n */\n keyExpression?: string\n\n exportFormats?: Readonly<ExportFormatConfiguration<P>[]>\n\n views: {\n listItemView: ItemListView<P>\n editView: ItemEditView<P>\n detailView?: ItemDetailView<P>\n }\n}\n\n\nexport interface RegistryViewProps\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>>\nextends RegisterConfiguration<Items> {\n /**\n * When search is initially opened, have this query pre-defined.\n * Not very useful since there are also preset searches in the browser now.\n */\n // TODO: Obsoluete?\n defaultSearchCriteria?: CriteriaGroup\n\n /**\n * Default predicate for matching items\n * using quick search.\n *\n * Must return the search expression as text.\n *\n * Search expression must return a boolean and can access:\n *\n * - `obj`, which *should* be a RegisterItem instance\n * with `obj.data` being its class-specific payload.\n *\n * E.g., if all important item classes in your register\n * specify a `name` field:\n *\n * @example (searchQuery) => `obj.data?.name?.toLowerCase().indexOf(\"${searchQuery.toLowerCase()}\") >= 0`\n */\n getQuickSearchPredicate?: (quickSearchQuery: string) => string\n\n /**\n * Extension-provided additional views that don’t correspond\n * to entities like register item, change request, etc. handled by RegistryKit.\n */\n customViews?: CustomViewConfiguration[]\n}\n\nexport interface CustomViewConfiguration {\n id: string\n label: string\n description: string\n view: React.FC<{\n /** View can support optional path for custom state/inner navigation (provisional). */\n path: string\n }>\n icon?: JSX.Element\n}\n\n\n// Item views\n\nexport interface ItemAction {\n getButtonProps:\n (item: RegisterItem<any>, itemClass: ItemClassConfiguration<any>, subregisterID?: string) =>\n ButtonProps | MenuItemProps\n}\n\nexport type RegistryView = React.FC<RegistryViewProps>\n\ntype RegistryItemPayloadDefaults<P extends Payload> =\n Partial<Omit<P, 'id'>>;\n\n/**\n * A small part of item class configuration,\n * useful e.g. for formatting related items.\n */\nexport type RelatedItemClassConfiguration = {\n title: string\n itemView: ItemListView<any>\n}\n\n\nexport interface RegistryItemViewProps<P extends Payload> {\n /**\n * Item reference.\n * Glossarist, for example, uses it to determine language subregister and set appropriate writing direction.\n */\n itemRef: Omit<InternalItemReference, 'itemID'> & { itemID?: InternalItemReference['itemID'] }\n\n /** Item data (payload). */\n itemData: P\n\n className?: string\n //subregisterID?: string\n\n /** Deprecated */\n useRegisterItemData?: any\n /** Deprecated */\n getRelatedItemClassConfiguration?: any\n}\n\nexport interface GenericRelatedItemViewProps {\n /** Currently selected item’s ref. */\n itemRef?: InternalItemReference\n\n /**\n * By default, clicking the item will spawn a tab via TabbedWorkspace context.\n * This prop can customize that behavior.\n */\n onJump?: () => void\n\n className?: string\n\n /**\n * Determines which item classes can be selected in the search dialog.\n * If undefined, *any* class can be chosen.\n * If empty list, no class can be chosen (weird).\n */\n availableClassIDs?: string[]\n\n // XXX: Check if obsolete, remove if unused\n itemSorter?: ItemClassConfiguration<any>[\"itemSorter\"]\n\n /** Called to auto-create an item (can’t auto-create if not provided) */\n onCreateNew?: () => Promise<InternalItemReference>\n\n /** Called when current item is cleared (can’t clear if not provided) */\n onClear?: () => void\n\n /** Called when a new item is selected (can’t change if not provided) */\n onChange?: (newRef: InternalItemReference) => void\n\n /** @deprecated subregisters no longer supported. */\n availableSubregisterIDs?: string[]\n\n /** @deprecated */\n useRegisterItemData?: any\n //useRegisterItemData: RegisterItemDataHook\n\n /** @deprecated */\n getRelatedItemClassConfiguration?: any\n //getRelatedItemClassConfiguration: ExtensionContext[\"getRelatedItemClassConfiguration\"]\n}\n\n\nexport type ItemEditView<P extends Payload> = React.FC<ItemEditViewProps<P>>;\n\nexport interface ItemEditViewProps<P extends Payload> extends RegistryItemViewProps<P> {\n onChange?: (newData: P) => void\n onCreateRelatedItem?:\n (classID: string, subregisterID?: string) => Promise<InternalItemReference>\n}\n\nexport interface ItemDetailViewProps<P extends Payload> extends RegistryItemViewProps<P> {\n //useRegisterItemData: RegisterItemDataHook\n}\n\nexport type ItemDetailView<P extends Payload> = React.FC<ItemDetailViewProps<P>>;\n\nexport interface ItemListViewProps<P extends Payload> extends RegistryItemViewProps<P> {\n}\n\nexport type ItemListView<P extends Payload> = React.FC<ItemListViewProps<P>>;\n\nexport type LazyItemView = React.FC<{ itemID: string }>;\n"]}
|
package/views/BrowserCtx.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
/// <reference types="react" />
|
|
3
|
-
import type {
|
|
4
|
-
import { type CriteriaGroup } from './FilterCriteria/models';
|
|
3
|
+
import type { ItemClassConfigurationSet, ItemClassConfiguration, RegisterItem, RegisterItemDataHook, Register, RegisterStakeholder, RelatedItemClassConfiguration, Subregisters, InternalItemReference, RegistryViewProps } from '../types';
|
|
5
4
|
import { type Protocol } from './protocolRegistry';
|
|
6
|
-
export
|
|
5
|
+
export interface BrowserCtx extends Pick<RegistryViewProps, "defaultSearchCriteria" | "getQuickSearchPredicate" | "customViews"> {
|
|
7
6
|
itemClasses: ItemClassConfigurationSet;
|
|
8
7
|
subregisters?: Subregisters;
|
|
9
8
|
/**
|
|
@@ -20,8 +19,6 @@ export declare type BrowserCtx = {
|
|
|
20
19
|
* Should contain the expression itself, no “return” statement.
|
|
21
20
|
*/
|
|
22
21
|
keyExpression?: string;
|
|
23
|
-
/** Default search criteria to be used by the Search sidebar */
|
|
24
|
-
defaultSearchCriteria?: CriteriaGroup;
|
|
25
22
|
/**
|
|
26
23
|
* Allows to access register metadata
|
|
27
24
|
* (e.g., version, stakeholders).
|
|
@@ -64,14 +61,9 @@ export declare type BrowserCtx = {
|
|
|
64
61
|
* If a path contains nothing or contains not a register item,
|
|
65
62
|
* the result will be null.
|
|
66
63
|
*/
|
|
67
|
-
/**
|
|
68
|
-
* Extension-provided additional views that don’t correspond
|
|
69
|
-
* to entities like register item, change request, etc. handled by RegistryKit.
|
|
70
|
-
*/
|
|
71
|
-
customViews: CustomViewConfiguration[];
|
|
72
64
|
/**
|
|
73
65
|
* Given item class ID, returns a small subset of relevant class configuration data.
|
|
74
66
|
*/
|
|
75
67
|
getRelatedItemClassConfiguration: (clsID: string) => RelatedItemClassConfiguration;
|
|
76
|
-
}
|
|
68
|
+
}
|
|
77
69
|
export declare const BrowserCtx: import("react").Context<BrowserCtx>;
|
package/views/BrowserCtx.js
CHANGED
package/views/BrowserCtx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserCtx.js","sourceRoot":"","sources":["../../src/views/BrowserCtx.tsx"],"names":[],"mappings":"AAAA,eAAe;AAEf,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BrowserCtx.js","sourceRoot":"","sources":["../../src/views/BrowserCtx.tsx"],"names":[],"mappings":"AAAA,eAAe;AAEf,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAmGrC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAa;IAClD,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,EAAE;IACf,yCAAyC;IACzC,oBAAoB,EAAE,IAAI;IAC1B,gBAAgB,EAAE,SAAS;IAC3B,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE,EAAE;QACT,WAAW,EAAE,CAAC,CAAC;QACf,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;KACtB,CAAC;IACF,gCAAgC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,kCAAqB,EAAE,CAAC;CAClG,CAAC,CAAC","sourcesContent":["/** @jsx jsx */\n\nimport { jsx } from '@emotion/react';\nimport { createContext } from 'react';\nimport type {\n ItemClassConfigurationSet,\n ItemClassConfiguration,\n RegisterItem,\n RegisterItemDataHook,\n Register,\n RegisterStakeholder,\n RelatedItemClassConfiguration,\n // SaveProposalHandler,\n Subregisters,\n InternalItemReference,\n RegistryViewProps,\n} from '../types';\nimport { type Protocol } from './protocolRegistry';\n\n\n// TODO(perf): split into smaller contexts\nexport interface BrowserCtx\nextends Pick<RegistryViewProps, \"defaultSearchCriteria\" | \"getQuickSearchPredicate\" | \"customViews\"> {\n itemClasses: ItemClassConfigurationSet\n subregisters?: Subregisters\n\n /**\n * Stakeholder corresponding to the current user.\n * If current user is not a stakeholder, undefined.\n */\n stakeholder?: RegisterStakeholder\n\n /**\n * Set if no remote is configured.\n */\n offline?: true\n\n /**\n * Common “key expression” (used for sorting) across the register.\n * Should contain the expression itself, no “return” statement.\n */\n keyExpression?: string\n\n /**\n * Allows to access register metadata\n * (e.g., version, stakeholders).\n *\n * `undefined` if loading, `null` if unspecified.\n */\n registerMetadata?: Register | null\n\n /** Hook for getting register item data. */\n useRegisterItemData: RegisterItemDataHook\n\n /**\n * Invoked to navigate to an item.\n * In SPA tabbed context, could translate to `spawnTab()`;\n * in static web context, could translate to navigating browser location.\n */\n jumpTo?: (uri: `${Protocol}:${string}`) => void\n\n /**\n * If a register item is selected, provide its data here.\n *\n * If item data is still loading or invalid, `undefined`.\n * If item is not selected, `null`.\n */\n selectedRegisterItem?: {\n item: RegisterItem<any>\n ref: InternalItemReference\n itemClass: ItemClassConfiguration<any>\n } | null\n\n /**\n * Change request being drafted or reviewed.\n * `undefined` if loading, `null` if there is no active change request.\n */\n activeChangeRequestID?: string | null\n\n /**\n * Setter for `activeChangeRequest()`. Set to `null` to unset.\n */\n setActiveChangeRequestID?: (id: string | null) => void\n\n /**\n * An async function for retrieving data of register items\n * at given paths. For cases where the hook doesn’t work.\n *\n * If a path contains nothing or contains not a register item,\n * the result will be null.\n */\n // getRegisterItemData: (opts: { itemPaths: string[] }) => Promise<Record<string, RegisterItem<any> | null>>\n\n // onPropose?: SaveProposalHandler\n\n //selectedItemPath?: string\n\n /**\n * Given item class ID, returns a small subset of relevant class configuration data.\n */\n getRelatedItemClassConfiguration: (clsID: string) => RelatedItemClassConfiguration\n // TODO: Rename to just “get class config”\n};\n\nexport const BrowserCtx = createContext<BrowserCtx>({\n itemClasses: {},\n customViews: [],\n // getRegisterItemData: async () => ({}),\n selectedRegisterItem: null,\n registerMetadata: undefined,\n useRegisterItemData: () => ({\n value: {},\n _reqCounter: -1,\n errors: [],\n isUpdating: true,\n refresh: () => void 0,\n }),\n getRelatedItemClassConfiguration: () => ({ title: 'N/A', itemView: () => <span>Loading…</span> }),\n});\n"]}
|