{"id":21451170,"url":"https://github.com/lenra-io/app-lib-java","last_synced_at":"2025-10-30T10:16:59.198Z","repository":{"id":215599812,"uuid":"739311795","full_name":"lenra-io/app-lib-java","owner":"lenra-io","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-26T13:59:50.000Z","size":220,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T12:25:30.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/lenra-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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},"funding":{"github":["lenra-io"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-01-05T09:07:24.000Z","updated_at":"2024-06-26T07:59:13.000Z","dependencies_parsed_at":"2024-03-21T18:24:47.902Z","dependency_job_id":"d8adb43e-c917-4624-9f8e-88f343c335e2","html_url":"https://github.com/lenra-io/app-lib-java","commit_stats":null,"previous_names":["lenra-io/app-lib-java"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fapp-lib-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fapp-lib-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fapp-lib-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fapp-lib-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lenra-io","download_url":"https://codeload.github.com/lenra-io/app-lib-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243963779,"owners_count":20375676,"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":[],"created_at":"2024-11-23T04:18:29.424Z","updated_at":"2025-10-30T10:16:54.179Z","avatar_url":"https://github.com/lenra-io.png","language":"Java","readme":"# app-lib-java\n\n\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\u003c!--\n*** This README was created with https://github.com/othneildrew/Best-README-Template\n--\u003e\n\n\n\n\u003c!-- PROJECT SHIELDS --\u003e\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n\n\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n\n\u003ch3 align=\"center\"\u003eApp Lib for Java based projects\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    This lib integrates all the elements the app needs in order to only keep the views, listeners and resources in the app project.\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/lenra-io/app-lib-java/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/lenra-io/app-lib-java/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n\nTo incorporate it into your Lenra app project, add the dependency to your `build.gradle` file as follows:\n```gradle\ndependencies {\n    def lenra = 'io.lenra:app:1.0.0'\n    implementation lenra\n\t\tannotationProcessor lenra\n\t\t...\n}\n```\n\n### Annotations\n\nThe lib provides a set of annotations to simplify the development of your app:\n- `@AppManifest`: to define the manifest of the app\n- `@AppView`: to create a view\n- `@AppListener`: to create a listener\n\nThe `@AppView` and `@AppListener` annotations are used to generate enums at build time that can be used in the app: `ViewName` and `ListenerName`.\n\n### App Manifest\n\nTo define the manifest of the app, create a static method in a class annotating it with `@AppManifest`:\n```java\n@AppManifest\npublic static Manifest manifest() {\n\treturn new Manifest()\n\t\t\t.json(\n\t\t\t\t\tnew Exposer(\n\t\t\t\t\t\t\tList.of(\n\t\t\t\t\t\t\t\t\tnew Route(\n\t\t\t\t\t\t\t\t\t\t\t\"/counter/global\",\n\t\t\t\t\t\t\t\t\t\t\tnew View(ViewName.LENRA_COUNTER)\n\t\t\t\t\t\t\t\t\t\t\t\t\t.find(new Find(Counter.class, Map.of(\"user\", \"global\")))\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t.roles(List.of(\"guest\", \"user\")),\n\t\t\t\t\t\t\t\t\tnew Route(\n\t\t\t\t\t\t\t\t\t\t\t\"/counter/me\",\n\t\t\t\t\t\t\t\t\t\t\tnew View(ViewName.LENRA_COUNTER)\n\t\t\t\t\t\t\t\t\t\t\t\t\t.find(new Find(Counter.class, Map.of(\"user\", \"@me\")))\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t);\n}\n```\n\n### App Views\n\nTo create a view, create a static method in a class annotating it with `@AppView`: \n```java\n// myView JSON view\n@AppView\npublic static Object myView() {\n\t\treturn Map.of(\n\t\t\t\t\"key\", \"value\"\n\t\t);\n}\n```\n\nA view can return any type of object, it will be serialized to JSON.\n\n#### View parameters\n\nA view can get parameters:\n```java\n// myView JSON view\n@AppView\npublic static Object myView(@AppView.Data List\u003cCounter\u003e counters, @AppView.Props Map\u003cString, Object\u003e props, @AppView.Context Map\u003cString, Object\u003e context) {\n\t\treturn Map.of(\n\t\t\t\t\"key\", \"value\"\n\t\t);\n}\n```\n\nThe parameters annotations let you define what are the needed parameters for the view (by default they are resolved in the next order):\n- `@AppView.Data`: the data needed for the view\n- `@AppView.Props`: the props passed to the view\n- `@AppView.Context`: the context of the view\n\nThe parameters are mapped to the expected type from JSON.\n\n### App Listeners\n\nTo create a listener, create a static method in a class annotating it with `@AppListener`: \n```java\n// myListener listener\n@AppListener\npublic static void myListener(String data, Api api) {\n\t\t// Do something with the data\n}\n```\n\n#### Listener parameters\n\nA listener can get parameters:\n```java\n// myListener listener\n@AppListener\npublic static void myListener(@AppListener.Api Api api, @AppListener.Props Map\u003cString, Object\u003e props, @AppListener.Event Map\u003cString, Object\u003e event) {\n\t\t// Do something with the data\n}\n```\n\nThe parameters annotations let you define what are the needed parameters for the listener (by default they are resolved in the next order):\n- `@AppListener.Api`: the API to call the Lenra API\n- `@AppListener.Props`: the props passed to the listener\n- `@AppListener.Event`: the event of the listener\n\nThe parameters are mapped to the expected type from JSON.\n\n\n### Lenra API calls\n\nTo call a Lenra API from a listener, utilize the `Api` instance provided as the first parameter in your listener function or by the `@AppListener.Api` annotation. \n\nYou can then create a document using the data API with the following code:\n```java\n@Getter @Setter\n@NoArgsConstructor\n@AllArgsConstructor\nclass CustomData extends Data {\n  private String value;\n}\n\nvar myDoc = api.data.coll(CustomData.class).createDoc(new CustomData(\"Hello world\"));\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please open an issue with the tag \"enhancement\".\nDon't forget to give the project a star if you liked it! Thanks again!generate\n\n### Generate classes\n\nA part of this lib is generated from the [Lenra API](https://github.com/lenra-io/api).\nThe class generation is made at build time:\n\n```bash\n# Load API\n## With wget\nwget https://github.com/lenra-io/api/releases/latest/download/load-api.sh -O - -q | bash\n## With curl\ncurl -fsSL https://github.com/lenra-io/api/releases/latest/download/load-api.sh | bash\n```\n\nThe classes are generated at build time with Gradle and Bun.\nYou can also generate them manually:\n\n```bash\n./gradlew generateApiClasses\n```\n\n### Build\n\n```bash\n./gradlew build\n```\n\n### Public to Maven Local\n\n```bash\n./gradlew :app:publishToMavenLocal\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the **MIT** License. See [LICENSE](./LICENSE) for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nLenra - [@lenra_dev](https://twitter.com/lenra_dev) - contact@lenra.io\n\nProject Link: [https://github.com/lenra-io/app-lib-java](https://github.com/lenra-io/app-lib-java)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/lenra-io/app-lib-java.svg?style=for-the-badge\n[contributors-url]: https://github.com/lenra-io/app-lib-java/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/lenra-io/app-lib-java.svg?style=for-the-badge\n[forks-url]: https://github.com/lenra-io/app-lib-java/network/members\n[stars-shield]: https://img.shields.io/github/stars/lenra-io/app-lib-java.svg?style=for-the-badge\n[stars-url]: https://github.com/lenra-io/app-lib-java/stargazers\n[issues-shield]: https://img.shields.io/github/issues/lenra-io/app-lib-java.svg?style=for-the-badge\n[issues-url]: https://github.com/lenra-io/app-lib-java/issues\n[license-shield]: https://img.shields.io/github/license/lenra-io/app-lib-java.svg?style=for-the-badge\n[license-url]: https://github.com/lenra-io/app-lib-java/blob/master/LICENSE\n","funding_links":["https://github.com/sponsors/lenra-io"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenra-io%2Fapp-lib-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flenra-io%2Fapp-lib-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenra-io%2Fapp-lib-java/lists"}