Skip to content

Commit ac26bff

Browse files
committed
Enable Notes list in SDK
1 parent 578e7c5 commit ac26bff

5 files changed

Lines changed: 66 additions & 2 deletions

File tree

src/__tests__/notesClient.test.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import assert from 'node:assert/strict';
44
import test from 'node:test';
55
import type { AuthModule } from '../auth/types.js';
6-
import type { ProjectNote } from '../notes/notesTypes.js';
6+
import type { ProjectNote, ProjectNoteHeader } from '../notes/notesTypes.js';
77
import { diskd } from '../sdk/diskd.js';
88

99
type FetchCall = { readonly url: string; readonly init?: RequestInit };
@@ -24,6 +24,16 @@ const stubNote: ProjectNote = {
2424
updatedAt: '2026-05-16T10:00:00.000Z',
2525
};
2626

27+
const stubHeader: ProjectNoteHeader = {
28+
id: NOTE_ID,
29+
projectId: PROJECT_ID,
30+
name: 'Architecture note',
31+
contentPreview: '# Architecture',
32+
params: { pin: false, order: 0 },
33+
createdAt: '2026-05-16T10:00:00.000Z',
34+
updatedAt: '2026-05-16T10:00:00.000Z',
35+
};
36+
2737
/** Build a deterministic auth module so Notes client tests assert SDK headers. */
2838
const makeAuth = (): AuthModule => ({
2939
signIn: async () => {},
@@ -118,6 +128,34 @@ test('notes.read sends GET with noteId path param and bound projectId query', as
118128
);
119129
});
120130

131+
test('notes.list sends GET with bound projectId query and returns headers', async () => {
132+
/* REQUIREMENT enabling:dev/platform-api/sdk -- Notes list uses the project-scoped project-notes API. */
133+
const url = 'http://app-service:3000';
134+
135+
await withFetchMock(
136+
() =>
137+
new Response(JSON.stringify([stubHeader]), {
138+
status: 200,
139+
headers: { 'Content-Type': 'application/json' },
140+
}),
141+
async (calls) => {
142+
const client = diskd.platform.notes({
143+
auth: makeAuth(),
144+
scope: { scopeType: 'project', projectId: PROJECT_ID },
145+
url,
146+
});
147+
const result = await client.list();
148+
149+
assert.deepEqual(result, [stubHeader]);
150+
assert.equal(
151+
calls[0]?.url,
152+
`http://app-service:3000/api/project-notes?projectId=${PROJECT_ID}`
153+
);
154+
assert.equal(calls[0]?.init?.method, 'GET');
155+
}
156+
);
157+
});
158+
121159
test('notes client throws on HTTP error with parsed message', async () => {
122160
const url = 'http://app-service:3000';
123161

src/browser/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export type { DriveClient, DrivePathEntry, DrivePathType } from '../drive/types.
7474
export type {
7575
CreateProjectNoteParams,
7676
ProjectNote,
77+
ProjectNoteHeader,
7778
ProjectNoteMetadata,
7879
ProjectNoteParams,
7980
ProjectNotesClient,

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ export { createProjectNotesClient } from './notes/notes.js';
383383
export type {
384384
CreateProjectNoteParams,
385385
ProjectNote,
386+
ProjectNoteHeader,
386387
ProjectNoteMetadata,
387388
ProjectNoteParams,
388389
ProjectNotesClient,

src/notes/notes.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import type { AuthModule } from '../auth/types.js';
22
import { resolveDiskdGatewayUrl } from '../env/baseUrl.js';
33
import { buildQuery, type HttpMethod, httpRequest, resolveAuthHeaders } from '../sdk/http.js';
4-
import type { CreateProjectNoteParams, ProjectNote, ProjectNotesClient } from './notesTypes.js';
4+
import type {
5+
CreateProjectNoteParams,
6+
ProjectNote,
7+
ProjectNoteHeader,
8+
ProjectNotesClient,
9+
} from './notesTypes.js';
510

611
// ---------------------------------------------------------------------------
712
// Client factory
@@ -59,5 +64,12 @@ export const createProjectNotesClient = (params: {
5964
`/api/project-notes/${encId(noteId)}${buildQuery([['projectId', params.projectId]])}`
6065
);
6166
},
67+
68+
list: async (): Promise<readonly ProjectNoteHeader[]> => {
69+
return request<readonly ProjectNoteHeader[]>(
70+
'GET',
71+
`/api/project-notes${buildQuery([['projectId', params.projectId]])}`
72+
);
73+
},
6274
};
6375
};

src/notes/notesTypes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ export type ProjectNote = {
2727
readonly updatedAt: string;
2828
};
2929

30+
export type ProjectNoteHeader = {
31+
readonly id: string;
32+
readonly projectId: string;
33+
readonly name: string;
34+
readonly contentPreview: string;
35+
readonly params: ProjectNoteParams;
36+
readonly createdAt: string;
37+
readonly updatedAt: string;
38+
};
39+
3040
// -- Scope and params --
3141

3242
export type ProjectNotesScopeRef = {
@@ -56,4 +66,6 @@ export type ProjectNotesClient = {
5666
readonly create: (params: CreateProjectNoteParams) => Promise<ProjectNote>;
5767
/** GET /api/project-notes/:noteId -- read a Drive-backed project note. */
5868
readonly read: (noteId: string) => Promise<ProjectNote>;
69+
/** GET /api/project-notes -- list Drive-backed project note headers. */
70+
readonly list: () => Promise<readonly ProjectNoteHeader[]>;
5971
};

0 commit comments

Comments
 (0)