notefeed 0.3.0 → 0.6.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.
Files changed (40) hide show
  1. package/README.md +9 -6
  2. package/dist/bin.js +6 -0
  3. package/dist/cli.js +42 -15
  4. package/dist/client.d.ts +52 -17
  5. package/dist/client.js +127 -53
  6. package/dist/generated/client/client.gen.d.ts +2 -0
  7. package/dist/generated/client/client.gen.js +216 -0
  8. package/dist/generated/client/index.d.ts +10 -0
  9. package/dist/generated/client/index.js +6 -0
  10. package/dist/generated/client/types.gen.d.ts +120 -0
  11. package/dist/generated/client/types.gen.js +2 -0
  12. package/dist/generated/client/utils.gen.d.ts +37 -0
  13. package/dist/generated/client/utils.gen.js +228 -0
  14. package/dist/generated/client.gen.d.ts +12 -0
  15. package/dist/generated/client.gen.js +3 -0
  16. package/dist/generated/core/auth.gen.d.ts +25 -0
  17. package/dist/generated/core/auth.gen.js +14 -0
  18. package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
  19. package/dist/generated/core/bodySerializer.gen.js +57 -0
  20. package/dist/generated/core/params.gen.d.ts +43 -0
  21. package/dist/generated/core/params.gen.js +109 -0
  22. package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
  23. package/dist/generated/core/pathSerializer.gen.js +106 -0
  24. package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
  25. package/dist/generated/core/queryKeySerializer.gen.js +92 -0
  26. package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
  27. package/dist/generated/core/serverSentEvents.gen.js +132 -0
  28. package/dist/generated/core/types.gen.d.ts +83 -0
  29. package/dist/generated/core/types.gen.js +2 -0
  30. package/dist/generated/core/utils.gen.d.ts +19 -0
  31. package/dist/generated/core/utils.gen.js +87 -0
  32. package/dist/generated/index.d.ts +2 -0
  33. package/dist/generated/index.js +2 -0
  34. package/dist/generated/sdk.gen.d.ts +49 -0
  35. package/dist/generated/sdk.gen.js +52 -0
  36. package/dist/generated/types.gen.d.ts +276 -0
  37. package/dist/generated/types.gen.js +2 -0
  38. package/dist/index.d.ts +2 -2
  39. package/dist/index.js +1 -1
  40. package/package.json +3 -3
