firstly 0.9.2 → 0.9.3
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# firstly
|
|
2
2
|
|
|
3
|
+
## 0.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#349](https://github.com/jycouet/firstly/pull/349) [`b285731`](https://github.com/jycouet/firstly/commit/b285731fe8e6cd41e5a257a044524486319e5544) Thanks [@jycouet](https://github.com/jycouet)! - feedback: `getIssues` now returns `labels` (names), `createdAt` and `updatedAt` per issue; `createIssue` accepts an optional `labels: string[]` applied on top of `create_label`.
|
|
8
|
+
|
|
9
|
+
- [#351](https://github.com/jycouet/firstly/pull/351) [`9701c40`](https://github.com/jycouet/firstly/commit/9701c404c7c2e6e2f94a7e3eab536b6a55d0c9c2) Thanks [@jycouet](https://github.com/jycouet)! - `withShortTermCache`: mutations (POST writes, PUT, PATCH, DELETE) now clear the cache once they settle, so a follow-up refresh no longer serves the pre-mutation read.
|
|
10
|
+
|
|
3
11
|
## 0.9.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -28,7 +28,8 @@ export type ShortTermCacheOptions = {
|
|
|
28
28
|
* Middleware that dedupes identical read requests within a short TTL - a tiny
|
|
29
29
|
* client-side cache. Two components mounting and issuing the same query result in
|
|
30
30
|
* ONE network call; each caller gets its own `Response` clone. Failed requests are
|
|
31
|
-
* evicted immediately so the next call retries.
|
|
31
|
+
* evicted immediately so the next call retries. Any mutation (non-GET that isn't a
|
|
32
|
+
* cached read) clears the cache once it settles, so a follow-up refresh sees fresh data.
|
|
32
33
|
*
|
|
33
34
|
* ```ts
|
|
34
35
|
* remult.apiClient.httpClient = stackHttpClient(withShortTermCache({ ttlMs: 2000 }))
|
|
@@ -26,7 +26,8 @@ const defaultShouldCache = (_input, init, key) => {
|
|
|
26
26
|
* Middleware that dedupes identical read requests within a short TTL - a tiny
|
|
27
27
|
* client-side cache. Two components mounting and issuing the same query result in
|
|
28
28
|
* ONE network call; each caller gets its own `Response` clone. Failed requests are
|
|
29
|
-
* evicted immediately so the next call retries.
|
|
29
|
+
* evicted immediately so the next call retries. Any mutation (non-GET that isn't a
|
|
30
|
+
* cached read) clears the cache once it settles, so a follow-up refresh sees fresh data.
|
|
30
31
|
*
|
|
31
32
|
* ```ts
|
|
32
33
|
* remult.apiClient.httpClient = stackHttpClient(withShortTermCache({ ttlMs: 2000 }))
|
|
@@ -48,7 +49,18 @@ export function withShortTermCache(opts = {}) {
|
|
|
48
49
|
cacheKey = `${cacheKey}:${bodyStr}`;
|
|
49
50
|
}
|
|
50
51
|
if (!shouldCache(input, init, cacheKey)) {
|
|
51
|
-
|
|
52
|
+
const method = init?.method?.toUpperCase() ?? 'GET';
|
|
53
|
+
if (method === 'GET')
|
|
54
|
+
return next(input, init);
|
|
55
|
+
// Mutation: drop cached reads once it settles (not before, so a read racing the
|
|
56
|
+
// write can't re-cache pre-mutation data). Cleared on error too: the server may
|
|
57
|
+
// have partially mutated.
|
|
58
|
+
try {
|
|
59
|
+
return await next(input, init);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
cache.clear();
|
|
63
|
+
}
|
|
52
64
|
}
|
|
53
65
|
const now = Date.now();
|
|
54
66
|
const cached = cache.get(cacheKey);
|
|
@@ -9,6 +9,10 @@ export declare class FeedbackController {
|
|
|
9
9
|
number: number;
|
|
10
10
|
titleHTML: string;
|
|
11
11
|
state: string;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
/** GitHub label names. */
|
|
15
|
+
labels: string[];
|
|
12
16
|
highlight: boolean;
|
|
13
17
|
}[]>;
|
|
14
18
|
static getIssue(issueNumber: number): Promise<{
|
|
@@ -27,7 +31,9 @@ export declare class FeedbackController {
|
|
|
27
31
|
}>;
|
|
28
32
|
static createIssue(milestoneId: string, title: string, body: string, metadata: {
|
|
29
33
|
page: string;
|
|
30
|
-
}
|
|
34
|
+
},
|
|
35
|
+
/** Extra label names applied on top of `create_label` (unknown names are ignored). */
|
|
36
|
+
labels?: string[]): Promise<{
|
|
31
37
|
id: string;
|
|
32
38
|
number: number;
|
|
33
39
|
}>;
|
|
@@ -121,6 +121,8 @@ export class FeedbackController {
|
|
|
121
121
|
number
|
|
122
122
|
titleHTML
|
|
123
123
|
state
|
|
124
|
+
createdAt
|
|
125
|
+
updatedAt
|
|
124
126
|
labels(first:10){
|
|
125
127
|
nodes {
|
|
126
128
|
name
|
|
@@ -142,14 +144,18 @@ export class FeedbackController {
|
|
|
142
144
|
issueOrder,
|
|
143
145
|
});
|
|
144
146
|
return data.repository.milestone.issues.nodes.map((issue) => {
|
|
147
|
+
const labels = issue.labels.nodes.map((label) => label.name);
|
|
145
148
|
const hasWaitingForAnswerLabel = remult.context.feedbackOptions.highlight_label
|
|
146
|
-
?
|
|
149
|
+
? labels.some((name) => name.includes(remult.context.feedbackOptions.highlight_label))
|
|
147
150
|
: false;
|
|
148
151
|
return {
|
|
149
152
|
id: issue.id,
|
|
150
153
|
number: issue.number,
|
|
151
154
|
titleHTML: issue.titleHTML,
|
|
152
155
|
state: issue.state,
|
|
156
|
+
createdAt: issue.createdAt,
|
|
157
|
+
updatedAt: issue.updatedAt,
|
|
158
|
+
labels,
|
|
153
159
|
highlight: hasWaitingForAnswerLabel,
|
|
154
160
|
};
|
|
155
161
|
});
|
|
@@ -231,7 +237,9 @@ repository(name: $repository, owner: $owner) {
|
|
|
231
237
|
};
|
|
232
238
|
return toRet;
|
|
233
239
|
}
|
|
234
|
-
static async createIssue(milestoneId, title, body, metadata
|
|
240
|
+
static async createIssue(milestoneId, title, body, metadata,
|
|
241
|
+
/** Extra label names applied on top of `create_label` (unknown names are ignored). */
|
|
242
|
+
labels = []) {
|
|
235
243
|
const repoInfo = await getGitHub(`query RepoInfo(
|
|
236
244
|
$repository: String!
|
|
237
245
|
$owner: String!
|
|
@@ -250,7 +258,8 @@ repository(name: $repository, owner: $owner) {
|
|
|
250
258
|
owner: remult.context.feedbackOptions.repo.owner,
|
|
251
259
|
});
|
|
252
260
|
const repoInfoData = repoInfo.repository;
|
|
253
|
-
const
|
|
261
|
+
const wanted = new Set([remult.context.feedbackOptions.create_label, ...labels]);
|
|
262
|
+
const labelIds = repoInfoData.labels.nodes.filter((c) => wanted.has(c.name)).map((c) => c.id);
|
|
254
263
|
const newIssue = await getGitHub(`mutation CreateIssue($input: CreateIssueInput!) {
|
|
255
264
|
createIssue(input: $input) {
|
|
256
265
|
issue {
|
|
@@ -263,7 +272,7 @@ repository(name: $repository, owner: $owner) {
|
|
|
263
272
|
input: {
|
|
264
273
|
repositoryId: repoInfoData.id,
|
|
265
274
|
milestoneId: milestoneId,
|
|
266
|
-
labelIds
|
|
275
|
+
labelIds,
|
|
267
276
|
title: title ?? 'New Feedback (wo title...)',
|
|
268
277
|
body: body,
|
|
269
278
|
},
|