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,186 +1,178 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } demanding that an {@link object } has specific properties of specific types.
4
- *
5
- * @remarks
6
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
- export class JSON_OP extends DBC {
8
- // #region Condition checking.
9
- /**
10
- * Checks if the object **toCheck** has the **necessaryProperties** of necessary type.
11
- *
12
- * @param toCheck The {@link object } to check for the necessary properties.
13
- * @param necessaryProperties The **{ name : string, type : string }**s defining the properties and type the {@link object } to
14
- * check needs to have.
15
- * @param checkElements Indicates if **toCheck** is an iterable object of which all elements have to be checked.
16
- * Elements will only be checked if **toCheck** is iterable, otherwise **toCheck** itself
17
- * will be checked.
18
- *
19
- * @returns TRUE if the value **toCheck** or it's elements, if **checkElements** is TRUE, has all **necessaryProperties**, otherwise a {@link string } to report the infringement. */
20
- public static checkAlgorithm(
21
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
22
- toCheck: any,
23
- necessaryProperties: Array<{ name: string; type: string }>,
24
- checkElements,
25
- ): boolean | string {
26
- if (toCheck === undefined || toCheck === null) {
27
- return `[ UNDEFINED or NULL received instead of object with following properties: ${JSON.stringify(necessaryProperties)} ]`;
28
- }
29
-
30
- for (const property of necessaryProperties)
31
- if (checkElements && typeof toCheck[Symbol.iterator] === "function") {
32
- for (const element of toCheck) {
33
- if (
34
- // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
35
- !element.hasOwnProperty(property.name) ||
36
- // biome-ignore lint/suspicious/useValidTypeof: <explanation>
37
- typeof element[property.name] !== property.type
38
- ) {
39
- return `[ Object "${JSON.stringify(element)}" in Array "${JSON.stringify(toCheck)}" does not contain the necessary property "${property.name}" of type "${property.type}"]`;
40
- }
41
- }
42
- } else {
43
- if (
44
- // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
45
- !toCheck.hasOwnProperty(property.name) ||
46
- // biome-ignore lint/suspicious/useValidTypeof: <explanation>
47
- typeof toCheck[property.name] !== property.type
48
- ) {
49
- return `[ Object does not contain the necessary property "${property.name}" of type "${property.type}"]`;
50
- }
51
- }
52
-
53
- return true;
54
- }
55
- /**
56
- * A parameter-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
57
- * by the tagged parameter.
58
- *
59
- * @param expression See {@link JSON.checkAlgorithm }.
60
- * @param path See {@link DBC.decPrecondition }.
61
- * @param dbc See {@link DBC.decPrecondition }.
62
- *
63
- * @returns See {@link DBC.decPrecondition }. */
64
- public static PRE(
65
- necessaryProperties: Array<{ name: string; type: string }>,
66
- checkElements = false,
67
- path: string | undefined = undefined,
68
- dbc = "WaXCode.DBC",
69
- ): (
70
- target: object,
71
- methodName: string | symbol | undefined,
72
- parameterIndex: number,
73
- ) => void {
74
- return DBC.createPRE(
75
- JSON_OP.checkAlgorithm,
76
- [necessaryProperties, checkElements],
77
- dbc,
78
- path,
79
- );
80
- }
81
- /**
82
- * A method-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
83
- * by the tagged method's returnvalue.
84
- *
85
- * @param expression See {@link JSON.checkAlgorithm }.
86
- * @param path See {@link DBC.Postcondition }.
87
- * @param dbc See {@link DBC.decPostcondition }.
88
- *
89
- * @returns See {@link DBC.decPostcondition }. */
90
- public static POST(
91
- necessaryProperties: Array<{ name: string; type: string }>,
92
- checkElements = false,
93
- path: string | undefined = undefined,
94
- dbc = "WaXCode.DBC",
95
- ): (
96
- target: object,
97
- propertyKey: string,
98
- descriptor: PropertyDescriptor,
99
- ) => PropertyDescriptor {
100
- return DBC.createPOST(
101
- JSON_OP.checkAlgorithm,
102
- [necessaryProperties, checkElements],
103
- dbc,
104
- path,
105
- );
106
- }
107
- /**
108
- * A field-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
109
- * by the tagged field.
110
- *
111
- * @param expression See {@link JSON.checkAlgorithm }.
112
- * @param path See {@link DBC.decInvariant }.
113
- * @param dbc See {@link DBC.decInvariant }.
114
- *
115
- * @returns See {@link DBC.decPostcondition }. */
116
- public static INVARIANT(
117
- necessaryProperties: Array<{ name: string; type: string }>,
118
- checkElements = false,
119
- path: string | undefined = undefined,
120
- dbc = "WaXCode.DBC",
121
- ) {
122
- return DBC.createINVARIANT(
123
- JSON_OP,
124
- [necessaryProperties, checkElements],
125
- dbc,
126
- path,
127
- );
128
- }
129
- // #endregion Condition checking.
130
- // #region Referenced Condition checking.
131
- //
132
- // For usage in dynamic scenarios (like with AE-DBC).
133
- //
134
- /**
135
- * Invokes the {@link JSON_OP.checkAlgorithm } passing the value **toCheck**, {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
136
- *
137
- * @param toCheck See {@link JSON_OP.checkAlgorithm }.
138
- *
139
- * @returns See {@link JSON_OP.checkAlgorithm}. */
140
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
141
- public check(toCheck: any) {
142
- return JSON_OP.checkAlgorithm(
143
- toCheck,
144
- this.necessaryProperties,
145
- this.checkElements,
146
- );
147
- }
148
- /**
149
- * Creates this {@link JSON_OP } by setting the protected property {@link JSON_OP.necessaryProperties } and {@link checkElements } used by {@link JSON_OP.check }.
150
- *
151
- * @param necessaryProperties See {@link JSON_OP.check }.
152
- * @param checkElements See {@link JSON_OP.check }. */
153
- public constructor(
154
- public necessaryProperties: Array<{ name: string; type: string }>,
155
- public checkElements = false,
156
- ) {
157
- super();
158
- }
159
- // #endregion Referenced Condition checking.
160
- // #region In-Method checking.
161
- /**
162
- * Invokes the {@link JSON_OP.checkAlgorithm } passing the value **toCheck**, {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
163
- *
164
- * @param toCheck See {@link JSON_OP.checkAlgorithm} }.
165
- * @param necessaryProperties See {@link JSON_OP.checkAlgorithm} }.
166
- * @param checkElements See {@link JSON_OP.checkAlgorithm} }.
167
- */
168
- public static check(
169
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
170
- toCheck: any,
171
- necessaryProperties: Array<{ name: string; type: string }>,
172
- checkElements = false,
173
- dbc: string | undefined = undefined,
174
- ) {
175
- const checkResult = JSON_OP.checkAlgorithm(
176
- toCheck,
177
- necessaryProperties,
178
- checkElements,
179
- );
180
-
181
- if (typeof checkResult === "string") {
182
- DBC.reportTsCheckInfringement(checkResult, dbc);
183
- }
184
- }
185
- // #endregion In-Method checking.
186
- }
1
+ import { DBC } from "../DBC";
2
+ /**
3
+ * A {@link DBC } demanding that an {@link object } has specific properties of specific types.
4
+ *
5
+ * @remarks
6
+ * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
+ export class JSON_OP extends DBC {
8
+ // #region Condition checking.
9
+ /**
10
+ * Checks if the object **toCheck** has the **necessaryProperties** of necessary type.
11
+ *
12
+ * @param toCheck The {@link object } to check for the necessary properties.
13
+ * @param necessaryProperties The **{ name : string, type : string }**s defining the properties and type the {@link object } to
14
+ * check needs to have.
15
+ * @param checkElements Indicates if **toCheck** is an iterable object of which all elements have to be checked.
16
+ * Elements will only be checked if **toCheck** is iterable, otherwise **toCheck** itself
17
+ * will be checked.
18
+ *
19
+ * @returns TRUE if the value **toCheck** or it's elements, if **checkElements** is TRUE, has all **necessaryProperties**, otherwise a {@link string } to report the infringement. */
20
+ public static checkAlgorithm(
21
+ toCheck: any,
22
+ necessaryProperties: Array<{ name: string; type: string }>,
23
+ checkElements,
24
+ ): boolean | string {
25
+ if (toCheck === undefined || toCheck === null) {
26
+ return `[ UNDEFINED or NULL received instead of object with following properties: ${JSON.stringify(necessaryProperties)} ]`;
27
+ }
28
+ for (const property of necessaryProperties)
29
+ if (checkElements && typeof toCheck[Symbol.iterator] === "function") {
30
+ for (const element of toCheck) {
31
+ if (
32
+ // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
33
+ !element.hasOwnProperty(property.name) ||
34
+ typeof element[property.name] !== property.type
35
+ ) {
36
+ return `[ Object "${JSON.stringify(element)}" in Array "${JSON.stringify(toCheck)}" does not contain the necessary property "${property.name}" of type "${property.type}"]`;
37
+ }
38
+ }
39
+ } else {
40
+ if (
41
+ // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
42
+ !toCheck.hasOwnProperty(property.name) ||
43
+ typeof toCheck[property.name] !== property.type
44
+ ) {
45
+ return `[ Object does not contain the necessary property "${property.name}" of type "${property.type}"]`;
46
+ }
47
+ }
48
+ return true;
49
+ }
50
+ /**
51
+ * A parameter-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
52
+ * by the tagged parameter.
53
+ *
54
+ * @param expression See {@link JSON.checkAlgorithm }.
55
+ * @param path See {@link DBC.decPrecondition }.
56
+ * @param dbc See {@link DBC.decPrecondition }.
57
+ *
58
+ * @returns See {@link DBC.decPrecondition }. */
59
+ public static PRE(
60
+ necessaryProperties: Array<{ name: string; type: string }>,
61
+ checkElements = false,
62
+ path: string | undefined = undefined,
63
+ dbc = "WaXCode.DBC",
64
+ ): (
65
+ target: object,
66
+ methodName: string | symbol | undefined,
67
+ parameterIndex: number,
68
+ ) => void {
69
+ return DBC.createPRE(
70
+ JSON_OP.checkAlgorithm,
71
+ [necessaryProperties, checkElements],
72
+ dbc,
73
+ path,
74
+ );
75
+ }
76
+ /**
77
+ * A method-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
78
+ * by the tagged method's returnvalue.
79
+ *
80
+ * @param expression See {@link JSON.checkAlgorithm }.
81
+ * @param path See {@link DBC.Postcondition }.
82
+ * @param dbc See {@link DBC.decPostcondition }.
83
+ *
84
+ * @returns See {@link DBC.decPostcondition }. */
85
+ public static POST(
86
+ necessaryProperties: Array<{ name: string; type: string }>,
87
+ checkElements = false,
88
+ path: string | undefined = undefined,
89
+ dbc = "WaXCode.DBC",
90
+ ): (
91
+ target: object,
92
+ propertyKey: string,
93
+ descriptor: PropertyDescriptor,
94
+ ) => PropertyDescriptor {
95
+ return DBC.createPOST(
96
+ JSON_OP.checkAlgorithm,
97
+ [necessaryProperties, checkElements],
98
+ dbc,
99
+ path,
100
+ );
101
+ }
102
+ /**
103
+ * A field-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
104
+ * by the tagged field.
105
+ *
106
+ * @param expression See {@link JSON.checkAlgorithm }.
107
+ * @param path See {@link DBC.decInvariant }.
108
+ * @param dbc See {@link DBC.decInvariant }.
109
+ *
110
+ * @returns See {@link DBC.decPostcondition }. */
111
+ public static INVARIANT(
112
+ necessaryProperties: Array<{ name: string; type: string }>,
113
+ checkElements = false,
114
+ path: string | undefined = undefined,
115
+ dbc = "WaXCode.DBC",
116
+ ) {
117
+ return DBC.createINVARIANT(
118
+ JSON_OP,
119
+ [necessaryProperties, checkElements],
120
+ dbc,
121
+ path,
122
+ );
123
+ }
124
+ // #endregion Condition checking.
125
+ // #region Referenced Condition checking.
126
+ //
127
+ // For usage in dynamic scenarios (like with AE-DBC).
128
+ //
129
+ /**
130
+ * Invokes the {@link JSON_OP.checkAlgorithm } passing the value **toCheck**, {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
131
+ *
132
+ * @param toCheck See {@link JSON_OP.checkAlgorithm }.
133
+ *
134
+ * @returns See {@link JSON_OP.checkAlgorithm}. */
135
+ public check(toCheck: any) {
136
+ return JSON_OP.checkAlgorithm(
137
+ toCheck,
138
+ this.necessaryProperties,
139
+ this.checkElements,
140
+ );
141
+ }
142
+ /**
143
+ * Creates this {@link JSON_OP } by setting the protected property {@link JSON_OP.necessaryProperties } and {@link checkElements } used by {@link JSON_OP.check }.
144
+ *
145
+ * @param necessaryProperties See {@link JSON_OP.check }.
146
+ * @param checkElements See {@link JSON_OP.check }. */
147
+ public constructor(
148
+ public necessaryProperties: Array<{ name: string; type: string }>,
149
+ public checkElements = false,
150
+ ) {
151
+ super();
152
+ }
153
+ // #endregion Referenced Condition checking.
154
+ // #region In-Method checking.
155
+ /**
156
+ * Invokes the {@link JSON_OP.checkAlgorithm } passing the value **toCheck**, {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
157
+ *
158
+ * @param toCheck See {@link JSON_OP.checkAlgorithm} }.
159
+ * @param necessaryProperties See {@link JSON_OP.checkAlgorithm} }.
160
+ * @param checkElements See {@link JSON_OP.checkAlgorithm} }.
161
+ */
162
+ public static check(
163
+ toCheck: any,
164
+ necessaryProperties: Array<{ name: string; type: string }>,
165
+ checkElements = false,
166
+ dbc: string | undefined = undefined,
167
+ ) {
168
+ const checkResult = JSON_OP.checkAlgorithm(
169
+ toCheck,
170
+ necessaryProperties,
171
+ checkElements,
172
+ );
173
+ if (typeof checkResult === "string") {
174
+ DBC.reportTsCheckInfringement(checkResult, dbc);
175
+ }
176
+ }
177
+ // #endregion In-Method checking.
178
+ }