@utilix-tech/sdk 0.78.0 → 0.80.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +21 -6
  3. package/dist/{ai_agent-CmrVjvYH.d.cts → ai_agent-DeCy0oZK.d.cts} +42 -2
  4. package/dist/{ai_agent-CmrVjvYH.d.ts → ai_agent-DeCy0oZK.d.ts} +42 -2
  5. package/dist/{chunk-EKIXOA7B.js → chunk-HJLGUNSO.js} +58 -1
  6. package/dist/{chunk-RP574L5Z.js → chunk-OFLNVDNX.js} +46 -1
  7. package/dist/{chunk-XT2BQWXT.js → chunk-RYSN5JNA.js} +49 -1
  8. package/dist/{chunk-34C6GXCC.js → chunk-WUOZHCIC.js} +217 -1
  9. package/dist/{code-46xO9xFf.d.cts → code-C4n621_i.d.cts} +30 -2
  10. package/dist/{code-46xO9xFf.d.ts → code-C4n621_i.d.ts} +30 -2
  11. package/dist/index.cjs +366 -0
  12. package/dist/index.d.cts +4 -4
  13. package/dist/index.d.ts +4 -4
  14. package/dist/index.js +4 -4
  15. package/dist/{json-CaiYsGDQ.d.cts → json-Ca6gZCNB.d.cts} +45 -2
  16. package/dist/{json-CaiYsGDQ.d.ts → json-Ca6gZCNB.d.ts} +45 -2
  17. package/dist/tools/ai_agent.cjs +57 -0
  18. package/dist/tools/ai_agent.d.cts +1 -1
  19. package/dist/tools/ai_agent.d.ts +1 -1
  20. package/dist/tools/ai_agent.js +1 -1
  21. package/dist/tools/code.cjs +48 -0
  22. package/dist/tools/code.d.cts +1 -1
  23. package/dist/tools/code.d.ts +1 -1
  24. package/dist/tools/code.js +1 -1
  25. package/dist/tools/json.cjs +216 -0
  26. package/dist/tools/json.d.cts +1 -1
  27. package/dist/tools/json.d.ts +1 -1
  28. package/dist/tools/json.js +1 -1
  29. package/dist/tools/units.cjs +45 -0
  30. package/dist/tools/units.d.cts +1 -1
  31. package/dist/tools/units.d.ts +1 -1
  32. package/dist/tools/units.js +1 -1
  33. package/dist/{units-BqegyALA.d.ts → units-D7YRRwei.d.cts} +29 -2
  34. package/dist/{units-BqegyALA.d.cts → units-D7YRRwei.d.ts} +29 -2
  35. package/package.json +1 -1
@@ -15,6 +15,7 @@
15
15
  * - json-to-zod : jsonToZod
16
16
  * - json-schema-to-typescript : jsonSchemaToTypescript
17
17
  * - json-merge-patch : mergeJsonPatch, applyJsonMergePatch
18
+ * - json-patch : diffJsonPatch, applyJsonPatch, generateJsonPatch
18
19
  */
19
20
  type ParseStatus = 'idle' | 'valid' | 'error';
