@jskit-ai/http-web 0.2.7 → 0.2.9

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 (73) hide show
  1. package/package.json +7 -6
  2. package/src/client/bulkActions.js +2 -0
  3. package/src/client/components/CrudAddEditScreen.vue +13 -18
  4. package/src/client/components/CrudDeleteAction.vue +1 -1
  5. package/src/client/components/CrudListBulkActionSurface.vue +13 -13
  6. package/src/client/components/CrudListDateFilterControl.vue +2 -2
  7. package/src/client/components/CrudListFilterControls.vue +4 -4
  8. package/src/client/components/CrudListFilterSurface.vue +8 -8
  9. package/src/client/components/CrudListRecordActionMenu.vue +9 -19
  10. package/src/client/components/CrudListScreen.vue +21 -39
  11. package/src/client/components/CrudViewScreen.vue +4 -4
  12. package/src/client/components/SelectField.vue +1 -0
  13. package/src/client/composables/crud/crudHttpClientSupport.js +10 -10
  14. package/src/client/composables/crud/crudJsonApiTransportSupport.js +1 -0
  15. package/src/client/composables/crud/crudLookupFieldRuntime.js +3 -3
  16. package/src/client/composables/crud/crudSchemaFormHelpers.js +3 -3
  17. package/src/client/composables/internal/crudListFilterLookupSupport.js +10 -8
  18. package/src/client/composables/internal/crudListParentTitleSupport.js +2 -2
  19. package/src/client/composables/internal/useOperationScope.js +7 -5
  20. package/src/client/composables/records/useAddEdit.js +12 -11
  21. package/src/client/composables/records/useCrudAddEdit.js +27 -40
  22. package/src/client/composables/records/useCrudList.js +4 -11
  23. package/src/client/composables/records/useCrudView.js +4 -10
  24. package/src/client/composables/records/useList.js +18 -11
  25. package/src/client/composables/records/useView.js +18 -11
  26. package/src/client/composables/runtime/addEditUiRuntime.js +10 -17
  27. package/src/client/composables/runtime/listUiRuntime.js +17 -20
  28. package/src/client/composables/runtime/modelStateHelpers.js +18 -8
  29. package/src/client/composables/runtime/operationUiHelpers.js +20 -20
  30. package/src/client/composables/runtime/operationValidationHelpers.js +12 -7
  31. package/src/client/composables/runtime/useAddEditCore.js +39 -36
  32. package/src/client/composables/runtime/useCommandCore.js +33 -32
  33. package/src/client/composables/runtime/useEndpointResource.js +10 -14
  34. package/src/client/composables/runtime/useFieldErrorBag.js +3 -2
  35. package/src/client/composables/runtime/useListCore.js +7 -11
  36. package/src/client/composables/runtime/useUiFeedback.js +3 -2
  37. package/src/client/composables/runtime/useViewCore.js +10 -20
  38. package/src/client/composables/runtime/viewUiRuntime.js +7 -6
  39. package/src/client/composables/support/listQueryParamSupport.js +6 -10
  40. package/src/client/composables/support/refValueHelpers.js +2 -6
  41. package/src/client/composables/support/requestQueryRuntimeSupport.js +2 -2
  42. package/src/client/composables/support/routeTemplateHelpers.js +13 -12
  43. package/src/client/composables/support/scopeHelpers.js +5 -4
  44. package/src/client/composables/useAccess.js +8 -5
  45. package/src/client/composables/useCommand.js +7 -6
  46. package/src/client/composables/useCrudAddEditScreen.js +13 -12
  47. package/src/client/composables/useCrudDeleteAction.js +13 -25
  48. package/src/client/composables/useCrudListBulkActions.js +18 -14
  49. package/src/client/composables/useCrudListFilterLookups.js +8 -4
  50. package/src/client/composables/useCrudListFilters.js +13 -6
  51. package/src/client/composables/useCrudListParentTitle.js +10 -9
  52. package/src/client/composables/useCrudListRowActions.js +15 -11
  53. package/src/client/composables/useCrudListScreen.js +17 -16
  54. package/src/client/composables/useCrudViewScreen.js +8 -7
  55. package/src/client/composables/usePagedCollection.js +9 -18
  56. package/src/client/composables/useRealtimeQueryInvalidation.js +15 -13
  57. package/src/client/composables/useScopeRuntime.js +3 -2
  58. package/src/client/lib/httpClient.js +12 -10
  59. package/src/client/rowActions.js +2 -0
  60. package/src/client/support/crudListActionSupport.js +16 -8
  61. package/src/client/types.js +596 -0
  62. package/test/addEditUiRuntime.test.js +8 -8
  63. package/test/crudScreenComponents.test.js +4 -2
  64. package/test/exportsContract.test.js +1 -0
  65. package/test/listUiRuntime.test.js +5 -5
  66. package/test/requestTransportOptions.test.js +15 -15
  67. package/test/routeTemplateHelpers.test.js +5 -5
  68. package/test/translation.test.js +3 -0
  69. package/test/useAddEditCore.test.js +4 -0
  70. package/test/useCrudDeleteAction.test.js +4 -4
  71. package/test/useCrudListParentTitle.test.js +6 -6
  72. package/test/viewCoreLoading.test.js +0 -19
  73. package/test/viewUiRuntime.test.js +5 -5
