{"id":15091154,"url":"https://github.com/profcomff/api-uilib","last_synced_at":"2025-04-12T07:10:47.521Z","repository":{"id":249155263,"uuid":"830622993","full_name":"profcomff/api-uilib","owner":"profcomff","description":"API wrappers, autogenerated from openapi.json files","archived":false,"fork":false,"pushed_at":"2025-02-28T21:20:04.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T02:22:44.641Z","etag":null,"topics":["api","library","openapi","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@profcomff/api-uilib","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/profcomff.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}},"created_at":"2024-07-18T16:22:31.000Z","updated_at":"2025-02-28T21:17:41.000Z","dependencies_parsed_at":"2024-07-18T21:43:48.144Z","dependency_job_id":"caa612d0-08da-4fec-ac8f-86fdef272920","html_url":"https://github.com/profcomff/api-uilib","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":"0.38888888888888884","last_synced_commit":"e934bce71e63fac3db95c3998f264b3a0fda253e"},"previous_names":["profcomff/api-uilib"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profcomff%2Fapi-uilib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profcomff%2Fapi-uilib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profcomff%2Fapi-uilib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profcomff%2Fapi-uilib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/profcomff","download_url":"https://codeload.github.com/profcomff/api-uilib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530575,"owners_count":21119600,"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":["api","library","openapi","typescript"],"created_at":"2024-09-25T10:35:59.818Z","updated_at":"2025-04-12T07:10:47.466Z","avatar_url":"https://github.com/profcomff.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Схемы и клиент для взаимодействия с API Твой ФФ\n\nПредставляет интерфейс для совершения запросов к API по адресу \u003chttps://api.profcomff.com\u003e.\n\nПоддерживает типы данных TypeScript и подсветку синтаксиса.\n\n[\u003cimg src=\"https://cdn.profcomff.com/easycode/easycode.svg\" width=\"200\"\u003e\u003c/img\u003e](https://easycode.profcomff.com/templates/docker-node/workspace?mode=manual\u0026param.Repository+URL=https://github.com/profcomff/api-uilib.git\u0026param.Working+directory=api-uilib)\n\n\n## Использование\n\nУстановите библиотеку\n\n```shell\npnpm install @profcomff/api-uilib\n```\n\nИспользуйте для совершения запросов к \u003chttps://api.test.profcomff.com\u003e и \u003chttps://api.profcomff.com\u003e.\n\n```ts\nimport { createClient, setupAuth } from \"@profcomff/api-uilib\";\n\n// Setup client with base API path\n// You can use environment `import.meta.env.VITE_API_URL` for example\nconst apiClient = createClient(\"https://api.test.profcomff.com\");\n\n// Setup token for requests to API\n// It is optional, only for routes with authention\nsetupAuth(\"myApiTokenHere\");\n\n// Make request\nconst me_with_scopes = await apiClient.GET(\"/auth/me\", {\n  params: {\n    query: {\n      info: [\"session_scopes\"],\n    },\n  },\n});\n```\n\n\n## Тестирование\n\n_На основе \u003chttps://openapi-ts.dev/openapi-fetch/testing\u003e._\n\n```ts\nimport { createTestClient } from \"@profcomff/api-uilib\";\nimport { http, HttpResponse } from 'msw';\nimport { afterEach, beforeAll, afterAll, expect, test } from 'vitest';\nimport { setupServer } from 'msw/node';\n\nexport const server = setupServer();\n\nbeforeAll(() =\u003e {\n\tserver.listen({\n\t\tonUnhandledRequest: request =\u003e {\n\t\t\tthrow new Error(`No request handler found for ${request.method} ${request.url}`);\n\t\t},\n\t});\n});\n\nafterEach(() =\u003e server.resetHandlers());\nafterAll(() =\u003e server.close());\n\ntest('Get basic info from Auth API with hardload', async () =\u003e {\n\tconst baseUrl = import.meta.env.VITE_API_URL;\n\n\tconst rawData = {\n\t\tid: 1,\n\t\temail: 'hello@world.com',\n\t};\n\n\tserver.use(http.get(`${baseUrl}/auth/user/1`, () =\u003e HttpResponse.json(rawData, { status: 200 })));\n\tconst testClient = createTestClient({ baseUrl });  // Клиент API должен быть инициализирован ПОСЛЕ msw сервера\n\n\tconst { data, error } = await testClient\n        .GET(\n            '/auth/user/{user_id}',\n            { params: { path: { user_id: this.id } },\n        });\n    expect(data).toEqual(rawData);\n    expect(error).toBeUndefined();\n});\n```\n\n\n## Разработка\n\n### Автоматическая генерация\n\nИспользуйте команду `pnpm generate` или [CI-пайплайн Autogen API bindings](https://github.com/profcomff/api-uilib/actions/workflows/autogen.yaml) для кодогенерации последней версии биндингов с **продового** API \u003chttps://api.profcomff.com\u003e.\n\nCI исполняется вручную по нажатии кнопки run workflow. После завершения исполнения новая версия будет доступна для ревью в виде Pull Request с названием \"Automated API update\".\n\n### Релизный процесс\n\nБиблиотека релизится по созданию тега вида `v*`, где вместо звездочки идет описание версии [по правилам semver](https://semver.org/lang/ru/). Менять версию в `package.json` не нужно.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofcomff%2Fapi-uilib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprofcomff%2Fapi-uilib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofcomff%2Fapi-uilib/lists"}