@utilix-tech/sdk 0.29.0 → 0.31.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 +25 -11
  3. package/dist/{chunk-2CJSLYWI.js → chunk-3TYWIX3B.js} +107 -1
  4. package/dist/{chunk-66QHV5KW.js → chunk-6FIB72KX.js} +66 -1
  5. package/dist/{chunk-I63BCOAG.js → chunk-GDIZWDBY.js} +57 -1
  6. package/dist/{chunk-WO3LJMVV.js → chunk-WVEKRKGU.js} +101 -1
  7. package/dist/{data-XRb0D7Zn.d.cts → data-C4lCByXw.d.cts} +24 -2
  8. package/dist/{data-XRb0D7Zn.d.ts → data-C4lCByXw.d.ts} +24 -2
  9. package/dist/{generators-BGtRGpJZ.d.ts → generators-Du8cBesn.d.cts} +45 -2
  10. package/dist/{generators-BGtRGpJZ.d.cts → generators-Du8cBesn.d.ts} +45 -2
  11. package/dist/index.cjs +327 -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-DEVFIpsC.d.cts → json-Ta9JykSB.d.cts} +36 -2
  16. package/dist/{json-DEVFIpsC.d.ts → json-Ta9JykSB.d.ts} +36 -2
  17. package/dist/tools/data.cjs +65 -0
  18. package/dist/tools/data.d.cts +1 -1
  19. package/dist/tools/data.d.ts +1 -1
  20. package/dist/tools/data.js +1 -1
  21. package/dist/tools/generators.cjs +106 -0
  22. package/dist/tools/generators.d.cts +1 -1
  23. package/dist/tools/generators.d.ts +1 -1
  24. package/dist/tools/generators.js +1 -1
  25. package/dist/tools/json.cjs +100 -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 +56 -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-COt5uI20.d.cts → units-DQYLZd1n.d.cts} +33 -2
  34. package/dist/{units-COt5uI20.d.ts → units-DQYLZd1n.d.ts} +33 -2
  35. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { media_exports as media } from './chunk-L6V4W4SU.js';
2
- export { units_exports as units } from './chunk-I63BCOAG.js';
2
+ export { units_exports as units } from './chunk-GDIZWDBY.js';
3
3
  export { network_exports as network } from './chunk-CSNTHZHF.js';
4
4
  export { api_exports as api } from './chunk-52ZDKSIX.js';
5
5
  export { code_exports as code } from './chunk-LXKIPPDG.js';
@@ -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-265NPGKH.js';
10
- export { json_exports as json } from './chunk-WO3LJMVV.js';
10
+ export { json_exports as json } from './chunk-WVEKRKGU.js';
11
11
  export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
12
12
  export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
13
13
  export { text_exports as text } from './chunk-AFEZ6N4A.js';
14
- export { data_exports as data } from './chunk-66QHV5KW.js';
15
- export { generators_exports as generators } from './chunk-2CJSLYWI.js';
14
+ export { data_exports as data } from './chunk-6FIB72KX.js';
15
+ export { generators_exports as generators } from './chunk-3TYWIX3B.js';
16
16
  export { time_exports as time } from './chunk-IEPWZERQ.js';
17
17
  import './chunk-MLKGABMK.js';
18
18
 
@@ -13,6 +13,7 @@
13
13
  * - json-to-go : jsonToGo, parseStructs, toPascalCase, inferGoType
14
14
  * - json-to-python : jsonToPython, toSnakeCase, inferPythonType
15
15
  * - json-to-zod : jsonToZod
16
+ * - json-schema-to-typescript : jsonSchemaToTypescript
16
17
  */
17
18
  type ParseStatus = 'idle' | 'valid' | 'error';
