@jskit-ai/users-web 0.1.173 → 0.1.175

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 (113) 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/src/client/providers/UsersWebClientProvider.js +0 -2
  6. package/test/exportsContract.test.js +3 -29
  7. package/test/settingsPlacementContract.test.js +10 -0
  8. package/fixtures/crud-list-date-filters/App.vue +0 -107
  9. package/fixtures/crud-list-date-filters/index.html +0 -12
  10. package/fixtures/crud-list-date-filters/main.js +0 -24
  11. package/fixtures/crud-list-date-filters/vite.config.mjs +0 -18
  12. package/src/client/bulkActions.js +0 -47
  13. package/src/client/components/CrudAddEditScreen.vue +0 -186
  14. package/src/client/components/CrudDeleteAction.vue +0 -93
  15. package/src/client/components/CrudListBulkActionSurface.vue +0 -126
  16. package/src/client/components/CrudListDateFilterControl.vue +0 -188
  17. package/src/client/components/CrudListFilterSurface.vue +0 -388
  18. package/src/client/components/CrudListRecordActionMenu.vue +0 -120
  19. package/src/client/components/CrudListScreen.vue +0 -501
  20. package/src/client/components/CrudViewScreen.vue +0 -197
  21. package/src/client/composables/crud/crudBindingSupport.js +0 -75
  22. package/src/client/composables/crud/crudHttpClientSupport.js +0 -57
  23. package/src/client/composables/crud/crudJsonApiTransportSupport.js +0 -145
  24. package/src/client/composables/crud/crudLookupFieldLabelSupport.js +0 -151
  25. package/src/client/composables/crud/crudLookupFieldRuntime.js +0 -251
  26. package/src/client/composables/crud/crudSchemaFormHelpers.js +0 -464
  27. package/src/client/composables/internal/crudListFilterLookupSupport.js +0 -161
  28. package/src/client/composables/internal/crudListParentTitleSupport.js +0 -171
  29. package/src/client/composables/internal/useOperationScope.js +0 -144
  30. package/src/client/composables/records/useAddEdit.js +0 -224
  31. package/src/client/composables/records/useCrudAddEdit.js +0 -227
  32. package/src/client/composables/records/useCrudList.js +0 -101
  33. package/src/client/composables/records/useCrudView.js +0 -47
  34. package/src/client/composables/records/useList.js +0 -500
  35. package/src/client/composables/records/useView.js +0 -164
  36. package/src/client/composables/runtime/addEditUiRuntime.js +0 -130
  37. package/src/client/composables/runtime/listUiRuntime.js +0 -123
  38. package/src/client/composables/runtime/modelStateHelpers.js +0 -90
  39. package/src/client/composables/runtime/operationAdapters.js +0 -34
  40. package/src/client/composables/runtime/operationUiHelpers.js +0 -125
  41. package/src/client/composables/runtime/operationValidationHelpers.js +0 -51
  42. package/src/client/composables/runtime/useAddEditCore.js +0 -112
  43. package/src/client/composables/runtime/useCommandCore.js +0 -123
  44. package/src/client/composables/runtime/useEndpointResource.js +0 -199
  45. package/src/client/composables/runtime/useFieldErrorBag.js +0 -61
  46. package/src/client/composables/runtime/useListCore.js +0 -112
  47. package/src/client/composables/runtime/useUiFeedback.js +0 -98
  48. package/src/client/composables/runtime/useViewCore.js +0 -93
  49. package/src/client/composables/runtime/viewUiRuntime.js +0 -96
  50. package/src/client/composables/support/errorMessageHelpers.js +0 -66
  51. package/src/client/composables/support/listQueryParamSupport.js +0 -473
  52. package/src/client/composables/support/listSearchSupport.js +0 -70
  53. package/src/client/composables/support/refValueHelpers.js +0 -19
  54. package/src/client/composables/support/requestQueryRuntimeSupport.js +0 -141
  55. package/src/client/composables/support/resourceLoadStateHelpers.js +0 -208
  56. package/src/client/composables/support/routeTemplateHelpers.js +0 -285
  57. package/src/client/composables/support/scopeHelpers.js +0 -145
  58. package/src/client/composables/useAccess.js +0 -109
  59. package/src/client/composables/useCommand.js +0 -118
  60. package/src/client/composables/useCrudAddEditScreen.js +0 -88
  61. package/src/client/composables/useCrudDeleteAction.js +0 -160
  62. package/src/client/composables/useCrudListBulkActions.js +0 -147
  63. package/src/client/composables/useCrudListFilterLookups.js +0 -146
  64. package/src/client/composables/useCrudListFilters.js +0 -339
  65. package/src/client/composables/useCrudListParentTitle.js +0 -151
  66. package/src/client/composables/useCrudListRowActions.js +0 -144
  67. package/src/client/composables/useCrudListScreen.js +0 -237
  68. package/src/client/composables/useCrudViewScreen.js +0 -77
  69. package/src/client/composables/usePagedCollection.js +0 -181
  70. package/src/client/composables/useRealtimeQueryInvalidation.js +0 -156
  71. package/src/client/composables/useScopeRuntime.js +0 -135
  72. package/src/client/filters.js +0 -15
  73. package/src/client/lib/httpClient.js +0 -47
  74. package/src/client/lib/permissions.js +0 -34
  75. package/src/client/rowActions.js +0 -47
  76. package/src/client/support/contractGuards.js +0 -34
  77. package/src/client/support/crudListDateFilterSupport.js +0 -91
  78. package/test/addEditUiRuntime.test.js +0 -110
  79. package/test/crudBindingSupport.test.js +0 -110
  80. package/test/crudHttpClientSupport.test.js +0 -77
  81. package/test/crudJsonApiTransportSupport.test.js +0 -179
  82. package/test/crudListBulkActionSurface.test.js +0 -27
  83. package/test/crudListDateFilterSupport.test.js +0 -92
  84. package/test/crudListDateFilterSurface.browser.test.js +0 -182
  85. package/test/crudListFilterSurface.test.js +0 -90
  86. package/test/crudLookupFieldRuntime.test.js +0 -264
  87. package/test/crudScreenComponents.test.js +0 -117
  88. package/test/errorIntentContract.test.js +0 -31
  89. package/test/errorMessageHelpers.test.js +0 -28
  90. package/test/listQueryParamSupport.test.js +0 -223
  91. package/test/listUiRuntime.test.js +0 -102
  92. package/test/operationValidationHelpers.test.js +0 -64
  93. package/test/permissions.test.js +0 -35
  94. package/test/refValueHelpers.test.js +0 -14
  95. package/test/requestTransportOptions.test.js +0 -457
  96. package/test/resourceLoadStateHelpers.test.js +0 -189
  97. package/test/routeTemplateHelpers.test.js +0 -85
  98. package/test/scopeHelpers.test.js +0 -57
  99. package/test/useAddEditCore.test.js +0 -124
  100. package/test/useAddEditRequestQueryParams.test.js +0 -190
  101. package/test/useCrudAddEdit.test.js +0 -415
  102. package/test/useCrudDeleteAction.test.js +0 -139
  103. package/test/useCrudListBulkActions.test.js +0 -65
  104. package/test/useCrudListFilterLookups.test.js +0 -114
  105. package/test/useCrudListFilters.test.js +0 -293
  106. package/test/useCrudListParentTitle.test.js +0 -262
  107. package/test/useCrudListRowActions.test.js +0 -77
  108. package/test/useListRouteInitialization.test.js +0 -337
  109. package/test/useListSearchSupport.test.js +0 -61
  110. package/test/usePagedCollection.test.js +0 -53
  111. package/test/useViewRequestQueryParams.test.js +0 -20
  112. package/test/viewCoreLoading.test.js +0 -44
  113. package/test/viewUiRuntime.test.js +0 -95
