@moreapp/common-nodejs 0.7.7 → 0.7.11

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/schema.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ export declare const EmailAddressSchema: z.ZodEffects<z.ZodString, string, string>;
2
3
  export declare const FormVersionFieldSchema: z.ZodObject<{
3
4
  uid: z.ZodString;
4
5
  properties: z.ZodObject<{
@@ -113,7 +114,7 @@ export declare const SubmissionSchema: z.ZodObject<{
113
114
  data: z.ZodRecord<z.ZodString, z.ZodAny>;
114
115
  mailStatuses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
115
116
  pdfFileId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
116
- emailAddresses: z.ZodArray<z.ZodString, "many">;
117
+ emailAddresses: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
117
118
  }, "strip", z.ZodTypeAny, {
118
119
  emailAddresses: string[];
119
120
  pdfFileId?: string | null | undefined;
@@ -265,7 +266,7 @@ export declare const BaseIntegrationRequestSchema: z.ZodObject<{
265
266
  data: z.ZodRecord<z.ZodString, z.ZodAny>;
266
267
  mailStatuses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
267
268
  pdfFileId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
268
- emailAddresses: z.ZodArray<z.ZodString, "many">;
269
+ emailAddresses: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
269
270
  }, "strip", z.ZodTypeAny, {
270
271
  emailAddresses: string[];
271
272
  pdfFileId?: string | null | undefined;
package/dist/schema.js CHANGED
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseIntegrationRequestSchema = exports.SubmissionSchema = exports.FormVersionSchema = exports.FormVersionFieldSchema = void 0;
3
+ exports.BaseIntegrationRequestSchema = exports.SubmissionSchema = exports.FormVersionSchema = exports.FormVersionFieldSchema = exports.EmailAddressSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const utils_1 = require("./utils");
6
+ exports.EmailAddressSchema = zod_1.z
7
+ .string()
8
+ .trim()
9
+ .refine((val) => (0, utils_1.isValidEmail)(val));
5
10
  exports.FormVersionFieldSchema = zod_1.z.object({
6
11
  uid: zod_1.z.string(),
7
12
  properties: zod_1.z.object({
@@ -36,7 +41,7 @@ exports.SubmissionSchema = zod_1.z.object({
36
41
  mailStatuses: zod_1.z
37
42
  .array(zod_1.z.object({
38
43
  pdfFileId: zod_1.z.string().nullish(),
39
- emailAddresses: zod_1.z.array(zod_1.z.string().email()),
44
+ emailAddresses: zod_1.z.array(exports.EmailAddressSchema),
40
45
  }))
41
46
  .nullish(),
42
47
  });
package/dist/utils.js CHANGED
@@ -34,7 +34,7 @@ function currentTraceId() {
34
34
  exports.currentTraceId = currentTraceId;
35
35
  const emailAddressMaxLength = 254; // https://stackoverflow.com/a/574698
36
36
  const emailAddressLocalPattern = /^.+$/;
37
- const emailAddressDomainPattern = /^(?:[a-z0-9À-ž](?:[a-z0-9À-ž-]{0,61}[a-z0-9À-ž])?\.)+[a-z0-9À-ž][a-z0-9À-ž-]{0,61}[a-z0-9]$/;
37
+ const emailAddressDomainPattern = /^(?:[A-z0-9À-ž](?:[A-z0-9À-ž-]{0,61}[A-z0-9À-ž])?\.)+[A-z0-9À-ž][A-z0-9À-ž-]{0,61}[A-z0-9]$/;
38
38
  // There are many regex patterns to validate email addresses, but they all have flaws and cannot 100% correctly verify
39
39
  // every possible email address. For us, it's more important to avoid the majority of typo's instead of catching every
40
40
  // invalid email address. We let our email provider handle and false positives (either by their validation or the fact
@@ -44,17 +44,18 @@ describe("isValidEmail", () => {
44
44
  test("Subdomain with a dash", () => expect((0, utils_1.isValidEmail)("a@sub.dom-ain.dev")).toBeTruthy());
45
45
  test("Long TLD", () => expect((0, utils_1.isValidEmail)("a@b.business")).toBeTruthy());
46
46
  test("Diacritics", () => expect((0, utils_1.isValidEmail)("ẞçäöü@möręæppß.dev")).toBeTruthy());
47
+ test("Casing", () => expect((0, utils_1.isValidEmail)("TØmÂs@mŒREÄPp.cOm")).toBeTruthy());
47
48
  });
48
49
  describe("Invalid email addresses", () => {
49
50
  test("Missing '@' character and domain", () => expect((0, utils_1.isValidEmail)("john")).toBeFalsy());
50
- test("// Multiple '@' characters", () => expect((0, utils_1.isValidEmail)("a@b@moreapp.dev")).toBeFalsy());
51
- test("// Empty", () => expect((0, utils_1.isValidEmail)("")).toBeFalsy());
52
- test("// Whitespace before/after", () => expect((0, utils_1.isValidEmail)(" a@moreapp.dev ")).toBeFalsy());
53
- test("// Newlines, tabs, ..., before/after", () => expect((0, utils_1.isValidEmail)("\n \ta@moreapp.dev\n ")).toBeFalsy());
54
- test("// Missing '@' character", () => expect((0, utils_1.isValidEmail)("ab.com")).toBeFalsy());
55
- test("// Double dot in domain", () => expect((0, utils_1.isValidEmail)("a@moreapp..com")).toBeFalsy());
56
- test("// Too short TLD", () => expect((0, utils_1.isValidEmail)("a@b.c")).toBeFalsy());
57
- test("// Missing local part", () => expect((0, utils_1.isValidEmail)("@moreapp.dev")).toBeFalsy());
58
- test("// Too long", () => expect((0, utils_1.isValidEmail)("abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-@moreapp.dev")).toBeFalsy());
51
+ test("Multiple '@' characters", () => expect((0, utils_1.isValidEmail)("a@b@moreapp.dev")).toBeFalsy());
52
+ test("Empty", () => expect((0, utils_1.isValidEmail)("")).toBeFalsy());
53
+ test("Whitespace before/after", () => expect((0, utils_1.isValidEmail)(" a@moreapp.dev ")).toBeFalsy());
54
+ test("Newlines, tabs, ..., before/after", () => expect((0, utils_1.isValidEmail)("\n \ta@moreapp.dev\n ")).toBeFalsy());
55
+ test("Missing '@' character", () => expect((0, utils_1.isValidEmail)("ab.com")).toBeFalsy());
56
+ test("Double dot in domain", () => expect((0, utils_1.isValidEmail)("a@moreapp..com")).toBeFalsy());
57
+ test("Too short TLD", () => expect((0, utils_1.isValidEmail)("a@b.c")).toBeFalsy());
58
+ test("Missing local part", () => expect((0, utils_1.isValidEmail)("@moreapp.dev")).toBeFalsy());
59
+ test("Too long", () => expect((0, utils_1.isValidEmail)("abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-@moreapp.dev")).toBeFalsy());
59
60
  });
60
61
  });
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@moreapp/common-nodejs",
3
- "version": "0.7.7",
3
+ "version": "0.7.11",
4
4
  "license": "UNLICENSED",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "test": "jest",
9
+ "test": "jest --detectOpenHandles",
10
+ "test:workflow": "yarn test --coverage",
10
11
  "prettier": "prettier './**/*.{ts,json,yaml,md,}'",
11
12
  "format:check": "yarn prettier --check",
12
13
  "format:fix": "yarn prettier --write",
@@ -22,7 +23,7 @@
22
23
  "@google-cloud/opentelemetry-cloud-trace-exporter": "2.1.0",
23
24
  "@opentelemetry/api": "1.4.1",
24
25
  "@opentelemetry/instrumentation": "0.41.2",
25
- "@opentelemetry/instrumentation-dns": "0.32.4",
26
+ "@opentelemetry/instrumentation-dns": "0.32.5",
26
27
  "@opentelemetry/instrumentation-express": "0.33.3",
27
28
  "@opentelemetry/instrumentation-http": "0.41.2",
28
29
  "@opentelemetry/instrumentation-winston": "0.32.2",
@@ -36,25 +37,24 @@
36
37
  "zod": "3.22.4"
37
38
  },
38
39
  "devDependencies": {
39
- "@types/jest": "29.5.10",
40
+ "@types/jest": "29.5.11",
40
41
  "@types/lodash": "4.14.202",
41
42
  "@types/node": "18.17.19",
42
- "@typescript-eslint/eslint-plugin": "5.62.0",
43
- "@typescript-eslint/parser": "5.62.0",
43
+ "@typescript-eslint/eslint-plugin": "6.20.0",
44
+ "@typescript-eslint/parser": "6.20.0",
44
45
  "eslint": "8.48.0",
45
46
  "eslint-config-airbnb-typescript": "17.1.0",
46
- "eslint-config-prettier": "8.10.0",
47
+ "eslint-config-prettier": "9.1.0",
47
48
  "eslint-plugin-import": "2.28.1",
48
- "eslint-plugin-prettier": "4.2.1",
49
- "husky": "8.0.3",
49
+ "eslint-plugin-prettier": "5.1.3",
50
+ "husky": "9.0.7",
50
51
  "jest": "29.6.4",
51
52
  "jest-mock-extended": "3.0.5",
52
- "jest-sonar-reporter": "2.0.0",
53
- "lint-staged": "13.3.0",
53
+ "lint-staged": "15.2.1",
54
54
  "nock": "13.3.8",
55
- "prettier": "2.8.8",
56
- "ts-jest": "29.1.1",
57
- "ts-node": "10.9.1",
55
+ "prettier": "3.2.4",
56
+ "ts-jest": "29.1.2",
57
+ "ts-node": "10.9.2",
58
58
  "typescript": "5.2.2"
59
59
  },
60
60
  "prettier": {