@goplusvn/core 0.1.87 → 0.1.89

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 (30) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/package.json +1 -1
  3. package/src/audit/__tests__/prisma-audit-extension.test.ts +113 -0
  4. package/src/audit/prisma-audit-extension.ts +41 -13
  5. package/src/configs/status.ts +67 -0
  6. package/src/cron/__tests__/cron-single-runner.test.ts +260 -0
  7. package/src/cron/cron-schedule.ts +113 -20
  8. package/src/cron/db-cron-manager.ts +90 -7
  9. package/src/cron/simple-cron-job.ts +17 -6
  10. package/src/crud/__tests__/status-boolean-display.test.tsx +186 -0
  11. package/src/crud/components/crud-detail-dialog.tsx +21 -8
  12. package/src/crud/components/crud-field-renderer.tsx +20 -13
  13. package/src/crud/components/crud-filter-chips.tsx +14 -39
  14. package/src/crud/components/crud-filters/datetime-filter.tsx +58 -17
  15. package/src/crud/components/crud-provider.tsx +10 -2
  16. package/src/crud/components/crud-table-toolbar.tsx +38 -40
  17. package/src/crud/components/crud-table.tsx +13 -8
  18. package/src/crud/lib/coerce.ts +36 -10
  19. package/src/crud/lib/filter-defaults.test.ts +115 -0
  20. package/src/crud/lib/filter-defaults.ts +56 -0
  21. package/src/crud/lib/filter-display.ts +59 -0
  22. package/src/crud/lib/query-builder.ts +4 -0
  23. package/src/types/index.ts +16 -9
  24. package/src/ui/data-display/data-table/data-table-toolbar.tsx +8 -2
  25. package/src/ui/data-display/data-table/data-table.tsx +32 -4
  26. package/src/ui/layout/user-dropdown.tsx +30 -23
  27. package/src/ui/primitives/status-badge.tsx +14 -10
  28. package/src/ui/shared/status-indicator.tsx +266 -74
  29. package/src/utils/index.ts +87 -38
  30. package/src/workspace/__tests__/workspace-delegation.test.ts +29 -11
@@ -104,8 +104,12 @@ describe("D1 — chứa trong nhánh", () => {
104
104
  }
105
105
  });
106
106
 
107
- it("người không được uỷ quyềnđâu cả thì chặn ngay", () => {
108
- const nobody = customerAdmin({
107
+ it("không phải quản trị nhưng TRONG nhánh gốc của mình thì qua", () => {
108
+ // Luật đã được NỚI có chủ đích (commit "relax workspace delegation rules
109
+ // for user creation"): thành viên của nhánh gốc thao tác được trong chính
110
+ // nhánh đó, không bắt buộc phải là quản trị viên. Bài test này trước đây
111
+ // còn khoá luật cũ nên đỏ suốt — nay khoá đúng luật đang chạy.
112
+ const member = customerAdmin({
109
113
  scope: createWorkspaceScope({
110
114
  canViewAll: false,
111
115
  rootIds: ["spa"],
@@ -113,10 +117,13 @@ describe("D1 — chứa trong nhánh", () => {
113
117
  adminIds: [],
114
118
  }),
115
119
  });
116
- expect(() => assertWorkspacesInScope(nobody, ["spa"])).toThrow(
117
- /không được uỷ quyền/,
120
+ expect(() => assertWorkspacesInScope(member, ["spa"])).not.toThrow();
121
+ // Nhưng RA NGOÀI nhánh thì vẫn chặn — nới không đồng nghĩa với bỏ ngỏ.
122
+ expect(() => assertWorkspacesInScope(member, ["tanloc"])).toThrow(
123
+ /Ngoài phạm vi/,
118
124
  );
119
- expect(canDelegateUsers(nobody)).toBe(false);
125
+ // Và không có nhánh nào làm quản trị thì vẫn KHÔNG được uỷ quyền người dùng.
126
+ expect(canDelegateUsers(member)).toBe(false);
120
127
  });
121
128
 
122
129
  it("toàn quyền đi qua mọi thứ", () => {
@@ -375,7 +382,11 @@ describe("Quản trị VAI TRÒ — cổng tạo/sửa/xoá", () => {
375
382
  });
376
383
 
377
384
  it("tạo vai trò trong nhánh mình: được đóng dấu workspace + giữ rank", () => {
378
- const gate = assertCanManageRole(customerAdmin(), null, draft({ rank: 80 }));
385
+ const gate = assertCanManageRole(
386
+ customerAdmin(),
387
+ null,
388
+ draft({ rank: 80 }),
389
+ );
379
390
  expect(gate.workspaceId).toBe("spa");
380
391
  expect(gate.rank).toBe(80);
381
392
  });
@@ -448,17 +459,24 @@ describe("Quản trị VAI TRÒ — cổng tạo/sửa/xoá", () => {
448
459
  canManageRole(customerAdmin(), role({ workspaceId: "tanloc" })),
449
460
  ).toBe(false);
450
461
  expect(
451
- canManageRole(customerAdmin(), role({ workspaceId: "spa", isSystem: true })),
462
+ canManageRole(
463
+ customerAdmin(),
464
+ role({ workspaceId: "spa", isSystem: true }),
465
+ ),
452
466
  ).toBe(false);
453
- expect(canManageRole(customerAdmin(), role({ workspaceId: "spa-qc" }))).toBe(
454
- true,
455
- );
467
+ expect(
468
+ canManageRole(customerAdmin(), role({ workspaceId: "spa-qc" })),
469
+ ).toBe(true);
456
470
  });
457
471
 
458
472
  it("nhóm vận hành miễn mọi luật", () => {
459
473
  expect(canManageRole(opsAdmin(), role({ isSystem: true }))).toBe(true);
460
474
  expect(() =>
461
- assertCanManageRole(opsAdmin(), null, draft({ permissions: ["role:create"] })),
475
+ assertCanManageRole(
476
+ opsAdmin(),
477
+ null,
478
+ draft({ permissions: ["role:create"] }),
479
+ ),
462
480
  ).not.toThrow();
463
481
  expect(defaultRoleWorkspaceIdFor(opsAdmin())).toBeNull();
464
482
  });