@utilix-tech/sdk 0.56.0 → 0.57.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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
4
4
 
5
+ ## 0.57.0
6
+ - Add `mergeJsonPatch`, `applyJsonMergePatch` (json-merge-patch): apply an RFC 7396 JSON Merge Patch document to a target JSON document, with null-valued patch keys removing the matching target key.
7
+ - Add `generateCspNonce` (csp-nonce-generator): generate a cryptographically random, base64-encoded Content-Security-Policy nonce with ready-to-paste header directive and script/style tag snippets.
8
+
5
9
  ## 0.56.0
6
10
  - Add `buildAcceptLanguage`, `parseAcceptLanguage` (accept-language-parser): build an Accept-Language request-header value from locale/quality pairs sorted by descending preference, or parse an existing one into its ranked entries.
7
11
  - Add `calculateBlendedLoanRate` (blended-loan-rate-calculator): compute the single weighted-average interest rate across a list of loan balances, plus combined monthly and annual interest accrual.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @utilix-tech/sdk
2
2
 
3
- **648 developer utility functions for Node.js: runs locally, no API key required.**
3
+ **659 developer utility functions for Node.js: runs locally, no API key required.**
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@utilix-tech/sdk?style=flat-square&color=cb3837)](https://www.npmjs.com/package/@utilix-tech/sdk)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/@utilix-tech/sdk?style=flat-square)](https://www.npmjs.com/package/@utilix-tech/sdk)
@@ -66,7 +66,7 @@ const { formatJson } = require("@utilix-tech/sdk/json");
66
66
 
67
67
  ```ts
68
68
  import { formatJson, minifyJson, diffJson, jsonToTypescript, jsonSchemaToTypescript, validateJson,
69
- evaluateJsonPath, resolveJsonPointer, jsonToCsv, yamlToJson, jsonToYaml, getJsonStats } from "@utilix-tech/sdk/json";
69
+ evaluateJsonPath, resolveJsonPointer, applyJsonMergePatch, jsonToCsv, yamlToJson, jsonToYaml, getJsonStats } from "@utilix-tech/sdk/json";
70
70
 
71
71
  // Format with 2-space indent
72
72
  formatJson('{"name":"alice","age":30}', { indent: 2 });
@@ -87,6 +87,10 @@ evaluateJsonPath(obj, "$.users[*].name");
87
87
  resolveJsonPointer('{"users":[{"name":"Alice"}]}', "/users/0/name");
88
88
  // { found: true, value: "Alice", tokens: ["users", "0", "name"] }
89
89
 
90
+ // Apply an RFC 7396 JSON Merge Patch
91
+ applyJsonMergePatch('{"a":"b","c":{"d":"e","f":"g"}}', '{"a":"z","c":{"f":null}}');
92
+ // { result: { a: "z", c: { d: "e" } } }
93
+
90
94
  // Convert JSON to CSV
91
95
  jsonToCsv('[{"a":1,"b":2}]');
92
96
 
@@ -278,7 +282,7 @@ inferCsvColumnTypes("id,price,active\n1,9.99,true\n2,5,false");
278
282
 
279
283
  ```ts
280
284
  import { generateUuid, generateV4, generateV7, generateUlid,
281
- generatePassword, checkStrength, estimatePasswordEntropy, generateData } from "@utilix-tech/sdk/generators";
285
+ generatePassword, checkStrength, estimatePasswordEntropy, generateData, generateCspNonce } from "@utilix-tech/sdk/generators";
282
286
 
283
287
  generateUuid(); // "f47ac10b-58cc-4372-a567-0e02b2c3d479" (v4)
284
288
  generateV7(); // time-ordered UUID v7
@@ -296,6 +300,10 @@ generateData([
296
300
  { name: "email", type: "email" },
297
301
  { name: "age", type: "number" },
298
302
  ], 10); // 10 rows
303
+
304
+ // Cryptographically random CSP nonce, plus ready-to-paste snippets
305
+ generateCspNonce(16);
306
+ // { nonce: "...", scriptSrcDirective: "script-src 'nonce-...'", scriptTag: '<script nonce="...">' }
299
307
  ```
300
308
 
301
309
  ---
@@ -856,12 +864,12 @@ inspectGifFrames(new Uint8Array(gifBytes));
856
864
 
857
865
  | Import | What it does |
858
866
  |---|---|
859
- | `@utilix-tech/sdk/json` | Format, minify, diff, validate, JSONPath, CSV↔JSON, YAML↔JSON, TS types from data or from a JSON Schema |
867
+ | `@utilix-tech/sdk/json` | Format, minify, diff, validate, JSONPath, JSON Pointer, RFC 7396 merge patch, CSV↔JSON, YAML↔JSON, TS types from data or from a JSON Schema |
860
868
  | `@utilix-tech/sdk/encoding` | Base64, URL, HTML entities, Base32/Base58/Base62 encode/decode |
861
869
  | `@utilix-tech/sdk/hashing` | MD5, SHA-1/256/512, bcrypt, HMAC, .htpasswd, SRI hashes, content-hash ETag generation |
862
870
  | `@utilix-tech/sdk/text` | Case convert, slugify, word count, lorem ipsum, line ops, HTML→Markdown, Levenshtein/Damerau string distance, readability scoring, sentence length distribution, emoji lookup |
863
871
  | `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI, NDJSON parse and convert, SRT/WebVTT subtitles, Markdown front matter parser, YAML anchor/alias resolver, CSV column type inferencer |
864
- | `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, entropy estimator, fake data |
872
+ | `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, entropy estimator, fake data, CSP nonce generator |
865
873
  | `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
866
874
  | `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN validation, loan calculator, EMI calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator, break-even point calculator, Rule of 72 calculator, savings goal calculator, ROI calculator, cash denomination/till calculator, payback period calculator, CD maturity calculator, debt-to-income ratio calculator |
