@pleasenobugs/server 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/README.md +6 -1
- package/dist/board.d.ts +2 -2
- package/dist/board.d.ts.map +1 -1
- package/dist/board.js +29 -3
- package/dist/board.js.map +1 -1
- package/dist/bootstrap.d.ts +3 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +27 -4
- package/dist/bootstrap.js.map +1 -1
- package/dist/importer.d.ts +3 -0
- package/dist/importer.d.ts.map +1 -1
- package/dist/importer.js +11 -5
- package/dist/importer.js.map +1 -1
- package/dist/limit.d.ts.map +1 -1
- package/dist/limit.js +6 -2
- package/dist/limit.js.map +1 -1
- package/dist/main.js +23 -7
- package/dist/main.js.map +1 -1
- package/dist/memory-store.d.ts +21 -3
- package/dist/memory-store.d.ts.map +1 -1
- package/dist/memory-store.js +84 -8
- package/dist/memory-store.js.map +1 -1
- package/dist/projects.d.ts +2 -0
- package/dist/projects.d.ts.map +1 -1
- package/dist/projects.js +12 -2
- package/dist/projects.js.map +1 -1
- package/dist/router.d.ts +6 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +420 -13
- package/dist/router.js.map +1 -1
- package/dist/sqlite-store.d.ts +18 -3
- package/dist/sqlite-store.d.ts.map +1 -1
- package/dist/sqlite-store.js +193 -15
- package/dist/sqlite-store.js.map +1 -1
- package/dist/store.d.ts +66 -11
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +4 -1
- package/dist/store.js.map +1 -1
- package/package.json +2 -2
package/dist/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Answer, PostContext,
|
|
1
|
+
import type { Answer, Message, PostContext, PostFix, PostKind, PostStatus, Project, ShotFor, ShotType, Update } from '@pleasenobugs/core';
|
|
2
2
|
/**
|
|
3
3
|
* Where a board keeps its rows, behind one interface so the same server runs on
|
|
4
4
|
* an in-memory map, an SQLite file or Postgres.
|
|
@@ -27,13 +27,21 @@ export interface PostRow {
|
|
|
27
27
|
text: string;
|
|
28
28
|
at: number;
|
|
29
29
|
status: PostStatus;
|
|
30
|
-
|
|
30
|
+
/** The conversation under it, oldest first, hidden messages included. Changed only through {@link Store.setThread}. */
|
|
31
|
+
thread?: Message[];
|
|
32
|
+
/** Done bugs and ideas only. */
|
|
33
|
+
fix?: PostFix;
|
|
31
34
|
hidden?: boolean;
|
|
35
|
+
/** Waiting for an owner's approval: its author and the owners see it, nobody else. */
|
|
36
|
+
pending?: boolean;
|
|
32
37
|
context?: PostContext;
|
|
38
|
+
/** Reviews only. */
|
|
39
|
+
rating?: number;
|
|
33
40
|
/**
|
|
34
41
|
* When an owner last set a status on it or wrote under it. Its own field
|
|
35
|
-
* rather than `
|
|
36
|
-
* answer too. Nothing else touches it, so a vote cannot lift
|
|
42
|
+
* rather than the last message's `at`, because a status moved with nothing
|
|
43
|
+
* written is an answer too. Nothing else touches it, so a vote cannot lift
|
|
44
|
+
* somebody's news, and neither can the author's own answer.
|
|
37
45
|
*/
|
|
38
46
|
answeredAt?: number;
|
|
39
47
|
}
|
|
@@ -41,15 +49,38 @@ export interface PostRow {
|
|
|
41
49
|
export interface PostWithVotes extends PostRow {
|
|
42
50
|
votes: number;
|
|
43
51
|
voted: boolean;
|
|
52
|
+
/** Who sees its screenshot, when it has one. */
|
|
53
|
+
shot?: ShotFor;
|
|
44
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* A screenshot, kept apart from its post so reading a board never loads one.
|
|
57
|
+
* Gone with the post (see `deletePost`).
|
|
58
|
+
*/
|
|
59
|
+
export interface Shot {
|
|
60
|
+
type: ShotType;
|
|
61
|
+
data: Uint8Array;
|
|
62
|
+
/**
|
|
63
|
+
* Whether its author agreed to everyone seeing it. Stored once and never
|
|
64
|
+
* changed: without it the screenshot is the owners' alone, whatever happens
|
|
65
|
+
* later. An owner taking it off the board is a separate flag.
|
|
66
|
+
*/
|
|
67
|
+
board: boolean;
|
|
68
|
+
}
|
|
69
|
+
/** A stored screenshot, with who sees it now. */
|
|
70
|
+
export interface StoredShot extends Shot {
|
|
71
|
+
for: ShotFor;
|
|
72
|
+
}
|
|
73
|
+
/** Who sees a screenshot, from what its author agreed to and what an owner did. */
|
|
74
|
+
export declare function shotFor(board: boolean, off: boolean): ShotFor;
|
|
45
75
|
/** What `updatePost` may change. `null` removes a field. */
|
|
46
76
|
export interface PostPatch {
|
|
47
77
|
status?: PostStatus;
|
|
48
|
-
|
|
78
|
+
fix?: PostFix | null;
|
|
49
79
|
hidden?: boolean;
|
|
80
|
+
pending?: boolean;
|
|
50
81
|
answeredAt?: number;
|
|
51
82
|
}
|
|
52
|
-
/** How much one board has had, for telemetry. Hidden posts are not counted. */
|
|
83
|
+
/** How much one board has had, for telemetry. Hidden posts, and those still waiting for approval, are not counted. */
|
|
53
84
|
export interface ProjectStats {
|
|
54
85
|
bugs: number;
|
|
55
86
|
ideas: number;
|
|
@@ -84,21 +115,45 @@ export interface Store {
|
|
|
84
115
|
getPost(projectId: string, id: string): Promise<PostRow | null>;
|
|
85
116
|
/**
|
|
86
117
|
* Write a new post **and the author's own vote** in one step, since the
|
|
87
|
-
* number means "how many want this" and the author is one of them
|
|
88
|
-
* Answers false, writing nothing, when the id is
|
|
118
|
+
* number means "how many want this" and the author is one of them, plus its
|
|
119
|
+
* screenshot if it has one. Answers false, writing nothing, when the id is
|
|
120
|
+
* taken.
|
|
89
121
|
*/
|
|
90
|
-
createPost(row: PostRow): Promise<boolean>;
|
|
122
|
+
createPost(row: PostRow, shot?: Shot): Promise<boolean>;
|
|
91
123
|
updatePost(projectId: string, id: string, patch: PostPatch): Promise<void>;
|
|
92
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* Replace a post's conversation, **only if it still is `prev`**, and answer
|
|
126
|
+
* whether it did. The router decides whose turn it is from what it read;
|
|
127
|
+
* this makes sure nothing was said in between, so two answers sent at once
|
|
128
|
+
* can never both land after the same question. Empty `next` removes it.
|
|
129
|
+
*/
|
|
130
|
+
setThread(projectId: string, id: string, next: Message[], prev: Message[]): Promise<boolean>;
|
|
131
|
+
/** Removes the post, its votes and its screenshot. */
|
|
93
132
|
deletePost(projectId: string, id: string): Promise<void>;
|
|
133
|
+
getShot(projectId: string, postId: string): Promise<StoredShot | null>;
|
|
134
|
+
/**
|
|
135
|
+
* An owner takes a screenshot off the board, or puts it back. Putting back
|
|
136
|
+
* does nothing to one its author never agreed to show: that stays `owners`.
|
|
137
|
+
*/
|
|
138
|
+
setShotOff(projectId: string, postId: string, off: boolean): Promise<void>;
|
|
139
|
+
/** Removes a post's screenshot and nothing else. */
|
|
140
|
+
deleteShot(projectId: string, postId: string): Promise<void>;
|
|
141
|
+
/** Whether this wallet has a post of this kind on this board, hidden ones included. */
|
|
142
|
+
hasPostOfKind(projectId: string, author: string, kind: PostKind): Promise<boolean>;
|
|
94
143
|
/** Add or remove one wallet's vote, atomically. Answers the new count. */
|
|
95
144
|
vote(projectId: string, id: string, voter: string, up: boolean): Promise<number>;
|
|
96
145
|
/** How many posts this wallet wrote on this board after `since`. */
|
|
97
146
|
countByAuthorSince(projectId: string, author: string, since: number): Promise<number>;
|
|
98
147
|
/** How many posts anybody wrote on this board after `since`. */
|
|
99
148
|
countSince(projectId: string, since: number): Promise<number>;
|
|
100
|
-
/** This wallet's answered posts, newest answer first. */
|
|
149
|
+
/** This wallet's answered posts, newest answer first, with where each stands and its fix. */
|
|
101
150
|
answersFor(projectId: string, author: string, limit: number): Promise<Answer[]>;
|
|
151
|
+
/** A board's updates, newest first, each with every post id it was written with. */
|
|
152
|
+
updates(projectId: string): Promise<Update[]>;
|
|
153
|
+
/** Answers false, writing nothing, when the id is taken. */
|
|
154
|
+
createUpdate(projectId: string, update: Update): Promise<boolean>;
|
|
155
|
+
/** Answers whether there was one. The posts it fixed keep their status and fix. */
|
|
156
|
+
deleteUpdate(projectId: string, id: string): Promise<boolean>;
|
|
102
157
|
names(projectId: string, addresses: string[]): Promise<Map<string, string>>;
|
|
103
158
|
/** Empty or undefined clears it. */
|
|
104
159
|
setName(projectId: string, address: string, name: string | undefined): Promise<void>;
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,WAAW,EACX,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,OAAO,EACP,WAAW,EACX,OAAO,EACP,QAAQ,EACR,UAAU,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,MAAM,EACP,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;GAgBG;AAEH,0EAA0E;AAC1E,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;IACnB,uHAAuH;IACvH,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,gCAAgC;IAChC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sFAAsF;IACtF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,0EAA0E;AAC1E,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C,KAAK,EAAE,MAAM,CAAC;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A4D;IAC5D,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,mFAAmF;IACnF,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAG9D,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5E,oCAAoC;IACpC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGrF,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3D,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE"}
|
package/dist/store.js
CHANGED
package/dist/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAyFA,mFAAmF;AACnF,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,GAAY;IAClD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AACnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pleasenobugs/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The PleaseNoBugs API: a feedback board for Nimiq mini apps, with pluggable storage.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@nimiq/core": "^2.7.1",
|
|
46
|
-
"@pleasenobugs/core": "0.
|
|
46
|
+
"@pleasenobugs/core": "0.3.0",
|
|
47
47
|
"cors": "^2.8.5",
|
|
48
48
|
"express": "^4.21.2"
|
|
49
49
|
},
|