@communecter/cocolight-api-client 1.0.54 → 1.0.56

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 (179) hide show
  1. package/dist/401.cocolight-api-client.browser.js +1 -0
  2. package/dist/401.cocolight-api-client.cjs +1 -0
  3. package/dist/401.cocolight-api-client.mjs.js +1 -0
  4. package/dist/588.cocolight-api-client.browser.js +1 -0
  5. package/dist/588.cocolight-api-client.cjs +1 -0
  6. package/dist/588.cocolight-api-client.mjs.js +1 -0
  7. package/dist/593.cocolight-api-client.browser.js +1 -0
  8. package/dist/593.cocolight-api-client.cjs +1 -0
  9. package/dist/593.cocolight-api-client.mjs.js +1 -0
  10. package/dist/839.cocolight-api-client.browser.js +1 -0
  11. package/dist/839.cocolight-api-client.cjs +1 -0
  12. package/dist/839.cocolight-api-client.mjs.js +1 -0
  13. package/dist/cocolight-api-client.browser.js +3 -3
  14. package/dist/cocolight-api-client.cjs +1 -1
  15. package/dist/cocolight-api-client.mjs.js +1 -1
  16. package/dist/cocolight-api-client.vite.mjs.js +1 -1
  17. package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
  18. package/package.json +29 -17
  19. package/src/{Api.js → Api.ts} +85 -95
  20. package/src/{ApiClient.js → ApiClient.ts} +436 -247
  21. package/src/EJSONType.ts +103 -0
  22. package/src/api/{Badge.js → Badge.ts} +56 -45
  23. package/src/api/BaseEntity.ts +3890 -0
  24. package/src/api/Comment.ts +200 -0
  25. package/src/api/{EndpointApi.js → EndpointApi.ts} +363 -297
  26. package/src/api/EndpointApi.types.ts +4609 -0
  27. package/src/api/EntityRegistry.ts +203 -0
  28. package/src/api/Event.ts +332 -0
  29. package/src/api/News.ts +331 -0
  30. package/src/api/{Organization.js → Organization.ts} +155 -119
  31. package/src/api/{Poi.js → Poi.ts} +68 -60
  32. package/src/api/{Project.js → Project.ts} +150 -127
  33. package/src/api/{User.js → User.ts} +321 -256
  34. package/src/api/UserApi.ts +148 -0
  35. package/src/api/serverDataType/Comment.ts +88 -0
  36. package/src/api/serverDataType/Event.ts +80 -0
  37. package/src/api/serverDataType/News.ts +138 -0
  38. package/src/api/serverDataType/Organization.ts +80 -0
  39. package/src/api/serverDataType/Project.ts +71 -0
  40. package/src/api/serverDataType/User.ts +103 -0
  41. package/src/api/serverDataType/common.ts +80 -0
  42. package/src/endpoints.module.ts +2621 -0
  43. package/src/error.ts +86 -0
  44. package/src/index.ts +86 -0
  45. package/src/mixin/UserMixin.ts +4 -0
  46. package/src/types/api-responses.ts +217 -0
  47. package/src/types/entities.ts +22 -0
  48. package/src/types/error-guards.ts +230 -0
  49. package/src/types/index.ts +39 -0
  50. package/src/types/payloads.ts +21 -0
  51. package/src/types/transforms.ts +110 -0
  52. package/src/utils/{FileOfflineStorageStrategy.node.js → FileOfflineStorageStrategy.node.ts} +15 -12
  53. package/src/utils/{FileStorageStrategy.node.js → FileStorageStrategy.node.ts} +16 -39
  54. package/src/utils/MultiServerFileStorageStrategy.node.ts +67 -0
  55. package/src/utils/MultiServerTokenStorageStrategy.ts +139 -0
  56. package/src/utils/{OfflineClientManager.js → OfflineClientManager.ts} +82 -86
  57. package/src/utils/OfflineQueueStorageStrategy.ts +47 -0
  58. package/src/utils/TokenStorage.ts +77 -0
  59. package/src/utils/compat.ts +12 -0
  60. package/src/utils/createDefaultMultiServerTokenStorageStrategy.ts +35 -0
  61. package/src/utils/{createDefaultOfflineStrategy.js → createDefaultOfflineStrategy.ts} +8 -3
  62. package/src/utils/createDefaultTokenStorageStrategy.ts +33 -0
  63. package/src/utils/{reactive.js → reactive.ts} +49 -40
  64. package/src/utils/stream-utils.node.ts +12 -0
  65. package/types/Api.d.ts +38 -82
  66. package/types/Api.d.ts.map +1 -0
  67. package/types/ApiClient.d.ts +244 -184
  68. package/types/ApiClient.d.ts.map +1 -0
  69. package/types/EJSONType.d.ts +48 -22
  70. package/types/EJSONType.d.ts.map +1 -0
  71. package/types/api/Badge.d.ts +20 -20
  72. package/types/api/Badge.d.ts.map +1 -0
  73. package/types/api/BaseEntity.d.ts +751 -446
  74. package/types/api/BaseEntity.d.ts.map +1 -0
  75. package/types/api/Comment.d.ts +36 -0
  76. package/types/api/EndpointApi.d.ts +347 -295
  77. package/types/api/EndpointApi.d.ts.map +1 -0
  78. package/types/api/EndpointApi.types.d.ts +3914 -4133
  79. package/types/api/EntityRegistry.d.ts +18 -16
  80. package/types/api/EntityRegistry.d.ts.map +1 -0
  81. package/types/api/Event.d.ts +119 -35
  82. package/types/api/Event.d.ts.map +1 -0
  83. package/types/api/News.d.ts +52 -20
  84. package/types/api/News.d.ts.map +1 -0
  85. package/types/api/Organization.d.ts +165 -49
  86. package/types/api/Organization.d.ts.map +1 -0
  87. package/types/api/Poi.d.ts +51 -22
  88. package/types/api/Poi.d.ts.map +1 -0
  89. package/types/api/Project.d.ts +151 -52
  90. package/types/api/Project.d.ts.map +1 -0
  91. package/types/api/User.d.ts +222 -93
  92. package/types/api/User.d.ts.map +1 -0
  93. package/types/api/UserApi.d.ts +60 -9
  94. package/types/api/UserApi.d.ts.map +1 -0
  95. package/types/api/serverDataType/Comment.d.ts +83 -0
  96. package/types/api/serverDataType/Event.d.ts +67 -0
  97. package/types/api/serverDataType/News.d.ts +130 -0
  98. package/types/api/serverDataType/Organization.d.ts +65 -0
  99. package/types/api/serverDataType/Organization.d.ts.map +1 -0
  100. package/types/api/serverDataType/Project.d.ts +58 -0
  101. package/types/api/serverDataType/Project.d.ts.map +1 -0
  102. package/types/api/serverDataType/User.d.ts +86 -0
  103. package/types/api/serverDataType/User.d.ts.map +1 -0
  104. package/types/api/serverDataType/common.d.ts +71 -0
  105. package/types/api/serverDataType/common.d.ts.map +1 -0
  106. package/types/endpoints.module.d.ts +6922 -1215
  107. package/types/endpoints.module.d.ts.map +1 -0
  108. package/types/error.d.ts +25 -51
  109. package/types/error.d.ts.map +1 -0
  110. package/types/index.d.ts +55 -48
  111. package/types/index.d.ts.map +1 -0
  112. package/types/mixin/UserMixin.d.ts +1 -1
  113. package/types/mixin/UserMixin.d.ts.map +1 -0
  114. package/types/types/api-responses.d.ts +190 -0
  115. package/types/types/api-responses.d.ts.map +1 -0
  116. package/types/types/entities.d.ts +17 -0
  117. package/types/types/entities.d.ts.map +1 -0
  118. package/types/types/error-guards.d.ts +99 -0
  119. package/types/types/error-guards.d.ts.map +1 -0
  120. package/types/types/index.d.ts +7 -0
  121. package/types/types/payloads.d.ts +17 -0
  122. package/types/types/payloads.d.ts.map +1 -0
  123. package/types/types/transforms.d.ts +79 -0
  124. package/types/types/transforms.d.ts.map +1 -0
  125. package/types/utils/FileOfflineStorageStrategy.node.d.ts +10 -9
  126. package/types/utils/FileOfflineStorageStrategy.node.d.ts.map +1 -0
  127. package/types/utils/FileStorageStrategy.node.d.ts +9 -20
  128. package/types/utils/FileStorageStrategy.node.d.ts.map +1 -0
  129. package/types/utils/MultiServerFileStorageStrategy.node.d.ts +13 -18
  130. package/types/utils/MultiServerFileStorageStrategy.node.d.ts.map +1 -0
  131. package/types/utils/MultiServerTokenStorageStrategy.d.ts +30 -51
  132. package/types/utils/MultiServerTokenStorageStrategy.d.ts.map +1 -0
  133. package/types/utils/OfflineClientManager.d.ts +52 -88
  134. package/types/utils/OfflineClientManager.d.ts.map +1 -0
  135. package/types/utils/OfflineQueueStorageStrategy.d.ts +12 -9
  136. package/types/utils/OfflineQueueStorageStrategy.d.ts.map +1 -0
  137. package/types/utils/TokenStorage.d.ts +20 -70
  138. package/types/utils/TokenStorage.d.ts.map +1 -0
  139. package/types/utils/compat.d.ts +4 -0
  140. package/types/utils/compat.d.ts.map +1 -0
  141. package/types/utils/createDefaultMultiServerTokenStorageStrategy.d.ts +2 -11
  142. package/types/utils/createDefaultMultiServerTokenStorageStrategy.d.ts.map +1 -0
  143. package/types/utils/createDefaultOfflineStrategy.d.ts +2 -3
  144. package/types/utils/createDefaultOfflineStrategy.d.ts.map +1 -0
  145. package/types/utils/createDefaultTokenStorageStrategy.d.ts +2 -12
  146. package/types/utils/createDefaultTokenStorageStrategy.d.ts.map +1 -0
  147. package/types/utils/reactive.d.ts +10 -16
  148. package/types/utils/reactive.d.ts.map +1 -0
  149. package/types/utils/stream-utils.node.d.ts +3 -2
  150. package/types/utils/stream-utils.node.d.ts.map +1 -0
  151. package/dist/123.cocolight-api-client.browser.js +0 -1
  152. package/dist/123.cocolight-api-client.cjs +0 -1
  153. package/dist/22.cocolight-api-client.mjs.js +0 -1
  154. package/dist/339.cocolight-api-client.mjs.js +0 -1
  155. package/dist/394.cocolight-api-client.browser.js +0 -1
  156. package/dist/394.cocolight-api-client.cjs +0 -1
  157. package/dist/405.cocolight-api-client.browser.js +0 -1
  158. package/dist/405.cocolight-api-client.cjs +0 -1
  159. package/dist/774.cocolight-api-client.mjs.js +0 -1
  160. package/dist/790.cocolight-api-client.mjs.js +0 -1
  161. package/dist/931.cocolight-api-client.browser.js +0 -1
  162. package/dist/931.cocolight-api-client.cjs +0 -1
  163. package/src/EJSONType.js +0 -53
  164. package/src/api/BaseEntity.js +0 -2828
  165. package/src/api/EntityRegistry.js +0 -152
  166. package/src/api/Event.js +0 -226
  167. package/src/api/News.js +0 -244
  168. package/src/api/UserApi.js +0 -81
  169. package/src/endpoints.module.js +0 -5
  170. package/src/error.js +0 -121
  171. package/src/index.js +0 -97
  172. package/src/mixin/UserMixin.js +0 -8
  173. package/src/utils/MultiServerFileStorageStrategy.node.js +0 -87
  174. package/src/utils/MultiServerTokenStorageStrategy.js +0 -188
  175. package/src/utils/OfflineQueueStorageStrategy.js +0 -51
  176. package/src/utils/TokenStorage.js +0 -153
  177. package/src/utils/createDefaultMultiServerTokenStorageStrategy.js +0 -51
  178. package/src/utils/createDefaultTokenStorageStrategy.js +0 -49
  179. package/src/utils/stream-utils.node.js +0 -10