20
21
  interface JsonParseResult {
@@ -220,6 +221,43 @@ declare function mergeJsonPatch(target: unknown, patch: unknown): unknown;
220
221
  declare function applyJsonMergePatch(targetJson: string, patchJson: string): MergePatchResult | {
221
222
  error: string;
222
223
  };
224
+ type JsonPatchOp = 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test';
225
+ interface JsonPatchOperation {
226
+ op: JsonPatchOp;
227
+ path: string;
228
+ value?: unknown;
229
+ from?: string;
230
+ }
231
+ /**
232
+ * Generates a minimal (naive, index-by-index for arrays) RFC 6902 JSON
233
+ * Patch document describing how to transform `a` into `b`. Object keys
234
+ * produce add/remove/replace; arrays are compared position by position,
235
+ * with removes emitted from the highest index down and adds appended at
236
+ * the end, so the resulting patch applies correctly in order. This is not
237
+ * a minimal-edit-distance diff (it won't detect a reordering as a move) —
238
+ * just a direct, deterministic structural comparison.
239
+ */
240
+ declare function diffJsonPatch(a: unknown, b: unknown): JsonPatchOperation[];
241
+ /**
242
+ * Applies a sequence of RFC 6902 JSON Patch operations to a target
243
+ * document and returns the result, or an error naming the failing
244
+ * operation's index. Supports add, remove, replace, move, copy, and test.
245
+ * The input document is not mutated.
246
+ */
247
+ declare function applyJsonPatch(target: unknown, operations: JsonPatchOperation[]): {
248
+ result: unknown;
249
+ } | {
250
+ error: string;
251
+ };
252
+ /**
253
+ * Convenience wrapper: diffs two JSON documents given as strings and
254
+ * returns the generated RFC 6902 patch, or a parse error.
255
+ */
256
+ declare function generateJsonPatch(aJson: string, bJson: string): {
257
+ patch: JsonPatchOperation[];
258
+ } | {
259
+ error: string;
260
+ };
223
261
 
224
262
  type json_ConvertOptions = ConvertOptions;
225
263
  type json_CsvOptions = CsvOptions;
@@ -229,6 +267,8 @@ type json_GoField = GoField;
229
267
  type json_GoStruct = GoStruct;
230
268
  type json_JsonDiffResult = JsonDiffResult;
231
269
  type json_JsonParseResult = JsonParseResult;
270
+ type json_JsonPatchOp = JsonPatchOp;
271
+ type json_JsonPatchOperation = JsonPatchOperation;
232
272
  type json_JsonPathResult = JsonPathResult;
233
273
  type json_JsonPointerResult = JsonPointerResult;
234
274
  type json_JsonSchemaLike = JsonSchemaLike;
@@ -242,13 +282,16 @@ type json_ValidationError = ValidationError;
242
282
  type json_ValidationResult = ValidationResult;
243
283
  type json_ZodOptions = ZodOptions;
244
284
  declare const json_applyJsonMergePatch: typeof applyJsonMergePatch;
285
+ declare const json_applyJsonPatch: typeof applyJsonPatch;
245
286
  declare const json_csvToJson: typeof csvToJson;
246
287
  declare const json_detectFormat: typeof detectFormat;
247
288
  declare const json_diffJson: typeof diffJson;
289
+ declare const json_diffJsonPatch: typeof diffJsonPatch;
248
290
  declare const json_evaluateJsonPath: typeof evaluateJsonPath;
249
291
  declare const json_formatDiffLine: typeof formatDiffLine;
250
292
  declare const json_formatJson: typeof formatJson;
251
293
  declare const json_generateExample: typeof generateExample;
294
+ declare const json_generateJsonPatch: typeof generateJsonPatch;
252
295
  declare const json_getJsonStats: typeof getJsonStats;
253
296
  declare const json_inferGoType: typeof inferGoType;
254
297
  declare const json_inferPythonType: typeof inferPythonType;
@@ -272,7 +315,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
272
315
  declare const json_validateJsonString: typeof validateJsonString;
273
316
  declare const json_yamlToJson: typeof yamlToJson;
274
317
  declare namespace json {
275
- export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_JsonSchemaLike as JsonSchemaLike, type json_JsonSchemaToTsOptions as JsonSchemaToTsOptions, type json_MergePatchResult as MergePatchResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_applyJsonMergePatch as applyJsonMergePatch, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonSchemaToTypescript as jsonSchemaToTypescript, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_mergeJsonPatch as mergeJsonPatch, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
318
+ export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPatchOp as JsonPatchOp, type json_JsonPatchOperation as JsonPatchOperation, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_JsonSchemaLike as JsonSchemaLike, type json_JsonSchemaToTsOptions as JsonSchemaToTsOptions, type json_MergePatchResult as MergePatchResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_applyJsonMergePatch as applyJsonMergePatch, json_applyJsonPatch as applyJsonPatch, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_diffJsonPatch as diffJsonPatch, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_generateJsonPatch as generateJsonPatch, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonSchemaToTypescript as jsonSchemaToTypescript, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_mergeJsonPatch as mergeJsonPatch, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
276
319
  }
277
320
 
278
- export { jsonToCsv as A, jsonToGo as B, type ConvertOptions as C, type DiffNode as D, jsonToPython as E, jsonToTypescript as F, type GoField as G, jsonToYaml as H, jsonToZod as I, type JsonDiffResult as J, mergeJsonPatch as K, minifyJson as L, type MergePatchResult as M, parseJson as N, parseStructs as O, type ParseStatus as P, resolveJsonPointer as Q, toPascalCase as R, toSnakeCase as S, validateJson as T, validateJsonPath as U, type ValidationError as V, validateJsonString as W, yamlToJson as X, type ZodOptions as Z, type CsvOptions as a, type DiffType as b, type GoStruct as c, type JsonParseResult as d, type JsonPathResult as e, type JsonPointerResult as f, type JsonSchemaLike as g, type JsonSchemaToTsOptions as h, type PythonClass as i, json as j, type PythonField as k, type PythonMode as l, type ValidationResult as m, applyJsonMergePatch as n, csvToJson as o, detectFormat as p, diffJson as q, evaluateJsonPath as r, formatDiffLine as s, formatJson as t, generateExample as u, getJsonStats as v, inferGoType as w, inferPythonType as x, inferType as y, jsonSchemaToTypescript as z };
321
+ export { validateJsonPath as $, getJsonStats as A, inferGoType as B, type ConvertOptions as C, type DiffNode as D, inferPythonType as E, inferType as F, type GoField as G, jsonSchemaToTypescript as H, jsonToCsv as I, type JsonDiffResult as J, jsonToGo as K, jsonToPython as L, type MergePatchResult as M, jsonToTypescript as N, jsonToYaml as O, type ParseStatus as P, jsonToZod as Q, mergeJsonPatch as R, minifyJson as S, parseJson as T, parseStructs as U, type ValidationError as V, resolveJsonPointer as W, toPascalCase as X, toSnakeCase as Y, type ZodOptions as Z, validateJson as _, type CsvOptions as a, validateJsonString as a0, yamlToJson as a1, type DiffType as b, type GoStruct as c, type JsonParseResult as d, type JsonPatchOp as e, type JsonPatchOperation as f, type JsonPathResult as g, type JsonPointerResult as h, type JsonSchemaLike as i, json as j, type JsonSchemaToTsOptions as k, type PythonClass as l, type PythonField as m, type PythonMode as n, type ValidationResult as o, applyJsonMergePatch as p, applyJsonPatch as q, csvToJson as r, detectFormat as s, diffJson as t, diffJsonPatch as u, evaluateJsonPath as v, formatDiffLine as w, formatJson as x, generateExample as y, generateJsonPatch as z };
@@ -1081,8 +1081,65 @@ function lintToolSchema(jsonText) {
1081
1081
  const valid = !issues.some((i) => i.severity === "error");
1082
1082
  return { toolCount: normalized.length, issues, valid };
1083
1083
  }
1084
+ function calculateRetryBackoffSchedule(input) {
1085
+ const { baseDelayMs, multiplier, maxRetries, maxDelayMs, jitter = "none" } = input;
1086
+ if (!Number.isFinite(baseDelayMs) || baseDelayMs <= 0) {
1087
+ return { error: "baseDelayMs must be a finite number greater than zero" };
1088
+ }
1089
+ if (!Number.isFinite(multiplier) || multiplier < 1) {
1090
+ return { error: "multiplier must be a finite number of at least 1" };
1091
+ }
1092
+ if (!Number.isInteger(maxRetries) || maxRetries < 1 || maxRetries > 50) {
1093
+ return { error: "maxRetries must be a whole number between 1 and 50" };
1094
+ }
1095
+ if (maxDelayMs !== void 0 && maxDelayMs !== null) {
1096
+ if (!Number.isFinite(maxDelayMs) || maxDelayMs <= 0) {
1097
+ return { error: "maxDelayMs must be a finite number greater than zero when provided" };
1098
+ }
1099
+ }
1100
+ if (jitter !== "none" && jitter !== "full" && jitter !== "equal") {
1101
+ return { error: "jitter must be one of 'none', 'full', or 'equal'" };
1102
+ }
1103
+ const round0 = (n) => Math.round(n);
1104
+ const attempts = [];
1105
+ let totalBestCaseMs = 0;
1106
+ let totalWorstCaseMs = 0;
1107
+ for (let i = 1; i <= maxRetries; i++) {
1108
+ let nominal = baseDelayMs * Math.pow(multiplier, i - 1);
1109
+ if (maxDelayMs !== void 0 && maxDelayMs !== null) {
1110
+ nominal = Math.min(nominal, maxDelayMs);
1111
+ }
1112
+ let minDelay;
1113
+ let maxDelay;
1114
+ if (jitter === "full") {
1115
+ minDelay = 0;
1116
+ maxDelay = nominal;
1117
+ } else if (jitter === "equal") {
1118
+ minDelay = nominal / 2;
1119
+ maxDelay = nominal;
1120
+ } else {
1121
+ minDelay = nominal;
1122
+ maxDelay = nominal;
1123
+ }
1124
+ attempts.push({
1125
+ attempt: i,
1126
+ nominalDelayMs: round0(nominal),
1127
+ minDelayMs: round0(minDelay),
1128
+ maxDelayMs: round0(maxDelay)
1129
+ });
1130
+ totalBestCaseMs += minDelay;
1131
+ totalWorstCaseMs += maxDelay;
1132
+ }
1133
+ return {
1134
+ attempts,
1135
+ jitter,
1136
+ totalBestCaseMs: round0(totalBestCaseMs),
1137
+ totalWorstCaseMs: round0(totalWorstCaseMs)
1138
+ };
1139
+ }
1084
1140
 
1085
1141
  exports.MODEL_PRICING = MODEL_PRICING;
1142
+ exports.calculateRetryBackoffSchedule = calculateRetryBackoffSchedule;
1086
1143
  exports.chunkText = chunkText;
1087
1144
  exports.compressHtml = compressHtml;
1088
1145
  exports.compressJson = compressJson;
@@ -1 +1 @@
1
- export { C as ChunkStrategy, b as CompressHtmlResult, c as CompressJsonResult, d as CompressMarkdownResult, e as CostEstimate, D as DedupeResult, f as DedupeStrategy, g as DiffEntry2, h as DiffOp2, i as DiffResult2, E as Entity2, j as EntityType2, k as ExtractJsonResult, l as ExtractKeywordsResult, m as ExtractUrlsResult, F as FewShotExample, n as FewShotFormat, o as FewShotFormatResult, I as InjectionDetectResult, p as InjectionFinding, J as JsonBlock, q as JsonRepairResult, K as Keyword, M as MODEL_PRICING, r as MergeResult, s as MergeStrategy, t as ModelPricing, P as PiiDetectResult, u as PiiFinding, v as PiiType, R as RankedChunk, w as RelevanceResult, S as SanitizeResult, x as SecretDetectResult, y as SecretFinding, z as SecretType, A as SummaryResult, T as TableResult2, B as TextChunk, G as TokenEstimate, H as TokenEstimateResult, L as ToolSchemaIssue, N as ToolSchemaLintResult, O as TrimResult, Q as TrimStrategy, U as UrlMatch, V as ValidationError, W as ValidationResult, X as VectorSimilarityResult, Y as chunkText, Z as compressHtml, _ as compressJson, $ as compressMarkdown, a0 as deduplicateLines, a1 as detectPii, a2 as detectPromptInjection, a3 as detectSecrets, a4 as diffJson, a5 as estimateCost, a6 as estimateTokens, a7 as expandQuery, a8 as extractEntities, a9 as extractJson, aa as extractKeywords, ab as extractTables, ac as extractUrls, ad as flattenJson, ae as formatFewShotExamples, af as lintToolSchema, ag as mergeJson, ah as redactPii, ai as repairJson, aj as rerankChunks, ak as sanitizeHtml, al as scoreRelevance, am as summarizeForLlm, an as trimToTokens, ao as unflattenJson, ap as validateJsonSchema, aq as vectorSimilarity } from '../ai_agent-CmrVjvYH.cjs';
1
+ export { C as ChunkStrategy, b as CompressHtmlResult, c as CompressJsonResult, d as CompressMarkdownResult, e as CostEstimate, D as DedupeResult, f as DedupeStrategy, g as DiffEntry2, h as DiffOp2, i as DiffResult2, E as Entity2, j as EntityType2, k as ExtractJsonResult, l as ExtractKeywordsResult, m as ExtractUrlsResult, F as FewShotExample, n as FewShotFormat, o as FewShotFormatResult, I as InjectionDetectResult, p as InjectionFinding, J as JsonBlock, q as JsonRepairResult, K as Keyword, M as MODEL_PRICING, r as MergeResult, s as MergeStrategy, t as ModelPricing, P as PiiDetectResult, u as PiiFinding, v as PiiType, R as RankedChunk, w as RelevanceResult, x as RetryBackoffAttempt, y as RetryBackoffInput, z as RetryBackoffResult, A as RetryJitterMode, S as SanitizeResult, B as SecretDetectResult, G as SecretFinding, H as SecretType, L as SummaryResult, T as TableResult2, N as TextChunk, O as TokenEstimate, Q as TokenEstimateResult, U as ToolSchemaIssue, V as ToolSchemaLintResult, W as TrimResult, X as TrimStrategy, Y as UrlMatch, Z as ValidationError, _ as ValidationResult, $ as VectorSimilarityResult, a0 as calculateRetryBackoffSchedule, a1 as chunkText, a2 as compressHtml, a3 as compressJson, a4 as compressMarkdown, a5 as deduplicateLines, a6 as detectPii, a7 as detectPromptInjection, a8 as detectSecrets, a9 as diffJson, aa as estimateCost, ab as estimateTokens, ac as expandQuery, ad as extractEntities, ae as extractJson, af as extractKeywords, ag as extractTables, ah as extractUrls, ai as flattenJson, aj as formatFewShotExamples, ak as lintToolSchema, al as mergeJson, am as redactPii, an as repairJson, ao as rerankChunks, ap as sanitizeHtml, aq as scoreRelevance, ar as summarizeForLlm, as as trimToTokens, at as unflattenJson, au as validateJsonSchema, av as vectorSimilarity } from '../ai_agent-DeCy0oZK.cjs';
@@ -1 +1 @@
1
- export { C as ChunkStrategy, b as CompressHtmlResult, c as CompressJsonResult, d as CompressMarkdownResult, e as CostEstimate, D as DedupeResult, f as DedupeStrategy, g as DiffEntry2, h as DiffOp2, i as DiffResult2, E as Entity2, j as EntityType2, k as ExtractJsonResult, l as ExtractKeywordsResult, m as ExtractUrlsResult, F as FewShotExample, n as FewShotFormat, o as FewShotFormatResult, I as InjectionDetectResult, p as InjectionFinding, J as JsonBlock, q as JsonRepairResult, K as Keyword, M as MODEL_PRICING, r as MergeResult, s as MergeStrategy, t as ModelPricing, P as PiiDetectResult, u as PiiFinding, v as PiiType, R as RankedChunk, w as RelevanceResult, S as SanitizeResult, x as SecretDetectResult, y as SecretFinding, z as SecretType, A as SummaryResult, T as TableResult2, B as TextChunk, G as TokenEstimate, H as TokenEstimateResult, L as ToolSchemaIssue, N as ToolSchemaLintResult, O as TrimResult, Q as TrimStrategy, U as UrlMatch, V as ValidationError, W as ValidationResult, X as VectorSimilarityResult, Y as chunkText, Z as compressHtml, _ as compressJson, $ as compressMarkdown, a0 as deduplicateLines, a1 as detectPii, a2 as detectPromptInjection, a3 as detectSecrets, a4 as diffJson, a5 as estimateCost, a6 as estimateTokens, a7 as expandQuery, a8 as extractEntities, a9 as extractJson, aa as extractKeywords, ab as extractTables, ac as extractUrls, ad as flattenJson, ae as formatFewShotExamples, af as lintToolSchema, ag as mergeJson, ah as redactPii, ai as repairJson, aj as rerankChunks, ak as sanitizeHtml, al as scoreRelevance, am as summarizeForLlm, an as trimToTokens, ao as unflattenJson, ap as validateJsonSchema, aq as vectorSimilarity } from '../ai_agent-CmrVjvYH.js';
1
+ export { C as ChunkStrategy, b as CompressHtmlResult, c as CompressJsonResult, d as CompressMarkdownResult, e as CostEstimate, D as DedupeResult, f as DedupeStrategy, g as DiffEntry2, h as DiffOp2, i as DiffResult2, E as Entity2, j as EntityType2, k as ExtractJsonResult, l as ExtractKeywordsResult, m as ExtractUrlsResult, F as FewShotExample, n as FewShotFormat, o as FewShotFormatResult, I as InjectionDetectResult, p as InjectionFinding, J as JsonBlock, q as JsonRepairResult, K as Keyword, M as MODEL_PRICING, r as MergeResult, s as MergeStrategy, t as ModelPricing, P as PiiDetectResult, u as PiiFinding, v as PiiType, R as RankedChunk, w as RelevanceResult, x as RetryBackoffAttempt, y as RetryBackoffInput, z as RetryBackoffResult, A as RetryJitterMode, S as SanitizeResult, B as SecretDetectResult, G as SecretFinding, H as SecretType, L as SummaryResult, T as TableResult2, N as TextChunk, O as TokenEstimate, Q as TokenEstimateResult, U as ToolSchemaIssue, V as ToolSchemaLintResult, W as TrimResult, X as TrimStrategy, Y as UrlMatch, Z as ValidationError, _ as ValidationResult, $ as VectorSimilarityResult, a0 as calculateRetryBackoffSchedule, a1 as chunkText, a2 as compressHtml, a3 as compressJson, a4 as compressMarkdown, a5 as deduplicateLines, a6 as detectPii, a7 as detectPromptInjection, a8 as detectSecrets, a9 as diffJson, aa as estimateCost, ab as estimateTokens, ac as expandQuery, ad as extractEntities, ae as extractJson, af as extractKeywords, ag as extractTables, ah as extractUrls, ai as flattenJson, aj as formatFewShotExamples, ak as lintToolSchema, al as mergeJson, am as redactPii, an as repairJson, ao as rerankChunks, ap as sanitizeHtml, aq as scoreRelevance, ar as summarizeForLlm, as as trimToTokens, at as unflattenJson, au as validateJsonSchema, av as vectorSimilarity } from '../ai_agent-DeCy0oZK.js';
@@ -1,2 +1,2 @@
1
- export { MODEL_PRICING, chunkText, compressHtml, compressJson, compressMarkdown, deduplicateLines, detectPii, detectPromptInjection, detectSecrets, diffJson, estimateCost, estimateTokens, expandQuery, extractEntities, extractJson, extractKeywords, extractTables, extractUrls, flattenJson, formatFewShotExamples, lintToolSchema, mergeJson, redactPii, repairJson, rerankChunks, sanitizeHtml, scoreRelevance, summarizeForLlm, trimToTokens, unflattenJson, validateJsonSchema, vectorSimilarity } from '../chunk-EKIXOA7B.js';
1
+ export { MODEL_PRICING, calculateRetryBackoffSchedule, chunkText, compressHtml, compressJson, compressMarkdown, deduplicateLines, detectPii, detectPromptInjection, detectSecrets, diffJson, estimateCost, estimateTokens, expandQuery, extractEntities, extractJson, extractKeywords, extractTables, extractUrls, flattenJson, formatFewShotExamples, lintToolSchema, mergeJson, redactPii, repairJson, rerankChunks, sanitizeHtml, scoreRelevance, summarizeForLlm, trimToTokens, unflattenJson, validateJsonSchema, vectorSimilarity } from '../chunk-HJLGUNSO.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -3813,6 +3813,53 @@ function validateAria(html) {
3813
3813
  valid: issues.every((i) => i.severity !== "error")
3814
3814
  };
