@atscript/typescript 0.1.12 → 0.1.14

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.cjs CHANGED
@@ -750,6 +750,14 @@ else {
750
750
  }
751
751
  }
752
752
  validateString(def, value) {
753
+ const filled = def.metadata.get("expect.filled");
754
+ if (filled) {
755
+ if (value.trim().length === 0) {
756
+ const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
757
+ this.error(message);
758
+ return false;
759
+ }
760
+ }
753
761
  const minLength = def.metadata.get("expect.minLength");
754
762
  if (minLength) {
755
763
  const length = typeof minLength === "number" ? minLength : minLength.length;
@@ -938,6 +946,7 @@ else throw new Error(`Can't find prop ${typeName}${keys}`);
938
946
  }
939
947
  if (!newBase && keys) throw new Error(`Can't find prop ${typeName}${keys}`);
940
948
  else if (!newBase) throw new Error(`"${typeName}" is not annotated type`);
949
+ for (const [k, v] of newBase.metadata.entries()) if (!metadata.has(k)) metadata.set(k, Array.isArray(v) ? [...v] : v);
941
950
  this.$type = {
942
951
  __is_atscript_annotated_type: true,
943
952
  type: newBase.type,
@@ -1016,6 +1025,7 @@ function buildJsonSchema(type) {
1016
1025
  if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
1017
1026
  }
1018
1027
  if (schema.type === "string") {
1028
+ if (meta.get("expect.filled")) schema.minLength = 1;
1019
1029
  const minLength = meta.get("expect.minLength");
1020
1030
  if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
1021
1031
  const maxLength = meta.get("expect.maxLength");
package/dist/index.cjs CHANGED
@@ -747,6 +747,14 @@ else {
747
747
  }
748
748
  }
749
749
  validateString(def, value) {
750
+ const filled = def.metadata.get("expect.filled");
751
+ if (filled) {
752
+ if (value.trim().length === 0) {
753
+ const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
754
+ this.error(message);
755
+ return false;
756
+ }
757
+ }
750
758
  const minLength = def.metadata.get("expect.minLength");
751
759
  if (minLength) {
752
760
  const length = typeof minLength === "number" ? minLength : minLength.length;
@@ -935,6 +943,7 @@ else throw new Error(`Can't find prop ${typeName}${keys}`);
935
943
  }
936
944
  if (!newBase && keys) throw new Error(`Can't find prop ${typeName}${keys}`);
937
945
  else if (!newBase) throw new Error(`"${typeName}" is not annotated type`);
946
+ for (const [k, v] of newBase.metadata.entries()) if (!metadata.has(k)) metadata.set(k, Array.isArray(v) ? [...v] : v);
938
947
  this.$type = {
939
948
  __is_atscript_annotated_type: true,
940
949
  type: newBase.type,
@@ -1013,6 +1022,7 @@ function buildJsonSchema(type) {
1013
1022
  if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
1014
1023
  }
1015
1024
  if (schema.type === "string") {
1025
+ if (meta.get("expect.filled")) schema.minLength = 1;
1016
1026
  const minLength = meta.get("expect.minLength");
1017
1027
  if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
1018
1028
  const maxLength = meta.get("expect.maxLength");
package/dist/index.mjs CHANGED
@@ -723,6 +723,14 @@ else {
723
723
  }
724
724
  }
725
725
  validateString(def, value) {
726
+ const filled = def.metadata.get("expect.filled");
727
+ if (filled) {
728
+ if (value.trim().length === 0) {
729
+ const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
730
+ this.error(message);
731
+ return false;
732
+ }
733
+ }
726
734
  const minLength = def.metadata.get("expect.minLength");
727
735
  if (minLength) {
728
736
  const length = typeof minLength === "number" ? minLength : minLength.length;
@@ -911,6 +919,7 @@ else throw new Error(`Can't find prop ${typeName}${keys}`);
911
919
  }
912
920
  if (!newBase && keys) throw new Error(`Can't find prop ${typeName}${keys}`);
913
921
  else if (!newBase) throw new Error(`"${typeName}" is not annotated type`);
922
+ for (const [k, v] of newBase.metadata.entries()) if (!metadata.has(k)) metadata.set(k, Array.isArray(v) ? [...v] : v);
914
923
  this.$type = {
915
924
  __is_atscript_annotated_type: true,
916
925
  type: newBase.type,
@@ -989,6 +998,7 @@ function buildJsonSchema(type) {
989
998
  if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
990
999
  }
991
1000
  if (schema.type === "string") {
1001
+ if (meta.get("expect.filled")) schema.minLength = 1;
992
1002
  const minLength = meta.get("expect.minLength");
993
1003
  if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
994
1004
  const maxLength = meta.get("expect.maxLength");
package/dist/utils.cjs CHANGED
@@ -302,6 +302,14 @@ else {
302
302
  }
303
303
  }
304
304
  validateString(def, value) {
305
+ const filled = def.metadata.get("expect.filled");
306
+ if (filled) {
307
+ if (value.trim().length === 0) {
308
+ const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
309
+ this.error(message);
310
+ return false;
311
+ }
312
+ }
305
313
  const minLength = def.metadata.get("expect.minLength");
306
314
  if (minLength) {
307
315
  const length = typeof minLength === "number" ? minLength : minLength.length;
@@ -490,6 +498,7 @@ else throw new Error(`Can't find prop ${typeName}${keys}`);
490
498
  }
491
499
  if (!newBase && keys) throw new Error(`Can't find prop ${typeName}${keys}`);
492
500
  else if (!newBase) throw new Error(`"${typeName}" is not annotated type`);
501
+ for (const [k, v] of newBase.metadata.entries()) if (!metadata.has(k)) metadata.set(k, Array.isArray(v) ? [...v] : v);
493
502
  this.$type = {
494
503
  __is_atscript_annotated_type: true,
495
504
  type: newBase.type,
@@ -581,6 +590,7 @@ function buildJsonSchema(type) {
581
590
  if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
582
591
  }
583
592
  if (schema.type === "string") {
593
+ if (meta.get("expect.filled")) schema.minLength = 1;
584
594
  const minLength = meta.get("expect.minLength");
585
595
  if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
586
596
  const maxLength = meta.get("expect.maxLength");
package/dist/utils.mjs CHANGED
@@ -301,6 +301,14 @@ else {
301
301
  }
302
302
  }
303
303
  validateString(def, value) {
304
+ const filled = def.metadata.get("expect.filled");
305
+ if (filled) {
306
+ if (value.trim().length === 0) {
307
+ const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
308
+ this.error(message);
309
+ return false;
310
+ }
311
+ }
304
312
  const minLength = def.metadata.get("expect.minLength");
305
313
  if (minLength) {
306
314
  const length = typeof minLength === "number" ? minLength : minLength.length;
@@ -489,6 +497,7 @@ else throw new Error(`Can't find prop ${typeName}${keys}`);
489
497
  }
490
498
  if (!newBase && keys) throw new Error(`Can't find prop ${typeName}${keys}`);
491
499
  else if (!newBase) throw new Error(`"${typeName}" is not annotated type`);
500
+ for (const [k, v] of newBase.metadata.entries()) if (!metadata.has(k)) metadata.set(k, Array.isArray(v) ? [...v] : v);
492
501
  this.$type = {
493
502
  __is_atscript_annotated_type: true,
494
503
  type: newBase.type,
@@ -580,6 +589,7 @@ function buildJsonSchema(type) {
580
589
  if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
581
590
  }
582
591
  if (schema.type === "string") {
592
+ if (meta.get("expect.filled")) schema.minLength = 1;
583
593
  const minLength = meta.get("expect.minLength");
584
594
  if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
585
595
  const maxLength = meta.get("expect.maxLength");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/typescript",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Atscript: typescript-gen support.",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -70,7 +70,7 @@
70
70
  "homepage": "https://github.com/moostjs/atscript/tree/main/packages/typescript#readme",
71
71
  "license": "ISC",
72
72
  "peerDependencies": {
73
- "@atscript/core": "^0.1.12"
73
+ "@atscript/core": "^0.1.14"
74
74
  },
75
75
  "dependencies": {
76
76
  "@moostjs/event-cli": "^0.5.32",