18
19
  interface JsonParseResult {
@@ -170,6 +171,36 @@ interface JsonPointerResult {
170
171
  * traversal, no external calls.
171
172
  */
172
173
  declare function resolveJsonPointer(json: string, pointer: string): JsonPointerResult;
174
+ interface JsonSchemaLike {
175
+ type?: string | string[];
176
+ properties?: Record<string, JsonSchemaLike>;
177
+ required?: string[];
178
+ items?: JsonSchemaLike | JsonSchemaLike[];
179
+ enum?: unknown[];
180
+ const?: unknown;
181
+ oneOf?: JsonSchemaLike[];
182
+ anyOf?: JsonSchemaLike[];
183
+ allOf?: JsonSchemaLike[];
184
+ $ref?: string;
185
+ additionalProperties?: boolean | JsonSchemaLike;
186
+ description?: string;
187
+ definitions?: Record<string, JsonSchemaLike>;
188
+ $defs?: Record<string, JsonSchemaLike>;
189
+ [key: string]: unknown;
190
+ }
191
+ interface JsonSchemaToTsOptions {
192
+ rootName?: string;
193
+ }
194
+ /**
195
+ * Convert a JSON Schema document into TypeScript interfaces/types. Unlike
196
+ * jsonToTypescript (which infers types from an example data payload), this
197
+ * reads the schema's declared `type`/`enum`/`required` keywords directly, so
198
+ * optional vs. required fields and enum/union types come through accurately
199
+ * instead of being guessed from a single example value.
200
+ */
201
+ declare function jsonSchemaToTypescript(schemaJson: string, options?: JsonSchemaToTsOptions): string | {
202
+ error: string;
203
+ };
173
204
 
174
205
  type json_ConvertOptions = ConvertOptions;
175
206
  type json_CsvOptions = CsvOptions;
@@ -181,6 +212,8 @@ type json_JsonDiffResult = JsonDiffResult;
181
212
  type json_JsonParseResult = JsonParseResult;
182
213
  type json_JsonPathResult = JsonPathResult;
183
214
  type json_JsonPointerResult = JsonPointerResult;
215
+ type json_JsonSchemaLike = JsonSchemaLike;
216
+ type json_JsonSchemaToTsOptions = JsonSchemaToTsOptions;
184
217
  type json_ParseStatus = ParseStatus;
185
218
  type json_PythonClass = PythonClass;
186
219
  type json_PythonField = PythonField;
@@ -199,6 +232,7 @@ declare const json_getJsonStats: typeof getJsonStats;
199
232
  declare const json_inferGoType: typeof inferGoType;
200
233
  declare const json_inferPythonType: typeof inferPythonType;
201
234
  declare const json_inferType: typeof inferType;
235
+ declare const json_jsonSchemaToTypescript: typeof jsonSchemaToTypescript;
202
236
  declare const json_jsonToCsv: typeof jsonToCsv;
203
237
  declare const json_jsonToGo: typeof jsonToGo;
204
238
  declare const json_jsonToPython: typeof jsonToPython;
@@ -216,7 +250,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
216
250
  declare const json_validateJsonString: typeof validateJsonString;
217
251
  declare const json_yamlToJson: typeof yamlToJson;
218
252
  declare namespace json {
219
- 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_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_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 };
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 };
220
254
  }
221
255
 
222
- export { jsonToYaml as A, jsonToZod as B, type ConvertOptions as C, type DiffNode as D, minifyJson as E, parseJson as F, type GoField as G, parseStructs as H, resolveJsonPointer as I, type JsonDiffResult as J, toPascalCase as K, toSnakeCase as L, validateJson as M, validateJsonPath as N, validateJsonString as O, type ParseStatus as P, yamlToJson as Q, 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 PythonClass as g, type PythonField as h, type PythonMode as i, json as j, type ValidationResult as k, csvToJson as l, detectFormat as m, diffJson as n, evaluateJsonPath as o, formatDiffLine as p, formatJson as q, generateExample as r, getJsonStats as s, inferGoType as t, inferPythonType as u, inferType as v, jsonToCsv as w, jsonToGo as x, jsonToPython as y, jsonToTypescript as z };
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 };
@@ -13,6 +13,7 @@
13
13
  * - json-to-go : jsonToGo, parseStructs, toPascalCase, inferGoType
14
14
  * - json-to-python : jsonToPython, toSnakeCase, inferPythonType
15
15
  * - json-to-zod : jsonToZod
16
+ * - json-schema-to-typescript : jsonSchemaToTypescript
16
17
  */
17
18
  type ParseStatus = 'idle' | 'valid' | 'error';
18
19
  interface JsonParseResult {
@@ -170,6 +171,36 @@ interface JsonPointerResult {
170
171
  * traversal, no external calls.
171
172
  */
172
173
  declare function resolveJsonPointer(json: string, pointer: string): JsonPointerResult;
174
+ interface JsonSchemaLike {
175
+ type?: string | string[];
176
+ properties?: Record<string, JsonSchemaLike>;
177
+ required?: string[];
178
+ items?: JsonSchemaLike | JsonSchemaLike[];
179
+ enum?: unknown[];
180
+ const?: unknown;
181
+ oneOf?: JsonSchemaLike[];
182
+ anyOf?: JsonSchemaLike[];
183
+ allOf?: JsonSchemaLike[];
184
+ $ref?: string;
185
+ additionalProperties?: boolean | JsonSchemaLike;
186
+ description?: string;
187
+ definitions?: Record<string, JsonSchemaLike>;
188
+ $defs?: Record<string, JsonSchemaLike>;
189
+ [key: string]: unknown;
190
+ }
191
+ interface JsonSchemaToTsOptions {
192
+ rootName?: string;
193
+ }
194
+ /**
195
+ * Convert a JSON Schema document into TypeScript interfaces/types. Unlike
196
+ * jsonToTypescript (which infers types from an example data payload), this
197
+ * reads the schema's declared `type`/`enum`/`required` keywords directly, so
198
+ * optional vs. required fields and enum/union types come through accurately
199
+ * instead of being guessed from a single example value.
200
+ */
201
+ declare function jsonSchemaToTypescript(schemaJson: string, options?: JsonSchemaToTsOptions): string | {
202
+ error: string;
203
+ };
173
204
 
174
205
  type json_ConvertOptions = ConvertOptions;
175
206
  type json_CsvOptions = CsvOptions;
@@ -181,6 +212,8 @@ type json_JsonDiffResult = JsonDiffResult;
181
212
  type json_JsonParseResult = JsonParseResult;
182
213
  type json_JsonPathResult = JsonPathResult;
183
214
  type json_JsonPointerResult = JsonPointerResult;
215
+ type json_JsonSchemaLike = JsonSchemaLike;
216
+ type json_JsonSchemaToTsOptions = JsonSchemaToTsOptions;
184
217
  type json_ParseStatus = ParseStatus;
185
218
  type json_PythonClass = PythonClass;
186
219
  type json_PythonField = PythonField;
@@ -199,6 +232,7 @@ declare const json_getJsonStats: typeof getJsonStats;
199
232
  declare const json_inferGoType: typeof inferGoType;
200
233
  declare const json_inferPythonType: typeof inferPythonType;
201
234
  declare const json_inferType: typeof inferType;
235
+ declare const json_jsonSchemaToTypescript: typeof jsonSchemaToTypescript;
202
236
  declare const json_jsonToCsv: typeof jsonToCsv;
203
237
  declare const json_jsonToGo: typeof jsonToGo;
204
238
  declare const json_jsonToPython: typeof jsonToPython;
@@ -216,7 +250,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
216
250
  declare const json_validateJsonString: typeof validateJsonString;
217
251
  declare const json_yamlToJson: typeof yamlToJson;
218
252
  declare namespace json {
219
- 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_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_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 };
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 };
220
254
  }
