iconograph-ui 1.7.20 → 2.0.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.
Files changed (92) hide show
  1. package/example/src/routes/{+page.svelte → basic/+page.svelte} +1 -1
  2. package/example/src/routes/parabole/+layout.svelte +111 -0
  3. package/example/src/routes/parabole/+page.svelte +112 -0
  4. package/example/static/icons/discord-logo-icon.svg +22 -0
  5. package/example/static/icons/icon-add-w.svg +38 -0
  6. package/example/static/icons/icon-archive-black.svg +1 -0
  7. package/example/static/icons/icon-archive-grey.svg +38 -0
  8. package/example/static/icons/icon-beneficiaire-small.svg +50 -0
  9. package/example/static/icons/icon-beneficiaire.svg +48 -0
  10. package/example/static/icons/icon-cardlist-black.svg +56 -0
  11. package/example/static/icons/icon-cardlist-grey.svg +56 -0
  12. package/example/static/icons/icon-client.png +0 -0
  13. package/example/static/icons/icon-dashboard.svg +40 -0
  14. package/example/static/icons/icon-doc.svg +39 -0
  15. package/example/static/icons/icon-done.svg +1 -0
  16. package/example/static/icons/icon-edit-g.svg +61 -0
  17. package/example/static/icons/icon-edit-w.svg +1 -0
  18. package/example/static/icons/icon-info-100.svg +54 -0
  19. package/example/static/icons/icon-info-w.svg +39 -0
  20. package/example/static/icons/icon-kanban-black.svg +65 -0
  21. package/example/static/icons/icon-kanban-grey.svg +65 -0
  22. package/example/static/icons/icon-link.svg +47 -0
  23. package/example/static/icons/icon-list-black.svg +76 -0
  24. package/example/static/icons/icon-list-grey.svg +76 -0
  25. package/example/static/icons/icon-member.png +0 -0
  26. package/example/static/icons/icon-next-w.svg +42 -0
  27. package/example/static/icons/icon-note.svg +44 -0
  28. package/example/static/icons/icon-order.svg +61 -0
  29. package/example/static/icons/icon-out.svg +38 -0
  30. package/example/static/icons/icon-project.svg +39 -0
  31. package/example/static/icons/icon-red-star.svg +53 -0
  32. package/example/static/icons/icon-save-b.png +0 -0
  33. package/example/static/icons/icon-save-w.png +0 -0
  34. package/example/static/icons/icon-task.svg +40 -0
  35. package/example/static/icons/icon-timeline-black.svg +68 -0
  36. package/example/static/icons/icon-timeline-grey.svg +68 -0
  37. package/example/static/icons/icon-user-add.svg +41 -0
  38. package/example/static/icons/icon-user.png +0 -0
  39. package/example/static/icons/icon-user.svg +39 -0
  40. package/example/static/icons/loader-ring-w.svg +1 -0
  41. package/lib/{display → components/display}/Portal.svelte +3 -3
  42. package/lib/{layout → components/layout}/Card.svelte +2 -1
  43. package/lib/{navigation → components/navigation}/MainMenu.svelte +26 -33
  44. package/lib/{navigation → components/navigation}/MenuItem.svelte +8 -7
  45. package/lib/network/APIErrors.js +51 -0
  46. package/lib/network/action.js +21 -0
  47. package/lib/network/clientFetch.js +50 -0
  48. package/lib/network/index.js +1 -0
  49. package/lib/network/requestApi.js +127 -0
  50. package/lib/network/requestn8n.js +52 -0
  51. package/lib/utils/flattenType.js +8 -0
  52. package/lib/utils/transformers/entityTransformer.js +28 -0
  53. package/lib/utils/transformers/index.js +1 -0
  54. package/lib/utils/transformers/projectTransformer.js +17 -0
  55. package/lib/utils/transformers/userTransformer.js +36 -0
  56. package/package.json +11 -3
  57. /package/example/src/routes/{+layout.svelte → basic/+layout.svelte} +0 -0
  58. /package/example/src/routes/{example → basic/example}/+server.js +0 -0
  59. /package/example/src/routes/{user → basic/user}/+page.svelte +0 -0
  60. /package/example/src/routes/{user → basic/user}/+server.js +0 -0
  61. /package/lib/{display → components/display}/DateStr.svelte +0 -0
  62. /package/lib/{display → components/display}/Field.svelte +0 -0
  63. /package/lib/{display → components/display}/Link.svelte +0 -0
  64. /package/lib/{form → components/form}/ActionButton.svelte +0 -0
  65. /package/lib/{form → components/form}/Checkbox.svelte +0 -0
  66. /package/lib/{form → components/form}/FlexForm.svelte +0 -0
  67. /package/lib/{form → components/form}/Form.svelte +0 -0
  68. /package/lib/{form → components/form}/FormButton.svelte +0 -0
  69. /package/lib/{form → components/form}/Input.svelte +0 -0
  70. /package/lib/{form → components/form}/MultiSelect.svelte +0 -0
  71. /package/lib/{form → components/form}/SegmentedSwitchInput.svelte +0 -0
  72. /package/lib/{form → components/form}/SexeChoiceInput.svelte +0 -0
  73. /package/lib/{inputs → components/form/inputs}/Editor.svelte +0 -0
  74. /package/lib/{inputs → components/form/inputs}/PasswordInput.svelte +0 -0
  75. /package/lib/{inputs → components/form/inputs}/SearchSelect.svelte +0 -0
  76. /package/lib/{layout → components/layout}/BodySection.svelte +0 -0
  77. /package/lib/{layout → components/layout}/HeadSection.svelte +0 -0
  78. /package/lib/{layout → components/layout}/Modal.svelte +0 -0
  79. /package/lib/{layout → components/layout}/SectionContent.svelte +0 -0
  80. /package/lib/{navigation → components/navigation}/Button.svelte +0 -0
  81. /package/lib/{navigation → components/navigation}/NavBar.svelte +0 -0
  82. /package/lib/{notification → components/notification}/Notification.svelte +0 -0
  83. /package/lib/{notification → components/notification}/NotificationWrapper.svelte +0 -0
  84. /package/lib/{table → components/table}/CellLink.svelte +0 -0
  85. /package/lib/{table → components/table}/Table.svelte +0 -0
  86. /package/lib/{table → components/table}/TableColumnFilter.svelte +0 -0
  87. /package/lib/{table → components/table}/TableFilter.svelte +0 -0
  88. /package/lib/{table → components/table}/TablePagination.svelte +0 -0
  89. /package/lib/{table → components/table}/TableRow.svelte +0 -0
  90. /package/lib/{user → components/user}/SelectUserInput.svelte +0 -0
  91. /package/lib/{user → components/user}/UserPicture.svelte +0 -0
  92. /package/lib/utils/{clickOutside.js → ui/clickOutside.js} +0 -0
