@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
@@ -30,19 +30,19 @@ test("createListUiRuntime resolves nested route links from the parent list scope
30
30
  isInitialLoading: ref(false),
31
31
  recordIdParam: "petId",
32
32
  routeParams: ref({
33
- workspaceSlug: "dogandgroom",
33
+ workspaceSlug: "harbor",
34
34
  contactId: "541841",
35
35
  petId: "715528"
36
36
  }),
37
37
  routeParamNames: ref(["workspaceSlug", "contactId", "petId"]),
38
- routePath: ref("/w/dogandgroom/admin/contacts/541841/pets/715528"),
38
+ routePath: ref("/w/harbor/admin/contacts/541841/pets/715528"),
39
39
  viewUrlTemplate: "./:petId",
40
40
  editUrlTemplate: "./:petId/edit"
41
41
  });
42
42
 
43
- assert.equal(runtime.resolveParams("./new"), "/w/dogandgroom/admin/contacts/541841/pets/new");
44
- assert.equal(runtime.resolveViewUrl({ id: "901" }), "/w/dogandgroom/admin/contacts/541841/pets/901");
45
- assert.equal(runtime.resolveEditUrl({ id: "901" }), "/w/dogandgroom/admin/contacts/541841/pets/901/edit");
43
+ assert.equal(runtime.resolveParams("./new"), "/w/harbor/admin/contacts/541841/pets/new");
44
+ assert.equal(runtime.resolveViewUrl({ id: "901" }), "/w/harbor/admin/contacts/541841/pets/901");
45
+ assert.equal(runtime.resolveEditUrl({ id: "901" }), "/w/harbor/admin/contacts/541841/pets/901/edit");
46
46
  });
47
47
 
