Code Monkey home page Code Monkey logo

jaystack / odata-v4-server Goto Github PK

View Code? Open in Web Editor NEW
73.0 18.0 55.0 2.4 MB

With JayStack OData v4 Server you can build your own data endpoints without the hassle of implementing any protocol-level code. This framework binds OData v4 requests to your annotated controller functions, and compiles OData v4 compatible response. Clients can access services through OData-compliant HTTP requests. We recommend the JayData library for consuming OData v4 APIs.

Home Page: https://jaystack.com/products/jaystack-odata-v4-server/

TypeScript 99.85% JavaScript 0.15%
odata nodejs typescript

odata-v4-server's Introduction

JayStack OData V4 Server

OData V4 server for node.js

Features

  • OASIS Standard OData Version 4.0 server
  • usable as a standalone server, as an Express router, as a node.js stream or as a library
  • expose service document and service metadata - $metadata
  • setup metadata using decorators or metadata JSON
  • supported data types are Edm primitives, complex types, navigation properties
  • support create, read, update, and delete entity sets, action imports, function imports, collection and entity bound actions and functions
  • support for full OData query language using odata-v4-parser
    • filtering entities - $filter
    • sorting - $orderby
    • paging - $skip and $top
    • projection of entities - $select
    • expanding entities - $expand
    • $count
  • support sync and async controller functions
  • support async controller functions using Promise, async/await or ES6 generator functions
  • support result streaming
  • support media entities

Controller and server functions parameter injection decorators

  • @odata.key
  • @odata.filter
  • @odata.query
  • @odata.context
  • @odata.body
  • @odata.result
  • @odata.stream

Example Northwind server

export class ProductsController extends ODataController{
    @odata.GET
    find(@odata.filter filter:ODataQuery){
        if (filter) return products.filter(createFilter(filter));
        return products;
    }

    @odata.GET
    findOne(@odata.key key:string){
        return products.filter(product => product._id == key)[0];
    }

    @odata.POST
    insert(@odata.body product:any){
        product._id = new ObjectID().toString();
        products.push(product);
        return product;
    }

    @odata.PATCH
    update(@odata.key key:string, @odata.body delta:any){
        let product = products.filter(product => product._id == key)[0];
        for (let prop in delta){
            product[prop] = delta[prop];
        }
    }

    @odata.DELETE
    remove(@odata.key key:string){
        products.splice(products.indexOf(products.filter(product => product._id == key)[0]), 1);
    }
}

export class CategoriesController extends ODataController{
    @odata.GET
    find(@odata.filter filter:ODataQuery){
        if (filter) return categories.filter(createFilter(filter));
        return categories;
    }

    @odata.GET
    findOne(@odata.key key:string){
        return categories.filter(category => category._id == key)[0];
    }

    @odata.POST
    insert(@odata.body category:any){
        category._id = new ObjectID().toString();
        categories.push(category);
        return category;
    }

    @odata.PATCH
    update(@odata.key key:string, @odata.body delta:any){
        let category = categories.filter(category => category._id == key)[0];
        for (let prop in delta){
            category[prop] = delta[prop];
        }
    }

    @odata.DELETE
    remove(@odata.key key:string){
        categories.splice(categories.indexOf(categories.filter(category => category._id == key)[0]), 1);
    }
}

@odata.cors
@odata.controller(ProductsController, true)
@odata.controller(CategoriesController, true)
export class NorthwindODataServer extends ODataServer{}
NorthwindODataServer.create("/odata", 3000);

odata-v4-server's People

Contributors

holocron avatar lazarv avatar slajher avatar tisos avatar tlvarga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

odata-v4-server's Issues

Support for other property attributes?

I've been looking for a way to add attributes like maxLength, precision, and scale using decorators. So far, I haven't had any luck. Is there a way to do this with model classes directly, or does it require lower level solutions like a schema.json file or using odata-v4-metadata?

Needs License Information

Can you add a license.txt file to your odata server repos? Without it, the libraries aren't particularly useful...

Potential issue with metadata=full and $select

I haven't been able to find a definitive answer on this, so it might be undefined behavior in the OData spec. But right now, the server returns <property>@odata.type metadata about non-string/non-boolean properties that are excluded via the $select query parameter when a request is made with odata.metadata=full.

