@jskit-ai/users-web 0.1.173 → 0.1.174

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 (112) hide show
  1. package/package.json +18 -149
  2. package/src/client/composables/account-settings/accountSettingsAvatarUploadRuntime.js +2 -2
  3. package/src/client/composables/useAccountSettingsRuntime.js +3 -3
  4. package/src/client/index.js +0 -11
  5. package/test/exportsContract.test.js +3 -29
  6. package/test/settingsPlacementContract.test.js +10 -0
  7. package/fixtures/crud-list-date-filters/App.vue +0 -107
  8. package/fixtures/crud-list-date-filters/index.html +0 -12
  9. package/fixtures/crud-list-date-filters/main.js +0 -24
  10. package/fixtures/crud-list-date-filters/vite.config.mjs +0 -18
  11. package/src/client/bulkActions.js +0 -47
  12. package/src/client/components/CrudAddEditScreen.vue +0 -186
  13. package/src/client/components/CrudDeleteAction.vue +0 -93
  14. package/src/client/components/CrudListBulkActionSurface.vue +0 -126
  15. package/src/client/components/CrudListDateFilterControl.vue +0 -188
  16. package/src/client/components/CrudListFilterSurface.vue +0 -388
  17. package/src/client/components/CrudListRecordActionMenu.vue +0 -120
  18. package/src/client/components/CrudListScreen.vue +0 -501
  19. package/src/client/components/CrudViewScreen.vue +0 -197
  20. package/src/client/composables/crud/crudBindingSupport.js +0 -75
  21. package/src/client/composables/crud/crudHttpClientSupport.js +0 -57
  22. package/src/client/composables/crud/crudJsonApiTransportSupport.js +0 -145
  23. package/src/client/composables/crud/crudLookupFieldLabelSupport.js +0 -151
  24. package/src/client/composables/crud/crudLookupFieldRuntime.js +0 -251
  25. package/src/client/composables/crud/crudSchemaFormHelpers.js +0 -464
  26. package/src/client/composables/internal/crudListFilterLookupSupport.js +0 -161
  27. package/src/client/composables/internal/crudListParentTitleSupport.js +0 -171
  28. package/src/client/composables/internal/useOperationScope.js +0 -144
  29. package/src/client/composables/records/useAddEdit.js +0 -224
  30. package/src/client/composables/records/useCrudAddEdit.js +0 -227
  31. package/src/client/composables/records/useCrudList.js +0 -101
  32. package/src/client/composables/records/useCrudView.js +0 -47
  33. package/src/client/composables/records/useList.js +0 -500
  34. package/src/client/composables/records/useView.js +0 -164
  35. package/src/client/composables/runtime/addEditUiRuntime.js +0 -130
  36. package/src/client/composables/runtime/listUiRuntime.js +0 -123
  37. package/src/client/composables/runtime/modelStateHelpers.js +0 -90
  38. package/src/client/composables/runtime/operationAdapters.js +0 -34
  39. package/src/client/composables/runtime/operationUiHelpers.js +0 -125
  40. package/src/client/composables/runtime/operationValidationHelpers.js +0 -51
  41. package/src/client/composables/runtime/useAddEditCore.js +0 -112
  42. package/src/client/composables/runtime/useCommandCore.js +0 -123
  43. package/src/client/composables/runtime/useEndpointResource.js +0 -199
  44. package/src/client/composables/runtime/useFieldErrorBag.js +0 -61
  45. package/src/client/composables/runtime/useListCore.js +0 -112
  46. package/src/client/composables/runtime/useUiFeedback.js +0 -98
  47. package/src/client/composables/runtime/useViewCore.js +0 -93
  48. package/src/client/composables/runtime/viewUiRuntime.js +0 -96
  49. package/src/client/composables/support/errorMessageHelpers.js +0 -66
  50. package/src/client/composables/support/listQueryParamSupport.js +0 -473
  51. package/src/client/composables/support/listSearchSupport.js +0 -70
  52. package/src/client/composables/support/refValueHelpers.js +0 -19
  53. package/src/client/composables/support/requestQueryRuntimeSupport.js +0 -141
  54. package/src/client/composables/support/resourceLoadStateHelpers.js +0 -208
  55. package/src/client/composables/support/routeTemplateHelpers.js +0 -285
  56. package/src/client/composables/support/scopeHelpers.js +0 -145
  57. package/src/client/composables/useAccess.js +0 -109
  58. package/src/client/composables/useCommand.js +0 -118
  59. package/src/client/composables/useCrudAddEditScreen.js +0 -88
  60. package/src/client/composables/useCrudDeleteAction.js +0 -160
  61. package/src/client/composables/useCrudListBulkActions.js +0 -147
  62. package/src/client/composables/useCrudListFilterLookups.js +0 -146
  63. package/src/client/composables/useCrudListFilters.js +0 -339
  64. package/src/client/composables/useCrudListParentTitle.js +0 -151
  65. package/src/client/composables/useCrudListRowActions.js +0 -144
  66. package/src/client/composables/useCrudListScreen.js +0 -237
  67. package/src/client/composables/useCrudViewScreen.js +0 -77
  68. package/src/client/composables/usePagedCollection.js +0 -181
  69. package/src/client/composables/useRealtimeQueryInvalidation.js +0 -156
  70. package/src/client/composables/useScopeRuntime.js +0 -135
  71. package/src/client/filters.js +0 -15
  72. package/src/client/lib/httpClient.js +0 -47
  73. package/src/client/lib/permissions.js +0 -34
  74. package/src/client/rowActions.js +0 -47
  75. package/src/client/support/contractGuards.js +0 -34
  76. package/src/client/support/crudListDateFilterSupport.js +0 -91
  77. package/test/addEditUiRuntime.test.js +0 -110
  78. package/test/crudBindingSupport.test.js +0 -110
  79. package/test/crudHttpClientSupport.test.js +0 -77
  80. package/test/crudJsonApiTransportSupport.test.js +0 -179
  81. package/test/crudListBulkActionSurface.test.js +0 -27
  82. package/test/crudListDateFilterSupport.test.js +0 -92
  83. package/test/crudListDateFilterSurface.browser.test.js +0 -182
  84. package/test/crudListFilterSurface.test.js +0 -90
  85. package/test/crudLookupFieldRuntime.test.js +0 -264
  86. package/test/crudScreenComponents.test.js +0 -117
  87. package/test/errorIntentContract.test.js +0 -31
  88. package/test/errorMessageHelpers.test.js +0 -28
  89. package/test/listQueryParamSupport.test.js +0 -223
  90. package/test/listUiRuntime.test.js +0 -102
  91. package/test/operationValidationHelpers.test.js +0 -64
  92. package/test/permissions.test.js +0 -35
  93. package/test/refValueHelpers.test.js +0 -14
  94. package/test/requestTransportOptions.test.js +0 -457
  95. package/test/resourceLoadStateHelpers.test.js +0 -189
  96. package/test/routeTemplateHelpers.test.js +0 -85
  97. package/test/scopeHelpers.test.js +0 -57
  98. package/test/useAddEditCore.test.js +0 -124
  99. package/test/useAddEditRequestQueryParams.test.js +0 -190
  100. package/test/useCrudAddEdit.test.js +0 -415
  101. package/test/useCrudDeleteAction.test.js +0 -139
  102. package/test/useCrudListBulkActions.test.js +0 -65
  103. package/test/useCrudListFilterLookups.test.js +0 -114
  104. package/test/useCrudListFilters.test.js +0 -293
  105. package/test/useCrudListParentTitle.test.js +0 -262
  106. package/test/useCrudListRowActions.test.js +0 -77
  107. package/test/useListRouteInitialization.test.js +0 -337
  108. package/test/useListSearchSupport.test.js +0 -61
  109. package/test/usePagedCollection.test.js +0 -53
  110. package/test/useViewRequestQueryParams.test.js +0 -20
  111. package/test/viewCoreLoading.test.js +0 -44
  112. package/test/viewUiRuntime.test.js +0 -95
