cmsdk 1.0.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 (38) hide show
  1. cmsdk-1.0.0/PKG-INFO +137 -0
  2. cmsdk-1.0.0/README.md +111 -0
  3. cmsdk-1.0.0/cmsdk/__init__.py +93 -0
  4. cmsdk-1.0.0/cmsdk/core/__init__.py +12 -0
  5. cmsdk-1.0.0/cmsdk/core/base_view.py +481 -0
  6. cmsdk-1.0.0/cmsdk/core/jsonapp.py +302 -0
  7. cmsdk-1.0.0/cmsdk/errors/__init__.py +66 -0
  8. cmsdk-1.0.0/cmsdk/errors/exceptions.py +427 -0
  9. cmsdk-1.0.0/cmsdk/types/__init__.py +100 -0
  10. cmsdk-1.0.0/cmsdk/types/models.py +437 -0
  11. cmsdk-1.0.0/cmsdk/utils/__init__.py +14 -0
  12. cmsdk-1.0.0/cmsdk/utils/file_formats.py +202 -0
  13. cmsdk-1.0.0/cmsdk/utils/validators.py +751 -0
  14. cmsdk-1.0.0/cmsdk/views/__init__.py +32 -0
  15. cmsdk-1.0.0/cmsdk/views/action_grid_view.py +115 -0
  16. cmsdk-1.0.0/cmsdk/views/action_list_view.py +88 -0
  17. cmsdk-1.0.0/cmsdk/views/base_action_view.py +163 -0
  18. cmsdk-1.0.0/cmsdk/views/card_view.py +143 -0
  19. cmsdk-1.0.0/cmsdk/views/carousel_view.py +189 -0
  20. cmsdk-1.0.0/cmsdk/views/form_view.py +474 -0
  21. cmsdk-1.0.0/cmsdk/views/map_view.py +142 -0
  22. cmsdk-1.0.0/cmsdk/views/media_view.py +112 -0
  23. cmsdk-1.0.0/cmsdk/views/message_view.py +106 -0
  24. cmsdk-1.0.0/cmsdk/views/qr_display_view.py +88 -0
  25. cmsdk-1.0.0/cmsdk/views/qr_scan_view.py +157 -0
  26. cmsdk-1.0.0/cmsdk/views/reader_view.py +270 -0
  27. cmsdk-1.0.0/cmsdk/views/timeline_view.py +108 -0
  28. cmsdk-1.0.0/cmsdk.egg-info/PKG-INFO +137 -0
  29. cmsdk-1.0.0/cmsdk.egg-info/SOURCES.txt +36 -0
  30. cmsdk-1.0.0/cmsdk.egg-info/dependency_links.txt +1 -0
  31. cmsdk-1.0.0/cmsdk.egg-info/requires.txt +10 -0
  32. cmsdk-1.0.0/cmsdk.egg-info/top_level.txt +2 -0
  33. cmsdk-1.0.0/pyproject.toml +60 -0
  34. cmsdk-1.0.0/setup.cfg +4 -0
  35. cmsdk-1.0.0/tests/test_form_view.py +148 -0
  36. cmsdk-1.0.0/tests/test_intro_fields.py +69 -0
  37. cmsdk-1.0.0/tests/test_jsonapp.py +106 -0
  38. cmsdk-1.0.0/tests/test_validators.py +70 -0