221
255
 
222
- export { jsonToYaml as A, jsonToZod as B, type ConvertOptions as C, type DiffNode as D, minifyJson as E, parseJson as F, type GoField as G, parseStructs as H, resolveJsonPointer as I, type JsonDiffResult as J, toPascalCase as K, toSnakeCase as L, validateJson as M, validateJsonPath as N, validateJsonString as O, type ParseStatus as P, yamlToJson as Q, 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 PythonClass as g, type PythonField as h, type PythonMode as i, json as j, type ValidationResult as k, csvToJson as l, detectFormat as m, diffJson as n, evaluateJsonPath as o, formatDiffLine as p, formatJson as q, generateExample as r, getJsonStats as s, inferGoType as t, inferPythonType as u, inferType as v, jsonToCsv as w, jsonToGo as x, jsonToPython as y, jsonToTypescript as z };
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 };
@@ -1309,6 +1309,70 @@ function shiftSubtitles(input, offsetSeconds, target) {
1309
1309
  warnings
1310
1310
  };
1311
1311
  }
1312
+ function parseFrontMatterScalar(value) {
1313
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
1314
+ return value.slice(1, -1);
1315
+ }
1316
+ if (value === "true") return true;
1317
+ if (value === "false") return false;
1318
+ if (value === "null" || value === "~") return null;
1319
+ if (value !== "" && !Number.isNaN(Number(value))) return Number(value);
1320
+ return value;
1321
+ }
1322
+ function parseFrontMatter(input) {
1323
+ if (typeof input !== "string" || input.length === 0) return { error: "input is required" };
1324
+ const normalized = input.replace(/\r\n/g, "\n");
1325
+ if (!normalized.startsWith("---\n") && normalized !== "---") {
1326
+ return { frontMatter: {}, body: input, hasFrontMatter: false, raw: "" };
1327
+ }
1328
+ const closingIdx = normalized.indexOf("\n---", 4);
1329
+ if (closingIdx === -1) {
1330
+ return { error: 'Front matter opening delimiter found but no closing "---" delimiter' };
1331
+ }
1332
+ const raw = normalized.slice(4, closingIdx);
1333
+ let afterClose = normalized.slice(closingIdx + 4);
1334
+ if (afterClose.startsWith("\n")) afterClose = afterClose.slice(1);
1335
+ const frontMatter = {};
1336
+ const rawLines = raw.split("\n");
1337
+ let i = 0;
1338
+ while (i < rawLines.length) {
1339
+ const line = rawLines[i];
1340
+ if (line.trim() === "" || line.trim().startsWith("#")) {
1341
+ i++;
1342
+ continue;
1343
+ }
1344
+ const colonIdx = line.indexOf(":");
1345
+ if (colonIdx === -1) return { error: `Invalid front matter line ${i + 1}: expected "key: value"` };
1346
+ const key = line.slice(0, colonIdx).trim();
1347
+ if (!key) return { error: `Invalid front matter line ${i + 1}: empty key` };
1348
+ const rest = line.slice(colonIdx + 1).trim();
1349
+ if (rest === "") {
1350
+ const listItems = [];
1351
+ let j = i + 1;
1352
+ while (j < rawLines.length && /^\s*-\s+/.test(rawLines[j])) {
1353
+ listItems.push(rawLines[j].replace(/^\s*-\s+/, "").trim());
1354
+ j++;
1355
+ }
1356
+ if (listItems.length > 0) {
1357
+ frontMatter[key] = listItems.map(parseFrontMatterScalar);
1358
+ i = j;
1359
+ continue;
1360
+ }
1361
+ frontMatter[key] = null;
1362
+ i++;
1363
+ continue;
1364
+ }
1365
+ if (rest.startsWith("[") && rest.endsWith("]")) {
1366
+ const inner = rest.slice(1, -1).trim();
1367
+ frontMatter[key] = inner === "" ? [] : inner.split(",").map((s) => parseFrontMatterScalar(s.trim()));
1368
+ i++;
1369
+ continue;
1370
+ }
1371
+ frontMatter[key] = parseFrontMatterScalar(rest);
1372
+ i++;
1373
+ }
1374
+ return { frontMatter, body: afterClose, hasFrontMatter: true, raw };
1375
+ }
1312
1376
 
