django-notion-sync 0.1.0__tar.gz

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.
Files changed (76) hide show
  1. django_notion_sync-0.1.0/.gitignore +226 -0
  2. django_notion_sync-0.1.0/CHANGELOG.md +61 -0
  3. django_notion_sync-0.1.0/LICENSE +21 -0
  4. django_notion_sync-0.1.0/PKG-INFO +707 -0
  5. django_notion_sync-0.1.0/README.md +672 -0
  6. django_notion_sync-0.1.0/pyproject.toml +138 -0
  7. django_notion_sync-0.1.0/src/notion_sync/__init__.py +5 -0
  8. django_notion_sync-0.1.0/src/notion_sync/admin.py +193 -0
  9. django_notion_sync-0.1.0/src/notion_sync/api.py +106 -0
  10. django_notion_sync-0.1.0/src/notion_sync/apps.py +27 -0
  11. django_notion_sync-0.1.0/src/notion_sync/checks.py +145 -0
  12. django_notion_sync-0.1.0/src/notion_sync/client.py +217 -0
  13. django_notion_sync-0.1.0/src/notion_sync/conf.py +160 -0
  14. django_notion_sync-0.1.0/src/notion_sync/exceptions.py +105 -0
  15. django_notion_sync-0.1.0/src/notion_sync/files.py +173 -0
  16. django_notion_sync-0.1.0/src/notion_sync/inbound.py +381 -0
  17. django_notion_sync-0.1.0/src/notion_sync/management/__init__.py +0 -0
  18. django_notion_sync-0.1.0/src/notion_sync/management/commands/__init__.py +0 -0
  19. django_notion_sync-0.1.0/src/notion_sync/management/commands/notion_sync_check.py +111 -0
  20. django_notion_sync-0.1.0/src/notion_sync/management/commands/notion_sync_drain.py +49 -0
  21. django_notion_sync-0.1.0/src/notion_sync/management/commands/notion_sync_process_webhooks.py +26 -0
  22. django_notion_sync-0.1.0/src/notion_sync/management/commands/notion_sync_prune.py +26 -0
  23. django_notion_sync-0.1.0/src/notion_sync/management/commands/notion_sync_reconcile.py +73 -0
  24. django_notion_sync-0.1.0/src/notion_sync/management/commands/notion_sync_webhook_token.py +33 -0
  25. django_notion_sync-0.1.0/src/notion_sync/mapping.py +501 -0
  26. django_notion_sync-0.1.0/src/notion_sync/migrations/0001_initial.py +101 -0
  27. django_notion_sync-0.1.0/src/notion_sync/migrations/0002_model_syncs.py +58 -0
  28. django_notion_sync-0.1.0/src/notion_sync/migrations/0003_webhook_event.py +69 -0
  29. django_notion_sync-0.1.0/src/notion_sync/migrations/__init__.py +0 -0
  30. django_notion_sync-0.1.0/src/notion_sync/models.py +168 -0
  31. django_notion_sync-0.1.0/src/notion_sync/outbox.py +442 -0
  32. django_notion_sync-0.1.0/src/notion_sync/pages.py +217 -0
  33. django_notion_sync-0.1.0/src/notion_sync/py.typed +0 -0
  34. django_notion_sync-0.1.0/src/notion_sync/records.py +43 -0
  35. django_notion_sync-0.1.0/src/notion_sync/schema.py +52 -0
  36. django_notion_sync-0.1.0/src/notion_sync/signals.py +56 -0
  37. django_notion_sync-0.1.0/src/notion_sync/sync.py +213 -0
  38. django_notion_sync-0.1.0/src/notion_sync/tasks.py +86 -0
  39. django_notion_sync-0.1.0/src/notion_sync/templates/admin/notion_sync/webhookevent/change_list.html +8 -0
  40. django_notion_sync-0.1.0/src/notion_sync/templates/admin/notion_sync/webhookevent/verification_token.html +39 -0
  41. django_notion_sync-0.1.0/src/notion_sync/urls.py +12 -0
  42. django_notion_sync-0.1.0/src/notion_sync/values.py +455 -0
  43. django_notion_sync-0.1.0/src/notion_sync/views.py +15 -0
  44. django_notion_sync-0.1.0/src/notion_sync/webhooks.py +451 -0
  45. django_notion_sync-0.1.0/tests/__init__.py +0 -0
  46. django_notion_sync-0.1.0/tests/celery_app.py +12 -0
  47. django_notion_sync-0.1.0/tests/conftest.py +153 -0
  48. django_notion_sync-0.1.0/tests/fake_notion.py +291 -0
  49. django_notion_sync-0.1.0/tests/live/__init__.py +0 -0
  50. django_notion_sync-0.1.0/tests/live/conftest.py +86 -0
  51. django_notion_sync-0.1.0/tests/live/test_inbound_live.py +122 -0
  52. django_notion_sync-0.1.0/tests/live/test_live.py +260 -0
  53. django_notion_sync-0.1.0/tests/settings.py +106 -0
  54. django_notion_sync-0.1.0/tests/test_admin.py +125 -0
  55. django_notion_sync-0.1.0/tests/test_api.py +331 -0
  56. django_notion_sync-0.1.0/tests/test_app.py +93 -0
  57. django_notion_sync-0.1.0/tests/test_celery.py +135 -0
  58. django_notion_sync-0.1.0/tests/test_checks.py +142 -0
  59. django_notion_sync-0.1.0/tests/test_client.py +176 -0
  60. django_notion_sync-0.1.0/tests/test_commands.py +206 -0
  61. django_notion_sync-0.1.0/tests/test_conf.py +106 -0
  62. django_notion_sync-0.1.0/tests/test_env_file.py +36 -0
  63. django_notion_sync-0.1.0/tests/test_inbound.py +439 -0
  64. django_notion_sync-0.1.0/tests/test_mapping.py +166 -0
  65. django_notion_sync-0.1.0/tests/test_migrations.py +8 -0
  66. django_notion_sync-0.1.0/tests/test_outbox.py +645 -0
  67. django_notion_sync-0.1.0/tests/test_sdk_http.py +69 -0
  68. django_notion_sync-0.1.0/tests/test_sync.py +587 -0
  69. django_notion_sync-0.1.0/tests/test_values.py +380 -0
  70. django_notion_sync-0.1.0/tests/test_webhooks.py +1034 -0
  71. django_notion_sync-0.1.0/tests/testapp/__init__.py +0 -0
  72. django_notion_sync-0.1.0/tests/testapp/migrations/0001_initial.py +158 -0
  73. django_notion_sync-0.1.0/tests/testapp/migrations/__init__.py +0 -0
  74. django_notion_sync-0.1.0/tests/testapp/models.py +51 -0
  75. django_notion_sync-0.1.0/tests/testapp/notion_mappings.py +30 -0
  76. django_notion_sync-0.1.0/tests/urls.py +7 -0