@@ -1,18 +1,16 @@
1
- // reactive.js - Système maison combinant Signal + Proxy pour réactivité profonde et fine
1
+ // reactive.ts - Système maison combinant Signal + Proxy pour réactivité profonde et fine
2
2
 
3
- const effectStack = [];
3
+ const effectStack: (() => void)[] = [];
4
4
  const computedCache = new WeakMap();
5
5
  const signalRegistry = new WeakMap();
6
6
  let batchDepth = 0;
7
- const pendingEffects = new Set();
7
+ const pendingEffects = new Set<() => void>();
8
8
 
9
9
  /**
10
10
  * Crée une fonction réactive qui se relance automatiquement
11
11
  * lorsqu'une valeur réactive qu'elle utilise change.
12
- * @param {Function} fn
13
- * @returns {Function} le wrapper exécuté
14
12
  */
15
- export function effect(fn) {
13
+ export function effect(fn: () => void): () => void {
16
14
  const wrapper = () => {
17
15
  try {
18
16
  effectStack.push(wrapper);
@@ -28,10 +26,8 @@ export function effect(fn) {
28
26
  /**
29
27
  * Exécute une fonction dans un lot, en retardant l'exécution
30
28
  * des effets jusqu'à ce que le lot soit terminé.
31
- * @param {Function} fn
32
- * @returns {void}
33
29
  */
34
- export function batch(fn) {
30
+ export function batch(fn: () => void): void {
35
31
  batchDepth++;
36
32
  try {
37
33
  fn();
@@ -40,17 +36,15 @@ export function batch(fn) {
40
36
  if (batchDepth === 0) {
41
37
  const effects = Array.from(pendingEffects);
42
38
  pendingEffects.clear();
43
- for (const effect of effects) effect();
39
+ for (const effect of effects) (effect as () => void)();
44
40
  }
45
41
  }
46
42
  }
47
43
 
48
44
  /**
49
45
  * Crée un signal observable pour une valeur primitive ou complexe.
50
- * @param {*} initialValue
51
- * @returns {{value: *, subscribe: Function, __isSignal: boolean}}
52
46
  */
53
- function createSignal(initialValue) {
47
+ function createSignal(initialValue?: any): any {
54
48
  let value = initialValue;
55
49
  const subscribers = new Set();
56
50
 
@@ -64,13 +58,13 @@ function createSignal(initialValue) {
64
58
  if (value !== newValue) {
65
59
  value = newValue;
66
60
  if (batchDepth > 0) {
67
- subscribers.forEach((fn) => pendingEffects.add(fn));
61
+ subscribers.forEach((fn) => pendingEffects.add(fn as () => void));
68
62
  } else {
69
- subscribers.forEach((fn) => fn());
63
+ subscribers.forEach((fn) => (fn as () => void)());
70
64
  }
71
65
  }
72
66
  },
73
- subscribe(fn) {
67
+ subscribe(fn: any) {
74
68
  subscribers.add(fn);
75
69
  return () => subscribers.delete(fn);
76
70
  },
@@ -85,47 +79,62 @@ function createSignal(initialValue) {
85
79
  * @param {*} obj
86
80
  * @returns {boolean}
87
81
  */
88
- export function isSignal(obj) {
82
+ export function isSignal(obj: any) {
89
83
  return obj && obj.__isSignal === true;
90
84
  }
91
85
 
92
- function toRaw(obj) {
86
+ function toRaw(obj: any) {
93
87
  return isSignal(obj) ? obj.value : obj;
94
88
  }
95
89
 
96
- function _wrapArray(arr, path) {
90
+ function _wrapArray(arr: any[], path: string[]): any {
97
91
  const proxy = new Proxy(arr, {
98
- get(target, prop) {
99
- if (typeof prop === "string" && !isNaN(prop)) {
100
- const val = target[prop];
101
- return isReactive(val) ? val : reactive(val, path.concat(prop));
92
+ get(target, prop, receiver) {
93
+ if (typeof prop === "string" && !isNaN(+prop)) {
94
+ const val = target[+prop];
95
+ return isReactive(val) ? val : _wrapReactive(val, [...path, prop] as any);
102
96
  }
103
- return Reflect.get(target, prop);
97
+ return Reflect.get(target, prop, receiver);
104
98
  },
105
99
  set(target, prop, value) {
106
- const val = reactive(value, path.concat(prop));
107
- target[prop] = val;
100
+ if (typeof prop === "string" && !isNaN(+prop)) {
101
+ const val = _wrapReactive(value, [...path, prop] as any);
102
+ target[+prop] = val;
103
+ }
108
104
  return true;
109
105
  }
110
106
  });
111
107
  return proxy;
112
108
  }
113
109
 
114
- function _wrapReactive(obj, path = []) {
110
+ function _wrapReactive(obj: any, path: any = []) {
115
111
  if (typeof obj !== "object" || obj === null) return obj;
116
112
  if (Array.isArray(obj)) return _wrapArray(obj, path);
117
113
  if (obj.__isReactive) return obj;
118
114
 
115
+ // Ne pas proxifier les types d'upload (Buffer, File, Blob, Stream)
116
+ // car cela corromprait leurs données internes
117
+ // Buffer (Node.js)
118
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer(obj)) return obj;
119
+ // File (Browser)
120
+ if (typeof File !== "undefined" && obj instanceof File) return obj;
121
+ // Blob (Browser)
122
+ if (typeof Blob !== "undefined" && obj instanceof Blob) return obj;
123
+ // ReadableStream (Node.js)
124
+ if (obj && typeof obj.pipe === "function" && typeof obj.on === "function") return obj;
125
+ // Date objects
126
+ if (obj instanceof Date) return obj;
127
+
119
128
  const signalMap = new Map();
120
129
  const proxy = new Proxy(obj, {
121
- // eslint-disable-next-line no-unused-vars
122
- get(target, prop, receiver) {
130
+
131
+ get(target, prop) {
123
132
  if (prop === "__raw") return target;
124
133
  if (prop === "__isReactive") return true;
125
134
 
126
135
  if (!signalMap.has(prop)) {
127
136
  const val = target[prop];
128
- const reactiveVal = _wrapReactive(val, path.concat(prop));
137
+ const reactiveVal = _wrapReactive(val, [...path, String(prop)] as any);
129
138
  const signal = createSignal(reactiveVal);
130
139
  signalMap.set(prop, signal);
131
140
  }
@@ -135,12 +144,12 @@ function _wrapReactive(obj, path = []) {
135
144
  },
136
145
 
137
146
  set(target, prop, value) {
138
- const val = _wrapReactive(value, path.concat(prop));
147
+ const val = _wrapReactive(value, [...path, String(prop)] as any);
139
148
  if (!signalMap.has(prop)) {
140
149
  const signal = createSignal(val);
141
150
  signalMap.set(prop, signal);
142
151
  }
143
- signalMap.get(prop).value = val;
152
+ signalMap.get(prop)!.value = val;
144
153
  target[prop] = toRaw(val);
145
154
  return true;
146
155
  },
@@ -160,7 +169,7 @@ function _wrapReactive(obj, path = []) {
160
169
  * @param {object} obj
161
170
  * @returns {object}
162
171
  */
163
- export function reactive(obj) {
172
+ export function reactive(obj: any) {
164
173
  if (typeof obj !== "object" || obj === null) return obj;
165
174
  if (obj.__isReactive) return obj;
166
175
  return _wrapReactive(obj);
@@ -171,7 +180,7 @@ export function reactive(obj) {
171
180
  * @param {*} obj
172
181
  * @returns {boolean}
173
182
  */
174
- export function isReactive(obj) {
183
+ export function isReactive(obj: any) {
175
184
  return obj !== null && typeof obj === "object" && obj.__isReactive === true;
176
185
  }
177
186
 
@@ -180,7 +189,7 @@ export function isReactive(obj) {
180
189
  * @param {Function} fn
181
190
  * @returns {{value: *}}
182
191
  */
183
- export function computed(fn) {
192
+ export function computed(fn: any) {
184
193
  if (computedCache.has(fn)) return computedCache.get(fn);
185
194
 
186
195
  const result = createSignal();
@@ -194,8 +203,8 @@ export function computed(fn) {
194
203
  * @param {Function} getter
195
204
  * @param {Function} callback
196
205
  */
197
- export function watch(getter, callback) {
198
- let oldValue;
206
+ export function watch(getter: any, callback: any) {
207
+ let oldValue: any;
199
208
  effect(() => {
200
209
  const newValue = getter();
201
210
  if (newValue !== oldValue) {
@@ -206,11 +215,11 @@ export function watch(getter, callback) {
206
215
  }
207
216
 
208
217
  /**
209
- * Récupère les signaux internes dun objet réactif.
218
+ * Récupère les signaux internes d'un objet réactif.
210
219
  * @param {object} obj
211
220
  * @returns {Map|null}
212
221
  */
213
- export function getSignals(obj) {
222
+ export function getSignals(obj: any) {
214
223
  if (!isReactive(obj)) return null;
215
224
  return signalRegistry.get(obj);
216
225
  }
@@ -222,7 +231,7 @@ export function getSignals(obj) {
222
231
  * @param {(newValue: any, oldValue: any) => void} callback
223
232
  * @returns {() => void} fonction de nettoyage
224
233
  */
225
- export function subscribeTo(obj, key, callback) {
234
+ export function subscribeTo(obj: any, key: any, callback: any) {
226
235
  const signals = getSignals(obj);
227
236
  if (!signals || !signals.has(key)) return () => {};
228
237
  const signal = signals.get(key);
@@ -0,0 +1,12 @@
1
+ // utils/stream-utils.node.ts
2
+ import type { Readable, PassThrough } from "stream";
3
+
4
+ export async function bufferToReadable(buffer: Buffer): Promise<Readable> {
5
+ const { Readable } = await import("stream");
6
+ return Readable.from(buffer);
7
+ }
8
+
9
+ export async function createPassThrough(): Promise<PassThrough> {
10
+ const { PassThrough } = await import("stream");
11
+ return new PassThrough();
12
+ }
package/types/Api.d.ts CHANGED
@@ -1,131 +1,87 @@
1
- /** @typedef {import("./ApiClient.js").default} ApiClient */
2
- /** @typedef {import("./ApiClient.js").ApiClientOptions} ApiClientOptions */
1
+ import { Badge } from "./api/Badge.js";
2
+ import { Comment } from "./api/Comment.js";
3
+ import EndpointApi from "./api/EndpointApi.js";
4
+ import { Event } from "./api/Event.js";
5
+ import { News } from "./api/News.js";
6
+ import { Organization } from "./api/Organization.js";
7
+ import { Poi } from "./api/Poi.js";
8
+ import { Project } from "./api/Project.js";
9
+ import { User } from "./api/User.js";
10
+ import { UserApi } from "./api/UserApi.js";
11
+ import type ApiClient from "./ApiClient.js";
12
+ import type { ApiClientOptions } from "./ApiClient.js";
13
+ /**
14
+ * Union type for all possible entity types
15
+ */
16
+ type EntityTypes = User | Organization | Project | Event | Poi | Badge | News | Comment;
17
+ /**
18
+ * Type pour récupérer une entité existante via l'API publique.
19
+ * Nécessite soit un id, soit un slug.
20
+ * Les propriétés additionnelles sont autorisées mais ignorées lors de la récupération.
21
+ */
22
+ type EntityData = {
23
+ id: string;
24
+ slug?: string;
25
+ [key: string]: any;
26
+ } | {
27
+ slug: string;
28
+ id?: string;
29
+ [key: string]: any;
30
+ };
3
31
  export default class Api {
32
+ private _loggedUser;
33
+ private _client;
4
34
  /**
5
35
  * Authentifie l'utilisateur et retourne une instance d'Api.
6
- *
7
- * @param {string} email - L'adresse email.
8
- * @param {string} password - Le mot de passe.
9
- * @param {ApiClientOptions|ApiClient} options - Options pour l'ApiClient ou instance existante.
10
- * @returns {Promise<Api>}
11
- * @throws {ApiAuthenticationError|ApiClientError|ApiError}
12
36
  */
13
37
  static userLogin(email: string, password: string, options: ApiClientOptions | ApiClient): Promise<Api>;
14
38
  /**
15
39
  * Crée une instance de UserApi avec les options fournies.
16
- *
17
- * @param {ApiClientOptions|ApiClient} options - Options pour ApiClient ou instance d'ApiClient.
18
- * @returns {UserApi}
19
- * @throws {Error}
20
40
  */
21
41
  static userApi(options: ApiClientOptions | ApiClient): UserApi;
22
42
  /**
23
43
  * Connecte un utilisateur avec un UserApi existant.
24
- *
25
- * @param {UserApi} userApi - Instance UserApi utilisée pour l'authentification.
26
- * @param {string} email - Email de l'utilisateur.
27
- * @param {string} password - Mot de passe de l'utilisateur.
28
- * @returns {Promise<Api>}
29
- * @throws {ApiAuthenticationError|ApiClientError|ApiError}
30
44
  */
31
45
  static userApiLogin(userApi: UserApi, email: string, password: string): Promise<Api>;
32
46
  /**
33
47
  * Construit une instance d'Api.
34
- *
35
- * @param {User|null} loggedUser - L'utilisateur connecté ou null.
36
- * @param {ApiClient} client - L'instance d'ApiClient.
37
48
  */
38
49
  constructor(loggedUser: User | null, client: ApiClient);
39
- _loggedUser: User;
40
- _client: import("./ApiClient.js").default;
41
50
  /**
42
51
  * Retourne l'utilisateur connecté.
43
- *
44
- * @returns {Promise<User>} L'utilisateur connecté.
45
- * @throws {ApiAuthenticationError} Si l'utilisateur n'est pas authentifié.
46
52
  */
47
53
  me(): Promise<User>;
48
54
  /**
49
55
  * Crée une instance User (autre que le connecté).
50
- *
51
- * @param {{id?: string, slug?: string, [k: string]: any}} userData
52
- * @returns {Promise<User>}
53
- * @throws {Error}
54
56
  */
55
- user(userData: {
56
- id?: string;
57
- slug?: string;
58
- [k: string]: any;
59
- }): Promise<User>;
57
+ user(userData: EntityData): Promise<User>;
60
58
  /**
61
59
  * Creates an Organization object and optionally retrieves its profile.
62
- *
63
- * @param {{id?: string, slug?: string, [k: string]: any}} organizationData - The data required to initialize the Organization object.
64
- * @returns {Promise<Organization>} A promise that resolves to the created Organization object.
65
- * @throws {Error} Throws an error if the organization creation or profile retrieval fails.
66
60
  */
67
- organization(organizationData: {
68
- id?: string;
69
- slug?: string;
70
- [k: string]: any;
71
- }): Promise<Organization>;
61
+ organization(organizationData: EntityData): Promise<Organization>;
72
62
  /**
73
63
  * Creates a new Project instance and optionally retrieves its profile.
74
- *
75
- * @param {{id?: string, slug?: string, [k: string]: any}} projectData - The data used to initialize the Project instance.
76
- * @returns {Promise<Project>} A promise that resolves to the created Project instance.
77
- * @throws {Error} If an error occurs during project creation or profile retrieval.
78
64
  */
79
- project(projectData: {
80
- id?: string;
81
- slug?: string;
82
- [k: string]: any;
83
- }): Promise<Project>;
65
+ project(projectData: EntityData): Promise<Project>;
84
66
  /**
85
67
  * Creates a new Event instance and optionally retrieves its profile.
86
- *
87
- * @param {{id?: string, slug?: string, [k: string]: any}} eventData
88
- * @returns {Promise<Event>}
89
- * @throws {Error}
90
68
  */
91
- event(eventData: {
92
- id?: string;
93
- slug?: string;
94
- [k: string]: any;
95
- }): Promise<Event>;
69
+ event(eventData: EntityData): Promise<Event>;
96
70
  /**
97
71
  * Retourne une entité à partir d'un slug.
98
- *
99
- * @param {string} slug
100
- * @returns {Promise<User|Organization|Project|Event|Poi|Badge|News>}
101
- * @throws {ApiResponseError|ApiClientError|ApiError}
102
72
  */
103
- entitySlug(slug: string): Promise<User | Organization | Project | Event | Poi | Badge | News>;
73
+ entitySlug(slug: string): Promise<EntityTypes>;
104
74
  /**
105
75
  * Retourne l'instance d'ApiClient.
106
- * @returns {ApiClient}
107
76
  */
108
77
  get client(): ApiClient;
109
78
  /**
110
79
  * Retourne l'instance d'EndpointApi.
111
- * @returns {EndpointApi}
112
80
  */
113
81
  get endpointApi(): EndpointApi;
114
82
  /**
115
83
  * Déconnecte l'utilisateur et réinitialise la session.
116
- * @returns {void}
117
84
  */
118
85
  logout(): void;
119
- loggedUser: any;
120
86
  }
121
- export type ApiClient = import("./ApiClient.js").default;
122
- export type ApiClientOptions = import("./ApiClient.js").ApiClientOptions;
123
- import { User } from "./api/User.js";
124
- import { Organization } from "./api/Organization.js";
125
- import { Project } from "./api/Project.js";
126
- import { Event } from "./api/Event.js";
127
- import { Poi } from "./api/Poi.js";
128
- import { Badge } from "./api/Badge.js";
129
- import { News } from "./api/News.js";
130
- import EndpointApi from "./api/EndpointApi.js";
131
- import { UserApi } from "./api/UserApi.js";
87
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../src/Api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,WAAW,MAAM,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