pubky-app-specs 0.4.3 → 0.5.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/LICENSE +21 -0
- package/README.md +170 -297
- package/package.json +7 -40
- package/pubky_app_specs.d.ts +448 -359
- package/{index.cjs → pubky_app_specs.js} +1844 -1895
- package/pubky_app_specs_bg.wasm +0 -0
- package/example.js +0 -295
- package/index.js +0 -2990
package/pubky_app_specs.d.ts
CHANGED
|
@@ -1,194 +1,71 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Builds an User URI of the form "pubky://<user_pubky_id>/pub/pubky.app/profile.json"
|
|
6
|
-
*/
|
|
7
|
-
export function userUriBuilder(user_id: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Builds a Post URI of the form "pubky://<author_id>/pub/pubky.app/posts/<post_id>"
|
|
10
|
-
*/
|
|
11
|
-
export function postUriBuilder(author_id: string, post_id: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Builds a Follow URI of the form "pubky://<author_id>/pub/pubky.app/follows/<follow_id>"
|
|
14
|
-
*/
|
|
15
|
-
export function followUriBuilder(author_id: string, follow_id: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Builds a Mute URI of the form "pubky://<author_id>/pub/pubky.app/mutes/<mute_id>"
|
|
18
|
-
*/
|
|
19
|
-
export function muteUriBuilder(author_id: string, mute_id: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Builds a Bookmark URI of the form "pubky://<author_id>/pub/pubky.app/bookmarks/<bookmark_id>"
|
|
22
|
-
*/
|
|
23
|
-
export function bookmarkUriBuilder(author_id: string, bookmark_id: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Builds a Tag URI of the form "pubky://<author_id>/pub/pubky.app/tags/<tag_id>"
|
|
26
|
-
*/
|
|
27
|
-
export function tagUriBuilder(author_id: string, tag_id: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* Builds a File URI of the form "pubky://<author_id>/pub/pubky.app/files/<file_id>"
|
|
30
|
-
*/
|
|
31
|
-
export function fileUriBuilder(author_id: string, file_id: string): string;
|
|
32
|
-
/**
|
|
33
|
-
* Builds a Blob URI of the form "pubky://<author_id>/pub/pubky.app/blobs/<blob_id>"
|
|
34
|
-
*/
|
|
35
|
-
export function blobUriBuilder(author_id: string, blob_id: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* Builds a Feed URI of the form "pubky://<author_id>/pub/pubky.app/feeds/<feed_id>"
|
|
38
|
-
*/
|
|
39
|
-
export function feedUriBuilder(author_id: string, feed_id: string): string;
|
|
40
|
-
/**
|
|
41
|
-
* Builds a LastRead URI of the form "pubky://<author_id>/pub/pubky.app/last_read"
|
|
42
|
-
*/
|
|
43
|
-
export function lastReadUriBuilder(author_id: string): string;
|
|
44
|
-
/**
|
|
45
|
-
* Returns the list of valid MIME types for file attachments.
|
|
46
|
-
*
|
|
47
|
-
* This allows JavaScript consumers to validate file types before submission
|
|
48
|
-
* without having to duplicate the list.
|
|
49
|
-
*
|
|
50
|
-
* # Example (TypeScript)
|
|
51
|
-
*
|
|
52
|
-
* ```typescript
|
|
53
|
-
* import { get_valid_mime_types } from "pubky-app-specs";
|
|
54
|
-
*
|
|
55
|
-
* const validTypes = get_valid_mime_types();
|
|
56
|
-
* const fileType = "image/png";
|
|
57
|
-
* if (validTypes.includes(fileType)) {
|
|
58
|
-
* console.log("Valid file type!");
|
|
59
|
-
* }
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
export function getValidMimeTypes(): any[];
|
|
63
|
-
/**
|
|
64
|
-
* Parses a Pubky URI and returns a strongly typed `ParsedUriResult`.
|
|
65
|
-
*
|
|
66
|
-
* This function wraps the internal ParsedUri ust parsing logic. It converts the result into a
|
|
67
|
-
* strongly typed object that is easier to use in TypeScript.
|
|
68
|
-
*
|
|
69
|
-
* # Parameters
|
|
70
|
-
*
|
|
71
|
-
* - `uri`: A string slice representing the Pubky URI. The URI should follow the format:
|
|
72
|
-
* `pubky://<user_id>/pub/pubky.app/<resource>[/<id>]`.
|
|
73
|
-
*
|
|
74
|
-
* # Returns
|
|
75
|
-
*
|
|
76
|
-
* On success, returns a `ParsedUriResult` with:
|
|
77
|
-
* - `user_id`: the parsed user ID,
|
|
78
|
-
* - `resource`: a string (derived from the Display implementation of internal `Resource` enum),
|
|
79
|
-
* - `resource_id`: an optional resource identifier (if applicable).
|
|
80
|
-
*
|
|
81
|
-
* On failure, returns a JavaScript error (`String`) containing an error message.
|
|
82
|
-
*
|
|
83
|
-
* # Example (TypeScript)
|
|
84
|
-
*
|
|
85
|
-
* ```typescript
|
|
86
|
-
* import { parse_uri } from "pubky-app-specs";
|
|
87
|
-
*
|
|
88
|
-
* try {
|
|
89
|
-
* const result = parse_uri("pubky://user123/pub/pubky.app/posts/abc123");
|
|
90
|
-
* console.log(result.user_id); // e.g. "user123"
|
|
91
|
-
* console.log(result.resource); // e.g. "posts"
|
|
92
|
-
* console.log(result.resource_id); // e.g. "abc123" or null
|
|
93
|
-
* } catch (error) {
|
|
94
|
-
* console.error("Error parsing URI:", error);
|
|
95
|
-
* }
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export function parse_uri(uri: string): ParsedUriResult;
|
|
99
|
-
/**
|
|
100
|
-
* Enum representing the layout of the feed.
|
|
101
|
-
*/
|
|
102
|
-
export enum PubkyAppFeedLayout {
|
|
103
|
-
Columns = 0,
|
|
104
|
-
Wide = 1,
|
|
105
|
-
Visual = 2,
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Enum representing the reach of the feed.
|
|
109
|
-
*/
|
|
110
|
-
export enum PubkyAppFeedReach {
|
|
111
|
-
Following = 0,
|
|
112
|
-
Followers = 1,
|
|
113
|
-
Friends = 2,
|
|
114
|
-
All = 3,
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Enum representing the sort order of the feed.
|
|
118
|
-
*/
|
|
119
|
-
export enum PubkyAppFeedSort {
|
|
120
|
-
Recent = 0,
|
|
121
|
-
Popularity = 1,
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Represents the type of pubky-app posted data
|
|
125
|
-
* Used primarily to best display the content in UI
|
|
126
|
-
*/
|
|
127
|
-
export enum PubkyAppPostKind {
|
|
128
|
-
Short = 0,
|
|
129
|
-
Long = 1,
|
|
130
|
-
Image = 2,
|
|
131
|
-
Video = 3,
|
|
132
|
-
Link = 4,
|
|
133
|
-
File = 5,
|
|
134
|
-
}
|
|
3
|
+
|
|
135
4
|
export class BlobResult {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
5
|
+
private constructor();
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
readonly blob: PubkyAppBlob;
|
|
9
|
+
readonly meta: Meta;
|
|
140
10
|
}
|
|
11
|
+
|
|
141
12
|
export class BookmarkResult {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
13
|
+
private constructor();
|
|
14
|
+
free(): void;
|
|
15
|
+
[Symbol.dispose](): void;
|
|
16
|
+
readonly bookmark: PubkyAppBookmark;
|
|
17
|
+
readonly meta: Meta;
|
|
146
18
|
}
|
|
19
|
+
|
|
147
20
|
export class FeedResult {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
21
|
+
private constructor();
|
|
22
|
+
free(): void;
|
|
23
|
+
[Symbol.dispose](): void;
|
|
24
|
+
readonly feed: PubkyAppFeed;
|
|
25
|
+
readonly meta: Meta;
|
|
152
26
|
}
|
|
27
|
+
|
|
153
28
|
export class FileResult {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
29
|
+
private constructor();
|
|
30
|
+
free(): void;
|
|
31
|
+
[Symbol.dispose](): void;
|
|
32
|
+
readonly file: PubkyAppFile;
|
|
33
|
+
readonly meta: Meta;
|
|
158
34
|
}
|
|
35
|
+
|
|
159
36
|
export class FollowResult {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
37
|
+
private constructor();
|
|
38
|
+
free(): void;
|
|
39
|
+
[Symbol.dispose](): void;
|
|
40
|
+
readonly follow: PubkyAppFollow;
|
|
41
|
+
readonly meta: Meta;
|
|
164
42
|
}
|
|
43
|
+
|
|
165
44
|
export class LastReadResult {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
45
|
+
private constructor();
|
|
46
|
+
free(): void;
|
|
47
|
+
[Symbol.dispose](): void;
|
|
48
|
+
readonly last_read: PubkyAppLastRead;
|
|
49
|
+
readonly meta: Meta;
|
|
170
50
|
}
|
|
171
|
-
|
|
172
|
-
* Each FFI function:
|
|
173
|
-
* - Accepts minimal fields in a JavaScript-friendly manner (e.g. strings, JSON).
|
|
174
|
-
* - Creates the Rust model, sanitizes, and validates it.
|
|
175
|
-
* - Generates the ID (if applicable).
|
|
176
|
-
* - Generates the path (if applicable).
|
|
177
|
-
* - Returns { json, id, path, url } or a descriptive error.
|
|
178
|
-
*/
|
|
51
|
+
|
|
179
52
|
export class Meta {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
53
|
+
private constructor();
|
|
54
|
+
free(): void;
|
|
55
|
+
[Symbol.dispose](): void;
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly path: string;
|
|
58
|
+
readonly url: string;
|
|
185
59
|
}
|
|
60
|
+
|
|
186
61
|
export class MuteResult {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
62
|
+
private constructor();
|
|
63
|
+
free(): void;
|
|
64
|
+
[Symbol.dispose](): void;
|
|
65
|
+
readonly meta: Meta;
|
|
66
|
+
readonly mute: PubkyAppMute;
|
|
191
67
|
}
|
|
68
|
+
|
|
192
69
|
/**
|
|
193
70
|
* This object represents the result of parsing a Pubky URI. It contains:
|
|
194
71
|
* - `user_id`: the parsed user ID as a string.
|
|
@@ -196,41 +73,47 @@ export class MuteResult {
|
|
|
196
73
|
* - `resource_id`: an optional resource identifier (if applicable).
|
|
197
74
|
*/
|
|
198
75
|
export class ParsedUriResult {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
76
|
+
private constructor();
|
|
77
|
+
free(): void;
|
|
78
|
+
[Symbol.dispose](): void;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the resource kind.
|
|
81
|
+
*/
|
|
82
|
+
readonly resource: string;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the resource ID if present.
|
|
85
|
+
*/
|
|
86
|
+
readonly resource_id: string | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the user ID.
|
|
89
|
+
*/
|
|
90
|
+
readonly user_id: string;
|
|
213
91
|
}
|
|
92
|
+
|
|
214
93
|
export class PostResult {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
94
|
+
private constructor();
|
|
95
|
+
free(): void;
|
|
96
|
+
[Symbol.dispose](): void;
|
|
97
|
+
readonly meta: Meta;
|
|
98
|
+
readonly post: PubkyAppPost;
|
|
219
99
|
}
|
|
100
|
+
|
|
220
101
|
/**
|
|
221
102
|
* Represents a blob, which backs a file uploaded by the user.
|
|
222
103
|
* URI: /pub/pubky.app/blobs/:blob_id
|
|
223
104
|
*/
|
|
224
105
|
export class PubkyAppBlob {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
106
|
+
private constructor();
|
|
107
|
+
free(): void;
|
|
108
|
+
[Symbol.dispose](): void;
|
|
109
|
+
static fromJson(js_value: any): PubkyAppBlob;
|
|
110
|
+
toJson(): any;
|
|
111
|
+
/**
|
|
112
|
+
* Getter for the blob data as a `Uint8Array`.
|
|
113
|
+
*/
|
|
114
|
+
readonly data: Uint8Array;
|
|
233
115
|
}
|
|
116
|
+
|
|
234
117
|
/**
|
|
235
118
|
* Represents raw homeserver bookmark with id
|
|
236
119
|
* URI: /pub/pubky.app/bookmarks/:bookmark_id
|
|
@@ -242,84 +125,119 @@ export class PubkyAppBlob {
|
|
|
242
125
|
* Where bookmark_id is Crockford-base32(Blake3("{uri_bookmarked}"")[:half])
|
|
243
126
|
*/
|
|
244
127
|
export class PubkyAppBookmark {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
128
|
+
private constructor();
|
|
129
|
+
free(): void;
|
|
130
|
+
[Symbol.dispose](): void;
|
|
131
|
+
/**
|
|
132
|
+
* Serialize to JSON for WASM.
|
|
133
|
+
*/
|
|
134
|
+
static fromJson(js_value: any): PubkyAppBookmark;
|
|
135
|
+
toJson(): any;
|
|
136
|
+
created_at: bigint;
|
|
137
|
+
/**
|
|
138
|
+
* Getter for `uri`.
|
|
139
|
+
*/
|
|
140
|
+
readonly uri: string;
|
|
257
141
|
}
|
|
142
|
+
|
|
258
143
|
/**
|
|
259
144
|
* Represents a feed configuration.
|
|
260
145
|
*/
|
|
261
146
|
export class PubkyAppFeed {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
147
|
+
private constructor();
|
|
148
|
+
free(): void;
|
|
149
|
+
[Symbol.dispose](): void;
|
|
150
|
+
/**
|
|
151
|
+
* Serialize to JSON for WASM.
|
|
152
|
+
*/
|
|
153
|
+
static fromJson(js_value: any): PubkyAppFeed;
|
|
154
|
+
toJson(): any;
|
|
155
|
+
created_at: bigint;
|
|
156
|
+
/**
|
|
157
|
+
* Getter for `feed`.
|
|
158
|
+
*/
|
|
159
|
+
readonly feed: PubkyAppFeedConfig;
|
|
160
|
+
/**
|
|
161
|
+
* Getter for `name`.
|
|
162
|
+
*/
|
|
163
|
+
readonly name: string;
|
|
278
164
|
}
|
|
165
|
+
|
|
279
166
|
/**
|
|
280
167
|
* Configuration object for the feed.
|
|
281
168
|
*/
|
|
282
169
|
export class PubkyAppFeedConfig {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
170
|
+
private constructor();
|
|
171
|
+
free(): void;
|
|
172
|
+
[Symbol.dispose](): void;
|
|
173
|
+
static fromJson(js_value: any): PubkyAppFeedConfig;
|
|
174
|
+
toJson(): any;
|
|
175
|
+
/**
|
|
176
|
+
* Getter for `content`.
|
|
177
|
+
*/
|
|
178
|
+
readonly content: PubkyAppPostKind | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* Getter for `layout`.
|
|
181
|
+
*/
|
|
182
|
+
readonly layout: PubkyAppFeedLayout;
|
|
183
|
+
/**
|
|
184
|
+
* Getter for `name`.
|
|
185
|
+
*/
|
|
186
|
+
readonly reach: PubkyAppFeedReach;
|
|
187
|
+
/**
|
|
188
|
+
* Getter for `sort`.
|
|
189
|
+
*/
|
|
190
|
+
readonly sort: PubkyAppFeedSort;
|
|
191
|
+
/**
|
|
192
|
+
* Getter for `tags`.
|
|
193
|
+
*/
|
|
194
|
+
readonly tags: string[] | undefined;
|
|
307
195
|
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Enum representing the layout of the feed.
|
|
199
|
+
*/
|
|
200
|
+
export enum PubkyAppFeedLayout {
|
|
201
|
+
Columns = 0,
|
|
202
|
+
Wide = 1,
|
|
203
|
+
Visual = 2,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Enum representing the reach of the feed.
|
|
208
|
+
*/
|
|
209
|
+
export enum PubkyAppFeedReach {
|
|
210
|
+
Following = 0,
|
|
211
|
+
Followers = 1,
|
|
212
|
+
Friends = 2,
|
|
213
|
+
All = 3,
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Enum representing the sort order of the feed.
|
|
218
|
+
*/
|
|
219
|
+
export enum PubkyAppFeedSort {
|
|
220
|
+
Recent = 0,
|
|
221
|
+
Popularity = 1,
|
|
222
|
+
}
|
|
223
|
+
|
|
308
224
|
/**
|
|
309
225
|
* Represents a file uploaded by the user.
|
|
310
226
|
* URI: /pub/pubky.app/files/:file_id
|
|
311
227
|
*/
|
|
312
228
|
export class PubkyAppFile {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
229
|
+
private constructor();
|
|
230
|
+
free(): void;
|
|
231
|
+
[Symbol.dispose](): void;
|
|
232
|
+
static fromJson(js_value: any): PubkyAppFile;
|
|
233
|
+
toJson(): any;
|
|
234
|
+
created_at: bigint;
|
|
235
|
+
size: number;
|
|
236
|
+
readonly content_type: string;
|
|
237
|
+
readonly name: string;
|
|
238
|
+
readonly src: string;
|
|
322
239
|
}
|
|
240
|
+
|
|
323
241
|
/**
|
|
324
242
|
* Represents raw homeserver follow object with timestamp
|
|
325
243
|
*
|
|
@@ -332,23 +250,27 @@ export class PubkyAppFile {
|
|
|
332
250
|
* `/pub/pubky.app/follows/pxnu33x7jtpx9ar1ytsi4yxbp6a5o36gwhffs8zoxmbuptici1jy`
|
|
333
251
|
*/
|
|
334
252
|
export class PubkyAppFollow {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
253
|
+
private constructor();
|
|
254
|
+
free(): void;
|
|
255
|
+
[Symbol.dispose](): void;
|
|
256
|
+
static fromJson(js_value: any): PubkyAppFollow;
|
|
257
|
+
toJson(): any;
|
|
258
|
+
created_at: bigint;
|
|
340
259
|
}
|
|
260
|
+
|
|
341
261
|
/**
|
|
342
262
|
* Represents the last read timestamp for notifications.
|
|
343
263
|
* URI: /pub/pubky.app/last_read
|
|
344
264
|
*/
|
|
345
265
|
export class PubkyAppLastRead {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
266
|
+
private constructor();
|
|
267
|
+
free(): void;
|
|
268
|
+
[Symbol.dispose](): void;
|
|
269
|
+
static fromJson(js_value: any): PubkyAppLastRead;
|
|
270
|
+
toJson(): any;
|
|
271
|
+
timestamp: bigint;
|
|
351
272
|
}
|
|
273
|
+
|
|
352
274
|
/**
|
|
353
275
|
* Represents raw homeserver Mute object with timestamp
|
|
354
276
|
* URI: /pub/pubky.app/mutes/:user_id
|
|
@@ -358,12 +280,14 @@ export class PubkyAppLastRead {
|
|
|
358
280
|
* `/pub/pubky.app/mutes/pxnu33x7jtpx9ar1ytsi4yxbp6a5o36gwhffs8zoxmbuptici1jy`
|
|
359
281
|
*/
|
|
360
282
|
export class PubkyAppMute {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
283
|
+
private constructor();
|
|
284
|
+
free(): void;
|
|
285
|
+
[Symbol.dispose](): void;
|
|
286
|
+
static fromJson(js_value: any): PubkyAppMute;
|
|
287
|
+
toJson(): any;
|
|
288
|
+
created_at: bigint;
|
|
366
289
|
}
|
|
290
|
+
|
|
367
291
|
/**
|
|
368
292
|
* Represents raw post in homeserver with content and kind
|
|
369
293
|
* URI: /pub/pubky.app/posts/:post_id
|
|
@@ -374,28 +298,47 @@ export class PubkyAppMute {
|
|
|
374
298
|
* `/pub/pubky.app/posts/00321FCW75ZFY`
|
|
375
299
|
*/
|
|
376
300
|
export class PubkyAppPost {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
301
|
+
free(): void;
|
|
302
|
+
[Symbol.dispose](): void;
|
|
303
|
+
static fromJson(js_value: any): PubkyAppPost;
|
|
304
|
+
/**
|
|
305
|
+
* Creates a new `PubkyAppPost` instance and sanitizes it.
|
|
306
|
+
*/
|
|
307
|
+
constructor(content: string, kind: PubkyAppPostKind, parent?: string | null, embed?: PubkyAppPostEmbed | null, attachments?: string[] | null);
|
|
308
|
+
toJson(): any;
|
|
309
|
+
readonly attachments: string[] | undefined;
|
|
310
|
+
readonly content: string;
|
|
311
|
+
readonly embed: PubkyAppPostEmbed | undefined;
|
|
312
|
+
readonly kind: string;
|
|
313
|
+
readonly parent: string | undefined;
|
|
389
314
|
}
|
|
315
|
+
|
|
390
316
|
/**
|
|
391
317
|
* Represents embedded content within a post
|
|
392
318
|
*/
|
|
393
319
|
export class PubkyAppPostEmbed {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
320
|
+
free(): void;
|
|
321
|
+
[Symbol.dispose](): void;
|
|
322
|
+
constructor(uri: string, kind: PubkyAppPostKind);
|
|
323
|
+
readonly kind: string;
|
|
324
|
+
readonly uri: string;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Represents the type of pubky-app posted data
|
|
329
|
+
* Used primarily to best display the content in UI
|
|
330
|
+
*/
|
|
331
|
+
export enum PubkyAppPostKind {
|
|
332
|
+
Short = 0,
|
|
333
|
+
Long = 1,
|
|
334
|
+
Image = 2,
|
|
335
|
+
Video = 3,
|
|
336
|
+
Link = 4,
|
|
337
|
+
File = 5,
|
|
338
|
+
Collection = 6,
|
|
339
|
+
Unknown = 7,
|
|
398
340
|
}
|
|
341
|
+
|
|
399
342
|
/**
|
|
400
343
|
* Represents raw homeserver tag with id
|
|
401
344
|
* URI: /pub/pubky.app/tags/:tag_id
|
|
@@ -407,96 +350,242 @@ export class PubkyAppPostEmbed {
|
|
|
407
350
|
* Where tag_id is Crockford-base32(Blake3("{uri_tagged}:{label}")[:half])
|
|
408
351
|
*/
|
|
409
352
|
export class PubkyAppTag {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
353
|
+
private constructor();
|
|
354
|
+
free(): void;
|
|
355
|
+
[Symbol.dispose](): void;
|
|
356
|
+
static fromJson(js_value: any): PubkyAppTag;
|
|
357
|
+
/**
|
|
358
|
+
* Serialize to JSON for WASM.
|
|
359
|
+
*/
|
|
360
|
+
toJson(): any;
|
|
361
|
+
created_at: bigint;
|
|
362
|
+
/**
|
|
363
|
+
* Getter for `label`.
|
|
364
|
+
*/
|
|
365
|
+
readonly label: string;
|
|
366
|
+
/**
|
|
367
|
+
* Getter for `uri`.
|
|
368
|
+
*/
|
|
369
|
+
readonly uri: string;
|
|
426
370
|
}
|
|
371
|
+
|
|
427
372
|
/**
|
|
428
373
|
* URI: /pub/pubky.app/profile.json
|
|
429
374
|
*/
|
|
430
375
|
export class PubkyAppUser {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
376
|
+
free(): void;
|
|
377
|
+
[Symbol.dispose](): void;
|
|
378
|
+
static fromJson(js_value: any): PubkyAppUser;
|
|
379
|
+
/**
|
|
380
|
+
* Creates a new `PubkyAppUser` instance and sanitizes it.
|
|
381
|
+
*/
|
|
382
|
+
constructor(name: string, bio?: string | null, image?: string | null, links?: PubkyAppUserLink[] | null, status?: string | null);
|
|
383
|
+
toJson(): any;
|
|
384
|
+
readonly bio: string | undefined;
|
|
385
|
+
readonly image: string | undefined;
|
|
386
|
+
readonly links: PubkyAppUserLink[] | undefined;
|
|
387
|
+
readonly name: string;
|
|
388
|
+
readonly status: string | undefined;
|
|
443
389
|
}
|
|
390
|
+
|
|
444
391
|
/**
|
|
445
392
|
* Represents a user's single link with a title and URL.
|
|
446
393
|
*/
|
|
447
394
|
export class PubkyAppUserLink {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
395
|
+
free(): void;
|
|
396
|
+
[Symbol.dispose](): void;
|
|
397
|
+
/**
|
|
398
|
+
* Creates a new `PubkyAppUserLink` instance and sanitizes it.
|
|
399
|
+
*/
|
|
400
|
+
constructor(title: string, url: string);
|
|
401
|
+
readonly title: string;
|
|
402
|
+
readonly url: string;
|
|
455
403
|
}
|
|
404
|
+
|
|
456
405
|
/**
|
|
457
406
|
* Represents user data with name, bio, image, links, and status.
|
|
458
407
|
*/
|
|
459
408
|
export class PubkyId {
|
|
460
|
-
|
|
461
|
-
|
|
409
|
+
private constructor();
|
|
410
|
+
free(): void;
|
|
411
|
+
[Symbol.dispose](): void;
|
|
462
412
|
}
|
|
413
|
+
|
|
463
414
|
/**
|
|
464
415
|
* Represents a user's single link with a title and URL.
|
|
465
416
|
*/
|
|
466
417
|
export class PubkySpecsBuilder {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
418
|
+
free(): void;
|
|
419
|
+
[Symbol.dispose](): void;
|
|
420
|
+
createBlob(blob_data: any): BlobResult;
|
|
421
|
+
createBookmark(uri: string): BookmarkResult;
|
|
422
|
+
/**
|
|
423
|
+
* Creates a `kind = Collection` post — a curated list of URIs under
|
|
424
|
+
* a name and optional description.
|
|
425
|
+
*
|
|
426
|
+
* Convenience wrapper around `createPost` that builds the
|
|
427
|
+
* `PubkyAppCollectionContent` envelope (`{ name, description, items }`) and
|
|
428
|
+
* JSON-serializes it into `content` internally, so JS callers don't
|
|
429
|
+
* have to stringify the envelope themselves.
|
|
430
|
+
*
|
|
431
|
+
* `parent` and `embed` are not supported for Collection posts — the
|
|
432
|
+
* validator rejects them — so this helper omits those arguments.
|
|
433
|
+
*/
|
|
434
|
+
createCollectionPost(name: string, description?: string | null, items?: string[] | null): PostResult;
|
|
435
|
+
createFeed(tags: any, reach: string, layout: string, sort: string, content: string | null | undefined, name: string): FeedResult;
|
|
436
|
+
createFile(name: string, src: string, content_type: string, size: number): FileResult;
|
|
437
|
+
createFollow(followee_id: string): FollowResult;
|
|
438
|
+
createLastRead(): LastReadResult;
|
|
439
|
+
createMute(mutee_id: string): MuteResult;
|
|
440
|
+
createPost(content: string, kind: PubkyAppPostKind, parent?: string | null, embed?: PubkyAppPostEmbed | null, attachments?: string[] | null): PostResult;
|
|
441
|
+
createTag(uri: string, label: string): TagResult;
|
|
442
|
+
createUser(name: string, bio: string | null | undefined, image: string | null | undefined, links: any, status?: string | null): UserResult;
|
|
443
|
+
/**
|
|
444
|
+
* Edits an existing post by updating its content while preserving its original ID and timestamp.
|
|
445
|
+
*/
|
|
446
|
+
editPost(original_post: PubkyAppPost, post_id: string, new_content: string): PostResult;
|
|
447
|
+
/**
|
|
448
|
+
* Creates a new `PubkyAppBuilder` instance.
|
|
449
|
+
*/
|
|
450
|
+
constructor(pubky_id: string);
|
|
451
|
+
/**
|
|
452
|
+
* Returns validation limits as a JSON value for client-side use.
|
|
453
|
+
*/
|
|
454
|
+
readonly validationLimits: any;
|
|
490
455
|
}
|
|
456
|
+
|
|
491
457
|
export class TagResult {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
458
|
+
private constructor();
|
|
459
|
+
free(): void;
|
|
460
|
+
[Symbol.dispose](): void;
|
|
461
|
+
readonly meta: Meta;
|
|
462
|
+
readonly tag: PubkyAppTag;
|
|
496
463
|
}
|
|
464
|
+
|
|
497
465
|
export class UserResult {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
466
|
+
private constructor();
|
|
467
|
+
free(): void;
|
|
468
|
+
[Symbol.dispose](): void;
|
|
469
|
+
readonly meta: Meta;
|
|
470
|
+
readonly user: PubkyAppUser;
|
|
502
471
|
}
|
|
472
|
+
|
|
473
|
+
export function baseUriBuilder(user_id: string): string;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Builds a Blob URI of the form "pubky://<author_id>/pub/pubky.app/blobs/<blob_id>"
|
|
477
|
+
*/
|
|
478
|
+
export function blobUriBuilder(author_id: string, blob_id: string): string;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Builds a Bookmark URI of the form "pubky://<author_id>/pub/pubky.app/bookmarks/<bookmark_id>"
|
|
482
|
+
*/
|
|
483
|
+
export function bookmarkUriBuilder(author_id: string, bookmark_id: string): string;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Builds a Feed URI of the form "pubky://<author_id>/pub/pubky.app/feeds/<feed_id>"
|
|
487
|
+
*/
|
|
488
|
+
export function feedUriBuilder(author_id: string, feed_id: string): string;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Builds a File URI of the form "pubky://<author_id>/pub/pubky.app/files/<file_id>"
|
|
492
|
+
*/
|
|
493
|
+
export function fileUriBuilder(author_id: string, file_id: string): string;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Builds a Follow URI of the form "pubky://<author_id>/pub/pubky.app/follows/<follow_id>"
|
|
497
|
+
*/
|
|
498
|
+
export function followUriBuilder(author_id: string, follow_id: string): string;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Returns the list of valid MIME types for file attachments.
|
|
502
|
+
*
|
|
503
|
+
* This allows JavaScript consumers to validate file types before submission
|
|
504
|
+
* without having to duplicate the list.
|
|
505
|
+
*
|
|
506
|
+
* # Example (TypeScript)
|
|
507
|
+
*
|
|
508
|
+
* ```typescript
|
|
509
|
+
* import { get_valid_mime_types } from "pubky-app-specs";
|
|
510
|
+
*
|
|
511
|
+
* const validTypes = get_valid_mime_types();
|
|
512
|
+
* const fileType = "image/png";
|
|
513
|
+
* if (validTypes.includes(fileType)) {
|
|
514
|
+
* console.log("Valid file type!");
|
|
515
|
+
* }
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
export function getValidMimeTypes(): any[];
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Each FFI function:
|
|
522
|
+
* - Accepts minimal fields in a JavaScript-friendly manner (e.g. strings, JSON).
|
|
523
|
+
* - Creates the Rust model, sanitizes, and validates it.
|
|
524
|
+
* - Generates the ID (if applicable).
|
|
525
|
+
* - Generates the path (if applicable).
|
|
526
|
+
* - Returns { json, id, path, url } or a descriptive error.
|
|
527
|
+
* Returns validation limits as a JSON value for client-side use without a builder.
|
|
528
|
+
*/
|
|
529
|
+
export function getValidationLimits(): any;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Builds a LastRead URI of the form "pubky://<author_id>/pub/pubky.app/last_read"
|
|
533
|
+
*/
|
|
534
|
+
export function lastReadUriBuilder(author_id: string): string;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Builds a Mute URI of the form "pubky://<author_id>/pub/pubky.app/mutes/<mute_id>"
|
|
538
|
+
*/
|
|
539
|
+
export function muteUriBuilder(author_id: string, mute_id: string): string;
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Parses a Pubky URI and returns a strongly typed `ParsedUriResult`.
|
|
543
|
+
*
|
|
544
|
+
* This function wraps the internal ParsedUri ust parsing logic. It converts the result into a
|
|
545
|
+
* strongly typed object that is easier to use in TypeScript.
|
|
546
|
+
*
|
|
547
|
+
* # Parameters
|
|
548
|
+
*
|
|
549
|
+
* - `uri`: A string slice representing the Pubky URI. The URI should follow the format:
|
|
550
|
+
* `pubky://<user_id>/pub/pubky.app/<resource>[/<id>]`.
|
|
551
|
+
*
|
|
552
|
+
* # Returns
|
|
553
|
+
*
|
|
554
|
+
* On success, returns a `ParsedUriResult` with:
|
|
555
|
+
* - `user_id`: the parsed user ID,
|
|
556
|
+
* - `resource`: a string (derived from the Display implementation of internal `Resource` enum),
|
|
557
|
+
* - `resource_id`: an optional resource identifier (if applicable).
|
|
558
|
+
*
|
|
559
|
+
* On failure, returns a JavaScript error (`String`) containing an error message.
|
|
560
|
+
*
|
|
561
|
+
* # Example (TypeScript)
|
|
562
|
+
*
|
|
563
|
+
* ```typescript
|
|
564
|
+
* import { parse_uri } from "pubky-app-specs";
|
|
565
|
+
*
|
|
566
|
+
* try {
|
|
567
|
+
* const result = parse_uri("pubky://user123/pub/pubky.app/posts/abc123");
|
|
568
|
+
* console.log(result.user_id); // e.g. "user123"
|
|
569
|
+
* console.log(result.resource); // e.g. "posts"
|
|
570
|
+
* console.log(result.resource_id); // e.g. "abc123" or null
|
|
571
|
+
* } catch (error) {
|
|
572
|
+
* console.error("Error parsing URI:", error);
|
|
573
|
+
* }
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
export function parse_uri(uri: string): ParsedUriResult;
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Builds a Post URI of the form "pubky://<author_id>/pub/pubky.app/posts/<post_id>"
|
|
580
|
+
*/
|
|
581
|
+
export function postUriBuilder(author_id: string, post_id: string): string;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Builds a Tag URI of the form "pubky://<author_id>/pub/pubky.app/tags/<tag_id>"
|
|
585
|
+
*/
|
|
586
|
+
export function tagUriBuilder(author_id: string, tag_id: string): string;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Builds an User URI of the form "pubky://<user_pubky_id>/pub/pubky.app/profile.json"
|
|
590
|
+
*/
|
|
591
|
+
export function userUriBuilder(user_id: string): string;
|