diff --git a/.gitignore b/.gitignore index 6aeaf8f8e..378959f7b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,6 @@ cover_html .splunkrc *.zip test_logs/* -docs/ \ No newline at end of file +docs/ +.vscode/ +*.tgz \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9e6c0ed3f..9ddcbb884 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,21 +2,17 @@ ## How to contribute -If you would like to contribute to this project, go here for more information: - -* [Splunk and open source][contributions] -* [Individual contributions][indivcontrib] -* [Company contributions][companycontrib] +If you would like to contribute to this project, see [Contributions to Splunk][indivcontrib] for more information. ## Issues & Bug Reports If you're seeing some unexpected behavior with this project, please create an [issue on GitHub][issues] with the following information: -0. Version of this project you're using (ex: 1.7.1) -0. Platform version (ex: Windows Server 2012) -0. Framework version (ex: Node.js 0.10.37) or Browser (ex: Chrome 43.0.2357.81) -0. Splunk version (ex: 6.2.2) -0. Other relevant information (ex: local/remote environment, Splunk network configuration) +1. Version of this project you're using (ex: 1.7.1) +1. Platform version (ex: Windows Server 2012) +1. Framework version (ex: Node.js 0.10.37) or Browser (ex: Chrome 43.0.2357.81) +1. Splunk version (ex: 6.2.2) +1. Other relevant information (ex: local/remote environment, Splunk network configuration) Alternatively, if you have a Splunk question please ask on [Splunk Answers][answers] @@ -26,14 +22,14 @@ We love to see pull requests! To create a pull request: -0. Fill out the [Individual Contributor Agreement][indivcontrib]. -0. Fork [the repository][repo]. -0. Make changes to the **`develop`** branch, preferably with tests. -0. Create a [pull request][pulls] against the **`develop`** branch. +1. Fill out the [Individual Contributor Agreement][indivcontrib]. +1. Fork [the repository][repo]. +1. Make changes to the **`develop`** branch, preferably with tests. +1. Create a [pull request][pulls] against the **`develop`** branch. ## Contact us -You can reach Splunk support at _support@splunk.com_ if you have Splunk related questions. +You can [contact support][contact] if you have Splunk related questions. You can reach the Developer Platform team at _devinfo@splunk.com_. @@ -43,4 +39,5 @@ You can reach the Developer Platform team at _devinfo@splunk.com_. [answers]: http://answers.splunk.com/ [repo]: https://github.com/splunk/splunk-sdk-javascript [issues]: https://github.com/splunk/splunk-sdk-javascript/issues -[pulls]: https://github.com/splunk/splunk-sdk-javascript/pulls \ No newline at end of file +[pulls]: https://github.com/splunk/splunk-sdk-javascript/pulls +[contact]: https://www.splunk.com/en_us/support-and-services.html diff --git a/README.md b/README.md index 104100f15..eec4eb924 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ JavaScript. This SDK supports both server- and client-side JavaScript. ## Requirements -* Node.js v.0.12, or v4 or later. The Splunk SDK for Javascript is tested with Node.js v.0.12, v4.2, and v10.0. +* Node.js v.0.12, or v4 or later. The Splunk SDK for Javascript is tested with Node.js v.0.12, v4.2, and v10.0, as well as with Typescript 3.8. * Splunk Enterprise 6.3.0 or later, or Splunk Cloud. The Splunk SDK for Javascript is tested with Splunk Enterprise 7.0 and 7.2. ## Installation @@ -57,6 +57,12 @@ code: var splunkjs = require('splunk-sdk'); +Or, to include the Splunk SDK in your Typescript project, use the `import` function in your code: + + ```typescript + import * as splunk from "splunk-sdk"; + ``` + ## Usage The following examples show you how to list search jobs using client-side and @@ -110,6 +116,47 @@ jobs: }); }); +### Typescript code example + +This example shows how to use the Splunk SDK for Javascript in a Typescript project: + + ```typescript + import * as splunk from "splunk-sdk"; + + const service = new splunk.Service({username: "admin", password: "changeme"}); + + service.login((err, success) => { + if (err) { + throw err; + } + + console.log("Login was successful: " + success); + service.jobs().fetch((err, jobs) => { + const jobList = jobs.list(); + for(let i = 0; i < jobList.length; i++) { + console.log("Job " + i + ": " + jobList[i].sid); + } + }); + }); + ``` + +Here is a good example of a `tslint.json` configuration that works well with this library and doesn't spit out too many errors, since these are basic Typescript definitions. Note that allowing the `var` keyword, as well as not using arrow functions makes typescript behave less predictably: + + ```json + { + "defaultSeverity": "error", + "extends": [ + "tslint:recommended" + ], + "jsRules": {}, + "rules": { + "no-var-keyword": false, + "only-arrow-functions": false, + "no-console": false + }, + "rulesDirectory": [] + ``` + ## SDK examples The Splunk SDK for JavaScript contains several server- and client-based examples. @@ -251,6 +298,11 @@ To run all the tests and generate JUnit compatible XML in `splunk-sdk-javascript Packaged third-party dependencies (such as test runners) + +/dist +Typescript Definition files + + /docs API reference documentation @@ -364,7 +416,7 @@ If you would like to contribute to the SDK, go here for more information: ### Support 1. You will be granted support if you or your company are already covered under an existing maintenance/support agreement. - Send an email to support@splunk.com and include "Splunk SDK for JavaScript" in the subject line. + Submit a new case in the [Support Portal][contact] and include "Splunk SDK for JavaScript" in the subject line. 2. If you are not covered under an existing maintenance/support agreement, you can find help through the broader community at: