@rkmodules/rules 0.0.123 → 0.0.124
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.js +169 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +169 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/Primitives/Date/duration.d.ts +2 -0
- package/dist/lib/Primitives/Date/formatDate.d.ts +2 -0
- package/dist/lib/Primitives/Date/index.d.ts +3 -0
- package/dist/lib/Primitives/Date/isoDate.d.ts +2 -0
- package/dist/lib/Primitives/Date/parseDate.d.ts +2 -0
- package/dist/lib/Primitives/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2431,6 +2431,173 @@ var primitives$1 = (_a$1 = {},
|
|
|
2431
2431
|
_a$1[explodeObject.name] = explodeObject,
|
|
2432
2432
|
_a$1);
|
|
2433
2433
|
|
|
2434
|
+
var INFERRED = "inferred";
|
|
2435
|
+
var ary$1 = __spreadArray([INFERRED], __read(Intl.supportedValuesOf("timeZone")), false);
|
|
2436
|
+
var parseDate = {
|
|
2437
|
+
name: "parseDate",
|
|
2438
|
+
label: "Parse",
|
|
2439
|
+
description: "Parses a date string",
|
|
2440
|
+
inputs: {
|
|
2441
|
+
datestring: { type: "string", default: "" },
|
|
2442
|
+
},
|
|
2443
|
+
params: {
|
|
2444
|
+
timezone: {
|
|
2445
|
+
type: "choice",
|
|
2446
|
+
default: INFERRED,
|
|
2447
|
+
options: ary$1,
|
|
2448
|
+
},
|
|
2449
|
+
},
|
|
2450
|
+
outputs: {
|
|
2451
|
+
date: "Date",
|
|
2452
|
+
},
|
|
2453
|
+
impl: function (inputs, params, engine) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2454
|
+
return __generator(this, function (_a) {
|
|
2455
|
+
return [2 /*return*/, {
|
|
2456
|
+
date: mapTree(inputs.datestring || {}, function (dateStr) {
|
|
2457
|
+
var parsedDate = new Date(dateStr);
|
|
2458
|
+
if (params.timezone !== INFERRED) {
|
|
2459
|
+
parsedDate = new Date(parsedDate.toLocaleString("en-US", {
|
|
2460
|
+
timeZone: params.timezone,
|
|
2461
|
+
}));
|
|
2462
|
+
}
|
|
2463
|
+
var stamp = parsedDate.getTime();
|
|
2464
|
+
return isNaN(stamp) ? null : stamp;
|
|
2465
|
+
}),
|
|
2466
|
+
}];
|
|
2467
|
+
});
|
|
2468
|
+
}); },
|
|
2469
|
+
};
|
|
2470
|
+
|
|
2471
|
+
var ary = Intl.supportedValuesOf("timeZone");
|
|
2472
|
+
var formatDate = {
|
|
2473
|
+
name: "formatDate",
|
|
2474
|
+
label: "Format",
|
|
2475
|
+
description: "Formats a date",
|
|
2476
|
+
inputs: {
|
|
2477
|
+
date: { type: "Date", default: "" },
|
|
2478
|
+
},
|
|
2479
|
+
params: {
|
|
2480
|
+
locale: { type: "string", default: "en-US", label: "locale" },
|
|
2481
|
+
dateStyle: {
|
|
2482
|
+
type: "string",
|
|
2483
|
+
options: ["full", "long", "medium", "short", "none"],
|
|
2484
|
+
default: "medium",
|
|
2485
|
+
label: "date style",
|
|
2486
|
+
},
|
|
2487
|
+
timeStyle: {
|
|
2488
|
+
type: "string",
|
|
2489
|
+
options: ["full", "long", "medium", "short", "none"],
|
|
2490
|
+
default: "short",
|
|
2491
|
+
label: "time style",
|
|
2492
|
+
},
|
|
2493
|
+
timezone: {
|
|
2494
|
+
type: "choice",
|
|
2495
|
+
default: function () {
|
|
2496
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
2497
|
+
},
|
|
2498
|
+
options: ary,
|
|
2499
|
+
},
|
|
2500
|
+
hour12: {
|
|
2501
|
+
type: "boolean",
|
|
2502
|
+
default: false,
|
|
2503
|
+
label: "12 hour time",
|
|
2504
|
+
},
|
|
2505
|
+
},
|
|
2506
|
+
outputs: {
|
|
2507
|
+
string: "string",
|
|
2508
|
+
},
|
|
2509
|
+
impl: function (inputs, params, engine) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2510
|
+
return __generator(this, function (_a) {
|
|
2511
|
+
return [2 /*return*/, {
|
|
2512
|
+
string: mapTree(inputs.date || {}, function (dateInput) {
|
|
2513
|
+
var parsedDate = new Date(dateInput);
|
|
2514
|
+
if (isNaN(parsedDate.getTime())) {
|
|
2515
|
+
return "invalid date";
|
|
2516
|
+
}
|
|
2517
|
+
var dateStyle = params.dateStyle === "none" ? undefined : params.dateStyle;
|
|
2518
|
+
var timeStyle = params.timeStyle === "none" ? undefined : params.timeStyle;
|
|
2519
|
+
var str = new Intl.DateTimeFormat(params.locale, {
|
|
2520
|
+
dateStyle: dateStyle,
|
|
2521
|
+
timeStyle: timeStyle,
|
|
2522
|
+
hour12: params.hour12,
|
|
2523
|
+
timeZone: params.timezone,
|
|
2524
|
+
}).format(parsedDate);
|
|
2525
|
+
return str;
|
|
2526
|
+
}),
|
|
2527
|
+
}];
|
|
2528
|
+
});
|
|
2529
|
+
}); },
|
|
2530
|
+
};
|
|
2531
|
+
|
|
2532
|
+
var duration = {
|
|
2533
|
+
name: "duration",
|
|
2534
|
+
label: "Duration",
|
|
2535
|
+
description: "Creates a duration",
|
|
2536
|
+
inputs: {
|
|
2537
|
+
days: { type: "number", default: 0 },
|
|
2538
|
+
hours: { type: "number", default: 0 },
|
|
2539
|
+
minutes: { type: "number", default: 0 },
|
|
2540
|
+
seconds: { type: "number", default: 0 },
|
|
2541
|
+
milliseconds: { type: "number", default: 0 },
|
|
2542
|
+
},
|
|
2543
|
+
outputs: {
|
|
2544
|
+
duration: "number",
|
|
2545
|
+
},
|
|
2546
|
+
impl: function (inputs, params, engine) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2547
|
+
return __generator(this, function (_a) {
|
|
2548
|
+
return [2 /*return*/, {
|
|
2549
|
+
duration: nAryOnTree([
|
|
2550
|
+
inputs.days || {},
|
|
2551
|
+
inputs.hours || {},
|
|
2552
|
+
inputs.minutes || {},
|
|
2553
|
+
inputs.seconds || {},
|
|
2554
|
+
inputs.milliseconds || {},
|
|
2555
|
+
], function (_a) {
|
|
2556
|
+
var _b = __read(_a, 5), _c = _b[0], days = _c === void 0 ? 0 : _c, _d = _b[1], hours = _d === void 0 ? 0 : _d, _e = _b[2], minutes = _e === void 0 ? 0 : _e, _f = _b[3], seconds = _f === void 0 ? 0 : _f, _g = _b[4], milliseconds = _g === void 0 ? 0 : _g;
|
|
2557
|
+
var totalMilliseconds = days * 24 * 60 * 60 * 1000 +
|
|
2558
|
+
hours * 60 * 60 * 1000 +
|
|
2559
|
+
minutes * 60 * 1000 +
|
|
2560
|
+
seconds * 1000 +
|
|
2561
|
+
milliseconds;
|
|
2562
|
+
return totalMilliseconds;
|
|
2563
|
+
}, true),
|
|
2564
|
+
}];
|
|
2565
|
+
});
|
|
2566
|
+
}); },
|
|
2567
|
+
};
|
|
2568
|
+
|
|
2569
|
+
var isoDate = {
|
|
2570
|
+
name: "isoDate",
|
|
2571
|
+
label: "To ISO",
|
|
2572
|
+
description: "ISO 8601 format of a date",
|
|
2573
|
+
inputs: {
|
|
2574
|
+
date: { type: "Date", default: "" },
|
|
2575
|
+
},
|
|
2576
|
+
outputs: {
|
|
2577
|
+
string: "string",
|
|
2578
|
+
},
|
|
2579
|
+
impl: function (inputs, params, engine) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2580
|
+
return __generator(this, function (_a) {
|
|
2581
|
+
return [2 /*return*/, {
|
|
2582
|
+
string: mapTree(inputs.date || {}, function (dateInput) {
|
|
2583
|
+
var parsedDate = new Date(dateInput);
|
|
2584
|
+
if (isNaN(parsedDate.getTime())) {
|
|
2585
|
+
return "invalid date";
|
|
2586
|
+
}
|
|
2587
|
+
return parsedDate.toISOString();
|
|
2588
|
+
}),
|
|
2589
|
+
}];
|
|
2590
|
+
});
|
|
2591
|
+
}); },
|
|
2592
|
+
};
|
|
2593
|
+
|
|
2594
|
+
var functions = {
|
|
2595
|
+
parseDate: parseDate,
|
|
2596
|
+
formatDate: formatDate,
|
|
2597
|
+
isoDate: isoDate,
|
|
2598
|
+
duration: duration,
|
|
2599
|
+
};
|
|
2600
|
+
|
|
2434
2601
|
var Lib = {
|
|
2435
2602
|
Util: primitives$9,
|
|
2436
2603
|
Math: primitives$8,
|
|
@@ -2441,8 +2608,9 @@ var Lib = {
|
|
|
2441
2608
|
Logic: primitives$3,
|
|
2442
2609
|
IO: primitives$2,
|
|
2443
2610
|
Json: primitives$1,
|
|
2611
|
+
Date: functions,
|
|
2444
2612
|
};
|
|
2445
|
-
var primitives = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, primitives$2), primitives$9), primitives$8), primitives$7), primitives$6), primitives$5), primitives$4), primitives$3), primitives$1);
|
|
2613
|
+
var primitives = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, primitives$2), primitives$9), primitives$8), primitives$7), primitives$6), primitives$5), primitives$4), primitives$3), primitives$1), functions);
|
|
2446
2614
|
|
|
2447
2615
|
function isPrimitive(node) {
|
|
2448
2616
|
return node.impl !== undefined;
|