1313
1377
  exports.convertSubtitles = convertSubtitles;
1314
1378
  exports.csvToJson = csvToJson;
@@ -1337,6 +1401,7 @@ exports.minifyXml = minifyXml;
1337
1401
  exports.ndjsonToJsonArray = ndjsonToJsonArray;
1338
1402
  exports.parseCsv = parseCsv;
1339
1403
  exports.parseEnv = parseEnv;
1404
+ exports.parseFrontMatter = parseFrontMatter;
1340
1405
  exports.parseIni = parseIni;
1341
1406
  exports.parseSubtitleTimestamp = parseSubtitleTimestamp;
1342
1407
  exports.parseSubtitles = parseSubtitles;
@@ -1 +1 @@
1
- export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, I as IniSection, N as NdjsonLineResult, f as NdjsonValidateResult, P as ParseOptions, g as ParsedIni, h as ParsedSubtitles, S as SubtitleCue, i as SubtitleFormat, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, j as XmlToJsonOptions, k as convertSubtitles, l as csvToJson, m as detectDelimiter, n as detectSubtitleFormat, o as diffEnvExample, p as envToExport, q as envToJson, r as formatNdjson, s as formatSubtitleTimestamp, t as formatToml, u as formatXml, v as getSection, w as getSectionNames, x as getTomlStats, y as getXmlStats, z as getYamlStats, A as iniToJson, B as jsonArrayToNdjson, D as jsonToIni, F as jsonToToml, G as jsonToXml, H as minifyNdjson, J as minifyToml, K as minifyXml, L as ndjsonToJsonArray, M as parseCsv, O as parseEnv, Q as parseIni, R as parseSubtitleTimestamp, U as parseSubtitles, W as parseXmlToObject, Y as serializeSubtitles, Z as shiftSubtitles, _ as stringifyIni, $ as toCsvString, a0 as tomlToJson, a1 as validateEnvKey, a2 as validateIni, a3 as validateNdjson, a4 as validateToml, a5 as validateXml, a6 as validateYaml, a7 as xmlToJson } from '../data-XRb0D7Zn.cjs';
1
+ export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, F as FrontMatterError, f as FrontMatterResult, I as IniSection, N as NdjsonLineResult, g as NdjsonValidateResult, P as ParseOptions, h as ParsedIni, i as ParsedSubtitles, S as SubtitleCue, j as SubtitleFormat, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, k as XmlToJsonOptions, l as convertSubtitles, m as csvToJson, n as detectDelimiter, o as detectSubtitleFormat, p as diffEnvExample, q as envToExport, r as envToJson, s as formatNdjson, t as formatSubtitleTimestamp, u as formatToml, v as formatXml, w as getSection, x as getSectionNames, y as getTomlStats, z as getXmlStats, A as getYamlStats, B as iniToJson, D as jsonArrayToNdjson, G as jsonToIni, H as jsonToToml, J as jsonToXml, K as minifyNdjson, L as minifyToml, M as minifyXml, O as ndjsonToJsonArray, Q as parseCsv, R as parseEnv, U as parseFrontMatter, W as parseIni, Y as parseSubtitleTimestamp, Z as parseSubtitles, _ as parseXmlToObject, $ as serializeSubtitles, a0 as shiftSubtitles, a1 as stringifyIni, a2 as toCsvString, a3 as tomlToJson, a4 as validateEnvKey, a5 as validateIni, a6 as validateNdjson, a7 as validateToml, a8 as validateXml, a9 as validateYaml, aa as xmlToJson } from '../data-C4lCByXw.cjs';
@@ -1 +1 @@
1
- export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, I as IniSection, N as NdjsonLineResult, f as NdjsonValidateResult, P as ParseOptions, g as ParsedIni, h as ParsedSubtitles, S as SubtitleCue, i as SubtitleFormat, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, j as XmlToJsonOptions, k as convertSubtitles, l as csvToJson, m as detectDelimiter, n as detectSubtitleFormat, o as diffEnvExample, p as envToExport, q as envToJson, r as formatNdjson, s as formatSubtitleTimestamp, t as formatToml, u as formatXml, v as getSection, w as getSectionNames, x as getTomlStats, y as getXmlStats, z as getYamlStats, A as iniToJson, B as jsonArrayToNdjson, D as jsonToIni, F as jsonToToml, G as jsonToXml, H as minifyNdjson, J as minifyToml, K as minifyXml, L as ndjsonToJsonArray, M as parseCsv, O as parseEnv, Q as parseIni, R as parseSubtitleTimestamp, U as parseSubtitles, W as parseXmlToObject, Y as serializeSubtitles, Z as shiftSubtitles, _ as stringifyIni, $ as toCsvString, a0 as tomlToJson, a1 as validateEnvKey, a2 as validateIni, a3 as validateNdjson, a4 as validateToml, a5 as validateXml, a6 as validateYaml, a7 as xmlToJson } from '../data-XRb0D7Zn.js';
1
+ export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, F as FrontMatterError, f as FrontMatterResult, I as IniSection, N as NdjsonLineResult, g as NdjsonValidateResult, P as ParseOptions, h as ParsedIni, i as ParsedSubtitles, S as SubtitleCue, j as SubtitleFormat, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, k as XmlToJsonOptions, l as convertSubtitles, m as csvToJson, n as detectDelimiter, o as detectSubtitleFormat, p as diffEnvExample, q as envToExport, r as envToJson, s as formatNdjson, t as formatSubtitleTimestamp, u as formatToml, v as formatXml, w as getSection, x as getSectionNames, y as getTomlStats, z as getXmlStats, A as getYamlStats, B as iniToJson, D as jsonArrayToNdjson, G as jsonToIni, H as jsonToToml, J as jsonToXml, K as minifyNdjson, L as minifyToml, M as minifyXml, O as ndjsonToJsonArray, Q as parseCsv, R as parseEnv, U as parseFrontMatter, W as parseIni, Y as parseSubtitleTimestamp, Z as parseSubtitles, _ as parseXmlToObject, $ as serializeSubtitles, a0 as shiftSubtitles, a1 as stringifyIni, a2 as toCsvString, a3 as tomlToJson, a4 as validateEnvKey, a5 as validateIni, a6 as validateNdjson, a7 as validateToml, a8 as validateXml, a9 as validateYaml, aa as xmlToJson } from '../data-C4lCByXw.js';
@@ -1,2 +1,2 @@
1
- export { convertSubtitles, csvToJson, detectDelimiter, detectSubtitleFormat, diffEnvExample, envToExport, envToJson, formatNdjson, formatSubtitleTimestamp, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseIni, parseSubtitleTimestamp, parseSubtitles, parseXmlToObject, serializeSubtitles, shiftSubtitles, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson } from '../chunk-66QHV5KW.js';
1
+ export { convertSubtitles, csvToJson, detectDelimiter, detectSubtitleFormat, diffEnvExample, envToExport, envToJson, formatNdjson, formatSubtitleTimestamp, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseFrontMatter, parseIni, parseSubtitleTimestamp, parseSubtitles, parseXmlToObject, serializeSubtitles, shiftSubtitles, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson } from '../chunk-6FIB72KX.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -207,6 +207,111 @@ function checkStrength(password) {
207
207
  color: levels[score].color
