gatsby-source-notion-churnotion 1.1.37 → 1.1.39

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.
@@ -59,6 +59,66 @@ const createSchemaCustomization = ({ actions, schema }) => {
59
59
  description: "String!",
60
60
  },
61
61
  }),
62
+ schema.buildObjectType({
63
+ name: constants_1.NODE_TYPE.Category,
64
+ interfaces: ["Node"],
65
+ fields: {
66
+ id: "ID!",
67
+ parent: {
68
+ type: constants_1.NODE_TYPE.Category,
69
+ extensions: {
70
+ link: { by: "id", from: "parent" },
71
+ },
72
+ },
73
+ category_name: "String!",
74
+ slug: "String!",
75
+ children: {
76
+ type: `[${constants_1.NODE_TYPE.Category}!]!`,
77
+ extensions: {
78
+ link: { by: "parent", from: "id" },
79
+ },
80
+ },
81
+ churnotions: {
82
+ type: `[${constants_1.NODE_TYPE.Post}]`,
83
+ extensions: {
84
+ link: { by: "category", from: "id" },
85
+ },
86
+ },
87
+ childrenChurnotion: {
88
+ type: `[${constants_1.NODE_TYPE.Post}]`,
89
+ resolve: (source, args, context) => {
90
+ return context.nodeModel.runQuery({
91
+ query: {
92
+ filter: {
93
+ category: { eq: source.id },
94
+ },
95
+ },
96
+ type: constants_1.NODE_TYPE.Post,
97
+ firstOnly: false,
98
+ });
99
+ },
100
+ },
101
+ url: "String!",
102
+ books: {
103
+ type: `[${constants_1.NODE_TYPE.Book}]`,
104
+ extensions: {
105
+ link: { by: "id" },
106
+ },
107
+ },
108
+ childrenNBook: {
109
+ type: `[${constants_1.NODE_TYPE.Book}]`,
110
+ extensions: {
111
+ link: { by: "book_category", from: "id" },
112
+ },
113
+ },
114
+ childrenNCategory: {
115
+ type: `[${constants_1.NODE_TYPE.Category}]`,
116
+ extensions: {
117
+ link: { by: "parent", from: "id" },
118
+ },
119
+ },
120
+ },
121
+ }),
62
122
  `
63
123
  type ${constants_1.NODE_TYPE.Post} implements Node {
64
124
  id: ID!
@@ -89,22 +149,6 @@ const createSchemaCustomization = ({ actions, schema }) => {
89
149
  url: String!
90
150
  }
91
151
 
92
- type ${constants_1.NODE_TYPE.Category} implements Node {
93
- id: ID!
94
- parent: ${constants_1.NODE_TYPE.Category} @link(by: "id", from: "parent")
95
- category_name: String!
96
- slug: String!
97
- children: [${constants_1.NODE_TYPE.Category}!]! @link(by: "parent")
98
- churnotions: [${constants_1.NODE_TYPE.Post}] @link(by: "category", from: "id")
99
- url: String!
100
- books: [${constants_1.NODE_TYPE.Book}] @link(by: "id")
101
- childrenNBook: [${constants_1.NODE_TYPE.Book}] @link(by: "book_category", from: "id")
102
- }
103
-
104
- type Fields {
105
- childrenChurnotion: [${constants_1.NODE_TYPE.Post}] @link(by: "id")
106
- }
107
-
108
152
  type ${constants_1.NODE_TYPE.Metadata} implements Node {
109
153
  id: ID!,
110
154
  title: String,
@@ -3,3 +3,7 @@ export { onPluginInit } from "./onPluginInit";
3
3
  export { sourceNodes } from "./source-nodes";
4
4
  export { createSchemaCustomization } from "./createSchemaCustomization";
5
5
  export { onPostBootstrap } from "./onPostBootstrap";
6
+ export declare const createPagesStatefully: {
7
+ (...args: any[]): Promise<void>;
8
+ waitFor: string[];
9
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.onPostBootstrap = exports.createSchemaCustomization = exports.sourceNodes = exports.onPluginInit = void 0;
3
+ exports.createPagesStatefully = exports.onPostBootstrap = exports.createSchemaCustomization = exports.sourceNodes = exports.onPluginInit = void 0;
4
4
  var onPluginInit_1 = require("./onPluginInit");
5
5
  Object.defineProperty(exports, "onPluginInit", { enumerable: true, get: function () { return onPluginInit_1.onPluginInit; } });
6
6
  var source_nodes_1 = require("./source-nodes");
@@ -9,3 +9,11 @@ var createSchemaCustomization_1 = require("./createSchemaCustomization");
9
9
  Object.defineProperty(exports, "createSchemaCustomization", { enumerable: true, get: function () { return createSchemaCustomization_1.createSchemaCustomization; } });
10
10
  var onPostBootstrap_1 = require("./onPostBootstrap");
11
11
  Object.defineProperty(exports, "onPostBootstrap", { enumerable: true, get: function () { return onPostBootstrap_1.onPostBootstrap; } });
12
+ // Set priority to ensure onPostBootstrap runs before any createPages functions
13
+ const createPagesStatefully = async (...args) => {
14
+ // This is a placeholder function that does nothing
15
+ // It exists only to set the waitFor property
16
+ };
17
+ exports.createPagesStatefully = createPagesStatefully;
18
+ // Wait for onPostBootstrap to complete before running createPages
19
+ exports.createPagesStatefully.waitFor = ["onPostBootstrap"];
@@ -95,6 +95,32 @@ const onPostBootstrap = async ({ getNodesByType, actions, reporter, createNodeId
95
95
  reporter.info(`Added ${relatedPostIds.length} posts to book: ${book.book_name}`);
96
96
  });
97
97
  reporter.info(`Book-Post relationship creation completed`);
98
+ // 1.5 Category와 Post 간의 관계 설정
99
+ // Get all Category nodes
100
+ const categories = getNodesByType(constants_1.NODE_TYPE.Category);
101
+ // Create a map of category ID to related posts
102
+ const categoryPostMap = new Map();
103
+ // Populate the map
104
+ posts.forEach((post) => {
105
+ if (post.category) {
106
+ if (!categoryPostMap.has(post.category)) {
107
+ categoryPostMap.set(post.category, []);
108
+ }
109
+ categoryPostMap.get(post.category).push(post.id);
110
+ }
111
+ });
112
+ // Create explicit fields for each category
113
+ categories.forEach((category) => {
114
+ const relatedPostIds = categoryPostMap.get(category.id) || [];
115
+ // Add childrenChurnotion field explicitly
116
+ createNodeField({
117
+ node: category,
118
+ name: "childrenChurnotion",
119
+ value: relatedPostIds,
120
+ });
121
+ reporter.info(`Added ${relatedPostIds.length} posts to category: ${category.category_name}`);
122
+ });
123
+ reporter.info(`Category-Post relationship creation completed`);
98
124
  // 2. 관련 포스트 기능 구현
99
125
  reporter.info(`Creating related posts...`);
100
126
  // 유효한 텍스트가 있는 포스트 필터링
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatsby-source-notion-churnotion",
3
3
  "description": "Gatsby plugin that can connect with One Notion Database RECURSIVELY using official API",
4
- "version": "1.1.37",
4
+ "version": "1.1.39",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",