ec4w_validator 0.0.1001111222 → 0.0.1001111224

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/README.Docker.md CHANGED
@@ -1,22 +1,17 @@
1
- ### Building and running your application
1
+ # Docker usage
2
2
 
3
- When you're ready, start your application by running:
4
- `docker compose down && docker compose up --build`.
3
+ Docker container may be used, configurations are for:
4
+ * for development purpose only,
5
+ * to setup a development environment in a container
5
6
 
6
- Your application will be available at http://localhost:5173.
7
+ commands to run:
8
+ ```bash
9
+ docker compose down --remove-orphans \
10
+ # remove any leftover stopped container
11
+ && \
12
+ # build image and then run it, auto remove when done and on exit
13
+ docker compose run --rm --build app
14
+ # you are in container now --sh--
15
+ # enter `exit` to exit from container's sh
7
16
 
8
- ### Deploying your application to the cloud
9
-
10
- First, build your image, e.g.: `docker build -t myapp .`.
11
- If your cloud uses a different CPU architecture than your development
12
- machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
13
- you'll want to build the image for that platform, e.g.:
14
- `docker build --platform=linux/amd64 -t myapp .`.
15
-
16
- Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.
17
-
18
- Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
19
- docs for more detail on building and pushing.
20
-
21
- ### References
22
- * [Docker's Node.js guide](https://docs.docker.com/language/nodejs/)
17
+ ```
package/dist/index.js CHANGED
@@ -1,159 +1,226 @@
1
- class c {
1
+ function _toJSON(target) {
2
+ const jsonObj = { ...target };
3
+ const proto = Object.getPrototypeOf(target);
4
+ Object.entries(Object.getOwnPropertyDescriptors(proto)).forEach(([key, descriptor]) => {
5
+ if (typeof descriptor.get === "function") {
6
+ jsonObj[key] = target[key];
7
+ }
8
+ });
9
+ return jsonObj;
10
+ }
11
+ class EC4W_Validator {
2
12
  /** @type {SentRequest[]} */
3
- #t = [];
13
+ #requestList = [];
4
14
  /** @param {SentRequest[]} requestList */
5
- constructor(e) {
6
- this.#t = e;
15
+ constructor(requestList) {
16
+ this.#requestList = requestList;
7
17
  }
8
18
  /** @returns {EC4W_Result} */
9
19
  conclude() {
10
- const e = [];
11
- for (const r of this.#t) {
12
- if (!r.url) continue;
13
- const s = new URL(r.url);
14
- o.canBe(r.method, s) ? e.push(new o(r.method, s)) : u.canBe(r.method, s) && e.push(new u(r.method, s));
20
+ const sentRequests = [];
21
+ for (const request of this.#requestList) {
22
+ if (!request.url) continue;
23
+ const Url = new URL(request.url);
24
+ if (UPDE_Request.canBe(request.method, Url)) {
25
+ sentRequests.push(new UPDE_Request(request.method, Url));
26
+ } else if (Conversion_Request.canBe(request.method, Url)) {
27
+ sentRequests.push(new Conversion_Request(request.method, Url));
28
+ } else ;
15
29
  }
16
- if (e.length < 1) throw new Error("no ( sentRequest ) detected");
17
- const t = [];
30
+ if (sentRequests.length < 1) throw new Error("no ( sentRequest ) detected");
31
+ const EC4W_list = [];
18
32
  {
19
- let r = null;
20
- for (const s of e)
21
- s instanceof o ? r = s : s instanceof u && t.push(new f(r, s));
33
+ let lastUPDE = null;
34
+ for (const ping of sentRequests) {
35
+ if (ping instanceof UPDE_Request) {
36
+ lastUPDE = ping;
37
+ } else if (ping instanceof Conversion_Request) {
38
+ EC4W_list.push(new EC4W_Request(lastUPDE, ping));
39
+ }
40
+ }
22
41
  }
23
- if (t.length < 1) throw new Error("no ( UPDE | EC4w ) requests detected");
24
- return new m(t);
42
+ if (EC4W_list.length < 1) throw new Error("no ( UPDE | EC4w ) requests detected");
43
+ return new EC4W_Result(EC4W_list);
25
44
  }
26
45
  /** @param {string} em */
27
- static emIsValid(e) {
28
- if (!e || e.startsWith("tv.1") === !1 || e === "tv.1" || /^tv\.1~e[0-9]/.test(e)) return !1;
29
- const t = e.split("~"), r = t.length;
30
- if (r < 2) return !1;
31
- for (let s = 1; s < r; ++s) {
32
- if (t[s] === "") return !1;
33
- const [h, d] = t[s].split(".");
34
- if (!h || !d) return !1;
46
+ static emIsValid(em) {
47
+ if (!em) return false;
48
+ if (em.startsWith("tv.1") === false) return false;
49
+ if (em === "tv.1") return false;
50
+ if (/^tv\.1~e[0-9]/.test(em)) return false;
51
+ const part = em.split("~");
52
+ const len = part.length;
53
+ if (len < 2) return false;
54
+ for (let i = 1; i < len; ++i) {
55
+ if (part[i] === "") return false;
56
+ const [key, value] = part[i].split(".");
57
+ if (!key) return false;
58
+ if (!value) return false;
35
59
  }
36
- return !0;
60
+ return true;
61
+ }
62
+ toJSON() {
63
+ return _toJSON(this);
37
64
  }
38
65
  }
39
- const a = Object.freeze({
66
+ const EC4W_ValidMessages = Object.freeze({
40
67
  em_validInConversion: "valid `em` in Conversion payload",
41
68
  em_validInUPDE: "valid `em` in UPDE payload"
42
- }), l = Object.freeze({
69
+ });
70
+ const EC4W_ErrorMessages = Object.freeze({
43
71
  em_invalidInConversion: "invalid `em` in Conversion payload",
44
72
  em_invalidInUPDE: "invalid `em` in UPDE payload",
45
73
  ecsid_mismatch: "mismatch `ecsid` between UPDE and Conversion payload",
46
74
  conversionId_mismatch: "mismatch `Conversion ID` between UPDE and Conversion payload",
47
75
  noEC4W_request: "no valid EC4W requests detected at all"
48
76
  });
49
- class f {
50
- #t = null;
51
- #e;
77
+ class EC4W_Request {
78
+ #UPDE_Request = null;
79
+ #Conversion_Request;
52
80
  /**
53
81
  * @param {UPDE_Request?} UPDE_Request
54
82
  * @param {Conversion_Request} Conversion_Request */
55
- constructor(e, t) {
56
- this.#t = e, this.#e = t;
83
+ constructor(UPDE_Request2, Conversion_Request2) {
84
+ this.#UPDE_Request = UPDE_Request2;
85
+ this.#Conversion_Request = Conversion_Request2;
57
86
  }
58
87
  get result() {
59
- return !this.#t && !this.#e ? new n(!1, l.noEC4W_request) : this.#s() === !1 ? new n(!1, l.ecsid_mismatch) : this.#r();
88
+ if (!this.#UPDE_Request && !this.#Conversion_Request)
89
+ return new Result(false, EC4W_ErrorMessages.noEC4W_request);
90
+ if (this.#ecsidIsValid() === false)
91
+ return new Result(false, EC4W_ErrorMessages.ecsid_mismatch);
92
+ return this.#emIsValid();
60
93
  }
61
- #s() {
62
- return this.#e === null ? !1 : this.#t === null ? !0 : !(!this.#t.ecsid || !this.#e.ecsid || this.#t.ecsid !== this.#e.ecsid);
94
+ #ecsidIsValid() {
95
+ if (this.#Conversion_Request === null) return false;
96
+ if (this.#UPDE_Request === null) {
97
+ return true;
98
+ }
99
+ if (!this.#UPDE_Request.ecsid) return false;
100
+ if (!this.#Conversion_Request.ecsid) return false;
101
+ if (this.#UPDE_Request.ecsid !== this.#Conversion_Request.ecsid) return false;
102
+ return true;
63
103
  }
64
- #r() {
65
- if (this.#e === null)
66
- return new n(!1, l.em_invalidInConversion);
67
- if (this.#t === null) {
68
- const t = this.#e.emIsValid();
69
- return t ? new n(t, a.em_validInConversion) : new n(t, l.em_invalidInConversion);
104
+ #emIsValid() {
105
+ if (this.#Conversion_Request === null)
106
+ return new Result(false, EC4W_ErrorMessages.em_invalidInConversion);
107
+ if (this.#UPDE_Request === null) {
108
+ const isValid2 = this.#Conversion_Request.emIsValid();
109
+ if (isValid2) return new Result(isValid2, EC4W_ValidMessages.em_validInConversion);
110
+ else return new Result(isValid2, EC4W_ErrorMessages.em_invalidInConversion);
70
111
  }
71
- if (this.#e.em === null) {
72
- const t = this.#t.emIsValid();
73
- return t ? new n(t, a.em_validInUPDE) : new n(t, l.em_invalidInUPDE);
112
+ if (this.#Conversion_Request.em === null) {
113
+ const isValid2 = this.#UPDE_Request.emIsValid();
114
+ if (isValid2) return new Result(isValid2, EC4W_ValidMessages.em_validInUPDE);
115
+ else return new Result(isValid2, EC4W_ErrorMessages.em_invalidInUPDE);
74
116
  }
75
- const e = this.#e.emIsValid();
76
- return e ? new n(e, a.em_validInConversion) : new n(e, l.em_invalidInConversion);
117
+ const isValid = this.#Conversion_Request.emIsValid();
118
+ if (isValid) return new Result(isValid, EC4W_ValidMessages.em_validInConversion);
119
+ else return new Result(isValid, EC4W_ErrorMessages.em_invalidInConversion);
120
+ }
121
+ toJSON() {
122
+ return _toJSON(this);
77
123
  }
78
124
  }
79
- class n {
80
- #t;
125
+ class Result {
126
+ #isGood;
81
127
  get isGood() {
82
- return this.#t;
128
+ return this.#isGood;
83
129
  }
84
- #e;
130
+ #message;
85
131
  get message() {
86
- return this.#e;
132
+ return this.#message;
87
133
  }
88
134
  /** @param {boolean} isGood
89
135
  * @param {string} message */
90
- constructor(e, t) {
91
- this.#t = e, this.#e = t;
136
+ constructor(isGood, message) {
137
+ this.#isGood = isGood;
138
+ this.#message = message;
139
+ }
140
+ toJSON() {
141
+ return {
142
+ isGood: this.#isGood,
143
+ message: this.#message
144
+ };
92
145
  }
93
146
  }
94
- class o {
147
+ class UPDE_Request {
95
148
  /**
96
149
  * @param {string} method
97
150
  * @param {URL} Url */
98
- static canBe(e, t) {
99
- return !(e !== "GET" || t.toString().startsWith("https://www.google.com/ccm/form-data/") === !1 || t.searchParams.get("em") === null);
151
+ static canBe(method, Url) {
152
+ if (method !== "GET") return false;
153
+ if (false === Url.toString().startsWith("https://www.google.com/ccm/form-data/")) return false;
154
+ if (Url.searchParams.get("em") === null) return false;
155
+ return true;
100
156
  }
101
- #t;
157
+ #method;
102
158
  get method() {
103
- return this.#t;
159
+ return this.#method;
104
160
  }
105
- #e;
161
+ #Url;
106
162
  get url() {
107
- return this.#e.toString();
163
+ return this.#Url.toString();
108
164
  }
109
165
  /**
110
166
  * @param {string} method
111
167
  * @param {URL} Url */
112
- constructor(e, t) {
113
- this.#t = e, this.#e = t;
168
+ constructor(method, Url) {
169
+ this.#method = method;
170
+ this.#Url = Url;
114
171
  }
115
172
  get em() {
116
- return this.#e.searchParams.get("em");
173
+ return this.#Url.searchParams.get("em");
117
174
  }
118
175
  get ecsid() {
119
- return this.#e.searchParams.get("ecsid");
176
+ return this.#Url.searchParams.get("ecsid");
120
177
  }
121
178
  emIsValid() {
122
- return c.emIsValid(this.em);
179
+ return EC4W_Validator.emIsValid(this.em);
180
+ }
181
+ toJSON() {
182
+ return _toJSON(this);
123
183
  }
124
184
  }
125
- class u {
185
+ class Conversion_Request {
126
186
  /**
127
187
  * @param {string} method
128
188
  * @param {URL} Url */
129
- static canBe(e, t) {
130
- return !(e !== "GET" || t.toString().startsWith("https://www.googleadservices.com/ccm/conversion/") === !1 || t.searchParams.get("label") === null);
189
+ static canBe(method, Url) {
190
+ if (method !== "GET") return false;
191
+ if (false === Url.toString().startsWith("https://www.googleadservices.com/ccm/conversion/")) return false;
192
+ if (Url.searchParams.get("label") === null) return false;
193
+ return true;
131
194
  }
132
- #t;
195
+ #method;
133
196
  get method() {
134
- return this.#t;
197
+ return this.#method;
135
198
  }
136
- #e;
199
+ #Url;
137
200
  get url() {
138
- return this.#e.toString();
201
+ return this.#Url.toString();
139
202
  }
140
203
  /**
141
204
  * @param {string} method
142
205
  * @param {URL} Url */
143
- constructor(e, t) {
144
- this.#t = e, this.#e = t;
206
+ constructor(method, Url) {
207
+ this.#method = method;
208
+ this.#Url = Url;
145
209
  }
146
210
  get em() {
147
- return this.#e.searchParams.get("em");
211
+ return this.#Url.searchParams.get("em");
148
212
  }
149
213
  get ecsid() {
150
- return this.#e.searchParams.get("ecsid");
214
+ return this.#Url.searchParams.get("ecsid");
151
215
  }
152
216
  emIsValid() {
153
- return c.emIsValid(this.em);
217
+ return EC4W_Validator.emIsValid(this.em);
218
+ }
219
+ toJSON() {
220
+ return _toJSON(this);
154
221
  }
155
222
  }
156
- class m {
223
+ class EC4W_Result {
157
224
  /** @type {EC4W_Request[]} */
158
225
  EC4W_Requests = [];
159
226
  // errors = [];
@@ -161,18 +228,20 @@ class m {
161
228
  /**
162
229
  * @param {EC4W_Request[]} EC4W_Requests
163
230
  * */
164
- constructor(e) {
165
- if (!e || e.length < 1) throw new Error("no requests detected");
166
- this.EC4W_Requests = e;
231
+ constructor(EC4W_Requests) {
232
+ if (!EC4W_Requests || EC4W_Requests.length < 1) throw new Error("no requests detected");
233
+ this.EC4W_Requests = EC4W_Requests;
167
234
  }
168
235
  get invalidRequest() {
169
- for (const e of this.EC4W_Requests)
170
- if (e.result.isGood === !1) return e;
236
+ for (const EC4W_Request2 of this.EC4W_Requests) {
237
+ if (EC4W_Request2.result.isGood === false) return EC4W_Request2;
238
+ }
171
239
  return null;
172
240
  }
173
241
  get validRequest() {
174
- for (const e of this.EC4W_Requests)
175
- if (e.result.isGood) return e;
242
+ for (const EC4W_Request2 of this.EC4W_Requests) {
243
+ if (EC4W_Request2.result.isGood) return EC4W_Request2;
244
+ }
176
245
  return null;
177
246
  }
178
247
  // get summary() {
@@ -185,21 +254,28 @@ class m {
185
254
  // }
186
255
  // return summary;
187
256
  // }
257
+ toJSON() {
258
+ return _toJSON(this);
259
+ }
188
260
  }
189
- class v {
261
+ class SentRequest {
190
262
  url = "https://";
191
263
  method = "GET";
192
- constructor(e, t) {
193
- this.url = e, this.method = t;
264
+ constructor(url, method) {
265
+ this.url = url;
266
+ this.method = method;
267
+ }
268
+ toJSON() {
269
+ return _toJSON(this);
194
270
  }
195
271
  }
196
272
  export {
197
- u as Conversion_Request,
198
- l as EC4W_ErrorMessages,
199
- f as EC4W_Request,
200
- m as EC4W_Result,
201
- a as EC4W_ValidMessages,
202
- c as EC4W_Validator,
203
- v as SentRequest,
204
- o as UPDE_Request
273
+ Conversion_Request,
274
+ EC4W_ErrorMessages,
275
+ EC4W_Request,
276
+ EC4W_Result,
277
+ EC4W_ValidMessages,
278
+ EC4W_Validator,
279
+ SentRequest,
280
+ UPDE_Request
205
281
  };
@@ -0,0 +1,285 @@
1
+ (function(global, factory) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.ec4w_validator = {}));
3
+ })(this, (function(exports2) {
4
+ "use strict";
5
+ function _toJSON(target) {
6
+ const jsonObj = { ...target };
7
+ const proto = Object.getPrototypeOf(target);
8
+ Object.entries(Object.getOwnPropertyDescriptors(proto)).forEach(([key, descriptor]) => {
9
+ if (typeof descriptor.get === "function") {
10
+ jsonObj[key] = target[key];
11
+ }
12
+ });
13
+ return jsonObj;
14
+ }
15
+ class EC4W_Validator {
16
+ /** @type {SentRequest[]} */
17
+ #requestList = [];
18
+ /** @param {SentRequest[]} requestList */
19
+ constructor(requestList) {
20
+ this.#requestList = requestList;
21
+ }
22
+ /** @returns {EC4W_Result} */
23
+ conclude() {
24
+ const sentRequests = [];
25
+ for (const request of this.#requestList) {
26
+ if (!request.url) continue;
27
+ const Url = new URL(request.url);
28
+ if (UPDE_Request.canBe(request.method, Url)) {
29
+ sentRequests.push(new UPDE_Request(request.method, Url));
30
+ } else if (Conversion_Request.canBe(request.method, Url)) {
31
+ sentRequests.push(new Conversion_Request(request.method, Url));
32
+ } else ;
33
+ }
34
+ if (sentRequests.length < 1) throw new Error("no ( sentRequest ) detected");
35
+ const EC4W_list = [];
36
+ {
37
+ let lastUPDE = null;
38
+ for (const ping of sentRequests) {
39
+ if (ping instanceof UPDE_Request) {
40
+ lastUPDE = ping;
41
+ } else if (ping instanceof Conversion_Request) {
42
+ EC4W_list.push(new EC4W_Request(lastUPDE, ping));
43
+ }
44
+ }
45
+ }
46
+ if (EC4W_list.length < 1) throw new Error("no ( UPDE | EC4w ) requests detected");
47
+ return new EC4W_Result(EC4W_list);
48
+ }
49
+ /** @param {string} em */
50
+ static emIsValid(em) {
51
+ if (!em) return false;
52
+ if (em.startsWith("tv.1") === false) return false;
53
+ if (em === "tv.1") return false;
54
+ if (/^tv\.1~e[0-9]/.test(em)) return false;
55
+ const part = em.split("~");
56
+ const len = part.length;
57
+ if (len < 2) return false;
58
+ for (let i = 1; i < len; ++i) {
59
+ if (part[i] === "") return false;
60
+ const [key, value] = part[i].split(".");
61
+ if (!key) return false;
62
+ if (!value) return false;
63
+ }
64
+ return true;
65
+ }
66
+ toJSON() {
67
+ return _toJSON(this);
68
+ }
69
+ }
70
+ const EC4W_ValidMessages = Object.freeze({
71
+ em_validInConversion: "valid `em` in Conversion payload",
72
+ em_validInUPDE: "valid `em` in UPDE payload"
73
+ });
74
+ const EC4W_ErrorMessages = Object.freeze({
75
+ em_invalidInConversion: "invalid `em` in Conversion payload",
76
+ em_invalidInUPDE: "invalid `em` in UPDE payload",
77
+ ecsid_mismatch: "mismatch `ecsid` between UPDE and Conversion payload",
78
+ conversionId_mismatch: "mismatch `Conversion ID` between UPDE and Conversion payload",
79
+ noEC4W_request: "no valid EC4W requests detected at all"
80
+ });
81
+ class EC4W_Request {
82
+ #UPDE_Request = null;
83
+ #Conversion_Request;
84
+ /**
85
+ * @param {UPDE_Request?} UPDE_Request
86
+ * @param {Conversion_Request} Conversion_Request */
87
+ constructor(UPDE_Request2, Conversion_Request2) {
88
+ this.#UPDE_Request = UPDE_Request2;
89
+ this.#Conversion_Request = Conversion_Request2;
90
+ }
91
+ get result() {
92
+ if (!this.#UPDE_Request && !this.#Conversion_Request)
93
+ return new Result(false, EC4W_ErrorMessages.noEC4W_request);
94
+ if (this.#ecsidIsValid() === false)
95
+ return new Result(false, EC4W_ErrorMessages.ecsid_mismatch);
96
+ return this.#emIsValid();
97
+ }
98
+ #ecsidIsValid() {
99
+ if (this.#Conversion_Request === null) return false;
100
+ if (this.#UPDE_Request === null) {
101
+ return true;
102
+ }
103
+ if (!this.#UPDE_Request.ecsid) return false;
104
+ if (!this.#Conversion_Request.ecsid) return false;
105
+ if (this.#UPDE_Request.ecsid !== this.#Conversion_Request.ecsid) return false;
106
+ return true;
107
+ }
108
+ #emIsValid() {
109
+ if (this.#Conversion_Request === null)
110
+ return new Result(false, EC4W_ErrorMessages.em_invalidInConversion);
111
+ if (this.#UPDE_Request === null) {
112
+ const isValid2 = this.#Conversion_Request.emIsValid();
113
+ if (isValid2) return new Result(isValid2, EC4W_ValidMessages.em_validInConversion);
114
+ else return new Result(isValid2, EC4W_ErrorMessages.em_invalidInConversion);
115
+ }
116
+ if (this.#Conversion_Request.em === null) {
117
+ const isValid2 = this.#UPDE_Request.emIsValid();
118
+ if (isValid2) return new Result(isValid2, EC4W_ValidMessages.em_validInUPDE);
119
+ else return new Result(isValid2, EC4W_ErrorMessages.em_invalidInUPDE);
120
+ }
121
+ const isValid = this.#Conversion_Request.emIsValid();
122
+ if (isValid) return new Result(isValid, EC4W_ValidMessages.em_validInConversion);
123
+ else return new Result(isValid, EC4W_ErrorMessages.em_invalidInConversion);
124
+ }
125
+ toJSON() {
126
+ return _toJSON(this);
127
+ }
128
+ }
129
+ class Result {
130
+ #isGood;
131
+ get isGood() {
132
+ return this.#isGood;
133
+ }
134
+ #message;
135
+ get message() {
136
+ return this.#message;
137
+ }
138
+ /** @param {boolean} isGood
139
+ * @param {string} message */
140
+ constructor(isGood, message) {
141
+ this.#isGood = isGood;
142
+ this.#message = message;
143
+ }
144
+ toJSON() {
145
+ return {
146
+ isGood: this.#isGood,
147
+ message: this.#message
148
+ };
149
+ }
150
+ }
151
+ class UPDE_Request {
152
+ /**
153
+ * @param {string} method
154
+ * @param {URL} Url */
155
+ static canBe(method, Url) {
156
+ if (method !== "GET") return false;
157
+ if (false === Url.toString().startsWith("https://www.google.com/ccm/form-data/")) return false;
158
+ if (Url.searchParams.get("em") === null) return false;
159
+ return true;
160
+ }
161
+ #method;
162
+ get method() {
163
+ return this.#method;
164
+ }
165
+ #Url;
166
+ get url() {
167
+ return this.#Url.toString();
168
+ }
169
+ /**
170
+ * @param {string} method
171
+ * @param {URL} Url */
172
+ constructor(method, Url) {
173
+ this.#method = method;
174
+ this.#Url = Url;
175
+ }
176
+ get em() {
177
+ return this.#Url.searchParams.get("em");
178
+ }
179
+ get ecsid() {
180
+ return this.#Url.searchParams.get("ecsid");
181
+ }
182
+ emIsValid() {
183
+ return EC4W_Validator.emIsValid(this.em);
184
+ }
185
+ toJSON() {
186
+ return _toJSON(this);
187
+ }
188
+ }
189
+ class Conversion_Request {
190
+ /**
191
+ * @param {string} method
192
+ * @param {URL} Url */
193
+ static canBe(method, Url) {
194
+ if (method !== "GET") return false;
195
+ if (false === Url.toString().startsWith("https://www.googleadservices.com/ccm/conversion/")) return false;
196
+ if (Url.searchParams.get("label") === null) return false;
197
+ return true;
198
+ }
199
+ #method;
200
+ get method() {
201
+ return this.#method;
202
+ }
203
+ #Url;
204
+ get url() {
205
+ return this.#Url.toString();
206
+ }
207
+ /**
208
+ * @param {string} method
209
+ * @param {URL} Url */
210
+ constructor(method, Url) {
211
+ this.#method = method;
212
+ this.#Url = Url;
213
+ }
214
+ get em() {
215
+ return this.#Url.searchParams.get("em");
216
+ }
217
+ get ecsid() {
218
+ return this.#Url.searchParams.get("ecsid");
219
+ }
220
+ emIsValid() {
221
+ return EC4W_Validator.emIsValid(this.em);
222
+ }
223
+ toJSON() {
224
+ return _toJSON(this);
225
+ }
226
+ }
227
+ class EC4W_Result {
228
+ /** @type {EC4W_Request[]} */
229
+ EC4W_Requests = [];
230
+ // errors = [];
231
+ messages = [];
232
+ /**
233
+ * @param {EC4W_Request[]} EC4W_Requests
234
+ * */
235
+ constructor(EC4W_Requests) {
236
+ if (!EC4W_Requests || EC4W_Requests.length < 1) throw new Error("no requests detected");
237
+ this.EC4W_Requests = EC4W_Requests;
238
+ }
239
+ get invalidRequest() {
240
+ for (const EC4W_Request2 of this.EC4W_Requests) {
241
+ if (EC4W_Request2.result.isGood === false) return EC4W_Request2;
242
+ }
243
+ return null;
244
+ }
245
+ get validRequest() {
246
+ for (const EC4W_Request2 of this.EC4W_Requests) {
247
+ if (EC4W_Request2.result.isGood) return EC4W_Request2;
248
+ }
249
+ return null;
250
+ }
251
+ // get summary() {
252
+ // const summary = [], EC4W_Requests = this.EC4W_Requests;
253
+ // for (const EC4W_Request of EC4W_Requests) {
254
+ // summary.push({
255
+ // EC4W_Request: EC4W_Request,
256
+ // result: EC4W_Request.result,
257
+ // });
258
+ // }
259
+ // return summary;
260
+ // }
261
+ toJSON() {
262
+ return _toJSON(this);
263
+ }
264
+ }
265
+ class SentRequest {
266
+ url = "https://";
267
+ method = "GET";
268
+ constructor(url, method) {
269
+ this.url = url;
270
+ this.method = method;
271
+ }
272
+ toJSON() {
273
+ return _toJSON(this);
274
+ }
275
+ }
276
+ exports2.Conversion_Request = Conversion_Request;
277
+ exports2.EC4W_ErrorMessages = EC4W_ErrorMessages;
278
+ exports2.EC4W_Request = EC4W_Request;
279
+ exports2.EC4W_Result = EC4W_Result;
280
+ exports2.EC4W_ValidMessages = EC4W_ValidMessages;
281
+ exports2.EC4W_Validator = EC4W_Validator;
282
+ exports2.SentRequest = SentRequest;
283
+ exports2.UPDE_Request = UPDE_Request;
284
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
285
+ }));
package/dist/vite.svg CHANGED
File without changes
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
- {
2
- "name": "ec4w_validator",
3
- "private": false,
4
- "version": "0.0.1001111222",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview",
10
- "test": "vitest --run",
11
- "test-watch": "vitest",
12
- "test-coverage": "vitest run --coverage"
13
- },
14
- "files": [
15
- "./dist/"
16
- ],
17
- "main": "./dist/index.umd.cjs",
18
- "module": "./dist/index.js",
19
- "exports": {
20
- ".": {
21
- "import": "./dist/index.js",
22
- "require": "./dist/index.umd.js"
23
- }
24
- },
25
- "devDependencies": {
26
- "@eslint/js": "^9.39.2",
27
- "@vitest/coverage-v8": "^4.0.18",
28
- "eslint": "^9.39.2",
29
- "globals": "^17.2.0",
30
- "jsdom": "^27.4.0",
31
- "vite": "^7.2.4",
32
- "vitest": "^4.0.18"
33
- }
34
- }
1
+ {
2
+ "name": "ec4w_validator",
3
+ "private": false,
4
+ "version": "0.0.1001111224",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "preview": "vite preview",
10
+ "test": "vitest --run",
11
+ "test-watch": "vitest",
12
+ "test-coverage": "vitest run --coverage"
13
+ },
14
+ "files": [
15
+ "./dist/"
16
+ ],
17
+ "main": "./dist/index.umd.cjs",
18
+ "module": "./dist/index.js",
19
+ "exports": {
20
+ ".": {
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.umd.js"
23
+ }
24
+ },
25
+ "devDependencies": {
26
+ "@eslint/js": "^9.39.2",
27
+ "@vitest/coverage-v8": "^4.0.18",
28
+ "eslint": "^9.39.2",
29
+ "globals": "^17.2.0",
30
+ "jsdom": "^27.4.0",
31
+ "vite": "^7.2.4",
32
+ "vitest": "^4.0.18"
33
+ }
34
+ }
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {}