dsh-mnemon 0.5.5 → 0.5.7

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.
@@ -1,6 +1,5 @@
1
- import { i as withMemoryStorageLock, t as defineMemoryStrategyConfiguration } from "./strategy-configuration-B_DsZRQG.js";
2
- import { a as defineMemoryStrategy, i as defineMemorySource, o as defineMemoryStrategyExtension, r as defineMemoryPlugin, t as canonicalMemoryJson } from "./definitions-j0FLgE0-.js";
3
- import { createHash, randomUUID } from "node:crypto";
1
+ import { a as memoryConfigurationDigest, c as record, d as truncate, f as withMemoryStorageLock, i as integer, l as stringArray, o as migrationLineage, s as receipt, t as defineMemoryStrategyConfiguration, u as text } from "./strategy-configuration-BTXIWooc.js";
2
+ import { a as defineMemoryStrategy, i as defineMemorySource, o as defineMemoryStrategyExtension, r as defineMemoryPlugin } from "./definitions-j0FLgE0-.js";
4
3
  //#region src/sdk/install.ts
5
4
  function stableEntryId(ctx, explicit) {
6
5
  const configured = explicit?.trim();
@@ -23,72 +22,4 @@ function installMemory(ctx, contribution, options = {}) {
23
22
  }), `dsh-mnemon: install ${entryId}`);
24
23
  }
25
24
  //#endregion
26
- //#region src/sdk/input.ts
27
- /** Stable digest of validated configuration; raw values never enter diagnostics. */
28
- function memoryConfigurationDigest(value) {
29
- return `config:${createHash("sha256").update(canonicalMemoryJson(value, "memory configuration")).digest("hex")}`;
30
- }
31
- function record(value, label) {
32
- if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} must be an object`);
33
- return value;
34
- }
35
- function text(value, label, maximum, required = true) {
36
- if (value === void 0 && !required) return void 0;
37
- if (typeof value !== "string") throw new Error(`${label} must be a string`);
38
- const normalized = value.trim();
39
- if (required && normalized === "") throw new Error(`${label} is required`);
40
- if (normalized.length > maximum) throw new Error(`${label} is too long (max ${maximum} characters)`);
41
- return normalized === "" ? void 0 : normalized;
42
- }
43
- function integer(value, fallback, minimum, maximum) {
44
- if (value === void 0) return fallback;
45
- if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > maximum) throw new Error(`value must be an integer within ${minimum}..${maximum}`);
46
- return value;
47
- }
48
- function stringArray(value, label, maximum = 50) {
49
- if (value === void 0) return void 0;
50
- if (!Array.isArray(value) || value.length > maximum || value.some((item) => typeof item !== "string")) throw new Error(`${label} must be a string array`);
51
- return value.map((item) => item.trim()).filter(Boolean);
52
- }
53
- function truncate(value, maximum) {
54
- if (maximum <= 0) return "";
55
- if (value.length <= maximum) return value;
56
- let end = maximum - 1;
57
- if (end > 0 && /[\uD800-\uDBFF]/u.test(value[end - 1])) end--;
58
- return `${value.slice(0, end)}…`;
59
- }
60
- function receipt(viewId, offerId, sourceInstanceKey, revision, details, completion = "unknown") {
61
- return {
62
- id: `receipt:${randomUUID()}`,
63
- viewId,
64
- offerId,
65
- sourceInstanceKey,
66
- status: completion === "failed" ? "failed" : completion === "partial" || completion === "unknown" ? "partial" : "succeeded",
67
- completion,
68
- ...completion === "committed" ? { committedAt: (/* @__PURE__ */ new Date()).toISOString() } : {},
69
- ...revision === void 0 ? {} : { revision },
70
- details
71
- };
72
- }
73
- /** Validate migration proof supplied by an authorized Source management caller. */
74
- function migrationLineage(value) {
75
- if (value === void 0) return [];
76
- if (!Array.isArray(value) || value.length > 1e3) throw new Error("lineage must be an array of at most 1000 entries");
77
- return value.map((item) => {
78
- const entry = record(item, "lineage");
79
- const endpoint = (value) => {
80
- const fields = record(value, "lineage endpoint");
81
- return {
82
- layerId: text(fields.layerId, "lineage layerId", 300),
83
- reference: text(fields.reference, "lineage reference", 2e3),
84
- digest: text(fields.digest, "lineage digest", 300)
85
- };
86
- };
87
- return {
88
- source: endpoint(entry.source),
89
- destination: endpoint(entry.destination)
90
- };
91
- });
92
- }
93
- //#endregion
94
25
  export { receipt as createMemoryMutationReceipt, defineMemoryPlugin, defineMemorySource, defineMemoryStrategy, defineMemoryStrategyConfiguration, defineMemoryStrategyExtension, installMemory, memoryConfigurationDigest, integer as memoryInputInteger, migrationLineage as memoryInputMigrationLineage, record as memoryInputRecord, stringArray as memoryInputStringArray, text as memoryInputText, truncate as truncateMemoryText, withMemoryStorageLock };