3815
3815
  }
3816
+ var CONNECTION_STRING_RE = /^([a-zA-Z][a-zA-Z0-9+.-]*):\/\/(?:([^@/?#]*)@)?([^/?#]*)(?:\/([^?#]*))?(?:\?([^#]*))?$/;
3817
+ function _parseConnectionHost(segment) {
3818
+ const ipv6Match = segment.match(/^\[([^\]]+)\](?::(\d+))?$/);
3819
+ if (ipv6Match) {
3820
+ return { host: ipv6Match[1], port: ipv6Match[2] ? parseInt(ipv6Match[2], 10) : null };
3821
+ }
3822
+ const lastColon = segment.lastIndexOf(":");
3823
+ if (lastColon === -1) return { host: segment, port: null };
3824
+ const portPart = segment.slice(lastColon + 1);
3825
+ if (!/^\d+$/.test(portPart)) return { host: segment, port: null };
3826
+ return { host: segment.slice(0, lastColon), port: parseInt(portPart, 10) };
3827
+ }
3828
+ function parseConnectionString(input) {
3829
+ if (!input || typeof input !== "string" || !input.trim()) {
3830
+ return { error: "Connection string is empty" };
3831
+ }
3832
+ const trimmed = input.trim();
3833
+ const match = trimmed.match(CONNECTION_STRING_RE);
3834
+ if (!match) {
3835
+ return { error: "Not a valid scheme://[user[:password]@]host[,host2][/database][?params] connection string" };
3836
+ }
3837
+ const [, scheme, userinfo, hostPart, databasePart, queryPart] = match;
3838
+ let user = null;
3839
+ let password = null;
3840
+ if (userinfo) {
3841
+ const sepIndex = userinfo.indexOf(":");
3842
+ if (sepIndex === -1) {
3843
+ user = decodeURIComponent(userinfo);
3844
+ } else {
3845
+ user = decodeURIComponent(userinfo.slice(0, sepIndex));
3846
+ password = decodeURIComponent(userinfo.slice(sepIndex + 1));
3847
+ }
3848
+ }
3849
+ const hosts = hostPart ? hostPart.split(",").filter(Boolean).map(_parseConnectionHost) : [];
3850
+ const database = databasePart ? decodeURIComponent(databasePart) : null;
3851
+ const params = {};
3852
+ if (queryPart) {
3853
+ for (const pair of queryPart.split("&")) {
3854
+ if (!pair) continue;
3855
+ const eqIndex = pair.indexOf("=");
3856
+ const key = eqIndex === -1 ? pair : pair.slice(0, eqIndex);
3857
+ const value = eqIndex === -1 ? "" : pair.slice(eqIndex + 1);
3858
+ params[decodeURIComponent(key)] = decodeURIComponent(value);
3859
+ }
3860
+ }
3861
+ return { scheme, user, password, hosts, database, params };
3862
+ }
3816
3863
 
3817
3864
  exports.ALL_FLAGS = ALL_FLAGS;
3818
3865
  exports.CHEATSHEET = CHEATSHEET;
@@ -3854,6 +3901,7 @@ exports.minifyJs = minifyJs;
3854
3901
  exports.minifySql = minifySql;
3855
3902
  exports.normalizeRef = normalizeRef;
3856
3903
  exports.parseCommitTrailers = parseCommitTrailers;
3904
+ exports.parseConnectionString = parseConnectionString;
3857
3905
  exports.parseDockerImage = parseDockerImage;
3858
3906
  exports.parseEnv = parseEnv;
3859
3907
  exports.parseGitCommand = parseGitCommand;
@@ -1 +1 @@
1
- export { A as ALL_FLAGS, a as ApiEndpoint, b as ApiInfo, d as AriaIssue, e as AriaValidationResult, C as CHEATSHEET, f as CheatsheetEntry, g as CommitTrailer, h as CommitTrailerResult, i as ConventionalCommitFinding, j as ConventionalCommitFooter, k as ConventionalCommitOptions, l as ConventionalCommitParsed, m as ConventionalCommitResult, n as ConventionalCommitSeverity, o as CssResult, D as DEFAULT_COMMIT_TYPES, p as DependencyAuditDuplicate, q as DependencyAuditEntry, r as DependencyAuditIssue, s as DependencyAuditResult, t as DependencyRangeType, u as DependencySection, v as DockerImageRef, E as EditorConfigIssue, w as EditorConfigProperty, x as EditorConfigSection, y as EditorConfigValidationResult, z as EnvEntry, B as EnvParseResult, F as ExportsIssue, G as ExportsShape, H as ExportsValidationResult, I as GitCommandConfig, J as GitCommandResult, K as GitOperation, L as GithubUrlInfo, M as GithubUrlType, N as GitignoreTestResult, O as GqlFormatResult, P as HtmlFormatResult, Q as HtmlMinifyOptions, R as HtmlMinifyResult, S as JsMinifyOptions, T as JsMinifyResult, U as MIME_TABLE, V as MarkdownFootnoteDefinition, W as MarkdownFootnoteReference, X as MarkdownFootnoteResult, Y as MatchResult, Z as MimeEntry, _ as MimeLookupResult, $ as OPERATIONS, a0 as ParsedSpec, a1 as RedosFinding, a2 as RedosResult, a3 as RedosSeverity, a4 as RegexBackreferenceInfo, a5 as RegexError, a6 as RegexFlag, a7 as RegexGroupAnalysis, a8 as RegexGroupInfo, a9 as RegexGroupIssue, aa as RegexMatch, ab as RegexResult, ac as RegexSuccess, ad as SQL_DEFAULT_OPTIONS, ae as Segment, af as SpecVersion, ag as SqlDialect, ah as SqlFormatOptions, ai as SvgSpriteResult, aj as SvgSpriteSymbol, ak as TestPatternResult, al as TsconfigIssue, am as TsconfigValidationResult, an as analyzeRegexGroups, ao as auditDependencyRanges, ap as buildDockerPull, aq as buildDockerRun, ar as buildGitCommand, as as collapseHtmlWhitespace, at as collapseJsWhitespace, au as countProperties, av as countRules, aw as detectDialect, ax as detectOperationType, ay as detectRedos, az as envToExport, aA as envToJson, aB as extractMarkdownFootnotes, aC as extractSvgSpriteSymbols, aD as formatCss, aE as formatGql, aF as formatHtml, aG as formatSql, aH as getEndpointsByTag, aI as getHtmlStats, aJ as getJsStats, aK as getMethodColor, aL as isValidTag, aM as lintConventionalCommit, aN as lookupMime, aO as minifyCss, aP as minifyGql, aQ as minifyHtml, aR as minifyJs, aS as minifySql, aT as normalizeRef, aU as parseCommitTrailers, aV as parseDockerImage, aW as parseEnv, aX as parseGitCommand, aY as parseGithubUrl, aZ as parseSpec, a_ as removeConsoleCalls, a$ as removeEmptyAttributes, b0 as removeHtmlComments, b1 as removeJsComments, b2 as removeRedundantAttributes, b3 as searchCheatsheet, b4 as searchEndpoints, b5 as splitStatements, b6 as testGitignorePatterns, b7 as testPattern, b8 as testRegex, b9 as validateAria, ba as validateEditorConfig, bb as validateEnvKey, bc as validatePackageExports, bd as validateTsconfig } from '../code-46xO9xFf.cjs';
1
+ export { A as ALL_FLAGS, a as ApiEndpoint, b as ApiInfo, d as AriaIssue, e as AriaValidationResult, C as CHEATSHEET, f as CheatsheetEntry, g as CommitTrailer, h as CommitTrailerResult, i as ConnectionStringHost, j as ConnectionStringResult, k as ConventionalCommitFinding, l as ConventionalCommitFooter, m as ConventionalCommitOptions, n as ConventionalCommitParsed, o as ConventionalCommitResult, p as ConventionalCommitSeverity, q as CssResult, D as DEFAULT_COMMIT_TYPES, r as DependencyAuditDuplicate, s as DependencyAuditEntry, t as DependencyAuditIssue, u as DependencyAuditResult, v as DependencyRangeType, w as DependencySection, x as DockerImageRef, E as EditorConfigIssue, y as EditorConfigProperty, z as EditorConfigSection, B as EditorConfigValidationResult, F as EnvEntry, G as EnvParseResult, H as ExportsIssue, I as ExportsShape, J as ExportsValidationResult, K as GitCommandConfig, L as GitCommandResult, M as GitOperation, N as GithubUrlInfo, O as GithubUrlType, P as GitignoreTestResult, Q as GqlFormatResult, R as HtmlFormatResult, S as HtmlMinifyOptions, T as HtmlMinifyResult, U as JsMinifyOptions, V as JsMinifyResult, W as MIME_TABLE, X as MarkdownFootnoteDefinition, Y as MarkdownFootnoteReference, Z as MarkdownFootnoteResult, _ as MatchResult, $ as MimeEntry, a0 as MimeLookupResult, a1 as OPERATIONS, a2 as ParsedSpec, a3 as RedosFinding, a4 as RedosResult, a5 as RedosSeverity, a6 as RegexBackreferenceInfo, a7 as RegexError, a8 as RegexFlag, a9 as RegexGroupAnalysis, aa as RegexGroupInfo, ab as RegexGroupIssue, ac as RegexMatch, ad as RegexResult, ae as RegexSuccess, af as SQL_DEFAULT_OPTIONS, ag as Segment, ah as SpecVersion, ai as SqlDialect, aj as SqlFormatOptions, ak as SvgSpriteResult, al as SvgSpriteSymbol, am as TestPatternResult, an as TsconfigIssue, ao as TsconfigValidationResult, ap as analyzeRegexGroups, aq as auditDependencyRanges, ar as buildDockerPull, as as buildDockerRun, at as buildGitCommand, au as collapseHtmlWhitespace, av as collapseJsWhitespace, aw as countProperties, ax as countRules, ay as detectDialect, az as detectOperationType, aA as detectRedos, aB as envToExport, aC as envToJson, aD as extractMarkdownFootnotes, aE as extractSvgSpriteSymbols, aF as formatCss, aG as formatGql, aH as formatHtml, aI as formatSql, aJ as getEndpointsByTag, aK as getHtmlStats, aL as getJsStats, aM as getMethodColor, aN as isValidTag, aO as lintConventionalCommit, aP as lookupMime, aQ as minifyCss, aR as minifyGql, aS as minifyHtml, aT as minifyJs, aU as minifySql, aV as normalizeRef, aW as parseCommitTrailers, aX as parseConnectionString, aY as parseDockerImage, aZ as parseEnv, a_ as parseGitCommand, a$ as parseGithubUrl, b0 as parseSpec, b1 as removeConsoleCalls, b2 as removeEmptyAttributes, b3 as removeHtmlComments, b4 as removeJsComments, b5 as removeRedundantAttributes, b6 as searchCheatsheet, b7 as searchEndpoints, b8 as splitStatements, b9 as testGitignorePatterns, ba as testPattern, bb as testRegex, bc as validateAria, bd as validateEditorConfig, be as validateEnvKey, bf as validatePackageExports, bg as validateTsconfig } from '../code-C4n621_i.cjs';
@@ -1 +1 @@
1
- export { A as ALL_FLAGS, a as ApiEndpoint, b as ApiInfo, d as AriaIssue, e as AriaValidationResult, C as CHEATSHEET, f as CheatsheetEntry, g as CommitTrailer, h as CommitTrailerResult, i as ConventionalCommitFinding, j as ConventionalCommitFooter, k as ConventionalCommitOptions, l as ConventionalCommitParsed, m as ConventionalCommitResult, n as ConventionalCommitSeverity, o as CssResult, D as DEFAULT_COMMIT_TYPES, p as DependencyAuditDuplicate, q as DependencyAuditEntry, r as DependencyAuditIssue, s as DependencyAuditResult, t as DependencyRangeType, u as DependencySection, v as DockerImageRef, E as EditorConfigIssue, w as EditorConfigProperty, x as EditorConfigSection, y as EditorConfigValidationResult, z as EnvEntry, B as EnvParseResult, F as ExportsIssue, G as ExportsShape, H as ExportsValidationResult, I as GitCommandConfig, J as GitCommandResult, K as GitOperation, L as GithubUrlInfo, M as GithubUrlType, N as GitignoreTestResult, O as GqlFormatResult, P as HtmlFormatResult, Q as HtmlMinifyOptions, R as HtmlMinifyResult, S as JsMinifyOptions, T as JsMinifyResult, U as MIME_TABLE, V as MarkdownFootnoteDefinition, W as MarkdownFootnoteReference, X as MarkdownFootnoteResult, Y as MatchResult, Z as MimeEntry, _ as MimeLookupResult, $ as OPERATIONS, a0 as ParsedSpec, a1 as RedosFinding, a2 as RedosResult, a3 as RedosSeverity, a4 as RegexBackreferenceInfo, a5 as RegexError, a6 as RegexFlag, a7 as RegexGroupAnalysis, a8 as RegexGroupInfo, a9 as RegexGroupIssue, aa as RegexMatch, ab as RegexResult, ac as RegexSuccess, ad as SQL_DEFAULT_OPTIONS, ae as Segment, af as SpecVersion, ag as SqlDialect, ah as SqlFormatOptions, ai as SvgSpriteResult, aj as SvgSpriteSymbol, ak as TestPatternResult, al as TsconfigIssue, am as TsconfigValidationResult, an as analyzeRegexGroups, ao as auditDependencyRanges, ap as buildDockerPull, aq as buildDockerRun, ar as buildGitCommand, as as collapseHtmlWhitespace, at as collapseJsWhitespace, au as countProperties, av as countRules, aw as detectDialect, ax as detectOperationType, ay as detectRedos, az as envToExport, aA as envToJson, aB as extractMarkdownFootnotes, aC as extractSvgSpriteSymbols, aD as formatCss, aE as formatGql, aF as formatHtml, aG as formatSql, aH as getEndpointsByTag, aI as getHtmlStats, aJ as getJsStats, aK as getMethodColor, aL as isValidTag, aM as lintConventionalCommit, aN as lookupMime, aO as minifyCss, aP as minifyGql, aQ as minifyHtml, aR as minifyJs, aS as minifySql, aT as normalizeRef, aU as parseCommitTrailers, aV as parseDockerImage, aW as parseEnv, aX as parseGitCommand, aY as parseGithubUrl, aZ as parseSpec, a_ as removeConsoleCalls, a$ as removeEmptyAttributes, b0 as removeHtmlComments, b1 as removeJsComments, b2 as removeRedundantAttributes, b3 as searchCheatsheet, b4 as searchEndpoints, b5 as splitStatements, b6 as testGitignorePatterns, b7 as testPattern, b8 as testRegex, b9 as validateAria, ba as validateEditorConfig, bb as validateEnvKey, bc as validatePackageExports, bd as validateTsconfig } from '../code-46xO9xFf.js';
1
+ export { A as ALL_FLAGS, a as ApiEndpoint, b as ApiInfo, d as AriaIssue, e as AriaValidationResult, C as CHEATSHEET, f as CheatsheetEntry, g as CommitTrailer, h as CommitTrailerResult, i as ConnectionStringHost, j as ConnectionStringResult, k as ConventionalCommitFinding, l as ConventionalCommitFooter, m as ConventionalCommitOptions, n as ConventionalCommitParsed, o as ConventionalCommitResult, p as ConventionalCommitSeverity, q as CssResult, D as DEFAULT_COMMIT_TYPES, r as DependencyAuditDuplicate, s as DependencyAuditEntry, t as DependencyAuditIssue, u as DependencyAuditResult, v as DependencyRangeType, w as DependencySection, x as DockerImageRef, E as EditorConfigIssue, y as EditorConfigProperty, z as EditorConfigSection, B as EditorConfigValidationResult, F as EnvEntry, G as EnvParseResult, H as ExportsIssue, I as ExportsShape, J as ExportsValidationResult, K as GitCommandConfig, L as GitCommandResult, M as GitOperation, N as GithubUrlInfo, O as GithubUrlType, P as GitignoreTestResult, Q as GqlFormatResult, R as HtmlFormatResult, S as HtmlMinifyOptions, T as HtmlMinifyResult, U as JsMinifyOptions, V as JsMinifyResult, W as MIME_TABLE, X as MarkdownFootnoteDefinition, Y as MarkdownFootnoteReference, Z as MarkdownFootnoteResult, _ as MatchResult, $ as MimeEntry, a0 as MimeLookupResult, a1 as OPERATIONS, a2 as ParsedSpec, a3 as RedosFinding, a4 as RedosResult, a5 as RedosSeverity, a6 as RegexBackreferenceInfo, a7 as RegexError, a8 as RegexFlag, a9 as RegexGroupAnalysis, aa as RegexGroupInfo, ab as RegexGroupIssue, ac as RegexMatch, ad as RegexResult, ae as RegexSuccess, af as SQL_DEFAULT_OPTIONS, ag as Segment, ah as SpecVersion, ai as SqlDialect, aj as SqlFormatOptions, ak as SvgSpriteResult, al as SvgSpriteSymbol, am as TestPatternResult, an as TsconfigIssue, ao as TsconfigValidationResult, ap as analyzeRegexGroups, aq as auditDependencyRanges, ar as buildDockerPull, as as buildDockerRun, at as buildGitCommand, au as collapseHtmlWhitespace, av as collapseJsWhitespace, aw as countProperties, ax as countRules, ay as detectDialect, az as detectOperationType, aA as detectRedos, aB as envToExport, aC as envToJson, aD as extractMarkdownFootnotes, aE as extractSvgSpriteSymbols, aF as formatCss, aG as formatGql, aH as formatHtml, aI as formatSql, aJ as getEndpointsByTag, aK as getHtmlStats, aL as getJsStats, aM as getMethodColor, aN as isValidTag, aO as lintConventionalCommit, aP as lookupMime, aQ as minifyCss, aR as minifyGql, aS as minifyHtml, aT as minifyJs, aU as minifySql, aV as normalizeRef, aW as parseCommitTrailers, aX as parseConnectionString, aY as parseDockerImage, aZ as parseEnv, a_ as parseGitCommand, a$ as parseGithubUrl, b0 as parseSpec, b1 as removeConsoleCalls, b2 as removeEmptyAttributes, b3 as removeHtmlComments, b4 as removeJsComments, b5 as removeRedundantAttributes, b6 as searchCheatsheet, b7 as searchEndpoints, b8 as splitStatements, b9 as testGitignorePatterns, ba as testPattern, bb as testRegex, bc as validateAria, bd as validateEditorConfig, be as validateEnvKey, bf as validatePackageExports, bg as validateTsconfig } from '../code-C4n621_i.js';
@@ -1,2 +1,2 @@
1
- export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, analyzeRegexGroups, auditDependencyRanges, buildDockerPull, buildDockerRun, buildGitCommand, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, extractMarkdownFootnotes, extractSvgSpriteSymbols, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseCommitTrailers, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testGitignorePatterns, testPattern, testRegex, validateAria, validateEditorConfig, validateEnvKey, validatePackageExports, validateTsconfig } from '../chunk-XT2BQWXT.js';
1
+ export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, analyzeRegexGroups, auditDependencyRanges, buildDockerPull, buildDockerRun, buildGitCommand, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, extractMarkdownFootnotes, extractSvgSpriteSymbols, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseCommitTrailers, parseConnectionString, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testGitignorePatterns, testPattern, testRegex, validateAria, validateEditorConfig, validateEnvKey, validatePackageExports, validateTsconfig } from '../chunk-RYSN5JNA.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -1423,15 +1423,231 @@ function applyJsonMergePatch(targetJson, patchJson) {
1423
1423
  }