48
48
  test("createListUiRuntime resolves templates that depend on existing route params", () => {
@@ -3,6 +3,7 @@ import test from "node:test";
3
3
  import { QueryClient, QueryObserver, VueQueryPlugin } from "@tanstack/vue-query";
4
4
  import { createSSRApp, h } from "vue";
5
5
  import { renderToString } from "vue/server-renderer";
6
+ import { routeLocationKey } from "vue-router";
6
7
 
7
8
  import {
8
9
  buildEndpointReadRequestOptions,
@@ -10,10 +11,7 @@ import {
10
11
  useEndpointResource
11
12
  } from "../src/client/composables/runtime/useEndpointResource.js";
12
13
  import { useCommand } from "../src/client/composables/useCommand.js";
13
- import {
14
- configureHttpWebClient,
15
- resetHttpWebClientForTests
16
- } from "../src/client/lib/httpClient.js";
14
+ import { configureHttpWebClient } from "../src/client/lib/httpClient.js";
17
15
  import { buildListRequestOptions, useListCore } from "../src/client/composables/runtime/useListCore.js";
18
16
  import {
19
17
  resolveOperationRealtimeOptions,
@@ -310,7 +308,7 @@ test("realtime bursts never cancel a read in flight and read once more after it"
310
308
 
311
309
  test("endpoint resource reads attach request recovery metadata to query options", async () => {
312
310
  const queryClient = new QueryClient();
313
- const queryKey = ["project-access", "beepollen"];
311
+ const queryKey = ["project-access", "acme"];
314
312
  const app = createSSRApp({
315
313
  setup() {
316
314
  useEndpointResource({
@@ -448,7 +446,7 @@ test("endpoint resources use the configured http-web HTTP client by default", as
448
446
  enabled: false
449
447
  },
450
448
  resolveRequestUrl(url) {
451
- return url.replace(/^\/api\//u, "/api/app/beepollen/");
449
+ return url.replace(/^\/api\//u, "/api/app/acme/");
452
450
  },
453
451
  fetchImpl: async (url, options) => {
454
452
  calls.push([url, options]);
@@ -475,8 +473,8 @@ test("endpoint resources use the configured http-web HTTP client by default", as
475
473
  const app = createSSRApp({
476
474
  setup() {
477
475
  resource = useEndpointResource({
478
- queryKey: ["vibe64-sessions"],
479
- path: "/api/vibe64/sessions"
476
+ queryKey: ["chat-sessions"],
477
+ path: "/api/chat/sessions"
480
478
  });
481
479
  return () => h("div");
482
480
  }
@@ -488,9 +486,9 @@ test("endpoint resources use the configured http-web HTTP client by default", as
488
486
 
489
487
  await resource.reload();
490
488
 
491
- assert.equal(calls.at(-1)?.[0], "/api/app/beepollen/vibe64/sessions");
489
+ assert.equal(calls.at(-1)?.[0], "/api/app/acme/chat/sessions");
492
490
  } finally {
493
- resetHttpWebClientForTests();
491
+ configureHttpWebClient();
494
492
  }
495
493
  });
496
494
 
@@ -503,7 +501,7 @@ test("commands use the configured http-web HTTP client by default", async () =>
503
501
  enabled: false
504
502
  },
505
503
  resolveRequestUrl(url) {
506
- return url.replace(/^\/api\//u, "/api/app/beepollen/");
504
+ return url.replace(/^\/api\//u, "/api/app/acme/");
507
505
  },
508
506
  fetchImpl: async (url, options) => {
509
507
  calls.push([url, options]);
@@ -531,11 +529,12 @@ test("commands use the configured http-web HTTP client by default", async () =>
531
529
  setup() {
532
530
  command = useCommand({
533
531
  access: "always",
534
- apiSuffix: "/vibe64/sessions"
532
+ apiSuffix: "/chat/sessions"
535
533
  });
536
534
  return () => h("div");
537
535
  }
538
536
  });
537
+ app.provide(routeLocationKey, { path: "/" });
539
538
  app.use(VueQueryPlugin, {
540
539
  queryClient
541
540
  });
@@ -543,10 +542,10 @@ test("commands use the configured http-web HTTP client by default", async () =>
543
542
 
544
543
  await command.run();
545
544
 
546
- assert.equal(calls.at(-1)?.[0], "/api/app/beepollen/vibe64/sessions");
545
+ assert.equal(calls.at(-1)?.[0], "/api/app/acme/chat/sessions");
547
546
  assert.equal(calls.at(-1)?.[1]?.method, "POST");
548
547
  } finally {
549
- resetHttpWebClientForTests();
548
+ configureHttpWebClient();
550
549
  }
551
550
  });
552
551
 
@@ -586,6 +585,7 @@ test("commands use public CRUD resource access without a CSRF session preflight"
586
585
  return () => h("div");
587
586
  }
588
587
  });
588
+ app.provide(routeLocationKey, { path: "/" });
589
589
  app.use(VueQueryPlugin, {
590
590
  queryClient
591
591
  });
@@ -598,6 +598,6 @@ test("commands use public CRUD resource access without a CSRF session preflight"
598
598
  assert.equal(calls[0][1].method, "DELETE");
599
599
  assert.equal(Object.hasOwn(calls[0][1], "csrf"), false);
600
600
  } finally {
601
- resetHttpWebClientForTests();
601
+ configureHttpWebClient();
602
602
  }
603
603
  });
@@ -30,9 +30,9 @@ test("resolveRouteParamNamesInOrder prefers matched route templates", () => {
30
30
  });
31
31
 
32
32
  test("resolveScopedRoutePathname supports at/before/after anchors", () => {
33
- const currentPathname = "/w/dogandgroom/admin/contacts/541841/pets/715528/edit/advanced";
33
+ const currentPathname = "/w/harbor/admin/contacts/541841/pets/715528/edit/advanced";
34
34
  const params = {
35
- workspaceSlug: "dogandgroom",
35
+ workspaceSlug: "harbor",
36
36
  contactId: "541841",
37
37
  petId: "715528"
38
38
  };
@@ -46,7 +46,7 @@ test("resolveScopedRoutePathname supports at/before/after anchors", () => {
46
46
  anchorParamName: "contactId",
47
47
  anchorMode: "at"
48
48
  }),
49
- "/w/dogandgroom/admin/contacts/541841"
49
+ "/w/harbor/admin/contacts/541841"
50
50
  );
51
51
  assert.equal(
52
52
  resolveScopedRoutePathname({
@@ -56,7 +56,7 @@ test("resolveScopedRoutePathname supports at/before/after anchors", () => {
56
56
  anchorParamName: "petId",
57
57
  anchorMode: "before"
58
58
  }),
59
- "/w/dogandgroom/admin/contacts/541841/pets"
59
+ "/w/harbor/admin/contacts/541841/pets"
60
60
  );
61
61
  assert.equal(
62
62
  resolveScopedRoutePathname({
@@ -66,7 +66,7 @@ test("resolveScopedRoutePathname supports at/before/after anchors", () => {
66
66
  anchorParamName: "petId",
67
67
  anchorMode: "after"
68
68
  }),
69
- "/w/dogandgroom/admin/contacts/541841/pets/715528/edit"
69
+ "/w/harbor/admin/contacts/541841/pets/715528/edit"
70
70
  );
71
71
  });
72
72
 
@@ -133,7 +133,10 @@ test("CRUD list chrome is English by default and follows the active language", a
133
133
  const screen = {
134
134
  records: { hasMore: true, loadError: "" },
135
135
  listPrimaryAction: "/books/new",
136
+ bulkActions: { hasActions: false },
137
+ rowActions: { hasActions: false, hasVisibleActionsFor: () => false },
136
138
  displayRows: [{ key: "1", recordKey: "1", record: { title: "Kindred" } }],
139
+ selectableRows: [],
137
140
  resolveRecordTitle: (record) => record.title
138
141
  };
139
142
 
@@ -15,6 +15,8 @@ test("useAddEditCore writes saved payloads to the submit-time query key", async
15
15
  };
16
16
  const resource = {
17
17
  isSaving: ref(false),
18
+ query: { isPending: ref(false) },
19
+ data: ref(null),
18
20
  async save() {
19
21
  return payload;
20
22
  }
@@ -72,6 +74,8 @@ test("useAddEditCore snapshots the cache key after payload normalization", async
72
74
  };
73
75
  const resource = {
74
76
  isSaving: ref(false),
77
+ query: { isPending: ref(false) },
78
+ data: ref(null),
75
79
  async save() {
76
80
  return payload;
77
81
  }
@@ -4,7 +4,7 @@ import { QueryClient, QueryObserver, VueQueryPlugin } from "@tanstack/vue-query"
4
4
  import { createSSRApp, effectScope, h, nextTick, ref, watch } from "vue";
5
5
  import { renderToString } from "vue/server-renderer";
6
6
  import { createMemoryHistory, createRouter } from "vue-router";
7
- import { configureHttpWebClient, resetHttpWebClientForTests } from "../src/client/lib/httpClient.js";
7
+ import { configureHttpWebClient } from "../src/client/lib/httpClient.js";
8
8
  import {
9
9
  requireCrudDeleteOperation,
10
10
  useCrudDeleteAction
@@ -184,7 +184,7 @@ test("useCrudDeleteAction keeps the record dialog open with useful error feedbac
184
184
  });
185
185
 
186
186
  test("public deletion resolves the configured client without session CSRF", async (t) => {
187
- t.after(resetHttpWebClientForTests);
187
+ t.after(() => configureHttpWebClient());
188
188
  const requests = [];
189
189
  configureHttpWebClient({
190
190
  async request(path, options) {
@@ -207,7 +207,7 @@ test("public deletion resolves the configured client without session CSRF", asyn
207
207
  });
208
208
 
209
209
  test("authenticated deletion retains configured-client CSRF behavior", async (t) => {
210
- t.after(resetHttpWebClientForTests);
210
+ t.after(() => configureHttpWebClient());
211
211
  const requests = [];
212
212
  configureHttpWebClient({
213
213
  async request(path, options) {
@@ -226,7 +226,7 @@ test("authenticated deletion retains configured-client CSRF behavior", async (t)
226
226
  });
227
227
 
228
228
  test("public deletion honors an explicit client override", async (t) => {
229
- t.after(resetHttpWebClientForTests);
229
+ t.after(() => configureHttpWebClient());
230
230
  configureHttpWebClient({
231
231
  request() {
232
232
  assert.fail("The configured client must not replace the explicit override.");
@@ -45,7 +45,7 @@ test("resolveCrudListParentDescriptor selects the nearest lookup route parent",
45
45
  { path: "/w/:workspaceSlug/admin/contacts/:contactId/availabilities" }
46
46
  ],
47
47
  params: {
48
- workspaceSlug: "dogandgroom",
48
+ workspaceSlug: "harbor",
49
49
  contactId: "538779"
50
50
  }
51
51
  },
@@ -80,7 +80,7 @@ test("resolveCrudListParentTitleFromItems uses the hydrated lookup label", () =>
80
80
  route: {
81
81
  matched: [{ path: "/w/:workspaceSlug/admin/contacts/:contactId/availabilities" }],
82
82
  params: {
83
- workspaceSlug: "dogandgroom",
83
+ workspaceSlug: "harbor",
84
84
  contactId: "538779"
85
85
  }
86
86
  },
@@ -113,7 +113,7 @@ test("resolveCrudListParentTitleFromItems ignores raw lookup ids when no hydrate
113
113
  route: {
114
114
  matched: [{ path: "/w/:workspaceSlug/admin/contacts/:contactId/availabilities" }],
115
115
  params: {
116
- workspaceSlug: "dogandgroom",
116
+ workspaceSlug: "harbor",
117
117
  contactId: "538779"
118
118
  }
119
119
  },
@@ -171,7 +171,7 @@ test("resolveCrudListParentDescriptor supports parentRouteParamKey aliases", ()
171
171
  route: {
172
172
  matched: [{ path: "/w/:workspaceSlug/admin/contacts/:contactId/availabilities" }],
173
173
  params: {
174
- workspaceSlug: "dogandgroom",
174
+ workspaceSlug: "harbor",
175
175
  contactId: "538779"
176
176
  }
177
177
  },
@@ -199,7 +199,7 @@ test("useCrudListParentTitle loads the parent record when child rows only expose
199
199
  route: {
200
200
  matched: [{ path: "/w/:workspaceSlug/admin/contacts/:contactId/availabilities" }],
201
201
  params: {
202
- workspaceSlug: "dogandgroom",
202
+ workspaceSlug: "harbor",
203
203
  contactId: "538779"
204
204
  }
205
205
  },
@@ -237,7 +237,7 @@ test("useCrudListParentTitle requests the parent through JSON:API record transpo
237
237
  route: {
238
238
  matched: [{ path: "/w/:workspaceSlug/admin/contacts/:contactId/availabilities" }],
239
239
  params: {
240
- workspaceSlug: "dogandgroom",
240
+ workspaceSlug: "harbor",
241
241
  contactId: "538779"
242
242
  }
243
243
  },
@@ -23,22 +23,3 @@ test("useViewCore prefers resource isInitialLoading/isFetching signals when prov
23
23
  assert.equal(view.isLoading.value, false);
24
24
  assert.equal(view.isFetching.value, true);
25
25
  });
26
-
27
- test("useViewCore falls back to query pending/fetching when resource-level loading refs are absent", () => {
28
- const resource = {
29
- data: ref(null),
30
- query: {
31
- isPending: ref(true),
32
- isFetching: ref(false),
33
- error: ref(null)
34
- },
35
- loadError: ref("")
36
- };
37
-
38
- const view = useViewCore({
39
- resource
40
- });
41
-
42
- assert.equal(view.isLoading.value, true);
43
- assert.equal(view.isFetching.value, false);
44
- });
@@ -27,19 +27,19 @@ test("createViewUiRuntime resolves view links from the record pathname when rout
27
27
  const runtime = createViewUiRuntime({
28
28
  recordIdParam: "contactId",
29
29
  routeParams: ref({
30
- workspaceSlug: "dogandgroom",
30
+ workspaceSlug: "harbor",
31
31
  contactId: "541841",
32
32
  petId: "715528"
33
33
  }),
34
34
  routeParamNames: ref(["workspaceSlug", "contactId", "petId"]),
35
- routePath: ref("/w/dogandgroom/admin/contacts/541841/pets/715528"),
35
+ routePath: ref("/w/harbor/admin/contacts/541841/pets/715528"),
36
36
  listUrlTemplate: "..",
37
37
  editUrlTemplate: "./edit"
38
38
  });
39
39
 
40
- assert.equal(runtime.listUrl.value, "/w/dogandgroom/admin/contacts");
41
- assert.equal(runtime.editUrl.value, "/w/dogandgroom/admin/contacts/541841/edit");
42
- assert.equal(runtime.resolveParams("./edit"), "/w/dogandgroom/admin/contacts/541841/edit");
40
+ assert.equal(runtime.listUrl.value, "/w/harbor/admin/contacts");
41
+ assert.equal(runtime.editUrl.value, "/w/harbor/admin/contacts/541841/edit");
42
+ assert.equal(runtime.resolveParams("./edit"), "/w/harbor/admin/contacts/541841/edit");
43
43
  });
44
44
 
45
45
  test("createViewUiRuntime uses route param order when repeated values are present", () => {