@linguacode/cli 1.0.2 → 1.1.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/bin/lingua.cjs +739 -4
- package/package.json +1 -1
package/bin/lingua.cjs
CHANGED
|
@@ -6974,7 +6974,10 @@ var UTILITY_ADAPTER_IDS = [
|
|
|
6974
6974
|
// (the renderer utils now re-export — implementation note, no drift).
|
|
6975
6975
|
"uuid",
|
|
6976
6976
|
"lorem-ipsum",
|
|
6977
|
-
"string-inspect"
|
|
6977
|
+
"string-inspect",
|
|
6978
|
+
// Natural-language schedule -> cron expression, sharing the Cron Parser
|
|
6979
|
+
// panel's grammar (src/shared/utilities/cronPhrase.ts).
|
|
6980
|
+
"cron-phrase"
|
|
6978
6981
|
];
|
|
6979
6982
|
|
|
6980
6983
|
// src/shared/utilities/base64.ts
|
|
@@ -8539,6 +8542,733 @@ var uuidAdapter = {
|
|
|
8539
8542
|
}
|
|
8540
8543
|
};
|
|
8541
8544
|
|
|
8545
|
+
// src/shared/utilities/cronPhrase.ts
|
|
8546
|
+
var WEEKDAYS = [
|
|
8547
|
+
[/\b(?:sundays?|domingos?|dom|sun)\b/g, 0],
|
|
8548
|
+
[/\b(?:mondays?|lunes|mon|lun)\b/g, 1],
|
|
8549
|
+
[/\b(?:tuesdays?|martes|tue|tues|mar)\b/g, 2],
|
|
8550
|
+
[/\b(?:wednesdays?|miercoles|wed|mie)\b/g, 3],
|
|
8551
|
+
[/\b(?:thursdays?|jueves|thu|thur|thurs|jue)\b/g, 4],
|
|
8552
|
+
[/\b(?:fridays?|viernes|fri|vie)\b/g, 5],
|
|
8553
|
+
[/\b(?:saturdays?|sabados?|sat|sab)\b/g, 6]
|
|
8554
|
+
];
|
|
8555
|
+
var MONTHS = [
|
|
8556
|
+
[/\b(?:january|enero|jan|ene)\b/g, 1],
|
|
8557
|
+
[/\b(?:february|febrero|feb)\b/g, 2],
|
|
8558
|
+
[/\b(?:march|marzo)\b/g, 3],
|
|
8559
|
+
[/\b(?:april|abril|apr|abr)\b/g, 4],
|
|
8560
|
+
[/\b(?:may|mayo)\b/g, 5],
|
|
8561
|
+
[/\b(?:june|junio|jun)\b/g, 6],
|
|
8562
|
+
[/\b(?:july|julio|jul)\b/g, 7],
|
|
8563
|
+
[/\b(?:august|agosto|aug|ago)\b/g, 8],
|
|
8564
|
+
[/\b(?:september|septiembre|setiembre|sep|sept)\b/g, 9],
|
|
8565
|
+
[/\b(?:october|octubre|oct)\b/g, 10],
|
|
8566
|
+
[/\b(?:november|noviembre|nov)\b/g, 11],
|
|
8567
|
+
[/\b(?:december|diciembre|dec|dic)\b/g, 12]
|
|
8568
|
+
];
|
|
8569
|
+
var FILLER = /* @__PURE__ */ new Set([
|
|
8570
|
+
"cron",
|
|
8571
|
+
"fire",
|
|
8572
|
+
"job",
|
|
8573
|
+
"task",
|
|
8574
|
+
"tarea",
|
|
8575
|
+
"schedule",
|
|
8576
|
+
"horario",
|
|
8577
|
+
"expresion",
|
|
8578
|
+
"expression",
|
|
8579
|
+
"run",
|
|
8580
|
+
"runs",
|
|
8581
|
+
"running",
|
|
8582
|
+
"ejecuta",
|
|
8583
|
+
"ejecutar",
|
|
8584
|
+
"ejecutame",
|
|
8585
|
+
"corre",
|
|
8586
|
+
"correr",
|
|
8587
|
+
"lanza",
|
|
8588
|
+
"lanzar",
|
|
8589
|
+
"programa",
|
|
8590
|
+
"programar",
|
|
8591
|
+
"a",
|
|
8592
|
+
"al",
|
|
8593
|
+
"las",
|
|
8594
|
+
"la",
|
|
8595
|
+
"el",
|
|
8596
|
+
"los",
|
|
8597
|
+
"lo",
|
|
8598
|
+
"de",
|
|
8599
|
+
"del",
|
|
8600
|
+
"en",
|
|
8601
|
+
"y",
|
|
8602
|
+
"e",
|
|
8603
|
+
"o",
|
|
8604
|
+
"u",
|
|
8605
|
+
"un",
|
|
8606
|
+
"una",
|
|
8607
|
+
"que",
|
|
8608
|
+
"por",
|
|
8609
|
+
"para",
|
|
8610
|
+
"punto",
|
|
8611
|
+
"horas",
|
|
8612
|
+
"hora",
|
|
8613
|
+
"hrs",
|
|
8614
|
+
"hs",
|
|
8615
|
+
"at",
|
|
8616
|
+
"of",
|
|
8617
|
+
"on",
|
|
8618
|
+
"in",
|
|
8619
|
+
"the",
|
|
8620
|
+
"and",
|
|
8621
|
+
"or",
|
|
8622
|
+
"a.m",
|
|
8623
|
+
"p.m",
|
|
8624
|
+
"am",
|
|
8625
|
+
"pm",
|
|
8626
|
+
"oclock",
|
|
8627
|
+
"every",
|
|
8628
|
+
"cada",
|
|
8629
|
+
"todos",
|
|
8630
|
+
"todas",
|
|
8631
|
+
"dias",
|
|
8632
|
+
"dia",
|
|
8633
|
+
"me",
|
|
8634
|
+
"mi",
|
|
8635
|
+
"my",
|
|
8636
|
+
"please"
|
|
8637
|
+
]);
|
|
8638
|
+
var NUMBER_WORDS = [
|
|
8639
|
+
[/\buno\b/g, "1"],
|
|
8640
|
+
[/\bdos\b/g, "2"],
|
|
8641
|
+
[/\btres\b/g, "3"],
|
|
8642
|
+
[/\bcuatro\b/g, "4"],
|
|
8643
|
+
[/\bcinco\b/g, "5"],
|
|
8644
|
+
[/\bseis\b/g, "6"],
|
|
8645
|
+
[/\bsiete\b/g, "7"],
|
|
8646
|
+
[/\bocho\b/g, "8"],
|
|
8647
|
+
[/\bnueve\b/g, "9"],
|
|
8648
|
+
[/\bdiez\b/g, "10"],
|
|
8649
|
+
[/\bdoce\b/g, "12"],
|
|
8650
|
+
[/\bone\b/g, "1"],
|
|
8651
|
+
[/\btwo\b/g, "2"],
|
|
8652
|
+
[/\bthree\b/g, "3"],
|
|
8653
|
+
[/\bfour\b/g, "4"],
|
|
8654
|
+
[/\bfive\b/g, "5"],
|
|
8655
|
+
[/\bsix\b/g, "6"],
|
|
8656
|
+
[/\bseven\b/g, "7"],
|
|
8657
|
+
[/\beight\b/g, "8"],
|
|
8658
|
+
[/\bnine\b/g, "9"],
|
|
8659
|
+
[/\bten\b/g, "10"],
|
|
8660
|
+
[/\beleven\b/g, "11"],
|
|
8661
|
+
[/\btwelve\b/g, "12"]
|
|
8662
|
+
];
|
|
8663
|
+
function normalize(phrase) {
|
|
8664
|
+
let text = phrase.toLowerCase().normalize("NFD").replace(/[̀-ͯ]/gu, "").replace(/[.,;!?]+/gu, " ").replace(/\s+/gu, " ").trim();
|
|
8665
|
+
text = text.replace(/\ba las? once\b/gu, "a las 11");
|
|
8666
|
+
for (const [regex, digit] of NUMBER_WORDS) {
|
|
8667
|
+
text = text.replace(regex, digit);
|
|
8668
|
+
}
|
|
8669
|
+
return text;
|
|
8670
|
+
}
|
|
8671
|
+
function consume(state, start, end) {
|
|
8672
|
+
state.spans.push([start, end]);
|
|
8673
|
+
}
|
|
8674
|
+
function runAll(regex, text, onMatch) {
|
|
8675
|
+
regex.lastIndex = 0;
|
|
8676
|
+
let match;
|
|
8677
|
+
while ((match = regex.exec(text)) !== null) {
|
|
8678
|
+
onMatch(match);
|
|
8679
|
+
if (match[0].length === 0) regex.lastIndex += 1;
|
|
8680
|
+
}
|
|
8681
|
+
}
|
|
8682
|
+
function toHour(raw, meridiem) {
|
|
8683
|
+
let hour = Number(raw);
|
|
8684
|
+
if (!Number.isInteger(hour)) return null;
|
|
8685
|
+
if (meridiem) {
|
|
8686
|
+
if (hour < 1 || hour > 12) return null;
|
|
8687
|
+
if (meridiem === "pm" && hour < 12) hour += 12;
|
|
8688
|
+
if (meridiem === "am" && hour === 12) hour = 0;
|
|
8689
|
+
return hour;
|
|
8690
|
+
}
|
|
8691
|
+
return hour >= 0 && hour <= 23 ? hour : null;
|
|
8692
|
+
}
|
|
8693
|
+
function extractHourRange(text, state) {
|
|
8694
|
+
const range = /\b(?:between|entre|de|desde|from)\s+(?:las?\s+)?(\d{1,2})\s*(am|pm)?\s+(?:and|y|a|hasta|to)\s+(?:las?\s+)?(\d{1,2})\s*(am|pm)?\b/g;
|
|
8695
|
+
runAll(range, text, (m) => {
|
|
8696
|
+
const start = toHour(m[1], m[2]);
|
|
8697
|
+
let end = toHour(m[3], m[4]);
|
|
8698
|
+
if (start === null || end === null) return;
|
|
8699
|
+
let pmAssumed = false;
|
|
8700
|
+
if (end < start && !m[4] && end <= 12 && end + 12 <= 23) {
|
|
8701
|
+
end += 12;
|
|
8702
|
+
pmAssumed = true;
|
|
8703
|
+
}
|
|
8704
|
+
if (end <= start) return;
|
|
8705
|
+
state.hourRange = { start, end, pmAssumed };
|
|
8706
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8707
|
+
});
|
|
8708
|
+
}
|
|
8709
|
+
function extractTimes(text, state) {
|
|
8710
|
+
runAll(/\b(?:noon|mediodia)\b/g, text, (m) => {
|
|
8711
|
+
state.times.push({ hour: 12, minute: 0 });
|
|
8712
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8713
|
+
});
|
|
8714
|
+
runAll(/\b(?:midnight|medianoche)\b/g, text, (m) => {
|
|
8715
|
+
state.times.push({ hour: 0, minute: 0 });
|
|
8716
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8717
|
+
});
|
|
8718
|
+
runAll(/\b(\d{1,2}):(\d{2})\s*(am|pm)?\b/g, text, (m) => {
|
|
8719
|
+
const hour = toHour(m[1], m[3]);
|
|
8720
|
+
const minute = Number(m[2]);
|
|
8721
|
+
if (hour === null || minute < 0 || minute > 59) return;
|
|
8722
|
+
state.times.push({ hour, minute });
|
|
8723
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8724
|
+
});
|
|
8725
|
+
runAll(/\b(\d{1,2})\s*(am|pm)\b/g, text, (m) => {
|
|
8726
|
+
if (state.spans.some(([s, e]) => m.index >= s && m.index < e)) return;
|
|
8727
|
+
const hour = toHour(m[1], m[2]);
|
|
8728
|
+
if (hour === null) return;
|
|
8729
|
+
state.times.push({ hour, minute: 0 });
|
|
8730
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8731
|
+
});
|
|
8732
|
+
const halfQuarter = [
|
|
8733
|
+
[/\b(?:at\s+|a las?\s+)?(\d{1,2})\s+y\s+media\b/g, 30],
|
|
8734
|
+
[/\b(?:at\s+|a las?\s+)?(\d{1,2})\s+y\s+cuarto\b/g, 15],
|
|
8735
|
+
[/\bhalf past\s+(\d{1,2})\b/g, 30],
|
|
8736
|
+
[/\bquarter past\s+(\d{1,2})\b/g, 15]
|
|
8737
|
+
];
|
|
8738
|
+
for (const [regex, minute] of halfQuarter) {
|
|
8739
|
+
runAll(regex, text, (m) => {
|
|
8740
|
+
if (state.spans.some(([s, e]) => m.index >= s && m.index < e)) return;
|
|
8741
|
+
const hour = toHour(m[1], void 0);
|
|
8742
|
+
if (hour === null) return;
|
|
8743
|
+
state.times.push({ hour, minute });
|
|
8744
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8745
|
+
});
|
|
8746
|
+
}
|
|
8747
|
+
runAll(/\b(?:at|a las?)\s+(\d{1,2})\b/g, text, (m) => {
|
|
8748
|
+
if (state.spans.some(([s, e]) => m.index >= s && m.index < e)) return;
|
|
8749
|
+
const tail = text.slice(m.index + m[0].length);
|
|
8750
|
+
if (/^\s*(?::|am|pm)/.test(tail)) return;
|
|
8751
|
+
const hour = toHour(m[1], void 0);
|
|
8752
|
+
if (hour === null) return;
|
|
8753
|
+
state.times.push({ hour, minute: 0 });
|
|
8754
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8755
|
+
});
|
|
8756
|
+
}
|
|
8757
|
+
function extractInterval(text, state) {
|
|
8758
|
+
const unitOf = (word) => {
|
|
8759
|
+
if (/^min(?:s|uto?s?|utes?)?$/.test(word)) return "minute";
|
|
8760
|
+
if (/^(?:hours?|horas?|hrs?|hs)$/.test(word)) return "hour";
|
|
8761
|
+
if (/^(?:days?|dias?)$/.test(word)) return "day";
|
|
8762
|
+
if (/^(?:weeks?|semanas?)$/.test(word)) return "week";
|
|
8763
|
+
if (/^(?:months?|mes(?:es)?)$/.test(word)) return "month";
|
|
8764
|
+
if (/^(?:years?|anos?|anios?)$/.test(word)) return "year";
|
|
8765
|
+
return null;
|
|
8766
|
+
};
|
|
8767
|
+
const FIELD_MAX = {
|
|
8768
|
+
minute: 59,
|
|
8769
|
+
hour: 23,
|
|
8770
|
+
day: 31,
|
|
8771
|
+
month: 12
|
|
8772
|
+
};
|
|
8773
|
+
runAll(/\b(?:every other|each other|cada dos)\s+([a-z]+)\b/g, text, (m) => {
|
|
8774
|
+
const unit = unitOf(m[1]);
|
|
8775
|
+
if (!unit) return;
|
|
8776
|
+
state.interval = { unit, step: 2 };
|
|
8777
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8778
|
+
});
|
|
8779
|
+
runAll(/\b(?:every|each|cada)\s+(?:(\d+)\s+)?([a-z]+)\b/g, text, (m) => {
|
|
8780
|
+
if (state.spans.some(([s, e]) => m.index >= s && m.index < e)) return;
|
|
8781
|
+
const unit = unitOf(m[2]);
|
|
8782
|
+
if (!unit) return;
|
|
8783
|
+
const step = m[1] ? Number(m[1]) : 1;
|
|
8784
|
+
if (!Number.isInteger(step) || step < 1 || step > 999) return;
|
|
8785
|
+
if (unit !== "week" && unit !== "year" && step > FIELD_MAX[unit]) {
|
|
8786
|
+
state.stepOutOfRange = { step, max: FIELD_MAX[unit] };
|
|
8787
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8788
|
+
return;
|
|
8789
|
+
}
|
|
8790
|
+
if (state.interval && (state.interval.unit !== unit || state.interval.step !== step)) {
|
|
8791
|
+
state.intervalConflict = true;
|
|
8792
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8793
|
+
return;
|
|
8794
|
+
}
|
|
8795
|
+
state.interval = { unit, step };
|
|
8796
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8797
|
+
});
|
|
8798
|
+
if (!state.interval) {
|
|
8799
|
+
const singles = [
|
|
8800
|
+
[/\b(?:every half hour|cada media hora)\b/g, { unit: "minute", step: 30 }],
|
|
8801
|
+
// "once a day" reads as a plain daily schedule; "twice a day" is the
|
|
8802
|
+
// 12-hour cadence (00:00 and 12:00, or anchored to the given time).
|
|
8803
|
+
[/\b(?:once (?:a|per) (?:day|dia)|once daily)\b/g, { unit: "day", step: 1 }],
|
|
8804
|
+
[/\b(?:once (?:a|per) week)\b/g, { unit: "week", step: 1 }],
|
|
8805
|
+
[/\b(?:once (?:a|per) month)\b/g, { unit: "month", step: 1 }],
|
|
8806
|
+
// Post-normalization forms: "dos veces" already reads "2 veces" here.
|
|
8807
|
+
[/\b(?:twice (?:a|per) (?:day|dia)|twice daily|2 veces al dia)\b/g, { unit: "hour", step: 12 }],
|
|
8808
|
+
[/\b(?:una|1) vez al dia\b/g, { unit: "day", step: 1 }],
|
|
8809
|
+
[/\b(?:hourly)\b/g, { unit: "hour", step: 1 }],
|
|
8810
|
+
[/\b(?:daily|diario|diaria|diariamente|todos los dias)\b/g, { unit: "day", step: 1 }],
|
|
8811
|
+
[/\b(?:weekly|semanal|semanalmente)\b/g, { unit: "week", step: 1 }],
|
|
8812
|
+
[/\b(?:monthly|mensual|mensualmente)\b/g, { unit: "month", step: 1 }],
|
|
8813
|
+
[/\b(?:quarterly|trimestral|trimestralmente|every quarter|cada trimestre)\b/g, { unit: "month", step: 3 }],
|
|
8814
|
+
[/\b(?:yearly|annually|anual|anualmente)\b/g, { unit: "year", step: 1 }]
|
|
8815
|
+
];
|
|
8816
|
+
for (const [regex, interval] of singles) {
|
|
8817
|
+
runAll(regex, text, (m) => {
|
|
8818
|
+
state.interval = interval;
|
|
8819
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8820
|
+
});
|
|
8821
|
+
}
|
|
8822
|
+
}
|
|
8823
|
+
}
|
|
8824
|
+
function extractWeekdays(text, state) {
|
|
8825
|
+
runAll(/\b(?:weekdays?|entre semana|dias? (?:habiles|laborables)|business days)\b/g, text, (m) => {
|
|
8826
|
+
state.weekdayRange = { from: 1, to: 5 };
|
|
8827
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8828
|
+
});
|
|
8829
|
+
runAll(/\b(?:weekends?|fines? de semana)\b/g, text, (m) => {
|
|
8830
|
+
state.weekdays.add(6);
|
|
8831
|
+
state.weekdays.add(0);
|
|
8832
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8833
|
+
});
|
|
8834
|
+
const ORDINALS = [
|
|
8835
|
+
[/^(?:first|1st|primer|primero|primera)$/, 1],
|
|
8836
|
+
[/^(?:second|2nd|segundo|segunda)$/, 2],
|
|
8837
|
+
[/^(?:third|3rd|tercer|tercero|tercera)$/, 3],
|
|
8838
|
+
[/^(?:fourth|4th|cuarto|cuarta)$/, 4],
|
|
8839
|
+
[/^(?:fifth|5th|quinto|quinta)$/, 5],
|
|
8840
|
+
[/^(?:last|ultimo|ultima)$/, "last"]
|
|
8841
|
+
];
|
|
8842
|
+
const ordinalWord = "(?:first|1st|second|2nd|third|3rd|fourth|4th|fifth|5th|last|primer[oa]?|segund[oa]|tercer[oa]?|cuart[oa]|quint[oa]|ultim[oa])";
|
|
8843
|
+
const dayWord = "(?:sundays?|domingos?|mondays?|lunes|tuesdays?|martes|wednesdays?|miercoles|thursdays?|jueves|fridays?|viernes|saturdays?|sabados?)";
|
|
8844
|
+
const rangeRe = new RegExp(`\\b(${dayWord})\\s+(?:to|a|hasta|-)\\s+(${dayWord})\\b`, "g");
|
|
8845
|
+
const dayNumber = (word) => {
|
|
8846
|
+
for (const [regex, value] of WEEKDAYS) {
|
|
8847
|
+
regex.lastIndex = 0;
|
|
8848
|
+
if (regex.test(word)) return value;
|
|
8849
|
+
}
|
|
8850
|
+
return null;
|
|
8851
|
+
};
|
|
8852
|
+
const nthRe = new RegExp(
|
|
8853
|
+
`\\b(${ordinalWord})\\s+(${dayWord})(\\s+(?:of (?:the |every |each )?month|de cada mes|del mes))?\\b`,
|
|
8854
|
+
"g"
|
|
8855
|
+
);
|
|
8856
|
+
runAll(nthRe, text, (m) => {
|
|
8857
|
+
const day = dayNumber(m[2]);
|
|
8858
|
+
if (day === null) return;
|
|
8859
|
+
const nth = ORDINALS.find(([re]) => re.test(m[1]))?.[1];
|
|
8860
|
+
if (nth === void 0) return;
|
|
8861
|
+
state.nthWeekday = { day, nth };
|
|
8862
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8863
|
+
});
|
|
8864
|
+
runAll(rangeRe, text, (m) => {
|
|
8865
|
+
const from = dayNumber(m[1]);
|
|
8866
|
+
const to = dayNumber(m[2]);
|
|
8867
|
+
if (from === null || to === null || from === to) return;
|
|
8868
|
+
state.weekdayRange = { from, to };
|
|
8869
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8870
|
+
});
|
|
8871
|
+
for (const [regex, value] of WEEKDAYS) {
|
|
8872
|
+
runAll(new RegExp(regex.source, "g"), text, (m) => {
|
|
8873
|
+
if (state.spans.some(([s, e]) => m.index >= s && m.index < e)) return;
|
|
8874
|
+
state.weekdays.add(value);
|
|
8875
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8876
|
+
});
|
|
8877
|
+
}
|
|
8878
|
+
}
|
|
8879
|
+
function extractSemiMonthly(text, state) {
|
|
8880
|
+
runAll(
|
|
8881
|
+
/\b(?:quincenal(?:mente)?|quincena|semi[-\s]?monthly|twice (?:a|per) month|2 veces al mes)\b/g,
|
|
8882
|
+
text,
|
|
8883
|
+
(m) => {
|
|
8884
|
+
if (state.spans.some(([s, e]) => m.index >= s && m.index < e)) return;
|
|
8885
|
+
state.semiMonthly = true;
|
|
8886
|
+
state.monthDays.push(1, 15);
|
|
8887
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8888
|
+
}
|
|
8889
|
+
);
|
|
8890
|
+
}
|
|
8891
|
+
function extractMonthDays(text, state) {
|
|
8892
|
+
runAll(/\b(?:first day(?: of (?:the )?month)?|primer dia(?: del? mes)?)\b/g, text, (m) => {
|
|
8893
|
+
state.monthDays.push(1);
|
|
8894
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8895
|
+
});
|
|
8896
|
+
runAll(/\b(?:last day(?: of (?:the )?month)?|ultimo dia(?: del? mes)?)\b/g, text, (m) => {
|
|
8897
|
+
state.lastDayOfMonth = true;
|
|
8898
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8899
|
+
});
|
|
8900
|
+
runAll(/\b(\d{1,2})(?:st|nd|rd|th)(\s+of (?:the |every |each )?month)?\b/g, text, (m) => {
|
|
8901
|
+
if (state.spans.some(([s, e]) => m.index >= s && m.index < e)) return;
|
|
8902
|
+
const day = Number(m[1]);
|
|
8903
|
+
if (!Number.isInteger(day) || day < 1 || day > 31) return;
|
|
8904
|
+
state.monthDays.push(day);
|
|
8905
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8906
|
+
});
|
|
8907
|
+
runAll(
|
|
8908
|
+
/\b(?:on the|el dia|los dias|el|dia)\s+(\d{1,2})(?:st|nd|rd|th)?(\s+(?:de cada mes|del mes|of (?:the |every )?month))?\b/g,
|
|
8909
|
+
text,
|
|
8910
|
+
(m) => {
|
|
8911
|
+
if (state.spans.some(([s, e]) => m.index >= s && m.index < e)) return;
|
|
8912
|
+
if (!m[2] && !/(?:st|nd|rd|th)/.test(m[0])) return;
|
|
8913
|
+
const day = Number(m[1]);
|
|
8914
|
+
if (!Number.isInteger(day) || day < 1 || day > 31) return;
|
|
8915
|
+
state.monthDays.push(day);
|
|
8916
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8917
|
+
}
|
|
8918
|
+
);
|
|
8919
|
+
}
|
|
8920
|
+
function extractMonths(text, state) {
|
|
8921
|
+
for (const [regex, value] of MONTHS) {
|
|
8922
|
+
runAll(new RegExp(regex.source, "g"), text, (m) => {
|
|
8923
|
+
if (state.spans.some(([s, e]) => m.index >= s && m.index < e)) return;
|
|
8924
|
+
if (!state.months.includes(value)) state.months.push(value);
|
|
8925
|
+
consume(state, m.index, m.index + m[0].length);
|
|
8926
|
+
});
|
|
8927
|
+
}
|
|
8928
|
+
}
|
|
8929
|
+
function leftoverTokens(text, spans) {
|
|
8930
|
+
const masked = text.split("").map((ch, i2) => spans.some(([s, e]) => i2 >= s && i2 < e) ? " " : ch).join("");
|
|
8931
|
+
return masked.split(/\s+/).map((token) => token.trim()).filter((token) => token.length > 0 && !FILLER.has(token));
|
|
8932
|
+
}
|
|
8933
|
+
function formatDow(state) {
|
|
8934
|
+
if (state.nthWeekday) {
|
|
8935
|
+
const { day, nth } = state.nthWeekday;
|
|
8936
|
+
return nth === "last" ? `${day}L` : `${day}#${nth}`;
|
|
8937
|
+
}
|
|
8938
|
+
if (state.weekdayRange) {
|
|
8939
|
+
const { from, to } = state.weekdayRange;
|
|
8940
|
+
return from < to ? `${from}-${to}` : `${from}-6,0-${to}`;
|
|
8941
|
+
}
|
|
8942
|
+
if (state.weekdays.size > 0) {
|
|
8943
|
+
return [...state.weekdays].sort((a, b) => a - b).join(",");
|
|
8944
|
+
}
|
|
8945
|
+
return null;
|
|
8946
|
+
}
|
|
8947
|
+
function phraseToCron(phrase) {
|
|
8948
|
+
const text = normalize(phrase);
|
|
8949
|
+
if (text.length === 0) return { ok: false, reason: "empty" };
|
|
8950
|
+
const state = {
|
|
8951
|
+
spans: [],
|
|
8952
|
+
times: [],
|
|
8953
|
+
hourRange: null,
|
|
8954
|
+
interval: null,
|
|
8955
|
+
intervalConflict: false,
|
|
8956
|
+
stepOutOfRange: null,
|
|
8957
|
+
weekdays: /* @__PURE__ */ new Set(),
|
|
8958
|
+
weekdayRange: null,
|
|
8959
|
+
nthWeekday: null,
|
|
8960
|
+
semiMonthly: false,
|
|
8961
|
+
monthDays: [],
|
|
8962
|
+
lastDayOfMonth: false,
|
|
8963
|
+
months: []
|
|
8964
|
+
};
|
|
8965
|
+
extractHourRange(text, state);
|
|
8966
|
+
extractInterval(text, state);
|
|
8967
|
+
extractWeekdays(text, state);
|
|
8968
|
+
extractSemiMonthly(text, state);
|
|
8969
|
+
extractMonthDays(text, state);
|
|
8970
|
+
extractMonths(text, state);
|
|
8971
|
+
extractTimes(text, state);
|
|
8972
|
+
const leftover = leftoverTokens(text, state.spans);
|
|
8973
|
+
if (leftover.length > 0) {
|
|
8974
|
+
return { ok: false, reason: "unrecognized", leftover };
|
|
8975
|
+
}
|
|
8976
|
+
if (state.stepOutOfRange) {
|
|
8977
|
+
return {
|
|
8978
|
+
ok: false,
|
|
8979
|
+
reason: "unsupported",
|
|
8980
|
+
detail: {
|
|
8981
|
+
key: "utilities.tool.cron.phrase.unsupported.stepOutOfRange",
|
|
8982
|
+
values: { step: state.stepOutOfRange.step, max: state.stepOutOfRange.max }
|
|
8983
|
+
}
|
|
8984
|
+
};
|
|
8985
|
+
}
|
|
8986
|
+
if (state.intervalConflict) {
|
|
8987
|
+
return {
|
|
8988
|
+
ok: false,
|
|
8989
|
+
reason: "unsupported",
|
|
8990
|
+
detail: { key: "utilities.tool.cron.phrase.unsupported.conflictingIntervals" }
|
|
8991
|
+
};
|
|
8992
|
+
}
|
|
8993
|
+
const anythingExtracted = state.times.length > 0 || state.hourRange !== null || state.interval !== null || state.weekdays.size > 0 || state.weekdayRange !== null || state.nthWeekday !== null || state.monthDays.length > 0 || state.lastDayOfMonth || state.months.length > 0;
|
|
8994
|
+
if (!anythingExtracted) {
|
|
8995
|
+
return { ok: false, reason: "unrecognized", leftover: [] };
|
|
8996
|
+
}
|
|
8997
|
+
const assumptions = [];
|
|
8998
|
+
const caveats = [];
|
|
8999
|
+
if (state.interval && state.interval.unit === "week" && state.interval.step > 1) {
|
|
9000
|
+
return {
|
|
9001
|
+
ok: false,
|
|
9002
|
+
reason: "unsupported",
|
|
9003
|
+
detail: {
|
|
9004
|
+
key: "utilities.tool.cron.phrase.unsupported.multiWeek",
|
|
9005
|
+
values: { step: state.interval.step }
|
|
9006
|
+
}
|
|
9007
|
+
};
|
|
9008
|
+
}
|
|
9009
|
+
const uniqueMinutes = new Set(state.times.map((t) => t.minute));
|
|
9010
|
+
if (state.times.length > 1 && uniqueMinutes.size > 1) {
|
|
9011
|
+
return {
|
|
9012
|
+
ok: false,
|
|
9013
|
+
reason: "unsupported",
|
|
9014
|
+
detail: { key: "utilities.tool.cron.phrase.unsupported.mixedTimes" }
|
|
9015
|
+
};
|
|
9016
|
+
}
|
|
9017
|
+
let minute = "*";
|
|
9018
|
+
let hour = "*";
|
|
9019
|
+
let dom = "*";
|
|
9020
|
+
let month = "*";
|
|
9021
|
+
let dow = "*";
|
|
9022
|
+
const dowValue = formatDow(state);
|
|
9023
|
+
if (dowValue) dow = dowValue;
|
|
9024
|
+
if (state.nthWeekday) {
|
|
9025
|
+
caveats.push({
|
|
9026
|
+
key: state.nthWeekday.nth === "last" ? "utilities.tool.cron.phrase.caveat.nonstandardLastWeekday" : "utilities.tool.cron.phrase.caveat.nonstandardNthWeekday"
|
|
9027
|
+
});
|
|
9028
|
+
}
|
|
9029
|
+
if (state.monthDays.length > 0) {
|
|
9030
|
+
dom = [...new Set(state.monthDays)].sort((a, b) => a - b).join(",");
|
|
9031
|
+
}
|
|
9032
|
+
if (state.semiMonthly) {
|
|
9033
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.semiMonthly" });
|
|
9034
|
+
caveats.push({ key: "utilities.tool.cron.phrase.caveat.semiMonthlyGap" });
|
|
9035
|
+
}
|
|
9036
|
+
if (state.lastDayOfMonth) {
|
|
9037
|
+
dom = dom === "*" ? "L" : `${dom},L`;
|
|
9038
|
+
caveats.push({ key: "utilities.tool.cron.phrase.caveat.nonstandardLast" });
|
|
9039
|
+
}
|
|
9040
|
+
if (state.months.length > 0) {
|
|
9041
|
+
month = [...state.months].sort((a, b) => a - b).join(",");
|
|
9042
|
+
}
|
|
9043
|
+
if (state.times.length > 0) {
|
|
9044
|
+
const minuteValue = state.times[0].minute;
|
|
9045
|
+
minute = String(minuteValue);
|
|
9046
|
+
hour = [...new Set(state.times.map((t) => t.hour))].sort((a, b) => a - b).join(",");
|
|
9047
|
+
}
|
|
9048
|
+
const interval = state.interval;
|
|
9049
|
+
if (interval) {
|
|
9050
|
+
switch (interval.unit) {
|
|
9051
|
+
case "minute": {
|
|
9052
|
+
minute = interval.step === 1 ? "*" : `*/${interval.step}`;
|
|
9053
|
+
if (interval.step > 1 && 60 % interval.step !== 0) {
|
|
9054
|
+
caveats.push({
|
|
9055
|
+
key: "utilities.tool.cron.phrase.caveat.minuteStepUneven",
|
|
9056
|
+
values: { step: interval.step, tail: 60 % interval.step }
|
|
9057
|
+
});
|
|
9058
|
+
}
|
|
9059
|
+
if (state.times.length > 0) {
|
|
9060
|
+
hour = [...new Set(state.times.map((t) => t.hour))].sort((a, b) => a - b).join(",");
|
|
9061
|
+
}
|
|
9062
|
+
if (state.hourRange) hour = `${state.hourRange.start}-${state.hourRange.end}`;
|
|
9063
|
+
break;
|
|
9064
|
+
}
|
|
9065
|
+
case "hour": {
|
|
9066
|
+
hour = interval.step === 1 ? "*" : `*/${interval.step}`;
|
|
9067
|
+
if (interval.step > 1 && 24 % interval.step !== 0) {
|
|
9068
|
+
caveats.push({
|
|
9069
|
+
key: "utilities.tool.cron.phrase.caveat.hourStepUneven",
|
|
9070
|
+
values: { step: interval.step, tail: 24 % interval.step }
|
|
9071
|
+
});
|
|
9072
|
+
}
|
|
9073
|
+
if (state.times.length === 0) {
|
|
9074
|
+
minute = "0";
|
|
9075
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.minuteZero" });
|
|
9076
|
+
}
|
|
9077
|
+
if (state.hourRange) {
|
|
9078
|
+
hour = interval.step === 1 ? `${state.hourRange.start}-${state.hourRange.end}` : `${state.hourRange.start}-${state.hourRange.end}/${interval.step}`;
|
|
9079
|
+
}
|
|
9080
|
+
break;
|
|
9081
|
+
}
|
|
9082
|
+
case "day": {
|
|
9083
|
+
if (interval.step > 1) {
|
|
9084
|
+
dom = `*/${interval.step}`;
|
|
9085
|
+
caveats.push({
|
|
9086
|
+
key: "utilities.tool.cron.phrase.caveat.domStepReset",
|
|
9087
|
+
values: { step: interval.step }
|
|
9088
|
+
});
|
|
9089
|
+
}
|
|
9090
|
+
if (state.times.length === 0 && !state.hourRange) {
|
|
9091
|
+
minute = "0";
|
|
9092
|
+
hour = "0";
|
|
9093
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.midnight" });
|
|
9094
|
+
}
|
|
9095
|
+
break;
|
|
9096
|
+
}
|
|
9097
|
+
case "week": {
|
|
9098
|
+
if (dow === "*") {
|
|
9099
|
+
dow = "1";
|
|
9100
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.monday" });
|
|
9101
|
+
}
|
|
9102
|
+
if (state.times.length === 0) {
|
|
9103
|
+
minute = "0";
|
|
9104
|
+
hour = "0";
|
|
9105
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.midnight" });
|
|
9106
|
+
}
|
|
9107
|
+
break;
|
|
9108
|
+
}
|
|
9109
|
+
case "year": {
|
|
9110
|
+
if (month === "*") {
|
|
9111
|
+
month = "1";
|
|
9112
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.january" });
|
|
9113
|
+
}
|
|
9114
|
+
if (dom === "*") {
|
|
9115
|
+
dom = "1";
|
|
9116
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.firstOfMonth" });
|
|
9117
|
+
}
|
|
9118
|
+
if (interval.step > 1) {
|
|
9119
|
+
caveats.push({
|
|
9120
|
+
key: "utilities.tool.cron.phrase.caveat.noYearField",
|
|
9121
|
+
values: { step: interval.step }
|
|
9122
|
+
});
|
|
9123
|
+
}
|
|
9124
|
+
if (state.times.length === 0) {
|
|
9125
|
+
minute = "0";
|
|
9126
|
+
hour = "0";
|
|
9127
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.midnight" });
|
|
9128
|
+
}
|
|
9129
|
+
break;
|
|
9130
|
+
}
|
|
9131
|
+
case "month": {
|
|
9132
|
+
if (interval.step > 1) {
|
|
9133
|
+
month = `*/${interval.step}`;
|
|
9134
|
+
if (12 % interval.step !== 0) {
|
|
9135
|
+
caveats.push({
|
|
9136
|
+
key: "utilities.tool.cron.phrase.caveat.monthStepUneven",
|
|
9137
|
+
values: { step: interval.step, tail: 12 % interval.step }
|
|
9138
|
+
});
|
|
9139
|
+
}
|
|
9140
|
+
}
|
|
9141
|
+
if (dom === "*") {
|
|
9142
|
+
dom = "1";
|
|
9143
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.firstOfMonth" });
|
|
9144
|
+
}
|
|
9145
|
+
if (state.times.length === 0) {
|
|
9146
|
+
minute = "0";
|
|
9147
|
+
hour = "0";
|
|
9148
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.midnight" });
|
|
9149
|
+
}
|
|
9150
|
+
break;
|
|
9151
|
+
}
|
|
9152
|
+
}
|
|
9153
|
+
}
|
|
9154
|
+
if (!interval && state.hourRange) {
|
|
9155
|
+
hour = `${state.hourRange.start}-${state.hourRange.end}`;
|
|
9156
|
+
if (state.times.length === 0) {
|
|
9157
|
+
minute = "0";
|
|
9158
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.minuteZero" });
|
|
9159
|
+
}
|
|
9160
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.hourlyWindow" });
|
|
9161
|
+
}
|
|
9162
|
+
if (state.hourRange?.pmAssumed) {
|
|
9163
|
+
assumptions.push({
|
|
9164
|
+
key: "utilities.tool.cron.phrase.assumption.pmWindowEnd",
|
|
9165
|
+
values: { end: state.hourRange.end - 12, shifted: state.hourRange.end }
|
|
9166
|
+
});
|
|
9167
|
+
}
|
|
9168
|
+
if (!interval && !state.hourRange && state.times.length > 0 && dom === "*" && dow === "*" && month === "*") {
|
|
9169
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.daily" });
|
|
9170
|
+
}
|
|
9171
|
+
if (!interval && !state.hourRange && state.times.length === 0) {
|
|
9172
|
+
minute = "0";
|
|
9173
|
+
hour = "0";
|
|
9174
|
+
assumptions.push({ key: "utilities.tool.cron.phrase.assumption.midnight" });
|
|
9175
|
+
}
|
|
9176
|
+
if (dom !== "*" && dow !== "*") {
|
|
9177
|
+
caveats.push({ key: "utilities.tool.cron.phrase.caveat.domDowUnion" });
|
|
9178
|
+
}
|
|
9179
|
+
return {
|
|
9180
|
+
ok: true,
|
|
9181
|
+
expression: `${minute} ${hour} ${dom} ${month} ${dow}`,
|
|
9182
|
+
assumptions,
|
|
9183
|
+
caveats
|
|
9184
|
+
};
|
|
9185
|
+
}
|
|
9186
|
+
|
|
9187
|
+
// src/shared/utilities/cronPhraseAdapter.ts
|
|
9188
|
+
var CRON_PHRASE_NOTE_TEXT = {
|
|
9189
|
+
"utilities.tool.cron.phrase.assumption.minuteZero": "Assumed minute 0.",
|
|
9190
|
+
"utilities.tool.cron.phrase.assumption.midnight": "No time given; assumed 00:00.",
|
|
9191
|
+
"utilities.tool.cron.phrase.assumption.monday": "No weekday given; assumed Monday.",
|
|
9192
|
+
"utilities.tool.cron.phrase.assumption.firstOfMonth": "Assumed day 1 of the month.",
|
|
9193
|
+
"utilities.tool.cron.phrase.assumption.daily": "Runs every day at that time.",
|
|
9194
|
+
"utilities.tool.cron.phrase.assumption.hourlyWindow": "Hourly within the window.",
|
|
9195
|
+
"utilities.tool.cron.phrase.assumption.pmWindowEnd": "Read the window end as {{shifted}}:00 ({{end}} pm).",
|
|
9196
|
+
"utilities.tool.cron.phrase.assumption.january": "A yearly schedule needs a date; assumed January 1.",
|
|
9197
|
+
"utilities.tool.cron.phrase.caveat.noYearField": "Cron has no year field, so an every-{{step}}-years cadence cannot be expressed. This fires every January 1 instead.",
|
|
9198
|
+
"utilities.tool.cron.phrase.caveat.nonstandardNthWeekday": "The # operator (nth weekday of the month) is a Quartz extension, not POSIX cron.",
|
|
9199
|
+
"utilities.tool.cron.phrase.caveat.nonstandardLastWeekday": "The L operator on a weekday (last one of the month) is a Quartz extension, not POSIX cron.",
|
|
9200
|
+
"utilities.tool.cron.phrase.assumption.semiMonthly": "A fortnightly cadence has no single cron form; read as the 1st and the 15th.",
|
|
9201
|
+
"utilities.tool.cron.phrase.caveat.semiMonthlyGap": "The gap is not uniform: 14 days from the 1st to the 15th, then 14 to 17 days from the 15th to the next 1st.",
|
|
9202
|
+
"utilities.tool.cron.phrase.caveat.domStepReset": "The {{step}}-day step restarts at the start of every month, so the gap breaks at month boundaries.",
|
|
9203
|
+
"utilities.tool.cron.phrase.caveat.domDowUnion": "Cron treats day-of-month plus weekday as either/or: this fires on those dates AND on those weekdays.",
|
|
9204
|
+
"utilities.tool.cron.phrase.caveat.nonstandardLast": "L (last day) is not POSIX-standard cron; check your scheduler accepts it.",
|
|
9205
|
+
"utilities.tool.cron.phrase.caveat.minuteStepUneven": "60 is not divisible by {{step}}; the count restarts each hour, leaving a {{tail}}-minute gap.",
|
|
9206
|
+
"utilities.tool.cron.phrase.caveat.hourStepUneven": "24 is not divisible by {{step}}; the count restarts at midnight, leaving a {{tail}}-hour gap.",
|
|
9207
|
+
"utilities.tool.cron.phrase.caveat.monthStepUneven": "12 is not divisible by {{step}}; the count restarts each January, leaving a {{tail}}-month gap.",
|
|
9208
|
+
"utilities.tool.cron.phrase.unsupported.multiWeek": "Cron cannot express a continuous every-{{step}}-weeks schedule. Closest options: fixed days like 1,15, or run weekly and skip inside the job.",
|
|
9209
|
+
"utilities.tool.cron.phrase.unsupported.mixedTimes": "One cron expression cannot combine times with different minutes (the fields multiply). Create one expression per time.",
|
|
9210
|
+
"utilities.tool.cron.phrase.unsupported.stepOutOfRange": "A step of {{step}} does not fit this cron field (maximum {{max}}). Express it with the next larger unit.",
|
|
9211
|
+
"utilities.tool.cron.phrase.unsupported.conflictingIntervals": "The phrase asks for two competing cadences at once. Keep one interval per expression."
|
|
9212
|
+
};
|
|
9213
|
+
function renderCronPhraseNote(note) {
|
|
9214
|
+
const template = CRON_PHRASE_NOTE_TEXT[note.key] ?? note.key;
|
|
9215
|
+
return template.replace(
|
|
9216
|
+
/\{\{(\w+)\}\}/gu,
|
|
9217
|
+
(_, name) => String(note.values?.[name] ?? `{{${name}}}`)
|
|
9218
|
+
);
|
|
9219
|
+
}
|
|
9220
|
+
var ANNOTATE_OPTION = {
|
|
9221
|
+
key: "annotate",
|
|
9222
|
+
type: "boolean",
|
|
9223
|
+
labelKey: "utilityPipeline.adapter.cronPhrase.options.annotate.label",
|
|
9224
|
+
defaultValue: false
|
|
9225
|
+
};
|
|
9226
|
+
var cronPhraseAdapter = {
|
|
9227
|
+
id: "cron-phrase",
|
|
9228
|
+
titleKey: "utilityPipeline.adapter.cronPhrase.title",
|
|
9229
|
+
descriptionKey: "utilityPipeline.adapter.cronPhrase.description",
|
|
9230
|
+
inputKind: "text",
|
|
9231
|
+
outputKind: "text",
|
|
9232
|
+
optionsSchema: [ANNOTATE_OPTION],
|
|
9233
|
+
defaultOptions: () => ({ annotate: false }),
|
|
9234
|
+
parseOptions: (raw) => {
|
|
9235
|
+
if (raw === void 0 || raw === null) return { annotate: false };
|
|
9236
|
+
if (typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
9237
|
+
const candidate = raw;
|
|
9238
|
+
const annotate = candidate.annotate === void 0 ? false : candidate.annotate;
|
|
9239
|
+
if (typeof annotate !== "boolean") return null;
|
|
9240
|
+
return { annotate };
|
|
9241
|
+
},
|
|
9242
|
+
run: async (input, options) => {
|
|
9243
|
+
const result = phraseToCron(input);
|
|
9244
|
+
if (!result.ok) {
|
|
9245
|
+
if (result.reason === "empty") {
|
|
9246
|
+
return { ok: false, reason: "invalid-input", detail: "Empty phrase." };
|
|
9247
|
+
}
|
|
9248
|
+
if (result.reason === "unrecognized") {
|
|
9249
|
+
const leftover = result.leftover && result.leftover.length > 0 ? ` Not understood: ${result.leftover.join(", ")}.` : "";
|
|
9250
|
+
return {
|
|
9251
|
+
ok: false,
|
|
9252
|
+
reason: "invalid-input",
|
|
9253
|
+
detail: `Could not turn the phrase into a schedule.${leftover}`
|
|
9254
|
+
};
|
|
9255
|
+
}
|
|
9256
|
+
return {
|
|
9257
|
+
ok: false,
|
|
9258
|
+
reason: "unsupported",
|
|
9259
|
+
detail: result.detail ? renderCronPhraseNote(result.detail) : "Unsupported schedule."
|
|
9260
|
+
};
|
|
9261
|
+
}
|
|
9262
|
+
if (!options.annotate) return { ok: true, value: result.expression };
|
|
9263
|
+
const lines = [
|
|
9264
|
+
result.expression,
|
|
9265
|
+
...result.assumptions.map((note) => `# assumption: ${renderCronPhraseNote(note)}`),
|
|
9266
|
+
...result.caveats.map((note) => `# caveat: ${renderCronPhraseNote(note)}`)
|
|
9267
|
+
];
|
|
9268
|
+
return { ok: true, value: lines.join("\n") };
|
|
9269
|
+
}
|
|
9270
|
+
};
|
|
9271
|
+
|
|
8542
9272
|
// src/shared/utilities/urlParse.ts
|
|
8543
9273
|
function parseUrl(input) {
|
|
8544
9274
|
try {
|
|
@@ -8697,7 +9427,8 @@ var UTILITY_ADAPTER_REGISTRY = {
|
|
|
8697
9427
|
// implementation — generator-style holdouts (uuid / lorem / inspect).
|
|
8698
9428
|
uuid: uuidAdapter,
|
|
8699
9429
|
"lorem-ipsum": loremIpsumAdapter,
|
|
8700
|
-
"string-inspect": stringInspectAdapter
|
|
9430
|
+
"string-inspect": stringInspectAdapter,
|
|
9431
|
+
"cron-phrase": cronPhraseAdapter
|
|
8701
9432
|
};
|
|
8702
9433
|
function getAdapter(id) {
|
|
8703
9434
|
if (!Object.prototype.hasOwnProperty.call(UTILITY_ADAPTER_REGISTRY, id)) {
|
|
@@ -9210,6 +9941,10 @@ var CLI_HELP_CATALOG = {
|
|
|
9210
9941
|
flags: ["input", "option", "json", "quiet", "color", "help"],
|
|
9211
9942
|
examples: [
|
|
9212
9943
|
{ command: `echo '{"a":1}' | lingua utility json-format`, description: "Format piped JSON." },
|
|
9944
|
+
{
|
|
9945
|
+
command: `echo 'cada 3 dias 8am' | lingua utility cron-phrase`,
|
|
9946
|
+
description: "Turn a plain-words schedule (English or Spanish) into a cron expression."
|
|
9947
|
+
},
|
|
9213
9948
|
{
|
|
9214
9949
|
command: "lingua utility base64-encode --input README.md",
|
|
9215
9950
|
description: "Encode a file without opening the app."
|
|
@@ -9819,8 +10554,8 @@ function assertSingleTarget(command, positionals, help, label) {
|
|
|
9819
10554
|
|
|
9820
10555
|
// src/cli/lingua.ts
|
|
9821
10556
|
function resolveCliVersion() {
|
|
9822
|
-
if ("1.0
|
|
9823
|
-
return "1.0
|
|
10557
|
+
if ("1.1.0".length > 0) {
|
|
10558
|
+
return "1.1.0";
|
|
9824
10559
|
}
|
|
9825
10560
|
return "0.0.0-dev";
|
|
9826
10561
|
}
|
package/package.json
CHANGED