pubky-app-specs 0.4.2 → 0.4.3

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 CHANGED
@@ -71,12 +71,12 @@ async function createUser(pubkyId) {
71
71
  const specs = new PubkySpecsBuilder(pubkyId);
72
72
 
73
73
  // Create user object with minimal fields
74
- const {user, meta} = specs.createUser(
74
+ const { user, meta } = specs.createUser(
75
75
  "Alice", // Name
76
76
  "Hello from WASM", // Bio
77
77
  null, // Image URL or File
78
78
  null, // Links
79
- "active" // Status
79
+ "active", // Status
80
80
  );
81
81
 
82
82
  // meta contains { id, path, url }.
@@ -112,12 +112,12 @@ async function createPost(pubkyId, content) {
112
112
  const specs = new PubkySpecsBuilder(pubkyId);
113
113
 
114
114
  // Create the Post object
115
- const {post, meta} = specs.createPost(
115
+ const { post, meta } = specs.createPost(
116
116
  content,
117
117
  PubkyAppPostKind.Short,
118
118
  null, // parent post URI (for replies)
119
119
  null, // embed object (for reposts)
120
- null // attachments (array of file URLs, max 3)
120
+ null, // attachments (array of file URLs, max 3)
121
121
  );
122
122
 
123
123
  // Store the post
@@ -128,7 +128,7 @@ async function createPost(pubkyId, content) {
128
128
  });
129
129
 
130
130
  console.log("Post stored at:", meta.url);
131
- return {post, meta};
131
+ return { post, meta };
132
132
  }
133
133
  ```
134
134
 
@@ -143,12 +143,12 @@ async function createPostWithAttachments(pubkyId, content, fileUrls) {
143
143
  const specs = new PubkySpecsBuilder(pubkyId);
144
144
 
145
145
  // Create post with attachments (max 3 allowed)
146
- const {post, meta} = specs.createPost(
146
+ const { post, meta } = specs.createPost(
147
147
  content,
148
148
  PubkyAppPostKind.Image,
149
149
  null, // parent
150
150
  null, // embed
151
- fileUrls // e.g. ["pubky://user/pub/pubky.app/files/abc123"]
151
+ fileUrls, // e.g. ["pubky://user/pub/pubky.app/files/abc123"]
152
152
  );
153
153
 
154
154
  const postJson = post.toJson();
@@ -160,7 +160,7 @@ async function createPostWithAttachments(pubkyId, content, fileUrls) {
160
160
  });
161
161
 
162
162
  console.log("Post with attachments stored at:", meta.url);
163
- return {post, meta};
163
+ return { post, meta };
164
164
  }
165
165
  ```
166
166
 
@@ -174,7 +174,7 @@ async function followUser(myPubkyId, userToFollow) {
174
174
  const client = new Client();
175
175
  const specs = new PubkySpecsBuilder(myPubkyId);
176
176
 
177
- const {follow, meta} = specs.createFollow(userToFollow);
177
+ const { follow, meta } = specs.createFollow(userToFollow);
178
178
 
179
179
  // We only need to store the JSON in the homeserver
180
180
  await client.fetch(meta.url, {
@@ -215,7 +215,7 @@ async function uploadFile(pubkyId, fileData, fileName, contentType, fileSize) {
215
215
 
216
216
  // First, create and store the blob (raw binary data)
217
217
  const { blob, meta: blobMeta } = specs.createBlob(fileData);
218
-
218
+
219
219
  await client.fetch(blobMeta.url, {
220
220
  method: "PUT",
221
221
  body: JSON.stringify(blob.toJson()),
@@ -223,10 +223,10 @@ async function uploadFile(pubkyId, fileData, fileName, contentType, fileSize) {
223
223
 
224
224
  // Then create the file metadata pointing to the blob
225
225
  const { file, meta: fileMeta } = specs.createFile(
226
- fileName, // e.g. "vacation-photo.jpg"
227
- blobMeta.url, // Reference to the blob
228
- contentType, // e.g. "image/jpeg"
229
- fileSize // Size in bytes
226
+ fileName, // e.g. "vacation-photo.jpg"
227
+ blobMeta.url, // Reference to the blob
228
+ contentType, // e.g. "image/jpeg"
229
+ fileSize, // Size in bytes
230
230
  );
231
231
 
232
232
  await client.fetch(fileMeta.url, {
@@ -287,16 +287,16 @@ const userId = "8kkppkmiubfq4pxn6f73nqrhhhgkb5xyfprntc9si3np9ydbotto";
287
287
  const targetUserId = "dzswkfy7ek3bqnoc89jxuqqfbzhjrj6mi8qthgbxxcqkdugm3rio";
288
288
 
289
289
  // Build URIs for different resources
290
- userUriBuilder(userId); // pubky://{userId}/pub/pubky.app/profile.json
291
- postUriBuilder(userId, "0033SSE3B1FQ0"); // pubky://{userId}/pub/pubky.app/posts/{postId}
292
- bookmarkUriBuilder(userId, "ABC123"); // pubky://{userId}/pub/pubky.app/bookmarks/{bookmarkId}
293
- followUriBuilder(userId, targetUserId); // pubky://{userId}/pub/pubky.app/follows/{targetUserId}
294
- tagUriBuilder(userId, "XYZ789"); // pubky://{userId}/pub/pubky.app/tags/{tagId}
295
- muteUriBuilder(userId, targetUserId); // pubky://{userId}/pub/pubky.app/mutes/{targetUserId}
296
- lastReadUriBuilder(userId); // pubky://{userId}/pub/pubky.app/last_read
297
- blobUriBuilder(userId, "BLOB123"); // pubky://{userId}/pub/pubky.app/blobs/{blobId}
298
- fileUriBuilder(userId, "FILE456"); // pubky://{userId}/pub/pubky.app/files/{fileId}
299
- feedUriBuilder(userId, "FEED789"); // pubky://{userId}/pub/pubky.app/feeds/{feedId}
290
+ userUriBuilder(userId); // pubky://{userId}/pub/pubky.app/profile.json
291
+ postUriBuilder(userId, "0033SSE3B1FQ0"); // pubky://{userId}/pub/pubky.app/posts/{postId}
292
+ bookmarkUriBuilder(userId, "ABC123"); // pubky://{userId}/pub/pubky.app/bookmarks/{bookmarkId}
293
+ followUriBuilder(userId, targetUserId); // pubky://{userId}/pub/pubky.app/follows/{targetUserId}
294
+ tagUriBuilder(userId, "XYZ789"); // pubky://{userId}/pub/pubky.app/tags/{tagId}
295
+ muteUriBuilder(userId, targetUserId); // pubky://{userId}/pub/pubky.app/mutes/{targetUserId}
296
+ lastReadUriBuilder(userId); // pubky://{userId}/pub/pubky.app/last_read
297
+ blobUriBuilder(userId, "BLOB123"); // pubky://{userId}/pub/pubky.app/blobs/{blobId}
298
+ fileUriBuilder(userId, "FILE456"); // pubky://{userId}/pub/pubky.app/files/{fileId}
299
+ feedUriBuilder(userId, "FEED789"); // pubky://{userId}/pub/pubky.app/feeds/{feedId}
300
300
  ```
301
301
 
302
302
  ---
@@ -330,6 +330,52 @@ A `ParsedUriResult` object with:
330
330
 
331
331
  ---
332
332
 
333
+ ## Validation limits
334
+
335
+ The WASM builder exposes validation limits as a JSON object so UIs can reuse
336
+ the canonical rules without duplicating magic numbers.
337
+
338
+ ```js
339
+ import init, { PubkySpecsBuilder } from "pubky-app-specs";
340
+
341
+ await init();
342
+ const builder = new PubkySpecsBuilder("pubky_id_here");
343
+ const limits = builder.validationLimits;
344
+
345
+ console.log(limits);
346
+ ```
347
+
348
+ Example output shape:
349
+
350
+ ```json
351
+ {
352
+ "maxBlobSizeBytes": 104857600,
353
+ "maxFileSizeBytes": 104857600,
354
+ "tagLabelMinLength": 1,
355
+ "tagLabelMaxLength": 20,
356
+ "tagInvalidChars": [",", ":", " ", "\t", "\n", "\r"],
357
+ "userNameMinLength": 3,
358
+ "userNameMaxLength": 50,
359
+ "userBioMaxLength": 160,
360
+ "userImageUrlMaxLength": 300,
361
+ "userLinksMaxCount": 5,
362
+ "userLinkTitleMaxLength": 100,
363
+ "userLinkUrlMaxLength": 300,
364
+ "userStatusMaxLength": 50,
365
+ "postShortContentMaxLength": 2000,
366
+ "postLongContentMaxLength": 50000,
367
+ "postAttachmentsMaxCount": 3,
368
+ "postAttachmentUrlMaxLength": 200,
369
+ "postAllowedAttachmentProtocols": ["pubky", "http", "https"],
370
+ "fileNameMinLength": 1,
371
+ "fileNameMaxLength": 255,
372
+ "fileSrcMaxLength": 1024,
373
+ "feedTagsMaxCount": 5
374
+ }
375
+ ```
376
+
377
+ ---
378
+
333
379
  ## 📄 License
334
380
 
335
381
  MIT
package/index.cjs CHANGED
@@ -2311,6 +2311,17 @@ class PubkySpecsBuilder {
2311
2311
  PubkySpecsBuilderFinalization.register(this, this.__wbg_ptr, this);
2312
2312
  return this;
2313
2313
  }
2314
+ /**
2315
+ * Returns validation limits as a JSON value for client-side use.
2316
+ * @returns {any}
2317
+ */
2318
+ get validationLimits() {
2319
+ const ret = wasm.pubkyspecsbuilder_validationLimits(this.__wbg_ptr);
2320
+ if (ret[2]) {
2321
+ throw takeFromExternrefTable0(ret[1]);
2322
+ }
2323
+ return takeFromExternrefTable0(ret[0]);
2324
+ }
2314
2325
  /**
2315
2326
  * @param {string} name
2316
2327
  * @param {string | null | undefined} bio
@@ -2617,6 +2628,11 @@ module.exports.__wbg_entries_3265d4158b33e5dc = function(arg0) {
2617
2628
  return ret;
2618
2629
  };
2619
2630
 
2631
+ module.exports.__wbg_fromCodePoint_f37c25c172f2e8b5 = function() { return handleError(function (arg0) {
2632
+ const ret = String.fromCodePoint(arg0 >>> 0);
2633
+ return ret;
2634
+ }, arguments) };
2635
+
2620
2636
  module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
2621
2637
  const ret = Reflect.get(arg0, arg1);
2622
2638
  return ret;