{"_id":"@4efficiency/ra-data-odata-server","_rev":"6-8c9404531de5bacd891df7417a49570a","name":"@4efficiency/ra-data-odata-server","dist-tags":{"latest":"4.3.4"},"versions":{"4.3.1":{"name":"@4efficiency/ra-data-odata-server","version":"4.3.1","keywords":["odata","react-admin"],"author":{"name":"John Vert"},"license":"MIT","_id":"@4efficiency/ra-data-odata-server@4.3.1","maintainers":[{"name":"ihor4ef.nl","email":"ihor.matsiuk@4ef.nl"},{"name":"4efficency-admin","email":"beheerder4ef@outlook.com"},{"name":"remco4ef","email":"remco.blumink@4ef.nl"}],"homepage":"https://github.com/Groopit/ra-data-odata-server#readme","bugs":{"url":"https://github.com/Groopit/ra-data-odata-server/issues"},"dist":{"shasum":"a93277606716eefb0ebe96f2c90570f18cc7577c","tarball":"https://registry.npmjs.org/@4efficiency/ra-data-odata-server/-/ra-data-odata-server-4.3.1.tgz","fileCount":79,"integrity":"sha512-lY2SNgWnGy6EXgUD47Ob0RF4VlupIV37SeyuIf4ZhA4oDyP0VeZ8+VO9mrzjZZ94fFwr50ldB9rcMq14d6TwOg==","signatures":[{"sig":"MEQCIBFAQbvsrNoWK9y0uQ4em8AEWUax27g9+dSnKHMn16SLAiBbC1ev6GPUQcLFLdjS8li4EJfcCeoBFTfeuFR5Jp7UjQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1797916},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"238afed67fa6ac03b5733b86a6728a13240d8bd6","scripts":{"test":"jest","build":"tsc -p tsconfig.build.json"},"_npmUser":{"name":"remco4ef","email":"remco.blumink@4ef.nl"},"repository":{"url":"git+https://github.com/Groopit/ra-data-odata-server.git","type":"git"},"_npmVersion":"10.1.0","description":"OData Server data provider for react-admin","directories":{},"_nodeVersion":"20.9.0","dependencies":{"ra-core":"^5.0.2","@odata/client":"^2.21.6","fast-xml-parser":"^4.3.3"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^7.24.0","prettier":"2.6.2","babel-jest":"^29.7.0","jsonexport":"^2.4.1","typescript":"^5.5.2","@babel/core":"^7.14.3","@types/jest":"^26.0.24","@types/request":"^2.48.5","jest-fetch-mock":"^3.0.3","@tsconfig/node10":"^1.0.7","@babel/preset-env":"^7.14.2","final-form-arrays":"^3.0.2","jest-environment-jsdom":"^29.7.0","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.22.0","@typescript-eslint/eslint-plugin":"^4.22.0"},"_npmOperationalInternal":{"tmp":"tmp/ra-data-odata-server_4.3.1_1720640125649_0.7670609932507724","host":"s3://npm-registry-packages"}},"4.3.2":{"name":"@4efficiency/ra-data-odata-server","version":"4.3.2","keywords":["odata","react-admin"],"author":{"name":"John Vert"},"license":"MIT","_id":"@4efficiency/ra-data-odata-server@4.3.2","maintainers":[{"name":"ihor4ef.nl","email":"ihor.matsiuk@4ef.nl"},{"name":"4efficency-admin","email":"beheerder4ef@outlook.com"},{"name":"remco4ef","email":"remco.blumink@4ef.nl"}],"homepage":"https://github.com/Groopit/ra-data-odata-server#readme","bugs":{"url":"https://github.com/Groopit/ra-data-odata-server/issues"},"dist":{"shasum":"e38954a412b1afb48c95ef14d8fe9756e98384b9","tarball":"https://registry.npmjs.org/@4efficiency/ra-data-odata-server/-/ra-data-odata-server-4.3.2.tgz","fileCount":112,"integrity":"sha512-nxjQLYWB5B1pxNk7huU2rGLT6mcjHU25DJIcKpGhmqdoYEUvEC97XE0hRvlNAKAtkunGq56Gq5f+Aq0kJzl5iQ==","signatures":[{"sig":"MEYCIQDdUOkh4PI0mZtTPjOziB89oB54VCi5xC1rcDHBvIAZUAIhAIpkR42vQLMHm1pgFLwyy7aLuUZXvU7dZ8RyubkgceoY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1833187},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"c0286b7fb428c9a6073ef376931568dbd97e5678","scripts":{"test":"jest","build":"tsc -p tsconfig.build.json"},"_npmUser":{"name":"remco4ef","email":"remco.blumink@4ef.nl"},"repository":{"url":"git+https://github.com/Groopit/ra-data-odata-server.git","type":"git"},"_npmVersion":"10.1.0","description":"OData Server data provider for react-admin","directories":{},"_nodeVersion":"20.9.0","dependencies":{"ra-core":"^5.0.2","@odata/client":"^2.21.6","fast-xml-parser":"^4.3.3"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^7.24.0","prettier":"2.6.2","babel-jest":"^29.7.0","jsonexport":"^2.4.1","typescript":"^5.5.2","@babel/core":"^7.14.3","@types/jest":"^26.0.24","@types/request":"^2.48.5","jest-fetch-mock":"^3.0.3","@tsconfig/node10":"^1.0.7","@babel/preset-env":"^7.14.2","final-form-arrays":"^3.0.2","jest-environment-jsdom":"^29.7.0","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.22.0","@typescript-eslint/eslint-plugin":"^4.22.0"},"_npmOperationalInternal":{"tmp":"tmp/ra-data-odata-server_4.3.2_1720640423217_0.9098073802340982","host":"s3://npm-registry-packages"}},"4.3.3":{"name":"@4efficiency/ra-data-odata-server","version":"4.3.3","keywords":["odata","react-admin"],"author":{"name":"John Vert"},"license":"MIT","_id":"@4efficiency/ra-data-odata-server@4.3.3","maintainers":[{"name":"ihor4ef.nl","email":"ihor.matsiuk@4ef.nl"},{"name":"4efficency-admin","email":"beheerder4ef@outlook.com"},{"name":"remco4ef","email":"remco.blumink@4ef.nl"}],"homepage":"https://github.com/Groopit/ra-data-odata-server#readme","bugs":{"url":"https://github.com/Groopit/ra-data-odata-server/issues"},"dist":{"shasum":"13806dede018fab7b40f1ce9171f23e91c4b8901","tarball":"https://registry.npmjs.org/@4efficiency/ra-data-odata-server/-/ra-data-odata-server-4.3.3.tgz","fileCount":108,"integrity":"sha512-0+f50bYaZsJRquSOLqusSyBk/bjXatu6Qprse0hQMYlgtaKjOAAD+P6Ny1PralwGXsHb+SBJEDU548rYW2sE6A==","signatures":[{"sig":"MEQCIAVYso7rgtCT6bZdVyc/Zbdq4JieNK7l/ni2Ya5+DDfVAiBzwal0gmEhCUDfdKbXMw3zCpIyjxPuhYTywmdSyHQDkw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1791923},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"adf056477f97f3fe065243691b5a1e88e6617116","scripts":{"test":"jest","build":"tsc -p tsconfig.build.json"},"_npmUser":{"name":"remco4ef","email":"remco.blumink@4ef.nl"},"repository":{"url":"git+https://github.com/Groopit/ra-data-odata-server.git","type":"git"},"_npmVersion":"10.1.0","description":"OData Server data provider for react-admin","directories":{},"_nodeVersion":"20.9.0","dependencies":{"ra-core":"^5.0.5","@odata/client":"^2.21.10","fast-xml-parser":"^4.3.3"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^7.24.0","prettier":"2.6.2","babel-jest":"^29.7.0","jsonexport":"^2.4.1","typescript":"^5.5.2","@babel/core":"^7.14.3","@types/jest":"^26.0.24","@types/request":"^2.48.5","jest-fetch-mock":"^3.0.3","@tsconfig/node10":"^1.0.7","@babel/preset-env":"^7.14.2","final-form-arrays":"^3.0.2","jest-environment-jsdom":"^29.7.0","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.22.0","@typescript-eslint/eslint-plugin":"^4.22.0"},"_npmOperationalInternal":{"tmp":"tmp/ra-data-odata-server_4.3.3_1721834518404_0.7572259264747012","host":"s3://npm-registry-packages"}},"4.3.4":{"name":"@4efficiency/ra-data-odata-server","version":"4.3.4","keywords":["odata","react-admin"],"author":{"name":"John Vert"},"license":"MIT","_id":"@4efficiency/ra-data-odata-server@4.3.4","maintainers":[{"name":"ihor4ef.nl","email":"ihor.matsiuk@4ef.nl"},{"name":"4efficency-admin","email":"beheerder4ef@outlook.com"},{"name":"remco4ef","email":"remco.blumink@4ef.nl"}],"homepage":"https://github.com/Groopit/ra-data-odata-server#readme","bugs":{"url":"https://github.com/Groopit/ra-data-odata-server/issues"},"dist":{"shasum":"f4e01e7ac5163d8b7f13795c7402121ffc3a94cd","tarball":"https://registry.npmjs.org/@4efficiency/ra-data-odata-server/-/ra-data-odata-server-4.3.4.tgz","fileCount":108,"integrity":"sha512-iC91PxeXFN8DGmEww7ilLBve7kYdnr0KYzSkUAyz4dc5iCuCJ1iczrO6yZ6mww4MZQ5tM8rLQq4kGg9F/SKBGA==","signatures":[{"sig":"MEUCIG3xKxEU0cFWUmYM0Sj6WGcbN/RZoS+39LvQkbN50jzrAiEAs+fS9p+A6JePaBYrb3u2yl3XRLRrucpv+n3euVUFrxU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1791957},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"9b37129a4ca4c902cbb00a54487754b73949ee6c","scripts":{"test":"jest","build":"tsc -p tsconfig.build.json"},"_npmUser":{"name":"remco4ef","email":"remco.blumink@4ef.nl"},"repository":{"url":"git+https://github.com/Groopit/ra-data-odata-server.git","type":"git"},"_npmVersion":"10.1.0","description":"OData Server data provider for react-admin","directories":{},"_nodeVersion":"20.9.0","dependencies":{"ra-core":"^5.0.5","@odata/client":"^2.21.10","fast-xml-parser":"^4.3.3"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^7.24.0","prettier":"2.6.2","babel-jest":"^29.7.0","jsonexport":"^2.4.1","typescript":"^5.5.2","@babel/core":"^7.14.3","@types/jest":"^26.0.24","@types/request":"^2.48.5","jest-fetch-mock":"^3.0.3","@tsconfig/node10":"^1.0.7","@babel/preset-env":"^7.14.2","final-form-arrays":"^3.0.2","jest-environment-jsdom":"^29.7.0","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.22.0","@typescript-eslint/eslint-plugin":"^4.22.0"},"_npmOperationalInternal":{"tmp":"tmp/ra-data-odata-server_4.3.4_1730474465707_0.05997569742106301","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-07-10T19:35:25.553Z","modified":"2025-09-26T13:52:50.947Z","4.3.1":"2024-07-10T19:35:25.883Z","4.3.2":"2024-07-10T19:40:23.446Z","4.3.3":"2024-07-24T15:21:58.633Z","4.3.4":"2024-11-01T15:21:06.035Z"},"bugs":{"url":"https://github.com/Groopit/ra-data-odata-server/issues"},"author":{"name":"John Vert"},"license":"MIT","homepage":"https://github.com/Groopit/ra-data-odata-server#readme","keywords":["odata","react-admin"],"repository":{"url":"git+https://github.com/Groopit/ra-data-odata-server.git","type":"git"},"description":"OData Server data provider for react-admin","maintainers":[{"email":"remco.blumink@4ef.nl","name":"remco4ef"},{"email":"beheerder4ef@outlook.com","name":"4efficency-admin"},{"email":"evan.bruno@4ef.nl","name":"evan4ef"}],"readme":"# OData Data Provider For React-Admin\r\n\r\nOData Data Provider for [react-admin](https://github.com/marmelab/react-admin), the frontend framework for building admin applications in the browser.\r\n\r\nThis version is a fork of the original version made suitable for React-admin version 5.\r\n\r\n## Changes\r\n\r\n- add q_int filter to search for a numeric column containing some numbers \r\n\r\n## Features\r\n\r\n- Parses OData $metadata and creates a list of EntitySets which can be displayed as react-admin \\<Resources\\>\r\n- Transparently renames entity keys to 'id' fields so they can be used by react-admin.\r\n- Handles scalar keys (Edm.Int16, Edm.Int32, Edm.Int64 and Edm.Guid) correctly so you can directly use EntitySets with integer or guid keys.\r\n- extends the react-admin `getManyReference()` method to support expanding child relations.\r\n\r\n## Installation\r\n\r\n```sh\r\nnpm install --save ra-data-odata-server\r\n```\r\n\r\n## Usage\r\n\r\nInitializing the OData provider requires loading and parsing the OData service's manifest. Since that is an async operation, you need to make sure it is complete before passing the provider to react-admin. An easy way to do that is the React `useEffect()` hook.\r\n\r\nOnce the provider is initialized, you can use the `getResources()` method to get a list of EntitySets that can be used directly by react-admin.\r\n\r\n```ts\r\nimport odataProvider, { OdataDataProvider } from \"ra-data-odata-server\";\r\n\r\nfunction App() {\r\n  const [dataProvider, setDataProvider] = useState<OdataDataProvider>();\r\n  useEffect(() => {\r\n    odataProvider(\r\n      \"https://services.odata.org/v4/Northwind/Northwind.svc/\"\r\n    ).then((p) => setDataProvider(p));\r\n    return () => {};\r\n  }, []);\r\n\r\n  return dataProvider ? (\r\n    <Admin dataProvider={dataProvider}>\r\n      {dataProvider.getResources().map((r) => (\r\n        <Resource\r\n          key={r}\r\n          name={r}\r\n          list={ListGuesser}\r\n          edit={EditGuesser}\r\n          show={ShowGuesser}\r\n        />\r\n      ))}\r\n    </Admin>\r\n  ) : (\r\n    <Loading></Loading>\r\n  );\r\n}\r\n```\r\n\r\nSee the [example directory](https://github.com/Groopit/ra-data-odata-server/tree/main/example) for a complete working react-admin 4.x solution that runs against the Northwind odata service.\r\n\r\n### List Filters\r\n\r\nThis provider has support for [react-admin filter operators](https://marmelab.com/react-admin/FilteringTutorial.html#filter-operators). By appending an underscore and operator name to an identifier, you can override the default 'Contains' operator. The following operators are supported\r\n\r\nSuffix | [OData filter](http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Filter_System_Query) | example\r\n---|---|---|\r\n_neq| ne | `filter: {email_neq: \"test@example.com\"}`\r\n_eq| eq | `filter: {name_eq: \"John Smith\"}`\r\n_lte| le | `filter: {price_lte: 0.99}`\r\n_lt| lt | `filter: {price_lt: 1}`\r\n_gte| ge | `filter: {price_gte: 1}`\r\n_gt| gt | `filter: {quantity_gt: 10}`\r\n_eq_any| in | `filter: {quantity_eq_any: [10, 20]}`\r\n_neq_any| not in | `filter: {quantity_neq_any: [10, 20]}`\r\n_inc| eq (AND) | `filter: {quantity_inc: [10, 20]}`\r\n_inc_any| eq (OR) | `filter: {quantity_inc_any: [10, 20]}`\r\n_ninc_any| ne (AND) | `filter: {quantity_ninc_any: [10, 20]}`\r\n_boolean| eq | `filter: {active_boolean: true}`\r\n_q| contains | `filter: {name_q: \"John\"}`\r\n_q_int | contains (int) | `filter: {number_q_int: \"123\"}`\r\n\r\nIf the filter field name is `q`, then it is converted to a search query:\r\n\r\n```\r\nfilter: {q: \"John\"} -> $search=John\r\n```\r\n\r\nIf a suffix operator is not supplied, then the default filter operator is `Contains` to search a field for a substring.\r\n\r\nMultiple filters can also be combined and used directly with the [`<List>`](https://marmelab.com/react-admin/List.html) component.\r\n\r\n```ts\r\n<List resource=\"posts\"\r\n    filter={{\r\n      author_eq: \"John Smith\",\r\n      published_at_gte: \"2020-01-01T23:59:59.99Z\"\r\n    }}>\r\n    <Datagrid rowClick=\"show\">\r\n      <TextField source=\"id\" />\r\n      <TextField source=\"title\" />\r\n      <DateField source=\"published_at\" />\r\n      <TextField source=\"category\" />\r\n      <BooleanField source=\"commentable\" />\r\n    </Datagrid>\r\n</List>\r\n```\r\n\r\n### List Sorting\r\n\r\nThe name of the field to be sorted is converted to a format that OData understands. For example, \"category.name\" will turn into \"Category/Name\".\r\n\r\n```ts\r\n<List resource=\"posts\"\r\n    filter={{\r\n      author_eq: \"John Smith\",\r\n      published_at_gte: \"2020-01-01T23:59:59.99Z\"\r\n    }}>\r\n    <Datagrid rowClick=\"show\">\r\n      <TextField source=\"id\" />\r\n      <TextField source=\"title\" />\r\n      <DateField source=\"published_at\" />\r\n      <TextField source=\"category\" sortBy=\"category.name\" />\r\n      <BooleanField source=\"commentable\" />\r\n    </Datagrid>\r\n</List>\r\n```\r\n\r\n### Select fields\r\n\r\nIf the API provides more data than necessary, then you can request only those fields that are needed.\r\n\r\n```ts\r\n<ReferenceInput\r\n  source=\"user.id\"\r\n  reference=\"users\"\r\n  queryOptions={{\r\n    meta: {\r\n      select: [\"firstName\", \"lastName\", \"fullName\"]\r\n    }\r\n  }}\r\n  fullWidth\r\n  sort={{ field: \"lastName\", order: \"ASC\" }}\r\n  perPage={0}\r\n>\r\n  <AutocompleteInput\r\n    optionText=\"fullName\"\r\n    filterToQuery={(q) => ({ q })}\r\n  />\r\n</ReferenceInput>\r\n```\r\n\r\n### Expand fields\r\n\r\nIf an entity has nested fields, you can ask the API to include them in the response.\r\n\r\n```ts\r\n<ReferenceInput\r\n  source=\"company.id\"\r\n  reference=\"companies\"\r\n  queryOptions={{\r\n    meta: {\r\n      expand: [\"city\", \"city.info\", \"city.info.company\"]\r\n    }\r\n  }}\r\n  fullWidth\r\n  sort={{ field: \"name\", order: \"ASC\" }}\r\n  perPage={0}\r\n>\r\n  <AutocompleteInput\r\n    optionText=\"name\"\r\n    filterToQuery={(q) => ({ q })}\r\n  />\r\n</ReferenceInput>\r\n```\r\n\r\n### OData Actions\r\n\r\nThis provider has built-in support for invoking OData actions. This works with react-admin's\r\nmutation support. For example, if you had an 'Approve' action for an OData comment, you could\r\ninvoke it like this:\r\n\r\n```ts\r\nimport * as React from \"react\";\r\nimport { useMutation } from \"react-query\";\r\nimport { useDataProvider, Button } from \"react-admin\";\r\n\r\nconst ApproveButton = ({ record }) => {\r\n  const dataProvider = useDataProvider();\r\n  const { mutate, isLoading } = useMutation(() =>\r\n    dataProvider.action(\"comments\", {\r\n      id: record.id,\r\n      action: \"approve\",\r\n      payload: { isApproved: true },\r\n    })\r\n  );\r\n  return (\r\n    <Button label=\"Approve\" onClick={() => mutate()} disabled={isLoading} />\r\n  );\r\n};\r\n```\r\n\r\n### Child relationships\r\n\r\nOData supports hierarchical relationships - e.g. `/Customers('ALFKI')/Orders` returns all the order entities related to the customer with ID 'ALFKI'. In order to support this type of query in react-admin, the `getManyReferences()` filter is enhanced with a 'parent' property. You can pass this to the standard \\<ReferenceManyField> react-admin component. For example, when the current record is a customer, you can display all that customer's orders with this syntax\r\n\r\n```tsx\r\n<ReferenceManyField\r\n  label=\"Customer Orders\"\r\n  reference=\"Orders\"\r\n  target=\"Orders\"\r\n  filter={{ parent: \"customers\" }}\r\n>\r\n  <SingleFieldList linkType=\"show\">\r\n    <ChipField source=\"id\" />\r\n  </SingleFieldList>\r\n</ReferenceManyField>\r\n```\r\n\r\nThis also supports many-to-many relationships without requiring that your service exposes an intermediate join table as a resource.\r\n\r\n## Authentication hook\r\n\r\nTo support OData servers that require authentication, you can provide an options callback when creating the data provider. This will get called before each query and must return a `Partial<ODataNewOptions>`. Notably the `commonHeaders` property of this object will be added to each outgoing\r\nHTTP request. For example, if you have a `getAccessToken()` function that returns a `Promise<string>` you would initialize your provider like this.\r\n\r\n```ts\r\nodataProvider(\"https://myodataservice.com/odata\", () => {\r\n  return getAccessToken().then((token) => ({\r\n    commonHeaders: {\r\n      Authorization: \"Bearer \" + token,\r\n    },\r\n  }));\r\n}).then((provider) => setDataProvider(provider));\r\n```\r\n\r\n## Fetch proxy interface\r\n\r\nIf your authentication requires more than just a header (cookie-based authentication, for instance) you can provide a\r\n[fetchProxy](https://github.com/Soontao/light-odata/blob/HEAD/docs/Advanced.md#fetch-proxy) property which can implement\r\nany fetch() behavior you need.\r\n\r\n```ts\r\nodataProvider(\"https://myodataservice.com/odata\", () => {\r\n  fetchProxy: async (url, init) => {\r\n    // just add some transform here\r\n    // for example, add headers, change url, rate limit, retry ...\r\n    const response = await fetch(url, {\r\n      method: init.method,\r\n      credentials: \"include\",\r\n      headers: {\r\n        \"Content-Type\": \"application/json\",\r\n        \"X-Some-Custom\": \"Header\",\r\n      },\r\n    });    let content: any;\r\n    if (\r\n      //\r\n      // Check to see if the returned content is JSON\r\n      //\r\n      response.headers\r\n        .get(\"content-type\")\r\n        ?.indexOf(\"application/json\") !== -1\r\n    ) {\r\n      content = await response.json();\r\n    } else {\r\n      content = await response.text();\r\n    }\r\n    return { content, response }; // the content is an object\r\n  },\r\n}).then((provider) => setDataProvider(provider));\r\n```\r\n\r\n## Known Limitations\r\n\r\n- EntitySets with no keys or compound keys are not supported - react-admin only supports string keys\r\n- EntityType inheritance doesn't work\r\n\r\n## License\r\n\r\nThis data provider is licensed under the MIT License, and sponsored by [Groopit](https://groopit.co).\r\n","readmeFilename":"readme.md"}