208
208
  };
209
209
  }
210
+ var _SYMBOL_POOL_CHARS = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
211
+ var _SYMBOL_POOL_SET = new Set(_SYMBOL_POOL_CHARS.split(""));
212
+ function _hasSymbolChar(password) {
213
+ for (const ch of password) {
214
+ if (_SYMBOL_POOL_SET.has(ch)) return true;
215
+ }
216
+ return false;
217
+ }
218
+ function _hasSequentialRun(password, minRun) {
219
+ let ascRun = 1;
220
+ let descRun = 1;
221
+ for (let i = 1; i < password.length; i++) {
222
+ const prev = password.charCodeAt(i - 1);
223
+ const curr = password.charCodeAt(i);
224
+ if (curr === prev + 1) {
225
+ ascRun++;
226
+ descRun = 1;
227
+ } else if (curr === prev - 1) {
228
+ descRun++;
229
+ ascRun = 1;
230
+ } else {
231
+ ascRun = 1;
232
+ descRun = 1;
233
+ }
234
+ if (ascRun >= minRun || descRun >= minRun) return true;
235
+ }
236
+ return false;
237
+ }
238
+ function _formatCrackDuration(seconds) {
239
+ if (!isFinite(seconds)) return "effectively never";
240
+ if (seconds < 1) return "instantly";
241
+ const units = [
242
+ ["century", 315576e4],
243
+ ["year", 31557600],
244
+ ["month", 2629800],
245
+ ["day", 86400],
246
+ ["hour", 3600],
247
+ ["minute", 60],
248
+ ["second", 1]
249
+ ];
250
+ for (const [name, unitSeconds] of units) {
251
+ if (seconds >= unitSeconds) {
252
+ const value = seconds / unitSeconds;
253
+ if (name === "century" && value > 1e3) return "longer than the age of the universe";
254
+ const rounded = value >= 100 ? Math.round(value) : Math.round(value * 10) / 10;
255
+ const plural = name === "century" ? "centuries" : `${name}s`;
256
+ return `${rounded} ${rounded === 1 ? name : plural}`;
257
+ }
258
+ }
259
+ return "instantly";
260
+ }
261
+ function estimatePasswordEntropy(password) {
262
+ if (!password) return { error: "Password is required" };
263
+ const hasLowercase = /[a-z]/.test(password);
264
+ const hasUppercase = /[A-Z]/.test(password);
265
+ const hasDigits = /[0-9]/.test(password);
266
+ const hasSymbols = _hasSymbolChar(password);
267
+ const hasOther = /[^\x20-\x7e]/.test(password);
268
+ let poolSize = 0;
269
+ if (hasLowercase) poolSize += 26;
270
+ if (hasUppercase) poolSize += 26;
271
+ if (hasDigits) poolSize += 10;
272
+ if (hasSymbols) poolSize += _SYMBOL_POOL_CHARS.length;
273
+ if (hasOther) poolSize += 100;
274
+ const entropyBits = Math.round(password.length * Math.log2(poolSize) * 100) / 100;
275
+ let strength;
276
+ if (entropyBits < 28) strength = "very-weak";
277
+ else if (entropyBits < 36) strength = "weak";
278
+ else if (entropyBits < 60) strength = "fair";
279
+ else if (entropyBits < 128) strength = "strong";
280
+ else strength = "very-strong";
281
+ const averageGuesses = Math.pow(2, entropyBits) / 2;
282
+ const scenarios = [
283
+ { scenario: "Online, throttled (100 guesses/hour)", guessesPerSecond: 100 / 3600 },
284
+ { scenario: "Online, unthrottled (10 guesses/sec)", guessesPerSecond: 10 },
285
+ { scenario: "Offline, slow hash e.g. bcrypt (10k guesses/sec)", guessesPerSecond: 1e4 },
286
+ { scenario: "Offline, fast hash / GPU cluster (10B guesses/sec)", guessesPerSecond: 1e10 }
287
+ ];
288
+ const crackTimes = scenarios.map((s) => ({
289
+ scenario: s.scenario,
290
+ guessesPerSecond: s.guessesPerSecond,
291
+ humanReadable: _formatCrackDuration(averageGuesses / s.guessesPerSecond)
292
+ }));
293
+ const warnings = [];
294
+ if (password.length < 8) {
295
+ warnings.push("Shorter than 8 characters \u2014 most sites and cracking tools treat this as trivially weak regardless of entropy.");
296
+ }
297
+ if (/(.)\1{2,}/.test(password)) {
298
+ warnings.push('Contains a repeated character run (e.g. "aaa"), which is easier to guess than the entropy figure implies.');
299
+ }
300
+ if (_hasSequentialRun(password, 3)) {
301
+ warnings.push('Contains a sequential run (e.g. "abc" or "321"), which is easier to guess than the entropy figure implies.');
302
+ }
303
+ if (poolSize <= 26) {
304
+ warnings.push("Uses only one character class \u2014 mixing in uppercase, digits, or symbols raises the character pool and entropy.");
305
+ }
306
+ return {
307
+ length: password.length,
308
+ charset: { hasLowercase, hasUppercase, hasDigits, hasSymbols, hasOther, poolSize },
309
+ entropyBits,
310
+ strength,
311
+ crackTimes,
312
+ warnings
313
+ };
314
+ }
210
315
  var DATA_TYPES = [
211
316
  { value: "name", label: "Full Name", example: "John Smith" },
212
317
  { value: "email", label: "Email Address", example: "john.smith@gmail.com" },
@@ -503,6 +608,7 @@ exports.DEFAULT_QR_OPTIONS = DEFAULT_QR_OPTIONS;
503
608
  exports.SYMBOL_CHARS = SYMBOL_CHARS;
504
609
  exports.ULID_REGEX = ULID_REGEX;
505
610
  exports.checkStrength = checkStrength;
611
+ exports.estimatePasswordEntropy = estimatePasswordEntropy;
506
612
  exports.generateBulk = generateBulk;
507
613
  exports.generateBulkPasswords = generateBulkPasswords;
508
614
  exports.generateBulkUlids = generateBulkUlids;
@@ -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 PasswordOptions, Q as QrErrorLevel, d as QrOptions, e as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, f as UuidVersion, h as checkStrength, i as generateBulk, j as generateBulkPasswords, k as generateBulkUlids, l as generateData, m as generatePassword, n as generateQrDataUrl, o as generateQrSvg, p as generateSingle, q as generateUlid, r as generateUuid, s as generateV4, t as generateV7, u as isValidUlid, v as isValidUuid, w as parseUlid, x as parseUuidVersion } from '../generators-BGtRGpJZ.cjs';
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 +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 PasswordOptions, Q as QrErrorLevel, d as QrOptions, e as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, f as UuidVersion, h as checkStrength, i as generateBulk, j as generateBulkPasswords, k as generateBulkUlids, l as generateData, m as generatePassword, n as generateQrDataUrl, o as generateQrSvg, p as generateSingle, q as generateUlid, r as generateUuid, s as generateV4, t as generateV7, u as isValidUlid, v as isValidUuid, w as parseUlid, x as parseUuidVersion } from '../generators-BGtRGpJZ.js';
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,2 +1,2 @@
1
- export { AMBIGUOUS_CHARS, DATA_TYPES, DEFAULT_OPTIONS, DEFAULT_QR_OPTIONS, SYMBOL_CHARS, ULID_REGEX, checkStrength, generateBulk, generateBulkPasswords, generateBulkUlids, generateData, generatePassword, generateQrDataUrl, generateQrSvg, generateSingle, generateUlid, generateUuid, generateV4, generateV7, isValidUlid, isValidUuid, parseUlid, parseUuidVersion } from '../chunk-2CJSLYWI.js';
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';
2
2
  import '../chunk-MLKGABMK.js';