cmsdk-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: cmsdk
3
+ Version: 1.0.0
4
+ Summary: A modern Python SDK for generating dynamic JSON interfaces
5
+ Author: JsonApp Team
6
+ License: MIT
7
+ Keywords: json,interface,form-builder,sdk,dynamic-ui,mobile-apps
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: cryptography>=41.0.0
18
+ Requires-Dist: markdown>=3.4.0
19
+ Requires-Dist: bleach>=6.0.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
22
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
23
+ Requires-Dist: black>=23.0.0; extra == "dev"
24
+ Requires-Dist: mypy>=1.5.0; extra == "dev"
25
+ Requires-Dist: ruff>=0.0.280; extra == "dev"
26
+
27
+ # JSONApp Python SDK
28
+
29
+ > **Note**: This is the Python port of the JSONApp SDK. This repository is a monorepo containing multiple language implementations. See the [root README](../README.md) for an overview.
30
+
31
+ A stateless backend library for building views that are sent to renderers (mobile or web). This is the Python port of the TypeScript JSONApp SDK.
32
+
33
+ ## Features
34
+
35
+ - **Stateless Architecture**: No internal state, perfect for serverless and microservices
36
+ - **Ed25519 Signing**: Secure view signing and verification using Ed25519 cryptography
37
+ - **12 View Types**: Form, Reader, ActionList, ActionGrid, QRScan, QRDisplay, Message, Card, Carousel, Timeline, Media, Map
38
+ - **Type Safety**: Full type definitions using Python dataclasses and type hints
39
+ - **Validation**: Built-in field and form validation
40
+ - **Security**: XSS protection, URL validation, input sanitization
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install -r requirements.txt
46
+ ```
47
+
48
+ ## Quick Start
49
+
50
+ ```python
51
+ from jsonapp import JsonApp, JsonAppConfig
52
+ from jsonapp.views import FormView
53
+
54
+ # Initialize JsonApp
55
+ config = JsonAppConfig(
56
+ app_id="my-app",
57
+ view_expiration_minutes=60,
58
+ )
59
+ app = JsonApp(config)
60
+
61
+ # Create a form view
62
+ form = app.create_form_view("registration", "User Registration")
63
+ form.add_text_field("name", "Full Name", is_required=True)
64
+ form.add_email_field("email", "Email", is_required=True)
65
+ form.submit_button("Register")
66
+
67
+ # Serve with signature
68
+ response = app.serve(form)
69
+ print(response.view) # The view JSON
70
+ print(response.signature) # Ed25519 signature
71
+ ```
72
+
73
+ ## View Types
74
+
75
+ ### FormView
76
+ Create forms with various field types (text, email, password, select, file, GPS, etc.)
77
+
78
+ ### ReaderView
79
+ Display rich content with paragraphs, images, markdown, tables, code blocks, etc.
80
+
81
+ ### ActionListView / ActionGridView
82
+ Display lists or grids of actions
83
+
84
+ ### QRScanView / QRDisplayView
85
+ QR code scanning and display
86
+
87
+ ### MessageView
88
+ Display messages with actions
89
+
90
+ ### CardView
91
+ Display card-based content with stats and sections
92
+
93
+ ### CarouselView
94
+ Display carousel slides
95
+
96
+ ### TimelineView
97
+ Display chronological events
98
+
99
+ ### MediaView
100
+ Display audio and video playlists
101
+
102
+ ### MapView
103
+ Display geographic data on maps
104
+
105
+ ## API Parity
106
+
107
+ The Python SDK maintains API parity with the TypeScript version:
108
+
109
+ - Same factory methods: `app.create_form_view()`, `app.create_reader_view()`, etc.
110
+ - Same fluent API: `view.add_field().set_intro().submit_button()` (or `set_note()` for backward compatibility)
111
+ - Same validation and security features
112
+ - Same Ed25519 signing and verification
113
+
114
+ ## Examples
115
+
116
+ See `examples/basic_usage.py` for a complete example.
117
+
118
+ ## Requirements
119
+
120
+ - Python 3.10+
121
+ - cryptography (for Ed25519)
122
+ - markdown (for ReaderView markdown support)
123
+ - bleach (for HTML sanitization)
124
+
125
+ ## Status
126
+
127
+ ✅ Core classes (BaseView, JsonApp)
128
+ ✅ All 12 view types
129
+ ✅ Type definitions
130
+ ✅ Error handling
131
+ ✅ Validation utilities
132
+ ✅ Ed25519 signing/verification
133
+ ✅ Examples
134
+
135
+ ## License
136
+
137
+ Same as the TypeScript SDK.
cmsdk-1.0.0/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # JSONApp Python SDK
2
+
3
+ > **Note**: This is the Python port of the JSONApp SDK. This repository is a monorepo containing multiple language implementations. See the [root README](../README.md) for an overview.
4
+
5
+ A stateless backend library for building views that are sent to renderers (mobile or web). This is the Python port of the TypeScript JSONApp SDK.
6
+
7
+ ## Features
8
+
9
+ - **Stateless Architecture**: No internal state, perfect for serverless and microservices
10
+ - **Ed25519 Signing**: Secure view signing and verification using Ed25519 cryptography
11
+ - **12 View Types**: Form, Reader, ActionList, ActionGrid, QRScan, QRDisplay, Message, Card, Carousel, Timeline, Media, Map
12
+ - **Type Safety**: Full type definitions using Python dataclasses and type hints
13
+ - **Validation**: Built-in field and form validation
14
+ - **Security**: XSS protection, URL validation, input sanitization
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install -r requirements.txt
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```python
25
+ from jsonapp import JsonApp, JsonAppConfig
26
+ from jsonapp.views import FormView
27
+
28
+ # Initialize JsonApp
29
+ config = JsonAppConfig(
30
+ app_id="my-app",
31
+ view_expiration_minutes=60,
32
+ )
33
+ app = JsonApp(config)
34
+
35
+ # Create a form view
36
+ form = app.create_form_view("registration", "User Registration")
37
+ form.add_text_field("name", "Full Name", is_required=True)
38
+ form.add_email_field("email", "Email", is_required=True)
39
+ form.submit_button("Register")
40
+
41
+ # Serve with signature
42
+ response = app.serve(form)
43
+ print(response.view) # The view JSON
44
+ print(response.signature) # Ed25519 signature
45
+ ```
46
+
47
+ ## View Types
48
+
49
+ ### FormView
50
+ Create forms with various field types (text, email, password, select, file, GPS, etc.)
51
+
52
+ ### ReaderView
53
+ Display rich content with paragraphs, images, markdown, tables, code blocks, etc.
54
+
55
+ ### ActionListView / ActionGridView
56
+ Display lists or grids of actions
57
+
58
+ ### QRScanView / QRDisplayView
59
+ QR code scanning and display
60
+
61
+ ### MessageView
62
+ Display messages with actions
63
+
64
+ ### CardView
65
+ Display card-based content with stats and sections
66
+
67
+ ### CarouselView
68
+ Display carousel slides
69
+
70
+ ### TimelineView
71
+ Display chronological events
72
+
73
+ ### MediaView
74
+ Display audio and video playlists
75
+
76
+ ### MapView
77
+ Display geographic data on maps
78
+
79
+ ## API Parity
80
+
81
+ The Python SDK maintains API parity with the TypeScript version:
82
+
83
+ - Same factory methods: `app.create_form_view()`, `app.create_reader_view()`, etc.
84
+ - Same fluent API: `view.add_field().set_intro().submit_button()` (or `set_note()` for backward compatibility)
85
+ - Same validation and security features
86
+ - Same Ed25519 signing and verification
87
+
88
+ ## Examples
89
+
90
+ See `examples/basic_usage.py` for a complete example.
91
+
92
+ ## Requirements
93
+
94
+ - Python 3.10+
95
+ - cryptography (for Ed25519)
96
+ - markdown (for ReaderView markdown support)
97
+ - bleach (for HTML sanitization)
98
+
99
+ ## Status
100
+
101
+ ✅ Core classes (BaseView, JsonApp)
102
+ ✅ All 12 view types
103
+ ✅ Type definitions
104
+ ✅ Error handling
105
+ ✅ Validation utilities
106
+ ✅ Ed25519 signing/verification
107
+ ✅ Examples
108
+
109
+ ## License
110
+
111
+ Same as the TypeScript SDK.
@@ -0,0 +1,93 @@
1
+ """
2
+ JSONApp SDK for Python
3
+ A stateless backend library for building views that are sent to renderers (mobile or web)
4
+ """
5
+
6
+ from .core.jsonapp import JsonApp, JsonAppConfig, SecureViewResponse
7
+ from .core.base_view import BaseView
8
+ from .views import (
9
+ FormView,
10
+ ReaderView,
11
+ ActionListView,
12
+ ActionGridView,
13
+ QRScanView,
14
+ QRDisplayView,
15
+ MessageView,
16
+ CardView,
17
+ CarouselView,
18
+ TimelineView,
19
+ MediaView,
20
+ MapView,
21
+ )
22
+ from .errors import (
23
+ JsonAppError,
24
+ ValidationError,
25
+ FieldValidationError,
26
+ SecurityError,
27
+ SignatureVerificationError,
28
+ ViewExpiredError,
29
+ AppIdMismatchError,
30
+ ConfigurationError,
31
+ MissingRequiredParameterError,
32
+ InvalidParameterError,
33
+ DataError,
34
+ FieldNotFoundError,
35
+ ActionNotFoundError,
36
+ ElementNotFoundError,
37
+ EmptyCollectionError,
38
+ ViewError,
39
+ ViewNotFoundError,
40
+ ViewValidationError,
41
+ MaxViewsExceededError,
42
+ ExternalError,
43
+ MarkdownParseError,
44
+ NoProcessContextError,
45
+ ERROR_CODES,
46
+ )
47
+
48
+ __version__ = "3.0.0"
49
+
50
+ __all__ = [
51
+ # Core classes
52
+ "JsonApp",
53
+ "JsonAppConfig",
54
+ "SecureViewResponse",
55
+ "BaseView",
56
+ # View classes
57
+ "FormView",
58
+ "ReaderView",
59
+ "ActionListView",
60
+ "ActionGridView",
61
+ "QRScanView",
62
+ "QRDisplayView",
63
+ "MessageView",
64
+ "CardView",
65
+ "CarouselView",
66
+ "TimelineView",
67
+ "MediaView",
68
+ "MapView",
69
+ # Error classes
70
+ "JsonAppError",
71
+ "ValidationError",
72
+ "FieldValidationError",
73
+ "SecurityError",
74
+ "SignatureVerificationError",
75
+ "ViewExpiredError",
76
+ "AppIdMismatchError",
77
+ "ConfigurationError",
78
+ "MissingRequiredParameterError",
79
+ "InvalidParameterError",
80
+ "DataError",
81
+ "FieldNotFoundError",
82
+ "ActionNotFoundError",
83
+ "ElementNotFoundError",
84
+ "EmptyCollectionError",
85
+ "ViewError",
86
+ "ViewNotFoundError",
87
+ "ViewValidationError",
88
+ "MaxViewsExceededError",
89
+ "ExternalError",
90
+ "MarkdownParseError",
91
+ "NoProcessContextError",
92
+ "ERROR_CODES",
93
+ ]
@@ -0,0 +1,12 @@
1
+ """Core classes for JSONApp SDK"""
2
+
3
+ from .base_view import BaseView
4
+ from .jsonapp import JsonApp, JsonAppConfig, SecureViewResponse
5
+
6
+ __all__ = [
7
+ "BaseView",
8
+ "JsonApp",
9
+ "JsonAppConfig",
10
+ "SecureViewResponse",
11
+ ]
12
+