@cccsaurora/howler-ui 2.19.0-dev.1000 → 2.19.0-dev.1023

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 (56) hide show
  1. package/api/action/index.d.ts +5 -4
  2. package/api/action/index.js +8 -8
  3. package/api/analytic/index.d.ts +3 -2
  4. package/api/analytic/index.js +4 -4
  5. package/api/analytic/owner.d.ts +2 -1
  6. package/api/analytic/owner.js +2 -2
  7. package/api/analytic/rules.d.ts +2 -1
  8. package/api/analytic/rules.js +2 -2
  9. package/api/dossier/index.d.ts +4 -3
  10. package/api/dossier/index.js +6 -6
  11. package/api/hit/index.d.ts +3 -2
  12. package/api/hit/index.js +4 -4
  13. package/api/hit/labels.d.ts +3 -2
  14. package/api/hit/labels.js +4 -4
  15. package/api/hit/overwrite.d.ts +2 -1
  16. package/api/hit/overwrite.js +2 -2
  17. package/api/hit/transition.d.ts +2 -1
  18. package/api/hit/transition.js +2 -2
  19. package/api/index.d.ts +5 -4
  20. package/api/index.js +8 -8
  21. package/api/overview/index.d.ts +4 -3
  22. package/api/overview/index.js +6 -6
  23. package/api/search/overview.d.ts +2 -2
  24. package/api/template/index.d.ts +4 -3
  25. package/api/template/index.js +6 -6
  26. package/api/user/index.d.ts +2 -1
  27. package/api/user/index.js +2 -2
  28. package/api/view/index.d.ts +4 -3
  29. package/api/view/index.js +6 -6
  30. package/components/app/providers/SearchResponseProvider.d.ts +21 -0
  31. package/components/app/providers/SearchResponseProvider.js +81 -0
  32. package/components/app/providers/SearchResponseProvider.test.d.ts +1 -0
  33. package/components/app/providers/SearchResponseProvider.test.js +406 -0
  34. package/components/app/providers/ViewProvider.test.js +4 -1
  35. package/components/elements/addons/search/SearchPagination.d.ts +2 -1
  36. package/components/elements/addons/search/SearchPagination.js +4 -4
  37. package/components/elements/addons/search/SearchTotal.test.js +3 -1
  38. package/components/elements/display/ItemManager.d.ts +2 -2
  39. package/components/elements/display/ItemManager.js +1 -1
  40. package/components/hooks/useMyApi.d.ts +1 -1
  41. package/components/routes/action/useMyActionFunctions.js +5 -2
  42. package/components/routes/action/view/ActionDetails.js +7 -1
  43. package/components/routes/action/view/ActionSearch.js +20 -14
  44. package/components/routes/analytics/AnalyticDetails.js +1 -1
  45. package/components/routes/analytics/AnalyticSearch.js +6 -6
  46. package/components/routes/dossiers/Dossiers.js +13 -11
  47. package/components/routes/home/AddNewCard.test.js +20 -2
  48. package/components/routes/home/ViewRefresh.test.js +1 -1
  49. package/components/routes/overviews/OverviewViewer.js +6 -2
  50. package/components/routes/overviews/Overviews.js +13 -11
  51. package/components/routes/templates/TemplateViewer.js +7 -2
  52. package/components/routes/templates/Templates.js +16 -11
  53. package/components/routes/views/Views.js +15 -12
  54. package/locales/en/translation.json +4 -1
  55. package/locales/fr/translation.json +4 -1
  56. package/package.json +103 -103
@@ -1,10 +1,11 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import * as execute from '@cccsaurora/howler-ui/api/action/execute';
2
3
  import * as operations from '@cccsaurora/howler-ui/api/action/operations';
3
4
  import type { Action } from '@cccsaurora/howler-ui/models/entities/generated/Action';
4
5
  export declare const uri: (id?: string) => string;
5
6
  export declare const get: (id: string) => Promise<Action>;
