oarepo-model-builder-cf


Nameoarepo-model-builder-cf JSON
Version 4.0.7 PyPI version JSON
download
home_pagehttps://github.com/oarepo/oarepo-model-builder-cf
Summary"A model builder plugin for custom fields support"
upload_time2023-11-14 07:04:00
maintainer
docs_urlNone
authorMiroslav Simek
requires_python>=3.9
licenseMIT
keywords invenio cf model builder
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Custom fields plugin for model builder

## Custom fields

Custom fields allow extending model at configuration time, with the same sources.
This plugin adds two types of custom fields - ones defined on an explicit element
(usually the "custom_fields" element is used, but any name can be used) and other
one inlining the custom fields directly to the main content.

Currently there is no support for inlining custom fields to "metadata" element,
but this can be changed in the future.

## Model file

Custom fields are defined on the level of "model":

```yaml
model:
    use: invenio
    custom-fields:
    - element: custom_fields
      config: TEST_CUSTOM_FIELDS
    properties:
        metadata:
            properties:
                title: fulltext
```

### Explicit custom fields

Explicit custom fields are defined using a pair of `element name` and `config` variable.
In the instance the custom fields will be separated into the `element name`:

```python
# config

from invenio_records_resources.services.custom_fields.text import KeywordCF

TEST_CUSTOM_FIELDS = [
    KeywordCF('blah')
]
```

```json5
// instance
{
    "metadata": {
        "title": "My Title"
    },
    "custom_fields": {                  // "element" from model
        "blah": "Custom field value"    // as defined in "TEST_CUSTOM_FIELDS" variable
    }
}
```

### Inline custom fields

Inline custom fields are placed on the root level of the instance, without an enclosing element. To define them, just leave the `element` definition. Note that only 1 definition of inline CF is allowed.

```yaml
model:
    use: invenio
    custom-fields:
    - config: INLINE_CF
    properties:
        metadata:
            properties:
                title: fulltext
```


```python
# config

from invenio_records_resources.services.custom_fields.text import KeywordCF

INLINE_CF = [
    KeywordCF('blah')
]
```

```json5
// instance
{
    "metadata": {
        "title": "My Title"
    },
    "blah": "Custom field value"    // as defined in "INLINE_CF" variable
}
```

### Custom fields nested in metadata

Custom fields nested inside the metadata are not supported yet.

## Using custom fields

Custom fields influence the jsonschema file (adding a non-checked object or allowing additional properties) and the mapping file (adding an empty mapping for CF). 

During deployment time, after the index is created and before data are poured in,
a specialized mapping for custom fields must be created. To do so, call

