firstly 0.1.3 → 0.2.1

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.
Files changed (121) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/esm/auth/Entities.js +2 -2
  3. package/esm/auth/server/AuthController.server.js +32 -12
  4. package/esm/auth/static/assets/Page-BRNWcY5Z.js +1 -0
  5. package/esm/auth/static/assets/Page-CFcEsGK8.d.ts +2 -0
  6. package/esm/auth/static/assets/Page-CFcEsGK8.js +7 -0
  7. package/esm/auth/static/assets/Page-tLVs5slF.js +1 -0
  8. package/esm/auth/static/assets/index-D38rqu4x.d.ts +201 -0
  9. package/esm/auth/static/assets/index-D38rqu4x.js +2 -0
  10. package/esm/auth/static/index.html +1 -1
  11. package/esm/bin/cmd.js +3 -3
  12. package/esm/carbone/CarboneController.d.ts +35 -0
  13. package/esm/carbone/CarboneController.js +155 -0
  14. package/esm/carbone/Roles_Carbon.d.ts +8 -0
  15. package/esm/carbone/Roles_Carbon.js +8 -0
  16. package/esm/carbone/carboneEntities.d.ts +21 -0
  17. package/esm/carbone/carboneEntities.js +83 -0
  18. package/esm/carbone/index.d.ts +29 -0
  19. package/esm/carbone/index.js +68 -0
  20. package/esm/carbone/server/CarboneServer.d.ts +19 -0
  21. package/esm/carbone/server/CarboneServer.js +38 -0
  22. package/esm/carbone/server/index.d.ts +7 -0
  23. package/esm/carbone/server/index.js +23 -0
  24. package/esm/changeLog/changeLogEntities.js +1 -1
  25. package/esm/cron/Cron.js +1 -1
  26. package/esm/feedback/FeedbackController.d.ts +6 -2
  27. package/esm/feedback/FeedbackController.js +145 -143
  28. package/esm/feedback/server/index.d.ts +2 -2
  29. package/esm/feedback/server/index.js +3 -3
  30. package/esm/feedback/types.d.ts +5 -0
  31. package/esm/feedback/ui/DialogIssue.svelte +5 -5
  32. package/esm/feedback/ui/DialogIssues.svelte +5 -5
  33. package/esm/feedback/ui/DialogMilestones.svelte +1 -1
  34. package/esm/internals/BaseEnum.d.ts +1 -0
  35. package/esm/internals/FF_Fields.d.ts +6 -4
  36. package/esm/internals/FF_Fields.js +27 -64
  37. package/esm/internals/cellsBuildor.d.ts +2 -1
  38. package/esm/internals/index.d.ts +7 -8
  39. package/esm/internals/storeItem.d.ts +1 -0
  40. package/esm/mail/Mail.js +1 -1
  41. package/esm/mail/server/index.d.ts +8 -2
  42. package/esm/mail/server/index.js +35 -7
  43. package/esm/server/index.d.ts +1 -1
  44. package/esm/svelte/FF_Cell.svelte +3 -5
  45. package/esm/svelte/FF_Cell.svelte.d.ts +13 -4
  46. package/esm/svelte/FF_Cell_Caption.svelte.d.ts +10 -3
  47. package/esm/svelte/FF_Cell_Display.svelte.d.ts +10 -3
  48. package/esm/svelte/FF_Cell_Edit.svelte.d.ts +11 -4
  49. package/esm/svelte/FF_Cell_Error.svelte.d.ts +10 -3
  50. package/esm/svelte/FF_Cell_Hint.svelte.d.ts +10 -3
  51. package/esm/svelte/FF_Form.svelte +4 -5
  52. package/esm/svelte/FF_Form.svelte.d.ts +10 -3
  53. package/esm/svelte/FF_Grid.svelte +2 -2
  54. package/esm/svelte/FF_Grid.svelte.d.ts +10 -3
  55. package/esm/svelte/FF_Layout.svelte +3 -3
  56. package/esm/svelte/FF_Layout.svelte.d.ts +10 -3
  57. package/esm/svelte/dialog/DialogManagement.svelte +2 -5
  58. package/esm/svelte/dialog/DialogPrimitive.svelte +1 -2
  59. package/esm/svelte/dialog/dialog.js +2 -2
  60. package/esm/svelte/ff_Config.svelte.js +2 -2
  61. package/esm/svelte/index.d.ts +2 -7
  62. package/esm/svelte/index.js +2 -7
  63. package/esm/ui/Button.svelte +40 -23
  64. package/esm/ui/Button.svelte.d.ts +10 -34
  65. package/esm/ui/Clipboardable.svelte +13 -17
  66. package/esm/ui/Clipboardable.svelte.d.ts +9 -33
  67. package/esm/ui/Field.svelte +38 -8
  68. package/esm/ui/FieldGroup.svelte.d.ts +1 -1
  69. package/esm/ui/Grid.svelte +11 -82
  70. package/esm/ui/Grid.svelte.d.ts +0 -1
  71. package/esm/ui/Grid2.svelte +25 -86
  72. package/esm/ui/Grid2.svelte.d.ts +1 -2
  73. package/esm/ui/GridPaginate.svelte +1 -1
  74. package/esm/ui/GridPaginate2.svelte +2 -2
  75. package/esm/ui/Icon.svelte +2 -18
  76. package/esm/ui/Icon.svelte.d.ts +0 -2
  77. package/esm/ui/LibIcon.js +2 -2
  78. package/esm/ui/Loading.svelte +1 -1
  79. package/esm/ui/Tooltip.svelte +3 -2
  80. package/esm/ui/dialog/DialogManagement.svelte +14 -5
  81. package/esm/ui/dialog/DialogPrimitive.svelte +4 -4
  82. package/esm/ui/dialog/FormEditAction.svelte +4 -4
  83. package/esm/ui/dialog/dialog.d.ts +5 -2
  84. package/esm/ui/dialog/dialog.js +2 -2
  85. package/esm/ui/index.d.ts +1 -0
  86. package/esm/ui/index.js +1 -0
  87. package/esm/ui/internals/FieldContainer.svelte +25 -14
  88. package/esm/ui/internals/FieldContainer.svelte.d.ts +9 -30
  89. package/esm/ui/internals/Input.svelte.d.ts +1 -1
  90. package/esm/ui/internals/Textarea.svelte +2 -5
  91. package/esm/ui/internals/select/MultiSelectMelt.svelte +6 -4
  92. package/esm/ui/internals/select/Select2.svelte +88 -0
  93. package/esm/ui/internals/select/Select2.svelte.d.ts +12 -0
  94. package/esm/ui/internals/select/SelectMelt.svelte +5 -5
  95. package/esm/ui/internals/select/SelectRadio.svelte +1 -1
  96. package/esm/ui/link/Link.svelte +1 -1
  97. package/esm/ui/link/LinkPlus.svelte +9 -5
  98. package/esm/ui/link/LinkPlus.svelte.d.ts +5 -19
  99. package/esm/virtual/Customer.js +2 -3
  100. package/esm/virtual/UIEntity.js +10 -6
  101. package/package.json +16 -9
  102. package/esm/auth/static/assets/Page-9Ytj29NS.js +0 -1
  103. package/esm/auth/static/assets/Page-C1pM-UDt.d.ts +0 -2
  104. package/esm/auth/static/assets/Page-C1pM-UDt.js +0 -20
  105. package/esm/auth/static/assets/Page-CPz6KCw_.js +0 -1
  106. package/esm/auth/static/assets/index-AoBb9Ds5.d.ts +0 -232
  107. package/esm/auth/static/assets/index-AoBb9Ds5.js +0 -2
  108. package/esm/svelte/FF_Display.svelte +0 -51
  109. package/esm/svelte/FF_Display.svelte.d.ts +0 -22
  110. package/esm/svelte/FF_Edit.svelte +0 -104
  111. package/esm/svelte/FF_Edit.svelte.d.ts +0 -25
  112. package/esm/svelte/FF_Error.svelte +0 -23
  113. package/esm/svelte/FF_Error.svelte.d.ts +0 -22
  114. package/esm/svelte/FF_Field.svelte +0 -62
  115. package/esm/svelte/FF_Field.svelte.d.ts +0 -22
  116. package/esm/svelte/FF_Hint.svelte +0 -21
  117. package/esm/svelte/FF_Hint.svelte.d.ts +0 -22
  118. package/esm/svelte/FF_Label.svelte +0 -23
  119. package/esm/svelte/FF_Label.svelte.d.ts +0 -22
  120. /package/esm/auth/static/assets/{Page-CPz6KCw_.d.ts → Page-BRNWcY5Z.d.ts} +0 -0
  121. /package/esm/auth/static/assets/{Page-9Ytj29NS.d.ts → Page-tLVs5slF.d.ts} +0 -0