@@ -1,500 +0,0 @@
1
- import { computed, onScopeDispose, proxyRefs, ref, watch } from "vue";
2
- import { useRouter } from "vue-router";
3
- import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
4
- import { ROUTE_VISIBILITY_WORKSPACE } from "@jskit-ai/kernel/shared/support/visibility";
5
- import { useListCore } from "../runtime/useListCore.js";
6
- import { resolveOperationAdapter } from "../runtime/operationAdapters.js";
7
- import { setupOperationErrorReporting } from "../runtime/operationUiHelpers.js";
8
- import { createListUiRuntime } from "../runtime/listUiRuntime.js";
9
- import { asPlainObject } from "../support/scopeHelpers.js";
10
- import {
11
- buildRequestQueryObject,
12
- createRequestQueryRuntime
13
- } from "../support/requestQueryRuntimeSupport.js";
14
- import {
15
- normalizeListSearchConfig,
16
- matchesLocalSearch
17
- } from "../support/listSearchSupport.js";
18
- import {
19
- normalizeListSyncToRouteConfig,
20
- resolveQueryParamDescriptors,
21
- resolveActiveQueryParamEntries,
22
- resolveWritableQueryParamBindings,
23
- buildQueryParamEntriesToken,
24
- parseRouteBindingValue,
25
- areQueryParamBindingValuesEqual,
26
- buildRouteQueryCompareToken,
27
- mergeManagedQueryParamKeyHistory,
28
- resolveRouteSyncManagedKeys
29
- } from "../support/listQueryParamSupport.js";
30
- import {
31
- resolveRouteParamNamesInOrder,
32
- } from "../support/routeTemplateHelpers.js";
33
-
34
- const EMPTY_ROUTE_SYNC_QUERY_PARAM_BLACKLIST = Object.freeze([]);
35
-
36
- function useList({
37
- ownershipFilter = ROUTE_VISIBILITY_WORKSPACE,
38
- surfaceId = "",
39
- access = "auto",
40
- apiSuffix = "",
41
- queryKeyFactory = null,
42
- viewPermissions = [],
43
- readEnabled = true,
44
- placementSource = "users-web.list",
45
- fallbackLoadError = "Unable to load list.",
46
- initialPageParam = null,
47
- getNextPageParam,
48
- selectItems,
49
- client = null,
50
- transport = null,
51
- requestOptions,
52
- queryOptions,
53
- requestRecovery,
54
- requestRecoveryLabel = "List",
55
- realtime = null,
56
- adapter = null,
57
- recordIdParam = "recordId",
58
- recordIdSelector = null,
59
- viewUrlTemplate = "",
60
- editUrlTemplate = "",
61
- search = null,
62
- queryParams = null,
63
- routeQueryValueResolvers = null,
64
- requestQueryParams = null,
65
- requestFieldsets = null,
66
- syncToRoute = false
67
- } = {}) {
68
- const searchConfig = normalizeListSearchConfig(search);
69
- const routeSyncConfig = normalizeListSyncToRouteConfig(syncToRoute, {
70
- defaultSearchParam: searchConfig.queryParam
71
- });
72
- const routeSyncHydrated = ref(
73
- routeSyncConfig.enabled !== true || routeSyncConfig.hydrateFromRoute !== true
74
- );
75
- const router = routeSyncConfig.enabled === true ? useRouter() : null;
76
- const searchQuery = ref(searchConfig.initialQuery);
77
- const debouncedSearchQuery = ref(searchConfig.initialQuery);
78
- let searchDebounceTimer = null;
79
- const isSearchDebouncing = ref(false);
80
-
81
- watch(searchQuery, (value) => {
82
- const normalizedValue = normalizeText(value);
83
- if (searchDebounceTimer) {
84
- clearTimeout(searchDebounceTimer);
85
- }
86
- if (searchConfig.enabled !== true) {
87
- debouncedSearchQuery.value = normalizedValue;
88
- isSearchDebouncing.value = false;
89
- return;
90
- }
91
- isSearchDebouncing.value = true;
92
- searchDebounceTimer = setTimeout(() => {
93
- debouncedSearchQuery.value = normalizedValue;
94
- isSearchDebouncing.value = false;
95
- searchDebounceTimer = null;
96
- }, searchConfig.debounceMs);
97
- }, { immediate: true });
98
-
99
- onScopeDispose(() => {
100
- if (!searchDebounceTimer) {
101
- return;
102
- }
103
- clearTimeout(searchDebounceTimer);
104
- searchDebounceTimer = null;
105
- });
106
-
107
- const operationAdapter = resolveOperationAdapter(adapter, {
108
- context: "useList adapter"
109
- });
110
- const operationScope = operationAdapter.useOperationScope({
111
- ownershipFilter,
112
- surfaceId,
113
- access,
114
- placementSource,
115
- apiSuffix,
116
- readEnabled,
117
- queryKeyFactory,
118
- permissionSets: {
119
- view: viewPermissions
120
- },
121
- realtime
122
- });
123
- if (
124
- routeSyncConfig.enabled === true &&
125
- routeSyncConfig.hydrateFromRoute === true &&
126
- routeSyncConfig.syncSearch === true &&
127
- searchConfig.enabled === true
128
- ) {
129
- const routeQuerySource = asPlainObject(operationScope.routeContext.route?.query || {});
130
- const routeSearchValue = routeQuerySource[routeSyncConfig.searchParam];
131
- const hydratedSearch = normalizeText(Array.isArray(routeSearchValue) ? routeSearchValue[0] : routeSearchValue);
132
-
133
- if (searchDebounceTimer) {
134
- clearTimeout(searchDebounceTimer);
135
- searchDebounceTimer = null;
136
- }
137
-
138
- searchQuery.value = hydratedSearch;
139
- debouncedSearchQuery.value = hydratedSearch;
140
- isSearchDebouncing.value = false;
141
- }
142
- const canView = operationScope.permissionGate("view");
143
- const queryParamsContext = computed(() => {
144
- return Object.freeze({
145
- surfaceId: operationScope.routeContext.currentSurfaceId.value,
146
- scopeParamValue: operationScope.scopeParamValue.value,
147
- ownershipFilter: operationScope.normalizedOwnershipFilter
148
- });
149
- });
150
- const queryParamDescriptors = computed(() => {
151
- return resolveQueryParamDescriptors(queryParams, queryParamsContext.value, {
152
- routeValueResolvers: routeQueryValueResolvers
153
- });
154
- });
155
- const requestQueryRuntime = createRequestQueryRuntime({
156
- requestQueryParams,
157
- requestFieldsets,
158
- context: queryParamsContext
159
- });
160
- const {
161
- activeRequestQueryParamEntries,
162
- activeRequestQueryParamsToken,
163
- activeRequestFieldsets,
164
- activeRequestFieldsetsToken,
165
- queryKeyParts: requestQueryKeyParts
166
- } = requestQueryRuntime;
167
- const declaredQueryParamKeys = computed(() => {
168
- return queryParamDescriptors.value.map((descriptor) => descriptor.key);
169
- });
170
- const activeQueryParamEntries = computed(() => {
171
- return resolveActiveQueryParamEntries(queryParamDescriptors.value);
172
- });
173
- const activeQueryParamsToken = computed(() => buildQueryParamEntriesToken(activeQueryParamEntries.value));
174
- const writableQueryParamBindings = computed(() => {
175
- return resolveWritableQueryParamBindings(queryParamDescriptors.value);
176
- });
177
- const activeSearchQuery = computed(() => {
178
- if (searchConfig.enabled !== true) {
179
- return "";
180
- }
181
- const normalized = normalizeText(debouncedSearchQuery.value);
182
- if (!normalized || normalized.length < searchConfig.minLength) {
183
- return "";
184
- }
185
- return normalized;
186
- });
187
- const querySearchEnabled = computed(() => searchConfig.enabled === true && searchConfig.mode === "query");
188
- const listPath = computed(() => {
189
- return normalizeText(operationScope.apiPath.value);
190
- });
191
- const listRequestOptions = computed(() => {
192
- const entries = [];
193
-
194
- if (querySearchEnabled.value) {
195
- const queryValue = activeSearchQuery.value;
196
- if (queryValue) {
197
- entries.push({
198
- key: searchConfig.queryParam,
199
- values: [queryValue]
200
- });
201
- }
202
- }
203
-
204
- entries.push(...activeRequestQueryParamEntries.value);
205
- entries.push(...activeQueryParamEntries.value);
206
-
207
- const query = buildRequestQueryObject(entries, {
208
- fieldsets: activeRequestFieldsets.value
209
- });
210
- const baseOptions = asPlainObject(requestOptions);
211
- if (Object.keys(query).length < 1) {
212
- return baseOptions;
213
- }
214
-
215
- return {
216
- ...baseOptions,
217
- query
218
- };
219
- });
220
- const listQueryKey = computed(() => {
221
- const sourceQueryKey = operationScope.queryKey.value;
222
- const baseQueryKey = Array.isArray(sourceQueryKey)
223
- ? [...sourceQueryKey]
224
- : sourceQueryKey == null
225
- ? []
226
- : [sourceQueryKey];
227
- baseQueryKey.push(...requestQueryKeyParts.value);
228
- if (querySearchEnabled.value) {
229
- baseQueryKey.push("__search__", searchConfig.queryParam, activeSearchQuery.value);
230
- }
231
- if (activeQueryParamsToken.value) {
232
- baseQueryKey.push("__query__", activeQueryParamsToken.value);
233
- }
234
- return baseQueryKey;
235
- });
236
-
237
- const listReadEnabled = computed(() => canView.value && routeSyncHydrated.value);
238
- const list = useListCore({
239
- queryKey: listQueryKey,
240
- path: listPath,
241
- enabled: operationScope.queryCanRun(listReadEnabled),
242
- client,
243
- transport,
244
- initialPageParam,
245
- getNextPageParam,
246
- selectItems,
247
- requestOptions: listRequestOptions,
248
- queryOptions,
249
- requestRecovery,
250
- requestRecoveryLabel,
251
- fallbackLoadError
252
- });
253
- const routeSyncApplying = ref(false);
254
- const routeSyncManagedKeyHistory = ref([]);
255
- const routeSyncQueryParamBlacklist = computed(() => {
256
- if (routeSyncConfig.enabled !== true || routeSyncConfig.syncQueryParams !== true) {
257
- return EMPTY_ROUTE_SYNC_QUERY_PARAM_BLACKLIST;
258
- }
259
- return routeSyncConfig.queryParamBlacklist;
260
- });
261
- const routeSyncQueryParamBlacklistSet = computed(() => {
262
- return new Set(routeSyncQueryParamBlacklist.value);
263
- });
264
- if (routeSyncConfig.enabled === true && routeSyncConfig.syncQueryParams === true) {
265
- watch(declaredQueryParamKeys, (nextKeys) => {
266
- routeSyncManagedKeyHistory.value = mergeManagedQueryParamKeyHistory(
267
- routeSyncManagedKeyHistory.value,
268
- nextKeys
269
- );
270
- }, { immediate: true });
271
- }
272
- const routeSyncManagedKeys = computed(() => {
273
- const managedKeys = resolveRouteSyncManagedKeys({
274
- searchEnabled: searchConfig.enabled,
275
- searchParam: routeSyncConfig.searchParam,
276
- syncSearch: routeSyncConfig.enabled === true && routeSyncConfig.syncSearch === true,
277
- syncQueryParams: routeSyncConfig.enabled === true && routeSyncConfig.syncQueryParams === true,
278
- declaredKeys: declaredQueryParamKeys.value,
279
- keyHistory: routeSyncManagedKeyHistory.value
280
- });
281
- if (routeSyncConfig.enabled !== true || routeSyncConfig.syncQueryParams !== true) {
282
- return managedKeys;
283
- }
284
-
285
- const output = new Set(managedKeys);
286
- for (const key of routeSyncQueryParamBlacklist.value) {
287
- output.add(key);
288
- }
289
- return [...output].sort((left, right) => left.localeCompare(right));
290
- });
291
- const routeSyncDesiredQuery = computed(() => {
292
- if (routeSyncConfig.enabled !== true) {
293
- return {};
294
- }
295
-
296
- const desiredQuery = {};
297
- if (routeSyncConfig.syncSearch === true && searchConfig.enabled === true) {
298
- const normalizedSearch = normalizeText(searchQuery.value);
299
- if (normalizedSearch) {
300
- desiredQuery[routeSyncConfig.searchParam] = normalizedSearch;
301
- }
302
- }
303
- if (routeSyncConfig.syncQueryParams === true) {
304
- for (const entry of activeQueryParamEntries.value) {
305
- if (routeSyncQueryParamBlacklistSet.value.has(entry.key)) {
306
- continue;
307
- }
308
- if (entry.values.length === 1) {
309
- desiredQuery[entry.key] = entry.values[0];
310
- continue;
311
- }
312
- desiredQuery[entry.key] = [...entry.values];
313
- }
314
- }
315
-
316
- return desiredQuery;
317
- });
318
- if (routeSyncConfig.enabled === true) {
319
- watch(
320
- () => operationScope.routeContext.route?.query || {},
321
- (routeQuery) => {
322
- const initialHydration = routeSyncHydrated.value !== true;
323
- if (routeSyncConfig.hydrateFromRoute !== true || routeSyncApplying.value === true) {
324
- routeSyncHydrated.value = true;
325
- return;
326
- }
327
-
328
- const routeQuerySource = asPlainObject(routeQuery);
329
- if (routeSyncConfig.syncSearch === true && searchConfig.enabled === true) {
330
- const routeSearchValue = routeQuerySource[routeSyncConfig.searchParam];
331
- const nextSearch = normalizeText(Array.isArray(routeSearchValue) ? routeSearchValue[0] : routeSearchValue);
332
- if (nextSearch !== searchQuery.value) {
333
- searchQuery.value = nextSearch;
334
- }
335
- }
336
- if (routeSyncConfig.syncQueryParams === true) {
337
- for (const binding of writableQueryParamBindings.value) {
338
- if (routeSyncQueryParamBlacklistSet.value.has(binding.key)) {
339
- continue;
340
- }
341
- const nextValue = parseRouteBindingValue(binding, routeQuerySource[binding.key], {
342
- initial: initialHydration
343
- });
344
- const currentValue = typeof binding.get === "function" ? binding.get() : undefined;
345
- if (areQueryParamBindingValuesEqual(currentValue, nextValue)) {
346
- continue;
347
- }
348
- try {
349
- binding.set(nextValue);
350
- } catch {
351
- // Ignore non-writable query param bindings.
352
- }
353
- }
354
- }
355
-
356
- routeSyncHydrated.value = true;
357
- },
358
- {
359
- immediate: true
360
- }
361
- );
362
-
363
- watch(
364
- [routeSyncDesiredQuery, routeSyncManagedKeys],
365
- async ([desiredQuery, managedKeys]) => {
366
- if (routeSyncHydrated.value !== true || routeSyncApplying.value === true) {
367
- return;
368
- }
369
-
370
- const managedKeySet = new Set(Array.isArray(managedKeys) ? managedKeys : []);
371
- const currentQuery = asPlainObject(operationScope.routeContext.route?.query || {});
372
- const nextQuery = {};
373
-
374
- for (const [key, value] of Object.entries(currentQuery)) {
375
- if (managedKeySet.has(key)) {
376
- continue;
377
- }
378
- nextQuery[key] = value;
379
- }
380
- for (const [key, value] of Object.entries(asPlainObject(desiredQuery))) {
381
- nextQuery[key] = value;
382
- }
383
-
384
- if (buildRouteQueryCompareToken(currentQuery) === buildRouteQueryCompareToken(nextQuery)) {
385
- return;
386
- }
387
-
388
- routeSyncApplying.value = true;
389
- try {
390
- if (routeSyncConfig.mode === "push") {
391
- await router.push({
392
- query: nextQuery
393
- });
394
- } else {
395
- await router.replace({
396
- query: nextQuery
397
- });
398
- }
399
- } finally {
400
- routeSyncApplying.value = false;
401
- }
402
- }
403
- );
404
- }
405
-
406
- watch(activeSearchQuery, (nextValue, previousValue) => {
407
- if (!querySearchEnabled.value) {
408
- return;
409
- }
410
- if (nextValue === previousValue) {
411
- return;
412
- }
413
-
414
- list.trimToFirstPage();
415
- });
416
- watch(
417
- [
418
- activeQueryParamsToken,
419
- activeRequestQueryParamsToken,
420
- activeRequestFieldsetsToken
421
- ],
422
- () => {
423
- list.trimToFirstPage();
424
- }
425
- );
426
- const filteredItems = computed(() => {
427
- const sourceItems = Array.isArray(list.items.value) ? list.items.value : [];
428
- if (searchConfig.enabled !== true || searchConfig.mode !== "local") {
429
- return sourceItems;
430
- }
431
-
432
- const queryValue = activeSearchQuery.value;
433
- if (!queryValue) {
434
- return sourceItems;
435
- }
436
-
437
- return sourceItems.filter((item) => matchesLocalSearch(item, queryValue, searchConfig.fields));
438
- });
439
-
440
- const isInitialLoading = operationScope.isLoading(list.isInitialLoading);
441
- const isFetching = operationScope.isLoading(list.isFetching);
442
- const isRefetching = computed(() => Boolean(isFetching.value && !isInitialLoading.value));
443
- const loadError = operationScope.loadError(list.loadError);
444
- const isLoading = operationScope.isLoading(list.isLoading);
445
- const listUiRuntime = createListUiRuntime({
446
- items: filteredItems,
447
- isInitialLoading,
448
- recordIdParam,
449
- recordIdSelector,
450
- routeParams: computed(() => operationScope.routeContext.route?.params || {}),
451
- routeParamNames: computed(() => resolveRouteParamNamesInOrder(operationScope.routeContext.route)),
452
- routePath: computed(() => operationScope.routeContext.route?.path || ""),
453
- viewUrlTemplate,
454
- editUrlTemplate
455
- });
456
- setupOperationErrorReporting({
457
- source: `${placementSource}.load`,
458
- loadError,
459
- dedupeWindowMs: 0,
460
- loadActionFactory: () => ({
461
- label: "Retry",
462
- dismissOnRun: true,
463
- handler() {
464
- void list.reload();
465
- }
466
- })
467
- });
468
-
469
- return proxyRefs({
470
- canView,
471
- isInitialLoading,
472
- isFetching,
473
- isRefetching,
474
- isLoading,
475
- isLoadingMore: list.isLoadingMore,
476
- hasMore: list.hasMore,
477
- loadError,
478
- pages: list.pages,
479
- items: filteredItems,
480
- reload: list.reload,
481
- loadMore: list.loadMore,
482
- hasViewUrl: listUiRuntime.hasViewUrl,
483
- hasEditUrl: listUiRuntime.hasEditUrl,
484
- actionColumnCount: listUiRuntime.actionColumnCount,
485
- showListSkeleton: listUiRuntime.showListSkeleton,
486
- resolveRowKey: listUiRuntime.resolveRowKey,
487
- resolveParams: listUiRuntime.resolveParams,
488
- resolveViewUrl: listUiRuntime.resolveViewUrl,
489
- resolveEditUrl: listUiRuntime.resolveEditUrl,
490
- searchEnabled: searchConfig.enabled,
491
- searchMode: searchConfig.mode,
492
- searchQuery,
493
- searchLabel: searchConfig.label,
494
- searchPlaceholder: searchConfig.placeholder,
495
- isSearchDebouncing,
496
- activeQueryParamsToken
497
- });
498
- }
499
-
500
- export { useList };
@@ -1,164 +0,0 @@
1
- import { computed, proxyRefs } from "vue";
2
- import { useRoute } from "vue-router";
3
- import { ROUTE_VISIBILITY_WORKSPACE } from "@jskit-ai/kernel/shared/support/visibility";
4
- import { useViewCore } from "../runtime/useViewCore.js";
5
- import { useEndpointResource } from "../runtime/useEndpointResource.js";
6
- import { resolveOperationAdapter } from "../runtime/operationAdapters.js";
7
- import { setupOperationErrorReporting } from "../runtime/operationUiHelpers.js";
8
- import { createViewUiRuntime } from "../runtime/viewUiRuntime.js";
9
- import { createRequestQueryRuntime } from "../support/requestQueryRuntimeSupport.js";
10
- import { resolveRouteParamNamesInOrder } from "../support/routeTemplateHelpers.js";
11
- import { resolveOperationRealtimeOptions } from "../useRealtimeQueryInvalidation.js";
12
-
13
- function useView({
14
- resource = null,
15
- ownershipFilter = ROUTE_VISIBILITY_WORKSPACE,
16
- surfaceId = "",
17
- access = "auto",
18
- apiSuffix = "",
19
- queryKeyFactory = null,
20
- viewPermissions = [],
21
- readMethod = "GET",
22
- readEnabled = true,
23
- client = null,
24
- transport = null,
25
- requestRecovery = null,
26
- requestRecoveryLabel = "Resource",
27
- placementSource = "users-web.view",
28
- fallbackLoadError = "Unable to load resource.",
29
- notFoundStatuses = [404],
30
- notFoundMessage = "Record not found.",
31
- model,
32
- mapLoadedToModel,
33
- requestQueryParams = null,
34
- requestFieldsets = null,
35
- recordIdParam = "recordId",
36
- routeParams = null,
37
- routeRecordId = null,
38
- apiUrlTemplate = "",
39
- listUrlTemplate = "",
40
- editUrlTemplate = "",
41
- includeRecordIdInQueryKey = false,
42
- realtime = undefined,
43
- adapter = null
44
- } = {}) {
45
- const route = useRoute();
46
- const viewUiRuntime = createViewUiRuntime({
47
- recordIdParam,
48
- routeParams: routeParams ?? computed(() => route?.params || {}),
49
- routeParamNames: computed(() => resolveRouteParamNamesInOrder(route)),
50
- routePath: computed(() => route?.path || ""),
51
- routeRecordId,
52
- apiUrlTemplate,
53
- listUrlTemplate,
54
- editUrlTemplate
55
- });
56
- const normalizedApiUrlTemplate = String(apiUrlTemplate || "").trim();
57
- const effectiveApiSuffix = normalizedApiUrlTemplate ? viewUiRuntime.apiSuffix : apiSuffix;
58
- const operationAdapter = resolveOperationAdapter(adapter, {
59
- context: "useView adapter"
60
- });
61
- const operationScope = operationAdapter.useOperationScope({
62
- ownershipFilter,
63
- surfaceId,
64
- access,
65
- placementSource,
66
- apiSuffix: effectiveApiSuffix,
67
- readEnabled,
68
- queryKeyFactory,
69
- permissionSets: {
70
- view: viewPermissions
71
- },
72
- realtime: resolveOperationRealtimeOptions({
73
- realtime,
74
- fallbackRealtime: resource?.operations?.view?.realtime ||
75
- resource?.operations?.list?.realtime ||
76
- null
77
- })
78
- });
79
- const queryParamsContext = computed(() => {
80
- return Object.freeze({
81
- surfaceId: operationScope.routeContext.currentSurfaceId.value,
82
- scopeParamValue: operationScope.scopeParamValue.value,
83
- ownershipFilter: operationScope.normalizedOwnershipFilter,
84
- recordId: viewUiRuntime.recordId.value
85
- });
86
- });
87
- const baseQueryKey = computed(() => {
88
- const source = Array.isArray(operationScope.queryKey.value) ? operationScope.queryKey.value : [];
89
- const next = [...source];
90
- if (!includeRecordIdInQueryKey) {
91
- return next;
92
- }
93
-
94
- const recordIdToken = String(viewUiRuntime.recordId.value || "").trim();
95
- return [...next, recordIdToken];
96
- });
97
- const requestQueryRuntime = createRequestQueryRuntime({
98
- requestQueryParams,
99
- requestFieldsets,
100
- context: queryParamsContext,
101
- sourceQueryKey: baseQueryKey
102
- });
103
- const canView = operationScope.permissionGate("view");
104
-
105
- const endpointResource = useEndpointResource({
106
- queryKey: requestQueryRuntime.queryKey,
107
- path: operationScope.apiPath,
108
- enabled: operationScope.queryCanRun(canView),
109
- client,
110
- readMethod,
111
- readQuery: requestQueryRuntime.requestQuery,
112
- transport,
113
- requestRecovery,
114
- requestRecoveryLabel,
115
- refreshOnPull: true,
116
- fallbackLoadError
117
- });
118
-
119
- const view = useViewCore({
120
- resource: endpointResource,
121
- model,
122
- canView,
123
- mapLoadedToModel,
124
- notFoundStatuses,
125
- notFoundMessage
126
- });
127
-
128
- const loadError = operationScope.loadError(view.loadError);
129
- const isLoading = operationScope.isLoading(view.isLoading);
130
- const isFetching = operationScope.isLoading(view.isFetching);
131
- const isRefetching = computed(() => Boolean(isFetching.value && !isLoading.value));
132
- setupOperationErrorReporting({
133
- source: `${placementSource}.load`,
134
- loadError,
135
- notFoundError: view.notFoundError,
136
- dedupeWindowMs: 0,
137
- loadActionFactory: () => ({
138
- label: "Retry",
139
- dismissOnRun: true,
140
- handler() {
141
- void view.refresh();
142
- }
143
- })
144
- });
145
-
146
- return proxyRefs({
147
- record: view.record,
148
- recordId: viewUiRuntime.recordId,
149
- listUrl: viewUiRuntime.listUrl,
150
- editUrl: viewUiRuntime.editUrl,
151
- resolveParams: viewUiRuntime.resolveParams,
152
- canView,
153
- isLoading,
154
- isFetching,
155
- isRefetching,
156
- isNotFound: view.isNotFound,
157
- notFoundError: view.notFoundError,
158
- loadError,
159
- refresh: view.refresh,
160
- resource: endpointResource
161
- });
162
- }
163
-
164
- export { useView };