@tryghost/mg-json 0.11.10 → 0.11.12

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-2025 Ghost Foundation
3
+ Copyright (c) 2013-2026 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-2025 Ghost Foundation - Released under the [MIT license](LICENSE).
39
+ Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
@@ -3,6 +3,7 @@ import stripMeta from './meta-to-ghost.js';
3
3
  import processPostRelations from './process-post-relations.js';
4
4
  import validate from './validate.js';
5
5
  import reorderTags from './reorder-tags.js';
6
+ import {removeEmptyUsers} from './remove-empty.js';
6
7
 
7
8
  export default async (input, options = {}, ctx) => {
8
9
  // Construct a basic Ghost JSON template
@@ -20,5 +21,8 @@ export default async (input, options = {}, ctx) => {
20
21
  // Strip any meta data from the input / flatten structures
21
22
  output.data = stripMeta(output.data, options);
22
23
 
24
+ // Remove empty users (without posts)
25
+ output.data = removeEmptyUsers(output.data);
26
+
23
27
  return output;
24
28
  };
@@ -0,0 +1,24 @@
1
+ const removeEmptyUsers = (data) => {
2
+ // Assign temp IDs to users without IDs
3
+ data.users.forEach((user) => {
4
+ if (!user.id || user.id === '') {
5
+ user.id = `temp-id-${Math.random().toString(36).substring(2, 15)}`;
6
+ }
7
+ });
8
+
9
+ // Remove users without posts and their role associations
10
+ const userIdsWithPosts = new Set(
11
+ data.posts_authors.map(pa => pa.author_id)
12
+ );
13
+
14
+ data.users = data?.users?.filter(user => userIdsWithPosts.has(user.id)) || [];
15
+ if (data?.roles_users) {
16
+ data.roles_users = data?.roles_users?.filter(ru => userIdsWithPosts.has(ru.user_id)) || [];
17
+ }
18
+
19
+ return data;
20
+ };
21
+
22
+ export {
23
+ removeEmptyUsers
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-json",
3
- "version": "0.11.10",
3
+ "version": "0.11.12",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-json",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -25,11 +25,11 @@
25
25
  "jest-extended": "6.0.0"
26
26
  },
27
27
  "dependencies": {
28
- "@tryghost/string": "0.2.17",
28
+ "@tryghost/string": "0.2.21",
29
29
  "bson-objectid": "2.0.4",
30
30
  "html-entities": "2.6.0",
31
31
  "lodash": "4.17.21",
32
- "node-email-verifier": "2.0.0"
32
+ "node-email-verifier": "4.0.0"
33
33
  },
34
- "gitHead": "614571603585add8915fc853d0081208c2382a44"
34
+ "gitHead": "027225930710c0643603f6ae346dc76504d9bb7a"
35
35
  }