@@ -0,0 +1,68 @@
1
+ import { Log } from '@kitql/helpers';
2
+ import { CarboneLog, CarboneTemplate } from './carboneEntities';
3
+ export { Roles_Carbon as Roles_Mail } from './Roles_Carbon';
4
+ export const key = 'carbone';
5
+ export const log = new Log(key);
6
+ export const carbonEntities = {
7
+ CarboneTemplate,
8
+ CarboneLog,
9
+ };
10
+ /**
11
+ * Converts a File object to base64 string (without data URL prefix)
12
+ * @param file - The File object to convert
13
+ * @returns Promise<string> - Base64 string without data URL prefix
14
+ */
15
+ export const fileToBase64 = (file) => {
16
+ return new Promise((resolve, reject) => {
17
+ const reader = new FileReader();
18
+ reader.onload = () => {
19
+ const result = reader.result;
20
+ // Remove data URL prefix to get just the base64 content
21
+ const base64Content = result.split(',')[1];
22
+ resolve(base64Content);
23
+ };
24
+ reader.onerror = reject;
25
+ reader.readAsDataURL(file);
26
+ });
27
+ };
28
+ /**
29
+ * Downloads a file from base64 data
30
+ * @param base64Data - The base64 encoded file data
31
+ * @param filename - The filename for the download
32
+ * @param contentType - The MIME type of the file
33
+ */
34
+ export const downloadFile = (base64Data, filename, contentType) => {
35
+ try {
36
+ // Convert base64 to blob
37
+ const byteCharacters = atob(base64Data);
38
+ const byteNumbers = new Array(byteCharacters.length);
39
+ for (let i = 0; i < byteCharacters.length; i++) {
40
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
41
+ }
42
+ const byteArray = new Uint8Array(byteNumbers);
43
+ const blob = new Blob([byteArray], { type: contentType });
44
+ // Create download link
45
+ const url = URL.createObjectURL(blob);
46
+ const link = document.createElement('a');
47
+ link.href = url;
48
+ link.download = filename;
49
+ link.style.display = 'none';
50
+ // Trigger download
51
+ document.body.appendChild(link);
52
+ link.click();
53
+ document.body.removeChild(link);
54
+ // Clean up
55
+ URL.revokeObjectURL(url);
56
+ }
57
+ catch (error) {
58
+ console.error('Download failed:', error);
59
+ throw error;
60
+ }
61
+ };
62
+ /**
63
+ * File processing utilities for Carbone templates
64
+ */
65
+ export const carboneFileUtils = {
66
+ fileToBase64,
67
+ downloadFile,
68
+ };
@@ -0,0 +1,19 @@
1
+ export declare class CarboneServer {
2
+ api_key: string;
3
+ api_url: string;
4
+ api_version: '5';
5
+ test: boolean;
6
+ constructor(options: {
7
+ CARBONE_API_KEY?: string;
8
+ api_url?: string;
9
+ api_version?: '5';
10
+ test?: boolean;
11
+ });
12
+ private getHeaders;
13
+ fetch: (o: {
14
+ api: string;
15
+ body?: string;
16
+ method?: "POST" | "GET" | "DELETE";
17
+ headers?: HeadersInit;
18
+ }) => Promise<Response>;
19
+ }
@@ -0,0 +1,38 @@
1
+ import { log } from '..';
2
+ export class CarboneServer {
3
+ api_key;
4
+ api_url;
5
+ api_version;
6
+ test;
7
+ constructor(options) {
8
+ this.api_key = options.CARBONE_API_KEY ?? '';
9
+ this.api_url = options.api_url ?? 'https://api.carbone.io';
10
+ this.api_version = options.api_version ?? '5';
11
+ this.test = options.test ?? false;
12
+ }
13
+ getHeaders = (headersInit) => {
14
+ if (this.api_key === undefined || this.api_key === '') {
15
+ log.error('Token CARBONE_API_TOKEN not defined!');
16
+ throw new Error('Configuration error');
17
+ }
18
+ const headers = new Headers(headersInit);
19
+ headers.append('Authorization', 'Bearer ' + this.api_key);
20
+ headers.append('Carbone-version', this.api_version);
21
+ // headers.append('Carbone-version', 'staging')
22
+ headers.append('Content-type', 'application/json');
23
+ return headers;
24
+ };
25
+ fetch = async (o) => {
26
+ const response = await fetch(`${this.api_url}${o.api}`, {
27
+ method: o.method ?? 'POST',
28
+ headers: this.getHeaders(o.headers),
29
+ body: o.body,
30
+ });
31
+ if (!response.ok) {
32
+ const err = await response.json();
33
+ log.error(`Carbone render failed`, err);
34
+ throw new Error(err.error);
35
+ }
36
+ return response;
37
+ };
38
+ }
@@ -0,0 +1,7 @@
1
+ import { Module } from 'remult/server';
2
+ export declare const carbone: (config: {
3
+ CARBONE_API_KEY?: string;
4
+ api_url?: string;
5
+ api_version?: "5";
6
+ test?: boolean;
7
+ }) => Module<unknown>;
@@ -0,0 +1,23 @@
1
+ import { Module } from 'remult/server';
2
+ import { carbonEntities, key, log } from '..';
3
+ import { CarboneController } from '../CarboneController';
4
+ import { CarboneServer } from './CarboneServer';
5
+ export const carbone = (config) => {
6
+ return new Module({
7
+ key,
8
+ entities: Object.values(carbonEntities),
9
+ controllers: [CarboneController],
10
+ initApi: async () => {
11
+ if (config.CARBONE_API_KEY === undefined) {
12
+ log.error('CARBONE_API_KEY is required');
13
+ }
14
+ else {
15
+ CarboneController.server = new CarboneServer({
16
+ ...config,
17
+ test: config.test === undefined ? config.CARBONE_API_KEY.startsWith('test') : config.test,
18
+ });
19
+ log.success('initialized');
20
+ }
21
+ },
22
+ });
23
+ };
@@ -19,7 +19,7 @@ let ChangeLog = class ChangeLog {
19
19
  deleted = false;
20
20
  };
