@ordinatio/entities 1.0.3 → 1.1.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/README.md CHANGED
@@ -191,6 +191,10 @@ await app.entities.createNote({ entityType: 'client', entityId: 'client-123', co
191
191
  | `getNotes(db, options)` | Query | List notes with cursor pagination |
192
192
  | `deleteNote(db, noteId, entityId)` | Mutation | Delete a note |
193
193
 
194
+ ### Tags Module (`@ordinatio/entities/tags`, experimental)
195
+
196
+ Pure, zero-dependency helpers for tags, on their own subpath so a browser component can import them without pulling in the rest of the package (no Prisma, zod or Node modules): `tagNameKey` / `cleanTagName` / `checkTagName` (the case-insensitive identity of a name; **pinned to its first shipped behaviour** because apps store the key in a unique column), `TAG_COLORS` / `isTagColor` / `resolveTagColor`, `DEFAULT_TAG_LIMITS` (name length 40, 50 changes per save, 15 pinned, 500 per workspace: defaults, a store takes them as arguments), and the picker helpers `describeTagChanges`, `tagSetKey`, `rebaseSelection`, `mergeTagOptions`. The `./schemas` and `./errors` subpaths exist only in the workspace (source) exports map and are not part of the published package yet. A store interface, service and contract suite are planned for a later release on a separate server entry; until a second product has used them, the interface is experimental.
197
+
194
198
  ### Contacts Module
195
199
 
196
200
  | Function | Type | Description |
@@ -1,4 +1,5 @@
1
1
  // src/errors.ts
2
+ import { createModuleError } from "@ordinatio/errors";
2
3
  var KNOWLEDGE_ERRORS = {
3
4
  KNOWLEDGE_300: {
4
5
  code: "KNOWLEDGE_300",
@@ -575,35 +576,40 @@ var AGENTKNOW_ERRORS = {
575
576
  ]
576
577
  }
577
578
  };
578
- function knowledgeError(code, context) {
579
- const def = KNOWLEDGE_ERRORS[code];
580
- const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z/, "");
581
- return {
582
- code: def.code,
583
- ref: `${def.code}-${timestamp}`,
584
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
585
- module: "KNOWLEDGE",
586
- description: def.description,
587
- severity: def.severity,
588
- recoverable: def.recoverable,
589
- diagnosis: [...def.diagnosis],
590
- context: context || {}
579
+ function toSharedErrorRegistry(registry) {
580
+ const severityMap = {
581
+ low: "info",
582
+ medium: "warning",
583
+ high: "error",
584
+ critical: "critical"
591
585
  };
586
+ const result = {};
587
+ for (const [code, def] of Object.entries(registry)) {
588
+ result[code] = {
589
+ code: def.code,
590
+ description: def.description,
591
+ severity: severityMap[def.severity],
592
+ recoverable: def.recoverable,
593
+ diagnosis: def.diagnosis.map((d) => `${d.step}: ${d.check}`),
594
+ file: def.file,
595
+ function: def.function
596
+ };
597
+ }
598
+ return result;
592
599
  }
600
+ var _knowledgeError = null;
601
+ function knowledgeError(code, context) {
602
+ if (!_knowledgeError) {
603
+ _knowledgeError = createModuleError("KNOWLEDGE", toSharedErrorRegistry(KNOWLEDGE_ERRORS));
604
+ }
605
+ return _knowledgeError(code, context);
606
+ }
607
+ var _agentKnowledgeError = null;
593
608
  function agentKnowledgeError(code, context) {
594
- const entry = AGENTKNOW_ERRORS[code];
595
- const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "");
596
- return {
597
- code: entry.code,
598
- ref: `${entry.code}-${ts}`,
599
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
600
- module: "AGENT_KNOWLEDGE",
601
- description: entry.description,
602
- severity: entry.severity,
603
- recoverable: entry.recoverable,
604
- diagnosis: [...entry.diagnosis],
605
- context: context || {}
606
- };
609
+ if (!_agentKnowledgeError) {
610
+ _agentKnowledgeError = createModuleError("AGENT_KNOWLEDGE", AGENTKNOW_ERRORS);
611
+ }
612
+ return _agentKnowledgeError(code, context);
607
613
  }
608
614
  var ContactNotFoundError = class extends Error {
609
615
  constructor(id) {