@@ -1,91 +0,0 @@
1
- const DATE_ONLY_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/u;
2
-
3
- function parseDateOnlyValue(value = "") {
4
- const match = DATE_ONLY_PATTERN.exec(String(value || "").trim());
5
- if (!match) {
6
- return null;
7
- }
8
-
9
- const year = Number(match[1]);
10
- const month = Number(match[2]);
11
- const day = Number(match[3]);
12
- const date = new Date(0);
13
- date.setHours(12, 0, 0, 0);
14
- date.setFullYear(year, month - 1, day);
15
-
16
- if (
17
- date.getFullYear() !== year ||
18
- date.getMonth() !== month - 1 ||
19
- date.getDate() !== day
20
- ) {
21
- return null;
22
- }
23
-
24
- return date;
25
- }
26
-
27
- function formatDateOnlyValue(value = null) {
28
- const source = Array.isArray(value) ? value[0] : value;
29
- const date = source instanceof Date
30
- ? source
31
- : parseDateOnlyValue(source);
32
- if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
33
- return "";
34
- }
35
-
36
- const year = date.getFullYear();
37
- if (year < 0 || year > 9999) {
38
- return "";
39
- }
40
-
41
- return [
42
- String(year).padStart(4, "0"),
43
- String(date.getMonth() + 1).padStart(2, "0"),
44
- String(date.getDate()).padStart(2, "0")
45
- ].join("-");
46
- }
47
-
48
- function formatDateOnlyDisplay(value = "", { locale = undefined } = {}) {
49
- const date = parseDateOnlyValue(value);
50
- if (!date) {
51
- return "";
52
- }
53
-
54
- try {
55
- return new Intl.DateTimeFormat(locale || undefined, {
56
- year: "numeric",
57
- month: "short",
58
- day: "numeric"
59
- }).format(date);
60
- } catch {
61
- return formatDateOnlyValue(date);
62
- }
63
- }
64
-
65
- function formatCrudListDateFilterChipLabel(filter = {}, rawValue, { locale = undefined } = {}) {
66
- if (filter.type === "date") {
67
- const dateLabel = formatDateOnlyDisplay(rawValue, { locale }) || String(rawValue || "");
68
- return dateLabel ? `${filter.label}: ${dateLabel}` : "";
69
- }
70
-
71
- if (filter.type !== "dateRange") {
72
- return "";
73
- }
74
-
75
- const from = formatDateOnlyDisplay(rawValue?.from, { locale }) || String(rawValue?.from || "");
76
- const to = formatDateOnlyDisplay(rawValue?.to, { locale }) || String(rawValue?.to || "");
77
- if (from && to) {
78
- return `${filter.label}: ${from} to ${to}`;
79
- }
80
- if (from) {
81
- return `${filter.label}: from ${from}`;
82
- }
83
- return to ? `${filter.label}: to ${to}` : "";
84
- }
85
-
86
- export {
87
- parseDateOnlyValue,
88
- formatDateOnlyValue,
89
- formatDateOnlyDisplay,
90
- formatCrudListDateFilterChipLabel
91
- };
@@ -1,110 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { ref } from "vue";
4
- import { createAddEditUiRuntime } from "../src/client/composables/runtime/addEditUiRuntime.js";
5
-
6
- test("createAddEditUiRuntime resolves api/list/cancel paths from route params", () => {
7
- const runtime = createAddEditUiRuntime({
8
- recordIdParam: "addressId",
9
- routeParams: ref({
10
- contactId: "7",
11
- addressId: "42"
12
- }),
13
- routePath: ref("/contacts/7/addresses/new"),
14
- apiUrlTemplate: "/crud/contacts/:contactId/addresses/:addressId",
15
- viewUrlTemplate: "../:addressId",
16
- listUrlTemplate: ".."
17
- });
18
-
19
- assert.equal(runtime.recordId.value, "42");
20
- assert.equal(runtime.apiSuffix.value, "/crud/contacts/7/addresses/42");
21
- assert.equal(runtime.listUrl.value, "/contacts/7/addresses");
22
- assert.equal(runtime.cancelUrl.value, "/contacts/7/addresses/42");
23
- assert.equal(runtime.resolveParams("../:addressId"), "/contacts/7/addresses/42");
24
- });
25
-
26
- test("createAddEditUiRuntime resolves view urls for saved payload ids with nested params", () => {
27
- const runtime = createAddEditUiRuntime({
28
- recordIdParam: "addressId",
29
- routeParams: ref({
30
- contactId: "7"
31
- }),
32
- viewUrlTemplate: "/contacts/:contactId/addresses/:addressId"
33
- });
34
-
35
- assert.equal(runtime.resolveSavedViewUrl({ id: 99 }), "/contacts/7/addresses/99");
36
- });
37
-
38
- test("createAddEditUiRuntime keeps nested child routes stable when the saved child id matches a parent id", () => {
39
- const runtime = createAddEditUiRuntime({
40
- recordIdParam: "addressId",
41
- routeParams: ref({
42
- workspaceSlug: "tonymobily",
43
- contactId: "1"
44
- }),
45
- routeParamNames: ref(["workspaceSlug", "contactId"]),
46
- routePath: ref("/w/tonymobily/admin/contacts/1/addresses/new"),
47
- viewUrlTemplate: "../:addressId",
48
- listUrlTemplate: ".."
49
- });
50
-
51
- assert.equal(runtime.listUrl.value, "/w/tonymobily/admin/contacts/1/addresses");
52
- assert.equal(runtime.resolveSavedViewUrl({ id: 1 }), "/w/tonymobily/admin/contacts/1/addresses/1");
53
- });
54
-
55
- test("createAddEditUiRuntime resolves edit-page relative list and cancel links", () => {
56
- const runtime = createAddEditUiRuntime({
57
- recordIdParam: "addressId",
58
- routeParams: ref({
59
- contactId: "7",
60
- addressId: "42"
61
- }),
62
- routePath: ref("/contacts/7/addresses/42/edit"),
63
- viewUrlTemplate: "..",
64
- listUrlTemplate: "../.."
65
- });
66
-
67
- assert.equal(runtime.listUrl.value, "/contacts/7/addresses");
68
- assert.equal(runtime.cancelUrl.value, "/contacts/7/addresses/42");
69
- });
70
-
71
- test("createAddEditUiRuntime resolves nested edit links from the record scope", () => {
72
- const runtime = createAddEditUiRuntime({
73
- recordIdParam: "petId",
74
- routeParams: ref({
75
- workspaceSlug: "dogandgroom",
76
- contactId: "541841",
77
- petId: "715528"
78
- }),
79
- routeParamNames: ref(["workspaceSlug", "contactId", "petId"]),
80
- routePath: ref("/w/dogandgroom/admin/contacts/541841/pets/715528/edit/advanced"),
81
- viewUrlTemplate: "..",
82
- listUrlTemplate: "../.."
83
- });
84
-
85
- assert.equal(runtime.cancelUrl.value, "/w/dogandgroom/admin/contacts/541841/pets/715528");
86
- assert.equal(runtime.listUrl.value, "/w/dogandgroom/admin/contacts/541841/pets");
87
- });
88
-
89
- test("createAddEditUiRuntime supports custom saved-record selector", () => {
90
- const runtime = createAddEditUiRuntime({
91
- recordIdParam: "addressId",
92
- routeParams: ref({
93
- contactId: "7"
94
- }),
95
- viewUrlTemplate: "/contacts/:contactId/addresses/:addressId",
96
- saveRecordIdSelector: (payload = {}) => payload.uuid
97
- });
98
-
99
- assert.equal(runtime.resolveSavedViewUrl({ uuid: "abc-123" }), "/contacts/7/addresses/abc-123");
100
- });
101
-
102
- test("createAddEditUiRuntime validates route parameter names", () => {
103
- assert.throws(
104
- () =>
105
- createAddEditUiRuntime({
106
- recordIdParam: "record-id"
107
- }),
108
- /recordIdParam "record-id" is invalid/
109
- );
110
- });
@@ -1,110 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { ref } from "vue";
4
- import {
5
- CRUD_BINDING_MODE_ROUTE,
6
- CRUD_BINDING_MODE_MERGE,
7
- CRUD_BINDING_MODE_EXPLICIT,
8
- CRUD_BINDING_MODE_NONE,
9
- normalizeCrudBindingMode,
10
- resolveCrudBoundValues
11
- } from "../src/client/composables/crud/crudBindingSupport.js";
12
-
13
- test("normalizeCrudBindingMode defaults invalid values to route", () => {
14
- assert.equal(normalizeCrudBindingMode(""), CRUD_BINDING_MODE_ROUTE);
15
- assert.equal(normalizeCrudBindingMode("unknown"), CRUD_BINDING_MODE_ROUTE);
16
- assert.equal(normalizeCrudBindingMode("merge"), CRUD_BINDING_MODE_MERGE);
17
- assert.equal(normalizeCrudBindingMode("explicit"), CRUD_BINDING_MODE_EXPLICIT);
18
- assert.equal(normalizeCrudBindingMode("none"), CRUD_BINDING_MODE_NONE);
19
- });
20
-
21
- test("resolveCrudBoundValues returns route values in route mode", () => {
22
- const values = resolveCrudBoundValues({
23
- binding: {
24
- mode: "route",
25
- values: {
26
- contactId: "22"
27
- }
28
- },
29
- routeValues: {
30
- contactId: "11"
31
- }
32
- });
33
-
34
- assert.deepEqual(values, {
35
- contactId: "11"
36
- });
37
- });
38
-
39
- test("resolveCrudBoundValues merges explicit values over route values in merge mode", () => {
40
- const values = resolveCrudBoundValues({
41
- binding: {
42
- mode: "merge",
43
- values: {
44
- contactId: "22",
45
- serviceId: "4"
46
- }
47
- },
48
- routeValues: {
49
- contactId: "11"
50
- }
51
- });
52
-
53
- assert.deepEqual(values, {
54
- contactId: "22",
55
- serviceId: "4"
56
- });
57
- });
58
-
59
- test("resolveCrudBoundValues uses only explicit values in explicit mode", () => {
60
- const values = resolveCrudBoundValues({
61
- binding: {
62
- mode: "explicit",
63
- values: {
64
- serviceId: "4"
65
- }
66
- },
67
- routeValues: {
68
- contactId: "11"
69
- }
70
- });
71
-
72
- assert.deepEqual(values, {
73
- serviceId: "4"
74
- });
75
- });
76
-
77
- test("resolveCrudBoundValues disables automatic binding in none mode", () => {
78
- const values = resolveCrudBoundValues({
79
- binding: {
80
- mode: "none",
81
- values: {
82
- serviceId: "4"
83
- }
84
- },
85
- routeValues: {
86
- contactId: "11"
87
- }
88
- });
89
-
90
- assert.deepEqual(values, {});
91
- });
92
-
93
- test("resolveCrudBoundValues unwraps reactive binding config and values", () => {
94
- const values = resolveCrudBoundValues({
95
- binding: ref({
96
- mode: "merge",
97
- values: ref({
98
- serviceId: "4"
99
- })
100
- }),
101
- routeValues: {
102
- contactId: "11"
103
- }
104
- });
105
-
106
- assert.deepEqual(values, {
107
- contactId: "11",
108
- serviceId: "4"
109
- });
110
- });
@@ -1,77 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
-
4
- import {
5
- normalizeCrudApiAccess,
6
- resolveCrudHttpClient
7
- } from "../src/client/composables/crud/crudHttpClientSupport.js";
8
- import {
9
- __testables as crudListScreenTestables
10
- } from "../src/client/composables/useCrudListScreen.js";
11
-
12
- test("resolveCrudHttpClient injects per-request CSRF opt-out for public resources", async () => {
13
- const calls = [];
14
- const configuredClient = {
15
- async request(url, options) {
16
- calls.push([url, options]);
17
- return { ok: true };
18
- }
19
- };
20
- const client = resolveCrudHttpClient({ apiAccess: "public" }, {
21
- client: configuredClient
22
- });
23
-
24
- for (const method of ["POST", "PATCH", "DELETE"]) {
25
- await client.request("/api/books/1", {
26
- method,
27
- csrf: true
28
- });
29
- }
30
-
31
- assert.deepEqual(
32
- calls.map(([url, options]) => [url, options.method, options.csrf]),
33
- [
34
- ["/api/books/1", "POST", false],
35
- ["/api/books/1", "PATCH", false],
36
- ["/api/books/1", "DELETE", false]
37
- ]
38
- );
39
- });
40
-
41
- test("resolveCrudHttpClient preserves the configured client for authenticated resources", () => {
42
- const configuredClient = {
43
- request() {}
44
- };
45
-
46
- assert.equal(
47
- resolveCrudHttpClient({ apiAccess: "authenticated" }, { client: configuredClient }),
48
- configuredClient
49
- );
50
- assert.equal(
51
- resolveCrudHttpClient({}, { client: configuredClient }),
52
- configuredClient
53
- );
54
- assert.equal(normalizeCrudApiAccess(""), "authenticated");
55
- assert.throws(
56
- () => resolveCrudHttpClient({ apiAccess: "always" }, { client: configuredClient }),
57
- /apiAccess must be one of: authenticated, public/
58
- );
59
- });
60
-
61
- test("CRUD list row and bulk action context carries the resource-aware client", () => {
62
- const records = {
63
- reload() {}
64
- };
65
- const client = {
66
- request() {}
67
- };
68
-
69
- assert.deepEqual(
70
- crudListScreenTestables.buildCrudListActionContext(records, client),
71
- {
72
- records,
73
- reload: records.reload,
74
- client
75
- }
76
- );
77
- });
@@ -1,179 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { createSchema } from "json-rest-schema";
4
- import {
5
- inferCrudJsonApiTransport,
6
- inferCrudLookupJsonApiTransport,
7
- resolveCrudJsonApiTransport,
8
- resolveLookupFieldMap
9
- } from "../src/client/composables/crud/crudJsonApiTransportSupport.js";
10
-
11
- const resource = {
12
- namespace: "pets",
13
- contract: {
14
- lookup: {
15
- containerKey: "lookups"
16
- }
17
- },
18
- operations: {
19
- view: {
20
- output: {
21
- schema: createSchema({
22
- id: {
23
- type: "string",
24
- required: true
25
- },
26
- contactId: {
27
- type: "string",
28
- required: true,
29
- belongsTo: "contacts",
30
- as: "contact"
31
- },
32
- breedId: {
33
- type: "string",
34
- nullable: true,
35
- belongsTo: "breeds",
36
- as: "breed"
37
- }
38
- })
39
- }
40
- }
41
- }
42
- };
43
-
44
- test("inferCrudJsonApiTransport infers collection transport for CRUD lists", () => {
45
- assert.deepEqual(
46
- inferCrudJsonApiTransport(resource, {
47
- mode: "list"
48
- }),
49
- {
50
- kind: "jsonapi-resource",
51
- responseType: "pets",
52
- responseKind: "collection"
53
- }
54
- );
55
- });
56
-
57
- test("inferCrudJsonApiTransport infers record request/response transport for CRUD add/edit", () => {
58
- assert.deepEqual(
59
- inferCrudJsonApiTransport(resource, {
60
- mode: "add-edit",
61
- operationName: "patch"
62
- }),
63
- {
64
- kind: "jsonapi-resource",
65
- requestType: "pets",
66
- responseType: "pets",
67
- responseKind: "record"
68
- }
69
- );
70
- });
71
-
72
- test("inferCrudJsonApiTransport infers record response transport for CRUD delete", () => {
73
- assert.deepEqual(
74
- inferCrudJsonApiTransport(resource, {
75
- mode: "delete"
76
- }),
77
- {
78
- kind: "jsonapi-resource",
79
- responseType: "pets",
80
- responseKind: "record"
81
- }
82
- );
83
- });
84
-
85
- test("inferCrudLookupJsonApiTransport infers collection transport from lookup namespace", () => {
86
- assert.deepEqual(
87
- inferCrudLookupJsonApiTransport({
88
- namespace: "services"
89
- }),
90
- {
91
- kind: "jsonapi-resource",
92
- responseType: "services",
93
- responseKind: "collection"
94
- }
95
- );
96
- });
97
-
98
- test("inferCrudLookupJsonApiTransport infers collection transport from lookup apiPath", () => {
99
- assert.deepEqual(
100
- inferCrudLookupJsonApiTransport({
101
- apiPath: "/contact-roles"
102
- }),
103
- {
104
- kind: "jsonapi-resource",
105
- responseType: "contact-roles",
106
- responseKind: "collection"
107
- }
108
- );
109
- });
110
-
111
- test("inferCrudLookupJsonApiTransport returns null without a lookup namespace", () => {
112
- assert.equal(
113
- inferCrudLookupJsonApiTransport({}),
114
- null
115
- );
116
- });
117
-
118
- test("resolveLookupFieldMap derives lookup aliases from the shared CRUD resource", () => {
119
- assert.deepEqual(resolveLookupFieldMap(resource), {
120
- breed: "breedId",
121
- contact: "contactId"
122
- });
123
- });
124
-
125
- test("resolveCrudJsonApiTransport infers and enriches JSON:API transport from the resource", () => {
126
- assert.deepEqual(
127
- resolveCrudJsonApiTransport(undefined, resource, {
128
- mode: "list"
129
- }),
130
- {
131
- kind: "jsonapi-resource",
132
- responseType: "pets",
133
- responseKind: "collection",
134
- lookupContainerKey: "lookups",
135
- lookupFieldMap: {
136
- breed: "breedId",
137
- contact: "contactId"
138
- }
139
- }
140
- );
141
- });
142
-
143
- test("resolveCrudJsonApiTransport infers record request/response transport for CRUD add/edit", () => {
144
- assert.deepEqual(
145
- resolveCrudJsonApiTransport(undefined, resource, {
146
- mode: "add-edit",
147
- operationName: "patch"
148
- }),
149
- {
150
- kind: "jsonapi-resource",
151
- requestType: "pets",
152
- responseType: "pets",
153
- responseKind: "record",
154
- lookupContainerKey: "lookups",
155
- lookupFieldMap: {
156
- breed: "breedId",
157
- contact: "contactId"
158
- }
159
- }
160
- );
161
- });
162
-
163
- test("resolveCrudJsonApiTransport rejects explicit CRUD transport overrides", () => {
164
- assert.throws(
165
- () =>
166
- resolveCrudJsonApiTransport(
167
- {
168
- kind: "jsonapi-resource",
169
- responseType: "pets",
170
- responseKind: "record"
171
- },
172
- resource,
173
- {
174
- mode: "view"
175
- }
176
- ),
177
- /do not accept explicit transport/
178
- );
179
- });
@@ -1,27 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import path from "node:path";
4
- import { readFile } from "node:fs/promises";
5
- import { fileURLToPath } from "node:url";
6
-
7
- const TEST_DIRECTORY = path.dirname(fileURLToPath(import.meta.url));
8
- const PACKAGE_DIR = path.resolve(TEST_DIRECTORY, "..");
9
-
10
- test("CrudListBulkActionSurface stays adaptive and runtime-owned", async () => {
11
- const source = await readFile(
12
- path.join(PACKAGE_DIR, "src", "client", "components", "CrudListBulkActionSurface.vue"),
13
- "utf8"
14
- );
15
-
16
- assert.match(source, /defineProps/);
17
- assert.match(source, /useDisplay/);
18
- assert.match(source, /v-if="shouldRender"/);
19
- assert.match(source, /selectedCount/);
20
- assert.match(source, /hasActions/);
21
- assert.match(source, /hasSelection/);
22
- assert.match(source, /v-menu/);
23
- assert.match(source, /Bulk actions/);
24
- assert.match(source, /min-height:\s*48px/);
25
- assert.doesNotMatch(source, /useCrudList\(/);
26
- assert.doesNotMatch(source, /apiSuffix|repository|server/);
27
- });
@@ -1,92 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { spawnSync } from "node:child_process";
3
- import test from "node:test";
4
- import {
5
- parseDateOnlyValue,
6
- formatDateOnlyValue,
7
- formatDateOnlyDisplay,
8
- formatCrudListDateFilterChipLabel
9
- } from "../src/client/support/crudListDateFilterSupport.js";
10
-
11
- test("date filter picker values round-trip through the YYYY-MM-DD contract", () => {
12
- const parsed = parseDateOnlyValue("2026-04-18");
13
-
14
- assert.ok(parsed instanceof Date);
15
- assert.equal(parsed.getFullYear(), 2026);
16
- assert.equal(parsed.getMonth(), 3);
17
- assert.equal(parsed.getDate(), 18);
18
- assert.equal(formatDateOnlyValue(parsed), "2026-04-18");
19
- assert.equal(formatDateOnlyValue([new Date(2026, 4, 9)]), "2026-05-09");
20
- assert.equal(formatDateOnlyValue("2026-11-03"), "2026-11-03");
21
- });
22
-
23
- test("date filter parsing rejects impossible calendar dates", () => {
24
- assert.equal(parseDateOnlyValue("2026-02-29"), null);
25
- assert.ok(parseDateOnlyValue("2028-02-29") instanceof Date);
26
- assert.equal(parseDateOnlyValue("04/18/2026"), null);
27
- assert.equal(parseDateOnlyValue(""), null);
28
- assert.equal(formatDateOnlyValue(new Date("invalid")), "");
29
- });
30
-
31
- test("date filter display and chip labels are locale-aware without exposing Date strings", () => {
32
- assert.equal(formatDateOnlyDisplay("2026-04-18", { locale: "en-US" }), "Apr 18, 2026");
33
- assert.equal(formatDateOnlyDisplay("2026-04-18", { locale: "en-GB" }), "18 Apr 2026");
34
- assert.equal(
35
- formatCrudListDateFilterChipLabel(
36
- { type: "date", label: "Submitted" },
37
- "2026-04-18",
38
- { locale: "en-US" }
39
- ),
40
- "Submitted: Apr 18, 2026"
41
- );
42
- assert.equal(
43
- formatCrudListDateFilterChipLabel(
44
- { type: "dateRange", label: "Arrival" },
45
- { from: "2026-05-04", to: "2026-05-10" },
46
- { locale: "en-US" }
47
- ),
48
- "Arrival: May 4, 2026 to May 10, 2026"
49
- );
50
- assert.equal(
51
- formatCrudListDateFilterChipLabel(
52
- { type: "dateRange", label: "Arrival" },
53
- { from: "", to: "2026-05-10" },
54
- { locale: "en-US" }
55
- ),
56
- "Arrival: to May 10, 2026"
57
- );
58
- });
59
-
60
- test("date-only conversion does not shift across time zones", () => {
61
- const supportModuleUrl = new URL(
62
- "../src/client/support/crudListDateFilterSupport.js",
63
- import.meta.url
64
- ).href;
65
- const script = `
66
- import { parseDateOnlyValue, formatDateOnlyValue } from ${JSON.stringify(supportModuleUrl)};
67
- const parsed = parseDateOnlyValue("2026-01-01");
68
- process.stdout.write(JSON.stringify({
69
- value: formatDateOnlyValue(parsed),
70
- year: parsed.getFullYear(),
71
- month: parsed.getMonth(),
72
- day: parsed.getDate()
73
- }));
74
- `;
75
-
76
- for (const timezone of ["UTC", "America/Los_Angeles", "Pacific/Kiritimati"]) {
77
- const result = spawnSync(process.execPath, ["--input-type=module", "--eval", script], {
78
- encoding: "utf8",
79
- env: {
80
- ...process.env,
81
- TZ: timezone
82
- }
83
- });
84
- assert.equal(result.status, 0, result.stderr);
85
- assert.deepEqual(JSON.parse(result.stdout), {
86
- value: "2026-01-01",
87
- year: 2026,
88
- month: 0,
89
- day: 1
90
- }, timezone);
91
- }
92
- });