For example, if you have a Product model with id, description, price, and quantity properties and you issue a request to the server that includes odata.metadata=full and $select=id. The value section of the response would look something like this, even though price and quantity were not selected:

{
            "@odata.id": "http://www.example.com/odata/Product(1)",
            "@odata.type": "#Product",
            "[email protected]": "#Int64",
            "id": 11,
            "[email protected]": "#Decimal",
            "[email protected]": "#Int64",
}

Salesforce's built-in OData connector errors out in this situation, stating that it can't deserialize the response. Their implementation seems to rely on the type metadata only being included for the fields listed in $select, which seems like a reasonable expectation. But, like I said, I'm not sure what the spec actually calls for. So I don't know who's "right" in this case.

The relevant section of the code base appears to be here:

} else if (type != "Edm.String" && type != "Edm.Boolean") {

Add plain js example

Would it be possible to add an example using plain javascript with no decorators being used?

Thx

Prepare feature list

  • we need a full feature list for review (possible pro features ?)
  • we need a blog material to the release and showcase post

?$expand does not work properly

Expand seems to be broken on both of these examples

https://github.com/jaystack/odata-v4-server-mongodb-example
https://github.com/jaystack/odata-v4-server-mssql-example

If you visit http://services.odata.org/V4/ samples and use the following url

http://services.odata.org/V4/(S(ggb5l0d13uzsg0ro2qgrpoa4))/TripPinServiceRW/People?$expand=Trips

You will see you can get People and also their Trips

But if you try to do a similar query with odata-v4-server it breaks. For example

this breaks

http://localhost:3000/Products?$expand=Category

The console pumps out this error ( Im using the SQL server example in this case )

image

(node:10068) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'length' of undefined
(node:10068) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I can see the navigation property for Category is indeed there
image

Is this a bug, or am I not using this navigation property the way its intended? Is there some kind of Containment property that needs to be included on the NavigationProperty?

I did notice the navigation property in the services.odata.org sample is different, and includes a ContainsTarget property.

image

My details

Windows 10 Pro x64
Node version 8.1.1
npm version 5.0.3

The MS SQL Server sample has the following dependencies

"devDependencies": {
"@types/express": "^4.0.34",
"@types/mssql": "^3.1.30",
"chai": "^3.5.0",
"mocha": "^3.2.0",
"mochawesome": "^1.5.4",
"typescript": "^2.0.10"
},
"dependencies": {
"express": "^4.14.0",
"msnodesqlv8": "^0.2.10",
"mssql": "^3.3.0",
"odata-v4-mssql": "^0.1.0",
"odata-v4-server": "^0.1.15"
}

How to run the odata-v4-server on iis

Hi I have a iis setup that is able to run node js files, for that i used this guide
https://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx

after the iis setup is done, basically I just need to point the browser to the url of the js file containing the server like this "http://localhost/node/helloworld/hello.js"

but i the case of the odata server to start it, I use the command npm start. so for me is not clear to which js file should I point to start the saver as I do when I use node in iis

Pull Requests accepted?

Are pull requests accepted?

I submitted PR #31 but haven't seen any activity on it.

If there's something else I need to do please let me know.

Thanks!

Create a shim to share model

If you want to share your typescript model classes between client(frontend) and server(backend) you'll need a shim for the @Edm decorators.

Problem with circular dependecies

I want to have a model with circular dependencies. Something like this:
Product
{
category: Category
}

Category
{
products: Product[]
}

I prepared this model using annotations and plain classes, but it generates incorrect metadata.
Type of navigation property products is Collection. It should be Collection(Product).

When I used previous version of your library it started to working ok.

Incorrect metadata for:
"odata-v4-mongodb": "^0.1.12",
"odata-v4-server": "^0.2.10"

Correct metadata for:
"odata-v4-mongodb": "^0.1.9",
"odata-v4-server": "^0.1.38"

Maybe I should generate my model using different approach? Can you help me?

After pulling down the latest changes from master, tsc fails with dozens of errors.

I have verified that my workspace is clean by creating a fresh clone of master. Running 'npm install' triggers a run of tsc, which results in dozens of errors like

src/example/advanced.ts(17,5): error TS1241: Unable to resolve signature of method decorator when called as an expression.
  Type 'ExpressionDecorator' has no properties in common with type 'TypedPropertyDescriptor<(query: Token, stream: Writable) => Promise<Writable>>'.

and a couple like

src/lib/result.ts(29,25): error TS2345: Argument of type 'this' is not assignable to parameter of type 'Readable | PromiseLike<Readable>'.
  Type 'ODataStream' is not assignable to type 'Readable | PromiseLike<Readable>'.
    Type 'ODataStream' is not assignable to type 'PromiseLike<Readable>'.
      Type 'this' is not assignable to type 'PromiseLike<Readable>'.
        Type 'ODataStream' is not assignable to type 'PromiseLike<Readable>'.
          Property 'then' is missing in type 'ODataStream'.

This is using node lts/boron. Should I be using something else? Would that affect tsc?

Unsupported features

Hi
I have a question about unsupported odata-v4-server features (http://jaydata.org/jaystack-odata-v4-server-features)

Now I'm choosing tech stack for the OData API project based on the data from MSSQL database. Nodejs with jaydata/odata-v4-server looks like a good candidate for it, but the goal of the project is 100% compliance with the OData standard.

In the same time JayStack OData v4 Server doesn't support a set of features.

So the questions are:

  1. Is it possible to implement unsupported features by myself on the server level or these features are unsupported on the JayData library / odata-v4-parser?
  2. Does the odata-v4-parser support 100% of OData standard ?
  3. If unsupported features are unsupported on server/jaydata lib level, but supported by odata-v4-parser, is there some ways/examples etc. how is it possible to create missing features ?

Issues with the $filter, $select and other QueryOperations

Hello @lazarv

I see some issues with the odata-v4-server ODataQuery, the request query which is received in the controller has duplicated parameters. As a result of duplicate parameters the query generated by odata-v4-sql are incorrect. I feel there is a potential bug in the Visitor class.

Below is the screenshot for reference.

image

`import {
odata,
ODataController,
ODataServer,
ODataQuery,
Edm
} from "odata-v4-server";
import { createQuery, createFilter } from "odata-v4-sql";

export default class employee {
@Edm.Key
@Edm.Computed
@Edm.String
id: string;
@Edm.String name: string;
@Edm.String email: string;
@Edm.String department: string;
@Edm.String countryCode: string;
}

@odata.type(employee)
export class EmployeeController extends ODataController {
@odata.GET
async find(@odata.query query: ODataQuery) {
console.log("Query Received in controller - ", query);
const sqlQuery = createQuery(query);
console.log("SQL Query Returned from odata-v4-sql - ", sqlQuery);
return [];
}
}

@odata.cors
@odata.controller(EmployeeController, "employee")
export class NorthwindODataServer extends ODataServer {}

NorthwindODataServer.create("/", 3003);
console.log("Odata Server Running at / on port 3003");`

how to turn the generic implementation into specific mysql , mongo or postgress setup

Hi i have been able to setup the odata server for postgres using the following repository

https://github.com/jaystack/odata-v4-server-pgsql-example

the repository contains the source with all needed references to connect to postgres serve a model, now I wonder, how can you start from the scratch with just the odata-v4-server and add the correct connectors to connect to an specific database.

can you provide an example to achieve my goal? to turn the generic version of the server and the turn it into a postgres , mongo or mysql odata server

CORS pre-flight in server instance

Hi.

I'm trying to use this odata-v4-server as a service with sap open ui5 framework in couple. Using @odata.cors don't satisfy requirements of open ui5 because they actively using "options" request for pre-flight check. In this case i enhance static create method of class ODataServerBase to support pre-flight conditions in this way

....
if (server.cors) {
var corsOpt = {
origin: ['http://localhost:8080', 'http://localhost'],
optionsSuccessStatus: 204,
exposedHeaders: ['OData-Version']
}
router.options('*', cors(corsOpt))
router.use(cors(corsOpt));
}

May be exists another way, supported by this odata-v4-server api? Using a router class as optional parameter of create method can be is alternative solution.

P.S. using router instance, that returned by create method(without port parameter request) has no effect. If reffer to documentation of npm cors package, using pre-flight conditions have to declare before any router definition in express instance.

How can I use generic query string parameters for apikeys

Hi,

I have a large recordset that holds records owned by different users. Now I want to enable them to use OData to query their (!) data only.

My ideas were like this:

  1. server/xyz/Records (this would get all records for the user with apikey xyz)
  2. server/Records?apikey=xyz

Option 1 should be easy enough, as xyz is in the context, but I can't access it from my "find" GET function. That one only has query.

Option 2 throws an error.

How can I do this? Thanks for your help.

What about a $batch for odata v4

Hi, thank you for your work. This looks very greate and frendly for consumers :)

i'm looking for odata v4 $batch implementation handler. May be exists some example for this?

Cannot create Collection property decorator with EnumTypes

When annotating a class' properties like so:

@Collection(Edm.EnumType(Foo))
Bar!: Foo;

The metadata returned looks like the following:
<Property Name="Bar" Type="Collection([object Object])"/>

Are there additional steps required to make this work?

Is this project dead?

There hasn't been any activity in this repository for a while. Has the project moved or is it dead?

Support cancellation of long running requests

I am using odata-v4-server to pump several GB of data into MS PowerBI. Ideally, if I cancel a query in PowerBI, the query should be canceled in node.js.

I can currently do this by hacking around with the one of the private properties on the ODataProcessor that is passed into the streaming get handler in my controller.

Would it be possible to expose this event (or the entire request) to the controller GET methods so that long running streaming responses can be cancelled if the request is cancelled by the client?

Here is the hack:

        if (stream instanceof ODataProcessor) {
            let p = stream as any;
            p.context.request.on("close", () => {
                reader.close();
             });
        }

In context:

@odata.type(AwesomeBusinessObject)
@Edm.EntitySet("AwesomeBusinessObjects")
class AwesomeBusinessObjectController extends ODataController {
    @odata.GET
    async getItems( @odata.stream stream: Writable) {
        let reader = fs.createReadStream("data/table_of_awesome_business_objects_000.tsv");
        let parser = new Parser({ delimiter: "\t", rowDelimiter: "\n", columns: headers }); // csv parser
        let mapper = new AwesomeBusinessObjectMapper(); // map from csv -> odata entity

        // close the reader if the request is closed. 
        if (stream instanceof ODataProcessor) {
            let p = stream as any;
            p.context.request.on("close", () => {
                reader.close();
             });
        }

        return reader
            .pipe(parser)
            .pipe(mapper)
            .pipe(stream);
    }
}

Missing support for OData Batch Requests

Hi,

suddenly there is no support for OData V4 batch requests. Is it planned to add this? Implementing with UI5 the OData V4 model only gives you the ability to commit changes per batch requests.

When sending a batch request server.ts will throw an error on line 273, because the incoming content-type is multipart/mixed. I think the request has to be cut and processed part-by-part somewhere around this.

Regards

error TS2304: Cannot find name 'Token' (Cannot import EDM)

Transpiling this source with the below tsconfig: import { Edm } from 'odata-v4-server' generates the below compiler error and trace:

{
    "compilerOptions": {
        "target": "es6",
        "experimentalDecorators": true,
        "moduleResolution": "node"
    }
}
PS C:\Users\guscr\Desktop\odata-v4-server-issue> tsc
node_modules/odata-v4-server/build/lib/controller.d.ts(7,45): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/odata.d.ts(41,29): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/odata.d.ts(42,38): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/odata.d.ts(49,31): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/odata.d.ts(50,40): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/odata.d.ts(66,26): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/odata.d.ts(67,35): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/server.d.ts(34,45): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(8,11): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(12,11): error TS2304: Cannot find name 'TokenType'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(15,11): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(32,10): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(41,17): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(42,35): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(43,39): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(44,33): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(45,37): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(46,33): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(47,40): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(48,39): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(49,46): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(50,43): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(51,48): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(52,43): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(53,49): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(54,40): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(55,43): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(56,46): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(57,47): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(58,51): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(59,48): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(60,52): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(61,40): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(62,33): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(63,37): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(64,37): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(65,29): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(66,38): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(67,40): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(68,39): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(69,42): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(70,40): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(71,42): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(72,47): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(73,51): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(74,36): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(75,38): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(76,44): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(77,43): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(78,39): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(79,35): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(80,42): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(81,40): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(82,41): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(83,42): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(84,44): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(85,45): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(86,44): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(87,43): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(88,41): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(89,34): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(90,33): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(91,31): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(92,36): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(93,44): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(94,42): error TS2304: Cannot find name 'Token'.
node_modules/odata-v4-server/build/lib/visitor.d.ts(95,41): error TS2304: Cannot find name 'Token'.

Do you have an example to show how to self-reference the model

`
@Edm.Annotate({
term: "UI.DisplayName",
string: "Products"
})

export class Product{
@Edm.Key
@Edm.Computed
@Edm.String
@Edm.Convert(toObjectID)
@Edm.Annotate({
term: "UI.DisplayName",
string: "Product identifier"
}, {
term: "UI.ControlHint",
string: "ReadOnly"
})
_id:ObjectID
@Edm.ForeignKey("Product")
@Edm.EntityType(Edm.ForwardRef(() => Product))
@Edm.Partner("Product")
Product:Product
UnitPrice:number
}

`

Compilation error

Transform class changed inside so now ODataProcessor should be adjusted.
to reproduce:
create a fresh project with one line only
import { ODataServer, ODataController, Edm, odata, ODataQuery } from "odata-v4-server";

try to compile. you'll get
node_modules/odata-v4-server/build/lib/processor.d.ts(19,22): error TS2415: Clas
s 'ODataProcessor' incorrectly extends base class 'Transform'.
Property '_transform' is protected in type 'ODataProcessor' but public in type
'Transform'.

could be solved by changing
protected _transform(chunk:any, encoding:string, done:Function){
to
public _transform(chunk:any, encoding:string, done:Function){
in processor.ts

TypeError (reflect-metadata) on mysql-and other examples

npm test and npm start fails

i'm new with odata-v4-server and tried to run the mysql example on a installation of

- node v8.15.0
- odata-v4-server v0.2.13
- odata-v4-mysql v0.1.1
- mysql v2.16.0
- reflect-metadata v0.1.13

The metadata of the service could not be generated out of the model data.
I got the following error:

node .

C:\jaydata\odata-v4-server-example-03\node_modules\reflect-metadata\Reflect.js:228
throw new TypeError();
^

TypeError
at Object.defineMetadata (C:\jaydata\odata-v4-server-example-03\node_modules\reflect-metadata\Reflect.js:228:23)
at C:\jaydata\odata-v4-server-example-03\node_modules\odata-v4-server\build\lib\edm.js:946:25
at DecorateProperty (C:\jaydata\odata-v4-server-example-03\node_modules\reflect-metadata\Reflect.js:553:33)
at Object.decorate (C:\jaydata\odata-v4-server-example-03\node_modules\reflect-metadata\Reflect.js:123:24)
at __decorate (C:\jaydata\odata-v4-server-example-03\lib\model.js:4:92)
at Object. (C:\jaydata\odata-v4-server-example-03\lib\model.js:57:1)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1

It seems there is a problem with the EntityType's.
I could not find any solution, how to define the navigation properties in the model file.

Any ideas ?

Regards
Jürgen

Use as SVC

Hi !
How can I use my server as OData Service ?
image
Thanks

tsc compilation error with @types/node 10.9.4

A project using odata-v4-server npm package and with @types/node version 10.9.4 will throw an error when compiling TypeScript:

src/lib/processor.ts:383:7 - error TS2415: Class 'ODataStreamWrapper' incorrectly extends base class 'Transform'.
  Property '_flush' is protected in type 'ODataStreamWrapper' but public in type 'Transform'.

383 class ODataStreamWrapper extends Transform {
          ~~~~~~~~~~~~~~~~~~


src/lib/processor.ts:431:14 - error TS2415: Class 'ODataProcessor' incorrectly extends base class 'Transform'.
  Property '_flush' is protected in type 'ODataProcessor' but public in type 'Transform'.

431 export class ODataProcessor extends Transform {
                 ~~~~~~~~~~~~~~

The fix is to change both _flush methods in processor.ts to public instead of protected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.