867
875
  | `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing, User-Agent parsing, IPv6 address compress/expand, Permissions-Policy header builder, Client Hints header builder/parser, Content-Disposition header builder/parser, X-Content-Type-Options header builder/risk assessor, sitemap.xml validator, sitemap index splitter |
@@ -4,6 +4,7 @@ import * as yaml from 'js-yaml';
4
4
  // src/tools/json.ts
5
5
  var json_exports = {};
6
6
  __export(json_exports, {
7
+ applyJsonMergePatch: () => applyJsonMergePatch,
7
8
  csvToJson: () => csvToJson,
8
9
  detectFormat: () => detectFormat,
9
10
  diffJson: () => diffJson,
@@ -22,6 +23,7 @@ __export(json_exports, {
22
23
  jsonToTypescript: () => jsonToTypescript,
23
24
  jsonToYaml: () => jsonToYaml,
24
25
  jsonToZod: () => jsonToZod,
26
+ mergeJsonPatch: () => mergeJsonPatch,
25
27
  minifyJson: () => minifyJson,
26
28
  parseJson: () => parseJson,
27
29
  parseStructs: () => parseStructs,
@@ -1402,5 +1404,36 @@ function jsonSchemaToTypescript(schemaJson, options) {
1402
1404
  }
1403
1405
  return parts.join("\n\n");
1404
1406
  }
1407
+ function _isMergePatchObject(value) {
1408
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1409
+ }
1410
+ function mergeJsonPatch(target, patch) {
1411
+ if (!_isMergePatchObject(patch)) return patch;
1412
+ const result = _isMergePatchObject(target) ? { ...target } : {};
1413
+ for (const key of Object.keys(patch)) {
1414
+ const value = patch[key];
1415
+ if (value === null) {
1416
+ delete result[key];
1417
+ } else {
1418
+ result[key] = mergeJsonPatch(result[key], value);
1419
+ }
1420
+ }
1421
+ return result;
1422
+ }
1423
+ function applyJsonMergePatch(targetJson, patchJson) {
1424
+ let target;
1425
+ try {
1426
+ target = JSON.parse(targetJson);
1427
+ } catch {
1428
+ return { error: "Target is not valid JSON" };
1429
+ }
1430
+ let patch;
1431
+ try {
1432
+ patch = JSON.parse(patchJson);
1433
+ } catch {
1434
+ return { error: "Patch is not valid JSON" };
1435
+ }
1436
+ return { result: mergeJsonPatch(target, patch) };
1437
+ }
1405
1438
 
1406
- export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonSchemaToTypescript, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, json_exports, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson };
1439
+ export { applyJsonMergePatch, csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonSchemaToTypescript, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, json_exports, mergeJsonPatch, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson };
@@ -16,6 +16,7 @@ __export(generators_exports, {
16
16
  generateBulk: () => generateBulk,
17
17
  generateBulkPasswords: () => generateBulkPasswords,
18
18
  generateBulkUlids: () => generateBulkUlids,
19
+ generateCspNonce: () => generateCspNonce,
19
20
  generateData: () => generateData,
20
21
  generatePassword: () => generatePassword,
21
22
  generateQrDataUrl: () => generateQrDataUrl,
@@ -622,5 +623,19 @@ async function generateQrDataUrl(text, options) {
622
623
  }
623
624
  });
624
625
  }
626
+ function generateCspNonce(byteLength = 16) {
627
+ if (!Number.isInteger(byteLength) || byteLength < 8 || byteLength > 64) {
628
+ return { error: "Byte length must be a whole number between 8 and 64" };
629
+ }
630
+ const nonce = randomBytes(byteLength).toString("base64");
631
+ return {
632
+ nonce,
633
+ byteLength,
634
+ scriptSrcDirective: `script-src 'nonce-${nonce}'`,
635
+ styleSrcDirective: `style-src 'nonce-${nonce}'`,
636
+ scriptTag: `<script nonce="${nonce}">`,
637
+ styleTag: `<style nonce="${nonce}">`
638
+ };
639
+ }
625
640
 
626
- export { AMBIGUOUS_CHARS, DATA_TYPES, DEFAULT_OPTIONS, DEFAULT_QR_OPTIONS, SYMBOL_CHARS, ULID_REGEX, checkStrength, estimatePasswordEntropy, generateBulk, generateBulkPasswords, generateBulkUlids, generateData, generatePassword, generateQrDataUrl, generateQrSvg, generateSingle, generateUlid, generateUuid, generateV4, generateV7, generators_exports, isValidUlid, isValidUuid, parseUlid, parseUuidVersion };
641
+ export { AMBIGUOUS_CHARS, DATA_TYPES, DEFAULT_OPTIONS, DEFAULT_QR_OPTIONS, SYMBOL_CHARS, ULID_REGEX, checkStrength, estimatePasswordEntropy, generateBulk, generateBulkPasswords, generateBulkUlids, generateCspNonce, generateData, generatePassword, generateQrDataUrl, generateQrSvg, generateSingle, generateUlid, generateUuid, generateV4, generateV7, generators_exports, isValidUlid, isValidUuid, parseUlid, parseUuidVersion };
@@ -10,6 +10,7 @@
10
10
  * - password-entropy-estimator : estimatePasswordEntropy
11
11
  * - random-data : generateSingle, generateData
12
12
  * - qr-code : generateQrSvg, generateQrDataUrl
13
+ * - csp-nonce-generator : generateCspNonce
13
14
  */
14
15
  type UuidVersion = 'v4' | 'v7';
15
16
  interface GeneratedUuid {
@@ -117,8 +118,27 @@ interface QrOptions {
117
118
  declare const DEFAULT_QR_OPTIONS: QrOptions;
118
119
  declare function generateQrSvg(text: string, options?: QrOptions): Promise<string>;
119
120
  declare function generateQrDataUrl(text: string, options?: QrOptions): Promise<string>;
121
+ interface CspNonceResult {
122
+ nonce: string;
123
+ byteLength: number;
124
+ scriptSrcDirective: string;
125
+ styleSrcDirective: string;
126
+ scriptTag: string;
127
+ styleTag: string;
128
+ }
129
+ /**
130
+ * Generate a cryptographically random, base64-encoded nonce for a
131
+ * Content-Security-Policy script-src/style-src directive, along with
132
+ * ready-to-paste header directive and <script>/<style nonce="..."> tag
133
+ * snippets. Generates a fresh value on every call; the same value must be
134
+ * reused for both the header and the markup within a single request.
135
+ */
136
+ declare function generateCspNonce(byteLength?: number): CspNonceResult | {
137
+ error: string;
138
+ };
120
139
 
121
140
  declare const generators_AMBIGUOUS_CHARS: typeof AMBIGUOUS_CHARS;
141
+ type generators_CspNonceResult = CspNonceResult;
122
142
  declare const generators_DATA_TYPES: typeof DATA_TYPES;
123
143
  declare const generators_DEFAULT_OPTIONS: typeof DEFAULT_OPTIONS;
124
144
  declare const generators_DEFAULT_QR_OPTIONS: typeof DEFAULT_QR_OPTIONS;
@@ -141,6 +161,7 @@ declare const generators_estimatePasswordEntropy: typeof estimatePasswordEntropy
141
161
  declare const generators_generateBulk: typeof generateBulk;
142
162
  declare const generators_generateBulkPasswords: typeof generateBulkPasswords;
143
163
  declare const generators_generateBulkUlids: typeof generateBulkUlids;
164
+ declare const generators_generateCspNonce: typeof generateCspNonce;
144
165
  declare const generators_generateData: typeof generateData;
145
166
  declare const generators_generatePassword: typeof generatePassword;
146
167
  declare const generators_generateQrDataUrl: typeof generateQrDataUrl;
@@ -155,7 +176,7 @@ declare const generators_isValidUuid: typeof isValidUuid;
155
176
  declare const generators_parseUlid: typeof parseUlid;
156
177
  declare const generators_parseUuidVersion: typeof parseUuidVersion;
157
178
  declare namespace generators {
158
- export { generators_AMBIGUOUS_CHARS as AMBIGUOUS_CHARS, generators_DATA_TYPES as DATA_TYPES, generators_DEFAULT_OPTIONS as DEFAULT_OPTIONS, generators_DEFAULT_QR_OPTIONS as DEFAULT_QR_OPTIONS, type generators_DataType as DataType, type generators_GeneratedUuid as GeneratedUuid, type generators_PasswordCharsetInfo as PasswordCharsetInfo, type generators_PasswordCrackTimeEstimate as PasswordCrackTimeEstimate, type generators_PasswordEntropyResult as PasswordEntropyResult, type generators_PasswordEntropyStrength as PasswordEntropyStrength, type generators_PasswordOptions as PasswordOptions, type generators_QrErrorLevel as QrErrorLevel, type generators_QrOptions as QrOptions, type generators_QrOutputFormat as QrOutputFormat, type generators_RandomConfig as RandomConfig, generators_SYMBOL_CHARS as SYMBOL_CHARS, generators_ULID_REGEX as ULID_REGEX, type generators_UuidVersion as UuidVersion, generators_checkStrength as checkStrength, generators_estimatePasswordEntropy as estimatePasswordEntropy, generators_generateBulk as generateBulk, generators_generateBulkPasswords as generateBulkPasswords, generators_generateBulkUlids as generateBulkUlids, generators_generateData as generateData, generators_generatePassword as generatePassword, generators_generateQrDataUrl as generateQrDataUrl, generators_generateQrSvg as generateQrSvg, generators_generateSingle as generateSingle, generators_generateUlid as generateUlid, generators_generateUuid as generateUuid, generators_generateV4 as generateV4, generators_generateV7 as generateV7, generators_isValidUlid as isValidUlid, generators_isValidUuid as isValidUuid, generators_parseUlid as parseUlid, generators_parseUuidVersion as parseUuidVersion };
179
+ export { generators_AMBIGUOUS_CHARS as AMBIGUOUS_CHARS, type generators_CspNonceResult as CspNonceResult, generators_DATA_TYPES as DATA_TYPES, generators_DEFAULT_OPTIONS as DEFAULT_OPTIONS, generators_DEFAULT_QR_OPTIONS as DEFAULT_QR_OPTIONS, type generators_DataType as DataType, type generators_GeneratedUuid as GeneratedUuid, type generators_PasswordCharsetInfo as PasswordCharsetInfo, type generators_PasswordCrackTimeEstimate as PasswordCrackTimeEstimate, type generators_PasswordEntropyResult as PasswordEntropyResult, type generators_PasswordEntropyStrength as PasswordEntropyStrength, type generators_PasswordOptions as PasswordOptions, type generators_QrErrorLevel as QrErrorLevel, type generators_QrOptions as QrOptions, type generators_QrOutputFormat as QrOutputFormat, type generators_RandomConfig as RandomConfig, generators_SYMBOL_CHARS as SYMBOL_CHARS, generators_ULID_REGEX as ULID_REGEX, type generators_UuidVersion as UuidVersion, generators_checkStrength as checkStrength, generators_estimatePasswordEntropy as estimatePasswordEntropy, generators_generateBulk as generateBulk, generators_generateBulkPasswords as generateBulkPasswords, generators_generateBulkUlids as generateBulkUlids, generators_generateCspNonce as generateCspNonce, generators_generateData as generateData, generators_generatePassword as generatePassword, generators_generateQrDataUrl as generateQrDataUrl, generators_generateQrSvg as generateQrSvg, generators_generateSingle as generateSingle, generators_generateUlid as generateUlid, generators_generateUuid as generateUuid, generators_generateV4 as generateV4, generators_generateV7 as generateV7, generators_isValidUlid as isValidUlid, generators_isValidUuid as isValidUuid, generators_parseUlid as parseUlid, generators_parseUuidVersion as parseUuidVersion };
159
180
  }
160
181
 
161
- export { AMBIGUOUS_CHARS as A, isValidUuid as B, parseUlid as C, DATA_TYPES as D, parseUuidVersion as E, type GeneratedUuid as G, type PasswordCharsetInfo as P, type QrErrorLevel as Q, type RandomConfig as R, SYMBOL_CHARS as S, ULID_REGEX as U, DEFAULT_OPTIONS as a, DEFAULT_QR_OPTIONS as b, type DataType as c, type PasswordCrackTimeEstimate as d, type PasswordEntropyResult as e, type PasswordEntropyStrength as f, generators as g, type PasswordOptions as h, type QrOptions as i, type QrOutputFormat as j, type UuidVersion as k, checkStrength as l, estimatePasswordEntropy as m, generateBulk as n, generateBulkPasswords as o, generateBulkUlids as p, generateData as q, generatePassword as r, generateQrDataUrl as s, generateQrSvg as t, generateSingle as u, generateUlid as v, generateUuid as w, generateV4 as x, generateV7 as y, isValidUlid as z };
182
+ export { AMBIGUOUS_CHARS as A, isValidUlid as B, type CspNonceResult as C, DATA_TYPES as D, isValidUuid as E, parseUlid as F, type GeneratedUuid as G, parseUuidVersion as H, type PasswordCharsetInfo as P, type QrErrorLevel as Q, type RandomConfig as R, SYMBOL_CHARS as S, ULID_REGEX as U, DEFAULT_OPTIONS as a, DEFAULT_QR_OPTIONS as b, type DataType as c, type PasswordCrackTimeEstimate as d, type PasswordEntropyResult as e, type PasswordEntropyStrength as f, generators as g, type PasswordOptions as h, type QrOptions as i, type QrOutputFormat as j, type UuidVersion as k, checkStrength as l, estimatePasswordEntropy as m, generateBulk as n, generateBulkPasswords as o, generateBulkUlids as p, generateCspNonce as q, generateData as r, generatePassword as s, generateQrDataUrl as t, generateQrSvg as u, generateSingle as v, generateUlid as w, generateUuid as x, generateV4 as y, generateV7 as z };
@@ -10,6 +10,7 @@
10
10
  * - password-entropy-estimator : estimatePasswordEntropy
11
11
  * - random-data : generateSingle, generateData
12
12
  * - qr-code : generateQrSvg, generateQrDataUrl
13
+ * - csp-nonce-generator : generateCspNonce
13
14
  */
14
15
  type UuidVersion = 'v4' | 'v7';
15
16
  interface GeneratedUuid {
@@ -117,8 +118,27 @@ interface QrOptions {
117
118
  declare const DEFAULT_QR_OPTIONS: QrOptions;
118
119
  declare function generateQrSvg(text: string, options?: QrOptions): Promise<string>;
119
120
  declare function generateQrDataUrl(text: string, options?: QrOptions): Promise<string>;
121
+ interface CspNonceResult {
122
+ nonce: string;
123
+ byteLength: number;
124
+ scriptSrcDirective: string;
125
+ styleSrcDirective: string;
126
+ scriptTag: string;
127
+ styleTag: string;
128
+ }
129
+ /**
130
+ * Generate a cryptographically random, base64-encoded nonce for a
131
+ * Content-Security-Policy script-src/style-src directive, along with
132
+ * ready-to-paste header directive and <script>/<style nonce="..."> tag
133
+ * snippets. Generates a fresh value on every call; the same value must be
134
+ * reused for both the header and the markup within a single request.
135
+ */
136
+ declare function generateCspNonce(byteLength?: number): CspNonceResult | {
137
+ error: string;
138
+ };
120
139
 
121
140
  declare const generators_AMBIGUOUS_CHARS: typeof AMBIGUOUS_CHARS;
141
+ type generators_CspNonceResult = CspNonceResult;
122
142
  declare const generators_DATA_TYPES: typeof DATA_TYPES;
123
143
  declare const generators_DEFAULT_OPTIONS: typeof DEFAULT_OPTIONS;
124
144
  declare const generators_DEFAULT_QR_OPTIONS: typeof DEFAULT_QR_OPTIONS;
@@ -141,6 +161,7 @@ declare const generators_estimatePasswordEntropy: typeof estimatePasswordEntropy
141
161
  declare const generators_generateBulk: typeof generateBulk;
142
162
  declare const generators_generateBulkPasswords: typeof generateBulkPasswords;
143
163
  declare const generators_generateBulkUlids: typeof generateBulkUlids;
164
+ declare const generators_generateCspNonce: typeof generateCspNonce;
144
165
  declare const generators_generateData: typeof generateData;
145
166
  declare const generators_generatePassword: typeof generatePassword;
146
167
  declare const generators_generateQrDataUrl: typeof generateQrDataUrl;
@@ -155,7 +176,7 @@ declare const generators_isValidUuid: typeof isValidUuid;
155
176
  declare const generators_parseUlid: typeof parseUlid;
156
177
  declare const generators_parseUuidVersion: typeof parseUuidVersion;
157
178
  declare namespace generators {
158
- export { generators_AMBIGUOUS_CHARS as AMBIGUOUS_CHARS, generators_DATA_TYPES as DATA_TYPES, generators_DEFAULT_OPTIONS as DEFAULT_OPTIONS, generators_DEFAULT_QR_OPTIONS as DEFAULT_QR_OPTIONS, type generators_DataType as DataType, type generators_GeneratedUuid as GeneratedUuid, type generators_PasswordCharsetInfo as PasswordCharsetInfo, type generators_PasswordCrackTimeEstimate as PasswordCrackTimeEstimate, type generators_PasswordEntropyResult as PasswordEntropyResult, type generators_PasswordEntropyStrength as PasswordEntropyStrength, type generators_PasswordOptions as PasswordOptions, type generators_QrErrorLevel as QrErrorLevel, type generators_QrOptions as QrOptions, type generators_QrOutputFormat as QrOutputFormat, type generators_RandomConfig as RandomConfig, generators_SYMBOL_CHARS as SYMBOL_CHARS, generators_ULID_REGEX as ULID_REGEX, type generators_UuidVersion as UuidVersion, generators_checkStrength as checkStrength, generators_estimatePasswordEntropy as estimatePasswordEntropy, generators_generateBulk as generateBulk, generators_generateBulkPasswords as generateBulkPasswords, generators_generateBulkUlids as generateBulkUlids, generators_generateData as generateData, generators_generatePassword as generatePassword, generators_generateQrDataUrl as generateQrDataUrl, generators_generateQrSvg as generateQrSvg, generators_generateSingle as generateSingle, generators_generateUlid as generateUlid, generators_generateUuid as generateUuid, generators_generateV4 as generateV4, generators_generateV7 as generateV7, generators_isValidUlid as isValidUlid, generators_isValidUuid as isValidUuid, generators_parseUlid as parseUlid, generators_parseUuidVersion as parseUuidVersion };
179
+ export { generators_AMBIGUOUS_CHARS as AMBIGUOUS_CHARS, type generators_CspNonceResult as CspNonceResult, generators_DATA_TYPES as DATA_TYPES, generators_DEFAULT_OPTIONS as DEFAULT_OPTIONS, generators_DEFAULT_QR_OPTIONS as DEFAULT_QR_OPTIONS, type generators_DataType as DataType, type generators_GeneratedUuid as GeneratedUuid, type generators_PasswordCharsetInfo as PasswordCharsetInfo, type generators_PasswordCrackTimeEstimate as PasswordCrackTimeEstimate, type generators_PasswordEntropyResult as PasswordEntropyResult, type generators_PasswordEntropyStrength as PasswordEntropyStrength, type generators_PasswordOptions as PasswordOptions, type generators_QrErrorLevel as QrErrorLevel, type generators_QrOptions as QrOptions, type generators_QrOutputFormat as QrOutputFormat, type generators_RandomConfig as RandomConfig, generators_SYMBOL_CHARS as SYMBOL_CHARS, generators_ULID_REGEX as ULID_REGEX, type generators_UuidVersion as UuidVersion, generators_checkStrength as checkStrength, generators_estimatePasswordEntropy as estimatePasswordEntropy, generators_generateBulk as generateBulk, generators_generateBulkPasswords as generateBulkPasswords, generators_generateBulkUlids as generateBulkUlids, generators_generateCspNonce as generateCspNonce, generators_generateData as generateData, generators_generatePassword as generatePassword, generators_generateQrDataUrl as generateQrDataUrl, generators_generateQrSvg as generateQrSvg, generators_generateSingle as generateSingle, generators_generateUlid as generateUlid, generators_generateUuid as generateUuid, generators_generateV4 as generateV4, generators_generateV7 as generateV7, generators_isValidUlid as isValidUlid, generators_isValidUuid as isValidUuid, generators_parseUlid as parseUlid, generators_parseUuidVersion as parseUuidVersion };
159
180
  }
160
181
 
161
- export { AMBIGUOUS_CHARS as A, isValidUuid as B, parseUlid as C, DATA_TYPES as D, parseUuidVersion as E, type GeneratedUuid as G, type PasswordCharsetInfo as P, type QrErrorLevel as Q, type RandomConfig as R, SYMBOL_CHARS as S, ULID_REGEX as U, DEFAULT_OPTIONS as a, DEFAULT_QR_OPTIONS as b, type DataType as c, type PasswordCrackTimeEstimate as d, type PasswordEntropyResult as e, type PasswordEntropyStrength as f, generators as g, type PasswordOptions as h, type QrOptions as i, type QrOutputFormat as j, type UuidVersion as k, checkStrength as l, estimatePasswordEntropy as m, generateBulk as n, generateBulkPasswords as o, generateBulkUlids as p, generateData as q, generatePassword as r, generateQrDataUrl as s, generateQrSvg as t, generateSingle as u, generateUlid as v, generateUuid as w, generateV4 as x, generateV7 as y, isValidUlid as z };
182
+ export { AMBIGUOUS_CHARS as A, isValidUlid as B, type CspNonceResult as C, DATA_TYPES as D, isValidUuid as E, parseUlid as F, type GeneratedUuid as G, parseUuidVersion as H, type PasswordCharsetInfo as P, type QrErrorLevel as Q, type RandomConfig as R, SYMBOL_CHARS as S, ULID_REGEX as U, DEFAULT_OPTIONS as a, DEFAULT_QR_OPTIONS as b, type DataType as c, type PasswordCrackTimeEstimate as d, type PasswordEntropyResult as e, type PasswordEntropyStrength as f, generators as g, type PasswordOptions as h, type QrOptions as i, type QrOutputFormat as j, type UuidVersion as k, checkStrength as l, estimatePasswordEntropy as m, generateBulk as n, generateBulkPasswords as o, generateBulkUlids as p, generateCspNonce as q, generateData as r, generatePassword as s, generateQrDataUrl as t, generateQrSvg as u, generateSingle as v, generateUlid as w, generateUuid as x, generateV4 as y, generateV7 as z };
package/dist/index.cjs CHANGED
@@ -42,6 +42,7 @@ var __export = (target, all) => {
42
42
  // src/tools/json.ts
43
43
  var json_exports = {};
44
44
  __export(json_exports, {
45
+ applyJsonMergePatch: () => applyJsonMergePatch,
45
46
  csvToJson: () => csvToJson,
46
47
  detectFormat: () => detectFormat,
47
48
  diffJson: () => diffJson,
@@ -60,6 +61,7 @@ __export(json_exports, {
60
61
  jsonToTypescript: () => jsonToTypescript,
61
62
  jsonToYaml: () => jsonToYaml,
62
63
  jsonToZod: () => jsonToZod,
64
+ mergeJsonPatch: () => mergeJsonPatch,
63
65
  minifyJson: () => minifyJson,
64
66
  parseJson: () => parseJson,
65
67
  parseStructs: () => parseStructs,
@@ -1440,6 +1442,37 @@ function jsonSchemaToTypescript(schemaJson, options) {
1440
1442
  }
1441
1443
  return parts.join("\n\n");
1442
1444
  }
1445
+ function _isMergePatchObject(value) {
1446
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1447
+ }
1448
+ function mergeJsonPatch(target, patch) {
1449
+ if (!_isMergePatchObject(patch)) return patch;
1450
+ const result = _isMergePatchObject(target) ? { ...target } : {};
1451
+ for (const key of Object.keys(patch)) {
1452
+ const value = patch[key];
1453
+ if (value === null) {
1454
+ delete result[key];
1455
+ } else {
1456
+ result[key] = mergeJsonPatch(result[key], value);
1457
+ }
1458
+ }
1459
+ return result;
1460
+ }
1461
+ function applyJsonMergePatch(targetJson, patchJson) {
1462
+ let target;
1463
+ try {
1464
+ target = JSON.parse(targetJson);
1465
+ } catch {
1466
+ return { error: "Target is not valid JSON" };
1467
+ }
1468
+ let patch;
1469
+ try {
1470
+ patch = JSON.parse(patchJson);
1471
+ } catch {
1472
+ return { error: "Patch is not valid JSON" };
1473
+ }
1474
+ return { result: mergeJsonPatch(target, patch) };
1475
+ }
1443
1476
 
1444
1477
  // src/tools/encoding.ts
1445
1478
  var encoding_exports = {};
@@ -6935,6 +6968,7 @@ __export(generators_exports, {
6935
6968
  generateBulk: () => generateBulk,
6936
6969
  generateBulkPasswords: () => generateBulkPasswords,
6937
6970
  generateBulkUlids: () => generateBulkUlids,
6971
+ generateCspNonce: () => generateCspNonce,
6938
6972
  generateData: () => generateData,
6939
6973
  generatePassword: () => generatePassword,
6940
6974
  generateQrDataUrl: () => generateQrDataUrl,
@@ -7541,6 +7575,20 @@ async function generateQrDataUrl(text, options) {
7541
7575
  }
7542
7576
  });
7543
7577
  }
7578
+ function generateCspNonce(byteLength = 16) {
7579
+ if (!Number.isInteger(byteLength) || byteLength < 8 || byteLength > 64) {
7580
+ return { error: "Byte length must be a whole number between 8 and 64" };
7581
+ }
7582
+ const nonce = crypto.randomBytes(byteLength).toString("base64");
7583
+ return {
7584
+ nonce,
7585
+ byteLength,
7586
+ scriptSrcDirective: `script-src 'nonce-${nonce}'`,
7587
+ styleSrcDirective: `style-src 'nonce-${nonce}'`,
7588
+ scriptTag: `<script nonce="${nonce}">`,
7589
+ styleTag: `<style nonce="${nonce}">`
7590
+ };
7591
+ }
7544
7592
 
7545
7593
  // src/tools/time.ts
7546
7594
  var time_exports = {};
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- export { j as json } from './json-Ta9JykSB.cjs';
1
+ export { j as json } from './json-CaiYsGDQ.cjs';
2
2
  export { e as encoding } from './encoding-Dk3wpmb3.cjs';
3
3
  export { h as hashing } from './hashing-CJjlvqS_.cjs';
4
4
  export { t as text } from './text-DWUcY8H1.cjs';
5
5
  export { d as data } from './data-Cvyg8ZXo.cjs';
6
- export { g as generators } from './generators-Du8cBesn.cjs';
6
+ export { g as generators } from './generators-DAXXrMvG.cjs';
7
7
  export { t as time } from './time-KqJjdqII.cjs';
8
8
  export { u as units } from './units-BM9GkUZW.cjs';
9
9
  export { n as network } from './network-CoGf7_Op.cjs';
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { j as json } from './json-Ta9JykSB.js';
1
+ export { j as json } from './json-CaiYsGDQ.js';
2
2
  export { e as encoding } from './encoding-Dk3wpmb3.js';
3
3
  export { h as hashing } from './hashing-CJjlvqS_.js';
4
4
  export { t as text } from './text-DWUcY8H1.js';
5
5
  export { d as data } from './data-Cvyg8ZXo.js';
6
- export { g as generators } from './generators-Du8cBesn.js';
6
+ export { g as generators } from './generators-DAXXrMvG.js';
7
7
  export { t as time } from './time-KqJjdqII.js';
8
8
  export { u as units } from './units-BM9GkUZW.js';
9
9
  export { n as network } from './network-CoGf7_Op.js';
package/dist/index.js CHANGED
@@ -7,12 +7,12 @@ export { color_exports as color } from './chunk-BPVAB4P2.js';
7
7
  export { css_exports as css } from './chunk-6YPV2AB5.js';
8
8
  export { misc_exports as misc } from './chunk-GX7H6TAX.js';
9
9
  export { ai_agent_exports as ai_agent } from './chunk-EKIXOA7B.js';
10
- export { json_exports as json } from './chunk-WVEKRKGU.js';
10
+ export { json_exports as json } from './chunk-34C6GXCC.js';
11
11
  export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
12
12
  export { hashing_exports as hashing } from './chunk-PET2CGTH.js';
13
13
  export { text_exports as text } from './chunk-P7TXG7CI.js';
14
14
  export { data_exports as data } from './chunk-56VFNHVO.js';
15
- export { generators_exports as generators } from './chunk-3TYWIX3B.js';
15
+ export { generators_exports as generators } from './chunk-422ICOZX.js';
16
16
  export { time_exports as time } from './chunk-IEPWZERQ.js';
17
17
  import './chunk-MLKGABMK.js';
18
18
 
@@ -14,6 +14,7 @@
14
14
  * - json-to-python : jsonToPython, toSnakeCase, inferPythonType
15
15
  * - json-to-zod : jsonToZod
16
16
  * - json-schema-to-typescript : jsonSchemaToTypescript
17
+ * - json-merge-patch : mergeJsonPatch, applyJsonMergePatch
17
18
  */
18
19
  type ParseStatus = 'idle' | 'valid' | 'error';
19
20
  interface JsonParseResult {
@@ -201,6 +202,24 @@ interface JsonSchemaToTsOptions {
201
202
  declare function jsonSchemaToTypescript(schemaJson: string, options?: JsonSchemaToTsOptions): string | {
202
203
  error: string;
203
204
  };
205
+ interface MergePatchResult {
206
+ result: unknown;
207
+ }
208
+ /**
209
+ * Apply an RFC 7396 JSON Merge Patch to a target value. A patch that is not
210
+ * itself a JSON object replaces the target wholesale (this is how arrays are
211
+ * replaced rather than merged element by element); a null-valued key in an
212
+ * object patch removes that key from the result.
213
+ */
214
+ declare function mergeJsonPatch(target: unknown, patch: unknown): unknown;
215
+ /**
216
+ * Apply an RFC 7396 JSON Merge Patch document to a target JSON document,
217
+ * both given as JSON strings, and return the merged result. Pure recursive
218
+ * merge, no external calls.
219
+ */
220
+ declare function applyJsonMergePatch(targetJson: string, patchJson: string): MergePatchResult | {
221
+ error: string;
222
+ };
204
223
 
205
224
  type json_ConvertOptions = ConvertOptions;
206
225
  type json_CsvOptions = CsvOptions;
@@ -214,6 +233,7 @@ type json_JsonPathResult = JsonPathResult;
214
233
  type json_JsonPointerResult = JsonPointerResult;
215
234
  type json_JsonSchemaLike = JsonSchemaLike;
216
235
  type json_JsonSchemaToTsOptions = JsonSchemaToTsOptions;
236
+ type json_MergePatchResult = MergePatchResult;
217
237
  type json_ParseStatus = ParseStatus;
218
238
  type json_PythonClass = PythonClass;
219
239
  type json_PythonField = PythonField;
@@ -221,6 +241,7 @@ type json_PythonMode = PythonMode;
221
241
  type json_ValidationError = ValidationError;
222
242
  type json_ValidationResult = ValidationResult;
223
243
  type json_ZodOptions = ZodOptions;
244
+ declare const json_applyJsonMergePatch: typeof applyJsonMergePatch;
224
245
  declare const json_csvToJson: typeof csvToJson;
225
246
  declare const json_detectFormat: typeof detectFormat;
226
247
  declare const json_diffJson: typeof diffJson;
@@ -239,6 +260,7 @@ declare const json_jsonToPython: typeof jsonToPython;
239
260
  declare const json_jsonToTypescript: typeof jsonToTypescript;
240
261
  declare const json_jsonToYaml: typeof jsonToYaml;
241
262
  declare const json_jsonToZod: typeof jsonToZod;
263
+ declare const json_mergeJsonPatch: typeof mergeJsonPatch;
242
264
  declare const json_minifyJson: typeof minifyJson;
243
265
  declare const json_parseJson: typeof parseJson;
244
266
  declare const json_parseStructs: typeof parseStructs;
@@ -250,7 +272,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
250
272
  declare const json_validateJsonString: typeof validateJsonString;
251
273
  declare const json_yamlToJson: typeof yamlToJson;
252
274
  declare namespace json {
253
- 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_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_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_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 };
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 };
254
276
  }
255
277
 
256
- export { jsonToGo as A, jsonToPython as B, type ConvertOptions as C, type DiffNode as D, jsonToTypescript as E, jsonToYaml as F, type GoField as G, jsonToZod as H, minifyJson as I, type JsonDiffResult as J, parseJson as K, parseStructs as L, resolveJsonPointer as M, toPascalCase as N, toSnakeCase as O, type ParseStatus as P, validateJson as Q, validateJsonPath as R, validateJsonString as S, yamlToJson as T, type ValidationError as V, 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, csvToJson as n, detectFormat as o, diffJson as p, evaluateJsonPath as q, formatDiffLine as r, formatJson as s, generateExample as t, getJsonStats as u, inferGoType as v, inferPythonType as w, inferType as x, jsonSchemaToTypescript as y, jsonToCsv as z };
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 };
@@ -14,6 +14,7 @@
14
14
  * - json-to-python : jsonToPython, toSnakeCase, inferPythonType
15
15
  * - json-to-zod : jsonToZod
16
16
  * - json-schema-to-typescript : jsonSchemaToTypescript
17
+ * - json-merge-patch : mergeJsonPatch, applyJsonMergePatch
17
18
  */
18
19
  type ParseStatus = 'idle' | 'valid' | 'error';
19
20
  interface JsonParseResult {
@@ -201,6 +202,24 @@ interface JsonSchemaToTsOptions {
201
202
  declare function jsonSchemaToTypescript(schemaJson: string, options?: JsonSchemaToTsOptions): string | {
202
203
  error: string;
203
204
  };
205
+ interface MergePatchResult {
206
+ result: unknown;
207
+ }
208
+ /**
209
+ * Apply an RFC 7396 JSON Merge Patch to a target value. A patch that is not
210
+ * itself a JSON object replaces the target wholesale (this is how arrays are
211
+ * replaced rather than merged element by element); a null-valued key in an
212
+ * object patch removes that key from the result.
213
+ */
214
+ declare function mergeJsonPatch(target: unknown, patch: unknown): unknown;
215
+ /**
216
+ * Apply an RFC 7396 JSON Merge Patch document to a target JSON document,
217
+ * both given as JSON strings, and return the merged result. Pure recursive
218
+ * merge, no external calls.
219
+ */
220
+ declare function applyJsonMergePatch(targetJson: string, patchJson: string): MergePatchResult | {
221
+ error: string;
222
+ };
204
223
 
205
224
  type json_ConvertOptions = ConvertOptions;
206
225
  type json_CsvOptions = CsvOptions;
@@ -214,6 +233,7 @@ type json_JsonPathResult = JsonPathResult;
214
233
  type json_JsonPointerResult = JsonPointerResult;
215
234
  type json_JsonSchemaLike = JsonSchemaLike;
216
235
  type json_JsonSchemaToTsOptions = JsonSchemaToTsOptions;
236
+ type json_MergePatchResult = MergePatchResult;
217
237
  type json_ParseStatus = ParseStatus;
218
238
  type json_PythonClass = PythonClass;
219
239
  type json_PythonField = PythonField;
@@ -221,6 +241,7 @@ type json_PythonMode = PythonMode;
221
241
  type json_ValidationError = ValidationError;
222
242
  type json_ValidationResult = ValidationResult;
223
243
  type json_ZodOptions = ZodOptions;
244
+ declare const json_applyJsonMergePatch: typeof applyJsonMergePatch;
224
245
  declare const json_csvToJson: typeof csvToJson;
225
246
  declare const json_detectFormat: typeof detectFormat;
226
247
  declare const json_diffJson: typeof diffJson;
@@ -239,6 +260,7 @@ declare const json_jsonToPython: typeof jsonToPython;
239
260
  declare const json_jsonToTypescript: typeof jsonToTypescript;
240
261
  declare const json_jsonToYaml: typeof jsonToYaml;
241
262
  declare const json_jsonToZod: typeof jsonToZod;
263
+ declare const json_mergeJsonPatch: typeof mergeJsonPatch;
242
264
  declare const json_minifyJson: typeof minifyJson;
243
265
  declare const json_parseJson: typeof parseJson;
244
266
  declare const json_parseStructs: typeof parseStructs;
@@ -250,7 +272,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
250
272
  declare const json_validateJsonString: typeof validateJsonString;
251
273
  declare const json_yamlToJson: typeof yamlToJson;
252
274
  declare namespace json {
253
- 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_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_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_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 };
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 };
254
276
  }
255
277
 
256
- export { jsonToGo as A, jsonToPython as B, type ConvertOptions as C, type DiffNode as D, jsonToTypescript as E, jsonToYaml as F, type GoField as G, jsonToZod as H, minifyJson as I, type JsonDiffResult as J, parseJson as K, parseStructs as L, resolveJsonPointer as M, toPascalCase as N, toSnakeCase as O, type ParseStatus as P, validateJson as Q, validateJsonPath as R, validateJsonString as S, yamlToJson as T, type ValidationError as V, 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, csvToJson as n, detectFormat as o, diffJson as p, evaluateJsonPath as q, formatDiffLine as r, formatJson as s, generateExample as t, getJsonStats as u, inferGoType as v, inferPythonType as w, inferType as x, jsonSchemaToTypescript as y, jsonToCsv as z };
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 };
@@ -600,6 +600,20 @@ async function generateQrDataUrl(text, options) {
600
600
  }
601
601
  });
602
602
  }
603
+ function generateCspNonce(byteLength = 16) {
604
+ if (!Number.isInteger(byteLength) || byteLength < 8 || byteLength > 64) {
605
+ return { error: "Byte length must be a whole number between 8 and 64" };
606
+ }
607
+ const nonce = crypto.randomBytes(byteLength).toString("base64");
608
+ return {
609
+ nonce,
610
+ byteLength,
611
+ scriptSrcDirective: `script-src 'nonce-${nonce}'`,
612
+ styleSrcDirective: `style-src 'nonce-${nonce}'`,
613
+ scriptTag: `<script nonce="${nonce}">`,
614
+ styleTag: `<style nonce="${nonce}">`
615
+ };
616
+ }
603
617
 
604
618
  exports.AMBIGUOUS_CHARS = AMBIGUOUS_CHARS;
605
619
  exports.DATA_TYPES = DATA_TYPES;
@@ -612,6 +626,7 @@ exports.estimatePasswordEntropy = estimatePasswordEntropy;
612
626
  exports.generateBulk = generateBulk;
613
627
  exports.generateBulkPasswords = generateBulkPasswords;
614
628
  exports.generateBulkUlids = generateBulkUlids;
629
+ exports.generateCspNonce = generateCspNonce;
615
630
  exports.generateData = generateData;
616
631
  exports.generatePassword = generatePassword;
617
632
  exports.generateQrDataUrl = generateQrDataUrl;
@@ -1 +1 @@
1
- export { A as AMBIGUOUS_CHARS, D as DATA_TYPES, a as DEFAULT_OPTIONS, b as DEFAULT_QR_OPTIONS, c as DataType, G as GeneratedUuid, P as PasswordCharsetInfo, d as PasswordCrackTimeEstimate, e as PasswordEntropyResult, f as PasswordEntropyStrength, h as PasswordOptions, Q as QrErrorLevel, i as QrOptions, j as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, k as UuidVersion, l as checkStrength, m as estimatePasswordEntropy, n as generateBulk, o as generateBulkPasswords, p as generateBulkUlids, q as generateData, r as generatePassword, s as generateQrDataUrl, t as generateQrSvg, u as generateSingle, v as generateUlid, w as generateUuid, x as generateV4, y as generateV7, z as isValidUlid, B as isValidUuid, C as parseUlid, E as parseUuidVersion } from '../generators-Du8cBesn.cjs';
1
+ export { A as AMBIGUOUS_CHARS, C as CspNonceResult, D as DATA_TYPES, a as DEFAULT_OPTIONS, b as DEFAULT_QR_OPTIONS, c as DataType, G as GeneratedUuid, P as PasswordCharsetInfo, d as PasswordCrackTimeEstimate, e as PasswordEntropyResult, f as PasswordEntropyStrength, h as PasswordOptions, Q as QrErrorLevel, i as QrOptions, j as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, k as UuidVersion, l as checkStrength, m as estimatePasswordEntropy, n as generateBulk, o as generateBulkPasswords, p as generateBulkUlids, q as generateCspNonce, r as generateData, s as generatePassword, t as generateQrDataUrl, u as generateQrSvg, v as generateSingle, w as generateUlid, x as generateUuid, y as generateV4, z as generateV7, B as isValidUlid, E as isValidUuid, F as parseUlid, H as parseUuidVersion } from '../generators-DAXXrMvG.cjs';
@@ -1 +1 @@
1
- export { A as AMBIGUOUS_CHARS, D as DATA_TYPES, a as DEFAULT_OPTIONS, b as DEFAULT_QR_OPTIONS, c as DataType, G as GeneratedUuid, P as PasswordCharsetInfo, d as PasswordCrackTimeEstimate, e as PasswordEntropyResult, f as PasswordEntropyStrength, h as PasswordOptions, Q as QrErrorLevel, i as QrOptions, j as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, k as UuidVersion, l as checkStrength, m as estimatePasswordEntropy, n as generateBulk, o as generateBulkPasswords, p as generateBulkUlids, q as generateData, r as generatePassword, s as generateQrDataUrl, t as generateQrSvg, u as generateSingle, v as generateUlid, w as generateUuid, x as generateV4, y as generateV7, z as isValidUlid, B as isValidUuid, C as parseUlid, E as parseUuidVersion } from '../generators-Du8cBesn.js';
1
+ export { A as AMBIGUOUS_CHARS, C as CspNonceResult, D as DATA_TYPES, a as DEFAULT_OPTIONS, b as DEFAULT_QR_OPTIONS, c as DataType, G as GeneratedUuid, P as PasswordCharsetInfo, d as PasswordCrackTimeEstimate, e as PasswordEntropyResult, f as PasswordEntropyStrength, h as PasswordOptions, Q as QrErrorLevel, i as QrOptions, j as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, k as UuidVersion, l as checkStrength, m as estimatePasswordEntropy, n as generateBulk, o as generateBulkPasswords, p as generateBulkUlids, q as generateCspNonce, r as generateData, s as generatePassword, t as generateQrDataUrl, u as generateQrSvg, v as generateSingle, w as generateUlid, x as generateUuid, y as generateV4, z as generateV7, B as isValidUlid, E as isValidUuid, F as parseUlid, H as parseUuidVersion } from '../generators-DAXXrMvG.js';
@@ -1,2 +1,2 @@
1
- export { AMBIGUOUS_CHARS, DATA_TYPES, DEFAULT_OPTIONS, DEFAULT_QR_OPTIONS, SYMBOL_CHARS, ULID_REGEX, checkStrength, estimatePasswordEntropy, generateBulk, generateBulkPasswords, generateBulkUlids, generateData, generatePassword, generateQrDataUrl, generateQrSvg, generateSingle, generateUlid, generateUuid, generateV4, generateV7, isValidUlid, isValidUuid, parseUlid, parseUuidVersion } from '../chunk-3TYWIX3B.js';
1
+ export { AMBIGUOUS_CHARS, DATA_TYPES, DEFAULT_OPTIONS, DEFAULT_QR_OPTIONS, SYMBOL_CHARS, ULID_REGEX, checkStrength, estimatePasswordEntropy, generateBulk, generateBulkPasswords, generateBulkUlids, generateCspNonce, generateData, generatePassword, generateQrDataUrl, generateQrSvg, generateSingle, generateUlid, generateUuid, generateV4, generateV7, isValidUlid, isValidUuid, parseUlid, parseUuidVersion } from '../chunk-422ICOZX.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -1392,7 +1392,39 @@ function jsonSchemaToTypescript(schemaJson, options) {
1392
1392
  }
1393
1393
  return parts.join("\n\n");
1394
1394
  }
1395
+ function _isMergePatchObject(value) {
1396
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1397
+ }
1398
+ function mergeJsonPatch(target, patch) {
1399
+ if (!_isMergePatchObject(patch)) return patch;
1400
+ const result = _isMergePatchObject(target) ? { ...target } : {};
1401
+ for (const key of Object.keys(patch)) {
1402
+ const value = patch[key];
1403
+ if (value === null) {
1404
+ delete result[key];
1405
+ } else {
1406
+ result[key] = mergeJsonPatch(result[key], value);
1407
+ }
1408
+ }
1409
+ return result;
1410
+ }
1411
+ function applyJsonMergePatch(targetJson, patchJson) {
1412
+ let target;
1413
+ try {
1414
+ target = JSON.parse(targetJson);
1415
+ } catch {
1416
+ return { error: "Target is not valid JSON" };
1417
+ }
1418
+ let patch;
1419
+ try {
1420
+ patch = JSON.parse(patchJson);
1421
+ } catch {
1422
+ return { error: "Patch is not valid JSON" };
1423
+ }
1424
+ return { result: mergeJsonPatch(target, patch) };
1425
+ }
1395
1426
 
1427
+ exports.applyJsonMergePatch = applyJsonMergePatch;
1396
1428
  exports.csvToJson = csvToJson;
1397
1429
  exports.detectFormat = detectFormat;
1398
1430
  exports.diffJson = diffJson;
@@ -1411,6 +1443,7 @@ exports.jsonToPython = jsonToPython;
1411
1443
  exports.jsonToTypescript = jsonToTypescript;
1412
1444
  exports.jsonToYaml = jsonToYaml;
1413
1445
  exports.jsonToZod = jsonToZod;
1446
+ exports.mergeJsonPatch = mergeJsonPatch;
1414
1447
  exports.minifyJson = minifyJson;
1415
1448
  exports.parseJson = parseJson;
1416
1449
  exports.parseStructs = parseStructs;
@@ -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, P as ParseStatus, i as PythonClass, k as PythonField, l as PythonMode, V as ValidationError, m as ValidationResult, Z as ZodOptions, n as csvToJson, o as detectFormat, p as diffJson, q as evaluateJsonPath, r as formatDiffLine, s as formatJson, t as generateExample, u as getJsonStats, v as inferGoType, w as inferPythonType, x as inferType, y as jsonSchemaToTypescript, z as jsonToCsv, A as jsonToGo, B as jsonToPython, E as jsonToTypescript, F as jsonToYaml, H as jsonToZod, I as minifyJson, K as parseJson, L as parseStructs, M as resolveJsonPointer, N as toPascalCase, O as toSnakeCase, Q as validateJson, R as validateJsonPath, S as validateJsonString, T as yamlToJson } from '../json-Ta9JykSB.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 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 +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, P as ParseStatus, i as PythonClass, k as PythonField, l as PythonMode, V as ValidationError, m as ValidationResult, Z as ZodOptions, n as csvToJson, o as detectFormat, p as diffJson, q as evaluateJsonPath, r as formatDiffLine, s as formatJson, t as generateExample, u as getJsonStats, v as inferGoType, w as inferPythonType, x as inferType, y as jsonSchemaToTypescript, z as jsonToCsv, A as jsonToGo, B as jsonToPython, E as jsonToTypescript, F as jsonToYaml, H as jsonToZod, I as minifyJson, K as parseJson, L as parseStructs, M as resolveJsonPointer, N as toPascalCase, O as toSnakeCase, Q as validateJson, R as validateJsonPath, S as validateJsonString, T as yamlToJson } from '../json-Ta9JykSB.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 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,2 +1,2 @@
1
- export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonSchemaToTypescript, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-WVEKRKGU.js';
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';
2
2
  import '../chunk-MLKGABMK.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utilix-tech/sdk",
3
- "version": "0.56.0",
3
+ "version": "0.57.0",
4
4
  "description": "154+ developer utility tools for Node.js: JSON, encoding, hashing, color, CSS, network and more. Runs locally, no API key required.",
5
5
  "author": "Utilix <hello@utilix.tech>",
6
6
  "license": "MIT",