firstly 0.10.4 → 0.10.6

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.
@@ -66,319 +66,340 @@ async function addMetaData(issueId, obj) {
66
66
  }
67
67
  export class FeedbackController {
68
68
  static async getMilestones() {
69
- const data = await getGitHub(`query Milestones(
70
- $repository: String!
71
- $owner: String!
72
- $filter: String
73
- $take: Int = 25
74
- $cursor: String
75
- ) {
76
- repository(name: $repository, owner: $owner) {
77
- milestones(query: $filter, last: $take, after: $cursor, states: OPEN) {
78
- pageInfo {
79
- endCursor
80
- }
81
- nodes {
82
- id
83
- number
84
- title
85
- }
69
+ if (import.meta.env.SSR) {
70
+ const data = await getGitHub(`query Milestones(
71
+ $repository: String!
72
+ $owner: String!
73
+ $filter: String
74
+ $take: Int = 25
75
+ $cursor: String
76
+ ) {
77
+ repository(name: $repository, owner: $owner) {
78
+ milestones(query: $filter, last: $take, after: $cursor, states: OPEN) {
79
+ pageInfo {
80
+ endCursor
81
+ }
82
+ nodes {
83
+ id
84
+ number
85
+ title
86
+ }
87
+ }
88
+ }
89
+ }
90
+ `, {
91
+ repository: remult.context.feedbackOptions.repo.name,
92
+ owner: remult.context.feedbackOptions.repo.owner,
93
+ filter: remult.context.feedbackOptions.milestones?.title_filter ?? '',
94
+ });
95
+ return data.repository.milestones.nodes.map((c) => {
96
+ return {
97
+ ...c,
98
+ title: c.title
99
+ .replaceAll(remult.context.feedbackOptions.milestones?.title_filter ?? '', '')
100
+ .trim(),
101
+ };
102
+ });
86
103
  }
87
- }
88
- }
89
- `, {
90
- repository: remult.context.feedbackOptions.repo.name,
91
- owner: remult.context.feedbackOptions.repo.owner,
92
- filter: remult.context.feedbackOptions.milestones?.title_filter ?? '',
93
- });
94
- return data.repository.milestones.nodes.map((c) => {
95
- return {
96
- ...c,
97
- title: c.title
98
- .replaceAll(remult.context.feedbackOptions.milestones?.title_filter ?? '', '')
99
- .trim(),
100
- };
101
- });
104
+ throw new Error('feedback.getMilestones: server-only');
102
105
  }
103
106
  static async getIssues(milestoneNumber, issueState) {
104
- const issueOrder = issueState === 'CLOSED'
105
- ? { field: 'UPDATED_AT', direction: 'DESC' } // When close, the last issue updated.
106
- : null; // When open take milestone order
107
- const data = await getGitHub(`query Issues(
108
- $repository: String!
109
- $owner: String!
110
- $filters: IssueFilters
111
- $milestoneNumber: Int!
112
- $take: Int = 25
113
- $cursor: String
114
- $issueOrder: IssueOrder
115
- ) {
116
- repository(name: $repository, owner: $owner) {
117
- milestone(number: $milestoneNumber) {
118
- issues(first: $take, after: $cursor, filterBy: $filters, orderBy: $issueOrder) {
119
- nodes {
120
- id
121
- number
122
- titleHTML
123
- state
124
- createdAt
125
- updatedAt
126
- labels(first:10){
127
- nodes {
128
- name
129
- }
107
+ if (import.meta.env.SSR) {
108
+ const issueOrder = issueState === 'CLOSED'
109
+ ? { field: 'UPDATED_AT', direction: 'DESC' } // When close, the last issue updated.
110
+ : null; // When open take milestone order
111
+ const data = await getGitHub(`query Issues(
112
+ $repository: String!
113
+ $owner: String!
114
+ $filters: IssueFilters
115
+ $milestoneNumber: Int!
116
+ $take: Int = 25
117
+ $cursor: String
118
+ $issueOrder: IssueOrder
119
+ ) {
120
+ repository(name: $repository, owner: $owner) {
121
+ milestone(number: $milestoneNumber) {
122
+ issues(first: $take, after: $cursor, filterBy: $filters, orderBy: $issueOrder) {
123
+ nodes {
124
+ id
125
+ number
126
+ titleHTML
127
+ state
128
+ createdAt
129
+ updatedAt
130
+ labels(first:10){
131
+ nodes {
132
+ name
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
140
+ `, {
141
+ repository: remult.context.feedbackOptions.repo.name,
142
+ owner: remult.context.feedbackOptions.repo.owner,
143
+ milestoneNumber,
144
+ filters: {
145
+ // GitHub treats `labels: []` as "match nothing", so omit the key when unset.
146
+ labels: remult.context.feedbackOptions.milestones?.labels_filters?.length
147
+ ? remult.context.feedbackOptions.milestones.labels_filters
148
+ : undefined,
149
+ states: [issueState],
150
+ },
151
+ issueOrder,
152
+ });
153
+ return data.repository.milestone.issues.nodes.map((issue) => {
154
+ const labels = issue.labels.nodes.map((label) => label.name);
155
+ const hasWaitingForAnswerLabel = remult.context.feedbackOptions.highlight_label
156
+ ? labels.some((name) => name.includes(remult.context.feedbackOptions.highlight_label))
157
+ : false;
158
+ return {
159
+ id: issue.id,
160
+ number: issue.number,
161
+ titleHTML: issue.titleHTML,
162
+ state: issue.state,
163
+ createdAt: issue.createdAt,
164
+ updatedAt: issue.updatedAt,
165
+ labels,
166
+ highlight: hasWaitingForAnswerLabel,
167
+ };
168
+ });
169
+ }
170
+ throw new Error('feedback.getIssues: server-only');
171
+ }
172
+ static async getIssue(issueNumber) {
173
+ if (import.meta.env.SSR) {
174
+ const data = await getGitHub(`query Issue($repository: String!, $owner: String!, $issueNumber: Int!) {
175
+ repository(name: $repository, owner: $owner) {
176
+ issue(number: $issueNumber) {
177
+ id
178
+ createdAt
179
+ bodyHTML
180
+ state
181
+ title
182
+ labels(first: 25){
183
+ nodes{
184
+ id
185
+ name
186
+ }
187
+ }
188
+ comments(first: 100) {
189
+ nodes {
190
+ id
191
+ isMinimized
192
+ createdAt
193
+ body
194
+ bodyHTML
195
+ reactionGroups {
196
+ content
197
+ reactors(first: 1) {
198
+ totalCount
199
+ }
200
+ }
201
+ }
202
+ }
203
+ }
204
+ }
205
+ }
206
+ `, {
207
+ repository: remult.context.feedbackOptions.repo.name,
208
+ owner: remult.context.feedbackOptions.repo.owner,
209
+ issueNumber,
210
+ });
211
+ const items = [];
212
+ const firstItem = {
213
+ bodyHTML: data.repository.issue.bodyHTML,
214
+ createdAt: data.repository.issue.createdAt,
215
+ public: true,
216
+ title: data.repository.issue.title,
217
+ };
218
+ items.push(firstItem);
219
+ const comments = data.repository.issue.comments.nodes;
220
+ for (let i = 0; i < comments.length; i++) {
221
+ if (comments[i].isMinimized) {
222
+ const parsed = JSON.parse(comments[i].body.replaceAll('<pre>\n', '').replaceAll('\n</pre>', ''));
223
+ const last = items.at(-1);
224
+ last.who = parsed?.author ?? '???';
225
+ last.public = true;
226
+ }
227
+ else {
228
+ const nbEye = comments[i].reactionGroups.find((c) => c.content === 'EYES')?.reactors.totalCount;
229
+ items.push({
230
+ bodyHTML: comments[i].bodyHTML,
231
+ createdAt: new Date(comments[i].createdAt),
232
+ public: nbEye && nbEye > 0 ? true : false,
233
+ title: data.repository.issue.title,
234
+ });
130
235
  }
131
- }
132
236
  }
133
- }
134
- }
135
- }
136
- `, {
137
- repository: remult.context.feedbackOptions.repo.name,
138
- owner: remult.context.feedbackOptions.repo.owner,
139
- milestoneNumber,
140
- filters: {
141
- // GitHub treats `labels: []` as "match nothing", so omit the key when unset.
142
- labels: remult.context.feedbackOptions.milestones?.labels_filters?.length
143
- ? remult.context.feedbackOptions.milestones.labels_filters
144
- : undefined,
145
- states: [issueState],
146
- },
147
- issueOrder,
148
- });
149
- return data.repository.milestone.issues.nodes.map((issue) => {
150
- const labels = issue.labels.nodes.map((label) => label.name);
151
237
  const hasWaitingForAnswerLabel = remult.context.feedbackOptions.highlight_label
152
- ? labels.some((name) => name.includes(remult.context.feedbackOptions.highlight_label))
238
+ ? data.repository.issue.labels.nodes.some((label) => label.name.includes(remult.context.feedbackOptions.highlight_label))
153
239
  : false;
154
- return {
155
- id: issue.id,
156
- number: issue.number,
157
- titleHTML: issue.titleHTML,
158
- state: issue.state,
159
- createdAt: issue.createdAt,
160
- updatedAt: issue.updatedAt,
161
- labels,
240
+ const toRet = {
241
+ id: data.repository.issue.id,
242
+ state: data.repository.issue.state,
243
+ items: items.filter((c) => c.public),
244
+ labels: data.repository.issue.labels.nodes,
162
245
  highlight: hasWaitingForAnswerLabel,
246
+ title: data.repository.issue.title,
163
247
  };
164
- });
165
- }
166
- static async getIssue(issueNumber) {
167
- const data = await getGitHub(`query Issue($repository: String!, $owner: String!, $issueNumber: Int!) {
168
- repository(name: $repository, owner: $owner) {
169
- issue(number: $issueNumber) {
170
- id
171
- createdAt
172
- bodyHTML
173
- state
174
- title
175
- labels(first: 25){
176
- nodes{
177
- id
178
- name
179
- }
180
- }
181
- comments(first: 100) {
182
- nodes {
183
- id
184
- isMinimized
185
- createdAt
186
- body
187
- bodyHTML
188
- reactionGroups {
189
- content
190
- reactors(first: 1) {
191
- totalCount
192
- }
193
- }
194
- }
195
- }
196
- }
197
- }
198
- }
199
- `, {
200
- repository: remult.context.feedbackOptions.repo.name,
201
- owner: remult.context.feedbackOptions.repo.owner,
202
- issueNumber,
203
- });
204
- const items = [];
205
- const firstItem = {
206
- bodyHTML: data.repository.issue.bodyHTML,
207
- createdAt: data.repository.issue.createdAt,
208
- public: true,
209
- title: data.repository.issue.title,
210
- };
211
- items.push(firstItem);
212
- const comments = data.repository.issue.comments.nodes;
213
- for (let i = 0; i < comments.length; i++) {
214
- if (comments[i].isMinimized) {
215
- const parsed = JSON.parse(comments[i].body.replaceAll('<pre>\n', '').replaceAll('\n</pre>', ''));
216
- const last = items.at(-1);
217
- last.who = parsed?.author ?? '???';
218
- last.public = true;
219
- }
220
- else {
221
- const nbEye = comments[i].reactionGroups.find((c) => c.content === 'EYES')?.reactors.totalCount;
222
- items.push({
223
- bodyHTML: comments[i].bodyHTML,
224
- createdAt: new Date(comments[i].createdAt),
225
- public: nbEye && nbEye > 0 ? true : false,
226
- title: data.repository.issue.title,
227
- });
228
- }
248
+ return toRet;
229
249
  }
230
- const hasWaitingForAnswerLabel = remult.context.feedbackOptions.highlight_label
231
- ? data.repository.issue.labels.nodes.some((label) => label.name.includes(remult.context.feedbackOptions.highlight_label))
232
- : false;
233
- const toRet = {
234
- id: data.repository.issue.id,
235
- state: data.repository.issue.state,
236
- items: items.filter((c) => c.public),
237
- labels: data.repository.issue.labels.nodes,
238
- highlight: hasWaitingForAnswerLabel,
239
- title: data.repository.issue.title,
240
- };
241
- return toRet;
250
+ throw new Error('feedback.getIssue: server-only');
242
251
  }
243
252
  static async createIssue(milestoneId, title, body, metadata,
244
253
  /** Extra label names applied on top of `create_label` (unknown names are ignored). */
245
254
  labels = []) {
246
- const repoInfo = await getGitHub(`query RepoInfo(
247
- $repository: String!
248
- $owner: String!
249
- ) {
250
- repository(name: $repository, owner: $owner) {
251
- id
252
- labels(first: 25){
253
- nodes{
254
- id
255
- name
256
- }
257
- }
258
- }
259
- }`, {
260
- repository: remult.context.feedbackOptions.repo.name,
261
- owner: remult.context.feedbackOptions.repo.owner,
262
- });
263
- const repoInfoData = repoInfo.repository;
264
- const wanted = new Set([remult.context.feedbackOptions.create_label, ...labels]);
265
- const labelIds = repoInfoData.labels.nodes.filter((c) => wanted.has(c.name)).map((c) => c.id);
266
- const newIssue = await getGitHub(`mutation CreateIssue($input: CreateIssueInput!) {
267
- createIssue(input: $input) {
268
- issue {
269
- id
270
- number
255
+ if (import.meta.env.SSR) {
256
+ const repoInfo = await getGitHub(`query RepoInfo(
257
+ $repository: String!
258
+ $owner: String!
259
+ ) {
260
+ repository(name: $repository, owner: $owner) {
261
+ id
262
+ labels(first: 25){
263
+ nodes{
264
+ id
265
+ name
266
+ }
267
+ }
268
+ }
269
+ }`, {
270
+ repository: remult.context.feedbackOptions.repo.name,
271
+ owner: remult.context.feedbackOptions.repo.owner,
272
+ });
273
+ const repoInfoData = repoInfo.repository;
274
+ const wanted = new Set([remult.context.feedbackOptions.create_label, ...labels]);
275
+ const labelIds = repoInfoData.labels.nodes.filter((c) => wanted.has(c.name)).map((c) => c.id);
276
+ const newIssue = await getGitHub(`mutation CreateIssue($input: CreateIssueInput!) {
277
+ createIssue(input: $input) {
278
+ issue {
279
+ id
280
+ number
281
+ }
282
+ }
283
+ }
284
+ `, {
285
+ input: {
286
+ repositoryId: repoInfoData.id,
287
+ milestoneId: milestoneId,
288
+ labelIds,
289
+ title: title ?? 'New Feedback (wo title...)',
290
+ body: body,
291
+ },
292
+ });
293
+ const toRet = newIssue.createIssue.issue;
294
+ const feedbackMetadata = remult.context.feedbackOptions.transformMetadata?.({
295
+ user: remult.user,
296
+ metadata,
297
+ }) ?? metadata;
298
+ await addMetaData(toRet.id, feedbackMetadata);
299
+ remult.context.feedbackOptions.saved?.({
300
+ number: toRet.number,
301
+ title: title,
302
+ body,
303
+ metadata: feedbackMetadata,
304
+ });
305
+ return toRet;
271
306
  }
272
- }
273
- }
274
- `, {
275
- input: {
276
- repositoryId: repoInfoData.id,
277
- milestoneId: milestoneId,
278
- labelIds,
279
- title: title ?? 'New Feedback (wo title...)',
280
- body: body,
281
- },
282
- });
283
- const toRet = newIssue.createIssue.issue;
284
- const feedbackMetadata = remult.context.feedbackOptions.transformMetadata?.({
285
- user: remult.user,
286
- metadata,
287
- }) ?? metadata;
288
- await addMetaData(toRet.id, feedbackMetadata);
289
- remult.context.feedbackOptions.saved?.({
290
- number: toRet.number,
291
- title: title,
292
- body,
293
- metadata: feedbackMetadata,
294
- });
295
- return toRet;
307
+ throw new Error('feedback.createIssue: server-only');
296
308
  }
297
309
  static async addCommentOnIssue(issueId, issueNumber, title, body, metadata, labels) {
298
- const inputComment = {
299
- subjectId: issueId,
300
- body,
301
- };
302
- const inputIssue = {
303
- id: issueId,
304
- labelIds: (remult.context.feedbackOptions.highlight_label
305
- ? labels.filter((c) => c.name !== remult.context.feedbackOptions.highlight_label)
306
- : labels).map((c) => c.id),
307
- };
308
- await getGitHub(`mutation AddComment($inputComment: AddCommentInput!, $inputIssue: UpdateIssueInput!) {
309
- addComment(input: $inputComment) {
310
- commentEdge {
311
- node {
312
- id
313
- }
314
- }
315
- }
316
- updateIssue(input: $inputIssue) {
317
- issue {
318
- id
319
- }
310
+ if (import.meta.env.SSR) {
311
+ const inputComment = {
312
+ subjectId: issueId,
313
+ body,
314
+ };
315
+ const inputIssue = {
316
+ id: issueId,
317
+ labelIds: (remult.context.feedbackOptions.highlight_label
318
+ ? labels.filter((c) => c.name !== remult.context.feedbackOptions.highlight_label)
319
+ : labels).map((c) => c.id),
320
+ };
321
+ await getGitHub(`mutation AddComment($inputComment: AddCommentInput!, $inputIssue: UpdateIssueInput!) {
322
+ addComment(input: $inputComment) {
323
+ commentEdge {
324
+ node {
325
+ id
326
+ }
327
+ }
328
+ }
329
+ updateIssue(input: $inputIssue) {
330
+ issue {
331
+ id
332
+ }
333
+ }
334
+ }
335
+ `, {
336
+ inputComment,
337
+ inputIssue,
338
+ });
339
+ const feedbackMetadata = remult.context.feedbackOptions.transformMetadata?.({
340
+ user: remult.user,
341
+ metadata,
342
+ }) ?? metadata;
343
+ await addMetaData(issueId, feedbackMetadata);
344
+ remult.context.feedbackOptions.saved?.({
345
+ number: issueNumber,
346
+ title,
347
+ body,
348
+ metadata: feedbackMetadata,
349
+ });
350
+ return 'done';
320
351
  }
321
- }
322
- `, {
323
- inputComment,
324
- inputIssue,
325
- });
326
- const feedbackMetadata = remult.context.feedbackOptions.transformMetadata?.({
327
- user: remult.user,
328
- metadata,
329
- }) ?? metadata;
330
- await addMetaData(issueId, feedbackMetadata);
331
- remult.context.feedbackOptions.saved?.({
332
- number: issueNumber,
333
- title,
334
- body,
335
- metadata: feedbackMetadata,
336
- });
337
- return 'done';
352
+ throw new Error('feedback.addCommentOnIssue: server-only');
338
353
  }
339
354
  static async close(issueId, labels) {
340
- const inputClose = {
341
- issueId,
342
- };
343
- const inputIssue = {
344
- id: issueId,
345
- labelIds: (remult.context.feedbackOptions.highlight_label
346
- ? labels.filter((c) => c.name !== remult.context.feedbackOptions.highlight_label)
347
- : labels).map((c) => c.id),
348
- };
349
- await getGitHub(`mutation CloseIssue($inputIssue: UpdateIssueInput!, $inputClose: CloseIssueInput!) {
350
- updateIssue(input: $inputIssue) {
351
- issue {
352
- id
353
- }
354
- }
355
- closeIssue(input: $inputClose) {
356
- issue {
357
- id
358
- }
355
+ if (import.meta.env.SSR) {
356
+ const inputClose = {
357
+ issueId,
358
+ };
359
+ const inputIssue = {
360
+ id: issueId,
361
+ labelIds: (remult.context.feedbackOptions.highlight_label
362
+ ? labels.filter((c) => c.name !== remult.context.feedbackOptions.highlight_label)
363
+ : labels).map((c) => c.id),
364
+ };
365
+ await getGitHub(`mutation CloseIssue($inputIssue: UpdateIssueInput!, $inputClose: CloseIssueInput!) {
366
+ updateIssue(input: $inputIssue) {
367
+ issue {
368
+ id
369
+ }
370
+ }
371
+ closeIssue(input: $inputClose) {
372
+ issue {
373
+ id
374
+ }
375
+ }
376
+ }
377
+ `, {
378
+ inputIssue,
379
+ inputClose,
380
+ });
381
+ return 'done';
359
382
  }
360
- }
361
- `, {
362
- inputIssue,
363
- inputClose,
364
- });
365
- return 'done';
383
+ throw new Error('feedback.close: server-only');
366
384
  }
367
385
  static async reOpen(issueId) {
368
- const input = {
369
- issueId,
370
- };
371
- await getGitHub(`mutation ReOpenIssue($input: ReopenIssueInput!) {
372
- reopenIssue(input: $input) {
373
- issue {
374
- id
375
- }
386
+ if (import.meta.env.SSR) {
387
+ const input = {
388
+ issueId,
389
+ };
390
+ await getGitHub(`mutation ReOpenIssue($input: ReopenIssueInput!) {
391
+ reopenIssue(input: $input) {
392
+ issue {
393
+ id
394
+ }
395
+ }
396
+ }
397
+ `, {
398
+ input,
399
+ });
400
+ return 'done';
376
401
  }
377
- }
378
- `, {
379
- input,
380
- });
381
- return 'done';
402
+ throw new Error('feedback.reOpen: server-only');
382
403
  }
383
404
  }
384
405
  __decorate([
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { remult, repo } from 'remult'
5
5
 
6
+ import { errorMessage } from '../../core/helper.js'
6
7
  import { Mail } from '../Mail'
7
8
  import { Roles_Mail } from '../Roles_Mail'
8
9
 
@@ -28,7 +29,7 @@
28
29
  try {
29
30
  mails = await repo(Mail).find({ limit })
30
31
  } catch (e) {
31
- error = e instanceof Error ? e.message : String(e)
32
+ error = errorMessage(e)
32
33
  } finally {
33
34
  isLoading = false
34
35
  }
@@ -50,6 +50,7 @@ export type SqlTokensOptions = {
50
50
  /** Override the pool used by `read` tokens. Defaults to the Postgres pool behind the data provider. */
51
51
  pool?: SqlTokenPool;
52
52
  };
53
+ export declare const SERVER_ONLY = "sqlAdmin: server-only";
53
54
  export declare const SQL_ADMINS: ("FF_Role.Admin" | "SqlAdmin.Admin")[];
54
55
  export declare class SqlAdminController {
55
56
  /** Optional override set by the `sqlAdmin()` module's `initApi`. Falls back to `SqlDatabase.getDb()`. */