@@ -0,0 +1,87 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from './pathSerializer.gen.js';
3
+ export const PATH_PARAM_RE = /\{[^{}]+\}/g;
4
+ export const defaultPathSerializer = ({ path, url: _url }) => {
5
+ let url = _url;
6
+ const matches = _url.match(PATH_PARAM_RE);
7
+ if (matches) {
8
+ for (const match of matches) {
9
+ let explode = false;
10
+ let name = match.substring(1, match.length - 1);
11
+ let style = 'simple';
12
+ if (name.endsWith('*')) {
13
+ explode = true;
14
+ name = name.substring(0, name.length - 1);
15
+ }
16
+ if (name.startsWith('.')) {
17
+ name = name.substring(1);
18
+ style = 'label';
19
+ }
20
+ else if (name.startsWith(';')) {
21
+ name = name.substring(1);
22
+ style = 'matrix';
23
+ }
24
+ const value = path[name];
25
+ if (value === undefined || value === null) {
26
+ continue;
27
+ }
28
+ if (Array.isArray(value)) {
29
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
30
+ continue;
31
+ }
32
+ if (typeof value === 'object') {
33
+ url = url.replace(match, serializeObjectParam({
34
+ explode,
35
+ name,
36
+ style,
37
+ value: value,
38
+ valueOnly: true,
39
+ }));
40
+ continue;
41
+ }
42
+ if (style === 'matrix') {
43
+ url = url.replace(match, `;${serializePrimitiveParam({
44
+ name,
45
+ value: value,
46
+ })}`);
47
+ continue;
48
+ }
49
+ const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
50
+ url = url.replace(match, replaceValue);
51
+ }
52
+ }
53
+ return url;
54
+ };
55
+ export const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
56
+ const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
57
+ let url = (baseUrl ?? '') + pathUrl;
58
+ if (path) {
59
+ url = defaultPathSerializer({ path, url });
60
+ }
61
+ let search = query ? querySerializer(query) : '';
62
+ if (search.startsWith('?')) {
63
+ search = search.substring(1);
64
+ }
65
+ if (search) {
66
+ url += `?${search}`;
67
+ }
68
+ return url;
69
+ };
70
+ export function getValidRequestBody(options) {
71
+ const hasBody = options.body !== undefined;
72
+ const isSerializedBody = hasBody && options.bodySerializer;
73
+ if (isSerializedBody) {
74
+ if ('serializedBody' in options) {
75
+ const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== '';
76
+ return hasSerializedBody ? options.serializedBody : null;
77
+ }
78
+ // not all clients implement a serializedBody property (i.e., client-axios)
79
+ return options.body !== '' ? options.body : null;
80
+ }
81
+ // plain/text body
82
+ if (hasBody) {
83
+ return options.body;
84
+ }
85
+ // no body was provided
86
+ return undefined;
87
+ }
@@ -0,0 +1,2 @@
1
+ export { getNote, getOpenApi, getReadNote, listNotes, listReadNotes, type Options, postNote } from './sdk.gen.js';
2
+ export type { ClientOptions, Created, Error, GetNoteData, GetNoteError, GetNoteErrors, GetNoteResponse, GetNoteResponses, GetOpenApiData, GetOpenApiResponse, GetOpenApiResponses, GetReadNoteData, GetReadNoteError, GetReadNoteErrors, GetReadNoteResponse, GetReadNoteResponses, ListNotesData, ListNotesError, ListNotesErrors, ListNotesResponse, ListNotesResponses, ListReadNotesData, ListReadNotesError, ListReadNotesErrors, ListReadNotesResponse, ListReadNotesResponses, Note, NoteList, PostForm, PostJson, PostNoteData, PostNoteError, PostNoteErrors, PostNoteResponse, PostNoteResponses } from './types.gen.js';
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export { getNote, getOpenApi, getReadNote, listNotes, listReadNotes, postNote } from './sdk.gen.js';
@@ -0,0 +1,49 @@
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';
3
+ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
4
+ /**
5
+ * You can provide a client instance returned by `createClient()` instead of
6
+ * individual options. This might be also useful if you want to implement a
7
+ * custom client.
8
+ */
9
+ client?: Client;
10
+ /**
11
+ * You can pass arbitrary values through the `meta` object. This can be
12
+ * used to access values that aren't defined as part of the SDK function.
13
+ */
14
+ meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
15
+ };
16
+ /**
17
+ * List a feed's notes
18
+ *
19
+ * Newest first. A feed with no notes (or that doesn't exist yet) is an empty list.
20
+ */
21
+ export declare const listNotes: <ThrowOnError extends boolean = false>(options: Options<ListNotesData, ThrowOnError>) => RequestResult<ListNotesResponses, ListNotesErrors, ThrowOnError>;
22
+ /**
23
+ * Post a note
24
+ *
25
+ * Creates the feed with its first note. Also served at `POST /{feed}`, the short form the client packages and curl one-liners use. The body is at most 102400 bytes and must be UTF-8. `application/x-www-form-urlencoded` (what `curl -d` sends) is read as raw markdown, not as form fields.
26
+ */
27
+ export declare const postNote: <ThrowOnError extends boolean = false>(options: Options<PostNoteData, ThrowOnError>) => RequestResult<PostNoteResponses, PostNoteErrors, ThrowOnError>;
28
+ /**
29
+ * Get one note
30
+ */
31
+ export declare const getNote: <ThrowOnError extends boolean = false>(options: Options<GetNoteData, ThrowOnError>) => RequestResult<GetNoteResponses, GetNoteErrors, ThrowOnError>;
32
+ /**
33
+ * List a feed's notes by its read id
34
+ *
35
+ * Public, even on an instance with a password, and never reveals the feed's name. An unknown read id is an empty list, so read ids can't be probed. The same notes as the read link's RSS.
36
+ */
37
+ export declare const listReadNotes: <ThrowOnError extends boolean = false>(options: Options<ListReadNotesData, ThrowOnError>) => RequestResult<ListReadNotesResponses, ListReadNotesErrors, ThrowOnError>;
38
+ /**
39
+ * Get one note by its feed's read id
40
+ *
41
+ * Public, like the read link.
42
+ */
43
+ export declare const getReadNote: <ThrowOnError extends boolean = false>(options: Options<GetReadNoteData, ThrowOnError>) => RequestResult<GetReadNoteResponses, GetReadNoteErrors, ThrowOnError>;
44
+ /**
45
+ * This API's OpenAPI document
46
+ *
47
+ * Generated from the server's route table, with `servers` set to this instance's URL.
48
+ */
49
+ export declare const getOpenApi: <ThrowOnError extends boolean = false>(options?: Options<GetOpenApiData, ThrowOnError>) => RequestResult<GetOpenApiResponses, unknown, ThrowOnError>;
@@ -0,0 +1,52 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { client } from './client.gen.js';
3
+ /**
4
+ * List a feed's notes
5
+ *
6
+ * Newest first. A feed with no notes (or that doesn't exist yet) is an empty list.
7
+ */
8
+ export const listNotes = (options) => (options.client ?? client).get({
9
+ security: [{ scheme: 'bearer', type: 'http' }],
10
+ url: '/api/v1/feeds/{feed}/notes',
11
+ ...options
12
+ });
13
+ /**
14
+ * Post a note
15
+ *
16
+ * Creates the feed with its first note. Also served at `POST /{feed}`, the short form the client packages and curl one-liners use. The body is at most 102400 bytes and must be UTF-8. `application/x-www-form-urlencoded` (what `curl -d` sends) is read as raw markdown, not as form fields.
17
+ */
18
+ export const postNote = (options) => (options.client ?? client).post({
19
+ security: [{ scheme: 'bearer', type: 'http' }],
20
+ url: '/api/v1/feeds/{feed}/notes',
21
+ ...options,
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ ...options.headers
25
+ }
26
+ });
27
+ /**
28
+ * Get one note
29
+ */
30
+ export const getNote = (options) => (options.client ?? client).get({
31
+ security: [{ scheme: 'bearer', type: 'http' }],
32
+ url: '/api/v1/feeds/{feed}/notes/{id}',
33
+ ...options
34
+ });
35
+ /**
36
+ * List a feed's notes by its read id
37
+ *
38
+ * Public, even on an instance with a password, and never reveals the feed's name. An unknown read id is an empty list, so read ids can't be probed. The same notes as the read link's RSS.
39
+ */
40
+ export const listReadNotes = (options) => (options.client ?? client).get({ url: '/api/v1/read/{readId}/notes', ...options });
41
+ /**
42
+ * Get one note by its feed's read id
43
+ *
44
+ * Public, like the read link.
45
+ */
46
+ export const getReadNote = (options) => (options.client ?? client).get({ url: '/api/v1/read/{readId}/notes/{id}', ...options });
47
+ /**
48
+ * This API's OpenAPI document
49
+ *
50
+ * Generated from the server's route table, with `servers` set to this instance's URL.
51
+ */
52
+ export const getOpenApi = (options) => (options?.client ?? client).get({ url: '/api/v1/openapi.json', ...options });
@@ -0,0 +1,276 @@
1
+ export type ClientOptions = {
2
+ baseUrl: 'https://notefeed.me' | (string & {});
3
+ };
4
+ export type Note = {
5
+ /**
6
+ * UTC time to the second plus a slug of the title
7
+ */
8
+ id: string;
9
+ /**
10
+ * The first heading, or the first non-empty line; may be empty
11
+ */
12
+ title: string;
13
+ /**
14
+ * The note, byte-for-byte as posted
15
+ */
16
+ markdown: string;
17
+ /**
18
+ * When the note was posted (UTC)
19
+ */
20
+ created_at: string;
21
+ /**
22
+ * The note's page in the web UI
23
+ */
24
+ url: string;
25
+ };
26
+ export type NoteList = {
27
+ /**
28
+ * Newest first
29
+ */
30
+ notes: Array<Note>;
31
+ /**
32
+ * Pass as `before` for the next (older) page; null on the last page
33
+ */
34
+ next: string | null;
35
+ };
36
+ export type Created = {
37
+ id: string;
38
+ /**
39
+ * The note's page in the web UI
40
+ */
41
+ url: string;
42
+ /**
43
+ * The feed's page in the web UI
44
+ */
45
+ feed_url: string;
46
+ /**
47
+ * The feed's read-only RSS link, safe to share
48
+ */
49
+ read_url: string;
50
+ };
51
+ export type Error = {
52
+ /**
53
+ * A short reason, for people
54
+ */
55
+ error: string;
56
+ /**
57
+ * Stable machine-readable code; absent only on a 500
58
+ */
59
+ code?: 'invalid_feed' | 'reserved_feed' | 'auth' | 'rate_limited' | 'too_many_attempts' | 'feed_limit' | 'note_limit' | 'empty_note' | 'too_large' | 'unsupported_type' | 'invalid_body' | 'invalid_request' | 'not_found';
60
+ };
61
+ export type PostJson = {
62
+ markdown: string;
63
+ };
64
+ export type PostForm = {
65
+ markdown: string;
66
+ };
67
+ export type ListNotesData = {
68
+ body?: never;
69
+ path: {
70
+ /**
71
+ * The feed's name. It is the write key: anyone who knows it can post.
72
+ */
73
+ feed: string;
74
+ };
75
+ query?: {
76
+ /**
77
+ * Notes per page, 1–100
78
+ */
79
+ limit?: number;
80
+ /**
81
+ * Only notes older than this id: the previous page's `next`
82
+ */
83
+ before?: string;
84
+ };
85
+ url: '/api/v1/feeds/{feed}/notes';
86
+ };
87
+ export type ListNotesErrors = {
88
+ /**
89
+ * Invalid or reserved feed name, or a bad `limit` / `before`
90
+ */
91
+ 400: Error;
92
+ /**
93
+ * The instance has a password and it is missing or wrong
94
+ */
95
+ 401: Error;
96
+ /**
97
+ * Too many wrong passwords from this client
98
+ */
99
+ 429: Error;
100
+ };
101
+ export type ListNotesError = ListNotesErrors[keyof ListNotesErrors];
102
+ export type ListNotesResponses = {
103
+ /**
104
+ * A page of notes
105
+ */
106
+ 200: NoteList;
107
+ };
108
+ export type ListNotesResponse = ListNotesResponses[keyof ListNotesResponses];
109
+ export type PostNoteData = {
110
+ body: PostJson;
111
+ path: {
112
+ /**
113
+ * The feed's name. It is the write key: anyone who knows it can post.
114
+ */
115
+ feed: string;
116
+ };
117
+ query?: never;
118
+ url: '/api/v1/feeds/{feed}/notes';
119
+ };
120
+ export type PostNoteErrors = {
121
+ /**
122
+ * Invalid or reserved feed name; empty note; bad JSON, form or UTF-8
123
+ */
124
+ 400: Error;
125
+ /**
126
+ * The instance has a password and it is missing or wrong
127
+ */
128
+ 401: Error;
129
+ /**
130
+ * Body over 102400 bytes
131
+ */
132
+ 413: Error;
133
+ /**
134
+ * Unsupported content type
135
+ */
136
+ 415: Error;
137
+ /**
138
+ * Too many posts, or wrong passwords, from this client
139
+ */
140
+ 429: Error;
141
+ /**
142
+ * NOTEFEED_MAX_FEEDS or NOTEFEED_MAX_NOTES_PER_FEED reached
143
+ */
144
+ 507: Error;
145
+ };
146
+ export type PostNoteError = PostNoteErrors[keyof PostNoteErrors];
147
+ export type PostNoteResponses = {
148
+ /**
149
+ * Stored
150
+ */
151
+ 201: Created;
152
+ };
153
+ export type PostNoteResponse = PostNoteResponses[keyof PostNoteResponses];
154
+ export type GetNoteData = {
155
+ body?: never;
156
+ path: {
157
+ /**
158
+ * The feed's name. It is the write key: anyone who knows it can post.
159
+ */
160
+ feed: string;
161
+ /**
162
+ * The note's id
163
+ */
164
+ id: string;
165
+ };
166
+ query?: never;
167
+ url: '/api/v1/feeds/{feed}/notes/{id}';
168
+ };
169
+ export type GetNoteErrors = {
170
+ /**
171
+ * Invalid or reserved feed name
172
+ */
173
+ 400: Error;
174
+ /**
175
+ * The instance has a password and it is missing or wrong
176
+ */
177
+ 401: Error;
178
+ /**
179
+ * No such note
180
+ */
181
+ 404: Error;
182
+ /**
183
+ * Too many wrong passwords from this client
184
+ */
185
+ 429: Error;
186
+ };
187
+ export type GetNoteError = GetNoteErrors[keyof GetNoteErrors];
188
+ export type GetNoteResponses = {
189
+ /**
190
+ * The note
191
+ */
192
+ 200: Note;
193
+ };
194
+ export type GetNoteResponse = GetNoteResponses[keyof GetNoteResponses];
195
+ export type ListReadNotesData = {
196
+ body?: never;
197
+ path: {
198
+ /**
199
+ * The feed's read id, from its read link. Read-only; never reveals the name.
200
+ */
201
+ readId: string;
202
+ };
203
+ query?: {
204
+ /**
205
+ * Notes per page, 1–100
206
+ */
207
+ limit?: number;
208
+ /**
209
+ * Only notes older than this id: the previous page's `next`
210
+ */
211
+ before?: string;
212
+ };
213
+ url: '/api/v1/read/{readId}/notes';
214
+ };
215
+ export type ListReadNotesErrors = {
216
+ /**
217
+ * A bad `limit` / `before`
218
+ */
219
+ 400: Error;
220
+ /**
221
+ * Malformed read id
222
+ */
223
+ 404: Error;
224
+ };
225
+ export type ListReadNotesError = ListReadNotesErrors[keyof ListReadNotesErrors];
226
+ export type ListReadNotesResponses = {
227
+ /**
228
+ * A page of notes
229
+ */
230
+ 200: NoteList;
231
+ };
232
+ export type ListReadNotesResponse = ListReadNotesResponses[keyof ListReadNotesResponses];
233
+ export type GetReadNoteData = {
234
+ body?: never;
235
+ path: {
236
+ /**
237
+ * The feed's read id, from its read link. Read-only; never reveals the name.
238
+ */
239
+ readId: string;
240
+ /**
241
+ * The note's id
242
+ */
243
+ id: string;
244
+ };
245
+ query?: never;
246
+ url: '/api/v1/read/{readId}/notes/{id}';
247
+ };
248
+ export type GetReadNoteErrors = {
249
+ /**
250
+ * No such note, or a malformed or unknown read id
251
+ */
252
+ 404: Error;
253
+ };
254
+ export type GetReadNoteError = GetReadNoteErrors[keyof GetReadNoteErrors];
255
+ export type GetReadNoteResponses = {
256
+ /**
257
+ * The note
258
+ */
259
+ 200: Note;
260
+ };
261
+ export type GetReadNoteResponse = GetReadNoteResponses[keyof GetReadNoteResponses];
262
+ export type GetOpenApiData = {
263
+ body?: never;
264
+ path?: never;
265
+ query?: never;
266
+ url: '/api/v1/openapi.json';
267
+ };
268
+ export type GetOpenApiResponses = {
269
+ /**
270
+ * OpenAPI 3.1
271
+ */
272
+ 200: {
273
+ [key: string]: unknown;
274
+ };
275
+ };
276
+ export type GetOpenApiResponse = GetOpenApiResponses[keyof GetOpenApiResponses];
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { AuthError, Client, ConfigError, InvalidNoteError, NotefeedError, NoteTooLargeError } from "./client.js";
2
- export type { ClientOptions, Note } from "./client.js";
1
+ export { AuthError, Client, ConfigError, InvalidRequestError, LimitReachedError, NotefeedError, NotFoundError, NoteTooLargeError, RateLimitedError, } from "./client.js";
2
+ export type { ClientOptions, Created, ErrorCode, Note } from "./client.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { AuthError, Client, ConfigError, InvalidNoteError, NotefeedError, NoteTooLargeError } from "./client.js";
1
+ export { AuthError, Client, ConfigError, InvalidRequestError, LimitReachedError, NotefeedError, NotFoundError, NoteTooLargeError, RateLimitedError, } from "./client.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notefeed",
3
- "version": "0.3.0",
3
+ "version": "0.6.0",
4
4
  "description": "Client and CLI for notefeed, a self-hosted inbox for markdown notes that you read back as RSS.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Marcel Bruckner",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsc",
34
- "test": "vitest run",
34
+ "test": "tsc && vitest run",
35
35
  "prepublishOnly": "npm run build"
36
36
  },
37
37
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "url": "git+https://github.com/Marceltov/notefeed.git",
40
40
  "directory": "packages/js"
41
41
  },
42
- "homepage": "https://notefeed.me/clients/",
42
+ "homepage": "https://docs.notefeed.me/clients/",
43
43
  "bugs": {
44
44
  "url": "https://github.com/Marceltov/notefeed/issues"
45
45
  },