better-notion 2.1.4__py3-none-any.whl → 2.1.6__py3-none-any.whl

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.
@@ -522,7 +522,13 @@ class WorkIssueSchema:
522
522
 
523
523
  @staticmethod
524
524
  def get_schema() -> Dict[str, Dict[str, Any]]:
525
- """Return Notion database schema for Work Issues."""
525
+ """Return Notion database schema for Work Issues.
526
+
527
+ Note: The following properties are NOT included here and will be added
528
+ after database creation via database.update():
529
+ - "Blocking Tasks": Relation to Tasks (added in post-processing)
530
+ - "Caused Incidents": Relation to Incidents (Incidents created after Work Issues)
531
+ """
526
532
  return {
527
533
  "Title": PropertyBuilder.title("Title"),
528
534
  "Project": PropertyBuilder.relation("Project"),
@@ -561,10 +567,6 @@ class WorkIssueSchema:
561
567
  "Proposed Solution": PropertyBuilder.text("Proposed Solution"),
562
568
  "Related Idea": PropertyBuilder.relation("Related Idea", dual_property=False),
563
569
  "Fix Tasks": PropertyBuilder.relation("Fix Tasks", dual_property=False),
564
- # Blocking Tasks: Tasks blocked by this work issue (will be updated after database creation)
565
- "Blocking Tasks": PropertyBuilder.relation("Blocking Tasks", dual_property=False),
566
- # Caused Incidents: Incidents caused by this work issue (will be updated after database creation)
567
- "Caused Incidents": PropertyBuilder.relation("Caused Incidents", dual_property=False),
568
570
  }
569
571
 
570
572
 
@@ -573,7 +575,11 @@ class IncidentSchema:
573
575
 
574
576
  @staticmethod
575
577
  def get_schema() -> Dict[str, Dict[str, Any]]:
576
- """Return Notion database schema for Incidents."""
578
+ """Return Notion database schema for Incidents.
579
+
580
+ Note: "Root Cause Work Issue" is NOT included here and will be added
581
+ after database creation via database.update() for consistency.
582
+ """
577
583
  return {
578
584
  "Title": PropertyBuilder.title("Title"),
579
585
  "Project": PropertyBuilder.relation("Project"),
@@ -607,8 +613,6 @@ class IncidentSchema:
607
613
  ],
608
614
  ),
609
615
  "Fix Task": PropertyBuilder.relation("Fix Task", dual_property=False),
610
- # Root Cause Work Issue: Relation to Work Issues (will be updated after database creation)
611
- "Root Cause Work Issue": PropertyBuilder.relation("Root Cause Work Issue", dual_property=False),
612
616
  "Root Cause": PropertyBuilder.text("Root Cause"),
613
617
  "Detected Date": PropertyBuilder.date("Detected Date"),
614
618
  "Resolved Date": PropertyBuilder.date("Resolved Date"),
@@ -142,15 +142,29 @@ class WorkspaceInitializer:
142
142
  except Exception as e:
143
143
  # Clean up databases created so far
144
144
  import traceback
145
- logger.error(f"Failed to create {display_name} database: {str(e)}")
146
- logger.error(f"Full traceback:\n{traceback.format_exc()}")
145
+ import sys
146
+
147
+ # Log to stderr for visibility
148
+ print(f"\n{'='*60}", file=sys.stderr)
149
+ print(f"❌ FAILED TO CREATE: {display_name} database", file=sys.stderr)
150
+ print(f"{'='*60}", file=sys.stderr)
151
+ print(f"Error: {str(e)}", file=sys.stderr)
152
+ print(f"\nFull traceback:", file=sys.stderr)
153
+ traceback.print_exc(file=sys.stderr)
147
154
 
148
155
  # Try to get more error details if available
149
156
  error_details = str(e)
150
157
  if hasattr(e, 'response') and hasattr(e.response, 'text'):
151
- logger.error(f"Notion API response: {e.response.text}")
158
+ print(f"\nNotion API response:", file=sys.stderr)
159
+ print(f"{e.response.text}", file=sys.stderr)
152
160
  error_details += f"\nNotion API response: {e.response.text}"
153
161
 
162
+ print(f"\nDatabases created before failure: {list(self._database_ids.keys())}", file=sys.stderr)
163
+ print(f"{'='*60}\n", file=sys.stderr)
164
+
165
+ logger.error(f"Failed to create {display_name} database: {str(e)}")
166
+ logger.error(f"Full traceback:\n{traceback.format_exc()}")
167
+
154
168
  logger.warning(f"Cleaning up {len(self._database_ids)} databases that were created...")
155
169
  await self._delete_existing_databases(parent, self._database_ids)
156
170
 
@@ -403,11 +417,13 @@ class WorkspaceInitializer:
403
417
  async def _update_cross_database_relations(self) -> None:
404
418
  """Update cross-database relations after all databases are created.
405
419
 
406
- This updates:
407
- - Tasks: Related Work Issue -> Work Issues
408
- - Work Issues: Blocking Tasks -> Tasks
409
- - Work Issues: Caused Incidents -> Incidents
420
+ This adds:
421
+ - Tasks: Dependencies (self-referential), Related Work Issue -> Work Issues
422
+ - Work Issues: Blocking Tasks -> Tasks, Caused Incidents -> Incidents
410
423
  - Incidents: Root Cause Work Issue -> Work Issues
424
+
425
+ All these properties are added AFTER database creation because they
426
+ reference databases that may not exist yet during initial creation.
411
427
  """
