@optique/temporal 0.9.0-dev.185 → 0.9.0-dev.187
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/dist/index.cjs +28 -9
- package/dist/index.d.cts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +28 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
25
|
const __optique_core_message = __toESM(require("@optique/core/message"));
|
|
26
|
+
const __optique_core_nonempty = __toESM(require("@optique/core/nonempty"));
|
|
26
27
|
|
|
27
28
|
//#region src/index.ts
|
|
28
29
|
/**
|
|
@@ -37,8 +38,10 @@ const __optique_core_message = __toESM(require("@optique/core/message"));
|
|
|
37
38
|
* @returns A ValueParser that parses strings into Temporal.Instant values.
|
|
38
39
|
*/
|
|
39
40
|
function instant(options = {}) {
|
|
41
|
+
const metavar = options.metavar ?? "TIMESTAMP";
|
|
42
|
+
(0, __optique_core_nonempty.ensureNonEmptyString)(metavar);
|
|
40
43
|
return {
|
|
41
|
-
metavar
|
|
44
|
+
metavar,
|
|
42
45
|
parse(input) {
|
|
43
46
|
try {
|
|
44
47
|
const value = Temporal.Instant.from(input);
|
|
@@ -71,8 +74,10 @@ function instant(options = {}) {
|
|
|
71
74
|
* @returns A ValueParser that parses strings into Temporal.Duration values.
|
|
72
75
|
*/
|
|
73
76
|
function duration(options = {}) {
|
|
77
|
+
const metavar = options.metavar ?? "DURATION";
|
|
78
|
+
(0, __optique_core_nonempty.ensureNonEmptyString)(metavar);
|
|
74
79
|
return {
|
|
75
|
-
metavar
|
|
80
|
+
metavar,
|
|
76
81
|
parse(input) {
|
|
77
82
|
try {
|
|
78
83
|
const value = Temporal.Duration.from(input);
|
|
@@ -104,8 +109,10 @@ function duration(options = {}) {
|
|
|
104
109
|
* @returns A ValueParser that parses strings into Temporal.ZonedDateTime values.
|
|
105
110
|
*/
|
|
106
111
|
function zonedDateTime(options = {}) {
|
|
112
|
+
const metavar = options.metavar ?? "ZONED_DATETIME";
|
|
113
|
+
(0, __optique_core_nonempty.ensureNonEmptyString)(metavar);
|
|
107
114
|
return {
|
|
108
|
-
metavar
|
|
115
|
+
metavar,
|
|
109
116
|
parse(input) {
|
|
110
117
|
try {
|
|
111
118
|
const value = Temporal.ZonedDateTime.from(input);
|
|
@@ -137,8 +144,10 @@ function zonedDateTime(options = {}) {
|
|
|
137
144
|
* @returns A ValueParser that parses strings into Temporal.PlainDate values.
|
|
138
145
|
*/
|
|
139
146
|
function plainDate(options = {}) {
|
|
147
|
+
const metavar = options.metavar ?? "DATE";
|
|
148
|
+
(0, __optique_core_nonempty.ensureNonEmptyString)(metavar);
|
|
140
149
|
return {
|
|
141
|
-
metavar
|
|
150
|
+
metavar,
|
|
142
151
|
parse(input) {
|
|
143
152
|
try {
|
|
144
153
|
const value = Temporal.PlainDate.from(input);
|
|
@@ -170,8 +179,10 @@ function plainDate(options = {}) {
|
|
|
170
179
|
* @returns A ValueParser that parses strings into Temporal.PlainTime values.
|
|
171
180
|
*/
|
|
172
181
|
function plainTime(options = {}) {
|
|
182
|
+
const metavar = options.metavar ?? "TIME";
|
|
183
|
+
(0, __optique_core_nonempty.ensureNonEmptyString)(metavar);
|
|
173
184
|
return {
|
|
174
|
-
metavar
|
|
185
|
+
metavar,
|
|
175
186
|
parse(input) {
|
|
176
187
|
try {
|
|
177
188
|
const value = Temporal.PlainTime.from(input);
|
|
@@ -203,8 +214,10 @@ function plainTime(options = {}) {
|
|
|
203
214
|
* @returns A ValueParser that parses strings into Temporal.PlainDateTime values.
|
|
204
215
|
*/
|
|
205
216
|
function plainDateTime(options = {}) {
|
|
217
|
+
const metavar = options.metavar ?? "DATETIME";
|
|
218
|
+
(0, __optique_core_nonempty.ensureNonEmptyString)(metavar);
|
|
206
219
|
return {
|
|
207
|
-
metavar
|
|
220
|
+
metavar,
|
|
208
221
|
parse(input) {
|
|
209
222
|
try {
|
|
210
223
|
const value = Temporal.PlainDateTime.from(input);
|
|
@@ -236,8 +249,10 @@ function plainDateTime(options = {}) {
|
|
|
236
249
|
* @returns A ValueParser that parses strings into Temporal.PlainYearMonth values.
|
|
237
250
|
*/
|
|
238
251
|
function plainYearMonth(options = {}) {
|
|
252
|
+
const metavar = options.metavar ?? "YEAR-MONTH";
|
|
253
|
+
(0, __optique_core_nonempty.ensureNonEmptyString)(metavar);
|
|
239
254
|
return {
|
|
240
|
-
metavar
|
|
255
|
+
metavar,
|
|
241
256
|
parse(input) {
|
|
242
257
|
try {
|
|
243
258
|
const value = Temporal.PlainYearMonth.from(input);
|
|
@@ -269,8 +284,10 @@ function plainYearMonth(options = {}) {
|
|
|
269
284
|
* @returns A ValueParser that parses strings into Temporal.PlainMonthDay values.
|
|
270
285
|
*/
|
|
271
286
|
function plainMonthDay(options = {}) {
|
|
287
|
+
const metavar = options.metavar ?? "--MONTH-DAY";
|
|
288
|
+
(0, __optique_core_nonempty.ensureNonEmptyString)(metavar);
|
|
272
289
|
return {
|
|
273
|
-
metavar
|
|
290
|
+
metavar,
|
|
274
291
|
parse(input) {
|
|
275
292
|
try {
|
|
276
293
|
const value = Temporal.PlainMonthDay.from(input);
|
|
@@ -304,8 +321,10 @@ function plainMonthDay(options = {}) {
|
|
|
304
321
|
* @returns A ValueParser that parses and validates timezone identifiers.
|
|
305
322
|
*/
|
|
306
323
|
function timeZone(options = {}) {
|
|
324
|
+
const metavar = options.metavar ?? "TIMEZONE";
|
|
325
|
+
(0, __optique_core_nonempty.ensureNonEmptyString)(metavar);
|
|
307
326
|
return {
|
|
308
|
-
metavar
|
|
327
|
+
metavar,
|
|
309
328
|
parse(input) {
|
|
310
329
|
try {
|
|
311
330
|
Temporal.ZonedDateTime.from({
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ValueParser } from "@optique/core/valueparser";
|
|
2
2
|
import { Message } from "@optique/core/message";
|
|
3
|
+
import { NonEmptyString } from "@optique/core/nonempty";
|
|
3
4
|
|
|
4
5
|
//#region src/index.d.ts
|
|
5
6
|
|
|
@@ -31,7 +32,7 @@ interface InstantOptions {
|
|
|
31
32
|
* word in uppercase, like `TIMESTAMP` or `INSTANT`.
|
|
32
33
|
* @default `"TIMESTAMP"`
|
|
33
34
|
*/
|
|
34
|
-
readonly metavar?:
|
|
35
|
+
readonly metavar?: NonEmptyString;
|
|
35
36
|
/**
|
|
36
37
|
* Custom error messages for instant parsing failures.
|
|
37
38
|
* @since 0.5.0
|
|
@@ -55,7 +56,7 @@ interface DurationOptions {
|
|
|
55
56
|
* word in uppercase, like `DURATION`.
|
|
56
57
|
* @default `"DURATION"`
|
|
57
58
|
*/
|
|
58
|
-
readonly metavar?:
|
|
59
|
+
readonly metavar?: NonEmptyString;
|
|
59
60
|
/**
|
|
60
61
|
* Custom error messages for duration parsing failures.
|
|
61
62
|
* @since 0.5.0
|
|
@@ -79,7 +80,7 @@ interface ZonedDateTimeOptions {
|
|
|
79
80
|
* word in uppercase, like `ZONED_DATETIME`.
|
|
80
81
|
* @default `"ZONED_DATETIME"`
|
|
81
82
|
*/
|
|
82
|
-
readonly metavar?:
|
|
83
|
+
readonly metavar?: NonEmptyString;
|
|
83
84
|
/**
|
|
84
85
|
* Custom error messages for zoned datetime parsing failures.
|
|
85
86
|
* @since 0.5.0
|
|
@@ -103,7 +104,7 @@ interface PlainDateOptions {
|
|
|
103
104
|
* word in uppercase, like `DATE`.
|
|
104
105
|
* @default `"DATE"`
|
|
105
106
|
*/
|
|
106
|
-
readonly metavar?:
|
|
107
|
+
readonly metavar?: NonEmptyString;
|
|
107
108
|
/**
|
|
108
109
|
* Custom error messages for plain date parsing failures.
|
|
109
110
|
* @since 0.5.0
|
|
@@ -127,7 +128,7 @@ interface PlainTimeOptions {
|
|
|
127
128
|
* word in uppercase, like `TIME`.
|
|
128
129
|
* @default `"TIME"`
|
|
129
130
|
*/
|
|
130
|
-
readonly metavar?:
|
|
131
|
+
readonly metavar?: NonEmptyString;
|
|
131
132
|
/**
|
|
132
133
|
* Custom error messages for plain time parsing failures.
|
|
133
134
|
* @since 0.5.0
|
|
@@ -151,7 +152,7 @@ interface PlainDateTimeOptions {
|
|
|
151
152
|
* word in uppercase, like `DATETIME`.
|
|
152
153
|
* @default `"DATETIME"`
|
|
153
154
|
*/
|
|
154
|
-
readonly metavar?:
|
|
155
|
+
readonly metavar?: NonEmptyString;
|
|
155
156
|
/**
|
|
156
157
|
* Custom error messages for plain datetime parsing failures.
|
|
157
158
|
* @since 0.5.0
|
|
@@ -175,7 +176,7 @@ interface PlainYearMonthOptions {
|
|
|
175
176
|
* word in uppercase, like `YEAR-MONTH`.
|
|
176
177
|
* @default `"YEAR-MONTH"`
|
|
177
178
|
*/
|
|
178
|
-
readonly metavar?:
|
|
179
|
+
readonly metavar?: NonEmptyString;
|
|
179
180
|
/**
|
|
180
181
|
* Custom error messages for plain year-month parsing failures.
|
|
181
182
|
* @since 0.5.0
|
|
@@ -199,7 +200,7 @@ interface PlainMonthDayOptions {
|
|
|
199
200
|
* word in uppercase, like `--MONTH-DAY`.
|
|
200
201
|
* @default `"--MONTH-DAY"`
|
|
201
202
|
*/
|
|
202
|
-
readonly metavar?:
|
|
203
|
+
readonly metavar?: NonEmptyString;
|
|
203
204
|
/**
|
|
204
205
|
* Custom error messages for plain month-day parsing failures.
|
|
205
206
|
* @since 0.5.0
|
|
@@ -223,7 +224,7 @@ interface TimeZoneOptions {
|
|
|
223
224
|
* word in uppercase, like `TIMEZONE`.
|
|
224
225
|
* @default `"TIMEZONE"`
|
|
225
226
|
*/
|
|
226
|
-
readonly metavar?:
|
|
227
|
+
readonly metavar?: NonEmptyString;
|
|
227
228
|
/**
|
|
228
229
|
* Custom error messages for timezone parsing failures.
|
|
229
230
|
* @since 0.5.0
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { Message } from "@optique/core/message";
|
|
3
|
+
import { NonEmptyString } from "@optique/core/nonempty";
|
|
3
4
|
import { ValueParser } from "@optique/core/valueparser";
|
|
4
5
|
|
|
5
6
|
//#region src/index.d.ts
|
|
@@ -32,7 +33,7 @@ interface InstantOptions {
|
|
|
32
33
|
* word in uppercase, like `TIMESTAMP` or `INSTANT`.
|
|
33
34
|
* @default `"TIMESTAMP"`
|
|
34
35
|
*/
|
|
35
|
-
readonly metavar?:
|
|
36
|
+
readonly metavar?: NonEmptyString;
|
|
36
37
|
/**
|
|
37
38
|
* Custom error messages for instant parsing failures.
|
|
38
39
|
* @since 0.5.0
|
|
@@ -56,7 +57,7 @@ interface DurationOptions {
|
|
|
56
57
|
* word in uppercase, like `DURATION`.
|
|
57
58
|
* @default `"DURATION"`
|
|
58
59
|
*/
|
|
59
|
-
readonly metavar?:
|
|
60
|
+
readonly metavar?: NonEmptyString;
|
|
60
61
|
/**
|
|
61
62
|
* Custom error messages for duration parsing failures.
|
|
62
63
|
* @since 0.5.0
|
|
@@ -80,7 +81,7 @@ interface ZonedDateTimeOptions {
|
|
|
80
81
|
* word in uppercase, like `ZONED_DATETIME`.
|
|
81
82
|
* @default `"ZONED_DATETIME"`
|
|
82
83
|
*/
|
|
83
|
-
readonly metavar?:
|
|
84
|
+
readonly metavar?: NonEmptyString;
|
|
84
85
|
/**
|
|
85
86
|
* Custom error messages for zoned datetime parsing failures.
|
|
86
87
|
* @since 0.5.0
|
|
@@ -104,7 +105,7 @@ interface PlainDateOptions {
|
|
|
104
105
|
* word in uppercase, like `DATE`.
|
|
105
106
|
* @default `"DATE"`
|
|
106
107
|
*/
|
|
107
|
-
readonly metavar?:
|
|
108
|
+
readonly metavar?: NonEmptyString;
|
|
108
109
|
/**
|
|
109
110
|
* Custom error messages for plain date parsing failures.
|
|
110
111
|
* @since 0.5.0
|
|
@@ -128,7 +129,7 @@ interface PlainTimeOptions {
|
|
|
128
129
|
* word in uppercase, like `TIME`.
|
|
129
130
|
* @default `"TIME"`
|
|
130
131
|
*/
|
|
131
|
-
readonly metavar?:
|
|
132
|
+
readonly metavar?: NonEmptyString;
|
|
132
133
|
/**
|
|
133
134
|
* Custom error messages for plain time parsing failures.
|
|
134
135
|
* @since 0.5.0
|
|
@@ -152,7 +153,7 @@ interface PlainDateTimeOptions {
|
|
|
152
153
|
* word in uppercase, like `DATETIME`.
|
|
153
154
|
* @default `"DATETIME"`
|
|
154
155
|
*/
|
|
155
|
-
readonly metavar?:
|
|
156
|
+
readonly metavar?: NonEmptyString;
|
|
156
157
|
/**
|
|
157
158
|
* Custom error messages for plain datetime parsing failures.
|
|
158
159
|
* @since 0.5.0
|
|
@@ -176,7 +177,7 @@ interface PlainYearMonthOptions {
|
|
|
176
177
|
* word in uppercase, like `YEAR-MONTH`.
|
|
177
178
|
* @default `"YEAR-MONTH"`
|
|
178
179
|
*/
|
|
179
|
-
readonly metavar?:
|
|
180
|
+
readonly metavar?: NonEmptyString;
|
|
180
181
|
/**
|
|
181
182
|
* Custom error messages for plain year-month parsing failures.
|
|
182
183
|
* @since 0.5.0
|
|
@@ -200,7 +201,7 @@ interface PlainMonthDayOptions {
|
|
|
200
201
|
* word in uppercase, like `--MONTH-DAY`.
|
|
201
202
|
* @default `"--MONTH-DAY"`
|
|
202
203
|
*/
|
|
203
|
-
readonly metavar?:
|
|
204
|
+
readonly metavar?: NonEmptyString;
|
|
204
205
|
/**
|
|
205
206
|
* Custom error messages for plain month-day parsing failures.
|
|
206
207
|
* @since 0.5.0
|
|
@@ -224,7 +225,7 @@ interface TimeZoneOptions {
|
|
|
224
225
|
* word in uppercase, like `TIMEZONE`.
|
|
225
226
|
* @default `"TIMEZONE"`
|
|
226
227
|
*/
|
|
227
|
-
readonly metavar?:
|
|
228
|
+
readonly metavar?: NonEmptyString;
|
|
228
229
|
/**
|
|
229
230
|
* Custom error messages for timezone parsing failures.
|
|
230
231
|
* @since 0.5.0
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { message } from "@optique/core/message";
|
|
3
|
+
import { ensureNonEmptyString } from "@optique/core/nonempty";
|
|
3
4
|
|
|
4
5
|
//#region src/index.ts
|
|
5
6
|
/**
|
|
@@ -14,8 +15,10 @@ import { message } from "@optique/core/message";
|
|
|
14
15
|
* @returns A ValueParser that parses strings into Temporal.Instant values.
|
|
15
16
|
*/
|
|
16
17
|
function instant(options = {}) {
|
|
18
|
+
const metavar = options.metavar ?? "TIMESTAMP";
|
|
19
|
+
ensureNonEmptyString(metavar);
|
|
17
20
|
return {
|
|
18
|
-
metavar
|
|
21
|
+
metavar,
|
|
19
22
|
parse(input) {
|
|
20
23
|
try {
|
|
21
24
|
const value = Temporal.Instant.from(input);
|
|
@@ -48,8 +51,10 @@ function instant(options = {}) {
|
|
|
48
51
|
* @returns A ValueParser that parses strings into Temporal.Duration values.
|
|
49
52
|
*/
|
|
50
53
|
function duration(options = {}) {
|
|
54
|
+
const metavar = options.metavar ?? "DURATION";
|
|
55
|
+
ensureNonEmptyString(metavar);
|
|
51
56
|
return {
|
|
52
|
-
metavar
|
|
57
|
+
metavar,
|
|
53
58
|
parse(input) {
|
|
54
59
|
try {
|
|
55
60
|
const value = Temporal.Duration.from(input);
|
|
@@ -81,8 +86,10 @@ function duration(options = {}) {
|
|
|
81
86
|
* @returns A ValueParser that parses strings into Temporal.ZonedDateTime values.
|
|
82
87
|
*/
|
|
83
88
|
function zonedDateTime(options = {}) {
|
|
89
|
+
const metavar = options.metavar ?? "ZONED_DATETIME";
|
|
90
|
+
ensureNonEmptyString(metavar);
|
|
84
91
|
return {
|
|
85
|
-
metavar
|
|
92
|
+
metavar,
|
|
86
93
|
parse(input) {
|
|
87
94
|
try {
|
|
88
95
|
const value = Temporal.ZonedDateTime.from(input);
|
|
@@ -114,8 +121,10 @@ function zonedDateTime(options = {}) {
|
|
|
114
121
|
* @returns A ValueParser that parses strings into Temporal.PlainDate values.
|
|
115
122
|
*/
|
|
116
123
|
function plainDate(options = {}) {
|
|
124
|
+
const metavar = options.metavar ?? "DATE";
|
|
125
|
+
ensureNonEmptyString(metavar);
|
|
117
126
|
return {
|
|
118
|
-
metavar
|
|
127
|
+
metavar,
|
|
119
128
|
parse(input) {
|
|
120
129
|
try {
|
|
121
130
|
const value = Temporal.PlainDate.from(input);
|
|
@@ -147,8 +156,10 @@ function plainDate(options = {}) {
|
|
|
147
156
|
* @returns A ValueParser that parses strings into Temporal.PlainTime values.
|
|
148
157
|
*/
|
|
149
158
|
function plainTime(options = {}) {
|
|
159
|
+
const metavar = options.metavar ?? "TIME";
|
|
160
|
+
ensureNonEmptyString(metavar);
|
|
150
161
|
return {
|
|
151
|
-
metavar
|
|
162
|
+
metavar,
|
|
152
163
|
parse(input) {
|
|
153
164
|
try {
|
|
154
165
|
const value = Temporal.PlainTime.from(input);
|
|
@@ -180,8 +191,10 @@ function plainTime(options = {}) {
|
|
|
180
191
|
* @returns A ValueParser that parses strings into Temporal.PlainDateTime values.
|
|
181
192
|
*/
|
|
182
193
|
function plainDateTime(options = {}) {
|
|
194
|
+
const metavar = options.metavar ?? "DATETIME";
|
|
195
|
+
ensureNonEmptyString(metavar);
|
|
183
196
|
return {
|
|
184
|
-
metavar
|
|
197
|
+
metavar,
|
|
185
198
|
parse(input) {
|
|
186
199
|
try {
|
|
187
200
|
const value = Temporal.PlainDateTime.from(input);
|
|
@@ -213,8 +226,10 @@ function plainDateTime(options = {}) {
|
|
|
213
226
|
* @returns A ValueParser that parses strings into Temporal.PlainYearMonth values.
|
|
214
227
|
*/
|
|
215
228
|
function plainYearMonth(options = {}) {
|
|
229
|
+
const metavar = options.metavar ?? "YEAR-MONTH";
|
|
230
|
+
ensureNonEmptyString(metavar);
|
|
216
231
|
return {
|
|
217
|
-
metavar
|
|
232
|
+
metavar,
|
|
218
233
|
parse(input) {
|
|
219
234
|
try {
|
|
220
235
|
const value = Temporal.PlainYearMonth.from(input);
|
|
@@ -246,8 +261,10 @@ function plainYearMonth(options = {}) {
|
|
|
246
261
|
* @returns A ValueParser that parses strings into Temporal.PlainMonthDay values.
|
|
247
262
|
*/
|
|
248
263
|
function plainMonthDay(options = {}) {
|
|
264
|
+
const metavar = options.metavar ?? "--MONTH-DAY";
|
|
265
|
+
ensureNonEmptyString(metavar);
|
|
249
266
|
return {
|
|
250
|
-
metavar
|
|
267
|
+
metavar,
|
|
251
268
|
parse(input) {
|
|
252
269
|
try {
|
|
253
270
|
const value = Temporal.PlainMonthDay.from(input);
|
|
@@ -281,8 +298,10 @@ function plainMonthDay(options = {}) {
|
|
|
281
298
|
* @returns A ValueParser that parses and validates timezone identifiers.
|
|
282
299
|
*/
|
|
283
300
|
function timeZone(options = {}) {
|
|
301
|
+
const metavar = options.metavar ?? "TIMEZONE";
|
|
302
|
+
ensureNonEmptyString(metavar);
|
|
284
303
|
return {
|
|
285
|
-
metavar
|
|
304
|
+
metavar,
|
|
286
305
|
parse(input) {
|
|
287
306
|
try {
|
|
288
307
|
Temporal.ZonedDateTime.from({
|