@neurowire/core 0.4.0 → 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/dist/index.d.ts CHANGED
@@ -334,6 +334,20 @@ declare function matchRule(entry: NeurowireEntry, rule: FilterRule): boolean;
334
334
  */
335
335
  declare function filterEntries(feed: NeurowireFeed, spec: FilterSpec): NeurowireFeed;
336
336
 
337
+ /**
338
+ * Stable, content-derived entry ids. Pure and dependency-free (no node:crypto)
339
+ * so core stays portable. Used to give entries that lack a real GUID a
340
+ * deterministic id, keeping dedup and round-trips stable across formats.
341
+ */
342
+ /** FNV-1a (64-bit) hash of `input`, returned as a fixed 16-char lowercase hex string. */
343
+ declare function hashHex(input: string): string;
344
+ /**
345
+ * A deterministic synthetic id derived from an entry's link and title.
346
+ * Same `(link, title)` always yields the same urn; different inputs (essentially)
347
+ * always differ. Shape: `urn:nwf:<16-char hex>`.
348
+ */
349
+ declare function stableId(link: string, title: string): string;
350
+
337
351
  /** One feed plus the source label its entries should carry in a merge. */
338
352
  interface MergePart {
339
353
  feed: NeurowireFeed;
@@ -472,4 +486,4 @@ declare function isFormat(value: string): value is Format;
472
486
  /** Serialize a feed to the requested format. */
473
487
  declare function serialize(feed: NeurowireFeed, format: Format): string;
474
488
 
475
- export { EXTENSIONS, EntrySchema, FORMATS, FeedSchema, type FilterField, type FilterRule, type FilterSpec, type Format, GENERATOR, type JsonFeedDocument, MEDIA_TYPES, type MergeOptions, type MergePart, type Mesh, MeshSchema, type MeshSource, MeshSourceSchema, type NeurowireEntry, type NeurowireFeed, type NwfIssue, type NwfValidation, type Person, PersonSchema, type SelectOptions, type SortKey, type SortOrder, type TimeWindow, type WindowSpec, entryKey, filterEntries, fromNwf, isFormat, matchRule, mergeFeeds, newEntries, parseDuration, parseMesh, parseNeurowireFeed, resolveWindow, selectEntries, serialize, toAtom, toJsonFeed, toJsonFeedObject, toMarkdown, toNwf, validateNwf };
489
+ export { EXTENSIONS, EntrySchema, FORMATS, FeedSchema, type FilterField, type FilterRule, type FilterSpec, type Format, GENERATOR, type JsonFeedDocument, MEDIA_TYPES, type MergeOptions, type MergePart, type Mesh, MeshSchema, type MeshSource, MeshSourceSchema, type NeurowireEntry, type NeurowireFeed, type NwfIssue, type NwfValidation, type Person, PersonSchema, type SelectOptions, type SortKey, type SortOrder, type TimeWindow, type WindowSpec, entryKey, filterEntries, fromNwf, hashHex, isFormat, matchRule, mergeFeeds, newEntries, parseDuration, parseMesh, parseNeurowireFeed, resolveWindow, selectEntries, serialize, stableId, toAtom, toJsonFeed, toJsonFeedObject, toMarkdown, toNwf, validateNwf };
package/dist/index.js CHANGED
@@ -43,6 +43,21 @@ function filterEntries(feed, spec) {
43
43
  return { ...feed, entries: kept };
44
44
  }
45
45
 
46
+ // src/id.ts
47
+ function hashHex(input) {
48
+ let hash = 0xcbf29ce484222325n;
49
+ const prime = 0x100000001b3n;
50
+ for (let i = 0; i < input.length; i++) {
51
+ hash ^= BigInt(input.charCodeAt(i));
52
+ hash = hash * prime & 0xffffffffffffffffn;
53
+ }
54
+ return hash.toString(16).padStart(16, "0");
55
+ }
56
+ function stableId(link, title) {
57
+ return `urn:nwf:${hashHex(`${link}
58
+ ${title}`)}`;
59
+ }
60
+
46
61
  // src/model.ts
47
62
  import { z } from "zod";
48
63
  var PersonSchema = z.object({
@@ -703,6 +718,7 @@ export {
703
718
  entryKey,
704
719
  filterEntries,
705
720
  fromNwf,
721
+ hashHex,
706
722
  isFormat,
707
723
  matchRule,
708
724
  mergeFeeds,
@@ -713,6 +729,7 @@ export {
713
729
  resolveWindow,
714
730
  selectEntries,
715
731
  serialize,
732
+ stableId,
716
733
  toAtom,
717
734
  toJsonFeed,
718
735
  toJsonFeedObject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neurowire/core",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Canonical feed model and serializers (Atom, JSON Feed 1.1, Markdown, nwf) for Neurowire.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",