@orthacms/content-server 0.4.2 → 0.4.3

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 (135) hide show
  1. package/dist/index.d.ts +15 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +38 -1
  4. package/dist/lib/content.module.d.ts.map +1 -1
  5. package/dist/lib/content.module.js +23 -1
  6. package/dist/lib/entries/http/controllers/create-entry.controller.d.ts.map +1 -1
  7. package/dist/lib/entries/http/controllers/create-entry.controller.js +1 -1
  8. package/dist/lib/entries/http/controllers/update-entry.controller.d.ts.map +1 -1
  9. package/dist/lib/entries/http/controllers/update-entry.controller.js +1 -1
  10. package/dist/lib/entries/http/dto/extension-bag.validator.d.ts +14 -0
  11. package/dist/lib/entries/http/dto/extension-bag.validator.d.ts.map +1 -0
  12. package/dist/lib/entries/http/dto/extension-bag.validator.js +42 -0
  13. package/dist/lib/entries/http/dto/save-entry.dto.d.ts +16 -0
  14. package/dist/lib/entries/http/dto/save-entry.dto.d.ts.map +1 -1
  15. package/dist/lib/entries/http/dto/save-entry.dto.js +30 -0
  16. package/dist/lib/entries/infrastructure/persistence/entry-writer.service.d.ts +28 -2
  17. package/dist/lib/entries/infrastructure/persistence/entry-writer.service.d.ts.map +1 -1
  18. package/dist/lib/entries/infrastructure/persistence/entry-writer.service.js +112 -15
  19. package/dist/lib/entries/infrastructure/persistence/relation-link.service.d.ts +38 -5
  20. package/dist/lib/entries/infrastructure/persistence/relation-link.service.d.ts.map +1 -1
  21. package/dist/lib/entries/infrastructure/persistence/relation-link.service.js +38 -6
  22. package/dist/lib/entries/infrastructure/queries/entries.service.d.ts +3 -1
  23. package/dist/lib/entries/infrastructure/queries/entries.service.d.ts.map +1 -1
  24. package/dist/lib/entries/infrastructure/queries/entries.service.js +17 -5
  25. package/dist/lib/entries/infrastructure/queries/entry-match.query.d.ts +82 -0
  26. package/dist/lib/entries/infrastructure/queries/entry-match.query.d.ts.map +1 -0
  27. package/dist/lib/entries/infrastructure/queries/entry-match.query.js +152 -0
  28. package/dist/lib/extension/entry-access-source.d.ts +112 -0
  29. package/dist/lib/extension/entry-access-source.d.ts.map +1 -0
  30. package/dist/lib/extension/entry-filter-provider.d.ts +79 -0
  31. package/dist/lib/extension/entry-filter-provider.d.ts.map +1 -0
  32. package/dist/lib/extension/entry-filter-provider.js +149 -0
  33. package/dist/lib/extension/entry-write-extension.d.ts +185 -0
  34. package/dist/lib/extension/entry-write-extension.d.ts.map +1 -0
  35. package/dist/lib/extension/entry-write-extension.js +182 -0
  36. package/dist/lib/extension/entry-write-hook.d.ts +98 -0
  37. package/dist/lib/extension/entry-write-hook.d.ts.map +1 -0
  38. package/dist/lib/extension/read-scope.d.ts +107 -0
  39. package/dist/lib/extension/read-scope.d.ts.map +1 -0
  40. package/dist/lib/extension/read-scope.js +131 -0
  41. package/dist/lib/public-api/infrastructure/public-entries.query.d.ts +14 -1
  42. package/dist/lib/public-api/infrastructure/public-entries.query.d.ts.map +1 -1
  43. package/dist/lib/public-api/infrastructure/public-entries.query.js +20 -3
  44. package/dist/lib/public-api/infrastructure/public-expansion.query.d.ts +16 -4
  45. package/dist/lib/public-api/infrastructure/public-expansion.query.d.ts.map +1 -1
  46. package/dist/lib/public-api/infrastructure/public-expansion.query.js +29 -9
  47. package/dist/lib/revisions/application/use-cases/restore-revision.use-case.d.ts.map +1 -1
  48. package/dist/lib/revisions/application/use-cases/restore-revision.use-case.js +12 -1
  49. package/dist/lib/revisions/infrastructure/persistence/revision-snapshot.d.ts +7 -1
  50. package/dist/lib/revisions/infrastructure/persistence/revision-snapshot.d.ts.map +1 -1
  51. package/dist/lib/revisions/infrastructure/persistence/revision-snapshot.js +9 -2
  52. package/dist/lib/revisions/types/revision-view.d.ts +11 -0
  53. package/dist/lib/revisions/types/revision-view.d.ts.map +1 -1
  54. package/dist/lib/utils/content-views-plugin.d.ts +28 -0
  55. package/dist/lib/utils/content-views-plugin.d.ts.map +1 -0
  56. package/dist/lib/utils/content-views-plugin.js +29 -0
  57. package/dist/lib/views/application/queries/saved-views.query.d.ts +16 -0
  58. package/dist/lib/views/application/queries/saved-views.query.d.ts.map +1 -0
  59. package/dist/lib/views/application/queries/saved-views.query.js +46 -0
  60. package/dist/lib/views/application/saved-view-access.service.d.ts +30 -0
  61. package/dist/lib/views/application/saved-view-access.service.d.ts.map +1 -0
  62. package/dist/lib/views/application/saved-view-access.service.js +55 -0
  63. package/dist/lib/views/application/use-cases/create-saved-view.use-case.d.ts +27 -0
  64. package/dist/lib/views/application/use-cases/create-saved-view.use-case.d.ts.map +1 -0
  65. package/dist/lib/views/application/use-cases/create-saved-view.use-case.js +57 -0
  66. package/dist/lib/views/application/use-cases/delete-saved-view.use-case.d.ts +15 -0
  67. package/dist/lib/views/application/use-cases/delete-saved-view.use-case.d.ts.map +1 -0
  68. package/dist/lib/views/application/use-cases/delete-saved-view.use-case.js +35 -0
  69. package/dist/lib/views/application/use-cases/set-default-view.use-case.d.ts +23 -0
  70. package/dist/lib/views/application/use-cases/set-default-view.use-case.d.ts.map +1 -0
  71. package/dist/lib/views/application/use-cases/set-default-view.use-case.js +51 -0
  72. package/dist/lib/views/application/use-cases/update-saved-view.use-case.d.ts +21 -0
  73. package/dist/lib/views/application/use-cases/update-saved-view.use-case.d.ts.map +1 -0
  74. package/dist/lib/views/application/use-cases/update-saved-view.use-case.js +61 -0
  75. package/dist/lib/views/application/view-scope.service.d.ts +25 -0
  76. package/dist/lib/views/application/view-scope.service.d.ts.map +1 -0
  77. package/dist/lib/views/application/view-scope.service.js +45 -0
  78. package/dist/lib/views/content-views.module.d.ts +22 -0
  79. package/dist/lib/views/content-views.module.d.ts.map +1 -0
  80. package/dist/lib/views/content-views.module.js +63 -0
  81. package/dist/lib/views/domain/errors/index.d.ts +6 -0
  82. package/dist/lib/views/domain/errors/index.d.ts.map +1 -0
  83. package/dist/lib/views/domain/errors/index.js +12 -0
  84. package/dist/lib/views/domain/errors/saved-view-forbidden.error.d.ts +10 -0
  85. package/dist/lib/views/domain/errors/saved-view-forbidden.error.d.ts.map +1 -0
  86. package/dist/lib/views/domain/errors/saved-view-forbidden.error.js +16 -0
  87. package/dist/lib/views/domain/errors/saved-view-limit-error.d.ts +9 -0
  88. package/dist/lib/views/domain/errors/saved-view-limit-error.d.ts.map +1 -0
  89. package/dist/lib/views/domain/errors/saved-view-limit-error.js +16 -0
  90. package/dist/lib/views/domain/errors/saved-view-name-taken.error.d.ts +5 -0
  91. package/dist/lib/views/domain/errors/saved-view-name-taken.error.d.ts.map +1 -0
  92. package/dist/lib/views/domain/errors/saved-view-name-taken.error.js +11 -0
  93. package/dist/lib/views/domain/errors/saved-view-not-found.error.d.ts +9 -0
  94. package/dist/lib/views/domain/errors/saved-view-not-found.error.d.ts.map +1 -0
  95. package/dist/lib/views/domain/errors/saved-view-not-found.error.js +15 -0
  96. package/dist/lib/views/domain/saved-view.d.ts +66 -0
  97. package/dist/lib/views/domain/saved-view.d.ts.map +1 -0
  98. package/dist/lib/views/domain/saved-view.js +18 -0
  99. package/dist/lib/views/domain/saved-view.repository.d.ts +77 -0
  100. package/dist/lib/views/domain/saved-view.repository.d.ts.map +1 -0
  101. package/dist/lib/views/domain/saved-view.repository.js +5 -0
  102. package/dist/lib/views/http/controllers/saved-views.controller.d.ts +45 -0
  103. package/dist/lib/views/http/controllers/saved-views.controller.d.ts.map +1 -0
  104. package/dist/lib/views/http/controllers/saved-views.controller.js +216 -0
  105. package/dist/lib/views/http/controllers/to-http-error.d.ts +10 -0
  106. package/dist/lib/views/http/controllers/to-http-error.d.ts.map +1 -0
  107. package/dist/lib/views/http/controllers/to-http-error.js +26 -0
  108. package/dist/lib/views/http/dto/save-view.dto.d.ts +54 -0
  109. package/dist/lib/views/http/dto/save-view.dto.d.ts.map +1 -0
  110. package/dist/lib/views/http/dto/save-view.dto.js +230 -0
  111. package/dist/lib/views/http/dto/view-payload.validator.d.ts +20 -0
  112. package/dist/lib/views/http/dto/view-payload.validator.d.ts.map +1 -0
  113. package/dist/lib/views/http/dto/view-payload.validator.js +52 -0
  114. package/dist/lib/views/infrastructure/persistence/drizzle-saved-view.repository.d.ts +17 -0
  115. package/dist/lib/views/infrastructure/persistence/drizzle-saved-view.repository.d.ts.map +1 -0
  116. package/dist/lib/views/infrastructure/persistence/drizzle-saved-view.repository.js +125 -0
  117. package/dist/lib/views/infrastructure/schema/external-refs.d.ts +68 -0
  118. package/dist/lib/views/infrastructure/schema/external-refs.d.ts.map +1 -0
  119. package/dist/lib/views/infrastructure/schema/external-refs.js +29 -0
  120. package/dist/lib/views/infrastructure/schema/index.d.ts +8 -0
  121. package/dist/lib/views/infrastructure/schema/index.d.ts.map +1 -0
  122. package/dist/lib/views/infrastructure/schema/index.js +13 -0
  123. package/dist/lib/views/infrastructure/schema/saved-views.d.ts +275 -0
  124. package/dist/lib/views/infrastructure/schema/saved-views.d.ts.map +1 -0
  125. package/dist/lib/views/infrastructure/schema/saved-views.js +87 -0
  126. package/dist/lib/views/views.constants.d.ts +26 -0
  127. package/dist/lib/views/views.constants.d.ts.map +1 -0
  128. package/dist/lib/views/views.constants.js +28 -0
  129. package/dist/lib/views/views.tokens.d.ts +17 -0
  130. package/dist/lib/views/views.tokens.d.ts.map +1 -0
  131. package/dist/lib/views/views.tokens.js +21 -0
  132. package/migrations/0000_saved_views.sql +29 -0
  133. package/migrations/meta/0000_snapshot.json +256 -0
  134. package/migrations/meta/_journal.json +13 -0
  135. package/package.json +13 -12
