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