pubky-app-specs 0.4.3 → 0.4.4

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
@@ -332,17 +332,45 @@ A `ParsedUriResult` object with:
332
332
 
333
333
  ## Validation limits
334
334
 
335
- The WASM builder exposes validation limits as a JSON object so UIs can reuse
336
- the canonical rules without duplicating magic numbers.
335
+ Validation limits are published as JSON so UIs and tests can reuse the
336
+ canonical rules without WASM, plus optional WASM accessors when needed.
337
+
338
+ ### ✅ Recommended (no WASM)
339
+
340
+ **Named export from the package root:**
337
341
 
338
342
  ```js
339
- import init, { PubkySpecsBuilder } from "pubky-app-specs";
343
+ import { validationLimits, getValidationLimits } from "pubky-app-specs";
340
344
 
341
- await init();
342
- const builder = new PubkySpecsBuilder("pubky_id_here");
343
- const limits = builder.validationLimits;
345
+ console.log(validationLimits);
346
+ const copy = getValidationLimits();
347
+ ```
348
+
349
+ **Direct subpath import (ESM):**
350
+
351
+ ```js
352
+ import limits from "pubky-app-specs/validationLimits";
353
+ // or
354
+ import limitsJson from "pubky-app-specs/validationLimits.json";
355
+ ```
356
+
357
+ **Direct subpath import (CJS):**
344
358
 
345
- console.log(limits);
359
+ ```js
360
+ const { validationLimits, getValidationLimits } = require("pubky-app-specs");
361
+ // or
362
+ const limits = require("pubky-app-specs/validationLimits");
363
+ ```
364
+
365
+ ### WASM accessors
366
+
367
+ ```js
368
+ import { PubkySpecsBuilder, getValidationLimits } from "pubky-app-specs";
369
+
370
+ const limitsFromWasm = getValidationLimits();
371
+
372
+ const builder = new PubkySpecsBuilder("pubky_id_here");
373
+ const limitsFromBuilder = builder.validationLimits;
346
374
  ```
347
375
 
348
376
  Example output shape:
@@ -364,7 +392,7 @@ Example output shape:
364
392
  "userStatusMaxLength": 50,
365
393
  "postShortContentMaxLength": 2000,
366
394
  "postLongContentMaxLength": 50000,
367
- "postAttachmentsMaxCount": 3,
395
+ "postAttachmentsMaxCount": 4,
368
396
  "postAttachmentUrlMaxLength": 200,
369
397
  "postAllowedAttachmentProtocols": ["pubky", "http", "https"],
370
398
  "fileNameMinLength": 1,
package/index.cjs CHANGED
@@ -446,6 +446,24 @@ module.exports.lastReadUriBuilder = function(author_id) {
446
446
  }
447
447
  };
448
448
 
449
+ /**
450
+ * Each FFI function:
451
+ * - Accepts minimal fields in a JavaScript-friendly manner (e.g. strings, JSON).
452
+ * - Creates the Rust model, sanitizes, and validates it.
453
+ * - Generates the ID (if applicable).
454
+ * - Generates the path (if applicable).
455
+ * - Returns { json, id, path, url } or a descriptive error.
456
+ * Returns validation limits as a JSON value for client-side use without a builder.
457
+ * @returns {any}
458
+ */
459
+ module.exports.getValidationLimits = function() {
460
+ const ret = wasm.getValidationLimits();
461
+ if (ret[2]) {
462
+ throw takeFromExternrefTable0(ret[1]);
463
+ }
464
+ return takeFromExternrefTable0(ret[0]);
465
+ };
466
+
449
467
  /**
450
468
  * Returns the list of valid MIME types for file attachments.
451
469
  *
@@ -815,14 +833,7 @@ module.exports.LastReadResult = LastReadResult;
815
833
  const MetaFinalization = (typeof FinalizationRegistry === 'undefined')
816
834
  ? { register: () => {}, unregister: () => {} }
817
835
  : new FinalizationRegistry(ptr => wasm.__wbg_meta_free(ptr >>> 0, 1));
818
- /**
819
- * Each FFI function:
820
- * - Accepts minimal fields in a JavaScript-friendly manner (e.g. strings, JSON).
821
- * - Creates the Rust model, sanitizes, and validates it.
822
- * - Generates the ID (if applicable).
823
- * - Generates the path (if applicable).
824
- * - Returns { json, id, path, url } or a descriptive error.
825
- */
836
+
826
837
  class Meta {
827
838
 
828
839
  static __wrap(ptr) {