1424
1424
  return { result: mergeJsonPatch(target, patch) };
1425
1425
  }
1426
+ function _escapeJsonPointerToken(token) {
1427
+ return token.replace(/~/g, "~0").replace(/\//g, "~1");
1428
+ }
1429
+ function _unescapeJsonPointerToken(token) {
1430
+ return token.replace(/~1/g, "/").replace(/~0/g, "~");
1431
+ }
1432
+ function _parseJsonPointer(pointer) {
1433
+ if (pointer === "") return [];
1434
+ if (!pointer.startsWith("/")) throw new Error(`Invalid JSON Pointer "${pointer}": must start with "/"`);
1435
+ return pointer.slice(1).split("/").map(_unescapeJsonPointerToken);
1436
+ }
1437
+ function _isPlainObject(value) {
1438
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1439
+ }
1440
+ function _deepEqual(a, b) {
1441
+ if (a === b) return true;
1442
+ if (typeof a !== typeof b) return false;
1443
+ if (Array.isArray(a) || Array.isArray(b)) {
1444
+ if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
1445
+ return a.every((v, i) => _deepEqual(v, b[i]));
1446
+ }
1447
+ if (_isPlainObject(a) && _isPlainObject(b)) {
1448
+ const aKeys = Object.keys(a);
1449
+ const bKeys = Object.keys(b);
1450
+ if (aKeys.length !== bKeys.length) return false;
1451
+ return aKeys.every((k) => k in b && _deepEqual(a[k], b[k]));
1452
+ }
1453
+ return false;
1454
+ }
1455
+ function _getByTokens(doc, tokens) {
1456
+ let current = doc;
1457
+ for (const token of tokens) {
1458
+ if (Array.isArray(current)) {
1459
+ const index = token === "-" ? current.length - 1 : parseInt(token, 10);
1460
+ if (!Number.isInteger(index) || index < 0 || index >= current.length) return { found: false, value: void 0 };
1461
+ current = current[index];
1462
+ } else if (_isPlainObject(current)) {
1463
+ if (!(token in current)) return { found: false, value: void 0 };
1464
+ current = current[token];
1465
+ } else {
1466
+ return { found: false, value: void 0 };
1467
+ }
1468
+ }
1469
+ return { found: true, value: current };
1470
+ }
1471
+ function diffJsonPatch(a, b) {
1472
+ const ops = [];
1473
+ _diffValue(a, b, "", ops);
1474
+ return ops;
1475
+ }
1476
+ function _diffValue(a, b, path, ops) {
1477
+ if (_deepEqual(a, b)) return;
1478
+ if (_isPlainObject(a) && _isPlainObject(b)) {
1479
+ for (const key of Object.keys(a)) {
1480
+ if (!(key in b)) ops.push({ op: "remove", path: `${path}/${_escapeJsonPointerToken(key)}` });
1481
+ }
1482
+ for (const key of Object.keys(b)) {
1483
+ const childPath = `${path}/${_escapeJsonPointerToken(key)}`;
1484
+ if (!(key in a)) {
1485
+ ops.push({ op: "add", path: childPath, value: b[key] });
1486
+ } else {
1487
+ _diffValue(a[key], b[key], childPath, ops);
1488
+ }
1489
+ }
1490
+ return;
1491
+ }
1492
+ if (Array.isArray(a) && Array.isArray(b)) {
1493
+ const minLen = Math.min(a.length, b.length);
1494
+ for (let i = 0; i < minLen; i++) {
1495
+ _diffValue(a[i], b[i], `${path}/${i}`, ops);
1496
+ }
1497
+ if (b.length > a.length) {
1498
+ for (let i = a.length; i < b.length; i++) ops.push({ op: "add", path: `${path}/${i}`, value: b[i] });
1499
+ } else if (a.length > b.length) {
1500
+ for (let i = a.length - 1; i >= b.length; i--) ops.push({ op: "remove", path: `${path}/${i}` });
1501
+ }
1502
+ return;
1503
+ }
1504
+ ops.push({ op: "replace", path, value: b });
1505
+ }
1506
+ function applyJsonPatch(target, operations) {
1507
+ let doc = JSON.parse(JSON.stringify(target ?? null));
1508
+ const applyOne = (op, index) => {
1509
+ if (op.path === void 0 || op.op === void 0) return `Operation ${index}: missing "op" or "path"`;
1510
+ let tokens;
1511
+ try {
1512
+ tokens = _parseJsonPointer(op.path);
1513
+ } catch (e) {
1514
+ return `Operation ${index}: ${e.message}`;
1515
+ }
1516
+ const setAt = (tgtTokens, value) => {
1517
+ if (tgtTokens.length === 0) {
1518
+ doc = value;
1519
+ return null;
1520
+ }
1521
+ const parentTokens = tgtTokens.slice(0, -1);
1522
+ const lastToken = tgtTokens[tgtTokens.length - 1];
1523
+ const { found, value: parent } = _getByTokens(doc, parentTokens);
1524
+ if (!found) return `Operation ${index}: path "${op.path}" has no parent`;
1525
+ if (Array.isArray(parent)) {
1526
+ const idx = lastToken === "-" ? parent.length : parseInt(lastToken, 10);
1527
+ if (!Number.isInteger(idx) || idx < 0 || idx > parent.length) return `Operation ${index}: array index "${lastToken}" out of bounds`;
1528
+ parent.splice(idx, 0, value);
1529
+ } else if (_isPlainObject(parent)) {
1530
+ parent[lastToken] = value;
1531
+ } else {
1532
+ return `Operation ${index}: cannot add into a non-object, non-array value at "${op.path}"`;
1533
+ }
1534
+ return null;
1535
+ };
1536
+ const replaceAt = (tgtTokens, value) => {
1537
+ if (tgtTokens.length === 0) {
1538
+ doc = value;
1539
+ return null;
1540
+ }
1541
+ const parentTokens = tgtTokens.slice(0, -1);
1542
+ const lastToken = tgtTokens[tgtTokens.length - 1];
1543
+ const { found, value: parent } = _getByTokens(doc, parentTokens);
1544
+ if (!found) return `Operation ${index}: path "${op.path}" has no parent`;
1545
+ if (Array.isArray(parent)) {
1546
+ const idx = lastToken === "-" ? parent.length - 1 : parseInt(lastToken, 10);
1547
+ if (!Number.isInteger(idx) || idx < 0 || idx >= parent.length) return `Operation ${index}: array index "${lastToken}" out of bounds`;
1548
+ parent[idx] = value;
1549
+ } else if (_isPlainObject(parent)) {
1550
+ if (!(lastToken in parent)) return `Operation ${index}: path "${op.path}" does not exist`;
1551
+ parent[lastToken] = value;
1552
+ } else {
1553
+ return `Operation ${index}: cannot replace into a non-object, non-array value at "${op.path}"`;
1554
+ }
1555
+ return null;
1556
+ };
1557
+ const removeAt = (tgtTokens) => {
1558
+ if (tgtTokens.length === 0) return { error: `Operation ${index}: cannot remove the whole document (path "")` };
1559
+ const parentTokens = tgtTokens.slice(0, -1);
1560
+ const lastToken = tgtTokens[tgtTokens.length - 1];
1561
+ const { found, value: parent } = _getByTokens(doc, parentTokens);
1562
+ if (!found) return { error: `Operation ${index}: path "${op.path}" has no parent` };
1563
+ if (Array.isArray(parent)) {
1564
+ const idx = lastToken === "-" ? parent.length - 1 : parseInt(lastToken, 10);
1565
+ if (!Number.isInteger(idx) || idx < 0 || idx >= parent.length) return { error: `Operation ${index}: array index "${lastToken}" out of bounds` };
1566
+ const [removed] = parent.splice(idx, 1);
1567
+ return { error: null, removed };
1568
+ }
1569
+ if (_isPlainObject(parent)) {
1570
+ if (!(lastToken in parent)) return { error: `Operation ${index}: path "${op.path}" does not exist` };
1571
+ const removed = parent[lastToken];
1572
+ delete parent[lastToken];
1573
+ return { error: null, removed };
1574
+ }
1575
+ return { error: `Operation ${index}: cannot remove from a non-object, non-array value at "${op.path}"` };
1576
+ };
1577
+ switch (op.op) {
1578
+ case "add":
1579
+ return setAt(tokens, op.value);
1580
+ case "replace":
1581
+ return replaceAt(tokens, op.value);
1582
+ case "remove":
1583
+ return removeAt(tokens).error;
1584
+ case "test": {
1585
+ const { found, value } = _getByTokens(doc, tokens);
1586
+ if (!found) return `Operation ${index}: path "${op.path}" does not exist`;
1587
+ if (!_deepEqual(value, op.value)) return `Operation ${index}: test failed at "${op.path}"`;
1588
+ return null;
1589
+ }
1590
+ case "move": {
1591
+ if (!op.from) return `Operation ${index}: "move" requires "from"`;
1592
+ let fromTokens;
1593
+ try {
1594
+ fromTokens = _parseJsonPointer(op.from);
1595
+ } catch (e) {
1596
+ return `Operation ${index}: ${e.message}`;
1597
+ }
1598
+ const removal = removeAt(fromTokens);
1599
+ if (removal.error) return removal.error;
1600
+ return setAt(tokens, removal.removed);
1601
+ }
1602
+ case "copy": {
1603
+ if (!op.from) return `Operation ${index}: "copy" requires "from"`;
1604
+ let fromTokens;
1605
+ try {
1606
+ fromTokens = _parseJsonPointer(op.from);
1607
+ } catch (e) {
1608
+ return `Operation ${index}: ${e.message}`;
1609
+ }
1610
+ const { found, value } = _getByTokens(doc, fromTokens);
1611
+ if (!found) return `Operation ${index}: "from" path "${op.from}" does not exist`;
1612
+ return setAt(tokens, JSON.parse(JSON.stringify(value)));
1613
+ }
1614
+ default:
1615
+ return `Operation ${index}: unknown op "${op.op}"`;
1616
+ }
1617
+ };
1618
+ for (let i = 0; i < operations.length; i++) {
1619
+ const err = applyOne(operations[i], i);
1620
+ if (err) return { error: err };
1621
+ }
1622
+ return { result: doc };
1623
+ }
1624
+ function generateJsonPatch(aJson, bJson) {
1625
+ let a;
1626
+ try {
1627
+ a = JSON.parse(aJson);
1628
+ } catch {
1629
+ return { error: "First document is not valid JSON" };
1630
+ }
1631
+ let b;
1632
+ try {
1633
+ b = JSON.parse(bJson);
1634
+ } catch {
1635
+ return { error: "Second document is not valid JSON" };
1636
+ }
1637
+ return { patch: diffJsonPatch(a, b) };
1638
+ }
1426
1639
 
1427
1640
  exports.applyJsonMergePatch = applyJsonMergePatch;
1641
+ exports.applyJsonPatch = applyJsonPatch;
1428
1642
  exports.csvToJson = csvToJson;
1429
1643
  exports.detectFormat = detectFormat;
1430
1644
  exports.diffJson = diffJson;
1645
+ exports.diffJsonPatch = diffJsonPatch;
1431
1646
  exports.evaluateJsonPath = evaluateJsonPath;
1432
1647
  exports.formatDiffLine = formatDiffLine;
1433
1648
  exports.formatJson = formatJson;
1434
1649
  exports.generateExample = generateExample;
1650
+ exports.generateJsonPatch = generateJsonPatch;
1435
1651
  exports.getJsonStats = getJsonStats;
1436
1652
  exports.inferGoType = inferGoType;
1437
1653
  exports.inferPythonType = inferPythonType;
@@ -1 +1 @@
1
- export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, g as JsonSchemaLike, h as JsonSchemaToTsOptions, M as MergePatchResult, P as ParseStatus, i as PythonClass, k as PythonField, l as PythonMode, V as ValidationError, m as ValidationResult, Z as ZodOptions, n as applyJsonMergePatch, o as csvToJson, p as detectFormat, q as diffJson, r as evaluateJsonPath, s as formatDiffLine, t as formatJson, u as generateExample, v as getJsonStats, w as inferGoType, x as inferPythonType, y as inferType, z as jsonSchemaToTypescript, A as jsonToCsv, B as jsonToGo, E as jsonToPython, F as jsonToTypescript, H as jsonToYaml, I as jsonToZod, K as mergeJsonPatch, L as minifyJson, N as parseJson, O as parseStructs, Q as resolveJsonPointer, R as toPascalCase, S as toSnakeCase, T as validateJson, U as validateJsonPath, W as validateJsonString, X as yamlToJson } from '../json-CaiYsGDQ.cjs';
1
+ export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPatchOp, f as JsonPatchOperation, g as JsonPathResult, h as JsonPointerResult, i as JsonSchemaLike, k as JsonSchemaToTsOptions, M as MergePatchResult, P as ParseStatus, l as PythonClass, m as PythonField, n as PythonMode, V as ValidationError, o as ValidationResult, Z as ZodOptions, p as applyJsonMergePatch, q as applyJsonPatch, r as csvToJson, s as detectFormat, t as diffJson, u as diffJsonPatch, v as evaluateJsonPath, w as formatDiffLine, x as formatJson, y as generateExample, z as generateJsonPatch, A as getJsonStats, B as inferGoType, E as inferPythonType, F as inferType, H as jsonSchemaToTypescript, I as jsonToCsv, K as jsonToGo, L as jsonToPython, N as jsonToTypescript, O as jsonToYaml, Q as jsonToZod, R as mergeJsonPatch, S as minifyJson, T as parseJson, U as parseStructs, W as resolveJsonPointer, X as toPascalCase, Y as toSnakeCase, _ as validateJson, $ as validateJsonPath, a0 as validateJsonString, a1 as yamlToJson } from '../json-Ca6gZCNB.cjs';
@@ -1 +1 @@
1
- export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, g as JsonSchemaLike, h as JsonSchemaToTsOptions, M as MergePatchResult, P as ParseStatus, i as PythonClass, k as PythonField, l as PythonMode, V as ValidationError, m as ValidationResult, Z as ZodOptions, n as applyJsonMergePatch, o as csvToJson, p as detectFormat, q as diffJson, r as evaluateJsonPath, s as formatDiffLine, t as formatJson, u as generateExample, v as getJsonStats, w as inferGoType, x as inferPythonType, y as inferType, z as jsonSchemaToTypescript, A as jsonToCsv, B as jsonToGo, E as jsonToPython, F as jsonToTypescript, H as jsonToYaml, I as jsonToZod, K as mergeJsonPatch, L as minifyJson, N as parseJson, O as parseStructs, Q as resolveJsonPointer, R as toPascalCase, S as toSnakeCase, T as validateJson, U as validateJsonPath, W as validateJsonString, X as yamlToJson } from '../json-CaiYsGDQ.js';
1
+ export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPatchOp, f as JsonPatchOperation, g as JsonPathResult, h as JsonPointerResult, i as JsonSchemaLike, k as JsonSchemaToTsOptions, M as MergePatchResult, P as ParseStatus, l as PythonClass, m as PythonField, n as PythonMode, V as ValidationError, o as ValidationResult, Z as ZodOptions, p as applyJsonMergePatch, q as applyJsonPatch, r as csvToJson, s as detectFormat, t as diffJson, u as diffJsonPatch, v as evaluateJsonPath, w as formatDiffLine, x as formatJson, y as generateExample, z as generateJsonPatch, A as getJsonStats, B as inferGoType, E as inferPythonType, F as inferType, H as jsonSchemaToTypescript, I as jsonToCsv, K as jsonToGo, L as jsonToPython, N as jsonToTypescript, O as jsonToYaml, Q as jsonToZod, R as mergeJsonPatch, S as minifyJson, T as parseJson, U as parseStructs, W as resolveJsonPointer, X as toPascalCase, Y as toSnakeCase, _ as validateJson, $ as validateJsonPath, a0 as validateJsonString, a1 as yamlToJson } from '../json-Ca6gZCNB.js';
@@ -1,2 +1,2 @@
1
- export { applyJsonMergePatch, csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonSchemaToTypescript, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, mergeJsonPatch, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-34C6GXCC.js';
1
+ export { applyJsonMergePatch, applyJsonPatch, csvToJson, detectFormat, diffJson, diffJsonPatch, evaluateJsonPath, formatDiffLine, formatJson, generateExample, generateJsonPatch, getJsonStats, inferGoType, inferPythonType, inferType, jsonSchemaToTypescript, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, mergeJsonPatch, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-WUOZHCIC.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -2651,6 +2651,50 @@ function calculateRequiredBandwidth(fileSize, fileSizeUnit, targetSeconds) {
2651
2651
  requiredMBps: requiredBitsPerSecond / 8 / 1e6
2652
2652
  };
2653
2653
  }
2654
+ var _REAL_RATE_FIELDS = ["nominalRatePercent", "inflationRatePercent", "realRatePercent"];
2655
+ function calculateRealRateOfReturn(input) {
2656
+ const provided = (v) => typeof v === "number" && Number.isFinite(v);
2657
+ const given = _REAL_RATE_FIELDS.filter((f) => provided(input[f]));
2658
+ if (given.length !== 2) {
2659
+ return { error: `Provide exactly two of nominalRatePercent, inflationRatePercent, realRatePercent (got ${given.length})` };
2660
+ }
2661
+ for (const f of given) {
2662
+ const v = input[f];
2663
+ if (v <= -100) return { error: `${f} must be greater than -100` };
2664
+ }
2665
+ const has = (f) => given.includes(f);
2666
+ const nominal0 = input.nominalRatePercent;
2667
+ const inflation0 = input.inflationRatePercent;
2668
+ const real0 = input.realRatePercent;
2669
+ let nominalRatePercent;
2670
+ let inflationRatePercent;
2671
+ let realRatePercent;
2672
+ let solvedFor;
2673
+ if (has("nominalRatePercent") && has("inflationRatePercent")) {
2674
+ nominalRatePercent = nominal0;
2675
+ inflationRatePercent = inflation0;
2676
+ realRatePercent = ((1 + nominal0 / 100) / (1 + inflation0 / 100) - 1) * 100;
2677
+ solvedFor = "realRatePercent";
2678
+ } else if (has("realRatePercent") && has("inflationRatePercent")) {
2679
+ realRatePercent = real0;
2680
+ inflationRatePercent = inflation0;
2681
+ nominalRatePercent = ((1 + real0 / 100) * (1 + inflation0 / 100) - 1) * 100;
2682
+ solvedFor = "nominalRatePercent";
2683
+ } else {
2684
+ nominalRatePercent = nominal0;
2685
+ realRatePercent = real0;
2686
+ inflationRatePercent = ((1 + nominal0 / 100) / (1 + real0 / 100) - 1) * 100;
2687
+ solvedFor = "inflationRatePercent";
2688
+ }
2689
+ const round4 = (n) => Math.round(n * 1e4) / 1e4;
2690
+ return {
2691
+ nominalRatePercent: round4(nominalRatePercent),
2692
+ inflationRatePercent: round4(inflationRatePercent),
2693
+ realRatePercent: round4(realRatePercent),
2694
+ given,
2695
+ solvedFor
2696
+ };
2697
+ }
2654
2698
 
2655
2699
  exports.BASE_LABELS = BASE_LABELS;
2656
2700
  exports.BASE_PREFIXES = BASE_PREFIXES;
@@ -2693,6 +2737,7 @@ exports.calculateMortgagePoints = calculateMortgagePoints;
2693
2737
  exports.calculateMovingAverages = calculateMovingAverages;
2694
2738
  exports.calculatePaybackPeriod = calculatePaybackPeriod;
2695
2739
  exports.calculatePercentageChange = calculatePercentageChange;
2740
+ exports.calculateRealRateOfReturn = calculateRealRateOfReturn;
2696
2741
  exports.calculateRequiredBandwidth = calculateRequiredBandwidth;
2697
2742
  exports.calculateRoi = calculateRoi;
2698
2743
  exports.calculateRuleOf72 = calculateRuleOf72;