@crossworks/client-types 0.232.281 → 0.232.283
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.
- package/package.json +1 -1
- package/src/dto/member.ts +59 -1
- package/src/index.ts +8 -0
- package/src/member-kinds.test.ts +13 -0
- package/src/member-kinds.ts +12 -0
package/package.json
CHANGED
package/src/dto/member.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* its own thread.
|
|
6
6
|
*/
|
|
7
7
|
import type { AccessLevel } from './access';
|
|
8
|
+
import type { MemberItemKind } from '../member-kinds';
|
|
8
9
|
|
|
9
10
|
/** GET /api/member/shell */
|
|
10
11
|
export type MemberShell = {
|
|
@@ -30,7 +31,7 @@ export type MemberShell = {
|
|
|
30
31
|
logoDarkVersion: string | null;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
export type MemberLibraryKind =
|
|
34
|
+
export type MemberLibraryKind = MemberItemKind;
|
|
34
35
|
|
|
35
36
|
export type MemberLibraryRow = {
|
|
36
37
|
id: string;
|
|
@@ -80,3 +81,60 @@ export type MemberChatThread = {
|
|
|
80
81
|
linked?: boolean;
|
|
81
82
|
messages: MemberChatMessage[];
|
|
82
83
|
};
|
|
84
|
+
|
|
85
|
+
// ── Personal spaces (member logins Phase 2) ──────────────────────────────
|
|
86
|
+
|
|
87
|
+
export type MemberSpaceSharing = 'private' | 'team';
|
|
88
|
+
export type MemberReviewState = 'draft' | 'submitted' | 'returned' | 'accepted';
|
|
89
|
+
|
|
90
|
+
/** One item of a personal space: GET /api/member/space[/team] rows. */
|
|
91
|
+
export type MemberSpaceItemRow = {
|
|
92
|
+
id: string;
|
|
93
|
+
type: MemberItemKind;
|
|
94
|
+
title: string;
|
|
95
|
+
icon: string | null;
|
|
96
|
+
sharing: MemberSpaceSharing;
|
|
97
|
+
reviewState: MemberReviewState;
|
|
98
|
+
submittedAt: string | null;
|
|
99
|
+
returnedNote: string | null;
|
|
100
|
+
/** The login that wrote it (team drafts show whose it is). */
|
|
101
|
+
authorLoginId: string | null;
|
|
102
|
+
updatedAt: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** GET /api/member/space?kind=&q=&page= (and /space/team) */
|
|
106
|
+
export type MemberSpaceList = {
|
|
107
|
+
items: MemberSpaceItemRow[];
|
|
108
|
+
total: number;
|
|
109
|
+
page: number;
|
|
110
|
+
pageSize: number;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** A space file's metadata; the bytes stream from the item's bytes route. */
|
|
114
|
+
export type MemberSpaceFile = {
|
|
115
|
+
id: string;
|
|
116
|
+
filename: string;
|
|
117
|
+
extension: string;
|
|
118
|
+
mimeType: string;
|
|
119
|
+
sizeBytes: number;
|
|
120
|
+
sha256: string | null;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* An item's body. The page, drawing and table shapes are the brain's own
|
|
125
|
+
* editor models (content-core); the contract leaves them to the client, which
|
|
126
|
+
* narrows them with `TDoc` / `TTable`.
|
|
127
|
+
*/
|
|
128
|
+
export type MemberSpaceItemBody<TDoc = unknown, TTable = unknown> =
|
|
129
|
+
| { type: 'page'; page: { doc: TDoc; draft: TDoc | null; draftRev?: number; title: string } }
|
|
130
|
+
| { type: 'note'; note: { content: string; title: string } }
|
|
131
|
+
/** Null for a teammate: their drawing shows from its saved SVG route. */
|
|
132
|
+
| { type: 'draw'; draw: { scene: TDoc; draft: TDoc | null; draftRev?: number } | null }
|
|
133
|
+
| { type: 'table'; table: TTable }
|
|
134
|
+
| { type: 'file'; file: MemberSpaceFile };
|
|
135
|
+
|
|
136
|
+
/** GET /api/member/space/:id (and the team read): the row and its body. */
|
|
137
|
+
export type MemberSpaceItem<TDoc = unknown, TTable = unknown> = {
|
|
138
|
+
row: MemberSpaceItemRow;
|
|
139
|
+
body: MemberSpaceItemBody<TDoc, TTable>;
|
|
140
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -47,8 +47,16 @@ export type {
|
|
|
47
47
|
MemberLibraryKind,
|
|
48
48
|
MemberLibraryPage,
|
|
49
49
|
MemberLibraryRow,
|
|
50
|
+
MemberReviewState,
|
|
50
51
|
MemberShell,
|
|
52
|
+
MemberSpaceFile,
|
|
53
|
+
MemberSpaceItem,
|
|
54
|
+
MemberSpaceItemBody,
|
|
55
|
+
MemberSpaceItemRow,
|
|
56
|
+
MemberSpaceList,
|
|
57
|
+
MemberSpaceSharing,
|
|
51
58
|
} from './dto/member';
|
|
59
|
+
export type { MemberItemKind } from './member-kinds';
|
|
52
60
|
|
|
53
61
|
// Types only at the root; the runtime constants (APP_TINTS, limits) are the
|
|
54
62
|
// `@mantle/client-types/app-nav` subpath.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { MEMBER_ITEM_KINDS, isMemberItemKind } from './member-kinds';
|
|
3
|
+
|
|
4
|
+
describe('member item kinds', () => {
|
|
5
|
+
it('is the five kinds a space holds and the Library lists', () => {
|
|
6
|
+
expect([...MEMBER_ITEM_KINDS]).toEqual(['page', 'note', 'draw', 'table', 'file']);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('accepts a kind and refuses anything else', () => {
|
|
10
|
+
for (const k of MEMBER_ITEM_KINDS) expect(isMemberItemKind(k)).toBe(true);
|
|
11
|
+
for (const v of ['folder', 'app', 'Page', '', null, 3]) expect(isMemberItemKind(v)).toBe(false);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kinds of item a member works with: what a personal space holds and
|
|
3
|
+
* what the Library lists. The ONE list, for the brain (member-space.ts,
|
|
4
|
+
* member-library.ts) and the client alike (audit M2); a runtime constant, so
|
|
5
|
+
* it is the `@mantle/client-types/member-kinds` subpath.
|
|
6
|
+
*/
|
|
7
|
+
export const MEMBER_ITEM_KINDS = ['page', 'note', 'draw', 'table', 'file'] as const;
|
|
8
|
+
export type MemberItemKind = (typeof MEMBER_ITEM_KINDS)[number];
|
|
9
|
+
|
|
10
|
+
export function isMemberItemKind(v: unknown): v is MemberItemKind {
|
|
11
|
+
return typeof v === 'string' && (MEMBER_ITEM_KINDS as readonly string[]).includes(v);
|
|
12
|
+
}
|