notefeed 0.6.0 → 0.8.0
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/README.md +12 -0
- package/dist/cli.js +71 -15
- package/dist/client.d.ts +85 -8
- package/dist/client.js +167 -14
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +1 -1
- package/dist/generated/sdk.gen.d.ts +56 -2
- package/dist/generated/sdk.gen.js +106 -2
- package/dist/generated/types.gen.d.ts +590 -21
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client/index.js';
|
|
2
|
-
import type { GetNoteData, GetNoteErrors, GetNoteResponses, GetOpenApiData, GetOpenApiResponses, GetReadNoteData, GetReadNoteErrors, GetReadNoteResponses, ListNotesData, ListNotesErrors, ListNotesResponses, ListReadNotesData, ListReadNotesErrors, ListReadNotesResponses, PostNoteData, PostNoteErrors, PostNoteResponses } from './types.gen.js';
|
|
2
|
+
import type { ChangeFeedPasswordData, ChangeFeedPasswordErrors, ChangeFeedPasswordResponses, DeleteFeedData, DeleteFeedErrors, DeleteFeedResponses, DeleteNoteData, DeleteNoteErrors, DeleteNoteResponses, EditNoteData, EditNoteErrors, EditNoteResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetNoteData, GetNoteErrors, GetNoteResponses, GetOpenApiData, GetOpenApiResponses, GetReadFeedData, GetReadFeedErrors, GetReadFeedResponses, GetReadNoteData, GetReadNoteErrors, GetReadNoteResponses, ListNotesData, ListNotesErrors, ListNotesResponses, ListReadNotesData, ListReadNotesErrors, ListReadNotesResponses, PatchNoteData, PatchNoteErrors, PatchNoteResponses, PostNoteData, PostNoteErrors, PostNoteResponses, RemoveFeedPasswordData, RemoveFeedPasswordErrors, RemoveFeedPasswordResponses, UpdateFeedData, UpdateFeedErrors, UpdateFeedResponses } from './types.gen.js';
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -22,13 +22,67 @@ export declare const listNotes: <ThrowOnError extends boolean = false>(options:
|
|
|
22
22
|
/**
|
|
23
23
|
* Post a note
|
|
24
24
|
*
|
|
25
|
-
* Creates the feed with its first note. Also served at `POST /{feed}`, the short form
|
|
25
|
+
* The body is the note, a file, and `Content-Type` says which kind: `text/markdown` (UTF-8, at most 102400 bytes), or an image, `image/png`, `image/jpeg`, `image/gif` or `image/webp` (at most NOTEFEED_MAX_IMAGE_BYTES, default 5 MiB). Nothing is guessed: any other type, or none, is `415`, and so is a body that is not what the type says (an image is recognized by its first bytes; SVG is refused). It is stored byte for byte, with no resizing and no metadata stripped (EXIF such as GPS position stays in an image). Creates the feed with its first note, optionally protected by its own password (`X-Feed-Password`; 1 to 256 printable ASCII characters, with no space at the start or end) and with the read id in `X-Read-Id`; both are only used by the post that creates the feed. Posting to a protected feed needs its password. Also served at `POST /{feed}`, the short form curl one-liners use. The response names the note's `file` and where it is served, `file_url`, under the feed's read id (public like the read link). Metadata goes in headers: `X-Note-Title`, `X-Note-Tags` (at most 10 tags, each 1 to 32 characters of letters, digits, `-`, `_`, `.` and `:`; case is folded to lowercase, duplicates are removed), `X-Note-Alt` (images), `X-Note-Name` (the original file name).
|
|
26
26
|
*/
|
|
27
27
|
export declare const postNote: <ThrowOnError extends boolean = false>(options: Options<PostNoteData, ThrowOnError>) => RequestResult<PostNoteResponses, PostNoteErrors, ThrowOnError>;
|
|
28
|
+
/**
|
|
29
|
+
* Delete a note
|
|
30
|
+
*
|
|
31
|
+
* Needs the feed's password if it has one, and counts against the post rate limit. The feed stays, even with no notes left. Read links can't delete.
|
|
32
|
+
*/
|
|
33
|
+
export declare const deleteNote: <ThrowOnError extends boolean = false>(options: Options<DeleteNoteData, ThrowOnError>) => RequestResult<DeleteNoteResponses, DeleteNoteErrors, ThrowOnError>;
|
|
28
34
|
/**
|
|
29
35
|
* Get one note
|
|
30
36
|
*/
|
|
31
37
|
export declare const getNote: <ThrowOnError extends boolean = false>(options: Options<GetNoteData, ThrowOnError>) => RequestResult<GetNoteResponses, GetNoteErrors, ThrowOnError>;
|
|
38
|
+
/**
|
|
39
|
+
* Change a note's title or alt text
|
|
40
|
+
*
|
|
41
|
+
* Sets the note's title and/or alt text (alt only for images). An empty string removes one: a markdown note's title follows its text again. At least one is needed. Needs the feed's password if it has one, and counts against the post rate limit. Read links can't change notes.
|
|
42
|
+
*/
|
|
43
|
+
export declare const patchNote: <ThrowOnError extends boolean = false>(options: Options<PatchNoteData, ThrowOnError>) => RequestResult<PatchNoteResponses, PatchNoteErrors, ThrowOnError>;
|
|
44
|
+
/**
|
|
45
|
+
* Replace a note's content
|
|
46
|
+
*
|
|
47
|
+
* The body is the new file, with the same rules as posting: a `Content-Type` that is one of the accepted types, a body that is what it declares. A note keeps its type, so the type must be the note's own (`415` otherwise). Id, creation time and metadata stay: the title of a markdown note without one set follows the new text. Change the title or alt text with `PATCH`. Needs the feed's password if it has one, and counts against the post rate limit. Read links can't edit.
|
|
48
|
+
*/
|
|
49
|
+
export declare const editNote: <ThrowOnError extends boolean = false>(options: Options<EditNoteData, ThrowOnError>) => RequestResult<EditNoteResponses, EditNoteErrors, ThrowOnError>;
|
|
50
|
+
/**
|
|
51
|
+
* Delete a feed
|
|
52
|
+
*
|
|
53
|
+
* Deletes the feed with all its notes, its settings, its password and its read link, for good: there is no undo. The name is free again; a feed created there later gets a new read link, and the old one answers like an unknown one. Needs the feed's password if it has one, and counts against the post rate limit.
|
|
54
|
+
*/
|
|
55
|
+
export declare const deleteFeed: <ThrowOnError extends boolean = false>(options: Options<DeleteFeedData, ThrowOnError>) => RequestResult<DeleteFeedResponses, DeleteFeedErrors, ThrowOnError>;
|
|
56
|
+
/**
|
|
57
|
+
* Get a feed's settings
|
|
58
|
+
*
|
|
59
|
+
* The title and description, the title image, whether the feed is protected, and its read link (null while it has no notes). A feed exists once its first note is posted.
|
|
60
|
+
*/
|
|
61
|
+
export declare const getFeed: <ThrowOnError extends boolean = false>(options: Options<GetFeedData, ThrowOnError>) => RequestResult<GetFeedResponses, GetFeedErrors, ThrowOnError>;
|
|
62
|
+
/**
|
|
63
|
+
* Change a feed's settings
|
|
64
|
+
*
|
|
65
|
+
* Replaces both the title (at most 100 characters) and the description (at most 500); surrounding whitespace is trimmed and control characters are refused. `show_sender` (default true) shows who posted each note to readers; omitted leaves it as it is. `read_id` gives the feed another read link (3 to 64 characters: a-z, 0-9, - and _; empty for a random one): the old id is freed and answers like an unknown read id until another feed takes it, and the notes are not edited (a relative image link follows the new id, a full URL does not). A short readable read id is guessable, so protect the feed with a password if that matters. An instance can turn chosen read ids off (NOTEFEED_ALLOW_CUSTOM_IDS=0): then only an empty `read_id` is accepted. `image` is the file name `uploadImage` returned for this feed (title image), empty to remove it, or omitted to leave it as it is; any other value is a 400. Needs the feed's password if it has one, and counts against the post rate limit. Only on a feed that exists: it is created by its first note. Read links can't change settings.
|
|
66
|
+
*/
|
|
67
|
+
export declare const updateFeed: <ThrowOnError extends boolean = false>(options: Options<UpdateFeedData, ThrowOnError>) => RequestResult<UpdateFeedResponses, UpdateFeedErrors, ThrowOnError>;
|
|
68
|
+
/**
|
|
69
|
+
* Remove a feed's password
|
|
70
|
+
*
|
|
71
|
+
* Needs the current password in `X-Feed-Password`. The feed stays, open to anyone who knows its name. An open feed answers 409.
|
|
72
|
+
*/
|
|
73
|
+
export declare const removeFeedPassword: <ThrowOnError extends boolean = false>(options: Options<RemoveFeedPasswordData, ThrowOnError>) => RequestResult<RemoveFeedPasswordResponses, RemoveFeedPasswordErrors, ThrowOnError>;
|
|
74
|
+
/**
|
|
75
|
+
* Change a feed's password
|
|
76
|
+
*
|
|
77
|
+
* Needs the current password in `X-Feed-Password`. A feed can only get a password when it is created, so an open feed answers 409.
|
|
78
|
+
*/
|
|
79
|
+
export declare const changeFeedPassword: <ThrowOnError extends boolean = false>(options: Options<ChangeFeedPasswordData, ThrowOnError>) => RequestResult<ChangeFeedPasswordResponses, ChangeFeedPasswordErrors, ThrowOnError>;
|
|
80
|
+
/**
|
|
81
|
+
* Get a feed's title and description by its read id
|
|
82
|
+
*
|
|
83
|
+
* Public, even on an instance with a password, and never reveals the feed's name. An unknown read id has an empty title and description, so read ids can't be probed.
|
|
84
|
+
*/
|
|
85
|
+
export declare const getReadFeed: <ThrowOnError extends boolean = false>(options: Options<GetReadFeedData, ThrowOnError>) => RequestResult<GetReadFeedResponses, GetReadFeedErrors, ThrowOnError>;
|
|
32
86
|
/**
|
|
33
87
|
* List a feed's notes by its read id
|
|
34
88
|
*
|
|
@@ -13,17 +13,28 @@ export const listNotes = (options) => (options.client ?? client).get({
|
|
|
13
13
|
/**
|
|
14
14
|
* Post a note
|
|
15
15
|
*
|
|
16
|
-
* Creates the feed with its first note. Also served at `POST /{feed}`, the short form
|
|
16
|
+
* The body is the note, a file, and `Content-Type` says which kind: `text/markdown` (UTF-8, at most 102400 bytes), or an image, `image/png`, `image/jpeg`, `image/gif` or `image/webp` (at most NOTEFEED_MAX_IMAGE_BYTES, default 5 MiB). Nothing is guessed: any other type, or none, is `415`, and so is a body that is not what the type says (an image is recognized by its first bytes; SVG is refused). It is stored byte for byte, with no resizing and no metadata stripped (EXIF such as GPS position stays in an image). Creates the feed with its first note, optionally protected by its own password (`X-Feed-Password`; 1 to 256 printable ASCII characters, with no space at the start or end) and with the read id in `X-Read-Id`; both are only used by the post that creates the feed. Posting to a protected feed needs its password. Also served at `POST /{feed}`, the short form curl one-liners use. The response names the note's `file` and where it is served, `file_url`, under the feed's read id (public like the read link). Metadata goes in headers: `X-Note-Title`, `X-Note-Tags` (at most 10 tags, each 1 to 32 characters of letters, digits, `-`, `_`, `.` and `:`; case is folded to lowercase, duplicates are removed), `X-Note-Alt` (images), `X-Note-Name` (the original file name).
|
|
17
17
|
*/
|
|
18
18
|
export const postNote = (options) => (options.client ?? client).post({
|
|
19
|
+
bodySerializer: null,
|
|
19
20
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
20
21
|
url: '/api/v1/feeds/{feed}/notes',
|
|
21
22
|
...options,
|
|
22
23
|
headers: {
|
|
23
|
-
'Content-Type': '
|
|
24
|
+
'Content-Type': 'text/markdown',
|
|
24
25
|
...options.headers
|
|
25
26
|
}
|
|
26
27
|
});
|
|
28
|
+
/**
|
|
29
|
+
* Delete a note
|
|
30
|
+
*
|
|
31
|
+
* Needs the feed's password if it has one, and counts against the post rate limit. The feed stays, even with no notes left. Read links can't delete.
|
|
32
|
+
*/
|
|
33
|
+
export const deleteNote = (options) => (options.client ?? client).delete({
|
|
34
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
35
|
+
url: '/api/v1/feeds/{feed}/notes/{id}',
|
|
36
|
+
...options
|
|
37
|
+
});
|
|
27
38
|
/**
|
|
28
39
|
* Get one note
|
|
29
40
|
*/
|
|
@@ -32,6 +43,99 @@ export const getNote = (options) => (options.client ?? client).get({
|
|
|
32
43
|
url: '/api/v1/feeds/{feed}/notes/{id}',
|
|
33
44
|
...options
|
|
34
45
|
});
|
|
46
|
+
/**
|
|
47
|
+
* Change a note's title or alt text
|
|
48
|
+
*
|
|
49
|
+
* Sets the note's title and/or alt text (alt only for images). An empty string removes one: a markdown note's title follows its text again. At least one is needed. Needs the feed's password if it has one, and counts against the post rate limit. Read links can't change notes.
|
|
50
|
+
*/
|
|
51
|
+
export const patchNote = (options) => (options.client ?? client).patch({
|
|
52
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
53
|
+
url: '/api/v1/feeds/{feed}/notes/{id}',
|
|
54
|
+
...options,
|
|
55
|
+
headers: {
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
...options.headers
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Replace a note's content
|
|
62
|
+
*
|
|
63
|
+
* The body is the new file, with the same rules as posting: a `Content-Type` that is one of the accepted types, a body that is what it declares. A note keeps its type, so the type must be the note's own (`415` otherwise). Id, creation time and metadata stay: the title of a markdown note without one set follows the new text. Change the title or alt text with `PATCH`. Needs the feed's password if it has one, and counts against the post rate limit. Read links can't edit.
|
|
64
|
+
*/
|
|
65
|
+
export const editNote = (options) => (options.client ?? client).put({
|
|
66
|
+
bodySerializer: null,
|
|
67
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
68
|
+
url: '/api/v1/feeds/{feed}/notes/{id}',
|
|
69
|
+
...options,
|
|
70
|
+
headers: {
|
|
71
|
+
'Content-Type': 'text/markdown',
|
|
72
|
+
...options.headers
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Delete a feed
|
|
77
|
+
*
|
|
78
|
+
* Deletes the feed with all its notes, its settings, its password and its read link, for good: there is no undo. The name is free again; a feed created there later gets a new read link, and the old one answers like an unknown one. Needs the feed's password if it has one, and counts against the post rate limit.
|
|
79
|
+
*/
|
|
80
|
+
export const deleteFeed = (options) => (options.client ?? client).delete({
|
|
81
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
82
|
+
url: '/api/v1/feeds/{feed}',
|
|
83
|
+
...options
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Get a feed's settings
|
|
87
|
+
*
|
|
88
|
+
* The title and description, the title image, whether the feed is protected, and its read link (null while it has no notes). A feed exists once its first note is posted.
|
|
89
|
+
*/
|
|
90
|
+
export const getFeed = (options) => (options.client ?? client).get({
|
|
91
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
92
|
+
url: '/api/v1/feeds/{feed}',
|
|
93
|
+
...options
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Change a feed's settings
|
|
97
|
+
*
|
|
98
|
+
* Replaces both the title (at most 100 characters) and the description (at most 500); surrounding whitespace is trimmed and control characters are refused. `show_sender` (default true) shows who posted each note to readers; omitted leaves it as it is. `read_id` gives the feed another read link (3 to 64 characters: a-z, 0-9, - and _; empty for a random one): the old id is freed and answers like an unknown read id until another feed takes it, and the notes are not edited (a relative image link follows the new id, a full URL does not). A short readable read id is guessable, so protect the feed with a password if that matters. An instance can turn chosen read ids off (NOTEFEED_ALLOW_CUSTOM_IDS=0): then only an empty `read_id` is accepted. `image` is the file name `uploadImage` returned for this feed (title image), empty to remove it, or omitted to leave it as it is; any other value is a 400. Needs the feed's password if it has one, and counts against the post rate limit. Only on a feed that exists: it is created by its first note. Read links can't change settings.
|
|
99
|
+
*/
|
|
100
|
+
export const updateFeed = (options) => (options.client ?? client).put({
|
|
101
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
102
|
+
url: '/api/v1/feeds/{feed}',
|
|
103
|
+
...options,
|
|
104
|
+
headers: {
|
|
105
|
+
'Content-Type': 'application/json',
|
|
106
|
+
...options.headers
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* Remove a feed's password
|
|
111
|
+
*
|
|
112
|
+
* Needs the current password in `X-Feed-Password`. The feed stays, open to anyone who knows its name. An open feed answers 409.
|
|
113
|
+
*/
|
|
114
|
+
export const removeFeedPassword = (options) => (options.client ?? client).delete({
|
|
115
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
116
|
+
url: '/api/v1/feeds/{feed}/password',
|
|
117
|
+
...options
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* Change a feed's password
|
|
121
|
+
*
|
|
122
|
+
* Needs the current password in `X-Feed-Password`. A feed can only get a password when it is created, so an open feed answers 409.
|
|
123
|
+
*/
|
|
124
|
+
export const changeFeedPassword = (options) => (options.client ?? client).put({
|
|
125
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
126
|
+
url: '/api/v1/feeds/{feed}/password',
|
|
127
|
+
...options,
|
|
128
|
+
headers: {
|
|
129
|
+
'Content-Type': 'application/json',
|
|
130
|
+
...options.headers
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* Get a feed's title and description by its read id
|
|
135
|
+
*
|
|
136
|
+
* Public, even on an instance with a password, and never reveals the feed's name. An unknown read id has an empty title and description, so read ids can't be probed.
|
|
137
|
+
*/
|
|
138
|
+
export const getReadFeed = (options) => (options.client ?? client).get({ url: '/api/v1/read/{readId}', ...options });
|
|
35
139
|
/**
|
|
36
140
|
* List a feed's notes by its read id
|
|
37
141
|
*
|