@utilix-tech/sdk 0.20.0 → 0.22.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 +8 -0
- package/README.md +21 -4
- package/dist/{chunk-ZPQZEIXP.js → chunk-IEPWZERQ.js} +95 -2
- package/dist/{chunk-U34B5XPK.js → chunk-TLRSQHMP.js} +58 -1
- package/dist/{chunk-TSAGO3XP.js → chunk-WO3LJMVV.js} +54 -1
- package/dist/index.cjs +204 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{json-BjSoIS1h.d.ts → json-DEVFIpsC.d.cts} +26 -2
- package/dist/{json-BjSoIS1h.d.cts → json-DEVFIpsC.d.ts} +26 -2
- package/dist/{time-DbT8fjaF.d.cts → time-KqJjdqII.d.cts} +48 -2
- package/dist/{time-DbT8fjaF.d.ts → time-KqJjdqII.d.ts} +48 -2
- package/dist/tools/json.cjs +53 -0
- package/dist/tools/json.d.cts +1 -1
- package/dist/tools/json.d.ts +1 -1
- package/dist/tools/json.js +1 -1
- package/dist/tools/time.cjs +93 -0
- package/dist/tools/time.d.cts +1 -1
- package/dist/tools/time.d.ts +1 -1
- package/dist/tools/time.js +1 -1
- package/dist/tools/units.cjs +57 -0
- package/dist/tools/units.d.cts +1 -1
- package/dist/tools/units.d.ts +1 -1
- package/dist/tools/units.js +1 -1
- package/dist/{units-BFTQwpBu.d.ts → units-KrjRyu0w.d.cts} +53 -2
- package/dist/{units-BFTQwpBu.d.cts → units-KrjRyu0w.d.ts} +53 -2
- package/package.json +1 -1
|
@@ -148,6 +148,28 @@ interface ZodOptions {
|
|
|
148
148
|
declare function jsonToZod(json: string, options?: ZodOptions): string | {
|
|
149
149
|
error: string;
|
|
150
150
|
};
|
|
151
|
+
interface JsonPointerResult {
|
|
152
|
+
pointer: string;
|
|
153
|
+
found: boolean;
|
|
154
|
+
value?: unknown;
|
|
155
|
+
/** Decoded reference tokens (after ~1 -> / and ~0 -> ~ unescaping). */
|
|
156
|
+
tokens: string[];
|
|
157
|
+
/** Set when the input JSON is invalid or the pointer syntax is malformed. */
|
|
158
|
+
error?: string;
|
|
159
|
+
/** The reference token at which resolution stopped (found === false). */
|
|
160
|
+
failedAt?: string;
|
|
161
|
+
/** Why resolution stopped at `failedAt`. */
|
|
162
|
+
reason?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Resolve an RFC 6901 JSON Pointer against a JSON document. Accepts both the
|
|
166
|
+
* plain form ("" for the whole document, or "/foo/0") and the URI-fragment
|
|
167
|
+
* form ("#/foo/0", percent-decoded). Distinguishes an invalid document /
|
|
168
|
+
* malformed pointer (`error`) from a syntactically valid pointer whose target
|
|
169
|
+
* is simply absent (`found: false` with `failedAt` + `reason`). Pure
|
|
170
|
+
* traversal, no external calls.
|
|
171
|
+
*/
|
|
172
|
+
declare function resolveJsonPointer(json: string, pointer: string): JsonPointerResult;
|
|
151
173
|
|
|
152
174
|
type json_ConvertOptions = ConvertOptions;
|
|
153
175
|
type json_CsvOptions = CsvOptions;
|
|
@@ -158,6 +180,7 @@ type json_GoStruct = GoStruct;
|
|
|
158
180
|
type json_JsonDiffResult = JsonDiffResult;
|
|
159
181
|
type json_JsonParseResult = JsonParseResult;
|
|
160
182
|
type json_JsonPathResult = JsonPathResult;
|
|
183
|
+
type json_JsonPointerResult = JsonPointerResult;
|
|
161
184
|
type json_ParseStatus = ParseStatus;
|
|
162
185
|
type json_PythonClass = PythonClass;
|
|
163
186
|
type json_PythonField = PythonField;
|
|
@@ -185,6 +208,7 @@ declare const json_jsonToZod: typeof jsonToZod;
|
|
|
185
208
|
declare const json_minifyJson: typeof minifyJson;
|
|
186
209
|
declare const json_parseJson: typeof parseJson;
|
|
187
210
|
declare const json_parseStructs: typeof parseStructs;
|
|
211
|
+
declare const json_resolveJsonPointer: typeof resolveJsonPointer;
|
|
188
212
|
declare const json_toPascalCase: typeof toPascalCase;
|
|
189
213
|
declare const json_toSnakeCase: typeof toSnakeCase;
|
|
190
214
|
declare const json_validateJson: typeof validateJson;
|
|
@@ -192,7 +216,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
|
|
|
192
216
|
declare const json_validateJsonString: typeof validateJsonString;
|
|
193
217
|
declare const json_yamlToJson: typeof yamlToJson;
|
|
194
218
|
declare namespace json {
|
|
195
|
-
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_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_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
|
|
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 };
|
|
196
220
|
}
|
|
197
221
|
|
|
198
|
-
export {
|
|
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 };
|
|
@@ -148,6 +148,28 @@ interface ZodOptions {
|
|
|
148
148
|
declare function jsonToZod(json: string, options?: ZodOptions): string | {
|
|
149
149
|
error: string;
|
|
150
150
|
};
|
|
151
|
+
interface JsonPointerResult {
|
|
152
|
+
pointer: string;
|
|
153
|
+
found: boolean;
|
|
154
|
+
value?: unknown;
|
|
155
|
+
/** Decoded reference tokens (after ~1 -> / and ~0 -> ~ unescaping). */
|
|
156
|
+
tokens: string[];
|
|
157
|
+
/** Set when the input JSON is invalid or the pointer syntax is malformed. */
|
|
158
|
+
error?: string;
|
|
159
|
+
/** The reference token at which resolution stopped (found === false). */
|
|
160
|
+
failedAt?: string;
|
|
161
|
+
/** Why resolution stopped at `failedAt`. */
|
|
162
|
+
reason?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Resolve an RFC 6901 JSON Pointer against a JSON document. Accepts both the
|
|
166
|
+
* plain form ("" for the whole document, or "/foo/0") and the URI-fragment
|
|
167
|
+
* form ("#/foo/0", percent-decoded). Distinguishes an invalid document /
|
|
168
|
+
* malformed pointer (`error`) from a syntactically valid pointer whose target
|
|
169
|
+
* is simply absent (`found: false` with `failedAt` + `reason`). Pure
|
|
170
|
+
* traversal, no external calls.
|
|
171
|
+
*/
|
|
172
|
+
declare function resolveJsonPointer(json: string, pointer: string): JsonPointerResult;
|
|
151
173
|
|
|
152
174
|
type json_ConvertOptions = ConvertOptions;
|
|
153
175
|
type json_CsvOptions = CsvOptions;
|
|
@@ -158,6 +180,7 @@ type json_GoStruct = GoStruct;
|
|
|
158
180
|
type json_JsonDiffResult = JsonDiffResult;
|
|
159
181
|
type json_JsonParseResult = JsonParseResult;
|
|
160
182
|
type json_JsonPathResult = JsonPathResult;
|
|
183
|
+
type json_JsonPointerResult = JsonPointerResult;
|
|
161
184
|
type json_ParseStatus = ParseStatus;
|
|
162
185
|
type json_PythonClass = PythonClass;
|
|
163
186
|
type json_PythonField = PythonField;
|
|
@@ -185,6 +208,7 @@ declare const json_jsonToZod: typeof jsonToZod;
|
|
|
185
208
|
declare const json_minifyJson: typeof minifyJson;
|
|
186
209
|
declare const json_parseJson: typeof parseJson;
|
|
187
210
|
declare const json_parseStructs: typeof parseStructs;
|
|
211
|
+
declare const json_resolveJsonPointer: typeof resolveJsonPointer;
|
|
188
212
|
declare const json_toPascalCase: typeof toPascalCase;
|
|
189
213
|
declare const json_toSnakeCase: typeof toSnakeCase;
|
|
190
214
|
declare const json_validateJson: typeof validateJson;
|
|
@@ -192,7 +216,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
|
|
|
192
216
|
declare const json_validateJsonString: typeof validateJsonString;
|
|
193
217
|
declare const json_yamlToJson: typeof yamlToJson;
|
|
194
218
|
declare namespace json {
|
|
195
|
-
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_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_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
|
|
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 };
|
|
196
220
|
}
|
|
197
221
|
|
|
198
|
-
export {
|
|
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 };
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - date-diff : parseDate, humanizeDiff, diffDates, COMMON_DATE_PRESETS
|
|
7
7
|
* - timezone : TIMEZONES, getTimezoneOffset, convertTime, formatInTimezone, getAllZonesForTime
|
|
8
8
|
* - cron-next : parseCronExpression, getNextRuns, formatRunDate, getRunInterval
|
|
9
|
+
* - iso8601-duration : parseIso8601Duration, formatIso8601Duration
|
|
9
10
|
*/
|
|
10
11
|
interface TimestampResult {
|
|
11
12
|
unix: number;
|
|
@@ -111,6 +112,47 @@ declare function getNextRuns(expr: string, count?: number, fromDate?: Date): Dat
|
|
|
111
112
|
};
|
|
112
113
|
declare function formatRunDate(date: Date, timezone?: string): string;
|
|
113
114
|
declare function getRunInterval(dates: Date[]): string;
|
|
115
|
+
interface DurationParseResult {
|
|
116
|
+
input: string;
|
|
117
|
+
years: number;
|
|
118
|
+
months: number;
|
|
119
|
+
weeks: number;
|
|
120
|
+
days: number;
|
|
121
|
+
hours: number;
|
|
122
|
+
minutes: number;
|
|
123
|
+
seconds: number;
|
|
124
|
+
totalSeconds: number;
|
|
125
|
+
approximate: boolean;
|
|
126
|
+
human: string;
|
|
127
|
+
}
|
|
128
|
+
interface DurationFormatResult {
|
|
129
|
+
seconds: number;
|
|
130
|
+
iso: string;
|
|
131
|
+
days: number;
|
|
132
|
+
hours: number;
|
|
133
|
+
minutes: number;
|
|
134
|
+
human: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Parse an ISO 8601 duration string (e.g. "P3DT4H30M", "PT1H", "P1Y6M") into
|
|
138
|
+
* its individual components plus a total number of seconds. Years and months
|
|
139
|
+
* have no fixed length, so when either is present `totalSeconds` uses nominal
|
|
140
|
+
* conversions (1 year = 365 days, 1 month = 30 days) and `approximate` is set
|
|
141
|
+
* to true. Weeks, days, hours, minutes, and seconds are exact. Fractional
|
|
142
|
+
* seconds are supported.
|
|
143
|
+
*/
|
|
144
|
+
declare function parseIso8601Duration(input: string): DurationParseResult | {
|
|
145
|
+
error: string;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Format a non-negative number of seconds into a canonical ISO 8601 duration
|
|
149
|
+
* string. The output uses only days, hours, minutes, and seconds (never years
|
|
150
|
+
* or months, which have no fixed length), e.g. 90061 -> "P1DT1H1M1S". Zero is
|
|
151
|
+
* rendered as "PT0S". Fractional seconds are preserved.
|
|
152
|
+
*/
|
|
153
|
+
declare function formatIso8601Duration(seconds: number): DurationFormatResult | {
|
|
154
|
+
error: string;
|
|
155
|
+
};
|
|
114
156
|
|
|
115
157
|
declare const time_COMMON_CRONS: typeof COMMON_CRONS;
|
|
116
158
|
declare const time_COMMON_DATE_PRESETS: typeof COMMON_DATE_PRESETS;
|
|
@@ -118,6 +160,8 @@ type time_CronField = CronField;
|
|
|
118
160
|
type time_CronNextField = CronNextField;
|
|
119
161
|
type time_CronResult = CronResult;
|
|
120
162
|
type time_DateDiffResult = DateDiffResult;
|
|
163
|
+
type time_DurationFormatResult = DurationFormatResult;
|
|
164
|
+
type time_DurationParseResult = DurationParseResult;
|
|
121
165
|
type time_ParsedCron = ParsedCron;
|
|
122
166
|
declare const time_TIMEZONES: typeof TIMEZONES;
|
|
123
167
|
type time_TimestampResult = TimestampResult;
|
|
@@ -125,6 +169,7 @@ type time_TimezoneEntry = TimezoneEntry;
|
|
|
125
169
|
declare const time_convertTime: typeof convertTime;
|
|
126
170
|
declare const time_diffDates: typeof diffDates;
|
|
127
171
|
declare const time_formatInTimezone: typeof formatInTimezone;
|
|
172
|
+
declare const time_formatIso8601Duration: typeof formatIso8601Duration;
|
|
128
173
|
declare const time_formatRelative: typeof formatRelative;
|
|
129
174
|
declare const time_formatRunDate: typeof formatRunDate;
|
|
130
175
|
declare const time_fromIsoString: typeof fromIsoString;
|
|
@@ -138,8 +183,9 @@ declare const time_humanizeDiff: typeof humanizeDiff;
|
|
|
138
183
|
declare const time_parseCron: typeof parseCron;
|
|
139
184
|
declare const time_parseCronExpression: typeof parseCronExpression;
|
|
140
185
|
declare const time_parseDate: typeof parseDate;
|
|
186
|
+
declare const time_parseIso8601Duration: typeof parseIso8601Duration;
|
|
141
187
|
declare namespace time {
|
|
142
|
-
export { time_COMMON_CRONS as COMMON_CRONS, time_COMMON_DATE_PRESETS as COMMON_DATE_PRESETS, type time_CronField as CronField, type time_CronNextField as CronNextField, type time_CronResult as CronResult, type time_DateDiffResult as DateDiffResult, type time_ParsedCron as ParsedCron, time_TIMEZONES as TIMEZONES, type time_TimestampResult as TimestampResult, type time_TimezoneEntry as TimezoneEntry, time_convertTime as convertTime, time_diffDates as diffDates, time_formatInTimezone as formatInTimezone, time_formatRelative as formatRelative, time_formatRunDate as formatRunDate, time_fromIsoString as fromIsoString, time_fromUnix as fromUnix, time_getAllZonesForTime as getAllZonesForTime, time_getNextRuns as getNextRuns, time_getNow as getNow, time_getRunInterval as getRunInterval, time_getTimezoneOffset as getTimezoneOffset, time_humanizeDiff as humanizeDiff, time_parseCron as parseCron, time_parseCronExpression as parseCronExpression, time_parseDate as parseDate };
|
|
188
|
+
export { time_COMMON_CRONS as COMMON_CRONS, time_COMMON_DATE_PRESETS as COMMON_DATE_PRESETS, type time_CronField as CronField, type time_CronNextField as CronNextField, type time_CronResult as CronResult, type time_DateDiffResult as DateDiffResult, type time_DurationFormatResult as DurationFormatResult, type time_DurationParseResult as DurationParseResult, type time_ParsedCron as ParsedCron, time_TIMEZONES as TIMEZONES, type time_TimestampResult as TimestampResult, type time_TimezoneEntry as TimezoneEntry, time_convertTime as convertTime, time_diffDates as diffDates, time_formatInTimezone as formatInTimezone, time_formatIso8601Duration as formatIso8601Duration, time_formatRelative as formatRelative, time_formatRunDate as formatRunDate, time_fromIsoString as fromIsoString, time_fromUnix as fromUnix, time_getAllZonesForTime as getAllZonesForTime, time_getNextRuns as getNextRuns, time_getNow as getNow, time_getRunInterval as getRunInterval, time_getTimezoneOffset as getTimezoneOffset, time_humanizeDiff as humanizeDiff, time_parseCron as parseCron, time_parseCronExpression as parseCronExpression, time_parseDate as parseDate, time_parseIso8601Duration as parseIso8601Duration };
|
|
143
189
|
}
|
|
144
190
|
|
|
145
|
-
export { COMMON_CRONS as C, type DateDiffResult as D, type ParsedCron as P, TIMEZONES as T, COMMON_DATE_PRESETS as a, type CronField as b, type CronNextField as c, type CronResult as d, type
|
|
191
|
+
export { parseIso8601Duration as A, COMMON_CRONS as C, type DateDiffResult as D, type ParsedCron as P, TIMEZONES as T, COMMON_DATE_PRESETS as a, type CronField as b, type CronNextField as c, type CronResult as d, type DurationFormatResult as e, type DurationParseResult as f, type TimestampResult as g, type TimezoneEntry as h, convertTime as i, diffDates as j, formatInTimezone as k, formatIso8601Duration as l, formatRelative as m, formatRunDate as n, fromIsoString as o, fromUnix as p, getAllZonesForTime as q, getNextRuns as r, getNow as s, time as t, getRunInterval as u, getTimezoneOffset as v, humanizeDiff as w, parseCron as x, parseCronExpression as y, parseDate as z };
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - date-diff : parseDate, humanizeDiff, diffDates, COMMON_DATE_PRESETS
|
|
7
7
|
* - timezone : TIMEZONES, getTimezoneOffset, convertTime, formatInTimezone, getAllZonesForTime
|
|
8
8
|
* - cron-next : parseCronExpression, getNextRuns, formatRunDate, getRunInterval
|
|
9
|
+
* - iso8601-duration : parseIso8601Duration, formatIso8601Duration
|
|
9
10
|
*/
|
|
10
11
|
interface TimestampResult {
|
|
11
12
|
unix: number;
|
|
@@ -111,6 +112,47 @@ declare function getNextRuns(expr: string, count?: number, fromDate?: Date): Dat
|
|
|
111
112
|
};
|
|
112
113
|
declare function formatRunDate(date: Date, timezone?: string): string;
|
|
113
114
|
declare function getRunInterval(dates: Date[]): string;
|
|
115
|
+
interface DurationParseResult {
|
|
116
|
+
input: string;
|
|
117
|
+
years: number;
|
|
118
|
+
months: number;
|
|
119
|
+
weeks: number;
|
|
120
|
+
days: number;
|
|
121
|
+
hours: number;
|
|
122
|
+
minutes: number;
|
|
123
|
+
seconds: number;
|
|
124
|
+
totalSeconds: number;
|
|
125
|
+
approximate: boolean;
|
|
126
|
+
human: string;
|
|
127
|
+
}
|
|
128
|
+
interface DurationFormatResult {
|
|
129
|
+
seconds: number;
|
|
130
|
+
iso: string;
|
|
131
|
+
days: number;
|
|
132
|
+
hours: number;
|
|
133
|
+
minutes: number;
|
|
134
|
+
human: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Parse an ISO 8601 duration string (e.g. "P3DT4H30M", "PT1H", "P1Y6M") into
|
|
138
|
+
* its individual components plus a total number of seconds. Years and months
|
|
139
|
+
* have no fixed length, so when either is present `totalSeconds` uses nominal
|
|
140
|
+
* conversions (1 year = 365 days, 1 month = 30 days) and `approximate` is set
|
|
141
|
+
* to true. Weeks, days, hours, minutes, and seconds are exact. Fractional
|
|
142
|
+
* seconds are supported.
|
|
143
|
+
*/
|
|
144
|
+
declare function parseIso8601Duration(input: string): DurationParseResult | {
|
|
145
|
+
error: string;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Format a non-negative number of seconds into a canonical ISO 8601 duration
|
|
149
|
+
* string. The output uses only days, hours, minutes, and seconds (never years
|
|
150
|
+
* or months, which have no fixed length), e.g. 90061 -> "P1DT1H1M1S". Zero is
|
|
151
|
+
* rendered as "PT0S". Fractional seconds are preserved.
|
|
152
|
+
*/
|
|
153
|
+
declare function formatIso8601Duration(seconds: number): DurationFormatResult | {
|
|
154
|
+
error: string;
|
|
155
|
+
};
|
|
114
156
|
|
|
115
157
|
declare const time_COMMON_CRONS: typeof COMMON_CRONS;
|
|
116
158
|
declare const time_COMMON_DATE_PRESETS: typeof COMMON_DATE_PRESETS;
|
|
@@ -118,6 +160,8 @@ type time_CronField = CronField;
|
|
|
118
160
|
type time_CronNextField = CronNextField;
|
|
119
161
|
type time_CronResult = CronResult;
|
|
120
162
|
type time_DateDiffResult = DateDiffResult;
|
|
163
|
+
type time_DurationFormatResult = DurationFormatResult;
|
|
164
|
+
type time_DurationParseResult = DurationParseResult;
|
|
121
165
|
type time_ParsedCron = ParsedCron;
|
|
122
166
|
declare const time_TIMEZONES: typeof TIMEZONES;
|
|
123
167
|
type time_TimestampResult = TimestampResult;
|
|
@@ -125,6 +169,7 @@ type time_TimezoneEntry = TimezoneEntry;
|
|
|
125
169
|
declare const time_convertTime: typeof convertTime;
|
|
126
170
|
declare const time_diffDates: typeof diffDates;
|
|
127
171
|
declare const time_formatInTimezone: typeof formatInTimezone;
|
|
172
|
+
declare const time_formatIso8601Duration: typeof formatIso8601Duration;
|
|
128
173
|
declare const time_formatRelative: typeof formatRelative;
|
|
129
174
|
declare const time_formatRunDate: typeof formatRunDate;
|
|
130
175
|
declare const time_fromIsoString: typeof fromIsoString;
|
|
@@ -138,8 +183,9 @@ declare const time_humanizeDiff: typeof humanizeDiff;
|
|
|
138
183
|
declare const time_parseCron: typeof parseCron;
|
|
139
184
|
declare const time_parseCronExpression: typeof parseCronExpression;
|
|
140
185
|
declare const time_parseDate: typeof parseDate;
|
|
186
|
+
declare const time_parseIso8601Duration: typeof parseIso8601Duration;
|
|
141
187
|
declare namespace time {
|
|
142
|
-
export { time_COMMON_CRONS as COMMON_CRONS, time_COMMON_DATE_PRESETS as COMMON_DATE_PRESETS, type time_CronField as CronField, type time_CronNextField as CronNextField, type time_CronResult as CronResult, type time_DateDiffResult as DateDiffResult, type time_ParsedCron as ParsedCron, time_TIMEZONES as TIMEZONES, type time_TimestampResult as TimestampResult, type time_TimezoneEntry as TimezoneEntry, time_convertTime as convertTime, time_diffDates as diffDates, time_formatInTimezone as formatInTimezone, time_formatRelative as formatRelative, time_formatRunDate as formatRunDate, time_fromIsoString as fromIsoString, time_fromUnix as fromUnix, time_getAllZonesForTime as getAllZonesForTime, time_getNextRuns as getNextRuns, time_getNow as getNow, time_getRunInterval as getRunInterval, time_getTimezoneOffset as getTimezoneOffset, time_humanizeDiff as humanizeDiff, time_parseCron as parseCron, time_parseCronExpression as parseCronExpression, time_parseDate as parseDate };
|
|
188
|
+
export { time_COMMON_CRONS as COMMON_CRONS, time_COMMON_DATE_PRESETS as COMMON_DATE_PRESETS, type time_CronField as CronField, type time_CronNextField as CronNextField, type time_CronResult as CronResult, type time_DateDiffResult as DateDiffResult, type time_DurationFormatResult as DurationFormatResult, type time_DurationParseResult as DurationParseResult, type time_ParsedCron as ParsedCron, time_TIMEZONES as TIMEZONES, type time_TimestampResult as TimestampResult, type time_TimezoneEntry as TimezoneEntry, time_convertTime as convertTime, time_diffDates as diffDates, time_formatInTimezone as formatInTimezone, time_formatIso8601Duration as formatIso8601Duration, time_formatRelative as formatRelative, time_formatRunDate as formatRunDate, time_fromIsoString as fromIsoString, time_fromUnix as fromUnix, time_getAllZonesForTime as getAllZonesForTime, time_getNextRuns as getNextRuns, time_getNow as getNow, time_getRunInterval as getRunInterval, time_getTimezoneOffset as getTimezoneOffset, time_humanizeDiff as humanizeDiff, time_parseCron as parseCron, time_parseCronExpression as parseCronExpression, time_parseDate as parseDate, time_parseIso8601Duration as parseIso8601Duration };
|
|
143
189
|
}
|
|
144
190
|
|
|
145
|
-
export { COMMON_CRONS as C, type DateDiffResult as D, type ParsedCron as P, TIMEZONES as T, COMMON_DATE_PRESETS as a, type CronField as b, type CronNextField as c, type CronResult as d, type
|
|
191
|
+
export { parseIso8601Duration as A, COMMON_CRONS as C, type DateDiffResult as D, type ParsedCron as P, TIMEZONES as T, COMMON_DATE_PRESETS as a, type CronField as b, type CronNextField as c, type CronResult as d, type DurationFormatResult as e, type DurationParseResult as f, type TimestampResult as g, type TimezoneEntry as h, convertTime as i, diffDates as j, formatInTimezone as k, formatIso8601Duration as l, formatRelative as m, formatRunDate as n, fromIsoString as o, fromUnix as p, getAllZonesForTime as q, getNextRuns as r, getNow as s, time as t, getRunInterval as u, getTimezoneOffset as v, humanizeDiff as w, parseCron as x, parseCronExpression as y, parseDate as z };
|
package/dist/tools/json.cjs
CHANGED
|
@@ -1241,6 +1241,58 @@ function jsonToZod(json, options) {
|
|
|
1241
1241
|
|
|
1242
1242
|
export const ${rootName}Schema = ${schema}`;
|
|
1243
1243
|
}
|
|
1244
|
+
function _unescapePointerToken(token) {
|
|
1245
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1246
|
+
}
|
|
1247
|
+
function resolveJsonPointer(json, pointer) {
|
|
1248
|
+
let parsed;
|
|
1249
|
+
try {
|
|
1250
|
+
parsed = JSON.parse(json);
|
|
1251
|
+
} catch {
|
|
1252
|
+
return { pointer, found: false, tokens: [], error: "Invalid JSON input" };
|
|
1253
|
+
}
|
|
1254
|
+
let ptr = pointer;
|
|
1255
|
+
if (ptr.startsWith("#")) {
|
|
1256
|
+
ptr = ptr.slice(1);
|
|
1257
|
+
try {
|
|
1258
|
+
ptr = decodeURIComponent(ptr);
|
|
1259
|
+
} catch {
|
|
1260
|
+
return { pointer, found: false, tokens: [], error: "Invalid percent-encoding in URI-fragment pointer" };
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
if (ptr === "") {
|
|
1264
|
+
return { pointer, found: true, value: parsed, tokens: [] };
|
|
1265
|
+
}
|
|
1266
|
+
if (!ptr.startsWith("/")) {
|
|
1267
|
+
return { pointer, found: false, tokens: [], error: "Pointer must be empty or start with '/' (RFC 6901)" };
|
|
1268
|
+
}
|
|
1269
|
+
const tokens = ptr.split("/").slice(1).map(_unescapePointerToken);
|
|
1270
|
+
let current = parsed;
|
|
1271
|
+
for (const token of tokens) {
|
|
1272
|
+
if (Array.isArray(current)) {
|
|
1273
|
+
if (token === "-") {
|
|
1274
|
+
return { pointer, found: false, tokens, failedAt: token, reason: '"-" refers to the nonexistent element after the end of the array' };
|
|
1275
|
+
}
|
|
1276
|
+
if (!/^(0|[1-9][0-9]*)$/.test(token)) {
|
|
1277
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `"${token}" is not a valid array index` };
|
|
1278
|
+
}
|
|
1279
|
+
const idx = Number(token);
|
|
1280
|
+
if (idx >= current.length) {
|
|
1281
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `array index ${idx} is out of bounds (length ${current.length})` };
|
|
1282
|
+
}
|
|
1283
|
+
current = current[idx];
|
|
1284
|
+
} else if (current !== null && typeof current === "object") {
|
|
1285
|
+
const obj = current;
|
|
1286
|
+
if (!Object.prototype.hasOwnProperty.call(obj, token)) {
|
|
1287
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `key "${token}" not found` };
|
|
1288
|
+
}
|
|
1289
|
+
current = obj[token];
|
|
1290
|
+
} else {
|
|
1291
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `cannot descend into ${current === null ? "null" : typeof current} at "${token}"` };
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
return { pointer, found: true, value: current, tokens };
|
|
1295
|
+
}
|
|
1244
1296
|
|
|
1245
1297
|
exports.csvToJson = csvToJson;
|
|
1246
1298
|
exports.detectFormat = detectFormat;
|
|
@@ -1262,6 +1314,7 @@ exports.jsonToZod = jsonToZod;
|
|
|
1262
1314
|
exports.minifyJson = minifyJson;
|
|
1263
1315
|
exports.parseJson = parseJson;
|
|
1264
1316
|
exports.parseStructs = parseStructs;
|
|
1317
|
+
exports.resolveJsonPointer = resolveJsonPointer;
|
|
1265
1318
|
exports.toPascalCase = toPascalCase;
|
|
1266
1319
|
exports.toSnakeCase = toSnakeCase;
|
|
1267
1320
|
exports.validateJson = validateJson;
|
package/dist/tools/json.d.cts
CHANGED
|
@@ -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, P as ParseStatus,
|
|
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';
|
package/dist/tools/json.d.ts
CHANGED
|
@@ -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, P as ParseStatus,
|
|
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';
|
package/dist/tools/json.js
CHANGED
|
@@ -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, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-
|
|
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';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/time.cjs
CHANGED
|
@@ -659,6 +659,97 @@ function getRunInterval(dates) {
|
|
|
659
659
|
const days = Math.round(diffMins / 1440);
|
|
660
660
|
return `Every ${days} days`;
|
|
661
661
|
}
|
|
662
|
+
var DURATION_SECONDS_PER_YEAR = 365 * 86400;
|
|
663
|
+
var DURATION_SECONDS_PER_MONTH = 30 * 86400;
|
|
664
|
+
function humanizeDurationParts(parts) {
|
|
665
|
+
const pieces = [];
|
|
666
|
+
for (const [value, label] of parts) {
|
|
667
|
+
if (value === 0) continue;
|
|
668
|
+
pieces.push(`${value} ${label}${value === 1 ? "" : "s"}`);
|
|
669
|
+
}
|
|
670
|
+
return pieces.length > 0 ? pieces.join(", ") : "0 seconds";
|
|
671
|
+
}
|
|
672
|
+
function parseIso8601Duration(input) {
|
|
673
|
+
if (typeof input !== "string") return { error: "Duration must be a string" };
|
|
674
|
+
const trimmed = input.trim();
|
|
675
|
+
if (trimmed.length === 0) return { error: "Duration is empty" };
|
|
676
|
+
const match = trimmed.match(
|
|
677
|
+
/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/
|
|
678
|
+
);
|
|
679
|
+
if (!match) {
|
|
680
|
+
return { error: 'Not a valid ISO 8601 duration (expected a form like "P3DT4H30M")' };
|
|
681
|
+
}
|
|
682
|
+
const years = match[1] ? parseInt(match[1], 10) : 0;
|
|
683
|
+
const months = match[2] ? parseInt(match[2], 10) : 0;
|
|
684
|
+
const weeks = match[3] ? parseInt(match[3], 10) : 0;
|
|
685
|
+
const days = match[4] ? parseInt(match[4], 10) : 0;
|
|
686
|
+
const hours = match[5] ? parseInt(match[5], 10) : 0;
|
|
687
|
+
const minutes = match[6] ? parseInt(match[6], 10) : 0;
|
|
688
|
+
const seconds = match[7] ? parseFloat(match[7]) : 0;
|
|
689
|
+
if (years + months + weeks + days + hours + minutes + seconds === 0) {
|
|
690
|
+
return { error: 'Duration has no components (a bare "P" or "PT" is not valid)' };
|
|
691
|
+
}
|
|
692
|
+
const approximate = years > 0 || months > 0;
|
|
693
|
+
const totalSeconds = years * DURATION_SECONDS_PER_YEAR + months * DURATION_SECONDS_PER_MONTH + weeks * 7 * 86400 + days * 86400 + hours * 3600 + minutes * 60 + seconds;
|
|
694
|
+
const human = humanizeDurationParts([
|
|
695
|
+
[years, "year"],
|
|
696
|
+
[months, "month"],
|
|
697
|
+
[weeks, "week"],
|
|
698
|
+
[days, "day"],
|
|
699
|
+
[hours, "hour"],
|
|
700
|
+
[minutes, "minute"],
|
|
701
|
+
[seconds, "second"]
|
|
702
|
+
]);
|
|
703
|
+
return {
|
|
704
|
+
input: trimmed,
|
|
705
|
+
years,
|
|
706
|
+
months,
|
|
707
|
+
weeks,
|
|
708
|
+
days,
|
|
709
|
+
hours,
|
|
710
|
+
minutes,
|
|
711
|
+
seconds,
|
|
712
|
+
totalSeconds: Math.round(totalSeconds * 1e6) / 1e6,
|
|
713
|
+
approximate,
|
|
714
|
+
human
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
function formatIso8601Duration(seconds) {
|
|
718
|
+
if (typeof seconds !== "number" || !Number.isFinite(seconds) || seconds < 0) {
|
|
719
|
+
return { error: "Seconds must be zero or a positive number" };
|
|
720
|
+
}
|
|
721
|
+
const totalDays = Math.floor(seconds / 86400);
|
|
722
|
+
let rem = seconds - totalDays * 86400;
|
|
723
|
+
const hours = Math.floor(rem / 3600);
|
|
724
|
+
rem -= hours * 3600;
|
|
725
|
+
const minutes = Math.floor(rem / 60);
|
|
726
|
+
let secs = rem - minutes * 60;
|
|
727
|
+
secs = Math.round(secs * 1e6) / 1e6;
|
|
728
|
+
let iso = "P";
|
|
729
|
+
if (totalDays > 0) iso += `${totalDays}D`;
|
|
730
|
+
const hasTime = hours > 0 || minutes > 0 || secs > 0;
|
|
731
|
+
if (hasTime) {
|
|
732
|
+
iso += "T";
|
|
733
|
+
if (hours > 0) iso += `${hours}H`;
|
|
734
|
+
if (minutes > 0) iso += `${minutes}M`;
|
|
735
|
+
if (secs > 0) iso += `${secs}S`;
|
|
736
|
+
}
|
|
737
|
+
if (iso === "P") iso = "PT0S";
|
|
738
|
+
const human = humanizeDurationParts([
|
|
739
|
+
[totalDays, "day"],
|
|
740
|
+
[hours, "hour"],
|
|
741
|
+
[minutes, "minute"],
|
|
742
|
+
[secs, "second"]
|
|
743
|
+
]);
|
|
744
|
+
return {
|
|
745
|
+
seconds,
|
|
746
|
+
iso,
|
|
747
|
+
days: totalDays,
|
|
748
|
+
hours,
|
|
749
|
+
minutes,
|
|
750
|
+
human
|
|
751
|
+
};
|
|
752
|
+
}
|
|
662
753
|
|
|
663
754
|
exports.COMMON_CRONS = COMMON_CRONS;
|
|
664
755
|
exports.COMMON_DATE_PRESETS = COMMON_DATE_PRESETS;
|
|
@@ -666,6 +757,7 @@ exports.TIMEZONES = TIMEZONES;
|
|
|
666
757
|
exports.convertTime = convertTime;
|
|
667
758
|
exports.diffDates = diffDates;
|
|
668
759
|
exports.formatInTimezone = formatInTimezone;
|
|
760
|
+
exports.formatIso8601Duration = formatIso8601Duration;
|
|
669
761
|
exports.formatRelative = formatRelative;
|
|
670
762
|
exports.formatRunDate = formatRunDate;
|
|
671
763
|
exports.fromIsoString = fromIsoString;
|
|
@@ -679,3 +771,4 @@ exports.humanizeDiff = humanizeDiff;
|
|
|
679
771
|
exports.parseCron = parseCron;
|
|
680
772
|
exports.parseCronExpression = parseCronExpression;
|
|
681
773
|
exports.parseDate = parseDate;
|
|
774
|
+
exports.parseIso8601Duration = parseIso8601Duration;
|
package/dist/tools/time.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as COMMON_CRONS, a as COMMON_DATE_PRESETS, b as CronField, c as CronNextField, d as CronResult, D as DateDiffResult, P as ParsedCron, T as TIMEZONES,
|
|
1
|
+
export { C as COMMON_CRONS, a as COMMON_DATE_PRESETS, b as CronField, c as CronNextField, d as CronResult, D as DateDiffResult, e as DurationFormatResult, f as DurationParseResult, P as ParsedCron, T as TIMEZONES, g as TimestampResult, h as TimezoneEntry, i as convertTime, j as diffDates, k as formatInTimezone, l as formatIso8601Duration, m as formatRelative, n as formatRunDate, o as fromIsoString, p as fromUnix, q as getAllZonesForTime, r as getNextRuns, s as getNow, u as getRunInterval, v as getTimezoneOffset, w as humanizeDiff, x as parseCron, y as parseCronExpression, z as parseDate, A as parseIso8601Duration } from '../time-KqJjdqII.cjs';
|
package/dist/tools/time.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as COMMON_CRONS, a as COMMON_DATE_PRESETS, b as CronField, c as CronNextField, d as CronResult, D as DateDiffResult, P as ParsedCron, T as TIMEZONES,
|
|
1
|
+
export { C as COMMON_CRONS, a as COMMON_DATE_PRESETS, b as CronField, c as CronNextField, d as CronResult, D as DateDiffResult, e as DurationFormatResult, f as DurationParseResult, P as ParsedCron, T as TIMEZONES, g as TimestampResult, h as TimezoneEntry, i as convertTime, j as diffDates, k as formatInTimezone, l as formatIso8601Duration, m as formatRelative, n as formatRunDate, o as fromIsoString, p as fromUnix, q as getAllZonesForTime, r as getNextRuns, s as getNow, u as getRunInterval, v as getTimezoneOffset, w as humanizeDiff, x as parseCron, y as parseCronExpression, z as parseDate, A as parseIso8601Duration } from '../time-KqJjdqII.js';
|
package/dist/tools/time.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { COMMON_CRONS, COMMON_DATE_PRESETS, TIMEZONES, convertTime, diffDates, formatInTimezone, formatRelative, formatRunDate, fromIsoString, fromUnix, getAllZonesForTime, getNextRuns, getNow, getRunInterval, getTimezoneOffset, humanizeDiff, parseCron, parseCronExpression, parseDate } from '../chunk-
|
|
1
|
+
export { COMMON_CRONS, COMMON_DATE_PRESETS, TIMEZONES, convertTime, diffDates, formatInTimezone, formatIso8601Duration, formatRelative, formatRunDate, fromIsoString, fromUnix, getAllZonesForTime, getNextRuns, getNow, getRunInterval, getTimezoneOffset, humanizeDiff, parseCron, parseCronExpression, parseDate, parseIso8601Duration } from '../chunk-IEPWZERQ.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/units.cjs
CHANGED
|
@@ -1264,6 +1264,61 @@ function calculateTimeValue(amount, annualRatePercent, years, direction, compoun
|
|
|
1264
1264
|
interest: round22(futureValue - presentValue)
|
|
1265
1265
|
};
|
|
1266
1266
|
}
|
|
1267
|
+
function calculatePercentageChange(oldValue, newValue) {
|
|
1268
|
+
if (!Number.isFinite(oldValue)) return { error: "Original value must be a finite number" };
|
|
1269
|
+
if (!Number.isFinite(newValue)) return { error: "New value must be a finite number" };
|
|
1270
|
+
if (oldValue === 0 && newValue !== 0) {
|
|
1271
|
+
return { error: "Percentage change from zero is undefined (division by zero); use a nonzero original value" };
|
|
1272
|
+
}
|
|
1273
|
+
const round4 = (n) => Math.round(n * 1e4) / 1e4;
|
|
1274
|
+
const absoluteChange = newValue - oldValue;
|
|
1275
|
+
const percentChange = oldValue === 0 ? 0 : absoluteChange / Math.abs(oldValue) * 100;
|
|
1276
|
+
const multiplier = oldValue === 0 ? 1 : newValue / oldValue;
|
|
1277
|
+
let direction;
|
|
1278
|
+
if (absoluteChange > 0) direction = "increase";
|
|
1279
|
+
else if (absoluteChange < 0) direction = "decrease";
|
|
1280
|
+
else direction = "no change";
|
|
1281
|
+
return {
|
|
1282
|
+
oldValue,
|
|
1283
|
+
newValue,
|
|
1284
|
+
absoluteChange: round4(absoluteChange),
|
|
1285
|
+
percentChange: round4(percentChange),
|
|
1286
|
+
direction,
|
|
1287
|
+
multiplier: round4(multiplier)
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
function convertAprApy(rate, compoundsPerYear, direction) {
|
|
1291
|
+
if (!Number.isFinite(rate) || rate < 0) return { error: "Rate must be zero or a positive number" };
|
|
1292
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
1293
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
1294
|
+
}
|
|
1295
|
+
if (direction !== "apr-to-apy" && direction !== "apy-to-apr") {
|
|
1296
|
+
return { error: 'Direction must be "apr-to-apy" or "apy-to-apr"' };
|
|
1297
|
+
}
|
|
1298
|
+
const round6 = (n2) => Math.round(n2 * 1e6) / 1e6;
|
|
1299
|
+
const round8 = (n2) => Math.round(n2 * 1e8) / 1e8;
|
|
1300
|
+
const n = compoundsPerYear;
|
|
1301
|
+
let aprDecimal;
|
|
1302
|
+
let apyDecimal;
|
|
1303
|
+
if (direction === "apr-to-apy") {
|
|
1304
|
+
aprDecimal = rate / 100;
|
|
1305
|
+
apyDecimal = Math.pow(1 + aprDecimal / n, n) - 1;
|
|
1306
|
+
} else {
|
|
1307
|
+
apyDecimal = rate / 100;
|
|
1308
|
+
aprDecimal = n * (Math.pow(1 + apyDecimal, 1 / n) - 1);
|
|
1309
|
+
}
|
|
1310
|
+
const apr = round6(aprDecimal * 100);
|
|
1311
|
+
const apy = round6(apyDecimal * 100);
|
|
1312
|
+
return {
|
|
1313
|
+
direction,
|
|
1314
|
+
compoundsPerYear: n,
|
|
1315
|
+
apr,
|
|
1316
|
+
apy,
|
|
1317
|
+
aprDecimal: round8(aprDecimal),
|
|
1318
|
+
apyDecimal: round8(apyDecimal),
|
|
1319
|
+
difference: round6(apy - apr)
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1267
1322
|
|
|
1268
1323
|
exports.BASE_LABELS = BASE_LABELS;
|
|
1269
1324
|
exports.BASE_PREFIXES = BASE_PREFIXES;
|
|
@@ -1282,12 +1337,14 @@ exports.calcAspectRatio = calcAspectRatio;
|
|
|
1282
1337
|
exports.calcSubnet = calcSubnet;
|
|
1283
1338
|
exports.calculateCompoundInterest = calculateCompoundInterest;
|
|
1284
1339
|
exports.calculateLoan = calculateLoan;
|
|
1340
|
+
exports.calculatePercentageChange = calculatePercentageChange;
|
|
1285
1341
|
exports.calculateSimpleInterest = calculateSimpleInterest;
|
|
1286
1342
|
exports.calculateTax = calculateTax;
|
|
1287
1343
|
exports.calculateTimeValue = calculateTimeValue;
|
|
1288
1344
|
exports.calculateTipSplit = calculateTipSplit;
|
|
1289
1345
|
exports.compareSemver = compareSemver;
|
|
1290
1346
|
exports.convert = convert;
|
|
1347
|
+
exports.convertAprApy = convertAprApy;
|
|
1291
1348
|
exports.convertBytes = convertBytes;
|
|
1292
1349
|
exports.convertIp = convertIp;
|
|
1293
1350
|
exports.coverBox = coverBox;
|
package/dist/tools/units.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS,
|
|
1
|
+
export { A as AmortizationRow, a as AprApyDirection, b as AprApyResult, c as AspectRatioResult, B as BASE_LABELS, d as BASE_PREFIXES, e as BYTE_UNITS, f as BarcodeFormat, g as BarcodeValidationResult, h as BaseConvertResult, i as ByteConvertResult, j as ByteUnit, C as COMMON_CURRENCIES, k as COMMON_LOCALES, l as COMMON_PERMISSIONS, m as COMMON_RATIOS, n as COMMON_SIZES, o as COMMON_TAX_RATES, p as COMMON_TIP_PERCENTAGES, q as COMMON_VIEWPORTS, r as CardValidationResult, s as CompoundInterestResult, t as CompoundYearRow, D as Dimensions, F as FilePermissions, v as FormatOptions, I as IbanValidationResult, w as IpConversion, x as IsbnFormat, y as IsbnResult, L as LoanResult, N as NotationStyle, z as NumberBase, P as PercentChangeDirection, E as PercentageChangeResult, G as Permission, H as PxConvertResult, S as SemverVersion, J as SimpleInterestResult, K as SubnetInfo, T as TaxDirection, M as TaxResult, O as TimeValueDirection, Q as TimeValueResult, R as TipSplitResult, V as ViewportConvertResult, U as autoFormat, W as bumpVersion, X as calcAspectRatio, Y as calcSubnet, Z as calculateCompoundInterest, _ as calculateLoan, $ as calculatePercentageChange, a0 as calculateSimpleInterest, a1 as calculateTax, a2 as calculateTimeValue, a3 as calculateTipSplit, a4 as compareSemver, a5 as convert, a6 as convertAprApy, a7 as convertBytes, a8 as convertIp, a9 as coverBox, aa as decimalToIp, ab as decimalToIpCidr, ac as describePermissions, ad as fitIntoBox, ae as formatNumber, af as formatValue, ag as formatVwValue, ah as formatWithSeparator, ai as gcd, aj as ipFromBinary, ak as ipFromDecimal, al as ipFromHex, am as ipToBinary, an as ipToDecimal, ao as ipToDecimalCidr, ap as ipToHex, aq as ipToOctal, ar as isValid, as as isValidCidr, at as isValidIp, au as isValidIpv4, av as octalToPermissions, aw as parseFileSize, ax as parseInput, ay as parseNumberString, az as parseSemver, aA as permissionsToChmod, aB as permissionsToOctal, aC as permissionsToSymbolic, aD as ptToPx, aE as pxToAll, aF as pxToViewport, aG as remToPx, aH as satisfiesRange, aI as scaleByHeight, aJ as scaleByWidth, aK as sortVersions, aL as splitSubnet, aM as symbolicToPermissions, aN as validateBarcode, aO as validateCardNumber, aP as validateIban, aQ as validateIsbn, aR as viewportToPx } from '../units-KrjRyu0w.cjs';
|
package/dist/tools/units.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS,
|
|
1
|
+
export { A as AmortizationRow, a as AprApyDirection, b as AprApyResult, c as AspectRatioResult, B as BASE_LABELS, d as BASE_PREFIXES, e as BYTE_UNITS, f as BarcodeFormat, g as BarcodeValidationResult, h as BaseConvertResult, i as ByteConvertResult, j as ByteUnit, C as COMMON_CURRENCIES, k as COMMON_LOCALES, l as COMMON_PERMISSIONS, m as COMMON_RATIOS, n as COMMON_SIZES, o as COMMON_TAX_RATES, p as COMMON_TIP_PERCENTAGES, q as COMMON_VIEWPORTS, r as CardValidationResult, s as CompoundInterestResult, t as CompoundYearRow, D as Dimensions, F as FilePermissions, v as FormatOptions, I as IbanValidationResult, w as IpConversion, x as IsbnFormat, y as IsbnResult, L as LoanResult, N as NotationStyle, z as NumberBase, P as PercentChangeDirection, E as PercentageChangeResult, G as Permission, H as PxConvertResult, S as SemverVersion, J as SimpleInterestResult, K as SubnetInfo, T as TaxDirection, M as TaxResult, O as TimeValueDirection, Q as TimeValueResult, R as TipSplitResult, V as ViewportConvertResult, U as autoFormat, W as bumpVersion, X as calcAspectRatio, Y as calcSubnet, Z as calculateCompoundInterest, _ as calculateLoan, $ as calculatePercentageChange, a0 as calculateSimpleInterest, a1 as calculateTax, a2 as calculateTimeValue, a3 as calculateTipSplit, a4 as compareSemver, a5 as convert, a6 as convertAprApy, a7 as convertBytes, a8 as convertIp, a9 as coverBox, aa as decimalToIp, ab as decimalToIpCidr, ac as describePermissions, ad as fitIntoBox, ae as formatNumber, af as formatValue, ag as formatVwValue, ah as formatWithSeparator, ai as gcd, aj as ipFromBinary, ak as ipFromDecimal, al as ipFromHex, am as ipToBinary, an as ipToDecimal, ao as ipToDecimalCidr, ap as ipToHex, aq as ipToOctal, ar as isValid, as as isValidCidr, at as isValidIp, au as isValidIpv4, av as octalToPermissions, aw as parseFileSize, ax as parseInput, ay as parseNumberString, az as parseSemver, aA as permissionsToChmod, aB as permissionsToOctal, aC as permissionsToSymbolic, aD as ptToPx, aE as pxToAll, aF as pxToViewport, aG as remToPx, aH as satisfiesRange, aI as scaleByHeight, aJ as scaleByWidth, aK as sortVersions, aL as splitSubnet, aM as symbolicToPermissions, aN as validateBarcode, aO as validateCardNumber, aP as validateIban, aQ as validateIsbn, aR as viewportToPx } from '../units-KrjRyu0w.js';
|