diff --git a/.jshintrc b/.jshintrc index 1821cc99..032b0536 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,10 +1,11 @@ { - "node": true, - "curly": true, - "eqeqeq": true, - "eqnull": true, - "noarg": true, - "nonew": true, - "undef": true, - "unused": true + "esversion": 6, + "node": true, + "curly": true, + "eqeqeq": true, + "eqnull": true, + "noarg": true, + "nonew": true, + "undef": true, + "unused": true } diff --git a/LEGALNOTICES b/LEGALNOTICES new file mode 100644 index 00000000..96eccf04 --- /dev/null +++ b/LEGALNOTICES @@ -0,0 +1,8793 @@ +Open Source Product Notices +MarkLogic supported GitHub projects +Last updated: December 18, 2017 +Copyright (c) 2017-2018 MarkLogic Corporation. +MarkLogic and the MarkLogic logo are trademarks or registered trademarks of MarkLogic Corporation in +the United States and other countries. All other trademarks are the property of their respective owners. +The following software may be included in this project: +@ngrx/core 1.2.0 +Attribution Statements +https://github.com/ngrx/core + +Copyright Statements +Copyright (c) 2016 Brandon Roberts, Mike Ryan, Rob Wormald + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2016 Brandon Roberts, Mike Ryan, Rob Wormald + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Source materials are available for download at: https://github.com/ngrx/core +@ngrx/effects 2.0-3 +Attribution Statements +https://github.com/ngrx/effects + +Copyright Statements +Copyright (c) 2016 Brandon Roberts, Mike Ryan, Rob Wormald + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2016 Brandon Roberts, Mike Ryan, Rob Wormald + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Source materials are available for download at: https://github.com/ngrx/effects +@ngrx/effects 4.0.5 +Attribution Statements +https://github.com/ngrx/effects + +Copyright Statements +Copyright (c) 2016 Brandon Roberts, Mike Ryan, Rob Wormald + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2016 Brandon Roberts, Mike Ryan, Rob Wormald + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Source materials are available for download at: https://github.com/ngrx/effects +@ngrx/store 2.2.2 +Attribution Statements +https://github.com/ngrx/store + +Copyright Statements +Copyright (c) 2015 ngrx + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2015 ngrx + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/ngrx/store +@ngrx/store 4.0.3 +Attribution Statements +https://github.com/ngrx/store + +Copyright Statements +Copyright (c) 2015 ngrx + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2015 ngrx + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/ngrx/store +ag-Grid 9.0.0 +Attribution Statements +http://www.ag-grid.com + +Copyright Statements +Copyright (c) 2015-2016 AG GRID LTD + +License Text (http://spdx.org/licenses/MIT) +The MIT License + +Copyright (c) 2015-2016 AG GRID LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Source materials are available for download at: https://github.com/ceolter/ag-grid +ag-Grid Angular Component 9.0.0 +Attribution Statements +https://www.ag-grid.com/ + +Copyright Statements +Copyright (c) 2015-2016 AG GRID LTD + +License Text (http://spdx.org/licenses/MIT) +The MIT License + +Copyright (c) 2015-2016 AG GRID LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Source materials are available for download at: https://github.com/ceolter/ag-grid-angular +Angular 4.1.0 +Attribution Statements +https://angular.io/ + +Copyright Statements +Copyright (c) 2014-2017 Google, Inc. http://angular.io + +License Text (http://spdx.org/licenses/MIT) +The MIT License + +Copyright (c) 2014-2017 Google, Inc. http://angular.io + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/angular/angular +angular2-highcharts 0.5.5 +Copyright Statements +Copyright (c) 2016 Eugene Gluhotorenko + +License Text (http://spdx.org/licenses/MIT) +MIT License + +Copyright (c) 2016 Eugene Gluhotorenko + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/gevgeny/angular2-highcharts +Apache Avro(tm) 1.7.4 +Attribution Statements +http://avro.apache.org + +NUnit license acknowledgement: + +| Portions Copyright (c) 2002-2012 Charlie Poole or Copyright (c) 2002-2004 James +| W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright (c) 2000-2002 +| Philip A. Craig + +Based upon the representations of upstream licensors, it is understood that +portions of the mapreduce API included in the Java implementation are licensed +from various contributors under one or more contributor license agreements to +Odiago, Inc. and were then contributed by Odiago to Apache Avro, which has now +made them available under the Apache 2.0 license. The original file header text +is: + +| Licensed to Odiago, Inc. under one or more contributor license +| agreements. See the NOTICE file distributed with this work for +| additional information regarding copyright ownership. Odiago, Inc. +| licenses this file to you under the Apache License, Version 2.0 +| (the "License"); you may not use this file except in compliance +| with the License. You may obtain a copy of the License at +| +| http://www.apache.org/licenses/LICENSE-2.0 +| +| Unless required by applicable law or agreed to in writing, software +| distributed under the License is distributed on an "AS IS" BASIS, +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +| implied. See the License for the specific language governing +| permissions and limitations under the License. + +The Odiago NOTICE at the time of the contribution: + +| This product includes software developed by Odiago, Inc. +| (http://www.wibidata.com). + +Apache Ivy includes the following in its NOTICE file: + +| Apache Ivy +| Copyright 2007-2010 The Apache Software Foundation +| +| This product includes software developed by +| The Apache Software Foundation (http://www.apache.org/). +| +| Portions of Ivy were originally developed by +| Jayasoft SARL (http://www.jayasoft.fr/) +| and are licensed to the Apache Software Foundation under the +| "Software Grant License Agreement" +| +| SSH and SFTP support is provided by the JCraft JSch package, +| which is open source software, available under +| the terms of a BSD style license. +| The original software and related information is available +| at http://www.jcraft.com/jsch/. + +Apache Log4Net includes the following in its NOTICE file: + +| Apache log4net +| Copyright 2004-2015 The Apache Software Foundation +| +| This product includes software developed at +| The Apache Software Foundation (http://www.apache.org/). + +Copyright Statements +Copyright 2010-2015 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Source materials are available for download at: https://github.com/apache/avro +Apache Avro(tm) 1.8.1 +Attribution Statements +http://avro.apache.org + +NUnit license acknowledgement: + +| Portions Copyright (c) 2002-2012 Charlie Poole or Copyright (c) 2002-2004 James +| W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright (c) 2000-2002 +| Philip A. Craig + +Based upon the representations of upstream licensors, it is understood that +portions of the mapreduce API included in the Java implementation are licensed +from various contributors under one or more contributor license agreements to +Odiago, Inc. and were then contributed by Odiago to Apache Avro, which has now +made them available under the Apache 2.0 license. The original file header text +is: + +| Licensed to Odiago, Inc. under one or more contributor license +| agreements. See the NOTICE file distributed with this work for +| additional information regarding copyright ownership. Odiago, Inc. +| licenses this file to you under the Apache License, Version 2.0 +| (the "License"); you may not use this file except in compliance +| with the License. You may obtain a copy of the License at +| +| http://www.apache.org/licenses/LICENSE-2.0 +| +| Unless required by applicable law or agreed to in writing, software +| distributed under the License is distributed on an "AS IS" BASIS, +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +| implied. See the License for the specific language governing +| permissions and limitations under the License. + +The Odiago NOTICE at the time of the contribution: + +| This product includes software developed by Odiago, Inc. +| (http://www.wibidata.com). + +Apache Ivy includes the following in its NOTICE file: + +| Apache Ivy +| Copyright 2007-2010 The Apache Software Foundation +| +| This product includes software developed by +| The Apache Software Foundation (http://www.apache.org/). +| +| Portions of Ivy were originally developed by +| Jayasoft SARL (http://www.jayasoft.fr/) +| and are licensed to the Apache Software Foundation under the +| "Software Grant License Agreement" +| +| SSH and SFTP support is provided by the JCraft JSch package, +| which is open source software, available under +| the terms of a BSD style license. +| The original software and related information is available +| at http://www.jcraft.com/jsch/. + +Apache Log4Net includes the following in its NOTICE file: + +| Apache log4net +| Copyright 2004-2015 The Apache Software Foundation +| +| This product includes software developed at +| The Apache Software Foundation (http://www.apache.org/). + +Copyright Statements +Copyright 2010-2015 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/avro +Apache Commons CLI(tm) 1.2 +Attribution Statements +http://commons.apache.org/cli/ + +Copyright Statements +Copyright 2001-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-cli +Apache Commons Codec(tm) 1.4 +Attribution Statements +http://commons.apache.org/codec/ + +src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java +contains test data from http://aspell.net/test/orig/batch0.tab. +Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org) + +The content of package org.apache.commons.codec.language.bm has been translated +from the original php source code available at http://stevemorse.org/phoneticinfo.htm +with permission from the original authors. +Original source copyright: +Copyright (c) 2008 Alexander Beider & Stephen P. Morse. + +Copyright Statements +Copyright 2002-2016 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-codec +Apache Commons Codec(tm) 1.7 +Attribution Statements +http://commons.apache.org/codec/ + +src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java +contains test data from http://aspell.net/test/orig/batch0.tab. +Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org) + +The content of package org.apache.commons.codec.language.bm has been translated +from the original php source code available at http://stevemorse.org/phoneticinfo.htm +with permission from the original authors. +Original source copyright: +Copyright (c) 2008 Alexander Beider & Stephen P. Morse. + +Copyright Statements +Copyright 2002-2016 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Apache Commons Collections(tm) 3.2.1 +Attribution Statements +http://commons.apache.org/collections/ + +Copyright Statements +Copyright 2001-2016 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-collections +Apache Commons Configuration(tm) 1.6 +Attribution Statements +http://commons.apache.org/proper/commons-configuration/ + +Copyright Statements +Copyright 2001-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-configuration +Apache Commons CSV(tm) 1.4 +Attribution Statements +http://commons.apache.org/proper/commons-csv/ + +Modifications copyright (c) 2017 MarkLogic Corporation. +September 2017 MarkLogic modified the parser to include the byte count of the original +data read. + +Copyright Statements +Copyright 2005-2016 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-csv +Apache Commons IO(tm) 2.4 +Attribution Statements +http://commons.apache.org/proper/commons-io/ + +Copyright Statements +Copyright 2002-2016 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://git-wip-us.apache.org/repos/asf?p=commons- +io.git +Apache Commons Lang(tm) 2.6 +Attribution Statements +http://commons.apache.org/lang/ + +This product includes software from the Spring Framework, +under the Apache License 2.0 (see: StringUtils.containsWhitespace()) + +Copyright Statements +Copyright 2001-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-lang +Apache Commons Lang(tm) 3.5 +Attribution Statements +http://commons.apache.org/proper/commons-lang/ + +This product includes software from the Spring Framework, +under the Apache License 2.0 (see: StringUtils.containsWhitespace()) + +Copyright Statements +Copyright 2001-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-lang +Apache Commons Lang(tm) 3.6 +Attribution Statements +http://commons.apache.org/proper/commons-lang/ + +This product includes software from the Spring Framework, +under the Apache License 2.0 (see: StringUtils.containsWhitespace()) + +Copyright Statements +Copyright 2001-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-lang +Apache Commons Logging(tm) 1.1.1 +Attribution Statements +http://commons.apache.org/logging + +Copyright Statements +Copyright 2003-2016 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-logging +Apache Commons Logging(tm) 1.1.3 +Attribution Statements +http://commons.apache.org/proper/commons-logging/ + +Copyright Statements +Copyright 2003-2016 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/commons-logging +Apache Commons Modeler 2.0.1 +Attribution Statements +http://commons.apache.org/dormant/commons-modeler/ + +Copyright Statements +(c) 2002-2008 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: http://commons.apache.org/dormant/commons- +modeler/downloads.html +Apache Commons Parent 1.4 +Attribution Statements +https://commons.apache.org/commons-parent-pom.html + +Copyright Statements +Copyright (C) 2017, The Apache Software Foundation + +License Text (http://www.apache.org/licenses/LICENSE-2.0.txt) + +Source materials are available for download at: https://commons.apache.org/svninfo.html +Apache Derby 10.13.1.1 +Attribution Statements +https://db.apache.org/derby/releases/release-10.13.1.1.cgi + +Portions of Derby were originally developed by +International Business Machines Corporation and are +licensed to the Apache Software Foundation under the +"Software Grant and Corporate Contribution License Agreement", +informally known as the "Derby CLA". +The following copyright notice(s) were affixed to portions of the code +with which this file is now or was at one time distributed +and are placed here unaltered. + +(C) Copyright 1997,2004 International Business Machines Corporation. All rights +reserved. + +(C) Copyright IBM Corp. 2003. + + +========================================================================= + + +The portion of the functionTests under 'nist' was originally +developed by the National Institute of Standards and Technology (NIST), +an agency of the United States Department of Commerce, and adapted by +International Business Machines Corporation in accordance with the NIST +Software Acknowledgment and Redistribution document at +http://www.itl.nist.gov/div897/ctg/sql_form.htm + + + +========================================================================= + + +Derby uses the SerialBlob and SerialClob implementations from the Apache +Harmony project. The following notice covers the Harmony sources: + +Portions of Harmony were originally developed by +Intel Corporation and are licensed to the Apache Software +Foundation under the "Software Grant and Corporate Contribution +License Agreement", informally known as the "Intel Harmony CLA". + + +========================================================================= + + +The Derby build relies on source files supplied by the Apache Felix +project. The following notice covers the Felix files: + + Apache Felix Main + Copyright 2008 The Apache Software Foundation + + + I. Included Software + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + Licensed under the Apache License 2.0. + + This product includes software developed at + The OSGi Alliance (http://www.osgi.org/). + Copyright (c) OSGi Alliance (2000, 2007). + Licensed under the Apache License 2.0. + + This product includes software from http://kxml.sourceforge.net. + Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany. + Licensed under BSD License. + + II. Used Software + + This product uses software developed at + The OSGi Alliance (http://www.osgi.org/). + Copyright (c) OSGi Alliance (2000, 2007). + Licensed under the Apache License 2.0. + + + III. License Summary + - Apache License 2.0 + - BSD License + + +========================================================================= + + +The Derby build relies on jar files supplied by the Apache Lucene +project. The following notice covers the Lucene files: + +Apache Lucene +Copyright 2013 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + +Includes software from other Apache Software Foundation projects, +including, but not limited to: + - Apache Ant + - Apache Jakarta Regexp + - Apache Commons + - Apache Xerces + +ICU4J, (under analysis/icu) is licensed under an MIT styles license +and Copyright (c) 1995-2008 International Business Machines Corporation and others + +Some data files (under analysis/icu/src/data) are derived from Unicode data such +as the Unicode Character Database. See http://unicode.org/copyright.html for more +details. + +Brics Automaton (under core/src/java/org/apache/lucene/util/automaton) is +BSD-licensed, created by Anders Møller. See http://www.brics.dk/automaton/ + +The levenshtein automata tables (under core/src/java/org/apache/lucene/util/automaton) +were +automatically generated with the moman/finenight FSA library, created by +Jean-Philippe Barrette-LaPierre. This library is available under an MIT license, +see http://sites.google.com/site/rrettesite/moman and +http://bitbucket.org/jpbarrette/moman/overview/ + +The class org.apache.lucene.util.WeakIdentityMap was derived from +the Apache CXF project and is Apache License 2.0. + +The Google Code Prettify is Apache License 2.0. +See http://code.google.com/p/google-code-prettify/ + +JUnit (junit-4.10) is licensed under the Common Public License v. 1.0 +See http://junit.sourceforge.net/cpl-v10.html + +This product includes code (JaspellTernarySearchTrie) from Java Spelling Checkin +g Package (jaspell): http://jaspell.sourceforge.net/ +License: The BSD License (http://www.opensource.org/licenses/bsd-license.php) + +The snowball stemmers in + analysis/common/src/java/net/sf/snowball +were developed by Martin Porter and Richard Boulton. +The snowball stopword lists in + analysis/common/src/resources/org/apache/lucene/analysis/snowball +were developed by Martin Porter and Richard Boulton. +The full snowball package is available from + http://snowball.tartarus.org/ + +The KStem stemmer in + analysis/common/src/org/apache/lucene/analysis/en +was developed by Bob Krovetz and Sergio Guzman-Lara (CIIR-UMass Amherst) +under the BSD-license. + +The Arabic,Persian,Romanian,Bulgarian, and Hindi analyzers (common) come with a +default +stopword list that is BSD-licensed created by Jacques Savoy. These files reside in: +analysis/common/src/resources/org/apache/lucene/analysis/ar/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/fa/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/ro/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/bg/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/hi/stopwords.txt +See http://members.unine.ch/jacques.savoy/clef/index.html. + +The German,Spanish,Finnish,French,Hungarian,Italian,Portuguese,Russian and Swedish +light stemmers +(common) are based on BSD-licensed reference implementations created by Jacques Savoy +and +Ljiljana Dolamic. These files reside in: +analysis/common/src/java/org/apache/lucene/analysis/de/GermanLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/de/GermanMinimalStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/es/SpanishLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/fi/FinnishLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchMinimalStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/hu/HungarianLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/it/ItalianLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/ru/RussianLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/sv/SwedishLightStemmer.java + +The Stempel analyzer (stempel) includes BSD-licensed software developed +by the Egothor project http://egothor.sf.net/, created by Leo Galambos, Martin Kvapil, +and Edmond Nolan. + +The Polish analyzer (stempel) comes with a default +stopword list that is BSD-licensed created by the Carrot2 project. The file resides +in stempel/src/resources/org/apache/lucene/analysis/pl/stopwords.txt. +See http://project.carrot2.org/license.html. + +The SmartChineseAnalyzer source code (smartcn) was +provided by Xiaoping Gao and copyright 2009 by www.imdict.net. + +WordBreakTestUnicode_*.java (under modules/analysis/common/src/test/) +is derived from Unicode data such as the Unicode Character Database. +See http://unicode.org/copyright.html for more details. + +The Morfologik analyzer (morfologik) includes BSD-licensed software +developed by Dawid Weiss and Marcin Milkowski (http://morfologik.blogspot.com/). + +Morfologik uses data from Polish ispell/myspell dictionary +(http://www.sjp.pl/slownik/en/) licenced on the terms of (inter alia) +LGPL and Creative Commons ShareAlike. + +Morfologic includes data from BSD-licensed dictionary of Polish (SGJP) +(http://sgjp.pl/morfeusz/) + +Servlet-api.jar and javax.servlet-*.jar are under the CDDL license, the original +source code for this can be found at http://www.eclipse.org/jetty/downloads.php + +=========================================================================== +Kuromoji Japanese Morphological Analyzer - Apache Lucene Integration +=========================================================================== + +This software includes a binary and/or source version of data from + + mecab-ipadic-2.7.0-20070801 + +which can be obtained from + + http://atilika.com/releases/mecab-ipadic/mecab-ipadic-2.7.0-20070801.tar.gz + +or + + http://jaist.dl.sourceforge.net/project/mecab/mecab-ipadic/2.7.0-20070801/mecab- +ipadic-2.7.0-20070801.tar.gz + +=========================================================================== +mecab-ipadic-2.7.0-20070801 Notice +=========================================================================== + +Nara Institute of Science and Technology (NAIST), +the copyright holders, disclaims all warranties with regard to this +software, including all implied warranties of merchantability and +fitness, in no event shall NAIST be liable for +any special, indirect or consequential damages or any damages +whatsoever resulting from loss of use, data or profits, whether in an +action of contract, negligence or other tortuous action, arising out +of or in connection with the use or performance of this software. + +A large portion of the dictionary entries +originate from ICOT Free Software. The following conditions for ICOT +Free Software applies to the current dictionary as well. + +Each User may also freely distribute the Program, whether in its +original form or modified, to any third party or parties, PROVIDED +that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear +on, or be attached to, the Program, which is distributed substantially +in the same form as set out herein and that such intended +distribution, if actually made, will neither violate or otherwise +contravene any of the laws and regulations of the countries having +jurisdiction over the User or the intended distribution itself. + +NO WARRANTY + +The program was produced on an experimental basis in the course of the +research and development conducted during the project and is provided +to users as so produced on an experimental basis. Accordingly, the +program is provided without any warranty whatsoever, whether express, +implied, statutory or otherwise. The term "warranty" used herein +includes, but is not limited to, any warranty of the quality, +performance, merchantability and fitness for a particular purpose of +the program and the nonexistence of any infringement or violation of +any right of any third party. + +Each user of the program will agree and understand, and be deemed to +have agreed and understood, that there is no warranty whatsoever for +the program and, accordingly, the entire risk arising from or +otherwise connected with the program is assumed by the user. + +Therefore, neither ICOT, the copyright holder, or any other +organization that participated in or was otherwise related to the +development of the program and their respective officials, directors, +officers and other employees shall be held liable for any and all +damages, including, without limitation, general, special, incidental +and consequential damages, arising out of or otherwise in connection +with the use or inability to use the program or any product, material +or result produced or otherwise obtained by using the program, +regardless of whether they have been advised of, or otherwise had +knowledge of, the possibility of such damages at any time during the +project or thereafter. Each user will be deemed to have agreed to the +foregoing by his or her commencement of use of the program. The term +"use" as used herein includes, but is not limited to, the use, +modification, copying and distribution of the program and the +production of secondary products from the program. + +In the case where the program, whether in its original form or +modified, was distributed or delivered to or received by a user from +any person, organization or entity other than ICOT, unless it makes or +grants independently of ICOT any specific warranty to the user in +writing, such person, organization or entity, will also be exempted +from and not be held liable to the user for any such damages as noted +above as far as the program is concerned. + +========================================================================= + +The Derby build relies on a jar file supplied by the JSON Simple +project, hosted at https://code.google.com/p/json-simple/. +The JSON simple jar file is licensed under the Apache 2.0 License. +No other notice covers that jar file. + +Copyright Statements +Copyright 2004-2015 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: http://mvnrepository.com/artifact/org.apache.derby/derby +Apache Hadoop 2.6.0 +Attribution Statements +http://hadoop.apache.org/ + +APACHE HADOOP SUBCOMPONENTS: + +The Apache Hadoop project contains subcomponents with separate copyright +notices and license terms. Your use of the source code for the these +subcomponents is subject to the terms and conditions of the following +licenses. + +For the org.apache.hadoop.util.bloom.* classes: + +/** + * + * Copyright (c) 2005, European Commission project OneLab under contract + * 034819 (http://www.one-lab.org) + * All rights reserved. + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * - Neither the name of the University Catholique de Louvain - UCL + * nor the names of its contributors may be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +For portions of the native implementation of slicing-by-8 CRC calculation +in src/main/native/src/org/apache/hadoop/util: + +Copyright (c) 2008,2009,2010 Massachusetts Institute of Technology. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +* Neither the name of the Massachusetts Institute of Technology nor + the names of its contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Other portions are under the same license from Intel: +http://sourceforge.net/projects/slicing-by-8/ +/*++ + * + * Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved + * + * This software program is licensed subject to the BSD License, + * available at http://www.opensource.org/licenses/bsd-license.html + * + * Abstract: The main routine + * + --*/ + +For +src/main/native/src/org/apache/hadoop/io/compress/lz4/{lz4.h,lz4.c,lz4hc.h,lz4hc.c}, + +/* + LZ4 - Fast LZ compression algorithm + Header File + Copyright (C) 2011-2014, Yann Collet. + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - LZ4 source repository : http://code.google.com/p/lz4/ + - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +*/ + + +For hadoop-common-project/hadoop-common/src/main/native/gtest +--------------------------------------------------------------------- +Copyright 2008, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The binary distribution of this product bundles these dependencies under the +following license: +re2j 1.0 +--------------------------------------------------------------------- +(GO license) +This is a work derived from Russ Cox's RE2 in Go, whose license +http://golang.org/LICENSE is as follows: + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + * Neither the name of Google Inc. nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +For hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/util/tree.h +--------------------------------------------------------------------- +Copyright 2002 Niels Provos +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The binary distribution of this product bundles binaries of leveldbjni +(https://github.com/fusesource/leveldbjni), which is available under the +following license: + +Copyright (c) 2011 FuseSource Corp. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of FuseSource Corp. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +For hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server- +nodemanager/src/main/native/container- +executor/impl/compat/{fstatat|openat|unlinkat}.h: + +Copyright (c) 2012 The FreeBSD Foundation +All rights reserved. + +This software was developed by Pawel Jakub Dawidek under sponsorship from +the FreeBSD Foundation. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +============= + +The binary distribution of this product bundles binaries of leveldb +(http://code.google.com/p/leveldb/), which is available under the following +license: + +Copyright (c) 2011 The LevelDB Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The binary distribution of this product bundles binaries of snappy +(http://code.google.com/p/snappy/), which is available under the following +license: + +Copyright 2011, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +For: +hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/dataTables.bootstrap.js +hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/dataTables.bootstrap.css +hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/jquery.dataTables.min.js +hadoop-yarn-project/hadoop-yarn/hadoop-yarn- +common/src/main/resources/webapps/static/dt-1.9.4/ +-------------------------------------------------------------------------------- +Copyright (C) 2008-2016, SpryMedia Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For: +hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/dust-full-2.0.0.min.js +hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/dust-helpers-1.1.1.min.js +-------------------------------------------------------------------------------- + +Copyright (c) 2010 Aleksander Williams + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +For: +hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/moment.min.js +-------------------------------------------------------------------------------- + +Copyright (c) 2011-2016 Tim Wood, Iskren Chernev, Moment.js contributors + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +The binary distribution of this product bundles these dependencies under the +following license: +hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/bootstrap-3.0.2 +hadoop-tools/hadoop-sls/src/main/html/js/thirdparty/bootstrap.min.js +hadoop-tools/hadoop-sls/src/main/html/css/bootstrap.min.css +hadoop-tools/hadoop-sls/src/main/html/css/bootstrap-responsive.min.css +bootstrap v3.3.6 +broccoli-asset-rev v2.4.2 +broccoli-funnel v1.0.1 +datatables v1.10.8 +em-helpers v0.5.13 +em-table v0.1.6 +ember v2.2.0 +ember-array-contains-helper v1.0.2 +ember-bootstrap v0.5.1 +ember-cli v1.13.13 +ember-cli-app-version v1.0.0 +ember-cli-babel v5.1.6 +ember-cli-content-security-policy v0.4.0 +ember-cli-dependency-checker v1.2.0 +ember-cli-htmlbars v1.0.2 +ember-cli-htmlbars-inline-precompile v0.3.1 +ember-cli-ic-ajax v0.2.1 +ember-cli-inject-live-reload v1.4.0 +ember-cli-jquery-ui v0.0.20 +ember-cli-qunit v1.2.1 +ember-cli-release v0.2.8 +ember-cli-shims v0.0.6 +ember-cli-sri v1.2.1 +ember-cli-test-loader v0.2.1 +ember-cli-uglify v1.2.0 +ember-d3 v0.1.0 +ember-data v2.1.0 +ember-disable-proxy-controllers v1.0.1 +ember-export-application-global v1.0.5 +ember-load-initializers v0.1.7 +ember-qunit v0.4.16 +ember-qunit-notifications v0.1.0 +ember-resolver v2.0.3 +ember-spin-spinner v0.2.3 +ember-truth-helpers v1.2.0 +jquery v2.1.4 +jquery-ui v1.11.4 +loader.js v3.3.0 +momentjs v2.10.6 +qunit v1.19.0 +select2 v4.0.0 +snippet-ss v1.11.0 +spin.js v2.3.2 +Azure Data Lake Store - Java client SDK 2.0.11 +JCodings 1.0.8 +Joni 2.1.2 +Mockito 1.8.5 +JUL to SLF4J bridge 1.7.25 +SLF4J API Module 1.7.25 +SLF4J LOG4J-12 Binding 1.7.25 +-------------------------------------------------------------------------------- + +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +For: +hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/jquery-1.10.2.min.js +hadoop-tools/hadoop-sls/src/main/html/js/thirdparty/jquery.js +hadoop-yarn-project/hadoop-yarn/hadoop-yarn- +common/src/main/resources/webapps/static/jquery +Apache HBase - Server which contains JQuery minified javascript library version 1.8.3 +-------------------------------------------------------------------------------- + +Copyright 2005, 2012, 2013 jQuery Foundation and other contributors, +https://jquery.org/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/jquery + +The following license applies to all parts of this software except as +documented below: + +==== + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==== + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. + +For: +hadoop-yarn-project/hadoop-yarn/hadoop-yarn- +common/src/main/resources/webapps/static/jt/jquery.jstree.js +-------------------------------------------------------------------------------- + +Copyright (c) 2014 Ivan Bozhanov + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For: +hadoop-tools/hadoop-sls/src/main/html/js/thirdparty/d3.v3.js +-------------------------------------------------------------------------------- + +D3 is available under a 3-clause BSD license. For details, see: +hadoop-tools/hadoop-sls/src/main/html/js/thirdparty/d3-LICENSE + +The binary distribution of this product bundles these dependencies under the +following license: +HSQLDB Database 2.3.4 +-------------------------------------------------------------------------------- +(HSQL License) +"COPYRIGHTS AND LICENSES (based on BSD License) + +For work developed by the HSQL Development Group: + +Copyright (c) 2001-2016, The HSQL Development Group +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +Neither the name of the HSQL Development Group nor the names of its +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG, +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +For work originally developed by the Hypersonic SQL Group: + +Copyright (c) 1995-2000 by the Hypersonic SQL Group. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +Neither the name of the Hypersonic SQL Group nor the names of its +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE HYPERSONIC SQL GROUP, +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +This software consists of voluntary contributions made by many individuals on behalf +of the +Hypersonic SQL Group." + +The binary distribution of this product bundles these dependencies under the +following license: +Java Servlet API 3.1.0 +servlet-api 2.5 +jsp-api 2.1 +jsr311-api 1.1.1 +Glassfish Jasper 6.1.14 +Servlet Specification 2.5 API 6.1.14 +-------------------------------------------------------------------------------- + +The binary distribution of this product bundles these dependencies under the +following license: +jersey-client 1.19 +jersey-core 1.19 +jersey-grizzly2 1.19 +jersey-grizzly2-servlet 1.19 +jersey-json 1.19 +jersey-server 1.19 +jersey-servlet 1.19 +jersey-guice 1.19 +Jersey Test Framework - Grizzly 2 Module 1.19 +JAXB RI 2.2.3 +Java Architecture for XML Binding 2.2.11 +grizzly-framework 2.2.21 +grizzly-http 2.2.21 +grizzly-http-server 2.2.21 +grizzly-http-servlet 2.2.21 +grizzly-rcm 2.2.21 +-------------------------------------------------------------------------------- + +The binary distribution of this product bundles these dependencies under the +following license: +Protocol Buffer Java API 2.5.0 +-------------------------------------------------------------------------------- +This license applies to all parts of Protocol Buffers except the following: + + - Atomicops support for generic gcc, located in + src/google/protobuf/stubs/atomicops_internals_generic_gcc.h. + This file is copyrighted by Red Hat Inc. + + - Atomicops support for AIX/POWER, located in + src/google/protobuf/stubs/atomicops_internals_power.h. + This file is copyrighted by Bloomberg Finance LP. + +Copyright 2014, Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +For: +XML Commons External Components XML APIs 1.3.04 +-------------------------------------------------------------------------------- +By obtaining, using and/or copying this work, you (the licensee) agree that you +have read, understood, and will comply with the following terms and conditions. + +Permission to copy, modify, and distribute this software and its documentation, +with or without modification, for any purpose and without fee or royalty is +hereby granted, provided that you include the following on ALL copies of the +software and documentation or portions thereof, including modifications: +- The full text of this NOTICE in a location viewable to users of the +redistributed or derivative work. +- Any pre-existing intellectual property disclaimers, notices, or terms and +conditions. If none exist, the W3C Software Short Notice should be included +(hypertext is preferred, text is permitted) within the body of any redistributed +or derivative code. +- Notice of any changes or modifications to the files, including the date changes +were made. (We recommend you provide URIs to the location from which the code is +derived.) + +The binary distribution of this product bundles these dependencies under the +following license: +JUnit 4.11 +Eclipse JDT Core 3.1.1 +-------------------------------------------------------------------------------- + +The binary distribution of this product bundles these dependencies under the +following license: +JSch 0.1.51 +ParaNamer Core 2.3 +JLine 0.9.94 +leveldbjni-all 1.8 +Hamcrest Core 1.3 +ASM Core 5.0.4 +ASM Commons 5.0.2 +ASM Tree 5.0.2 +-------------------------------------------------------------------------------- +(3-clause BSD) +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The binary distribution of this product bundles these dependencies under the +following license: +FindBugs-jsr305 3.0.0 +-------------------------------------------------------------------------------- +(2-clause BSD) +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. + +The binary distribution of this product bundles these dependencies under the +following license: +"Java Concurrency in Practice" book annotations 1.0 +-------------------------------------------------------------------------------- +(CCAL v2.5) +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS +PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR +OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS +LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE +BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED +HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. + +1. Definitions + +"Collective Work" means a work, such as a periodical issue, anthology or +encyclopedia, in which the Work in its entirety in unmodified form, along with a +number of other contributions, constituting separate and independent works in +themselves, are assembled into a collective whole. A work that constitutes a +Collective Work will not be considered a Derivative Work (as defined below) for +the purposes of this License. +"Derivative Work" means a work based upon the Work or upon the Work and other +pre-existing works, such as a translation, musical arrangement, dramatization, +fictionalization, motion picture version, sound recording, art reproduction, +abridgment, condensation, or any other form in which the Work may be recast, +transformed, or adapted, except that a work that constitutes a Collective Work +will not be considered a Derivative Work for the purpose of this License. For +the avoidance of doubt, where the Work is a musical composition or sound +recording, the synchronization of the Work in timed-relation with a moving image +("synching") will be considered a Derivative Work for the purpose of this +License. +"Licensor" means the individual or entity that offers the Work under the terms +of this License. +"Original Author" means the individual or entity who created the Work. +"Work" means the copyrightable work of authorship offered under the terms of +this License. +"You" means an individual or entity exercising rights under this License who has +not previously violated the terms of this License with respect to the Work, or +who has received express permission from the Licensor to exercise rights under +this License despite a previous violation. +2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or +restrict any rights arising from fair use, first sale or other limitations on +the exclusive rights of the copyright owner under copyright law or other +applicable laws. + +3. License Grant. Subject to the terms and conditions of this License, Licensor +hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the +duration of the applicable copyright) license to exercise the rights in the Work +as stated below: + +to reproduce the Work, to incorporate the Work into one or more Collective +Works, and to reproduce the Work as incorporated in the Collective Works; +to create and reproduce Derivative Works; +to distribute copies or phonorecords of, display publicly, perform publicly, and +perform publicly by means of a digital audio transmission the Work including as +incorporated in Collective Works; +to distribute copies or phonorecords of, display publicly, perform publicly, and +perform publicly by means of a digital audio transmission Derivative Works. +For the avoidance of doubt, where the work is a musical composition: + +Performance Royalties Under Blanket Licenses. Licensor waives the exclusive +right to collect, whether individually or via a performance rights society (e.g. +ASCAP, BMI, SESAC), royalties for the public performance or public digital +performance (e.g. webcast) of the Work. +Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right +to collect, whether individually or via a music rights agency or designated +agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the +Work ("cover version") and distribute, subject to the compulsory license created +by 17 USC Section 115 of the US Copyright Act (or the equivalent in other +jurisdictions). +Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the +Work is a sound recording, Licensor waives the exclusive right to collect, +whether individually or via a performance-rights society (e.g. SoundExchange), +royalties for the public digital performance (e.g. webcast) of the Work, subject +to the compulsory license created by 17 USC Section 114 of the US Copyright Act +(or the equivalent in other jurisdictions). +The above rights may be exercised in all media and formats whether now known or +hereafter devised. The above rights include the right to make such modifications +as are technically necessary to exercise the rights in other media and formats. +All rights not expressly granted by Licensor are hereby reserved. + +4. Restrictions.The license granted in Section 3 above is expressly made subject +to and limited by the following restrictions: + +You may distribute, publicly display, publicly perform, or publicly digitally +perform the Work only under the terms of this License, and You must include a +copy of, or the Uniform Resource Identifier for, this License with every copy or +phonorecord of the Work You distribute, publicly display, publicly perform, or +publicly digitally perform. You may not offer or impose any terms on the Work +that alter or restrict the terms of this License or the recipients' exercise of +the rights granted hereunder. You may not sublicense the Work. You must keep +intact all notices that refer to this License and to the disclaimer of +warranties. You may not distribute, publicly display, publicly perform, or +publicly digitally perform the Work with any technological measures that control +access or use of the Work in a manner inconsistent with the terms of this +License Agreement. The above applies to the Work as incorporated in a Collective +Work, but this does not require the Collective Work apart from the Work itself +to be made subject to the terms of this License. If You create a Collective +Work, upon notice from any Licensor You must, to the extent practicable, remove +from the Collective Work any credit as required by clause 4(b), as requested. If +You create a Derivative Work, upon notice from any Licensor You must, to the +extent practicable, remove from the Derivative Work any credit as required by +clause 4(b), as requested. +If you distribute, publicly display, publicly perform, or publicly digitally +perform the Work or any Derivative Works or Collective Works, You must keep +intact all copyright notices for the Work and provide, reasonable to the medium +or means You are utilizing: (i) the name of the Original Author (or pseudonym, +if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor +designate another party or parties (e.g. a sponsor institute, publishing entity, +journal) for attribution in Licensor's copyright notice, terms of service or by +other reasonable means, the name of such party or parties; the title of the Work +if supplied; to the extent reasonably practicable, the Uniform Resource +Identifier, if any, that Licensor specifies to be associated with the Work, +unless such URI does not refer to the copyright notice or licensing information +for the Work; and in the case of a Derivative Work, a credit identifying the use +of the Work in the Derivative Work (e.g., "French translation of the Work by +Original Author," or "Screenplay based on original Work by Original Author"). +Such credit may be implemented in any reasonable manner; provided, however, that +in the case of a Derivative Work or Collective Work, at a minimum such credit +will appear where any other comparable authorship credit appears and in a manner +at least as prominent as such other comparable authorship credit. +5. Representations, Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS +THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING +THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT +LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR +PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, +OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME +JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH +EXCLUSION MAY NOT APPLY TO YOU. + +6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN +NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, +INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS +LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +7. Termination + +This License and the rights granted hereunder will terminate automatically upon +any breach by You of the terms of this License. Individuals or entities who have +received Derivative Works or Collective Works from You under this License, +however, will not have their licenses terminated provided such individuals or +entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, +and 8 will survive any termination of this License. +Subject to the above terms and conditions, the license granted here is perpetual +(for the duration of the applicable copyright in the Work). Notwithstanding the +above, Licensor reserves the right to release the Work under different license +terms or to stop distributing the Work at any time; provided, however that any +such election will not serve to withdraw this License (or any other license that +has been, or is required to be, granted under the terms of this License), and +this License will continue in full force and effect unless terminated as stated +above. +8. Miscellaneous + +Each time You distribute or publicly digitally perform the Work or a Collective +Work, the Licensor offers to the recipient a license to the Work on the same +terms and conditions as the license granted to You under this License. +Each time You distribute or publicly digitally perform a Derivative Work, +Licensor offers to the recipient a license to the original Work on the same +terms and conditions as the license granted to You under this License. +If any provision of this License is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this License, and without further action by the parties to this +agreement, such provision shall be reformed to the minimum extent necessary to +make such provision valid and enforceable. +No term or provision of this License shall be deemed waived and no breach +consented to unless such waiver or consent shall be in writing and signed by the +party to be charged with such waiver or consent. +This License constitutes the entire agreement between the parties with respect +to the Work licensed here. There are no understandings, agreements or +representations with respect to the Work not specified here. Licensor shall not +be bound by any additional provisions that may appear in any communication from +You. This License may not be modified without the mutual written agreement of +the Licensor and You. + +The binary distribution of this product bundles these dependencies under the +following license: +jamon-runtime 2.4.1 +-------------------------------------------------------------------------------- + +The binary distribution of this product bundles these dependencies under the +following license: +JDOM 1.1 +-------------------------------------------------------------------------------- +/*-- + + Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the disclaimer that follows + these conditions in the documentation and/or other materials + provided with the distribution. + + 3. The name "JDOM" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact . + + 4. Products derived from this software may not be called "JDOM", nor + may "JDOM" appear in their name, without prior written permission + from the JDOM Project Management . + + In addition, we request (but do not require) that you include in the + end-user documentation provided with the redistribution and/or in the + software itself an acknowledgement equivalent to the following: + "This product includes software developed by the + JDOM Project (http://www.jdom.org/)." + Alternatively, the acknowledgment may be graphical using the logos + available at http://www.jdom.org/images/logos. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + + This software consists of voluntary contributions made by many + individuals on behalf of the JDOM Project and was originally + created by Jason Hunter and + Brett McLaughlin . For more information + on the JDOM Project, please see . + + */ + +The binary distribution of this product bundles these dependencies under the +following license: +Hbase Server 1.2.4 +-------------------------------------------------------------------------------- +This project bundles a derivative image for our Orca Logo. This image is +available under the Creative Commons By Attribution 3.0 License. + +-------------------------------------------------------------------------------- + +For: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs +/server/datanode/checker/AbstractFuture.java and +hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs +/server/datanode/checker/TimeoutFuture.java + +Copyright (C) 2007 The Guava Authors + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. + +Copyright Statements +Copyright (C) 2017, The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: http://maven.ibiblio.org/maven2/org/apache/hadoop/ +Apache Hadoop ZooKeeper 3.4.5 +Attribution Statements +http://zookeeper.apache.org/releases.html +http://zookeeper.apache.org/doc/r3.4.2/ + +Copyright Statements +Copyright (c) 2008 The Apache Software Foundation. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download +at: http://maven.ibiblio.org/maven2/org/apache/zookeeper/zookeeper +Apache HTrace 3.0.4 +Attribution Statements +http://incubator.apache.org/projects/htrace.html + +The HTrace Owl logo is from http://www.clker.com/clipart-13653.html. It is +public domain. + +D3 v3.4.11, a javascript library for manipulating data, used by htrace-hbase +is available under the BSD License: + + Copyright (c) 2010-2014, Michael Bostock + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name Michael Bostock may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The following libraries are all available under these terms of the MIT license + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +Bootstrap v3.3.1, an html, css, and javascript framework. +Copyright (c) 2011-2014 Twitter, Inc. + +underscore 1.7.0, a javascript library of functional programming helpers. +Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative +Reporters & Editors + +jquery 2.1.4, a javascript library. +Copyright 2014 jQuery Foundation and other contributors, https://jquery.org/ + +backbone 1.1.2, a javascript library. +Copyright (c) 2010-2014 Jeremy Ashkenas, DocumentCloud. + +moment.js 2.10.3, a front end time conversion project. +Copyright (c) 2011-2015 Tim Wood, Iskren Chernev, Moment.js contributors. + +CMP v10 is an implementation of the MessagePack serialization format in C. +Copyright (c) 2014 Charles Gunyon + +Copyright Statements +Copyright (C) The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://git-wip-us.apache.org/repos/asf?p=incubator- +htrace.git +Apache HTrace 3.2.0 +Attribution Statements +http://incubator.apache.org/projects/htrace.html + +The HTrace Owl logo is from http://www.clker.com/clipart-13653.html. It is +public domain. + +D3 v3.4.11, a javascript library for manipulating data, used by htrace-hbase +is available under the BSD License: + + Copyright (c) 2010-2014, Michael Bostock + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name Michael Bostock may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The following libraries are all available under these terms of the MIT license + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +Bootstrap v3.3.1, an html, css, and javascript framework. +Copyright (c) 2011-2014 Twitter, Inc. + +underscore 1.7.0, a javascript library of functional programming helpers. +Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative +Reporters & Editors + +jquery 2.1.4, a javascript library. +Copyright 2014 jQuery Foundation and other contributors, https://jquery.org/ + +backbone 1.1.2, a javascript library. +Copyright (c) 2010-2014 Jeremy Ashkenas, DocumentCloud. + +moment.js 2.10.3, a front end time conversion project. +Copyright (c) 2011-2015 Tim Wood, Iskren Chernev, Moment.js contributors. + +CMP v10 is an implementation of the MessagePack serialization format in C. +Copyright (c) 2014 Charles Gunyon + +Copyright Statements +Copyright (C) The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://git-wip-us.apache.org/repos/asf?p=incubator- +htrace.git +Apache HttpComponents HttpClient 3.1 +Attribution Statements +http://hc.apache.org/httpclient-3.x/ + +Copyright Statements +Copyright 1999-2012 The Apache Software Foundation + +License Text (https://spdx.org/licenses/Apache-2.0.html) + +Source materials are available for download at: https://github.com/apache/httpcomponents-client +Apache HttpComponents HttpClient 4.5.3 +Attribution Statements +https://hc.apache.org/httpcomponents-client-ga/index.html + +Copyright Statements +Copyright 1999-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/httpcomponents-client +Apache Jena ARQ 2.10.0 +Attribution Statements +http://jena.apache.org/ + +Portions of this software were originally based on the following: + - Copyright 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, +LP + - Copyright 2010, 2011 Epimorphics Ltd. + - Copyright 2010 Talis Systems Ltd. +These have been licensed to the Apache Software Foundation under a software grant. + +Copyright Statements +Copyright 2011-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/jena/tree/master/jena-arq +Apache Jena ARQ 3.4.0 +Attribution Statements +http://jena.apache.org/ + +Portions of this software were originally based on the following: + - Copyright 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, +LP + - Copyright 2010, 2011 Epimorphics Ltd. + - Copyright 2010 Talis Systems Ltd. +These have been licensed to the Apache Software Foundation under a software grant. + +Copyright Statements +Copyright 2011-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/jena/tree/master/jena-arq +Apache Jena Core 2.10.0 +Attribution Statements +http://jena.apache.org/ + +Portions of this software were originally based on the following: + - Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard +Development Company, LP + - Copyright 2010, 2011 Epimorphics Ltd. + - Copyright 2010, 2011 Talis Systems Ltd. +These have been licensed to the Apache Software Foundation under a software grant. + +This product includes software developed by +PluggedIn Software under a BSD license. + +The following files contain code contributed by Plugged In Software: + +src/main/java/org/apache/jena/rdfxml/xmlinput/ExtendedHandler.java +src/main/java/org/apache/jena/rdfxml/xmlinput/XMLHandler.java +src/main/java/org/apache/jena/rdfxml/xmlinput/ARP.java + + (c) Copyright 2003, Plugged In Software + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Copyright Statements +Copyright 2011-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/jena/tree/master/jena-core +Apache Jena IRI 0.9.5 +Attribution Statements +http://jena.apache.org/ + +Portions of this software were originally based on the following: + - Copyright 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, +LP + - Copyright 2010, 2011 Epimorphics Ltd. + - Copyright 2010, 2011 Talis Systems Ltd. +These have been licensed to the Apache Software Foundation under a software grant. + +Copyright Statements +Copyright 2011-2017 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/jena/tree/master/jena-iri +Apache Log4j(tm) 1.2.17 +Attribution Statements +http://logging.apache.org/log4j/1.2/ + +This product includes source code based on Sun +Microsystems' book titled "Java Nativer Interface: +Programmer's Guide and Specification" and freely available +to the public at http://java.sun.com/docs/books/jni. + +Copyright Statements +Copyright 2006 The Apache Software Foundation. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/apache/log4j +Apache XML Commons APIs 1.3.03 +Attribution Statements +http://xml.apache.org/commons/components/external/ + + Portions of this software were originally based on the following: + - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. + - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. + - software copyright (c) 2000 World Wide Web Consortium, http://www.w3.org + +Copyright Statements +Copyright 2001-2003,2006 The Apache Software Foundation. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Apache XML Commons APIs 1.4.01 +Attribution Statements +http://xml.apache.org/commons/components/external/ + + Portions of this software were originally based on the following: + - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. + - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. + - software copyright (c) 2000 World Wide Web Consortium, http://www.w3.org + +Copyright Statements +Copyright 2001-2003,2006 The Apache Software Foundation. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Azure Resource Manager +Attribution Statements +https://azure.microsoft.com/en-us/features/resource-manager/ + +Copyright Statements +(c) 2017 Microsoft + +License Text (https://azure.microsoft.com/en-us/support/legal/) +https://azure.microsoft.com/en-us/support/legal/ +https://azure.microsoft.com/en-us/support/legal/subscription-agreement/ +https://azure.microsoft.com/en-us/support/legal/marketplace-terms/ +https://azure.microsoft.com/en-us/support/legal/preview-supplemental-terms/ + +Bliki engine (Java Wikipedia API) 3.1.0 +Attribution Statements +https://bitbucket.org/axelclk/info.bliki.wiki + +This package uses modified sources and libraries from other open source projects: +a) HTMLCleaner which is published under BSD license. +For more information see: +http://htmlcleaner.sourceforge.net/ + +b) The JAMWiki MagicWord implementation which is published under the GNU Lesser +General Public License. +For more information see: +http://jamwiki.org + +c) The JSPWiki LatexConverter which is published under the GNU Lesser General Public +License. +For more information see: +http://jspwiki.org/wiki/LatexConverter + +d) Textile-J which is published under Apache license. +For more information see: +https://textile-j.dev.java.net/ + +e) The Flying Saucer project which is published under the GNU Lesser General Public +License. +For more information see: +https://xhtmlrenderer.dev.java.net/ + +f) iText (PDF generation) which is published under the Mozilla Public License +For more information see: +http://www.lowagie.com/iText/ and http://itextpdf.sourceforge.net/ + +g) The Apache Commons libraries are published under the Apache License +http://commons.apache.org/ + +h) The Apache Derby libraries are published under the Apache License +http://db.apache.org/derby/ + +g) the stringtotime library is published under the following License: + +Copyright (c) 2012 Clutch, Inc. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +For more information see: +https://github.com/collegeman/stringtotime + +j) the Scribunto MediaWiki extension which is published under GPL-2.0+ and MIT +https://www.mediawiki.org/wiki/Extension:Scribunto + +k) The LuaJ library is published under the MIT license +http://www.luaj.org/luaj/3.0/README.html + +Copyright (c) 2009-2014 Luaj.org. + +Copyright Statements +Axel Kramer + +License Text (http://www.opensource.org/licenses/eclipse-1.0.php) +Eclipse Public License, Version 1.0 (EPL-1.0) +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE +("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES +RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and +b) in the case of each subsequent Contributor: +i) changes to the Program, and +ii) additions to the Program; +where such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor if it +was added to the Program by such Contributor itself or anyone acting on such +Contributor's behalf. Contributions do not include additions to the Program which: (i) +are separate modules of software distributed in conjunction with the Program under +their own license agreement, and (ii) are not derivative works of the Program. +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when combined +with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, including all +Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a +non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare +derivative works of, publicly display, publicly perform, distribute and sublicense the +Contribution of such Contributor, if any, and such derivative works, in source code +and object code form. +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a +non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, +use, sell, offer to sell, import and otherwise transfer the Contribution of such +Contributor, if any, in source code and object code form. This patent license shall +apply to the combination of the Contribution and the Program if, at the time the +Contribution is added by the Contributor, such addition of the Contribution causes +such combination to be covered by the Licensed Patents. The patent license shall not +apply to any other combinations which include the Contribution. No hardware per se is +licensed hereunder. +c) Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor that the +Program does not infringe the patent or other intellectual property rights of any +other entity. Each Contributor disclaims any liability to Recipient for claims brought +by any other entity based on infringement of intellectual property rights or +otherwise. As a condition to exercising the rights and licenses granted hereunder, +each Recipient hereby assumes sole responsibility to secure any other intellectual +property rights needed, if any. For example, if a third party patent license is +required to allow Recipient to distribute the Program, it is Recipient's +responsibility to acquire that license before distributing the Program. +d) Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in this +Agreement. +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own +license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and +b) its license agreement: +i) effectively disclaims on behalf of all Contributors all warranties and conditions, +express and implied, including warranties or conditions of title and non-infringement, +and implied warranties or conditions of merchantability and fitness for a particular +purpose; +ii) effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such as +lost profits; +iii) states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and +iv) states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a medium +customarily used for software exchange. +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and +b) a copy of this Agreement must be included with each copy of the Program. +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if any, +in a manner that reasonably allows subsequent Recipients to identify the originator of +the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect +to end users, business partners and the like. While this license is intended to +facilitate the commercial use of the Program, the Contributor who includes the Program +in a commercial product offering should do so in a manner which does not create +potential liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial Contributor") +hereby agrees to defend and indemnify every other Contributor ("Indemnified +Contributor") against any losses, damages and costs (collectively "Losses") arising +from claims, lawsuits and other legal actions brought by a third party against the +Indemnified Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program in a +commercial product offering. The obligations in this section do not apply to any +claims or Losses relating to any actual or alleged intellectual property infringement. +In order to qualify, an Indemnified Contributor must: a) promptly notify the +Commercial Contributor in writing of such claim, and b) allow the Commercial +Contributor to control, and cooperate with the Commercial Contributor in, the defense +and any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, +Product X. That Contributor is then a Commercial Contributor. If that Commercial +Contributor then makes performance claims, or offers warranties related to Product X, +those performance claims and warranties are such Commercial Contributor's +responsibility alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those performance claims and +warranties, and if a court requires any other Contributor to pay any damages as a +result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED +INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON- +INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is +solely responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or equipment, and +unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, +it shall not affect the validity or enforceability of the remainder of the terms of +this Agreement, and without further action by the parties hereto, such provision shall +be reformed to the minimum extent necessary to make such provision valid and +enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim +or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations +of the Program with other software or hardware) infringes such Recipient's patent(s), +then such Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to comply with +any of the material terms or conditions of this Agreement and does not cure such +failure in a reasonable period of time after becoming aware of such noncompliance. If +all Recipient's rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by Recipient +relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to +avoid inconsistency the Agreement is copyrighted and may only be modified in the +following manner. The Agreement Steward reserves the right to publish new versions +(including revisions) of this Agreement from time to time. No one other than the +Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is +the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement under +which it was received. In addition, after a new version of the Agreement is published, +Contributor may elect to distribute the Program (including its Contributions) under +the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient +receives no rights or licenses to the intellectual property of any Contributor under +this Agreement, whether expressly, by implication, estoppel or otherwise. All rights +in the Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the intellectual +property laws of the United States of America. No party to this Agreement will bring a +legal action under this Agreement more than one year after the cause of action arose. +Each party waives its rights to a jury trial in any resulting litigation. + +Source materials are available for download at: https://bitbucket.org/axelclk/info.bliki.wiki/src +bluebird 3.5.0 +Attribution Statements +http://bluebirdjs.com/docs/getting-started.html + +Copyright Statements +Copyright (C) Petka Antonov + +License Text (http://spdx.org/licenses/MIT) +MIT License + +Copyright (c) Petka Antonov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/petkaantonov/bluebird +bluebird 3.5.1 +Attribution Statements +http://bluebirdjs.com/docs/getting-started.html + +Copyright Statements +Copyright (C) 2017, Petka Antonov + +License Text (http://spdx.org/licenses/MIT) +MIT License + +Copyright (c) 2017 Petka Antonov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/petkaantonov/bluebird +Bootstrap 4.0.0-alpha.5 +Attribution Statements +http://getbootstrap.com + +Copyright Statements +Copyright (c) 2011-2017 Twitter, Inc. +Copyright (c) 2011-2017 The Bootstrap Authors + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2011-2017 Twitter, Inc. +Copyright (c) 2011-2017 The Bootstrap Authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/twbs/bootstrap +C3p0 0.9.5.2 +Attribution Statements +http://www.mchange.com/projects/c3p0/ + +Copyright Statements +(c) 2015 Machinery For Change, Inc. + +License Text (http://spdx.org/licenses/EPL-1.0) + +Source materials are available for download at: http://mvnrepository.com/artifact/com.mchange/c3p0 +CentOS (for Microsoft Azure Linux Agent) 7.3 +Attribution Statements +https://azuremarketplace.microsoft.com/en- +us/marketplace/apps/RogueWave.CentOSbased73?tab=Overview + +Copyright Statements +Rogue Wave Software, Inc. + +License Text (https://www.roguewave.com/products-services/services/open-source-software/cloud- +services/azure/service-agreement) +CentOS Support Service Agreement for Windows Azure +This OpenLogic Support Agreement is a legal agreement between OpenLogic, Inc., a +Delaware Corporation ("OpenLogic") and you, either an individual or an entity ("you"). +If you are an individual, you represent to us that you are lawfully able to enter into +contracts (e.g., you are not a minor). If you are entering into this agreement on +behalf of an entity, you represent to us that you have legal authority to bind that +entity. + +This agreement governs the support services ("Services") provided to you by OpenLogic +for designated open source software stacks made available by OpenLogic on Windows +Azure ("OSS Stacks"). This agreement is effective as of the date you purchased support +for the OSS Stack(s) ("Effective Date"). + +1. Support Services + +OpenLogic will provide technical support for the specific OSS Stacks that Windows +Azure reports to OpenLogic you have purchased commencing on the Effective Date. +Technical support includes assistance with problem resolution, defects, and "how to" +questions as well as advice and recommendations on installation and configuration. +Support for OSS Stacks will cover only Windows Azure instances on which the stack is +deployed through the Windows Azure. It will not cover support of the Windows Azure +infrastructure or support for the OSS Stacks running on other infrastructure. + +OpenLogic will provide support 12 hours per day between 8:00 AM and 8:00 PM EST / EDT, +five days per week for Developer Support and 24 hours per day, seven days per week for +Production Support. Technical support incidents can be submitted via email or by +phone. Each single unique defect or question about a Purchased Stack will be counted +as an incident. Unless otherwise indicated at the time of purchase, you may submit an +unlimited number of technical support incidents. Details about the technical support +process, response times, types of issues, and severity of issues can be found here +www.roguewave.com/products-services/services/open-source-software/cloud- +services/azure/service-agreement. + +2. Limitations on Support + +OpenLogic will have no obligation to provide technical support or may cease providing +the Services in the case of or with respect to any incident that is in whole or in +part due to, caused by, or resulting from any of the following: + + (i) a breach by you of this Agreement; + + (ii) the operational characteristics of Windows Azure provided hardware, instances, +or infrastructure; + + (iii) any third party products, software, hardware, equipment, content, data or +information, and any modifications, improvements, updates, new versions or new +releases thereto or thereof, not provided by OpenLogic; + + (v) any OSS Stack other than the most current release thereof made available by +OpenLogic through Windows Azure; + + (vi) use of any OSS Stack after OpenLogic has notified you to cease use thereof under +this Agreement; or + + (vii) your negligence, abuse, misapplication, or misuse of the OSS Stacks or the +Services. + +OpenLogic will have no liability for any changes required by your hardware or software +configuration which may be necessary to use any OSS Stack due to a workaround, error +correction, or maintenance release. + +3. Fees, Term, and Termination + +You will be billed by Windows Azure under the terms of the Windows Azure Customer +Agreement. The term of this agreement will commence on the Effective Date and will +remain in effect until terminated by you or Windows Azure as per the Windows Azure +Customer Agreement. The Windows Azure Customer Agreement is located at +www.roguewave.com/products-services/services/open-source-software/cloud- +services/azure/service-agreement/. + +4. Intellectual Property Rights + + 4.1. Intellectual Property Rights. Intellectual property rights includes, without +limitation, all copyrights, trademarks, service marks, trade secrets, patents, moral +rights, and any and all other legal rights protecting intangible proprietary +information ("IPR"). All pre-existing intellectual property rights owned or licensed +by either party are and will remain the exclusive property of that party. + + 4.2. License. During the term of this Agreement, you may choose to provide OpenLogic +with access to Your IPR to facilitate OpenLogic in providing the Services, in which +case you grant to OpenLogic all rights and licenses in and to the Your Technology as +may be necessary for OpenLogic to complete its obligations under this Agreement. It +should be noted that OpenLogic does not have access to Your Technology deployed on +Windows Azure unless you choose to give OpenLogic access as part of providing the +Services. OpenLogic hereby grants to you a non-exclusive, non-transferable, worldwide +license to use, reproduce, and modify any OpenLogic IPR provided to you during the +course of performing the Services for your own internal business purposes. To the +extent any deliverable hereunder is a derivative work, modification, patch, or script +of or directly relating to an open source software project (each an "Open Source +Deliverable"), OpenLogic will license such Open Source Deliverable under the same open +source software license as the open source project to which it relates. + + 4.3. OSS Stacks License. The OSS Stacks are comprised of open source software, which +is subject to the terms of the open source software license(s) accompanying or +otherwise applicable to that open source software. Any other code created and +supplied directly by OpenLogic is governed by the MIT License. The terms of the open +source software licenses apply to the open source software independent of the terms of +the MIT License or this agreement. Nothing in this agreement limits your rights under +or grants rights to you that supersede the terms of any applicable open source +software license. + + 4.4. You acknowledge that your own distribution or deployment of instances containing +or linking to the OSS Stacks or any other open source software may trigger open source +license requirements for which you are responsible. + + 4.5. Open Source Community. In the process of providing the Services, OpenLogic +occasionally finds bugs and errors in open source software as well as issues in how +certain open source packages work together. OpenLogic will make best efforts to work +with open source communities to resolve bugs or defects and contribute those changes +back for incorporation in future releases. Due to the nature of open source +development, OpenLogic can not guarantee that the open source communities will accept +bug fixes. + +5. Customer's Comments and Feedback + +In the course of OpenLogic providing you with technical support, you may provide +comments, suggestions, and other feedback regarding the OSS Stacks, the support +services, or related topics to OpenLogic. You agree that OpenLogic will be free to use +any such feedback you provide for any purpose, including without limitation +implementing changes based on your feedback to the OSS Stacks, support,, or other +offerings without attribution or compensation to you. + +6. Warranties. + + 6.1. General. Each party represents and warrants to the other party that: the +performance of such party's obligations hereunder do not and will not violate any law, +rule or regulation applicable to such party. + + 6.2. OpenLogic. OpenLogic will perform all Services as stated under this Agreement. +If OpenLogic fails to comply with the previous sentence, OpenLogic will, at its sole +discretion and as Client's sole remedy and OpenLogic's sole obligation for any such +failure: (a) re-perform the Services in a manner that resolves the alleged failure; or +(b) refund any Fees paid by Client attributable to the Services that are the subject +of the failure. + +7. Disclaimer + +THE WARRANTIES SET FORTH IN SECTION 6 (Warranties) ARE THE SOLE AND EXCLUSIVE +WARRANTIES MADE BY OPENLOGIC UNDER THIS AGREEMENT AND OPENLOGIC SPECIFICALLY DISCLAIMS +ANY AND ALL OTHER WARRANTIES OF ANY KIND, WHETHER EXPRESS, IMPLIED OR STATUTORY, WITH +REGARD TO THE SERVICES, DELIVERABLES AND ANY OTHER SUBJECT MATTER OF THIS AGREEMENT, +INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF NON-INFRINGEMENT, TITLE, FITNESS FOR +A PARTICULAR PURPOSE, FUNCTIONALITY OR MERCHANTABILITY. + +8. Limitation of Liability + +OPENLOGIC WILL NOT BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL +DAMAGES ARISING OUT OF THIS AGREEMENT (HOWEVER ARISING, INCLUDING NEGLIGENCE), +INCLUDING, BY WAY OF EXAMPLE, LOST REVENUE, LOST PROFITS, BUSINESS INTERRUPTION, AND +INJURY TO REPUTATION, EVEN IF OPENLOGIC HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. THE TOTAL CUMULATIVE LIABILITY OF OPENLOGIC RELATING TO THIS AGREEMENT, +REGARDLESS OF THE FORM OF ACTION, WHETHER IN CONTRACT, TORT OR OTHERWISE, WILL NOT +EXCEED THE TOTAL FEES PAID TO AMAZON BY CLIENT FOR SUPPORT PROVIDED BY OPENLOGIC +DURING THE 3 MONTH PERIOD IMMEDIATELY PRECEDING THE EVENT(S) GIVING RISE TO SUCH +LIABILITY. + +9. Confidential Information. + + 9.1. Confidential Information. For purposes of this Agreement, "Confidential +Information" means any data or information regarding the business, finances, services +or technology of either party provided to or otherwise obtained by the other party, +including, without limitation, technical, marketing, financial, pricing, employee, and +planning information, and any other data or information received or otherwise obtained +under this Agreement that a reasonable person should have known, under the +circumstances, was confidential or proprietary. + + 9.2. Protection. Each party (the "Receiving Party") may from time to time receive or +otherwise obtain Confidential Information from the other party (the "Disclosing +Party"). The Receiving Party will not use any Confidential Information of the +Disclosing Party for any purpose not expressly permitted by this Agreement, and will +disclose the Confidential Information of the Disclosing Party only to the employees or +contractors of the Receiving Party who have a need to know such Confidential +Information for purposes of this Agreement and who are under a duty of confidentiality +no less restrictive than the Receiving Party's duty hereunder. The Receiving Party +will protect the Disclosing Party's Confidential Information in the same manner as the +Receiving Party protects its own confidential information of a similar nature and with +no less than reasonable care. + + 9.3. Exceptions. The Receiving Party's obligations with respect to any Confidential +Information of the Disclosing Party will terminate if such information: (a) was +already lawfully known to the Receiving Party as of the Effective Date; (b) is +disclosed to the Receiving Party after the Effective Date by a third party who had the +right to make such disclosure without any confidentiality restrictions; (c) is, or +through no fault of the Receiving Party becomes, generally available to the public; or +(d) is independently developed by the Receiving Party without access to, use of, or +reference to, the Disclosing Party's Confidential Information. In addition, the +Receiving Party will be allowed to disclose Confidential Information of the Disclosing +Party to the extent that such disclosure is: (i) necessary for the Receiving Party to +enforce its rights under this Agreement in connection with a legal proceeding; or (ii) +required by law or by the order of a court of similar judicial, regulatory or +administrative body, provided that the Receiving Party notifies the Disclosing Party +in advance of such required disclosure promptly and in writing and cooperates with the +Disclosing Party, at the Disclosing Party's reasonable request and expense, in any +lawful action to contest or limit the scope of such required disclosure. + +10. General + + 10.1. Export. You will comply with all applicable export and import laws and +regulations in your use of the OSS Stacks. You represent that you are not barred from +receiving services under U.S. laws or other applicable jurisdiction, including without +limitations, the Denied Persons List and the Entity List, and other lists issued by +the U.S. Department of Commerce, Bureau of Industry and Security. You represent that +you are not located in, under the control of, or a national or resident of any country +to which the United States has embargoed goods. + + 10.2. Assignment. This agreement, or any of your rights and obligations under +this agreement, cannot be assigned or otherwise transferred in whole or in part, and +any such attempted assignment or transfer by Customer in violation of the foregoing +will be null and void. + + 10.3. Choice of law. This agreement will be governed by the laws of the State +of Colorado in the United States of America, without regard to conflicts of law +principles. The federal and state courts located in Denver, Colorado (and any other +courts having jurisdiction over matters arising in Denver, Colorado) will have +exclusive jurisdiction over any disputes arising under this agreement and the parties +hereby irrevocably consent to the personal jurisdiction of such courts. The parties +agree that the United Nations Convention on Contracts for the International Sale of +Goods is specifically excluded from application to this agreement. + + 10.4. Relationship of parties. This agreement does not create a partnership, +franchise, joint venture, agency, fiduciary, or employment relationship between you +and OpenLogic. There are no third-party beneficiaries to this agreement. + + 10.5. Waiver. All waivers under this agreement must be in writing. Any waiver +or failure to enforce any provision of this agreement on one occasion will not be +deemed a waiver of any other provision or of such provision on any other occasion. + + 10.6. Severability. If any provision of this agreement is held to be +unenforceable, that provision will be modified so as to be enforceable, or if such +modification is not possible, that provision will be removed and the remaining +provisions will remain in full force. + + 10.7. Survival. Sections 4 (Intellectual Property Rights), 5 (Customer's +Comments and Feedback), 7 (Disclaimer), 8 (Limitation of Liability), 9 (Confidential +Information), and 10 (General) will survive termination or expiration of this +agreement. + +-- Last updated 5 June 2012. + +Source materials are available for download at: https://azuremarketplace.microsoft.com/en- +us/marketplace/apps/RogueWave.CentOSbased73?tab=Overview +concat-stream 1.6.0 +Copyright Statements +Copyright (c) 2013 Max Ogden + +License Text (http://spdx.org/licenses/MIT) +The MIT License + +Copyright (c) 2013 Max Ogden + +Permission is hereby granted, free of charge, +to any person obtaining a copy of this software and +associated documentation files (the "Software"), to +deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/maxogden/concat-stream +core-js 2.4.1 +Copyright Statements +Copyright (c) 2014-2016 Denis Pushkarev + +License Text (http://spdx.org/licenses/MIT) +Copyright (c) 2014-2016 Denis Pushkarev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/zloirock/core-js +deepcopy.js 0.6.3 +Copyright Statements +Copyright (c) 2013 sasa+1 + +License Text (http://spdx.org/licenses/MIT) +(The MIT LICENSE) + +Copyright (c) 2013 sasa+1 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/sasaplus1/deepcopy.js +dicer 0.2.5 +Copyright Statements +Copyright Brian White. All rights reserved. + +License Text (https://spdx.org/licenses/MIT.html) +Copyright Brian White. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/mscdex/dicer +DocStrap 1.0.0 +Attribution Statements +https://github.com/docstrap/docstrap + +Copyright Statements +Copyright (c) 2012-15 Terry Weiss & Contributors. All rights reserved. + +License Text (http://spdx.org/licenses/MIT) +Copyright (c) 2012-15 Terry Weiss & Contributors. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/docstrap/docstrap +DOM4J 1.6.1 +Attribution Statements +http://dom4j.org + +Copyright Statements +Copyright 2001-2010 (C) MetaStuff, Ltd. All Rights Reserved. + +License Text (https://github.com/dom4j/dom4j/blob/master/LICENSE) +Copyright 2001-2010 (C) MetaStuff, Ltd. All Rights Reserved. + +Redistribution and use of this software and associated documentation +("Software"), with or without modification, are permitted provided +that the following conditions are met: + +1. Redistributions of source code must retain copyright + statements and notices. Redistributions must also contain a + copy of this document. + +2. Redistributions in binary form must reproduce the + above copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +3. The name "DOM4J" must not be used to endorse or promote + products derived from this Software without prior written + permission of MetaStuff, Ltd. For written permission, + please contact dom4j-info@metastuff.com. + +4. Products derived from this Software may not be called "DOM4J" + nor may "DOM4J" appear in their names without prior written + permission of MetaStuff, Ltd. DOM4J is a registered + trademark of MetaStuff, Ltd. + +5. Due credit should be given to the DOM4J Project - + http://dom4j.sourceforge.net + +THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: https://github.com/dom4j/dom4j +FileSaver.js 1.3.3 +Attribution Statements +https://eligrey.com/blog/saving-generated-files-on-the-client-side/ + +Copyright Statements +Copyright (c) 2016 Eli Grey. + +License Text (http://spdx.org/licenses/MIT) +MIT License + +Copyright (c) 2016 Eli Grey. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/eligrey/FileSaver.js +FunctX 1.0 +Attribution Statements +http://www.functx.com/ + +Copyright Statements +Copyright (C) 2007 Datypic + +License Text (http://spdx.org/licenses/LGPL-2.1.html) +GNU LESSER GENERAL PUBLIC LICENSE +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, +but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the successor +of the GNU Library Public License, version 2, hence the version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share and +change it. By contrast, the GNU General Public Licenses are intended to guarantee your +freedom to share and change free software--to make sure the software is free for all +its users. + +This license, the Lesser General Public License, applies to some specially designated +software packages--typically libraries--of the Free Software Foundation and other +authors who decide to use it. You can use it too, but we suggest you first think +carefully about whether this license or the ordinary General Public License is the +better strategy to use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. Our +General Public Licenses are designed to make sure that you have the freedom to +distribute copies of free software (and charge for this service if you wish); that you +receive source code or can get it if you want it; that you can change the software and +use pieces of it in new free programs; and that you are informed that you can do these +things. + +To protect your rights, we need to make restrictions that forbid distributors to deny +you these rights or to ask you to surrender these rights. These restrictions translate +to certain responsibilities for you if you distribute copies of the library or if you +modify it. + +For example, if you distribute copies of the library, whether gratis or for a fee, you +must give the recipients all the rights that we gave you. You must make sure that +they, too, receive or can get the source code. If you link other code with the +library, you must provide complete object files to the recipients, so that they can +relink them with the library after making changes to the library and recompiling it. +And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, and (2) +we offer you this license, which gives you legal permission to copy, distribute and/or +modify the library. + +To protect each distributor, we want to make it very clear that there is no warranty +for the free library. Also, if the library is modified by someone else and passed on, +the recipients should know that what they have is not the original version, so that +the original author's reputation will not be affected by problems that might be +introduced by others. + +Finally, software patents pose a constant threat to the existence of any free program. +We wish to make sure that a company cannot effectively restrict the users of a free +program by obtaining a restrictive license from a patent holder. Therefore, we insist +that any patent license obtained for a version of the library must be consistent with +the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU General +Public License. This license, the GNU Lesser General Public License, applies to +certain designated libraries, and is quite different from the ordinary General Public +License. We use this license for certain libraries in order to permit linking those +libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared library, +the combination of the two is legally speaking a combined work, a derivative of the +original library. The ordinary General Public License therefore permits such linking +only if the entire combination fits its criteria of freedom. The Lesser General Public +License permits more lax criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does Less to +protect the user's freedom than the ordinary General Public License. It also provides +other free software developers Less of an advantage over competing non-free programs. +These disadvantages are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain special +circumstances. + +For example, on rare occasions, there may be a special need to encourage the widest +possible use of a certain library, so that it becomes a de-facto standard. To achieve +this, non-free programs must be allowed to use the library. A more frequent case is +that a free library does the same job as widely used non-free libraries. In this case, +there is little to gain by limiting the free library to free software only, so we use +the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs enables a +greater number of people to use a large body of free software. For example, permission +to use the GNU C Library in non-free programs enables many more people to use the +whole GNU operating system, as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' freedom, +it does ensure that the user of a program that is linked with the Library has the +freedom and the wherewithal to run that program using a modified version of the +Library. + +The precise terms and conditions for copying, distribution and modification follow. +Pay close attention to the difference between a "work based on the library" and a +"work that uses the library". The former contains code derived from the library, +whereas the latter must be combined with the library in order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program which +contains a notice placed by the copyright holder or other authorized party saying it +may be distributed under the terms of this Lesser General Public License (also called +"this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared so as to be +conveniently linked with application programs (which use some of those functions and +data) to form executables. + +The "Library", below, refers to any such software library or work which has been +distributed under these terms. A "work based on the Library" means either the Library +or any derivative work under copyright law: that is to say, a work containing the +Library or a portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is included without +limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications +to it. For a library, complete source code means all the source code for all modules +it contains, plus any associated interface definition files, plus the scripts used to +control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered by this +License; they are outside its scope. The act of running a program using the Library is +not restricted, and output from such a program is covered only if its contents +constitute a work based on the Library (independent of the use of the Library in a +tool for writing it). Whether that is true depends on what the Library does and what +the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source code +as you receive it, in any medium, provided that you conspicuously and appropriately +publish on each copy an appropriate copyright notice and disclaimer of warranty; keep +intact all the notices that refer to this License and to the absence of any warranty; +and distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you may at your +option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, thus +forming a work based on the Library, and copy and distribute such modifications or +work under the terms of Section 1 above, provided that you also meet all of these +conditions: + +a) The modified work must itself be a software library. + +b) You must cause the files modified to carry prominent notices stating that you +changed the files and the date of any change. + +c) You must cause the whole of the work to be licensed at no charge to all third +parties under the terms of this License. + +d) If a facility in the modified Library refers to a function or a table of data to be +supplied by an application program that uses the facility, other than as an argument +passed when the facility is invoked, then you must make a good faith effort to ensure +that, in the event an application does not supply such function or table, the facility +still operates, and performs whatever part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose that is +entirely well-defined independent of the application. Therefore, Subsection 2d +requires that any application-supplied function or table used by this function must be +optional: if the application does not supply it, the square root function must still +compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable sections of +that work are not derived from the Library, and can be reasonably considered +independent and separate works in themselves, then this License, and its terms, do not +apply to those sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based on the Library, +the distribution of the whole must be on the terms of this License, whose permissions +for other licensees extend to the entire whole, and thus to each and every part +regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to +work written entirely by you; rather, the intent is to exercise the right to control +the distribution of derivative or collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library with the +Library (or with a work based on the Library) on a volume of a storage or distribution +medium does not bring the other work under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public License instead +of this License to a given copy of the Library. To do this, you must alter all the +notices that refer to this License, so that they refer to the ordinary GNU General +Public License, version 2, instead of to this License. (If a newer version than +version 2 of the ordinary GNU General Public License has appeared, then you can +specify that version instead if you wish.) Do not make any other change in these +notices. + +Once this change is made in a given copy, it is irreversible for that copy, so the +ordinary GNU General Public License applies to all subsequent copies and derivative +works made from that copy. + +This option is useful when you wish to copy part of the code of the Library into a +program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of it, under +Section 2) in object code or executable form under the terms of Sections 1 and 2 above +provided that you accompany it with the complete corresponding machine-readable source +code, which must be distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated +place, then offering equivalent access to copy the source code from the same place +satisfies the requirement to distribute the source code, even though third parties are +not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but is +designed to work with the Library by being compiled or linked with it, is called a +"work that uses the Library". Such a work, in isolation, is not a derivative work of +the Library, and therefore falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates an executable +that is a derivative of the Library (because it contains portions of the Library), +rather than a "work that uses the library". The executable is therefore covered by +this License. Section 6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file that is part of +the Library, the object code for the work may be a derivative work of the Library even +though the source code is not. Whether this is true is especially significant if the +work can be linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure layouts and +accessors, and small macros and small inline functions (ten lines or less in length), +then the use of the object file is unrestricted, regardless of whether it is legally a +derivative work. (Executables containing this object code plus portions of the Library +will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute the object +code for the work under the terms of Section 6. Any executables containing that work +also fall under Section 6, whether or not they are linked directly with the Library +itself. + +6. As an exception to the Sections above, you may also combine or link a "work that +uses the Library" with the Library to produce a work containing portions of the +Library, and distribute that work under terms of your choice, provided that the terms +permit modification of the work for the customer's own use and reverse engineering for +debugging such modifications. + +You must give prominent notice with each copy of the work that the Library is used in +it and that the Library and its use are covered by this License. You must supply a +copy of this License. If the work during execution displays copyright notices, you +must include the copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one of these things: + +a) Accompany the work with the complete corresponding machine-readable source code for +the Library including whatever changes were used in the work (which must be +distributed under Sections 1 and 2 above); and, if the work is an executable linked +with the Library, with the complete machine-readable "work that uses the Library", as +object code and/or source code, so that the user can modify the Library and then +relink to produce a modified executable containing the modified Library. (It is +understood that the user who changes the contents of definitions files in the Library +will not necessarily be able to recompile the application to use the modified +definitions.) + +b) Use a suitable shared library mechanism for linking with the Library. A suitable +mechanism is one that (1) uses at run time a copy of the library already present on +the user's computer system, rather than copying library functions into the executable, +and (2) will operate properly with a modified version of the library, if the user +installs one, as long as the modified version is interface-compatible with the version +that the work was made with. + +c) Accompany the work with a written offer, valid for at least three years, to give +the same user the materials specified in Subsection 6a, above, for a charge no more +than the cost of performing this distribution. + +d) If distribution of the work is made by offering access to copy from a designated +place, offer equivalent access to copy the above specified materials from the same +place. + +e) Verify that the user has already received a copy of these materials or that you +have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must include +any data and utility programs needed for reproducing the executable from it. However, +as a special exception, the materials to be distributed need not include anything that +is normally distributed (in either source or binary form) with the major components +(compiler, kernel, and so on) of the operating system on which the executable runs, +unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other +proprietary libraries that do not normally accompany the operating system. Such a +contradiction means you cannot use both them and the Library together in an executable +that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side +in a single library together with other library facilities not covered by this +License, and distribute such a combined library, provided that the separate +distribution of the work based on the Library and of the other library facilities is +otherwise permitted, and provided that you do these two things: + +a) Accompany the combined library with a copy of the same work based on the Library, +uncombined with any other library facilities. This must be distributed under the terms +of the Sections above. + +b) Give prominent notice with the combined library of the fact that part of it is a +work based on the Library, and explaining where to find the accompanying uncombined +form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library except +as expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense, link with, or distribute the Library is void, and will automatically +terminate your rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses terminated so long +as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, +nothing else grants you permission to modify or distribute the Library or its +derivative works. These actions are prohibited by law if you do not accept this +License. Therefore, by modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and all its terms and +conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the +recipient automatically receives a license from the original licensor to copy, +distribute, link with or modify the Library subject to these terms and conditions. You +may not impose any further restrictions on the recipients' exercise of the rights +granted herein. You are not responsible for enforcing compliance by third parties with +this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or +for any other reason (not limited to patent issues), conditions are imposed on you +(whether by court order, agreement or otherwise) that contradict the conditions of +this License, they do not excuse you from the conditions of this License. If you +cannot distribute so as to satisfy simultaneously your obligations under this License +and any other pertinent obligations, then as a consequence you may not distribute the +Library at all. For example, if a patent license would not permit royalty-free +redistribution of the Library by all those who receive copies directly or indirectly +through you, then the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular +circumstance, the balance of the section is intended to apply, and the section as a +whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other +property right claims or to contest validity of any such claims; this section has the +sole purpose of protecting the integrity of the free software distribution system +which is implemented by public license practices. Many people have made generous +contributions to the wide range of software distributed through that system in +reliance on consistent application of that system; it is up to the author/donor to +decide if he or she is willing to distribute software through any other system and a +licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence +of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries +either by patents or by copyrighted interfaces, the original copyright holder who +places the Library under this License may add an explicit geographical distribution +limitation excluding those countries, so that distribution is permitted only in or +among countries not thus excluded. In such case, this License incorporates the +limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser +General Public License from time to time. Such new versions will be similar in spirit +to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies a +version number of this License which applies to it and "any later version", you have +the option of following the terms and conditions either of that version or of any +later version published by the Free Software Foundation. If the Library does not +specify a license version number, you may choose any version ever published by the +Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose +distribution conditions are incompatible with these, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, write +to the Free Software Foundation; we sometimes make exceptions for this. Our decision +will be guided by the two goals of preserving the free status of all derivatives of +our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE +LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN +WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE +RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY +PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY +COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS +PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, +INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE +OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE +WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible use to +the public, we recommend making it free software that everyone can redistribute and +change. You can do so by permitting redistribution under these terms (or, +alternatively, under the terms of the ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is safest to +attach them to the start of each source file to most effectively convey the exclusion +of warranty; and each file should have at least the "copyright" line and a pointer to +where the full notice is found. + +one line to give the library's name and an idea of what it does. +Copyright (C) year name of author + +This library is free software; you can redistribute it and/or modify it under the +terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, +Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by +electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, if +any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; +alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! + +GeoNames 1.0 +Attribution Statements +http://www.geonames.org/source-code/ + +Copyright Statements +Copyright 2012 Marc Wick, geonames.org + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://sourceforge.net/projects/geonames/ +Gradle 2.14 +Attribution Statements +https://gradle.org/ + +Gradle Subcomponents: + +------------------------------------------------------------------------------ +License for the slf4j package +------------------------------------------------------------------------------ +SLF4J License + +Copyright (c) 2004-2007 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +These terms are identical to those of the MIT License, also called the X License or +the X11 License, +which is a simple, permissive non-copyleft free software license. It is deemed +compatible with virtually +all types of licenses, commercial or otherwise. In particular, the Free Software +Foundation has declared it +compatible with GNU GPL. It is also known to be approved by the Apache Software +Foundation as compatible +with Apache Software License. + + +------------------------------------------------------------------------------ +License for the JUnit package +------------------------------------------------------------------------------ +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses +to its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license set +forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered +by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on or +through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to +control, and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may participate in +any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement, including but not limited to the risks and costs of +program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against a Contributor with respect to +a patent applicable to software (including a cross-claim or counterclaim in a +lawsuit), then any patent licenses granted by that Contributor to such Recipient +under this Agreement shall terminate as of the date such litigation is filed. In +addition, if Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the Program +itself (excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +IBM is the initial Agreement Steward. IBM may assign the responsibility to serve +as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the Agreement +is published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in Sections +2(a) and 2(b) above, Recipient receives no rights or licenses to the +intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. + +------------------------------------------------------------------------------ +License for the JCIFS package +------------------------------------------------------------------------------ +JCIFS License + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + +Copyright Statements +(c) Gradle Inc. 2017 + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://services.gradle.org/distributions/gradle-2.14- +bin.zip +Gradle 2.14 +Attribution Statements +https://gradle.org/ + +Gradle Subcomponents: + +------------------------------------------------------------------------------ +License for the slf4j package +------------------------------------------------------------------------------ +SLF4J License + +Copyright (c) 2004-2007 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +These terms are identical to those of the MIT License, also called the X License or +the X11 License, +which is a simple, permissive non-copyleft free software license. It is deemed +compatible with virtually +all types of licenses, commercial or otherwise. In particular, the Free Software +Foundation has declared it +compatible with GNU GPL. It is also known to be approved by the Apache Software +Foundation as compatible +with Apache Software License. + + +------------------------------------------------------------------------------ +License for the JUnit package +------------------------------------------------------------------------------ +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses +to its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license set +forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered +by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on or +through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to +control, and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may participate in +any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement, including but not limited to the risks and costs of +program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against a Contributor with respect to +a patent applicable to software (including a cross-claim or counterclaim in a +lawsuit), then any patent licenses granted by that Contributor to such Recipient +under this Agreement shall terminate as of the date such litigation is filed. In +addition, if Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the Program +itself (excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +IBM is the initial Agreement Steward. IBM may assign the responsibility to serve +as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the Agreement +is published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in Sections +2(a) and 2(b) above, Recipient receives no rights or licenses to the +intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. + +------------------------------------------------------------------------------ +License for the JCIFS package +------------------------------------------------------------------------------ +JCIFS License + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + +Copyright Statements +(c) Gradle Inc. 2017 + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://services.gradle.org/distributions/gradle-2.14- +bin.zip +Gradle 2.14 +Attribution Statements +https://gradle.org/ + +Gradle Subcomponents: + +------------------------------------------------------------------------------ +License for the slf4j package +------------------------------------------------------------------------------ +SLF4J License + +Copyright (c) 2004-2007 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +These terms are identical to those of the MIT License, also called the X License or +the X11 License, +which is a simple, permissive non-copyleft free software license. It is deemed +compatible with virtually +all types of licenses, commercial or otherwise. In particular, the Free Software +Foundation has declared it +compatible with GNU GPL. It is also known to be approved by the Apache Software +Foundation as compatible +with Apache Software License. + + +------------------------------------------------------------------------------ +License for the JUnit package +------------------------------------------------------------------------------ +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses +to its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license set +forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered +by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on or +through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to +control, and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may participate in +any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement, including but not limited to the risks and costs of +program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against a Contributor with respect to +a patent applicable to software (including a cross-claim or counterclaim in a +lawsuit), then any patent licenses granted by that Contributor to such Recipient +under this Agreement shall terminate as of the date such litigation is filed. In +addition, if Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the Program +itself (excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +IBM is the initial Agreement Steward. IBM may assign the responsibility to serve +as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the Agreement +is published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in Sections +2(a) and 2(b) above, Recipient receives no rights or licenses to the +intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. + +------------------------------------------------------------------------------ +License for the JCIFS package +------------------------------------------------------------------------------ +JCIFS License + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + +Copyright Statements +(c) Gradle Inc. 2017 + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://services.gradle.org/distributions/gradle-2.14- +bin.zip +Gson 2.2.2 +Attribution Statements +http://code.google.com/p/google-gson/ + +Copyright Statements +Copyright 2008 Google Inc. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/google/gson +Gson 2.8.1 +Attribution Statements +http://code.google.com/p/google-gson/ + +Copyright Statements +Copyright 2008 Google Inc. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/google/gson +Guava 11.0.2 +Attribution Statements +http://code.google.com/p/guava-libraries + +Copyright Statements +Copyright (c) Google. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/google/guava +H2 Database Engine 1.4.193 +Attribution Statements +http://www.h2database.com/html/main.html + +Copyright Statements +Thomas Mueller + +License Text (http://spdx.org/licenses/EPL-1.0) + +Source materials are available for download at: http://www.h2database.com/html/download.html +Hamcrest 1.3 +Attribution Statements +http://code.google.com/p/hamcrest + +Copyright Statements +Copyright (c) 2000-2015 www.hamcrest.org +All rights reserved. + +License Text (http://spdx.org/licenses/BSD-2-Clause) +BSD License + +Copyright (c) 2000-2015 www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +Source materials are available for download at: https://github.com/hamcrest/JavaHamcrest +HtmlCleaner 2.21 +Attribution Statements +http://htmlcleaner.sourceforge.net/ + +Copyright Statements +Copyright (c) 2006-2017, HtmlCleaner team. All rights reserved. + +License Text (https://spdx.org/licenses/BSD-3-Clause.html) + Copyright (c) 2006-2017, HtmlCleaner team. + All rights reserved. + + Redistribution and use of this software in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + + * The name of HtmlCleaner may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: http://htmlcleaner.sourceforge.net/download.php +HtmlCleaner 2.4 +Attribution Statements +http://htmlcleaner.sourceforge.net/ + +Copyright Statements +Copyright (c) 2006-2017, HtmlCleaner team. All rights reserved. + +License Text (https://spdx.org/licenses/BSD-3-Clause.html) + Copyright (c) 2006-2017, HtmlCleaner team. + All rights reserved. + + Redistribution and use of this software in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + + * The name of HtmlCleaner may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: http://htmlcleaner.sourceforge.net/download.php +HyperSQL Database (HSQLDB) 2.3.4 +Attribution Statements +http://hsqldb.org/ + +For work originally developed by the Hypersonic SQL Group: + +Copyright (c) 1995-2000 by the Hypersonic SQL Group. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +Neither the name of the Hypersonic SQL Group nor the names of its +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE HYPERSONIC SQL GROUP, +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +This software consists of voluntary contributions made by many individuals on behalf +of the +Hypersonic SQL Group. + +Copyright Statements +Copyright (c) 2001-2016, The HSQL Development Group +All rights reserved. + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Copyright (c) 2001-2016, The HSQL Development Group +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +Neither the name of the HSQL Development Group nor the names of its +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG, +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: http://mvnrepository.com/artifact/org.hsqldb/hsqldb +HyperSQL Database (HSQLDB) 2.4.0 +Attribution Statements +http://hsqldb.org/ + +For work originally developed by the Hypersonic SQL Group: + +Copyright (c) 1995-2000 by the Hypersonic SQL Group. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +Neither the name of the Hypersonic SQL Group nor the names of its +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE HYPERSONIC SQL GROUP, +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +This software consists of voluntary contributions made by many individuals on behalf +of the +Hypersonic SQL Group. + +Copyright Statements +Copyright (c) 2001-2016, The HSQL Development Group +All rights reserved. + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Copyright (c) 2001-2016, The HSQL Development Group +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +Neither the name of the HSQL Development Group nor the names of its +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG, +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: http://mvnrepository.com/artifact/org.hsqldb/hsqldb +Intl.js 1.2.5 +Attribution Statements +Contents of the `locale-data` directory are a modified form of the Unicode CLDR +data found at http://www.unicode.org/cldr/data/. It comes with the following +license. + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1991-2013 Unicode, Inc. All rights reserved. Distributed under +the Terms of Use in http://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +the Unicode data files and any associated documentation (the "Data Files") or +Unicode software and any associated documentation (the "Software") to deal in +the Data Files or Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, and/or sell copies +of the Data Files or Software, and to permit persons to whom the Data Files or +Software are furnished to do so, provided that (a) the above copyright +notice(s) and this permission notice appear with all copies of the Data Files +or Software, (b) both the above copyright notice(s) and this permission notice +appear in associated documentation, and (c) there is clear notice in each +modified Data File or in the Software as well as in the documentation +associated with the Data File(s) or Software that the data or software has been +modified. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD +PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN +THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING +OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR +SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not be +used in advertising or otherwise to promote the sale, use or other dealings in +these Data Files or Software without prior written authorization of the +copyright holder. + +Unicode and the Unicode logo are trademarks of Unicode, Inc. in the United +States and other countries. All third party trademarks referenced herein are +the property of their respective owners. + +Copyright Statements +Copyright (c) 2013 Andy Earnshaw + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2013 Andy Earnshaw + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/andyearnshaw/Intl.js +Jackson Annotations 2.8.0 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: http://github.com/FasterXML/jackson +Jackson Annotations 2.8.3 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: http://github.com/FasterXML/jackson +Jackson Annotations 2.9.1 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: http://github.com/FasterXML/jackson +Jackson Core 1.9.13 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/FasterXML/jackson-core +Jackson Core 2.8.0 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://www.apache.org/licenses/LICENSE-2.0.txt) + +Source materials are available for download at: https://github.com/FasterXML/jackson-core +Jackson Core 2.8.3 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://www.apache.org/licenses/LICENSE-2.0.txt) + +Source materials are available for download at: https://github.com/FasterXML/jackson-core +Jackson Core 2.9.1 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://www.apache.org/licenses/LICENSE-2.0.txt) + +Source materials are available for download at: https://github.com/FasterXML/jackson-core +Jackson Databind 2.8.0 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://www.apache.org/licenses/LICENSE-2.0.txt) + +Source materials are available for download at: https://github.com/FasterXML/jackson-databind +Jackson Databind 2.8.3 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://www.apache.org/licenses/LICENSE-2.0.txt) + +Source materials are available for download at: https://github.com/FasterXML/jackson-databind +Jackson Databind 2.9.1 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://www.apache.org/licenses/LICENSE-2.0.txt) + +Source materials are available for download at: https://github.com/FasterXML/jackson-databind +Jackson Dataformat CSV 2.8.3 +Attribution Statements +https://github.com/FasterXML/jackson-dataformat-csv + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/FasterXML/jackson-dataformat-csv +Jackson Dataformat CSV 2.9.1 +Attribution Statements +https://github.com/FasterXML/jackson-dataformat-csv + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/FasterXML/jackson-dataformat-csv +Jackson Dataformat XML 2.8.3 +Attribution Statements +http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/FasterXML/jackson-dataformat-xml +Jackson Dataformat XML 2.9.1 +Attribution Statements +http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/FasterXML/jackson-dataformat-xml +Jackson JAXB Annotations 2.8.8 +Attribution Statements +http://wiki.fasterxml.com/JacksonJAXBAnnotations + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download +at: https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-jaxb-annotations +Jackson Mapper 1.9.13 +Attribution Statements +http://wiki.fasterxml.com/JacksonHome + +Copyright Statements +Copyright (c)2009 FasterXML, LLC + +License Text (http://spdx.org/licenses/Apache-2.0) + +Java SE Runtime Environment (JRE) 7 +Attribution Statements +http://docs.oracle.com/javase/ + +The Java(TM) Platform, Standard Edition Runtime Environment (JRE) is +intended for software developers and vendors to redistribute with +their applications. + +The Java SE Runtime Environment contains the Java virtual machine, +runtime class libraries, and Java application launcher that are +necessary to run programs written in the Java programming language. +It is not a development environment and does not contain development +tools such as compilers or debuggers. For development tools, see the +Java SE Development Kit (JDK(TM)). + + +======================================================================= + Deploying Applications with the Java SE Runtime Environment +======================================================================= + +When you deploy an application written in the Java programming +language, your software bundle will probably consist of the following +parts: + + Your own class, resource, and data files. + A runtime environment. + An installation procedure or program. + +You already have the first part, of course. The remainder of this +document covers the other two parts. Also see the Developers website: + + http://www.oracle.com/technetwork/java + +----------------------------------------------------------------------- +Runtime Environment +----------------------------------------------------------------------- + +To run your application, a user needs the Java SE Runtime Environment, +which is freely available from Oracle. Or, you can redistribute the +Java SE Runtime Environment for free with your application, according +to the terms of the Oracle Binary Code License Agreement for the Java +SE Platform Products. + +The final step in the deployment process occurs when the software is +installed on an individual user's system. Installation consists of copying +software onto the user's system, then configuring the user's system +to support that software. You should ensure that your installation +procedure does not overwrite existing JRE installations, as they may +be required by other applications. + + +======================================================================= + Redistribution of the Java SE Runtime Environment (JRE) +======================================================================= + + -------------------------------------------------------- + NOTE - The license for this software does not allow the + redistribution of beta and other pre-release versions. + -------------------------------------------------------- + +You may reproduce and distribute the Software (and also portions of +Software identified below as Redistributable), provided that you comply +with the terms and conditions of the Oracle Binary Code License +Agreement for the Java SE Platform Products. + +The term "vendors" used here refers to licensees, developers, and +independent software vendors (ISVs) who license and distribute the +Java SE Runtime Environment with their programs. + +Vendors must follow the terms of the Java SE Runtime Environment Binary +Code License agreement. + +----------------------------------------------------------------------- +Required vs. Optional Files +----------------------------------------------------------------------- + +The files that make up the Java SE Runtime Environment are divided into +two categories: required and optional. Optional files may be excluded +from redistributions of the Java SE Runtime Environment at the +vendor's discretion. + +The following section contains a list of the files and directories that +may optionally be omitted from redistributions with the Java SE Runtime +Environment. All files not in these lists of optional files must be +included in redistributions of the runtime environment. + +----------------------------------------------------------------------- +Optional Files and Directories +----------------------------------------------------------------------- + +The following files may be optionally excluded from redistributions. +These files are located in the jre1.7.0_ directory, where + is the update version number. Solaris and Linux filenames +and separators are shown. Windows executables have the ".exe" suffix. +Corresponding files with _g in the name can also be excluded. +The corresponding man pages should be excluded for any excluded +executables (with paths listed below beginning with bin/ , +for the Solaris(TM) Operating System and Linux). + + lib/ext/ + sunjce_provider.jar,sunec.jar, sunpkcs11.jar and sunmscapi.jar - JCA/JCE + providers for Java Cryptography APIs. Some providers + are not available on all OS or Architectures. The + runtime environment must contain at least one implementation + of each of the required Security algorithms as described in: + http://download.oracle.com/javase/7/docs/technotes/guides/ + security/StandardNames.html + + localedata.jar - contains many of the resources + needed for non US English locales + dnsns.jar - for the InetAddress wrapper of JNDI DNS provider + bin/rmid [.exe, and .dll on Microsoft Windows] + Java RMI Activation System Daemon + bin/rmiregistry + Java Remote Object Registry + bin/tnameserv + Java IDL Name Server + bin/keytool + Key and Certificate Management Tool + bin/kinit [Microsoft Windows] + Used to obtain and cache Kerberos ticket-granting tickets + bin/klist [Microsoft Windows] + Kerberos display entries in credentials cache and keytab + bin/ktab [Microsoft Windows] + Kerberos key table manager + bin/policytool + Policy File Creation and Management Tool + bin/orbd + Object Request Broker Daemon + bin/servertool + Java IDL Server Tool + bin/javaws and lib/javaws.jar + Java Web Start + +When redistributing the JRE on Microsoft Windows as a private +application runtime (not accessible by other applications) +with a custom launcher, the following files are also +optional. These are libraries and executables that are used +for Java support in Internet Explorer and Mozilla family browsers; +these files are not needed in a private JRE redistribution. + + bin\java.exe + bin\javaw.exe + bin\javaws.exe + bin\javacpl.exe + bin\jucheck.exe + bin\wsdetect.dll + bin\npjpi*.dll (The filename changes in every release) + bin\NPOJI610.dll + bin\axbridge.dll + bin\deploy.dll + bin\jpicom.dll + bin\javacpl.cpl + + bin\jpiexp32.dll + bin\jpinscp.dll + bin\jpioji.dll + bin\jpishare.dll + lib\deploy.jar + lib\plugin.jar + lib\javaws.jar + lib\deploy\messages.properties + lib\deploy\messages_de.properties + lib\deploy\messages_es.properties + lib\deploy\messages_fr.properties + lib\deploy\messages_it.properties + lib\deploy\messages_ja.properties + lib\deploy\messages_ko.properties + lib\deploy\messages_pt_BR.properties + lib\deploy\messages_sv.properties + lib\deploy\messages_zh_CN.properties + lib\deploy\messages_zh_HK.properties + lib\deploy\messages_zh_TW.properties + lib\deploy\splash.jpg + + +----------------------------------------------------------------------- +Redistributable JDK(TM) Files +----------------------------------------------------------------------- + +The limited set of files from the Java SE Development Kit (JDK) +listed below may be included in vendor redistributions of the Java SE +Runtime Environment. All paths are relative to the top-level +directory of the JDK. The corresponding man pages should be included for +any included executables (with paths listed below beginning with bin/ , +for the Solaris(TM) Operating System and Linux). + + jre/lib/cmm/PYCC.pf + Color profile. This file is required only if one wishes to + convert between the PYCC color space and another color space. + + All .ttf font files in the jre/lib/fonts directory. + Note that the LucidaSansRegular.ttf font is already contained + in the Java SE Runtime Environment, so there is no need to + bring that file over from the JDK. + + The javac bytecode compiler, consisting of the following files: + bin/javac [Solaris(TM) Operating System + and Linux] + bin/sparcv9/javac [Solaris Operating System + (SPARC(R) Platform Edition)] + bin/amd64/javac [Solaris Operating System (AMD)] + bin/javac.exe [Microsoft Windows] + lib/tools.jar [All platforms] + + The Annotation Processing Tool, consisting of the following files: + bin/apt [Solaris(TM) Operating System + and Linux] + bin/sparcv9/apt [Solaris Operating System + (SPARC(R) Platform Edition)] + bin/amd64/apt [Solaris Operating System (AMD)] + bin/apt.exe [Microsoft Windows] + + lib/jconsole.jar + The Jconsole application. + + jre\bin\server\ + On Microsoft Windows platforms, the JDK includes both + the Java HotSpot(TM) Server VM and Java HotSpot Client VM. + However, the Java SE Runtime Environment for Microsoft Windows + platforms includes only the Java HotSpot Client VM. Those wishing + to use the Java HotSpot Server VM with the Java SE Runtime + Environment may copy the JDK's jre\bin\server folder to a + bin\server directory in the Java SE Runtime Environment. Software + vendors may redistribute the Java HotSpot Server VM with their + redistributions of the Java SE Runtime Environment. + + +----------------------------------------------------------------------- +Unlimited Strength Java Cryptography Extension +----------------------------------------------------------------------- + +Due to import control restrictions for some countries, the Java +Cryptography Extension (JCE) policy files shipped with the Java SE +Development Kit and the Java SE Runtime Environment allow strong but +limited cryptography to be used. These files are located at + + /lib/security/local_policy.jar + /lib/security/US_export_policy.jar + +where is the jre directory of the JDK or the +top-level directory of the Java SE Runtime Environment. + +An unlimited strength version of these files indicating no restrictions +on cryptographic strengths is available on the JDK web site for +those living in eligible countries. Those living in eligible countries +may download the unlimited strength version and replace the strong +cryptography jar files with the unlimited strength files. + +----------------------------------------------------------------------- +The cacerts Certificates File +----------------------------------------------------------------------- + +Root CA certificates may be added to or removed from the Java SE +certificate file located at + + /lib/security/cacerts + +For more information, see "The cacerts Certificates File" section +in the keytool documentation at: + +http://download.oracle.com/javase/7/docs/technotes/guides/security + +======================================================================= +Endorsed Standards Override Mechanism +======================================================================= + +From time to time it is necessary to update the Java platform in order +to incorporate newer versions of standards that are created outside of +the Java Community Process(SM) (JCP(SM) http://www.jcp.org/) (Endorsed +Standards), or in order to update the version of a technology included +in the platform to correspond to a later standalone version of that +technology (Standalone Technologies). + +The Endorsed Standards Override Mechanism provides a means whereby +later versions of classes and interfaces that implement Endorsed +Standards or Standalone Technologies may be incorporated into the Java +Platform. + +For more information on the Endorsed Standards Override Mechanism, +including the list of platform packages that it may be used to +override, see + + http://download.oracle.com/javase/7/docs/technotes/guides/standards/ + +Copyright Statements +The Java(TM) Runtime Environment (JRE) is a product of Oracle. + +License Text (http://www.oracle.com/technetwork/java/javase/terms/license/index.html) +Oracle Binary Code License Agreement for the Java SE Platform Products and JavaFX + +ORACLE AMERICA, INC. ("ORACLE"), FOR AND ON BEHALF OF ITSELF AND ITS SUBSIDIARIES AND +AFFILIATES UNDER COMMON CONTROL, IS WILLING TO LICENSE THE SOFTWARE TO YOU ONLY UPON +THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS BINARY CODE LICENSE +AGREEMENT AND SUPPLEMENTAL LICENSE TERMS (COLLECTIVELY "AGREEMENT"). PLEASE READ THE +AGREEMENT CAREFULLY. BY SELECTING THE "ACCEPT LICENSE AGREEMENT" (OR THE EQUIVALENT) +BUTTON AND/OR BY USING THE SOFTWARE YOU ACKNOWLEDGE THAT YOU HAVE READ THE TERMS AND +AGREE TO THEM. IF YOU ARE AGREEING TO THESE TERMS ON BEHALF OF A COMPANY OR OTHER +LEGAL ENTITY, YOU REPRESENT THAT YOU HAVE THE LEGAL AUTHORITY TO BIND THE LEGAL ENTITY +TO THESE TERMS. IF YOU DO NOT HAVE SUCH AUTHORITY, OR IF YOU DO NOT WISH TO BE BOUND +BY THE TERMS, THEN SELECT THE "DECLINE LICENSE AGREEMENT" (OR THE EQUIVALENT) BUTTON +AND YOU MUST NOT USE THE SOFTWARE ON THIS SITE OR ANY OTHER MEDIA ON WHICH THE +SOFTWARE IS CONTAINED. + +1. DEFINITIONS. "Software" means the software identified above in binary form that you +selected for download, install or use (in the version You selected for download, +install or use) from Oracle or its authorized licensees, any other machine readable +materials (including, but not limited to, libraries, source files, header files, and +data files), any updates or error corrections provided by Oracle, and any user +manuals, programming guides and other documentation provided to you by Oracle under +this Agreement. "General Purpose Desktop Computers and Servers" means computers, +including desktop and laptop computers, or servers, used for general computing +functions under end user control (such as but not specifically limited to email, +general purpose Internet browsing, and office suite productivity tools). The use of +Software in systems and solutions that provide dedicated functionality (other than as +mentioned above) or designed for use in embedded or function-specific software +applications, for example but not limited to: Software embedded in or bundled with +industrial control systems, wireless mobile telephones, wireless handheld devices, +kiosks, TV/STB, Blu-ray Disc devices, telematics and network control switching +equipment, printers and storage management systems, and other related systems are +excluded from this definition and not licensed under this Agreement. "Programs" means +(a) Java technology applets and applications intended to run on the Java Platform, +Standard Edition platform on Java-enabled General Purpose Desktop Computers and +Servers; and (b) JavaFX technology applications intended to run on the JavaFX Runtime +on JavaFX-enabled General Purpose Desktop Computers and Servers. "Commercial Features" +means those features identified in Table 1-1 (Commercial Features In Java SE Product +Editions) of the Java SE documentation accessible at +http://www.oracle.com/technetwork/java/javase/documentation/index.html. "README File" +means the README file for the Software accessible at +http://www.oracle.com/technetwork/java/javase/documentation/index.html. + +2. LICENSE TO USE. Subject to the terms and conditions of this Agreement including, +but not limited to, the Java Technology Restrictions of the Supplemental License +Terms, Oracle grants you a non-exclusive, non-transferable, limited license without +license fees to reproduce and use internally the Software complete and unmodified for +the sole purpose of running Programs. THE LICENSE SET FORTH IN THIS SECTION 2 DOES NOT +EXTEND TO THE COMMERCIAL FEATURES. YOUR RIGHTS AND OBLIGATIONS RELATED TO THE +COMMERCIAL FEATURES ARE AS SET FORTH IN THE SUPPLEMENTAL TERMS ALONG WITH ADDITIONAL +LICENSES FOR DEVELOPERS AND PUBLISHERS. + +3. RESTRICTIONS. Software is copyrighted. Title to Software and all associated +intellectual property rights is retained by Oracle and/or its licensors. Unless +enforcement is prohibited by applicable law, you may not modify, decompile, or reverse +engineer Software. You acknowledge that the Software is developed for general use in a +variety of information management applications; it is not developed or intended for +use in any inherently dangerous applications, including applications that may create a +risk of personal injury. If you use the Software in dangerous applications, then you +shall be responsible to take all appropriate fail-safe, backup, redundancy, and other +measures to ensure its safe use. Oracle disclaims any express or implied warranty of +fitness for such uses. No right, title or interest in or to any trademark, service +mark, logo or trade name of Oracle or its licensors is granted under this Agreement. +Additional restrictions for developers and/or publishers licenses are set forth in the +Supplemental License Terms. + +4. DISCLAIMER OF WARRANTY. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +KIND. ORACLE FURTHER DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT +LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE OR NONINFRINGEMENT. + +5. LIMITATION OF LIABILITY. IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY INDIRECT, +INCIDENTAL, SPECIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR DAMAGES FOR LOSS OF +PROFITS, REVENUE, DATA OR DATA USE, INCURRED BY YOU OR ANY THIRD PARTY, WHETHER IN AN +ACTION IN CONTRACT OR TORT, EVEN IF ORACLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. ORACLE'S ENTIRE LIABILITY FOR DAMAGES HEREUNDER SHALL IN NO EVENT EXCEED ONE +THOUSAND DOLLARS (U.S. $1,000). + +6. TERMINATION. This Agreement is effective until terminated. You may terminate this +Agreement at any time by destroying all copies of Software. This Agreement will +terminate immediately without notice from Oracle if you fail to comply with any +provision of this Agreement. Either party may terminate this Agreement immediately +should any Software become, or in either party's opinion be likely to become, the +subject of a claim of infringement of any intellectual property right. Upon +termination, you must destroy all copies of Software. + +7. EXPORT REGULATIONS. You agree that U.S. export control laws and other applicable +export and import laws govern your use of the Software, including technical data; +additional information can be found on Oracle's Global Trade Compliance web site +(http://www.oracle.com/us/products/export). You agree that neither the Software nor +any direct product thereof will be exported, directly, or indirectly, in violation of +these laws, or will be used for any purpose prohibited by these laws including, +without limitation, nuclear, chemical, or biological weapons proliferation. + +8. TRADEMARKS AND LOGOS. You acknowledge and agree as between you +and Oracle that Oracle owns the ORACLE and JAVA trademarks and all ORACLE- and JAVA- +related trademarks, service marks, logos and other brand +designations ("Oracle Marks"), and you agree to comply with the Third +Party Usage Guidelines for Oracle Trademarks currently located at +http://www.oracle.com/us/legal/third-party-trademarks/index.html . Any use you make of +the Oracle Marks inures to Oracle's benefit. + +9. U.S. GOVERNMENT LICENSE RIGHTS. If Software is being acquired by or on behalf of +the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any +tier), then the Government's rights in Software and accompanying documentation shall +be only those set forth in this Agreement. + +10. GOVERNING LAW. This agreement is governed by the substantive and procedural laws +of California. You and Oracle agree to submit to the exclusive jurisdiction of, and +venue in, the courts of San Francisco, or Santa Clara counties in California in any +dispute arising out of or relating to this agreement. + +11. SEVERABILITY. If any provision of this Agreement is held to be unenforceable, this +Agreement will remain in effect with the provision omitted, unless omission would +frustrate the intent of the parties, in which case this Agreement will immediately +terminate. + +12. INTEGRATION. This Agreement is the entire agreement between you and Oracle +relating to its subject matter. It supersedes all prior or contemporaneous oral or +written communications, proposals, representations and warranties and prevails over +any conflicting or additional terms of any quote, order, acknowledgment, or other +communication between the parties relating to its subject matter during the term of +this Agreement. No modification of this Agreement will be binding, unless in writing +and signed by an authorized representative of each party. + +SUPPLEMENTAL LICENSE TERMS + +These Supplemental License Terms add to or modify the terms of the Binary Code License +Agreement. Capitalized terms not defined in these Supplemental Terms shall have the +same meanings ascribed to them in the Binary Code License Agreement. These +Supplemental Terms shall supersede any inconsistent or conflicting terms in the Binary +Code License Agreement, or in any license contained within the Software. + +A. COMMERCIAL FEATURES. You may not use the Commercial Features for running Programs, +Java applets or applications in your internal business operations or for any +commercial or production purpose, or for any purpose other than as set forth in +Sections B, C, D and E of these Supplemental Terms. If You want to use the Commercial +Features for any purpose other than as permitted in this Agreement, You must obtain a +separate license from Oracle. + +B. SOFTWARE INTERNAL USE FOR DEVELOPMENT LICENSE GRANT. Subject to the terms and +conditions of this Agreement and restrictions and exceptions set forth in the README +File incorporated herein by reference, including, but not limited to the Java +Technology Restrictions of these Supplemental Terms, Oracle grants you a non- +exclusive, non-transferable, limited license without fees to reproduce internally and +use internally the Software complete and unmodified for the purpose of designing, +developing, and testing your Programs. + +C. LICENSE TO DISTRIBUTE SOFTWARE. Subject to the terms and conditions of this +Agreement and restrictions and exceptions set forth in the README File, including, but +not limited to the Java Technology Restrictions and Limitations on Redistribution of +these Supplemental Terms, Oracle grants you a non-exclusive, non-transferable, limited +license without fees to reproduce and distribute the Software, provided that (i) you +distribute the Software complete and unmodified and only bundled as part of, and for +the sole purpose of running, your Programs, (ii) the Programs add significant and +primary functionality to the Software, (iii) you do not distribute additional software +intended to replace any component(s) of the Software, (iv) you do not remove or alter +any proprietary legends or notices contained in the Software, (v) you only distribute +the Software subject to a license agreement that: (a) is a complete, unmodified +reproduction of this Agreement; or (b) protects Oracle's interests consistent with the +terms contained in this Agreement and that includes the notice set forth in Section H, +and (vi) you agree to defend and indemnify Oracle and its licensors from and against +any damages, costs, liabilities, settlement amounts and/or expenses (including +attorneys' fees) incurred in connection with any claim, lawsuit or action by any third +party that arises or results from the use or distribution of any and all Programs +and/or Software. The license set forth in this Section C does not extend to the +Software identified in Section G. + +D. LICENSE TO DISTRIBUTE REDISTRIBUTABLES. Subject to the terms and conditions of this +Agreement and restrictions and exceptions set forth in the README File, including but +not limited to the Java Technology Restrictions and Limitations on Redistribution of +these Supplemental Terms, Oracle grants you a non-exclusive, non-transferable, limited +license without fees to reproduce and distribute those files specifically identified +as redistributable in the README File ("Redistributables") provided that: (i) you +distribute the Redistributables complete and unmodified, and only bundled as part of +Programs, (ii) the Programs add significant and primary functionality to the +Redistributables, (iii) you do not distribute additional software intended to +supersede any component(s) of the Redistributables (unless otherwise specified in the +applicable README File), (iv) you do not remove or alter any proprietary legends or +notices contained in or on the Redistributables, (v) you only distribute the +Redistributables pursuant to a license agreement that: (a) is a complete, unmodified +reproduction of this Agreement; or (b) protects Oracle's interests consistent with the +terms contained in the Agreement and includes the notice set forth in Section H, (vi) +you agree to defend and indemnify Oracle and its licensors from and against any +damages, costs, liabilities, settlement amounts and/or expenses (including attorneys' +fees) incurred in connection with any claim, lawsuit or action by any third party that +arises or results from the use or distribution of any and all Programs and/or +Software. The license set forth in this Section D does not extend to the Software +identified in Section G. + +E. DISTRIBUTION BY PUBLISHERS. This section pertains to your distribution of the +JavaTM SE Development Kit Software ("JDK") with your printed book or magazine (as +those terms are commonly used in the industry) relating to Java technology +("Publication"). Subject to and conditioned upon your compliance with the restrictions +and obligations contained in the Agreement, Oracle hereby grants to you a non- +exclusive, nontransferable limited right to reproduce complete and unmodified copies +of the JDK on electronic media (the "Media") for the sole purpose of inclusion and +distribution with your Publication(s), subject to the following terms: (i) You may not +distribute the JDK on a stand-alone basis; it must be distributed with your +Publication(s); (ii) You are responsible for downloading the JDK from the applicable +Oracle web site; (iii) You must refer to the JDK as JavaTM SE Development Kit; (iv) +The JDK must be reproduced in its entirety and without any modification whatsoever +(including with respect to all proprietary notices) and distributed with your +Publication subject to a license agreement that is a complete, unmodified reproduction +of this Agreement; (v) The Media label shall include the following information: +"Copyright [YEAR], Oracle America, Inc. All rights reserved. Use is subject to license +terms. ORACLE and JAVA trademarks and all ORACLE- and JAVA-related trademarks, service +marks, logos and other brand designations are trademarks or registered trademarks of +Oracle in the U.S. and other countries." [YEAR] is the year of Oracle's release of the +Software; the year information can typically be found in the Software's "About" box or +screen. This information must be placed on the Media label in such a manner as to only +apply to the JDK; (vi) You must clearly identify the JDK as Oracle's product on the +Media holder or Media label, and you may not state or imply that Oracle is responsible +for any third-party software contained on the Media; (vii) You may not include any +third party software on the Media which is intended to be a replacement or substitute +for the JDK; (viii) You agree to defend and indemnify Oracle and its licensors from +and against any damages, costs, liabilities, settlement amounts and/or expenses +(including attorneys' fees) incurred in connection with any claim, lawsuit or action +by any third party that arises or results from the use or distribution of the JDK +and/or the Publication; ; and (ix) You shall provide Oracle with a written notice for +each Publication; such notice shall include the following information: (1) title of +Publication, (2) author(s), (3) date of Publication, and (4) ISBN or ISSN numbers. +Such notice shall be sent to Oracle America, Inc., 500 Oracle Parkway, Redwood Shores, +California 94065 U.S.A , Attention: General Counsel. + +F. JAVA TECHNOLOGY RESTRICTIONS. You may not create, modify, or change the behavior +of, or authorize your licensees to create, modify, or change the behavior of, classes, +interfaces, or subpackages that are in any way identified as "java", "javax", "sun", +"oracle" or similar convention as specified by Oracle in any naming convention +designation. + +G. LIMITATIONS ON REDISTRIBUTION. You may not redistribute or otherwise transfer +patches, bug fixes or updates made available by Oracle through Oracle Premier Support, +including those made available under Oracle's Java SE Support program. + +H. COMMERCIAL FEATURES NOTICE. For purpose of complying with Supplemental Term Section +C.(v)(b) and D.(v)(b), your license agreement shall include the following notice, +where the notice is displayed in a manner that anyone using the Software will see the +notice: + +Use of the Commercial Features for any commercial or production purpose requires a +separate license from Oracle. "Commercial Features" means those features identified +Table 1-1 (Commercial Features In Java SE Product Editions) of the Java SE +documentation accessible at +http://www.oracle.com/technetwork/java/javase/documentation/index.html + + + +I. SOURCE CODE. Software may contain source code that, unless expressly licensed for +other purposes, is provided solely for reference purposes pursuant to the terms of +this Agreement. Source code may not be redistributed unless expressly provided for in +this Agreement. + +J. THIRD PARTY CODE. Additional copyright notices and license terms applicable to +portions of the Software are set forth in the THIRDPARTYLICENSEREADME file accessible +at http://www.oracle.com/technetwork/java/javase/documentation/index.html. In addition +to any terms and conditions of any third party opensource/freeware license identified +in the THIRDPARTYLICENSEREADME file, the disclaimer of warranty and limitation of +liability provisions in paragraphs 4 and 5 of the Binary Code License Agreement shall +apply to all Software in this distribution. + +K. TERMINATION FOR INFRINGEMENT. Either party may terminate this Agreement immediately +should any Software become, or in either party's opinion be likely to become, the +subject of a claim of infringement of any intellectual property right. + +L. INSTALLATION AND AUTO-UPDATE. The Software's installation and auto-update processes +transmit a limited amount of data to Oracle (or its service provider) about those +specific processes to help Oracle understand and optimize them. Oracle does not +associate the data with personally identifiable information. You can find more +information about the data Oracle collects as a result of your Software download at +http://www.oracle.com/technetwork/java/javase/documentation/index.html. + +For inquiries please contact: Oracle America, Inc., 500 Oracle Parkway, + +Redwood Shores, California 94065, USA. + +Last updated 02 April 2013 + +Source materials are available for download +at: http://www.oracle.com/technetwork/indexes/downloads/index.html +JavaBeans(tm) Activation Framework 1.1.1 +Attribution Statements +http://www.oracle.com/technetwork/articles/java/index-135046.html + +Copyright Statements +(c) Oracle + +License Text (http://spdx.org/licenses/CDDL-1.0) +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) +Version 1.0 +1. Definitions. + +1.1. "Contributor" means each individual or entity that creates or contributes to the +creation of Modifications. + +1.2. "Contributor Version" means the combination of the Original Software, prior +Modifications used by a Contributor (if any), and the Modifications made by that +particular Contributor. + +1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, or (c) +the combination of files containing Original Software with files containing +Modifications, in each case including portions thereof. + +1.4. "Executable" means the Covered Software in any form other than Source Code. + +1.5. "Initial Developer" means the individual or entity that first makes Original +Software available under this License. + +1.6. "Larger Work" means a work which combines Covered Software or portions thereof +with code not governed by the terms of this License. + +1.7. "License" means this document. + +1.8. "Licensable" means having the right to grant, to the maximum extent possible, +whether at the time of the initial grant or subsequently acquired, any and all of the +rights conveyed herein. + +1.9. "Modifications" means the Source Code and Executable form of any of the +following: + +A. Any file that results from an addition to, deletion from or modification of the +contents of a file containing Original Software or previous Modifications; + +B. Any new file that contains any part of the Original Software or previous +Modification; or + +C. Any new file that is contributed or otherwise made available under the terms of +this License. + +1.10. "Original Software" means the Source Code and Executable form of computer +software code that is originally released under this License. + +1.11. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, +including without limitation, method, process, and apparatus claims, in any patent +Licensable by grantor. + +1.12. "Source Code" means (a) the common form of computer software code in which +modifications are made and (b) associated documentation included in or with such code. + +1.13. "You" (or "Your") means an individual or a legal entity exercising rights under, +and complying with all of the terms of, this License. For legal entities, "You" +includes any entity which controls, is controlled by, or is under common control with +You. For purposes of this definition, "control" means (a) the power, direct or +indirect, to cause the direction or management of such entity, whether by contract or +otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares +or beneficial ownership of such entity. + +2. License Grants. + +2.1. The Initial Developer Grant. +Conditioned upon Your compliance with Section 3.1 below and subject to third party +intellectual property claims, the Initial Developer hereby grants You a world-wide, +royalty-free, non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) Licensable by +Initial Developer, to use, reproduce, modify, display, perform, sublicense and +distribute the Original Software (or portions thereof), with or without Modifications, +and/or as part of a Larger Work; and + +(b) under Patent Claims infringed by the making, using or selling of Original +Software, to make, have made, use, practice, sell, and offer for sale, and/or +otherwise dispose of the Original Software (or portions thereof). + +(c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial +Developer first distributes or otherwise makes the Original Software available to a +third party under the terms of this License. + +(d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code +that You delete from the Original Software, or (2) for infringements caused by: (i) +the modification of the Original Software, or (ii) the combination of the Original +Software with other software or devices. + +2.2. Contributor Grant. +Conditioned upon Your compliance with Section 3.1 below and subject to third party +intellectual property claims, each Contributor hereby grants You a world-wide, +royalty-free, non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) Licensable by +Contributor to use, reproduce, modify, display, perform, sublicense and distribute the +Modifications created by such Contributor (or portions thereof), either on an +unmodified basis, with other Modifications, as Covered Software and/or as part of a +Larger Work; and + +(b) under Patent Claims infringed by the making, using, or selling of Modifications +made by that Contributor either alone and/or in combination with its Contributor +Version (or portions of such combination), to make, use, sell, offer for sale, have +made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or +portions thereof); and (2) the combination of Modifications made by that Contributor +with its Contributor Version (or portions of such combination). + +(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date +Contributor first distributes or otherwise makes the Modifications available to a +third party. + +(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any +code that Contributor has deleted from the Contributor Version; (2) for infringements +caused by: (i) third party modifications of Contributor Version, or (ii) the +combination of Modifications made by that Contributor with other software (except as +part of the Contributor Version) or other devices; or (3) under Patent Claims +infringed by Covered Software in the absence of Modifications made by that +Contributor. + +3. Distribution Obligations. + +3.1. Availability of Source Code. +Any Covered Software that You distribute or otherwise make available in Executable +form must also be made available in Source Code form and that Source Code form must be +distributed only under the terms of this License. You must include a copy of this +License with every copy of the Source Code form of the Covered Software You distribute +or otherwise make available. You must inform recipients of any such Covered Software +in Executable form as to how they can obtain such Covered Software in Source Code form +in a reasonable manner on or through a medium customarily used for software exchange. + +3.2. Modifications. +The Modifications that You create or to which You contribute are governed by the terms +of this License. You represent that You believe Your Modifications are Your original +creation(s) and/or You have sufficient rights to grant the rights conveyed by this +License. + +3.3. Required Notices. +You must include a notice in each of Your Modifications that identifies You as the +Contributor of the Modification. You may not remove or alter any copyright, patent or +trademark notices contained within the Covered Software, or any notices of licensing +or any descriptive text giving attribution to any Contributor or the Initial +Developer. + +3.4. Application of Additional Terms. +You may not offer or impose any terms on any Covered Software in Source Code form that +alters or restricts the applicable version of this License or the recipients' rights +hereunder. You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered Software. +However, you may do so only on Your own behalf, and not on behalf of the Initial +Developer or any Contributor. You must make it absolutely clear that any such +warranty, support, indemnity or liability obligation is offered by You alone, and You +hereby agree to indemnify the Initial Developer and every Contributor for any +liability incurred by the Initial Developer or such Contributor as a result of +warranty, support, indemnity or liability terms You offer. + +3.5. Distribution of Executable Versions. +You may distribute the Executable form of the Covered Software under the terms of this +License or under the terms of a license of Your choice, which may contain terms +different from this License, provided that You are in compliance with the terms of +this License and that the license for the Executable form does not attempt to limit or +alter the recipient's rights in the Source Code form from the rights set forth in this +License. If You distribute the Covered Software in Executable form under a different +license, You must make it absolutely clear that any terms which differ from this +License are offered by You alone, not by the Initial Developer or Contributor. You +hereby agree to indemnify the Initial Developer and every Contributor for any +liability incurred by the Initial Developer or such Contributor as a result of any +such terms You offer. + +3.6. Larger Works. +You may create a Larger Work by combining Covered Software with other code not +governed by the terms of this License and distribute the Larger Work as a single +product. In such a case, You must make sure the requirements of this License are +fulfilled for the Covered Software. + +4. Versions of the License. + +4.1. New Versions. +Sun Microsystems, Inc. is the initial license steward and may publish revised and/or +new versions of this License from time to time. Each version will be given a +distinguishing version number. Except as provided in Section 4.3, no one other than +the license steward has the right to modify this License. + +4.2. Effect of New Versions. +You may always continue to use, distribute or otherwise make the Covered Software +available under the terms of the version of the License under which You originally +received the Covered Software. If the Initial Developer includes a notice in the +Original Software prohibiting it from being distributed or otherwise made available +under any subsequent version of the License, You must distribute and make the Covered +Software available under the terms of the version of the License under which You +originally received the Covered Software. Otherwise, You may also choose to use, +distribute or otherwise make the Covered Software available under the terms of any +subsequent version of the License published by the license steward. + +4.3. Modified Versions. +When You are an Initial Developer and You want to create a new license for Your +Original Software, You may create and use a modified version of this License if You: +(a) rename the license and remove any references to the name of the license steward +(except to note that the license differs from this License); and (b) otherwise make it +clear that the license contains terms which differ from this License. + +5. DISCLAIMER OF WARRANTY. + +COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR +PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY +RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF +ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES +AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED +HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. TERMINATION. + +6.1. This License and the rights granted hereunder will terminate automatically if You +fail to comply with terms herein and fail to cure such breach within 30 days of +becoming aware of the breach. Provisions which, by their nature, must remain in effect +beyond the termination of this License shall survive. + +6.2. If You assert a patent infringement claim (excluding declaratory judgment +actions) against Initial Developer or a Contributor (the Initial Developer or +Contributor against whom You assert such claim is referred to as "Participant") +alleging that the Participant Software (meaning the Contributor Version where the +Participant is a Contributor or the Original Software where the Participant is the +Initial Developer) directly or indirectly infringes any patent, then any and all +rights granted directly or indirectly to You by such Participant, the Initial +Developer (if the Initial Developer is not the Participant) and all Contributors under +Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant +terminate prospectively and automatically at the expiration of such 60 day notice +period, unless if within such 60 day period You withdraw Your claim with respect to +the Participant Software against such Participant either unilaterally or pursuant to a +written agreement with Participant. + +6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user +licenses that have been validly granted by You or any distributor hereunder prior to +termination (excluding licenses granted to You by any distributor) shall survive +termination. + +7. LIMITATION OF LIABILITY. + +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), +CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR +ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE +TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY +CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, +WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL +DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF +SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR +PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW +PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION +OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY +TO YOU. + +8. U.S. GOVERNMENT END USERS. + +The Covered Software is a "commercial item," as that term is defined in 48 C.F.R. +2.101 (Oct. 1995), consisting of "commercial computer software" (as that term is +defined at 48 C.F.R. § 252.227-7014(a)(1)) and "commercial computer software +documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent +with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all +U.S. Government End Users acquire Covered Software with only those rights set forth +herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other +FAR, DFAR, or other clause or provision that addresses Government rights in computer +software under this License. + +9. MISCELLANEOUS. + +This License represents the complete agreement concerning subject matter hereof. If +any provision of this License is held to be unenforceable, such provision shall be +reformed only to the extent necessary to make it enforceable. This License shall be +governed by the law of the jurisdiction specified in a notice contained within the +Original Software (except to the extent applicable law, if any, provides otherwise), +excluding such jurisdiction's conflict-of-law provisions. Any litigation relating to +this License shall be subject to the jurisdiction of the courts located in the +jurisdiction and venue specified in a notice contained within the Original Software, +with the losing party responsible for costs, including, without limitation, court +costs and reasonable attorneys' fees and expenses. The application of the United +Nations Convention on Contracts for the International Sale of Goods is expressly +excluded. Any law or regulation which provides that the language of a contract shall +be construed against the drafter shall not apply to this License. You agree that You +alone are responsible for compliance with the United States export administration +regulations (and the export control laws and regulation of any other countries) when +You use, distribute or otherwise make available any Covered Software. + +10. RESPONSIBILITY FOR CLAIMS. + +As between Initial Developer and the Contributors, each party is responsible for +claims and damages arising, directly or indirectly, out of its utilization of rights +under this License and You agree to work with Initial Developer and Contributors to +distribute such responsibility on an equitable basis. Nothing herein is intended or +shall be deemed to constitute any admission of liability. + +Source materials are available for download +at: https://mvnrepository.com/artifact/javax.activation/activation +JavaMail 1.5.6 +Attribution Statements +https://javaee.github.io/javamail/ + +Copyright Statements +Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved. + +License Text (http://www.spdx.org/licenses/CDDL-1.1.html) +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) +Version 1.1 +1. Definitions. + +1.1. "Contributor" means each individual or entity that creates or contributes to the +creation of Modifications. + +1.2. "Contributor Version" means the combination of the Original Software, prior +Modifications used by a Contributor (if any), and the Modifications made by that +particular Contributor. + +1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, or (c) +the combination of files containing Original Software with files containing +Modifications, in each case including portions thereof. + +1.4. "Executable" means the Covered Software in any form other than Source Code. + +1.5. "Initial Developer" means the individual or entity that first makes Original +Software available under this License. + +1.6. "Larger Work" means a work which combines Covered Software or portions thereof +with code not governed by the terms of this License. + +1.7. "License" means this document. + +1.8. "Licensable" means having the right to grant, to the maximum extent possible, +whether at the time of the initial grant or subsequently acquired, any and all of the +rights conveyed herein. + +1.9. "Modifications" means the Source Code and Executable form of any of the +following: + +A. Any file that results from an addition to, deletion from or modification of the +contents of a file containing Original Software or previous Modifications; + +B. Any new file that contains any part of the Original Software or previous +Modification; or + +C. Any new file that is contributed or otherwise made available under the terms of +this License. + +1.10. "Original Software" means the Source Code and Executable form of computer +software code that is originally released under this License. + +1.11. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, +including without limitation, method, process, and apparatus claims, in any patent +Licensable by grantor. + +1.12. "Source Code" means (a) the common form of computer software code in which +modifications are made and (b) associated documentation included in or with such code. + +1.13. "You" (or "Your") means an individual or a legal entity exercising rights under, +and complying with all of the terms of, this License. For legal entities, "You" +includes any entity which controls, is controlled by, or is under common control with +You. For purposes of this definition, "control" means (a) the power, direct or +indirect, to cause the direction or management of such entity, whether by contract or +otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares +or beneficial ownership of such entity. + +2. License Grants. + +2.1. The Initial Developer Grant. +Conditioned upon Your compliance with Section 3.1 below and subject to third party +intellectual property claims, the Initial Developer hereby grants You a world-wide, +royalty-free, non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) Licensable by +Initial Developer, to use, reproduce, modify, display, perform, sublicense and +distribute the Original Software (or portions thereof), with or without Modifications, +and/or as part of a Larger Work; and + +(b) under Patent Claims infringed by the making, using or selling of Original +Software, to make, have made, use, practice, sell, and offer for sale, and/or +otherwise dispose of the Original Software (or portions thereof). + +(c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial +Developer first distributes or otherwise makes the Original Software available to a +third party under the terms of this License. + +(d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code +that You delete from the Original Software, or (2) for infringements caused by: (i) +the modification of the Original Software, or (ii) the combination of the Original +Software with other software or devices. + +2.2. Contributor Grant. +Conditioned upon Your compliance with Section 3.1 below and subject to third party +intellectual property claims, each Contributor hereby grants You a world-wide, +royalty-free, non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) Licensable by +Contributor to use, reproduce, modify, display, perform, sublicense and distribute the +Modifications created by such Contributor (or portions thereof), either on an +unmodified basis, with other Modifications, as Covered Software and/or as part of a +Larger Work; and + +(b) under Patent Claims infringed by the making, using, or selling of Modifications +made by that Contributor either alone and/or in combination with its Contributor +Version (or portions of such combination), to make, use, sell, offer for sale, have +made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or +portions thereof); and (2) the combination of Modifications made by that Contributor +with its Contributor Version (or portions of such combination). + +(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date +Contributor first distributes or otherwise makes the Modifications available to a +third party. + +(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any +code that Contributor has deleted from the Contributor Version; (2) for infringements +caused by: (i) third party modifications of Contributor Version, or (ii) the +combination of Modifications made by that Contributor with other software (except as +part of the Contributor Version) or other devices; or (3) under Patent Claims +infringed by Covered Software in the absence of Modifications made by that +Contributor. + +3. Distribution Obligations. + +3.1. Availability of Source Code. +Any Covered Software that You distribute or otherwise make available in Executable +form must also be made available in Source Code form and that Source Code form must be +distributed only under the terms of this License. You must include a copy of this +License with every copy of the Source Code form of the Covered Software You distribute +or otherwise make available. You must inform recipients of any such Covered Software +in Executable form as to how they can obtain such Covered Software in Source Code form +in a reasonable manner on or through a medium customarily used for software exchange. + +3.2. Modifications. +The Modifications that You create or to which You contribute are governed by the terms +of this License. You represent that You believe Your Modifications are Your original +creation(s) and/or You have sufficient rights to grant the rights conveyed by this +License. + +3.3. Required Notices. +You must include a notice in each of Your Modifications that identifies You as the +Contributor of the Modification. You may not remove or alter any copyright, patent or +trademark notices contained within the Covered Software, or any notices of licensing +or any descriptive text giving attribution to any Contributor or the Initial +Developer. + +3.4. Application of Additional Terms. +You may not offer or impose any terms on any Covered Software in Source Code form that +alters or restricts the applicable version of this License or the recipients' rights +hereunder. You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered Software. +However, you may do so only on Your own behalf, and not on behalf of the Initial +Developer or any Contributor. You must make it absolutely clear that any such +warranty, support, indemnity or liability obligation is offered by You alone, and You +hereby agree to indemnify the Initial Developer and every Contributor for any +liability incurred by the Initial Developer or such Contributor as a result of +warranty, support, indemnity or liability terms You offer. + +3.5. Distribution of Executable Versions. +You may distribute the Executable form of the Covered Software under the terms of this +License or under the terms of a license of Your choice, which may contain terms +different from this License, provided that You are in compliance with the terms of +this License and that the license for the Executable form does not attempt to limit or +alter the recipient's rights in the Source Code form from the rights set forth in this +License. If You distribute the Covered Software in Executable form under a different +license, You must make it absolutely clear that any terms which differ from this +License are offered by You alone, not by the Initial Developer or Contributor. You +hereby agree to indemnify the Initial Developer and every Contributor for any +liability incurred by the Initial Developer or such Contributor as a result of any +such terms You offer. + +3.6. Larger Works. +You may create a Larger Work by combining Covered Software with other code not +governed by the terms of this License and distribute the Larger Work as a single +product. In such a case, You must make sure the requirements of this License are +fulfilled for the Covered Software. + +4. Versions of the License. + +4.1. New Versions. +Oracle is the initial license steward and may publish revised and/or new versions of +this License from time to time. Each version will be given a distinguishing version +number. Except as provided in Section 4.3, no one other than the license steward has +the right to modify this License. + +4.2. Effect of New Versions. +You may always continue to use, distribute or otherwise make the Covered Software +available under the terms of the version of the License under which You originally +received the Covered Software. If the Initial Developer includes a notice in the +Original Software prohibiting it from being distributed or otherwise made available +under any subsequent version of the License, You must distribute and make the Covered +Software available under the terms of the version of the License under which You +originally received the Covered Software. Otherwise, You may also choose to use, +distribute or otherwise make the Covered Software available under the terms of any +subsequent version of the License published by the license steward. + +4.3. Modified Versions. +When You are an Initial Developer and You want to create a new license for Your +Original Software, You may create and use a modified version of this License if You: +(a) rename the license and remove any references to the name of the license steward +(except to note that the license differs from this License); and (b) otherwise make it +clear that the license contains terms which differ from this License. + +5. DISCLAIMER OF WARRANTY. +COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR +PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY +RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF +ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES +AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED +HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. TERMINATION. + +6.1. This License and the rights granted hereunder will terminate automatically if You +fail to comply with terms herein and fail to cure such breach within 30 days of +becoming aware of the breach. Provisions which, by their nature, must remain in effect +beyond the termination of this License shall survive. + +6.2. If You assert a patent infringement claim (excluding declaratory judgment +actions) against Initial Developer or a Contributor (the Initial Developer or +Contributor against whom You assert such claim is referred to as "Participant") +alleging that the Participant Software (meaning the Contributor Version where the +Participant is a Contributor or the Original Software where the Participant is the +Initial Developer) directly or indirectly infringes any patent, then any and all +rights granted directly or indirectly to You by such Participant, the Initial +Developer (if the Initial Developer is not the Participant) and all Contributors under +Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant +terminate prospectively and automatically at the expiration of such 60 day notice +period, unless if within such 60 day period You withdraw Your claim with respect to +the Participant Software against such Participant either unilaterally or pursuant to a +written agreement with Participant. + +6.3. If You assert a patent infringement claim against Participant alleging that the +Participant Software directly or indirectly infringes any patent where such claim is +resolved (such as by license or settlement) prior to the initiation of patent +infringement litigation, then the reasonable value of the licenses granted by such +Participant under Sections 2.1 or 2.2 shall be taken into account in determining the +amount or value of any payment or license. + +6.4. In the event of termination under Sections 6.1 or 6.2 above, all end user +licenses that have been validly granted by You or any distributor hereunder prior to +termination (excluding licenses granted to You by any distributor) shall survive +termination. + +7. LIMITATION OF LIABILITY. + +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), +CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR +ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE +TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY +CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, +COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, +EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS +LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY +RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH +LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL +OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +8. U.S. GOVERNMENT END USERS. + +The Covered Software is a "commercial item," as that term is defined in 48 C.F.R. +2.101 (Oct. 1995), consisting of "commercial computer software" (as that term is +defined at 48 C.F.R. § 252.227-7014(a)(1)) and "commercial computer software +documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent +with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all +U.S. Government End Users acquire Covered Software with only those rights set forth +herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other +FAR, DFAR, or other clause or provision that addresses Government rights in computer +software under this License. + +9. MISCELLANEOUS. + +This License represents the complete agreement concerning subject matter hereof. If +any provision of this License is held to be unenforceable, such provision shall be +reformed only to the extent necessary to make it enforceable. This License shall be +governed by the law of the jurisdiction specified in a notice contained within the +Original Software (except to the extent applicable law, if any, provides otherwise), +excluding such jurisdiction's conflict-of-law provisions. Any litigation relating to +this License shall be subject to the jurisdiction of the courts located in the +jurisdiction and venue specified in a notice contained within the Original Software, +with the losing party responsible for costs, including, without limitation, court +costs and reasonable attorneys' fees and expenses. The application of the United +Nations Convention on Contracts for the International Sale of Goods is expressly +excluded. Any law or regulation which provides that the language of a contract shall +be construed against the drafter shall not apply to this License. You agree that You +alone are responsible for compliance with the United States export administration +regulations (and the export control laws and regulation of any other countries) when +You use, distribute or otherwise make available any Covered Software. + +10. RESPONSIBILITY FOR CLAIMS. + +As between Initial Developer and the Contributors, each party is responsible for +claims and damages arising, directly or indirectly, out of its utilization of rights +under this License and You agree to work with Initial Developer and Contributors to +distribute such responsibility on an equitable basis. Nothing herein is intended or +shall be deemed to constitute any admission of liability. + +NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) +The code released under the CDDL shall be governed by the laws of the State of +California (excluding conflict-of-law provisions). Any litigation relating to this +License shall be subject to the jurisdiction of the Federal Courts of the Northern +District of California and the state courts of the State of California, with venue +lying in Santa Clara County, California. + +Source materials are available for download +at: https://mvnrepository.com/artifact/com.sun.mail/javax.mail +JavaMail 1.6.0 +Attribution Statements +https://javaee.github.io/javamail/ + +Copyright Statements +Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved. + +License Text (http://www.spdx.org/licenses/CDDL-1.1.html) + +Source materials are available for download +at: https://mvnrepository.com/artifact/com.sun.mail/javax.mail +Javax.transaction API 1.2 +Attribution Statements +https://github.com/javaee/jta-spec + +Copyright Statements +Copyright 2017 Oracle and/or its affiliates. All rights reserved. + +License Text (https://spdx.org/licenses/CDDL-1.1.html) + +Source materials are available for download +at: http://mvnrepository.com/artifact/javax.transaction/javax.transaction-api +javax.ws.rs-api (JAX-RS API) 2.0.1 +Attribution Statements +https://github.com/jax-rs/api + +Copyright Statements +Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved. + +License Text (http://www.spdx.org/licenses/CDDL-1.1.html) + +Source materials are available for download at: https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs- +api +javax.ws.rs-api (JAX-RS API) 2.1 +Attribution Statements +https://github.com/jax-rs/api + +Copyright Statements +Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved. + +License Text (http://www.spdx.org/licenses/CDDL-1.1.html) + +Source materials are available for download at: https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs- +api +JAX RS Provider For JSON Content Type (jackson-jaxrs) 1.9.13 +Attribution Statements +http://jackson.codehaus.org + +Copyright Statements +Copyright (c) FasterXML. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download +at: http://mvnrepository.com/artifact/org.codehaus.jackson/jackson-jaxrs/1.9.13 +JDOM 1.0 +Attribution Statements +http://www.jdom.org + +Copyright Statements +Copyright (C) 2000-2012 Jason Hunter & Brett McLaughlin. All rights reserved. + +License Text (https://github.com/hunterhacker/jdom/blob/master/LICENSE.txt) +Copyright (C) 2000-2012 Jason Hunter & Brett McLaughlin. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the disclaimer that follows + these conditions in the documentation and/or other materials + provided with the distribution. + + 3. The name "JDOM" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact . + + 4. Products derived from this software may not be called "JDOM", nor + may "JDOM" appear in their name, without prior written permission + from the JDOM Project Management . + + In addition, we request (but do not require) that you include in the + end-user documentation provided with the redistribution and/or in the + software itself an acknowledgement equivalent to the following: + "This product includes software developed by the + JDOM Project (http://www.jdom.org/)." + Alternatively, the acknowledgment may be graphical using the logos + available at http://www.jdom.org/images/logos. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + + This software consists of voluntary contributions made by many + individuals on behalf of the JDOM Project and was originally + created by Jason Hunter and + Brett McLaughlin . For more information + on the JDOM Project, please see . + +Source materials are available for download at: https://github.com/hunterhacker/jdom/ +JDOM 2.0.5 +Attribution Statements +http://www.jdom.org + +Copyright Statements +Copyright (C) 2000-2012 Jason Hunter & Brett McLaughlin. All rights reserved. + +License Text (https://github.com/hunterhacker/jdom/blob/master/LICENSE.txt) +Copyright (C) 2000-2012 Jason Hunter & Brett McLaughlin. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the disclaimer that follows + these conditions in the documentation and/or other materials + provided with the distribution. + + 3. The name "JDOM" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact . + + 4. Products derived from this software may not be called "JDOM", nor + may "JDOM" appear in their name, without prior written permission + from the JDOM Project Management . + + In addition, we request (but do not require) that you include in the + end-user documentation provided with the redistribution and/or in the + software itself an acknowledgement equivalent to the following: + "This product includes software developed by the + JDOM Project (http://www.jdom.org/)." + Alternatively, the acknowledgment may be graphical using the logos + available at http://www.jdom.org/images/logos. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + + This software consists of voluntary contributions made by many + individuals on behalf of the JDOM Project and was originally + created by Jason Hunter and + Brett McLaughlin . For more information + on the JDOM Project, please see . + +Source materials are available for download at: https://github.com/hunterhacker/jdom/ +JDOM 2.0.6 +Attribution Statements +http://www.jdom.org + +Copyright Statements +Copyright (C) 2000-2012 Jason Hunter & Brett McLaughlin. All rights reserved. + +License Text (https://github.com/hunterhacker/jdom/blob/master/LICENSE.txt) +Copyright (C) 2000-2012 Jason Hunter & Brett McLaughlin. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the disclaimer that follows + these conditions in the documentation and/or other materials + provided with the distribution. + + 3. The name "JDOM" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact . + + 4. Products derived from this software may not be called "JDOM", nor + may "JDOM" appear in their name, without prior written permission + from the JDOM Project Management . + + In addition, we request (but do not require) that you include in the + end-user documentation provided with the redistribution and/or in the + software itself an acknowledgement equivalent to the following: + "This product includes software developed by the + JDOM Project (http://www.jdom.org/)." + Alternatively, the acknowledgment may be graphical using the logos + available at http://www.jdom.org/images/logos. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + + This software consists of voluntary contributions made by many + individuals on behalf of the JDOM Project and was originally + created by Jason Hunter and + Brett McLaughlin . For more information + on the JDOM Project, please see . + +Source materials are available for download at: https://github.com/hunterhacker/jdom/ +Jersey 1.17 +Attribution Statements +https://jersey.java.net/ + +%% The following software may be included in this product: ASM + Use of any of this software is governed by the terms of the license below: + +Copyright (c) 2000-2005 INRIA, France Telecom +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +%% The following software may be included in this product: Jettison + Use of any of this software is governed by the terms of the license below: + + +Copyright 2006 Envoi Solutions LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Copyright Statements +Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + +License Text (http://www.spdx.org/licenses/CDDL-1.1.html) + +Source materials are available for download at: https://github.com/jersey/jersey/ +Jersey 1.9 +Attribution Statements +https://jersey.java.net/ + +%% The following software may be included in this product: ASM + Use of any of this software is governed by the terms of the license below: + +Copyright (c) 2000-2005 INRIA, France Telecom +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +%% The following software may be included in this product: Jettison + Use of any of this software is governed by the terms of the license below: + + +Copyright 2006 Envoi Solutions LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Copyright Statements +Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + +License Text (http://www.spdx.org/licenses/CDDL-1.1.html) + +Source materials are available for download at: https://github.com/jersey/jersey/ +JQuery 2.0.0 +Attribution Statements +https://code.jquery.com/jquery/ + +Copyright JS Foundation and other contributors, https://js.foundation/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/jquery + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. + +Copyright Statements +Copyright (c) 2009-2017 John Resig, jQuery Foundation, Inc. + +License Text (https://spdx.org/licenses/MIT.html) +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/jquery/jquery +JSON 20080701 +Attribution Statements +http://www.json.org/ + +Copyright Statements +Copyright (c) 2002 JSON.org + +License Text (http://spdx.org/licenses/MIT) +Copyright (c) 2002 JSON.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download +at: https://mvnrepository.com/artifact/org.json/json/20080701 +JUnit 4.11 +Attribution Statements +http://junit.org + +The JUnit depends on Java Hamcrest (http://hamcrest.org/JavaHamcrest/). + +Copyright Statements +Copyright (c) 2002-2015 JUnit. All Rights Reserved. + +License Text (http://spdx.org/licenses/EPL-1.0) + +Source materials are available for download at: https://github.com/junit-team/junit4 +JUnit 4.12 +Attribution Statements +http://junit.org + +The JUnit depends on Java Hamcrest (http://hamcrest.org/JavaHamcrest/). + +Copyright Statements +Copyright (c) 2002-2015 JUnit. All Rights Reserved. + +License Text (http://spdx.org/licenses/EPL-1.0) + +Source materials are available for download at: https://github.com/junit-team/junit4 +Lodash 4.17.4 +Attribution Statements +https://lodash.com/ + +Based on Underscore.js, copyright Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/lodash/lodash + +Copyright and related rights for sample code are waived via CC0. Sample +code is defined as all source code displayed within the prose of the +documentation. + +CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +Files located in the node_modules and vendor directories are externally +maintained libraries used by this software which have their own +licenses; we recommend you read them, as their terms may differ from the +terms above. + +Copyright Statements +Copyright JS Foundation and other contributors + +License Text (http://spdx.org/licenses/MIT) +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/lodash/lodash +Logback 1.0.9 +Attribution Statements +http://logback.qos.ch + +Copyright Statements +Copyright (C) 1999-2015, QOS.ch. All rights reserved. + +License Text (http://spdx.org/licenses/EPL-1.0) + +Source materials are available for download at: https://github.com/qos-ch/logback +Logback 1.2.3 +Attribution Statements +http://logback.qos.ch + +Copyright Statements +Copyright (C) 1999-2015, QOS.ch. All rights reserved. + +License Text (http://spdx.org/licenses/EPL-1.0) + +Source materials are available for download at: https://github.com/qos-ch/logback +Lunr 0.5.11 +Attribution Statements +https://lunrjs.com/ + +Copyright Statements +Copyright (C) 2015 Oliver Nightingale + +License Text (http://spdx.org/licenses/MIT) +Copyright (C) 2015 Oliver Nightingale + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/olivernn/lunr.js +MapR 5.1.0 +Attribution Statements +https://mapr.com/ + +Copyright Statements +MapR Technologies, Inc. + +License Text () +Made available under commercial license + +MapR Hadoop 2.7.0-mapr-1602 +Attribution Statements +https://mapr.com/products/apache-hadoop/ + +Copyright Statements +(c) MapR Technologies, Inc. All Rights Reserved + +License Text (http://spdx.org/licenses/Apache-2.0) + +MIME Streaming Extension (Mimepull) 1.9.4 +Attribution Statements +http://mimepull.java.net + +Copyright Statements +Copyright (c) YYYY Oracle and/or its affiliates. All rights reserved. + +License Text (http://www.spdx.org/licenses/CDDL-1.1.html) + +Source materials are available for download at: https://github.com/javaee/metro-mimepull +Mockito 1.10.19 +Attribution Statements +http://site.mockito.org/ + +Copyright Statements +Copyright (c) 2007 Mockito contributors + +License Text (https://spdx.org/licenses/MIT.html) +The MIT License + +Copyright (c) 2007 Mockito contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/mockito/mockito +Moment.js 2.17.0 +Attribution Statements +http://momentjs.com/ + +Copyright Statements +Copyright (c) JS Foundation and other contributors + +License Text (http://spdx.org/licenses/MIT) +Copyright (c) JS Foundation and other contributors + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/moment/moment +multipart-stream 2.0.1 +Copyright Statements +Copyright (C) 2014, Hendrik Cech + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2014 Hendrik Cech + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/hendrikcech/multipart-stream +MXP1: Xml Pull Parser 3rd Edition (XPP3) 1.1.4c +Attribution Statements +http://www.extreme.indiana.edu/xgws/xsoap/xpp/mxp1/ + +Copyright Statements +Copyright (c) 2002 Extreme! Lab, Indiana University. All rights reserved. + +License Text (https://spdx.org/licenses/Apache-1.1.html) +Copyright (c) 2002 Extreme! Lab, Indiana University. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list +of conditions and the following disclaimer in the documentation and/or other materials +provided with the distribution. + +3. The end-user documentation included with the redistribution, if any, must include +the following acknowledgment: + "This product includes software developed by the Indiana University Extreme! Lab +(http://www.extreme.indiana.edu/)." +Alternately, this acknowledgment may appear in the software itself, if and wherever +such third-party acknowledgments normally appear. + +4. The names "Indiana Univeristy" and "Indiana Univeristy Extreme! Lab" must not be +used to endorse or promote products derived from this software without prior written +permission. For written permission, please contact http://www.extreme.indiana.edu/. + +5. Products derived from this software may not use "Indiana Univeristy" name nor may +"Indiana Univeristy" appear in their name, without prior written permission of the +Indiana University. + +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS, COPYRIGHT HOLDERS OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: http://www.extreme.indiana.edu/dist/java- +repository/xpp3/distributions/ +ng2-bootstrap 1.1.16-11 +Attribution Statements +http://valor-software.com/ngx-bootstrap/#/ + +Copyright Statements +Copyright (c) 2015-2017 Valor Software +Copyright (c) 2015-2017 Dmitriy Shekhovtsov + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2015-2017 Valor Software +Copyright (c) 2015-2017 Dmitriy Shekhovtsov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Source materials are available for download at: https://github.com/valor-software/ng2-bootstrap +ngx-bootstrap 1.1.6 +Attribution Statements +http://valor-software.com/ngx-bootstrap/#/ + +Copyright Statements +Copyright (c) 2015-2017 Valor Software +Copyright (c) 2015-2017 Dmitriy Shekhovtsov + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2015-2017 Valor Software +Copyright (c) 2015-2017 Dmitriy Shekhovtsov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Source materials are available for download at: https://github.com/valor-software/ngx-bootstrap +ngx-bootstrap 1.6.6 +Attribution Statements +http://valor-software.com/ngx-bootstrap/#/ + +Copyright Statements +Copyright (c) 2015-2017 Valor Software +Copyright (c) 2015-2017 Dmitriy Shekhovtsov + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2015-2017 Valor Software +Copyright (c) 2015-2017 Dmitriy Shekhovtsov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Source materials are available for download at: https://github.com/valor-software/ngx-bootstrap +OkHttp 3.8.1 +Attribution Statements +http://square.github.io/okhttp/ + +Copyright Statements +Copyright 2016 Square, Inc. + +License Text (http://www.apache.org/licenses/LICENSE-2.0.txt) + +Source materials are available for download +at: https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp +OkHttp 3.9.0 +Attribution Statements +http://square.github.io/okhttp/ + +Copyright Statements +Copyright 2016 Square, Inc. + +License Text (http://www.apache.org/licenses/LICENSE-2.0.txt) + +Source materials are available for download +at: https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp +okhttp-digest 1.14 +Attribution Statements +https://github.com/rburgst/okhttp-digest/ + +The following NOTICEs are pertain to software distributed with this project. +Apache HttpComponents HttpClient +Copyright 1999-2011 The Apache Software Foundation + +Copyright Statements +rburgst http://rainer.4950.net + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/rburgst/okhttp-digest/ +okhttp-digest 1.15 +Attribution Statements +https://github.com/rburgst/okhttp-digest/ + +The following NOTICEs are pertain to software distributed with this project. +Apache HttpComponents HttpClient +Copyright 1999-2011 The Apache Software Foundation + +Copyright Statements +rburgst http://rainer.4950.net + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/rburgst/okhttp-digest/ +Okio 1.13 +Attribution Statements +http://square.github.io/okio/1.x/okio/ + +Copyright Statements +Copyright (c) 2017. All Rights Reserved. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download +at: https://mvnrepository.com/artifact/com.squareup.okio/okio +opencsv 2.3 +Attribution Statements +http://opencsv.sf.net + +Copyright Statements +Copyright (c) 2017. All rights reserved. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://sourceforge.net/p/opencsv/source/ci/master/tree/ +opencsv 2.4 +Attribution Statements +http://opencsv.sf.net + +Copyright Statements +Copyright (c) 2017. All rights reserved. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://sourceforge.net/p/opencsv/source/ci/master/tree/ +Protocol Buffers (protobuf) 2.5.0 +Attribution Statements +https://developers.google.com/protocol-buffers/ + +This license applies to all parts of Protocol Buffers except the following: + + - Atomicops support for generic gcc, located in + src/google/protobuf/stubs/atomicops_internals_generic_gcc.h. + This file is copyrighted by Red Hat Inc. + + - Atomicops support for AIX/POWER, located in + src/google/protobuf/stubs/atomicops_internals_power.h. + This file is copyrighted by Bloomberg Finance LP. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +Copyright Statements +Copyright 2014, Google Inc. All rights reserved. + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Copyright 2014, Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: https://github.com/google/protobuf +qs 6.5.0 +Attribution Statements +The complete list of contributors can be found at: +https://github.com/hapijs/qs/graphs/contributors + +Copyright Statements +Copyright (c) 2014 Nathan LaFreniere and other contributors. All rights reserved. + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Copyright (c) 2014 Nathan LaFreniere and other contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * The names of any contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +qs 6.5.1 +Attribution Statements +https://github.com/ljharb/qs +The complete list of contributors can be found at: +https://github.com/hapijs/qs/graphs/contributors + +Copyright Statements +Copyright (c) 2014 Nathan LaFreniere and other contributors. +All rights reserved. + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Copyright (c) 2014 Nathan LaFreniere and other contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * The names of any contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: https://github.com/ljharb/qs +RDF4J (Sesame Runtime) 2.2.2 +Attribution Statements +http://rdf4j.org/ + +Copyright Statements +Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. +Copyright Aduna (http://www.aduna-software.com/) 2001-2013 +All rights reserved. + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Eclipse Distribution License - v 1.0 + +Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. +Copyright Aduna (http://www.aduna-software.com/) 2001-2013 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list +of conditions and the following disclaimer in the documentation and/or other materials +provided with the distribution. + +* Neither the name of the Eclipse Foundation, Inc. nor the names of its contributors +may be used to endorse or promote products derived from this software without specific +prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +Source materials are available for download at: https://github.com/eclipse/rdf4j +RDF4J (Sesame Runtime) 2.8.10 +Attribution Statements +http://rdf4j.org/ + +Copyright Statements +Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. +Copyright Aduna (http://www.aduna-software.com/) 2001-2013 +All rights reserved. + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Eclipse Distribution License - v 1.0 + +Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. +Copyright Aduna (http://www.aduna-software.com/) 2001-2013 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list +of conditions and the following disclaimer in the documentation and/or other materials +provided with the distribution. + +* Neither the name of the Eclipse Foundation, Inc. nor the names of its contributors +may be used to endorse or promote products derived from this software without specific +prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +Source materials are available for download at: https://github.com/eclipse/rdf4j +RxJS 5.1.0 +Attribution Statements +http://reactivex.io/rxjs/ + +author.name: Ben Lesh + +Copyright Statements +Copyright (c) 2015-2017 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/ReactiveX/RxJS +RxJS 5.4.3 +Attribution Statements +http://reactivex.io/rxjs/ + +author.name: Ben Lesh + +Copyright Statements +Copyright (c) 2015-2017 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/ReactiveX/RxJS +Saxon-HE 9.7.0-7 +Attribution Statements +http://www.saxonica.com/ + +Copyright Statements +Copyright (C) 2017, Saxonica, John Lumley, Debbie Lockett, Michael Kay, O'Neil +Delpratt + +License Text (https://spdx.org/licenses/MPL-2.0.html) +Mozilla Public License +Version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the creation +of, or owns Covered Software. +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a +Contributor and that particular Contributor's Contribution. +1.3. "Contribution" + + means Covered Software of a particular Contributor. +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the notice in +Exhibit A, the Executable Form of such Source Code Form, and Modifications of such +Source Code Form, in each case including portions thereof. +1.5. "Incompatible With Secondary Licenses" + + means + + that the initial Contributor has attached the notice described in Exhibit B to +the Covered Software; or + + that the Covered Software was made available under the terms of version 1.1 or +earlier of the License, but not also under the terms of a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a separate +file or files, that is not Covered Software. +1.8. "License" + + means this document. +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether at the +time of the initial grant or subsequently, any and all of the rights conveyed by this +License. +1.10. "Modifications" + + means any of the following: + + any file in Source Code Form that results from an addition to, deletion from, +or modification of the contents of Covered Software; or + + any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, process, and +apparatus claims, in any patent Licensable by such Contributor that would be +infringed, but for the grant of the License, by the making, using, selling, offering +for sale, having made, import, or transfer of either its Contributions or its +Contributor Version. +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser General +Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or +any later versions of those licenses. +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this License. For +legal entities, "You" includes any entity that controls, is controlled by, or is under +common control with You. For purposes of this definition, "control" means (a) the +power, direct or indirect, to cause the direction or management of such entity, +whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of +the outstanding shares or beneficial ownership of such entity. + +2. License Grants and Conditions +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: + + under intellectual property rights (other than patent or trademark) Licensable by +such Contributor to use, reproduce, make available, modify, display, perform, +distribute, and otherwise exploit its Contributions, either on an unmodified basis, +with Modifications, or as part of a Larger Work; and + + under Patent Claims of such Contributor to make, use, sell, offer for sale, have +made, import, and otherwise transfer either its Contributions or its Contributor +Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution become effective +for each Contribution on the date the Contributor first distributes such Contribution. +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under this License. +No additional rights or licenses will be implied from the distribution or licensing of +Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent +license is granted by a Contributor: + + for any code that a Contributor has removed from Covered Software; or + + for infringements caused by: (i) Your and any other third party's modifications of +Covered Software, or (ii) the combination of its Contributions with other software +(except as part of its Contributor Version); or + + under Patent Claims infringed by Covered Software in the absence of its +Contributions. + +This License does not grant any rights in the trademarks, service marks, or logos of +any Contributor (except as may be necessary to comply with the notice requirements in +Section 3.4). +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to distribute the +Covered Software under a subsequent version of this License (see Section 10.2) or +under the terms of a Secondary License (if permitted under the terms of Section 3.3). +2.5. Representation + +Each Contributor represents that the Contributor believes its Contributions are its +original creation(s) or it has sufficient rights to grant the rights to its +Contributions conveyed by this License. +2.6. Fair Use + +This License is not intended to limit any rights You have under applicable copyright +doctrines of fair use, fair dealing, or other equivalents. +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. +3. Responsibilities +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any Modifications +that You create or to which You contribute, must be under the terms of this License. +You must inform recipients that the Source Code Form of the Covered Software is +governed by the terms of this License, and how they can obtain a copy of this License. +You may not attempt to alter or restrict the recipients' rights in the Source Code +Form. +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + + such Covered Software must also be made available in Source Code Form, as +described in Section 3.1, and You must inform recipients of the Executable Form how +they can obtain a copy of such Source Code Form by reasonable means in a timely +manner, at a charge no more than the cost of distribution to the recipient; and + + You may distribute such Executable Form under the terms of this License, or +sublicense it under different terms, provided that the license for the Executable Form +does not attempt to limit or alter the recipients' rights in the Source Code Form +under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, provided that +You also comply with the requirements of this License for the Covered Software. If the +Larger Work is a combination of Covered Software with a work governed by one or more +Secondary Licenses, and the Covered Software is not Incompatible With Secondary +Licenses, this License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of the Larger Work +may, at their option, further distribute the Covered Software under the terms of +either this License or such Secondary License(s). +3.4. Notices + +You may not remove or alter the substance of any license notices (including copyright +notices, patent notices, disclaimers of warranty, or limitations of liability) +contained within the Source Code Form of the Covered Software, except that You may +alter any license notices to the extent required to remedy known factual inaccuracies. +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, indemnity or +liability obligations to one or more recipients of Covered Software. However, You may +do so only on Your own behalf, and not on behalf of any Contributor. You must make it +absolutely clear that any such warranty, support, indemnity, or liability obligation +is offered by You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, indemnity or +liability terms You offer. You may include additional disclaimers of warranty and +limitations of liability specific to any jurisdiction. +4. Inability to Comply Due to Statute or Regulation + +If it is impossible for You to comply with any of the terms of this License with +respect to some or all of the Covered Software due to statute, judicial order, or +regulation then You must: (a) comply with the terms of this License to the maximum +extent possible; and (b) describe the limitations and the code they affect. Such +description must be placed in a text file included with all distributions of the +Covered Software under this License. Except to the extent prohibited by statute or +regulation, such description must be sufficiently detailed for a recipient of ordinary +skill to be able to understand it. +5. Termination + +5.1. The rights granted under this License will terminate automatically if You fail to +comply with any of its terms. However, if You become compliant, then the rights +granted under this License from a particular Contributor are reinstated (a) +provisionally, unless and until such Contributor explicitly and finally terminates +Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of +the non-compliance by some reasonable means prior to 60 days after You have come back +into compliance. Moreover, Your grants from a particular Contributor are reinstated on +an ongoing basis if such Contributor notifies You of the non-compliance by some +reasonable means, this is the first time You have received notice of non-compliance +with this License from such Contributor, and You become compliant prior to 30 days +after Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent infringement +claim (excluding declaratory judgment actions, counter-claims, and cross-claims) +alleging that a Contributor Version directly or indirectly infringes any patent, then +the rights granted to You by any and all Contributors for the Covered Software under +Section 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license +agreements (excluding distributors and resellers) which have been validly granted by +You or Your distributors under this License prior to termination shall survive +termination. +6. Disclaimer of Warranty + +Covered Software is provided under this License on an "as is" basis, without warranty +of any kind, either expressed, implied, or statutory, including, without limitation, +warranties that the Covered Software is free of defects, merchantable, fit for a +particular purpose or non-infringing. The entire risk as to the quality and +performance of the Covered Software is with You. Should any Covered Software prove +defective in any respect, You (not any Contributor) assume the cost of any necessary +servicing, repair, or correction. This disclaimer of warranty constitutes an essential +part of this License. No use of any Covered Software is authorized under this License +except under this disclaimer. +7. Limitation of Liability + +Under no circumstances and under no legal theory, whether tort (including negligence), +contract, or otherwise, shall any Contributor, or anyone who distributes Covered +Software as permitted above, be liable to You for any direct, indirect, special, +incidental, or consequential damages of any character including, without limitation, +damages for lost profits, loss of goodwill, work stoppage, computer failure or +malfunction, or any and all other commercial damages or losses, even if such party +shall have been informed of the possibility of such damages. This limitation of +liability shall not apply to liability for death or personal injury resulting from +such party's negligence to the extent applicable law prohibits such limitation. Some +jurisdictions do not allow the exclusion or limitation of incidental or consequential +damages, so this exclusion and limitation may not apply to You. +8. Litigation + +Any litigation relating to this License may be brought only in the courts of a +jurisdiction where the defendant maintains its principal place of business and such +litigation shall be governed by laws of that jurisdiction, without reference to its +conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to +bring cross-claims or counter-claims. +9. Miscellaneous + +This License represents the complete agreement concerning the subject matter hereof. +If any provision of this License is held to be unenforceable, such provision shall be +reformed only to the extent necessary to make it enforceable. Any law or regulation +which provides that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. +10. Versions of the License +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one +other than the license steward has the right to modify or publish new versions of this +License. Each version will be given a distinguishing version number. +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version of the License +under which You originally received the Covered Software, or under the terms of any +subsequent version published by the license steward. +10.3. Modified Versions + +If you create software not governed by this License, and you want to create a new +license for such software, you may create and use a modified version of this License +if you rename the license and remove any references to the name of the license steward +(except to note that such modified license differs from this License). +10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses + +If You choose to distribute Source Code Form that is Incompatible With Secondary +Licenses under the terms of this version of the License, the notice described in +Exhibit B of this License must be attached. +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not distributed with this file, You can obtain one at +http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, then You +may include the notice in a location (such as a LICENSE file in a relevant directory) +where a recipient would be likely to look for such a notice. + +You may add additional accurate notices of copyright ownership. +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible With Secondary Licenses", as defined by the +Mozilla Public License, v. 2.0. + +Source materials are available for download at: https://sourceforge.net/projects/saxon/files/Saxon-HE/ +Sizzle +Attribution Statements +http://sizzlejs.com + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/sizzle + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. + +Copyright Statements +Copyright JS Foundation and other contributors, https://js.foundation/ + +License Text (https://spdx.org/licenses/MIT.html) +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/jquery/sizzle/tree/master +SLF4J API 1.7.12 +Attribution Statements +http://www.slf4j.org + +Copyright Statements +Copyright (c) 2004-2007 QOS.ch. All rights reserved. + +License Text (http://spdx.org/licenses/MIT) +Copyright (c) 2004-2007 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/qos-ch/slf4j/tree/master/slf4j-api +SLF4J API 1.7.2 +Attribution Statements +http://www.slf4j.org + +Copyright Statements +Copyright (c) 2004-2007 QOS.ch. All rights reserved. + +License Text (http://spdx.org/licenses/MIT) +Copyright (c) 2004-2007 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/qos-ch/slf4j/tree/master/slf4j-api +SLF4J API 1.7.25 +Attribution Statements +http://www.slf4j.org + +Copyright Statements +Copyright (c) 2004-2007 QOS.ch. All rights reserved. + +License Text (http://spdx.org/licenses/MIT) +Copyright (c) 2004-2007 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/qos-ch/slf4j/tree/master/slf4j-api +SLF4J API 1.7.5 +Attribution Statements +http://www.slf4j.org + +Copyright Statements +Copyright (c) 2004-2007 QOS.ch. All rights reserved. + +License Text (http://spdx.org/licenses/MIT) +Copyright (c) 2004-2007 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/qos-ch/slf4j/tree/master/slf4j-api +SLF4J Log4j12 1.7.5 +Attribution Statements +https://www.slf4j.org/api/org/slf4j/impl/Log4jLoggerAdapter.html + +Copyright Statements +Copyright (c) 2004-2007 QOS.ch. All rights reserved. + +License Text (http://spdx.org/licenses/MIT) +Copyright (c) 2004-2007 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/qos-ch/slf4j/tree/master/slf4j-log4j12 +Sport Ontology 2.3 +Attribution Statements +https://www.bbc.co.uk/ontologies/sport + +Copyright Statements +Copyright (c) 2017 BBC. + +License Text (https://spdx.org/licenses/CC-BY-4.0.html) +Creative Commons Attribution 4.0 International +Creative Commons Corporation ("Creative Commons") is not a law firm and does not +provide legal services or legal advice. Distribution of Creative Commons public +licenses does not create a lawyer-client or other relationship. Creative Commons makes +its licenses and related information available on an "as-is" basis. Creative Commons +gives no warranties regarding its licenses, any material licensed under their terms +and conditions, or any related information. Creative Commons disclaims all liability +for damages resulting from their use to the fullest extent possible. +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions that +creators and other rights holders may use to share original works of authorship and +other material subject to copyright and certain other rights specified in the public +license below. The following considerations are for informational purposes only, are +not exhaustive, and do not form part of our licenses. + +Considerations for licensors: Our public licenses are intended for use by those +authorized to give the public permission to use material in ways otherwise restricted +by copyright and certain other rights. Our licenses are irrevocable. Licensors should +read and understand the terms and conditions of the license they choose before +applying it. Licensors should also secure all rights necessary before applying our +licenses so that the public can reuse the material as expected. Licensors should +clearly mark any material not subject to the license. This includes other CC-licensed +material, or material used under an exception or limitation to copyright. More +considerations for licensors. + +Considerations for the public: By using one of our public licenses, a licensor grants +the public permission to use the licensed material under specified terms and +conditions. If the licensor's permission is not necessary for any reason-for example, +because of any applicable exception or limitation to copyright-then that use is not +regulated by the license. Our licenses grant only permissions under copyright and +certain other rights that a licensor has authority to grant. Use of the licensed +material may still be restricted for other reasons, including because others have +copyright or other rights in the material. A licensor may make special requests, such +as asking that all changes be marked or described. Although not required by our +licenses, you are encouraged to respect those requests where reasonable. More +considerations for the public. + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to be bound by +the terms and conditions of this Creative Commons Attribution 4.0 International Public +License ("Public License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in consideration +of benefits the Licensor receives from making the Licensed Material available under +these terms and conditions. + +Section 1 - Definitions. + +a. Adapted Material means material subject to Copyright and Similar Rights that +is derived from or based upon the Licensed Material and in which the Licensed Material +is translated, altered, arranged, transformed, or otherwise modified in a manner +requiring permission under the Copyright and Similar Rights held by the Licensor. For +purposes of this Public License, where the Licensed Material is a musical work, +performance, or sound recording, Adapted Material is always produced where the +Licensed Material is synched in timed relation with a moving image. + +b. Adapter's License means the license You apply to Your Copyright and Similar +Rights in Your contributions to Adapted Material in accordance with the terms and +conditions of this Public License. + +c. Copyright and Similar Rights means copyright and/or similar rights closely +related to copyright including, without limitation, performance, broadcast, sound +recording, and Sui Generis Database Rights, without regard to how the rights are +labeled or categorized. For purposes of this Public License, the rights specified in +Section 2(b)(1)-(2) are not Copyright and Similar Rights. + +d. Effective Technological Measures means those measures that, in the absence of +proper authority, may not be circumvented under laws fulfilling obligations under +Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar +international agreements. + +e. Exceptions and Limitations means fair use, fair dealing, and/or any other +exception or limitation to Copyright and Similar Rights that applies to Your use of +the Licensed Material. + +f. Licensed Material means the artistic or literary work, database, or other +material to which the Licensor applied this Public License. + +g. Licensed Rights means the rights granted to You subject to the terms and +conditions of this Public License, which are limited to all Copyright and Similar +Rights that apply to Your use of the Licensed Material and that the Licensor has +authority to license. + +h. Licensor means the individual(s) or entity(ies) granting rights under this +Public License. + +i. Share means to provide material to the public by any means or process that +requires permission under the Licensed Rights, such as reproduction, public display, +public performance, distribution, dissemination, communication, or importation, and to +make material available to the public including in ways that members of the public may +access the material from a place and at a time individually chosen by them. + +j. Sui Generis Database Rights means rights other than copyright resulting from +Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on +the legal protection of databases, as amended and/or succeeded, as well as other +essentially equivalent rights anywhere in the world. + +k. You means the individual or entity exercising the Licensed Rights under this +Public License. Your has a corresponding meaning. + +Section 2 - Scope. + +a. License grant. + +1. Subject to the terms and conditions of this Public License, the Licensor hereby +grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable +license to exercise the Licensed Rights in the Licensed Material to: + +A. reproduce and Share the Licensed Material, in whole or in part; and + +B. produce, reproduce, and Share Adapted Material. + +2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and +Limitations apply to Your use, this Public License does not apply, and You do not need +to comply with its terms and conditions. + +3. Term. The term of this Public License is specified in Section 6(a). + +4. Media and formats; technical modifications allowed. The Licensor authorizes You to +exercise the Licensed Rights in all media and formats whether now known or hereafter +created, and to make technical modifications necessary to do so. The Licensor waives +and/or agrees not to assert any right or authority to forbid You from making technical +modifications necessary to exercise the Licensed Rights, including technical +modifications necessary to circumvent Effective Technological Measures. For purposes +of this Public License, simply making modifications authorized by this Section 2(a)(4) +never produces Adapted Material. + +5. Downstream recipients. + +A. Offer from the Licensor - Licensed Material. Every recipient of the Licensed +Material automatically receives an offer from the Licensor to exercise the Licensed +Rights under the terms and conditions of this Public License. + +B. No downstream restrictions. You may not offer or impose any additional or different +terms or conditions on, or apply any Effective Technological Measures to, the Licensed +Material if doing so restricts exercise of the Licensed Rights by any recipient of the +Licensed Material. + +6. No endorsement. Nothing in this Public License constitutes or may be construed as +permission to assert or imply that You are, or that Your use of the Licensed Material +is, connected with, or sponsored, endorsed, or granted official status by, the +Licensor or others designated to receive attribution as provided in Section +3(a)(1)(A)(i). + +b. Other rights. + +1. Moral rights, such as the right of integrity, are not licensed under this Public +License, nor are publicity, privacy, and/or other similar personality rights; however, +to the extent possible, the Licensor waives and/or agrees not to assert any such +rights held by the Licensor to the limited extent necessary to allow You to exercise +the Licensed Rights, but not otherwise. + +2. Patent and trademark rights are not licensed under this Public License. + +3. To the extent possible, the Licensor waives any right to collect royalties from You +for the exercise of the Licensed Rights, whether directly or through a collecting +society under any voluntary or waivable statutory or compulsory licensing scheme. In +all other cases the Licensor expressly reserves any right to collect such royalties. + +Section 3 - License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following +conditions. + +a. Attribution. + +1. If You Share the Licensed Material (including in modified form), You must: + +A. retain the following if it is supplied by the Licensor with the Licensed Material: + +i. identification of the creator(s) of the Licensed Material and any others designated +to receive attribution, in any reasonable manner requested by the Licensor (including +by pseudonym if designated); + +ii. a copyright notice; + +iii. a notice that refers to this Public License; + +iv. a notice that refers to the disclaimer of warranties; + +v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + +B. indicate if You modified the Licensed Material and retain an indication of any +previous modifications; and + +C. indicate the Licensed Material is licensed under this Public License, and include +the text of, or the URI or hyperlink to, this Public License. + +2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on +the medium, means, and context in which You Share the Licensed Material. For example, +it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a +resource that includes the required information. + +3. If requested by the Licensor, You must remove any of the information required by +Section 3(a)(1)(A) to the extent reasonably practicable. + +4. If You Share Adapted Material You produce, the Adapter's License You apply must not +prevent recipients of the Adapted Material from complying with this Public License. + +Section 4 - Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to Your use +of the Licensed Material: + +a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, +reuse, reproduce, and Share all or a substantial portion of the contents of the +database; + +b. if You include all or a substantial portion of the database contents in a +database in which You have Sui Generis Database Rights, then the database in which You +have Sui Generis Database Rights (but not its individual contents) is Adapted +Material; and + +c. You must comply with the conditions in Section 3(a) if You Share all or a +substantial portion of the contents of the database. +For the avoidance of doubt, this Section 4 supplements and does not replace Your +obligations under this Public License where the Licensed Rights include other +Copyright and Similar Rights. + +Section 5 - Disclaimer of Warranties and Limitation of Liability. + +a. Unless otherwise separately undertaken by the Licensor, to the extent +possible, the Licensor offers the Licensed Material as-is and as-available, and makes +no representations or warranties of any kind concerning the Licensed Material, whether +express, implied, statutory, or other. This includes, without limitation, warranties +of title, merchantability, fitness for a particular purpose, non-infringement, absence +of latent or other defects, accuracy, or the presence or absence of errors, whether or +not known or discoverable. Where disclaimers of warranties are not allowed in full or +in part, this disclaimer may not apply to You. + +b. To the extent possible, in no event will the Licensor be liable to You on any +legal theory (including, without limitation, negligence) or otherwise for any direct, +special, indirect, incidental, consequential, punitive, exemplary, or other losses, +costs, expenses, or damages arising out of this Public License or use of the Licensed +Material, even if the Licensor has been advised of the possibility of such losses, +costs, expenses, or damages. Where a limitation of liability is not allowed in full or +in part, this limitation may not apply to You. + +c. The disclaimer of warranties and limitation of liability provided above shall +be interpreted in a manner that, to the extent possible, most closely approximates an +absolute disclaimer and waiver of all liability. + +Section 6 - Term and Termination. + +a. This Public License applies for the term of the Copyright and Similar Rights +licensed here. However, if You fail to comply with this Public License, then Your +rights under this Public License terminate automatically. + +b. Where Your right to use the Licensed Material has terminated under Section +6(a), it reinstates: + +1. automatically as of the date the violation is cured, provided it is cured within 30 +days of Your discovery of the violation; or + +2. upon express reinstatement by the Licensor. + +c. For the avoidance of doubt, this Section 6(b) does not affect any right the +Licensor may have to seek remedies for Your violations of this Public License. + +d. For the avoidance of doubt, the Licensor may also offer the Licensed Material +under separate terms or conditions or stop distributing the Licensed Material at any +time; however, doing so will not terminate this Public License. + +e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + +Section 7 - Other Terms and Conditions. + +a. The Licensor shall not be bound by any additional or different terms or +conditions communicated by You unless expressly agreed. + +b. Any arrangements, understandings, or agreements regarding the Licensed +Material not stated herein are separate from and independent of the terms and +conditions of this Public License. + +Section 8 - Interpretation. + +a. For the avoidance of doubt, this Public License does not, and shall not be +interpreted to, reduce, limit, restrict, or impose conditions on any use of the +Licensed Material that could lawfully be made without permission under this Public +License. + +b. To the extent possible, if any provision of this Public License is deemed +unenforceable, it shall be automatically reformed to the minimum extent necessary to +make it enforceable. If the provision cannot be reformed, it shall be severed from +this Public License without affecting the enforceability of the remaining terms and +conditions. + +c. No term or condition of this Public License will be waived and no failure to +comply consented to unless expressly agreed to by the Licensor. + +d. Nothing in this Public License constitutes or may be interpreted as a +limitation upon, or waiver of, any privileges and immunities that apply to the +Licensor or You, including from the legal processes of any jurisdiction or authority. + +Creative Commons is not a party to its public licenses. Notwithstanding, Creative +Commons may elect to apply one of its public licenses to material it publishes and in +those instances will be considered the "Licensor." Except for the limited purpose of +indicating that material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the use of the +trademark "Creative Commons" or any other trademark or logo of Creative Commons +without its prior written consent including, without limitation, in connection with +any unauthorized modifications to any of its public licenses or any other +arrangements, understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the public licenses.?? +Creative Commons may be contacted at creativecommons.org. + +Source materials are available for download at: https://www.bbc.co.uk/ontologies/sport +Spring Framework 4.3.10.RELEASE +Attribution Statements +https://projects.spring.io/spring-framework/ + +Copyright Statements +Copyright (c) 2002-2013 Pivotal, Inc. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/spring-projects/spring-framework +StAX2 API 3.1.4 +Attribution Statements +https://github.com/FasterXML/stax2-api + +Copyright Statements +Copyright (C) 2017, fasterxml.com, Tatu Saloranta + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Copyright (c) 2017, fasterxml.com, Tatu Saloranta +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download +at: http://repo1.maven.org/maven2/org/codehaus/woodstox/stax2-api/3.1.4/ +Sunlight 1.22.0 +Attribution Statements +http://sunlightjs.com/ + +Copyright Statements +by Tommy Montgomery + +License Text (https://spdx.org/licenses/WTFPL.html) +DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + +Source materials are available for download at: https://github.com/tmont/sunlight +Superstore.xls +Attribution Statements +https://www.tableau.com/ + +Copyright Statements +(c) 2003-2017 Tableau Software. All Rights Reserved + +License Text () +Made available under commercial license. + +SystemJS 0.19.40 +Attribution Statements +https://github.com/systemjs/systemjs + +Copyright Statements +Copyright (C) 2013-2016 Guy Bedford + +License Text (http://spdx.org/licenses/MIT) +MIT License + +Copyright (C) 2013-2016 Guy Bedford + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/systemjs/systemjs +through2 2.0.3 +Copyright Statements +Copyright (c) 2016 Rod Vagg (the "Original Author") and additional contributors + +License Text (http://spdx.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2016 Rod Vagg (the "Original Author") and additional contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/rvagg/through2 +Woodstox 5.0.3 +Attribution Statements +http://woodstox.codehaus.org/ + +Copyright Statements +Copyright (c) 2004-2010, Woodstox Project (http://woodstox.codehaus.org/) +All rights reserved. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: http://woodstox.codehaus.org/Download +www-authenticate 0.6.2 +Copyright Statements +Copyright (c) 2013 Randy McLaughlin + +License Text (https://spdx.org/licenses/MIT.html) +Copyright (c) 2013 Randy McLaughlin + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/randymized/www-authenticate +Xalan-Java 2.7.0 +Attribution Statements +https://xml.apache.org/xalan-j/ + + Portions of this software was originally based on the following: + + - software copyright (c) 1999-2002, Lotus Development Corporation., +http://www.lotus.com. + - software copyright (c) 2001-2002, Sun Microsystems., http://www.sun.com. + - software copyright (c) 2003, IBM Corporation., http://www.ibm.com. + - voluntary contributions made by Ovidiu Predescu (ovidiu@cup.hp.com) on behalf +of the + Apache Software Foundation and was originally developed at Hewlett Packard +Company. + +Copyright Statements +Copyright (c) 2006 The Apache Software Foundation. All Rights Reserved. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://mvnrepository.com/artifact/xalan/xalan +Xerces2 Java Parser 2.11.0 +Attribution Statements +https://xerces.apache.org/xerces2-j/ + +Portions of this software were originally based on the following: + - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. + - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. + - voluntary contributions made by Paul Eng on behalf of the + Apache Software Foundation that were originally developed at iClick, Inc., + software copyright (c) 1999. + +Copyright Statements +Copyright 1999-2015 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: http://svn.apache.org/viewvc/xerces/java/trunk/ +Xerces2 Java Parser 2.8.0 +Attribution Statements +https://xerces.apache.org/xerces2-j/ + +Portions of this software were originally based on the following: + - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. + - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. + - voluntary contributions made by Paul Eng on behalf of the + Apache Software Foundation that were originally developed at iClick, Inc., + software copyright (c) 1999. + +Copyright Statements +Copyright 1999-2015 The Apache Software Foundation + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: http://svn.apache.org/viewvc/xerces/java/trunk/ +Xml Compatibility Extensions For Jackson (jackson-xc) 1.9.13 +Attribution Statements +http://jackson.codehaus.org + +Copyright Statements +Copyright (c) FasterXML. + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download +at: https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-xc/1.9.13 +XMLUnit 1.3 +Attribution Statements +http://www.xmlunit.org/ + +Copyright Statements +Copyright (c) 2001-2015, Jeff Martin, Tim Bacon +All rights reserved. + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Copyright (c) 2001-2015, Jeff Martin, Tim Bacon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name XMLUnit nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: https://github.com/xmlunit/xmlunit/tree/master/xmlunit- +legacy +XMLUnit 1.6 +Attribution Statements +http://www.xmlunit.org/ + +Copyright Statements +Copyright (c) 2001-2015, Jeff Martin, Tim Bacon +All rights reserved. + +License Text (http://spdx.org/licenses/BSD-3-Clause) +Copyright (c) 2001-2015, Jeff Martin, Tim Bacon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name XMLUnit nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Source materials are available for download at: https://github.com/xmlunit/xmlunit/tree/master/xmlunit- +legacy +XOM(tm) 1.2.5 +Attribution Statements +http://xom.nu + +Copyright Statements +Copyright (c) 2002, 2004 Elliotte Rusty Harold + +License Text (http://spdx.org/licenses/LGPL-2.1.html) + +Source materials are available for download at: https://github.com/elharo/xom/ +XQuery XML Memory Operations 1.0.6 +Attribution Statements +https://github.com/ryanjdew/XQuery-XML-Memory-Operations + +Copyright Statements +Copyright (c) 2013 Ryan Dew + +License Text (http://spdx.org/licenses/Apache-2.0) + +Source materials are available for download at: https://github.com/ryanjdew/XQuery-XML-Memory- +Operations +XStream 1.4.9 +Attribution Statements +http://x-stream.github.io + +Copyright Statements +Copyright (c) 2003-2006, Joe Walnes +Copyright (c) 2006-2015 XStream Committers +All rights reserved. + +License Text (https://spdx.org/licenses/BSD-3-Clause.html) +Copyright (c) 2003-2006, Joe Walnes +Copyright (c) 2006-2015 XStream Committers +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list +of +conditions and the following disclaimer in the documentation and/or other materials +provided +with the distribution. + +3. Neither the name of XStream nor the names of its contributors may be used to +endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +yakaa 1.0.1 +Copyright Statements +Copyright Joyent, Inc. and other Node contributors. + +License Text (http://spdx.org/licenses/MIT) +Copyright Joyent, Inc. and other Node contributors. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +Source materials are available for download at: https://github.com/newrelic/yakaa +Zone.js 0.6.26 +Attribution Statements +https://github.com/angular/zone.js + +author.name: Brian Ford + +Copyright Statements +Copyright (c) 2016 Google, Inc. + +License Text (http://spdx.org/licenses/MIT) +The MIT License + +Copyright (c) 2016 Google, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/angular/zone.js +Zone.js 0.8.18 +Attribution Statements +https://github.com/angular/zone.js + +author.name: Brian Ford + +Copyright Statements +Copyright (c) 2016 Google, Inc. + +License Text (http://spdx.org/licenses/MIT) +The MIT License + +Copyright (c) 2016 Google, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Source materials are available for download at: https://github.com/angular/zone.js +---------- +Please direct questions, comments and requests to fossreview@marklogic.com. +Open source software required to be made available under license is included herein. In the event you +are unable to obtain a copy of such open source software, please contact fossreview@marklogic.com +and a copy will be made available to you. diff --git a/LICENSE b/LICENSE index 92cad5a8..0250b070 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright © 2017 MarkLogic Corporation. +Copyright © 2017-2018 MarkLogic Corporation. This project and its code and functionality is not representative of MarkLogic Server and is not supported by MarkLogic. diff --git a/NOTICE b/NOTICE index 60d5f63a..ae5d67ba 100644 --- a/NOTICE +++ b/NOTICE @@ -1,4 +1,4 @@ -Copyright © 2017 MarkLogic Corporation. +Copyright © 2017-2018 MarkLogic Corporation. This project and its code and functionality is not representative of MarkLogic Server and is not supported by MarkLogic. diff --git a/config-optic/connectdef.js b/config-optic/connectdef.js new file mode 100644 index 00000000..256fd02b --- /dev/null +++ b/config-optic/connectdef.js @@ -0,0 +1,31 @@ +/* + * Copyright 2015 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +var name = 'nodeOpticFunctionalTest'; + +var plan = { + host: 'localhost', + port: 8079, + user: 'admin', + password: 'admin', + authType: 'DIGEST' +} + +module.exports = { + name: name, + plan: plan +}; diff --git a/config-optic/databaseconfig.sjs b/config-optic/databaseconfig.sjs new file mode 100755 index 00000000..1648cc21 --- /dev/null +++ b/config-optic/databaseconfig.sjs @@ -0,0 +1,36 @@ +var admin = require("/MarkLogic/admin.xqy"); +var config = admin.getConfiguration(); +var dbid = xdmp.database("nodeOpticFunctionalTest"); +var modDbId = xdmp.database("nodeOpticFunctionalTestModules"); + +var cityIndex = admin.databaseRangeElementIndex("string", "", "city", "http://marklogic.com/collation/", fn.false()); +var popularityIndex = admin.databaseRangeElementIndex("int", "", "popularity", "", fn.false()); +var distanceIndex = admin.databaseRangeElementIndex("double", "", "distance", "", fn.false()); +var dateIndex = admin.databaseRangeElementIndex("date", "", "date", "", fn.false()); +var cityLexicon = admin.databaseElementWordLexicon("", "city", "http://marklogic.com/collation/"); +var geoIndex = admin.databaseGeospatialElementIndex("", "latLonPoint", "wgs84", fn.false()); +var idIndex = admin.databaseRangeElementIndex("int", "", "id", "", fn.false()); + +var cityNameIndex = admin.databaseRangeElementIndex("string", "", "cityName", "http://marklogic.com/collation/", fn.false()); +var cityTeamIndex = admin.databaseRangeElementIndex("string", "", "cityTeam", "http://marklogic.com/collation/", fn.false()); +var cityPopulationIndex = admin.databaseRangeElementIndex("long", "", "cityPopulation", "", fn.false()); + +config = admin.databaseAddRangeElementIndex(config, dbid, cityIndex); +config = admin.databaseAddRangeElementIndex(config, dbid, popularityIndex); +config = admin.databaseAddRangeElementIndex(config, dbid, distanceIndex); +config = admin.databaseAddRangeElementIndex(config, dbid, dateIndex); +config = admin.databaseAddRangeElementIndex(config, dbid, idIndex); + +config = admin.databaseAddRangeElementIndex(config, dbid, cityNameIndex); +config = admin.databaseAddRangeElementIndex(config, dbid, cityTeamIndex); +config = admin.databaseAddRangeElementIndex(config, dbid, cityPopulationIndex); + +config = admin.databaseAddElementWordLexicon(config, dbid, cityLexicon); +config = admin.databaseAddGeospatialElementIndex(config, dbid, geoIndex); +config = admin.databaseSetTripleIndex(config, dbid, fn.true()); +config = admin.databaseSetCollectionLexicon(config, dbid, fn.true()); +config = admin.databaseSetUriLexicon(config, dbid, fn.true()); + +config = admin.databaseSetSchemaDatabase(config, dbid, modDbId); + +admin.saveConfiguration(config); diff --git a/config-optic/loaddata.js b/config-optic/loaddata.js new file mode 100755 index 00000000..2edb3214 --- /dev/null +++ b/config-optic/loaddata.js @@ -0,0 +1,169 @@ +'use strict'; + +var fs = require('fs'); + +var moduleFiles = [ + { + uri:'/optic/view/test/masterDetail.tdex', + collections:['http://marklogic.com/xdmp/tde'], + contentType:'application/vnd.marklogic-tde+xml', + content:fs.createReadStream('./config-optic/qa-data/masterDetail.tdex') + }, + { + uri:'/optic/view/test/masterDetail2.tdej', + collections:['http://marklogic.com/xdmp/tde'], + contentType:'application/vnd.marklogic-tde+json', + content:fs.createReadStream('./config-optic/qa-data/masterDetail2.tdej') + }, + { + uri:'/optic/view/test/masterDetail3.tdej', + collections:['http://marklogic.com/xdmp/tde'], + contentType:'application/vnd.marklogic-tde+json', + content:fs.createReadStream('./config-optic/qa-data/masterDetail3.tdej') + }, + { + uri:'/optic/view/test/masterDetail4.tdej', + collections:['http://marklogic.com/xdmp/tde'], + contentType:'application/vnd.marklogic-tde+json', + content:fs.createReadStream('./config-optic/qa-data/masterDetail4.tdej') + }, + { + uri:'/optic/test/mapperReducer.sjs', + contentType:'application/vnd.marklogic-javascript', + content:fs.createReadStream('./config-optic/qa-data/mapperReducer.sjs') + } +]; + +var dataFiles = [ + { + uri:'/optic/view/test/masterDetail.xml', + collections:['/optic/view/test'], + content:fs.createReadStream('./config-optic/qa-data/masterDetail.xml') + },{ + uri:'/optic/view/test/masterDetail2.json', + collections:['/optic/view/test'], + content:fs.createReadStream('./config-optic/qa-data/masterDetail2.json') + },{ + uri:'/optic/view/test/masterDetail3.json', + collections:['/optic/view/test'], + content:fs.createReadStream('./config-optic/qa-data/masterDetail3.json') + },{ + uri:'/optic/view/test/masterDetail4.json', + collections:['/optic/view/test'], + content:fs.createReadStream('./config-optic/qa-data/masterDetail4.json') + },{ + uri:'/optic/view/test/masterDetail5.json', + collections:['/optic/view/test'], + content:fs.createReadStream('./config-optic/qa-data/masterDetail5.json') + },{ + uri:'/optic/triple/test/playerTripleSet.xml', + collections:['/optic/player/triple/test'], + content:fs.createReadStream('./config-optic/qa-data/playerTripleSet.xml') + },{ + uri:'/optic/triple/test/teamTripleSet.xml', + collections:['/optic/team/triple/test'], + content:fs.createReadStream('./config-optic/qa-data/teamTripleSet.xml') + },{ + uri:'/optic/triple/test/duplicatePlayerTripleSet.xml', + collections:['/optic/player/triple/test'], + content:fs.createReadStream('./config-optic/qa-data/playerTripleSet.xml') + },{ + uri:'/optic/triple/test/duplicateTeamTripleSet.xml', + collections:['/optic/team/triple/test'], + content:fs.createReadStream('./config-optic/qa-data/teamTripleSet.xml') + },{ + uri:'/optic/triple/test/otherPlayerTripleSet.xml', + collections:['/optic/other/player/triple/test'], + content:fs.createReadStream('./config-optic/qa-data/otherPlayerTripleSet.xml') + },{ + uri:'/optic/lexicon/test/doc1.json', + collections:['/optic/lexicon/test', '/other/coll1', '/other/coll2'], + content:fs.createReadStream('./config-optic/qa-data/doc1.json') + },{ + uri:'/optic/lexicon/test/doc2.json', + collections:['/optic/lexicon/test'], + content:fs.createReadStream('./config-optic/qa-data/doc2.json') + },{ + uri:'/optic/lexicon/test/doc3.json', + collections:['/optic/lexicon/test'], + content:fs.createReadStream('./config-optic/qa-data/doc3.json') + },{ + uri:'/optic/lexicon/test/doc4.xml', + collections:['/optic/lexicon/test'], + content:fs.createReadStream('./config-optic/qa-data/doc4.xml') + },{ + uri:'/optic/lexicon/test/doc5.xml', + collections:['/optic/lexicon/test'], + content:fs.createReadStream('./config-optic/qa-data/doc5.xml') + },{ + uri:'/optic/lexicon/test/city1.json', + collections:['/optic/lexicon/test'], + content:fs.createReadStream('./config-optic/qa-data/city1.json') + },{ + uri:'/optic/lexicon/test/city2.json', + collections:['/optic/lexicon/test'], + content:fs.createReadStream('./config-optic/qa-data/city2.json') + },{ + uri:'/optic/lexicon/test/city3.json', + collections:['/optic/lexicon/test'], + content:fs.createReadStream('./config-optic/qa-data/city3.json') + },{ + uri:'/optic/lexicon/test/city4.json', + collections:['/optic/lexicon/test'], + content:fs.createReadStream('./config-optic/qa-data/city4.json') + },{ + uri:'/optic/lexicon/test/city5.json', + collections:['/optic/lexicon/test'], + content:fs.createReadStream('./config-optic/qa-data/city5.json') + },{ + uri:'/optic/plan/test/planViews.json', + collections:['/optic/plan/test'], + content:fs.createReadStream('./config-optic/qa-data/planViews.json') + },{ + uri:'/optic/plan/test/planLexicons.json', + collections:['/optic/plan/test'], + content:fs.createReadStream('./config-optic/qa-data/planLexicons.json') + },{ + uri:'/optic/plan/test/planTriples.json', + collections:['/optic/plan/test'], + content:fs.createReadStream('./config-optic/qa-data/planTriples.json') + }]; + +var graphFiles1 = [ + { + uri: '/optic/sparql/test/people.ttl', + contentType: 'text/turtle', + data: fs.createReadStream('./config-optic/qa-data/people.ttl') + } +]; + +var graphFiles2 = [ + { + uri: '/optic/sparql/test/companies.ttl', + contentType: 'text/turtle', + data: fs.createReadStream('./config-optic/qa-data/companies_100.ttl') + } +]; + +function writeDocuments(db) { + return db.documents.write(dataFiles); +} + +function writeDocumentsToMod(db) { + return db.documents.write(moduleFiles); +} + +function writeGraphs1(db) { + return db.graphs.write(graphFiles1); +} + +function writeGraphs2(db) { + return db.graphs.write(graphFiles2); +} + +module.exports = { + writeDocuments: writeDocuments, + writeDocumentsToMod: writeDocumentsToMod, + writeGraphs1: writeGraphs1, + writeGraphs2: writeGraphs2 +}; diff --git a/config-optic/loadtde.xqy b/config-optic/loadtde.xqy new file mode 100644 index 00000000..7ad2bc38 --- /dev/null +++ b/config-optic/loadtde.xqy @@ -0,0 +1,54 @@ +xquery version "1.0-ml"; + +let $evalStr := +' +xquery version "1.0-ml"; +xdmp:document-insert("/optic/view/test/masterDetail.tde", + , +(xdmp:permission("rest-evaluator", "update")), +"http://marklogic.com/xdmp/tde", +() +)' + +return +xdmp:eval( + $evalStr, + (), + + {xdmp:database("nodeOpticFunctionalTestModules")} + +); diff --git a/config-optic/myload.js b/config-optic/myload.js new file mode 100644 index 00000000..37b0df03 --- /dev/null +++ b/config-optic/myload.js @@ -0,0 +1,25 @@ +'use strict'; + +var util = require('util'); + +var fs = require('fs'); + +var marklogic = require('marklogic'); +var testlib = require('./testlib.js'); + +var clientConnectdef = require('./connectdef.js'); +var testName = clientConnectdef.name; +var planServerdef = clientConnectdef.plan; + +var testLoad = require('./loaddata.js'); +var testUser = require('./userconfig.js'); + +var db = marklogic.createDatabaseClient({ + host: planServerdef.host, + port: planServerdef.port, + user: 'admin', + password: 'admin', + authType: planServerdef.authType +}); + +testLoad.writeDocuments(db); diff --git a/config-optic/qa-data/city1.json b/config-optic/qa-data/city1.json new file mode 100755 index 00000000..8388cedb --- /dev/null +++ b/config-optic/qa-data/city1.json @@ -0,0 +1,6 @@ + +{ + "cityName": "london", + "cityTeam": "arsenal", + "cityPopulation": 2000000 +} diff --git a/config-optic/qa-data/city2.json b/config-optic/qa-data/city2.json new file mode 100755 index 00000000..c0a37c3d --- /dev/null +++ b/config-optic/qa-data/city2.json @@ -0,0 +1,6 @@ + +{ + "cityName": "new york", + "cityTeam": "yankee", + "cityPopulation": 11000000 +} diff --git a/config-optic/qa-data/city3.json b/config-optic/qa-data/city3.json new file mode 100755 index 00000000..9f18b122 --- /dev/null +++ b/config-optic/qa-data/city3.json @@ -0,0 +1,6 @@ + +{ + "cityName": "new jersey", + "cityTeam": "nets", + "cityPopulation": 3000000 +} diff --git a/config-optic/qa-data/city4.json b/config-optic/qa-data/city4.json new file mode 100755 index 00000000..5640ea7d --- /dev/null +++ b/config-optic/qa-data/city4.json @@ -0,0 +1,6 @@ + +{ + "cityName": "beijing", + "cityTeam": "ducks", + "cityPopulation": 55000000 +} diff --git a/config-optic/qa-data/city5.json b/config-optic/qa-data/city5.json new file mode 100755 index 00000000..3814c03c --- /dev/null +++ b/config-optic/qa-data/city5.json @@ -0,0 +1,6 @@ + +{ + "cityName": "cape town", + "cityTeam": "pirates", + "cityPopulation": 650000 +} diff --git a/config-optic/qa-data/companies_100.ttl b/config-optic/qa-data/companies_100.ttl new file mode 100755 index 00000000..605112c7 --- /dev/null +++ b/config-optic/qa-data/companies_100.ttl @@ -0,0 +1,1804 @@ +@prefix demor: . +@prefix demov: . +@prefix vcard: . + + +##company 1 +demor:COMPANY001 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 12000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "San Jose"; + vcard:region "Texas"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 2 +demor:COMPANY002 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 100000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "San Jose"; + vcard:region "New York"; + vcard:postal-code "77777"; + vcard:street-address "1 Infinite Loop" ]. + +##company 3 +demor:COMPANY003 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 1000000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "San Jose"; + vcard:region "Arizona"; + vcard:postal-code "77777"; + vcard:street-address "1 Infinite Loop" ]. + +##company 4 +demor:COMPANY004 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 8; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Menlo Park"; + vcard:region "Arizona"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 5 +demor:COMPANY005 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 347852766; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "Menlo Park"; + vcard:region "Texas"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 6 +demor:COMPANY006 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 2300450; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "San Jose"; + vcard:region "North Dakota"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 7 +demor:COMPANY007 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 8; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "Menlo Park"; + vcard:region "Nevada"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 8 +demor:COMPANY008 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 347852766; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Redwood City"; + vcard:region "North Carolina"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 9 +demor:COMPANY009 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 300000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "Atherton"; + vcard:region "Texas"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 10 +demor:COMPANY010 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 15000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "Menlo Park"; + vcard:region "New York"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 11 +demor:COMPANY011 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 1000000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "San Jose"; + vcard:region "Arizona"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 12 +demor:COMPANY012 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 347852766; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Atherton"; + vcard:region "North Carolina"; + vcard:postal-code "55555"; + vcard:street-address "1 Infinite Loop" ]. + +##company 13 +demor:COMPANY013 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 1000000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Redwood City"; + vcard:region "North Carolina"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 14 +demor:COMPANY014 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 347852766; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Menlo Park"; + vcard:region "North Dakota"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 15 +demor:COMPANY015 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 12000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "Menlo Park"; + vcard:region "North Dakota"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 16 +demor:COMPANY016 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 15000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "San Jose"; + vcard:region "Texas"; + vcard:postal-code "77777"; + vcard:street-address "1 Infinite Loop" ]. + +##company 17 +demor:COMPANY017 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 100000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "Redwood City"; + vcard:region "Texas"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 18 +demor:COMPANY018 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 1000000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Redwood City"; + vcard:region "North Dakota"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 19 +demor:COMPANY019 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 12000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "San Jose"; + vcard:region "Arizona"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 20 +demor:COMPANY020 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 10000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Atherton"; + vcard:region "Arizona"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 21 +demor:COMPANY021 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 15000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Redwood City"; + vcard:region "New York"; + vcard:postal-code "22222"; + vcard:street-address "1 Infinite Loop" ]. + +##company 22 +demor:COMPANY022 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 100000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Atherton"; + vcard:region "North Dakota"; + vcard:postal-code "55555"; + vcard:street-address "1 Infinite Loop" ]. + +##company 23 +demor:COMPANY023 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 15000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "Menlo Park"; + vcard:region "Arizona"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 24 +demor:COMPANY024 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 12000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Menlo Park"; + vcard:region "North Dakota"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 25 +demor:COMPANY025 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 8; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "San Jose"; + vcard:region "Arizona"; + vcard:postal-code "77777"; + vcard:street-address "1 Infinite Loop" ]. + +##company 26 +demor:COMPANY026 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 10000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "San Jose"; + vcard:region "North Carolina"; + vcard:postal-code "22222"; + vcard:street-address "1 Infinite Loop" ]. + +##company 27 +demor:COMPANY027 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 15000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "Atherton"; + vcard:region "North Carolina"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 28 +demor:COMPANY028 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 2300450; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Atherton"; + vcard:region "Arizona"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 29 +demor:COMPANY029 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 347852766; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Atherton"; + vcard:region "Nevada"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 30 +demor:COMPANY030 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 15000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Menlo Park"; + vcard:region "California"; + vcard:postal-code "77777"; + vcard:street-address "1 Infinite Loop" ]. + +##company 31 +demor:COMPANY031 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 100000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Redwood City"; + vcard:region "Arizona"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 32 +demor:COMPANY032 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 347852766; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "Menlo Park"; + vcard:region "California"; + vcard:postal-code "77777"; + vcard:street-address "1 Infinite Loop" ]. + +##company 33 +demor:COMPANY033 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 8; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Redwood City"; + vcard:region "Arizona"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 34 +demor:COMPANY034 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 15000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Redwood City"; + vcard:region "Nevada"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 35 +demor:COMPANY035 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 10000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Menlo Park"; + vcard:region "Nevada"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 36 +demor:COMPANY036 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 300000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "San Jose"; + vcard:region "Arizona"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 37 +demor:COMPANY037 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 10000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Atherton"; + vcard:region "Arizona"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 38 +demor:COMPANY038 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 300000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "Atherton"; + vcard:region "Texas"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 39 +demor:COMPANY039 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 100000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Redwood City"; + vcard:region "Nevada"; + vcard:postal-code "55555"; + vcard:street-address "1 Infinite Loop" ]. + +##company 40 +demor:COMPANY040 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 15000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "Menlo Park"; + vcard:region "California"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 41 +demor:COMPANY041 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 300000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Menlo Park"; + vcard:region "New York"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 42 +demor:COMPANY042 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 10000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Atherton"; + vcard:region "Nevada"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 43 +demor:COMPANY043 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 1000000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "San Jose"; + vcard:region "California"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 44 +demor:COMPANY044 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 10000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Menlo Park"; + vcard:region "North Dakota"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 45 +demor:COMPANY045 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 15000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "Redwood City"; + vcard:region "Arizona"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 46 +demor:COMPANY046 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 300000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "Atherton"; + vcard:region "California"; + vcard:postal-code "77777"; + vcard:street-address "1 Infinite Loop" ]. + +##company 47 +demor:COMPANY047 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 100000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "Redwood City"; + vcard:region "New York"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 48 +demor:COMPANY048 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 100000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "San Jose"; + vcard:region "Arizona"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 49 +demor:COMPANY049 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 347852766; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "Redwood City"; + vcard:region "North Carolina"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 50 +demor:COMPANY050 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 347852766; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "San Jose"; + vcard:region "Texas"; + vcard:postal-code "22222"; + vcard:street-address "1 Infinite Loop" ]. + +##company 51 +demor:COMPANY051 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 100000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "Menlo Park"; + vcard:region "Texas"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 52 +demor:COMPANY052 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 12000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "Menlo Park"; + vcard:region "Arizona"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 53 +demor:COMPANY053 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 347852766; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Redwood City"; + vcard:region "North Dakota"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 54 +demor:COMPANY054 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 10000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Redwood City"; + vcard:region "North Dakota"; + vcard:postal-code "55555"; + vcard:street-address "1 Infinite Loop" ]. + +##company 55 +demor:COMPANY055 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 15000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Menlo Park"; + vcard:region "North Dakota"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 56 +demor:COMPANY056 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 347852766; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Menlo Park"; + vcard:region "New York"; + vcard:postal-code "22222"; + vcard:street-address "1 Infinite Loop" ]. + +##company 57 +demor:COMPANY057 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 10000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "San Jose"; + vcard:region "Texas"; + vcard:postal-code "22222"; + vcard:street-address "1 Infinite Loop" ]. + +##company 58 +demor:COMPANY058 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 1000000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "Redwood City"; + vcard:region "New York"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 59 +demor:COMPANY059 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 15000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "San Jose"; + vcard:region "California"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 60 +demor:COMPANY060 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 100000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "Redwood City"; + vcard:region "New York"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 61 +demor:COMPANY061 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 10000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Redwood City"; + vcard:region "Texas"; + vcard:postal-code "55555"; + vcard:street-address "1 Infinite Loop" ]. + +##company 62 +demor:COMPANY062 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 15000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Redwood City"; + vcard:region "Nevada"; + vcard:postal-code "22222"; + vcard:street-address "1 Infinite Loop" ]. + +##company 63 +demor:COMPANY063 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 100000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Menlo Park"; + vcard:region "New York"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 64 +demor:COMPANY064 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 12000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "San Jose"; + vcard:region "North Dakota"; + vcard:postal-code "22222"; + vcard:street-address "1 Infinite Loop" ]. + +##company 65 +demor:COMPANY065 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 2300450; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "Atherton"; + vcard:region "North Carolina"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 66 +demor:COMPANY066 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 10000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Atherton"; + vcard:region "Nevada"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 67 +demor:COMPANY067 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 8; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "Redwood City"; + vcard:region "North Dakota"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 68 +demor:COMPANY068 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 300000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Atherton"; + vcard:region "Texas"; + vcard:postal-code "77777"; + vcard:street-address "1 Infinite Loop" ]. + +##company 69 +demor:COMPANY069 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 12000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "Redwood City"; + vcard:region "Arizona"; + vcard:postal-code "55555"; + vcard:street-address "1 Infinite Loop" ]. + +##company 70 +demor:COMPANY070 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 2300450; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "Menlo Park"; + vcard:region "New York"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 71 +demor:COMPANY071 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 8; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Redwood City"; + vcard:region "North Dakota"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 72 +demor:COMPANY072 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 1000000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Menlo Park"; + vcard:region "California"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 73 +demor:COMPANY073 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 1000000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Redwood City"; + vcard:region "Texas"; + vcard:postal-code "22222"; + vcard:street-address "1 Infinite Loop" ]. + +##company 74 +demor:COMPANY074 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 15000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Menlo Park"; + vcard:region "California"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 75 +demor:COMPANY075 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 10000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Menlo Park"; + vcard:region "Nevada"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 76 +demor:COMPANY076 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 300000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "Atherton"; + vcard:region "New York"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 77 +demor:COMPANY077 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 12000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Japan"; + vcard:locality "Redwood City"; + vcard:region "Nevada"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 78 +demor:COMPANY078 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 8; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "San Jose"; + vcard:region "Arizona"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 79 +demor:COMPANY079 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 1000000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "San Jose"; + vcard:region "Texas"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 80 +demor:COMPANY080 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 15000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Redwood City"; + vcard:region "California"; + vcard:postal-code "22222"; + vcard:street-address "1 Infinite Loop" ]. + +##company 81 +demor:COMPANY081 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 347852766; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "China"; + vcard:locality "Menlo Park"; + vcard:region "Arizona"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 82 +demor:COMPANY082 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 15000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "San Jose"; + vcard:region "Texas"; + vcard:postal-code "66666"; + vcard:street-address "1 Infinite Loop" ]. + +##company 83 +demor:COMPANY083 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 100000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "Menlo Park"; + vcard:region "California"; + vcard:postal-code "55555"; + vcard:street-address "1 Infinite Loop" ]. + +##company 84 +demor:COMPANY084 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 100000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "San Jose"; + vcard:region "California"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 85 +demor:COMPANY085 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 347852766; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "Atherton"; + vcard:region "Texas"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 86 +demor:COMPANY086 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 1000000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "San Jose"; + vcard:region "New York"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 87 +demor:COMPANY087 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 10000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Atherton"; + vcard:region "California"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 88 +demor:COMPANY088 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 100000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Menlo Park"; + vcard:region "California"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 89 +demor:COMPANY089 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 100000000; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "Redwood City"; + vcard:region "New York"; + vcard:postal-code "33333"; + vcard:street-address "1 Infinite Loop" ]. + +##company 90 +demor:COMPANY090 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 10000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CTO"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "San Jose"; + vcard:region "Arizona"; + vcard:postal-code "88888"; + vcard:street-address "1 Infinite Loop" ]. + +##company 91 +demor:COMPANY091 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 10000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "Italy"; + vcard:locality "Menlo Park"; + vcard:region "North Carolina"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 92 +demor:COMPANY092 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 100000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "President"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Redwood City"; + vcard:region "New York"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 93 +demor:COMPANY093 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 12000000; + demov:employees 10500; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "Germany"; + vcard:locality "Menlo Park"; + vcard:region "North Carolina"; + vcard:postal-code "55555"; + vcard:street-address "1 Infinite Loop" ]. + +##company 94 +demor:COMPANY094 a vcard:Organization; + demov:listed "true"; + demov:industry "Financial Services"; + demov:sales 8; + demov:employees 12; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "Mary Hodges"; + ]; + vcard:hasAddress [ + vcard:country-name "UK"; + vcard:locality "Menlo Park"; + vcard:region "California"; + vcard:postal-code "44444"; + vcard:street-address "1 Infinite Loop" ]. + +##company 95 +demor:COMPANY095 a vcard:Organization; + demov:listed "true"; + demov:industry "Healthcare/Life Sciences"; + demov:sales 12000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Menlo Park"; + vcard:region "Nevada"; + vcard:postal-code "55555"; + vcard:street-address "1 Infinite Loop" ]. + +##company 96 +demor:COMPANY096 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 100000000; + demov:employees 256; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Redwood City"; + vcard:region "North Dakota"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 97 +demor:COMPANY097 a vcard:Organization; + demov:listed "true"; + demov:industry "Industrial Goods"; + demov:sales 347852766; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "India"; + vcard:locality "Redwood City"; + vcard:region "Nevada"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. + +##company 98 +demor:COMPANY098 a vcard:Organization; + demov:listed "true"; + demov:industry "Other"; + demov:sales 300000000; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CFO"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Menlo Park"; + vcard:region "Arizona"; + vcard:postal-code "11111"; + vcard:street-address "1 Infinite Loop" ]. + +##company 99 +demor:COMPANY099 a vcard:Organization; + demov:listed "true"; + demov:industry "Business/Consumer Service"; + demov:sales 300000000; + demov:employees 22647; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "CEO"; + vcard:hasEmail ; + vcard:fn "Joe Brown"; + ]; + vcard:hasAddress [ + vcard:country-name "USA"; + vcard:locality "Atherton"; + vcard:region "Arizona"; + vcard:postal-code "77777"; + vcard:street-address "1 Infinite Loop" ]. + +##company 100 +demor:COMPANY100 a vcard:Organization; + demov:listed "true"; + demov:industry "Retail/Wholesale"; + demov:sales 2300450; + demov:employees 9450; + demov:hasExecutive [ a vcard:Individual; + vcard:hasTitle "Director of IT"; + vcard:hasEmail ; + vcard:fn "John Smith"; + ]; + vcard:hasAddress [ + vcard:country-name "France"; + vcard:locality "Atherton"; + vcard:region "New York"; + vcard:postal-code "99999"; + vcard:street-address "1 Infinite Loop" ]. diff --git a/config-optic/qa-data/doc1.json b/config-optic/qa-data/doc1.json new file mode 100755 index 00000000..38fa8e56 --- /dev/null +++ b/config-optic/qa-data/doc1.json @@ -0,0 +1,18 @@ +{ + "city":"london", + "distance":50.4, + "date":"2007-01-01", + "metro":true, + "description":"Two recent discoveries indicate probable very early settlements near the Thames", + "popularity":5, + "location":{ + "latLonPoint":"51.50, -0.12", + "latLonPair":{ + "lat":51.5, + "long":-0.12 + }, + "latLonParent":{ + "latLonChild":"51.50, -0.12" + } + } +} \ No newline at end of file diff --git a/config-optic/qa-data/doc2.json b/config-optic/qa-data/doc2.json new file mode 100755 index 00000000..c7345198 --- /dev/null +++ b/config-optic/qa-data/doc2.json @@ -0,0 +1,18 @@ +{ + "city":"new york", + "distance":23.3, + "date":"2006-06-23", + "metro":true, + "description":"Henry Hudsons 1609 voyage marked the beginning of European involvement with the area", + "popularity":5, + "location":{ + "latLonPoint":"40.71, -74.01", + "latLonPair":{ + "lat":40.71, + "long":-74.01 + }, + "latLonParent":{ + "latLonChild":"40.71, -74.01" + } + } +} \ No newline at end of file diff --git a/config-optic/qa-data/doc3.json b/config-optic/qa-data/doc3.json new file mode 100755 index 00000000..2bd7df87 --- /dev/null +++ b/config-optic/qa-data/doc3.json @@ -0,0 +1,18 @@ +{ + "city":"new jersey", + "distance":12.9, + "date":"1971-12-23", + "metro":false, + "description":"American forces under Washington met the forces under General Henry Clinton", + "popularity":2, + "location":{ + "latLonPoint":"40.72, -74.07", + "latLonPair":{ + "lat":40.72, + "long":-74.07 + }, + "latLonParent":{ + "latLonChild":"40.72, -74.07" + } + } +} \ No newline at end of file diff --git a/config-optic/qa-data/doc4.xml b/config-optic/qa-data/doc4.xml new file mode 100755 index 00000000..8431dfa5 --- /dev/null +++ b/config-optic/qa-data/doc4.xml @@ -0,0 +1,19 @@ + + beijing + 134.5 + 1981-11-09 + true + The Miyun Reservoir, on the upper reaches of the Chaobai River, is the largest reservoir within the municipality + 5 + + 39.90,116.40 + + 39.90,116.40 + + + 39.90 + 116.40 + + + + \ No newline at end of file diff --git a/config-optic/qa-data/doc5.xml b/config-optic/qa-data/doc5.xml new file mode 100755 index 00000000..8576dba9 --- /dev/null +++ b/config-optic/qa-data/doc5.xml @@ -0,0 +1,19 @@ + + cape town + 377.9 + 1999-04-22 + true + The earliest known remnants in the region were found at Peers cave in Fish Hoek + 3 + + -33.91,18.42 + + -33.91,18.42 + + + -33.91 + 18.42 + + + + \ No newline at end of file diff --git a/config-optic/qa-data/mapperReducer.sjs b/config-optic/qa-data/mapperReducer.sjs new file mode 100644 index 00000000..5c1af234 --- /dev/null +++ b/config-optic/qa-data/mapperReducer.sjs @@ -0,0 +1,92 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +function arrayMapper(row) { + const result = row.concat(); + result.push((typeof result[0] === 'string') ? 'seconds' : + fn.floor(fn.secondsFromDateTime(fn.currentDateTime())) + ); + return result; +} + +function colorIdMapper(row) { + const result = row; + switch(result.myColorId) { + case 1: + result.myColorId = 'RED'; + break; + case 2: + result.myColorId = 'BLUE'; + break; + case 3: + result.myColorId = 'YELLOW'; + break; + case 4: + result.myColorId = 'BLACK'; + break; + default: + result.myColorId = 'NO COLOR'; + } + return result; +} + +function arrayReducer(previous, row) { + const val = (previous === void 0) ? 0 : previous + row[0]; + return val; +} + +function fibReducer(previous, row) { + const i = Array.isArray(previous) ? previous.length : 0; + const result = row; + result.i = i; + switch(i) { + case 0: + result.fib = 0; + break; + case 1: + result.fib = 1; + break; + default: + result.fib = previous[i - 2].fib + previous[i - 1].fib; + break; + } + if (previous === void 0) { + previous = [result]; + } else { + previous.push(result); + } + return previous; +} + +function ageMapper(row) { + const result = row; + if(result.player_age < 21) + result.player_age = 'rookie'; + else if(result.player_age > 21 && result.player_age < 30) + result.player_age = 'premium'; + else + result.player_age = 'veteran'; + return result; +} + +module.exports = { + arrayMapper: arrayMapper, + colorIdMapper: colorIdMapper, + ageMapper: ageMapper, + arrayReducer: arrayReducer, + fibReducer: fibReducer +}; diff --git a/config-optic/qa-data/masterDetail.tdex b/config-optic/qa-data/masterDetail.tdex new file mode 100755 index 00000000..4f479c01 --- /dev/null +++ b/config-optic/qa-data/masterDetail.tdex @@ -0,0 +1,35 @@ + diff --git a/config-optic/qa-data/masterDetail.xml b/config-optic/qa-data/masterDetail.xml new file mode 100755 index 00000000..412f27e8 --- /dev/null +++ b/config-optic/qa-data/masterDetail.xml @@ -0,0 +1,59 @@ + + + + 1 + Master 1 + 2015-12-01 + + + 2 + Master 2 + 2015-12-02 + + + + + 1 + Detail 1 + 1 + 10.01 + blue + + + 2 + Detail 2 + 2 + 20.02 + blue + + + 3 + Detail 3 + 1 + 30.03 + blue + + + 4 + Detail 4 + 2 + 40.04 + green + + + 5 + Detail 5 + 1 + 50.05 + green + + + 6 + Detail 6 + 2 + 60.06 + green + + + + diff --git a/config-optic/qa-data/masterDetail2.json b/config-optic/qa-data/masterDetail2.json new file mode 100755 index 00000000..c11cccf2 --- /dev/null +++ b/config-optic/qa-data/masterDetail2.json @@ -0,0 +1,64 @@ +{ + "sets2": { + "masterSet": { + "master": [ + { + "id": "3", + "name": "Master 3", + "date": "2016-03-01" + }, + { + "id": "4", + "name": "Master 4", + "date": "2016-05-25" + } + ] + }, + "detailSet": { + "detail": [ + { + "id": "7", + "name": "Detail 7", + "masterId": "3", + "amount": "64.33", + "color": "red" + }, + { + "id": "8", + "name": "Detail 8", + "masterId": "4", + "amount": "89.36", + "color": "blue" + }, + { + "id": "9", + "name": "Detail 9", + "masterId": "1", + "amount": "72.90", + "color": "yellow" + }, + { + "id": "10", + "name": "Detail 10", + "masterId": "2", + "amount": "30.26", + "color": "black" + }, + { + "id": "11", + "name": "Detail 11", + "masterId": "3", + "amount": "82.04", + "color": "green" + }, + { + "id": "12", + "name": "Detail 12", + "masterId": "1", + "amount": "25.86", + "color": "red" + } + ] + } + } +} diff --git a/config-optic/qa-data/masterDetail2.tdej b/config-optic/qa-data/masterDetail2.tdej new file mode 100755 index 00000000..40463213 --- /dev/null +++ b/config-optic/qa-data/masterDetail2.tdej @@ -0,0 +1,53 @@ +{ + "template": { + "context": "/sets2", + "templates": [{ + "context": "masterSet/master", + "rows": [{ + "schemaName": "opticFunctionalTest2", + "viewName": "master", + "columns": [{ + "name": "id", + "scalarType": "int", + "val": "id" + }, { + "name": "name", + "scalarType": "string", + "val": "name" + }, { + "name": "date", + "scalarType": "date", + "val": "date" + }] + }] + }, { + "context": "detailSet/detail", + "rows": [{ + "schemaName": "opticFunctionalTest2", + "viewName": "detail", + "columns": [{ + "name": "id", + "scalarType": "int", + "val": "id" + }, { + "name": "name", + "scalarType": "string", + "val": "name" + }, { + "name": "masterId", + "scalarType": "int", + "val": "masterId" + }, { + "name": "amount", + "scalarType": "double", + "val": "amount" + }, { + "name": "color", + "scalarType": "string", + "val": "color" + }] + }] + }] + } +} + diff --git a/config-optic/qa-data/masterDetail3.json b/config-optic/qa-data/masterDetail3.json new file mode 100755 index 00000000..cac14f0b --- /dev/null +++ b/config-optic/qa-data/masterDetail3.json @@ -0,0 +1,64 @@ +{ + "sets3": { + "masterSet3": { + "master3": [ + { + "id": "3", + "name": "Master 3", + "date": "2016-03-01" + }, + { + "id": "4", + "name": "Master 4", + "date": "2016-05-25" + } + ] + }, + "detailSet3": { + "detail3": [ + { + "id": "7", + "name": "Detail 7", + "masterId": "3", + "amount": "64.33", + "color": "red" + }, + { + "id": "8", + "name": "Detail 8", + "masterId": "4", + "amount": "89.36", + "color": "blue" + }, + { + "id": "9", + "name": "Detail 9", + "masterId": "1", + "amount": "72.90", + "color": "yellow" + }, + { + "id": "10", + "name": "Detail 10", + "masterId": "2", + "amount": "30.26", + "color": "black" + }, + { + "id": "11", + "name": "Detail 11", + "masterId": "3", + "amount": "82.04", + "color": "green" + }, + { + "id": "12", + "name": "Detail 12", + "masterId": "1", + "amount": "25.86", + "color": "red" + } + ] + } + } +} diff --git a/config-optic/qa-data/masterDetail3.tdej b/config-optic/qa-data/masterDetail3.tdej new file mode 100755 index 00000000..d702b049 --- /dev/null +++ b/config-optic/qa-data/masterDetail3.tdej @@ -0,0 +1,53 @@ +{ + "template": { + "context": "/sets3", + "templates": [{ + "context": "masterSet3/master3", + "rows": [{ + "schemaName": "opticFunctionalTest3", + "viewName": "master3", + "columns": [{ + "name": "id", + "scalarType": "int", + "val": "id" + }, { + "name": "name", + "scalarType": "string", + "val": "name" + }, { + "name": "date", + "scalarType": "date", + "val": "date" + }] + }] + }, { + "context": "detailSet3/detail3", + "rows": [{ + "schemaName": "opticFunctionalTest3", + "viewName": "detail3", + "columns": [{ + "name": "id", + "scalarType": "int", + "val": "id" + }, { + "name": "name", + "scalarType": "string", + "val": "name" + }, { + "name": "masterId", + "scalarType": "int", + "val": "masterId" + }, { + "name": "amount", + "scalarType": "double", + "val": "amount" + }, { + "name": "color", + "scalarType": "string", + "val": "color" + }] + }] + }] + } +} + diff --git a/config-optic/qa-data/masterDetail4.json b/config-optic/qa-data/masterDetail4.json new file mode 100755 index 00000000..3650a387 --- /dev/null +++ b/config-optic/qa-data/masterDetail4.json @@ -0,0 +1,43 @@ +{ + "sets4": { + "masterSet4": { + "master4": [ + { + "id": "100", + "name": "Master 100", + "date": "2016-03-11" + }, + { + "id": "200", + "name": "Master 200", + "date": "2016-04-02" + } + ] + }, + "detailSet4": { + "detail4": [ + { + "id": "100", + "name": "Detail 100", + "masterId": "100", + "amount": "64.33", + "color": "red" + }, + { + "id": "200", + "name": "Detail 200", + "masterId": "200", + "amount": "89.36", + "color": "blue" + }, + { + "id": "300", + "name": "Detail 300", + "masterId": "200", + "amount": "72.90", + "color": "yellow" + } + ] + } + } +} diff --git a/config-optic/qa-data/masterDetail4.tdej b/config-optic/qa-data/masterDetail4.tdej new file mode 100755 index 00000000..7d026ce4 --- /dev/null +++ b/config-optic/qa-data/masterDetail4.tdej @@ -0,0 +1,53 @@ +{ + "template": { + "context": "/sets4", + "templates": [{ + "context": "masterSet4/master4", + "rows": [{ + "schemaName": "opticFunctionalTest4", + "viewName": "master4", + "columns": [{ + "name": "id", + "scalarType": "int", + "val": "id" + }, { + "name": "name", + "scalarType": "string", + "val": "name" + }, { + "name": "date", + "scalarType": "date", + "val": "date" + }] + }] + }, { + "context": "detailSet4/detail4", + "rows": [{ + "schemaName": "opticFunctionalTest4", + "viewName": "detail4", + "columns": [{ + "name": "id", + "scalarType": "int", + "val": "id" + }, { + "name": "name", + "scalarType": "string", + "val": "name" + }, { + "name": "masterId", + "scalarType": "int", + "val": "masterId" + }, { + "name": "amount", + "scalarType": "double", + "val": "amount" + }, { + "name": "color", + "scalarType": "string", + "val": "color" + }] + }] + }] + } +} + diff --git a/config-optic/qa-data/masterDetail5.json b/config-optic/qa-data/masterDetail5.json new file mode 100755 index 00000000..be57f67e --- /dev/null +++ b/config-optic/qa-data/masterDetail5.json @@ -0,0 +1,29 @@ +{ + "sets4": { + "detailSet4": { + "detail4": [ + { + "id": "400", + "name": "Detail 400", + "masterId": "200", + "amount": "164.33", + "color": "purple" + }, + { + "id": "500", + "name": "Detail 500", + "masterId": "100", + "amount": "189.36", + "color": "gold" + }, + { + "id": "600", + "name": "Detail 600", + "masterId": "100", + "amount": "172.90", + "color": "white" + } + ] + } + } +} diff --git a/config-optic/qa-data/otherPlayerTripleSet.xml b/config-optic/qa-data/otherPlayerTripleSet.xml new file mode 100755 index 00000000..9314362f --- /dev/null +++ b/config-optic/qa-data/otherPlayerTripleSet.xml @@ -0,0 +1,87 @@ + + + + + http://marklogic.com/other/bball/id#101 + http://marklogic.com/other/bball/players#name + Phil Green + + + http://marklogic.com/other/bball/id#101 + http://marklogic.com/other/bball/players#type + http://marklogic.com/other/bball/players/bbtype/Dataset + + + http://marklogic.com/other/bball/id#101 + http://marklogic.com/other/bball/players#description + Describing Phil Green + + + http://marklogic.com/other/bball/id#101 + http://marklogic.com/other/bball/players#position + Shortstop + + + http://marklogic.com/other/bball/id#101 + http://marklogic.com/other/bball/players#dob + 1985-03-27 + + + http://marklogic.com/other/bball/id#101 + http://marklogic.com/other/bball/players#eff + 82.03 + + + http://marklogic.com/other/bball/id#101 + http://marklogic.com/other/bball/players#age + 26 + + + http://marklogic.com/other/bball/id#101 + http://marklogic.com/other/bball/players#team + http://marklogic.com/mlb/team/id/003 + + + http://marklogic.com/other/bball/id#102 + http://marklogic.com/other/bball/players#name + Sam Cho + + + http://marklogic.com/other/bball/id#102 + http://marklogic.com/other/bball/players#type + http://marklogic.com/other/bball/players/bbtype/Dataset + + + http://marklogic.com/other/bball/id#102 + http://marklogic.com/other/bball/players#description + Describing Sam Cho + + + http://marklogic.com/other/bball/id#102 + http://marklogic.com/other/bball/players#position + Center Field + + + http://marklogic.com/other/bball/id#102 + http://marklogic.com/other/bball/players#dob + 1993-02-08 + + + http://marklogic.com/other/bball/id#102 + http://marklogic.com/other/bball/players#eff + 21.99 + + + http://marklogic.com/other/bball/id#102 + http://marklogic.com/other/bball/players#age + 22 + + + http://marklogic.com/other/bball/id#102 + http://marklogic.com/other/bball/players#team + http://marklogic.com/mlb/team/id/006 + + + + + diff --git a/config-optic/qa-data/people.ttl b/config-optic/qa-data/people.ttl new file mode 100644 index 00000000..de6cf435 --- /dev/null +++ b/config-optic/qa-data/people.ttl @@ -0,0 +1,70 @@ +@prefix foaf: . +@prefix ppl: . + +ppl:person1 foaf:knows ppl:person2 . +ppl:person1 foaf:knows ppl:person3 . +ppl:person1 foaf:knows ppl:person5 . +ppl:person1 foaf:knows ppl:person7 . + +ppl:person2 foaf:knows ppl:person11 . +ppl:person2 foaf:knows ppl:person3 . +ppl:person3 foaf:knows ppl:person13 . +ppl:person13 foaf:knows ppl:person17 . +ppl:person13 foaf:knows ppl:person19 . + +ppl:person4 foaf:knows ppl:person6 . +ppl:person6 foaf:knows ppl:person8 . +ppl:person8 foaf:knows ppl:person10 . +ppl:person10 foaf:knows ppl:person12 . +ppl:person12 foaf:knows ppl:person14 . +ppl:person14 foaf:knows ppl:person16 . +ppl:person16 foaf:knows ppl:person18 . +ppl:person18 foaf:knows ppl:person20 . + +ppl:person20 foaf:knows ppl:person20 . + +ppl:person9 foaf:knows ppl:person12 . +ppl:person12 foaf:knows ppl:person15 . +ppl:person15 foaf:knows ppl:person18 . +ppl:person18 foaf:knows ppl:person9 . + +ppl:person1 a ppl:Person ; + foaf:name "Person 1" . +ppl:person2 a ppl:Person ; + foaf:name "Person 2" . +ppl:person3 a ppl:Person ; + foaf:name "Person 3" . +ppl:person4 a ppl:Person ; + foaf:name "Person 4" . +ppl:person5 a ppl:Person ; + foaf:name "Person 5" . +ppl:person6 a ppl:Person ; + foaf:name "Person 6" . +ppl:person7 a ppl:Person ; + foaf:name "Person 7" . +ppl:person8 a ppl:Person ; + foaf:name "Person 8" . +ppl:person9 a ppl:Person ; + foaf:name "Person 9" . +ppl:person10 a ppl:Person ; + foaf:name "Person 10" . +ppl:person11 a ppl:Person ; + foaf:name "Person 11" . +ppl:person12 a ppl:Person ; + foaf:name "Person 12" . +ppl:person13 a ppl:Person ; + foaf:name "Person 13" . +ppl:person14 a ppl:Person ; + foaf:name "Person 14" . +ppl:person15 a ppl:Person ; + foaf:name "Person 15" . +ppl:person16 a ppl:Person ; + foaf:name "Person 16" . +ppl:person17 a ppl:Person ; + foaf:name "Person 17" . +ppl:person18 a ppl:Person ; + foaf:name "Person 18" . +ppl:person19 a ppl:Person ; + foaf:name "Person 19" . +ppl:person20 a ppl:Person ; + foaf:name "Person 20" . diff --git a/config-optic/qa-data/planLexicons.json b/config-optic/qa-data/planLexicons.json new file mode 100644 index 00000000..66b82e6f --- /dev/null +++ b/config-optic/qa-data/planLexicons.json @@ -0,0 +1,2 @@ +{"$optic":{"ns":"op", "fn":"operators", "args":[{"ns":"op", "fn":"from-lexicons", "args":[{"uri1":{"uriReference":{}}, "city":{"jsonPropertyReference":{"property":"city", "scalarType":"string", "collation":"http://marklogic.com/collation/", "nullable":false}}, "popularity":{"jsonPropertyReference":{"property":"popularity", "scalarType":"int", "nullable":false}}, "date":{"jsonPropertyReference":{"property":"date", "scalarType":"date", "nullable":false}}, "distance":{"jsonPropertyReference":{"property":"distance", "scalarType":"double", "nullable":false}}, "point":{"jsonPropertyReference":{"property":"latLonPoint", "scalarType":"point", "coordinateSystem":"wgs84", "nullable":false}}}, "myCity", {"ns":"op", "fn":"fragment-id-col", "args":["fragId1"]}]}, {"ns":"op", "fn":"join-inner", "args":[{"ns":"op", "fn":"operators", "args":[{"ns":"op", "fn":"from-lexicons", "args":[{"uri2":{"uriReference":{}}, "cityName":{"jsonPropertyReference":{"property":"cityName", "scalarType":"string", "collation":"http://marklogic.com/collation/", "nullable":false}}, "cityTeam":{"jsonPropertyReference":{"property":"cityTeam", "scalarType":"string", "collation":"http://marklogic.com/collation/", "nullable":false}}}, "myTeam", {"ns":"op", "fn":"fragment-id-col", "args":["fragId2"]}]}]}, null, null]}, {"ns":"op", "fn":"where", "args":[{"ns":"op", "fn":"eq", "args":[{"ns":"op", "fn":"viewCol", "args":["myCity", "city"]}, {"ns":"op", "fn":"col", "args":["cityName"]}]}]}, {"ns":"op", "fn":"order-by", "args":[[{"ns":"op", "fn":"asc", "args":[{"ns":"op", "fn":"col", "args":["date"]}]}]]}]}} + diff --git a/config-optic/qa-data/planSPARQL.json b/config-optic/qa-data/planSPARQL.json new file mode 100644 index 00000000..bd102685 --- /dev/null +++ b/config-optic/qa-data/planSPARQL.json @@ -0,0 +1 @@ +{"$optic":{"ns":"op", "fn":"operators", "args":[{"ns":"op", "fn":"from-sparql", "args":["PREFIX demov: PREFIX vcard: SELECT ?industry (SUM (?sales) AS ?sum_sales ) FROM WHERE { ?company a vcard:Organization . ?company demov:sales ?sales . ?company demov:industry ?industry } GROUP BY ?industry ORDER BY ?sum_sales", "MySPARQL"]}, {"ns":"op", "fn":"select", "args":[[{"ns":"op", "fn":"viewCol", "args":["MySPARQL", "industry"]}, {"ns":"op", "fn":"as", "args":["doubleSales", {"ns":"op", "fn":"multiply", "args":[{"ns":"op", "fn":"viewCol", "args":["MySPARQL", "sum_sales"]}, "2"]}]}, {"ns":"op", "fn":"as", "args":["discount", {"ns":"op", "fn":"divide", "args":[{"ns":"op", "fn":"viewCol", "args":["MySPARQL", "sum_sales"]}, "10"]}]}], null]}]}} diff --git a/config-optic/qa-data/planSQL.json b/config-optic/qa-data/planSQL.json new file mode 100644 index 00000000..0a433761 --- /dev/null +++ b/config-optic/qa-data/planSQL.json @@ -0,0 +1 @@ +{"$optic":{"ns":"op", "fn":"operators", "args":[{"ns":"op", "fn":"from-sql", "args":["SELECT * FROM opticFunctionalTest.detail INNER JOIN opticFunctionalTest.master WHERE (opticFunctionalTest.detail.masterId = opticFunctionalTest.master.id AND opticFunctionalTest.master.id = opticFunctionalTest.detail.id)", null]}, {"ns":"op", "fn":"order-by", "args":[[{"ns":"op", "fn":"desc", "args":[{"ns":"op", "fn":"viewCol", "args":["detail", "name"]}]}]]}, {"ns":"op", "fn":"offset-limit", "args":[1, 100]}]}} diff --git a/config-optic/qa-data/planTriples.json b/config-optic/qa-data/planTriples.json new file mode 100644 index 00000000..192553b8 --- /dev/null +++ b/config-optic/qa-data/planTriples.json @@ -0,0 +1,165 @@ +{ + "$optic": { + "ns": "op", + "fn": "operators", + "args": [{ + "ns": "op", + "fn": "from-triples", + "args": [ + [{ + "ns": "op", + "fn": "pattern", + "args": [ + [{ + "ns": "op", + "fn": "col", + "args": ["player_id"] + }], + [{ + "ns": "sem", + "fn": "iri", + "args": ["http://marklogic.com/other/bball/players#age"] + }], + [{ + "ns": "op", + "fn": "col", + "args": ["player_age"] + }], null + ] + }, { + "ns": "op", + "fn": "pattern", + "args": [ + [{ + "ns": "op", + "fn": "col", + "args": ["player_id"] + }], + [{ + "ns": "sem", + "fn": "iri", + "args": ["http://marklogic.com/other/bball/players#name"] + }], + [{ + "ns": "op", + "fn": "col", + "args": ["player_name"] + }], null + ] + }, { + "ns": "op", + "fn": "pattern", + "args": [ + [{ + "ns": "op", + "fn": "col", + "args": ["player_id"] + }], + [{ + "ns": "sem", + "fn": "iri", + "args": ["http://marklogic.com/other/bball/players#team"] + }], + [{ + "ns": "op", + "fn": "col", + "args": ["player_team"] + }], null + ] + }], "myPlayer", null, null + ] + }, { + "ns": "op", + "fn": "join-left-outer", + "args": [{ + "ns": "op", + "fn": "operators", + "args": [{ + "ns": "op", + "fn": "from-triples", + "args": [ + [{ + "ns": "op", + "fn": "pattern", + "args": [ + [{ + "ns": "op", + "fn": "col", + "args": ["team_id"] + }], + [{ + "ns": "sem", + "fn": "iri", + "args": ["http://marklogic.com/mlb/team/name"] + }], + [{ + "ns": "op", + "fn": "col", + "args": ["team_name"] + }], null + ] + }, { + "ns": "op", + "fn": "pattern", + "args": [ + [{ + "ns": "op", + "fn": "col", + "args": ["team_id"] + }], + [{ + "ns": "sem", + "fn": "iri", + "args": ["http://marklogic.com/mlb/team/city"] + }], + [{ + "ns": "op", + "fn": "col", + "args": ["team_city"] + }], null + ] + }], "myTeam", null, null + ] + }] + }, + [{ + "ns": "op", + "fn": "on", + "args": [{ + "ns": "op", + "fn": "col", + "args": ["player_team"] + }, { + "ns": "op", + "fn": "col", + "args": ["team_id"] + }] + }], null + ] + }, { + "ns": "op", + "fn": "where", + "args": [{ + "ns": "op", + "fn": "and", + "args": [{ + "ns": "op", + "fn": "gt", + "args": [{ + "ns": "op", + "fn": "col", + "args": ["player_age"] + }, 20] + }, { + "ns": "op", + "fn": "is-defined", + "args": [{ + "ns": "op", + "fn": "col", + "args": ["team_name"] + }] + }] + }] + }] + } +} diff --git a/config-optic/qa-data/planViews.json b/config-optic/qa-data/planViews.json new file mode 100644 index 00000000..05640966 --- /dev/null +++ b/config-optic/qa-data/planViews.json @@ -0,0 +1 @@ +{"$optic":{"ns":"op", "fn":"operators", "args":[{"ns":"op", "fn":"from-view", "args":["opticFunctionalTest", "detail", "myDetail", null]}, {"ns":"op", "fn":"join-inner", "args":[{"ns":"op", "fn":"operators", "args":[{"ns":"op", "fn":"from-view", "args":["opticFunctionalTest", "master", "myMaster", null]}]}, [{"ns":"op", "fn":"on", "args":[{"ns":"op", "fn":"viewCol", "args":["myDetail", "masterId"]}, {"ns":"op", "fn":"viewCol", "args":["myMaster", "id"]}]}, {"ns":"op", "fn":"on", "args":[{"ns":"op", "fn":"viewCol", "args":["myMaster", "id"]}, {"ns":"op", "fn":"viewCol", "args":["myDetail", "id"]}]}], null]}, {"ns":"op", "fn":"order-by", "args":[[{"ns":"op", "fn":"desc", "args":[{"ns":"op", "fn":"viewCol", "args":["myDetail", "name"]}]}]]}, {"ns":"op", "fn":"offset-limit", "args":[1, 100]}]}} diff --git a/config-optic/qa-data/playerTripleSet.xml b/config-optic/qa-data/playerTripleSet.xml new file mode 100755 index 00000000..c7345106 --- /dev/null +++ b/config-optic/qa-data/playerTripleSet.xml @@ -0,0 +1,376 @@ + + + + + http://marklogic.com/baseball/id#001 + http://marklogic.com/baseball/players/name + John Doe + + + http://marklogic.com/baseball/id#001 + http://marklogic.com/baseball/players/type + http://marklogic.com/baseball/players/bbtype/Dataset + + + http://marklogic.com/baseball/id#001 + http://marklogic.com/baseball/players/description + Describing John Doe + + + http://marklogic.com/baseball/id#001 + http://marklogic.com/baseball/players/position + Pitcher + + + http://marklogic.com/baseball/id#001 + http://marklogic.com/baseball/players/dob + 1981-05-04 + + + http://marklogic.com/baseball/id#001 + http://marklogic.com/baseball/players/eff + 25.45 + + + http://marklogic.com/baseball/id#001 + http://marklogic.com/baseball/players/age + 31 + + + http://marklogic.com/baseball/id#001 + http://marklogic.com/baseball/players/team + http://marklogic.com/mlb/team/id/001 + + + http://marklogic.com/baseball/id#002 + http://marklogic.com/baseball/players/name + Bob Brian + + + http://marklogic.com/baseball/id#002 + http://marklogic.com/baseball/players/type + http://marklogic.com/baseball/players/bbtype/Dataset + + + http://marklogic.com/baseball/id#002 + http://marklogic.com/baseball/players/description + Describing Bob Brian + + + http://marklogic.com/baseball/id#002 + http://marklogic.com/baseball/players/position + Outfielder + + + http://marklogic.com/baseball/id#002 + http://marklogic.com/baseball/players/dob + 1999-01-15 + + + http://marklogic.com/baseball/id#002 + http://marklogic.com/baseball/players/eff + 78.45 + + + http://marklogic.com/baseball/id#002 + http://marklogic.com/baseball/players/age + 23 + + + http://marklogic.com/baseball/id#002 + http://marklogic.com/baseball/players/team + http://marklogic.com/mlb/team/id/003 + + + http://marklogic.com/baseball/id#003 + http://marklogic.com/baseball/players/name + Josh Ream + + + http://marklogic.com/baseball/id#003 + http://marklogic.com/baseball/players/type + http://marklogic.com/baseball/players/bbtype/Dataset + + + http://marklogic.com/baseball/id#003 + http://marklogic.com/baseball/players/description + Describing Josh Ream + + + http://marklogic.com/baseball/id#003 + http://marklogic.com/baseball/players/position + Pitcher + + + http://marklogic.com/baseball/id#003 + http://marklogic.com/baseball/players/dob + 1985-11-30 + + + http://marklogic.com/baseball/id#003 + http://marklogic.com/baseball/players/eff + 53.10 + + + http://marklogic.com/baseball/id#003 + http://marklogic.com/baseball/players/age + 29 + + + http://marklogic.com/baseball/id#003 + http://marklogic.com/baseball/players/team + http://marklogic.com/mlb/team/id/001 + + + http://marklogic.com/baseball/id#004 + http://marklogic.com/baseball/players/name + Pat Crenshaw + + + http://marklogic.com/baseball/id#004 + http://marklogic.com/baseball/players/type + http://marklogic.com/baseball/players/bbtype/Dataset + + + http://marklogic.com/baseball/id#004 + http://marklogic.com/baseball/players/description + Describing Pat Crenshaw + + + http://marklogic.com/baseball/id#004 + http://marklogic.com/baseball/players/position + Catcher + + + http://marklogic.com/baseball/id#004 + http://marklogic.com/baseball/players/dob + 1998-09-01 + + + http://marklogic.com/baseball/id#004 + http://marklogic.com/baseball/players/eff + 33.89 + + + http://marklogic.com/baseball/id#004 + http://marklogic.com/baseball/players/age + 25 + + + http://marklogic.com/baseball/id#004 + http://marklogic.com/baseball/players/team + http://marklogic.com/mlb/team/id/005 + + + + + http://marklogic.com/baseball/id#005 + http://marklogic.com/baseball/players/name + Pedro Barrozo + + + http://marklogic.com/baseball/id#005 + http://marklogic.com/baseball/players/type + http://marklogic.com/baseball/players/bbtype/Dataset + + + http://marklogic.com/baseball/id#005 + http://marklogic.com/baseball/players/description + Describing Pedro Barrozo + + + http://marklogic.com/baseball/id#005 + http://marklogic.com/baseball/players/position + Midfielder + + + http://marklogic.com/baseball/id#005 + http://marklogic.com/baseball/players/dob + 1991-12-09 + + + http://marklogic.com/baseball/id#005 + http://marklogic.com/baseball/players/eff + 41.65 + + + http://marklogic.com/baseball/id#005 + http://marklogic.com/baseball/players/age + 19 + + + http://marklogic.com/baseball/id#005 + http://marklogic.com/baseball/players/team + http://marklogic.com/mlb/team/id/002 + + + + + http://marklogic.com/baseball/id#006 + http://marklogic.com/baseball/players/name + Aoki Yamada + + + http://marklogic.com/baseball/id#006 + http://marklogic.com/baseball/players/type + http://marklogic.com/baseball/players/bbtype/Dataset + + + http://marklogic.com/baseball/id#006 + http://marklogic.com/baseball/players/description + Describing Aoki Yamada + + + http://marklogic.com/baseball/id#006 + http://marklogic.com/baseball/players/position + First Base + + + http://marklogic.com/baseball/id#006 + http://marklogic.com/baseball/players/dob + 1987-03-15 + + + http://marklogic.com/baseball/id#006 + http://marklogic.com/baseball/players/eff + 55.2 + + + http://marklogic.com/baseball/id#006 + http://marklogic.com/baseball/players/age + 34 + + + http://marklogic.com/baseball/id#006 + http://marklogic.com/baseball/players/team + http://marklogic.com/mlb/team/id/003 + + + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/name + Matt Rose + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/type + http://marklogic.com/baseball/players/bbtype/Dataset + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/description + Describing Matt Rose + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/position + Pitcher + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/dob + 1984-11-01 + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/eff + 32.89 + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/age + 29 + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/team + http://marklogic.com/mlb/team/id/005 + + + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/name + Matt Rose + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/type + http://marklogic.com/baseball/players/bbtype/Dataset + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/description + Describing Matt Rose + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/position + Pitcher + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/dob + 1984-11-01 + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/eff + 32.89 + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/age + 29 + + + http://marklogic.com/baseball/id#007 + http://marklogic.com/baseball/players/team + http://marklogic.com/mlb/team/id/005 + + + + + http://marklogic.com/baseball/id#008 + http://marklogic.com/baseball/players/name + Juan Leone + + + http://marklogic.com/baseball/id#008 + http://marklogic.com/baseball/players/type + http://marklogic.com/baseball/players/bbtype/Dataset + + + http://marklogic.com/baseball/id#008 + http://marklogic.com/baseball/players/description + Describing Juan Leone + + + http://marklogic.com/baseball/id#008 + http://marklogic.com/baseball/players/position + Second Base + + + http://marklogic.com/baseball/id#008 + http://marklogic.com/baseball/players/dob + 1993-08-17 + + + http://marklogic.com/baseball/id#008 + http://marklogic.com/baseball/players/eff + 29.77 + + + http://marklogic.com/baseball/id#008 + http://marklogic.com/baseball/players/age + 27 + + + http://marklogic.com/baseball/id#008 + http://marklogic.com/baseball/players/team + http://marklogic.com/mlb/team/id/001 + + + + diff --git a/config-optic/qa-data/teamTripleSet.xml b/config-optic/qa-data/teamTripleSet.xml new file mode 100755 index 00000000..9e18ba09 --- /dev/null +++ b/config-optic/qa-data/teamTripleSet.xml @@ -0,0 +1,56 @@ + + + + + http://marklogic.com/mlb/team/id/001 + http://marklogic.com/mlb/team/name + Giants + + + http://marklogic.com/mlb/team/id/001 + http://marklogic.com/mlb/team/city + San Francisco + + + http://marklogic.com/mlb/team/id/002 + http://marklogic.com/mlb/team/name + Athletics + + + http://marklogic.com/mlb/team/id/002 + http://marklogic.com/mlb/team/city + Oakland + + + http://marklogic.com/mlb/team/id/003 + http://marklogic.com/mlb/team/name + Padres + + + http://marklogic.com/mlb/team/id/003 + http://marklogic.com/mlb/team/city + San Diego + + + http://marklogic.com/mlb/team/id/004 + http://marklogic.com/mlb/team/name + Yankees + + + http://marklogic.com/mlb/team/id/004 + http://marklogic.com/mlb/team/city + New York + + + http://marklogic.com/mlb/team/id/005 + http://marklogic.com/mlb/team/name + Mariners + + + http://marklogic.com/mlb/team/id/005 + http://marklogic.com/mlb/team/city + Seattle + + + + \ No newline at end of file diff --git a/config-optic/setupqa.js b/config-optic/setupqa.js new file mode 100755 index 00000000..22a07b2e --- /dev/null +++ b/config-optic/setupqa.js @@ -0,0 +1,130 @@ +/* + * Copyright 2015 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +var util = require('../node_modules/core-util-is/lib/util.js'); + +var fs = require('fs'); +var valcheck = require('core-util-is'); + +var marklogic = require('../lib/marklogic.js'); +var testlib = require('./testlib.js'); + +var clientConnectdef = require('./connectdef.js'); +var testName = clientConnectdef.name; +var planServerdef = clientConnectdef.plan; + +var testLoad = require('./loaddata.js'); +var testUser = require('./userconfig.js'); + +var db = marklogic.createDatabaseClient({ + host: planServerdef.host, + port: planServerdef.port, + user: 'admin', + password: 'admin', + authType: planServerdef.authType +}); +var dbMod = marklogic.createDatabaseClient({ + database: testName+'Modules', + host: planServerdef.host, + port: planServerdef.port, + user: 'admin', + password: 'admin', + authType: planServerdef.authType +}); +var manager = testlib.createManager(marklogic.createDatabaseClient({ + host: planServerdef.host, + port: 8002, + user: 'admin', + password: 'admin', + authType: planServerdef.authType + })); + +console.log('checking for '+testName); +var check = manager.get({ + endpoint: '/v1/rest-apis/'+testName + }).result(); +check.then(function(response) { + if (response.statusCode !== 404) { + return check; + } + + console.log('creating database and REST server for '+testName); + return manager.post({ + endpoint: '/v1/rest-apis', + body: { + 'rest-api': { + name: testName, + group: 'Default', + database: testName, + 'modules-database': testName+'Modules', + port: planServerdef.port + } + } + }).result(); + }) +.then(function(response){ + console.log('setting up rest eval role'); + return testUser.addRestEvalRole(manager).result(); +}) +.then(function(response){ + console.log('setting up rest eval user'); + return testUser.addRestEvalUser(manager).result(); +}) +.then(function(response){ + console.log('setting up rest reader user'); + return testUser.addRestReaderUser(manager).result(); +}) +.then(function(response){ + console.log('setting up tde template on module database'); + return testLoad.writeDocumentsToMod(dbMod).result(); +}) +.then(function(response){ + console.log('setting up sample documents'); + return testLoad.writeDocuments(db).result(); +}) +.then(function(response){ + console.log('setting up graphs1'); + return testLoad.writeGraphs1(db).result(); +}) +.then(function(response){ + console.log('setting up graphs2'); + return testLoad.writeGraphs2(db).result(); +}) +.then(function(response){ + console.log('setting up database setup file'); + return db.config.extlibs.write({ + path:'/ext/optic/test/databaseconfig.sjs', contentType:'application/javascript', source:fs.createReadStream('./config-optic/databaseconfig.sjs') + }).result(); +}) +.then(function(response) { + console.log('setting up database configuration'); + var dbEval = marklogic.createDatabaseClient({ + host: planServerdef.host, + port: planServerdef.port, + user: 'rest-evaluator', + password: 'x', + authType: planServerdef.authType + }); + return dbEval.invoke('/ext/optic/test/databaseconfig.sjs').result(); +}) +.then(function(response){ + console.log('setup done'); + }) +.catch(function(error){ + console.log('error'); + console.log(util.inspect(error, {depth:null})); + }); diff --git a/config-optic/teardown.js b/config-optic/teardown.js new file mode 100644 index 00000000..a7f332f5 --- /dev/null +++ b/config-optic/teardown.js @@ -0,0 +1,112 @@ +/* + * Copyright 2015 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +var util = require('../node_modules/core-util-is/lib/util.js'); + +var fs = require('fs'); +var valcheck = require('core-util-is'); + +var marklogic = require('../lib/marklogic.js'); +var testlib = require('./testlib.js'); + +var clientConnectdef = require('./connectdef.js'); +var testName = clientConnectdef.name; +var planServerdef = clientConnectdef.plan; + +var modDb = marklogic.createDatabaseClient({ + database: testName+'Modules', + host: planServerdef.host, + port: planServerdef.port, + user: 'admin', + password: 'admin', + authType: planServerdef.authType +}); +var manager = testlib.createManager(marklogic.createDatabaseClient({ + host: planServerdef.host, + port: 8002, + user: 'admin', + password: 'admin', + authType: planServerdef.authType + })); + +console.log('checking for '+testName); +manager.get({ + endpoint: '/v1/rest-apis/'+testName + }) +.result(function(response) { + if (response.statusCode === 404) { + console.log(testName+' not found - nothing to delete'); + } else { + console.log('removing database and REST server for '+testName); + manager.put({ + endpoint: '/manage/v2/databases/'+testName+'/properties', + params: { + format: 'json' + }, + body: { + 'schema-database': 'Schemas' + }, + hasResponse: true + }).result() + .then(function(response) { + return manager.post({ + endpoint: '/manage/v2/databases/'+testName, + contentType: 'application/json', + accept: 'application/json', + body: {'operation': 'clear-database'} + }).result(); + }) + .then(function(response) { + return manager.post({ + endpoint: '/manage/v2/databases/'+testName+'Modules', + contentType: 'application/json', + accept: 'application/json', + body: {'operation': 'clear-database'} + }).result(); + }) + .then(function(response) { + return manager.remove({ + endpoint: '/manage/v2/users/rest-evaluator' + }).result(); + }) + .then(function(response) { + return manager.remove({ + endpoint: '/manage/v2/users/rest-reader-optic' + }).result(); + }) + .then(function(response) { + return manager.remove({ + endpoint: '/manage/v2/roles/rest-evaluator' + }).result(); + }) + .then(function(response) { + return manager.remove({ + endpoint: '/v1/rest-apis/'+testName, + accept: 'application/json', + params: {include: ['content', 'modules']} + }).result(); + }) + .then(function(response) { + console.log('teardown succeeded - restart the server'); + }) + .catch(function(error) { + console.log('failed to tear down '+testName+' server:\n'+ + JSON.stringify(error, null, 2)); + }); + } +}); + diff --git a/config-optic/testlib.js b/config-optic/testlib.js new file mode 100644 index 00000000..4d7919e1 --- /dev/null +++ b/config-optic/testlib.js @@ -0,0 +1,198 @@ +/* + * Copyright 2014-2015 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; +var valcheck = require('../node_modules/core-util-is/lib/util.js'); + +var mlutil = require('../lib/mlutil.js'); +var Operation = require('../lib/operation.js'); +var requester = require('../lib/requester.js'); + +//CAUTION: the functions in this module are not part of the supported API and +//may change or may be removed at any time. + +function responseOutputTransform(headers, data) { + /*jshint validthis:true */ + var operation = this; + + var response = { + statusCode: operation.responseStatusCode, + headers: headers + }; + if (!valcheck.isNullOrUndefined(data)) { + response.data = data; + } + + return response; +} + +function Manager(adminClient) { + if (!(this instanceof Manager)) { + return new Manager(adminClient); + } + this.client = adminClient; +} + +// TODO: configure acceptable errors +Manager.prototype.get = function manageGet(paramsObj) { + var endpoint = paramsObj.endpoint; + var params = paramsObj.params; + var headers = paramsObj.headers; + var hasResponse = paramsObj.hasResponse; + + var path = makePath(endpoint, params); + + var requestOptions = mlutil.copyProperties(this.client.connectionParams); + requestOptions.method = 'GET'; + requestOptions.headers = valcheck.isNullOrUndefined(headers) ? { + 'Accept': 'application/json' + } : headers; + requestOptions.path = path; + + var operation = new Operation( + 'GET '+path, this.client, requestOptions, 'empty', + ((hasResponse === 'false') ? 'empty' : 'single') + ); + operation.validStatusCodes = [200, 201, 204, 404]; + operation.outputTransform = responseOutputTransform; + + return requester.startRequest(operation); +}; +Manager.prototype.post = function managePost(paramsObj) { + var endpoint = paramsObj.endpoint; + var params = paramsObj.params; + var headers = paramsObj.headers; + var body = paramsObj.body; + var hasResponse = paramsObj.hasResponse; + + var path = makePath(endpoint, params); + + var requestOptions = mlutil.copyProperties(this.client.connectionParams); + requestOptions.method = 'POST'; + requestOptions.headers = valcheck.isNullOrUndefined(headers) ? { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } : headers; + requestOptions.path = path; + + var hasBody = !valcheck.isNullOrUndefined(body); + + var operation = new Operation( + 'POST '+path, + this.client, + requestOptions, + hasBody ? 'single' : 'empty', + ((hasResponse === 'false') ? 'empty' : 'single') + ); + operation.outputTransform = responseOutputTransform; + if (hasBody) { + operation.requestBody = body; + } + + return requester.startRequest(operation); +}; +Manager.prototype.put = function managePut(paramsObj) { + var endpoint = paramsObj.endpoint; + var params = paramsObj.params; + var headers = paramsObj.headers; + var body = paramsObj.body; + var hasResponse = paramsObj.hasResponse; + + var path = makePath(endpoint, params); + + var requestOptions = mlutil.copyProperties(this.client.connectionParams); + requestOptions.method = 'PUT'; + requestOptions.headers = valcheck.isNullOrUndefined(headers) ? { + 'Content-Type': 'application/json' + } : headers; + requestOptions.path = path; + + var hasBody = !valcheck.isNullOrUndefined(body); + + var operation = new Operation( + 'PUT '+path, + this.client, + requestOptions, + hasBody ? 'single' : 'empty', + ((hasResponse === 'true') ? 'single' : 'empty') + ); + operation.outputTransform = responseOutputTransform; + if (hasBody) { + operation.requestBody = body; + } + + return requester.startRequest(operation); +}; +Manager.prototype.remove = function manageRemove(paramsObj) { + var endpoint = paramsObj.endpoint; + var params = paramsObj.params; + var headers = paramsObj.headers; + var hasResponse = paramsObj.hasResponse; + + var path = makePath(endpoint, params); + + var requestOptions = mlutil.copyProperties(this.client.connectionParams); + requestOptions.method = 'DELETE'; + requestOptions.headers = valcheck.isNullOrUndefined(headers) ? { + 'Accept': 'application/json' + } : headers; + requestOptions.path = path; + + var operation = new Operation( + 'DELETE '+path, + this.client, + requestOptions, + 'empty', + ((hasResponse === 'true') ? 'single' : 'empty') + ); + operation.outputTransform = responseOutputTransform; + + return requester.startRequest(operation); +}; + +function makePath(endpoint, params) { + var path = encodeURI(endpoint); + if (!valcheck.isNullOrUndefined(params)) { + var paramKeys = Object.keys(params); + var sep = '?'; + for (var i=0; i < paramKeys.length; i++) { + var paramKey = paramKeys[i]; + var value = params[paramKey]; + if (valcheck.isArray(value)) { + for (var j=0; j < value.length; j++) { + path += sep+paramKey+'='+encodeURIComponent(value[j]); + if (i === 0 && j === 0) { + sep = '&'; + } + } + } else { + path += sep+paramKey+'='+encodeURIComponent(value); + if (i === 0) { + sep = '&'; + } + } + } + } + + return path; +} + +function createManager(adminClient) { + return new Manager(adminClient); +}; + +module.exports = { + createManager: createManager +}; diff --git a/config-optic/userconfig.js b/config-optic/userconfig.js new file mode 100755 index 00000000..91674a2b --- /dev/null +++ b/config-optic/userconfig.js @@ -0,0 +1,100 @@ +'use strict'; + +function addRestEvalRole(manager) { + return manager.post({ + endpoint: '/manage/v2/roles', + body: { + 'role-name': 'rest-evaluator', + description: 'REST writer who can eval, invoke, or set a dynamic databases', + role: [ + 'rest-writer' + ], + privilege: [ + { + 'privilege-name': 'xdmp-eval', + action: 'http://marklogic.com/xdmp/privileges/xdmp-eval', + kind: 'execute' + }, + { + 'privilege-name': 'xdmp-eval-in', + action: 'http://marklogic.com/xdmp/privileges/xdmp-eval-in', + kind: 'execute' + }, + { + 'privilege-name': 'xdmp-invoke', + action: 'http://marklogic.com/xdmp/privileges/xdmp-invoke', + kind: 'execute' + }, + { + 'privilege-name': 'xdbc-eval', + action: 'http://marklogic.com/xdmp/privileges/xdbc-eval', + kind: 'execute' + }, + { + 'privilege-name': 'xdbc-eval-in', + action: 'http://marklogic.com/xdmp/privileges/xdbc-eval-in', + kind: 'execute' + }, + { + 'privilege-name': 'xdbc-invoke', + action: 'http://marklogic.com/xdmp/privileges/xdbc-invoke', + kind: 'execute' + }, + { + 'privilege-name': 'any-uri', + action: 'http://marklogic.com/xdmp/privileges/any-uri', + kind: 'execute' + }, + { + 'privilege-name': 'admin-module-read', + action: 'http://marklogic.com/xdmp/privileges/admin-module-read', + kind: 'execute' + }, + { + 'privilege-name': 'admin-module-write', + action: 'http://marklogic.com/xdmp/privileges/admin-module-write', + kind: 'execute' + }, + { + 'privilege-name': 'unprotected-collections', + action: 'http://marklogic.com/xdmp/privileges/unprotected-collections', + kind: 'execute' + } + ] + } + }); +} + +function addRestEvalUser(manager) { + return manager.post({ + endpoint: '/manage/v2/users', + body: { + 'user-name': 'rest-evaluator', + password: 'x', + description: 'rest-evaluator user', + role: [ + 'rest-evaluator' + ] + } + }); +} + +function addRestReaderUser(manager) { + return manager.post({ + endpoint: '/manage/v2/users', + body: { + 'user-name': 'rest-reader-optic', + password: 'x', + description: 'rest-reader user', + role: [ + 'rest-reader' + ] + } + }); +} + +module.exports = { + addRestEvalRole: addRestEvalRole, + addRestEvalUser: addRestEvalUser, + addRestReaderUser: addRestReaderUser +}; diff --git a/etc/data/employees.tdej b/etc/data/employees.tdej new file mode 100644 index 00000000..1f9d7773 --- /dev/null +++ b/etc/data/employees.tdej @@ -0,0 +1,28 @@ +{ + "template":{ + "context":"/Employee", + "rows":[ + { + "schemaName":"company", + "viewName":"employees", + "columns":[ + { + "name":"EmployeeID", + "scalarType":"int", + "val":"ID" + }, + { + "name":"FirstName", + "scalarType":"string", + "val":"FirstName" + }, + { + "name":"LastName", + "scalarType":"string", + "val":"LastName" + } + ] + } + ] + } +} diff --git a/etc/data/masterDetail.tdex b/etc/data/masterDetail.tdex new file mode 100644 index 00000000..baea81c2 --- /dev/null +++ b/etc/data/masterDetail.tdex @@ -0,0 +1,37 @@ + + + diff --git a/etc/data/masterDetail.xml b/etc/data/masterDetail.xml new file mode 100644 index 00000000..768f1d28 --- /dev/null +++ b/etc/data/masterDetail.xml @@ -0,0 +1,16 @@ + + + + + 1Master 12015-12-01 + 2Master 22015-12-02 + + + 1Detail 1110.01blue + 2Detail 2220.02blue + 3Detail 3130.03blue + 4Detail 4240.04green + 5Detail 5150.05green + 6Detail 6260.06green + + diff --git a/etc/data/musician.tdex b/etc/data/musician.tdex new file mode 100644 index 00000000..fb6bf1ef --- /dev/null +++ b/etc/data/musician.tdex @@ -0,0 +1,16 @@ + + + diff --git a/etc/data/rowPostProcessors.sjs b/etc/data/rowPostProcessors.sjs new file mode 100644 index 00000000..f3365215 --- /dev/null +++ b/etc/data/rowPostProcessors.sjs @@ -0,0 +1,64 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +function arrayMapper(row) { + const result = row.concat(); + result.push((typeof result[0] === 'string') ? 'seconds' : + fn.floor(fn.secondsFromDateTime(fn.currentDateTime())) + ); + return result; +} +function arrayReducer(previous, row) { + const val = (previous === void 0) ? 0 : previous + row[0]; + return val; +} +function secondsMapper(row) { + row.seconds = new Date().getSeconds(); + return row; +} +function fibReducer(previous, row) { + const i = Array.isArray(previous) ? previous.length : 0; + + row.i = i; + + switch(i) { + case 0: + row.fib = 0; + break; + case 1: + row.fib = 1; + break; + default: + row.fib = previous[i - 2].fib + previous[i - 1].fib; + break; + } + + if (i === 0) { + previous = [row]; + } else { + previous.push(row); + } + + return previous; +} + +module.exports = { + arrayMapper: arrayMapper, + arrayReducer: arrayReducer, + secondsMapper: secondsMapper, + fibReducer: fibReducer +}; diff --git a/etc/data/tripleSets.xml b/etc/data/tripleSets.xml new file mode 100644 index 00000000..82b966e4 --- /dev/null +++ b/etc/data/tripleSets.xml @@ -0,0 +1,64 @@ + + + + + + + /datastore/id#A + http://purl.org/dc/terms/title + The A datastore + + /datastore/id#A + http://purl.org/dc/terms/type + http://purl.org/dc/dcmitype/Dataset + + /datastore/id#A + http://purl.org/dc/terms/description + Describing A + + /datastore/id#A + http://purl.org/dc/terms/alternative + The Awesome datastore + + /datastore/id#B + http://purl.org/dc/terms/title + The B datastore + + /datastore/id#B + http://purl.org/dc/terms/type + http://purl.org/dc/dcmitype/Dataset + + /datastore/id#B + http://purl.org/dc/terms/description + Describing B + + /datastore/id#B + http://purl.org/dc/terms/modified + 2015-12-14 + + /master/id#1 + http://purl.org/dc/terms/identifier + 1 + + /master/id#1 + http://purl.org/dc/terms/source + /datastore/id#A + + /master/id#1 + http://purl.org/dc/terms/description + First description + + /master/id#2 + http://purl.org/dc/terms/identifier + 2 + + /master/id#2 + http://purl.org/dc/terms/source + /datastore/id#B + + /master/id#2 + http://purl.org/dc/terms/description + Second description + + + diff --git a/etc/test-config-qa-ssl.js b/etc/test-config-qa-ssl.js index 85a92525..e210c0cb 100644 --- a/etc/test-config-qa-ssl.js +++ b/etc/test-config-qa-ssl.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/etc/test-config-qa.js b/etc/test-config-qa.js index 08f88126..25e8f850 100644 --- a/etc/test-config-qa.js +++ b/etc/test-config-qa.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/etc/test-config.js b/etc/test-config.js index 34d90adf..caba197f 100644 --- a/etc/test-config.js +++ b/etc/test-config.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/etc/test-lib.js b/etc/test-lib.js index 10331f7a..2bfccb83 100644 --- a/etc/test-lib.js +++ b/etc/test-lib.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ Manager.prototype.get = function manageGet(paramsObj) { 'Accept': 'application/json' } : headers; requestOptions.path = path; - + var operation = new Operation( 'GET '+path, this.client, requestOptions, 'empty', ((hasResponse === 'false') ? 'empty' : 'single') @@ -86,7 +86,7 @@ Manager.prototype.post = function managePost(paramsObj) { 'Accept': 'application/json' } : headers; requestOptions.path = path; - + var hasBody = !valcheck.isNullOrUndefined(body); var operation = new Operation( @@ -101,7 +101,7 @@ Manager.prototype.post = function managePost(paramsObj) { operation.requestBody = body; } - return requester.startRequest(operation); + return requester.startRequest(operation); }; Manager.prototype.put = function managePut(paramsObj) { var endpoint = paramsObj.endpoint; @@ -133,7 +133,7 @@ Manager.prototype.put = function managePut(paramsObj) { operation.requestBody = body; } - return requester.startRequest(operation); + return requester.startRequest(operation); }; Manager.prototype.remove = function manageRemove(paramsObj) { var endpoint = paramsObj.endpoint; @@ -149,7 +149,7 @@ Manager.prototype.remove = function manageRemove(paramsObj) { 'Accept': 'application/json' } : headers; requestOptions.path = path; - + var operation = new Operation( 'DELETE '+path, this.client, @@ -159,7 +159,7 @@ Manager.prototype.remove = function manageRemove(paramsObj) { ); operation.outputTransform = responseOutputTransform; - return requester.startRequest(operation); + return requester.startRequest(operation); }; function makePath(endpoint, params) { diff --git a/etc/test-setup-prompt.js b/etc/test-setup-prompt.js index 4e285096..57e65a98 100644 --- a/etc/test-setup-prompt.js +++ b/etc/test-setup-prompt.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,10 +62,10 @@ function adminPasswordCallback(error, result) { this.password = 'admin'; } else { console.log('no admin password specified, so cannot setup'); - process.exit(1); + process.exit(1); } } else { - this.password = result; + this.password = result; } this.finish(); } diff --git a/etc/test-setup-qa.js b/etc/test-setup-qa.js index 24eaacab..52531a48 100644 --- a/etc/test-setup-qa.js +++ b/etc/test-setup-qa.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -175,12 +175,12 @@ function setup(manager) { 'triple-index': true, 'schema-database': testconfig.testServerName+'-modules', 'range-path-index': [ - { + { 'scalar-type': 'decimal', 'path-expression': 'price/amt', collation: '', 'range-value-positions': false, - 'invalid-values': 'reject' + 'invalid-values': 'reject' } ], 'geospatial-path-index': [ @@ -193,25 +193,25 @@ function setup(manager) { } ], 'geospatial-element-index' : [ - { + { 'namespace-uri': '', localname: 'gElemPoint', 'coordinate-system': 'wgs84', 'point-format': 'point', 'range-value-positions': false, - 'invalid-values': 'reject' + 'invalid-values': 'reject' }, - { + { 'namespace-uri': '', localname: 'gElemPointWgs84Double', 'coordinate-system': 'wgs84/double', 'point-format': 'point', 'range-value-positions': false, - 'invalid-values': 'reject' + 'invalid-values': 'reject' } ], - 'geospatial-element-child-index': [ - { + 'geospatial-element-child-index': [ + { 'parent-namespace-uri': '', 'parent-localname': 'gElemChildParent', 'namespace-uri': '', @@ -219,9 +219,9 @@ function setup(manager) { 'coordinate-system': 'wgs84', 'point-format': 'point', 'range-value-positions': false, - 'invalid-values': 'reject' - }, - { + 'invalid-values': 'reject' + }, + { 'parent-namespace-uri': '', 'parent-localname': 'gElemChildParentEtrs89Double', 'namespace-uri': '', @@ -229,11 +229,11 @@ function setup(manager) { 'coordinate-system': 'etrs89/double', 'point-format': 'point', 'range-value-positions': false, - 'invalid-values': 'reject' - } + 'invalid-values': 'reject' + } ], - 'geospatial-element-pair-index': [ - { + 'geospatial-element-pair-index': [ + { 'parent-namespace-uri': '', 'parent-localname': 'gElemPair', 'latitude-namespace-uri': '', @@ -242,9 +242,9 @@ function setup(manager) { 'longitude-localname': 'longitude', 'coordinate-system': 'wgs84', 'range-value-positions': false, - 'invalid-values': 'reject' - }, - { + 'invalid-values': 'reject' + }, + { 'parent-namespace-uri': '', 'parent-localname': 'gElemPairRawDouble', 'latitude-namespace-uri': '', @@ -253,11 +253,11 @@ function setup(manager) { 'longitude-localname': 'longitudeRawDouble', 'coordinate-system': 'raw/double', 'range-value-positions': false, - 'invalid-values': 'reject' - } + 'invalid-values': 'reject' + } ], - 'geospatial-element-attribute-pair-index': [ - { + 'geospatial-element-attribute-pair-index': [ + { 'parent-namespace-uri': '', 'parent-localname': 'gAttrPair', 'latitude-namespace-uri': '', @@ -266,8 +266,8 @@ function setup(manager) { 'longitude-localname': 'longitude', 'coordinate-system': 'wgs84', 'range-value-positions': false, - 'invalid-values': 'reject' - } + 'invalid-values': 'reject' + } ], 'geospatial-region-path-index': [ { @@ -410,7 +410,7 @@ function setup(manager) { }); } else { console.log(testconfig.testServerName+' setup failed with HTTP status: '+response.statusCode); - console.log(response.data); + console.log(response.data); } }); } else { diff --git a/etc/test-setup-users.js b/etc/test-setup-users.js index 58d021dd..8d4a23d5 100644 --- a/etc/test-setup-users.js +++ b/etc/test-setup-users.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/etc/test-setup.js b/etc/test-setup.js index 1eb8f866..27e6d1e9 100644 --- a/etc/test-setup.js +++ b/etc/test-setup.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,15 +13,194 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var valcheck = require('core-util-is'); +const fs = require('fs'); +const valcheck = require('core-util-is'); +const marklogic = require('../lib/marklogic.js'); -var marklogic = require('../lib/marklogic.js'); +const promptForAdmin = require('./test-setup-prompt.js'); +const setupUsers = require('./test-setup-users.js'); -var promptForAdmin = require('./test-setup-prompt.js'); -var setupUsers = require('./test-setup-users.js'); +const testlib = require('./test-lib.js'); +const testconfig = require('./test-config.js'); -var testlib = require('./test-lib.js'); -var testconfig = require('./test-config.js'); +const moduleFiles = [ + { + uri:'/optic/test/masterDetail.tdex', + collections:['http://marklogic.com/xdmp/tde'], + contentType:'application/vnd.marklogic-tde+xml', + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read']}, + {'role-name':testconfig.restReaderConnection.user, capabilities:['read']}, + {'role-name':testconfig.restAdminConnection.user, capabilities:['read', 'update']} + ], + content:fs.createReadStream('./etc/data/masterDetail.tdex') + },{ + uri:'/optic/test/musician.tdex', + collections:['http://marklogic.com/xdmp/tde'], + contentType:'application/vnd.marklogic-tde+xml', + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read']}, + {'role-name':testconfig.restReaderConnection.user, capabilities:['read']}, + {'role-name':testconfig.restAdminConnection.user, capabilities:['read', 'update']} + ], + content:fs.createReadStream('./etc/data/musician.tdex') + },{ + uri:'/etc/optic/rowPostProcessors.sjs', + contentType:'application/vnd.marklogic-javascript', + permissions: [ + {'role-name':'app-user', capabilities:['read', 'execute']}, + {'role-name':'app-builder', capabilities:['read', 'execute']}, + {'role-name':testconfig.restReaderConnection.user, capabilities:['read', 'execute']}, + {'role-name':testconfig.restAdminConnection.user, capabilities:['read', 'execute', 'update']} + ], + content:fs.createReadStream('./etc/data/rowPostProcessors.sjs') + },{ + uri:'/etc/optic/employees.tdej', + contentType:'application/json', + collections:['http://marklogic.com/xdmp/tde'], + permissions: [ + {'role-name':'app-user', capabilities:['read', 'execute']}, + {'role-name':'app-builder', capabilities:['read', 'execute']}, + {'role-name':testconfig.restReaderConnection.user, capabilities:['read', 'execute']}, + {'role-name':testconfig.restAdminConnection.user, capabilities:['read', 'execute', 'update']} + ], + content:fs.createReadStream('./etc/data/employees.tdej') + }]; + +const dataFiles = [ + { + uri:'/optic/test/masterDetail.xml', + collections:['/optic/test', '/schemas/inventory'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:fs.createReadStream('./etc/data/masterDetail.xml') + },{ + uri:'/optic/test/tripleSets.xml', + collections:['/optic/test', '/graphs/inventory'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:fs.createReadStream('./etc/data/tripleSets.xml') + },{ + uri:'/optic/test/queryDoc1.json', + collections:['/optic/test', '/optic/test1'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{srchFood:'apples', srchNumber:2, srchLevel:20, srchCity:'Cairo', + srchPoint: '15.25, 15.25', + srchContainer:{srchColA:'common', srchColB:'outlier', srchColC:'common'}} + },{ + uri:'/optic/test/queryDoc2.json', + collections:['/optic/test', '/optic/test2'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{srchFood:'banannas', srchNumber:3, srchLevel:30, srchCity:'Antioch', + srchPoint: '25.25, 25.25', + srchContainer:{srchColA:'common', srchColB:'common', srchColC:'outlier'}} + },{ + uri:'/optic/test/queryDoc3.json', + collections:['/optic/test', '/optic/test3'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{srchFood:'citron', srchNumber:1, srchLevel:10, srchCity:'Bonn', + srchPoint: '35.25, 35.25', + srchContainer:{srchColA:'outlier', srchColB:'common', srchColC:'common'}} + },{ + uri:'/optic/test/musician1.json', + collections:['/optic/test', '/optic/music'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{musician:{lastName:'Armstrong', firstName:'Louis', dob:'1901-08-04', instrument:['trumpet', 'vocal']}} + },{ + uri:'/optic/test/albums1.json', + collections:['/optic/test', '/optic/music'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{style:['dixieland'], albums:[ + {triple:{subject:'/optic/test/albums1_1', predicate:'/optic/test/albumName', object:'Hot Fives'}}, + {triple:{subject:'/optic/test/albums1_1', predicate:'/optic/test/musicianUri', object:'/optic/test/musician1.json'}}, + {triple:{subject:'/optic/test/albums1_2', predicate:'/optic/test/albumName', object:'Porgy and Bess'}}, + {triple:{subject:'/optic/test/albums1_2', predicate:'/optic/test/musicianUri', object:'/optic/test/musician1.json'}} + ]} + },{ + uri:'/optic/test/musician2.json', + collections:['/optic/test', '/optic/music'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{musician:{lastName:'Byron', firstName:'Don', dob:'1958-11-08', instrument:['clarinet', 'saxophone']}} + },{ + uri:'/optic/test/albums2.json', + collections:['/optic/test', '/optic/music'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{style:['avantgarde'], albums:[ + {triple:{subject:'/optic/test/albums2_1', predicate:'/optic/test/albumName', object:'Four Thoughts on Marvin Gaye'}}, + {triple:{subject:'/optic/test/albums2_1', predicate:'/optic/test/musicianUri', object:'/optic/test/musician2.json'}}, + {triple:{subject:'/optic/test/albums2_2', predicate:'/optic/test/albumName', object:'A Ballad For Many'}}, + {triple:{subject:'/optic/test/albums2_2', predicate:'/optic/test/musicianUri', object:'/optic/test/musician2.json'}} + ]} + },{ + uri:'/optic/test/musician3.json', + collections:['/optic/test', '/optic/music'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{musician:{lastName:'Coltrane', firstName:'John', dob:'1926-09-23', instrument:['saxophone']}} + },{ + uri:'/optic/test/albums3.json', + collections:['/optic/test', '/optic/music'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{style:['avantgarde'], albums:[ + {triple:{subject:'/optic/test/albums3_1', predicate:'/optic/test/albumName', object:'Impressions'}}, + {triple:{subject:'/optic/test/albums3_1', predicate:'/optic/test/musicianUri', object:'/optic/test/musician3.json'}}, + {triple:{subject:'/optic/test/albums3_2', predicate:'/optic/test/albumName', object:'Crescent'}}, + {triple:{subject:'/optic/test/albums3_2', predicate:'/optic/test/musicianUri', object:'/optic/test/musician3.json'}} + ]} + },{ + uri:'/optic/test/musician4.json', + collections:['/optic/test', '/optic/music'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{musician:{lastName:'Davis', firstName:'Miles', dob:'1926-05-26', instrument:['trumpet']}} + },{ + uri:'/optic/test/albums4.json', + collections:['/optic/test', '/optic/music'], + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + content:{style:['modal'], albums:[ + {triple:{subject:'/optic/test/albums4_1', predicate:'/optic/test/albumName', object:'Kind of Blue'}}, + {triple:{subject:'/optic/test/albums4_1', predicate:'/optic/test/musicianUri', object:'/optic/test/musician4.json'}}, + {triple:{subject:'/optic/test/albums4_2', predicate:'/optic/test/albumName', object:'In a Silent Way'}}, + {triple:{subject:'/optic/test/albums4_2', predicate:'/optic/test/musicianUri', object:'/optic/test/musician4.json'}} + ]} + }]; promptForAdmin(createManager); @@ -29,9 +208,9 @@ function createManager(adminUser, adminPassword) { testconfig.manageAdminConnection.user = adminUser; testconfig.manageAdminConnection.password = adminPassword; - var manageClient = + const manageClient = marklogic.createDatabaseClient(testconfig.manageAdminConnection); - var manager = testlib.createManager(manageClient); + const manager = testlib.createManager(manageClient); setupUsers(manager, setup); } @@ -84,18 +263,17 @@ function setup(manager) { endpoint: '/manage/v2/databases/'+testconfig.testServerName+'/properties' }).result(). then(function(response) { - var indexName = null; - var indexType = null; - var indexdef = null; - var i = null; + let indexName = null; + let indexType = null; + let indexdef = null; + let i = null; - var elementWordLexicon = response.data['element-word-lexicon']; - var lexiconTest = { + const lexiconTest = { defaultWordKey: true, taggedWordKey: true }; - - var lexers = []; + let elementWordLexicon = response.data['element-word-lexicon']; + let lexers = []; if (valcheck.isNullOrUndefined(elementWordLexicon)) { elementWordLexicon = []; lexers = Object.keys(lexiconTest); @@ -121,19 +299,22 @@ function setup(manager) { elementWordLexicon.push(indexdef); } - var rangeElementIndex = response.data['range-element-index']; - - var rangeTest = { + const rangeTest = { rangeKey1: 'string', rangeKey2: 'string', rangeKey3: 'int', rangeKey4: 'int', + rangeKey5: 'int', + srchCity: 'string', + srchLevel: 'int', + srchNumber: 'int', systemStartTime: 'dateTime', systemEndTime: 'dateTime', validStartTime: 'dateTime', validEndTime: 'dateTime' }; - var rangers = []; + let rangeElementIndex = response.data['range-element-index']; + let rangers = []; if (valcheck.isNullOrUndefined(rangeElementIndex)) { rangeElementIndex = []; rangers = Object.keys(rangeTest); @@ -164,9 +345,7 @@ function setup(manager) { rangeElementIndex.push(indexdef); } - var geospatialElementIndex = response.data['geospatial-element-index']; - - var pointGeospatialIndex = { + const pointGeospatialIndex = { 'namespace-uri': '', localname: 'point', 'coordinate-system': 'wgs84', @@ -174,6 +353,7 @@ function setup(manager) { 'point-format': 'point', 'invalid-values': 'ignore' }; + let geospatialElementIndex = response.data['geospatial-element-index']; if (valcheck.isNullOrUndefined(geospatialElementIndex)) { geospatialElementIndex = [pointGeospatialIndex]; @@ -185,11 +365,13 @@ function setup(manager) { geospatialElementIndex.push(pointGeospatialIndex); } - var body = { - 'collection-lexicon': true, - 'triple-index': true, - 'schema-database': testconfig.testServerName+'-modules', + const body = { + 'collection-lexicon': true, + 'uri-lexicon': true, + 'triple-index': true, + 'schema-database': testconfig.testServerName+'-modules', }; + if (valcheck.isArray(elementWordLexicon) && elementWordLexicon.length > 0) { body['element-word-lexicon'] = elementWordLexicon; } @@ -212,6 +394,7 @@ function setup(manager) { }).result(); }). then(function(response) { + console.log('checking system temporal axis'); return manager.get({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+'/temporal/axes/systemTime' }).result(); @@ -220,9 +403,11 @@ function setup(manager) { if (response.statusCode < 400) { return this; } + console.log('creating system temporal axis'); return createAxis(manager, 'system'); }). then(function(response) { + console.log('checking valid temporal axis'); return manager.get({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+'/temporal/axes/validTime' }).result(); @@ -231,9 +416,11 @@ function setup(manager) { if (response.statusCode < 400) { return this; } + console.log('creating valid temporal axis'); return createAxis(manager, 'valid'); }). then(function(response) { + console.log('checking temporal collection'); return manager.get({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+ '/temporal/collections/temporalCollection' @@ -243,6 +430,7 @@ function setup(manager) { if (response.statusCode < 400) { return this; } + console.log('creating temporal collection'); return manager.post({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+'/temporal/collections', body: { @@ -256,13 +444,15 @@ function setup(manager) { then(function(response) { return manager.get({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+ - '/temporal/collections/LSQT/properties?collection=temporalCollection' + '/temporal/collections/lsqt/properties?collection=temporalCollection' }).result(); }). then(function(response) { - if (response.statusCode < 400) { - return this; - } + // 2017-10-24: Commenting out, LSQT enablement required for LSQT testing + // if (response.statusCode < 400) { + // return this; + // } + console.log('configuring LSQT'); return manager.put({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+ '/temporal/collections/lsqt/properties?collection=temporalCollection', @@ -274,16 +464,28 @@ function setup(manager) { } }).result(); }). + then(function(response){ + console.log('setting up modules database resources'); + const modDb = marklogic.createDatabaseClient({ + database: testconfig.testServerName+'-modules', + host: testconfig.manageAdminConnection.host, + port: testconfig.manageAdminConnection.port, + user: testconfig.manageAdminConnection.user, + password: testconfig.manageAdminConnection.password, + authType: testconfig.manageAdminConnection.authType + }); + return modDb.documents.write(moduleFiles).result(); + }). /* TODO: advance LSQT after creating documents then(function(response) { - var evalConnection = { + const evalConnection = { host: testconfig.testHost, port: testconfig.restPort, user: testconfig.manageAdminConnection.user, password: testconfig.manageAdminConnection.password, authType: testconfig.restAuthType }; - var evalClient = marklogic.createDatabaseClient(evalConnection); + const evalClient = marklogic.createDatabaseClient(evalConnection); return evalClient.xqueryEval( 'xquery version "1.0-ml"; '+ 'import module namespace temporal = "http://marklogic.com/xdmp/temporal" '+ @@ -292,16 +494,28 @@ function setup(manager) { ).result(); }). */ + then(function(response){ + console.log('setting up sample documents'); + const db = marklogic.createDatabaseClient({ + host: testconfig.restWriterConnection.host, + port: testconfig.restWriterConnection.port, + user: testconfig.restWriterConnection.user, + password: testconfig.restWriterConnection.password, + authType: testconfig.restWriterConnection.authType + }); + return db.documents.write(dataFiles).result(); + }). then(function(response) { console.log(testconfig.testServerName+' setup succeeded'); - }, function(error) { + }). + catch(function(err) { console.log('failed to set up '+testconfig.testServerName+' server:\n'+ - JSON.stringify(error, null, 2)); + JSON.stringify(err, null, 2)); process.exit(1); }); } else { console.log(testconfig.testServerName+' setup failed with HTTP status: '+response.statusCode); - console.log(response.data); + console.log(response.data); process.exit(1); } }); diff --git a/etc/test-teardown-qa.js b/etc/test-teardown-qa.js index fe2bcea4..aa0603b0 100644 --- a/etc/test-teardown-qa.js +++ b/etc/test-teardown-qa.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ function setup(manager) { body: { 'schema-database': 'Schemas' }, - hasResponse: true + hasResponse: true }).result(). then(function(response) { return manager.post({ @@ -68,7 +68,7 @@ function setup(manager) { body: {'operation': 'clear-database'} }).result(); }). - /*then(function(response) { + /*then(function(response) { return manager.remove({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+'/temporal/collections?collection=temporalCollection' }).result(); diff --git a/etc/test-teardown.js b/etc/test-teardown.js index c37e138a..17ba5598 100644 --- a/etc/test-teardown.js +++ b/etc/test-teardown.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/etc/users-setup.js b/etc/users-setup.js index 03803574..2fb74d90 100644 --- a/etc/users-setup.js +++ b/etc/users-setup.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/all.js b/examples/all.js index 82dea496..7675ac66 100644 --- a/examples/all.js +++ b/examples/all.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/before-load.js b/examples/before-load.js index 06158824..07eb0673 100644 --- a/examples/before-load.js +++ b/examples/before-load.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,38 +14,47 @@ * limitations under the License. */ var fs = require('fs'); +var PromisePlus = require('../lib/bluebird-plus.js'); var marklogic = require('../'); var exutil = require('./example-util.js'); +var testconfig = require('../etc/test-config.js'); + var db = marklogic.createDatabaseClient(exutil.restWriterConnection); var fsdir = 'examples/data/'; var dbdir = '/countries/'; var batchSize = 100; +var files = []; var collections = ['/countries', '/facts/geographic']; function readFile(filenames, i, buffer, isLast) { var filename = filenames[i]; - fs.readFile(fsdir+filename, function (err, content) { - if (err) { - throw err; - } - - buffer.push({ - uri: dbdir+filename, - category: 'content', - contentType: 'application/json', - collections: collections, - content: content.toString() - }); - if (isLast) { - console.log('loading batch from '+buffer[0].uri+' to '+filename); - db.documents.write(buffer).result(function(response) { + files.push(new PromisePlus((resolve, reject) => { + fs.readFile(fsdir+filename, function (err, content) { + if (err) { + throw err; + } + var document = ({ + uri: dbdir+filename, + category: 'content', + contentType: 'application/json', + collections: collections, + content: content.toString() + }); + resolve(document); + }) + })); + + if (isLast) { + PromisePlus.all(files).then(function(documents) { + console.log('loading batch from '+documents[0].uri+' to '+filename); + db.documents.write(documents).result(function(response) { console.log( 'done loading:\n'+ response.documents.map(function(document) { @@ -54,9 +63,11 @@ function readFile(filenames, i, buffer, isLast) { ); writeBatch(filenames, i + 1); }); - } - }); -} + }); + files = []; + } + +}; function writeBatch(filenames, batchFirst) { if (batchFirst >= filenames.length) { @@ -96,3 +107,30 @@ var ws = db.documents.write({ result(function(response) { console.log('wrote '+imageFile); }); + +// Write TDE template to Schemas database +console.log('copy TDE template'); +const schemaDb = marklogic.createDatabaseClient({ + database: 'Schemas', + host: testconfig.manageAdminConnection.host, + port: testconfig.manageAdminConnection.port, + user: testconfig.manageAdminConnection.user, + password: testconfig.manageAdminConnection.password, + authType: testconfig.manageAdminConnection.authType + }); +schemaDb.documents.write({ + uri:'/examples/data/countries.tdej', + contentType:'application/json', + collections:['http://marklogic.com/xdmp/tde'], + permissions: [ + {'role-name':testconfig.restAdminConnection.user, + capabilities:['read', 'execute', 'update']} + ], + content:fs.createReadStream(fsdir+'countries.tdej') + }) + .result(function(response) { + console.log('template written'); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/examples/data/countries.tdej b/examples/data/countries.tdej new file mode 100644 index 00000000..57c5fd59 --- /dev/null +++ b/examples/data/countries.tdej @@ -0,0 +1,40 @@ +{ + "template": { + "collections": [ + "/countries" + ], + "context": "/", + "rows": [ + { + "schemaName": "facts", + "viewName": "countries", + "columns": [ + { + "name": "name", + "scalarType": "string", + "val": "name" + }, + { + "name": "code", + "scalarType": "string", + "val": "code", + "nullable": true + }, + { + "name": "region", + "scalarType": "string", + "val": "region", + "nullable": true + }, + { + "name": "area", + "scalarType": "int", + "val": "geo/Area/total/quantity", + "nullable": true, + "invalidValues": "ignore" + } + ] + } + ] + } +} diff --git a/examples/example-util.js b/examples/example-util.js index 922197ca..0966b017 100644 --- a/examples/example-util.js +++ b/examples/example-util.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ if (fs.existsSync('node_modules/marklogic')) { var testconfig = null; switch(locationType) { case packageLocation: - testconfig = require('../etc/test-config.js'); + testconfig = require('../etc/test-config.js'); break; default: - testconfig = require('./example-config.js'); + testconfig = require('./example-config.js'); break; } @@ -45,10 +45,10 @@ function locateRequire() { if (marklogic === null) { switch(locationType) { case packageLocation: - marklogic = require('../'); + marklogic = require('../'); break; default: - marklogic = require('marklogic'); + marklogic = require('marklogic'); break; } } @@ -79,7 +79,7 @@ function pathToData() { var queueRunner = { mode: 'waiting', - queue: [] + queue: [] }; function addScript(script) { if (queueRunner.mode === 'waiting' && queueRunner.queue.length === 0) { diff --git a/examples/optimistic-locking.js b/examples/optimistic-locking.js index c6af3e84..b9fb0c94 100644 --- a/examples/optimistic-locking.js +++ b/examples/optimistic-locking.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/patch-document.js b/examples/patch-document.js index ca083f77..60073d0f 100644 --- a/examples/patch-document.js +++ b/examples/patch-document.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/probe-document.js b/examples/probe-document.js index 73c71575..f7b127d1 100644 --- a/examples/probe-document.js +++ b/examples/probe-document.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/query-builder.js b/examples/query-builder.js index 80f2f7ed..d6c7aa52 100644 --- a/examples/query-builder.js +++ b/examples/query-builder.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/query-by-example.js b/examples/query-by-example.js index bdbb7217..d93ac568 100644 --- a/examples/query-by-example.js +++ b/examples/query-by-example.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/query-extract.js b/examples/query-extract.js index 69c85aea..80210f47 100644 --- a/examples/query-extract.js +++ b/examples/query-extract.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/query-parser.js b/examples/query-parser.js index 9288a53b..88e20e1d 100644 --- a/examples/query-parser.js +++ b/examples/query-parser.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/read-documents.js b/examples/read-documents.js index 5bcf5ad1..a5fc2e92 100644 --- a/examples/read-documents.js +++ b/examples/read-documents.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/read-metadata.js b/examples/read-metadata.js index ac84fca5..0bb9d600 100644 --- a/examples/read-metadata.js +++ b/examples/read-metadata.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/read-rows.js b/examples/read-rows.js new file mode 100644 index 00000000..8d98383b --- /dev/null +++ b/examples/read-rows.js @@ -0,0 +1,62 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const exutil = require('./example-util.js'); + +// a real application would require without the 'exutil.' namespace +const marklogic = exutil.require('marklogic'); +const p = marklogic.planBuilder; + +const db = marklogic.createDatabaseClient(exutil.restReaderConnection); + +console.log('Read document content as rows from view'); + +// View defined here: examples/data/countries.tdej +const plan = p.fromView('facts', 'countries', '') + .select(['name', 'region', 'area']) + .where(p.eq(p.col('region'), 'North America')) + .orderBy(p.desc('area')) + .limit(4); + +db.rows.query(plan, { + format: 'json', + structure: 'object', + columnTypes: 'header' +}) + .then(function (response) { + console.log('Columns:'); + console.log( + // Comma-separated list of column names + response.columns.map(function (col) { + return col.name; + }).join(', ') + ); + console.log('Rows:'); + response.rows.forEach(function (row) { + console.log( + // Comma-separated list of values in each row + Object.keys(row).map(function (key) { + return row[key]; + }).join(', ') + ); + }) + console.log('done'); + + exutil.succeeded(); + }) + .catch(function(error) { + console.log(JSON.stringify(error)); + exutil.failed(); + }); diff --git a/examples/read-stream.js b/examples/read-stream.js index d43c2a34..a3d0a4d7 100644 --- a/examples/read-stream.js +++ b/examples/read-stream.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/setup.js b/examples/setup.js index ded7bea7..5f83b424 100644 --- a/examples/setup.js +++ b/examples/setup.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/transform-on-client.js b/examples/transform-on-client.js index afc2eeb4..09896b5f 100644 --- a/examples/transform-on-client.js +++ b/examples/transform-on-client.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/write-remove.js b/examples/write-remove.js index bed73c21..c305e225 100644 --- a/examples/write-remove.js +++ b/examples/write-remove.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/write-stream.js b/examples/write-stream.js index ac909a05..41a8baa1 100644 --- a/examples/write-stream.js +++ b/examples/write-stream.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/gulpfile.js b/gulpfile.js index e3bb685b..5c0b63f1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/jsdoc.json b/jsdoc.json index ca1dcfa7..842e0a1e 100644 --- a/jsdoc.json +++ b/jsdoc.json @@ -6,7 +6,7 @@ "templates": { "theme": "marklogic", "systemName": "MarkLogic Node.js Client API", - "copyright": "Copyright 2014-2017 MarkLogic Corporation", + "copyright": "Copyright 2014-2018 MarkLogic Corporation", "navType": "vertical", "inverseNav": true, "includeDate": false, diff --git a/lib/bluebird-plus.js b/lib/bluebird-plus.js index b9488f46..b936100c 100644 --- a/lib/bluebird-plus.js +++ b/lib/bluebird-plus.js @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 MarkLogic Corporation + * Copyright 2015-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/documents.js b/lib/documents.js index 9ee1109a..04a02457 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,6 +121,16 @@ function wipeOutputTransform(/*headers, data*/) { return output; } +function advanceLsqtOutputTransform(headers) { + /*jshint validthis:true */ + + var output = { + lsqt: headers.lsqt + }; + + return output; +} + /** * An object offering the alternative of a {@link ResultProvider#result} function * or a {@link ResultProvider#stream} function for receiving the results @@ -448,6 +458,74 @@ Documents.prototype.wipe = function wipeDocument() { return requester.startRequest(operation); }; +/** + * Advances the LSQT (Last Stable Query Time) of a temporal collection. + * @method documents#advanceLsqt + * @since 2.1.1 + * @param {string} temporalCollection - The name of the temporal collection + * for which to advance the LSQT. + * @param {string} [lag] - The lag (in seconds (???)) to subtract from the + * maximum system start time in the temporal collection to determine the LSQT. + * @returns {ResultProvider} an object whose result() function takes + * an object with the new LSQT as an 'lsqt' property. + */ +Documents.prototype.advanceLsqt = function temporalAdvanceLsqt() { + /*jshint validthis:true */ + var args = mlutil.asArray.apply(null, arguments); + + var tempColl = null; + var lag = null; + + // Positional case + if (typeof args[0] === 'string' || args[0] instanceof String) { + tempColl = args[0]; + if (args[1] !== void 0) { + if (typeof args[1] === 'number' || args[0] instanceof Number) { + lag = args[1]; + } else { + throw new Error('lag parameter takes a number in seconds'); + } + } + } + // Object case + else { + var obj = args[0]; + if (obj.temporalCollection === void 0) { + throw new Error('must specify temporalCollection'); + } else { + tempColl = obj.temporalCollection; + } + if (obj.lag !== void 0) { + if (typeof obj.lag === 'number' || obj.lag instanceof Number) { + lag = obj.lag; + } else { + throw new Error('lag parameter takes a number in seconds'); + } + } + } + + var path = '/v1/temporal/collections/' + encodeURIComponent(tempColl); + path += '?result=advance-lsqt'; + if (lag !== null) { + path += '&lag=' + encodeURIComponent(lag); + } + + var connectionParams = this.client.connectionParams; + var requestOptions = mlutil.copyProperties(connectionParams); + requestOptions.method = 'POST'; + requestOptions.path = mlutil.databaseParam(connectionParams, path, '&'); + + var operation = new Operation( + 'advance LSQT', this.client, requestOptions, 'empty', 'empty' + ); + // operation.temporalCollection = tempColl; + operation.validStatusCodes = [204]; + operation.outputTransform = advanceLsqtOutputTransform; + operation.errorTransform = uriErrorTransform; + + return requester.startRequest(operation); +}; + /** @ignore */ function readStatusValidator(statusCode) { return (statusCode < 400 || statusCode === 404) ? @@ -534,6 +612,8 @@ function singleReadOutputTransform(headers, data) { * @param {number[]} [range] - the range of bytes to extract * from a binary document; the range is specified with a zero-based * start byte and the position after the end byte as in Array.slice() + * @param {DatabaseClient.Timestamp} [timestamp] - a Timestamp object for point-in-time + * operations. * @returns {ResultProvider} an object whose result() function takes * a {@link documents#resultList} success callback. */ @@ -552,6 +632,7 @@ function readDocumentsImpl(contentOnly, args) { var transform = null; var contentType = null; var range = null; + var timestamp = null; var arg = args[0]; if (Array.isArray(arg)) { @@ -571,6 +652,7 @@ function readDocumentsImpl(contentOnly, args) { transform = arg.transform; contentType = arg.contentType; range = arg.range; + timestamp = arg.timestamp; } if (categories == null) { @@ -596,6 +678,12 @@ function readDocumentsImpl(contentOnly, args) { path += '&'+mlutil.endpointTransform(transform); } + if (timestamp !== null && timestamp !== void 0) { + if (timestamp.value !== null) { + path += '×tamp='+timestamp.value; + } + } + var isSinglePayload = ( uris.length === 1 && ( (categories.length === 1 && categories[0] === 'content') || @@ -684,6 +772,7 @@ function readDocumentsImpl(contentOnly, args) { } else if (contentOnly === true) { operation.subdata = ['content']; } + operation.timestamp = (timestamp !== null) ? timestamp : null; return requester.startRequest(operation); } @@ -1366,11 +1455,13 @@ function collectMetadata(document) { var metadataCategories = ['collections', 'permissions', 'quality', 'properties', 'metadataValues']; for (var i = 0; i < metadataCategories.length; i++) { var category = metadataCategories[i]; - if (document[category] != null) { - if (metadata === null) { - metadata = {}; + if (document !== null) { + if (document[category] != null) { + if (metadata === null) { + metadata = {}; + } + metadata[category] = document[category]; } - metadata[category] = document[category]; } } return metadata; @@ -1654,13 +1745,15 @@ function listOutputTransform(headers, data) { * @since 1.0 * @param {object} query - a query built by a {@link queryBuilder} or * a {@link documents.CombinedQueryDefinition} + * @param {DatabaseClient.Timestamp} [timestamp] - a Timestamp object for point-in-time + * operations. * @returns {ResultProvider} an object whose result() function takes * a {@link documents#resultList} success callback. */ -Documents.prototype.query = function queryDocuments(builtQuery) { - return queryDocumentsImpl.call(this, null, false, builtQuery); +Documents.prototype.query = function queryDocuments(builtQuery, timestamp) { + return queryDocumentsImpl.call(this, null, false, builtQuery, timestamp); }; -function queryDocumentsImpl(collectionParam, contentOnly, builtQuery) { +function queryDocumentsImpl(collectionParam, contentOnly, builtQuery, timestamp) { /*jshint validthis:true */ var wrapper = qb.makeSearchBody(builtQuery); @@ -1760,6 +1853,12 @@ function queryDocumentsImpl(collectionParam, contentOnly, builtQuery) { endpoint += '&collection='+encodeURIComponent(collectionParam); } + if (timestamp !== undefined && timestamp instanceof mlutil.Timestamp) { + if (timestamp.value !== null) { + endpoint += '×tamp='+timestamp.value; + } + } + var connectionParams = this.client.connectionParams; var requestOptions = mlutil.copyProperties(connectionParams); requestOptions.method = 'POST'; @@ -1793,6 +1892,7 @@ function queryDocumentsImpl(collectionParam, contentOnly, builtQuery) { if (!returnDocuments) { operation.outputTransform = listOutputTransform; } + operation.timestamp = (timestamp !== undefined) ? timestamp : null; return requester.startRequest(operation); } diff --git a/lib/extlibs.js b/lib/extlibs.js index bd8511ee..522eb8e9 100644 --- a/lib/extlibs.js +++ b/lib/extlibs.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/graphs.js b/lib/graphs.js index 7b11055e..6a73b77c 100644 --- a/lib/graphs.js +++ b/lib/graphs.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ var requester = require('./requester.js'); var mlutil = require('./mlutil.js'); var Operation = require('./operation.js'); var qb = require('./query-builder.js'); +var mlutil = require('./mlutil.js'); function uriErrorTransform(message) { /*jshint validthis:true */ @@ -124,6 +125,8 @@ function Graphs(client) { * @param {string|transactions.Transaction} [txid] - a string * transaction id or Transaction object identifying an open * multi-statement transaction that has uncommitted triples + * @param {DatabaseClient.Timestamp} [timestamp] - a Timestamp object for point-in-time + * operations. * @returns {ResultProvider} an object whose stream() function returns a read stream * that receives the triples for the graph in the requested format */ @@ -138,6 +141,7 @@ Graphs.prototype.read = function readGraph() { var uri = null; var category = null; var txid = null; + var timestamp = null; var testArg = args[0]; if (typeof testArg === 'string' || testArg instanceof String) { @@ -153,6 +157,7 @@ Graphs.prototype.read = function readGraph() { uri = params.uri; category = params.category; txid = params.txid; + timestamp = params.timestamp; if (contentType == null) { throw new Error('named parameters must specify the content type when reading a graph'); } @@ -170,6 +175,11 @@ Graphs.prototype.read = function readGraph() { if (txid !== null && txid !== void 0) { endpoint += '&txid='+mlutil.getTxidParam(txid); } + if (timestamp !== null && timestamp !== void 0) { + if (timestamp.value !== null) { + endpoint += '×tamp='+timestamp.value; + } + } var connectionParams = this.client.connectionParams; var requestOptions = mlutil.copyProperties(connectionParams); @@ -189,6 +199,7 @@ Graphs.prototype.read = function readGraph() { operation.uri = uri; } operation.errorTransform = uriErrorTransform; + operation.timestamp = (timestamp !== null) ? timestamp : null; return requester.startRequest(operation); }; @@ -501,6 +512,8 @@ function applyGraph(action, args) { * @param {string|transactions.Transaction} [txid] - a string * transaction id or Transaction object identifying an open * multi-statement transaction that has uncommitted triples for new graphs + * @param {DatabaseClient.Timestamp} [timestamp] - a Timestamp object for point-in-time + * operations. * @returns {ResultProvider} an object whose result() function takes * a success callback that receives the list of graphs stored * on the server @@ -510,16 +523,31 @@ Graphs.prototype.list = function listGraphs() { var contentType = null; var txid = null; - if (argLen > 1) { - contentType = arguments[0]; - txid = arguments[1]; - } else if (argLen === 1) { - var arg = arguments[0]; - if (typeof arg === 'string' || arg instanceof String) { - contentType = arg; - } else { - contentType = arg.contentType; - txid = arg.txid; + var timestamp = null; + if (argLen > 0) { + var arg = null; + var i = argLen - 1; + for (; i >= 0; i--) { + arg = arguments[i]; + if (typeof arg === 'string' || arg instanceof String) { + contentType = arg; + continue; + } + if (arg instanceof mlutil.Transaction) { + txid = arg; + continue; + } + if (arg instanceof mlutil.Timestamp) { + timestamp = arg; + continue; + } + if (arg !== null && typeof arg === 'object') { + contentType = arg.contentType; + txid = arg.txid; + timestamp = arg.timestamp; + continue; + } + throw new Error('unknown parameter: '+arg); } } @@ -533,6 +561,13 @@ Graphs.prototype.list = function listGraphs() { if (sep === '?') { sep = '&'; } } + if (timestamp !== null && timestamp !== void 0) { + if (timestamp.value !== null) { + endpoint += sep+'timestamp='+timestamp.value; + if (sep === '?') { sep = '&'; } + } + } + var connectionParams = this.client.connectionParams; var requestOptions = mlutil.copyProperties(connectionParams); requestOptions.method = 'GET'; @@ -551,6 +586,7 @@ Graphs.prototype.list = function listGraphs() { operation.contentType = contentType; } operation.outputTransform = listOutputTransform; + operation.timestamp = (timestamp !== null) ? timestamp : null; return requester.startRequest(operation); }; @@ -565,7 +601,7 @@ Graphs.prototype.list = function listGraphs() { * @param {string|string[]} [defaultGraphs] - the default graphs for the SPARQL query * @param {string|string[]} [namedGraphs] - the named graphs for the SPARQL query * @param {string|ReadableStream} query - the SPARQL query - * @param {object} [documentQuery] - a {@link queryBuilder.Query} returned + * @param {object} [docQuery] - a {@link queryBuilder.Query} returned * by the query builder functions that qualifies the documents * supplying the triples * @param {number} [start] - the zero-based position @@ -588,6 +624,8 @@ Graphs.prototype.list = function listGraphs() { * @param {object} [bindings] - the values for placeholder variables within the query * specified with an object whose keys are the names of the variables and whose values * are either primitives or objects with a type or lang key and a value key + * @param {DatabaseClient.Timestamp} [timestamp] - a Timestamp object for point-in-time + * operations * @returns {ResultProvider} an object whose stream() function returns a read stream * that receives the query response */ @@ -613,6 +651,7 @@ Graphs.prototype.sparql = function queryGraphSPARQL() { var defaultRulesets = null; var optimizeLevel = null; var bindings = null; + var timestamp = null; // TODO: collection, directory? @@ -633,6 +672,7 @@ Graphs.prototype.sparql = function queryGraphSPARQL() { defaultRulesets = params.defaultRulesets; optimizeLevel = params.optimizeLevel; bindings = params.bindings; + timestamp = params.timestamp; if ((acceptType == null) || (query == null)) { throw new Error('named parameters must specify content type and query for SPARQL query on graphs'); } @@ -689,6 +729,13 @@ Graphs.prototype.sparql = function queryGraphSPARQL() { } } + if (timestamp !== null && timestamp !== void 0) { + if (timestamp.value !== null) { + endpoint += sep+'timestamp='+timestamp.value; + if (sep === '?') { sep = '&'; } + } + } + var commonParams = makeCommonSPARQLParams( base, txid, rulesets, defaultRulesets, optimizeLevel, bindings, sep ); @@ -711,6 +758,7 @@ Graphs.prototype.sparql = function queryGraphSPARQL() { throw new Error('cannot qualify a SPARQL query with a Query By Example'); } + // Handle builtQuery as a QueryBuilder object or a combined query queryBody = qb.lib.makeSearchBody(builtQuery).searchBody; queryBody.search.sparql = query; } @@ -736,6 +784,7 @@ Graphs.prototype.sparql = function queryGraphSPARQL() { operation.requestBody = queryBody; operation.errorTransform = uriErrorTransform; + operation.timestamp = (timestamp !== null) ? timestamp : null; return requester.startRequest(operation); }; @@ -917,61 +966,7 @@ function makeCommonSPARQLParams( if (sep === '?') { sep = '&'; } } if (bindings !== null && bindings !== void 0) { - var keys = Object.keys(bindings); - var max = keys.length; - - var key = null; - var obj = null; - var type = null; - var lang = null; - var hasType = false; - var hasLang = false; - var name = null; - var value = null; - - for (var i = 0; i < max; i++) { - key = keys[i]; - obj = bindings[key]; - - value = obj.value; - if (value === void 0) { - name = key; - value = obj; - } else { - type = obj.type; - lang = obj.lang; - - hasType = (type !== null && type !== void 0); - if (hasType) { - if (typeof type !== 'string' && !(type instanceof String)) { - throw new Error('type must be string'); - } - if (type.indexOf(':') > -1) { - throw new Error('type cannot contain colon - '+type); - } - } - - hasLang = (lang !== null && lang !== void 0); - if (hasLang) { - if (typeof lang !== 'string' && !(lang instanceof String)) { - throw new Error('lang must be string'); - } - } - - if (hasType && hasLang && type !== 'string') { - throw new Error('cannot combine type with lang - '+type+' '+lang); - } else if (hasLang) { - name = key + '@' + lang; - } else if (hasType) { - name = key + ':' + type; - } else { - name = key; - } - } - - endpoint += sep+encodeURIComponent('bind:'+name)+'='+encodeURIComponent(value); - if (i === 0 && sep === '?') { sep = '&'; } - } + endpoint += mlutil.makeBindingsParams(bindings, sep); } return (endpoint === '') ? null : endpoint; diff --git a/lib/marklogic.js b/lib/marklogic.js index c568d2d9..7a4251b5 100644 --- a/lib/marklogic.js +++ b/lib/marklogic.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ var mllog = require('./mllog.js'); var documents = require('./documents.js'); var Graphs = require('./graphs.js'); +var Rows = require('./rows.js'); var Values = require('./values.js'); var ExtLibs = require('./extlibs.js'); var RESTServerProperties = require('./rest-server-properties.js'); @@ -35,6 +36,7 @@ var serverExec = require('./server-exec.js'); var queryBuilder = require('./query-builder.js'); var patchBuilder = require('./patch-builder.js'); var valuesBuilder = require('./values-builder.js'); +var planBuilder = require('./plan-builder.js'); /** * Provides functions to connect to a MarkLogic database and to build @@ -274,6 +276,15 @@ function MarkLogicClient(connectionParams) { * @type {documents} */ this.documents = documents.create(this); + /** + * Provides functions for performing relational operations + * on indexed values and documents in the database. + * @name rows + * @since 2.1.1 + * @memberof! DatabaseClient# + * @type {rows} + */ + this.rows = new Rows(this); /** * Provides functions that open, commit, or rollback multi-statement * transactions. @@ -598,6 +609,24 @@ MarkLogicClient.prototype.getLogger = function getClientLogger() { return logger; }; +/** + * An object representing a timestamp on the server. + * @typedef {object} DatabaseClient.Timestamp + * @since 2.1.1 + */ + +/** + * Creates a timestamp object. + * @method DatabaseClient#createTimestamp + * @since 2.1.1 + * @param {string} [value] - a timestamp value as a string. + * @returns {Timestamp} - a Timestamp object. + */ +MarkLogicClient.prototype.createTimestamp = function databaseCreateTimestamp(value) { + let ts = new mlutil.Timestamp(value ? value : null); + return ts; +}; + function initClient(client, inputParams) { var connectionParams = {}; var keys = ['host', 'port', 'database', 'user', 'password', 'authType']; @@ -706,6 +735,13 @@ module.exports = { * to project tuples (rows) of values from documents */ valuesBuilder: valuesBuilder.builder, + /** + * A factory for creating a rows plan builder. + * @function marklogic.planBuilder + * @since 2.4 + * @returns {planBuilder} a helper for defining a rows query + */ + planBuilder: planBuilder.builder, /** * Configures the slice mode of the query builder and values builder diff --git a/lib/mllog.js b/lib/mllog.js index 1abb94c4..8a54a433 100644 --- a/lib/mllog.js +++ b/lib/mllog.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/mlutil.js b/lib/mlutil.js index 14da629e..7799e772 100644 --- a/lib/mlutil.js +++ b/lib/mlutil.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -307,6 +307,20 @@ function addTxidHeaders(requestOptions, txid) { } } +function Timestamp(value) { + if (!(this instanceof Timestamp)) { + return new Timestamp(); + } + this.value = null; + if (value !== undefined && value !== null) { + if (typeof value === 'string' || value instanceof String) { + this.value = value; + } else { + throw new Error('timestamp value must be specified as a string'); + } + } +} + // Slice mode can be 'array' or 'legacy' var sliceMode = 'array'; function setSliceMode(mode) { @@ -378,6 +392,69 @@ function makeSliceClause(variant, args) { return sliceClause; } +function makeBindingsParams(bindings, sep) { + + var keys = Object.keys(bindings); + var max = keys.length; + + var key = null; + var obj = null; + var type = null; + var lang = null; + var hasType = false; + var hasLang = false; + var name = null; + var value = null; + var paramStr = ''; + + for (var i = 0; i < max; i++) { + key = keys[i]; + obj = bindings[key]; + + value = obj.value; + if (value === void 0) { + name = key; + value = obj; + } else { + type = obj.type; + lang = obj.lang; + + hasType = (type !== null && type !== void 0); + if (hasType) { + if (typeof type !== 'string' && !(type instanceof String)) { + throw new Error('type must be string'); + } + if (type.indexOf(':') > -1) { + throw new Error('type cannot contain colon - '+type); + } + } + + hasLang = (lang !== null && lang !== void 0); + if (hasLang) { + if (typeof lang !== 'string' && !(lang instanceof String)) { + throw new Error('lang must be string'); + } + } + + if (hasType && hasLang && type !== 'string') { + throw new Error('cannot combine type with lang - '+type+' '+lang); + } else if (hasLang) { + name = key + '@' + lang; + } else if (hasType) { + name = key + ':' + type; + } else { + name = key; + } + } + + paramStr += sep+encodeURIComponent('bind:'+name)+'='+encodeURIComponent(value); + if (i === 0 && sep === '?') { sep = '&'; } + } + + return paramStr; + +} + module.exports = { addTxidHeaders: addTxidHeaders, appendItem: appendItem, @@ -392,11 +469,13 @@ module.exports = { first: first, getTxidParam: getTxidParam, makeSliceClause: makeSliceClause, + makeBindingsParams: makeBindingsParams, marshal: marshal, multipartBoundary: multipartBoundary, parseJSON: parseJSON, rootname: rootname, setSliceMode: setSliceMode, + Timestamp: Timestamp, Transaction: Transaction, unmarshal: unmarshal }; diff --git a/lib/operation.js b/lib/operation.js index 3bffec1c..af3dfbf4 100644 --- a/lib/operation.js +++ b/lib/operation.js @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 MarkLogic Corporation + * Copyright 2015-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,9 +44,13 @@ function Operation(name, client, options, requestType, responseType) { this.responseHeaders = null; this.outputStreamMode = null; this.outputStream = null; - this.streamModes = this.STREAM_MODES_CHUNKED_OBJECT; + this.streamModes = this.STREAM_MODES_CHUNKED_OBJECT_SEQUENCE; + this.nextMetadataBuffer = null; + this.timestamp = null; + this.complexValues = null; } -Operation.prototype.STREAM_MODES_CHUNKED_OBJECT = {chunked: true, object: true}; +Operation.prototype.STREAM_MODES_CHUNKED_OBJECT_SEQUENCE = + {chunked: true, object: true, sequence: true}; Operation.prototype.emptyHeaderData = function emptyHeaderData( response @@ -90,86 +94,88 @@ Operation.prototype.collectBodyObject = function collectBodyObject(data) { return bodyObject; }; -Operation.prototype.queueDocument = function queueDocument( - data, rawHeaderQueue, metadataBuffer, objectQueue +/** + * Make an object out of multipart part data + * @param {Buffer} data - Multipart part data + * @param {FifoQueue} rawHeaderQueue - Queue of headers for part data + * @return {Object} - The object + * + * @ignore + */ +Operation.prototype.makeObject = function makeObject( + data, rawHeaderQueue ) { var operation = this; var outputTransform = operation.outputTransform; + var partObject = null; + // Get corresponding multipart header for part var partRawHeaders = rawHeaderQueue.pollFirst(); - var partHeaders = parsePartHeaders(partRawHeaders); - var partUri = partHeaders.uri; - var isInline = (partUri == null); + var isInline = (partUri == null && !partHeaders.kind); var isMetadata = ( !isInline && (partHeaders.category != null) && partHeaders.category !== 'content' ); + // Convert buffer data to object var partData = mlutil.unmarshal(partHeaders.format, data); - var nextMetadataBuffer = null; - var partObject = null; + // Inline case if (isInline) { - if (metadataBuffer !== null) { - operation.queueMetadata(metadataBuffer, objectQueue); - } operation.logger.debug('parsed inline'); + // Resource execs and server-side evals if (operation.inlineAsDocument) { partHeaders.content = partData; partObject = partHeaders; - } else { - partObject = partData; } - } else if (isMetadata) { - if (metadataBuffer !== null) { - operation.queueMetadata(metadataBuffer, objectQueue); + // Search summaries + else { + partObject = partData; } + } + // Metadata case + else if (isMetadata) { operation.logger.debug('parsed metadata for %s', partUri); - nextMetadataBuffer = [partHeaders, partData]; - } else { + if (this.nextMetadataBuffer !== null) { + var metadataHeaders = this.nextMetadataBuffer[0]; + mlutil.copyProperties(this.nextMetadataBuffer[1], metadataHeaders); + partObject = metadataHeaders; + } + this.nextMetadataBuffer = [partHeaders, partData]; + } + // Content case + else { operation.logger.debug('parsed content for %s', partUri); - if (metadataBuffer !== null) { - if (metadataBuffer[0].uri === partUri) { - operation.logger.debug('copying metadata for %s', partUri); - mlutil.copyProperties(metadataBuffer[1], partHeaders); - } else { - operation.queueMetadata(metadataBuffer, objectQueue); - } + // If metadata exists, copy to object + if (this.nextMetadataBuffer !== null) { + operation.logger.debug('copying metadata for %s', partUri); + mlutil.copyProperties(this.nextMetadataBuffer[1], partHeaders); + this.nextMetadataBuffer = null; } partHeaders.content = partData; partObject = partHeaders; } if (partObject !== null) { + // Subdata processing (poor man's XPath) var subdata = operation.subdata; if (Array.isArray(subdata)) { partObject = projectData(partObject, subdata, 0); } - + // Transform if (outputTransform != null) { partObject = outputTransform.call(operation, partRawHeaders, partObject); } - - if (partObject !== void 0) { - objectQueue.addLast(partObject); - } else { + if (partObject === void 0) { operation.logger.debug('skipped undefined output from transform'); } } - - return nextMetadataBuffer; -}; -Operation.prototype.queueMetadata = function queueMetadata( - metadataBuffer, objectQueue - ) { - var metadataHeaders = metadataBuffer[0]; - mlutil.copyProperties(metadataBuffer[1], metadataHeaders); - objectQueue.addLast(metadataHeaders); + return partObject; }; Operation.prototype.dispatchError = function dispatchError(error) { var operation = this; @@ -237,7 +243,8 @@ Operation.prototype.copyResponseHeaders = function copyResponseHeaders(response) responseHeaders['content-length'], responseHeaders.etag, responseHeaders.location, - responseHeaders['x-marklogic-system-time'] + responseHeaders['x-marklogic-system-time'], + responseHeaders['ml-lsqt'] ); switch(format) { @@ -250,7 +257,7 @@ Operation.prototype.copyResponseHeaders = function copyResponseHeaders(response) } }; function OperationHeaders( - contentType, format, contentLength, versionId, location, systemTime + contentType, format, contentLength, versionId, location, systemTime, lsqt ) { this.contentType = contentType; this.format = format; @@ -272,6 +279,7 @@ function OperationHeaders( this.location = (location == null) ? null : location; this.systemTime = (systemTime == null) ? null : systemTime; + this.lsqt = (lsqt == null) ? null : lsqt; } function trimContentType(contentType) { if (contentType == null) { @@ -388,6 +396,11 @@ function parsePartHeaders(headers) { partHeaders.contentLength = contentLengthArray[0]; } + var contentIdArray = headers['content-id']; + if (Array.isArray(contentIdArray) && contentIdArray.length > 0) { + partHeaders.contentId = contentIdArray[0].slice(1, -1); + } + return partHeaders; } diff --git a/lib/optional.js b/lib/optional.js index 12824e98..cee208b4 100644 --- a/lib/optional.js +++ b/lib/optional.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/patch-builder.js b/lib/patch-builder.js index ec0c7130..2d72b1c2 100644 --- a/lib/patch-builder.js +++ b/lib/patch-builder.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -438,7 +438,7 @@ function replace() { cardinality = arg; continue; } - if (apply == null) { + if (apply === null || apply === undefined) { apply = arg.apply; if (apply != null) { content = arg.content; @@ -529,7 +529,7 @@ function replaceInsert() { continue; } } - if (apply == null) { + if (apply === null || apply === undefined) { apply = arg.apply; if (apply != null) { content = arg.content; diff --git a/lib/plan-builder-base.js b/lib/plan-builder-base.js new file mode 100644 index 00000000..7ed1f438 --- /dev/null +++ b/lib/plan-builder-base.js @@ -0,0 +1,433 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const types = require('./server-types-generated.js'); + +function checkMinArity(funcName, argsLen, minArity) { + if (argsLen < minArity) { + throw new Error( + `${funcName} takes a minimum of ${minArity} arguments but received: ${argsLen}` + ); + } +} +function checkMaxArity(funcName, argsLen, maxArity) { + if (argsLen > maxArity) { + throw new Error( + `${funcName} takes a maximum of ${maxArity} arguments but received: ${argsLen}` + ); + } +} +function checkArity(funcName, argsLen, minArity, maxArity) { + checkMinArity(funcName, argsLen, minArity); + checkMaxArity(funcName, argsLen, maxArity); +} + +function checkArg(arg, funcName, argPos, paramName, paramTypes, isRequired, isMultiple) { + if (arg === void 0) { + if (isRequired) { + throw new Error( + `${argLabel(funcName, paramName, argPos)} is a required ${typeLabel(paramTypes)} value` + ); + } + return null; + } else if (Array.isArray(arg)) { + if (!isMultiple) { + throw new Error( + `${argLabel(funcName, paramName, argPos)} must be one ${typeLabel(paramTypes)} value instead of an array` + ); + } else if (arg.length === 0 && isRequired) { + throw new Error( + `${argLabel(funcName, paramName, argPos)} array must have at least one ${typeLabel(paramTypes)} value` + ); + } + return arg.map(val => castArg(val, funcName, paramName, argPos, paramTypes)); + } + + const val = castArg(arg, funcName, paramName, argPos, paramTypes); + const result = isMultiple ? [val] : val; + return result; +} +function castArg(arg, funcName, paramName, argPos, paramTypes) { + if (arg === void 0 || arg === null || !Array.isArray(paramTypes) || paramTypes.length === 0) { + return arg; + } else if (arg instanceof Object) { + if (paramTypes.some(paramType => (arg instanceof paramType))) { + return arg; + } else if (arg instanceof Number || arg instanceof Boolean || arg instanceof String) { + arg = arg.valueOf(); + } else if (arg instanceof types.ServerType) { + throw new Error( + `${argLabel(funcName, paramName, argPos)} must have type ${typeLabel(paramTypes)}` + ); + } else if (paramTypes.some(paramType => { + const paramClass = paramType.name; + switch(paramClass) { + case 'PlanCtsReferenceMap': return Object.keys(arg).every(key => { + const value = arg[key]; + if (value instanceof types.CtsReference) { + return true; + } + throw new Error( + `${argLabel(funcName, paramName, argPos)} has ${key} key without a CtsReference value for ${typeLabel(paramTypes)}` + ); + }); + case 'PlanGroupConcatOption': return Object.keys(arg).every(key => { + const value = arg[key]; + switch(key) { + case 'separator': + if (typeof value === 'string' || value instanceof String) { + return true; + } + throw new Error( + `${argLabel(funcName, paramName, argPos)} separator must be a string for ${typeLabel(paramTypes)} options` + ); + case 'values': + if (value === 'distinct') { + return true; + } + throw new Error( + `${argLabel(funcName, paramName, argPos)} values can only be "distinct" for ${typeLabel(paramTypes)} options` + ); + default: + return false; + }}); + case 'PlanTripleOption': return Object.keys(arg).every(key => { + const value = arg[key]; + switch(key) { + case 'dedup': + switch(value) { + case 'on': + case 'off': + return true; + default: + throw new Error( + `${argLabel(funcName, paramName, argPos)} values for dedup can only be "on" or "off" for ${typeLabel(paramTypes)} options` + ); + } + break; + default: + return false; + }}); + case 'PlanValueOption': return Object.keys(arg).every(key => { + const value = arg[key]; + switch(key) { + case 'values': + if (value === 'distinct') { + return true; + } + throw new Error( + `${argLabel(funcName, paramName, argPos)} values can only be "distinct" for ${typeLabel(paramTypes)} options` + ); + default: + return false; + }}); + case 'PlanXsValueMap': + const keys = Object.keys(arg); + const columns = (keys.length === 2) ? arg.columnNames : null; + const rows = Array.isArray(columns) ? arg.rowValues : null; + if (Array.isArray(rows)) { + if (columns.every(column => (typeof column === 'string' || column instanceof String))) { + if (rows.every(row => (Array.isArray(row) && row.length <= columns.length))) { + return true; + } + } + return false; + } + return keys.every(key => { + const value = arg[key]; + const valtype = typeof value; + switch (valtype) { + case 'boolean': return true; + case 'number': return true; + case 'string': return true; + case 'object': + if (value === null || value instanceof String || value instanceof Number || value instanceof Boolean) { + return true; + } else if (value instanceof types.XsAnyAtomicType) { + const valArgs = value._args; + if (Array.isArray(valArgs) && valArgs.every(valArg => !(valArg instanceof types.ServerType))) { + return true; + } + throw new Error( + `${argLabel(funcName, paramName, argPos)} has ${key} key with expression value` + ); + } + break; + default: + throw new Error( + `${argLabel(funcName, paramName, argPos)} has ${key} key with ${valtype} instead of ${typeLabel(paramTypes)} literal value` + ); + }}); + default: + return false; + } + })) { + return arg; + } else { + throw new Error( + `${argLabel(funcName, paramName, argPos)} has invalid argument for ${typeLabel(paramTypes)} value: ${arg}` + ); + } + } + + const argType = typeof arg; + switch(argType) { + case 'boolean': + if (isProtoChained(paramTypes, [types.XsBoolean, types.BooleanNode, types.JsonContentNode])) { + return arg; + } + break; + case 'number': + if (isProtoChained(paramTypes, + [types.XsDecimal, types.XsDouble, types.XsFloat, types.XsNumeric, types.NumberNode, types.JsonContentNode])) { + return arg; + } + break; + case 'string': + if (isProtoChained(paramTypes, [types.XsAnyAtomicType, types.TextNode, types.JsonContentNode, types.XmlContentNode])) { + return arg; + } + break; + default: + throw new Error( + `${argLabel(funcName, paramName, argPos)} must be a ${typeLabel(paramTypes)} instead of ${argType} value` + ); + } + throw new Error( + `${argLabel(funcName, paramName, argPos)} must be a ${typeLabel(paramTypes)} value` + ); +} + +function isProtoChained(declaredTypes, valueTypes) { + return valueTypes.some(valueType => { + const valueProto = valueType.prototype; + return declaredTypes.some(declaredType => { + const declaredProto = declaredType.prototype; + return ( + declaredProto === valueProto || + declaredProto.isPrototypeOf(valueProto) || + valueProto.isPrototypeOf(declaredProto) + ); + }); + }); +} + +function argLabel(funcName, paramName, argPos) { + return `${paramName} argument at ${argPos} of ${funcName}()`; +} +function typeLabel(paramTypes) { + // vulnerable if a type ever has a name property + return paramTypes.map(paramType => paramType.name).join(' or '); +} + +function getNamer(args, name) { + const onlyArg = getOptionalArg(args); + const namer = (onlyArg === null || onlyArg[name] === void 0) ? null : onlyArg; + return namer; +} +function getOptionalArg(args) { + const firstArg = (args.length === 1) ? args[0] : void 0; + const onlyArg = (firstArg !== null && !Array.isArray(firstArg) && typeof firstArg === 'object') ? + firstArg : null; + return onlyArg; +} + +function makePositionalArgs(funcName, minArity, isUnbounded, paramDefs, args) { + const paramLen = paramDefs.length; + if (isUnbounded) { + checkMinArity(funcName, args.length, minArity); + } else { + checkArity(funcName, args.length, minArity, paramLen); + } + return args.map((arg, i) => { + const paramNum = (isUnbounded && i >= paramLen) ? (paramLen - 1) : i; + const paramDef = paramDefs[paramNum]; + return checkArg(arg, funcName, i, paramDef[0], paramDef[1], paramDef[2], paramDef[3]); + }); +} +function makeNamedArgs(namer, funcName, minArity, paramNames, paramDefs, args) { + Object.keys(namer).forEach(name => { + if (!paramNames.has(name)) { + throw new Error(`${name} is not a named parameter of ${funcName}`); + } + }); + args = []; + let paramDef = null; + let i = 0; + let j = -1; + for (const paramName of paramNames) { + const val = namer[paramName]; + if (val !== void 0) { + paramDef = paramDefs[++j]; + while (j < i) { + args.push(checkArg(null, funcName, j, paramDef[0], paramDef[1], paramDef[2], paramDef[3])); + paramDef = paramDefs[++j]; + } + args.push(checkArg(val, funcName, i, paramName, paramDef[1], paramDef[2], paramDef[3])); + } + i++; + } + while (++j < minArity) { + paramDef = paramDefs[j]; + args.push(checkArg(null, funcName, j, paramDef[0], paramDef[1], paramDef[2], paramDef[3])); + } + checkArity(funcName, args.length, minArity, paramNames.length); + return args; +} +function makeSingleArgs(funcName, minArity, paramDef, args) { + const argLen = args.length; + checkArity(funcName, argLen, minArity, 1); + if (argLen === 1) { + const paramName = paramDef[0]; + const namer = getNamer(args, paramName); + if (namer === null || namer instanceof types.ServerType) { + args[0] = checkArg(args[0], funcName, 0, paramName, paramDef[1], paramDef[2], paramDef[3]); + } else if (Object.keys(namer).length > 1) { + throw new Error(`named parameter object has keys other than ${paramName} for ${funcName}`); + } else { + args[0] = checkArg(namer[paramName], funcName, 0, paramName, paramDef[1], paramDef[2], paramDef[3]); + } + } + return args; +} + +function exportOperators(plan) { + const operList = plan._operators; + if (!Array.isArray(operList)) { + throw new Error(`operator list is not an array: `+operList); + } + return { + ns: 'op', + fn: 'operators', + args: operList.map(oper => exportOperator(oper)) + }; +} +function exportOperator(oper) { + const ns = oper._ns; + const fn = oper._fn; + const args = oper._args; + if (ns !== 'op' || fn === void 0 || !Array.isArray(args)) { + throw new Error(`cannot export invalid operator: ${oper}`); + } + + let exportedArgs = null; + switch(fn) { + case 'from-literals': + exportedArgs = args.map((arg, i) => { + if (i === 0) { + const lit = (!Array.isArray(arg)) ? arg : (arg.length ===1) ? arg[0] : void 0; + if (lit === void 0) { + return exportArgs(arg); + } else { + const columnNames = lit.columnNames; + const rowValues = lit.rowValues; + if (columnNames === void 0 || rowValues === void 0) { + return [exportArg(lit)]; + } else if (Array.isArray(columnNames) && Array.isArray(rowValues)) { + return rowValues.map((rowIn) => { + if (!Array.isArray(rowIn)) { + throw new Error(`literal row is not array: ${rowIn}`); + } + const rowOut = {}; + rowIn.forEach((value, j) => { + if (j > columnNames.length) { + throw new Error(`more values than column names: ${rowIn}`); + } + rowOut[columnNames[j]] = value; + }); + return rowOut; + }); + } else { + throw new Error(`no literals: ${oper}`); + } + } + } else { + return exportArg(arg); + } + }); + break; + case 'join-inner': + case 'join-left-outer': + case 'join-cross-product': + case 'except': + case 'intersect': + case 'union': + exportedArgs = args.map((arg, i) => { + if (i === 0) { + return exportOperators(arg); + } + return exportArg(arg); + }); + break; + default: + exportedArgs = exportArgs(args); + break; + } + + return {ns:ns, fn:fn, args:exportedArgs}; +} +function exportObject(obj) { + const ns = obj._ns; + const fn = obj._fn; + const args = obj._args; + if (ns !== void 0 && fn !== void 0 && Array.isArray(args)) { + return { + ns: ns, + fn: fn, + args: exportArgs(args) + }; + } + return Object.getOwnPropertyNames(obj).reduce( + (objCopy, key) => {objCopy[key] = exportArg(obj[key]); return objCopy;}, + {} + ); +} +function exportArgs(argList) { + if (argList === void 0 || argList === null || argList.length === 0 || + (argList.length === 1 && argList[0] === null) + ) { + return []; + } + return argList.map(arg => { + return exportArg(arg); + }); +} +function exportArg(arg) { + if (arg === null || typeof arg !== 'object' || + arg instanceof String || arg instanceof Number || arg instanceof Boolean + ) { + return arg; + } else if (!Array.isArray(arg)) { + return exportObject(arg); + } else if (arg.length === 1) { + return exportArg(arg[0]); + } + return exportArgs(arg); +} +function doExport(plan) { + return {$optic:exportOperators(plan)}; +} + +module.exports = { + checkArity: checkArity, + checkMaxArity: checkMaxArity, + getNamer: getNamer, + makeNamedArgs: makeNamedArgs, + makePositionalArgs: makePositionalArgs, + makeSingleArgs: makeSingleArgs, + doExport: doExport +}; diff --git a/lib/plan-builder-generated.js b/lib/plan-builder-generated.js new file mode 100644 index 00000000..845a2899 --- /dev/null +++ b/lib/plan-builder-generated.js @@ -0,0 +1,7148 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +/* IMPORTANT: Do not edit. This file is generated. */ +const types = require('./server-types-generated.js'); +const bldrbase = require('./plan-builder-base.js'); + +class CtsExpr { + constructor() { + } + /** + * Returns a query specifying the set difference of the matches specified by two sub-queries. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.andNotQuery|cts.andNotQuery} + * @method planBuilder.cts#andNotQuery + * @since 2.1.1 + * @param { CtsQuery } [positiveQuery] - A positive query, specifying the search results filtered in. + * @param { CtsQuery } [negativeQuery] - A negative query, specifying the search results to filter out. + * @returns { CtsQuery } + */ +andNotQuery(...args) { + const namer = bldrbase.getNamer(args, 'positive-query'); + const paramdefs = [['positive-query', [types.CtsQuery], true, false], ['negative-query', [types.CtsQuery], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.andNotQuery', 2, new Set(['positive-query', 'negative-query']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.andNotQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'and-not-query', checkedArgs); + + } +/** + * Returns a query specifying the intersection of the matches specified by the sub-queries. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.andQuery|cts.andQuery} + * @method planBuilder.cts#andQuery + * @since 2.1.1 + * @param { CtsQuery } [queries] - A sequence of sub-queries. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "ordered" An ordered and-query, which specifies that the sub-query matches must occur in the order of the specified sub-queries. For example, if the sub-queries are "cat" and "dog", an ordered query will only match fragments where both "cat" and "dog" occur, and where "cat" comes before "dog" in the fragment. "unordered" An unordered and-query, which specifies that the sub-query matches can occur in any order. + * @returns { CtsQuery } + */ +andQuery(...args) { + const namer = bldrbase.getNamer(args, 'queries'); + const paramdefs = [['queries', [types.CtsQuery], false, true], ['options', [types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.andQuery', 1, new Set(['queries', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.andQuery', 1, false, paramdefs, args); + return new types.CtsQuery('cts', 'and-query', checkedArgs); + + } +/** + * Returns a query specifying that matches to matching-query should have their search relevance scores boosted if they also match boosting-query. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.boostQuery|cts.boostQuery} + * @method planBuilder.cts#boostQuery + * @since 2.1.1 + * @param { CtsQuery } [matchingQuery] - A sub-query that is used for match and scoring. + * @param { CtsQuery } [boostingQuery] - A sub-query that is used only for boosting score. + * @returns { CtsQuery } + */ +boostQuery(...args) { + const namer = bldrbase.getNamer(args, 'matching-query'); + const paramdefs = [['matching-query', [types.CtsQuery], true, false], ['boosting-query', [types.CtsQuery], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.boostQuery', 2, new Set(['matching-query', 'boosting-query']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.boostQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'boost-query', checkedArgs); + + } +/** + * Returns a geospatial box value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.box|cts.box} + * @method planBuilder.cts#box + * @since 2.1.1 + * @param { XsDouble } [south] - The southern boundary of the box. + * @param { XsDouble } [west] - The western boundary of the box. + * @param { XsDouble } [north] - The northern boundary of the box. + * @param { XsDouble } [east] - The eastern boundary of the box. + * @returns { CtsBox } + */ +box(...args) { + const namer = bldrbase.getNamer(args, 'south'); + const paramdefs = [['south', [types.XsDouble], true, false], ['west', [types.XsDouble], true, false], ['north', [types.XsDouble], true, false], ['east', [types.XsDouble], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.box', 4, new Set(['south', 'west', 'north', 'east']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.box', 4, false, paramdefs, args); + return new types.CtsBox('cts', 'box', checkedArgs); + + } +/** + * Returns a geospatial circle value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.circle|cts.circle} + * @method planBuilder.cts#circle + * @since 2.1.1 + * @param { XsDouble } [radius] - The radius of the circle. The units for the radius is determined at runtime by the cts:query options (miles is currently the only option). + * @param { CtsPoint } [center] - A point representing the center of the circle. + * @returns { CtsCircle } + */ +circle(...args) { + const namer = bldrbase.getNamer(args, 'radius'); + const paramdefs = [['radius', [types.XsDouble], true, false], ['center', [types.CtsPoint], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.circle', 2, new Set(['radius', 'center']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.circle', 2, false, paramdefs, args); + return new types.CtsCircle('cts', 'circle', checkedArgs); + + } +/** + * Returns a query matching documents in the collections with the given URIs. It will match both documents and properties documents in the collections with the given URIs. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.collectionQuery|cts.collectionQuery} + * @method planBuilder.cts#collectionQuery + * @since 2.1.1 + * @param { XsString } [uris] - One or more collection URIs. + * @returns { CtsQuery } + */ +collectionQuery(...args) { + const paramdef = ['uris', [types.XsString], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('cts.collectionQuery', 1, paramdef, args); + return new types.CtsQuery('cts', 'collection-query', checkedArgs); + } +/** + * Creates a reference to the collection lexicon, for use as a parameter to cts:value-tuples. Since lexicons are implemented with range indexes, this function will throw an exception if the specified range index does not exist. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.collectionReference|cts.collectionReference} + * @method planBuilder.cts#collectionReference + * @since 2.1.1 + * @param { XsString } [options] - Options. The default is (). Options include: "nullable" Allow null values in tuples reported from cts:value-tuples when using this lexicon. "unchecked" Do not check the definition against the context database. + * @returns { CtsReference } + */ +collectionReference(...args) { + const paramdef = ['options', [types.XsString], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('cts.collectionReference', 0, paramdef, args); + return new types.CtsReference('cts', 'collection-reference', checkedArgs); + } +/** + * Returns a query matching documents in the directories with the given URIs. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.directoryQuery|cts.directoryQuery} + * @method planBuilder.cts#directoryQuery + * @since 2.1.1 + * @param { XsString } [uris] - One or more directory URIs. + * @param { XsString } [depth] - "1" for immediate children, "infinity" for all. If not supplied, depth is "1". + * @returns { CtsQuery } + */ +directoryQuery(...args) { + const namer = bldrbase.getNamer(args, 'uris'); + const paramdefs = [['uris', [types.XsString], false, true], ['depth', [types.XsString], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.directoryQuery', 1, new Set(['uris', 'depth']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.directoryQuery', 1, false, paramdefs, args); + return new types.CtsQuery('cts', 'directory-query', checkedArgs); + + } +/** + * Returns a query that matches all documents where query matches any document fragment. When searching documents, document-properties, or document-locks, cts:document-fragment-query provides a convenient way to additionally constrain the search against any document fragment. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.documentFragmentQuery|cts.documentFragmentQuery} + * @method planBuilder.cts#documentFragmentQuery + * @since 2.1.1 + * @param { CtsQuery } [query] - A query to be matched against any document fragment. + * @returns { CtsQuery } + */ +documentFragmentQuery(...args) { + const paramdef = ['query', [types.CtsQuery], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('cts.documentFragmentQuery', 1, paramdef, args); + return new types.CtsQuery('cts', 'document-fragment-query', checkedArgs); + } +/** + * Returns a query matching documents with the given URIs. It will match both documents and properties documents with the given URIs. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.documentQuery|cts.documentQuery} + * @method planBuilder.cts#documentQuery + * @since 2.1.1 + * @param { XsString } [uris] - One or more document URIs. + * @returns { CtsQuery } + */ +documentQuery(...args) { + const paramdef = ['uris', [types.XsString], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('cts.documentQuery', 1, paramdef, args); + return new types.CtsQuery('cts', 'document-query', checkedArgs); + } +/** + * Returns a cts:query matching elements by name which has specific attributes representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementAttributePairGeospatialQuery|cts.elementAttributePairGeospatialQuery} + * @method planBuilder.cts#elementAttributePairGeospatialQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more parent element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsQName } [latitudeAttributeNames] - One or more latitude attribute QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching latitude attribute in any point instance will be checked. + * @param { XsQName } [longitudeAttributeNames] - One or more longitude attribute QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching longitude attribute in any point instance will be checked. + * @param { CtsRegion } [regions] - One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "coordinate-system=string" Use the given coordinate system. Valid values are: wgs84The WGS84 coordinate system. wgs84/doubleThe WGS84 coordinate system at double precision. etrs89The ETRS89 coordinate system. etrs89/doubleThe ETRS89 coordinate system at double precision. rawThe raw (unmapped) coordinate system. raw/doubleThe raw coordinate system at double precision. "precision=value" Use the coordinate system at the given precision. Allowed values: float and double. "units=value" Measure distance and the radii of circles in the specified units. Allowed values: miles (default), km, feet, meters. "boundaries-included" Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes', circles', and polygons' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching. "boundaries-endpoints-excluded" Points on linestrings' boundary (the endpoints) are not counted as matching. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $regions parameter are considered synonyms for scoring purposes. The result is that occurances of more than one of the synonyms are scored as if there are more occurance of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +elementAttributePairGeospatialQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['latitude-attribute-names', [types.XsQName], false, true], ['longitude-attribute-names', [types.XsQName], false, true], ['regions', [types.CtsRegion], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementAttributePairGeospatialQuery', 4, new Set(['element-name', 'latitude-attribute-names', 'longitude-attribute-names', 'regions', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementAttributePairGeospatialQuery', 4, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-attribute-pair-geospatial-query', checkedArgs); + + } +/** + * Returns a cts:query matching element-attributes by name with a range-index entry equal to a given value. Searches with the cts:element-attribute-range-query constructor require an attribute range index on the specified QName(s); if there is no range index configured, then an exception is thrown. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementAttributeRangeQuery|cts.elementAttributeRangeQuery} + * @method planBuilder.cts#elementAttributeRangeQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsQName } [attributeName] - One or more attribute QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsString } [operator] - A comparison operator. Operators include: "<" Match range index values less than $value. "<=" Match range index values less than or equal to $value. ">" Match range index values greater than $value. ">=" Match range index values greater than or equal to $value. "=" Match range index values equal to $value. "!=" Match range index values not equal to $value. + * @param { XsAnyAtomicType } [value] - Some values to match. When multiple values are specified, the query matches if any value matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "collation=URI" Use the range index with the collation specified by URI. If not specified, then the default collation from the query is used. If a range index with the specified collation does not exist, an error is thrown. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $value parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +elementAttributeRangeQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['attribute-name', [types.XsQName], false, true], ['operator', [types.XsString], true, false], ['value', [types.XsAnyAtomicType], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementAttributeRangeQuery', 4, new Set(['element-name', 'attribute-name', 'operator', 'value', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementAttributeRangeQuery', 4, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-attribute-range-query', checkedArgs); + + } +/** + * Creates a reference to an element attribute value lexicon, for use as a parameter to cts:value-tuples. Since lexicons are implemented with range indexes, this function will throw an exception if the specified range index does not exist. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementAttributeReference|cts.elementAttributeReference} + * @method planBuilder.cts#elementAttributeReference + * @since 2.1.1 + * @param { XsQName } [element] - An element QName. + * @param { XsQName } [attribute] - An attribute QName. + * @param { XsString } [options] - Options. The default is (). Options include: "type=type" Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, anyURI, point, or long-lat-point) "collation=URI" Use the lexicon with the collation specified by URI. "nullable" Allow null values in tuples reported from cts:value-tuples when using this lexicon. "unchecked" Read the scalar type, collation and coordinate-system info only from the input. Do not check the definition against the context database. "coordinate-system=name" Create a reference to an index or lexicon based on the specified coordinate system. Allowed values: "wgs84", "wgs84/double", "raw", "raw/double". Only applicable if the index/lexicon value type is point or long-lat-point. "precision=value" Create a reference to an index or lexicon configured with the specified geospatial precision. Allowed values: float and double. Only applicable if the index/lexicon value type is point or long-lat-point. This value takes precedence over the precision implicit in the coordinate system name. + * @returns { CtsReference } + */ +elementAttributeReference(...args) { + const namer = bldrbase.getNamer(args, 'element'); + const paramdefs = [['element', [types.XsQName], true, false], ['attribute', [types.XsQName], true, false], ['options', [types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementAttributeReference', 2, new Set(['element', 'attribute', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementAttributeReference', 2, false, paramdefs, args); + return new types.CtsReference('cts', 'element-attribute-reference', checkedArgs); + + } +/** + * Returns a query matching elements by name with attributes by name with text content equal a given phrase. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementAttributeValueQuery|cts.elementAttributeValueQuery} + * @method planBuilder.cts#elementAttributeValueQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsQName } [attributeName] - One or more attribute QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsString } [text] - One or more attribute values to match. When multiple strings are specified, the query matches if any string matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "case-sensitive" A case-sensitive query. "case-insensitive" A case-insensitive query. "diacritic-sensitive" A diacritic-sensitive query. "diacritic-insensitive" A diacritic-insensitive query. "punctuation-sensitive" A punctuation-sensitive query. "punctuation-insensitive" A punctuation-insensitive query. "whitespace-sensitive" A whitespace-sensitive query. "whitespace-insensitive" A whitespace-insensitive query. "stemmed" A stemmed query. "unstemmed" An unstemmed query. "wildcarded" A wildcarded query. "unwildcarded" An unwildcarded query. "exact" An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded". "lang=iso639code" Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "synonym" Specifies that all of the terms in the $text parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). * "lexicon-expansion-limit=number" Specifies the limit for lexicon expansion. This puts a restriction on the number of lexicon expansions that can be performed. If the limit is exceeded, the server may raise an error depending on whether the "limit-check" option is set. The default value for this option will be 4096. "limit-check" Specifies that an error will be raised if the lexicon expansion exceeds the specified limit. "no-limit-check" Specifies that error will not be raised if the lexicon expansion exceeds the specified limit. The server will try to resolve the wildcard. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +elementAttributeValueQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['attribute-name', [types.XsQName], false, true], ['text', [types.XsString], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementAttributeValueQuery', 3, new Set(['element-name', 'attribute-name', 'text', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementAttributeValueQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-attribute-value-query', checkedArgs); + + } +/** + * Returns a query matching elements by name with attributes by name with text content containing a given phrase. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementAttributeWordQuery|cts.elementAttributeWordQuery} + * @method planBuilder.cts#elementAttributeWordQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsQName } [attributeName] - One or more attribute QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsString } [text] - Some words or phrases to match. When multiple strings are specified, the query matches if any string matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "case-sensitive" A case-sensitive query. "case-insensitive" A case-insensitive query. "diacritic-sensitive" A diacritic-sensitive query. "diacritic-insensitive" A diacritic-insensitive query. "punctuation-sensitive" A punctuation-sensitive query. "punctuation-insensitive" A punctuation-insensitive query. "whitespace-sensitive" A whitespace-sensitive query. "whitespace-insensitive" A whitespace-insensitive query. "stemmed" A stemmed query. "unstemmed" An unstemmed query. "wildcarded" A wildcarded query. "unwildcarded" An unwildcarded query. "exact" An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded". "lang=iso639code" Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "synonym" Specifies that all of the terms in the $text parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). "lexicon-expand=value" The value is one of full, prefix-postfix, off, or heuristic (the default is heuristic). An option with a value of lexicon-expand=full specifies that wildcards are resolved by expanding the pattern to words in a lexicon (if there is one available), and turning into a series of cts:word-queries, even if this takes a long time to evaluate. An option with a value of lexicon-expand=prefix-postfix specifies that wildcards are resolved by expanding the pattern to the pre- and postfixes of the words in the word lexicon (if there is one), and turning the query into a series of character queries, even if it takes a long time to evaluate. An option with a value of lexicon-expand=off specifies that wildcards are only resolved by looking up character patterns in the search pattern index, not in the lexicon. An option with a value of lexicon-expand=heuristic, which is the default, specifies that wildcards are resolved by using a series of internal rules, such as estimating the number of lexicon entries that need to be scanned, seeing if the estimate crosses certain thresholds, and (if appropriate), using another way besides lexicon expansion to resolve the query. * "lexicon-expansion-limit=number" Specifies the limit for lexicon expansion. This puts a restriction on the number of lexicon expansions that can be performed. If the limit is exceeded, the server may raise an error depending on whether the "limit-check" option is set. The default value for this option will be 4096. "limit-check" Specifies that an error will be raised if the lexicon expansion exceeds the specified limit. "no-limit-check" Specifies that error will not be raised if the lexicon expansion exceeds the specified limit. The server will try to resolve the wildcard. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +elementAttributeWordQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['attribute-name', [types.XsQName], false, true], ['text', [types.XsString], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementAttributeWordQuery', 3, new Set(['element-name', 'attribute-name', 'text', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementAttributeWordQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-attribute-word-query', checkedArgs); + + } +/** + * Returns a cts:query matching elements by name which has specific element children representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementChildGeospatialQuery|cts.elementChildGeospatialQuery} + * @method planBuilder.cts#elementChildGeospatialQuery + * @since 2.1.1 + * @param { XsQName } [parentElementName] - One or more parent element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsQName } [childElementNames] - One or more child element QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching latitude child in any point instance will be checked. The element must specify both latitude and longitude coordinates. + * @param { CtsRegion } [regions] - One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "coordinate-system=string" Use the given coordinate system. Valid values are: wgs84The WGS84 coordinate system. wgs84/doubleThe WGS84 coordinate system at double precision. etrs89The ETRS89 coordinate system. etrs89/doubleThe ETRS89 coordinate system at double precision. rawThe raw (unmapped) coordinate system. raw/doubleThe raw coordinate system at double precision. "precision=string" Use the coordinate system at the given precision. Allowed values: float (default) and double. "units=value" Measure distance and the radii of circles in the specified units. Allowed values: miles (default), km, feet, meters. "boundaries-included" Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes', circles', and polygons' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching. "boundaries-endpoints-excluded" Points on linestrings' boundary (the endpoints) are not counted as matching. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "type=long-lat-point" Specifies the format for the point in the data as longitude first, latitude second. "type=point" Specifies the format for the point in the data as latitude first, longitude second. This is the default format. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $regions parameter are considered synonyms for scoring purposes. The result is that occurances of more than one of the synonyms are scored as if there are more occurance of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +elementChildGeospatialQuery(...args) { + const namer = bldrbase.getNamer(args, 'parent-element-name'); + const paramdefs = [['parent-element-name', [types.XsQName], false, true], ['child-element-names', [types.XsQName], false, true], ['regions', [types.CtsRegion], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementChildGeospatialQuery', 3, new Set(['parent-element-name', 'child-element-names', 'regions', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementChildGeospatialQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-child-geospatial-query', checkedArgs); + + } +/** + * Returns a cts:query matching elements by name whose content represents a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementGeospatialQuery|cts.elementGeospatialQuery} + * @method planBuilder.cts#elementGeospatialQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { CtsRegion } [regions] - One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "coordinate-system=string" Use the given coordinate system. Valid values are: wgs84The WGS84 coordinate system. wgs84/doubleThe WGS84 coordinate system at double precision. etrs89The ETRS89 coordinate system. etrs89/doubleThe ETRS89 coordinate system at double precision. rawThe raw (unmapped) coordinate system. raw/doubleThe raw coordinate system at double precision. "precision=value" Use the coordinate system at the given precision. Allowed values: float and double. "units=value" Measure distance and the radii of circles in the specified units. Allowed values: miles (default), km, feet, meters. "boundaries-included" Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes', circles', and polygons' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching. "boundaries-endpoints-excluded" Points on linestrings' boundary (the endpoints) are not counted as matching. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "type=long-lat-point" Specifies the format for the point in the data as longitude first, latitude second. "type=point" Specifies the format for the point in the data as latitude first, longitude second. This is the default format. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $regions parameter are considered synonyms for scoring purposes. The result is that occurances of more than one of the synonyms are scored as if there are more occurance of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +elementGeospatialQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['regions', [types.CtsRegion], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementGeospatialQuery', 2, new Set(['element-name', 'regions', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementGeospatialQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-geospatial-query', checkedArgs); + + } +/** + * Returns a cts:query matching elements by name which has specific element children representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementPairGeospatialQuery|cts.elementPairGeospatialQuery} + * @method planBuilder.cts#elementPairGeospatialQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more parent element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsQName } [latitudeElementNames] - One or more latitude element QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching latitude child in any point instance will be checked. + * @param { XsQName } [longitudeElementNames] - One or more longitude element QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching longitude child in any point instance will be checked. + * @param { CtsRegion } [regions] - One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "coordinate-system=string" Use the given coordinate system. Valid values are: wgs84The WGS84 coordinate system. wgs84/doubleThe WGS84 coordinate system at double precision. etrs89The ETRS89 coordinate system. etrs89/doubleThe ETRS89 coordinate system at double precision. rawThe raw (unmapped) coordinate system. raw/doubleThe raw coordinate system at double precision. "precision=value" Use the coordinate system at the given precision. Allowed values: float and double. "units=value" Measure distance and the radii of circles in the specified units. Allowed values: miles (default), km, feet, meters. "boundaries-included" Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes', circles', and polygons' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching. "boundaries-endpoints-excluded" Points on linestrings' boundary (the endpoints) are not counted as matching. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $regions parameter are considered synonyms for scoring purposes. The result is that occurances of more than one of the synonyms are scored as if there are more occurance of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +elementPairGeospatialQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['latitude-element-names', [types.XsQName], false, true], ['longitude-element-names', [types.XsQName], false, true], ['regions', [types.CtsRegion], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementPairGeospatialQuery', 4, new Set(['element-name', 'latitude-element-names', 'longitude-element-names', 'regions', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementPairGeospatialQuery', 4, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-pair-geospatial-query', checkedArgs); + + } +/** + * Returns a cts:query matching elements by name with the content constrained by the given cts:query in the second parameter. Searches for matches in the specified element and all of its descendants. If the specified query in the second parameter has any cts:element-attribute-*-query constructors, it will search attributes directly on the specified element and attributes on any descendant elements (see the second example below). Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementQuery|cts.elementQuery} + * @method planBuilder.cts#elementQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { CtsQuery } [query] - A query for the element to match. If a string is entered, the string is treated as a cts:word-query of the specified string. + * @returns { CtsQuery } + */ +elementQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['query', [types.CtsQuery], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementQuery', 2, new Set(['element-name', 'query']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-query', checkedArgs); + + } +/** + * Returns a cts:query matching elements by name with a range-index entry equal to a given value. Searches with the cts:element-range-query constructor require an element range index on the specified QName(s); if there is no range index configured, then an exception is thrown. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementRangeQuery|cts.elementRangeQuery} + * @method planBuilder.cts#elementRangeQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsString } [operator] - A comparison operator. Operators include: "<" Match range index values less than $value. "<=" Match range index values less than or equal to $value. ">" Match range index values greater than $value. ">=" Match range index values greater than or equal to $value. "=" Match range index values equal to $value. "!=" Match range index values not equal to $value. + * @param { XsAnyAtomicType } [value] - One or more element values to match. When multiple values are specified, the query matches if any value matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "collation=URI" Use the range index with the collation specified by URI. If not specified, then the default collation from the query is used. If a range index with the specified collation does not exist, an error is thrown. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $value parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +elementRangeQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['operator', [types.XsString], true, false], ['value', [types.XsAnyAtomicType], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementRangeQuery', 3, new Set(['element-name', 'operator', 'value', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementRangeQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-range-query', checkedArgs); + + } +/** + * Creates a reference to an element value lexicon, for use as a parameter to cts:value-tuples, temporal:axis-create, or any other function that takes an index reference. Since lexicons are implemented with range indexes, this function will throw an exception if the specified range index does not exist. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementReference|cts.elementReference} + * @method planBuilder.cts#elementReference + * @since 2.1.1 + * @param { XsQName } [element] - An element QName. + * @param { XsString } [options] - Options. The default is (). Options include: "type=type" Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, anyURI, point, or long-lat-point) "collation=URI" Use the lexicon with the collation specified by URI. "nullable" Allow null values in tuples reported from cts:value-tuples when using this lexicon. "unchecked" Read the scalar type, collation and coordinate-system info only from the input. Do not check the definition against the context database. "coordinate-system=name" Create a reference to an index or lexicon based on the specified coordinate system. Allowed values: "wgs84", "wgs84/double", "raw", "raw/double". Only applicable if the index/lexicon value type is point or long-lat-point. "precision=value" Create a reference to an index or lexicon configured with the specified geospatial precision. Allowed values: float and double. Only applicable if the index/lexicon value type is point or long-lat-point. This value takes precedence over the precision implicit in the coordinate system name. + * @returns { CtsReference } + */ +elementReference(...args) { + const namer = bldrbase.getNamer(args, 'element'); + const paramdefs = [['element', [types.XsQName], true, false], ['options', [types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementReference', 1, new Set(['element', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementReference', 1, false, paramdefs, args); + return new types.CtsReference('cts', 'element-reference', checkedArgs); + + } +/** + * Returns a query matching elements by name with text content equal a given phrase. cts:element-value-query only matches against simple elements (that is, elements that contain only text and have no element children). Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementValueQuery|cts.elementValueQuery} + * @method planBuilder.cts#elementValueQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsString } [text] - One or more element values to match. When multiple strings are specified, the query matches if any string matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "case-sensitive" A case-sensitive query. "case-insensitive" A case-insensitive query. "diacritic-sensitive" A diacritic-sensitive query. "diacritic-insensitive" A diacritic-insensitive query. "punctuation-sensitive" A punctuation-sensitive query. "punctuation-insensitive" A punctuation-insensitive query. "whitespace-sensitive" A whitespace-sensitive query. "whitespace-insensitive" A whitespace-insensitive query. "stemmed" A stemmed query. "unstemmed" An unstemmed query. "wildcarded" A wildcarded query. "unwildcarded" An unwildcarded query. "exact" An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded". "lang=iso639code" Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "synonym" Specifies that all of the terms in the $text parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). "lexicon-expansion-limit=number" Specifies the limit for lexicon expansion. This puts a restriction on the number of lexicon expansions that can be performed. If the limit is exceeded, the server may raise an error depending on whether the "limit-check" option is set. The default value for this option will be 4096. "limit-check" Specifies that an error will be raised if the lexicon expansion exceeds the specified limit. "no-limit-check" Specifies that error will not be raised if the lexicon expansion exceeds the specified limit. The server will try to resolve the wildcard. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +elementValueQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['text', [types.XsString], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementValueQuery', 1, new Set(['element-name', 'text', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementValueQuery', 1, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-value-query', checkedArgs); + + } +/** + * Returns a query matching elements by name with text content containing a given phrase. Searches only through immediate text node children of the specified element as well as any text node children of child elements defined in the Admin Interface as element-word-query-throughs or phrase-throughs; does not search through any other children of the specified element. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.elementWordQuery|cts.elementWordQuery} + * @method planBuilder.cts#elementWordQuery + * @since 2.1.1 + * @param { XsQName } [elementName] - One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches. + * @param { XsString } [text] - Some words or phrases to match. When multiple strings are specified, the query matches if any string matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "case-sensitive" A case-sensitive query. "case-insensitive" A case-insensitive query. "diacritic-sensitive" A diacritic-sensitive query. "diacritic-insensitive" A diacritic-insensitive query. "punctuation-sensitive" A punctuation-sensitive query. "punctuation-insensitive" A punctuation-insensitive query. "whitespace-sensitive" A whitespace-sensitive query. "whitespace-insensitive" A whitespace-insensitive query. "stemmed" A stemmed query. "unstemmed" An unstemmed query. "wildcarded" A wildcarded query. "unwildcarded" An unwildcarded query. "exact" An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded". "lang=iso639code" Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration. "distance-weight=number" A weight applied based on the minimum distance between matches of this query. Higher weights add to the importance of proximity (as opposed to term matches) when the relevance order is calculated. The default value is 0.0 (no impact of proximity). The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. This parameter has no effect if the word positions index is not enabled. This parameter has no effect on searches that use score-simple, score-random, or score-zero (because those scoring algorithms do not consider term frequency, proximity is irrelevant). "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "synonym" Specifies that all of the terms in the $text parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). "lexicon-expand=value" The value is one of full, prefix-postfix, off, or heuristic (the default is heuristic). An option with a value of lexicon-expand=full specifies that wildcards are resolved by expanding the pattern to words in a lexicon (if there is one available), and turning into a series of cts:word-queries, even if this takes a long time to evaluate. An option with a value of lexicon-expand=prefix-postfix specifies that wildcards are resolved by expanding the pattern to the pre- and postfixes of the words in the word lexicon (if there is one), and turning the query into a series of character queries, even if it takes a long time to evaluate. An option with a value of lexicon-expand=off specifies that wildcards are only resolved by looking up character patterns in the search pattern index, not in the lexicon. An option with a value of lexicon-expand=heuristic, which is the default, specifies that wildcards are resolved by using a series of internal rules, such as estimating the number of lexicon entries that need to be scanned, seeing if the estimate crosses certain thresholds, and (if appropriate), using another way besides lexicon expansion to resolve the query. * "lexicon-expansion-limit=number" Specifies the limit for lexicon expansion. This puts a restriction on the number of lexicon expansions that can be performed. If the limit is exceeded, the server may raise an error depending on whether the "limit-check" option is set. The default value for this option will be 4096. "limit-check" Specifies that an error will be raised if the lexicon expansion exceeds the specified limit. "no-limit-check" Specifies that error will not be raised if the lexicon expansion exceeds the specified limit. The server will try to resolve the wildcard. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +elementWordQuery(...args) { + const namer = bldrbase.getNamer(args, 'element-name'); + const paramdefs = [['element-name', [types.XsQName], false, true], ['text', [types.XsString], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.elementWordQuery', 2, new Set(['element-name', 'text', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.elementWordQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'element-word-query', checkedArgs); + + } +/** + * Returns a query that matches no fragments. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.falseQuery|cts.falseQuery} + * @method planBuilder.cts#falseQuery + * @since 2.1.1 + + * @returns { CtsQuery } + */ +falseQuery(...args) { + bldrbase.checkMaxArity('cts.falseQuery', args.length, 0); + return new types.CtsQuery('cts', 'false-query', args); + } +/** + * Returns a cts:query matching fields by name with a range-index entry equal to a given value. Searches with the cts:field-range-query constructor require a field range index on the specified field name(s); if there is no range index configured, then an exception is thrown. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.fieldRangeQuery|cts.fieldRangeQuery} + * @method planBuilder.cts#fieldRangeQuery + * @since 2.1.1 + * @param { XsString } [fieldName] - One or more field names to match. When multiple field names are specified, the query matches if any field name matches. + * @param { XsString } [operator] - A comparison operator. Operators include: "<" Match range index values less than $value. "<=" Match range index values less than or equal to $value. ">" Match range index values greater than $value. ">=" Match range index values greater than or equal to $value. "=" Match range index values equal to $value. "!=" Match range index values not equal to $value. + * @param { XsAnyAtomicType } [value] - One or more field values to match. When multiple values are specified, the query matches if any value matches. The value must be a type for which there is a range index defined. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "collation=URI" Use the range index with the collation specified by URI. If not specified, then the default collation from the query is used. If a range index with the specified collation does not exist, an error is thrown. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $value parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +fieldRangeQuery(...args) { + const namer = bldrbase.getNamer(args, 'field-name'); + const paramdefs = [['field-name', [types.XsString], false, true], ['operator', [types.XsString], true, false], ['value', [types.XsAnyAtomicType], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.fieldRangeQuery', 3, new Set(['field-name', 'operator', 'value', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.fieldRangeQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'field-range-query', checkedArgs); + + } +/** + * Creates a reference to a field value lexicon, for use as a parameter to cts:value-tuples. Since lexicons are implemented with range indexes, this function will throw an exception if the specified range index does not exist. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.fieldReference|cts.fieldReference} + * @method planBuilder.cts#fieldReference + * @since 2.1.1 + * @param { XsString } [field] - A field name. + * @param { XsString } [options] - Options. The default is (). Options include: "type=type" Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, anyURI, point, or long-lat-point) "collation=URI" Use the lexicon with the collation specified by URI. "nullable" Allow null values in tuples reported from cts:value-tuples when using this lexicon. "unchecked" Read the scalar type, collation and coordinate-system info only from the input. Do not check the definition against the context database. "coordinate-system=name" Create a reference to an index or lexicon based on the specified coordinate system. Allowed values: "wgs84", "wgs84/double", "raw", "raw/double". Only applicable if the index/lexicon value type is point or long-lat-point. "precision=value" Create a reference to an index or lexicon configured with the specified geospatial precision. Allowed values: float and double. Only applicable if the index/lexicon value type is point or long-lat-point. This value takes precedence over the precision implicit in the coordinate system name. + * @returns { CtsReference } + */ +fieldReference(...args) { + const namer = bldrbase.getNamer(args, 'field'); + const paramdefs = [['field', [types.XsString], true, false], ['options', [types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.fieldReference', 1, new Set(['field', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.fieldReference', 1, false, paramdefs, args); + return new types.CtsReference('cts', 'field-reference', checkedArgs); + + } +/** + * Returns a query matching text content containing a given value in the specified field. If the specified field does not exist, cts:field-value-query throws an exception. If the specified field does not have the index setting field value searches enabled, either for the database or for the specified field, then a cts:search with a cts:field-value-query throws an exception. A field is a named object that specified elements to include and exclude from a search, and can include score weights for any included elements. You create fields at the database level using the Admin Interface. For details on fields, see the chapter on "Fields Database Settings" in the Administrator's Guide. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.fieldValueQuery|cts.fieldValueQuery} + * @method planBuilder.cts#fieldValueQuery + * @since 2.1.1 + * @param { XsString } [fieldName] - One or more field names to search over. If multiple field names are supplied, the match can be in any of the specified fields (or-query semantics). + * @param { XsAnyAtomicType } [text] - The values to match. If multiple values are specified, the query matches if any of the values match (or-query semantics). For XML documents, the values should be strings. For JSON, the values can be strings, numbers or booleans. To match null, pass in the empty sequence. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "case-sensitive" A case-sensitive query. "case-insensitive" A case-insensitive query. "diacritic-sensitive" A diacritic-sensitive query. "diacritic-insensitive" A diacritic-insensitive query. "punctuation-sensitive" A punctuation-sensitive query. "punctuation-insensitive" A punctuation-insensitive query. "whitespace-sensitive" A whitespace-sensitive query. "whitespace-insensitive" A whitespace-insensitive query. "stemmed" A stemmed query. "unstemmed" An unstemmed query. "wildcarded" A wildcarded query. "unwildcarded" An unwildcarded query. "exact" An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded". "lang=iso639code" Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration. "distance-weight=number" A weight applied based on the minimum distance between matches of this query. Higher weights add to the importance of proximity (as opposed to term matches) when the relevance order is calculated. The default value is 0.0 (no impact of proximity). The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. This parameter has no effect if the word positions index is not enabled. This parameter has no effect on searches that use score-simple or score-random (because those scoring algorithms do not consider term frequency, proximity is irrelevant). "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "synonym" Specifies that all of the terms in the $text parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). "lexicon-expansion-limit=number" Specifies the limit for lexicon expansion. This puts a restriction on the number of lexicon expansions that can be performed. If the limit is exceeded, the server may raise an error depending on whether the "limit-check" option is set. The default value for this option will be 4096. "limit-check" Specifies that an error will be raised if the lexicon expansion exceeds the specified limit. "no-limit-check" Specifies that error will not be raised if the lexicon expansion exceeds the specified limit. The server will try to resolve the wildcard. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +fieldValueQuery(...args) { + const namer = bldrbase.getNamer(args, 'field-name'); + const paramdefs = [['field-name', [types.XsString], false, true], ['text', [types.XsAnyAtomicType], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.fieldValueQuery', 2, new Set(['field-name', 'text', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.fieldValueQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'field-value-query', checkedArgs); + + } +/** + * Returns a query matching fields whose content contains the given phrase. If the specified field does not exist, this function throws an exception. A field is a named object that specified elements to include and exclude from a search, and can include score weights for any included elements. You create fields at the database level using the Admin Interface. For details on fields, see the chapter on "Fields Database Settings" in the Administrator's Guide. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.fieldWordQuery|cts.fieldWordQuery} + * @method planBuilder.cts#fieldWordQuery + * @since 2.1.1 + * @param { XsString } [fieldName] - One or more field names to search over. If multiple field names are supplied, the match can be in any of the specified fields (or-query semantics). + * @param { XsString } [text] - The word or phrase to match. If multiple strings are specified, the query matches if any of the words or phrases match (or-query semantics). + * @param { XsString } [options] - Options to this query. The default is (). Options include: "case-sensitive" A case-sensitive query. "case-insensitive" A case-insensitive query. "diacritic-sensitive" A diacritic-sensitive query. "diacritic-insensitive" A diacritic-insensitive query. "punctuation-sensitive" A punctuation-sensitive query. "punctuation-insensitive" A punctuation-insensitive query. "whitespace-sensitive" A whitespace-sensitive query. "whitespace-insensitive" A whitespace-insensitive query. "stemmed" A stemmed query. "unstemmed" An unstemmed query. "wildcarded" A wildcarded query. "unwildcarded" An unwildcarded query. "exact" An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded". "lang=iso639code" Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration. "distance-weight=number" A weight applied based on the minimum distance between matches of this query. Higher weights add to the importance of proximity (as opposed to term matches) when the relevance order is calculated. The default value is 0.0 (no impact of proximity). The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. This parameter has no effect if the word positions index is not enabled. This parameter has no effect on searches that use score-simple, score-random, or score-zero (because those scoring algorithms do not consider term frequency, proximity is irrelevant). "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "synonym" Specifies that all of the terms in the $text parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). "lexicon-expand=value" The value is one of full, prefix-postfix, off, or heuristic (the default is heuristic). An option with a value of lexicon-expand=full specifies that wildcards are resolved by expanding the pattern to words in a lexicon (if there is one available), and turning into a series of cts:word-queries, even if this takes a long time to evaluate. An option with a value of lexicon-expand=prefix-postfix specifies that wildcards are resolved by expanding the pattern to the pre- and postfixes of the words in the word lexicon (if there is one), and turning the query into a series of character queries, even if it takes a long time to evaluate. An option with a value of lexicon-expand=off specifies that wildcards are only resolved by looking up character patterns in the search pattern index, not in the lexicon. An option with a value of lexicon-expand=heuristic, which is the default, specifies that wildcards are resolved by using a series of internal rules, such as estimating the number of lexicon entries that need to be scanned, seeing if the estimate crosses certain thresholds, and (if appropriate), using another way besides lexicon expansion to resolve the query. * "lexicon-expansion-limit=number" Specifies the limit for lexicon expansion. This puts a restriction on the number of lexicon expansions that can be performed. If the limit is exceeded, the server may raise an error depending on whether the "limit-check" option is set. The default value for this option will be 4096. "limit-check" Specifies that an error will be raised if the lexicon expansion exceeds the specified limit. "no-limit-check" Specifies that error will not be raised if the lexicon expansion exceeds the specified limit. The server will try to resolve the wildcard. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +fieldWordQuery(...args) { + const namer = bldrbase.getNamer(args, 'field-name'); + const paramdefs = [['field-name', [types.XsString], false, true], ['text', [types.XsString], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.fieldWordQuery', 2, new Set(['field-name', 'text', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.fieldWordQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'field-word-query', checkedArgs); + + } +/** + * Returns a cts:query matching json properties by name which has specific children representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.jsonPropertyChildGeospatialQuery|cts.jsonPropertyChildGeospatialQuery} + * @method planBuilder.cts#jsonPropertyChildGeospatialQuery + * @since 2.1.1 + * @param { XsString } [parentPropertyName] - One or more parent property names to match. When multiple names are specified, the query matches if any name matches. + * @param { XsString } [childPropertyNames] - One or more child property names to match. When multiple names are specified, the query matches if any name matches; however, only the first matching latitude child in any point instance will be checked. The property must specify both latitude and longitude coordinates. + * @param { CtsRegion } [regions] - One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "coordinate-system=string" Use the given coordinate system. Valid values are: wgs84The WGS84 coordinate system. wgs84/doubleThe WGS84 coordinate system at double precision. etrs89The ETRS89 coordinate system. etrs89/doubleThe ETRS89 coordinate system at double precision. rawThe raw (unmapped) coordinate system. raw/doubleThe raw coordinate system at double precision. "precision=string" Use the coordinate system at the given precision. Allowed values: float (default) and double. "units=value" Measure distance and the radii of circles in the specified units. Allowed values: miles (default), km, feet, meters. "boundaries-included" Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes', circles', and polygons' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching. "boundaries-endpoints-excluded" Points on linestrings' boundary (the endpoints) are not counted as matching. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "type=long-lat-point" Specifies the format for the point in the data as longitude first, latitude second. "type=point" Specifies the format for the point in the data as latitude first, longitude second. This is the default format. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $regions parameter are considered synonyms for scoring purposes. The result is that occurances of more than one of the synonyms are scored as if there are more occurance of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +jsonPropertyChildGeospatialQuery(...args) { + const namer = bldrbase.getNamer(args, 'parent-property-name'); + const paramdefs = [['parent-property-name', [types.XsString], false, true], ['child-property-names', [types.XsString], false, true], ['regions', [types.CtsRegion], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.jsonPropertyChildGeospatialQuery', 3, new Set(['parent-property-name', 'child-property-names', 'regions', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.jsonPropertyChildGeospatialQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'json-property-child-geospatial-query', checkedArgs); + + } +/** + * Returns a cts:query matching json properties by name whose content represents a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.jsonPropertyGeospatialQuery|cts.jsonPropertyGeospatialQuery} + * @method planBuilder.cts#jsonPropertyGeospatialQuery + * @since 2.1.1 + * @param { XsString } [propertyName] - One or more json property names to match. When multiple names are specified, the query matches if any name matches. + * @param { CtsRegion } [regions] - One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "coordinate-system=string" Use the given coordinate system. Valid values are: wgs84The WGS84 coordinate system. wgs84/doubleThe WGS84 coordinate system at double precision. etrs89The ETRS89 coordinate system. etrs89/doubleThe ETRS89 coordinate system at double precision. rawThe raw (unmapped) coordinate system. raw/doubleThe raw coordinate system at double precision. "precision=string" Use the coordinate system at the given precision. Allowed values: float (default) and double. "units=value" Measure distance and the radii of circles in the specified units. Allowed values: miles (default), km, feet, meters. "boundaries-included" Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes', circles', and polygons' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching. "boundaries-endpoints-excluded" Points on linestrings' boundary (the endpoints) are not counted as matching. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "type=long-lat-point" Specifies the format for the point in the data as longitude first, latitude second. "type=point" Specifies the format for the point in the data as latitude first, longitude second. This is the default format. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $regions parameter are considered synonyms for scoring purposes. The result is that occurances of more than one of the synonyms are scored as if there are more occurance of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +jsonPropertyGeospatialQuery(...args) { + const namer = bldrbase.getNamer(args, 'property-name'); + const paramdefs = [['property-name', [types.XsString], false, true], ['regions', [types.CtsRegion], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.jsonPropertyGeospatialQuery', 2, new Set(['property-name', 'regions', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.jsonPropertyGeospatialQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'json-property-geospatial-query', checkedArgs); + + } +/** + * Returns a cts:query matching json properties by name which has specific property children representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.jsonPropertyPairGeospatialQuery|cts.jsonPropertyPairGeospatialQuery} + * @method planBuilder.cts#jsonPropertyPairGeospatialQuery + * @since 2.1.1 + * @param { XsString } [propertyName] - One or more parent property names to match. When multiple names are specified, the query matches if any name matches. + * @param { XsString } [latitudePropertyNames] - One or more latitude property names to match. When multiple names are specified, the query matches if any name matches; however, only the first matching latitude child in any point instance will be checked. + * @param { XsString } [longitudePropertyNames] - One or more longitude property names to match. When multiple names are specified, the query matches if any name matches; however, only the first matching longitude child in any point instance will be checked. + * @param { CtsRegion } [regions] - One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "coordinate-system=string" Use the given coordinate system. Valid values are: wgs84The WGS84 coordinate system. wgs84/doubleThe WGS84 coordinate system at double precision. etrs89The ETRS89 coordinate system. etrs89/doubleThe ETRS89 coordinate system at double precision. rawThe raw (unmapped) coordinate system. raw/doubleThe raw coordinate system at double precision. "precision=value" Use the coordinate system at the given precision. Allowed values: float and double. "units=value" Measure distance and the radii of circles in the specified units. Allowed values: miles (default), km, feet, meters. "boundaries-included" Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes', circles', and polygons' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching. "boundaries-endpoints-excluded" Points on linestrings' boundary (the endpoints) are not counted as matching. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $regions parameter are considered synonyms for scoring purposes. The result is that occurances of more than one of the synonyms are scored as if there are more occurance of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +jsonPropertyPairGeospatialQuery(...args) { + const namer = bldrbase.getNamer(args, 'property-name'); + const paramdefs = [['property-name', [types.XsString], false, true], ['latitude-property-names', [types.XsString], false, true], ['longitude-property-names', [types.XsString], false, true], ['regions', [types.CtsRegion], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.jsonPropertyPairGeospatialQuery', 4, new Set(['property-name', 'latitude-property-names', 'longitude-property-names', 'regions', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.jsonPropertyPairGeospatialQuery', 4, false, paramdefs, args); + return new types.CtsQuery('cts', 'json-property-pair-geospatial-query', checkedArgs); + + } +/** + * Returns a cts:query matching JSON properties by name with a range-index entry equal to a given value. Searches with the cts:json-property-range-query constructor require a property range index on the specified names; if there is no range index configured, then an exception is thrown. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.jsonPropertyRangeQuery|cts.jsonPropertyRangeQuery} + * @method planBuilder.cts#jsonPropertyRangeQuery + * @since 2.1.1 + * @param { XsString } [propertyName] - One or more property name to match. When multiple names are specified, the query matches if any name matches. + * @param { XsString } [operator] - A comparison operator. Operators include: "<" Match range index values less than $value. "<=" Match range index values less than or equal to $value. ">" Match range index values greater than $value. ">=" Match range index values greater than or equal to $value. "=" Match range index values equal to $value. "!=" Match range index values not equal to $value. + * @param { XsAnyAtomicType } [value] - One or more property values to match. When multiple values are specified, the query matches if any value matches. The value must be a type for which there is a range index defined. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "collation=URI" Use the range index with the collation specified by URI. If not specified, then the default collation from the query is used. If a range index with the specified collation does not exist, an error is thrown. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $value parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +jsonPropertyRangeQuery(...args) { + const namer = bldrbase.getNamer(args, 'property-name'); + const paramdefs = [['property-name', [types.XsString], false, true], ['operator', [types.XsString], true, false], ['value', [types.XsAnyAtomicType], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.jsonPropertyRangeQuery', 3, new Set(['property-name', 'operator', 'value', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.jsonPropertyRangeQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'json-property-range-query', checkedArgs); + + } +/** + * Creates a reference to a JSON property value lexicon, for use as a parameter to cts:value-tuples. Since lexicons are implemented with range indexes, this function will throw an exception if the specified range index does not exist. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.jsonPropertyReference|cts.jsonPropertyReference} + * @method planBuilder.cts#jsonPropertyReference + * @since 2.1.1 + * @param { XsString } [property] - A property name. + * @param { XsString } [options] - Options. The default is (). Options include: "type=type" Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, anyURI, point, or long-lat-point) "collation=URI" Use the lexicon with the collation specified by URI. "nullable" Allow null values in tuples reported from cts:value-tuples when using this lexicon. "unchecked" Read the scalar type, collation and coordinate-system info only from the input. Do not check the definition against the context database. "coordinate-system=name" Create a reference to an index or lexicon based on the specified coordinate system. Allowed values: "wgs84", "wgs84/double", "raw", "raw/double". Only applicable if the index/lexicon value type is point or long-lat-point. "precision=value" Create a reference to an index or lexicon configured with the specified geospatial precision. Allowed values: float and double. Only applicable if the index/lexicon value type is point or long-lat-point. This value takes precedence over the precision implicit in the coordinate system name. + * @returns { CtsReference } + */ +jsonPropertyReference(...args) { + const namer = bldrbase.getNamer(args, 'property'); + const paramdefs = [['property', [types.XsString], true, false], ['options', [types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.jsonPropertyReference', 1, new Set(['property', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.jsonPropertyReference', 1, false, paramdefs, args); + return new types.CtsReference('cts', 'json-property-reference', checkedArgs); + + } +/** + * Returns a cts:query matching JSON properties by name with the content constrained by the given cts:query in the second parameter. Searches for matches in the specified property and all of its descendants. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.jsonPropertyScopeQuery|cts.jsonPropertyScopeQuery} + * @method planBuilder.cts#jsonPropertyScopeQuery + * @since 2.1.1 + * @param { XsString } [propertyName] - One or more property names to match. When multiple names are specified, the query matches if any name matches. + * @param { CtsQuery } [query] - A query for the property to match. If a string is entered, the string is treated as a cts:word-query of the specified string. + * @returns { CtsQuery } + */ +jsonPropertyScopeQuery(...args) { + const namer = bldrbase.getNamer(args, 'property-name'); + const paramdefs = [['property-name', [types.XsString], false, true], ['query', [types.CtsQuery], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.jsonPropertyScopeQuery', 2, new Set(['property-name', 'query']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.jsonPropertyScopeQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'json-property-scope-query', checkedArgs); + + } +/** + * Returns a query matching JSON properties by name with value equal the given value. For arrays, the query matches if the value of any elements in the array matches the given value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.jsonPropertyValueQuery|cts.jsonPropertyValueQuery} + * @method planBuilder.cts#jsonPropertyValueQuery + * @since 2.1.1 + * @param { XsString } [propertyName] - One or more property names to match. When multiple names are specified, the query matches if any name matches. + * @param { XsAnyAtomicType } [value] - One or more property values to match. When multiple values are specified, the query matches if any value matches. The values can be strings, numbers or booleans. If the value is the empty sequence, the query matches null. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "case-sensitive" A case-sensitive query. "case-insensitive" A case-insensitive query. "diacritic-sensitive" A diacritic-sensitive query. "diacritic-insensitive" A diacritic-insensitive query. "punctuation-sensitive" A punctuation-sensitive query. "punctuation-insensitive" A punctuation-insensitive query. "whitespace-sensitive" A whitespace-sensitive query. "whitespace-insensitive" A whitespace-insensitive query. "stemmed" A stemmed query. "unstemmed" An unstemmed query. "wildcarded" A wildcarded query. "unwildcarded" An unwildcarded query. "exact" An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded". "lang=iso639code" Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "synonym" Specifies that all of the terms in the $text parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). "lexicon-expansion-limit=number" Specifies the limit for lexicon expansion. This puts a restriction on the number of lexicon expansions that can be performed. If the limit is exceeded, the server may raise an error depending on whether the "limit-check" option is set. The default value for this option will be 4096. "limit-check" Specifies that an error will be raised if the lexicon expansion exceeds the specified limit. "no-limit-check" Specifies that error will not be raised if the lexicon expansion exceeds the specified limit. The server will try to resolve the wildcard. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +jsonPropertyValueQuery(...args) { + const namer = bldrbase.getNamer(args, 'property-name'); + const paramdefs = [['property-name', [types.XsString], false, true], ['value', [types.XsAnyAtomicType], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.jsonPropertyValueQuery', 2, new Set(['property-name', 'value', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.jsonPropertyValueQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'json-property-value-query', checkedArgs); + + } +/** + * Returns a query matching JSON properties by name with text content containing a given phrase. Searches only through immediate text node children of the specified property. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.jsonPropertyWordQuery|cts.jsonPropertyWordQuery} + * @method planBuilder.cts#jsonPropertyWordQuery + * @since 2.1.1 + * @param { XsString } [propertyName] - One or more JSON property names to match. When multiple names are specified, the query matches if any name matches. + * @param { XsString } [text] - Some words or phrases to match. When multiple strings are specified, the query matches if any string matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "case-sensitive" A case-sensitive query. "case-insensitive" A case-insensitive query. "diacritic-sensitive" A diacritic-sensitive query. "diacritic-insensitive" A diacritic-insensitive query. "punctuation-sensitive" A punctuation-sensitive query. "punctuation-insensitive" A punctuation-insensitive query. "whitespace-sensitive" A whitespace-sensitive query. "whitespace-insensitive" A whitespace-insensitive query. "stemmed" A stemmed query. "unstemmed" An unstemmed query. "wildcarded" A wildcarded query. "unwildcarded" An unwildcarded query. "exact" An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded". "lang=iso639code" Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration. "distance-weight=number" A weight applied based on the minimum distance between matches of this query. Higher weights add to the importance of proximity (as opposed to term matches) when the relevance order is calculated. The default value is 0.0 (no impact of proximity). The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. This parameter has no effect if the word positions index is not enabled. This parameter has no effect on searches that use score-simple, score-random, or score-zero (because those scoring algorithms do not consider term frequency, proximity is irrelevant). "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "synonym" Specifies that all of the terms in the $text parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). "lexicon-expand=value" The value is one of full, prefix-postfix, off, or heuristic (the default is heuristic). An option with a value of lexicon-expand=full specifies that wildcards are resolved by expanding the pattern to words in a lexicon (if there is one available), and turning into a series of cts:word-queries, even if this takes a long time to evaluate. An option with a value of lexicon-expand=prefix-postfix specifies that wildcards are resolved by expanding the pattern to the pre- and postfixes of the words in the word lexicon (if there is one), and turning the query into a series of character queries, even if it takes a long time to evaluate. An option with a value of lexicon-expand=off specifies that wildcards are only resolved by looking up character patterns in the search pattern index, not in the lexicon. An option with a value of lexicon-expand=heuristic, which is the default, specifies that wildcards are resolved by using a series of internal rules, such as estimating the number of lexicon entries that need to be scanned, seeing if the estimate crosses certain thresholds, and (if appropriate), using another way besides lexicon expansion to resolve the query. * "lexicon-expansion-limit=number" Specifies the limit for lexicon expansion. This puts a restriction on the number of lexicon expansions that can be performed. If the limit is exceeded, the server may raise an error depending on whether the "limit-check" option is set. The default value for this option will be 4096. "limit-check" Specifies that an error will be raised if the lexicon expansion exceeds the specified limit. "no-limit-check" Specifies that error will not be raised if the lexicon expansion exceeds the specified limit. The server will try to resolve the wildcard. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +jsonPropertyWordQuery(...args) { + const namer = bldrbase.getNamer(args, 'property-name'); + const paramdefs = [['property-name', [types.XsString], false, true], ['text', [types.XsString], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.jsonPropertyWordQuery', 2, new Set(['property-name', 'text', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.jsonPropertyWordQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'json-property-word-query', checkedArgs); + + } +/** + * Returns a query that matches all documents where query matches document-locks. When searching documents or document-properties, cts:locks-fragment-query provides a convenient way to additionally constrain the search against document-locks fragments. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.locksFragmentQuery|cts.locksFragmentQuery} + * @method planBuilder.cts#locksFragmentQuery + * @since 2.1.1 + * @param { CtsQuery } [query] - A query to be matched against the locks fragment. + * @returns { CtsQuery } + */ +locksFragmentQuery(...args) { + const paramdef = ['query', [types.CtsQuery], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('cts.locksFragmentQuery', 1, paramdef, args); + return new types.CtsQuery('cts', 'locks-fragment-query', checkedArgs); + } +/** + * Returns only documents before LSQT or a timestamp before LSQT for stable query results. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.lsqtQuery|cts.lsqtQuery} + * @method planBuilder.cts#lsqtQuery + * @since 2.1.1 + * @param { XsString } [temporalCollection] - The name of the temporal collection. + * @param { XsDateTime } [timestamp] - Return only temporal documents with a system start time less than or equal to this value. Default is temporal:get-lsqt($temporal-collection). Timestamps larger than LSQT are rejected. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "cached-incremental" Break down the query into sub-queries and then cache each one of them for better performance. This is enabled, by default. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +lsqtQuery(...args) { + const namer = bldrbase.getNamer(args, 'temporal-collection'); + const paramdefs = [['temporal-collection', [types.XsString], true, false], ['timestamp', [types.XsDateTime], false, false], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.lsqtQuery', 1, new Set(['temporal-collection', 'timestamp', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.lsqtQuery', 1, false, paramdefs, args); + return new types.CtsQuery('cts', 'lsqt-query', checkedArgs); + + } +/** + * Returns a query matching all of the specified queries, where the matches occur within the specified distance from each other. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.nearQuery|cts.nearQuery} + * @method planBuilder.cts#nearQuery + * @since 2.1.1 + * @param { CtsQuery } [queries] - A sequence of queries to match. + * @param { XsDouble } [distance] - A distance, in number of words, between any two matching queries. The results match if two queries match and the distance between the two matches is equal to or less than the specified distance. A distance of 0 matches when the text is the exact same text or when there is overlapping text (see the third example below). A negative distance is treated as 0. The default value is 10. + * @param { XsString } [options] - Options to this query. The default value is (). Options include: "ordered" Any near-query matches must occur in the order of the specified sub-queries. "unordered" Any near-query matches will satisfy the query, regardless of the order they were specified. "minimum-distance" The minimum distance between two matching queries. The results match if the two queries match and the minimum distance between the two matches is greater than or equal to the specified minimum distance. The default value is zero. A negative distance is treated as 0. + * @param { XsDouble } [distanceWeight] - A weight attributed to the distance for this query. Higher weights add to the importance of distance (as opposed to term matches) when the relevance order is calculated. The default value is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. This parameter has no effect if the word positions index is not enabled. + * @returns { CtsQuery } + */ +nearQuery(...args) { + const namer = bldrbase.getNamer(args, 'queries'); + const paramdefs = [['queries', [types.CtsQuery], false, true], ['distance', [types.XsDouble], false, false], ['options', [types.XsString], false, true], ['distance-weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.nearQuery', 1, new Set(['queries', 'distance', 'options', 'distance-weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.nearQuery', 1, false, paramdefs, args); + return new types.CtsQuery('cts', 'near-query', checkedArgs); + + } +/** + * Returns a query matching the first subquery, where those matches do not occur within 0 distance of the other query. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.notInQuery|cts.notInQuery} + * @method planBuilder.cts#notInQuery + * @since 2.1.1 + * @param { CtsQuery } [positiveQuery] - A positive query, specifying the search results filtered in. + * @param { CtsQuery } [negativeQuery] - A negative query, specifying the search results to filter out. + * @returns { CtsQuery } + */ +notInQuery(...args) { + const namer = bldrbase.getNamer(args, 'positive-query'); + const paramdefs = [['positive-query', [types.CtsQuery], true, false], ['negative-query', [types.CtsQuery], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.notInQuery', 2, new Set(['positive-query', 'negative-query']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.notInQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'not-in-query', checkedArgs); + + } +/** + * Returns a query specifying the matches not specified by its sub-query. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.notQuery|cts.notQuery} + * @method planBuilder.cts#notQuery + * @since 2.1.1 + * @param { CtsQuery } [query] - A negative query, specifying the search results to filter out. + * @returns { CtsQuery } + */ +notQuery(...args) { + const paramdef = ['query', [types.CtsQuery], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('cts.notQuery', 1, paramdef, args); + return new types.CtsQuery('cts', 'not-query', checkedArgs); + } +/** + * Returns a query specifying the union of the matches specified by the sub-queries. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.orQuery|cts.orQuery} + * @method planBuilder.cts#orQuery + * @since 2.1.1 + * @param { CtsQuery } [queries] - A sequence of sub-queries. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "synonym" Specifies that all of the terms in the $queries parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). + * @returns { CtsQuery } + */ +orQuery(...args) { + const namer = bldrbase.getNamer(args, 'queries'); + const paramdefs = [['queries', [types.CtsQuery], false, true], ['options', [types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.orQuery', 1, new Set(['queries', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.orQuery', 1, false, paramdefs, args); + return new types.CtsQuery('cts', 'or-query', checkedArgs); + + } +/** + * Returns a cts:query matching path expressions whose content represents a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.pathGeospatialQuery|cts.pathGeospatialQuery} + * @method planBuilder.cts#pathGeospatialQuery + * @since 2.1.1 + * @param { XsString } [pathExpression] - One or more path expressions to match. When multiple path expressions are specified, the query matches if any path expression matches. + * @param { CtsRegion } [regions] - One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "coordinate-system=string" Use the given coordinate system. Valid values are: wgs84The WGS84 coordinate system. wgs84/doubleThe WGS84 coordinate system at double precision. etrs89The ETRS89 coordinate system. etrs89/doubleThe ETRS89 coordinate system at double precision. rawThe raw (unmapped) coordinate system. raw/doubleThe raw coordinate system at double precision. "precision=value" Use the coordinate system at the given precision. Allowed values: float and double. "units=value" Measure distance and the radii of circles in the specified units. Allowed values: miles (default), km, feet, meters. "boundaries-included" Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes', circles', and polygons' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching. "boundaries-endpoints-excluded" Points on linestrings' boundary (the endpoints) are not counted as matching. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "type=long-lat-point" Specifies the format for the point in the data as longitude first, latitude second. "type=point" Specifies the format for the point in the data as latitude first, longitude second. This is the default format. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $regions parameter are considered synonyms for scoring purposes. The result is that occurances of more than one of the synonyms are scored as if there are more occurance of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +pathGeospatialQuery(...args) { + const namer = bldrbase.getNamer(args, 'path-expression'); + const paramdefs = [['path-expression', [types.XsString], false, true], ['regions', [types.CtsRegion], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.pathGeospatialQuery', 2, new Set(['path-expression', 'regions', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.pathGeospatialQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'path-geospatial-query', checkedArgs); + + } +/** + * Returns a cts:query matching documents where the content addressed by an XPath expression satisfies the specified relationship (=, <, >, etc.) with respect to the input criteria values. A path range index must exist for each path when you perform a search. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.pathRangeQuery|cts.pathRangeQuery} + * @method planBuilder.cts#pathRangeQuery + * @since 2.1.1 + * @param { XsString } [pathExpression] - One or more XPath expressions that identify the content to match. When multiple paths are specified, the query matches if any path matches. + * @param { XsString } [operator] - A comparison operator. Operators include: "<" Match range index values less than $value. "<=" Match range index values less than or equal to $value. ">" Match range index values greater than $value. ">=" Match range index values greater than or equal to $value. "=" Match range index values equal to $value. "!=" Match range index values not equal to $value. + * @param { XsAnyAtomicType } [value] - One or more values to match. These values are compared to the value(s) addressed by the path-expression parameter. When multiple When multiple values are specified, the query matches if any value matches. The value must be a type for which there is a range index defined. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "collation=URI" Use the range index with the collation specified by URI. If not specified, then the default collation from the query is used. If a range index with the specified collation does not exist, an error is thrown. "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. "synonym" Specifies that all of the terms in the $value parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +pathRangeQuery(...args) { + const namer = bldrbase.getNamer(args, 'path-expression'); + const paramdefs = [['path-expression', [types.XsString], false, true], ['operator', [types.XsString], true, false], ['value', [types.XsAnyAtomicType], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.pathRangeQuery', 3, new Set(['path-expression', 'operator', 'value', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.pathRangeQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'path-range-query', checkedArgs); + + } +/** + * Creates a reference to a path value lexicon, for use as a parameter to cts:value-tuples. Since lexicons are implemented with range indexes, this function will throw an exception if the specified range index does not exist. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.pathReference|cts.pathReference} + * @method planBuilder.cts#pathReference + * @since 2.1.1 + * @param { XsString } [pathExpression] - A path range index expression. + * @param { XsString } [options] - Options. The default is (). Options include: "type=type" Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, anyURI, point, or long-lat-point) "collation=URI" Use the lexicon with the collation specified by URI. "nullable" Allow null values in tuples reported from cts:value-tuples when using this lexicon. "unchecked" Read the scalar type, collation and coordinate-system info only from the input. Do not check the definition against the context database. "coordinate-system=name" Create a reference to an index or lexicon based on the specified coordinate system. Allowed values: "wgs84", "wgs84/double", "raw", "raw/double". Only applicable if the index/lexicon value type is point or long-lat-point. "precision=value" Create a reference to an index or lexicon configured with the specified geospatial precision. Allowed values: float and double. Only applicable if the index/lexicon value type is point or long-lat-point. This value takes precedence over the precision implicit in the coordinate system name. + * @param { MapMap } [map] - A map of namespace bindings. The keys should be namespace prefixes and the values should be namespace URIs. These namespace bindings will be added to the in-scope namespace bindings in the interpretation of the path. + * @returns { CtsReference } + */ +pathReference(...args) { + const namer = bldrbase.getNamer(args, 'path-expression'); + const paramdefs = [['path-expression', [types.XsString], true, false], ['options', [types.XsString], false, true], ['map', [types.MapMap], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.pathReference', 1, new Set(['path-expression', 'options', 'map']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.pathReference', 1, false, paramdefs, args); + return new types.CtsReference('cts', 'path-reference', checkedArgs); + + } +/** + * Creates a period value, for use as a parameter to cts:period-range-query or cts:period-compare-query. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.period|cts.period} + * @method planBuilder.cts#period + * @since 2.1.1 + * @param { XsDateTime } [start] - The dateTime value indicating start of the period. + * @param { XsDateTime } [end] - The dateTime value indicating end of the period. + * @returns { CtsPeriod } + */ +period(...args) { + const namer = bldrbase.getNamer(args, 'start'); + const paramdefs = [['start', [types.XsDateTime], true, false], ['end', [types.XsDateTime], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.period', 2, new Set(['start', 'end']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.period', 2, false, paramdefs, args); + return new types.CtsPeriod('cts', 'period', checkedArgs); + + } +/** + * Returns a cts:query matching documents that have relevant pair of period values. Searches with the cts:period-compare-query constructor require two valid names of period, if the either of the specified period does not exist, then an exception is thrown. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.periodCompareQuery|cts.periodCompareQuery} + * @method planBuilder.cts#periodCompareQuery + * @since 2.1.1 + * @param { XsString } [axis1] - Name of the first axis to compare + * @param { XsString } [operator] - A comparison operator. Period is the two timestamps contained in the axis. Operators include: "aln_equals" Match documents whose period1 equals period2. "aln_contains" Match documents whose period1 contains period2. i.e. period1 starts before period2 starts and ends before period2 ends. "aln_contained_by" Match documents whose period1 is contained by period2. "aln_meets" Match documents whose period1 meets period2, i.e. period1 ends at period2 start. "aln_met_by" Match documents whose period1 meets period2, i.e. period1 starts at period2 end. "aln_before" Match documents whose period1 is before period2, i.e. period1 ends before period2 starts. "aln_after" Match documents whose period1 is after period2, i.e. period1 starts after period2 ends. "aln_starts" Match documents whose period1 starts period2, i.e. period1 starts at period2 start and ends before period2 ends. "aln_started_by" Match documents whose period2 starts period1, i.e. period1 starts at period2 start and ends after period2 ends. "aln_finishes" Match documents whose period1 finishes period2, i.e. period1 finishes at period2 finish and starts after period2 starts. "aln_finished_by" Match documents whose period2 finishes period1, i.e. period1 finishes at period2 finish and starts before period2 starts. "aln_overlaps" Match documents whose period1 overlaps period2, i.e. period1 starts before period2 start and ends before period2 ends but after period2 starts. "aln_overlapped_by" Match documents whose period2 overlaps period1, i.e. period1 starts after period2 start but before period2 ends and ends after period2 ends. "iso_contains" Match documents whose period1 contains period2 in sql 2011 standard. i.e. period1 starts before or at period2 starts and ends after or at period2 ends. "iso_overlaps" Match documents whose period1 overlaps period2 in sql 2011 standard. i.e. period1 and period2 have common time period. "iso_succeeds" Match documents whose period1 succeeds period2 in sql 2011 standard. i.e. period1 starts at or after period2 ends "iso_precedes" Match documents whose period1 precedes period2 in sql 2011 standard. i.e. period1 ends at or before period2 ends "iso_succeeds" Match documents whose period1 succeeds period2 in sql 2011 standard. i.e. period1 starts at or after period2 ends "iso_precedes" Match documents whose period1 precedes period2 in sql 2011 standard. i.e. period1 ends at or before period2 ends "iso_imm_succeeds" Match documents whose period1 immediately succeeds period2 in sql 2011 standard. i.e. period1 starts at period2 ends "iso_imm_precedes" Match documents whose period1 immediately precedes period2 in sql 2011 standard. i.e. period1 ends at period2 ends + * @param { XsString } [axis2] - Name of the second period to compare + * @param { XsString } [options] - Options to this query. The default is (). Options include: "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. + * @returns { CtsQuery } + */ +periodCompareQuery(...args) { + const namer = bldrbase.getNamer(args, 'axis-1'); + const paramdefs = [['axis-1', [types.XsString], true, false], ['operator', [types.XsString], true, false], ['axis-2', [types.XsString], true, false], ['options', [types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.periodCompareQuery', 3, new Set(['axis-1', 'operator', 'axis-2', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.periodCompareQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'period-compare-query', checkedArgs); + + } +/** + * Returns a cts:query matching axis by name with a period value with an operator. Searches with the cts:period-range-query constructor require a axis definition on the axis name; if there is no axis configured, then an exception is thrown. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.periodRangeQuery|cts.periodRangeQuery} + * @method planBuilder.cts#periodRangeQuery + * @since 2.1.1 + * @param { XsString } [axisName] - One or more axis to match on. + * @param { XsString } [operator] - A comparison operator. Operators include: "aln_equals" Match documents whose period1 equals value. "aln_contains" Match documents whose period1 contains value. i.e. period1 starts before value starts and ends before value ends. "aln_contained_by" Match documents whose period1 is contained by value. "aln_meets" Match documents whose period1 meets value, i.e. period1 ends at value start. "aln_met_by" Match documents whose period1 meets value, i.e. period1 starts at value end. "aln_before" Match documents whose period1 is before value, i.e. period1 ends before value starts. "aln_after" Match documents whose period1 is after value, i.e. period1 starts after value ends. "aln_starts" Match documents whose period1 starts value, i.e. period1 starts at value start and ends before value ends. "aln_started_by" Match documents whose value starts period1, i.e. period1 starts at value start and ends after value ends. "aln_finishes" Match documents whose period1 finishes value, i.e. period1 finishes at value finish and starts after value starts. "aln_finished_by" Match documents whose value finishes period1, i.e. period1 finishes at value finish and starts before value starts. "aln_overlaps" Match documents whose period1 overlaps value, i.e. period1 starts before value start and ends before value ends but after value starts. "aln_overlapped_by" Match documents whose value overlaps period1, i.e. period1 starts after value start but before value ends and ends after value ends. "iso_contains" Match documents whose period1 contains value in sql 2011 standard. i.e. period1 starts before or at value starts and ends after or at value ends. "iso_overlaps" Match documents whose period1 overlaps value in sql 2011 standard. i.e. period1 and value have common time period. "iso_succeeds" Match documents whose period1 succeeds value in sql 2011 standard. i.e. period1 starts at or after value ends "iso_precedes" Match documents whose period1 precedes value in sql 2011 standard. i.e. period1 ends at or before value ends "iso_imm_succeeds" Match documents whose period1 immediately succeeds value in sql 2011 standard. i.e. period1 starts at value end "iso_imm_precedes" Match documents whose period1 immediately precedes value in sql 2011 standard. i.e. period1 ends at value end + * @param { CtsPeriod } [period] - the cts:period to perform operations on. When multiple values are specified, the query matches if any value matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. + * @returns { CtsQuery } + */ +periodRangeQuery(...args) { + const namer = bldrbase.getNamer(args, 'axis-name'); + const paramdefs = [['axis-name', [types.XsString], false, true], ['operator', [types.XsString], true, false], ['period', [types.CtsPeriod], false, true], ['options', [types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.periodRangeQuery', 2, new Set(['axis-name', 'operator', 'period', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.periodRangeQuery', 2, false, paramdefs, args); + return new types.CtsQuery('cts', 'period-range-query', checkedArgs); + + } +/** + * Returns a point value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.point|cts.point} + * @method planBuilder.cts#point + * @since 2.1.1 + * @param { XsDouble } [latitude] - The latitude of the point. + * @param { XsDouble } [longitude] - The longitude of the point. + * @returns { CtsPoint } + */ +point(...args) { + const namer = bldrbase.getNamer(args, 'latitude'); + const paramdefs = [['latitude', [types.XsDouble], true, false], ['longitude', [types.XsDouble], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.point', 2, new Set(['latitude', 'longitude']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.point', 2, false, paramdefs, args); + return new types.CtsPoint('cts', 'point', checkedArgs); + + } +/** + * Returns a geospatial polygon value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.polygon|cts.polygon} + * @method planBuilder.cts#polygon + * @since 2.1.1 + * @param { XsAnyAtomicType } [vertices] - The vertices of the polygon, given in order. No edge may cover more than 180 degrees of either latitude or longitude. The polygon as a whole may not encompass both poles. These constraints are necessary to ensure an unambiguous interpretation of the polygon. There must be at least three vertices. The first vertex should be identical to the last vertex to close the polygon. vertexes. + * @returns { CtsPolygon } + */ +polygon(...args) { + const paramdef = ['vertices', [types.XsAnyAtomicType], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('cts.polygon', 1, paramdef, args); + return new types.CtsPolygon('cts', 'polygon', checkedArgs); + } +/** + * Returns a query that matches all documents where query matches document-properties. When searching documents or document-locks, this query type provides a convenient way to additionally constrain the search against document-properties fragments. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.propertiesFragmentQuery|cts.propertiesFragmentQuery} + * @method planBuilder.cts#propertiesFragmentQuery + * @since 2.1.1 + * @param { CtsQuery } [query] - A query to be matched against the properties fragment. + * @returns { CtsQuery } + */ +propertiesFragmentQuery(...args) { + const paramdef = ['query', [types.CtsQuery], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('cts.propertiesFragmentQuery', 1, paramdef, args); + return new types.CtsQuery('cts', 'properties-fragment-query', checkedArgs); + } +/** + * Returns the stem(s) for a word. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.stem|cts.stem} + * @method planBuilder.cts#stem + * @since 2.1.1 + * @param { XsString } [text] - A word or phrase to stem. + * @param { XsString } [language] - A language to use for stemming. If not supplied, it uses the database default language. + * @param { XsString } [partOfSpeech] - A part of speech to use for stemming. The default is the unspecified part of speech. This parameter is for testing custom stemmers. + * @returns { XsString } + */ +stem(...args) { + const namer = bldrbase.getNamer(args, 'text'); + const paramdefs = [['text', [types.XsString, PlanColumn, PlanParam], true, false], ['language', [types.XsString, PlanColumn, PlanParam], false, false], ['partOfSpeech', [types.XsString, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.stem', 1, new Set(['text', 'language', 'partOfSpeech']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.stem', 1, false, paramdefs, args); + return new types.XsString('cts', 'stem', checkedArgs); + + } +/** + * Tokenizes text into words, punctuation, and spaces. Returns output in the type cts:token, which has subtypes cts:word, cts:punctuation, and cts:space, all of which are subtypes of xs:string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.tokenize|cts.tokenize} + * @method planBuilder.cts#tokenize + * @since 2.1.1 + * @param { XsString } [text] - A word or phrase to tokenize. + * @param { XsString } [language] - A language to use for tokenization. If not supplied, it uses the database default language. + * @param { XsString } [field] - A field to use for tokenization. If the field has custom tokenization rules, they will be used. If no field is supplied or the field has no custom tokenization rules, the default tokenization rules are used. + * @returns { XsString } + */ +tokenize(...args) { + const namer = bldrbase.getNamer(args, 'text'); + const paramdefs = [['text', [types.XsString, PlanColumn, PlanParam], true, false], ['language', [types.XsString, PlanColumn, PlanParam], false, false], ['field', [types.XsString, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.tokenize', 1, new Set(['text', 'language', 'field']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.tokenize', 1, false, paramdefs, args); + return new types.XsString('cts', 'tokenize', checkedArgs); + + } +/** + * Returns a cts:query matching triples with a triple index entry equal to the given values. Searches with the cts:triple-range-query constructor require the triple index; if the triple index is not configured, then an exception is thrown. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.tripleRangeQuery|cts.tripleRangeQuery} + * @method planBuilder.cts#tripleRangeQuery + * @since 2.1.1 + * @param { XsAnyAtomicType } [subject] - The subjects to look up. When multiple values are specified, the query matches if any value matches. When the empty sequence is specified, then triples with any subject are matched. + * @param { XsAnyAtomicType } [predicate] - The predicates to look up. When multiple values are specified, the query matches if any value matches. When the empty sequence is specified, then triples with any predicate are matched. + * @param { XsAnyAtomicType } [object] - The objects to look up. When multiple values are specified, the query matches if any value matches. When the empty sequence is specified, then triples with any object are matched. + * @param { XsString } [operator] - If a single string is provided it is treated as the operator for the $object values. If a sequence of three strings are provided, they give the operators for $subject, $predicate and $object in turn. The default operator is "=". Operators include: "sameTerm" Match triple index values which are the same RDF term as $value. This compares aspects of values that are ignored in XML Schema comparison semantics, like timezone and derived type of $value. "<" Match range index values less than $value. "<=" Match range index values less than or equal to $value. ">" Match range index values greater than $value. ">=" Match range index values greater than or equal to $value. "=" Match range index values equal to $value. "!=" Match range index values not equal to $value. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "cached" Cache the results of this query in the list cache. "uncached" Do not cache the results of this query in the list cache. "score-function=function" Use the selected scoring function. The score function may be: linearUse a linear function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. reciprocalUse a reciprocal function of the difference between the specified query value and the matching value in the index to calculate a score for this range query. zeroThis range query does not contribute to the score. This is the default. "slope-factor=number" Apply the given number as a scaling factor to the slope of the scoring function. The default is 1.0. + * @param { XsDouble } [weight] - A weight for this query. The default is 1.0. + * @returns { CtsQuery } + */ +tripleRangeQuery(...args) { + const namer = bldrbase.getNamer(args, 'subject'); + const paramdefs = [['subject', [types.XsAnyAtomicType], false, true], ['predicate', [types.XsAnyAtomicType], false, true], ['object', [types.XsAnyAtomicType], false, true], ['operator', [types.XsString], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.tripleRangeQuery', 3, new Set(['subject', 'predicate', 'object', 'operator', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.tripleRangeQuery', 3, false, paramdefs, args); + return new types.CtsQuery('cts', 'triple-range-query', checkedArgs); + + } +/** + * Returns a query that matches all fragments. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.trueQuery|cts.trueQuery} + * @method planBuilder.cts#trueQuery + * @since 2.1.1 + + * @returns { CtsQuery } + */ +trueQuery(...args) { + bldrbase.checkMaxArity('cts.trueQuery', args.length, 0); + return new types.CtsQuery('cts', 'true-query', args); + } +/** + * Creates a reference to the URI lexicon, for use as a parameter to cts:value-tuples. This function requires the URI lexicon to be enabled, otherwise it throws an exception. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.uriReference|cts.uriReference} + * @method planBuilder.cts#uriReference + * @since 2.1.1 + + * @returns { CtsReference } + */ +uriReference(...args) { + bldrbase.checkMaxArity('cts.uriReference', args.length, 0); + return new types.CtsReference('cts', 'uri-reference', args); + } +/** + * Returns a query matching text content containing a given phrase. Provides a client interface to a server function. See {@link http://docs.marklogic.com/cts.wordQuery|cts.wordQuery} + * @method planBuilder.cts#wordQuery + * @since 2.1.1 + * @param { XsString } [text] - Some words or phrases to match. When multiple strings are specified, the query matches if any string matches. + * @param { XsString } [options] - Options to this query. The default is (). Options include: "case-sensitive" A case-sensitive query. "case-insensitive" A case-insensitive query. "diacritic-sensitive" A diacritic-sensitive query. "diacritic-insensitive" A diacritic-insensitive query. "punctuation-sensitive" A punctuation-sensitive query. "punctuation-insensitive" A punctuation-insensitive query. "whitespace-sensitive" A whitespace-sensitive query. "whitespace-insensitive" A whitespace-insensitive query. "stemmed" A stemmed query. "unstemmed" An unstemmed query. "wildcarded" A wildcarded query. "unwildcarded" An unwildcarded query. "exact" An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded". "lang=iso639code" Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration. "distance-weight=number" A weight applied based on the minimum distance between matches of this query. Higher weights add to the importance of proximity (as opposed to term matches) when the relevance order is calculated. The default value is 0.0 (no impact of proximity). The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. This parameter has no effect if the word positions index is not enabled. This parameter has no effect on searches that use score-simple, score-random, or score-zero (because those scoring algorithms do not consider term frequency, proximity is irrelevant). "min-occurs=number" Specifies the minimum number of occurrences required. If fewer that this number of words occur, the fragment does not match. The default is 1. "max-occurs=number" Specifies the maximum number of occurrences required. If more than this number of words occur, the fragment does not match. The default is unbounded. "synonym" Specifies that all of the terms in the $text parameter are considered synonyms for scoring purposes. The result is that occurrences of more than one of the synonyms are scored as if there are more occurrences of the same term (as opposed to having a separate term that contributes to score). "lexicon-expand=value" The value is one of full, prefix-postfix, off, or heuristic (the default is heuristic). An option with a value of lexicon-expand=full specifies that wildcards are resolved by expanding the pattern to words in a lexicon (if there is one available), and turning into a series of cts:word-queries, even if this takes a long time to evaluate. An option with a value of lexicon-expand=prefix-postfix specifies that wildcards are resolved by expanding the pattern to the pre- and postfixes of the words in the word lexicon (if there is one), and turning the query into a series of character queries, even if it takes a long time to evaluate. An option with a value of lexicon-expand=off specifies that wildcards are only resolved by looking up character patterns in the search pattern index, not in the lexicon. An option with a value of lexicon-expand=heuristic, which is the default, specifies that wildcards are resolved by using a series of internal rules, such as estimating the number of lexicon entries that need to be scanned, seeing if the estimate crosses certain thresholds, and (if appropriate), using another way besides lexicon expansion to resolve the query. "lexicon-expansion-limit=number" Specifies the limit for lexicon expansion. This puts a restriction on the number of lexicon expansions that can be performed. If the limit is exceeded, the server may raise an error depending on whether the "limit-check" option is set. The default value for this option will be 4096. "limit-check" Specifies that an error will be raised if the lexicon expansion exceeds the specified limit. "no-limit-check" Specifies that error will not be raised if the lexicon expansion exceeds the specified limit. The server will try to resolve the wildcard. + * @param { XsDouble } [weight] - A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. + * @returns { CtsQuery } + */ +wordQuery(...args) { + const namer = bldrbase.getNamer(args, 'text'); + const paramdefs = [['text', [types.XsString], false, true], ['options', [types.XsString], false, true], ['weight', [types.XsDouble], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'cts.wordQuery', 1, new Set(['text', 'options', 'weight']), paramdefs, args) : + bldrbase.makePositionalArgs('cts.wordQuery', 1, false, paramdefs, args); + return new types.CtsQuery('cts', 'word-query', checkedArgs); + + } +} +class FnExpr { + constructor() { + } + /** + * Returns the absolute value of arg. If arg is negative returns -arg otherwise returns arg. If type of arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of arg. If the type of arg is a type derived from one of the numeric types, the result is an instance of the base numeric type. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.abs|fn.abs} + * @method planBuilder.fn#abs + * @since 2.1.1 + * @param { XsNumeric } [arg] - A numeric value. + * @returns { XsNumeric } + */ +abs(...args) { + const paramdef = ['arg', [types.XsNumeric, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.abs', 1, paramdef, args); + return new types.XsNumeric('fn', 'abs', checkedArgs); + } +/** + * Adjusts an xs:date value to a specific timezone, or to no timezone at all. If timezone is the empty sequence, returns an xs:date without a timezone. Otherwise, returns an xs:date with a timezone. For purposes of timezone adjustment, an xs:date is treated as an xs:dateTime with time 00:00:00. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.adjustDateToTimezone|fn.adjustDateToTimezone} + * @method planBuilder.fn#adjustDateToTimezone + * @since 2.1.1 + * @param { XsDate } [arg] - The date to adjust to the new timezone. + * @param { XsDayTimeDuration } [timezone] - The new timezone for the date. + * @returns { XsDate } + */ +adjustDateToTimezone(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsDate, PlanColumn, PlanParam], false, false], ['timezone', [types.XsDayTimeDuration, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.adjustDateToTimezone', 1, new Set(['arg', 'timezone']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.adjustDateToTimezone', 1, false, paramdefs, args); + return new types.XsDate('fn', 'adjust-date-to-timezone', checkedArgs); + + } +/** + * Adjusts an xs:dateTime value to a specific timezone, or to no timezone at all. If timezone is the empty sequence, returns an xs:dateTime without a timezone. Otherwise, returns an xs:dateTime with a timezone. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.adjustDateTimeToTimezone|fn.adjustDateTimeToTimezone} + * @method planBuilder.fn#adjustDateTimeToTimezone + * @since 2.1.1 + * @param { XsDateTime } [arg] - The dateTime to adjust to the new timezone. + * @param { XsDayTimeDuration } [timezone] - The new timezone for the dateTime. + * @returns { XsDateTime } + */ +adjustDateTimeToTimezone(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsDateTime, PlanColumn, PlanParam], false, false], ['timezone', [types.XsDayTimeDuration, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.adjustDateTimeToTimezone', 1, new Set(['arg', 'timezone']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.adjustDateTimeToTimezone', 1, false, paramdefs, args); + return new types.XsDateTime('fn', 'adjust-dateTime-to-timezone', checkedArgs); + + } +/** + * Adjusts an xs:time value to a specific timezone, or to no timezone at all. If timezone is the empty sequence, returns an xs:time without a timezone. Otherwise, returns an xs:time with a timezone. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.adjustTimeToTimezone|fn.adjustTimeToTimezone} + * @method planBuilder.fn#adjustTimeToTimezone + * @since 2.1.1 + * @param { XsTime } [arg] - The time to adjust to the new timezone. + * @param { XsDayTimeDuration } [timezone] - The new timezone for the date. + * @returns { XsTime } + */ +adjustTimeToTimezone(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsTime, PlanColumn, PlanParam], false, false], ['timezone', [types.XsDayTimeDuration, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.adjustTimeToTimezone', 1, new Set(['arg', 'timezone']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.adjustTimeToTimezone', 1, false, paramdefs, args); + return new types.XsTime('fn', 'adjust-time-to-timezone', checkedArgs); + + } +/** + * The result of the function is a new element node whose string value is the original string, but which contains markup to show which parts of the input match the regular expression. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.analyzeString|fn.analyzeString} + * @method planBuilder.fn#analyzeString + * @since 2.1.1 + * @param { XsString } [in] - The string to start with. + * @param { XsString } [regex] - The regular expression pattern to match. + * @param { XsString } [flags] - The flag representing how to interpret the regular expression. One of "s", "m", "i", or "x", as defined in http://www.w3.org/TR/xpath-functions/#flags. + * @returns { ElementNode } + */ +analyzeString(...args) { + const namer = bldrbase.getNamer(args, 'in'); + const paramdefs = [['in', [types.XsString, PlanColumn, PlanParam], false, false], ['regex', [types.XsString, PlanColumn, PlanParam], true, false], ['flags', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.analyzeString', 2, new Set(['in', 'regex', 'flags']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.analyzeString', 2, false, paramdefs, args); + return new types.ElementNode('fn', 'analyze-string', checkedArgs); + + } +/** + * Returns the average of the values in the input sequence arg, that is, the sum of the values divided by the number of values. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.avg|fn.avg} + * @method planBuilder.fn#avg + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg] - The sequence of values to average. + * @returns { XsAnyAtomicType } + */ +avg(...args) { + const paramdef = ['arg', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.avg', 1, paramdef, args); + return new types.XsAnyAtomicType('fn', 'avg', checkedArgs); + } +/** + * Returns the value of the base-uri property for the specified node. If the node is part of a document and does not have a base-uri attribute explicitly set, fn:base-uri typically returns the URI of the document in which the node resides. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.baseUri|fn.baseUri} + * @method planBuilder.fn#baseUri + * @since 2.1.1 + * @param { Node } [arg] - The node whose base-uri is to be returned. + * @returns { XsAnyURI } + */ +baseUri(...args) { + const paramdef = ['arg', [types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.baseUri', 1, paramdef, args); + return new types.XsAnyURI('fn', 'base-uri', checkedArgs); + } +/** + * Computes the effective boolean value of the sequence arg. See Section 2.4.3 Effective Boolean Value[XP]. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.boolean|fn.boolean} + * @method planBuilder.fn#boolean + * @since 2.1.1 + * @param { Item } [arg] - A sequence of items. + * @returns { XsBoolean } + */ +boolean(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.boolean', 1, paramdef, args); + return new types.XsBoolean('fn', 'boolean', checkedArgs); + } +/** + * Returns the smallest (closest to negative infinity) number with no fractional part that is not less than the value of arg. If type of arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of arg. If the type of arg is a type derived from one of the numeric types, the result is an instance of the base numeric type. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.ceiling|fn.ceiling} + * @method planBuilder.fn#ceiling + * @since 2.1.1 + * @param { XsNumeric } [arg] - A numeric value. + * @returns { XsNumeric } + */ +ceiling(...args) { + const paramdef = ['arg', [types.XsNumeric, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.ceiling', 1, paramdef, args); + return new types.XsNumeric('fn', 'ceiling', checkedArgs); + } +/** + * Returns true if the specified parameters are the same Unicode code point, otherwise returns false. The codepoints are compared according to the Unicode code point collation (http://www.w3.org/2005/xpath-functions/collation/codepoint). Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.codepointEqual|fn.codepointEqual} + * @method planBuilder.fn#codepointEqual + * @since 2.1.1 + * @param { XsString } [comparand1] - A string to be compared. + * @param { XsString } [comparand2] - A string to be compared. + * @returns { XsBoolean } + */ +codepointEqual(...args) { + const namer = bldrbase.getNamer(args, 'comparand1'); + const paramdefs = [['comparand1', [types.XsString, PlanColumn, PlanParam], false, false], ['comparand2', [types.XsString, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.codepointEqual', 2, new Set(['comparand1', 'comparand2']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.codepointEqual', 2, false, paramdefs, args); + return new types.XsBoolean('fn', 'codepoint-equal', checkedArgs); + + } +/** + * Creates an xs:string from a sequence of Unicode code points. Returns the zero-length string if arg is the empty sequence. If any of the code points in arg is not a legal XML character, an error is raised. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.codepointsToString|fn.codepointsToString} + * @method planBuilder.fn#codepointsToString + * @since 2.1.1 + * @param { XsInteger } [arg] - A sequence of Unicode code points. + * @returns { XsString } + */ +codepointsToString(...args) { + const paramdef = ['arg', [types.XsInteger, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.codepointsToString', 1, paramdef, args); + return new types.XsString('fn', 'codepoints-to-string', checkedArgs); + } +/** + * Returns -1, 0, or 1, depending on whether the value of the comparand1 is respectively less than, equal to, or greater than the value of comparand2, according to the rules of the collation that is used. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.compare|fn.compare} + * @method planBuilder.fn#compare + * @since 2.1.1 + * @param { XsString } [comparand1] - A string to be compared. + * @param { XsString } [comparand2] - A string to be compared. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsInteger } + */ +compare(...args) { + const namer = bldrbase.getNamer(args, 'comparand1'); + const paramdefs = [['comparand1', [types.XsString, PlanColumn, PlanParam], false, false], ['comparand2', [types.XsString, PlanColumn, PlanParam], false, false], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.compare', 2, new Set(['comparand1', 'comparand2', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.compare', 2, false, paramdefs, args); + return new types.XsInteger('fn', 'compare', checkedArgs); + + } +/** + * Returns the xs:string that is the concatenation of the values of the specified parameters. Accepts two or more xs:anyAtomicType arguments and casts them to xs:string. If any of the parameters is the empty sequence, the parameter is treated as the zero-length string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.concat|fn.concat} + * @method planBuilder.fn#concat + * @since 2.1.1 + * @param { XsAnyAtomicType } [parameter1] - A value. + * @returns { XsString } + */ +concat(...args) { + const namer = bldrbase.getNamer(args, 'parameter1'); + const paramdefs = [['parameter1', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.concat', 1, new Set(['parameter1']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.concat', 1, true, paramdefs, args); + return new types.XsString('fn', 'concat', checkedArgs); + + } +/** + * Returns true if the first parameter contains the string from the second parameter, otherwise returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.contains|fn.contains} + * @method planBuilder.fn#contains + * @since 2.1.1 + * @param { XsString } [parameter1] - The string from which to test. + * @param { XsString } [parameter2] - The string to test for existence in the first parameter. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsBoolean } + */ +contains(...args) { + const namer = bldrbase.getNamer(args, 'parameter1'); + const paramdefs = [['parameter1', [types.XsString, PlanColumn, PlanParam], false, false], ['parameter2', [types.XsString, PlanColumn, PlanParam], false, false], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.contains', 2, new Set(['parameter1', 'parameter2', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.contains', 2, false, paramdefs, args); + return new types.XsBoolean('fn', 'contains', checkedArgs); + + } +/** + * Returns the number of items in the value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.count|fn.count} + * @method planBuilder.fn#count + * @since 2.1.1 + * @param { Item } [arg] - The sequence of items to count. + * @param { XsDouble } [maximum] - The maximum value of the count to return. MarkLogic Server will stop count when the $maximum value is reached and return the $maximum value. This is an extension to the W3C standard fn:count function. + * @returns { XsInteger } + */ +count(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.Item, PlanColumn, PlanParam], false, true], ['maximum', [types.XsDouble, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.count', 1, new Set(['arg', 'maximum']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.count', 1, false, paramdefs, args); + return new types.XsInteger('fn', 'count', checkedArgs); + + } +/** + * Returns xs:date(fn:current-dateTime()). This is an xs:date (with timezone) that is current at some time during the evaluation of a query or transformation in which fn:current-date() is executed. This function is *stable*. The precise instant during the query or transformation represented by the value of fn:current-date() is *implementation dependent*. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.currentDate|fn.currentDate} + * @method planBuilder.fn#currentDate + * @since 2.1.1 + + * @returns { XsDate } + */ +currentDate(...args) { + bldrbase.checkMaxArity('fn.currentDate', args.length, 0); + return new types.XsDate('fn', 'current-date', args); + } +/** + * Returns the current dateTime value (with timezone) from the dynamic context. (See Section C.2 Dynamic Context Components[XP].) This is an xs:dateTime that is current at some time during the evaluation of a query or transformation in which fn:current-dateTime() is executed. This function is *stable*. The precise instant during the query or transformation represented by the value of fn:current-dateTime() is *implementation dependent*. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.currentDateTime|fn.currentDateTime} + * @method planBuilder.fn#currentDateTime + * @since 2.1.1 + + * @returns { XsDateTime } + */ +currentDateTime(...args) { + bldrbase.checkMaxArity('fn.currentDateTime', args.length, 0); + return new types.XsDateTime('fn', 'current-dateTime', args); + } +/** + * Returns xs:time(fn:current-dateTime()). This is an xs:time (with timezone) that is current at some time during the evaluation of a query or transformation in which fn:current-time() is executed. This function is *stable*. The precise instant during the query or transformation represented by the value of fn:current-time() is *implementation dependent*. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.currentTime|fn.currentTime} + * @method planBuilder.fn#currentTime + * @since 2.1.1 + + * @returns { XsTime } + */ +currentTime(...args) { + bldrbase.checkMaxArity('fn.currentTime', args.length, 0); + return new types.XsTime('fn', 'current-time', args); + } +/** + * Returns an xs:integer between 1 and 31, both inclusive, representing the day component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.dayFromDate|fn.dayFromDate} + * @method planBuilder.fn#dayFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose day component will be returned. + * @returns { XsInteger } + */ +dayFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.dayFromDate', 1, paramdef, args); + return new types.XsInteger('fn', 'day-from-date', checkedArgs); + } +/** + * Returns an xs:integer between 1 and 31, both inclusive, representing the day component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.dayFromDateTime|fn.dayFromDateTime} + * @method planBuilder.fn#dayFromDateTime + * @since 2.1.1 + * @param { XsDateTime } [arg] - The dateTime whose day component will be returned. + * @returns { XsInteger } + */ +dayFromDateTime(...args) { + const paramdef = ['arg', [types.XsDateTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.dayFromDateTime', 1, paramdef, args); + return new types.XsInteger('fn', 'day-from-dateTime', checkedArgs); + } +/** + * Returns an xs:integer representing the days component in the canonical lexical representation of the value of arg. The result may be negative. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.daysFromDuration|fn.daysFromDuration} + * @method planBuilder.fn#daysFromDuration + * @since 2.1.1 + * @param { XsDuration } [arg] - The duration whose day component will be returned. + * @returns { XsInteger } + */ +daysFromDuration(...args) { + const paramdef = ['arg', [types.XsDuration, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.daysFromDuration', 1, paramdef, args); + return new types.XsInteger('fn', 'days-from-duration', checkedArgs); + } +/** + * This function assesses whether two sequences are deep-equal to each other. To be deep-equal, they must contain items that are pairwise deep-equal; and for two items to be deep-equal, they must either be atomic values that compare equal, or nodes of the same kind, with the same name, whose children are deep-equal. This is defined in more detail below. The collation argument identifies a collation which is used at all levels of recursion when strings are compared (but not when names are compared), according to the rules in 7.3.1 Collations. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.deepEqual|fn.deepEqual} + * @method planBuilder.fn#deepEqual + * @since 2.1.1 + * @param { Item } [parameter1] - The first sequence of items, each item should be an atomic value or node. + * @param { Item } [parameter2] - The sequence of items to compare to the first sequence of items, again each item should be an atomic value or node. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsBoolean } + */ +deepEqual(...args) { + const namer = bldrbase.getNamer(args, 'parameter1'); + const paramdefs = [['parameter1', [types.Item, PlanColumn, PlanParam], false, true], ['parameter2', [types.Item, PlanColumn, PlanParam], false, true], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.deepEqual', 2, new Set(['parameter1', 'parameter2', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.deepEqual', 2, false, paramdefs, args); + return new types.XsBoolean('fn', 'deep-equal', checkedArgs); + + } +/** + * Returns the value of the default collation property from the static context. Components of the static context are discussed in Section C.1 Static Context Components[XP]. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.defaultCollation|fn.defaultCollation} + * @method planBuilder.fn#defaultCollation + * @since 2.1.1 + + * @returns { XsString } + */ +defaultCollation(...args) { + bldrbase.checkMaxArity('fn.defaultCollation', args.length, 0); + return new types.XsString('fn', 'default-collation', args); + } +/** + * Returns the sequence that results from removing from arg all but one of a set of values that are eq to one other. Values that cannot be compared, i.e. the eq operator is not defined for their types, are considered to be distinct. Values of type xs:untypedAtomic are compared as if they were of type xs:string. The order in which the sequence of values is returned is implementation dependent. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.distinctValues|fn.distinctValues} + * @method planBuilder.fn#distinctValues + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg] - A sequence of items. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsAnyAtomicType } + */ +distinctValues(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, true], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.distinctValues', 1, new Set(['arg', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.distinctValues', 1, false, paramdefs, args); + return new types.XsAnyAtomicType('fn', 'distinct-values', checkedArgs); + + } +/** + * Returns the value of the document-uri property for the specified node. If the node is a document node, then the value returned is the URI of the document. If the node is not a document node, then fn:document-uri returns the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.documentUri|fn.documentUri} + * @method planBuilder.fn#documentUri + * @since 2.1.1 + * @param { Node } [arg] - The node whose document-uri is to be returned. + * @returns { XsAnyURI } + */ +documentUri(...args) { + const paramdef = ['arg', [types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.documentUri', 1, paramdef, args); + return new types.XsAnyURI('fn', 'document-uri', checkedArgs); + } +/** + * If the value of arg is the empty sequence, the function returns true; otherwise, the function returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.empty|fn.empty} + * @method planBuilder.fn#empty + * @since 2.1.1 + * @param { Item } [arg] - A sequence to test. + * @returns { XsBoolean } + */ +empty(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.empty', 1, paramdef, args); + return new types.XsBoolean('fn', 'empty', checkedArgs); + } +/** + * Invertible function that escapes characters required to be escaped inside path segments of URIs. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.encodeForUri|fn.encodeForUri} + * @method planBuilder.fn#encodeForUri + * @since 2.1.1 + * @param { XsString } [uriPart] - A string representing an unescaped URI. + * @returns { XsString } + */ +encodeForUri(...args) { + const paramdef = ['uri-part', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.encodeForUri', 1, paramdef, args); + return new types.XsString('fn', 'encode-for-uri', checkedArgs); + } +/** + * Returns true if the first parameter ends with the string from the second parameter, otherwise returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.endsWith|fn.endsWith} + * @method planBuilder.fn#endsWith + * @since 2.1.1 + * @param { XsString } [parameter1] - The parameter from which to test. + * @param { XsString } [parameter2] - The string to test whether it is at the end of the first parameter. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsBoolean } + */ +endsWith(...args) { + const namer = bldrbase.getNamer(args, 'parameter1'); + const paramdefs = [['parameter1', [types.XsString, PlanColumn, PlanParam], false, false], ['parameter2', [types.XsString, PlanColumn, PlanParam], false, false], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.endsWith', 2, new Set(['parameter1', 'parameter2', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.endsWith', 2, false, paramdefs, args); + return new types.XsBoolean('fn', 'ends-with', checkedArgs); + + } +/** + * %-escapes everything except printable ASCII characters. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.escapeHtmlUri|fn.escapeHtmlUri} + * @method planBuilder.fn#escapeHtmlUri + * @since 2.1.1 + * @param { XsString } [uriPart] - A string representing an unescaped URI. + * @returns { XsString } + */ +escapeHtmlUri(...args) { + const paramdef = ['uri-part', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.escapeHtmlUri', 1, paramdef, args); + return new types.XsString('fn', 'escape-html-uri', checkedArgs); + } +/** + * If the value of arg is not the empty sequence, the function returns true; otherwise, the function returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.exists|fn.exists} + * @method planBuilder.fn#exists + * @since 2.1.1 + * @param { Item } [arg] - A sequence to test. + * @returns { XsBoolean } + */ +exists(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.exists', 1, paramdef, args); + return new types.XsBoolean('fn', 'exists', checkedArgs); + } +/** + * Returns the xs:boolean value false. Equivalent to xs:boolean("0"). Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.false|fn.false} + * @method planBuilder.fn#false + * @since 2.1.1 + + * @returns { XsBoolean } + */ +false(...args) { + bldrbase.checkMaxArity('fn.false', args.length, 0); + return new types.XsBoolean('fn', 'false', args); + } +/** + * Returns the largest (closest to positive infinity) number with no fractional part that is not greater than the value of arg. If type of arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of arg. If the type of arg is a type derived from one of the numeric types, the result is an instance of the base numeric type. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.floor|fn.floor} + * @method planBuilder.fn#floor + * @since 2.1.1 + * @param { XsNumeric } [arg] - A numeric value. + * @returns { XsNumeric } + */ +floor(...args) { + const paramdef = ['arg', [types.XsNumeric, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.floor', 1, paramdef, args); + return new types.XsNumeric('fn', 'floor', checkedArgs); + } +/** + * Returns a formatted date value based on the picture argument. This is an XSLT function, and it is available in XSLT, XQuery 1.0-ml, and Server-Side JavaScript. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.formatDate|fn.formatDate} + * @method planBuilder.fn#formatDate + * @since 2.1.1 + * @param { XsDate } [value] - The given date $value that needs to be formatted. + * @param { XsString } [picture] - The desired string representation of the given date $value. The picture string is a sequence of characters, in which the characters represent variables such as, decimal-separator-sign, grouping-sign, zero-digit-sign, digit-sign, pattern-separator, percent sign and per-mille-sign. For details on the picture string, see http://www.w3.org/TR/xslt20/#date-picture-string. + * @param { XsString } [language] - The desired language for string representation of the date $value. + * @param { XsString } [calendar] - The only calendar supported at this point is "Gregorian" or "AD". + * @param { XsString } [country] - $country is used the specification to take into account country specific string representation. + * @returns { XsString } + */ +formatDate(...args) { + const namer = bldrbase.getNamer(args, 'value'); + const paramdefs = [['value', [types.XsDate, PlanColumn, PlanParam], false, false], ['picture', [types.XsString, PlanColumn, PlanParam], true, false], ['language', [types.XsString, PlanColumn, PlanParam], false, false], ['calendar', [types.XsString, PlanColumn, PlanParam], false, false], ['country', [types.XsString, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.formatDate', 2, new Set(['value', 'picture', 'language', 'calendar', 'country']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.formatDate', 2, false, paramdefs, args); + return new types.XsString('fn', 'format-date', checkedArgs); + + } +/** + * Returns a formatted dateTime value based on the picture argument. This is an XSLT function, and it is available in XSLT, XQuery 1.0-ml, and Server-Side JavaScript. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.formatDateTime|fn.formatDateTime} + * @method planBuilder.fn#formatDateTime + * @since 2.1.1 + * @param { XsDateTime } [value] - The given dateTime $value that needs to be formatted. + * @param { XsString } [picture] - The desired string representation of the given dateTime $value. The picture string is a sequence of characters, in which the characters represent variables such as, decimal-separator-sign, grouping-sign, zero-digit-sign, digit-sign, pattern-separator, percent sign and per-mille-sign. For details on the picture string, see http://www.w3.org/TR/xslt20/#date-picture-string. + * @param { XsString } [language] - The desired language for string representation of the dateTime $value. + * @param { XsString } [calendar] - The only calendar supported at this point is "Gregorian" or "AD". + * @param { XsString } [country] - $country is used the specification to take into account country specific string representation. + * @returns { XsString } + */ +formatDateTime(...args) { + const namer = bldrbase.getNamer(args, 'value'); + const paramdefs = [['value', [types.XsDateTime, PlanColumn, PlanParam], false, false], ['picture', [types.XsString, PlanColumn, PlanParam], true, false], ['language', [types.XsString, PlanColumn, PlanParam], false, false], ['calendar', [types.XsString, PlanColumn, PlanParam], false, false], ['country', [types.XsString, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.formatDateTime', 2, new Set(['value', 'picture', 'language', 'calendar', 'country']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.formatDateTime', 2, false, paramdefs, args); + return new types.XsString('fn', 'format-dateTime', checkedArgs); + + } +/** + * Returns a formatted string representation of value argument based on the supplied picture. An optional decimal format name may also be supplied for interpretation of the picture string. This is an XSLT function, and it is available in XSLT, XQuery 1.0-ml, and Server-Side JavaScript. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.formatNumber|fn.formatNumber} + * @method planBuilder.fn#formatNumber + * @since 2.1.1 + * @param { XsNumeric } [value] - The given numeric $value that needs to be formatted. + * @param { XsString } [picture] - The desired string representation of the given number $value. The picture string is a sequence of characters, in which the characters represent variables such as, decimal-separator-sign, grouping-sign, zero-digit-sign, digit-sign, pattern-separator, percent sign and per-mille-sign. For details on the format-number picture string, see http://www.w3.org/TR/xslt20/#function-format-number. + * @param { XsString } [decimalFormatName] - Represents a named instruction. It is used to assign values to the variables mentioned above based on the picture string. + * @returns { XsString } + */ +formatNumber(...args) { + const namer = bldrbase.getNamer(args, 'value'); + const paramdefs = [['value', [types.XsNumeric, PlanColumn, PlanParam], false, true], ['picture', [types.XsString, PlanColumn, PlanParam], true, false], ['decimal-format-name', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.formatNumber', 2, new Set(['value', 'picture', 'decimal-format-name']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.formatNumber', 2, false, paramdefs, args); + return new types.XsString('fn', 'format-number', checkedArgs); + + } +/** + * Returns a formatted time value based on the picture argument. This is an XSLT function, and it is available in XSLT, XQuery 1.0-ml, and Server-Side JavaScript. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.formatTime|fn.formatTime} + * @method planBuilder.fn#formatTime + * @since 2.1.1 + * @param { XsTime } [value] - The given time $value that needs to be formatted. + * @param { XsString } [picture] - The desired string representation of the given time $value. The picture string is a sequence of characters, in which the characters represent variables such as, decimal-separator-sign, grouping-sign, zero-digit-sign, digit-sign, pattern-separator, percent sign and per-mille-sign. For details on the picture string, see http://www.w3.org/TR/xslt20/#date-picture-string. + * @param { XsString } [language] - The desired language for string representation of the time $value. + * @param { XsString } [calendar] - The only calendar supported at this point is "Gregorian" or "AD". + * @param { XsString } [country] - $country is used the specification to take into account country specific string representation. + * @returns { XsString } + */ +formatTime(...args) { + const namer = bldrbase.getNamer(args, 'value'); + const paramdefs = [['value', [types.XsTime, PlanColumn, PlanParam], false, false], ['picture', [types.XsString, PlanColumn, PlanParam], true, false], ['language', [types.XsString, PlanColumn, PlanParam], false, false], ['calendar', [types.XsString, PlanColumn, PlanParam], false, false], ['country', [types.XsString, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.formatTime', 2, new Set(['value', 'picture', 'language', 'calendar', 'country']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.formatTime', 2, false, paramdefs, args); + return new types.XsString('fn', 'format-time', checkedArgs); + + } +/** + * Returns a string that uniquely identifies a given node. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.generateId|fn.generateId} + * @method planBuilder.fn#generateId + * @since 2.1.1 + * @param { Node } [node] - The node whose ID will be generated. + * @returns { XsString } + */ +generateId(...args) { + const paramdef = ['node', [types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.generateId', 1, paramdef, args); + return new types.XsString('fn', 'generate-id', checkedArgs); + } +/** + * Returns the first item in a sequence. For more details, see XPath 3.0 Functions and Operators. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.head|fn.head} + * @method planBuilder.fn#head + * @since 2.1.1 + * @param { Item } [seq] - A sequence of items. + * @returns { Item } + */ +head(...args) { + const paramdef = ['seq', [types.Item, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.head', 1, paramdef, args); + return new types.Item('fn', 'head', checkedArgs); + } +/** + * Returns an xs:integer between 0 and 23, both inclusive, representing the hours component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.hoursFromDateTime|fn.hoursFromDateTime} + * @method planBuilder.fn#hoursFromDateTime + * @since 2.1.1 + * @param { XsDateTime } [arg] - The dateTime whose hours component will be returned. + * @returns { XsInteger } + */ +hoursFromDateTime(...args) { + const paramdef = ['arg', [types.XsDateTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.hoursFromDateTime', 1, paramdef, args); + return new types.XsInteger('fn', 'hours-from-dateTime', checkedArgs); + } +/** + * Returns an xs:integer representing the hours component in the canonical lexical representation of the value of arg. The result may be negative. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.hoursFromDuration|fn.hoursFromDuration} + * @method planBuilder.fn#hoursFromDuration + * @since 2.1.1 + * @param { XsDuration } [arg] - The duration whose hour component will be returned. + * @returns { XsInteger } + */ +hoursFromDuration(...args) { + const paramdef = ['arg', [types.XsDuration, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.hoursFromDuration', 1, paramdef, args); + return new types.XsInteger('fn', 'hours-from-duration', checkedArgs); + } +/** + * Returns an xs:integer between 0 and 23, both inclusive, representing the value of the hours component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.hoursFromTime|fn.hoursFromTime} + * @method planBuilder.fn#hoursFromTime + * @since 2.1.1 + * @param { XsTime } [arg] - The time whose hours component will be returned. + * @returns { XsInteger } + */ +hoursFromTime(...args) { + const paramdef = ['arg', [types.XsTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.hoursFromTime', 1, paramdef, args); + return new types.XsInteger('fn', 'hours-from-time', checkedArgs); + } +/** + * Returns the value of the implicit timezone property from the dynamic context. Components of the dynamic context are discussed in Section C.2 Dynamic Context Components[XP]. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.implicitTimezone|fn.implicitTimezone} + * @method planBuilder.fn#implicitTimezone + * @since 2.1.1 + + * @returns { XsDayTimeDuration } + */ +implicitTimezone(...args) { + bldrbase.checkMaxArity('fn.implicitTimezone', args.length, 0); + return new types.XsDayTimeDuration('fn', 'implicit-timezone', args); + } +/** + * Returns the prefixes of the in-scope namespaces for element. For namespaces that have a prefix, it returns the prefix as an xs:NCName. For the default namespace, which has no prefix, it returns the zero-length string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.inScopePrefixes|fn.inScopePrefixes} + * @method planBuilder.fn#inScopePrefixes + * @since 2.1.1 + * @param { ElementNode } [element] - The element whose in-scope prefixes will be returned. + * @returns { XsString } + */ +inScopePrefixes(...args) { + const paramdef = ['element', [types.ElementNode, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.inScopePrefixes', 1, paramdef, args); + return new types.XsString('fn', 'in-scope-prefixes', checkedArgs); + } +/** + * Returns a sequence of positive integers giving the positions within the sequence seqParam of items that are equal to srchParam. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.indexOf|fn.indexOf} + * @method planBuilder.fn#indexOf + * @since 2.1.1 + * @param { XsAnyAtomicType } [seqParam] - A sequence of values. + * @param { XsAnyAtomicType } [srchParam] - A value to find on the list. + * @param { XsString } [collationLiteral] - A collation identifier. + * @returns { XsInteger } + */ +indexOf(...args) { + const namer = bldrbase.getNamer(args, 'seqParam'); + const paramdefs = [['seqParam', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, true], ['srchParam', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['collationLiteral', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.indexOf', 2, new Set(['seqParam', 'srchParam', 'collationLiteral']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.indexOf', 2, false, paramdefs, args); + return new types.XsInteger('fn', 'index-of', checkedArgs); + + } +/** + * Returns a new sequence constructed from the value of target with the value of inserts inserted at the position specified by the value of position. (The value of target is not affected by the sequence construction.) Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.insertBefore|fn.insertBefore} + * @method planBuilder.fn#insertBefore + * @since 2.1.1 + * @param { Item } [target] - The sequence of items into which new items will be inserted. + * @param { XsInteger } [position] - The position in the target sequence at which the new items will be added. + * @param { Item } [inserts] - The items to insert into the target sequence. + * @returns { Item } + */ +insertBefore(...args) { + const namer = bldrbase.getNamer(args, 'target'); + const paramdefs = [['target', [types.Item, PlanColumn, PlanParam], false, true], ['position', [types.XsInteger, PlanColumn, PlanParam], true, false], ['inserts', [types.Item, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.insertBefore', 3, new Set(['target', 'position', 'inserts']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.insertBefore', 3, false, paramdefs, args); + return new types.Item('fn', 'insert-before', checkedArgs); + + } +/** + * Idempotent function that escapes non-URI characters. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.iriToUri|fn.iriToUri} + * @method planBuilder.fn#iriToUri + * @since 2.1.1 + * @param { XsString } [uriPart] - A string representing an unescaped URI. + * @returns { XsString } + */ +iriToUri(...args) { + const paramdef = ['uri-part', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.iriToUri', 1, paramdef, args); + return new types.XsString('fn', 'iri-to-uri', checkedArgs); + } +/** + * This function tests whether the language of node, or the context node if the second argument is omitted, as specified by xml:lang attributes is the same as, or is a sublanguage of, the language specified by testlang. The language of the argument node, or the context node if the second argument is omitted, is determined by the value of the xml:lang attribute on the node, or, if the node has no such attribute, by the value of the xml:lang attribute on the nearest ancestor of the node that has an xml:lang attribute. If there is no such ancestor, then the function returns false Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.lang|fn.lang} + * @method planBuilder.fn#lang + * @since 2.1.1 + * @param { XsString } [testlang] - The language against which to test the node. + * @param { Node } [node] - The node to test. + * @returns { XsBoolean } + */ +lang(...args) { + const namer = bldrbase.getNamer(args, 'testlang'); + const paramdefs = [['testlang', [types.XsString, PlanColumn, PlanParam], false, false], ['node', [types.Node, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.lang', 2, new Set(['testlang', 'node']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.lang', 2, false, paramdefs, args); + return new types.XsBoolean('fn', 'lang', checkedArgs); + + } +/** + * Returns the local part of the name of arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.localName|fn.localName} + * @method planBuilder.fn#localName + * @since 2.1.1 + * @param { Node } [arg] - The node whose local name is to be returned. + * @returns { XsString } + */ +localName(...args) { + const paramdef = ['arg', [types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.localName', 1, paramdef, args); + return new types.XsString('fn', 'local-name', checkedArgs); + } +/** + * Returns an xs:NCName representing the local part of arg. If arg is the empty sequence, returns the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.localNameFromQName|fn.localNameFromQName} + * @method planBuilder.fn#localNameFromQName + * @since 2.1.1 + * @param { XsQName } [arg] - A qualified name. + * @returns { XsNCName } + */ +localNameFromQName(...args) { + const paramdef = ['arg', [types.XsQName, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.localNameFromQName', 1, paramdef, args); + return new types.XsNCName('fn', 'local-name-from-QName', checkedArgs); + } +/** + * Returns the specified string converting all of the characters to lower-case characters. If a character does not have a corresponding lower-case character, then the original character is returned. The lower-case characters are determined using the Unicode Case Mappings. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.lowerCase|fn.lowerCase} + * @method planBuilder.fn#lowerCase + * @since 2.1.1 + * @param { XsString } [string] - The string to convert. + * @returns { XsString } + */ +lowerCase(...args) { + const paramdef = ['string', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.lowerCase', 1, paramdef, args); + return new types.XsString('fn', 'lower-case', checkedArgs); + } +/** + * Returns true if the specified input matches the specified pattern, otherwise returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.matches|fn.matches} + * @method planBuilder.fn#matches + * @since 2.1.1 + * @param { XsString } [input] - The input from which to match. + * @param { XsString } [pattern] - The regular expression to match. + * @param { XsString } [flags] - The flag representing how to interpret the regular expression. One of "s", "m", "i", or "x", as defined in http://www.w3.org/TR/xpath-functions/#flags. + * @returns { XsBoolean } + */ +matches(...args) { + const namer = bldrbase.getNamer(args, 'input'); + const paramdefs = [['input', [types.XsString, PlanColumn, PlanParam], false, false], ['pattern', [types.XsString, PlanColumn, PlanParam], true, false], ['flags', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.matches', 2, new Set(['input', 'pattern', 'flags']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.matches', 2, false, paramdefs, args); + return new types.XsBoolean('fn', 'matches', checkedArgs); + + } +/** + * Selects an item from the input sequence arg whose value is greater than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.max|fn.max} + * @method planBuilder.fn#max + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg] - The sequence of values whose maximum will be returned. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsAnyAtomicType } + */ +max(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, true], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.max', 1, new Set(['arg', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.max', 1, false, paramdefs, args); + return new types.XsAnyAtomicType('fn', 'max', checkedArgs); + + } +/** + * Selects an item from the input sequence arg whose value is less than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.min|fn.min} + * @method planBuilder.fn#min + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg] - The sequence of values whose minimum will be returned. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsAnyAtomicType } + */ +min(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, true], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.min', 1, new Set(['arg', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.min', 1, false, paramdefs, args); + return new types.XsAnyAtomicType('fn', 'min', checkedArgs); + + } +/** + * Returns an xs:integer value between 0 and 59, both inclusive, representing the minute component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.minutesFromDateTime|fn.minutesFromDateTime} + * @method planBuilder.fn#minutesFromDateTime + * @since 2.1.1 + * @param { XsDateTime } [arg] - The dateTime whose minutes component will be returned. + * @returns { XsInteger } + */ +minutesFromDateTime(...args) { + const paramdef = ['arg', [types.XsDateTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.minutesFromDateTime', 1, paramdef, args); + return new types.XsInteger('fn', 'minutes-from-dateTime', checkedArgs); + } +/** + * Returns an xs:integer representing the minutes component in the canonical lexical representation of the value of arg. The result may be negative. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.minutesFromDuration|fn.minutesFromDuration} + * @method planBuilder.fn#minutesFromDuration + * @since 2.1.1 + * @param { XsDuration } [arg] - The duration whose minute component will be returned. + * @returns { XsInteger } + */ +minutesFromDuration(...args) { + const paramdef = ['arg', [types.XsDuration, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.minutesFromDuration', 1, paramdef, args); + return new types.XsInteger('fn', 'minutes-from-duration', checkedArgs); + } +/** + * Returns an xs:integer value between 0 to 59, both inclusive, representing the value of the minutes component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.minutesFromTime|fn.minutesFromTime} + * @method planBuilder.fn#minutesFromTime + * @since 2.1.1 + * @param { XsTime } [arg] - The time whose minutes component will be returned. + * @returns { XsInteger } + */ +minutesFromTime(...args) { + const paramdef = ['arg', [types.XsTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.minutesFromTime', 1, paramdef, args); + return new types.XsInteger('fn', 'minutes-from-time', checkedArgs); + } +/** + * Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.monthFromDate|fn.monthFromDate} + * @method planBuilder.fn#monthFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose month component will be returned. + * @returns { XsInteger } + */ +monthFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.monthFromDate', 1, paramdef, args); + return new types.XsInteger('fn', 'month-from-date', checkedArgs); + } +/** + * Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.monthFromDateTime|fn.monthFromDateTime} + * @method planBuilder.fn#monthFromDateTime + * @since 2.1.1 + * @param { XsDateTime } [arg] - The dateTime whose month component will be returned. + * @returns { XsInteger } + */ +monthFromDateTime(...args) { + const paramdef = ['arg', [types.XsDateTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.monthFromDateTime', 1, paramdef, args); + return new types.XsInteger('fn', 'month-from-dateTime', checkedArgs); + } +/** + * Returns an xs:integer representing the months component in the canonical lexical representation of the value of arg. The result may be negative. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.monthsFromDuration|fn.monthsFromDuration} + * @method planBuilder.fn#monthsFromDuration + * @since 2.1.1 + * @param { XsDuration } [arg] - The duration whose month component will be returned. + * @returns { XsInteger } + */ +monthsFromDuration(...args) { + const paramdef = ['arg', [types.XsDuration, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.monthsFromDuration', 1, paramdef, args); + return new types.XsInteger('fn', 'months-from-duration', checkedArgs); + } +/** + * Returns the name of a node, as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.name|fn.name} + * @method planBuilder.fn#name + * @since 2.1.1 + * @param { Node } [arg] - The node whose name is to be returned. + * @returns { XsString } + */ +name(...args) { + const paramdef = ['arg', [types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.name', 1, paramdef, args); + return new types.XsString('fn', 'name', checkedArgs); + } +/** + * Returns the namespace URI of the xs:QName of the node specified by arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.namespaceUri|fn.namespaceUri} + * @method planBuilder.fn#namespaceUri + * @since 2.1.1 + * @param { Node } [arg] - The node whose namespace URI is to be returned. + * @returns { XsAnyURI } + */ +namespaceUri(...args) { + const paramdef = ['arg', [types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.namespaceUri', 1, paramdef, args); + return new types.XsAnyURI('fn', 'namespace-uri', checkedArgs); + } +/** + * Returns the namespace URI of one of the in-scope namespaces for element, identified by its namespace prefix. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.namespaceUriForPrefix|fn.namespaceUriForPrefix} + * @method planBuilder.fn#namespaceUriForPrefix + * @since 2.1.1 + * @param { XsString } [prefix] - A namespace prefix to look up. + * @param { ElementNode } [element] - An element node providing namespace context. + * @returns { XsAnyURI } + */ +namespaceUriForPrefix(...args) { + const namer = bldrbase.getNamer(args, 'prefix'); + const paramdefs = [['prefix', [types.XsString, PlanColumn, PlanParam], false, false], ['element', [types.ElementNode, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.namespaceUriForPrefix', 2, new Set(['prefix', 'element']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.namespaceUriForPrefix', 2, false, paramdefs, args); + return new types.XsAnyURI('fn', 'namespace-uri-for-prefix', checkedArgs); + + } +/** + * Returns the namespace URI for arg as an xs:string. If arg is the empty sequence, the empty sequence is returned. If arg is in no namespace, the zero-length string is returned. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.namespaceUriFromQName|fn.namespaceUriFromQName} + * @method planBuilder.fn#namespaceUriFromQName + * @since 2.1.1 + * @param { XsQName } [arg] - A qualified name. + * @returns { XsAnyURI } + */ +namespaceUriFromQName(...args) { + const paramdef = ['arg', [types.XsQName, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.namespaceUriFromQName', 1, paramdef, args); + return new types.XsAnyURI('fn', 'namespace-uri-from-QName', checkedArgs); + } +/** + * Summary: Returns an xs:boolean indicating whether the argument node is "nilled". If the argument is not an element node, returns the empty sequence. If the argument is the empty sequence, returns the empty sequence. For element nodes, true() is returned if the element is nilled, otherwise false(). Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.nilled|fn.nilled} + * @method planBuilder.fn#nilled + * @since 2.1.1 + * @param { Node } [arg] - The node to test for nilled status. + * @returns { XsBoolean } + */ +nilled(...args) { + const paramdef = ['arg', [types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.nilled', 1, paramdef, args); + return new types.XsBoolean('fn', 'nilled', checkedArgs); + } +/** + * Returns an expanded-QName for node kinds that can have names. For other kinds of nodes it returns the empty sequence. If arg is the empty sequence, the empty sequence is returned. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.nodeName|fn.nodeName} + * @method planBuilder.fn#nodeName + * @since 2.1.1 + * @param { Node } [arg] - The node whose name is to be returned. + * @returns { XsQName } + */ +nodeName(...args) { + const paramdef = ['arg', [types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.nodeName', 1, paramdef, args); + return new types.XsQName('fn', 'node-name', checkedArgs); + } +/** + * Returns the specified string with normalized whitespace, which strips off any leading or trailing whitespace and replaces any other sequences of more than one whitespace characters with a single space character (#x20). Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.normalizeSpace|fn.normalizeSpace} + * @method planBuilder.fn#normalizeSpace + * @since 2.1.1 + * @param { XsString } [input] - The string from which to normalize whitespace. + * @returns { XsString } + */ +normalizeSpace(...args) { + const paramdef = ['input', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.normalizeSpace', 1, paramdef, args); + return new types.XsString('fn', 'normalize-space', checkedArgs); + } +/** + * Return the argument normalized according to the normalization criteria for a normalization form identified by the value of normalizationForm. The effective value of the normalizationForm is computed by removing leading and trailing blanks, if present, and converting to upper case. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.normalizeUnicode|fn.normalizeUnicode} + * @method planBuilder.fn#normalizeUnicode + * @since 2.1.1 + * @param { XsString } [arg] - The string to normalize. + * @param { XsString } [normalizationForm] - The form under which to normalize the specified string: NFC, NFD, NFKC, or NFKD. + * @returns { XsString } + */ +normalizeUnicode(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsString, PlanColumn, PlanParam], false, false], ['normalizationForm', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.normalizeUnicode', 1, new Set(['arg', 'normalizationForm']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.normalizeUnicode', 1, false, paramdefs, args); + return new types.XsString('fn', 'normalize-unicode', checkedArgs); + + } +/** + * Returns true if the effective boolean value is false, and false if the effective boolean value is true. The arg parameter is first reduced to an effective boolean value by applying the fn:boolean function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.not|fn.not} + * @method planBuilder.fn#not + * @since 2.1.1 + * @param { Item } [arg] - The expression to negate. + * @returns { XsBoolean } + */ +not(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.not', 1, paramdef, args); + return new types.XsBoolean('fn', 'not', checkedArgs); + } +/** + * Returns the value indicated by arg or, if arg is not specified, the context item after atomization, converted to an xs:double. If arg is the empty sequence or if arg or the context item cannot be converted to an xs:double, the xs:double value NaN is returned. If the context item is undefined an error is raised: [err:XPDY0002]. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.number|fn.number} + * @method planBuilder.fn#number + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg] - The value to be returned as an xs:double value. + * @returns { XsDouble } + */ +number(...args) { + const paramdef = ['arg', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.number', 1, paramdef, args); + return new types.XsDouble('fn', 'number', checkedArgs); + } +/** + * Returns an xs:NCName representing the prefix of arg. The empty sequence is returned if arg is the empty sequence or if the value of arg contains no prefix. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.prefixFromQName|fn.prefixFromQName} + * @method planBuilder.fn#prefixFromQName + * @since 2.1.1 + * @param { XsQName } [arg] - A qualified name. + * @returns { XsNCName } + */ +prefixFromQName(...args) { + const paramdef = ['arg', [types.XsQName, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.prefixFromQName', 1, paramdef, args); + return new types.XsNCName('fn', 'prefix-from-QName', checkedArgs); + } +/** + * Returns an xs:QName with the namespace URI given in paramURI. If paramURI is the zero-length string or the empty sequence, it represents "no namespace"; in this case, if the value of paramQName contains a colon (:), an error is raised [err:FOCA0002]. The prefix (or absence of a prefix) in paramQName is retained in the returned xs:QName value. The local name in the result is taken from the local part of paramQName. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.QName|fn.QName} + * @method planBuilder.fn#QName + * @since 2.1.1 + * @param { XsString } [paramURI] - A namespace URI, as a string. + * @param { XsString } [paramQName] - A lexical qualified name (xs:QName), a string of the form "prefix:localname" or "localname". + * @returns { XsQName } + */ +QName(...args) { + const namer = bldrbase.getNamer(args, 'paramURI'); + const paramdefs = [['paramURI', [types.XsString, PlanColumn, PlanParam], false, false], ['paramQName', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.QName', 2, new Set(['paramURI', 'paramQName']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.QName', 2, false, paramdefs, args); + return new types.XsQName('fn', 'QName', checkedArgs); + + } +/** + * Returns a new sequence constructed from the value of target with the item at the position specified by the value of position removed. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.remove|fn.remove} + * @method planBuilder.fn#remove + * @since 2.1.1 + * @param { Item } [target] - The sequence of items from which items will be removed. + * @param { XsInteger } [position] - The position in the target sequence from which the items will be removed. + * @returns { Item } + */ +remove(...args) { + const namer = bldrbase.getNamer(args, 'target'); + const paramdefs = [['target', [types.Item, PlanColumn, PlanParam], false, true], ['position', [types.XsInteger, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.remove', 2, new Set(['target', 'position']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.remove', 2, false, paramdefs, args); + return new types.Item('fn', 'remove', checkedArgs); + + } +/** + * Returns a string constructed by replacing the specified pattern on the input string with the specified replacement string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.replace|fn.replace} + * @method planBuilder.fn#replace + * @since 2.1.1 + * @param { XsString } [input] - The string to start with. + * @param { XsString } [pattern] - The regular expression pattern to match. If the pattern does not match the $input string, the function will return the $input string unchanged. + * @param { XsString } [replacement] - The regular expression pattern to replace the $pattern with. It can also be a capture expression (for more details, see http://www.w3.org/TR/xpath-functions/#func-replace). + * @param { XsString } [flags] - The flag representing how to interpret the regular expression. One of "s", "m", "i", or "x", as defined in http://www.w3.org/TR/xpath-functions/#flags. + * @returns { XsString } + */ +replace(...args) { + const namer = bldrbase.getNamer(args, 'input'); + const paramdefs = [['input', [types.XsString, PlanColumn, PlanParam], false, false], ['pattern', [types.XsString, PlanColumn, PlanParam], true, false], ['replacement', [types.XsString, PlanColumn, PlanParam], true, false], ['flags', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.replace', 3, new Set(['input', 'pattern', 'replacement', 'flags']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.replace', 3, false, paramdefs, args); + return new types.XsString('fn', 'replace', checkedArgs); + + } +/** + * Returns an xs:QName value (that is, an expanded QName) by taking an xs:string that has the lexical form of an xs:QName (a string in the form "prefix:local-name" or "local-name") and resolving it using the in-scope namespaces for a given element. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.resolveQName|fn.resolveQName} + * @method planBuilder.fn#resolveQName + * @since 2.1.1 + * @param { XsString } [qname] - A string of the form "prefix:local-name". + * @param { ElementNode } [element] - An element providing the in-scope namespaces to use to resolve the qualified name. + * @returns { XsQName } + */ +resolveQName(...args) { + const namer = bldrbase.getNamer(args, 'qname'); + const paramdefs = [['qname', [types.XsString, PlanColumn, PlanParam], false, false], ['element', [types.ElementNode, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.resolveQName', 2, new Set(['qname', 'element']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.resolveQName', 2, false, paramdefs, args); + return new types.XsQName('fn', 'resolve-QName', checkedArgs); + + } +/** + * Resolves a relative URI against an absolute URI. If base is specified, the URI is resolved relative to that base. If base is not specified, the base is set to the base-uri property from the static context, if the property exists; if it does not exist, an error is thrown. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.resolveUri|fn.resolveUri} + * @method planBuilder.fn#resolveUri + * @since 2.1.1 + * @param { XsString } [relative] - A URI reference to resolve against the base. + * @param { XsString } [base] - An absolute URI to use as the base of the resolution. + * @returns { XsAnyURI } + */ +resolveUri(...args) { + const namer = bldrbase.getNamer(args, 'relative'); + const paramdefs = [['relative', [types.XsString, PlanColumn, PlanParam], false, false], ['base', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.resolveUri', 2, new Set(['relative', 'base']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.resolveUri', 2, false, paramdefs, args); + return new types.XsAnyURI('fn', 'resolve-uri', checkedArgs); + + } +/** + * Reverses the order of items in a sequence. If arg is the empty sequence, the empty sequence is returned. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.reverse|fn.reverse} + * @method planBuilder.fn#reverse + * @since 2.1.1 + * @param { Item } [target] - The sequence of items to be reversed. + * @returns { Item } + */ +reverse(...args) { + const paramdef = ['target', [types.Item, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.reverse', 1, paramdef, args); + return new types.Item('fn', 'reverse', checkedArgs); + } +/** + * Returns the root of the tree to which arg belongs. This will usually, but not necessarily, be a document node. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.root|fn.root} + * @method planBuilder.fn#root + * @since 2.1.1 + * @param { Node } [arg] - The node whose root node will be returned. + * @returns { Node } + */ +root(...args) { + const paramdef = ['arg', [types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.root', 1, paramdef, args); + return new types.Node('fn', 'root', checkedArgs); + } +/** + * Returns the number with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. If type of arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of arg. If the type of arg is a type derived from one of the numeric types, the result is an instance of the base numeric type. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.round|fn.round} + * @method planBuilder.fn#round + * @since 2.1.1 + * @param { XsNumeric } [arg] - A numeric value to round. + * @returns { XsNumeric } + */ +round(...args) { + const paramdef = ['arg', [types.XsNumeric, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.round', 1, paramdef, args); + return new types.XsNumeric('fn', 'round', checkedArgs); + } +/** + * The value returned is the nearest (that is, numerically closest) numeric to arg that is a multiple of ten to the power of minus precision. If two such values are equally near (e.g. if the fractional part in arg is exactly .500...), returns the one whose least significant digit is even. If type of arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of arg. If the type of arg is a type derived from one of the numeric types, the result is an instance of the base numeric type. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.roundHalfToEven|fn.roundHalfToEven} + * @method planBuilder.fn#roundHalfToEven + * @since 2.1.1 + * @param { XsNumeric } [arg] - A numeric value to round. + * @param { XsInteger } [precision] - The precision to which to round the value. + * @returns { XsNumeric } + */ +roundHalfToEven(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsNumeric, PlanColumn, PlanParam], false, false], ['precision', [types.XsInteger, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.roundHalfToEven', 1, new Set(['arg', 'precision']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.roundHalfToEven', 1, false, paramdefs, args); + return new types.XsNumeric('fn', 'round-half-to-even', checkedArgs); + + } +/** + * Returns an xs:decimal value between 0 and 60.999..., both inclusive representing the seconds and fractional seconds in the localized value of arg. Note that the value can be greater than 60 seconds to accommodate occasional leap seconds used to keep human time synchronized with the rotation of the planet. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.secondsFromDateTime|fn.secondsFromDateTime} + * @method planBuilder.fn#secondsFromDateTime + * @since 2.1.1 + * @param { XsDateTime } [arg] - The dateTime whose seconds component will be returned. + * @returns { XsDecimal } + */ +secondsFromDateTime(...args) { + const paramdef = ['arg', [types.XsDateTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.secondsFromDateTime', 1, paramdef, args); + return new types.XsDecimal('fn', 'seconds-from-dateTime', checkedArgs); + } +/** + * Returns an xs:decimal representing the seconds component in the canonical lexical representation of the value of arg. The result may be negative. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.secondsFromDuration|fn.secondsFromDuration} + * @method planBuilder.fn#secondsFromDuration + * @since 2.1.1 + * @param { XsDuration } [arg] - The duration whose minute component will be returned. + * @returns { XsDecimal } + */ +secondsFromDuration(...args) { + const paramdef = ['arg', [types.XsDuration, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.secondsFromDuration', 1, paramdef, args); + return new types.XsDecimal('fn', 'seconds-from-duration', checkedArgs); + } +/** + * Returns an xs:decimal value between 0 and 60.999..., both inclusive, representing the seconds and fractional seconds in the localized value of arg. Note that the value can be greater than 60 seconds to accommodate occasional leap seconds used to keep human time synchronized with the rotation of the planet. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.secondsFromTime|fn.secondsFromTime} + * @method planBuilder.fn#secondsFromTime + * @since 2.1.1 + * @param { XsTime } [arg] - The time whose seconds component will be returned. + * @returns { XsDecimal } + */ +secondsFromTime(...args) { + const paramdef = ['arg', [types.XsTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.secondsFromTime', 1, paramdef, args); + return new types.XsDecimal('fn', 'seconds-from-time', checkedArgs); + } +/** + * Returns true if the first parameter starts with the string from the second parameter, otherwise returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.startsWith|fn.startsWith} + * @method planBuilder.fn#startsWith + * @since 2.1.1 + * @param { XsString } [parameter1] - The string from which to test. + * @param { XsString } [parameter2] - The string to test whether it is at the beginning of the first parameter. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsBoolean } + */ +startsWith(...args) { + const namer = bldrbase.getNamer(args, 'parameter1'); + const paramdefs = [['parameter1', [types.XsString, PlanColumn, PlanParam], false, false], ['parameter2', [types.XsString, PlanColumn, PlanParam], false, false], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.startsWith', 2, new Set(['parameter1', 'parameter2', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.startsWith', 2, false, paramdefs, args); + return new types.XsBoolean('fn', 'starts-with', checkedArgs); + + } +/** + * Returns the value of arg represented as an xs:string. If no argument is supplied, this function returns the string value of the context item (.). Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.string|fn.string} + * @method planBuilder.fn#string + * @since 2.1.1 + * @param { Item } [arg] - The item to be rendered as a string. + * @returns { XsString } + */ +string(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.string', 1, paramdef, args); + return new types.XsString('fn', 'string', checkedArgs); + } +/** + * Returns an xs:string created by concatenating the members of the parameter1 sequence using parameter2 as a separator. If the value of arg2 is the zero-length string, then the members of parameter1 are concatenated without a separator. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.stringJoin|fn.stringJoin} + * @method planBuilder.fn#stringJoin + * @since 2.1.1 + * @param { XsString } [parameter1] - A sequence of strings. + * @param { XsString } [parameter2] - A separator string to concatenate between the items in $parameter1. + * @returns { XsString } + */ +stringJoin(...args) { + const namer = bldrbase.getNamer(args, 'parameter1'); + const paramdefs = [['parameter1', [types.XsString, PlanColumn, PlanParam], false, true], ['parameter2', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.stringJoin', 2, new Set(['parameter1', 'parameter2']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.stringJoin', 2, false, paramdefs, args); + return new types.XsString('fn', 'string-join', checkedArgs); + + } +/** + * Returns an integer representing the length of the specified string. The length is 1-based, so a string that is one character long returns a value of 1. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.stringLength|fn.stringLength} + * @method planBuilder.fn#stringLength + * @since 2.1.1 + * @param { XsString } [sourceString] - The string to calculate the length. + * @returns { XsInteger } + */ +stringLength(...args) { + const paramdef = ['sourceString', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.stringLength', 1, paramdef, args); + return new types.XsInteger('fn', 'string-length', checkedArgs); + } +/** + * Returns the sequence of Unicode code points that constitute an xs:string. If arg is a zero-length string or the empty sequence, the empty sequence is returned. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.stringToCodepoints|fn.stringToCodepoints} + * @method planBuilder.fn#stringToCodepoints + * @since 2.1.1 + * @param { XsString } [arg] - A string. + * @returns { XsInteger } + */ +stringToCodepoints(...args) { + const paramdef = ['arg', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.stringToCodepoints', 1, paramdef, args); + return new types.XsInteger('fn', 'string-to-codepoints', checkedArgs); + } +/** + * Returns the contiguous sequence of items in the value of sourceSeq beginning at the position indicated by the value of startingLoc and continuing for the number of items indicated by the value of length. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.subsequence|fn.subsequence} + * @method planBuilder.fn#subsequence + * @since 2.1.1 + * @param { Item } [sourceSeq] - The sequence of items from which a subsequence will be selected. + * @param { XsNumeric } [startingLoc] - The starting position of the start of the subsequence. + * @param { XsNumeric } [length] - The length of the subsequence. + * @returns { Item } + */ +subsequence(...args) { + const namer = bldrbase.getNamer(args, 'sourceSeq'); + const paramdefs = [['sourceSeq', [types.Item, PlanColumn, PlanParam], false, true], ['startingLoc', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['length', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.subsequence', 2, new Set(['sourceSeq', 'startingLoc', 'length']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.subsequence', 2, false, paramdefs, args); + return new types.Item('fn', 'subsequence', checkedArgs); + + } +/** + * Returns a substring starting from the startingLoc and continuing for length characters. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.substring|fn.substring} + * @method planBuilder.fn#substring + * @since 2.1.1 + * @param { XsString } [sourceString] - The string from which to create a substring. + * @param { XsNumeric } [startingLoc] - The number of characters from the start of the $sourceString. + * @param { XsNumeric } [length] - The number of characters beyond the $startingLoc. + * @returns { XsString } + */ +substring(...args) { + const namer = bldrbase.getNamer(args, 'sourceString'); + const paramdefs = [['sourceString', [types.XsString, PlanColumn, PlanParam], false, false], ['startingLoc', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['length', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.substring', 2, new Set(['sourceString', 'startingLoc', 'length']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.substring', 2, false, paramdefs, args); + return new types.XsString('fn', 'substring', checkedArgs); + + } +/** + * Returns the substring created by taking all of the input characters that occur after the specified after characters. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.substringAfter|fn.substringAfter} + * @method planBuilder.fn#substringAfter + * @since 2.1.1 + * @param { XsString } [input] - The string from which to create the substring. + * @param { XsString } [after] - The string after which the substring is created. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsString } + */ +substringAfter(...args) { + const namer = bldrbase.getNamer(args, 'input'); + const paramdefs = [['input', [types.XsString, PlanColumn, PlanParam], false, false], ['after', [types.XsString, PlanColumn, PlanParam], false, false], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.substringAfter', 2, new Set(['input', 'after', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.substringAfter', 2, false, paramdefs, args); + return new types.XsString('fn', 'substring-after', checkedArgs); + + } +/** + * Returns the substring created by taking all of the input characters that occur before the specified before characters. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.substringBefore|fn.substringBefore} + * @method planBuilder.fn#substringBefore + * @since 2.1.1 + * @param { XsString } [input] - The string from which to create the substring. + * @param { XsString } [before] - The string before which the substring is created. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsString } + */ +substringBefore(...args) { + const namer = bldrbase.getNamer(args, 'input'); + const paramdefs = [['input', [types.XsString, PlanColumn, PlanParam], false, false], ['before', [types.XsString, PlanColumn, PlanParam], false, false], ['collation', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.substringBefore', 2, new Set(['input', 'before', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.substringBefore', 2, false, paramdefs, args); + return new types.XsString('fn', 'substring-before', checkedArgs); + + } +/** + * Returns a value obtained by adding together the values in arg. If zero is not specified, then the value returned for an empty sequence is the xs:integer value 0. If zero is specified, then the value returned for an empty sequence is zero. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.sum|fn.sum} + * @method planBuilder.fn#sum + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg] - The sequence of values to be summed. + * @param { XsAnyAtomicType } [zero] - The value to return as zero if the input sequence is the empty sequence. This parameter is not available in the 0.9-ml XQuery dialect. + * @returns { XsAnyAtomicType } + */ +sum(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, true], ['zero', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.sum', 1, new Set(['arg', 'zero']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.sum', 1, false, paramdefs, args); + return new types.XsAnyAtomicType('fn', 'sum', checkedArgs); + + } +/** + * Returns all but the first item in a sequence. For more details, see XPath 3.0 Functions and Operators. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.tail|fn.tail} + * @method planBuilder.fn#tail + * @since 2.1.1 + * @param { Item } [seq] - The function value. + * @returns { Item } + */ +tail(...args) { + const paramdef = ['seq', [types.Item, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.tail', 1, paramdef, args); + return new types.Item('fn', 'tail', checkedArgs); + } +/** + * Returns the timezone component of arg if any. If arg has a timezone component, then the result is an xs:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.timezoneFromDate|fn.timezoneFromDate} + * @method planBuilder.fn#timezoneFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose timezone component will be returned. + * @returns { XsDayTimeDuration } + */ +timezoneFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.timezoneFromDate', 1, paramdef, args); + return new types.XsDayTimeDuration('fn', 'timezone-from-date', checkedArgs); + } +/** + * Returns the timezone component of arg if any. If arg has a timezone component, then the result is an xs:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.timezoneFromDateTime|fn.timezoneFromDateTime} + * @method planBuilder.fn#timezoneFromDateTime + * @since 2.1.1 + * @param { XsDateTime } [arg] - The dateTime whose timezone component will be returned. + * @returns { XsDayTimeDuration } + */ +timezoneFromDateTime(...args) { + const paramdef = ['arg', [types.XsDateTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.timezoneFromDateTime', 1, paramdef, args); + return new types.XsDayTimeDuration('fn', 'timezone-from-dateTime', checkedArgs); + } +/** + * Returns the timezone component of arg if any. If arg has a timezone component, then the result is an xs:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.timezoneFromTime|fn.timezoneFromTime} + * @method planBuilder.fn#timezoneFromTime + * @since 2.1.1 + * @param { XsTime } [arg] - The time whose timezone component will be returned. + * @returns { XsDayTimeDuration } + */ +timezoneFromTime(...args) { + const paramdef = ['arg', [types.XsTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.timezoneFromTime', 1, paramdef, args); + return new types.XsDayTimeDuration('fn', 'timezone-from-time', checkedArgs); + } +/** + * Returns a sequence of strings contructed by breaking the specified input into substrings separated by the specified pattern. The specified pattern is not returned as part of the returned items. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.tokenize|fn.tokenize} + * @method planBuilder.fn#tokenize + * @since 2.1.1 + * @param { XsString } [input] - The string to tokenize. + * @param { XsString } [pattern] - The regular expression pattern from which to separate the tokens. + * @param { XsString } [flags] - The flag representing how to interpret the regular expression. One of "s", "m", "i", or "x", as defined in http://www.w3.org/TR/xpath-functions/#flags. + * @returns { XsString } + */ +tokenize(...args) { + const namer = bldrbase.getNamer(args, 'input'); + const paramdefs = [['input', [types.XsString, PlanColumn, PlanParam], false, false], ['pattern', [types.XsString, PlanColumn, PlanParam], true, false], ['flags', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.tokenize', 2, new Set(['input', 'pattern', 'flags']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.tokenize', 2, false, paramdefs, args); + return new types.XsString('fn', 'tokenize', checkedArgs); + + } +/** + * Returns a string where every character in src that occurs in some position in the mapString is translated into the transString character in the corresponding location of the mapString character. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.translate|fn.translate} + * @method planBuilder.fn#translate + * @since 2.1.1 + * @param { XsString } [src] - The string to translate characters. + * @param { XsString } [mapString] - The string representing characters to be translated. + * @param { XsString } [transString] - The string representing the characters to which the $mapString characters are translated. + * @returns { XsString } + */ +translate(...args) { + const namer = bldrbase.getNamer(args, 'src'); + const paramdefs = [['src', [types.XsString, PlanColumn, PlanParam], false, false], ['mapString', [types.XsString, PlanColumn, PlanParam], true, false], ['transString', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'fn.translate', 3, new Set(['src', 'mapString', 'transString']), paramdefs, args) : + bldrbase.makePositionalArgs('fn.translate', 3, false, paramdefs, args); + return new types.XsString('fn', 'translate', checkedArgs); + + } +/** + * Returns the xs:boolean value true. Equivalent to xs:boolean("1"). Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.true|fn.true} + * @method planBuilder.fn#true + * @since 2.1.1 + + * @returns { XsBoolean } + */ +true(...args) { + bldrbase.checkMaxArity('fn.true', args.length, 0); + return new types.XsBoolean('fn', 'true', args); + } +/** + * Returns the items of sourceSeq in an implementation dependent order. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.unordered|fn.unordered} + * @method planBuilder.fn#unordered + * @since 2.1.1 + * @param { Item } [sourceSeq] - The sequence of items. + * @returns { Item } + */ +unordered(...args) { + const paramdef = ['sourceSeq', [types.Item, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('fn.unordered', 1, paramdef, args); + return new types.Item('fn', 'unordered', checkedArgs); + } +/** + * Returns the specified string converting all of the characters to upper-case characters. If a character does not have a corresponding upper-case character, then the original character is returned. The upper-case characters are determined using the Unicode Case Mappings. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.upperCase|fn.upperCase} + * @method planBuilder.fn#upperCase + * @since 2.1.1 + * @param { XsString } [string] - The string to upper-case. + * @returns { XsString } + */ +upperCase(...args) { + const paramdef = ['string', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.upperCase', 1, paramdef, args); + return new types.XsString('fn', 'upper-case', checkedArgs); + } +/** + * Returns an xs:integer representing the year component in the localized value of arg. The result may be negative. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.yearFromDate|fn.yearFromDate} + * @method planBuilder.fn#yearFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose year component will be returned. + * @returns { XsInteger } + */ +yearFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.yearFromDate', 1, paramdef, args); + return new types.XsInteger('fn', 'year-from-date', checkedArgs); + } +/** + * Returns an xs:integer representing the year component in the localized value of arg. The result may be negative. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.yearFromDateTime|fn.yearFromDateTime} + * @method planBuilder.fn#yearFromDateTime + * @since 2.1.1 + * @param { XsDateTime } [arg] - The dateTime whose year component will be returned. + * @returns { XsInteger } + */ +yearFromDateTime(...args) { + const paramdef = ['arg', [types.XsDateTime, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.yearFromDateTime', 1, paramdef, args); + return new types.XsInteger('fn', 'year-from-dateTime', checkedArgs); + } +/** + * Returns an xs:integer representing the years component in the canonical lexical representation of the value of arg. The result may be negative. Provides a client interface to a server function. See {@link http://docs.marklogic.com/fn.yearsFromDuration|fn.yearsFromDuration} + * @method planBuilder.fn#yearsFromDuration + * @since 2.1.1 + * @param { XsDuration } [arg] - The duration whose year component will be returned. + * @returns { XsInteger } + */ +yearsFromDuration(...args) { + const paramdef = ['arg', [types.XsDuration, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('fn.yearsFromDuration', 1, paramdef, args); + return new types.XsInteger('fn', 'years-from-duration', checkedArgs); + } +} +class JsonExpr { + constructor() { + } + /** + * Creates a (JSON) array, which is like a sequence of values, but allows for nesting. Provides a client interface to a server function. See {@link http://docs.marklogic.com/json.array|json.array} + * @method planBuilder.json#array + * @since 2.1.1 + * @param { ElementNode } [array] - A serialized array element. + * @returns { JsonArray } + */ +array(...args) { + const paramdef = ['array', [types.ElementNode, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('json.array', 0, paramdef, args); + return new types.JsonArray('json', 'array', checkedArgs); + } +/** + * Returns the size of the array. Provides a client interface to a server function. See {@link http://docs.marklogic.com/json.arraySize|json.arraySize} + * @method planBuilder.json#arraySize + * @since 2.1.1 + * @param { JsonArray } [array] - An array. + * @returns { XsUnsignedLong } + */ +arraySize(...args) { + const paramdef = ['array', [types.JsonArray, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('json.arraySize', 1, paramdef, args); + return new types.XsUnsignedLong('json', 'array-size', checkedArgs); + } +/** + * Returns the array values as an XQuery sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/json.arrayValues|json.arrayValues} + * @method planBuilder.json#arrayValues + * @since 2.1.1 + * @param { JsonArray } [array] - An array. + * @param { XsBoolean } [flatten] - Include values from subarrays in the sequence. The default is false, meaning that subarrays are returned as array values. + * @returns { Item } + */ +arrayValues(...args) { + const namer = bldrbase.getNamer(args, 'array'); + const paramdefs = [['array', [types.JsonArray, PlanColumn, PlanParam], true, false], ['flatten', [types.XsBoolean, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'json.arrayValues', 1, new Set(['array', 'flatten']), paramdefs, args) : + bldrbase.makePositionalArgs('json.arrayValues', 1, false, paramdefs, args); + return new types.Item('json', 'array-values', checkedArgs); + + } +/** + * Creates a JSON object, which is a kind of map with a fixed and ordered set of keys. Provides a client interface to a server function. See {@link http://docs.marklogic.com/json.object|json.object} + * @method planBuilder.json#object + * @since 2.1.1 + * @param { ElementNode } [map] - A serialized JSON object. + * @returns { JsonObject } + */ +object(...args) { + const paramdef = ['map', [types.ElementNode, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('json.object', 0, paramdef, args); + return new types.JsonObject('json', 'object', checkedArgs); + } +/** + * Creates a JSON object. Provides a client interface to a server function. See {@link http://docs.marklogic.com/json.objectDefine|json.objectDefine} + * @method planBuilder.json#objectDefine + * @since 2.1.1 + * @param { XsString } [keys] - The sequence of keys in this object. + * @returns { JsonObject } + */ +objectDefine(...args) { + const paramdef = ['keys', [types.XsString, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('json.objectDefine', 0, paramdef, args); + return new types.JsonObject('json', 'object-define', checkedArgs); + } +/** + * Extract a subarray from an array, producing a new array. The second and third arguments to this function operate similarly to those of fn:subsequence for XQuery sequences. Provides a client interface to a server function. See {@link http://docs.marklogic.com/json.subarray|json.subarray} + * @method planBuilder.json#subarray + * @since 2.1.1 + * @param { JsonArray } [array] - An array. + * @param { XsNumeric } [startingLoc] - The starting position of the start of the subarray. + * @param { XsNumeric } [length] - The length of the subarray. + * @returns { JsonArray } + */ +subarray(...args) { + const namer = bldrbase.getNamer(args, 'array'); + const paramdefs = [['array', [types.JsonArray, PlanColumn, PlanParam], true, false], ['startingLoc', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['length', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'json.subarray', 2, new Set(['array', 'startingLoc', 'length']), paramdefs, args) : + bldrbase.makePositionalArgs('json.subarray', 2, false, paramdefs, args); + return new types.JsonArray('json', 'subarray', checkedArgs); + + } +/** + * Constructs an array from a sequence of items. Provides a client interface to a server function. See {@link http://docs.marklogic.com/json.toArray|json.toArray} + * @method planBuilder.json#toArray + * @since 2.1.1 + * @param { Item } [items] - A sequence of items. + * @param { XsNumeric } [limit] - The size of the array to construct. If the size is less than the length of the item sequence, only as "limit" items are put into the array. If the size is more than the length of the sequence, the array is filled with null values up to the limit. + * @param { Item } [zero] - The value to use to pad out the array, if necessary. By default the empty sequence is used. + * @returns { JsonArray } + */ +toArray(...args) { + const namer = bldrbase.getNamer(args, 'items'); + const paramdefs = [['items', [types.Item, PlanColumn, PlanParam], false, true], ['limit', [types.XsNumeric, PlanColumn, PlanParam], false, false], ['zero', [types.Item, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'json.toArray', 0, new Set(['items', 'limit', 'zero']), paramdefs, args) : + bldrbase.makePositionalArgs('json.toArray', 0, false, paramdefs, args); + return new types.JsonArray('json', 'to-array', checkedArgs); + + } +} +class MapExpr { + constructor() { + } + /** + * Returns true if the key exists in the map. Provides a client interface to a server function. See {@link http://docs.marklogic.com/map.contains|map.contains} + * @method planBuilder.map#contains + * @since 2.1.1 + * @param { MapMap } [map] - A map. + * @param { XsString } [key] - A key. + * @returns { XsBoolean } + */ +contains(...args) { + const namer = bldrbase.getNamer(args, 'map'); + const paramdefs = [['map', [types.MapMap, PlanColumn, PlanParam], true, false], ['key', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'map.contains', 2, new Set(['map', 'key']), paramdefs, args) : + bldrbase.makePositionalArgs('map.contains', 2, false, paramdefs, args); + return new types.XsBoolean('map', 'contains', checkedArgs); + + } +/** + * Returns the number of keys used in the map. Provides a client interface to a server function. See {@link http://docs.marklogic.com/map.count|map.count} + * @method planBuilder.map#count + * @since 2.1.1 + * @param { MapMap } [map] - A map. + * @returns { XsUnsignedInt } + */ +count(...args) { + const paramdef = ['map', [types.MapMap, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('map.count', 1, paramdef, args); + return new types.XsUnsignedInt('map', 'count', checkedArgs); + } +/** + * Constructs a new map with a single entry consisting of the key and value specified as arguments. This is particularly helpful when used as part of an argument to map:new(). Provides a client interface to a server function. See {@link http://docs.marklogic.com/map.entry|map.entry} + * @method planBuilder.map#entry + * @since 2.1.1 + * @param { XsString } [key] - The map key. + * @param { Item } [value] - The map value. + * @returns { MapMap } + */ +entry(...args) { + const namer = bldrbase.getNamer(args, 'key'); + const paramdefs = [['key', [types.XsString, PlanColumn, PlanParam], true, false], ['value', [types.Item, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'map.entry', 2, new Set(['key', 'value']), paramdefs, args) : + bldrbase.makePositionalArgs('map.entry', 2, false, paramdefs, args); + return new types.MapMap('map', 'entry', checkedArgs); + + } +/** + * Get a value from a map. Provides a client interface to a server function. See {@link http://docs.marklogic.com/map.get|map.get} + * @method planBuilder.map#get + * @since 2.1.1 + * @param { MapMap } [map] - A map. + * @param { XsString } [key] - A key. + * @returns { Item } + */ +get(...args) { + const namer = bldrbase.getNamer(args, 'map'); + const paramdefs = [['map', [types.MapMap, PlanColumn, PlanParam], true, false], ['key', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'map.get', 2, new Set(['map', 'key']), paramdefs, args) : + bldrbase.makePositionalArgs('map.get', 2, false, paramdefs, args); + return new types.Item('map', 'get', checkedArgs); + + } +/** + * Get the keys used in the map. Provides a client interface to a server function. See {@link http://docs.marklogic.com/map.keys|map.keys} + * @method planBuilder.map#keys + * @since 2.1.1 + * @param { MapMap } [map] - A map. + * @returns { XsString } + */ +keys(...args) { + const paramdef = ['map', [types.MapMap, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('map.keys', 1, paramdef, args); + return new types.XsString('map', 'keys', checkedArgs); + } +/** + * Creates a map. Provides a client interface to a server function. See {@link http://docs.marklogic.com/map.map|map.map} + * @method planBuilder.map#map + * @since 2.1.1 + * @param { ElementNode } [map] - A serialized map element. + * @returns { MapMap } + */ +map(...args) { + const paramdef = ['map', [types.ElementNode, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('map.map', 0, paramdef, args); + return new types.MapMap('map', 'map', checkedArgs); + } +} +class MathExpr { + constructor() { + } + /** + * Returns the arc cosine of x, in radians, in the range from 0 to pi (inclusive). Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.acos|math.acos} + * @method planBuilder.math#acos + * @since 2.1.1 + * @param { XsDouble } [x] - The fraction to be evaluated. Must be in the range of -1 to +1 (inclusive). + * @returns { XsDouble } + */ +acos(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.acos', 1, paramdef, args); + return new types.XsDouble('math', 'acos', checkedArgs); + } +/** + * Returns the arc sine of x, in radians, in the range from -pi/2 to +pi/2 (inclusive). Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.asin|math.asin} + * @method planBuilder.math#asin + * @since 2.1.1 + * @param { XsDouble } [x] - The fraction to be evaluated. Must be in the range of -1 to +1 (inclusive). + * @returns { XsDouble } + */ +asin(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.asin', 1, paramdef, args); + return new types.XsDouble('math', 'asin', checkedArgs); + } +/** + * Returns the arc tangent of x, in radians. in the range from -pi/2 to +pi/2 (inclusive). Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.atan|math.atan} + * @method planBuilder.math#atan + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +atan(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.atan', 1, paramdef, args); + return new types.XsDouble('math', 'atan', checkedArgs); + } +/** + * Returns the arc tangent of y/x, in radians, in the range from -pi/2 to +pi/2 (inclusive), using the signs of y and x to determine the apropriate quadrant. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.atan2|math.atan2} + * @method planBuilder.math#atan2 + * @since 2.1.1 + * @param { XsDouble } [y] - The floating point dividend. + * @param { XsDouble } [x] - The floating point divisor. + * @returns { XsDouble } + */ +atan2(...args) { + const namer = bldrbase.getNamer(args, 'y'); + const paramdefs = [['y', [types.XsDouble, PlanColumn, PlanParam], true, false], ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'math.atan2', 2, new Set(['y', 'x']), paramdefs, args) : + bldrbase.makePositionalArgs('math.atan2', 2, false, paramdefs, args); + return new types.XsDouble('math', 'atan2', checkedArgs); + + } +/** + * Returns the smallest integer greater than or equal to x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.ceil|math.ceil} + * @method planBuilder.math#ceil + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +ceil(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.ceil', 1, paramdef, args); + return new types.XsDouble('math', 'ceil', checkedArgs); + } +/** + * Returns the Pearson correlation coefficient of a data set. The size of the input array should be 2. The function eliminates all pairs for which either the first element or the second element is empty. After the elimination, if the length of the input is less than 2, the function returns the empty sequence. After the elimination, if the standard deviation of the first column or the standard deviation of the second column is 0, the function returns the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.correlation|math.correlation} + * @method planBuilder.math#correlation + * @since 2.1.1 + * @param { JsonArray } [arg] - The input data set. Each array should contain a pair of values. + * @returns { XsDouble } + */ +correlation(...args) { + const paramdef = ['arg', [types.JsonArray, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('math.correlation', 1, paramdef, args); + return new types.XsDouble('math', 'correlation', checkedArgs); + } +/** + * Returns the cosine of x, in the range from -1 to +1 (inclusive). Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.cos|math.cos} + * @method planBuilder.math#cos + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +cos(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.cos', 1, paramdef, args); + return new types.XsDouble('math', 'cos', checkedArgs); + } +/** + * Returns the hyperbolic cosine of x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.cosh|math.cosh} + * @method planBuilder.math#cosh + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +cosh(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.cosh', 1, paramdef, args); + return new types.XsDouble('math', 'cosh', checkedArgs); + } +/** + * Returns the cotangent of x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.cot|math.cot} + * @method planBuilder.math#cot + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +cot(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.cot', 1, paramdef, args); + return new types.XsDouble('math', 'cot', checkedArgs); + } +/** + * Returns the sample covariance of a data set. The size of the input array should be 2. The function eliminates all pairs for which either the first element or the second element is empty. After the elimination, if the length of the input is less than 2, the function returns the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.covariance|math.covariance} + * @method planBuilder.math#covariance + * @since 2.1.1 + * @param { JsonArray } [arg] - The input data set. Each array should contain a pair of values. + * @returns { XsDouble } + */ +covariance(...args) { + const paramdef = ['arg', [types.JsonArray, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('math.covariance', 1, paramdef, args); + return new types.XsDouble('math', 'covariance', checkedArgs); + } +/** + * Returns the population covariance of a data set. The size of the input array should be 2. The function eliminates all pairs for which either the first element or the second element is empty. After the elimination, if the length of the input is 0, the function returns the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.covarianceP|math.covarianceP} + * @method planBuilder.math#covarianceP + * @since 2.1.1 + * @param { JsonArray } [arg] - The input data set. Each array should contain a pair of values. + * @returns { XsDouble } + */ +covarianceP(...args) { + const paramdef = ['arg', [types.JsonArray, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('math.covarianceP', 1, paramdef, args); + return new types.XsDouble('math', 'covariance-p', checkedArgs); + } +/** + * Returns numeric expression converted from radians to degrees. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.degrees|math.degrees} + * @method planBuilder.math#degrees + * @since 2.1.1 + * @param { XsDouble } [x] - An angle expressed in radians. + * @returns { XsDouble } + */ +degrees(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.degrees', 1, paramdef, args); + return new types.XsDouble('math', 'degrees', checkedArgs); + } +/** + * Returns e (approximately 2.71828182845905) to the xth power. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.exp|math.exp} + * @method planBuilder.math#exp + * @since 2.1.1 + * @param { XsDouble } [x] - The exponent to be evaluated. + * @returns { XsDouble } + */ +exp(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.exp', 1, paramdef, args); + return new types.XsDouble('math', 'exp', checkedArgs); + } +/** + * Returns the absolute value of x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.fabs|math.fabs} + * @method planBuilder.math#fabs + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +fabs(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.fabs', 1, paramdef, args); + return new types.XsDouble('math', 'fabs', checkedArgs); + } +/** + * Returns the largest integer less than or equal to x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.floor|math.floor} + * @method planBuilder.math#floor + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +floor(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.floor', 1, paramdef, args); + return new types.XsDouble('math', 'floor', checkedArgs); + } +/** + * Returns the remainder of x/y. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.fmod|math.fmod} + * @method planBuilder.math#fmod + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point dividend. + * @param { XsDouble } [y] - The floating point divisor. + * @returns { XsDouble } + */ +fmod(...args) { + const namer = bldrbase.getNamer(args, 'x'); + const paramdefs = [['x', [types.XsDouble, PlanColumn, PlanParam], true, false], ['y', [types.XsDouble, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'math.fmod', 2, new Set(['x', 'y']), paramdefs, args) : + bldrbase.makePositionalArgs('math.fmod', 2, false, paramdefs, args); + return new types.XsDouble('math', 'fmod', checkedArgs); + + } +/** + * Returns x broken up into mantissa and exponent, where x = mantissa*2^exponent. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.frexp|math.frexp} + * @method planBuilder.math#frexp + * @since 2.1.1 + * @param { XsDouble } [x] - The exponent to be evaluated. + * @returns { Item } + */ +frexp(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.frexp', 1, paramdef, args); + return new types.Item('math', 'frexp', checkedArgs); + } +/** + * Returns x*2^i. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.ldexp|math.ldexp} + * @method planBuilder.math#ldexp + * @since 2.1.1 + * @param { XsDouble } [y] - The floating-point number to be multiplied. + * @param { XsInteger } [i] - The exponent integer. + * @returns { XsDouble } + */ +ldexp(...args) { + const namer = bldrbase.getNamer(args, 'y'); + const paramdefs = [['y', [types.XsDouble, PlanColumn, PlanParam], true, false], ['i', [types.XsInteger, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'math.ldexp', 2, new Set(['y', 'i']), paramdefs, args) : + bldrbase.makePositionalArgs('math.ldexp', 2, false, paramdefs, args); + return new types.XsDouble('math', 'ldexp', checkedArgs); + + } +/** + * Returns a linear model that fits the given data set. The size of the input array should be 2, as currently only simple linear regression model is supported. The first element of the array should be the value of the dependent variable while the other element should be the value of the independent variable. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.linearModel|math.linearModel} + * @method planBuilder.math#linearModel + * @since 2.1.1 + * @param { JsonArray } [arg] - The input data set. Each array should contain a pair of values. + * @returns { MathLinearModel } + */ +linearModel(...args) { + const paramdef = ['arg', [types.JsonArray, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('math.linearModel', 1, paramdef, args); + return new types.MathLinearModel('math', 'linear-model', checkedArgs); + } +/** + * Returns the coefficients of the linear model. Currently only simple linear regression model is supported so the return should contain only one coefficient (also called "slope"). Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.linearModelCoeff|math.linearModelCoeff} + * @method planBuilder.math#linearModelCoeff + * @since 2.1.1 + * @param { MathLinearModel } [linearModel] - A linear model. + * @returns { XsDouble } + */ +linearModelCoeff(...args) { + const paramdef = ['linear-model', [types.MathLinearModel, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.linearModelCoeff', 1, paramdef, args); + return new types.XsDouble('math', 'linear-model-coeff', checkedArgs); + } +/** + * Returns the intercept of the linear model. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.linearModelIntercept|math.linearModelIntercept} + * @method planBuilder.math#linearModelIntercept + * @since 2.1.1 + * @param { MathLinearModel } [linearModel] - A linear model. + * @returns { XsDouble } + */ +linearModelIntercept(...args) { + const paramdef = ['linear-model', [types.MathLinearModel, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.linearModelIntercept', 1, paramdef, args); + return new types.XsDouble('math', 'linear-model-intercept', checkedArgs); + } +/** + * Returns the R^2 value of the linear model. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.linearModelRsquared|math.linearModelRsquared} + * @method planBuilder.math#linearModelRsquared + * @since 2.1.1 + * @param { MathLinearModel } [linearModel] - A linear model. + * @returns { XsDouble } + */ +linearModelRsquared(...args) { + const paramdef = ['linear-model', [types.MathLinearModel, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.linearModelRsquared', 1, paramdef, args); + return new types.XsDouble('math', 'linear-model-rsquared', checkedArgs); + } +/** + * Returns the base-e logarithm of x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.log|math.log} + * @method planBuilder.math#log + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +log(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.log', 1, paramdef, args); + return new types.XsDouble('math', 'log', checkedArgs); + } +/** + * Returns the base-10 logarithm of x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.log10|math.log10} + * @method planBuilder.math#log10 + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +log10(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.log10', 1, paramdef, args); + return new types.XsDouble('math', 'log10', checkedArgs); + } +/** + * Returns the median of a sequence of values. The function returns the empty sequence if the input is the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.median|math.median} + * @method planBuilder.math#median + * @since 2.1.1 + * @param { XsDouble } [arg] - The sequence of values. + * @returns { XsDouble } + */ +median(...args) { + const paramdef = ['arg', [types.XsDouble, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('math.median', 1, paramdef, args); + return new types.XsDouble('math', 'median', checkedArgs); + } +/** + * Returns the mode of a sequence. The mode is the value that occurs most frequently in a data set. If no value occurs more than once in the data set, the function returns the empty sequence. If the input is the empty sequence, the function returns the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.mode|math.mode} + * @method planBuilder.math#mode + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg] - The sequence of values. + * @param { XsString } [options] - Options. The default is (). Options include: "collation=URI" Applies only when $arg is of the xs:string type. If no specified, the default collation is used. "coordinate-system=name" Applies only when $arg is of the cts:point type. If no specified, the default coordinate system is used. + * @returns { XsAnyAtomicType } + */ +mode(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, true], ['options', [types.XsString, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'math.mode', 1, new Set(['arg', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('math.mode', 1, false, paramdefs, args); + return new types.XsAnyAtomicType('math', 'mode', checkedArgs); + + } +/** + * Returns x broken up into fraction and integer. x = fraction+integer. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.modf|math.modf} + * @method planBuilder.math#modf + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +modf(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.modf', 1, paramdef, args); + return new types.XsDouble('math', 'modf', checkedArgs); + } +/** + * Returns the rank of a value in a data set as a percentage of the data set. If the given value is not equal to any item in the sequence, the function returns the empty sequence. See math:rank. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.percentRank|math.percentRank} + * @method planBuilder.math#percentRank + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg] - The sequence of values. + * @param { XsAnyAtomicType } [value] - The value to be "ranked". + * @param { XsString } [options] - Options. The default is (). Options include: "ascending"(default) Rank the value as if the sequence was sorted in ascending order. "descending" Rank the value as if the sequence was sorted in descending order. "collation=URI" Applies only when $arg is of the xs:string type. If no specified, the default collation is used. "coordinate-system=name" Applies only when $arg is of the cts:point type. If no specified, the default coordinate system is used. + * @returns { XsDouble } + */ +percentRank(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, true], ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['options', [types.XsString, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'math.percentRank', 2, new Set(['arg', 'value', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('math.percentRank', 2, false, paramdefs, args); + return new types.XsDouble('math', 'percent-rank', checkedArgs); + + } +/** + * Returns a sequence of percentile(s) given a sequence of percentage(s). The function returns the empty sequence if either arg or p is the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.percentile|math.percentile} + * @method planBuilder.math#percentile + * @since 2.1.1 + * @param { XsDouble } [arg] - The sequence of values to calculate the percentile(s) on. + * @param { XsDouble } [p] - The sequence of percentage(s). + * @returns { XsDouble } + */ +percentile(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsDouble, PlanColumn, PlanParam], false, true], ['p', [types.XsDouble, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'math.percentile', 2, new Set(['arg', 'p']), paramdefs, args) : + bldrbase.makePositionalArgs('math.percentile', 2, false, paramdefs, args); + return new types.XsDouble('math', 'percentile', checkedArgs); + + } +/** + * Returns the value of pi. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.pi|math.pi} + * @method planBuilder.math#pi + * @since 2.1.1 + + * @returns { XsDouble } + */ +pi(...args) { + bldrbase.checkMaxArity('math.pi', args.length, 0); + return new types.XsDouble('math', 'pi', args); + } +/** + * Returns x^y. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.pow|math.pow} + * @method planBuilder.math#pow + * @since 2.1.1 + * @param { XsDouble } [x] - The floating-point base number. + * @param { XsDouble } [y] - The exponent to be applied to x. + * @returns { XsDouble } + */ +pow(...args) { + const namer = bldrbase.getNamer(args, 'x'); + const paramdefs = [['x', [types.XsDouble, PlanColumn, PlanParam], true, false], ['y', [types.XsDouble, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'math.pow', 2, new Set(['x', 'y']), paramdefs, args) : + bldrbase.makePositionalArgs('math.pow', 2, false, paramdefs, args); + return new types.XsDouble('math', 'pow', checkedArgs); + + } +/** + * Returns numeric expression converted from degrees to radians. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.radians|math.radians} + * @method planBuilder.math#radians + * @since 2.1.1 + * @param { XsDouble } [x] - An angle expressed in degrees. + * @returns { XsDouble } + */ +radians(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.radians', 1, paramdef, args); + return new types.XsDouble('math', 'radians', checkedArgs); + } +/** + * Returns the rank of a value in a data set. Ranks are skipped in the event of ties. If the given value is not equal to any item in the sequence, the function returns the empty sequence. The function can be used on numeric values, xs:yearMonthDuration, xs:dayTimeDuration, xs:string, xs:anyURI, xs:date, xs:dateTime, xs:time, and cts:point. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.rank|math.rank} + * @method planBuilder.math#rank + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - The sequence of values. + * @param { XsAnyAtomicType } [arg2] - The value to be "ranked". + * @param { XsString } [options] - Options. The default is (). Options include: "ascending"(default) Rank the value as if the sequence was sorted in ascending order. "descending" Rank the value as if the sequence was sorted in descending order. "collation=URI" Applies only when $arg is of the xs:string type. If no specified, the default collation is used. "coordinate-system=name" Applies only when $arg is of the cts:point type. If no specified, the default coordinate system is used. + * @returns { XsInteger } + */ +rank(...args) { + const namer = bldrbase.getNamer(args, 'arg1'); + const paramdefs = [['arg1', [types.XsAnyAtomicType, PlanColumn, PlanParam], false, true], ['arg2', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['options', [types.XsString, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'math.rank', 2, new Set(['arg1', 'arg2', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('math.rank', 2, false, paramdefs, args); + return new types.XsInteger('math', 'rank', checkedArgs); + + } +/** + * Returns the sine of x, in the range from -1 to +1 (inclusive). Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.sin|math.sin} + * @method planBuilder.math#sin + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +sin(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.sin', 1, paramdef, args); + return new types.XsDouble('math', 'sin', checkedArgs); + } +/** + * Returns the hyperbolic sine of x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.sinh|math.sinh} + * @method planBuilder.math#sinh + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +sinh(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.sinh', 1, paramdef, args); + return new types.XsDouble('math', 'sinh', checkedArgs); + } +/** + * Returns the square root of x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.sqrt|math.sqrt} + * @method planBuilder.math#sqrt + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +sqrt(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.sqrt', 1, paramdef, args); + return new types.XsDouble('math', 'sqrt', checkedArgs); + } +/** + * Returns the sample standard deviation of a sequence of values. The function returns the empty sequence if the length of the input sequence is less than 2. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.stddev|math.stddev} + * @method planBuilder.math#stddev + * @since 2.1.1 + * @param { XsDouble } [arg] - The sequence of values. + * @returns { XsDouble } + */ +stddev(...args) { + const paramdef = ['arg', [types.XsDouble, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('math.stddev', 1, paramdef, args); + return new types.XsDouble('math', 'stddev', checkedArgs); + } +/** + * Returns the standard deviation of a population. The function returns the empty sequence if the input is the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.stddevP|math.stddevP} + * @method planBuilder.math#stddevP + * @since 2.1.1 + * @param { XsDouble } [arg] - The sequence of values. + * @returns { XsDouble } + */ +stddevP(...args) { + const paramdef = ['arg', [types.XsDouble, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('math.stddevP', 1, paramdef, args); + return new types.XsDouble('math', 'stddev-p', checkedArgs); + } +/** + * Returns the tangent of x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.tan|math.tan} + * @method planBuilder.math#tan + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +tan(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.tan', 1, paramdef, args); + return new types.XsDouble('math', 'tan', checkedArgs); + } +/** + * Returns the hyperbolic tangent of x, in the range from -1 to +1 (inclusive). Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.tanh|math.tanh} + * @method planBuilder.math#tanh + * @since 2.1.1 + * @param { XsDouble } [x] - The floating point number to be evaluated. + * @returns { XsDouble } + */ +tanh(...args) { + const paramdef = ['x', [types.XsDouble, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('math.tanh', 1, paramdef, args); + return new types.XsDouble('math', 'tanh', checkedArgs); + } +/** + * Returns the number truncated to a certain number of decimal places. If type of arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of arg. If the type of arg is a type derived from one of the numeric types, the result is an instance of the base numeric type. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.trunc|math.trunc} + * @method planBuilder.math#trunc + * @since 2.1.1 + * @param { XsNumeric } [arg] - A numeric value to truncate. + * @param { XsInteger } [n] - The numbers of decimal places to truncate to. The default is 0. Negative values cause that many digits to the left of the decimal point to be truncated. + * @returns { XsNumeric } + */ +trunc(...args) { + const namer = bldrbase.getNamer(args, 'arg'); + const paramdefs = [['arg', [types.XsNumeric, PlanColumn, PlanParam], false, false], ['n', [types.XsInteger, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'math.trunc', 1, new Set(['arg', 'n']), paramdefs, args) : + bldrbase.makePositionalArgs('math.trunc', 1, false, paramdefs, args); + return new types.XsNumeric('math', 'trunc', checkedArgs); + + } +/** + * Returns the sample variance of a sequence of values. The function returns the empty sequence if the length of the input sequence is less than 2. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.variance|math.variance} + * @method planBuilder.math#variance + * @since 2.1.1 + * @param { XsDouble } [arg] - The sequence of values. + * @returns { XsDouble } + */ +variance(...args) { + const paramdef = ['arg', [types.XsDouble, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('math.variance', 1, paramdef, args); + return new types.XsDouble('math', 'variance', checkedArgs); + } +/** + * Returns the population variance of a sequence of values. The function returns the empty sequence if the input is the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/math.varianceP|math.varianceP} + * @method planBuilder.math#varianceP + * @since 2.1.1 + * @param { XsDouble } [arg] - The sequence of values. + * @returns { XsDouble } + */ +varianceP(...args) { + const paramdef = ['arg', [types.XsDouble, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('math.varianceP', 1, paramdef, args); + return new types.XsDouble('math', 'variance-p', checkedArgs); + } +} +class RdfExpr { + constructor() { + } + /** + * Returns an rdf:langString value with the given value and language tag. The rdf:langString type extends xs:string, and represents a language tagged string in RDF. Provides a client interface to a server function. See {@link http://docs.marklogic.com/rdf.langString|rdf.langString} + * @method planBuilder.rdf#langString + * @since 2.1.1 + * @param { XsString } [string] - The lexical value. + * @param { XsString } [lang] - The language. + * @returns { RdfLangString } + */ +langString(...args) { + const namer = bldrbase.getNamer(args, 'string'); + const paramdefs = [['string', [types.XsString, PlanColumn, PlanParam], true, false], ['lang', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'rdf.langString', 2, new Set(['string', 'lang']), paramdefs, args) : + bldrbase.makePositionalArgs('rdf.langString', 2, false, paramdefs, args); + return new types.RdfLangString('rdf', 'langString', checkedArgs); + + } +/** + * Returns the language of an rdf:langString value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/rdf.langStringLanguage|rdf.langStringLanguage} + * @method planBuilder.rdf#langStringLanguage + * @since 2.1.1 + * @param { RdfLangString } [val] - The rdf:langString value. + * @returns { XsString } + */ +langStringLanguage(...args) { + const paramdef = ['val', [types.RdfLangString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('rdf.langStringLanguage', 1, paramdef, args); + return new types.XsString('rdf', 'langString-language', checkedArgs); + } +} +class SemExpr { + constructor() { + } + /** + * This function returns an identifier for a blank node, allowing the construction of a triple that refers to a blank node. This XQuery function backs up the SPARQL BNODE() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.bnode|sem.bnode} + * @method planBuilder.sem#bnode + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - If provided, the same blank node identifier is returned for the same argument value passed to the function. + * @returns { SemBlank } + */ +bnode(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.bnode', 0, paramdef, args); + return new types.SemBlank('sem', 'bnode', checkedArgs); + } +/** + * Returns the value of the first argument that evaluates without error. This XQuery function backs up the SPARQL COALESCE() functional form. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.coalesce|sem.coalesce} + * @method planBuilder.sem#coalesce + * @since 2.1.1 + * @param { Item } [parameter1] - A value. + * @returns { Item } + */ +coalesce(...args) { + const namer = bldrbase.getNamer(args, 'parameter1'); + const paramdefs = [['parameter1', [types.Item, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sem.coalesce', 1, new Set(['parameter1']), paramdefs, args) : + bldrbase.makePositionalArgs('sem.coalesce', 1, true, paramdefs, args); + return new types.Item('sem', 'coalesce', checkedArgs); + + } +/** + * Returns the name of the simple type of the atomic value argument as a SPARQL style IRI. If the value is derived from sem:unknown or sem:invalid, the datatype IRI part of those values is returned. This XQuery function backs up the SPARQL datatype() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.datatype|sem.datatype} + * @method planBuilder.sem#datatype + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - The value to return the type of. + * @returns { SemIri } + */ +datatype(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.datatype', 1, paramdef, args); + return new types.SemIri('sem', 'datatype', checkedArgs); + } +/** + * The IF function form evaluates the first argument, interprets it as a effective boolean value, then returns the value of expression2 if the EBV is true, otherwise it returns the value of expression3. Only one of expression2 and expression3 is evaluated. If evaluating the first argument raises an error, then an error is raised for the evaluation of the IF expression. This XQuery function backs up the SPARQL IF() functional form. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.if|sem.if} + * @method planBuilder.sem#if + * @since 2.1.1 + * @param { XsBoolean } [condition] - The condition. + * @param { Item } [then] - The then expression. + * @param { Item } [else] - The else expression. + * @returns { Item } + */ +if(...args) { + const namer = bldrbase.getNamer(args, 'condition'); + const paramdefs = [['condition', [types.XsBoolean, PlanColumn, PlanParam], true, false], ['then', [types.Item, PlanColumn, PlanParam], false, true], ['else', [types.Item, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sem.if', 3, new Set(['condition', 'then', 'else']), paramdefs, args) : + bldrbase.makePositionalArgs('sem.if', 3, false, paramdefs, args); + return new types.Item('sem', 'if', checkedArgs); + + } +/** + * Returns a sem:invalid value with the given literal value and datatype IRI. The sem:invalid type extends xs:untypedAtomic, and represents an RDF value whose literal string is invalid according to the schema for it's datatype. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.invalid|sem.invalid} + * @method planBuilder.sem#invalid + * @since 2.1.1 + * @param { XsString } [string] - The lexical value. + * @param { SemIri } [datatype] - The datatype IRI. + * @returns { SemInvalid } + */ +invalid(...args) { + const namer = bldrbase.getNamer(args, 'string'); + const paramdefs = [['string', [types.XsString, PlanColumn, PlanParam], true, false], ['datatype', [types.SemIri, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sem.invalid', 2, new Set(['string', 'datatype']), paramdefs, args) : + bldrbase.makePositionalArgs('sem.invalid', 2, false, paramdefs, args); + return new types.SemInvalid('sem', 'invalid', checkedArgs); + + } +/** + * Returns the datatype IRI of a sem:invalid value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.invalidDatatype|sem.invalidDatatype} + * @method planBuilder.sem#invalidDatatype + * @since 2.1.1 + * @param { SemInvalid } [val] - The sem:invalid value. + * @returns { SemIri } + */ +invalidDatatype(...args) { + const paramdef = ['val', [types.SemInvalid, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.invalidDatatype', 1, paramdef, args); + return new types.SemIri('sem', 'invalid-datatype', checkedArgs); + } +/** + * This is a constructor function that takes a string and constructs an item of type sem:iri from it. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.iri|sem.iri} + * @method planBuilder.sem#iri + * @since 2.1.1 + * @param { XsAnyAtomicType } [stringIri] - The string with which to construct the sem:iri. + * @returns { SemIri } + */ +iri(...args) { + const paramdef = ['string-iri', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.iri', 1, paramdef, args); + return new types.SemIri('sem', 'iri', checkedArgs); + } +/** + * Provides a client interface to a server function. + * @method planBuilder.sem#iriToQName + * @since 2.1.1 + * @param { XsString } [arg1] - + * @returns { XsQName } + */ +iriToQName(...args) { + const paramdef = ['arg1', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.iriToQName', 1, paramdef, args); + return new types.XsQName('sem', 'iri-to-QName', checkedArgs); + } +/** + * Returns true if the argument is an RDF blank node - that is, derived from type sem:blank. This XQuery function backs up the SPARQL isBlank() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.isBlank|sem.isBlank} + * @method planBuilder.sem#isBlank + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - The value to test. + * @returns { XsBoolean } + */ +isBlank(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.isBlank', 1, paramdef, args); + return new types.XsBoolean('sem', 'isBlank', checkedArgs); + } +/** + * Returns true if the argument is an RDF IRI - that is, derived from type sem:iri, but not derived from type sem:blank. This XQuery function backs up the SPARQL isIRI() and isURI() functions. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.isIRI|sem.isIRI} + * @method planBuilder.sem#isIRI + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - The value to test. + * @returns { XsBoolean } + */ +isIRI(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.isIRI', 1, paramdef, args); + return new types.XsBoolean('sem', 'isIRI', checkedArgs); + } +/** + * Returns true if the argument is an RDF literal - that is, derived from type xs:anyAtomicType, but not derived from type sem:iri. This XQuery function backs up the SPARQL isLiteral() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.isLiteral|sem.isLiteral} + * @method planBuilder.sem#isLiteral + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - The value to test. + * @returns { XsBoolean } + */ +isLiteral(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.isLiteral', 1, paramdef, args); + return new types.XsBoolean('sem', 'isLiteral', checkedArgs); + } +/** + * Returns true if the argument is a valid numeric RDF literal. This XQuery function backs up the SPARQL isNumeric() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.isNumeric|sem.isNumeric} + * @method planBuilder.sem#isNumeric + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - The value to test. + * @returns { XsBoolean } + */ +isNumeric(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.isNumeric', 1, paramdef, args); + return new types.XsBoolean('sem', 'isNumeric', checkedArgs); + } +/** + * Returns the language of the value passed in, or the empty string if the value has no language. Only values derived from rdf:langString have a language. This XQuery function backs up the SPARQL lang() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.lang|sem.lang} + * @method planBuilder.sem#lang + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - The value to return the language of. + * @returns { XsString } + */ +lang(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.lang', 1, paramdef, args); + return new types.XsString('sem', 'lang', checkedArgs); + } +/** + * Returns true if lang-tag matches lang-range according to the basic filtering scheme defined in RFC4647. This XQuery function backs up the SPARQL langMatches() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.langMatches|sem.langMatches} + * @method planBuilder.sem#langMatches + * @since 2.1.1 + * @param { XsString } [langTag] - The language tag. + * @param { XsString } [langRange] - The language range. + * @returns { XsBoolean } + */ +langMatches(...args) { + const namer = bldrbase.getNamer(args, 'lang-tag'); + const paramdefs = [['lang-tag', [types.XsString, PlanColumn, PlanParam], true, false], ['lang-range', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sem.langMatches', 2, new Set(['lang-tag', 'lang-range']), paramdefs, args) : + bldrbase.makePositionalArgs('sem.langMatches', 2, false, paramdefs, args); + return new types.XsBoolean('sem', 'langMatches', checkedArgs); + + } +/** + * Provides a client interface to a server function. + * @method planBuilder.sem#QNameToIri + * @since 2.1.1 + * @param { XsQName } [arg1] - + * @returns { SemIri } + */ +QNameToIri(...args) { + const paramdef = ['arg1', [types.XsQName, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.QNameToIri', 1, paramdef, args); + return new types.SemIri('sem', 'QName-to-iri', checkedArgs); + } +/** + * Returns a random double between 0 and 1. This XQuery function backs up the SPARQL RAND() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.random|sem.random} + * @method planBuilder.sem#random + * @since 2.1.1 + + * @returns { XsDouble } + */ +random(...args) { + bldrbase.checkMaxArity('sem.random', args.length, 0); + return new types.XsDouble('sem', 'random', args); + } +/** + * The sem:ruleset-store function returns a set of triples derived by applying the ruleset to the triples in the sem:store constructor provided in store ("the triples that can be inferred from these rules"). Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.rulesetStore|sem.rulesetStore} + * @method planBuilder.sem#rulesetStore + * @since 2.1.1 + * @param { XsString } [locations] - The locations of the rulesets. + * @param { SemStore } [store] - The base store(s) over which to apply the ruleset to get inferred triples. The default for sem:store is an empty sequence, which means accessing the current database's triple index using the default rulesets configured for that database. + * @param { XsString } [options] - Options as a sequence of string values. Available options are: "size=number of MB" The maximum size of the memory used to cache inferred triples. This defaults to the default inference size set for the app-server. If the value provided is bigger than the maximum inference size set for the App Server, an error is raised [XDMP-INFSIZE]. + * @returns { SemStore } + */ +rulesetStore(...args) { + const namer = bldrbase.getNamer(args, 'locations'); + const paramdefs = [['locations', [types.XsString], false, true], ['store', [types.SemStore], false, true], ['options', [types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sem.rulesetStore', 1, new Set(['locations', 'store', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('sem.rulesetStore', 1, false, paramdefs, args); + return new types.SemStore('sem', 'ruleset-store', checkedArgs); + + } +/** + * Returns true if the arguments are the same RDF term as defined by the RDF concepts specification. This XQuery function backs up the SPARQL sameTerm() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.sameTerm|sem.sameTerm} + * @method planBuilder.sem#sameTerm + * @since 2.1.1 + * @param { XsAnyAtomicType } [a] - The first value to test. + * @param { XsAnyAtomicType } [b] - The second value to test. + * @returns { XsBoolean } + */ +sameTerm(...args) { + const namer = bldrbase.getNamer(args, 'a'); + const paramdefs = [['a', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['b', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sem.sameTerm', 2, new Set(['a', 'b']), paramdefs, args) : + bldrbase.makePositionalArgs('sem.sameTerm', 2, false, paramdefs, args); + return new types.XsBoolean('sem', 'sameTerm', checkedArgs); + + } +/** + * The sem:store function defines a set of criteria, that when evaluated, selects a set of triples to be passed in to sem:sparql(), sem:sparql-update(), or sem:sparql-values() as part of the options argument. The sem:store constructor queries from the current database's triple index, restricted by the options and the cts:query argument (for instance, "triples in documents matching this query"). Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.store|sem.store} + * @method planBuilder.sem#store + * @since 2.1.1 + * @param { XsString } [options] - Options as a sequence of string values. Available options are: "any" Values from any fragment should be included. "document" Values from document fragments should be included. "properties" Values from properties fragments should be included. "locks" Values from locks fragments should be included. "checked" Word positions should be checked when resolving the query. "unchecked" Word positions should not be checked when resolving the query. "size=number of MB" The maximum size of the memory used to cache inferred triples. This defaults to the default inference size set for the app-server. If the value provided is bigger than the maximum inference size set for the App Server, an error is raised [XDMP-INFSIZE]. "no-default-rulesets" Don't apply the database's default rulesets to the sem:store. "locking=read-write/write" read-write: Read-lock documents containing triples being accessed, write-lock documents being updated; write: Only write-lock documents being updated. Default is locking=read-write. Locking is ignored in query transaction. + * @param { CtsQuery } [query] - Only include triples in fragments selected by the cts:query. The triples do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string. + * @returns { SemStore } + */ +store(...args) { + const namer = bldrbase.getNamer(args, 'options'); + const paramdefs = [['options', [types.XsString], false, true], ['query', [types.CtsQuery], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sem.store', 0, new Set(['options', 'query']), paramdefs, args) : + bldrbase.makePositionalArgs('sem.store', 0, false, paramdefs, args); + return new types.SemStore('sem', 'store', checkedArgs); + + } +/** + * Returns the timezone of an xs:dateTime value as a string. This XQuery function backs up the SPARQL TZ() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.timezoneString|sem.timezoneString} + * @method planBuilder.sem#timezoneString + * @since 2.1.1 + * @param { XsDateTime } [value] - The dateTime value + * @returns { XsString } + */ +timezoneString(...args) { + const paramdef = ['value', [types.XsDateTime, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.timezoneString', 1, paramdef, args); + return new types.XsString('sem', 'timezone-string', checkedArgs); + } +/** + * Returns a value to represent the RDF typed literal with lexical value value and datatype IRI datatype. Returns a value of type sem:unknown for datatype IRIs for which there is no schema, and a value of type sem:invalid for lexical values which are invalid according to the schema for the given datatype. This XQuery function backs up the SPARQL STRDT() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.typedLiteral|sem.typedLiteral} + * @method planBuilder.sem#typedLiteral + * @since 2.1.1 + * @param { XsString } [value] - The lexical value. + * @param { SemIri } [datatype] - The datatype IRI. + * @returns { XsAnyAtomicType } + */ +typedLiteral(...args) { + const namer = bldrbase.getNamer(args, 'value'); + const paramdefs = [['value', [types.XsString, PlanColumn, PlanParam], true, false], ['datatype', [types.SemIri, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sem.typedLiteral', 2, new Set(['value', 'datatype']), paramdefs, args) : + bldrbase.makePositionalArgs('sem.typedLiteral', 2, false, paramdefs, args); + return new types.XsAnyAtomicType('sem', 'typed-literal', checkedArgs); + + } +/** + * Returns a sem:unknown value with the given literal value and datatype IRI. The sem:unknown type extends xs:untypedAtomic, and represents an RDF value with a datatype IRI for which no schema is available. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.unknown|sem.unknown} + * @method planBuilder.sem#unknown + * @since 2.1.1 + * @param { XsString } [string] - The lexical value. + * @param { SemIri } [datatype] - The datatype IRI. + * @returns { SemUnknown } + */ +unknown(...args) { + const namer = bldrbase.getNamer(args, 'string'); + const paramdefs = [['string', [types.XsString, PlanColumn, PlanParam], true, false], ['datatype', [types.SemIri, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sem.unknown', 2, new Set(['string', 'datatype']), paramdefs, args) : + bldrbase.makePositionalArgs('sem.unknown', 2, false, paramdefs, args); + return new types.SemUnknown('sem', 'unknown', checkedArgs); + + } +/** + * Returns the datatype IRI of a sem:unknown value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.unknownDatatype|sem.unknownDatatype} + * @method planBuilder.sem#unknownDatatype + * @since 2.1.1 + * @param { SemUnknown } [val] - The sem:unknown value. + * @returns { SemIri } + */ +unknownDatatype(...args) { + const paramdef = ['val', [types.SemUnknown, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sem.unknownDatatype', 1, paramdef, args); + return new types.SemIri('sem', 'unknown-datatype', checkedArgs); + } +/** + * Return a UUID URN (RFC4122) as a sem:iri value. This XQuery function backs up the SPARQL UUID() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.uuid|sem.uuid} + * @method planBuilder.sem#uuid + * @since 2.1.1 + + * @returns { SemIri } + */ +uuid(...args) { + bldrbase.checkMaxArity('sem.uuid', args.length, 0); + return new types.SemIri('sem', 'uuid', args); + } +/** + * Return a string that is the scheme specific part of random UUID URN (RFC4122). This XQuery function backs up the SPARQL STRUUID() function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sem.uuidString|sem.uuidString} + * @method planBuilder.sem#uuidString + * @since 2.1.1 + + * @returns { XsString } + */ +uuidString(...args) { + bldrbase.checkMaxArity('sem.uuidString', args.length, 0); + return new types.XsString('sem', 'uuid-string', args); + } +} +class SpellExpr { + constructor() { + } + /** + * Given a word returns the two metaphone keys. The primary and secondary metaphone keys which represent the phonetic encoding of two words are returned as a sequence of two strings. Double metaphone is an algorithm based on phonetic sounds useful in providing data to spelling correction suggestions. Provides a client interface to a server function. See {@link http://docs.marklogic.com/spell.doubleMetaphone|spell.doubleMetaphone} + * @method planBuilder.spell#doubleMetaphone + * @since 2.1.1 + * @param { XsString } [word] - The word for phonetic matching. + * @returns { XsString } + */ +doubleMetaphone(...args) { + const paramdef = ['word', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('spell.doubleMetaphone', 1, paramdef, args); + return new types.XsString('spell', 'double-metaphone', checkedArgs); + } +/** + * Given two strings, returns the Levenshtein distance between those strings. The Levenshtein distance is a measure of how many operations it takes to transform a string into another string, and it is useful in determining if a word is spelled correctly, or in simply comparing how "different" two words are. Provides a client interface to a server function. See {@link http://docs.marklogic.com/spell.levenshteinDistance|spell.levenshteinDistance} + * @method planBuilder.spell#levenshteinDistance + * @since 2.1.1 + * @param { XsString } [str1] - The first input string. + * @param { XsString } [str2] - The second input string. + * @returns { XsInteger } + */ +levenshteinDistance(...args) { + const namer = bldrbase.getNamer(args, 'str1'); + const paramdefs = [['str1', [types.XsString, PlanColumn, PlanParam], true, false], ['str2', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'spell.levenshteinDistance', 2, new Set(['str1', 'str2']), paramdefs, args) : + bldrbase.makePositionalArgs('spell.levenshteinDistance', 2, false, paramdefs, args); + return new types.XsInteger('spell', 'levenshtein-distance', checkedArgs); + + } +/** + * Returns the romanization of the string, substituting basic Latin letters for the letters in the string, according to their sound. Unsupported characters will be mapped to '?' for compatibility with the double metaphone algorithm. We support romanization of the scripts of the languages with advanced support in MarkLogic except for Chinese characters and Hangul. Provides a client interface to a server function. See {@link http://docs.marklogic.com/spell.romanize|spell.romanize} + * @method planBuilder.spell#romanize + * @since 2.1.1 + * @param { XsString } [string] - The input string. + * @returns { XsString } + */ +romanize(...args) { + const paramdef = ['string', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('spell.romanize', 1, paramdef, args); + return new types.XsString('spell', 'romanize', checkedArgs); + } +} +class SqlExpr { + constructor() { + } + /** + * Returns the length of the string "str" in bits. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.bitLength|sql.bitLength} + * @method planBuilder.sql#bitLength + * @since 2.1.1 + * @param { XsString } [str] - The string to be evaluated. + * @returns { XsInteger } + */ +bitLength(...args) { + const paramdef = ['str', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.bitLength', 1, paramdef, args); + return new types.XsInteger('sql', 'bit-length', checkedArgs); + } +/** + * Returns an rdf:collatedString value with the given value and collation tag. The rdf:collatedString type extends xs:string , and represents a collation tagged string in RDF. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.collatedString|sql.collatedString} + * @method planBuilder.sql#collatedString + * @since 2.1.1 + * @param { XsString } [string] - The lexical value. + * @param { XsString } [collationURI] - The collation URI. + * @returns { XsString } + */ +collatedString(...args) { + const namer = bldrbase.getNamer(args, 'string'); + const paramdefs = [['string', [types.XsString, PlanColumn, PlanParam], true, false], ['collationURI', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.collatedString', 2, new Set(['string', 'collationURI']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.collatedString', 2, false, paramdefs, args); + return new types.XsString('sql', 'collated-string', checkedArgs); + + } +/** + * Returns a specified date with the specified number interval (signed integer) added to a specified datepart of that date Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.dateadd|sql.dateadd} + * @method planBuilder.sql#dateadd + * @since 2.1.1 + * @param { XsString } [datepart] - Is the part of date where the number will be added. The following table lists all valid datepart arguments. User-defined variable equivalents are not valid. The return data type is the data type of the date argument. Options: datepart parameter abbreviation includes: "year","yyyy","yy" The year part of the date "quarter","qq","q" The quarter part of the date "month","mm","m" The month part of the date "dayofyear","dy","y" The day of the year from the date "day","dd","d" The day of the month from the date "week","wk","ww" The week of the year from the date "weekday","dw" The day of the week from the date "hour","hh" The hour of the day from the date "minute","mi","n" The minute of the hour from the date "second","ss","s" The second of the minute from the date "millisecond","ms" The millisecond of the minute from the date "microsecond","msc" The microsecond of the minute from the date "nanosecond","ns" The nanosecond of the minute from the date + * @param { XsInt } [number] - This number will be added to the datepart of the given date. + * @param { Item } [date] - Is an expression that can be resolved to a time, date or datetime, value. date can be an expression, column expression, user-defined variable or string literal. startdate is subtracted from enddate. + * @returns { Item } + */ +dateadd(...args) { + const namer = bldrbase.getNamer(args, 'datepart'); + const paramdefs = [['datepart', [types.XsString, PlanColumn, PlanParam], true, false], ['number', [types.XsInt, PlanColumn, PlanParam], true, false], ['date', [types.Item, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.dateadd', 3, new Set(['datepart', 'number', 'date']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.dateadd', 3, false, paramdefs, args); + return new types.Item('sql', 'dateadd', checkedArgs); + + } +/** + * Returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.datediff|sql.datediff} + * @method planBuilder.sql#datediff + * @since 2.1.1 + * @param { XsString } [datepart] - Is the part of startdate and enddate that specifies the type of boundary crossed. The following table lists all valid datepart arguments. User-defined variable equivalents are not valid. Options: datepart parameter abbreviation includes: "year","yyyy","yy" The year part of the date "quarter","qq","q" The quarter part of the date "month","mm","m" The month part of the date "dayofyear","dy","y" The day of the year from the date "day","dd","d" The day of the month from the date "week","wk","ww" The week of the year from the date "weekday","dw" The day of the week from the date "hour","hh" The hour of the day from the date "minute","mi","n" The minute of the hour from the date "second","ss","s" The second of the minute from the date "millisecond","ms" The millisecond of the minute from the date "microsecond","msc" The microsecond of the minute from the date "nanosecond","ns" The nanosecond of the minute from the date + * @param { Item } [startdate] - Is an expression that can be resolved to a time, date, datetime or value. date can be an expression, column expression, user-defined variable or string literal. startdate is subtracted from enddate. + * @param { Item } [enddate] - Same as startdate. + * @returns { XsInteger } + */ +datediff(...args) { + const namer = bldrbase.getNamer(args, 'datepart'); + const paramdefs = [['datepart', [types.XsString, PlanColumn, PlanParam], true, false], ['startdate', [types.Item, PlanColumn, PlanParam], true, false], ['enddate', [types.Item, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.datediff', 3, new Set(['datepart', 'startdate', 'enddate']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.datediff', 3, false, paramdefs, args); + return new types.XsInteger('sql', 'datediff', checkedArgs); + + } +/** + * Returns an integer that represents the specified datepart of the specified date. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.datepart|sql.datepart} + * @method planBuilder.sql#datepart + * @since 2.1.1 + * @param { XsString } [datepart] - The part of date that to be returned. Options: datepart parameter abbreviation includes: "year","yyyy","yy" The year part of the date "quarter","qq","q" The quarter part of the date "month","mm","m" The month part of the date "dayofyear","dy","y" The day of the year from the date "day","dd","d" The day of the month from the date "week","wk","ww" The week of the year from the date "weekday","dw" The day of the week from the date "hour","hh" The hour of the day from the date "minute","mi","n" The minute of the hour from the date "second","ss","s" The second of the minute from the date "millisecond","ms" The millisecond of the minute from the date "microsecond","msc" The microsecond of the minute from the date "nanosecond","ns" The nanosecond of the minute from the date "TZoffset","tz" The timezone offset from the date + * @param { Item } [date] - Is an expression that can be resolved to a xs:date, xs:time, xs:dateTime. date can be an expression, column expression,user-defined variable, or string literal. + * @returns { XsInteger } + */ +datepart(...args) { + const namer = bldrbase.getNamer(args, 'datepart'); + const paramdefs = [['datepart', [types.XsString, PlanColumn, PlanParam], true, false], ['date', [types.Item, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.datepart', 2, new Set(['datepart', 'date']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.datepart', 2, false, paramdefs, args); + return new types.XsInteger('sql', 'datepart', checkedArgs); + + } +/** + * Returns an xs:integer between 1 and 31, both inclusive, representing the day component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.day|sql.day} + * @method planBuilder.sql#day + * @since 2.1.1 + * @param { Item } [arg] - The xs:genericDateTimeArg whose day component will be returned. + * @returns { XsInteger } + */ +day(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.day', 1, paramdef, args); + return new types.XsInteger('sql', 'day', checkedArgs); + } +/** + * Returns an xs:string representing the dayname value in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.dayname|sql.dayname} + * @method planBuilder.sql#dayname + * @since 2.1.1 + * @param { Item } [arg] - The date whose dayname value will be returned. + * @returns { XsString } + */ +dayname(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.dayname', 1, paramdef, args); + return new types.XsString('sql', 'dayname', checkedArgs); + } +/** + * Returns an xs:integer between 0 and 23, both inclusive, representing the value of the hours component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.hours|sql.hours} + * @method planBuilder.sql#hours + * @since 2.1.1 + * @param { Item } [arg] - The genericDateTime whose hours component will be returned. + * @returns { XsInteger } + */ +hours(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.hours', 1, paramdef, args); + return new types.XsInteger('sql', 'hours', checkedArgs); + } +/** + * Returns a string that that is the first argument with length characters removed starting at start and the second string has been inserted beginning at start. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.insert|sql.insert} + * @method planBuilder.sql#insert + * @since 2.1.1 + * @param { XsString } [str] - The string to manipulate. + * @param { XsNumeric } [start] - The starting position where characters will be inserted. + * @param { XsNumeric } [length] - The number of characters to be removed. + * @param { XsString } [str2] - The string to insert. + * @returns { XsString } + */ +insert(...args) { + const namer = bldrbase.getNamer(args, 'str'); + const paramdefs = [['str', [types.XsString, PlanColumn, PlanParam], true, false], ['start', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['length', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['str2', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.insert', 4, new Set(['str', 'start', 'length', 'str2']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.insert', 4, false, paramdefs, args); + return new types.XsString('sql', 'insert', checkedArgs); + + } +/** + * Find the starting location of a pattern in a string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.instr|sql.instr} + * @method planBuilder.sql#instr + * @since 2.1.1 + * @param { XsString } [str] - The string to be evaluated. + * @param { XsString } [n] - The pattern to be evaluated. + * @returns { XsUnsignedInt } + */ +instr(...args) { + const namer = bldrbase.getNamer(args, 'str'); + const paramdefs = [['str', [types.XsString, PlanColumn, PlanParam], true, false], ['n', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.instr', 2, new Set(['str', 'n']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.instr', 2, false, paramdefs, args); + return new types.XsUnsignedInt('sql', 'instr', checkedArgs); + + } +/** + * Returns a string that is the leftmost characters of the target string. The number of characters to return is specified by the second argument. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.left|sql.left} + * @method planBuilder.sql#left + * @since 2.1.1 + * @param { Item } [str] - The base string. If the value is not a string, its string value will be used. + * @param { XsNumeric } [n] - The number of leftmost characters of the string to return. + * @returns { XsString } + */ +left(...args) { + const namer = bldrbase.getNamer(args, 'str'); + const paramdefs = [['str', [types.Item, PlanColumn, PlanParam], false, true], ['n', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.left', 2, new Set(['str', 'n']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.left', 2, false, paramdefs, args); + return new types.XsString('sql', 'left', checkedArgs); + + } +/** + * Return a string that removes leading empty spaces in the input string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.ltrim|sql.ltrim} + * @method planBuilder.sql#ltrim + * @since 2.1.1 + * @param { XsString } [str] - The string to be evaluated. + * @returns { XsString } + */ +ltrim(...args) { + const paramdef = ['str', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.ltrim', 1, paramdef, args); + return new types.XsString('sql', 'ltrim', checkedArgs); + } +/** + * Returns an xs:integer value between 0 to 59, both inclusive, representing the value of the minutes component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.minutes|sql.minutes} + * @method planBuilder.sql#minutes + * @since 2.1.1 + * @param { Item } [arg] - The genericDateTime whose minutes component will be returned. + * @returns { XsInteger } + */ +minutes(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.minutes', 1, paramdef, args); + return new types.XsInteger('sql', 'minutes', checkedArgs); + } +/** + * Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.month|sql.month} + * @method planBuilder.sql#month + * @since 2.1.1 + * @param { Item } [arg] - The genericDateTime whose month component will be returned. + * @returns { XsInteger } + */ +month(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.month', 1, paramdef, args); + return new types.XsInteger('sql', 'month', checkedArgs); + } +/** + * Returns month name, calculated from the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.monthname|sql.monthname} + * @method planBuilder.sql#monthname + * @since 2.1.1 + * @param { Item } [arg] - The date whose month-name will be returned. + * @returns { XsString } + */ +monthname(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.monthname', 1, paramdef, args); + return new types.XsString('sql', 'monthname', checkedArgs); + } +/** + * Returns the length of the string "str" in bits. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.octetLength|sql.octetLength} + * @method planBuilder.sql#octetLength + * @since 2.1.1 + * @param { XsString } [x] - The string to be evaluated. + * @returns { XsInteger } + */ +octetLength(...args) { + const paramdef = ['x', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.octetLength', 1, paramdef, args); + return new types.XsInteger('sql', 'octet-length', checkedArgs); + } +/** + * Returns an xs:integer between 1 and 4, both inclusive, calculating the quarter component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.quarter|sql.quarter} + * @method planBuilder.sql#quarter + * @since 2.1.1 + * @param { Item } [arg] - The genericDateTime whose quarter component will be returned. + * @returns { XsInteger } + */ +quarter(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.quarter', 1, paramdef, args); + return new types.XsInteger('sql', 'quarter', checkedArgs); + } +/** + * Return a random number. This differs from xdmp:random in that the argument is a seed. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.rand|sql.rand} + * @method planBuilder.sql#rand + * @since 2.1.1 + * @param { XsUnsignedLong } [n] - The random seed. Currently this parameter is ignored. + * @returns { XsUnsignedLong } + */ +rand(...args) { + const paramdef = ['n', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.rand', 1, paramdef, args); + return new types.XsUnsignedLong('sql', 'rand', checkedArgs); + } +/** + * Returns a string that concatenates the first argument as many times as specified by the second argument. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.repeat|sql.repeat} + * @method planBuilder.sql#repeat + * @since 2.1.1 + * @param { Item } [str] - The string to duplicate. If the value is not a string, its string value will be used. + * @param { XsNumeric } [n] - The number of times to repeat the string. + * @returns { XsString } + */ +repeat(...args) { + const namer = bldrbase.getNamer(args, 'str'); + const paramdefs = [['str', [types.Item, PlanColumn, PlanParam], false, true], ['n', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.repeat', 2, new Set(['str', 'n']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.repeat', 2, false, paramdefs, args); + return new types.XsString('sql', 'repeat', checkedArgs); + + } +/** + * Returns a string that is the rightmost characters of the target string. The number of characters to return is specified by the second argument. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.right|sql.right} + * @method planBuilder.sql#right + * @since 2.1.1 + * @param { Item } [str] - The base string. If the value is not a string, its string value will be used. + * @param { XsNumeric } [n] - The number of rightmost characters of the string to return. + * @returns { XsString } + */ +right(...args) { + const namer = bldrbase.getNamer(args, 'str'); + const paramdefs = [['str', [types.Item, PlanColumn, PlanParam], false, true], ['n', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.right', 2, new Set(['str', 'n']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.right', 2, false, paramdefs, args); + return new types.XsString('sql', 'right', checkedArgs); + + } +/** + * Return a string that removes trailing empty spaces in the input string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.rtrim|sql.rtrim} + * @method planBuilder.sql#rtrim + * @since 2.1.1 + * @param { XsString } [str] - The string to be evaluated. + * @returns { XsString } + */ +rtrim(...args) { + const paramdef = ['str', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.rtrim', 1, paramdef, args); + return new types.XsString('sql', 'rtrim', checkedArgs); + } +/** + * Returns an xs:decimal value between 0 and 60.999..., both inclusive, representing the seconds and fractional seconds in the localized value of arg. Note that the value can be greater than 60 seconds to accommodate occasional leap seconds used to keep human time synchronized with the rotation of the planet. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.seconds|sql.seconds} + * @method planBuilder.sql#seconds + * @since 2.1.1 + * @param { Item } [arg] - The time whose seconds component will be returned. + * @returns { XsDecimal } + */ +seconds(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.seconds', 1, paramdef, args); + return new types.XsDecimal('sql', 'seconds', checkedArgs); + } +/** + * Returns the sign of number x. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.sign|sql.sign} + * @method planBuilder.sql#sign + * @since 2.1.1 + * @param { XsNumeric } [x] - The number to be evaluated. + * @returns { Item } + */ +sign(...args) { + const paramdef = ['x', [types.XsNumeric, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.sign', 1, paramdef, args); + return new types.Item('sql', 'sign', checkedArgs); + } +/** + * Returns a string that is the given number of spaces. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.space|sql.space} + * @method planBuilder.sql#space + * @since 2.1.1 + * @param { XsNumeric } [n] - The number of spaces to return as a string. + * @returns { XsString } + */ +space(...args) { + const paramdef = ['n', [types.XsNumeric, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.space', 1, paramdef, args); + return new types.XsString('sql', 'space', checkedArgs); + } +/** + * Returns a xs:string? timestamp created by adding a number to the given dateTimeType field of a given timestamp. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.timestampadd|sql.timestampadd} + * @method planBuilder.sql#timestampadd + * @since 2.1.1 + * @param { XsString } [dateTimeType] - The dateTimeType of the timestamp where addition should take place. Available types are: SQL_TSI_FRAC_SECOND nano seconds SQL_TSI_SECOND seconds SQL_TSI_MINUTE minute SQL_TSI_HOUR hour SQL_TSI_DAY day SQL_TSI_WEEK week SQL_TSI_MONTH month SQL_TSI_QUARTER quarter SQL_TSI_YEAR year + * @param { XsInt } [value] - The integer to add to the given dateTimeType field of the third parameter. + * @param { Item } [timestamp] - The xs:dateTime timestamp to which addition has to take place. + * @returns { Item } + */ +timestampadd(...args) { + const namer = bldrbase.getNamer(args, 'dateTimeType'); + const paramdefs = [['dateTimeType', [types.XsString, PlanColumn, PlanParam], true, false], ['value', [types.XsInt, PlanColumn, PlanParam], true, false], ['timestamp', [types.Item, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.timestampadd', 3, new Set(['dateTimeType', 'value', 'timestamp']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.timestampadd', 3, false, paramdefs, args); + return new types.Item('sql', 'timestampadd', checkedArgs); + + } +/** + * Returns the difference in dateTimeType field of two given timestamps. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.timestampdiff|sql.timestampdiff} + * @method planBuilder.sql#timestampdiff + * @since 2.1.1 + * @param { XsString } [dateTimeType] - The dateTimeType of the timestamp where addition should take place. Available types are: SQL_TSI_FRAC_SECOND nano seconds SQL_TSI_SECOND seconds SQL_TSI_MINUTE minute SQL_TSI_HOUR hour SQL_TSI_DAY day SQL_TSI_WEEK week SQL_TSI_MONTH month SQL_TSI_QUARTER quarter SQL_TSI_YEAR year + * @param { Item } [timestamp1] - The integer to add to the given dateTimeType field of the third parameter. + * @param { Item } [timestamp2] - The xs:dateTime timestamp to which addition has to take place. + * @returns { XsInteger } + */ +timestampdiff(...args) { + const namer = bldrbase.getNamer(args, 'dateTimeType'); + const paramdefs = [['dateTimeType', [types.XsString, PlanColumn, PlanParam], true, false], ['timestamp1', [types.Item, PlanColumn, PlanParam], true, false], ['timestamp2', [types.Item, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'sql.timestampdiff', 3, new Set(['dateTimeType', 'timestamp1', 'timestamp2']), paramdefs, args) : + bldrbase.makePositionalArgs('sql.timestampdiff', 3, false, paramdefs, args); + return new types.XsInteger('sql', 'timestampdiff', checkedArgs); + + } +/** + * Return a string that removes leading empty spaces in the input string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.trim|sql.trim} + * @method planBuilder.sql#trim + * @since 2.1.1 + * @param { XsString } [str] - The string to be evaluated. + * @returns { XsString } + */ +trim(...args) { + const paramdef = ['str', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.trim', 1, paramdef, args); + return new types.XsString('sql', 'trim', checkedArgs); + } +/** + * Returns an xs:integer between 1 and 53, both inclusive, representing the week value in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.week|sql.week} + * @method planBuilder.sql#week + * @since 2.1.1 + * @param { Item } [arg] - The dateTime/date/string whose day component will be returned. + * @returns { XsInteger } + */ +week(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.week', 1, paramdef, args); + return new types.XsInteger('sql', 'week', checkedArgs); + } +/** + * Provides a client interface to a server function. + * @method planBuilder.sql#weekday + * @since 2.1.1 + * @param { Item } [arg1] - + * @returns { XsInteger } + */ +weekday(...args) { + const paramdef = ['arg1', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.weekday', 1, paramdef, args); + return new types.XsInteger('sql', 'weekday', checkedArgs); + } +/** + * Returns an xs:integer representing the year component in the localized value of arg. The result may be negative. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.year|sql.year} + * @method planBuilder.sql#year + * @since 2.1.1 + * @param { Item } [arg] - The dateTime/date/string whose day component will be returned. + * @returns { XsInteger } + */ +year(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.year', 1, paramdef, args); + return new types.XsInteger('sql', 'year', checkedArgs); + } +/** + * Returns an xs:integer between 1 and 366, both inclusive, representing the yearday value in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/sql.yearday|sql.yearday} + * @method planBuilder.sql#yearday + * @since 2.1.1 + * @param { Item } [arg] - The xs:genericDateTimeArg whose days of the year will be returned. + * @returns { XsInteger } + */ +yearday(...args) { + const paramdef = ['arg', [types.Item, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('sql.yearday', 1, paramdef, args); + return new types.XsInteger('sql', 'yearday', checkedArgs); + } +} +class XdmpExpr { + constructor() { + } + /** + * Add two 64-bit integer values, discarding overflow. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.add64|xdmp.add64} + * @method planBuilder.xdmp#add64 + * @since 2.1.1 + * @param { XsUnsignedLong } [x] - The first value. + * @param { XsUnsignedLong } [y] - The second value. + * @returns { XsUnsignedLong } + */ +add64(...args) { + const namer = bldrbase.getNamer(args, 'x'); + const paramdefs = [['x', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false], ['y', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.add64', 2, new Set(['x', 'y']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.add64', 2, false, paramdefs, args); + return new types.XsUnsignedLong('xdmp', 'add64', checkedArgs); + + } +/** + * AND two 64-bit integer values. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.and64|xdmp.and64} + * @method planBuilder.xdmp#and64 + * @since 2.1.1 + * @param { XsUnsignedLong } [x] - The first value. + * @param { XsUnsignedLong } [y] - The second value. + * @returns { XsUnsignedLong } + */ +and64(...args) { + const namer = bldrbase.getNamer(args, 'x'); + const paramdefs = [['x', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false], ['y', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.and64', 2, new Set(['x', 'y']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.and64', 2, false, paramdefs, args); + return new types.XsUnsignedLong('xdmp', 'and64', checkedArgs); + + } +/** + * Converts base64-encoded string to plaintext. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.base64Decode|xdmp.base64Decode} + * @method planBuilder.xdmp#base64Decode + * @since 2.1.1 + * @param { XsString } [encoded] - Encoded text to be decoded. + * @returns { XsString } + */ +base64Decode(...args) { + const paramdef = ['encoded', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.base64Decode', 1, paramdef, args); + return new types.XsString('xdmp', 'base64-decode', checkedArgs); + } +/** + * Converts plaintext into base64-encoded string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.base64Encode|xdmp.base64Encode} + * @method planBuilder.xdmp#base64Encode + * @since 2.1.1 + * @param { XsString } [plaintext] - Plaintext to be encoded. + * @returns { XsString } + */ +base64Encode(...args) { + const paramdef = ['plaintext', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.base64Encode', 1, paramdef, args); + return new types.XsString('xdmp', 'base64-encode', checkedArgs); + } +/** + * Returns true if a value is castable. This is similar to the "castable as" XQuery predicate, except that the type is determined at runtime. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.castableAs|xdmp.castableAs} + * @method planBuilder.xdmp#castableAs + * @since 2.1.1 + * @param { XsString } [namespaceUri] - The namespace URI of the type. + * @param { XsString } [localName] - The local-name of the type. + * @param { Item } [item] - The item to be cast. + * @returns { XsBoolean } + */ +castableAs(...args) { + const namer = bldrbase.getNamer(args, 'namespace-uri'); + const paramdefs = [['namespace-uri', [types.XsString, PlanColumn, PlanParam], true, false], ['local-name', [types.XsString, PlanColumn, PlanParam], true, false], ['item', [types.Item, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.castableAs', 3, new Set(['namespace-uri', 'local-name', 'item']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.castableAs', 3, false, paramdefs, args); + return new types.XsBoolean('xdmp', 'castable-as', checkedArgs); + + } +/** + * Calculates the password hash for the given password and salt. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.crypt|xdmp.crypt} + * @method planBuilder.xdmp#crypt + * @since 2.1.1 + * @param { XsString } [password] - String to be hashed. + * @param { XsString } [salt] - Salt to avoid 1:1 mapping from passwords to hashes. Only the first 8 characters of the salt are significant; any characters beyond the eighth are ignored. + * @returns { XsString } + */ +crypt(...args) { + const namer = bldrbase.getNamer(args, 'password'); + const paramdefs = [['password', [types.XsString, PlanColumn, PlanParam], true, false], ['salt', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.crypt', 2, new Set(['password', 'salt']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.crypt', 2, false, paramdefs, args); + return new types.XsString('xdmp', 'crypt', checkedArgs); + + } +/** + * Calculates the password hash for the given plain-text password. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.crypt2|xdmp.crypt2} + * @method planBuilder.xdmp#crypt2 + * @since 2.1.1 + * @param { XsString } [password] - String to be hashed. + * @returns { XsString } + */ +crypt2(...args) { + const paramdef = ['password', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.crypt2', 1, paramdef, args); + return new types.XsString('xdmp', 'crypt2', checkedArgs); + } +/** + * Returns an xs:string representing the dayname value in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.daynameFromDate|xdmp.daynameFromDate} + * @method planBuilder.xdmp#daynameFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose dayname value will be returned. + * @returns { XsString } + */ +daynameFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.daynameFromDate', 1, paramdef, args); + return new types.XsString('xdmp', 'dayname-from-date', checkedArgs); + } +/** + * Invertible function that decodes characters an NCName produced by xdmp:encode-for-NCName. Given the NCName produced by xdmp:encode-for-NCName this function returns the original string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.decodeFromNCName|xdmp.decodeFromNCName} + * @method planBuilder.xdmp#decodeFromNCName + * @since 2.1.1 + * @param { XsString } [name] - A string representing an NCName. This string must have been the result of a previous call to xdmp:decode-from-NCName or undefined results will occur. + * @returns { XsString } + */ +decodeFromNCName(...args) { + const paramdef = ['name', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.decodeFromNCName', 1, paramdef, args); + return new types.XsString('xdmp', 'decode-from-NCName', checkedArgs); + } +/** + * Returns a string representing the description of a given item sequence. If you take the output of this function and evaluate it as an XQuery program, it returns the item(s) input to the function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.describe|xdmp.describe} + * @method planBuilder.xdmp#describe + * @since 2.1.1 + * @param { Item } [item] - The item sequence whose description is returned. + * @param { XsUnsignedInt } [maxSequenceLength] - Represents the maximum number of items per sequence to print. The default is 3. () means no maximum. + * @param { XsUnsignedInt } [maxItemLength] - Represents the maximum number of characters per item to print. The default is 64. The minimum is 8. () means no limit. + * @returns { XsString } + */ +describe(...args) { + const namer = bldrbase.getNamer(args, 'item'); + const paramdefs = [['item', [types.Item, PlanColumn, PlanParam], false, true], ['max-sequence-length', [types.XsUnsignedInt, PlanColumn, PlanParam], false, false], ['max-item-length', [types.XsUnsignedInt, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.describe', 1, new Set(['item', 'max-sequence-length', 'max-item-length']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.describe', 1, false, paramdefs, args); + return new types.XsString('xdmp', 'describe', checkedArgs); + + } +/** + * Returns the specified string, converting all of the characters with diacritics to characters without diacritics. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.diacriticLess|xdmp.diacriticLess} + * @method planBuilder.xdmp#diacriticLess + * @since 2.1.1 + * @param { XsString } [string] - The string to convert. + * @returns { XsString } + */ +diacriticLess(...args) { + const paramdef = ['string', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.diacriticLess', 1, paramdef, args); + return new types.XsString('xdmp', 'diacritic-less', checkedArgs); + } +/** + * Returns the schema-defined content-type of an element ("empty", "simple", "element-only", or "mixed"). Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.elementContentType|xdmp.elementContentType} + * @method planBuilder.xdmp#elementContentType + * @since 2.1.1 + * @param { ElementNode } [element] - An element node. + * @returns { XsString } + */ +elementContentType(...args) { + const paramdef = ['element', [types.ElementNode, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.elementContentType', 1, paramdef, args); + return new types.XsString('xdmp', 'element-content-type', checkedArgs); + } +/** + * Invertible function that escapes characters required to be part of an NCName. This is useful when translating names from other representations such as JSON to XML. Given any string, the result is always a valid NCName. Providing all names are passed through this function the result is distinct NCNames so the results can be used for searching as well as name generation. The inverse function is xdmp:decode-for-NCName. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.encodeForNCName|xdmp.encodeForNCName} + * @method planBuilder.xdmp#encodeForNCName + * @since 2.1.1 + * @param { XsString } [name] - A string which is used as an NCName (such as the localname for an element or attribute). + * @returns { XsString } + */ +encodeForNCName(...args) { + const paramdef = ['name', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.encodeForNCName', 1, paramdef, args); + return new types.XsString('xdmp', 'encode-for-NCName', checkedArgs); + } +/** + * Returns a formatted number value based on the picture argument. The difference between this function and the W3C standards fn:format-number function is that this function imitates the XSLT xsl:number instruction, which has richer formatting options than the fn:format-number function. This function can be used for spelled-out and ordinal numbering in many languages. This function is available in XSLT as well as in all dialects of XQuery and Server-Side JavaScript. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.formatNumber|xdmp.formatNumber} + * @method planBuilder.xdmp#formatNumber + * @since 2.1.1 + * @param { XsNumeric } [value] - The given numeric $value that needs to be formatted. + * @param { XsString } [picture] - The desired string representation of the given numeric $value. The picture string is a sequence of characters, in which the characters represent variables such as, decimal-separator-sign, grouping-sign, zero-digit-sign, digit-sign, pattern-separator, percent sign and per-mille-sign. For details on the picture string, see http://www.w3.org/TR/xslt20/#date-picture-string. Unlike fn:format-number(), here the picture string allows spelled-out (uppercase, lowercase and Capitalcase) formatting. + * @param { XsString } [language] - The desired language for string representation of the numeric $value. An empty sequence must be passed in even if a user doesn't want to specifiy this argument. + * @param { XsString } [letterValue] - Same as letter-value attribute in xsl:number. This argument is ignored during formatting as of now. It may be used in future. An empty sequence must be passed in even if a user doesn't want to specifiy this argument. + * @param { XsString } [ordchar] - If $ordchar is "yes" then ordinal numbering is attempted. If this is any other string, including an empty string, then then cardinal numbering is generated. An empty sequence must be passed in even if a user doesn't want to specifiy this argument. + * @param { XsString } [zeroPadding] - Value of $zero-padding is used to pad integer part of a number on the left and fractional part on the right, if needed. An empty sequence must be passed in even if a user doesn't want to specifiy this argument. + * @param { XsString } [groupingSeparator] - Value of $grouping-separator is a character, used to groups of digits, especially useful in making long sequence of digits more readable. For example, 10,000,000- here "," is used as a separator after each group of three digits. An empty sequence must be passed in even if a user doesn't want to specify this argument. + * @param { XsInteger } [groupingSize] - Represents size of the group, i.e. the number of digits before after which grouping separator is inserted. An empty sequence must be passed in even if a user doesn't want to specifiy this argument. + * @returns { XsString } + */ +formatNumber(...args) { + const namer = bldrbase.getNamer(args, 'value'); + const paramdefs = [['value', [types.XsNumeric, PlanColumn, PlanParam], false, true], ['picture', [types.XsString, PlanColumn, PlanParam], false, false], ['language', [types.XsString, PlanColumn, PlanParam], false, false], ['letter-value', [types.XsString, PlanColumn, PlanParam], false, false], ['ordchar', [types.XsString, PlanColumn, PlanParam], false, false], ['zero-padding', [types.XsString, PlanColumn, PlanParam], false, false], ['grouping-separator', [types.XsString, PlanColumn, PlanParam], false, false], ['grouping-size', [types.XsInteger, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.formatNumber', 1, new Set(['value', 'picture', 'language', 'letter-value', 'ordchar', 'zero-padding', 'grouping-separator', 'grouping-size']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.formatNumber', 1, false, paramdefs, args); + return new types.XsString('xdmp', 'format-number', checkedArgs); + + } +/** + * Atomizes a JSON node, returning a JSON value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.fromJson|xdmp.fromJson} + * @method planBuilder.xdmp#fromJson + * @since 2.1.1 + * @param { Node } [arg] - A node of kind object-node(), array-node(), text(), number-node(), boolean-node(), null-node(), or document-node(). + * @returns { Item } + */ +fromJson(...args) { + const paramdef = ['arg', [types.Node, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.fromJson', 1, paramdef, args); + return new types.Item('xdmp', 'from-json', checkedArgs); + } +/** + * Returns the name of the current user. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.getCurrentUser|xdmp.getCurrentUser} + * @method planBuilder.xdmp#getCurrentUser + * @since 2.1.1 + + * @returns { XsString } + */ +getCurrentUser(...args) { + bldrbase.checkMaxArity('xdmp.getCurrentUser', args.length, 0); + return new types.XsString('xdmp', 'get-current-user', args); + } +/** + * Returns the 32-bit hash of a string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.hash32|xdmp.hash32} + * @method planBuilder.xdmp#hash32 + * @since 2.1.1 + * @param { XsString } [string] - The string to be hashed. + * @returns { XsUnsignedInt } + */ +hash32(...args) { + const paramdef = ['string', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.hash32', 1, paramdef, args); + return new types.XsUnsignedInt('xdmp', 'hash32', checkedArgs); + } +/** + * Returns the 64-bit hash of a string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.hash64|xdmp.hash64} + * @method planBuilder.xdmp#hash64 + * @since 2.1.1 + * @param { XsString } [string] - The string to be hashed. + * @returns { XsUnsignedLong } + */ +hash64(...args) { + const paramdef = ['string', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.hash64', 1, paramdef, args); + return new types.XsUnsignedLong('xdmp', 'hash64', checkedArgs); + } +/** + * Parses a hexadecimal string, returning an integer. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.hexToInteger|xdmp.hexToInteger} + * @method planBuilder.xdmp#hexToInteger + * @since 2.1.1 + * @param { XsString } [hex] - The hexadecimal string. + * @returns { XsInteger } + */ +hexToInteger(...args) { + const paramdef = ['hex', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.hexToInteger', 1, paramdef, args); + return new types.XsInteger('xdmp', 'hex-to-integer', checkedArgs); + } +/** + * Calculates the Hash-based Message Authentication Code (HMAC) using the md5 hash function of the given secret key and message arguments. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.hmacMd5|xdmp.hmacMd5} + * @method planBuilder.xdmp#hmacMd5 + * @since 2.1.1 + * @param { Item } [secretkey] - The secret key. Must be xs:string or a binary node. + * @param { Item } [message] - Message to be authenticated. Must be xs:string or a binary node. + * @param { XsString } [encoding] - Encoding format for the output string, must be "hex" for hexadecimal or "base64". Default is "hex". + * @returns { XsString } + */ +hmacMd5(...args) { + const namer = bldrbase.getNamer(args, 'secretkey'); + const paramdefs = [['secretkey', [types.Item, PlanColumn, PlanParam], true, false], ['message', [types.Item, PlanColumn, PlanParam], true, false], ['encoding', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.hmacMd5', 2, new Set(['secretkey', 'message', 'encoding']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.hmacMd5', 2, false, paramdefs, args); + return new types.XsString('xdmp', 'hmac-md5', checkedArgs); + + } +/** + * Calculates the Hash-based Message Authentication Code (HMAC) using the SHA1 hash function of the given secret key and message arguments. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.hmacSha1|xdmp.hmacSha1} + * @method planBuilder.xdmp#hmacSha1 + * @since 2.1.1 + * @param { Item } [secretkey] - The secret key. Must be xs:string or a binary node. + * @param { Item } [message] - Message to be authenticated. Must be xs:string or a binary node. + * @param { XsString } [encoding] - Encoding format for the output string, must be "hex" for hexadecimal or "base64". Default is "hex". + * @returns { XsString } + */ +hmacSha1(...args) { + const namer = bldrbase.getNamer(args, 'secretkey'); + const paramdefs = [['secretkey', [types.Item, PlanColumn, PlanParam], true, false], ['message', [types.Item, PlanColumn, PlanParam], true, false], ['encoding', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.hmacSha1', 2, new Set(['secretkey', 'message', 'encoding']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.hmacSha1', 2, false, paramdefs, args); + return new types.XsString('xdmp', 'hmac-sha1', checkedArgs); + + } +/** + * Calculates the Hash-based Message Authentication Code (HMAC) using the SHA256 hash function of the given secret key and message arguments. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.hmacSha256|xdmp.hmacSha256} + * @method planBuilder.xdmp#hmacSha256 + * @since 2.1.1 + * @param { Item } [secretkey] - The secret key. Must be xs:string or a binary node. + * @param { Item } [message] - Message to be authenticated. Must be xs:string or a binary node. + * @param { XsString } [encoding] - Encoding format for the output string, must be "hex" for hexadecimal or "base64". Default is "hex". + * @returns { XsString } + */ +hmacSha256(...args) { + const namer = bldrbase.getNamer(args, 'secretkey'); + const paramdefs = [['secretkey', [types.Item, PlanColumn, PlanParam], true, false], ['message', [types.Item, PlanColumn, PlanParam], true, false], ['encoding', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.hmacSha256', 2, new Set(['secretkey', 'message', 'encoding']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.hmacSha256', 2, false, paramdefs, args); + return new types.XsString('xdmp', 'hmac-sha256', checkedArgs); + + } +/** + * Calculates the Hash-based Message Authentication Code (HMAC) using the SHA512 hash function of the given secret key and message arguments. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.hmacSha512|xdmp.hmacSha512} + * @method planBuilder.xdmp#hmacSha512 + * @since 2.1.1 + * @param { Item } [secretkey] - The secret key. Must be xs:string or a binary node. + * @param { Item } [message] - Message to be authenticated. Must be xs:string or a binary node. + * @param { XsString } [encoding] - Encoding format for the output string, must be "hex" for hexadecimal or "base64". Default is "hex". + * @returns { XsString } + */ +hmacSha512(...args) { + const namer = bldrbase.getNamer(args, 'secretkey'); + const paramdefs = [['secretkey', [types.Item, PlanColumn, PlanParam], true, false], ['message', [types.Item, PlanColumn, PlanParam], true, false], ['encoding', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.hmacSha512', 2, new Set(['secretkey', 'message', 'encoding']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.hmacSha512', 2, false, paramdefs, args); + return new types.XsString('xdmp', 'hmac-sha512', checkedArgs); + + } +/** + * Returns the string where the first letter of each token has been uppercased. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.initcap|xdmp.initcap} + * @method planBuilder.xdmp#initcap + * @since 2.1.1 + * @param { XsString } [string] - The string to modify. + * @returns { XsString } + */ +initcap(...args) { + const paramdef = ['string', [types.XsString, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.initcap', 1, paramdef, args); + return new types.XsString('xdmp', 'initcap', checkedArgs); + } +/** + * Returns a hexadecimal representation of an integer. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.integerToHex|xdmp.integerToHex} + * @method planBuilder.xdmp#integerToHex + * @since 2.1.1 + * @param { XsInteger } [val] - The integer value. + * @returns { XsString } + */ +integerToHex(...args) { + const paramdef = ['val', [types.XsInteger, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.integerToHex', 1, paramdef, args); + return new types.XsString('xdmp', 'integer-to-hex', checkedArgs); + } +/** + * Returns an octal representation of an integer. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.integerToOctal|xdmp.integerToOctal} + * @method planBuilder.xdmp#integerToOctal + * @since 2.1.1 + * @param { XsInteger } [val] - The integer value. + * @returns { XsString } + */ +integerToOctal(...args) { + const paramdef = ['val', [types.XsInteger, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.integerToOctal', 1, paramdef, args); + return new types.XsString('xdmp', 'integer-to-octal', checkedArgs); + } +/** + * Construct a context-independent string from a QName. This string is of the form "{namespaceURI}localname" and is suitable for use as a map key. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.keyFromQName|xdmp.keyFromQName} + * @method planBuilder.xdmp#keyFromQName + * @since 2.1.1 + * @param { XsQName } [name] - The QName to compute a key for. + * @returns { XsString } + */ +keyFromQName(...args) { + const paramdef = ['name', [types.XsQName, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.keyFromQName', 1, paramdef, args); + return new types.XsString('xdmp', 'key-from-QName', checkedArgs); + } +/** + * Left-shift a 64-bit integer value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.lshift64|xdmp.lshift64} + * @method planBuilder.xdmp#lshift64 + * @since 2.1.1 + * @param { XsUnsignedLong } [x] - The value to shift. + * @param { XsLong } [y] - The left shift to perform. This value may be negative. + * @returns { XsUnsignedLong } + */ +lshift64(...args) { + const namer = bldrbase.getNamer(args, 'x'); + const paramdefs = [['x', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false], ['y', [types.XsLong, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.lshift64', 2, new Set(['x', 'y']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.lshift64', 2, false, paramdefs, args); + return new types.XsUnsignedLong('xdmp', 'lshift64', checkedArgs); + + } +/** + * Calculates the md5 hash of the given argument. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.md5|xdmp.md5} + * @method planBuilder.xdmp#md5 + * @since 2.1.1 + * @param { Item } [data] - Data to be hashed. Must be xs:string or a binary node. + * @param { XsString } [encoding] - Encoding format for the output string, must be "hex" for hexadecimal or "base64". Default is "hex". + * @returns { XsString } + */ +md5(...args) { + const namer = bldrbase.getNamer(args, 'data'); + const paramdefs = [['data', [types.Item, PlanColumn, PlanParam], true, false], ['encoding', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.md5', 1, new Set(['data', 'encoding']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.md5', 1, false, paramdefs, args); + return new types.XsString('xdmp', 'md5', checkedArgs); + + } +/** + * Returns month name, calculated from the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.monthNameFromDate|xdmp.monthNameFromDate} + * @method planBuilder.xdmp#monthNameFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose month-name will be returned. + * @returns { XsString } + */ +monthNameFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.monthNameFromDate', 1, paramdef, args); + return new types.XsString('xdmp', 'month-name-from-date', checkedArgs); + } +/** + * Muliply two 64-bit integer values, discarding overflow. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.mul64|xdmp.mul64} + * @method planBuilder.xdmp#mul64 + * @since 2.1.1 + * @param { XsUnsignedLong } [x] - The first value. + * @param { XsUnsignedLong } [y] - The second value. + * @returns { XsUnsignedLong } + */ +mul64(...args) { + const namer = bldrbase.getNamer(args, 'x'); + const paramdefs = [['x', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false], ['y', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.mul64', 2, new Set(['x', 'y']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.mul64', 2, false, paramdefs, args); + return new types.XsUnsignedLong('xdmp', 'mul64', checkedArgs); + + } +/** + * Returns any collections for the node's document in the database. If the specified node does not come from a document in a database, then xdmp:node-collections returns an empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.nodeCollections|xdmp.nodeCollections} + * @method planBuilder.xdmp#nodeCollections + * @since 2.1.1 + * @param { Node } [node] - The node whose collections are to be returned. + * @returns { XsString } + */ +nodeCollections(...args) { + const paramdef = ['node', [types.Node, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.nodeCollections', 1, paramdef, args); + return new types.XsString('xdmp', 'node-collections', checkedArgs); + } +/** + * Returns an xs:string representing the node's kind: either "document", "element", "attribute", "text", "namespace", "processing-instruction", "binary", or "comment". Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.nodeKind|xdmp.nodeKind} + * @method planBuilder.xdmp#nodeKind + * @since 2.1.1 + * @param { Node } [node] - The node whose kind is to be returned. + * @returns { XsString } + */ +nodeKind(...args) { + const paramdef = ['node', [types.Node, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.nodeKind', 1, paramdef, args); + return new types.XsString('xdmp', 'node-kind', checkedArgs); + } +/** + * Returns the metadata value of a given node. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.nodeMetadata|xdmp.nodeMetadata} + * @method planBuilder.xdmp#nodeMetadata + * @since 2.1.1 + * @param { Node } [node] - The node whose metadata are to be returned. + * @returns { MapMap } + */ +nodeMetadata(...args) { + const paramdef = ['node', [types.Node, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.nodeMetadata', 1, paramdef, args); + return new types.MapMap('xdmp', 'node-metadata', checkedArgs); + } +/** + * Returns the metadata value of a node for a particular key. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.nodeMetadataValue|xdmp.nodeMetadataValue} + * @method planBuilder.xdmp#nodeMetadataValue + * @since 2.1.1 + * @param { Node } [uri] - The node whose metadata are to be returned. + * @param { XsString } [keyName] - Name of the key for the metadata. + * @returns { XsString } + */ +nodeMetadataValue(...args) { + const namer = bldrbase.getNamer(args, 'uri'); + const paramdefs = [['uri', [types.Node, PlanColumn, PlanParam], true, false], ['keyName', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.nodeMetadataValue', 2, new Set(['uri', 'keyName']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.nodeMetadataValue', 2, false, paramdefs, args); + return new types.XsString('xdmp', 'node-metadata-value', checkedArgs); + + } +/** + * Returns the permissions to a node's document. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.nodePermissions|xdmp.nodePermissions} + * @method planBuilder.xdmp#nodePermissions + * @since 2.1.1 + * @param { Node } [node] - The node. + * @param { XsString } [outputKind] - The output kind. It can be either "elements" or "objects". With "elements", the built-in returns a sequence of XML elements. With "objects", the built-in returns a sequence of map:map. The default is "elements". + * @returns { Item } + */ +nodePermissions(...args) { + const namer = bldrbase.getNamer(args, 'node'); + const paramdefs = [['node', [types.Node, PlanColumn, PlanParam], true, false], ['output-kind', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.nodePermissions', 1, new Set(['node', 'output-kind']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.nodePermissions', 1, false, paramdefs, args); + return new types.Item('xdmp', 'node-permissions', checkedArgs); + + } +/** + * Returns the document-uri property of the parameter or its ancestor. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.nodeUri|xdmp.nodeUri} + * @method planBuilder.xdmp#nodeUri + * @since 2.1.1 + * @param { Node } [node] - The node whose URI is returned. + * @returns { XsString } + */ +nodeUri(...args) { + const paramdef = ['node', [types.Node, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.nodeUri', 1, paramdef, args); + return new types.XsString('xdmp', 'node-uri', checkedArgs); + } +/** + * NOT a 64-bit integer value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.not64|xdmp.not64} + * @method planBuilder.xdmp#not64 + * @since 2.1.1 + * @param { XsUnsignedLong } [x] - The input value. + * @returns { XsUnsignedLong } + */ +not64(...args) { + const paramdef = ['x', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.not64', 1, paramdef, args); + return new types.XsUnsignedLong('xdmp', 'not64', checkedArgs); + } +/** + * Parses an octal string, returning an integer. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.octalToInteger|xdmp.octalToInteger} + * @method planBuilder.xdmp#octalToInteger + * @since 2.1.1 + * @param { XsString } [octal] - The octal string. + * @returns { XsInteger } + */ +octalToInteger(...args) { + const paramdef = ['octal', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.octalToInteger', 1, paramdef, args); + return new types.XsInteger('xdmp', 'octal-to-integer', checkedArgs); + } +/** + * OR two 64-bit integer values. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.or64|xdmp.or64} + * @method planBuilder.xdmp#or64 + * @since 2.1.1 + * @param { XsUnsignedLong } [x] - The first value. + * @param { XsUnsignedLong } [y] - The second value. + * @returns { XsUnsignedLong } + */ +or64(...args) { + const namer = bldrbase.getNamer(args, 'x'); + const paramdefs = [['x', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false], ['y', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.or64', 2, new Set(['x', 'y']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.or64', 2, false, paramdefs, args); + return new types.XsUnsignedLong('xdmp', 'or64', checkedArgs); + + } +/** + * Parses a string containing date, time or dateTime using the supplied picture argument and returns a dateTime value. While this function is closely related to other XSLT functions, it is available in XSLT as well as in all XQuery dialects and in Server-Side JavaScript. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.parseDateTime|xdmp.parseDateTime} + * @method planBuilder.xdmp#parseDateTime + * @since 2.1.1 + * @param { XsString } [picture] - The desired string representation of the given $value. The picture string is a sequence of characters, in which the characters represent variables such as, decimal-separator-sign, grouping-sign, zero-digit-sign, digit-sign, pattern-separator, percent sign and per-mille-sign. For details on the picture string, see http://www.w3.org/TR/xslt20/#date-picture-string. This follows the specification of picture string in the W3C XSLT 2.0 specification for the fn:format-dateTime function. Symbol Description ----------------------------------- 'Y' year(absolute value) 'M' month in year 'D' day in month 'd' day in year 'F' day of week 'W' week in year 'w' week in month 'H' hour in day 'h' hour in half-day 'P' am/pm marker 'm' minute in hour 's' second in minute 'f' fractional seconds 'Z' timezone as a time offset from UTC for example PST 'z' timezone as an offset using GMT, for example GMT+1 + * @param { XsString } [value] - The given string $value representing the dateTime value that needs to be formatted. + * @param { XsString } [language] - The language used in string representation of the date, time or dateTime value. + * @param { XsString } [calendar] - This argument is reserved for future use. The only calendar supported at this point is "Gregorian" or "AD". + * @param { XsString } [country] - $country is used to take into account if there any country specific interpretation of the string while converting it into dateTime value. + * @returns { XsDateTime } + */ +parseDateTime(...args) { + const namer = bldrbase.getNamer(args, 'picture'); + const paramdefs = [['picture', [types.XsString, PlanColumn, PlanParam], true, false], ['value', [types.XsString, PlanColumn, PlanParam], true, false], ['language', [types.XsString, PlanColumn, PlanParam], false, false], ['calendar', [types.XsString, PlanColumn, PlanParam], false, false], ['country', [types.XsString, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.parseDateTime', 2, new Set(['picture', 'value', 'language', 'calendar', 'country']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.parseDateTime', 2, false, paramdefs, args); + return new types.XsDateTime('xdmp', 'parse-dateTime', checkedArgs); + + } +/** + * Parses a string containing date, time or dateTime using the supplied picture argument and returns a dateTime value. While this function is closely related to other XSLT functions, it is available in XSLT as well as in all XQuery dialects and in Server-Side JavaScript. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.parseYymmdd|xdmp.parseYymmdd} + * @method planBuilder.xdmp#parseYymmdd + * @since 2.1.1 + * @param { XsString } [picture] - The desired string representation of the given $value. This follows the specification of picture string which is compatible to the format specification in icu. See http://icu-project.org/apiref/icu4j/com/ibm/icu/text/SimpleDateFormat.html for more details. The following is the summary of the formatting symbols: Symbol Description ---------------------------- "y" year(absolute value) "M" month in year "d" day in month "D" day in year "E" day of week "w" week in year "W" week in month "H" hour in day "K" hour in half-day "a" am/pm marker "s" second in minute "S" fractional seconds "Z" timezone as a time offset from UTC for example PST "ZZZZ" timezone as an offset using GMT, for example GMT+1 + * @param { XsString } [value] - The given string $value that needs to be formatted. + * @param { XsString } [language] - The language used in string representation of the date, time or dateTime value. + * @param { XsString } [calendar] - This argument is reserved for future use. The only calendar supported at this point is "Gregorian" or "AD". + * @param { XsString } [country] - $country is used to take into account if there any country specific interpretation of the string while converting it into dateTime value. + * @returns { XsDateTime } + */ +parseYymmdd(...args) { + const namer = bldrbase.getNamer(args, 'picture'); + const paramdefs = [['picture', [types.XsString, PlanColumn, PlanParam], true, false], ['value', [types.XsString, PlanColumn, PlanParam], true, false], ['language', [types.XsString, PlanColumn, PlanParam], false, false], ['calendar', [types.XsString, PlanColumn, PlanParam], false, false], ['country', [types.XsString, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.parseYymmdd', 2, new Set(['picture', 'value', 'language', 'calendar', 'country']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.parseYymmdd', 2, false, paramdefs, args); + return new types.XsDateTime('xdmp', 'parse-yymmdd', checkedArgs); + + } +/** + * Returns a string whose value corresponds to the path of the node. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.path|xdmp.path} + * @method planBuilder.xdmp#path + * @since 2.1.1 + * @param { Node } [node] - The node whose path is returned. + * @param { XsBoolean } [includeDocument] - If true, then the path is presented with a leading doc(..)/.., otherwise the path is presented as /... + * @returns { XsString } + */ +path(...args) { + const namer = bldrbase.getNamer(args, 'node'); + const paramdefs = [['node', [types.Node, PlanColumn, PlanParam], true, false], ['include-document', [types.XsBoolean, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.path', 1, new Set(['node', 'include-document']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.path', 1, false, paramdefs, args); + return new types.XsString('xdmp', 'path', checkedArgs); + + } +/** + * Returns an integer value representing the starting position of a string within the search string. Note, the string starting position is 1. If the first parameter is empty, the result is the empty sequence. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.position|xdmp.position} + * @method planBuilder.xdmp#position + * @since 2.1.1 + * @param { XsString } [test] - The string to test for existence in the second parameter. + * @param { XsString } [target] - The string from which to test. + * @param { XsString } [collation] - The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. + * @returns { XsInteger } + */ +position(...args) { + const namer = bldrbase.getNamer(args, 'test'); + const paramdefs = [['test', [types.XsString, PlanColumn, PlanParam], false, false], ['target', [types.XsString, PlanColumn, PlanParam], false, false], ['collation', [types.XsString, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.position', 2, new Set(['test', 'target', 'collation']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.position', 2, false, paramdefs, args); + return new types.XsInteger('xdmp', 'position', checkedArgs); + + } +/** + * Construct a QName from a string of the form "{namespaceURI}localname". This function is useful for constructing Clark notation parameters for the xdmp:xslt-eval and xdmp:xslt-invoke functions. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.QNameFromKey|xdmp.QNameFromKey} + * @method planBuilder.xdmp#QNameFromKey + * @since 2.1.1 + * @param { XsString } [key] - The string from which to construct a QName. + * @returns { XsQName } + */ +QNameFromKey(...args) { + const paramdef = ['key', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.QNameFromKey', 1, paramdef, args); + return new types.XsQName('xdmp', 'QName-from-key', checkedArgs); + } +/** + * Returns an xs:integer between 1 and 4, both inclusive, calculating the quarter component in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.quarterFromDate|xdmp.quarterFromDate} + * @method planBuilder.xdmp#quarterFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose quarter component will be returned. + * @returns { XsInteger } + */ +quarterFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.quarterFromDate', 1, paramdef, args); + return new types.XsInteger('xdmp', 'quarter-from-date', checkedArgs); + } +/** + * Returns a random unsigned integer between 0 and a number up to 64 bits long. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.random|xdmp.random} + * @method planBuilder.xdmp#random + * @since 2.1.1 + * @param { XsUnsignedLong } [max] - The optional maximum value (inclusive). + * @returns { XsUnsignedLong } + */ +random(...args) { + const paramdef = ['max', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.random', 0, paramdef, args); + return new types.XsUnsignedLong('xdmp', 'random', checkedArgs); + } +/** + * Resolves a relative URI against an absolute URI. If base is specified, the URI is resolved relative to that base. If base is not specified, the base is set to the base-uri property from the static context, if the property exists; if it does not exist, an error is thrown. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.resolveUri|xdmp.resolveUri} + * @method planBuilder.xdmp#resolveUri + * @since 2.1.1 + * @param { XsString } [relative] - A URI reference to resolve against the base. + * @param { XsString } [base] - An absolute URI to use as the base of the resolution. + * @returns { XsAnyURI } + */ +resolveUri(...args) { + const namer = bldrbase.getNamer(args, 'relative'); + const paramdefs = [['relative', [types.XsString, PlanColumn, PlanParam], false, false], ['base', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.resolveUri', 2, new Set(['relative', 'base']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.resolveUri', 2, false, paramdefs, args); + return new types.XsAnyURI('xdmp', 'resolve-uri', checkedArgs); + + } +/** + * Right-shift a 64-bit integer value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.rshift64|xdmp.rshift64} + * @method planBuilder.xdmp#rshift64 + * @since 2.1.1 + * @param { XsUnsignedLong } [x] - The value to shift. + * @param { XsLong } [y] - The right shift to perform. This value may be negative. + * @returns { XsUnsignedLong } + */ +rshift64(...args) { + const namer = bldrbase.getNamer(args, 'x'); + const paramdefs = [['x', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false], ['y', [types.XsLong, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.rshift64', 2, new Set(['x', 'y']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.rshift64', 2, false, paramdefs, args); + return new types.XsUnsignedLong('xdmp', 'rshift64', checkedArgs); + + } +/** + * Calculates the SHA1 hash of the given argument. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.sha1|xdmp.sha1} + * @method planBuilder.xdmp#sha1 + * @since 2.1.1 + * @param { Item } [data] - Data to be hashed. Must be xs:string or a binary node. + * @param { XsString } [encoding] - Encoding format for the output string, must be "hex" for hexadecimal or "base64". Default is "hex". + * @returns { XsString } + */ +sha1(...args) { + const namer = bldrbase.getNamer(args, 'data'); + const paramdefs = [['data', [types.Item, PlanColumn, PlanParam], true, false], ['encoding', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.sha1', 1, new Set(['data', 'encoding']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.sha1', 1, false, paramdefs, args); + return new types.XsString('xdmp', 'sha1', checkedArgs); + + } +/** + * Calculates the SHA256 hash of the given argument. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.sha256|xdmp.sha256} + * @method planBuilder.xdmp#sha256 + * @since 2.1.1 + * @param { Item } [data] - Data to be hashed. Must be xs:string or a binary node. + * @param { XsString } [encoding] - Encoding format for the output string, must be "hex" for hexadecimal or "base64". Default is "hex". + * @returns { XsString } + */ +sha256(...args) { + const namer = bldrbase.getNamer(args, 'data'); + const paramdefs = [['data', [types.Item, PlanColumn, PlanParam], true, false], ['encoding', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.sha256', 1, new Set(['data', 'encoding']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.sha256', 1, false, paramdefs, args); + return new types.XsString('xdmp', 'sha256', checkedArgs); + + } +/** + * Calculates the SHA384 hash of the given argument. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.sha384|xdmp.sha384} + * @method planBuilder.xdmp#sha384 + * @since 2.1.1 + * @param { Item } [data] - Data to be hashed. Must be xs:string or a binary node. + * @param { XsString } [encoding] - Encoding format for the output string, must be "hex" for hexadecimal or "base64". Default is "hex". + * @returns { XsString } + */ +sha384(...args) { + const namer = bldrbase.getNamer(args, 'data'); + const paramdefs = [['data', [types.Item, PlanColumn, PlanParam], true, false], ['encoding', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.sha384', 1, new Set(['data', 'encoding']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.sha384', 1, false, paramdefs, args); + return new types.XsString('xdmp', 'sha384', checkedArgs); + + } +/** + * Calculates the SHA512 hash of the given argument. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.sha512|xdmp.sha512} + * @method planBuilder.xdmp#sha512 + * @since 2.1.1 + * @param { Item } [data] - Data to be hashed. Must be xs:string or a binary node. + * @param { XsString } [encoding] - Encoding format for the output string, must be "hex" for hexadecimal or "base64". Default is "hex". + * @returns { XsString } + */ +sha512(...args) { + const namer = bldrbase.getNamer(args, 'data'); + const paramdefs = [['data', [types.Item, PlanColumn, PlanParam], true, false], ['encoding', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.sha512', 1, new Set(['data', 'encoding']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.sha512', 1, false, paramdefs, args); + return new types.XsString('xdmp', 'sha512', checkedArgs); + + } +/** + * Combines an initial hash with a subsequent hash. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.step64|xdmp.step64} + * @method planBuilder.xdmp#step64 + * @since 2.1.1 + * @param { XsUnsignedLong } [initial] - An initial hash. + * @param { XsUnsignedLong } [step] - A step hash to be combined with the initial hash. + * @returns { XsUnsignedLong } + */ +step64(...args) { + const namer = bldrbase.getNamer(args, 'initial'); + const paramdefs = [['initial', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false], ['step', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.step64', 2, new Set(['initial', 'step']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.step64', 2, false, paramdefs, args); + return new types.XsUnsignedLong('xdmp', 'step64', checkedArgs); + + } +/** + * Formats a dateTime value using POSIX strftime. This function uses the POSIX strftime system call in the way it is implemented on each platform. For other XQuery functions that have more functionality (for example, for things like timezones), use one or more if the various XQuery or XSLT standard functions such as fn:format-dateTime. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.strftime|xdmp.strftime} + * @method planBuilder.xdmp#strftime + * @since 2.1.1 + * @param { XsString } [format] - The strftime format string. + * @param { XsDateTime } [value] - The dateTime value. + * @returns { XsString } + */ +strftime(...args) { + const namer = bldrbase.getNamer(args, 'format'); + const paramdefs = [['format', [types.XsString, PlanColumn, PlanParam], true, false], ['value', [types.XsDateTime, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.strftime', 2, new Set(['format', 'value']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.strftime', 2, false, paramdefs, args); + return new types.XsString('xdmp', 'strftime', checkedArgs); + + } +/** + * Converts a 64 bit timestamp value to an xs:dateTime. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.timestampToWallclock|xdmp.timestampToWallclock} + * @method planBuilder.xdmp#timestampToWallclock + * @since 2.1.1 + * @param { XsUnsignedLong } [timestamp] - The timestamp. + * @returns { XsDateTime } + */ +timestampToWallclock(...args) { + const paramdef = ['timestamp', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.timestampToWallclock', 1, paramdef, args); + return new types.XsDateTime('xdmp', 'timestamp-to-wallclock', checkedArgs); + } +/** + * Constructs a JSON document. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.toJson|xdmp.toJson} + * @method planBuilder.xdmp#toJson + * @since 2.1.1 + * @param { Item } [item] - A sequence of items from which the JSON document is to be constructed. The item sequence from which the JSON document is constructed. + * @returns { Node } + */ +toJson(...args) { + const paramdef = ['item', [types.Item, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.toJson', 1, paramdef, args); + return new types.Node('xdmp', 'to-json', checkedArgs); + } +/** + * Returns the name of the simple type of the atomic value argument as an xs:QName. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.type|xdmp.type} + * @method planBuilder.xdmp#type + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - The value to return the type of. + * @returns { XsQName } + */ +type(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.type', 1, paramdef, args); + return new types.XsQName('xdmp', 'type', checkedArgs); + } +/** + * Converts URL-encoded string to plaintext. This decodes the string created with xdmp:url-encode. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.urlDecode|xdmp.urlDecode} + * @method planBuilder.xdmp#urlDecode + * @since 2.1.1 + * @param { XsString } [encoded] - Encoded text to be decoded. + * @returns { XsString } + */ +urlDecode(...args) { + const paramdef = ['encoded', [types.XsString, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.urlDecode', 1, paramdef, args); + return new types.XsString('xdmp', 'url-decode', checkedArgs); + } +/** + * Converts plaintext into URL-encoded string. To decode the string, use xdmp:url-decode. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.urlEncode|xdmp.urlEncode} + * @method planBuilder.xdmp#urlEncode + * @since 2.1.1 + * @param { XsString } [plaintext] - Plaintext to be encoded. + * @param { XsBoolean } [noSpacePlus] - True to encode space as "%20" instead of "+". + * @returns { XsString } + */ +urlEncode(...args) { + const namer = bldrbase.getNamer(args, 'plaintext'); + const paramdefs = [['plaintext', [types.XsString, PlanColumn, PlanParam], true, false], ['noSpacePlus', [types.XsBoolean, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.urlEncode', 1, new Set(['plaintext', 'noSpacePlus']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.urlEncode', 1, false, paramdefs, args); + return new types.XsString('xdmp', 'url-encode', checkedArgs); + + } +/** + * Converts an xs:dateTime to a 64 bit timestamp value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.wallclockToTimestamp|xdmp.wallclockToTimestamp} + * @method planBuilder.xdmp#wallclockToTimestamp + * @since 2.1.1 + * @param { XsDateTime } [timestamp] - The xs:datetime value. + * @returns { XsUnsignedLong } + */ +wallclockToTimestamp(...args) { + const paramdef = ['timestamp', [types.XsDateTime, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.wallclockToTimestamp', 1, paramdef, args); + return new types.XsUnsignedLong('xdmp', 'wallclock-to-timestamp', checkedArgs); + } +/** + * Returns an xs:integer between 1 and 53, both inclusive, representing the week value in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.weekFromDate|xdmp.weekFromDate} + * @method planBuilder.xdmp#weekFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose weeks of the year will be returned. + * @returns { XsInteger } + */ +weekFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.weekFromDate', 1, paramdef, args); + return new types.XsInteger('xdmp', 'week-from-date', checkedArgs); + } +/** + * Returns an xs:integer in the range 1 to 7, inclusive, representing the weekday value in the localized value of arg. Monday is the first weekday value (value of 1), and Sunday is the last (value of 7). Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.weekdayFromDate|xdmp.weekdayFromDate} + * @method planBuilder.xdmp#weekdayFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose weekday value will be returned. + * @returns { XsInteger } + */ +weekdayFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.weekdayFromDate', 1, paramdef, args); + return new types.XsInteger('xdmp', 'weekday-from-date', checkedArgs); + } +/** + * XOR two 64-bit integer values. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.xor64|xdmp.xor64} + * @method planBuilder.xdmp#xor64 + * @since 2.1.1 + * @param { XsUnsignedLong } [x] - The first value. + * @param { XsUnsignedLong } [y] - The second value. + * @returns { XsUnsignedLong } + */ +xor64(...args) { + const namer = bldrbase.getNamer(args, 'x'); + const paramdefs = [['x', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false], ['y', [types.XsUnsignedLong, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'xdmp.xor64', 2, new Set(['x', 'y']), paramdefs, args) : + bldrbase.makePositionalArgs('xdmp.xor64', 2, false, paramdefs, args); + return new types.XsUnsignedLong('xdmp', 'xor64', checkedArgs); + + } +/** + * Returns an xs:integer between 1 and 366, both inclusive, representing the yearday value in the localized value of arg. Provides a client interface to a server function. See {@link http://docs.marklogic.com/xdmp.yeardayFromDate|xdmp.yeardayFromDate} + * @method planBuilder.xdmp#yeardayFromDate + * @since 2.1.1 + * @param { XsDate } [arg] - The date whose days of the year will be returned. + * @returns { XsInteger } + */ +yeardayFromDate(...args) { + const paramdef = ['arg', [types.XsDate, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xdmp.yeardayFromDate', 1, paramdef, args); + return new types.XsInteger('xdmp', 'yearday-from-date', checkedArgs); + } +} +class XsExpr { + constructor() { + } + /** + * Constructs or casts an expression to a XsAnyURI object. Provides a client interface to a server function. + * @method planBuilder.xs#anyURI + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsAnyURI } + */ +anyURI(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.anyURI', 1, paramdef, args); + return new types.XsAnyURI('xs', 'anyURI', checkedArgs); + } +/** + * Constructs or casts an expression to a XsBase64Binary object. Provides a client interface to a server function. + * @method planBuilder.xs#base64Binary + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsBase64Binary } + */ +base64Binary(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.base64Binary', 1, paramdef, args); + return new types.XsBase64Binary('xs', 'base64Binary', checkedArgs); + } +/** + * Constructs or casts an expression to a XsBoolean object. Provides a client interface to a server function. + * @method planBuilder.xs#boolean + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsBoolean } + */ +boolean(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.boolean', 1, paramdef, args); + return new types.XsBoolean('xs', 'boolean', checkedArgs); + } +/** + * Constructs or casts an expression to a XsByte object. Provides a client interface to a server function. + * @method planBuilder.xs#byte + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsByte } + */ +byte(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.byte', 1, paramdef, args); + return new types.XsByte('xs', 'byte', checkedArgs); + } +/** + * Constructs or casts an expression to a XsDate object. Provides a client interface to a server function. + * @method planBuilder.xs#date + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsDate } + */ +date(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.date', 1, paramdef, args); + return new types.XsDate('xs', 'date', checkedArgs); + } +/** + * Constructs or casts an expression to a XsDateTime object. Provides a client interface to a server function. + * @method planBuilder.xs#dateTime + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsDateTime } + */ +dateTime(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.dateTime', 1, paramdef, args); + return new types.XsDateTime('xs', 'dateTime', checkedArgs); + } +/** + * Constructs or casts an expression to a XsDayTimeDuration object. Provides a client interface to a server function. + * @method planBuilder.xs#dayTimeDuration + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsDayTimeDuration } + */ +dayTimeDuration(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.dayTimeDuration', 1, paramdef, args); + return new types.XsDayTimeDuration('xs', 'dayTimeDuration', checkedArgs); + } +/** + * Constructs or casts an expression to a XsDecimal object. Provides a client interface to a server function. + * @method planBuilder.xs#decimal + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsDecimal } + */ +decimal(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.decimal', 1, paramdef, args); + return new types.XsDecimal('xs', 'decimal', checkedArgs); + } +/** + * Constructs or casts an expression to a XsDouble object. Provides a client interface to a server function. + * @method planBuilder.xs#double + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsDouble } + */ +double(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.double', 1, paramdef, args); + return new types.XsDouble('xs', 'double', checkedArgs); + } +/** + * Constructs or casts an expression to a XsFloat object. Provides a client interface to a server function. + * @method planBuilder.xs#float + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsFloat } + */ +float(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.float', 1, paramdef, args); + return new types.XsFloat('xs', 'float', checkedArgs); + } +/** + * Constructs or casts an expression to a XsGDay object. Provides a client interface to a server function. + * @method planBuilder.xs#gDay + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsGDay } + */ +gDay(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.gDay', 1, paramdef, args); + return new types.XsGDay('xs', 'gDay', checkedArgs); + } +/** + * Constructs or casts an expression to a XsGMonth object. Provides a client interface to a server function. + * @method planBuilder.xs#gMonth + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsGMonth } + */ +gMonth(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.gMonth', 1, paramdef, args); + return new types.XsGMonth('xs', 'gMonth', checkedArgs); + } +/** + * Constructs or casts an expression to a XsGMonthDay object. Provides a client interface to a server function. + * @method planBuilder.xs#gMonthDay + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsGMonthDay } + */ +gMonthDay(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.gMonthDay', 1, paramdef, args); + return new types.XsGMonthDay('xs', 'gMonthDay', checkedArgs); + } +/** + * Constructs or casts an expression to a XsGYear object. Provides a client interface to a server function. + * @method planBuilder.xs#gYear + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsGYear } + */ +gYear(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.gYear', 1, paramdef, args); + return new types.XsGYear('xs', 'gYear', checkedArgs); + } +/** + * Constructs or casts an expression to a XsGYearMonth object. Provides a client interface to a server function. + * @method planBuilder.xs#gYearMonth + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsGYearMonth } + */ +gYearMonth(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.gYearMonth', 1, paramdef, args); + return new types.XsGYearMonth('xs', 'gYearMonth', checkedArgs); + } +/** + * Constructs or casts an expression to a XsHexBinary object. Provides a client interface to a server function. + * @method planBuilder.xs#hexBinary + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsHexBinary } + */ +hexBinary(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.hexBinary', 1, paramdef, args); + return new types.XsHexBinary('xs', 'hexBinary', checkedArgs); + } +/** + * Constructs or casts an expression to a XsInt object. Provides a client interface to a server function. + * @method planBuilder.xs#int + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsInt } + */ +int(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.int', 1, paramdef, args); + return new types.XsInt('xs', 'int', checkedArgs); + } +/** + * Constructs or casts an expression to a XsInteger object. Provides a client interface to a server function. + * @method planBuilder.xs#integer + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsInteger } + */ +integer(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.integer', 1, paramdef, args); + return new types.XsInteger('xs', 'integer', checkedArgs); + } +/** + * Constructs or casts an expression to a XsLanguage object. Provides a client interface to a server function. + * @method planBuilder.xs#language + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsLanguage } + */ +language(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.language', 1, paramdef, args); + return new types.XsLanguage('xs', 'language', checkedArgs); + } +/** + * Constructs or casts an expression to a XsLong object. Provides a client interface to a server function. + * @method planBuilder.xs#long + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsLong } + */ +long(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.long', 1, paramdef, args); + return new types.XsLong('xs', 'long', checkedArgs); + } +/** + * Constructs or casts an expression to a XsName object. Provides a client interface to a server function. + * @method planBuilder.xs#Name + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsName } + */ +Name(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.Name', 1, paramdef, args); + return new types.XsName('xs', 'Name', checkedArgs); + } +/** + * Constructs or casts an expression to a XsNCName object. Provides a client interface to a server function. + * @method planBuilder.xs#NCName + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsNCName } + */ +NCName(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.NCName', 1, paramdef, args); + return new types.XsNCName('xs', 'NCName', checkedArgs); + } +/** + * Constructs or casts an expression to a XsNegativeInteger object. Provides a client interface to a server function. + * @method planBuilder.xs#negativeInteger + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsNegativeInteger } + */ +negativeInteger(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.negativeInteger', 1, paramdef, args); + return new types.XsNegativeInteger('xs', 'negativeInteger', checkedArgs); + } +/** + * Constructs or casts an expression to a XsNMTOKEN object. Provides a client interface to a server function. + * @method planBuilder.xs#NMTOKEN + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsNMTOKEN } + */ +NMTOKEN(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.NMTOKEN', 1, paramdef, args); + return new types.XsNMTOKEN('xs', 'NMTOKEN', checkedArgs); + } +/** + * Constructs or casts an expression to a XsNonNegativeInteger object. Provides a client interface to a server function. + * @method planBuilder.xs#nonNegativeInteger + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsNonNegativeInteger } + */ +nonNegativeInteger(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.nonNegativeInteger', 1, paramdef, args); + return new types.XsNonNegativeInteger('xs', 'nonNegativeInteger', checkedArgs); + } +/** + * Constructs or casts an expression to a XsNonPositiveInteger object. Provides a client interface to a server function. + * @method planBuilder.xs#nonPositiveInteger + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsNonPositiveInteger } + */ +nonPositiveInteger(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.nonPositiveInteger', 1, paramdef, args); + return new types.XsNonPositiveInteger('xs', 'nonPositiveInteger', checkedArgs); + } +/** + * Constructs or casts an expression to a XsNormalizedString object. Provides a client interface to a server function. + * @method planBuilder.xs#normalizedString + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsNormalizedString } + */ +normalizedString(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.normalizedString', 1, paramdef, args); + return new types.XsNormalizedString('xs', 'normalizedString', checkedArgs); + } +/** + * Constructs or casts an expression to a XsNumeric object. Provides a client interface to a server function. + * @method planBuilder.xs#numeric + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsNumeric } + */ +numeric(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.numeric', 1, paramdef, args); + return new types.XsNumeric('xs', 'numeric', checkedArgs); + } +/** + * Constructs or casts an expression to a XsPositiveInteger object. Provides a client interface to a server function. + * @method planBuilder.xs#positiveInteger + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsPositiveInteger } + */ +positiveInteger(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.positiveInteger', 1, paramdef, args); + return new types.XsPositiveInteger('xs', 'positiveInteger', checkedArgs); + } +/** + * Constructs or casts an expression to a XsQName object. Provides a client interface to a server function. + * @method planBuilder.xs#QName + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsQName } + */ +QName(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.QName', 1, paramdef, args); + return new types.XsQName('xs', 'QName', checkedArgs); + } +/** + * Constructs or casts an expression to a XsShort object. Provides a client interface to a server function. + * @method planBuilder.xs#short + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsShort } + */ +short(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.short', 1, paramdef, args); + return new types.XsShort('xs', 'short', checkedArgs); + } +/** + * Constructs or casts an expression to a XsString object. Provides a client interface to a server function. + * @method planBuilder.xs#string + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsString } + */ +string(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.string', 1, paramdef, args); + return new types.XsString('xs', 'string', checkedArgs); + } +/** + * Constructs or casts an expression to a XsTime object. Provides a client interface to a server function. + * @method planBuilder.xs#time + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsTime } + */ +time(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.time', 1, paramdef, args); + return new types.XsTime('xs', 'time', checkedArgs); + } +/** + * Constructs or casts an expression to a XsToken object. Provides a client interface to a server function. + * @method planBuilder.xs#token + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsToken } + */ +token(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.token', 1, paramdef, args); + return new types.XsToken('xs', 'token', checkedArgs); + } +/** + * Constructs or casts an expression to a XsUnsignedByte object. Provides a client interface to a server function. + * @method planBuilder.xs#unsignedByte + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsUnsignedByte } + */ +unsignedByte(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.unsignedByte', 1, paramdef, args); + return new types.XsUnsignedByte('xs', 'unsignedByte', checkedArgs); + } +/** + * Constructs or casts an expression to a XsUnsignedInt object. Provides a client interface to a server function. + * @method planBuilder.xs#unsignedInt + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsUnsignedInt } + */ +unsignedInt(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.unsignedInt', 1, paramdef, args); + return new types.XsUnsignedInt('xs', 'unsignedInt', checkedArgs); + } +/** + * Constructs or casts an expression to a XsUnsignedLong object. Provides a client interface to a server function. + * @method planBuilder.xs#unsignedLong + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsUnsignedLong } + */ +unsignedLong(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.unsignedLong', 1, paramdef, args); + return new types.XsUnsignedLong('xs', 'unsignedLong', checkedArgs); + } +/** + * Constructs or casts an expression to a XsUnsignedShort object. Provides a client interface to a server function. + * @method planBuilder.xs#unsignedShort + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsUnsignedShort } + */ +unsignedShort(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.unsignedShort', 1, paramdef, args); + return new types.XsUnsignedShort('xs', 'unsignedShort', checkedArgs); + } +/** + * Constructs or casts an expression to a XsUntypedAtomic object. Provides a client interface to a server function. + * @method planBuilder.xs#untypedAtomic + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsUntypedAtomic } + */ +untypedAtomic(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.untypedAtomic', 1, paramdef, args); + return new types.XsUntypedAtomic('xs', 'untypedAtomic', checkedArgs); + } +/** + * Constructs or casts an expression to a XsYearMonthDuration object. Provides a client interface to a server function. + * @method planBuilder.xs#yearMonthDuration + * @since 2.1.1 + * @param { XsAnyAtomicType } [arg1] - the expression to construct or cast + * @returns { XsYearMonthDuration } + */ +yearMonthDuration(...args) { + const paramdef = ['arg1', [types.XsAnyAtomicType, types.Node, PlanColumn, PlanParam], false, false]; + const checkedArgs = bldrbase.makeSingleArgs('xs.yearMonthDuration', 1, paramdef, args); + return new types.XsYearMonthDuration('xs', 'yearMonthDuration', checkedArgs); + } +}class PlanTripleOption extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanValueOption extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanExprCol extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanJoinKey extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanTriplePattern extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanParamBinding extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanCase extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanFunction extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanJsonProperty extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanCtsReferenceMap extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanParam extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanSortKey extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanAggregateCol extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanXsValueMap extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanCondition extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +/** + * Plan objects have methods. + * @namespace planBuilder.Plan + * @since 2.1.1 + */ +class PlanPlan extends types.ServerType { + + constructor(prior, ns, fn, args) { + super(ns, fn, args); + this._operators = (prior === null) ? [this] : prior._operators.concat(this); + } + export() { + return bldrbase.doExport(this); + } +/** + * Provides a client interface to a server function. + * @method planBuilder.Plan#bindParam + * @since 2.1.1 + * @param { PlanParamName } [param] - + * @param { PlanParamBinding } [literal] - + * @returns { planBuilder.Plan } + */ +bindParam(...args) { + const namer = bldrbase.getNamer(args, 'param'); + const paramdefs = [['param', [PlanParam, types.XsString], true, false], ['literal', [PlanParamBinding], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanPlan.bindParam', 2, new Set(['param', 'literal']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanPlan.bindParam', 2, false, paramdefs, args); + return new PlanPlan(this, 'op', 'bind-param', checkedArgs); + + } +} +/** + * Prefixer objects have methods. + * @namespace planBuilder.Prefixer + * @since 2.1.1 + */ +class PlanPrefixer extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } +/** + * Provides a client interface to a server function. + * @method planBuilder.Prefixer#iri + * @since 2.1.1 + * @param { XsString } [name] - + * @returns { SemIri } + */ +iri(...args) { + const paramdef = ['name', [types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanPrefixer.iri', 1, paramdef, args); + return new types.SemIri('op', 'iri', checkedArgs); + } +} +class PlanColumn extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanGroupConcatOption extends types.ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class PlanExportablePlan extends PlanPlan { + + constructor(prior, ns, fn, args) { + super(prior, ns, fn, args); + } + +} +class PlanSystemColumn extends PlanColumn { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +/** + * PreparePlan objects have methods. + * @namespace planBuilder.PreparePlan + * @since 2.1.1 + */ +class PlanPreparePlan extends PlanExportablePlan { + + constructor(prior, ns, fn, args) { + super(prior, ns, fn, args); + } +/** + * This method applies the specified function to each row returned by the plan to produce a different result row. Provides a client interface to a server function. See {@link http://docs.marklogic.com/PreparePlan.prototype.map|PreparePlan.prototype.map} + * @method planBuilder.PreparePlan#map + * @since 2.1.1 + * @param { PlanFunction } [func] - The function to be appied. + * @returns { planBuilder.PlanExportablePlan } + */ +map(...args) { + const paramdef = ['func', [PlanFunction], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanPreparePlan.map', 1, paramdef, args); + return new PlanExportablePlan(this, 'op', 'map', checkedArgs); + } +/** + * This method applies a function or the builtin reducer to each row returned by the plan to produce a single result as with the reduce() method of JavaScript Array. Provides a client interface to a server function. See {@link http://docs.marklogic.com/PreparePlan.prototype.reduce|PreparePlan.prototype.reduce} + * @method planBuilder.PreparePlan#reduce + * @since 2.1.1 + * @param { PlanFunction } [func] - The function to be appied. + * @param { XsAnyAtomicType } [seed] - The value returned by the previous request. + * @returns { planBuilder.PlanExportablePlan } + */ +reduce(...args) { + const namer = bldrbase.getNamer(args, 'func'); + const paramdefs = [['func', [PlanFunction], true, false], ['seed', [types.XsAnyAtomicType], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanPreparePlan.reduce', 1, new Set(['func', 'seed']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanPreparePlan.reduce', 1, false, paramdefs, args); + return new PlanExportablePlan(this, 'op', 'reduce', checkedArgs); + + } +} +/** + * ModifyPlan objects have methods and inherit {@link planBuilder.PreparePlan} methods. + * @namespace planBuilder.ModifyPlan + * @since 2.1.1 + */ +class PlanModifyPlan extends PlanPreparePlan { + + constructor(prior, ns, fn, args) { + super(prior, ns, fn, args); + } +/** + * This method restricts the left row set to rows where a row with the same columns and values doesn't exist in the right row set. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.except|ModifyPlan.prototype.except} + * @method planBuilder.ModifyPlan#except + * @since 2.1.1 + * @param { PlanModifyPlan } [right] - The row set from the right view. + * @returns { planBuilder.ModifyPlan } + */ +except(...args) { + const paramdef = ['right', [PlanModifyPlan], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanModifyPlan.except', 1, paramdef, args); + return new PlanModifyPlan(this, 'op', 'except', checkedArgs); + } +/** + * This method collapses a group of rows into a single row. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.groupBy|ModifyPlan.prototype.groupBy} + * @method planBuilder.ModifyPlan#groupBy + * @since 2.1.1 + * @param { PlanExprColName } [keys] - This parameter specifies the columns used to determine the groups. Rows with the same values in these columns are consolidated into a single group. The columns can be existing columns or new columns created by an expression specified with op:as. The rows produced by the group by operation include the key columns. Specify an empty sequence to create a single group for all of the rows in the row set. + * @param { PlanAggregateColName } [aggregates] - This parameter specifies either new columns for aggregate functions over the rows in the group or columndefs that are constant for the group. The aggregate library functions are listed below. + * @returns { planBuilder.ModifyPlan } + */ +groupBy(...args) { + const namer = bldrbase.getNamer(args, 'keys'); + const paramdefs = [['keys', [PlanExprCol, PlanColumn, types.XsString], false, true], ['aggregates', [PlanAggregateCol, PlanColumn, PlanExprCol, types.XsString], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanModifyPlan.groupBy', 1, new Set(['keys', 'aggregates']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanModifyPlan.groupBy', 1, false, paramdefs, args); + return new PlanModifyPlan(this, 'op', 'group-by', checkedArgs); + + } +/** + * This method restricts the left row set to rows where a row with the same columns and values exists in the right row set. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.intersect|ModifyPlan.prototype.intersect} + * @method planBuilder.ModifyPlan#intersect + * @since 2.1.1 + * @param { PlanModifyPlan } [right] - The row set from the right view. + * @returns { planBuilder.ModifyPlan } + */ +intersect(...args) { + const paramdef = ['right', [PlanModifyPlan], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanModifyPlan.intersect', 1, paramdef, args); + return new PlanModifyPlan(this, 'op', 'intersect', checkedArgs); + } +/** + * This method yields one output row set that concatenates every left row with every right row. Matches other than equality matches (for instance, greater-than comparisons between keys) can be implemented with a condition on the cross product. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.joinCrossProduct|ModifyPlan.prototype.joinCrossProduct} + * @method planBuilder.ModifyPlan#joinCrossProduct + * @since 2.1.1 + * @param { PlanModifyPlan } [right] - The row set from the right view. + * @param { XsBoolean } [condition] - A boolean expression that filters the join output rows. + * @returns { planBuilder.ModifyPlan } + */ +joinCrossProduct(...args) { + const namer = bldrbase.getNamer(args, 'right'); + const paramdefs = [['right', [PlanModifyPlan], true, false], ['condition', [types.XsBoolean, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanModifyPlan.joinCrossProduct', 1, new Set(['right', 'condition']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanModifyPlan.joinCrossProduct', 1, false, paramdefs, args); + return new PlanModifyPlan(this, 'op', 'join-cross-product', checkedArgs); + + } +/** + * This function specifies a document column to add to the rows by reading the documents for an existing source column having a value of a document uri (which can be used to read other documents) or a fragment id (which can be used to read the source documents for rows). Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.joinDoc|ModifyPlan.prototype.joinDoc} + * @method planBuilder.ModifyPlan#joinDoc + * @since 2.1.1 + * @param { PlanColumnName } [docCol] - The document column to add to the rows. This can be a string or column specifying the name of the new column that should have the document as its value. + * @param { PlanColumn } [sourceCol] - The document uri or fragment id value. This is either the output from op:fragment-id-col specifying a fragment id column or a document uri column. Joining on a fragment id is more efficient than joining on a uri column. + * @returns { planBuilder.ModifyPlan } + */ +joinDoc(...args) { + const namer = bldrbase.getNamer(args, 'docCol'); + const paramdefs = [['docCol', [PlanColumn, types.XsString], true, false], ['sourceCol', [PlanColumn], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanModifyPlan.joinDoc', 2, new Set(['docCol', 'sourceCol']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanModifyPlan.joinDoc', 2, false, paramdefs, args); + return new PlanModifyPlan(this, 'op', 'join-doc', checkedArgs); + + } +/** + * This method adds a uri column to rows based on an existing fragment id column to identify the source document for each row. The fragmentIdCol must be an op:fragment-id-col specifying a fragment id column. If the fragment id column is null in the row, the row is dropped from the rowset. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.joinDocUri|ModifyPlan.prototype.joinDocUri} + * @method planBuilder.ModifyPlan#joinDocUri + * @since 2.1.1 + * @param { PlanColumnName } [uriCol] - The document uri. This is the output from op:col('uri') that specifies a document uri column. + * @param { PlanColumn } [fragmentIdCol] - The document fragment id value. This is the output from op:fragment-id-col specifying a fragment id column. + * @returns { planBuilder.ModifyPlan } + */ +joinDocUri(...args) { + const namer = bldrbase.getNamer(args, 'uriCol'); + const paramdefs = [['uriCol', [PlanColumn, types.XsString], true, false], ['fragmentIdCol', [PlanColumn], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanModifyPlan.joinDocUri', 2, new Set(['uriCol', 'fragmentIdCol']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanModifyPlan.joinDocUri', 2, false, paramdefs, args); + return new PlanModifyPlan(this, 'op', 'join-doc-uri', checkedArgs); + + } +/** + * This method returns all rows from multiple tables where the join condition is met. In the output row set, each row concatenates one left row and one right row for each match between the keys in the left and right row sets. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.joinInner|ModifyPlan.prototype.joinInner} + * @method planBuilder.ModifyPlan#joinInner + * @since 2.1.1 + * @param { PlanModifyPlan } [right] - The row set from the right view. + * @param { PlanJoinKey } [keys] - The equijoin from one or more calls to the op:on function. + * @param { XsBoolean } [condition] - A boolean expression that filters the join output rows. + * @returns { planBuilder.ModifyPlan } + */ +joinInner(...args) { + const namer = bldrbase.getNamer(args, 'right'); + const paramdefs = [['right', [PlanModifyPlan], true, false], ['keys', [PlanJoinKey], false, true], ['condition', [types.XsBoolean, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanModifyPlan.joinInner', 1, new Set(['right', 'keys', 'condition']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanModifyPlan.joinInner', 1, false, paramdefs, args); + return new PlanModifyPlan(this, 'op', 'join-inner', checkedArgs); + + } +/** + * This method yields one output row set with the rows from an inner join as well as rows from the left row set. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.joinLeftOuter|ModifyPlan.prototype.joinLeftOuter} + * @method planBuilder.ModifyPlan#joinLeftOuter + * @since 2.1.1 + * @param { PlanModifyPlan } [right] - The row set from the right view. + * @param { PlanJoinKey } [keys] - The equijoin from one or more calls to the op:on function. + * @param { XsBoolean } [condition] - A boolean expression that filters the join output rows. + * @returns { planBuilder.ModifyPlan } + */ +joinLeftOuter(...args) { + const namer = bldrbase.getNamer(args, 'right'); + const paramdefs = [['right', [PlanModifyPlan], true, false], ['keys', [PlanJoinKey], false, true], ['condition', [types.XsBoolean, PlanColumn, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanModifyPlan.joinLeftOuter', 1, new Set(['right', 'keys', 'condition']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanModifyPlan.joinLeftOuter', 1, false, paramdefs, args); + return new PlanModifyPlan(this, 'op', 'join-left-outer', checkedArgs); + + } +/** + * This method specifies the maximum number of rows to be returned by this Plan. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.limit|ModifyPlan.prototype.limit} + * @method planBuilder.ModifyPlan#limit + * @since 2.1.1 + * @param { PlanLongParam } [length] - The number of rows to return. + * @returns { planBuilder.ModifyPlan } + */ +limit(...args) { + const paramdef = ['length', [types.XsLong, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanModifyPlan.limit', 1, paramdef, args); + return new PlanModifyPlan(this, 'op', 'limit', checkedArgs); + } +/** + * This method returns a subset of the rows in the result set by skipping the number of rows specified by start and returning the remaining rows up to the number specified by the op:limit method. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.offset|ModifyPlan.prototype.offset} + * @method planBuilder.ModifyPlan#offset + * @since 2.1.1 + * @param { PlanLongParam } [start] - The number of rows to skip. + * @returns { planBuilder.ModifyPlan } + */ +offset(...args) { + const paramdef = ['start', [types.XsLong, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanModifyPlan.offset', 1, paramdef, args); + return new PlanModifyPlan(this, 'op', 'offset', checkedArgs); + } +/** + * This method returns a subset of the rows in the result set by skipping the number of rows specified by start and returning the remaining rows up to the length limit. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.offsetLimit|ModifyPlan.prototype.offsetLimit} + * @method planBuilder.ModifyPlan#offsetLimit + * @since 2.1.1 + * @param { PlanLongParam } [start] - The number of rows to skip. Default is 1. + * @param { PlanLongParam } [length] - The maximum number of rows to return. + * @returns { planBuilder.ModifyPlan } + */ +offsetLimit(...args) { + const namer = bldrbase.getNamer(args, 'start'); + const paramdefs = [['start', [types.XsLong, PlanParam], false, false], ['length', [types.XsLong, PlanParam], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanModifyPlan.offsetLimit', 2, new Set(['start', 'length']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanModifyPlan.offsetLimit', 2, false, paramdefs, args); + return new PlanModifyPlan(this, 'op', 'offset-limit', checkedArgs); + + } +/** + * This method sorts the row set by the specified order definition. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.orderBy|ModifyPlan.prototype.orderBy} + * @method planBuilder.ModifyPlan#orderBy + * @since 2.1.1 + * @param { PlanSortKeyName } [keys] - The specified column or sortdef output from the op:asc or op:desc function. + * @returns { planBuilder.ModifyPlan } + */ +orderBy(...args) { + const paramdef = ['keys', [PlanSortKey, PlanColumn, PlanExprCol, types.XsString], true, true]; + const checkedArgs = bldrbase.makeSingleArgs('PlanModifyPlan.orderBy', 1, paramdef, args); + return new PlanModifyPlan(this, 'op', 'order-by', checkedArgs); + } +/** + * This method prepares the specified plan for execution as an optional final step before execution. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.prepare|ModifyPlan.prototype.prepare} + * @method planBuilder.ModifyPlan#prepare + * @since 2.1.1 + * @param { XsInt } [optimize] - The optimization level, which can be 0, 1, or 2 (with 1 as the default). + * @returns { planBuilder.PreparePlan } + */ +prepare(...args) { + const paramdef = ['optimize', [types.XsInt], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanModifyPlan.prepare', 1, paramdef, args); + return new PlanPreparePlan(this, 'op', 'prepare', checkedArgs); + } +/** + * This call projects the specified columns from the current row set and / or applies a qualifier to the columns in the row set. Unlike SQL, a select call is not required in an Optic query. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.select|ModifyPlan.prototype.select} + * @method planBuilder.ModifyPlan#select + * @since 2.1.1 + * @param { PlanExprColName } [columns] - The columns to select. + * @param { XsString } [qualifierName] - Specifies a name for qualifying the column names in place of the combination of the schema and view names. Use cases for the qualifier include self joins. Using an empty string removes all qualification from the column names. + * @returns { planBuilder.ModifyPlan } + */ +select(...args) { + const namer = bldrbase.getNamer(args, 'columns'); + const paramdefs = [['columns', [PlanExprCol, PlanColumn, types.XsString], false, true], ['qualifierName', [types.XsString], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanModifyPlan.select', 1, new Set(['columns', 'qualifierName']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanModifyPlan.select', 1, false, paramdefs, args); + return new PlanModifyPlan(this, 'op', 'select', checkedArgs); + + } +/** + * This method yields all of the rows from the input row sets. Columns that are present only in some input row sets effectively have a null value in the rows from the other row sets. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.union|ModifyPlan.prototype.union} + * @method planBuilder.ModifyPlan#union + * @since 2.1.1 + * @param { PlanModifyPlan } [right] - The row set from the right view. + * @returns { planBuilder.ModifyPlan } + */ +union(...args) { + const paramdef = ['right', [PlanModifyPlan], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanModifyPlan.union', 1, paramdef, args); + return new PlanModifyPlan(this, 'op', 'union', checkedArgs); + } +/** + * This method restricts the row set to rows matched by the boolean expression. Use boolean composers such as op:and and op:or to combine multiple expressions. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.where|ModifyPlan.prototype.where} + * @method planBuilder.ModifyPlan#where + * @since 2.1.1 + * @param { PlanRowFilter } [condition] - This can be a boolean expression, a cts:query to qualify the source documents that produced the rows set, or (where part of the row set was produced by the op:from-triples accessor) a sem:store to restrict or expand the triples that produce the row set. + * @returns { planBuilder.ModifyPlan } + */ +where(...args) { + const paramdef = ['condition', [types.XsBoolean, PlanColumn, types.CtsQuery, types.SemStore, PlanCondition], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanModifyPlan.where', 1, paramdef, args); + return new PlanModifyPlan(this, 'op', 'where', checkedArgs); + } +/** + * This method removes duplicate rows from the row set. Provides a client interface to a server function. See {@link http://docs.marklogic.com/ModifyPlan.prototype.whereDistinct|ModifyPlan.prototype.whereDistinct} + * @method planBuilder.ModifyPlan#whereDistinct + * @since 2.1.1 + + * @returns { planBuilder.ModifyPlan } + */ +whereDistinct(...args) { + bldrbase.checkMaxArity('PlanModifyPlan.whereDistinct', args.length, 0); + return new PlanModifyPlan(this, 'op', 'where-distinct', args); + } +} +/** + * AccessPlan objects have methods and inherit {@link planBuilder.ModifyPlan} methods. + * @namespace planBuilder.AccessPlan + * @since 2.1.1 + */ +class PlanAccessPlan extends PlanModifyPlan { + + constructor(prior, ns, fn, args) { + super(prior, ns, fn, args); + } +/** + * This method identifies a column, where the column name is unique. A qualifier on the column name isn't necessary (and might not exist). In positions where only a column name can appear, the unqualified column name can also be provided as a string. Qualified column names cannot be provided as a string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.col|op.col} + * @method planBuilder.AccessPlan#col + * @since 2.1.1 + * @param { XsString } [column] - The Optic AccessorPlan created by op:from-view, op:from-triples, or op:from-lexicons. + * @returns { planBuilder.PlanColumn } + */ +col(...args) { + const paramdef = ['column', [types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanAccessPlan.col', 1, paramdef, args); + return new PlanColumn('op', 'col', checkedArgs); + } +} + +/** + * A helper for building the definition of a rows query. The helper is + * created by the {@link marklogic.planBuilder} function. + * @namespace planBuilder + */ +/** + * Builds expressions to call functions in the cts server library + * for a row pipeline. + * @namespace planBuilder.cts + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the fn server library + * for a row pipeline. + * @namespace planBuilder.fn + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the json server library + * for a row pipeline. + * @namespace planBuilder.json + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the map server library + * for a row pipeline. + * @namespace planBuilder.map + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the math server library + * for a row pipeline. + * @namespace planBuilder.math + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the rdf server library + * for a row pipeline. + * @namespace planBuilder.rdf + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the sem server library + * for a row pipeline. + * @namespace planBuilder.sem + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the spell server library + * for a row pipeline. + * @namespace planBuilder.spell + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the sql server library + * for a row pipeline. + * @namespace planBuilder.sql + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the xdmp server library + * for a row pipeline. + * @namespace planBuilder.xdmp + * @since 2.1.1 + */ +/** + * Builds expressions to call functions in the xs server library + * for a row pipeline. + * @namespace planBuilder.xs + * @since 2.1.1 + */ + +class PlanBuilder { + constructor(fieldOverrides) { + this.cts = (fieldOverrides.cts !== void 0) ? fieldOverrides.cts : new CtsExpr(); +this.fn = (fieldOverrides.fn !== void 0) ? fieldOverrides.fn : new FnExpr(); +this.json = (fieldOverrides.json !== void 0) ? fieldOverrides.json : new JsonExpr(); +this.map = (fieldOverrides.map !== void 0) ? fieldOverrides.map : new MapExpr(); +this.math = (fieldOverrides.math !== void 0) ? fieldOverrides.math : new MathExpr(); +this.rdf = (fieldOverrides.rdf !== void 0) ? fieldOverrides.rdf : new RdfExpr(); +this.sem = (fieldOverrides.sem !== void 0) ? fieldOverrides.sem : new SemExpr(); +this.spell = (fieldOverrides.spell !== void 0) ? fieldOverrides.spell : new SpellExpr(); +this.sql = (fieldOverrides.sql !== void 0) ? fieldOverrides.sql : new SqlExpr(); +this.xdmp = (fieldOverrides.xdmp !== void 0) ? fieldOverrides.xdmp : new XdmpExpr(); +this.xs = (fieldOverrides.xs !== void 0) ? fieldOverrides.xs : new XsExpr(); + } + + /** + * This function returns the sum of the specified numeric expressions. In expressions, the call should pass the result from an op:col function to identify a column. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.add|op.add} + * @method planBuilder#add + * @since 2.1.1 + * @param { XsNumeric } [left] - The left value expression. + * @param { XsNumeric } [right] - The right value expression. + * @returns { XsNumeric } + */ +add(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['right', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.add', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.add', 2, true, paramdefs, args); + } + return new types.XsNumeric('op', 'add', args); + } +/** + * This function returns true if the specified expressions all return true. Otherwise, it returns false. You can either compair Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.and|op.and} + * @method planBuilder#and + * @since 2.1.1 + * @param { XsAnyAtomicType } [left] - The left value expression. + * @param { XsAnyAtomicType } [right] - The right value expression. + * @returns { XsBoolean } + */ +and(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['right', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.and', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.and', 2, true, paramdefs, args); + } + return new types.XsBoolean('op', 'and', args); + } +/** + * This function divides the left numericExpression by the right numericExpression and returns the value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.divide|op.divide} + * @method planBuilder#divide + * @since 2.1.1 + * @param { XsNumeric } [left] - The left numeric expression. + * @param { XsNumeric } [right] - The right numeric expression. + * @returns { XsNumeric } + */ +divide(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['right', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.divide', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.divide', 2, false, paramdefs, args); + } + return new types.XsNumeric('op', 'divide', args); + } +/** + * This function returns true if the left and right expressions return the same value. Otherwise, it returns false. In expressions, the call should pass the result from an op:col function to identify a column. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.eq|op.eq} + * @method planBuilder#eq + * @since 2.1.1 + * @param { XsAnyAtomicType } [left] - The left value expression. + * @param { XsAnyAtomicType } [right] - The right value expression. + * @returns { XsBoolean } + */ +eq(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['right', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.eq', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.eq', 2, false, paramdefs, args); + } + return new types.XsBoolean('op', 'eq', args); + } +/** + * This function returns true if the value of the left expression is greater than or equal to the value of the right expression. Otherwise, it returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.ge|op.ge} + * @method planBuilder#ge + * @since 2.1.1 + * @param { XsAnyAtomicType } [left] - The left value expression. + * @param { XsAnyAtomicType } [right] - The right value expression. + * @returns { XsBoolean } + */ +ge(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['right', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.ge', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.ge', 2, false, paramdefs, args); + } + return new types.XsBoolean('op', 'ge', args); + } +/** + * This function returns true if the value of the left expression is greater than the value of the right expression. Otherwise, it returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.gt|op.gt} + * @method planBuilder#gt + * @since 2.1.1 + * @param { XsAnyAtomicType } [left] - The left value expression. + * @param { XsAnyAtomicType } [right] - The right value expression. + * @returns { XsBoolean } + */ +gt(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['right', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.gt', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.gt', 2, false, paramdefs, args); + } + return new types.XsBoolean('op', 'gt', args); + } +/** + * This function tests whether the value of an expression is null in the row where the expression might be as simple as a column identified by op:col. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.isDefined|op.isDefined} + * @method planBuilder#isDefined + * @since 2.1.1 + * @param { Item } [operand] - A boolean expression, such as op:eq or op:not, that might be null. + * @returns { XsBoolean } + */ +isDefined(...args) { + const paramdef = ['operand', [types.Item, PlanColumn, PlanParam], true, false]; + args = bldrbase.makeSingleArgs('planBuilder.isDefined', 1, paramdef, args); + return new types.XsBoolean('op', 'is-defined', args); + } +/** + * This function returns true if the value of the left expression is less than or equal to the value of the right expression. Otherwise, it returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.le|op.le} + * @method planBuilder#le + * @since 2.1.1 + * @param { XsAnyAtomicType } [left] - The left value expression. + * @param { XsAnyAtomicType } [right] - The right value expression. + * @returns { XsBoolean } + */ +le(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['right', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.le', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.le', 2, false, paramdefs, args); + } + return new types.XsBoolean('op', 'le', args); + } +/** + * This function returns true if the value of the left expression is less than the value of the right expression. Otherwise, it returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.lt|op.lt} + * @method planBuilder#lt + * @since 2.1.1 + * @param { XsAnyAtomicType } [left] - The left value expression. + * @param { XsAnyAtomicType } [right] - The right value expression. + * @returns { XsBoolean } + */ +lt(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['right', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.lt', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.lt', 2, false, paramdefs, args); + } + return new types.XsBoolean('op', 'lt', args); + } +/** + * This function multipies the left numericExpression by the right numericExpression and returns the value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.multiply|op.multiply} + * @method planBuilder#multiply + * @since 2.1.1 + * @param { XsNumeric } [left] - The left numeric expression. + * @param { XsNumeric } [right] - The right numeric expression. + * @returns { XsNumeric } + */ +multiply(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['right', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.multiply', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.multiply', 2, true, paramdefs, args); + } + return new types.XsNumeric('op', 'multiply', args); + } +/** + * This function returns true if the value of the left expression is not equal to the value of the right expression. Otherwise, it returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.ne|op.ne} + * @method planBuilder#ne + * @since 2.1.1 + * @param { XsAnyAtomicType } [left] - The left value expression. + * @param { XsAnyAtomicType } [right] - The right value expression. + * @returns { XsBoolean } + */ +ne(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['right', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.ne', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.ne', 2, false, paramdefs, args); + } + return new types.XsBoolean('op', 'ne', args); + } +/** + * This function returns true if neither of the specified boolean expressions return true. Otherwise, it returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.not|op.not} + * @method planBuilder#not + * @since 2.1.1 + * @param { XsAnyAtomicType } [operand] - Exactly one boolean expression, such as op:and or op:or, or op:is-defined. + * @returns { XsBoolean } + */ +not(...args) { + const paramdef = ['operand', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + args = bldrbase.makeSingleArgs('planBuilder.not', 1, paramdef, args); + return new types.XsBoolean('op', 'not', args); + } +/** + * This function returns true if the specified expressions all return true. Otherwise, it returns false. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.or|op.or} + * @method planBuilder#or + * @since 2.1.1 + * @param { XsAnyAtomicType } [left] - The left value expression. + * @param { XsAnyAtomicType } [right] - The right value expression. + * @returns { XsBoolean } + */ +or(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false], ['right', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.or', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.or', 2, true, paramdefs, args); + } + return new types.XsBoolean('op', 'or', args); + } +/** + * This function subtracts the right numericExpression from the left numericExpression and returns the value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.subtract|op.subtract} + * @method planBuilder#subtract + * @since 2.1.1 + * @param { XsNumeric } [left] - The left numeric expression. + * @param { XsNumeric } [right] - The right numeric expression. + * @returns { XsNumeric } + */ +subtract(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['right', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + if (namer !== null) { + const paramNames = new Set(['left', 'right']); + args = bldrbase.makeNamedArgs(namer, 'planBuilder.subtract', 2, paramNames, paramdefs, args); + } else { + args = bldrbase.makePositionalArgs('planBuilder.subtract', 2, false, paramdefs, args); + } + return new types.XsNumeric('op', 'subtract', args); + }/** + * This function creates a placeholder for a literal value in an expression or as the offset or max for a limit. The op:result function throws in an error if the binding parameter does not specify a literal value for the parameter. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.param|op.param} + * @method planBuilder#param + * @since 2.1.1 + * @param { XsString } [name] - The name of the parameter. + * @returns { planBuilder.PlanParam } + */ +param(...args) { + const paramdef = ['name', [types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.param', 1, paramdef, args); + return new PlanParam('op', 'param', checkedArgs); + } +/** + * This method identifies a column, where the column name is unique. A qualifier on the column name isn't necessary (and might not exist). In positions where only a column name can appear, the unqualified column name can also be provided as a string. Qualified column names cannot be provided as a string. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.col|op.col} + * @method planBuilder#col + * @since 2.1.1 + * @param { XsString } [column] - The Optic AccessorPlan created by op:from-view, op:from-triples, or op:from-lexicons. + * @returns { planBuilder.PlanColumn } + */ +col(...args) { + const paramdef = ['column', [types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.col', 1, paramdef, args); + return new PlanColumn('op', 'col', checkedArgs); + } +/** + * Unambiguously identifies a column with the schema name, view name, and column name. Useful only for columns provided by a view. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.schemaCol|op.schemaCol} + * @method planBuilder#schemaCol + * @since 2.1.1 + * @param { XsString } [schema] - The name of the schema. + * @param { XsString } [view] - The name of the view. + * @param { XsString } [column] - The name of the column. + * @returns { planBuilder.PlanColumn } + */ +schemaCol(...args) { + const namer = bldrbase.getNamer(args, 'schema'); + const paramdefs = [['schema', [types.XsString], true, false], ['view', [types.XsString], true, false], ['column', [types.XsString], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.schemaCol', 3, new Set(['schema', 'view', 'column']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.schemaCol', 3, false, paramdefs, args); + return new PlanColumn('op', 'schema-col', checkedArgs); + + } +/** + * Identifies a column where the combination of view and column name is unique. Identifying the schema isn't necessary (and it might not exist). Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.viewCol|op.viewCol} + * @method planBuilder#viewCol + * @since 2.1.1 + * @param { XsString } [view] - The name of the view. + * @param { XsString } [column] - The name of the column. + * @returns { planBuilder.PlanColumn } + */ +viewCol(...args) { + const namer = bldrbase.getNamer(args, 'view'); + const paramdefs = [['view', [types.XsString], true, false], ['column', [types.XsString], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.viewCol', 2, new Set(['view', 'column']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.viewCol', 2, false, paramdefs, args); + return new PlanColumn('op', 'view-col', checkedArgs); + + } +/** + * Specifies a name for adding a fragment id column to the row set identifying the source documents for the rows from a view, lexicons or triples. The only use for the fragment id is joining other rows from the same document, the document uri, or the document content. The fragment id is only useful during execution of the query and not after. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.fragmentIdCol|op.fragmentIdCol} + * @method planBuilder#fragmentIdCol + * @since 2.1.1 + * @param { XsString } [column] - + * @returns { planBuilder.PlanSystemColumn } + */ +fragmentIdCol(...args) { + const paramdef = ['column', [types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.fragmentIdCol', 1, paramdef, args); + return new PlanSystemColumn('op', 'fragment-id-col', checkedArgs); + } +/** + * Identifies the graph for a triple providing one or more columns for a row. You pass the graph column as a system column parameter to the op:pattern function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.graphCol|op.graphCol} + * @method planBuilder#graphCol + * @since 2.1.1 + * @param { XsString } [column] - The name to use for the graph column. + * @returns { planBuilder.PlanSystemColumn } + */ +graphCol(...args) { + const paramdef = ['column', [types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.graphCol', 1, paramdef, args); + return new PlanSystemColumn('op', 'graph-col', checkedArgs); + } +/** + * This function defines a column by assigning the value of an expression over the rows in the row set. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.as|op.as} + * @method planBuilder#as + * @since 2.1.1 + * @param { PlanColumnName } [column] - The name of the column to be defined. This can be either a string or the return value from op:col, op:view-col, or op:schema-col. + * @param { Item } [expression] - The expression used to define the value the column. + * @returns { planBuilder.PlanExprCol } + */ +as(...args) { + const namer = bldrbase.getNamer(args, 'column'); + const paramdefs = [['column', [PlanColumn, types.XsString], true, false], ['expression', [types.Item, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.as', 2, new Set(['column', 'expression']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.as', 2, false, paramdefs, args); + return new PlanExprCol('op', 'as', checkedArgs); + + } +/** + * This function reads a row set from a configured view over TDE-indexed rows or a predefined view over range indexes. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.fromView|op.fromView} + * @method planBuilder#fromView + * @since 2.1.1 + * @param { XsString } [schema] - The name identifying the schema containing the view. If the schema name is null, the engine searches for a view with the specified name. + * @param { XsString } [view] - The name identifying a configured template or range view for rows projected from documents. + * @param { XsString } [qualifierName] - Specifies a name for qualifying the column names in place of the combination of the schema and view names. Use cases for the qualifier include self joins. Using an empty string removes all qualification from the column names. + * @param { PlanSystemColumn } [sysCols] - An optional named fragment id column returned by op:fragment-id-col. One use case for fragment ids is in joins with lexicons or document content. + * @returns { planBuilder.AccessPlan } + */ +fromView(...args) { + const namer = bldrbase.getNamer(args, 'schema'); + const paramdefs = [['schema', [types.XsString], false, false], ['view', [types.XsString], true, false], ['qualifierName', [types.XsString], false, false], ['sysCols', [PlanSystemColumn], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.fromView', 2, new Set(['schema', 'view', 'qualifierName', 'sysCols']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.fromView', 2, false, paramdefs, args); + return new PlanAccessPlan(null, 'op', 'from-view', checkedArgs); + + } +/** + * This function factory returns a new function that takes a name parameter and returns a sem:iri, prepending the specified base URI onto the name. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.prefixer|op.prefixer} + * @method planBuilder#prefixer + * @since 2.1.1 + * @param { XsString } [base] - The base URI to be prepended to the name. + * @returns { planBuilder.Prefixer } + */ +prefixer(...args) { + const paramdef = ['base', [types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.prefixer', 1, paramdef, args); + return new PlanPrefixer('op', 'prefixer', checkedArgs); + } +/** + * Reads rows by matching patterns in the triple index. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.fromTriples|op.fromTriples} + * @method planBuilder#fromTriples + * @since 2.1.1 + * @param { PlanTriplePattern } [patterns] - One or more pattern definitions returned by the op:pattern function. + * @param { XsString } [qualifierName] - Specifies a name for qualifying the column names. By default, triple rows have no qualification. Use cases for the qualifier include self joins. Using an empty string removes all qualification from the column names. + * @param { XsString } [graphIris] - A list of graph IRIs to restrict the results to triples in the specified graphs. The sem:default-graph-iri function returns the iri that identifies the default graph. + * @param { PlanTripleOption } [option] - Options consisting of key-value pairs that set options. At present, the options consist of dedup which can take an on|off value to enable or disable deduplication. Deduplication is off by default. + * @returns { planBuilder.AccessPlan } + */ +fromTriples(...args) { + const namer = bldrbase.getNamer(args, 'patterns'); + const paramdefs = [['patterns', [PlanTriplePattern], true, true], ['qualifierName', [types.XsString], false, false], ['graphIris', [types.XsString], false, true], ['option', [PlanTripleOption], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.fromTriples', 1, new Set(['patterns', 'qualifierName', 'graphIris', 'option']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.fromTriples', 1, false, paramdefs, args); + return new PlanAccessPlan(null, 'op', 'from-triples', checkedArgs); + + } +/** + * This function builds the parameters for the op:from-triples function. The result is passed to op:from-triples to project rows from the graph of triples. The columns in a pattern become the columns of the row. The literals in a pattern are used to match triples. You should specify at least one literal in each pattern, usually the predicate. Where a column appears in more than one pattern, the matched triples are joined to form the row. You can specify optional triples with a op:join-left-outer with a separate op:from-triples. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.pattern|op.pattern} + * @method planBuilder#pattern + * @since 2.1.1 + * @param { PlanTriplePosition } [subjects] - One column or one or more literal values, such as the literal returned by a sem:iri call. + * @param { PlanTriplePosition } [predicates] - One column or one or more literal values, such as the literal returned by a sem.iri call. + * @param { PlanTriplePosition } [objects] - One column or one or more literal values, such as the literal returned by a sem:iri call. + * @param { PlanSystemColumn } [sysCols] - Specifies the result of an op:fragment-id-col or op:graph-col function to add columns for the fragment id or graph iri. + * @returns { planBuilder.PlanTriplePattern } + */ +pattern(...args) { + const namer = bldrbase.getNamer(args, 'subjects'); + const paramdefs = [['subjects', [PlanColumn, types.XsAnyAtomicType, PlanParam], false, true], ['predicates', [PlanColumn, types.XsAnyAtomicType, PlanParam], false, true], ['objects', [PlanColumn, types.XsAnyAtomicType, PlanParam], false, true], ['sysCols', [PlanSystemColumn], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.pattern', 3, new Set(['subjects', 'predicates', 'objects', 'sysCols']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.pattern', 3, false, paramdefs, args); + return new PlanTriplePattern('op', 'pattern', checkedArgs); + + } +/** + * This function dynamically constructs a view from range indexes or the uri or collection lexicons. This function will only return rows for documents where the first column has a value. The keys in the map specify the names of the columns and the values in the map provide cts:reference objects to specify the lexicon providing the values of the columns. Optic emits rows based on co-occurrence of lexicon values within the same document similar to cts:value-tuples If the cts:reference sets the nullable option to true, the column is optional in the row. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.fromLexicons|op.fromLexicons} + * @method planBuilder#fromLexicons + * @since 2.1.1 + * @param { PlanCtsReferenceMap } [indexes] - An object in which each key is a column name and each value specifies a cts:reference for a range index or other lexicon (especially the cts:uri-reference lexicon) with the column values. + * @param { XsString } [qualifierName] - Specifies a name for qualifying the column names. By default, lexicon rows have no qualification. Use cases for the qualifier include self joins. Using an empty string removes all qualification from the column names. + * @param { PlanSystemColumn } [sysCols] - An optional named fragment id column returned by the op:fragment-id-col function. The fragment id column can be used for joins. + * @returns { planBuilder.AccessPlan } + */ +fromLexicons(...args) { + const namer = bldrbase.getNamer(args, 'indexes'); + const paramdefs = [['indexes', [PlanCtsReferenceMap], true, false], ['qualifierName', [types.XsString], false, false], ['sysCols', [PlanSystemColumn], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.fromLexicons', 1, new Set(['indexes', 'qualifierName', 'sysCols']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.fromLexicons', 1, false, paramdefs, args); + return new PlanAccessPlan(null, 'op', 'from-lexicons', checkedArgs); + + } +/** + * Constructs a literal row set as in the SQL VALUES or SPARQL VALUES statements. When specifying rows with arrays, values are mapped to column names by position. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.fromLiterals|op.fromLiterals} + * @method planBuilder#fromLiterals + * @since 2.1.1 + * @param { PlanXsValueMap } [rows] - This parameter is either an array of object literals or sem:binding objects in which the key is a column name string identifying the column and the value is a literal with the value of the column, or this parameter is an object with a columnNames key having a value of an array of column names and a rowValues key having a value of an array of arrays with literal values. + * @param { XsString } [qualifierName] - Specifies a name for qualifying the column names in place of the combination of the schema and view names. Use cases for the qualifier include self joins. Using an empty string removes all qualification from the column names. + * @returns { planBuilder.AccessPlan } + */ +fromLiterals(...args) { + const namer = bldrbase.getNamer(args, 'rows'); + const paramdefs = [['rows', [PlanXsValueMap], true, true], ['qualifierName', [types.XsString], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.fromLiterals', 1, new Set(['rows', 'qualifierName']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.fromLiterals', 1, false, paramdefs, args); + return new PlanAccessPlan(null, 'op', 'from-literals', checkedArgs); + + } +/** + * Provides a client interface to a server function. + * @method planBuilder#fromSPARQL + * @since 2.1.1 + * @param { XsString } [select] - + * @param { XsString } [qualifierName] - + * @returns { planBuilder.ModifyPlan } + */ +fromSPARQL(...args) { + const namer = bldrbase.getNamer(args, 'select'); + const paramdefs = [['select', [types.XsString], true, false], ['qualifierName', [types.XsString], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.fromSPARQL', 1, new Set(['select', 'qualifierName']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.fromSPARQL', 1, false, paramdefs, args); + return new PlanModifyPlan(null, 'op', 'from-sparql', checkedArgs); + + } +/** + * Provides a client interface to a server function. + * @method planBuilder#fromSQL + * @since 2.1.1 + * @param { XsString } [select] - + * @param { XsString } [qualifierName] - + * @returns { planBuilder.ModifyPlan } + */ +fromSQL(...args) { + const namer = bldrbase.getNamer(args, 'select'); + const paramdefs = [['select', [types.XsString], true, false], ['qualifierName', [types.XsString], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.fromSQL', 1, new Set(['select', 'qualifierName']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.fromSQL', 1, false, paramdefs, args); + return new PlanModifyPlan(null, 'op', 'from-sql', checkedArgs); + + } +/** + * Provides a client interface to a server function. + * @method planBuilder#sqlCondition + * @since 2.1.1 + * @param { XsString } [expression] - + * @returns { planBuilder.PlanCondition } + */ +sqlCondition(...args) { + const paramdef = ['expression', [types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.sqlCondition', 1, paramdef, args); + return new PlanCondition('op', 'sql-condition', checkedArgs); + } +/** + * Specifies an equijoin using one columndef each from the left and right rows. The result is used by the op:join-inner and op:join-left-outer functions. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.on|op.on} + * @method planBuilder#on + * @since 2.1.1 + * @param { PlanExprColName } [left] - The rows from the left view. + * @param { PlanExprColName } [right] - The row set from the right view. + * @returns { planBuilder.PlanJoinKey } + */ +on(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [PlanExprCol, PlanColumn, types.XsString], true, false], ['right', [PlanExprCol, PlanColumn, types.XsString], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.on', 2, new Set(['left', 'right']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.on', 2, false, paramdefs, args); + return new PlanJoinKey('op', 'on', checkedArgs); + + } +/** + * This function averages the non-null values of the column for the rows in the group or row set. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.avg|op.avg} + * @method planBuilder#avg + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for the aggregated column. + * @param { PlanExprColName } [column] - The column to be aggregated. + * @param { PlanValueOption } [option] - The options can take a values key with a distinct value to average the distinct values of the column. + * @returns { planBuilder.PlanAggregateCol } + */ +avg(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], true, false], ['option', [PlanValueOption], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.avg', 2, new Set(['name', 'column', 'option']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.avg', 2, false, paramdefs, args); + return new PlanAggregateCol('op', 'avg', checkedArgs); + + } +/** + * This function constructs an array whose items are the result of evaluating the column for each row in the group or row set. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.arrayAggregate|op.arrayAggregate} + * @method planBuilder#arrayAggregate + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for the aggregated column. + * @param { PlanExprColName } [column] - The columns to be aggregated. + * @param { PlanValueOption } [option] - The options can take a values key with a distinct value to average the distinct values of the column. + * @returns { planBuilder.PlanAggregateCol } + */ +arrayAggregate(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], true, false], ['option', [PlanValueOption], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.arrayAggregate', 2, new Set(['name', 'column', 'option']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.arrayAggregate', 2, false, paramdefs, args); + return new PlanAggregateCol('op', 'array-aggregate', checkedArgs); + + } +/** + * This function counts the rows where the specified input column has a value. If the input column is omitted, all rows in the group or row set are counted. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.count|op.count} + * @method planBuilder#count + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for the column values. + * @param { PlanExprColName } [column] - The columns to be counted. + * @param { PlanValueOption } [option] - The options can take a values key with a distinct value to average the distinct values of the column. + * @returns { planBuilder.PlanAggregateCol } + */ +count(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], false, false], ['option', [PlanValueOption], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.count', 1, new Set(['name', 'column', 'option']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.count', 1, false, paramdefs, args); + return new PlanAggregateCol('op', 'count', checkedArgs); + + } +/** + * This function concatenates the non-null values of the column for the rows in the group or row set. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.groupConcat|op.groupConcat} + * @method planBuilder#groupConcat + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for column with the concatenated values. + * @param { PlanExprColName } [column] - The name of the column with the values to be concatenated for the group. + * @param { PlanGroupConcatString } [options] - The options can take a values key with a distinct value to average the distinct values of the column. In addition to the values key, the options can take a separator key specifying a separator character. The value can be a string or placeholder parameter. + * @returns { planBuilder.PlanAggregateCol } + */ +groupConcat(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], true, false], ['options', [types.XsString, PlanGroupConcatOption], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.groupConcat', 2, new Set(['name', 'column', 'options']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.groupConcat', 2, false, paramdefs, args); + return new PlanAggregateCol('op', 'group-concat', checkedArgs); + + } +/** + * This function gets the largest non-null value of the column for the rows in the group or row set. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.max|op.max} + * @method planBuilder#max + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for the largest value. + * @param { PlanExprColName } [column] - The group or row set. + * @param { PlanValueOption } [option] - The options can take a values key with a distinct value to average the distinct values of the column. + * @returns { planBuilder.PlanAggregateCol } + */ +max(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], true, false], ['option', [PlanValueOption], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.max', 2, new Set(['name', 'column', 'option']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.max', 2, false, paramdefs, args); + return new PlanAggregateCol('op', 'max', checkedArgs); + + } +/** + * This function gets the smallest non-null value of the column for the rows in the group or row set. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.min|op.min} + * @method planBuilder#min + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for the smallest value. + * @param { PlanExprColName } [column] - The group or row set. + * @param { PlanValueOption } [option] - The options can take a values key with a distinct value to average the distinct values of the column. + * @returns { planBuilder.PlanAggregateCol } + */ +min(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], true, false], ['option', [PlanValueOption], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.min', 2, new Set(['name', 'column', 'option']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.min', 2, false, paramdefs, args); + return new PlanAggregateCol('op', 'min', checkedArgs); + + } +/** + * This function randomly selects one non-null value of the column from the rows in the group or row set. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.sample|op.sample} + * @method planBuilder#sample + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for the value. + * @param { PlanExprColName } [column] - The group or row set. + * @returns { planBuilder.PlanAggregateCol } + */ +sample(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.sample', 2, new Set(['name', 'column']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.sample', 2, false, paramdefs, args); + return new PlanAggregateCol('op', 'sample', checkedArgs); + + } +/** + * This call constructs a sequence whose items are the values of a column for each row in the group or row set. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.sequenceAggregate|op.sequenceAggregate} + * @method planBuilder#sequenceAggregate + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for the aggregated column. + * @param { PlanExprColName } [column] - The column with the values to aggregate. + * @param { PlanValueOption } [option] - The options can take a values key with a distinct value to average the distinct values of the column. + * @returns { planBuilder.PlanAggregateCol } + */ +sequenceAggregate(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], true, false], ['option', [PlanValueOption], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.sequenceAggregate', 2, new Set(['name', 'column', 'option']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.sequenceAggregate', 2, false, paramdefs, args); + return new PlanAggregateCol('op', 'sequence-aggregate', checkedArgs); + + } +/** + * This function adds the non-null values of the column for the rows in the group or row set. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.sum|op.sum} + * @method planBuilder#sum + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for the aggregated column. + * @param { PlanExprColName } [column] - The column with the values to add. + * @param { PlanValueOption } [option] - The options can take a values key with a distinct value to average the distinct values of the column. + * @returns { planBuilder.PlanAggregateCol } + */ +sum(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], true, false], ['option', [PlanValueOption], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.sum', 2, new Set(['name', 'column', 'option']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.sum', 2, false, paramdefs, args); + return new PlanAggregateCol('op', 'sum', checkedArgs); + + } +/** + * This function processes the values of column for each row in the group or row set with the specified user-defined aggregate as implemented by an aggregate user-defined function (UDF) plugin. The UDF plugin must be installed on each host. The result is used for building the parameters used by the op:group-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.uda|op.uda} + * @method planBuilder#uda + * @since 2.1.1 + * @param { PlanColumnName } [name] - The name to be used for the aggregated column. + * @param { PlanExprColName } [column] - The column with the values to aggregate. + * @param { XsString } [module] - The path to the installed plugin module. + * @param { XsString } [function] - The name of the UDF function. + * @param { XsAnyAtomicType } [arg] - The options can take a values key with a distinct value to average the distinct values of the column and an arg key specifying an argument for the user-defined aggregate. The value can be a string or placeholder parameter. + * @returns { planBuilder.PlanAggregateCol } + */ +uda(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [PlanColumn, types.XsString], true, false], ['column', [PlanExprCol, PlanColumn, types.XsString], true, false], ['module', [types.XsString], true, false], ['function', [types.XsString], true, false], ['arg', [types.XsAnyAtomicType], false, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.uda', 4, new Set(['name', 'column', 'module', 'function', 'arg']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.uda', 4, false, paramdefs, args); + return new PlanAggregateCol('op', 'uda', checkedArgs); + + } +/** + * This function sorts the specified columndef in ascending order. The results are used by the op:order-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.asc|op.asc} + * @method planBuilder#asc + * @since 2.1.1 + * @param { PlanExprColName } [column] - The column by which order the output. + * @returns { planBuilder.PlanSortKey } + */ +asc(...args) { + const paramdef = ['column', [PlanExprCol, PlanColumn, types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.asc', 1, paramdef, args); + return new PlanSortKey('op', 'asc', checkedArgs); + } +/** + * This function sorts the specified columndef in descending order. The results are used by the op:order-by function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.desc|op.desc} + * @method planBuilder#desc + * @since 2.1.1 + * @param { PlanExprColName } [column] - The column by which order the output. + * @returns { planBuilder.PlanSortKey } + */ +desc(...args) { + const paramdef = ['column', [PlanExprCol, PlanColumn, types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.desc', 1, paramdef, args); + return new PlanSortKey('op', 'desc', checkedArgs); + } +/** + * This function returns the remainder afer the division of the dividend and divisor expressions. For example, op:modulo(5, 2) returns 1. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.modulo|op.modulo} + * @method planBuilder#modulo + * @since 2.1.1 + * @param { XsNumeric } [left] - The dividend numeric expression. + * @param { XsNumeric } [right] - The divisor numeric expression. + * @returns { XsNumeric } + */ +modulo(...args) { + const namer = bldrbase.getNamer(args, 'left'); + const paramdefs = [['left', [types.XsNumeric, PlanColumn, PlanParam], true, false], ['right', [types.XsNumeric, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.modulo', 2, new Set(['left', 'right']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.modulo', 2, false, paramdefs, args); + return new types.XsNumeric('op', 'modulo', checkedArgs); + + } +/** + * This function returns the specified valueExpression if the specified valueExpression is true. Otherwise, it returns null. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.case|op.case} + * @method planBuilder#case + * @since 2.1.1 + * @param { PlanCase } [when] - One or more op:when expressions. + * @param { Item } [otherwise] - The value expression to return if none of the op:when expressions is true. + * @returns { Item } + */ +case(...args) { + const namer = bldrbase.getNamer(args, 'when'); + const paramdefs = [['when', [PlanCase], true, true], ['otherwise', [types.Item, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.case', 2, new Set(['when', 'otherwise']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.case', 2, false, paramdefs, args); + return new types.Item('op', 'case', checkedArgs); + + } +/** + * This function executes the specified expression if the specified condition is true for the row. Otherwise, the expression is not executed and the next 'when' test is checked or, if there is no next 'when' text, the otherwise expression for the op:case expression is executed. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.when|op.when} + * @method planBuilder#when + * @since 2.1.1 + * @param { XsBoolean } [condition] - A boolean expression. + * @param { Item } [value] - The value expression to return if the boolean expression is true. + * @returns { planBuilder.PlanCase } + */ +when(...args) { + const namer = bldrbase.getNamer(args, 'condition'); + const paramdefs = [['condition', [types.XsBoolean, PlanColumn, PlanParam], true, false], ['value', [types.Item, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.when', 2, new Set(['condition', 'value']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.when', 2, false, paramdefs, args); + return new PlanCase('op', 'when', checkedArgs); + + } +/** + * This function extracts a sequence of child nodes from a column with node values -- especially, the document nodes from a document join. The path is an XPath (specified as a string) to apply to each node to generate a sequence of nodes as an expression value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.xpath|op.xpath} + * @method planBuilder#xpath + * @since 2.1.1 + * @param { PlanColumnName } [column] - The name of the column from which to extract the child nodes. + * @param { XsString } [path] - An XPath (specified as a string) to apply to each node. + * @returns { Node } + */ +xpath(...args) { + const namer = bldrbase.getNamer(args, 'column'); + const paramdefs = [['column', [PlanColumn, types.XsString], true, false], ['path', [types.XsString, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.xpath', 2, new Set(['column', 'path']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.xpath', 2, false, paramdefs, args); + return new types.Node('op', 'xpath', checkedArgs); + + } +/** + * This function constructs a JSON document with the root content, which must be exactly one JSON object or array node. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.jsonDocument|op.jsonDocument} + * @method planBuilder#jsonDocument + * @since 2.1.1 + * @param { JsonRootNode } [root] - The JSON object or array node used to construct the JSON document. + * @returns { DocumentNode } + */ +jsonDocument(...args) { + const paramdef = ['root', [types.JsonRootNode, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.jsonDocument', 1, paramdef, args); + return new types.DocumentNode('op', 'json-document', checkedArgs); + } +/** + * This function constructs a JSON object with the specified properties. The object can be used as the value of a column in a row or passed to a builtin function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.jsonObject|op.jsonObject} + * @method planBuilder#jsonObject + * @since 2.1.1 + * @param { PlanJsonProperty } [property] - The properties to be used to contruct the object. This is constructed by the op:prop function. + * @returns { ObjectNode } + */ +jsonObject(...args) { + const paramdef = ['property', [PlanJsonProperty], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.jsonObject', 0, paramdef, args); + return new types.ObjectNode('op', 'json-object', checkedArgs); + } +/** + * This function specifies the key expression and value content for a JSON property of a JSON object contructed by the op:json-object function. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.prop|op.prop} + * @method planBuilder#prop + * @since 2.1.1 + * @param { XsString } [key] - The key expression. This must evaluate to a string. + * @param { PlanJsonContentVal } [value] - The value content. This must be exactly one JSON node expression. + * @returns { planBuilder.PlanJsonProperty } + */ +prop(...args) { + const namer = bldrbase.getNamer(args, 'key'); + const paramdefs = [['key', [types.XsString, PlanColumn, PlanParam], true, false], ['value', [types.JsonContentNode, types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.prop', 2, new Set(['key', 'value']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.prop', 2, false, paramdefs, args); + return new PlanJsonProperty('op', 'prop', checkedArgs); + + } +/** + * This function constructs a JSON array during row processing. The array can be used as the value of a column in a row or passed to a builtin expression function. The node is constructed during processing of the plan, rather than when building the plan. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.jsonArray|op.jsonArray} + * @method planBuilder#jsonArray + * @since 2.1.1 + * @param { PlanJsonContentVal } [property] - The JSON nodes for the array. + * @returns { ArrayNode } + */ +jsonArray(...args) { + const paramdef = ['property', [types.JsonContentNode, types.XsAnyAtomicType, PlanColumn, PlanParam], false, true]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.jsonArray', 0, paramdef, args); + return new types.ArrayNode('op', 'json-array', checkedArgs); + } +/** + * This function constructs a JSON text node with the specified value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.jsonString|op.jsonString} + * @method planBuilder#jsonString + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - The value of the JSON text node. + * @returns { TextNode } + */ +jsonString(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.jsonString', 1, paramdef, args); + return new types.TextNode('op', 'json-string', checkedArgs); + } +/** + * This function constructs a JSON number node with the specified value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.jsonNumber|op.jsonNumber} + * @method planBuilder#jsonNumber + * @since 2.1.1 + * @param { XsNumeric } [value] - The value of the JSON number node. + * @returns { NumberNode } + */ +jsonNumber(...args) { + const paramdef = ['value', [types.XsNumeric, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.jsonNumber', 1, paramdef, args); + return new types.NumberNode('op', 'json-number', checkedArgs); + } +/** + * This function constructs a JSON boolean node with the specified value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.jsonBoolean|op.jsonBoolean} + * @method planBuilder#jsonBoolean + * @since 2.1.1 + * @param { XsBoolean } [value] - The value of the JSON boolean node. + * @returns { BooleanNode } + */ +jsonBoolean(...args) { + const paramdef = ['value', [types.XsBoolean, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.jsonBoolean', 1, paramdef, args); + return new types.BooleanNode('op', 'json-boolean', checkedArgs); + } +/** + * This function constructs a JSON null node. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.jsonNull|op.jsonNull} + * @method planBuilder#jsonNull + * @since 2.1.1 + + * @returns { NullNode } + */ +jsonNull(...args) { + bldrbase.checkMaxArity('PlanBuilder.jsonNull', args.length, 0); + return new types.NullNode('op', 'json-null', args); + } +/** + * This function constructs an XML document with the root content, which must be exactly one node. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.xmlDocument|op.xmlDocument} + * @method planBuilder#xmlDocument + * @since 2.1.1 + * @param { XmlRootNode } [root] - The XML node used to construct the XML document. + * @returns { DocumentNode } + */ +xmlDocument(...args) { + const paramdef = ['root', [types.XmlRootNode, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.xmlDocument', 1, paramdef, args); + return new types.DocumentNode('op', 'xml-document', checkedArgs); + } +/** + * This function constructs an XML element with the name (which can be a string or QName), zero or more attributes, and child content. The child content can include a sequence or array of atomic values or an element, comment, or processing instruction nodes. Atomic values are converted to text nodes. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.xmlElement|op.xmlElement} + * @method planBuilder#xmlElement + * @since 2.1.1 + * @param { PlanQualifiableName } [name] - The string or QName for the constructed element. + * @param { AttributeNode } [attributes] - Any element attributes returned from op:xml-attribute, or null if no attributes. + * @param { PlanXmlContentVal } [content] - A sequence or array of atomic values or an element, a comment from op:xml-comment, or processing instruction nodes from op:xml-pi. + * @returns { ElementNode } + */ +xmlElement(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [types.XsQName, types.XsString, PlanColumn, PlanParam], true, false], ['attributes', [types.AttributeNode, PlanColumn, PlanParam], false, true], ['content', [types.XmlContentNode, types.XsAnyAtomicType, PlanColumn, PlanParam], false, true]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.xmlElement', 1, new Set(['name', 'attributes', 'content']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.xmlElement', 1, false, paramdefs, args); + return new types.ElementNode('op', 'xml-element', checkedArgs); + + } +/** + * This function constructs an XML attribute with the name (which can be a string or QName) and atomic value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.xmlAttribute|op.xmlAttribute} + * @method planBuilder#xmlAttribute + * @since 2.1.1 + * @param { PlanQualifiableName } [name] - The attribute name. + * @param { XsAnyAtomicType } [value] - The attribute value. + * @returns { AttributeNode } + */ +xmlAttribute(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [types.XsQName, types.XsString, PlanColumn, PlanParam], true, false], ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.xmlAttribute', 2, new Set(['name', 'value']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.xmlAttribute', 2, false, paramdefs, args); + return new types.AttributeNode('op', 'xml-attribute', checkedArgs); + + } +/** + * This function constructs an XML text node with the specified value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.xmlText|op.xmlText} + * @method planBuilder#xmlText + * @since 2.1.1 + * @param { XsAnyAtomicType } [value] - The value of the XML text node. + * @returns { TextNode } + */ +xmlText(...args) { + const paramdef = ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.xmlText', 1, paramdef, args); + return new types.TextNode('op', 'xml-text', checkedArgs); + } +/** + * This function constructs an XML comment with the atomic value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.xmlComment|op.xmlComment} + * @method planBuilder#xmlComment + * @since 2.1.1 + * @param { XsAnyAtomicType } [content] - The comment text. + * @returns { CommentNode } + */ +xmlComment(...args) { + const paramdef = ['content', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanBuilder.xmlComment', 1, paramdef, args); + return new types.CommentNode('op', 'xml-comment', checkedArgs); + } +/** + * This function constructs an XML processing instruction with the atomic value. Provides a client interface to a server function. See {@link http://docs.marklogic.com/op.xmlPi|op.xmlPi} + * @method planBuilder#xmlPi + * @since 2.1.1 + * @param { XsString } [name] - The name of the processing instruction. + * @param { XsAnyAtomicType } [value] - The value of the processing instruction. + * @returns { ProcessingInstructionNode } + */ +xmlPi(...args) { + const namer = bldrbase.getNamer(args, 'name'); + const paramdefs = [['name', [types.XsString, PlanColumn, PlanParam], true, false], ['value', [types.XsAnyAtomicType, PlanColumn, PlanParam], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.xmlPi', 2, new Set(['name', 'value']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.xmlPi', 2, false, paramdefs, args); + return new types.ProcessingInstructionNode('op', 'xml-pi', checkedArgs); + + } +/** + * Provides a client interface to a server function. + * @method planBuilder#resolveFunction + * @since 2.1.1 + * @param { PlanQualifiableName } [functionName] - + * @param { XsString } [modulePath] - + * @returns { planBuilder.PlanFunction } + */ +resolveFunction(...args) { + const namer = bldrbase.getNamer(args, 'functionName'); + const paramdefs = [['functionName', [types.XsQName, types.XsString], true, false], ['modulePath', [types.XsString], true, false]]; + const checkedArgs = (namer !== null) ? + bldrbase.makeNamedArgs(namer, 'PlanBuilder.resolveFunction', 2, new Set(['functionName', 'modulePath']), paramdefs, args) : + bldrbase.makePositionalArgs('PlanBuilder.resolveFunction', 2, false, paramdefs, args); + return new PlanFunction('op', 'resolve-function', checkedArgs); + + } +} + +module.exports = { + PlanBuilder: PlanBuilder, +CtsExpr: CtsExpr, +FnExpr: FnExpr, +JsonExpr: JsonExpr, +MapExpr: MapExpr, +MathExpr: MathExpr, +RdfExpr: RdfExpr, +SemExpr: SemExpr, +SpellExpr: SpellExpr, +SqlExpr: SqlExpr, +XdmpExpr: XdmpExpr, +XsExpr: XsExpr, + Plan: PlanPlan, + AccessPlan: PlanAccessPlan, + PlanColumn: PlanColumn +}; diff --git a/lib/plan-builder.js b/lib/plan-builder.js new file mode 100644 index 00000000..2fa4c444 --- /dev/null +++ b/lib/plan-builder.js @@ -0,0 +1,114 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const types = require('./server-types-generated.js'); +const bldrbase = require('./plan-builder-base.js'); +const bldrgen = require('./plan-builder-generated.js'); + +/** @ignore */ +function isNonEmptyString(arg) { + if (typeof arg === "string" || arg instanceof String) { + return (arg.length > 0); + } + return false; +} +/** @ignore */ +function iriMaker(builder, prefix, name) { + if (!isNonEmptyString(name)) { + throw new Error('cannot define '+prefix+' iri without name: '+name); + } + + const lastChar = prefix.substr(-1, 1); + const firstChar = name.substr(0, 1); + if (firstChar === lastChar) { + if (name.length === 1) { + throw new Error('cannot define '+prefix+' iri with name of '+name); + } + // TODO: name separator should override prefix separator in SJS, XQY, and Java + name = name.substr(1); + } else if (name.length === 0) { + throw new Error('cannot define '+prefix+' iri with empty name'); + } + + return builder.sem.iri(prefix + name); +} + +bldrgen.AccessPlan.prototype.col = function(...args) { + const self = this; + const paramdef = ['column', [types.XsString], true, false]; + const checkedArgs = bldrbase.makeSingleArgs('PlanAccessPlan.col', 1, paramdef, args); + const colName = checkedArgs[0]; + const accessorArgs = self._args; + switch (self._fn) { + case 'from-lexicons': + case 'from-literals': + case 'from-triples': + const qualifierName = (accessorArgs.length > 1) ? accessorArgs[1] : null; + if (qualifierName !== void 0 && qualifierName !== null) { + return new bldrgen.PlanColumn('op', 'view-col', [qualifierName, colName]); + } + break; + case 'from-view': + const viewQualifier = (accessorArgs.length > 2) ? accessorArgs[2] : null; + if (viewQualifier !== void 0 && viewQualifier !== null) { + return new bldrgen.PlanColumn('op', 'view-col', [viewQualifier, colName]); + } else { + const schemaName = accessorArgs[0]; + const viewName = accessorArgs[1]; + return new bldrgen.PlanColumn('op', 'schema-col', + [((schemaName === void 0) ? null : schemaName), viewName, colName] + ); + } + break; + } + return new bldrgen.PlanColumn('op', 'col', checkedArgs); +}; + +class Builder extends bldrgen.PlanBuilder { + constructor() { + super({}); + } + prefixer(base) { + const self = this; + + if (!isNonEmptyString(base)) { + throw new Error('cannot define prefixer without prefix: '+base); + } + const lastChar = base.substr(-1, 1); + if (lastChar !== '/' && lastChar !== '#' && lastChar !== '?') { + base += '/'; + } + + const prefix = base; + return function(name) { + return iriMaker(self, prefix, name); + }; + } + resolveFunction(functionName, modulePath) { + return super.resolveFunction( + (functionName instanceof types.XsQName) ? functionName : this.xs.QName(functionName), + modulePath + ); + } +} + +const builder = new Builder(); + +module.exports = { + builder: builder, + Plan: bldrgen.Plan +}; diff --git a/lib/query-builder.js b/lib/query-builder.js index 006ea00d..4df2483d 100644 --- a/lib/query-builder.js +++ b/lib/query-builder.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/requester.js b/lib/requester.js index 3db3be50..591bdd11 100644 --- a/lib/requester.js +++ b/lib/requester.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -291,7 +291,7 @@ function chunkedRequester(request) { var operation = this; var requestWriter = operation.requestWriter; - if (requestWriter == null) { + if (requestWriter === null || requestWriter === undefined) { operation.errorListener('no request writer for streaming request'); request.end(); } diff --git a/lib/resources-config.js b/lib/resources-config.js index 2984a456..37e3d1a5 100644 --- a/lib/resources-config.js +++ b/lib/resources-config.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/resources-exec.js b/lib/resources-exec.js index 9f8605e5..53a7e554 100644 --- a/lib/resources-exec.js +++ b/lib/resources-exec.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/responder.js b/lib/responder.js index e6a753fd..f9ac2173 100644 --- a/lib/responder.js +++ b/lib/responder.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,31 @@ var stream = require('stream'); var util = require('util'); var concatStream = require('concat-stream'); +var jsonParser = require('json-text-sequence').parser; var Dicer = require('dicer'); var through2 = require('through2'); var PromisePlus = require('./bluebird-plus.js'); var mlutil = require('./mlutil.js'); +/** + * Handle response from the REST API based on response and operation + * @param {http.IncomingMessage} response - An HTTP response + * + * The following dispatch methods are available: + * + * BodyDispatcher.emptyPromise() + * BodyDispatcher.emptyStream() + * BodyDispatcher.promise() + * BodyDispatcher.chunkedStream() + * BodyDispatcher.objectStream() + * MultipartDispatcher.emptyPromise() + * MultipartDispatcher.emptyStream() + * MultipartDispatcher.promise() + * MultipartDispatcher.chunkedStream() + * MultipartDispatcher.objectStream() + * + * @ignore + */ function responseDispatcher(response) { /*jshint validthis:true */ var operation = this; @@ -36,7 +56,7 @@ function responseDispatcher(response) { } var responseType = response.headers['content-type']; - var responseTypeLen = (responseType == null) ? 0 : responseType.length; + var responseTypeLen = (responseType === undefined) ? 0 : responseType.length; var responseBoundary = null; if (15 <= responseTypeLen && responseType.substr(0, 15) === 'multipart/mixed') { responseBoundary = responseType.replace( @@ -55,6 +75,8 @@ function responseDispatcher(response) { } var isMultipart = (responseBoundary != null); + // inputHeader may be boundary (for multipart) or content type (for body) + // Allows dispatch function signatures to remain consistent var inputHeader = isMultipart ? responseBoundary : responseType; var responseLength = response.headers['content-length']; @@ -62,6 +84,14 @@ function responseDispatcher(response) { var expectedType = operation.responseType; + // point-in-time operations: if timestamp unset, set with header value + if (operation.timestamp !== undefined && operation.timestamp !== null) { + if (operation.timestamp.value === null + && response.headers['ml-effective-timestamp']) { + operation.timestamp.value = response.headers['ml-effective-timestamp']; + } + } + var dispatcher = null; if (isMultipart) { if (expectedType !== 'multipart') { @@ -69,6 +99,10 @@ function responseDispatcher(response) { } dispatcher = new MultipartDispatcher(operation); + } else if (20 <= responseTypeLen && responseType.substr(0, 20) === 'application/json-seq') { + dispatcher = new JSONSeqDispatcher(operation); + } else if (8 <= responseTypeLen && responseType.substr(0, 8) === 'text/csv') { + dispatcher = new CSVDispatcher(operation); } else { if (expectedType === 'multipart') { operation.logger.debug('expected multipart but received body'); @@ -104,6 +138,9 @@ function responseDispatcher(response) { case 'objectStream': dispatcher.objectStream(inputHeader, response); break; + case 'sequenceStream': + dispatcher.sequenceStream(inputHeader, response); + break; default: operation.errorListener('unknown output mode '+outputMode); break; @@ -111,6 +148,187 @@ function responseDispatcher(response) { } } +function CSVDispatcher(operation) { + if (!(this instanceof CSVDispatcher)) { + return new CSVDispatcher(operation); + } + + this.operation = operation; +} +CSVDispatcher.prototype.promise = function dispatchCSVPromise( + contentType, response + ) { + var operation = this.operation; + + operation.logger.debug('csv promise'); + var collectObject = function collectPromiseBodyObject(data) { + operation.data = data; + resolvedPromise(operation, operation.resolve); + }; + + var isString = operation.copyResponseHeaders(response); + + response.pipe(concatStream( + {encoding: (isString ? 'string' : 'buffer')}, + collectObject + )); +}; +CSVDispatcher.prototype.chunkedStream = function dispatchCSVChunkedStream( + contentType, response + ) { + var operation = this.operation; + + operation.logger.debug('csv chunked stream'); + + // HTTP response gives a chunked stream to begin with + // .stream('chunked') creates through2 stream (writable and readable) + // Simply pipe HTTP response to the through2 stream + response.pipe(operation.outputStream); +}; +function JSONSeqDispatcher(operation) { + if (!(this instanceof JSONSeqDispatcher)) { + return new JSONSeqDispatcher(operation); + } + + this.operation = operation; +} +JSONSeqDispatcher.prototype.promise = function dispatchJSONSeqPromise( + contentType, response + ) { + var operation = this.operation; + var errorListener = operation.errorListener; + var objectQueue = new FifoQueue(2); + var parsedObjects = 0; + + operation.logger.debug('json sequence promise'); + + var dataListener = function JSONSeqDataListener(object) { + parsedObjects++; + operation.logger.debug('json-seq parsing object %d', parsedObjects); + objectQueue.addLast(object); + }; + + var finishListener = function JSONSeqFinishListener() { + operation.logger.debug('json-seq finished parsing %d objects', parsedObjects); + operation.data = objectQueue.getQueue(); + resolvedPromise(operation, operation.resolve); + + dataListener = null; + finishListener = null; + parser = null; + objectQueue = null; + + }; + + var parser = new jsonParser() + .on('data', dataListener) + .on('truncated', function(buf) { + throw new Error('json-seq truncated data encountered: ' + buf); + }) + .on('invalid', errorListener) + .on('finish', finishListener); + + response.pipe(parser); + +}; +JSONSeqDispatcher.prototype.sequenceStream = function dispatchJSONSeqSequenceStream( + contentType, response + ) { + this.stream('sequence', response); +}; +JSONSeqDispatcher.prototype.objectStream = function dispatchJSONSeqObjectStream( + contentType, response + ) { + this.stream('object', response); +}; +JSONSeqDispatcher.prototype.stream = function dispatchJSONSeqStream( + streamMode, response + ) { + var operation = this.operation; + var errorListener = operation.errorListener; + var outputStream = operation.outputStream; + var parsedObjects = 0; + var hasParsed = false; + var hasEnded = false; + + operation.logger.debug('json sequence stream ' + streamMode); + + var dataListener = function JSONSeqDataListener(object) { + parsedObjects++; + operation.logger.debug('parsing object %d', parsedObjects); + operation.logger.debug(object); + + var writeResult = null; + if (object !== null && object !== undefined) { + if (streamMode === 'object') { + writeResult = outputStream.write(object); + } else if (streamMode === 'sequence') { + writeResult = outputStream.write('\x1e' + JSON.stringify(object) + '\n'); + } else { + writeResult = outputStream.write(JSON.stringify(object)); + } + } + + // Manage backpressure + if (writeResult === false) { + // Only pause resp stream if resp hasn't ended + if (!hasEnded) { + response.pause(); + } + return; + } + + }; + + var responseFinisher = function JSONSeqFinishListener() { + + if (hasParsed && hasEnded) { + operation.logger.debug('finished parsing %d objects', parsedObjects); + + dataListener = null; + responseFinisher = null; + parseFinishListener = null; + responseEndListener = null; + drainListener = null; + parser = null; + + outputStream.end(); + } + + }; + + var parseFinishListener = function objectParseFinishListener() { + hasParsed = true; + responseFinisher(); + }; + + var responseEndListener = function objectResponseEndListener() { + hasEnded = true; + responseFinisher(); + }; + + var drainListener = function objectDrainListener() { + if (!hasEnded) { + response.resume(); + } + }; + + var parser = new jsonParser() + .on('data', dataListener) + .on('truncated', function(buf) { + throw new Error('truncated data encountered: ' + buf); + }) + .on('invalid', errorListener) + .on('finish', parseFinishListener); + + response.on('end', responseEndListener); + + outputStream.on('drain', drainListener); + + response.pipe(parser); + +}; + function BodyDispatcher(operation) { if (!(this instanceof BodyDispatcher)) { return new BodyDispatcher(operation); @@ -150,13 +368,15 @@ BodyDispatcher.prototype.promise = function dispatchBodyPromise( operation.logger.debug('body promise'); var collectObject = function collectPromiseBodyObject(data) { + // turn collected data into something usable + // e.g., if JSON, parse as JS object operation.data = operation.collectBodyObject(data); resolvedPromise(operation, operation.resolve); - collectObject = null; }; var isString = operation.copyResponseHeaders(response); + // concatStream accumulates response with callback response.pipe(concatStream( {encoding: (isString ? 'string' : 'buffer')}, collectObject @@ -169,6 +389,9 @@ BodyDispatcher.prototype.chunkedStream = function dispatchBodyChunkedStream( operation.logger.debug('body chunked stream'); + // HTTP response gives a chunked stream to begin with + // .stream('chunked') creates through2 stream (writable and readable) + // Simply pipe HTTP response to the through2 stream response.pipe(operation.outputStream); }; BodyDispatcher.prototype.objectStream = function dispatchBodyObjectStream( @@ -178,16 +401,16 @@ BodyDispatcher.prototype.objectStream = function dispatchBodyObjectStream( operation.logger.debug('body object stream'); + // outputStream is a through2 stream in object mode var outputStream = operation.outputStream; var collectObject = function collectStreamBodyObject(data) { + // similar to promise body case, but write to through2 var writableObject = operation.collectBodyObject(data); if (writableObject != null) { outputStream.write(writableObject); } outputStream.end(); - - collectObject = null; }; var isString = operation.copyResponseHeaders(response); @@ -198,6 +421,10 @@ BodyDispatcher.prototype.objectStream = function dispatchBodyObjectStream( )); }; +// Multipart cases similar to the above, but with multiple objects +// Promise case: Accumulate an array of objects +// Chunked case: Send chunks (but filter out multipart bits -- e.g., headers) +// Object stream case: Write multiple objects instead of single object function MultipartDispatcher(operation) { if (!(this instanceof MultipartDispatcher)) { return new MultipartDispatcher(operation); @@ -241,6 +468,7 @@ MultipartDispatcher.prototype.promise = function dispatchMultipartPromise( boundary, response ) { var operation = this.operation; + operation.logger.debug('multipart promise'); var errorListener = operation.errorListener; @@ -248,8 +476,6 @@ MultipartDispatcher.prototype.promise = function dispatchMultipartPromise( var objectQueue = new FifoQueue(2); var partReaderQueue = new FifoQueue(3); - var metadataBuffer = null; - var parsingParts = 0; var parsedParts = 0; @@ -257,8 +483,11 @@ MultipartDispatcher.prototype.promise = function dispatchMultipartPromise( var hasEnded = false; var responseFinisher = function promiseResponseFinisher() { - if (metadataBuffer !== null) { - operation.queueMetadata(metadataBuffer, objectQueue); + // If there is metadata left in the buffer, add it to queue + if (operation.nextMetadataBuffer !== null) { + var metadataHeaders = operation.nextMetadataBuffer[0]; + mlutil.copyProperties(operation.nextMetadataBuffer[1], metadataHeaders); + objectQueue.addLast(metadataHeaders); } operation.logger.debug('ending multipart promise'); @@ -283,10 +512,14 @@ MultipartDispatcher.prototype.promise = function dispatchMultipartPromise( partReaderQueue.removeFirst(); - metadataBuffer = operation.queueDocument( - (data.length === 0) ? null : data, rawHeaderQueue, metadataBuffer, objectQueue + var madeObject = operation.makeObject( + (data.length === 0) ? null : data, rawHeaderQueue ); + if (madeObject !== null && madeObject !== undefined) { + objectQueue.addLast(madeObject); + } + if (partReaderQueue.hasItem()) { var partConcatenator = concatStream(partFinisher); partConcatenator.on('error', errorListener); @@ -295,9 +528,8 @@ MultipartDispatcher.prototype.promise = function dispatchMultipartPromise( partReadStream.pipe(partConcatenator); } else if (hasParsed) { responseFinisher(); - } else if (!hasEnded) { - parser.emit('drain'); } + }; var partHeadersListener = function promisePartHeadersListener(headers) { @@ -345,6 +577,7 @@ MultipartDispatcher.prototype.chunkedStream = function dispatchMultipartChunkedS boundary, response ) { var operation = this.operation; + operation.logger.debug('multipart chunked stream'); var errorListener = operation.errorListener; @@ -374,8 +607,6 @@ MultipartDispatcher.prototype.chunkedStream = function dispatchMultipartChunkedS partReadStream.pipe(outputStream, {end: false}); } else if (hasParsed) { responseFinisher(); - } else if (!hasEnded) { - parser.emit('drain'); } }; @@ -414,11 +645,15 @@ MultipartDispatcher.prototype.objectStream = function dispatchMultipartObjectStr boundary, response ) { var operation = this.operation; + operation.logger.debug('multipart object stream'); var errorListener = operation.errorListener; var rawHeaderQueue = new FifoQueue(5); - var metadataBuffer = null; + var partReaderQueue = new FifoQueue(3); + + // For referenced attachments case + var partBuffer = null; var parsingParts = 0; var parsedParts = 0; @@ -426,19 +661,119 @@ MultipartDispatcher.prototype.objectStream = function dispatchMultipartObjectStr var hasParsed = false; var hasEnded = false; - var partTransform = function objectPartQueueTransform(data) { - parsedParts++; - var objectQueue = queuedReader.getItemQueue(); - metadataBuffer = operation.queueDocument( - (data.length === 0) ? null : data, rawHeaderQueue, metadataBuffer, objectQueue - ); - doneChecker(); + var isConcatenating = false; + + var responseFinisher = function objectResponseFinisher() { + + if (!partReaderQueue.hasItem() && hasParsed && hasEnded) { + + // Handle multipart with reference attachments (rows) + if (operation.complexValues === 'reference') { + // If there is a part left in the buffer, write it + if (partBuffer !== null) { + operation.outputStream.write(partBuffer); + partBuffer = null; + } + } + // All other cases + else { + // If there is metadata left in the buffer, write it + if (operation.nextMetadataBuffer !== null) { + var metadataHeaders = operation.nextMetadataBuffer[0]; + mlutil.copyProperties(operation.nextMetadataBuffer[1], metadataHeaders); + operation.outputStream.write(metadataHeaders); + operation.nextMetadataBuffer = null; + } + } + + rawHeaderQueue = null; + parser = null; + partHeadersListener = null; + partListener = null; + parseFinishListener = null; + responseEndListener = null; + + operation.outputStream.end(); + } + }; - var queuedReader = new QueuedReader( - {objectMode: true}, operation.logger, partTransform - ); - this.queuedReader = queuedReader; + var partFinisher = function objectPartFinisher(data) { + parsedParts++; + operation.logger.debug('parsed part %d', parsedParts); + + var madeObject = operation.makeObject( + (data.length === 0) ? null : data, rawHeaderQueue + ); + + // Handle multipart with reference attachments (rows) + var writeResult = null; + if (operation.complexValues === 'reference') { + if (madeObject !== null && madeObject !== undefined) { + // Columns object + if (madeObject.kind === 'columns') { + writeResult = operation.outputStream.write(madeObject); + } + // Row object + else if (madeObject.kind === 'row') { + // First + if (partBuffer === null) { + partBuffer = madeObject; + } + // Subsequent + else { + writeResult = operation.outputStream.write(partBuffer); + partBuffer = madeObject; + } + } + // Attachment object + else { + // Remove '[n]' to get column name + var columnName = madeObject.contentId + .slice(0, madeObject.contentId.lastIndexOf('[')); + // Put attachment into currently cached part + partBuffer.content[columnName] = { + contentType: madeObject.contentType, + format: madeObject.format, + content: madeObject.content + }; + } + } + } + // All other cases + else { + if (madeObject !== null && madeObject !== undefined) { + writeResult = operation.outputStream.write(madeObject); + } + } + + // Manage backpressure + if (writeResult === false) { + // Only pause resp stream if not all parsed and resp hasn't ended + if (hasParsed && !partReaderQueue.hasItem()) { + responseFinisher(); + } else if (!hasEnded) { + response.pause(); + } + return; + } + + partReaderQueue.removeFirst(); + isConcatenating = false; + + // If item avail, concat-stream it with callback to finisher + if (partReaderQueue.hasItem()) { + isConcatenating = true; + var partRead = concatStream(partFinisher); + partRead.on('error', errorListener); + var partReadStream = partReaderQueue.getFirst(); + partReadStream.pipe(partRead); + + } else if (hasParsed) { + responseFinisher(); + } + + }; var partHeadersListener = function objectPartHeadersListener(headers) { operation.logger.debug('queued header'); @@ -447,49 +782,42 @@ MultipartDispatcher.prototype.objectStream = function dispatchMultipartObjectStr var partListener = function objectPartListener(partReadStream) { parsingParts++; + operation.logger.debug('parsing part %d', parsingParts); + partReadStream.on('header', partHeadersListener); partReadStream.on('error', errorListener); - queuedReader.addReader(partReadStream); + partReaderQueue.addLast(partReadStream); + + if (partReaderQueue.isLast()) { + isConcatenating = true; + var partRead = concatStream(partFinisher); + partRead.on('error', errorListener); + partReadStream.pipe(partRead); + } }; var parseFinishListener = function objectParseFinishListener() { hasParsed = true; - doneChecker(); + responseFinisher(); }; var responseEndListener = function objectResponseEndListener() { hasEnded = true; - doneChecker(); + responseFinisher(); }; - /** - * Check if HTTP response has ended, Dicer has finished parsing, - * and the Queue is empty. If all are true, then we can call end() - * on output stream. - */ - var doneChecker = function doneChecker() { - - if (queuedReader.isQueueEmpty() && hasParsed && hasEnded) { - if (metadataBuffer !== null) { - var objectQueue = queuedReader.getItemQueue(); - operation.queueMetadata(metadataBuffer, objectQueue); - metadataBuffer = null; + var drainListener = function objectDrainListener() { + if (!hasEnded) { + response.resume(); + // Don't read if concat in progress to avoid double processing + if (partReaderQueue.hasItem() && !isConcatenating) { + isConcatenating = true; + var partRead = concatStream(partFinisher); + partRead.on('error', errorListener); + var partReadStream = partReaderQueue.getFirst(); + partReadStream.pipe(partRead); } - - rawHeaderQueue = null; - queuedReader = null; - parser = null; - partHeadersListener = null; - partListener = null; - parseFinishListener = null; - responseEndListener = null; - partTransform = null; - - operation.outputStream.end(); - } else if (!hasEnded && parsedParts === parsingParts) { - parser.emit('drain'); } - }; var parser = new Dicer({boundary: boundary}); @@ -499,9 +827,10 @@ MultipartDispatcher.prototype.objectStream = function dispatchMultipartObjectStr response.on('end', responseEndListener); + operation.outputStream.on('drain', drainListener); + response.pipe(parser); - queuedReader.pipe(operation.outputStream); }; /* Note: Dicer appears to read ahead. @@ -522,133 +851,6 @@ MultipartDispatcher.prototype.objectStream = function dispatchMultipartObjectStr part end 2 finish */ -function QueuedReader(options, logger, itemsTransform) { - if (!(this instanceof QueuedReader)) { - return new QueuedReader(options, logger, itemsTransform); - } - stream.Readable.call(this, options); - - var self = this; - - this.itemsTransform = itemsTransform; - this.logger = logger; - - this.minWriters = 5; - this.maxItems = 10; - - this.readerQueue = new FifoQueue(10); - this.writerQueue = new FifoQueue(this.minWriters); - this.itemQueue = new FifoQueue(this.maxItems); - - this.isReading = true; - this.queueDone = false; - - this.addItems = function queuedReaderAddItems(data) { - self.writerQueue.removeFirst(); - - self.logger.debug('concatenated item'); - - var itemQueue = self.itemQueue; - var beforeLength = itemQueue.length(); - - self.itemsTransform(data); - - if (beforeLength < itemQueue.length()) { - if (beforeLength === 0) { - self.emit('readable'); - } - if (self.isReading || isLast) { - logger.debug('writing first item'); - self.isReading = self.push(itemQueue.pollFirst()); - } - } - - self.nextReader(); - }; -} -util.inherits(QueuedReader, stream.Readable); -QueuedReader.prototype.addReader = function queuedAddReader(reader) { - var readerQueue = this.readerQueue; - if (readerQueue === null) { - return; - } - - readerQueue.addLast(reader); - this.logger.debug('queued item %d', readerQueue.getTotal()); - this.nextReader(); -}; -QueuedReader.prototype.getItemQueue = function getItemQueue() { - return this.itemQueue; -}; -QueuedReader.prototype.isQueueEmpty = function isQueueEmpty() { - return (this.readerQueue.length() === 0 && this.writerQueue.length() === 0); -}; -QueuedReader.prototype.nextReader = function queuedReaderNextReader() { - if (!this.isReading) { - return; - } - - var readerQueue = this.readerQueue; - if (readerQueue === null || readerQueue.length() === 0) { - return; - } - - if (this.itemQueue.length() >= this.maxItems) { - return; - } - - var writerQueue = this.writerQueue; - var minWriters = this.minWriters; - - var logger = this.logger; - - var addItems = this.addItems; - - var i = writerQueue.length(); - var j = readerQueue.length(); - var writer = null; - for (; i <= minWriters && j > 0; i++, j--) { - writer = concatStream(addItems); - writerQueue.addLast(writer); - logger.debug('reading item'); - readerQueue.pollFirst().pipe(writer); - } -}; -QueuedReader.prototype._read = function queuedReaderRead(/*size*/) { - var itemQueue = this.itemQueue; - if (itemQueue === null) { - return; - } - - var logger = this.logger; - - var hasItem = itemQueue.hasItem(); - var canRead = true; - while (hasItem && canRead) { - logger.debug('writing item'); - canRead = this.push(itemQueue.pollFirst()); - hasItem = itemQueue.hasItem(); - } - - if (this.queueDone && !hasItem && this.readerQueue.length() === 0 && - this.writerQueue.length() === 0) { - this.logger.debug('wrote %d items', itemQueue.getTotal()); - this.push(null); - - this.readerQueue = null; - this.writerQueue = null; - this.itemQueue = null; - } else if (!canRead) { - if (this.isReading) { - this.isReading = false; - } - } else { - if (!this.isReading) { - this.isReading = true; - } - this.nextReader(); - } -}; function FifoQueue(min) { if (!(this instanceof FifoQueue)) { @@ -680,9 +882,6 @@ FifoQueue.prototype.isLast = function fifoIsLast() { FifoQueue.prototype.getFirst = function fifoGetFirst() { return (this.first >= 0) ? this.queue[this.first] : undefined; }; -FifoQueue.prototype.getLast = function fifoGetLast() { - return (this.first >= 0) ? this.queue[this.last] : undefined; -}; FifoQueue.prototype.removeFirst = function fifoRemoveFirst() { if (this.first >= 0) { this.queue[this.first] = undefined; @@ -701,17 +900,20 @@ FifoQueue.prototype.pollFirst = function fifoPollFirst() { } return item; }; -FifoQueue.prototype.getTotal = function fifoGetTotal() { - return this.total; -}; FifoQueue.prototype.getQueue = function fifoGetQueue() { return (this.first === 0 && this.last === this.queue.length) ? this.queue : this.queue.slice(this.first, this.last + 1); }; +/* +FifoQueue.prototype.getLast = function fifoGetLast() { + return (this.first >= 0) ? this.queue[this.last] : undefined; +}; +FifoQueue.prototype.getTotal = function fifoGetTotal() { + return this.total; +}; FifoQueue.prototype.length = function fifoLength() { return (this.first >= 0) ? (this.last - this.first) + 1 : 0; }; -/* FifoQueue.prototype.at = function fifoAt(i) { return this.queue[this.first + i]; }; @@ -931,6 +1133,9 @@ function operationResultStream() { case 'object': outputStream= through2({objectMode: true}); break; + case 'sequence': + outputStream= through2(); + break; default: throw new Error('unknown stream mode: '+streamMode); } diff --git a/lib/rest-server-properties.js b/lib/rest-server-properties.js index e5958e0c..4c270e5c 100644 --- a/lib/rest-server-properties.js +++ b/lib/rest-server-properties.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/rows.js b/lib/rows.js new file mode 100644 index 00000000..54b04c20 --- /dev/null +++ b/lib/rows.js @@ -0,0 +1,315 @@ + +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + + +const requester = require('./requester.js'), + mlutil = require('./mlutil.js'), + Operation = require('./operation.js'), + planBuilder = require('./plan-builder.js'); + +/** @ignore */ +function Rows(client) { + this.client = client; +} + +/** + * Provides functions for performing SQL-like, relational operations + * on MarkLogic data. Enables you to retrieve document data as rows + * by executing a plan constructed by a {@link planBuilder}. + * @namespace rows + */ + +/** + * Specifies how a {@link planBuilder} plan is executed, the formatting + * of the results returned, and variable bindings. + * @typedef {object} rows.RowsOptions + * @since 2.1.1 + * @property {string} [format] - Format of the returned results. Possible + * values: 'json'|'xml'|'csv'. Default: 'json'. + * @property {string} [structure] - Structure of the output. Possible values: + * 'object'|'array'. Default: 'object'. + * @property {string} [columnTypes] - Whether to emit column data types on + * each row or only the column name header. Possible values: 'rows'|'header'. + * Default: 'rows'. + * @property {string} [complexValues] - Whether complex array, binary, element, + * object, and text node columns should be serialized inline or as a reference + * to a separate response part. Possible values: 'inline'|'reference'. Default: + * 'inline'. Only relevant when results are delivered as an JSON object stream. + * @property {object} [bindings] - Values for placeholder variables within the + * query plan. You define them with an object whose keys are the names of the + * variables and whose values are either primitives or objects with a type or + * lang key and a value key. Bindings are handled the same way as with + * graphs#sparql and graphs#sparqlUpdate. + * @property {DatabaseClient.Timestamp} [timestamp] - A Timestamp object for + * point-in-time operations. + */ + +/** + * Executes a plan built by a {@link planBuilder} and returns a promise data + * structure. + * @method rows#query + * @since 2.1.1 + * @param {object} builtPlan - A {@link planBuilder} object or a built + * plan defined as a JSON object. + * @param {RowsOptions} options - Options that control how the plan is + * executed and the results returned. + * @returns {Promise} A Promise. + */ +Rows.prototype.query = function queryRows() { + let args = mlutil.asArray.apply(null, arguments); + + if (args.length < 1) { + throw new Error('built plan required'); + } + + let builtPlan = args[0], + options = (args.length === 2) ? args[1] : null; + + return queryRowsImpl.call(this, builtPlan, null, options); +}; +function queryRowsImpl(builtPlan, streamType, options) { + let sep = '?', + validFormats = ['json','xml','csv'], + validStructures = ['object','array'], + validColumnTypes = ['rows','header'], + validComplexValues = ['inline','reference'], + validStreamTypes = ['chunked','object','sequence'], + // set defaults + format = 'json', + structure = 'object', + columnTypes = 'rows', + complexValues = null, + timestamp = null; + + options = options || {}; + + if (streamType !== null && !(validStreamTypes.indexOf(streamType) >= 0)) { + throw new Error('invalid stream type "' + options.streamType + '"'); + } + + if (options.format !== null && options.format !== void 0) { + if (validFormats.indexOf(options.format) >= 0) { + format = options.format; + } else { + throw new Error('invalid row format "' + options.format + '"'); + } + } + + if (options.structure !== null && options.structure !== void 0) { + if (validStructures.indexOf(options.structure) >= 0) { + structure = options.structure; + } else { + throw new Error('invalid row structure "' + options.structure + '"'); + } + } + + if (options.columnTypes !== null && options.columnTypes !== void 0) { + if (validColumnTypes.indexOf(options.columnTypes) >= 0) { + columnTypes = options.columnTypes; + } else { + throw new Error('invalid column types "' + options.columnTypes + '"'); + } + } + + if (options.complexValues !== null && options.complexValues !== void 0) { + if (validComplexValues.indexOf(options.complexValues) >= 0) { + complexValues = options.complexValues; + } else { + throw new Error('invalid node columns "' + options.complexValues + '"'); + } + } + + if (options.timestamp !== null && options.timestamp !== void 0) { + if (!(timestamp instanceof mlutil.Timestamp)) { + timestamp = options.timestamp; + } else { + throw new Error('invalid timestamp'); + } + } + + let endpoint = '/v1/rows'; + + if (options.bindings) { + endpoint += mlutil.makeBindingsParams(options.bindings, sep); + if (sep === '?') { sep = '&'; } + } + + const connectionParams = this.client.connectionParams; + const requestOptions = mlutil.copyProperties(connectionParams); + requestOptions.method = 'POST'; + + let acceptHeader = null; + let responseType = null; + switch (format) { + case 'xml': + acceptHeader = 'application/xml'; + responseType = 'single'; + endpoint += sep + 'output=' + structure + '&column-types=' + columnTypes; + break; + case 'csv': + acceptHeader = 'text/csv'; + responseType = 'single'; + endpoint += sep + 'output=' + structure + '&column-types=header'; + if (sep === '?') { sep = '&'; } + break; + default: + if (streamType !== null && streamType === 'sequence'){ + acceptHeader = 'application/json-seq'; + responseType = 'single'; + } else if (streamType !== null && streamType === 'object'){ + if (complexValues === 'reference') { + acceptHeader = 'multipart/mixed; boundary=' + mlutil.multipartBoundary; + responseType = 'multipart'; + } else { + acceptHeader = 'application/json-seq'; + responseType = 'single'; + } + } + // Chunked stream, promise + else { + acceptHeader = 'application/json'; + responseType = 'single'; + } + endpoint += sep + 'output=' + structure + '&column-types=' + columnTypes; + if (sep === '?') { sep = '&'; } + endpoint += (complexValues === 'reference') ? sep + 'node-columns=reference' : ''; + break; + } + requestOptions.headers = { + 'Content-Type': 'application/json', + 'Accept': acceptHeader + }; + + if (timestamp !== null) { + if (timestamp.value !== null) { + endpoint += sep + 'timestamp='+timestamp.value; + if (sep === '?') { sep = '&'; } + } + } + + // Specify database if defined in client connection + requestOptions.path = mlutil.databaseParam(connectionParams, endpoint, '&'); + + const operation = new Operation( + 'query rows', this.client, requestOptions, 'single', responseType + ); + operation.validStatusCodes = [200, 404]; + operation.complexValues = complexValues; + // Built plan can be PlanBuilder object or JSON string + if (builtPlan instanceof planBuilder.Plan) { + operation.requestBody = JSON.stringify(builtPlan.export()); + } else { + operation.requestBody = builtPlan; + } + operation.timestamp = (timestamp !== null) ? timestamp : null; + + const responseSelector = requester.startRequest(operation); + + if (streamType !== null) { + return responseSelector.stream(streamType); + } else { + return responseSelector.result(); + } + +} + +/** + * Executes a plan built by a {@link planBuilder} and returns a readable + * stream data structure. + * @method rows#queryAsStream + * @since 2.1.1 + * @param {object} builtPlan - A {@link planBuilder} object or a built + * plan defined as a JSON object. + * @param {string} streamType - Type of stream. Possible values: 'chunked'| + * 'object'|'sequence'. Default: 'chunked'. + * @param {RowsOptions} options - Options that control how the plan is + * executed and the results returned. + * @returns {ReadableStream} A readable stream. + */ +Rows.prototype.queryAsStream = function queryAsStreamRows() { + let args = mlutil.asArray.apply(null, arguments), + streamType = 'chunked', // default + options = null; + + if (args.length < 1) { + throw new Error('built plan required'); + } + + let builtPlan = args[0]; + + if (args.length === 2) { + if (typeof args[1] === 'string' || args[1] instanceof String) { + streamType = args[1]; + } else { + options = args[1]; + } + } else if (args.length > 2) { + streamType = args[1]; + options = args[2]; + } + + return queryRowsImpl.call(this, builtPlan, streamType, options); +}; + +/** + * Returns an explanation of an execution plan as a promise. + * @method rows#explain + * @since 2.1.1 + * @param {object} builtPlan - A {@link planBuilder} object or a built + * plan as a JSON object. + * @param {string} [format] - The format of the returned representation: + * 'json'|'xml'. The default is 'json'. + * @returns {Promise} A promise whose success callback receives the + * explanation as JSON or XML. + */ +Rows.prototype.explain = function explainRows(builtPlan, format) { + + const connectionParams = this.client.connectionParams; + const requestOptions = mlutil.copyProperties(connectionParams); + requestOptions.method = 'POST'; + const validFormats = ['json','xml','csv']; + let acceptHeader = 'application/json'; // default + if (format !== null && format !== void 0) { + if (validFormats.indexOf(format) >= 0) { + acceptHeader = 'application/' + format; + } else { + throw new Error('invalid explain format "' + format + '"'); + } + } + requestOptions.headers = { + 'Content-Type': 'application/json', + 'Accept': acceptHeader + }; + + requestOptions.path = '/v1/rows?output=explain'; + + const operation = new Operation( + 'explain rows', this.client, requestOptions, 'single', 'single'); + operation.validStatusCodes = [200, 404]; + // Built plan can be PlanBuilder object or JSON string + if (builtPlan instanceof planBuilder.Plan) { + operation.requestBody = JSON.stringify(builtPlan.export()); + } else { + operation.requestBody = builtPlan; + } + + const responseSelector = requester.startRequest(operation); + return responseSelector.result(); +} + +module.exports = Rows; diff --git a/lib/server-exec.js b/lib/server-exec.js index 0e3f4e60..44b187a9 100644 --- a/lib/server-exec.js +++ b/lib/server-exec.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/server-types-generated.js b/lib/server-types-generated.js new file mode 100644 index 00000000..da83b215 --- /dev/null +++ b/lib/server-types-generated.js @@ -0,0 +1,747 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +/* IMPORTANT: Do not edit. This file is generated. */ +class ServerType { + constructor(ns, fn, args) { + this._ns = ns; + this._fn = fn; + this._args = args; + } +} +class Item extends ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class SemBlank extends ServerType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class Node extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class MapMap extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsReference extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsAnySimpleType extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsPeriod extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsQuery extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsRegion extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class SemStore extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class JsonArray extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class MathLinearModel extends Item { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class ArrayNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class TextNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XmlContentNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + + static [Symbol.hasInstance](obj) { + return obj instanceof Object && ( + XmlContentNode.prototype.isPrototypeOf(obj) || + obj instanceof CommentNode || obj instanceof ElementNode || obj instanceof ProcessingInstructionNode || obj instanceof TextNode + ); + } +} +class ObjectNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class BooleanNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class AttributeNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class JsonContentNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + + static [Symbol.hasInstance](obj) { + return obj instanceof Object && ( + JsonContentNode.prototype.isPrototypeOf(obj) || + obj instanceof ArrayNode || obj instanceof BooleanNode || obj instanceof NullNode || obj instanceof NumberNode || obj instanceof ObjectNode || obj instanceof TextNode + ); + } +} +class DocumentNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class JsonRootNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + + static [Symbol.hasInstance](obj) { + return obj instanceof Object && ( + JsonRootNode.prototype.isPrototypeOf(obj) || + obj instanceof ArrayNode || obj instanceof ObjectNode + ); + } +} +class ProcessingInstructionNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CommentNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class NumberNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class NullNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XmlRootNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + + static [Symbol.hasInstance](obj) { + return obj instanceof Object && ( + XmlRootNode.prototype.isPrototypeOf(obj) || + obj instanceof CommentNode || obj instanceof ElementNode || obj instanceof ProcessingInstructionNode + ); + } +} +class ElementNode extends Node { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class JsonObject extends MapMap { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsElementAttributeReference extends CtsReference { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsJsonPropertyReference extends CtsReference { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsPathReference extends CtsReference { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsUriReference extends CtsReference { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsFieldReference extends CtsReference { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsCollectionReference extends CtsReference { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsElementReference extends CtsReference { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsAnyAtomicType extends XsAnySimpleType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsPoint extends CtsRegion { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsPolygon extends CtsRegion { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsCircle extends CtsRegion { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class CtsBox extends CtsRegion { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsTime extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsBoolean extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsNumeric extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + + static [Symbol.hasInstance](obj) { + return obj instanceof Object && ( + XsNumeric.prototype.isPrototypeOf(obj) || + obj instanceof XsDecimal || obj instanceof XsDouble || obj instanceof XsFloat + ); + } +} +class SemUnknown extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsDuration extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsDecimal extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsBase64Binary extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsFloat extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsString extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsGYearMonth extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsGMonthDay extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsUntypedAtomic extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsQName extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsHexBinary extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsGYear extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsGMonth extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsDateTime extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class SemInvalid extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsDouble extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsAnyURI extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class SemBnode extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsGDay extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsDate extends XsAnyAtomicType { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsYearMonthDuration extends XsDuration { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsDayTimeDuration extends XsDuration { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsInteger extends XsDecimal { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsNormalizedString extends XsString { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class RdfLangString extends XsString { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class SemIri extends XsAnyURI { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsNonPositiveInteger extends XsInteger { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsLong extends XsInteger { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsNonNegativeInteger extends XsInteger { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsToken extends XsNormalizedString { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsNegativeInteger extends XsNonPositiveInteger { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsInt extends XsLong { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsUnsignedLong extends XsNonNegativeInteger { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsPositiveInteger extends XsNonNegativeInteger { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsNMTOKEN extends XsToken { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsLanguage extends XsToken { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsName extends XsToken { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsShort extends XsInt { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsUnsignedInt extends XsUnsignedLong { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsNCName extends XsName { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsByte extends XsShort { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsUnsignedShort extends XsUnsignedInt { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} +class XsUnsignedByte extends XsUnsignedShort { + + constructor(ns, fn, args) { + super(ns, fn, args); + } + +} + +module.exports = { + ServerType: ServerType, +ArrayNode: ArrayNode, +AttributeNode: AttributeNode, +BooleanNode: BooleanNode, +CommentNode: CommentNode, +CtsBox: CtsBox, +CtsCircle: CtsCircle, +CtsCollectionReference: CtsCollectionReference, +CtsElementAttributeReference: CtsElementAttributeReference, +CtsElementReference: CtsElementReference, +CtsFieldReference: CtsFieldReference, +CtsJsonPropertyReference: CtsJsonPropertyReference, +CtsPathReference: CtsPathReference, +CtsPeriod: CtsPeriod, +CtsPoint: CtsPoint, +CtsPolygon: CtsPolygon, +CtsQuery: CtsQuery, +CtsReference: CtsReference, +CtsRegion: CtsRegion, +CtsUriReference: CtsUriReference, +DocumentNode: DocumentNode, +ElementNode: ElementNode, +Item: Item, +JsonContentNode: JsonContentNode, +JsonRootNode: JsonRootNode, +JsonArray: JsonArray, +JsonObject: JsonObject, +MapMap: MapMap, +MathLinearModel: MathLinearModel, +Node: Node, +NullNode: NullNode, +NumberNode: NumberNode, +ObjectNode: ObjectNode, +ProcessingInstructionNode: ProcessingInstructionNode, +RdfLangString: RdfLangString, +SemBlank: SemBlank, +SemBnode: SemBnode, +SemInvalid: SemInvalid, +SemIri: SemIri, +SemStore: SemStore, +SemUnknown: SemUnknown, +TextNode: TextNode, +XmlContentNode: XmlContentNode, +XmlRootNode: XmlRootNode, +XsAnyAtomicType: XsAnyAtomicType, +XsAnySimpleType: XsAnySimpleType, +XsAnyURI: XsAnyURI, +XsBase64Binary: XsBase64Binary, +XsBoolean: XsBoolean, +XsByte: XsByte, +XsDate: XsDate, +XsDateTime: XsDateTime, +XsDayTimeDuration: XsDayTimeDuration, +XsDecimal: XsDecimal, +XsDouble: XsDouble, +XsDuration: XsDuration, +XsFloat: XsFloat, +XsGDay: XsGDay, +XsGMonth: XsGMonth, +XsGMonthDay: XsGMonthDay, +XsGYear: XsGYear, +XsGYearMonth: XsGYearMonth, +XsHexBinary: XsHexBinary, +XsInt: XsInt, +XsInteger: XsInteger, +XsLanguage: XsLanguage, +XsLong: XsLong, +XsName: XsName, +XsNCName: XsNCName, +XsNegativeInteger: XsNegativeInteger, +XsNMTOKEN: XsNMTOKEN, +XsNonNegativeInteger: XsNonNegativeInteger, +XsNonPositiveInteger: XsNonPositiveInteger, +XsNormalizedString: XsNormalizedString, +XsNumeric: XsNumeric, +XsPositiveInteger: XsPositiveInteger, +XsQName: XsQName, +XsShort: XsShort, +XsString: XsString, +XsTime: XsTime, +XsToken: XsToken, +XsUnsignedByte: XsUnsignedByte, +XsUnsignedInt: XsUnsignedInt, +XsUnsignedLong: XsUnsignedLong, +XsUnsignedShort: XsUnsignedShort, +XsUntypedAtomic: XsUntypedAtomic, +XsYearMonthDuration: XsYearMonthDuration +}; diff --git a/lib/transactions.js b/lib/transactions.js index fc6b0734..4c6d06c4 100644 --- a/lib/transactions.js +++ b/lib/transactions.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/transforms.js b/lib/transforms.js index 10ef3bb4..da66acdf 100644 --- a/lib/transforms.js +++ b/lib/transforms.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/values-builder.js b/lib/values-builder.js index 19e719df..ddde4bfa 100644 --- a/lib/values-builder.js +++ b/lib/values-builder.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/values.js b/lib/values.js index b8edeae0..e7e68134 100644 --- a/lib/values.js +++ b/lib/values.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,15 +43,26 @@ function Values(client) { * @method values#read * @since 1.0 * @param {object} valuesQuery - a query built by a {@link valuesBuilder} + * @param {DatabaseClient.Timestamp} [timestamp] - a Timestamp object for point-in-time + * operations * @returns {ResultProvider} an object whose result() function takes * a success callback that receives the tuples. */ Values.prototype.read = function readValues() { - if (arguments.length !== 1) { + if (arguments.length === 0 || arguments.length > 2) { throw new Error('incorrect number of arguments to read values'); } var arg = arguments[0]; + var timestamp = null; + if (arguments.length === 2) { + if (arguments[1] instanceof mlutil.Timestamp) { + timestamp = arguments[1]; + } else { + throw new Error('invalid timestamp argument'); + } + } + var structuredef = { name: 'structuredef', style: 'consistent' @@ -169,6 +180,12 @@ Values.prototype.read = function readValues() { endpoint += '&'+mlutil.endpointTransform(transform); } + if (timestamp !== null && timestamp !== void 0) { + if (timestamp.value !== null) { + endpoint += '×tamp='+timestamp.value; + } + } + var connectionParams = this.client.connectionParams; var requestOptions = mlutil.copyProperties(connectionParams); requestOptions.method = 'POST'; @@ -183,6 +200,7 @@ Values.prototype.read = function readValues() { ); operation.validStatusCodes = [200, 204]; operation.requestBody = {search: searchBody}; + operation.timestamp = (timestamp !== null) ? timestamp : null; return requester.startRequest(operation); }; diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 57e0a5b6..076e40c7 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,198 +1,36 @@ { "name": "marklogic", - "version": "2.0.0-ea4", + "version": "2.1.1", "dependencies": { - "acorn": { - "version": "3.3.0", - "from": "acorn@>=3.3.0 <4.0.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz" - }, - "acorn-jsx": { - "version": "3.0.1", - "from": "acorn-jsx@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz" - }, - "ansi-regex": { - "version": "2.1.1", - "from": "ansi-regex@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - }, - "ansi-styles": { - "version": "2.2.1", - "from": "ansi-styles@>=2.2.1 <3.0.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz" - }, - "archy": { - "version": "1.0.0", - "from": "archy@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz" - }, - "arr-diff": { - "version": "2.0.0", - "from": "arr-diff@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz" - }, - "arr-flatten": { - "version": "1.0.1", - "from": "arr-flatten@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.1.tgz" - }, - "array-differ": { - "version": "1.0.0", - "from": "array-differ@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz" - }, - "array-uniq": { - "version": "1.0.3", - "from": "array-uniq@>=1.0.2 <2.0.0", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz" - }, - "array-unique": { - "version": "0.2.1", - "from": "array-unique@>=0.2.1 <0.3.0", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz" - }, - "async": { - "version": "1.0.0", - "from": "async@>=1.0.0 <1.1.0", - "resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz" - }, - "balanced-match": { - "version": "0.4.2", - "from": "balanced-match@>=0.4.1 <0.5.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz" - }, - "beeper": { - "version": "1.1.1", - "from": "beeper@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz" + "big-integer": { + "version": "1.6.25", + "from": "big-integer@>=1.6.25 <2.0.0", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.25.tgz" }, "bluebird": { - "version": "3.5.0", - "from": "bluebird@>=3.4.7 <4.0.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz" - }, - "brace-expansion": { - "version": "1.1.6", - "from": "brace-expansion@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz" - }, - "braces": { - "version": "1.8.5", - "from": "braces@>=1.8.2 <2.0.0", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz" - }, - "browser-stdout": { - "version": "1.3.0", - "from": "browser-stdout@1.3.0", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz" - }, - "buffer-shims": { - "version": "1.0.0", - "from": "buffer-shims@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz" - }, - "catharsis": { - "version": "0.8.8", - "from": "catharsis@>=0.8.8 <0.9.0", - "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.8.tgz" - }, - "chalk": { - "version": "1.1.3", - "from": "chalk@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz" - }, - "cli": { - "version": "1.0.1", - "from": "cli@>=1.0.0 <1.1.0", - "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", - "dependencies": { - "glob": { - "version": "7.1.1", - "from": "glob@>=7.1.1 <8.0.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz" - } - } - }, - "clone": { - "version": "1.0.2", - "from": "clone@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz" - }, - "clone-stats": { - "version": "0.0.1", - "from": "clone-stats@>=0.0.1 <0.0.2", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz" - }, - "colors": { - "version": "1.0.3", - "from": "colors@>=1.0.0 <1.1.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz" - }, - "commander": { - "version": "2.9.0", - "from": "commander@2.9.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz" - }, - "concat-map": { - "version": "0.0.1", - "from": "concat-map@0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + "version": "3.5.1", + "from": "bluebird@>=3.5.1 <4.0.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz" }, "concat-stream": { "version": "1.6.0", "from": "concat-stream@>=1.6.0 <2.0.0", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz" }, - "console-browserify": { - "version": "1.1.0", - "from": "console-browserify@>=1.1.0 <1.2.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz" - }, "core-util-is": { "version": "1.0.2", "from": "core-util-is@>=1.0.0 <1.1.0", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" }, - "cycle": { - "version": "1.0.3", - "from": "cycle@>=1.0.0 <1.1.0", - "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz" - }, - "date-now": { - "version": "0.1.4", - "from": "date-now@>=0.1.4 <0.2.0", - "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz" - }, - "dateformat": { - "version": "2.0.0", - "from": "dateformat@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz" - }, - "debug": { - "version": "2.6.2", - "from": "debug@>=2.2.0 <3.0.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.2.tgz" - }, "deepcopy": { "version": "0.6.3", "from": "deepcopy@>=0.6.3 <0.7.0", "resolved": "https://registry.npmjs.org/deepcopy/-/deepcopy-0.6.3.tgz" }, - "defaults": { - "version": "1.0.3", - "from": "defaults@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz" - }, - "deprecated": { - "version": "0.0.1", - "from": "deprecated@>=0.0.1 <0.0.2", - "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz" - }, - "detect-file": { + "delimit-stream": { "version": "0.1.0", - "from": "detect-file@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz" + "from": "delimit-stream@0.1.0", + "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz" }, "dicer": { "version": "0.2.5", @@ -208,871 +46,50 @@ "version": "1.1.14", "from": "readable-stream@>=1.1.0 <1.2.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz" - } - } - }, - "diff": { - "version": "1.4.0", - "from": "diff@1.4.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz" - }, - "dom-serializer": { - "version": "0.1.0", - "from": "dom-serializer@>=0.0.0 <1.0.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", - "dependencies": { - "domelementtype": { - "version": "1.1.3", - "from": "domelementtype@>=1.1.1 <1.2.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz" - } - } - }, - "domelementtype": { - "version": "1.3.0", - "from": "domelementtype@>=1.3.0 <2.0.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz" - }, - "domhandler": { - "version": "2.3.0", - "from": "domhandler@>=2.3.0 <3.0.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz" - }, - "domutils": { - "version": "1.5.1", - "from": "domutils@>=1.5.1 <2.0.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz" - }, - "dtrace-provider": { - "version": "0.8.1", - "from": "dtrace-provider@>=0.8.0 <0.9.0", - "resolved": "https://registry.npmjs.org/dtrace-provider/-/dtrace-provider-0.8.1.tgz" - }, - "duplexer2": { - "version": "0.0.2", - "from": "duplexer2@0.0.2", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", - "dependencies": { - "isarray": { - "version": "0.0.1", - "from": "isarray@0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" }, - "readable-stream": { - "version": "1.1.14", - "from": "readable-stream@>=1.1.9 <1.2.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz" - } - } - }, - "end-of-stream": { - "version": "0.1.5", - "from": "end-of-stream@>=0.1.5 <0.2.0", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", - "dependencies": { - "once": { - "version": "1.3.3", - "from": "once@>=1.3.0 <1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz" + "string_decoder": { + "version": "0.10.31", + "from": "string_decoder@>=0.10.0 <0.11.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" } } }, - "entities": { - "version": "1.1.1", - "from": "entities@>=1.1.1 <2.0.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz" - }, - "escape-string-regexp": { - "version": "1.0.5", - "from": "escape-string-regexp@>=1.0.2 <2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" - }, - "espree": { - "version": "3.1.7", - "from": "espree@>=3.1.7 <3.2.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.1.7.tgz" - }, - "exit": { - "version": "0.1.2", - "from": "exit@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz" - }, - "expand-brackets": { - "version": "0.1.5", - "from": "expand-brackets@>=0.1.4 <0.2.0", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz" - }, - "expand-range": { - "version": "1.8.2", - "from": "expand-range@>=1.8.1 <2.0.0", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz" - }, - "expand-tilde": { - "version": "1.2.2", - "from": "expand-tilde@>=1.2.2 <2.0.0", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz" - }, - "extend": { - "version": "3.0.0", - "from": "extend@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz" - }, - "extglob": { - "version": "0.3.2", - "from": "extglob@>=0.3.1 <0.4.0", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz" - }, - "eyes": { - "version": "0.1.8", - "from": "eyes@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz" - }, - "fancy-log": { - "version": "1.3.0", - "from": "fancy-log@>=1.1.0 <2.0.0", - "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz" - }, - "filename-regex": { - "version": "2.0.0", - "from": "filename-regex@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.0.tgz" - }, - "fill-range": { - "version": "2.2.3", - "from": "fill-range@>=2.1.0 <3.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz" - }, - "find-index": { - "version": "0.1.1", - "from": "find-index@>=0.1.1 <0.2.0", - "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz" - }, - "findup-sync": { - "version": "0.4.3", - "from": "findup-sync@>=0.4.2 <0.5.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz" - }, - "fined": { - "version": "1.0.2", - "from": "fined@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/fined/-/fined-1.0.2.tgz" - }, - "first-chunk-stream": { - "version": "1.0.0", - "from": "first-chunk-stream@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz" - }, - "flagged-respawn": { - "version": "0.3.2", - "from": "flagged-respawn@>=0.3.2 <0.4.0", - "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.2.tgz" - }, - "for-in": { - "version": "1.0.2", - "from": "for-in@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz" - }, - "for-own": { - "version": "0.1.5", - "from": "for-own@>=0.1.4 <0.2.0", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz" - }, - "fs-exists-sync": { - "version": "0.1.0", - "from": "fs-exists-sync@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz" - }, - "fs.realpath": { - "version": "1.0.0", - "from": "fs.realpath@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" - }, - "gaze": { - "version": "0.5.2", - "from": "gaze@>=0.5.1 <0.6.0", - "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz" - }, - "glob": { - "version": "6.0.4", - "from": "glob@>=6.0.1 <7.0.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz" - }, - "glob-base": { - "version": "0.3.0", - "from": "glob-base@>=0.3.0 <0.4.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz" - }, - "glob-parent": { - "version": "2.0.0", - "from": "glob-parent@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz" - }, - "glob-stream": { - "version": "3.1.18", - "from": "glob-stream@>=3.1.5 <4.0.0", - "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", - "dependencies": { - "glob": { - "version": "4.5.3", - "from": "glob@>=4.3.1 <5.0.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz" - }, - "isarray": { - "version": "0.0.1", - "from": "isarray@0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "minimatch": { - "version": "2.0.10", - "from": "minimatch@>=2.0.1 <3.0.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz" - }, - "readable-stream": { - "version": "1.0.34", - "from": "readable-stream@>=1.0.33-1 <1.1.0-0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz" - }, - "through2": { - "version": "0.6.5", - "from": "through2@>=0.6.1 <0.7.0", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz" - } - } - }, - "glob-watcher": { - "version": "0.0.6", - "from": "glob-watcher@>=0.0.6 <0.0.7", - "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz" - }, - "glob2base": { - "version": "0.0.12", - "from": "glob2base@>=0.0.12 <0.0.13", - "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz" - }, - "global-modules": { - "version": "0.2.3", - "from": "global-modules@>=0.2.3 <0.3.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz" - }, - "global-prefix": { - "version": "0.1.5", - "from": "global-prefix@>=0.1.4 <0.2.0", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-0.1.5.tgz" - }, - "globule": { - "version": "0.1.0", - "from": "globule@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", - "dependencies": { - "glob": { - "version": "3.1.21", - "from": "glob@>=3.1.21 <3.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz" - }, - "graceful-fs": { - "version": "1.2.3", - "from": "graceful-fs@>=1.2.0 <1.3.0", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz" - }, - "inherits": { - "version": "1.0.2", - "from": "inherits@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz" - }, - "minimatch": { - "version": "0.2.14", - "from": "minimatch@>=0.2.11 <0.3.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz" - } - } - }, - "glogg": { - "version": "1.0.0", - "from": "glogg@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz" - }, - "graceful-fs": { - "version": "3.0.11", - "from": "graceful-fs@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz" - }, - "graceful-readlink": { - "version": "1.0.1", - "from": "graceful-readlink@>=1.0.0", - "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" - }, - "growl": { - "version": "1.9.2", - "from": "growl@1.9.2", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz" - }, - "gulp-util": { - "version": "3.0.8", - "from": "gulp-util@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "dependencies": { - "minimist": { - "version": "1.2.0", - "from": "minimist@>=1.1.0 <2.0.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz" - } - } - }, - "gulplog": { - "version": "1.0.0", - "from": "gulplog@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz" - }, - "has-ansi": { - "version": "2.0.0", - "from": "has-ansi@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz" - }, - "has-flag": { - "version": "1.0.0", - "from": "has-flag@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz" - }, - "has-gulplog": { - "version": "0.1.0", - "from": "has-gulplog@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz" - }, - "homedir-polyfill": { - "version": "1.0.1", - "from": "homedir-polyfill@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz" - }, - "htmlparser2": { - "version": "3.9.2", - "from": "htmlparser2@>=3.9.0 <4.0.0", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.9.2.tgz" - }, - "inflight": { - "version": "1.0.6", - "from": "inflight@>=1.0.4 <2.0.0", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz" - }, "inherits": { "version": "2.0.3", "from": "inherits@>=2.0.3 <3.0.0", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz" }, - "ini": { - "version": "1.3.4", - "from": "ini@>=1.3.4 <2.0.0", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz" - }, - "ink-docstrap": { - "version": "1.3.0", - "from": "ink-docstrap@>=1.1.4 <2.0.0", - "resolved": "https://registry.npmjs.org/ink-docstrap/-/ink-docstrap-1.3.0.tgz" - }, - "interpret": { - "version": "1.0.1", - "from": "interpret@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.1.tgz" - }, - "irregular-plurals": { - "version": "1.2.0", - "from": "irregular-plurals@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-1.2.0.tgz" - }, - "is-absolute": { - "version": "0.2.6", - "from": "is-absolute@>=0.2.3 <0.3.0", - "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz" - }, - "is-buffer": { - "version": "1.1.5", - "from": "is-buffer@>=1.0.2 <2.0.0", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz" - }, - "is-dotfile": { - "version": "1.0.2", - "from": "is-dotfile@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.2.tgz" - }, - "is-equal-shallow": { - "version": "0.1.3", - "from": "is-equal-shallow@>=0.1.3 <0.2.0", - "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz" - }, - "is-extendable": { - "version": "0.1.1", - "from": "is-extendable@>=0.1.1 <0.2.0", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz" - }, - "is-extglob": { - "version": "1.0.0", - "from": "is-extglob@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz" - }, - "is-glob": { - "version": "2.0.1", - "from": "is-glob@>=2.0.1 <3.0.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz" - }, - "is-number": { - "version": "2.1.0", - "from": "is-number@>=2.1.0 <3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz" - }, - "is-posix-bracket": { - "version": "0.1.1", - "from": "is-posix-bracket@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz" - }, - "is-primitive": { - "version": "2.0.0", - "from": "is-primitive@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz" - }, - "is-relative": { - "version": "0.2.1", - "from": "is-relative@>=0.2.1 <0.3.0", - "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz" - }, "is-stream": { "version": "1.1.0", "from": "is-stream@>=1.0.1 <2.0.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz" }, - "is-unc-path": { - "version": "0.1.2", - "from": "is-unc-path@>=0.1.1 <0.2.0", - "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz" - }, - "is-utf8": { - "version": "0.2.1", - "from": "is-utf8@>=0.2.0 <0.3.0", - "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz" - }, - "is-windows": { - "version": "0.2.0", - "from": "is-windows@>=0.2.0 <0.3.0", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz" - }, "isarray": { "version": "1.0.0", "from": "isarray@>=1.0.0 <1.1.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" }, - "isexe": { - "version": "1.1.2", - "from": "isexe@>=1.1.1 <2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-1.1.2.tgz" - }, - "isobject": { - "version": "2.1.0", - "from": "isobject@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz" - }, - "isstream": { - "version": "0.1.2", - "from": "isstream@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz" - }, - "js2xmlparser": { - "version": "1.0.0", - "from": "js2xmlparser@>=1.0.0 <1.1.0", - "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-1.0.0.tgz" - }, - "jsdoc": { - "version": "3.4.3", - "from": "jsdoc@>=3.4.3 <4.0.0", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.4.3.tgz", - "dependencies": { - "bluebird": { - "version": "3.4.7", - "from": "bluebird@>=3.4.6 <3.5.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz" - } - } - }, - "json3": { - "version": "3.3.2", - "from": "json3@3.3.2", - "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz" + "json-text-sequence": { + "version": "0.1.1", + "from": "json-text-sequence@>=0.1.1 <0.2.0", + "resolved": "https://registry.npmjs.org/json-text-sequence/-/json-text-sequence-0.1.1.tgz" }, "kerberos": { "version": "0.0.23", "from": "kerberos@>=0.0.23 <0.0.24", - "resolved": "https://registry.npmjs.org/kerberos/-/kerberos-0.0.23.tgz" - }, - "kind-of": { - "version": "3.1.0", - "from": "kind-of@>=3.0.2 <4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.1.0.tgz" - }, - "klaw": { - "version": "1.3.1", - "from": "klaw@>=1.3.0 <1.4.0", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "from": "graceful-fs@>=4.1.9 <5.0.0", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz" - } - } - }, - "liftoff": { - "version": "2.3.0", - "from": "liftoff@>=2.1.0 <3.0.0", - "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz" - }, - "lodash": { - "version": "1.0.2", - "from": "lodash@>=1.0.1 <1.1.0", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz" - }, - "lodash._baseassign": { - "version": "3.2.0", - "from": "lodash._baseassign@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz" - }, - "lodash._basecopy": { - "version": "3.0.1", - "from": "lodash._basecopy@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz" - }, - "lodash._basecreate": { - "version": "3.0.3", - "from": "lodash._basecreate@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz" - }, - "lodash._basetostring": { - "version": "3.0.1", - "from": "lodash._basetostring@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz" - }, - "lodash._basevalues": { - "version": "3.0.0", - "from": "lodash._basevalues@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz" - }, - "lodash._getnative": { - "version": "3.9.1", - "from": "lodash._getnative@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz" - }, - "lodash._isiterateecall": { - "version": "3.0.9", - "from": "lodash._isiterateecall@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz" - }, - "lodash._reescape": { - "version": "3.0.0", - "from": "lodash._reescape@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz" - }, - "lodash._reevaluate": { - "version": "3.0.0", - "from": "lodash._reevaluate@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz" - }, - "lodash._reinterpolate": { - "version": "3.0.0", - "from": "lodash._reinterpolate@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz" - }, - "lodash._root": { - "version": "3.0.1", - "from": "lodash._root@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz" - }, - "lodash.assign": { - "version": "4.2.0", - "from": "lodash.assign@>=4.2.0 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz" - }, - "lodash.assignwith": { - "version": "4.2.0", - "from": "lodash.assignwith@>=4.0.7 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz" - }, - "lodash.clonedeep": { - "version": "4.5.0", - "from": "lodash.clonedeep@>=4.3.2 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz" - }, - "lodash.create": { - "version": "3.1.1", - "from": "lodash.create@3.1.1", - "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz" - }, - "lodash.escape": { - "version": "3.2.0", - "from": "lodash.escape@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz" - }, - "lodash.isarguments": { - "version": "3.1.0", - "from": "lodash.isarguments@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz" - }, - "lodash.isarray": { - "version": "3.0.4", - "from": "lodash.isarray@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz" - }, - "lodash.isempty": { - "version": "4.4.0", - "from": "lodash.isempty@>=4.2.1 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz" - }, - "lodash.isobject": { - "version": "3.0.2", - "from": "lodash.isobject@>=3.0.2 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-3.0.2.tgz" - }, - "lodash.isplainobject": { - "version": "4.0.6", - "from": "lodash.isplainobject@>=4.0.4 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz" - }, - "lodash.isstring": { - "version": "4.0.1", - "from": "lodash.isstring@>=4.0.1 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz" - }, - "lodash.keys": { - "version": "3.1.2", - "from": "lodash.keys@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz" - }, - "lodash.mapvalues": { - "version": "4.6.0", - "from": "lodash.mapvalues@>=4.4.0 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz" - }, - "lodash.merge": { - "version": "4.6.0", - "from": "lodash.merge@>=4.6.0 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.0.tgz" - }, - "lodash.pick": { - "version": "4.4.0", - "from": "lodash.pick@>=4.2.1 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz" - }, - "lodash.restparam": { - "version": "3.6.1", - "from": "lodash.restparam@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz" - }, - "lodash.template": { - "version": "3.6.2", - "from": "lodash.template@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz" - }, - "lodash.templatesettings": { - "version": "3.1.1", - "from": "lodash.templatesettings@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz" - }, - "lru-cache": { - "version": "2.7.3", - "from": "lru-cache@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz" - }, - "map-cache": { - "version": "0.2.2", - "from": "map-cache@>=0.2.0 <0.3.0", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz" - }, - "map-stream": { - "version": "0.0.6", - "from": "map-stream@0.0.6", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.6.tgz" - }, - "marked": { - "version": "0.3.6", - "from": "marked@>=0.3.6 <0.4.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz" - }, - "micromatch": { - "version": "2.3.11", - "from": "micromatch@>=2.3.7 <3.0.0", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz" - }, - "minimatch": { - "version": "3.0.3", - "from": "minimatch@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz" - }, - "minimist": { - "version": "0.0.8", - "from": "minimist@0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" - }, - "mkdirp": { - "version": "0.5.1", - "from": "mkdirp@>=0.5.1 <0.6.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz" - }, - "mocha": { - "version": "3.2.0", - "from": "mocha@>=3.2.0 <4.0.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.2.0.tgz", - "dependencies": { - "debug": { - "version": "2.2.0", - "from": "debug@2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" - }, - "glob": { - "version": "7.0.5", - "from": "glob@7.0.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.5.tgz" - }, - "ms": { - "version": "0.7.1", - "from": "ms@0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" - }, - "supports-color": { - "version": "3.1.2", - "from": "supports-color@3.1.2", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz" - } - } - }, - "moment": { - "version": "2.17.1", - "from": "moment@>=2.10.6 <3.0.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.17.1.tgz" - }, - "ms": { - "version": "0.7.2", - "from": "ms@0.7.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" + "resolved": "https://registry.npmjs.org/kerberos/-/kerberos-0.0.23.tgz", + "optional": true }, "multipart-stream": { "version": "2.0.1", "from": "multipart-stream@>=2.0.1 <3.0.0", "resolved": "https://registry.npmjs.org/multipart-stream/-/multipart-stream-2.0.1.tgz" }, - "multipipe": { - "version": "0.1.2", - "from": "multipipe@>=0.1.2 <0.2.0", - "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz" - }, - "mute-stream": { - "version": "0.0.7", - "from": "mute-stream@>=0.0.4 <0.1.0", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz" - }, - "mv": { - "version": "2.1.1", - "from": "mv@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz" - }, "nan": { "version": "2.5.1", "from": "nan@>=2.5.1 <2.6.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.5.1.tgz" - }, - "natives": { - "version": "1.1.0", - "from": "natives@>=1.1.0 <2.0.0", - "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz" - }, - "ncp": { - "version": "2.0.0", - "from": "ncp@>=2.0.0 <2.1.0", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz" - }, - "normalize-path": { - "version": "2.0.1", - "from": "normalize-path@>=2.0.1 <3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz" - }, - "object-assign": { - "version": "3.0.0", - "from": "object-assign@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz" - }, - "object.omit": { - "version": "2.0.1", - "from": "object.omit@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz" - }, - "once": { - "version": "1.4.0", - "from": "once@>=1.3.0 <2.0.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz" - }, - "orchestrator": { - "version": "0.3.8", - "from": "orchestrator@>=0.3.0 <0.4.0", - "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz" - }, - "ordered-read-streams": { - "version": "0.1.0", - "from": "ordered-read-streams@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz" - }, - "os-homedir": { - "version": "1.0.2", - "from": "os-homedir@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz" - }, - "os-tmpdir": { - "version": "1.0.2", - "from": "os-tmpdir@>=1.0.1 <1.1.0", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz" - }, - "parse-filepath": { - "version": "1.0.1", - "from": "parse-filepath@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.1.tgz" - }, - "parse-glob": { - "version": "3.0.4", - "from": "parse-glob@>=3.0.4 <4.0.0", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz" - }, - "parse-passwd": { - "version": "1.0.0", - "from": "parse-passwd@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz" - }, - "path-is-absolute": { - "version": "1.0.1", - "from": "path-is-absolute@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - }, - "path-parse": { - "version": "1.0.5", - "from": "path-parse@>=1.0.5 <2.0.0", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz" - }, - "path-root": { - "version": "0.1.1", - "from": "path-root@>=0.1.1 <0.2.0", - "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz" - }, - "path-root-regex": { - "version": "0.1.2", - "from": "path-root-regex@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz" - }, - "plur": { - "version": "2.1.2", - "from": "plur@>=2.1.0 <3.0.0", - "resolved": "https://registry.npmjs.org/plur/-/plur-2.1.2.tgz" - }, - "preserve": { - "version": "0.2.0", - "from": "preserve@>=0.2.0 <0.3.0", - "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz" - }, - "pretty-hrtime": { - "version": "1.0.3", - "from": "pretty-hrtime@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz" + "resolved": "https://registry.npmjs.org/nan/-/nan-2.5.1.tgz", + "optional": true }, "process-nextick-args": { "version": "1.0.7", @@ -1080,343 +97,50 @@ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz" }, "qs": { - "version": "6.4.0", - "from": "qs@>=6.3.0 <7.0.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz" - }, - "randomatic": { - "version": "1.1.6", - "from": "randomatic@>=1.1.3 <2.0.0", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.6.tgz" - }, - "rcfinder": { - "version": "0.1.9", - "from": "rcfinder@>=0.1.6 <0.2.0", - "resolved": "https://registry.npmjs.org/rcfinder/-/rcfinder-0.1.9.tgz" - }, - "rcloader": { - "version": "0.2.2", - "from": "rcloader@>=0.2.2 <0.3.0", - "resolved": "https://registry.npmjs.org/rcloader/-/rcloader-0.2.2.tgz" + "version": "6.5.1", + "from": "qs@>=6.5.1 <7.0.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz" }, "readable-stream": { - "version": "2.2.3", + "version": "2.3.3", "from": "readable-stream@>=2.2.2 <3.0.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.3.tgz" - }, - "rechoir": { - "version": "0.6.2", - "from": "rechoir@>=0.6.2 <0.7.0", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz" - }, - "regex-cache": { - "version": "0.4.3", - "from": "regex-cache@>=0.4.2 <0.5.0", - "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz" - }, - "regexp-quote": { - "version": "0.0.0", - "from": "regexp-quote@0.0.0", - "resolved": "https://registry.npmjs.org/regexp-quote/-/regexp-quote-0.0.0.tgz" - }, - "repeat-element": { - "version": "1.1.2", - "from": "repeat-element@>=1.1.2 <2.0.0", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz" - }, - "repeat-string": { - "version": "1.6.1", - "from": "repeat-string@>=1.5.2 <2.0.0", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" - }, - "replace-ext": { - "version": "0.0.1", - "from": "replace-ext@0.0.1", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz" - }, - "req-cwd": { - "version": "1.0.1", - "from": "req-cwd@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/req-cwd/-/req-cwd-1.0.1.tgz" - }, - "req-from": { - "version": "1.0.1", - "from": "req-from@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/req-from/-/req-from-1.0.1.tgz" - }, - "requizzle": { - "version": "0.2.1", - "from": "requizzle@>=0.2.1 <0.3.0", - "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.1.tgz", - "dependencies": { - "underscore": { - "version": "1.6.0", - "from": "underscore@>=1.6.0 <1.7.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" - } - } - }, - "resolve": { - "version": "1.3.2", - "from": "resolve@>=1.1.7 <2.0.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.2.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz" }, - "resolve-dir": { - "version": "0.1.1", - "from": "resolve-dir@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz" - }, - "resolve-from": { - "version": "2.0.0", - "from": "resolve-from@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz" - }, - "rimraf": { - "version": "2.4.5", - "from": "rimraf@>=2.4.0 <2.5.0", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz" - }, - "safe-json-stringify": { - "version": "1.0.4", - "from": "safe-json-stringify@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/safe-json-stringify/-/safe-json-stringify-1.0.4.tgz" + "safe-buffer": { + "version": "5.1.1", + "from": "safe-buffer@>=5.1.1 <5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" }, "sandwich-stream": { "version": "1.0.0", "from": "sandwich-stream@>=1.0.0 <2.0.0", "resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-1.0.0.tgz" }, - "sanitize-html": { - "version": "1.14.1", - "from": "sanitize-html@>=1.13.0 <2.0.0", - "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-1.14.1.tgz" - }, - "semver": { - "version": "4.3.6", - "from": "semver@>=4.1.0 <5.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz" - }, - "sequencify": { - "version": "0.0.7", - "from": "sequencify@>=0.0.7 <0.1.0", - "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz" - }, - "shelljs": { - "version": "0.3.0", - "from": "shelljs@>=0.3.0 <0.4.0", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz" - }, - "should-equal": { - "version": "1.0.1", - "from": "should-equal@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-1.0.1.tgz" - }, - "should-format": { - "version": "3.0.3", - "from": "should-format@>=3.0.2 <4.0.0", - "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz" - }, - "should-type": { - "version": "1.4.0", - "from": "should-type@>=1.4.0 <2.0.0", - "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz" - }, - "should-type-adaptors": { - "version": "1.0.1", - "from": "should-type-adaptors@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.0.1.tgz" - }, - "should-util": { - "version": "1.0.0", - "from": "should-util@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz" - }, - "sigmund": { - "version": "1.0.1", - "from": "sigmund@>=1.0.0 <1.1.0", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz" - }, - "sparkles": { - "version": "1.0.0", - "from": "sparkles@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz" - }, - "stack-trace": { - "version": "0.0.9", - "from": "stack-trace@>=0.0.0 <0.1.0", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.9.tgz" - }, - "stream-consume": { - "version": "0.1.0", - "from": "stream-consume@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz" - }, "streamsearch": { "version": "0.1.2", "from": "streamsearch@0.1.2", "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz" }, "string_decoder": { - "version": "0.10.31", - "from": "string_decoder@>=0.10.0 <0.11.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - }, - "strip-ansi": { - "version": "3.0.1", - "from": "strip-ansi@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz" - }, - "strip-bom": { - "version": "1.0.0", - "from": "strip-bom@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz" - }, - "strip-json-comments": { - "version": "2.0.1", - "from": "strip-json-comments@>=2.0.1 <2.1.0", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz" - }, - "supports-color": { - "version": "2.0.0", - "from": "supports-color@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - }, - "taffydb": { - "version": "2.6.2", - "from": "taffydb@2.6.2", - "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz" - }, - "temp": { - "version": "0.8.3", - "from": "temp@>=0.8.3 <0.9.0", - "resolved": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", - "dependencies": { - "rimraf": { - "version": "2.2.8", - "from": "rimraf@>=2.2.6 <2.3.0", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz" - } - } - }, - "through": { - "version": "2.3.8", - "from": "through@>=2.3.4 <3.0.0", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" + "version": "1.0.3", + "from": "string_decoder@>=1.0.3 <1.1.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz" }, "through2": { "version": "2.0.3", "from": "through2@>=2.0.3 <3.0.0", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz" }, - "tildify": { - "version": "1.2.0", - "from": "tildify@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz" - }, - "time-stamp": { - "version": "1.0.1", - "from": "time-stamp@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.0.1.tgz" - }, - "tmp": { - "version": "0.0.28", - "from": "tmp@0.0.28", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.28.tgz" - }, "typedarray": { "version": "0.0.6", "from": "typedarray@>=0.0.6 <0.0.7", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" }, - "unc-path-regex": { - "version": "0.1.2", - "from": "unc-path-regex@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz" - }, - "underscore": { - "version": "1.8.3", - "from": "underscore@>=1.8.3 <1.9.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz" - }, - "underscore-contrib": { - "version": "0.3.0", - "from": "underscore-contrib@>=0.3.0 <0.4.0", - "resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz", - "dependencies": { - "underscore": { - "version": "1.6.0", - "from": "underscore@1.6.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" - } - } - }, - "unique-stream": { - "version": "1.0.0", - "from": "unique-stream@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz" - }, - "user-home": { - "version": "1.1.1", - "from": "user-home@>=1.1.1 <2.0.0", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz" - }, "util-deprecate": { "version": "1.0.2", "from": "util-deprecate@>=1.0.1 <1.1.0", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" }, - "v8flags": { - "version": "2.0.11", - "from": "v8flags@>=2.0.2 <3.0.0", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.0.11.tgz" - }, - "vinyl": { - "version": "0.5.3", - "from": "vinyl@>=0.5.0 <0.6.0", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz" - }, - "vinyl-fs": { - "version": "0.3.14", - "from": "vinyl-fs@>=0.3.0 <0.4.0", - "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", - "dependencies": { - "clone": { - "version": "0.2.0", - "from": "clone@>=0.2.0 <0.3.0", - "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz" - }, - "isarray": { - "version": "0.0.1", - "from": "isarray@0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "readable-stream": { - "version": "1.0.34", - "from": "readable-stream@>=1.0.33-1 <1.1.0-0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz" - }, - "through2": { - "version": "0.6.5", - "from": "through2@>=0.6.1 <0.7.0", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz" - }, - "vinyl": { - "version": "0.4.6", - "from": "vinyl@>=0.4.0 <0.5.0", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz" - } - } - }, - "which": { - "version": "1.2.12", - "from": "which@>=1.2.12 <2.0.0", - "resolved": "https://registry.npmjs.org/which/-/which-1.2.12.tgz" - }, - "wrappy": { - "version": "1.0.2", - "from": "wrappy@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - }, "www-authenticate": { "version": "0.6.2", "from": "www-authenticate@>=0.6.2 <0.7.0", diff --git a/package.json b/package.json index b5c5cfc8..31fd6be6 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "name": "marklogic", "description": "The official MarkLogic Node.js client API.", "homepage": "http://github.com/marklogic/node-client-api", - "version": "2.0.3", + "version": "2.1.1", "license": "Apache-2.0", "main": "./lib/marklogic.js", "keywords": [ @@ -20,12 +20,14 @@ "xpath" ], "dependencies": { - "bluebird": "^3.4.7", + "big-integer": "^1.6.25", + "bluebird": "^3.5.1", "concat-stream": "^1.6.0", "deepcopy": "^0.6.3", "dicer": "^0.2.5", + "json-text-sequence": "^0.1.1", "multipart-stream": "^2.0.1", - "qs": "^6.3.0", + "qs": "^6.5.1", "through2": "^2.0.3", "www-authenticate": "^0.6.2", "yakaa": "^1.0.1" @@ -35,7 +37,7 @@ "url": "http://github.com/marklogic/node-client-api.git" }, "engines": { - "node": ">=6.3.1" + "node": ">=6.9.0" }, "devDependencies": { "bunyan": "^1.3.3", @@ -44,11 +46,13 @@ "gulp-jsdoc3": "^1.0.1", "gulp-jshint": "^2.0.4", "gulp-mocha": "^4.1.0", - "jsdoc": "^3.4.3", + "intercept-stdout": "^0.1.2", + "jsdoc": "^3.5.5", "jshint": "^2.6.0", - "mocha": "^3.2.0", + "mocha": "^4.0.1", + "chai": "^4.1.2", "read": "^1.0.5", - "should": "^11.2.1", + "should": "^13.1.3", "winston": "^2.3.1" }, "optionalDependencies": { diff --git a/test-basic/client.js b/test-basic/client.js index 6f95d16e..4f1acd8c 100644 --- a/test-basic/client.js +++ b/test-basic/client.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,11 @@ var q = marklogic.queryBuilder; var YAgent = require('yakaa'); -// TODO: setup should create user with eval-in role +// 'rest-evaluator' user can evaluate against an alternate db: +// http://docs.marklogic.com/guide/rest-dev/intro#id_72318 var connection = { - user: 'admin', - password: 'admin' + user: testconfig.restEvaluatorConnection.user, + password: testconfig.restEvaluatorConnection.password }; Object.keys(testconfig.restWriterConnection).forEach(function(key){ if (connection[key] === undefined) { @@ -101,4 +102,9 @@ describe('database clients', function() { agentDb.connectionParams.agent.options.keepAliveTimeoutMsecs.should.equal(1000); done(); }); + it('should create a timestamp', function(done) { + let timestamp = db.createTimestamp('123'); + timestamp.value.should.equal('123'); + done(); + }); }); diff --git a/test-basic/data/directoryConstraint.xqy b/test-basic/data/directoryConstraint.xqy index 2e6d1774..9582f022 100644 --- a/test-basic/data/directoryConstraint.xqy +++ b/test-basic/data/directoryConstraint.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-basic/data/echoModule.js b/test-basic/data/echoModule.js index aeb4724c..9c9cebc0 100644 --- a/test-basic/data/echoModule.js +++ b/test-basic/data/echoModule.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ case 8: 4.4; break; case 9: - new Date('2010-10-08T10:17:15.125Z'); + new Date('2010-10-08T10:17:15.125'); break; case 10: xdmp.arrayValues([1, 'two', {i:3}, [4,'four'], xdmp.unquote('5')]); diff --git a/test-basic/data/echoModule.xqy b/test-basic/data/echoModule.xqy index da623883..45146999 100644 --- a/test-basic/data/echoModule.xqy +++ b/test-basic/data/echoModule.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-basic/data/extractFirst.xqy b/test-basic/data/extractFirst.xqy index 4aee4ff4..071770f1 100644 --- a/test-basic/data/extractFirst.xqy +++ b/test-basic/data/extractFirst.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-basic/data/flagTransform.xqy b/test-basic/data/flagTransform.xqy index c35b7cc2..1a2ddfd9 100644 --- a/test-basic/data/flagTransform.xqy +++ b/test-basic/data/flagTransform.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-basic/data/literals.json b/test-basic/data/literals.json new file mode 100644 index 00000000..48ec664a --- /dev/null +++ b/test-basic/data/literals.json @@ -0,0 +1,52 @@ +{ + "$optic": { + "ns": "op", + "fn": "operators", + "args": [ + { + "ns": "op", + "fn": "from-literals", + "args": [ + [ + { + "id": 1, + "name": "Master 1", + "date": "2015-12-01" + }, + { + "id": 2, + "name": "Master 2", + "date": "2015-12-02" + }, + { + "id": 3, + "name": "Master 3", + "date": "2015-12-03" + } + ], + null + ] + }, + { + "ns": "op", + "fn": "where", + "args": [ + { + "ns": "op", + "fn": "gt", + "args": [ + { + "ns": "op", + "fn": "col", + "args": [ + "id" + ] + }, + 1 + ] + } + ] + } + ] + } +} diff --git a/test-basic/data/literalsAttachments.json b/test-basic/data/literalsAttachments.json new file mode 100644 index 00000000..a0d6f8a3 --- /dev/null +++ b/test-basic/data/literalsAttachments.json @@ -0,0 +1,178 @@ +{ + "$optic": { + "args": [ + { + "args": [ + [ + { + "bool": true, + "gp": 1, + "nm": "alpha", + "num": 10, + "row": 1, + "str": "a" + }, + { + "bool": false, + "gp": 1, + "nm": "beta", + "num": 20, + "row": 2, + "str": "b" + }, + { + "bool": true, + "gp": 2, + "nm": "gamma", + "num": 30, + "row": 3, + "str": "c" + }, + { + "bool": false, + "gp": 2, + "nm": "delta", + "num": 40, + "row": 4, + "str": "d" + } + ], + null + ], + "fn": "from-literals", + "ns": "op" + }, + { + "args": [ + { + "args": [ + { + "args": [ + "gp" + ], + "fn": "col", + "ns": "op" + }, + 1 + ], + "fn": "eq", + "ns": "op" + } + ], + "fn": "where", + "ns": "op" + }, + { + "args": [ + [ + { + "args": [ + "row" + ], + "fn": "col", + "ns": "op" + }, + { + "args": [ + "node", + { + "args": [ + { + "args": [ + { + "args": [ + "nm" + ], + "fn": "col", + "ns": "op" + }, + null, + [ + { + "args": [ + { + "args": [ + "str" + ], + "fn": "col", + "ns": "op" + }, + null, + [ + { + "args": [ + { + "args": [ + "bool" + ], + "fn": "col", + "ns": "op" + } + ], + "fn": "xml-text", + "ns": "op" + } + ] + ], + "fn": "xml-element", + "ns": "op" + } + ] + ], + "fn": "xml-element", + "ns": "op" + } + ], + "fn": "xml-document", + "ns": "op" + } + ], + "fn": "as", + "ns": "op" + }, + { + "args": [ + "kind", + { + "args": [ + { + "args": [ + "node" + ], + "fn": "col", + "ns": "op" + } + ], + "fn": "node-kind", + "ns": "xdmp" + } + ], + "fn": "as", + "ns": "op" + } + ], + null + ], + "fn": "select", + "ns": "op" + }, + { + "args": [ + [ + { + "args": [ + "row" + ], + "fn": "col", + "ns": "op" + } + ] + ], + "fn": "order-by", + "ns": "op" + } + ], + "fn": "operators", + "ns": "op" + } +} diff --git a/test-basic/data/literalsAttachments.sjs b/test-basic/data/literalsAttachments.sjs new file mode 100644 index 00000000..51b0a5cd --- /dev/null +++ b/test-basic/data/literalsAttachments.sjs @@ -0,0 +1,19 @@ +const p = require('/MarkLogic/optic'); + +p.fromLiterals([ + {row:1, gp:1, nm:'alpha', str:'a', num:10, bool:true}, + {row:2, gp:1, nm:'beta', str:'b', num:20, bool:false}, + {row:3, gp:2, nm:'gamma', str:'c', num:30, bool:true}, + {row:4, gp:2, nm:'delta', str:'d', num:40, bool:false} + ]) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.xmlDocument( + p.xmlElement(p.col('nm'), null, + p.xmlElement(p.col('str'), null, p.xmlText(p.col('bool'))) + ) + )), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') +.export(); diff --git a/test-basic/data/literalsBinaryAttachments.json b/test-basic/data/literalsBinaryAttachments.json new file mode 100644 index 00000000..5ddb6b78 --- /dev/null +++ b/test-basic/data/literalsBinaryAttachments.json @@ -0,0 +1,62 @@ +{ + "$optic": { + "args": [ + { + "args": [ + [ + { + "id": 1, + "uri": "/test/binary/test1.png", + "val": 2 + }, + { + "id": 2, + "uri": "/test/write/stream1.png", + "val": 4 + } + ], + null + ], + "fn": "from-literals", + "ns": "op" + }, + { + "args": [ + [ + { + "args": [ + "id" + ], + "fn": "col", + "ns": "op" + } + ] + ], + "fn": "order-by", + "ns": "op" + }, + { + "args": [ + { + "args": [ + "doc" + ], + "fn": "col", + "ns": "op" + }, + { + "args": [ + "uri" + ], + "fn": "col", + "ns": "op" + } + ], + "fn": "join-doc", + "ns": "op" + } + ], + "fn": "operators", + "ns": "op" + } +} diff --git a/test-basic/data/literalsBinaryAttachments.sjs b/test-basic/data/literalsBinaryAttachments.sjs new file mode 100644 index 00000000..038e725c --- /dev/null +++ b/test-basic/data/literalsBinaryAttachments.sjs @@ -0,0 +1,9 @@ +const op = require('/MarkLogic/optic'); + +op.fromLiterals([ + {id:1, val: 2, uri:'/test/binary/test1.png'}, + {id:2, val: 4, uri:'/test/write/stream1.png'} + ]) + .orderBy('id') + .joinDoc(op.col('doc'), op.col('uri')) + .export(); diff --git a/test-basic/data/literalsBindings.json b/test-basic/data/literalsBindings.json new file mode 100644 index 00000000..8d125818 --- /dev/null +++ b/test-basic/data/literalsBindings.json @@ -0,0 +1,58 @@ +{ + "$optic": { + "ns": "op", + "fn": "operators", + "args": [ + { + "ns": "op", + "fn": "from-literals", + "args": [ + [ + { + "id": 1, + "name": "Master 1", + "date": "2015-12-01" + }, + { + "id": 2, + "name": "Master 2", + "date": "2015-12-02" + }, + { + "id": 3, + "name": "Master 3", + "date": "2015-12-03" + } + ], + null + ] + }, + { + "ns": "op", + "fn": "where", + "args": [ + { + "ns": "op", + "fn": "gt", + "args": [ + { + "ns": "op", + "fn": "col", + "args": [ + "id" + ] + }, + { + "ns": "op", + "fn": "param", + "args": [ + "limit" + ] + } + ] + } + ] + } + ] + } +} diff --git a/test-basic/data/objectify.xqy b/test-basic/data/objectify.xqy index d5fff354..de1b4aff 100644 --- a/test-basic/data/objectify.xqy +++ b/test-basic/data/objectify.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-basic/data/timeService.xqy b/test-basic/data/timeService.xqy index 10a2dfb8..266d659c 100644 --- a/test-basic/data/timeService.xqy +++ b/test-basic/data/timeService.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-basic/data/timestampTransform.js b/test-basic/data/timestampTransform.js index 277eb8eb..eb9e143e 100644 --- a/test-basic/data/timestampTransform.js +++ b/test-basic/data/timestampTransform.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/data/versionService.js b/test-basic/data/versionService.js index a0b09d29..93f83078 100644 --- a/test-basic/data/versionService.js +++ b/test-basic/data/versionService.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/data/wrapperService.xqy b/test-basic/data/wrapperService.xqy index ddb6c260..99f1265b 100644 --- a/test-basic/data/wrapperService.xqy +++ b/test-basic/data/wrapperService.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-basic/documents-core.js b/test-basic/documents-core.js index fee3c0e2..5f247ca3 100644 --- a/test-basic/documents-core.js +++ b/test-basic/documents-core.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -313,7 +313,7 @@ describe('document content', function(){ }) .catch(done); }); - it('should read as a stream', function(done){ + it('should read as a chunked stream', function(done){ db.documents.read(uri).stream('chunked').on('error', done). pipe( concatStream({encoding: 'buffer'}, function(value) { @@ -373,6 +373,57 @@ describe('document content', function(){ }) .catch(done); }); + it('should read as an object stream with content and metadata', function(done){ + var count = 0; + db.documents.read({ + uris: ['/test/write/arrayString1.json', '/test/write/arrayObject2.json'], + categories: ['content', 'quality'] + }).stream('object').on('error', done). + on('data', function (data) { + count++; + valcheck.isObject(data).should.equal(true); + data.should.have.property('content'); + data.should.have.property('quality'); + }). + on('end', function () { + count.should.equal(2); + done(); + }); + }); + it('should read as an object stream with content only', function(done){ + var count = 0; + db.documents.read({ + uris: ['/test/write/arrayString1.json', '/test/write/arrayObject2.json'], + categories: ['content'] + }).stream('object').on('error', done). + on('data', function (data) { + count++; + valcheck.isObject(data).should.equal(true); + data.should.have.property('content'); + data.should.not.have.property('quality'); + }). + on('end', function () { + count.should.equal(2); + done(); + }); + }); + it('should read as an object stream with metadata only', function(done){ + var count = 0; + db.documents.read({ + uris: ['/test/write/arrayString1.json', '/test/write/arrayObject2.json'], + categories: ['quality'] + }).stream('object').on('error', done). + on('data', function (data) { + count++; + valcheck.isObject(data).should.equal(true); + data.should.not.have.property('content'); + data.should.have.property('quality'); + }). + on('end', function () { + count.should.equal(2); + done(); + }); + }); }); describe('a JSON document in two chunks', function(){ before(function(done){ diff --git a/test-basic/documents-negative.js b/test-basic/documents-negative.js index c3652349..5b3cb3f3 100644 --- a/test-basic/documents-negative.js +++ b/test-basic/documents-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/documents-patch.js b/test-basic/documents-patch.js index 20520026..ba6de1a5 100644 --- a/test-basic/documents-patch.js +++ b/test-basic/documents-patch.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/documents-query.js b/test-basic/documents-query.js index 5dc1ffe1..0e7757a1 100644 --- a/test-basic/documents-query.js +++ b/test-basic/documents-query.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -142,6 +142,36 @@ describe('document query', function(){ }) .catch(done); }); + it('should match a directory query using combined query', function(done){ + var combined = { + options: { + 'search-option': [ + 'unfiltered' + ] + }, + search: { + query: { + queries: [{ + "directory-query": { + uri: ["/test/query/matchDir/"] + } + }] + }, + qtext: '' + } + }; + db.documents.query(combined) + .result(function(response) { + response.length.should.equal(1); + var document = response[0]; + document.should.be.ok; + document.uri.should.equal('/test/query/matchDir/doc1.json'); + document.should.have.property('content'); + document.content.id.should.equal('matchDoc1'); + done(); + }) + .catch(done); + }); it('should match a collection query', function(done){ db.documents.query( q.where( @@ -530,6 +560,24 @@ describe('document query', function(){ }) .catch(done); }); + it('should get the query as an object stream with initial summary', function(done){ + this.timeout(3000); + var objects = []; + db.documents.query( + q.where( + q.value('valueKey', 'match value') + ).withOptions({metrics: true}) + ).stream('object') + .on('error', done) + .on('data', function (object) { + objects.push(object); + }). + on('end', function () { + objects[0].should.have.property('snippet-format'); + objects[1].should.have.property('uri'); + done(); + }); + }); }); describe('for a where clause with a parsed query', function() { it('should match a value query', function(done){ diff --git a/test-basic/documents-quick.js b/test-basic/documents-quick.js index 4bbec0d3..e2dd7387 100644 --- a/test-basic/documents-quick.js +++ b/test-basic/documents-quick.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/documents-temporal-document.js b/test-basic/documents-temporal-document.js index d81a2f9e..f73f46b8 100644 --- a/test-basic/documents-temporal-document.js +++ b/test-basic/documents-temporal-document.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/documents-temporal-patch.js b/test-basic/documents-temporal-patch.js index fd999c20..8e6f6cfe 100644 --- a/test-basic/documents-temporal-patch.js +++ b/test-basic/documents-temporal-patch.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/documents-temporal-protect.js b/test-basic/documents-temporal-protect.js index 3ed85cf8..55b00b28 100644 --- a/test-basic/documents-temporal-protect.js +++ b/test-basic/documents-temporal-protect.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ describe('temporal protect', function() { validStartTime: '1111-11-11T11:11:11Z', validEndTime: '9999-12-31T23:59:59Z' }; - before(function(done){ + it('should protect a temporal document with duration and default level', function(done) { db.documents.write({ documents: { uri: 'tempDoc1.json', @@ -37,63 +37,12 @@ describe('temporal protect', function() { }, temporalCollection: 'temporalCollection' }).result(function(response){ - return db.documents.write({ - documents:{ - uri: 'tempDoc2.json', - content: content - }, - temporalCollection: 'temporalCollection' - }).result() - }).then(function(response){ - return db.documents.write({ - documents:{ - uri: 'tempDoc3.json', - content: content - }, - temporalCollection: 'temporalCollection' - }).result() - }).then(function(response){ - return db.documents.write({ - documents:{ - uri: 'tempDoc4.json', - content: content - }, - temporalCollection: 'temporalCollection' - }).result() - }).then(function(response){ - done(); - }).catch(done); - }); - after(function(done){ - db.documents.wipe({ + return db.documents.protect({ uri: 'tempDoc1.json', - temporalCollection: 'temporalCollection' - }).result(function(response){ - return db.documents.wipe({ - uri: 'tempDoc2.json', - temporalCollection: 'temporalCollection' - }).result(); - }).then(function(response){ - return db.documents.wipe({ - uri: 'tempDoc3.json', - temporalCollection: 'temporalCollection' - }).result(); - }).then(function(response){ - return db.documents.wipe({ - uri: 'tempDoc4.json', - temporalCollection: 'temporalCollection' + temporalCollection: 'temporalCollection', + duration: 'PT0S' }).result(); - }).then(function(response){ - fs.unlinkSync(archiveFile); - done(); - }).catch(done); - }); - it('should protect a temporal document with duration and default level', function(done) { - db.documents.protect({ - uri: 'tempDoc1.json', - temporalCollection: 'temporalCollection', - duration: 'PT0S' - }).result(function(response) { + }).then(function(response) { response.uri.should.equal('tempDoc1.json'); response.temporalCollection.should.equal('temporalCollection'); response.level.should.equal(DEFAULT_LEVEL); @@ -109,16 +58,29 @@ describe('temporal protect', function() { m.metadataValues.should.have.property('temporalProtectLevel'); m.metadataValues.temporalProtectLevel.should.equal(DEFAULT_LEVEL); m.metadataValues.should.have.property('temporalProtectExTime'); + return db.documents.wipe({ + uri: 'tempDoc1.json', + temporalCollection: 'temporalCollection' + }).result(); + }).then(function(response){ done(); }).catch(done); }); it('should protect a temporal document with an expireTime and level', function(done) { - db.documents.protect({ - uri: 'tempDoc2.json', - temporalCollection: 'temporalCollection', - expireTime: '2016-06-03T19:56:17.681154-07:00', - level: 'noWipe' - }).result(function(response) { + db.documents.write({ + documents: { + uri: 'tempDoc2.json', + content: content + }, + temporalCollection: 'temporalCollection' + }).result(function(response){ + return db.documents.protect({ + uri: 'tempDoc2.json', + temporalCollection: 'temporalCollection', + expireTime: '2016-06-03T19:56:17.681154-07:00', + level: 'noWipe' + }).result(); + }).then(function(response) { response.uri.should.equal('tempDoc2.json'); response.temporalCollection.should.equal('temporalCollection'); response.level.should.equal('noWipe'); @@ -137,17 +99,30 @@ describe('temporal protect', function() { m.metadataValues.temporalProtectExTime.should.equal( '2016-06-03T19:56:17.681154-07:00' ); + return db.documents.wipe({ + uri: 'tempDoc2.json', + temporalCollection: 'temporalCollection' + }).result(); + }).then(function(response){ done(); - }) - .catch(done); + }).catch(done); }); + // Jenkins skips archivePath test: https://bugtrack.marklogic.com/45783 it('should protect a temporal document with a duration and archivePath', function(done) { - db.documents.protect({ - uri: 'tempDoc3.json', - temporalCollection: 'temporalCollection', - duration: 'PT0S', - archivePath: archiveFile - }).result(function(response) { + db.documents.write({ + documents: { + uri: 'tempDoc3.json', + content: content + }, + temporalCollection: 'temporalCollection' + }).result(function(response){ + return db.documents.protect({ + uri: 'tempDoc3.json', + temporalCollection: 'temporalCollection', + duration: 'PT0S', + archivePath: archiveFile + }).result(); + }).then(function(response){ response.uri.should.equal('tempDoc3.json'); response.temporalCollection.should.equal('temporalCollection'); response.level.should.equal(DEFAULT_LEVEL); @@ -165,16 +140,30 @@ describe('temporal protect', function() { m.metadataValues.should.have.property('temporalArchiveStatus'); m.metadataValues.temporalArchiveStatus.should.equal('succeeded'); m.metadataValues.should.have.property('temporalArchiveTime'); + return db.documents.wipe({ + uri: 'tempDoc3.json', + temporalCollection: 'temporalCollection' + }).result(); + }).then(function(response){ + fs.unlinkSync(archiveFile); done(); }).catch(done); }); it('should protect a temporal document twice', function(done) { - db.documents.protect({ - uri: 'tempDoc4.json', - temporalCollection: 'temporalCollection', - expireTime: '2016-01-01T12:34:56.7890-07:00', - level: 'noUpdate' - }).result(function(response) { + db.documents.write({ + documents: { + uri: 'tempDoc4.json', + content: content + }, + temporalCollection: 'temporalCollection' + }).result(function(response){ + return db.documents.protect({ + uri: 'tempDoc4.json', + temporalCollection: 'temporalCollection', + expireTime: '2016-01-01T12:34:56.7890-07:00', + level: 'noUpdate' + }).result(); + }).then(function(response){ response.uri.should.equal('tempDoc4.json'); response.temporalCollection.should.equal('temporalCollection'); response.level.should.equal('noUpdate'); @@ -182,13 +171,17 @@ describe('temporal protect', function() { uri: 'tempDoc4.json', temporalCollection: 'temporalCollection', expireTime: '2016-01-01T12:34:56.7890-07:00', - level: 'noUpdate', - archivePath: archiveFile + level: 'noUpdate' }).result(); }).then(function(response){ response.uri.should.equal('tempDoc4.json'); response.temporalCollection.should.equal('temporalCollection'); response.level.should.equal('noUpdate'); + return db.documents.wipe({ + uri: 'tempDoc4.json', + temporalCollection: 'temporalCollection' + }).result(); + }).then(function(response){ done(); }).catch(done); }); diff --git a/test-basic/documents-temporal-wipe.js b/test-basic/documents-temporal-wipe.js index e220e2aa..3974fc33 100644 --- a/test-basic/documents-temporal-wipe.js +++ b/test-basic/documents-temporal-wipe.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/documents-temporal.js b/test-basic/documents-temporal.js index d472e0dd..95739af5 100644 --- a/test-basic/documents-temporal.js +++ b/test-basic/documents-temporal.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ var marklogic = require('../'); var q = marklogic.queryBuilder; var db = marklogic.createDatabaseClient(testconfig.restTemporalConnection); +var restAdminDB = marklogic.createDatabaseClient(testconfig.restAdminConnection); /* ASSUMPTION: this test will not be run more frequently * than once every 10 seconds. To run more frequently, @@ -83,7 +84,7 @@ describe('temporal document', function() { .then(function(documents){ documents.should.have.property('length'); documents.length.should.equal(2); - var latestNow = Date.now(); + var latestNow = Date.now(); for (var i=0; i < 2; i++) { var document = documents[i]; document.should.have.property('content'); @@ -94,6 +95,16 @@ describe('temporal document', function() { done();}) .catch(done); }); + it('should advance the LSQT', function(done) { + restAdminDB.documents.advanceLsqt('temporalCollection', 60) + .result(function(response) { + response.should.have.property('lsqt'); + var parsed = Date.parse(response['lsqt']); + valcheck.isNumber(parsed).should.equal(true); + done(); + }) + .catch(done); + }); /* TODO: requires a REST interface to temporal:advance-lsqt() to create the collection LSQT document it('should query temporal documents relative to lsqt', function(done) { db.documents.query(q.where( @@ -160,7 +171,7 @@ describe('temporal document', function() { .then(function(documents) { documents.should.have.property('length'); documents.length.should.equal(1); - var latestNow = Date.now(); + var latestNow = Date.now(); var document = documents[0]; document.should.have.property('content'); document.content.should.have.property('systemEndTime'); diff --git a/test-basic/documents-transform.js b/test-basic/documents-transform.js index 97cbd064..e853fab0 100644 --- a/test-basic/documents-transform.js +++ b/test-basic/documents-transform.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/documents-version.js b/test-basic/documents-version.js index 8d46468e..02a8d5ab 100644 --- a/test-basic/documents-version.js +++ b/test-basic/documents-version.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/errors.js b/test-basic/errors.js index ee1b6fa9..daa3bdde 100644 --- a/test-basic/errors.js +++ b/test-basic/errors.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/extlibs.js b/test-basic/extlibs.js index 3d794f7b..bc87befd 100644 --- a/test-basic/extlibs.js +++ b/test-basic/extlibs.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/graphs.js b/test-basic/graphs.js index 093287e0..33e669dc 100644 --- a/test-basic/graphs.js +++ b/test-basic/graphs.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ var marklogic = require('../'); var q = marklogic.queryBuilder; var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); +var restAdminDB = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('graph operations', function(){ var graphUri = 'marklogic.com/people'; @@ -263,4 +264,91 @@ describe('graph operations', function(){ }) .catch(done); }); + + describe('write document with embedded triple and docQuery', function () { + before(function (done) { + this.timeout(10000); + var writeStream = db.documents.createWriteStream({ + uri: '/test/docquery/query.xml', + contentType: 'application/xml' + }); + writeStream.result(function (response) { + done(); + }, done); + writeStream.write("" + + "testValue" + + "" + + "" + + "http://example.org/s2" + + "http://example.org/p2" + + "" + + "test2" + + "" + + "" + + "", 'utf8'); + writeStream.end(); + }); + it('should run SPARQL query with docQuery', function (done) { + this.timeout(10000); + var myQuery = "SELECT ?o WHERE {?s ?p ?o .}"; + var docQuery = q.where(q.term('testValue')); + db.graphs.sparql({ + contentType: 'application/json', + query: myQuery, + docQuery: docQuery + }). + result(function (response) { + response.results.bindings[0].should.have.property('o'); + response.results.bindings[0].o.value.should.equal('test2'); + done(); + }, done); + }); + + it('should run SPARQL query with docQuery in combined query form', function (done) { + this.timeout(10000); + var myQuery = "SELECT ?o WHERE {?s ?p ?o .}"; + var combinedQuery = { + search: { + options: { + 'search-option': [ + 'unfiltered' + ] + }, + query: { + queries: [{ + 'term-query': { + text: ['testValue'] + } + }] + } + }, + qtext: '' + }; + db.graphs.sparql({ + contentType: 'application/json', + query: myQuery, + docQuery: combinedQuery + }). + result(function (response) { + response.results.bindings[0].should.have.property('o'); + response.results.bindings[0].o.value.should.equal('test2'); + done(); + }, done); + }); + it('should delete test document', function(done){ + restAdminDB.documents.remove('/test/docquery/query.xml'). + result(function(response) { + done(); + }, done); + }); + it('should drop all graphs', function(done){ + var myData = "DROP ALL ;" + db.graphs.sparqlUpdate({ + data: myData + }). + result(function(response){ + done(); + }, done); + }); + }); }); diff --git a/test-basic/logging.js b/test-basic/logging.js new file mode 100644 index 00000000..bc246cd4 --- /dev/null +++ b/test-basic/logging.js @@ -0,0 +1,88 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var should = require('should'), + testconfig = require('../etc/test-config.js'), + marklogic = require('../'), + bunyan = require('bunyan'), + winston = require('winston'), + intercept = require("intercept-stdout"); + +var dbDefault = marklogic.createDatabaseClient(testconfig.restWriterConnection); +var dbBunyan = marklogic.createDatabaseClient(testconfig.restWriterConnection); +var dbWinston = marklogic.createDatabaseClient(testconfig.restWriterConnection); + +describe('logging', function(){ + + describe('with default', function(){ + dbDefault.setLogger('debug'); + it('should write default entries', function(done){ + var captured = []; + var unhook = intercept(function(txt) { + captured.push(txt); + }); + dbDefault.config.serverprops.read().result(function(response) { + unhook(); + captured[0].should.startWith('Debug:'); + done(); + }, done); + }); + }); + + describe('with Bunyan', function(){ + var bunyanLogger = bunyan.createLogger({name: 'bunyanlog', level: 'debug'}); + dbBunyan.setLogger(bunyanLogger); + it('should write Bunyan JSON entries', function(done){ + var captured = []; + var unhook = intercept(function(txt) { + captured.push(txt); + }); + dbBunyan.config.serverprops.read().result(function(response) { + unhook(); + var first = JSON.parse(captured[0]); + first.should.have.property('name'); + first.name.should.eql('bunyanlog'); + done(); + }, done); + }); + }); + + describe('with Winston', function(){ + var winstonLogger = new (winston.Logger)({ + level: 'debug', + transports: [ + new (winston.transports.Console)({ + formatter: function(options) { + return options.level.toUpperCase() +' '+ (options.message ? options.message : ''); + } + }) + ] + }); + dbWinston.setLogger(winstonLogger); + it('should write Winston string entries', function(done){ + var captured = []; + var unhook = intercept(function(txt) { + captured.push(txt); + }); + dbWinston.config.serverprops.read().result(function(response) { + unhook(); + captured[0].should.startWith('DEBUG'); + done(); + }, done); + }); + }); + +}); + diff --git a/test-basic/patch-builder.js b/test-basic/patch-builder.js index f99df362..30f69285 100644 --- a/test-basic/patch-builder.js +++ b/test-basic/patch-builder.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/plan-aggregates.js b/test-basic/plan-aggregates.js new file mode 100644 index 00000000..30031f51 --- /dev/null +++ b/test-basic/plan-aggregates.js @@ -0,0 +1,321 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; + +describe('aggregates', function() { + it('avg', function(done) { + execPlan( + p.fromLiterals([ + {group:1, val:2}, + {group:1, val:4}, + {group:2, val:3}, + {group:2, val:5}, + {group:2, val:7} + ]) + .groupBy('group', p.avg('valAvg', 'val')) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valAvg.value).equal(3); + should(output[1].group.value).equal(2); + should(output[1].valAvg.value).equal(5); + done(); + }) + .catch(done); + }); + it('count on a column', function(done) { + execPlan( + p.fromLiterals([ + {group:1, val:2}, + {group:1, val:4}, + {group:2, val:3}, + {group:2}, + {group:2, val:7} + ]) + .groupBy('group', p.count('valCount', 'val')) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valCount.value).equal(2); + should(output[1].group.value).equal(2); + should(output[1].valCount.value).equal(2); + done(); + }) + .catch(done); + }); + it('count over rows', function(done) { + execPlan( + p.fromLiterals([ + {group:1, val:2}, + {group:1, val:4}, + {group:2, val:3}, + {group:2}, + {group:2, val:7} + ]) + .groupBy('group', p.count('valCount')) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valCount.value).equal(2); + should(output[1].group.value).equal(2); + should(output[1].valCount.value).equal(3); + done(); + }) + .catch(done); + }); + it('arrayAggregate', function(done) { + execPlan( + p.fromLiterals([ + {group:1, val:2}, + {group:1, val:4}, + {group:2, val:3}, + {group:2, val:5}, + {group:2, val:7} + ]) + .groupBy('group', p.arrayAggregate('valArray', 'val')) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valArray.value.length).equal(2); + should(output[0].valArray.value[0]).equal(2); + should(output[0].valArray.value[1]).equal(4); + should(output[1].group.value).equal(2); + should(output[1].valArray.value.length).equal(3); + should(output[1].valArray.value[0]).equal(3); + should(output[1].valArray.value[1]).equal(5); + should(output[1].valArray.value[2]).equal(7); + done(); + }) + .catch(done); + }); + it('groupConcat', function(done) { + execPlan( + p.fromLiterals([ + {group:1, val:2}, + {group:1, val:4}, + {group:2, val:3}, + {group:2, val:5}, + {group:2, val:7, extra:'a'}, + {group:2, val:7, extra:'b'} + ]) + .groupBy('group', p.groupConcat('valGroupConcat', 'val', {separator:'-', values:'distinct'})) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valGroupConcat.value).equal('2-4'); + should(output[1].group.value).equal(2); + should(output[1].valGroupConcat.value).equal('3-5-7'); + done(); + }) + .catch(done); + }); + it('sequenceAggregate', function(done) { + execPlan( + p.fromLiterals([ + {group:1, val:2}, + {group:1, val:4}, + {group:2, val:3}, + {group:2, val:5}, + {group:2, val:7} + ]) + .groupBy('group', p.sequenceAggregate('valSequence', 'val')) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valSequence.value.length).equal(2); + should(output[0].valSequence.value[0]).equal(2); + should(output[0].valSequence.value[1]).equal(4); + should(output[1].group.value).equal(2); + should(output[1].valSequence.value.length).equal(3); + should(output[1].valSequence.value[0]).equal(3); + should(output[1].valSequence.value[1]).equal(5); + should(output[1].valSequence.value[2]).equal(7); + done(); + }) + .catch(done); + }); + it('max', function(done) { + execPlan( + p.fromLiterals([ + {group:1, val:2}, + {group:1, val:4}, + {group:2, val:3}, + {group:2, val:5}, + {group:2, val:7} + ]) + .groupBy('group', p.max('valMax', 'val')) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valMax.value).equal(4); + should(output[1].group.value).equal(2); + should(output[1].valMax.value).equal(7); + done(); + }) + .catch(done); + }); + it('min', function(done) { + execPlan( + p.fromLiterals([ + {group:1, val:2}, + {group:1, val:4}, + {group:2, val:3}, + {group:2, val:5}, + {group:2, val:7} + ]) + .groupBy('group', p.min('valMin', 'val')) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valMin.value).equal(2); + should(output[1].group.value).equal(2); + should(output[1].valMin.value).equal(3); + done(); + }) + .catch(done); + }); + it('sample', function(done) { + execPlan( + p.fromLiterals([ + {group:1, check:'A', val:2}, + {group:1, check:'A', val:4}, + {group:2, check:'B', val:3}, + {group:2, check:'B', val:5}, + {group:2, check:'B', val:7} + ]) + .groupBy('group', [p.sample('checkSample', 'check'), p.avg('valAvg', 'val')]) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].checkSample.value).equal('A'); + should(output[0].valAvg.value).equal(3); + should(output[1].group.value).equal(2); + should(output[1].checkSample.value).equal('B'); + should(output[1].valAvg.value).equal(5); + done(); + }) + .catch(done); + }); + it('sum', function(done) { + execPlan( + p.fromLiterals([ + {group:1, val:2}, + {group:1, val:4}, + {group:2, val:3}, + {group:2, val:5}, + {group:2, val:7} + ]) + .groupBy('group', p.sum('valSum', 'val')) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valSum.value).equal(6); + should(output[1].group.value).equal(2); + should(output[1].valSum.value).equal(15); + done(); + }) + .catch(done); + }); + it('with duplicate values', function(done) { + execPlan( + p.fromLiterals([ + {row:1, group:1, val:2}, + {row:2, group:1, val:4}, + {row:3, group:1, val:2}, + {row:4, group:2, val:3}, + {row:5, group:2, val:5}, + {row:6, group:2, val:7}, + {row:7, group:2, val:5} + ]) + .groupBy('group', p.count('valCount', 'val')) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valCount.value).equal(3); + should(output[1].group.value).equal(2); + should(output[1].valCount.value).equal(4); + done(); + }) + .catch(done); + }); + it('with distinct values', function(done) { + execPlan( + p.fromLiterals([ + {row:1, group:1, val:2}, + {row:2, group:1, val:4}, + {row:3, group:1, val:2}, + {row:4, group:2, val:3}, + {row:5, group:2, val:5}, + {row:6, group:2, val:7}, + {row:7, group:2, val:5} + ]) + .groupBy('group', p.count('valCount', 'val', {values:'distinct'})) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].valCount.value).equal(2); + should(output[1].group.value).equal(2); + should(output[1].valCount.value).equal(3); + done(); + }) + .catch(done); + }); +}); diff --git a/test-basic/plan-builder-base.js b/test-basic/plan-builder-base.js new file mode 100644 index 00000000..0850fa8f --- /dev/null +++ b/test-basic/plan-builder-base.js @@ -0,0 +1,98 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const marklogic = require('../'); + +const testconfig = require('../etc/test-config'); + +const dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); +const dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); + +const planBuilder = marklogic.planBuilder; + +const rowMgr = dbReader.rows; + +const lit = planBuilder.fromLiterals({rowId:1}); + +function makeInput(values) { + if (values === void 0) { + return lit; + } + return lit.select(values.map((value, i) => planBuilder.as(String(i + 1), value))); +} +function makeTest(input, expression) { + return input.select(planBuilder.as('t', expression)); +} +function execPlan(query, bindings, output) { + const plan = JSON.stringify(query.export()); +// console.log(plan); + const rowOutput = (output === void 0 || output === null) ? 'object' : output; + if (bindings === void 0 || bindings === null) { + return rowMgr.query(plan, {format: 'json', structure: rowOutput}); + } + return rowMgr.query(plan, {format: 'json', structure: rowOutput, bindings:bindings}); +} +function explainPlan(query, format) { + const plan = JSON.stringify(query.export()); + return rowMgr.explain(plan, (format === void 0 || format === null) ? 'json' : format); +} +function testPlan(values, expression) { + return execPlan(makeTest(makeInput(values), expression)); +} +function getResults(response) { + if (response.statusCode >= 500) { + const err = new Error(response.statusCode); + err.response = response; + throw err; + } + if (Array.isArray(response) && response.length > 0 && Array.isArray(response[0].columns)) { + return response.slice(1); + } + const rows = response.rows; + if (rows === void 0) { + return response; + } + return rows; +} +function getResult(response) { + return getResults(response)[0].t; +} + +function makeSelectCall(list) { + return lit.select(list); +} +function makeSelectExport(list) { + return {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-literals', args:[[{rowId:1}]]}, + {ns:'op', fn:'select', args: Array.isArray(list) ? list : [list] } + ]}}; +} + +module.exports = { + dbReader: dbReader, + dbWriter: dbWriter, + planBuilder: planBuilder, + execPlan: execPlan, + explainPlan: explainPlan, + getResult: getResult, + getResults: getResults, + makeInput: makeInput, + makeSelectCall: makeSelectCall, + makeSelectExport: makeSelectExport, + makeTest: makeTest, + testPlan: testPlan +}; diff --git a/test-basic/plan-builder-generated.js b/test-basic/plan-builder-generated.js new file mode 100644 index 00000000..cdd22510 --- /dev/null +++ b/test-basic/plan-builder-generated.js @@ -0,0 +1,2266 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +/* IMPORTANT: Do not edit. This file is generated. */ +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const testPlan = pbb.testPlan; +const getResult = pbb.getResult; + +describe('plan builder', function() { + describe('expression functions', function() { + it('cts.stem#1', function(done) { + testPlan([p.xs.string("ran")], p.cts.stem(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('run'); + done(); + }).catch(done); + }); + it('cts.stem#2', function(done) { + testPlan([p.xs.string("ran"), p.xs.string("en")], p.cts.stem(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('run'); + done(); + }).catch(done); + }); + it('cts.tokenize#1', function(done) { + testPlan([p.xs.string("a-b c")], p.cts.tokenize(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(["a", "-", "b", " ", "c"]); + done(); + }).catch(done); + }); + it('cts.tokenize#2', function(done) { + testPlan([p.xs.string("a-b c"), p.xs.string("en")], p.cts.tokenize(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(["a", "-", "b", " ", "c"]); + done(); + }).catch(done); + }); + it('fn.abs#1', function(done) { + testPlan([p.xs.double(-11)], p.fn.abs(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('11'); + done(); + }).catch(done); + }); + it('fn.analyzeString#2', function(done) { + testPlan([p.xs.string("aXbyc"), p.xs.string("[xy]")], p.fn.analyzeString(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('aXbyc'); + done(); + }).catch(done); + }); + it('fn.analyzeString#3', function(done) { + testPlan([p.xs.string("aXbyc"), p.xs.string("[xy]"), p.xs.string("i")], p.fn.analyzeString(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('aXbyc'); + done(); + }).catch(done); + }); + it('fn.avg#1', function(done) { + testPlan([[p.xs.double(2), p.xs.double(4), p.xs.double(6), p.xs.double(8)]], p.fn.avg(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('5'); + done(); + }).catch(done); + }); + it('fn.boolean#1', function(done) { + testPlan([p.xs.string("abc")], p.fn.boolean(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.ceiling#1', function(done) { + testPlan([p.xs.double(1.3)], p.fn.ceiling(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('fn.codepointEqual#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("abc")], p.fn.codepointEqual(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.codepointsToString#1', function(done) { + testPlan([[p.xs.integer(97), p.xs.integer(98), p.xs.integer(99)]], p.fn.codepointsToString(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('fn.compare#2', function(done) { + testPlan([p.xs.string("abz"), p.xs.string("aba")], p.fn.compare(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('fn.compare#3', function(done) { + testPlan([p.xs.string("abz"), p.xs.string("aba"), p.xs.string("http://marklogic.com/collation/")], p.fn.compare(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('fn.concat#2', function(done) { + testPlan([p.xs.string("a"), p.xs.string("b")], p.fn.concat(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('ab'); + done(); + }).catch(done); + }); + it('fn.concat#3', function(done) { + testPlan([p.xs.string("a"), p.xs.string("b"), p.xs.string("c")], p.fn.concat(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('fn.contains#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("b")], p.fn.contains(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.contains#3', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("b"), p.xs.string("http://marklogic.com/collation/")], p.fn.contains(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.count#1', function(done) { + testPlan([[p.xs.double(1), p.xs.double(2), p.xs.double(3)]], p.fn.count(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3'); + done(); + }).catch(done); + }); + it('fn.count#2', function(done) { + testPlan([[p.xs.double(1), p.xs.double(2), p.xs.double(3)], p.xs.double(4)], p.fn.count(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3'); + done(); + }).catch(done); + }); + it('fn.dayFromDate#1', function(done) { + testPlan([p.xs.date("2016-01-02-03:04")], p.fn.dayFromDate(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('fn.dayFromDateTime#1', function(done) { + testPlan([p.xs.dateTime("2016-01-02T10:09:08Z")], p.fn.dayFromDateTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('fn.daysFromDuration#1', function(done) { + testPlan([p.xs.dayTimeDuration("P3DT4H5M6S")], p.fn.daysFromDuration(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3'); + done(); + }).catch(done); + }); + it('fn.deepEqual#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("abc")], p.fn.deepEqual(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.deepEqual#3', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("abc"), p.xs.string("http://marklogic.com/collation/")], p.fn.deepEqual(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.distinctValues#1', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("b"), p.xs.string("c")]], p.fn.distinctValues(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(["a", "b", "c"]); + done(); + }).catch(done); + }); + it('fn.distinctValues#2', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("b"), p.xs.string("c")], p.xs.string("http://marklogic.com/collation/")], p.fn.distinctValues(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(["a", "b", "c"]); + done(); + }).catch(done); + }); + it('fn.empty#1', function(done) { + testPlan([p.xs.double(1)], p.fn.empty(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(false); + done(); + }).catch(done); + }); + it('fn.encodeForUri#1', function(done) { + testPlan([p.xs.string("http://a/b?c#d")], p.fn.encodeForUri(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('http%3A%2F%2Fa%2Fb%3Fc%23d'); + done(); + }).catch(done); + }); + it('fn.endsWith#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("c")], p.fn.endsWith(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.endsWith#3', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("c"), p.xs.string("http://marklogic.com/collation/")], p.fn.endsWith(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.escapeHtmlUri#1', function(done) { + testPlan([p.xs.string("http://a/b?c#d")], p.fn.escapeHtmlUri(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('http://a/b?c#d'); + done(); + }).catch(done); + }); + it('fn.exists#1', function(done) { + testPlan([p.xs.double(1)], p.fn.exists(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.false#0', function(done) { + testPlan(undefined, p.fn.false()) + .then(function(response) { + should(getResult(response).value).eql(false); + done(); + }).catch(done); + }); + it('fn.floor#1', function(done) { + testPlan([p.xs.double(1.7)], p.fn.floor(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('fn.formatDate#2', function(done) { + testPlan([p.xs.date("2016-01-02-03:04"), p.xs.string("[Y0001]/[M01]/[D01]")], p.fn.formatDate(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016/01/02'); + done(); + }).catch(done); + }); + it('fn.formatDateTime#2', function(done) { + testPlan([p.xs.dateTime("2016-01-02T10:09:08Z"), p.xs.string("[Y0001]/[M01]/[D01] [H01]:[m01]:[s01]:[f01]")], p.fn.formatDateTime(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016/01/02 10:09:08:00'); + done(); + }).catch(done); + }); + it('fn.formatNumber#2', function(done) { + testPlan([p.xs.double(1234.5), p.xs.string("#,##0.00")], p.fn.formatNumber(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql("1,234.50"); + done(); + }).catch(done); + }); + it('fn.formatTime#2', function(done) { + testPlan([p.xs.time("10:09:08Z"), p.xs.string("[H01]:[m01]:[s01]:[f01]")], p.fn.formatTime(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('10:09:08:00'); + done(); + }).catch(done); + }); + it('fn.head#1', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c")]], p.fn.head(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a'); + done(); + }).catch(done); + }); + it('fn.hoursFromDateTime#1', function(done) { + testPlan([p.xs.dateTime("2016-01-02T10:09:08Z")], p.fn.hoursFromDateTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('10'); + done(); + }).catch(done); + }); + it('fn.hoursFromDuration#1', function(done) { + testPlan([p.xs.dayTimeDuration("P3DT4H5M6S")], p.fn.hoursFromDuration(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('4'); + done(); + }).catch(done); + }); + it('fn.hoursFromTime#1', function(done) { + testPlan([p.xs.time("10:09:08Z")], p.fn.hoursFromTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('10'); + done(); + }).catch(done); + }); + it('fn.indexOf#2', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c")], p.xs.string("b")], p.fn.indexOf(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('fn.indexOf#3', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c")], p.xs.string("b"), p.xs.string("http://marklogic.com/collation/")], p.fn.indexOf(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('fn.insertBefore#3', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("e"), p.xs.string("f")], p.xs.integer(3), [p.xs.string("c"), p.xs.string("d")]], p.fn.insertBefore(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).eql(["a", "b", "c", "d", "e", "f"]); + done(); + }).catch(done); + }); + it('fn.iriToUri#1', function(done) { + testPlan([p.xs.string("http://a/b?c#d")], p.fn.iriToUri(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('http://a/b?c#d'); + done(); + }).catch(done); + }); + it('fn.localNameFromQName#1', function(done) { + testPlan([p.xs.QName("abc")], p.fn.localNameFromQName(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('fn.lowerCase#1', function(done) { + testPlan([p.xs.string("ABC")], p.fn.lowerCase(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('fn.matches#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("^.B")], p.fn.matches(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(false); + done(); + }).catch(done); + }); + it('fn.matches#3', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("^.B"), p.xs.string("i")], p.fn.matches(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.max#1', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c")]], p.fn.max(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('c'); + done(); + }).catch(done); + }); + it('fn.max#2', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c")], p.xs.string("http://marklogic.com/collation/")], p.fn.max(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('c'); + done(); + }).catch(done); + }); + it('fn.min#1', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c")]], p.fn.min(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a'); + done(); + }).catch(done); + }); + it('fn.min#2', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c")], p.xs.string("http://marklogic.com/collation/")], p.fn.min(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a'); + done(); + }).catch(done); + }); + it('fn.minutesFromDateTime#1', function(done) { + testPlan([p.xs.dateTime("2016-01-02T10:09:08Z")], p.fn.minutesFromDateTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('9'); + done(); + }).catch(done); + }); + it('fn.minutesFromDuration#1', function(done) { + testPlan([p.xs.dayTimeDuration("P3DT4H5M6S")], p.fn.minutesFromDuration(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('5'); + done(); + }).catch(done); + }); + it('fn.minutesFromTime#1', function(done) { + testPlan([p.xs.time("10:09:08Z")], p.fn.minutesFromTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('9'); + done(); + }).catch(done); + }); + it('fn.monthFromDate#1', function(done) { + testPlan([p.xs.date("2016-01-02-03:04")], p.fn.monthFromDate(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('fn.monthFromDateTime#1', function(done) { + testPlan([p.xs.dateTime("2016-01-02T10:09:08Z")], p.fn.monthFromDateTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('fn.monthsFromDuration#1', function(done) { + testPlan([p.xs.yearMonthDuration("P1Y2M")], p.fn.monthsFromDuration(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('fn.namespaceUriFromQName#1', function(done) { + testPlan([p.xs.QName("abc")], p.fn.namespaceUriFromQName(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal(''); + done(); + }).catch(done); + }); + it('fn.normalizeSpace#1', function(done) { + testPlan([p.xs.string(" abc 123 ")], p.fn.normalizeSpace(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc 123'); + done(); + }).catch(done); + }); + it('fn.normalizeUnicode#1', function(done) { + testPlan([p.xs.string(" aBc ")], p.fn.normalizeUnicode(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('aBc '); + done(); + }).catch(done); + }); + it('fn.normalizeUnicode#2', function(done) { + testPlan([p.xs.string(" aBc "), p.xs.string("NFC")], p.fn.normalizeUnicode(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('aBc '); + done(); + }).catch(done); + }); + it('fn.not#1', function(done) { + testPlan([p.xs.boolean(true)], p.fn.not(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(false); + done(); + }).catch(done); + }); + it('fn.number#1', function(done) { + testPlan([p.xs.string("1.1")], p.fn.number(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.1'); + done(); + }).catch(done); + }); + it('fn.prefixFromQName#1', function(done) { + testPlan([p.xs.QName("abc")], p.fn.prefixFromQName(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(null); + done(); + }).catch(done); + }); + it('fn.QName#2', function(done) { + testPlan([p.xs.string("http://a/b"), p.xs.string("c")], p.fn.QName(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('c'); + done(); + }).catch(done); + }); + it('fn.remove#2', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("x"), p.xs.string("c")], p.xs.integer(3)], p.fn.remove(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(["a", "b", "c"]); + done(); + }).catch(done); + }); + it('fn.replace#3', function(done) { + testPlan([p.xs.string("axc"), p.xs.string("^(.)X"), p.xs.string("$1b")], p.fn.replace(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('axc'); + done(); + }).catch(done); + }); + it('fn.replace#4', function(done) { + testPlan([p.xs.string("axc"), p.xs.string("^(.)X"), p.xs.string("$1b"), p.xs.string("i")], p.fn.replace(p.col("1"), p.col("2"), p.col("3"), p.col("4"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('fn.resolveUri#2', function(done) { + testPlan([p.xs.string("b?c#d"), p.xs.string("http://a/x")], p.fn.resolveUri(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('http://a/b?c#d'); + done(); + }).catch(done); + }); + it('fn.reverse#1', function(done) { + testPlan([[p.xs.string("c"), p.xs.string("b"), p.xs.string("a")]], p.fn.reverse(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(["a", "b", "c"]); + done(); + }).catch(done); + }); + it('fn.round#1', function(done) { + testPlan([p.xs.double(1.7)], p.fn.round(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('fn.roundHalfToEven#1', function(done) { + testPlan([p.xs.double(1234.5)], p.fn.roundHalfToEven(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1234'); + done(); + }).catch(done); + }); + it('fn.roundHalfToEven#2', function(done) { + testPlan([p.xs.double(1234.5), p.xs.integer(-2)], p.fn.roundHalfToEven(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1200'); + done(); + }).catch(done); + }); + it('fn.secondsFromDateTime#1', function(done) { + testPlan([p.xs.dateTime("2016-01-02T10:09:08Z")], p.fn.secondsFromDateTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('8'); + done(); + }).catch(done); + }); + it('fn.secondsFromDuration#1', function(done) { + testPlan([p.xs.dayTimeDuration("P3DT4H5M6S")], p.fn.secondsFromDuration(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('6'); + done(); + }).catch(done); + }); + it('fn.secondsFromTime#1', function(done) { + testPlan([p.xs.time("10:09:08Z")], p.fn.secondsFromTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('8'); + done(); + }).catch(done); + }); + it('fn.startsWith#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("a")], p.fn.startsWith(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.startsWith#3', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("a"), p.xs.string("http://marklogic.com/collation/")], p.fn.startsWith(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.string#1', function(done) { + testPlan([p.xs.double(1)], p.fn.string(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('fn.stringJoin#2', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c")], p.xs.string("+")], p.fn.stringJoin(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a+b+c'); + done(); + }).catch(done); + }); + it('fn.stringLength#1', function(done) { + testPlan([p.xs.string("abc")], p.fn.stringLength(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3'); + done(); + }).catch(done); + }); + it('fn.stringToCodepoints#1', function(done) { + testPlan([p.xs.string("abc")], p.fn.stringToCodepoints(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql([97, 98, 99]); + done(); + }).catch(done); + }); + it('fn.subsequence#2', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c"), p.xs.string("d"), p.xs.string("e")], p.xs.double(2)], p.fn.subsequence(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(["b", "c", "d", "e"]); + done(); + }).catch(done); + }); + it('fn.subsequence#3', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c"), p.xs.string("d"), p.xs.string("e")], p.xs.double(2), p.xs.double(3)], p.fn.subsequence(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).eql(["b", "c", "d"]); + done(); + }).catch(done); + }); + it('fn.substring#2', function(done) { + testPlan([p.xs.string("abcd"), p.xs.double(2)], p.fn.substring(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('bcd'); + done(); + }).catch(done); + }); + it('fn.substring#3', function(done) { + testPlan([p.xs.string("abcd"), p.xs.double(2), p.xs.double(2)], p.fn.substring(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('bc'); + done(); + }).catch(done); + }); + it('fn.substringAfter#2', function(done) { + testPlan([p.xs.string("abcd"), p.xs.string("ab")], p.fn.substringAfter(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('cd'); + done(); + }).catch(done); + }); + it('fn.substringAfter#3', function(done) { + testPlan([p.xs.string("abcd"), p.xs.string("ab"), p.xs.string("http://marklogic.com/collation/")], p.fn.substringAfter(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('cd'); + done(); + }).catch(done); + }); + it('fn.substringBefore#2', function(done) { + testPlan([p.xs.string("abcd"), p.xs.string("cd")], p.fn.substringBefore(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('ab'); + done(); + }).catch(done); + }); + it('fn.substringBefore#3', function(done) { + testPlan([p.xs.string("abcd"), p.xs.string("cd"), p.xs.string("http://marklogic.com/collation/")], p.fn.substringBefore(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('ab'); + done(); + }).catch(done); + }); + it('fn.sum#1', function(done) { + testPlan([[p.xs.double(1), p.xs.double(2), p.xs.double(3)]], p.fn.sum(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('6'); + done(); + }).catch(done); + }); + it('fn.tail#1', function(done) { + testPlan([[p.xs.string("a"), p.xs.string("b"), p.xs.string("c")]], p.fn.tail(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(["b", "c"]); + done(); + }).catch(done); + }); + it('fn.tokenize#2', function(done) { + testPlan([p.xs.string("axbxc"), p.xs.string("X")], p.fn.tokenize(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('axbxc'); + done(); + }).catch(done); + }); + it('fn.tokenize#3', function(done) { + testPlan([p.xs.string("axbxc"), p.xs.string("X"), p.xs.string("i")], p.fn.tokenize(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).eql(["a", "b", "c"]); + done(); + }).catch(done); + }); + it('fn.translate#3', function(done) { + testPlan([p.xs.string("axcy"), p.xs.string("xy"), p.xs.string("bd")], p.fn.translate(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abcd'); + done(); + }).catch(done); + }); + it('fn.true#0', function(done) { + testPlan(undefined, p.fn.true()) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('fn.upperCase#1', function(done) { + testPlan([p.xs.string("abc")], p.fn.upperCase(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('ABC'); + done(); + }).catch(done); + }); + it('fn.yearFromDate#1', function(done) { + testPlan([p.xs.date("2016-01-02-03:04")], p.fn.yearFromDate(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016'); + done(); + }).catch(done); + }); + it('fn.yearFromDateTime#1', function(done) { + testPlan([p.xs.dateTime("2016-01-02T10:09:08Z")], p.fn.yearFromDateTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016'); + done(); + }).catch(done); + }); + it('fn.yearsFromDuration#1', function(done) { + testPlan([p.xs.yearMonthDuration("P1Y2M")], p.fn.yearsFromDuration(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('json.array#0', function(done) { + testPlan(undefined, p.json.array()) + .then(function(response) { + should(getResult(response).value).eql([]); + done(); + }).catch(done); + }); + it('json.toArray#0', function(done) { + testPlan(undefined, p.json.toArray()) + .then(function(response) { + should(getResult(response).value).eql([]); + done(); + }).catch(done); + }); + it('map.entry#2', function(done) { + testPlan([p.xs.string("one"), p.xs.string("two")], p.map.entry(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql({"one":"two"}); + done(); + }).catch(done); + }); + it('map.map#0', function(done) { + testPlan(undefined, p.map.map()) + .then(function(response) { + should(getResult(response).value).eql({}); + done(); + }).catch(done); + }); + it('math.acos#1', function(done) { + testPlan([p.xs.double(0.5)], p.math.acos(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.0471975511966'); + done(); + }).catch(done); + }); + it('math.asin#1', function(done) { + testPlan([p.xs.double(0.5)], p.math.asin(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0.523598775598299'); + done(); + }).catch(done); + }); + it('math.atan#1', function(done) { + testPlan([p.xs.double(3.14159)], p.math.atan(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.26262701154934'); + done(); + }).catch(done); + }); + it('math.atan2#2', function(done) { + testPlan([p.xs.double(36.23), p.xs.double(5.234)], p.math.atan2(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.42732303452594'); + done(); + }).catch(done); + }); + it('math.ceil#1', function(done) { + testPlan([p.xs.double(1.3)], p.math.ceil(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('math.cos#1', function(done) { + testPlan([p.xs.double(11)], p.math.cos(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0.00442569798805079'); + done(); + }).catch(done); + }); + it('math.cosh#1', function(done) { + testPlan([p.xs.double(11)], p.math.cosh(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('29937.0708659498'); + done(); + }).catch(done); + }); + it('math.cot#1', function(done) { + testPlan([p.xs.double(19.5)], p.math.cot(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.31422390103306'); + done(); + }).catch(done); + }); + it('math.degrees#1', function(done) { + testPlan([p.xs.double(1.5707963267949)], p.math.degrees(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('90.0000000000002'); + done(); + }).catch(done); + }); + it('math.exp#1', function(done) { + testPlan([p.xs.double(0.1)], p.math.exp(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.10517091807565'); + done(); + }).catch(done); + }); + it('math.fabs#1', function(done) { + testPlan([p.xs.double(4.013)], p.math.fabs(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('4.013'); + done(); + }).catch(done); + }); + it('math.floor#1', function(done) { + testPlan([p.xs.double(1.7)], p.math.floor(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('math.fmod#2', function(done) { + testPlan([p.xs.double(10), p.xs.double(3)], p.math.fmod(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('math.frexp#1', function(done) { + testPlan([p.xs.double(10)], p.math.frexp(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql([0.625, 4]); + done(); + }).catch(done); + }); + it('math.ldexp#2', function(done) { + testPlan([p.xs.double(1.333), p.xs.integer(10)], p.math.ldexp(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1364.992'); + done(); + }).catch(done); + }); + it('math.log#1', function(done) { + testPlan([p.xs.double(1000)], p.math.log(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('6.90775527898214'); + done(); + }).catch(done); + }); + it('math.log10#1', function(done) { + testPlan([p.xs.double(1000)], p.math.log10(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3'); + done(); + }).catch(done); + }); + it('math.median#1', function(done) { + testPlan([p.xs.double(1.2)], p.math.median(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.2'); + done(); + }).catch(done); + }); + it('math.mode#1', function(done) { + testPlan([[p.xs.string("abc"), p.xs.string("abc"), p.xs.string("def")]], p.math.mode(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('math.mode#2', function(done) { + testPlan([[p.xs.string("abc"), p.xs.string("abc"), p.xs.string("def")], p.xs.string("collation=http://marklogic.com/collation/")], p.math.mode(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('math.modf#1', function(done) { + testPlan([p.xs.double(1.333)], p.math.modf(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql([0.333, 1]); + done(); + }).catch(done); + }); + it('math.percentRank#2', function(done) { + testPlan([[p.xs.double(1), p.xs.double(7), p.xs.double(5), p.xs.double(5), p.xs.double(10), p.xs.double(9)], p.xs.double(9)], p.math.percentRank(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0.833333333333333'); + done(); + }).catch(done); + }); + it('math.percentRank#3', function(done) { + testPlan([[p.xs.double(1), p.xs.double(7), p.xs.double(5), p.xs.double(5), p.xs.double(10), p.xs.double(9)], p.xs.double(9), p.xs.string("descending")], p.math.percentRank(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0.333333333333333'); + done(); + }).catch(done); + }); + it('math.percentile#2', function(done) { + testPlan([[p.xs.double(2), p.xs.double(3), p.xs.double(1), p.xs.double(4)], [p.xs.double(0.25), p.xs.double(0.75)]], p.math.percentile(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql([1.5, 3.5]); + done(); + }).catch(done); + }); + it('math.pi#0', function(done) { + testPlan(undefined, p.math.pi()) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3.14159265358979'); + done(); + }).catch(done); + }); + it('math.pow#2', function(done) { + testPlan([p.xs.double(2), p.xs.double(10)], p.math.pow(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1024'); + done(); + }).catch(done); + }); + it('math.radians#1', function(done) { + testPlan([p.xs.double(90)], p.math.radians(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.5707963267949'); + done(); + }).catch(done); + }); + it('math.rank#2', function(done) { + testPlan([[p.xs.double(1), p.xs.double(7), p.xs.double(5), p.xs.double(5), p.xs.double(10), p.xs.double(9)], p.xs.double(9)], p.math.rank(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('5'); + done(); + }).catch(done); + }); + it('math.rank#3', function(done) { + testPlan([[p.xs.double(1), p.xs.double(7), p.xs.double(5), p.xs.double(5), p.xs.double(10), p.xs.double(9)], p.xs.double(9), p.xs.string("descending")], p.math.rank(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('math.sin#1', function(done) { + testPlan([p.xs.double(1.95)], p.math.sin(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0.928959715003869'); + done(); + }).catch(done); + }); + it('math.sinh#1', function(done) { + testPlan([p.xs.double(1.95)], p.math.sinh(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3.44320675450139'); + done(); + }).catch(done); + }); + it('math.sqrt#1', function(done) { + testPlan([p.xs.double(4)], p.math.sqrt(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('math.stddev#1', function(done) { + testPlan([p.xs.double(1.2)], p.math.stddev(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(null); + done(); + }).catch(done); + }); + it('math.stddevP#1', function(done) { + testPlan([p.xs.double(1.2)], p.math.stddevP(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0'); + done(); + }).catch(done); + }); + it('math.tan#1', function(done) { + testPlan([p.xs.double(19.5)], p.math.tan(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0.760905351982977'); + done(); + }).catch(done); + }); + it('math.tanh#1', function(done) { + testPlan([p.xs.double(0.95)], p.math.tanh(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0.739783051274004'); + done(); + }).catch(done); + }); + it('math.trunc#1', function(done) { + testPlan([p.xs.double(123.456)], p.math.trunc(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('123'); + done(); + }).catch(done); + }); + it('math.trunc#2', function(done) { + testPlan([p.xs.double(123.456), p.xs.integer(2)], p.math.trunc(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('123.45'); + done(); + }).catch(done); + }); + it('math.variance#1', function(done) { + testPlan([p.xs.double(1.2)], p.math.variance(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(null); + done(); + }).catch(done); + }); + it('math.varianceP#1', function(done) { + testPlan([p.xs.double(1.2)], p.math.varianceP(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0'); + done(); + }).catch(done); + }); + it('rdf.langString#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("en")], p.rdf.langString(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('rdf.langStringLanguage#1', function(done) { + testPlan([p.rdf.langString("abc", "en")], p.rdf.langStringLanguage(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('en'); + done(); + }).catch(done); + }); + it('sem.coalesce#2', function(done) { + testPlan([p.xs.string("a"), p.xs.string("b")], p.sem.coalesce(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a'); + done(); + }).catch(done); + }); + it('sem.coalesce#3', function(done) { + testPlan([p.xs.string("a"), p.xs.string("b"), p.xs.string("c")], p.sem.coalesce(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a'); + done(); + }).catch(done); + }); + it('sem.datatype#1', function(done) { + testPlan([p.xs.string("a")], p.sem.datatype(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('http://www.w3.org/2001/XMLSchema#string'); + done(); + }).catch(done); + }); + it('sem.if#3', function(done) { + testPlan([p.xs.boolean(true), p.xs.string("a"), p.xs.string("b")], p.sem.if(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a'); + done(); + }).catch(done); + }); + it('sem.invalid#2', function(done) { + testPlan([p.xs.string("abc"), p.sem.iri("http://a/b")], p.sem.invalid(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('sem.iri#1', function(done) { + testPlan([p.xs.string("http://a/b")], p.sem.iri(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('http://a/b'); + done(); + }).catch(done); + }); + it('sem.iriToQName#1', function(done) { + testPlan([p.xs.string("http://a/b")], p.sem.iriToQName(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('b'); + done(); + }).catch(done); + }); + it('sem.isBlank#1', function(done) { + testPlan([p.xs.double(1)], p.sem.isBlank(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(false); + done(); + }).catch(done); + }); + it('sem.isIRI#1', function(done) { + testPlan([p.xs.double(1)], p.sem.isIRI(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(false); + done(); + }).catch(done); + }); + it('sem.isLiteral#1', function(done) { + testPlan([p.xs.double(1)], p.sem.isLiteral(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('sem.isNumeric#1', function(done) { + testPlan([p.xs.string("a")], p.sem.isNumeric(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(false); + done(); + }).catch(done); + }); + it('sem.lang#1', function(done) { + testPlan([p.xs.string("abc")], p.sem.lang(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal(''); + done(); + }).catch(done); + }); + it('sem.langMatches#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("abc")], p.sem.langMatches(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('sem.QNameToIri#1', function(done) { + testPlan([p.xs.QName("abc")], p.sem.QNameToIri(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('sem.sameTerm#2', function(done) { + testPlan([p.xs.double(1), p.xs.double(1)], p.sem.sameTerm(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('sem.timezoneString#1', function(done) { + testPlan([p.xs.dateTime("2016-01-02T10:09:08Z")], p.sem.timezoneString(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('Z'); + done(); + }).catch(done); + }); + it('sem.typedLiteral#2', function(done) { + testPlan([p.xs.string("abc"), p.sem.iri("http://a/b")], p.sem.typedLiteral(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('sem.unknown#2', function(done) { + testPlan([p.xs.string("abc"), p.sem.iri("http://a/b")], p.sem.unknown(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('spell.doubleMetaphone#1', function(done) { + testPlan([p.xs.string("smith")], p.spell.doubleMetaphone(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(["smo", "xmt"]); + done(); + }).catch(done); + }); + it('spell.levenshteinDistance#2', function(done) { + testPlan([p.xs.string("cat"), p.xs.string("cats")], p.spell.levenshteinDistance(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('spell.romanize#1', function(done) { + testPlan([p.xs.string("abc")], p.spell.romanize(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('sql.bitLength#1', function(done) { + testPlan([p.xs.string("abc")], p.sql.bitLength(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('24'); + done(); + }).catch(done); + }); + it('sql.collatedString#2', function(done) { + testPlan([p.xs.string("a"), p.xs.string("http://marklogic.com/collation/")], p.sql.collatedString(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a'); + done(); + }).catch(done); + }); + it('sql.dateadd#3', function(done) { + testPlan([p.xs.string("day"), p.xs.int(3), p.xs.string("2016-01-02T10:09:08Z")], p.sql.dateadd(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016-01-05T10:09:08Z'); + done(); + }).catch(done); + }); + it('sql.datediff#3', function(done) { + testPlan([p.xs.string("day"), p.xs.string("2016-01-02T10:09:08Z"), p.xs.string("2016-01-05T10:09:08Z")], p.sql.datediff(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3'); + done(); + }).catch(done); + }); + it('sql.datepart#2', function(done) { + testPlan([p.xs.string("day"), p.xs.string("2016-01-05T10:09:08Z")], p.sql.datepart(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('5'); + done(); + }).catch(done); + }); + it('sql.day#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.sql.day(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('sql.dayname#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.sql.dayname(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('Saturday'); + done(); + }).catch(done); + }); + it('sql.hours#1', function(done) { + testPlan([p.xs.string("10:09:08")], p.sql.hours(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('10'); + done(); + }).catch(done); + }); + it('sql.insert#4', function(done) { + testPlan([p.xs.string("axxxf"), p.xs.double(2), p.xs.double(3), p.xs.string("bcde")], p.sql.insert(p.col("1"), p.col("2"), p.col("3"), p.col("4"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abcdef'); + done(); + }).catch(done); + }); + it('sql.instr#2', function(done) { + testPlan([p.xs.string("abcde"), p.xs.string("cd")], p.sql.instr(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3'); + done(); + }).catch(done); + }); + it('sql.left#2', function(done) { + testPlan([p.xs.string("abcde"), p.xs.double(3)], p.sql.left(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('sql.ltrim#1', function(done) { + testPlan([p.xs.string("abc")], p.sql.ltrim(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('sql.minutes#1', function(done) { + testPlan([p.xs.string("10:09:08")], p.sql.minutes(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('9'); + done(); + }).catch(done); + }); + it('sql.month#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.sql.month(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('sql.monthname#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.sql.monthname(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('January'); + done(); + }).catch(done); + }); + it('sql.octetLength#1', function(done) { + testPlan([p.xs.string("abc")], p.sql.octetLength(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3'); + done(); + }).catch(done); + }); + it('sql.quarter#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.sql.quarter(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('sql.repeat#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.double(2)], p.sql.repeat(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abcabc'); + done(); + }).catch(done); + }); + it('sql.right#2', function(done) { + testPlan([p.xs.string("abcde"), p.xs.double(3)], p.sql.right(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('cde'); + done(); + }).catch(done); + }); + it('sql.rtrim#1', function(done) { + testPlan([p.xs.string("abc")], p.sql.rtrim(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('sql.seconds#1', function(done) { + testPlan([p.xs.string("10:09:08")], p.sql.seconds(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('8'); + done(); + }).catch(done); + }); + it('sql.sign#1', function(done) { + testPlan([p.xs.double(-3)], p.sql.sign(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('-1'); + done(); + }).catch(done); + }); + it('sql.space#1', function(done) { + testPlan([p.xs.double(1.2)], p.sql.space(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal(''); + done(); + }).catch(done); + }); + it('sql.trim#1', function(done) { + testPlan([p.xs.string("abc")], p.sql.trim(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('sql.week#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.sql.week(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('53'); + done(); + }).catch(done); + }); + it('sql.weekday#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.sql.weekday(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('6'); + done(); + }).catch(done); + }); + it('sql.year#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.sql.year(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016'); + done(); + }).catch(done); + }); + it('sql.yearday#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.sql.yearday(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('xdmp.add64#2', function(done) { + testPlan([p.xs.unsignedLong(123), p.xs.unsignedLong(456)], p.xdmp.add64(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('579'); + done(); + }).catch(done); + }); + it('xdmp.and64#2', function(done) { + testPlan([p.xs.unsignedLong(255), p.xs.unsignedLong(2)], p.xdmp.and64(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('xdmp.base64Decode#1', function(done) { + testPlan([p.xs.string("aGVsbG8sIHdvcmxk")], p.xdmp.base64Decode(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql("hello, world"); + done(); + }).catch(done); + }); + it('xdmp.base64Encode#1', function(done) { + testPlan([p.xs.string("hello, world")], p.xdmp.base64Encode(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('aGVsbG8sIHdvcmxk'); + done(); + }).catch(done); + }); + it('xdmp.castableAs#3', function(done) { + testPlan([p.xs.string("http://www.w3.org/2001/XMLSchema"), p.xs.string("int"), p.xs.string("1")], p.xdmp.castableAs(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('xdmp.crypt#2', function(done) { + testPlan([p.xs.string("123abc"), p.xs.string("admin")], p.xdmp.crypt(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('arQEnpM6JHR8vY4n3e5gr0'); + done(); + }).catch(done); + }); + it('xdmp.daynameFromDate#1', function(done) { + testPlan([p.xs.date("2016-01-02")], p.xdmp.daynameFromDate(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('Saturday'); + done(); + }).catch(done); + }); + it('xdmp.decodeFromNCName#1', function(done) { + testPlan([p.xs.string("A_20_Name")], p.xdmp.decodeFromNCName(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('A Name'); + done(); + }).catch(done); + }); + it('xdmp.diacriticLess#1', function(done) { + testPlan([p.xs.string("abc")], p.xdmp.diacriticLess(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('xdmp.encodeForNCName#1', function(done) { + testPlan([p.xs.string("A Name")], p.xdmp.encodeForNCName(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('A_20_Name'); + done(); + }).catch(done); + }); + it('xdmp.formatNumber#1', function(done) { + testPlan([p.xs.double(9)], p.xdmp.formatNumber(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('9'); + done(); + }).catch(done); + }); + it('xdmp.formatNumber#2', function(done) { + testPlan([p.xs.double(9), p.xs.string("W")], p.xdmp.formatNumber(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('9'); + done(); + }).catch(done); + }); + it('xdmp.formatNumber#3', function(done) { + testPlan([p.xs.double(9), p.xs.string("W"), p.xs.string("en")], p.xdmp.formatNumber(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('NINE'); + done(); + }).catch(done); + }); + it('xdmp.formatNumber#4', function(done) { + testPlan([p.xs.double(9), p.xs.string("W"), p.xs.string("en"), p.xs.string("")], p.xdmp.formatNumber(p.col("1"), p.col("2"), p.col("3"), p.col("4"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('NINE'); + done(); + }).catch(done); + }); + it('xdmp.formatNumber#5', function(done) { + testPlan([p.xs.double(9), p.xs.string("W"), p.xs.string("en"), p.xs.string(""), p.xs.string("")], p.xdmp.formatNumber(p.col("1"), p.col("2"), p.col("3"), p.col("4"), p.col("5"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('NINE'); + done(); + }).catch(done); + }); + it('xdmp.formatNumber#6', function(done) { + testPlan([p.xs.double(9), p.xs.string("W"), p.xs.string("en"), p.xs.string(""), p.xs.string(""), p.xs.string("")], p.xdmp.formatNumber(p.col("1"), p.col("2"), p.col("3"), p.col("4"), p.col("5"), p.col("6"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('NINE'); + done(); + }).catch(done); + }); + it('xdmp.formatNumber#7', function(done) { + testPlan([p.xs.double(9), p.xs.string("W"), p.xs.string("en"), p.xs.string(""), p.xs.string(""), p.xs.string(""), p.xs.string(",")], p.xdmp.formatNumber(p.col("1"), p.col("2"), p.col("3"), p.col("4"), p.col("5"), p.col("6"), p.col("7"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('NINE'); + done(); + }).catch(done); + }); + it('xdmp.formatNumber#8', function(done) { + testPlan([p.xs.double(9), p.xs.string("W"), p.xs.string("en"), p.xs.string(""), p.xs.string(""), p.xs.string(""), p.xs.string(","), p.xs.integer(3)], p.xdmp.formatNumber(p.col("1"), p.col("2"), p.col("3"), p.col("4"), p.col("5"), p.col("6"), p.col("7"), p.col("8"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('NINE'); + done(); + }).catch(done); + }); + it('xdmp.hash32#1', function(done) { + testPlan([p.xs.string("abc")], p.xdmp.hash32(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('4229403455'); + done(); + }).catch(done); + }); + it('xdmp.hash64#1', function(done) { + testPlan([p.xs.string("abc")], p.xdmp.hash64(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('13056678368508584127'); + done(); + }).catch(done); + }); + it('xdmp.hexToInteger#1', function(done) { + testPlan([p.xs.string("1234567890abcdef")], p.xdmp.hexToInteger(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1311768467294899695'); + done(); + }).catch(done); + }); + it('xdmp.hmacMd5#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("def")], p.xdmp.hmacMd5(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('debda77b7cc3e7a10ee70104e6717a6b'); + done(); + }).catch(done); + }); + it('xdmp.hmacMd5#3', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("def"), p.xs.string("base64")], p.xdmp.hmacMd5(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3r2ne3zD56EO5wEE5nF6aw=='); + done(); + }).catch(done); + }); + it('xdmp.hmacSha1#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("def")], p.xdmp.hmacSha1(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('12554eabbaf7e8e12e4737020f987ca7901016e5'); + done(); + }).catch(done); + }); + it('xdmp.hmacSha1#3', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("def"), p.xs.string("base64")], p.xdmp.hmacSha1(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('ElVOq7r36OEuRzcCD5h8p5AQFuU='); + done(); + }).catch(done); + }); + it('xdmp.hmacSha256#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("def")], p.xdmp.hmacSha256(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('20ebc0f09344470134f35040f63ea98b1d8e414212949ee5c500429d15eab081'); + done(); + }).catch(done); + }); + it('xdmp.hmacSha256#3', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("def"), p.xs.string("base64")], p.xdmp.hmacSha256(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('IOvA8JNERwE081BA9j6pix2OQUISlJ7lxQBCnRXqsIE='); + done(); + }).catch(done); + }); + it('xdmp.hmacSha512#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("def")], p.xdmp.hmacSha512(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('bf93c3deee1eb6660ec00820a285327b3e8b775f641fd7f2ea321b6a241afe7b49a5cca81d2e8e1d206bd3379530e2d9ad3a7b2cc54ca66ea3352ebfee3862e5'); + done(); + }).catch(done); + }); + it('xdmp.hmacSha512#3', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("def"), p.xs.string("base64")], p.xdmp.hmacSha512(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('v5PD3u4etmYOwAggooUyez6Ld19kH9fy6jIbaiQa/ntJpcyoHS6OHSBr0zeVMOLZrTp7LMVMpm6jNS6/7jhi5Q=='); + done(); + }).catch(done); + }); + it('xdmp.initcap#1', function(done) { + testPlan([p.xs.string("abc")], p.xdmp.initcap(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('Abc'); + done(); + }).catch(done); + }); + it('xdmp.integerToHex#1', function(done) { + testPlan([p.xs.integer(123)], p.xdmp.integerToHex(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('7b'); + done(); + }).catch(done); + }); + it('xdmp.integerToOctal#1', function(done) { + testPlan([p.xs.integer(123)], p.xdmp.integerToOctal(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('173'); + done(); + }).catch(done); + }); + it('xdmp.keyFromQName#1', function(done) { + testPlan([p.xs.QName("abc")], p.xdmp.keyFromQName(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('xdmp.lshift64#2', function(done) { + testPlan([p.xs.unsignedLong(255), p.xs.long(2)], p.xdmp.lshift64(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1020'); + done(); + }).catch(done); + }); + it('xdmp.md5#1', function(done) { + testPlan([p.xs.string("abc")], p.xdmp.md5(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('900150983cd24fb0d6963f7d28e17f72'); + done(); + }).catch(done); + }); + it('xdmp.md5#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("base64")], p.xdmp.md5(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('kAFQmDzST7DWlj99KOF/cg=='); + done(); + }).catch(done); + }); + it('xdmp.monthNameFromDate#1', function(done) { + testPlan([p.xs.date("2016-01-02")], p.xdmp.monthNameFromDate(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('January'); + done(); + }).catch(done); + }); + it('xdmp.mul64#2', function(done) { + testPlan([p.xs.unsignedLong(123), p.xs.unsignedLong(456)], p.xdmp.mul64(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('56088'); + done(); + }).catch(done); + }); + it('xdmp.not64#1', function(done) { + testPlan([p.xs.unsignedLong(255)], p.xdmp.not64(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('18446744073709551360'); + done(); + }).catch(done); + }); + it('xdmp.octalToInteger#1', function(done) { + testPlan([p.xs.string("12345670")], p.xdmp.octalToInteger(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2739128'); + done(); + }).catch(done); + }); + it('xdmp.or64#2', function(done) { + testPlan([p.xs.unsignedLong(255), p.xs.unsignedLong(2)], p.xdmp.or64(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('255'); + done(); + }).catch(done); + }); + it('xdmp.position#2', function(done) { + testPlan([p.xs.string("abcdef"), p.xs.string("cd")], p.xdmp.position(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0'); + done(); + }).catch(done); + }); + it('xdmp.position#3', function(done) { + testPlan([p.xs.string("abcdef"), p.xs.string("cd"), p.xs.string("http://marklogic.com/collation/")], p.xdmp.position(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0'); + done(); + }).catch(done); + }); + it('xdmp.QNameFromKey#1', function(done) { + testPlan([p.xs.string("{http://a/b}c")], p.xdmp.QNameFromKey(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('c'); + done(); + }).catch(done); + }); + it('xdmp.quarterFromDate#1', function(done) { + testPlan([p.xs.date("2016-01-02")], p.xdmp.quarterFromDate(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xdmp.resolveUri#2', function(done) { + testPlan([p.xs.string("b?c#d"), p.xs.string("/a/x")], p.xdmp.resolveUri(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('/a/b?c#d'); + done(); + }).catch(done); + }); + it('xdmp.rshift64#2', function(done) { + testPlan([p.xs.unsignedLong(255), p.xs.long(2)], p.xdmp.rshift64(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('63'); + done(); + }).catch(done); + }); + it('xdmp.sha1#1', function(done) { + testPlan([p.xs.string("abc")], p.xdmp.sha1(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a9993e364706816aba3e25717850c26c9cd0d89d'); + done(); + }).catch(done); + }); + it('xdmp.sha1#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("base64")], p.xdmp.sha1(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('qZk+NkcGgWq6PiVxeFDCbJzQ2J0='); + done(); + }).catch(done); + }); + it('xdmp.sha256#1', function(done) { + testPlan([p.xs.string("abc")], p.xdmp.sha256(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'); + done(); + }).catch(done); + }); + it('xdmp.sha256#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("base64")], p.xdmp.sha256(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0='); + done(); + }).catch(done); + }); + it('xdmp.sha384#1', function(done) { + testPlan([p.xs.string("abc")], p.xdmp.sha384(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7'); + done(); + }).catch(done); + }); + it('xdmp.sha384#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("base64")], p.xdmp.sha384(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('ywB1P0WjXou1oD1pmsZQBycsMqsO3tFjGotgWkP/W+2AhgcroefMI1i67KE0yCWn'); + done(); + }).catch(done); + }); + it('xdmp.sha512#1', function(done) { + testPlan([p.xs.string("abc")], p.xdmp.sha512(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f'); + done(); + }).catch(done); + }); + it('xdmp.sha512#2', function(done) { + testPlan([p.xs.string("abc"), p.xs.string("base64")], p.xdmp.sha512(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('3a81oZNherrMQXNJriBBMRLm+k6JqX6iCp7u5ktV05ohkpkqJ0/BqDa6PCOj/uu9RU1EI2Q86A4qmslPpUyknw=='); + done(); + }).catch(done); + }); + it('xdmp.step64#2', function(done) { + testPlan([p.xs.unsignedLong(123), p.xs.unsignedLong(456)], p.xdmp.step64(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('8966314677'); + done(); + }).catch(done); + }); + it('xdmp.type#1', function(done) { + testPlan([p.xs.string("a")], p.xdmp.type(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('string'); + done(); + }).catch(done); + }); + it('xdmp.urlDecode#1', function(done) { + testPlan([p.xs.string("a+b")], p.xdmp.urlDecode(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a b'); + done(); + }).catch(done); + }); + it('xdmp.urlEncode#1', function(done) { + testPlan([p.xs.string("a b")], p.xdmp.urlEncode(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a+b'); + done(); + }).catch(done); + }); + it('xdmp.weekFromDate#1', function(done) { + testPlan([p.xs.date("2016-01-02")], p.xdmp.weekFromDate(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('53'); + done(); + }).catch(done); + }); + it('xdmp.weekdayFromDate#1', function(done) { + testPlan([p.xs.date("2016-01-02")], p.xdmp.weekdayFromDate(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('6'); + done(); + }).catch(done); + }); + it('xdmp.xor64#2', function(done) { + testPlan([p.xs.unsignedLong(255), p.xs.unsignedLong(2)], p.xdmp.xor64(p.col("1"), p.col("2"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('253'); + done(); + }).catch(done); + }); + it('xdmp.yeardayFromDate#1', function(done) { + testPlan([p.xs.date("2016-01-02")], p.xdmp.yeardayFromDate(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2'); + done(); + }).catch(done); + }); + it('xs.anyURI#1', function(done) { + testPlan([p.xs.string("http://a/b?c#d")], p.xs.anyURI(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('http://a/b?c#d'); + done(); + }).catch(done); + }); + it('xs.base64Binary#1', function(done) { + testPlan([p.xs.string("aGVsbG8sIHdvcmxk")], p.xs.base64Binary(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('aGVsbG8sIHdvcmxk'); + done(); + }).catch(done); + }); + it('xs.boolean#1', function(done) { + testPlan([p.xs.boolean(true)], p.xs.boolean(p.col("1"))) + .then(function(response) { + should(getResult(response).value).eql(true); + done(); + }).catch(done); + }); + it('xs.byte#1', function(done) { + testPlan([p.xs.double(1)], p.xs.byte(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.date#1', function(done) { + testPlan([p.xs.string("2016-01-02")], p.xs.date(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016-01-02'); + done(); + }).catch(done); + }); + it('xs.dateTime#1', function(done) { + testPlan([p.xs.string("2016-01-02T10:09:08Z")], p.xs.dateTime(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016-01-02T10:09:08Z'); + done(); + }).catch(done); + }); + it('xs.dayTimeDuration#1', function(done) { + testPlan([p.xs.string("P3DT4H5M6S")], p.xs.dayTimeDuration(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('P3DT4H5M6S'); + done(); + }).catch(done); + }); + it('xs.decimal#1', function(done) { + testPlan([p.xs.double(1.2)], p.xs.decimal(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.2'); + done(); + }).catch(done); + }); + it('xs.double#1', function(done) { + testPlan([p.xs.double(1.2)], p.xs.double(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.2'); + done(); + }).catch(done); + }); + it('xs.float#1', function(done) { + testPlan([p.xs.double(1)], p.xs.float(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.gDay#1', function(done) { + testPlan([p.xs.string("---02")], p.xs.gDay(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('---02'); + done(); + }).catch(done); + }); + it('xs.gMonth#1', function(done) { + testPlan([p.xs.string("--01")], p.xs.gMonth(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('--01'); + done(); + }).catch(done); + }); + it('xs.gMonthDay#1', function(done) { + testPlan([p.xs.string("--01-02")], p.xs.gMonthDay(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('--01-02'); + done(); + }).catch(done); + }); + it('xs.gYear#1', function(done) { + testPlan([p.xs.string("2016")], p.xs.gYear(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016'); + done(); + }).catch(done); + }); + it('xs.gYearMonth#1', function(done) { + testPlan([p.xs.string("2016-01")], p.xs.gYearMonth(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('2016-01'); + done(); + }).catch(done); + }); + it('xs.hexBinary#1', function(done) { + testPlan([p.xs.string("68656c6c6f2c20776f726c64")], p.xs.hexBinary(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('68656C6C6F2C20776F726C64'); + done(); + }).catch(done); + }); + it('xs.int#1', function(done) { + testPlan([p.xs.double(1)], p.xs.int(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.integer#1', function(done) { + testPlan([p.xs.double(1)], p.xs.integer(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.language#1', function(done) { + testPlan([p.xs.string("en-US")], p.xs.language(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('en-US'); + done(); + }).catch(done); + }); + it('xs.long#1', function(done) { + testPlan([p.xs.double(1)], p.xs.long(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.Name#1', function(done) { + testPlan([p.xs.string("a:b:c")], p.xs.Name(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a:b:c'); + done(); + }).catch(done); + }); + it('xs.NCName#1', function(done) { + testPlan([p.xs.string("a-b-c")], p.xs.NCName(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a-b-c'); + done(); + }).catch(done); + }); + it('xs.negativeInteger#1', function(done) { + testPlan([p.xs.double(-1)], p.xs.negativeInteger(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('-1'); + done(); + }).catch(done); + }); + it('xs.NMTOKEN#1', function(done) { + testPlan([p.xs.string("a:b:c")], p.xs.NMTOKEN(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a:b:c'); + done(); + }).catch(done); + }); + it('xs.nonNegativeInteger#1', function(done) { + testPlan([p.xs.string("0")], p.xs.nonNegativeInteger(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0'); + done(); + }).catch(done); + }); + it('xs.nonPositiveInteger#1', function(done) { + testPlan([p.xs.string("0")], p.xs.nonPositiveInteger(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('0'); + done(); + }).catch(done); + }); + it('xs.normalizedString#1', function(done) { + testPlan([p.xs.string("a b c")], p.xs.normalizedString(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a b c'); + done(); + }).catch(done); + }); + it('xs.numeric#1', function(done) { + testPlan([p.xs.double(1.2)], p.xs.numeric(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1.2'); + done(); + }).catch(done); + }); + it('xs.positiveInteger#1', function(done) { + testPlan([p.xs.double(1)], p.xs.positiveInteger(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.QName#1', function(done) { + testPlan([p.xs.string("abc")], p.xs.QName(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('xs.short#1', function(done) { + testPlan([p.xs.double(1)], p.xs.short(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.string#1', function(done) { + testPlan([p.xs.string("abc")], p.xs.string(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('xs.time#1', function(done) { + testPlan([p.xs.string("10:09:08Z")], p.xs.time(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('10:09:08Z'); + done(); + }).catch(done); + }); + it('xs.token#1', function(done) { + testPlan([p.xs.string("a b c")], p.xs.token(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('a b c'); + done(); + }).catch(done); + }); + it('xs.unsignedByte#1', function(done) { + testPlan([p.xs.double(1)], p.xs.unsignedByte(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.unsignedInt#1', function(done) { + testPlan([p.xs.double(1)], p.xs.unsignedInt(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.unsignedLong#1', function(done) { + testPlan([p.xs.double(1)], p.xs.unsignedLong(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.unsignedShort#1', function(done) { + testPlan([p.xs.double(1)], p.xs.unsignedShort(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('1'); + done(); + }).catch(done); + }); + it('xs.untypedAtomic#1', function(done) { + testPlan([p.xs.string("abc")], p.xs.untypedAtomic(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('abc'); + done(); + }).catch(done); + }); + it('xs.yearMonthDuration#1', function(done) { + testPlan([p.xs.string("P1Y2M")], p.xs.yearMonthDuration(p.col("1"))) + .then(function(response) { + should(String(getResult(response).value).replace(/^ /, '')).equal('P1Y2M'); + done(); + }).catch(done); + }); + }); + describe('expression operators', function() { + it('add#2', function(done) { + testPlan([p.xs.double(1), p.xs.double(2)], p.add(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(3); + done(); + }).catch(done); + }); + it('add#3', function(done) { + testPlan([p.xs.double(1), p.xs.double(2), p.xs.double(3)], p.add(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).equal(6); + done(); + }).catch(done); + }); + it('and#2', function(done) { + testPlan([p.xs.boolean(true), p.xs.boolean(true)], p.and(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('and#3', function(done) { + testPlan([p.xs.boolean(true), p.xs.boolean(true), p.xs.boolean(true)], p.and(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('divide#2', function(done) { + testPlan([p.xs.double(6), p.xs.double(2)], p.divide(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(3); + done(); + }).catch(done); + }); + it('eq#2', function(done) { + testPlan([p.xs.double(1), p.xs.double(1)], p.eq(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('ge#2', function(done) { + testPlan([p.xs.double(1), p.xs.double(1)], p.ge(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('gt#2', function(done) { + testPlan([p.xs.double(2), p.xs.double(1)], p.gt(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('le#2', function(done) { + testPlan([p.xs.double(1), p.xs.double(1)], p.le(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('lt#2', function(done) { + testPlan([p.xs.double(1), p.xs.double(2)], p.lt(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('multiply#2', function(done) { + testPlan([p.xs.double(2), p.xs.double(3)], p.multiply(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(6); + done(); + }).catch(done); + }); + it('multiply#3', function(done) { + testPlan([p.xs.double(2), p.xs.double(3), p.xs.double(4)], p.multiply(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).equal(24); + done(); + }).catch(done); + }); + it('ne#2', function(done) { + testPlan([p.xs.double(1), p.xs.double(2)], p.ne(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('not#1', function(done) { + testPlan([p.xs.boolean(false)], p.not(p.col("1"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('or#2', function(done) { + testPlan([p.xs.boolean(false), p.xs.boolean(true)], p.or(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('or#3', function(done) { + testPlan([p.xs.boolean(false), p.xs.boolean(true), p.xs.boolean(false)], p.or(p.col("1"), p.col("2"), p.col("3"))) + .then(function(response) { + should(getResult(response).value).equal(true); + done(); + }).catch(done); + }); + it('subtract#2', function(done) { + testPlan([p.xs.double(3), p.xs.double(2)], p.subtract(p.col("1"), p.col("2"))) + .then(function(response) { + should(getResult(response).value).equal(1); + done(); + }).catch(done); + }); + }); +}); diff --git a/test-basic/plan-composers.js b/test-basic/plan-composers.js new file mode 100644 index 00000000..210d4e10 --- /dev/null +++ b/test-basic/plan-composers.js @@ -0,0 +1,299 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; + +describe('composers', function() { + describe('for literals', function() { + it('with inner join', function(done) { + execPlan( + p.fromLiterals([ + {masterId:1, masterVal:'A'}, + {masterId:2, masterVal:'B'}, + {masterId:3, masterVal:'C'} + ]) + .joinInner( + p.fromLiterals([ + {detailId:1, masterId:1, detailVal:'a'}, + {detailId:2, masterId:1, detailVal:'b'}, + {detailId:3, masterId:3, detailVal:'c'}, + {detailId:4, masterId:4, detailVal:'d'} + ]) + ) + .orderBy(['masterId', 'detailId']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].masterId.value).equal(1); + should(output[0].masterVal.value).equal('A'); + should(output[0].detailId.value).equal(1); + should(output[0].detailVal.value).equal('a'); + should(output[1].masterId.value).equal(1); + should(output[1].masterVal.value).equal('A'); + should(output[1].detailId.value).equal(2); + should(output[1].detailVal.value).equal('b'); + should(output[2].masterId.value).equal(3); + should(output[2].masterVal.value).equal('C'); + should(output[2].detailId.value).equal(3); + should(output[2].detailVal.value).equal('c'); + done(); + }) + .catch(done); + }); + it('with left join', function(done) { + execPlan( + p.fromLiterals([ + {masterId:1, masterVal:'A'}, + {masterId:2, masterVal:'B'}, + {masterId:3, masterVal:'C'} + ]) + .joinLeftOuter( + p.fromLiterals([ + {detailId:1, masterId:1, detailVal:'a'}, + {detailId:2, masterId:1, detailVal:'b'}, + {detailId:3, masterId:3, detailVal:'c'}, + {detailId:4, masterId:4, detailVal:'d'} + ]) + ) + .orderBy(['masterId', 'detailId']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(4); + should(output[0].masterId.value).equal(1); + should(output[0].masterVal.value).equal('A'); + should(output[0].detailId.value).equal(1); + should(output[0].detailVal.value).equal('a'); + should(output[1].masterId.value).equal(1); + should(output[1].masterVal.value).equal('A'); + should(output[1].detailId.value).equal(2); + should(output[1].detailVal.value).equal('b'); + should(output[2].masterId.value).equal(2); + should(output[2].masterVal.value).equal('B'); + should(output[2].detailId.value).equal(null); + should(output[2].detailVal.value).equal(null); + should(output[3].masterId.value).equal(3); + should(output[3].masterVal.value).equal('C'); + should(output[3].detailId.value).equal(3); + should(output[3].detailVal.value).equal('c'); + done(); + }) + .catch(done); + }); + it('with key matches on inner join', function(done) { + execPlan( + p.fromLiterals([ + {primaryKey:1, masterVal:'A'}, + {primaryKey:2, masterVal:'B'}, + {primaryKey:3, masterVal:'C'} + ]) + .joinInner( + p.fromLiterals([ + {detailId:1, foreignKey:1, detailVal:'a'}, + {detailId:2, foreignKey:1, detailVal:'b'}, + {detailId:3, foreignKey:3, detailVal:'c'}, + {detailId:4, foreignKey:4, detailVal:'d'} + ]), + p.on('primaryKey', 'foreignKey') + ) + .orderBy(['primaryKey', 'detailId']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].primaryKey.value).equal(1); + should(output[0].foreignKey.value).equal(1); + should(output[0].masterVal.value).equal('A'); + should(output[0].detailId.value).equal(1); + should(output[0].detailVal.value).equal('a'); + should(output[1].primaryKey.value).equal(1); + should(output[1].foreignKey.value).equal(1); + should(output[1].masterVal.value).equal('A'); + should(output[1].detailId.value).equal(2); + should(output[1].detailVal.value).equal('b'); + should(output[2].primaryKey.value).equal(3); + should(output[2].foreignKey.value).equal(3); + should(output[2].masterVal.value).equal('C'); + should(output[2].detailId.value).equal(3); + should(output[2].detailVal.value).equal('c'); + done(); + }) + .catch(done); + }); + it('with condition on left join', function(done) { + execPlan( + p.fromLiterals([ + {masterId:1, masterVal:'A'}, + {masterId:2, masterVal:'B'}, + {masterId:3, masterVal:'C'} + ]) + .joinLeftOuter( + p.fromLiterals([ + {detailId:1, masterId:1, detailVal:'a'}, + {detailId:2, masterId:1, detailVal:'b'}, + {detailId:3, masterId:3, detailVal:'c'}, + {detailId:4, masterId:4, detailVal:'d'} + ]), + null, + p.eq(p.col('detailVal'), 'b') + ) + .orderBy(['masterId', 'detailId']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].masterId.value).equal(1); + should(output[0].masterVal.value).equal('A'); + should(output[0].detailId.value).equal(2); + should(output[0].detailVal.value).equal('b'); + should(output[1].masterId.value).equal(2); + should(output[1].masterVal.value).equal('B'); + should(output[1].detailId.value).equal(null); + should(output[1].detailVal.value).equal(null); + should(output[2].masterId.value).equal(3); + should(output[2].masterVal.value).equal('C'); + should(output[2].detailId.value).equal(null); + should(output[2].detailVal.value).equal(null); + done(); + }) + .catch(done); + }); + it('with cross product join', function(done) { + execPlan( + p.fromLiterals([ + {masterId:1, masterVal:'A'}, + {masterId:2, masterVal:'B'} + ]) + .joinCrossProduct( + p.fromLiterals([ + {detailId:1, detailVal:'a'}, + {detailId:2, detailVal:'b'} + ]) + ) + .orderBy(['masterId', 'detailId']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(4); + should(output[0].masterId.value).equal(1); + should(output[0].masterVal.value).equal('A'); + should(output[0].detailId.value).equal(1); + should(output[0].detailVal.value).equal('a'); + should(output[1].masterId.value).equal(1); + should(output[1].masterVal.value).equal('A'); + should(output[1].detailId.value).equal(2); + should(output[1].detailVal.value).equal('b'); + should(output[2].masterId.value).equal(2); + should(output[2].masterVal.value).equal('B'); + should(output[2].detailId.value).equal(1); + should(output[2].detailVal.value).equal('a'); + should(output[3].masterId.value).equal(2); + should(output[3].masterVal.value).equal('B'); + should(output[3].detailId.value).equal(2); + should(output[3].detailVal.value).equal('b'); + done(); + }) + .catch(done); + }); + it('with union', function(done) { + execPlan( + p.fromLiterals([ + {id:1, val:'a'}, + {id:3, val:'c'} + ]) + .union( + p.fromLiterals([ + {id:2, val:'b'}, + {id:4, val:'d'} + ]) + ) + .orderBy('id') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(4); + should(output[0].id.value).equal(1); + should(output[0].val.value).equal('a'); + should(output[1].id.value).equal(2); + should(output[1].val.value).equal('b'); + should(output[2].id.value).equal(3); + should(output[2].val.value).equal('c'); + should(output[3].id.value).equal(4); + should(output[3].val.value).equal('d'); + done(); + }) + .catch(done); + }); + it('with intersect', function(done) { + execPlan( + p.fromLiterals([ + {val:'a', id:1}, + {val:'b', id:2}, + {val:'x', id:3} + ]) + .intersect( + p.fromLiterals([ + {id:1, val:'x'}, + {id:2, val:'b'}, + {id:3, val:'c'} + ]) + ) + .orderBy('id') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].id.value).equal(2); + should(output[0].val.value).equal('b'); + done(); + }) + .catch(done); + }); + it('with except', function(done) { + execPlan( + p.fromLiterals([ + {val:'a', id:1}, + {val:'b', id:2} + ]) + .except( + p.fromLiterals([ + {id:1, val:'a'}, + {id:2, val:'x'}, + {id:3, val:'c'} + ]) + ) + .orderBy('id') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].id.value).equal(2); + should(output[0].val.value).equal('b'); + done(); + }) + .catch(done); + }); + }); +}); diff --git a/test-basic/plan-documents.js b/test-basic/plan-documents.js new file mode 100644 index 00000000..f875864a --- /dev/null +++ b/test-basic/plan-documents.js @@ -0,0 +1,156 @@ +/* + * Copyright 2016-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; + +describe('documents', function() { + const runnerMod = '/ext/optic/querytester.sjs'; + describe('join uri', function() { + it('with fragment id', function(done) { + execPlan( + p.fromView('opticUnitTest', 'musician', null, p.fragmentIdCol('musicianDocId')) + .orderBy(p.desc('lastName')) + .limit(2) + .joinDocUri('musicianDocUri', p.fragmentIdCol('musicianDocId')) + .orderBy(p.desc('lastName')) + .select(null, '') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].lastName.value).equal('Davis'); + should(output[0].firstName.value).equal('Miles'); + should(output[0].musicianDocUri.value).equal('/optic/test/musician4.json'); + should(output[1].lastName.value).equal('Coltrane'); + should(output[1].firstName.value).equal('John'); + should(output[1].musicianDocUri.value).equal('/optic/test/musician3.json'); + done(); + }) + .catch(done); + }); + }); + describe('join content', function() { + it('with fragment id', function(done) { + execPlan( + p.fromView('opticUnitTest', 'musician', null, p.fragmentIdCol('musicianDocId')) + .orderBy(p.desc('lastName')) + .limit(2) + .joinDoc('musicianDoc', p.fragmentIdCol('musicianDocId')) + .orderBy(p.desc('lastName')) + .select(null, '') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].lastName.value).equal('Davis'); + should(output[0].firstName.value).equal('Miles'); + should(output[0].musicianDoc.value.musician.instrument.length).equal(1); + should(output[0].musicianDoc.value.musician.instrument[0]).equal('trumpet'); + should(output[1].lastName.value).equal('Coltrane'); + should(output[1].firstName.value).equal('John'); + should(output[1].musicianDoc.value.musician.instrument.length).equal(1); + should(output[1].musicianDoc.value.musician.instrument[0]).equal('saxophone'); + done(); + }) + .catch(done); + }); + it('with xpath', function(done) { + execPlan( + p.fromView('opticUnitTest', 'musician', null, p.fragmentIdCol('musicianDocId')) + .orderBy(p.desc('lastName')) + .limit(2) + .joinDoc('musicianDoc', p.fragmentIdCol('musicianDocId')) + .orderBy(p.desc('lastName')) + .select(['lastName', 'firstName', p.as('nodes', p.xpath('musicianDoc', '/musician/(dob|instrument)'))], '') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].lastName.value).equal('Davis'); + should(output[0].firstName.value).equal('Miles'); + should(output[0].nodes.value.length).equal(2); + should(output[0].nodes.value[0]).equal('1926-05-26'); + should(output[0].nodes.value[1]).equal('trumpet'); + should(output[1].lastName.value).equal('Coltrane'); + should(output[1].firstName.value).equal('John'); + should(output[1].nodes.value.length).equal(2); + should(output[1].nodes.value[0]).equal('1926-09-23'); + should(output[1].nodes.value[1]).equal('saxophone'); + done(); + }) + .catch(done); + }); + it('with collections', function(done) { + execPlan( + p.fromView('opticUnitTest', 'musician', null, p.fragmentIdCol('musicianDocId')) + .orderBy(p.desc('lastName')) + .limit(2) + .joinDoc('musicianDoc', p.fragmentIdCol('musicianDocId')) + .orderBy(p.desc('lastName')) + .select(['lastName', 'firstName', p.as('tag', p.xdmp.nodeCollections(p.col('musicianDoc')))], '') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].lastName.value).equal('Davis'); + should(output[0].firstName.value).equal('Miles'); + should(output[0].tag.value).containEql('/optic/test'); + should(output[0].tag.value).containEql('/optic/music'); + should(output[1].lastName.value).equal('Coltrane'); + should(output[1].firstName.value).equal('John'); + should(output[1].tag.value).containEql('/optic/test'); + should(output[1].tag.value).containEql('/optic/music'); + done(); + }) + .catch(done); + }); + it('with document uri', function(done) { + execPlan( + p.fromLiterals([ + {id:1, val: 2, musicianDocUri:'/optic/test/musician4.json'}, + {id:2, val: 4, musicianDocUri:'/optic/test/not/a/real/doc.nada'}, + {id:3, val: 6, musicianDocUri:'/optic/test/musician3.json'} + ]) + .joinDoc('musicianDoc', p.col('musicianDocUri')) + .orderBy('id') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(1); + should(output[0].val.value).equal(2); + should(output[0].musicianDocUri.value).equal('/optic/test/musician4.json'); + should(output[0].musicianDoc.value.musician.lastName).equal('Davis'); + should(output[0].musicianDoc.value.musician.firstName).equal('Miles'); + should(output[1].id.value).equal(3); + should(output[1].val.value).equal(6); + should(output[1].musicianDocUri.value).equal('/optic/test/musician3.json'); + should(output[1].musicianDoc.value.musician.lastName).equal('Coltrane'); + should(output[1].musicianDoc.value.musician.firstName).equal('John'); + done(); + }) + .catch(done); + }); + }); +}); diff --git a/test-basic/plan-expressions.js b/test-basic/plan-expressions.js new file mode 100644 index 00000000..c0bd1c12 --- /dev/null +++ b/test-basic/plan-expressions.js @@ -0,0 +1,457 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; +const makeSelectCall = pbb.makeSelectCall; +const makeSelectExport = pbb.makeSelectExport; + +describe('expressions', function() { + it('col() identifier', function(done) { + const value = + makeSelectCall(p.col('val')).export(); + should(value).deepEqual( + makeSelectExport( + {ns:'op', fn:'col', args:['val']} + )); + done(); + }); + it('viewCol() identifier', function(done) { + const value = + makeSelectCall(p.viewCol('docview', 'val')).export(); + should(value).deepEqual( + makeSelectExport( + {ns:'op', fn:'view-col', args:['docview', 'val']} + )); + done(); + }); + it('schemaCol() identifier', function(done) { + const value = + makeSelectCall(p.schemaCol('docschema', 'docview', 'val')).export(); + should(value).deepEqual( + makeSelectExport( + {ns:'op', fn:'schema-col', args:['docschema', 'docview', 'val']} + )); + done(); + }); + it('positional eq with or', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where(p.or(p.eq(p.col('str'), 'two'), p.eq(p.col('num'), 1))) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].num.value).equal(1); + should(output[0].str.value).equal('one'); + should(output[1].row.value).equal(2); + should(output[1].num.value).equal(2); + should(output[1].str.value).equal('two'); + done(); + }) + .catch(done); + }); + it('named eq with or', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where(p.or({ + left: p.eq({left:p.col('str'), right:'two'}), + right: p.eq({left:p.col('num'), right:1 }) + })) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].num.value).equal(1); + should(output[0].str.value).equal('one'); + should(output[1].row.value).equal(2); + should(output[1].num.value).equal(2); + should(output[1].str.value).equal('two'); + done(); + }) + .catch(done); + }); + it('ne with and', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where(p.and(p.ne(p.col('str'), 'two'), p.ne(p.col('num'), 1))) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].row.value).equal(3); + should(output[0].num.value).equal(3); + should(output[0].str.value).equal('three'); + done(); + }) + .catch(done); + }); + it('gt or lt', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where(p.or(p.gt(p.col('num'), 2), p.lt(p.col('num'), 2))) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].num.value).equal(1); + should(output[0].str.value).equal('one'); + should(output[1].row.value).equal(3); + should(output[1].num.value).equal(3); + should(output[1].str.value).equal('three'); + done(); + }) + .catch(done); + }); + it('ge and le', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where(p.and(p.ge(p.col('num'), 2), p.le(p.col('num'), 2))) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].row.value).equal(2); + should(output[0].num.value).equal(2); + should(output[0].str.value).equal('two'); + done(); + }) + .catch(done); + }); + it('not', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where(p.not(p.eq(p.col('num'), 1))) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(2); + should(output[0].num.value).equal(2); + should(output[0].str.value).equal('two'); + should(output[1].row.value).equal(3); + should(output[1].num.value).equal(3); + should(output[1].str.value).equal('three'); + done(); + }) + .catch(done); + }); + it('nested', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where( + p.or( + p.and( + p.or( + p.and(p.ge(p.col('num'), 2), p.le(p.col('num'), 2)), + p.lt(p.col('num'), 1) + ), + p.or( + p.and(p.gt(p.col('num'), 1), p.lt(p.col('num'), 3)), + p.gt(p.col('num'), 3) + ) + ), + p.and(p.gt(p.col('num'), 2), p.lt(p.col('num'), 2)) + ) + ) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].row.value).equal(2); + should(output[0].num.value).equal(2); + should(output[0].str.value).equal('two'); + done(); + }) + .catch(done); + }); + it('concat', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'} + ]) + .where(p.eq(p.fn.concat(p.col('num'), 1), '11')) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].row.value).equal(1); + should(output[0].num.value).equal(1); + should(output[0].str.value).equal('one'); + done(); + }) + .catch(done); + }); + it('add or subtract', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where(p.or(p.eq(p.add(p.col('num'), 1), 2), p.eq(p.subtract(3, p.col('num')), 2))) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].row.value).equal(1); + should(output[0].num.value).equal(1); + should(output[0].str.value).equal('one'); + done(); + }) + .catch(done); + }); + it('multiply or divide', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where(p.and(p.eq(p.multiply(p.col('num'), 1), 2), p.eq(p.divide(4, p.col('num')), 2))) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].row.value).equal(2); + should(output[0].num.value).equal(2); + should(output[0].str.value).equal('two'); + done(); + }) + .catch(done); + }); + it('modulo', function(done) { + execPlan( + p.fromLiterals([ + {row:1, num:1, str:'one'}, + {row:2, num:2, str:'two'}, + {row:3, num:3, str:'three'} + ]) + .where(p.eq(p.modulo(4, p.col('num')), 1)) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].row.value).equal(3); + should(output[0].num.value).equal(3); + should(output[0].str.value).equal('three'); + done(); + }) + .catch(done); + }); + it('with as', function(done) { + execPlan( + p.fromLiterals([ + {row:1, low:4, high:8}, + {row:2, low:3, high:6}, + {row:3, low:2, high:4} + ]) + .select([ + p.as(p.col('added'), p.add(p.col('low'), p.col('high'))), + p.as('subtracted', p.subtract(p.col('high'), p.col('low'))), + p.as('compared', p.eq(p.col('low'), 3)), + p.as('concatted', p.fn.concat(p.col('low'), p.col('high'))) + ]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].added.value).equal(12); + should(output[0].subtracted.value).equal(4); + should(output[0].compared.value).equal(false); + should(output[0].concatted.value).equal('48'); + should(output[1].added.value).equal(9); + should(output[1].subtracted.value).equal(3); + should(output[1].compared.value).equal(true); + should(output[1].concatted.value).equal('36'); + should(output[2].added.value).equal(6); + should(output[2].subtracted.value).equal(2); + should(output[2].compared.value).equal(false); + should(output[2].concatted.value).equal('24'); + done(); + }) + .catch(done); + }); + it('with if', function(done) { + execPlan( + p.fromLiterals([ + {row:1, val:8}, + {row:2, val:6}, + {row:3, val:4} + ]) + .select(['row', + p.as('iffed', p.sem.if(p.eq(p.col('row'), 2), 'even', 'odd')) + ]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].row.value).equal(1); + should(output[0].iffed.value).equal('odd'); + should(output[1].row.value).equal(2); + should(output[1].iffed.value).equal('even'); + should(output[2].row.value).equal(3); + should(output[2].iffed.value).equal('odd'); + done(); + }) + .catch(done); + }); + it('with case', function(done) { + execPlan( + p.fromLiterals([ + {row:1, val:8}, + {row:2, val:6}, + {row:3, val:4} + ]) + .select(['row', p.as('cased', p.case( + [p.when(p.eq(p.col('row'), 2), 'second'), + p.when(p.eq(p.col('row'), 3), 'third')], + 'otherwise' + ))]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].row.value).equal(1); + should(output[0].cased.value).equal('otherwise'); + should(output[1].row.value).equal(2); + should(output[1].cased.value).equal('second'); + should(output[2].row.value).equal(3); + should(output[2].cased.value).equal('third'); + done(); + }) + .catch(done); + }); + it('with isDefined', function(done) { + execPlan( + p.fromLiterals([ + {row:1, sparse:6}, + {row:2}, + {row:3, sparse:4} + ]) + .select(['row', 'sparse', + p.as('defcheck', p.sem.if(p.isDefined(p.col('sparse')), 'present', 'absent')) + ]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].row.value).equal(1); + should(output[0].sparse.value).equal(6); + should(output[0].defcheck.value).equal('present'); + should(output[1].row.value).equal(2); + should(output[1].sparse.value).equal(null); + should(output[1].defcheck.value).equal('absent'); + should(output[2].row.value).equal(3); + should(output[2].sparse.value).equal(4); + should(output[2].defcheck.value).equal('present'); + done(); + }) + .catch(done); + }); + it('positional builtin function with array', function(done) { + execPlan( + p.fromLiterals([ + {row:1, one:'a', two:'b', three:'c'}, + {row:2, one:'b', two:'c', three:'a'}, + {row:3, one:'c', two:'a', three:'b'} + ]) + .select(['row', p.as('pos', p.fn.indexOf([p.col('one'), p.col('two'), p.col('three')], 'b'))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].row.value).equal(1); + should(output[0].pos.value).equal(2); + should(output[1].row.value).equal(2); + should(output[1].pos.value).equal(1); + should(output[2].row.value).equal(3); + should(output[2].pos.value).equal(3); + done(); + }) + .catch(done); + }); + it('named builtin function with array', function(done) { + execPlan( + p.fromLiterals([ + {row:1, one:'a', two:'b', three:'c'}, + {row:2, one:'b', two:'c', three:'a'}, + {row:3, one:'c', two:'a', three:'b'} + ]) + .select(['row', p.as('pos', p.fn.indexOf({ + seqParam: [p.col('one'), p.col('two'), p.col('three')], + srchParam: 'b' + }))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].row.value).equal(1); + should(output[0].pos.value).equal(2); + should(output[1].row.value).equal(2); + should(output[1].pos.value).equal(1); + should(output[2].row.value).equal(3); + should(output[2].pos.value).equal(3); + done(); + }) + .catch(done); + }); +}); diff --git a/test-basic/plan-lexicons.js b/test-basic/plan-lexicons.js new file mode 100644 index 00000000..85318e95 --- /dev/null +++ b/test-basic/plan-lexicons.js @@ -0,0 +1,186 @@ +/* + * Copyright 2016-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; + +describe('lexicons', function() { + const exportedLexicon = + {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-lexicons', args:[{ + uri:{ns:'cts', fn:'uri-reference', args:[]}, + number:{ns:'cts', fn:'json-property-reference', args:['srchNumber']}, + city:{ns:'cts', fn:'json-property-reference', args:['srchCity']} + }, + 'docRange']} + ]}}; + it('on access', function(done) { + execPlan( + p.fromLexicons({ + uri:p.cts.uriReference(), + number:p.cts.jsonPropertyReference('srchNumber'), + level:p.cts.jsonPropertyReference('srchLevel'), + city:p.cts.jsonPropertyReference('srchCity') + }) + .orderBy('number') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].uri.value).equal('/optic/test/queryDoc3.json'); + should(output[0].number.value).equal(1); + should(output[0].level.value).equal(10); + should(output[0].city.value).equal('Bonn'); + should(output[1].uri.value).equal('/optic/test/queryDoc1.json'); + should(output[1].number.value).equal(2); + should(output[1].level.value).equal(20); + should(output[1].city.value).equal('Cairo'); + should(output[2].uri.value).equal('/optic/test/queryDoc2.json'); + should(output[2].number.value).equal(3); + should(output[2].level.value).equal(30); + should(output[2].city.value).equal('Antioch'); + done(); + }) + .catch(done); + }); + it('with fragment id column', function(done) { + execPlan( + p.fromLexicons({ + uri: p.cts.uriReference(), + number: p.cts.jsonPropertyReference('srchNumber') + }, + null, + p.fragmentIdCol('sourceDocId')) + .orderBy('number') + .select(['uri', 'number', 'sourceDocId', + p.as('sourceDocCheck', p.isDefined(p.col('sourceDocId')))]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].uri.value).equal('/optic/test/queryDoc3.json'); + should(output[0].number.value).equal(1); + should(output[0].sourceDocCheck.value).equal(true); + should.not.exist(output[0].srcDocId); + should(output[1].uri.value).equal('/optic/test/queryDoc1.json'); + should(output[1].number.value).equal(2); + should(output[1].sourceDocCheck.value).equal(true); + should.not.exist(output[1].srcDocId); + should(output[2].uri.value).equal('/optic/test/queryDoc2.json'); + should(output[2].number.value).equal(3); + should(output[2].sourceDocCheck.value).equal(true); + should.not.exist(output[2].srcDocId); + done(); + }) + .catch(done); + }); + it('having col method', function(done) { + const accessor = p.fromLexicons({ + uri:p.cts.uriReference(), + number:p.cts.jsonPropertyReference('srchNumber') + }, + 'urinum'); + const colPlan = accessor.select(accessor.col('number')); + const value = colPlan.export(); + should(value.$optic.args.length).equal(2); + should(value.$optic.args[1].args.length).equal(1); + should(value.$optic.args[1].args[0]).deepEqual( + {ns:'op', fn:'view-col', args:['urinum', 'number']} + ); + execPlan( + colPlan + .orderBy(accessor.col('number')) + .limit(2) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0]['urinum.number'].value).equal(1); + should.not.exist(output[0]['urinum.uri']); + should(output[1]['urinum.number'].value).equal(2); + should.not.exist(output[1]['urinum.uri']); + done(); + }) + .catch(done); + }); + it('with nullable column', function(done) { + execPlan( + p.fromLexicons({ + uri:p.cts.uriReference(), + number:p.cts.jsonPropertyReference('srchNumber', 'nullable') + }) + .where(p.cts.directoryQuery('/optic/test/')) + .orderBy('uri') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(13); + for (let i=0; i < 9; i++) { + should(output[i].number.value).equal(null); + } + should(output[9].uri.value).equal('/optic/test/queryDoc1.json'); + should(output[9].number.value).equal(2); + should(output[10].uri.value).equal('/optic/test/queryDoc2.json'); + should(output[10].number.value).equal(3); + should(output[11].uri.value).equal('/optic/test/queryDoc3.json'); + should(output[11].number.value).equal(1); + should(output[12].number.value).equal(null); + done(); + }) + .catch(done); + }); + it('with query', function(done) { + execPlan( + p.fromLexicons({ + uri:p.cts.uriReference(), + number:p.cts.jsonPropertyReference('srchNumber', 'nullable') + }) + .where(p.cts.jsonPropertyWordQuery('srchColA', 'common')) + .orderBy('uri') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].uri.value).equal('/optic/test/queryDoc1.json'); + should(output[0].number.value).equal(2); + should(output[1].uri.value).equal('/optic/test/queryDoc2.json'); + should(output[1].number.value).equal(3); + done(); + }) + .catch(done); + }); + describe('serialize', function() { + it('on export', function(done) { + const value = + p.fromLexicons({ + uri:p.cts.uriReference(), + number:p.cts.jsonPropertyReference('srchNumber'), + city:p.cts.jsonPropertyReference('srchCity') + }, + 'docRange') + .export(); + should(value).deepEqual(exportedLexicon); + done(); + }); + }); +}); diff --git a/test-basic/plan-literals.js b/test-basic/plan-literals.js new file mode 100644 index 00000000..e82b01c1 --- /dev/null +++ b/test-basic/plan-literals.js @@ -0,0 +1,94 @@ +/* + * Copyright 2016-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; + +describe('literals', function() { + const runnerMod = '/ext/optic/querytester.sjs'; + describe('accessor', function() { + it('as objects', function(done) { + execPlan( + p.fromLiterals([ + {orderId: 1, orderExtra: 'First extra'}, + {orderId: 2, orderExtra: 'Second extra'} + ], + 'lit') + ) + .then(function(response) { + const output = getResults(response); + should(output[0]['lit.orderId'].value).equal(1); + should(output[0]['lit.orderExtra'].value).equal('First extra'); + should(output[1]['lit.orderId'].value).equal(2); + should(output[1]['lit.orderExtra'].value).equal('Second extra'); + done(); + }) + .catch(done); + }); + it('as arrays', function(done) { + execPlan( + p.fromLiterals({ + columnNames: ['orderId', 'orderExtra'], + rowValues: [ + [1, 'First extra'], + [2, 'Second extra'] + ] + }) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].orderId.value).equal(1); + should(output[0].orderExtra.value).equal('First extra'); + should(output[1].orderId.value).equal(2); + should(output[1].orderExtra.value).equal('Second extra'); + done(); + }) + .catch(done); + }); + it('having col method', function(done) { + const accessor = p.fromLiterals([ + {orderId: 1, orderExtra: 'First extra'} + ], + 'lit'); + const colPlan = accessor.select(accessor.col('orderId')); + const value = colPlan.export(); + should(value.$optic.args.length).equal(2); + should(value.$optic.args[1].args.length).equal(1); + should(value.$optic.args[1].args[0]).deepEqual( + {ns:'op', fn:'view-col', args:['lit', 'orderId']} + ); + execPlan( + colPlan + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0]['lit.orderId'].value).equal(1); + done(); + }) + .catch(done); + }); + }); + // see other unit tests for other operations on literals +}); diff --git a/test-basic/plan-modifiers.js b/test-basic/plan-modifiers.js new file mode 100644 index 00000000..1dbafa3d --- /dev/null +++ b/test-basic/plan-modifiers.js @@ -0,0 +1,462 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; + +describe('modifier', function() { + describe('for literals', function() { + it('with where', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Master 1', date:'2015-12-01'}, + {id:2, name:'Master 2', date:'2015-12-02'} + ]) + .where(p.eq(p.col('id'),1)) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].id.value).equal(1); + should(output[0].name.value).equal('Master 1'); + should(output[0].date.value).equal('2015-12-01'); + done(); + }).catch(done); + }); + it('with column where', function(done) { + execPlan( + p.fromLiterals([ + {id:1, condition:true}, + {id:2, condition:false} + ]) + .where(p.col('condition')) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].id.value).equal(1); + should(output[0].condition.value).equal(true); + done(); + }) + .catch(done); + }); + it('with SQL condition where', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Master 1', date:'2015-12-01'}, + {id:2, name:'Master 2', date:'2015-12-02'} + ]) + .where(p.sqlCondition('id BETWEEN 0.5 AND 1.5')) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].id.value).equal(1); + should(output[0].name.value).equal('Master 1'); + should(output[0].date.value).equal('2015-12-01'); + done(); + }) + .catch(done); + }); + it('with whereDistinct', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Detail 1', masterId:1, amount:10.01, color:'blue'}, + {id:2, name:'Detail 2', masterId:2, amount:20.02, color:'blue'}, + {id:3, name:'Detail 3', masterId:1, amount:30.03, color:'blue'}, + {id:4, name:'Detail 4', masterId:2, amount:40.04, color:'green'}, + {id:5, name:'Detail 5', masterId:1, amount:50.05, color:'green'}, + {id:6, name:'Detail 6', masterId:2, amount:60.06, color:'green'} + ]) + .select('color') + .whereDistinct() + .orderBy('color') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].color.value).equal('blue'); + should(output[1].color.value).equal('green'); + done(); + }) + .catch(done); + }); + it('with select', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Master 1', date:'2015-12-01'}, + {id:2, name:'Master 2', date:'2015-12-02'} + ]) + .select(['id', 'name']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(1); + should(output[0].name.value).equal('Master 1'); + should(output[0].date).equal(void 0); + should(output[1].id.value).equal(2); + should(output[1].name.value).equal('Master 2'); + should(output[1].date).equal(void 0); + done(); + }) + .catch(done); + }); + it('with qualified select', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Master 1', date:'2015-12-01'}, + {id:2, name:'Master 2', date:'2015-12-02'} + ]) + .select(['id', 'name'], 'selqual') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0]['selqual.id'].value).equal(1); + should(output[0]['selqual.name'].value).equal('Master 1'); + should(output[0]['selqual.date']).equal(void 0); + should(output[1]['selqual.id'].value).equal(2); + should(output[1]['selqual.name'].value).equal('Master 2'); + should(output[1]['selqual.date']).equal(void 0); + done(); + }) + .catch(done); + }); + it('with orderBy', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Detail 1', masterId:1, amount:10.01, color:'blue'}, + {id:2, name:'Detail 2', masterId:2, amount:20.02, color:'blue'}, + {id:3, name:'Detail 3', masterId:1, amount:30.03, color:'blue'}, + {id:4, name:'Detail 4', masterId:2, amount:40.04, color:'green'}, + {id:5, name:'Detail 5', masterId:1, amount:50.05, color:'green'}, + {id:6, name:'Detail 6', masterId:2, amount:60.06, color:'green'} + ]) + .orderBy(['masterId', 'id']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(6); + should(output[0].id.value).equal(1); + should(output[0].masterId.value).equal(1); + should(output[1].id.value).equal(3); + should(output[1].masterId.value).equal(1); + should(output[2].id.value).equal(5); + should(output[2].masterId.value).equal(1); + should(output[3].id.value).equal(2); + should(output[3].masterId.value).equal(2); + should(output[4].id.value).equal(4); + should(output[4].masterId.value).equal(2); + should(output[5].id.value).equal(6); + should(output[5].masterId.value).equal(2); + done(); + }) + .catch(done); + }); + it('with groupBy on key', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Detail 1', masterId:1, amount:10.01, color:'blue'}, + {id:2, name:'Detail 2', masterId:2, amount:20.02, color:'blue'}, + {id:3, name:'Detail 3', masterId:1, amount:30.03, color:'blue'}, + {id:4, name:'Detail 4', masterId:2, amount:40.04, color:'green'}, + {id:5, name:'Detail 5', masterId:1, amount:50.05, color:'green'}, + {id:6, name:'Detail 6', masterId:2, amount:60.06, color:'green'} + ]) + .groupBy('masterId', [p.count('detailCount', 'id'), p.sum('detailSum', 'id')]) + .orderBy(['masterId']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].masterId.value).equal(1); + should(output[0].detailCount.value).equal(3); + should(output[0].detailSum.value).equal(9); + should(output[1].masterId.value).equal(2); + should(output[1].detailCount.value).equal(3); + should(output[1].detailSum.value).equal(12); + done(); + }) + .catch(done); + }); + it('with groupBy over all', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Detail 1', masterId:1, amount:10.01, color:'blue'}, + {id:2, name:'Detail 2', masterId:2, amount:20.02, color:'blue'}, + {id:3, name:'Detail 3', masterId:1, amount:30.03, color:'blue'}, + {id:4, name:'Detail 4', masterId:2, amount:40.04, color:'green'}, + {id:5, name:'Detail 5', masterId:1, amount:50.05, color:'green'}, + {id:6, name:'Detail 6', masterId:2, amount:60.06, color:'green'} + ]) + .groupBy(null, [p.count('detailCount', 'id'), p.sum('detailSum', 'id')]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].detailCount.value).equal(6); + should(output[0].detailSum.value).equal(21); + done(); + }) + .catch(done); + }); + it('with offsetLimit', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Detail 1', masterId:1, amount:10.01, color:'blue'}, + {id:2, name:'Detail 2', masterId:2, amount:20.02, color:'blue'}, + {id:3, name:'Detail 3', masterId:1, amount:30.03, color:'blue'}, + {id:4, name:'Detail 4', masterId:2, amount:40.04, color:'green'}, + ]) + .orderBy('id') + .offsetLimit(1, 2) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(2); + should(output[0].masterId.value).equal(2); + should(output[1].id.value).equal(3); + should(output[1].masterId.value).equal(1); + done(); + }) + .catch(done); + }); + it('with offset', function(done) { + execPlan( + p.fromLiterals([ + {id:1, name:'Detail 1', masterId:1, amount:10.01, color:'blue'}, + {id:2, name:'Detail 2', masterId:2, amount:20.02, color:'blue'}, + {id:3, name:'Detail 3', masterId:1, amount:30.03, color:'blue'}, + ]) + .orderBy('id') + .offset(1) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(2); + should(output[0].masterId.value).equal(2); + should(output[1].id.value).equal(3); + should(output[1].masterId.value).equal(1); + done(); + }) + .catch(done); + }); + it('with limit', function(done) { + execPlan( + p.fromLiterals([ + {id:2, name:'Detail 2', masterId:2, amount:20.02, color:'blue'}, + {id:3, name:'Detail 3', masterId:1, amount:30.03, color:'blue'}, + {id:4, name:'Detail 4', masterId:2, amount:40.04, color:'green'}, + ]) + .orderBy('id') + .limit(2) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(2); + should(output[0].masterId.value).equal(2); + should(output[1].id.value).equal(3); + should(output[1].masterId.value).equal(1); + done(); + }) + .catch(done); + }); + it('with named parameters', function(done) { + execPlan( + p.fromLiterals({rows:[ + {id:1, name:'Detail 1', masterId:1, amount:10.01, color:'blue'}, + {id:2, name:'Detail 2', masterId:2, amount:20.02, color:'blue'}, + {id:3, name:'Detail 3', masterId:1, amount:30.03, color:'blue'}, + {id:4, name:'Detail 4', masterId:2, amount:40.04, color:'green'}, + {id:5, name:'Detail 5', masterId:1, amount:50.05, color:'green'}, + {id:6, name:'Detail 6', masterId:2, amount:60.06, color:'green'} + ]}) + .where({condition:p.not(p.eq(p.col('id'),0))}) + .groupBy({keys:'masterId', aggregates:[ + p.count('detailCount', 'id'), p.sum('detailSum', 'id') + ]}) + .orderBy({keys:['masterId']}) + .select({columns:['masterId', 'detailCount']}) + .offsetLimit(1, 1) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].masterId.value).equal(2); + should(output[0].detailCount.value).equal(3); + done(); + }) + .catch(done); + }); + }); + describe('with as expression binding', function() { + it('for select', function(done) { + execPlan( + p.fromLiterals([ + {row:1, val:8}, + {row:2, val:6}, + {row:3, val:4} + ]) + .select(p.as('added', p.add(p.col('row'), p.col('val')))) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].added.value).equal(9); + should(output[1].added.value).equal(8); + should(output[2].added.value).equal(7); + done(); + }) + .catch(done); + }); + it('for orderBy', function(done) { + execPlan( + p.fromLiterals([ + {row:1, val:8}, + {row:2, val:6}, + {row:3, val:4} + ]) + .orderBy(p.as('added', p.add(p.col('row'), p.col('val')))) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].added.value).equal(7); + should(output[0].row.value).equal(3); + should(output[0].val.value).equal(4); + should(output[1].added.value).equal(8); + should(output[1].row.value).equal(2); + should(output[1].val.value).equal(6); + should(output[2].added.value).equal(9); + should(output[2].row.value).equal(1); + should(output[2].val.value).equal(8); + done(); + }) + .catch(done); + }); + it('for groupBy key', function(done) { + execPlan( + p.fromLiterals([ + {partA:1, partB:4}, + {partA:2, partB:3}, + {partA:1, partB:6}, + {partA:2, partB:5}, + {partA:3, partB:4} + ]) + .groupBy(p.as('added', p.add(p.col('partA'), p.col('partB'))), p.count('partCount', 'partB')) + .orderBy('added') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].added.value).equal(5); + should(output[0].partCount.value).equal(2); + should(output[1].added.value).equal(7); + should(output[1].partCount.value).equal(3); + done(); + }) + .catch(done); + }); + it('for groupBy aggregate', function(done) { + execPlan( + p.fromLiterals([ + {group:1, partA:1, partB:4}, + {group:1, partA:2, partB:3}, + {group:2, partA:1, partB:6}, + {group:2, partA:2, partB:5}, + {group:2, partA:3, partB:4} + ]) + .orderBy('group') + .groupBy('group', p.sum('partSum', p.as('added', p.add(p.col('partA'), p.col('partB'))))) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].partSum.value).equal(10); + should(output[1].group.value).equal(2); + should(output[1].partSum.value).equal(21); + done(); + }) + .catch(done); + }); + }); + it('for groupBy with implicit sample aggregate', function(done) { + execPlan( + p.fromLiterals([ + {group:1, groupVal:'A', detail:11}, + {group:1, groupVal:'A', detail:12}, + {group:2, groupVal:'B', detail:21}, + {group:2, groupVal:'B', detail:22}, + {group:2, groupVal:'B', detail:23} + ]) + .groupBy('group', ['groupVal', 'detail']) + .orderBy('group') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].group.value).equal(1); + should(output[0].groupVal.value).equal('A'); + should(output[0].detail.value).within(11,12); + should(output[1].group.value).equal(2); + should(output[1].groupVal.value).equal('B'); + should(output[1].detail.value).within(21,23); + done(); + }) + .catch(done); + }); + it('for ascending and descending orderBy', function(done) { + execPlan( + p.fromLiterals([ + {row:1, keyA:8, keyB:3}, + {row:2, keyA:4, keyB:3}, + {row:3, keyA:8, keyB:7}, + {row:4, keyA:4, keyB:7} + ]) + .orderBy([p.asc('keyA'), p.desc('keyB')]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(4); + should(output[0].row.value).equal(4); + should(output[0].keyA.value).equal(4); + should(output[0].keyB.value).equal(7); + should(output[1].row.value).equal(2); + should(output[1].keyA.value).equal(4); + should(output[1].keyB.value).equal(3); + should(output[2].row.value).equal(3); + should(output[2].keyA.value).equal(8); + should(output[2].keyB.value).equal(7); + should(output[3].row.value).equal(1); + should(output[3].keyA.value).equal(8); + should(output[3].keyB.value).equal(3); + done(); + }) + .catch(done); + }); +}); diff --git a/test-basic/plan-nodes.js b/test-basic/plan-nodes.js new file mode 100644 index 00000000..6e90b515 --- /dev/null +++ b/test-basic/plan-nodes.js @@ -0,0 +1,644 @@ +/* + * Copyright 2017-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; + +describe('nodes', function() { + const literals = [ + {row:1, gp:1, nm:'alpha', str:'a', num:10, bool:true}, + {row:2, gp:1, nm:'beta', str:'b', num:20, bool:false}, + {row:3, gp:2, nm:'gamma', str:'c', num:30, bool:true}, + {row:4, gp:2, nm:'delta', str:'d', num:40, bool:false} + ]; + // Note: roundtripped + const exportedJson = + {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-literals', args:[[{s:'a', n:1}]]}, + {ns:'op', fn:'select', args:[ + {ns:'op', fn:'as', args:['o', + {ns:'op', fn:'json-document', args:[ + {ns:'op', fn:'json-object', args:[[ + {ns:'op', fn:'prop', args:['p1', + {ns:'op', fn:'json-string', args:[ + {ns:'op', fn:'col', args:['s']} + ]} + ]}, + {ns:'op', fn:'prop', args:['p2', + {ns:'op', fn:'json-array', args:[ + {ns:'op', fn:'json-number', args:[ + {ns:'op', fn:'col', args:['n']} + ]} + ]} + ]} + ]]} + ]} + ]} + ]} + ]}}; + const exportedXml = + {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-literals', args:[[{s:'a', n:1}]]}, + {ns:'op', fn:'select', args:[ + {ns:'op', fn:'as', args:['c', + {ns:'op', fn:'xml-document', args:[ + {ns:'op', fn:'xml-element', args:['e', + {ns:'op', fn:'xml-attribute', args:['a', + {ns:'op', fn:'col', args:['s']} + ]}, + {ns:'op', fn:'xml-text', args:[ + {ns:'op', fn:'col', args:['n']} + ]} + ]} + ]} + ]} + ]} + ]}}; + describe('JSON', function() { + it('string', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', p.as('node', p.jsonString(p.col('str'))), p.as('kind', p.xdmp.nodeKind(p.col('node')))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal('a'); + should(output[0].kind.value).equal('text'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal('b'); + should(output[1].kind.value).equal('text'); + done(); + }) + .catch(done); + }); + it('number', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', p.as('node', p.jsonNumber(p.col('num'))), p.as('kind', p.xdmp.nodeKind(p.col('node')))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal(10); + should(output[0].kind.value).equal('number'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal(20); + should(output[1].kind.value).equal('number'); + done(); + }) + .catch(done); + }); + it('boolean', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', p.as('node', p.jsonBoolean(p.col('bool'))), p.as('kind', p.xdmp.nodeKind(p.col('node')))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal(true); + should(output[0].kind.value).equal('boolean'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal(false); + should(output[1].kind.value).equal('boolean'); + done(); + }) + .catch(done); + }); + it('null', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', p.as('node', p.jsonNull()), p.as('kind', p.xdmp.nodeKind(p.col('node')))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal(null); + should(output[0].kind.value).equal('null'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal(null); + should(output[1].kind.value).equal('null'); + done(); + }) + .catch(done); + }); + it('array', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.jsonArray([ + p.jsonString(p.col('str')), + p.jsonNumber(p.col('num')), + p.jsonBoolean(p.col('bool')), + p.jsonNull(), + p.xs.string(p.col('str')), + p.xs.int(p.col('num')), + p.xs.boolean(p.col('bool')), + 'string', + 5, + true + ])), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value.length).equal(10); + should(output[0].node.value[0]).equal('a'); + should(output[0].node.value[1]).equal(10); + should(output[0].node.value[2]).equal(true); + should(output[0].node.value[3]).equal(null); + should(output[0].node.value[4]).equal('a'); + should(output[0].node.value[5]).equal(10); + should(output[0].node.value[6]).equal(true); + should(output[0].node.value[7]).equal('string'); + should(output[0].node.value[8]).equal(5); + should(output[0].node.value[9]).equal(true); + should(output[0].kind.value).equal('array'); + should(output[1].row.value).equal(2); + should(output[1].node.value.length).equal(10); + should(output[1].node.value[0]).equal('b'); + should(output[1].node.value[1]).equal(20); + should(output[1].node.value[2]).equal(false); + should(output[1].node.value[3]).equal(null); + should(output[1].node.value[4]).equal('b'); + should(output[1].node.value[5]).equal(20); + should(output[1].node.value[6]).equal(false); + should(output[1].node.value[7]).equal('string'); + should(output[1].node.value[8]).equal(5); + should(output[1].node.value[9]).equal(true); + should(output[1].kind.value).equal('array'); + done(); + }) + .catch(done); + }); + it('object', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.jsonObject([ + p.prop(p.col('str'), p.col('num')), + p.prop('k2', p.col('bool')), + p.prop('k3', p.jsonNull()), + p.prop('k4', p.jsonArray([p.col('row')])) + ])), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value.a).equal(10); + should(output[0].node.value.k2).equal(true); + should(output[0].node.value.k3).equal(null); + should(output[0].node.value.k4.length).equal(1); + should(output[0].node.value.k4[0]).equal(1); + should(output[0].kind.value).equal('object'); + should(output[1].row.value).equal(2); + should(output[1].node.value.b).equal(20); + should(output[1].node.value.k2).equal(false); + should(output[1].node.value.k3).equal(null); + should(output[1].node.value.k4[0]).equal(2); + should(output[1].kind.value).equal('object'); + done(); + }) + .catch(done); + }); + it('document', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.jsonDocument(p.jsonObject([ + p.prop('k1', p.col('str')), + p.prop('k2', p.jsonArray([ + p.col('num'), + p.jsonObject([ + p.prop('k3', p.col('bool')), + p.prop('k4', p.jsonNull()) + ]) + ])) + ]))), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value.k1).equal('a'); + should(output[0].node.value.k2.length).equal(2); + should(output[0].node.value.k2[0]).equal(10); + should(output[0].node.value.k2[1].k3).equal(true); + should(output[0].node.value.k2[1].k4).equal(null); + should(output[0].kind.value).equal('document'); + should(output[1].row.value).equal(2); + should(output[1].node.value.k1).equal('b'); + should(output[1].node.value.k2.length).equal(2); + should(output[1].node.value.k2[0]).equal(20); + should(output[1].node.value.k2[1].k3).equal(false); + should(output[1].node.value.k2[1].k4).equal(null); + should(output[1].kind.value).equal('document'); + done(); + }) + .catch(done); + }); + it('expression', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.jsonObject([ + p.prop('k1', 'first'), + p.prop(p.fn.concat('key',p.col('row')), p.fn.concat(p.col('str'),' value')), + p.prop('k3', p.jsonArray([ + 0, + p.col('num'), + 'end' + ])) + ])), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value.k1).equal('first'); + should(output[0].node.value.key1).equal('a value'); + should(output[0].node.value.k3.length).equal(3); + should(output[0].node.value.k3[0]).equal(0); + should(output[0].node.value.k3[1]).equal(10); + should(output[0].node.value.k3[2]).equal('end'); + should(output[0].kind.value).equal('object'); + should(output[1].row.value).equal(2); + should(output[1].node.value.k1).equal('first'); + should(output[1].node.value.key2).equal('b value'); + should(output[1].node.value.k3.length).equal(3); + should(output[1].node.value.k3[0]).equal(0); + should(output[1].node.value.k3[1]).equal(20); + should(output[1].node.value.k3[2]).equal('end'); + should(output[1].kind.value).equal('object'); + done(); + }) + .catch(done); + }); + it('array aggregate', function(done) { + execPlan( + p.fromLiterals(literals) + .select(['gp', + p.as('ro', p.jsonObject([ + p.prop('row', p.col('row')), + p.prop('nm', p.col('nm')), + p.prop('num', p.col('num')) + ])) + ]) + .groupBy('gp', p.arrayAggregate('ra', 'ro')) + .orderBy('gp') + .select(p.as('container', p.jsonObject([ + p.prop('group', p.col('gp')), + p.prop('rows', p.col('ra')) + ])) + ) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].container.value.group).equal(1); + should(output[0].container.value.rows.length).equal(2); + should(output[0].container.value.rows[0].row).equal(1); + should(output[0].container.value.rows[0].nm).equal('alpha'); + should(output[0].container.value.rows[0].num).equal(10); + should(output[0].container.value.rows[1].row).equal(2); + should(output[0].container.value.rows[1].nm).equal('beta'); + should(output[0].container.value.rows[1].num).equal(20); + should(output[1].container.value.group).equal(2); + should(output[1].container.value.rows.length).equal(2); + should(output[1].container.value.rows[0].row).equal(3); + should(output[1].container.value.rows[0].nm).equal('gamma'); + should(output[1].container.value.rows[0].num).equal(30); + should(output[1].container.value.rows[1].row).equal(4); + should(output[1].container.value.rows[1].nm).equal('delta'); + should(output[1].container.value.rows[1].num).equal(40); + done(); + }) + .catch(done); + }); + }); + describe('XML', function() { + it('text', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', p.as('node', p.xmlText(p.col('str'))), p.as('kind', p.xdmp.nodeKind(p.col('node')))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal('a'); + should(output[0].kind.value).equal('text'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal('b'); + should(output[1].kind.value).equal('text'); + done(); + }) + .catch(done); + }); + it('comment', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', p.as('node', p.xmlComment(p.col('str'))), p.as('kind', p.xdmp.nodeKind(p.col('node')))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal(''); + should(output[0].kind.value).equal('comment'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal(''); + should(output[1].kind.value).equal('comment'); + done(); + }) + .catch(done); + }); + it('processing instruction', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', p.as('node', p.xmlPi(p.col('str'), p.col('num'))), p.as('kind', p.xdmp.nodeKind(p.col('node')))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal(''); + should(output[0].kind.value).equal('processing-instruction'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal(''); + should(output[1].kind.value).equal('processing-instruction'); + done(); + }) + .catch(done); + }); + it('element empty', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', p.as('node', p.xmlElement(p.col('str'))), p.as('kind', p.xdmp.nodeKind(p.col('node')))]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal(''); + should(output[0].kind.value).equal('element'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal(''); + should(output[1].kind.value).equal('element'); + done(); + }) + .catch(done); + }); + it('element attribute', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.xmlElement(p.col('nm'), p.xmlAttribute(p.col('str'), p.col('num')))), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal(''); + should(output[0].kind.value).equal('element'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal(''); + should(output[1].kind.value).equal('element'); + done(); + }) + .catch(done); + }); + it('element content', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.xmlElement(p.col('nm'), null, [ + p.xmlText(p.col('str')), + p.xs.string(p.col('str')), + p.col('str'), + 'string' + ])), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal('aa a string'); + should(output[0].kind.value).equal('element'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal('bb b string'); + should(output[1].kind.value).equal('element'); + done(); + }) + .catch(done); + }); + it('element attribute content', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.xmlElement(p.col('nm'), p.xmlAttribute(p.col('str'), p.col('num')), p.xmlText(p.col('bool')))), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal('true'); + should(output[0].kind.value).equal('element'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal('false'); + should(output[1].kind.value).equal('element'); + done(); + }) + .catch(done); + }); + it('document', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.xmlDocument( + p.xmlElement(p.col('nm'), null, + p.xmlElement(p.col('str'), null, p.xmlText(p.col('bool'))) + ) + )), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal('true'); + should(output[0].kind.value).equal('document'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal('false'); + should(output[1].kind.value).equal('document'); + done(); + }) + .catch(done); + }); + it('expression', function(done) { + execPlan( + p.fromLiterals(literals) + .where(p.eq(p.col('gp'), 1)) + .select(['row', + p.as('node', p.xmlElement(p.fn.concat(p.col('nm'), 'Name'), [ + p.xmlAttribute(p.fn.concat('key', p.col('row')), 'value'), + p.xmlAttribute('key', p.fn.concat(p.col('str'), ' value')) + ], [ + p.xmlText(p.fn.concat(p.col('num'), ' text')), + p.xmlElement('separator'), + 'end' + ]) + ), + p.as('kind', p.xdmp.nodeKind(p.col('node'))) + ]) + .orderBy('row') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].row.value).equal(1); + should(output[0].node.value).equal('10 textend'); + should(output[0].kind.value).equal('element'); + should(output[1].row.value).equal(2); + should(output[1].node.value).equal('20 textend'); + should(output[1].kind.value).equal('element'); + done(); + }) + .catch(done); + }); + it('sequence aggregate', function(done) { + execPlan( + p.fromLiterals(literals) + .select(['gp', + p.as('re', p.xmlElement('relem', [ + p.xmlAttribute('row', p.col('row')), + p.xmlAttribute('nm', p.col('nm')), + p.xmlAttribute('num', p.col('num')) + ])) + ]) + .groupBy('gp', p.sequenceAggregate('rs', 're')) + .orderBy('gp') + .select(p.as('container', p.xmlElement('gelem', + p.xmlAttribute('group', p.col('gp')), + p.xmlElement('rows', p.col('rs')) + )) + ) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].container.value).equal( + '' + ); + should(output[1].container.value).equal( + '' + ); + done(); + }) + .catch(done); + }); + }); + describe('serialization', function() { + it('JSON export', function(done) { + const value = + p.fromLiterals([{s:'a', n:1}]) + .select(p.as('o',p.jsonDocument( + p.jsonObject([ + p.prop('p1', p.jsonString(p.col('s'))), + p.prop('p2', p.jsonArray([ + p.jsonNumber(p.col('n')) + ])) + ]) + ))) + .export(); + should(value).deepEqual(exportedJson); + done(); + }); + it('XML export', function(done) { + const value = + p.fromLiterals([{s:'a', n:1}]) + .select(p.as('c', p.xmlDocument( + p.xmlElement('e', p.xmlAttribute('a', p.col('s')), + p.xmlText(p.col('n')) + ) + ))) + .export(); + should(value).deepEqual(exportedXml); + done(); + }); + }); +}); diff --git a/test-basic/plan-processors.js b/test-basic/plan-processors.js new file mode 100644 index 00000000..2e35025c --- /dev/null +++ b/test-basic/plan-processors.js @@ -0,0 +1,317 @@ +/* + * Copyright 2016-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const explainPlan = pbb.explainPlan; +const getResults = pbb.getResults; + +describe('processor', function() { + describe('prepare', function() { + it('optimize level', function(done) { + execPlan( + p.fromLiterals([ + {id:1, val: 2}, + {id:2, val: 4} + ]) + .orderBy('id') + .prepare(2) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(1); + should(output[0].val.value).equal(2); + should(output[1].id.value).equal(2); + should(output[1].val.value).equal(4); + done(); + }) + .catch(done); + }); + }); + describe('result', function() { + it('as implicit object sequence', function(done) { + execPlan( + p.fromLiterals([ + {id:1, val: 2}, + {id:2, val: 4} + ]) + .orderBy('id') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(1); + should(output[0].val.value).equal(2); + should(output[1].id.value).equal(2); + should(output[1].val.value).equal(4); + done(); + }) + .catch(done); + }); + it('as explicit object sequence', function(done) { + execPlan( + p.fromLiterals([ + {id:1, val: 2}, + {id:2, val: 4} + ]) + .orderBy('id'), + null, + 'object' + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(1); + should(output[0].val.value).equal(2); + should(output[1].id.value).equal(2); + should(output[1].val.value).equal(4); + done(); + }) + .catch(done); + }); + it('as array sequence', function(done) { + execPlan( + p.fromLiterals([ + {id:1, val: 2}, + {id:2, val: 4} + ]) + .orderBy('id'), + null, + 'array' + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].length).equal(2); + let idPos = 0; + let valPos = 0; + for (let i=0; i < 2; i++) { + switch(output[0][i].name) { + case "id": + idPos = i; + break; + case "val": + valPos = i; + break; + default: + should(output[0][i]).equal('SHOULD NOT EXIST'); + break; + } + } + should(idPos).be.greaterThanOrEqual(0); + should(valPos).be.greaterThanOrEqual(0); + should(output[1][idPos].value).equal(1); + should(output[1][valPos].value).equal(2); + should(output[2][idPos].value).equal(2); + should(output[2][valPos].value).equal(4); + done(); + }) + .catch(done); + }); + it('with placeholder parameter', function(done) { + execPlan( + p.fromLiterals([ + {id:1, val: 2}, + {id:2, val: 4}, + {id:3, val: 6}, + {id:4, val: 8} + ]) + .offsetLimit(p.param('start'), p.param('length')) + .where(p.gt(p.col('val'), p.param('floor'))) + .select(['id', p.as('incremented', p.add(p.col('val'), p.param('increment')))]), + { + start:1, length:2, floor:4, increment:1 + } + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].id.value).equal(3); + should(output[0].incremented.value).equal(7); + done(); + }) + .catch(done); + }); + }); + describe('function', function() { + it('as array mapper', function(done) { + execPlan( + p.fromLiterals([ + {id:1, val: 2}, + {id:2, val: 4} + ]) + .orderBy('id') + .map(p.resolveFunction('arrayMapper', '/etc/optic/rowPostProcessors.sjs')), + null, + 'array' + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(3); + should(output[0].length).equal(3); + let idPos = -1; + let valPos = -1; + let secondsPos = -1; + for (let i=0; i < 3; i++) { + switch(output[0][i].name) { + case "id": + idPos = i; + break; + case "val": + valPos = i; + break; + case "seconds": + secondsPos = i; + break; + default: + should(output[0][i]).equal('SHOULD NOT EXIST'); + break; + } + } + should(idPos).be.greaterThanOrEqual(0); + should(valPos).be.greaterThanOrEqual(0); + should(secondsPos).be.greaterThanOrEqual(0); + should(output[1][idPos].value).equal(1); + should(output[1][valPos].value).equal(2); + should(output[1][secondsPos].value).be.greaterThanOrEqual(0); + should(output[1][secondsPos].value).be.lessThanOrEqual(59); + should(output[2][idPos].value).equal(2); + should(output[2][valPos].value).equal(4); + should(output[2][secondsPos].value).be.greaterThanOrEqual(0); + should(output[2][secondsPos].value).be.lessThanOrEqual(59); + done(); + }) + .catch(done); + }); + it('as object mapper', function(done) { + execPlan( + p.fromLiterals([ + {id:1, val: 2}, + {id:2, val: 4} + ]) + .orderBy('id') + .map(p.resolveFunction('secondsMapper', '/etc/optic/rowPostProcessors.sjs')) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(1); + should(output[0].val.value).equal(2); + should(output[0].seconds.value).be.greaterThanOrEqual(0); + should(output[0].seconds.value).be.lessThanOrEqual(59); + should(output[1].id.value).equal(2); + should(output[1].val.value).equal(4); + should(output[1].seconds.value).be.greaterThanOrEqual(0); + should(output[1].seconds.value).be.lessThanOrEqual(59); + done(); + }) + .catch(done); + }); + it('as array reducer', function(done) { + execPlan( + p.fromLiterals([ + {val: 2}, + {val: 4}, + {val: 6}, + {val: 8} + ]) + .orderBy('val') + .reduce(p.resolveFunction('arrayReducer', '/etc/optic/rowPostProcessors.sjs')), + null, + 'array' + ) + .then(function(response) { + const output = getResults(response); + should(output).equal(20); + done(); + }) + .catch(done); + }); + it('as object reducer', function(done) { + execPlan( + p.fromLiterals([ + {val: 2}, + {val: 4}, + {val: 6}, + {val: 8}, + {val: 10}, + {val: 12} + ]) + .orderBy('val') + .reduce(p.resolveFunction('fibReducer', '/etc/optic/rowPostProcessors.sjs')) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(6); + should(output[0].i.value).equal(0); + should(output[0].val.value).equal(2); + should(output[0].fib.value).equal(0); + should(output[1].i.value).equal(1); + should(output[1].val.value).equal(4); + should(output[1].fib.value).equal(1); + should(output[2].i.value).equal(2); + should(output[2].val.value).equal(6); + should(output[2].fib.value).equal(1); + should(output[3].i.value).equal(3); + should(output[3].val.value).equal(8); + should(output[3].fib.value).equal(2); + should(output[4].i.value).equal(4); + should(output[4].val.value).equal(10); + should(output[4].fib.value).equal(3); + should(output[5].i.value).equal(5); + should(output[5].val.value).equal(12); + should(output[5].fib.value).equal(5); + done(); + }) + .catch(done); + }); + }); + it('explain default', function(done) { + explainPlan( + p.fromLiterals([ + {id:1, val: 2}, + {id:2, val: 4} + ]) + ) + .then(function(output) { + should(output.node).equal('plan'); + should.exist(output.expr); + done(); + }) + .catch(done); + }); + it('explain xml', function(done) { + explainPlan( + p.fromLiterals([ + {id:1, val: 2}, + {id:2, val: 4} + ]), + 'xml' + ) + .then(function(output) { + should.exist(output); + done(); + }) + .catch(done); + }); +}); diff --git a/test-basic/plan-triples.js b/test-basic/plan-triples.js new file mode 100644 index 00000000..ac8ccb14 --- /dev/null +++ b/test-basic/plan-triples.js @@ -0,0 +1,380 @@ +/* + * Copyright 2016-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; + +describe('triples', function() { + const datastore = p.col('datastore'); + const master = p.col('master'); + const masterId = p.col('masterId'); + const titleCol = p.col('title'); + const datastoreType = p.sem.iri('http://purl.org/dc/dcmitype/Dataset'); + const dc = p.prefixer('http://purl.org/dc/terms/'); + const typeProp = dc('type'); + const titleProp = dc('title'); + const sourceProp = dc('source'); + const idProp = dc('identifier'); + const descProp = dc('description'); + const altProp = dc('alternative'); + const exportedTriplesBarePatterns = + {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-triples', args:[[ + {ns:'op', fn:'pattern', args:[ + {ns:'op', fn:'col', args:['datastore']}, + {ns:'sem', fn:'iri', args:['http://purl.org/dc/terms/type']}, + {ns:'sem', fn:'iri', args:['http://purl.org/dc/dcmitype/Dataset']} + ]}, + {ns:'op', fn:'pattern', args:[ + {ns:'op', fn:'col', args:['datastore']}, + {ns:'sem', fn:'iri', args:['http://purl.org/dc/terms/title']}, + {ns:'op', fn:'col', args:['title']} + ]}] + ]} + ]}}; + const exportedTriplesGraphColumn = + {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-triples', args:[[ + {ns:'op', fn:'pattern', args:[ + {ns:'op', fn:'col', args:['datastore']}, + {ns:'sem', fn:'iri', args:['http://purl.org/dc/terms/type']}, + {ns:'sem', fn:'iri', args:['http://purl.org/dc/dcmitype/Dataset']}, + {ns:'op', fn:'graph-col', args:['sourceGraph']} + ]}, + {ns:'op', fn:'pattern', args:[ + {ns:'op', fn:'col', args:['datastore']}, + {ns:'sem', fn:'iri', args:['http://purl.org/dc/terms/title']}, + {ns:'op', fn:'col', args:['title']} + ]}] + ]}, + {ns:'op', fn:'order-by', args:[['sourceGraph','title']]} + ]}}; + const exportedFromSPARQL = + {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-sparql', args:[ + 'PREFIX dc: '+ + 'SELECT ?datastore ?title '+ + 'WHERE {?datastore dc:type ; dc:title ?title .}' + ]} + ]}}; + describe('accessors', function() { + it('with bare patterns', function(done) { + execPlan( + p.fromTriples([ + p.pattern(datastore, typeProp, datastoreType), + p.pattern(datastore, titleProp, titleCol), + p.pattern(datastore, descProp, p.col('desc')) + ], + 'tripview') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0]['tripview.datastore'].value).equal('/datastore/id#A'); + should(output[0]['tripview.title'].value).equal('The A datastore'); + should(output[0]['tripview.desc'].value).equal('Describing A'); + should(output[1]['tripview.datastore'].value).equal('/datastore/id#B'); + should(output[1]['tripview.title'].value).equal('The B datastore'); + should(output[1]['tripview.desc'].value).equal('Describing B'); + done(); + }) + .catch(done); + }); + it('with multiple literals', function(done) { + execPlan( + p.fromTriples( + p.pattern( + p.col('identified'), + idProp, + [1, 2] + )) + .orderBy('identified') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].identified.value).equal('/master/id#1'); + should(output[1].identified.value).equal('/master/id#2'); + done(); + }) + .catch(done); + }); + it('with required column', function(done) { + execPlan( + p.fromTriples([ + p.pattern(datastore, typeProp, datastoreType), + p.pattern(datastore, titleProp, titleCol), + p.pattern(datastore, altProp, p.col('alternative')) + ]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].datastore.value).equal('/datastore/id#A'); + should(output[0].title.value).equal('The A datastore'); + should(output[0].alternative.value).equal('The Awesome datastore'); + done(); + }) + .catch(done); + }); + it('with optional column', function(done) { + execPlan( + p.fromTriples([ + p.pattern(datastore, typeProp, datastoreType), + p.pattern(datastore, titleProp, titleCol) + ]) + .joinLeftOuter(p.fromTriples( + p.pattern(datastore, altProp, p.col('alternative')) + )) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].datastore.value).equal('/datastore/id#A'); + should(output[0].title.value).equal('The A datastore'); + should(output[0].alternative.value).equal('The Awesome datastore'); + should(output[1].datastore.value).equal('/datastore/id#B'); + should(output[1].title.value).equal('The B datastore'); + should(output[1].alternative.value).equal(null); + done(); + }) + .catch(done); + }); + it('with fragment id column', function(done) { + execPlan( + p.fromTriples([ + p.pattern(datastore, typeProp, datastoreType, p.fragmentIdCol('sourceDocId')), + p.pattern(datastore, titleProp, titleCol) + ]) + .select(['datastore','title','sourceDocId', + p.as('sourceDocCheck',p.isDefined(p.fragmentIdCol('sourceDocId')))]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].datastore.value).equal('/datastore/id#A'); + should(output[0].title.value).equal('The A datastore'); + should(output[0].sourceDocCheck.value).equal(true); + should.not.exist(output[0].sourceDocId); + should(output[1].datastore.value).equal('/datastore/id#B'); + should(output[1].title.value).equal('The B datastore'); + should(output[1].sourceDocCheck.value).equal(true); + should.not.exist(output[1].sourceDocId); + done(); + }) + .catch(done); + }); + it('having col method', function(done) { + const accessor = p.fromTriples([ + p.pattern(datastore, typeProp, datastoreType, p.fragmentIdCol('sourceDoc')), + p.pattern(datastore, titleProp, titleCol) + ], + 'tripview'); + const colPlan = accessor.select(accessor.col('title')); + const value = colPlan.export(); + should(value.$optic.args.length).equal(2); + should(value.$optic.args[1].args.length).equal(1); + should(value.$optic.args[1].args[0]).deepEqual( + {ns:'op', fn:'view-col', args:['tripview', 'title']} + ); + execPlan( + colPlan + .orderBy(accessor.col('title')) + .limit(2) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0]['tripview.title'].value).equal('The A datastore'); + should(output[1]['tripview.title'].value).equal('The B datastore'); + done(); + }) + .catch(done); + }); + it('with graph iri', function(done) { + execPlan( + p.fromTriples( + p.pattern(p.col('albumId'), p.sem.iri('/optic/test/albumName'), p.col('albumName')), + null, + '/optic/music' + ) + .where(p.cts.jsonPropertyWordQuery('style', 'avantgarde')) + .orderBy('albumName') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(4); + should(output[0].albumName.value).equal('A Ballad For Many'); + should(output[1].albumName.value).equal('Crescent'); + should(output[2].albumName.value).equal('Four Thoughts on Marvin Gaye'); + should(output[3].albumName.value).equal('Impressions'); + done(); + }) + .catch(done); + }); + it('with param', function(done) { + execPlan( + p.fromTriples( + p.pattern(p.col('albumId'), p.sem.iri('/optic/test/albumName'), p.param('albumName')) + ), + {albumName:'Crescent'} + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].albumId.value).equal('/optic/test/albums3_2'); + done(); + }) + .catch(done); + }); + it('with query', function(done) { + execPlan( + p.fromTriples( + p.pattern(p.col('albumId'), p.sem.iri('/optic/test/albumName'), p.col('albumName')) + ) + .where(p.cts.jsonPropertyWordQuery('style', 'avantgarde')) + .orderBy('albumName') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(4); + should(output[0].albumName.value).equal('A Ballad For Many'); + should(output[1].albumName.value).equal('Crescent'); + should(output[2].albumName.value).equal('Four Thoughts on Marvin Gaye'); + should(output[3].albumName.value).equal('Impressions'); + done(); + }) + .catch(done); + }); + it('with store', function(done) { + execPlan( + p.fromTriples( + p.pattern(p.col('albumId'), p.sem.iri('/optic/test/albumName'), p.col('albumName')) + ) + .where(p.sem.store("document", p.cts.jsonPropertyWordQuery('style', 'avantgarde'))) + .orderBy('albumName') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(4); + should(output[0].albumName.value).equal('A Ballad For Many'); + should(output[1].albumName.value).equal('Crescent'); + should(output[2].albumName.value).equal('Four Thoughts on Marvin Gaye'); + should(output[3].albumName.value).equal('Impressions'); + done(); + }) + .catch(done); + }); + it('with graph column', function(done) { + execPlan( + p.fromTriples([ + p.pattern(datastore, typeProp, datastoreType, p.graphCol('sourceGraph')), + p.pattern(datastore, titleProp, titleCol) + ]) + .where(p.eq(p.col('sourceGraph'), '/graphs/inventory')) + .orderBy(['sourceGraph', 'title']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].sourceGraph.value).equal('/graphs/inventory'); + should(output[0].title.value).equal('The A datastore'); + should(output[1].sourceGraph.value).equal('/graphs/inventory'); + should(output[1].title.value).equal('The B datastore'); + done(); + }) + .catch(done); + }); + }); + describe('from SPARQL', function() { + it('basic', function(done) { + execPlan( + p.fromSPARQL('PREFIX dc: '+ + 'SELECT ?datastore ?title '+ + 'WHERE {?datastore dc:type ; dc:title ?title .}') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0]['datastore'].value).equal('/datastore/id#A'); + should(output[0]['title'].value).equal('The A datastore'); + should(output[1]['datastore'].value).equal('/datastore/id#B'); + should(output[1]['title'].value).equal('The B datastore'); + done(); + }) + .catch(done); + }); + it('with qualifier', function(done) { + execPlan( + p.fromSPARQL('PREFIX dc: '+ + 'SELECT ?datastore ?title '+ + 'WHERE {?datastore dc:type ; dc:title ?title .}', + 'sparqlsel') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0]['sparqlsel.datastore'].value).equal('/datastore/id#A'); + should(output[0]['sparqlsel.title'].value).equal('The A datastore'); + should(output[1]['sparqlsel.datastore'].value).equal('/datastore/id#B'); + should(output[1]['sparqlsel.title'].value).equal('The B datastore'); + done(); + }) + .catch(done); + }); + }); + describe('serialize', function() { + describe('export', function() { + it('with bare patterns', function(done) { + const value = + p.fromTriples([ + p.pattern(datastore, typeProp, datastoreType), + p.pattern(datastore, titleProp, titleCol) + ]) + .export(); + should(value).deepEqual(exportedTriplesBarePatterns); + done(); + }); + it('with graph column', function(done) { + const value = + p.fromTriples([ + p.pattern(datastore, typeProp, datastoreType, p.graphCol('sourceGraph')), + p.pattern(datastore, titleProp, titleCol) + ]) + .orderBy(['sourceGraph', 'title']) + .export(); + should(value).deepEqual(exportedTriplesGraphColumn); + done(); + }); + it('from SPARQL', function(done) { + const value = + p.fromSPARQL('PREFIX dc: '+ + 'SELECT ?datastore ?title '+ + 'WHERE {?datastore dc:type ; dc:title ?title .}') + .export(); + should(value).deepEqual(exportedFromSPARQL); + done(); + }); + }); + }); +}); diff --git a/test-basic/plan-views.js b/test-basic/plan-views.js new file mode 100644 index 00000000..1bdf9f28 --- /dev/null +++ b/test-basic/plan-views.js @@ -0,0 +1,561 @@ +/* + * Copyright 2016-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const should = require('should'); + +const marklogic = require('../'); +const p = marklogic.planBuilder; + +const pbb = require('./plan-builder-base'); +const execPlan = pbb.execPlan; +const getResults = pbb.getResults; + +function getValue(row, col) { + const prefix = 'opticUnitTest.'; + return row[prefix+col].value; +} +function testValue(row, col, val) { + should(getValue(row, col)).equal(val); +} + +describe('view', function() { + const exportedView = + {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-view', args:['opticUnitTest', 'master']}, + {ns:'op', fn:'order-by', args:['id']} + ]}}; + const exportedQueryView = + {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-view', args:['opticUnitTest', 'musician']}, + {ns:'op', fn:'where', args:[{ns:'cts', fn:'json-property-word-query', args:['instrument', 'trumpet']}]}, + {ns:'op', fn:'order-by', args:['lastName']} + ]}}; + const exportedFromSQL = + {$optic:{ns:'op', fn:'operators', args:[ + {ns:'op', fn:'from-sql', args:[ + 'SELECT id, name, date FROM master WHERE id = 1' + ]} + ]}}; + describe('accessors', function() { + it('basic', function(done) { + execPlan( + p.fromView('opticUnitTest', 'master') + .orderBy(p.schemaCol('opticUnitTest', 'master', 'id')) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + testValue(output[0], 'master.id', 1); + testValue(output[0], 'master.name', 'Master 1'); + testValue(output[0], 'master.date', '2015-12-01'); + should.not.exist(output[0]['opticUnitTest.master.rowid']); + should.not.exist(output[0]['opticUnitTest.master.__docid']); + testValue(output[1], 'master.id', 2); + testValue(output[1], 'master.name', 'Master 2'); + testValue(output[1], 'master.date', '2015-12-02'); + should.not.exist(output[1]['opticUnitTest.master.rowid']); + should.not.exist(output[1]['opticUnitTest.master.__docid']); + done(); + }) + .catch(done); + }); + it('alias', function(done) { + execPlan( + p.fromView('opticUnitTest', 'master', 'optimast') + .orderBy(p.viewCol('optimast', 'id')) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0]['optimast.id'].value).equal(1); + should(output[0]['optimast.name'].value).equal('Master 1'); + should(output[0]['optimast.date'].value).equal('2015-12-01'); + should(output[1]['optimast.id'].value).equal(2); + should(output[1]['optimast.name'].value).equal('Master 2'); + should(output[1]['optimast.date'].value).equal('2015-12-02'); + done(); + }) + .catch(done); + }); + it('having col method', function(done) { + const accessor = p.fromView('opticUnitTest', 'master'); + const colPlan = accessor.select(accessor.col('id')); + const value = colPlan.export(); + should(value.$optic.args.length).equal(2); + should(value.$optic.args[1].args.length).equal(1); + should(value.$optic.args[1].args[0]).deepEqual( + {ns:'op', fn:'schema-col', args:['opticUnitTest', 'master', 'id']} + ); + execPlan( + colPlan + .orderBy(accessor.col('id')) + .limit(2) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0]['opticUnitTest.master.id'].value).equal(1); + should.not.exist(output[0]['opticUnitTest.master.name']); + should(output[1]['opticUnitTest.master.id'].value).equal(2); + should.not.exist(output[1]['opticUnitTest.master.name']); + done(); + }) + .catch(done); + }); + it('having qualified col method', function(done) { + const accessor = p.fromView('opticUnitTest', 'master', 'idview'); + const colPlan = accessor.select(accessor.col('id')); + const value = colPlan.export(); + should(value.$optic.args.length).equal(2); + should(value.$optic.args[1].args.length).equal(1); + should(value.$optic.args[1].args[0]).deepEqual( + {ns:'op', fn:'view-col', args:['idview', 'id']} + ); + execPlan( + colPlan + .orderBy(accessor.col('id')) + .limit(2) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0]['idview.id'].value).equal(1); + should.not.exist(output[0]['idview.name']); + should(output[1]['idview.id'].value).equal(2); + should.not.exist(output[1]['idview.name']); + done(); + }) + .catch(done); + }); + it('query', function(done) { + execPlan( + p.fromView('opticUnitTest', 'musician') + .where(p.cts.jsonPropertyWordQuery('instrument', 'trumpet')) + .orderBy('lastName') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + testValue(output[0], 'musician.lastName', 'Armstrong'); + testValue(output[0], 'musician.firstName', 'Louis'); + testValue(output[0], 'musician.dob', '1901-08-04'); + testValue(output[1], 'musician.lastName', 'Davis'); + testValue(output[1], 'musician.firstName', 'Miles'); + testValue(output[1], 'musician.dob', '1926-05-26'); + done(); + }) + .catch(done); + }); + it('with fragment id column', function(done) { + execPlan( + p.fromView('opticUnitTest', 'master', null, p.fragmentIdCol('sourceDocId')) + .where(p.eq(p.col('id'), 1)) + .select(['id','name','sourceDocId', + p.as('sourceDocCheck',p.isDefined(p.col('sourceDocId')))], + '') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0].id.value).equal(1); + should(output[0].name.value).equal('Master 1'); + should(output[0].sourceDocCheck.value).equal(true); + should.not.exist(output[0].sourceDocId); + done(); + }) + .catch(done); + }); + }); + describe('modifiers', function() { + it('with where', function(done) { + execPlan( + p.fromView('opticUnitTest', 'master') + .where(p.eq(p.schemaCol('opticUnitTest', 'master', 'id'), 1)) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + testValue(output[0], 'master.id', 1); + testValue(output[0], 'master.name', 'Master 1'); + testValue(output[0], 'master.date', '2015-12-01'); + done(); + }) + .catch(done); + }); + it('with whereDistinct', function(done) { + execPlan( + p.fromView('opticUnitTest', 'detail') + .select(p.schemaCol('opticUnitTest', 'detail', 'color')) + .whereDistinct() + .orderBy(p.schemaCol('opticUnitTest', 'detail', 'color')) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + testValue(output[0], 'detail.color', 'blue'); + testValue(output[1], 'detail.color', 'green'); + done(); + }) + .catch(done); + }); + it('with select', function(done) { + execPlan( + p.fromView('opticUnitTest', 'master') + .select([p.schemaCol('opticUnitTest', 'master', 'id'), + p.schemaCol('opticUnitTest', 'master', 'name')]) + .orderBy(p.schemaCol('opticUnitTest', 'master', 'id')) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + testValue(output[0], 'master.id', 1); + testValue(output[0], 'master.name', 'Master 1'); + should.not.exist(output[0]['opticUnitTest.master.date']); + testValue(output[1], 'master.id', 2); + testValue(output[1], 'master.name', 'Master 2'); + should.not.exist(output[1]['opticUnitTest.master.date']); + done(); + }) + .catch(done); + }); + it('without system columns', function(done) { + execPlan( + p.fromView('opticUnitTest', 'master') + .select(null, '') + .orderBy('id') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].id.value).equal(1); + should(output[0].name.value).equal('Master 1'); + should(output[0].date.value).equal('2015-12-01'); + should.not.exist(output[0]['master.rowid']); + should.not.exist(output[0]['master.__docid']); + should(output[1].id.value).equal(2); + should(output[1].name.value).equal('Master 2'); + should(output[1].date.value).equal('2015-12-02'); + should.not.exist(output[1]['master.rowid']); + should.not.exist(output[1]['master.__docid']); + done(); + }) + .catch(done); + }); + it('with orderBy', function(done) { + execPlan( + p.fromView('opticUnitTest', 'detail') + .orderBy([p.schemaCol('opticUnitTest', 'detail', 'masterId'), + p.schemaCol('opticUnitTest', 'detail', 'id')]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(6); + testValue(output[0], 'detail.id', 1); + testValue(output[0], 'detail.masterId', 1); + testValue(output[1], 'detail.id', 3); + testValue(output[1], 'detail.masterId', 1); + testValue(output[2], 'detail.id', 5); + testValue(output[2], 'detail.masterId', 1); + testValue(output[3], 'detail.id', 2); + testValue(output[3], 'detail.masterId', 2); + testValue(output[4], 'detail.id', 4); + testValue(output[4], 'detail.masterId', 2); + testValue(output[5], 'detail.id', 6); + testValue(output[5], 'detail.masterId', 2); + done(); + }) + .catch(done); + }); + it('with groupBy', function(done) { + execPlan( + p.fromView('opticUnitTest', 'detail') + .groupBy(p.schemaCol('opticUnitTest', 'detail', 'masterId'), + p.count('detailCount', p.schemaCol('opticUnitTest', 'detail', 'id'))) + .orderBy([p.schemaCol('opticUnitTest', 'detail', 'masterId')]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + testValue(output[0], 'detail.masterId', 1); + should(output[0].detailCount.value).equal(3); + testValue(output[1], 'detail.masterId', 2); + should(output[1].detailCount.value).equal(3); + done(); + }) + .catch(done); + }); + it('with offsetLimit', function(done) { + execPlan( + p.fromView('opticUnitTest', 'detail') + .orderBy(p.schemaCol('opticUnitTest', 'detail', 'id')) + .offsetLimit(1, 2) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + testValue(output[0], 'detail.id', 2); + testValue(output[0], 'detail.masterId', 2); + testValue(output[1], 'detail.id', 3); + testValue(output[1], 'detail.masterId', 1); + done(); + }) + .catch(done); + }); + }); + describe('composers', function() { + it('with inner join', function(done) { + execPlan( + p.fromView('opticUnitTest', 'master') + .joinInner( + p.fromView('opticUnitTest', 'detail'), + p.on(p.schemaCol('opticUnitTest', 'master', 'id'), + p.schemaCol('opticUnitTest', 'detail', 'masterId')) + ) + .orderBy([p.schemaCol('opticUnitTest', 'master', 'id'), + p.schemaCol('opticUnitTest', 'detail', 'id')]) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(6); + testValue(output[0], 'master.id', 1); + testValue(output[0], 'master.name', 'Master 1'); + testValue(output[0], 'master.date', '2015-12-01'); + testValue(output[0], 'detail.id', 1); + testValue(output[0], 'detail.name', 'Detail 1'); + testValue(output[0], 'detail.amount', 10.01); + testValue(output[0], 'detail.color', 'blue'); + testValue(output[1], 'master.id', 1); + testValue(output[1], 'master.date', '2015-12-01'); + testValue(output[1], 'detail.id', 3); + testValue(output[1], 'detail.name', 'Detail 3'); + testValue(output[1], 'detail.amount', 30.03); + testValue(output[1], 'detail.color', 'blue'); + testValue(output[2], 'master.id', 1); + testValue(output[2], 'master.date', '2015-12-01'); + testValue(output[2], 'detail.id', 5); + testValue(output[2], 'detail.name', 'Detail 5'); + testValue(output[2], 'detail.amount', 50.05); + testValue(output[2], 'detail.color', 'green'); + testValue(output[3], 'master.id', 2); + testValue(output[3], 'master.name', 'Master 2'); + testValue(output[3], 'master.date', '2015-12-02'); + testValue(output[3], 'detail.id', 2); + testValue(output[3], 'detail.name', 'Detail 2'); + testValue(output[3], 'detail.amount', 20.02); + testValue(output[3], 'detail.color', 'blue'); + testValue(output[4], 'master.id', 2); + testValue(output[4], 'master.name', 'Master 2'); + testValue(output[4], 'master.date', '2015-12-02'); + testValue(output[4], 'detail.id', 4); + testValue(output[4], 'detail.name', 'Detail 4'); + testValue(output[4], 'detail.amount', 40.04); + testValue(output[4], 'detail.color', 'green'); + testValue(output[5], 'master.id', 2); + testValue(output[5], 'master.name', 'Master 2'); + testValue(output[5], 'master.date', '2015-12-02'); + testValue(output[5], 'detail.id', 6); + testValue(output[5], 'detail.name', 'Detail 6'); + testValue(output[5], 'detail.amount', 60.06); + testValue(output[5], 'detail.color', 'green'); + done(); + }) + .catch(done); + }); + it('with union', function(done) { + execPlan( + p.fromView('opticUnitTest', 'master') + .select([p.as('unionName', p.schemaCol('opticUnitTest', 'master', 'name')), + p.as('unionId', p.schemaCol('opticUnitTest', 'master', 'id'))]) + .union( + p.fromView('opticUnitTest', 'detail') + .select([p.as('unionName', p.schemaCol('opticUnitTest', 'detail', 'name')), + p.as('unionId', p.schemaCol('opticUnitTest', 'detail', 'id'))]) + ) + .orderBy(['unionName', 'unionId']) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(8); + should(output[0].unionId.value).equal(1); + should(output[0].unionName.value).equal('Detail 1'); + should(output[1].unionId.value).equal(2); + should(output[1].unionName.value).equal('Detail 2'); + should(output[2].unionId.value).equal(3); + should(output[2].unionName.value).equal('Detail 3'); + should(output[3].unionId.value).equal(4); + should(output[3].unionName.value).equal('Detail 4'); + should(output[4].unionId.value).equal(5); + should(output[4].unionName.value).equal('Detail 5'); + should(output[5].unionId.value).equal(6); + should(output[5].unionName.value).equal('Detail 6'); + should(output[6].unionId.value).equal(1); + should(output[6].unionName.value).equal('Master 1'); + should(output[7].unionId.value).equal(2); + should(output[7].unionName.value).equal('Master 2'); + done(); + }) + .catch(done); + }); + it('with intersect', function(done) { + execPlan( + p.fromView('opticUnitTest', 'master') + .select([p.as('unionId', p.schemaCol('opticUnitTest', 'master', 'id'))]) + .intersect( + p.fromView('opticUnitTest', 'detail') + .select([p.as('unionId', p.schemaCol('opticUnitTest', 'detail', 'id'))]) + ) + .orderBy('unionId') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + should(output[0].unionId.value).equal(1); + should(output[1].unionId.value).equal(2); + done(); + }) + .catch(done); + }); + it('with except', function(done) { + execPlan( + p.fromView('opticUnitTest', 'detail') + .select([p.as('unionId', p.schemaCol('opticUnitTest', 'detail', 'id'))]) + .except( + p.fromView('opticUnitTest', 'master') + .select([p.as('unionId', p.schemaCol('opticUnitTest', 'master', 'id'))]) + ) + .orderBy('unionId') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(4); + should(output[0].unionId.value).equal(3); + should(output[1].unionId.value).equal(4); + should(output[2].unionId.value).equal(5); + should(output[3].unionId.value).equal(6); + done(); + }) + .catch(done); + }); + }); + describe('for view and triples', function() { + it('with inner join', function(done) { + const datastore = p.col('datastore'); + const master = p.col('master'); + const masterId = p.col('masterId'); + const datastoreType = p.sem.iri('http://purl.org/dc/dcmitype/Dataset'); + const dc = p.prefixer('http://purl.org/dc/terms/'); + const typeProp = dc('type'); + const titleProp = dc('title'); + const sourceProp = dc('source'); + const idProp = dc('identifier'); + const descProp = dc('description'); + execPlan( + p.fromView('opticUnitTest', 'master') + .joinInner( + p.fromTriples([ + p.pattern(datastore, typeProp, datastoreType), + p.pattern(datastore, titleProp, p.col('datastoreTitle')), + p.pattern(master, sourceProp, p.col('datastore')), + p.pattern(master, idProp, masterId), + p.pattern(datastore, descProp, p.col('masterDesc')) + ], + null), + p.on(p.schemaCol('opticUnitTest', 'master', 'id'), masterId) + ) + .orderBy(masterId) + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(2); + testValue(output[0], 'master.id', 1); + testValue(output[0], 'master.name', 'Master 1'); + testValue(output[0], 'master.date', '2015-12-01'); + should(output[0].datastore.value).equal('/datastore/id#A'); + should(output[0].datastoreTitle.value).equal('The A datastore'); + should(output[0].masterDesc.value).equal('Describing A'); + testValue(output[1], 'master.id', 2); + testValue(output[1], 'master.name', 'Master 2'); + testValue(output[1], 'master.date', '2015-12-02'); + should(output[1].datastore.value).equal('/datastore/id#B'); + should(output[1].datastoreTitle.value).equal('The B datastore'); + should(output[1].masterDesc.value).equal('Describing B'); + done(); + }) + .catch(done); + }); + }); + describe('from SQL', function() { + it('basic', function(done) { + execPlan( + p.fromSQL('SELECT id, name, date FROM master WHERE id = 1') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + testValue(output[0], 'master.id', 1); + testValue(output[0], 'master.name', 'Master 1'); + testValue(output[0], 'master.date', '2015-12-01'); + done(); + }) + .catch(done); + }); + it('with qualifier', function(done) { + execPlan( + p.fromSQL('SELECT id, name, date FROM master WHERE id = 1', 'sqlsel') + ) + .then(function(response) { + const output = getResults(response); + should(output.length).equal(1); + should(output[0]['sqlsel.id'].value).equal(1); + should(output[0]['sqlsel.name'].value).equal('Master 1'); + should(output[0]['sqlsel.date'].value).equal('2015-12-01'); + done(); + }) + .catch(done); + }); + }); + describe('serialize', function() { + it('export', function(done) { + const value = + p.fromView('opticUnitTest', 'master') + .orderBy('id') + .export(); + should(value).deepEqual(exportedView); + done(); + }); + it('export query', function(done) { + const value = + p.fromView('opticUnitTest', 'musician') + .where(p.cts.jsonPropertyWordQuery('instrument', 'trumpet')) + .orderBy('lastName') + .export(); + should(value).deepEqual(exportedQueryView); + done(); + }); + it('export from SQL', function(done) { + const value = + p.fromSQL('SELECT id, name, date FROM master WHERE id = 1') + .export(); + should(value).deepEqual(exportedFromSQL); + done(); + }); + }); +/* TODO: + * schema collection for view + * export for view with query + */ +}); diff --git a/test-basic/probe.js b/test-basic/probe.js index ccb5d6a7..293aa889 100644 --- a/test-basic/probe.js +++ b/test-basic/probe.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/query-builder.js b/test-basic/query-builder.js index 7902ad89..38836c22 100644 --- a/test-basic/query-builder.js +++ b/test-basic/query-builder.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/removeAll.js b/test-basic/removeAll.js index 550e82f3..1de8707b 100644 --- a/test-basic/removeAll.js +++ b/test-basic/removeAll.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/resources-config.js b/test-basic/resources-config.js index 512a4fb6..01bb9722 100644 --- a/test-basic/resources-config.js +++ b/test-basic/resources-config.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/resources-exec.js b/test-basic/resources-exec.js index 45f0585f..34143dfb 100644 --- a/test-basic/resources-exec.js +++ b/test-basic/resources-exec.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -159,7 +159,7 @@ describe('when executing resource services', function(){ }) .catch(done); }); - // TODO: formats, multiple, single, or empty response, chunked streams, JavaScript resource services + // TODO: formats, multiple, single, or empty response, chunked streams, JavaScript resource services }); describe('using JavaScript', function() { var jsServiceName = 'versionService'; diff --git a/test-basic/rest-server-properties.js b/test-basic/rest-server-properties.js index 3e60fc74..4821525b 100644 --- a/test-basic/rest-server-properties.js +++ b/test-basic/rest-server-properties.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-basic/rows.js b/test-basic/rows.js new file mode 100644 index 00000000..82a250ac --- /dev/null +++ b/test-basic/rows.js @@ -0,0 +1,408 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const should = require('should'), + fs = require('fs'), + valcheck = require('core-util-is') + eol = require('os').EOL; + +const testconfig = require('../etc/test-config.js'); + +const marklogic = require('../'); + +const planPath = './test-basic/data/literals.json'; +const planPathBindings = './test-basic/data/literalsBindings.json'; +const planPathAttachments = './test-basic/data/literalsAttachments.json'; +const planPathBinaryAttachments = './test-basic/data/literalsBinaryAttachments.json'; + +const db = marklogic.createDatabaseClient(testconfig.restWriterConnection); +//db.setLogger('debug'); + +const p = marklogic.planBuilder; + +describe('rows', function(){ + + const planFromJSON = fs.readFileSync(planPath, 'utf8'); + const planFromJSONBindings = fs.readFileSync(planPathBindings, 'utf8'); + const planFromJSONAttachments = fs.readFileSync(planPathAttachments, 'utf8'); + const planFromJSONBinaryAttachments = fs.readFileSync(planPathBinaryAttachments, 'utf8'); + const planFromBuilder = p.fromLiterals([ + {"id": 1,"name": "Master 1","date": "2015-12-01"}, + {"id": 2,"name": "Master 2","date": "2015-12-02"}, + {"id": 3,"name": "Master 3","date": "2015-12-03"}, + ]) + .where(p.gt(p.col('id'), 1)); + + describe('read as a promise', function(){ + + it('as a JSON object using plan builder object', function(){ + return db.rows.query(planFromBuilder) + .then(function (response) { + //console.log(response); + valcheck.isObject(response).should.equal(true); + valcheck.isArray(response).should.equal(false); + response.should.have.property('columns'); + }); + }); + + it('as a JSON object using JSON plan', function(){ + return db.rows.query(planFromJSON) + .then(function(response) { + //console.log(JSON.stringify(response, null, 2)); + valcheck.isObject(response).should.equal(true); + valcheck.isArray(response).should.equal(false); + }); + }); + + it('as a JSON array', function(){ + return db.rows.query(planFromJSON, {format: 'json', structure: 'array'}) + .then(function(response) { + //console.log(JSON.stringify(response, null, 2)); + valcheck.isArray(response).should.equal(true); + }); + }); + + it('as a JSON object with header column types', function(){ + return db.rows.query(planFromJSON, {format: 'json', columnTypes: 'header'}) + .then(function(response) { + //console.log(JSON.stringify(response, null, 2)); + valcheck.isObject(response).should.equal(true); + valcheck.isArray(response).should.equal(false); + response.should.have.property('columns'); + const cols = response['columns']; + valcheck.isArray(cols).should.equal(true);; + cols[0].should.have.property('name'); + cols[0].should.have.property('type'); + }); + }); + + it('as a JSON object with bindings', function(){ + return db.rows.query(planFromJSONBindings, { + format: 'json', + bindings: { + 'limit': {value: 2, type: 'integer'}, + 'foo': {value: 'bar', lang: 'en'} + } + }) + .then(function(response) { + //console.log(response); + valcheck.isObject(response).should.equal(true); + valcheck.isArray(response).should.equal(false); + response.should.have.property('columns'); + response.should.have.property('rows'); + response['rows'].length.should.equal(1); + }); + }); + + it('as an XML string', function(){ + return db.rows.query(planFromJSON, {format: 'xml', columnsTypes: 'rows'}) + .then(function(response) { + //console.log(response); + valcheck.isString(response).should.equal(true); + response.should.startWith('{ $constraint/@name, - for $directory in + for $directory in let $dir-array := json:array() return ( json:array-push($dir-array,"/"), @@ -81,7 +81,7 @@ as element(search:facet) return { attribute name {$directory}, - attribute count { + attribute count { xdmp:estimate(cts:search(collection(),cts:and-query( ($query, cts:directory-query($directory,"infinity")) )))}, diff --git a/test-complete/data/emptyTransform.js b/test-complete/data/emptyTransform.js index 0c8bd4f1..5c290759 100644 --- a/test-complete/data/emptyTransform.js +++ b/test-complete/data/emptyTransform.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-complete/data/extractFirst.xqy b/test-complete/data/extractFirst.xqy index 7c95b3c9..fb45d352 100644 --- a/test-complete/data/extractFirst.xqy +++ b/test-complete/data/extractFirst.xqy @@ -1,7 +1,7 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ module namespace extractFirst = "http://marklogic.com/snippet/custom/extractFirs import module namespace json="http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy"; - + declare namespace search = "http://marklogic.com/appservices/search"; declare namespace jsonbasic = "http://marklogic.com/xdmp/json/basic"; @@ -29,7 +29,7 @@ declare option xdmp:mapping "false"; declare function extractFirst:snippet( $result as node(), - $ctsquery as schema-element(cts:query), + $ctsquery as schema-element(cts:query), $transform as element(search:transform-results)) as element(search:snippet) { diff --git a/test-complete/data/flagTransform.xqy b/test-complete/data/flagTransform.xqy index c35b7cc2..1a2ddfd9 100644 --- a/test-complete/data/flagTransform.xqy +++ b/test-complete/data/flagTransform.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-complete/data/objectify.xqy b/test-complete/data/objectify.xqy index 2ea3525e..5644f736 100644 --- a/test-complete/data/objectify.xqy +++ b/test-complete/data/objectify.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ xquery version "1.0-ml"; : See the License for the specific language governing permissions and : limitations under the License. :) - + module namespace objectify = "http://marklogic.com/patch/apply/objectify"; declare default function namespace "http://www.w3.org/2005/xpath-functions"; diff --git a/test-complete/data/paramTransform.js b/test-complete/data/paramTransform.js index 0a9c62ea..0f53721a 100644 --- a/test-complete/data/paramTransform.js +++ b/test-complete/data/paramTransform.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ function paramTransform(context, params, document) { var intValue = params.myInt; var boolValue = params.myBool == 'true'; newDoc.title = newTitle; - newDoc.intKey = parseInt(intValue); + newDoc.intKey = parseInt(intValue); newDoc.boolKey = boolValue; return newDoc; } diff --git a/test-complete/data/sourceParams.js b/test-complete/data/sourceParams.js index 09f7099f..04a2bccc 100644 --- a/test-complete/data/sourceParams.js +++ b/test-complete/data/sourceParams.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + var num1; var num2; num1 + num2; diff --git a/test-complete/data/sourceParams.xqy b/test-complete/data/sourceParams.xqy index 365413fe..cb7612c5 100644 --- a/test-complete/data/sourceParams.xqy +++ b/test-complete/data/sourceParams.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-complete/data/sourceParamsNegative.js b/test-complete/data/sourceParamsNegative.js index d07cc87f..746cc0f8 100644 --- a/test-complete/data/sourceParamsNegative.js +++ b/test-complete/data/sourceParamsNegative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + avar num1; var num2; num1 + num2; diff --git a/test-complete/data/sourceParamsNegative.xqy b/test-complete/data/sourceParamsNegative.xqy index ddea5a10..434b1b1e 100644 --- a/test-complete/data/sourceParamsNegative.xqy +++ b/test-complete/data/sourceParamsNegative.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-complete/data/sourceSimple.js b/test-complete/data/sourceSimple.js index 70a17950..15203f7c 100644 --- a/test-complete/data/sourceSimple.js +++ b/test-complete/data/sourceSimple.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + var a = "hello"; var b = "world"; a.concat(b); diff --git a/test-complete/data/sourceSimple.xqy b/test-complete/data/sourceSimple.xqy index e3642d03..ab37a124 100644 --- a/test-complete/data/sourceSimple.xqy +++ b/test-complete/data/sourceSimple.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-complete/data/sourceSimpleNegative.js b/test-complete/data/sourceSimpleNegative.js index 66dd0bcc..dc1e77c2 100644 --- a/test-complete/data/sourceSimpleNegative.js +++ b/test-complete/data/sourceSimpleNegative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-complete/data/sourceSimpleNegative.xqy b/test-complete/data/sourceSimpleNegative.xqy index d3275df3..ab3c58ac 100644 --- a/test-complete/data/sourceSimpleNegative.xqy +++ b/test-complete/data/sourceSimpleNegative.xqy @@ -1,6 +1,6 @@ xquery version "1.0-ml"; (: - : Copyright 2014-2017 MarkLogic Corporation + : Copyright 2014-2018 MarkLogic Corporation : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. diff --git a/test-complete/data/timestampTransform.js b/test-complete/data/timestampTransform.js index 5b64ea2a..8b9b39f6 100644 --- a/test-complete/data/timestampTransform.js +++ b/test-complete/data/timestampTransform.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-complete/nodejs-config-patch-negative.js b/test-complete/nodejs-config-patch-negative.js index 3b1dc1f0..400b326b 100644 --- a/test-complete/nodejs-config-patch-negative.js +++ b/test-complete/nodejs-config-patch-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,15 +31,15 @@ var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Config patch negative test', function(){ var replaceModule = 'objectify.xqy'; - var replacePath = './node-client-api/test-complete/data/objectify.xqy'; + var replacePath = __dirname + '/data/objectify.xqy'; var replaceModuleInvalid = 'objectifyInvalid.xqy'; - var replacePathInvalid = './node-client-api/test-complete/data/objectifyInvalid.xqy'; + var replacePathInvalid = __dirname + '/data/objectifyInvalid.xqy'; it('should fail to write replacement library with reader user', function(done){ this.timeout(10000); db.config.patch.replace.write( - replaceModule, - [{'role-name':'app-user', capabilities:['execute']}], + replaceModule, + [{'role-name':'app-user', capabilities:['execute']}], fs.createReadStream(replacePath)). result(function(response) { response.should.equal('SHOULD HAVE FAILED'); @@ -76,8 +76,8 @@ describe('Config patch negative test', function(){ it('should write document for test', function(done){ dbWriter.documents.write({ - uri: '/test/config/patch/replace/negative/patchReplaceNegative1.json', - collections: ['patchReplaceCollection'], + uri: '/test/config/patch/replace/negative/patchReplaceNegative1.json', + collections: ['patchReplaceCollection'], contentType: 'application/json', content: { title: 'this is patch replace' diff --git a/test-complete/nodejs-config-patch.js b/test-complete/nodejs-config-patch.js index d162d013..d555976a 100644 --- a/test-complete/nodejs-config-patch.js +++ b/test-complete/nodejs-config-patch.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,13 +31,13 @@ var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Config patch test', function(){ var replaceModule = 'objectify.xqy'; - var replacePath = './node-client-api/test-complete/data/objectify.xqy'; + var replacePath = __dirname + '/data/objectify.xqy'; it('should write the replacement library', function(done){ this.timeout(10000); dbAdmin.config.patch.replace.write( - replaceModule, - [{'role-name':'app-user', capabilities:['execute']}], + replaceModule, + [{'role-name':'app-user', capabilities:['execute']}], fs.createReadStream(replacePath)). result(function(response){ //console.log(response); @@ -55,7 +55,7 @@ describe('Config patch test', function(){ done(); }, done); }); - + it('should list the replacement library', function(done){ dbAdmin.config.patch.replace.list(). result(function(response){ @@ -87,8 +87,8 @@ describe('Config patch test', function(){ it('should write the replacement library for the test', function(done){ this.timeout(10000); dbAdmin.config.patch.replace.write( - replaceModule, - [{'role-name':'app-user', capabilities:['execute']}], + replaceModule, + [{'role-name':'app-user', capabilities:['execute']}], fs.createReadStream(replacePath)). result(function(response){ done(); @@ -97,8 +97,8 @@ describe('Config patch test', function(){ it('should write document for test', function(done){ dbWriter.documents.write({ - uri: '/test/config/patch/replace/patchReplace1.json', - collections: ['patchReplaceCollection'], + uri: '/test/config/patch/replace/patchReplace1.json', + collections: ['patchReplaceCollection'], contentType: 'application/json', content: { title: 'this is patch replace' diff --git a/test-complete/nodejs-config-query-negative.js b/test-complete/nodejs-config-query-negative.js index 30a4c560..4e0c48d6 100644 --- a/test-complete/nodejs-config-query-negative.js +++ b/test-complete/nodejs-config-query-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,14 +32,14 @@ describe('Config query negative test', function(){ var dbDir = '/marklogic/query/invalid/custom/'; var dbModule = 'directoryConstraintInvalid.xqy'; var dbPath = dbDir + dbModule; - var fsPath = './node-client-api/test-complete/data/directoryConstraintInvalid.xqy'; + var fsPath = __dirname + '/data/directoryConstraintInvalid.xqy'; it('should fail to write the custom query with reader user', function(done){ this.timeout(10000); db.config.query.custom.write( - 'directoryConstraint.xqy', - [{'role-name':'app-user', capabilities:['execute']}], - fs.createReadStream('./node-client-api/test-complete/data/directoryConstraint.xqy')). + 'directoryConstraint.xqy', + [{'role-name':'app-user', capabilities:['execute']}], + fs.createReadStream(__dirname + '/data/directoryConstraint.xqy')). result(function(response) { response.should.equal('SHOULD HAVE FAILED'); done(); diff --git a/test-complete/nodejs-config-query.js b/test-complete/nodejs-config-query.js index e2c26a03..7cd85cd0 100644 --- a/test-complete/nodejs-config-query.js +++ b/test-complete/nodejs-config-query.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,13 +32,13 @@ describe('Config query test', function(){ var dbDir = '/marklogic/query/custom/'; var dbModule = 'directoryConstraint.xqy'; var dbPath = dbDir + dbModule; - var fsPath = './node-client-api/test-complete/data/directoryConstraint.xqy'; + var fsPath = __dirname + '/data/directoryConstraint.xqy'; it('should write the custom query', function(done){ this.timeout(10000); dbAdmin.config.query.custom.write( - dbModule, - [{'role-name':'app-user', capabilities:['execute']}], + dbModule, + [{'role-name':'app-user', capabilities:['execute']}], fs.createReadStream(fsPath)). result(function(response){ //console.log(response); @@ -56,7 +56,7 @@ describe('Config query test', function(){ done(); }, done); }); - + it('should list the custom query', function(done){ dbAdmin.config.query.custom.list(). result(function(response){ @@ -89,8 +89,8 @@ describe('Config query test', function(){ it('should write the custom query for test', function(done){ this.timeout(10000); dbAdmin.config.query.custom.write( - dbModule, - [{'role-name':'app-user', capabilities:['execute']}], + dbModule, + [{'role-name':'app-user', capabilities:['execute']}], fs.createReadStream(fsPath)). result(function(response){ done(); @@ -99,8 +99,8 @@ describe('Config query test', function(){ it('should write document for test', function(done){ dbWriter.documents.write({ - uri: '/test/custom/query/customQuery1.json', - collections: ['customCollection'], + uri: '/test/custom/query/customQuery1.json', + collections: ['customCollection'], contentType: 'application/json', content: { title: 'this is custom query' diff --git a/test-complete/nodejs-database-concurrency.js b/test-complete/nodejs-database-concurrency.js index eb9b1355..7fe06605 100644 --- a/test-complete/nodejs-database-concurrency.js +++ b/test-complete/nodejs-database-concurrency.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Database Concurrency Test', function() { - + it('should write the document using db1 conn and overwrite using db2 conn', function(done) { db1.documents.write({ uri: '/test/dbconn/test1.json', @@ -40,7 +40,7 @@ describe('Database Concurrency Test', function() { contentType: 'application/json', content: { title: 'second conn' - } + } }). result(function(response) { done(); @@ -53,7 +53,7 @@ describe('Database Concurrency Test', function() { uris: '/test/dbconn/test1.json' }). result(function(response) { - //console.log(response); + //console.log(response); response[0].content.title.should.equal('second conn'); db2.documents.probe({ uri: '/test/dbconn/test1.json' diff --git a/test-complete/nodejs-database-connection-negative.js b/test-complete/nodejs-database-connection-negative.js index 0534cedf..9eafd7f7 100644 --- a/test-complete/nodejs-database-connection-negative.js +++ b/test-complete/nodejs-database-connection-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-complete/nodejs-database-connection-ssl.js b/test-complete/nodejs-database-connection-ssl.js index b0e312ee..aebf299b 100644 --- a/test-complete/nodejs-database-connection-ssl.js +++ b/test-complete/nodejs-database-connection-ssl.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,10 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbSsl = marklogic.createDatabaseClient(testconfig.restSslConnection); describe('SSL Test', function() { - - var docuri = '/foo/bar/test1.json'; - var docuri2 = '/foo/bar/test2.json'; - + + var docuri = '/foo/bar/test1.json'; + var docuri2 = '/foo/bar/test2.json'; + before(function(done) { this.timeout(10000); dbSsl.documents.write({ @@ -89,7 +89,7 @@ describe('SSL Test', function() { collCount.should.equal(2); for(var i=0; i < collCount; i++) { document.collections[i].should.equal('coll' + i); - } + } done(); }, done); }); diff --git a/test-complete/nodejs-documents-binary-gif.js b/test-complete/nodejs-documents-binary-gif.js index 817b910d..4f185906 100644 --- a/test-complete/nodejs-documents-binary-gif.js +++ b/test-complete/nodejs-documents-binary-gif.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('Binary documents test', function(){ - var fsPath = './node-client-api/test-complete/data/121-GIF-Image-GIF-gif_sample1.gif'; + var fsPath = __dirname + '/data/121-GIF-Image-GIF-gif_sample1.gif'; var uri = '/test/binary/stream/121-GIF-Image-GIF-gif_sample1.gif'; var binaryValue = null; @@ -46,7 +46,7 @@ describe('Binary documents test', function(){ //console.log(response); response.documents[0].uri.should.equal(uri); done(); - }, done); + }, done); }); it('should read the binary with Readable stream', function(done){ @@ -56,18 +56,18 @@ describe('Binary documents test', function(){ documents[0].content.should.not.equal(null); //console.log(documents); done(); - }, done); + }, done); }); - + it('should remove the document', function(done){ this.timeout(10000); dbWriter.documents.remove(uri). result(function(response) { response.should.be.ok; done(); - }, done); + }, done); }); - + }); diff --git a/test-complete/nodejs-documents-binary-mp3.js b/test-complete/nodejs-documents-binary-mp3.js index e6d68553..6ac3d1a9 100644 --- a/test-complete/nodejs-documents-binary-mp3.js +++ b/test-complete/nodejs-documents-binary-mp3.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ var dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Binary documents test', function(){ - var binaryPath = './node-client-api/test-complete/data/mediaCQ.mp3'; + var binaryPath = __dirname + '/data/mediaCQ.mp3'; var uri = '/test/binary/someMp3File.mp3'; var binaryValue = null; before(function(done){ @@ -40,7 +40,7 @@ describe('Binary documents test', function(){ pipe(concatStream({encoding: 'buffer'}, function(value){ binaryValue = value; done(); - })); + })); }); it('should write the binary with Readable stream', function(done){ @@ -56,7 +56,7 @@ describe('Binary documents test', function(){ result(function(response){ response.should.have.property('documents'); done(); - }, done); + }, done); }); it('should read the binary with Readable stream', function(done){ @@ -67,9 +67,9 @@ describe('Binary documents test', function(){ JSON.stringify(binaryValue).should.equal( JSON.stringify(documents[0].content)); done(); - }, done); + }, done); }); - + it('should delete mp3 file', function(done){ dbAdmin.documents.removeAll({ all: true @@ -77,7 +77,7 @@ describe('Binary documents test', function(){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-binary-pdf.js b/test-complete/nodejs-documents-binary-pdf.js index 97b90ddb..20207c98 100644 --- a/test-complete/nodejs-documents-binary-pdf.js +++ b/test-complete/nodejs-documents-binary-pdf.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ var dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Binary documents test', function(){ - var binaryPath = './node-client-api/test-complete/data/somePdfFile.pdf'; + var binaryPath = __dirname + '/data/somePdfFile.pdf'; var uri = '/test/binary/somePdfFile.pdf'; var binaryValue = null; before(function(done){ @@ -40,7 +40,7 @@ describe('Binary documents test', function(){ pipe(concatStream({encoding: 'buffer'}, function(value){ binaryValue = value; done(); - })); + })); }); it('should write the binary with Readable stream', function(done){ @@ -58,7 +58,7 @@ describe('Binary documents test', function(){ result(function(response){ response.should.have.property('documents'); done(); - }, done); + }, done); }); it('should read the binary with Readable stream', function(done){ @@ -70,7 +70,7 @@ describe('Binary documents test', function(){ JSON.stringify(binaryValue).should.equal( JSON.stringify(documents[0].content)); done(); - }, done); + }, done); }); it('should read the binary document metadata', function(done) { @@ -84,7 +84,7 @@ describe('Binary documents test', function(){ done(); }, done); }); - + it('should delete the pdf file', function(done){ dbAdmin.documents.removeAll({ all: true @@ -92,7 +92,7 @@ describe('Binary documents test', function(){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-binary-range.js b/test-complete/nodejs-documents-binary-range.js index b5608bb7..c1ae46e7 100644 --- a/test-complete/nodejs-documents-binary-range.js +++ b/test-complete/nodejs-documents-binary-range.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ var dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Binary documents test', function(){ - var binaryPath = './node-client-api/test-complete/data/mediaCQ.mp3'; + var binaryPath = __dirname + '/data/mediaCQ.mp3'; var uri = '/test/binary/range/someMp3File.mp3'; var binaryValue = null; before(function(done){ @@ -40,7 +40,7 @@ describe('Binary documents test', function(){ pipe(concatStream({encoding: 'buffer'}, function(value){ binaryValue = value; done(); - })); + })); }); it('should write the binary with Readable stream', function(done){ @@ -56,7 +56,7 @@ describe('Binary documents test', function(){ result(function(response){ response.should.have.property('documents'); done(); - }, done); + }, done); }); it('should read the binary with range', function(done){ @@ -67,7 +67,7 @@ describe('Binary documents test', function(){ //console.log(JSON.stringify(documents[0], null, 2)); JSON.stringify(documents[0].content[0]).should.equal('80'); done(); - }, done); + }, done); }); it('should read the binary with invalid range', function(done){ @@ -81,9 +81,9 @@ describe('Binary documents test', function(){ error.body.errorResponse.messageCode.should.equal('REST-INVALIDPARAM'); //console.log(JSON.stringify(error, null, 2)); done(); - }); + }); }); - + it('should read the binary with invalid float range', function(done){ this.timeout(10000); var uri = '/test/write/range/someMp3File.mp3'; @@ -95,7 +95,7 @@ describe('Binary documents test', function(){ error.body.errorResponse.messageCode.should.equal('REST-INVALIDPARAM'); //console.log(JSON.stringify(error, null, 2)); done(); - }); + }); }); it('should read the binary with reversed range', function(done){ @@ -111,7 +111,7 @@ describe('Binary documents test', function(){ //console.log(error.toString()); strError.should.equal('Error: start length greater than or equal to end length for byte range: 15,10'); done(); - } + } }); it('should read the binary without start range', function(done){ @@ -127,9 +127,9 @@ describe('Binary documents test', function(){ //console.log(error.toString()); strError.should.equal('Error: start length for byte range parameter is not integer: undefined'); done(); - } + } }); - + it('should delete mp3 file', function(done){ dbAdmin.documents.removeAll({ all: true @@ -137,7 +137,7 @@ describe('Binary documents test', function(){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-crud-negative.js b/test-complete/nodejs-documents-crud-negative.js index 094225c8..0c451d2d 100644 --- a/test-complete/nodejs-documents-crud-negative.js +++ b/test-complete/nodejs-documents-crud-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,7 +117,7 @@ describe('Document CRUD negative test', function(){ done(); }, function(error) { //console.log(error.body); - error.body.errorResponse.messageCode.should.equal('REST-FAILEDAUTH'); + error.body.errorResponse.messageCode.should.equal('SEC-PRIV'); error.statusCode.should.equal(403); done(); }); @@ -133,7 +133,7 @@ describe('Document CRUD negative test', function(){ done(); }, function(error) { //console.log(error); - error.body.errorResponse.messageCode.should.equal('REST-REQUIREDPARAM'); + error.body.errorResponse.messageCode.should.equal('RESTAPI-INVALIDREQ'); error.statusCode.should.equal(400); done(); }); diff --git a/test-complete/nodejs-documents-crud.js b/test-complete/nodejs-documents-crud.js index cc26433a..f2c7dbbb 100644 --- a/test-complete/nodejs-documents-crud.js +++ b/test-complete/nodejs-documents-crud.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,10 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); describe('Write Document Test', function() { - - var docuri = '/foo/bar/test1.json'; - var docuri2 = '/foo/bar/test2.json'; - + + var docuri = '/foo/bar/test1.json'; + var docuri2 = '/foo/bar/test2.json'; + before(function(done) { this.timeout(10000); db.documents.write({ @@ -50,7 +50,7 @@ describe('Write Document Test', function() { {'role-name':'app-builder', capabilities:['read', 'update']} ], properties: {prop1:'bar', prop2:33}, - content: {id:245, name:'Paul'} + content: {id:245, name:'Paul'} }).result(function(response){done();}, done); }); @@ -89,7 +89,7 @@ describe('Write Document Test', function() { collCount.should.equal(2); for(var i=0; i < collCount; i++) { document.collections[i].should.equal('coll' + i); - } + } done(); }, done); }); diff --git a/test-complete/nodejs-documents-extract-negative.js b/test-complete/nodejs-documents-extract-negative.js index a85c2cc6..23807b2a 100644 --- a/test-complete/nodejs-documents-extract-negative.js +++ b/test-complete/nodejs-documents-extract-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('extract negative test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('extract negative test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('extract negative test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -83,7 +83,7 @@ describe('extract negative test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -129,6 +129,6 @@ describe('extract negative test', function(){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-extract.js b/test-complete/nodejs-documents-extract.js index 9a8954d5..5ed5af59 100644 --- a/test-complete/nodejs-documents-extract.js +++ b/test-complete/nodejs-documents-extract.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document extract test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('Document extract test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('Document extract test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -83,7 +83,7 @@ describe('Document extract test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -167,7 +167,7 @@ describe('Document extract test', function(){ '/node("id")' ] }) - ).withOptions({search: ['filtered']}) + ).withOptions({search: ['filtered']}) ).result(function(response) { response.length.should.equal(1); response[0].content.should.have.property('context'); @@ -231,7 +231,7 @@ describe('Document extract test', function(){ result(function(response) { done(); }, done); - }); + }); /*it('should do extract with back level up', function(done){ db.documents.query( q.where( diff --git a/test-complete/nodejs-documents-metadata-values.js b/test-complete/nodejs-documents-metadata-values.js index 9409d74f..0fa55df6 100644 --- a/test-complete/nodejs-documents-metadata-values.js +++ b/test-complete/nodejs-documents-metadata-values.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ describe('Document Metadata values test', function() { contentType: 'application/json', quality: 250, properties: { - prop1:'bar', + prop1:'bar', prop2:1981 }, metadataValues: { @@ -45,20 +45,20 @@ describe('Document Metadata values test', function() { metaDateTime: '2011-12-31T23:59:59' }, content: { - id: '0001', + id: '0001', name:'bowl' } }). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response.documents[0].uri.should.equal('/test/metadata/values/doc1.json'); + response.documents[0].uri.should.equal('/test/metadata/values/doc1.json'); done(); }, done); }); it('TEST 2 - read the content and metadata values', function(done) { db.documents.read({ - uris: ['/test/metadata/values/doc1.json'], + uris: ['/test/metadata/values/doc1.json'], categories:['content', 'metadataValues'] }).result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); @@ -73,7 +73,7 @@ describe('Document Metadata values test', function() { it('TEST 3 - insert patch on metadata values', function(done) { db.documents.patch({ - uri: '/test/metadata/values/doc1.json', + uri: '/test/metadata/values/doc1.json', categories:['metadataValues'], operations: [ p.insert('metadataValues', 'last-child', {meta6: 'added patch'}) @@ -87,7 +87,7 @@ describe('Document Metadata values test', function() { it('TEST 4 - read the patched metadata values', function(done) { db.documents.read({ - uris: ['/test/metadata/values/doc1.json'], + uris: ['/test/metadata/values/doc1.json'], categories:['metadataValues'] }).result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); @@ -98,7 +98,7 @@ describe('Document Metadata values test', function() { it('TEST 5 - remove patch on metadata values', function(done) { db.documents.patch({ - uri: '/test/metadata/values/doc1.json', + uri: '/test/metadata/values/doc1.json', categories:['metadataValues'], operations: [ p.remove('meta6') @@ -112,7 +112,7 @@ describe('Document Metadata values test', function() { it('TEST 6 - read the patched metadata values', function(done) { db.documents.read({ - uris: ['/test/metadata/values/doc1.json'], + uris: ['/test/metadata/values/doc1.json'], categories:['metadataValues'] }).result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); @@ -123,7 +123,7 @@ describe('Document Metadata values test', function() { it('TEST 7 - insert patch on existing metadata values', function(done) { db.documents.patch({ - uri: '/test/metadata/values/doc1.json', + uri: '/test/metadata/values/doc1.json', categories:['metadataValues'], operations: [ p.insert('metadataValues', 'last-child', {meta1: 'this is the date'}) @@ -137,7 +137,7 @@ describe('Document Metadata values test', function() { it('TEST 8 - read the patched metadata values', function(done) { db.documents.read({ - uris: ['/test/metadata/values/doc1.json'], + uris: ['/test/metadata/values/doc1.json'], categories:['metadataValues'] }).result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); @@ -148,7 +148,7 @@ describe('Document Metadata values test', function() { it('TEST 9 - add patch on metadataValues', function(done) { db.documents.patch({ - uri: '/test/metadata/values/doc1.json', + uri: '/test/metadata/values/doc1.json', categories:['metadataValues'], operations: [ p.metadataValues.add('metaAddNumber', '123.456'), @@ -163,7 +163,7 @@ describe('Document Metadata values test', function() { it('TEST 10 - read the added patch metadata values', function(done) { db.documents.read({ - uris: ['/test/metadata/values/doc1.json'], + uris: ['/test/metadata/values/doc1.json'], categories:['metadataValues'] }).result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); @@ -175,7 +175,7 @@ describe('Document Metadata values test', function() { it('TEST 11 - replace patch on metadataValues', function(done) { db.documents.patch({ - uri: '/test/metadata/values/doc1.json', + uri: '/test/metadata/values/doc1.json', categories:['metadataValues'], operations: [ p.metadataValues.replace('metaAddNumber', '678.999'), @@ -190,7 +190,7 @@ describe('Document Metadata values test', function() { it('TEST 12 - read the replaced patch metadata values', function(done) { db.documents.read({ - uris: ['/test/metadata/values/doc1.json'], + uris: ['/test/metadata/values/doc1.json'], categories:['metadataValues'] }).result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); @@ -203,7 +203,7 @@ describe('Document Metadata values test', function() { it('TEST 13 - negative: non-string on values', function(done) { try { db.documents.patch({ - uri: '/test/metadata/values/doc1.json', + uri: '/test/metadata/values/doc1.json', categories:['metadataValues'], operations: [ p.metadataValues.add('metaNegNonString', 1001.6789) @@ -222,7 +222,7 @@ describe('Document Metadata values test', function() { it('TEST 14 - negative: non-string on names', function(done) { try { db.documents.patch({ - uri: '/test/metadata/values/doc1.json', + uri: '/test/metadata/values/doc1.json', categories:['metadataValues'], operations: [ p.metadataValues.add(negativeMeta, 'invValues') @@ -268,7 +268,7 @@ describe('Document Metadata values test', function() { it('TEST 16 - read the content and metadata values', function(done) { db.documents.read({ - uris: ['/test/metadata/values/doc2.json'], + uris: ['/test/metadata/values/doc2.json'], categories:['content', 'metadataValues'] }).result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); diff --git a/test-complete/nodejs-documents-parse-2.js b/test-complete/nodejs-documents-parse-2.js index 2840268f..853b0db3 100644 --- a/test-complete/nodejs-documents-parse-2.js +++ b/test-complete/nodejs-documents-parse-2.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ describe('Document parse binding test 2', function(){ var dbDir = '/marklogic/query/custom/constaint/'; var dbModule = 'directoryConstraint.xqy'; var dbPath = dbDir+dbModule; - var fsPath = './node-client-api/test-complete/data/directoryConstraint.xqy'; + var fsPath = __dirname + '/data/directoryConstraint.xqy'; before(function(done){ this.timeout(10000); @@ -49,7 +49,7 @@ describe('Document parse binding test 2', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -63,7 +63,7 @@ describe('Document parse binding test 2', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -77,7 +77,7 @@ describe('Document parse binding test 2', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -91,7 +91,7 @@ describe('Document parse binding test 2', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -117,8 +117,8 @@ describe('Document parse binding test 2', function(){ it('should write the custom query for test', function(done){ this.timeout(10000); dbAdmin.config.query.custom.write( - dbModule, - [{'role-name':'app-user', capabilities:['execute']}], + dbModule, + [{'role-name':'app-user', capabilities:['execute']}], fs.createReadStream(fsPath)). result(function(response){ done(); @@ -141,7 +141,7 @@ describe('Document parse binding test 2', function(){ done(); }, done); }); - + it('should do function parse', function(done){ dbWriter.documents.query( q.where( diff --git a/test-complete/nodejs-documents-parse.js b/test-complete/nodejs-documents-parse.js index fa6126b3..09634608 100644 --- a/test-complete/nodejs-documents-parse.js +++ b/test-complete/nodejs-documents-parse.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document parse binding test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('Document parse binding test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('Document parse binding test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -85,7 +85,7 @@ describe('Document parse binding test', function(){ booleanVal: false, nullVal: 'not null' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -211,7 +211,7 @@ describe('Document parse binding test', function(){ done(); }, done); }); - + it('should do complex parse', function(done){ db.documents.query( q.where( @@ -341,5 +341,5 @@ describe('Document parse binding test', function(){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-patch-2.js b/test-complete/nodejs-documents-patch-2.js index d2eceef9..9a4b41c8 100755 --- a/test-complete/nodejs-documents-patch-2.js +++ b/test-complete/nodejs-documents-patch-2.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ describe('document patch test 2', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -57,7 +57,7 @@ describe('document patch test 2', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -71,7 +71,7 @@ describe('document patch test 2', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -85,7 +85,7 @@ describe('document patch test 2', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -300,5 +300,5 @@ describe('document patch test 2', function(){ done(); }, done); }); - + }); diff --git a/test-complete/nodejs-documents-patch-datatypes.js b/test-complete/nodejs-documents-patch-datatypes.js index 35c40b5c..f56a6066 100644 --- a/test-complete/nodejs-documents-patch-datatypes.js +++ b/test-complete/nodejs-documents-patch-datatypes.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,13 +31,13 @@ var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('patch datatypes test', function(){ var replaceModule = 'objectify.xqy'; - var replacePath = './node-client-api/test-complete/data/objectify.xqy'; + var replacePath = __dirname + '/data/objectify.xqy'; it('should write the replacement library for the test', function(done){ this.timeout(10000); dbAdmin.config.patch.replace.write( - replaceModule, - [{'role-name':'app-user', capabilities:['execute']}], + replaceModule, + [{'role-name':'app-user', capabilities:['execute']}], fs.createReadStream(replacePath)). result(function(response){ done(); @@ -46,8 +46,8 @@ describe('patch datatypes test', function(){ it('should write document for test', function(done){ dbWriter.documents.write({ - uri: '/test/patch/datatypes/patchDatatypes1.json', - collections: ['patchDatatypesCollection'], + uri: '/test/patch/datatypes/patchDatatypes1.json', + collections: ['patchDatatypesCollection'], contentType: 'application/json', content: { title: 'hello', diff --git a/test-complete/nodejs-documents-patch-metadata.js b/test-complete/nodejs-documents-patch-metadata.js index 2e772a2f..0ccf8c0e 100644 --- a/test-complete/nodejs-documents-patch-metadata.js +++ b/test-complete/nodejs-documents-patch-metadata.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ describe('document patch metadata test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -56,7 +56,7 @@ describe('document patch metadata test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -70,7 +70,7 @@ describe('document patch metadata test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -84,7 +84,7 @@ describe('document patch metadata test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -109,7 +109,7 @@ describe('document patch metadata test', function(){ var uri1 = '/test/query/matchList/doc5.json'; var p = marklogic.patchBuilder; dbWriter.documents.patch({uri: uri1, - categories: ['metadata'], + categories: ['metadata'], operations: [ p.replace('node("quality")', 33) ] @@ -118,10 +118,10 @@ describe('document patch metadata test', function(){ db.documents.read({uris: uri1, categories: ['metadata']}). result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); - documents[0].quality.should.equal(33); + documents[0].quality.should.equal(33); done(); }, done); - }, done); + }, done); }); it('should appply patch on metadata with jsonpath', function(done){ @@ -129,7 +129,7 @@ describe('document patch metadata test', function(){ var uri1 = '/test/query/matchList/doc5.json'; var p = marklogic.patchBuilder; dbWriter.documents.patch({uri: uri1, - categories: ['metadata'], + categories: ['metadata'], operations: [ p.pathLanguage('jsonpath'), p.replace('$.quality', 45) @@ -139,10 +139,10 @@ describe('document patch metadata test', function(){ db.documents.read({uris: uri1, categories: ['metadata']}). result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); - documents[0].quality.should.equal(45); + documents[0].quality.should.equal(45); done(); }, done); - }, done); + }, done); }); it('should appply patch on metadata properties', function(done){ @@ -150,7 +150,7 @@ describe('document patch metadata test', function(){ var uri1 = '/test/query/matchList/doc5.json'; var p = marklogic.patchBuilder; dbWriter.documents.patch({uri: uri1, - categories: ['metadata'], + categories: ['metadata'], operations: [ p.pathLanguage('jsonpath'), p.insert('$.properties.prop1', 'after', {prop2: 'world'}) @@ -160,17 +160,17 @@ describe('document patch metadata test', function(){ db.documents.read({uris: uri1, categories: ['metadata']}). result(function(documents) { //console.log(JSON.stringify(documents, null, 4)); - documents[0].properties.prop2.should.equal('world'); + documents[0].properties.prop2.should.equal('world'); done(); }, done); - }, done); + }, done); }); it('should appply patch on metadata properties', function(done){ this.timeout(10000); var uri1 = '/test/query/matchDir/doc4.json'; var p = marklogic.patchBuilder; dbWriter.documents.patch({uri: uri1, - categories: ['metadata'], + categories: ['metadata'], operations: [ p.collections.add('collection2/ADDED'), p.collections.remove('collection2/0'), @@ -197,7 +197,7 @@ it('should appply patch on metadata properties', function(done){ documents[0].should.have.property('permissions') done(); }, done); - }, done); + }, done); }); it('should remove the document', function(done){ dbAdmin.documents.removeAll({all: true}). diff --git a/test-complete/nodejs-documents-patch-negative.js b/test-complete/nodejs-documents-patch-negative.js index e1adbe20..aa52cca0 100644 --- a/test-complete/nodejs-documents-patch-negative.js +++ b/test-complete/nodejs-documents-patch-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ describe('document patch negative test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -57,7 +57,7 @@ describe('document patch negative test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -71,7 +71,7 @@ describe('document patch negative test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -85,7 +85,7 @@ describe('document patch negative test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -108,7 +108,7 @@ describe('document patch negative test', function(){ /*it('should fail to appply patch without document uri', function(done){ var uri1 = '/test/query/matchList/doc5.json'; dbWriter.documents.patch({ - categories: ['metadata'], + categories: ['metadata'], operations: [ p.replace('node("quality")', 33) ] @@ -119,7 +119,7 @@ describe('document patch negative test', function(){ }, function(error) { //console.log(error); done(); - }); + }); });*/ it('should fail to appply patch without categories', function(done){ @@ -136,7 +136,7 @@ describe('document patch negative test', function(){ }, function(error) { //console.log(error); done(); - }); + }); }); it('should fail to appply patch without pathLanguange', function(done){ @@ -155,7 +155,7 @@ describe('document patch negative test', function(){ }, function(error) { //console.log(error); done(); - }); + }); }); it('should write document for test', function(done){ @@ -194,7 +194,7 @@ describe('document patch negative test', function(){ //console.log(error); error.statusCode.should.equal(400); done(); - }); + }); }); it('should write document for test', function(done){ @@ -261,7 +261,7 @@ describe('document patch negative test', function(){ dbAdmin.documents.removeAll({all: true}). result(function(response){ done(); - }, done); + }, done); }); }); diff --git a/test-complete/nodejs-documents-patch-null.js b/test-complete/nodejs-documents-patch-null.js index 8140b6ed..32a32290 100644 --- a/test-complete/nodejs-documents-patch-null.js +++ b/test-complete/nodejs-documents-patch-null.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ describe('document patch test null - Bug 37787', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -57,7 +57,7 @@ describe('document patch test null - Bug 37787', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -71,7 +71,7 @@ describe('document patch test null - Bug 37787', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -85,7 +85,7 @@ describe('document patch test null - Bug 37787', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -140,5 +140,5 @@ describe('document patch test null - Bug 37787', function(){ done(); }, done); }); - + }); diff --git a/test-complete/nodejs-documents-patch-stream.js b/test-complete/nodejs-documents-patch-stream.js index 9a6743cd..ea294e03 100644 --- a/test-complete/nodejs-documents-patch-stream.js +++ b/test-complete/nodejs-documents-patch-stream.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ describe('document patch stream', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -57,7 +57,7 @@ describe('document patch stream', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -71,7 +71,7 @@ describe('document patch stream', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -85,7 +85,7 @@ describe('document patch stream', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -110,7 +110,7 @@ describe('document patch stream', function(){ var uri1 = '/test/query/matchList/doc5.json'; var p = marklogic.patchBuilder; dbWriter.documents.patch({uri: uri1, - categories: ['metadata'], + categories: ['metadata'], operations: [ p.pathLanguage('jsonpath'), p.insert('$.properties.prop1', 'after', {prop2: 'world'}) @@ -146,5 +146,5 @@ it('should delete all documents', function(done){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-patch.js b/test-complete/nodejs-documents-patch.js index e485d61b..d53dcefd 100644 --- a/test-complete/nodejs-documents-patch.js +++ b/test-complete/nodejs-documents-patch.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ describe('document patch test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/patch/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -57,7 +57,7 @@ describe('document patch test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/patch/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -71,7 +71,7 @@ describe('document patch test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/patch/doc4.json', collections: [], contentType: 'application/json', @@ -85,7 +85,7 @@ describe('document patch test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/patch/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -107,7 +107,7 @@ describe('document patch test', function(){ var uri2 = '/test/patch/doc4.json'; it('should apply the patch', function(done){ - + dbWriter.documents.patch('/test/patch/doc5.json', p.pathLanguage('jsonpath'), p.insert('$.title', 'after', {newKey:'newChild'}), @@ -167,7 +167,7 @@ describe('document patch test', function(){ p.insert('array-node("collections")', 'last-child', 'addedCollection'), p.insert('properties', 'last-child', {newPropKey: 'newPropValue'}), p.replace('quality', 24), - p.insert('array-node("permissions")', 'last-child', {'role-name': 'app-builder', capabilities: ['read', 'update']}) + p.insert('array-node("permissions")', 'last-child', {'role-name': 'app-builder', capabilities: ['read', 'update']}) ] }).result(function(response) { //console.log(JSON.stringify(response, null, 4)); @@ -196,7 +196,7 @@ describe('document patch test', function(){ done(); }, done); }); - + it('should modify the patch on metadata', function(done){ dbWriter.documents.patch({ uri: '/test/patch/doc4.json', @@ -205,7 +205,7 @@ describe('document patch test', function(){ p.replace('collections[. eq "addedCollection"]', 'modifiedCollection'), p.insert('properties/newPropKey', 'after', {anotherPropKey: 'anotherPropValue'}), p.replace('quality', 42), - p.remove('permissions[role-name eq "app-builder"]') + p.remove('permissions[role-name eq "app-builder"]') ] }).result(function(response) { //console.log(JSON.stringify(response, null, 4)); diff --git a/test-complete/nodejs-documents-qbe.js b/test-complete/nodejs-documents-qbe.js index da41f1f9..704df657 100644 --- a/test-complete/nodejs-documents-qbe.js +++ b/test-complete/nodejs-documents-qbe.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document qbe test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('Document qbe test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('Document qbe test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -83,7 +83,7 @@ describe('Document qbe test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -197,7 +197,7 @@ describe('Document qbe test', function(){ it('should do query on title string', function(done){ db.documents.query( q.where( - q.byExample( + q.byExample( '' + ' json' + ' ' + @@ -434,6 +434,6 @@ it('should delete all documents', function(done){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-query-2.js b/test-complete/nodejs-documents-query-2.js index 0fb0fb65..2c83c070 100644 --- a/test-complete/nodejs-documents-query-2.js +++ b/test-complete/nodejs-documents-query-2.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document query test 2', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('Document query test 2', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('Document query test 2', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -84,7 +84,7 @@ describe('Document query test 2', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -118,7 +118,7 @@ describe('Document query test 2', function(){ db.documents.query( q.where( q.document('/test/query/matchDir/doc4.json', - '/something/invalid/bla.json', + '/something/invalid/bla.json', '/test/query/matchList/doc5.json', '/test/query/matchList/doc6.xml') )).result(function(response) { diff --git a/test-complete/nodejs-documents-query-3.js b/test-complete/nodejs-documents-query-3.js index 7c159f2d..ca15bc4c 100644 --- a/test-complete/nodejs-documents-query-3.js +++ b/test-complete/nodejs-documents-query-3.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-complete/nodejs-documents-query-facet.js b/test-complete/nodejs-documents-query-facet.js index 7673076c..25270cca 100644 --- a/test-complete/nodejs-documents-query-facet.js +++ b/test-complete/nodejs-documents-query-facet.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document facet query test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/facet/doc2.json', collections: ['facetCollection'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('Document facet query test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/facet/doc3.json', collections: ['facetCollection'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('Document facet query test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/facet/doc4.json', collections: ['facetCollection'], contentType: 'application/json', @@ -83,7 +83,7 @@ describe('Document facet query test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/facet/doc5.json', collections: ['facetCollection'], contentType: 'application/json', @@ -113,8 +113,8 @@ describe('Document facet query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); done(); }, done); }); @@ -131,8 +131,8 @@ describe('Document facet query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('5'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('5'); done(); }, done); }); @@ -154,8 +154,8 @@ describe('Document facet query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response[0].facets.popularity.facetValues[0].name.should.equal('moderate'); - response[0].facets.popularity.facetValues[0].count.should.equal(1); + response[0].facets.popularity.facetValues[0].name.should.equal('moderate'); + response[0].facets.popularity.facetValues[0].count.should.equal(1); done(); }, done); }); @@ -179,8 +179,8 @@ describe('Document facet query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response[0].facets.popularity.facetValues[0].name.should.equal('moderate'); - response[0].facets.popularity.facetValues[0].count.should.equal(1); + response[0].facets.popularity.facetValues[0].name.should.equal('moderate'); + response[0].facets.popularity.facetValues[0].count.should.equal(1); done(); }, done); }); @@ -204,10 +204,10 @@ describe('Document facet query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response[0].facets.datetime.facetValues[0].name.should.equal('2005'); - response[0].facets.datetime.facetValues[0].count.should.equal(1); - response[0].facets.datetime.facetValues[4].name.should.equal('2009'); - response[0].facets.datetime.facetValues[4].count.should.equal(1); + response[0].facets.datetime.facetValues[0].name.should.equal('2005'); + response[0].facets.datetime.facetValues[0].count.should.equal(1); + response[0].facets.datetime.facetValues[4].name.should.equal('2009'); + response[0].facets.datetime.facetValues[4].count.should.equal(1); done(); }, done); }); @@ -233,10 +233,10 @@ describe('Document facet query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response[0].facets.datetime.facetValues[0].name.should.equal('2005'); - response[0].facets.datetime.facetValues[0].count.should.equal(1); - response[0].facets.datetime.facetValues[4].name.should.equal('2009'); - response[0].facets.datetime.facetValues[4].count.should.equal(1); + response[0].facets.datetime.facetValues[0].name.should.equal('2005'); + response[0].facets.datetime.facetValues[0].count.should.equal(1); + response[0].facets.datetime.facetValues[4].name.should.equal('2009'); + response[0].facets.datetime.facetValues[4].count.should.equal(1); done(); }, done); }); @@ -255,12 +255,12 @@ describe('Document facet query test', function(){ //console.log(JSON.stringify(response, null, 2)); response[0].total.should.equal(4); response[0].results[0].matches[0]['match-text'][1].highlight.should.equal('the'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); done(); }, done); }); - + it('should query with facet, asc orderby, and snippet', function(done){ db.documents.query( q.where( @@ -279,12 +279,12 @@ describe('Document facet query test', function(){ response[0].total.should.equal(4); response[0].results[0].uri.should.equal('/test/query/facet/doc3.json'); response[0].results[0].matches[0]['match-text'][1].highlight.should.equal('the'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); done(); }, done); }); - + it('should query with facet, des orderby, and snippet, and score logtf', function(done){ db.documents.query( q.where( @@ -303,12 +303,12 @@ describe('Document facet query test', function(){ response[0].results[0].uri.should.equal('/test/query/facet/doc3.json'); response[0].results[0].score.should.equal(22528); response[0].results[0].matches[0]['match-text'][1].highlight.should.equal('the'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); done(); }, done); }); - + it('should query with facet, des orderby, and snippet, and score logtfidf', function(done){ db.documents.query( q.where( @@ -327,8 +327,8 @@ describe('Document facet query test', function(){ response[0].results[0].uri.should.equal('/test/query/facet/doc3.json'); response[0].results[0].score.should.equal(8448); response[0].results[0].matches[0]['match-text'][1].highlight.should.equal('the'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); done(); }, done); }); @@ -350,8 +350,8 @@ describe('Document facet query test', function(){ response[0].results[0].uri.should.equal('/test/query/facet/doc3.json'); response[0].results[0].score.should.equal(2048); response[0].results[0].matches[0]['match-text'][1].highlight.should.equal('the'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); done(); }, done); }); @@ -372,8 +372,8 @@ describe('Document facet query test', function(){ response[0].total.should.equal(4); response[0].results[0].uri.should.equal('/test/query/facet/doc3.json'); response[0].results[0].matches[0]['match-text'][1].highlight.should.equal('the'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); done(); }, done); }); @@ -396,8 +396,8 @@ describe('Document facet query test', function(){ response[0].results[0].uri.should.equal('/test/query/facet/doc3.json'); response[0].results[0].score.should.equal(0); response[0].results[0].matches[0]['match-text'][1].highlight.should.equal('the'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); done(); }, done); }); @@ -419,8 +419,8 @@ describe('Document facet query test', function(){ response[0].total.should.equal(4); response[0].results[0].uri.should.equal('/test/query/facet/doc5.json'); response[0].results[0].matches[0]['match-text'][0].highlight.should.equal('The'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); done(); }, done); }); @@ -449,9 +449,9 @@ describe('Document facet query test', function(){ response[0].total.should.equal(4); response[0].results[0].uri.should.equal('/test/query/facet/doc3.json'); response[0].results[0].matches[0]['match-text'][1].highlight.should.equal('the'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); - response[1].content.id.should.equal('0013'); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[1].content.id.should.equal('0013'); done(); }, done); }); @@ -489,15 +489,15 @@ describe('Document facet query test', function(){ response[0].total.should.equal(4); response[0].results[0].uri.should.equal('/test/query/facet/doc3.json'); response[0].results[0].matches[0]['match-text'][1].highlight.should.equal('the'); - response[0].facets.popularity.facetValues.length.should.equal(3); - response[0].facets.popularity.facetValues[0].name.should.equal('3'); - response[1].content.id.should.equal('0013'); - response[0].facets.datetime.facetValues[0].name.should.equal('2005'); - response[0].facets.datetime.facetValues[0].count.should.equal(1); + response[0].facets.popularity.facetValues.length.should.equal(3); + response[0].facets.popularity.facetValues[0].name.should.equal('3'); + response[1].content.id.should.equal('0013'); + response[0].facets.datetime.facetValues[0].name.should.equal('2005'); + response[0].facets.datetime.facetValues[0].count.should.equal(1); done(); }, done); }); - + it('should remove the documents', function(done){ dbAdmin.documents.removeAll({collection: 'facetCollection'}). result(function(response) { diff --git a/test-complete/nodejs-documents-query-geo-double.js b/test-complete/nodejs-documents-query-geo-double.js index 5e99772a..0a67baab 100644 --- a/test-complete/nodejs-documents-query-geo-double.js +++ b/test-complete/nodejs-documents-query-geo-double.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document geo query test', function(){ latitudeRawDouble: 12.34, longitudeRawDouble: 5.48 } - } + } }, { uri: '/test/double/geo/doc2.json', @@ -57,7 +57,7 @@ describe('Document geo query test', function(){ latitudeRawDouble: 34.89, longitudeRawDouble: 88.27 } - } + } }, { uri: '/test/double/geo/doc3.json', @@ -73,14 +73,14 @@ describe('Document geo query test', function(){ latitudeRawDouble: 101.09, longitudeRawDouble: 4.99 } - } + } }, { uri: '/test/double/geo/doc4.xml', collections: ['geoDoubleCollection'], contentType: 'application/xml', - content: - '' + + content: + '' + ' ben_red' + ' 50.75,44.78' + ' ' + @@ -96,8 +96,8 @@ describe('Document geo query test', function(){ uri: '/test/double/geo/doc5.xml', collections: ['geoDoubleCollection'], contentType: 'application/xml', - content: - '' + + content: + '' + ' george_blue' + ' 250.35,144.77' + ' ' + @@ -107,7 +107,7 @@ describe('Document geo query test', function(){ ' 250.35' + ' 144.77' + ' ' + - ' ' + + ' ' + '' }, { @@ -124,7 +124,7 @@ describe('Document geo query test', function(){ latitudeRawDouble: 37.2768, longitudeRawDouble: -77.4008 } - } + } } ). result(function(response){done();}, done); @@ -135,7 +135,7 @@ describe('Document geo query test', function(){ q.where( q.geospatial( q.geoProperty('gElemPointWgs84Double'), - q.geoOptions('coordinate-system=wgs84/double'), + q.geoOptions('coordinate-system=wgs84/double'), q.point(12.34, 5.48) ) ) @@ -153,12 +153,12 @@ describe('Document geo query test', function(){ q.where( q.geospatial( q.geoProperty( - q.property('gElemChildParentEtrs89Double'), + q.property('gElemChildParentEtrs89Double'), q.property('gElemChildPointEtrs89Double') - ), - q.geoOptions('coordinate-system=etrs89/double'), - q.latlon(12.3467, 5.4843) - ) + ), + q.geoOptions('coordinate-system=etrs89/double'), + q.latlon(12.3467, 5.4843) + ) ) ). result(function(response) { @@ -174,7 +174,7 @@ describe('Document geo query test', function(){ q.where( q.geospatial( q.geoPropertyPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), - q.geoOptions('coordinate-system=raw/double'), + q.geoOptions('coordinate-system=raw/double'), q.latlon(12.34, 5.48) ) ) @@ -191,8 +191,8 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), - q.geoOptions('coordinate-system=raw/double'), + q.geoPropertyPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), + q.geoOptions('coordinate-system=raw/double'), q.circle(10, 11.24, 5.67) ) ) @@ -209,7 +209,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), + q.geoPropertyPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), q.geoOptions('boundaries-included', 'coordinate-system=raw/double'), q.box(11.45, 4.43, 20.09, 10.38) ) @@ -227,7 +227,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoElementPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), + q.geoElementPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), q.geoOptions('coordinate-system=raw/double'), q.latlon(50.75, 44.78) ) @@ -246,7 +246,7 @@ describe('Document geo query test', function(){ q.where( q.geospatial( q.geoProperty('gElemPointWgs84Double'), - q.geoOptions('coordinate-system=wgs84/double'), + q.geoOptions('coordinate-system=wgs84/double'), q.point(12, 5) ) ) @@ -263,12 +263,12 @@ describe('Document geo query test', function(){ q.where( q.geospatial( q.geoProperty( - q.property('gElemChildParentEtrs89Double'), + q.property('gElemChildParentEtrs89Double'), q.property('gElemChildPointEtrs89Double') - ), - q.geoOptions('coordinate-system=etrs89/double'), - q.latlon(12, 5) - ) + ), + q.geoOptions('coordinate-system=etrs89/double'), + q.latlon(12, 5) + ) ) ). result(function(response) { @@ -283,7 +283,7 @@ describe('Document geo query test', function(){ q.where( q.geospatial( q.geoPropertyPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), - q.geoOptions('coordinate-system=raw/double'), + q.geoOptions('coordinate-system=raw/double'), q.latlon(12, 5) ) ) @@ -299,7 +299,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), + q.geoPropertyPair('gElemPairRawDouble', 'latitudeRawDouble', 'longitudeRawDouble'), q.geoOptions('boundaries-excluded', 'coordinate-system=raw/double'), q.box(12, 5, 20, 10) ) diff --git a/test-complete/nodejs-documents-query-geo-region.js b/test-complete/nodejs-documents-query-geo-region.js index 4d71b268..2dec6d8b 100644 --- a/test-complete/nodejs-documents-query-geo-region.js +++ b/test-complete/nodejs-documents-query-geo-region.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,84 +30,84 @@ var geoDataFiles = [ { uri:'/geo/region/test/Equator-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/Equator-json.json') + content:fs.createReadStream(__dirname + '/data/geo/Equator-json.json') },{ uri:'/geo/region/test/North-Pole-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/North-Pole-json.json') + content:fs.createReadStream(__dirname + '/data/geo/North-Pole-json.json') },{ uri:'/geo/region/test/Prime-Meridian-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/Prime-Meridian-json.json') + content:fs.createReadStream(__dirname + '/data/geo/Prime-Meridian-json.json') },{ uri:'/geo/region/test/South-More-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/South-More-json.json') + content:fs.createReadStream(__dirname + '/data/geo/South-More-json.json') },{ uri:'/geo/region/test/Tropic-of-Cancer-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/Tropic-of-Cancer-json.json') + content:fs.createReadStream(__dirname + '/data/geo/Tropic-of-Cancer-json.json') },{ uri:'/geo/region/test/International-Date-Line-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/International-Date-Line-json.json') + content:fs.createReadStream(__dirname + '/data/geo/International-Date-Line-json.json') },{ uri:'/geo/region/test/North-West-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/North-West-json.json') + content:fs.createReadStream(__dirname + '/data/geo/North-West-json.json') },{ uri:'/geo/region/test/South-East-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/South-East-json.json') + content:fs.createReadStream(__dirname + '/data/geo/South-East-json.json') },{ uri:'/geo/region/test/South-Pole-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/South-Pole-json.json') + content:fs.createReadStream(__dirname + '/data/geo/South-Pole-json.json') },{ uri:'/geo/region/test/Tropic-of-Capricorn-json.json', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/Tropic-of-Capricorn-json.json') + content:fs.createReadStream(__dirname + '/data/geo/Tropic-of-Capricorn-json.json') },{ uri:'/geo/region/test/Equator.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/Equator.xml') + content:fs.createReadStream(__dirname + '/data/geo/Equator.xml') },{ uri:'/geo/region/test/North-Pole.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/North-Pole.xml') + content:fs.createReadStream(__dirname + '/data/geo/North-Pole.xml') },{ uri:'/geo/region/test/Prime-Meridian.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/Prime-Meridian.xml') + content:fs.createReadStream(__dirname + '/data/geo/Prime-Meridian.xml') },{ uri:'/geo/region/test/South-More.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/South-More.xml') + content:fs.createReadStream(__dirname + '/data/geo/South-More.xml') },{ uri:'/geo/region/test/Tropic-of-Cancer.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/Tropic-of-Cancer.xml') + content:fs.createReadStream(__dirname + '/data/geo/Tropic-of-Cancer.xml') },{ uri:'/geo/region/test/International-Date-Line.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/International-Date-Line.xml') + content:fs.createReadStream(__dirname + '/data/geo/International-Date-Line.xml') },{ uri:'/geo/region/test/North-West.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/North-West.xml') + content:fs.createReadStream(__dirname + '/data/geo/North-West.xml') },{ uri:'/geo/region/test/South-East.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/South-East.xml') + content:fs.createReadStream(__dirname + '/data/geo/South-East.xml') },{ uri:'/geo/region/test/South-Pole.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/South-Pole.xml') + content:fs.createReadStream(__dirname + '/data/geo/South-Pole.xml') },{ uri:'/geo/region/test/Tropic-of-Capricorn.xml', collections:['/geo/region/test'], - content:fs.createReadStream('./node-client-api/test-complete/data/geo/Tropic-of-Capricorn.xml') - } + content:fs.createReadStream(__dirname + '/data/geo/Tropic-of-Capricorn.xml') + } ]; @@ -124,8 +124,8 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/point'), - 'contains', - //q.geoOptions('coordinate-system=wgs84'), + 'contains', + //q.geoOptions('coordinate-system=wgs84'), q.point(0, -66.09375) ) ) @@ -144,8 +144,8 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/circle'), - 'contains', - //q.geoOptions('coordinate-system=wgs84/double'), + 'contains', + //q.geoOptions('coordinate-system=wgs84/double'), q.circle(6.897, q.point(0,-66.09375)) ) ) @@ -185,7 +185,7 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/point'), - 'intersects', + 'intersects', q.point(83.229523, -34.453123) ) ) @@ -204,7 +204,7 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/polygon'), - 'intersects', + 'intersects', q.box(-5.45, -76.35643, 5.35, -54.636) ) ) @@ -223,19 +223,19 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/polygon'), - 'intersects', + 'intersects', q.polygon( - [44.65, 88.64], - [39.87, 97.74], - [30.18, 101.1], - [20.55, 102.32], + [44.65, 88.64], + [39.87, 97.74], + [30.18, 101.1], + [20.55, 102.32], [8.04, 104.9], [5.24, 91.9], [2.22, 83.42], [-5.91, 72.86], [5.98, 66.63], - [8.21, 53.38], - [20.14, 51.78], + [8.21, 53.38], + [20.14, 51.78], [29.88, 57.83], [41.82, 58.1], [43.27, 69.97], @@ -259,10 +259,10 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/complex-polygon'), - 'intersects', + 'intersects', q.polygon( q.point(84, -37), - q.point(83, -36.5), + q.point(83, -36.5), q.point(82, -36), q.point(84, -37) ) @@ -271,11 +271,11 @@ describe('Document geo query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response.length.should.equal(4); + response.length.should.equal(2); response[0].uri.should.equal('/geo/region/test/North-Pole.xml'); response[1].uri.should.equal('/geo/region/test/North-Pole-json.json'); - response[2].uri.should.equal('/geo/region/test/Prime-Meridian.xml'); - response[3].uri.should.equal('/geo/region/test/Prime-Meridian-json.json'); + //response[2].uri.should.equal('/geo/region/test/Prime-Meridian.xml'); + //response[3].uri.should.equal('/geo/region/test/Prime-Meridian-json.json'); done(); }, done); }); @@ -285,28 +285,28 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/point'), - 'within', + 'within', q.polygon( - [40.13, -52.96], - [40.45, -36.61], - [38.16, -13.48], - [21.09, -1.1], - [0.0, -17.46], - [-17.38, -12.52], + [40.13, -52.96], + [40.45, -36.61], + [38.16, -13.48], + [21.09, -1.1], + [0.0, -17.46], + [-17.38, -12.52], [-33.08, -20.47], [-51.46, -28.61], - [-65.33, -44.77], - [-66.8, -66.0], + [-65.33, -44.77], + [-66.8, -66.0], [-53.99, -83.54], - [-54.35, -105.49], + [-54.35, -105.49], [-24.59, -99.85], - [-14.58, -110.86], - [-0.0, -127.42], - [13.44, -107.37], - [35.78, -115.25], - [53.21, -104.66], + [-14.58, -110.86], + [-0.0, -127.42], + [13.44, -107.37], + [35.78, -115.25], + [53.21, -104.66], [48.69, -81.82], - [55.37, -66.0], + [55.37, -66.0], [40.13, -52.96] ) ) @@ -314,11 +314,9 @@ describe('Document geo query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response.length.should.equal(4); - response[0].uri.should.equal('/geo/region/test/South-More-json.json'); - response[1].uri.should.equal('/geo/region/test/Equator.xml'); - response[2].uri.should.equal('/geo/region/test/Equator-json.json'); - response[3].uri.should.equal('/geo/region/test/South-More.xml'); + response.length.should.equal(2); + response[0].uri.should.equal('/geo/region/test/Equator.xml'); + response[1].uri.should.equal('/geo/region/test/Equator-json.json'); done(); }, done); }); @@ -328,7 +326,7 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/polygon'), - 'covered-by', + 'covered-by', q.circle(1200, q.point(83,-29.87)) ) ) @@ -347,7 +345,7 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/polygon'), - 'covers', + 'covers', q.box(-5.45, -76.35643, 5.35, -54.636) ) ) @@ -366,7 +364,7 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/polygon'), - 'overlaps', + 'overlaps', q.box(80, -30, 88, -28) ) ) @@ -385,7 +383,7 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/point'), - 'touches', + 'touches', q.box(37.463235, 0, 40, 5) ) ) @@ -404,7 +402,7 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/point', q.geoOptions(['coordinate-system=wgs84'])), - 'disjoint', + 'disjoint', q.circle(120.5, q.point(-26.797920, 136.406250)) ) ) @@ -421,7 +419,7 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/point', q.geoOptions(['coordinate-system=wgs84'])), - 'equals', + 'equals', q.point(0, -66.09374), q.geoOptions(['slope-factor=1']), q.fragmentScope(['documents']) @@ -430,9 +428,7 @@ describe('Document geo query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response.length.should.equal(2); - response[0].uri.should.equal('/geo/region/test/Equator.xml'); - response[1].uri.should.equal('/geo/region/test/Equator-json.json'); + response.length.should.equal(0); done(); }, done); }); @@ -449,9 +445,9 @@ describe('Document geo query test', function(){ ). result(function(response) { //console.log(JSON.stringify(response, null, 2)); - response.length.should.equal(8); - response[0].uri.should.equal('/geo/region/test/International-Date-Line.xml'); - response[7].uri.should.equal('/geo/region/test/North-West.xml'); + response.length.should.equal(2); + response[0].uri.should.equal('/geo/region/test/Tropic-of-Cancer-json.json'); + response[1].uri.should.equal('/geo/region/test/Tropic-of-Cancer.xml'); done(); }, done); }); @@ -481,7 +477,7 @@ describe('Document geo query test', function(){ q.where( q.geospatialRegion( q.geoPath('/root/item/point', q.geoOptions(['coordinate-system=wgs84'])), - 'equals', + 'equals', q.point(0, -66.09374), q.geoOptions(['slope-factor=1']), q.fragmentScope('properties') diff --git a/test-complete/nodejs-documents-query-geo.js b/test-complete/nodejs-documents-query-geo.js index ef6f88a8..9d38c13b 100644 --- a/test-complete/nodejs-documents-query-geo.js +++ b/test-complete/nodejs-documents-query-geo.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document geo query test', function(){ latitude: 12, longitude: 5 } - } + } }, { uri: '/test/query/geo/doc2.json', @@ -57,7 +57,7 @@ describe('Document geo query test', function(){ latitude: 34, longitude: 88 } - } + } }, { uri: '/test/query/geo/doc3.json', @@ -73,14 +73,14 @@ describe('Document geo query test', function(){ latitude: 101, longitude: 4 } - } + } }, { uri: '/test/query/geo/doc4.xml', collections: ['geoCollection'], contentType: 'application/xml', - content: - '' + + content: + '' + ' ben_red' + ' 50,44' + ' ' + @@ -96,8 +96,8 @@ describe('Document geo query test', function(){ uri: '/test/query/geo/doc5.xml', collections: ['geoCollection'], contentType: 'application/xml', - content: - '' + + content: + '' + ' george_blue' + ' 250,144' + ' ' + @@ -107,7 +107,7 @@ describe('Document geo query test', function(){ ' 250' + ' 144' + ' ' + - ' ' + + ' ' + '' }, { @@ -124,7 +124,7 @@ describe('Document geo query test', function(){ latitude: 37.2768, longitude: -77.4008 } - } + } } ). result(function(response){done();}, done); @@ -134,7 +134,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), + q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), q.latlon(12, 5) ) ) @@ -151,7 +151,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), + q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), q.latlon(12, 5), q.geoOptions('boundaries-latitude-excluded') ) @@ -169,7 +169,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoProperty('gElemPoint'), + q.geoProperty('gElemPoint'), q.point(34, 88) ) ) @@ -187,11 +187,11 @@ describe('Document geo query test', function(){ q.where( q.geospatial( q.geoProperty( - q.property('gElemChildParent'), + q.property('gElemChildParent'), q.property('gElemChildPoint') - ), - q.latlon(34, 88) - ) + ), + q.latlon(34, 88) + ) ) ). result(function(response) { @@ -208,9 +208,9 @@ describe('Document geo query test', function(){ q.or( q.geospatial( q.geoProperty( - q.property('gElemChildParent'), + q.property('gElemChildParent'), q.property('gElemChildPoint') - ), + ), q.latlon(34, 88) ), q.word('title', 'karl_kara') @@ -229,7 +229,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), + q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), q.circle(100, 11, 5) ) ) @@ -246,7 +246,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), + q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), q.circle(2000, 32.2768, -62.4008) ) ) @@ -263,7 +263,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), + q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), q.box(11, 4, 20, 10), q.geoOptions('boundaries-included') ) @@ -281,7 +281,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), + q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), q.box(12, 5, 20, 10), q.geoOptions('boundaries-included') ) @@ -299,7 +299,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), + q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), q.box(12, 5, 20, 10), q.geoOptions('boundaries-excluded') ) @@ -316,7 +316,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), + q.geoPropertyPair('gElemPair', 'latitude', 'longitude'), q.polygon([12, 5], [20, 10], [34, 22]) ) ) @@ -333,7 +333,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPath('gElemChildParent/gElemChildPoint'), + q.geoPath('gElemChildParent/gElemChildPoint'), q.latlon(12, 5) ) ) @@ -350,7 +350,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoPath(q.pathIndex('gElemChildParent/gElemChildPoint')), + q.geoPath(q.pathIndex('gElemChildParent/gElemChildPoint')), q.point(12, 5) ) ) @@ -367,7 +367,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoElementPair('gElemPair', 'latitude', 'longitude'), + q.geoElementPair('gElemPair', 'latitude', 'longitude'), q.latlon(50, 44) ) ) @@ -384,7 +384,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoElement('gElemPoint'), + q.geoElement('gElemPoint'), q.latlon(50, 44) ) ) @@ -401,7 +401,7 @@ describe('Document geo query test', function(){ dbWriter.documents.query( q.where( q.geospatial( - q.geoAttributePair('gAttrPair', 'latitude', 'longitude'), + q.geoAttributePair('gAttrPair', 'latitude', 'longitude'), q.circle(100, 240, 144) ) ) diff --git a/test-complete/nodejs-documents-query-negative.js b/test-complete/nodejs-documents-query-negative.js index c8e4c139..e2b72cde 100644 --- a/test-complete/nodejs-documents-query-negative.js +++ b/test-complete/nodejs-documents-query-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document query negative test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('Document query negative test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('Document query negative test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -83,7 +83,7 @@ describe('Document query negative test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -129,7 +129,7 @@ describe('Document query negative test', function(){ ) ).should.equal('SHOULD HAVE FAILED'); done(); - } + } catch(error) { //console.log(error.toString()); var strErr = error.toString(); @@ -147,7 +147,7 @@ describe('Document query negative test', function(){ ) ).should.equal('SHOULD HAVE FAILED'); done(); - } + } catch(error) { //console.log(error.toString()); var strErr = error.toString(); @@ -164,7 +164,7 @@ describe('Document query negative test', function(){ ).slice(0) ).should.equal('SHOULD HAVE FAILED'); done(); - } + } catch(error) { //console.log(error.toString()); var strErr = error.toString(); @@ -180,5 +180,5 @@ it('should delete all documents', function(done){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-query-options.js b/test-complete/nodejs-documents-query-options.js index 14277f3f..368a865a 100644 --- a/test-complete/nodejs-documents-query-options.js +++ b/test-complete/nodejs-documents-query-options.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ describe('document query options test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -56,7 +56,7 @@ describe('document query options test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -70,7 +70,7 @@ describe('document query options test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -84,7 +84,7 @@ describe('document query options test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', diff --git a/test-complete/nodejs-documents-query-slice.js b/test-complete/nodejs-documents-query-slice.js index 1f26c1e6..51aaeed8 100644 --- a/test-complete/nodejs-documents-query-slice.js +++ b/test-complete/nodejs-documents-query-slice.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ describe('document query slice test', function(){ values: [{score: 56.7}, {rate: 3}], p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -59,7 +59,7 @@ describe('document query slice test', function(){ values: [{score: 92.45}, {rate: 5}], p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -74,7 +74,7 @@ describe('document query slice test', function(){ values: [{score: 33.56}, {rate: 1}], p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -89,7 +89,7 @@ describe('document query slice test', function(){ values: [{score: 12.34}, {rate: 3}], p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -243,7 +243,7 @@ it('should do document query with slice array with index 3 and offset 10', funct }, function(error) { //console.log(error); error.statusCode.should.equal(400); - error.body.errorResponse.messageCode.should.equal('REST-INVALIDTYPE'); + error.body.errorResponse.messageCode.should.equal('REST-INVALIDPARAM'); done(); }); diff --git a/test-complete/nodejs-documents-query-sort.js b/test-complete/nodejs-documents-query-sort.js index be66fae1..1ba269b6 100644 --- a/test-complete/nodejs-documents-query-sort.js +++ b/test-complete/nodejs-documents-query-sort.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ describe('document query sort test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/sort/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -56,7 +56,7 @@ describe('document query sort test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/sort/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -70,7 +70,7 @@ describe('document query sort test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/sort/doc4.json', collections: [], contentType: 'application/json', @@ -84,7 +84,7 @@ describe('document query sort test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/sort/doc5.json', collections: ['matchList'], contentType: 'application/json', diff --git a/test-complete/nodejs-documents-query-stream.js b/test-complete/nodejs-documents-query-stream.js index 7c80b782..a9218f05 100644 --- a/test-complete/nodejs-documents-query-stream.js +++ b/test-complete/nodejs-documents-query-stream.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ describe('Document query stream test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -56,7 +56,7 @@ describe('Document query stream test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -70,7 +70,7 @@ describe('Document query stream test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -84,7 +84,7 @@ describe('Document query stream test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -114,7 +114,7 @@ describe('Document query stream test', function(){ }). on('end', function() { done(); - }, done); + }, done); }); it('should do simple parse', function(done){ @@ -133,7 +133,7 @@ describe('Document query stream test', function(){ }). on('end', function() { done(); - }, done); + }, done); }); it('should do extract with include-with-ancestors', function(done){ @@ -157,8 +157,30 @@ describe('Document query stream test', function(){ }). on('end', function() { done(); - }, done); + }, done); }); + + it('should do collections query', function(done) { + var count = 0; + var str = ''; + var chunks = []; + db.documents.query( + q.where( + q.collection('matchCollection1') + ) + .slice(0, 5) + ) + .stream() + .on('data', function(chunk) { + count++; + }) + .on('end', function() { + //console.log(count); + count.should.equal(2); + done(); + }, done); + }); + it('should delete all documents', function(done){ dbAdmin.documents.removeAll({ all: true @@ -166,6 +188,6 @@ describe('Document query stream test', function(){ result(function(response) { done(); }, done); - }); - + }); + }); diff --git a/test-complete/nodejs-documents-query.js b/test-complete/nodejs-documents-query.js index 83339fec..33e5f9a7 100644 --- a/test-complete/nodejs-documents-query.js +++ b/test-complete/nodejs-documents-query.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ describe('Document query test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -56,7 +56,7 @@ describe('Document query test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -70,7 +70,7 @@ describe('Document query test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -84,7 +84,7 @@ describe('Document query test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -130,7 +130,7 @@ describe('Document query test', function(){ }); }); - it('should wait for set stemmed searches on database', function(done) { + it('should wait for set stemmed searches on database', function(done) { setTimeout(function() { done(); }, 10000); @@ -152,7 +152,7 @@ describe('Document query test', function(){ this.timeout(20000); db.documents.query( q.where( - q.word('title', 'bush') + q.word('title', 'bush') ). slice(0, 1, q.snippet()). withOptions({categories: 'none'}) @@ -164,12 +164,12 @@ describe('Document query test', function(){ //response[0].results[0].matches[0]['match-text'][1].should.containEql('{ highlight: \'Bush\' }'); done(); }, done); - }); - + }); + it('should do word query withOptions Unfiltered', function(done){ db.documents.query( q.where( - q.word('p', 'The') + q.word('p', 'The') ). withOptions({search:['unfiltered']},{categories: ['content']}) ). @@ -182,7 +182,7 @@ describe('Document query test', function(){ it('should do word query withOptions default and must be unfiltered', function(done){ db.documents.query( q.where( - q.word('p', 'The') + q.word('p', 'The') ). withOptions({categories: ['content']}) ). @@ -195,7 +195,7 @@ describe('Document query test', function(){ it('should do word query witgh slice and withOptions fileterd', function(done){ db.documents.query( q.where( - q.word('p', 'The') + q.word('p', 'The') ). withOptions({search:['filtered']},{categories: ['content']}) ). @@ -205,7 +205,7 @@ describe('Document query test', function(){ done(); }, done); }); - + it('should do term query', function(done){ db.documents.query( q.where( @@ -226,7 +226,7 @@ describe('Document query test', function(){ db.documents.query( q.where( q.or( - q.value('id', '0??6', q.termOptions('wildcarded')), + q.value('id', '0??6', q.termOptions('wildcarded')), q.word('id', '00*2', q.termOptions('wildcarded')) ) ).withOptions({search:['filtered']},{categories: ['content']}) @@ -243,7 +243,7 @@ describe('Document query test', function(){ db.documents.query( q.where( q.or( - q.value('title', 'The memex'), + q.value('title', 'The memex'), q.and( q.value('id', '0013'), q.value('date', '2007-03-03') @@ -263,7 +263,7 @@ describe('Document query test', function(){ db.documents.query( q.where( q.and( - q.term('Atlantic'), + q.term('Atlantic'), q.term('Monthly'), q.term('Bush') ) @@ -349,7 +349,7 @@ describe('Document query test', function(){ db.documents.query( q.where( q.and( - q.term('Atlantic'), + q.term('Atlantic'), q.term('Monthly'), q.term('Bush') ) @@ -369,7 +369,7 @@ describe('Document query test', function(){ db.documents.query( q.where( q.and( - q.term('Atlantic'), + q.term('Atlantic'), q.term('Monthly'), q.term('Bush') ) @@ -445,7 +445,7 @@ it('should delete all documents', function(done){ done(); }, done); }); - + it('should set database stemmed searches back to off', function(done){ var src = "var admin = require('/MarkLogic/admin.xqy');" + "var c = admin.getConfiguration();" + @@ -461,7 +461,7 @@ it('should delete all documents', function(done){ }); }); - it('should wait for set stemmed searches on database', function(done) { + it('should wait for set stemmed searches on database', function(done) { setTimeout(function() { done(); }, 10000); diff --git a/test-complete/nodejs-documents-quick.js b/test-complete/nodejs-documents-quick.js index 06ad819b..0cc2e42f 100644 --- a/test-complete/nodejs-documents-quick.js +++ b/test-complete/nodejs-documents-quick.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ describe('quick path', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - },{ + },{ uri: '/test/query/matchDir/doc3.json', collections: '/matchCollection2', contentType: 'application/json', @@ -60,7 +60,7 @@ describe('quick path', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: '/matchCollection1', contentType: 'application/json', @@ -101,7 +101,7 @@ describe('quick path', function(){ documents[1].content.should.have.property('title'); done(); }, done); - }); + }); /* it('should fail in writing objects to wrong collection', function(done){ dbWriter.createCollection( '/matchCollection3', @@ -152,7 +152,7 @@ describe('quick path', function(){ error.statusCode.should.equal(403); done(); }); - }); + }); it('should query objects', function(done){ dbWriter.queryCollection( '/matchCollection1', @@ -184,7 +184,7 @@ describe('quick path', function(){ error.statusCode.should.equal(403); done(); }); - }); + }); it('should remove a document', function(done) { var docUri = [ '/test/query/matchDir/doc3.json' ]; dbWriter.remove(docUri). diff --git a/test-complete/nodejs-documents-read-chunk.js b/test-complete/nodejs-documents-read-chunk.js index f9ebfecb..3b703ae7 100644 --- a/test-complete/nodejs-documents-read-chunk.js +++ b/test-complete/nodejs-documents-read-chunk.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ var dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Binary documents test', function(){ - var binaryPath = './node-client-api/test-complete/data/somePdfFile.pdf'; + var binaryPath = __dirname + '/data/somePdfFile.pdf'; var uri = '/test/binary/somePdfFile.pdf'; var binaryValue = null; before(function(done){ @@ -40,7 +40,7 @@ describe('Binary documents test', function(){ pipe(concatStream({encoding: 'buffer'}, function(value){ binaryValue = value; done(); - })); + })); }); it('should write the binary with Readable stream', function(done){ @@ -58,10 +58,10 @@ describe('Binary documents test', function(){ result(function(response){ response.should.have.property('documents'); done(); - }, done); + }, done); }); - it('should wait for the document to be written', function(done) { + it('should wait for the document to be written', function(done) { setTimeout(function() { done(); }, 10000); @@ -78,7 +78,7 @@ describe('Binary documents test', function(){ }). on('end', function() { done(); - }, done); + }, done); }, 3000); }); it('should delete all documents', function(done){ @@ -88,7 +88,7 @@ it('should delete all documents', function(done){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-remove-multiple.js b/test-complete/nodejs-documents-remove-multiple.js index a3dfb1dd..7fef1e96 100644 --- a/test-complete/nodejs-documents-remove-multiple.js +++ b/test-complete/nodejs-documents-remove-multiple.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test-complete/nodejs-documents-removeAll-all.js b/test-complete/nodejs-documents-removeAll-all.js index f8fd3586..f1b39054 100644 --- a/test-complete/nodejs-documents-removeAll-all.js +++ b/test-complete/nodejs-documents-removeAll-all.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document remove all with all param', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('Document remove all with all param', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('Document remove all with all param', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -83,7 +83,7 @@ describe('Document remove all with all param', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', diff --git a/test-complete/nodejs-documents-removeAll-negative.js b/test-complete/nodejs-documents-removeAll-negative.js index d31b2605..74b85fea 100644 --- a/test-complete/nodejs-documents-removeAll-negative.js +++ b/test-complete/nodejs-documents-removeAll-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document remove all negative test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('Document remove all negative test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('Document remove all negative test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -83,7 +83,7 @@ describe('Document remove all negative test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', diff --git a/test-complete/nodejs-documents-removeAll.js b/test-complete/nodejs-documents-removeAll.js index 0bbeea84..533dcaff 100644 --- a/test-complete/nodejs-documents-removeAll.js +++ b/test-complete/nodejs-documents-removeAll.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ describe('Document remove all test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -55,7 +55,7 @@ describe('Document remove all test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -69,7 +69,7 @@ describe('Document remove all test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -83,7 +83,7 @@ describe('Document remove all test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', diff --git a/test-complete/nodejs-documents-resources-config.js b/test-complete/nodejs-documents-resources-config.js index 1dc2b528..6635e6ea 100644 --- a/test-complete/nodejs-documents-resources-config.js +++ b/test-complete/nodejs-documents-resources-config.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,14 +29,14 @@ var restAdminDB = marklogic.createDatabaseClient(testconfig.restAdminConnection) describe('when configuring resource services', function(){ var serviceName = 'timeService'; var serviceNameInvalid = 'BlaBla'; - var servicePath = './node-client-api/test-basic/data/timeService.xqy'; + var servicePath = __dirname + '/../test-basic/data/timeService.xqy'; it('should write the resource service with positional parameters', function(done){ this.timeout(10000); restAdminDB.config.resources.write(serviceName, 'xquery', fs.createReadStream(servicePath)). result(function(response){ done(); }, done); - }); + }); it('should write the resource service with named parameters', function(done){ this.timeout(10000); restAdminDB.config.resources.write({ @@ -51,7 +51,7 @@ describe('when configuring resource services', function(){ result(function(response){ done(); }, done); - }); + }); it('should read the resource service', function(done){ restAdminDB.config.resources.read(serviceName). result(function(source){ @@ -59,8 +59,8 @@ describe('when configuring resource services', function(){ (valcheck.isNullOrUndefined(source)).should.equal(false); done(); }, done); - }); - + }); + it('should try to read the resource service via invalid name', function(done){ restAdminDB.config.resources.read(serviceNameInvalid). result(function(source){ @@ -83,7 +83,7 @@ describe('when configuring resource services', function(){ length.should.equal(1); done(); }, done); - }); + }); it('should over-write the resource service with named parameters', function(done){ this.timeout(10000); restAdminDB.config.resources.write({ @@ -98,21 +98,21 @@ describe('when configuring resource services', function(){ result(function(response){ done(); }, done); - }); - + }); + /* //Need to get to the content first it('should delete specified resource config ', function(done){ restAdminDB.config.resources.resource.remove(serviceName). result(function(response){ done(); }, done); - }); */ + }); */ it('should delete the resource service', function(done){ restAdminDB.config.resources.remove(serviceName). result(function(response){ done(); }, done); - }); + }); it('should try read the resource service after remove', function(done){ restAdminDB.config.resources.read(serviceName). result(function(source){ @@ -121,11 +121,11 @@ describe('when configuring resource services', function(){ (valcheck.isNullOrUndefined(error)).should.equal(false); done(); }, done); - }); + }); it('should delete the invalid resource service', function(done){ restAdminDB.config.resources.remove(serviceNameInvalid). result(function(response){ done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-resources.js b/test-complete/nodejs-documents-resources.js index f903e8f1..cb4181eb 100644 --- a/test-complete/nodejs-documents-resources.js +++ b/test-complete/nodejs-documents-resources.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ var restAdminDB = marklogic.createDatabaseClient(testconfig.restAdminConnection) describe('when executing resource services', function(){ describe('using XQuery', function() { var xqyServiceName = 'wrapperService'; - var xqyServicePath = './node-client-api/test-basic/data/wrapperService.xqy'; + var xqyServicePath = __dirname + '/../test-basic/data/wrapperService.xqy'; before(function(done){ this.timeout(10000); restAdminDB.config.resources.write(xqyServiceName, 'xquery', fs.createReadStream(xqyServicePath)). @@ -78,7 +78,7 @@ describe('when executing resource services', function(){ done(); }, done); }); - + it('should get two documents', function(done){ db.resources.get({ name:xqyServiceName, params:{value:'foo', multipart:'true'} @@ -171,9 +171,9 @@ describe('when executing resource services', function(){ done(); }, done); }); - - - }); + + + }); it('should put one untyped document', function(done){ db.resources.put({ name:xqyServiceName, params:{value:'foo'}, documents:[ @@ -336,7 +336,7 @@ it('should put one untyped document', function(done){ }); }); it('should remove one document with transaction', function(done){ - + var tid = null; db.transactions.open().result(). then(function(response) { diff --git a/test-complete/nodejs-documents-suggest.js b/test-complete/nodejs-documents-suggest.js index b2d68cd2..e22b923b 100644 --- a/test-complete/nodejs-documents-suggest.js +++ b/test-complete/nodejs-documents-suggest.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ describe('Document suggest test', function(){ taggedWordKey: 'apple', otherKey: 'aruba' } - }, { + }, { uri: '/test/query/suggest/doc2.json', collections: ['suggestCollection'], contentType: 'application/json', @@ -44,7 +44,7 @@ describe('Document suggest test', function(){ defaultWordKey: 'memento', taggedWordKey: 'application' } - }, { + }, { uri: '/test/query/suggest/doc3.json', collections: ['suggestCollection'], contentType: 'application/json', @@ -52,7 +52,7 @@ describe('Document suggest test', function(){ defaultWordKey: 'mendoza', taggedWordKey: 'approximate' } - }, { + }, { uri: '/test/query/suggest/doc4.json', collections: ['suggestCollection'], contentType: 'application/json', @@ -60,7 +60,7 @@ describe('Document suggest test', function(){ defaultWordKey: 'memoir', taggedWordKey: 'ape' } - }, { + }, { uri: '/test/query/suggest/doc5.json', collections: ['suggestCollection'], contentType: 'application/json', @@ -74,7 +74,7 @@ describe('Document suggest test', function(){ it('should do suggest with default binding', function(done){ db.documents.suggest({ - partial: 'mem', + partial: 'mem', query: q.where( q.parsedFrom('', q.parseBindings( @@ -96,7 +96,7 @@ describe('Document suggest test', function(){ it('should do suggest with default binding without parsedFrom', function(done){ db.documents.suggest( - 'mem', + 'mem', q.where( q.directory('/test/query/suggest/', true) ), @@ -117,7 +117,7 @@ describe('Document suggest test', function(){ it('should do suggest with default binding and limit', function(done){ db.documents.suggest({ - partial: 'mem', + partial: 'mem', query: q.where( q.parsedFrom('', q.parseBindings( @@ -125,7 +125,7 @@ describe('Document suggest test', function(){ ) ) ), - limit: 2 + limit: 2 }). result(function(response) { //console.log(response); @@ -138,7 +138,7 @@ describe('Document suggest test', function(){ it('should do suggest with default binding and exceeding limit', function(done){ db.documents.suggest({ - partial: 'mem', + partial: 'mem', query: q.where( q.parsedFrom('', q.suggestBindings( @@ -161,7 +161,7 @@ describe('Document suggest test', function(){ it('should do suggest with binding', function(done){ db.documents.suggest({ - partial: 'tag1:app', + partial: 'tag1:app', query: q.where( q.parsedFrom('', q.parseBindings( @@ -183,7 +183,7 @@ describe('Document suggest test', function(){ it('should do suggest with overriden default binding', function(done){ db.documents.suggest({ - partial: 'a', + partial: 'a', query: q.where( q.parsedFrom('', q.parseBindings( @@ -206,7 +206,7 @@ describe('Document suggest test', function(){ it('should do suggest with overriden binding', function(done){ db.documents.suggest({ - partial: 'tag1:a', + partial: 'tag1:a', query: q.where( q.parsedFrom('', q.parseBindings( @@ -229,7 +229,7 @@ describe('Document suggest test', function(){ it('should do suggest with binding and limit', function(done){ db.documents.suggest({ - partial: 'tag1:app', + partial: 'tag1:app', query: q.where( q.parsedFrom('', q.suggestBindings( @@ -250,7 +250,7 @@ describe('Document suggest test', function(){ it('should do suggest with multiple bindings', function(done){ db.documents.suggest({ - partial: 'tag1:a', + partial: 'tag1:a', query: q.where( q.parsedFrom('', q.parseBindings( @@ -272,7 +272,7 @@ describe('Document suggest test', function(){ it('should fail with invalid binding', function(done){ db.documents.suggest({ - partial: 'a', + partial: 'a', query: q.where( q.parsedFrom('', q.parseBindings( @@ -298,7 +298,7 @@ describe('Document suggest test', function(){ it('should fail with negative limit', function(done){ db.documents.suggest({ - partial: 'a', + partial: 'a', query: q.where( q.parsedFrom('', q.parseBindings( diff --git a/test-complete/nodejs-documents-transaction-combo.js b/test-complete/nodejs-documents-transaction-combo.js index 0bce9ec6..7892d456 100644 --- a/test-complete/nodejs-documents-transaction-combo.js +++ b/test-complete/nodejs-documents-transaction-combo.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ var q = marklogic.queryBuilder; var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('Transaction combo test', function() { - + var tid = 0; var tid2 = 0; @@ -51,13 +51,13 @@ describe('Transaction combo test', function() { .then(function(response) { //console.log(JSON.stringify(response, null, 2)); response['transaction-status']['transaction-id'].should.equal(tid); - response['transaction-status']['time-limit'].should.equal('30'); + parseInt(response['transaction-status']['time-limit']).should.be.above(27); return db.transactions.rollback(tid).result(); }) .then(function(response) { //console.log(JSON.stringify(response, null, 2)); response.finished.should.equal('rollback'); - return db.documents.read({uris: '/test/transaction/doc1.json'}).result(); + return db.documents.read({uris: '/test/transaction/doc1.json'}).result(); }) .then(function(response) { //console.log(JSON.stringify(response, null, 2)); @@ -87,13 +87,13 @@ describe('Transaction combo test', function() { .then(function(response) { //console.log(JSON.stringify(response, null, 2)); response.finished.should.equal('commit'); - return db.documents.read({uris: '/test/transaction/doc1.json'}).result(); + return db.documents.read({uris: '/test/transaction/doc1.json'}).result(); }) .then(function(response) { //console.log(JSON.stringify(response, null, 2)); response[0].content.lastname.should.equal('Adams'); response[0].content.txKey.should.equal(tid2); - return db.documents.remove('/test/transaction/doc1.json').result(); + return db.documents.remove('/test/transaction/doc1.json').result(); }) .then(function(response) { response.removed.should.equal(true); diff --git a/test-complete/nodejs-documents-transaction-remove.js b/test-complete/nodejs-documents-transaction-remove.js index c7b56f63..a1495cf4 100644 --- a/test-complete/nodejs-documents-transaction-remove.js +++ b/test-complete/nodejs-documents-transaction-remove.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ var q = marklogic.queryBuilder; var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('Transaction remove multiple documents test', function() { - + var tid = 0; var tid2 = 0; @@ -68,7 +68,7 @@ describe('Transaction remove multiple documents test', function() { .then(function(response) { //console.log(JSON.stringify(response, null, 2)); response[0].uri.should.equal('/test/remove/transaction/doc1.json'); - return db.transactions.commit(tid).result(); + return db.transactions.commit(tid).result(); }) .then(function(response) { //console.log(JSON.stringify(response, null, 2)); @@ -90,7 +90,7 @@ describe('Transaction remove multiple documents test', function() { return db.documents.remove({ txid: tid2, uris: [ - '/test/remove/transaction/doc1.json', + '/test/remove/transaction/doc1.json', '/test/remove/transaction/doc2.json' ] }).result(); diff --git a/test-complete/nodejs-documents-transaction-timelimit.js b/test-complete/nodejs-documents-transaction-timelimit.js index c4ca390e..2a4d9ade 100644 --- a/test-complete/nodejs-documents-transaction-timelimit.js +++ b/test-complete/nodejs-documents-transaction-timelimit.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); var tid = null; describe('Document transaction test', function() { - + // Set transaction time limit to be 1 second /* it('should commit the write document', function(done) { db.transactions.open({transactionName: "nodeTransaction", timeLimit: 1}).result(). @@ -37,7 +37,7 @@ describe('Document transaction test', function() { contentType: 'application/json', content: {firstname: "John", lastname: "Doe", txKey: tid} }).result(function(response) {done();}, done); - }) + }) }); // Read about transaction status @@ -70,7 +70,7 @@ it('should commit the write document', function(done) { .then(function(response) { //console.log(JSON.stringify(response, null, 2)); response['transaction-status']['transaction-name'].should.equal('nodeTransaction'); - response['transaction-status']['time-limit'].should.equal('2'); + parseInt(response['transaction-status']['time-limit']).should.be.above(0); done(); }, done); /*.catch(function(error) { @@ -91,7 +91,7 @@ it('should commit the write document', function(done) { db.documents.read({uris:'/test/transaction/doc1.json', txid: tid,}).result(function(response) { console.log("Response: " + JSON.stringify(response)); done(new Error("Response did not time out")); - }, + }, function(err) { err.statusCode.should.equal(400); err.body.errorResponse.messageCode.should.equal("XDMP-NOTXN"); @@ -106,18 +106,18 @@ it('should commit the write document', function(done) { function(response) { console.log("Response: " + JSON.stringify(response)); done(new Error("Response did not time out")); - }, + }, function(err) { err.statusCode.should.equal(400); err.body.errorResponse.messageCode.should.equal("XDMP-NOTXN"); done(); }); - }); + }); it('should remove all documents', function(done) { dbAdmin.documents.removeAll({all: true}). result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-transaction-withstate.js b/test-complete/nodejs-documents-transaction-withstate.js index 2d83f78b..e06799ea 100644 --- a/test-complete/nodejs-documents-transaction-withstate.js +++ b/test-complete/nodejs-documents-transaction-withstate.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ var q = marklogic.queryBuilder; var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('Transaction with state test', function() { - + var tid = 0; var tid2 = 0; var hostId = 0; @@ -51,13 +51,13 @@ describe('Transaction with state test', function() { //console.log(JSON.stringify(response, null, 2)); response['transaction-status']['host']['host-id'].should.equal(hostId); response['transaction-status']['transaction-id'].should.equal(tid); - response['transaction-status']['time-limit'].should.equal('30'); + parseInt(response['transaction-status']['time-limit']).should.be.above(27); return db.transactions.rollback(tid).result(); }) .then(function(response) { //console.log(JSON.stringify(response, null, 2)); response.finished.should.equal('rollback'); - return db.documents.read({uris: '/test/state/transaction/doc1.json'}).result(); + return db.documents.read({uris: '/test/state/transaction/doc1.json'}).result(); }) .then(function(response) { //console.log(JSON.stringify(response, null, 2)); @@ -91,13 +91,13 @@ describe('Transaction with state test', function() { .then(function(response) { //console.log(JSON.stringify(response, null, 2)); response.finished.should.equal('commit'); - return db.documents.read({uris: '/test/state/transaction/doc1.json'}).result(); + return db.documents.read({uris: '/test/state/transaction/doc1.json'}).result(); }) .then(function(response) { //console.log(JSON.stringify(response, null, 2)); response[0].content.lastname.should.equal('Adams'); response[0].content.txKey.should.equal(tid2); - return db.documents.remove('/test/state/transaction/doc1.json').result(); + return db.documents.remove('/test/state/transaction/doc1.json').result(); }) .then(function(response) { response.removed.should.equal(true); diff --git a/test-complete/nodejs-documents-transaction.js b/test-complete/nodejs-documents-transaction.js index 95b84c85..b30caa51 100644 --- a/test-complete/nodejs-documents-transaction.js +++ b/test-complete/nodejs-documents-transaction.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Document transaction test', function() { - + it('should commit the write document', function(done) { this.timeout(10000); var tid = null; @@ -41,7 +41,7 @@ describe('Document transaction test', function() { then(function(response) { return db.transactions.commit(tid). result(function(response) {done();}, done); - }); + }); }); it('should read the commited document', function(done) { @@ -81,7 +81,7 @@ describe('Document transaction test', function() { then(function(response) { return db.transactions.rollback(tid). result(function(response) {done();}, done); - }); + }); });*/ it('should rollback the write document', function(done) { @@ -97,14 +97,14 @@ describe('Document transaction test', function() { content: {firstname: "Peter", lastname: "Pan", txKey: tid} }).result(); }). - + then(function(response) { //console.log(response); return db.transactions.rollback(tid) - .result(function(response) { + .result(function(response) { //console.log(response); done();}, done); - }); + }); }); /*it('should be able to read the rolled back document', function(done) { this.timeout(10000); @@ -134,17 +134,17 @@ describe('Document transaction test', function() { then(function(response) { return db.documents.write({ txid: tid, - uri: '/test/transaction/doc3.json', + uri: '/test/transaction/doc3.json', contentType: 'application/json', content: {firstname: "Chuck", lastname: "Sang", txKey: tid} }).result(); }). then(function(response) { return db.transactions.rollback(tid). - result(function(response) { + result(function(response) { //console.log(response); done();}, done); - }); + }); }); it('should be able to read the original document', function(done) { @@ -161,14 +161,14 @@ describe('Document transaction test', function() { done(); }); }); - - + + it('should remove all documents', function(done) { this.timeout(10000); dbAdmin.documents.removeAll({all: true}). result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-values-negative.js b/test-complete/nodejs-documents-values-negative.js index 64b8e76f..1698a9b1 100644 --- a/test-complete/nodejs-documents-values-negative.js +++ b/test-complete/nodejs-documents-values-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ describe('Document tuples negative test', function(){ values: [{score: 56.7}, {rate: 3}], p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -58,7 +58,7 @@ describe('Document tuples negative test', function(){ values: [{score: 92.45}, {rate: 5}], p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -73,7 +73,7 @@ describe('Document tuples negative test', function(){ values: [{score: 33.56}, {rate: 1}], p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -88,7 +88,7 @@ describe('Document tuples negative test', function(){ values: [{score: 12.34}, {rate: 3}], p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', diff --git a/test-complete/nodejs-documents-values.js b/test-complete/nodejs-documents-values.js index b56d5207..4274b46b 100644 --- a/test-complete/nodejs-documents-values.js +++ b/test-complete/nodejs-documents-values.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ describe('Document tuples test', function(){ values: [{score: 56.7}, {rate: 3}], p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -58,7 +58,7 @@ describe('Document tuples test', function(){ values: [{score: 92.45}, {rate: 5}], p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -73,7 +73,7 @@ describe('Document tuples test', function(){ values: [{score: 33.56}, {rate: 1}], p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -88,7 +88,7 @@ describe('Document tuples test', function(){ values: [{score: 12.34}, {rate: 3}], p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -213,7 +213,7 @@ describe('Document tuples test', function(){ }); it('should do values on path', function(done){ - this.timeout(10000); + this.timeout(10000); db.values.read( t.fromIndexes(t.pathIndex('price/amt')) ).result(function (values) { @@ -230,12 +230,12 @@ describe('Document tuples test', function(){ done(); }, done); }); - - /* + + /* //Issue with Index settings working on it //Need to create a filed name : filed_for_valueread and a range index in it on title type string it('should do values on field', function(done){ - this.timeout(10000); + this.timeout(10000); db.values.read( t.fromIndexes( t.field('filed_for_valueread') @@ -251,7 +251,7 @@ describe('Document tuples test', function(){ done(); }, done); }); */ - + it('should do sum aggregates', function(done){ this.timeout(10000); db.values.read( diff --git a/test-complete/nodejs-documents-write-large.js b/test-complete/nodejs-documents-write-large.js index e7923ed5..6cc514c0 100644 --- a/test-complete/nodejs-documents-write-large.js +++ b/test-complete/nodejs-documents-write-large.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ var dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Large document write test', function(){ - var binaryPath = './node-client-api/test-complete/data/shaks200all.xml'; + var binaryPath = __dirname + '/data/shaks200all.xml'; var uri = '/test/binary/shaks200all.xml'; var binaryValue = null; before(function(done){ @@ -40,7 +40,7 @@ describe('Large document write test', function(){ pipe(concatStream({encoding: 'buffer'}, function(value){ binaryValue = value; done(); - })); + })); }); it('should write the large document with Readable stream', function(done){ @@ -58,7 +58,7 @@ describe('Large document write test', function(){ result(function(response){ response.should.have.property('documents'); done(); - }, done); + }, done); }); /*it('should read the large document with Readable stream', function(done){ @@ -71,7 +71,7 @@ describe('Large document write test', function(){ count.should.equal(2064); //console.log(JSON.stringify(documents, null, 2)); done(); - }, done); + }, done); });*/ it('should read the large document with Readable stream', function(done){ @@ -91,7 +91,7 @@ describe('Large document write test', function(){ chunks.should.be.greaterThan(1); length.should.equal(7648280); done(); - }, done); + }, done); }); it('should read the large document metadata', function(done) { @@ -105,7 +105,7 @@ describe('Large document write test', function(){ done(); }, done); }); - + it('should delete the xml file file', function(done){ dbAdmin.documents.removeAll({ all: true @@ -113,7 +113,7 @@ describe('Large document write test', function(){ result(function(response) { done(); }, done); - }); + }); }); diff --git a/test-complete/nodejs-documents-write-stream.js b/test-complete/nodejs-documents-write-stream.js index 0632489c..a7a547c9 100644 --- a/test-complete/nodejs-documents-write-stream.js +++ b/test-complete/nodejs-documents-write-stream.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ describe('Write Document Stream Test', function() { contentType: 'application/json' }); writeStream.result(function(response) {done();}, done); - writeStream.write('{"title":"hello"}', 'utf8'); + writeStream.write('{"title":"hello"}', 'utf8'); writeStream.end(); }); it('should read back the value', function(done){ @@ -44,7 +44,7 @@ describe('Write Document Stream Test', function() { done(); }, done); }); - }); + }); describe('write json stream in chunk', function() { before(function(done) { @@ -54,8 +54,8 @@ describe('Write Document Stream Test', function() { contentType: 'application/json' }); writeStream.result(function(response) {done();}, done); - writeStream.write('{"title":"El Dorado", ', 'utf8'); - writeStream.write('"count":5}', 'utf8'); + writeStream.write('{"title":"El Dorado", ', 'utf8'); + writeStream.write('"count":5}', 'utf8'); writeStream.end(); }); it('should read back the value', function(done){ @@ -66,7 +66,7 @@ describe('Write Document Stream Test', function() { }, done); }); }); - + describe('write xml stream in chunk', function() { before(function(done) { this.timeout(10000); @@ -75,8 +75,8 @@ describe('Write Document Stream Test', function() { contentType: 'application/xml' }); writeStream.result(function(response) {done();}, done); - writeStream.write('hello', 'utf8'); - writeStream.write('', 'utf8'); + writeStream.write('hello', 'utf8'); + writeStream.write('', 'utf8'); writeStream.end(); }); it('should read back the value', function(done){ @@ -87,12 +87,12 @@ describe('Write Document Stream Test', function() { }, done); }); }); - + describe('write transform for a test', function() { before(function(done) { this.timeout(10000); var transformName = 'employeeStylesheet'; - var transformPath = './node-client-api/test-complete/data/employeeStylesheet.xslt'; + var transformPath = __dirname + '/data/employeeStylesheet.xslt'; fs.createReadStream(transformPath). pipe(concatStream({encoding:'string'}, function(source) { dbAdmin.config.transforms.write(transformName, 'xslt', source). @@ -114,8 +114,8 @@ describe('Write Document Stream Test', function() { transform: [transformName] }); writeStream.result(function(response) {done();}, done); - writeStream.write('John', 'utf8'); - writeStream.write('', 'utf8'); + writeStream.write('John', 'utf8'); + writeStream.write('', 'utf8'); writeStream.end(); }); it('should read back the value', function(done){ diff --git a/test-complete/nodejs-extlibs-negative.js b/test-complete/nodejs-extlibs-negative.js index 4af38df6..f617aa03 100644 --- a/test-complete/nodejs-extlibs-negative.js +++ b/test-complete/nodejs-extlibs-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,16 +25,16 @@ var dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Extlib negative test', function(){ - var fsPath = './node-client-api/test-complete/data/sourceParams.js'; + var fsPath = __dirname + '/data/sourceParams.js'; var invokePath = '/ext/invokeTest/sourceParams.sjs'; - var invalidFsPath = './node-client-api/test-complete/data/someInvalidFile.js'; + var invalidFsPath = __dirname + '/data/someInvalidFile.js'; before(function(done) { this.timeout(10000); dbAdmin.config.extlibs.write({ path:invokePath, contentType:'application/javascript', source:fs.createReadStream(fsPath) }). - result(function(response){done();}, done); + result(function(response){done();}, done); }); after(function(done) { @@ -51,7 +51,7 @@ describe('Extlib negative test', function(){ done(); }, function(error) { //console.log(error.body); - error.body.errorResponse.messageCode.should.equal('REST-FAILEDAUTH'); + error.body.errorResponse.messageCode.should.equal('SEC-PRIV'); error.statusCode.should.equal(403); done(); }); diff --git a/test-complete/nodejs-extlibs.js b/test-complete/nodejs-extlibs.js index 3357e11b..d4e4aa44 100644 --- a/test-complete/nodejs-extlibs.js +++ b/test-complete/nodejs-extlibs.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,14 +30,14 @@ var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Extension library test', function(){ var dbPath = '/marklogic/snippet/custom/extractFirst.xqy'; - var fsPath = './node-client-api/test-complete/data/extractFirst.xqy'; + var fsPath = __dirname + '/data/extractFirst.xqy'; it('should write the extension library', function(done){ this.timeout(10000); dbAdmin.config.extlibs.write( - dbPath, - {'role-name':'app-user', capabilities:['execute']}, - 'application/xquery', + dbPath, + {'role-name':'app-user', capabilities:['execute']}, + 'application/xquery', fs.createReadStream(fsPath)). result(function(response){done();}, done); }); @@ -49,7 +49,7 @@ describe('Extension library test', function(){ done(); }, done); }); - + it('should list the extension libraries', function(done){ dbAdmin.config.extlibs.list(). result(function(response){ diff --git a/test-complete/nodejs-graphs-content-type.js b/test-complete/nodejs-graphs-content-type.js index ac6371d8..6bfec2d7 100644 --- a/test-complete/nodejs-graphs-content-type.js +++ b/test-complete/nodejs-graphs-content-type.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('content type graph test', function(){ var graphUri = 'http://marklogic.com/graphs/content#type'; - var graphPath = './node-client-api/test-complete/data/mlgraph.ttl'; + var graphPath = __dirname + '/data/mlgraph.ttl'; before('should write the graph', function(done){ this.timeout(10000); @@ -115,7 +115,7 @@ describe('content type graph test', function(){ "FROM \n" + "WHERE {?s ad:firstName 'John'}" db.graphs.sparql({ - contentType: 'application/sparql-results+xml', + contentType: 'application/sparql-results+xml', query: myQuery }). result(function(response){ @@ -132,7 +132,7 @@ describe('content type graph test', function(){ "FROM \n" + "WHERE {?s ad:firstName 'John'}" db.graphs.sparql({ - contentType: 'text/csv', + contentType: 'text/csv', query: myQuery }). result(function(response){ @@ -149,7 +149,7 @@ describe('content type graph test', function(){ "FROM \n" + "WHERE {?s ad:firstName 'John'}" db.graphs.sparql({ - contentType: 'text/html', + contentType: 'text/html', query: myQuery }). result(function(response){ @@ -164,7 +164,7 @@ describe('content type graph test', function(){ this.timeout(10000); var myQuery = "DESCRIBE " db.graphs.sparql({ - contentType: 'application/n-triples', + contentType: 'application/n-triples', query: myQuery }). result(function(response){ @@ -178,7 +178,7 @@ describe('content type graph test', function(){ this.timeout(10000); var myQuery = "DESCRIBE " db.graphs.sparql({ - contentType: 'application/n-quads', + contentType: 'application/n-quads', query: myQuery }). result(function(response){ @@ -192,7 +192,7 @@ describe('content type graph test', function(){ this.timeout(10000); var myQuery = "DESCRIBE " db.graphs.sparql({ - contentType: 'application/sparql-results+json', + contentType: 'application/sparql-results+json', query: myQuery }). result(function(response){ @@ -209,7 +209,7 @@ describe('content type graph test', function(){ this.timeout(10000); var myQuery = "DESCRIBE " db.graphs.sparql({ - contentType: 'application/rdf+xml', + contentType: 'application/rdf+xml', query: myQuery }). result(function(response){ diff --git a/test-complete/nodejs-graphs-default.js b/test-complete/nodejs-graphs-default.js index 9eed693d..48dfc295 100644 --- a/test-complete/nodejs-graphs-default.js +++ b/test-complete/nodejs-graphs-default.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,9 +27,9 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('default graph test', function(){ var graphUri = 'marklogic.com/defafult/people'; - var graphPath = './node-client-api/test-complete/data/people.ttl'; - var sparqlPath = './node-client-api/test-complete/data/people.rq'; - var sparqlPath2 = './node-client-api/test-complete/data/people2.rq'; + var graphPath = __dirname + '/data/people.ttl'; + var sparqlPath = __dirname + '/data/people.rq'; + var sparqlPath2 = __dirname + '/data/people2.rq'; var defGraphUri = 'http://marklogic.com/semantics#default-graph'; it('should write the default graph', function(done){ @@ -68,7 +68,7 @@ describe('default graph test', function(){ it('should list the graph', function(done){ this.timeout(10000); - db.graphs.list(). + db.graphs.list(). result(function(collections){ collections.some(function(collection){ return collection === defGraphUri; @@ -101,9 +101,9 @@ describe('default graph test', function(){ var myQuery = "PREFIX foaf: " + "PREFIX ppl: " + "SELECT *" + - "WHERE { ?s foaf:knows ppl:person8 }" + "WHERE { ?s foaf:knows ppl:person8 }" db.graphs.sparql({ - contentType: 'application/sparql-results+json', + contentType: 'application/sparql-results+json', //query: fs.createReadStream(sparqlPath2) query: myQuery }). @@ -114,6 +114,45 @@ describe('default graph test', function(){ }, done); }); + it('should run combined SPARQL query', function(done){ + this.timeout(10000); + var myQuery = "PREFIX foaf: " + + "PREFIX ppl: " + + "SELECT *" + + "WHERE { ppl:person1 foaf:knows ?o }" + var docQuery = q.where(q.term('person5')); + db.graphs.sparql({ + contentType: 'application/sparql-results+json', + query: myQuery, + docQuery: docQuery + }). + result(function(response){ + //console.log(JSON.stringify(response, null, 2)); + response.results.bindings.length.should.equal(4); + response.results.bindings[0].o.value.should.equal('http://people.org/person2'); + done(); + }, done); + }); + + it('should run combined SPARQL query with invalid docQuery', function(done){ + this.timeout(10000); + var myQuery = "PREFIX foaf: " + + "PREFIX ppl: " + + "SELECT *" + + "WHERE { ppl:person1 foaf:knows ?o }" + var docQuery = q.where(q.term('foo')); + db.graphs.sparql({ + contentType: 'application/sparql-results+json', + query: myQuery, + docQuery: docQuery + }). + result(function(response){ + //console.log(JSON.stringify(response, null, 2)); + response.results.bindings.length.should.equal(0); + done(); + }, done); + }); + it('should delete the graph', function(done){ this.timeout(10000); db.graphs.remove(). diff --git a/test-complete/nodejs-graphs-merge-stream.js b/test-complete/nodejs-graphs-merge-stream.js index d39d91cb..c55cf9e3 100644 --- a/test-complete/nodejs-graphs-merge-stream.js +++ b/test-complete/nodejs-graphs-merge-stream.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('merge stream graph test', function(){ var graphUri = 'marklogic.com/stream/merge/people'; - var graphPath1 = './node-client-api/test-complete/data/people3.ttl'; - var graphPath2 = './node-client-api/test-complete/data/people4.ttl'; - var sparqlPath = './node-client-api/test-complete/data/people.rq'; + var graphPath1 = __dirname + '/data/people3.ttl'; + var graphPath2 = __dirname + '/data/people4.ttl'; + var sparqlPath = __dirname + '/data/people.rq'; it('should write the first graph with stream', function(done){ this.timeout(10000); @@ -56,7 +56,7 @@ describe('merge stream graph test', function(){ fs.createReadStream(graphPath2).pipe(ws); }); - it('should wait for the graphs to get merged', function(done) { + it('should wait for the graphs to get merged', function(done) { setTimeout(function() { done(); }, 10000); @@ -81,7 +81,7 @@ describe('merge stream graph test', function(){ it('should list the merged graph', function(done){ this.timeout(10000); - db.graphs.list(). + db.graphs.list(). result(function(collections){ //console.log(collections); collections.some(function(collection){ diff --git a/test-complete/nodejs-graphs-merge.js b/test-complete/nodejs-graphs-merge.js index 2fb885aa..b1060454 100644 --- a/test-complete/nodejs-graphs-merge.js +++ b/test-complete/nodejs-graphs-merge.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('merge graph test', function(){ var graphUri = 'marklogic.com/merge/people'; var graphUriInv = 'marklogic.com/invalid'; - var graphPath1 = './node-client-api/test-complete/data/people3.ttl'; - var graphPath2 = './node-client-api/test-complete/data/people4.ttl'; - var sparqlPath = './node-client-api/test-complete/data/people.rq'; + var graphPath1 = __dirname + '/data/people3.ttl'; + var graphPath2 = __dirname + '/data/people4.ttl'; + var sparqlPath = __dirname + '/data/people.rq'; it('should write the first graph', function(done){ this.timeout(10000); @@ -50,7 +50,7 @@ describe('merge graph test', function(){ }, done); }); - it('should wait for the graphs to get merged', function(done) { + it('should wait for the graphs to get merged', function(done) { setTimeout(function() { done(); }, 10000); @@ -81,7 +81,7 @@ describe('merge graph test', function(){ it('should list the merged graph', function(done){ this.timeout(10000); - db.graphs.list(). + db.graphs.list(). result(function(collections){ collections.some(function(collection){ return collection === graphUri; @@ -116,6 +116,45 @@ describe('merge graph test', function(){ }, done); }); + it('should run a combined SPARQL query', function(done){ + this.timeout(20000); + var docQuery = q.where(q.term('person1')); + var myQuery = "PREFIX foaf: " + + "PREFIX ppl: " + + "SELECT *" + + "WHERE { ppl:person1 foaf:knows ?o }" + db.graphs.sparql({ + contentType: 'application/sparql-results+json', + query: myQuery, + docQuery: docQuery + }). + result(function(response){ + //console.log(JSON.stringify(response, null, 2)) + response.results.bindings.length.should.equal(1); + response.results.bindings[0].o.value.should.equal('http://people.org/person2'); + done(); + }, done); + }); + + it('should run a combined SPARQL query with invalid docQuery', function(done){ + this.timeout(20000); + var docQuery = q.where(q.term('foo')); + var myQuery = "PREFIX foaf: " + + "PREFIX ppl: " + + "SELECT *" + + "WHERE { ppl:person1 foaf:knows ?o }" + db.graphs.sparql({ + contentType: 'application/sparql-results+json', + query: myQuery, + docQuery: docQuery + }). + result(function(response){ + //console.log(JSON.stringify(response, null, 2)) + response.results.bindings.length.should.equal(0); + done(); + }, done); + }); + it('should delete the merged graph', function(done){ this.timeout(10000); db.graphs.remove(graphUri). diff --git a/test-complete/nodejs-graphs-negative.js b/test-complete/nodejs-graphs-negative.js index 84f4d2e1..5b1e9297 100644 --- a/test-complete/nodejs-graphs-negative.js +++ b/test-complete/nodejs-graphs-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,8 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('graph negative test', function(){ var graphUri = 'marklogic.com/negative/people'; - var graphPath = './node-client-api/test-complete/data/people.ttl'; - var sparqlPath = './node-client-api/test-complete/data/people.rq'; + var graphPath = __dirname + '/data/people.ttl'; + var sparqlPath = __dirname + '/data/people.rq'; it('should write the graph', function(done){ this.timeout(10000); @@ -130,8 +130,8 @@ describe('graph negative test', function(){ it('should fail to write graph with invalid permissions', function(done){ this.timeout(10000); db.graphs.write({ - uri: graphUri, - contentType: 'text/turtle', + uri: graphUri, + contentType: 'text/turtle', data: fs.createReadStream(graphPath), permissions: [{'role-name': 'invalid-role', capabilities:['read']}] }). @@ -141,7 +141,7 @@ describe('graph negative test', function(){ done(); }, function(error) { //console.log(error); - error.body.errorResponse.message.should.containEql('Invalid parameter: Role invalid-role does not exist'); + error.body.errorResponse.message.should.containEql('Role does not exist: role-name = invalid-role'); done(); }); }); diff --git a/test-complete/nodejs-graphs-overwrite-stream.js b/test-complete/nodejs-graphs-overwrite-stream.js index 2d681085..04a568f7 100644 --- a/test-complete/nodejs-graphs-overwrite-stream.js +++ b/test-complete/nodejs-graphs-overwrite-stream.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('stream overwrite graph test', function(){ var graphUri = 'marklogic.com/stream/overwrite/people'; - var graphPath1 = './node-client-api/test-complete/data/people3.ttl'; - var graphPath2 = './node-client-api/test-complete/data/people4.ttl'; - var sparqlPath = './node-client-api/test-complete/data/people.rq'; + var graphPath1 = __dirname + '/data/people3.ttl'; + var graphPath2 = __dirname + '/data/people4.ttl'; + var sparqlPath = __dirname + '/data/people.rq'; it('should write a new graph with stream', function(done){ this.timeout(10000); @@ -89,7 +89,7 @@ describe('stream overwrite graph test', function(){ it('should list the graph', function(done){ this.timeout(10000); - db.graphs.list(). + db.graphs.list(). result(function(collections){ //console.log(collections); collections.some(function(collection){ diff --git a/test-complete/nodejs-graphs-overwrite.js b/test-complete/nodejs-graphs-overwrite.js index f4f859ab..dd14718d 100644 --- a/test-complete/nodejs-graphs-overwrite.js +++ b/test-complete/nodejs-graphs-overwrite.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,9 +27,9 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('overwrite graph test', function(){ var graphUri = 'marklogic.com/overwrite/people'; - var graphPath1 = './node-client-api/test-complete/data/people3.ttl'; - var graphPath2 = './node-client-api/test-complete/data/people4.ttl'; - var sparqlPath = './node-client-api/test-complete/data/people.rq'; + var graphPath1 = __dirname + '/data/people3.ttl'; + var graphPath2 = __dirname + '/data/people4.ttl'; + var sparqlPath = __dirname + '/data/people.rq'; it('should write the graph', function(done){ this.timeout(10000); @@ -79,7 +79,7 @@ describe('overwrite graph test', function(){ it('should list the overwritten graph', function(done){ this.timeout(10000); - db.graphs.list(). + db.graphs.list(). result(function(collections){ //console.log(JSON.stringify(collections, null, 2)) collections.some(function(collection){ @@ -91,7 +91,7 @@ describe('overwrite graph test', function(){ /*it('should list the overwritten graph', function(done){ this.timeout(10000); - db.graphs.list('foo/bar'). + db.graphs.list('foo/bar'). result(function(response){ //console.log(JSON.stringify(response, null, 4)) done(); diff --git a/test-complete/nodejs-graphs-read-write-stream.js b/test-complete/nodejs-graphs-read-write-stream.js index 856cc40c..fa99c4c9 100644 --- a/test-complete/nodejs-graphs-read-write-stream.js +++ b/test-complete/nodejs-graphs-read-write-stream.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,8 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('stream graph test', function(){ var graphUri = 'marklogic.com/stream/people'; - var graphPath = './node-client-api/test-complete/data/people.ttl'; - var sparqlPath = './node-client-api/test-complete/data/people.rq'; + var graphPath = __dirname + '/data/people.ttl'; + var sparqlPath = __dirname + '/data/people.rq'; it('should write a new graph with stream', function(done){ this.timeout(10000); @@ -60,7 +60,7 @@ describe('stream graph test', function(){ it('should list the graph', function(done){ this.timeout(10000); - db.graphs.list(). + db.graphs.list(). result(function(collections){ //console.log(collections); collections.some(function(collection){ diff --git a/test-complete/nodejs-graphs-repair.js b/test-complete/nodejs-graphs-repair.js index 2dc0b1a1..0d457385 100644 --- a/test-complete/nodejs-graphs-repair.js +++ b/test-complete/nodejs-graphs-repair.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,8 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('repair graph test', function(){ var graphUri = 'marklogic.com/repair/people'; - var graphPath = './node-client-api/test-complete/data/people2.ttl'; - var sparqlPath = './node-client-api/test-complete/data/people.rq'; + var graphPath = __dirname + '/data/people2.ttl'; + var sparqlPath = __dirname + '/data/people.rq'; it('should write the graph with repair is true', function(done){ this.timeout(10000); @@ -66,7 +66,7 @@ describe('repair graph test', function(){ it('should list the repaired graph', function(done){ this.timeout(10000); - db.graphs.list(). + db.graphs.list(). result(function(collections){ collections.some(function(collection){ return collection === graphUri; diff --git a/test-complete/nodejs-graphs-transaction-remove.js b/test-complete/nodejs-graphs-transaction-remove.js index 1c6ca4f5..572971fd 100644 --- a/test-complete/nodejs-graphs-transaction-remove.js +++ b/test-complete/nodejs-graphs-transaction-remove.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,9 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('Graphs transaction remove test', function() { var graphUri = 'marklogic.com/tx/peoplerem'; - var graphPath = './node-client-api/test-complete/data/people3.ttl'; - var graphPath2 = './node-client-api/test-complete/data/people4.ttl'; - + var graphPath = __dirname + '/data/people3.ttl'; + var graphPath2 = __dirname + '/data/people4.ttl'; + var tid = 0; var tid2 = 0; @@ -52,8 +52,8 @@ describe('Graphs transaction remove test', function() { //console.log(JSON.stringify(response, null, 2)); response.graph.should.equal('marklogic.com/tx/peoplerem'); return db.graphs.read({ - uri: graphUri, - contentType: 'application/json', + uri: graphUri, + contentType: 'application/json', txid: tid, category: 'content' }).result(); @@ -63,8 +63,8 @@ describe('Graphs transaction remove test', function() { //console.log(JSON.stringify(response, null, 2)); response.should.have.property('http://people.org/person1'); return db.graphs.read({ - uri: graphUri, - contentType: 'application/json', + uri: graphUri, + contentType: 'application/json', txid: tid, category: 'metadata' }).result(); @@ -151,14 +151,14 @@ describe('Graphs transaction remove test', function() { //console.log('Write graph transaction 2'); //console.log(JSON.stringify(response, null, 2)); response.graph.should.equal('marklogic.com/tx/peoplerem'); - return db.graphs.read({uri: graphUri, contentType: 'application/json', txid: tid2}).result(); + return db.graphs.read({uri: graphUri, contentType: 'application/json', txid: tid2}).result(); }) .then(function(response) { //console.log('Read graph content transaction 2'); //console.log(JSON.stringify(response, null, 2)); response.should.have.property('http://people.org/person1'); response.should.have.property('http://people.org/person2'); - return db.graphs.read({uri: graphUri, contentType: 'application/json', txid: tid2, category: 'permissions'}).result(); + return db.graphs.read({uri: graphUri, contentType: 'application/json', txid: tid2, category: 'permissions'}).result(); }) .then(function(response) { //console.log('Read graph permissions transaction 2'); @@ -186,19 +186,19 @@ describe('Graphs transaction remove test', function() { //console.log('Remove graph transaction 2'); //console.log(JSON.stringify(response, null, 2)); response.graph.should.equal('marklogic.com/tx/peoplerem'); - return db.graphs.probe({uri: graphUri, txid: tid2}).result(); + return db.graphs.probe({uri: graphUri, txid: tid2}).result(); }) .then(function(response) { //console.log('Probe removed graph'); //console.log(JSON.stringify(response, null, 2)); response.exists.should.equal(false); - return db.transactions.commit(tid2).result(); + return db.transactions.commit(tid2).result(); }) .then(function(response) { //console.log('Commit transaction 2'); //console.log(JSON.stringify(response, null, 2)); response.finished.should.equal('commit'); - return db.graphs.probe(graphUri).result(); + return db.graphs.probe(graphUri).result(); }) .then(function(response) { //console.log('Probe removed committed graph'); diff --git a/test-complete/nodejs-graphs-transaction.js b/test-complete/nodejs-graphs-transaction.js index 8362e1ae..dfd6dc3f 100644 --- a/test-complete/nodejs-graphs-transaction.js +++ b/test-complete/nodejs-graphs-transaction.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,9 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('Graphs transaction combo test', function() { var graphUri = 'marklogic.com/tx/people'; - var graphPath = './node-client-api/test-complete/data/people3.ttl'; - var graphPath2 = './node-client-api/test-complete/data/people4.ttl'; - + var graphPath = __dirname + '/data/people3.ttl'; + var graphPath2 = __dirname + '/data/people4.ttl'; + var tid = 0; var tid2 = 0; @@ -52,8 +52,8 @@ describe('Graphs transaction combo test', function() { //console.log(JSON.stringify(response, null, 2)); response.graph.should.equal('marklogic.com/tx/people'); return db.graphs.read({ - uri: graphUri, - contentType: 'application/json', + uri: graphUri, + contentType: 'application/json', txid: tid, category: 'content' }).result(); @@ -63,8 +63,8 @@ describe('Graphs transaction combo test', function() { //console.log(JSON.stringify(response, null, 2)); response.should.have.property('http://people.org/person1'); return db.graphs.read({ - uri: graphUri, - contentType: 'application/json', + uri: graphUri, + contentType: 'application/json', txid: tid, category: 'metadata' }).result(); @@ -151,14 +151,14 @@ describe('Graphs transaction combo test', function() { //console.log('Write graph transaction 2'); //console.log(JSON.stringify(response, null, 2)); response.graph.should.equal('marklogic.com/tx/people'); - return db.graphs.read({uri: graphUri, contentType: 'application/json', txid: tid2}).result(); + return db.graphs.read({uri: graphUri, contentType: 'application/json', txid: tid2}).result(); }) .then(function(response) { //console.log('Read graph content transaction 2'); //console.log(JSON.stringify(response, null, 2)); response.should.have.property('http://people.org/person1'); response.should.have.property('http://people.org/person2'); - return db.graphs.read({uri: graphUri, contentType: 'application/json', txid: tid2, category: 'permissions'}).result(); + return db.graphs.read({uri: graphUri, contentType: 'application/json', txid: tid2, category: 'permissions'}).result(); }) .then(function(response) { //console.log('Read graph permissions transaction 2'); @@ -186,21 +186,21 @@ describe('Graphs transaction combo test', function() { //console.log('Commit graph transaction 2'); //console.log(JSON.stringify(response, null, 2)); response.finished.should.equal('commit'); - return db.graphs.read({uri: graphUri, contentType: 'application/json'}).result(); + return db.graphs.read({uri: graphUri, contentType: 'application/json'}).result(); }) .then(function(response) { //console.log('Read commited graph'); //console.log(JSON.stringify(response, null, 2)); response.should.have.property('http://people.org/person1'); response.should.have.property('http://people.org/person2'); - return db.graphs.probe(graphUri).result(); + return db.graphs.probe(graphUri).result(); }) .then(function(response) { //console.log('Probe commited graph'); //console.log(JSON.stringify(response, null, 2)); response.exists.should.equal(true); response.graph.should.equal('marklogic.com/tx/people'); - return db.graphs.remove(graphUri).result(); + return db.graphs.remove(graphUri).result(); }) .then(function(response) { //response.removed.should.equal(true); diff --git a/test-complete/nodejs-issue-104.js b/test-complete/nodejs-issue-104.js index 54037668..72a72829 100644 --- a/test-complete/nodejs-issue-104.js +++ b/test-complete/nodejs-issue-104.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ var q = marklogic.queryBuilder; var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); -describe('when executing write to default graph', function() { +describe('Issue 104', function() { before('add triples to default graph', function(done) { done(); @@ -46,21 +46,21 @@ describe('when executing write to default graph', function() { 'ppl:person3 a ppl:Person ;', ' foaf:name "Person 3" .', ]; - + db.graphs.write({contentType: 'text/turtle', data: triples.join('\n')}).result( - function(response) { + function(response) { //console.log(response); // response.length.should.equal(docCount); response.should.have.properties('defaultGraph', 'graph'); response.defaultGraph.should.equal(true); done(); - }, + }, function(error) { console.log(JSON.stringify(error, null, 2)); done(error); - }, + }, done); }); @@ -69,6 +69,6 @@ describe('when executing write to default graph', function() { result(function(response) { done(); }, done); - }); - + }); + }); diff --git a/test-complete/nodejs-issue-108-109.js b/test-complete/nodejs-issue-108-109.js index 00ebaafa..a1199032 100644 --- a/test-complete/nodejs-issue-108-109.js +++ b/test-complete/nodejs-issue-108-109.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,9 @@ var q = marklogic.queryBuilder; var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); var restAdminDB = marklogic.createDatabaseClient(testconfig.restAdminConnection); var serviceName = 'issue-108-109'; -var servicePath = './node-client-api/test-complete/data/issue-108-109.sjs'; +var servicePath = __dirname + '/data/issue-108-109.sjs'; -describe('when executing resource services', function() { +describe('Issue 108 - 109', function() { before('should write the extension service', function(done) { restAdminDB.config.resources.write(serviceName, 'javascript', fs.createReadStream(servicePath)). @@ -39,7 +39,7 @@ describe('when executing resource services', function() { it('should get document', function(done){ db.resources.get({ - name: serviceName, + name: serviceName, params: { a: 1, b: 2, c: 'three'} }).result(function(response) { response.length.should.equal(3); @@ -59,7 +59,7 @@ describe('when executing resource services', function() { else if (resp.content.name === 'a') { resp.content.value.should.equal('three'); } - } + } done(); }, function(error) { @@ -71,17 +71,17 @@ describe('when executing resource services', function() { it('should put document', function(done){ db.resources.put({ - name: serviceName, + name: serviceName, params: { basename: ['one', 'two']}, documents: [ - { + { contentType: 'application/json', - content: {key1:'value1'} + content: {key1:'value1'} }, - { + { contentType: 'application/json', - content: {key2:'value2'} + content: {key2:'value2'} }, ] }).result(function(response) { @@ -102,5 +102,5 @@ describe('when executing resource services', function() { done(); }, done); }); - + }); diff --git a/test-complete/nodejs-issue-110.js b/test-complete/nodejs-issue-110.js index e2193411..7aba5a1d 100644 --- a/test-complete/nodejs-issue-110.js +++ b/test-complete/nodejs-issue-110.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ var db = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); -describe('Document extract test', function(){ +describe('Issue 110', function(){ before(function(done){ this.timeout(10000); dbWriter.documents.write({ @@ -40,7 +40,7 @@ describe('Document extract test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', contentType: 'application/json', content: { @@ -53,7 +53,7 @@ describe('Document extract test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', contentType: 'application/json', content: { @@ -66,7 +66,7 @@ describe('Document extract test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', contentType: 'application/json', content: { @@ -79,7 +79,7 @@ describe('Document extract test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', contentType: 'application/json', content: { @@ -218,7 +218,7 @@ describe('Document extract test', function(){ result(function(response) { done(); }, done); - }); + }); /*it('should do extract with back level up', function(done){ db.documents.query( q.where( diff --git a/test-complete/nodejs-issue-115.js b/test-complete/nodejs-issue-115.js index cdb775c0..fb8a24f5 100644 --- a/test-complete/nodejs-issue-115.js +++ b/test-complete/nodejs-issue-115.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ var db = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbWriter = marklogic.createDatabaseClient(testconfig.restWriterConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); -describe('document query options test', function(){ +describe('Issue 115', function(){ before(function(done){ this.timeout(10000); // NOTE: must create a string range index on rangeKey1 and rangeKey2 @@ -42,7 +42,7 @@ describe('document query options test', function(){ }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/query/matchDir/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -56,7 +56,7 @@ describe('document query options test', function(){ }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/query/matchDir/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -70,7 +70,7 @@ describe('document query options test', function(){ }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/query/matchDir/doc4.json', collections: [], contentType: 'application/json', @@ -84,7 +84,7 @@ describe('document query options test', function(){ }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/query/matchList/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -105,7 +105,7 @@ describe('document query options test', function(){ it('should do document query with options and category as content Github issue#151', function(done){ db.documents.query( q.where( - q.word('title', 'bush') + q.word('title', 'bush') ). withOptions({queryPlan: true, metrics: false, @@ -116,15 +116,15 @@ describe('document query options test', function(){ response.length.should.equal(3); response[0].plan.should.be.ok; response[0].report.should.be.ok; - response[0].report.should.containEql('cts:search(fn:collection(), cts:json-property-word-query'); - + response[0].report.should.containEql('cts:search(fn:collection(), cts:json-property-word-query'); + done(); }, done); }); it('should do document query with options and category as none Github issue#151', function(done){ db.documents.query( q.where( - q.word('title', 'bush') + q.word('title', 'bush') ). withOptions({queryPlan: true, metrics: false, @@ -135,12 +135,12 @@ describe('document query options test', function(){ response.length.should.equal(1); response[0].plan.should.be.ok; response[0].report.should.be.ok; - response[0].report.should.containEql('cts:search(fn:collection(), cts:json-property-word-query'); - + response[0].report.should.containEql('cts:search(fn:collection(), cts:json-property-word-query'); + done(); }, done); }); - + it('should remove all documents', function(done){ dbAdmin.documents.removeAll({all:true}). result(function(response) { diff --git a/test-complete/nodejs-issue-257.js b/test-complete/nodejs-issue-257.js index af12f2ce..fa4aaa07 100644 --- a/test-complete/nodejs-issue-257.js +++ b/test-complete/nodejs-issue-257.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,9 @@ var q = marklogic.queryBuilder; var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); var restAdminDB = marklogic.createDatabaseClient(testconfig.restAdminConnection); var serviceName = 'issue-257'; -var servicePath = './node-client-api/test-complete/data/issue-257.sjs'; +var servicePath = __dirname + '/data/issue-257.sjs'; -describe('issue 257', function() { +describe('Issue 257', function() { before('should write the extension service', function(done) { restAdminDB.config.resources.write(serviceName, 'javascript', fs.createReadStream(servicePath)). @@ -39,7 +39,7 @@ describe('issue 257', function() { it('should post without document property', function(done){ db.resources.post({ - name: serviceName + name: serviceName }).result(function(response) { //console.log(JSON.stringify(response, null, 2)); response.should.equal('POST worked'); @@ -53,5 +53,5 @@ describe('issue 257', function() { done(); }, done); }); - + }); diff --git a/test-complete/nodejs-issue-99.js b/test-complete/nodejs-issue-99.js index 45ec2f11..e47cbd1b 100644 --- a/test-complete/nodejs-issue-99.js +++ b/test-complete/nodejs-issue-99.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ var q = marklogic.queryBuilder; var dbEval = marklogic.createDatabaseClient(testconfig.restEvaluatorConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); -describe('Issue 99 test', function(){ +describe('Issue 99', function(){ it('should do javascript eval on json', function(done){ debugger; @@ -51,7 +51,7 @@ describe('Issue 99 test', function(){ function(err) { console.log(err); done(err); - }, + }, done); }); @@ -63,7 +63,7 @@ describe('Issue 99 test', function(){ done(); }, done); }); - + }); diff --git a/test-complete/nodejs-javascript-eval-negative.js b/test-complete/nodejs-javascript-eval-negative.js index 06efe456..ecb639bc 100644 --- a/test-complete/nodejs-javascript-eval-negative.js +++ b/test-complete/nodejs-javascript-eval-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ describe('Javascript eval negaive test', function(){ dbEval.eval('var num1;' + 'var num2;' + 'num1 + num2;', - {num1:2, number2:3} + {num1:2, number2:3} ). result(function(values) { //values.should.equal('SHOULD HAVE FAILED'); @@ -39,7 +39,7 @@ describe('Javascript eval negaive test', function(){ strVal.should.equal('[{"format":"text","datatype":"double","value":"NaN"}]'); done(); }, function(error) { - //console.log(error); + //console.log(error); done(); }); }); @@ -48,14 +48,14 @@ describe('Javascript eval negaive test', function(){ dbEval.eval('var num1;' + 'var num2;' + 'num1 + num2;', - {num1:2, num2:3, num3:10} + {num1:2, num2:3, num3:10} ). result(function(values) { var strVal = JSON.stringify(values); strVal.should.equal('[{"format":"text","datatype":"integer","value":5}]'); done(); }, function(error) { - //console.log(error); + //console.log(error); done(); }); }); @@ -64,14 +64,14 @@ describe('Javascript eval negaive test', function(){ dbEval.eval('var num1;' + 'var num2;' + 'num1 + num3;', - {num1:2, num2:3} + {num1:2, num2:3} ). result(function(values) { values.should.equal('SHOULD HAVE FAILED'); done(); }, function(error) { error.statusCode.should.equal(500); - //console.log(error); + //console.log(error); done(); }); }); diff --git a/test-complete/nodejs-javascript-eval-params.js b/test-complete/nodejs-javascript-eval-params.js index 26747d5c..62f38d42 100644 --- a/test-complete/nodejs-javascript-eval-params.js +++ b/test-complete/nodejs-javascript-eval-params.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ describe('Javascript eval params test', function(){ dbEval.eval('var num1;' + 'var num2;' + 'num1 + num2;', - {num1:2, num2:3} + {num1:2, num2:3} ).result(function(values) { //console.log(values); values[0].value.should.equal(5); @@ -43,7 +43,7 @@ describe('Javascript eval params test', function(){ dbEval.eval('var num1;' + 'var num2;' + 'num1 + num2;', - {num1:2, num2:3} + {num1:2, num2:3} ). stream(). on('data', function(data) { diff --git a/test-complete/nodejs-javascript-eval.js b/test-complete/nodejs-javascript-eval.js index dc9f592d..7037d5a5 100644 --- a/test-complete/nodejs-javascript-eval.js +++ b/test-complete/nodejs-javascript-eval.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ describe('Server eval test', function(){ it('should do javascript eval to call on array', function(done){ var src = 'var mycars = ["volvo", "nissan", "honda", "volvo", "HONDA"];' + - 'fn.distinctValues(xdmp.arrayValues(mycars));' + 'fn.distinctValues(xdmp.arrayValues(mycars));' dbEval.eval(src). result(function(values) { //console.log(values); diff --git a/test-complete/nodejs-javascript-invoke-params-negative.js b/test-complete/nodejs-javascript-invoke-params-negative.js index 7d679ee4..cd35d765 100644 --- a/test-complete/nodejs-javascript-invoke-params-negative.js +++ b/test-complete/nodejs-javascript-invoke-params-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ var dbEval = marklogic.createDatabaseClient(testconfig.restEvaluatorConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Javascript invoke params negative test', function(){ - - var fsPath = './node-client-api/test-complete/data/sourceParamsNegative.js'; + + var fsPath = __dirname + '/data/sourceParamsNegative.js'; var invokePath = '/ext/invokeTest/sourceParamsNegative.sjs'; before(function(done) { @@ -37,7 +37,7 @@ describe('Javascript invoke params negative test', function(){ }). result(function(response){done();}, done); }); - + after(function(done) { dbAdmin.config.extlibs.remove(invokePath). result(function(response){done();}, done); diff --git a/test-complete/nodejs-javascript-invoke-params.js b/test-complete/nodejs-javascript-invoke-params.js index c9b149cb..dfc299bc 100644 --- a/test-complete/nodejs-javascript-invoke-params.js +++ b/test-complete/nodejs-javascript-invoke-params.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ var dbEval = marklogic.createDatabaseClient(testconfig.restEvaluatorConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Javascript invoke test', function(){ - - var fsPath = './node-client-api/test-complete/data/sourceParams.js'; + + var fsPath = __dirname + '/data/sourceParams.js'; var invokePath = '/ext/invokeTest/sourceParams.sjs'; before(function(done) { @@ -37,7 +37,7 @@ describe('Javascript invoke test', function(){ }). result(function(response){done();}, done); }); - + after(function(done) { dbAdmin.config.extlibs.remove(invokePath). result(function(response){done();}, done); diff --git a/test-complete/nodejs-javascript-invoke-simple-negative.js b/test-complete/nodejs-javascript-invoke-simple-negative.js index b689854b..109c4ba7 100644 --- a/test-complete/nodejs-javascript-invoke-simple-negative.js +++ b/test-complete/nodejs-javascript-invoke-simple-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ var dbEval = marklogic.createDatabaseClient(testconfig.restEvaluatorConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Javascript invoke simple negative test', function(){ - - var fsPath = './node-client-api/test-complete/data/sourceSimpleNegative.js'; + + var fsPath = __dirname + '/data/sourceSimpleNegative.js'; var invokePath = '/ext/invokeTest/sourceSimpleNegative.sjs'; before(function(done) { @@ -37,7 +37,7 @@ describe('Javascript invoke simple negative test', function(){ }). result(function(response){done();}, done); }); - + after(function(done) { dbAdmin.config.extlibs.remove(invokePath). result(function(response){done();}, done); diff --git a/test-complete/nodejs-javascript-invoke-simple.js b/test-complete/nodejs-javascript-invoke-simple.js index abea2eb8..0653f2af 100644 --- a/test-complete/nodejs-javascript-invoke-simple.js +++ b/test-complete/nodejs-javascript-invoke-simple.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ var dbEval = marklogic.createDatabaseClient(testconfig.restEvaluatorConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Javascript invoke test', function(){ - - var fsPath = './node-client-api/test-complete/data/sourceSimple.js'; + + var fsPath = __dirname + '/data/sourceSimple.js'; var invokePath = '/ext/invokeTest/sourceSimple.sjs'; before(function(done) { @@ -37,7 +37,7 @@ describe('Javascript invoke test', function(){ }). result(function(response){done();}, done); }); - + after(function(done) { dbAdmin.config.extlibs.remove(invokePath). result(function(response){done();}, done); diff --git a/test-complete/nodejs-logger-bunyan.js b/test-complete/nodejs-logger-bunyan.js index 93953242..949366ee 100644 --- a/test-complete/nodejs-logger-bunyan.js +++ b/test-complete/nodejs-logger-bunyan.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ describe('Bunyan logger test', function(){ dbAdmin.config.serverprops.read().result(function(response) { //var log = JSON.stringify(response); //console.log(log); - //log.should.containEql('testlog'); + //log.should.containEql('testlog'); done(); }, done); }); diff --git a/test-complete/nodejs-logger-winston.js b/test-complete/nodejs-logger-winston.js index 592d17b6..c1897694 100644 --- a/test-complete/nodejs-logger-winston.js +++ b/test-complete/nodejs-logger-winston.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ describe('Winston logger test', function(){ dbAdmin.config.serverprops.read().result(function(response) { //var log = JSON.stringify(response); //console.log(log); - //log.should.containEql('testlog'); + //log.should.containEql('testlog'); done(); }, done); }); diff --git a/test-complete/nodejs-optic-cts-queries.js b/test-complete/nodejs-optic-cts-queries.js new file mode 100644 index 00000000..6f24b45b --- /dev/null +++ b/test-complete/nodejs-optic-cts-queries.js @@ -0,0 +1,404 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const expect = require('chai').expect; +const fs = require('fs'); + +const marklogic = require('../'); + +const connectdef = require('../config-optic/connectdef.js'); + +const db = marklogic.createDatabaseClient(connectdef.plan); +const op = marklogic.planBuilder; +const q = marklogic.queryBuilder; + +describe('Nodejs Optic cts queries test', function(){ + + it('TEST 1 - jsonPropertyWordQuery on fromLexicons', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity', op.fragmentIdCol('fragId1') + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam', op.fragmentIdCol('fragId2') + ); + const output = + plan1 + .where(op.cts.jsonPropertyWordQuery('city', 'new')) + .joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .orderBy(op.asc(op.col('date'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(2); + expect(output.rows[0]['myCity.city'].value).to.equal('new jersey'); + expect(output.rows[1]['myCity.city'].value).to.equal('new york'); + done(); + }, done); + }); + + it('TEST 2 - jsonPropertyValueQuery on fromLexicons', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity', op.fragmentIdCol('fragId1') + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam', op.fragmentIdCol('fragId2') + ); + const output = + plan1.where(op.cts.jsonPropertyWordQuery('city', 'new')) + .joinInner(plan2.where(op.cts.jsonPropertyValueQuery('cityTeam', 'yankee'))) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .orderBy(op.asc(op.col('date'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myCity.city'].value).to.equal('new york'); + done(); + }, done); + }); + + it('TEST 3 - jsonPropertyGeospatialQuery with box on fromLexicons', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity', op.fragmentIdCol('fragId1') + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam', op.fragmentIdCol('fragId2') + ); + const output = + plan1 + .where(op.cts.jsonPropertyGeospatialQuery('latLonPoint', op.cts.box(49.16, -13.41, 60.85, 1.76))) + .joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .orderBy(op.asc(op.col('date'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myCity.city']).to.equal('london'); + done(); + }, done); + }); + + it('TEST 4 - collectionQuery and elementValueQuery on fromLexicons', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity', op.fragmentIdCol('fragId1') + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam', op.fragmentIdCol('fragId2') + ); + const output = + plan1 + .where(op.cts.orQuery([op.cts.collectionQuery('/other/coll1'), op.cts.elementValueQuery(op.xs.QName('metro'), 'true')])) + .joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .orderBy(op.asc(op.col('date'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0]['myCity.city']).to.equal('beijing'); + expect(output.rows[1]['myCity.city']).to.equal('cape town'); + expect(output.rows[2]['myCity.city']).to.equal('london'); + done(); + }, done); + }); + + it('TEST 5 - setup for tripleRangeQuery on fromTriples', function(done){ + var src = + `declareUpdate(); + var sem = require("/MarkLogic/semantics.xqy"); + + var a = sem.rdfInsert( + sem.triple(sem.iri("http://example.com/ns/directory#m"), + sem.iri("http://example.com/ns/person#firstName"), + "Mark"), + "override-graph=opticRdfTest"); + var b = sem.rdfInsert( + sem.triple(sem.iri("http://example.com/Mark"), + sem.iri("http://example.com/ns/person#age"), + 37), + "override-graph=opticRdfTest"); + var c = sem.rdfInsert( + sem.triple(sem.iri("http://example.com/ns/directory#m"), + sem.iri("http://example.com/ns/person#firstName"), + "John"), + "override-graph=opticRdfTest"); + var d = sem.rdfInsert( + sem.triple(sem.iri("http://example.com/John"), + sem.iri("http://example.com/ns/person#age"), + 30), + "override-graph=opticRdfTest"); + var e = sem.rdfInsert( + sem.triple(sem.iri("http://example.com/ns/directory#m"), + sem.iri("http://example.com/ns/person#firstName"), + "Mark"), + "override-graph=opticRdfTest"); + var f = sem.rdfInsert( + sem.triple(sem.iri("http://example.com/Mark"), + sem.iri("http://example.com/ns/person#age"), + 65), + "override-graph=opticRdfTest"); + + var res = new Array(); + res.push(a); + res.push(b); + res.push(c); + res.push(d); + res.push(e); + res.push(f); + res;` + + db.eval(src) + .result(function(output) { + //console.log(JSON.stringify(output, null, 2)); + done(); + }, done); + }); + + it('TEST 6 - tripleRangeQuery on fromTriples', function(done){ + const pp = op.prefixer('http://example.com/ns/person#'); + const nameCol = op.col('name'); + const ageCol = op.col('age'); + + const name_plan = + op.fromTriples([ + op.pattern(nameCol, pp('age'), ageCol) + ], null, null); + + const output = + name_plan + .where(op.cts.tripleRangeQuery(op.sem.iri("http://example.com/Mark"), op.sem.iri("http://example.com/ns/person#age"), 50, "<")) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0].name).to.equal('http://example.com/Mark'); + expect(output.rows[0].age).to.equal(37); + done(); + }, done); + }); + + it('TEST 7 - cleanup for tripleRangeQuery on fromTriples', function(done){ + var src = + `declareUpdate(); + var sem = require("/MarkLogic/semantics.xqy"); + sem.graphDelete(sem.iri("opticRdfTest"))` + db.eval(src) + .result(function(output) { + //console.log(JSON.stringify(output, null, 2)); + done(); + }, done); + }); + + it('TEST 8 - jsonPropertyWordQuery on fromViews', function(done){ + const plan1 = + op.fromView('opticFunctionalTest4', 'detail4', null, null) + + const plan2 = + op.fromView('opticFunctionalTest4', 'master4') + + const output = + plan1 + .where(op.cts.jsonPropertyWordQuery('name', 'Detail 100')) + .joinInner(plan2, op.on(op.schemaCol('opticFunctionalTest4', 'detail4', 'masterId'), op.schemaCol('opticFunctionalTest4', 'master4', 'id'))) + .orderBy(op.schemaCol('opticFunctionalTest4', 'detail4', 'id')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0]['opticFunctionalTest4.detail4.id']).to.equal(100); + expect(output.rows[0]['opticFunctionalTest4.master4.name']).to.equal('Master 100'); + expect(output.rows[2]['opticFunctionalTest4.detail4.id']).to.equal(300); + expect(output.rows[2]['opticFunctionalTest4.master4.name']).to.equal('Master 200'); + done(); + }, done); + }); + + it('TEST 9 - wordQuery and jsonPropertyValueQuery on fromViews', function(done){ + const plan1 = + op.fromView('opticFunctionalTest4', 'detail4', null, null); + + const plan2 = + op.fromView('opticFunctionalTest4', 'master4', null, null); + const output = + plan1 + .where(op.cts.jsonPropertyValueQuery('id', '600')) + .joinInner( + plan2.where(op.cts.wordQuery('Master 100')), + op.on(op.schemaCol('opticFunctionalTest4', 'detail4', 'masterId'), op.schemaCol('opticFunctionalTest4', 'master4', 'id')) + ) + .orderBy(op.schemaCol('opticFunctionalTest4', 'detail4', 'id')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0]['opticFunctionalTest4.detail4.id']).to.equal(400); + expect(output.rows[0]['opticFunctionalTest4.master4.name']).to.equal('Master 200'); + expect(output.rows[2]['opticFunctionalTest4.detail4.id']).to.equal(600); + expect(output.rows[2]['opticFunctionalTest4.master4.name']).to.equal('Master 100'); + done(); + }, done); + }); + + it('TEST 11 - jsonPropertyRangeQuery on fromViews', function(done){ + const plan1 = + op.fromView('opticFunctionalTest4', 'detail4', null, null); + + const plan2 = + op.fromView('opticFunctionalTest4', 'master4'); + + const output = + plan1 + .where(op.cts.jsonPropertyRangeQuery('id', '>', 300)) + .joinInner(plan2, op.on(op.schemaCol('opticFunctionalTest4', 'detail4', 'masterId'), op.schemaCol('opticFunctionalTest4', 'master4', 'id'))) + .orderBy(op.schemaCol('opticFunctionalTest4', 'detail4', 'id')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0]['opticFunctionalTest4.detail4.id']).to.equal(400); + expect(output.rows[0]['opticFunctionalTest4.master4.name']).to.equal('Master 200'); + expect(output.rows[2]['opticFunctionalTest4.detail4.id']).to.equal(600); + expect(output.rows[2]['opticFunctionalTest4.master4.name']).to.equal('Master 100'); + done(); + }, done); + }); + + it('TEST 12 - nearQuery on fromLexicons', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity', op.fragmentIdCol('fragId1') + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam', op.fragmentIdCol('fragId2') + ); + const output = + plan1 + .where(op.cts.nearQuery([op.cts.wordQuery('near'), op.cts.wordQuery('Thames')], 3)) + .joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .orderBy(op.asc(op.col('date'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myCity.city']).to.equal('london'); + done(); + }, done); + }); + + it('TEST 13 - cts queries with options on fromLexicons', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity', op.fragmentIdCol('fragId1') + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam', op.fragmentIdCol('fragId2') + ); + const output = + plan1 + .where(op.cts.jsonPropertyWordQuery('city', '*k', ['wildcarded', 'case-sensitive'])) + .joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .orderBy(op.asc(op.col('date'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myCity.city']).to.equal('new york'); + done(); + }, done); + }); + +}); diff --git a/test-complete/nodejs-optic-from-lexicons.js b/test-complete/nodejs-optic-from-lexicons.js new file mode 100644 index 00000000..8996e847 --- /dev/null +++ b/test-complete/nodejs-optic-from-lexicons.js @@ -0,0 +1,689 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const expect = require('chai').expect; +const fs = require('fs'); + +const marklogic = require('../'); + +const connectdef = require('../config-optic/connectdef.js'); + +const db = marklogic.createDatabaseClient(connectdef.plan); +const op = marklogic.planBuilder; + +describe('Nodejs Optic from lexicons test', function(){ + + it('TEST 1 - access with where orderby select - columnTypes header and data types', function(done){ + const popCol = op.col('popularity'); + const dateCol = op.col('date'); + const plan1 = + op.fromLexicons( + { + uri: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const output = + plan1 + .where(op.gt(popCol, 2)) + .orderBy(op.asc('date')) + .select(['city', 'popularity', 'date', 'distance', 'point']) + + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[2].name).to.equal('myCity.date'); + expect(output.columns[2].type).to.equal('xs:date'); + expect(output.columns[4].name).to.equal('myCity.point'); + expect(output.columns[4].type).to.equal('http://marklogic.com/cts#point'); + expect(output.rows.length).to.equal(4); + expect(output.rows[0]['myCity.popularity']).to.equal(5); + expect(output.rows[0]['myCity.date']).to.equal('1981-11-09'); + expect(output.rows[3]['myCity.popularity']).to.equal(5); + expect(output.rows[3]['myCity.date']).to.equal('2007-01-01'); + done(); + }, done); + }); + + it('TEST 2 - join inner doc', function(done){ + const plan1 = + op.fromLexicons( + { + uri: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const output = + plan1 + .joinDoc(op.col('doc'), op.col('uri')) + .orderBy(op.asc('uri')) + .select(['uri', 'city', 'popularity', 'date', 'distance', 'point', op.as('nodes', op.fn.number(op.xpath('doc', '//latLonPair/lat')))]) + .where(op.isDefined(op.col('nodes'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[6].name).to.equal('nodes'); + expect(output.columns[6].type).to.equal('xs:double'); + expect(output.rows.length).to.equal(5); + expect(output.rows[0]['myCity.uri']).to.equal('/optic/lexicon/test/doc1.json'); + expect(output.rows[0]['myCity.popularity']).to.equal(5); + expect(output.rows[0].nodes).to.equal(51.5); + expect(output.rows[1]['myCity.uri']).to.equal('/optic/lexicon/test/doc2.json'); + expect(output.rows[1]['myCity.popularity']).to.equal(5); + expect(output.rows[1].nodes).to.equal(40.71); + expect(output.rows[4]['myCity.uri']).to.equal('/optic/lexicon/test/doc5.xml'); + expect(output.rows[4]['myCity.popularity']).to.equal(3); + expect(output.rows[4].nodes).to.equal(-33.91); + done(); + }, done); + }); + + it('TEST 3 - join inner with keymatch, viewCol, and date sort - structure array, columnTypes rows', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .orderBy(op.asc(op.col('date'))) + db.rows.query(output, { format: 'json', structure: 'array', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.length).to.equal(6); + expect(output[1][1].value).to.equal('new jersey'); + expect(output[1][3].value).to.equal('1971-12-23'); + expect(output[1][5].type).to.equal('http://marklogic.com/cts#point'); + expect(output[1][5].value).to.equal('40.720001,-74.07'); + expect(output[1][7].value).to.equal('new jersey'); + expect(output[1][8].value).to.equal('nets'); + expect(output[5][1].value).to.equal('london'); + expect(output[5][3].value).to.equal('2007-01-01'); + done(); + }, done); + }); + + it('TEST 4 - using element reference and null viewname', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.elementReference(op.fn.QName(null, 'city')), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.elementReference(op.fn.QName(null, 'date')), + distance: op.cts.elementReference(op.fn.QName(null, 'distance')), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2, op.on(op.viewCol(null, 'city'), op.viewCol(null, 'cityName'))) + .joinDoc(op.col('doc'), op.col('uri1')) + .select(['uri1', 'city', 'popularity', 'date', 'distance', 'point', op.as('nodes', op.xpath('doc', '//city')), 'uri2', 'cityName', 'cityTeam']) + .where(op.isDefined(op.col('nodes'))) + .orderBy(op.desc('uri2')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(5); + expect(output.rows[0]['myCity.city']).to.equal('cape town'); + expect(output.rows[0]['myCity.uri1']).to.equal('/optic/lexicon/test/doc5.xml'); + expect(output.rows[0]['myTeam.uri2']).to.equal('/optic/lexicon/test/city5.json'); + expect(output.rows[0].nodes).to.equal('cape town'); + expect(output.rows[4]['myCity.city']).to.equal('london'); + expect(output.rows[4]['myCity.uri1']).to.equal('/optic/lexicon/test/doc1.json'); + expect(output.rows[4]['myTeam.uri2']).to.equal('/optic/lexicon/test/city1.json'); + expect(output.rows[4].nodes).to.equal('london'); + done(); + }, done); + }); + + it('TEST 5 - access without uri reference - with format xml', function(done){ + const popCol = op.col('popularity'); + const dateCol = op.col('date'); + const plan1 = + op.fromLexicons( + { + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const output = + plan1 + .where(op.gt(popCol, 2)) + .orderBy([op.asc('popularity'), op.asc('city')]) + .select(['city', 'popularity', 'date', 'distance', 'point']) + db.rows.query(output, { format: 'xml', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + const outputStr = output.toString().trim().replace(/[\n\r]/g, ''); + //console.log(outputStr); + expect(outputStr).to.equal('cape town31999-04-22377.9-33.91,18.42beijing51981-11-09134.539.900002,116.4london52007-01-0150.451.5,-0.12new york52006-06-2323.340.709999,-74.009995'); + done(); + }, done); + }); + + it('TEST 6 - join inner with plan accessor column identifier', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.elementReference(op.fn.QName('', 'city')), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.elementReference(op.fn.QName('', 'date')), + distance: op.cts.elementReference(op.fn.QName('', 'distance')), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const cityCol = plan1.col('city'); + const cityNameCol = plan2.col('cityName'); + const output = + plan1.joinInner(plan2, op.on(cityCol, cityNameCol)) + .joinDoc(op.col('doc'), op.col('uri1')) + .select(['uri1', 'city', 'popularity', 'date', 'distance', 'point', op.as('nodes', op.xpath('doc', '//city')), 'uri2', 'cityName', 'cityTeam']) + .where(op.isDefined(op.col('nodes'))) + .orderBy(op.desc('uri2')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(5); + expect(output.rows[0]['myCity.city']).to.equal('cape town'); + expect(output.rows[0]['myCity.uri1']).to.equal('/optic/lexicon/test/doc5.xml'); + expect(output.rows[0]['myTeam.uri2']).to.equal('/optic/lexicon/test/city5.json'); + expect(output.rows[0].nodes).to.equal('cape town'); + expect(output.rows[4]['myCity.city']).to.equal('london'); + expect(output.rows[4]['myCity.uri1']).to.equal('/optic/lexicon/test/doc1.json'); + expect(output.rows[4]['myTeam.uri2']).to.equal('/optic/lexicon/test/city1.json'); + expect(output.rows[4].nodes).to.equal('london'); + done(); + }, done); + }); + + it('TEST 7 - use result on prepared plan and multiple order by', function(done){ + const popCol = op.col('popularity'); + const dateCol = op.col('date'); + const plan1 = + op.fromLexicons( + { + uri: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const preparedPlan = + plan1 + .where(op.gt(popCol, 2)) + .orderBy([op.asc('popularity'), op.desc('date')]) + .select(['city', 'popularity', 'date', 'distance', 'point']) + .prepare(0); + //console.log(JSON.stringify(preparedPlan)); + db.rows.query(preparedPlan, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(4); + /*expect(output[0].value['myCity.city']).to.equal('cape town'); + expect(output[0].value['myCity.popularity']).to.equal(3); + expect(output[1].value['myCity.popularity']).to.equal(5); + expect(output[1].value['myCity.date']).to.equal('2007-01-01'); + expect(output[3].value['myCity.popularity']).to.equal(5); + expect(output[3].value['myCity.date']).to.equal('1981-11-09');*/ + done(); + }, done); + }); + + it('TEST 8 - join inner doc without xpath - with format csv', function(done){ + const plan1 = + op.fromLexicons( + { + uri: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const output = + plan1 + .joinDoc(op.col('doc'), op.col('uri')) + .orderBy(op.asc('uri')) + db.rows.query(output, { format: 'csv', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + expect(output).to.contain('myCity.uri,myCity.city,myCity.popularity,myCity.date,myCity.distance,myCity.point,doc'); + expect(output).to.contain('/optic/lexicon/test/doc1.json,london,5,2007-01-01,50.4,"51.5,-0.12","{""city"":""london"", ""distance"":50.4, ""date"":""2007-01-01"", ""metro"":true, ""description"":""Two recent discoveries indicate probable very early settlements near the Thames"", ""popularity"":5, ""location"":{""latLonPoint"":""51.50, -0.12"", ""latLonPair"":{""lat"":51.5, ""long"":-0.12}, ""latLonParent"":{""latLonChild"":""51.50, -0.12""}}}"'); + done(); + }, done); + }); + + it('TEST 9 - export plan and execute the plan', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity', op.fragmentIdCol('fragId1') + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam', op.fragmentIdCol('fragId2') + ); + const exportedPlan = + plan1.joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .orderBy(op.asc(op.col('date'))) + .export(); + //console.log(JSON.stringify(exportedPlan).trim().replace(/[\n\r]/g, '')); + const exportedPlanStr = JSON.stringify(exportedPlan).trim().replace(/[\n\r]/g, ''); + expect(exportedPlanStr).to.equal('{"$optic":{"ns":"op","fn":"operators","args":[{"ns":"op","fn":"from-lexicons","args":[{"uri1":{"ns":"cts","fn":"uri-reference","args":[]},"city":{"ns":"cts","fn":"json-property-reference","args":["city"]},"popularity":{"ns":"cts","fn":"json-property-reference","args":["popularity"]},"date":{"ns":"cts","fn":"json-property-reference","args":["date"]},"distance":{"ns":"cts","fn":"json-property-reference","args":["distance"]},"point":{"ns":"cts","fn":"json-property-reference","args":["latLonPoint"]}},"myCity",{"ns":"op","fn":"fragment-id-col","args":["fragId1"]}]},{"ns":"op","fn":"join-inner","args":[{"ns":"op","fn":"operators","args":[{"ns":"op","fn":"from-lexicons","args":[{"uri2":{"ns":"cts","fn":"uri-reference","args":[]},"cityName":{"ns":"cts","fn":"json-property-reference","args":["cityName"]},"cityTeam":{"ns":"cts","fn":"json-property-reference","args":["cityTeam"]}},"myTeam",{"ns":"op","fn":"fragment-id-col","args":["fragId2"]}]}]}]},{"ns":"op","fn":"where","args":[{"ns":"op","fn":"eq","args":[{"ns":"op","fn":"view-col","args":["myCity","city"]},{"ns":"op","fn":"col","args":["cityName"]}]}]},{"ns":"op","fn":"order-by","args":[{"ns":"op","fn":"asc","args":[{"ns":"op","fn":"col","args":["date"]}]}]}]}}'); + db.rows.query(exportedPlan, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(5); + expect(output.rows[0]['myCity.city']).to.equal('new jersey'); + expect(output.rows[0]['myCity.date']).to.equal('1971-12-23'); + expect(output.rows[0]['myTeam.cityName']).to.equal('new jersey'); + expect(output.rows[0]['myTeam.cityTeam']).to.equal('nets'); + expect(output.rows[4]['myCity.city']).to.equal('london'); + expect(output.rows[4]['myCity.date']).to.equal('2007-01-01'); + expect(output.rows[4]['myTeam.cityName']).to.equal('london'); + expect(output.rows[4]['myTeam.cityTeam']).to.equal('arsenal'); + expect(output.rows[4]['myTeam.uri2']).to.equal('/optic/lexicon/test/city1.json'); + expect(output.rows[4]['myCity.__docid']).to.not.exist; + expect(output.rows[4]['myTeam.__docid']).to.not.exist; + done(); + }, done); + }); + + it('TEST 10 - join inner with joinInnerDoc - with queryAsStream', function(done){ + let count = 0; + let str = ''; + const chunks = []; + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .joinDoc(op.col('doc'), op.col('uri2')) + .orderBy(op.asc(op.col('date'))) + db.rows.queryAsStream(output, 'object', { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'reference' }) + .on('data', function(chunk) { + chunks.push(chunk.kind.toString()); + count++; + }). + on('end', function() { + //console.log(count); + //console.log(chunks.join('')); + expect(chunks.join(' ')).to.equal('columns row row row row row'); + expect(count).to.equal(6); + done(); + }, done); + }); + + it('TEST 11 - join inner with joinInnerDoc and xpath - with queryAsStream sequence', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .joinDoc(op.col('doc'), op.col('uri2')) + .select(['uri1', 'city', 'popularity', 'date', 'distance', 'point', op.viewCol('myCity', '__docId'), 'uri2', 'cityName', 'cityTeam', op.viewCol('myTeam', '__docId'), op.as('nodes', op.xpath('doc', '/cityTeam'))]) + .where(op.isDefined(op.col('nodes'))) + .orderBy(op.asc(op.col('date'))) + db.rows.queryAsStream(output, 'sequence', { format: 'json', structure: 'object', columnTypes: 'header' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('\u001e{"columns":[{"name":"myCity.uri1","type":"xs:string"},{"name":"myCity.city","type":"xs:string"},{"name":"myCity.popularity","type":"xs:integer"},{"name":"myCity.date","type":"xs:date"},{"name":"myCity.distance","type":"xs:double"},{"name":"myCity.point","type":"http://marklogic.com/cts#point"},{"name":"myTeam.uri2","type":"xs:string"},{"name":"myTeam.cityName","type":"xs:string"},{"name":"myTeam.cityTeam","type":"xs:string"},{"name":"nodes","type":"array"}]}\u001e{"myCity.uri1":"/optic/lexicon/test/doc3.json","myCity.city":"new jersey","myCity.popularity":2,"myCity.date":"1971-12-23","myCity.distance":12.9,"myCity.point":"40.720001,-74.07","myTeam.uri2":"/optic/lexicon/test/city3.json","myTeam.cityName":"new jersey","myTeam.cityTeam":"nets","nodes":"nets"}\u001e{"myCity.uri1":"/optic/lexicon/test/doc4.xml","myCity.city":"beijing","myCity.popularity":5,"myCity.date":"1981-11-09","myCity.distance":134.5,"myCity.point":"39.900002,116.4","myTeam.uri2":"/optic/lexicon/test/city4.json","myTeam.cityName":"beijing","myTeam.cityTeam":"ducks","nodes":"ducks"}\u001e{"myCity.uri1":"/optic/lexicon/test/doc5.xml","myCity.city":"cape town","myCity.popularity":3,"myCity.date":"1999-04-22","myCity.distance":377.9,"myCity.point":"-33.91,18.42","myTeam.uri2":"/optic/lexicon/test/city5.json","myTeam.cityName":"cape town","myTeam.cityTeam":"pirates","nodes":"pirates"}\u001e{"myCity.uri1":"/optic/lexicon/test/doc2.json","myCity.city":"new york","myCity.popularity":5,"myCity.date":"2006-06-23","myCity.distance":23.3,"myCity.point":"40.709999,-74.009995","myTeam.uri2":"/optic/lexicon/test/city2.json","myTeam.cityName":"new york","myTeam.cityTeam":"yankee","nodes":"yankee"}\u001e{"myCity.uri1":"/optic/lexicon/test/doc1.json","myCity.city":"london","myCity.popularity":5,"myCity.date":"2007-01-01","myCity.distance":50.4,"myCity.point":"51.5,-0.12","myTeam.uri2":"/optic/lexicon/test/city1.json","myTeam.cityName":"london","myTeam.cityTeam":"arsenal","nodes":"arsenal"}'); + expect(count).to.equal(6); + done(); + }, done); + }); + + it('TEST 12 - join inner with joinInnerDoc and xpath - with queryAsStream chunked', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2) + .where(op.eq(op.viewCol('myCity', 'city'), op.col('cityName'))) + .joinDoc(op.col('doc'), op.col('uri2')) + .select(['uri1', 'city', 'popularity', 'date', 'distance', 'point', op.viewCol('myCity', '__docId'), 'uri2', 'cityName', 'cityTeam', op.viewCol('myTeam', '__docId'), op.as('nodes', op.xpath('doc', '/cityTeam'))]) + .where(op.isDefined(op.col('nodes'))) + .orderBy(op.asc(op.col('date'))) + db.rows.queryAsStream(output, 'chunked', { format: 'json', structure: 'array', columnTypes: 'rows' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('[ [{"name":"myCity.uri1"},{"name":"myCity.city"},{"name":"myCity.popularity"},{"name":"myCity.date"},{"name":"myCity.distance"},{"name":"myCity.point"},{"name":"myTeam.uri2"},{"name":"myTeam.cityName"},{"name":"myTeam.cityTeam"},{"name":"nodes"}], [{"type":"xs:string","value":"/optic/lexicon/test/doc3.json"},{"type":"xs:string","value":"new jersey"},{"type":"xs:integer","value":2},{"type":"xs:date","value":"1971-12-23"},{"type":"xs:double","value":12.9},{"type":"http://marklogic.com/cts#point","value":"40.720001,-74.07"},{"type":"xs:string","value":"/optic/lexicon/test/city3.json"},{"type":"xs:string","value":"new jersey"},{"type":"xs:string","value":"nets"},{"type":"text","value":"nets"}], [{"type":"xs:string","value":"/optic/lexicon/test/doc4.xml"},{"type":"xs:string","value":"beijing"},{"type":"xs:integer","value":5},{"type":"xs:date","value":"1981-11-09"},{"type":"xs:double","value":134.5},{"type":"http://marklogic.com/cts#point","value":"39.900002,116.4"},{"type":"xs:string","value":"/optic/lexicon/test/city4.json"},{"type":"xs:string","value":"beijing"},{"type":"xs:string","value":"ducks"},{"type":"text","value":"ducks"}], [{"type":"xs:string","value":"/optic/lexicon/test/doc5.xml"},{"type":"xs:string","value":"cape town"},{"type":"xs:integer","value":3},{"type":"xs:date","value":"1999-04-22"},{"type":"xs:double","value":377.9},{"type":"http://marklogic.com/cts#point","value":"-33.91,18.42"},{"type":"xs:string","value":"/optic/lexicon/test/city5.json"},{"type":"xs:string","value":"cape town"},{"type":"xs:string","value":"pirates"},{"type":"text","value":"pirates"}], [{"type":"xs:string","value":"/optic/lexicon/test/doc2.json"},{"type":"xs:string","value":"new york"},{"type":"xs:integer","value":5},{"type":"xs:date","value":"2006-06-23"},{"type":"xs:double","value":23.3},{"type":"http://marklogic.com/cts#point","value":"40.709999,-74.009995"},{"type":"xs:string","value":"/optic/lexicon/test/city2.json"},{"type":"xs:string","value":"new york"},{"type":"xs:string","value":"yankee"},{"type":"text","value":"yankee"}], [{"type":"xs:string","value":"/optic/lexicon/test/doc1.json"},{"type":"xs:string","value":"london"},{"type":"xs:integer","value":5},{"type":"xs:date","value":"2007-01-01"},{"type":"xs:double","value":50.4},{"type":"http://marklogic.com/cts#point","value":"51.5,-0.12"},{"type":"xs:string","value":"/optic/lexicon/test/city1.json"},{"type":"xs:string","value":"london"},{"type":"xs:string","value":"arsenal"},{"type":"text","value":"arsenal"}] ]'); + expect(count).to.equal(1); + done(); + }, done); + }); + + it('TEST 13 - restricted xpath with predicate fn:max', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2, + op.on(op.viewCol('myCity', 'city'), op.viewCol('myTeam', 'cityName')), + op.ne(op.col('popularity'), 3) + ) + .joinDoc(op.col('doc'), op.col('uri1')) + .select(['uri1', 'city', 'popularity', 'date', 'distance', 'point', op.as('nodes', op.xpath('doc', "/location[fn:max((./latLonPair/lat, ./latLonPair/long)) eq 51.5]")), 'uri2', 'cityName', 'cityTeam']) + .where(op.isDefined(op.col('nodes'))) + .orderBy(op.desc(op.col('distance'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myCity.city']).to.equal('london'); + expect(output.rows[0].nodes.latLonPair.lat).to.equal(51.5); + done(); + }, done); + }); + + it('TEST 14 - restricted xpath with predicate math:trunc', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2, + op.on(op.viewCol('myCity', 'city'), op.viewCol('myTeam', 'cityName')), + op.ne(op.col('popularity'), 3) + ) + .joinDoc(op.col('doc'), op.col('uri1')) + .select(['uri1', 'city', 'popularity', 'date', 'distance', 'point', op.as('nodes', op.xpath('doc', "/location[math:trunc(./latLonPair/lat, 0) eq 51]")), 'uri2', 'cityName', 'cityTeam']) + .where(op.isDefined(op.col('nodes'))) + .orderBy(op.desc(op.col('distance'))) + db.rows.query(output) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myCity.city'].value).to.equal('london'); + expect(output.rows[0].nodes.value.latLonPair.lat).to.equal(51.5); + done(); + }, done); + }); + + it('TEST 15 - restricted xpath with predicate sql:day', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2, + op.on(op.viewCol('myCity', 'city'), op.viewCol('myTeam', 'cityName')), + op.ne(op.col('popularity'), 3) + ) + .joinDoc(op.col('doc'), op.col('uri1')) + .select(['uri1', 'city', 'popularity', 'date', 'distance', 'point', op.as('nodes', op.xpath('doc', "/date[sql:day(.) lt 23]")), 'uri2', 'cityName', 'cityTeam']) + .where(op.isDefined(op.col('nodes'))) + .orderBy(op.desc(op.col('distance'))) + db.rows.query(output, { columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myCity.city']).to.equal('london'); + expect(output.rows[0]['myCity.date']).to.equal('2007-01-01'); + done(); + }, done); + }); + + it('TEST 16 - sql condition with between and AND operator', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2) + .where(op.sqlCondition('(myCity.popularity BETWEEN 2 AND 4) AND (city = cityName)')) + .orderBy(op.asc(op.col('date'))) + db.rows.query(output, { columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(2); + expect(output.rows[0]['myCity.city']).to.equal('new jersey'); + expect(output.rows[0]['myCity.popularity']).to.equal(2); + expect(output.rows[1]['myCity.city']).to.equal('cape town'); + expect(output.rows[1]['myCity.popularity']).to.equal(3); + done(); + }, done); + }); + + it('TEST 17 - with named parameters', function(done){ + const plan1 = + op.fromLexicons({ + indexes: + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, qualifierName: 'myCity' + }); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner({ + right: plan2, + keys: [op.on({left: op.viewCol('myCity', 'city'), right: op.viewCol({view: 'myTeam', column: 'cityName'})})], + condition: op.ne(op.col('popularity'), 3) + }) + .joinDoc({docCol: op.col('doc'), sourceCol: op.col('uri1')}) + .select({columns: ['uri1', 'city', 'popularity', 'date', 'distance', 'point', op.as('nodes', op.xpath({column: 'doc', path: "/date[sql:day(.) lt 23]"})), 'uri2', 'cityName', 'cityTeam']}) + .where(op.isDefined(op.col('nodes'))) + .orderBy(op.desc(op.col('distance'))) + db.rows.query(output, { columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myCity.city']).to.equal('london'); + expect(output.rows[0]['myCity.date']).to.equal('2007-01-01'); + done(); + }, done); + }); +}); diff --git a/test-complete/nodejs-optic-from-literals.js b/test-complete/nodejs-optic-from-literals.js new file mode 100644 index 00000000..4204116a --- /dev/null +++ b/test-complete/nodejs-optic-from-literals.js @@ -0,0 +1,325 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const expect = require('chai').expect; + +const fs = require('fs'); + +const marklogic = require('../'); + +const connectdef = require('../config-optic/connectdef.js'); + +const db = marklogic.createDatabaseClient(connectdef.plan); +const op = marklogic.planBuilder; + +describe('Nodejs Optic from literals test', function(){ + + it('TEST 1 - join inner and check types', function(done){ + const plan1 = + op.fromLiterals([ + {rowId: 1, colorId: 1, desc: 'ball', date: op.xs.date('2013-08-15'), duration: op.xs.yearMonthDuration('P3Y3M')}, + {rowId: 2, colorId: 2, desc: 'square', date: op.xs.date('2013-08-15'), duration: op.xs.yearMonthDuration('P3Y3M')}, + {rowId: 3, colorId: 1, desc: 'box', date: op.xs.date('2013-08-15'), duration: op.xs.yearMonthDuration('P3Y3M')}, + {rowId: 4, colorId: 1, desc: 'hoop', date: op.xs.date('2013-08-15'), duration: op.xs.yearMonthDuration('P3Y3M')}, + {rowId: 5, colorId: 5, desc: 'circle', date: op.xs.date('2013-08-15'), duration: op.xs.yearMonthDuration('P3Y3M')} + ]); + const plan2 = + op.fromLiterals([ + {colorId: 1, colorDesc: 'red', dateTime: op.xs.dateTime('2000-01-11T12:01:00.000Z')}, + {colorId: 2, colorDesc: 'blue', dateTime: op.xs.dateTime('2001-01-11T12:01:00.000Z')}, + {colorId: 3, colorDesc: 'black', dateTime: op.xs.dateTime('2002-01-11T12:01:00.000Z')}, + {colorId: 4, colorDesc: 'yellow', dateTime: op.xs.dateTime('2003-01-11T12:01:00.000Z')} + ]); + const output = + plan1.joinInner(plan2) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[3].name).to.equal('date'); + expect(output.columns[3].type).to.equal('xs:date'); + expect(output.columns[4].name).to.equal('dateTime'); + expect(output.columns[4].type).to.equal('xs:dateTime'); + expect(output.columns[5].name).to.equal('duration'); + expect(output.columns[5].type).to.equal('xs:yearMonthDuration'); + expect(output.rows.length).to.equal(4); + expect(output.rows[0].rowId).to.equal(1); + expect(output.rows[0].desc).to.equal('ball'); + expect(output.rows[0].colorDesc).to.equal('red'); + expect(output.rows[3].rowId).to.equal(4); + expect(output.rows[3].desc).to.equal('hoop'); + expect(output.rows[3].colorDesc).to.equal('red'); + done(); + }, done); + }); + + it('TEST 2 - join inner doc on json and xml documents', function(done){ + const output = + op.fromLiterals([ + {id:1, val: 2, uri:'/optic/lexicon/test/doc1.json'}, + {id:2, val: 4, uri:'/optic/test/not/a/real/doc.nada'}, + {id:3, val: 6, uri:'/optic/lexicon/test/doc3.json'}, + {id:4, val: 8, uri:'/optic/lexicon/test/doc4.xml'} + ]) + .joinDoc(op.col('doc'), op.col('uri')) + .orderBy(op.asc('id')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0].id).to.equal(1); + expect(output.rows[0].doc.city).to.equal('london'); + expect(output.rows[1].id).to.equal(3); + expect(output.rows[1].doc.city).to.equal('new jersey'); + expect(output.rows[2].id).to.equal(4); + expect(output.rows[2].doc).to.contain('beijing'); + done(); + }, done); + }); + + it('TEST 3 - where limit and select', function(done){ + const plan1 = + op.fromLiterals([ + {rowId: 1, colorId: 1, desc: 'ball'}, + {rowId: 2, colorId: 2, desc: 'square'}, + {rowId: 3, colorId: 1, desc: 'box'}, + {rowId: 4, colorId: 1, desc: 'hoop'}, + {rowId: 5, colorId: 5, desc: 'circle'} + ]); + const plan2 = + op.fromLiterals([ + {colorId: 1, colorDesc: 'red'}, + {colorId: 2, colorDesc: 'blue'}, + {colorId: 3, colorDesc: 'black'}, + {colorId: 4, colorDesc: 'yellow'} + ]); + const output = + plan1.joinInner(plan2) + .where(op.eq(op.col('colorId'), 1)) + .offsetLimit(1, 3) + db.rows.query(output, { format: 'json', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.length).to.equal(3); + expect(output[1][3]).to.equal(3); + expect(output[1][0]).to.equal('box'); + expect(output[2][3]).to.equal(4); + expect(output[2][0]).to.equal('hoop'); + done(); + }, done); + }); + + it('TEST 4 - join inner doc with xpath accessing attribute on xml', function(done){ + let count = 0; + let str = ''; + const chunks = []; + const output = + op.fromLiterals([ + {id:1, val: 2, uri:'/optic/lexicon/test/doc1.json'}, + {id:2, val: 4, uri:'/optic/test/not/a/real/doc.nada'}, + {id:3, val: 6, uri:'/optic/lexicon/test/doc3.json'}, + {id:4, val: 8, uri:'/optic/lexicon/test/doc4.xml'} + ]) + .orderBy(op.asc('id')) + .joinDoc(op.col('doc'), op.col('uri')) + .select(['id', 'val', 'uri', op.as('nodes', op.xpath('doc', '/doc/distance/@direction'))]) + .where(op.isDefined(op.col('nodes'))) + db.rows.queryAsStream(output) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('{ "columns": [{"name":"id"},{"name":"val"},{"name":"uri"},{"name":"nodes"}], "rows":[ {"id":{"type":"xs:integer","value":4},"val":{"type":"xs:integer","value":8},"uri":{"type":"xs:string","value":"/optic/lexicon/test/doc4.xml"},"nodes":{"type":"attribute","value":"east"}}] }'); + expect(count).to.equal(1); + done(); + }, done); + }); + + it('TEST 5 - multple inner joins', function(done){ + let count = 0; + let str = ''; + const chunks = []; + const plan1 = + op.fromLiterals([ + {rowId: 1, colorId: 1, desc: 'ball'}, + {rowId: 2, colorId: 2, desc: 'square'}, + {rowId: 3, colorId: 1, desc: 'box'}, + {rowId: 4, colorId: 1, desc: 'hoop'}, + {rowId: 5, colorId: 5, desc: 'circle'} + ], 'myItem'); + const plan2 = + op.fromLiterals([ + {colorId: 1, colorDesc: 'red'}, + {colorId: 2, colorDesc: 'blue'}, + {colorId: 3, colorDesc: 'black'}, + {colorId: 4, colorDesc: 'yellow'} + ], 'myColor'); + const plan3 = + op.fromLiterals([ + {color: 'red', ref: 'rose'}, + {color: 'blue', ref: 'water'}, + {color: 'black', ref: 'bag'}, + {color: 'yellow', ref: 'moon'} + ], 'myRef'); + const descCol = plan1.col('desc'); + const itemColorIdCol = plan1.col('colorId'); + const colorIdCol = plan2.col('colorId'); + const colorDescCol = plan2.col('colorDesc'); + const refColorCol = plan3.col('color'); + const refCol = plan3.col('ref'); + const output = + plan1.joinInner(plan2, [op.on(itemColorIdCol, colorIdCol)]) + .joinInner(plan3, op.on(colorDescCol, refColorCol)) + .select([descCol, colorIdCol, refCol]) + .orderBy([colorIdCol, descCol]) + db.rows.queryAsStream(output, 'sequence', { format: 'json', structure: 'object', columnTypes: 'header' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('\u001e{"columns":[{"name":"myItem.desc","type":"xs:string"},{"name":"myColor.colorId","type":"xs:integer"},{"name":"myRef.ref","type":"xs:string"}]}\u001e{"myItem.desc":"ball","myColor.colorId":1,"myRef.ref":"rose"}\u001e{"myItem.desc":"box","myColor.colorId":1,"myRef.ref":"rose"}\u001e{"myItem.desc":"hoop","myColor.colorId":1,"myRef.ref":"rose"}\u001e{"myItem.desc":"square","myColor.colorId":2,"myRef.ref":"water"}'); + expect(count).to.equal(5); + done(); + }, done); + }); + + it('TEST 6 - sql condition with in and AND', function(done){ + let count = 0; + let str = ''; + const chunks = []; + const plan1 = + op.fromLiterals([ + {rowId: 1, colorId: 1, desc: 'ball'}, + {rowId: 2, colorId: 2, desc: 'square'}, + {rowId: 3, colorId: 1, desc: 'box'}, + {rowId: 4, colorId: 1, desc: 'hoop'}, + {rowId: 5, colorId: 5, desc: 'circle'} + ], 'table1'); + const plan2 = + op.fromLiterals([ + {colorId: 1, colorDesc: 'red'}, + {colorId: 2, colorDesc: 'blue'}, + {colorId: 3, colorDesc: 'black'}, + {colorId: 4, colorDesc: 'yellow'} + ], 'table2'); + const output = + plan1.joinInner(plan2) + .where(op.sqlCondition("(table1.colorId = table2.colorId) AND table1.desc IN ('ball', 'box')")) + .orderBy(op.desc(op.viewCol('table1', 'rowId'))) + db.rows.queryAsStream(output, 'chunked', { format: 'csv', columnTypes: 'header' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('table1.desc,table2.colorId,table1.colorId,table2.colorDesc,table1.rowId box,1,1,red,3 ball,1,1,red,1'); + expect(count).to.equal(1); + done(); + }, done); + }); + + it('TEST 7 - with mapper', function(done){ + const plan1 = + op.fromLiterals([ + {rowId: 1, colorId_shape: 1, desc: 'ball'}, + {rowId: 2, colorId_shape: 2, desc: 'square'}, + {rowId: 3, colorId_shape: 1, desc: 'box'}, + {rowId: 4, colorId_shape: 1, desc: 'hoop'}, + {rowId: 5, colorId_shape: 5, desc: 'circle'} + ]); + + const plan2 = + op.fromLiterals([ + {colorId: 1, colorDesc: 'red'}, + {colorId: 2, colorDesc: 'blue'}, + {colorId: 3, colorDesc: 'black'}, + {colorId: 4, colorDesc: 'yellow'} + ]); + const output = + plan1.joinInner( + plan2, op.on(op.col('colorId_shape'), op.col('colorId')) + ) + .select([ + 'rowId', + op.as('description', op.col('desc')), + op.as('myColorId', op.col('colorId')), + 'colorDesc' + ]) + .orderBy(op.asc('rowId')) + .map(op.resolveFunction('colorIdMapper', '/optic/test/mapperReducer.sjs')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(4); + expect(output.rows[0].rowId).to.equal(1); + expect(output.rows[0].myColorId).to.equal('RED'); + expect(output.rows[1].rowId).to.equal(2); + expect(output.rows[1].myColorId).to.equal('BLUE'); + done(); + }, done); + }); + + it('TEST 8 - with reducer', function(done){ + const plan1 = + op.fromLiterals([ + {rowId: 1, colorId_shape: 1, desc: 'ball'}, + {rowId: 2, colorId_shape: 2, desc: 'square'}, + {rowId: 3, colorId_shape: 1, desc: 'box'}, + {rowId: 4, colorId_shape: 1, desc: 'hoop'}, + {rowId: 5, colorId_shape: 5, desc: 'circle'} + ]); + + const plan2 = + op.fromLiterals([ + {colorId: 1, colorDesc: 'red'}, + {colorId: 2, colorDesc: 'blue'}, + {colorId: 3, colorDesc: 'black'}, + {colorId: 4, colorDesc: 'yellow'} + ]); + const output = + plan1.joinInner( + plan2, op.on(op.col('colorId_shape'), op.col('colorId')) + ) + .select([ + op.as('myRowId', op.col('rowId')) + ]) + .orderBy(op.asc('myRowId')) + .reduce(op.resolveFunction('fibReducer', '/optic/test/mapperReducer.sjs')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(4); + expect(output.rows[0].myRowId).to.equal(1); + expect(output.rows[0].i).to.equal(0); + expect(output.rows[0].fib).to.equal(0); + expect(output.rows[3].myRowId).to.equal(4); + expect(output.rows[3].i).to.equal(3); + expect(output.rows[3].fib).to.equal(2); + done(); + }, done); + }); +}); diff --git a/test-complete/nodejs-optic-from-sparql.js b/test-complete/nodejs-optic-from-sparql.js new file mode 100644 index 00000000..897ee7e7 --- /dev/null +++ b/test-complete/nodejs-optic-from-sparql.js @@ -0,0 +1,347 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const expect = require('chai').expect; +const fs = require('fs'); + +const marklogic = require('../'); + +const connectdef = require('../config-optic/connectdef.js'); + +const db = marklogic.createDatabaseClient(connectdef.plan); +const op = marklogic.planBuilder; + +describe('Nodejs Optic from sparql test', function(){ + + it('TEST 1 - simple sparql select with offsetLimit - format json, structure object, columnTypes header', function(done){ + const output = + op.fromSPARQL("PREFIX foaf: \ + PREFIX ppl: \ + SELECT ?s ?o \ + WHERE { ?s foaf:knows ?o }") + .offsetLimit(11, 15) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(11); + expect(output.columns[0].name).to.equal('s'); + expect(output.columns[0].type).to.equal('sem:iri'); + expect(output.rows[0].s).to.equal('http://people.org/person16'); + expect(output.rows[0].o).to.equal('http://people.org/person18'); + expect(output.rows[10].s).to.equal('http://people.org/person9'); + expect(output.rows[10].o).to.equal('http://people.org/person12'); + done(); + }, done); + }); + + it('TEST 2 - sparql select with multiple triple patterns - columnTypes rows', function(done){ + const output = + op.fromSPARQL("PREFIX foaf: \ + PREFIX ppl: \ + SELECT * \ + WHERE { \ + ?person foaf:name ?name . \ + ?person ?type . \ + }") + .limit(5) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(5); + expect(output.rows[0].person.value).to.equal('http://people.org/person1'); + expect(output.rows[0].person.type).to.equal('sem:iri'); + expect(output.rows[0].name.value).to.equal('Person 1'); + expect(output.rows[0].type.value).to.equal('http://people.org/Person'); + expect(output.rows[0].type.type).to.equal('sem:iri'); + done(); + }, done); + }); + + it('TEST 3 - sparql select with multiple triple patterns with condition - structure array', function(done){ + const output = + op.fromSPARQL("PREFIX foaf: \ + PREFIX ppl: \ + SELECT ?personA ?personB \ + WHERE { \ + ?personB foaf:name 'Person 7' . \ + ?personA foaf:knows ?personB \ + }") + db.rows.query(output, { format: 'json', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.length).to.equal(2); + expect(output[1][0]).to.equal('http://people.org/person1'); + expect(output[1][1]).to.equal('http://people.org/person7'); + done(); + }, done); + }); + + it('TEST 4 - sparql select with order by - format xml', function(done){ + const output = + op.fromSPARQL("PREFIX foaf: \ + PREFIX ppl: \ + SELECT * \ + WHERE { \ + ?person foaf:name ?name . \ + ?person ?type . \ + } \ + ORDER BY ?name") + .limit(15) + .offset(11) + db.rows.query(output, { format: 'xml', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + const outputStr = output.toString().trim().replace(/[\n\r]/g, ''); + //console.log(outputStr); + expect(outputStr).to.equal('http://people.org/person2Person 2http://people.org/Personhttp://people.org/person20Person 20http://people.org/Personhttp://people.org/person3Person 3http://people.org/Personhttp://people.org/person4Person 4http://people.org/Person'); + done(); + }, done); + }); + + it('TEST 5 - sparql aggregate on count - format csv, structure array', function(done){ + const output = + op.fromSPARQL("PREFIX demov: \ + PREFIX vcard: \ + SELECT (COUNT(?industry) AS ?total) \ + FROM \ + WHERE { \ + ?company a vcard:Organization . \ + ?company demov:industry ?industry . \ + ?company demov:industry 'Industrial Goods' \ + }") + db.rows.query(output, { format: 'csv', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + expect(output).to.contain('["total"]'); + expect(output).to.contain('[15]'); + done(); + }, done); + }); + + it('TEST 6 - sparql aggregate on count distinct - queryAsStream object', function(done){ + let count = 0; + let str = ''; + const chunks = []; + const output = + op.fromSPARQL("PREFIX demov: \ + PREFIX vcard: \ + SELECT (COUNT( DISTINCT ?industry) AS ?total_industries) \ + FROM \ + WHERE { \ + ?company demov:industry ?industry . \ + }") + db.rows.queryAsStream(output, 'object', { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'reference' }) + .on('data', function(chunk) { + chunks.push(chunk.kind.toString()); + count++; + }). + on('end', function() { + //console.log(count); + //console.log(chunks.join('')); + expect(chunks.join(' ')).to.equal('columns row'); + expect(count).to.equal(2); + done(); + }, done); + }); + + it('TEST 7 - sparql aggregate on sum - queryAsStream sequence, structure array, columnTypes rows', function(done){ + let count = 0; + let str = ''; + const chunks = []; + const output = + op.fromSPARQL("PREFIX demov: \ + PREFIX vcard: \ + SELECT ( SUM (?sales) AS ?sum_sales ) \ + FROM \ + WHERE { \ + ?company a vcard:Organization . \ + ?company demov:sales ?sales \ + }") + db.rows.queryAsStream(output, 'sequence', { format: 'json', structure: 'array', columnTypes: 'rows' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('\u001e[{"name":"sum_sales"}]\u001e[{"type":"xs:integer","value":19318588272}]'); + expect(count).to.equal(2); + done(); + }, done); + }); + + it('TEST 8 - sparql aggregate on sum with bind - queryAsStream chunked, format xml', function(done){ + let count = 0; + let str = ''; + const chunks = []; + const output = + op.fromSPARQL("PREFIX demov: \ + PREFIX vcard: \ + SELECT DISTINCT ?industry (SUM(?sales) as ?total_sales) ?country \ + FROM \ + WHERE { \ + ?company a vcard:Organization . \ + ?company demov:sales ?sales . \ + ?company demov:industry 'Other' . \ + ?company vcard:hasAddress/vcard:country-name 'USA' . \ + BIND (vcard:hasAddress/vcard:country-name as ?country) \ + BIND (demov:industry as ?industry) \ + }") + db.rows.queryAsStream(output, 'chunked', { format: 'xml', structure: 'object', columnTypes: 'header' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal(' http://demo/verb#industry 1647852766 '); + expect(count).to.equal(1); + done(); + }, done); + }); + + it('TEST 9 - sparql group by', function(done){ + const output = + op.fromSPARQL("PREFIX demov: \ + PREFIX vcard: \ + SELECT ?industry (SUM (?sales) AS ?sum_sales ) \ + FROM \ + WHERE { \ + ?company a vcard:Organization . \ + ?company demov:sales ?sales . \ + ?company demov:industry ?industry \ + } \ + GROUP BY ?industry \ + ORDER BY ?sum_sales") + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(6); + expect(output.rows[0].industry).to.equal('Retail/Wholesale'); + expect(output.rows[0].sum_sales).to.equal(1255159206); + expect(output.rows[5].industry).to.equal('Healthcare/Life Sciences'); + expect(output.rows[5].sum_sales).to.equal(6141852782); + done(); + }, done); + }); + + it('TEST 10 - sparql group by with min - export and execute plan', function(done){ + const output = + op.fromSPARQL("PREFIX demov: \ + PREFIX vcard: \ + SELECT ?country (MIN (?sales) AS ?min_sales ) \ + FROM \ + WHERE { \ + ?company a vcard:Organization . \ + ?company demov:sales ?sales . \ + ?company vcard:hasAddress [ vcard:country-name ?country ] \ + } \ + GROUP BY ?country \ + ORDER BY ASC( ?min_sales ) ?country") + .export(); + //console.log(JSON.stringify(output).trim().replace(/[\n\r]/g, '')); + const outputStr = JSON.stringify(output).trim().replace(/[\n\r]/g, ''); + //console.log(outputStr); + expect(outputStr).to.equal('{"$optic":{"ns":"op","fn":"operators","args":[{"ns":"op","fn":"from-sparql","args":["PREFIX demov: PREFIX vcard: SELECT ?country (MIN (?sales) AS ?min_sales ) FROM WHERE { ?company a vcard:Organization . ?company demov:sales ?sales . ?company vcard:hasAddress [ vcard:country-name ?country ] } GROUP BY ?country ORDER BY ASC( ?min_sales ) ?country"]}]}}'); + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(8); + expect(output.rows[0].country).to.equal('China'); + expect(output.rows[0].min_sales).to.equal(8); + expect(output.rows[7].country).to.equal('USA'); + expect(output.rows[7].min_sales).to.equal(10000000); + done(); + }, done); + }); + + it('TEST 11 - sparql group by with qualifier', function(done){ + const output = + op.fromSPARQL("PREFIX demov: \ + PREFIX vcard: \ + SELECT ?industry (SUM (?sales) AS ?sum_sales ) \ + FROM \ + WHERE { \ + ?company a vcard:Organization . \ + ?company demov:sales ?sales . \ + ?company demov:industry ?industry \ + } \ + GROUP BY ?industry \ + ORDER BY ?sum_sales", 'MySPARQL') + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(6); + expect(output.rows[0]['MySPARQL.industry']).to.equal('Retail/Wholesale'); + expect(output.rows[0]['MySPARQL.sum_sales']).to.equal(1255159206); + expect(output.rows[5]['MySPARQL.industry']).to.equal('Healthcare/Life Sciences'); + expect(output.rows[5]['MySPARQL.sum_sales']).to.equal(6141852782); + done(); + }, done); + }); + + it('TEST 15 - with explain', function(done){ + const output = + op.fromSPARQL("PREFIX demov: \ + PREFIX vcard: \ + SELECT ?industry (SUM (?sales) AS ?sum_sales ) \ + FROM \ + WHERE { \ + ?company a vcard:Organization . \ + ?company demov:sales ?sales . \ + ?company demov:industry ?industry \ + } \ + GROUP BY ?industry \ + ORDER BY ?sum_sales", 'MySPARQL') + db.rows.explain(output, 'json') + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.node).to.equal('plan'); + expect(output.expr.from['default-graph'][0].value).to.equal('/optic/sparql/test/companies.ttl'); + done(); + }, done); + }); + + it('TEST 16 - negative case', function(done){ + const output = + op.fromSPARQL("PREFIX foaf: \ + PREFIX ppl: \ + SELECT * \ + WHERE { \ + ?person foaf:name ?name . \ + ?person ?type . \ + } \ + ORDER BY ?name") + .limit(-1) + .offset(11) + db.rows.query(output, { format: 'xml', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + expect(output).to.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + expect(error.body.errorResponse.message).to.contain('limit must be a positive number'); + done(); + }); + }); + +}); diff --git a/test-complete/nodejs-optic-from-sql.js b/test-complete/nodejs-optic-from-sql.js new file mode 100644 index 00000000..cf15e4dc --- /dev/null +++ b/test-complete/nodejs-optic-from-sql.js @@ -0,0 +1,310 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const expect = require('chai').expect; + +const fs = require('fs'); + +const marklogic = require('../'); + +const connectdef = require('../config-optic/connectdef.js'); + +const db = marklogic.createDatabaseClient(connectdef.plan); +const op = marklogic.planBuilder; + +describe('Nodejs Optic from sql test', function(){ + + it('TEST 1 - join inner with keymatch - with format json, structure object, columnTypes header', function(done){ + const plan1 = + op.fromSQL("SELECT * from opticFunctionalTest.detail"); + const plan2 = + op.fromSQL("SELECT * from opticFunctionalTest.master"); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .orderBy(op.asc(op.schemaCol('opticFunctionalTest', 'detail', 'id'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[5].type).to.equal('xs:date'); + expect(output.rows.length).to.equal(6); + expect(output.rows[0]['opticFunctionalTest.detail.id']).to.equal(1); + expect(output.rows[0]['opticFunctionalTest.master.id']).to.equal(1); + expect(output.rows[0]['opticFunctionalTest.detail.masterId']).to.equal(1); + expect(output.rows[0]['opticFunctionalTest.detail.name']).to.equal('Detail 1'); + expect(output.rows[5]['opticFunctionalTest.detail.id']).to.equal(6); + expect(output.rows[5]['opticFunctionalTest.master.id']).to.equal(2); + expect(output.rows[5]['opticFunctionalTest.detail.masterId']).to.equal(2); + expect(output.rows[5]['opticFunctionalTest.detail.name']).to.equal('Detail 6'); + done(); + }, done); + }); + + it('TEST 2 - join inner with keymatch and select - with format json, structure object, columnTypes rows', function(done){ + const output = + op.fromSQL("SELECT opticFunctionalTest.master.name AS MasterName, opticFunctionalTest.master.date, opticFunctionalTest.detail.name AS DetailName, opticFunctionalTest.detail.amount, opticFunctionalTest.detail.color" + + " FROM opticFunctionalTest.detail" + + " INNER JOIN opticFunctionalTest.master ON opticFunctionalTest.master.id = opticFunctionalTest.detail.masterId" + + " ORDER BY DetailName DESC") + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(6); + expect(output.rows[0].MasterName.value).to.equal('Master 2'); + expect(output.rows[0].DetailName.value).to.equal('Detail 6'); + expect(output.rows[0]['opticFunctionalTest.detail.amount'].value).to.equal(60.06); + expect(output.rows[0]['opticFunctionalTest.detail.amount'].type).to.equal('xs:double'); + expect(output.rows[5].MasterName.value).to.equal('Master 1'); + expect(output.rows[5].DetailName.value).to.equal('Detail 1'); + expect(output.rows[5]['opticFunctionalTest.detail.color'].value).to.equal('blue'); + expect(output.rows[5]['opticFunctionalTest.detail.color'].type).to.equal('xs:string'); + done(); + }, done); + }); + + it('TEST 3 - group by - with structure array', function(done){ + const plan1 = + op.fromSQL("SELECT * from opticFunctionalTest.detail"); + const plan2 = + op.fromSQL("SELECT * from opticFunctionalTest.master"); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .groupBy(op.schemaCol('opticFunctionalTest', 'master', 'name'), op.sum('DetailSum', op.schemaCol('opticFunctionalTest', 'detail', 'amount'))) + .orderBy(op.desc(op.col('DetailSum'))) + db.rows.query(output, { format: 'json', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.length).to.equal(3); + expect(output[1][0]).to.equal('Master 2'); + expect(output[1][1]).to.equal(120.12); + expect(output[2][0]).to.equal('Master 1'); + expect(output[2][1]).to.equal(90.09); + done(); + }, done); + }); + + it('TEST 4 - sql group by - format xml', function(done){ + const output = + op.fromSQL("SELECT opticFunctionalTest.master.name, opticFunctionalTest.detail.name AS DetailName, opticFunctionalTest.detail.color, SUM(amount) AS DetailSum \ + FROM opticFunctionalTest.detail \ + INNER JOIN opticFunctionalTest.master ON opticFunctionalTest.master.id = opticFunctionalTest.detail.masterId \ + GROUP BY opticFunctionalTest.master.name") + .orderBy(op.desc(op.col('DetailSum'))) + db.rows.query(output, { format: 'xml', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + const outputStr = output.toString().trim().replace(/[\n\r]/g, ''); + //console.log(outputStr); + expect(outputStr).to.contain('90.09'); + expect(outputStr).to.contain('120.12'); + done(); + }, done); + }); + + it('TEST 5 - join left outer with select - format csv', function(done){ + const output = + op.fromSQL("SELECT * FROM opticFunctionalTest.detail LEFT JOIN opticFunctionalTest.master") + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .orderBy([op.desc(op.col('DetailName')), op.desc(op.col('MasterName'))]) + db.rows.query(output, { format: 'csv', structure: 'array', columnTypes: 'rows' }) + .then(function(output) { + //console.log(output); + expect(output).to.contain('["MasterName", "opticFunctionalTest.master.date", "DetailName", "opticFunctionalTest.detail.amount", "opticFunctionalTest.detail.color"]'); + expect(output).to.contain('["Master 2", "2015-12-02", "Detail 6", 60.06, "green"]'); + expect(output).to.contain('["Master 1", "2015-12-01", "Detail 1", 10.01, "blue"]'); + done(); + }, done); + }); + + it('TEST 6 - union with select - queryAsStream object', function(done){ + let count = 0; + let str = ''; + const chunks = []; + const output = + op.fromSQL("SELECT opticFunctionalTest.detail.id, opticFunctionalTest.detail.name FROM opticFunctionalTest.detail ORDER BY name \ + UNION \ + SELECT opticFunctionalTest.master.id, opticFunctionalTest.master.name FROM opticFunctionalTest.master ORDER BY name") + .orderBy('id') + db.rows.queryAsStream(output, 'object', { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'reference' }) + .on('data', function(chunk) { + chunks.push(chunk.kind.toString()); + count++; + }). + on('end', function() { + //console.log(count); + //console.log(chunks.join('')); + expect(chunks.join(' ')).to.equal('columns row row row row row row row row'); + expect(count).to.equal(9); + done(); + }, done); + }); + + it('TEST 7 - join cross product - queryAsStream sequence', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const output = + op.fromSQL("SELECT opticFunctionalTest.master.name, opticFunctionalTest.master.date, opticFunctionalTest.detail.name, opticFunctionalTest.detail.amount, opticFunctionalTest.detail.color FROM opticFunctionalTest.detail \ + CROSS JOIN opticFunctionalTest.master \ + ORDER BY opticFunctionalTest.detail.name DESC, opticFunctionalTest.master.name ASC") + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + db.rows.queryAsStream(output, 'sequence', { format: 'json', structure: 'object', columnTypes: 'header' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('\u001e{"columns":[{"name":"MasterName","type":"xs:string"},{"name":"opticFunctionalTest.master.date","type":"xs:date"},{"name":"DetailName","type":"xs:string"},{"name":"opticFunctionalTest.detail.amount","type":"xs:double"},{"name":"opticFunctionalTest.detail.color","type":"xs:string"}]}\u001e{"MasterName":"Master 1","opticFunctionalTest.master.date":"2015-12-01","DetailName":"Detail 6","opticFunctionalTest.detail.amount":60.06,"opticFunctionalTest.detail.color":"green"}\u001e{"MasterName":"Master 2","opticFunctionalTest.master.date":"2015-12-02","DetailName":"Detail 6","opticFunctionalTest.detail.amount":60.06,"opticFunctionalTest.detail.color":"green"}\u001e{"MasterName":"Master 1","opticFunctionalTest.master.date":"2015-12-01","DetailName":"Detail 5","opticFunctionalTest.detail.amount":50.05,"opticFunctionalTest.detail.color":"green"}\u001e{"MasterName":"Master 2","opticFunctionalTest.master.date":"2015-12-02","DetailName":"Detail 5","opticFunctionalTest.detail.amount":50.05,"opticFunctionalTest.detail.color":"green"}\u001e{"MasterName":"Master 1","opticFunctionalTest.master.date":"2015-12-01","DetailName":"Detail 4","opticFunctionalTest.detail.amount":40.04,"opticFunctionalTest.detail.color":"green"}\u001e{"MasterName":"Master 2","opticFunctionalTest.master.date":"2015-12-02","DetailName":"Detail 4","opticFunctionalTest.detail.amount":40.04,"opticFunctionalTest.detail.color":"green"}\u001e{"MasterName":"Master 1","opticFunctionalTest.master.date":"2015-12-01","DetailName":"Detail 3","opticFunctionalTest.detail.amount":30.03,"opticFunctionalTest.detail.color":"blue"}\u001e{"MasterName":"Master 2","opticFunctionalTest.master.date":"2015-12-02","DetailName":"Detail 3","opticFunctionalTest.detail.amount":30.03,"opticFunctionalTest.detail.color":"blue"}\u001e{"MasterName":"Master 1","opticFunctionalTest.master.date":"2015-12-01","DetailName":"Detail 2","opticFunctionalTest.detail.amount":20.02,"opticFunctionalTest.detail.color":"blue"}\u001e{"MasterName":"Master 2","opticFunctionalTest.master.date":"2015-12-02","DetailName":"Detail 2","opticFunctionalTest.detail.amount":20.02,"opticFunctionalTest.detail.color":"blue"}\u001e{"MasterName":"Master 1","opticFunctionalTest.master.date":"2015-12-01","DetailName":"Detail 1","opticFunctionalTest.detail.amount":10.01,"opticFunctionalTest.detail.color":"blue"}\u001e{"MasterName":"Master 2","opticFunctionalTest.master.date":"2015-12-02","DetailName":"Detail 1","opticFunctionalTest.detail.amount":10.01,"opticFunctionalTest.detail.color":"blue"}'); + expect(count).to.equal(13); + done(); + }, done); + }); + + it('TEST 8 - select with empty string qualifier and as - with queryAsStream chunked', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const output = + op.fromSQL("SELECT * FROM opticFunctionalTest.detail INNER JOIN opticFunctionalTest.master WHERE opticFunctionalTest.detail.masterId = opticFunctionalTest.master.id") + .select([op.schemaCol('opticFunctionalTest', 'detail', 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'color'), + op.as('masterName', op.schemaCol('opticFunctionalTest', 'master', 'name'))], + '') + .orderBy('id') + db.rows.queryAsStream(output, 'chunked', { format: 'json', structure: 'object', columnTypes: 'header' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('{ "columns": [{"name":"id","type":"xs:integer"},{"name":"color","type":"xs:string"},{"name":"masterName","type":"xs:string"}], "rows":[ {"id":1,"color":"blue","masterName":"Master 1"}, {"id":2,"color":"blue","masterName":"Master 2"}, {"id":3,"color":"blue","masterName":"Master 1"}, {"id":4,"color":"green","masterName":"Master 2"}, {"id":5,"color":"green","masterName":"Master 1"}, {"id":6,"color":"green","masterName":"Master 2"}] }'); + expect(count).to.equal(1); + done(); + }, done); + }); + + it('TEST 9 - inner join with multiple on', function(done){ + const output = + op.fromSQL("SELECT * FROM opticFunctionalTest.detail INNER JOIN opticFunctionalTest.master WHERE (opticFunctionalTest.detail.masterId = opticFunctionalTest.master.id AND opticFunctionalTest.master.id = opticFunctionalTest.detail.id)") + .orderBy(op.desc(op.viewCol('detail', 'name'))) + .offsetLimit(1, 100) + .export(); + const outputStr = JSON.stringify(output).trim().replace(/[\n\r]/g, ''); + //console.log(outputStr); + expect(outputStr).to.equal('{"$optic":{"ns":"op","fn":"operators","args":[{"ns":"op","fn":"from-sql","args":["SELECT * FROM opticFunctionalTest.detail INNER JOIN opticFunctionalTest.master WHERE (opticFunctionalTest.detail.masterId = opticFunctionalTest.master.id AND opticFunctionalTest.master.id = opticFunctionalTest.detail.id)"]},{"ns":"op","fn":"order-by","args":[{"ns":"op","fn":"desc","args":[{"ns":"op","fn":"view-col","args":["detail","name"]}]}]},{"ns":"op","fn":"offset-limit","args":[1,100]}]}}'); + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['opticFunctionalTest.master.id']).to.equal(1); + expect(output.rows[0]['opticFunctionalTest.master.name']).to.equal('Master 1'); + expect(output.rows[0]['opticFunctionalTest.detail.id']).to.equal(1); + expect(output.rows[0]['opticFunctionalTest.detail.name']).to.equal('Detail 1'); + expect(output.rows[0]['opticFunctionalTest.detail.masterId']).to.equal(1); + done(); + }, done); + }); + + it('TEST 10 - arithmetic operations with sql condition', function(done){ + const output = + op.fromSQL("SELECT (opticFunctionalTest.detail.amount + opticFunctionalTest.detail.masterId) AS added, \ + (opticFunctionalTest.detail.amount - opticFunctionalTest.master.id) AS substracted, \ + (opticFunctionalTest.detail.amount % opticFunctionalTest.master.id) AS modulo, \ + (opticFunctionalTest.detail.amount / (opticFunctionalTest.detail.amount * opticFunctionalTest.detail.id)) AS divided \ + FROM opticFunctionalTest.detail INNER JOIN opticFunctionalTest.master WHERE opticFunctionalTest.detail.masterId = opticFunctionalTest.master.id") + .where(op.sqlCondition("divided >= 0.3")) + .orderBy(op.asc('substracted')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0].divided).to.equal(1); + expect(output.rows[2].divided).to.equal(0.333333333333333); + done(); + }, done); + }); + + it('TEST 11 - sql like', function(done){ + const output = + op.fromSQL("SELECT * FROM opticFunctionalTest.detail \ + INNER JOIN opticFunctionalTest.master \ + WHERE (opticFunctionalTest.detail.masterId = opticFunctionalTest.master.id AND opticFunctionalTest.detail.color LIKE 'b%')") + .select([op.schemaCol('opticFunctionalTest', 'detail', 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'color'), + op.as('masterName', op.schemaCol('opticFunctionalTest', 'master', 'name'))], + '') + .orderBy('id') + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0].color).to.equal('blue'); + expect(output.rows[1].color).to.equal('blue'); + expect(output.rows[2].color).to.equal('blue'); + done(); + }, done); + }); + + it('TEST 12 - with named params', function(done){ + const output = + op.fromSQL({select: "SELECT (opticFunctionalTest.detail.amount + opticFunctionalTest.detail.masterId) AS added, \ + (opticFunctionalTest.detail.amount - opticFunctionalTest.master.id) AS substracted, \ + (opticFunctionalTest.detail.amount % opticFunctionalTest.master.id) AS modulo, \ + (opticFunctionalTest.detail.amount / (opticFunctionalTest.detail.amount * opticFunctionalTest.detail.id)) AS divided \ + FROM opticFunctionalTest.detail INNER JOIN opticFunctionalTest.master WHERE opticFunctionalTest.detail.masterId = opticFunctionalTest.master.id", qualifierName: 'mySQL'}) + .where({condition: op.sqlCondition({expression: "divided >= 0.3"})}) + .orderBy({keys: op.asc({column: 'substracted'})}) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0]['mySQL.divided']).to.equal(1); + expect(output.rows[2]['mySQL.divided']).to.equal(0.333333333333333); + done(); + }, done); + }); + +}); diff --git a/test-complete/nodejs-optic-from-triples.js b/test-complete/nodejs-optic-from-triples.js new file mode 100644 index 00000000..1a8bebca --- /dev/null +++ b/test-complete/nodejs-optic-from-triples.js @@ -0,0 +1,582 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const expect = require('chai').expect; + +const fs = require('fs'); + +const marklogic = require('../'); + +const connectdef = require('../config-optic/connectdef.js'); + +const db = marklogic.createDatabaseClient(connectdef.plan); +const op = marklogic.planBuilder; + +describe('Nodejs Optic from triples test', function(){ + + /*it('sleep for 10 seconds', function(done) { + setTimeout(function() { + done(); + }, 10000); + });*/ + + it('TEST 1 - access with desc orderBy - format json, structure object, columnTypes header', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const ageCol = op.col('age'); + const idCol = op.col('id'); + const nameCol = op.col('name'); + const teamCol = op.col('team'); + const output = + op.fromTriples([ + op.pattern(idCol, bb('age'), ageCol), + op.pattern(idCol, bb('name'), nameCol), + op.pattern(idCol, bb('team'), teamCol) + ], null, null, {dedup: 'on'}) + .orderBy(op.desc(ageCol)) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[0].name).to.equal('id'); + expect(output.columns[0].type).to.equal('sem:iri'); + expect(output.columns[3].name).to.equal('team'); + expect(output.columns[3].type).to.equal('sem:iri'); + expect(output.rows.length).to.equal(8); + expect(output.rows[0].id).to.equal('http://marklogic.com/baseball/id#006'); + expect(output.rows[0].age).to.equal(34); + expect(output.rows[0].name).to.equal('Aoki Yamada'); + expect(output.rows[0].team).to.equal('http://marklogic.com/mlb/team/id/003'); + expect(output.rows[7].id).to.equal('http://marklogic.com/baseball/id#005'); + expect(output.rows[7].age).to.equal(19); + expect(output.rows[7].name).to.equal('Pedro Barrozo'); + expect(output.rows[7].team).to.equal('http://marklogic.com/mlb/team/id/002'); + done(); + }, done); + }); + + it('TEST 2 - join inner - format json, structure object, columnTypes rows', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerTeamCol = op.col('player_team'); + const teamIdCol = op.col('player_team'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol) + ], null, null, {dedup: 'on'}); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ]); + const output = + player_plan.joinInner(team_plan) + .where(op.eq(teamNameCol, 'Giants')) + .orderBy(op.asc(playerAgeCol)) + .select([ + op.as('PlayerName', playerNameCol), + op.as('PlayerAge', playerAgeCol), + op.as('TeamName', op.fn.concat(teamCityCol, ' ', teamNameCol)) + ]) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0].PlayerName.value).to.equal('Juan Leone'); + expect(output.rows[0].TeamName.value).to.equal('San Francisco Giants'); + expect(output.rows[0].TeamName.type).to.equal('xs:string'); + expect(output.rows[2].TeamName.value).to.equal('San Francisco Giants'); + done(); + }, done); + }); + + it('TEST 3 - join inner with condition - format xml, structure array', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerTeamCol = op.col('player_team'); + const teamIdCol = op.col('team_id'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol) + ], null, null); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ], null, null); + + const output = + player_plan.joinInner( + team_plan, + op.on(playerTeamCol, teamIdCol), + op.and(op.gt(playerAgeCol, 27), op.eq(teamNameCol, 'Giants')) + ) + .orderBy(op.asc(playerAgeCol)) + .select([ + op.as('PlayerName', playerNameCol), + op.as('PlayerAge', playerAgeCol), + op.as('TeamName', op.fn.concat(teamCityCol, ' ', teamNameCol)) + ]) + + db.rows.query(output, { format: 'xml', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + const outputStr = output.toString().trim().replace(/[\n\r]/g, ''); + //console.log(outputStr); + expect(outputStr).to.equal('Josh Ream29San Francisco GiantsJohn Doe31San Francisco Giants'); + done(); + }, done); + }); + + it('TEST 4 - union with where distinct - format csv', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerTeamCol = op.col('player_team'); + const teamIdCol = op.col('player_team'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol) + ]); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ]); + + const output = + player_plan.union(team_plan) + .whereDistinct() + db.rows.query(output, { format: 'csv', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + expect(output).to.contain('player_id,player_age,player_name,player_team,team_name,team_city'); + expect(output).to.contain(',,,http://marklogic.com/mlb/team/id/001,Giants,San Francisco'); + expect(output).to.contain('http://marklogic.com/baseball/id#001,31,John Doe,http://marklogic.com/mlb/team/id/001,,'); + expect(output).to.contain('http://marklogic.com/baseball/id#008,27,Juan Leone,http://marklogic.com/mlb/team/id/001,,'); + done(); + }, done); + }); + + it('TEST 5 - group by avg - queryAsStream sequence', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerTeamCol = op.col('player_team'); + const teamIdCol = op.col('player_team'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol) + ]); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ]); + + const output = + player_plan.joinInner(team_plan) + .groupBy(teamNameCol, op.avg('AverageAge', playerAgeCol)) + .orderBy(op.asc(op.col('AverageAge'))) + db.rows.queryAsStream(output, 'sequence', { format: 'json', structure: 'object', columnTypes: 'header' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('\u001e{"columns":[{"name":"team_name","type":"xs:string"},{"name":"AverageAge","type":"xs:decimal"}]}\u001e{"team_name":"Athletics","AverageAge":19}\u001e{"team_name":"Mariners","AverageAge":27}\u001e{"team_name":"Padres","AverageAge":28.5}\u001e{"team_name":"Giants","AverageAge":29}'); + expect(count).to.equal(5); + done(); + }, done); + }); + + it('TEST 6 - group by sum on all - queryAsStream chunked', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerEffCol = op.col('player_eff'); + const playerTeamCol = op.col('player_team'); + const teamIdCol = op.col('player_team'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol), + op.pattern(playerIdCol, bb('eff'), playerEffCol) + ]); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ]); + + const output = + player_plan.joinInner(team_plan) + .groupBy(null, op.sum('SumAll', playerEffCol)) + .orderBy(op.desc(op.col('SumAll'))) + db.rows.queryAsStream(output, 'chunked', { format: 'xml', structure: 'array', columnTypes: 'rows' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal(' 350.4 '); + expect(count).to.equal(1); + done(); + }, done); + }); + + it('TEST 7 - join inner with graph iri', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerTeamCol = op.col('player_team'); + const graphCol = op.col('graphUri'); + const teamIdCol = op.col('player_team'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol, op.graphCol('graphUri')), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol) + ], + null, '/optic/player/triple/test' + ); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ], null, null); + + const output = + player_plan.joinInner(team_plan) + .where(op.eq(teamNameCol, 'Giants')) + .orderBy(op.asc(playerAgeCol)) + .select([ + op.as('PlayerName', playerNameCol), + op.as('PlayerAge', playerAgeCol), + op.as('TeamName', op.fn.concat(teamCityCol, ' ', teamNameCol)), + op.as('GraphName', graphCol) + ]) + + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0].PlayerName).to.equal('Juan Leone'); + expect(output.rows[0].TeamName).to.equal('San Francisco Giants'); + expect(output.rows[0].GraphName).to.equal('/optic/player/triple/test'); + expect(output.rows[2].TeamName).to.equal('San Francisco Giants'); + done(); + }, done); + }); + + it('TEST 8 - join inner with non matching graph iri', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerTeamCol = op.col('player_team'); + const graphCol = op.col('graphUri'); + const teamIdCol = op.col('player_team'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol, op.graphCol('graphUri')), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol) + ], null, '/optic/team/triple/test' + ); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ], null, null); + + const output = + player_plan.joinInner(team_plan) + .where(op.eq(teamNameCol, 'Giants')) + .orderBy(op.asc(playerAgeCol)) + .select([ + op.as('PlayerName', playerNameCol), + op.as('PlayerAge', playerAgeCol), + op.as('TeamName', op.fn.concat(teamCityCol, ' ', teamNameCol)) + ]) + + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output).to.be.undefined; + done(); + }, done); + }); + + it('TEST 9 - join inner with array of graph iris', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerTeamCol = op.col('player_team'); + const playerGraphCol = op.col('graphUri1'); + const teamIdCol = op.col('player_team'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol, op.graphCol('graphUri1')), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol) + ], null, ['/optic/player/triple/test', '/optic/team/triple/test'] + ); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ], null, null + ); + + const output = + player_plan.joinInner(team_plan) + .where(op.eq(teamNameCol, 'Giants')) + .orderBy(op.asc(playerAgeCol)) + .select([ + op.as('PlayerName', playerNameCol), + op.as('PlayerAge', playerAgeCol), + op.as('TeamName', op.fn.concat(teamCityCol, ' ', teamNameCol)), + op.as('PlayerGraph', playerGraphCol), + ]) + + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0].PlayerName).to.equal('Juan Leone'); + expect(output.rows[0].TeamName).to.equal('San Francisco Giants'); + expect(output.rows[0].PlayerGraph).to.equal('/optic/player/triple/test'); + expect(output.rows[2].TeamName).to.equal('San Francisco Giants'); + done(); + }, done); + }); + + it('TEST 10 - access with qualifier and no subject', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const ageCol = op.col('age'); + const idCol = op.col('id'); + const nameCol = op.col('name'); + const teamCol = op.col('team'); + const output = + op.fromTriples([ + op.pattern(null, bb('age'), ageCol) + ], 'myPlayer', null) + .orderBy(op.desc(op.viewCol('myPlayer', 'age'))) + + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(7); + expect(output.rows[0]['myPlayer.age']).to.equal(34); + expect(output.rows[6]['myPlayer.age']).to.equal(19); + done(); + }, done); + }); + + it('TEST 11 - access with iri predicate', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const ageCol = op.col('age'); + const idCol = op.col('id'); + const nameCol = op.col('name'); + const teamCol = op.col('team'); + const output = + op.fromTriples([ + op.pattern(idCol, op.sem.iri('http://marklogic.com/baseball/players/age'), ageCol) + ], 'myPlayer', null) + .orderBy(op.asc(op.viewCol('myPlayer', 'id'))) + + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(8); + expect(output.rows[0]['myPlayer.id']).to.equal('http://marklogic.com/baseball/id#001'); + expect(output.rows[0]['myPlayer.age']).to.equal(31); + expect(output.rows[7]['myPlayer.id']).to.equal('http://marklogic.com/baseball/id#008'); + expect(output.rows[7]['myPlayer.age']).to.equal(27); + done(); + }, done); + }); + + it('TEST 12 - empty results', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/foo'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerTeamCol = op.col('player_team'); + const teamIdCol = op.col('team_id'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol) + ], null, null); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ], null, null); + + const output = + player_plan.joinInner( + team_plan, + op.on(playerTeamCol, teamIdCol), + op.and(op.gt(playerAgeCol, 27), op.eq(teamNameCol, 'Giants')) + ) + .orderBy(op.asc(playerAgeCol)) + .select([ + op.as('PlayerName', playerNameCol), + op.as('PlayerAge', playerAgeCol), + op.as('TeamName', op.fn.concat(teamCityCol, ' ', teamNameCol)) + ]) + + db.rows.query(output, { format: 'xml', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + expect(output).to.equal('\n\n\n\n\n\n\n'); + done(); + }, done); + }); + + it('TEST 13 - dedup off', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const ageCol = op.col('age'); + const idCol = op.col('id'); + const nameCol = op.col('name'); + const teamCol = op.col('team'); + const output = + op.fromTriples([ + op.pattern(idCol, bb('age'), ageCol), + op.pattern(idCol, bb('name'), nameCol), + op.pattern(idCol, bb('team'), teamCol) + ], null, null, {dedup: 'off'}) + .orderBy(op.desc(ageCol)) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.be.above(8); + done(); + }, done); + }); + + it('TEST 14 - with mapper', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const tm = op.prefixer('http://marklogic.com/mlb/team/'); + const playerAgeCol = op.col('player_age'); + const playerIdCol = op.col('player_id'); + const playerNameCol = op.col('player_name'); + const playerTeamCol = op.col('player_team'); + const teamIdCol = op.col('player_team'); + const teamNameCol = op.col('team_name'); + const teamCityCol = op.col('team_city'); + const player_plan = + op.fromTriples([ + op.pattern(playerIdCol, bb('age'), playerAgeCol), + op.pattern(playerIdCol, bb('name'), playerNameCol), + op.pattern(playerIdCol, bb('team'), playerTeamCol) + ], null, null, {dedup: 'on'}); + + const team_plan = + op.fromTriples([ + op.pattern(teamIdCol, tm('name'), teamNameCol), + op.pattern(teamIdCol, tm('city'), teamCityCol) + ]); + const output = + player_plan.joinInner(team_plan) + .where(op.ne(teamNameCol, 'Giants')) + .orderBy(op.asc(playerNameCol)) + .select([ + playerAgeCol, + op.as('PlayerName', playerNameCol) + ]) + .map(op.resolveFunction('ageMapper', '/optic/test/mapperReducer.sjs')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(5); + expect(output.rows[0].player_age).to.equal('veteran'); + expect(output.rows[0].PlayerName).to.equal('Aoki Yamada'); + expect(output.rows[4].player_age).to.equal('rookie'); + expect(output.rows[4].PlayerName).to.equal('Pedro Barrozo'); + done(); + }, done); + }); + +}); diff --git a/test-complete/nodejs-optic-from-views.js b/test-complete/nodejs-optic-from-views.js new file mode 100644 index 00000000..3d40327f --- /dev/null +++ b/test-complete/nodejs-optic-from-views.js @@ -0,0 +1,1191 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const expect = require('chai').expect; +const fs = require('fs'); + +const marklogic = require('../'); + +const connectdef = require('../config-optic/connectdef.js'); + +const db = marklogic.createDatabaseClient(connectdef.plan); +const op = marklogic.planBuilder; + +describe('Nodejs Optic from views test', function(){ + var oldTimestamp = db.createTimestamp('123'); + + it('TEST 1 - join inner with keymatch - object structure, columnType rows', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .orderBy(op.asc(op.schemaCol('opticFunctionalTest', 'detail', 'id'))) + + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[0].name).to.equal('opticFunctionalTest.detail.id'); + expect(output.columns[0].type).to.not.exist; + expect(output.rows.length).to.equal(6); + expect(output.rows[0]['opticFunctionalTest.detail.id'].type).to.equal('xs:integer'); + expect(output.rows[0]['opticFunctionalTest.detail.id'].value).to.equal(1); + expect(output.rows[0]['opticFunctionalTest.master.id'].value).to.equal(1); + expect(output.rows[0]['opticFunctionalTest.detail.masterId'].value).to.equal(1); + expect(output.rows[0]['opticFunctionalTest.detail.name'].value).to.equal('Detail 1'); + expect(output.rows[0]['opticFunctionalTest.detail.name'].type).to.equal('xs:string'); + expect(output.rows[5]['opticFunctionalTest.detail.id'].value).to.equal(6); + expect(output.rows[5]['opticFunctionalTest.master.id'].value).to.equal(2); + expect(output.rows[5]['opticFunctionalTest.detail.masterId'].value).to.equal(2); + expect(output.rows[5]['opticFunctionalTest.detail.name'].value).to.equal('Detail 6'); + done(); + }, done); + }); + + it('TEST 2 - join inner with keymatch and select - array structure', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .orderBy(op.desc(op.col('DetailName'))) + + db.rows.query(output, { format: 'json', structure: 'array', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.length).to.equal(7); + expect(output[0].length).to.equal(5); + expect(output[1].length).to.equal(5); + expect(output[0][0].name).to.equal('MasterName'); + expect(output[1][0].value).to.equal('Master 2'); + expect(output[1][2].value).to.equal('Detail 6'); + expect(output[1][3].value).to.equal(60.06); + expect(output[6][0].value).to.equal('Master 1'); + expect(output[6][2].value).to.equal('Detail 1'); + expect(output[6][4].value).to.equal('blue'); + done(); + }, done); + }); + + it('TEST 3 - group by - columnTypes header', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .groupBy(op.schemaCol('opticFunctionalTest', 'master', 'name'), op.sum('DetailSum', op.schemaCol('opticFunctionalTest', 'detail', 'amount'))) + .orderBy(op.desc(op.col('DetailSum'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[0].name).to.equal('opticFunctionalTest.master.name'); + expect(output.columns[0].type).to.equal('xs:string'); + expect(output.rows.length).to.equal(2); + expect(output.rows[0]['opticFunctionalTest.master.name']).to.equal('Master 2'); + expect(output.rows[0].DetailSum).to.equal(120.12); + expect(output.rows[0].type).to.not.exist; + expect(output.rows[1]['opticFunctionalTest.master.name']).to.equal('Master 1'); + expect(output.rows[1].DetailSum).to.equal(90.09); + done(); + }, done); + }); + + it('TEST 4 - join inner with qualifier - format xml, columnTypes rows', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail') + .orderBy(op.viewCol('myDetail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master', 'myMaster') + .orderBy(op.viewCol('myMaster' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.viewCol('myMaster' , 'id'), + op.viewCol('myDetail', 'masterId') + ) + ) + .orderBy(op.viewCol('myDetail', 'id')) + db.rows.query(output, { format: 'xml', structure: 'object', columnTypes: 'rows' }) + .then(function(output) { + //console.log(output); + expect(output).to.contain('1'); + expect(output).to.contain(''); + done(); + }, done); + }); + + it('TEST 5 - join left outer with select - format xml columnTypes header', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinLeftOuter(plan2) + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .orderBy([op.desc(op.col('DetailName')), op.desc(op.col('MasterName'))]) + db.rows.query(output, { format: 'xml', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + expect(output).to.contain(''); + expect(output).to.contain('Detail 6'); + done(); + }, done); + }); + + it('TEST 6 - union with select - format csv', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.union(plan2) + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .orderBy(op.desc(op.col('DetailName'))) + db.rows.query(output, { format: 'csv', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + expect(output).to.contain('MasterName,opticFunctionalTest.master.date,DetailName,opticFunctionalTest.detail.amount,opticFunctionalTest.detail.color'); + expect(output).to.contain(',,Detail 2,20.02,blue'); + expect(output).to.contain('Master 2,2015-12-02,,,'); + done(); + }, done); + }); + + it('TEST 7 - join cross product - format csv, structure array', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinCrossProduct(plan2) + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .orderBy(op.desc(op.col('DetailName'))) + .orderBy(op.asc(op.col('MasterName'))) + db.rows.query(output, { format: 'csv', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + expect(output).to.contain('["MasterName", "opticFunctionalTest.master.date", "DetailName", "opticFunctionalTest.detail.amount", "opticFunctionalTest.detail.color"]'); + expect(output).to.contain('["Master 1", "2015-12-01", "Detail 2", 20.02, "blue"]'); + expect(output).to.contain('["Master 2", "2015-12-02", "Detail 1", 10.01, "blue"]'); + done(); + }, done); + }); + + it('TEST 8 - accessor plan - complexValues reference', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + + const idCol = plan1.col('id'); + const nameCol = plan1.col('name'); + const output = + op.fromView('opticFunctionalTest', 'detail', 'myDetail') + .where(op.gt(idCol, 3)) + .select([idCol, nameCol]) + .orderBy(op.desc(nameCol)) + + db.rows.queryAsStream(output, 'object', { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'reference' }) + .on('data', function(chunk) { + chunks.push(chunk.kind.toString()); + count++; + }). + on('end', function() { + //console.log(count); + //console.log(chunks.join('')); + expect(chunks.join(' ')).to.equal('columns row row row'); + expect(count).to.equal(4); + done(); + }, done); + }); + + it('TEST 9 - accessor plan - stream sequence, structure array, columnTypes header, complexValues inline', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + + const idCol = plan1.col('id'); + const nameCol = plan1.col('name'); + const output = + op.fromView('opticFunctionalTest', 'detail', 'myDetail') + .where(op.gt(idCol, 3)) + .select([idCol, nameCol]) + .orderBy(op.desc(nameCol)) + + db.rows.queryAsStream(output, 'sequence', { format: 'json', structure: 'array', columnTypes: 'header', complexValues: 'inline' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + expect(str).to.equal('\u001e[{"name":"myDetail.id","type":"xs:integer"},{"name":"myDetail.name","type":"xs:string"}]\u001e[6,"Detail 6"]\u001e[5,"Detail 5"]\u001e[4,"Detail 4"]'); + done(); + }, done); + }); + + it('TEST 10 - accessor plan - stream chunked, structure array, columnTypes header, complexValues inline', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + + const idCol = plan1.col('id'); + const nameCol = plan1.col('name'); + const output = + op.fromView('opticFunctionalTest', 'detail', 'myDetail') + .where(op.gt(idCol, 3)) + .select([idCol, nameCol]) + .orderBy(op.desc(nameCol)) + + db.rows.queryAsStream(output, 'chunked', { format: 'json', structure: 'object', columnTypes: 'rows', complexValues: 'inline' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + expect(str).to.equal('{ "columns": [{"name":"myDetail.id"},{"name":"myDetail.name"}], "rows":[ {"myDetail.id":{"type":"xs:integer","value":6},"myDetail.name":{"type":"xs:string","value":"Detail 6"}}, {"myDetail.id":{"type":"xs:integer","value":5},"myDetail.name":{"type":"xs:string","value":"Detail 5"}}, {"myDetail.id":{"type":"xs:integer","value":4},"myDetail.name":{"type":"xs:string","value":"Detail 4"}}] }'); + done(); + }, done); + }); + + /*it('TEST 11 - inner join with accessor plan and on', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master', 'myMaster'); + const masterIdCol1 = plan1.col('masterId'); + const masterIdCol2 = plan2.col('id'); + const detailIdCol = plan1.col('id'); + const detailNameCol = plan1.col('name'); + const masterNameCol = plan2.col('name'); + const output = + plan1.joinInner(plan2, op.on(masterIdCol1, masterIdCol2), op.ge(detailIdCol, 3)) + .select([masterIdCol2, masterNameCol, detailIdCol, detailNameCol]) + .orderBy(op.desc(detailNameCol)) + .offsetLimit(1, 100) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + console.log(JSON.stringify(output, null, 2)); + expect(output.length).to.equal(3); + expect(output[0].value['myMaster.id']).to.equal(1); + expect(output[0].value['myMaster.name']).to.equal('Master 1'); + expect(output[0].value['myDetail.id']).to.equal(5); + expect(output[0].value['myDetail.name']).to.equal('Detail 5'); + expect(output[2].value['myDetail.id']).to.equal(3); + expect(output[2].value['myDetail.name']).to.equal('Detail 3'); + done(); + }, function(error) {console.log(error); done(); }); + });*/ + + it('TEST 12 - join inner with null schema', function(done){ + const plan1 = + op.fromView(null, 'detail3'); + const plan2 = + op.fromView(null, 'master3'); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol(null, 'master3' , 'id'), + op.schemaCol(null, 'detail3', 'masterId') + ) + ) + .orderBy(op.asc(op.schemaCol(null, 'detail3', 'id'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns.length).to.equal(8); + expect(output.rows.length).to.equal(3); + expect(output.rows[0]['opticFunctionalTest3.detail3.id']).to.equal(7); + expect(output.rows[0]['opticFunctionalTest3.master3.id']).to.equal(3); + expect(output.rows[0]['opticFunctionalTest3.detail3.masterId']).to.equal(3); + expect(output.rows[0]['opticFunctionalTest3.detail3.name']).to.equal('Detail 7'); + expect(output.rows[2]['opticFunctionalTest3.detail3.id']).to.equal(11); + expect(output.rows[2]['opticFunctionalTest3.master3.id']).to.equal(3); + expect(output.rows[2]['opticFunctionalTest3.detail3.masterId']).to.equal(3); + expect(output.rows[2]['opticFunctionalTest3.detail3.name']).to.equal('Detail 11'); + done(); + }, done); + }); + + it('TEST 13 - join inner with where disctinct', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .orderBy(op.asc(op.schemaCol('opticFunctionalTest', 'detail', 'id'))) + .select(op.schemaCol('opticFunctionalTest', 'detail', 'color')) + .whereDistinct() + .orderBy(op.desc(op.schemaCol('opticFunctionalTest', 'detail', 'color'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(2); + expect(output.rows[0]['opticFunctionalTest.detail.color']).to.equal('green'); + expect(output.rows[1]['opticFunctionalTest.detail.color']).to.equal('blue'); + done(); + }, done); + }); + + it('TEST 14 - join inner with multiple group by and different column identifiers - type checking', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master'); + const amountCol = plan1.col('amount'); + const sep = ' and '; + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .orderBy(op.asc(op.schemaCol('opticFunctionalTest', 'detail', 'id'))) + .groupBy( + op.as('colorStat', op.schemaCol('opticFunctionalTest', 'detail', 'color')), [ + op.max('maxColor', op.viewCol('detail', 'amount')), + op.min('minColor', op.schemaCol('opticFunctionalTest', 'detail', 'amount')), + op.avg('avgColor', op.col('amount')), + op.sample('sampleColor', amountCol), + op.sum('sumColor', amountCol), + op.groupConcat('groupConcatColor', amountCol, {separator: sep}), + op.count('masterCount', op.schemaCol('opticFunctionalTest', 'master', 'id')) + ] + ) + .orderBy(op.desc(op.col('colorStat'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[1].type).to.equal('xs:double'); + expect(output.columns[6].type).to.equal('xs:string'); + expect(output.columns[7].type).to.equal('xs:integer'); + expect(output.rows.length).to.equal(2); + expect(output.rows[0].colorStat).to.equal('green'); + expect(output.rows[0].maxColor).to.equal(60.06); + expect(output.rows[0].minColor).to.equal(40.04); + expect(output.rows[0].avgColor).to.equal(50.05); + expect(output.rows[0].sumColor).to.equal(150.15); + expect(output.rows[0].masterCount).to.equal(3); + expect(output.rows[0].sampleColor).to.not.equal(null); + expect(output.rows[0].groupConcatColor).to.equal('40.04 and 50.05 and 60.06'); + expect(output.rows[1].colorStat).to.equal('blue'); + expect(output.rows[1].maxColor).to.equal(30.03); + expect(output.rows[1].minColor).to.equal(10.01); + expect(output.rows[1].avgColor).to.equal(20.02); + expect(output.rows[1].sumColor).to.equal(60.06); + expect(output.rows[1].masterCount).to.equal(3); + expect(output.rows[1].groupConcatColor).to.equal('10.01 and 20.02 and 30.03'); + done(); + }, done); + }); + + it('TEST 15 - select with qualifier', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master'); + const amountCol = plan1.col('amount'); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .select([op.schemaCol('opticFunctionalTest', 'detail', 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'color'), + op.schemaCol('opticFunctionalTest', 'master', 'name')], + 'newRow') + .orderBy('id') + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[0].name).to.equal('newRow.id'); + expect(output.rows.length).to.equal(6); + expect(output.rows[0]['newRow.id']).to.equal(1); + expect(output.rows[0]['newRow.color']).to.equal('blue'); + expect(output.rows[0]['newRow.name']).to.equal('Master 1'); + expect(output.rows[5]['newRow.id']).to.equal(6); + expect(output.rows[5]['newRow.color']).to.equal('green'); + expect(output.rows[5]['newRow.name']).to.equal('Master 2'); + done(); + }, done); + }); + + it('TEST 16 - arithmetic operations', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .select([ + op.as('added', op.add(op.col('amount'), op.viewCol('detail', 'masterId'))), + op.as('substracted', op.subtract(op.col('amount'), op.viewCol('master', 'id'))), + op.as('modulo', op.modulo(op.col('amount'), op.viewCol('master', 'id'))), + op.as('invSubstract', op.subtract(op.col('amount'), op.viewCol('master', 'date'))), + op.as('divided', op.divide(op.col('amount'), op.multiply(op.col('amount'), op.viewCol('detail', 'id')))) + ]) + .orderBy(op.asc('substracted')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[3].type).to.equal('null'); + expect(output.rows.length).to.equal(6); + expect(output.rows[0].added).to.equal(11.01); + expect(output.rows[0].substracted).to.equal(9.01); + expect(output.rows[0].modulo).to.equal(0.00999999999999979); + expect(output.rows[0].invSubstract).to.equal(null); + expect(output.rows[0].divided).to.equal(1); + expect(output.rows[5].added).to.equal(62.06); + expect(output.rows[5].substracted).to.equal(58.06); + expect(output.rows[5].modulo).to.equal(0.0600000000000023); + expect(output.rows[5].invSubstract).to.equal(null); + expect(output.rows[5].divided).to.equal(0.166666666666667); + done(); + }, done); + }); + + it('TEST 17 - with value processing function on where', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const numbers = [10, 40, 50, 30, 60, 0, 100]; + const output = + plan1.joinInner(plan2) + .where( + op.gt( + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), op.math.median(numbers) + ) + ) + .select(op.as('myAmount', op.viewCol('detail', 'amount'))) + .whereDistinct() + .orderBy(op.asc('myAmount')) + db.rows.query(output, { format: 'xml', structure: 'array', columnTypes: 'rows', complexValues: 'reference' }) + .then(function(output) { + const outputStr = output.toString().trim().replace(/[\n\r]/g, ''); + expect(outputStr).to.equal('<\/t:columns>40.04<\/t:cell><\/t:row>50.05<\/t:cell><\/t:row>60.06<\/t:cell><\/t:row><\/t:table>'); + done(); + }, done); + }); + + it('TEST 18 - union with arrayAggregate - without row options', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.union(plan2) + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .groupBy('MasterName', op.arrayAggregate('arrayDetail', 'DetailName')) + .orderBy(op.desc(op.col('MasterName'))) + db.rows.query(output) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0].MasterName.value).to.equal('Master 2'); + expect(output.rows[0].MasterName.type).to.equal('xs:string'); + expect(output.rows[0].arrayDetail.value.length).to.equal(0); + expect(output.rows[1].MasterName.value).to.equal('Master 1'); + expect(output.rows[1].arrayDetail.value.length).to.equal(0); + expect(output.rows[2].MasterName.value).to.equal(null); + expect(output.rows[2].arrayDetail.value.length).to.equal(6); + expect(output.rows[2].arrayDetail.value[0]).to.equal('Detail 1'); + done(); + }, done); + }); + + it('TEST 19 - intersect on different schemas', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'master'); + const plan2 = + op.fromView('opticFunctionalTest2', 'master'); + const plan3 = + op.fromView('opticFunctionalTest', 'detail'); + const output = + plan1.select(op.as('unionId', op.schemaCol('opticFunctionalTest', 'master', 'id'))) + .union(plan2.select(op.as('unionId', op.schemaCol('opticFunctionalTest2', 'master', 'id')))) + .intersect( + plan3 + .select(op.as('unionId', op.schemaCol('opticFunctionalTest', 'detail', 'id'))) + ) + .orderBy('unionId') + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'inline' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(4); + expect(output.rows[0].unionId).to.equal(1); + expect(output.rows[1].unionId).to.equal(2); + expect(output.rows[2].unionId).to.equal(3); + expect(output.rows[3].unionId).to.equal(4); + done(); + }, done); + }); + + it('TEST 20 - except on different schemas', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'master'); + const plan2 = + op.fromView('opticFunctionalTest2', 'master'); + const plan3 = + op.fromView('opticFunctionalTest2', 'detail'); + const output = + plan3 + .select(op.as('unionId', op.schemaCol('opticFunctionalTest2', 'detail', 'id'))) + .except( + plan1.select(op.as('unionId', op.schemaCol('opticFunctionalTest', 'master', 'id'))) + .union(plan2.select(op.as('unionId', op.schemaCol('opticFunctionalTest2', 'master', 'id')))) + ) + .orderBy('unionId') + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'inline' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(6); + expect(output.rows[0].unionId).to.equal(7); + expect(output.rows[1].unionId).to.equal(8); + expect(output.rows[2].unionId).to.equal(9); + expect(output.rows[3].unionId).to.equal(10); + expect(output.rows[5].unionId).to.equal(12); + done(); + }, done); + }); + + it('TEST 21 - using explain - format json', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .orderBy(op.desc(op.col('DetailName'))) + db.rows.explain(output, 'json') + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.node).to.equal('plan'); + expect(output.expr.expr.columns[0].name).to.equal('MasterName'); + done(); + }, done); + }); + + it('TEST 22 - using explain - format xml', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .orderBy(op.desc(op.col('DetailName'))) + db.rows.explain(output, 'xml') + .then(function(output) { + //console.log(output); + expect(output).to.contain(''); + expect(output).to.contain('Master 1'); + expect(output.rows[1]['opticFunctionalTest2.detail.id']).to.equal(10); + expect(output.rows[1]['opticFunctionalTest.master.id']).to.equal(2); + expect(output.rows[1].doc).to.contain('Detail 4'); + expect(output.rows[2]['opticFunctionalTest2.detail.id']).to.equal(12); + expect(output.rows[2]['opticFunctionalTest.master.id']).to.equal(1); + expect(output.rows[2].doc).to.contain('Detail 6'); + done(); + }, done); + }); + + it('TEST 26 - as with conditional on null', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.as('MyAmount', op.sem.if(op.gt(op.schemaCol('opticFunctionalTest', 'detail', 'amount'), 40), 'Y', null)), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .orderBy(op.desc(op.col('DetailName'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'inline' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(6); + expect(output.rows[0].MasterName).to.equal('Master 2'); + expect(output.rows[0].DetailName).to.equal('Detail 6'); + expect(output.rows[0].MyAmount).to.equal('Y'); + expect(output.rows[5].MasterName).to.equal('Master 1'); + expect(output.rows[5].DetailName).to.equal('Detail 1'); + expect(output.rows[5].MyAmount).to.equal(null); + expect(output.rows[5]['opticFunctionalTest.detail.color']).to.equal('blue'); + done(); + }, done); + }); + + it('TEST 27 - with sql condition', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.sqlCondition('opticFunctionalTest.master.id = opticFunctionalTest.detail.masterId') + ) + .select([ + op.as('MasterName', op.schemaCol('opticFunctionalTest', 'master', 'name')), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol('opticFunctionalTest', 'detail', 'amount'), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]) + .orderBy(op.desc(op.col('DetailName'))) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'inline' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(6); + expect(output.rows[0].MasterName).to.equal('Master 2'); + expect(output.rows[0].DetailName).to.equal('Detail 6'); + expect(output.rows[0]['opticFunctionalTest.detail.amount']).to.equal(60.06); + expect(output.rows[5].MasterName).to.equal('Master 1'); + expect(output.rows[5].DetailName).to.equal('Detail 1'); + expect(output.rows[5]['opticFunctionalTest.detail.color']).to.equal('blue'); + done(); + }, done); + }); + + it('TEST 28 - sql condition on qualifiers', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail') + .orderBy(op.viewCol('myDetail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master', 'myMaster') + .orderBy(op.viewCol('myMaster' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.sqlCondition('myMaster.id = myDetail.masterId') + ) + .orderBy(op.viewCol('myDetail', 'id')) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'inline' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(6); + expect(output.rows[0]['myDetail.id']).to.equal(1); + expect(output.rows[0]['myMaster.id']).to.equal(1); + expect(output.rows[0]['myDetail.masterId']).to.equal(1); + expect(output.rows[0]['myDetail.name']).to.equal('Detail 1'); + expect(output.rows[5]['myDetail.id']).to.equal(6); + expect(output.rows[5]['myMaster.id']).to.equal(2); + expect(output.rows[5]['myDetail.masterId']).to.equal(2); + expect(output.rows[5]['myDetail.name']).to.equal('Detail 6'); + done(); + }, done); + }); + + it('TEST 29 - sql condition with AND operator', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + + const idCol = plan1.col('id'); + const nameCol = plan1.col('name'); + const output = + op.fromView('opticFunctionalTest', 'detail', 'myDetail') + .where(op.sqlCondition("myDetail.id <> 3 AND myDetail.name != 'Detail 4'")) + .select([idCol, nameCol]) + .orderBy(op.desc(nameCol)) + + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'inline' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(4); + expect(output.rows[0]['myDetail.id']).to.equal(6); + expect(output.rows[0]['myDetail.name']).to.equal('Detail 6'); + expect(output.rows[2]['myDetail.id']).to.equal(2); + expect(output.rows[2]['myDetail.name']).to.equal('Detail 2'); + done(); + }, done); + }); + + it('TEST 32 - offsetLimit, params and bindings', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master', 'myMaster'); + const output = + plan1.joinInner(plan2, op.on(op.viewCol('myDetail', 'masterId'), op.viewCol('myMaster', 'id')), op.ge(op.viewCol('myDetail', 'id'), op.param({name: 'detailIdVal'}))) + .select([op.viewCol('myMaster', 'id'), op.viewCol('myMaster', 'name'), op.viewCol('myDetail', 'id'), op.viewCol('myDetail', 'name')]) + .orderBy(op.desc(op.viewCol('myDetail', 'name'))) + .offsetLimit(op.param({name: 'start'}), op.param({name: 'length'})) + db.rows.query(output, { + format: 'json', + structure: 'object', + columnTypes: 'header', + complexValues: 'inline', + bindings: { + 'detailIdVal': {value: 3, type: 'integer'}, + 'start': {value: 1, type: 'integer'}, + 'length': {value: 100, type: 'integer'} + } + }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0]['myMaster.id']).to.equal(1); + expect(output.rows[0]['myMaster.name']).to.equal('Master 1'); + expect(output.rows[0]['myDetail.id']).to.equal(5); + expect(output.rows[0]['myDetail.name']).to.equal('Detail 5'); + expect(output.rows[2]['myDetail.id']).to.equal(3); + expect(output.rows[2]['myDetail.name']).to.equal('Detail 3'); + done(); + }, done); + }); + + it('TEST 33 - inner join with accessor plan', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master', 'myMaster'); + const masterIdCol1 = plan1.col('masterId'); + const masterIdCol2 = plan2.col('id'); + const detailIdCol = plan1.col('id'); + const detailNameCol = plan1.col('name'); + const masterNameCol = plan2.col('name'); + const output = + plan1.joinInner(plan2) + .where(op.eq(masterIdCol1, masterIdCol2)) + .select([masterIdCol2, masterNameCol, detailIdCol, detailNameCol]) + .orderBy(op.desc(detailNameCol)) + .offsetLimit(1, 3) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header'}) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0]['myMaster.id']).to.equal(1); + expect(output.rows[0]['myMaster.name']).to.equal('Master 1'); + expect(output.rows[0]['myDetail.id']).to.equal(5); + expect(output.rows[0]['myDetail.name']).to.equal('Detail 5'); + expect(output.rows[2]['myDetail.id']).to.equal(3); + expect(output.rows[2]['myDetail.name']).to.equal('Detail 3'); + done(); + }, done); + }); + + it('TEST 34 - negative case', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + + const idCol = plan1.col('id'); + const nameCol = plan1.col('name'); + const output = + op.fromView('opticFunctionalTest', 'invalidFoo', 'myDetail') + .where(op.gt(idCol, 3)) + .select([idCol, nameCol]) + .orderBy(op.desc(nameCol)) + + db.rows.queryAsStream(output, 'object', { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'reference' }) + .on('data', function(chunk) { + chunks.push(chunk.kind.toString()); + count++; + }). + on('error', function(error) { + //console.log(JSON.stringify(error, null, 2)); + expect(error.body.errorResponse.message).to.contain('Unknown table: Table \'opticFunctionalTest.invalidFoo\' not found'); + }). + on('end', function() { + expect(chunks).to.be.empty; + done(); + }, done); + }); + + it('TEST 35 - with named parameters', function(done){ + const plan1 = + op.fromView({schema: 'opticFunctionalTest', view: 'detail'}) + .orderBy({keys: op.schemaCol({schema: 'opticFunctionalTest', view: 'detail', column: 'id'})}); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner({right: plan2}) + .where({condition: + op.eq({ + left: op.schemaCol({schema: 'opticFunctionalTest', view: 'master' , column: 'id'}), + right: op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + }) + }) + .select({columns: [ + op.as({column: 'MasterName', expression: op.schemaCol({schema: 'opticFunctionalTest', view: 'master', column: 'name'})}), + op.schemaCol('opticFunctionalTest', 'master', 'date'), + op.as('DetailName', op.schemaCol('opticFunctionalTest', 'detail', 'name')), + op.schemaCol({schema: 'opticFunctionalTest', view: 'detail', column: 'amount'}), + op.schemaCol('opticFunctionalTest', 'detail', 'color') + ]}) + .orderBy({keys: [op.desc({column: op.col({column: 'DetailName'})})]}) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[1].type).to.equal('xs:date'); + expect(output.rows.length).to.equal(6); + expect(output.rows[0].MasterName).to.equal('Master 2'); + expect(output.rows[0].DetailName).to.equal('Detail 6'); + expect(output.rows[5].MasterName).to.equal('Master 1'); + expect(output.rows[5].DetailName).to.equal('Detail 1'); + done(); + }, done); + }); + + it('TEST 36 - with named parameters multiple on', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master', 'myMaster'); + const masterIdCol1 = plan1.col({column: 'masterId'}); + const masterIdCol2 = plan2.col('id'); + const idCol1 = plan2.col('id'); + const idCol2 = plan1.col({column: 'id'}); + const detailNameCol = plan1.col({column: 'name'}); + const masterNameCol = plan2.col('name'); + const output = + plan1.joinInner({ + right: plan2, + keys: [op.on(masterIdCol1, masterIdCol2), op.on(idCol1, idCol2)] + }) + .orderBy({keys: [op.desc({column: detailNameCol})]}) + .offsetLimit({start: 1, length: 100}) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myMaster.id']).to.equal(1); + expect(output.rows[0]['myMaster.name']).to.equal('Master 1'); + expect(output.rows[0]['myDetail.id']).to.equal(1); + expect(output.rows[0]['myDetail.name']).to.equal('Detail 1'); + expect(output.rows[0]['myDetail.masterId']).to.equal(1); + done(); + }, done); + }); + + it('TEST 37 - with timestamp', function(done){ + const timestamp = db.createTimestamp(); + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master', 'myMaster'); + const masterIdCol1 = plan1.col({column: 'masterId'}); + const masterIdCol2 = plan2.col('id'); + const idCol1 = plan2.col('id'); + const idCol2 = plan1.col({column: 'id'}); + const detailNameCol = plan1.col({column: 'name'}); + const masterNameCol = plan2.col('name'); + const output = + plan1.joinInner({ + right: plan2, + keys: [op.on(masterIdCol1, masterIdCol2), op.on(idCol1, idCol2)] + }) + .orderBy({keys: [op.desc({column: detailNameCol})]}) + .offsetLimit({start: 1, length: 100}) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header', timestamp: timestamp }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myMaster.id']).to.equal(1); + expect(output.rows[0]['myMaster.name']).to.equal('Master 1'); + expect(output.rows[0]['myDetail.id']).to.equal(1); + expect(output.rows[0]['myDetail.name']).to.equal('Detail 1'); + expect(output.rows[0]['myDetail.masterId']).to.equal(1); + done(); + }, done); + }); + + it('TEST 38 - with old timestamp', function(done){ + const timestamp = db.createTimestamp(); + const plan1 = + op.fromView('opticFunctionalTest', 'detail', 'myDetail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master', 'myMaster'); + const masterIdCol1 = plan1.col({column: 'masterId'}); + const masterIdCol2 = plan2.col('id'); + const idCol1 = plan2.col('id'); + const idCol2 = plan1.col({column: 'id'}); + const detailNameCol = plan1.col({column: 'name'}); + const masterNameCol = plan2.col('name'); + const output = + plan1.joinInner({ + right: plan2, + keys: [op.on(masterIdCol1, masterIdCol2), op.on(idCol1, idCol2)] + }) + .orderBy({keys: [op.desc({column: detailNameCol})]}) + .offsetLimit({start: 1, length: 100}) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header', timestamp: oldTimestamp }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output).to.be.undefined; + done(); + }, function(error) { + //console.log(error); + expect(error.body.errorResponse.message).to.contain('XDMP-OLDSTAMP: Timestamp too old'); + done(); + }); + }); +}); diff --git a/test-complete/nodejs-optic-nodes.js b/test-complete/nodejs-optic-nodes.js new file mode 100644 index 00000000..f9fd0390 --- /dev/null +++ b/test-complete/nodejs-optic-nodes.js @@ -0,0 +1,577 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const expect = require('chai').expect; + + +const fs = require('fs'); + +const marklogic = require('../'); + +const connectdef = require('../config-optic/connectdef.js'); + +const db = marklogic.createDatabaseClient(connectdef.plan); +const op = marklogic.planBuilder; + +describe('Nodejs Optic nodes json constructor test', function(){ + + it('TEST 1 - construct json from literals', function(done){ + const plan1 = + op.fromLiterals([ + {rowId: 1, colorId: 1, desc: 'ball'}, + {rowId: 2, colorId: 2, desc: 'square'}, + {rowId: 3, colorId: 1, desc: 'box'}, + {rowId: 4, colorId: 1, desc: 'hoop'}, + {rowId: 5, colorId: 5, desc: 'circle'} + ], 'myItem'); + const plan2 = + op.fromLiterals([ + {colorId: 1, colorDesc: 'red'}, + {colorId: 2, colorDesc: 'blue'}, + {colorId: 3, colorDesc: 'black'}, + {colorId: 4, colorDesc: 'yellow'} + ], 'myColor'); + + const output = + plan1.joinInner(plan2, op.on(op.viewCol('myItem', 'colorId'), op.viewCol('myColor', 'colorId'))) + .select([ + 'rowId', + op.as('myJSON', op.jsonDocument(op.jsonObject([ + op.prop('str', op.jsonString(op.col('desc'))), + op.prop('strFunc', op.jsonString(op.fn.stringToCodepoints(op.col('desc')))), + op.prop('mathFunc', op.jsonNumber(op.math.sqrt(op.col('rowId')))), + op.prop('upper', op.jsonString(op.fn.upperCase(op.viewCol('myItem', 'desc')))), + op.prop('num', op.jsonNumber(op.col('rowId'))), + op.prop('bool', op.jsonBoolean(op.isDefined(op.col('rowId')))), + op.prop('null', op.jsonNull()), + op.prop('array', op.jsonArray([op.jsonString(op.col('desc')), op.jsonNumber(op.col('rowId'))])) + ]))), + op.as('node', op.jsonString(op.col('desc'))), + op.as('kind', op.xdmp.nodeKind(op.col('node'))), + op.as('xml', + op.xmlDocument( + op.xmlElement( + 'root', + op.xmlAttribute('attrA', op.col('rowId')), + [ + op.xmlElement('elemA', null, op.viewCol('myColor', 'colorDesc')), + op.xmlComment(op.fn.concat('this is a comment for ', op.col('desc'))), + op.xmlElement('elemB', null, op.col('desc')) + ] + ) + ) + ) + ]) + .orderBy('rowId') + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.columns[1].name).to.equal('myJSON'); + expect(output.columns[1].type).to.equal('object'); + expect(output.columns[2].name).to.equal('node'); + expect(output.columns[2].type).to.equal('text'); + expect(output.columns[4].name).to.equal('xml'); + expect(output.columns[4].type).to.equal('element'); + expect(output.rows.length).to.equal(4); + expect(output.rows[0]['myItem.rowId']).to.equal(1); + expect(output.rows[0].myJSON.str).to.equal('ball'); + expect(output.rows[0].myJSON.upper).to.equal('BALL'); + expect(output.rows[0].myJSON.num).to.equal(1); + expect(output.rows[0].myJSON.bool).to.equal(true); + expect(output.rows[0].myJSON.null).to.equal(null); + expect(output.rows[0].myJSON.array.length).to.equal(2); + expect(output.rows[0].myJSON.array[0]).to.equal('ball'); + expect(output.rows[0].kind).to.equal('text'); + expect(output.rows[1].myJSON.strFunc).to.equal('115 113 117 97 114 101'); + expect(output.rows[1].myJSON.mathFunc).to.equal(1.4142135623731); + expect(output.rows[0].xml).to.equal('redball'); + expect(output.rows[3]['myItem.rowId']).to.equal(4); + expect(output.rows[3].xml).to.equal('redhoop'); + done(); + }, done); + }); + + it('TEST 2 - construct json from views', function(done){ + const plan1 = + op.fromView('opticFunctionalTest2', 'detail') + .orderBy(op.schemaCol('opticFunctionalTest2', 'detail', 'id')); + const plan2 = + op.fromView('opticFunctionalTest', 'master') + .orderBy(op.schemaCol('opticFunctionalTest', 'master' , 'id')); + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest2', 'detail', 'masterId') + ) + ) + .orderBy(op.asc(op.schemaCol('opticFunctionalTest2', 'detail', 'id'))) + .select([ + op.as('myJSON', + op.jsonDocument( + op.jsonObject([ + op.prop('object1', + op.jsonObject([ + op.prop('object2', op.jsonString(op.schemaCol('opticFunctionalTest2', 'detail', 'masterId'))), + op.prop('object3', op.jsonNumber(op.schemaCol('opticFunctionalTest', 'master', 'id'))) + ]) + ), + op.prop('object4', + op.jsonObject( + op.prop('object5', + op.jsonObject([ + op.prop('object6', op.jsonNumber(op.schemaCol('opticFunctionalTest2', 'detail', 'id'))), + op.prop('array1', op.jsonArray([ + op.jsonString(op.schemaCol('opticFunctionalTest2', 'detail', 'name')), + op.jsonString(op.schemaCol('opticFunctionalTest', 'master', 'date')), + op.jsonNumber(op.schemaCol('opticFunctionalTest2', 'detail', 'amount')), + op.jsonBoolean(op.isDefined(op.schemaCol('opticFunctionalTest2', 'detail', 'amount'))), + op.jsonObject(op.prop('object7', op.jsonObject(op.prop('object8', op.jsonString(op.schemaCol('opticFunctionalTest2', 'detail', 'color')))))) + ])) + ]) + ) + ) + ) + ]) + ) + ) + ]) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(3); + expect(output.rows[0].myJSON.value.object1.object2).to.equal('1'); + expect(output.rows[0].myJSON.type).to.equal('object'); + expect(output.rows[0].myJSON.value.object1.object3).to.equal(1); + expect(output.rows[0].myJSON.value.object4.object5.object6).to.equal(9); + expect(output.rows[0].myJSON.value.object4.object5.array1[2]).to.equal(72.9); + expect(output.rows[0].myJSON.value.object4.object5.array1[4].object7.object8).to.equal('yellow'); + done(); + }, done); + }); + + it('TEST 3 - construct xml from Triples', function(done){ + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const ageCol = op.col('age'); + const idCol = op.col('id'); + const nameCol = op.col('name'); + const posCol = op.col('position'); + const output = + op.fromTriples([ + op.pattern(idCol, bb('age'), ageCol), + op.pattern(idCol, bb('name'), nameCol), + op.pattern(idCol, bb('position'), posCol) + ]) + .where( + op.and( + op.le(ageCol, 25), + op.eq(posCol, 'Catcher') + ) + ) + .orderBy(op.desc(ageCol)) + .select([ + op.as('PlayerName', nameCol), + op.as('PlayerPosition', posCol), + op.as('PlayerAge', ageCol) + ]) + .select([ + 'PlayerName', + 'PlayerPosition', + 'PlayerAge', + op.as('xml', + op.xmlDocument( + op.xmlElement( + 'root', + op.xmlAttribute('attrA', op.col('PlayerName')), + [ + op.xmlElement('elemA', null, op.col('PlayerPosition')), + op.xmlElement('elemACodePoints', null, op.fn.stringToCodepoints(op.col('PlayerPosition'))), + op.xmlElement('elemB', null, op.col('PlayerAge')), + op.xmlElement('elemC', null, op.math.sqrt(op.col('PlayerAge'))) + ] + ) + ) + ) + ]) + db.rows.query(output, { format: 'xml', structure: 'object', columnTypes: 'rows' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + //console.log(output); + const outputStr = output.toString().trim().replace(/[\n\r]/g, ''); + //console.log(outputStr); + expect(outputStr).to.equal('Pat CrenshawCatcher25Catcher67 97 116 99 104 101 114255'); + done(); + }, done); + }); + + it('TEST 4 - construct json from lexicons', function(done){ + const plan1 = + op.fromLexicons( + { + uri1: op.cts.uriReference(), + city: op.cts.jsonPropertyReference('city'), + popularity: op.cts.jsonPropertyReference('popularity'), + date: op.cts.jsonPropertyReference('date'), + distance: op.cts.jsonPropertyReference('distance'), + point: op.cts.jsonPropertyReference('latLonPoint') + }, 'myCity' + ); + const plan2 = + op.fromLexicons( + { + uri2: op.cts.uriReference(), + cityName: op.cts.jsonPropertyReference('cityName'), + cityTeam: op.cts.jsonPropertyReference('cityTeam') + }, 'myTeam' + ); + const output = + plan1.joinInner(plan2, + op.on(op.viewCol('myCity', 'city'), op.viewCol('myTeam', 'cityName')), + op.ne(op.col('popularity'), 3) + ) + .joinDoc(op.col('doc'), op.col('uri1')) + .orderBy('uri1') + .select([ + op.as('myJSON1', op.jsonDocument(op.jsonObject(op.prop('object1', op.viewCol('myCity', 'uri1'))))), + op.as('myJSON2', op.jsonDocument(op.jsonObject([ + op.prop('object2', op.viewCol('myTeam', 'cityTeam')), + op.prop('object3', op.col('cityName')) + ]))), + op.as('myJSON3', op.jsonDocument(op.jsonObject(op.prop('object4', op.jsonNumber(op.fn.number(op.xpath('doc', '//latLonPair/lat'))))))), + op.as('myJSON4', op.jsonDocument(op.jsonObject(op.prop('array1', op.jsonArray([ + op.jsonString(op.col('uri2')), op.col('popularity'), op.jsonArray([op.col('date'), op.jsonNumber(op.col('distance'))]) + ]))))) + ]) + db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(4); + expect(output.rows[0].myJSON1.object1).to.equal('/optic/lexicon/test/doc1.json'); + expect(output.rows[0].myJSON2.object2).to.equal('arsenal'); + expect(output.rows[0].myJSON2.object3).to.equal('london'); + expect(output.rows[0].myJSON3.object4).to.equal(51.5); + expect(output.rows[0].myJSON4.array1[2][0]).to.equal('2007-01-01'); + done(); + }, done); + }); + + it('TEST 5 - construct json from aggregates - xml format', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master'); + const amountCol = plan1.col('amount'); + const sep = ' and '; + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .orderBy(op.asc(op.schemaCol('opticFunctionalTest', 'detail', 'id'))) + .groupBy( + op.as('colorStat', op.schemaCol('opticFunctionalTest', 'detail', 'color')), [ + op.max('maxColor', op.viewCol('detail', 'amount')), + op.min('minColor', op.schemaCol('opticFunctionalTest', 'detail', 'amount')), + op.avg('avgColor', op.col('amount')), + op.sample('sampleColor', amountCol), + op.sum('sumColor', amountCol), + op.groupConcat('groupConcatColor', amountCol, {separator: sep}), + op.count('masterCount', op.schemaCol('opticFunctionalTest', 'master', 'id')) + ] + ) + .orderBy(op.desc(op.col('colorStat'))) + .select([ + op.as('myJSON1', op.jsonDocument(op.jsonObject(op.prop('object1', op.col('maxColor'))))), + op.as('myJSON2', op.jsonDocument(op.jsonObject(op.prop('array1', op.jsonArray([ + op.col('minColor'), + op.jsonString(op.col('avgColor')), + op.col('sumColor') + ]))))), + op.as('myJSON3', op.jsonDocument(op.jsonObject(op.prop('object2', op.jsonObject(op.prop('object3', op.jsonNumber(op.col('masterCount')))))))), + op.as('myJSON4', op.jsonDocument(op.jsonObject(op.prop('array2', op.jsonArray([ + op.jsonObject(op.prop('object4', op.jsonString(op.col('groupConcatColor')))), + op.jsonObject(op.prop('object5', op.col('minColor'))) + ]))))) + ]) + db.rows.query(output, { format: 'xml', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + const outputStr = output.toString().trim().replace(/[\n\r]/g, ''); + //console.log(outputStr); + expect(outputStr).to.equal('{"object1":60.06}{"array1":[40.04, "50.05", 150.15]}{"object2":{"object3":3}}{"array2":[{"object4":"40.04 and 50.05 and 60.06"}, {"object5":40.04}]}{"object1":30.03}{"array1":[10.01, "20.02", 60.06]}{"object2":{"object3":3}}{"array2":[{"object4":"10.01 and 20.02 and 30.03"}, {"object5":10.01}]}'); + done(); + }, done); + }); + + it('TEST 6 - construct json from aggregates - csv format', function(done){ + const plan1 = + op.fromView('opticFunctionalTest', 'detail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master'); + const amountCol = plan1.col('amount'); + const sep = ' and '; + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .orderBy(op.asc(op.schemaCol('opticFunctionalTest', 'detail', 'id'))) + .groupBy( + op.as('colorStat', op.schemaCol('opticFunctionalTest', 'detail', 'color')), [ + op.max('maxColor', op.viewCol('detail', 'amount')), + op.min('minColor', op.schemaCol('opticFunctionalTest', 'detail', 'amount')), + op.avg('avgColor', op.col('amount')), + op.sample('sampleColor', amountCol), + op.sum('sumColor', amountCol), + op.groupConcat('groupConcatColor', amountCol, {separator: sep}), + op.count('masterCount', op.schemaCol('opticFunctionalTest', 'master', 'id')) + ] + ) + .orderBy(op.desc(op.col('colorStat'))) + .select([ + op.as('myJSON1', op.jsonDocument(op.jsonObject(op.prop('object1', op.col('maxColor'))))), + op.as('myJSON2', op.jsonDocument(op.jsonObject(op.prop('array1', op.jsonArray([ + op.col('minColor'), + op.jsonString(op.col('avgColor')), + op.col('sumColor') + ]))))), + op.as('myJSON3', op.jsonDocument(op.jsonObject(op.prop('object2', op.jsonObject(op.prop('object3', op.jsonNumber(op.col('masterCount')))))))), + op.as('myJSON4', op.jsonDocument(op.jsonObject(op.prop('array2', op.jsonArray([ + op.jsonObject(op.prop('object4', op.jsonString(op.col('groupConcatColor')))), + op.jsonObject(op.prop('object5', op.col('minColor'))) + ]))))) + ]) + db.rows.query(output, { format: 'csv', structure: 'array', columnTypes: 'header' }) + .then(function(output) { + //console.log(output); + expect(output).to.contain('["myJSON1", "myJSON2", "myJSON3", "myJSON4"]'); + expect(output).to.contain('[{"object1":60.06}, {"array1":[40.04, "50.05", 150.15]}, {"object2":{"object3":3}}, {"array2":[{"object4":"40.04 and 50.05 and 60.06"}, {"object5":40.04}]}]'); + expect(output).to.contain('[{"object1":30.03}, {"array1":[10.01, "20.02", 60.06]}, {"object2":{"object3":3}}, {"array2":[{"object4":"10.01 and 20.02 and 30.03"}, {"object5":10.01}]}]'); + done(); + }, done); + }); + + it('TEST 7 - queryAsStream chunked', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const plan1 = + op.fromView('opticFunctionalTest', 'detail'); + const plan2 = + op.fromView('opticFunctionalTest', 'master'); + const amountCol = plan1.col('amount'); + const sep = ' and '; + const output = + plan1.joinInner(plan2) + .where( + op.eq( + op.schemaCol('opticFunctionalTest', 'master' , 'id'), + op.schemaCol('opticFunctionalTest', 'detail', 'masterId') + ) + ) + .orderBy(op.asc(op.schemaCol('opticFunctionalTest', 'detail', 'id'))) + .groupBy( + op.as('colorStat', op.schemaCol('opticFunctionalTest', 'detail', 'color')), [ + op.max('maxColor', op.viewCol('detail', 'amount')), + op.min('minColor', op.schemaCol('opticFunctionalTest', 'detail', 'amount')), + op.avg('avgColor', op.col('amount')), + op.sample('sampleColor', amountCol), + op.sum('sumColor', amountCol), + op.groupConcat('groupConcatColor', amountCol, {separator: sep}), + op.count('masterCount', op.schemaCol('opticFunctionalTest', 'master', 'id')) + ] + ) + .orderBy(op.desc(op.col('colorStat'))) + .select([ + op.as('myJSON1', op.jsonDocument(op.jsonObject(op.prop('object1', op.col('maxColor'))))), + op.as('myJSON2', op.jsonDocument(op.jsonObject(op.prop('array1', op.jsonArray([ + op.col('minColor'), + op.jsonString(op.col('avgColor')), + op.col('sumColor') + ]))))), + op.as('myJSON3', op.jsonDocument(op.jsonObject(op.prop('object2', op.jsonObject(op.prop('object3', op.jsonNumber(op.col('masterCount')))))))), + op.as('myJSON4', op.jsonDocument(op.jsonObject(op.prop('array2', op.jsonArray([ + op.jsonObject(op.prop('object4', op.jsonString(op.col('groupConcatColor')))), + op.jsonObject(op.prop('object5', op.col('minColor'))) + ]))))) + ]) + db.rows.queryAsStream(output, 'chunked', { format: 'json', structure: 'object', columnTypes: 'header' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + //console.log(count); + expect(str).to.equal('{ "columns": [{"name":"myJSON1","type":"object"},{"name":"myJSON2","type":"object"},{"name":"myJSON3","type":"object"},{"name":"myJSON4","type":"object"}], "rows":[ {"myJSON1":{"object1":60.06},"myJSON2":{"array1":[40.04, "50.05", 150.15]},"myJSON3":{"object2":{"object3":3}},"myJSON4":{"array2":[{"object4":"40.04 and 50.05 and 60.06"}, {"object5":40.04}]}}, {"myJSON1":{"object1":30.03},"myJSON2":{"array1":[10.01, "20.02", 60.06]},"myJSON3":{"object2":{"object3":3}},"myJSON4":{"array2":[{"object4":"10.01 and 20.02 and 30.03"}, {"object5":10.01}]}}] }'); + expect(count).to.equal(1); + done(); + }, done); + }); + + it('TEST 8 - construct complex node with queryAsStream and complexValues reference', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const bb = op.prefixer('http://marklogic.com/baseball/players/'); + const ageCol = op.col('age'); + const idCol = op.col('id'); + const nameCol = op.col('name'); + const posCol = op.col('position'); + const output = + op.fromTriples([ + op.pattern(idCol, bb('age'), ageCol), + op.pattern(idCol, bb('name'), nameCol), + op.pattern(idCol, bb('position'), posCol) + ]) + .where( + op.and( + op.le(ageCol, 25), + op.eq(posCol, 'Catcher') + ) + ) + .orderBy(op.desc(ageCol)) + .select([ + op.as('PlayerName', nameCol), + op.as('PlayerPosition', posCol), + op.as('PlayerAge', ageCol) + ]) + .select([ + 'PlayerName', + 'PlayerPosition', + 'PlayerAge', + op.as('xml', + op.xmlDocument( + op.xmlElement( + 'root', + op.xmlAttribute('attrA', op.col('PlayerName')), + [ + op.xmlElement('elemA', null, op.col('PlayerPosition')), + op.xmlElement('elemACodePoints', null, op.fn.stringToCodepoints(op.col('PlayerPosition'))), + op.xmlElement('elemB', null, op.col('PlayerAge')), + op.xmlElement('elemC', null, op.math.sqrt(op.col('PlayerAge'))) + ] + ) + ) + ) + ]) + db.rows.queryAsStream(output, 'object', { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'reference' }) + .on('data', function(chunk) { + chunks.push(chunk.content.xml); + count++; + }). + on('end', function() { + //console.log(count); + //console.log(JSON.stringify(chunks, null, 2)); + expect(count).to.equal(2); + expect(chunks[0]).to.be.undefined; + expect(chunks[1].contentType).to.equal('application/xml'); + expect(chunks[1].format).to.equal('xml'); + expect(chunks[1].content).to.equal('\nCatcher67 97 116 99 104 101 114255'); + done(); + }, done); + }); + + it('TEST 9 - construct complex JSON and xml node with queryAsStream and complexValues reference', function(done){ + var count = 0; + var str = ''; + const chunks = []; + const plan1 = + op.fromLiterals([ + {rowId: 1, colorId: 1, desc: 'ball'}, + {rowId: 2, colorId: 2, desc: 'square'}, + {rowId: 3, colorId: 1, desc: 'box'}, + {rowId: 4, colorId: 1, desc: 'hoop'}, + {rowId: 5, colorId: 5, desc: 'circle'} + ], 'myItem'); + const plan2 = + op.fromLiterals([ + {colorId: 1, colorDesc: 'red'}, + {colorId: 2, colorDesc: 'blue'}, + {colorId: 3, colorDesc: 'black'}, + {colorId: 4, colorDesc: 'yellow'} + ], 'myColor'); + + const output = + plan1.joinInner(plan2, op.on(op.viewCol('myItem', 'colorId'), op.viewCol('myColor', 'colorId'))) + .select([ + 'rowId', + op.as('myJSON', op.jsonDocument(op.jsonObject([ + op.prop('str', op.jsonString(op.col('desc'))), + op.prop('strFunc', op.jsonString(op.fn.stringToCodepoints(op.col('desc')))), + op.prop('mathFunc', op.jsonNumber(op.math.sqrt(op.col('rowId')))), + op.prop('upper', op.jsonString(op.fn.upperCase(op.viewCol('myItem', 'desc')))), + op.prop('num', op.jsonNumber(op.col('rowId'))), + op.prop('bool', op.jsonBoolean(op.isDefined(op.col('rowId')))), + op.prop('null', op.jsonNull()), + op.prop('array', op.jsonArray([op.jsonString(op.col('desc')), op.jsonNumber(op.col('rowId'))])) + ]))), + op.as('node', op.jsonString(op.col('desc'))), + op.as('kind', op.xdmp.nodeKind(op.col('node'))), + op.as('xml', + op.xmlDocument( + op.xmlElement( + 'root', + op.xmlAttribute('attrA', op.col('rowId')), + [ + op.xmlElement('elemA', null, op.viewCol('myColor', 'colorDesc')), + op.xmlComment(op.fn.concat('this is a comment for ', op.col('desc'))), + op.xmlElement('elemB', null, op.col('desc')) + ] + ) + ) + ) + ]) + .orderBy('rowId') + db.rows.queryAsStream(output, 'object', { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'reference' }) + .on('data', function(chunk) { + chunks.push(chunk.content); + count++; + }). + on('end', function() { + //console.log(count); + //console.log(JSON.stringify(chunks, null, 2)); + expect(count).to.equal(5); + expect(chunks[0].columns[1].name).to.equal('myJSON'); + expect(chunks[0].columns[1].type).to.equal('cid'); + expect(chunks[0].columns[2].name).to.equal('node'); + expect(chunks[0].columns[2].type).to.equal('cid'); + expect(chunks[0].columns[4].name).to.equal('xml'); + expect(chunks[0].columns[4].type).to.equal('cid'); + expect(chunks[1].myJSON.contentType).to.equal('application/json'); + expect(chunks[1].myJSON.format).to.equal('json'); + expect(chunks[1].myJSON.content.str).to.equal('ball'); + expect(chunks[1].node.contentType).to.equal('text/plain'); + expect(chunks[1].node.format).to.equal('text'); + expect(chunks[1].node.content).to.equal('ball'); + expect(chunks[1].kind).to.equal('text'); + expect(chunks[1].xml.contentType).to.equal('application/xml'); + expect(chunks[1].xml.format).to.equal('xml'); + expect(chunks[1].xml.content).to.equal('\nredball'); + done(); + }, done); + }); + +}); diff --git a/test-complete/nodejs-optic-read-file.js b/test-complete/nodejs-optic-read-file.js new file mode 100644 index 00000000..381f2298 --- /dev/null +++ b/test-complete/nodejs-optic-read-file.js @@ -0,0 +1,128 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +const expect = require('chai').expect; +const fs = require('fs'); + +const marklogic = require('../'); + +const connectdef = require('../config-optic/connectdef.js'); + +const db = marklogic.createDatabaseClient(connectdef.plan); +const op = marklogic.planBuilder; + +const planViewsPath = __dirname + '/../config-optic/qa-data/planViews.json'; +const planLexiconsPath = __dirname + '/../config-optic/qa-data/planLexicons.json'; +const planTriplesPath = __dirname + '/../config-optic/qa-data/planTriples.json'; +const planSQLPath = __dirname + '/../config-optic/qa-data/planSQL.json'; +const planSPARQLPath = __dirname + '/../config-optic/qa-data/planSPARQL.json'; + +const planFromViews = fs.readFileSync(planViewsPath, 'utf8'); +const planFromLexicons = fs.readFileSync(planLexiconsPath, 'utf8'); +const planFromTriples = fs.readFileSync(planTriplesPath, 'utf8'); +const planFromSQL = fs.readFileSync(planSQLPath, 'utf8'); +const planFromSPARQL = fs.readFileSync(planSPARQLPath, 'utf8'); + +describe('Nodejs Optic read from file test', function(){ + + it('TEST 1 - read plan views from file', function(done){ + db.rows.query(planFromViews, { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'inline' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(1); + expect(output.rows[0]['myMaster.id']).to.equal(1); + expect(output.rows[0]['myMaster.name']).to.equal('Master 1'); + expect(output.rows[0]['myDetail.id']).to.equal(1); + expect(output.rows[0]['myDetail.name']).to.equal('Detail 1'); + expect(output.rows[0]['myDetail.masterId']).to.equal(1); + done(); + }, done); + }); + + it('TEST 2 - read plan views from file with queryAsStream', function(done){ + let count = 0; + let str = ''; + const chunks = []; + db.rows.queryAsStream(planFromViews, 'chunked', { format: 'json', structure: 'object', columnTypes: 'rows', complexValues: 'inline' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + expect(str).to.equal('{ "columns": [{"name":"myDetail.id"},{"name":"myMaster.id"},{"name":"myDetail.name"},{"name":"myMaster.name"},{"name":"myDetail.masterId"},{"name":"myMaster.date"},{"name":"myDetail.amount"},{"name":"myDetail.color"}], "rows":[ {"myDetail.id":{"type":"xs:integer","value":1},"myMaster.id":{"type":"xs:integer","value":1},"myDetail.name":{"type":"xs:string","value":"Detail 1"},"myMaster.name":{"type":"xs:string","value":"Master 1"},"myDetail.masterId":{"type":"xs:integer","value":1},"myMaster.date":{"type":"xs:date","value":"2015-12-01"},"myDetail.amount":{"type":"xs:double","value":10.01},"myDetail.color":{"type":"xs:string","value":"blue"}}] }'); + done(); + }, done); + }); + + it('TEST 3 - read plan lexicons from file', function(done){ + db.rows.query(planFromLexicons, { format: 'json', structure: 'object', columnTypes: 'header', complexValues: 'inline' }) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.rows.length).to.equal(5); + expect(output.rows[0]['myCity.city']).to.equal('new jersey'); + expect(output.rows[0]['myTeam.cityTeam']).to.equal('nets'); + expect(output.rows[4]['myCity.city']).to.equal('london'); + expect(output.rows[4]['myTeam.cityTeam']).to.equal('arsenal'); + done(); + }, done); + }); + + it('TEST 4 - read plan triples from file', function(done){ + db.rows.query(planFromTriples, { format: 'xml', structure: 'array', columnTypes: 'header', complexValues: 'inline' }) + .then(function(output) { + //console.log(output); + const outputStr = output.toString().trim().replace(/[\n\r]/g, ''); + //console.log(outputStr); + expect(outputStr).to.equal('http://marklogic.com/other/bball/id#101http://marklogic.com/mlb/team/id/00326Phil Greenhttp://marklogic.com/mlb/team/id/003PadresSan Diego'); + done(); + }, done); + }); + + it('TEST 5 - read plan sql from file with queryAsStream', function(done){ + let count = 0; + let str = ''; + const chunks = []; + db.rows.queryAsStream(planFromSQL, 'chunked', { format: 'csv', structure: 'object', columnTypes: 'rows', complexValues: 'inline' }) + .on('data', function(chunk) { + //console.log(chunk.toString()); + str = str + chunk.toString().trim().replace(/[\n\r]/g, ' '); + count++; + }). + on('end', function() { + //console.log(str); + expect(str).to.equal('opticFunctionalTest.detail.id,opticFunctionalTest.master.id,opticFunctionalTest.detail.name,opticFunctionalTest.master.name,opticFunctionalTest.detail.masterId,opticFunctionalTest.master.date,opticFunctionalTest.detail.amount,opticFunctionalTest.detail.color 1,1,Detail 1,Master 1,1,2015-12-01,10.01,blue'); + expect(count).to.equal(1); + done(); + }, done); + }); + + it('TEST 6 - read plan sparql from file', function(done){ + db.rows.query(planFromSPARQL, { format: 'json', structure: 'array', columnTypes: 'rows'}) + .then(function(output) { + //console.log(JSON.stringify(output, null, 2)); + expect(output.length).to.equal(7); + expect(output[0][0].name).to.equal('MySPARQL.industry'); + expect(output[1][0].value).to.equal('Retail/Wholesale'); + expect(output[1][0].type).to.equal('xs:string'); + expect(output[6][2].value).to.equal(614185278.2); + expect(output[6][2].type).to.equal('xs:decimal'); + done(); + }, done); + }); +}); diff --git a/test-complete/nodejs-optimistic-locking-stream.js b/test-complete/nodejs-optimistic-locking-stream.js index 7d67968a..1d227916 100644 --- a/test-complete/nodejs-optimistic-locking-stream.js +++ b/test-complete/nodejs-optimistic-locking-stream.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,9 +62,9 @@ describe('Optimistic locking stream test', function() { var ws = dbWriter.documents.createWriteStream({ uri: '/test/optlock/stream/streamLock1.json', contentType: 'application/json', - versionId: response.versionId + versionId: response.versionId }); - ws.result(function(response) { done(); }, done); + ws.result(function(response) { done(); }, done); ws.write('{"hello": "world"}'); ws.end(); }); @@ -81,7 +81,7 @@ describe('Optimistic locking stream test', function() { }). on('end', function() { done(); - }, done); + }, done); }); /*it('should fail to write without version id', function(done){ @@ -89,13 +89,13 @@ describe('Optimistic locking stream test', function() { then(function(response) { var ws = dbWriter.documents.createWriteStream({ uri: '/test/optlock/stream/streamLock1.json', - contentType: 'application/json' + contentType: 'application/json' }); - ws.result(function(response) { + ws.result(function(response) { ws.write('{"hello": "world"}'); ws.end(); //response.should.equal('SHOULD HAVE FAILED'); - done(); + done(); }, function(error) { error.statusCode.should.equal(403); done(); @@ -129,7 +129,7 @@ describe('Optimistic locking stream test', function() { }, done); }); }); - + it('should fail to apply the patch without version id', function(done){ dbWriter.documents.patch('/test/optlock/doc5.json', p.pathLanguage('jsonpath'), @@ -141,14 +141,14 @@ describe('Optimistic locking stream test', function() { result(function(response) { response.should.be('SHOULD BE FAILED'); done(); - }, function(error) { + }, function(error) { //console.log(error); error.statusCode.should.equal(403); done(); }); }); - + it('should apply the patch with the version id', function(done){ dbWriter.documents.probe('/test/optlock/doc5.json').result(). then(function(response) { @@ -168,7 +168,7 @@ describe('Optimistic locking stream test', function() { }, done); }); }); - + it('should read the patch', function(done){ dbReader.documents.read('/test/optlock/doc5.json'). result(function(response) { @@ -296,7 +296,7 @@ describe('Optimistic locking stream test', function() { result(function(response) { //console.log(JSON.stringify(response, null, 4)); done(); - }, done); + }, done); }); });*/ @@ -310,7 +310,7 @@ describe('Optimistic locking stream test', function() { //console.log(JSON.stringify(response, null, 4)); response[0].content.should.equal('this doc is overwritten'); done(); - }, done); + }, done); }); });*/ @@ -325,7 +325,7 @@ describe('Optimistic locking stream test', function() { //console.log(JSON.stringify(response, null, 4)); response[0].content.title.should.equal('this doc is overwritten'); done(); - }, done); + }, done); }); });*/ diff --git a/test-complete/nodejs-optimistic-locking.js b/test-complete/nodejs-optimistic-locking.js index f9b05277..59be5e49 100644 --- a/test-complete/nodejs-optimistic-locking.js +++ b/test-complete/nodejs-optimistic-locking.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ describe('Optimistic locking test', function() { }, p: 'Vannevar Bush wrote an article for The Atlantic Monthly' } - }, { + }, { uri: '/test/optlock/doc2.json', collections: ['matchCollection1', 'matchCollection2'], contentType: 'application/json', @@ -57,7 +57,7 @@ describe('Optimistic locking test', function() { }, p: 'The Bush article described a device called a Memex' } - }, { + }, { uri: '/test/optlock/doc3.json', collections: ['matchCollection2'], contentType: 'application/json', @@ -71,7 +71,7 @@ describe('Optimistic locking test', function() { }, p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' } - }, { + }, { uri: '/test/optlock/doc4.json', collections: [], contentType: 'application/json', @@ -85,7 +85,7 @@ describe('Optimistic locking test', function() { }, p: 'Vannevar served as a prominent policymaker and public intellectual' } - }, { + }, { uri: '/test/optlock/doc5.json', collections: ['matchList'], contentType: 'application/json', @@ -189,7 +189,7 @@ describe('Optimistic locking test', function() { }, done); }); }); - + it('should fail to apply the patch without version id', function(done){ dbWriter.documents.patch('/test/optlock/doc5.json', p.pathLanguage('jsonpath'), @@ -201,7 +201,7 @@ describe('Optimistic locking test', function() { result(function(response) { response.should.be('SHOULD BE FAILED'); done(); - }, function(error) { + }, function(error) { //console.log(JSON.stringify(error, null, 2)); error.statusCode.should.equal(428); error.body.errorResponse.messageCode.should.equal('RESTAPI-CONTENTNOVERSION'); @@ -210,7 +210,7 @@ describe('Optimistic locking test', function() { }); }); - + it('should apply the patch with the version id', function(done){ dbWriter.documents.probe('/test/optlock/doc5.json').result(). then(function(response) { @@ -230,7 +230,7 @@ describe('Optimistic locking test', function() { }, done); }); }); - + it('should read the patch', function(done){ dbReader.documents.read('/test/optlock/doc5.json'). result(function(response) { @@ -360,7 +360,7 @@ describe('Optimistic locking test', function() { result(function(response) { //console.log(JSON.stringify(response, null, 4)); done(); - }, done); + }, done); }); }); @@ -374,7 +374,7 @@ describe('Optimistic locking test', function() { //console.log(JSON.stringify(response, null, 4)); response[0].content.should.equal('this doc is overwritten'); done(); - }, done); + }, done); }); });*/ @@ -389,7 +389,7 @@ describe('Optimistic locking test', function() { //console.log(JSON.stringify(response, null, 4)); response[0].content.title.should.equal('this doc is overwritten'); done(); - }, done); + }, done); }); }); diff --git a/test-complete/nodejs-pitq-documents.js b/test-complete/nodejs-pitq-documents.js new file mode 100644 index 00000000..7e2c31b4 --- /dev/null +++ b/test-complete/nodejs-pitq-documents.js @@ -0,0 +1,216 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var should = require('should'); + +var testconfig = require('../etc/test-config-qa.js'); + +var marklogic = require('../'); +var q = marklogic.queryBuilder; + +var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); +var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); + +describe('Document PITQ Test', function() { + + var docuri1 = '/pitq/test/doc1.json'; + var docuri2 = '/pitq/test/doc2.json'; + var oldTimestamp = db.createTimestamp('123'); + var zeroTimestamp = db.createTimestamp('0'); + var negativeTimestamp = db.createTimestamp('-1'); + + before(function(done) { + this.timeout(10000); + db.documents.write({ + uri: docuri1, + collections: ['coll0', 'coll1'], + contentType: 'application/json', + quality: 10, + permissions: [ + {'role-name':'app-user', capabilities:['read', 'node-update']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + properties: {prop1:'foo', prop2:25}, + content: {id:12, name:'Jason'} + }, { + uri: docuri2, + collections: ['coll0', 'coll1'], + contentType: 'application/json', + quality: 10, + permissions: [ + {'role-name':'app-user', capabilities:['read', 'node-update']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + properties: {prop1:'bar', prop2:33}, + content: {id:245, name:'Paul'} + }).result(function(response){done();}, done); + }); + + it('read document with different timestamp scenarios', function(done) { + var timestamp = db.createTimestamp(); + // read with correct timestamp + db.documents.read({ + uris: docuri1, + categories:['content'], + timestamp: timestamp + }) + .result(function(response) { + var document = response[0]; + //console.log(JSON.stringify(document, null, 2)); + document.content.name.should.equal('Jason'); + + // read with negative timestamp + return db.documents.read({ + uris: docuri1, + timestamp: negativeTimestamp + }).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL: $0 -1 set-transaction-timestamp'); + + // read with zero timestamp + return db.documents.read({ + uris: docuri1, + timestamp: zeroTimestamp + }).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL0: The value of expression \'$0\' is required to be non-zero in rule: set-transaction-timestamp'); + + // read with old timestamp + return db.documents.read({ + uris: docuri1, + timestamp: oldTimestamp + }).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.containEql('Timestamp too old'); + + // read with correct timestamp again + return db.documents.read({ + uris: docuri1, + timestamp: timestamp + }).result(); + }) + .then(function(response) { + done(); + //console.log(JSON.stringify(document, null, 2)); + var document = response[0]; + document.content.name.should.equal('Jason'); + }, done); + }); + + it('query document with different timestamp scenarios', function(done) { + var timestamp = db.createTimestamp(); + // query with correct timestamp + db.documents.query( + q.where( + q.word('name', 'Jason') + ), + timestamp + ) + .result(function(response) { + var document = response[0]; + //console.log(JSON.stringify(document, null, 2)); + document.content.name.should.equal('Jason'); + + // query with negative timestamp + return db.documents.query( + q.where( + q.word('name', 'Jason') + ), + negativeTimestamp + ).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL: $0 -1 set-transaction-timestamp'); + + // query with zero timestamp + return db.documents.query( + q.where( + q.word('name', 'Jason') + ), + zeroTimestamp + ).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL0: The value of expression \'$0\' is required to be non-zero in rule: set-transaction-timestamp'); + + // query with old timestamp + return db.documents.query( + q.where( + q.word('name', 'Jason') + ), + oldTimestamp + ).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.containEql('Timestamp too old'); + + // query with correct timestamp again + return db.documents.query( + q.where( + q.word('name', 'Jason') + ), + timestamp + ).result(); + }) + .then(function(response) { + done(); + //console.log(JSON.stringify(document, null, 2)); + var document = response[0]; + document.content.name.should.equal('Jason'); + }, done); + }); + + it('should delete the document', function(done) { + db.documents.remove(docuri1).result(function(document) { + document.removed.should.eql(true); + done(); + }, done); + }); + + it('should delete the document', function(done) { + db.documents.remove(docuri2).result(function(document) { + document.removed.should.eql(true); + done(); + }, done); + }); + +}); diff --git a/test-complete/nodejs-pitq-graphs.js b/test-complete/nodejs-pitq-graphs.js new file mode 100644 index 00000000..2c220316 --- /dev/null +++ b/test-complete/nodejs-pitq-graphs.js @@ -0,0 +1,274 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var should = require('should'); + +var fs = require('fs'); +var bigInt = require('big-integer'); +var valcheck = require('core-util-is'); +var concatStream = require('concat-stream'); + +var testconfig = require('../etc/test-config-qa.js'); + +var marklogic = require('../'); +var q = marklogic.queryBuilder; +var t = marklogic.valuesBuilder; + +var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); +var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); +var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); + +describe('Graphs PITQ Test', function() { + + var graphUri = 'marklogic.com/stream/people'; + var graphPath = __dirname + '/data/people.ttl'; + var sparqlPath = __dirname + '/data/people.rq'; + var defGraphUri = 'http://marklogic.com/semantics#default-graph'; + + var oldTimestamp = db.createTimestamp('123'); + var zeroTimestamp = db.createTimestamp('0'); + var negativeTimestamp = db.createTimestamp('-1'); + + it('should write the default graph', function(done){ + this.timeout(10000); + db.graphs.write('text/turtle', fs.createReadStream(graphPath)). + result(function(response){ + //console.log(JSON.stringify(response, null, 2)); + response.defaultGraph.should.equal(true); + done(); + }, done); + }); + + it('read graphs with different timestamp scenarios', function(done) { + this.timeout(30000); + var timestamp = db.createTimestamp(); + // graphs read with correct timestamp + db.graphs.read({ + contentType: 'application/json', + timestamp: timestamp + }) + .result(function(response) { + //console.log(JSON.stringify(response, null, 2)); + var strResponse = JSON.stringify(response); + strResponse.should.containEql('http://people.org/person15'); + + // graphs read with negative timestamp + return db.graphs.read({ + contentType: 'application/json', + timestamp: negativeTimestamp + }).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL: $0 -1 set-transaction-timestamp'); + + // graphs read with zero timestamp + return db.graphs.read({ + contentType: 'application/json', + timestamp: zeroTimestamp + }).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL0: The value of expression \'$0\' is required to be non-zero in rule: set-transaction-timestamp'); + + // graphs read with old timestamp + return db.graphs.read({ + contentType: 'application/json', + timestamp: oldTimestamp + }).result(); + }) + .then(function(response) { + //console.log(JSON.stringify(response, null, 2)); + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.containEql('Timestamp too old'); + + // graphs read with correct timestamp again + return db.graphs.read({ + contentType: 'application/json', + timestamp: timestamp + }).result(); + }) + .then(function(response) { + done(); + //console.log(JSON.stringify(response, null, 2)); + var strResponse = JSON.stringify(response); + strResponse.should.containEql('http://people.org/person15'); + }, done); + }); + + it('list graphs with different timestamp scenarios', function(done) { + this.timeout(10000); + var timestamp = db.createTimestamp(); + // graphs list with correct timestamp + db.graphs.list(timestamp) + .result(function(collections) { + //console.log(JSON.stringify(collections, null, 2)); + collections.some(function(collection){ + return collection === defGraphUri; + }).should.equal(true); + + // graphs list with negative timestamp + return db.graphs.list(negativeTimestamp) + .result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL: $0 -1 set-transaction-timestamp'); + + // graphs list with zero timestamp + return db.graphs.list(zeroTimestamp).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL0: The value of expression \'$0\' is required to be non-zero in rule: set-transaction-timestamp'); + + // graphs list with old timestamp + return db.graphs.list(oldTimestamp).result(); + }) + .then(function(response) { + //console.log(JSON.stringify(response, null, 2)); + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.containEql('Timestamp too old'); + + // graphs list with correct timestamp again + return db.graphs.list(timestamp).result(); + }) + .then(function(collections) { + done(); + //console.log(JSON.stringify(collections, null, 2)); + collections.some(function(collection){ + return collection === defGraphUri; + }).should.equal(true); + }, done); + }); + + it('sparql graphs with different timestamp scenarios', function(done) { + this.timeout(10000); + var timestamp = db.createTimestamp(); + // graphs read with correct timestamp + db.graphs.sparql({ + contentType: 'application/sparql-results+json', + query: fs.createReadStream(sparqlPath), + timestamp: timestamp + }) + .result(function(response) { + //console.log(JSON.stringify(response, null, 2)); + response.should.have.property('head'); + response.head.should.have.property('vars'); + response.head.vars.length.should.equal(2); + response.head.vars[0].should.equal('personName1'); + response.head.vars[1].should.equal('personName2'); + response.should.have.property('results'); + response.results.should.have.property('bindings'); + var strResponse = JSON.stringify(response); + //console.log(strResponse); + strResponse.should.containEql('Person 1'); + strResponse.should.containEql('Person 2'); + + // graphs sparql with negative timestamp + return db.graphs.sparql({ + contentType: 'application/sparql-results+json', + query: fs.createReadStream(sparqlPath), + timestamp: negativeTimestamp + }).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL: $0 -1 set-transaction-timestamp'); + + // graphs sparql with zero timestamp + return db.graphs.sparql({ + contentType: 'application/sparql-results+json', + query: fs.createReadStream(sparqlPath), + timestamp: zeroTimestamp + }).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL0: The value of expression \'$0\' is required to be non-zero in rule: set-transaction-timestamp'); + + // graphs sparql with old timestamp + return db.graphs.sparql({ + contentType: 'application/sparql-results+json', + query: fs.createReadStream(sparqlPath), + timestamp: oldTimestamp + }).result(); + }) + .then(function(response) { + //console.log(JSON.stringify(response, null, 2)); + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.containEql('Timestamp too old'); + + // graphs sparql with correct timestamp again + return db.graphs.sparql({ + contentType: 'application/sparql-results+json', + query: fs.createReadStream(sparqlPath), + timestamp: timestamp + }).result(); + }) + .then(function(response) { + done(); + //console.log(JSON.stringify(response, null, 2)); + response.should.have.property('head'); + response.head.should.have.property('vars'); + response.head.vars.length.should.equal(2); + response.head.vars[0].should.equal('personName1'); + response.head.vars[1].should.equal('personName2'); + response.should.have.property('results'); + response.results.should.have.property('bindings'); + var strResponse = JSON.stringify(response); + //console.log(strResponse); + strResponse.should.containEql('Person 1'); + strResponse.should.containEql('Person 2'); + }, done); + }); + + it('should delete the graph', function(done){ + this.timeout(10000); + db.graphs.remove(). + result(function(response){ + done(); + }, done); + }); + +}); diff --git a/test-complete/nodejs-pitq-values.js b/test-complete/nodejs-pitq-values.js new file mode 100644 index 00000000..0b04b7f4 --- /dev/null +++ b/test-complete/nodejs-pitq-values.js @@ -0,0 +1,225 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var should = require('should'); + +var testconfig = require('../etc/test-config-qa.js'); + +var marklogic = require('../'); +var q = marklogic.queryBuilder; +var t = marklogic.valuesBuilder; + +var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); +var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); +var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); + +describe('Values PITQ Test', function() { + + var oldTimestamp = db.createTimestamp('123'); + var zeroTimestamp = db.createTimestamp('0'); + var negativeTimestamp = db.createTimestamp('-1'); + + before(function(done) { + this.timeout(10000); + db.documents.write({ + uri: '/pitq/query/matchDir/doc1.json', + collections: ['matchCollection1'], + contentType: 'application/json', + content: { + title: 'Vannevar Bush', + popularity: 5, + id: '0011', + date: '2005-01-01', + price: { + amt: 0.1 + }, + values: [{score: 56.7}, {rate: 3}], + p: 'Vannevar Bush wrote an article for The Atlantic Monthly' + } + }, { + uri: '/pitq/query/matchDir/doc2.json', + collections: ['matchCollection1', 'matchCollection2'], + contentType: 'application/json', + content: { + title: 'The Bush article', + popularity: 4, + id: '0012', + date: '2006-02-02', + price: { + amt: 0.12 + }, + values: [{score: 92.45}, {rate: 5}], + p: 'The Bush article described a device called a Memex' + } + }, { + uri: '/pitq/query/matchDir/doc3.json', + collections: ['matchCollection2'], + contentType: 'application/json', + content: { + title: 'For 1945', + popularity: 3, + id: '0013', + date: '2007-03-03', + price: { + amt: 1.23 + }, + values: [{score: 33.56}, {rate: 1}], + p: 'For 1945, the thoughts expressed in the Atlantic Monthly were groundbreaking' + } + }, { + uri: '/pitq/query/matchDir/doc4.json', + collections: [], + contentType: 'application/json', + content: { + title: 'Vannevar served', + popularity: 5, + id: '0024', + date: '2008-04-04', + price: { + amt: 12.34 + }, + values: [{score: 12.34}, {rate: 3}], + p: 'Vannevar served as a prominent policymaker and public intellectual' + } + }, { + uri: '/pitq/query/matchList/doc5.json', + collections: ['matchList'], + contentType: 'application/json', + content: { + title: 'The memex', + popularity: 5, + id: '0026', + date: '2009-05-05', + price: { + amt: 123.45 + }, + values: [{score: 77.678}, {rate: 2}], + p: 'The Memex, unfortunately, had no automated search feature' + } + },{ + uri: '/pitq/query/matchList/doc6.xml', + collections: ['matchList'], + contentType: 'application/xml', + content: 'John' + }, { + uri: '/pitq/query/matchList/doc7.xml', + collections: ['matchList'], + contentType: 'application/xml', + content: 'John0081' + }).result(function(response){done();}, done); + }); + + it('query document with different timestamp scenarios', function(done) { + var timestamp = db.createTimestamp(); + // values read with correct timestamp + db.values.read( + t.fromIndexes( + t.range('score', 'xs:double') + ). + where( + t.word('title', 'bush') + ), + timestamp + ) + .result(function(response) { + //console.log(JSON.stringify(document, null, 2)); + var strData = JSON.stringify(response); + strData.should.containEql('"frequency":1,"distinct-value":["56.7"]'); + strData.should.containEql('"frequency":1,"distinct-value":["92.45"]'); + + // values read with negative timestamp + return db.values.read( + t.fromIndexes( + t.range('score', 'xs:double') + ). + where( + t.word('title', 'bush') + ), + negativeTimestamp + ).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL: $0 -1 set-transaction-timestamp'); + + // values read with zero timestamp + return db.values.read( + t.fromIndexes( + t.range('score', 'xs:double') + ). + where( + t.word('title', 'bush') + ), + zeroTimestamp + ).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.equal('XDMP-RWINVAL0: The value of expression \'$0\' is required to be non-zero in rule: set-transaction-timestamp'); + + // values read with old timestamp + return db.values.read( + t.fromIndexes( + t.range('score', 'xs:double') + ). + where( + t.word('title', 'bush') + ), + oldTimestamp + ).result(); + }) + .then(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.message.should.containEql('Timestamp too old'); + + // values read with correct timestamp again + return db.values.read( + t.fromIndexes( + t.range('score', 'xs:double') + ). + where( + t.word('title', 'bush') + ), + timestamp + ).result(); + }) + .then(function(response) { + done(); + //console.log(JSON.stringify(response, null, 2)); + var strData = JSON.stringify(response); + strData.should.containEql('"frequency":1,"distinct-value":["56.7"]'); + strData.should.containEql('"frequency":1,"distinct-value":["92.45"]'); + }, done); + }); + + it('should delete all documents', function(done){ + dbAdmin.documents.removeAll({ + all: true + }). + result(function(response) { + done(); + }, done); + }); + +}); diff --git a/test-complete/nodejs-process-env.js b/test-complete/nodejs-process-env.js index cc30c3cf..29ed1252 100644 --- a/test-complete/nodejs-process-env.js +++ b/test-complete/nodejs-process-env.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -process.env.NODE_ENV = 'development'; +process.env.NODE_ENV = 'development'; var should = require('should'); @@ -25,7 +25,7 @@ var marklogic = require('../'); var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('Process Env Test', function() { - + before(function(done) { this.timeout(10000); db.documents.write({ @@ -55,5 +55,5 @@ describe('Process Env Test', function() { }); process.env.NODE_ENV = undefined; - + }); diff --git a/test-complete/nodejs-serverprops.js b/test-complete/nodejs-serverprops.js index e167e02e..fcc6664a 100644 --- a/test-complete/nodejs-serverprops.js +++ b/test-complete/nodejs-serverprops.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ describe('Server props test', function(){ it('should read server props', function(done){ dbAdmin.config.serverprops.read().result(function(values) { //console.log(values); - values.debug.should.equal(false); + values.debug.should.equal(false); done(); }, done); }); @@ -43,7 +43,7 @@ describe('Server props test', function(){ it('should read server props after changing it', function(done){ dbAdmin.config.serverprops.read().result(function(values) { //console.log(values); - values.debug.should.equal(true); + values.debug.should.equal(true); done(); }, done); }); diff --git a/test-complete/nodejs-sparql-update.js b/test-complete/nodejs-sparql-update.js index 3e049705..83a46186 100644 --- a/test-complete/nodejs-sparql-update.js +++ b/test-complete/nodejs-sparql-update.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,8 @@ var db = marklogic.createDatabaseClient(testconfig.restWriterConnection); describe('sparql update test', function(){ var graphUri = 'http://marklogic.com/sparqlupdate/people'; var mlGraphUri = 'http://marklogic.com/sparqlupdate/mladd'; - var mlGraphPath = './node-client-api/test-complete/data/mlgraph.ttl'; - var inferGraphPath = './node-client-api/test-complete/data/inferenceData.nt'; + var mlGraphPath = __dirname + '/data/mlgraph.ttl'; + var inferGraphPath = __dirname + '/data/inferenceData.nt'; before('should drop all graphs', function(done){ var myData = "DROP ALL ;" @@ -60,9 +60,9 @@ describe('sparql update test', function(){ }). result(function(response){ //console.log(JSON.stringify(response, null, 2)); - response.defaultGraph.should.equal(true); + response.defaultGraph.should.equal(false); (response.graph === null).should.be.true; - response.graphType.should.equal('default'); + response.graphType.should.equal('inline'); done(); }, done); }); @@ -139,7 +139,7 @@ describe('sparql update test', function(){ response.should.equal('SHOULD HAVE FAILED'); done(); }, function(error) { - //console.log(error); + //console.log(error); error.body.errorResponse.message.should.containEql('XDMP-SPQLGRAPHEXIST'); done(); }); @@ -147,8 +147,8 @@ describe('sparql update test', function(){ it('should write to the existing graph', function(done){ db.graphs.write({ - uri: 'http://marklogic.com/sparqlupdate/people', - contentType: 'text/turtle', + uri: 'http://marklogic.com/sparqlupdate/people', + contentType: 'text/turtle', data: fs.createReadStream(mlGraphPath) }). result(function(response){ @@ -169,7 +169,7 @@ describe('sparql update test', function(){ " ?p ?o .\n" + "}" db.graphs.sparql({ - contentType: 'application/sparql-results+json', + contentType: 'application/sparql-results+json', query: myQuery }). result(function(response){ @@ -218,7 +218,7 @@ describe('sparql update test', function(){ "FROM \n" + "WHERE {?s ?p ?o}" db.graphs.sparql({ - contentType: 'application/sparql-results+json', + contentType: 'application/sparql-results+json', query: myQuery }). result(function(response){ @@ -251,7 +251,7 @@ describe('sparql update test', function(){ response.should.equal('SHOULD HAVE FAILED'); done(); }, function(error) { - //console.log(error); + //console.log(error); error.body.errorResponse.message.should.containEql('Unexpected token syntax error, unexpected {, expecting DELETE or INSERT'); done(); }); @@ -274,7 +274,7 @@ describe('sparql update test', function(){ result(function(response){ //console.log(JSON.stringify(response, null, 2)); response.defaultGraph.should.equal(false); - response.graphType.should.equal('named'); + response.graphType.should.equal('inline'); done(); }, done); }); @@ -298,7 +298,7 @@ describe('sparql update test', function(){ done(); }, function(error) { //console.log(JSON.stringify(error, null, 2)); - error.body.errorResponse.message.should.containEql('Invalid type in optimize: -10 is not a value of type unsignedInt'); + error.body.errorResponse.message.should.containEql('Invalid parameter: optimize parameter not convertible to xs:unsignedLong value: -10'); done(); }); }); @@ -345,7 +345,7 @@ describe('sparql update test', function(){ result(function(response){ //console.log(JSON.stringify(response, null, 2)); response.defaultGraph.should.equal(false); - response.graphType.should.equal('named'); + response.graphType.should.equal('inline'); done(); }, done); }); @@ -354,7 +354,7 @@ describe('sparql update test', function(){ it('should do sparql update on with transaction', function(done){ db.transactions.open({transactionName: 'sparqlUpdateTransaction', timeLimit: 30}) .result(function(response) { - tid = response.txid; + tid = response.txid; var myData = "PREFIX bb: \n" + "INSERT DATA\n" + "{\n" + @@ -363,10 +363,10 @@ describe('sparql update test', function(){ " bb:987 bb:id 987 .\n" + " }\n" + "}" - + return db.graphs.sparqlUpdate({ data: myData, - txid: tid + txid: tid }).result(); }) .then(function(response){ @@ -399,7 +399,7 @@ describe('sparql update test', function(){ "FROM \n" + "WHERE {?s bb:id 987}" db.graphs.sparql({ - contentType: 'application/sparql-results+json', + contentType: 'application/sparql-results+json', query: myQuery }). result(function(response){ @@ -434,7 +434,7 @@ describe('sparql update test', function(){ "FROM \n" + "WHERE {?s bb:id 7878}" db.graphs.sparql({ - contentType: 'application/sparql-results+json', + contentType: 'application/sparql-results+json', query: myQuery }). result(function(response){ @@ -446,8 +446,8 @@ describe('sparql update test', function(){ it('should write graph for inference', function(done){ db.graphs.write({ - uri: 'http://marklogic.com/sparqlupdate/infer', - contentType: 'application/n-triples', + uri: 'http://marklogic.com/sparqlupdate/infer', + contentType: 'application/n-triples', data: fs.createReadStream(inferGraphPath) }). result(function(response){ @@ -475,7 +475,7 @@ describe('sparql update test', function(){ done(); }, done); }); - + it('should create the graph-Bug38274', function(done){ var myData = "CREATE GRAPH ;" db.graphs.sparqlUpdate('CREATE GRAPH ;'). diff --git a/test-complete/nodejs-sparql.js b/test-complete/nodejs-sparql.js index 9811b3d8..c92aff04 100644 --- a/test-complete/nodejs-sparql.js +++ b/test-complete/nodejs-sparql.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('sparql query tests', function () { - var graphPath = './node-client-api/test-complete/data/people.ttl'; - var graphPath1 = './node-client-api/test-complete/data/inferenceData.nt'; - var ttlfile = './node-client-api/test-complete/data/tigers.ttl'; + var graphPath = __dirname + '/data/people.ttl'; + var graphPath1 = __dirname + '/data/inferenceData.nt'; + var ttlfile = __dirname + '/data/tigers.ttl'; var defGraphUri = 'http://marklogic.com/semantics#default-graph'; it('should write the default graph', function (done) { diff --git a/test-complete/nodejs-temporal-advance-lsqt.js b/test-complete/nodejs-temporal-advance-lsqt.js new file mode 100644 index 00000000..87060f91 --- /dev/null +++ b/test-complete/nodejs-temporal-advance-lsqt.js @@ -0,0 +1,312 @@ +/* + * Copyright 2014-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var should = require('should'); + +var testlib = require('../etc/test-lib.js'); +var testconfig = require('../etc/test-config-qa.js'); + +var marklogic = require('../'); + +testconfig.manageAdminConnection.user = "admin"; +testconfig.manageAdminConnection.password = "admin"; +var adminClient = marklogic.createDatabaseClient(testconfig.manageAdminConnection); +var adminManager = testlib.createManager(adminClient); +var db = marklogic.createDatabaseClient(testconfig.restTemporalConnection); +var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); +var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); +var q = marklogic.queryBuilder; +var temporalCollectionName = 'temporalCollectionLsqt'; + +describe('LSQT query (lsqtQuery) Test', function() { + + var docuri = 'temporalDoc.json'; + + before(function(done) { + adminManager.put({ + endpoint: '/manage/v2/databases/'+testconfig.testServerName+'/temporal/collections/lsqt/properties?collection=temporalCollectionLsqt', + body: { + "lsqt-enabled": true, + "automation": { + "enabled": true + } + } + }).result(function(response){done();}) + .catch(done); + }); + + it('should write the document content', function(done) { + db.documents.write({ + uri: docuri, + collections: ['coll0', 'coll1'], + temporalCollection: temporalCollectionName, + contentType: 'application/json', + quality: 10, + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + properties: {prop1:'foo', prop2:25}, + content: { + 'System': { + 'systemStartTime' : "", + 'systemEndTime' : "", + }, + 'Valid': { + 'validStartTime': "2001-01-01T00:00:00Z", + 'validEndTime': "2011-12-31T23:59:59Z" + }, + 'Address': "999 Skyway Park", + 'uri': "javaSingleDoc1.json", + id: 12, + name: 'Jason' + }, + systemTime: '2005-01-01T00:00:01Z' + } + ).result(function(response){done();}, done); + }); + + /*it('should update the document content', function(done) { + db.documents.write({ + uri: docuri, + collections: ['coll0', 'coll1'], + temporalCollection: temporalCollectionName, + contentType: 'application/json', + quality: 10, + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update', 'execute']} + ], + properties: {prop1:'foo updated', prop2:50}, + content: { + 'System': { + 'systemStartTime' : "", + 'systemEndTime' : "", + }, + 'Valid': { + 'validStartTime': "2003-01-01T00:00:00", + 'validEndTime': "2008-12-31T23:59:59" + }, + 'Address': "888 Skyway Park", + 'uri': "javaSingleDoc1.json", + id: 12, + name: 'Jason' + }, + systemTime: '2010-01-01T00:00:01' + }).result(function(response){done();}, done); + });*/ + + + it('should wait for lsqt advancement', function(done) { + setTimeout(function() { + done(); + }, 3000); + }); + + it('should not be able to do lsqt query: ', function(done) { + db.documents.query( + q.where( + q.lsqtQuery(temporalCollectionName, '2007-01-01T00:00:01Z') + ) + ) + .result(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.messageCode.should.equal('TEMPORAL-GTLSQT'); + done(); + }); + }); + + it('should be able to do lsqt query: ', function(done) { + db.documents.query( + q.where( + q.lsqtQuery(temporalCollectionName, '2005-01-01T00:00:01Z') + ) + ) + .result(function(response) { + //console.log(JSON.stringify(response, null, 2)); + response.length.should.equal(1); + response[0].content.System.systemStartTime.should.equal('2005-01-01T00:00:01Z'); + response[0].content.System.systemEndTime.should.equal('9999-12-31T11:59:59Z'); + response[0].content.Valid.validStartTime.should.equal('2001-01-01T00:00:00Z'); + response[0].content.Valid.validEndTime.should.equal('2011-12-31T23:59:59Z'); + done(); + }, done); + }); + + it('should update the document content', function(done) { + db.documents.write({ + uri: docuri, + collections: ['coll0', 'coll1'], + temporalCollection: temporalCollectionName, + contentType: 'application/json', + quality: 10, + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + properties: {prop1:'foo', prop2:25}, + content: { + 'System': { + 'systemStartTime' : "", + 'systemEndTime' : "", + }, + 'Valid': { + 'validStartTime': "2001-01-01T00:00:00Z", + 'validEndTime': "2011-12-31T23:59:59Z" + }, + 'Address': "999 Skyway Park", + 'uri': "javaSingleDoc1.json", + id: 12, + name: 'Chris' + }, + systemTime: '2007-01-01T00:00:01Z' + } + ).result(function(response){done();}, done); + }); + + it('should wait for lsqt advancement', function(done) { + setTimeout(function() { + done(); + }, 3000); + }); + + it('should be able to do lsqt query on both new and old doc', function(done) { + db.documents.query( + q.where( + q.lsqtQuery(temporalCollectionName, '2007-01-01T00:00:01Z') + ) + ) + .result(function(response) { + //console.log(JSON.stringify(response, null, 2)); + response.length.should.equal(2); + response[0].content.System.systemStartTime.should.equal('2005-01-01T00:00:01Z'); + response[0].content.System.systemEndTime.should.equal('2007-01-01T00:00:01Z'); + response[0].content.name.should.equal('Jason'); + response[1].content.System.systemStartTime.should.equal('2007-01-01T00:00:01Z'); + response[1].content.System.systemEndTime.should.equal('9999-12-31T11:59:59Z'); + response[1].content.name.should.equal('Chris'); + done(); + }, done); + }); + + it('should be able to do lsqt query on old doc', function(done) { + db.documents.query( + q.where( + q.lsqtQuery(temporalCollectionName, '2005-01-01T00:00:01') + ) + ) + .result(function(response) { + //console.log(JSON.stringify(response, null, 2)); + response.length.should.equal(1); + response[0].content.System.systemStartTime.should.equal('2005-01-01T00:00:01Z'); + response[0].content.System.systemEndTime.should.equal('2007-01-01T00:00:01Z'); + response[0].content.name.should.equal('Jason'); + done(); + }, done); + }); + + it('should update the document content', function(done) { + db.documents.write({ + uri: docuri, + collections: ['coll0', 'coll1'], + temporalCollection: temporalCollectionName, + contentType: 'application/json', + quality: 10, + permissions: [ + {'role-name':'app-user', capabilities:['read']}, + {'role-name':'app-builder', capabilities:['read', 'update']} + ], + properties: {prop1:'foo', prop2:25}, + content: { + 'System': { + 'systemStartTime' : "", + 'systemEndTime' : "", + }, + 'Valid': { + 'validStartTime': "2001-01-01T00:00:00Z", + 'validEndTime': "2011-12-31T23:59:59Z" + }, + 'Address': "999 Skyway Park", + 'uri': "javaSingleDoc1.json", + id: 12, + name: 'Mark' + }, + systemTime: '2009-01-01T00:00:01Z' + } + ).result(function(response){done();}, done); + }); + + it('should advance the LSQT', function(done) { + dbAdmin.documents.advanceLsqt(temporalCollectionName, 3000) + .result(function(response) { + //console.log(JSON.stringify(response, null, 2)); + response.should.have.property('lsqt'); + response.lsqt.should.not.equal('2009-01-01T00:00:01Z') + done(); + }, done); + }); + + /*it('should wait for lsqt advancement', function(done) { + setTimeout(function() { + done(); + }, 3000); + });*/ + + it('should be able to do lsqt query on new and old doc', function(done) { + db.documents.query( + q.where( + q.lsqtQuery(temporalCollectionName, '2008-12-31T06:00:01Z') + ) + ) + .result(function(response) { + //console.log(JSON.stringify(response, null, 2)); + response.length.should.equal(2); + response[1].content.System.systemStartTime.should.equal('2005-01-01T00:00:01Z'); + response[1].content.System.systemEndTime.should.equal('2007-01-01T00:00:01Z'); + response[1].content.name.should.equal('Jason'); + done(); + }, done); + }); + + it('should not be able to do lsqt query on new advanced lsqt', function(done) { + db.documents.query( + q.where( + q.lsqtQuery(temporalCollectionName, '2009-01-01T00:00:01Z') + ) + ) + .result(function(response) { + response.should.equal('SHOULD HAVE FAILED'); + done(); + }, function(error) { + //console.log(JSON.stringify(error, null, 2)); + error.body.errorResponse.messageCode.should.equal('TEMPORAL-GTLSQT'); + done(); + }); + }); + + after(function(done) { + dbAdmin.documents.removeAll({ + all: true + }). + result(function(response) { + done(); + }) + .catch(done); + }); + +}); diff --git a/test-complete/nodejs-temporal-insert-bulk.js b/test-complete/nodejs-temporal-insert-bulk.js index 7d0c472d..cb31b562 100644 --- a/test-complete/nodejs-temporal-insert-bulk.js +++ b/test-complete/nodejs-temporal-insert-bulk.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,10 +30,10 @@ var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); describe('Temporal insert bulk test', function() { - - var docuri = 'temporalDoc.json'; + + var docuri = 'temporalDoc.json'; var docuri2 = 'nonTemporalDoc.json'; - + before(function(done) { db.documents.write( { @@ -59,7 +59,7 @@ describe('Temporal insert bulk test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } }, @@ -84,7 +84,7 @@ describe('Temporal insert bulk test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc2.json", - id: 12, + id: 12, name: 'Bourne' } } @@ -131,7 +131,7 @@ describe('Temporal insert bulk test', function() { //console.log("Invalid Collection: " + coll); should.equal(false, true); } - } + } done(); }, done); }); @@ -185,7 +185,7 @@ describe('Temporal insert bulk test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); @@ -201,5 +201,5 @@ describe('Temporal insert bulk test', function() { done(); }, done); }); - + }); diff --git a/test-complete/nodejs-temporal-insert-lsqt.js b/test-complete/nodejs-temporal-insert-lsqt.js index 93b701d5..738c5107 100644 --- a/test-complete/nodejs-temporal-insert-lsqt.js +++ b/test-complete/nodejs-temporal-insert-lsqt.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,8 +35,8 @@ var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); describe('Temporal insert lsqt test', function() { - - var docuri = 'temporalDoc.json'; + + var docuri = 'temporalDoc.json'; it('enable lsqt', function(done) { this.timeout(10000); @@ -75,7 +75,7 @@ describe('Temporal insert lsqt test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' }, systemTime: '2010-01-01T00:00:00' @@ -125,7 +125,7 @@ describe('Temporal insert lsqt test', function() { //console.log("Invalid Collection: " + coll); should.equal(false, true); } - } + } done(); }, done); }); @@ -177,7 +177,7 @@ describe('Temporal insert lsqt test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-temporal-insert-transform.js b/test-complete/nodejs-temporal-insert-transform.js index 1e840047..0786f3a0 100644 --- a/test-complete/nodejs-temporal-insert-transform.js +++ b/test-complete/nodejs-temporal-insert-transform.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,15 +33,15 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Temporal insert transform test', function() { - - var docuri = 'temporalDoc.json'; + + var docuri = 'temporalDoc.json'; var docuri2 = 'nonTemporalDoc.json'; var transformName1 = 'flagParam'; - var transformPath1 = './node-client-api/test-complete/data/flagTransform.xqy'; + var transformPath1 = __dirname + '/data/flagTransform.xqy'; var transformName2 = 'timestamp'; - var transformPath2 = './node-client-api/test-complete/data/timestampTransform.js'; + var transformPath2 = __dirname + '/data/timestampTransform.js'; before(function(done) { this.timeout(10000); @@ -85,7 +85,7 @@ describe('Temporal insert transform test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } @@ -116,7 +116,7 @@ describe('Temporal insert transform test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc2.json", - id: 12, + id: 12, name: 'Bourne' } } @@ -164,7 +164,7 @@ describe('Temporal insert transform test', function() { //console.log("Invalid Collection: " + coll); should.equal(false, true); } - } + } done(); }, done); }); @@ -239,7 +239,7 @@ describe('Temporal insert transform test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); @@ -256,5 +256,5 @@ describe('Temporal insert transform test', function() { }) .catch(done); }); - + }); diff --git a/test-complete/nodejs-temporal-insert.js b/test-complete/nodejs-temporal-insert.js index 008db1e7..ff0aa03b 100644 --- a/test-complete/nodejs-temporal-insert.js +++ b/test-complete/nodejs-temporal-insert.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Temporal insert test', function() { - + var docuri = 'temporalDoc.json'; before(function(done) { @@ -59,7 +59,7 @@ describe('Temporal insert test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } @@ -108,7 +108,7 @@ describe('Temporal insert test', function() { //console.log("Invalid Collection: " + coll); should.equal(false, true); } - } + } done(); }, done); }); @@ -160,7 +160,7 @@ describe('Temporal insert test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); @@ -177,5 +177,5 @@ describe('Temporal insert test', function() { }) .catch(done); }); - + }); diff --git a/test-complete/nodejs-temporal-lsqt-query.js b/test-complete/nodejs-temporal-lsqt-query.js index faf9be94..851601d0 100644 --- a/test-complete/nodejs-temporal-lsqt-query.js +++ b/test-complete/nodejs-temporal-lsqt-query.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,9 +31,9 @@ var q = marklogic.queryBuilder; var temporalCollectionName = 'temporalCollectionLsqt'; describe('LSQT query (lsqtQuery) Test', function() { - - var docuri = 'temporalDoc.json'; - + + var docuri = 'temporalDoc.json'; + before(function(done) { adminManager.put({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+'/temporal/collections/lsqt/properties?collection=temporalCollectionLsqt', @@ -47,7 +47,7 @@ describe('LSQT query (lsqtQuery) Test', function() { .catch(done); }); - it('should update the document content', function(done) { + it('should update the document content', function(done) { db.documents.write({ uri: docuri, collections: ['coll0', 'coll1'], @@ -70,7 +70,7 @@ describe('LSQT query (lsqtQuery) Test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' }, systemTime: '2005-01-01T00:00:01' @@ -78,7 +78,7 @@ describe('LSQT query (lsqtQuery) Test', function() { ).result(function(response){done();}, done); }); - it('should update the document content', function(done) { + it('should update the document content', function(done) { db.documents.write({ uri: docuri, collections: ['coll0', 'coll1'], @@ -101,7 +101,7 @@ describe('LSQT query (lsqtQuery) Test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' }, systemTime: '2010-01-01T00:00:01' @@ -109,7 +109,7 @@ describe('LSQT query (lsqtQuery) Test', function() { }); - it('should wait for lsqt advancement', function(done) { + it('should wait for lsqt advancement', function(done) { setTimeout(function() { done(); }, 3000); @@ -142,7 +142,7 @@ describe('LSQT query (lsqtQuery) Test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-temporal-patch.js b/test-complete/nodejs-temporal-patch.js index 3ba2c47c..924af006 100644 --- a/test-complete/nodejs-temporal-patch.js +++ b/test-complete/nodejs-temporal-patch.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,9 +33,9 @@ var q = marklogic.queryBuilder; var p = marklogic.patchBuilder; describe('Temporal patch test', function() { - - var docuri = 'temporalDoc.json'; - + + var docuri = 'temporalDoc.json'; + before(function(done) { this.timeout(10000); dbWriter.documents.write({ @@ -60,7 +60,7 @@ describe('Temporal patch test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } }).result(function(response){done();}) @@ -146,7 +146,7 @@ describe('Temporal patch test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-temporal-period-compare-query.js b/test-complete/nodejs-temporal-period-compare-query.js index aecf8d45..4b785ab0 100644 --- a/test-complete/nodejs-temporal-period-compare-query.js +++ b/test-complete/nodejs-temporal-period-compare-query.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ var q = marklogic.queryBuilder; var temporalCollectionName = 'temporalCollectionLsqt' describe('Temporal period compare query test', function() { - - var docuri = 'temporalDoc.json'; - - before(function(done) { + + var docuri = 'temporalDoc.json'; + + before(function(done) { adminManager.put({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+'/temporal/collections/lsqt/properties?collection=temporalCollectionLsqt', body: { @@ -70,7 +70,7 @@ describe('Temporal period compare query test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' }, systemTime: '2005-01-01T00:00:01' @@ -100,7 +100,7 @@ describe('Temporal period compare query test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' }, systemTime: '2010-01-01T00:00:01' @@ -126,7 +126,7 @@ describe('Temporal period compare query test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-temporal-period-range-query-multiple-axis.js b/test-complete/nodejs-temporal-period-range-query-multiple-axis.js index 896ff32f..d74992cc 100644 --- a/test-complete/nodejs-temporal-period-range-query-multiple-axis.js +++ b/test-complete/nodejs-temporal-period-range-query-multiple-axis.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,9 +30,9 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var q = marklogic.queryBuilder; describe('Temporal period range query multiple axis test', function() { - - var docuri = 'temporalDoc.json'; - + + var docuri = 'temporalDoc.json'; + before(function(done) { db.documents.write({ uri: docuri, @@ -56,14 +56,14 @@ describe('Temporal period range query multiple axis test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } ).result(function(response){done();}, done); }); - it('should update the document content', function(done) { + it('should update the document content', function(done) { db.documents.write({ uri: docuri, collections: ['coll0', 'coll1'], @@ -86,13 +86,13 @@ describe('Temporal period range query multiple axis test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } }).result(function(response){done();}, done); }); - it('should do period range query using aln_contains', function(done) { + it('should do period range query using aln_contains', function(done) { db.documents.query(q.where( q.periodRange(['validTime', 'validTime'], 'aln_contains', [ q.period('2003-01-01T00:00:01', '2008-12-31T23:59:58')]), @@ -112,7 +112,7 @@ describe('Temporal period range query multiple axis test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-temporal-period-range-query.js b/test-complete/nodejs-temporal-period-range-query.js index d3ddb26a..1dd36f77 100644 --- a/test-complete/nodejs-temporal-period-range-query.js +++ b/test-complete/nodejs-temporal-period-range-query.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,9 +30,9 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var q = marklogic.queryBuilder; describe('Temporal period range query test', function() { - - var docuri = 'temporalDoc.json'; - + + var docuri = 'temporalDoc.json'; + before(function(done) { db.documents.write({ uri: docuri, @@ -56,7 +56,7 @@ describe('Temporal period range query test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } @@ -64,7 +64,7 @@ describe('Temporal period range query test', function() { .catch(done); }); - it('should update the document content', function(done) { + it('should update the document content', function(done) { db.documents.write({ uri: docuri, collections: ['coll0', 'coll1'], @@ -87,13 +87,13 @@ describe('Temporal period range query test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } }).result(function(response){done();}, done); }); - it('should do period range query using aln_contains', function(done) { + it('should do period range query using aln_contains', function(done) { db.documents.query(q.where( q.periodRange('validTime', 'aln_contains', q.period('2001-01-01T00:00:01', '2011-12-31T23:59:58')), q.collection('temporalCollection') @@ -112,7 +112,7 @@ describe('Temporal period range query test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-temporal-protect-delete.js b/test-complete/nodejs-temporal-protect-delete.js index 9309d624..67366d8b 100644 --- a/test-complete/nodejs-temporal-protect-delete.js +++ b/test-complete/nodejs-temporal-protect-delete.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Temporal protect delete test', function() { - + var docuri = 'temporalDeleteDoc1.json'; before(function(done) { @@ -59,7 +59,7 @@ describe('Temporal protect delete test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } @@ -109,14 +109,14 @@ describe('Temporal protect delete test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } }).result(function(response) { //console.log(JSON.stringify(response, null, 2)); response.documents[0].uri.should.equal(docuri); done(); - }, done); + }, done); }); it('should verify the document', function(done) { @@ -250,7 +250,7 @@ describe('Temporal protect delete test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); @@ -266,5 +266,5 @@ describe('Temporal protect delete test', function() { done(); }, done); }); - + }); diff --git a/test-complete/nodejs-temporal-protect-update.js b/test-complete/nodejs-temporal-protect-update.js index 2f1b4ee0..ee4b1d79 100644 --- a/test-complete/nodejs-temporal-protect-update.js +++ b/test-complete/nodejs-temporal-protect-update.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Temporal protect update test', function() { - + var docuri = 'temporalUpdateDoc1.json'; var expTime = '2026-11-03T19:56:17.681154-07:00'; @@ -60,7 +60,7 @@ describe('Temporal protect update test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } @@ -110,17 +110,17 @@ describe('Temporal protect update test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } }).result(function(response) { //console.log(response); response.should.equal('SHOULD HAVE FAILED'); done(); - }, function(error) { - //console.log(error); + }, function(error) { + //console.log(error); error.body.errorResponse.message.should.equal('TEMPORAL-PROTECTED: The document temporalUpdateDoc1.json is protected noUpdate'); - done(); + done(); }); }); @@ -286,7 +286,7 @@ describe('Temporal protect update test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); @@ -302,5 +302,5 @@ describe('Temporal protect update test', function() { done(); }, done); }); - + }); diff --git a/test-complete/nodejs-temporal-protect-wipe.js b/test-complete/nodejs-temporal-protect-wipe.js index de21b982..a0c72474 100644 --- a/test-complete/nodejs-temporal-protect-wipe.js +++ b/test-complete/nodejs-temporal-protect-wipe.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Temporal protect wipe test', function() { - + var docuri = 'temporalWipeDoc1.json'; before(function(done) { @@ -59,7 +59,7 @@ describe('Temporal protect wipe test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } @@ -109,14 +109,14 @@ describe('Temporal protect wipe test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } }).result(function(response) { //console.log(JSON.stringify(response, null, 2)); response.documents[0].uri.should.equal(docuri); done(); - }, done); + }, done); }); it('should verify the document', function(done) { @@ -142,7 +142,7 @@ describe('Temporal protect wipe test', function() { response.should.equal('SHOULD HAVE FAILED'); done(); }, function(error) { - //console.log(JSON.stringify(error, null, 2)); + //console.log(JSON.stringify(error, null, 2)); error.body.errorResponse.messageCode.should.equal('TEMPORAL-PROTECTED'); error.body.errorResponse.message.should.containEql('The document temporalWipeDoc1.json is protected noWipe'); done(); @@ -185,17 +185,17 @@ describe('Temporal protect wipe test', function() { }, 'Address': "123 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } }).result(function(response) { //console.log(response); response.should.equal('SHOULD HAVE FAILED'); done(); - }, function(error) { - //console.log(error); + }, function(error) { + //console.log(error); error.body.errorResponse.message.should.equal('TEMPORAL-PROTECTED: The document temporalWipeDoc1.json is protected noUpdate'); - done(); + done(); }); }); @@ -208,7 +208,7 @@ describe('Temporal protect wipe test', function() { //response.should.equal('SHOULD HAVE FAILED'); done(); }, function(error) { - //console.log(JSON.stringify(error, null, 2)); + //console.log(JSON.stringify(error, null, 2)); error.body.errorResponse.messageCode.should.equal('TEMPORAL-COLLECTIONNOTFOUND'); error.body.errorResponse.message.should.containEql('Temporal collection invalidTemporalCollection is not found'); done(); @@ -224,7 +224,7 @@ describe('Temporal protect wipe test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); @@ -240,5 +240,5 @@ describe('Temporal protect wipe test', function() { done(); }, done); }); - + }); diff --git a/test-complete/nodejs-temporal-transaction-commit.js b/test-complete/nodejs-temporal-transaction-commit.js index 96dfdb3a..c29a6a89 100644 --- a/test-complete/nodejs-temporal-transaction-commit.js +++ b/test-complete/nodejs-temporal-transaction-commit.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ describe('Temporal transaction commit test', function() { done(); }, done); }); - + it('should commit the write document', function(done) { db.transactions.open().result(). then(function(response) { @@ -75,12 +75,12 @@ describe('Temporal transaction commit test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } ).result(function(response) {done();}, done); - }) + }) }); it('should read the document before commit if txid matches', function(done) { @@ -120,12 +120,12 @@ describe('Temporal transaction commit test', function() { function(response) { //console.log("response: " + JSON.stringify(response)); done(); - }, + }, function(err) { //console.log("Error: " + err); done(); }); - }); + }); it('should do collection query based on docuri after commit', function(done) { db.documents.query( @@ -138,7 +138,7 @@ describe('Temporal transaction commit test', function() { done(); }, done); }); - + /*after(function(done) { return adminManager.post({ endpoint: '/manage/v2/databases/' + testconfig.testServerName, @@ -148,7 +148,7 @@ describe('Temporal transaction commit test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-temporal-transaction-rollback.js b/test-complete/nodejs-temporal-transaction-rollback.js index 5f7a4fbc..5c4981ef 100644 --- a/test-complete/nodejs-temporal-transaction-rollback.js +++ b/test-complete/nodejs-temporal-transaction-rollback.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ describe('Temporal transaction rollback test', function() { done(); }, done); }); - + it('should commit the write document', function(done) { db.transactions.open().result(). then(function(response) { @@ -75,12 +75,12 @@ describe('Temporal transaction rollback test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } ).result(function(response) {done();}, done); - }) + }) }); it('should read the document before commit if txid matches', function(done) { @@ -120,12 +120,12 @@ describe('Temporal transaction rollback test', function() { function(response) { //console.log("response: " + JSON.stringify(response)); done(); - }, + }, function(err) { //console.log("Error: " + err); done(); }); - }); + }); it('should do collection query based on docuri after commit', function(done) { db.documents.query( @@ -138,7 +138,7 @@ describe('Temporal transaction rollback test', function() { done(); }, done); }); - + /*after(function(done) { return adminManager.post({ endpoint: '/manage/v2/databases/' + testconfig.testServerName, @@ -148,7 +148,7 @@ describe('Temporal transaction rollback test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-temporal-update-lsqt.js b/test-complete/nodejs-temporal-update-lsqt.js index b89eb38a..01589ea2 100644 --- a/test-complete/nodejs-temporal-update-lsqt.js +++ b/test-complete/nodejs-temporal-update-lsqt.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ function validateData(response) { systemEndTime = response[i].content.System.systemEndTime; //console.log("systemStartTime = " + systemStartTime); //console.log("systemEndTime = " + systemEndTime); - + validStartTime = response[i].content.Valid.validStartTime; validEndTime = response[i].content.Valid.validEndTime; //console.log("validStartTime = " + validStartTime); @@ -55,7 +55,7 @@ function validateData(response) { //console.log("Quality: " + quality); var permissions = response[i].permissions; - + if ((validStartTime.indexOf("2003-01-01T00:00:00") !== -1) && (validEndTime.indexOf("2008-12-31T23:59:59") !== -1)) { systemStartTime.should.containEql("2011-01-01T00:00:01"); systemEndTime.should.containEql("9999-12-31T11:59:59Z"); @@ -101,99 +101,99 @@ function validateData(response) { while (resCollections.hasNext()) { String collection = resCollections.next(); System.out.println("Collection = " + collection); - + if (!collection.equals(docId) && - !collection.equals(updateCollectionName) && + !collection.equals(updateCollectionName) && !collection.equals(temporalLsqtCollectionName)) { assertFalse("Collection not what is expected: " + collection, true); } } - + assertTrue("Properties should be empty", metadataHandle.getProperties().isEmpty()); assertTrue("Document permissions difference in size value", actualPermissions.contains("size:3")); - + assertTrue("Document permissions difference in rest-reader permission", actualPermissions.contains("rest-reader:[READ]")); assertTrue("Document permissions difference in rest-writer permission", actualPermissions.contains("rest-writer:[UPDATE]")); assertTrue("Document permissions difference in app-user permission", - (actualPermissions.contains("app-user:[") && actualPermissions.contains("READ") && + (actualPermissions.contains("app-user:[") && actualPermissions.contains("READ") && actualPermissions.contains("UPDATE"))); assertFalse("Document permissions difference in app-user permission", actualPermissions.contains("EXECUTE")); - + assertEquals(quality, 99); - } + } if (validStartTime.contains("2001-01-01T00:00:00") && validEndTime.contains("2003-01-01T00:00:00")) { assertTrue("System start date check failed", (systemStartTime.contains("2011-01-01T00:00:01"))); assertTrue("System start date check failed", (systemEndTime.contains("9999-12-31T23:59:59"))); - + Iterator resCollections = metadataHandle.getCollections().iterator(); while (resCollections.hasNext()) { String collection = resCollections.next(); System.out.println("Collection = " + collection); - + if (!collection.equals(docId) && - !collection.equals(insertCollectionName) && + !collection.equals(insertCollectionName) && !collection.equals(temporalLsqtCollectionName)) { assertFalse("Collection not what is expected: " + collection, true); } } - + assertTrue("Properties should be empty", metadataHandle.getProperties().isEmpty()); assertTrue("Document permissions difference in size value", actualPermissions.contains("size:3")); - + assertTrue("Document permissions difference in rest-reader permission", actualPermissions.contains("rest-reader:[READ]")); assertTrue("Document permissions difference in rest-writer permission", actualPermissions.contains("rest-writer:[UPDATE]")); assertTrue("Document permissions difference in app-user permission", - (actualPermissions.contains("app-user:[") && actualPermissions.contains("READ") && + (actualPermissions.contains("app-user:[") && actualPermissions.contains("READ") && actualPermissions.contains("UPDATE") && actualPermissions.contains("EXECUTE"))); - + assertEquals(quality, 11); - } - - if (validStartTime.contains("2008-12-31T23:59:59") && validEndTime.contains("2011-12-31T23:59:59")) { - // This is the latest document + } + + if (validStartTime.contains("2008-12-31T23:59:59") && validEndTime.contains("2011-12-31T23:59:59")) { + // This is the latest document assertTrue("System start date check failed", (systemStartTime.contains("2011-01-01T00:00:01"))); - assertTrue("System start date check failed", (systemEndTime.contains("9999-12-31T23:59:59"))); + assertTrue("System start date check failed", (systemEndTime.contains("9999-12-31T23:59:59"))); assertTrue("URI should be the doc uri ", record.getUri().equals(docId)); Iterator resCollections = metadataHandle.getCollections().iterator(); while (resCollections.hasNext()) { String collection = resCollections.next(); System.out.println("Collection = " + collection); - + if (!collection.equals(docId) && - !collection.equals(insertCollectionName) && + !collection.equals(insertCollectionName) && !collection.equals(temporalLsqtCollectionName) && !collection.equals(latestCollectionName)) { assertFalse("Collection not what is expected: " + collection, true); } } - - + + assertTrue("Document permissions difference in size value", actualPermissions.contains("size:3")); - + assertTrue("Document permissions difference in rest-reader permission", actualPermissions.contains("rest-reader:[READ]")); assertTrue("Document permissions difference in rest-writer permission", actualPermissions.contains("rest-writer:[UPDATE]")); assertTrue("Document permissions difference in app-user permission", - (actualPermissions.contains("app-user:[") && actualPermissions.contains("READ") && + (actualPermissions.contains("app-user:[") && actualPermissions.contains("READ") && actualPermissions.contains("UPDATE") && actualPermissions.contains("EXECUTE"))); assertEquals(quality, 11); - + validateMetadata(metadataHandle); - } - + } + if (validStartTime.contains("2001-01-01T00:00:00") && validEndTime.contains("2011-12-31T23:59:59")) { assertTrue("System start date check failed", (systemStartTime.contains("2010-01-01T00:00:01"))); assertTrue("System start date check failed", (systemEndTime.contains("2011-01-01T00:00:01"))); @@ -202,30 +202,30 @@ function validateData(response) { while (resCollections.hasNext()) { String collection = resCollections.next(); System.out.println("Collection = " + collection); - + if (!collection.equals(docId) && - !collection.equals(insertCollectionName) && + !collection.equals(insertCollectionName) && !collection.equals(temporalLsqtCollectionName)) { assertFalse("Collection not what is expected: " + collection, true); } - } - + } + assertTrue("Properties should be empty", metadataHandle.getProperties().isEmpty()); assertTrue("Document permissions difference in size value", actualPermissions.contains("size:3")); - + assertTrue("Document permissions difference in rest-reader permission", actualPermissions.contains("rest-reader:[READ]")); assertTrue("Document permissions difference in rest-writer permission", actualPermissions.contains("rest-writer:[UPDATE]")); assertTrue("Document permissions difference in app-user permission", - (actualPermissions.contains("app-user:[") && actualPermissions.contains("READ") && + (actualPermissions.contains("app-user:[") && actualPermissions.contains("READ") && actualPermissions.contains("UPDATE") && actualPermissions.contains("EXECUTE"))); assertEquals(quality, 11); - } - ***/ + } + ***/ } } @@ -237,10 +237,10 @@ function validateData(response) { describe('Temporal update lsqt test', function() { - - var docuri = 'temporalDoc.json'; + + var docuri = 'temporalDoc.json'; var docuri2 = 'nonTemporalDoc.json'; - + before(function(done) { adminManager.put({ endpoint: '/manage/v2/databases/'+testconfig.testServerName+'/temporal/collections/lsqt/properties?collection=temporalCollectionLsqt', @@ -276,7 +276,7 @@ describe('Temporal update lsqt test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' }, systemTime: '2010-01-01T00:00:00' @@ -308,7 +308,7 @@ describe('Temporal update lsqt test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Bourne' }, systemTime: '2011-01-01T00:00:01' @@ -356,7 +356,7 @@ describe('Temporal update lsqt test', function() { //console.log("Invalid Collection: " + coll); should.equal(false, true); } - } + } done(); }, done); }); @@ -516,7 +516,7 @@ describe('Temporal update lsqt test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-temporal-update.js b/test-complete/nodejs-temporal-update.js index 7822c8c8..6b066a0a 100644 --- a/test-complete/nodejs-temporal-update.js +++ b/test-complete/nodejs-temporal-update.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,9 +30,9 @@ var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); var q = marklogic.queryBuilder; describe('Temporal update test', function() { - - var docuri = 'temporalDoc.json'; - + + var docuri = 'temporalDoc.json'; + before(function(done) { this.timeout(20000); db.documents.write({ @@ -57,7 +57,7 @@ describe('Temporal update test', function() { }, 'Address': "999 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } } @@ -86,7 +86,7 @@ describe('Temporal update test', function() { }, 'Address': "888 Skyway Park", 'uri': "javaSingleDoc1.json", - id: 12, + id: 12, name: 'Jason' } }).result(function(response) { @@ -144,7 +144,7 @@ describe('Temporal update test', function() { //console.log("Invalid Collection: " + coll); should.equal(false, true); } - } + } done(); }, done); }); @@ -304,7 +304,7 @@ describe('Temporal update test', function() { }).result().then(function(response) { if (response >= 400) { console.log(response); - } + } done(); }, function(err) { console.log(err); done(); diff --git a/test-complete/nodejs-transform-combine.js b/test-complete/nodejs-transform-combine.js index fb3a5cdd..1de2a1d9 100644 --- a/test-complete/nodejs-transform-combine.js +++ b/test-complete/nodejs-transform-combine.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,15 +33,15 @@ describe('Transform test with combination', function(){ dbWriter.documents.write({ uri: '/test/transform/comboTransform.json', contentType: 'application/json', - content: {title: 'combo'} + content: {title: 'combo'} }). result(function(response){done();}, done); });*/ var transformName1 = 'flagParam'; - var transformPath1 = './node-client-api/test-complete/data/flagTransform.xqy'; + var transformPath1 = __dirname + '/data/flagTransform.xqy'; var transformName2 = 'timestamp'; - var transformPath2 = './node-client-api/test-complete/data/timestampTransform.js'; + var transformPath2 = __dirname + '/data/timestampTransform.js'; it('should write the transform', function(done){ this.timeout(10000); @@ -60,8 +60,8 @@ describe('Transform test with combination', function(){ result(function(response){done();}, done); })); }); - - var uri = '/test/transform/comboTransform.json'; + + var uri = '/test/transform/comboTransform.json'; it('should modify during write and read', function(done){ this.timeout(10000); diff --git a/test-complete/nodejs-transform-empty.js b/test-complete/nodejs-transform-empty.js index 3d79219d..78b6286a 100644 --- a/test-complete/nodejs-transform-empty.js +++ b/test-complete/nodejs-transform-empty.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ describe('Transform test with null output -- issue #147', function(){ uri: '/test/transform/emptyTransform1.json', contentType: 'application/json', quality: 10, - content: {title: 'hello world'} + content: {title: 'hello world'} }, { uri: '/test/transform/emptyTransform2.json', @@ -46,7 +46,7 @@ describe('Transform test with null output -- issue #147', function(){ }); var transformName = 'emptyTransform'; - var transformPath = './node-client-api/test-complete/data/emptyTransform.js'; + var transformPath = __dirname + '/data/emptyTransform.js'; it('should write the transform', function(done){ this.timeout(10000); @@ -57,8 +57,8 @@ describe('Transform test with null output -- issue #147', function(){ })); }); - var uri1 = '/test/transform/emptyTransform1.json'; - var uri2 = '/test/transform/emptyTransform2.json'; + var uri1 = '/test/transform/emptyTransform1.json'; + var uri2 = '/test/transform/emptyTransform2.json'; it('should return null transform and metadata during read', function(done){ db.documents.read({ @@ -86,9 +86,9 @@ describe('Transform test with null output -- issue #147', function(){ contentType: 'application/json', quality: 20, content: {title: 'hi there'}, - transform: transformName + transform: transformName }, - { + { uri: '/test/transform/emptyTransform4.json', contentType: 'application/json', quality: 25, @@ -101,8 +101,8 @@ describe('Transform test with null output -- issue #147', function(){ }, done); }); - var uri3 = '/test/transform/emptyTransform3.json'; - var uri4 = '/test/transform/emptyTransform4.json'; + var uri3 = '/test/transform/emptyTransform3.json'; + var uri4 = '/test/transform/emptyTransform4.json'; it('should return null content and metadata on read', function(done){ db.documents.read({ diff --git a/test-complete/nodejs-transform-javascript.js b/test-complete/nodejs-transform-javascript.js index 3144d8ed..c331e7d3 100644 --- a/test-complete/nodejs-transform-javascript.js +++ b/test-complete/nodejs-transform-javascript.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,18 +33,18 @@ describe('Transform test with javascript', function(){ dbWriter.documents.write({ uri: '/test/transform/jstransform.json', contentType: 'application/json', - content: {title: 'transform test with javascript'} + content: {title: 'transform test with javascript'} }, { uri: '/test/transform/jstransform2.json', contentType: 'application/json', - content: {title: 'exapmle test with javascript'} + content: {title: 'exapmle test with javascript'} }). result(function(response){done();}, done); }); var transformName = 'timestamp'; - var transformPath = './node-client-api/test-complete/data/timestampTransform.js'; + var transformPath = __dirname + '/data/timestampTransform.js'; it('should write the transform', function(done){ this.timeout(10000); @@ -62,7 +62,7 @@ describe('Transform test with javascript', function(){ done(); }, done); }); - + it('should list the transform', function(done){ dbAdmin.config.transforms.list(). result(function(response){ @@ -70,8 +70,8 @@ describe('Transform test with javascript', function(){ done(); }, done); }); - - var uri = '/test/transform/jstransform.json'; + + var uri = '/test/transform/jstransform.json'; it('should modify during read', function(done){ db.documents.read({ @@ -97,9 +97,9 @@ describe('Transform test with javascript', function(){ response.length.should.equal(2); done(); }, done); - }); - - + }); + + it('should modify during query', function(){ this.timeout(10000); db.documents.query( diff --git a/test-complete/nodejs-transform-negative.js b/test-complete/nodejs-transform-negative.js index 449314b6..a2130b79 100644 --- a/test-complete/nodejs-transform-negative.js +++ b/test-complete/nodejs-transform-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ describe('Extension library test', function(){ uri: '/test/transform/employee.xml', collections: ['employee'], contentType: 'application/xml', - content: 'John' + content: 'John' }). result(function(response){done();}, done); }); @@ -51,8 +51,8 @@ describe('Extension library test', function(){ done(); }); }); - - var uri = '/test/transform/employee.xml'; + + var uri = '/test/transform/employee.xml'; it('should modify during read -- negative with unistalled tranform', function(done){ db.read({ diff --git a/test-complete/nodejs-transform-params.js b/test-complete/nodejs-transform-params.js index 65ad892a..12c27c58 100644 --- a/test-complete/nodejs-transform-params.js +++ b/test-complete/nodejs-transform-params.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ describe('Transform with params', function(){ uri: '/test/transform/paramTransform1.json', contentType: 'application/json', quality: 10, - content: {title: 'hello world'} + content: {title: 'hello world'} }, { uri: '/test/transform/paramTransform2.json', @@ -46,7 +46,7 @@ describe('Transform with params', function(){ }); var transformName = 'paramTransform'; - var transformPath = './node-client-api/test-complete/data/paramTransform.js'; + var transformPath = __dirname + '/data/paramTransform.js'; it('should write the transform', function(done){ this.timeout(10000); @@ -57,14 +57,14 @@ describe('Transform with params', function(){ })); }); - var uri1 = '/test/transform/paramTransform1.json'; - var uri2 = '/test/transform/paramTransform2.json'; + var uri1 = '/test/transform/paramTransform1.json'; + var uri2 = '/test/transform/paramTransform2.json'; it('should return transformed content and metadata during read', function(done){ db.documents.read({ uris: [uri1, uri2], categories: ['content', 'metadata'], - transform: [transformName, + transform: [transformName, {title: 'new title', myInt: 2, myBool: true} ] }). diff --git a/test-complete/nodejs-transform-save-json-as-xml.js b/test-complete/nodejs-transform-save-json-as-xml.js index 15d263ae..4c6634d1 100644 --- a/test-complete/nodejs-transform-save-json-as-xml.js +++ b/test-complete/nodejs-transform-save-json-as-xml.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,13 +33,13 @@ describe('Transform save json as xml', function(){ dbWriter.documents.write({ uri: '/test/transform/savejsonasxmltransform.xml', contentType: 'application/json', - content: {name: 'bob'} + content: {name: 'bob'} }). result(function(response){done();}, done); }); var transformName = 'to-xml'; - var transformPath = './node-client-api/test-complete/data/to-xml.xqy'; + var transformPath = __dirname + '/data/to-xml.xqy'; it('should write the transform', function(done){ this.timeout(10000); @@ -57,7 +57,7 @@ describe('Transform save json as xml', function(){ done(); }, done); }); - + it('should list the transform', function(done){ dbAdmin.config.transforms.list(). result(function(response){ @@ -65,8 +65,8 @@ describe('Transform save json as xml', function(){ done(); }, done); }); - - var uri = '/test/transform/savejsonasxmltransform.xml'; + + var uri = '/test/transform/savejsonasxmltransform.xml'; it('should modify during read', function(done){ db.documents.read({ diff --git a/test-complete/nodejs-transform-xquery.js b/test-complete/nodejs-transform-xquery.js index 64adf35f..6b96b694 100644 --- a/test-complete/nodejs-transform-xquery.js +++ b/test-complete/nodejs-transform-xquery.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,13 +33,13 @@ describe('Transform test with xquery', function(){ dbWriter.documents.write({ uri: '/test/transform/xquerytransform.json', contentType: 'application/json', - content: {title: 'transform test with xquery'} + content: {title: 'transform test with xquery'} }). result(function(response){done();}, done); }); var transformName = 'flagParam'; - var transformPath = './node-client-api/test-complete/data/flagTransform.xqy'; + var transformPath = __dirname + '/data/flagTransform.xqy'; it('should write the transform', function(done){ this.timeout(10000); @@ -57,7 +57,7 @@ describe('Transform test with xquery', function(){ done(); }, done); }); - + it('should list the transform', function(done){ dbAdmin.config.transforms.list(). result(function(response){ @@ -65,8 +65,8 @@ describe('Transform test with xquery', function(){ done(); }, done); }); - - var uri = '/test/transform/xquerytransform.json'; + + var uri = '/test/transform/xquerytransform.json'; it('should modify during read', function(done){ db.documents.read({ diff --git a/test-complete/nodejs-transform-xslt.js b/test-complete/nodejs-transform-xslt.js index 10171c21..b3d494b9 100644 --- a/test-complete/nodejs-transform-xslt.js +++ b/test-complete/nodejs-transform-xslt.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,13 +34,13 @@ describe('Transform test', function(){ uri: '/test/transform/employee.xml', collections: ['employee'], contentType: 'application/xml', - content: 'John' + content: 'John' }). result(function(response){done();}, done); }); var transformName = 'employeeStylesheet'; - var transformPath = './node-client-api/test-complete/data/employeeStylesheet.xslt'; + var transformPath = __dirname + '/data/employeeStylesheet.xslt'; it('should write the transform', function(done){ this.timeout(10000); @@ -58,7 +58,7 @@ describe('Transform test', function(){ done(); }, done); }); - + it('should list the transform', function(done){ dbAdmin.config.transforms.list(). result(function(response){ @@ -66,8 +66,8 @@ describe('Transform test', function(){ done(); }, done); }); - - var uri = '/test/transform/employee.xml'; + + var uri = '/test/transform/employee.xml'; it('should modify during read', function(done){ db.documents.read({ @@ -102,7 +102,7 @@ describe('Transform test', function(){ uri: '/test/transform/write/xslttransform.xml', contentType: 'application/xml', collections: ['employee'], - content: 'John', + content: 'John', transform: transformName }). result(function(response) { diff --git a/test-complete/nodejs-xquery-eval-negative.js b/test-complete/nodejs-xquery-eval-negative.js index 08559aad..609c8653 100644 --- a/test-complete/nodejs-xquery-eval-negative.js +++ b/test-complete/nodejs-xquery-eval-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ describe('Xquery eval negaive test', function(){ it('should fail with non-matching var name', function(done){ dbEval.xqueryEval( 'let $a := 2' + - 'return $sum' + 'return $sum' ). result(function(values) { values.should.equal('SHOULD HAVE FAILED'); @@ -38,7 +38,7 @@ describe('Xquery eval negaive test', function(){ }, function(error) { error.statusCode.should.equal(500); //error.body.should.containEql('XDMP-UNEXPECTED'); - //console.log(error); + //console.log(error); done(); }); }); @@ -47,14 +47,14 @@ describe('Xquery eval negaive test', function(){ dbEval.eval('var num1;' + 'var num2;' + 'num1 + num2;', - {num1:2, num2:3, num3:10} + {num1:2, num2:3, num3:10} ). result(function(values) { var strVal = JSON.stringify(values); strVal.should.equal('[{"format":"text","datatype":"integer","value":5}]'); done(); }, function(error) { - console.log(error); + console.log(error); done(); }); }); @@ -63,14 +63,14 @@ describe('Xquery eval negaive test', function(){ dbEval.eval('var num1;' + 'var num2;' + 'num1 + num3;', - {num1:2, num2:3} + {num1:2, num2:3} ). result(function(values) { values.should.equal('SHOULD HAVE FAILED'); done(); }, function(error) { error.statusCode.should.equal(500); - //console.log(error); + //console.log(error); done(); }); }); diff --git a/test-complete/nodejs-xquery-eval.js b/test-complete/nodejs-xquery-eval.js index 8a81427b..16afd8a4 100644 --- a/test-complete/nodejs-xquery-eval.js +++ b/test-complete/nodejs-xquery-eval.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ describe('Server xquery eval test', function(){ }); it('should do more complex xquery eval with string', function(done){ - dbEval.xqueryEval('let $s := "hello"' + + dbEval.xqueryEval('let $s := "hello"' + 'let $t := "world"' + 'return fn:concat($s, " ", $t)') .result(function(values) { @@ -47,7 +47,7 @@ describe('Server xquery eval test', function(){ }); it('should do more complex xquery eval with xml node', function(done){ - dbEval.xqueryEval('for $i in (1, 2), $j in ("a", "b")' + + dbEval.xqueryEval('for $i in (1, 2), $j in ("a", "b")' + 'return i is {$i} and js is {$j}') .result(function(values) { //console.log(values); @@ -57,7 +57,7 @@ describe('Server xquery eval test', function(){ }); it('should do more complex xquery eval with json', function(done){ - dbEval.xqueryEval('let $object := json:object()' + + dbEval.xqueryEval('let $object := json:object()' + 'let $_ := map:put($object, "a", 111)' + 'return xdmp:to-json($object)') .result(function(values) { diff --git a/test-complete/nodejs-xquery-invoke-params-negative.js b/test-complete/nodejs-xquery-invoke-params-negative.js index 39976c0b..06886ac3 100644 --- a/test-complete/nodejs-xquery-invoke-params-negative.js +++ b/test-complete/nodejs-xquery-invoke-params-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ var dbEval = marklogic.createDatabaseClient(testconfig.restEvaluatorConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Xquery invoke params negative test', function(){ - - var fsPath = './node-client-api/test-complete/data/sourceParamsNegative.xqy'; + + var fsPath = __dirname + '/data/sourceParamsNegative.xqy'; var invokePath = '/ext/invokeTest/sourceParamsNegative.xqy'; before(function(done) { @@ -37,7 +37,7 @@ describe('Xquery invoke params negative test', function(){ }). result(function(response){done();}, done); }); - + after(function(done) { dbAdmin.config.extlibs.remove(invokePath). result(function(response){done();}, done); diff --git a/test-complete/nodejs-xquery-invoke-params.js b/test-complete/nodejs-xquery-invoke-params.js index 1d034b50..df0a5a9b 100644 --- a/test-complete/nodejs-xquery-invoke-params.js +++ b/test-complete/nodejs-xquery-invoke-params.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ var dbEval = marklogic.createDatabaseClient(testconfig.restEvaluatorConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Xquery invoke test', function(){ - - var fsPath = './node-client-api/test-complete/data/sourceParams.xqy'; + + var fsPath = __dirname + '/data/sourceParams.xqy'; var invokePath = '/ext/invokeTest/sourceParams.xqy'; before(function(done) { @@ -37,7 +37,7 @@ describe('Xquery invoke test', function(){ }). result(function(response){done();}, done); }); - + after(function(done) { dbAdmin.config.extlibs.remove(invokePath). result(function(response){done();}, done); diff --git a/test-complete/nodejs-xquery-invoke-simple-negative.js b/test-complete/nodejs-xquery-invoke-simple-negative.js index 91c3509d..4670f9e1 100644 --- a/test-complete/nodejs-xquery-invoke-simple-negative.js +++ b/test-complete/nodejs-xquery-invoke-simple-negative.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ var dbEval = marklogic.createDatabaseClient(testconfig.restEvaluatorConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Xquery invoke simple negative test', function(){ - - var fsPath = './node-client-api/test-complete/data/sourceSimpleNegative.xqy'; + + var fsPath = __dirname + '/data/sourceSimpleNegative.xqy'; var invokePath = '/ext/invokeTest/sourceSimpleNegative.xqy'; before(function(done) { @@ -37,7 +37,7 @@ describe('Xquery invoke simple negative test', function(){ }). result(function(response){done();}, done); }); - + after(function(done) { dbAdmin.config.extlibs.remove(invokePath). result(function(response){done();}, done); diff --git a/test-complete/nodejs-xquery-invoke-simple.js b/test-complete/nodejs-xquery-invoke-simple.js index 83ffe463..c84fc147 100644 --- a/test-complete/nodejs-xquery-invoke-simple.js +++ b/test-complete/nodejs-xquery-invoke-simple.js @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 MarkLogic Corporation + * Copyright 2014-2018 MarkLogic Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ var dbEval = marklogic.createDatabaseClient(testconfig.restEvaluatorConnection); var dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Xquery invoke test', function(){ - - var fsPath = './node-client-api/test-complete/data/sourceSimple.xqy'; + + var fsPath = __dirname + '/data/sourceSimple.xqy'; var invokePath = '/ext/invokeTest/sourceSimple.xqy'; before(function(done) { @@ -37,7 +37,7 @@ describe('Xquery invoke test', function(){ }). result(function(response){done();}, done); }); - + after(function(done) { dbAdmin.config.extlibs.remove(invokePath). result(function(response){done();}, done);