{"id":25442075,"url":"https://github.com/vitalygashkov/fmptools","last_synced_at":"2025-05-15T19:10:41.646Z","repository":{"id":194303194,"uuid":"690530977","full_name":"vitalygashkov/fmptools","owner":"vitalygashkov","description":"Foresight Mobile Platform utilities for web","archived":false,"fork":false,"pushed_at":"2025-03-01T05:00:47.000Z","size":209,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T22:09:20.732Z","etag":null,"topics":["fmp","foresight"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vitalygashkov.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}},"created_at":"2023-09-12T11:31:19.000Z","updated_at":"2024-10-03T18:58:36.000Z","dependencies_parsed_at":"2023-09-12T20:25:30.780Z","dependency_job_id":null,"html_url":"https://github.com/vitalygashkov/fmptools","commit_stats":null,"previous_names":["vitalygashkov/fmptools"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalygashkov%2Ffmptools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalygashkov%2Ffmptools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalygashkov%2Ffmptools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalygashkov%2Ffmptools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitalygashkov","download_url":"https://codeload.github.com/vitalygashkov/fmptools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254404347,"owners_count":22065641,"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":["fmp","foresight"],"created_at":"2025-02-17T13:16:43.943Z","updated_at":"2025-05-15T19:10:41.628Z","avatar_url":"https://github.com/vitalygashkov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/fmptools\"\u003e\u003cimg alt=\"npm-badge\" src=\"https://img.shields.io/npm/v/fmptools.svg?colorB=ff733e\" height=\"20\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/fmptools\"\u003e\u003cimg alt=\"npm-downloads-badge\" src=\"https://img.shields.io/npm/dm/fmptools.svg?colorB=53aabb\" height=\"20\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/fmptools\"\u003e\u003cimg alt=\"npm-downloads-badge\" src=\"https://img.shields.io/npm/dt/fmptools.svg\" height=\"20\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/vitalygashkov/fmptools/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/fmptools\" alt=\"license-badge\" height=\"20\"\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003efmptools is a set of \u003ca href=\"https://www.fsight.ru/en/mobile-platform/\" title=\"Foresight Mobile Platform\"\u003eFMP\u003c/a\u003e utilities for transforming RPC requests\u003c/h4\u003e\n\n### Install\n\n```sh\nnpm i fmptools\n```\n\n### Usage\n\nUse Axios interceptors to convert response and/or request data automatically for all FMP requests:\n\n```javascript\nimport axios from 'axios';\nimport { createRequestInterceptor, createResponseInterceptor } from 'fmptools';\n\nconst http = axios.create();\n\nconst init = async () =\u003e {\n  const { data: schema } = await http.get('https://example.com/api/v1/schema');\n\n  const requestInterceptor = createRequestInterceptor(schema);\n  http.interceptors.request.use(requestInterceptor);\n\n  const responseInterceptor = createResponseInterceptor(schema);\n  http.interceptors.response.use(responseInterceptor);\n};\n\nconst makeRequest = async () =\u003e {\n  const url = 'https://example.com/api/v1/rpc/ZFM_USERDATA/';\n  const { data: responseData } = await http.post(url);\n  return responseData;\n};\n```\n\nOr convert response/request data manually:\n\n```javascript\nimport axios from 'axios';\nimport { convertRequestData, convertResponseData } from 'fmptools';\n\nconst makeRequest = async () =\u003e {\n  const { data: schema } = await axios.get('https://example.com/api/v1/schema');\n\n  const resource = 'ZFM_CREATE_TASK';\n  const requestData = {\n    IT_DATA: [\n      {\n        TITLE: 'Task #1',\n        USERID: 1,\n        DATE: '2023-09-26',\n        TIME: '06:48:17',\n        EMAIL: 'example1@mail.com',\n      },\n    ],\n  };\n  /* Table entities will be converted to rows as arrays\n   * IT_DATA: [['Task #1', 1, '2023-09-26', '06:48:17', 'example1@mail.com']]\n   */\n  const requestDataConverted = convertRequestData(requestData, schema, resource);\n  const url = `https://example.com/api/v1/rpc/${resource}/`;\n  const options = { data: requestDataConverted };\n  const { data } = await axios.post(url, options);\n  const responseData = convertResponseData(data, schema, resource);\n  return responseData;\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalygashkov%2Ffmptools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitalygashkov%2Ffmptools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalygashkov%2Ffmptools/lists"}