sasat 0.20.4 → 0.20.5

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/cli/cli.cjs CHANGED
@@ -2881,6 +2881,36 @@ const toTsType = (type) => {
2881
2881
  };
2882
2882
 
2883
2883
  const qExpr$3 = tsg.identifier("qe").importFrom("sasat");
2884
+ const makeConditionValueRaw = (cv) => {
2885
+ const arg = tsg.identifier("arg");
2886
+ const context = arg.property("context?");
2887
+ switch (cv.kind) {
2888
+ case "context": {
2889
+ const value = context.property(cv.field);
2890
+ if (cv.onNotDefined.action !== "defaultValue") {
2891
+ return value;
2892
+ }
2893
+ return tsg.binary(
2894
+ context.property(cv.field),
2895
+ "||",
2896
+ typeof cv.onNotDefined.value === "string" ? tsg.string(cv.onNotDefined.value) : tsg.number(cv.onNotDefined.value)
2897
+ );
2898
+ }
2899
+ case "fixed": {
2900
+ return typeof cv.value === "string" ? tsg.string(cv.value) : tsg.number(cv.value);
2901
+ }
2902
+ case "today": {
2903
+ return tsg.identifier(
2904
+ cv.type === "datetime" ? "getTodayDateTimeString" : "getTodayDateString"
2905
+ ).importFrom("sasat").call();
2906
+ }
2907
+ case "now": {
2908
+ return tsg.identifier("dateString").importFrom("sasat").call(tsg.new(tsg.identifier("Date")));
2909
+ }
2910
+ default:
2911
+ throw Error(`not implemented: makeConditionValue.${cv.kind}`);
2912
+ }
2913
+ };
2884
2914
  const makeConditionValueQExpr = (cv) => {
2885
2915
  const arg = tsg.identifier("arg");
2886
2916
  const context = arg.property("context?");
@@ -3546,9 +3576,7 @@ const makeConditionExpr = (entity, condition) => {
3546
3576
  if (condition.operator === "IN") {
3547
3577
  return qExpr.property("in").call(
3548
3578
  makeJoinConditionValueQExpr(entity, condition.left),
3549
- tsg.array(
3550
- condition.right.map((it) => makeJoinConditionValueQExpr(entity, it))
3551
- )
3579
+ tsg.array(condition.right.map((it) => makeConditionValueRaw(it)))
3552
3580
  );
3553
3581
  }
3554
3582
  return qExpr.property("comparison").call(
package/dist/cli/cli.mjs CHANGED
@@ -2857,6 +2857,36 @@ const toTsType = (type) => {
2857
2857
  };
2858
2858
 
2859
2859
  const qExpr$3 = tsg.identifier("qe").importFrom("sasat");
2860
+ const makeConditionValueRaw = (cv) => {
2861
+ const arg = tsg.identifier("arg");
2862
+ const context = arg.property("context?");
2863
+ switch (cv.kind) {
2864
+ case "context": {
2865
+ const value = context.property(cv.field);
2866
+ if (cv.onNotDefined.action !== "defaultValue") {
2867
+ return value;
2868
+ }
2869
+ return tsg.binary(
2870
+ context.property(cv.field),
2871
+ "||",
2872
+ typeof cv.onNotDefined.value === "string" ? tsg.string(cv.onNotDefined.value) : tsg.number(cv.onNotDefined.value)
2873
+ );
2874
+ }
2875
+ case "fixed": {
2876
+ return typeof cv.value === "string" ? tsg.string(cv.value) : tsg.number(cv.value);
2877
+ }
2878
+ case "today": {
2879
+ return tsg.identifier(
2880
+ cv.type === "datetime" ? "getTodayDateTimeString" : "getTodayDateString"
2881
+ ).importFrom("sasat").call();
2882
+ }
2883
+ case "now": {
2884
+ return tsg.identifier("dateString").importFrom("sasat").call(tsg.new(tsg.identifier("Date")));
2885
+ }
2886
+ default:
2887
+ throw Error(`not implemented: makeConditionValue.${cv.kind}`);
2888
+ }
2889
+ };
2860
2890
  const makeConditionValueQExpr = (cv) => {
2861
2891
  const arg = tsg.identifier("arg");
2862
2892
  const context = arg.property("context?");
@@ -3522,9 +3552,7 @@ const makeConditionExpr = (entity, condition) => {
3522
3552
  if (condition.operator === "IN") {
3523
3553
  return qExpr.property("in").call(
3524
3554
  makeJoinConditionValueQExpr(entity, condition.left),
3525
- tsg.array(
3526
- condition.right.map((it) => makeJoinConditionValueQExpr(entity, it))
3527
- )
3555
+ tsg.array(condition.right.map((it) => makeConditionValueRaw(it)))
3528
3556
  );
3529
3557
  }
3530
3558
  return qExpr.property("comparison").call(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sasat",
3
- "version": "0.20.4",
3
+ "version": "0.20.5",
4
4
  "repository": "https://github.com/nin138/sasat.git",
5
5
  "author": "nin138 <ninian138@gmail.com>",
6
6
  "license": "MIT",