@insignia-education/api-sdk-js 0.9.26 → 0.9.29
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/AGENTS.md +9 -0
- package/package.json +1 -1
- package/src/api/v1/Files.js +16 -2
- package/src/api/v1/Users.js +15 -2
package/AGENTS.md
CHANGED
|
@@ -67,7 +67,16 @@ The SDK is language-neutral — it must never contain human-readable strings.
|
|
|
67
67
|
- Error objects thrown by the SDK must expose a machine-readable `status` (HTTP code) and `data` (raw API body). The consuming app handles translation.
|
|
68
68
|
- Do not add locale/language logic to the SDK — that belongs to the frontend.
|
|
69
69
|
|
|
70
|
+
## API ↔ SDK sync rule
|
|
71
|
+
|
|
72
|
+
**This SDK must stay in sync with [`insignia-education/api`](../api) at all times.** Any endpoint added, renamed, or removed in the API must be reflected here in the same task/commit.
|
|
73
|
+
|
|
74
|
+
- New endpoint in `api` → new method in the correct `src/api/v1/*.js` class
|
|
75
|
+
- Removed endpoint → remove or deprecate the corresponding SDK method
|
|
76
|
+
- Never leave the SDK behind the API; the `front` repo relies solely on this SDK
|
|
77
|
+
|
|
70
78
|
## Never do
|
|
71
79
|
- Don't add runtime dependencies
|
|
72
80
|
- Don't change the constructor signature of `InsigniaApiV1`
|
|
73
81
|
- Don't hardcode API base URLs — always receive from constructor
|
|
82
|
+
- Don't let the SDK lag behind `api` — update both in the same task
|
package/package.json
CHANGED
package/src/api/v1/Files.js
CHANGED
|
@@ -5,7 +5,21 @@ export default class Files {
|
|
|
5
5
|
this.#client = client;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/** List files in a directory. params: { organization_id, directory, per_page } */
|
|
9
|
+
list(params = {}) { return this.#client.get('/files', params); }
|
|
10
|
+
|
|
11
|
+
/** Get a single file record by ID. */
|
|
12
|
+
get(id) { return this.#client.get(`/files/${id}`); }
|
|
13
|
+
|
|
14
|
+
/** Upload a file (FormData). Supports: file, folder, organization_id, filename, generate_webp, … */
|
|
9
15
|
upload(formData) { return this.#client.upload('/files', formData); }
|
|
10
|
-
|
|
16
|
+
|
|
17
|
+
/** Create a logical folder. body: { organization_id, path } */
|
|
18
|
+
createFolder(body) { return this.#client.upload('/files/folder', body); }
|
|
19
|
+
|
|
20
|
+
/** Update file description. body: { description } */
|
|
21
|
+
update(id, body) { return this.#client.patch(`/files/${id}`, body); }
|
|
22
|
+
|
|
23
|
+
/** Soft-delete a file. Pass s3=true to also remove from S3. */
|
|
24
|
+
delete(id, s3 = false) { return this.#client.del(`/files/${id}${s3 ? '?s3=1' : ''}`); }
|
|
11
25
|
}
|
package/src/api/v1/Users.js
CHANGED
|
@@ -5,8 +5,10 @@ export default class Users {
|
|
|
5
5
|
this.#client = client;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
get(id = null)
|
|
9
|
-
|
|
8
|
+
get(id = null) { return id ? this.#client.get(`/users/${id}`) : this.#client.get('/users'); }
|
|
9
|
+
getByUsername(username) { return this.#client.get(`/users/username/${username}`); }
|
|
10
|
+
findByUsername(username) { return this.#client.get(`/users/find/${username}`); }
|
|
11
|
+
cashReceivers() { return this.#client.get('/users/cash-receivers'); }
|
|
10
12
|
edit(id, data) { return this.#client.patch(`/users/${id}`, data); }
|
|
11
13
|
|
|
12
14
|
#nested(userId, path) {
|
|
@@ -61,6 +63,17 @@ export default class Users {
|
|
|
61
63
|
|
|
62
64
|
statistics(userId) { return { get: () => this.#client.get(`/users/${userId}/statistics`) }; }
|
|
63
65
|
|
|
66
|
+
experiences(userId) {
|
|
67
|
+
const base = `/users/${userId}/experiences`;
|
|
68
|
+
const client = this.#client;
|
|
69
|
+
return {
|
|
70
|
+
get: (id = null) => id ? client.get(`${base}/${id}`) : client.get(base),
|
|
71
|
+
create: (data) => client.put(base, data),
|
|
72
|
+
edit: (id, data) => client.patch(`${base}/${id}`, data),
|
|
73
|
+
delete: (id) => client.del(`${base}/${id}`),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
64
77
|
organizations(userId) {
|
|
65
78
|
const base = `/users/${userId}/organizations`;
|
|
66
79
|
const client = this.#client;
|