@tryghost/mg-json 0.11.3 → 0.11.5

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2013-2023 Ghost Foundation
3
+ Copyright (c) 2013-2025 Ghost Foundation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -36,4 +36,4 @@ Follow the instructions for the top-level repo.
36
36
 
37
37
  # Copyright & License
38
38
 
39
- Copyright (c) 2013-2023 Ghost Foundation - Released under the [MIT license](LICENSE).
39
+ Copyright (c) 2013-2025 Ghost Foundation - Released under the [MIT license](LICENSE).
@@ -4,12 +4,12 @@ import processPostRelations from './process-post-relations.js';
4
4
  import validate from './validate.js';
5
5
  import reorderTags from './reorder-tags.js';
6
6
 
7
- export default (input, options = {}, ctx) => {
7
+ export default async (input, options = {}, ctx) => {
8
8
  // Construct a basic Ghost JSON template
9
9
  let output = baseTemplate();
10
10
 
11
11
  // Validate data and potentially alter if needed
12
- input = validate(input, ctx);
12
+ input = await validate(input, ctx);
13
13
 
14
14
  // Reorder tags so #internal-tags appear last
15
15
  input = reorderTags(input);
@@ -1,4 +1,7 @@
1
- export default (json, ctx = null) => {
1
+ import {slugify} from '@tryghost/string';
2
+ import emailValidator from 'node-email-verifier';
3
+
4
+ export default async (json, ctx = null) => {
2
5
  if (!json.posts) {
3
6
  return json;
4
7
  }
@@ -8,6 +11,7 @@ export default (json, ctx = null) => {
8
11
 
9
12
  // String length data from https://github.com/TryGhost/Ghost/blob/main/ghost/core/core/server/data/schema/schema.js
10
13
  let properties = {
14
+ title: 255,
11
15
  slug: 191,
12
16
  custom_excerpt: 300,
13
17
  og_title: 300,
@@ -35,5 +39,17 @@ export default (json, ctx = null) => {
35
39
  json.posts[index].data = input;
36
40
  });
37
41
 
42
+ if (json?.users?.length) {
43
+ for await (const [index, item] of json.users.entries()) {
44
+ const isEmailValid = await emailValidator(item.data.email);
45
+
46
+ if (!isEmailValid) {
47
+ item.data.email = `${slugify(item?.data?.slug || item?.data?.name || 'author')}@example.com`;
48
+ }
49
+
50
+ json.users[index] = item;
51
+ }
52
+ }
53
+
38
54
  return json;
39
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-json",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-json",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -28,7 +28,8 @@
28
28
  "@tryghost/string": "0.2.12",
29
29
  "bson-objectid": "2.0.4",
30
30
  "html-entities": "2.5.2",
31
- "lodash": "4.17.21"
31
+ "lodash": "4.17.21",
32
+ "node-email-verifier": "2.0.0"
32
33
  },
33
- "gitHead": "c1d13ccea270adcaf60dfc9d1e371ef25dfad31e"
34
+ "gitHead": "c0d0850c491eb693ffbd33fd68f88ca87bb15f6a"
34
35
  }