@@ -1293,6 +1293,105 @@ function resolveJsonPointer(json, pointer) {
1293
1293
  }
1294
1294
  return { pointer, found: true, value: current, tokens };
1295
1295
  }
1296
+ function _schemaRefName(ref) {
1297
+ const parts = ref.split("/");
1298
+ return _capitalize(parts[parts.length - 1] || "Ref");
1299
+ }
1300
+ function _schemaLiteralType(value) {
1301
+ if (typeof value === "string") return JSON.stringify(value);
1302
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
1303
+ if (value === null) return "null";
1304
+ return JSON.stringify(value);
1305
+ }
1306
+ function _safePropertyKey(key) {
1307
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
1308
+ }
1309
+ function _schemaToTsType(schema, name, interfaces) {
1310
+ if (schema.$ref) return _schemaRefName(schema.$ref);
1311
+ if (schema.const !== void 0) return _schemaLiteralType(schema.const);
1312
+ if (schema.enum) return schema.enum.map(_schemaLiteralType).join(" | ");
1313
+ if (schema.oneOf) return schema.oneOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1314
+ if (schema.anyOf) return schema.anyOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1315
+ if (schema.allOf) return schema.allOf.map((s, i) => _schemaToTsType(s, `${name}Part${i}`, interfaces)).join(" & ");
1316
+ const types = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];
1317
+ const nullable = types.includes("null");
1318
+ const nonNullTypes = types.filter((t) => t !== "null");
1319
+ const primaryType = nonNullTypes[0] ?? (schema.properties || schema.additionalProperties !== void 0 ? "object" : void 0);
1320
+ let result;
1321
+ switch (primaryType) {
1322
+ case "string":
1323
+ result = "string";
1324
+ break;
1325
+ case "number":
1326
+ case "integer":
1327
+ result = "number";
1328
+ break;
1329
+ case "boolean":
1330
+ result = "boolean";
1331
+ break;
1332
+ case "array": {
1333
+ const itemsSchema = Array.isArray(schema.items) ? schema.items[0] : schema.items;
1334
+ const itemType = itemsSchema ? _schemaToTsType(itemsSchema, `${name}Item`, interfaces) : "unknown";
1335
+ result = `${itemType}[]`;
1336
+ break;
1337
+ }
1338
+ case "object": {
1339
+ _buildSchemaInterface(schema, name, interfaces);
1340
+ result = name;
1341
+ break;
1342
+ }
1343
+ default:
1344
+ result = "unknown";
1345
+ }
1346
+ return nullable ? `${result} | null` : result;
1347
+ }
1348
+ function _buildSchemaInterface(schema, name, interfaces) {
1349
+ if (interfaces.has(name)) return;
1350
+ const required = new Set(schema.required ?? []);
1351
+ const lines = [`interface ${name} {`];
1352
+ for (const [key, propSchema] of Object.entries(schema.properties ?? {})) {
1353
+ if (propSchema.description) lines.push(` /** ${propSchema.description} */`);
1354
+ const optional = required.has(key) ? "" : "?";
1355
+ const propType = _schemaToTsType(propSchema, _capitalize(key), interfaces);
1356
+ lines.push(` ${_safePropertyKey(key)}${optional}: ${propType};`);
1357
+ }
1358
+ if (schema.additionalProperties === true) {
1359
+ lines.push(" [key: string]: unknown;");
1360
+ } else if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
1361
+ const addType = _schemaToTsType(schema.additionalProperties, `${name}Value`, interfaces);
1362
+ lines.push(` [key: string]: ${addType};`);
1363
+ }
1364
+ lines.push("}");
1365
+ interfaces.set(name, lines.join("\n"));
1366
+ }
1367
+ function jsonSchemaToTypescript(schemaJson, options) {
1368
+ let schema;
1369
+ try {
1370
+ schema = JSON.parse(schemaJson);
1371
+ } catch {
1372
+ return { error: "Invalid JSON input" };
1373
+ }
1374
+ if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
1375
+ return { error: "Schema must be a JSON object" };
1376
+ }
1377
+ const rootName = options?.rootName ?? "Root";
1378
+ const typedSchema = schema;
1379
+ const interfaces = /* @__PURE__ */ new Map();
1380
+ const defs = { ...typedSchema.$defs ?? {}, ...typedSchema.definitions ?? {} };
1381
+ for (const [defName, defSchema] of Object.entries(defs)) {
1382
+ const defTypeName = _capitalize(defName);
1383
+ const defType = _schemaToTsType(defSchema, defTypeName, interfaces);
1384
+ if (!interfaces.has(defTypeName)) {
1385
+ interfaces.set(defTypeName, `type ${defTypeName} = ${defType};`);
1386
+ }
1387
+ }
1388
+ const rootType = _schemaToTsType(typedSchema, rootName, interfaces);
1389
+ const parts = [...interfaces.values()];
1390
+ if (!interfaces.has(rootName)) {
1391
+ parts.push(`type ${rootName} = ${rootType};`);
1392
+ }
1393
+ return parts.join("\n\n");
1394
+ }
1296
1395
 
