@pleasenobugs/core 0.1.1 → 0.3.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/rules.d.ts +74 -2
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +133 -3
- package/dist/rules.js.map +1 -1
- package/dist/thread.d.ts +38 -0
- package/dist/thread.d.ts.map +1 -0
- package/dist/thread.js +48 -0
- package/dist/thread.js.map +1 -0
- package/dist/types.d.ts +130 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/dist/rules.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { PostKind, PostStatus, Rules } from './types.js';
|
|
1
|
+
import type { PostFix, PostKind, PostStatus, Rules, ShotRule } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* The limits a new project starts with. These are the numbers Shitti's board
|
|
4
4
|
* ran on, where they had been tried on real people before being written here.
|
|
5
5
|
*/
|
|
6
6
|
export declare const DEFAULT_RULES: Readonly<Rules>;
|
|
7
|
+
export declare const SHOT_RULES: readonly ShotRule[];
|
|
8
|
+
/** Whether a value is one of the screenshot rules, for reading a request or a variable. */
|
|
9
|
+
export declare function isShotRule(v: unknown): v is ShotRule;
|
|
7
10
|
/** A display name. Long enough for a real one, short enough for a card. */
|
|
8
11
|
export declare const NAME_MAX = 24;
|
|
9
12
|
/** A client-minted post id. */
|
|
@@ -15,10 +18,79 @@ export declare const CONTEXT_VALUE_MAX = 100;
|
|
|
15
18
|
export declare const DAY_MS: number;
|
|
16
19
|
export declare const POST_KINDS: readonly PostKind[];
|
|
17
20
|
export declare const POST_STATUSES: readonly PostStatus[];
|
|
18
|
-
/** Whether a value is one of the
|
|
21
|
+
/** Whether a value is one of the kinds, for reading a request body. */
|
|
19
22
|
export declare function isPostKind(v: unknown): v is PostKind;
|
|
23
|
+
/** A review's stars, both ends included. */
|
|
24
|
+
export declare const RATING_MIN = 1;
|
|
25
|
+
export declare const RATING_MAX = 5;
|
|
26
|
+
/** Whether a value is a whole number of stars. */
|
|
27
|
+
export declare function isRating(v: unknown): v is number;
|
|
28
|
+
/**
|
|
29
|
+
* A screenshot, at most this many bytes once decoded. The widget scales a
|
|
30
|
+
* phone screenshot down to well under it; the limit is for scripts.
|
|
31
|
+
*/
|
|
32
|
+
export declare const SHOT_MAX_BYTES = 1000000;
|
|
33
|
+
/** The image types a screenshot may be. No SVG: it can carry script. */
|
|
34
|
+
export declare const SHOT_TYPES: readonly ["image/jpeg", "image/png", "image/webp"];
|
|
35
|
+
export type ShotType = (typeof SHOT_TYPES)[number];
|
|
36
|
+
/** Whether a kind may carry a screenshot. A review is an opinion, not a report. */
|
|
37
|
+
export declare function takesShot(kind: PostKind): boolean;
|
|
20
38
|
/** Whether a value is one of the four states, for reading a request body. */
|
|
21
39
|
export declare function isPostStatus(v: unknown): v is PostStatus;
|
|
40
|
+
/** An update: its title, the lines under it, and how many posts it may say it fixed. */
|
|
41
|
+
export declare const UPDATE_TITLE_MAX = 80;
|
|
42
|
+
export declare const UPDATE_TEXT_MAX = 300;
|
|
43
|
+
export declare const UPDATE_POSTS_MAX = 50;
|
|
44
|
+
/** A version as an app numbers its releases, and a link to a fix. */
|
|
45
|
+
export declare const VERSION_MAX = 24;
|
|
46
|
+
export declare const LINK_MAX = 300;
|
|
47
|
+
/**
|
|
48
|
+
* A version, trimmed: `''` for none, null when it is not one. Letters,
|
|
49
|
+
* digits and `. + _ -`, starting with a letter or a digit, so it reads the
|
|
50
|
+
* same on every card and can never be more than a label.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* cleanVersion(' v1.4.2 ') // → 'v1.4.2'
|
|
54
|
+
* cleanVersion('') // → ''
|
|
55
|
+
* cleanVersion('1.4 beta') // → null
|
|
56
|
+
*/
|
|
57
|
+
export declare function cleanVersion(v: unknown): string | null;
|
|
58
|
+
/**
|
|
59
|
+
* A link to a page on github.com or gitlab.com, as one clean `https://`
|
|
60
|
+
* address: `''` for none, null for anything that is not one.
|
|
61
|
+
*
|
|
62
|
+
* Those two and nothing else, on purpose: a link on a board is something an
|
|
63
|
+
* app's users are invited to tap, and "it goes to the code" is a promise this
|
|
64
|
+
* keeps for every board, whoever runs it. A GitLab on somebody's own server
|
|
65
|
+
* is left out for the same reason: its address could be anything. People
|
|
66
|
+
* paste a link the way an address bar shows it, so a missing `https://` is
|
|
67
|
+
* added and `http://` and `www.` are tidied away. A bare `github.com` is
|
|
68
|
+
* refused: it points at nothing in particular.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* cleanCodeLink('github.com/me/app/pull/42') // → 'https://github.com/me/app/pull/42'
|
|
72
|
+
* cleanCodeLink('gitlab.com/me/app/-/merge_requests/7') // → 'https://gitlab.com/me/app/-/merge_requests/7'
|
|
73
|
+
* cleanCodeLink('https://github.com.evil.example') // → null
|
|
74
|
+
* cleanCodeLink('javascript:alert(1)') // → null
|
|
75
|
+
*/
|
|
76
|
+
export declare function cleanCodeLink(v: unknown): string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Which site a link goes to, by name, for "View on GitHub": null for one
|
|
79
|
+
* {@link cleanCodeLink} would refuse.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* codeSite('https://gitlab.com/me/app/-/releases/v2') // → 'GitLab'
|
|
83
|
+
*/
|
|
84
|
+
export declare function codeSite(link: string): 'GitHub' | 'GitLab' | null;
|
|
85
|
+
/**
|
|
86
|
+
* A fix from a request body, `{ version?, link? }`, cleaned: `{}` when it
|
|
87
|
+
* says nothing, null when either part is not what it claims to be.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* cleanFix({ version: '1.4.2', link: 'github.com/me/app/pull/42' })
|
|
91
|
+
* // → { version: '1.4.2', link: 'https://github.com/me/app/pull/42' }
|
|
92
|
+
*/
|
|
93
|
+
export declare function cleanFix(v: unknown): PostFix | null;
|
|
22
94
|
/**
|
|
23
95
|
* A post's context, cleaned to what the server will store, or null when it is
|
|
24
96
|
* not an object at all.
|
package/dist/rules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
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,CAAC;AAExC,wEAAwE;AACxE,eAAO,MAAM,UAAU,oDAAqD,CAAC;AAC7E,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAEjD;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAExD;AAED,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,qEAAqE;AACrE,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,QAAQ,MAAM,CAAC;AAE5B;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAKtD;AAUD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAgBvD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAIjE;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAOnD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAWtE"}
|
package/dist/rules.js
CHANGED
|
@@ -9,8 +9,15 @@ export const DEFAULT_RULES = Object.freeze({
|
|
|
9
9
|
textMax: 200,
|
|
10
10
|
/** Longer than a post, because the reply is the one that has to explain. */
|
|
11
11
|
replyMax: 300,
|
|
12
|
-
kinds: ['bug', 'idea'],
|
|
12
|
+
kinds: ['bug', 'idea', 'review'],
|
|
13
|
+
screenshots: 'board',
|
|
14
|
+
approve: false,
|
|
13
15
|
});
|
|
16
|
+
export const SHOT_RULES = ['board', 'owners', 'off'];
|
|
17
|
+
/** Whether a value is one of the screenshot rules, for reading a request or a variable. */
|
|
18
|
+
export function isShotRule(v) {
|
|
19
|
+
return typeof v === 'string' && SHOT_RULES.includes(v);
|
|
20
|
+
}
|
|
14
21
|
/** A display name. Long enough for a real one, short enough for a card. */
|
|
15
22
|
export const NAME_MAX = 24;
|
|
16
23
|
/** A client-minted post id. */
|
|
@@ -20,16 +27,139 @@ export const CONTEXT_MAX_KEYS = 10;
|
|
|
20
27
|
export const CONTEXT_VALUE_MAX = 100;
|
|
21
28
|
/** The window `rules.perDay` is counted over. Rolling, never reset at midnight. */
|
|
22
29
|
export const DAY_MS = 24 * 60 * 60 * 1000;
|
|
23
|
-
export const POST_KINDS = ['bug', 'idea'];
|
|
30
|
+
export const POST_KINDS = ['bug', 'idea', 'review'];
|
|
24
31
|
export const POST_STATUSES = ['open', 'planned', 'done', 'declined'];
|
|
25
|
-
/** Whether a value is one of the
|
|
32
|
+
/** Whether a value is one of the kinds, for reading a request body. */
|
|
26
33
|
export function isPostKind(v) {
|
|
27
34
|
return typeof v === 'string' && POST_KINDS.includes(v);
|
|
28
35
|
}
|
|
36
|
+
/** A review's stars, both ends included. */
|
|
37
|
+
export const RATING_MIN = 1;
|
|
38
|
+
export const RATING_MAX = 5;
|
|
39
|
+
/** Whether a value is a whole number of stars. */
|
|
40
|
+
export function isRating(v) {
|
|
41
|
+
return typeof v === 'number' && Number.isInteger(v) && v >= RATING_MIN && v <= RATING_MAX;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A screenshot, at most this many bytes once decoded. The widget scales a
|
|
45
|
+
* phone screenshot down to well under it; the limit is for scripts.
|
|
46
|
+
*/
|
|
47
|
+
export const SHOT_MAX_BYTES = 1_000_000;
|
|
48
|
+
/** The image types a screenshot may be. No SVG: it can carry script. */
|
|
49
|
+
export const SHOT_TYPES = ['image/jpeg', 'image/png', 'image/webp'];
|
|
50
|
+
/** Whether a kind may carry a screenshot. A review is an opinion, not a report. */
|
|
51
|
+
export function takesShot(kind) {
|
|
52
|
+
return kind === 'bug' || kind === 'idea';
|
|
53
|
+
}
|
|
29
54
|
/** Whether a value is one of the four states, for reading a request body. */
|
|
30
55
|
export function isPostStatus(v) {
|
|
31
56
|
return typeof v === 'string' && POST_STATUSES.includes(v);
|
|
32
57
|
}
|
|
58
|
+
/** An update: its title, the lines under it, and how many posts it may say it fixed. */
|
|
59
|
+
export const UPDATE_TITLE_MAX = 80;
|
|
60
|
+
export const UPDATE_TEXT_MAX = 300;
|
|
61
|
+
export const UPDATE_POSTS_MAX = 50;
|
|
62
|
+
/** A version as an app numbers its releases, and a link to a fix. */
|
|
63
|
+
export const VERSION_MAX = 24;
|
|
64
|
+
export const LINK_MAX = 300;
|
|
65
|
+
/**
|
|
66
|
+
* A version, trimmed: `''` for none, null when it is not one. Letters,
|
|
67
|
+
* digits and `. + _ -`, starting with a letter or a digit, so it reads the
|
|
68
|
+
* same on every card and can never be more than a label.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* cleanVersion(' v1.4.2 ') // → 'v1.4.2'
|
|
72
|
+
* cleanVersion('') // → ''
|
|
73
|
+
* cleanVersion('1.4 beta') // → null
|
|
74
|
+
*/
|
|
75
|
+
export function cleanVersion(v) {
|
|
76
|
+
if (typeof v !== 'string')
|
|
77
|
+
return null;
|
|
78
|
+
const s = v.trim();
|
|
79
|
+
if (!s)
|
|
80
|
+
return '';
|
|
81
|
+
return s.length <= VERSION_MAX && /^[0-9A-Za-z][0-9A-Za-z.+_-]*$/.test(s) ? s : null;
|
|
82
|
+
}
|
|
83
|
+
/** The sites a fix or an update may link to, by the host a link names, and the host it is written with. */
|
|
84
|
+
const CODE_SITES = {
|
|
85
|
+
'github.com': 'github.com',
|
|
86
|
+
'www.github.com': 'github.com',
|
|
87
|
+
'gitlab.com': 'gitlab.com',
|
|
88
|
+
'www.gitlab.com': 'gitlab.com',
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* A link to a page on github.com or gitlab.com, as one clean `https://`
|
|
92
|
+
* address: `''` for none, null for anything that is not one.
|
|
93
|
+
*
|
|
94
|
+
* Those two and nothing else, on purpose: a link on a board is something an
|
|
95
|
+
* app's users are invited to tap, and "it goes to the code" is a promise this
|
|
96
|
+
* keeps for every board, whoever runs it. A GitLab on somebody's own server
|
|
97
|
+
* is left out for the same reason: its address could be anything. People
|
|
98
|
+
* paste a link the way an address bar shows it, so a missing `https://` is
|
|
99
|
+
* added and `http://` and `www.` are tidied away. A bare `github.com` is
|
|
100
|
+
* refused: it points at nothing in particular.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* cleanCodeLink('github.com/me/app/pull/42') // → 'https://github.com/me/app/pull/42'
|
|
104
|
+
* cleanCodeLink('gitlab.com/me/app/-/merge_requests/7') // → 'https://gitlab.com/me/app/-/merge_requests/7'
|
|
105
|
+
* cleanCodeLink('https://github.com.evil.example') // → null
|
|
106
|
+
* cleanCodeLink('javascript:alert(1)') // → null
|
|
107
|
+
*/
|
|
108
|
+
export function cleanCodeLink(v) {
|
|
109
|
+
if (typeof v !== 'string')
|
|
110
|
+
return null;
|
|
111
|
+
const s = v.trim();
|
|
112
|
+
if (!s)
|
|
113
|
+
return '';
|
|
114
|
+
if (s.length > LINK_MAX)
|
|
115
|
+
return null;
|
|
116
|
+
let url;
|
|
117
|
+
try {
|
|
118
|
+
url = new URL(/^https?:\/\//i.test(s) ? s : `https://${s}`);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:')
|
|
124
|
+
return null;
|
|
125
|
+
const host = CODE_SITES[url.hostname];
|
|
126
|
+
if (!host)
|
|
127
|
+
return null;
|
|
128
|
+
if (url.username || url.password || url.port || url.pathname.length < 2)
|
|
129
|
+
return null;
|
|
130
|
+
return `https://${host}${url.pathname}${url.search}${url.hash}`;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Which site a link goes to, by name, for "View on GitHub": null for one
|
|
134
|
+
* {@link cleanCodeLink} would refuse.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* codeSite('https://gitlab.com/me/app/-/releases/v2') // → 'GitLab'
|
|
138
|
+
*/
|
|
139
|
+
export function codeSite(link) {
|
|
140
|
+
const clean = cleanCodeLink(link);
|
|
141
|
+
if (!clean)
|
|
142
|
+
return null;
|
|
143
|
+
return clean.startsWith('https://gitlab.com/') ? 'GitLab' : 'GitHub';
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A fix from a request body, `{ version?, link? }`, cleaned: `{}` when it
|
|
147
|
+
* says nothing, null when either part is not what it claims to be.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* cleanFix({ version: '1.4.2', link: 'github.com/me/app/pull/42' })
|
|
151
|
+
* // → { version: '1.4.2', link: 'https://github.com/me/app/pull/42' }
|
|
152
|
+
*/
|
|
153
|
+
export function cleanFix(v) {
|
|
154
|
+
if (!v || typeof v !== 'object' || Array.isArray(v))
|
|
155
|
+
return null;
|
|
156
|
+
const { version, link } = v;
|
|
157
|
+
const ver = version === undefined ? '' : cleanVersion(version);
|
|
158
|
+
const url = link === undefined ? '' : cleanCodeLink(link);
|
|
159
|
+
if (ver === null || url === null)
|
|
160
|
+
return null;
|
|
161
|
+
return { ...(ver ? { version: ver } : {}), ...(url ? { link: url } : {}) };
|
|
162
|
+
}
|
|
33
163
|
/**
|
|
34
164
|
* A post's context, cleaned to what the server will store, or null when it is
|
|
35
165
|
* not an object at all.
|
package/dist/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.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AAI;QAAE,OAAO,IAAI,CAAC;IAC9C,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC7E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,CAAU;IACrC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACjE,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC,IAAI,gBAAgB;YAAE,MAAM;QACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,EAAE;YAAE,SAAS;QACnE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC7C,CAAC,EAAE,CAAC;IACN,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/thread.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Message, PostKind, PostReply, PostStatus } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The rules of the conversation under a post, in one place, so the server
|
|
4
|
+
* that enforces them and the widget that draws them can never disagree about
|
|
5
|
+
* whose turn it is.
|
|
6
|
+
*
|
|
7
|
+
* A hidden message does not count. To everybody but the owners it is not
|
|
8
|
+
* there, so counting it would leave its author staring at a conversation that
|
|
9
|
+
* ends with the app's question and no way to answer it.
|
|
10
|
+
*/
|
|
11
|
+
/** Whether a kind has a conversation the author can join. A review gets the app's answer and nothing back. */
|
|
12
|
+
export declare function takesAnswers(kind: PostKind): boolean;
|
|
13
|
+
/** Whether a status closes the conversation for the author: it is done, or will not be. */
|
|
14
|
+
export declare function isClosed(status: PostStatus): boolean;
|
|
15
|
+
/** The messages everybody sees, in order. */
|
|
16
|
+
export declare function shownThread(thread: Message[] | undefined): Message[];
|
|
17
|
+
/** The last message everybody sees, or undefined before anybody wrote. */
|
|
18
|
+
export declare function lastWord(thread: Message[] | undefined): Message | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the author may write under their post now: a bug or an idea that
|
|
21
|
+
* is still open or planned, right after a message from the app.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* authorMayAnswer({ kind: 'bug', status: 'open', thread: [{ from: 'app', … }] }) // → true
|
|
25
|
+
* authorMayAnswer({ kind: 'bug', status: 'open', thread: [{ from: 'author', … }] }) // → false, the app is next
|
|
26
|
+
*/
|
|
27
|
+
export declare function authorMayAnswer(post: {
|
|
28
|
+
kind: PostKind;
|
|
29
|
+
status: PostStatus;
|
|
30
|
+
thread?: Message[];
|
|
31
|
+
}): boolean;
|
|
32
|
+
/** Whether the author answered and the app has not said anything since: what "New answer" means to an owner. */
|
|
33
|
+
export declare function waitingOnApp(post: {
|
|
34
|
+
thread?: Message[];
|
|
35
|
+
}): boolean;
|
|
36
|
+
/** The app's latest message as the one reply widgets from before conversations read, or undefined. */
|
|
37
|
+
export declare function latestReply(thread: Message[] | undefined): PostReply | undefined;
|
|
38
|
+
//# sourceMappingURL=thread.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../src/thread.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE3E;;;;;;;;GAQG;AAEH,8GAA8G;AAC9G,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAEpD;AAED,2FAA2F;AAC3F,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAEpD;AAED,6CAA6C;AAC7C,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE,CAEpE;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAG3E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG,OAAO,CAEzG;AAED,gHAAgH;AAChH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG,OAAO,CAElE;AAED,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAIhF"}
|
package/dist/thread.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules of the conversation under a post, in one place, so the server
|
|
3
|
+
* that enforces them and the widget that draws them can never disagree about
|
|
4
|
+
* whose turn it is.
|
|
5
|
+
*
|
|
6
|
+
* A hidden message does not count. To everybody but the owners it is not
|
|
7
|
+
* there, so counting it would leave its author staring at a conversation that
|
|
8
|
+
* ends with the app's question and no way to answer it.
|
|
9
|
+
*/
|
|
10
|
+
/** Whether a kind has a conversation the author can join. A review gets the app's answer and nothing back. */
|
|
11
|
+
export function takesAnswers(kind) {
|
|
12
|
+
return kind === 'bug' || kind === 'idea';
|
|
13
|
+
}
|
|
14
|
+
/** Whether a status closes the conversation for the author: it is done, or will not be. */
|
|
15
|
+
export function isClosed(status) {
|
|
16
|
+
return status === 'done' || status === 'declined';
|
|
17
|
+
}
|
|
18
|
+
/** The messages everybody sees, in order. */
|
|
19
|
+
export function shownThread(thread) {
|
|
20
|
+
return (thread ?? []).filter((m) => !m.hidden);
|
|
21
|
+
}
|
|
22
|
+
/** The last message everybody sees, or undefined before anybody wrote. */
|
|
23
|
+
export function lastWord(thread) {
|
|
24
|
+
const shown = shownThread(thread);
|
|
25
|
+
return shown[shown.length - 1];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether the author may write under their post now: a bug or an idea that
|
|
29
|
+
* is still open or planned, right after a message from the app.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* authorMayAnswer({ kind: 'bug', status: 'open', thread: [{ from: 'app', … }] }) // → true
|
|
33
|
+
* authorMayAnswer({ kind: 'bug', status: 'open', thread: [{ from: 'author', … }] }) // → false, the app is next
|
|
34
|
+
*/
|
|
35
|
+
export function authorMayAnswer(post) {
|
|
36
|
+
return takesAnswers(post.kind) && !isClosed(post.status) && lastWord(post.thread)?.from === 'app';
|
|
37
|
+
}
|
|
38
|
+
/** Whether the author answered and the app has not said anything since: what "New answer" means to an owner. */
|
|
39
|
+
export function waitingOnApp(post) {
|
|
40
|
+
return lastWord(post.thread)?.from === 'author';
|
|
41
|
+
}
|
|
42
|
+
/** The app's latest message as the one reply widgets from before conversations read, or undefined. */
|
|
43
|
+
export function latestReply(thread) {
|
|
44
|
+
const app = shownThread(thread).filter((m) => m.from === 'app');
|
|
45
|
+
const last = app[app.length - 1];
|
|
46
|
+
return last ? { text: last.text, at: last.at } : undefined;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=thread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread.js","sourceRoot":"","sources":["../src/thread.ts"],"names":[],"mappings":"AAEA;;;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GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
* is a v2. Clients must ignore fields they do not know, which is what lets the
|
|
7
7
|
* server add one without breaking an app nobody has updated.
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Something is broken, something is missing, or what somebody thinks of the
|
|
11
|
+
* app as it is. A review carries a `rating` and is the one kind that is not a
|
|
12
|
+
* request: nothing gets planned or fixed, so it never gets a status.
|
|
13
|
+
*/
|
|
14
|
+
export type PostKind = 'bug' | 'idea' | 'review';
|
|
11
15
|
/**
|
|
12
16
|
* Where a post stands, set by a project's owners and nobody else.
|
|
13
17
|
*
|
|
@@ -16,11 +20,53 @@ export type PostKind = 'bug' | 'idea';
|
|
|
16
20
|
* nothing was ever answered.
|
|
17
21
|
*/
|
|
18
22
|
export type PostStatus = 'open' | 'planned' | 'done' | 'declined';
|
|
19
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The app's latest message under a post, for widgets from before
|
|
25
|
+
* conversations: they read this and nothing else. The whole conversation is
|
|
26
|
+
* `thread`.
|
|
27
|
+
*/
|
|
20
28
|
export interface PostReply {
|
|
21
29
|
text: string;
|
|
22
30
|
at: number;
|
|
23
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Who wrote a message under a post: the app (one of the project's owners,
|
|
34
|
+
* speaking for it) or whoever wrote the post.
|
|
35
|
+
*/
|
|
36
|
+
export type MessageFrom = 'app' | 'author';
|
|
37
|
+
/**
|
|
38
|
+
* One message in the conversation under a bug or an idea.
|
|
39
|
+
*
|
|
40
|
+
* The turns are the point: the app may write whenever it likes, the author
|
|
41
|
+
* only right after the app said something. So a conversation is always the
|
|
42
|
+
* app asking and the author answering, and never somebody talking to a wall.
|
|
43
|
+
*/
|
|
44
|
+
export interface Message {
|
|
45
|
+
/** Minted by whoever sends it, so a retry is recognised. */
|
|
46
|
+
id: string;
|
|
47
|
+
from: MessageFrom;
|
|
48
|
+
text: string;
|
|
49
|
+
at: number;
|
|
50
|
+
/** When it was last changed, if it was. Only ever the last message, before anybody answered it. */
|
|
51
|
+
edited?: number;
|
|
52
|
+
/** Owners only: an author's message an owner took off the board. */
|
|
53
|
+
hidden?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Where a fix can be found, set by an owner on a bug or an idea they marked
|
|
57
|
+
* done: the version it shipped in, and the page on GitHub or GitLab that
|
|
58
|
+
* shows it. Both optional, and gone as soon as the post stands anywhere but
|
|
59
|
+
* done.
|
|
60
|
+
*
|
|
61
|
+
* github.com and gitlab.com and nothing else, so a link on somebody's board
|
|
62
|
+
* always goes where it says it goes (see `cleanCodeLink`).
|
|
63
|
+
*/
|
|
64
|
+
export interface PostFix {
|
|
65
|
+
/** As the app numbers its releases: `1.4.2`, `v2.0-beta`. */
|
|
66
|
+
version?: string;
|
|
67
|
+
/** A page on github.com or gitlab.com: a commit, a pull request or a release. */
|
|
68
|
+
link?: string;
|
|
69
|
+
}
|
|
24
70
|
/**
|
|
25
71
|
* Free-form detail for reproducing a bug: an app version, a screen, whether
|
|
26
72
|
* the user was inside Nimiq Pay. Owners' eyes only.
|
|
@@ -29,6 +75,23 @@ export interface PostReply {
|
|
|
29
75
|
* become a place to stash anything bigger than a label.
|
|
30
76
|
*/
|
|
31
77
|
export type PostContext = Record<string, string>;
|
|
78
|
+
/**
|
|
79
|
+
* Who sees a post's screenshot.
|
|
80
|
+
*
|
|
81
|
+
* - `board`: everybody who reads the board. Only ever because its author
|
|
82
|
+
* ticked that everyone may see it.
|
|
83
|
+
* - `off`: the author agreed, but an owner took it off the board. Owners can
|
|
84
|
+
* put it back.
|
|
85
|
+
* - `owners`: the author never agreed, so owners only, for good. Nobody can
|
|
86
|
+
* turn it into `board` later; that would be a promise broken after the fact.
|
|
87
|
+
*/
|
|
88
|
+
export type ShotFor = 'board' | 'off' | 'owners';
|
|
89
|
+
/**
|
|
90
|
+
* What a board allows screenshots to be, whatever the widget asks:
|
|
91
|
+
* `board` (the author may put one on the board), `owners` (only ever for the
|
|
92
|
+
* owners) or `off` (none at all).
|
|
93
|
+
*/
|
|
94
|
+
export type ShotRule = 'board' | 'owners' | 'off';
|
|
32
95
|
/**
|
|
33
96
|
* One post, as a reader receives it.
|
|
34
97
|
*
|
|
@@ -51,11 +114,29 @@ export interface Post {
|
|
|
51
114
|
/** The author's display name. Absent when they posted anonymously or never
|
|
52
115
|
* chose one. Never an address: a name is a label, an address an identity. */
|
|
53
116
|
who?: string;
|
|
117
|
+
/** The app's latest message, for widgets from before `thread`. */
|
|
54
118
|
reply?: PostReply;
|
|
119
|
+
/**
|
|
120
|
+
* The conversation under it, oldest first. Absent until somebody wrote.
|
|
121
|
+
* Hidden messages reach owners only, marked.
|
|
122
|
+
*/
|
|
123
|
+
thread?: Message[];
|
|
124
|
+
/** A done bug or idea only: where the fix is. Sent to everybody. */
|
|
125
|
+
fix?: PostFix;
|
|
126
|
+
/** Reviews only: 1 to 5 stars. */
|
|
127
|
+
rating?: number;
|
|
55
128
|
/** Owners only. */
|
|
56
129
|
context?: PostContext;
|
|
130
|
+
/** A screenshot comes with it, read through the post's `/shot` route. Sent
|
|
131
|
+
* to everybody for one on the board, and to owners for any. */
|
|
132
|
+
shot?: boolean;
|
|
133
|
+
/** Owners only, with `shot`: who sees it. */
|
|
134
|
+
shotFor?: ShotFor;
|
|
57
135
|
/** Owners only: a post they took off the board, kept so it can come back. */
|
|
58
136
|
hidden?: boolean;
|
|
137
|
+
/** Waiting for an owner to approve it, on a board with `rules.approve`.
|
|
138
|
+
* Only its author and the owners see it until then. */
|
|
139
|
+
pending?: boolean;
|
|
59
140
|
}
|
|
60
141
|
/** A project's limits. Defaults in `DEFAULT_RULES`. */
|
|
61
142
|
export interface Rules {
|
|
@@ -66,6 +147,16 @@ export interface Rules {
|
|
|
66
147
|
replyMax: number;
|
|
67
148
|
/** Which kinds this board accepts, in the order the widget offers them. */
|
|
68
149
|
kinds: PostKind[];
|
|
150
|
+
/**
|
|
151
|
+
* What screenshots may be on this board, enforced by the server whatever a
|
|
152
|
+
* widget sends. Absent on projects made before 0.2.0, which means `board`.
|
|
153
|
+
*/
|
|
154
|
+
screenshots?: ShotRule;
|
|
155
|
+
/**
|
|
156
|
+
* Whether a new post waits for an owner's approval before anybody else sees
|
|
157
|
+
* it. For a board on a public page. Absent means no.
|
|
158
|
+
*/
|
|
159
|
+
approve?: boolean;
|
|
69
160
|
}
|
|
70
161
|
/** What anybody may know about a project. */
|
|
71
162
|
export interface PublicProject {
|
|
@@ -105,12 +196,46 @@ export interface BoardRead {
|
|
|
105
196
|
posts: Post[];
|
|
106
197
|
/** Present only when the request carried a valid proof. */
|
|
107
198
|
me?: Me;
|
|
199
|
+
/**
|
|
200
|
+
* How many updates the project has written, when it has any, so a widget
|
|
201
|
+
* can offer the Updates page without reading it first.
|
|
202
|
+
*/
|
|
203
|
+
updates?: number;
|
|
108
204
|
}
|
|
109
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* One of your own posts that an owner has answered. `at` is when. Where it
|
|
207
|
+
* stands and its fix come along, so an app can say "fixed in 1.4.2" rather
|
|
208
|
+
* than only that there is news.
|
|
209
|
+
*/
|
|
110
210
|
export interface Answer {
|
|
111
211
|
id: string;
|
|
112
212
|
text: string;
|
|
113
213
|
at: number;
|
|
214
|
+
status?: PostStatus;
|
|
215
|
+
fix?: PostFix;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* What changed in the app, written by an owner for the Updates page. Anybody
|
|
219
|
+
* may read a project's updates, signed in or not, like the board.
|
|
220
|
+
*
|
|
221
|
+
* Every update has a link, because what the page is for is getting from "it
|
|
222
|
+
* changed" to the change itself, on GitHub or GitLab, in one tap.
|
|
223
|
+
*/
|
|
224
|
+
export interface Update {
|
|
225
|
+
id: string;
|
|
226
|
+
title: string;
|
|
227
|
+
/** A few lines on what changed. */
|
|
228
|
+
text?: string;
|
|
229
|
+
version?: string;
|
|
230
|
+
/** A page on github.com or gitlab.com. */
|
|
231
|
+
link: string;
|
|
232
|
+
at: number;
|
|
233
|
+
/**
|
|
234
|
+
* The bugs and ideas on the board it fixed or built, as post ids. Each was
|
|
235
|
+
* marked done with this update's version and link when it was written. Only
|
|
236
|
+
* those still on the board are sent.
|
|
237
|
+
*/
|
|
238
|
+
posts: string[];
|
|
114
239
|
}
|
|
115
240
|
/**
|
|
116
241
|
* Who is asking, sent base64url-encoded in `Authorization: Nimiq <...>`.
|
|
@@ -146,5 +271,5 @@ export interface AppLogin {
|
|
|
146
271
|
message: string;
|
|
147
272
|
}
|
|
148
273
|
/** Every error the API answers with, as `{ error: ErrorCode }`. */
|
|
149
|
-
export type ErrorCode = 'bad_request' | 'unauthorized' | 'not_yours' | 'not_owner' | 'origin_not_allowed' | 'no_project' | 'no_post' | 'duplicate' | 'too_many' | 'rate_limited' | 'not_found' | 'internal';
|
|
274
|
+
export type ErrorCode = 'bad_request' | 'unauthorized' | 'not_yours' | 'not_owner' | 'origin_not_allowed' | 'no_project' | 'no_post' | 'no_update' | 'duplicate' | 'reviewed' | 'not_your_turn' | 'closed' | 'too_many' | 'rate_limited' | 'not_found' | 'internal';
|
|
150
275
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,MAAM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