412
428
  if "tasks" in self._database_ids:
413
429
  await self._update_relation(
@@ -491,6 +507,42 @@ class WorkspaceInitializer:
491
507
  }
492
508
  }
493
509
  }
510
+ elif property_name == "Blocking Tasks":
511
+ # Relation from Work Issues to Tasks
512
+ schema[property_name] = {
513
+ "relation": {
514
+ "database_id": target_database_id,
515
+ "type": "dual_property",
516
+ "dual_property": {
517
+ "synced_property_name": "Blocked By Work Issue",
518
+ "synced_property_type": "relation"
519
+ }
520
+ }
521
+ }
522
+ elif property_name == "Caused Incidents":
523
+ # Relation from Work Issues to Incidents
524
+ schema[property_name] = {
525
+ "relation": {
526
+ "database_id": target_database_id,
527
+ "type": "dual_property",
528
+ "dual_property": {
529
+ "synced_property_name": "Root Cause Work Issue",
530
+ "synced_property_type": "relation"
531
+ }
532
+ }
533
+ }
534
+ elif property_name == "Root Cause Work Issue":
535
+ # Relation from Incidents to Work Issues
536
+ schema[property_name] = {
537
+ "relation": {
538
+ "database_id": target_database_id,
539
+ "type": "dual_property",
540
+ "dual_property": {
541
+ "synced_property_name": "Caused Incidents",
542
+ "synced_property_type": "relation"
543
+ }
544
+ }
545
+ }
494
546
  else:
495
547
  # Generic relation
496
548
  schema[property_name] = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: better-notion
3
- Version: 2.1.4
3
+ Version: 2.1.6
4
4
  Summary: A high-level Python SDK for the Notion API with developer experience in mind.
5
5
  Project-URL: Homepage, https://github.com/nesalia-inc/better-notion
6
6
  Project-URL: Documentation, https://github.com/nesalia-inc/better-notion#readme
@@ -130,11 +130,11 @@ better_notion/utils/agents/dependency_resolver.py,sha256=PfHHDIQztGih4LwylMb0_My
130
130
  better_notion/utils/agents/metadata.py,sha256=thQSXfYx9mWgmBud8HtlNTLr5SwH6E_O1AjSNSnMFoo,6614
131
131
  better_notion/utils/agents/project_context.py,sha256=aJlzy5H2rL4sAfW2jHL_3K2VkBJ4ihUhCRVolkpuO78,7477
132
132
  better_notion/utils/agents/rbac.py,sha256=8ZA8Y7wbOiVZDbpjpH7iC35SZrZ0jl4fcJ3xWCm3SsE,11820
133
- better_notion/utils/agents/schemas.py,sha256=NVrNxiQmBbUvjF03UirGr8GZF7jl4arqL6F3JCalH1E,22873
133
+ better_notion/utils/agents/schemas.py,sha256=2QF71tL-lt_n7u-oizVDMj4nd29fl8uUbhMKTWxNzr4,22721
134
134
  better_notion/utils/agents/state_machine.py,sha256=xUBEeDTbU1Xq-rsRo2sbr6AUYpYrV9DTHOtZT2cWES8,6699
135
- better_notion/utils/agents/workspace.py,sha256=3FBoD3p1WQ0LTX0Nl1ahlAMI3ep0HxLy8qg-2E2YGNI,23182
136
- better_notion-2.1.4.dist-info/METADATA,sha256=y1wGfmPtKsfugifAJEalb4WJNEFh5mdLgonDyq7pNWE,11096
137
- better_notion-2.1.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
138
- better_notion-2.1.4.dist-info/entry_points.txt,sha256=D0bUcP7Z00Zyjxw7r2p29T95UrwioDO0aGDoHe9I6fo,55
139
- better_notion-2.1.4.dist-info/licenses/LICENSE,sha256=BAdN3JpgMY_y_fWqZSCFSvSbC2mTHP-BKDAzF5FXQAI,1069
140
- better_notion-2.1.4.dist-info/RECORD,,
135
+ better_notion/utils/agents/workspace.py,sha256=21T0aQ2MYq60jJvaBvcdUCHZT7JENZ-4VciS5Z-5_X0,25736
136
+ better_notion-2.1.6.dist-info/METADATA,sha256=MYHP3_45OizHx44DSa7COKpPa2ByMkZXnx9966IYv9o,11096
137
+ better_notion-2.1.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
138
+ better_notion-2.1.6.dist-info/entry_points.txt,sha256=D0bUcP7Z00Zyjxw7r2p29T95UrwioDO0aGDoHe9I6fo,55
139
+ better_notion-2.1.6.dist-info/licenses/LICENSE,sha256=BAdN3JpgMY_y_fWqZSCFSvSbC2mTHP-BKDAzF5FXQAI,1069
140
+ better_notion-2.1.6.dist-info/RECORD,,