{"id":15443471,"url":"https://github.com/lemonyte/deta-space-actions","last_synced_at":"2025-03-03T00:32:22.284Z","repository":{"id":181719810,"uuid":"657069135","full_name":"lemonyte/deta-space-actions","owner":"lemonyte","description":"Python package to interact with Deta Space Actions.","archived":true,"fork":false,"pushed_at":"2024-10-27T04:00:19.000Z","size":36,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T23:40:01.112Z","etag":null,"topics":["asgi","asgi-middleware","deta","deta-space","python","python-package"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemonyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-22T08:49:16.000Z","updated_at":"2024-12-09T18:29:32.000Z","dependencies_parsed_at":"2024-01-15T16:29:41.577Z","dependency_job_id":"4fba0c38-827c-4931-9841-62970386df84","html_url":"https://github.com/lemonyte/deta-space-actions","commit_stats":{"total_commits":59,"total_committers":2,"mean_commits":29.5,"dds":0.05084745762711862,"last_synced_commit":"a821b593a58af9b4270a1ad3ab5f986003044999"},"previous_names":["lemonyte/deta-space-actions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemonyte%2Fdeta-space-actions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemonyte%2Fdeta-space-actions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemonyte%2Fdeta-space-actions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemonyte%2Fdeta-space-actions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemonyte","download_url":"https://codeload.github.com/lemonyte/deta-space-actions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241587784,"owners_count":19986628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asgi","asgi-middleware","deta","deta-space","python","python-package"],"created_at":"2024-10-01T19:35:09.125Z","updated_at":"2025-03-03T00:32:22.263Z","avatar_url":"https://github.com/lemonyte.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deta Space Actions\n\n\u003e [!IMPORTANT]  \n\u003e This project was created for Deta Space, a service which no longer exists as of October 17th, 2024.\n\nPython package to interact with Deta Space Actions.\n\nPorted from the Node package [deta-space-actions](https://www.npmjs.com/package/deta-space-actions).\n\nThis package is somewhat temporary, hopefully its functionality will be implemented in a future version of the official [Deta Python SDK](https://github.com/deta/deta-python).\n\n## Features\n\n- Dependency-free\n- Includes type hints\n- Supports Python 3.8 and above\n- Object-oriented interface for defining and invoking actions\n- Generic ASGI middleware\n- Optional type checking support for the middleware\n\n## TODO\n\n- [ ] Invocation function\n- [ ] Better typing\n- [ ] Add tests\n\n## Installation\n\nTo install the latest in-development version:\n\n```shell\npython -m pip install git+https://github.com/lemonyte/deta-space-actions\n```\n\nOr, to install a specific commit:\n\n```shell\npython -m pip install git+https://github.com/lemonyte/deta-space-actions@{commit}\n```\n\nIf you want full type checking support for the ASGI middleware, you'll also need to install [`asgiref`](https://github.com/django/asgiref) with:\n\n```shell\npython -m pip install asgiref\n```\n\nOr use the optional dependency syntax:\n\n```shell\npython -m pip install \"deta-space-actions[typing] @ git+https://github.com/lemonyte/deta-space-actions\"\n```\n\n## Usage\n\n### Using the middleware\n\nThe package provides a generic ASGI middleware class that can be used with any ASGI framework.\n\n```python\nfrom deta_space_actions import Actions, ActionsMiddleware, Input, InputType\n\n# Create an ASGI app.\napp = ...\n# Create an Actions instance.\nactions = Actions()\n# Add the middleware if your framework has a helper method for adding middleware.\napp.add_middleware(ActionsMiddleware, actions=actions)\n# Otherwise, wrap the app instance.\napp = ActionsMiddleware(app, actions=actions)\n\n\n# Add an action.\n@actions.action(\n    title=\"Say hello\",\n    inputs=[\n        Input(\n            name=\"name\",\n            type=InputType.STRING,\n            optional=False,\n        ),\n    ],\n)\nasync def hello(payload):\n    return f\"Hello, {payload.get('name', 'world')}!\"\n```\n\n### Using your own path handler\n\nAlternatively, you can write your own handler function and use it with your framework's routing system.\nAn example for FastAPI is shown below.\n\n```python\nimport json\n\nfrom fastapi import FastAPI, HTTPException, Request\n\nfrom deta_space_actions import Actions, Input, InputType\n\n# Create a FastAPI app.\napp = FastAPI()\n# Create an Actions instance.\nactions = Actions()\n\n\n# Add an action.\n@actions.action(\n    title=\"Say hello\",\n    inputs=[\n        Input(\n            name=\"name\",\n            type=InputType.STRING,\n            optional=False,\n        ),\n    ],\n)\nasync def hello(payload):\n    return f\"Hello, {payload.get('name', 'world')}!\"\n\n\n# Define a path handler.\n@app.post(\"/__space/actions/{action_name}\")\nasync def actions_handler(action_name: str, request: Request):\n    action = actions.get(action_name)\n    if not action:\n        raise HTTPException(404)\n    try:\n        payload = await request.json()\n    except json.JSONDecodeError:\n        payload = {}\n    return await action.run(payload)\n```\n\n## License\n\n[MIT License](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemonyte%2Fdeta-space-actions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemonyte%2Fdeta-space-actions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemonyte%2Fdeta-space-actions/lists"}