grtjn / marklogic-typescript-definitions

TypeScript Definition files for MarkLogic built-in functions, available as npm module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot Find Name 'xs'

sjordan1975 opened this issue · comments

xs namespace is missing from typings file.

See attached:
xs namespace

commented

Thnx!

@christyharagan what do you make of this?

Yup, again, just bad typing. I'll get a fix in.

Hang on a second... shouldn't that be:

fn.QName("")

@christyharagan Insert a document with the following:

declareUpdate();

xdmp.documentInsert('/test.xml', xdmp.unquote("<name>John Doe</name>"))

Then run the following query:

cts.search(cts.elementValueQuery(xs.QName("name")))

But I mean, isn't the QName function in the fn namespace, not xs.

xs.QName is the value, whereas fn.QName is the constructor.

I'm not sure about that. fn.QName is a function. xs.QName is a value ???:

https://docs.marklogic.com/fn/qname:

These built-in functions are XQuery functions defined to operate on qualified name (xs:QName) values. They are defined in XQuery 1.0 and XPath 2.0 Functions and Operators.

I think xs.QName is shorthand for fn.QName("",value) which can also be expressed simply as "value"

In QConsole, these are all equal:

cts.search(cts.elementValueQuery("name"))
cts.search(cts.elementValueQuery(xs.QName("name")))
cts.search(cts.elementValueQuery(fn.QName("","name")))
commented

Hmmm, you are right. Looking a bit deeper it's a builtin Type Constructor, and our documentation doesn't talk about builtin constructors, hence we don't generate them.

@grtjn @jmakeig : If we're going to be complete here, we should probably generate all xs. type constructors. Any ideas on where we get this? Should our docs be updated?

@grtjn @jmakeig: If we're going to be complete here, we should probably generate all xs. type constructors. Any ideas on where we get this? Should our docs be updated?

Yes. We should aim for complete coverage of the entire public API surface area—in both the docs and the typings. I think the first step will be some gap analysis. Is there a classification scheme we can start with?

  • Globals
  • Namespaces (e.g. xdmp, cts)
  • Built-in types and constructors
  • Built-in functions
  • “Proxied” XQuery functions
  • Libraries (e.g. JSearch, Optic)
commented

Not sure. Not even sure ML docs divides things in categories at all, other than perhaps by prefix, e.g. xdmp, cts, etc.

What do you mean by built-in?

“Built-in” means implemented in C++. The end-user doesn’t care where an API is implemented, but the details often matter for how we actually expose things.

commented

Fair point, but the api docs don't bother to describe the built-in types like xs:QName. We can only generate typedefs for what is provided in the apidocs. If you can get it added, then it will get included here as well.. :)

commented

This also explains why all xs: types are translated to a primitive or Object

commented

On second thought, seems like Christy did a lot of pre-work to manually add this. I'll look into making it more complete. xs.QName was already exposed in v0.3.0 of this types lib, but I'll try to add a few more..