```bash
invenio oarepo cf init
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/oarepo/oarepo-model-builder-cf",
    "name": "oarepo-model-builder-cf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "invenio cf model builder",
    "author": "Miroslav Simek",
    "author_email": "simek.miroslav@techlib.cz",
    "download_url": "https://files.pythonhosted.org/packages/57/12/7740201635d0bd8a5b50fd0985b84432f155d1da1ad7d2b9ff4568c875fc/oarepo-model-builder-cf-4.0.7.tar.gz",
    "platform": "any",
    "description": "# Custom fields plugin for model builder\n\n## Custom fields\n\nCustom fields allow extending model at configuration time, with the same sources.\nThis plugin adds two types of custom fields - ones defined on an explicit element\n(usually the \"custom_fields\" element is used, but any name can be used) and other\none inlining the custom fields directly to the main content.\n\nCurrently there is no support for inlining custom fields to \"metadata\" element,\nbut this can be changed in the future.\n\n## Model file\n\nCustom fields are defined on the level of \"model\":\n\n```yaml\nmodel:\n    use: invenio\n    custom-fields:\n    - element: custom_fields\n      config: TEST_CUSTOM_FIELDS\n    properties:\n        metadata:\n            properties:\n                title: fulltext\n```\n\n### Explicit custom fields\n\nExplicit custom fields are defined using a pair of `element name` and `config` variable.\nIn the instance the custom fields will be separated into the `element name`:\n\n```python\n# config\n\nfrom invenio_records_resources.services.custom_fields.text import KeywordCF\n\nTEST_CUSTOM_FIELDS = [\n    KeywordCF('blah')\n]\n```\n\n```json5\n// instance\n{\n    \"metadata\": {\n        \"title\": \"My Title\"\n    },\n    \"custom_fields\": {                  // \"element\" from model\n        \"blah\": \"Custom field value\"    // as defined in \"TEST_CUSTOM_FIELDS\" variable\n    }\n}\n```\n\n### Inline custom fields\n\nInline custom fields are placed on the root level of the instance, without an enclosing element. To define them, just leave the `element` definition. Note that only 1 definition of inline CF is allowed.\n\n```yaml\nmodel:\n    use: invenio\n    custom-fields:\n    - config: INLINE_CF\n    properties:\n        metadata:\n            properties:\n                title: fulltext\n```\n\n\n```python\n# config\n\nfrom invenio_records_resources.services.custom_fields.text import KeywordCF\n\nINLINE_CF = [\n    KeywordCF('blah')\n]\n```\n\n```json5\n// instance\n{\n    \"metadata\": {\n        \"title\": \"My Title\"\n    },\n    \"blah\": \"Custom field value\"    // as defined in \"INLINE_CF\" variable\n}\n```\n\n### Custom fields nested in metadata\n\nCustom fields nested inside the metadata are not supported yet.\n\n## Using custom fields\n\nCustom fields influence the jsonschema file (adding a non-checked object or allowing additional properties) and the mapping file (adding an empty mapping for CF). \n\nDuring deployment time, after the index is created and before data are poured in,\na specialized mapping for custom fields must be created. To do so, call\n\n```bash\ninvenio oarepo cf init\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\"A model builder plugin for custom fields support\"",
    "version": "4.0.7",
    "project_urls": {
        "Homepage": "https://github.com/oarepo/oarepo-model-builder-cf"
    },
    "split_keywords": [
        "invenio",
        "cf",
        "model",
        "builder"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "673096b4b23ecc5e07a54a0b8d0a0ee52682400a3fa0aed7dd3a72895a4ebae7",
                "md5": "703a91fed7c7394c61c5ad0e13d7dc03",
                "sha256": "3b8afcb677b8b0e16560068f28935791f4c5b3ae538714499d32e31f26ffe4a6"
            },
            "downloads": -1,
            "filename": "oarepo_model_builder_cf-4.0.7-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "703a91fed7c7394c61c5ad0e13d7dc03",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.9",
            "size": 9234,
            "upload_time": "2023-11-14T07:03:58",
            "upload_time_iso_8601": "2023-11-14T07:03:58.954322Z",
            "url": "https://files.pythonhosted.org/packages/67/30/96b4b23ecc5e07a54a0b8d0a0ee52682400a3fa0aed7dd3a72895a4ebae7/oarepo_model_builder_cf-4.0.7-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "57127740201635d0bd8a5b50fd0985b84432f155d1da1ad7d2b9ff4568c875fc",
                "md5": "43361183031a463d417c38cfc681a5f0",
                "sha256": "0ca3821c6fade7dc292dad0ffcca075befd8527a0d74b366fb96aab48ad9ed99"
            },
            "downloads": -1,
            "filename": "oarepo-model-builder-cf-4.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "43361183031a463d417c38cfc681a5f0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 4606,
            "upload_time": "2023-11-14T07:04:00",
            "upload_time_iso_8601": "2023-11-14T07:04:00.145866Z",
            "url": "https://files.pythonhosted.org/packages/57/12/7740201635d0bd8a5b50fd0985b84432f155d1da1ad7d2b9ff4568c875fc/oarepo-model-builder-cf-4.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-14 07:04:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "oarepo",
    "github_project": "oarepo-model-builder-cf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "oarepo-model-builder-cf"
}
        
Elapsed time: 0.13647s