1297
1396
  exports.csvToJson = csvToJson;
1298
1397
  exports.detectFormat = detectFormat;
@@ -1305,6 +1404,7 @@ exports.getJsonStats = getJsonStats;
1305
1404
  exports.inferGoType = inferGoType;
1306
1405
  exports.inferPythonType = inferPythonType;
1307
1406
  exports.inferType = inferType;
1407
+ exports.jsonSchemaToTypescript = jsonSchemaToTypescript;
1308
1408
  exports.jsonToCsv = jsonToCsv;
1309
1409
  exports.jsonToGo = jsonToGo;
1310
1410
  exports.jsonToPython = jsonToPython;
@@ -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, P as ParseStatus, g as PythonClass, h as PythonField, i as PythonMode, V as ValidationError, k as ValidationResult, Z as ZodOptions, l as csvToJson, m as detectFormat, n as diffJson, o as evaluateJsonPath, p as formatDiffLine, q as formatJson, r as generateExample, s as getJsonStats, t as inferGoType, u as inferPythonType, v as inferType, w as jsonToCsv, x as jsonToGo, y as jsonToPython, z as jsonToTypescript, A as jsonToYaml, B as jsonToZod, E as minifyJson, F as parseJson, H as parseStructs, I as resolveJsonPointer, K as toPascalCase, L as toSnakeCase, M as validateJson, N as validateJsonPath, O as validateJsonString, Q as yamlToJson } from '../json-DEVFIpsC.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, 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 +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, P as ParseStatus, g as PythonClass, h as PythonField, i as PythonMode, V as ValidationError, k as ValidationResult, Z as ZodOptions, l as csvToJson, m as detectFormat, n as diffJson, o as evaluateJsonPath, p as formatDiffLine, q as formatJson, r as generateExample, s as getJsonStats, t as inferGoType, u as inferPythonType, v as inferType, w as jsonToCsv, x as jsonToGo, y as jsonToPython, z as jsonToTypescript, A as jsonToYaml, B as jsonToZod, E as minifyJson, F as parseJson, H as parseStructs, I as resolveJsonPointer, K as toPascalCase, L as toSnakeCase, M as validateJson, N as validateJsonPath, O as validateJsonString, Q as yamlToJson } from '../json-DEVFIpsC.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, 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,2 +1,2 @@
1
- export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-WO3LJMVV.js';
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';
2
2
  import '../chunk-MLKGABMK.js';
