ocf-types 1.2.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.
@@ -0,0 +1,28 @@
1
+ # Mac
2
+ .DS_Store
3
+
4
+ # IDE files
5
+ .vscode
6
+ .idea
7
+
8
+ # Node
9
+ node_modules
10
+
11
+ # Python
12
+ *.pyc
13
+ venv/
14
+ requirements.txt
15
+ docs/__pycache__
16
+
17
+ # MkDocs
18
+ site/
19
+
20
+ # Generated artifacts (composed schemas, generated TS types, etc.)
21
+ build/
22
+
23
+ # Generated OCF types package output — produced at build/publish time, never committed.
24
+ packages/ocf-types/index.d.ts
25
+ packages/ocf-types/*.tgz
26
+ packages/ocf-types-python/ocf_types/__init__.py
27
+ packages/ocf-types-python/dist/
28
+ packages/ocf-types-python/.mypy_cache/
@@ -0,0 +1,60 @@
1
+ ### Schema and Documentation License
2
+
3
+ Version 1.0.1, April 3, 2024
4
+
5
+ Copyright (C) 2024 Open Cap Table Coalition <https://opencaptablecoalition.com/>
6
+
7
+ #### 1. LICENSE
8
+
9
+ **By using and/or copying Open Cap Table Coalition JSON Schema files or documentation thereof
10
+ (each, individually, an "OCF File", and, collectively, the "OCF Files"), you (the licensee)
11
+ agree that you have read, understood, and will comply with the following terms and conditions**:
12
+
13
+ Permission to copy and distribute OCF Files, in any medium for any purpose and without fee or
14
+ royalty is hereby granted, provided that
15
+
16
+ 1. For _ALL_ copies of an OCF File or portions thereof that are **not** JSON Schema files, you include
17
+
18
+ - A link to the original OCF File and
19
+ - A notice in the form "Copyright © [$date-of-ocf-file] [Open Cap Table Coalition](https://opencaptablecoalition.com)."; and
20
+
21
+ 2. For _ALL_ copies of an OCF File or portions thereof that **are** JSON Schema files, you include
22
+
23
+ - A `$comment` field with a value of: "Copyright © [$date-of-ocf-file]
24
+ Open Cap Table Coalition (https://opencaptablecoalition.com) / Original File: [$url-of-original-schema-file]"
25
+
26
+ When space permits, inclusion of the full text of the **NOTICE** (as defined below) should be provided. We request
27
+ that authorship attribution be provided in any software, documents, or other items or products
28
+ that you create pursuant to the implementation of OCF Files, or any portion thereof.
29
+
30
+ No right to create modifications or derivatives of OCF Files is granted pursuant to this license,
31
+ except as follows:
32
+
33
+ _To facilitate implementation of the technical specifications set forth in
34
+ the OCF Files, anyone may prepare and distribute derivative works and
35
+ portions of the OCF Files in software, in supporting materials accompanying
36
+ software, and in documentation of software, PROVIDED that all such
37
+ works include the notice below. HOWEVER, the publication of derivative
38
+ works of OCF Files for use as a technical specification is expressly prohibited._
39
+
40
+ In addition, "Code Components" - sample OCF file implementations, sample OCF JSONs and computer
41
+ programming language code - are licensed under the [Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0).
42
+
43
+ The full "Notice" is:
44
+
45
+ > "Copyright © [$date-of-ocf-file] Open Cap Table Coalition. This software or document
46
+ > includes material copied from or derived from [title and URI of the OCF File]."
47
+
48
+ #### 2. DISCLAIMERS
49
+
50
+ OCF FILES ARE PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES,
51
+ EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS
52
+ FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE OCF FILES ARE
53
+ SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY
54
+ THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE
55
+ FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE OCF FILES
56
+ OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.
57
+
58
+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining
59
+ to the OCF Files or their contents without specific, written prior permission. Title to copyright
60
+ in the OCF Files will at all times remain with copyright holders.
@@ -0,0 +1,200 @@
1
+ Metadata-Version: 2.5
2
+ Name: ocf-types
3
+ Version: 1.2.0
4
+ Summary: Python types for the Open Cap Format (OCF), generated from the OCF JSON Schemas.
5
+ Project-URL: Homepage, https://github.com/Open-Cap-Table-Coalition/Open-Cap-Format-OCF#readme
6
+ Project-URL: Repository, https://github.com/Open-Cap-Table-Coalition/Open-Cap-Format-OCF
7
+ Project-URL: Issues, https://github.com/Open-Cap-Table-Coalition/Open-Cap-Format-OCF/issues
8
+ License: ### Schema and Documentation License
9
+
10
+ Version 1.0.1, April 3, 2024
11
+
12
+ Copyright (C) 2024 Open Cap Table Coalition <https://opencaptablecoalition.com/>
13
+
14
+ #### 1. LICENSE
15
+
16
+ **By using and/or copying Open Cap Table Coalition JSON Schema files or documentation thereof
17
+ (each, individually, an "OCF File", and, collectively, the "OCF Files"), you (the licensee)
18
+ agree that you have read, understood, and will comply with the following terms and conditions**:
19
+
20
+ Permission to copy and distribute OCF Files, in any medium for any purpose and without fee or
21
+ royalty is hereby granted, provided that
22
+
23
+ 1. For _ALL_ copies of an OCF File or portions thereof that are **not** JSON Schema files, you include
24
+
25
+ - A link to the original OCF File and
26
+ - A notice in the form "Copyright © [$date-of-ocf-file] [Open Cap Table Coalition](https://opencaptablecoalition.com)."; and
27
+
28
+ 2. For _ALL_ copies of an OCF File or portions thereof that **are** JSON Schema files, you include
29
+
30
+ - A `$comment` field with a value of: "Copyright © [$date-of-ocf-file]
31
+ Open Cap Table Coalition (https://opencaptablecoalition.com) / Original File: [$url-of-original-schema-file]"
32
+
33
+ When space permits, inclusion of the full text of the **NOTICE** (as defined below) should be provided. We request
34
+ that authorship attribution be provided in any software, documents, or other items or products
35
+ that you create pursuant to the implementation of OCF Files, or any portion thereof.
36
+
37
+ No right to create modifications or derivatives of OCF Files is granted pursuant to this license,
38
+ except as follows:
39
+
40
+ _To facilitate implementation of the technical specifications set forth in
41
+ the OCF Files, anyone may prepare and distribute derivative works and
42
+ portions of the OCF Files in software, in supporting materials accompanying
43
+ software, and in documentation of software, PROVIDED that all such
44
+ works include the notice below. HOWEVER, the publication of derivative
45
+ works of OCF Files for use as a technical specification is expressly prohibited._
46
+
47
+ In addition, "Code Components" - sample OCF file implementations, sample OCF JSONs and computer
48
+ programming language code - are licensed under the [Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0).
49
+
50
+ The full "Notice" is:
51
+
52
+ > "Copyright © [$date-of-ocf-file] Open Cap Table Coalition. This software or document
53
+ > includes material copied from or derived from [title and URI of the OCF File]."
54
+
55
+ #### 2. DISCLAIMERS
56
+
57
+ OCF FILES ARE PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES,
58
+ EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS
59
+ FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE OCF FILES ARE
60
+ SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY
61
+ THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE
62
+ FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE OCF FILES
63
+ OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.
64
+
65
+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining
66
+ to the OCF Files or their contents without specific, written prior permission. Title to copyright
67
+ in the OCF Files will at all times remain with copyright holders.
68
+ License-File: LICENSE.md
69
+ Keywords: cap-table,ocf,open-cap-format,types,typing
70
+ Classifier: Programming Language :: Python :: 3
71
+ Classifier: Typing :: Typed
72
+ Requires-Python: >=3.10
73
+ Requires-Dist: typing-extensions>=4.9
74
+ Description-Content-Type: text/markdown
75
+
76
+ # ocf-types
77
+
78
+ Python types for the
79
+ [Open Cap Format (OCF)](https://github.com/Open-Cap-Table-Coalition/Open-Cap-Format-OCF), generated
80
+ directly from the OCF JSON Schemas.
81
+
82
+ > **Generated. Do not edit by hand.** `ocf_types/__init__.py` is produced by
83
+ > `npm run build:ocf-types-python` from the schemas under [`/schema`](../../schema). It is built at
84
+ > release time and is _not_ committed to the repository.
85
+
86
+ This is the Python counterpart of [`@opencaptablecoalition/ocf-types`](../ocf-types), the TypeScript
87
+ types.
88
+
89
+ ## Install
90
+
91
+ ```bash
92
+ pip install ocf-types
93
+ ```
94
+
95
+ The package version is the OCF schema release it was generated from: `ocf-types==1.2.0` has the
96
+ types for OCF `v1.2.0`. It needs Python 3.10 or later and depends only on `typing_extensions`.
97
+
98
+ ## Usage
99
+
100
+ ```python
101
+ import ocf_types as ocf
102
+
103
+
104
+ def quantity_transferred(transfer: ocf.StockTransfer) -> str:
105
+ return transfer["quantity"]
106
+
107
+
108
+ issuer: ocf.Issuer = {
109
+ "object_type": "ISSUER",
110
+ "id": "issuer",
111
+ "legal_name": "Example Co",
112
+ "formation_date": "2022-01-03",
113
+ "country_of_formation": "US",
114
+ }
115
+ ```
116
+
117
+ Every type is a `TypedDict`, a `Literal` or a union of those, so an OCF object stays the plain
118
+ `dict` that `json.load` gives you. The package adds no behaviour at run time.
119
+
120
+ ## What's included
121
+
122
+ One named type per OCF schema:
123
+
124
+ - **Objects, types and file wrappers** are `TypedDict` classes. A field the schema does not
125
+ require is `NotRequired`.
126
+ - **Enums** are `Literal` types: `StockClassType = Literal["COMMON", "PREFERRED"]`.
127
+ - **Scalar types** are aliases: `Numeric = str`, `Date = str`.
128
+ - **Versioned schemas** are the union of their versions:
129
+ `EquityCompensationIssuance = EquityCompensationIssuanceV1 | EquityCompensationIssuanceV2`.
130
+
131
+ ### Objects are built the way OCF builds them
132
+
133
+ OCF composes each object from primitives with `allOf`. The Python types keep that, where the
134
+ TypeScript types flatten it:
135
+
136
+ ```python
137
+ class Transfer(TypedDict):
138
+ balance_security_id: NotRequired[str]
139
+ resulting_security_ids: list[str]
140
+
141
+
142
+ class StockTransfer(Object, Transaction, SecurityTransaction, Transfer):
143
+ object_type: Literal["TX_STOCK_TRANSFER"]
144
+ quantity: Numeric
145
+ ```
146
+
147
+ So a function that takes a `Transfer` accepts a stock, convertible, warrant or equity compensation
148
+ transfer.
149
+
150
+ For each primitive there is also a union of everything built from it, named `Any` plus the
151
+ primitive: `AnyTransfer`, `AnyIssuance`, `AnyTransaction`, `AnyObject`, `AnyConversionTrigger`. Use
152
+ one when code handles every member and should be checked against the fields they share:
153
+
154
+ ```python
155
+ def results(transfer: ocf.AnyTransfer) -> list[str]:
156
+ return transfer["resulting_security_ids"] # every transfer has this
157
+
158
+
159
+ def quantity(transfer: ocf.AnyTransfer) -> str:
160
+ return transfer["quantity"] # error: a convertible transfer has an amount, not a quantity
161
+ ```
162
+
163
+ ### Names
164
+
165
+ The names are the ones the TypeScript types use, without the `OCF` prefix: `StockIssuance` here is
166
+ `OCFStockIssuance` there. A Python module is its own namespace, so `import ocf_types as ocf` gives
167
+ `ocf.StockIssuance`. To generate with the prefix, pass `--prefix OCF` to
168
+ `npm run schema:gen-python-types`.
169
+
170
+ ## What the types do not check
171
+
172
+ A type says which fields an object has and what each holds. It cannot say everything a JSON Schema
173
+ does. These are not represented:
174
+
175
+ - patterns and formats (a `Numeric` or a `Date` is a `str`);
176
+ - minimums and other limits on a value;
177
+ - conditional requirements, such as "an option has an `exercise_price`";
178
+ - that no other field is allowed.
179
+
180
+ Validate OCF data against the JSON Schemas for full correctness, for example with
181
+ [`@open-captable/cli`](https://www.npmjs.com/package/@open-captable/cli). Treat a value as its OCF
182
+ type once it has passed.
183
+
184
+ ## Type checkers
185
+
186
+ The types are checked in CI with **pyright** and **mypy** in strict mode, as an installed package:
187
+ correct uses must pass, and a set of deliberate mistakes must each be reported.
188
+
189
+ A schema often narrows a field of a schema it is built from: every object narrows `object_type` from
190
+ the `ObjectType` enum to its own value. The types allow that by declaring such a field `ReadOnly` in
191
+ the base class ([PEP 705](https://peps.python.org/pep-0705/)).
192
+
193
+ An older mypy does not accept that narrowing when it checks the module's own source: mypy 1.18.2
194
+ reports "Overwriting TypedDict field", and mypy 2.4.1 does not. This does not affect an installed
195
+ package, which mypy does not report on. It matters only if you copy `ocf_types` into your own source
196
+ tree. As an installed package the types were tested with mypy 1.18.2 and 2.4.1, and pyright 1.1.414.
197
+
198
+ ## License
199
+
200
+ Generated from the OCF schemas. See [LICENSE.md](LICENSE.md).
@@ -0,0 +1,125 @@
1
+ # ocf-types
2
+
3
+ Python types for the
4
+ [Open Cap Format (OCF)](https://github.com/Open-Cap-Table-Coalition/Open-Cap-Format-OCF), generated
5
+ directly from the OCF JSON Schemas.
6
+
7
+ > **Generated. Do not edit by hand.** `ocf_types/__init__.py` is produced by
8
+ > `npm run build:ocf-types-python` from the schemas under [`/schema`](../../schema). It is built at
9
+ > release time and is _not_ committed to the repository.
10
+
11
+ This is the Python counterpart of [`@opencaptablecoalition/ocf-types`](../ocf-types), the TypeScript
12
+ types.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pip install ocf-types
18
+ ```
19
+
20
+ The package version is the OCF schema release it was generated from: `ocf-types==1.2.0` has the
21
+ types for OCF `v1.2.0`. It needs Python 3.10 or later and depends only on `typing_extensions`.
22
+
23
+ ## Usage
24
+
25
+ ```python
26
+ import ocf_types as ocf
27
+
28
+
29
+ def quantity_transferred(transfer: ocf.StockTransfer) -> str:
30
+ return transfer["quantity"]
31
+
32
+
33
+ issuer: ocf.Issuer = {
34
+ "object_type": "ISSUER",
35
+ "id": "issuer",
36
+ "legal_name": "Example Co",
37
+ "formation_date": "2022-01-03",
38
+ "country_of_formation": "US",
39
+ }
40
+ ```
41
+
42
+ Every type is a `TypedDict`, a `Literal` or a union of those, so an OCF object stays the plain
43
+ `dict` that `json.load` gives you. The package adds no behaviour at run time.
44
+
45
+ ## What's included
46
+
47
+ One named type per OCF schema:
48
+
49
+ - **Objects, types and file wrappers** are `TypedDict` classes. A field the schema does not
50
+ require is `NotRequired`.
51
+ - **Enums** are `Literal` types: `StockClassType = Literal["COMMON", "PREFERRED"]`.
52
+ - **Scalar types** are aliases: `Numeric = str`, `Date = str`.
53
+ - **Versioned schemas** are the union of their versions:
54
+ `EquityCompensationIssuance = EquityCompensationIssuanceV1 | EquityCompensationIssuanceV2`.
55
+
56
+ ### Objects are built the way OCF builds them
57
+
58
+ OCF composes each object from primitives with `allOf`. The Python types keep that, where the
59
+ TypeScript types flatten it:
60
+
61
+ ```python
62
+ class Transfer(TypedDict):
63
+ balance_security_id: NotRequired[str]
64
+ resulting_security_ids: list[str]
65
+
66
+
67
+ class StockTransfer(Object, Transaction, SecurityTransaction, Transfer):
68
+ object_type: Literal["TX_STOCK_TRANSFER"]
69
+ quantity: Numeric
70
+ ```
71
+
72
+ So a function that takes a `Transfer` accepts a stock, convertible, warrant or equity compensation
73
+ transfer.
74
+
75
+ For each primitive there is also a union of everything built from it, named `Any` plus the
76
+ primitive: `AnyTransfer`, `AnyIssuance`, `AnyTransaction`, `AnyObject`, `AnyConversionTrigger`. Use
77
+ one when code handles every member and should be checked against the fields they share:
78
+
79
+ ```python
80
+ def results(transfer: ocf.AnyTransfer) -> list[str]:
81
+ return transfer["resulting_security_ids"] # every transfer has this
82
+
83
+
84
+ def quantity(transfer: ocf.AnyTransfer) -> str:
85
+ return transfer["quantity"] # error: a convertible transfer has an amount, not a quantity
86
+ ```
87
+
88
+ ### Names
89
+
90
+ The names are the ones the TypeScript types use, without the `OCF` prefix: `StockIssuance` here is
91
+ `OCFStockIssuance` there. A Python module is its own namespace, so `import ocf_types as ocf` gives
92
+ `ocf.StockIssuance`. To generate with the prefix, pass `--prefix OCF` to
93
+ `npm run schema:gen-python-types`.
94
+
95
+ ## What the types do not check
96
+
97
+ A type says which fields an object has and what each holds. It cannot say everything a JSON Schema
98
+ does. These are not represented:
99
+
100
+ - patterns and formats (a `Numeric` or a `Date` is a `str`);
101
+ - minimums and other limits on a value;
102
+ - conditional requirements, such as "an option has an `exercise_price`";
103
+ - that no other field is allowed.
104
+
105
+ Validate OCF data against the JSON Schemas for full correctness, for example with
106
+ [`@open-captable/cli`](https://www.npmjs.com/package/@open-captable/cli). Treat a value as its OCF
107
+ type once it has passed.
108
+
109
+ ## Type checkers
110
+
111
+ The types are checked in CI with **pyright** and **mypy** in strict mode, as an installed package:
112
+ correct uses must pass, and a set of deliberate mistakes must each be reported.
113
+
114
+ A schema often narrows a field of a schema it is built from: every object narrows `object_type` from
115
+ the `ObjectType` enum to its own value. The types allow that by declaring such a field `ReadOnly` in
116
+ the base class ([PEP 705](https://peps.python.org/pep-0705/)).
117
+
118
+ An older mypy does not accept that narrowing when it checks the module's own source: mypy 1.18.2
119
+ reports "Overwriting TypedDict field", and mypy 2.4.1 does not. This does not affect an installed
120
+ package, which mypy does not report on. It matters only if you copy `ocf_types` into your own source
121
+ tree. As an installed package the types were tested with mypy 1.18.2 and 2.4.1, and pyright 1.1.414.
122
+
123
+ ## License
124
+
125
+ Generated from the OCF schemas. See [LICENSE.md](LICENSE.md).