6
- export declare const post: (data: Action) => Promise<Action>;
7
- export declare const put: (id: string, data: Action) => Promise<Action>;
8
- export declare const patch: (id: string, data: Action) => Promise<Action>;
9
- export declare const del: (id: string) => Promise<void>;
7
+ export declare const post: (data: Action, refresh?: HowlerRefreshParam) => Promise<Action>;
8
+ export declare const put: (id: string, data: Action, refresh?: HowlerRefreshParam) => Promise<Action>;
9
+ export declare const patch: (id: string, data: Action, refresh?: HowlerRefreshParam) => Promise<Action>;
10
+ export declare const del: (id: string, refresh?: HowlerRefreshParam) => Promise<void>;
10
11
  export { execute, operations };
@@ -13,16 +13,16 @@ export const get = (id) => {
13
13
  })
14
14
  .then(res => res.items[0]);
15
15
  };
16
- export const post = (data) => {
17
- return hpost(uri(), data);
16
+ export const post = (data, refresh) => {
17
+ return hpost(uri(), data, {}, refresh ? new URLSearchParams({ refresh }) : undefined);
18
18
  };
19
- export const put = (id, data) => {
20
- return hput(uri(id), data);
19
+ export const put = (id, data, refresh) => {
20
+ return hput(uri(id), data, {}, refresh ? new URLSearchParams({ refresh }) : undefined);
21
21
  };
22
- export const patch = (id, data) => {
23
- return hpatch(uri(id), data);
22
+ export const patch = (id, data, refresh) => {
23
+ return hpatch(uri(id), data, {}, refresh ? new URLSearchParams({ refresh }) : undefined);
24
24
  };
25
- export const del = (id) => {
26
- return hdelete(uri(id));
25
+ export const del = (id, refresh) => {
26
+ return hdelete(uri(id), undefined, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
27
27
  };
28
28
  export { execute, operations };
@@ -1,3 +1,4 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import * as comments from '@cccsaurora/howler-ui/api/analytic/comments';
2
3
  import * as favourite from '@cccsaurora/howler-ui/api/analytic/favourite';
3
4
  import * as notebooks from '@cccsaurora/howler-ui/api/analytic/notebooks';
@@ -7,6 +8,6 @@ import type { Analytic } from '@cccsaurora/howler-ui/models/entities/generated/A
7
8
  export type EditOptions = Pick<Analytic, 'description' | 'rule' | 'rule_crontab' | 'triage_settings'>;
8
9
  export declare const uri: (id?: string) => string;
9
10
  export declare const get: (id?: string) => Promise<Analytic> | Promise<Analytic[]>;
10
- export declare const put: (id: string, editData: EditOptions) => Promise<Analytic>;
11
- export declare const del: (id: string) => Promise<any>;
11
+ export declare const put: (id: string, editData: EditOptions, refresh?: HowlerRefreshParam) => Promise<Analytic>;
12
+ export declare const del: (id: string, refresh?: HowlerRefreshParam) => Promise<void>;
12
13
  export { comments, favourite, notebooks, owner, rules };
@@ -10,10 +10,10 @@ export const uri = (id) => {
10
10
  export const get = (id) => {
11
11
  return id ? hget(uri(id)) : hget(uri());
12
12
  };
13
- export const put = (id, editData) => {
14
- return hput(uri(id), editData);
13
+ export const put = (id, editData, refresh) => {
14
+ return hput(uri(id), editData, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
15
15
  };
16
- export const del = (id) => {
17
- return hdelete(uri(id));
16
+ export const del = (id, refresh) => {
17
+ return hdelete(uri(id), undefined, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
18
18
  };
19
19
  export { comments, favourite, notebooks, owner, rules };
@@ -1,5 +1,6 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import type { Analytic } from '@cccsaurora/howler-ui/models/entities/generated/Analytic';
2
3
  export declare const uri: (id: string) => string;
3
4
  export declare const post: (id: string, body: {
4
5
  username: string;
5
- }) => Promise<Analytic>;
6
+ }, refresh?: HowlerRefreshParam) => Promise<Analytic>;
@@ -3,6 +3,6 @@ import { uri as parentUri } from '@cccsaurora/howler-ui/api/analytic';
3
3
  export const uri = (id) => {
4
4
  return joinAllUri(parentUri(), id, 'owner');
5
5
  };
6
- export const post = (id, body) => {
7
- return hpost(uri(id), body);
6
+ export const post = (id, body, refresh) => {
7
+ return hpost(uri(id), body, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
8
8
  };
@@ -1,3 +1,4 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import type { Analytic } from '@cccsaurora/howler-ui/models/entities/generated/Analytic';
2
3
  export declare const uri: () => string;
3
- export declare const post: (body: Pick<Analytic, "description" | "name" | "rule" | "rule_type" | "rule_crontab">) => Promise<Analytic>;
4
+ export declare const post: (body: Pick<Analytic, "description" | "name" | "rule" | "rule_type" | "rule_crontab">, refresh?: HowlerRefreshParam) => Promise<Analytic>;
@@ -3,6 +3,6 @@ import { uri as parentUri } from '@cccsaurora/howler-ui/api/analytic';
3
3
  export const uri = () => {
4
4
  return joinUri(parentUri(), 'rules');
5
5
  };
6
- export const post = (body) => {
7
- return hpost(uri(), body);
6
+ export const post = (body, refresh) => {
7
+ return hpost(uri(), body, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
8
8
  };
@@ -1,8 +1,9 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import type { Dossier } from '@cccsaurora/howler-ui/models/entities/generated/Dossier';
2
3
  import * as hit from './hit';
3
4
  export declare const uri: (id?: string) => string;
4
5
  export declare const get: (id?: string) => Promise<Dossier | Dossier[]>;
5
- export declare const post: (newData: Partial<Dossier>) => Promise<Dossier>;
6
- export declare const put: (id: string, dossier: Partial<Dossier>) => Promise<Dossier>;
7
- export declare const del: (id: string) => Promise<void>;
6
+ export declare const post: (newData: Partial<Dossier>, refresh?: HowlerRefreshParam) => Promise<Dossier>;
7
+ export declare const put: (id: string, dossier: Partial<Dossier>, refresh?: HowlerRefreshParam) => Promise<Dossier>;
8
+ export declare const del: (id: string, refresh?: HowlerRefreshParam) => Promise<void>;
8
9
  export { hit };
@@ -7,13 +7,13 @@ export const uri = (id) => {
7
7
  export const get = (id) => {
8
8
  return hget(uri(id));
9
9
  };
10
- export const post = (newData) => {
11
- return hpost(uri(), newData);
10
+ export const post = (newData, refresh) => {
11
+ return hpost(uri(), newData, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
12
12
  };
13
- export const put = (id, dossier) => {
14
- return hput(uri(id), dossier);
13
+ export const put = (id, dossier, refresh) => {
14
+ return hput(uri(id), dossier, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
15
15
  };
16
- export const del = (id) => {
17
- return hdelete(uri(id));
16
+ export const del = (id, refresh) => {
17
+ return hdelete(uri(id), undefined, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
18
18
  };
19
19
  export { hit };
@@ -1,3 +1,4 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import * as assign from '@cccsaurora/howler-ui/api/hit/assign';
2
3
  import * as comments from '@cccsaurora/howler-ui/api/hit/comments';
3
4
  import * as labels from '@cccsaurora/howler-ui/api/hit/labels';
@@ -28,8 +29,8 @@ interface PostResponse {
28
29
  error: string;
29
30
  }[];
30
31
  }
31
- export declare const post: (hits: Hit[]) => Promise<PostResponse>;
32
- export declare const del: (ids: string[]) => Promise<{
32
+ export declare const post: (hits: Hit[], refresh?: HowlerRefreshParam) => Promise<PostResponse>;
33
+ export declare const del: (ids: string[], refresh?: HowlerRefreshParam) => Promise<{
33
34
  success: boolean;
34
35
  }>;
35
36
  export { assign, comments, labels, overwrite, transition };
package/api/hit/index.js CHANGED
@@ -14,10 +14,10 @@ export const get = (id, metadata) => {
14
14
  }
15
15
  return hget(uri(id), params);
16
16
  };
17
- export const post = (hits) => {
18
- return hpost(uri(), hits);
17
+ export const post = (hits, refresh) => {
18
+ return hpost(uri(), hits, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
19
19
  };
20
- export const del = (ids) => {
21
- return hdelete(uri(), ids);
20
+ export const del = (ids, refresh) => {
21
+ return hdelete(uri(), ids, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
22
22
  };
23
23
  export { assign, comments, labels, overwrite, transition };
@@ -1,5 +1,6 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import type { LabelActionBody } from '@cccsaurora/howler-ui/api/hit';
2
3
  import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
3
4
  export declare const uri: (id: string, category: string) => string;
4
- export declare const put: (id: string, category: string, body: LabelActionBody) => Promise<Hit>;
5
- export declare const del: (id: string, category: string, body: LabelActionBody) => Promise<Hit>;
5
+ export declare const put: (id: string, category: string, body: LabelActionBody, refresh?: HowlerRefreshParam) => Promise<Hit>;
6
+ export declare const del: (id: string, category: string, body: LabelActionBody, refresh?: HowlerRefreshParam) => Promise<Hit>;
package/api/hit/labels.js CHANGED
@@ -3,9 +3,9 @@ import { uri as parentUri } from '@cccsaurora/howler-ui/api/hit';
3
3
  export const uri = (id, category) => {
4
4
  return joinAllUri(parentUri(), id, 'labels', category);
5
5
  };
6
- export const put = (id, category, body) => {
7
- return hput(uri(id, category), body);
6
+ export const put = (id, category, body, refresh) => {
7
+ return hput(uri(id, category), body, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
8
8
  };
9
- export const del = (id, category, body) => {
10
- return hdelete(uri(id, category), body);
9
+ export const del = (id, category, body, refresh) => {
10
+ return hdelete(uri(id, category), body, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
11
11
  };
@@ -1,3 +1,4 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
2
3
  export declare const uri: (id: string) => string;
3
- export declare const put: <T extends Hit = Hit>(id: string, body: Partial<T>) => Promise<T>;
4
+ export declare const put: <T extends Hit = Hit>(id: string, body: Partial<T>, refresh?: HowlerRefreshParam) => Promise<T>;
@@ -3,6 +3,6 @@ import { uri as parentUri } from '@cccsaurora/howler-ui/api/hit';
3
3
  export const uri = (id) => {
4
4
  return joinAllUri(parentUri(), id, 'overwrite');
5
5
  };
6
- export const put = (id, body) => {
7
- return hput(uri(id), body);
6
+ export const put = (id, body, refresh) => {
7
+ return hput(uri(id), body, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
8
8
  };
@@ -1,4 +1,5 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import type { HitTransitionBody } from '@cccsaurora/howler-ui/api/hit';
2
3
  import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
3
4
  export declare const uri: (id: string) => string;
4
- export declare const post: (id: string, body: HitTransitionBody) => Promise<Hit>;
5
+ export declare const post: (id: string, body: HitTransitionBody, refresh?: HowlerRefreshParam) => Promise<Hit>;
@@ -3,6 +3,6 @@ import { uri as parentUri } from '@cccsaurora/howler-ui/api/hit';
3
3
  export const uri = (id) => {
4
4
  return joinAllUri(parentUri(), id, 'transition');
5
5
  };
6
- export const post = (id, body) => {
7
- return hpost(uri(id), body);
6
+ export const post = (id, body, refresh) => {
7
+ return hpost(uri(id), body, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
8
8
  };
package/api/index.d.ts CHANGED
@@ -38,6 +38,7 @@ export type HowlerResponse<R> = {
38
38
  api_server_version: string;
39
39
  api_status_code: number;
40
40
  };
41
+ export type HowlerRefreshParam = 'true' | 'false' | 'wait_for';
41
42
  /**
42
43
  * The base section of the Howler API uri.
43
44
  *
@@ -106,7 +107,7 @@ export declare const hget: <R = any>(_uri: string, searchParams?: URLSearchParam
106
107
  * @param body - the body of the request.
107
108
  * @returns the `api_response` object of the returned {@link HowlerResponse}.
108
109
  */
109
- export declare const hpost: <R = any>(_uri: string, body: any, headers?: HeadersInit) => Promise<R>;
110
+ export declare const hpost: <R = any>(_uri: string, body: any, headers?: HeadersInit, searchParams?: URLSearchParams) => Promise<R>;
110
111
  /**
111
112
  * Peform an HTTP PUT for the specified uri and body data.
112
113
  *
@@ -116,7 +117,7 @@ export declare const hpost: <R = any>(_uri: string, body: any, headers?: Headers
116
117
  * @param body - the body of the request.
117
118
  * @returns the `api_response` object of the returned {@link HowlerResponse}.
118
119
  */
119
- export declare const hput: <R = any>(_uri: string, body: any, headers?: HeadersInit) => Promise<R>;
120
+ export declare const hput: <R = any>(_uri: string, body: any, headers?: HeadersInit, searchParams?: URLSearchParams) => Promise<R>;
120
121
  /**
121
122
  * Peform an HTTP PATCH for the specified uri and body data.
122
123
  *
@@ -126,7 +127,7 @@ export declare const hput: <R = any>(_uri: string, body: any, headers?: HeadersI
126
127
  * @param body - the body of the request.
127
128
  * @returns the `api_response` object of the returned {@link HowlerResponse}.
128
129
  */
129
- export declare const hpatch: <R = any>(_uri: string, body: any, headers?: HeadersInit) => Promise<R>;
130
+ export declare const hpatch: <R = any>(_uri: string, body: any, headers?: HeadersInit, searchParams?: URLSearchParams) => Promise<R>;
130
131
  /**
131
132
  * Performa an HTTP DELETE for the specified uri.
132
133
  *
@@ -135,7 +136,7 @@ export declare const hpatch: <R = any>(_uri: string, body: any, headers?: Header
135
136
  * @param _uri - the uri to fetch.
136
137
  * @returns the `api_response` object of the returned {@link HowlerResponse}.
137
138
  */
138
- export declare const hdelete: <R = any>(_uri: string, body?: any, headers?: HeadersInit) => Promise<R>;
139
+ export declare const hdelete: <R = any>(_uri: string, body?: any, headers?: HeadersInit, searchParams?: URLSearchParams) => Promise<R>;
139
140
  /**
140
141
  * Default export exposing the howler rest api
141
142
  */
package/api/index.js CHANGED
@@ -196,8 +196,8 @@ export const hget = (_uri, searchParams, headers = {}) => {
196
196
  * @param body - the body of the request.
197
197
  * @returns the `api_response` object of the returned {@link HowlerResponse}.
198
198
  */
199
- export const hpost = (_uri, body, headers = {}) => {
200
- return hfetch(_uri, 'post', body, undefined, headers);
199
+ export const hpost = (_uri, body, headers = {}, searchParams) => {
200
+ return hfetch(_uri, 'post', body, searchParams, headers);
201
201
  };
202
202
  /**
203
203
  * Peform an HTTP PUT for the specified uri and body data.
@@ -208,8 +208,8 @@ export const hpost = (_uri, body, headers = {}) => {
208
208
  * @param body - the body of the request.
209
209
  * @returns the `api_response` object of the returned {@link HowlerResponse}.
210
210
  */
211
- export const hput = (_uri, body, headers = {}) => {
212
- return hfetch(_uri, 'put', body, undefined, headers);
211
+ export const hput = (_uri, body, headers = {}, searchParams) => {
212
+ return hfetch(_uri, 'put', body, searchParams, headers);
213
213
  };
214
214
  /**
215
215
  * Peform an HTTP PATCH for the specified uri and body data.
@@ -220,8 +220,8 @@ export const hput = (_uri, body, headers = {}) => {
220
220
  * @param body - the body of the request.
221
221
  * @returns the `api_response` object of the returned {@link HowlerResponse}.
222
222
  */
223
- export const hpatch = (_uri, body, headers = {}) => {
224
- return hfetch(_uri, 'patch', body, undefined, headers);
223
+ export const hpatch = (_uri, body, headers = {}, searchParams) => {
224
+ return hfetch(_uri, 'patch', body, searchParams, headers);
225
225
  };
226
226
  /**
227
227
  * Performa an HTTP DELETE for the specified uri.
@@ -231,8 +231,8 @@ export const hpatch = (_uri, body, headers = {}) => {
231
231
  * @param _uri - the uri to fetch.
232
232
  * @returns the `api_response` object of the returned {@link HowlerResponse}.
233
233
  */
234
- export const hdelete = (_uri, body = null, headers = {}) => {
235
- return hfetch(_uri, 'delete', body, undefined, headers);
234
+ export const hdelete = (_uri, body = null, headers = {}, searchParams) => {
235
+ return hfetch(_uri, 'delete', body, searchParams, headers);
236
236
  };
237
237
  /**
238
238
  * Default export exposing the howler rest api
@@ -1,6 +1,7 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import type { Overview } from '@cccsaurora/howler-ui/models/entities/generated/Overview';
2
3
  export declare const uri: (id?: string) => string;
3
4
  export declare const get: () => Promise<Overview[]>;
4
- export declare const post: (newData: Partial<Overview>) => Promise<Overview>;
5
- export declare const put: (id: string, content: string) => Promise<Overview>;
6
- export declare const del: (id: string) => Promise<void>;
5
+ export declare const post: (newData: Partial<Overview>, refresh?: HowlerRefreshParam) => Promise<Overview>;
6
+ export declare const put: (id: string, content: string, refresh?: HowlerRefreshParam) => Promise<Overview>;
7
+ export declare const del: (id: string, refresh?: HowlerRefreshParam) => Promise<void>;
@@ -5,12 +5,12 @@ export const uri = (id) => {
5
5
  export const get = () => {
6
6
  return hget(uri());
7
7
  };
8
- export const post = (newData) => {
9
- return hpost(uri(), newData);
8
+ export const post = (newData, refresh) => {
9
+ return hpost(uri(), newData, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
10
10
  };
11
- export const put = (id, content) => {
12
- return hput(uri(id), { content });
11
+ export const put = (id, content, refresh) => {
12
+ return hput(uri(id), { content }, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
13
13
  };
14
- export const del = (id) => {
15
- return hdelete(uri(id));
14
+ export const del = (id, refresh) => {
15
+ return hdelete(uri(id), undefined, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
16
16
  };
@@ -1,4 +1,4 @@
1
1
  import type { HowlerSearchRequest, HowlerSearchResponse } from '@cccsaurora/howler-ui/api/search';
2
- import type { Template } from '@cccsaurora/howler-ui/models/entities/generated/Template';
2
+ import type { Overview } from '@cccsaurora/howler-ui/models/entities/generated/Overview';
3
3
  export declare const uri: () => string;
4
- export declare const post: (request?: HowlerSearchRequest) => Promise<HowlerSearchResponse<Template>>;
4
+ export declare const post: (request?: HowlerSearchRequest) => Promise<HowlerSearchResponse<Overview>>;
@@ -1,6 +1,7 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import type { Template } from '@cccsaurora/howler-ui/models/entities/generated/Template';
2
3
  export declare const uri: (id?: string) => string;
3
4
  export declare const get: () => Promise<Template[]>;
4
- export declare const post: (newData: Partial<Template>) => Promise<Template>;
5
- export declare const put: (id: string, newFields: string[]) => Promise<Template>;
6
- export declare const del: (id: string) => Promise<void>;
5
+ export declare const post: (newData: Partial<Template>, refresh?: HowlerRefreshParam) => Promise<Template>;
6
+ export declare const put: (id: string, newFields: string[], refresh?: HowlerRefreshParam) => Promise<Template>;
7
+ export declare const del: (id: string, refresh?: HowlerRefreshParam) => Promise<void>;
@@ -5,12 +5,12 @@ export const uri = (id) => {
5
5
  export const get = () => {
6
6
  return hget(uri());
7
7
  };
8
- export const post = (newData) => {
9
- return hpost(uri(), newData);
8
+ export const post = (newData, refresh) => {
9
+ return hpost(uri(), newData, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
10
10
  };
11
- export const put = (id, newFields) => {
12
- return hput(uri(id), newFields);
11
+ export const put = (id, newFields, refresh) => {
12
+ return hput(uri(id), newFields, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
13
13
  };
14
- export const del = (id) => {
15
- return hdelete(uri(id));
14
+ export const del = (id, refresh) => {
15
+ return hdelete(uri(id), undefined, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
16
16
  };
@@ -1,3 +1,4 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import * as avatar from '@cccsaurora/howler-ui/api/user/avatar';
2
3
  import * as groups from '@cccsaurora/howler-ui/api/user/groups';
3
4
  import * as whoami from '@cccsaurora/howler-ui/api/user/whoami';
@@ -6,5 +7,5 @@ export declare const uri: (username?: string) => string;
6
7
  export declare const get: (username: string) => Promise<HowlerUser>;
7
8
  export declare const put: (username: string, newData: Partial<HowlerUser> | {
8
9
  new_pass: string;
9
- }) => Promise<any>;
10
+ }, refresh?: HowlerRefreshParam) => Promise<any>;
10
11
  export { avatar, groups, whoami };
package/api/user/index.js CHANGED
@@ -9,7 +9,7 @@ export const uri = (username) => {
9
9
  export const get = (username) => {
10
10
  return hget(uri(username));
11
11
  };
12
- export const put = (username, newData) => {
13
- return hput(uri(username), newData);
12
+ export const put = (username, newData, refresh) => {
13
+ return hput(uri(username), newData, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
14
14
  };
15
15
  export { avatar, groups, whoami };
@@ -1,8 +1,9 @@
1
+ import { type HowlerRefreshParam } from '@cccsaurora/howler-ui/api';
1
2
  import * as favourite from '@cccsaurora/howler-ui/api/view/favourite';
2
3
  import type { View } from '@cccsaurora/howler-ui/models/entities/generated/View';
3
4
  export declare const uri: (id?: string) => string;
4
5
  export declare const get: () => Promise<View[]>;
5
- export declare const post: (newData: Partial<View>) => Promise<View>;
6
- export declare const put: (id: string, partialView: Partial<Omit<View, "view_id">>) => Promise<View>;
7
- export declare const del: (id: string) => Promise<void>;
6
+ export declare const post: (newData: Partial<View>, refresh?: HowlerRefreshParam) => Promise<View>;
7
+ export declare const put: (id: string, partialView: Partial<Omit<View, "view_id">>, refresh?: HowlerRefreshParam) => Promise<View>;
8
+ export declare const del: (id: string, refresh?: HowlerRefreshParam) => Promise<void>;
8
9
  export { favourite };
package/api/view/index.js CHANGED
@@ -6,13 +6,13 @@ export const uri = (id) => {
6
6
  export const get = () => {
7
7
  return hget(uri());
8
8
  };
9
- export const post = (newData) => {
10
- return hpost(uri(), newData);
9
+ export const post = (newData, refresh) => {
10
+ return hpost(uri(), newData, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
11
11
  };
12
- export const put = (id, partialView) => {
13
- return hput(uri(id), partialView);
12
+ export const put = (id, partialView, refresh) => {
13
+ return hput(uri(id), partialView, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
14
14
  };
15
- export const del = (id) => {
16
- return hdelete(uri(id));
15
+ export const del = (id, refresh) => {
16
+ return hdelete(uri(id), undefined, undefined, refresh ? new URLSearchParams({ refresh }) : undefined);
17
17
  };
18
18
  export { favourite };
@@ -0,0 +1,21 @@
1
+ import type { HowlerSearchRequest, HowlerSearchResponse } from '@cccsaurora/howler-ui/api/search';
2
+ import type { DispatchApiConfig } from '@cccsaurora/howler-ui/components/hooks/useMyApi';
3
+ import { type PropsWithChildren } from 'react';
4
+ export type SearchResponseState<T> = HowlerSearchResponse<T> & {
5
+ removeCount: number;
6
+ };
7
+ export type SearchResponseContextType<T> = {
8
+ push: (item: T) => void;
9
+ remove: (id: string) => void;
10
+ replace: (id: string, item: T) => void;
11
+ request: (endpoint: (request: HowlerSearchRequest) => Promise<HowlerSearchResponse<T>>, requestData: HowlerSearchRequest, config?: DispatchApiConfig) => Promise<HowlerSearchResponse<T>>;
12
+ getSearchRequestData: (requestData: Partial<HowlerSearchRequest>) => Partial<HowlerSearchRequest>;
13
+ response: SearchResponseState<T> | null;
14
+ };
15
+ export declare const SearchResponseContext: import("react").Context<SearchResponseContextType<any>>;
16
+ type SearchResponseProviderProps<T> = PropsWithChildren<{
17
+ idField: string;
18
+ initialResponse?: SearchResponseState<T>;
19
+ }>;
20
+ declare const SearchResponseProvider: <T>({ children, idField: idField, initialResponse }: SearchResponseProviderProps<T>) => import("react/jsx-runtime").JSX.Element;
21
+ export default SearchResponseProvider;
@@ -0,0 +1,81 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
3
+ import { createContext, useCallback, useState } from 'react';
4
+ export const SearchResponseContext = createContext(null);
5
+ const SearchResponseProvider = ({ children, idField: idField, initialResponse = null }) => {
6
+ const { dispatchApi } = useMyApi();
7
+ const [response, setResponse] = useState(initialResponse);
8
+ const request = useCallback(async (endpoint, requestData, config) => {
9
+ const _response = await dispatchApi(endpoint(requestData), config);
10
+ setResponse(_prevResponse => ({
11
+ ..._response,
12
+ removeCount: _response.offset <= _prevResponse?.offset ? 0 : (_prevResponse?.removeCount ?? 0)
13
+ }));
14
+ return _response;
15
+ }, [dispatchApi]);
16
+ const getSearchRequestData = useCallback((requestData) => {
17
+ const modifiedRequest = { ...requestData };
18
+ if (response?.removeCount) {
19
+ if (response.offset < modifiedRequest.offset) {
20
+ modifiedRequest.offset = Math.max(0, modifiedRequest.offset - response.removeCount);
21
+ }
22
+ }
23
+ return modifiedRequest;
24
+ }, [response]);
25
+ const push = useCallback((item) => {
26
+ setResponse(_response => {
27
+ if (_response === null) {
28
+ return _response;
29
+ }
30
+ const filteredItems = _response.items.filter(v => v[idField] !== item[idField]);
31
+ const itemExists = filteredItems.length < _response.items.length;
32
+ filteredItems.push(item);
33
+ return {
34
+ items: filteredItems.length <= _response.rows ? filteredItems : _response.items,
35
+ offset: _response.offset,
36
+ rows: _response.rows,
37
+ total: itemExists ? _response.total : _response.total + 1,
38
+ removeCount: itemExists ? _response.removeCount : Math.max(_response.removeCount - 1, 0)
39
+ };
40
+ });
41
+ }, [idField]);
42
+ const replace = useCallback((id, item) => {
43
+ if (item[idField] !== undefined && id !== item[idField]) {
44
+ throw new Error('Item id is defined but id does not match the id provided to replace function');
45
+ }
46
+ const newItem = {
47
+ ...item,
48
+ [idField]: item[idField] !== undefined ? item[idField] : id
49
+ };
50
+ setResponse(_response => {
51
+ if (_response === null) {
52
+ return _response;
53
+ }
54
+ return {
55
+ items: _response.items.map(v => (v[idField] === id ? newItem : v)),
56
+ offset: _response.offset,
57
+ rows: _response.rows,
58
+ total: _response.total,
59
+ removeCount: _response.removeCount
60
+ };
61
+ });
62
+ }, [idField]);
63
+ const remove = useCallback((id) => {
64
+ setResponse(_response => {
65
+ if (_response === null) {
66
+ return _response;
67
+ }
68
+ const filteredItems = _response.items.filter(v => v[idField] !== id);
69
+ const itemExists = filteredItems.length < _response.items.length;
70
+ return {
71
+ items: filteredItems,
72
+ offset: _response.offset,
73
+ rows: _response.rows,
74
+ total: itemExists ? _response.total - 1 : _response.total,
75
+ removeCount: itemExists ? _response.removeCount + 1 : _response.removeCount
76
+ };
77
+ });
78
+ }, [idField]);
79
+ return (_jsx(SearchResponseContext.Provider, { value: { push, remove, replace, request, getSearchRequestData, response }, children: children }));
80
+ };
81
+ export default SearchResponseProvider;