@@ -1593,6 +1593,61 @@ function calculateRuleOf72(value, direction) {
1593
1593
  errorPercent: round4(errorPercent)
1594
1594
  };
1595
1595
  }
1596
+ function calculateEmi(principal, annualRatePercent, tenure, tenureUnit = "years") {
1597
+ if (!Number.isFinite(principal) || principal <= 0) return { error: "Principal must be a positive number" };
1598
+ if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
1599
+ return { error: "Annual interest rate must be zero or a positive number" };
1600
+ }
1601
+ if (tenureUnit !== "years" && tenureUnit !== "months") {
1602
+ return { error: 'tenureUnit must be "years" or "months"' };
1603
+ }
1604
+ if (!Number.isFinite(tenure) || tenure <= 0) return { error: "Tenure must be a positive number" };
1605
+ const tenureMonths = Math.round(tenureUnit === "years" ? tenure * 12 : tenure);
1606
+ if (tenureMonths <= 0) return { error: "Tenure must resolve to at least 1 month" };
1607
+ const monthlyRate = annualRatePercent / 100 / 12;
1608
+ let emi;
1609
+ if (monthlyRate === 0) {
1610
+ emi = principal / tenureMonths;
1611
+ } else {
1612
+ const factor = Math.pow(1 + monthlyRate, tenureMonths);
1613
+ emi = principal * monthlyRate * factor / (factor - 1);
1614
+ }
1615
+ const yearlyBreakdown = [];
1616
+ let balance = round2(principal);
1617
+ let totalPayment = 0;
1618
+ let yearPrincipal = 0;
1619
+ let yearInterest = 0;
1620
+ let year = 1;
1621
+ for (let month = 1; month <= tenureMonths; month++) {
1622
+ const interest = monthlyRate === 0 ? 0 : round2(balance * monthlyRate);
1623
+ let principalPortion = round2(emi) - interest;
1624
+ if (month === tenureMonths || principalPortion > balance) principalPortion = balance;
1625
+ const payment = round2(principalPortion + interest);
1626
+ balance = Math.max(round2(balance - principalPortion), 0);
1627
+ totalPayment += payment;
1628
+ yearPrincipal += principalPortion;
1629
+ yearInterest += interest;
1630
+ const isYearEnd = month % 12 === 0 || month === tenureMonths;
1631
+ if (isYearEnd) {
1632
+ yearlyBreakdown.push({
1633
+ year,
1634
+ principalPaid: round2(yearPrincipal),
1635
+ interestPaid: round2(yearInterest),
1636
+ balance
1637
+ });
1638
+ year += 1;
1639
+ yearPrincipal = 0;
1640
+ yearInterest = 0;
1641
+ }
1642
+ }
1643
+ return {
1644
+ emi: round2(emi),
1645
+ totalInterest: round2(totalPayment - principal),
1646
+ totalPayment: round2(totalPayment),
1647
+ tenureMonths,
1648
+ yearlyBreakdown
1649
+ };
1650
+ }
1596
1651
 
1597
1652
  exports.BASE_LABELS = BASE_LABELS;
1598
1653
  exports.BASE_PREFIXES = BASE_PREFIXES;
@@ -1613,6 +1668,7 @@ exports.calcSubnet = calcSubnet;
1613
1668
  exports.calculateBreakEven = calculateBreakEven;
1614
1669
  exports.calculateCompoundInterest = calculateCompoundInterest;
1615
1670
  exports.calculateDiscount = calculateDiscount;
1671
+ exports.calculateEmi = calculateEmi;
1616
1672
  exports.calculateLoan = calculateLoan;
1617
1673
  exports.calculateMarginMarkup = calculateMarginMarkup;
1618
1674
  exports.calculatePercentageChange = calculatePercentageChange;