@@ -0,0 +1,5 @@
1
+ /** The caller already holds a view by this name in the same workspace + scope. */
2
+ export declare class SavedViewNameTakenError extends Error {
3
+ constructor(name: string);
4
+ }
5
+ //# sourceMappingURL=saved-view-name-taken.error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saved-view-name-taken.error.d.ts","sourceRoot":"","sources":["../../../../../src/lib/views/domain/errors/saved-view-name-taken.error.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,qBAAa,uBAAwB,SAAQ,KAAK;gBAClC,IAAI,EAAE,MAAM;CAI3B"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SavedViewNameTakenError = void 0;
4
+ /** The caller already holds a view by this name in the same workspace + scope. */
5
+ class SavedViewNameTakenError extends Error {
6
+ constructor(name) {
7
+ super(`You already have a view named "${name}" for this list.`);
8
+ this.name = 'SavedViewNameTakenError';
9
+ }
10
+ }
11
+ exports.SavedViewNameTakenError = SavedViewNameTakenError;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A saved view the caller may not read, or that does not exist. One error for
3
+ * both so the API cannot be used to probe which views other people hold — the
4
+ * controller maps it to a 404 either way.
5
+ */
6
+ export declare class SavedViewNotFoundError extends Error {
7
+ constructor(id: string);
8
+ }
9
+ //# sourceMappingURL=saved-view-not-found.error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saved-view-not-found.error.d.ts","sourceRoot":"","sources":["../../../../../src/lib/views/domain/errors/saved-view-not-found.error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACjC,EAAE,EAAE,MAAM;CAIzB"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SavedViewNotFoundError = void 0;
4
+ /**
5
+ * A saved view the caller may not read, or that does not exist. One error for
6
+ * both so the API cannot be used to probe which views other people hold — the
7
+ * controller maps it to a 404 either way.
8
+ */
9
+ class SavedViewNotFoundError extends Error {
10
+ constructor(id) {
11
+ super(`Saved view "${id}" was not found.`);
12
+ this.name = 'SavedViewNotFoundError';
13
+ }
14
+ }
15
+ exports.SavedViewNotFoundError = SavedViewNotFoundError;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * A saved list view — the named slice of a collection an editor returns to.
3
+ *
4
+ * Framework-free by ADR-0003: this module is the contract the HTTP layer, the
5
+ * repository adapter and the admin all agree on, and it imports nothing.
6
+ */
7
+ /** Who may see a saved view. */
8
+ export declare const VIEW_VISIBILITY: {
9
+ /** Only its owner. */
10
+ readonly Private: "private";
11
+ /** Every member of the workspace it belongs to. */
12
+ readonly Workspace: "workspace";
13
+ };
14
+ /** One visibility value. */
15
+ export type ViewVisibility = (typeof VIEW_VISIBILITY)[keyof typeof VIEW_VISIBILITY];
16
+ /** Every visibility, for validators and the OpenAPI enum. */
17
+ export declare const VIEW_VISIBILITY_VALUES: ("private" | "workspace")[];
18
+ /**
19
+ * The slice a view restores, stored as one opaque-ish JSON document.
20
+ *
21
+ * Deliberately mirrors the **URL params** the records page already owns rather
22
+ * than re-modelling them: `filter` and `sort` are the raw `?filter=` / `?sort=`
23
+ * strings, so a view round-trips through the same code path a hand-edited link
24
+ * does. Two things are absent on purpose — `search` is a one-off question, not
25
+ * a property of the slice, and `page` is a reading position, so a view always
26
+ * opens on the first page.
27
+ */
28
+ export interface SavedViewPayload {
29
+ /** The `?filter=` JSON string, or absent for no filter. */
30
+ filter?: string;
31
+ /** The `?sort=` spec (`updatedAt` / `-updatedAt`), or absent for unsorted. */
32
+ sort?: string;
33
+ /** Rows per page. */
34
+ pageSize?: number;
35
+ /** Visible column ids, **in display order**. */
36
+ columns?: string[];
37
+ /**
38
+ * Slot-owned list params (the i18n plugin's `?locale=`, and whatever a
39
+ * later plugin contributes), as an opaque string map. Opaque because the
40
+ * keys come from `RECORDS_TOOLBAR_SLOT.listParamKeys` at runtime — naming
41
+ * them here would break the next plugin's params silently.
42
+ */
43
+ extra?: Record<string, string>;
44
+ }
45
+ /** A saved view as the API returns it. */
46
+ export interface SavedView {
47
+ /** Primary key. */
48
+ id: string;
49
+ /** The list this view belongs to (`content:<typeName>`). */
50
+ scope: string;
51
+ /** Display name, unique per owner within a workspace + scope. */
52
+ name: string;
53
+ /** Who may see it. */
54
+ visibility: ViewVisibility;
55
+ /** The user who created it. */
56
+ ownerId: string;
57
+ /** Whether the caller owns it — the admin gates Save and Delete on this. */
58
+ isOwn: boolean;
59
+ /** Whether it is the caller's default for this scope. */
60
+ isDefault: boolean;
61
+ /** The slice it restores. */
62
+ payload: SavedViewPayload;
63
+ /** Last-modified timestamp, ISO-8601. */
64
+ updatedAt: string;
65
+ }
66
+ //# sourceMappingURL=saved-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saved-view.d.ts","sourceRoot":"","sources":["../../../../src/lib/views/domain/saved-view.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,gCAAgC;AAChC,eAAO,MAAM,eAAe;IACxB,sBAAsB;;IAEtB,mDAAmD;;CAE7C,CAAC;AAEX,4BAA4B;AAC5B,MAAM,MAAM,cAAc,GACtB,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAE3D,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,6BAAiC,CAAC;AAErE;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC7B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,0CAA0C;AAC1C,MAAM,WAAW,SAAS;IACtB,mBAAmB;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,UAAU,EAAE,cAAc,CAAC;IAC3B,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,KAAK,EAAE,OAAO,CAAC;IACf,yDAAyD;IACzD,SAAS,EAAE,OAAO,CAAC;IACnB,6BAA6B;IAC7B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * A saved list view — the named slice of a collection an editor returns to.
4
+ *
5
+ * Framework-free by ADR-0003: this module is the contract the HTTP layer, the
6
+ * repository adapter and the admin all agree on, and it imports nothing.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.VIEW_VISIBILITY_VALUES = exports.VIEW_VISIBILITY = void 0;
10
+ /** Who may see a saved view. */
11
+ exports.VIEW_VISIBILITY = {
12
+ /** Only its owner. */
13
+ Private: 'private',
14
+ /** Every member of the workspace it belongs to. */
15
+ Workspace: 'workspace'
16
+ };
17
+ /** Every visibility, for validators and the OpenAPI enum. */
18
+ exports.VIEW_VISIBILITY_VALUES = Object.values(exports.VIEW_VISIBILITY);
@@ -0,0 +1,77 @@
1
+ import type { SavedViewPayload, ViewVisibility } from './saved-view';
2
+ /** A stored view row, before the per-caller flags are derived. */
3
+ export interface SavedViewRecord {
4
+ /** Primary key. */
5
+ id: string;
6
+ /** The workspace it belongs to. */
7
+ workspaceId: string;
8
+ /** The list it is over. */
9
+ scope: string;
10
+ /** The user who saved it. */
11
+ ownerId: string;
12
+ /** Who may see it. */
13
+ visibility: ViewVisibility;
14
+ /** Display name. */
15
+ name: string;
16
+ /** The slice it restores. */
17
+ payload: SavedViewPayload;
18
+ /** Manual ordering within its scope. */
19
+ position: number;
20
+ /** Last-modified timestamp. */
21
+ updatedAt: Date;
22
+ }
23
+ /** Everything needed to store a new view. */
24
+ export interface NewSavedView {
25
+ /** The workspace it belongs to. */
26
+ workspaceId: string;
27
+ /** The list it is over. */
28
+ scope: string;
29
+ /** The user saving it. */
30
+ ownerId: string;
31
+ /** Who may see it. */
32
+ visibility: ViewVisibility;
33
+ /** Display name. */
34
+ name: string;
35
+ /** The slice it restores. */
36
+ payload: SavedViewPayload;
37
+ }
38
+ /** The fields an update may change; absent keys are left alone. */
39
+ export interface SavedViewPatch {
40
+ /** New display name. */
41
+ name?: string;
42
+ /** New visibility. */
43
+ visibility?: ViewVisibility;
44
+ /** New slice. */
45
+ payload?: SavedViewPayload;
46
+ }
47
+ /**
48
+ * Persistence port for saved views. The interface lives in `domain/` and the
49
+ * Drizzle adapter in `infrastructure/`, per ADR-0003 — nothing here knows about
50
+ * SQL, and the use-cases depend on this shape rather than on a table.
51
+ */
52
+ export interface SavedViewRepository {
53
+ /**
54
+ * Every view in this workspace + scope the reader may see: their own
55
+ * (whatever the visibility) plus everyone's workspace-visible ones.
56
+ */
57
+ listVisible(workspaceId: string, scope: string, readerId: string): Promise<SavedViewRecord[]>;
58
+ /** One view by id, or `null` when it does not exist. */
59
+ findById(id: string): Promise<SavedViewRecord | null>;
60
+ /** How many views this owner already holds in this workspace + scope. */
61
+ countForOwner(workspaceId: string, scope: string, ownerId: string): Promise<number>;
62
+ /** Stores a new view and returns it. */
63
+ create(view: NewSavedView): Promise<SavedViewRecord>;
64
+ /** Applies a patch and returns the updated row. */
65
+ update(id: string, patch: SavedViewPatch): Promise<SavedViewRecord>;
66
+ /** Removes a view. Defaults pointing at it are cascaded away. */
67
+ delete(id: string): Promise<void>;
68
+ /** The view this reader defaults to for a scope, or `null`. */
69
+ findDefaultId(userId: string, scope: string): Promise<string | null>;
70
+ /** Makes `viewId` this user's default for the scope, replacing any prior. */
71
+ setDefault(userId: string, scope: string, viewId: string): Promise<void>;
72
+ /** Clears this user's default for the scope, if any. */
73
+ clearDefault(userId: string, scope: string): Promise<void>;
74
+ }
75
+ /** DI token for {@link SavedViewRepository}. */
76
+ export declare const SAVED_VIEW_REPOSITORY: unique symbol;
77
+ //# sourceMappingURL=saved-view.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saved-view.repository.d.ts","sourceRoot":"","sources":["../../../../src/lib/views/domain/saved-view.repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAErE,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC5B,mBAAmB;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB;IACtB,UAAU,EAAE,cAAc,CAAC;IAC3B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,SAAS,EAAE,IAAI,CAAC;CACnB;AAED,6CAA6C;AAC7C,MAAM,WAAW,YAAY;IACzB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB;IACtB,UAAU,EAAE,cAAc,CAAC;IAC3B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,OAAO,EAAE,gBAAgB,CAAC;CAC7B;AAED,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC3B,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,iBAAiB;IACjB,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC;;;OAGG;IACH,WAAW,CACP,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAE9B,wDAAwD;IACxD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IAEtD,yEAAyE;IACzE,aAAa,CACT,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB,wCAAwC;IACxC,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAErD,mDAAmD;IACnD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEpE,iEAAiE;IACjE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC,+DAA+D;IAC/D,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAErE,6EAA6E;IAC7E,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzE,wDAAwD;IACxD,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D;AAED,gDAAgD;AAChD,eAAO,MAAM,qBAAqB,eAAkC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SAVED_VIEW_REPOSITORY = void 0;
4
+ /** DI token for {@link SavedViewRepository}. */
5
+ exports.SAVED_VIEW_REPOSITORY = Symbol('SAVED_VIEW_REPOSITORY');
@@ -0,0 +1,45 @@
1
+ import { type PublicUser } from '@orthacms/identity-server';
2
+ import type { SavedView } from '../../domain/saved-view';
3
+ import { SavedViewsQuery } from '../../application/queries/saved-views.query';
4
+ import { CreateSavedViewUseCase } from '../../application/use-cases/create-saved-view.use-case';
5
+ import { UpdateSavedViewUseCase } from '../../application/use-cases/update-saved-view.use-case';
6
+ import { DeleteSavedViewUseCase } from '../../application/use-cases/delete-saved-view.use-case';
7
+ import { SetDefaultViewUseCase } from '../../application/use-cases/set-default-view.use-case';
8
+ import { ViewScopeService } from '../../application/view-scope.service';
9
+ import { CreateViewDto, ListViewsQueryDto, UpdateViewDto } from '../dto/save-view.dto';
10
+ /**
11
+ * `/api/views` — a member's saved list views for one content type.
12
+ *
13
+ * A genuine CRUD resource over one thing, so it stays a single controller
14
+ * rather than five. Every route is workspace-scoped (`WorkspaceGuard` reads
15
+ * `X-Workspace-Id` and 403s a non-member) and gated on `content:read`: a view
16
+ * is a saved way of reading content, so anyone who cannot read content has no
17
+ * use for one. Sharing needs `views:share` on top, checked per write because it
18
+ * depends on the *body*, not the route.
19
+ *
20
+ * The stored payload is **not** a grant. It is replayed through the ordinary
21
+ * list query with the reader's own permissions, workspace scope and content
22
+ * grants, so a shared view shows a narrower reader fewer rows — never more.
23
+ */
24
+ export declare class SavedViewsController {
25
+ private readonly views;
26
+ private readonly scopes;
27
+ private readonly createView;
28
+ private readonly updateView;
29
+ private readonly deleteView;
30
+ private readonly setDefault;
31
+ constructor(views: SavedViewsQuery, scopes: ViewScopeService, createView: CreateSavedViewUseCase, updateView: UpdateSavedViewUseCase, deleteView: DeleteSavedViewUseCase, setDefault: SetDefaultViewUseCase);
32
+ /** Every view this member may see for a list: their own plus the shared ones. */
33
+ list(query: ListViewsQueryDto, workspaceId: string, user?: PublicUser): Promise<SavedView[]>;
34
+ /** Saves the current slice as a new view. */
35
+ create(body: CreateViewDto, workspaceId: string, user?: PublicUser): Promise<SavedView>;
36
+ /** Renames, re-shares, or re-captures a view the caller owns. */
37
+ update(id: string, body: UpdateViewDto, workspaceId: string, user?: PublicUser): Promise<SavedView>;
38
+ /** Deletes a view the caller owns. */
39
+ remove(id: string, workspaceId: string, user?: PublicUser): Promise<void>;
40
+ /** Lands this member on the view when they open the list. */
41
+ makeDefault(id: string, workspaceId: string, user?: PublicUser): Promise<void>;
42
+ /** Clears the caller's default, so the list opens unfiltered again. */
43
+ clearDefault(id: string, workspaceId: string, user?: PublicUser): Promise<void>;
44
+ }
45
+ //# sourceMappingURL=saved-views.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saved-views.controller.d.ts","sourceRoot":"","sources":["../../../../../src/lib/views/http/controllers/saved-views.controller.ts"],"names":[],"mappings":"AAiBA,OAAO,EAKH,KAAK,UAAU,EAClB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EACH,aAAa,EACb,iBAAiB,EACjB,aAAa,EAChB,MAAM,sBAAsB,CAAC;AAG9B;;;;;;;;;;;;;GAaG;AACH,qBAIa,oBAAoB;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBALV,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,sBAAsB,EAClC,UAAU,EAAE,sBAAsB,EAClC,UAAU,EAAE,sBAAsB,EAClC,UAAU,EAAE,qBAAqB;IAGtD,iFAAiF;IAO3E,IAAI,CACG,KAAK,EAAE,iBAAiB,EACb,WAAW,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,UAAU,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC;IAMvB,6CAA6C;IAOvC,MAAM,CACA,IAAI,EAAE,aAAa,EACP,WAAW,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,UAAU,GACjC,OAAO,CAAC,SAAS,CAAC;IAoBrB,iEAAiE;IAO3D,MAAM,CACoB,EAAE,EAAE,MAAM,EAC9B,IAAI,EAAE,aAAa,EACP,WAAW,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,UAAU,GACjC,OAAO,CAAC,SAAS,CAAC;IASrB,sCAAsC;IAQhC,MAAM,CACoB,EAAE,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,UAAU,GACjC,OAAO,CAAC,IAAI,CAAC;IAShB,6DAA6D;IAQvD,WAAW,CACe,EAAE,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,UAAU,GACjC,OAAO,CAAC,IAAI,CAAC;IAShB,uEAAuE;IAQjE,YAAY,CACc,EAAE,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,UAAU,GACjC,OAAO,CAAC,IAAI,CAAC;CAQnB"}
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SavedViewsController = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const swagger_1 = require("@nestjs/swagger");
7
+ const identity_server_1 = require("@orthacms/identity-server");
8
+ const workspaces_server_1 = require("@orthacms/workspaces-server");
9
+ const saved_view_1 = require("../../domain/saved-view");
10
+ const saved_views_query_1 = require("../../application/queries/saved-views.query");
11
+ const create_saved_view_use_case_1 = require("../../application/use-cases/create-saved-view.use-case");
12
+ const update_saved_view_use_case_1 = require("../../application/use-cases/update-saved-view.use-case");
13
+ const delete_saved_view_use_case_1 = require("../../application/use-cases/delete-saved-view.use-case");
14
+ const set_default_view_use_case_1 = require("../../application/use-cases/set-default-view.use-case");
15
+ const view_scope_service_1 = require("../../application/view-scope.service");
16
+ const save_view_dto_1 = require("../dto/save-view.dto");
17
+ const to_http_error_1 = require("./to-http-error");
18
+ /**
19
+ * `/api/views` — a member's saved list views for one content type.
20
+ *
21
+ * A genuine CRUD resource over one thing, so it stays a single controller
22
+ * rather than five. Every route is workspace-scoped (`WorkspaceGuard` reads
23
+ * `X-Workspace-Id` and 403s a non-member) and gated on `content:read`: a view
24
+ * is a saved way of reading content, so anyone who cannot read content has no
25
+ * use for one. Sharing needs `views:share` on top, checked per write because it
26
+ * depends on the *body*, not the route.
27
+ *
28
+ * The stored payload is **not** a grant. It is replayed through the ordinary
29
+ * list query with the reader's own permissions, workspace scope and content
30
+ * grants, so a shared view shows a narrower reader fewer rows — never more.
31
+ */
32
+ let SavedViewsController = class SavedViewsController {
33
+ views;
34
+ scopes;
35
+ createView;
36
+ updateView;
37
+ deleteView;
38
+ setDefault;
39
+ constructor(views, scopes, createView, updateView, deleteView, setDefault) {
40
+ this.views = views;
41
+ this.scopes = scopes;
42
+ this.createView = createView;
43
+ this.updateView = updateView;
44
+ this.deleteView = deleteView;
45
+ this.setDefault = setDefault;
46
+ }
47
+ /** Every view this member may see for a list: their own plus the shared ones. */
48
+ async list(query, workspaceId, user) {
49
+ const actor = requireUser(user);
50
+ await this.scopes.assertReachable(query.scope, workspaceId);
51
+ return this.views.list(workspaceId, query.scope, actor.id);
52
+ }
53
+ /** Saves the current slice as a new view. */
54
+ async create(body, workspaceId, user) {
55
+ const actor = requireUser(user);
56
+ await this.scopes.assertReachable(body.scope, workspaceId);
57
+ try {
58
+ return await this.createView.execute({
59
+ workspaceId,
60
+ scope: body.scope,
61
+ name: body.name,
62
+ visibility: body.visibility ?? saved_view_1.VIEW_VISIBILITY.Private,
63
+ payload: body.payload,
64
+ makeDefault: body.makeDefault
65
+ }, actor);
66
+ }
67
+ catch (error) {
68
+ (0, to_http_error_1.toHttpError)(error);
69
+ }
70
+ }
71
+ /** Renames, re-shares, or re-captures a view the caller owns. */
72
+ async update(id, body, workspaceId, user) {
73
+ const actor = requireUser(user);
74
+ try {
75
+ return await this.updateView.execute(id, workspaceId, body, actor);
76
+ }
77
+ catch (error) {
78
+ (0, to_http_error_1.toHttpError)(error);
79
+ }
80
+ }
81
+ /** Deletes a view the caller owns. */
82
+ async remove(id, workspaceId, user) {
83
+ const actor = requireUser(user);
84
+ try {
85
+ await this.deleteView.execute(id, workspaceId, actor);
86
+ }
87
+ catch (error) {
88
+ (0, to_http_error_1.toHttpError)(error);
89
+ }
90
+ }
91
+ /** Lands this member on the view when they open the list. */
92
+ async makeDefault(id, workspaceId, user) {
93
+ const actor = requireUser(user);
94
+ try {
95
+ await this.setDefault.execute(id, workspaceId, actor);
96
+ }
97
+ catch (error) {
98
+ (0, to_http_error_1.toHttpError)(error);
99
+ }
100
+ }
101
+ /** Clears the caller's default, so the list opens unfiltered again. */
102
+ async clearDefault(id, workspaceId, user) {
103
+ const actor = requireUser(user);
104
+ try {
105
+ await this.setDefault.executeClear(id, workspaceId, actor);
106
+ }
107
+ catch (error) {
108
+ (0, to_http_error_1.toHttpError)(error);
109
+ }
110
+ }
111
+ };
112
+ exports.SavedViewsController = SavedViewsController;
113
+ tslib_1.__decorate([
114
+ (0, swagger_1.ApiOperation)({
115
+ summary: 'List the saved views for one content type',
116
+ description: 'Returns the caller’s own views at any visibility plus every workspace-shared view for the scope, ordered for the switcher.'
117
+ }),
118
+ (0, common_1.Get)(),
119
+ tslib_1.__param(0, (0, common_1.Query)()),
120
+ tslib_1.__param(1, (0, workspaces_server_1.CurrentWorkspace)()),
121
+ tslib_1.__param(2, (0, identity_server_1.CurrentUser)()),
122
+ tslib_1.__metadata("design:type", Function),
123
+ tslib_1.__metadata("design:paramtypes", [save_view_dto_1.ListViewsQueryDto, String, Object]),
124
+ tslib_1.__metadata("design:returntype", Promise)
125
+ ], SavedViewsController.prototype, "list", null);
126
+ tslib_1.__decorate([
127
+ (0, swagger_1.ApiOperation)({
128
+ summary: 'Save a new view',
129
+ description: 'Stores the filter/sort/columns slice under a name. `visibility: workspace` additionally requires `views:share`.'
130
+ }),
131
+ (0, common_1.Post)(),
132
+ tslib_1.__param(0, (0, common_1.Body)()),
133
+ tslib_1.__param(1, (0, workspaces_server_1.CurrentWorkspace)()),
134
+ tslib_1.__param(2, (0, identity_server_1.CurrentUser)()),
135
+ tslib_1.__metadata("design:type", Function),
136
+ tslib_1.__metadata("design:paramtypes", [save_view_dto_1.CreateViewDto, String, Object]),
137
+ tslib_1.__metadata("design:returntype", Promise)
138
+ ], SavedViewsController.prototype, "create", null);
139
+ tslib_1.__decorate([
140
+ (0, swagger_1.ApiOperation)({
141
+ summary: 'Update a saved view',
142
+ description: 'Owner-only. Send just the fields that change — `payload` on Save, `name` on a rename, `visibility` on share/unshare.'
143
+ }),
144
+ (0, common_1.Patch)(':id'),
145
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
146
+ tslib_1.__param(1, (0, common_1.Body)()),
147
+ tslib_1.__param(2, (0, workspaces_server_1.CurrentWorkspace)()),
148
+ tslib_1.__param(3, (0, identity_server_1.CurrentUser)()),
149
+ tslib_1.__metadata("design:type", Function),
150
+ tslib_1.__metadata("design:paramtypes", [String, save_view_dto_1.UpdateViewDto, String, Object]),
151
+ tslib_1.__metadata("design:returntype", Promise)
152
+ ], SavedViewsController.prototype, "update", null);
153
+ tslib_1.__decorate([
154
+ (0, swagger_1.ApiOperation)({
155
+ summary: 'Delete a saved view',
156
+ description: 'Owner-only. Any member’s default pointing at it is cleared by the cascade.'
157
+ }),
158
+ (0, common_1.Delete)(':id'),
159
+ (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
160
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
161
+ tslib_1.__param(1, (0, workspaces_server_1.CurrentWorkspace)()),
162
+ tslib_1.__param(2, (0, identity_server_1.CurrentUser)()),
163
+ tslib_1.__metadata("design:type", Function),
164
+ tslib_1.__metadata("design:paramtypes", [String, String, Object]),
165
+ tslib_1.__metadata("design:returntype", Promise)
166
+ ], SavedViewsController.prototype, "remove", null);
167
+ tslib_1.__decorate([
168
+ (0, swagger_1.ApiOperation)({
169
+ summary: 'Make a view the caller’s default',
170
+ description: 'Not owner-gated: a default is the reader’s own landing choice, so any view they can see may be one.'
171
+ }),
172
+ (0, common_1.Put)(':id/default'),
173
+ (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
174
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
175
+ tslib_1.__param(1, (0, workspaces_server_1.CurrentWorkspace)()),
176
+ tslib_1.__param(2, (0, identity_server_1.CurrentUser)()),
177
+ tslib_1.__metadata("design:type", Function),
178
+ tslib_1.__metadata("design:paramtypes", [String, String, Object]),
179
+ tslib_1.__metadata("design:returntype", Promise)
180
+ ], SavedViewsController.prototype, "makeDefault", null);
181
+ tslib_1.__decorate([
182
+ (0, swagger_1.ApiOperation)({
183
+ summary: 'Clear the caller’s default view',
184
+ description: 'The list then opens with no filter. Idempotent — clearing an absent default succeeds.'
185
+ }),
186
+ (0, common_1.Delete)(':id/default'),
187
+ (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
188
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
189
+ tslib_1.__param(1, (0, workspaces_server_1.CurrentWorkspace)()),
190
+ tslib_1.__param(2, (0, identity_server_1.CurrentUser)()),
191
+ tslib_1.__metadata("design:type", Function),
192
+ tslib_1.__metadata("design:paramtypes", [String, String, Object]),
193
+ tslib_1.__metadata("design:returntype", Promise)
194
+ ], SavedViewsController.prototype, "clearDefault", null);
195
+ exports.SavedViewsController = SavedViewsController = tslib_1.__decorate([
196
+ (0, swagger_1.ApiTags)('views'),
197
+ (0, common_1.UseGuards)(identity_server_1.PermissionsGuard, workspaces_server_1.WorkspaceGuard),
198
+ (0, identity_server_1.RequirePermissions)(identity_server_1.PERMISSIONS.CONTENT_READ),
199
+ (0, common_1.Controller)('views'),
200
+ tslib_1.__metadata("design:paramtypes", [saved_views_query_1.SavedViewsQuery,
201
+ view_scope_service_1.ViewScopeService,
202
+ create_saved_view_use_case_1.CreateSavedViewUseCase,
203
+ update_saved_view_use_case_1.UpdateSavedViewUseCase,
204
+ delete_saved_view_use_case_1.DeleteSavedViewUseCase,
205
+ set_default_view_use_case_1.SetDefaultViewUseCase])
206
+ ], SavedViewsController);
207
+ /**
208
+ * Narrows the optional `@CurrentUser()` to a present one. Every route here is
209
+ * behind the app-wide `AuthGuard`, so this cannot fire in practice — it exists
210
+ * so the use-cases take a `PublicUser` rather than an optional one.
211
+ */
212
+ function requireUser(user) {
213
+ if (!user)
214
+ throw new common_1.UnauthorizedException();
215
+ return user;
216
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Maps the saved-view domain errors onto HTTP. Domain errors stay
3
+ * transport-agnostic (ADR-0003), so every controller funnels through this one
4
+ * translation rather than each restating the status codes.
5
+ *
6
+ * Anything unrecognised is rethrown untouched — swallowing it here would turn a
7
+ * genuine fault into a misleading 4xx.
8
+ */
9
+ export declare function toHttpError(error: unknown): never;
10
+ //# sourceMappingURL=to-http-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-http-error.d.ts","sourceRoot":"","sources":["../../../../../src/lib/views/http/controllers/to-http-error.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAcjD"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toHttpError = toHttpError;
4
+ const common_1 = require("@nestjs/common");
5
+ const errors_1 = require("../../domain/errors");
6
+ /**
7
+ * Maps the saved-view domain errors onto HTTP. Domain errors stay
8
+ * transport-agnostic (ADR-0003), so every controller funnels through this one
9
+ * translation rather than each restating the status codes.
10
+ *
11
+ * Anything unrecognised is rethrown untouched — swallowing it here would turn a
12
+ * genuine fault into a misleading 4xx.
13
+ */
14
+ function toHttpError(error) {
15
+ if (error instanceof errors_1.SavedViewNotFoundError) {
16
+ throw new common_1.NotFoundException(error.message);
17
+ }
18
+ if (error instanceof errors_1.SavedViewForbiddenError) {
19
+ throw new common_1.ForbiddenException(error.message);
20
+ }
21
+ if (error instanceof errors_1.SavedViewNameTakenError ||
22
+ error instanceof errors_1.SavedViewLimitError) {
23
+ throw new common_1.ConflictException(error.message);
24
+ }
25
+ throw error;
26
+ }
@@ -0,0 +1,54 @@
1
+ import { type ViewVisibility } from '../../domain/saved-view';
2
+ /**
3
+ * The slice a view stores. Mirrors the records page's URL params rather than
4
+ * re-modelling them, so a saved view and a hand-edited link travel the same
5
+ * code path. `search` and `page` are absent by design — see
6
+ * {@link SavedViewPayload}.
7
+ */
8
+ export declare class ViewPayloadDto {
9
+ /** The `?filter=` JSON string. */
10
+ filter?: string;
11
+ /** The `?sort=` spec. */
12
+ sort?: string;
13
+ /** Rows per page. */
14
+ pageSize?: number;
15
+ /** Visible column ids, in display order. */
16
+ columns?: string[];
17
+ /** Slot-owned list params (e.g. the i18n plugin's `locale`). */
18
+ extra?: Record<string, string>;
19
+ }
20
+ /** Body of `POST /api/views`. */
21
+ export declare class CreateViewDto {
22
+ /**
23
+ * The list this view is over. v1 accepts content collections only, so a
24
+ * typo cannot quietly create a view nothing will ever list.
25
+ */
26
+ scope: string;
27
+ /** Display name. */
28
+ name: string;
29
+ /** Who may see it. Defaults to private. */
30
+ visibility?: ViewVisibility;
31
+ /** The slice it restores. */
32
+ payload: ViewPayloadDto;
33
+ /** Whether to land on this view when opening the list. */
34
+ makeDefault?: boolean;
35
+ }
36
+ /**
37
+ * Body of `PATCH /api/views/:id`. Every field optional — the switcher sends
38
+ * only `payload` on “Save”, only `name` on a rename, and only `visibility` on
39
+ * share/unshare.
40
+ */
41
+ export declare class UpdateViewDto {
42
+ /** New display name. */
43
+ name?: string;
44
+ /** New visibility. */
45
+ visibility?: ViewVisibility;
46
+ /** New slice. */
47
+ payload?: ViewPayloadDto;
48
+ }
49
+ /** Query of `GET /api/views`. */
50
+ export declare class ListViewsQueryDto {
51
+ /** The list to return views for. */
52
+ scope: string;
53
+ }
54
+ //# sourceMappingURL=save-view.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-view.dto.d.ts","sourceRoot":"","sources":["../../../../../src/lib/views/http/dto/save-view.dto.ts"],"names":[],"mappings":"AAuBA,OAAO,EAGH,KAAK,cAAc,EACtB,MAAM,yBAAyB,CAAC;AAUjC;;;;;GAKG;AACH,qBAAa,cAAc;IACvB,kCAAkC;IAYlC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,yBAAyB;IAWzB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,qBAAqB;IAYrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,4CAA4C;IAa5C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,gEAAgE;IAWhE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,iCAAiC;AACjC,qBAAa,aAAa;IACtB;;;OAGG;IAaH,KAAK,EAAG,MAAM,CAAC;IAEf,oBAAoB;IAcpB,IAAI,EAAG,MAAM,CAAC;IAEd,2CAA2C;IAS3C,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B,6BAA6B;IAO7B,OAAO,EAAG,cAAc,CAAC;IAEzB,0DAA0D;IAQ1D,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,qBAAa,aAAa;IACtB,wBAAwB;IAcxB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,sBAAsB;IAItB,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B,iBAAiB;IAKjB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,iCAAiC;AACjC,qBAAa,iBAAiB;IAC1B,oCAAoC;IAapC,KAAK,EAAG,MAAM,CAAC;CAClB"}