@@ -0,0 +1,226 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # uv
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule*
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Conda environments
163
+ conda-meta/
164
+
165
+ # Spyder project settings
166
+ .spyderproject
167
+ .spyproject
168
+
169
+ # Rope project settings
170
+ .ropeproject
171
+
172
+ # mkdocs/Zensical documentation
173
+ /site
174
+
175
+ # mypy
176
+ .mypy_cache/
177
+ .dmypy.json
178
+ dmypy.json
179
+
180
+ # Pyre type checker
181
+ .pyre/
182
+
183
+ # pytype static type analyzer
184
+ .pytype/
185
+
186
+ # Cython debug symbols
187
+ cython_debug/
188
+
189
+ # PyCharm
190
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
191
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
192
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
193
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
194
+ # .idea/
195
+
196
+ # Abstra
197
+ # Abstra is an AI-powered process automation framework.
198
+ # Ignore directories containing user credentials, local state, and settings.
199
+ # Learn more at https://abstra.io/docs
200
+ .abstra/
201
+
202
+ # Visual Studio Code
203
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
204
+ # can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
205
+ # and can be added to the global gitignore or merged into this file. However, if you prefer, you
206
+ # could uncomment the following to ignore the entire vscode folder
207
+ # .vscode/
208
+ # Temporary file for partial code execution
209
+ tempCodeRunnerFile.py
210
+
211
+ # Ruff stuff:
212
+ .ruff_cache/
213
+
214
+ # PyPI configuration file
215
+ .pypirc
216
+
217
+ # Marimo
218
+ marimo/_static/
219
+ marimo/_lsp/
220
+ __marimo__/
221
+
222
+ # Streamlit
223
+ .streamlit/secrets.toml
224
+
225
+ # Local planning docs
226
+ plans/
@@ -0,0 +1,61 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-11-25
10
+
11
+ First public release.
12
+
13
+ ### Added
14
+
15
+ - Writing pages: `notion_sync.api.create_page`, `update_page`, `upsert_page`,
16
+ `archive_page` and `get_page`, taking plain Python values converted by the
17
+ data source's schema.
18
+ - File attachments through `NotionFile`, uploaded with Notion's upload API.
19
+ - The outbox: `enqueue_create`, `enqueue_update`, `enqueue_upsert` and
20
+ `enqueue_archive`, with backoff, an attempt cap and a guard against
21
+ duplicate pages after a lost response. Rows end as `sent`, `failed`,
22
+ `needs_review` or `skipped`.
23
+ - Model sync: `NotionSyncMixin` stores a record's page ID, with
24
+ `sync_to_notion()` and `enqueue_notion_sync()`. A queued sync stores a
25
+ reference and reads values when sent, and a record has at most one pending
26
+ row.
27
+ - Declarative mappings: `@notion_sync.register(Model)` with `Out()` and
28
+ `In()` fields, found in each app's `notion_mappings.py`, with `auto_sync`,
29
+ `on_delete = "archive"` and `on_notion_trash` (`"unlink"` or `"delete"`).
30
+ - Inbound sync: `In()` fields are written back from Notion. Pages are always
31
+ fetched fresh, older states are skipped, and the save names only `In`
32
+ fields, so it never queues a sync back to Notion.
33
+ - A webhook endpoint, `include("notion_sync.urls")`. It checks
34
+ `X-Notion-Signature` against each target's `WEBHOOK_VERIFICATION_TOKEN`,
35
+ routes events by the page's data source, ignores repeated events and events
36
+ older than 48 hours, and acts on `page.created`, `page.properties_updated`,
37
+ `page.moved`, `page.deleted` and `page.undeleted`.
38
+ - `WEBHOOK_PROCESSING = "stored"`: events are saved as `WebhookEvent` rows and
39
+ processed later, with backoff and an attempt cap.
40
+ - Management commands: `notion_sync_check` (calls Notion to check targets and
41
+ mappings), `notion_sync_drain`, `notion_sync_process_webhooks`,
42
+ `notion_sync_reconcile [--target] [--since | --all]`, `notion_sync_prune`
43
+ (outbox rows and processed webhook events) and `notion_sync_webhook_token`.
44
+ - The `celery` extra: tasks `drain_outbox`, `send_outbox_item`,
45
+ `process_webhook_event`, `process_webhook_events` and `reconcile`, with
46
+ `DISPATCH = "celery"` sending each row as soon as it commits.
47
+ - Signals `page_synced`, `sync_failed`, `page_changed` and `page_trashed`.
48
+ - Admin for the outbox, with a retry action, and a read-only admin for webhook
49
+ events, with a superuser-only page showing the webhook handshake token.
50
+ - The `NOTION_SYNC` setting with named targets.
51
+ - Django system checks, `notion_sync.E001` to `E004` and `W001` to `W002`, for
52
+ the setting, mapping targets, Celery dispatch and the webhook cache. They
53
+ run offline. A clear `ImproperlyConfigured` at startup when
54
+ `django.contrib.contenttypes` is not installed.
55
+ - Type hints: the package ships `py.typed`, and its public modules are fully
56
+ typed and checked with mypy.
57
+ - A documented public API and deprecation policy in the README. Each public
58
+ module defines `__all__`.
59
+
60
+ [Unreleased]: https://github.com/layline-dev/django-notion-sync/compare/v0.1.0...HEAD
61
+ [0.1.0]: https://github.com/layline-dev/django-notion-sync/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Layline LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.