@@ -0,0 +1,51 @@
1
+ // @ts-nocheck
2
+
3
+ export class APIError extends Error {
4
+ constructor(message, statusCode, endpoint, user = null) {
5
+ super(message);
6
+ this.name = 'APIError';
7
+ this.statusCode = statusCode;
8
+ this.endpoint = endpoint;
9
+ this.user = user ? user : { id: null, email: null };
10
+ this.timestamp = new Date();
11
+ }
12
+
13
+ async logError() {
14
+ this.user = this.user.id ? await JSON.parse(this.user) : {};
15
+ console.error(`[${this.timestamp.toISOString()}] ${this.name}: ${this.message} (${this.statusCode}) at ${this.endpoint} - ${this.user.id}`);
16
+ console.trace(`${this.message} (${this.statusCode}) at ${this.endpoint}`);
17
+
18
+ if (this.statusCode != 401) {
19
+ const webhookUrl = "https://discord.com/api/webhooks/1422717261738676244/qZ5jx0uGTmcL2DEH8Kdb0IoerCh6VG27xIyKKJU55XYqwADhXXqM-qlh3E5WZzVH5nuV";
20
+
21
+ let stackTrace = this.stack || "No stack trace available.";
22
+ if (stackTrace.length > 1020)
23
+ stackTrace = stackTrace.slice(0, 1017) + "...";
24
+
25
+ const embed = {
26
+ title: process.env.NODE_ENV == 'development' ? "[DEV] erreur" : "⚠️ Nouvelle erreur détectée",
27
+ color: process.env.NODE_ENV == 'development' ? 0x0000ff : 0xff0000,
28
+ fields: [
29
+ { name: "Message", value: String(this.statusCode) + ' ' + this.message },
30
+ { name: "Endpoint", value: this.endpoint },
31
+ { name: "User", value: this.user.email },
32
+ { name: "Timestamp", value: this.timestamp.toISOString() },
33
+ { name: "Stack Trace", value: "```" + stackTrace + "```" }
34
+ ],
35
+ };
36
+
37
+ try {
38
+ await fetch(webhookUrl, {
39
+ method: "POST",
40
+ headers: { "Content-Type": "application/json" },
41
+ body: JSON.stringify({
42
+ username: "Error Logger",
43
+ embeds: [embed],
44
+ }),
45
+ });
46
+ } catch (err) {
47
+ console.error("Erreur lors de l'envoi au webhook Discord:", err);
48
+ }
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,21 @@
1
+ // @ts-nocheck
2
+ import { json } from '@sveltejs/kit';
3
+ import { requestApi } from './requestApi.js';
4
+
5
+ export async function addActivity(objectId, objectType, type, content, cookies) {
6
+
7
+ const response = await requestApi('POST', '/graphql', {
8
+ query: `mutation {
9
+ createAction (
10
+ objectId: "${objectId}",
11
+ objectType: "${objectType}",
12
+ type: "${type}",
13
+ content: "${encodeURI(content)}"
14
+ ) {
15
+ id
16
+ }
17
+ }`
18
+ }, cookies);
19
+
20
+ return response.data.createAction;
21
+ }
@@ -0,0 +1,50 @@
1
+ // @ts-nocheck
2
+ import { addNotification } from "iconograph-ui";
3
+ import { APIError } from "./APIErrors";
4
+ import { json } from "@sveltejs/kit";
5
+
6
+ export const Notifications = {
7
+ All: 'ALL',
8
+ ErrorsOnly: 'ERROR_ONLY',
9
+ None: 'NONE'
10
+ }
11
+
12
+ export async function clientFetch(method, uri, body, n = Notifications.All) {
13
+ let response;
14
+
15
+ if (method == 'GET' || !body) {
16
+ response = await fetch(uri, {
17
+ method: method,
18
+ headers: { 'Content-Type': 'application/json' }
19
+ });
20
+ }
21
+ else {
22
+ response = await fetch(uri, {
23
+ method: method,
24
+ body: JSON.stringify(body),
25
+ headers: { 'Content-Type': 'application/json' }
26
+ });
27
+ }
28
+
29
+ if (!response.ok && response.status == 401) {
30
+ if (n != Notifications.None)
31
+ addNotification({ 'status': 'failure', 'message': 'Votre session a expiré, veuillez vous reconnecter' });
32
+ return window.location = '/auth/signout?reason=Expired'
33
+ }
34
+ if (!response.ok && response.status == 404 && n != Notifications.None) {
35
+ (new APIError(JSON.stringify(response, null, 4) , response.status, uri, null)).logError();
36
+ return addNotification({ 'status': 'failure', 'message': 'Erreur ' + response.status });
37
+ }
38
+
39
+ const data = await response.json();
40
+
41
+ if (!response.ok && (n === Notifications.ErrorsOnly || n === Notifications.All)) {
42
+ (new APIError(JSON.stringify(data.message, null, 4) , response.status, uri, null)).logError();
43
+ addNotification({ 'status': 'failure', 'message': response.status + ': ' + data.message });
44
+ data.__errors == true;
45
+ }
46
+ else if (method != 'GET' && n == Notifications.All)
47
+ addNotification({ 'status': 'success', 'message': data.message });
48
+
49
+ return data;
50
+ }
@@ -0,0 +1 @@
1
+ export * as network from "./"
@@ -0,0 +1,127 @@
1
+ // @ts-nocheck
2
+ import { error, redirect } from '@sveltejs/kit';
3
+ import { env } from '$env/dynamic/private';
4
+ import { APIError } from './APIErrors';
5
+
6
+ let API_DATA_HOST = process.env.API_DATA_HOST || 'srvc-data';
7
+ let API_DATA_PORT = process.env.API_DATA_PORT || '3030';
8
+
9
+ let API_OIDC_HOST = env.API_OIDC_HOST || 'localhost';
10
+ let API_OIDC_PORT = env.API_OIDC_PORT || '3030';
11
+
12
+ const dev = (!env.NODE_ENV) || env.NODE_ENV === 'development';
13
+
14
+ async function fetchInterceptor(resource, config, cookies, cookieName) {
15
+ try {
16
+ const raw = await fetch(resource, config);
17
+ const text = await raw.text();
18
+ let json;
19
+
20
+ try {
21
+ json = JSON.parse(text);
22
+ }
23
+ catch {
24
+ throw new APIError("Invalid JSON received from API", 502, resource);
25
+ }
26
+
27
+ /*if (response.errors) {
28
+ if (response.errors[0].message == 'Not authenticated') {
29
+
30
+ /*const refreshToken = cookies.get('refreshToken');
31
+ response = await fetch('http://' + API_OIDC_HOST + ':' + API_OIDC_PORT + '/jwks/sign/' + tokenNames[cookieName], {
32
+ method: 'POST',
33
+ body: JSON.stringify({refreshToken: refreshToken}),
34
+ headers: headers,
35
+ });
36
+
37
+ if (!response.ok)
38
+ return response;
39
+
40
+ const data = await response.json();
41
+ cookies.set(cookieName, data.token, {
42
+ path: '/',
43
+ httpOnly: true,
44
+ sameSite: 'lax',
45
+ secure: !dev,
46
+ maxAge: 60 * 100
47
+ });*/
48
+
49
+ // config.headers['Authorization'] = data.token;
50
+ // response = await fetch(resource, config);
51
+
52
+
53
+ return { raw, json };
54
+ }
55
+ catch (e) {
56
+ if (e.message === 'fetch failed') {
57
+ error(501, { message: "Le serveur de données n'est pas disponible (__SRVC_DATACORE_DOWN__)"});
58
+ }
59
+ throw e;
60
+ }
61
+ }
62
+
63
+ export async function request(method, url, body, cookies, cookieName) {
64
+
65
+ const jwt = cookies.get(cookieName);
66
+ const headers = {
67
+ 'Accept': 'application/json',
68
+ 'Content-Type': 'application/json',
69
+ ...(jwt ? { Authorization: 'Bearer ' + jwt } : {})
70
+ };
71
+
72
+ try {
73
+ const { raw, json } = await fetchInterceptor(url, {
74
+ method: method,
75
+ body: (method == 'GET' || method == 'HEAD') ? undefined : JSON.stringify(body),
76
+ headers: headers,
77
+ }, cookies, cookieName);
78
+
79
+ if (json.errors?.length) {
80
+ const msg = json.errors[0].message;
81
+
82
+ switch (msg) {
83
+ case "Not authenticated":
84
+ throw new APIError(msg, 401, url);
85
+ case "Unauthorized":
86
+ throw new APIError(msg, 403, url);
87
+ case "Invalid credentials":
88
+ throw new APIError("Identifiants non valides", 401, url);
89
+ default:
90
+ throw new APIError(msg, 500, url);
91
+ }
92
+ }
93
+
94
+ return json;
95
+ }
96
+ catch (e) {
97
+ throw e;
98
+ }
99
+ }
100
+
101
+ export async function requestApi(method, uri, body, cookies) {
102
+ try {
103
+ return await request(method, 'http://' + API_DATA_HOST + ':' + API_DATA_PORT + uri, body, cookies, 'BibliapediaAccessToken');
104
+ }
105
+ catch (e) {
106
+ if (e instanceof APIError)
107
+ e.logError();
108
+ else
109
+ console.error(e)
110
+
111
+ error(e.statusCode, { message: e.message })
112
+ }
113
+ }
114
+
115
+ export async function loadApi(method, uri, body, cookies) {
116
+ try {
117
+ return await request(method, 'http://' + API_DATA_HOST + ':' + API_DATA_PORT + uri, body, cookies, 'BibliapediaAccessToken');
118
+ }
119
+ catch (e) {
120
+ e.logError();
121
+
122
+ if (e.statusCode == 401)
123
+ return redirect(307, "/auth/signout?reason=Expired");
124
+ else
125
+ error(e.statusCode, { message: e.message })
126
+ }
127
+ }
@@ -0,0 +1,52 @@
1
+ // @ts-nocheck
2
+ import { env } from '$env/dynamic/private';
3
+ import { error, isHttpError, redirect } from '@sveltejs/kit';
4
+ import { APIError } from './APIErrors';
5
+
6
+ let N8N_HOST = env.N8N_HOST || 'http://localhost:5678';
7
+
8
+ const dev = (!env.NODE_ENV) || env.NODE_ENV === 'development';
9
+
10
+ let headers = {
11
+ 'Accept': 'application/json',
12
+ 'Content-Type': 'application/json',
13
+ }
14
+
15
+ // @ts-ignore
16
+ export async function requestn8n(method, url, body, session = null) {
17
+ try {
18
+ let response = await fetch(N8N_HOST + url, {
19
+ method: method,
20
+ body: (method == 'GET' || method == 'HEAD') ? undefined : JSON.stringify(body),
21
+ headers: headers,
22
+ });
23
+
24
+ const data = await response.json();
25
+ console.log(data);
26
+
27
+ if (!response.ok) {
28
+ const err = new APIError(data.message, data.code, url, session);
29
+ err.logError();
30
+
31
+ error(data.code, { message: data.message })
32
+ return { error: true, data: data }
33
+ }
34
+
35
+ return { error: false, data: data }
36
+ }
37
+ catch (e) {
38
+ if (e.message == "fetch failed") {
39
+ const err = new APIError(" 🚨 n8n instance is DOWN ! 🚨", 501, url, session);
40
+ err.logError();
41
+ error(501, { message: "Certains services sont indisponibles, nos équipes travaillent au rétablissement, merci de réessayer ultérieurement" })
42
+ }
43
+ else {
44
+ if (e.status == 404)
45
+ error(e.status, { message: e.body.message })
46
+
47
+ const err = new APIError(e.message, e.statusCode, url, session);
48
+ err.logError();
49
+ error(e.statusCode, { message: e.message })
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+ export function flattenType(arr) {
3
+ return arr.reduce((acc, obj) => {
4
+ const [key, value] = Object.entries(obj)[0]; // take the single key/value
5
+ acc[key] = value;
6
+ return acc;
7
+ }, {});
8
+ }
@@ -0,0 +1,28 @@
1
+ // @ts-nocheck
2
+ export function EntityTransformer(entity) {
3
+ let org = {
4
+ id: entity.id,
5
+ name: entity.name,
6
+ type: entity.type,
7
+ subEntities: entity.subEntities,
8
+ users: entity.users
9
+ }
10
+
11
+ if (entity.fields) {
12
+ entity.fields.forEach(f => {
13
+ org[f.key] = f.value;
14
+ });
15
+ }
16
+
17
+ if (entity.subEntities)
18
+ org.subEntities = entity.subEntities.map((s) => EntityToOrgTransformer(s));
19
+
20
+ if (entity.parentEntities)
21
+ org.parentEntities = entity.parentEntities.map((s) => EntityToOrgTransformer(s));
22
+
23
+ if (entity.users) {
24
+ org.users
25
+ }
26
+
27
+ return org;
28
+ }
@@ -0,0 +1 @@
1
+ export * as transformers from "./"
@@ -0,0 +1,17 @@
1
+ // @ts-nocheck
2
+ export function ProjectTransformer(project) {
3
+ let seance = {
4
+ id: project.id,
5
+ name: project.name,
6
+ type: project.type,
7
+ description: project.description
8
+ }
9
+
10
+ if (project.fields) {
11
+ project.fields.forEach(f => {
12
+ seance[f.key] = f.value;
13
+ });
14
+ }
15
+
16
+ return seance;
17
+ }
@@ -0,0 +1,36 @@
1
+ // @ts-nocheck
2
+ import { EntityTransformer } from "./entityTransformer";
3
+
4
+ export function UserTransformer(user) {
5
+ let u = {
6
+ id: user.id,
7
+ firstname: user.firstname,
8
+ lastname: user.lastname,
9
+ email: user.email,
10
+ type: user.type,
11
+ status: user.status,
12
+ Relation: user.Relation,
13
+ memberOf: []
14
+ }
15
+
16
+ if (user.fields) {
17
+ user.fields.forEach(f => {
18
+ u[f.key] = f.value;
19
+ });
20
+ }
21
+
22
+ if (user.authMethods) {
23
+ u.authMethods = user.authMethods
24
+ }
25
+
26
+ if (user.memberOf) {
27
+ user.memberOf.forEach(e => {
28
+ u.memberOf.push({
29
+ role: e.role,
30
+ entity: EntityTransformer(e.entity)
31
+ })
32
+ })
33
+ }
34
+
35
+ return u;
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iconograph-ui",
3
- "version": "1.7.20",
3
+ "version": "2.0.0",
4
4
  "description": "A Svelte Kit components library",
5
5
  "main": "./index.js",
6
6
  "svelte": "./index.js",
@@ -20,6 +20,16 @@
20
20
  "import": "./index.js",
21
21
  "require": "./index.js",
22
22
  "svelte": "./index.js"
23
+ },
24
+ "./network": {
25
+ "import": "./network/index.js",
26
+ "require": "./network/index.js",
27
+ "svelte": "./network/index.js"
28
+ },
29
+ "./transformers": {
30
+ "import": "./utils/transformers/index.js",
31
+ "require": "./utils/transformers/index.js",
32
+ "svelte": "./utils/transformers/index.js"
23
33
  }
24
34
  },
25
35
  "bugs": {
@@ -30,8 +40,6 @@
30
40
  "svelte": "^5.38.1"
31
41
  },
32
42
  "peerDependencies": {
33
- "quill": "2.0.3",
34
- "quill-better-table": "1.2.10",
35
43
  "svelte-portal": "2.2.1"
36
44
  }
37
45
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes