xdbc 1.0.217 → 1.0.219

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.
Files changed (120) hide show
  1. package/.gitattributes +16 -8
  2. package/.vscode/settings.json +3 -3
  3. package/.vscode/tasks.json +23 -23
  4. package/ASSESSMENT.md +249 -0
  5. package/README.md +538 -408
  6. package/__tests__/DBC/AE.test.ts +62 -62
  7. package/__tests__/DBC/ARRAY.test.ts +91 -91
  8. package/__tests__/DBC/DEFINED.test.ts +53 -53
  9. package/__tests__/DBC/DOM.test.ts +786 -0
  10. package/__tests__/DBC/Decorators.test.ts +367 -367
  11. package/__tests__/DBC/EQ.test.ts +13 -13
  12. package/__tests__/DBC/GREATER.test.ts +31 -31
  13. package/__tests__/DBC/HasAttribute.test.ts +60 -60
  14. package/__tests__/DBC/IF.test.ts +62 -62
  15. package/__tests__/DBC/INSTANCE.test.ts +13 -13
  16. package/__tests__/DBC/JSON.OP.test.ts +47 -47
  17. package/__tests__/DBC/JSON.Parse.test.ts +17 -17
  18. package/__tests__/DBC/OR.test.ts +14 -14
  19. package/__tests__/DBC/PLAIN_OBJECT.test.ts +109 -109
  20. package/__tests__/DBC/REGEX.test.ts +17 -17
  21. package/__tests__/DBC/TYPE.test.ts +13 -13
  22. package/__tests__/DBC/UNDEFINED.test.ts +45 -45
  23. package/__tests__/DBC/ZOD.test.ts +54 -54
  24. package/__tests__/DBC/onInfringement.test.ts +262 -0
  25. package/biome.json +45 -40
  26. package/dist/DBC/AE.js +172 -0
  27. package/dist/DBC/ARR/PLAIN_OBJECT.d.ts +0 -3
  28. package/dist/DBC/ARR/PLAIN_OBJECT.js +95 -0
  29. package/dist/DBC/ARRAY.d.ts +0 -3
  30. package/dist/DBC/ARRAY.js +90 -0
  31. package/dist/DBC/COMPARISON/GREATER.js +21 -0
  32. package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +21 -0
  33. package/dist/DBC/COMPARISON/LESS.js +21 -0
  34. package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +21 -0
  35. package/dist/DBC/COMPARISON.js +98 -0
  36. package/dist/DBC/DEFINED.js +87 -0
  37. package/dist/DBC/DOM.d.ts +123 -0
  38. package/dist/DBC/DOM.js +362 -0
  39. package/dist/DBC/EQ/DIFFERENT.js +34 -0
  40. package/dist/DBC/EQ.js +101 -0
  41. package/dist/DBC/GREATER.js +99 -0
  42. package/dist/DBC/HasAttribute.js +101 -0
  43. package/dist/DBC/IF.js +96 -0
  44. package/dist/DBC/INSTANCE.js +122 -0
  45. package/dist/DBC/JSON.OP.js +120 -0
  46. package/dist/DBC/JSON.Parse.js +104 -0
  47. package/dist/DBC/OR.js +125 -0
  48. package/dist/DBC/REGEX.js +136 -0
  49. package/dist/DBC/TYPE.js +112 -0
  50. package/dist/DBC/UNDEFINED.js +87 -0
  51. package/dist/DBC/ZOD.js +99 -0
  52. package/dist/DBC.d.ts +18 -4
  53. package/dist/DBC.js +645 -0
  54. package/dist/Demo.d.ts +10 -0
  55. package/dist/Demo.js +713 -0
  56. package/dist/Test.html +18 -0
  57. package/dist/bundle.js +6140 -405
  58. package/dist/index.d.ts +22 -0
  59. package/dist/index.html +18 -0
  60. package/dist/index.js +22 -0
  61. package/docs/assets/highlight.css +22 -22
  62. package/docs/assets/icons.js +17 -17
  63. package/docs/assets/main.js +60 -60
  64. package/docs/assets/style.css +1640 -1640
  65. package/docs/classes/DBC.DBC.html +98 -98
  66. package/docs/classes/DBC_AE.AE.html +160 -160
  67. package/docs/classes/DBC_EQ.EQ.html +131 -131
  68. package/docs/classes/DBC_GREATER.GREATER.html +139 -139
  69. package/docs/classes/DBC_INSTANCE.INSTANCE.html +130 -130
  70. package/docs/classes/DBC_JSON.OP.JSON_OP.html +138 -138
  71. package/docs/classes/DBC_JSON.Parse.JSON_Parse.html +129 -129
  72. package/docs/classes/DBC_OR.OR.html +137 -137
  73. package/docs/classes/DBC_REGEX.REGEX.html +136 -136
  74. package/docs/classes/DBC_TYPE.TYPE.html +130 -130
  75. package/docs/classes/Demo.Demo.html +14 -14
  76. package/docs/hierarchy.html +1 -1
  77. package/docs/index.html +1 -1
  78. package/docs/modules/DBC.html +1 -1
  79. package/docs/modules/DBC_AE.html +1 -1
  80. package/docs/modules/DBC_EQ.html +1 -1
  81. package/docs/modules/DBC_GREATER.html +1 -1
  82. package/docs/modules/DBC_INSTANCE.html +1 -1
  83. package/docs/modules/DBC_JSON.OP.html +1 -1
  84. package/docs/modules/DBC_JSON.Parse.html +1 -1
  85. package/docs/modules/DBC_OR.html +1 -1
  86. package/docs/modules/DBC_REGEX.html +1 -1
  87. package/docs/modules/DBC_TYPE.html +1 -1
  88. package/docs/modules/Demo.html +1 -1
  89. package/jest.config.js +32 -32
  90. package/package.json +71 -55
  91. package/src/DBC/AE.ts +269 -288
  92. package/src/DBC/ARR/PLAIN_OBJECT.ts +122 -133
  93. package/src/DBC/ARRAY.ts +117 -127
  94. package/src/DBC/COMPARISON/GREATER.ts +41 -46
  95. package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +41 -45
  96. package/src/DBC/COMPARISON/LESS.ts +41 -45
  97. package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +41 -45
  98. package/src/DBC/COMPARISON.ts +149 -159
  99. package/src/DBC/DEFINED.ts +117 -122
  100. package/src/DBC/DOM.ts +453 -0
  101. package/src/DBC/EQ/DIFFERENT.ts +51 -57
  102. package/src/DBC/EQ.ts +154 -163
  103. package/src/DBC/HasAttribute.ts +149 -154
  104. package/src/DBC/IF.ts +173 -179
  105. package/src/DBC/INSTANCE.ts +168 -171
  106. package/src/DBC/JSON.OP.ts +178 -186
  107. package/src/DBC/JSON.Parse.ts +150 -157
  108. package/src/DBC/OR.ts +183 -187
  109. package/src/DBC/REGEX.ts +195 -196
  110. package/src/DBC/TYPE.ts +142 -149
  111. package/src/DBC/UNDEFINED.ts +115 -117
  112. package/src/DBC/ZOD.ts +130 -135
  113. package/src/DBC.ts +902 -904
  114. package/src/Demo.ts +537 -404
  115. package/src/index.ts +22 -0
  116. package/tsconfig.json +18 -18
  117. package/tsconfig.test.json +7 -7
  118. package/typedoc.json +16 -16
  119. package/webpack.config.js +27 -27
  120. package/Assessment.md +0 -507
@@ -1,157 +1,150 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } demanding that a {@link string } is {@link JSON.parse}able.
4
- *
5
- * @remarks
6
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
- export class JSON_Parse extends DBC {
8
- // #region Condition checking.
9
- /**
10
- * Tries to {@link JSON.parse } the {@link string } **toCheck** invoking the **receptor** with the result, if so.
11
- *
12
- * @param toCheck The {@link string } to be {@link JSON.parse }d.
13
- * @param receptor The **( json : object ) => void** to receive the {@link JSON.parse }d {@link string } **toCheck**.
14
- * check needs to have.
15
- *
16
- * @returns TRUE if the value **toCheck** is a valid JSON, otherwise a {@link string } to report the infringement. */
17
- public static checkAlgorithm(
18
- toCheck: string,
19
- receptor: (json: object) => void,
20
- ): boolean | string {
21
- // biome-ignore lint/suspicious/noExplicitAny: JSON.parse returns any.
22
- let parsed: any;
23
-
24
- try {
25
- parsed = JSON.parse(toCheck);
26
- } catch (X: unknown) {
27
- return `[ Following string is not a valid JSON: ${toCheck}]`;
28
- }
29
-
30
- if (receptor) {
31
- receptor(parsed);
32
- }
33
-
34
- return true;
35
- }
36
- /**
37
- * A parameter-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
38
- * by the tagged parameter.
39
- *
40
- * @param receptor See {@link JSON.checkAlgorithm }.
41
- * @param path See {@link DBC.decPrecondition }.
42
- * @param dbc See {@link DBC.decPrecondition }.
43
- *
44
- * @returns See {@link DBC.decPrecondition }. */
45
- public static PRE(
46
- receptor: (json: object) => void,
47
- path: string | undefined = undefined,
48
- hint: string | undefined = undefined,
49
- dbc: string | undefined = undefined,
50
- ): (
51
- target: object,
52
- methodName: string | symbol | undefined,
53
- parameterIndex: number,
54
- ) => void {
55
- return DBC.createPRE(
56
- JSON_Parse.checkAlgorithm,
57
- [receptor],
58
- dbc,
59
- path,
60
- hint,
61
- );
62
- }
63
- /**
64
- * A method-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
65
- * by the tagged method's returnvalue.
66
- *
67
- * @param expression See {@link JSON.checkAlgorithm }.
68
- * @param path See {@link DBC.Postcondition }.
69
- * @param dbc See {@link DBC.decPostcondition }.
70
- *
71
- * @returns See {@link DBC.decPostcondition }. */
72
- public static POST(
73
- receptor: (json: object) => void,
74
- path: string | undefined = undefined,
75
- hint: string | undefined = undefined,
76
- dbc: string | undefined = undefined,
77
- ): (
78
- target: object,
79
- propertyKey: string,
80
- descriptor: PropertyDescriptor,
81
- ) => PropertyDescriptor {
82
- return DBC.createPOST(
83
- JSON_Parse.checkAlgorithm,
84
- [receptor],
85
- dbc,
86
- path,
87
- hint,
88
- );
89
- }
90
- /**
91
- * A field-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
92
- * by the tagged field.
93
- *
94
- * @param expression See {@link JSON.checkAlgorithm }.
95
- * @param path See {@link DBC.decInvariant }.
96
- * @param dbc See {@link DBC.decInvariant }.
97
- *
98
- * @returns See {@link DBC.decInvariant }. */
99
- public static INVARIANT(
100
- receptor: (json: object) => void,
101
- path: string | undefined = undefined,
102
- hint: string | undefined = undefined,
103
- dbc: string | undefined = undefined,
104
- ) {
105
- return DBC.createINVARIANT(JSON_Parse, [receptor], dbc, path, hint);
106
- }
107
- // #endregion Condition checking.
108
- // #region Referenced Condition checking.
109
- //
110
- // For usage in dynamic scenarios (like with AE-DBC).
111
- //
112
- /**
113
- * Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck** and {@link JSON_Parse.receptor }.
114
- *
115
- * @param toCheck See {@link JSON_Parse.checkAlgorithm }.
116
- *
117
- * @returns See {@link JSON_Parse.checkAlgorithm}. */
118
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
119
- public check(toCheck: any) {
120
- return JSON_Parse.checkAlgorithm(
121
- toCheck,
122
- this.receptor as (json: object) => void,
123
- );
124
- }
125
- /**
126
- * Creates this {@link JSON_Parse } by setting the protected property {@link JSON_Parse.necessaryProperties } and {@link checkElements } used by {@link JSON_Parse.check }.
127
- *
128
- * @param necessaryProperties See {@link JSON_Parse.check }.
129
- * @param checkElements See {@link JSON_Parse.check }. */
130
- public constructor(
131
- public receptor: ((json: object) => void) | undefined = undefined,
132
- ) {
133
- super();
134
- }
135
- // #endregion Referenced Condition checking.
136
- // #region In-Method checking.
137
- /**
138
- * Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck**, {@link JSON_Parse.necessaryProperties } and {@link JSON_Parse.checkElements }.
139
- *
140
- * @param toCheck See {@link JSON_Parse.checkAlgorithm} }.
141
- * @param necessaryProperties See {@link JSON_Parse.checkAlgorithm} }.
142
- * @param checkElements See {@link JSON_Parse.checkAlgorithm} }.
143
- */
144
- public static check(
145
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
146
- toCheck: any,
147
- receptor: (json: object) => void,
148
- dbc: string | undefined = undefined,
149
- ) {
150
- const checkResult = JSON_Parse.checkAlgorithm(toCheck, receptor);
151
-
152
- if (typeof checkResult === "string") {
153
- DBC.reportTsCheckInfringement(checkResult, dbc);
154
- }
155
- }
156
- // #endregion In-Method checking.
157
- }
1
+ import { DBC } from "../DBC";
2
+ /**
3
+ * A {@link DBC } demanding that a {@link string } is {@link JSON.parse}able.
4
+ *
5
+ * @remarks
6
+ * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
+ export class JSON_Parse extends DBC {
8
+ // #region Condition checking.
9
+ /**
10
+ * Tries to {@link JSON.parse } the {@link string } **toCheck** invoking the **receptor** with the result, if so.
11
+ *
12
+ * @param toCheck The {@link string } to be {@link JSON.parse }d.
13
+ * @param receptor The **( json : object ) => void** to receive the {@link JSON.parse }d {@link string } **toCheck**.
14
+ * check needs to have.
15
+ *
16
+ * @returns TRUE if the value **toCheck** is a valid JSON, otherwise a {@link string } to report the infringement. */
17
+ public static checkAlgorithm(
18
+ toCheck: string,
19
+ receptor: (json: object) => void,
20
+ ): boolean | string {
21
+ let parsed: any;
22
+ try {
23
+ parsed = JSON.parse(toCheck);
24
+ } catch (X: unknown) {
25
+ return `[ Following string is not a valid JSON: ${toCheck}]`;
26
+ }
27
+ if (receptor) {
28
+ receptor(parsed);
29
+ }
30
+ return true;
31
+ }
32
+ /**
33
+ * A parameter-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
34
+ * by the tagged parameter.
35
+ *
36
+ * @param receptor See {@link JSON.checkAlgorithm }.
37
+ * @param path See {@link DBC.decPrecondition }.
38
+ * @param dbc See {@link DBC.decPrecondition }.
39
+ *
40
+ * @returns See {@link DBC.decPrecondition }. */
41
+ public static PRE(
42
+ receptor: (json: object) => void,
43
+ path: string | undefined = undefined,
44
+ hint: string | undefined = undefined,
45
+ dbc: string | undefined = undefined,
46
+ ): (
47
+ target: object,
48
+ methodName: string | symbol | undefined,
49
+ parameterIndex: number,
50
+ ) => void {
51
+ return DBC.createPRE(
52
+ JSON_Parse.checkAlgorithm,
53
+ [receptor],
54
+ dbc,
55
+ path,
56
+ hint,
57
+ );
58
+ }
59
+ /**
60
+ * A method-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
61
+ * by the tagged method's returnvalue.
62
+ *
63
+ * @param expression See {@link JSON.checkAlgorithm }.
64
+ * @param path See {@link DBC.Postcondition }.
65
+ * @param dbc See {@link DBC.decPostcondition }.
66
+ *
67
+ * @returns See {@link DBC.decPostcondition }. */
68
+ public static POST(
69
+ receptor: (json: object) => void,
70
+ path: string | undefined = undefined,
71
+ hint: string | undefined = undefined,
72
+ dbc: string | undefined = undefined,
73
+ ): (
74
+ target: object,
75
+ propertyKey: string,
76
+ descriptor: PropertyDescriptor,
77
+ ) => PropertyDescriptor {
78
+ return DBC.createPOST(
79
+ JSON_Parse.checkAlgorithm,
80
+ [receptor],
81
+ dbc,
82
+ path,
83
+ hint,
84
+ );
85
+ }
86
+ /**
87
+ * A field-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
88
+ * by the tagged field.
89
+ *
90
+ * @param expression See {@link JSON.checkAlgorithm }.
91
+ * @param path See {@link DBC.decInvariant }.
92
+ * @param dbc See {@link DBC.decInvariant }.
93
+ *
94
+ * @returns See {@link DBC.decInvariant }. */
95
+ public static INVARIANT(
96
+ receptor: (json: object) => void,
97
+ path: string | undefined = undefined,
98
+ hint: string | undefined = undefined,
99
+ dbc: string | undefined = undefined,
100
+ ) {
101
+ return DBC.createINVARIANT(JSON_Parse, [receptor], dbc, path, hint);
102
+ }
103
+ // #endregion Condition checking.
104
+ // #region Referenced Condition checking.
105
+ //
106
+ // For usage in dynamic scenarios (like with AE-DBC).
107
+ //
108
+ /**
109
+ * Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck** and {@link JSON_Parse.receptor }.
110
+ *
111
+ * @param toCheck See {@link JSON_Parse.checkAlgorithm }.
112
+ *
113
+ * @returns See {@link JSON_Parse.checkAlgorithm}. */
114
+ public check(toCheck: any) {
115
+ return JSON_Parse.checkAlgorithm(
116
+ toCheck,
117
+ this.receptor as (json: object) => void,
118
+ );
119
+ }
120
+ /**
121
+ * Creates this {@link JSON_Parse } by setting the protected property {@link JSON_Parse.necessaryProperties } and {@link checkElements } used by {@link JSON_Parse.check }.
122
+ *
123
+ * @param necessaryProperties See {@link JSON_Parse.check }.
124
+ * @param checkElements See {@link JSON_Parse.check }. */
125
+ public constructor(
126
+ public receptor: ((json: object) => void) | undefined = undefined,
127
+ ) {
128
+ super();
129
+ }
130
+ // #endregion Referenced Condition checking.
131
+ // #region In-Method checking.
132
+ /**
133
+ * Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck**, {@link JSON_Parse.necessaryProperties } and {@link JSON_Parse.checkElements }.
134
+ *
135
+ * @param toCheck See {@link JSON_Parse.checkAlgorithm} }.
136
+ * @param necessaryProperties See {@link JSON_Parse.checkAlgorithm} }.
137
+ * @param checkElements See {@link JSON_Parse.checkAlgorithm} }.
138
+ */
139
+ public static check(
140
+ toCheck: any,
141
+ receptor: (json: object) => void,
142
+ dbc: string | undefined = undefined,
143
+ ) {
144
+ const checkResult = JSON_Parse.checkAlgorithm(toCheck, receptor);
145
+ if (typeof checkResult === "string") {
146
+ DBC.reportTsCheckInfringement(checkResult, dbc);
147
+ }
148
+ }
149
+ // #endregion In-Method checking.
150
+ }