@@ -5,13 +5,18 @@ function normalizeMessage(value) {
5
5
  return String(value || "").trim();
6
6
  }
7
7
 
8
+ function noRetryAction() {
9
+ return null;
10
+ }
11
+
12
+ /** @param {import("../../types.js").OperationErrorReporting} [options] */
8
13
  function setupOperationErrorReporting({
9
14
  enabled = true,
10
15
  source = "http-web.operation",
11
16
  loadError = null,
12
17
  notFoundError = null,
13
- loadActionFactory = null,
14
- notFoundActionFactory = null,
18
+ loadActionFactory = noRetryAction,
19
+ notFoundActionFactory = noRetryAction,
15
20
  loadChannel = "",
16
21
  notFoundChannel = "",
17
22
  loadSeverity = "error",
@@ -30,13 +35,13 @@ function setupOperationErrorReporting({
30
35
  channel = "",
31
36
  intent = "resource-load",
32
37
  severity = "error",
33
- actionFactory = null
38
+ actionFactory = noRetryAction
34
39
  } = {}) {
35
40
  let lastMessage = "";
36
41
  let lastPresentationId = "";
37
42
 
38
43
  watch(
39
- () => normalizeMessage(value?.value),
44
+ () => normalizeMessage(value.value),
40
45
  (nextMessage) => {
41
46
  if (!nextMessage) {
42
47
  lastMessage = "";
@@ -52,12 +57,10 @@ function setupOperationErrorReporting({
52
57
  }
53
58
 
54
59
  lastMessage = nextMessage;
55
- const action = typeof actionFactory === "function"
56
- ? actionFactory({
57
- message: nextMessage,
58
- kind
59
- })
60
- : null;
60
+ const action = actionFactory({
61
+ message: nextMessage,
62
+ kind
63
+ });
61
64
  const reportResult = runtime.report({
62
65
  source: normalizedSource,
63
66
  message: nextMessage,
@@ -102,13 +105,11 @@ function setupOperationErrorReporting({
102
105
  }
103
106
  }
104
107
 
105
- function setupRouteChangeCleanup({
106
- enabled = true,
107
- route = null,
108
- feedback = null,
109
- fieldBag = null,
110
- onClear = null
111
- } = {}) {
108
+ /**
109
+ * Clears what an operation shows when the route changes.
110
+ * @param {{ enabled?: boolean, route: { fullPath?: string } | null, feedback: Pick<import("../../types.js").UiFeedback, "clear">, onClear: () => void }} options
111
+ */
112
+ function setupRouteChangeCleanup({ enabled = true, route, feedback, onClear }) {
112
113
  if (!enabled) {
113
114
  return;
114
115
  }
@@ -116,9 +117,8 @@ function setupRouteChangeCleanup({
116
117
  watch(
117
118
  () => route?.fullPath,
118
119
  () => {
119
- feedback?.clear?.();
120
- fieldBag?.clear?.();
121
- onClear?.();
120
+ feedback.clear();
121
+ onClear();
122
122
  }
123
123
  );
124
124
  }
@@ -1,17 +1,22 @@
1
- import { createValidationFailure } from "@jskit-ai/http-runtime/client";
1
+ import { buildValidationFailure } from "@jskit-ai/http-runtime/client";
2
2
  import { validateSchemaPayload } from "@jskit-ai/kernel/shared/validators";
3
3
  import { toUiFieldErrors } from "../support/errorMessageHelpers.js";
4
4
  import { useJskitText } from "../../i18n.js";
5
5
 
6
6
  const { t, text } = useJskitText();
7
7
 
8
+ // A check that only reads the result: it changes no field errors and reports nothing.
9
+ const SILENT_FIELD_BAG = Object.freeze({ apply() {} });
10
+ const SILENT_FEEDBACK = Object.freeze({ error() {} });
11
+
12
+ /** @param {import("../../types.js").OperationInputCheck} options */
8
13
  function validateOperationInput({
9
14
  input,
10
15
  rawPayload = {},
11
- fieldBag = null,
12
- feedback = null,
16
+ fieldBag = SILENT_FIELD_BAG,
17
+ feedback = SILENT_FEEDBACK,
13
18
  validationMessage = ""
14
- } = {}) {
19
+ }) {
15
20
  if (!input) {
16
21
  return {
17
22
  ok: true,
@@ -36,15 +41,15 @@ function validateOperationInput({
36
41
 
37
42
  const fieldErrorCodes = error.fieldErrorCodes || error.details?.fieldErrorCodes;
38
43
  const failure = {
39
- ...createValidationFailure({
44
+ ...buildValidationFailure({
40
45
  error: text(validationMessage) || t("jskit.http.feedback.validationFailed"),
41
46
  code: "validation_failed",
42
47
  fieldErrors: error?.fieldErrors
43
48
  }),
44
49
  ...(fieldErrorCodes ? { fieldErrorCodes } : {})
45
50
  };
46
- fieldBag?.apply?.(toUiFieldErrors(failure));
47
- feedback?.error?.(failure, failure.error);
51
+ fieldBag.apply(toUiFieldErrors(failure));
52
+ feedback.error(failure, failure.error);
48
53
  return {
49
54
  ok: false,
50
55
  failure,
@@ -1,12 +1,18 @@
1
1
  import { useQueryClient } from "@tanstack/vue-query";
2
2
  import { computed, ref } from "vue";
3
3
  import { validateOperationInput } from "./operationValidationHelpers.js";
4
- import { watchResourceModelState } from "./modelStateHelpers.js";
4
+ import { ignoreLoadedPayload, watchResourceModelState } from "./modelStateHelpers.js";
5
5
  import { toUiFieldErrors } from "../support/errorMessageHelpers.js";
6
+ import { emptyRecord } from "../support/scopeHelpers.js";
6
7
  import { useJskitText } from "../../i18n.js";
7
8
 
8
9
  const { t, text } = useJskitText();
9
10
 
11
+ function saveParsedInput(parsedInput) {
12
+ return parsedInput;
13
+ }
14
+
15
+ /** @param {import("../../types.js").AddEditCoreOptions} options */
10
16
  function useAddEditCore({
11
17
  model,
12
18
  resource,
@@ -15,13 +21,13 @@ function useAddEditCore({
15
21
  fieldBag,
16
22
  feedback,
17
23
  input,
18
- mapLoadedToModel,
19
- buildRawPayload,
20
- buildSavePayload,
24
+ mapLoadedToModel = ignoreLoadedPayload,
25
+ buildRawPayload = emptyRecord,
26
+ buildSavePayload = saveParsedInput,
21
27
  onSaveSuccess,
22
28
  validationFeedback = true,
23
29
  messages = {}
24
- } = {}) {
30
+ }) {
25
31
  const queryClient = useQueryClient();
26
32
  watchResourceModelState({
27
33
  resource,
@@ -36,10 +42,10 @@ function useAddEditCore({
36
42
  });
37
43
 
38
44
  const submitting = ref(false);
39
- const saving = computed(() => Boolean(submitting.value || resource?.isSaving?.value));
40
- const fieldErrors = fieldBag?.errors;
41
- const message = feedback?.message;
42
- const messageType = feedback?.messageType;
45
+ const saving = computed(() => Boolean(submitting.value || resource.isSaving.value));
46
+ const fieldErrors = fieldBag.errors;
47
+ const message = feedback.message;
48
+ const messageType = feedback.messageType;
43
49
  const validationAttempted = ref(false);
44
50
  const validationErrors = computed(() => {
45
51
  if (!validationAttempted.value || !input) {
@@ -52,24 +58,24 @@ function useAddEditCore({
52
58
  });
53
59
 
54
60
  function resolveRawPayload() {
55
- return typeof buildRawPayload === "function" ? buildRawPayload(model, {
61
+ return buildRawPayload(model, {
56
62
  queryClient,
57
63
  resource
58
- }) : {};
64
+ });
59
65
  }
60
66
 
61
67
  function resetValidation() {
62
68
  validationAttempted.value = false;
63
- fieldBag?.clear?.();
69
+ fieldBag.clear();
64
70
  }
65
71
 
66
72
  async function submit() {
67
- if (!canSave?.value || saving.value) {
73
+ if (!canSave.value || saving.value) {
68
74
  return;
69
75
  }
70
76
 
71
- feedback?.clear?.();
72
- fieldBag?.clear?.();
77
+ feedback.clear();
78
+ fieldBag.clear();
73
79
  validationAttempted.value = true;
74
80
 
75
81
  const rawPayload = resolveRawPayload();
@@ -78,7 +84,7 @@ function useAddEditCore({
78
84
  input,
79
85
  rawPayload,
80
86
  fieldBag,
81
- feedback: validationFeedback === false ? null : feedback,
87
+ feedback: validationFeedback === false ? undefined : feedback,
82
88
  validationMessage: text(messages.validation) || t("jskit.http.feedback.validationFailed")
83
89
  });
84
90
  if (!validationResult.ok) {
@@ -86,31 +92,28 @@ function useAddEditCore({
86
92
  }
87
93
 
88
94
  const { parsedInput } = validationResult;
89
- const savePayload = typeof buildSavePayload === "function"
90
- ? buildSavePayload(parsedInput, {
91
- rawPayload,
92
- queryClient,
93
- resource
94
- })
95
- : parsedInput;
95
+ const savePayload = buildSavePayload(parsedInput, {
96
+ rawPayload,
97
+ queryClient,
98
+ resource
99
+ });
96
100
 
97
101
  try {
98
102
  submitting.value = true;
99
- const queryKeySnapshot = queryKey?.value;
103
+ const queryKeySnapshot = queryKey.value;
100
104
  const payload = await resource.save(savePayload);
101
105
 
102
- if (typeof mapLoadedToModel === "function") {
103
- mapLoadedToModel(model, payload, {
104
- queryClient,
105
- resource
106
- });
107
- }
106
+ mapLoadedToModel(model, payload, {
107
+ queryClient,
108
+ resource
109
+ });
108
110
 
109
111
  if (queryKeySnapshot !== undefined) {
110
112
  queryClient.setQueryData(queryKeySnapshot, payload);
111
113
  }
112
114
 
113
- if (typeof onSaveSuccess === "function") {
115
+ // readable-check: allow method-probe - optional operation: a form with no onSaveSuccess reports the save in the same tick
116
+ if (onSaveSuccess) {
114
117
  await onSaveSuccess(payload, {
115
118
  queryClient,
116
119
  parsed: parsedInput,
@@ -120,16 +123,16 @@ function useAddEditCore({
120
123
  });
121
124
  }
122
125
 
123
- feedback?.success?.(text(messages.saveSuccess) || t("jskit.http.feedback.saved"));
126
+ feedback.success(text(messages.saveSuccess) || t("jskit.http.feedback.saved"));
124
127
  } catch (error) {
125
- fieldBag?.apply?.(toUiFieldErrors(error));
126
- feedback?.error?.(error, text(messages.saveError) || t("jskit.http.feedback.saveFailed"));
128
+ fieldBag.apply(toUiFieldErrors(error));
129
+ feedback.error(error, text(messages.saveError) || t("jskit.http.feedback.saveFailed"));
127
130
  } finally {
128
131
  submitting.value = false;
129
132
  }
130
133
  }
131
134
 
132
- return Object.freeze({
135
+ return {
133
136
  saving,
134
137
  fieldErrors,
135
138
  message,
@@ -138,7 +141,7 @@ function useAddEditCore({
138
141
  validationErrors,
139
142
  resetValidation,
140
143
  submit
141
- });
144
+ };
142
145
  }
143
146
 
144
147
  export { useAddEditCore };
@@ -1,10 +1,12 @@
1
1
  import { useQueryClient } from "@tanstack/vue-query";
2
2
  import { validateOperationInput } from "./operationValidationHelpers.js";
3
3
  import { toUiFieldErrors } from "../support/errorMessageHelpers.js";
4
+ import { emptyRecord } from "../support/scopeHelpers.js";
4
5
  import { useJskitText } from "../../i18n.js";
5
6
 
6
7
  const { t, text } = useJskitText();
7
8
 
9
+ /** @param {import("../../types.js").CommandCoreOptions} options */
8
10
  function useCommandCore({
9
11
  model,
10
12
  resource,
@@ -13,37 +15,35 @@ function useCommandCore({
13
15
  fieldBag,
14
16
  feedback,
15
17
  input,
16
- buildRawPayload,
18
+ buildRawPayload = emptyRecord,
17
19
  buildCommandPayload,
18
- buildCommandOptions,
20
+ buildCommandOptions = emptyRecord,
19
21
  onRunSuccess,
20
22
  onRunError,
21
23
  suppressSuccessMessage = false,
22
24
  messages = {}
23
- } = {}) {
25
+ }) {
24
26
  const queryClient = useQueryClient();
25
27
  const normalizedWriteMethod = String(writeMethod || "POST").trim().toUpperCase();
26
28
 
27
- const running = resource?.isSaving;
28
- const fieldErrors = fieldBag?.errors;
29
- const message = feedback?.message;
30
- const messageType = feedback?.messageType;
29
+ const running = resource.isSaving;
30
+ const fieldErrors = fieldBag.errors;
31
+ const message = feedback.message;
32
+ const messageType = feedback.messageType;
31
33
 
32
34
  async function run(context = {}) {
33
- if (!canRun?.value || running?.value) {
35
+ if (!canRun.value || running.value) {
34
36
  return null;
35
37
  }
36
38
 
37
- feedback?.clear?.();
38
- fieldBag?.clear?.();
39
+ feedback.clear();
40
+ fieldBag.clear();
39
41
 
40
- const rawPayload = typeof buildRawPayload === "function"
41
- ? buildRawPayload(model, {
42
- queryClient,
43
- resource,
44
- context
45
- })
46
- : {};
42
+ const rawPayload = buildRawPayload(model, {
43
+ queryClient,
44
+ resource,
45
+ context
46
+ });
47
47
 
48
48
  const validationResult = validateOperationInput({
49
49
  input,
@@ -57,6 +57,7 @@ function useCommandCore({
57
57
  }
58
58
 
59
59
  const { parsedInput } = validationResult;
60
+ // readable-check: allow method-probe - optional operation: without buildCommandPayload a command sends its parsed input, and nothing for DELETE
60
61
  const payload = typeof buildCommandPayload === "function"
61
62
  ? buildCommandPayload(parsedInput, {
62
63
  rawPayload,
@@ -66,19 +67,18 @@ function useCommandCore({
66
67
  })
67
68
  : (normalizedWriteMethod === "DELETE" ? undefined : parsedInput);
68
69
 
69
- const options = typeof buildCommandOptions === "function"
70
- ? buildCommandOptions(parsedInput, {
71
- rawPayload,
72
- queryClient,
73
- resource,
74
- context
75
- })
76
- : {};
70
+ const options = buildCommandOptions(parsedInput, {
71
+ rawPayload,
72
+ queryClient,
73
+ resource,
74
+ context
75
+ });
77
76
 
78
77
  try {
79
78
  const response = await resource.save(payload, options);
80
79
 
81
- if (typeof onRunSuccess === "function") {
80
+ // readable-check: allow method-probe - optional operation: a command with no onRunSuccess reports its success in the same tick
81
+ if (onRunSuccess) {
82
82
  await onRunSuccess(response, {
83
83
  parsed: parsedInput,
84
84
  rawPayload,
@@ -91,13 +91,14 @@ function useCommandCore({
91
91
  }
92
92
 
93
93
  if (!suppressSuccessMessage) {
94
- feedback?.success?.(text(messages.success) || t("jskit.http.feedback.completed"));
94
+ feedback.success(text(messages.success) || t("jskit.http.feedback.completed"));
95
95
  }
96
96
  return response;
97
97
  } catch (error) {
98
- fieldBag?.apply?.(toUiFieldErrors(error));
98
+ fieldBag.apply(toUiFieldErrors(error));
99
99
 
100
- if (typeof onRunError === "function") {
100
+ // readable-check: allow method-probe - optional operation: a command with no onRunError reports its failure in the same tick
101
+ if (onRunError) {
101
102
  await onRunError(error, {
102
103
  parsed: parsedInput,
103
104
  rawPayload,
@@ -109,18 +110,18 @@ function useCommandCore({
109
110
  });
110
111
  }
111
112
 
112
- feedback?.error?.(error, text(messages.error) || t("jskit.http.feedback.actionFailed"));
113
+ feedback.error(error, text(messages.error) || t("jskit.http.feedback.actionFailed"));
113
114
  throw error;
114
115
  }
115
116
  }
116
117
 
117
- return Object.freeze({
118
+ return {
118
119
  running,
119
120
  fieldErrors,
120
121
  message,
121
122
  messageType,
122
123
  run
123
- });
124
+ };
124
125
  }
125
126
 
126
127
  export { useCommandCore };
@@ -64,17 +64,18 @@ function buildEndpointWriteRequestOptions({
64
64
  return requestOptions;
65
65
  }
66
66
 
67
+ /** @param {import("../../types.js").EndpointResourceOptions} options */
67
68
  function useEndpointResource({
68
69
  queryKey,
69
70
  path = "",
70
71
  enabled = true,
71
- client = null,
72
+ client = getHttpWebClient(),
72
73
  readMethod = "GET",
73
74
  writeMethod = "PATCH",
74
- readQuery = null,
75
- transport = null,
75
+ readQuery,
76
+ transport,
76
77
  refreshOnPull = false,
77
- realtime = null,
78
+ realtime,
78
79
  queryOptions = null,
79
80
  mutationOptions = null,
80
81
  requestRecovery = null,
@@ -82,12 +83,7 @@ function useEndpointResource({
82
83
  requestRecoveryLabel = "",
83
84
  fallbackLoadError = "jskit.http.resource.loadFailed",
84
85
  fallbackSaveError = "jskit.http.resource.saveFailed"
85
- } = {}) {
86
- const activeClient = client || getHttpWebClient();
87
- if (!activeClient || typeof activeClient.request !== "function") {
88
- throw new TypeError("useEndpointResource requires a client with request().");
89
- }
90
-
86
+ }) {
91
87
  const normalizedPath = computed(() => resolveTextRef(path));
92
88
  const queryEnabled = computed(() => resolveEnabledRef(enabled) && Boolean(normalizedPath.value));
93
89
 
@@ -99,7 +95,7 @@ function useEndpointResource({
99
95
  throw new Error("Resource path is required.");
100
96
  }
101
97
 
102
- return activeClient.request(requestPath, {
98
+ return client.request(requestPath, {
103
99
  ...buildEndpointReadRequestOptions({
104
100
  method: readMethod,
105
101
  query: readQuery,
@@ -141,7 +137,7 @@ function useEndpointResource({
141
137
  const method = String(options.method || writeMethod || "PATCH").toUpperCase();
142
138
  const hasBody = Object.hasOwn(options, "body");
143
139
  const body = hasBody ? options.body : options.payload;
144
- return activeClient.request(
140
+ return client.request(
145
141
  requestPath,
146
142
  buildEndpointWriteRequestOptions({
147
143
  method,
@@ -178,7 +174,7 @@ function useEndpointResource({
178
174
  });
179
175
  }
180
176
 
181
- return Object.freeze({
177
+ return {
182
178
  query,
183
179
  mutation,
184
180
  data,
@@ -192,7 +188,7 @@ function useEndpointResource({
192
188
  realtime: realtimeBinding,
193
189
  reload,
194
190
  save
195
- });
191
+ };
196
192
  }
197
193
 
198
194
  export {
@@ -6,6 +6,7 @@ function normalizeFieldErrorKeys(keys) {
6
6
  : [];
7
7
  }
8
8
 
9
+ /** @param {string[]} [keys] The only fields the bag holds; any field when empty. */
9
10
  function useFieldErrorBag(keys = []) {
10
11
  const normalizedKeys = normalizeFieldErrorKeys(keys);
11
12
  const hasFixedKeys = normalizedKeys.length > 0;
@@ -50,12 +51,12 @@ function useFieldErrorBag(keys = []) {
50
51
  errors[key] = String(message || "");
51
52
  }
52
53
 
53
- return Object.freeze({
54
+ return {
54
55
  errors,
55
56
  clear,
56
57
  apply,
57
58
  set
58
- });
59
+ };
59
60
  }
60
61
 
61
62
  export { normalizeFieldErrorKeys, useFieldErrorBag };
@@ -55,26 +55,22 @@ function resolveListRequestMethod(requestOptions = null) {
55
55
  return String(resolveRequestOptionsObject(requestOptions).method || "GET").toUpperCase();
56
56
  }
57
57
 
58
+ /** @param {import("../../types.js").ListCoreOptions} options */
58
59
  function useListCore({
59
60
  queryKey,
60
61
  path = "",
61
62
  enabled = true,
62
- client = null,
63
- transport = null,
64
- initialPageParam = null,
63
+ client = getHttpWebClient(),
64
+ transport,
65
+ initialPageParam,
65
66
  getNextPageParam,
66
67
  selectItems,
67
- requestOptions = null,
68
+ requestOptions,
68
69
  queryOptions = null,
69
70
  requestRecovery = null,
70
71
  requestRecoveryLabel = t("jskit.http.list.label"),
71
72
  fallbackLoadError = t("jskit.http.list.loadFailed")
72
- } = {}) {
73
- const activeClient = client || getHttpWebClient();
74
- if (!activeClient || typeof activeClient.request !== "function") {
75
- throw new TypeError("useListCore requires a client with request().");
76
- }
77
-
73
+ }) {
78
74
  const normalizedPath = computed(() => resolveTextRef(path));
79
75
  const queryEnabled = computed(() => resolveEnabledRef(enabled) && Boolean(normalizedPath.value));
80
76
 
@@ -90,7 +86,7 @@ function useListCore({
90
86
 
91
87
  const options = buildListRequestOptions({ requestOptions, transport, pageParam });
92
88
  options.signal = options.signal ? AbortSignal.any([signal, options.signal]) : signal;
93
- return activeClient.request(requestPath, options);
89
+ return client.request(requestPath, options);
94
90
  },
95
91
  getNextPageParam,
96
92
  selectItems,
@@ -2,6 +2,7 @@ import { ref } from "vue";
2
2
  import { useShellWebErrorRuntime } from "@jskit-ai/shell-web/client/error";
3
3
  import { toUiErrorMessage } from "../support/errorMessageHelpers.js";
4
4
 
5
+ /** @param {import("../../types.js").UiFeedbackOptions} [options] */
5
6
  function useUiFeedback({
6
7
  initialType = "success",
7
8
  source = "http-web.ui-feedback",
@@ -86,13 +87,13 @@ function useUiFeedback({
86
87
  }
87
88
  }
88
89
 
89
- return Object.freeze({
90
+ return {
90
91
  message,
91
92
  messageType,
92
93
  clear,
93
94
  success,
94
95
  error
95
- });
96
+ };
96
97
  }
97
98
 
98
99
  export { useUiFeedback };
@@ -12,6 +12,7 @@ function normalizeStatusList(value) {
12
12
  return [404];
13
13
  }
14
14
 
15
+ /** @param {import("../../types.js").ViewCoreOptions} options */
15
16
  function useViewCore({
16
17
  resource,
17
18
  model,
@@ -19,7 +20,7 @@ function useViewCore({
19
20
  mapLoadedToModel,
20
21
  notFoundStatuses = [404],
21
22
  notFoundMessage = ""
22
- } = {}) {
23
+ }) {
23
24
  const statusList = normalizeStatusList(notFoundStatuses);
24
25
  watchResourceModelState({
25
26
  resource,
@@ -32,21 +33,10 @@ function useViewCore({
32
33
  }
33
34
  });
34
35
 
35
- const data = resource?.data;
36
- const record = computed(() => (model !== undefined ? model : data?.value));
37
- const isLoading = computed(() => {
38
- if (resource?.isInitialLoading?.value !== undefined) {
39
- return Boolean(resource.isInitialLoading.value);
40
- }
41
- return Boolean(resource?.query?.isPending?.value);
42
- });
43
- const isFetching = computed(() => {
44
- if (resource?.isFetching?.value !== undefined) {
45
- return Boolean(resource.isFetching.value);
46
- }
47
- return Boolean(resource?.query?.isFetching?.value);
48
- });
49
- const error = computed(() => resource?.query?.error?.value || null);
36
+ const record = computed(() => (model !== undefined ? model : resource.data.value));
37
+ const isLoading = computed(() => Boolean(resource.isInitialLoading.value));
38
+ const isFetching = computed(() => Boolean(resource.isFetching.value));
39
+ const error = computed(() => resource.query.error.value || null);
50
40
 
51
41
  const isNotFound = computed(() => {
52
42
  const status = Number(error.value?.status || 0);
@@ -66,7 +56,7 @@ function useViewCore({
66
56
  return "";
67
57
  }
68
58
 
69
- return String(resource?.loadError?.value || "").trim();
59
+ return String(resource.loadError.value || "").trim();
70
60
  });
71
61
 
72
62
  const resolvedCanView = computed(() => {
@@ -78,10 +68,10 @@ function useViewCore({
78
68
  });
79
69
 
80
70
  async function refresh() {
81
- return resource?.reload?.();
71
+ return resource.reload();
82
72
  }
83
73
 
84
- return Object.freeze({
74
+ return {
85
75
  record,
86
76
  isLoading,
87
77
  isFetching,
@@ -90,7 +80,7 @@ function useViewCore({
90
80
  loadError,
91
81
  canView: resolvedCanView,
92
82
  refresh
93
- });
83
+ };
94
84
  }
95
85
 
96
86
  export { useViewCore };