21
21
  __decorate([
22
- Fields.cuid()
22
+ Fields.id()
23
23
  ], ChangeLog.prototype, "id", void 0);
24
24
  __decorate([
25
25
  Fields.string()
package/esm/cron/Cron.js CHANGED
@@ -16,7 +16,7 @@ let Cron = class Cron {
16
16
  status = 'starting';
17
17
  };
18
18
  __decorate([
19
- Fields.cuid()
19
+ Fields.id()
20
20
  ], Cron.prototype, "id", void 0);
21
21
  __decorate([
22
22
  Fields.string({ required: true })
@@ -25,11 +25,15 @@ export declare class FeedbackController {
25
25
  highlight: any;
26
26
  title: any;
27
27
  }>;
28
- static createIssue(milestoneId: string, title: string, body: string, page: string): Promise<{
28
+ static createIssue(milestoneId: string, title: string, body: string, metadata: {
29
+ page: string;
30
+ }): Promise<{
29
31
  id: string;
30
32
  number: number;
31
33
  }>;
32
- static addCommentOnIssue(issueId: string, issueNumber: number, title: string, body: string, page: string, labels: {
34
+ static addCommentOnIssue(issueId: string, issueNumber: number, title: string, body: string, metadata: {
35
+ page: string;
36
+ }, labels: {
33
37
  id: string;
34
38
  name: string;
35
39
  }[]): Promise<string>;
@@ -32,31 +32,31 @@ async function getGitHub(query, variables) {
32
32
  }
33
33
  return null;
34
34
  }
35
- async function addMetaData(issueId, author, page) {
35
+ async function addMetaData(issueId, obj) {
36
36
  if (import.meta.env.SSR) {
37
37
  const commentToMinimize = await getGitHub(`mutation AddComment($input: AddCommentInput!) {
38
- addComment(input: $input) {
39
- commentEdge {
40
- node {
41
- id
42
- }
43
- }
44
- }
45
- }
46
- `, {
38
+ addComment(input: $input) {
39
+ commentEdge {
40
+ node {
41
+ id
42
+ }
43
+ }
44
+ }
45
+ }
46
+ `, {
47
47
  input: {
48
48
  subjectId: issueId,
49
- body: `<pre>\n${JSON.stringify({ author, page }, null, 2)}\n</pre>`,
49
+ body: `<pre>\n${JSON.stringify(obj, null, 2)}\n</pre>`,
50
50
  },
51
51
  });
52
52
  await getGitHub(`mutation MinimizeComment($input: MinimizeCommentInput!) {
53
- minimizeComment(input: $input) {
54
- minimizedComment {
55
- isMinimized
56
- }
57
- }
58
- }
59
- `, {
53
+ minimizeComment(input: $input) {
54
+ minimizedComment {
55
+ isMinimized
56
+ }
57
+ }
58
+ }
59
+ `, {
60
60
  input: {
61
61
  subjectId: commentToMinimize.addComment.commentEdge.node.id,
62
62
  classifier: 'OFF_TOPIC',
@@ -67,26 +67,26 @@ async function addMetaData(issueId, author, page) {
67
67
  export class FeedbackController {
68
68
  static async getMilestones() {
69
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
- }
86
- }
87
- }
88
- }
89
- `, {
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
+ }
86
+ }
87
+ }
88
+ }
89
+ `, {
90
90
  repository: remult.context.feedbackOptions.repo.name,
91
91
  owner: remult.context.feedbackOptions.repo.owner,
92
92
  filter: remult.context.feedbackOptions.milestones?.title_filter ?? '',
@@ -105,33 +105,33 @@ export class FeedbackController {
105
105
  ? { field: 'UPDATED_AT', direction: 'DESC' } // When close, the last issue updated.
106
106
  : null; // When open take milestone order
107
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
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
124
  labels(first:10){
125
125
  nodes {
126
126
  name
127
127
  }
128
128
  }
129
- }
130
- }
131
- }
132
- }
133
- }
134
- `, {
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ `, {
135
135
  repository: remult.context.feedbackOptions.repo.name,
136
136
  owner: remult.context.feedbackOptions.repo.owner,
137
137
  milestoneNumber,
@@ -156,38 +156,38 @@ export class FeedbackController {
156
156
  }
157
157
  static async getIssue(issueNumber) {
158
158
  const data = await getGitHub(`query Issue($repository: String!, $owner: String!, $issueNumber: Int!) {
159
- repository(name: $repository, owner: $owner) {
160
- issue(number: $issueNumber) {
161
- id
162
- createdAt
163
- bodyHTML
164
- state
165
- title
166
- labels(first: 25){
167
- nodes{
168
- id
169
- name
170
- }
171
- }
172
- comments(first: 100) {
173
- nodes {
174
- id
175
- isMinimized
176
- createdAt
177
- body
178
- bodyHTML
179
- reactionGroups {
180
- content
181
- reactors(first: 1) {
182
- totalCount
183
- }
184
- }
185
- }
186
- }
187
- }
188
- }
189
- }
190
- `, {
159
+ repository(name: $repository, owner: $owner) {
160
+ issue(number: $issueNumber) {
161
+ id
162
+ createdAt
163
+ bodyHTML
164
+ state
165
+ title
166
+ labels(first: 25){
167
+ nodes{
168
+ id
169
+ name
170
+ }
171
+ }
172
+ comments(first: 100) {
173
+ nodes {
174
+ id
175
+ isMinimized
176
+ createdAt
177
+ body
178
+ bodyHTML
179
+ reactionGroups {
180
+ content
181
+ reactors(first: 1) {
182
+ totalCount
183
+ }
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+ }
190
+ `, {
191
191
  repository: remult.context.feedbackOptions.repo.name,
192
192
  owner: remult.context.feedbackOptions.repo.owner,
193
193
  issueNumber,
@@ -204,7 +204,7 @@ export class FeedbackController {
204
204
  for (let i = 0; i < comments.length; i++) {
205
205
  if (comments[i].isMinimized) {
206
206
  const parsed = JSON.parse(comments[i].body.replaceAll('<pre>\n', '').replaceAll('\n</pre>', ''));
207
- items[items.length - 1].who = parsed.author;
207
+ items[items.length - 1].who = parsed?.author ?? '???';
208
208
  items[items.length - 1].public = true;
209
209
  }
210
210
  else {
@@ -230,35 +230,35 @@ export class FeedbackController {
230
230
  };
231
231
  return toRet;
232
232
  }
233
- static async createIssue(milestoneId, title, body, page) {
233
+ static async createIssue(milestoneId, title, body, metadata) {
234
234
  const repoInfo = await getGitHub(`query RepoInfo(
235
- $repository: String!
236
- $owner: String!
237
- ) {
238
- repository(name: $repository, owner: $owner) {
239
- id
235
+ $repository: String!
236
+ $owner: String!
237
+ ) {
238
+ repository(name: $repository, owner: $owner) {
239
+ id
240
240
  labels(first: 25){
241
241
  nodes{
242
242
  id
243
243
  name
244
244
  }
245
245
  }
246
- }
247
- }`, {
246
+ }
247
+ }`, {
248
248
  repository: remult.context.feedbackOptions.repo.name,
249
249
  owner: remult.context.feedbackOptions.repo.owner,
250
250
  });
251
251
  const repoInfoData = repoInfo.repository;
252
252
  const create_label = repoInfoData.labels.nodes.find((c) => c.name === remult.context.feedbackOptions.create_label);
253
253
  const newIssue = await getGitHub(`mutation CreateIssue($input: CreateIssueInput!) {
254
- createIssue(input: $input) {
255
- issue {
256
- id
257
- number
258
- }
259
- }
260
- }
261
- `, {
254
+ createIssue(input: $input) {
255
+ issue {
256
+ id
257
+ number
258
+ }
259
+ }
260
+ }
261
+ `, {
262
262
  input: {
263
263
  repositoryId: repoInfoData.id,
264
264
  milestoneId: milestoneId,
@@ -268,19 +268,20 @@ export class FeedbackController {
268
268
  },
269
269
  });
270
270
  const toRet = newIssue.createIssue.issue;
271
- await addMetaData(toRet.id, remult.user?.name, page);
271
+ const feedbackMetadata = remult.context.feedbackOptions.transformMetadata?.({
272
+ user: remult.user,
273
+ metadata,
274
+ }) ?? metadata;
275
+ await addMetaData(toRet.id, feedbackMetadata);
272
276
  remult.context.feedbackOptions.saved?.({
273
277
  number: toRet.number,
274
278
  title: title,
275
279
  body,
276
- metadata: {
277
- author: JSON.stringify(remult.user?.name),
278
- page,
279
- },
280
+ metadata: feedbackMetadata,
280
281
  });
281
282
  return toRet;
282
283
  }
283
- static async addCommentOnIssue(issueId, issueNumber, title, body, page, labels) {
284
+ static async addCommentOnIssue(issueId, issueNumber, title, body, metadata, labels) {
284
285
  const inputComment = {
285
286
  subjectId: issueId,
286
287
  body,
@@ -292,32 +293,33 @@ export class FeedbackController {
292
293
  : labels).map((c) => c.id),
293
294
  };
294
295
  await getGitHub(`mutation AddComment($inputComment: AddCommentInput!, $inputIssue: UpdateIssueInput!) {
295
- addComment(input: $inputComment) {
296
- commentEdge {
297
- node {
298
- id
299
- }
300
- }
301
- }
296
+ addComment(input: $inputComment) {
297
+ commentEdge {
298
+ node {
299
+ id
300
+ }
301
+ }
302
+ }
302
303
  updateIssue(input: $inputIssue) {
303
304
  issue {
304
305
  id
305
306
  }
306
307
  }
307
- }
308
- `, {
308
+ }
309
+ `, {
309
310
  inputComment,
310
311
  inputIssue,
311
312
  });
312
- await addMetaData(issueId, remult.user?.name, page);
313
+ const feedbackMetadata = remult.context.feedbackOptions.transformMetadata?.({
314
+ user: remult.user,
315
+ metadata,
316
+ }) ?? metadata;
317
+ await addMetaData(issueId, feedbackMetadata);
313
318
  remult.context.feedbackOptions.saved?.({
314
319
  number: issueNumber,
315
320
  title,
316
321
  body,
317
- metadata: {
318
- author: JSON.stringify(remult.user?.name),
319
- page,
320
- },
322
+ metadata: feedbackMetadata,
321
323
  });
322
324
  return 'done';
323
325
  }
@@ -337,13 +339,13 @@ export class FeedbackController {
337
339
  id
338
340
  }
339
341
  }
340
- closeIssue(input: $inputClose) {
341
- issue {
342
- id
343
- }
344
- }
345
- }
346
- `, {
342
+ closeIssue(input: $inputClose) {
343
+ issue {
344
+ id
345
+ }
346
+ }
347
+ }
348
+ `, {
347
349
  inputIssue,
348
350
  inputClose,
349
351
  });
@@ -354,13 +356,13 @@ export class FeedbackController {
354
356
  issueId,
355
357
  };
356
358
  await getGitHub(`mutation ReOpenIssue($input: ReopenIssueInput!) {
357
- reopenIssue(input: $input) {
358
- issue {
359
- id
360
- }
361
- }
362
- }
363
- `, {
359
+ reopenIssue(input: $input) {
360
+ issue {
361
+ id
362
+ }
363
+ }
364
+ }
365
+ `, {
364
366
  input,
365
367
  });
366
368
  return 'done';
@@ -1,6 +1,6 @@
1
- import { ModuleFF } from '../../server';
1
+ import { Module } from 'remult/server';
2
2
  import type { FeedbackOptions } from '../types';
3
- export declare const feedback: (o: FeedbackOptions) => ModuleFF;
3
+ export declare const feedback: (o: FeedbackOptions) => Module<unknown>;
4
4
  declare module 'remult' {
5
5
  interface RemultContext {
6
6
  feedbackOptions: FeedbackOptions;
@@ -1,9 +1,9 @@
1
1
  import { remult } from 'remult';
2
- import { ModuleFF } from '../../server';
2
+ import { Module } from 'remult/server';
3
3
  import { FeedbackController } from '../FeedbackController';
4
4
  export const feedback = (o) => {
5
- return new ModuleFF({
6
- name: 'feedback',
5
+ return new Module({
6
+ key: 'feedback',
7
7
  controllers: [FeedbackController],
8
8
  initRequest: async (kitEvent, op) => {
9
9
  remult.context.feedbackOptions = o;
@@ -1,3 +1,4 @@
1
+ import type { UserInfo } from 'remult';
1
2
  export type FeedbackOptions = {
2
3
  GITHUB_API_TOKEN: string;
3
4
  repo: {
@@ -10,6 +11,10 @@ export type FeedbackOptions = {
10
11
  };
11
12
  highlight_label?: string;
12
13
  create_label?: string;
14
+ transformMetadata?: (o: {
15
+ user: UserInfo | undefined;
16
+ metadata: Record<string, any>;
17
+ }) => Record<string, any>;
13
18
  saved?: (args: {
14
19
  number: number;
15
20
  title: string;
@@ -45,7 +45,7 @@
45
45
 
46
46
  const p = $page.url.pathname + $page.url.search
47
47
  if (!issue?.id) {
48
- const result = await FeedbackController.createIssue(milestoneId, title, content, p)
48
+ const result = await FeedbackController.createIssue(milestoneId, title, content, { page: p })
49
49
  issueNumber = result.number
50
50
  } else {
51
51
  await FeedbackController.addCommentOnIssue(
@@ -53,7 +53,7 @@
53
53
  issueNumber!,
54
54
  issue.title,
55
55
  content,
56
- p,
56
+ { page: p },
57
57
  issue.labels,
58
58
  )
59
59
  }
@@ -126,7 +126,7 @@
126
126
 
127
127
  {#if issue?.state === 'CLOSED'}
128
128
  <div class="flex justify-end">
129
- <Button on:click={reOpen} class="btn-neutral">Re Ouvrir</Button>
129
+ <Button onclick={reOpen} class="btn-neutral">Re Ouvrir</Button>
130
130
  </div>
131
131
  {:else}
132
132
  {#if issueNumber === null}
@@ -138,11 +138,11 @@
138
138
  ></Textarea>
139
139
  <div class="flex justify-between">
140
140
  {#if issueNumber}
141
- <Button on:click={close} tabIndex={-1} class="btn-outline btn-error">Clore le feedback</Button>
141
+ <Button onclick={close} tabindex={-1} class="btn-error">Clore le feedback</Button>
142
142
  {:else}
143
143
  <div></div>
144
144
  {/if}
145
- <Button on:click={send} disabled={disableButton(issueNumber, title, content)}>Envoyer</Button>
145
+ <Button onclick={send} disabled={disableButton(issueNumber, title, content)}>Envoyer</Button>
146
146
  </div>
147
147
  {/if}
148
148
  {/if}