Missing "types" property of #google-vision npm package - node.js

When trying to use the "types" enum of the google-vision package an error is thrown, and no such property exists in the object.
The documentation on how to use is here:
https://cloud.google.com/nodejs/docs/reference/vision/0.19.x/v1.ImageAnnotatorClient#methods
This is the code and error. You can see in the variables section on the left there is no "types" property to the object.
The documentation it states i should access the types of fearture like this:
[{type: vision.types.Feature.Type.FACE_DETECTION},
{type: vision.types.Feature.Type.WEB_DETECTION}]
I believe this is what I have done.
I would appreciate any comments on what the problem may be.
Thanks
Andrew

The nodejs sample code uses strings instead of enums. Can you try using a string instead?

Related

IBM ODM cannot generate a valid WADL

I've been plagued for months with an error in ODM.
It doesn't prevent my services from working, it only prevents ODM from automatically generating the JSON input payload when I test a service through the Rule Execution Server (the Retrieve HTDS Description File).
I attached a screenshot of the error.
What is puzzling is that:
if I move my variable from Input to Output, then the JSON gets generated in the Server Response section
if I manually enter my own JSON, the service executes correctly and I get back a decision
Does anyone have any idea what could possibly be wrong here?
Very likely your variable is not being deserialized properly. This would explain both the error you are getting and why you get it only as an input variable.
We get a similar error using a java.tim.ZonedDateTime with ODM 8.9.1, which does not support the java.time package. We just ignore the error -- and are hoping we can avoid it when we move to ODM 8.10.2.
hard to help as some of the context is missing. However the symptoms you describe tells there is a serialization issue one of the class of the HTDS interface.
It could be :
a getter/setter missing
a dependency missing in the XOM (classloader)
or a #jsonIgnore missing on a non getter/setter method whose name starts by get or set.
Best
Emmanuel

How to find type definition file for xss-clean npm library

I just started to learn typescript and just started converting my nodejs/express application to typescript.
I have successfully got all types for the library using npm i #types/some-lib
only library, I can't find was npm i #types/xss-clean
where to find this library
import xss from 'xss-clean' //getting type definition error
app.use(xss())
If the library does not have many TypeScript users, chances are that no published types exist. In that case you can add your own to whatever degree of detail you wish.
You can create a type definition file, e.g. xss-clean.d.ts:
declare module 'xss-clean'
{
const value: Function;
export default value;
}
[More on declaration files]
You can use this page to look up if a package has types or not. xss-clean does not seem to have any types yet, so you would have to declare them by yourself.
More info on that here.

serializeBinary() not found using google-protobuf on nodejs

I could really use some help. I am trying to follow along on the google-protobuf example:
https://www.npmjs.com/package/google-protobuf
However, when I try this line of code:
// Serializes to a UInt8Array.
var bytes = message.serializeBinary();
I get a Type Error saying that serializeBinary is not a function.
Is there a different function, or something I am missing? I could really use the help.
Best Regards,
Mike
Is the problem solved now?
I had the same problem, until I realized maybe I wasn't creating a real proto object and that is why it cannot recognize serializeBinary() as a function.
True enough, my message was actually a JavaScript object.
So I had to build a proto object by following this article.
https://ednsquare.com/story/working-with-protocol-buffers-in-javascript------MaDIJH
Basically, you have to initialize your proto object and then add properties to it through the set methods. In this way, the proto object is properly built. And therefore, should have the serializeBinary() function.

Why is a global `name` variable declared in typescript and can I avoid using it?

A friend refactored some code and moved the definition of a variable called name from the function's top-level scope into a then's body. This variable was used in a subsequent then which caused a ReferenceError since name was not in scope.
We couldn't understand how the code passed compilation until we saw that typescript/lib.d.ts has the following deceleration:
declare const name: never;
Long story short, I have two questions.
Why is name (as well as length and many other globals) added by default to typescript?
From the surrounding code this seems meant for projects intended to run in a browser, we're a node.js project. Can we opt out from having these declarations added for us?
This seems to be a very old browser behaviour. Referring to the MDN both name and length are properties of the window object.
https://developer.mozilla.org/en-US/docs/Web/API/Window/name
https://developer.mozilla.org/en-US/docs/Web/API/Window/length
In order to get rid of all the DOM-specific declarations, you can set the lib property in your tsconfig accordingly. You cann see all options on this page. Take a look at the --lib flag.
An option to tell TypeScript your code runs on Node.JS would be nice. But it seems not yet implemented: https://github.com/Microsoft/TypeScript/issues/9466

SuiteScript 2.0 search.Type is undefined

I am trying something like below:
require(['N/search'],
function(search)
{
var mySearch = search.create({
type : search.Type.FOLDER,
columns : ['internalid'],
filters : [ 'internalid', 'anyof', ID]
});
mySearch.run();
});
I get an error for search.Type.FOLDER that search.Type is undefined and so cannot find FOLDER of undefined
I was able to do a workaround by writing a type as 'folder' that worked, but, why is this enum not defined if it is documented in NetSuite's help.
I tried even logging all keys using Object.keys and the returned array does not contains Type key.
Has anyone tried this or if anyone can point out if something is wrong with my code?
I don't see anything wrong with your code, and I confirmed in my own instance that the module brought in by N/search does not include a Type enum. Including the N/record module does have correctly have the Type enum, so if you want to avoid the magic string 'folder', you could import N/record and use record.Type.FOLDER instead.
It's not ideal, as what you are doing should work, but it seems there must be a bug in the search module where they're not properly returning the Type enum.

Resources