npm package: @jiahaoshao1/notion-lifeos-fixer
Description: Automatically fix database relations after duplicating LifeOS template
Author: Jiahao Shao
Latest version: 1.0.2

# Notion LifeOS Relation Fixer

Automatically fix database relations after duplicating the LifeOS template.

## Problem

When you duplicate a Notion template with multiple databases and relations between them, all the relation properties break because they reference the old database IDs.

This tool automatically scans your duplicated LifeOS page, finds all databases, and rebuilds the relations between them.

## Installation

```bash
npx @jiahaoshao1/notion-lifeos-fixer <page_url> [api_key]
```

No installation needed! Just use `npx` to run it directly.

## Usage

### Step 1: Duplicate the LifeOS Template

Go to the [LifeOS Template](https://www.notion.so/LifeOS-Template-2f6119f193ef80c88aaffeb3286ff632) and click "Duplicate" in the top right corner.

### Step 2: Get Your Notion API Key

1. Go to [Notion Integrations](https://www.notion.so/my-integrations)
2. Click "+ New integration"
3. Give it a name (e.g., "LifeOS Fixer")
4. Copy the "Internal Integration Token"

### Step 3: Share Your Page with the Integration

1. Open your duplicated LifeOS page
2. Click "Share" in the top right
3. Click "Invite"
4. Search for your integration name and select it

### Step 4: Run the Fixer

```bash
npx @jiahaoshao1/notion-lifeos-fixer https://www.notion.so/Your-LifeOS-Page-abc123 secret_your_api_key
```

Or set the API key as an environment variable:

```bash
export NOTION_API_KEY=secret_your_api_key
npx @jiahaoshao1/notion-lifeos-fixer https://www.notion.so/Your-LifeOS-Page-abc123
```

## What It Does

The fixer will:

1. Scan your page for all child databases
2. Identify each database by name (Task Database, Notes Database, etc.)
3. Rebuild all relation properties according to the LifeOS schema:
   - Task → Projects, Notes
   - Notes → Projects, Areas, Resources
   - Projects → Notes, Areas, Resources
   - Resources → Projects, Notes, Areas
   - Areas → Notes, Resources
   - Make Time → (no relations)

## Example Output

```
🚀 Starting LifeOS Relation Fixer

📄 Page ID: 2f6119f193ef80c88aaffeb3286ff632

📊 Scanning databases...
  ✓ Found: Task Database (abc123...)
  ✓ Found: Notes Database (def456...)
  ✓ Found: Projects Database (ghi789...)
  ✓ Found: Resources Database (jkl012...)
  ✓ Found: Areas Database (mno345...)
  ✓ Found: Make Time Database (pqr678...)

🔗 Updating relations...
  🔧 Task Database:
    ✓ Related to Projects → Projects Database
    ✓ Related to Notes → Notes Database
  🔧 Notes Database:
    ✓ Related to Projects → Projects Database
    ✓ Related to Areas → Areas Database
    ✓ Related Resources → Resources Database
  ...

✅ All relations fixed successfully!
```

## Troubleshooting

### "NOTION_API_KEY not found"

Make sure you either:
- Pass the API key as the second argument
- Set the `NOTION_API_KEY` environment variable

### "No databases found in this page"

Make sure:
- You're using the URL of the duplicated page (not the original template)
- The page contains the LifeOS databases as child databases
- You've shared the page with your integration

### "Invalid Notion page URL"

The URL should look like:
- `https://www.notion.so/LifeOS-2f6119f193ef80c88aaffeb3286ff632`
- `https://www.notion.so/2f6119f193ef80c88aaffeb3286ff632`

## License

MIT

## Author

Jiahao Shao